// Generated from src/client by `npm run build` (scripts/build-client.mjs). Do not edit by hand. window.__ModuleLoader__.load({ id: 'dsh-sansheng-liubu', factory: (require) => { const module = { exports: {} } var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/client/index.js var index_exports = {}; __export(index_exports, { apply: () => apply, inject: () => inject }); module.exports = __toCommonJS(index_exports); // src/shared/roles.js var SEAT_IDS = Object.freeze([ "lead", "zhongshu", "shangshu", "menxia", "libu", "hubu", "lipu", "bingbu", "xingbu", "gongbu" ]); var SEATS = Object.freeze({ lead: { id: "lead", label: "丞相", duty: "接需求 · 协调汇报", responsibility: "面向用户承接想法:判断是否需要开工、必要时派给具体部门,并把各部门结果汇总成对用户的一次交付。" }, zhongshu: { id: "zhongshu", label: "中书", duty: "调查 · 澄清 · 规划", responsibility: "先把问题问清、把材料看全,再给出可执行的方案与验收标准草案,不直接产出最终交付物。" }, shangshu: { id: "shangshu", label: "尚书", duty: "分工 · 组织交付", responsibility: "把已经明确的方案拆成部门分工并组织交付;六部直属于尚书这一同级分组,六部之间不是上下级。" }, menxia: { id: "menxia", label: "门下", duty: "审议 · 整体审核", responsibility: "对方案和交付做独立审议,指出风险与不达标处。首版没有门下审核的任务必须如实标注“未审核”。" }, libu: { id: "libu", label: "吏部", duty: "角色 · 技能配置", responsibility: "对角色、技能与编制给出建议;职责不含绕过用户授权去改权限或其他项目设置。" }, hubu: { id: "hubu", label: "户部", duty: "数据 · 表格计算", responsibility: "处理数据、表格与计算,结论应可复算。" }, lipu: { id: "lipu", label: "礼部", duty: "文档 · 内容呈现", responsibility: "负责文档、内容与呈现形式,产出可编辑的源文件。" }, bingbu: { id: "bingbu", label: "兵部", duty: "环境 · 调试部署", responsibility: "负责环境、调试与部署;部署/发布等外部副作用仍服从用户授权与宿主审批。" }, xingbu: { id: "xingbu", label: "刑部", duty: "测试 · 风险检查", responsibility: "做测试与风险检查,给出可追溯的检查结果,而不是一句“已通过”。" }, gongbu: { id: "gongbu", label: "工部", duty: "代码 · 工程产出", responsibility: "负责代码实现与工程产出,交付可编辑源文件与真实检查结果。" } }); var SEAT_GROUPS = Object.freeze({ lead: Object.freeze(["lead"]), sansheng: Object.freeze(["zhongshu", "shangshu", "menxia"]), liubu: Object.freeze(["libu", "hubu", "lipu", "bingbu", "xingbu", "gongbu"]) }); function isSeatId(id) { return SEAT_IDS.includes(id); } function seatOf(id) { return SEATS[id]; } function seatLabel(id) { return SEATS[id]?.label ?? ""; } function seatBySessionId(projects, sessionId) { if (!sessionId || !projects) return void 0; for (const project of Object.values(projects)) { for (const seatId of SEAT_IDS) { if (project?.seats?.[seatId]?.sessionId === sessionId) { return { project, seatId, seat: SEATS[seatId] }; } } } return void 0; } // src/client/workbench.js var UNCHOSEN_MODEL_LABEL = "请选择模型"; var MODEL_SOURCE_LABELS = Object.freeze({ project: "项目覆盖", global: "继承全局默认", deployment: "未选择(回退部署默认)", none: "未选择" }); function modelSourceLabel(source) { return MODEL_SOURCE_LABELS[source] ?? "未选择"; } var SEAT_STATUS_LABELS = Object.freeze({ pending: "待启用", creating: "创建中", bound: "已绑定", failed: "创建失败", missing: "会话缺失" }); var DEFAULT_SEAT_STATUS = "pending"; function seatStatusLabel(status) { if (typeof status !== "string") return "未知状态"; return SEAT_STATUS_LABELS[status] ?? "未知状态"; } function projectStatusLabel(status) { switch (status) { case "pending": return "待启用"; case "provisioning": return "启用中"; case "ready": return "已启用"; case "error": return "启用失败"; default: return "未知状态"; } } function collectModelOptions(models) { const out = []; const seen = /* @__PURE__ */ new Set(); const providers = Array.isArray(models?.providers) ? models.providers : []; for (const entry of providers) { const provider = typeof entry?.provider === "string" ? entry.provider : ""; if (!provider) continue; const list = Array.isArray(entry?.models) ? entry.models : []; for (const item of list) { const model = typeof item?.model === "string" ? item.model : ""; if (!model) continue; const efforts = Array.isArray(item?.reasoningEffort) ? item.reasoningEffort.filter((e) => typeof e === "string" && e.trim() !== "") : []; if (efforts.length > 0) { for (const effort of efforts) { const value = provider + "::" + model + "::" + effort; if (value === "inherit" || seen.has(value)) continue; seen.add(value); out.push({ value, label: model + " · " + effort, provider, model, reasoningEffort: effort }); } } else { const value = provider + "::" + model; if (value === "inherit" || seen.has(value)) continue; seen.add(value); out.push({ value, label: model, provider, model }); } } } return out; } function findModelOption(options, modelValue2) { if (!Array.isArray(options)) return void 0; return options.find((option) => option.value === modelValue2); } function describeModel(model, options) { if (!model || typeof model !== "object" || typeof model.provider !== "string" || typeof model.model !== "string") { return { modelValue: "", modelLabel: UNCHOSEN_MODEL_LABEL }; } const effort = typeof model.reasoningEffort === "string" && model.reasoningEffort ? model.reasoningEffort : void 0; const list = Array.isArray(options) ? options : []; const match = list.find((option) => option.provider === model.provider && option.model === model.model && (option.reasoningEffort ?? void 0) === effort); if (match) return { modelValue: match.value, modelLabel: match.label, modelAvailable: true }; const base = list.find((option) => option.provider === model.provider && option.model === model.model); if (base) return { modelValue: base.value, modelLabel: base.label, modelAvailable: true }; const modelLabel = effort ? model.model + " · " + effort : model.model; const modelValue2 = effort ? model.provider + "::" + model.model + "::" + effort : model.provider + "::" + model.model; return { modelValue: modelValue2, modelLabel, modelAvailable: false }; } function normalizeSeats(seats) { const map = {}; if (Array.isArray(seats)) { for (const seat of seats) { if (seat && typeof seat === "object" && typeof seat.id === "string") map[seat.id] = seat; } } else if (seats && typeof seats === "object") { for (const [id, seat] of Object.entries(seats)) { if (seat && typeof seat === "object") map[id] = { id, ...seat }; } } return map; } function cloneGroups() { const out = {}; for (const key of Object.keys(SEAT_GROUPS)) out[key] = Array.from(SEAT_GROUPS[key]); return out; } function pickSelectedId(requested) { if (typeof requested === "string" && SEAT_IDS.includes(requested)) return requested; return SEAT_IDS[0]; } function hasOwn(obj, key) { return obj !== null && obj !== void 0 && Object.prototype.hasOwnProperty.call(obj, key); } function draftOf(draft, seatId) { if (!draft || typeof draft !== "object") return {}; const entry = draft[seatId]; return entry && typeof entry === "object" ? entry : {}; } function updateDraft(draft, seatId, patch) { const base = draft && typeof draft === "object" ? draft : {}; const previous = base[seatId] && typeof base[seatId] === "object" ? base[seatId] : {}; return { ...base, [seatId]: { ...previous, ...patch ?? {} } }; } function clearDraft(draft, seatId) { if (!draft || typeof draft !== "object" || !hasOwn(draft, seatId)) return draft ?? {}; const next = { ...draft }; delete next[seatId]; return next; } function buildWorkbenchView(view, ui) { const safeView = view && typeof view === "object" ? view : {}; const project = safeView.project && typeof safeView.project === "object" ? safeView.project : {}; const status = typeof project.status === "string" ? project.status : "pending"; const ready = status === "ready"; const seatMap = normalizeSeats(project.seats); const selectedSeatId = pickSelectedId(ui?.selectedSeatId); const models = ui?.models ?? null; const modelOptions = collectModelOptions(models); const draft = ui?.draft ?? null; const seats = SEAT_IDS.map((id) => { const def = SEATS[id]; const rec = seatMap[id] ?? {}; const seatStatus = typeof rec.status === "string" ? rec.status : DEFAULT_SEAT_STATUS; const configured = rec.configuredModel ?? rec.model ?? null; const model = describeModel(configured, modelOptions); const runtime = rec.runtimeState && typeof rec.runtimeState === "object" ? rec.runtimeState : null; return { id, name: def.label, duty: def.duty, status: seatStatus, statusLabel: seatStatusLabel(seatStatus), selected: id === selectedSeatId, modelValue: model.modelValue, modelLabel: model.modelLabel, modelAvailable: model.modelAvailable, modelSource: rec.modelSource ?? (rec.model ? "project" : "none"), modelSourceLabel: modelSourceLabel(rec.modelSource ?? (rec.model ? "project" : "none")), modelSyncStatus: rec.modelSync?.status ?? null, runtimeState: runtime ? runtime.state : null, runtimeLabel: runtime ? runtime.label : null, approvalState: runtime ? runtime.approvalState ?? null : null, bindingStatus: runtime ? runtime.bindingStatus : seatStatus }; }); const seatDef = SEATS[selectedSeatId]; const seatRec = seatMap[selectedSeatId] ?? {}; const draftEntry = draftOf(draft, selectedSeatId); let described; if (hasOwn(draftEntry, "modelValue")) { const raw = draftEntry.modelValue; if (raw === "" || raw === null || raw === void 0) { described = { modelValue: "", modelLabel: UNCHOSEN_MODEL_LABEL }; } else { const match = findModelOption(modelOptions, raw); described = match ? { modelValue: match.value, modelLabel: match.label } : { modelValue: String(raw), modelLabel: String(raw) }; } } else if (hasOwn(draftEntry, "model")) { described = describeModel(draftEntry.model, modelOptions); } else { described = describeModel(seatRec.model ?? null, modelOptions); } const instructions = hasOwn(draftEntry, "instructions") ? draftEntry.instructions : typeof seatRec.instructions === "string" ? seatRec.instructions : ""; const selectedStatus = typeof seatRec.status === "string" ? seatRec.status : DEFAULT_SEAT_STATUS; let boundCount = 0; let sessionCount = 0; for (const id of SEAT_IDS) { const rec = seatMap[id]; if (rec?.status === "bound") boundCount += 1; if (rec?.sessionId) sessionCount += 1; } return { projectTitle: typeof project.name === "string" ? project.name : "", ready, project: { id: project.id ?? "", name: typeof project.name === "string" ? project.name : "", status, statusLabel: projectStatusLabel(status), workspaceId: project.workspaceId ?? null, path: project.path ?? null, seatCount: seats.length, boundCount, sessionCount }, seats, groups: cloneGroups(), selected: { id: selectedSeatId, name: seatDef.label, duty: seatDef.duty, responsibility: seatDef.responsibility, status: selectedStatus, statusLabel: seatStatusLabel(selectedStatus), sessionId: seatRec.sessionId ?? null, modelValue: described.modelValue, modelLabel: described.modelLabel, configuredModel: seatRec.configuredModel ?? seatRec.model ?? null, modelSource: seatRec.modelSource ?? (seatRec.model ? "project" : "none"), modelSourceLabel: modelSourceLabel(seatRec.modelSource ?? (seatRec.model ? "project" : "none")), sessionModel: seatRec.sessionModel ?? null, modelSync: seatRec.modelSync ?? null, modelStatus: seatRec.modelSync?.status ?? null, instructions, modelOptions, dirty: Object.keys(draftEntry).length > 0 } }; } // src/client/master-model.js var MASTER_ACTIVE_COLUMNS = Object.freeze([ { id: "planning", title: "待规划 · 需求池", subtitle: "丞相接单 / 中书拟案", tone: "muted" }, { id: "review", title: "门下复核", subtitle: "方案审议 / 验收复核", tone: "primary" }, { id: "running", title: "六部执行中", subtitle: "尚书派工 · 并行交付", tone: "success" } ]); var MASTER_BLOCKED_COLUMN = Object.freeze({ id: "blocked", title: "阻塞 / 异常", subtitle: "需审批 / 失败 / 重投", tone: "error" }); var MASTER_DONE_COLUMN = Object.freeze({ id: "done", title: "已交付", subtitle: "验收通过归档", tone: "success" }); var PROJECT_DOT_VARS = Object.freeze([ "--chart-1", "--chart-2", "--chart-3", "--primary", "--success", "--warning" ]); var TASK_BLOCK_LABELS = { failed: "执行失败", returned: "已退回", reconfirm: "待重新确认" }; function computeMasterLayoutMode(frameWidth, hasPendingDock) { const w = Number(frameWidth) || 1280; const dockW = hasPendingDock ? w <= 1160 ? 312 : 344 : 0; const boardW = Math.max(0, w - dockW); if (boardW >= 880) return "board4"; if (boardW >= 640) return "board3"; return "list"; } function groupModelChoices(modelsOrOptions) { const options = Array.isArray(modelsOrOptions) ? modelsOrOptions : collectModelOptions(modelsOrOptions); const out = []; const byKey = /* @__PURE__ */ new Map(); for (const option of options) { if (!option || option.value === "inherit") continue; const provider = typeof option.provider === "string" ? option.provider : ""; const model = typeof option.model === "string" ? option.model : ""; if (!provider || !model) continue; const key = provider + "::" + model; if (key === "inherit") continue; let entry = byKey.get(key); if (!entry) { entry = { value: key, label: model, provider, model, efforts: [] }; byKey.set(key, entry); out.push(entry); } if (typeof option.reasoningEffort === "string" && option.reasoningEffort && !entry.efforts.includes(option.reasoningEffort)) { entry.efforts.push(option.reasoningEffort); } } return out; } function modelPartsOf(model) { if (!model || typeof model !== "object" || typeof model.provider !== "string" || typeof model.model !== "string") { return { modelKey: "", effort: "" }; } return { modelKey: model.provider + "::" + model.model, effort: typeof model.reasoningEffort === "string" ? model.reasoningEffort : "" }; } function modelObjectFromParts(modelKey, effort) { const raw = String(modelKey || "").trim(); if (!raw || raw === "inherit") return null; const parts = raw.split("::"); const provider = parts[0]?.trim(); const model = parts[1]?.trim(); if (!provider || !model) return null; const eff = String(effort || parts[2] || "").trim(); return eff ? { provider, model, reasoningEffort: eff } : { provider, model }; } function shortModelName(model) { if (!model || typeof model !== "object" || typeof model.model !== "string" || !model.model.trim()) { return "未选模型"; } const clean = model.model.trim().replace(/^deepseek-/, ""); const effort = typeof model.reasoningEffort === "string" && model.reasoningEffort.trim() ? model.reasoningEffort.trim() : ""; return effort ? clean + " · " + effort : clean; } function classifyTaskColumn(task) { if (!task || typeof task !== "object") return "planning"; if (task.status === "done" || task.stage === "delivered") return "done"; if (task.stage === "menxia_review" || task.stage === "menxia_acceptance" || task.stage === "awaiting_execution_approval" || task.ownerSeatId === "menxia" || task.status === "prepared" || task.status === "waiting_user") { return "review"; } if (task.stage === "zhongshu_draft" || task.status === "draft" || task.ownerSeatId === "zhongshu" || task.ownerSeatId === "lead" && task.stage !== "lead_delivery") { return "planning"; } return "running"; } function detectTaskBlockage(task, childTasks = []) { if (!task || typeof task !== "object") return null; if (task.status === "done" || task.stage === "delivered" || task.status === "cancelled") return null; if (task.workflowBlockage) { return { label: task.workflowBlockage.label || "流程阻塞", reason: task.workflowBlockage.reason || task.blockedReason || "流程推进受阻,请排查后继续", canRedispatch: task.deliveryState === "unknown" && Boolean(task.deliveryId), deliveryId: task.deliveryId || null, targetTaskId: task.id }; } if (task.deliveryState === "unknown") { return { label: "投递结果未知", reason: task.note || task.blockedReason || "投递状态未知,核对会话后可显式重投", canRedispatch: Boolean(task.deliveryId), deliveryId: task.deliveryId || null, targetTaskId: task.id }; } if (["failed", "returned", "reconfirm"].includes(task.status) || task.stage === "reconfirm") { const label = TASK_BLOCK_LABELS[task.status] || (task.stage === "reconfirm" ? "待重新确认" : "任务异常"); return { label, reason: task.blockedReason || task.note || task.reviewNote || "任务异常或需要重新确认", canRedispatch: false, deliveryId: null, targetTaskId: task.id }; } for (const child of childTasks) { if (!child || child.status === "cancelled") continue; if (child.workflowBlockage) { return { label: "子项阻塞", reason: child.workflowBlockage.reason || child.blockedReason || "部门子任务流程受阻", canRedispatch: child.deliveryState === "unknown" && Boolean(child.deliveryId), deliveryId: child.deliveryId || null, targetTaskId: child.id }; } if (child.deliveryState === "unknown") { return { label: "子项阻塞", reason: child.note || child.blockedReason || "部门子任务投递结果未知,可显式重投", canRedispatch: Boolean(child.deliveryId), deliveryId: child.deliveryId || null, targetTaskId: child.id }; } if (child.status === "failed") { return { label: "子项阻塞", reason: child.blockedReason || child.note || child.result || "部门子任务执行失败", canRedispatch: false, deliveryId: null, targetTaskId: child.id }; } } return null; } function normalizeSeatsMap(seats) { const map = {}; if (Array.isArray(seats)) { for (const seat of seats) { if (seat && typeof seat.id === "string") map[seat.id] = seat; } } else if (seats && typeof seats === "object") { for (const [id, seat] of Object.entries(seats)) { if (seat && typeof seat === "object") map[id] = { id, ...seat }; } } return map; } function formatShortElapsed(startTs, endTs, now) { const start = Number(startTs || 0); const end = Number(endTs || now || 0); if (!Number.isFinite(start) || start <= 0 || !Number.isFinite(end) || end <= start) return "—"; const sec = Math.max(1, Math.round((end - start) / 1e3)); if (sec < 60) return sec + "s"; const min = Math.floor(sec / 60); if (min < 60) return min + "m"; const hr = Math.floor(min / 60); const remMin = min % 60; return remMin > 0 ? hr + "h " + remMin + "m" : hr + "h"; } function buildMasterItems(projectBundles, modelsOrOptions, now = Date.now()) { const bundles = Array.isArray(projectBundles) ? projectBundles : []; const items = []; bundles.forEach((bundle, projIndex) => { const proj = bundle?.project?.project ?? bundle?.project ?? bundle; if (!proj || typeof proj.id !== "string" || !proj.id) return; const colorVar = PROJECT_DOT_VARS[projIndex % PROJECT_DOT_VARS.length]; const seatMap = normalizeSeatsMap(proj.seats); const allTasks = (Array.isArray(bundle?.tasks) ? bundle.tasks : []).filter((t) => t && t.status !== "cancelled"); const allReqs = (Array.isArray(bundle?.requirements) ? bundle.requirements : []).filter((r) => r && r.status !== "cancelled"); const allArtifacts = Array.isArray(bundle?.artifacts) ? bundle.artifacts : []; const workflowIds = new Set(allTasks.filter((t) => t.kind === "workflow").map((t) => t.id)); const childrenByParent = /* @__PURE__ */ new Map(); for (const t of allTasks) { if (t.kind === "execution" && t.parentTaskId && workflowIds.has(t.parentTaskId)) { let arr = childrenByParent.get(t.parentTaskId); if (!arr) { arr = []; childrenByParent.set(t.parentTaskId, arr); } arr.push(t); } } const coveredReqKeys = /* @__PURE__ */ new Set(); for (const t of allTasks) { if (t.kind === "workflow" && t.requirementId) { coveredReqKeys.add(t.requirementId + "@" + String(t.requirementRevision ?? "")); } } for (const task of allTasks) { if (task.kind === "execution" && task.parentTaskId && workflowIds.has(task.parentTaskId)) { continue; } const childTasks = childrenByParent.get(task.id) || []; const col = classifyTaskColumn(task); const blockage = detectTaskBlockage(task, childTasks); const seatRec = seatMap[task.ownerSeatId] || null; const seatModel = seatRec?.configuredModel ?? seatRec?.model ?? null; const childIdSet = new Set(childTasks.map((c) => c.id)); const matchedArtifacts = allArtifacts.filter((a) => a && (a.taskId === task.id || a.taskId && childIdSet.has(a.taskId))); const subtasks = childTasks.map((child) => { const childBlock = detectTaskBlockage(child); const childSeat = seatMap[child.ownerSeatId] || null; const st = child.status === "done" ? "done" : childBlock ? "blocked" : child.status === "running" || child.status === "dispatched" ? "running" : "pending"; return { id: child.id, seatId: child.ownerSeatId, title: child.title || child.id, status: st, statusLabel: childBlock ? childBlock.label : SEATS[child.ownerSeatId]?.label || child.status, sessionId: childSeat?.sessionId || null, blockage: childBlock, result: child.result || child.note || "" }; }); const ticker = blockage ? blockage.label + ":" + blockage.reason : col === "done" ? task.deliveryNote || task.result || task.summary || "已完成验收交付" : task.result || task.note || task.blockedReason || task.goal || task.requirement || "等待推进"; items.push({ key: proj.id + "::task::" + task.id, id: task.id, itemKind: "task", projectId: proj.id, projectName: proj.name || proj.id, projectColorVar: colorVar, col, seatId: task.ownerSeatId || "lead", seatStatusLabel: SEAT_STATUS_LABELS[seatRec?.status] || "", title: task.title || task.id, ticker, originalText: task.requirementSnapshot?.originalText || task.requirement || "", goal: task.goal || task.requirement || "", result: task.result || task.deliveryNote || task.summary || "", stage: task.stage || null, status: task.status, blockage, subtasks, progress: subtasks.length > 0 ? { done: childTasks.filter((c) => c.status === "done").length, total: childTasks.length } : null, consultations: Array.isArray(task.consultations) ? task.consultations : [], decisions: Array.isArray(task.decisions) ? task.decisions : [], artifacts: matchedArtifacts, modelLabel: shortModelName(seatModel), durationText: formatShortElapsed(task.dispatchedAt || task.createdAt, task.resultAt, now), updatedAt: Number(task.updatedAt || task.createdAt || 0), rawTask: task, rawRequirement: null }); } for (const req of allReqs) { if (!["discussing", "ready", "returned"].includes(req.status)) continue; const coverKey = req.id + "@" + String(req.revision ?? ""); if (coveredReqKeys.has(coverKey)) continue; const leadSeat = seatMap.lead || null; const leadModel = leadSeat?.configuredModel ?? leadSeat?.model ?? null; const blockage = req.status === "returned" ? { label: "需求退回", reason: req.blockedReason || "已退回,等待与丞相重新确认", canRedispatch: false, deliveryId: null, targetTaskId: null } : null; items.push({ key: proj.id + "::req::" + req.id, id: req.id, itemKind: "requirement", projectId: proj.id, projectName: proj.name || proj.id, projectColorVar: colorVar, col: "planning", seatId: "lead", seatStatusLabel: SEAT_STATUS_LABELS[leadSeat?.status] || "", title: req.title || req.id, ticker: req.summary || req.blockedReason || req.originalText || "待丞相整理或下派中书拟案", originalText: req.originalText || "", goal: req.scope || req.summary || req.originalText || "", result: req.acceptanceCriteria || req.judgementReason || "", stage: null, status: req.status, blockage, subtasks: [], progress: null, consultations: [], decisions: [], artifacts: [], modelLabel: shortModelName(leadModel), durationText: formatShortElapsed(req.updatedAt || req.createdAt, null, now), updatedAt: Number(req.updatedAt || req.createdAt || 0), rawTask: null, rawRequirement: req }); } }); return items; } function sortMasterColumnItems(items) { return [...Array.isArray(items) ? items : []].sort((a, b) => { const ba = a?.blockage ? 1 : 0; const bb = b?.blockage ? 1 : 0; if (ba !== bb) return bb - ba; return Number(b?.updatedAt || 0) - Number(a?.updatedAt || 0); }); } function filterMasterItems(items, { projectFilter = "all", search = "" } = {}) { const list = Array.isArray(items) ? items : []; const q = String(search || "").trim().toLowerCase(); return list.filter((item) => { if (projectFilter && projectFilter !== "all" && item.projectId !== projectFilter) return false; if (!q) return true; const seatLabel2 = SEATS[item.seatId]?.label || item.seatId || ""; const subtaskFields = (item.subtasks || []).flatMap((st) => [ st.id, st.title, SEATS[st.seatId]?.label || st.seatId, st.result ]); const haystack = [item.id, item.title, item.ticker, item.projectName, seatLabel2, item.goal, item.result, ...subtaskFields].filter(Boolean).join(" ").toLowerCase(); return haystack.includes(q); }); } // src/client/transport.js var ROUTE = "api/sansheng"; var SanshengRequestError = class extends Error { constructor(message, code, retryable = true) { super(message); this.name = "SanshengRequestError"; this.code = code || "sansheng/error"; this.retryable = retryable !== false; } }; async function request(endpoint, payload, signal) { let response; try { response = await fetch(ROUTE, { method: "POST", credentials: "same-origin", headers: { "content-type": "application/json" }, body: JSON.stringify({ endpoint, payload: payload ?? null }), signal }); } catch (error) { if (error && error.name === "AbortError") throw error; const detail = error && error.message ? error.message : String(error); throw new SanshengRequestError("无法连接 DSH,请确认它仍在运行(" + detail + ")", "NETWORK"); } if (!response.ok) { throw new SanshengRequestError("HTTP " + response.status, "HTTP_" + response.status); } let result; try { result = await response.json(); } catch (error) { throw new SanshengRequestError("响应不是合法 JSON", "sansheng/bad-response"); } if (!result || result.ok !== true) { const code = result && result.error && result.error.code ? result.error.code : "sansheng/error"; const message = result && result.error && result.error.message ? result.error.message : "请求失败"; const retryable = !(result && result.error && result.error.retryable === false); throw new SanshengRequestError(message, code, retryable); } return result.value; } var transport_default = request; // src/client/workbench-v2.js var import_react = require("react"); var SANSHENG_ORDER = ["zhongshu", "menxia", "shangshu"]; var LIUBU_ORDER = ["libu", "hubu", "lipu", "bingbu", "xingbu", "gongbu"]; var DELIB_SEATS = ["zhongshu", "menxia", "shangshu"]; var AVATAR_MIME = ["image/png", "image/jpeg", "image/webp"]; var AVATAR_MAX_BYTES = 120 * 1024; var TASK_META = { draft: { label: "待派发", tone: "muted" }, dispatched: { label: "已派发", tone: "primary" }, running: { label: "进行中", tone: "primary" }, prepared: { label: "待复核", tone: "warning" }, done: { label: "已完成", tone: "success" }, cancelled: { label: "已取消", tone: "muted" }, failed: { label: "失败", tone: "error" }, waiting_user: { label: "待批准", tone: "warning" }, returned: { label: "已退回", tone: "error" }, reconfirm: { label: "待重确认", tone: "error" } }; var REQ_STATUS_META = { discussing: { label: "商讨中", tone: "primary" }, ready: { label: "待下派", tone: "warning" }, published: { label: "已下派", tone: "success" }, returned: { label: "已退回", tone: "error" }, cancelled: { label: "已取消", tone: "muted" } }; var REQ_JUDGEMENT_LABELS = { can_do: "可立项", needs_discussion: "需商讨", not_now: "暂不可做" }; var WORKFLOW_STAGES = [ { id: "zhongshu_draft", label: "中书拟案" }, { id: "menxia_review", label: "门下审核" }, { id: "awaiting_execution_approval", label: "待批准" }, { id: "shangshu_dispatch", label: "尚书调度" }, { id: "department_exec", label: "六部执行" }, { id: "menxia_acceptance", label: "门下验收" }, { id: "delivered", label: "已交付" } ]; function smallSvg(paths, size = 14) { return (0, import_react.createElement)("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, paths.map((d, idx) => (0, import_react.createElement)("path", { key: idx, d }))); } var RefreshIcon = () => smallSvg(["M21 12a9 9 0 1 1-2.64-6.36", "M21 3v6h-6"], 13); var ChatIcon = () => smallSvg(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"], 13); var PlusIcon = () => smallSvg(["M12 5v14", "M5 12h14"], 13); var SearchIcon = () => (0, import_react.createElement)("svg", { viewBox: "0 0 24 24", width: 14, height: 14, fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", "aria-hidden": "true" }, (0, import_react.createElement)("circle", { cx: 11, cy: 11, r: 8 }), (0, import_react.createElement)("path", { d: "m21 21-4.3-4.3" })); var ChevronDown = (open) => (0, import_react.createElement)("svg", { viewBox: "0 0 24 24", width: 14, height: 14, fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", style: { transform: open ? "rotate(180deg)" : "none", transition: "transform 150ms ease" } }, (0, import_react.createElement)("path", { d: "m6 9 6 6 6-6" })); function pad2(n) { return String(n).padStart(2, "0"); } function dateText(ts) { const n = Number(ts); if (!Number.isFinite(n) || n <= 0) return "—"; const d = new Date(n); return d.getMonth() + 1 + "-" + pad2(d.getDate()) + " " + pad2(d.getHours()) + ":" + pad2(d.getMinutes()); } function durationText(ms) { const n = Number(ms); if (!Number.isFinite(n) || n <= 0) return "—"; const s = Math.round(n / 1e3); const m = Math.floor(s / 60) % 60; const hr = Math.floor(s / 3600); if (hr > 0) return hr + "h " + m + "m"; if (m > 0) return m + "m " + pad2(s % 60) + "s"; return s + "s"; } function taskDurationMs(task) { if (!task) return 0; const st = Number(task.dispatchedAt || task.createdAt || 0); const end = task.resultAt ? Number(task.resultAt) : Date.now(); if (!Number.isFinite(st) || !Number.isFinite(end) || st <= 0 || end <= st) return 0; return end - st; } function shortText(text, max) { const val = String(text || "").replace(/\s+/g, " ").trim(); if (!val) return ""; return val.length > max ? val.slice(0, max - 1) + "…" : val; } function refreshList(value, prev, projectChanged = false) { if (Array.isArray(value)) return value; return projectChanged ? [] : prev; } function seatKind(id) { if (id === "lead") return "总协调"; if (id === "zhongshu") return "方案"; if (id === "menxia") return "审核"; if (id === "shangshu") return "调度"; return "工作"; } function seatTone(seat) { if (!seat) return "muted"; if (seat.status === "missing" || seat.status === "failed" || seat.modelSyncStatus === "failed") return "error"; if (seat.approvalState === "waiting") return "error"; if (seat.runtimeState === "running" || seat.status === "creating") return "success"; return "muted"; } function seatStatusText(seat) { if (!seat) return "待命"; if (seat.status === "missing") return "会话缺失"; if (seat.status === "failed") return "创建失败"; if (seat.modelSyncStatus === "failed") return "同步失败"; if (seat.approvalState === "waiting") return "等待审批"; if (seat.runtimeLabel) return seat.runtimeLabel; if (seat.status === "bound") return "待命"; if (seat.status === "creating") return "开启中"; return "未开启"; } function seatChartVar(seatId) { return seatId === "zhongshu" ? "--ss-chart-1" : seatId === "menxia" ? "--ss-chart-2" : "--ss-chart-3"; } function seatDotTone(seatId) { return seatId === "zhongshu" ? "chart-1" : seatId === "menxia" ? "chart-2" : "chart-3"; } function avatarNode(seatId, avatars, size = 32, activeRing = false) { const custom = avatars?.[seatId]; const colorVar = seatChartVar(seatId); const ring = activeRing ? { boxShadow: "0 0 0 2px var(" + colorVar + ")" } : {}; if (custom?.type === "image" && custom.dataUrl) { return (0, import_react.createElement)("img", { src: custom.dataUrl, alt: (SEATS[seatId]?.label ?? seatId) + "头像", width: size, height: size, style: { width: size, height: size, borderRadius: "50%", objectFit: "cover", flex: "0 0 auto", ...ring } }); } const ch = custom?.type === "char" ? custom.char : (SEATS[seatId]?.label ?? seatId).slice(0, 1); return (0, import_react.createElement)("span", { "aria-hidden": "true", className: "font-seal", style: { width: size, height: size, borderRadius: "50%", background: "color-mix(in srgb, var(" + colorVar + ") 14%, var(--ss-card))", border: "1px solid var(" + colorVar + ")", color: "var(" + colorVar + ")", display: "inline-flex", alignItems: "center", justifyContent: "center", flex: "0 0 auto", fontSize: Math.max(12, Math.round(size * 0.42)), fontWeight: 700, ...ring } }, ch); } async function shrinkAvatar(file) { if (!file || !AVATAR_MIME.includes(file.type)) throw new Error("头像只支持 PNG、JPEG 或 WebP 图片"); const bitmap = await createImageBitmap(file); try { const side = 256; const canvas = document.createElement("canvas"); canvas.width = side; canvas.height = side; const ctx2d = canvas.getContext("2d"); const scale = Math.max(side / bitmap.width, side / bitmap.height); const w = Math.max(1, Math.round(bitmap.width * scale)); const ht = Math.max(1, Math.round(bitmap.height * scale)); ctx2d.drawImage(bitmap, Math.round((side - w) / 2), Math.round((side - ht) / 2), w, ht); for (const q of [0.9, 0.8, 0.7, 0.6, 0.5]) { const dataUrl = canvas.toDataURL("image/jpeg", q); if (Math.floor((dataUrl.length - dataUrl.indexOf(",") - 1) * 3 / 4) <= AVATAR_MAX_BYTES) return dataUrl; } throw new Error("图片压缩后仍超过 120KB,请换一张更简单的图片"); } finally { bitmap.close?.(); } } function WorkbenchV2(props) { const { sessionId, resolveWorkspace, navigateToSession, openRightTab, selectionCache, getLastSeatId, setLastSeatId } = props || {}; const [phase, setPhase] = (0, import_react.useState)("loading"); const [error, setError] = (0, import_react.useState)(null); const [errorRetryable, setErrorRetryable] = (0, import_react.useState)(true); const [notice, setNotice] = (0, import_react.useState)(null); const [view, setView] = (0, import_react.useState)(null); const [models, setModels] = (0, import_react.useState)(null); const [selectedSeatId, setSelectedSeatId] = (0, import_react.useState)(() => { const saved = typeof getLastSeatId === "function" ? getLastSeatId() : null; return SEAT_IDS.includes(saved) ? saved : SEAT_IDS[0]; }); const [tab, setTab] = (0, import_react.useState)("court"); const [inspectorTab, setInspectorTab] = (0, import_react.useState)("overview"); const [seatFilter, setSeatFilter] = (0, import_react.useState)("all"); const [flowSubTab, setFlowSubTab] = (0, import_react.useState)("tasks"); const [queueSearch, setQueueSearch] = (0, import_react.useState)(""); const [expandedConfigSeatId, setExpandedConfigSeatId] = (0, import_react.useState)(null); const [draft, setDraft] = (0, import_react.useState)({}); const [busy, setBusy] = (0, import_react.useState)(false); const [summaryBusy, setSummaryBusy] = (0, import_react.useState)(false); const [memory, setMemory] = (0, import_react.useState)(null); const [memoryEditing, setMemoryEditing] = (0, import_react.useState)(false); const [memoryDraft, setMemoryDraft] = (0, import_react.useState)({ goal: "", constraints: "", acceptance: "", decisions: "" }); const [tasks, setTasks] = (0, import_react.useState)([]); const [requirements, setRequirements] = (0, import_react.useState)([]); const [pendingApprovals, setPendingApprovals] = (0, import_react.useState)([]); const [approvalStatus, setApprovalStatus] = (0, import_react.useState)(null); const [deliberations, setDeliberations] = (0, import_react.useState)([]); const [deliberation, setDeliberation] = (0, import_react.useState)(null); const [delibSelectedId, setDelibSelectedId] = (0, import_react.useState)(null); const [delibDraft, setDelibDraft] = (0, import_react.useState)({ topic: "", taskId: "", requirementId: "", maxRounds: "3" }); const [delibSettingsOpen, setDelibSettingsOpen] = (0, import_react.useState)(false); const [delibBusy, setDelibBusy] = (0, import_react.useState)(false); const [avatarEdit, setAvatarEdit] = (0, import_react.useState)(null); const [agentRuns, setAgentRuns] = (0, import_react.useState)([]); const [artifacts, setArtifacts] = (0, import_react.useState)([]); const [artifactDraft, setArtifactDraft] = (0, import_react.useState)({ title: "", path: "", summary: "" }); const [artifactModalOpen, setArtifactModalOpen] = (0, import_react.useState)(false); const [durationModalOpen, setDurationModalOpen] = (0, import_react.useState)(false); const [selectedTask, setSelectedTask] = (0, import_react.useState)(null); const alive = (0, import_react.useRef)(true); const loadedProjectId = (0, import_react.useRef)(null); const taskAnswerVersion = (0, import_react.useRef)(0); (0, import_react.useEffect)(() => { alive.current = true; return () => { alive.current = false; }; }, []); const loadProject = (0, import_react.useCallback)(async () => { setPhase("loading"); setError(null); setErrorRetryable(true); setNotice(null); if (typeof resolveWorkspace !== "function") { setPhase("no-workspace"); return; } const workspace = resolveWorkspace(); if (!workspace) { setPhase("no-workspace"); return; } try { const projectView = await request("open", { workspaceId: workspace.workspaceId, name: workspace.name, path: workspace.path }); let modelCatalog = null; try { modelCatalog = await request("models"); } catch { } let memoryData = null; try { memoryData = (await request("memory", { projectId: projectView.project.id })).memory; } catch { } const nextProjectId = projectView.project.id; const answerVersion = taskAnswerVersion.current; const [taskRes, artifactRes, requirementRes, approvalRes, delibRes, agentRes] = await Promise.allSettled([ request("tasks", { projectId: nextProjectId }), request("artifacts", { projectId: nextProjectId }), request("requirements", { projectId: nextProjectId }), request("approvals", { projectId: nextProjectId }), request("deliberations", { projectId: nextProjectId }), request("agents", { projectId: nextProjectId }) ]); if (!alive.current) return; const projectChanged = loadedProjectId.current !== nextProjectId; loadedProjectId.current = nextProjectId; setView(projectView); setModels(modelCatalog); setMemory(memoryData); setMemoryDraft({ goal: memoryData?.goal ?? "", constraints: (memoryData?.constraints ?? []).join("\n"), acceptance: (memoryData?.acceptance ?? []).join("\n"), decisions: "" }); if (projectChanged) { setSelectedTask(null); setDelibSelectedId(null); setDeliberation(null); setMemoryEditing(false); } if (projectChanged || taskAnswerVersion.current === answerVersion) { setTasks((prev) => refreshList(taskRes.value?.tasks, prev, projectChanged)); } setArtifacts((prev) => refreshList(artifactRes.value?.artifacts, prev, projectChanged)); setRequirements((prev) => refreshList(requirementRes.value?.requirements, prev, projectChanged)); setPendingApprovals((prev) => refreshList(approvalRes.value?.approvals, prev, projectChanged)); setApprovalStatus(approvalRes.status === "fulfilled" ? approvalRes.value?.status ?? null : { available: false, degraded: true }); const delibList = delibRes.status === "fulfilled" && Array.isArray(delibRes.value?.deliberations) ? delibRes.value.deliberations : []; setDeliberations(delibList); if (agentRes.status === "fulfilled" && Array.isArray(agentRes.value?.runs)) setAgentRuns(agentRes.value.runs); const targetDelibId = delibList.find((x) => x.status === "running")?.id || delibList[0]?.id || null; if (targetDelibId) { try { const full = await request("deliberation", { projectId: nextProjectId, deliberationId: targetDelibId }); if (alive.current && loadedProjectId.current === nextProjectId) setDeliberation(full?.deliberation ?? null); } catch { } } setPhase("ready"); } catch (loadError) { if (!alive.current) return; setError(loadError?.message || "加载失败"); setErrorRetryable(!(loadError && loadError.retryable === false)); setPhase("error"); } }, [resolveWorkspace]); (0, import_react.useEffect)(() => { void loadProject(); }, [loadProject]); const projectId = view?.project?.id || null; const refreshDeliberations = (0, import_react.useCallback)(async () => { if (!projectId) return; const [data, agentsData] = await Promise.allSettled([ request("deliberations", { projectId }), request("agents", { projectId }) ]); if (!alive.current || loadedProjectId.current !== projectId) return; if (agentsData.status === "fulfilled") setAgentRuns(Array.isArray(agentsData.value?.runs) ? agentsData.value.runs : []); const list = Array.isArray(data.value?.deliberations) ? data.value.deliberations : []; setDeliberations(list); const target = delibSelectedId || list.find((item) => item.status === "running")?.id || list[0]?.id || null; if (!target) { setDeliberation(null); return; } const full = await request("deliberation", { projectId, deliberationId: target }); if (!alive.current || loadedProjectId.current !== projectId) return; setDeliberation(full?.deliberation ?? null); }, [projectId, delibSelectedId]); (0, import_react.useEffect)(() => { if (!projectId) return void 0; let disposed = false; let running = false; const tick = async () => { if (disposed || running) return; if (typeof document !== "undefined" && document.visibilityState === "hidden") return; running = true; try { const answerVer = taskAnswerVersion.current; const [projectRes, taskRes, artifactRes, requirementRes, approvalRes] = await Promise.allSettled([ request("project", { projectId }), request("tasks", { projectId }), request("artifacts", { projectId }), request("requirements", { projectId }), request("approvals", { projectId }) ]); if (disposed || !alive.current || loadedProjectId.current !== projectId) return; if (projectRes.value) setView(projectRes.value); if (taskAnswerVersion.current === answerVer) setTasks((prev) => refreshList(taskRes.value?.tasks, prev)); setArtifacts((prev) => refreshList(artifactRes.value?.artifacts, prev)); setRequirements((prev) => refreshList(requirementRes.value?.requirements, prev)); setPendingApprovals((prev) => refreshList(approvalRes.value?.approvals, prev)); setApprovalStatus(approvalRes.status === "fulfilled" ? approvalRes.value?.status ?? null : { available: false, degraded: true }); } finally { running = false; } }; const timer = setInterval(() => { void tick(); }, 4e3); const onVis = () => { if (document.visibilityState === "visible") void tick(); }; if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVis); void tick(); return () => { disposed = true; clearInterval(timer); if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVis); }; }, [projectId]); (0, import_react.useEffect)(() => { if (tab !== "deliberation" || !projectId) return void 0; let disposed = false; let running = false; const tick = async () => { if (disposed || running) return; running = true; try { await refreshDeliberations(); } catch { } finally { running = false; } }; const timer = setInterval(() => { void tick(); }, 1500); void tick(); return () => { disposed = true; clearInterval(timer); }; }, [tab, projectId, refreshDeliberations]); (0, import_react.useEffect)(() => { if (!projectId || !selectionCache) return; const saved = selectionCache.get(projectId); if (saved && SEAT_IDS.includes(saved)) setSelectedSeatId(saved); }, [projectId, selectionCache]); const wb = buildWorkbenchView(view, { selectedSeatId, models, draft }); const seatById = (0, import_react.useMemo)(() => { const map = {}; for (const seat of wb.seats) map[seat.id] = seat; return map; }, [wb.seats]); const seatRecMap = (0, import_react.useMemo)(() => { const raw = view?.project?.seats; const map = {}; if (Array.isArray(raw)) { for (const s of raw) if (s?.id) map[s.id] = s; } else if (raw && typeof raw === "object") { for (const [k, s] of Object.entries(raw)) map[k] = { id: k, ...s }; } return map; }, [view]); const activeChatSeatId = (0, import_react.useMemo)(() => { if (!sessionId) return null; for (const sid of SEAT_IDS) { if (seatRecMap[sid]?.sessionId === sessionId) return sid; } return null; }, [seatRecMap, sessionId]); const groupedChoices = (0, import_react.useMemo)(() => groupModelChoices(wb.selected.modelOptions), [wb.selected.modelOptions]); function selectSeat(id) { if (!id || id === selectedSeatId) return; setSelectedSeatId(id); if (typeof setLastSeatId === "function") setLastSeatId(id); if (projectId && selectionCache) selectionCache.set(projectId, id); } function seatDraftState(seatId) { const seatRec = seatRecMap[seatId] || {}; const dEntry = draftOf(draft, seatId); let modelValue2 = ""; if (Object.prototype.hasOwnProperty.call(dEntry, "modelValue")) { modelValue2 = String(dEntry.modelValue || ""); } else if (Object.prototype.hasOwnProperty.call(dEntry, "model")) { modelValue2 = describeModel(dEntry.model, wb.selected.modelOptions).modelValue; } else { modelValue2 = describeModel(seatRec.model ?? null, wb.selected.modelOptions).modelValue; } const parts = modelValue2.split("::"); const modelKey = parts[0] && parts[1] ? parts[0] + "::" + parts[1] : ""; const effort = parts[2] || ""; const instructions = Object.prototype.hasOwnProperty.call(dEntry, "instructions") ? dEntry.instructions : typeof seatRec.instructions === "string" ? seatRec.instructions : ""; return { modelKey, effort, modelValue: modelValue2, instructions }; } function updateSeatDraftModel(seatId, nextKey, nextEffort) { const val = nextKey ? nextEffort ? nextKey + "::" + nextEffort : nextKey : ""; setDraft((prev) => updateDraft(prev, seatId, { modelValue: val })); } async function saveSeatConfigFor(seatId) { if (!projectId) return; const { modelKey, effort, instructions } = seatDraftState(seatId); const model = modelObjectFromParts(modelKey, effort); if (!model) { setNotice("请先为当前角色选择模型"); return; } setBusy(true); setError(null); setNotice("保存中…"); try { await request("configure", { projectId, seatId, model, instructions }); const next = await request("project", { projectId }); if (!alive.current) return; setView(next); setDraft((prev) => clearDraft(prev, seatId)); setNotice("已保存「" + (SEATS[seatId]?.label || seatId) + "」配置"); } catch (err) { if (alive.current) setError(err?.message || "保存失败"); } finally { if (alive.current) setBusy(false); } } async function setGlobalDefaultFor(seatId) { if (!projectId) return; const { modelKey, effort } = seatDraftState(seatId); const configured = seatRecMap[seatId]?.configuredModel ?? seatRecMap[seatId]?.model ?? null; const model = modelObjectFromParts(modelKey, effort) || configured; if (!model) { setNotice("请先为当前角色选择模型"); return; } setBusy(true); setError(null); try { const res = await request("setGlobalDefault", { seatId, model }); const next = await request("project", { projectId }); if (!alive.current) return; setView(next); setNotice("已将「" + (SEATS[seatId]?.label || seatId) + "」设为全局默认;已同步 " + (res.applied || []).length + " 个项目"); } catch (err) { if (alive.current) setError(err?.message || "设置全局默认失败"); } finally { if (alive.current) setBusy(false); } } async function clearOverrideFor(seatId) { if (!projectId) return; setBusy(true); setError(null); try { await request("configure", { projectId, seatId, model: null }); const next = await request("project", { projectId }); if (!alive.current) return; setView(next); setDraft((prev) => clearDraft(prev, seatId)); setNotice("「" + (SEATS[seatId]?.label || seatId) + "」已恢复继承全局默认"); } catch (err) { if (alive.current) setError(err?.message || "恢复继承失败"); } finally { if (alive.current) setBusy(false); } } async function retrySyncFor(seatId) { if (!projectId) return; setBusy(true); setError(null); try { const res = await request("retrySeatModel", { projectId, seatId }); const next = await request("project", { projectId }); if (!alive.current) return; setView(next); setNotice("模型同步状态:" + (res.sync?.status ?? "unknown")); } catch (err) { if (alive.current) setError(err?.message || "重试同步失败"); } finally { if (alive.current) setBusy(false); } } async function openSeat(seatId) { const seat = seatById[seatId]; if (!projectId || !seat) return; if (seat.status === "missing") { setNotice("「" + seat.name + "」的会话已缺失,点击「重建会话」可恢复"); return; } if (seat.status !== "bound") { setNotice("「" + seat.name + "」尚未开启,请先点击开启"); return; } setBusy(true); setError(null); try { const res = await request("openSeat", { projectId, seatId }); if (!alive.current) return; if (!res?.sessionId) throw new Error("宿主没有返回会话"); navigateToSession?.(res.sessionId); setNotice("已切换到「" + seat.name + "」原生会话"); } catch (err) { if (alive.current) setError(err?.message || "打开会话失败"); if (err?.code === "sansheng/session-missing") { try { const next = await request("project", { projectId }); if (alive.current) setView(next); } catch { } } } finally { if (alive.current) setBusy(false); } } async function enableSeat(seatId) { if (!projectId) return; const seat = seatById[seatId]; setBusy(true); setError(null); setNotice("正在开启「" + (seat?.name || seatId) + "」…"); try { const next = await request("enableSeat", { projectId, seatId }); if (!alive.current) return; setView(next); setNotice("已按需开启「" + (seat?.name || seatId) + "」独立会话"); try { if (typeof openRightTab === "function") openRightTab(); } catch { } } catch (err) { if (alive.current) setError(err?.message || "开启失败"); } finally { if (alive.current) setBusy(false); } } async function rebuildSeat(seatId) { const seat = seatById[seatId]; if (!projectId || !seat) return; const rec = seatRecMap[seatId]; setBusy(true); setError(null); setNotice("正在重建「" + seat.name + "」会话…"); try { const next = await request("rebuildSeat", { projectId, seatId, expectedSessionId: rec?.sessionId || void 0 }); if (!alive.current) return; setView(next); setNotice("已重建「" + seat.name + "」会话(旧历史保留)"); } catch (err) { if (alive.current) setError(err?.message || "重建失败"); } finally { if (alive.current) setBusy(false); } } async function answerApproval(entry, choice) { if (!projectId || !entry || busy) return; setBusy(true); setError(null); try { await request("approvalAnswer", { projectId, seatId: entry.seatId, id: entry.id, sessionId: entry.sessionId, choice }); const data = await request("approvals", { projectId }); if (!alive.current || loadedProjectId.current !== projectId) return; setPendingApprovals((prev) => refreshList(data?.approvals, prev)); setApprovalStatus(data?.status ?? null); setNotice(choice === "allow" ? "已允许审批" : "已拒绝审批"); } catch (err) { if (alive.current) setError(err?.message || "审批应答失败"); } finally { if (alive.current) setBusy(false); } } async function answerDecision(taskId, decisionId, value) { if (!projectId || busy) return; setBusy(true); setError(null); try { await request("taskDecisionAnswer", { projectId, taskId, decisionId, value }); if (!alive.current || loadedProjectId.current !== projectId) return; taskAnswerVersion.current += 1; setTasks((prev) => prev.map((t) => t.id === taskId && Array.isArray(t.decisions) ? { ...t, decisions: t.decisions.map((d) => d.id === decisionId ? { ...d, status: "answered", answer: value } : d) } : t)); setNotice("已提交项目决定"); } catch (err) { if (alive.current && loadedProjectId.current === projectId) setError(err?.message || "项目决定提交失败"); } finally { if (alive.current) setBusy(false); } } async function redispatchTask(task) { if (!projectId || !task?.deliveryId || busy) return; setBusy(true); setError(null); try { const res = await request("taskRedispatch", { projectId, taskId: task.id, expectedDeliveryId: task.deliveryId }); const nextTasks = await request("tasks", { projectId }); if (!alive.current || loadedProjectId.current !== projectId) return; setTasks((prev) => refreshList(nextTasks?.tasks, prev)); const updated = nextTasks?.tasks?.find((x) => x.id === task.id); if (updated) setSelectedTask(updated); setNotice(res?.delivery?.status === "sent" ? "已显式重投此任务并送达席位会话" : "重投状态:" + (res?.delivery?.reason || res?.delivery?.status || "已处理")); } catch (err) { if (alive.current) setError(err?.message || "显式重投失败"); } finally { if (alive.current) setBusy(false); } } async function summarizeByShangshu() { if (!projectId || summaryBusy || busy) return; setSummaryBusy(true); setError(null); try { const res = await request("shangshuSummary", { projectId }); if (!alive.current) return; if (!res?.sessionId) throw new Error("宿主未返回尚书会话"); setNotice("已请尚书汇总当前项目进度,正在前往尚书会话"); navigateToSession?.(res.sessionId); } catch (err) { if (alive.current) setError(err?.message || "尚书汇总请求失败"); } finally { if (alive.current) setSummaryBusy(false); } } async function reloadTasks() { if (!projectId) return; try { const res = await request("tasks", { projectId }); if (alive.current && loadedProjectId.current === projectId) { setTasks((prev) => refreshList(res?.tasks, prev)); setNotice("已同步最新派工队列"); } } catch (err) { if (alive.current) setNotice(err?.message || "刷新失败"); } } async function startDeliberation() { if (!projectId || delibBusy) return; const topic = String(delibDraft.topic || "").trim(); if (!topic) { setError("请先填写议政议题"); return; } setDelibBusy(true); setError(null); try { const maxRounds = delibDraft.maxRounds === "" ? 3 : Number(delibDraft.maxRounds); const data = await request("deliberationStart", { projectId, topic, taskId: delibDraft.taskId || void 0, requirementId: delibDraft.requirementId || void 0, maxRounds, originSessionId: sessionId || void 0 }); if (!alive.current || loadedProjectId.current !== projectId) return; setDelibSelectedId(data.deliberation.id); setDeliberation(data.deliberation); setDelibDraft((prev) => ({ ...prev, topic: "" })); setNotice(data.receipt?.text || "议政已发起,已叫中书。"); await refreshDeliberations(); } catch (err) { if (alive.current) setError(err?.message || "发起议政失败"); } finally { if (alive.current) setDelibBusy(false); } } async function endDeliberation() { const did = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; if (!projectId || !did || delibBusy) return; setDelibBusy(true); setError(null); try { await request("deliberationEnd", { projectId, deliberationId: did }); if (!alive.current) return; setNotice("议政已收束结论"); await refreshDeliberations(); } catch (err) { if (alive.current) setError(err?.message || "收束议政失败"); } finally { if (alive.current) setDelibBusy(false); } } async function stopDeliberation() { const did = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; if (!projectId || !did || delibBusy) return; setDelibBusy(true); setError(null); try { const data = await request("deliberationStop", { projectId, deliberationId: did }); if (!alive.current) return; setDeliberation(data.deliberation); setNotice(data.receipt?.text || "已停止当前议政"); await refreshDeliberations(); } catch (err) { if (alive.current) setError(err?.message || "停止议政失败"); } finally { if (alive.current) setDelibBusy(false); } } async function retryDeliberation() { const did = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; if (!projectId || !did || delibBusy) return; setDelibBusy(true); setError(null); try { const data = await request("deliberationRetry", { projectId, deliberationId: did }); if (!alive.current) return; setDeliberation(data.deliberation); setNotice(data.delivery?.ok ? "已重试当前席位" : "重试未能送达,请查看席位会话"); await refreshDeliberations(); } catch (err) { if (alive.current) setError(err?.message || "重试席位失败"); } finally { if (alive.current) setDelibBusy(false); } } async function saveAvatar(seatId, payload = {}) { if (!projectId) return; setDelibBusy(true); setError(null); try { const data = payload.clear ? await request("clearAvatar", { projectId, seatId }) : await request("setAvatar", { projectId, seatId, ...payload }); if (!alive.current || loadedProjectId.current !== projectId) return; setView((prev) => { if (!prev?.project) return prev; const avatars = { ...prev.project.avatars ?? {} }; if (data.avatar) avatars[seatId] = data.avatar; else delete avatars[seatId]; return { ...prev, project: { ...prev.project, avatars } }; }); setAvatarEdit(null); setNotice(data.avatar ? "头像已更新" : "已恢复默认头像"); } catch (err) { if (alive.current) setError(err?.message || "头像更新失败"); } finally { if (alive.current) setDelibBusy(false); } } async function pickAvatarFile(seatId, file) { try { const dataUrl = await shrinkAvatar(file); await saveAvatar(seatId, { dataUrl }); } catch (err) { if (alive.current) setError(err?.message || "图片处理失败"); } } async function stopAgentRun(run) { if (!projectId || delibBusy) return; setDelibBusy(true); setError(null); try { await request("agentStop", { projectId, runId: run.id, kind: run.kind }); if (!alive.current) return; setNotice("已停止后台子 Agent「" + (run.label || run.seatId) + "」"); await refreshDeliberations(); } catch (err) { if (alive.current) setError(err?.message || "停止失败"); } finally { if (alive.current) setDelibBusy(false); } } async function saveMemory() { if (!projectId || busy) return; setBusy(true); setError(null); try { const res = await request("memoryUpdate", { projectId, expectedRevision: memory?.revision ?? 0, goal: memoryDraft.goal, constraints: memoryDraft.constraints.split("\n").map((x) => x.trim()).filter(Boolean), acceptance: memoryDraft.acceptance.split("\n").map((x) => x.trim()).filter(Boolean), decisions: memoryDraft.decisions.split("\n").map((x) => x.trim()).filter(Boolean).map((text) => ({ type: "user", status: "active", text, sourceRefs: [] })), sources: [] }); if (!alive.current) return; setMemory(res.memory); setMemoryEditing(false); setMemoryDraft((prev) => ({ ...prev, decisions: "" })); setNotice("项目共识已保存为 v" + res.memory.revision); } catch (err) { if (alive.current) setError(err?.message || "保存项目共识失败"); } finally { if (alive.current) setBusy(false); } } async function addArtifact() { if (!projectId || busy) return; const title = artifactDraft.title.trim(); if (!title) { setNotice("成果名称不能为空"); return; } setBusy(true); setError(null); try { const res = await request("artifactAdd", { projectId, title, path: artifactDraft.path.trim(), summary: artifactDraft.summary.trim() }); if (!alive.current) return; setArtifacts((list) => [...list, res.artifact]); setArtifactDraft({ title: "", path: "", summary: "" }); setArtifactModalOpen(false); setNotice("成果已登记"); } catch (err) { if (alive.current) setError(err?.message || "登记成果失败"); } finally { if (alive.current) setBusy(false); } } const degraded = Boolean(approvalStatus?.degraded); const toolApprovals = degraded ? [] : pendingApprovals; const decisions = (0, import_react.useMemo)(() => tasks.flatMap((task) => (task.decisions || []).filter((d) => d.status === "pending").map((decision) => ({ task, decision }))), [tasks]); const pendingCount = toolApprovals.length + decisions.length; const openTasksCount = tasks.filter((t) => ["running", "prepared", "dispatched", "failed", "waiting_user", "reconfirm"].includes(t.status)).length; const reviewCount = tasks.filter((t) => t.ownerSeatId === "menxia" && ["running", "prepared", "dispatched"].includes(t.status)).length; const anomalyCount = tasks.filter((t) => t.workflowBlockage || t.status === "failed" || t.deliveryState === "unknown").length + wb.seats.filter((s) => s.status === "missing" || s.modelSyncStatus === "failed").length; const activeDelib = deliberations.find((d) => d.status === "running") || null; const syncIssues = wb.seats.filter((s) => s.modelSyncStatus === "failed" || s.status === "missing").length; const projectDurationMs = tasks.reduce((sum, t) => sum + taskDurationMs(t), 0); const runningSeatsCount = wb.seats.filter((s) => s.runtimeState === "running").length; function latestTaskOf(seatId) { return tasks.filter((t) => t.ownerSeatId === seatId && t.status !== "cancelled").sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0))[0] || null; } function renderPendingZone() { if (pendingCount === 0 && !degraded) return null; return (0, import_react.createElement)( "section", { className: "frameless-zone", "aria-label": "待你处理" }, (0, import_react.createElement)( "div", { className: "frameless-zone-head" }, (0, import_react.createElement)( "div", { className: "frameless-zone-title-wrap" }, (0, import_react.createElement)("span", { className: "ss-dot is-primary is-pulse" }), (0, import_react.createElement)("h2", { className: "frameless-zone-title" }, "待你处理"), pendingCount > 0 ? (0, import_react.createElement)("span", { className: "frameless-zone-count" }, String(pendingCount)) : null ), (0, import_react.createElement)("span", { className: "frameless-zone-sub" }, "原生审批与决定同步") ), degraded ? (0, import_react.createElement)( "div", { className: "frameless-code", style: { color: "var(--ss-error)" } }, "工作台暂时无法获取工具审批队列,请在席位原生会话中使用审批卡。" + (approvalStatus?.reason ? "(" + approvalStatus.reason + ")" : "") ) : null, (0, import_react.createElement)( "div", { className: "frameless-zone-list" }, toolApprovals.map((a) => (0, import_react.createElement)( "article", { className: "frameless-item", key: "apr:" + a.sessionId + ":" + a.id }, (0, import_react.createElement)( "div", { className: "frameless-item-head" }, (0, import_react.createElement)( "div", { className: "frameless-item-meta" }, (0, import_react.createElement)("span", { className: "frameless-chip is-err" }, (0, import_react.createElement)("span", { className: "ss-dot is-error" }), "工具审批"), (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 13 } }, SEATS[a.seatId]?.label || a.seatId), a.tool ? (0, import_react.createElement)("span", { className: "font-mono-num", style: { fontSize: 12, color: "var(--ss-muted)" } }, a.tool) : null ), (0, import_react.createElement)("button", { type: "button", className: "frameless-link", disabled: busy, onClick: () => void openSeat(a.seatId) }, "查看会话 →") ), (0, import_react.createElement)("div", { className: "frameless-code" }, a.reason || a.detail?.text || "等待工具授权"), (0, import_react.createElement)( "div", { className: "frameless-btn-group" }, (0, import_react.createElement)("button", { type: "button", className: "frameless-btn", disabled: busy, onClick: () => void answerApproval(a, "reject") }, "拒绝"), (0, import_react.createElement)("button", { type: "button", className: "frameless-primary-btn", disabled: busy, onClick: () => void answerApproval(a, "allow") }, "允许一次") ) )), decisions.map(({ task, decision }) => (0, import_react.createElement)( "article", { className: "frameless-item", key: "dec:" + task.id + ":" + decision.id }, (0, import_react.createElement)( "div", { className: "frameless-item-head" }, (0, import_react.createElement)( "div", { className: "frameless-item-meta" }, (0, import_react.createElement)("span", { className: "frameless-chip is-pri" }, (0, import_react.createElement)("span", { className: "ss-dot is-primary" }), "项目决定"), (0, import_react.createElement)("span", { className: "truncate", style: { fontSize: 12, fontWeight: 500 } }, task.title) ), (0, import_react.createElement)("button", { type: "button", className: "frameless-link font-mono-num", onClick: () => setSelectedTask(task) }, task.id) ), (0, import_react.createElement)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.55 } }, decision.question), (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, role: "group", "aria-label": decision.question }, (decision.options || []).map((opt) => (0, import_react.createElement)("button", { key: opt.value, type: "button", className: "frameless-btn", disabled: busy, onClick: () => void answerDecision(task.id, decision.id, opt.value) }, opt.label)) ) )) ) ); } function renderModelControlsForSeat(seatId, onSaveCallback) { const rec = seatRecMap[seatId] || {}; const { modelKey, effort, instructions } = seatDraftState(seatId); const choiceObj = groupedChoices.find((c) => c.value === modelKey) || null; const extraChoices = modelKey && !choiceObj ? [{ value: modelKey, label: (rec.model?.model || modelKey) + "(目录未列出)", efforts: effort ? [effort] : [] }, ...groupedChoices] : groupedChoices; const efforts = choiceObj?.efforts || []; const configured = rec.configuredModel ?? rec.model ?? null; const sourceLabel = wb.seats.find((s) => s.id === seatId)?.modelSourceLabel || "未选择"; const syncStatus = rec.modelSync?.status || null; return (0, import_react.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, (0, import_react.createElement)( "div", { className: "kv-grid-2" }, (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "主任模型"), (0, import_react.createElement)( "select", { className: "wb-select", value: modelKey, onChange: (e) => { const nextKey = e.target.value; const nextChoice = groupedChoices.find((c) => c.value === nextKey); const nextEffort = nextChoice?.efforts?.includes(effort) ? effort : nextChoice?.efforts?.[0] || ""; updateSeatDraftModel(seatId, nextKey, nextEffort); } }, (0, import_react.createElement)("option", { value: "" }, UNCHOSEN_MODEL_LABEL), extraChoices.map((opt) => (0, import_react.createElement)("option", { key: opt.value, value: opt.value }, opt.label)) ) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "推理等级"), (0, import_react.createElement)( "select", { className: "wb-select", value: effort, disabled: efforts.length === 0, onChange: (e) => updateSeatDraftModel(seatId, modelKey, e.target.value) }, (0, import_react.createElement)("option", { value: "" }, efforts.length === 0 ? "默认(固定)" : "默认"), efforts.map((ef) => (0, import_react.createElement)("option", { key: ef, value: ef }, ef)) ) ) ), (0, import_react.createElement)( "div", { className: "kv-box", style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "配置来源"), (0, import_react.createElement)("span", { className: "ss-pill" + (rec.modelSource === "project" ? " is-primary" : "") }, sourceLabel) ), (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "当前会话模型"), (0, import_react.createElement)("span", { className: "font-mono-num" }, rec.sessionModel ? rec.sessionModel.provider + "/" + rec.sessionModel.model : configured ? shortModelName(configured) : "未绑定会话") ), (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "同步状态"), (0, import_react.createElement)( "span", { style: { color: syncStatus === "failed" ? "var(--ss-error)" : syncStatus === "synced" ? "var(--ss-success)" : "var(--ss-muted)" } }, syncStatus === "synced" ? "已同步" : syncStatus === "failed" ? "同步失败" + (rec.modelSync?.error ? " · " + rec.modelSync.error : "") : "待开启或待同步" ) ) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "角色补充说明(仅对本席生效)"), (0, import_react.createElement)("textarea", { rows: 3, className: "wb-textarea", value: instructions, placeholder: "追加给该席位的项目级补充约束…", onChange: (e) => setDraft((prev) => updateDraft(prev, seatId, { instructions: e.target.value })) }) ), (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy, onClick: () => void onSaveCallback(seatId) }, busy ? "保存中…" : "保存配置"), configured ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void setGlobalDefaultFor(seatId) }, "设为全局默认") : null, rec.modelSource === "project" ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void clearOverrideFor(seatId) }, "恢复继承") : null, syncStatus === "failed" || syncStatus === "unresolved" ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void retrySyncFor(seatId) }, "重试同步") : null ) ); } function renderCourtTab() { const lead = seatById.lead; const leadTone = seatTone(lead); const leadSelected = selectedSeatId === "lead"; const leadLatest = latestTaskOf("lead"); const filterMatch = (seat) => { if (seatFilter === "running") return seat.runtimeState === "running"; if (seatFilter === "attention") return seat.status === "missing" || seat.status === "failed" || seat.modelSyncStatus === "failed" || seat.approvalState === "waiting"; if (seatFilter === "pending") return seat.status === "pending"; return true; }; const renderSeatCard = (seatId, tier) => { const seat = seatById[seatId]; const tone = seatTone(seat); const selected = selectedSeatId === seatId; const isLive = activeChatSeatId === seatId; const dimmed = !filterMatch(seat); const latest = latestTaskOf(seatId); const modelShort = shortModelName(seatRecMap[seatId]?.configuredModel ?? seatRecMap[seatId]?.model ?? null); return (0, import_react.createElement)( "button", { key: seatId, type: "button", "aria-pressed": selected, className: "seat-card" + (tier === "sansheng" ? " is-sansheng" : " is-liubu") + (selected ? " is-selected" : "") + (dimmed ? " is-dimmed" : ""), onClick: () => selectSeat(seatId) }, (0, import_react.createElement)( "div", null, (0, import_react.createElement)( "div", { className: "seat-head" }, (0, import_react.createElement)( "span", { className: "seat-title-wrap" }, (0, import_react.createElement)("span", { className: "seat-name" }, seat.name), isLive ? (0, import_react.createElement)("span", { className: "seat-live-tag" }, "对话中") : null ), (0, import_react.createElement)( "span", { className: "seat-status-text" + (tone === "error" ? " is-error" : tone === "success" ? " is-success" : "") }, (0, import_react.createElement)("span", { className: "ss-dot is-" + tone + (tone === "success" ? " is-pulse" : "") }), seatStatusText(seat) ) ), (0, import_react.createElement)("div", { className: "seat-duty" }, seat.duty) ), (0, import_react.createElement)( "div", { className: "seat-footer" }, (0, import_react.createElement)( "span", { className: "seat-task-title", style: { color: latest ? "var(--ss-fg)" : "var(--ss-muted)" } }, latest ? latest.title : seat.status === "bound" ? "空闲待命" : "点击按需开启" ), (0, import_react.createElement)("span", { className: "seat-model-tag hide-narrow" }, modelShort === "未选模型" ? "—" : modelShort) ) ); }; const sel = wb.selected; const selSeat = seatById[sel.id]; const selTone = seatTone(selSeat); const selTasks = tasks.filter((t) => t.ownerSeatId === sel.id && t.status !== "cancelled").sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0)); const todayCutoff = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0); const selToday = selTasks.filter((t) => Number(t.createdAt) >= todayCutoff); const selTodayDone = selToday.filter((t) => t.status === "done"); const selLatest = selTasks[0] || null; const actionLabel = sel.status === "bound" ? "开始对话" : sel.status === "missing" ? "重建会话" : "开启「" + sel.name + "」"; const actionHandler = sel.status === "bound" ? () => void openSeat(sel.id) : sel.status === "missing" ? () => void rebuildSeat(sel.id) : () => void enableSeat(sel.id); return [ (0, import_react.createElement)( "section", { key: "telemetry", className: "telemetry-strip", "aria-label": "项目运行摘要" }, (0, import_react.createElement)( "div", { className: "telemetry-group" }, (0, import_react.createElement)( "span", { className: "telemetry-item" }, (0, import_react.createElement)("span", { className: "ss-dot " + (runningSeatsCount > 0 ? "is-success is-pulse" : "is-muted") }), (0, import_react.createElement)("strong", { className: "font-mono-num" }, wb.project.boundCount + "/10"), (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "在册") ), (0, import_react.createElement)( "button", { type: "button", onClick: () => { setTab("flow"); setFlowSubTab("tasks"); } }, (0, import_react.createElement)("strong", { className: "font-mono-num", style: { color: reviewCount > 0 ? "var(--ss-primary)" : "inherit" } }, String(reviewCount)), " ", (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "待复核") ), (0, import_react.createElement)( "button", { type: "button", onClick: () => { setTab("flow"); setFlowSubTab("queue"); setQueueSearch("失败"); } }, (0, import_react.createElement)("strong", { className: "font-mono-num", style: { color: anomalyCount > 0 ? "var(--ss-error)" : "inherit" } }, String(anomalyCount)), " ", (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "异常") ) ), (0, import_react.createElement)( "button", { type: "button", className: "font-mono-num", style: { color: "var(--ss-muted)" }, onClick: () => setDurationModalOpen(true) }, projectDurationMs > 0 ? durationText(projectDurationMs) : "—" ) ), renderPendingZone(), (0, import_react.createElement)( "div", { key: "split", className: "court-split" }, (0, import_react.createElement)( "section", { style: { display: "flex", flexDirection: "column", gap: 12 }, "aria-label": "十席谱系" }, (0, import_react.createElement)( "div", { className: "court-head" }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, (0, import_react.createElement)("h2", { className: "court-title" }, "十席谱系"), (0, import_react.createElement)("span", { style: { fontSize: 12, color: "var(--ss-muted)" } }, "点击席位查看详情") ), (0, import_react.createElement)( "div", { className: "seg-group" }, [ { id: "all", label: "全部" }, { id: "running", label: "运行中" }, { id: "attention", label: "需关注" }, { id: "pending", label: "未开启" } ].map((f) => (0, import_react.createElement)("button", { key: f.id, type: "button", className: "seg-btn" + (seatFilter === f.id ? " is-active" : ""), onClick: () => setSeatFilter(f.id) }, f.label)) ) ), (0, import_react.createElement)( "div", { className: "lead-card" + (leadSelected ? " is-selected" : "") }, (0, import_react.createElement)( "button", { type: "button", className: "lead-select-btn", onClick: () => selectSeat("lead") }, (0, import_react.createElement)("span", { className: "lead-seal" }, "相"), (0, import_react.createElement)( "div", { style: { minWidth: 0, flex: "1 1 auto" } }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 15, color: leadSelected ? "var(--ss-primary)" : "var(--ss-fg)" } }, "丞相"), (0, import_react.createElement)( "span", { className: "ss-pill is-" + leadTone }, (0, import_react.createElement)("span", { className: "ss-dot is-" + leadTone + (leadTone === "success" ? " is-pulse" : "") }), seatStatusText(lead) ), (0, import_react.createElement)("span", { className: "hide-narrow", style: { fontSize: 12, color: "var(--ss-muted)" } }, "总协调 · 需求入口") ), (0, import_react.createElement)( "p", { className: "truncate", style: { margin: "2px 0 0", fontSize: 12, color: "var(--ss-muted)" } }, leadLatest ? leadLatest.result || leadLatest.title : SEATS.lead.duty ) ) ), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy || lead.status === "creating", onClick: () => lead.status === "bound" ? void openSeat("lead") : void enableSeat("lead") }, lead.status === "bound" ? "进入对话" : "开启丞相") ), (0, import_react.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 6 } }, (0, import_react.createElement)("div", { className: "tier-divider" }, (0, import_react.createElement)("strong", null, "三省"), (0, import_react.createElement)("span", null, "中书拟案 → 门下审核 → 尚书调度"), (0, import_react.createElement)("span", { className: "tier-line" })), (0, import_react.createElement)("div", { className: "sansheng-grid" }, SANSHENG_ORDER.map((id) => renderSeatCard(id, "sansheng"))) ), (0, import_react.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 6 } }, (0, import_react.createElement)("div", { className: "tier-divider" }, (0, import_react.createElement)("strong", null, "六部"), (0, import_react.createElement)("span", null, "尚书统筹 · 同级并行交付"), (0, import_react.createElement)("span", { className: "tier-line" })), (0, import_react.createElement)("div", { className: "liubu-grid" }, LIUBU_ORDER.map((id) => renderSeatCard(id, "liubu"))) ) ), (0, import_react.createElement)( "aside", { className: "inspector-card", "aria-label": "席位检视面板" }, (0, import_react.createElement)( "div", { className: "inspector-head" }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 20, color: "var(--ss-primary)", lineHeight: 1 } }, sel.name), (0, import_react.createElement)("span", { className: "ss-pill is-" + selTone }, seatStatusText(selSeat)), (0, import_react.createElement)("span", { style: { fontSize: 12, color: "var(--ss-muted)" } }, seatKind(sel.id)) ), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy || sel.status === "creating", onClick: actionHandler }, ChatIcon(), (0, import_react.createElement)("span", null, actionLabel)) ), (0, import_react.createElement)( "div", { className: "inspector-subtabs" }, (0, import_react.createElement)("button", { type: "button", className: "inspector-subtab" + (inspectorTab === "overview" ? " is-active" : ""), onClick: () => setInspectorTab("overview") }, "概览与任务"), (0, import_react.createElement)( "button", { type: "button", className: "inspector-subtab" + (inspectorTab === "config" ? " is-active" : ""), onClick: () => setInspectorTab("config") }, "模型与指令" + (sel.modelSyncStatus === "failed" ? " · 异常" : "") ) ), (0, import_react.createElement)( "div", { className: "inspector-body" }, inspectorTab === "config" ? renderModelControlsForSeat(sel.id, saveSeatConfigFor) : [ (0, import_react.createElement)( "div", { key: "kv", className: "kv-grid-2" }, (0, import_react.createElement)( "div", { className: "kv-box" }, (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)" } }, "主任模型"), (0, import_react.createElement)("div", { className: "font-mono-num truncate", style: { fontWeight: 500, marginTop: 2 } }, sel.modelLabel), (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, sel.modelSourceLabel) ), (0, import_react.createElement)( "div", { className: "kv-box" }, (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)" } }, "会话绑定"), (0, import_react.createElement)( "div", { className: "font-mono-num", style: { fontWeight: 500, marginTop: 2, color: sel.status === "missing" ? "var(--ss-error)" : "var(--ss-fg)" } }, sel.status === "missing" ? "会话已缺失" : sel.sessionId ? sel.sessionId.slice(0, 10) : "尚未建立" ), (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, "本日 " + selToday.length + " 条 · 完 " + selTodayDone.length) ) ), sel.status === "missing" ? (0, import_react.createElement)( "div", { key: "miss", className: "wb-alert" }, (0, import_react.createElement)("span", null, "原会话在宿主中已不存在,重建后保留旧任务历史。"), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void rebuildSeat(sel.id) }, "重建会话") ) : null, sel.modelSyncStatus === "failed" ? (0, import_react.createElement)( "div", { key: "fail", className: "wb-alert" }, (0, import_react.createElement)("span", null, "模型同步失败:" + (sel.modelSync?.error || "未知原因")), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void retrySyncFor(sel.id) }, "重试同步") ) : null, (0, import_react.createElement)( "div", { key: "resp", style: { borderRadius: 8, border: "1px solid var(--ss-border)", padding: 12, display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "最近动态与职责"), (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, selLatest && (selLatest.result || selLatest.note) || sel.responsibility), selLatest ? (0, import_react.createElement)("p", { style: { margin: "4px 0 0", paddingTop: 6, borderTop: "1px dashed var(--ss-border)", color: "var(--ss-muted)" } }, "职责:" + sel.responsibility) : null ), sel.id === "shangshu" ? (0, import_react.createElement)("button", { key: "ss", type: "button", className: "frameless-btn", style: { width: "100%", padding: "8px 12px", borderRadius: 8 }, disabled: summaryBusy || busy, onClick: () => void summarizeByShangshu() }, summaryBusy ? "正在通知尚书汇总…" : "请尚书汇总当前项目任务进度 →") : null, sel.id === "lead" ? (0, import_react.createElement)("button", { key: "reqjump", type: "button", className: "frameless-btn", style: { width: "100%", padding: "8px 12px", borderRadius: 8 }, onClick: () => { setTab("flow"); setFlowSubTab("requirements"); } }, "前往「流转 · 需求清单」查看 " + requirements.length + " 条需求 →") : null, (0, import_react.createElement)( "div", { key: "recent", style: { display: "flex", flexDirection: "column", gap: 6 } }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, (0, import_react.createElement)("span", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "本席近期任务 (" + selTasks.length + ")"), selTasks.length > 0 ? (0, import_react.createElement)("button", { type: "button", className: "frameless-link", onClick: () => { setTab("flow"); setFlowSubTab("queue"); } }, "查看全部") : null ), selTasks.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "该席位暂无任务记录。") : selTasks.slice(0, 3).map((t) => { const tm = TASK_META[t.status] || { label: t.status, tone: "muted" }; return (0, import_react.createElement)( "button", { key: t.id, type: "button", className: "wb-card", style: { textAlign: "left", padding: 10 }, onClick: () => setSelectedTask(t) }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react.createElement)("span", { className: "truncate", style: { fontWeight: 500 } }, t.title), (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label) ), (0, import_react.createElement)( "p", { className: "line-clamp-2", style: { margin: 0, color: "var(--ss-muted)" } }, t.workflowBlockage ? t.workflowBlockage.reason : t.result || t.goal || t.requirement || "(暂无说明)" ) ); }) ) ] ) ) ) ]; } function renderStageStepper(stage) { const idx = WORKFLOW_STAGES.findIndex((s) => s.id === stage); return (0, import_react.createElement)( "div", { className: "stage-stepper" }, WORKFLOW_STAGES.map((st, i) => { const done = idx >= 0 && i < idx; const cur = idx >= 0 && i === idx; return (0, import_react.createElement)( "span", { key: st.id, style: { display: "inline-flex", alignItems: "center", gap: 4, flexShrink: 0 } }, (0, import_react.createElement)("span", { className: "stage-step-pill" + (done ? " is-done" : cur ? " is-cur" : "") }, st.label), i < WORKFLOW_STAGES.length - 1 ? (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)", fontSize: 12 } }, "→") : null ); }), stage === "reconfirm" ? (0, import_react.createElement)("span", { className: "ss-pill is-error" }, "阻塞 · 待重确认") : null ); } function renderFlowTab() { const wfTasks = tasks.filter((t) => t.kind === "workflow" || t.kind === "execution"); const deliveries = tasks.filter((t) => t.stage === "delivered" || t.status === "done"); const q = queueSearch.trim().toLowerCase(); const filteredQueue = tasks.filter((t) => { if (!q) return true; const sName = SEATS[t.ownerSeatId]?.label || ""; const tmLabel = TASK_META[t.status]?.label || ""; return [t.id, t.title, sName, tmLabel, t.goal, t.result].filter(Boolean).join(" ").toLowerCase().includes(q); }); const subTabs = [ { id: "tasks", label: "流转任务", count: wfTasks.length }, { id: "requirements", label: "需求清单", count: requirements.length }, { id: "queue", label: "派工队列", count: tasks.length }, { id: "delivery", label: "交付结果", count: deliveries.length } ]; let body = null; if (flowSubTab === "requirements") { body = requirements.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "暂无需求条目。与丞相在对话中明确需求后将整理至此。") : (0, import_react.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, requirements.map((req) => { const rm = REQ_STATUS_META[req.status] || { label: req.status, tone: "muted" }; return (0, import_react.createElement)( "article", { className: "wb-card", key: req.id }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: 8 } }, (0, import_react.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, (0, import_react.createElement)("span", { className: "font-mono-num", style: { fontWeight: 600, color: "var(--ss-primary)" } }, req.id + " · v" + req.revision), (0, import_react.createElement)("span", { className: "ss-pill is-" + rm.tone }, rm.label), req.judgement ? (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "丞相:" + (REQ_JUDGEMENT_LABELS[req.judgement] || req.judgement)) : null ), (0, import_react.createElement)("h3", { style: { margin: "4px 0 0", fontSize: 13, fontWeight: 600 } }, req.title) ), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => { try { void navigator.clipboard?.writeText?.(req.id); } catch { } setNotice("已复制需求编号:" + req.id); } }, "复制编号") ), req.summary ? (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, req.summary) : null, req.blockedReason ? (0, import_react.createElement)("div", { className: "wb-alert" }, "阻塞:" + req.blockedReason) : null, (0, import_react.createElement)( "details", { style: { borderRadius: 8, background: "var(--ss-subtle)", border: "1px solid var(--ss-border)", padding: "6px 10px" } }, (0, import_react.createElement)("summary", { style: { cursor: "pointer", color: "var(--ss-muted)", fontWeight: 500 } }, "展开范围、验收标准与待补信息"), (0, import_react.createElement)( "dl", { style: { margin: "8px 0 0", paddingTop: 8, borderTop: "1px solid var(--ss-border)", display: "grid", gap: 6 } }, (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "用户原话"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.originalText || "—")), (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "范围"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.scope || "—")), (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "非目标"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.nonGoals || "—")), (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "验收标准"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.acceptanceCriteria || "—")), req.risks ? (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "风险"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.risks)) : null, req.missingInfo ? (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "待补信息"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.missingInfo)) : null ) ) ); })); } else if (flowSubTab === "queue") { body = (0, import_react.createElement)( "div", { className: "wb-card", style: { padding: 0, overflow: "hidden", gap: 0 } }, (0, import_react.createElement)( "div", { style: { padding: 10, borderBottom: "1px solid var(--ss-border)", display: "flex", flexWrap: "wrap", gap: 8, alignItems: "center" } }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 6, flex: "1 1 150px", border: "1px solid var(--ss-border)", borderRadius: 8, background: "var(--ss-bg)", padding: "5px 10px" } }, SearchIcon(), (0, import_react.createElement)("input", { type: "search", value: queueSearch, placeholder: "按任务、席位、状态筛选…", style: { width: "100%", border: 0, background: "transparent", outline: "none", fontSize: 12 }, onChange: (e) => setQueueSearch(e.target.value) }) ), (0, import_react.createElement)("button", { type: "button", className: "frameless-btn", disabled: summaryBusy || busy, onClick: () => void summarizeByShangshu() }, summaryBusy ? "汇总中…" : "尚书汇总"), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void reloadTasks() }, "刷新") ), filteredQueue.length === 0 ? (0, import_react.createElement)("div", { style: { padding: 28, textAlign: "center", color: "var(--ss-muted)" } }, "没有匹配的派工记录。") : (0, import_react.createElement)( "div", { style: { overflowX: "auto" } }, (0, import_react.createElement)( "table", { className: "queue-table" }, (0, import_react.createElement)("thead", null, (0, import_react.createElement)( "tr", null, (0, import_react.createElement)("th", null, "任务"), (0, import_react.createElement)("th", null, "席位"), (0, import_react.createElement)("th", null, "状态"), (0, import_react.createElement)("th", { className: "col-dur" }, "耗时"), (0, import_react.createElement)("th", { className: "col-time" }, "派发时间") )), (0, import_react.createElement)("tbody", null, filteredQueue.map((t) => { const tm = TASK_META[t.status] || { label: t.status, tone: "muted" }; return (0, import_react.createElement)( "tr", { key: t.id, className: "is-click", onClick: () => setSelectedTask(t) }, (0, import_react.createElement)("td", null, (0, import_react.createElement)("div", { style: { fontWeight: 500 } }, t.title), (0, import_react.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, t.id)), (0, import_react.createElement)("td", { className: "font-seal", style: { fontWeight: 700, whiteSpace: "nowrap" } }, SEATS[t.ownerSeatId]?.label || "—"), (0, import_react.createElement)("td", null, (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label)), (0, import_react.createElement)("td", { className: "col-dur font-mono-num", style: { color: "var(--ss-muted)", whiteSpace: "nowrap" } }, durationText(taskDurationMs(t))), (0, import_react.createElement)("td", { className: "col-time font-mono-num", style: { color: "var(--ss-muted)", whiteSpace: "nowrap" } }, dateText(t.dispatchedAt)) ); })) ) ) ); } else if (flowSubTab === "delivery") { body = deliveries.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "还没有已交付结果。") : (0, import_react.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, deliveries.map((t) => { const children = tasks.filter((c) => c.parentTaskId === t.id && c.kind === "execution"); return (0, import_react.createElement)( "article", { className: "wb-card", key: t.id }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 8 } }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 13, fontWeight: 600 } }, t.title), (0, import_react.createElement)("span", { className: "ss-pill is-success" }, "已交付") ), (0, import_react.createElement)( "div", { className: "font-mono-num", style: { display: "flex", flexWrap: "wrap", gap: 8, color: "var(--ss-muted)" } }, (0, import_react.createElement)("span", null, t.id), (0, import_react.createElement)("span", null, "承办:" + (SEATS[t.ownerSeatId]?.label || "—")), t.resultSessionId ? (0, import_react.createElement)("span", null, "会话 " + t.resultSessionId.slice(0, 8)) : null, (0, import_react.createElement)("span", null, "耗时 " + durationText(taskDurationMs(t))) ), (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55, whiteSpace: "pre-wrap" } }, t.deliveryNote || t.result || t.summary || "(暂无交付说明)"), children.length ? (0, import_react.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 6, paddingTop: 8, borderTop: "1px dashed var(--ss-border)" } }, children.map((ch) => (0, import_react.createElement)( "div", { key: ch.id, style: { display: "flex", flexWrap: "wrap", gap: 8, alignItems: "center" } }, (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[ch.ownerSeatId]?.label || ch.ownerSeatId), (0, import_react.createElement)("span", { className: "ss-pill is-" + (TASK_META[ch.status]?.tone || "muted") }, TASK_META[ch.status]?.label || ch.status), (0, import_react.createElement)("span", { style: { flex: "1 1 120px", color: "var(--ss-muted)" } }, shortText(ch.result || ch.note || "(暂无结果)", 80)), ch.resultSessionId ? (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, ch.resultSessionId.slice(0, 8)) : null )) ) : null ); })); } else { body = wfTasks.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "还没有流转任务。丞相下派需求后会出现在这里。") : (0, import_react.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, wfTasks.map((t) => { const tm = TASK_META[t.status] || { label: t.status, tone: "muted" }; return (0, import_react.createElement)( "article", { key: t.id, className: "wb-card", style: t.workflowBlockage ? { borderColor: "color-mix(in srgb,var(--ss-error) 36%,var(--ss-border))" } : void 0 }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: 8 } }, (0, import_react.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 6 } }, (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, t.id), (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[t.ownerSeatId]?.label || t.ownerSeatId), t.requirementId ? (0, import_react.createElement)("span", { className: "ss-pill font-mono-num" }, t.requirementId + " v" + t.requirementRevision) : null, (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label) ), (0, import_react.createElement)("h3", { style: { margin: "4px 0 0", fontSize: 13, fontWeight: 600 } }, t.title) ), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setSelectedTask(t) }, "查看详情 →") ), t.kind === "workflow" ? renderStageStepper(t.stage) : null, t.workflowBlockage ? (0, import_react.createElement)( "div", { className: "wb-alert" }, (0, import_react.createElement)("span", null, t.workflowBlockage.label + ":" + t.workflowBlockage.reason), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setSelectedTask(t) }, "处理阻塞") ) : (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)", lineHeight: 1.55 } }, t.result || t.goal || t.requirement || "(暂无说明)") ); })); } return [ (0, import_react.createElement)( "div", { key: "subtabs", className: "flow-seg" }, subTabs.map((st) => (0, import_react.createElement)("button", { key: st.id, type: "button", className: "flow-seg-btn" + (flowSubTab === st.id ? " is-active" : ""), onClick: () => setFlowSubTab(st.id) }, st.label + " " + st.count)) ), (0, import_react.createElement)("div", { key: "flowbody" }, body) ]; } function renderDeliberationTab() { const avatars = view?.project?.avatars ?? {}; const active = deliberations.find((x) => x.status === "running") || null; const shownId = delibSelectedId || active?.id || deliberations[0]?.id || null; const summary = deliberations.find((x) => x.id === shownId) || null; const full = deliberation && deliberation.id === shownId ? deliberation : null; const shown = full || summary || null; const isActive = Boolean(shown && shown.status === "running"); const curSeat = isActive ? shown.currentSeatId || shown.turn?.seatId || null : null; const speeches = shown?.speeches || []; return [ (0, import_react.createElement)( "section", { key: "dhead", className: "wb-card" }, (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, (0, import_react.createElement)( "span", { className: "ss-pill is-" + (isActive ? "success" : shown?.status === "stopped" ? "error" : "muted") }, isActive ? "议政进行中" : shown?.status === "stopped" ? "已停止" : shown ? "已收束" : "空闲" ), (0, import_react.createElement)( "span", { className: "truncate", style: { fontWeight: 500 } }, shown ? "第 " + shown.round + " / " + (shown.maxRounds > 0 ? shown.maxRounds : "不限") + " 轮" + (curSeat ? " · 当值:" + (SEATS[curSeat]?.label || curSeat) : "") : "发起议题即可启动三省轮流审议" ) ), (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setDelibSettingsOpen((v) => !v) }, "议政设置"), isActive ? [ (0, import_react.createElement)("button", { key: "end", type: "button", className: "frameless-btn", disabled: delibBusy, onClick: () => void endDeliberation() }, "收束结论"), (0, import_react.createElement)("button", { key: "stop", type: "button", className: "wb-btn-outline", style: { color: "var(--ss-error)" }, disabled: delibBusy, onClick: () => void stopDeliberation() }, "立即停止") ] : null ) ), shown ? (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, shown.topic) : null, (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 8 } }, DELIB_SEATS.map((sid, i) => [ (0, import_react.createElement)( "button", { key: sid, type: "button", title: "点击调整「" + SEATS[sid].label + "」头像", style: { display: "inline-flex", alignItems: "center", gap: 6, padding: "5px 8px", borderRadius: 8, border: "1px solid " + (curSeat === sid ? "var(--ss-primary)" : "var(--ss-border)"), background: curSeat === sid ? "color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))" : "var(--ss-subtle)", opacity: !isActive || curSeat === sid ? 1 : 0.65 }, onClick: () => setAvatarEdit((prev) => prev?.seatId === sid ? null : { seatId: sid, char: "" }) }, avatarNode(sid, avatars, 24, curSeat === sid), (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[sid].label), curSeat === sid ? (0, import_react.createElement)("span", { style: { color: "var(--ss-primary)" } }, "当值") : null ), i < 2 ? (0, import_react.createElement)("span", { key: "arr-" + i, style: { color: "var(--ss-muted)" } }, "→") : null ]), (0, import_react.createElement)("span", { style: { marginLeft: "auto", color: "var(--ss-muted)" } }, "点击头像可换") ), shown?.turn?.error ? (0, import_react.createElement)( "div", { className: "wb-alert" }, (0, import_react.createElement)("span", null, shown.turn.error), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: delibBusy, onClick: () => void retryDeliberation() }, "重试当前席位") ) : null, avatarEdit ? (0, import_react.createElement)( "div", { style: { borderRadius: 8, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 10, display: "flex", flexWrap: "wrap", alignItems: "center", gap: 8 } }, avatarNode(avatarEdit.seatId, avatars, 28, false), (0, import_react.createElement)("span", { style: { fontWeight: 500 } }, SEATS[avatarEdit.seatId].label + "头像:"), (0, import_react.createElement)( "label", { className: "wb-btn-outline", style: { cursor: "pointer" } }, "选图片", (0, import_react.createElement)("input", { type: "file", accept: "image/png,image/jpeg,image/webp", style: { display: "none" }, onChange: (e) => { const f = e.target.files?.[0]; if (f) void pickAvatarFile(avatarEdit.seatId, f); e.target.value = ""; } }) ), (0, import_react.createElement)("input", { type: "text", maxLength: 8, placeholder: "或填 1 字 / Emoji", value: avatarEdit.char, className: "wb-input", style: { width: 130 }, onChange: (e) => setAvatarEdit((prev) => ({ ...prev, char: e.target.value })) }), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: delibBusy || !avatarEdit.char.trim(), onClick: () => void saveAvatar(avatarEdit.seatId, { char: avatarEdit.char.trim() }) }, "保存字符"), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: delibBusy, onClick: () => void saveAvatar(avatarEdit.seatId, { clear: true }) }, "恢复默认"), (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", style: { marginLeft: "auto" }, onClick: () => setAvatarEdit(null) }, "关闭") ) : null, delibSettingsOpen ? (0, import_react.createElement)( "div", { style: { borderRadius: 8, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 10, display: "grid", gridTemplateColumns: "repeat(auto-fit,minmax(130px,1fr))", gap: 8 } }, (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "轮次上限(0 为不限)"), (0, import_react.createElement)("input", { type: "number", min: 0, max: 20, value: delibDraft.maxRounds, className: "wb-input", onChange: (e) => setDelibDraft((p) => ({ ...p, maxRounds: e.target.value })) }) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "关联任务"), (0, import_react.createElement)( "select", { className: "wb-select", value: delibDraft.taskId, onChange: (e) => setDelibDraft((p) => ({ ...p, taskId: e.target.value })) }, (0, import_react.createElement)("option", { value: "" }, "不关联"), tasks.map((t) => (0, import_react.createElement)("option", { key: t.id, value: t.id }, t.id + " " + t.title)) ) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "关联需求"), (0, import_react.createElement)( "select", { className: "wb-select", value: delibDraft.requirementId, onChange: (e) => setDelibDraft((p) => ({ ...p, requirementId: e.target.value })) }, (0, import_react.createElement)("option", { value: "" }, "不关联"), requirements.map((r) => (0, import_react.createElement)("option", { key: r.id, value: r.id }, r.id + " " + r.title)) ) ) ) : null ), (0, import_react.createElement)( "section", { key: "transcript", className: "wb-card", "aria-label": "议政转写" }, speeches.length === 0 ? (0, import_react.createElement)("div", { style: { padding: "28px 0", textAlign: "center", color: "var(--ss-muted)" } }, "尚未开议。在下方输入议题,将按「中书 → 门下 → 尚书」顺序轮流发言。") : speeches.map((sp) => (0, import_react.createElement)( "div", { key: sp.id, style: { display: "flex", alignItems: "flex-start", gap: 10 } }, avatarNode(sp.seatId, avatars, 30, curSeat === sp.seatId), (0, import_react.createElement)( "div", { style: { minWidth: 0, flex: "1 1 auto", display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 8 } }, (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[sp.seatId]?.label || sp.seatId), (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, "第 " + sp.round + " 轮"), (0, import_react.createElement)( "span", { className: "ss-pill is-" + (sp.stance === "agree" ? "success" : sp.stance === "dissent" ? "error" : "warning") }, sp.stance === "agree" ? "赞同" : sp.stance === "dissent" ? "有分歧" : "待决" ) ), (0, import_react.createElement)("div", { className: "speech-bubble speech-" + seatDotTone(sp.seatId) }, sp.text), sp.openIssues ? (0, import_react.createElement)("div", { style: { color: "var(--ss-error)" } }, "未决:" + sp.openIssues) : null ) )), shown?.conclusion ? (0, import_react.createElement)( "div", { style: { borderRadius: 8, border: "1px solid color-mix(in srgb,var(--ss-success) 32%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-success) 7%,var(--ss-card))", padding: 10 } }, (0, import_react.createElement)("div", { style: { fontWeight: 600, color: "var(--ss-success)" } }, "议政结论"), (0, import_react.createElement)("p", { style: { margin: "4px 0 0", whiteSpace: "pre-wrap" } }, shown.conclusion.text) ) : null ), (0, import_react.createElement)( "div", { key: "composer", className: "wb-card", style: { flexDirection: "row", alignItems: "center", padding: 10 } }, (0, import_react.createElement)("input", { type: "text", value: delibDraft.topic, disabled: Boolean(active), placeholder: active ? "当前议政进行中,收束或停止后可发起新议题…" : "输入议题,交由三省轮流审议…", style: { flex: "1 1 auto", minWidth: 0, border: 0, background: "transparent", outline: "none", padding: "6px 8px", fontSize: 12 }, onChange: (e) => setDelibDraft((p) => ({ ...p, topic: e.target.value })), onKeyDown: (e) => { if (e.key === "Enter" && !active) void startDeliberation(); } }), (0, import_react.createElement)( "button", { type: "button", className: "wb-btn-primary", disabled: delibBusy || Boolean(active) || !delibDraft.topic.trim(), onClick: () => void startDeliberation() }, delibBusy ? "发起中…" : "发起议政" ) ), (0, import_react.createElement)( "div", { key: "extras", className: "consensus-grid" }, (0, import_react.createElement)( "section", { className: "wb-card" }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "后台子 Agent (" + agentRuns.length + ")"), (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "记室 / 主簿 / 接令") ), agentRuns.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "当前无运行中的后台子 Agent。") : agentRuns.map((run) => (0, import_react.createElement)( "div", { key: run.id, style: { borderRadius: 8, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 10, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react.createElement)( "div", { className: "truncate", style: { fontWeight: 500, display: "flex", alignItems: "center", gap: 6 } }, (0, import_react.createElement)("span", { className: "ss-dot is-success is-pulse" }), run.label || run.seatId ), run.brief ? (0, import_react.createElement)("div", { className: "truncate", style: { color: "var(--ss-muted)", marginTop: 2 } }, run.brief) : null ), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: delibBusy, onClick: () => void stopAgentRun(run) }, "停止") )) ), (0, import_react.createElement)( "section", { className: "wb-card" }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "议政记录 (" + deliberations.length + ")"), deliberations.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无议政记录。") : deliberations.map((item) => (0, import_react.createElement)( "button", { key: item.id, type: "button", className: "wb-card", style: { textAlign: "left", padding: 10, borderColor: shown?.id === item.id ? "var(--ss-primary)" : "var(--ss-border)", background: shown?.id === item.id ? "color-mix(in srgb,var(--ss-primary) 6%,var(--ss-card))" : "var(--ss-subtle)" }, onClick: () => setDelibSelectedId(item.id) }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, (0, import_react.createElement)("span", { className: "truncate", style: { fontWeight: 500 } }, item.topic), (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)", flexShrink: 0 } }, item.status === "running" ? "进行中" : item.status === "stopped" ? "已停止" : "已收束") ), (0, import_react.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, item.id + " · 第 " + item.round + " 轮") )) ) ) ]; } function renderMemoryTab() { const rev = memory?.revision ?? 0; const constraints = Array.isArray(memory?.constraints) ? memory.constraints : []; const acceptance = Array.isArray(memory?.acceptance) ? memory.acceptance : []; const decisionsList = Array.isArray(memory?.decisions) ? memory.decisions : []; if (memoryEditing) { return (0, import_react.createElement)( "section", { className: "wb-card" }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "编辑项目共识 · 当前 v" + rev), (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", onClick: () => setMemoryEditing(false) }, "取消") ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "项目目标"), (0, import_react.createElement)("textarea", { rows: 2, className: "wb-textarea", value: memoryDraft.goal, onChange: (e) => setMemoryDraft((m) => ({ ...m, goal: e.target.value })) }) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "硬约束(每行一条)"), (0, import_react.createElement)("textarea", { rows: 4, className: "wb-textarea", value: memoryDraft.constraints, onChange: (e) => setMemoryDraft((m) => ({ ...m, constraints: e.target.value })) }) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "验收标准(每行一条)"), (0, import_react.createElement)("textarea", { rows: 3, className: "wb-textarea", value: memoryDraft.acceptance, onChange: (e) => setMemoryDraft((m) => ({ ...m, acceptance: e.target.value })) }) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "追加新决定(每行一条)"), (0, import_react.createElement)("textarea", { rows: 2, className: "wb-textarea", value: memoryDraft.decisions, placeholder: "可选:记录新增项目级决定", onChange: (e) => setMemoryDraft((m) => ({ ...m, decisions: e.target.value })) }) ), (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 } }, (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setMemoryEditing(false) }, "取消"), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy, onClick: () => void saveMemory() }, busy ? "保存中…" : "保存为 v" + (rev + 1)) ) ); } return [ (0, import_react.createElement)( "section", { key: "mhero", className: "wb-card", style: { borderLeft: "3px solid var(--ss-primary)" } }, (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "center", gap: 8 } }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "项目共识"), (0, import_react.createElement)("span", { className: "ss-pill font-mono-num is-primary" }, "v" + rev) ), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setMemoryEditing(true) }, "编辑共识") ), (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.6 } }, memory?.goal || "尚未填写项目目标。保存后将自动注入各部门提示词与派工上下文。") ), (0, import_react.createElement)( "div", { key: "mgrid1", className: "consensus-grid" }, (0, import_react.createElement)( "section", { className: "wb-card" }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "硬约束"), (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, constraints.length + " 条") ), constraints.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无硬约束。") : (0, import_react.createElement)( "ul", { style: { margin: 0, padding: 0, listStyle: "none", display: "flex", flexDirection: "column", gap: 6 } }, constraints.map((c, idx) => (0, import_react.createElement)( "li", { key: idx, style: { display: "flex", gap: 8 } }, (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-primary)", flexShrink: 0 } }, idx + 1 + "."), (0, import_react.createElement)("span", { style: { lineHeight: 1.5 } }, c) )) ) ), (0, import_react.createElement)( "section", { className: "wb-card" }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "验收标准"), (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, acceptance.length + " 条") ), acceptance.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无验收标准。") : (0, import_react.createElement)( "ul", { style: { margin: 0, padding: 0, listStyle: "none", display: "flex", flexDirection: "column", gap: 6 } }, acceptance.map((a, idx) => (0, import_react.createElement)( "li", { key: idx, style: { display: "flex", gap: 8 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-success)", flexShrink: 0 } }, "✓"), (0, import_react.createElement)("span", { style: { lineHeight: 1.5 } }, a) )) ) ) ), (0, import_react.createElement)( "div", { key: "mgrid2", className: "consensus-grid" }, (0, import_react.createElement)( "section", { className: "wb-card" }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "现行决定 (" + decisionsList.length + ")"), decisionsList.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无记录。") : decisionsList.slice(-6).map((dec, idx) => (0, import_react.createElement)( "div", { key: idx, className: "kv-box" }, (0, import_react.createElement)("div", null, dec.text), (0, import_react.createElement)( "div", { className: "font-mono-num", style: { color: "var(--ss-muted)", marginTop: 4 } }, (dec.recordedAt ? dateText(dec.recordedAt) : "项目记录") + " · " + (dec.status === "active" ? "现行" : "已归档") ) )) ), (0, import_react.createElement)( "section", { className: "wb-card" }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "成果登记 (" + artifacts.length + ")"), (0, import_react.createElement)("button", { type: "button", className: "frameless-btn", onClick: () => setArtifactModalOpen(true) }, PlusIcon(), " 登记成果") ), artifacts.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "还没有登记成果。") : artifacts.map((a) => (0, import_react.createElement)( "div", { key: a.id, className: "kv-box" }, (0, import_react.createElement)("div", { style: { fontWeight: 500 } }, a.title), a.path ? (0, import_react.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-primary)", wordBreak: "break-all", marginTop: 2 } }, a.path) : null, a.summary ? (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, a.summary) : null )) ) ) ]; } function renderConfigTab() { return [ (0, import_react.createElement)( "section", { key: "binding", className: "wb-card" }, (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "center", gap: 8 } }, (0, import_react.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "项目绑定与全局默认(R-001)"), (0, import_react.createElement)( "p", { className: "font-mono-num truncate", style: { margin: "2px 0 0", color: "var(--ss-muted)" } }, (wb.project.path || wb.project.name || "—") + " · " + (wb.project.workspaceId || "—") ) ), (0, import_react.createElement)("span", { className: "ss-pill is-success" }, "项目隔离已生效") ) ), (0, import_react.createElement)( "section", { key: "seatlist", className: "wb-card", style: { padding: 0, overflow: "hidden", gap: 0 } }, (0, import_react.createElement)( "div", { style: { padding: "10px 14px", borderBottom: "1px solid var(--ss-border)", display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "center", gap: 8 } }, (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "十席开关与模型配置"), (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "点击任一席位展开配置模型与说明") ), (0, import_react.createElement)("div", null, SEAT_IDS.map((id) => { const seat = seatById[id]; const tone = seatTone(seat); const expanded = expandedConfigSeatId === id; const rec = seatRecMap[id] || {}; const actLabel = seat.status === "bound" ? "打开" : seat.status === "missing" ? "重建" : "上线"; const actHandler = seat.status === "bound" ? () => void openSeat(id) : seat.status === "missing" ? () => void rebuildSeat(id) : () => void enableSeat(id); const configured = rec.configuredModel ?? rec.model ?? null; const modelShort = shortModelName(configured); const srcShort = rec.modelSource === "project" ? "项目覆盖" : rec.modelSource === "global" ? "全局默认" : "未设默认"; return (0, import_react.createElement)( "div", { key: id, className: "cfg-row" + (expanded ? " is-open" : "") }, (0, import_react.createElement)( "div", { className: "cfg-row-head" }, (0, import_react.createElement)( "button", { type: "button", className: "cfg-row-toggle", "aria-expanded": expanded, onClick: () => setExpandedConfigSeatId(expanded ? null : id) }, (0, import_react.createElement)("span", { className: "ss-dot is-" + tone }), (0, import_react.createElement)( "div", { className: "cfg-seat-info" }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 14, flexShrink: 0, color: expanded ? "var(--ss-primary)" : "var(--ss-fg)" } }, seat.name), (0, import_react.createElement)("span", { className: "truncate", style: { color: "var(--ss-muted)" } }, seat.duty) ), (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 } }, (0, import_react.createElement)("span", { className: "font-mono-num truncate" }, modelShort), (0, import_react.createElement)("span", { className: "ss-pill" + (rec.modelSource === "project" ? " is-primary" : "") }, srcShort), seat.modelSyncStatus === "failed" ? (0, import_react.createElement)("span", { style: { color: "var(--ss-error)", fontWeight: 500, flexShrink: 0 } }, "同步失败") : null ) ) ), (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 6, paddingRight: 12, flexShrink: 0 } }, (0, import_react.createElement)("button", { type: "button", className: seat.status === "pending" ? "wb-btn-primary" : "wb-btn-outline", disabled: busy || seat.status === "creating", onClick: actHandler }, actLabel), (0, import_react.createElement)("button", { type: "button", "aria-label": "展开配置", style: { width: 28, height: 28, display: "inline-flex", alignItems: "center", justifyContent: "center", borderRadius: 6, color: "var(--ss-muted)" }, onClick: () => setExpandedConfigSeatId(expanded ? null : id) }, ChevronDown(expanded)) ) ), expanded ? (0, import_react.createElement)("div", { className: "cfg-inline-panel" }, renderModelControlsForSeat(id, saveSeatConfigFor)) : null ); })) ) ]; } function renderModals() { if (selectedTask) { const liveTask = tasks.find((t) => t.id === selectedTask.id) || selectedTask; const tm = TASK_META[liveTask.status] || { label: liveTask.status, tone: "muted" }; const seatLabel2 = SEATS[liveTask.ownerSeatId]?.label || liveTask.ownerSeatId || "—"; const orig = liveTask.requirementSnapshot?.originalText || liveTask.requirement; return (0, import_react.createElement)( "div", { className: "wb-modal-backdrop", onClick: (e) => { if (e.target === e.currentTarget) setSelectedTask(null); } }, (0, import_react.createElement)( "div", { className: "wb-modal", role: "dialog", "aria-modal": "true" }, (0, import_react.createElement)( "div", { className: "wb-modal-head" }, (0, import_react.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8, fontSize: 12 } }, (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, liveTask.id), (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label), (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, seatLabel2) ), (0, import_react.createElement)("h3", { className: "wb-modal-title", style: { marginTop: 4 } }, liveTask.title) ), (0, import_react.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭", onClick: () => setSelectedTask(null) }, "✕") ), (0, import_react.createElement)( "div", { className: "wb-modal-body" }, liveTask.kind === "workflow" ? renderStageStepper(liveTask.stage) : null, orig ? (0, import_react.createElement)( "div", { style: { borderRadius: 8, border: "1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))", padding: 10 } }, (0, import_react.createElement)("div", { style: { color: "var(--ss-primary)", fontWeight: 500, marginBottom: 4 } }, "用户原话"), (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, "「" + orig + "」") ) : null, (0, import_react.createElement)( "div", null, (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", fontWeight: 500, marginBottom: 4 } }, "任务说明"), (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.6, whiteSpace: "pre-wrap" } }, liveTask.goal || "(无任务说明)") ), liveTask.workflowBlockage ? (0, import_react.createElement)( "div", { className: "wb-alert", style: { flexDirection: "column", alignItems: "flex-start" } }, (0, import_react.createElement)("div", { style: { fontWeight: 600 } }, "当前阻塞 · " + liveTask.workflowBlockage.label), (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-fg)" } }, liveTask.workflowBlockage.reason), (0, import_react.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => { setSelectedTask(null); void openSeat(liveTask.ownerSeatId); } }, "打开" + seatLabel2 + "会话"), liveTask.deliveryState === "unknown" && liveTask.deliveryId ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy, onClick: () => void redispatchTask(liveTask) }, "显式重投此任务") : null ) ) : null, Array.isArray(liveTask.consultations) && liveTask.consultations.length > 0 ? (0, import_react.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 6 } }, (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", fontWeight: 500 } }, "会商记录 (" + liveTask.consultations.length + ")"), liveTask.consultations.map((c) => (0, import_react.createElement)( "div", { key: c.id || c.createdAt, className: "kv-box" }, (0, import_react.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", gap: 8, color: "var(--ss-muted)", marginBottom: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-fg)", fontWeight: 500 } }, (SEATS[c.fromSeatId]?.label || c.fromSeatId) + " → " + (c.toSeatIds || []).map((x) => SEATS[x]?.label || x).join("、")), (0, import_react.createElement)("span", { className: "font-mono-num" }, dateText(c.createdAt)) ), (0, import_react.createElement)("div", { style: { lineHeight: 1.55 } }, c.text) )) ) : null, (0, import_react.createElement)( "div", null, (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", fontWeight: 500, marginBottom: 4 } }, "任务完成情况"), (0, import_react.createElement)("div", { className: "kv-box", style: { whiteSpace: "pre-wrap", lineHeight: 1.6 } }, liveTask.result || liveTask.note || "(尚未回报结果)") ) ), (0, import_react.createElement)( "div", { className: "wb-modal-foot" }, (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setSelectedTask(null) }, "关闭") ) ) ); } if (durationModalOpen) { const rows = tasks.map((t) => ({ task: t, ms: taskDurationMs(t) })).filter((r) => r.ms > 0).sort((a, b) => b.ms - a.ms); return (0, import_react.createElement)( "div", { className: "wb-modal-backdrop", onClick: (e) => { if (e.target === e.currentTarget) setDurationModalOpen(false); } }, (0, import_react.createElement)( "div", { className: "wb-modal", role: "dialog", "aria-modal": "true" }, (0, import_react.createElement)( "div", { className: "wb-modal-head" }, (0, import_react.createElement)("h3", { className: "wb-modal-title" }, "任务耗时与用量说明"), (0, import_react.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭", onClick: () => setDurationModalOpen(false) }, "✕") ), (0, import_react.createElement)( "div", { className: "wb-modal-body" }, rows.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无任务耗时记录。") : (0, import_react.createElement)( "div", { style: { borderRadius: 8, border: "1px solid var(--ss-border)", overflow: "hidden" } }, (0, import_react.createElement)( "table", { className: "queue-table" }, (0, import_react.createElement)("thead", null, (0, import_react.createElement)("tr", null, (0, import_react.createElement)("th", null, "任务"), (0, import_react.createElement)("th", null, "承办"), (0, import_react.createElement)("th", { style: { textAlign: "right" } }, "耗时"))), (0, import_react.createElement)("tbody", null, rows.map((r) => (0, import_react.createElement)( "tr", { key: r.task.id }, (0, import_react.createElement)("td", null, r.task.title), (0, import_react.createElement)("td", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[r.task.ownerSeatId]?.label || "—"), (0, import_react.createElement)("td", { className: "font-mono-num", style: { textAlign: "right" } }, durationText(r.ms)) ))) ) ), (0, import_react.createElement)( "div", { className: "kv-box", style: { color: "var(--ss-muted)", lineHeight: 1.6 } }, (0, import_react.createElement)("strong", { style: { color: "var(--ss-fg)" } }, "关于 Token 与金额统计:"), "宿主尚未提供稳定 usage 数据源,这里不展示估算或虚构金额,接入真实用量后会在此呈现。" ) ) ) ); } if (artifactModalOpen) { return (0, import_react.createElement)( "div", { className: "wb-modal-backdrop", onClick: (e) => { if (e.target === e.currentTarget) setArtifactModalOpen(false); } }, (0, import_react.createElement)( "div", { className: "wb-modal", role: "dialog", "aria-modal": "true" }, (0, import_react.createElement)( "div", { className: "wb-modal-head" }, (0, import_react.createElement)("h3", { className: "wb-modal-title" }, "登记项目成果"), (0, import_react.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭", onClick: () => setArtifactModalOpen(false) }, "✕") ), (0, import_react.createElement)( "div", { className: "wb-modal-body" }, (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "成果名称"), (0, import_react.createElement)("input", { type: "text", className: "wb-input", value: artifactDraft.title, placeholder: "例如:竞品分析报告 v1", onChange: (e) => setArtifactDraft((p) => ({ ...p, title: e.target.value })) }) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "文件路径"), (0, import_react.createElement)("input", { type: "text", className: "wb-input", value: artifactDraft.path, placeholder: "例如:docs/竞品分析.md", onChange: (e) => setArtifactDraft((p) => ({ ...p, path: e.target.value })) }) ), (0, import_react.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "摘要"), (0, import_react.createElement)("textarea", { rows: 3, className: "wb-textarea", value: artifactDraft.summary, placeholder: "这份成果解决了什么、在哪里", onChange: (e) => setArtifactDraft((p) => ({ ...p, summary: e.target.value })) }) ) ), (0, import_react.createElement)( "div", { className: "wb-modal-foot" }, (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setArtifactModalOpen(false) }, "取消"), (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy, onClick: () => void addArtifact() }, busy ? "提交中…" : "登记成果") ) ) ); } return null; } function renderMainBody() { if (phase === "loading") return (0, import_react.createElement)("div", { className: "wb-empty-box" }, "正在载入项目工作台…"); if (phase === "no-workspace") return (0, import_react.createElement)("div", { className: "wb-empty-box" }, "当前会话尚未关联工作区,请在宿主中打开项目文件夹后重试。"); if (phase === "error" && !view) { return (0, import_react.createElement)( "div", { className: "wb-alert", style: { flexDirection: "column", alignItems: "flex-start" } }, (0, import_react.createElement)("span", null, error || "工作台加载失败"), errorRetryable ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", onClick: () => void loadProject() }, "重试") : null ); } if (tab === "flow") return renderFlowTab(); if (tab === "deliberation") return renderDeliberationTab(); if (tab === "memory") return renderMemoryTab(); if (tab === "config") return renderConfigTab(); return renderCourtTab(); } const navTabs = [ { id: "court", label: "朝堂", badge: pendingCount > 0 ? String(pendingCount) : null, tone: "primary" }, { id: "flow", label: "流转", badge: openTasksCount > 0 ? String(openTasksCount) : null, tone: "primary" }, { id: "deliberation", label: "议政", badge: activeDelib ? "进行中" : null, tone: "success" }, { id: "memory", label: "共识", badge: (memory?.revision ?? 0) > 0 ? "v" + memory.revision : null, tone: "muted" }, { id: "config", label: "配置", badge: syncIssues > 0 ? String(syncIssues) : null, tone: "error" } ]; const headerDotTone = syncIssues > 0 ? "is-error" : runningSeatsCount > 0 ? "is-success is-pulse" : "is-muted"; return (0, import_react.createElement)( "div", { className: "ssv2 ssw-tab-body", "data-sansheng-sidebar": "1" }, (0, import_react.createElement)( "header", { className: "wb-header" }, (0, import_react.createElement)( "div", { className: "wb-header-row" }, (0, import_react.createElement)( "div", { className: "wb-brand" }, (0, import_react.createElement)("div", { className: "wb-seal-badge" }, "省"), (0, import_react.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react.createElement)( "div", { className: "wb-brand-title-row" }, (0, import_react.createElement)("h1", { className: "wb-brand-title" }, "三省六部"), (0, import_react.createElement)("span", { className: "wb-role-badge hide-narrow" }, "单项目侧栏") ), (0, import_react.createElement)( "p", { className: "wb-subline" }, activeChatSeatId ? "固定绑定当前会话项目 · 当前对话:" + (SEATS[activeChatSeatId]?.label || activeChatSeatId) : "固定绑定当前会话项目 · " + wb.project.boundCount + " / " + wb.project.seatCount + " 席已绑定" ) ) ), (0, import_react.createElement)( "span", { className: "wb-proj-pill", title: "已固定绑定当前会话所属项目" }, (0, import_react.createElement)("span", { className: "ss-dot " + headerDotTone }), (0, import_react.createElement)("span", { className: "wb-proj-name" }, wb.project.name || wb.projectTitle || "当前项目") ) ), (0, import_react.createElement)( "nav", { className: "wb-tabs", role: "tablist", "aria-label": "工作台导航" }, navTabs.map((t) => (0, import_react.createElement)( "button", { key: t.id, type: "button", role: "tab", "aria-selected": tab === t.id, className: "wb-tab-btn" + (tab === t.id ? " is-active" : ""), onClick: () => setTab(t.id) }, (0, import_react.createElement)("span", null, t.label), t.badge ? (0, import_react.createElement)("span", { className: "wb-tab-badge ss-pill is-" + t.tone }, t.badge) : null )) ) ), error && view ? (0, import_react.createElement)( "div", { className: "wb-toast-wrap" }, (0, import_react.createElement)( "div", { className: "wb-toast-box is-error", role: "alert" }, (0, import_react.createElement)("span", null, error), (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", onClick: () => setError(null) }, "✕") ) ) : !error && notice ? (0, import_react.createElement)( "div", { className: "wb-toast-wrap" }, (0, import_react.createElement)( "div", { className: "wb-toast-box is-primary", role: "status" }, (0, import_react.createElement)("span", null, notice), (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", onClick: () => setNotice(null) }, "✕") ) ) : null, (0, import_react.createElement)("main", { className: "wb-body" }, renderMainBody()), (0, import_react.createElement)( "footer", { className: "wb-footer" }, (0, import_react.createElement)( "span", { className: "truncate" }, "项目 " + (wb.project.name || "—") + " · " + wb.project.boundCount + " / " + wb.project.seatCount + " 席已绑定 · 共识 v" + (memory?.revision ?? 0) ), (0, import_react.createElement)( "button", { type: "button", className: "wb-refresh-btn", disabled: busy, onClick: () => void loadProject() }, RefreshIcon(), (0, import_react.createElement)("span", null, "刷新") ) ), renderModals() ); } // src/client/master-workbench.js var import_react2 = require("react"); function smallSvg2(children, props) { return (0, import_react2.createElement)("svg", { viewBox: "0 0 24 24", width: 13, height: 13, fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", ...props || {} }, children); } var SearchSvg = (props) => smallSvg2([ (0, import_react2.createElement)("circle", { key: "c", cx: 11, cy: 11, r: 8 }), (0, import_react2.createElement)("path", { key: "p", d: "m21 21-4.3-4.3" }) ], props); var ChevronDownSvg = (props) => smallSvg2([ (0, import_react2.createElement)("polyline", { key: "p", points: "6 9 12 15 18 9" }) ], props); var SlidersSvg = () => smallSvg2([ (0, import_react2.createElement)("path", { key: "p", d: "M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M2 14h4M10 8h4M18 16h4" }) ], { strokeWidth: 1.8 }); function formatDateTime(ts) { const n = Number(ts); if (!Number.isFinite(n) || n <= 0) return "—"; const d = new Date(n); const p = (x) => String(x).padStart(2, "0"); return d.getMonth() + 1 + "-" + p(d.getDate()) + " " + p(d.getHours()) + ":" + p(d.getMinutes()); } function stageTone(col) { if (col === "done" || col === "running") return "success"; if (col === "review") return "primary"; return "muted"; } function stageTitle(col) { if (col === "done") return "已交付"; if (col === "review") return "门下复核"; if (col === "running") return "六部执行中"; return "待规划 · 需求池"; } function dotToneClass(tone, pulse) { const cls = "ss-dot is-" + (tone || "muted"); return pulse ? cls + " is-pulse" : cls; } function copyText(text, onDone) { try { if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) { void navigator.clipboard.writeText(text).then(() => onDone(true)).catch(() => onDone(false)); return; } } catch { } onDone(false); } function MasterWorkbench(props) { const { getCurrentWorkspace, navigateToSession } = props || {}; const [loading, setLoading] = (0, import_react2.useState)(true); const [projects, setProjects] = (0, import_react2.useState)([]); const [bundles, setBundles] = (0, import_react2.useState)([]); const [approvals, setApprovals] = (0, import_react2.useState)([]); const [degradedInfo, setDegradedInfo] = (0, import_react2.useState)(null); const [modelsCatalog, setModelsCatalog] = (0, import_react2.useState)(null); const [globalDefaults, setGlobalDefaults] = (0, import_react2.useState)(null); const [projectFilter, setProjectFilter] = (0, import_react2.useState)("all"); const [projMenuOpen, setProjMenuOpen] = (0, import_react2.useState)(false); const [viewMode, setViewMode] = (0, import_react2.useState)("board"); const [search, setSearch] = (0, import_react2.useState)(""); const [searchOpen, setSearchOpen] = (0, import_react2.useState)(false); const [pendingExpanded, setPendingExpanded] = (0, import_react2.useState)(true); const [drawer, setDrawer] = (0, import_react2.useState)(null); const [taskTab, setTaskTab] = (0, import_react2.useState)("overview"); const [expandedGlobalSeatId, setExpandedGlobalSeatId] = (0, import_react2.useState)(null); const [frameWidth, setFrameWidth] = (0, import_react2.useState)(1280); const [busy, setBusy] = (0, import_react2.useState)(false); const [toast, setToast] = (0, import_react2.useState)(null); const alive = (0, import_react2.useRef)(true); const rootRef = (0, import_react2.useRef)(null); const narrowSearchRef = (0, import_react2.useRef)(null); const toastTimerRef = (0, import_react2.useRef)(null); const autoOpenedOnce = (0, import_react2.useRef)(false); const answerVersion = (0, import_react2.useRef)(0); const showToast = (0, import_react2.useCallback)((text, tone = "primary") => { setToast({ text, tone }); if (toastTimerRef.current) clearTimeout(toastTimerRef.current); toastTimerRef.current = setTimeout(() => { if (alive.current) setToast(null); }, 3400); }, []); (0, import_react2.useEffect)(() => { alive.current = true; return () => { alive.current = false; if (toastTimerRef.current) clearTimeout(toastTimerRef.current); }; }, []); const loadAll = (0, import_react2.useCallback)(async ({ silent = false } = {}) => { const startVer = answerVersion.current; try { let listRes = await request("list"); let projList = Array.isArray(listRes?.projects) ? listRes.projects : []; if (projList.length === 0 && !autoOpenedOnce.current && typeof getCurrentWorkspace === "function") { const ws = getCurrentWorkspace(); if (ws && (ws.workspaceId || ws.path)) { autoOpenedOnce.current = true; try { await request("open", { workspaceId: ws.workspaceId, name: ws.name, path: ws.path }); listRes = await request("list"); projList = Array.isArray(listRes?.projects) ? listRes.projects : []; } catch { } } } const [modelsRes, globalRes] = await Promise.allSettled([ request("models"), request("globalDefaults") ]); const detailSettled = await Promise.all(projList.map(async (summary) => { const [projR, tasksR, reqsR, apprR, artR] = await Promise.allSettled([ request("project", { projectId: summary.id }), request("tasks", { projectId: summary.id }), request("requirements", { projectId: summary.id }), request("approvals", { projectId: summary.id }), request("artifacts", { projectId: summary.id }) ]); return { summary, projR, tasksR, reqsR, apprR, artR }; })); if (!alive.current) return; if (modelsRes.status === "fulfilled" && modelsRes.value) setModelsCatalog(modelsRes.value); if (globalRes.status === "fulfilled" && globalRes.value) setGlobalDefaults(globalRes.value); setBundles((prev) => { const prevMap = new Map(prev.map((b) => [b.project?.id, b])); return detailSettled.map(({ summary, projR, tasksR, reqsR, artR }) => { const old = prevMap.get(summary.id); const projectObj = projR.status === "fulfilled" ? projR.value?.project ?? projR.value : old?.project ?? { id: summary.id, name: summary.name, status: summary.status, seats: [] }; const tasks = tasksR.status === "fulfilled" && Array.isArray(tasksR.value?.tasks) ? tasksR.value.tasks : old?.tasks ?? []; const requirements = reqsR.status === "fulfilled" && Array.isArray(reqsR.value?.requirements) ? reqsR.value.requirements : old?.requirements ?? []; const artifacts = artR.status === "fulfilled" && Array.isArray(artR.value?.artifacts) ? artR.value.artifacts : old?.artifacts ?? []; return { project: projectObj, tasks, requirements, artifacts }; }); }); setProjects(projList.map((p, idx) => ({ ...p, colorVar: PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length] }))); if (answerVersion.current === startVer) { const nextApprovals = []; let degraded = null; detailSettled.forEach(({ summary, apprR }, idx) => { const colorVar = PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length]; if (apprR.status === "fulfilled") { const st = apprR.value?.status; if (st?.degraded) degraded = st.reason || "approval-center-degraded"; const list = Array.isArray(apprR.value?.approvals) ? apprR.value.approvals : []; for (const entry of list) { nextApprovals.push({ ...entry, projectId: entry.projectId || summary.id, projectName: summary.name, colorVar }); } } else { degraded = apprR.reason?.message || "审批队列暂不可达"; } }); setApprovals(nextApprovals); setDegradedInfo(degraded); } setLoading(false); } catch (error) { if (!alive.current) return; setLoading(false); if (!silent) showToast(error?.message || "总台状态加载失败", "error"); } }, [getCurrentWorkspace, showToast]); (0, import_react2.useEffect)(() => { void loadAll(); let running = false; const tick = async () => { if (running) return; if (typeof document !== "undefined" && document.visibilityState === "hidden") return; running = true; try { await loadAll({ silent: true }); } finally { running = false; } }; const timer = setInterval(() => { void tick(); }, 4e3); const onVis = () => { if (document.visibilityState === "visible") void tick(); }; if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVis); return () => { clearInterval(timer); if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVis); }; }, [loadAll]); (0, import_react2.useEffect)(() => { const node = rootRef.current; if (!node) return void 0; const sync = (w) => { if (w > 0) setFrameWidth(w); }; if (node.clientWidth > 0) sync(node.clientWidth); if (typeof ResizeObserver === "undefined") return void 0; const observer = new ResizeObserver((entries) => { const w = entries[0]?.contentRect?.width || node.clientWidth; sync(w); }); observer.observe(node); return () => observer.disconnect(); }, []); (0, import_react2.useEffect)(() => { if (typeof document === "undefined") return void 0; const onDown = (e) => { if (projMenuOpen && !e.target.closest?.(".mwb-proj-wrap")) setProjMenuOpen(false); }; const onKey = (e) => { if (e.key !== "Escape") return; if (projMenuOpen) { setProjMenuOpen(false); return; } if (searchOpen && frameWidth <= 760) { setSearchOpen(false); return; } if (drawer) setDrawer(null); }; document.addEventListener("mousedown", onDown); document.addEventListener("keydown", onKey); return () => { document.removeEventListener("mousedown", onDown); document.removeEventListener("keydown", onKey); }; }, [projMenuOpen, searchOpen, frameWidth, drawer]); const projectMetaById = (0, import_react2.useMemo)(() => { const map = /* @__PURE__ */ new Map(); bundles.forEach((b, idx) => { if (b?.project?.id) { map.set(b.project.id, { id: b.project.id, name: b.project.name || b.project.id, path: b.project.path || b.project.workspaceId || "", colorVar: PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length] }); } }); return map; }, [bundles]); const modelOptions = (0, import_react2.useMemo)(() => collectModelOptions(modelsCatalog), [modelsCatalog]); const modelChoices = (0, import_react2.useMemo)(() => groupModelChoices(modelOptions), [modelOptions]); const allItems = (0, import_react2.useMemo)(() => buildMasterItems(bundles, modelOptions), [bundles, modelOptions]); const visibleItems = (0, import_react2.useMemo)(() => filterMasterItems(allItems, { projectFilter, search }), [allItems, projectFilter, search]); const pendingEntries = (0, import_react2.useMemo)(() => { const out = []; for (const a of approvals) { if (projectFilter !== "all" && a.projectId !== projectFilter) continue; out.push({ kind: "approval", data: a }); } for (const item of allItems) { if (projectFilter !== "all" && item.projectId !== projectFilter) continue; for (const d of item.decisions || []) { if (d.status === "pending") out.push({ kind: "decision", item, data: d }); } } return out; }, [approvals, allItems, projectFilter]); const hasPendingBlock = pendingExpanded && (pendingEntries.length > 0 || Boolean(degradedInfo)); const layoutMode = computeMasterLayoutMode(frameWidth, hasPendingBlock); const isNarrow = layoutMode === "list"; const compactSearch = frameWidth <= 760; const effectiveProjectMeta = projectFilter !== "all" ? projectMetaById.get(projectFilter) : null; const activeProjList = (0, import_react2.useMemo)(() => bundles.map((b, idx) => { const pid = b.project?.id; const meta = projectMetaById.get(pid); const activeCnt = allItems.filter((it) => it.projectId === pid && it.col !== "done").length; const pendCnt = approvals.filter((a) => a.projectId === pid).length + allItems.filter((it) => it.projectId === pid).reduce((acc, it) => acc + (it.decisions || []).filter((d) => d.status === "pending").length, 0); return { id: pid, name: meta?.name || pid, path: meta?.path || "", colorVar: meta?.colorVar || PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length], activeCnt, pendCnt }; }), [bundles, projectMetaById, allItems, approvals]); const totalPendingAll = approvals.length + allItems.reduce((acc, it) => acc + (it.decisions || []).filter((d) => d.status === "pending").length, 0); const totalActiveAll = allItems.filter((it) => it.col !== "done").length; const doneItems = (0, import_react2.useMemo)(() => visibleItems.filter((it) => it.col === "done"), [visibleItems]); async function handleOpenSeat(projectId, seatId) { if (!projectId || !seatId) return; const bundle = bundles.find((b) => b.project?.id === projectId); const seats = bundle?.project?.seats; const seatRec = Array.isArray(seats) ? seats.find((s) => s.id === seatId) : seats?.[seatId]; const seatName = SEATS[seatId]?.label || seatId; setBusy(true); try { if (seatRec?.status === "missing") { await request("rebuildSeat", { projectId, seatId, expectedSessionId: seatRec.sessionId || void 0 }); showToast("已重建「" + seatName + "」会话(保留历史任务)", "success"); await loadAll({ silent: true }); return; } if (seatRec?.status !== "bound") { await request("enableSeat", { projectId, seatId }); } const res = await request("openSeat", { projectId, seatId }); if (res?.sessionId && typeof navigateToSession === "function") { navigateToSession(res.sessionId); showToast("已打开「" + seatName + "」会话", "primary"); } else { showToast("已就绪「" + seatName + "」独立会话", "success"); await loadAll({ silent: true }); } } catch (error) { showToast(error?.message || "打开席位会话失败", "error"); await loadAll({ silent: true }); } finally { if (alive.current) setBusy(false); } } async function handleApproval(entry, choice) { if (!entry || busy) return; setBusy(true); try { answerVersion.current += 1; await request("approvalAnswer", { projectId: entry.projectId, seatId: entry.seatId, id: entry.id, sessionId: entry.sessionId, choice }); setApprovals((prev) => prev.filter((a) => !(a.id === entry.id && a.sessionId === entry.sessionId))); showToast((choice === "allow" ? "已允许「" : "已拒绝「") + (SEATS[entry.seatId]?.label || entry.seatId) + "」工具执行", choice === "allow" ? "success" : "error"); await loadAll({ silent: true }); } catch (error) { showToast(error?.message || "审批应答失败", "error"); await loadAll({ silent: true }); } finally { if (alive.current) setBusy(false); } } async function handleDecision(item, decision, option) { if (!item || !decision || !option || busy) return; setBusy(true); try { answerVersion.current += 1; await request("taskDecisionAnswer", { projectId: item.projectId, taskId: item.id, decisionId: decision.id, value: option.value }); setBundles((prev) => prev.map((b) => { if (b.project?.id !== item.projectId) return b; return { ...b, tasks: (b.tasks || []).map((t) => t.id === item.id && Array.isArray(t.decisions) ? { ...t, decisions: t.decisions.map((d) => d.id === decision.id ? { ...d, status: "answered", answer: option.value } : d) } : t) }; })); showToast("已提交项目决定:" + option.label, "success"); await loadAll({ silent: true }); } catch (error) { showToast(error?.message || "提交决定失败", "error"); } finally { if (alive.current) setBusy(false); } } async function handleRedispatch(item) { const blk = item?.blockage; if (!item || !blk?.canRedispatch || !blk.deliveryId || busy) return; const targetTaskId = blk.targetTaskId || item.id; setBusy(true); try { const res = await request("taskRedispatch", { projectId: item.projectId, taskId: targetTaskId, expectedDeliveryId: blk.deliveryId }); const st = res?.delivery?.status; showToast(st === "sent" ? "已显式重投任务「" + targetTaskId + "」并送达会话" : "重投状态:" + (res?.delivery?.reason || st || "已处理"), st === "sent" ? "success" : "primary"); await loadAll({ silent: true }); } catch (error) { showToast(error?.message || "显式重投失败", "error"); } finally { if (alive.current) setBusy(false); } } async function handleSetGlobalSeat(seatId, modelObj) { if (!seatId || busy) return; setBusy(true); try { const res = modelObj ? await request("setGlobalDefault", { seatId, model: modelObj }) : await request("clearGlobalDefault", { seatId }); if (res?.globalDefaults) setGlobalDefaults(res.globalDefaults); const appliedCnt = Array.isArray(res?.applied) ? res.applied.length : 0; const failedCnt = Array.isArray(res?.failed) ? res.failed.length : 0; const label = SEATS[seatId]?.label || seatId; if (!modelObj) { showToast("已清除「" + label + "」全局默认设置" + (appliedCnt ? "(已同步 " + appliedCnt + " 个项目)" : ""), "primary"); } else { showToast("已更新「" + label + "」全局默认模型(已同步 " + appliedCnt + " 项" + (failedCnt ? ",失败 " + failedCnt + " 项" : "") + ")", failedCnt ? "error" : "success"); } await loadAll({ silent: true }); } catch (error) { showToast(error?.message || "全局默认模型保存失败", "error"); } finally { if (alive.current) setBusy(false); } } async function handleSeedGlobalDefaults() { if (busy) return; const targetProjId = projectFilter !== "all" ? projectFilter : projects[0]?.id ?? void 0; setBusy(true); try { const res = await request("seedGlobalDefaults", targetProjId ? { projectId: targetProjId } : {}); if (res?.globalDefaults) setGlobalDefaults(res.globalDefaults); if (res?.seeded) { showToast("已按项目同步初始化十席全局默认模型", "success"); } else if (res?.status === "existing") { showToast("全局默认配置文件已存在,未覆盖当前配置", "primary"); } else { showToast("未找到可用的基准项目,请逐席设置或先选择单个项目", "error"); } } catch (error) { showToast(error?.message || "同步初始化全局默认失败", "error"); } finally { if (alive.current) setBusy(false); } } function renderPendingZone(fullHeight) { return (0, import_react2.createElement)( "section", { className: "frameless-zone" + (fullHeight ? " is-dock-full" : ""), "aria-label": "待你处理" }, (0, import_react2.createElement)( "div", { className: "frameless-zone-head" }, (0, import_react2.createElement)( "div", { className: "frameless-zone-title-wrap" }, (0, import_react2.createElement)("span", { className: "ss-dot is-primary is-pulse" }), (0, import_react2.createElement)("h2", { className: "frameless-zone-title" }, "待你处理"), (0, import_react2.createElement)("span", { className: "frameless-zone-count" }, String(pendingEntries.length)), (0, import_react2.createElement)("span", { className: "frameless-zone-sub" }, projectFilter === "all" ? "跨项目" : effectiveProjectMeta?.name || "") ), (0, import_react2.createElement)("button", { type: "button", className: "wb-toast-close", onClick: () => setPendingExpanded(false) }, "收起") ), degradedInfo ? (0, import_react2.createElement)( "div", { className: "frameless-code", style: { color: "var(--ss-error)" } }, "部分项目无法获取宿主工具审批队列(" + degradedInfo + "),请在席位会话内使用原生审批卡。" ) : null, (0, import_react2.createElement)( "div", { className: "frameless-zone-list" + (fullHeight ? " is-scroll" : "") }, pendingEntries.map((entry) => { if (entry.kind === "approval") { const a = entry.data; return (0, import_react2.createElement)( "article", { className: "frameless-item", key: "apr:" + a.sessionId + ":" + a.id }, (0, import_react2.createElement)( "div", { className: "frameless-item-head" }, (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + (a.colorVar || "--ss-primary") + ")", flexShrink: 0 } }), (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontSize: 12, fontWeight: 500 } }, a.projectName || a.projectId) ), (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 6, marginLeft: "auto" } }, (0, import_react2.createElement)("span", { className: "frameless-chip is-err" }, (0, import_react2.createElement)("span", { className: "ss-dot is-error" }), "工具审批"), (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 13 } }, SEATS[a.seatId]?.label || a.seatId) ) ), (0, import_react2.createElement)( "div", { className: "frameless-code" }, a.tool ? (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", marginRight: 6 } }, "[" + a.tool + "]") : null, a.reason || a.detail?.text || "等待工具授权" ), (0, import_react2.createElement)( "div", { className: "frameless-actions" }, (0, import_react2.createElement)("button", { type: "button", className: "frameless-link", disabled: busy, onClick: () => void handleOpenSeat(a.projectId, a.seatId) }, "查看会话 ↗"), (0, import_react2.createElement)( "div", { className: "frameless-btn-group" }, (0, import_react2.createElement)("button", { type: "button", className: "frameless-btn", disabled: busy, onClick: () => void handleApproval(a, "reject") }, "拒绝"), (0, import_react2.createElement)("button", { type: "button", className: "frameless-primary-btn", disabled: busy, onClick: () => void handleApproval(a, "allow") }, "允许一次") ) ) ); } const d = entry.data; const it = entry.item; return (0, import_react2.createElement)( "article", { className: "frameless-item", key: "dec:" + it.key + ":" + d.id }, (0, import_react2.createElement)( "div", { className: "frameless-item-head" }, (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + it.projectColorVar + ")", flexShrink: 0 } }), (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontSize: 12, fontWeight: 500 } }, it.projectName) ), (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 6, marginLeft: "auto" } }, (0, import_react2.createElement)("span", { className: "frameless-chip is-pri" }, (0, import_react2.createElement)("span", { className: "ss-dot is-primary" }), "项目决定"), (0, import_react2.createElement)("button", { type: "button", className: "frameless-link font-mono-num", onClick: () => { setDrawer({ type: "task", itemKey: it.key }); setTaskTab("overview"); } }, it.id + " ↗") ) ), (0, import_react2.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 3 } }, (0, import_react2.createElement)("div", { style: { fontSize: 12, fontWeight: 600, color: "var(--ss-fg)" } }, it.title), (0, import_react2.createElement)("p", { style: { margin: 0, fontSize: 12, color: "var(--ss-muted)", lineHeight: 1.55 } }, d.question) ), (0, import_react2.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, (d.options || []).map((opt) => (0, import_react2.createElement)("button", { key: opt.value, type: "button", className: "frameless-btn", disabled: busy, onClick: () => void handleDecision(it, d, opt) }, opt.label)) ) ); }) ) ); } function renderKanbanCard(item) { const seat = SEATS[item.seatId]; const selected = drawer?.type === "task" && drawer.itemKey === item.key; const isBlocked = Boolean(item.blockage); const isRun = item.col === "running" && !isBlocked; const hasPendingDec = (item.decisions || []).some((d) => d.status === "pending"); const badgeTone = isBlocked ? "error" : isRun ? "success" : "muted"; return (0, import_react2.createElement)( "button", { key: item.key, type: "button", className: "mwb-kanban-card" + (isBlocked ? " is-blocked" : "") + (selected ? " is-selected" : ""), onClick: () => { setDrawer({ type: "task", itemKey: item.key }); setTaskTab("overview"); } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, width: "100%" } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + item.projectColorVar + ")", flexShrink: 0 }, title: item.projectName }), projectFilter === "all" ? [ (0, import_react2.createElement)("span", { key: "pn", className: "font-mono-num truncate", style: { color: "var(--ss-fg)", fontWeight: 500, fontSize: 12 } }, item.projectName), (0, import_react2.createElement)("span", { key: "sep", style: { color: "var(--ss-muted)", flexShrink: 0 } }, "·") ] : null, (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", flexShrink: 0, fontSize: 12 } }, item.id) ), (0, import_react2.createElement)( "span", { className: "ss-pill is-" + badgeTone }, (0, import_react2.createElement)("span", { className: dotToneClass(badgeTone, isRun) }), (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, isBlocked && layoutMode !== "board4" ? "阻塞 · " + (seat?.label || "—") : seat?.label || "—") ) ), (0, import_react2.createElement)("div", { className: "line-clamp-2", style: { fontSize: 12, fontWeight: 600, color: "var(--ss-fg)", lineHeight: 1.45 } }, item.title), (0, import_react2.createElement)( "div", { className: "mwb-card-ticker" + (isBlocked ? " is-blocked" : "") }, (0, import_react2.createElement)("span", { className: "line-clamp-2" }, item.ticker) ), (0, import_react2.createElement)( "div", { className: "mwb-card-foot", style: { width: "100%" } }, (0, import_react2.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "4px 8px" } }, item.progress ? (0, import_react2.createElement)( "span", { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 4 } }, (0, import_react2.createElement)("span", null, item.progress.done + "/" + item.progress.total), (0, import_react2.createElement)("span", { className: "mwb-progress-track" }, (0, import_react2.createElement)("span", { className: "mwb-progress-fill", style: { width: Math.round(item.progress.done / item.progress.total * 100) + "%" } })) ) : null, item.consultations?.length ? (0, import_react2.createElement)("span", null, "会商 " + item.consultations.length) : null, hasPendingDec ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)", fontWeight: 500 } }, "待决定") : null ), (0, import_react2.createElement)( "div", { className: "font-mono-num", style: { display: "flex", alignItems: "center", gap: 4, marginLeft: "auto", flexShrink: 0 } }, (0, import_react2.createElement)("span", null, item.modelLabel), (0, import_react2.createElement)("span", null, "·"), (0, import_react2.createElement)("span", null, item.durationText) ) ) ); } function renderBoardOrList() { if (loading && bundles.length === 0) { return (0, import_react2.createElement)( "div", { className: "mwb-list-wrap" }, (0, import_react2.createElement)("div", { className: "mwb-list-section", style: { padding: 32, textAlign: "center", fontSize: 12, color: "var(--ss-muted)" } }, "正在同步跨项目工作台数据…") ); } const effectiveMode = isNarrow ? "list" : viewMode; if (effectiveMode === "list") { const inlinePending = isNarrow && pendingExpanded && (pendingEntries.length > 0 || Boolean(degradedInfo)); return (0, import_react2.createElement)( "div", { className: "mwb-list-wrap" }, inlinePending ? renderPendingZone(false) : null, MASTER_ACTIVE_COLUMNS.map((col) => { const items = sortMasterColumnItems(visibleItems.filter((it) => it.col === col.id)); const blockedCnt = items.filter((it) => Boolean(it.blockage)).length; return (0, import_react2.createElement)( "section", { className: "mwb-list-section", key: col.id }, (0, import_react2.createElement)( "div", { className: "mwb-list-head" }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, (0, import_react2.createElement)("span", { className: dotToneClass(col.tone, col.id === "running" && items.length > 0) }), (0, import_react2.createElement)("span", { style: { fontWeight: 600, color: "var(--ss-fg)" }, className: "truncate" }, col.title), (0, import_react2.createElement)("span", { className: "ss-pill font-mono-num" }, String(items.length)), blockedCnt > 0 ? (0, import_react2.createElement)("span", { className: "ss-pill is-error font-mono-num" }, "阻塞 " + blockedCnt) : null ), (0, import_react2.createElement)("span", { className: "mwb-hide-compact truncate", style: { color: "var(--ss-muted)" } }, col.subtitle) ), items.length === 0 ? (0, import_react2.createElement)("div", { style: { padding: "14px 16px", fontSize: 12, color: "var(--ss-muted)" } }, "当前无任务") : items.map((item) => { const seat = SEATS[item.seatId]; const selected = drawer?.type === "task" && drawer.itemKey === item.key; const isBlocked = Boolean(item.blockage); const isRun = item.col === "running" && !isBlocked; const hasPendingDec = (item.decisions || []).some((d) => d.status === "pending"); const badgeTone = isBlocked ? "error" : isRun ? "success" : "muted"; return (0, import_react2.createElement)( "button", { key: item.key, type: "button", className: "mwb-list-row" + (isBlocked ? " is-blocked" : "") + (selected ? " is-selected" : ""), onClick: () => { setDrawer({ type: "task", itemKey: item.key }); setTaskTab("overview"); } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, width: "100%" } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + item.projectColorVar + ")", flexShrink: 0 } }), projectFilter === "all" ? [ (0, import_react2.createElement)("span", { key: "pn", className: "font-mono-num truncate", style: { color: "var(--ss-fg)", fontWeight: 500 } }, item.projectName), (0, import_react2.createElement)("span", { key: "sep", style: { color: "var(--ss-muted)" } }, "·") ] : null, (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", flexShrink: 0 } }, item.id) ), (0, import_react2.createElement)( "span", { className: "ss-pill is-" + badgeTone }, (0, import_react2.createElement)("span", { className: dotToneClass(badgeTone, isRun) }), (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, isBlocked ? "阻塞 · " + (seat?.label || "—") : seat?.label || "—") ) ), (0, import_react2.createElement)("div", { className: "line-clamp-2", style: { fontWeight: 600, color: "var(--ss-fg)" } }, item.title), (0, import_react2.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: "4px 12px", width: "100%" } }, (0, import_react2.createElement)("span", { className: "truncate", style: { minWidth: 0, flex: "1 1 160px", color: isBlocked ? "var(--ss-error)" : "var(--ss-muted)", fontWeight: isBlocked ? 500 : 400 } }, item.ticker), (0, import_react2.createElement)( "span", { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 8, color: "var(--ss-muted)", whiteSpace: "nowrap", marginLeft: "auto" } }, item.progress ? (0, import_react2.createElement)("span", null, item.progress.done + "/" + item.progress.total) : null, hasPendingDec ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)", fontFamily: "var(--ss-font-ui)", fontWeight: 500 } }, "待决定") : null, (0, import_react2.createElement)("span", null, item.modelLabel + " · " + item.durationText) ) ) ); }) ); }) ); } const is4Col = layoutMode === "board4"; const cols = is4Col ? [...MASTER_ACTIVE_COLUMNS, MASTER_BLOCKED_COLUMN] : MASTER_ACTIVE_COLUMNS; return (0, import_react2.createElement)( "div", { className: "mwb-kanban-board" + (is4Col ? " is-cols-4" : "") }, cols.map((col) => { const items = is4Col ? col.id === "blocked" ? sortMasterColumnItems(visibleItems.filter((it) => it.col !== "done" && Boolean(it.blockage))) : sortMasterColumnItems(visibleItems.filter((it) => it.col === col.id && !it.blockage)) : sortMasterColumnItems(visibleItems.filter((it) => it.col === col.id)); const blockedCnt = !is4Col ? items.filter((it) => Boolean(it.blockage)).length : 0; return (0, import_react2.createElement)( "section", { className: "mwb-kanban-col", key: col.id }, (0, import_react2.createElement)( "div", { className: "mwb-kanban-col-head" }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 6 } }, (0, import_react2.createElement)("span", { className: dotToneClass(col.tone, col.id === "running" && items.length > 0) }), (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 12, fontWeight: 600, color: "var(--ss-fg)" }, className: "truncate" }, col.title), (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 4, marginLeft: "auto", flexShrink: 0 } }, blockedCnt > 0 ? (0, import_react2.createElement)("span", { className: "ss-pill is-error font-mono-num" }, "阻塞 " + blockedCnt) : null, (0, import_react2.createElement)("span", { className: "ss-pill font-mono-num" }, String(items.length)) ) ), (0, import_react2.createElement)("div", { className: "truncate", style: { fontSize: 12, color: "var(--ss-muted)", marginTop: 2 } }, col.subtitle) ), (0, import_react2.createElement)( "div", { className: "mwb-kanban-col-list" }, items.length === 0 ? (0, import_react2.createElement)("div", { style: { border: "1px dashed var(--ss-border)", borderRadius: 8, padding: "28px 12px", textAlign: "center", fontSize: 12, color: "var(--ss-muted)" } }, "当前无任务") : items.map(renderKanbanCard) ) ); }) ); } function renderDrawer() { if (!drawer) return null; if (drawer.type === "task") { const item = allItems.find((it) => it.key === drawer.itemKey); if (!item) return null; const seat = SEATS[item.seatId]; const tabs = [ { id: "overview", label: "概览" }, { id: "subtasks", label: "子项 (" + (item.subtasks?.length || 0) + ")" }, { id: "consult", label: "会商 (" + (item.consultations?.length || 0) + ")" }, { id: "artifacts", label: "交付 (" + (item.artifacts?.length || 0) + ")" } ]; let tabBody = null; if (taskTab === "overview") { tabBody = (0, import_react2.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 12 } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "当前阶段"), (0, import_react2.createElement)( "span", { className: "ss-pill is-" + stageTone(item.col) }, (0, import_react2.createElement)("span", { className: dotToneClass(stageTone(item.col), false) }), stageTitle(item.col) ) ), item.blockage ? (0, import_react2.createElement)( "div", { style: { borderRadius: 12, border: "1px solid color-mix(in srgb,var(--ss-error) 34%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card))", padding: 12, display: "flex", flexDirection: "column", gap: 8 } }, (0, import_react2.createElement)("div", { style: { fontWeight: 600, color: "var(--ss-error)" } }, item.blockage.label), (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, item.blockage.reason), (0, import_react2.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, item.blockage.canRedispatch ? (0, import_react2.createElement)("button", { type: "button", className: "frameless-primary-btn", disabled: busy, onClick: () => void handleRedispatch(item) }, "显式重投并恢复执行") : (0, import_react2.createElement)("button", { type: "button", className: "frameless-btn", disabled: busy, onClick: () => void handleOpenSeat(item.projectId, item.seatId) }, "前往「" + (seat?.label || item.seatId) + "」处理") ) ) : null, item.originalText ? (0, import_react2.createElement)( "div", { style: { borderRadius: 12, border: "1px solid color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))", padding: 12, display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react2.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-primary)" } }, "用户原话"), (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.6 } }, "「" + item.originalText + "」") ) : null, (0, import_react2.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react2.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "任务说明"), (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.6, color: "var(--ss-fg)" } }, item.goal || "—") ), (0, import_react2.createElement)( "div", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react2.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "实时进展 / 产出"), (0, import_react2.createElement)("div", { style: { borderRadius: 12, background: "var(--ss-subtle)", border: "1px solid var(--ss-border)", padding: 12, lineHeight: 1.6, whiteSpace: "pre-wrap" } }, item.result || item.ticker) ) ); } else if (taskTab === "subtasks") { tabBody = (item.subtasks?.length || 0) === 0 ? (0, import_react2.createElement)("div", { style: { padding: "36px 0", textAlign: "center", color: "var(--ss-muted)" } }, "该任务未拆分部门子项。") : (0, import_react2.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 8 } }, item.subtasks.map((st) => (0, import_react2.createElement)( "div", { key: st.id, style: { borderRadius: 12, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 12, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react2.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[st.seatId]?.label || st.seatId), (0, import_react2.createElement)( "span", { className: "ss-pill is-" + (st.status === "done" ? "success" : st.status === "blocked" ? "error" : st.status === "running" ? "primary" : "muted") }, st.status === "done" ? "已完成" : st.status === "blocked" ? "阻塞" : st.status === "running" ? "执行中" : "待派" ) ), (0, import_react2.createElement)("div", { style: { fontWeight: 500, marginTop: 4 } }, st.title), st.result ? (0, import_react2.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, st.result) : null ), (0, import_react2.createElement)("button", { type: "button", className: "frameless-link", disabled: busy, onClick: () => void handleOpenSeat(item.projectId, st.seatId) }, "会话 ↗") ))); } else if (taskTab === "consult") { tabBody = (item.consultations?.length || 0) === 0 ? (0, import_react2.createElement)("div", { style: { padding: "36px 0", textAlign: "center", color: "var(--ss-muted)" } }, "暂无部门会商记录。") : (0, import_react2.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, item.consultations.map((c) => (0, import_react2.createElement)( "div", { key: c.id || c.createdAt, style: { borderRadius: 12, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 12, display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react2.createElement)( "div", { style: { display: "flex", justifyContent: "space-between", gap: 8, color: "var(--ss-muted)" } }, (0, import_react2.createElement)( "span", { style: { fontWeight: 500, color: "var(--ss-fg)" } }, (SEATS[c.fromSeatId]?.label || c.fromSeatId) + " → " + (c.toSeatIds || []).map((x) => SEATS[x]?.label || x).join("、") ), (0, import_react2.createElement)("span", { className: "font-mono-num" }, formatDateTime(c.createdAt)) ), (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, c.text) ))); } else { tabBody = (item.artifacts?.length || 0) === 0 ? (0, import_react2.createElement)("div", { style: { padding: "36px 0", textAlign: "center", color: "var(--ss-muted)" } }, "尚无关联交付物。") : (0, import_react2.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 8 } }, item.artifacts.map((art) => (0, import_react2.createElement)( "div", { key: art.id, style: { borderRadius: 12, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: "10px 12px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react2.createElement)( "div", { style: { minWidth: 0 } }, (0, import_react2.createElement)("div", { style: { fontWeight: 500 } }, art.title), art.path ? (0, import_react2.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-primary)", wordBreak: "break-all" } }, art.path) : null ), art.path ? (0, import_react2.createElement)("button", { type: "button", className: "frameless-link", onClick: () => copyText(art.path, (ok) => showToast(ok ? "已复制路径:" + art.path : "请手动选择复制路径", ok ? "success" : "muted")) }, "复制") : null ))); } return (0, import_react2.createElement)( "aside", { className: "mwb-split-drawer", "aria-label": "任务详情抽屉" }, (0, import_react2.createElement)( "div", { className: "mwb-drawer-head" }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, fontSize: 12 } }, (0, import_react2.createElement)( "div", { className: "font-mono-num", style: { display: "flex", alignItems: "center", gap: 6, color: "var(--ss-muted)", minWidth: 0 } }, drawer.fromDone ? [ (0, import_react2.createElement)("button", { key: "bk", type: "button", className: "frameless-link", onClick: () => setDrawer({ type: "done" }) }, "← 已交付"), (0, import_react2.createElement)("span", { key: "sp" }, "/") ] : null, (0, import_react2.createElement)("span", null, item.id), (0, import_react2.createElement)("span", null, "·"), (0, import_react2.createElement)("span", { className: "truncate" }, item.projectName) ), (0, import_react2.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭抽屉", onClick: () => setDrawer(null) }, "✕") ), (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600, lineHeight: 1.4 } }, item.title), (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, paddingTop: 2 } }, (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 6, fontSize: 12 } }, (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 14 } }, seat?.label || item.seatId), (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, seat?.duty || "") ), (0, import_react2.createElement)("button", { type: "button", className: "frameless-primary-btn", disabled: busy, onClick: () => void handleOpenSeat(item.projectId, item.seatId) }, "打开" + (seat?.label || "席位") + "会话 ↗") ) ), (0, import_react2.createElement)( "div", { className: "mwb-drawer-tabs" }, tabs.map((tb) => (0, import_react2.createElement)("button", { key: tb.id, type: "button", className: "mwb-drawer-tab" + (taskTab === tb.id ? " is-active" : ""), onClick: () => setTaskTab(tb.id) }, tb.label)) ), (0, import_react2.createElement)("div", { className: "mwb-drawer-body" }, tabBody) ); } if (drawer.type === "done") { return (0, import_react2.createElement)( "aside", { className: "mwb-split-drawer", "aria-label": "已交付归档" }, (0, import_react2.createElement)( "div", { className: "mwb-drawer-head" }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react2.createElement)( "div", null, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, (0, import_react2.createElement)("span", { className: "ss-dot is-success" }), (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "已交付归档"), (0, import_react2.createElement)("span", { className: "font-mono-num", style: { fontSize: 12, color: "var(--ss-muted)" } }, String(doneItems.length)) ), (0, import_react2.createElement)( "p", { style: { margin: "2px 0 0", fontSize: 12, color: "var(--ss-muted)" } }, projectFilter === "all" ? "跨项目验收通过记录 · 点击查看详情" : "当前项目:" + (effectiveProjectMeta?.name || "") ) ), (0, import_react2.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭抽屉", onClick: () => setDrawer(null) }, "✕") ) ), (0, import_react2.createElement)( "div", { className: "mwb-drawer-body" }, doneItems.length === 0 ? (0, import_react2.createElement)("div", { style: { padding: "44px 0", textAlign: "center", color: "var(--ss-muted)" } }, "当前筛选条件下暂无已交付任务") : doneItems.map((item) => (0, import_react2.createElement)( "button", { key: item.key, type: "button", className: "mwb-kanban-card", onClick: () => { setDrawer({ type: "task", itemKey: item.key, fromDone: true }); setTaskTab("overview"); } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, width: "100%" } }, (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + item.projectColorVar + ")", flexShrink: 0 } }), (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontWeight: 500 } }, item.projectName), (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "·"), (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", flexShrink: 0 } }, item.id) ), (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, color: "var(--ss-muted)", flexShrink: 0 } }, SEATS[item.seatId]?.label || "—") ), (0, import_react2.createElement)("div", { style: { fontWeight: 600, lineHeight: 1.45 } }, item.title), (0, import_react2.createElement)("div", { className: "line-clamp-2", style: { color: "var(--ss-muted)", lineHeight: 1.5 } }, item.ticker), (0, import_react2.createElement)( "div", { className: "font-mono-num", style: { display: "flex", justifyContent: "space-between", width: "100%", color: "var(--ss-muted)" } }, (0, import_react2.createElement)("span", null, item.artifacts?.length ? "交付物 " + item.artifacts.length : "已归档"), (0, import_react2.createElement)("span", null, item.modelLabel + " · " + item.durationText) ) )) ) ); } if (drawer.type === "settings") { const groups = [ { title: "中枢", ids: SEAT_GROUPS.lead }, { title: "三省", ids: SEAT_GROUPS.sansheng }, { title: "六部", ids: SEAT_GROUPS.liubu } ]; const gSeats = globalDefaults?.seats || {}; return (0, import_react2.createElement)( "aside", { className: "mwb-split-drawer", "aria-label": "全局默认模型配置" }, (0, import_react2.createElement)( "div", { className: "mwb-drawer-head" }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react2.createElement)( "div", null, (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "全局默认模型(R-001)"), (0, import_react2.createElement)("p", { className: "font-mono-num truncate", style: { margin: "2px 0 0", fontSize: 12, color: "var(--ss-muted)" } }, globalDefaults?.path || "~/.dsh/sansheng-liubu/setting.json") ), (0, import_react2.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭抽屉", onClick: () => setDrawer(null) }, "✕") ) ), (0, import_react2.createElement)( "div", { className: "mwb-drawer-body" }, (0, import_react2.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)", lineHeight: 1.55 } }, "点击任一席位展开调整;未设项目覆盖的席位自动从此处读取全局默认。"), groups.map((group) => (0, import_react2.createElement)( "div", { key: group.title, style: { display: "flex", flexDirection: "column", gap: 6 } }, (0, import_react2.createElement)("div", { style: { padding: "0 4px", fontWeight: 500, color: "var(--ss-muted)" } }, group.title), (0, import_react2.createElement)("div", { className: "mwb-gcfg-group" }, group.ids.map((sid) => { const meta = SEATS[sid]; const current = gSeats[sid] || null; const { modelKey, effort } = modelPartsOf(current); const choiceObj = modelChoices.find((c) => c.value === modelKey) || null; const efforts = choiceObj?.efforts || []; const extraChoices = modelKey && !choiceObj ? [{ value: modelKey, label: current.model + "(目录未列出)", efforts: effort ? [effort] : [] }, ...modelChoices] : modelChoices; const isOpen = expandedGlobalSeatId === sid; const previewText = current ? shortModelName(current) : "未设置(回退部署默认)"; return (0, import_react2.createElement)( "div", { key: sid, className: "mwb-gcfg-item" + (isOpen ? " is-open" : "") }, (0, import_react2.createElement)( "button", { type: "button", className: "mwb-gcfg-toggle", "aria-expanded": isOpen, onClick: () => setExpandedGlobalSeatId(isOpen ? null : sid) }, (0, import_react2.createElement)( "span", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 14, flexShrink: 0 } }, meta.label), (0, import_react2.createElement)("span", { className: "truncate", style: { color: "var(--ss-muted)" } }, meta.duty) ), (0, import_react2.createElement)( "span", { style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 } }, (0, import_react2.createElement)("span", { className: "ss-pill font-mono-num", style: { color: current ? "var(--ss-fg)" : "var(--ss-muted)" } }, previewText), ChevronDownSvg({ style: { color: isOpen ? "var(--ss-primary)" : "var(--ss-muted)", transform: isOpen ? "rotate(180deg)" : "none", transition: "transform 150ms ease" } }) ) ), isOpen ? (0, import_react2.createElement)( "div", { className: "mwb-gcfg-body" }, (0, import_react2.createElement)( "div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit,minmax(140px,1fr))", gap: 8 } }, (0, import_react2.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "主任模型"), (0, import_react2.createElement)( "select", { className: "wb-select", disabled: busy, value: modelKey, onChange: (e) => { const nextKey = e.target.value; const nextChoice = modelChoices.find((c) => c.value === nextKey); const nextEff = nextChoice?.efforts?.includes(effort) ? effort : nextChoice?.efforts?.[0] || ""; void handleSetGlobalSeat(sid, modelObjectFromParts(nextKey, nextEff)); } }, (0, import_react2.createElement)("option", { value: "" }, "未设置(回退部署默认)"), extraChoices.map((opt) => (0, import_react2.createElement)("option", { key: opt.value, value: opt.value }, opt.label)) ) ), (0, import_react2.createElement)( "label", { style: { display: "flex", flexDirection: "column", gap: 4 } }, (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "推理等级"), (0, import_react2.createElement)( "select", { className: "wb-select", disabled: busy || efforts.length === 0, value: effort, onChange: (e) => void handleSetGlobalSeat(sid, modelObjectFromParts(modelKey, e.target.value)) }, (0, import_react2.createElement)("option", { value: "" }, efforts.length === 0 ? "默认(固定)" : "默认"), efforts.map((ef) => (0, import_react2.createElement)("option", { key: ef, value: ef }, ef)) ) ) ), (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react2.createElement)("button", { type: "button", className: "frameless-link", disabled: busy || !current, style: { color: current ? "var(--ss-error)" : "var(--ss-muted)" }, onClick: () => void handleSetGlobalSeat(sid, null) }, "清除全局默认"), (0, import_react2.createElement)("button", { type: "button", className: "frameless-btn", onClick: () => setExpandedGlobalSeatId(null) }, "收起") ) ) : null ); })) )), (0, import_react2.createElement)("button", { type: "button", className: "frameless-primary-btn", style: { width: "100%", padding: "9px 12px", borderRadius: 12 }, disabled: busy, onClick: () => void handleSeedGlobalDefaults() }, "按当前项目同步初始化全局默认") ) ); } return null; } return (0, import_react2.createElement)( "div", { ref: rootRef, className: "ssmwb", "data-sansheng-master": "1" }, // 1. 顶部单行指令栏 + 窄栏可展开搜索行 (0, import_react2.createElement)( "header", { className: "mwb-header" }, (0, import_react2.createElement)( "div", { className: "mwb-header-row" }, (0, import_react2.createElement)( "div", { className: "mwb-header-left" }, (0, import_react2.createElement)( "div", { className: "mwb-brand-box" }, (0, import_react2.createElement)("div", { className: "mwb-brand-seal" }, "省"), (0, import_react2.createElement)("h1", { className: "mwb-brand-title mwb-hide-compact" }, "三省六部") ), (0, import_react2.createElement)("span", { className: "mwb-brand-sep mwb-hide-compact" }, "/"), (0, import_react2.createElement)( "div", { className: "mwb-proj-wrap" }, (0, import_react2.createElement)( "button", { type: "button", className: "mwb-proj-trigger" + (projMenuOpen ? " is-open" : ""), "aria-haspopup": "listbox", "aria-expanded": projMenuOpen, onClick: () => setProjMenuOpen((v) => !v) }, (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0, fontWeight: 500 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: projectFilter === "all" ? "var(--ss-primary)" : "var(" + (effectiveProjectMeta?.colorVar || "--ss-primary") + ")", flexShrink: 0 } }), projectFilter === "all" ? [ (0, import_react2.createElement)("span", { key: "all", className: "truncate" }, "全部项目"), (0, import_react2.createElement)("span", { key: "cnt", className: "font-mono-num", style: { color: "var(--ss-muted)", fontWeight: 400, flexShrink: 0 } }, String(activeProjList.length)) ] : (0, import_react2.createElement)("span", { className: "font-mono-num truncate" }, effectiveProjectMeta?.name || projectFilter) ), ChevronDownSvg({ style: { color: "var(--ss-muted)", transform: projMenuOpen ? "rotate(180deg)" : "none", transition: "transform 150ms ease", flexShrink: 0 } }) ), projMenuOpen ? (0, import_react2.createElement)( "div", { className: "mwb-proj-popover", role: "listbox", "aria-label": "切换项目范围" }, (0, import_react2.createElement)( "button", { type: "button", className: "mwb-proj-opt" + (projectFilter === "all" ? " is-selected" : ""), onClick: () => { setProjectFilter("all"); setProjMenuOpen(false); } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 8, fontWeight: projectFilter === "all" ? 600 : 500 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(--ss-primary)" } }), "全部项目" ), (0, import_react2.createElement)( "span", { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 6 } }, totalPendingAll > 0 ? (0, import_react2.createElement)("span", { className: "frameless-zone-count" }, String(totalPendingAll)) : null, (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, String(totalActiveAll)), projectFilter === "all" ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)" } }, "✓") : null ) ) ), (0, import_react2.createElement)("div", { style: { padding: "6px 10px 4px", borderTop: "1px solid var(--ss-border)", marginTop: 2, fontSize: 12, color: "var(--ss-muted)" } }, "工作区 (" + activeProjList.length + ")"), (0, import_react2.createElement)( "div", { style: { maxHeight: 256, overflowY: "auto", display: "flex", flexDirection: "column", gap: 2 } }, activeProjList.map((p) => { const on = projectFilter === p.id; return (0, import_react2.createElement)( "button", { key: p.id, type: "button", className: "mwb-proj-opt" + (on ? " is-selected" : ""), onClick: () => { setProjectFilter(p.id); setProjMenuOpen(false); } }, (0, import_react2.createElement)( "div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 } }, (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center", gap: 8, minWidth: 0 } }, (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + p.colorVar + ")", flexShrink: 0 } }), (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontWeight: on ? 600 : 500 } }, p.name) ), (0, import_react2.createElement)( "span", { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 6, flexShrink: 0 } }, p.pendCnt > 0 ? (0, import_react2.createElement)("span", { className: "frameless-zone-count" }, String(p.pendCnt)) : null, (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, String(p.activeCnt)), on ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)" } }, "✓") : null ) ), p.path ? (0, import_react2.createElement)("div", { className: "font-mono-num truncate", style: { paddingLeft: 16, fontSize: 12, color: "var(--ss-muted)", opacity: 0.85 } }, p.path) : null ); }) ) ) : null ), !isNarrow ? (0, import_react2.createElement)( "div", { className: "mwb-view-switch", role: "group", "aria-label": "切换视图" }, (0, import_react2.createElement)("button", { type: "button", className: "mwb-view-btn" + (viewMode === "board" ? " is-active" : ""), onClick: () => setViewMode("board") }, "看板"), (0, import_react2.createElement)("button", { type: "button", className: "mwb-view-btn" + (viewMode === "list" ? " is-active" : ""), onClick: () => setViewMode("list") }, "列表") ) : null ), (0, import_react2.createElement)( "div", { className: "mwb-header-right" }, (0, import_react2.createElement)( "div", { className: "mwb-search-inline" }, SearchSvg({ style: { color: "var(--ss-muted)", flexShrink: 0 } }), (0, import_react2.createElement)("input", { type: "search", className: "mwb-search-input", value: search, placeholder: "搜索任务、编号、席位…", onChange: (e) => setSearch(e.target.value) }) ), (0, import_react2.createElement)("button", { type: "button", className: "mwb-search-icon-btn" + (searchOpen || search.trim() ? " is-active" : ""), title: "搜索任务、编号、席位", "aria-label": "搜索任务", "aria-expanded": compactSearch && searchOpen, onClick: () => { const next = !searchOpen; setSearchOpen(next); if (next) setTimeout(() => narrowSearchRef.current?.focus(), 0); } }, SearchSvg({ width: 14, height: 14 })), (pendingEntries.length > 0 || Boolean(degradedInfo)) && !pendingExpanded ? (0, import_react2.createElement)( "button", { type: "button", className: "mwb-nav-btn is-pending", onClick: () => { setPendingExpanded(true); setDrawer(null); } }, (0, import_react2.createElement)("span", { className: "ss-dot is-primary is-pulse" }), (0, import_react2.createElement)("span", null, "待处理"), (0, import_react2.createElement)("span", { className: "font-mono-num", style: { fontWeight: 600 } }, String(pendingEntries.length)) ) : null, (0, import_react2.createElement)( "button", { type: "button", className: "mwb-nav-btn" + (drawer?.type === "done" || drawer?.fromDone ? " is-active" : ""), onClick: () => setDrawer((d) => d?.type === "done" ? null : { type: "done" }) }, (0, import_react2.createElement)("span", { className: "ss-dot is-success" }), (0, import_react2.createElement)("span", null, "已交付"), (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, String(doneItems.length)) ), (0, import_react2.createElement)( "button", { type: "button", className: "mwb-nav-btn" + (drawer?.type === "settings" ? " is-active" : ""), onClick: () => setDrawer((d) => d?.type === "settings" ? null : { type: "settings" }) }, SlidersSvg(), (0, import_react2.createElement)( "span", { style: { display: "inline-flex", alignItems: "center" } }, (0, import_react2.createElement)("span", { className: "mwb-hide-xs" }, "全局"), (0, import_react2.createElement)("span", null, "配置") ) ) ) ), compactSearch && searchOpen ? (0, import_react2.createElement)( "div", { className: "mwb-narrow-search-bar" }, (0, import_react2.createElement)( "div", { className: "mwb-narrow-search-input-wrap" }, SearchSvg({ style: { color: "var(--ss-muted)", flexShrink: 0 } }), (0, import_react2.createElement)("input", { ref: narrowSearchRef, type: "search", className: "mwb-search-input", value: search, placeholder: "搜索任务、编号、席位…", onChange: (e) => setSearch(e.target.value) }) ), (0, import_react2.createElement)("button", { type: "button", className: "mwb-narrow-cancel", onClick: () => { setSearch(""); setSearchOpen(false); } }, "取消") ) : null ), // 2. 主区:提示条 + 看板/列表 + 右侧「待你处理」停靠区 + 覆盖式详情/已交付/全局配置抽屉 (0, import_react2.createElement)( "div", { className: "mwb-main" }, toast ? (0, import_react2.createElement)( "div", { className: "wb-toast-wrap" }, (0, import_react2.createElement)( "div", { className: "wb-toast-box is-" + (toast.tone || "primary"), role: toast.tone === "error" ? "alert" : "status" }, (0, import_react2.createElement)("span", null, toast.text), (0, import_react2.createElement)("button", { type: "button", className: "wb-toast-close", "aria-label": "关闭提示", onClick: () => setToast(null) }, "✕") ) ) : null, (0, import_react2.createElement)( "div", { className: "mwb-workspace" }, (0, import_react2.createElement)("main", { className: "mwb-board-stage" }, renderBoardOrList()), !isNarrow && hasPendingBlock ? (0, import_react2.createElement)("aside", { className: "mwb-pending-dock", "aria-label": "待你处理队列" }, renderPendingZone(true)) : null, renderDrawer() ) ) ); } // src/client/workspace.js function samePath(a, b) { if (typeof a !== "string" || typeof b !== "string") return false; const norm = (value) => value.replace(/\//g, "\\").replace(/\\+$/g, "").toLowerCase(); return norm(a) === norm(b); } function baseName(path) { if (typeof path !== "string") return void 0; const parts = path.replace(/\/+$/g, "").split(/[\\/]/).filter(Boolean); return parts.length ? parts[parts.length - 1] : void 0; } function normalizeWorkspaceItem(item) { if (!item || typeof item !== "object") return null; const workspaceId = item.workspaceId ?? item.id ?? null; if (typeof workspaceId !== "string" || !workspaceId) return null; return { workspaceId, name: typeof item.name === "string" ? item.name : typeof item.title === "string" ? item.title : void 0, path: typeof item.path === "string" ? item.path : void 0, sessionIds: Array.isArray(item.sessionIds) ? item.sessionIds : void 0 }; } function workspaceItemsFromSnapshot(snapshot) { const items = Array.isArray(snapshot) ? snapshot : snapshot && typeof snapshot === "object" && Array.isArray(snapshot.items) ? snapshot.items : []; return items.map(normalizeWorkspaceItem).filter(Boolean); } function sessionSummaryFromSnapshot(snapshot, sessionId) { if (!snapshot || typeof snapshot !== "object" || typeof sessionId !== "string" || !sessionId) return null; const byId = snapshot.byId; if (!byId || typeof byId !== "object") return null; const summary = byId[sessionId]; return summary && typeof summary === "object" ? summary : null; } function workspaceForSession(items, sessionId, sessionSummary) { const list = (Array.isArray(items) ? items : []).map(normalizeWorkspaceItem).filter(Boolean); if (typeof sessionId !== "string" || !sessionId) return null; const bySession = list.find((item) => Array.isArray(item.sessionIds) && item.sessionIds.includes(sessionId)); if (bySession) return bySession; const cwd = sessionSummary && typeof sessionSummary.cwd === "string" ? sessionSummary.cwd : ""; if (!cwd) return null; const byPath = list.find((item) => item.path && samePath(item.path, cwd)); if (byPath) return byPath; return { workspaceId: null, name: baseName(cwd), path: cwd, sessionIds: [sessionId] }; } // src/client/styles.js var THEME_VARS_LIGHT = ` --ss-bg: var(--background, var(--dsw-alias-bg-base, #ffffff)); --ss-card: var(--card, var(--dsw-alias-bg-layer1, #ffffff)); --ss-sidebar: var(--sidebar, var(--dsw-alias-bg-layer2, #fafafa)); --ss-fg: var(--foreground, var(--dsw-alias-label-primary, #09090b)); --ss-fg2: color-mix(in srgb, var(--ss-fg) 78%, var(--ss-bg)); --ss-muted: var(--muted-foreground, var(--dsw-alias-label-tertiary, #71717a)); --ss-placeholder: color-mix(in srgb, var(--ss-muted) 75%, transparent); --ss-border: var(--border, var(--dsw-alias-border-l1, #e4e4e7)); --ss-primary: var(--primary, var(--dsw-alias-state-brand-primary, #1e40d8)); --ss-primary-fg: var(--primary-foreground, #ffffff); --ss-secondary: var(--secondary, var(--dsw-alias-interactive-bg-hover-solid, #f4f4f5)); --ss-secondary-fg: var(--secondary-foreground, var(--ss-fg)); --ss-success: var(--success, #16a34a); --ss-warning: var(--warning, #d97706); --ss-error: var(--error, var(--dsw-alias-state-error-primary, #dc2626)); --ss-link: var(--link, var(--ss-primary)); --ss-chart-1: var(--chart-1, #4c6ef5); --ss-chart-2: var(--chart-2, #12b886); --ss-chart-3: var(--chart-3, #e8590c); --ss-canvas: color-mix(in srgb, var(--ss-fg) 3%, var(--ss-bg)); --ss-col: color-mix(in srgb, var(--ss-fg) 3%, var(--ss-bg)); --ss-subtle: color-mix(in srgb, var(--ss-fg) 3.5%, var(--ss-card)); --ss-hover: color-mix(in srgb, var(--ss-fg) 5.5%, var(--ss-card)); --ss-font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; --ss-font-seal: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif; --ss-font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace; `; var THEME_VARS_DARK = ` --ss-bg: var(--background, var(--dsw-alias-bg-base, #09090b)); --ss-card: var(--card, var(--dsw-alias-bg-layer1, #18181b)); --ss-sidebar: var(--sidebar, var(--dsw-alias-bg-layer2, #0c0c0e)); --ss-fg: var(--foreground, var(--dsw-alias-label-primary, #fafafa)); --ss-fg2: color-mix(in srgb, var(--ss-fg) 80%, var(--ss-bg)); --ss-muted: var(--muted-foreground, var(--dsw-alias-label-tertiary, #a1a1aa)); --ss-placeholder: color-mix(in srgb, var(--ss-muted) 75%, transparent); --ss-border: var(--border, var(--dsw-alias-border-l1, #27272a)); --ss-primary: var(--primary, var(--dsw-alias-state-brand-primary, #6b8afd)); --ss-primary-fg: var(--primary-foreground, #0f172a); --ss-secondary: var(--secondary, var(--dsw-alias-interactive-bg-hover-solid, #27272a)); --ss-secondary-fg: var(--secondary-foreground, var(--ss-fg)); --ss-success: var(--success, #4ade80); --ss-warning: var(--warning, #fbbf24); --ss-error: var(--error, var(--dsw-alias-state-error-primary, #f87171)); --ss-link: var(--link, var(--ss-primary)); --ss-chart-1: var(--chart-1, #748ffc); --ss-chart-2: var(--chart-2, #38d9a9); --ss-chart-3: var(--chart-3, #ff922b); --ss-canvas: color-mix(in srgb, var(--ss-fg) 2.5%, var(--ss-bg)); --ss-col: color-mix(in srgb, var(--ss-fg) 3.5%, var(--ss-bg)); --ss-subtle: color-mix(in srgb, var(--ss-fg) 4.5%, var(--ss-card)); --ss-hover: color-mix(in srgb, var(--ss-fg) 7%, var(--ss-card)); `; var CSS = ` /* ---------- 宿主接线槽位 ---------- */ .ssw-tab-body,.ssw-main-panel{height:100%;min-height:0;width:100%;display:flex;flex-direction:column;overflow:hidden} .ssw-tab-title{font-size:12px;font-weight:600} .ssw-nav-hit{display:inline-flex;align-items:center;justify-content:center;color:inherit;width:100%;height:100%} .ssw-inline-bar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 14px;background:var(--dsw-alias-bg-layer2,#f4f4f5);border-bottom:1px solid var(--dsw-alias-border-l1,#e4e4e7);font-size:12px} .ssw-link{color:var(--dsw-alias-state-brand-primary,#1e40d8);font-size:12px;font-weight:500;padding:4px 6px;border-radius:6px} .ssw-float{position:fixed;right:14px;bottom:70px;z-index:2147483000;width:min(760px,calc(100vw - 28px));max-height:calc(100vh - 96px);display:flex;flex-direction:column;background:var(--dsw-alias-bg-base,#fff);border:1px solid var(--dsw-alias-border-l1,#e4e4e7);border-radius:12px;box-shadow:0 18px 50px -12px rgba(16,24,40,.28);overflow:hidden} /* ---------- 双工作台共享主题变量与基础重置 ---------- */ .ssv2,.ssmwb{ ${THEME_VARS_LIGHT} color-scheme: light dark; color: var(--ss-fg); font-family: var(--ss-font-ui); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; } @media (prefers-color-scheme: dark){ .ssv2,.ssmwb{ ${THEME_VARS_DARK} } } body[data-ds-dark-theme] .ssv2, body[data-ds-dark-theme] .ssmwb, html[data-theme="dark"] .ssv2, html[data-theme="dark"] .ssmwb, .ssv2[data-ssv-theme="dark"], .ssmwb[data-ssv-theme="dark"]{ ${THEME_VARS_DARK} } .ssv2 *,.ssmwb *{box-sizing:border-box} .ssv2 button,.ssmwb button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer} .ssv2 button:disabled,.ssmwb button:disabled{opacity:.5;cursor:default} .ssv2 input,.ssmwb input,.ssv2 select,.ssmwb select,.ssv2 textarea,.ssmwb textarea{font:inherit;color:var(--ss-fg)} .ssv2 :focus-visible,.ssmwb :focus-visible{outline:2px solid var(--ss-primary);outline-offset:1px} .ssv2 ::-webkit-scrollbar,.ssmwb ::-webkit-scrollbar{width:6px;height:6px} .ssv2 ::-webkit-scrollbar-track,.ssmwb ::-webkit-scrollbar-track{background:transparent} .ssv2 ::-webkit-scrollbar-thumb,.ssmwb ::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--ss-muted) 30%,transparent);border-radius:999px} .ssv2 .font-seal,.ssmwb .font-seal{font-family:var(--ss-font-seal);letter-spacing:.04em} .ssv2 .font-mono-num,.ssmwb .font-mono-num{font-family:var(--ss-font-mono);font-variant-numeric:tabular-nums} .ssv2 .truncate,.ssmwb .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .ssv2 .line-clamp-2,.ssmwb .line-clamp-2{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden} .ssv2 .wb-select,.ssmwb .wb-select{background:var(--ss-card);color:var(--ss-fg);border:1px solid var(--ss-border);border-radius:8px;padding:6px 10px;font-size:12px;width:100%} /* ---------- 语义状态点 / 胶囊 ---------- */ @keyframes ssvPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.42;transform:scale(1.24)}} .ss-dot{width:7px;height:7px;border-radius:50%;flex:0 0 auto;background:var(--ss-muted)} .ss-dot.is-primary{background:var(--ss-primary)} .ss-dot.is-success{background:var(--ss-success)} .ss-dot.is-warning{background:var(--ss-warning)} .ss-dot.is-error{background:var(--ss-error)} .ss-dot.is-pulse{animation:ssvPulse 2s ease-in-out infinite} @media (prefers-reduced-motion: reduce){.ss-dot.is-pulse{animation:none}} .ss-pill{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:12px;line-height:1.35;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);white-space:nowrap;flex-shrink:0} .ss-pill.is-primary{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));color:var(--ss-primary)} .ss-pill.is-success{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} .ss-pill.is-warning{background:color-mix(in srgb,var(--ss-fg) 3%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-warning) 36%,var(--ss-border));color:var(--ss-warning)} .ss-pill.is-error{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));color:var(--ss-error)} /* ---------- 极致无框「待你处理」样式(无外框浅蓝底 + 独立纯白条目) ---------- */ .frameless-zone{background:color-mix(in srgb,var(--ss-primary) 8.5%,var(--ss-card));border:0;border-radius:16px;padding:12px;display:flex;flex-direction:column;gap:10px} .frameless-zone.is-dock-full{flex:1 1 auto;min-height:0} .frameless-zone-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 4px;flex:none} .frameless-zone-title-wrap{display:flex;align-items:center;gap:8px;min-width:0} .frameless-zone-title{font-size:13px;font-weight:600;color:var(--ss-fg);margin:0;white-space:nowrap} .frameless-zone-count{padding:2px 7px;border-radius:999px;font-size:12px;line-height:1;font-weight:600;background:var(--ss-primary);color:var(--ss-primary-fg);font-family:var(--ss-font-mono);font-variant-numeric:tabular-nums;flex-shrink:0} .frameless-zone-sub{font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .frameless-zone-list{display:flex;flex-direction:column;gap:10px} .frameless-zone-list.is-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;padding-right:2px} .frameless-item{background:var(--ss-card);border:0;border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:8px;box-shadow:0 1px 3px color-mix(in srgb,var(--ss-primary) 8%,transparent);transition:box-shadow 150ms ease} .frameless-item:hover{box-shadow:0 3px 10px -2px color-mix(in srgb,var(--ss-primary) 15%,transparent)} .frameless-item-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px} .frameless-item-meta{display:flex;align-items:center;gap:6px;min-width:0} .frameless-chip{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:12px;font-weight:500;flex-shrink:0} .frameless-chip.is-err{background:color-mix(in srgb,var(--ss-error) 10%,var(--ss-card));color:var(--ss-error)} .frameless-chip.is-pri{background:color-mix(in srgb,var(--ss-primary) 10%,var(--ss-card));color:var(--ss-primary)} .frameless-code{background:color-mix(in srgb,var(--ss-fg) 3.5%,var(--ss-card));border:0;border-radius:8px;padding:7px 10px;font-size:12px;line-height:1.55;color:var(--ss-fg);overflow-wrap:anywhere} .frameless-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} .frameless-btn-group{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-left:auto} .frameless-btn{background:color-mix(in srgb,var(--ss-fg) 4.5%,var(--ss-card));color:var(--ss-fg);border:0;border-radius:8px;padding:5px 11px;font-size:12px;font-weight:500;transition:background-color 140ms ease,color 140ms ease} .frameless-btn:hover{background:color-mix(in srgb,var(--ss-primary) 11%,var(--ss-card));color:var(--ss-primary)} .frameless-primary-btn{background:var(--ss-primary);color:var(--ss-primary-fg);border:0;border-radius:8px;padding:5px 12px;font-size:12px;font-weight:500;transition:opacity 140ms ease} .frameless-primary-btn:hover{opacity:.9} .frameless-link{font-size:12px;color:var(--ss-link);flex-shrink:0} .frameless-link:hover{text-decoration:underline} /* ---------- 提示横幅 & 弹窗 ---------- */ .wb-toast-wrap{flex:none;padding:10px 16px 0} .wb-toast-box{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 12px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);font-size:12px} .wb-toast-box.is-primary{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));color:var(--ss-primary)} .wb-toast-box.is-success{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} .wb-toast-box.is-error{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));color:var(--ss-error)} .wb-toast-close{color:var(--ss-muted);padding:0 4px} .wb-toast-close:hover{color:var(--ss-fg)} .wb-modal-backdrop{position:fixed;inset:0;z-index:60;background:rgba(9,9,11,.46);display:flex;align-items:center;justify-content:center;padding:12px} .wb-modal{width:min(640px,100%);max-height:86vh;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden;box-shadow:0 20px 44px -12px rgba(0,0,0,.32)} .wb-modal-head{padding:12px 16px;border-bottom:1px solid var(--ss-border);display:flex;align-items:flex-start;justify-content:space-between;gap:12px} .wb-modal-title{margin:0;font-size:14px;font-weight:600;color:var(--ss-fg)} .wb-modal-close{width:28px;height:28px;border-radius:8px;border:1px solid var(--ss-border);display:inline-flex;align-items:center;justify-content:center;font-size:12px;flex-shrink:0} .wb-modal-close:hover{background:var(--ss-hover)} .wb-modal-body{padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;font-size:12px} .wb-modal-foot{padding:10px 16px;border-top:1px solid var(--ss-border);display:flex;justify-content:flex-end;gap:8px} /* ============================================================================ 1. BETTER SIDEBAR 单项目工作台 (.ssv2) ============================================================================ */ .ssv2{height:100%;min-height:0;width:100%;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--ss-canvas);container-type:inline-size;container-name:wb} .ssv2 .wb-header{flex:none;position:relative;z-index:20;padding:12px 16px 0;border-bottom:1px solid var(--ss-border);background:var(--ss-card)} .ssv2 .wb-header-row{display:flex;align-items:center;justify-content:space-between;gap:8px} .ssv2 .wb-brand{display:flex;align-items:center;gap:8px;min-width:0} .ssv2 .wb-seal-badge{width:32px;height:32px;border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));display:flex;align-items:center;justify-content:center;flex-shrink:0;font-family:var(--ss-font-seal);font-weight:700;font-size:14px;color:var(--ss-primary)} .ssv2 .wb-brand-title-row{display:flex;align-items:center;gap:6px;min-width:0} .ssv2 .wb-brand-title{margin:0;font-family:var(--ss-font-seal);font-size:16px;font-weight:700;line-height:1.25;white-space:nowrap} .ssv2 .wb-role-badge{padding:2px 6px;border-radius:4px;font-size:12px;line-height:1.1;background:var(--ss-subtle);border:1px solid var(--ss-border);color:var(--ss-muted);flex-shrink:0} .ssv2 .wb-subline{margin:2px 0 0;font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .ssv2 .wb-proj-pill{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:8px;background:var(--ss-subtle);border:1px solid var(--ss-border);font-size:12px;max-width:190px;flex-shrink:0} .ssv2 .wb-proj-name{font-weight:500;color:var(--ss-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .ssv2 .wb-tabs{display:flex;align-items:center;gap:2px;margin-top:8px;margin-bottom:-1px;overflow-x:auto} .ssv2 .wb-tab-btn{display:inline-flex;align-items:center;gap:6px;padding:9px 12px;font-size:12px;font-weight:500;white-space:nowrap;border-bottom:2px solid transparent;color:var(--ss-muted);transition:color 140ms ease,border-color 140ms ease} .ssv2 .wb-tab-btn:hover{color:var(--ss-fg)} .ssv2 .wb-tab-btn.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary);font-weight:600} .ssv2 .wb-tab-badge{padding:1px 6px;border-radius:999px;font-size:12px;line-height:1.2} .ssv2 .wb-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:14px} .ssv2 .wb-footer{flex:none;padding:8px 16px;border-top:1px solid var(--ss-border);background:var(--ss-sidebar);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px;color:var(--ss-muted)} .ssv2 .wb-refresh-btn{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:6px;font-size:12px;color:var(--ss-muted)} .ssv2 .wb-refresh-btn:hover{background:var(--ss-hover);color:var(--ss-fg)} .ssv2 .telemetry-strip{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:8px 12px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px} .ssv2 .telemetry-group{display:flex;flex-wrap:wrap;align-items:center;gap:12px} .ssv2 .telemetry-item{display:inline-flex;align-items:center;gap:5px} .ssv2 .court-split{display:grid;grid-template-columns:minmax(0,1fr);gap:16px;align-items:start} @container wb (min-width: 920px){.ssv2 .court-split{grid-template-columns:minmax(0,1.35fr) minmax(300px,0.95fr);gap:18px}} .ssv2 .court-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} .ssv2 .court-title{margin:0;font-size:14px;font-weight:600} .ssv2 .seg-group{display:inline-flex;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);padding:2px;font-size:12px} .ssv2 .seg-btn{padding:3px 8px;border-radius:6px;color:var(--ss-muted);transition:background-color 120ms ease,color 120ms ease;white-space:nowrap} .ssv2 .seg-btn:hover{color:var(--ss-fg)} .ssv2 .seg-btn.is-active{background:var(--ss-secondary);color:var(--ss-secondary-fg);font-weight:500} .ssv2 .lead-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:12px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;transition:border-color 140ms ease} .ssv2 .lead-card.is-selected{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));box-shadow:0 0 0 1px var(--ss-primary)} .ssv2 .lead-select-btn{display:flex;align-items:center;gap:10px;text-align:left;min-width:0;flex:1 1 auto} .ssv2 .lead-seal{width:36px;height:36px;border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));display:flex;align-items:center;justify-content:center;font-family:var(--ss-font-seal);font-weight:700;font-size:16px;color:var(--ss-primary);flex-shrink:0} .ssv2 .wb-btn-outline{padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;font-weight:500;transition:border-color 140ms ease,background-color 140ms ease;white-space:nowrap} .ssv2 .wb-btn-outline:hover{border-color:var(--ss-primary);color:var(--ss-primary)} .ssv2 .wb-btn-primary{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border-radius:8px;background:var(--ss-primary);color:var(--ss-primary-fg);font-size:12px;font-weight:500;white-space:nowrap;transition:opacity 140ms ease} .ssv2 .wb-btn-primary:hover{opacity:.9} .ssv2 .tier-divider{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ss-muted);padding:0 2px} .ssv2 .tier-divider strong{font-weight:500;color:var(--ss-fg)} .ssv2 .tier-line{flex:1 1 auto;height:1px;background:var(--ss-border)} .ssv2 .sansheng-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px} .ssv2 .liubu-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px} .ssv2 .seat-card{text-align:left;width:100%;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:10px;display:flex;flex-direction:column;justify-content:space-between;gap:6px;transition:border-color 140ms ease,background-color 140ms ease} .ssv2 .seat-card:hover{border-color:var(--ss-muted)} .ssv2 .seat-card.is-selected{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));box-shadow:0 0 0 1px var(--ss-primary)} .ssv2 .seat-card.is-dimmed{opacity:.35} .ssv2 .seat-head{display:flex;align-items:center;justify-content:space-between;gap:6px} .ssv2 .seat-title-wrap{display:inline-flex;align-items:center;gap:6px;min-width:0} .ssv2 .seat-name{font-family:var(--ss-font-seal);font-weight:700;font-size:15px;line-height:1.25} .ssv2 .seat-card.is-sansheng .seat-name{font-size:16px} .ssv2 .seat-card.is-selected .seat-name{color:var(--ss-primary)} .ssv2 .seat-live-tag{padding:2px 6px;border-radius:4px;font-size:12px;line-height:1;background:var(--ss-primary);color:var(--ss-primary-fg)} .ssv2 .seat-status-text{display:inline-flex;align-items:center;gap:4px;font-size:12px;white-space:nowrap;color:var(--ss-muted)} .ssv2 .seat-status-text.is-error{color:var(--ss-error);font-weight:500} .ssv2 .seat-status-text.is-success{color:var(--ss-success);font-weight:500} .ssv2 .seat-duty{font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px} .ssv2 .seat-footer{padding-top:6px;border-top:1px solid var(--ss-border);display:flex;align-items:center;justify-content:space-between;gap:6px;min-width:0} .ssv2 .seat-task-title{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .ssv2 .seat-model-tag{font-family:var(--ss-font-mono);font-size:12px;color:var(--ss-muted);max-width:92px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-shrink:0} /* 席位检视器 */ .ssv2 .inspector-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden} .ssv2 .inspector-head{padding:14px;border-bottom:1px solid var(--ss-border);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} .ssv2 .inspector-subtabs{display:flex;gap:16px;padding:0 14px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle)} .ssv2 .inspector-subtab{padding:8px 0;font-size:12px;font-weight:500;border-bottom:2px solid transparent;color:var(--ss-muted)} .ssv2 .inspector-subtab.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary)} .ssv2 .inspector-body{padding:14px;display:flex;flex-direction:column;gap:12px;font-size:12px} .ssv2 .kv-grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px} .ssv2 .kv-box{border-radius:8px;background:var(--ss-subtle);border:1px solid var(--ss-border);padding:10px} .ssv2 .wb-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:14px;display:flex;flex-direction:column;gap:10px;font-size:12px} .ssv2 .wb-empty-box{border-radius:12px;border:1px dashed var(--ss-border);padding:24px 16px;text-align:center;font-size:12px;color:var(--ss-muted)} .ssv2 .wb-textarea{width:100%;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);color:var(--ss-fg);padding:8px 10px;font-size:12px;resize:vertical} .ssv2 .wb-input{width:100%;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);color:var(--ss-fg);padding:7px 10px;font-size:12px} .ssv2 .wb-alert{border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));padding:10px;color:var(--ss-error);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px} /* 流转 / 议政 / 共识 / 配置 */ .ssv2 .flow-seg{display:inline-flex;flex-wrap:wrap;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);padding:2px;font-size:12px} .ssv2 .flow-seg-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:6px;color:var(--ss-muted)} .ssv2 .flow-seg-btn.is-active{background:var(--ss-primary);color:var(--ss-primary-fg);font-weight:500} .ssv2 .stage-stepper{display:flex;align-items:center;gap:4px;overflow-x:auto;padding:4px 0} .ssv2 .stage-step-pill{padding:2px 8px;border-radius:999px;font-size:12px;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);white-space:nowrap} .ssv2 .stage-step-pill.is-done{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} .ssv2 .stage-step-pill.is-cur{background:var(--ss-primary);border-color:var(--ss-primary);color:var(--ss-primary-fg);font-weight:500} .ssv2 .queue-table{width:100%;text-align:left;border-collapse:collapse;font-size:12px} .ssv2 .queue-table th{padding:10px 10px;font-weight:500;color:var(--ss-muted);background:var(--ss-subtle);border-bottom:1px solid var(--ss-border);white-space:nowrap} .ssv2 .queue-table td{padding:10px 10px;border-bottom:1px solid var(--ss-border);vertical-align:top} .ssv2 .queue-table tr.is-click{cursor:pointer} .ssv2 .queue-table tr.is-click:hover td{background:var(--ss-hover)} .ssv2 .consensus-grid{display:grid;grid-template-columns:1fr;gap:12px} @container wb (min-width: 620px){.ssv2 .consensus-grid{grid-template-columns:repeat(2,minmax(0,1fr))}} .ssv2 .speech-bubble{border-radius:12px;border:1px solid var(--ss-border);padding:10px 12px;font-size:12px;line-height:1.6;color:var(--ss-fg);background:color-mix(in srgb,var(--ss-fg) 3%,var(--ss-card));white-space:pre-wrap;overflow-wrap:anywhere} .ssv2 .speech-chart-1{border-left:2.5px solid var(--ss-chart-1)} .ssv2 .speech-chart-2{border-left:2.5px solid var(--ss-chart-2)} .ssv2 .speech-chart-3{border-left:2.5px solid var(--ss-chart-3)} .ssv2 .cfg-seat-info{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1 1 auto} @container wb (min-width: 720px){.ssv2 .cfg-seat-info{display:grid;grid-template-columns:minmax(170px,1fr) minmax(220px,1.15fr);align-items:center;gap:12px}} .ssv2 .cfg-row{border-bottom:1px solid var(--ss-border)} .ssv2 .cfg-row:last-child{border-bottom:0} .ssv2 .cfg-row.is-open{background:color-mix(in srgb,var(--ss-primary) 5%,var(--ss-card))} .ssv2 .cfg-row-head{display:flex;align-items:center;gap:8px;font-size:12px} .ssv2 .cfg-row-toggle{flex:1 1 auto;min-width:0;text-align:left;display:flex;align-items:center;gap:10px;padding:10px 4px 10px 14px} .ssv2 .cfg-inline-panel{padding:12px 14px;border-top:1px solid var(--ss-border);background:var(--ss-subtle);display:flex;flex-direction:column;gap:10px;font-size:12px} /* Narrow sidebar breakpoints (580px standard -> <=640px, 400px floor -> <=480px) */ @container wb (max-width: 520px){.ssv2 .col-dur,.ssv2 .col-time{display:none}} @container wb (max-width: 640px){ .ssv2 .wb-header{padding-left:14px;padding-right:14px} .ssv2 .wb-body{padding:12px} .ssv2 .frameless-zone{padding:10px;border-radius:12px} .ssv2 .frameless-zone-list{gap:8px} .ssv2 .frameless-item{padding:10px 12px;gap:8px;border-radius:10px} .ssv2 .frameless-code{padding:7px 10px} .ssv2 .hide-narrow{display:none !important} } @container wb (max-width: 480px){ .ssv2 .sansheng-grid{gap:7px} .ssv2 .liubu-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px} .ssv2 .wb-header{padding-left:10px;padding-right:10px} .ssv2 .wb-body{padding:8px} .ssv2 .wb-tab-btn{padding-left:8px;padding-right:8px} .ssv2 .frameless-zone{padding:8px;border-radius:11px} .ssv2 .frameless-zone-list{gap:7px} .ssv2 .frameless-item{padding:9px 10px;gap:7px;border-radius:9px} .ssv2 .frameless-code{padding:6px 9px} .ssv2 .seat-card.is-sansheng .seat-head{flex-direction:column;align-items:flex-start;gap:4px} .ssv2 .seat-card.is-sansheng .seat-duty,.ssv2 .seat-card.is-sansheng .seat-footer,.ssv2 .seat-card.is-liubu .seat-footer{display:none !important} } /* ============================================================================ 2. 主工作台跨项目看板总台 (.ssmwb) ============================================================================ */ .ssmwb{height:100%;min-height:0;width:100%;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--ss-canvas);container-type:inline-size;container-name:mwb} .ssmwb .mwb-header{flex:none;position:relative;z-index:40;background:var(--ss-card);border-bottom:1px solid var(--ss-border);padding:10px 16px} .ssmwb .mwb-header-row{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;flex-wrap:nowrap} .ssmwb .mwb-header-left{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:nowrap} .ssmwb .mwb-header-right{display:flex;align-items:center;gap:6px;margin-left:auto;flex-shrink:0;flex-wrap:nowrap} .ssmwb .mwb-brand-box{display:flex;align-items:center;gap:8px;flex-shrink:0} .ssmwb .mwb-brand-seal{width:28px;height:28px;border-radius:8px;background:var(--ss-fg);color:var(--ss-bg);display:flex;align-items:center;justify-content:center;font-family:var(--ss-font-seal);font-weight:700;font-size:12px;line-height:1} .ssmwb .mwb-brand-title{margin:0;font-family:var(--ss-font-seal);font-size:16px;font-weight:700;line-height:1} .ssmwb .mwb-brand-sep{color:var(--ss-border);flex-shrink:0} .ssmwb .mwb-proj-wrap{position:relative;min-width:0} .ssmwb .mwb-proj-trigger{display:inline-flex;align-items:center;gap:8px;padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;max-width:100%;transition:border-color 140ms ease} .ssmwb .mwb-proj-trigger:hover,.ssmwb .mwb-proj-trigger.is-open{border-color:var(--ss-primary)} .ssmwb .mwb-proj-trigger.is-open{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} .ssmwb .mwb-proj-popover{position:absolute;top:calc(100% + 6px);left:0;z-index:45;width:276px;max-width:90vw;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);box-shadow:0 12px 32px -8px color-mix(in srgb,var(--ss-fg) 20%,transparent);overflow:hidden;padding:6px;display:flex;flex-direction:column;gap:2px} .ssmwb .mwb-proj-opt{width:100%;text-align:left;padding:8px 10px;border-radius:8px;display:flex;flex-direction:column;gap:2px;font-size:12px;transition:background-color 120ms ease} .ssmwb .mwb-proj-opt:hover{background:var(--ss-hover)} .ssmwb .mwb-proj-opt.is-selected{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} .ssmwb .mwb-view-switch{display:inline-flex;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);padding:2px;font-size:12px;flex-shrink:0} .ssmwb .mwb-view-btn{padding:4px 10px;border-radius:6px;color:var(--ss-muted);transition:background-color 120ms ease,color 120ms ease;white-space:nowrap} .ssmwb .mwb-view-btn.is-active{background:var(--ss-card);color:var(--ss-fg);font-weight:500;box-shadow:0 1px 2px rgba(0,0,0,.08)} .ssmwb .mwb-search-inline{display:flex;align-items:center;gap:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);padding:5px 10px;width:200px;max-width:100%} .ssmwb .mwb-search-input{width:100%;border:0;background:transparent;font-size:12px;outline:none;color:var(--ss-fg)} .ssmwb .mwb-search-icon-btn{display:none;align-items:center;justify-content:center;padding:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);color:var(--ss-muted);flex-shrink:0} .ssmwb .mwb-search-icon-btn:hover,.ssmwb .mwb-search-icon-btn.is-active{border-color:var(--ss-primary)} .ssmwb .mwb-search-icon-btn.is-active{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} .ssmwb .mwb-narrow-search-bar{margin-top:8px;padding-top:8px;border-top:1px solid var(--ss-border);display:flex;align-items:center;gap:8px;font-size:12px} .ssmwb .mwb-narrow-search-input-wrap{flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);padding:6px 10px} .ssmwb .mwb-narrow-cancel{padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);flex-shrink:0} .ssmwb .mwb-narrow-cancel:hover{color:var(--ss-fg)} .ssmwb .mwb-nav-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;flex-shrink:0;white-space:nowrap;transition:border-color 140ms ease} .ssmwb .mwb-nav-btn:hover{border-color:var(--ss-primary)} .ssmwb .mwb-nav-btn.is-active{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary);font-weight:500} .ssmwb .mwb-nav-btn.is-pending{border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary);font-weight:500} .ssmwb .mwb-main{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden} .ssmwb .mwb-workspace{flex:1 1 auto;min-height:0;display:flex;position:relative;overflow:hidden} .ssmwb .mwb-board-stage{flex:1 1 0%;min-width:0;height:100%;overflow:hidden} .ssmwb .mwb-kanban-board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:minmax(0,100%);gap:12px;align-items:start;height:100%;overflow:hidden;padding:14px 16px 18px} .ssmwb .mwb-kanban-board.is-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))} .ssmwb .mwb-kanban-col{min-width:0;max-height:100%;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-col);overflow:hidden} .ssmwb .mwb-kanban-col-head{flex:none;padding:10px 12px;border-bottom:1px solid var(--ss-border)} .ssmwb .mwb-kanban-col-list{flex:1 1 auto;min-height:0;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:8px} .ssmwb .mwb-kanban-card{width:100%;text-align:left;background:var(--ss-card);border:1px solid var(--ss-border);border-radius:10px;padding:12px;display:flex;flex-direction:column;gap:8px;cursor:pointer;transition:border-color 140ms ease,box-shadow 140ms ease} .ssmwb .mwb-kanban-card:hover{border-color:color-mix(in srgb,var(--ss-primary) 45%,var(--ss-border));box-shadow:0 4px 12px -6px color-mix(in srgb,var(--ss-fg) 14%,transparent)} .ssmwb .mwb-kanban-card.is-selected{border-color:var(--ss-primary);box-shadow:0 0 0 1px var(--ss-primary),0 4px 14px -6px color-mix(in srgb,var(--ss-primary) 26%,transparent)} .ssmwb .mwb-kanban-card.is-blocked{border-color:color-mix(in srgb,var(--ss-error) 55%,var(--ss-border));box-shadow:inset 3px 0 0 0 var(--ss-error)} .ssmwb .mwb-kanban-card.is-blocked:hover{border-color:var(--ss-error)} .ssmwb .mwb-card-ticker{border-radius:8px;padding:6px 10px;font-size:12px;line-height:1.45;background:var(--ss-subtle);color:var(--ss-muted)} .ssmwb .mwb-card-ticker.is-blocked{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));color:var(--ss-error);font-weight:500} .ssmwb .mwb-card-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px 8px;padding-top:2px;font-size:12px;color:var(--ss-muted)} .ssmwb .mwb-progress-track{width:24px;height:6px;border-radius:999px;background:var(--ss-border);overflow:hidden;display:inline-block} .ssmwb .mwb-progress-fill{display:block;height:100%;background:var(--ss-primary)} .ssmwb .mwb-list-wrap{height:100%;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px} .ssmwb .mwb-list-section{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden} .ssmwb .mwb-list-head{padding:8px 14px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle);display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px} .ssmwb .mwb-list-row{width:100%;text-align:left;padding:10px 14px;display:flex;flex-direction:column;gap:6px;font-size:12px;border-bottom:1px solid var(--ss-border);transition:background-color 120ms ease} .ssmwb .mwb-list-row:last-child{border-bottom:0} .ssmwb .mwb-list-row:hover{background:var(--ss-hover)} .ssmwb .mwb-list-row.is-selected{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))} .ssmwb .mwb-list-row.is-blocked{border-left:3px solid var(--ss-error)} .ssmwb .mwb-pending-dock{width:344px;flex:0 0 344px;min-height:0;display:flex;flex-direction:column;padding:14px 14px 16px 0} .ssmwb .mwb-split-drawer{position:absolute;top:0;right:0;bottom:0;z-index:35;width:400px;max-width:100%;border-left:1px solid var(--ss-border);background:var(--ss-card);display:flex;flex-direction:column;min-height:0;box-shadow:-10px 0 28px -10px color-mix(in srgb,var(--ss-fg) 18%,transparent)} .ssmwb .mwb-drawer-head{flex:none;padding:12px 16px;border-bottom:1px solid var(--ss-border);display:flex;flex-direction:column;gap:8px} .ssmwb .mwb-drawer-tabs{flex:none;display:flex;gap:16px;padding:0 16px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle);font-size:12px} .ssmwb .mwb-drawer-tab{padding:8px 0;font-weight:500;border-bottom:2px solid transparent;color:var(--ss-muted)} .ssmwb .mwb-drawer-tab.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary)} .ssmwb .mwb-drawer-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px;font-size:12px} .ssmwb .mwb-gcfg-group{border-radius:16px;background:var(--ss-subtle);padding:6px;display:flex;flex-direction:column;gap:4px} .ssmwb .mwb-gcfg-item{border-radius:12px;background:var(--ss-card);border:1px solid transparent;transition:border-color 140ms ease} .ssmwb .mwb-gcfg-item.is-open{border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));box-shadow:0 1px 4px rgba(0,0,0,.06)} .ssmwb .mwb-gcfg-toggle{width:100%;text-align:left;padding:10px 12px;border-radius:12px;display:flex;align-items:center;justify-content:space-between;gap:8px} .ssmwb .mwb-gcfg-toggle:hover{background:var(--ss-hover)} .ssmwb .mwb-gcfg-body{padding:8px 12px 12px;border-top:1px solid var(--ss-border);display:flex;flex-direction:column;gap:10px} @container mwb (max-width: 1160px){ .ssmwb .mwb-pending-dock{width:312px;flex-basis:312px} } @container mwb (max-width: 760px){ .ssmwb .mwb-search-inline{display:none !important} .ssmwb .mwb-search-icon-btn{display:inline-flex !important} } @container mwb (max-width: 580px){ .ssmwb .mwb-header{padding:8px 10px} .ssmwb .mwb-list-wrap{padding:10px;gap:10px} .ssmwb .mwb-hide-compact{display:none !important} .ssmwb .frameless-zone{padding:9px;border-radius:12px} .ssmwb .frameless-item{padding:10px 11px;gap:7px;border-radius:10px} .ssmwb .frameless-code{padding:6px 9px} } @container mwb (max-width: 480px){ .ssmwb .mwb-hide-xs{display:none !important} } `; // src/client/cards.js var import_react3 = require("react"); var COLORS = { line: "var(--dsw-alias-border-l1, rgba(127,127,127,.28))", bg: "var(--dsw-alias-bg-base, transparent)", ink: "var(--dsw-alias-label-primary, inherit)", muted: "var(--dsw-alias-label-tertiary, #888)", soft: "var(--dsw-alias-interactive-bg-hover-solid, rgba(127,127,127,.08))", accent: "var(--dsw-alias-label-primary, currentColor)" }; function errorText(error) { return error?.message ? error.message : String(error); } function SanshengCardRow(props) { const callId = props?.callId || props?.block?.callId || ""; const [card, setCard] = (0, import_react3.useState)(null); const [error, setError] = (0, import_react3.useState)(""); const [busy, setBusy] = (0, import_react3.useState)(""); (0, import_react3.useEffect)(() => { if (!callId) return void 0; let alive = true; const load = async () => { try { const value = await request("cardGet", { cardId: callId }); if (!alive) return; setCard(value.card); setError(""); } catch (loadError) { if (alive) setError(errorText(loadError)); } }; void load(); const timer = setInterval(() => { void load(); }, 1500); return () => { alive = false; clearInterval(timer); }; }, [callId]); const answer = async (choice) => { if (!callId || busy || card?.status === "answered") return; setBusy(choice); setError(""); try { const value = await request("cardAnswer", { cardId: callId, choice }); setCard(value.card); } catch (answerError) { setError(errorText(answerError)); } finally { setBusy(""); } }; if (!callId) return (0, import_react3.createElement)("div", { style: { color: COLORS.muted, fontSize: 13, padding: "4px 0" } }, "卡片缺少调用标识,无法显示。"); if (!card) { return (0, import_react3.createElement)( "div", { style: { border: "1px solid " + COLORS.line, borderRadius: 8, padding: "10px 12px", margin: "4px 0", color: COLORS.muted, fontSize: 13 } }, error || "卡片加载中…" ); } const answered = card.status === "answered"; const options = Array.isArray(card.options) ? card.options : []; return (0, import_react3.createElement)( "div", { style: { border: "1px solid " + COLORS.line, borderRadius: 10, background: COLORS.bg, padding: "12px 14px", margin: "4px 0", display: "flex", flexDirection: "column", gap: 8, maxWidth: 720 }, "data-sansheng-card": card.id, "data-sansheng-card-status": card.status }, (0, import_react3.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, (0, import_react3.createElement)("span", { style: { fontSize: 11, lineHeight: "18px", padding: "0 7px", borderRadius: 999, background: COLORS.soft, color: COLORS.muted } }, card.kind === "approval" ? "审批" : "需要你回答"), (0, import_react3.createElement)("strong", { style: { fontSize: 14, color: COLORS.ink } }, card.title) ), (0, import_react3.createElement)("div", { style: { fontSize: 13, lineHeight: 1.7, color: COLORS.ink, whiteSpace: "pre-wrap" } }, card.body), card.kind === "approval" && (card.seatLabel || card.tool || card.reason) ? (0, import_react3.createElement)( "div", { style: { fontSize: 12, lineHeight: 1.7, color: COLORS.muted, whiteSpace: "pre-wrap" } }, [card.seatLabel ? "申请:" + card.seatLabel : "", card.tool ? "操作:" + card.tool : "", card.reason ? "原因:" + card.reason : ""].filter(Boolean).join("\n") ) : null, answered ? (0, import_react3.createElement)("div", { style: { fontSize: 13, color: COLORS.ink, fontWeight: 600 } }, "已选择:" + (card.answerLabel || card.answer || "")) : (0, import_react3.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, options.map((option) => (0, import_react3.createElement)("button", { key: option.value, type: "button", disabled: Boolean(busy), onClick: () => { void answer(option.value); }, title: option.description || "", style: { border: "1px solid " + COLORS.line, borderRadius: 8, background: busy === option.value ? COLORS.soft : "transparent", color: COLORS.ink, padding: "6px 12px", cursor: busy ? "default" : "pointer", fontSize: 13 } }, busy === option.value ? "处理中…" : option.label)) ), error ? (0, import_react3.createElement)("div", { style: { fontSize: 12, color: "var(--dsw-alias-state-error-primary, #b3261e)" } }, error) : null, answered ? null : (0, import_react3.createElement)("div", { style: { fontSize: 12, color: COLORS.muted } }, "可以在聊天里继续,之后再回来点这张卡。") ); } var cards_default = SanshengCardRow; // src/native/panel.js var GROUP_ORDER = ["lead", "sansheng", "liubu"]; var GROUP_TITLE = { lead: "统领", sansheng: "三省", liubu: "六部" }; var MAX_OPTIONS = 8; var PROJECT_STATUS_TEXT = { pending: "待启用", provisioning: "启用中", ready: "已就绪", error: "异常" }; var SEAT_STATUS_TEXT = { pending: "待启用", creating: "创建中", bound: "已绑定", failed: "失败", missing: "缺失" }; function asText(v) { return typeof v === "string" ? v : ""; } function seatRecords(project) { const out = {}; const seats = project ? project.seats : null; if (Array.isArray(seats)) { for (const s of seats) if (s && SEATS[s.id]) out[s.id] = s; } else if (seats && typeof seats === "object") { for (const id of SEAT_IDS) if (seats[id]) out[id] = seats[id]; } return out; } function isBound(seat) { return !!seat && seat.status === "bound" && typeof seat.sessionId === "string" && seat.sessionId.length > 0; } function modelValue(model) { if (!model || typeof model !== "object") return ""; if (typeof model.provider !== "string" || typeof model.model !== "string") return ""; return model.provider + "::" + model.model; } function flattenModels(models) { const opts = []; const providers = models && Array.isArray(models.providers) ? models.providers : []; for (const p of providers) { const pid = asText(p && p.provider); if (!pid) continue; const list = Array.isArray(p && p.models) ? p.models : []; for (const m of list) { const mid = typeof m === "string" ? m : asText(m && m.model); if (!mid) continue; opts.push({ value: pid + "::" + mid, label: pid + " / " + mid }); if (opts.length >= MAX_OPTIONS - 1) break; } if (opts.length >= MAX_OPTIONS - 1) break; } return opts; } function buildModelSelect(project, seat, models) { const real = flattenModels(models); const options = [{ value: "", label: "请选择模型" }].concat(real).slice(0, MAX_OPTIONS); const want = modelValue(seat && seat.model); const value = options.some((o) => o.value === want) ? want : ""; return { type: "select", label: "模型", value, options, action: { type: "sansheng/select-model", seatId: seat && seat.id || null, projectId: project && project.id || null } }; } function seatButton(project, seat, selectedSeatId) { const meta = SEATS[seat.id]; const selected = seat.id === selectedSeatId; return { type: "button", seatId: seat.id, label: meta.label, selected, variant: selected ? "primary" : "ghost", action: { type: "sansheng/select-seat", seatId: seat.id, projectId: project && project.id || null } }; } function groupNode(project, records, key, selectedSeatId) { const ids = (SEAT_GROUPS[key] || []).filter((id) => records[id] && SEATS[id]); if (ids.length === 0) return null; const perRow = key === "liubu" ? 3 : ids.length; const rows = []; for (let i = 0; i < ids.length; i += perRow) { const slice = ids.slice(i, i + perRow); rows.push({ type: "row", children: slice.map((id) => seatButton(project, records[id], selectedSeatId)) }); } return { type: "stack", group: key, children: [{ type: "text", text: GROUP_TITLE[key] + " · " + ids.length + " 席" }].concat(rows) }; } function selectedDetail(project, records, selectedSeatId, models) { const seat = selectedSeatId ? records[selectedSeatId] : null; if (!seat) { return { type: "callout", tone: "info", text: "点击上方角色卡片查看职责、模型与进入会话。" }; } const meta = SEATS[seat.id]; const bound = isBound(seat); const statusLabel = SEAT_STATUS_TEXT[seat.status] || asText(seat.status) || "未知"; const instructions = asText(seat.instructions).trim() || "(未填写)"; return { type: "stack", detail: seat.id, children: [ { type: "text", text: meta.label + " · " + meta.duty + " · " + statusLabel }, { type: "callout", tone: "info", text: "职责:" + meta.responsibility }, { type: "text", text: "角色补充说明(只读,请在 Web 端编辑)" }, { type: "callout", tone: "warn", text: instructions }, buildModelSelect(project, seat, models), { type: "button", label: bound ? "进入" + meta.label + "会话" : seat.status === "missing" ? meta.label + "会话缺失,请到 Web 工作台重建" : meta.label + "尚未绑定会话", variant: bound ? "primary" : "ghost", disabled: !bound, action: { type: "sansheng/enter-session", seatId: seat.id, projectId: project && project.id || null, sessionId: isBound(seat) ? seat.sessionId : null } } ] }; } function buildPanelView(input) { const { project = null, selectedSeatId = null, models = null } = input || {}; if (!project || typeof project !== "object") { return { type: "stack", children: [ { type: "text", text: "三省六部" }, { type: "callout", tone: "warn", text: "无法确定当前项目:原生面板作用域不含 workspaceId,且未能由 sessionId 反查到所属项目。请从已启用「三省六部」的项目会话中打开,或在 Web 工作台查看。" } ] }; } const records = seatRecords(project); const sel = selectedSeatId && records[selectedSeatId] ? selectedSeatId : records.lead ? "lead" : null; const ready = project.status === "ready"; const boundCount = SEAT_IDS.filter((id) => isBound(records[id])).length; const children = [ { type: "text", text: "三省六部 · " + (asText(project.name) || "未命名项目") }, { type: "callout", tone: ready ? "good" : "warn", text: (PROJECT_STATUS_TEXT[project.status] || "状态未知") + " · 已绑定 " + boundCount + "/10 席" } ]; for (const key of GROUP_ORDER) { const g = groupNode(project, records, key, sel); if (g) children.push(g); } children.push(selectedDetail(project, records, sel, models)); return { type: "stack", children }; } var panel_default = buildPanelView; // src/native/index.js var PANEL_ID = "sansheng"; var viewBySession = /* @__PURE__ */ new Map(); var selectionBySession = /* @__PURE__ */ new Map(); var modelsBySession = /* @__PURE__ */ new Map(); function cacheProject(project) { if (!project || typeof project !== "object") return; const seats = project.seats; for (const id of SEAT_IDS) { let seat = null; if (Array.isArray(seats)) seat = seats.find((s) => s && s.id === id) || null; else if (seats && typeof seats === "object") seat = seats[id] || null; if (seat && typeof seat.sessionId === "string" && seat.sessionId) { viewBySession.set(seat.sessionId, project); } } } function resolveProject(native, scope) { const sid = scope && typeof scope.sessionId === "string" ? scope.sessionId : null; const lookup = native && (native.sansheng || native.sanshengProjects) || null; if (lookup && typeof lookup.projectForScope === "function") { try { const p = lookup.projectForScope(scope); if (p) { cacheProject(p); return p; } } catch (e) { } } if (lookup && typeof lookup.projectForSession === "function" && sid) { try { const p = lookup.projectForSession(sid); if (p) { cacheProject(p); return p; } } catch (e) { } } let workspaceId = null; try { const sessions = native && native.sessions; if (sessions && typeof sessions.binding === "function" && sid) { const b = sessions.binding(sid); workspaceId = b && (b.workspaceId || b.workspace && b.workspace.id) || null; } } catch (e) { } if (lookup && typeof lookup.projectForWorkspace === "function" && workspaceId) { try { const p = lookup.projectForWorkspace(workspaceId); if (p) { cacheProject(p); return p; } } catch (e) { } } if (sid && viewBySession.has(sid)) return viewBySession.get(sid); return null; } function makeView(native, scope) { const sid = scope && typeof scope.sessionId === "string" ? scope.sessionId : null; const project = resolveProject(native, scope); const selectedSeatId = sid && selectionBySession.has(sid) ? selectionBySession.get(sid) : null; const models = sid && modelsBySession.has(sid) ? modelsBySession.get(sid) : null; return buildPanelView({ project, selectedSeatId, models }); } function normalizeAction(event) { const a = event && event.action; if (a && typeof a === "object") return a; const v = event && event.value; if (v && typeof v === "object" && typeof v.type === "string") return v; if (typeof a === "string") return Object.assign({ type: a }, v && typeof v === "object" ? v : {}); return null; } async function handleEvent(native, scope, event) { const sid = scope && typeof scope.sessionId === "string" ? scope.sessionId : null; const action = normalizeAction(event); if (!action || typeof action.type !== "string") return []; switch (action.type) { case "sansheng/select-seat": { if (sid && action.seatId) selectionBySession.set(sid, action.seatId); return [{ type: "refresh", id: PANEL_ID }]; } case "sansheng/select-model": { if (sid && action.seatId) selectionBySession.set(sid, action.seatId); return [{ type: "toast", text: "模型选择在原生面板暂未接持久化,请在 Web 端保存(需真机核验)" }]; } case "sansheng/enter-session": { const bridged = native && native.dshGo; const open = bridged && (bridged.openSession || bridged.navigate) || native && native.sansheng && native.sansheng.openSession; if (typeof open === "function" && action.sessionId) { try { await open(action.sessionId); return [{ type: "toast", text: "已请求打开会话" }]; } catch (e) { } } return [{ type: "toast", text: "原生 effect 暂不支持会话跳转,请从宿主会话列表进入(需真机核验)" }]; } default: return []; } } function makeDataProvider(native, dshGo) { return function data(scope, emit) { let cancelled = false; const run = async () => { if (typeof fetch !== "function") return; const sid = scope && typeof scope.sessionId === "string" ? scope.sessionId : null; if (!sid) return; const post = async (endpoint, payload) => { const res = await fetch("/api/sansheng", { method: "POST", credentials: "same-origin", headers: { "content-type": "application/json" }, body: JSON.stringify({ endpoint, payload: payload == null ? null : payload }) }); if (!res.ok) throw new Error("HTTP " + res.status); const r = await res.json(); if (!r || r.ok !== true) throw new Error(r && r.error && r.error.message || "request failed"); return r.value; }; const list = await post("list"); const projects = list && Array.isArray(list.projects) ? list.projects : []; for (const meta of projects) { const value = await post("project", { projectId: meta.id }); const project = value && value.project ? value.project : value; cacheProject(project); const seats = project && project.seats; const found = Array.isArray(seats) ? seats.some((s) => s && s.sessionId === sid) : seats && Object.values(seats).some((s) => s && s.sessionId === sid); if (found) { if (!cancelled) { try { emit({ project }); } catch (e) { } try { if (dshGo && typeof dshGo.refresh === "function") dshGo.refresh(PANEL_ID, scope); } catch (e) { } } return; } } }; run().catch(() => { }); return () => { cancelled = true; }; }; } function install(ctx) { if (!ctx || typeof ctx.inject !== "function") return () => { }; return ctx.inject(["dshGo", "sessions"], (native) => { const dshGo = native && native.dshGo; if (!dshGo || typeof dshGo.panel !== "function") return () => { }; const disposers = []; try { const offPanel = native.dshGo.panel(PANEL_ID, { view: (scope, caps) => makeView(native, scope), data: makeDataProvider(native, native.dshGo) }); if (typeof offPanel === "function") disposers.push(offPanel); } catch (e) { } if (typeof native.dshGo.on === "function") { try { const offOn = native.dshGo.on(PANEL_ID, (scope, event) => handleEvent(native, scope, event)); if (typeof offOn === "function") disposers.push(offOn); } catch (e) { } } return () => { for (const off of disposers) { try { off(); } catch (e) { } } }; }); } var native_default = { install }; // src/client/index.js var import_react4 = require("react"); var inject = ["sessions", "workspaces", "uiWorkspace", "uiConversation", "slots", "theme", "layout", "sidebarRightTabs", "sidebarRight"]; var PLUGIN_ID = "dsh-sansheng"; var TAB_KIND = "sansheng-workbench"; var TAB_TYPE_ID = "dsh-sansheng:workbench"; var RIGHT_PIN_KEY = "sansheng.right-workbench.pinned"; function readRightWorkbenchPinned() { try { return typeof localStorage !== "undefined" && localStorage.getItem(RIGHT_PIN_KEY) === "1"; } catch { return false; } } function writeRightWorkbenchPinned(value) { try { if (typeof localStorage === "undefined") return; if (value) localStorage.setItem(RIGHT_PIN_KEY, "1"); else localStorage.removeItem(RIGHT_PIN_KEY); } catch { } } function installStyles(doc, tag, text) { if (!doc || !doc.head) return null; const style = doc.createElement("style"); style.dataset.plugin = PLUGIN_ID; style.dataset.sansheng = tag; style.textContent = text; doc.head.appendChild(style); return style; } function svgWrap(children, props) { return (0, import_react4.createElement)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", ...props || {} }, children); } var TreeIcon = (props) => svgWrap([ (0, import_react4.createElement)("rect", { key: "a", x: 9, y: 2, width: 6, height: 5, rx: 1 }), (0, import_react4.createElement)("path", { key: "b", d: "M12 7v5M5 16v-4h14v4" }), (0, import_react4.createElement)("rect", { key: "c", x: 2, y: 16, width: 6, height: 5, rx: 1 }), (0, import_react4.createElement)("rect", { key: "d", x: 16, y: 16, width: 6, height: 5, rx: 1 }) ], props); var CloseIcon = (props) => svgWrap([(0, import_react4.createElement)("path", { key: "p", d: "m6 6 12 12M6 18 18 6" })], props); var FolderIcon = (props) => svgWrap([(0, import_react4.createElement)("path", { key: "p", d: "M3 7V5a2 2 0 0 1 2-2h5l2 3h7a2 2 0 0 1 2 2v11H3Z" })], props); var GearIcon = (props) => svgWrap([ (0, import_react4.createElement)("path", { key: "a", d: "M4 6h16M4 12h16M4 18h16" }), (0, import_react4.createElement)("circle", { key: "b", cx: 9, cy: 6, r: 2 }), (0, import_react4.createElement)("circle", { key: "c", cx: 16, cy: 12, r: 2 }), (0, import_react4.createElement)("circle", { key: "d", cx: 8, cy: 18, r: 2 }) ], props); var ChevronIcon = (props) => (0, import_react4.createElement)("svg", { viewBox: "0 0 24 24", width: 14, height: 14, fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", className: "ssw-chevron", "aria-hidden": "true" }, (0, import_react4.createElement)("path", { d: "m6 9 6 6 6-6" })); var SEAT_ICON_PATHS = { lead: ["M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z", "M4.5 20c0-3.2 3.4-5 7.5-5s7.5 1.8 7.5 5"], zhongshu: ["M7 3h7l4 4v14H7z", "M14 3v4h4", "M9.5 12h5", "M9.5 16h5"], shangshu: ["M4 4h6.5v6.5H4z", "M13.5 4H20v6.5h-6.5z", "M4 13.5h6.5V20H4z", "M13.5 13.5H20V20h-6.5z"], menxia: ["M12 3l7 3v6c0 4-3 7-7 9-4-2-7-5-7-9V6z", "m9 12 2 2 4-4"], libu: ["M12 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z", "M5 20c0-3 3-4.5 7-4.5s7 1.5 7 4.5"], hubu: ["M4 5h16v14H4z", "M4 10h16", "M10 5v14"], lipu: ["M7 3h10v18H7z", "M10 8h4", "M10 12h4", "M10 16h4"], bingbu: ["M4 5h16v12H4z", "m8 13 3-6 5 6", "M4 20h16"], xingbu: ["M6 3h12v18l-6-3-6 3z", "m9 10 2 2 4-4"], gongbu: ["m8 8-4 4 4 4", "m16 8 4 4-4 4", "M13 5l-2 14"] }; function SeatIcon(props) { const paths = SEAT_ICON_PATHS[props && props.id] ?? SEAT_ICON_PATHS.lead; return (0, import_react4.createElement)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", className: "ssw-seat-icon" }, paths.map((d, index) => (0, import_react4.createElement)("path", { key: index, d }))); } function isFn(value) { return typeof value === "function"; } function safeCall(obj, name) { try { if (!obj || !isFn(obj[name])) return void 0; return obj[name](); } catch { return void 0; } } function snapshotOf(obj) { if (!obj) return void 0; if (isFn(obj.getSnapshot)) { try { return obj.getSnapshot(); } catch { return void 0; } } return obj; } function apply(ctx) { if (typeof document !== "undefined") installStyles(document, "workbench", CSS); const get = (name) => { try { return ctx.get(name); } catch { return void 0; } }; let rightTabOpener = null; function sessionsSnapshot() { return snapshotOf(get("sessions")?.list) ?? snapshotOf(get("sessions")); } function workspaceItems() { const sources = [ get("workspaces")?.list, get("uiWorkspace")?.workspaces, get("workspaces") ]; for (const source of sources) { const items = workspaceItemsFromSnapshot(snapshotOf(source)); if (items.length) return items; } return []; } function sessionSummary(sessionId) { return sessionSummaryFromSnapshot(sessionsSnapshot(), sessionId); } function currentSessionId() { const snap = snapshotOf(get("sessions")?.list) ?? snapshotOf(get("sessions")); if (!snap || typeof snap !== "object") return null; for (const key of ["activeId", "currentId", "selectedId"]) { if (typeof snap[key] === "string" && snap[key]) return snap[key]; } if (snap.byId && typeof snap.byId === "object") { const main = Object.values(snap.byId).find((session) => (session?.retainedBy?.mainView ?? 0) > 0); if (main && typeof main.id === "string") return main.id; } return null; } function currentWorkspaceId() { const candidates = []; for (const holder of [get("workspaces"), get("uiWorkspace")]) { if (!holder) continue; for (const key of ["currentWorkspaceId", "currentId", "activeId"]) { if (isFn(holder[key])) candidates.push(safeCall(holder, key)); else if (typeof holder[key] === "string") candidates.push(holder[key]); } for (const key of ["current", "active", "selected", "currentWorkspace"]) { const value = holder[key]; const snap = snapshotOf(value); if (snap && typeof snap === "object") candidates.push(snap.workspaceId ?? snap.id); else if (typeof value === "string") candidates.push(value); } } const sessionId = currentSessionId(); if (sessionId) { const owner = workspaceItems().find((item) => Array.isArray(item.sessionIds) && item.sessionIds.includes(sessionId)); if (owner) candidates.push(owner.workspaceId); } return candidates.find((id) => typeof id === "string" && id) ?? null; } function workspaceForSessionId(sessionId) { const explicitId = typeof sessionId === "string" && sessionId ? sessionId : null; const targetId = explicitId || currentSessionId(); const fromSession = workspaceForSession(workspaceItems(), targetId, sessionSummary(targetId)); if (fromSession) return fromSession; if (explicitId && explicitId !== currentSessionId()) return null; return currentWorkspace(); } function currentWorkspace() { const items = workspaceItems(); const id = currentWorkspaceId(); if (id) { const hit = items.find((item) => item.workspaceId === id); return hit || { workspaceId: id, name: void 0, path: void 0 }; } if (items.length === 1) return items[0]; return null; } function seatRecordOf(view, id) { const seats = view && view.project ? view.project.seats : null; if (Array.isArray(seats)) return seats.find((seat) => seat && seat.id === id) || null; if (seats && typeof seats === "object") return seats[id] || null; return null; } function navigateToSession(sessionId) { if (!sessionId) return false; const attempts = []; const ui = get("uiWorkspace"); if (ui) { if (isFn(ui.openSession)) attempts.push(() => ui.openSession(sessionId)); if (isFn(ui.open)) attempts.push(() => ui.open(sessionId)); } const sessions = get("sessions"); if (sessions) { if (isFn(sessions.open)) attempts.push(() => sessions.open(sessionId)); if (isFn(sessions.openSession)) attempts.push(() => sessions.openSession(sessionId)); if (isFn(sessions.select)) attempts.push(() => sessions.select(sessionId)); } for (const name of ["navigation", "navigator", "router"]) { const svc = get(name); if (!svc) continue; if (isFn(svc.openSession)) attempts.push(() => svc.openSession(sessionId)); if (isFn(svc.navigate)) attempts.push(() => svc.navigate({ sessionId })); if (isFn(svc.open)) attempts.push(() => svc.open(sessionId)); } for (const run of attempts) { try { const result = run(); if (result && isFn(result.then)) result.catch(() => { }); return true; } catch { } } console.warn("[sansheng] 未找到可用的会话导航接口,仅发出 navigate 意图:", sessionId); try { if (typeof window !== "undefined") { window.dispatchEvent(new CustomEvent("sansheng:navigate", { detail: { sessionId } })); } } catch { } return false; } function ensureRightTab() { const tabs = get("sidebarRightTabs"); if (!tabs || !isFn(tabs.get)) return false; try { return !!(tabs.get(TAB_KIND) || tabs.get(TAB_TYPE_ID)); } catch { return false; } } function rightMountedSessionId() { const right = get("sidebarRight"); try { if (right && isFn(right.mounted?.getSnapshot)) { const mounted = right.mounted.getSnapshot(); if (typeof mounted === "string" && mounted) return mounted; } } catch { } return currentSessionId(); } function activeRightTabId() { const right = get("sidebarRight"); if (!right || !isFn(right.active)) return null; try { const record = right.active(); if (!record) return null; if (typeof record === "string") return record; return record.id || record.tabId || null; } catch { return null; } } function findRightWorkbenchTab(sessionId) { const right = get("sidebarRight"); if (!right || !isFn(right.openTabs?.getSnapshot)) return null; try { const rows = right.openTabs.getSnapshot(); const targetSessionId = typeof sessionId === "string" && sessionId ? sessionId : rightMountedSessionId(); if (!targetSessionId) return null; const matches = (Array.isArray(rows) ? rows : []).filter((item) => item && item.kind === TAB_KIND && item.sessionId === targetSessionId); if (matches.length === 0) return null; const activeId = activeRightTabId(); return matches.find((item) => item.tabId === activeId) || matches[0]; } catch { return null; } } function revealRightTab(sessionId) { const right = get("sidebarRight"); if (!right) return false; try { const row = findRightWorkbenchTab(sessionId); if (!row) return false; const activeId = activeRightTabId(); if (activeId !== row.tabId && isFn(right.focus)) right.focus(row.tabId); if (isFn(right.isExpanded) && !right.isExpanded() && isFn(right.toggleExpanded)) right.toggleExpanded(); const activeNow = activeRightTabId(); if (activeNow !== row.tabId) return false; if (isFn(right.isExpanded) && !right.isExpanded()) return false; scheduleWorkbenchVisibility(sessionId); return true; } catch (error) { console.warn("[sansheng] 展开右侧栏失败:", error && error.message ? error.message : error); return false; } } function scheduleRevealRightTab(sessionId) { for (const delay of [120, 420, 900, 1600]) { setTimeout(() => { if (!rightWorkbenchPinned) return; revealRightTab(sessionId); }, delay); } } function workbenchVisible(sessionId) { if (typeof document === "undefined") return true; try { const hosts = Array.from(document.querySelectorAll(".ssw-tab-body[data-session-id]")); const scoped = sessionId ? hosts.filter((el) => el.getAttribute("data-session-id") === sessionId) : hosts; if (sessionId && scoped.length === 0) return false; const candidates = scoped.length ? scoped : Array.from(document.querySelectorAll(".ssw-tab-body")); return candidates.some((host) => { const node = host.querySelector(".ssv2"); if (!node) return false; const rect = node.getBoundingClientRect(); return rect.width > 0 && rect.height > 0; }); } catch { return true; } } function scheduleWorkbenchVisibility(sessionId) { for (const delay of [180, 600, 1200]) { setTimeout(() => { if (!rightWorkbenchPinned) return; try { if (workbenchVisible(sessionId)) return; const right = get("sidebarRight"); const row = findRightWorkbenchTab(sessionId); if (!right || !row || activeRightTabId() !== row.tabId) return; const layout = get("layout"); if (layout && isFn(layout.openRightbar)) layout.openRightbar(true, false); else if (isFn(right.toggleExpanded)) right.toggleExpanded(); } catch { } }, delay); } } function tryOpenRightTab(sessionId) { const targetSessionId = typeof sessionId === "string" && sessionId ? sessionId : rightMountedSessionId(); const existing = findRightWorkbenchTab(targetSessionId); if (existing) return revealRightTab(targetSessionId); if (isFn(rightTabOpener)) { try { if (rightTabOpener(targetSessionId)) { scheduleRevealRightTab(targetSessionId); return true; } } catch (error) { console.warn("[sansheng] 子插件打开右栏失败:", error && error.message ? error.message : error); } return false; } const right = get("sidebarRight"); if (!right || !isFn(right.openTab)) return false; if (!ensureRightTab()) { registerRightTabType(); if (!ensureRightTab()) return false; } try { const mountedId = rightMountedSessionId(); if (targetSessionId && targetSessionId !== mountedId && isFn(right.openTabIn)) right.openTabIn(targetSessionId, TAB_KIND); else right.openTab(TAB_KIND); } catch (error) { console.warn("[sansheng] 打开右侧标签失败,改用浮动面板:", error && error.message ? error.message : error); return false; } revealRightTab(targetSessionId); scheduleRevealRightTab(targetSessionId); return true; } function SanshengTabBody(props) { const sessionId = props && props.sessionId; return (0, import_react4.createElement)("div", { className: "ssw-tab-body", "data-session-id": sessionId || void 0, "data-sansheng-right-tab": "native" }, (0, import_react4.createElement)(SanshengWorkbench, { sessionId })); } function SanshengTabTitle() { return (0, import_react4.createElement)("span", { className: "ssw-tab-title" }, "三省六部"); } let nativeRightTabWanted = true; let nativeRightTabStop = null; function uninstallNativeRightTab() { const stop = nativeRightTabStop; nativeRightTabStop = null; if (isFn(stop)) { try { stop(); } catch { } } } function registerRightTabType() { if (!nativeRightTabWanted || nativeRightTabStop || isFn(rightTabOpener)) return; if (!isFn(ctx.inject)) return; try { nativeRightTabStop = ctx.inject(["sidebarRightTabs"], (injected) => { if (!nativeRightTabWanted || isFn(rightTabOpener)) return; const tabs = injected.get("sidebarRightTabs"); if (!tabs || !isFn(tabs.register)) return; injected.effect(() => { let disposeType = null, disposeBody = null, disposeTitle = null; const cleanup = () => { try { disposeBody && disposeBody(); } catch { } try { disposeTitle && disposeTitle(); } catch { } try { disposeType && disposeType(); } catch { } }; try { disposeType = tabs.register({ id: TAB_TYPE_ID, kind: TAB_KIND, keepMounted: true, priority: "extension", title: () => "三省六部", guide: [{ id: `${TAB_TYPE_ID}:guide`, order: 32, title: () => "三省六部", description: () => "十席角色与独立会话的当前项目工作台", icon: TreeIcon }] }); disposeBody = ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({ name: "sidebar.right.pane.tab", key: TAB_TYPE_ID, inject: (sessionId) => ({ sessionId }) }, SanshengTabBody)); disposeTitle = ctx.slots.inject("sidebar.right.pane.tab.title", () => ctx.slots.register({ name: "sidebar.right.pane.tab.title", key: TAB_TYPE_ID, inject: (sessionId) => ({ sessionId }) }, SanshengTabTitle)); } catch (error) { const message = error && error.message ? error.message : error; if (!/inactive context/.test(String(message))) { console.warn("[sansheng] 注册右侧标签失败:", message); } cleanup(); return void 0; } return cleanup; }, "sansheng: native right tab fallback"); }); } catch (error) { nativeRightTabStop = null; const message = error && error.message ? error.message : error; if (!/inactive context/.test(String(message))) { console.warn("[sansheng] 注册右侧标签失败:", message); } } } function releaseNativeRightTab() { nativeRightTabWanted = false; uninstallNativeRightTab(); } function restoreNativeRightTab() { nativeRightTabWanted = true; registerRightTabType(); } const selectedSeatCache = /* @__PURE__ */ new Map(); let lastSelectedSeatId = SEAT_IDS[0]; let rightWorkbenchPinned = readRightWorkbenchPinned(); function SanshengWorkbench(props) { const sessionId = props && props.sessionId; const resolveWorkspace = (0, import_react4.useCallback)(() => workspaceForSessionId(sessionId), [sessionId]); return (0, import_react4.createElement)(WorkbenchV2, { sessionId, onClose: props && props.onClose, resolveWorkspace, navigateToSession, openRightTab: tryOpenRightTab, selectionCache: selectedSeatCache, getLastSeatId: () => lastSelectedSeatId, setLastSeatId: (id) => { lastSelectedSeatId = id; } }); } const workbenchService = { version: 1, Workbench: SanshengWorkbench, tabKind: TAB_KIND, tabTypeId: TAB_TYPE_ID, title: "三省六部", description: "十席角色与独立会话的当前项目工作台", icon: (size) => (0, import_react4.createElement)(TreeIcon, { width: size, height: size }), sessionSummary, attachRightTabOpener(fn) { rightTabOpener = isFn(fn) ? fn : null; return () => { if (rightTabOpener === fn) rightTabOpener = null; }; }, releaseNativeRightTab, restoreNativeRightTab }; ctx.provide("sanshengWorkbench", workbenchService); const NAV_PANEL_ID = "sansheng-workbench"; const NAV_ORDER = 32; function openRightWorkbench(sessionId) { const opened = tryOpenRightTab(sessionId); if (opened) { rightWorkbenchPinned = true; writeRightWorkbenchPinned(true); } return opened; } function closeRightWorkbench() { rightWorkbenchPinned = false; writeRightWorkbenchPinned(false); const right = get("sidebarRight"); const row = findRightWorkbenchTab(); if (row && right && isFn(right.close)) { try { right.close(row.tabId); return; } catch { } } const layout = get("layout"); if (layout && isFn(layout.selectPanel)) { try { layout.selectPanel(null); return; } catch { } } if (right && isFn(right.closeTab)) { try { right.closeTab(TAB_KIND); return; } catch { } } } function installRightDockPinning() { const right = get("sidebarRight"); if (!right || !isFn(right.mounted?.subscribe)) return; const delays = [400, 800, 1200, 1800, 2600, 3600, 5e3]; let timer = null; let attempt = 0; const clear = () => { if (timer !== null) { clearTimeout(timer); timer = null; } }; const ensure = () => { timer = null; if (!rightWorkbenchPinned) { attempt = 0; return; } try { const sessionId = rightMountedSessionId(); if (findRightWorkbenchTab(sessionId)) { if (revealRightTab(sessionId)) { attempt = 0; return; } } if (openRightWorkbench(sessionId)) { attempt = 0; return; } } catch { } if (attempt < delays.length - 1) { attempt += 1; timer = setTimeout(ensure, delays[attempt]); } }; const kick = () => { if (!rightWorkbenchPinned) return; clear(); attempt = 0; timer = setTimeout(ensure, delays[0]); }; const stop = right.mounted.subscribe(kick); let stopTabs = null; const discoverPinnedTab = () => { try { const sessionId = rightMountedSessionId(); if (!sessionId || !findRightWorkbenchTab(sessionId)) return; if (!rightWorkbenchPinned) { rightWorkbenchPinned = true; writeRightWorkbenchPinned(true); } kick(); } catch { } }; if (isFn(right.openTabs?.subscribe)) stopTabs = right.openTabs.subscribe(discoverPinnedTab); if (rightWorkbenchPinned) kick(); if (isFn(ctx.effect)) ctx.effect(() => { clear(); stop(); try { if (isFn(stopTabs)) stopTabs(); } catch { } }); } function SanshengNavButton(props) { const size = props && typeof props.size === "number" ? props.size : 16; return (0, import_react4.createElement)("span", { className: "ssw-nav-hit", role: "presentation", title: "三省六部" }, (0, import_react4.createElement)(TreeIcon, { width: size, height: size })); } function backToChat() { const layout = get("layout"); if (layout && isFn(layout.selectPanel)) { try { layout.selectPanel(null); } catch { } } } function SanshengMasterPanel() { return (0, import_react4.createElement)( "div", { className: "ssw-main-panel", "data-sansheng-main": "master-workbench" }, (0, import_react4.createElement)(MasterWorkbench, { getWorkspaces: workspaceItems, getCurrentWorkspace: currentWorkspace, navigateToSession: (sid) => { const ok = navigateToSession(sid); backToChat(); return ok; }, openRightTab: tryOpenRightTab }) ); } function registerNavEntry() { if (!ctx.slots || !isFn(ctx.slots.inject) || !isFn(ctx.slots.register)) { console.warn("[sansheng] 宿主未提供 slots.inject / slots.register,无法注册左侧导航入口"); return; } try { ctx.slots.inject("main", () => ctx.slots.inject("sidebar.panellist", () => { const disposers = []; const disposeAll = () => { for (const dispose of disposers.splice(0)) { try { if (isFn(dispose)) dispose(); } catch { } } }; try { disposers.push(ctx.slots.register({ name: "main", key: NAV_PANEL_ID, inject: () => ({}) }, SanshengMasterPanel)); disposers.push(ctx.slots.register({ name: "sidebar.panellist", id: NAV_PANEL_ID, order: NAV_ORDER, label: () => "三省六部" }, SanshengNavButton)); } catch (error) { disposeAll(); console.warn("[sansheng] 注册左侧导航入口失败:", error && error.message ? error.message : error); return void 0; } return disposeAll; })); } catch (error) { console.warn("[sansheng] 注册左侧导航入口失败:", error && error.message ? error.message : error); } } function registerCardToolview() { if (!ctx.slots || !isFn(ctx.slots.inject) || !isFn(ctx.slots.register)) return; try { ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({ name: "tool.call.toolview", key: "sansheng_card" }, SanshengCardRow)); } catch (error) { console.warn("[sansheng] 注册卡片视图失败:", error && error.message ? error.message : error); } } registerNavEntry(); registerCardToolview(); const nativeRightTabTimer = setTimeout(() => { try { registerRightTabType(); } catch { } }, 500); if (isFn(ctx.effect)) ctx.effect(() => () => clearTimeout(nativeRightTabTimer), "sansheng: native right tab timer"); installRightDockPinning(); try { install(ctx); } catch (error) { console.warn("[sansheng] 原生面板注册失败:", error && error.message ? error.message : error); } } return Object.defineProperty({ ...module.exports }, Symbol.toStringTag, { value: 'Module' }) }, })