team-anya-cli 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/apps/server/dist/broker/cc-broker.js +5 -1
  2. package/apps/server/dist/franky/context-builder.js +160 -0
  3. package/apps/server/dist/franky/franky-mcp-server.js +107 -0
  4. package/apps/server/dist/franky/franky-orchestrator.js +450 -0
  5. package/apps/server/dist/franky/index.js +5 -0
  6. package/apps/server/dist/franky/topic-router.js +16 -0
  7. package/apps/server/dist/gateway/feishu-sender.js +20 -0
  8. package/apps/server/dist/gateway/feishu-ws.js +1 -0
  9. package/apps/server/dist/gateway/message-intake.js +21 -4
  10. package/apps/server/dist/loid/mcp-server.js +1 -0
  11. package/apps/server/dist/loid/session-manager.js +0 -31
  12. package/apps/server/dist/main.js +39 -3
  13. package/apps/web/dist/assets/{index-DT5NuALG.js → index-D1AK5ZEE.js} +1 -1
  14. package/apps/web/dist/index.html +1 -1
  15. package/package.json +1 -1
  16. package/packages/core/dist/office-init.js +4 -0
  17. package/packages/core/dist/scope/defaults.js +15 -0
  18. package/packages/core/dist/scope/index.js +1 -1
  19. package/packages/db/dist/index.js +68 -1
  20. package/packages/db/dist/schema/index.js +1 -0
  21. package/packages/db/dist/schema/tasks.js +2 -0
  22. package/packages/db/dist/schema/topics.js +20 -0
  23. package/packages/db/src/migrations/0006_add_topics.sql +21 -0
  24. package/packages/db/src/migrations/0007_add_topic_root_message_id.sql +1 -0
  25. package/packages/db/src/migrations/meta/0006_snapshot.json +1513 -0
  26. package/packages/db/src/migrations/meta/_journal.json +14 -0
  27. package/packages/mcp-tools/dist/layer2/franky/topic-checkpoint.js +43 -0
  28. package/packages/mcp-tools/dist/layer2/franky/topic-escalate.js +19 -0
  29. package/packages/mcp-tools/dist/layer2/loid/topic-close.js +22 -0
  30. package/packages/mcp-tools/dist/layer2/loid/topic-create.js +56 -0
  31. package/packages/mcp-tools/dist/layer3/adapters/feishu-adapter.js +1 -0
  32. package/packages/mcp-tools/dist/layer3/channel-send.js +1 -0
  33. package/packages/mcp-tools/dist/registry.js +105 -17
  34. package/workspace/CHARTER.md +7 -4
  35. package/workspace/CLAUDE.md +18 -9
  36. package/workspace/PROTOCOL.md +35 -1
  37. package/workspace/TOOLS.md +6 -0
  38. package/workspace/franky/CLAUDE.md +37 -0
  39. package/workspace/franky/PLAYBOOK.md +215 -0
  40. package/workspace/franky/PROFILE.md +80 -0
@@ -4,7 +4,7 @@ import { join, resolve } from 'node:path';
4
4
  import Fastify from 'fastify';
5
5
  import fastifyCors from '@fastify/cors';
6
6
  import fastifyStatic from '@fastify/static';
7
- import { createDB, getTask as dbGetTask } from '@team-anya/db';
7
+ import { createDB, getTask as dbGetTask, getTopic as dbGetTopic } from '@team-anya/db';
8
8
  import { memoryRemember, auditAppend, ChannelRegistry, FeishuAdapter } from '@team-anya/mcp-tools';
9
9
  import { ensureOffice, TaskStatus } from '@team-anya/core';
10
10
  import { loadConfig } from './config.js';
@@ -24,6 +24,8 @@ import { LoidBrain } from './loid/brain.js';
24
24
  import { LoidContextBuilder } from './loid/context-builder.js';
25
25
  import { Clarifier } from './loid/clarifier.js';
26
26
  import { WorktreeManager } from './loid/worktree-manager.js';
