@kafca/agentdock 0.1.14 → 0.1.16
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.
- package/bin/agentdock.mjs +73 -3
- package/dist/renderer/assets/Badge-O6YyBOXO.js +1 -0
- package/dist/renderer/assets/Chat-Bb42Xu99.js +2 -0
- package/dist/renderer/assets/ChatMarkdown-CKIl8nVw.js +45 -0
- package/dist/renderer/assets/Config-U1HHZNv-.js +16 -0
- package/dist/renderer/assets/CronList-Qfok-TFN.js +1 -0
- package/dist/renderer/assets/Dashboard-DIxtJDEV.js +26 -0
- package/dist/renderer/assets/EmptyState-Ce5baC0x.js +6 -0
- package/dist/renderer/assets/KnowledgeDetail-DKjqGzjI.js +16 -0
- package/dist/renderer/assets/KnowledgeHome-CsYBKv3L.js +11 -0
- package/dist/renderer/assets/Logs-BV93l6f2.js +1 -0
- package/dist/renderer/assets/Modal-JbmTZbCL.js +10 -0
- package/dist/renderer/assets/Page-854R0NMM.js +1 -0
- package/dist/renderer/assets/ProjectDetail-Ct7yASjV.js +11 -0
- package/dist/renderer/assets/ProjectList-mJJeoUcP.js +1 -0
- package/dist/renderer/assets/SessionChat-CClPXCjv.js +1 -0
- package/dist/renderer/assets/SessionList-Cxilghws.js +1 -0
- package/dist/renderer/assets/ThreadChat-BUFr0IbT.js +23 -0
- package/dist/renderer/assets/Workspace-B_sQxTj-.js +14 -0
- package/dist/renderer/assets/arrow-left-mguKZKTu.js +6 -0
- package/dist/renderer/assets/book-open-3Awj2zba.js +6 -0
- package/dist/renderer/assets/circle-BWSc4-qr.js +6 -0
- package/dist/renderer/assets/desktop-D4Z7M9RM.js +3 -0
- package/dist/renderer/assets/funnel-DE2QCcoy.js +6 -0
- package/dist/renderer/assets/heart-B6xi7jGt.js +6 -0
- package/dist/renderer/assets/index-B2JL40NF.js +232 -0
- package/dist/renderer/assets/index-CJZeKEpW.css +11 -0
- package/dist/renderer/assets/pencil-BD6oAfUg.js +6 -0
- package/dist/renderer/assets/play-C9Ue_X4n.js +6 -0
- package/dist/renderer/assets/plug-CIaRVhae.js +6 -0
- package/dist/renderer/assets/plus-BWHFEPZn.js +6 -0
- package/dist/renderer/assets/projects-DCdaAlgs.js +1 -0
- package/dist/renderer/assets/save-DsSaJ2pw.js +6 -0
- package/dist/renderer/assets/search-Ci4i20HH.js +6 -0
- package/dist/renderer/assets/server-07G4ybtv.js +11 -0
- package/dist/renderer/assets/session-utils-D9njomRn.js +6 -0
- package/dist/renderer/assets/sessions-C4c2fLQB.js +1 -0
- package/dist/renderer/assets/shield-check-DjJz3hYk.js +6 -0
- package/dist/renderer/assets/trash-2-C5_ZLIsu.js +6 -0
- package/dist/renderer/assets/user-DHBITt1w.js +11 -0
- package/dist/renderer/assets/wifi-off-DuwKaMRJ.js +11 -0
- package/dist/renderer/index.html +2 -2
- package/dist-electron/electron/agent-runtime-detector.test.js +121 -0
- package/dist-electron/electron/lac-cli.test.js +63 -0
- package/dist-electron/electron/local-core-refactor.test.js +54 -0
- package/dist-electron/electron/plugin-kernel.test.js +6 -6
- package/dist-electron/electron/runtime-detection-service.test.js +116 -0
- package/dist-electron/electron/security-approval-store.test.js +89 -0
- package/dist-electron/electron/workspace-task-store.test.js +66 -0
- package/dist-electron/packages/core-sdk/src/index.js +124 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-backend.js +68 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-store.js +617 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-turn-coordinator.js +11 -0
- package/dist-electron/services/local-ai-core/src/cli/lac.js +19 -12
- package/dist-electron/services/local-ai-core/src/kernel/bootstrap.js +5 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/scheduler-local-plugin.js +35 -0
- package/dist-electron/services/local-ai-core/src/router/workspace-router.js +197 -0
- package/dist-electron/services/local-ai-core/src/runtime/agent-runtime-detector.js +237 -0
- package/dist-electron/services/local-ai-core/src/runtime/local-core-controller.js +72 -0
- package/dist-electron/services/local-ai-core/src/runtime/runtime-detection-service.js +138 -0
- package/dist-electron/services/local-ai-core/src/runtime/runtime-detection-store.js +46 -0
- package/dist-electron/services/local-ai-core/src/runtime/server.js +151 -0
- package/dist-electron/services/local-ai-core/src/scheduler/local-schedule-adapter.js +61 -0
- package/dist-electron/services/local-ai-core/src/security/command-risk.js +57 -0
- package/package.json +1 -1
- package/dist/renderer/assets/index-BM0Jl5gB.js +0 -487
- package/dist/renderer/assets/index-DrLbJPYN.css +0 -11
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{c as m,u as R,r as n,m as P,a6 as M,j as e,B as c,R as U,L as z,I as K,a7 as L,a8 as B,a9 as I}from"./index-B2JL40NF.js";import{B as _}from"./Badge-O6YyBOXO.js";import{P as A,S as d,a as H}from"./Page-854R0NMM.js";import{S as D}from"./save-DsSaJ2pw.js";import{P as $}from"./plug-CIaRVhae.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const q=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],E=m("file-code",q);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const F=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],T=m("rotate-ccw",F);/**
|
|
12
|
+
* @license lucide-react v0.487.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const V=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],X=m("scroll-text",V);function G(a){return a==="api_ready"?"success":a==="error"?"danger":a==="starting"?"warning":"neutral"}function Z(){const{t:a}=R(),[s,u]=n.useState(null),[l,j]=n.useState(null),[g,h]=n.useState(""),[k,x]=n.useState(""),[w,f]=n.useState(!0),[p,y]=n.useState(!1),[v,i]=n.useState(""),r=n.useCallback(async()=>{f(!0);try{const[t,o]=await Promise.allSettled([P(),M()]);t.status==="fulfilled"&&(u(t.value),h(t.value.settings.knowledge.baseUrl||""),x(t.value.settings.knowledge.baseUrl||"")),o.status==="fulfilled"&&j(o.value)}finally{f(!1)}},[]);n.useEffect(()=>{r()},[r]);const N=async()=>{if(confirm(a("system.restartConfirm")))try{await L(),i(a("common.success")),await r()}catch(t){i(t.message)}},b=async()=>{if(confirm(a("system.reloadConfirm")))try{await B(),i(a("common.success")),await r()}catch(t){i(t.message)}},S=async()=>{y(!0);try{const t=await I({knowledge:{baseUrl:g,authMode:(s==null?void 0:s.settings.knowledge.authMode)||"none",token:(s==null?void 0:s.settings.knowledge.token)||"",headerName:(s==null?void 0:s.settings.knowledge.headerName)||"X-API-Key",defaultCollection:(s==null?void 0:s.settings.knowledge.defaultCollection)||"personal_knowledge"}});u(o=>o&&{...o,settings:t}),x(t.knowledge.baseUrl||""),i(a("common.success"))}catch(t){i(t.message)}finally{y(!1)}},C=g!==k;return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(A,{title:a("nav.system"),description:"Runtime health, logs, and plugin diagnostics. Advanced config is available read-only from the diagnostics drawer.",actions:e.jsxs(e.Fragment,{children:[e.jsxs(c,{variant:"secondary",onClick:b,children:[e.jsx(U,{size:16})," ",a("system.reload")]}),e.jsxs(c,{variant:"danger",onClick:N,children:[e.jsx(T,{size:16})," ",a("system.restart")]}),e.jsx(z,{to:"/system/logs",children:e.jsxs(c,{variant:"secondary",children:[e.jsx(X,{size:16})," ",a("system.logs")]})})]})}),v?e.jsx("div",{role:"status",className:"rounded-lg border border-primary/20 bg-primary/10 px-4 py-3 text-sm text-primary",children:v}):null,e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-3",children:[e.jsxs(d,{title:"Runtime",description:w?"Loading...":"Local service status.",children:[e.jsx(H,{tone:G(s==null?void 0:s.phase),children:(s==null?void 0:s.phase)||"unknown"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:s!=null&&s.pendingRestart?"Restart required to apply saved changes.":"No pending restart."})]}),e.jsx(d,{title:"Config",description:"Active config file location.",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(E,{size:18,className:"mt-0.5 text-primary"}),e.jsx("p",{className:"break-all font-mono text-xs leading-5 text-muted-foreground",children:(s==null?void 0:s.settings.configPath)||(s==null?void 0:s.configFile.path)||"-"})]})}),e.jsxs(d,{title:"Plugins",description:"Health summary only.",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:l?`${l.enabledPluginCount}/${l.pluginCount}`:"-"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"enabled plugins"})]})]}),e.jsx(d,{title:"Knowledge",description:"System-wide knowledge API connection.",actions:e.jsxs(c,{size:"sm",onClick:()=>void S(),loading:p,disabled:!C&&!p,children:[e.jsx(D,{size:14})," Save"]}),children:e.jsx(K,{label:"Knowledge base URL",value:g,onChange:t=>h(t.target.value),placeholder:"http://127.0.0.1:16007"})}),e.jsx(d,{title:a("system.plugins"),description:"Plugin state is read-only in the daily UI. Use backend config for advanced changes.",children:l?l.plugins.length===0?e.jsx("div",{className:"py-8 text-sm text-muted-foreground",children:"No plugins registered."}):e.jsx("div",{className:"divide-y divide-border",children:l.plugins.map(t=>e.jsxs("div",{className:"flex items-start justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{size:15,className:"text-muted-foreground"}),e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.pluginId})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t.health.summary||t.manifest.provides.join(", ")||"No declared capabilities"})]}),e.jsx(_,{variant:t.health.status==="healthy"?"success":t.health.status==="failed"?"danger":"warning",children:t.health.status})]},t.pluginId))}):e.jsx("div",{className:"py-8 text-sm text-muted-foreground",children:"Loading..."})})]})}export{Z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a0 as R,l as b,a1 as z,a2 as D,a3 as W,a4 as O,u as B,r as n,j as t,a5 as F,B as c,_ as L,C as U,Y as k,O as w,I as f,T as _}from"./index-B2JL40NF.js";import{B as u}from"./Badge-O6YyBOXO.js";import{M as H}from"./Modal-JbmTZbCL.js";import{E as Y}from"./EmptyState-Ce5baC0x.js";import{P as q}from"./Page-854R0NMM.js";import{P as G}from"./plus-BWHFEPZn.js";import{P as K}from"./play-C9Ue_X4n.js";import{P as Q}from"./pencil-BD6oAfUg.js";import{T as V}from"./trash-2-C5_ZLIsu.js";const X=a=>R(),Z=a=>D(a),$=(a,d)=>z(a,d),ee=a=>W(a),te=a=>O(a),ae=()=>b().then(a=>a.workspaces),x={workspaceId:"",executionMode:"same-thread",triggerType:"cron",cronExpr:"0 9 * * *",runAt:"",promptTemplate:"",description:"",chatId:"",platformUserId:"",threadId:"",enabled:!0};function se(a){return a?{workspaceId:a.workspaceId,executionMode:a.executionMode,triggerType:a.triggerType,cronExpr:a.cronExpr||"0 9 * * *",runAt:a.runAt?String(a.runAt).slice(0,16):"",promptTemplate:a.promptTemplate,description:a.description,chatId:a.route.channelId,platformUserId:a.route.participantId||"",threadId:a.route.threadId||"",enabled:a.enabled}:x}function re(a){return{workspaceId:a.workspaceId,platform:"local",route:{type:"local.thread",channelId:a.workspaceId||"local",...a.threadId?{threadId:a.threadId}:{}},executionMode:a.executionMode||"same-thread",triggerType:a.triggerType,...a.triggerType==="cron"?{cronExpr:a.cronExpr,runAt:void 0}:{runAt:new Date(a.runAt).toISOString(),cronExpr:void 0},promptTemplate:a.promptTemplate,description:a.description,enabled:a.enabled}}function he(){const{t:a}=B(),[d,I]=n.useState([]),[h,T]=n.useState([]),[C,y]=n.useState(!0),[S,o]=n.useState(!1),[j,v]=n.useState(!1),[p,m]=n.useState(null),[s,r]=n.useState(x),E=n.useMemo(()=>h.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id)),[h]),i=n.useCallback(async()=>{y(!0);try{const[e,l]=await Promise.all([X(),ae()]);I(e.jobs||[]),T(l),r(g=>g.workspaceId||l.length===0?g:{...g,workspaceId:l[0].id})}finally{y(!1)}},[]);n.useEffect(()=>{i();const e=F(l=>{(l.type==="scheduler.job.updated"||l.type==="scheduler.run.updated")&&i()});return()=>e()},[i]);const J=()=>{var e;m(null),r({...x,workspaceId:((e=h[0])==null?void 0:e.id)||""}),o(!0)},N=e=>{m(e),r(se(e)),o(!0)},A=async()=>{if(!(!s.workspaceId||!s.promptTemplate.trim())&&!(s.triggerType==="once"&&!s.runAt)){v(!0);try{const e=re(s);p?await $(p.id,e):await Z(e),o(!1),m(null),r(x),await i()}finally{v(!1)}}},M=async e=>{confirm(a("common.confirmDelete"))&&(await ee(e),await i())},P=async e=>{await te(e),await i()};return C&&d.length===0?t.jsx("div",{className:"flex items-center justify-center h-64 text-gray-400 animate-pulse",children:a("common.loading")}):t.jsxs("div",{className:"space-y-4 animate-fade-in",children:[t.jsx(q,{title:a("cron.title"),description:"Create simple scheduled prompts for a workspace.",actions:t.jsxs(c,{onClick:J,children:[t.jsx(G,{size:16})," ",a("cron.add")]})}),d.length===0?t.jsx(Y,{message:a("cron.noJobs"),icon:L}):t.jsx("div",{className:"space-y-3",children:d.map(e=>t.jsx(U,{children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white text-sm",children:e.description||e.id}),t.jsx(u,{variant:e.enabled?"success":"default",children:e.enabled?a("cron.enabled"):"disabled"}),t.jsx(u,{variant:"default",children:e.triggerType}),t.jsx(u,{variant:"default",children:e.platform}),e.lastStatus&&t.jsx(u,{variant:e.lastStatus==="failed"?"danger":"default",children:e.lastStatus})]}),t.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-500 dark:text-gray-400 mt-2",children:[t.jsxs("span",{children:[t.jsx("strong",{children:"Workspace:"})," ",e.workspaceId]}),t.jsxs("span",{children:[t.jsx("strong",{children:"Execution:"})," ",e.executionMode]}),t.jsxs("span",{children:[t.jsx("strong",{children:"Route:"})," ",e.route.channelId," / ",e.route.participantId]}),t.jsxs("span",{children:[t.jsxs("strong",{children:[e.triggerType==="cron"?a("cron.expression"):"Run at",":"]})," ",e.triggerType==="cron"?e.cronExpr:k(e.runAt||"")]}),e.route.threadId&&t.jsxs("span",{children:[t.jsx("strong",{children:"Thread:"})," ",e.route.threadId]}),e.lastRunAt&&t.jsxs("span",{children:[t.jsxs("strong",{children:[a("cron.lastRun"),":"]})," ",k(e.lastRunAt)]})]}),t.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mt-2 whitespace-pre-wrap",children:e.promptTemplate}),e.lastError&&t.jsx("p",{className:"text-xs text-red-500 mt-2",children:e.lastError})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c,{size:"sm",variant:"secondary",onClick:()=>void P(e.id),children:t.jsx(K,{size:14})}),t.jsx(c,{size:"sm",variant:"secondary",onClick:()=>N(e),children:t.jsx(Q,{size:14})}),t.jsx(c,{size:"sm",variant:"danger",onClick:()=>void M(e.id),children:t.jsx(V,{size:14})})]})]})},e.id))}),t.jsx(H,{open:S,onClose:()=>o(!1),title:p?"Edit scheduler job":a("cron.add"),children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs(w,{label:"Workspace",value:s.workspaceId,onChange:e=>r({...s,workspaceId:e.target.value}),children:[t.jsx("option",{value:"",children:"Select workspace"}),E]}),t.jsxs(w,{label:"Schedule type",value:s.triggerType,onChange:e=>r({...s,triggerType:e.target.value}),children:[t.jsx("option",{value:"cron",children:"Repeating"}),t.jsx("option",{value:"once",children:"One time"})]}),s.triggerType==="cron"?t.jsx(f,{label:a("cron.expression"),value:s.cronExpr,onChange:e=>r({...s,cronExpr:e.target.value}),placeholder:"0 9 * * *"}):t.jsx(f,{label:"Run at",type:"datetime-local",value:s.runAt,onChange:e=>r({...s,runAt:e.target.value})}),t.jsx(f,{label:a("cron.description"),value:s.description,onChange:e=>r({...s,description:e.target.value})}),t.jsx(_,{label:a("cron.prompt"),value:s.promptTemplate,onChange:e=>r({...s,promptTemplate:e.target.value}),rows:4,placeholder:"Summarize today's blockers and post a status update."}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[t.jsx("input",{type:"checkbox",checked:s.enabled,onChange:e=>r({...s,enabled:e.target.checked})}),a("cron.enabled")]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(c,{variant:"secondary",onClick:()=>o(!1),children:a("common.cancel")}),t.jsx(c,{onClick:()=>void A(),disabled:j,children:a(p?"common.save":"cron.add")})]})]})})]})}export{he as default};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{c as j,u as te,r,a as ae,l as re,b as ie,d as w,e as ne,f as de,g as le,o as ce,h as oe,j as e,M as me,W as xe,F as W,C as g,B as he,R as ue,i as pe,L as A,S as ge}from"./index-B2JL40NF.js";import{B as n}from"./Badge-O6YyBOXO.js";import{E as f}from"./EmptyState-Ce5baC0x.js";import{P as fe}from"./Page-854R0NMM.js";import{l as je}from"./projects-DCdaAlgs.js";import{S as be,A as H}from"./server-07G4ybtv.js";import{B as ke}from"./book-open-3Awj2zba.js";import{S as U}from"./shield-check-DjJz3hYk.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ve=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ye=j("activity",ve);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Ne=[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],we=j("calendar-clock",Ne);/**
|
|
12
|
+
* @license lucide-react v0.487.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Re=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ae=j("circle-check",Re);/**
|
|
17
|
+
* @license lucide-react v0.487.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Se=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],F=j("cpu",Se);/**
|
|
22
|
+
* @license lucide-react v0.487.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const _e=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Me=j("list-checks",_e);function Le({title:a,description:t,to:o,icon:h,primary:d}){return e.jsxs(A,{to:o,className:["group flex min-h-[118px] flex-col justify-between rounded-2xl p-5 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring",d?"bg-black/[0.07] text-foreground hover:bg-black/[0.09] dark:bg-white/[0.10] dark:hover:bg-white/[0.13]":"bg-white/54 text-foreground hover:bg-white/72 dark:bg-white/[0.055] dark:hover:bg-white/[0.085]"].join(" "),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white/70 text-primary shadow-[0_1px_1px_rgba(0,0,0,0.04)] dark:bg-white/[0.08]",children:e.jsx(h,{size:20})}),e.jsx(H,{size:17,className:"mt-1 text-muted-foreground/45 transition-colors group-hover:text-foreground"})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-2 max-w-sm text-sm leading-5 text-muted-foreground",children:t})]})]})}function R({title:a,description:t,tasks:o,empty:h,urgent:d}){return e.jsxs(g,{className:"overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]}),e.jsx(n,{variant:d&&o.length>0?"warning":"secondary",children:o.length})]})}),o.length===0?e.jsx("div",{className:"p-5",children:e.jsx(f,{message:h,icon:Me})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:o.map(l=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:l.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[l.workspaceId," · ",l.runtimeId]})]}),e.jsx(n,{variant:l.status==="failed"?"danger":l.status==="completed"?"success":"info",children:l.status})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",new Date(l.updatedAt).toLocaleString()]})]},l.taskId))})]})}function ze({approvals:a}){return e.jsxs(g,{className:"overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"待审批"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"高风险操作会在这里等待确认或拒绝。"})]}),e.jsx(n,{variant:a.length>0?"warning":"secondary",children:a.length})]})}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(f,{message:"暂无待审批操作",icon:U})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.workspaceId," · ",t.kind]})]}),e.jsx(n,{variant:t.riskLevel==="high"?"danger":"warning",children:t.riskLevel})]}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs leading-5 text-muted-foreground",children:t.description})]},t.approvalId))})]})}function Ce({events:a}){return e.jsxs(g,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"审计记录"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"最近的任务、审批和权限事件。"})]}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(f,{message:"暂无审计记录",icon:U})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.summary}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.type," · ",t.actor||"system"]})]}),t.riskLevel?e.jsx(n,{variant:t.riskLevel==="high"?"danger":"secondary",children:t.riskLevel}):null]}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleString()})]},t.auditId))})]})}function We(){const{t:a}=te(),[t,o]=r.useState([]),[h,d]=r.useState([]),[l,S]=r.useState([]),[V,_]=r.useState([]),[K,M]=r.useState([]),[O,L]=r.useState([]),[Q,z]=r.useState([]),[G,C]=r.useState(!0),[J,D]=r.useState(!1),[X,u]=r.useState(!1),[E,T]=r.useState(""),[P,p]=r.useState(""),{desktopRuntime:c,desktopWorkspace:I,knowledgeModule:q,schedulerModule:$}=ae(),B=h.filter(s=>s.installed),b=[{title:"继续聊天",description:"打开本地对话,继续当前项目里的 agent 线程。",to:"/chat",icon:me,primary:!0},{title:"工作区",description:"管理项目、平台、模型和本地运行配置。",to:I?"/workspace":"/projects",icon:I?xe:W}];q&&b.push({title:"知识库",description:"上传文档,维护可被检索的项目资料。",to:"/knowledge",icon:ke}),$&&b.push({title:"定时任务",description:"查看和管理自动执行的计划任务。",to:"/cron",icon:we}),(!q||!$)&&b.push({title:"系统设置",description:"查看配置、日志和桌面应用偏好。",to:"/system",icon:ge});const k=r.useCallback(async()=>{var s;C(!0),T(""),p("");try{if(c){const[y,i]=await Promise.all([re(),ie().then(x=>({status:"fulfilled",runtimes:x}),x=>({status:"rejected",error:x}))]),[N,v,Z]=await Promise.all([w({status:["created","queued","running"],limit:6}),w({status:"waiting_for_user",limit:6}),w({status:["completed","failed","cancelled"],limit:6})]),[ee,se]=await Promise.all([ne({status:"pending",limit:6}),de({limit:6})]);S(N.tasks||[]),_(v.tasks||[]),M(Z.tasks||[]),L(ee.approvals||[]),z(se.events||[]),o((y.workspaces||[]).map(x=>({name:x.name,agent_type:x.agentType,platforms:x.platforms,sessions_count:x.sessionsCount,heartbeat_enabled:x.heartbeatEnabled}))),i.status==="fulfilled"?d(i.runtimes):(d([]),p(((s=i.error)==null?void 0:s.message)||String(i.error)));return}const m=await je();o(m.projects||[]),d([]),S([]),_([]),M([]),L([]),z([])}catch(m){T(m.message||String(m))}finally{C(!1)}},[c]),Y=r.useCallback(async()=>{D(!0),u(!0),p("");try{d(await le())}catch(s){p(s.message||String(s))}finally{D(!1),u(!1)}},[]);return r.useEffect(()=>{k();const s=()=>k();window.addEventListener("cc:refresh",s);const m=c?ce(()=>{k()}):()=>{},y=c?oe(i=>{if(i.type==="runtime.detect.started"){u(!0);return}if(i.type==="runtime.detect.completed"){u(!1),d(i.runtimes);return}if(i.type==="runtime.detect.failed"){u(!1),p(i.error);return}i.type==="runtime.status.changed"&&d(N=>N.map(v=>v.runtimeId===i.runtime.runtimeId?i.runtime:v))}):()=>{};return()=>{window.removeEventListener("cc:refresh",s),m(),y()}},[c,k]),G&&t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:e.jsx(ye,{className:"animate-pulse",size:24})}):e.jsxs("div",{className:"animate-fade-in space-y-8",children:[e.jsx(fe,{title:"概览",description:"继续最近的工作,或进入项目、知识和自动化配置。当前版本 v0.1.16"}),E?e.jsx("div",{role:"alert",className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-700 dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-200",children:E}):null,e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-end justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:"快速开始"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"常用入口会保留在最前面。"})]})}),e.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:b.map(s=>e.jsx(Le,{...s},s.to))})]}),c?e.jsxs(g,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"本机 Agent Runtime"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"显示本机 runtime 安装检测状态,不执行安装或登录检查。"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:B.length>0?"success":"default",children:[B.length," installed"]}),X?e.jsx(n,{variant:"info",children:"checking"}):null,e.jsxs(he,{variant:"outline",size:"sm",loading:J,onClick:Y,title:"刷新 runtime 检测",children:[e.jsx(ue,{size:15}),"刷新"]})]})]}),P?e.jsxs("div",{className:"px-5 py-4 text-sm text-amber-700 dark:text-amber-200",children:["检测失败:",P]}):h.length===0?e.jsx("div",{className:"p-5",children:e.jsx(f,{message:"还没有 runtime 检测结果",icon:F})}):e.jsx("div",{className:"grid grid-cols-1 gap-3 p-5 md:grid-cols-2 xl:grid-cols-3",children:h.map(s=>e.jsxs("div",{className:"rounded-2xl border border-black/[0.08] bg-white/50 p-4 shadow-[0_8px_24px_rgba(15,23,42,0.05)] dark:border-white/[0.08] dark:bg-white/[0.055]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:["flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",s.status==="installed"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-300":s.status==="error"?"bg-red-500/10 text-red-600 dark:text-red-200":"bg-amber-500/10 text-amber-700 dark:text-amber-200"].join(" "),children:e.jsx(F,{size:19})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:s.displayName}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:s.agentType})]})]}),s.status==="installed"?e.jsx(Ae,{size:18,className:"mt-0.5 shrink-0 text-emerald-500"}):e.jsx(pe,{size:18,className:"mt-0.5 shrink-0 text-amber-500"})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(n,{variant:s.status==="installed"?"success":s.status==="error"?"danger":"warning",children:s.status}),e.jsx(n,{children:s.source}),s.version?e.jsxs(n,{variant:"secondary",children:["v",s.version]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-5 text-muted-foreground",children:s.summary}),s.issues[0]?e.jsx("p",{className:"mt-2 text-xs leading-5 text-amber-700 dark:text-amber-200",children:s.issues[0].message}):null,s.binaryPath||s.command?e.jsx("p",{className:"mt-3 truncate rounded-lg bg-black/[0.045] px-2.5 py-2 font-mono text-xs text-muted-foreground dark:bg-white/[0.06]",children:s.binaryPath||s.command}):null,s.recommendedActions[0]?e.jsx("p",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:s.recommendedActions[0].description}):null,e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["Last checked ",new Date(s.detectedAt).toLocaleString()]})]},s.agentType))})]}):null,c?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-3",children:[e.jsx(R,{title:"运行中任务",description:"正在排队或执行的 agent 工作。",tasks:l,empty:"暂无运行中的任务"}),e.jsx(R,{title:"等待处理",description:"需要用户输入或审批的任务。",tasks:V,empty:"暂无等待处理的任务",urgent:!0}),e.jsx(R,{title:"最近完成",description:"最近结束、失败或取消的任务。",tasks:K,empty:"暂无最近任务"})]}):null,c?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[e.jsx(ze,{approvals:O}),e.jsx(Ce,{events:Q})]}):null,e.jsxs(g,{className:"p-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a("nav.projects")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"最近配置和会话概览。"})]}),e.jsx(A,{to:c?"/workspace":"/projects",className:"text-sm font-medium text-primary transition-colors hover:text-primary/80",children:a("common.viewAll")})]}),t.length===0?e.jsx("div",{className:"p-5",children:e.jsx(f,{message:a("projects.noProjects"),icon:W})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:t.slice(0,6).map(s=>{var m;return e.jsxs(A,{to:c?`/workspace?project=${encodeURIComponent(s.name)}`:`/projects/${s.name}`,className:"group flex items-center justify-between gap-3 px-5 py-4 transition-colors duration-200 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(be,{size:17})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:s.name}),e.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[s.agent_type," · ",((m=s.platforms)==null?void 0:m.join(", "))||"no platform"," · ",s.sessions_count," sessions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.heartbeat_enabled?e.jsx(n,{variant:"success",children:"heartbeat"}):null,e.jsx(H,{size:16,className:"text-muted-foreground/45 transition-colors group-hover:text-foreground"})]})]},s.name)})})]})]})}export{We as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as s,j as e}from"./index-B2JL40NF.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const r=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],c=s("inbox",r);function a({message:t,icon:o=c}){return e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card/70 py-12 text-muted-foreground",children:[e.jsx(o,{size:36,strokeWidth:1.5,className:"mb-3 opacity-80"}),e.jsx("p",{className:"text-sm",children:t})]})}export{a as E};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{c as y,X as R,r as t,ab as C,aA as q,ac as P,aB as U,aC as O,aD as V,aE as Z,j as e,L as _,B as p,S as G,C as x,H as Q,Y as F,I as X}from"./index-B2JL40NF.js";import{E}from"./EmptyState-Ce5baC0x.js";import{A as Y}from"./arrow-left-mguKZKTu.js";import{S as J}from"./search-Ci4i20HH.js";import{T as W}from"./trash-2-C5_ZLIsu.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ee=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]],se=y("file-search",ee);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ae=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],te=y("folder-tree",ae);/**
|
|
12
|
+
* @license lucide-react v0.487.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const re=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],B=y("upload",re);function K(a){return a==="success"?"border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-900/30 dark:bg-violet-950/20 dark:text-violet-300":a==="warning"?"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/30 dark:bg-amber-950/20 dark:text-amber-300":"border-red-200 bg-red-50 text-red-700 dark:border-red-900/30 dark:bg-red-950/20 dark:text-red-300"}function oe(){const{knowledgebaseId:a=""}=R(),[f,u]=t.useState(!0),[j,b]=t.useState(!1),[I,k]=t.useState(!1),[m,A]=t.useState(!1),[r,M]=t.useState(null),[N,D]=t.useState([]),[g,z]=t.useState([]),[w,v]=t.useState([]),[n,T]=t.useState(""),[h,c]=t.useState(null),o=t.useCallback(async()=>{if(a){u(!0);try{const[s,d,l,L]=await Promise.all([C(),q(a),P(),U(a).catch(()=>({files:[]}))]);A(!!s.baseUrl),M(d),D(l.folders||[]),z(L.files||[])}catch(s){c({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{u(!1)}}},[a]);t.useEffect(()=>{o()},[o]);const i=t.useMemo(()=>N.find(s=>s.id===(r==null?void 0:r.folderId))||null,[r==null?void 0:r.folderId,N]),$=t.useCallback(async s=>{const d=Array.from(s.target.files||[]);if(!(!a||d.length===0)){b(!0);try{const l=await C();await O(a,{files:d,collection:l.defaultCollection,folder:i==null?void 0:i.path}),c({tone:"success",message:"Files uploaded and indexed."}),await o(),s.target.value=""}catch(l){c({tone:"error",message:l instanceof Error?l.message:String(l)})}finally{b(!1)}}},[i==null?void 0:i.path,a,o]),H=t.useCallback(async s=>{if(!(!a||!window.confirm(`Delete file "${s.fileName}"?`)))try{await V(a,s.fileId),c({tone:"success",message:"File deleted."}),await o()}catch(d){c({tone:"error",message:d instanceof Error?d.message:String(d)})}},[a,o]),S=t.useCallback(async()=>{if(!a||!n.trim()){v([]);return}k(!0);try{const s=await Z(a,{query:n.trim(),limit:8});v(s.results||[])}catch(s){c({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{k(!1)}},[a,n]);return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(_,{to:"/knowledge",children:e.jsxs(p,{variant:"secondary",children:[e.jsx(Y,{size:14})," 返回知识库"]})}),r&&e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"text-gray-900 dark:text-white",children:r.name}),i?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2",children:"/"}),e.jsx("span",{children:i.path})]}):null]})]}),h&&e.jsx("div",{className:`rounded-xl border px-4 py-3 text-sm ${K(h.tone)}`,children:h.message}),!m&&!f&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${K("warning")}`,children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Knowledge retrieval is not configured."}),e.jsx("p",{className:"mt-1 text-sm opacity-90",children:"Add the ai_vector connection in System settings to upload files and search this knowledge base."})]}),e.jsx(_,{to:"/system",children:e.jsxs(p,{variant:"secondary",children:[e.jsx(G,{size:14})," Open System Settings"]})})]})}),f?e.jsx(x,{children:e.jsx("div",{className:"py-16 text-center text-sm text-gray-400",children:"正在加载知识库详情…"})}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:r.name}),e.jsx("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:r.description||"上传文档后,这个知识库会变成你当前项目的专属 RAG 索引。"})]}),e.jsxs("label",{className:Q("inline-flex cursor-pointer items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium",m?"bg-accent text-white hover:bg-accent-dim":"bg-gray-200 text-gray-500 dark:bg-white/[0.08] dark:text-gray-500"),children:[e.jsx(B,{size:14}),j?"上传中…":"上传文件",e.jsx("input",{type:"file",multiple:!0,className:"hidden",disabled:!m||j,onChange:s=>void $(s)})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"文档数"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-gray-900 dark:text-white",children:g.length})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"字符统计"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-gray-900 dark:text-white",children:g.reduce((s,d)=>s+Number(d.wordCount||0),0)})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"最近更新"}),e.jsx("p",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:F(r.updatedAt)})]})]})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"内容搜索"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"在当前知识库内检索已解析内容,快速确认切块与召回效果。"})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(J,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx(X,{value:n,onChange:s=>T(s.target.value),placeholder:"例如:升级流程、性能测试结论",className:"pl-9",onKeyDown:s=>{s.key==="Enter"&&S()}})]}),e.jsxs(p,{onClick:()=>void S(),disabled:!m||!n.trim(),loading:I,children:[e.jsx(se,{size:14})," 搜索"]})]}),w.length===0?e.jsx("div",{className:"rounded-2xl border border-dashed border-gray-200/80 px-4 py-8 text-center text-sm text-gray-400 dark:border-white/[0.08]",children:n?"还没有搜索结果。":"输入关键词后可以查看召回片段。"}):e.jsx("div",{className:"space-y-3",children:w.map(s=>e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:s.title}),e.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["chunk #",s.chunkOffset," · score ",s.score.toFixed(4)]})]}),e.jsx("span",{className:"rounded-full bg-gray-100 px-2.5 py-1 text-xs text-gray-500 dark:bg-white/[0.06] dark:text-gray-400",children:s.fileName})]}),e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm leading-7 text-gray-600 dark:text-gray-300",children:s.snippet})]},s.id))})]})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"文件列表"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"当前知识库内已完成解析并入库的文件。"})]})}),g.length===0?e.jsx(E,{message:"还没有文件,上传文档后会出现在这里。",icon:B}):e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200/80 dark:border-white/[0.08]",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_120px_120px_160px_60px] gap-3 border-b border-gray-200/80 bg-gray-50/80 px-4 py-3 text-xs font-medium uppercase tracking-wide text-gray-500 dark:border-white/[0.08] dark:bg-white/[0.03]",children:[e.jsx("span",{children:"文件"}),e.jsx("span",{children:"类型"}),e.jsx("span",{children:"字符数"}),e.jsx("span",{children:"创建时间"}),e.jsx("span",{})]}),g.map(s=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_120px_120px_160px_60px] gap-3 border-b border-gray-200/70 px-4 py-3 text-sm last:border-b-0 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium text-gray-900 dark:text-white",children:s.fileName}),e.jsx("p",{className:"mt-1 truncate text-xs text-gray-400",children:s.fileId})]}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:s.fileType}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:s.wordCount||0}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:F(s.createTime)}),e.jsx("button",{type:"button",onClick:()=>void H(s),className:"rounded-lg p-2 text-gray-400 hover:bg-red-500/10 hover:text-red-500","aria-label":`Delete ${s.fileName}`,children:e.jsx(W,{size:15})})]},s.fileId))]})]})]}):e.jsx(x,{children:e.jsx(E,{message:"没有找到这个知识库。",icon:te})})]})}export{oe as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as T,r as a,ab as se,ac as te,D as ae,ad as re,ae as ne,af as ie,ag as le,ah as oe,ai as de,j as e,L as $,B as d,S as ce,C as x,H as I,aj as me,I as C,ak as xe,Y as ge,T as he}from"./index-B2JL40NF.js";import{M as L}from"./Modal-JbmTZbCL.js";import{E as R}from"./EmptyState-Ce5baC0x.js";import{P}from"./pencil-BD6oAfUg.js";import{T as O}from"./trash-2-C5_ZLIsu.js";import{S as ue}from"./search-Ci4i20HH.js";import{P as pe}from"./plus-BWHFEPZn.js";import{B as fe}from"./book-open-3Awj2zba.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ye=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],je=T("folder-plus",ye);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ve=[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]],S=T("folders",ve);function _(o){return o==="success"?"border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-900/30 dark:bg-violet-950/20 dark:text-violet-300":o==="warning"?"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/30 dark:bg-amber-950/20 dark:text-amber-300":"border-red-200 bg-red-50 text-red-700 dark:border-red-900/30 dark:bg-red-950/20 dark:text-red-300"}function be(o){switch(o){case"file":return"bg-blue-500";case"spark":return"bg-amber-500";case"screen":return"bg-fuchsia-500";default:return"bg-indigo-500"}}function we(o){return o.split("/").length-1}function ze(){const[o,F]=a.useState(!0),[m,q]=a.useState([]),[j,A]=a.useState([]),[l,v]=a.useState(null),[g,H]=a.useState(""),[U,V]=a.useState(!1),[Z,h]=a.useState(!1),[G,u]=a.useState(!1),[p,B]=a.useState(""),[f,K]=a.useState(""),[b,E]=a.useState(""),[w,r]=a.useState(null),[z,y]=a.useState(null),n=a.useCallback(async()=>{F(!0);try{const[s,t,i]=await Promise.all([se(),te(),ae()]);V(!!s.baseUrl),q(t.folders||[]),A(i.bases||[])}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{F(!1)}},[]);a.useEffect(()=>{n()},[n]);const N=a.useMemo(()=>{if(!l)return null;const s=m.find(i=>i.id===l);if(!s)return null;const t=new Set([s.id]);return m.forEach(i=>{i.path.startsWith(`${s.path}/`)&&t.add(i.id)}),t},[m,l]),M=a.useMemo(()=>{const s=g.trim().toLowerCase();return j.filter(t=>(N?N.has(t.folderId||""):!0)?s?[t.name,t.description,t.creatorName].join(" ").toLowerCase().includes(s):!0:!1)},[j,N,g]),Q=a.useCallback(async()=>{if(!p.trim()){r({tone:"warning",message:"Folder name is required."});return}y("folder");try{await re({name:p.trim(),parentId:l}),B(""),h(!1),r({tone:"success",message:"Folder created."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{y(null)}},[p,n,l]),W=a.useCallback(async()=>{if(!f.trim()){r({tone:"warning",message:"Knowledge base name is required."});return}y("base");try{await ne({name:f.trim(),description:b.trim(),folderId:l}),K(""),E(""),u(!1),r({tone:"success",message:"Knowledge base created."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{y(null)}},[b,f,n,l]),Y=a.useCallback(async s=>{var i;const t=(i=window.prompt("Rename folder",s.name))==null?void 0:i.trim();if(!(!t||t===s.name))try{await ie(s.id,{name:t}),r({tone:"success",message:"Folder updated."}),await n()}catch(c){r({tone:"error",message:c instanceof Error?c.message:String(c)})}},[n]),J=a.useCallback(async s=>{if(window.confirm(`Delete folder "${s.name}"?`))try{await le(s.id),l===s.id&&v(null),r({tone:"success",message:"Folder deleted."}),await n()}catch(t){r({tone:"error",message:t instanceof Error?t.message:String(t)})}},[n,l]),X=a.useCallback(async s=>{var c,D;const t=(c=window.prompt("Knowledge base name",s.name))==null?void 0:c.trim();if(!t)return;const i=((D=window.prompt("Description",s.description))==null?void 0:D.trim())??s.description;try{await oe(s.id,{name:t,description:i}),r({tone:"success",message:"Knowledge base updated."}),await n()}catch(k){r({tone:"error",message:k instanceof Error?k.message:String(k)})}},[n]),ee=a.useCallback(async s=>{if(window.confirm(`Delete knowledge base "${s.name}"?`))try{await de(s.id),r({tone:"success",message:"Knowledge base deleted."}),await n()}catch(t){r({tone:"error",message:t instanceof Error?t.message:String(t)})}},[n]);return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[w&&e.jsx("div",{className:`rounded-xl border px-4 py-3 text-sm ${_(w.tone)}`,children:w.message}),!U&&!o&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${_("warning")}`,children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Knowledge search is not configured yet."}),e.jsx("p",{className:"mt-1 text-sm opacity-90",children:"Add the ai_vector base URL in System settings before uploading files or running retrieval."})]}),e.jsx($,{to:"/system",children:e.jsxs(d,{variant:"secondary",children:[e.jsx(ce,{size:14})," Open System Settings"]})})]})}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-[300px_minmax(0,1fr)]",children:[e.jsxs(x,{className:"p-0 overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200/80 px-5 py-4 dark:border-white/[0.08]",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"知识库"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"创建目录并管理知识库分类。"})]}),e.jsxs(d,{size:"sm",variant:"secondary",onClick:()=>h(!0),children:[e.jsx(je,{size:14})," 文件夹"]})]})}),e.jsx("div",{className:"px-5 py-4",children:e.jsxs("button",{type:"button",onClick:()=>v(null),className:I("flex w-full items-center justify-between rounded-xl px-3 py-2.5 text-left text-sm transition-colors",l?"hover:bg-gray-100/80 text-gray-600 dark:text-gray-300 dark:hover:bg-white/[0.06]":"bg-accent/10 text-gray-900 ring-1 ring-accent/30 dark:text-white"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(S,{size:16}),"全部知识库"]}),e.jsx("span",{className:"text-xs opacity-70",children:j.length})]})}),e.jsx("div",{className:"max-h-[70vh] overflow-y-auto px-3 pb-4",children:m.length===0?e.jsx(R,{message:"还没有目录,先创建一个文件夹吧。",icon:S}):e.jsx("div",{className:"space-y-1",children:m.map(s=>{const t=s.id===l;return e.jsx("div",{className:I("group rounded-xl px-2 py-1",t?"bg-accent/10 ring-1 ring-accent/25":"hover:bg-gray-100/80 dark:hover:bg-white/[0.04]"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>v(s.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left",style:{paddingLeft:`${8+we(s.path)*18}px`},children:[e.jsx(me,{size:14,className:"text-gray-400"}),e.jsx(S,{size:15,className:"text-amber-500"}),e.jsx("span",{className:"truncate text-sm text-gray-800 dark:text-gray-100",children:s.name})]}),e.jsx("button",{type:"button",onClick:()=>void Y(s),className:"rounded-md p-1 text-gray-400 transition hover:bg-gray-200/70 hover:text-gray-700 dark:hover:bg-white/[0.08] dark:hover:text-white","aria-label":`Rename ${s.name}`,children:e.jsx(P,{size:14})}),e.jsx("button",{type:"button",onClick:()=>void J(s),className:"rounded-md p-1 text-gray-400 transition hover:bg-red-500/10 hover:text-red-500","aria-label":`Delete ${s.name}`,children:e.jsx(O,{size:14})})]})},s.id)})})})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(x,{children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"知识库列表"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"目录筛选、本地搜索,以及知识库卡片概览都在这里。"})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative min-w-[260px]",children:[e.jsx(ue,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx(C,{value:g,onChange:s=>H(s.target.value),placeholder:"搜索名称、描述或创建者",className:"pl-9"})]}),e.jsxs(d,{variant:"secondary",onClick:()=>u(!0),children:[e.jsx(pe,{size:14})," 创建知识库"]})]})]})}),o?e.jsx(x,{children:e.jsx("div",{className:"py-16 text-center text-sm text-gray-400",children:"正在加载知识库…"})}):M.length===0?e.jsx(x,{children:e.jsx(R,{message:g?"没有匹配的知识库。":"还没有知识库,先创建一个开始上传文档。",icon:xe})}):e.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 2xl:grid-cols-3",children:M.map(s=>e.jsxs(x,{className:"group relative overflow-hidden border border-gray-200/90 bg-white/90 p-6 shadow-sm hover:border-accent/30 hover:shadow-xl hover:shadow-black/5 dark:border-white/[0.08] dark:bg-[rgba(0,0,0,0.55)]",children:[e.jsxs("div",{className:"absolute right-4 top-4 flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void X(s),className:"rounded-lg p-2 text-gray-400 hover:bg-gray-100/90 hover:text-gray-700 dark:hover:bg-white/[0.08] dark:hover:text-white",children:e.jsx(P,{size:15})}),e.jsx("button",{type:"button",onClick:()=>void ee(s),className:"rounded-lg p-2 text-gray-400 hover:bg-red-500/10 hover:text-red-500",children:e.jsx(O,{size:15})})]}),e.jsxs($,{to:`/knowledge/${encodeURIComponent(s.id)}`,className:"block space-y-5",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`mt-1 flex h-12 w-12 items-center justify-center rounded-2xl text-white shadow-lg ${be(s.icon)}`,children:e.jsx(fe,{size:22})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate pr-8 text-xl font-semibold text-gray-900 dark:text-white",children:s.name}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["创建者: ",s.creatorName||"系统管理员"]})]})]}),e.jsx("div",{className:"min-h-[72px] text-base leading-7 text-gray-600 dark:text-gray-300",children:s.description||"这个知识库还没有描述,点击进入后可以上传文件并开始检索。"}),e.jsxs("div",{className:"flex items-center gap-6 text-sm font-medium text-gray-700 dark:text-gray-200",children:[e.jsxs("span",{children:[s.fileCount," 文档数"]}),e.jsxs("span",{children:[(s.wordCount/1e3).toFixed(s.wordCount>0?1:0),"k 字符"]})]}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:["更新于 ",ge(s.updatedAt)]})]})]},s.id))})]})]}),e.jsx(L,{open:Z,onClose:()=>h(!1),title:"创建文件夹",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"文件夹名称",value:p,onChange:s=>B(s.target.value),placeholder:"例如:产品文档"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"secondary",onClick:()=>h(!1),children:"取消"}),e.jsx(d,{onClick:()=>void Q(),loading:z==="folder",children:"创建"})]})]})}),e.jsx(L,{open:G,onClose:()=>u(!1),title:"创建知识库",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"名称",value:f,onChange:s=>K(s.target.value),placeholder:"例如:运营文档库"}),e.jsx(he,{label:"描述",rows:4,value:b,onChange:s=>E(s.target.value),placeholder:"一句话说明这个知识库主要收录什么内容"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"secondary",onClick:()=>u(!1),children:"取消"}),e.jsx(d,{onClick:()=>void W(),loading:z==="base",children:"创建"})]})]})})]})}export{ze as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as v,r as t,aa as p,j as e,L as j,B as d,O as m,C as y}from"./index-B2JL40NF.js";import{B as N}from"./Badge-O6YyBOXO.js";import{P as b}from"./Page-854R0NMM.js";import{A as w}from"./arrow-left-mguKZKTu.js";import{F as L}from"./funnel-DE2QCcoy.js";const C={debug:"text-gray-400",info:"text-blue-400",warn:"text-amber-400",error:"text-red-400"},S={debug:"default",info:"info",warn:"warning",error:"danger"};function A(){const{t:a}=v(),[l,x]=t.useState([]),[r,u]=t.useState("info"),[n,f]=t.useState("100"),[g,i]=t.useState(!0),o=t.useCallback(async()=>{i(!0);try{const s=await p({level:r,limit:n});x(s.entries||[])}finally{i(!1)}},[r,n]);return t.useEffect(()=>{o()},[o]),e.jsxs("div",{className:"space-y-4 animate-fade-in",children:[e.jsx(b,{title:a("system.logs"),description:"Filtered runtime logs for troubleshooting.",actions:e.jsx(j,{to:"/system",children:e.jsxs(d,{variant:"secondary",size:"sm",children:[e.jsx(w,{size:14})," ",a("nav.system")]})})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{size:14,className:"text-muted-foreground"}),e.jsxs(m,{value:r,onChange:s=>u(s.target.value),className:"w-auto",children:[e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"error",children:"Error"})]})]}),e.jsxs(m,{value:n,onChange:s=>f(s.target.value),className:"w-auto",children:[e.jsx("option",{value:"50",children:"50"}),e.jsx("option",{value:"100",children:"100"}),e.jsx("option",{value:"500",children:"500"}),e.jsx("option",{value:"1000",children:"1000"})]}),e.jsx(d,{size:"sm",variant:"secondary",onClick:o,children:a("common.refresh")})]}),e.jsx(y,{children:g?e.jsx("div",{className:"text-muted-foreground animate-pulse text-sm",children:"Loading..."}):l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:a("common.noData")}):e.jsx("div",{className:"space-y-1 max-h-[65vh] overflow-y-auto font-mono text-xs",children:l.map((s,h)=>{var c;return e.jsxs("div",{className:"flex items-start gap-3 py-1.5 border-b last:border-0",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 w-36",children:(c=s.time)==null?void 0:c.slice(0,19)}),e.jsx(N,{variant:S[s.level]||"default",children:s.level}),e.jsx("span",{className:`${C[s.level]||"text-gray-500"} flex-1`,children:s.message})]},h)})})})]})}export{A as default};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{c as K,r as i,al as C,am as I,an as X,j as s,ao as O,ap as Y,aq as N,ar as x,as as Z,at as J,au as Q,av as ee,aw as te,ax as ne,ay as oe,az as re,H as P}from"./index-B2JL40NF.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ae=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],se=K("x",ae);function ie(e,t){return i.useReducer((o,n)=>t[o][n]??o,e)}var y=e=>{const{present:t,children:o}=e,n=ce(t),r=typeof o=="function"?o({present:n.isPresent}):i.Children.only(o),a=C(n.ref,le(r));return typeof o=="function"||n.isPresent?i.cloneElement(r,{ref:a}):null};y.displayName="Presence";function ce(e){const[t,o]=i.useState(),n=i.useRef(null),r=i.useRef(e),a=i.useRef("none"),c=e?"mounted":"unmounted",[u,d]=ie(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const l=h(n.current);a.current=u==="mounted"?l:"none"},[u]),I(()=>{const l=n.current,g=r.current;if(g!==e){const D=a.current,p=h(l);e?d("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?d("UNMOUNT"):d(g&&D!==p?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,d]),I(()=>{if(t){let l;const g=t.ownerDocument.defaultView??window,m=p=>{const V=h(n.current).includes(CSS.escape(p.animationName));if(p.target===t&&V&&(d("ANIMATION_END"),!r.current)){const q=t.style.animationFillMode;t.style.animationFillMode="forwards",l=g.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=q)})}},D=p=>{p.target===t&&(a.current=h(n.current))};return t.addEventListener("animationstart",D),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{g.clearTimeout(l),t.removeEventListener("animationstart",D),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:i.useCallback(l=>{n.current=l?getComputedStyle(l):null,o(l)},[])}}function h(e){return(e==null?void 0:e.animationName)||"none"}function le(e){var n,r;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,o=t&&"isReactWarning"in t&&t.isReactWarning;return o?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,o=t&&"isReactWarning"in t&&t.isReactWarning,o?e.props.ref:e.props.ref||e.ref)}var E="Dialog",[T]=Q(E),[ue,f]=T(E),b=e=>{const{__scopeDialog:t,children:o,open:n,defaultOpen:r,onOpenChange:a,modal:c=!0}=e,u=i.useRef(null),d=i.useRef(null),[l,g]=X({prop:n,defaultProp:r??!1,onChange:a,caller:E});return s.jsx(ue,{scope:t,triggerRef:u,contentRef:d,contentId:O(),titleId:O(),descriptionId:O(),open:l,onOpenChange:g,onOpenToggle:i.useCallback(()=>g(m=>!m),[g]),modal:c,children:o})};b.displayName=E;var j="DialogTrigger",de=i.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(j,o),a=C(t,r.triggerRef);return s.jsx(N.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":M(r.open),...n,ref:a,onClick:x(e.onClick,r.onOpenToggle)})});de.displayName=j;var A="DialogPortal",[fe,w]=T(A,{forceMount:void 0}),S=e=>{const{__scopeDialog:t,forceMount:o,children:n,container:r}=e,a=f(A,t);return s.jsx(fe,{scope:t,forceMount:o,children:i.Children.map(n,c=>s.jsx(y,{present:o||a.open,children:s.jsx(Y,{asChild:!0,container:r,children:c})}))})};S.displayName=A;var R="DialogOverlay",F=i.forwardRef((e,t)=>{const o=w(R,e.__scopeDialog),{forceMount:n=o.forceMount,...r}=e,a=f(R,e.__scopeDialog);return a.modal?s.jsx(y,{present:n||a.open,children:s.jsx(me,{...r,ref:t})}):null});F.displayName=R;var ge=ee("DialogOverlay.RemoveScroll"),me=i.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(R,o);return s.jsx(Z,{as:ge,allowPinchZoom:!0,shards:[r.contentRef],children:s.jsx(N.div,{"data-state":M(r.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),v="DialogContent",W=i.forwardRef((e,t)=>{const o=w(v,e.__scopeDialog),{forceMount:n=o.forceMount,...r}=e,a=f(v,e.__scopeDialog);return s.jsx(y,{present:n||a.open,children:a.modal?s.jsx(pe,{...r,ref:t}):s.jsx(ve,{...r,ref:t})})});W.displayName=v;var pe=i.forwardRef((e,t)=>{const o=f(v,e.__scopeDialog),n=i.useRef(null),r=C(t,o.contentRef,n);return i.useEffect(()=>{const a=n.current;if(a)return J(a)},[]),s.jsx(L,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:x(e.onCloseAutoFocus,a=>{var c;a.preventDefault(),(c=o.triggerRef.current)==null||c.focus()}),onPointerDownOutside:x(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0;(c.button===2||u)&&a.preventDefault()}),onFocusOutside:x(e.onFocusOutside,a=>a.preventDefault())})}),ve=i.forwardRef((e,t)=>{const o=f(v,e.__scopeDialog),n=i.useRef(!1),r=i.useRef(!1);return s.jsx(L,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var c,u;(c=e.onCloseAutoFocus)==null||c.call(e,a),a.defaultPrevented||(n.current||(u=o.triggerRef.current)==null||u.focus(),a.preventDefault()),n.current=!1,r.current=!1},onInteractOutside:a=>{var d,l;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const c=a.target;((l=o.triggerRef.current)==null?void 0:l.contains(c))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),L=i.forwardRef((e,t)=>{const{__scopeDialog:o,trapFocus:n,onOpenAutoFocus:r,onCloseAutoFocus:a,...c}=e,u=f(v,o),d=i.useRef(null),l=C(t,d);return te(),s.jsxs(s.Fragment,{children:[s.jsx(ne,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:r,onUnmountAutoFocus:a,children:s.jsx(oe,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":M(u.open),...c,ref:l,onDismiss:()=>u.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Ne,{titleId:u.titleId}),s.jsx(he,{contentRef:d,descriptionId:u.descriptionId})]})]})}),_="DialogTitle",k=i.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(_,o);return s.jsx(N.h2,{id:r.titleId,...n,ref:t})});k.displayName=_;var U="DialogDescription",xe=i.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(U,o);return s.jsx(N.p,{id:r.descriptionId,...n,ref:t})});xe.displayName=U;var G="DialogClose",$=i.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(G,o);return s.jsx(N.button,{type:"button",...n,ref:t,onClick:x(e.onClick,()=>r.onOpenChange(!1))})});$.displayName=G;function M(e){return e?"open":"closed"}var z="DialogTitleWarning",[Me,B]=re(z,{contentName:v,titleName:_,docsSlug:"dialog"}),Ne=({titleId:e})=>{const t=B(z),o=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
7
|
+
|
|
8
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
9
|
+
|
|
10
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(o))},[o,e]),null},De="DialogDescriptionWarning",he=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${B(De).contentName}}.`;return i.useEffect(()=>{var a;const r=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Re=b,Ce=S,ye=F,Ee=W,Oe=k,Ae=$;function Ie({open:e,onClose:t,title:o,children:n,className:r}){return s.jsx(Re,{open:e,onOpenChange:a=>{a||t()},children:s.jsxs(Ce,{children:[s.jsx(ye,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-fade-in"}),s.jsxs(Ee,{className:P("fixed inset-x-4 top-1/2 z-50 grid max-h-[calc(100dvh-2rem)] max-w-lg -translate-y-1/2 gap-4 overflow-y-auto","rounded-lg border bg-popover p-5 text-popover-foreground shadow-lg outline-none sm:left-1/2 sm:right-auto sm:w-[calc(100%-2rem)] sm:-translate-x-1/2 sm:p-6",r),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Oe,{className:"text-lg font-semibold leading-none tracking-tight",children:o}),s.jsx(Ae,{className:P("rounded-sm p-1 opacity-70 transition-opacity hover:opacity-100","focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"),"aria-label":"Close",children:s.jsx(se,{size:18})})]}),n]})]})})}export{Ie as M,se as X};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,C as m,H as a}from"./index-B2JL40NF.js";function u({title:s,description:r,actions:t}){return e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s}),r?e.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-6 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]})}function o({title:s,description:r,actions:t,children:l,className:d,bodyClassName:n}){return e.jsxs(m,{className:a("p-0",d),children:[(s||r||t)&&e.jsxs("div",{className:"flex flex-col gap-3 border-b px-5 py-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[s?e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s}):null,r?e.jsx("p",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]}),e.jsx("div",{className:a("p-5",n),children:l})]})}const x={neutral:"border-border bg-muted text-muted-foreground",success:"border-primary/20 bg-primary/10 text-primary",warning:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-200",danger:"border-destructive/20 bg-destructive/10 text-destructive dark:text-red-200",info:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-400/20 dark:bg-blue-500/10 dark:text-blue-200"};function b({children:s,tone:r="neutral"}){return e.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium",x[r]),children:s})}export{u as P,o as S,b as a};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as L,V as l,u as X,X as Y,r,j as e,L as G,B as n,Z as O,H as P,C as m,J as Q,I as p,Y as W,_ as ee}from"./index-B2JL40NF.js";import{B as f}from"./Badge-O6YyBOXO.js";import{M as S}from"./Modal-JbmTZbCL.js";import{E as z}from"./EmptyState-Ce5baC0x.js";import{P as se,S as $}from"./Page-854R0NMM.js";import{g as te}from"./projects-DCdaAlgs.js";import{A as ae}from"./arrow-left-mguKZKTu.js";import{H as I}from"./heart-B6xi7jGt.js";import{P as re}from"./plug-CIaRVhae.js";import{P as ne}from"./plus-BWHFEPZn.js";import{T as oe}from"./trash-2-C5_ZLIsu.js";import{P as le}from"./play-C9Ue_X4n.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ie=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],ce=L("layers",ie);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const de=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],me=L("pause",de),xe=s=>l.get(`/projects/${s}/providers`),ue=(s,a)=>l.post(`/projects/${s}/providers`,a),pe=(s,a)=>l.delete(`/projects/${s}/providers/${a}`),he=(s,a)=>l.post(`/projects/${s}/providers/${a}/activate`),ve=s=>l.get(`/projects/${s}/models`),je=(s,a)=>l.post(`/projects/${s}/model`,{model:a}),fe=s=>l.get(`/projects/${s}/heartbeat`),ge=s=>l.post(`/projects/${s}/heartbeat/pause`),be=s=>l.post(`/projects/${s}/heartbeat/resume`),ye=s=>l.post(`/projects/${s}/heartbeat/run`),Ne=(s,a)=>l.post(`/projects/${s}/heartbeat/interval`,{minutes:a});function Ee(){var k,C;const{t:s}=X(),{name:a}=Y(),[h,A]=r.useState("overview"),[d,H]=r.useState(null),[b,M]=r.useState([]),[we,E]=r.useState(""),[i,B]=r.useState(null),[y,T]=r.useState([]),[q,D]=r.useState(""),[R,N]=r.useState(!0),[U,v]=r.useState(!1),[c,x]=r.useState({name:"",api_key:"",base_url:"",model:""}),[Z,j]=r.useState(!1),[w,F]=r.useState("30"),o=r.useCallback(async()=>{if(a)try{N(!0);const[t,u,_,g]=await Promise.allSettled([te(a),xe(a),fe(a),ve(a)]);t.status==="fulfilled"&&H(t.value),u.status==="fulfilled"&&(M(u.value.providers||[]),E(u.value.active_provider||"")),_.status==="fulfilled"&&B(_.value),g.status==="fulfilled"&&(T(g.value.models||[]),D(g.value.current||""))}finally{N(!1)}},[a]);r.useEffect(()=>{o();const t=()=>o();return window.addEventListener("cc:refresh",t),()=>window.removeEventListener("cc:refresh",t)},[o]);const J=async()=>{!a||!c.name||(await ue(a,c),v(!1),x({name:"",api_key:"",base_url:"",model:""}),o())},K=async()=>{a&&(await Ne(a,parseInt(w)),j(!1),o())},V=[{key:"overview",icon:ce},{key:"providers",icon:O},{key:"heartbeat",icon:I}];return R&&!d?e.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(se,{title:a,description:"Project overview, providers, and heartbeat status. Low-frequency settings are no longer editable in the daily UI.",actions:e.jsx(G,{to:"/projects",children:e.jsxs(n,{variant:"secondary",size:"sm",children:[e.jsx(ae,{size:14})," Back"]})})}),d&&e.jsx(f,{variant:"info",children:d.agent_type}),e.jsx("div",{className:"flex gap-2",children:V.map(({key:t,icon:u})=>e.jsxs("button",{onClick:()=>A(t),className:P("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all",h===t?"bg-primary text-primary-foreground shadow-md":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:[e.jsx(u,{size:16}),s(`projects.tabs.${t}`)]},t))}),h==="overview"&&d&&e.jsxs("div",{className:"space-y-4",children:[e.jsx($,{title:s("projects.platforms"),children:e.jsx("div",{className:"flex flex-wrap gap-2",children:(k=d.platforms)==null?void 0:k.map(t=>e.jsxs(f,{variant:t.connected?"success":"danger",children:[e.jsx(re,{size:12,className:"mr-1"})," ",t.type," ",t.connected?"✓":"✗"]},t.type))})}),e.jsxs($,{title:s("sessions.title"),children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.sessions_count," ",s("nav.sessions").toLowerCase()]}),((C=d.active_session_keys)==null?void 0:C.length)>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:d.active_session_keys.map(t=>e.jsx(f,{variant:"default",children:t},t))})]})]}),h==="providers"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:s("providers.title")}),e.jsxs(n,{size:"sm",onClick:()=>v(!0),children:[e.jsx(ne,{size:14})," ",s("providers.add")]})]}),b.length===0?e.jsx(z,{message:s("common.noData")}):e.jsx("div",{className:"space-y-2",children:b.map(t=>e.jsx(m,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-foreground",children:t.name}),t.active&&e.jsx(f,{variant:"success",children:s("providers.active")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t.model," ",t.base_url?`· ${t.base_url}`:""]})]}),e.jsxs("div",{className:"flex gap-2",children:[!t.active&&e.jsxs(n,{size:"sm",variant:"secondary",onClick:()=>{he(a,t.name).then(o)},children:[e.jsx(Q,{size:14})," ",s("providers.activate")]}),!t.active&&e.jsx(n,{size:"sm",variant:"danger",onClick:()=>{pe(a,t.name).then(o)},children:e.jsx(oe,{size:14})})]})]})},t.name))}),y.length>0&&e.jsxs(m,{children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-3",children:s("providers.models")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(t=>e.jsx("button",{onClick:()=>{je(a,t).then(o)},className:P("px-3 py-1.5 rounded-lg text-xs font-medium transition-all",t===q?"bg-primary/15 text-primary border border-primary/30":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:t},t))})]}),e.jsx(S,{open:U,onClose:()=>v(!1),title:s("providers.add"),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{label:s("providers.name"),value:c.name,onChange:t=>x({...c,name:t.target.value})}),e.jsx(p,{label:"API Key",type:"password",value:c.api_key,onChange:t=>x({...c,api_key:t.target.value})}),e.jsx(p,{label:s("providers.baseUrl"),value:c.base_url,onChange:t=>x({...c,base_url:t.target.value}),placeholder:"https://api.example.com"}),e.jsx(p,{label:s("providers.model"),value:c.model,onChange:t=>x({...c,model:t.target.value})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(n,{variant:"secondary",onClick:()=>v(!1),children:s("common.cancel")}),e.jsx(n,{onClick:J,children:s("providers.add")})]})]})})]}),h==="heartbeat"&&e.jsxs("div",{className:"space-y-4",children:[i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(m,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("heartbeat.status")}),e.jsx("p",{className:"text-lg font-bold text-foreground mt-1",children:i.paused?s("heartbeat.paused"):s("heartbeat.running")})]}),e.jsxs(m,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("heartbeat.interval")}),e.jsxs("p",{className:"text-lg font-bold text-foreground mt-1",children:[i.interval_mins,"m"]})]}),e.jsxs(m,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("heartbeat.runCount")}),e.jsx("p",{className:"text-lg font-bold text-foreground mt-1",children:i.run_count})]}),e.jsxs(m,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("heartbeat.errorCount")}),e.jsx("p",{className:"text-lg font-bold text-foreground mt-1",children:i.error_count})]})]}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("p",{className:"text-muted-foreground",children:[s("heartbeat.lastRun"),": ",e.jsx("span",{className:"text-foreground",children:W(i.last_run)})]}),e.jsxs("p",{className:"text-muted-foreground",children:[s("heartbeat.skippedBusy"),": ",e.jsx("span",{className:"text-foreground",children:i.skipped_busy})]}),i.last_error&&e.jsx("p",{className:"text-destructive",children:i.last_error})]})}),e.jsxs("div",{className:"flex gap-2",children:[i.paused?e.jsxs(n,{onClick:()=>{be(a).then(o)},children:[e.jsx(le,{size:14})," ",s("heartbeat.resume")]}):e.jsxs(n,{variant:"secondary",onClick:()=>{ge(a).then(o)},children:[e.jsx(me,{size:14})," ",s("heartbeat.pause")]}),e.jsxs(n,{variant:"secondary",onClick:()=>{ye(a).then(o)},children:[e.jsx(I,{size:14})," ",s("heartbeat.trigger")]}),e.jsxs(n,{variant:"secondary",onClick:()=>j(!0),children:[e.jsx(ee,{size:14})," ",s("heartbeat.setInterval")]})]})]}):e.jsx(z,{message:s("common.noData")}),e.jsx(S,{open:Z,onClose:()=>j(!1),title:s("heartbeat.setInterval"),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{label:`${s("heartbeat.interval")} (min)`,type:"number",value:w,onChange:t=>F(t.target.value)}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(n,{variant:"secondary",onClick:()=>j(!1),children:s("common.cancel")}),e.jsx(n,{onClick:K,children:s("common.save")})]})]})})]})]})}export{Ee as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as x,r,j as e,F as f,L as j,C as u}from"./index-B2JL40NF.js";import{B as l}from"./Badge-O6YyBOXO.js";import{E as h}from"./EmptyState-Ce5baC0x.js";import{P as p}from"./Page-854R0NMM.js";import{l as g}from"./projects-DCdaAlgs.js";import{S as v,A as N}from"./server-07G4ybtv.js";import{H as w}from"./heart-B6xi7jGt.js";function z(){const{t}=x(),[a,m]=r.useState([]),[d,n]=r.useState(!0),i=r.useCallback(async()=>{try{n(!0);const s=await g();m(s.projects||[])}finally{n(!1)}},[]);return r.useEffect(()=>{i();const s=()=>i();return window.addEventListener("cc:refresh",s),()=>window.removeEventListener("cc:refresh",s)},[i]),d&&a.length===0?e.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):a.length===0?e.jsx(h,{message:t("projects.noProjects"),icon:f}):e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(p,{title:t("nav.projects"),description:"Project summaries with provider, platform, and session status."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:a.map(s=>{var o;return e.jsx(j,{to:`/projects/${s.name}`,children:e.jsxs(u,{hover:!0,className:"h-full",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{size:18,className:"text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:s.name})]}),e.jsx(N,{size:16,className:"text-muted-foreground/45"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[e.jsx(l,{variant:"info",children:s.agent_type}),(o=s.platforms)==null?void 0:o.map(c=>e.jsx(l,{children:c},c))]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.sessions_count," ",t("nav.sessions").toLowerCase()]}),s.heartbeat_enabled&&e.jsxs("span",{className:"flex items-center gap-1 text-primary",children:[e.jsx(w,{size:12})," ",t("heartbeat.title")]})]})]})},s.name)})})]})}export{z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as C,X as S,r,j as e,L as z,B as j,H as g,I as B}from"./index-B2JL40NF.js";import{B as y}from"./Badge-O6YyBOXO.js";import{g as E,a as I}from"./sessions-C4c2fLQB.js";import{C as L,S as M}from"./ChatMarkdown-CKIl8nVw.js";import{A as R}from"./arrow-left-mguKZKTu.js";import{C as D}from"./circle-BWSc4-qr.js";import{W as v,R as K}from"./wifi-off-DuwKaMRJ.js";import{B as U,U as W}from"./user-DHBITt1w.js";function q(){var h;const{t:a}=C(),{project:n,id:l}=S(),[s,N]=r.useState(null),[o,m]=r.useState(""),[d,x]=r.useState(!1),[b,f]=r.useState(!0),u=r.useRef(null),c=r.useCallback(async()=>{if(!(!n||!l))try{f(!0);const t=await E(n,l,200);N(t)}finally{f(!1)}},[n,l]);r.useEffect(()=>{c()},[c]),r.useEffect(()=>{var t;(t=u.current)==null||t.scrollIntoView({behavior:"smooth"})},[s==null?void 0:s.history]);const p=async()=>{if(!o.trim()||!n||!s)return;const t=o.trim();m(""),x(!0);try{await I(n,{session_key:s.session_key,message:t}),setTimeout(c,1500)}finally{x(!1)}},w=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),p())};return b&&!s?e.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):e.jsxs("div",{className:"flex flex-col h-[calc(100vh-8rem)] animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between pb-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(z,{to:"/sessions",className:"p-2 rounded-md hover:bg-accent/10 transition-colors",children:e.jsx(R,{size:18,className:"text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:(s==null?void 0:s.name)||l}),s!=null&&s.live?e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-primary bg-primary/10 px-1.5 py-0.5 rounded-full",children:[e.jsx(D,{size:5,className:"fill-current"})," live"]}):e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded-full",children:[e.jsx(v,{size:9})," ",a("sessions.offline")]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(y,{children:n}),(s==null?void 0:s.platform)&&e.jsx(y,{variant:"info",children:s.platform}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s==null?void 0:s.session_key})]})]})]}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:c,children:[e.jsx(K,{size:14})," ",a("common.refresh")]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-6 space-y-5",children:[(!(s!=null&&s.history)||s.history.length===0)&&e.jsx("p",{className:"text-center text-sm text-muted-foreground py-12",children:a("sessions.noMessages")}),(h=s==null?void 0:s.history)==null?void 0:h.map((t,k)=>{const i=t.role==="user";return e.jsxs("div",{className:g("flex gap-3",i?"justify-end":"justify-start"),children:[!i&&e.jsx("div",{className:"w-8 h-8 rounded-md bg-primary/10 flex items-center justify-center shrink-0 mt-1",children:e.jsx(U,{size:16,className:"text-primary"})}),e.jsx("div",{className:g("rounded-lg px-5 py-3.5 text-sm",i?"max-w-[70%] bg-primary text-primary-foreground rounded-br-md":"max-w-[85%] bg-card border text-card-foreground rounded-bl-md shadow-sm"),children:e.jsx(L,{content:t.content,isUser:i})}),i&&e.jsx("div",{className:"w-8 h-8 rounded-md bg-muted flex items-center justify-center shrink-0 mt-1",children:e.jsx(W,{size:16,className:"text-muted-foreground"})})]},k)}),e.jsx("div",{ref:u})]}),e.jsx("div",{className:"border-t pt-4",children:s!=null&&s.live?e.jsxs("div",{className:"flex gap-3",children:[e.jsx(B,{value:o,onChange:t=>m(t.target.value),onKeyDown:w,placeholder:a("sessions.messageInput"),className:"flex-1",disabled:d}),e.jsx(j,{onClick:p,disabled:d||!o.trim(),size:"icon","aria-label":a("sessions.messageInput"),children:d?e.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):e.jsx(M,{size:18})})]}):e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground bg-muted rounded-lg",children:[e.jsx(v,{size:14}),e.jsx("span",{children:a("sessions.notLiveHint")})]})})]})}export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as N,r as n,j as s,O as v,M as p,L as y,C as w}from"./index-B2JL40NF.js";import{B as f}from"./Badge-O6YyBOXO.js";import{E as _}from"./EmptyState-Ce5baC0x.js";import{l as S}from"./projects-DCdaAlgs.js";import{l as C}from"./sessions-C4c2fLQB.js";import{F as L}from"./funnel-DE2QCcoy.js";import{C as M}from"./circle-BWSc4-qr.js";import{U as E,B as $}from"./user-DHBITt1w.js";function k(a,o){if(!a)return"";const m=Date.now()-new Date(a).getTime(),i=Math.floor(m/6e4);if(i<1)return o("sessions.justNow");if(i<60)return`${i}m`;const l=Math.floor(i/60);return l<24?`${l}h`:`${Math.floor(l/24)}d`}function F(){const{t:a}=N(),[o,m]=n.useState([]),[i,l]=n.useState([]),[c,j]=n.useState(""),[h,x]=n.useState(!0),d=n.useCallback(async()=>{x(!0);try{const{projects:e}=await S();l(e||[]);const t=await Promise.all((e||[]).map(async r=>{try{const{sessions:g}=await C(r.name);return{project:r.name,sessions:g||[]}}catch{return{project:r.name,sessions:[]}}}));m(t)}finally{x(!1)}},[]);n.useEffect(()=>{d();const e=()=>d();return window.addEventListener("cc:refresh",e),()=>window.removeEventListener("cc:refresh",e)},[d]);const u=n.useMemo(()=>(c?o.filter(t=>t.project===c):o).flatMap(t=>t.sessions.map(r=>({...r,_project:t.project}))).sort((t,r)=>(r.updated_at||r.created_at||"").localeCompare(t.updated_at||t.created_at||"")),[o,c]);return h&&o.length===0?s.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):s.jsxs("div",{className:"space-y-4 animate-fade-in",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(L,{size:16,className:"text-muted-foreground"}),s.jsxs(v,{value:c,onChange:e=>j(e.target.value),className:"w-auto min-w-48",children:[s.jsx("option",{value:"",children:a("sessions.allProjects")}),i.map(e=>s.jsx("option",{value:e.name,children:e.name},e.name))]}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length," ",a("nav.sessions").toLowerCase()]})]}),u.length===0?s.jsx(_,{message:a("sessions.noSessions"),icon:p}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-3",children:u.map(e=>s.jsx(y,{to:`/sessions/${encodeURIComponent(e._project)}/${encodeURIComponent(e.id)}`,children:s.jsxs(w,{hover:!0,className:"group relative h-full p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(p,{size:14,className:e.live?"text-primary shrink-0":"text-muted-foreground shrink-0"}),s.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.name||e.user_name||e.id.slice(0,8)}),e.live&&s.jsx(M,{size:5,className:"fill-primary text-primary shrink-0"})]}),s.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 mt-0.5",children:k(e.updated_at||e.created_at,a)})]}),s.jsx("div",{className:"mb-2.5 min-h-[2.5rem]",children:e.last_message?s.jsxs("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed",children:[e.last_message.role==="user"?s.jsx(E,{size:10,className:"inline mr-1 -mt-0.5 opacity-60"}):s.jsx($,{size:10,className:"inline mr-1 -mt-0.5 opacity-60"}),e.last_message.content.replace(/\n/g," ").slice(0,100)]}):s.jsx("p",{className:"text-xs text-muted-foreground italic",children:a("sessions.noMessages")})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx(f,{children:e._project}),e.platform&&s.jsx(f,{variant:"info",children:e.platform}),s.jsxs("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[e.history_count," msgs"]})]})]})},`${e._project}-${e.id}`))})]})}export{F as default};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{c as _e,k as qe,r as i,m as mt,o as xt,n as ht,p as ft,l as bt,q as wt,s as Xe,t as $e,v as Ye,w as gt,x as kt,y as yt,z as jt,A as vt,D as Nt,E as Ct,j as t,B as Z,G as St,I as Ie,H as ee,J as Oe,T as _t,W as Mt}from"./index-B2JL40NF.js";import{X as Ee,M as Fe}from"./Modal-JbmTZbCL.js";import{C as Lt,S as Tt}from"./ChatMarkdown-CKIl8nVw.js";import{t as At,L as Pt}from"./session-utils-D9njomRn.js";import{n as It,i as Kt,a as He,b as zt,s as $t,w as Ke}from"./desktop-D4Z7M9RM.js";import{R as Dt,W as Rt}from"./wifi-off-DuwKaMRJ.js";import{S as Ut}from"./search-Ci4i20HH.js";import{C as Ce}from"./circle-BWSc4-qr.js";import{P as Bt}from"./pencil-BD6oAfUg.js";import{T as Ot}from"./trash-2-C5_ZLIsu.js";import{B as Et,U as Ft}from"./user-DHBITt1w.js";import{S as Ht}from"./shield-check-DjJz3hYk.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Wt=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Vt=_e("database",Wt);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Jt=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],We=_e("message-square-plus",Jt);/**
|
|
12
|
+
* @license lucide-react v0.487.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const qt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Xt=_e("panel-left",qt);/**
|
|
17
|
+
* @license lucide-react v0.487.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Yt=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],Gt=_e("terminal",Yt),Qt=9e4;function Me(e){return e?e.startsWith("💭 ")||e.startsWith("🔧 ")||e.startsWith("📤 ")||e.startsWith("⏳ "):!1}function ze(e){if(!e)return!1;const r=e.replace(/\s+/g," ").trim();return/^Agent 提问(?:\s*\(\d+\/\d+\))?/i.test(r)||r.includes("请回复选项编号")||r.includes("直接输入你的回答")||r.includes("等待你的回复")||r.includes("请直接回复")||r.includes("请输入你的回答")}function Se(e,r,s){if(r)return e.find(o=>o.id===r);if(s)return e.find(o=>o.preview&&o.turnKey===s)}function Zt(e,r,s){if(!e.preview||!s||e.turnKey!==s)return!1;const o=e.streamTargetContent??e.content;return!!(r&&o===r&&!Me(o))}function Ge(e){if(!e)return"";const r=e.match(/\[User Message\]\s*([\s\S]*?)\s*\[\/User Message\]/);return r?r[1]||"":e}function er(e){return e.map((r,s)=>({id:r.id||`${s}-${r.timestamp||r.role}`,role:r.role==="user"?"user":r.role==="system"?"system":"assistant",content:r.role==="user"?Ge(r.content):r.content,kind:r.kind==="progress"||r.kind==="system"?"progress":"final",order:s,timestamp:r.timestamp}))}function Qe(e){return{id:e.id,project:e.workspaceId,name:e.title,live:e.live,createdAt:e.createdAt,updatedAt:e.updatedAt,excerpt:Ge(e.excerpt),agentType:e.agentType,bridgeSessionKey:e.bridgeSessionKey}}function Ze(e){return[...e].sort((r,s)=>r.live!==s.live?r.live?-1:1:(s.updatedAt||s.createdAt||"").localeCompare(r.updatedAt||r.createdAt||""))}function tr(e,r){return r?[e.name,e.excerpt,e.bridgeSessionKey||""].join(" ").toLowerCase().includes(r):!0}function Ve(e){return[...e].sort((r,s)=>{const o=r.timestamp?new Date(r.timestamp).getTime():Number.NaN,d=s.timestamp?new Date(s.timestamp).getTime():Number.NaN,k=Number.isFinite(o),f=Number.isFinite(d);return k&&f&&o!==d?o-d:r.order!==s.order?r.order-s.order:r.id.localeCompare(s.id)})}function Je(e){if(!e)return"";const r=new Date(e);return Number.isNaN(r.getTime())?"":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(r)}function rr(e){switch(e){case"starting":return"启动中";case"api_ready":return"服务就绪";case"error":return"运行异常";default:return"未启动"}}function ar(e){if(!(e!=null&&e.startsWith("desktop:")))return"";const[,r=""]=e.split(":");return r}function nr(e){return Array.isArray(e)?e.map(r=>Array.isArray(r)?r.map(s=>It(s)).filter(s=>!!s):[]).filter(r=>r.length>0):[]}function et(e,r,s){const o=e.filter(d=>d.project!==r);return o.push({project:r,sessions:s}),o.sort((d,k)=>d.project.localeCompare(k.project))}function sr(e,r,s){var k;const o=((k=e.find(f=>f.project===r))==null?void 0:k.sessions)||[],d=Ze([s,...o.filter(f=>f.id!==s.id)]);return et(e,r,d)}function ir(e){return e.some(r=>r.some(s=>Kt(s)))}function or(e,r){return e==="stopping"?"Stopping current task…":e==="error"?"":e==="awaiting_input"?"Agent is waiting for your reply.":e==="permission_submitted"?"Permission sent. Waiting for the agent to continue…":e==="awaiting_permission"?"Waiting for your permission response.":r?"Agent is typing…":e==="running"?"Task is running…":""}function lr(e){return e==="running"||e==="awaiting_permission"||e==="permission_submitted"||e==="stopping"}function dr(e){return e!=="idle"&&e!=="awaiting_input"&&e!=="error"}function cr(e){return e!=="awaiting_input"&&e!=="awaiting_permission"&&e!=="permission_submitted"&&e!=="stopping"}function tt(){return qe()==="local_core"?{chatTitle:"本地对话",chatHeading:"本地对话",chatDescription:"浏览线程、切换工作区,并与本地 AI Core 保持同步。",scopeLabel:"当前工作区",scopeSelectPlaceholder:"选择工作区",searchPlaceholder:"搜索线程、联系人或消息摘要",startRuntimeLabel:"启动运行时",startingRuntimeLabel:"启动中…",newThreadLabel:"新建线程",pendingRestartLabel:"最新配置已经保存,但当前对话仍在使用旧运行时状态。请重启运行时以应用配置。",emptySelectionLabel:"选择工作区后即可开始对话。",emptyThreadsLabel:"当前还没有线程。",emptySearchLabel:"没有匹配的线程。",collectionLabel:"线程",activeScopeLabel:"当前工作区",activeConversationFallback:"新对话",startConversationLabel:"选择工作区后即可开始聊天。",runtimeOnlineLabel:"运行时在线",runtimeOfflineLabel:"运行时离线",emptyConversationLabel:"发送一条消息,即可在当前工作区创建新线程。",startFirstPlaceholder:"请先启动运行时",waitingRuntimePlaceholder:"正在等待运行时通道连接",sendPlaceholder:"输入一条发给当前线程的消息",permissionUnsupportedLabel:"当前代理无法在此对话中继续交互式审批。请切换到支持的代理,或调整运行时权限后重试。",replyTimeoutLabel:"审批回复已发送,但代理没有继续执行。该请求可能暂不支持本地运行时继续处理。"}:{chatTitle:"桌面对话",chatHeading:"桌面对话",chatDescription:"",scopeLabel:"当前项目",scopeSelectPlaceholder:"选择项目",searchPlaceholder:"搜索会话、用户或消息摘要",startRuntimeLabel:"启动服务",startingRuntimeLabel:"启动中…",newThreadLabel:"新建会话",pendingRestartLabel:"最新配置已经保存,但当前对话仍在使用旧服务状态。请重启桌面服务以应用配置。",emptySelectionLabel:"选择项目后即可开始对话。",emptyThreadsLabel:"当前还没有桌面会话。",emptySearchLabel:"没有匹配的会话。",collectionLabel:"会话",activeScopeLabel:"当前项目",activeConversationFallback:"新桌面对话",startConversationLabel:"选择项目后即可开始聊天。",runtimeOnlineLabel:"桥接在线",runtimeOfflineLabel:"桥接离线",emptyConversationLabel:"发送一条消息,即可在当前项目中创建桌面会话。",startFirstPlaceholder:"请先启动服务",waitingRuntimePlaceholder:"正在等待桌面桥接连接",sendPlaceholder:"输入一条发给桌面通道的消息",permissionUnsupportedLabel:"当前代理无法在桌面对话中继续交互式审批。请切换到支持的代理,或调整代理权限与 work_dir 后重试。",replyTimeoutLabel:"审批回复已发送,但代理没有继续执行。当前代理或请求可能暂不支持桌面续接。"}}function ur({requestedProject:e,selectedProject:r,setSelectedProject:s,clearReplyTimeout:o,updateTaskState:d,setTyping:k}){const[f,b]=i.useState(null),[A,K]=i.useState(!0),z=qe(),N=z==="electron",c=(f==null?void 0:f.phase)==="api_ready",v=c,C=i.useCallback(async()=>{const S=await mt();b(S),!S.roles.conversation.lastError&&!r&&!e&&S.settings.defaultProject&&s(S.settings.defaultProject)},[e,r,s]);return i.useEffect(()=>{C().finally(()=>K(!1));const S=xt($=>{b($),($.phase==="stopped"||$.phase==="error")&&(k(!1),o(),d("idle"))});return()=>{o(),S()}},[o,C,k,d]),i.useMemo(()=>({loading:A,refreshRuntime:C,runtime:f,runtimeProvider:z,serviceRunning:c,showSessionKey:N,transportReady:v}),[A,C,f,z,c,N,v])}function pr({current:e,requested:r,runtimeDefault:s,workspaceIds:o}){return e&&o.includes(e)?e:r&&o.includes(r)?r:s&&o.includes(s)?s:o[0]||""}function mr({activeThreadId:e,requestedWorkspaceId:r,requestedThreadId:s,runtimeDefaultWorkspaceId:o,runtimeProvider:d,searchParams:k,serviceRunning:f,selectedWorkspaceId:b,workspaceIds:A,threadGroups:K,threadSearch:z,setSelectedKnowledgeBaseIds:N,setActiveRunId:c,setActiveSessionAgentType:v,setActiveSessionId:C,setActiveSessionKey:S,setActiveSessionName:$,setBridgeError:_,setMessages:M,setPendingPermissionRequest:P,setProjects:J,setSearchParams:n,setSelectedProject:L,setThreadGroups:I,setTyping:U,applyLocalCoreThreadDetail:D,clearReplyTimeout:y,updateTaskState:w,holdBlankComposerRef:O,lastSessionByProjectRef:q,nextMessageOrderRef:g,pendingTurnRef:p,progressSequenceByTurnRef:j}){const X=i.useMemo(()=>{var m;return((m=K.find(h=>h.project===b))==null?void 0:m.sessions)||[]},[b,K]),H=i.useMemo(()=>{const m=z.trim().toLowerCase();return A.map(h=>{var l;const R=(((l=K.find(x=>x.project===h))==null?void 0:l.sessions)||[]).filter(x=>tr(x,m));return{project:h,sessions:R}}).filter(h=>h.sessions.length>0||!m&&h.project===b)},[b,K,z,A]),Q=i.useCallback(async m=>{if(!m||!f)return[];const h=Ze((await ht(m)).threads.map(l=>Qe(l))),R=h.find(l=>l.id===e);return R!=null&&R.agentType&&v(R.agentType),I(l=>et(l,m,h)),h},[e,f,v,I,!0]),W=i.useCallback(async(m,h)=>{if(!(!m||!h||!f)){O.current=!1,w("idle"),P(null),U(!1);{const R=await ft(h);D(R);return}}},[D,O,q,g,p,j,f,c,v,C,S,$,N,M,P,L,I,U,w,!0]),B=i.useCallback(async()=>{if(!f)return J([]),I([]),N([]),[];const m=(await bt()).workspaces.map(l=>l.id);J(m);const h=pr({current:b,requested:r,runtimeDefault:o,workspaceIds:m}),R=(await Promise.all(m.map(async l=>({project:l,sessions:await Q(l)})))).sort((l,x)=>l.project.localeCompare(x.project));return I(R),L(h),R},[Q,r,o,b,f,J,N,L,I,!0]);return i.useEffect(()=>{if(!f){I([]),M([]),P(null),N([]),v(""),c(""),_(""),p.current=null,g.current=0,j.current={},w("idle"),U(!1),y();return}B()},[y,g,p,j,B,f,c,v,_,M,P,N,I,U,w]),i.useEffect(()=>{if(!b||!f||X.find(x=>x.id===e))return;const h=r===b?s:"",R=q.current[b];if(!e&&O.current)return;const l=X.find(x=>x.id===h)||X.find(x=>x.id===R)||X[0];if(l){U(!1),w("idle"),_(""),y(),W(b,l.id);return}U(!1),w("idle"),_(""),y(),C(""),S(""),$(""),v(""),c(""),M([]),p.current=null,g.current=0,j.current={}},[e,y,O,q,W,g,p,j,s,r,b,f,c,v,C,S,$,_,M,U,X,w]),i.useEffect(()=>{if(!b&&!e)return;const m=new URLSearchParams(k);b?m.set("project",b):m.delete("project"),e?m.set("session",e):m.delete("session"),m.toString()!==k.toString()&&n(m,{replace:!0})},[e,k,b,n]),{filteredThreadGroups:H,loadActiveThread:W,refreshThreadsForWorkspace:Q,refreshWorkspacesAndThreads:B}}function xr({activeAgentType:e,activeThreadId:r,armReplyTimeout:s,clearActionStatuses:o,clearReplyTimeout:d,reserveNextMessageOrder:k,runtimeProvider:f,selectedWorkspaceId:b,sendAction:A,settlePreviewMessages:K,setActiveRunId:z,setBridgeError:N,setMessages:c,setPendingPermissionRequest:v,setPendingBridgeActionId:C,setTyping:S,updateTaskState:$}){return{handleBridgeAction:i.useCallback(async(P,J)=>{if(!r)return;const n=He(J.data)||J.data,L=He(J.data)||J.text||J.data,I=k(),U=`${crypto.randomUUID()}-user-action`;let D=!1;C(P.id),c(y=>y.map(w=>w.id===P.id?{...w,actionPending:!0}:w)),v(y=>y&&y.id===P.id?{...y,actionPending:!0}:y);try{c(w=>[...w,{id:U,role:"user",content:L,order:I,timestamp:new Date().toISOString()}]);const y=await A(r,n);z(y.runId),D=!0,N(""),K(P.actionReplyCtx),S(!0),d(),o(),P.actionMode==="permission"&&P.actionInteractive?($("permission_submitted","bridge-permission-submitted"),s("permission_continue"),v(null),c(w=>w.map(O=>O.id===P.id?{...O,actions:[],actionPending:!1,actionStatus:"Permission sent. Waiting for the agent to continue…"}:O))):($("running","bridge-action-submitted"),s())}catch(y){N(y instanceof Error?y.message:"Failed to send permission response."),c(w=>w.filter(O=>O.id!==U)),$(P.actionMode==="permission"&&P.actionInteractive?"awaiting_permission":"error",P.actionMode==="permission"&&P.actionInteractive?"bridge-permission-submit-failed":"bridge-action-submit-failed"),S(!1),v(w=>w&&w.id===P.id?{...w,actionPending:!1}:w)}finally{C(null),c(y=>y.map(w=>w.id===P.id?{...w,actionPending:!1,actions:D?w.actions||[]:w.actions}:w))}},[r,s,o,d,k,A,K,z,N,c,v,C,S,$,!0])}}function hr(e){var s;if(!e.id||e.role!=="assistant"||e.actionMode!=="permission"||!e.content)return null;const r=((s=e.actions)==null?void 0:s.filter(o=>o.length>0))||[];return r.length===0?null:{id:e.id,content:e.content,actions:r,actionReplyCtx:e.actionReplyCtx,actionPending:e.actionPending,actionStatus:e.actionStatus,actionMode:"permission",actionInteractive:!0}}function fr(e){return e==="awaiting_permission"?"awaiting_permission":"idle"}function br(e,r){return r?"awaiting_permission":e?"awaiting_input":"idle"}function wr(e,r){return r?"bridge-buttons-awaiting-permission":e?"bridge-buttons-awaiting-input":"bridge-buttons-idle"}function gr(e){const r=e||"This agent",s=tt();return s.permissionUnsupportedLabel.startsWith("This agent")?s.permissionUnsupportedLabel:`${r} ${s.permissionUnsupportedLabel.replace(/^This agent\s+/i,"")}`}function kr(e){return e.type==="typing_stop"||e.type==="buttons"||e.type==="card"?!0:e.type==="reply"&&!Me(e.content)}function yr({activeAgentType:e,activeBridgeSessionKey:r,armReplyTimeout:s,clearActionStatuses:o,clearReplyTimeout:d,finalizeTurnMessages:k,nextProgressMessageId:f,pendingTurnRef:b,progressSequenceByTurnRef:A,refreshThreadsForWorkspace:K,reserveAssistantMessageOrder:z,settlePreviewMessages:N,setBridgeError:c,setMessages:v,setPendingPermissionRequest:C,setTyping:S,taskStateRef:$,updateTaskState:_}){const M=zt(e),P=i.useCallback(n=>{cr($.current)&&_("running",n)},[$,_]),J=i.useCallback(n=>{console.info("[desktop-chat] bridge_event",{type:n.type,sessionKey:n.sessionKey,replyCtx:n.replyCtx,taskState:$.current});const L=ar(n.sessionKey);if(L&&kr(n)&&K(L),!(!n.sessionKey||n.sessionKey!==r))switch(n.type){case"preview_start":if(ze(n.content)){d(),S(!1),b.current=null,o(),_("awaiting_input","bridge-preview-awaiting-input"),C(null),c(""),v(g=>{const p=Se(g,n.previewHandle,n.replyCtx),j=(p==null?void 0:p.id)||n.previewHandle||`${n.replyCtx||crypto.randomUUID()}-preview`,F=g.filter(X=>X.id!==j);return F.push({id:j,role:"assistant",content:M?(p==null?void 0:p.content)||"":n.content||"",streamTargetContent:M?n.content||"":void 0,kind:"progress",order:(p==null?void 0:p.order)??z(n.sessionKey),timestamp:(p==null?void 0:p.timestamp)||new Date().toISOString(),turnKey:n.replyCtx,preview:!0,previewPlainText:M}),F});break}o(),S(!0),P("bridge-preview-start"),C(null),s(),c(""),v(g=>{const p=Se(g,n.previewHandle,n.replyCtx),j=(p==null?void 0:p.id)||n.previewHandle||`${n.replyCtx||crypto.randomUUID()}-preview`,F=g.filter(X=>X.id!==j);return F.push({id:j,role:"assistant",content:M?(p==null?void 0:p.content)||"":n.content||"",streamTargetContent:M?n.content||"":void 0,kind:"progress",order:(p==null?void 0:p.order)??z(n.sessionKey),timestamp:(p==null?void 0:p.timestamp)||new Date().toISOString(),turnKey:n.replyCtx,preview:!0,previewPlainText:M}),F});break;case"update_message":if(ze(n.content)){d(),S(!1),b.current=null,o(),_("awaiting_input","bridge-update-awaiting-input"),C(null),c(""),v(g=>{const p=Se(g,n.previewHandle,n.replyCtx);return p?g.map(j=>j.id===p.id?{...j,content:M?j.content:n.content||"",streamTargetContent:M?n.content||"":void 0,preview:!0,previewPlainText:M}:j):[...g,{id:n.previewHandle||`${n.replyCtx||crypto.randomUUID()}-preview`,role:"assistant",content:M?"":n.content||"",streamTargetContent:M?n.content||"":void 0,kind:"progress",order:z(n.sessionKey),timestamp:new Date().toISOString(),turnKey:n.replyCtx,preview:!0,previewPlainText:M}]});break}o(),S(!0),P("bridge-update-message"),C(null),s(),c(""),v(g=>{const p=Se(g,n.previewHandle,n.replyCtx);return p?g.map(j=>j.id===p.id?{...j,content:M?j.content:n.content||"",streamTargetContent:M?n.content||"":void 0,preview:!0,previewPlainText:M}:j):[...g,{id:n.previewHandle||`${n.replyCtx||crypto.randomUUID()}-preview`,role:"assistant",content:M?"":n.content||"",streamTargetContent:M?n.content||"":void 0,kind:"progress",order:z(n.sessionKey),timestamp:new Date().toISOString(),turnKey:n.replyCtx,preview:!0,previewPlainText:M}]});break;case"delete_message":v(g=>g.filter(p=>p.id!==n.previewHandle));break;case"typing_start":o(),S(!0),P("bridge-typing-start"),C(null),c(""),s();break;case"typing_stop":S(!1),d(),b.current=null,o(),_(fr($.current),$.current==="awaiting_permission"?"bridge-typing-stop-preserve-permission":"bridge-typing-stop"),N(n.replyCtx),k(n.replyCtx);break;case"reply":{const g=ze(n.content);o(),S(!g),g?(d(),b.current=null,_("awaiting_input","bridge-reply-awaiting-input")):(P("bridge-reply"),s()),C(null),c("");const p=f(n.replyCtx);!Me(n.content)&&n.replyCtx&&delete A.current[n.replyCtx],c(""),v(j=>[...j.filter(F=>!Zt(F,n.content,n.replyCtx)&&F.id!==p),{id:p,role:"assistant",content:n.content||"",kind:"progress",order:z(n.sessionKey),timestamp:new Date().toISOString(),turnKey:n.replyCtx}]);break}case"buttons":d(),S(!1),b.current=null,c(""),o(),N(n.replyCtx);const I=`${n.replyCtx||crypto.randomUUID()}-buttons`,U=nr(n.buttonRows||n.buttons),D=ir(U),y=D&&$t(e),w=D&&!y?[]:U,O=w,q=D&&!y?gr(e):void 0;v(g=>g.find(j=>j.id===I)?g.map(j=>j.id===I?{...j,content:n.content||j.content,actions:O,actionReplyCtx:n.replyCtx,actionPending:!1,actionMode:D?"permission":"generic",actionInteractive:y,actionStatus:q}:j):[...g,{id:I,role:"assistant",content:n.content||"Permission required before continuing.",kind:"progress",order:z(n.sessionKey),timestamp:new Date().toISOString(),turnKey:n.replyCtx,actions:O,actionReplyCtx:n.replyCtx,actionPending:!1,actionMode:D?"permission":"generic",actionInteractive:y,actionStatus:q}]),C(g=>{if(!D||!y)return null;const p={id:I,role:"assistant",content:n.content||"Permission required before continuing.",actions:w,actionReplyCtx:n.replyCtx,actionPending:!1,actionMode:"permission",actionStatus:q};return hr(p)||g}),_(br(U.length>0,y),wr(U.length>0,y));break;case"card":d(),S(!1),b.current=null,o(),_("idle","bridge-card"),C(null),N(n.replyCtx),k(n.replyCtx),c(""),v(g=>[...g,{id:`${n.replyCtx||crypto.randomUUID()}-card`,role:"assistant",content:"Interactive card received. Open the session in the standard Sessions view for full controls.",order:z(n.sessionKey),timestamp:new Date().toISOString()}]);break}},[M,e,r,s,o,d,k,f,b,A,K,z,N,c,v,C,S,P,_]);i.useEffect(()=>{const n=wt(L=>{J(L)});return()=>{d(),n()}},[d,J])}function jr(e){yr({activeAgentType:e.activeAgentType,activeBridgeSessionKey:e.activeBridgeSessionKey,armReplyTimeout:e.armReplyTimeout,clearActionStatuses:e.clearActionStatuses,clearReplyTimeout:e.clearReplyTimeout,finalizeTurnMessages:e.finalizeTurnMessages,nextProgressMessageId:e.nextProgressMessageId,pendingTurnRef:e.pendingTurnRef,progressSequenceByTurnRef:e.progressSequenceByTurnRef,refreshThreadsForWorkspace:e.refreshThreadsForWorkspace,reserveAssistantMessageOrder:e.reserveAssistantMessageOrder,settlePreviewMessages:e.settlePreviewMessages,setBridgeError:e.setBridgeError,setMessages:e.setMessages,setPendingPermissionRequest:e.setPendingPermissionRequest,setTyping:e.setTyping,taskStateRef:e.taskStateRef,updateTaskState:e.updateTaskState});const{handleBridgeAction:r}=xr({activeAgentType:e.activeAgentType,activeBridgeSessionKey:e.activeBridgeSessionKey,activeRunId:e.activeRunId,activeThreadId:e.activeThreadId,armReplyTimeout:e.armReplyTimeout,clearActionStatuses:e.clearActionStatuses,clearReplyTimeout:e.clearReplyTimeout,reserveNextMessageOrder:e.reserveNextMessageOrder,runtimeProvider:e.runtimeProvider,selectedWorkspaceId:e.selectedWorkspaceId,sendAction:e.sendAction,settlePreviewMessages:e.settlePreviewMessages,setActiveRunId:e.setActiveRunId,setBridgeError:e.setBridgeError,setMessages:e.setMessages,setPendingPermissionRequest:e.setPendingPermissionRequest,setPendingBridgeActionId:e.setPendingBridgeActionId,setTyping:e.setTyping,updateTaskState:e.updateTaskState,taskStateRef:e.taskStateRef});return{handleBridgeAction:r}}function vr({activeRunId:e,activeThreadId:r,activeBridgeSessionKey:s,availableKnowledgeBases:o,brandingNewThreadLabel:d,draft:k,loadActiveThread:f,selectedKnowledgeBaseIds:b,runtimeProvider:A,selectedProject:K,taskState:z,updateTaskState:N,applyLocalCoreThreadDetail:c,armReplyTimeout:v,clearReplyTimeout:C,refreshSessionsForProject:S,reserveNextMessageOrder:$,settlePreviewMessages:_,setActiveRunId:M,setActiveSessionId:P,setActiveSessionKey:J,setActiveSessionName:n,setBridgeError:L,setDraft:I,setMessages:U,setPendingPermissionRequest:D,setSending:y,setTyping:w,holdBlankComposerRef:O,lastSessionByProjectRef:q,nextMessageOrderRef:g,pendingTurnRef:p,progressSequenceByTurnRef:j,taskStateRef:F}){const H=i.useCallback(m=>{if(b.length===0)return Ke(m);const h=b.map(R=>o.find(l=>l.id===R)).filter(R=>!!R);return h.length===0?Ke(m):Ke(m,[["[Selected Knowledge Bases]",...h.map(R=>`- id: ${R.id} | name: ${R.name}`),"[/Selected Knowledge Bases]"].join(`
|
|
22
|
+
`)])},[o,b]),Q=i.useCallback(async()=>{if(!K)throw new Error("Choose a project first");if(r)return{id:r,sessionKey:s};const m=await Xe(K,`${d} ${new Date().toLocaleTimeString()}`);return c(m),await S(K),{id:m.id,sessionKey:m.bridgeSessionKey||""}},[s,r,c,d,S,K,!0]),W=i.useCallback(async()=>{if(!k.trim()||!K)return;const m=k.trim(),h=z==="awaiting_input",R=h?m:H(m),l=$();I(""),y(!0);try{const x=await Q();if(console.info("[desktop-chat] send",{runtimeProvider:A,selectedProject:K,threadId:x.id,sessionKey:x.sessionKey,selectedKnowledgeBaseIds:b}),p.current={sessionKey:x.sessionKey,userOrder:l},D(null),U(T=>[...T,{id:`${crypto.randomUUID()}-user`,role:"user",content:m,order:l,timestamp:new Date().toISOString()}]),N("running","send-started"),w(!0),L(""),x.id&&await $e(x.id,b),v(),x.id){const T=h?await Ye(x.id,R):await gt(x.id,R);M(T.runId)}else throw new Error("Managed desktop thread transport is unavailable.")}catch(x){C(),p.current=null,_(),D(null),w(!1),N("error","send-failed"),L(x instanceof Error?x.message:"Failed to send the message.")}finally{y(!1)}},[v,H,C,k,Q,z,p,$,b,K,M,L,I,U,D,y,_,w,N,!0]),B=i.useCallback(async()=>{if(!(!K||z==="stopping")){L(""),C(),_(),D(null),w(!1),N("stopping","stop-requested");try{if(e)await kt(e);else throw new Error("No active run to stop.");window.setTimeout(()=>{F.current==="stopping"&&N("idle","stop-timeout-complete")},1500)}catch(m){N("error","stop-failed"),L(m instanceof Error?m.message:"Failed to stop the current task.")}}},[e,C,L,D,_,w,K,z,F,N,!0]);return{handleSend:W,handleStopTask:B}}function Nr({activeThreadId:e,brandingNewThreadLabel:r,deleteTarget:s,renameDraft:o,renameTarget:d,runtimeProvider:k,searchParams:f,selectedKnowledgeBaseIds:b,selectedProject:A,updateTaskState:K,applyLocalCoreThreadDetail:z,clearReplyTimeout:N,refreshSessionsForProject:c,setActiveRunId:v,setActiveSessionAgentType:C,setActiveSessionId:S,setActiveSessionKey:$,setActiveSessionName:_,setBridgeError:M,setDeleteTarget:P,setMessages:J,setPendingPermissionRequest:n,setPendingSessionAction:L,setRenameDraft:I,setRenameTarget:U,setSearchParams:D,setTyping:y,holdBlankComposerRef:w,nextMessageOrderRef:O,pendingTurnRef:q,progressSequenceByTurnRef:g}){const j=k==="local_core",F=i.useCallback(()=>{w.current=!0,S(""),$(""),_(""),C(""),v(""),J([]),n(null),y(!1),K("idle"),M(""),q.current=null,O.current=0,g.current={},N()},[N,w,O,q,g,v,C,S,$,_,M,J,n,y,K]),X=i.useCallback(async()=>{if(A){if(j){L("rename");try{const B=await Xe(A,`${r} ${new Date().toLocaleTimeString()}`);if(b.length>0){const h=(await $e(B.id,b)).knowledgeBaseIds;B.selectedKnowledgeBaseIds=h}else B.selectedKnowledgeBaseIds=[];await c(A),z(B);const m=new URLSearchParams(f);m.set("project",A),m.set("session",B.id),D(m,{replace:!0})}finally{L(null)}return}F()}},[z,r,c,F,f,b,A,L,D,j,!0]),H=i.useCallback((B,m)=>{U({project:B,id:m.id,name:m.name}),I(m.name)},[I,U]),Q=i.useCallback(async()=>{if(d){L("rename");try{const B=o.trim();await yt(d.id,B),d.id===e&&_(B),await c(d.project),U(null),I("")}finally{L(null)}}},[e,c,o,d,_,L,I,U,!0]),W=i.useCallback(async()=>{if(s){L("delete");try{await jt(s.id),s.id===e&&F(),await c(s.project),P(null)}finally{L(null)}}},[e,s,c,F,P,L,!0]);return{handleCreateNew:X,handleDeleteSession:W,handleRenameSession:Q,openRenameModal:H}}function Cr({activeRunId:e,activeThreadId:r,activeBridgeSessionKey:s,availableKnowledgeBases:o,brandingNewThreadLabel:d,deleteTarget:k,draft:f,loadActiveThread:b,renameDraft:A,renameTarget:K,runtimeProvider:z,searchParams:N,selectedKnowledgeBaseIds:c,selectedWorkspaceId:v,taskState:C,updateTaskState:S,applyLocalCoreThreadDetail:$,armReplyTimeout:_,clearReplyTimeout:M,refreshSessionsForProject:P,reserveNextMessageOrder:J,settlePreviewMessages:n,setActiveRunId:L,setActiveSessionAgentType:I,setActiveSessionId:U,setActiveSessionKey:D,setActiveSessionName:y,setBridgeError:w,setDeleteTarget:O,setDraft:q,setMessages:g,setPendingPermissionRequest:p,setPendingSessionAction:j,setRenameDraft:F,setRenameTarget:X,setSearchParams:H,setSending:Q,setTyping:W,holdBlankComposerRef:B,lastSessionByProjectRef:m,nextMessageOrderRef:h,pendingTurnRef:R,progressSequenceByTurnRef:l,taskStateRef:x}){const T={runtimeProvider:z,selectedProject:v,updateTaskState:S,applyLocalCoreThreadDetail:$,clearReplyTimeout:M,refreshSessionsForProject:P,setBridgeError:w,setMessages:g,setPendingPermissionRequest:p,setTyping:W,holdBlankComposerRef:B,nextMessageOrderRef:h,pendingTurnRef:R,progressSequenceByTurnRef:l,taskStateRef:x},Y={setActiveRunId:L,setActiveSessionAgentType:I,setActiveSessionId:U,setActiveSessionKey:D,setActiveSessionName:y},G={setDeleteTarget:O,setPendingSessionAction:j,setRenameDraft:F,setRenameTarget:X},V={holdBlankComposerRef:B,lastSessionByProjectRef:m,nextMessageOrderRef:h,pendingTurnRef:R,progressSequenceByTurnRef:l,taskStateRef:x},te={setBridgeError:w,setMessages:g,setPendingPermissionRequest:p,setTyping:W},{handleSend:pe,handleStopTask:ne}=vr({activeRunId:e,activeThreadId:r,activeBridgeSessionKey:s,availableKnowledgeBases:o,brandingNewThreadLabel:d,draft:f,loadActiveThread:b,selectedKnowledgeBaseIds:c,taskState:C,armReplyTimeout:_,reserveNextMessageOrder:J,settlePreviewMessages:n,setDraft:q,setSending:Q,...T,...Y,...te,...V}),{handleCreateNew:me,handleDeleteSession:se,handleRenameSession:ie,openRenameModal:oe}=Nr({activeThreadId:r,brandingNewThreadLabel:d,deleteTarget:k,renameDraft:A,renameTarget:K,searchParams:N,selectedKnowledgeBaseIds:c,setSearchParams:H,...T,...Y,...G,...te});return{handleCreateNew:me,handleDeleteSession:se,handleRenameSession:ie,handleSend:pe,handleStopTask:ne,openRenameModal:oe}}function Sr(e,r){if(!r)return"";if(!e||!r.startsWith(e))return r.slice(0,Math.min(r.length,Math.max(1,Math.ceil(r.length/24))));if(e===r)return r;const s=r.length-e.length,o=s>160?14:s>80?8:s>24?4:2;return r.slice(0,Math.min(r.length,e.length+o))}function _r({activeThreadId:e,brandingReplyTimeoutLabel:r,setSelectedKnowledgeBaseIds:s,setActiveRunId:o,setActiveSessionAgentType:d,setActiveSessionId:k,setActiveSessionKey:f,setActiveSessionName:b,setBridgeError:A,setSelectedProject:K,setThreadGroups:z}){const[N,c]=i.useState([]),[v,C]=i.useState(null),[S,$]=i.useState(!1),[_,M]=i.useState("idle"),P=i.useRef(null),J=i.useRef("reply"),n=i.useRef({}),L=i.useRef(0),I=i.useRef(null),U=i.useRef(!1),D=i.useRef({}),y=i.useRef("idle"),w=i.useRef(""),O=i.useMemo(()=>Ve(N),[N]),q=lr(_),g=dr(_),p=or(_,S);i.useEffect(()=>{w.current=e},[e]);const j=i.useCallback((l,x="unspecified")=>{const T=y.current;y.current=l,M(l),T!==l&&console.info("[desktop-chat] task_state",{from:T,to:l,reason:x,threadId:w.current})},[]),F=i.useCallback(()=>{P.current&&(window.clearTimeout(P.current),P.current=null)},[]),X=i.useCallback((l="reply")=>{F(),J.current=l,P.current=window.setTimeout(()=>{$(!1),I.current=null,C(null),j("idle","reply-timeout"),A(l==="permission_continue"?r:"Agent did not respond in time. Check AgentDock runtime logs or adjust the model/provider.")},Qt)},[r,F,A,j]),H=i.useCallback(()=>{c(l=>l.map(x=>x.actionStatus||x.actionPending?{...x,actionPending:!1,actionStatus:void 0}:x))},[]),Q=i.useCallback(l=>{c(x=>{let T=!1;const Y=x.map(G=>!G.preview||l&&G.turnKey!==l?G:(T=!0,{...G,content:G.streamTargetContent??G.content,streamTargetContent:void 0,preview:!1,previewPlainText:!1}));return T?Y:x})},[]),W=i.useCallback(()=>{const l=L.current;return L.current+=1,l},[]),B=i.useCallback(l=>{const x=I.current;if(x&&l&&x.sessionKey===l){const T=x.userOrder+1;L.current<T&&(L.current=T)}return W()},[W]),m=i.useCallback(l=>{const x=l||crypto.randomUUID(),T=(D.current[x]||0)+1;return D.current[x]=T,`${x}-progress-${T}`},[]),h=i.useCallback(l=>{l&&c(x=>{const T=x.filter(V=>V.turnKey===l&&!V.preview);if(T.length===0)return x;const Y=[...T].reverse().find(V=>!Me(V.content)),G=Y==null?void 0:Y.id;return x.map(V=>V.turnKey!==l||V.preview?V:{...V,kind:G&&V.id===G?"final":"progress"})})},[]),R=i.useCallback(l=>{n.current[l.workspaceId]=l.id,K(l.workspaceId),k(l.id),f(l.bridgeSessionKey||""),b(l.title),d(l.agentType||""),o(l.runId||""),s(l.selectedKnowledgeBaseIds||[]),C(l.pendingPermissionRequest||null),z(T=>sr(T,l.workspaceId,Qe(l))),U.current=!1,D.current={};const x=er(l.messages||[]);I.current=null,L.current=x.reduce((T,Y)=>Math.max(T,Y.order+1),0),c(Ve(x))},[o,d,k,f,b,s,K,z,C]);return i.useEffect(()=>{if(!N.some(T=>T.preview&&T.previewPlainText&&typeof T.streamTargetContent=="string"&&T.streamTargetContent!==T.content))return;const x=window.setInterval(()=>{c(T=>{let Y=!1;const G=T.map(V=>!V.preview||!V.previewPlainText||typeof V.streamTargetContent!="string"||V.streamTargetContent===V.content?V:(Y=!0,{...V,content:Sr(V.content,V.streamTargetContent)}));return Y?G:T})},32);return()=>{window.clearInterval(x)}},[N]),{applyLocalCoreThreadDetail:R,armReplyTimeout:X,clearActionStatuses:H,clearReplyTimeout:F,holdBlankComposerRef:U,lastSessionByProjectRef:n,messages:N,nextMessageOrderRef:L,pendingPermissionRequest:v,finalizeTurnMessages:h,nextProgressMessageId:m,pendingTurnRef:I,progressSequenceByTurnRef:D,renderedMessages:O,reserveAssistantMessageOrder:B,reserveNextMessageOrder:W,setMessages:c,setPendingPermissionRequest:C,settlePreviewMessages:Q,setTyping:$,taskHint:p,taskInputLocked:g,taskRunning:q,taskState:_,taskStateRef:y,typing:S,updateTaskState:j}}function Mr(){const[e,r]=vt(),[s,o]=i.useState([]),[d,k]=i.useState(""),[f,b]=i.useState([]),[A,K]=i.useState(""),[z,N]=i.useState(""),[c,v]=i.useState(""),[C,S]=i.useState(""),[$,_]=i.useState(""),[M,P]=i.useState(""),[J,n]=i.useState(""),[L,I]=i.useState([]),[U,D]=i.useState([]),[y,w]=i.useState(null),[O,q]=i.useState(""),[g,p]=i.useState(null),[j,F]=i.useState(null),[X,H]=i.useState(null),[Q,W]=i.useState(!1),[B,m]=i.useState(""),h=i.useRef(0),R=i.useRef(null),l=e.get("project")||"",x=e.get("session")||"",T=tt(),{applyLocalCoreThreadDetail:Y,armReplyTimeout:G,clearActionStatuses:V,clearReplyTimeout:te,finalizeTurnMessages:pe,holdBlankComposerRef:ne,lastSessionByProjectRef:me,nextMessageOrderRef:se,nextProgressMessageId:ie,pendingPermissionRequest:oe,pendingTurnRef:xe,progressSequenceByTurnRef:he,renderedMessages:fe,reserveAssistantMessageOrder:Le,reserveNextMessageOrder:ye,setMessages:le,setPendingPermissionRequest:de,settlePreviewMessages:a,setTyping:u,taskHint:E,taskInputLocked:re,taskRunning:je,taskState:ae,taskStateRef:be,typing:ve,updateTaskState:ce}=_r({activeThreadId:A,brandingReplyTimeoutLabel:T.replyTimeoutLabel,setSelectedKnowledgeBaseIds:D,setActiveRunId:_,setActiveSessionAgentType:S,setActiveSessionId:K,setActiveSessionKey:N,setActiveSessionName:v,setBridgeError:m,setSelectedProject:k,setThreadGroups:b}),{loading:Te,refreshRuntime:ue,runtime:Ne,runtimeProvider:we,serviceRunning:De,showSessionKey:rt,transportReady:at}=ur({requestedProject:l,selectedProject:d,setSelectedProject:k,clearReplyTimeout:te,updateTaskState:ce,setTyping:u}),{filteredThreadGroups:nt,loadActiveThread:Re,refreshThreadsForWorkspace:Ue}=mr({activeThreadId:A,requestedWorkspaceId:l,requestedThreadId:x,runtimeDefaultWorkspaceId:Ne==null?void 0:Ne.settings.defaultProject,runtimeProvider:we,searchParams:e,selectedWorkspaceId:d,serviceRunning:De,workspaceIds:s,threadGroups:f,threadSearch:J,setSelectedKnowledgeBaseIds:D,setActiveRunId:_,setActiveSessionAgentType:S,setActiveSessionId:K,setActiveSessionKey:N,setActiveSessionName:v,setBridgeError:m,setMessages:le,setPendingPermissionRequest:de,setProjects:o,setSearchParams:r,setSelectedProject:k,setThreadGroups:b,setTyping:u,applyLocalCoreThreadDetail:Y,clearReplyTimeout:te,updateTaskState:ce,holdBlankComposerRef:ne,lastSessionByProjectRef:me,nextMessageOrderRef:se,pendingTurnRef:xe,progressSequenceByTurnRef:he});i.useEffect(()=>{var ge;(ge=R.current)==null||ge.scrollIntoView({behavior:"smooth"})},[fe,ve]);const Be=i.useCallback(async()=>{try{const ge=await Nt();I(ge.bases||[])}catch{I([])}},[we]);i.useEffect(()=>{Be()},[Be]);const st=i.useCallback(async ge=>{const Ae=Array.from(new Set(ge.map(ke=>String(ke||"").trim()).filter(Boolean))),Pe=h.current+1;if(h.current=Pe,D(Ae),!(!d||!A))try{const ke=we==="local_core"?(await $e(A,Ae)).knowledgeBaseIds:await Ct(d,A,Ae);h.current===Pe&&D(ke)}catch(ke){h.current===Pe&&m(ke instanceof Error?ke.message:"Failed to save selected knowledge bases.")}},[A,we,d,m]),{handleBridgeAction:it}=jr({activeAgentType:C,activeThreadId:A,activeRunId:$,activeBridgeSessionKey:z,runtimeProvider:we,selectedWorkspaceId:d,clearActionStatuses:V,clearReplyTimeout:te,finalizeTurnMessages:pe,nextProgressMessageId:ie,refreshThreadsForWorkspace:Ue,reserveAssistantMessageOrder:Le,reserveNextMessageOrder:ye,settlePreviewMessages:a,setActiveRunId:_,setBridgeError:m,setMessages:le,setPendingBridgeActionId:H,setTyping:u,setPendingPermissionRequest:de,updateTaskState:ce,armReplyTimeout:G,pendingTurnRef:xe,progressSequenceByTurnRef:he,sendAction:Ye,taskStateRef:be}),{handleCreateNew:ot,handleDeleteSession:lt,handleRenameSession:dt,handleSend:ct,handleStopTask:ut,openRenameModal:pt}=Cr({activeRunId:$,activeThreadId:A,activeBridgeSessionKey:z,availableKnowledgeBases:L,brandingNewThreadLabel:T.newThreadLabel,deleteTarget:g,draft:M,loadActiveThread:Re,renameDraft:O,renameTarget:y,runtimeProvider:we,searchParams:e,selectedKnowledgeBaseIds:U,selectedWorkspaceId:d,taskState:ae,updateTaskState:ce,applyLocalCoreThreadDetail:Y,armReplyTimeout:G,clearReplyTimeout:te,refreshSessionsForProject:Ue,reserveNextMessageOrder:ye,settlePreviewMessages:a,setActiveRunId:_,setActiveSessionAgentType:S,setActiveSessionId:K,setActiveSessionKey:N,setActiveSessionName:v,setBridgeError:m,setDeleteTarget:p,setDraft:P,setMessages:le,setPendingPermissionRequest:de,setPendingSessionAction:F,setRenameDraft:q,setRenameTarget:w,setSearchParams:r,setSending:W,setTyping:u,holdBlankComposerRef:ne,lastSessionByProjectRef:me,nextMessageOrderRef:se,pendingTurnRef:xe,progressSequenceByTurnRef:he,taskStateRef:be});return{activeRunId:$,activeSessionId:A,activeSessionKey:z,activeSessionName:c,bridgeError:B,branding:T,deleteTarget:g,draft:M,endRef:R,filteredSessionGroups:nt,handleBridgeAction:it,handleCreateNew:ot,handleDeleteSession:lt,handleRenameSession:dt,handleSend:ct,handleStopTask:ut,availableKnowledgeBases:L,loadActiveSession:Re,loading:Te,openRenameModal:pt,pendingBridgeActionId:X,pendingPermissionRequest:oe,pendingSessionAction:j,projects:s,refreshRuntime:ue,renameDraft:O,renameTarget:y,renderedMessages:fe,runtime:Ne,sending:Q,selectedKnowledgeBaseIds:U,serviceRunning:De,sessionSearch:J,selectedProject:d,setDeleteTarget:p,setDraft:P,setSelectedKnowledgeBaseIds:st,setRenameDraft:q,setRenameTarget:w,setSelectedProject:k,setSessionSearch:n,showSessionKey:rt,taskHint:E,taskInputLocked:re,taskRunning:je,taskState:ae,transportReady:at}}function Lr(e){const r=e.match(/^\s*(?:🔧\s*)?(Tool update)\s*-\s*([^-]+?)\s*-\s*([\s\S]+?)\s*$/i);if(r){const[,o,d,k]=r,f=k.trim();if(Tr(o,d.trim(),f))return null;try{const b=JSON.parse(f),A=typeof b.output=="string"?b.output:b.output??b.error??b;return{title:o,status:d.trim(),output:typeof A=="string"?A:JSON.stringify(A,null,2),label:"工具结果"}}catch{return{title:o,status:d.trim(),output:f,label:"工具结果"}}}const s=e.match(/^\s*🔧\s*(.+?)\s*$/);if(s){const o=s[1].trim();if(/^Tool update\s*-\s*running(?:\s*-\s*)?$/i.test(o))return null;const[d,...k]=o.split(":"),f=k.join(":").trim();return{title:d.trim()||"Tool call",status:"running",output:f,label:"工具调用"}}return null}function Tr(e,r,s){return/^Tool update$/i.test(e.trim())&&/^running$/i.test(r.trim())&&!s.trim()}function Ar(e){const r=e.trim();return/^🔧\s*Tool update\s*-\s*running(?:\s*-\s*)?$/i.test(r)}function Pr({card:e}){const r=e.status.toLowerCase()==="completed";return t.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-slate-200/80 bg-slate-50/95 shadow-[0_8px_22px_rgba(15,23,42,0.04)] dark:border-white/[0.07] dark:bg-[#111820] dark:shadow-none",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-slate-200/80 px-4 py-3 dark:border-white/[0.06]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary dark:text-primary",children:t.jsx(Mt,{size:14})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-semibold text-slate-800 dark:text-slate-100",children:e.title}),t.jsxs("p",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-slate-500 dark:text-slate-400",children:[t.jsx(Gt,{size:12}),e.label]})]})]}),t.jsx("span",{className:ee("shrink-0 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.12em]",r?"bg-primary/10 text-primary dark:text-primary":"bg-amber-500/10 text-amber-700 dark:text-amber-300"),children:e.status})]}),t.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-[12px] leading-5 text-slate-700 [scrollbar-gutter:stable] dark:text-slate-200",children:e.output||"无输出"})]})}function Ir(e){const r=e.split(`
|
|
23
|
+
`).map(f=>f.trim()).filter(Boolean),s=r.findIndex(f=>f.includes("若按钮没有显示")),o=s>=0?r.slice(0,s):r,d=o[0]||"等待工具确认",k=o.slice(1).filter(f=>!f.includes("请选择一个选项继续执行"));return{title:d,bodyLines:k}}function Kr(e){return/等待工具确认/.test(e)&&/allow all\s*\/\s*allow\s*\/\s*deny/i.test(e)}function zr({card:e,loading:r,onAction:s}){const o=Ir(e.content);return t.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-amber-200 bg-amber-50/90 shadow-[0_10px_26px_rgba(180,83,9,0.08)] dark:border-amber-400/20 dark:bg-amber-500/10 dark:shadow-none",children:[t.jsx("div",{className:"flex items-center justify-between gap-3 border-b border-amber-200/80 px-4 py-3 dark:border-amber-400/15",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-xl bg-amber-100 text-amber-700 dark:bg-amber-400/15 dark:text-amber-200",children:t.jsx(Ht,{size:14})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-semibold text-amber-950 dark:text-amber-50",children:o.title}),t.jsx("p",{className:"mt-0.5 text-[11px] text-amber-700/80 dark:text-amber-100/70",children:"权限响应"})]})]})}),o.bodyLines.length>0?t.jsx("div",{className:"space-y-2 px-4 py-3 text-sm leading-6 text-amber-950 dark:text-amber-50",children:o.bodyLines.map((d,k)=>t.jsx("p",{className:"break-words",children:d},`${e.id}-permission-line-${k}`))}):null,e.actionStatus?t.jsx("p",{className:"border-t border-amber-200/80 px-4 py-3 text-xs text-amber-700 dark:border-amber-400/15 dark:text-amber-100",children:e.actionStatus}):null,e.actions.length>0?t.jsx("div",{className:"flex flex-wrap gap-2 border-t border-amber-200/80 px-4 py-3 dark:border-amber-400/15",children:e.actions.flat().map(d=>t.jsx(Z,{size:"sm",variant:"secondary",onClick:()=>s(d),disabled:!!(e.actionPending||r),loading:r,className:"rounded-full border border-amber-300 bg-white text-amber-900 hover:bg-amber-100 dark:border-amber-400/30 dark:bg-white/[0.08] dark:text-amber-50 dark:hover:bg-white/[0.12]",children:d.text||d.data},`${e.id}-${d.data||d.text}`))}):null]})}function qr(){const[e,r]=i.useState(!1),s=i.useRef(null),[o,d]=i.useState(""),[k,f]=i.useState(!1),{activeRunId:b,activeSessionId:A,activeSessionKey:K,activeSessionName:z,bridgeError:N,branding:c,deleteTarget:v,draft:C,endRef:S,filteredSessionGroups:$,handleBridgeAction:_,handleCreateNew:M,handleDeleteSession:P,handleRenameSession:J,handleSend:n,handleStopTask:L,availableKnowledgeBases:I,loadActiveSession:U,loading:D,openRenameModal:y,pendingBridgeActionId:w,pendingPermissionRequest:O,pendingSessionAction:q,projects:g,refreshRuntime:p,renameDraft:j,renameTarget:F,renderedMessages:X,runtime:H,sending:Q,selectedKnowledgeBaseIds:W,serviceRunning:B,sessionSearch:m,selectedProject:h,setDeleteTarget:R,setDraft:l,setSelectedKnowledgeBaseIds:x,setRenameDraft:T,setRenameTarget:Y,setSelectedProject:G,setSessionSearch:V,showSessionKey:te,taskHint:pe,taskInputLocked:ne,taskRunning:me,taskState:se,transportReady:ie}=Mr(),oe=i.useMemo(()=>W.map(a=>{const u=I.find(E=>E.id===a);return{id:a,name:(u==null?void 0:u.name)||a,fileCount:(u==null?void 0:u.fileCount)||0}}),[I,W]),xe=i.useMemo(()=>{const a=o.trim().toLowerCase();return a?I.filter(u=>[u.name,u.description,u.id].join(" ").toLowerCase().includes(a)):I},[I,o]),he=i.useMemo(()=>{const a=new Set(W);return[...xe].sort((u,E)=>{const re=a.has(u.id),je=a.has(E.id);return re!==je?re?-1:1:u.name.localeCompare(E.name,"zh-CN")})},[xe,W]),fe=i.useMemo(()=>h?$.filter(a=>a.project===h):$,[$,h]),Le=i.useMemo(()=>h&&!g.includes(h)?[h,...g]:g,[g,h]),ye=i.useMemo(()=>fe.some(a=>a.sessions.length>0),[fe]),le=(H==null?void 0:H.phase)==="starting",de=W.length;return i.useEffect(()=>{const a=u=>{var E;(E=s.current)!=null&&E.contains(u.target)||r(!1)};return e&&document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a)}},[e]),i.useEffect(()=>{if(!e)return;const a=window.requestAnimationFrame(()=>{var E;const u=(E=s.current)==null?void 0:E.querySelector("input");u instanceof HTMLInputElement&&u.focus()});return()=>window.cancelAnimationFrame(a)},[e]),D?t.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-slate-500 animate-pulse",children:"正在加载桌面对话…"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative h-full min-h-0 overflow-hidden border-slate-200/80 bg-white shadow-[0_16px_40px_rgba(15,23,42,0.06)] animate-fade-in dark:border-white/[0.06] dark:bg-[#0b0f14] dark:shadow-[0_20px_70px_rgba(0,0,0,0.28)] md:rounded-[28px] md:border",children:t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 md:grid-cols-[288px_minmax(0,1fr)]",children:[t.jsxs("aside",{className:ee("min-h-0 flex-col border-r border-slate-200/80 bg-[linear-gradient(180deg,#fbfcfe_0%,#f5f7fb_100%)] dark:border-white/[0.06] dark:bg-[linear-gradient(180deg,#10151c_0%,#0c1016_100%)]",k?"flex":"hidden md:flex","absolute inset-0 z-30 md:static md:z-auto"),children:[t.jsxs("div",{className:"border-b border-slate-200/80 px-4 py-4 dark:border-white/[0.06]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-[11px] font-medium tracking-[0.18em] text-slate-400 dark:text-slate-500",children:"会话导航"}),t.jsx("h2",{className:"mt-2 text-[1.7rem] font-semibold leading-tight text-slate-900 dark:text-white",children:c.chatHeading})]}),t.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>void p(),className:"rounded-full border border-slate-200 bg-white text-slate-500 hover:bg-slate-100 dark:border-white/[0.08] dark:bg-white/[0.04] dark:text-slate-300 dark:hover:bg-white/[0.08]",children:t.jsx(Dt,{size:14})}),t.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>f(!1),className:"rounded-full border border-slate-200 bg-white text-slate-500 hover:bg-slate-100 dark:border-white/[0.08] dark:bg-white/[0.04] dark:text-slate-300 dark:hover:bg-white/[0.08] md:hidden",children:t.jsx(Ee,{size:14})})]}),t.jsxs("div",{className:"mt-4 space-y-3",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"block text-[11px] font-medium tracking-[0.18em] text-slate-400 dark:text-slate-500",children:c.scopeLabel}),t.jsxs("select",{value:h,onChange:a=>G(a.target.value),"data-testid":"desktop-chat-project-select",className:"w-full rounded-2xl border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 outline-none transition focus:border-primary/50 focus:ring-2 focus:ring-primary/15 dark:border-white/[0.08] dark:bg-[#0b1016] dark:text-white",children:[t.jsx("option",{value:"",children:c.scopeSelectPlaceholder}),Le.map(a=>t.jsx("option",{value:a,children:a},a))]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Z,{size:"md",variant:"secondary",onClick:()=>void M(),"data-testid":"desktop-chat-new-chat",className:"h-11 flex-1 rounded-2xl border border-slate-200 bg-white text-slate-700 hover:bg-slate-100 dark:border-white/[0.08] dark:bg-white/[0.05] dark:text-slate-100 dark:hover:bg-white/[0.09]",children:[t.jsx(We,{size:15}),c.newThreadLabel]}),!B||le?t.jsx(Z,{size:"md",onClick:()=>void St().then(p),disabled:le||B,"data-testid":"desktop-chat-start-service",className:"h-11 shrink-0 rounded-2xl px-3.5",children:le?c.startingRuntimeLabel:c.startRuntimeLabel}):null]}),t.jsxs("div",{className:"relative",children:[t.jsx(Ut,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 dark:text-slate-500"}),t.jsx(Ie,{value:m,onChange:a=>V(a.target.value),placeholder:c.searchPlaceholder,"data-testid":"desktop-chat-session-search",className:"h-11 rounded-2xl border-slate-200 bg-white pl-9 text-slate-900 placeholder:text-slate-400 dark:border-white/[0.08] dark:bg-[#0b1016] dark:text-white dark:placeholder:text-slate-500"})]}),t.jsx("div",{className:"flex items-center justify-between gap-3 rounded-2xl border border-slate-200/80 bg-white/85 px-3 py-2 dark:border-white/[0.06] dark:bg-white/[0.03]",children:t.jsxs("span",{className:"inline-flex items-center gap-2 text-xs font-medium text-slate-600 dark:text-slate-300",children:[t.jsx(Ce,{size:7,className:ee("fill-current",B?"text-primary":"text-slate-300 dark:text-slate-500")}),B?"服务在线":le?"服务启动中":"服务未启动"]})})]}),H!=null&&H.service.lastError?t.jsx("div",{className:"mt-3 rounded-2xl border border-red-500/20 bg-red-50 px-3 py-2 text-xs text-red-600 dark:bg-red-500/10 dark:text-red-200",children:H.service.lastError}):null,H!=null&&H.pendingRestart?t.jsx("div",{className:"mt-3 rounded-2xl border border-amber-500/20 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-200",children:c.pendingRestartLabel}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-24 pt-3 [scrollbar-gutter:stable] md:pb-3",children:!h&&!ye?t.jsxs("div",{className:"rounded-2xl border border-dashed border-slate-200/80 bg-white/70 px-4 py-6 text-center dark:border-white/[0.07] dark:bg-white/[0.02]",children:[t.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:"先选择一个项目"}),t.jsx("p",{className:"mt-2 text-xs leading-5 text-slate-500 dark:text-slate-400",children:"选择项目后展示对应会话列表。"})]}):ye?t.jsx("div",{className:"space-y-4",children:fe.map(a=>t.jsxs("section",{className:"space-y-2",children:[!h&&a.sessions.length>0?t.jsxs("div",{"data-testid":"desktop-chat-session-group","data-project":a.project,className:"flex items-center justify-between px-2 pt-1",children:[t.jsx("p",{className:"text-[11px] font-medium tracking-[0.08em] text-slate-400 dark:text-slate-500",children:a.project}),t.jsxs("p",{className:"text-[10px] text-slate-400 dark:text-slate-500",children:[a.sessions.length," ",c.collectionLabel]})]}):null,a.sessions.map(u=>t.jsx("div",{"data-testid":"desktop-chat-session-row","data-session-id":u.id,"data-project":a.project,role:"button",tabIndex:0,onClick:()=>{U(a.project,u.id),f(!1)},onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),U(a.project,u.id),f(!1))},className:ee("group relative overflow-hidden rounded-2xl border px-4 py-3 text-left transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary/20",u.id===A?"border-primary/20 bg-primary/10 shadow-[inset_3px_0_0_0_rgba(0,122,255,0.9)] dark:border-primary/25 dark:bg-primary/10":"border-transparent bg-white/70 hover:border-slate-200 hover:bg-white dark:bg-white/[0.03] dark:hover:border-white/[0.08] dark:hover:bg-white/[0.05]"),children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{"data-testid":"desktop-chat-session-open","data-session-id":u.id,"data-project":a.project,className:"min-w-0 flex-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"truncate text-sm font-medium text-slate-900 dark:text-white",children:u.name})}),t.jsx("p",{className:"mt-1 text-[11px] text-slate-400 dark:text-slate-500",children:At(u.updatedAt||u.createdAt)}),u.excerpt?t.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-5 text-slate-500 dark:text-slate-400",children:u.excerpt.replace(/\n/g," ")}):null,te&&u.bridgeSessionKey?t.jsx("p",{className:"mt-2 truncate text-[11px] text-slate-400 dark:text-slate-500",children:u.bridgeSessionKey}):null]}),t.jsxs("div",{className:"flex items-center gap-1 opacity-0 transition-opacity duration-200 group-hover:opacity-100 focus-within:opacity-100",children:[t.jsx(Z,{size:"sm",variant:"ghost",onClick:E=>{E.stopPropagation(),y(a.project,u)},"data-testid":"desktop-chat-session-rename","data-session-id":u.id,"data-project":a.project,className:"text-slate-400 hover:bg-slate-100 hover:text-slate-900 dark:hover:bg-white/[0.08] dark:hover:text-white",children:t.jsx(Bt,{size:14})}),t.jsx(Z,{size:"sm",variant:"ghost",className:"text-red-400 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-500/10 dark:hover:text-red-200","data-testid":"desktop-chat-session-delete","data-session-id":u.id,"data-project":a.project,onClick:E=>{E.stopPropagation(),R({project:a.project,id:u.id,name:u.name})},children:t.jsx(Ot,{size:14})})]})]})},u.id))]},a.project))}):t.jsxs("div",{className:"rounded-2xl border border-dashed border-slate-200/80 bg-white/70 px-4 py-6 text-center dark:border-white/[0.07] dark:bg-white/[0.02]",children:[t.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:m.trim()?"没有匹配的会话":"当前还没有桌面会话"}),t.jsx("p",{className:"mt-2 text-xs leading-5 text-slate-500 dark:text-slate-400",children:m.trim()?"换个关键词试试。":"发送第一条消息后,这里会出现新的会话记录。"})]})})]}),t.jsxs("section",{className:"flex min-h-0 flex-col bg-[linear-gradient(180deg,#ffffff_0%,#fbfcfe_100%)] dark:bg-[linear-gradient(180deg,#0d1218_0%,#0a0f15_100%)]",children:[t.jsxs("div",{className:"border-b border-slate-200/80 px-4 py-3 dark:border-white/[0.06] sm:px-6 sm:py-4",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Z,{size:"sm",variant:"secondary",onClick:()=>f(!0),className:"mt-0.5 h-9 w-9 shrink-0 rounded-xl px-0 md:hidden","aria-label":"Open sessions",children:t.jsx(Xt,{size:16})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-[11px] font-medium tracking-[0.16em] text-slate-400 dark:text-slate-500",children:"当前会话"}),t.jsx("h2",{className:"mt-1 truncate text-2xl font-semibold leading-tight text-slate-900 dark:text-white sm:mt-2 sm:text-[2rem] sm:leading-none","data-testid":"desktop-chat-active-title",children:z||c.activeConversationFallback})]})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[h?t.jsx("span",{className:"inline-flex items-center rounded-full bg-slate-100 px-2.5 py-1 text-[11px] text-slate-600 dark:bg-white/[0.05] dark:text-slate-300",children:h}):null,t.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-slate-100 px-2.5 py-1 text-[10px] uppercase tracking-[0.18em] text-slate-500 dark:bg-white/[0.05] dark:text-slate-400",children:rr(H==null?void 0:H.phase)}),ie?t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-primary/10 px-2.5 py-1 text-primary dark:text-primary",children:[t.jsx(Ce,{size:6,className:"fill-current"})," ",c.runtimeOnlineLabel]}):t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-slate-100 px-2.5 py-1 text-slate-500 dark:bg-white/[0.05] dark:text-slate-400",children:[t.jsx(Rt,{size:12})," ",c.runtimeOfflineLabel]}),te&&K?t.jsx("span",{className:"truncate text-[11px] text-slate-400 dark:text-slate-500",children:K}):null]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-4 [scrollbar-gutter:stable] sm:px-6 sm:py-5",children:[X.length===0?t.jsx("div",{className:"flex h-full min-h-[18rem] items-center justify-center",children:t.jsxs("div",{className:"w-full max-w-2xl rounded-3xl border border-slate-200/80 bg-white px-5 py-8 text-center shadow-[0_10px_30px_rgba(15,23,42,0.04)] dark:border-white/[0.06] dark:bg-white/[0.03] dark:shadow-none sm:rounded-[28px] sm:px-8 sm:py-10",children:[t.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:t.jsx(We,{size:22})}),t.jsx("h3",{className:"mt-4 text-lg font-semibold text-slate-900 dark:text-white sm:text-xl",children:"开始一段新的桌面对话"}),t.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-slate-500 dark:text-slate-400",children:h?`当前项目是 ${h}。直接提问即可创建会话并开始对话。`:"先在左侧选择项目,然后直接输入你的问题。"}),t.jsx("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:oe.length>0?oe.map(a=>t.jsx("span",{className:"rounded-full bg-primary/10 px-3 py-1 text-xs text-primary dark:bg-primary/10 dark:text-primary",children:a.name},a.id)):t.jsx("span",{className:"rounded-full bg-slate-100 px-3 py-1 text-xs text-slate-500 dark:bg-white/[0.05] dark:text-slate-400",children:"当前未限制知识库范围"})})]})}):t.jsx("div",{className:"space-y-5",children:X.map(a=>{if(a.kind==="progress"&&Ar(a.content))return null;const u=a.role==="user",E=a.role==="system",re=!u&&!E&&a.kind==="progress",je=(O==null?void 0:O.id)===a.id?O:null,ae=!u&&(je||(a.actionMode==="permission"&&a.actionInteractive||Kr(a.content)?{id:a.id,content:a.content,actions:a.actions||[],actionReplyCtx:a.actionReplyCtx,actionPending:a.actionPending,actionStatus:a.actionStatus,actionMode:"permission",actionInteractive:!0}:null)),be=!u&&!ae?Lr(a.content):null,ve=!!be;return t.jsxs("div",{className:ee("flex gap-2 sm:gap-3",u?"justify-end":"justify-start"),children:[u?null:t.jsx("div",{className:ee("mt-1 flex shrink-0 items-center justify-center rounded-full text-slate-400 dark:text-slate-500",E?"h-7 w-7 bg-amber-100 text-amber-600 dark:bg-amber-500/12 dark:text-amber-300":re?"h-6 w-6 bg-slate-100 dark:bg-white/[0.04]":"h-8 w-8 bg-slate-100 dark:bg-white/[0.06]"),children:E?t.jsx(Oe,{size:14}):re?t.jsx(Ce,{size:7,className:"fill-current"}):t.jsx(Et,{size:14})}),t.jsx("div",{"data-testid":"desktop-chat-message","data-role":a.role,"data-kind":a.kind||"final","data-order":String(a.order),"data-timestamp":a.timestamp||"",className:ee("transition-all",u?"max-w-[calc(100%-2.25rem)] sm:max-w-[72%]":ve?"max-w-[calc(100%-2.25rem)] sm:max-w-[86%]":re?"max-w-[calc(100%-2.25rem)] sm:max-w-[76%]":"max-w-[calc(100%-2.25rem)] sm:max-w-[84%]"),children:t.jsxs("div",{className:ee("rounded-[22px] px-4 py-3 text-sm",u?"chat-user-glass rounded-br-md text-slate-950 dark:text-slate-50":E?"rounded-bl-md border border-amber-200/80 bg-amber-50 text-amber-900 shadow-[0_6px_18px_rgba(15,23,42,0.03)] dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-100 dark:shadow-none":re?"rounded-bl-lg bg-slate-100/80 text-[13px] leading-6 text-slate-500 dark:bg-white/[0.04] dark:text-slate-400":"rounded-bl-md border border-slate-200/80 bg-white text-slate-800 shadow-[0_6px_18px_rgba(15,23,42,0.04)] dark:border-white/[0.06] dark:bg-white/[0.04] dark:text-slate-100 dark:shadow-none",ve&&"bg-transparent p-0 shadow-none dark:bg-transparent"),children:[t.jsxs("div",{className:ee("mb-2 flex items-center gap-2 text-[10px]",u?"justify-end text-slate-600 dark:text-white/55":"text-slate-400 dark:text-slate-500"),children:[E?t.jsx("span",{className:"tracking-[0.16em] text-amber-600 dark:text-amber-300",children:"系统"}):null,re?t.jsx("span",{className:"tracking-[0.16em] text-amber-500 dark:text-amber-300",children:ve?"工具":"过程"}):null,Je(a.timestamp)?t.jsx("span",{"data-testid":"desktop-chat-message-timestamp",children:Je(a.timestamp)}):null]}),ae?t.jsx(zr,{card:ae,loading:w===ae.id,onAction:ce=>void _(ae,ce)}):!u&&a.preview&&a.previewPlainText?t.jsx("div",{className:"whitespace-pre-wrap break-words text-[13px] leading-6 text-inherit",children:a.content}):be?t.jsx(Pr,{card:be}):t.jsx(Lt,{content:a.content,isUser:u}),!ae&&!u&&a.actions&&a.actions.length>0?t.jsx("div",{className:"mt-4 space-y-2",children:a.actions.map((ce,Te)=>t.jsx("div",{className:"flex flex-wrap gap-2",children:ce.map(ue=>t.jsx(Z,{size:"sm",variant:String(ue.data||"").includes("deny")?"danger":"secondary",onClick:()=>void _(a,ue),disabled:!!(a.actionPending||w),loading:w===a.id,"data-testid":"desktop-chat-action-button",className:"rounded-full",children:ue.text||ue.data},`${a.id}-${ue.data||ue.text}`))},`${a.id}-actions-${Te}`))}):null,!u&&a.actionStatus?t.jsx("p",{className:ee("mt-3 text-xs",a.actionInteractive?"text-slate-500 dark:text-slate-400":"text-amber-700 dark:text-amber-200"),"data-testid":"desktop-chat-action-status",children:a.actionStatus}):null,a.preview?t.jsx("p",{className:"mt-2 text-[10px] uppercase tracking-[0.18em] text-primary dark:text-primary",children:"实时预览"}):null]})}),u?t.jsx("div",{className:"mt-1 flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-slate-100 dark:bg-white/[0.08] sm:h-8 sm:w-8",children:t.jsx(Ft,{size:14,className:"text-slate-500 dark:text-slate-300"})}):null]},a.id)})}),pe?t.jsxs("div",{className:"mt-5 flex items-center gap-2 text-sm text-slate-400","data-testid":"desktop-chat-task-hint",children:[t.jsx(Ce,{size:8,className:"fill-current animate-pulse"})," ",pe]}):null,N?t.jsx("div",{className:"mt-4 rounded-2xl border border-amber-400/20 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:bg-amber-500/10 dark:text-amber-100","data-testid":"desktop-chat-bridge-error",children:N}):null,t.jsx("div",{ref:S})]}),t.jsx("div",{className:"border-t border-slate-200/80 px-3 py-3 dark:border-white/[0.06] sm:px-6",children:t.jsxs("div",{className:"rounded-3xl border border-slate-200/80 bg-white p-2 shadow-[0_8px_24px_rgba(15,23,42,0.05)] dark:border-white/[0.08] dark:bg-[#0f151c] dark:shadow-[0_12px_28px_rgba(0,0,0,0.20)] sm:rounded-[24px] sm:p-2.5",children:[t.jsxs("div",{className:"relative",ref:s,children:[t.jsx("div",{className:"rounded-2xl border border-slate-200 bg-slate-50/80 px-3 py-1.5 dark:border-white/[0.06] dark:bg-white/[0.03]",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:flex-nowrap",children:[t.jsx("p",{className:"shrink-0 text-[11px] font-medium text-slate-500 dark:text-slate-400",children:"知识库范围"}),t.jsxs(Z,{size:"sm",variant:"secondary",disabled:!h,onClick:()=>r(a=>!a),"data-testid":"desktop-chat-knowledge-base-toggle",className:"shrink-0 rounded-full border border-slate-200 bg-white text-slate-700 hover:bg-slate-100 dark:border-white/[0.08] dark:bg-white/[0.06] dark:text-slate-100 dark:hover:bg-white/[0.1]",children:[t.jsx(Vt,{size:13}),de>0?"调整知识库":"选择知识库"]}),t.jsx("div",{className:"order-3 flex min-w-full flex-1 items-center gap-2 overflow-x-auto whitespace-nowrap [scrollbar-gutter:stable] sm:order-none sm:min-w-0",children:oe.length===0?t.jsx("span",{className:"text-xs text-slate-400",children:h?"当前未限制知识库范围":"选择项目后可设置知识库范围"}):oe.map(a=>t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2 rounded-full border border-slate-200 bg-white px-2.5 py-1 text-xs text-slate-700 dark:border-white/[0.08] dark:bg-white/[0.06] dark:text-slate-100",children:[t.jsx("span",{className:"max-w-[10rem] truncate",children:a.name}),a.fileCount>0?t.jsxs("span",{className:"text-[10px] text-slate-500",children:[a.fileCount," 文档"]}):null,t.jsx("button",{type:"button",onClick:()=>void x(W.filter(u=>u!==a.id)),className:"text-slate-500 transition-colors hover:text-slate-900 dark:hover:text-white","data-testid":"desktop-chat-knowledge-base-remove",children:t.jsx(Ee,{size:12})})]},a.id))}),t.jsx("p",{className:"ml-auto shrink-0 text-[11px] text-slate-400 sm:ml-0",children:h?de>0?`已选 ${de} 个`:"未限制":"请先选项目"})]})}),e?t.jsxs("div",{className:"animate-float-in absolute bottom-full left-0 right-0 z-20 mb-3 max-h-[70dvh] overflow-hidden rounded-[24px] border border-slate-200 bg-white p-3 shadow-[0_22px_50px_rgba(15,23,42,0.12)] dark:border-white/[0.08] dark:bg-[#0c1117] dark:shadow-[0_28px_80px_rgba(0,0,0,0.40)]",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-slate-900 dark:text-white",children:"选择知识库"}),t.jsx("p",{className:"text-[11px] text-slate-400",children:"已选项排在前面,方便快速确认范围。"})]}),de>0?t.jsx("button",{type:"button",onClick:()=>void x([]),className:"text-xs text-slate-400 transition-colors hover:text-slate-900 dark:hover:text-white",children:"清空"}):null]}),t.jsx(Ie,{value:o,onChange:a=>d(a.target.value),placeholder:"搜索知识库",className:"mt-3 rounded-2xl border-slate-200 bg-white text-slate-900 placeholder:text-slate-400 dark:border-white/[0.08] dark:bg-white/[0.04] dark:text-white dark:placeholder:text-slate-500"}),t.jsx("div",{className:"mt-3 max-h-64 space-y-2 overflow-y-auto pr-2 [scrollbar-gutter:stable]",children:he.length===0?t.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 px-3 py-4 text-center text-xs text-slate-500 dark:border-white/[0.08]",children:"没有匹配的知识库"}):he.map(a=>{const u=W.includes(a.id);return t.jsxs("button",{type:"button",onClick:()=>void x(u?W.filter(E=>E!==a.id):[...W,a.id]),"data-testid":"desktop-chat-knowledge-base-select",className:ee("flex w-full items-start gap-3 rounded-xl border px-3 py-3 text-left transition-all duration-200",u?"border-primary/25 bg-primary/10 dark:border-primary/30 dark:bg-primary/10":"border-slate-200 bg-white hover:border-slate-300 hover:bg-slate-50 dark:border-white/[0.06] dark:bg-white/[0.03] dark:hover:border-white/[0.12] dark:hover:bg-white/[0.05]"),children:[t.jsx("span",{className:ee("mt-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full border text-[10px]",u?"border-primary bg-primary text-white":"border-slate-300 text-transparent dark:border-white/[0.12]"),children:t.jsx(Oe,{size:12})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-slate-900 dark:text-white",children:a.name}),t.jsxs("span",{className:"mt-1 block text-[11px] text-slate-400",children:[a.fileCount," 文档",a.description?` · ${a.description}`:""]})]})]},a.id)})})]}):null]}),t.jsxs("div",{className:"mt-2.5",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-2 sm:gap-3",children:[t.jsx(_t,{"data-testid":"desktop-chat-input",value:C,onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&!ne&&(a.preventDefault(),n())},rows:3,placeholder:B?ie?se==="awaiting_input"?"Agent 正在等待你的回复,可直接继续输入。":ne?"任务正在运行,点击停止可中断当前执行。":c.sendPlaceholder:c.waitingRuntimePlaceholder:c.startFirstPlaceholder,disabled:!B||!ie||Q||!h||ne,className:"min-h-[76px] rounded-[20px] border-slate-200 bg-white px-3 py-2.5 text-[15px] leading-6 text-slate-900 placeholder:text-slate-400 dark:border-white/[0.08] dark:bg-[#090d12] dark:text-white dark:placeholder:text-slate-500 sm:min-h-[94px] sm:px-4 sm:py-3"}),me?t.jsxs(Z,{variant:"danger",onClick:()=>void L(),disabled:!K&&!b||se==="stopping","data-testid":"desktop-chat-stop-task",className:"h-12 min-w-12 rounded-[20px] bg-red-50 px-3 text-red-600 hover:bg-red-100 dark:bg-red-500/12 dark:text-red-200 dark:hover:bg-red-500/18 sm:h-14 sm:min-w-[124px] sm:px-5",children:[t.jsx(Pt,{size:16,className:"animate-spin"}),t.jsx("span",{className:"hidden sm:inline",children:se==="stopping"?"停止中":"停止任务"})]}):t.jsx(Z,{onClick:()=>void n(),disabled:!C.trim()||!B||!ie||Q||!h,"data-testid":"desktop-chat-send",className:"h-12 w-12 rounded-full px-0 shadow-none sm:h-14 sm:w-14",children:t.jsx(Tt,{size:18})})]}),t.jsxs("div",{className:"mt-1.5 hidden items-center justify-between px-1 pr-[4.5rem] text-[11px] text-slate-500 dark:text-slate-400 sm:flex",children:[t.jsx("span",{children:"Enter 发送,Shift + Enter 换行"}),t.jsx("span",{children:h?"范围会随当前线程保存":"请先选择项目"})]})]})]})})]})]})}),t.jsx(Fe,{open:!!F,onClose:()=>Y(null),title:"重命名会话",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ie,{value:j,onChange:a=>T(a.target.value),onInput:a=>T(a.target.value),placeholder:"输入会话名称","data-testid":"desktop-chat-rename-input"}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(Z,{variant:"secondary",onClick:()=>Y(null),"data-testid":"desktop-chat-rename-cancel",children:"取消"}),t.jsx(Z,{onClick:()=>void J(),loading:q==="rename",disabled:!j.trim(),"data-testid":"desktop-chat-rename-save",children:"保存名称"})]})]})}),t.jsx(Fe,{open:!!v,onClose:()=>R(null),title:"删除会话",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["确定删除 ",t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:v==null?void 0:v.name})," 吗?这会移除该会话的本地保存记录。"]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(Z,{variant:"secondary",onClick:()=>R(null),"data-testid":"desktop-chat-delete-cancel",children:"取消"}),t.jsx(Z,{variant:"danger",onClick:()=>void P(),loading:q==="delete","data-testid":"desktop-chat-delete-confirm",children:"删除会话"})]})]})})]})}export{qr as default};
|