@kafca/agentdock 0.1.47 → 0.1.48
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/README.md +5 -0
- package/dist/renderer/assets/{Badge-BYREM3t3.js → Badge-C92lMj9Q.js} +1 -1
- package/dist/renderer/assets/{Chat-Dtb5X7sB.js → Chat-DqoKCPwz.js} +1 -1
- package/dist/renderer/assets/{ChatMarkdown-_slLloCh.js → ChatMarkdown-C4psQvmt.js} +1 -1
- package/dist/renderer/assets/{Config-pHichs7H.js → Config-1uk8FQL7.js} +2 -2
- package/dist/renderer/assets/{CronList-CJQMeCjz.js → CronList-DnKCiYWC.js} +1 -1
- package/dist/renderer/assets/{Dashboard-CY77Imde.js → Dashboard-rOAQcJA0.js} +2 -2
- package/dist/renderer/assets/{EmptyState-DCqmct2y.js → EmptyState-bF6Sc61O.js} +1 -1
- package/dist/renderer/assets/{KnowledgeDetail-DFrxa-pv.js → KnowledgeDetail-C5-Dp95R.js} +2 -2
- package/dist/renderer/assets/{KnowledgeHome-DL-vAfrH.js → KnowledgeHome-DGa1EWXD.js} +2 -2
- package/dist/renderer/assets/{Logs-jw9Uv590.js → Logs-CKKVW2k8.js} +1 -1
- package/dist/renderer/assets/{Modal-ChSm7tk6.js → Modal-DIc9HxD5.js} +3 -3
- package/dist/renderer/assets/{MonitorList-DrEwyS71.js → MonitorList-D2YOJRIX.js} +1 -1
- package/dist/renderer/assets/{Page-DhD-zgMU.js → Page-vZ-_l6Kn.js} +1 -1
- package/dist/renderer/assets/{ProjectDetail-BVSjpfpL.js → ProjectDetail-CqTa6kAh.js} +2 -2
- package/dist/renderer/assets/{ProjectList-CHGbTJjk.js → ProjectList-LgDQVVyZ.js} +1 -1
- package/dist/renderer/assets/{Select-rHs9CSam.js → Select-BN2HMOmY.js} +1 -1
- package/dist/renderer/assets/SessionChat-Beco1N1T.js +1 -0
- package/dist/renderer/assets/{SessionList-Mr1uAnRW.js → SessionList-3NkskCJJ.js} +1 -1
- package/dist/renderer/assets/ThreadChat-Ji8pOm5p.js +28 -0
- package/dist/renderer/assets/{Workspace-MRRg8ndJ.js → Workspace-yarrGItB.js} +1 -1
- package/dist/renderer/assets/{arrow-left-BU2NB2LA.js → arrow-left-DNovvfPp.js} +1 -1
- package/dist/renderer/assets/{book-open-D-TGvWwa.js → book-open-CarZFsXv.js} +1 -1
- package/dist/renderer/assets/{bot-IYNh8tH5.js → bot-g16rGMp6.js} +1 -1
- package/dist/renderer/assets/{check-CCZ0JO_S.js → check-DjFX73Zi.js} +1 -1
- package/dist/renderer/assets/{chevron-down-00bRZi15.js → chevron-down-B02YlQS_.js} +1 -1
- package/dist/renderer/assets/{circle-CpQ8x4k_.js → circle-DPfWdG1F.js} +1 -1
- package/dist/renderer/assets/{desktop-D0k2aGSj.js → desktop-DMkue1T6.js} +1 -1
- package/dist/renderer/assets/{funnel-UbcrCBCp.js → funnel-Dy1VL-D9.js} +1 -1
- package/dist/renderer/assets/{heart-DvLsV7tL.js → heart-YjvGwq5-.js} +1 -1
- package/dist/renderer/assets/{index-B2L4G-b_.js → index-CZN1STMc.js} +2 -2
- package/dist/renderer/assets/index-CjCuR6DI.css +11 -0
- package/dist/renderer/assets/{index-dy-g2Bh4.js → index-mvjDN9uV.js} +9 -9
- package/dist/renderer/assets/{pencil-qBYOgW5M.js → pencil-qpMjLIFd.js} +1 -1
- package/dist/renderer/assets/{play-Dn6b4AGj.js → play-CPCcNQcH.js} +1 -1
- package/dist/renderer/assets/{plus-CaApUwEm.js → plus-B76JWGKd.js} +1 -1
- package/dist/renderer/assets/projects-C1nFINjh.js +1 -0
- package/dist/renderer/assets/{save-CN6yvTfD.js → save-DtvrD3W1.js} +1 -1
- package/dist/renderer/assets/{search-Dn2MxYiO.js → search-Ddth-YHH.js} +1 -1
- package/dist/renderer/assets/{server-DpcVLHeh.js → server-D0zmghb3.js} +1 -1
- package/dist/renderer/assets/{session-utils-DnD2Q_y1.js → session-utils-C9oe-21F.js} +1 -1
- package/dist/renderer/assets/{sessions-eK5D4FLt.js → sessions-BXOnLLah.js} +1 -1
- package/dist/renderer/assets/{shield-check-DSSJkacw.js → shield-check-Cv5d_blH.js} +1 -1
- package/dist/renderer/assets/{trash-2-DmYJlEvO.js → trash-2-C2mimX2b.js} +1 -1
- package/dist/renderer/assets/{user-Cvf_uiyQ.js → user-BrLJ4elW.js} +1 -1
- package/dist/renderer/assets/{wifi-off-CCTloj-V.js → wifi-off-DvRJYLbG.js} +1 -1
- package/dist/renderer/index.html +2 -2
- package/dist-electron/packages/core-sdk/src/index.js +4 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-session-coordinator.js +51 -6
- package/dist-electron/services/local-ai-core/src/acp/store/local-core-acp-store.js +3 -0
- package/dist-electron/services/local-ai-core/src/acp/store/platform-store.js +13 -5
- package/dist-electron/services/local-ai-core/src/acp/store/schema.js +1 -0
- package/dist-electron/services/local-ai-core/src/acp/store/thread-store.js +3 -0
- package/dist-electron/services/local-ai-core/src/channel/shared/base-channel-gateway.js +4 -1
- package/dist-electron/services/local-ai-core/src/channel/shared/session-command-runtime.js +14 -3
- package/dist-electron/services/local-ai-core/src/router/workspace-router.js +8 -1
- package/dist-electron/services/local-ai-core/src/runtime/handlers/thread-handler.js +4 -0
- package/dist-electron/services/local-ai-core/src/runtime/server-routes.js +3 -0
- package/dist-electron/services/local-ai-core/src/thread/thread-command-service.js +23 -2
- package/dist-electron/services/local-ai-core/src/thread/thread-slash-command-dispatcher.js +1 -0
- package/dist-electron/src/pages/Threads/thread-chat-model.js +2 -0
- package/dist-electron/tests/electron/workspace-task-store.test.js +22 -3
- package/dist-electron/tests/integration/local-core-refactor.test.js +177 -0
- package/dist-electron/tests/integration/local-core-routes.test.js +45 -0
- package/package.json +2 -2
- package/dist/renderer/assets/SessionChat-CDc2FNMA.js +0 -1
- package/dist/renderer/assets/ThreadChat-Detu5UfN.js +0 -23
- package/dist/renderer/assets/index-CO4fGqmv.css +0 -11
- package/dist/renderer/assets/projects-BwF5RlNV.js +0 -1
package/README.md
CHANGED
|
@@ -94,6 +94,11 @@ flowchart LR
|
|
|
94
94
|
|
|
95
95
|
## New
|
|
96
96
|
|
|
97
|
+
### 2026-06-14
|
|
98
|
+
|
|
99
|
+
- 聊天输入框下方新增权限模式选择器,可在请求批准和完全访问之间切换,并随当前线程保存。
|
|
100
|
+
- 在 channel(Lark/Feishu/WeChat)里执行 `/agent use` 切换 Agent 时,选择会持久化到频道级偏好;后续 `/new` 创建新会话或重启后,新线程会自动继承该偏好。
|
|
101
|
+
|
|
97
102
|
### 2026-05-24
|
|
98
103
|
|
|
99
104
|
- 重构 Local AI Core 控制器:提取 ChannelService 与 ExternalService 为独立领域服务,Controller 缩至约 20 个方法,只保留生命周期、配置和事件编排。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,g as a}from"./index-
|
|
1
|
+
import{j as t,g as a}from"./index-mvjDN9uV.js";const n={default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",success:"border-transparent bg-primary/10 text-primary dark:bg-primary/15 dark:text-primary",warning:"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-200",danger:"border-transparent bg-destructive/10 text-destructive dark:bg-destructive/20 dark:text-red-200",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",info:"border-transparent bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-200"};function s({children:r,variant:e="default"}){return t.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",n[e]),children:r})}export{s as B};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as ze,
|
|
1
|
+
import{u as ze,y as Me,r as n,j as s,C as pe,I as ye,M as U,B as C,g as ee,R as De,T as Ae}from"./index-mvjDN9uV.js";import{M as be}from"./Modal-DIc9HxD5.js";import{E as $}from"./EmptyState-bF6Sc61O.js";import{C as Le,A as Be}from"./ChatMarkdown-C4psQvmt.js";import{l as Ke}from"./projects-C1nFINjh.js";import{l as Ue,g as $e,s as qe,a as je,r as Fe,d as Oe}from"./sessions-BXOnLLah.js";import{s as We,a as we,b as w,L as _,t as He}from"./session-utils-C9oe-21F.js";import{S as Ve}from"./search-Ddth-YHH.js";import{P as Ge}from"./pencil-qpMjLIFd.js";import{T as Je}from"./trash-2-C2mimX2b.js";import{B as Qe}from"./bot-g16rGMp6.js";import{U as Xe}from"./user-BrLJ4elW.js";import"./index-CZN1STMc.js";import"./check-DjFX73Zi.js";const Ye=1500,Ze=9e4;function es(a){return String(a||"").startsWith("web:")}function ss(a){return(a||[]).map((d,y)=>({id:`${d.timestamp||y}-${d.role}-${y}`,role:d.role==="user"?"user":"assistant",content:d.content,timestamp:d.timestamp,kind:d.kind}))}function ts(a){return a.map(d=>`${d.role}:${d.kind||"final"}:${d.timestamp||""}:${d.content}`).join(`
|
|
2
2
|
`)}function as(a){return a.filter(d=>d.role!=="user").length}function rs(a,d){var y;return(y=a.last_message)!=null&&y.content?a.last_message.content.replace(/\n/g," "):d("sessions.noMessages")}function ve(a){return(a instanceof Error?a.message:String(a||"")).trim().toLowerCase().includes("no active session found")}function ns(a,d){return(a instanceof Error?a.message:String(a||"")).trim().toLowerCase()?ve(a)?d("sessions.sessionUnavailable"):a instanceof Error?a.message:d("sessions.sendFailed"):d("sessions.sendFailed")}function js(){const{t:a}=ze(),[d,y]=Me(),[se,ke]=n.useState([]),[te,ae]=n.useState({}),[i,G]=n.useState(d.get("project")||""),[b,R]=n.useState([]),[r,h]=n.useState(null),[I,v]=n.useState([]),[J,re]=n.useState(""),[T,Q]=n.useState(""),[Ne,ne]=n.useState(!0),[Se,ie]=n.useState(!1),[Ce,le]=n.useState(!1),[X,oe]=n.useState(!1),[E,P]=n.useState("idle"),[de,k]=n.useState(""),[z,q]=n.useState(null),[F,Y]=n.useState(""),[M,O]=n.useState(null),[ce,W]=n.useState(null),me=n.useRef(null),x=n.useRef({project:"",sessionId:""}),H=n.useRef(null),V=n.useRef(null),j=d.get("project")||"",D=d.get("session")||"",ue=n.useMemo(()=>new Set(Object.values(te)),[te]),N=n.useMemo(()=>{const e=J.trim().toLowerCase();return e?b.filter(t=>We(t,e)):b},[J,b]),A=!!(r&&(r.live||ue.has(r.id))),Ee=!!(i&&A&&T.trim()&&!X&&E!=="sending"&&E!=="activating"&&E!=="polling"),f=n.useCallback((e,t)=>{const l=new URLSearchParams;e&&l.set("project",e),t&&l.set("session",t),y(l,{replace:!0})},[y]),c=n.useCallback((e="idle")=>{H.current&&(window.clearTimeout(H.current),H.current=null),V.current=null,P(e)},[]),xe=n.useCallback(e=>{R(t=>{const l=t.some(o=>o.id===e.id)?t.map(o=>o.id===e.id?{...o,...e}:o):[...t,e];return we(l)})},[]),fe=n.useCallback(async()=>{ne(!0);try{const{projects:e}=await Ke();ke(e||[])}finally{ne(!1)}},[]),u=n.useCallback(async e=>{if(!e)return R([]),ae({}),[];ie(!0);try{const{sessions:t,active_keys:l}=await Ue(e),o=we((t||[]).filter(m=>!es(m.session_key)));return ae(l||{}),x.current.project===e&&R(o),o}finally{ie(!1)}},[]),S=n.useCallback(async(e,t,l)=>{if(!e||!t)return h(null),v([]),null;l!=null&&l.silent||le(!0);try{const o=await $e(e,t,200);return x.current.project!==e||x.current.sessionId!==t||(xe(o),h({id:o.id,project:e,sessionKey:o.session_key,name:o.name||w(o),live:o.live,isDraft:!1,detail:o}),v(ss(o.history)),k("")),o}catch(o){return x.current.project===e&&x.current.sessionId===t&&k(o instanceof Error?o.message:a("sessions.loadFailed")),null}finally{l!=null&&l.silent||le(!1)}},[xe,a]),Z=n.useCallback(e=>{V.current=e,H.current=window.setTimeout(async()=>{const t=V.current;if(!t)return;if(Date.now()-t.startedAt>=Ze){c("timed_out"),k(a("sessions.pollTimeout")),await u(t.project);return}const l=await S(t.project,t.sessionId,{silent:!0});if(!l||!V.current){c(),await u(t.project);return}if(x.current.project!==t.project||x.current.sessionId!==t.sessionId){c();return}const o=ts(l.history),m=as(l.history)>t.assistantCountBefore,g=m&&o===t.lastSignature?t.stableCount+1:0,K={...t,lastSignature:o,stableCount:g};if(m&&g>=2){c(),await u(t.project);return}P("polling"),Z(K)},Ye)},[S,u,c,a]),he=n.useCallback((e,t,l)=>{c(),P("polling"),Z({project:e,sessionId:t,assistantCountBefore:l,stableCount:0,lastSignature:"",startedAt:Date.now()})},[Z,c]),Pe=n.useCallback(async e=>{if(c(),G(e),re(""),k(""),Q(""),!e){x.current={project:"",sessionId:""},h(null),v([]),R([]),f("");return}x.current={project:e,sessionId:""},h(null),v([]),f(e),await u(e)},[u,c,f]),L=n.useCallback(async e=>{if(e.isDraft||e.live||!e.id)return e;P("activating");try{await qe(e.project,{session_key:e.sessionKey,session_id:e.id}),await u(e.project);const t=await S(e.project,e.id,{silent:!0}),l={...e,live:(t==null?void 0:t.live)??!0,isDraft:!1,detail:t??e.detail,name:(t==null?void 0:t.name)||e.name};return h(l),l}finally{P("idle")}},[S,u]),B=n.useCallback(async(e,t)=>{c(),k(""),x.current={project:e,sessionId:t.id},G(e),f(e,t.id),h({id:t.id,project:e,sessionKey:t.session_key,name:w(t),live:t.live,isDraft:!1,detail:null});const l=await S(e,t.id);l&&!l.live&&await L({id:l.id,project:e,sessionKey:l.session_key,name:l.name||w(l),live:l.live,isDraft:!1,detail:l})},[L,S,c,f]),_e=n.useCallback(async()=>{c(),i&&(await u(i),r!=null&&r.id&&(x.current={project:i,sessionId:r.id},await S(i,r.id)))},[r==null?void 0:r.id,S,u,i,c]),ge=n.useCallback(async()=>{if(!T.trim()||!i)return;if(!A){k(a("sessions.sessionUnavailable"));return}const e=T.trim(),t=`${crypto.randomUUID()}-user`,l={id:t,role:"user",content:e,timestamp:new Date().toISOString()};Q(""),oe(!0),P("sending"),k("");try{const o=r||N[0];if(!o)throw new Error(a("sessions.noAvailableChatTarget"));let m=r&&r.id===o.id?r:{id:o.id,project:i,sessionKey:"session_key"in o?o.session_key:o.sessionKey,name:"session_key"in o?w(o):o.name,live:o.live,isDraft:!1,detail:null};(!r||r.id!==m.id)&&(x.current={project:i,sessionId:m.id},f(i,m.id),h(m)),m=await L(m),v(p=>[...p,l]);try{await je(i,{session_key:m.sessionKey,message:e})}catch(p){if(!ve(p)||!m.id)throw p;m=await L({...m,live:!1}),await je(i,{session_key:m.sessionKey,message:e})}const g=m.id;if(!g)throw new Error(a("sessions.createFailed"));const K=I.filter(p=>p.role!=="user").length;x.current={project:i,sessionId:g},h(p=>p&&{...p,id:g,isDraft:!1}),f(i,g),he(i,g,K),await u(i)}catch(o){c(),v(g=>g.filter(K=>K.id!==t));const m=ns(o,a);k(m)}finally{oe(!1)}},[r,A,L,T,N,I,u,i,he,c,a,f]),Re=n.useCallback(async()=>{if(!(!z||!i||!F.trim())){W("rename");try{await Fe(i,z.id,{name:F.trim()});const t=(await u(i)).find(l=>l.id===z.id);t&&(r==null?void 0:r.id)===t.id&&h(l=>l&&{...l,name:w(t)}),q(null),Y("")}finally{W(null)}}},[r==null?void 0:r.id,u,F,z,i]),Ie=n.useCallback(async()=>{if(!(!M||!i)){W("delete");try{await Oe(i,M.id);const e=await u(i);(r==null?void 0:r.id)===M.id&&(c(),x.current={project:i,sessionId:""},h(null),v([]),f(i)),e.length===0&&v([]),O(null)}finally{W(null)}}},[r==null?void 0:r.id,M,u,i,c,f]);n.useEffect(()=>{fe()},[fe]),n.useEffect(()=>{j&&(i&&i===j||G(j))},[j,i]),n.useEffect(()=>{if(!i){R([]);return}x.current.project=i,u(i)},[u,i]),n.useEffect(()=>{!i||D||r!=null&&r.id||N.length===0||B(i,N[0])},[r==null?void 0:r.id,N,B,D,i]),n.useEffect(()=>{if(!j||!D||i!==j)return;const e=b.find(t=>t.id===D);if(!e){b.length>0&&f(j,b[0].id);return}(r==null?void 0:r.id)!==e.id&&B(j,e)},[r==null?void 0:r.id,B,j,D,i,b,f]),n.useEffect(()=>{var e;(e=me.current)==null||e.scrollIntoView({behavior:"smooth"})},[I]),n.useEffect(()=>()=>c(),[c]);const Te=(r==null?void 0:r.name)||a("sessions.activeChat");return s.jsxs("div",{className:"grid min-h-[calc(100vh-8rem)] grid-cols-1 gap-4 xl:grid-cols-[22rem_minmax(0,1fr)] animate-fade-in",children:[s.jsxs(pe,{className:"flex flex-col gap-4 border-gray-200/80 bg-[#fbfbfd] p-4 shadow-none xl:h-[calc(100vh-8rem)] xl:overflow-hidden dark:border-white/[0.08] dark:bg-[#111214]",children:[s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.2em] text-gray-400",children:a("sessions.selectProject")}),s.jsxs("select",{value:i,onChange:e=>void Pe(e.target.value),className:"mt-2 w-full rounded-[18px] border border-gray-300/90 bg-white px-3 py-2 text-sm text-gray-900 transition-all focus:border-primary/40 focus:outline-none focus:ring-2 focus:ring-primary/10 dark:border-white/[0.1] dark:bg-[rgba(0,0,0,0.45)] dark:text-white",children:[s.jsx("option",{value:"",children:a("sessions.allProjects")}),se.map(e=>s.jsx("option",{value:e.name,children:e.name},e.name))]})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(ye,{value:J,onChange:e=>re(e.target.value),placeholder:a("common.search"),className:"pl-9","aria-label":a("common.search")}),s.jsx(Ve,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[s.jsx("span",{children:a("sessions.historyTitle")}),s.jsx("span",{children:N.length})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto space-y-2 pr-1",children:Ne?s.jsx("div",{className:"flex h-32 items-center justify-center text-gray-400",children:s.jsx(_,{className:"animate-spin",size:18})}):i?Se&&b.length===0?s.jsx("div",{className:"flex h-32 items-center justify-center text-gray-400",children:s.jsx(_,{className:"animate-spin",size:18})}):b.length===0?s.jsx($,{message:a("sessions.noSessions"),icon:U}):N.length===0?s.jsx($,{message:a("sessions.noSessions"),icon:U}):N.map(e=>{const t=e.id===(r==null?void 0:r.id);return s.jsxs("div",{className:ee("rounded-[18px] border p-3 transition-all",t?"border-primary/25 bg-primary/5":"border-gray-200/80 bg-white hover:border-gray-300 dark:border-white/[0.08] dark:bg-white/[0.03]"),children:[s.jsxs("button",{type:"button",onClick:()=>void B(i,e),className:"w-full text-left","data-testid":"web-chat-session-open",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:w(e)}),e.live||ue.has(e.id)?s.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[10px] text-primary",children:"live"}):s.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[10px] text-gray-400 dark:bg-white/[0.06] dark:text-gray-500",children:"history"})]}),s.jsx("p",{className:"mt-1 truncate text-xs text-gray-500 dark:text-gray-400",children:He(e.updated_at||e.created_at,a("sessions.justNow"))})]}),s.jsx("span",{className:"shrink-0 text-[10px] text-gray-400",children:e.history_count})]}),s.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-gray-500 dark:text-gray-400",children:rs(e,a)})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-end gap-1",children:[s.jsx(C,{size:"sm",variant:"ghost",onClick:()=>{q({id:e.id,name:w(e)}),Y(w(e))},"data-testid":"web-chat-session-rename",children:s.jsx(Ge,{size:14})}),s.jsx(C,{size:"sm",variant:"ghost",onClick:()=>O({id:e.id,name:w(e)}),"data-testid":"web-chat-session-delete",children:s.jsx(Je,{size:14})})]})]},e.id)}):s.jsx($,{message:a("sessions.projectRequired"),icon:U})})]})]}),s.jsxs(pe,{className:"flex min-h-[32rem] flex-col border-gray-200/80 bg-white p-0 shadow-none xl:h-[calc(100vh-8rem)] dark:border-white/[0.08] dark:bg-[#0b0d10]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200/80 px-5 py-4 dark:border-white/[0.08]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("h2",{className:"truncate text-lg font-semibold text-gray-900 dark:text-white",children:Te})}),s.jsx("p",{className:"mt-1 truncate text-sm text-gray-500 dark:text-gray-400",children:r?r.project:a("sessions.sendHint")})]}),s.jsxs(C,{size:"sm",variant:"secondary",onClick:()=>void _e(),"data-testid":"web-chat-refresh",children:[s.jsx(De,{size:14})," ",a("common.refresh")]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:i?Ce?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400",children:s.jsx(_,{className:"animate-spin",size:22})}):I.length===0?s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx($,{message:a(r?"sessions.noMessages":"sessions.sendHint"),icon:U})}):s.jsxs("div",{className:"mx-auto max-w-4xl space-y-5",children:[I.map(e=>{const t=e.role==="user";return s.jsxs("div",{className:ee("flex gap-3",t?"justify-end":"justify-start"),children:[!t&&s.jsx("div",{className:"mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#f5f5f7] dark:bg-white/[0.06]",children:s.jsx(Qe,{size:16,className:"text-primary"})}),s.jsx("div",{className:ee("max-w-[78%] rounded-[20px] px-5 py-3.5 text-sm",t?"chat-user-glass rounded-br-sm text-slate-950 dark:text-slate-50":"rounded-bl-sm border border-gray-200 bg-[#fbfbfd] text-gray-900 dark:border-white/[0.08] dark:bg-[rgba(255,255,255,0.04)] dark:text-gray-100"),children:s.jsx(Le,{content:e.content,isUser:t})}),t&&s.jsx("div",{className:"mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#f0f0f0] dark:bg-white/[0.08]",children:s.jsx(Xe,{size:16,className:"text-gray-500 dark:text-gray-300"})})]},e.id)}),s.jsx("div",{ref:me})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx($,{message:a("sessions.emptySelection"),icon:U})})}),s.jsxs("div",{className:"border-t border-gray-200/80 px-5 py-4 dark:border-white/[0.08]",children:[de&&s.jsx("div",{className:"mb-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/20 dark:text-red-300",children:de}),E==="polling"&&s.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400",children:[s.jsx(_,{size:14,className:"animate-spin"}),s.jsx("span",{children:a("sessions.waitingForReply")})]}),E==="activating"&&s.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400",children:[s.jsx(_,{size:14,className:"animate-spin"}),s.jsx("span",{children:a("sessions.preparingChat")})]}),s.jsx("div",{className:"mx-auto max-w-4xl",children:s.jsxs("div",{className:"relative",children:[s.jsx(Ae,{value:T,onChange:e=>Q(e.target.value),onKeyDown:e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),ge())},rows:3,placeholder:a(i?"sessions.messageInput":"sessions.projectRequired"),disabled:!i||!A||X||E==="polling"||E==="activating",className:"min-h-[104px] rounded-[22px] border-gray-200 bg-[#fbfbfd] px-4 pb-16 pt-3 text-[15px] leading-6 dark:border-white/[0.08] dark:bg-[rgba(255,255,255,0.04)] sm:min-h-[112px] sm:px-5 sm:pt-4","data-testid":"web-chat-input"}),s.jsx(C,{onClick:()=>void ge(),disabled:!Ee,size:"icon","aria-label":a("sessions.send"),className:"absolute bottom-3 right-3 h-11 w-11 rounded-full bg-primary px-0 text-white shadow-none hover:bg-[#0071e3] disabled:bg-slate-300 disabled:text-white disabled:opacity-100 dark:bg-primary dark:text-white dark:hover:bg-[#2997ff] dark:disabled:bg-white/20 dark:disabled:text-white/55 sm:h-12 sm:w-12","data-testid":"web-chat-send",children:X?s.jsx(_,{size:18,className:"animate-spin"}):s.jsx(Be,{size:22,strokeWidth:2.2})})]})}),!A&&r&&s.jsx("div",{className:"mt-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-500 dark:border-white/[0.08] dark:bg-white/[0.03] dark:text-gray-400",children:a("sessions.notLiveHint")})]})]}),s.jsx(be,{open:!!z,onClose:()=>q(null),title:a("sessions.renameTitle"),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(ye,{value:F,onChange:e=>Y(e.target.value),placeholder:a("sessions.renamePlaceholder"),"data-testid":"web-chat-rename-input"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(C,{variant:"secondary",onClick:()=>q(null),children:a("common.cancel")}),s.jsx(C,{onClick:()=>void Re(),loading:ce==="rename","data-testid":"web-chat-rename-save",children:a("common.save")})]})]})}),s.jsx(be,{open:!!M,onClose:()=>O(null),title:a("sessions.deleteConfirmTitle"),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a("sessions.deleteConfirmBody")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(C,{variant:"secondary",onClick:()=>O(null),children:a("common.cancel")}),s.jsx(C,{variant:"danger",onClick:()=>void Ie(),loading:ce==="delete","data-testid":"web-chat-delete-confirm",children:a("common.delete")})]})]})})]})}export{js as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as qi,
|
|
1
|
+
import{c as qi,J as dr,j as Te,g as Bo,r as Fo}from"./index-mvjDN9uV.js";import{C as zo}from"./check-DjFX73Zi.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as m,u as B,r as n,j as e,B as c,R as E,L as
|
|
1
|
+
import{c as m,u as B,r as n,j as e,B as c,R as E,L as H,a0 as $,I as q,a1 as T,a2 as V}from"./index-mvjDN9uV.js";import{g as F,q as X,v as R,w as G,x as J}from"./desktop-DMkue1T6.js";import{B as x}from"./Badge-C92lMj9Q.js";import{P as O,S as l,a as C}from"./Page-vZ-_l6Kn.js";import{S as Q}from"./shield-check-Cv5d_blH.js";import{S as W,P as Y}from"./save-DtvrD3W1.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -18,4 +18,4 @@ import{c as m,u as B,r as n,j as e,B as c,R as E,L as $,$ as H,I as q,a0 as T,a1
|
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const re=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],ie=m("stethoscope",re);function le(a){return a==="api_ready"?"success":a==="error"?"danger":a==="starting"?"warning":"neutral"}function xe(){const{t:a}=B(),[t,h]=n.useState(null),[o,M]=n.useState(null),[p,f]=n.useState([]),[d,I]=n.useState(null),[u,j]=n.useState(""),[D,v]=n.useState(""),[P,y]=n.useState(!0),[w,N]=n.useState(!1),[z,k]=n.useState(!1),[b,i]=n.useState(""),g=n.useCallback(async()=>{y(!0);try{const[s,r,S]=await Promise.allSettled([F(),X(),R()]);s.status==="fulfilled"&&(h(s.value),j(s.value.settings.knowledge.baseUrl||""),v(s.value.settings.knowledge.baseUrl||"")),r.status==="fulfilled"&&M(r.value),S.status==="fulfilled"&&f(S.value)}finally{y(!1)}},[]);n.useEffect(()=>{g()},[g]);const A=async()=>{if(confirm(a("system.restartConfirm")))try{await T(),i(a("common.success")),await g()}catch(s){i(s.message)}},L=async()=>{if(confirm(a("system.reloadConfirm")))try{await V(),i(a("common.success")),await g()}catch(s){i(s.message)}},U=async()=>{N(!0);try{const s=await G({knowledge:{baseUrl:u,authMode:(t==null?void 0:t.settings.knowledge.authMode)||"none",token:(t==null?void 0:t.settings.knowledge.token)||"",headerName:(t==null?void 0:t.settings.knowledge.headerName)||"X-API-Key",defaultCollection:(t==null?void 0:t.settings.knowledge.defaultCollection)||"personal_knowledge"}});h(r=>r&&{...r,settings:s}),v(s.knowledge.baseUrl||""),i(a("common.success"))}catch(s){i(s.message)}finally{N(!1)}},_=async()=>{k(!0);try{const s=await J();I(s),f(await R()),i(`Diagnostics completed with ${s.status} status.`)}catch(s){i(s.message)}finally{k(!1)}},K=u!==D;return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(O,{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:L,children:[e.jsx(E,{size:16})," ",a("system.reload")]}),e.jsxs(c,{variant:"danger",onClick:A,children:[e.jsx(te,{size:16})," ",a("system.restart")]}),e.jsx(
|
|
21
|
+
*/const re=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],ie=m("stethoscope",re);function le(a){return a==="api_ready"?"success":a==="error"?"danger":a==="starting"?"warning":"neutral"}function xe(){const{t:a}=B(),[t,h]=n.useState(null),[o,M]=n.useState(null),[p,f]=n.useState([]),[d,I]=n.useState(null),[u,j]=n.useState(""),[D,v]=n.useState(""),[P,y]=n.useState(!0),[w,N]=n.useState(!1),[z,k]=n.useState(!1),[b,i]=n.useState(""),g=n.useCallback(async()=>{y(!0);try{const[s,r,S]=await Promise.allSettled([F(),X(),R()]);s.status==="fulfilled"&&(h(s.value),j(s.value.settings.knowledge.baseUrl||""),v(s.value.settings.knowledge.baseUrl||"")),r.status==="fulfilled"&&M(r.value),S.status==="fulfilled"&&f(S.value)}finally{y(!1)}},[]);n.useEffect(()=>{g()},[g]);const A=async()=>{if(confirm(a("system.restartConfirm")))try{await T(),i(a("common.success")),await g()}catch(s){i(s.message)}},L=async()=>{if(confirm(a("system.reloadConfirm")))try{await V(),i(a("common.success")),await g()}catch(s){i(s.message)}},U=async()=>{N(!0);try{const s=await G({knowledge:{baseUrl:u,authMode:(t==null?void 0:t.settings.knowledge.authMode)||"none",token:(t==null?void 0:t.settings.knowledge.token)||"",headerName:(t==null?void 0:t.settings.knowledge.headerName)||"X-API-Key",defaultCollection:(t==null?void 0:t.settings.knowledge.defaultCollection)||"personal_knowledge"}});h(r=>r&&{...r,settings:s}),v(s.knowledge.baseUrl||""),i(a("common.success"))}catch(s){i(s.message)}finally{N(!1)}},_=async()=>{k(!0);try{const s=await J();I(s),f(await R()),i(`Diagnostics completed with ${s.status} status.`)}catch(s){i(s.message)}finally{k(!1)}},K=u!==D;return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(O,{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:L,children:[e.jsx(E,{size:16})," ",a("system.reload")]}),e.jsxs(c,{variant:"danger",onClick:A,children:[e.jsx(te,{size:16})," ",a("system.restart")]}),e.jsx(H,{to:"/system/logs",children:e.jsxs(c,{variant:"secondary",children:[e.jsx(ne,{size:16})," ",a("system.logs")]})})]})}),b?e.jsx("div",{role:"status",className:"rounded-lg border border-primary/20 bg-primary/10 px-4 py-3 text-sm text-primary",children:b}):null,e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-3",children:[e.jsxs(l,{className:"app-panel",title:"Runtime",description:P?"Loading...":"Local service status.",children:[e.jsx(C,{tone:le(t==null?void 0:t.phase),children:(t==null?void 0:t.phase)||"unknown"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:t!=null&&t.pendingRestart?"Restart required to apply saved changes.":"No pending restart."})]}),e.jsx(l,{className:"app-panel",title:"Config",description:"Active config file location.",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ee,{size:18,className:"mt-0.5 text-primary"}),e.jsx("p",{className:"break-all font-mono text-xs leading-5 text-muted-foreground",children:(t==null?void 0:t.settings.configPath)||(t==null?void 0:t.configFile.path)||"-"})]})}),e.jsxs(l,{className:"app-panel",title:"Plugins",description:"Health summary only.",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:o?`${o.enabledPluginCount}/${o.pluginCount}`:"-"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"enabled plugins"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[e.jsx(l,{className:"app-panel",title:"Diagnostics",description:"Structured runtime and channel health checks.",actions:e.jsxs(c,{size:"sm",variant:"secondary",onClick:()=>void _(),loading:z,children:[e.jsx(ie,{size:14})," Run doctor"]}),children:d?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{tone:d.status==="pass"?"success":d.status==="warn"?"warning":"danger",children:d.status}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Checked ",new Date(d.checkedAt).toLocaleString()]})]}),e.jsx("div",{className:"space-y-2",children:d.checks.map(s=>{var r;return e.jsx("div",{className:"app-list-row",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:"text-sm font-medium text-foreground",children:s.label}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:s.summary}),(r=s.errorInfo)!=null&&r.suggestedAction?e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-700 dark:text-amber-200",children:s.errorInfo.suggestedAction}):null]}),e.jsx(x,{variant:s.status==="pass"?"success":s.status==="warn"?"warning":"danger",children:s.status})]})},s.id)})})]}):e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(Q,{size:16,className:"mt-0.5 shrink-0"}),e.jsx("p",{children:"Run doctor to validate config, runtime readiness, channel health, and log access."})]})}),e.jsx(l,{className:"app-panel",title:"Recent Errors",description:"Aggregated runtime and channel failures from the current window.",children:p.length===0?e.jsx("div",{className:"py-8 text-sm text-muted-foreground",children:"No aggregated errors in the current diagnostics window."}):e.jsx("div",{className:"space-y-3",children:p.map(s=>e.jsx("div",{className:"app-list-row",children:e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx($,{size:14,className:"text-amber-500"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.errorInfo.userMessage}),e.jsx(x,{variant:s.errorInfo.severity==="error"?"danger":s.errorInfo.severity==="warning"?"warning":"info",children:s.errorInfo.code})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:s.errorInfo.message}),s.errorInfo.suggestedAction?e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-700 dark:text-amber-200",children:s.errorInfo.suggestedAction}):null,e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[s.count," occurrence(s), last seen ",new Date(s.lastSeenAt).toLocaleString()]})]})})},s.key))})})]}),e.jsx(l,{className:"app-panel",title:"Knowledge",description:"System-wide knowledge API connection.",actions:e.jsxs(c,{size:"sm",onClick:()=>void U(),loading:w,disabled:!K&&!w,children:[e.jsx(W,{size:14})," Save"]}),children:e.jsx(q,{label:"Knowledge base URL",value:u,onChange:s=>j(s.target.value),placeholder:"http://127.0.0.1:16007"})}),e.jsx(l,{className:"app-panel",title:a("system.plugins"),description:"Plugin state is read-only in the daily UI. Use backend config for advanced changes.",children:o?o.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:o.plugins.map(s=>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(Y,{size:15,className:"text-muted-foreground"}),e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:s.pluginId})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.health.summary||s.manifest.provides.join(", ")||"No declared capabilities"})]}),e.jsx(x,{variant:s.health.status==="healthy"?"success":s.health.status==="failed"?"danger":"warning",children:s.health.status})]},s.pluginId))}):e.jsx("div",{className:"py-8 text-sm text-muted-foreground",children:"Loading..."})})]})}export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{K as P,l as R,N as z,O as D,P as W,Q as O,u as B,r as n,j as t,s as F,B as c,H as L,C as U,G as k,I as f,T as H}from"./index-mvjDN9uV.js";import{B as u}from"./Badge-C92lMj9Q.js";import{M as G}from"./Modal-DIc9HxD5.js";import{S as w}from"./Select-BN2HMOmY.js";import{E as K}from"./EmptyState-bF6Sc61O.js";import{P as Q}from"./Page-vZ-_l6Kn.js";import{P as _}from"./plus-B76JWGKd.js";import{P as $}from"./play-CPCcNQcH.js";import{P as q}from"./pencil-qpMjLIFd.js";import{T as V}from"./trash-2-C2mimX2b.js";import"./index-CZN1STMc.js";import"./chevron-down-B02YlQS_.js";import"./check-DjFX73Zi.js";const X=a=>P(),Y=a=>D(a),Z=(a,o)=>z(a,o),ee=a=>W(a),te=a=>O(a),ae=()=>R().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 ye(){const{t:a}=B(),[o,I]=n.useState([]),[m,j]=n.useState([]),[T,y]=n.useState(!0),[C,d]=n.useState(!1),[S,v]=n.useState(!1),[p,h]=n.useState(null),[s,r]=n.useState(x),E=n.useMemo(()=>m.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id)),[m]),i=n.useCallback(async()=>{y(!0);try{const[e,l]=await Promise.all([X(),ae()]);I(e.jobs||[]),j(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 N=()=>{var e;h(null),r({...x,workspaceId:((e=m[0])==null?void 0:e.id)||""}),d(!0)},b=e=>{h(e),r(se(e)),d(!0)},J=async()=>{if(!(!s.workspaceId||!s.promptTemplate.trim())&&!(s.triggerType==="once"&&!s.runAt)){v(!0);try{const e=re(s);p?await Z(p.id,e):await Y(e),d(!1),h(null),r(x),await i()}finally{v(!1)}}},A=async e=>{confirm(a("common.confirmDelete"))&&(await ee(e),await i())},M=async e=>{await te(e),await i()};return T&&o.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:N,children:[t.jsx(_,{size:16})," ",a("cron.add")]})}),o.length===0?t.jsx(K,{message:a("cron.noJobs"),icon:L}):t.jsx("div",{className:"space-y-3",children:o.map(e=>t.jsx(U,{className:"app-panel",children:t.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",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:"mt-3 line-clamp-3 rounded-[16px] bg-black/[0.035] px-3 py-2 text-sm leading-6 text-gray-700 dark:bg-white/[0.05] dark:text-gray-300",children:e.promptTemplate}),e.lastError&&t.jsx("p",{className:"text-xs text-red-500 mt-2",children:e.lastError})]}),t.jsxs("div",{className:"flex shrink-0 gap-2 lg:pt-0",children:[t.jsx(c,{size:"sm",variant:"secondary",className:"app-icon-button",onClick:()=>void M(e.id),"aria-label":"Run now",children:t.jsx($,{size:14})}),t.jsx(c,{size:"sm",variant:"secondary",className:"app-icon-button",onClick:()=>b(e),"aria-label":"Edit job",children:t.jsx(q,{size:14})}),t.jsx(c,{size:"sm",variant:"danger",className:"app-icon-button",onClick:()=>void A(e.id),"aria-label":"Delete job",children:t.jsx(V,{size:14})})]})]})},e.id))}),t.jsx(G,{open:C,onClose:()=>d(!1),title:p?"Edit scheduler job":a("cron.add"),children:t.jsxs("div",{className:"space-y-4",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.jsxs("div",{className:"space-y-2",children:[t.jsx(f,{label:a("cron.expression"),value:s.cronExpr,onChange:e=>r({...s,cronExpr:e.target.value}),placeholder:"0 9 * * *"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:[["0 9 * * *","Daily 09:00"],["0 9 * * 1","Weekly Mon"],["*/30 * * * *","Every 30m"]].map(([e,l])=>t.jsx("button",{type:"button",onClick:()=>r({...s,cronExpr:e}),className:`app-segment text-xs ${s.cronExpr===e?"app-segment-active":"app-segment-idle"}`,children:l},e))})]}):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(H,{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:()=>d(!1),children:a("common.cancel")}),t.jsx(c,{onClick:()=>void J(),disabled:S,children:a(p?"common.save":"cron.add")})]})]})})]})}export{ye as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as b,u as ae,r,a as re,l as ie,b as L,d as ne,e as de,j as e,M as le,W as ce,F as V,C as f,B as oe,R as me,f as xe,L as E,S as ue,g as he}from"./index-
|
|
1
|
+
import{c as b,u as ae,r,a as re,l as ie,b as L,d as ne,e as de,j as e,M as le,W as ce,F as V,C as f,B as oe,R as me,f as xe,L as E,S as ue,g as he}from"./index-mvjDN9uV.js";import{B as d}from"./Badge-C92lMj9Q.js";import{E as j}from"./EmptyState-bF6Sc61O.js";import{P as pe}from"./Page-vZ-_l6Kn.js";import{l as ge}from"./projects-C1nFINjh.js";import{l as fe,r as je,o as be,a as ve}from"./desktop-DMkue1T6.js";import{S as ke,A as K}from"./server-D0zmghb3.js";import{B as ye}from"./book-open-CarZFsXv.js";import{S as O}from"./shield-check-Cv5d_blH.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -23,4 +23,4 @@ import{c as b,u as ae,r,a as re,l as ie,b as L,d as ne,e as de,j as e,M as le,W
|
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Ee=[["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"}]],Ce=b("list-checks",Ee);function _e({title:a,description:t,to:l,icon:o,primary:m}){return e.jsxs(E,{to:l,className:["group flex min-h-[112px] flex-col justify-between rounded-[18px] border p-5 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring",m?"border-primary/20 bg-primary/5 text-foreground hover:bg-primary/10 dark:bg-primary/10 dark:hover:bg-primary/15":"border-black/[0.08] bg-white text-foreground hover:bg-[#fcfcfd] dark:border-white/[0.07] dark:bg-white/[0.04] dark:hover:bg-white/[0.07]"].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-full bg-primary/10 text-primary dark:bg-primary/15",children:e.jsx(o,{size:20})}),e.jsx(K,{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 N({label:a,value:t,detail:l,tone:o="neutral"}){return e.jsxs("div",{className:"app-surface p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a}),e.jsx("p",{className:he("mt-2 text-2xl font-semibold",o==="primary"?"text-primary":o==="warning"?"text-amber-600 dark:text-amber-300":"text-foreground"),children:t}),e.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:l})]})}function ze(a){return a.readiness==="ready"?"success":a.readiness==="failed"?"danger":a.readiness==="degraded"?"warning":a.status==="installed"?"success":a.status==="error"?"danger":"warning"}function De(a){return a.readiness||(a.status==="installed"?"ready":"unknown")}function M({title:a,description:t,tasks:l,empty:o,urgent:m}){return e.jsxs(f,{className:"app-panel 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(d,{variant:m&&l.length>0?"warning":"secondary",children:l.length})]})}),l.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:o,icon:Ce})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:l.map(c=>e.jsxs("div",{className:"px-5 py-4 transition-colors hover:bg-black/[0.025] dark:hover:bg-white/[0.035]",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:c.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[c.workspaceId," · ",c.runtimeId]})]}),e.jsx(d,{variant:c.status==="failed"?"danger":c.status==="completed"?"success":"info",children:c.status})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",new Date(c.updatedAt).toLocaleString()]})]},c.taskId))})]})}function Pe({approvals:a}){return e.jsxs(f,{className:"app-panel 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(d,{variant:a.length>0?"warning":"secondary",children:a.length})]})}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无待审批操作",icon:O})}):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(d,{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 Te({events:a}){return e.jsxs(f,{className:"app-panel 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(j,{message:"暂无审计记录",icon:O})}):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(d,{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 Ke(){const{t:a}=ae(),[t,l]=r.useState([]),[o,m]=r.useState([]),[c,C]=r.useState([]),[w,_]=r.useState([]),[Q,z]=r.useState([]),[R,D]=r.useState([]),[G,P]=r.useState([]),[J,T]=r.useState(!0),[X,I]=r.useState(!1),[Y,p]=r.useState(!1),[q,$]=r.useState(""),[B,g]=r.useState(""),{desktopRuntime:x,desktopWorkspace:W,knowledgeModule:F,schedulerModule:H}=re(),A=o.filter(s=>s.installed),v=[{title:"继续聊天",description:"打开本地对话,继续当前项目里的 agent 线程。",to:"/chat",icon:le,primary:!0},{title:"工作区",description:"管理项目、平台、模型和本地运行配置。",to:W?"/workspace":"/projects",icon:W?ce:V}];F&&v.push({title:"知识库",description:"上传文档,维护可被检索的项目资料。",to:"/knowledge",icon:ye}),H&&v.push({title:"定时任务",description:"查看和管理自动执行的计划任务。",to:"/cron",icon:Ae}),(!F||!H)&&v.push({title:"系统设置",description:"查看配置、日志和桌面应用偏好。",to:"/system",icon:ue});const k=r.useCallback(async()=>{var s;T(!0),$(""),g("");try{if(x){const[h,i]=await Promise.all([ie(),fe().then(u=>({status:"fulfilled",runtimes:u}),u=>({status:"rejected",error:u}))]),[S,y,ee]=await Promise.all([L({status:["created","queued","running"],limit:6}),L({status:"waiting_for_user",limit:6}),L({status:["completed","failed","cancelled"],limit:6})]),[se,te]=await Promise.all([ne({status:"pending",limit:6}),de({limit:6})]);C(S.tasks||[]),_(y.tasks||[]),z(ee.tasks||[]),D(se.approvals||[]),P(te.events||[]),l((h.workspaces||[]).map(u=>({name:u.name,agent_type:u.agentType,platforms:u.platforms,sessions_count:u.sessionsCount,heartbeat_enabled:u.heartbeatEnabled}))),i.status==="fulfilled"?m(i.runtimes):(m([]),g(((s=i.error)==null?void 0:s.message)||String(i.error)));return}const n=await ge();l(n.projects||[]),m([]),C([]),_([]),z([]),D([]),P([])}catch(n){$(n.message||String(n))}finally{T(!1)}},[x]),Z=r.useCallback(async()=>{I(!0),p(!0),g("");try{m(await je())}catch(s){g(s.message||String(s))}finally{I(!1),p(!1)}},[]);return r.useEffect(()=>{k();const s=()=>k();window.addEventListener("cc:refresh",s);const n=x?be(()=>{k()}):()=>{},h=x?ve(i=>{if(i.type==="runtime.detect.started"){p(!0);return}if(i.type==="runtime.detect.completed"){p(!1),m(i.runtimes);return}if(i.type==="runtime.detect.failed"){p(!1),g(i.error);return}i.type==="runtime.status.changed"&&m(S=>S.map(y=>y.runtimeId===i.runtime.runtimeId?i.runtime:y))}):()=>{};return()=>{window.removeEventListener("cc:refresh",s),n(),h()}},[x,k]),J&&t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:e.jsx(we,{className:"animate-pulse",size:24})}):e.jsxs("div",{className:"animate-fade-in space-y-8",children:[e.jsx(pe,{title:"概览",description:"继续最近的工作,或进入项目、知识和自动化配置。当前版本 v0.1.47"}),e.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(N,{label:"Projects",value:t.length,detail:"configured workspaces",tone:"primary"}),e.jsx(N,{label:"Running",value:c.length,detail:"active agent tasks"}),e.jsx(N,{label:"Waiting",value:w.length+R.length,detail:"needs attention",tone:w.length+R.length>0?"warning":"neutral"}),e.jsx(N,{label:"Runtimes",value:A.length,detail:"installed locally"})]}),q?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:q}):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:v.map(s=>e.jsx(_e,{...s},s.to))})]}),x?e.jsxs(f,{className:"app-panel 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(d,{variant:A.length>0?"success":"default",children:[A.length," installed"]}),Y?e.jsx(d,{variant:"info",children:"checking"}):null,e.jsxs(oe,{variant:"outline",size:"sm",loading:X,onClick:Z,title:"刷新 runtime 检测",children:[e.jsx(me,{size:15}),"刷新"]})]})]}),B?e.jsxs("div",{className:"px-5 py-4 text-sm text-amber-700 dark:text-amber-200",children:["检测失败:",B]}):o.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"还没有 runtime 检测结果",icon:U})}):e.jsx("div",{className:"grid grid-cols-1 gap-3 p-5 md:grid-cols-2 xl:grid-cols-3",children:o.map(s=>{var n,h;return e.jsxs("div",{className:"app-list-row",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(U,{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(Le,{size:18,className:"mt-0.5 shrink-0 text-emerald-500"}):e.jsx(xe,{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(d,{variant:s.status==="installed"?"success":s.status==="error"?"danger":"warning",children:s.status}),e.jsx(d,{variant:ze(s),children:De(s)}),e.jsx(d,{children:s.source}),s.version?e.jsxs(d,{variant:"secondary",children:["v",s.version]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-5 text-muted-foreground",children:s.summary}),s.lastLaunchError?e.jsx("p",{className:"mt-2 text-xs leading-5 text-red-600 dark:text-red-200",children:s.lastLaunchError.userMessage}):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,(n=s.lastLaunchError)!=null&&n.suggestedAction?e.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:s.lastLaunchError.suggestedAction}):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]&&!((h=s.lastLaunchError)!=null&&h.suggestedAction)?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.lastCheckedAt||s.detectedAt).toLocaleString()]})]},s.agentType)})})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-3",children:[e.jsx(M,{title:"运行中任务",description:"正在排队或执行的 agent 工作。",tasks:c,empty:"暂无运行中的任务"}),e.jsx(M,{title:"等待处理",description:"需要用户输入或审批的任务。",tasks:w,empty:"暂无等待处理的任务",urgent:!0}),e.jsx(M,{title:"最近完成",description:"最近结束、失败或取消的任务。",tasks:Q,empty:"暂无最近任务"})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[e.jsx(Pe,{approvals:R}),e.jsx(Te,{events:G})]}):null,e.jsxs(f,{className:"app-panel 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(E,{to:x?"/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(j,{message:a("projects.noProjects"),icon:V})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:t.slice(0,6).map(s=>{var n;return e.jsxs(E,{to:x?`/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(ke,{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," · ",((n=s.platforms)==null?void 0:n.join(", "))||"no platform"," · ",s.sessions_count," sessions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.heartbeat_enabled?e.jsx(d,{variant:"success",children:"heartbeat"}):null,e.jsx(K,{size:16,className:"text-muted-foreground/45 transition-colors group-hover:text-foreground"})]})]},s.name)})})]})]})}export{Ke as default};
|
|
26
|
+
*/const Ee=[["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"}]],Ce=b("list-checks",Ee);function _e({title:a,description:t,to:l,icon:o,primary:m}){return e.jsxs(E,{to:l,className:["group flex min-h-[112px] flex-col justify-between rounded-[18px] border p-5 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring",m?"border-primary/20 bg-primary/5 text-foreground hover:bg-primary/10 dark:bg-primary/10 dark:hover:bg-primary/15":"border-black/[0.08] bg-white text-foreground hover:bg-[#fcfcfd] dark:border-white/[0.07] dark:bg-white/[0.04] dark:hover:bg-white/[0.07]"].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-full bg-primary/10 text-primary dark:bg-primary/15",children:e.jsx(o,{size:20})}),e.jsx(K,{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 N({label:a,value:t,detail:l,tone:o="neutral"}){return e.jsxs("div",{className:"app-surface p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a}),e.jsx("p",{className:he("mt-2 text-2xl font-semibold",o==="primary"?"text-primary":o==="warning"?"text-amber-600 dark:text-amber-300":"text-foreground"),children:t}),e.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:l})]})}function ze(a){return a.readiness==="ready"?"success":a.readiness==="failed"?"danger":a.readiness==="degraded"?"warning":a.status==="installed"?"success":a.status==="error"?"danger":"warning"}function De(a){return a.readiness||(a.status==="installed"?"ready":"unknown")}function M({title:a,description:t,tasks:l,empty:o,urgent:m}){return e.jsxs(f,{className:"app-panel 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(d,{variant:m&&l.length>0?"warning":"secondary",children:l.length})]})}),l.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:o,icon:Ce})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:l.map(c=>e.jsxs("div",{className:"px-5 py-4 transition-colors hover:bg-black/[0.025] dark:hover:bg-white/[0.035]",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:c.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[c.workspaceId," · ",c.runtimeId]})]}),e.jsx(d,{variant:c.status==="failed"?"danger":c.status==="completed"?"success":"info",children:c.status})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",new Date(c.updatedAt).toLocaleString()]})]},c.taskId))})]})}function Pe({approvals:a}){return e.jsxs(f,{className:"app-panel 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(d,{variant:a.length>0?"warning":"secondary",children:a.length})]})}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无待审批操作",icon:O})}):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(d,{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 Te({events:a}){return e.jsxs(f,{className:"app-panel 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(j,{message:"暂无审计记录",icon:O})}):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(d,{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 Ke(){const{t:a}=ae(),[t,l]=r.useState([]),[o,m]=r.useState([]),[c,C]=r.useState([]),[w,_]=r.useState([]),[Q,z]=r.useState([]),[R,D]=r.useState([]),[G,P]=r.useState([]),[J,T]=r.useState(!0),[X,I]=r.useState(!1),[Y,p]=r.useState(!1),[q,$]=r.useState(""),[B,g]=r.useState(""),{desktopRuntime:x,desktopWorkspace:W,knowledgeModule:F,schedulerModule:H}=re(),A=o.filter(s=>s.installed),v=[{title:"继续聊天",description:"打开本地对话,继续当前项目里的 agent 线程。",to:"/chat",icon:le,primary:!0},{title:"工作区",description:"管理项目、平台、模型和本地运行配置。",to:W?"/workspace":"/projects",icon:W?ce:V}];F&&v.push({title:"知识库",description:"上传文档,维护可被检索的项目资料。",to:"/knowledge",icon:ye}),H&&v.push({title:"定时任务",description:"查看和管理自动执行的计划任务。",to:"/cron",icon:Ae}),(!F||!H)&&v.push({title:"系统设置",description:"查看配置、日志和桌面应用偏好。",to:"/system",icon:ue});const k=r.useCallback(async()=>{var s;T(!0),$(""),g("");try{if(x){const[h,i]=await Promise.all([ie(),fe().then(u=>({status:"fulfilled",runtimes:u}),u=>({status:"rejected",error:u}))]),[S,y,ee]=await Promise.all([L({status:["created","queued","running"],limit:6}),L({status:"waiting_for_user",limit:6}),L({status:["completed","failed","cancelled"],limit:6})]),[se,te]=await Promise.all([ne({status:"pending",limit:6}),de({limit:6})]);C(S.tasks||[]),_(y.tasks||[]),z(ee.tasks||[]),D(se.approvals||[]),P(te.events||[]),l((h.workspaces||[]).map(u=>({name:u.name,agent_type:u.agentType,platforms:u.platforms,sessions_count:u.sessionsCount,heartbeat_enabled:u.heartbeatEnabled}))),i.status==="fulfilled"?m(i.runtimes):(m([]),g(((s=i.error)==null?void 0:s.message)||String(i.error)));return}const n=await ge();l(n.projects||[]),m([]),C([]),_([]),z([]),D([]),P([])}catch(n){$(n.message||String(n))}finally{T(!1)}},[x]),Z=r.useCallback(async()=>{I(!0),p(!0),g("");try{m(await je())}catch(s){g(s.message||String(s))}finally{I(!1),p(!1)}},[]);return r.useEffect(()=>{k();const s=()=>k();window.addEventListener("cc:refresh",s);const n=x?be(()=>{k()}):()=>{},h=x?ve(i=>{if(i.type==="runtime.detect.started"){p(!0);return}if(i.type==="runtime.detect.completed"){p(!1),m(i.runtimes);return}if(i.type==="runtime.detect.failed"){p(!1),g(i.error);return}i.type==="runtime.status.changed"&&m(S=>S.map(y=>y.runtimeId===i.runtime.runtimeId?i.runtime:y))}):()=>{};return()=>{window.removeEventListener("cc:refresh",s),n(),h()}},[x,k]),J&&t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:e.jsx(we,{className:"animate-pulse",size:24})}):e.jsxs("div",{className:"animate-fade-in space-y-8",children:[e.jsx(pe,{title:"概览",description:"继续最近的工作,或进入项目、知识和自动化配置。当前版本 v0.1.48"}),e.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(N,{label:"Projects",value:t.length,detail:"configured workspaces",tone:"primary"}),e.jsx(N,{label:"Running",value:c.length,detail:"active agent tasks"}),e.jsx(N,{label:"Waiting",value:w.length+R.length,detail:"needs attention",tone:w.length+R.length>0?"warning":"neutral"}),e.jsx(N,{label:"Runtimes",value:A.length,detail:"installed locally"})]}),q?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:q}):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:v.map(s=>e.jsx(_e,{...s},s.to))})]}),x?e.jsxs(f,{className:"app-panel 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(d,{variant:A.length>0?"success":"default",children:[A.length," installed"]}),Y?e.jsx(d,{variant:"info",children:"checking"}):null,e.jsxs(oe,{variant:"outline",size:"sm",loading:X,onClick:Z,title:"刷新 runtime 检测",children:[e.jsx(me,{size:15}),"刷新"]})]})]}),B?e.jsxs("div",{className:"px-5 py-4 text-sm text-amber-700 dark:text-amber-200",children:["检测失败:",B]}):o.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"还没有 runtime 检测结果",icon:U})}):e.jsx("div",{className:"grid grid-cols-1 gap-3 p-5 md:grid-cols-2 xl:grid-cols-3",children:o.map(s=>{var n,h;return e.jsxs("div",{className:"app-list-row",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(U,{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(Le,{size:18,className:"mt-0.5 shrink-0 text-emerald-500"}):e.jsx(xe,{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(d,{variant:s.status==="installed"?"success":s.status==="error"?"danger":"warning",children:s.status}),e.jsx(d,{variant:ze(s),children:De(s)}),e.jsx(d,{children:s.source}),s.version?e.jsxs(d,{variant:"secondary",children:["v",s.version]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-5 text-muted-foreground",children:s.summary}),s.lastLaunchError?e.jsx("p",{className:"mt-2 text-xs leading-5 text-red-600 dark:text-red-200",children:s.lastLaunchError.userMessage}):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,(n=s.lastLaunchError)!=null&&n.suggestedAction?e.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:s.lastLaunchError.suggestedAction}):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]&&!((h=s.lastLaunchError)!=null&&h.suggestedAction)?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.lastCheckedAt||s.detectedAt).toLocaleString()]})]},s.agentType)})})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-3",children:[e.jsx(M,{title:"运行中任务",description:"正在排队或执行的 agent 工作。",tasks:c,empty:"暂无运行中的任务"}),e.jsx(M,{title:"等待处理",description:"需要用户输入或审批的任务。",tasks:w,empty:"暂无等待处理的任务",urgent:!0}),e.jsx(M,{title:"最近完成",description:"最近结束、失败或取消的任务。",tasks:Q,empty:"暂无最近任务"})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[e.jsx(Pe,{approvals:R}),e.jsx(Te,{events:G})]}):null,e.jsxs(f,{className:"app-panel 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(E,{to:x?"/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(j,{message:a("projects.noProjects"),icon:V})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:t.slice(0,6).map(s=>{var n;return e.jsxs(E,{to:x?`/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(ke,{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," · ",((n=s.platforms)==null?void 0:n.join(", "))||"no platform"," · ",s.sessions_count," sessions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.heartbeat_enabled?e.jsx(d,{variant:"success",children:"heartbeat"}):null,e.jsx(K,{size:16,className:"text-muted-foreground/45 transition-colors group-hover:text-foreground"})]})]},s.name)})})]})]})}export{Ke as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as y,
|
|
1
|
+
import{c as y,E as q,r as t,aQ as C,b0 as H,aR as P,b1 as U,b2 as G,b3 as O,b4 as Q,j as e,L as _,B as p,S as V,C as x,g as Z,G as F,I as J}from"./index-mvjDN9uV.js";import{E}from"./EmptyState-bF6Sc61O.js";import{A as W}from"./arrow-left-DNovvfPp.js";import{S as X}from"./search-Ddth-YHH.js";import{T as Y}from"./trash-2-C2mimX2b.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,4 +13,4 @@ import{c as y,D as R,r as t,aP as C,a$ as q,aQ as H,b0 as U,b1 as O,b2 as Q,b3 a
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
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"}]],K=y("upload",re);function B(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=""}=
|
|
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"}]],K=y("upload",re);function B(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=""}=q(),[f,u]=t.useState(!0),[j,b]=t.useState(!1),[I,k]=t.useState(!1),[m,M]=t.useState(!1),[r,A]=t.useState(null),[N,z]=t.useState([]),[g,D]=t.useState([]),[w,v]=t.useState([]),[n,R]=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(),H(a),P(),U(a).catch(()=>({files:[]}))]);M(!!s.baseUrl),A(d),z(l.folders||[]),D(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=t.useCallback(async s=>{const d=Array.from(s.target.files||[]);if(!(!a||d.length===0)){b(!0);try{const l=await C();await G(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]),$=t.useCallback(async s=>{if(!(!a||!window.confirm(`Delete file "${s.fileName}"?`)))try{await O(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 Q(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(W,{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 ${B(h.tone)}`,children:h.message}),!m&&!f&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${B("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(V,{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:Z("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(K,{size:14}),j?"上传中…":"上传文件",e.jsx("input",{type:"file",multiple:!0,className:"hidden",disabled:!m||j,onChange:s=>void T(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(X,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx(J,{value:n,onChange:s=>R(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:K}):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 $(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(Y,{size:15})})]},s.fileId))]})]})]}):e.jsx(x,{children:e.jsx(E,{message:"没有找到这个知识库。",icon:te})})]})}export{oe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as _,r as t,
|
|
1
|
+
import{c as _,r as t,aQ as ae,aR as se,z as te,aS as re,aT as ne,aU as ie,aV as le,aW as oe,aX as de,j as e,L as D,B as d,S as ce,C as x,g as I,h as me,I as C,aY as xe,G as ge,T as pe}from"./index-mvjDN9uV.js";import{M as L}from"./Modal-DIc9HxD5.js";import{E as R}from"./EmptyState-bF6Sc61O.js";import{P}from"./pencil-qpMjLIFd.js";import{T as O}from"./trash-2-C2mimX2b.js";import{S as he}from"./search-Ddth-YHH.js";import{P as ue}from"./plus-B76JWGKd.js";import{B as ye}from"./book-open-CarZFsXv.js";import"./index-CZN1STMc.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{c as _,r as t,aP as ae,aQ as se,y as te,aR as re,aS as ne,aT as ie,aU as
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const be=[["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=_("folders",be);function T(o){return o==="success"?"border-primary/20 bg-primary/10 text-primary dark:border-primary/25 dark:bg-primary/10 dark:text-blue-200":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 ve(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 Me(){const[o,F]=t.useState(!0),[m,q]=t.useState([]),[j,A]=t.useState([]),[l,b]=t.useState(null),[g,U]=t.useState(""),[H,V]=t.useState(!1),[Q,p]=t.useState(!1),[W,h]=t.useState(!1),[u,B]=t.useState(""),[y,K]=t.useState(""),[v,E]=t.useState(""),[w,r]=t.useState(null),[z,f]=t.useState(null),n=t.useCallback(async()=>{F(!0);try{const[a,s,i]=await Promise.all([ae(),se(),te()]);V(!!a.baseUrl),q(s.folders||[]),A(i.bases||[])}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{F(!1)}},[]);t.useEffect(()=>{n()},[n]);const N=t.useMemo(()=>{if(!l)return null;const a=m.find(i=>i.id===l);if(!a)return null;const s=new Set([a.id]);return m.forEach(i=>{i.path.startsWith(`${a.path}/`)&&s.add(i.id)}),s},[m,l]),M=t.useMemo(()=>{const a=g.trim().toLowerCase();return j.filter(s=>(N?N.has(s.folderId||""):!0)?a?[s.name,s.description,s.creatorName].join(" ").toLowerCase().includes(a):!0:!1)},[j,N,g]),Z=t.useCallback(async()=>{if(!u.trim()){r({tone:"warning",message:"Folder name is required."});return}f("folder");try{await re({name:u.trim(),parentId:l}),B(""),p(!1),r({tone:"success",message:"Folder created."}),await n()}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{f(null)}},[u,n,l]),G=t.useCallback(async()=>{if(!y.trim()){r({tone:"warning",message:"Knowledge base name is required."});return}f("base");try{await ne({name:y.trim(),description:v.trim(),folderId:l}),K(""),E(""),h(!1),r({tone:"success",message:"Knowledge base created."}),await n()}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{f(null)}},[v,y,n,l]),X=t.useCallback(async a=>{var i;const s=(i=window.prompt("Rename folder",a.name))==null?void 0:i.trim();if(!(!s||s===a.name))try{await ie(a.id,{name:s}),r({tone:"success",message:"Folder updated."}),await n()}catch(c){r({tone:"error",message:c instanceof Error?c.message:String(c)})}},[n]),J=t.useCallback(async a=>{if(window.confirm(`Delete folder "${a.name}"?`))try{await le(a.id),l===a.id&&b(null),r({tone:"success",message:"Folder deleted."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}},[n,l]),Y=t.useCallback(async a=>{var c,$;const s=(c=window.prompt("Knowledge base name",a.name))==null?void 0:c.trim();if(!s)return;const i=(($=window.prompt("Description",a.description))==null?void 0:$.trim())??a.description;try{await oe(a.id,{name:s,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=t.useCallback(async a=>{if(window.confirm(`Delete knowledge base "${a.name}"?`))try{await de(a.id),r({tone:"success",message:"Knowledge base deleted."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}},[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 ${T(w.tone)}`,children:w.message}),!H&&!o&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${T("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(D,{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:"app-panel 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:()=>p(!0),children:[e.jsx(je,{size:14})," 文件夹"]})]})}),e.jsx("div",{className:"px-5 py-4",children:e.jsxs("button",{type:"button",onClick:()=>b(null),className:I("flex w-full items-center justify-between rounded-[16px] 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-primary/10 text-gray-900 ring-1 ring-primary/25 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(a=>{const s=a.id===l;return e.jsx("div",{className:I("group rounded-[16px] px-2 py-1",s?"bg-primary/10 ring-1 ring-primary/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:()=>b(a.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left",style:{paddingLeft:`${8+we(a.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:a.name})]}),e.jsx("button",{type:"button",onClick:()=>void X(a),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 ${a.name}`,children:e.jsx(P,{size:14})}),e.jsx("button",{type:"button",onClick:()=>void J(a),className:"rounded-md p-1 text-gray-400 transition hover:bg-red-500/10 hover:text-red-500","aria-label":`Delete ${a.name}`,children:e.jsx(O,{size:14})})]})},a.id)})})})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(x,{className:"app-toolbar",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(he,{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:a=>U(a.target.value),placeholder:"搜索名称、描述或创建者","aria-label":"搜索名称、描述或创建者",className:"pl-9"})]}),e.jsxs(d,{variant:"secondary",onClick:()=>h(!0),children:[e.jsx(ue,{size:14})," 创建知识库"]})]})]})}),o?e.jsx(x,{className:"app-panel",children:e.jsx("div",{className:"py-16 text-center text-sm text-gray-400",children:"正在加载知识库…"})}):M.length===0?e.jsx(x,{className:"app-panel",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(a=>e.jsxs(x,{className:"group app-panel relative overflow-hidden p-5 hover:border-primary/25",children:[e.jsxs("div",{className:"absolute right-4 top-4 flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void Y(a),"aria-label":`编辑 ${a.name}`,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(a),"aria-label":`删除 ${a.name}`,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(D,{to:`/knowledge/${encodeURIComponent(a.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-11 w-11 items-center justify-center rounded-full text-white ${ve(a.icon)}`,children:e.jsx(ye,{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:a.name}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["创建者: ",a.creatorName||"系统管理员"]})]})]}),e.jsx("div",{className:"min-h-[60px] text-sm leading-6 text-gray-600 dark:text-gray-300",children:a.description||"这个知识库还没有描述,点击进入后可以上传文件并开始检索。"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 rounded-[16px] bg-black/[0.035] px-3 py-2 text-sm font-medium text-gray-700 dark:bg-white/[0.05] dark:text-gray-200",children:[e.jsxs("span",{children:[a.fileCount," 文档数"]}),e.jsxs("span",{children:[(a.wordCount/1e3).toFixed(a.wordCount>0?1:0),"k 字符"]})]}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:["更新于 ",ge(a.updatedAt)]})]})]},a.id))})]})]}),e.jsx(L,{open:Q,onClose:()=>p(!1),title:"创建文件夹",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"文件夹名称",value:u,onChange:a=>B(a.target.value),placeholder:"例如:产品文档"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"secondary",onClick:()=>p(!1),children:"取消"}),e.jsx(d,{onClick:()=>void Z(),loading:z==="folder",children:"创建"})]})]})}),e.jsx(L,{open:W,onClose:()=>h(!1),title:"创建知识库",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"名称",value:y,onChange:a=>K(a.target.value),placeholder:"例如:运营文档库"}),e.jsx(pe,{label:"描述",rows:4,value:v,onChange:a=>E(a.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 G(),loading:z==="base",children:"创建"})]})]})})]})}export{Me as default};
|
|
11
|
+
*/const be=[["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=_("folders",be);function T(o){return o==="success"?"border-primary/20 bg-primary/10 text-primary dark:border-primary/25 dark:bg-primary/10 dark:text-blue-200":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 ve(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 Me(){const[o,F]=t.useState(!0),[m,q]=t.useState([]),[j,A]=t.useState([]),[l,b]=t.useState(null),[g,U]=t.useState(""),[H,V]=t.useState(!1),[G,p]=t.useState(!1),[Q,h]=t.useState(!1),[u,B]=t.useState(""),[y,K]=t.useState(""),[v,z]=t.useState(""),[w,r]=t.useState(null),[E,f]=t.useState(null),n=t.useCallback(async()=>{F(!0);try{const[a,s,i]=await Promise.all([ae(),se(),te()]);V(!!a.baseUrl),q(s.folders||[]),A(i.bases||[])}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{F(!1)}},[]);t.useEffect(()=>{n()},[n]);const N=t.useMemo(()=>{if(!l)return null;const a=m.find(i=>i.id===l);if(!a)return null;const s=new Set([a.id]);return m.forEach(i=>{i.path.startsWith(`${a.path}/`)&&s.add(i.id)}),s},[m,l]),M=t.useMemo(()=>{const a=g.trim().toLowerCase();return j.filter(s=>(N?N.has(s.folderId||""):!0)?a?[s.name,s.description,s.creatorName].join(" ").toLowerCase().includes(a):!0:!1)},[j,N,g]),W=t.useCallback(async()=>{if(!u.trim()){r({tone:"warning",message:"Folder name is required."});return}f("folder");try{await re({name:u.trim(),parentId:l}),B(""),p(!1),r({tone:"success",message:"Folder created."}),await n()}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{f(null)}},[u,n,l]),Z=t.useCallback(async()=>{if(!y.trim()){r({tone:"warning",message:"Knowledge base name is required."});return}f("base");try{await ne({name:y.trim(),description:v.trim(),folderId:l}),K(""),z(""),h(!1),r({tone:"success",message:"Knowledge base created."}),await n()}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{f(null)}},[v,y,n,l]),X=t.useCallback(async a=>{var i;const s=(i=window.prompt("Rename folder",a.name))==null?void 0:i.trim();if(!(!s||s===a.name))try{await ie(a.id,{name:s}),r({tone:"success",message:"Folder updated."}),await n()}catch(c){r({tone:"error",message:c instanceof Error?c.message:String(c)})}},[n]),Y=t.useCallback(async a=>{if(window.confirm(`Delete folder "${a.name}"?`))try{await le(a.id),l===a.id&&b(null),r({tone:"success",message:"Folder deleted."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}},[n,l]),J=t.useCallback(async a=>{var c,$;const s=(c=window.prompt("Knowledge base name",a.name))==null?void 0:c.trim();if(!s)return;const i=(($=window.prompt("Description",a.description))==null?void 0:$.trim())??a.description;try{await oe(a.id,{name:s,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=t.useCallback(async a=>{if(window.confirm(`Delete knowledge base "${a.name}"?`))try{await de(a.id),r({tone:"success",message:"Knowledge base deleted."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}},[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 ${T(w.tone)}`,children:w.message}),!H&&!o&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${T("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(D,{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:"app-panel 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:()=>p(!0),children:[e.jsx(je,{size:14})," 文件夹"]})]})}),e.jsx("div",{className:"px-5 py-4",children:e.jsxs("button",{type:"button",onClick:()=>b(null),className:I("flex w-full items-center justify-between rounded-[16px] 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-primary/10 text-gray-900 ring-1 ring-primary/25 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(a=>{const s=a.id===l;return e.jsx("div",{className:I("group rounded-[16px] px-2 py-1",s?"bg-primary/10 ring-1 ring-primary/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:()=>b(a.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left",style:{paddingLeft:`${8+we(a.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:a.name})]}),e.jsx("button",{type:"button",onClick:()=>void X(a),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 ${a.name}`,children:e.jsx(P,{size:14})}),e.jsx("button",{type:"button",onClick:()=>void Y(a),className:"rounded-md p-1 text-gray-400 transition hover:bg-red-500/10 hover:text-red-500","aria-label":`Delete ${a.name}`,children:e.jsx(O,{size:14})})]})},a.id)})})})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(x,{className:"app-toolbar",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(he,{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:a=>U(a.target.value),placeholder:"搜索名称、描述或创建者","aria-label":"搜索名称、描述或创建者",className:"pl-9"})]}),e.jsxs(d,{variant:"secondary",onClick:()=>h(!0),children:[e.jsx(ue,{size:14})," 创建知识库"]})]})]})}),o?e.jsx(x,{className:"app-panel",children:e.jsx("div",{className:"py-16 text-center text-sm text-gray-400",children:"正在加载知识库…"})}):M.length===0?e.jsx(x,{className:"app-panel",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(a=>e.jsxs(x,{className:"group app-panel relative overflow-hidden p-5 hover:border-primary/25",children:[e.jsxs("div",{className:"absolute right-4 top-4 flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void J(a),"aria-label":`编辑 ${a.name}`,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(a),"aria-label":`删除 ${a.name}`,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(D,{to:`/knowledge/${encodeURIComponent(a.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-11 w-11 items-center justify-center rounded-full text-white ${ve(a.icon)}`,children:e.jsx(ye,{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:a.name}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["创建者: ",a.creatorName||"系统管理员"]})]})]}),e.jsx("div",{className:"min-h-[60px] text-sm leading-6 text-gray-600 dark:text-gray-300",children:a.description||"这个知识库还没有描述,点击进入后可以上传文件并开始检索。"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 rounded-[16px] bg-black/[0.035] px-3 py-2 text-sm font-medium text-gray-700 dark:bg-white/[0.05] dark:text-gray-200",children:[e.jsxs("span",{children:[a.fileCount," 文档数"]}),e.jsxs("span",{children:[(a.wordCount/1e3).toFixed(a.wordCount>0?1:0),"k 字符"]})]}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:["更新于 ",ge(a.updatedAt)]})]})]},a.id))})]})]}),e.jsx(L,{open:G,onClose:()=>p(!1),title:"创建文件夹",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"文件夹名称",value:u,onChange:a=>B(a.target.value),placeholder:"例如:产品文档"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"secondary",onClick:()=>p(!1),children:"取消"}),e.jsx(d,{onClick:()=>void W(),loading:E==="folder",children:"创建"})]})]})}),e.jsx(L,{open:Q,onClose:()=>h(!1),title:"创建知识库",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"名称",value:y,onChange:a=>K(a.target.value),placeholder:"例如:运营文档库"}),e.jsx(pe,{label:"描述",rows:4,value:v,onChange:a=>z(a.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 Z(),loading:E==="base",children:"创建"})]})]})})]})}export{Me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as b,r as t,
|
|
1
|
+
import{u as b,r as t,aO as N,j as e,L as S,B as m,I as L,C}from"./index-mvjDN9uV.js";import{B as E}from"./Badge-C92lMj9Q.js";import{S as f}from"./Select-BN2HMOmY.js";import{P as k}from"./Page-vZ-_l6Kn.js";import{A as z}from"./arrow-left-DNovvfPp.js";import{F as B}from"./funnel-Dy1VL-D9.js";import{S as I}from"./search-Ddth-YHH.js";import"./index-CZN1STMc.js";import"./chevron-down-B02YlQS_.js";import"./check-DjFX73Zi.js";const A={sys:"text-gray-300",debug:"text-gray-400",info:"text-blue-400",warn:"text-amber-400",error:"text-red-400"},F={sys:"default",debug:"default",info:"info",warn:"warning",error:"danger"};function W(){const{t:o}=b(),[n,g]=t.useState([]),[l,h]=t.useState("sys"),[i,v]=t.useState("100"),[c,j]=t.useState(""),[d,w]=t.useState(!1),[y,u]=t.useState(!0),a=t.useCallback(async()=>{u(!0);try{const s=await N({level:l,limit:i});g(s.entries||[])}finally{u(!1)}},[l,i]);t.useEffect(()=>{a()},[a]),t.useEffect(()=>{if(!d)return;const s=window.setInterval(()=>{a()},3e3);return()=>window.clearInterval(s)},[d,a]);const x=t.useMemo(()=>{const s=c.trim().toLowerCase();return s?n.filter(r=>[r.level,r.time,r.message].join(" ").toLowerCase().includes(s)):n},[n,c]);return e.jsxs("div",{className:"space-y-4 animate-fade-in",children:[e.jsx(k,{title:o("system.logs"),description:"Filtered runtime logs for troubleshooting.",actions:e.jsx(S,{to:"/system",children:e.jsxs(m,{variant:"secondary",size:"sm",children:[e.jsx(z,{size:14})," ",o("nav.system")]})})}),e.jsxs("div",{className:"app-toolbar flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{size:14,className:"text-muted-foreground"}),e.jsxs(f,{value:l,onChange:s=>h(s.target.value),className:"w-auto",children:[e.jsx("option",{value:"sys",children:"Sys"}),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(f,{value:i,onChange:s=>v(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(m,{size:"sm",variant:"secondary",onClick:a,children:o("common.refresh")}),e.jsx(m,{size:"sm",variant:d?"primary":"secondary",onClick:()=>w(s=>!s),children:"Auto"}),e.jsxs("div",{className:"relative min-w-[16rem] flex-1",children:[e.jsx(I,{size:15,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(L,{value:c,onChange:s=>j(s.target.value),placeholder:"Search logs","aria-label":"Search logs",className:"pl-9"})]})]}),e.jsx(C,{className:"app-panel",children:y?e.jsx("div",{className:"text-muted-foreground animate-pulse text-sm",children:"Loading..."}):x.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:o("common.noData")}):e.jsx("div",{className:"max-h-[65vh] overflow-auto font-mono text-xs [scrollbar-gutter:stable]",children:x.map((s,r)=>{var p;return e.jsxs("div",{className:"grid min-w-[760px] grid-cols-[9rem_5rem_minmax(0,1fr)] items-start gap-3 border-b py-2 last:border-0",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 w-36",children:(p=s.time)==null?void 0:p.slice(0,19)}),e.jsx(E,{variant:F[s.level]||"default",children:s.level}),e.jsx("span",{className:`${A[s.level]||"text-gray-500"} whitespace-pre-wrap break-words`,children:s.message})]},r)})})})]})}export{W as default};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{c as K,r as s,
|
|
1
|
+
import{c as K,r as s,aP as C,j as i,g as M}from"./index-mvjDN9uV.js";import{u as I,d as X,e as O,g as Y,P as x,f as N,R as Z,h as J,c as Q,a as ee,i as te,F as ne,D as oe,j as re}from"./index-CZN1STMc.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
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"}]],ie=K("x",ae);function se(e,t){return s.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}):s.Children.only(o),a=C(n.ref,le(r));return typeof o=="function"||n.isPresent?s.cloneElement(r,{ref:a}):null};y.displayName="Presence";function ce(e){const[t,o]=s.useState(),n=s.useRef(null),r=s.useRef(e),a=s.useRef("none"),c=e?"mounted":"unmounted",[u,d]=se(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.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 H=h(n.current).includes(CSS.escape(p.animationName));if(p.target===t&&H&&(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:s.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=s.useRef(null),d=s.useRef(null),[l,g]=X({prop:n,defaultProp:r??!1,onChange:a,caller:E});return i.jsx(ue,{scope:t,triggerRef:u,contentRef:d,contentId:O(),titleId:O(),descriptionId:O(),open:l,onOpenChange:g,onOpenToggle:s.useCallback(()=>g(m=>!m),[g]),modal:c,children:o})};b.displayName=E;var j="DialogTrigger",de=s.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(j,o),a=C(t,r.triggerRef);return i.jsx(x.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":
|
|
6
|
+
*/const ae=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ie=K("x",ae);function se(e,t){return s.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}):s.Children.only(o),a=C(n.ref,le(r));return typeof o=="function"||n.isPresent?s.cloneElement(r,{ref:a}):null};y.displayName="Presence";function ce(e){const[t,o]=s.useState(),n=s.useRef(null),r=s.useRef(e),a=s.useRef("none"),c=e?"mounted":"unmounted",[u,d]=se(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.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 H=h(n.current).includes(CSS.escape(p.animationName));if(p.target===t&&H&&(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:s.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=s.useRef(null),d=s.useRef(null),[l,g]=X({prop:n,defaultProp:r??!1,onChange:a,caller:E});return i.jsx(ue,{scope:t,triggerRef:u,contentRef:d,contentId:O(),titleId:O(),descriptionId:O(),open:l,onOpenChange:g,onOpenToggle:s.useCallback(()=>g(m=>!m),[g]),modal:c,children:o})};b.displayName=E;var j="DialogTrigger",de=s.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(j,o),a=C(t,r.triggerRef);return i.jsx(x.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":P(r.open),...n,ref:a,onClick:N(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 i.jsx(fe,{scope:t,forceMount:o,children:s.Children.map(n,c=>i.jsx(y,{present:o||a.open,children:i.jsx(Y,{asChild:!0,container:r,children:c})}))})};S.displayName=A;var R="DialogOverlay",F=s.forwardRef((e,t)=>{const o=w(R,e.__scopeDialog),{forceMount:n=o.forceMount,...r}=e,a=f(R,e.__scopeDialog);return a.modal?i.jsx(y,{present:n||a.open,children:i.jsx(me,{...r,ref:t})}):null});F.displayName=R;var ge=ee("DialogOverlay.RemoveScroll"),me=s.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(R,o);return i.jsx(Z,{as:ge,allowPinchZoom:!0,shards:[r.contentRef],children:i.jsx(x.div,{"data-state":P(r.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),v="DialogContent",W=s.forwardRef((e,t)=>{const o=w(v,e.__scopeDialog),{forceMount:n=o.forceMount,...r}=e,a=f(v,e.__scopeDialog);return i.jsx(y,{present:n||a.open,children:a.modal?i.jsx(pe,{...r,ref:t}):i.jsx(ve,{...r,ref:t})})});W.displayName=v;var pe=s.forwardRef((e,t)=>{const o=f(v,e.__scopeDialog),n=s.useRef(null),r=C(t,o.contentRef,n);return s.useEffect(()=>{const a=n.current;if(a)return J(a)},[]),i.jsx(L,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:N(e.onCloseAutoFocus,a=>{var c;a.preventDefault(),(c=o.triggerRef.current)==null||c.focus()}),onPointerDownOutside:N(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0;(c.button===2||u)&&a.preventDefault()}),onFocusOutside:N(e.onFocusOutside,a=>a.preventDefault())})}),ve=s.forwardRef((e,t)=>{const o=f(v,e.__scopeDialog),n=s.useRef(!1),r=s.useRef(!1);return i.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=s.forwardRef((e,t)=>{const{__scopeDialog:o,trapFocus:n,onOpenAutoFocus:r,onCloseAutoFocus:a,...c}=e,u=f(v,o),d=s.useRef(null),l=C(t,d);return te(),i.jsxs(i.Fragment,{children:[i.jsx(ne,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:r,onUnmountAutoFocus:a,children:i.jsx(oe,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":P(u.open),...c,ref:l,onDismiss:()=>u.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(xe,{titleId:u.titleId}),i.jsx(he,{contentRef:d,descriptionId:u.descriptionId})]})]})}),_="DialogTitle",k=s.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(_,o);return i.jsx(x.h2,{id:r.titleId,...n,ref:t})});k.displayName=_;var U="DialogDescription",Ne=s.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(U,o);return i.jsx(x.p,{id:r.descriptionId,...n,ref:t})});Ne.displayName=U;var G="DialogClose",$=s.forwardRef((e,t)=>{const{__scopeDialog:o,...n}=e,r=f(G,o);return i.jsx(x.button,{type:"button",...n,ref:t,onClick:N(e.onClick,()=>r.onOpenChange(!1))})});$.displayName=G;function P(e){return e?"open":"closed"}var z="DialogTitleWarning",[Me,B]=re(z,{contentName:v,titleName:_,docsSlug:"dialog"}),xe=({titleId:e})=>{const t=B(z),o=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
7
7
|
|
|
8
8
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
9
9
|
|
|
10
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return s.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 s.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 i.jsx(Re,{open:e,onOpenChange:a=>{a||t()},children:i.jsxs(Ce,{children:[i.jsx(ye,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-fade-in"}),i.jsxs(Ee,{className:
|
|
10
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return s.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 s.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 i.jsx(Re,{open:e,onOpenChange:a=>{a||t()},children:i.jsxs(Ce,{children:[i.jsx(ye,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-fade-in"}),i.jsxs(Ee,{className:M("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:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Oe,{className:"text-lg font-semibold leading-none tracking-tight",children:o}),i.jsx(Ae,{className:M("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:i.jsx(ie,{size:18})})]}),n]})]})})}export{Ie as M,ie as X};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{U as q,l as D,V as W,X as $,Y as B,_ as F,u as L,r as l,j as s,s as R,B as p,$ as O,C as U,G as V,I as x,T as G}from"./index-mvjDN9uV.js";import{B as h}from"./Badge-C92lMj9Q.js";import{M as H}from"./Modal-DIc9HxD5.js";import{S as y}from"./Select-BN2HMOmY.js";import{E as X}from"./EmptyState-bF6Sc61O.js";import{P as Y}from"./Page-vZ-_l6Kn.js";import{P as Z}from"./plus-B76JWGKd.js";import{P as J}from"./play-CPCcNQcH.js";import{P as K}from"./pencil-qpMjLIFd.js";import{T as Q}from"./trash-2-C2mimX2b.js";import"./index-CZN1STMc.js";import"./chevron-down-B02YlQS_.js";import"./check-DjFX73Zi.js";const ee=t=>q(),te=t=>$(t),se=(t,o)=>W(t,o),ae=t=>B(t),ne=t=>F(t),oe=()=>D().then(t=>t.workspaces),g={workspaceId:"",title:"",sourceType:"stock.quote",symbol:"",condition:"abs_change_percent >= 3",promptTemplate:"",cooldownMinutes:"15",executionMode:"side-thread",enabled:!0};function v(t){const o=t.trim();if(o.includes("&&")||o.includes("||"))return{metric:"expression",operator:"==",value:!0,expression:o};const c=o.match(/^([a-zA-Z0-9_.-]+)\s*(>=|<=|==|!=|>|<)\s*(.+)$/);if(!c)return null;const r=String(c[3]||"").trim(),m=Number(r);return{metric:String(c[1]||"").trim(),operator:c[2],value:Number.isFinite(m)&&r!==""?m:r}}function C(t){return t.condition.expression?t.condition.expression:`${t.condition.metric} ${t.condition.operator} ${t.condition.value}`}function ie(t){return t?{workspaceId:t.workspaceId,title:t.title,sourceType:"stock.quote",symbol:String(t.sourceConfig.symbol||""),condition:C(t),promptTemplate:t.promptTemplate,cooldownMinutes:String(Math.round(t.cooldownMs/6e4)),executionMode:t.executionMode,enabled:t.enabled}:g}function le(t){const o=v(t.condition);if(!o)throw new Error("Invalid condition");return{workspaceId:t.workspaceId,title:t.title,sourceType:t.sourceType,sourceConfig:k[t.sourceType].buildConfig(t),condition:o,promptTemplate:t.promptTemplate,executionMode:t.executionMode,cooldownMs:Math.max(0,Number(t.cooldownMinutes||"0")*6e4),enabled:t.enabled}}const k={"stock.quote":{label:"Stock quote",buildConfig:t=>({symbol:t.symbol.toUpperCase()}),renderSummary:t=>String(t.sourceConfig.symbol||"")}};function ve(){const{t}=L(),[o,c]=l.useState([]),[r,m]=l.useState([]),[T,w]=l.useState(!0),[S,u]=l.useState(!1),[N,M]=l.useState(!1),[j,b]=l.useState(null),[a,n]=l.useState(g),I=l.useMemo(()=>r.map(e=>s.jsx("option",{value:e.id,children:e.name},e.id)),[r]),d=l.useCallback(async()=>{w(!0);try{const[e,i]=await Promise.all([ee(),oe()]);c(e.monitors||[]),m(i),n(f=>f.workspaceId||i.length===0?f:{...f,workspaceId:i[0].id})}finally{w(!1)}},[]);l.useEffect(()=>{d();const e=R(i=>{(i.type==="automation.monitor.updated"||i.type==="automation.monitor.run.updated")&&d()});return()=>e()},[d]);const E=()=>{var e;b(null),n({...g,workspaceId:((e=r[0])==null?void 0:e.id)||""}),u(!0)},P=e=>{b(e),n(ie(e)),u(!0)},A=async()=>{if(!(!a.workspaceId||!a.title.trim()||!a.symbol.trim()||!a.promptTemplate.trim()||!v(a.condition))){M(!0);try{const e=le(a);j?await se(j.id,e):await te(e),u(!1),b(null),n(g),await d()}finally{M(!1)}}},_=async e=>{confirm(t("common.confirmDelete"))&&(await ae(e),await d())},z=async e=>{await ne(e),await d()};return T&&o.length===0?s.jsx("div",{className:"flex h-64 items-center justify-center text-gray-400 animate-pulse",children:t("common.loading")}):s.jsxs("div",{className:"space-y-4 animate-fade-in",children:[s.jsx(Y,{title:t("monitors.title"),description:"Create event monitors that trigger agent analysis and stream results back to channels.",actions:s.jsxs(p,{onClick:E,children:[s.jsx(Z,{size:16})," ",t("monitors.add")]})}),o.length===0?s.jsx(X,{message:t("monitors.noMonitors"),icon:O}):s.jsx("div",{className:"space-y-3",children:o.map(e=>s.jsx(U,{className:"app-panel",children:s.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.title}),s.jsx(h,{variant:e.enabled?"success":"default",children:e.enabled?t("monitors.enabled"):"disabled"}),s.jsx(h,{variant:"default",children:e.sourceType}),s.jsx(h,{variant:"default",children:e.platform}),e.lastStatus&&s.jsx(h,{variant:e.lastStatus==="failed"?"danger":"default",children:e.lastStatus})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[s.jsxs("span",{children:[s.jsx("strong",{children:"Workspace:"})," ",e.workspaceId]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Subject:"})," ",k["stock.quote"].renderSummary(e)]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Condition:"})," ",C(e)]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Execution:"})," ",e.executionMode]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Cooldown:"})," ",Math.round(e.cooldownMs/6e4),"m"]}),e.lastTriggeredAt&&s.jsxs("span",{children:[s.jsxs("strong",{children:[t("monitors.lastRun"),":"]})," ",V(e.lastTriggeredAt)]})]}),s.jsx("p",{className:"mt-3 line-clamp-3 rounded-[16px] bg-black/[0.035] px-3 py-2 text-sm leading-6 text-gray-700 dark:bg-white/[0.05] dark:text-gray-300",children:e.promptTemplate}),e.lastError&&s.jsx("p",{className:"mt-2 text-xs text-red-500",children:e.lastError})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(p,{variant:"secondary",size:"sm",className:"app-icon-button",onClick:()=>z(e.id),title:t("monitors.run"),"aria-label":t("monitors.run"),children:s.jsx(J,{size:14})}),s.jsx(p,{variant:"secondary",size:"sm",className:"app-icon-button",onClick:()=>P(e),title:t("common.save"),"aria-label":t("common.save"),children:s.jsx(K,{size:14})}),s.jsx(p,{variant:"danger",size:"sm",className:"app-icon-button",onClick:()=>_(e.id),title:t("common.delete"),"aria-label":t("common.delete"),children:s.jsx(Q,{size:14})})]})]})},e.id))}),s.jsx(H,{open:S,title:t(j?"monitors.edit":"monitors.add"),onClose:()=>u(!1),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(y,{label:"Workspace",value:a.workspaceId,onChange:e=>n({...a,workspaceId:e.target.value}),children:I}),s.jsx(x,{label:t("monitors.monitorTitle"),value:a.title,onChange:e=>n({...a,title:e.target.value})}),s.jsx(y,{label:"Source",value:a.sourceType,onChange:e=>n({...a,sourceType:e.target.value}),children:Object.entries(k).map(([e,i])=>s.jsx("option",{value:e,children:i.label},e))}),a.sourceType==="stock.quote"&&s.jsx(x,{label:"Symbol",value:a.symbol,onChange:e=>n({...a,symbol:e.target.value}),placeholder:"AAPL"}),s.jsx(x,{label:t("monitors.condition"),value:a.condition,onChange:e=>n({...a,condition:e.target.value}),placeholder:"abs_change_percent >= 3"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:[["abs_change_percent >= 3","+/- 3%"],["price >= 500","Price >= 500"],["volume_ratio >= 2","Volume spike"]].map(([e,i])=>s.jsx("button",{type:"button",onClick:()=>n({...a,condition:e}),className:`app-segment text-xs ${a.condition===e?"app-segment-active":"app-segment-idle"}`,children:i},e))}),v(a.condition)?null:s.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-200",children:"Condition should look like metric >= value or a boolean expression."}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(x,{label:t("monitors.cooldown"),value:a.cooldownMinutes,onChange:e=>n({...a,cooldownMinutes:e.target.value})}),s.jsxs(y,{label:"Execution",value:a.executionMode,onChange:e=>n({...a,executionMode:e.target.value}),children:[s.jsx("option",{value:"side-thread",children:"side-thread"}),s.jsx("option",{value:"same-thread",children:"same-thread"})]})]}),s.jsx(G,{label:t("monitors.prompt"),rows:6,value:a.promptTemplate,onChange:e=>n({...a,promptTemplate:e.target.value})}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,onChange:e=>n({...a,enabled:e.target.checked})}),t("monitors.enabled")]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(p,{variant:"secondary",onClick:()=>u(!1),children:t("common.cancel")}),s.jsx(p,{onClick:A,disabled:N,children:t("common.save")})]})]})})]})}export{ve as default};
|