27
+ import { FrankyOrchestrator } from './franky/franky-orchestrator.js';
28
+ import { FrankyTopicRouter } from './franky/topic-router.js';
27
29
  export async function buildServer() {
28
30
  const config = loadConfig();
29
31
  // 初始化 office 目录(从模板源复制缺失的文件)
@@ -148,6 +150,7 @@ export async function buildServer() {
148
150
  const broker = new CCBroker({
149
151
  maxLoidInstances: 2,
150
152
  maxYorInstances: config.MAX_YOR_CONCURRENCY,
153
+ maxFrankyInstances: 2,
151
154
  logger: app.log,
152
155
  });
153
156
  // YorOrchestrator — 替代 Yor 子进程,通过 CCBroker 管理 Yor CC
@@ -157,6 +160,36 @@ export async function buildServer() {
157
160
  db,
158
161
  logger: app.log,
159
162
  });
163
+ // ── Franky Orchestrator ──
164
+ const frankyOrchestrator = new FrankyOrchestrator(broker, {
165
+ binary: config.CLAUDE_CODE_BINARY,
166
+ workspacePath: config.WORKSPACE_PATH,
167
+ db,
168
+ channelRegistry,
169
+ onMessageSent: feishuSender
170
+ ? (chatId) => { feishuSender.clearTypingReaction(chatId).catch(() => { }); }
171
+ : undefined,
172
+ onTopicEscalated: (topicId, reason, category) => {
173
+ // 通过飞书通知让相关人感知升级事件(审计日志已由 topic.escalate 工具写入)
174
+ if (feishuSender) {
175
+ const topic = dbGetTopic(db, topicId);
176
+ const chatId = topic?.chat_id;
177
+ if (chatId) {
178
+ feishuSender.sendText({
179
+ receiveIdType: 'chat_id',
180
+ receiveId: chatId,
181
+ text: `[Franky 升级] 专项「${topic?.title ?? topicId}」需要介入(${category}):${reason}`,
182
+ }).catch(err => {
183
+ app.log.error({ err, topicId }, 'Franky 升级飞书通知发送失败');
184
+ });
185
+ }
186
+ }
187
+ app.log.info({ topicId, category, reason }, 'Franky 升级请求');
188
+ },
189
+ getProjectConfig: (projectId) => worktreeManager.getProjectConfig(projectId),
190
+ logger: app.log,
191
+ });
192
+ const topicRouter = new FrankyTopicRouter(frankyOrchestrator, app.log);
160
193
  // LoidBrain(指挥模式)
161
194
  const loidBrain = new LoidBrain({
162
195
  binary: config.CLAUDE_CODE_BINARY,
@@ -173,6 +206,7 @@ export async function buildServer() {
173
206
  workspacePath: config.WORKSPACE_PATH,
174
207
  logger: app.log,
175
208
  yorOrchestrator,
209
+ threadCreator: feishuSender ?? undefined,
176
210
  getProjectConfig: (projectId) => worktreeManager.getProjectConfig(projectId),
177
211
  onProjectChanged: () => worktreeManager.invalidateCache(),
178
212
  onMessageSent: feishuSender
@@ -251,6 +285,7 @@ export async function buildServer() {
251
285
  loidBrain,
252
286
  contextBuilder,
253
287
  commandRouter,
288
+ topicRouter,
254
289
  });
255
290
  // MessageQueue
256
291
  const messageQueue = new MessageQueue({
@@ -279,7 +314,7 @@ export async function buildServer() {
279
314
  return reply.sendFile('index.html', webDistPath);
280
315
  });
281
316
  }
282
- return { app, db, config, broker, yorOrchestrator, messageIntake, messageQueue, feishuSender, loidBrain, larkClient, chatSyncService };
317
+ return { app, db, config, broker, yorOrchestrator, frankyOrchestrator, messageIntake, messageQueue, feishuSender, loidBrain, larkClient, chatSyncService };
283
318
  }
284
319
  /**
285
320
  * 完整启动流程:buildServer + listen + 飞书 WS + graceful shutdown
@@ -287,7 +322,7 @@ export async function buildServer() {
287
322
  */
288
323
  export async function startServer() {
289
324
  const serverCtx = await buildServer();
290
- const { app, config, broker, messageQueue, feishuSender, loidBrain, larkClient, chatSyncService, db } = serverCtx;
325
+ const { app, config, broker, messageQueue, feishuSender, loidBrain, larkClient, chatSyncService, db, frankyOrchestrator } = serverCtx;
291
326
  await app.listen({ port: config.PORT, host: '0.0.0.0' });
292
327
  app.log.info(`Anya server 已启动,端口 ${config.PORT}`);
293
328
  // 飞书 WebSocket 长连接
@@ -336,6 +371,7 @@ export async function startServer() {
336
371
  app.log.error({ err }, 'LoidBrain 关闭失败');
337
372
  }
338
373
  }
374
+ await frankyOrchestrator.shutdown();
339
375
  const result = await broker.shutdown(30_000);
340
376
  if (result.unfinished.length > 0) {
341
377
  app.log.info(`优雅关闭: ${result.unfinished.length} 个实例未完成`);
@@ -795,4 +795,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
795
795
  `),o&&w.jsxs("div",{className:"text-zinc-500 mt-2 pt-2 border-t border-zinc-700/50",children:["... ",r.length-a," more lines"]})]})})]})})}function wqe(e){const{input:t}=e;return!t||!t.pattern?null:w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(I0,{size:14,className:"text-amber-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:"Search"})]}),w.jsxs("div",{className:"p-3 space-y-2",children:[w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{className:"text-xs text-zinc-500",children:"Pattern:"}),w.jsx("code",{className:"text-xs font-mono text-amber-300 bg-amber-500/10 px-1.5 py-0.5 rounded",children:t.pattern})]}),t.path&&w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{className:"text-xs text-zinc-500",children:"Path:"}),w.jsx("span",{className:"text-xs font-mono text-zinc-300",children:t.path})]}),t.glob&&w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{className:"text-xs text-zinc-500",children:"Glob:"}),w.jsx("span",{className:"text-xs font-mono text-zinc-300",children:t.glob})]}),t.type&&w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{className:"text-xs text-zinc-500",children:"Type:"}),w.jsx("span",{className:"text-xs font-mono text-zinc-300",children:t.type})]})]})]})})}function $qe(e){const{input:t}=e;return!t||!t.pattern?null:w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(kR,{size:14,className:"text-cyan-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:"Find Files"})]}),w.jsxs("div",{className:"p-3 space-y-2",children:[w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{className:"text-xs text-zinc-500",children:"Pattern:"}),w.jsx("code",{className:"text-xs font-mono text-cyan-300 bg-cyan-500/10 px-1.5 py-0.5 rounded",children:t.pattern})]}),t.path&&w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{className:"text-xs text-zinc-500",children:"Path:"}),w.jsx("span",{className:"text-xs font-mono text-zinc-300",children:t.path})]})]})]})})}function hL(e){const{content:t,isFileList:n}=e;if(!t||t.trim().length===0)return w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-zinc-800/30 border border-zinc-700/50 rounded-lg",children:[w.jsx(I0,{size:14,className:"text-zinc-500"}),w.jsx("span",{className:"text-xs text-zinc-400",children:"No matches found"})]})});const r=t.split(`
796
796
  `).filter(l=>l.trim()),a=25,o=r.length>a,i=o?r.slice(0,a):r;return n?w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(kR,{size:14,className:"text-cyan-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:"Files Found"}),w.jsxs("span",{className:"text-xs text-zinc-500 ml-auto",children:[r.length," files"]})]}),w.jsxs("div",{className:"overflow-y-auto max-h-60",children:[w.jsx("ul",{className:"divide-y divide-zinc-800/50",children:i.map((l,s)=>w.jsxs("li",{className:"group flex items-center gap-2 px-3 py-1.5 hover:bg-zinc-800/30",children:[w.jsx($q,{size:12,className:"text-zinc-500 flex-shrink-0"}),w.jsx("span",{className:"text-xs font-mono text-zinc-300 truncate flex-1",children:l}),w.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:w.jsx(ip,{text:l})})]},s))}),o&&w.jsxs("div",{className:"px-3 py-2 text-xs text-zinc-500 border-t border-zinc-700/50",children:["... ",r.length-a," more files"]})]})]})}):w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(I0,{size:14,className:"text-amber-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:"Results"}),w.jsxs("span",{className:"text-xs text-zinc-500 ml-auto",children:[r.length," matches"]})]}),w.jsx("div",{className:"overflow-x-auto max-h-80 overflow-y-auto",children:w.jsxs("pre",{className:"text-xs font-mono p-3 text-zinc-300 whitespace-pre-wrap",children:[i.join(`
797
797
  `),o&&w.jsxs("div",{className:"text-zinc-500 mt-2 pt-2 border-t border-zinc-700/50",children:["... ",r.length-a," more matches"]})]})})]})})}function Eqe(e){return e.split("/").slice(-2).join("/")}function NU(e){var n;const t=e.split(".");return t.length>1?((n=t.pop())==null?void 0:n.toLowerCase())??"":""}function jU(e){return{ts:"TypeScript",tsx:"TypeScript React",js:"JavaScript",jsx:"JavaScript React",py:"Python",rb:"Ruby",go:"Go",rs:"Rust",java:"Java",cpp:"C++",c:"C",css:"CSS",scss:"SCSS",html:"HTML",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",sql:"SQL",sh:"Shell",bash:"Bash"}[e]||null}function Iqe(e){const{input:t}=e;if(!t||!t.file_path)return null;const n=Eqe(t.file_path),r=NU(t.file_path),a=r?jU(r):null;return w.jsx("div",{className:"w-full mt-2",children:w.jsx("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(Sq,{size:14,className:"text-sky-400"}),w.jsx("span",{className:"text-xs font-mono text-zinc-300",children:n}),a&&w.jsx("span",{className:"text-xs text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:a}),w.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[(t.offset||t.limit)&&w.jsxs("span",{className:"text-xs text-zinc-500 mr-1",children:[t.offset&&`from line ${t.offset}`,t.offset&&t.limit&&", ",t.limit&&`${t.limit} lines`]}),w.jsx(ip,{text:t.file_path})]})]})})})}function Pqe(e){const{content:t,fileName:n}=e;if(!t)return null;const r=t.split(`
798
- `),a=50,o=r.length>a,i=o?r.slice(0,a):r,l=n?NU(n):"",s=l?jU(l):null;return w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx($q,{size:14,className:"text-sky-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:"File Content"}),s&&w.jsx("span",{className:"text-xs text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:s}),w.jsxs("span",{className:"text-xs text-zinc-500 ml-auto",children:[r.length," lines"]})]}),w.jsxs("div",{className:"overflow-x-auto max-h-96 overflow-y-auto",children:[w.jsx("table",{className:"w-full text-xs font-mono",children:w.jsx("tbody",{children:i.map((u,d)=>w.jsxs("tr",{className:"hover:bg-zinc-800/30",children:[w.jsx("td",{className:"select-none text-right pr-3 pl-3 py-0.5 text-zinc-600 border-r border-zinc-800 w-10 sticky left-0 bg-zinc-900/70",children:d+1}),w.jsx("td",{className:"pl-3 pr-3 py-0.5 text-zinc-300 whitespace-pre",children:u||" "})]},d))})}),o&&w.jsxs("div",{className:"px-3 py-2 text-xs text-zinc-500 border-t border-zinc-700/50",children:["... ",r.length-a," more lines"]})]})]})})}function Rqe(e){const{input:t}=e;return!t||!t.questions||t.questions.length===0?null:w.jsx("div",{className:"w-full mt-2 space-y-3",children:t.questions.map((n,r)=>w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(Vze,{size:14,className:"text-violet-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:n.header||"Question"}),n.multiSelect&&w.jsx("span",{className:"text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded ml-auto",children:"Multi-select"})]}),w.jsxs("div",{className:"p-3 space-y-3",children:[w.jsx("p",{className:"text-sm text-zinc-200",children:n.question}),n.options&&n.options.length>0&&w.jsx("div",{className:"space-y-2",children:n.options.map((a,o)=>{const i=n.multiSelect?PAe:OAe;return w.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded bg-zinc-800/40 border border-zinc-700/30",children:[w.jsx(i,{size:14,className:"text-violet-400/70 mt-0.5 flex-shrink-0"}),w.jsxs("div",{className:"min-w-0",children:[w.jsx("div",{className:"text-xs font-medium text-zinc-200",children:a.label}),a.description&&w.jsx("div",{className:"text-xs text-zinc-500 mt-0.5",children:a.description})]})]},o)})})]})]},r))})}function Oqe(e){const t=e.toLowerCase();return t==="explore"?"text-cyan-400":t==="plan"?"text-violet-400":t==="claude-code-guide"?"text-amber-400":t==="general-purpose"?"text-emerald-400":"text-blue-400"}function Mqe(e){const t=e.toLowerCase();return t==="explore"?"bg-cyan-500/10 border-cyan-500/20":t==="plan"?"bg-violet-500/10 border-violet-500/20":t==="claude-code-guide"?"bg-amber-500/10 border-amber-500/20":t==="general-purpose"?"bg-emerald-500/10 border-emerald-500/20":"bg-blue-500/10 border-blue-500/20"}function _qe(e){const{input:t}=e;if(!t)return null;const n=Oqe(t.subagent_type),r=Mqe(t.subagent_type);return w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(bq,{size:14,className:n}),w.jsx("span",{className:`text-xs font-medium ${n}`,children:t.subagent_type}),t.description&&w.jsxs(w.Fragment,{children:[w.jsx(Lze,{size:10,className:"text-zinc-600"}),w.jsx("span",{className:"text-xs text-zinc-400",children:t.description})]}),w.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.resume&&w.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:[w.jsx($Ae,{size:10}),"resume"]}),t.run_in_background&&w.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:[w.jsx(gAe,{size:10}),"background"]}),t.model&&w.jsx("span",{className:"text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:t.model})]})]}),w.jsx("div",{className:"p-3",children:w.jsxs("div",{className:`flex items-start gap-2 px-3 py-2 rounded-lg border ${r}`,children:[w.jsx(Iq,{size:12,className:`${n} mt-0.5 flex-shrink-0`}),w.jsx("p",{className:"text-xs text-zinc-300 leading-relaxed whitespace-pre-wrap",children:t.prompt})]})})]})})}const kU=c.memo(function(t){const{content:n,className:r=""}=t;return w.jsx("div",{className:`break-words ${r}`,children:w.jsx(GVe,{remarkPlugins:[lqe],components:{h1:a=>w.jsx("div",{className:"text-base font-semibold text-zinc-100 mt-3 mb-1.5",children:a.children}),h2:a=>w.jsx("div",{className:"text-sm font-semibold text-zinc-100 mt-3 mb-1.5",children:a.children}),h3:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-3 mb-1.5",children:a.children}),h4:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-2 mb-1",children:a.children}),h5:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-2 mb-1",children:a.children}),h6:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-2 mb-1",children:a.children}),p:a=>w.jsx("p",{className:"text-[13px] leading-relaxed text-zinc-200 whitespace-pre-wrap my-2",children:a.children}),a:a=>w.jsx("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 underline underline-offset-2",children:a.children}),strong:a=>w.jsx("strong",{className:"font-semibold text-zinc-50",children:a.children}),em:a=>w.jsx("em",{className:"italic text-zinc-200",children:a.children}),code:a=>w.jsx("code",{className:"px-1.5 py-0.5 rounded bg-zinc-800/80 text-cyan-300 text-[12px] font-mono",children:a.children}),pre:a=>{var l,s,u;const{node:o}=a,i=(l=o==null?void 0:o.children)==null?void 0:l[0];if((i==null?void 0:i.tagName)==="code"){const f=(((s=i.properties)==null?void 0:s.className)||[]).find(g=>g.startsWith("language-")),m=(f==null?void 0:f.replace("language-",""))||"code",v=((u=i.children)==null?void 0:u.map(g=>g.value).join(""))||"";return w.jsxs("div",{className:"relative group my-2 rounded-lg overflow-hidden border border-zinc-700/50",children:[w.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-zinc-900 border-b border-zinc-700/50",children:[w.jsx("span",{className:"text-[10px] text-zinc-500 font-mono",children:m}),w.jsx(ip,{text:v})]}),w.jsx("pre",{className:"text-xs text-zinc-300 bg-zinc-900/80 p-3 overflow-x-auto",children:w.jsx("code",{children:v})})]})}return w.jsx("pre",{children:a.children})},ul:a=>w.jsx("ul",{className:"my-2 ml-3 space-y-1 list-disc list-inside text-zinc-200",children:a.children}),ol:a=>w.jsx("ol",{className:"my-2 ml-3 space-y-1 list-decimal list-inside text-zinc-200",children:a.children}),li:a=>w.jsx("li",{className:"text-[13px] leading-relaxed",children:a.children}),blockquote:a=>w.jsx("div",{className:"border-l-2 border-zinc-600 pl-3 my-2 text-zinc-400 italic",children:a.children}),hr:()=>w.jsx("hr",{className:"border-zinc-700 my-4"}),table:a=>w.jsx("div",{className:"my-2 overflow-x-auto rounded-lg border border-zinc-700/50",children:w.jsx("table",{className:"w-full text-[13px]",children:a.children})}),thead:a=>w.jsx("thead",{className:"bg-zinc-900",children:a.children}),tr:a=>w.jsx("tr",{className:"border-b border-zinc-700/50 last:border-b-0",children:a.children}),th:a=>w.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-200",children:a.children}),td:a=>w.jsx("td",{className:"px-3 py-2 text-zinc-300",children:a.children})},children:n})})});function Tqe(e){const t=new Map;for(const n of e)n.type==="tool_use"&&n.id&&n.name&&t.set(n.id,n.name);return t}const Nqe=c.memo(function(t){var g;const{message:n}=t,r=n.type==="user",a=(g=n.message)==null?void 0:g.content,o=()=>!a||typeof a=="string"?[]:a.filter(y=>y.type==="text"),i=()=>!a||typeof a=="string"?[]:a.filter(y=>y.type==="tool_use"||y.type==="tool_result"||y.type==="thinking"),l=()=>o().filter(y=>y.text&&td(y.text).length>0),s=()=>typeof a=="string"?td(a).length>0:l().length>0,u=i(),d=l(),f=s(),m=u.length>0,v=Array.isArray(a)?Tqe(a):new Map;return!f&&m?w.jsx("div",{className:"flex flex-col gap-1 py-0.5",children:u.map((y,h)=>w.jsx(d$,{block:y,toolMap:v},h))}):!f&&!m?null:w.jsx("div",{className:`flex ${r?"justify-end":"justify-start"} min-w-0`,children:w.jsxs("div",{className:"max-w-[85%] min-w-0",children:[w.jsx("div",{className:`px-3.5 py-2.5 rounded-2xl overflow-hidden ${r?"bg-indigo-600/80 text-indigo-50 rounded-br-md":"bg-cyan-700/50 text-zinc-100 rounded-bl-md"}`,children:typeof a=="string"?r?w.jsx("div",{className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed",children:td(a)}):w.jsx(kU,{content:td(a)}):w.jsx("div",{className:"flex flex-col gap-1",children:d.map((y,h)=>w.jsx(d$,{block:y,isUser:r,toolMap:v},h))})}),m&&w.jsx("div",{className:"flex flex-col gap-1 mt-1.5",children:u.map((y,h)=>w.jsx(d$,{block:y,toolMap:v},h))})]})})}),gL={todowrite:Eq,read:Sq,bash:Pq,grep:I0,edit:bAe,write:wq,glob:kR,task:bq},jqe=[{patterns:["web","fetch","url"],icon:aAe},{patterns:["ask","question"],icon:mAe},{patterns:["git","commit"],icon:nAe},{patterns:["sql","database","query"],icon:Gze},{patterns:["file","disk"],icon:iAe}];function kqe(e){const t=e.toLowerCase();if(gL[t])return gL[t];for(const{patterns:n,icon:r}of jqe)if(n.some(a=>t.includes(a)))return r;return jAe}function u$(e){return e.split("/").slice(-2).join("/")}const Dqe={read:e=>e.file_path?u$(String(e.file_path)):null,edit:e=>e.file_path?u$(String(e.file_path)):null,write:e=>e.file_path?u$(String(e.file_path)):null,bash:e=>{if(!e.command)return null;const t=String(e.command);return t.length>50?t.slice(0,50)+"...":t},grep:e=>e.pattern?`"${String(e.pattern)}"`:null,glob:e=>e.pattern?String(e.pattern):null,task:e=>e.description?String(e.description):null};function Fqe(e,t){if(!t)return null;const n=e.toLowerCase(),r=Dqe[n];if(r)return r(t);if(n.includes("web")&&t.url)try{return new URL(String(t.url)).hostname}catch{return String(t.url).slice(0,30)}return null}function Lqe(e){const{toolName:t,input:n}=e,r=t.toLowerCase();return r==="todowrite"&&n.todos?w.jsx(uqe,{todos:n.todos}):r==="edit"&&n.file_path?w.jsx(bqe,{input:n}):r==="write"&&n.file_path?w.jsx(xqe,{input:n}):r==="bash"&&n.command?w.jsx(Cqe,{input:n}):r==="grep"&&n.pattern?w.jsx(wqe,{input:n}):r==="glob"&&n.pattern?w.jsx($qe,{input:n}):r==="read"&&n.file_path?w.jsx(Iqe,{input:n}):r==="askuserquestion"&&n.questions?w.jsx(Rqe,{input:n}):r==="task"&&n.prompt?w.jsx(_qe,{input:n}):w.jsx("pre",{className:"text-xs text-slate-300 bg-slate-900/50 border border-slate-700/50 rounded-lg p-3 mt-2 overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto",children:JSON.stringify(n,null,2)})}function zqe(e){const{toolName:t,content:n,isError:r}=e,a=t.toLowerCase();if(a==="bash")return w.jsx(Sqe,{content:n,isError:r});if(a==="glob")return w.jsx(hL,{content:n,isFileList:!0});if(a==="grep")return w.jsx(hL,{content:n});if(a==="read")return w.jsx(Pqe,{content:n});if(!n||n.trim().length===0)return w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-teal-500/10 border border-teal-500/20 rounded-lg mt-2",children:[w.jsx(fb,{size:14,className:"text-teal-400"}),w.jsx("span",{className:"text-xs text-teal-300",children:"Completed successfully"})]});const o=2e3,i=n.length>o,l=i?n.slice(0,o):n;return w.jsxs("pre",{className:`text-xs rounded-lg p-3 mt-2 overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto border ${r?"bg-rose-950/30 text-rose-200/80 border-rose-900/30":"bg-teal-950/30 text-teal-200/80 border-teal-900/30"}`,children:[l,i&&w.jsxs("span",{className:"text-zinc-500",children:["... (",n.length-o," more chars)"]})]})}function d$(e){var i;const{block:t,isUser:n,toolMap:r}=e,[a,o]=c.useState(!1);if(t.type==="text"&&t.text){const l=td(t.text);return l?n?w.jsx("div",{className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed",children:l}):w.jsx(kU,{content:l}):null}if(t.type==="thinking"&&t.thinking)return w.jsxs("div",{className:a?"w-full":"",children:[w.jsxs("button",{onClick:()=>o(!a),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-amber-500/10 hover:bg-amber-500/15 text-[11px] text-amber-400/90 transition-colors border border-amber-500/20",children:[w.jsx(sAe,{size:12,className:"opacity-70"}),w.jsx("span",{className:"font-medium",children:"thinking"}),w.jsx("span",{className:"text-[10px] opacity-50 ml-0.5",children:a?"▼":"▶"})]}),a&&w.jsx("pre",{className:"text-xs text-zinc-400 bg-zinc-900/80 border border-zinc-800 rounded-lg p-3 mt-2 whitespace-pre-wrap max-h-80 overflow-y-auto",children:t.thinking})]});if(t.type==="tool_use"){const l=t.input&&typeof t.input=="object"?t.input:void 0,s=l&&Object.keys(l).length>0,u=kqe(t.name||""),d=Fqe(t.name||"",l),f=((i=t.name)==null?void 0:i.toLowerCase())||"",m=["todowrite","edit","write","bash","grep","glob","read","askuserquestion","task"].includes(f),v=f==="todowrite"||f==="askuserquestion"||f==="task",g=a||v;return w.jsxs("div",{className:g?"w-full":"",children:[w.jsxs("button",{onClick:()=>s&&!v&&o(!a),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-slate-500/10 hover:bg-slate-500/15 text-[11px] text-slate-300 transition-colors border border-slate-500/20",children:[w.jsx(u,{size:12,className:"opacity-60"}),w.jsx("span",{className:"font-medium text-slate-200",children:t.name}),d&&w.jsx("span",{className:"text-slate-500 font-normal truncate max-w-[200px]",children:d}),s&&!v&&w.jsx("span",{className:"text-[10px] opacity-40 ml-0.5",children:a?"▼":"▶"})]}),g&&s&&m?w.jsx(Lqe,{toolName:t.name||"",input:l}):a&&s&&w.jsx("pre",{className:"text-xs text-slate-300 bg-slate-900/50 border border-slate-700/50 rounded-lg p-3 mt-2 overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto",children:JSON.stringify(l,null,2)})]})}if(t.type==="tool_result"){const l=t.is_error,s=typeof t.content=="string"?t.content:JSON.stringify(t.content,null,2),u=td(s),d=u.length>0,f=60,m=d&&!a?u.slice(0,f)+(u.length>f?"...":""):null,v=t.tool_use_id&&r&&r.get(t.tool_use_id)||"";return w.jsxs("div",{className:a?"w-full":"",children:[w.jsxs("button",{onClick:()=>d&&o(!a),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] transition-colors border ${l?"bg-rose-500/10 hover:bg-rose-500/15 text-rose-400/90 border-rose-500/20":"bg-teal-500/10 hover:bg-teal-500/15 text-teal-400/90 border-teal-500/20"}`,children:[l?w.jsx(DAe,{size:12,className:"opacity-70"}):w.jsx(fb,{size:12,className:"opacity-70"}),w.jsx("span",{className:"font-medium",children:l?"error":"result"}),m&&!a&&w.jsx("span",{className:`font-normal truncate max-w-[200px] ${l?"text-rose-500/70":"text-teal-500/70"}`,children:m}),d&&w.jsx("span",{className:"text-[10px] opacity-40 ml-0.5",children:a?"▼":"▶"})]}),a&&d&&w.jsx(zqe,{toolName:v,content:u,isError:l})]})}return null}function Aqe({onClick:e}){return w.jsxs("button",{onClick:e,className:"fixed bottom-4 right-6 flex cursor-pointer items-center gap-1.5 rounded-full bg-zinc-200/90 px-3.5 py-2 text-xs font-medium text-zinc-900 shadow-lg backdrop-blur-sm transition-all hover:bg-zinc-100",children:[w.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})}),w.jsx("span",{children:"Latest"})]})}const Bqe=10,Hqe=1e3,Vqe=100;function Wqe(e){const{sessionId:t}=e,[n,r]=c.useState([]),[a,o]=c.useState(!0),[i,l]=c.useState(!0),s=c.useRef(null),u=c.useRef(null),d=c.useRef(0),f=c.useRef(!1),m=c.useRef(0),v=c.useRef(null),g=c.useRef(null),y=c.useRef(!0),h=c.useCallback(()=>{if(!y.current)return;v.current&&v.current.close();const I=new EventSource(`/api/sessions/${t}/stream?offset=${d.current}`);v.current=I,I.addEventListener("messages",E=>{m.current=0;const P=JSON.parse(E.data);o(!1),r(M=>{const R=new Set(M.map(N=>N.uuid).filter(Boolean)),O=P.filter(N=>!R.has(N.uuid));return O.length===0?M:(d.current+=O.length,[...M,...O])})}),I.onerror=()=>{if(I.close(),o(!1),!!y.current&&m.current<Bqe){const E=Math.min(Hqe*Math.pow(2,m.current),3e4);m.current++,g.current=setTimeout(()=>h(),E)}}},[t]);c.useEffect(()=>(y.current=!0,o(!0),r([]),d.current=0,m.current=0,h(),()=>{y.current=!1,g.current&&clearTimeout(g.current),v.current&&v.current.close()}),[h]);const x=c.useCallback(()=>{u.current&&(f.current=!0,u.current.scrollIntoView({behavior:"instant",block:"end"}),requestAnimationFrame(()=>{f.current=!1}))},[]);c.useEffect(()=>{i&&x()},[n,i,x]);const C=()=>{if(!s.current||f.current)return;const{scrollTop:I,scrollHeight:E,clientHeight:P}=s.current,M=E-I-P<Vqe;l(M)},S=n.find(I=>I.type==="summary"),$=n.filter(I=>I.type==="user"||I.type==="assistant");return a?w.jsx("div",{className:"flex h-full items-center justify-center text-zinc-500",children:"Loading..."}):$.length===0?w.jsx("div",{className:"flex h-full items-center justify-center text-zinc-500",children:"No messages in this session."}):w.jsxs("div",{className:"relative h-full",children:[w.jsx("div",{ref:s,onScroll:C,className:"h-full overflow-y-auto bg-zinc-950",children:w.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-4",children:[S&&w.jsxs("div",{className:"mb-6 rounded-xl border border-zinc-800/60 bg-zinc-900/50 p-4",children:[w.jsx("h2",{className:"text-sm font-medium text-zinc-200 leading-relaxed",children:S.summary}),w.jsxs("p",{className:"mt-2 text-[11px] text-zinc-500",children:[$.length," messages"]})]}),w.jsx("div",{className:"flex flex-col gap-2",children:$.map((I,E)=>w.jsx("div",{ref:E===$.length-1?u:void 0,children:w.jsx(Nqe,{message:I})},I.uuid||E))})]})}),!i&&w.jsx(Aqe,{onClick:()=>{l(!0),x()}})]})}function Kqe({status:e}){const t=G7e[e]??"bg-zinc-500/20 text-zinc-400";return w.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-[11px] font-medium ${t}`,children:Fs[e]??e})}function no({label:e,children:t}){return w.jsxs("div",{className:"mb-3",children:[w.jsx("div",{className:"text-[10px] text-zinc-500 uppercase tracking-wide mb-0.5",children:e}),w.jsx("div",{className:"text-[13px] text-zinc-300",children:t})]})}function qqe({sessionId:e}){const[t,n]=c.useState(null),[r,a]=c.useState(null),[o,i]=c.useState(!0);return c.useEffect(()=>{fetch(`/api/sessions/${e}/info`).then(l=>l.json()).then(l=>{l.success&&(n(l.data.session),a(l.data.task)),i(!1)}).catch(()=>i(!1))},[e]),o?w.jsx("div",{className:"flex items-center justify-center h-full text-zinc-600 text-xs",children:"Loading..."}):w.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4",children:[w.jsxs("div",{className:"mb-6",children:[w.jsxs("h3",{className:"text-[11px] text-zinc-500 uppercase tracking-wider font-medium mb-3 flex items-center gap-2",children:[w.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-500 inline-block"}),"Session"]}),t?w.jsxs(w.Fragment,{children:[w.jsx(no,{label:"Role",children:w.jsx("span",{className:`font-medium ${t.role==="yor"?"text-orange-400":"text-cyan-400"}`,children:t.role==="yor"?"Yor (执行者)":"Loid (策划者)"})}),t.project_path&&w.jsx(no,{label:"Project Path",children:w.jsx("code",{className:"text-[11px] text-zinc-400 break-all",children:t.project_path})}),w.jsx(no,{label:"Started",children:new Date(t.started_at).toLocaleString("zh-CN")}),t.ended_at&&w.jsx(no,{label:"Ended",children:new Date(t.ended_at).toLocaleString("zh-CN")}),!t.ended_at&&w.jsx(no,{label:"Status",children:w.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[w.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),w.jsx("span",{className:"text-green-400 text-[12px]",children:"运行中"})]})})]}):w.jsx("p",{className:"text-[12px] text-zinc-600",children:"无 DB 记录(可能为外部会话)"})]}),r&&w.jsxs("div",{children:[w.jsxs("h3",{className:"text-[11px] text-zinc-500 uppercase tracking-wider font-medium mb-3 flex items-center gap-2",children:[w.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 inline-block"}),"关联任务"]}),w.jsx(no,{label:"Task ID",children:w.jsx("code",{className:"text-[11px] text-zinc-400",children:r.task_id})}),w.jsx(no,{label:"Title",children:r.title}),w.jsx(no,{label:"Status",children:w.jsx(Kqe,{status:r.status})}),r.objective&&w.jsx(no,{label:"Objective",children:w.jsx("p",{className:"text-[12px] text-zinc-400 leading-relaxed",children:r.objective})}),r.acceptance_criteria&&r.acceptance_criteria.length>0&&w.jsx(no,{label:"验收标准",children:w.jsx("ul",{className:"list-disc list-inside text-[12px] text-zinc-400 space-y-0.5",children:r.acceptance_criteria.map((l,s)=>w.jsx("li",{children:l},s))})}),r.assignee&&w.jsx(no,{label:"Assignee",children:r.assignee}),r.branch&&w.jsx(no,{label:"Branch",children:w.jsx("code",{className:"text-[11px] text-cyan-400",children:r.branch})}),r.pr_url&&w.jsx(no,{label:"PR",children:w.jsx("a",{href:r.pr_url,target:"_blank",rel:"noopener noreferrer",className:"text-[12px] text-blue-400 hover:underline break-all",children:r.pr_url})}),w.jsxs(no,{label:"Retries",children:[r.retry_count," / ",r.max_retries]})]}),!r&&(t==null?void 0:t.task_id)&&w.jsxs("div",{children:[w.jsx("h3",{className:"text-[11px] text-zinc-500 uppercase tracking-wider font-medium mb-3",children:"关联任务"}),w.jsxs("p",{className:"text-[12px] text-zinc-600",children:["Task ",t.task_id," 未找到"]})]})]})}function Uqe(){const{sessionId:e}=WI(),[t,n]=c.useState(!1);return e?w.jsxs("div",{className:"session-viewer",style:{height:"100vh",display:"flex",background:"#09090b",color:"#fafafa"},children:[!t&&w.jsxs("aside",{style:{width:280,borderRight:"1px solid rgba(39,39,42,0.6)",display:"flex",flexDirection:"column",flexShrink:0,background:"#09090b"},children:[w.jsx("div",{style:{height:50,borderBottom:"1px solid rgba(39,39,42,0.6)",display:"flex",alignItems:"center",padding:"0 16px",gap:8},children:w.jsx("span",{className:"text-sm text-zinc-300 font-medium",children:"Session Info"})}),w.jsx("div",{style:{flex:1,overflow:"hidden"},children:w.jsx(qqe,{sessionId:e})})]}),w.jsxs("main",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[w.jsxs("div",{style:{height:50,borderBottom:"1px solid rgba(39,39,42,0.6)",display:"flex",alignItems:"center",padding:"0 16px",gap:12,flexShrink:0},children:[w.jsx("button",{onClick:()=>n(!t),className:"p-1.5 hover:bg-zinc-800 rounded transition-colors cursor-pointer",title:t?"展开侧边栏":"收起侧边栏",children:w.jsx("svg",{className:"w-4 h-4 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})}),w.jsx("span",{className:"text-sm text-zinc-300",children:"CC Session"}),w.jsx("code",{className:"text-xs text-zinc-500",children:e})]}),w.jsx("div",{style:{flex:1,overflow:"hidden"},children:w.jsx(Wqe,{sessionId:e})})]})]}):w.jsx("div",{className:"session-viewer",style:{height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},children:w.jsx("span",{className:"text-zinc-500",children:"Session ID is required"})})}const{Title:Xh,Text:f$}=ra,Gqe=[{value:"",label:"不设置(使用 CLI 默认)"},{value:"default",label:"default — 推荐设置,取决于账户类型"},{value:"opus",label:"opus — 最新 Opus,复杂推理任务"},{value:"sonnet",label:"sonnet — 最新 Sonnet,日常编码"},{value:"haiku",label:"haiku — 快速高效,简单任务"},{value:"opusplan",label:"opusplan — 规划用 Opus,执行用 Sonnet"},{value:"sonnet[1m]",label:"sonnet[1m] — Sonnet + 100 万 token 上下文"}];function Yqe(){const[e]=wn.useForm(),[t]=wn.useForm(),[n,r]=c.useState(!1),[a,o]=c.useState(!1),[i,l]=c.useState(!1),[s,u]=c.useState("custom");c.useEffect(()=>{r(!0),fetch("/api/settings/claude").then(m=>m.json()).then(m=>{e.setFieldsValue(m),t.setFieldsValue({skipOnboarding:m.skipOnboarding}),u(m.providerMode??"custom")}).catch(()=>{Si.error("加载配置失败")}).finally(()=>r(!1))},[e,t]);const d=async m=>{o(!0);try{const v=await fetch("/api/settings/claude",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});if(!v.ok){const g=await v.json();throw new Error(g.error||"保存失败")}Si.success("配置已保存")}catch(v){Si.error(v.message||"保存失败")}finally{o(!1)}},f=async m=>{l(!0);try{const v=await fetch("/api/settings/claude",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipOnboarding:m.skipOnboarding})});if(!v.ok){const g=await v.json();throw new Error(g.error||"保存失败")}Si.success("配置已保存")}catch(v){Si.error(v.message||"保存失败")}finally{l(!1)}};return w.jsxs("div",{style:{maxWidth:640},children:[w.jsxs(io,{loading:n,children:[w.jsx(Xh,{level:4,children:"Claude Code 配置"}),w.jsx(f$,{type:"secondary",style:{display:"block",marginBottom:24},children:"保存后写入 ~/.claude/settings.json,对所有 Claude Code 实例(Loid + Yor)生效。"}),w.jsxs(wn,{form:e,layout:"vertical",onFinish:d,children:[w.jsx(Xh,{level:5,style:{marginBottom:16},children:"API Provider"}),w.jsx(wn.Item,{label:"登录方式",name:"providerMode",extra:"选择「官方登录」将清除所有自定义配置,使用 Claude Code 官方账号登录。",children:w.jsxs(Ml.Group,{onChange:m=>u(m.target.value),children:[w.jsx(Ml.Button,{value:"official",children:"官方登录"}),w.jsx(Ml.Button,{value:"custom",children:"自定义 API"})]})}),s==="official"&&w.jsx(Ec,{type:"info",showIcon:!0,message:"使用官方登录",description:"保存后将清除所有自定义配置(API Key、Base URL、模型设置等),Claude Code 将使用官方账号认证。",style:{marginBottom:24}}),s==="custom"&&w.jsxs(w.Fragment,{children:[w.jsx(wn.Item,{label:"Base URL",name:"baseUrl",rules:[{type:"url",message:"请输入合法的 URL"}],children:w.jsx(Fr,{placeholder:"https://api.anthropic.com"})}),w.jsx(wn.Item,{label:"API Key",name:"apiKey",children:w.jsx(Fr.Password,{placeholder:"sk-ant-xxx"})}),w.jsx(v4,{}),w.jsx(Xh,{level:5,style:{marginBottom:4},children:"模型配置"}),w.jsx(f$,{type:"secondary",style:{display:"block",marginBottom:16},children:"「模型别名」写入 settings.json 顶层 model 字段;下方环境变量可覆盖各别名指向的具体模型版本。"}),w.jsx(wn.Item,{label:"模型别名",name:"model",extra:"选择预设别名,或留空使用 CLI 默认值。opusplan = 规划用 Opus + 执行用 Sonnet。",children:w.jsx(il,{options:Gqe,placeholder:"选择模型别名",allowClear:!0})}),w.jsx(wn.Item,{label:"ANTHROPIC_MODEL",name:"anthropicModel",extra:"主模型环境变量,填写完整模型名称可覆盖别名。留空则由别名决定。",children:w.jsx(Fr,{placeholder:"如 claude-sonnet-4-20250514"})}),w.jsx(wn.Item,{label:"ANTHROPIC_DEFAULT_OPUS_MODEL",name:"opusModel",extra:"opus 别名指向的具体模型版本。",children:w.jsx(Fr,{placeholder:"如 claude-opus-4-20250918"})}),w.jsx(wn.Item,{label:"ANTHROPIC_DEFAULT_SONNET_MODEL",name:"sonnetModel",extra:"sonnet 别名指向的具体模型版本。",children:w.jsx(Fr,{placeholder:"如 claude-sonnet-4-20250514"})}),w.jsx(wn.Item,{label:"ANTHROPIC_DEFAULT_HAIKU_MODEL",name:"haikuModel",extra:"haiku 别名及后台功能使用的模型版本。",children:w.jsx(Fr,{placeholder:"如 claude-haiku-4-5-20251001"})}),w.jsx(wn.Item,{label:"CLAUDE_CODE_SUBAGENT_MODEL",name:"subagentModel",extra:"子代理(subagent)使用的模型。",children:w.jsx(Fr,{placeholder:"如 claude-sonnet-4-20250514"})})]}),w.jsx(wn.Item,{children:w.jsx(Hn,{children:w.jsx(nr,{type:"primary",htmlType:"submit",icon:w.jsx(v5,{}),loading:a,children:"保存"})})})]})]}),w.jsxs(io,{style:{marginTop:16},loading:n,children:[w.jsx(Xh,{level:4,children:"Claude Code 初始化"}),w.jsx(f$,{type:"secondary",style:{display:"block",marginBottom:24},children:"写入 ~/.claude.json,控制 Claude Code CLI 首次启动行为。"}),w.jsxs(wn,{form:t,layout:"vertical",onFinish:f,children:[w.jsx(wn.Item,{label:"跳过初次安装确认",name:"skipOnboarding",valuePropName:"checked",extra:"设置 hasCompletedOnboarding = true,跳过首次启动的交互式确认流程。",children:w.jsx(_4,{})}),w.jsx(wn.Item,{children:w.jsx(nr,{type:"primary",htmlType:"submit",icon:w.jsx(v5,{}),loading:i,children:"保存"})})]})]})]})}const{Text:Qh}=ra;function Xqe(){const e=c.useRef(null),t=zi(),n=[{title:"Session ID",dataIndex:"session_id",width:160,search:!1,render:(r,a)=>w.jsx("a",{onClick:o=>{o.preventDefault(),o.stopPropagation(),t(`/sessions/${a.session_id}`)},children:w.jsxs(Qh,{style:{fontFamily:"monospace",fontSize:12},children:[w.jsx(Vy,{style:{color:"#722ed1",marginRight:4}}),a.session_id.slice(0,12),"..."]})})},{title:"角色",dataIndex:"role",width:90,valueType:"select",fieldProps:{options:[{label:"Loid",value:"loid"},{label:"Yor",value:"yor"}]},render:(r,a)=>w.jsx(on,{color:a.role==="loid"?"blue":"orange",children:a.role==="loid"?"Loid":"Yor"})},{title:"状态",dataIndex:"active",width:90,valueType:"select",fieldProps:{options:[{label:"进行中",value:"true"},{label:"已结束",value:"false"}]},render:(r,a)=>a.ended_at?w.jsx(on,{children:"已结束"}):w.jsx(on,{color:"green",children:"进行中"})},{title:"关联任务",dataIndex:"task_id",width:180,render:(r,a)=>a.task_id?w.jsxs("a",{onClick:o=>{o.preventDefault(),o.stopPropagation(),t(`/tasks?taskId=${a.task_id}`)},children:[w.jsx(eI,{style:{marginRight:4}}),w.jsx(Qh,{style:{fontFamily:"monospace",fontSize:12},children:a.task_id})]}):w.jsx(Qh,{type:"secondary",children:"-"})},{title:"实例 ID",dataIndex:"instance_id",width:160,search:!1,ellipsis:!0,render:(r,a)=>a.instance_id?w.jsx(Qh,{style:{fontFamily:"monospace",fontSize:12},children:a.instance_id}):"-"},{title:"开始时间",dataIndex:"started_at",valueType:"dateTime",width:180,search:!1,sorter:!0,defaultSortOrder:"descend",render:(r,a)=>Wt(a.started_at).format("YYYY-MM-DD HH:mm:ss")},{title:"结束时间",dataIndex:"ended_at",valueType:"dateTime",width:180,search:!1,render:(r,a)=>a.ended_at?Wt(a.ended_at).format("YYYY-MM-DD HH:mm:ss"):"-"}];return w.jsx("div",{children:w.jsx(dl,{actionRef:e,columns:n,rowKey:"id",headerTitle:"会话管理",search:{labelWidth:"auto",defaultCollapsed:!1},pagination:{defaultPageSize:20,showSizeChanger:!0,pageSizeOptions:["10","20","50","100"]},request:async r=>{const a=new URLSearchParams,o=r.pageSize??20,i=r.current??1;a.set("limit",String(o)),a.set("offset",String((i-1)*o)),r.role&&a.set("role",r.role),r.active&&a.set("active",r.active),r.task_id&&a.set("task_id",r.task_id);try{const l=await fetch(`/api/sessions?${a.toString()}`);if(!l.ok)throw new Error("Failed to fetch");const s=await l.json();return{data:s.data,total:s.total,success:!0}}catch{return{data:[],total:0,success:!1}}},onRow:r=>({onClick:()=>{t(`/sessions/${r.session_id}`)},style:{cursor:"pointer"}})})})}const Qqe={route:{path:"/",routes:[{path:"/workspace",name:"工作台",icon:w.jsx(pW,{}),routes:[{path:"/dashboard",name:"仪表盘"},{path:"/projects",name:"项目总览"},{path:"/tasks",name:"任务管理"}]},{path:"/comms",name:"沟通",icon:w.jsx(c0,{}),routes:[{path:"/messages",name:"消息日志"},{path:"/chats",name:"群聊管理"}]},{path:"/observability",name:"可观测",icon:w.jsx(uW,{}),routes:[{path:"/traces",name:"链路追踪"},{path:"/audit",name:"审计日志"},{path:"/sessions-list",name:"会话管理"},{path:"/reports",name:"每日报告"}]},{path:"/admin",name:"管理",icon:w.jsx(hW,{}),routes:[{path:"/team",name:"团队成员"},{path:"/settings",name:"设置"}]}]}};function Zqe(){const e=zi(),t=Al();return w.jsx(KFe,{title:"Anya Gateway",logo:w.jsx(pW,{style:{fontSize:24}}),layout:"mix",fixSiderbar:!0,...Qqe,location:{pathname:t.pathname},menuItemRender:(n,r)=>w.jsx("a",{onClick:a=>{a.preventDefault(),n.path&&e(n.path)},children:r}),children:w.jsxs(NL,{children:[w.jsx(Sa,{path:"/",element:w.jsx(hX,{to:"/dashboard",replace:!0})}),w.jsx(Sa,{path:"/dashboard",element:w.jsx(Z7e,{})}),w.jsx(Sa,{path:"/projects",element:w.jsx(Eze,{})}),w.jsx(Sa,{path:"/projects/:projectId",element:w.jsx(Oze,{})}),w.jsx(Sa,{path:"/tasks",element:w.jsx(hze,{})}),w.jsx(Sa,{path:"/messages",element:w.jsx(uze,{})}),w.jsx(Sa,{path:"/chats",element:w.jsx($ze,{})}),w.jsx(Sa,{path:"/chats/:chatId",element:w.jsx(_ze,{})}),w.jsx(Sa,{path:"/audit",element:w.jsx(bze,{})}),w.jsx(Sa,{path:"/traces",element:w.jsx(pze,{})}),w.jsx(Sa,{path:"/sessions-list",element:w.jsx(Xqe,{})}),w.jsx(Sa,{path:"/reports",element:w.jsx(xze,{})}),w.jsx(Sa,{path:"/team",element:w.jsx(Sze,{})}),w.jsx(Sa,{path:"/settings",element:w.jsx(Yqe,{})})]})})}function Jqe(){return w.jsxs(NL,{children:[w.jsx(Sa,{path:"/sessions/:sessionId",element:w.jsx(Uqe,{})}),w.jsx(Sa,{path:"/*",element:w.jsx(Zqe,{})})]})}xY.createRoot(document.getElementById("root")).render(w.jsx(te.StrictMode,{children:w.jsx(BX,{children:w.jsx(Jqe,{})})}))});export default eUe();
798
+ `),a=50,o=r.length>a,i=o?r.slice(0,a):r,l=n?NU(n):"",s=l?jU(l):null;return w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx($q,{size:14,className:"text-sky-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:"File Content"}),s&&w.jsx("span",{className:"text-xs text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:s}),w.jsxs("span",{className:"text-xs text-zinc-500 ml-auto",children:[r.length," lines"]})]}),w.jsxs("div",{className:"overflow-x-auto max-h-96 overflow-y-auto",children:[w.jsx("table",{className:"w-full text-xs font-mono",children:w.jsx("tbody",{children:i.map((u,d)=>w.jsxs("tr",{className:"hover:bg-zinc-800/30",children:[w.jsx("td",{className:"select-none text-right pr-3 pl-3 py-0.5 text-zinc-600 border-r border-zinc-800 w-10 sticky left-0 bg-zinc-900/70",children:d+1}),w.jsx("td",{className:"pl-3 pr-3 py-0.5 text-zinc-300 whitespace-pre",children:u||" "})]},d))})}),o&&w.jsxs("div",{className:"px-3 py-2 text-xs text-zinc-500 border-t border-zinc-700/50",children:["... ",r.length-a," more lines"]})]})]})})}function Rqe(e){const{input:t}=e;return!t||!t.questions||t.questions.length===0?null:w.jsx("div",{className:"w-full mt-2 space-y-3",children:t.questions.map((n,r)=>w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(Vze,{size:14,className:"text-violet-400"}),w.jsx("span",{className:"text-xs font-medium text-zinc-300",children:n.header||"Question"}),n.multiSelect&&w.jsx("span",{className:"text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded ml-auto",children:"Multi-select"})]}),w.jsxs("div",{className:"p-3 space-y-3",children:[w.jsx("p",{className:"text-sm text-zinc-200",children:n.question}),n.options&&n.options.length>0&&w.jsx("div",{className:"space-y-2",children:n.options.map((a,o)=>{const i=n.multiSelect?PAe:OAe;return w.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded bg-zinc-800/40 border border-zinc-700/30",children:[w.jsx(i,{size:14,className:"text-violet-400/70 mt-0.5 flex-shrink-0"}),w.jsxs("div",{className:"min-w-0",children:[w.jsx("div",{className:"text-xs font-medium text-zinc-200",children:a.label}),a.description&&w.jsx("div",{className:"text-xs text-zinc-500 mt-0.5",children:a.description})]})]},o)})})]})]},r))})}function Oqe(e){const t=e.toLowerCase();return t==="explore"?"text-cyan-400":t==="plan"?"text-violet-400":t==="claude-code-guide"?"text-amber-400":t==="general-purpose"?"text-emerald-400":"text-blue-400"}function Mqe(e){const t=e.toLowerCase();return t==="explore"?"bg-cyan-500/10 border-cyan-500/20":t==="plan"?"bg-violet-500/10 border-violet-500/20":t==="claude-code-guide"?"bg-amber-500/10 border-amber-500/20":t==="general-purpose"?"bg-emerald-500/10 border-emerald-500/20":"bg-blue-500/10 border-blue-500/20"}function _qe(e){const{input:t}=e;if(!t)return null;const n=Oqe(t.subagent_type),r=Mqe(t.subagent_type);return w.jsx("div",{className:"w-full mt-2",children:w.jsxs("div",{className:"bg-zinc-900/70 border border-zinc-700/50 rounded-lg overflow-hidden",children:[w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700/50 bg-zinc-800/30",children:[w.jsx(bq,{size:14,className:n}),w.jsx("span",{className:`text-xs font-medium ${n}`,children:t.subagent_type}),t.description&&w.jsxs(w.Fragment,{children:[w.jsx(Lze,{size:10,className:"text-zinc-600"}),w.jsx("span",{className:"text-xs text-zinc-400",children:t.description})]}),w.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.resume&&w.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:[w.jsx($Ae,{size:10}),"resume"]}),t.run_in_background&&w.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:[w.jsx(gAe,{size:10}),"background"]}),t.model&&w.jsx("span",{className:"text-[10px] text-zinc-500 bg-zinc-700/50 px-1.5 py-0.5 rounded",children:t.model})]})]}),w.jsx("div",{className:"p-3",children:w.jsxs("div",{className:`flex items-start gap-2 px-3 py-2 rounded-lg border ${r}`,children:[w.jsx(Iq,{size:12,className:`${n} mt-0.5 flex-shrink-0`}),w.jsx("p",{className:"text-xs text-zinc-300 leading-relaxed whitespace-pre-wrap",children:t.prompt})]})})]})})}const kU=c.memo(function(t){const{content:n,className:r=""}=t;return w.jsx("div",{className:`break-words ${r}`,children:w.jsx(GVe,{remarkPlugins:[lqe],components:{h1:a=>w.jsx("div",{className:"text-base font-semibold text-zinc-100 mt-3 mb-1.5",children:a.children}),h2:a=>w.jsx("div",{className:"text-sm font-semibold text-zinc-100 mt-3 mb-1.5",children:a.children}),h3:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-3 mb-1.5",children:a.children}),h4:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-2 mb-1",children:a.children}),h5:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-2 mb-1",children:a.children}),h6:a=>w.jsx("div",{className:"text-[13px] font-medium text-zinc-100 mt-2 mb-1",children:a.children}),p:a=>w.jsx("p",{className:"text-[13px] leading-relaxed text-zinc-200 whitespace-pre-wrap my-2",children:a.children}),a:a=>w.jsx("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 underline underline-offset-2",children:a.children}),strong:a=>w.jsx("strong",{className:"font-semibold text-zinc-50",children:a.children}),em:a=>w.jsx("em",{className:"italic text-zinc-200",children:a.children}),code:a=>w.jsx("code",{className:"px-1.5 py-0.5 rounded bg-zinc-800/80 text-cyan-300 text-[12px] font-mono",children:a.children}),pre:a=>{var l,s,u;const{node:o}=a,i=(l=o==null?void 0:o.children)==null?void 0:l[0];if((i==null?void 0:i.tagName)==="code"){const f=(((s=i.properties)==null?void 0:s.className)||[]).find(g=>g.startsWith("language-")),m=(f==null?void 0:f.replace("language-",""))||"code",v=((u=i.children)==null?void 0:u.map(g=>g.value).join(""))||"";return w.jsxs("div",{className:"relative group my-2 rounded-lg overflow-hidden border border-zinc-700/50",children:[w.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-zinc-900 border-b border-zinc-700/50",children:[w.jsx("span",{className:"text-[10px] text-zinc-500 font-mono",children:m}),w.jsx(ip,{text:v})]}),w.jsx("pre",{className:"text-xs text-zinc-300 bg-zinc-900/80 p-3 overflow-x-auto",children:w.jsx("code",{children:v})})]})}return w.jsx("pre",{children:a.children})},ul:a=>w.jsx("ul",{className:"my-2 ml-3 space-y-1 list-disc list-inside text-zinc-200",children:a.children}),ol:a=>w.jsx("ol",{className:"my-2 ml-3 space-y-1 list-decimal list-inside text-zinc-200",children:a.children}),li:a=>w.jsx("li",{className:"text-[13px] leading-relaxed",children:a.children}),blockquote:a=>w.jsx("div",{className:"border-l-2 border-zinc-600 pl-3 my-2 text-zinc-400 italic",children:a.children}),hr:()=>w.jsx("hr",{className:"border-zinc-700 my-4"}),table:a=>w.jsx("div",{className:"my-2 overflow-x-auto rounded-lg border border-zinc-700/50",children:w.jsx("table",{className:"w-full text-[13px]",children:a.children})}),thead:a=>w.jsx("thead",{className:"bg-zinc-900",children:a.children}),tr:a=>w.jsx("tr",{className:"border-b border-zinc-700/50 last:border-b-0",children:a.children}),th:a=>w.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-200",children:a.children}),td:a=>w.jsx("td",{className:"px-3 py-2 text-zinc-300",children:a.children})},children:n})})});function Tqe(e){const t=new Map;for(const n of e)n.type==="tool_use"&&n.id&&n.name&&t.set(n.id,n.name);return t}const Nqe=c.memo(function(t){var g;const{message:n}=t,r=n.type==="user",a=(g=n.message)==null?void 0:g.content,o=()=>!a||typeof a=="string"?[]:a.filter(y=>y.type==="text"),i=()=>!a||typeof a=="string"?[]:a.filter(y=>y.type==="tool_use"||y.type==="tool_result"||y.type==="thinking"),l=()=>o().filter(y=>y.text&&td(y.text).length>0),s=()=>typeof a=="string"?td(a).length>0:l().length>0,u=i(),d=l(),f=s(),m=u.length>0,v=Array.isArray(a)?Tqe(a):new Map;return!f&&m?w.jsx("div",{className:"flex flex-col gap-1 py-0.5",children:u.map((y,h)=>w.jsx(d$,{block:y,toolMap:v},h))}):!f&&!m?null:w.jsx("div",{className:`flex ${r?"justify-end":"justify-start"} min-w-0`,children:w.jsxs("div",{className:"max-w-[85%] min-w-0",children:[w.jsx("div",{className:`px-3.5 py-2.5 rounded-2xl overflow-hidden ${r?"bg-indigo-600/80 text-indigo-50 rounded-br-md":"bg-cyan-700/50 text-zinc-100 rounded-bl-md"}`,children:typeof a=="string"?r?w.jsx("div",{className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed",children:td(a)}):w.jsx(kU,{content:td(a)}):w.jsx("div",{className:"flex flex-col gap-1",children:d.map((y,h)=>w.jsx(d$,{block:y,isUser:r,toolMap:v},h))})}),m&&w.jsx("div",{className:"flex flex-col gap-1 mt-1.5",children:u.map((y,h)=>w.jsx(d$,{block:y,toolMap:v},h))})]})})}),gL={todowrite:Eq,read:Sq,bash:Pq,grep:I0,edit:bAe,write:wq,glob:kR,task:bq},jqe=[{patterns:["web","fetch","url"],icon:aAe},{patterns:["ask","question"],icon:mAe},{patterns:["git","commit"],icon:nAe},{patterns:["sql","database","query"],icon:Gze},{patterns:["file","disk"],icon:iAe}];function kqe(e){const t=e.toLowerCase();if(gL[t])return gL[t];for(const{patterns:n,icon:r}of jqe)if(n.some(a=>t.includes(a)))return r;return jAe}function u$(e){return e.split("/").slice(-2).join("/")}const Dqe={read:e=>e.file_path?u$(String(e.file_path)):null,edit:e=>e.file_path?u$(String(e.file_path)):null,write:e=>e.file_path?u$(String(e.file_path)):null,bash:e=>{if(!e.command)return null;const t=String(e.command);return t.length>50?t.slice(0,50)+"...":t},grep:e=>e.pattern?`"${String(e.pattern)}"`:null,glob:e=>e.pattern?String(e.pattern):null,task:e=>e.description?String(e.description):null};function Fqe(e,t){if(!t)return null;const n=e.toLowerCase(),r=Dqe[n];if(r)return r(t);if(n.includes("web")&&t.url)try{return new URL(String(t.url)).hostname}catch{return String(t.url).slice(0,30)}return null}function Lqe(e){const{toolName:t,input:n}=e,r=t.toLowerCase();return r==="todowrite"&&n.todos?w.jsx(uqe,{todos:n.todos}):r==="edit"&&n.file_path?w.jsx(bqe,{input:n}):r==="write"&&n.file_path?w.jsx(xqe,{input:n}):r==="bash"&&n.command?w.jsx(Cqe,{input:n}):r==="grep"&&n.pattern?w.jsx(wqe,{input:n}):r==="glob"&&n.pattern?w.jsx($qe,{input:n}):r==="read"&&n.file_path?w.jsx(Iqe,{input:n}):r==="askuserquestion"&&n.questions?w.jsx(Rqe,{input:n}):r==="task"&&n.prompt?w.jsx(_qe,{input:n}):w.jsx("pre",{className:"text-xs text-slate-300 bg-slate-900/50 border border-slate-700/50 rounded-lg p-3 mt-2 overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto",children:JSON.stringify(n,null,2)})}function zqe(e){const{toolName:t,content:n,isError:r}=e,a=t.toLowerCase();if(a==="bash")return w.jsx(Sqe,{content:n,isError:r});if(a==="glob")return w.jsx(hL,{content:n,isFileList:!0});if(a==="grep")return w.jsx(hL,{content:n});if(a==="read")return w.jsx(Pqe,{content:n});if(!n||n.trim().length===0)return w.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-teal-500/10 border border-teal-500/20 rounded-lg mt-2",children:[w.jsx(fb,{size:14,className:"text-teal-400"}),w.jsx("span",{className:"text-xs text-teal-300",children:"Completed successfully"})]});const o=2e3,i=n.length>o,l=i?n.slice(0,o):n;return w.jsxs("pre",{className:`text-xs rounded-lg p-3 mt-2 overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto border ${r?"bg-rose-950/30 text-rose-200/80 border-rose-900/30":"bg-teal-950/30 text-teal-200/80 border-teal-900/30"}`,children:[l,i&&w.jsxs("span",{className:"text-zinc-500",children:["... (",n.length-o," more chars)"]})]})}function d$(e){var i;const{block:t,isUser:n,toolMap:r}=e,[a,o]=c.useState(!1);if(t.type==="text"&&t.text){const l=td(t.text);return l?n?w.jsx("div",{className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed",children:l}):w.jsx(kU,{content:l}):null}if(t.type==="thinking"&&t.thinking)return w.jsxs("div",{className:a?"w-full":"",children:[w.jsxs("button",{onClick:()=>o(!a),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-amber-500/10 hover:bg-amber-500/15 text-[11px] text-amber-400/90 transition-colors border border-amber-500/20",children:[w.jsx(sAe,{size:12,className:"opacity-70"}),w.jsx("span",{className:"font-medium",children:"thinking"}),w.jsx("span",{className:"text-[10px] opacity-50 ml-0.5",children:a?"▼":"▶"})]}),a&&w.jsx("pre",{className:"text-xs text-zinc-400 bg-zinc-900/80 border border-zinc-800 rounded-lg p-3 mt-2 whitespace-pre-wrap max-h-80 overflow-y-auto",children:t.thinking})]});if(t.type==="tool_use"){const l=t.input&&typeof t.input=="object"?t.input:void 0,s=l&&Object.keys(l).length>0,u=kqe(t.name||""),d=Fqe(t.name||"",l),f=((i=t.name)==null?void 0:i.toLowerCase())||"",m=["todowrite","edit","write","bash","grep","glob","read","askuserquestion","task"].includes(f),v=f==="todowrite"||f==="askuserquestion"||f==="task",g=a||v;return w.jsxs("div",{className:g?"w-full":"",children:[w.jsxs("button",{onClick:()=>s&&!v&&o(!a),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-slate-500/10 hover:bg-slate-500/15 text-[11px] text-slate-300 transition-colors border border-slate-500/20",children:[w.jsx(u,{size:12,className:"opacity-60"}),w.jsx("span",{className:"font-medium text-slate-200",children:t.name}),d&&w.jsx("span",{className:"text-slate-500 font-normal truncate max-w-[200px]",children:d}),s&&!v&&w.jsx("span",{className:"text-[10px] opacity-40 ml-0.5",children:a?"▼":"▶"})]}),g&&s&&m?w.jsx(Lqe,{toolName:t.name||"",input:l}):a&&s&&w.jsx("pre",{className:"text-xs text-slate-300 bg-slate-900/50 border border-slate-700/50 rounded-lg p-3 mt-2 overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto",children:JSON.stringify(l,null,2)})]})}if(t.type==="tool_result"){const l=t.is_error,s=typeof t.content=="string"?t.content:JSON.stringify(t.content,null,2),u=td(s),d=u.length>0,f=60,m=d&&!a?u.slice(0,f)+(u.length>f?"...":""):null,v=t.tool_use_id&&r&&r.get(t.tool_use_id)||"";return w.jsxs("div",{className:a?"w-full":"",children:[w.jsxs("button",{onClick:()=>d&&o(!a),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] transition-colors border ${l?"bg-rose-500/10 hover:bg-rose-500/15 text-rose-400/90 border-rose-500/20":"bg-teal-500/10 hover:bg-teal-500/15 text-teal-400/90 border-teal-500/20"}`,children:[l?w.jsx(DAe,{size:12,className:"opacity-70"}):w.jsx(fb,{size:12,className:"opacity-70"}),w.jsx("span",{className:"font-medium",children:l?"error":"result"}),m&&!a&&w.jsx("span",{className:`font-normal truncate max-w-[200px] ${l?"text-rose-500/70":"text-teal-500/70"}`,children:m}),d&&w.jsx("span",{className:"text-[10px] opacity-40 ml-0.5",children:a?"▼":"▶"})]}),a&&d&&w.jsx(zqe,{toolName:v,content:u,isError:l})]})}return null}function Aqe({onClick:e}){return w.jsxs("button",{onClick:e,className:"fixed bottom-4 right-6 flex cursor-pointer items-center gap-1.5 rounded-full bg-zinc-200/90 px-3.5 py-2 text-xs font-medium text-zinc-900 shadow-lg backdrop-blur-sm transition-all hover:bg-zinc-100",children:[w.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})}),w.jsx("span",{children:"Latest"})]})}const Bqe=10,Hqe=1e3,Vqe=100;function Wqe(e){const{sessionId:t}=e,[n,r]=c.useState([]),[a,o]=c.useState(!0),[i,l]=c.useState(!0),s=c.useRef(null),u=c.useRef(null),d=c.useRef(0),f=c.useRef(!1),m=c.useRef(0),v=c.useRef(null),g=c.useRef(null),y=c.useRef(!0),h=c.useCallback(()=>{if(!y.current)return;v.current&&v.current.close();const I=new EventSource(`/api/sessions/${t}/stream?offset=${d.current}`);v.current=I,I.addEventListener("messages",E=>{m.current=0;const P=JSON.parse(E.data);o(!1),r(M=>{const R=new Set(M.map(N=>N.uuid).filter(Boolean)),O=P.filter(N=>!R.has(N.uuid));return O.length===0?M:(d.current+=O.length,[...M,...O])})}),I.onerror=()=>{if(I.close(),o(!1),!!y.current&&m.current<Bqe){const E=Math.min(Hqe*Math.pow(2,m.current),3e4);m.current++,g.current=setTimeout(()=>h(),E)}}},[t]);c.useEffect(()=>(y.current=!0,o(!0),r([]),d.current=0,m.current=0,h(),()=>{y.current=!1,g.current&&clearTimeout(g.current),v.current&&v.current.close()}),[h]);const x=c.useCallback(()=>{u.current&&(f.current=!0,u.current.scrollIntoView({behavior:"instant",block:"end"}),requestAnimationFrame(()=>{f.current=!1}))},[]);c.useEffect(()=>{i&&x()},[n,i,x]);const C=()=>{if(!s.current||f.current)return;const{scrollTop:I,scrollHeight:E,clientHeight:P}=s.current,M=E-I-P<Vqe;l(M)},S=n.find(I=>I.type==="summary"),$=n.filter(I=>I.type==="user"||I.type==="assistant");return a?w.jsx("div",{className:"flex h-full items-center justify-center text-zinc-500",children:"Loading..."}):$.length===0?w.jsx("div",{className:"flex h-full items-center justify-center text-zinc-500",children:"No messages in this session."}):w.jsxs("div",{className:"relative h-full",children:[w.jsx("div",{ref:s,onScroll:C,className:"h-full overflow-y-auto bg-zinc-950",children:w.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-4",children:[S&&w.jsxs("div",{className:"mb-6 rounded-xl border border-zinc-800/60 bg-zinc-900/50 p-4",children:[w.jsx("h2",{className:"text-sm font-medium text-zinc-200 leading-relaxed",children:S.summary}),w.jsxs("p",{className:"mt-2 text-[11px] text-zinc-500",children:[$.length," messages"]})]}),w.jsx("div",{className:"flex flex-col gap-2",children:$.map((I,E)=>w.jsx("div",{ref:E===$.length-1?u:void 0,children:w.jsx(Nqe,{message:I})},I.uuid||E))})]})}),!i&&w.jsx(Aqe,{onClick:()=>{l(!0),x()}})]})}function Kqe({status:e}){const t=G7e[e]??"bg-zinc-500/20 text-zinc-400";return w.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-[11px] font-medium ${t}`,children:Fs[e]??e})}function no({label:e,children:t}){return w.jsxs("div",{className:"mb-3",children:[w.jsx("div",{className:"text-[10px] text-zinc-500 uppercase tracking-wide mb-0.5",children:e}),w.jsx("div",{className:"text-[13px] text-zinc-300",children:t})]})}function qqe({sessionId:e}){const[t,n]=c.useState(null),[r,a]=c.useState(null),[o,i]=c.useState(!0);return c.useEffect(()=>{fetch(`/api/sessions/${e}/info`).then(l=>l.json()).then(l=>{l.success&&(n(l.data.session),a(l.data.task)),i(!1)}).catch(()=>i(!1))},[e]),o?w.jsx("div",{className:"flex items-center justify-center h-full text-zinc-600 text-xs",children:"Loading..."}):w.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4",children:[w.jsxs("div",{className:"mb-6",children:[w.jsxs("h3",{className:"text-[11px] text-zinc-500 uppercase tracking-wider font-medium mb-3 flex items-center gap-2",children:[w.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-500 inline-block"}),"Session"]}),t?w.jsxs(w.Fragment,{children:[w.jsx(no,{label:"Role",children:w.jsx("span",{className:`font-medium ${t.role==="yor"?"text-orange-400":t.role==="franky"?"text-green-400":"text-cyan-400"}`,children:t.role==="yor"?"Yor (执行者)":t.role==="franky"?"Franky (驻场工程师)":"Loid (策划者)"})}),t.project_path&&w.jsx(no,{label:"Project Path",children:w.jsx("code",{className:"text-[11px] text-zinc-400 break-all",children:t.project_path})}),w.jsx(no,{label:"Started",children:new Date(t.started_at).toLocaleString("zh-CN")}),t.ended_at&&w.jsx(no,{label:"Ended",children:new Date(t.ended_at).toLocaleString("zh-CN")}),!t.ended_at&&w.jsx(no,{label:"Status",children:w.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[w.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),w.jsx("span",{className:"text-green-400 text-[12px]",children:"运行中"})]})})]}):w.jsx("p",{className:"text-[12px] text-zinc-600",children:"无 DB 记录(可能为外部会话)"})]}),r&&w.jsxs("div",{children:[w.jsxs("h3",{className:"text-[11px] text-zinc-500 uppercase tracking-wider font-medium mb-3 flex items-center gap-2",children:[w.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 inline-block"}),"关联任务"]}),w.jsx(no,{label:"Task ID",children:w.jsx("code",{className:"text-[11px] text-zinc-400",children:r.task_id})}),w.jsx(no,{label:"Title",children:r.title}),w.jsx(no,{label:"Status",children:w.jsx(Kqe,{status:r.status})}),r.objective&&w.jsx(no,{label:"Objective",children:w.jsx("p",{className:"text-[12px] text-zinc-400 leading-relaxed",children:r.objective})}),r.acceptance_criteria&&r.acceptance_criteria.length>0&&w.jsx(no,{label:"验收标准",children:w.jsx("ul",{className:"list-disc list-inside text-[12px] text-zinc-400 space-y-0.5",children:r.acceptance_criteria.map((l,s)=>w.jsx("li",{children:l},s))})}),r.assignee&&w.jsx(no,{label:"Assignee",children:r.assignee}),r.branch&&w.jsx(no,{label:"Branch",children:w.jsx("code",{className:"text-[11px] text-cyan-400",children:r.branch})}),r.pr_url&&w.jsx(no,{label:"PR",children:w.jsx("a",{href:r.pr_url,target:"_blank",rel:"noopener noreferrer",className:"text-[12px] text-blue-400 hover:underline break-all",children:r.pr_url})}),w.jsxs(no,{label:"Retries",children:[r.retry_count," / ",r.max_retries]})]}),!r&&(t==null?void 0:t.task_id)&&w.jsxs("div",{children:[w.jsx("h3",{className:"text-[11px] text-zinc-500 uppercase tracking-wider font-medium mb-3",children:"关联任务"}),w.jsxs("p",{className:"text-[12px] text-zinc-600",children:["Task ",t.task_id," 未找到"]})]})]})}function Uqe(){const{sessionId:e}=WI(),[t,n]=c.useState(!1);return e?w.jsxs("div",{className:"session-viewer",style:{height:"100vh",display:"flex",background:"#09090b",color:"#fafafa"},children:[!t&&w.jsxs("aside",{style:{width:280,borderRight:"1px solid rgba(39,39,42,0.6)",display:"flex",flexDirection:"column",flexShrink:0,background:"#09090b"},children:[w.jsx("div",{style:{height:50,borderBottom:"1px solid rgba(39,39,42,0.6)",display:"flex",alignItems:"center",padding:"0 16px",gap:8},children:w.jsx("span",{className:"text-sm text-zinc-300 font-medium",children:"Session Info"})}),w.jsx("div",{style:{flex:1,overflow:"hidden"},children:w.jsx(qqe,{sessionId:e})})]}),w.jsxs("main",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[w.jsxs("div",{style:{height:50,borderBottom:"1px solid rgba(39,39,42,0.6)",display:"flex",alignItems:"center",padding:"0 16px",gap:12,flexShrink:0},children:[w.jsx("button",{onClick:()=>n(!t),className:"p-1.5 hover:bg-zinc-800 rounded transition-colors cursor-pointer",title:t?"展开侧边栏":"收起侧边栏",children:w.jsx("svg",{className:"w-4 h-4 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})}),w.jsx("span",{className:"text-sm text-zinc-300",children:"CC Session"}),w.jsx("code",{className:"text-xs text-zinc-500",children:e})]}),w.jsx("div",{style:{flex:1,overflow:"hidden"},children:w.jsx(Wqe,{sessionId:e})})]})]}):w.jsx("div",{className:"session-viewer",style:{height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},children:w.jsx("span",{className:"text-zinc-500",children:"Session ID is required"})})}const{Title:Xh,Text:f$}=ra,Gqe=[{value:"",label:"不设置(使用 CLI 默认)"},{value:"default",label:"default — 推荐设置,取决于账户类型"},{value:"opus",label:"opus — 最新 Opus,复杂推理任务"},{value:"sonnet",label:"sonnet — 最新 Sonnet,日常编码"},{value:"haiku",label:"haiku — 快速高效,简单任务"},{value:"opusplan",label:"opusplan — 规划用 Opus,执行用 Sonnet"},{value:"sonnet[1m]",label:"sonnet[1m] — Sonnet + 100 万 token 上下文"}];function Yqe(){const[e]=wn.useForm(),[t]=wn.useForm(),[n,r]=c.useState(!1),[a,o]=c.useState(!1),[i,l]=c.useState(!1),[s,u]=c.useState("custom");c.useEffect(()=>{r(!0),fetch("/api/settings/claude").then(m=>m.json()).then(m=>{e.setFieldsValue(m),t.setFieldsValue({skipOnboarding:m.skipOnboarding}),u(m.providerMode??"custom")}).catch(()=>{Si.error("加载配置失败")}).finally(()=>r(!1))},[e,t]);const d=async m=>{o(!0);try{const v=await fetch("/api/settings/claude",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});if(!v.ok){const g=await v.json();throw new Error(g.error||"保存失败")}Si.success("配置已保存")}catch(v){Si.error(v.message||"保存失败")}finally{o(!1)}},f=async m=>{l(!0);try{const v=await fetch("/api/settings/claude",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipOnboarding:m.skipOnboarding})});if(!v.ok){const g=await v.json();throw new Error(g.error||"保存失败")}Si.success("配置已保存")}catch(v){Si.error(v.message||"保存失败")}finally{l(!1)}};return w.jsxs("div",{style:{maxWidth:640},children:[w.jsxs(io,{loading:n,children:[w.jsx(Xh,{level:4,children:"Claude Code 配置"}),w.jsx(f$,{type:"secondary",style:{display:"block",marginBottom:24},children:"保存后写入 ~/.claude/settings.json,对所有 Claude Code 实例(Loid + Yor)生效。"}),w.jsxs(wn,{form:e,layout:"vertical",onFinish:d,children:[w.jsx(Xh,{level:5,style:{marginBottom:16},children:"API Provider"}),w.jsx(wn.Item,{label:"登录方式",name:"providerMode",extra:"选择「官方登录」将清除所有自定义配置,使用 Claude Code 官方账号登录。",children:w.jsxs(Ml.Group,{onChange:m=>u(m.target.value),children:[w.jsx(Ml.Button,{value:"official",children:"官方登录"}),w.jsx(Ml.Button,{value:"custom",children:"自定义 API"})]})}),s==="official"&&w.jsx(Ec,{type:"info",showIcon:!0,message:"使用官方登录",description:"保存后将清除所有自定义配置(API Key、Base URL、模型设置等),Claude Code 将使用官方账号认证。",style:{marginBottom:24}}),s==="custom"&&w.jsxs(w.Fragment,{children:[w.jsx(wn.Item,{label:"Base URL",name:"baseUrl",rules:[{type:"url",message:"请输入合法的 URL"}],children:w.jsx(Fr,{placeholder:"https://api.anthropic.com"})}),w.jsx(wn.Item,{label:"API Key",name:"apiKey",children:w.jsx(Fr.Password,{placeholder:"sk-ant-xxx"})}),w.jsx(v4,{}),w.jsx(Xh,{level:5,style:{marginBottom:4},children:"模型配置"}),w.jsx(f$,{type:"secondary",style:{display:"block",marginBottom:16},children:"「模型别名」写入 settings.json 顶层 model 字段;下方环境变量可覆盖各别名指向的具体模型版本。"}),w.jsx(wn.Item,{label:"模型别名",name:"model",extra:"选择预设别名,或留空使用 CLI 默认值。opusplan = 规划用 Opus + 执行用 Sonnet。",children:w.jsx(il,{options:Gqe,placeholder:"选择模型别名",allowClear:!0})}),w.jsx(wn.Item,{label:"ANTHROPIC_MODEL",name:"anthropicModel",extra:"主模型环境变量,填写完整模型名称可覆盖别名。留空则由别名决定。",children:w.jsx(Fr,{placeholder:"如 claude-sonnet-4-20250514"})}),w.jsx(wn.Item,{label:"ANTHROPIC_DEFAULT_OPUS_MODEL",name:"opusModel",extra:"opus 别名指向的具体模型版本。",children:w.jsx(Fr,{placeholder:"如 claude-opus-4-20250918"})}),w.jsx(wn.Item,{label:"ANTHROPIC_DEFAULT_SONNET_MODEL",name:"sonnetModel",extra:"sonnet 别名指向的具体模型版本。",children:w.jsx(Fr,{placeholder:"如 claude-sonnet-4-20250514"})}),w.jsx(wn.Item,{label:"ANTHROPIC_DEFAULT_HAIKU_MODEL",name:"haikuModel",extra:"haiku 别名及后台功能使用的模型版本。",children:w.jsx(Fr,{placeholder:"如 claude-haiku-4-5-20251001"})}),w.jsx(wn.Item,{label:"CLAUDE_CODE_SUBAGENT_MODEL",name:"subagentModel",extra:"子代理(subagent)使用的模型。",children:w.jsx(Fr,{placeholder:"如 claude-sonnet-4-20250514"})})]}),w.jsx(wn.Item,{children:w.jsx(Hn,{children:w.jsx(nr,{type:"primary",htmlType:"submit",icon:w.jsx(v5,{}),loading:a,children:"保存"})})})]})]}),w.jsxs(io,{style:{marginTop:16},loading:n,children:[w.jsx(Xh,{level:4,children:"Claude Code 初始化"}),w.jsx(f$,{type:"secondary",style:{display:"block",marginBottom:24},children:"写入 ~/.claude.json,控制 Claude Code CLI 首次启动行为。"}),w.jsxs(wn,{form:t,layout:"vertical",onFinish:f,children:[w.jsx(wn.Item,{label:"跳过初次安装确认",name:"skipOnboarding",valuePropName:"checked",extra:"设置 hasCompletedOnboarding = true,跳过首次启动的交互式确认流程。",children:w.jsx(_4,{})}),w.jsx(wn.Item,{children:w.jsx(nr,{type:"primary",htmlType:"submit",icon:w.jsx(v5,{}),loading:i,children:"保存"})})]})]})]})}const{Text:Qh}=ra;function Xqe(){const e=c.useRef(null),t=zi(),n=[{title:"Session ID",dataIndex:"session_id",width:160,search:!1,render:(r,a)=>w.jsx("a",{onClick:o=>{o.preventDefault(),o.stopPropagation(),t(`/sessions/${a.session_id}`)},children:w.jsxs(Qh,{style:{fontFamily:"monospace",fontSize:12},children:[w.jsx(Vy,{style:{color:"#722ed1",marginRight:4}}),a.session_id.slice(0,12),"..."]})})},{title:"角色",dataIndex:"role",width:90,valueType:"select",fieldProps:{options:[{label:"Loid",value:"loid"},{label:"Yor",value:"yor"},{label:"Franky",value:"franky"}]},render:(r,a)=>{const i={loid:{color:"blue",label:"Loid"},yor:{color:"orange",label:"Yor"},franky:{color:"green",label:"Franky"}}[a.role]??{color:"default",label:a.role};return w.jsx(on,{color:i.color,children:i.label})}},{title:"状态",dataIndex:"active",width:90,valueType:"select",fieldProps:{options:[{label:"进行中",value:"true"},{label:"已结束",value:"false"}]},render:(r,a)=>a.ended_at?w.jsx(on,{children:"已结束"}):w.jsx(on,{color:"green",children:"进行中"})},{title:"关联任务",dataIndex:"task_id",width:180,render:(r,a)=>a.task_id?w.jsxs("a",{onClick:o=>{o.preventDefault(),o.stopPropagation(),t(`/tasks?taskId=${a.task_id}`)},children:[w.jsx(eI,{style:{marginRight:4}}),w.jsx(Qh,{style:{fontFamily:"monospace",fontSize:12},children:a.task_id})]}):w.jsx(Qh,{type:"secondary",children:"-"})},{title:"实例 ID",dataIndex:"instance_id",width:160,search:!1,ellipsis:!0,render:(r,a)=>a.instance_id?w.jsx(Qh,{style:{fontFamily:"monospace",fontSize:12},children:a.instance_id}):"-"},{title:"开始时间",dataIndex:"started_at",valueType:"dateTime",width:180,search:!1,sorter:!0,defaultSortOrder:"descend",render:(r,a)=>Wt(a.started_at).format("YYYY-MM-DD HH:mm:ss")},{title:"结束时间",dataIndex:"ended_at",valueType:"dateTime",width:180,search:!1,render:(r,a)=>a.ended_at?Wt(a.ended_at).format("YYYY-MM-DD HH:mm:ss"):"-"}];return w.jsx("div",{children:w.jsx(dl,{actionRef:e,columns:n,rowKey:"id",headerTitle:"会话管理",search:{labelWidth:"auto",defaultCollapsed:!1},pagination:{defaultPageSize:20,showSizeChanger:!0,pageSizeOptions:["10","20","50","100"]},request:async r=>{const a=new URLSearchParams,o=r.pageSize??20,i=r.current??1;a.set("limit",String(o)),a.set("offset",String((i-1)*o)),r.role&&a.set("role",r.role),r.active&&a.set("active",r.active),r.task_id&&a.set("task_id",r.task_id);try{const l=await fetch(`/api/sessions?${a.toString()}`);if(!l.ok)throw new Error("Failed to fetch");const s=await l.json();return{data:s.data,total:s.total,success:!0}}catch{return{data:[],total:0,success:!1}}},onRow:r=>({onClick:()=>{t(`/sessions/${r.session_id}`)},style:{cursor:"pointer"}})})})}const Qqe={route:{path:"/",routes:[{path:"/workspace",name:"工作台",icon:w.jsx(pW,{}),routes:[{path:"/dashboard",name:"仪表盘"},{path:"/projects",name:"项目总览"},{path:"/tasks",name:"任务管理"}]},{path:"/comms",name:"沟通",icon:w.jsx(c0,{}),routes:[{path:"/messages",name:"消息日志"},{path:"/chats",name:"群聊管理"}]},{path:"/observability",name:"可观测",icon:w.jsx(uW,{}),routes:[{path:"/traces",name:"链路追踪"},{path:"/audit",name:"审计日志"},{path:"/sessions-list",name:"会话管理"},{path:"/reports",name:"每日报告"}]},{path:"/admin",name:"管理",icon:w.jsx(hW,{}),routes:[{path:"/team",name:"团队成员"},{path:"/settings",name:"设置"}]}]}};function Zqe(){const e=zi(),t=Al();return w.jsx(KFe,{title:"Anya Gateway",logo:w.jsx(pW,{style:{fontSize:24}}),layout:"mix",fixSiderbar:!0,...Qqe,location:{pathname:t.pathname},menuItemRender:(n,r)=>w.jsx("a",{onClick:a=>{a.preventDefault(),n.path&&e(n.path)},children:r}),children:w.jsxs(NL,{children:[w.jsx(Sa,{path:"/",element:w.jsx(hX,{to:"/dashboard",replace:!0})}),w.jsx(Sa,{path:"/dashboard",element:w.jsx(Z7e,{})}),w.jsx(Sa,{path:"/projects",element:w.jsx(Eze,{})}),w.jsx(Sa,{path:"/projects/:projectId",element:w.jsx(Oze,{})}),w.jsx(Sa,{path:"/tasks",element:w.jsx(hze,{})}),w.jsx(Sa,{path:"/messages",element:w.jsx(uze,{})}),w.jsx(Sa,{path:"/chats",element:w.jsx($ze,{})}),w.jsx(Sa,{path:"/chats/:chatId",element:w.jsx(_ze,{})}),w.jsx(Sa,{path:"/audit",element:w.jsx(bze,{})}),w.jsx(Sa,{path:"/traces",element:w.jsx(pze,{})}),w.jsx(Sa,{path:"/sessions-list",element:w.jsx(Xqe,{})}),w.jsx(Sa,{path:"/reports",element:w.jsx(xze,{})}),w.jsx(Sa,{path:"/team",element:w.jsx(Sze,{})}),w.jsx(Sa,{path:"/settings",element:w.jsx(Yqe,{})})]})})}function Jqe(){return w.jsxs(NL,{children:[w.jsx(Sa,{path:"/sessions/:sessionId",element:w.jsx(Uqe,{})}),w.jsx(Sa,{path:"/*",element:w.jsx(Zqe,{})})]})}xY.createRoot(document.getElementById("root")).render(w.jsx(te.StrictMode,{children:w.jsx(BX,{children:w.jsx(Jqe,{})})}))});export default eUe();
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Anya Gateway Dashboard</title>
7
- <script type="module" crossorigin src="/assets/index-DT5NuALG.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-D1AK5ZEE.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-BiiEB0qZ.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "team-anya-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Team Anya - AI 数字员工系统",
6
6
  "bin": {
@@ -13,6 +13,9 @@ const ALWAYS_OVERWRITE_FILES = [
13
13
  'yor/PROFILE.md',
14
14
  'yor/PLAYBOOK.md',
15
15
  'yor/SELF-HEAL.md',
16
+ 'franky/CLAUDE.md',
17
+ 'franky/PROFILE.md',
18
+ 'franky/PLAYBOOK.md',
16
19
  ];
17
20
  /** 仅当目标不存在时才复制的文件(配置/数据,运行时可能被修改) */
18
21
  const COPY_IF_MISSING_FILES = [
@@ -34,6 +37,7 @@ const REQUIRED_DIRS = [
34
37
  'reports',
35
38
  'yor',
36
39
  'loid',
40
+ 'franky',
37
41
  '.claude',
38
42
  ];
39
43
  async function exists(path) {
@@ -37,4 +37,19 @@ export const DEFAULT_FORBIDDEN_PATHS = [
37
37
  '**/.git/objects/**',
38
38
  '**/.git/refs/**',
39
39
  ];
40
+ /**
41
+ * Franky 专项模式的默认 scope
42
+ * 比 Yor 更宽松:允许 git push 到 feature 分支,允许创建 PR
43
+ * 但仍禁止 push main/master 和 force push
44
+ */
45
+ export const FRANKY_DEFAULT_SCOPE = {
46
+ allowedPaths: ['**'],
47
+ forbiddenPaths: DEFAULT_FORBIDDEN_PATHS,
48
+ allowedCommands: ['**'],
49
+ forbiddenCommands: [
50
+ 'git push\\s+--force',
51
+ 'git push\\b.*--force',
52
+ 'git push\\b.*\\b(main|master)\\b',
53
+ ],
54
+ };
40
55
  //# sourceMappingURL=defaults.js.map
@@ -1,3 +1,3 @@
1
1
  export { ScopeChecker, DEFAULT_SCOPE } from './checker.js';
2
- export { DEFAULT_FORBIDDEN_COMMANDS, DEFAULT_FORBIDDEN_PATHS } from './defaults.js';
2
+ export { DEFAULT_FORBIDDEN_COMMANDS, DEFAULT_FORBIDDEN_PATHS, FRANKY_DEFAULT_SCOPE } from './defaults.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { eq, desc, gte, like, and, sql, count, isNull, isNotNull } from 'drizzle-orm';
2
- import { tasks, taskClarifications, commitments, opportunities, auditEvents, orgMembers, orgOwnership, orgEscalationRules, communicationEvents, messageLog, traceSpans, chats, chatMembers, projects, projectRepos, ccSessions } from './schema/index.js';
2
+ import { tasks, taskClarifications, commitments, opportunities, auditEvents, orgMembers, orgOwnership, orgEscalationRules, communicationEvents, messageLog, traceSpans, chats, chatMembers, projects, projectRepos, ccSessions, topics } from './schema/index.js';
3
3
  export { createDB, createTestDB } from './client.js';
4
4
  export * from './schema/index.js';
5
5
  // ── Task CRUD ──
@@ -621,4 +621,71 @@ export function getAllProjectsWithStats(db, includeDeleted = false) {
621
621
  last_activity_at: tasksByProject[p.project_id]?.last_activity ?? p.updated_at,
622
622
  }));
623
623
  }
624
+ export function upsertTopic(db, input) {
625
+ const now = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
626
+ return db.insert(topics).values({
627
+ id: input.id,
628
+ project_id: input.project_id ?? null,
629
+ title: input.title,
630
+ description: input.description ?? null,
631
+ status: input.status,
632
+ thread_id: input.thread_id ?? null,
633
+ root_message_id: input.root_message_id ?? null,
634
+ chat_id: input.chat_id ?? null,
635
+ workspace_path: input.workspace_path ?? null,
636
+ branch_name: input.branch_name ?? null,
637
+ created_by: input.created_by ?? null,
638
+ created_at: now,
639
+ updated_at: now,
640
+ }).onConflictDoUpdate({
641
+ target: topics.id,
642
+ set: {
643
+ title: input.title,
644
+ description: input.description ?? null,
645
+ status: input.status,
646
+ thread_id: input.thread_id ?? null,
647
+ root_message_id: input.root_message_id ?? null,
648
+ chat_id: input.chat_id ?? null,
649
+ workspace_path: input.workspace_path ?? null,
650
+ branch_name: input.branch_name ?? null,
651
+ updated_at: now,
652
+ },
653
+ }).run();
654
+ }
655
+ export function getTopic(db, id) {
656
+ return db.select().from(topics).where(eq(topics.id, id)).get();
657
+ }
658
+ export function getTopicByThreadId(db, threadId) {
659
+ return db.select().from(topics)
660
+ .where(and(eq(topics.thread_id, threadId), eq(topics.status, 'active')))
661
+ .get();
662
+ }
663
+ export function updateTopicStatus(db, id, status) {
664
+ const now = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
665
+ return db.update(topics).set({
666
+ status,
667
+ updated_at: now,
668
+ ...(status === 'closed' ? { closed_at: now } : {}),
669
+ }).where(eq(topics.id, id)).run();
670
+ }
671
+ export function getActiveTopics(db) {
672
+ return db.select().from(topics).where(eq(topics.status, 'active')).all();
673
+ }
674
+ export function getTodayMaxTopicSequence(db) {
675
+ const today = new Date().toISOString().slice(0, 10).replace(/-/g, '');
676
+ const prefix = `TOPIC-${today}-`;
677
+ const rows = db.select().from(topics).where(like(topics.id, `${prefix}%`)).all();
678
+ let max = 0;
679
+ for (const topic of rows) {
680
+ const seq = parseInt(topic.id.split('-')[2], 10);
681
+ if (seq > max)
682
+ max = seq;
683
+ }
684
+ return max;
685
+ }
686
+ export function generateTopicId(db) {
687
+ const today = new Date().toISOString().slice(0, 10).replace(/-/g, '');
688
+ const max = getTodayMaxTopicSequence(db);
689
+ return `TOPIC-${today}-${String(max + 1).padStart(3, '0')}`;
690
+ }
624
691
  //# sourceMappingURL=index.js.map
@@ -9,4 +9,5 @@ export * from './chats.js';
9
9
  export * from './trace-spans.js';
10
10
  export * from './projects.js';
11
11
  export * from './cc-sessions.js';
12
+ export * from './topics.js';
12
13
  //# sourceMappingURL=index.js.map
@@ -29,6 +29,8 @@ export const tasks = sqliteTable('tasks', {
29
29
  cc_session_id: text('cc_session_id'),
30
30
  // 文件路径
31
31
  workspace_path: text('workspace_path'),
32
+ // 专项关联(可选,用于回溯关联)
33
+ topic_id: text('topic_id'),
32
34
  // 时间戳
33
35
  created_at: text('created_at').notNull().default(sql `(strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))`),
34
36
  updated_at: text('updated_at').notNull().default(sql `(strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))`),
@@ -0,0 +1,20 @@
1
+ import { sqliteTable, text } from 'drizzle-orm/sqlite-core';
2
+ import { sql } from 'drizzle-orm';
3
+ import { projects } from './projects.js';
4
+ export const topics = sqliteTable('topics', {
5
+ id: text('id').primaryKey(),
6
+ project_id: text('project_id').references(() => projects.project_id),
7
+ title: text('title').notNull(),
8
+ description: text('description'),
9
+ status: text('status').notNull().default('active'),
10
+ thread_id: text('thread_id'),
11
+ root_message_id: text('root_message_id'),
12
+ chat_id: text('chat_id'),
13
+ workspace_path: text('workspace_path'),
14
+ branch_name: text('branch_name'),
15
+ created_by: text('created_by'),
16
+ created_at: text('created_at').notNull().default(sql `(strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))`),
17
+ updated_at: text('updated_at').notNull().default(sql `(strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))`),
18
+ closed_at: text('closed_at'),
19
+ });
20
+ //# sourceMappingURL=topics.js.map
@@ -0,0 +1,21 @@
1
+ CREATE TABLE `topics` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `project_id` text REFERENCES `projects`(`project_id`),
4
+ `title` text NOT NULL,
5
+ `description` text,
6
+ `status` text NOT NULL DEFAULT 'active',
7
+ `thread_id` text,
8
+ `chat_id` text,
9
+ `workspace_path` text,
10
+ `branch_name` text,
11
+ `created_by` text,
12
+ `created_at` text NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
13
+ `updated_at` text NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
14
+ `closed_at` text
15
+ );
16
+ --> statement-breakpoint
17
+ CREATE INDEX `idx_topics_thread_id` ON `topics` (`thread_id`);
18
+ --> statement-breakpoint
19
+ CREATE INDEX `idx_topics_status` ON `topics` (`status`);
20
+ --> statement-breakpoint
21
+ ALTER TABLE `tasks` ADD COLUMN `topic_id` text REFERENCES `topics`(`id`);
@@ -0,0 +1 @@
1
+ ALTER TABLE `topics` ADD `root_message_id` text;