@kafca/agentdock 0.1.45 → 0.1.47
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 +11 -0
- package/dist/renderer/assets/{Badge-BIojwD6s.js → Badge-BYREM3t3.js} +1 -1
- package/dist/renderer/assets/Chat-Dtb5X7sB.js +2 -0
- package/dist/renderer/assets/{ChatMarkdown-DqszsPB_.js → ChatMarkdown-_slLloCh.js} +1 -1
- package/dist/renderer/assets/Config-pHichs7H.js +21 -0
- package/dist/renderer/assets/CronList-CJQMeCjz.js +1 -0
- package/dist/renderer/assets/Dashboard-CY77Imde.js +26 -0
- package/dist/renderer/assets/{EmptyState-BqCx1oWr.js → EmptyState-DCqmct2y.js} +1 -1
- package/dist/renderer/assets/{KnowledgeDetail-BwK8Gpfa.js → KnowledgeDetail-DFrxa-pv.js} +1 -1
- package/dist/renderer/assets/KnowledgeHome-DL-vAfrH.js +11 -0
- package/dist/renderer/assets/Logs-jw9Uv590.js +1 -0
- package/dist/renderer/assets/{Modal-D2U4r2V0.js → Modal-ChSm7tk6.js} +1 -1
- package/dist/renderer/assets/MonitorList-DrEwyS71.js +1 -0
- package/dist/renderer/assets/{Page-urf5GcT_.js → Page-DhD-zgMU.js} +1 -1
- package/dist/renderer/assets/ProjectDetail-BVSjpfpL.js +11 -0
- package/dist/renderer/assets/ProjectList-CHGbTJjk.js +1 -0
- package/dist/renderer/assets/{Select-CAscWpy5.js → Select-rHs9CSam.js} +1 -1
- package/dist/renderer/assets/SessionChat-CDc2FNMA.js +1 -0
- package/dist/renderer/assets/SessionList-Mr1uAnRW.js +1 -0
- package/dist/renderer/assets/ThreadChat-Detu5UfN.js +23 -0
- package/dist/renderer/assets/Workspace-MRRg8ndJ.js +19 -0
- package/dist/renderer/assets/{arrow-left-7HrNuS-V.js → arrow-left-BU2NB2LA.js} +1 -1
- package/dist/renderer/assets/{book-open-BDoAu82s.js → book-open-D-TGvWwa.js} +1 -1
- package/dist/renderer/assets/bot-IYNh8tH5.js +6 -0
- package/dist/renderer/assets/{check-DGlyq4xX.js → check-CCZ0JO_S.js} +1 -1
- package/dist/renderer/assets/{chevron-down-Bb_3EHq9.js → chevron-down-00bRZi15.js} +1 -1
- package/dist/renderer/assets/{circle-DIpqZnYw.js → circle-CpQ8x4k_.js} +1 -1
- package/dist/renderer/assets/{desktop-Ci1fnRDR.js → desktop-D0k2aGSj.js} +1 -1
- package/dist/renderer/assets/{desktop-Do_UrC-o.js → desktop-JQkhNOF4.js} +1 -1
- package/dist/renderer/assets/{funnel-Bbf0ERLP.js → funnel-UbcrCBCp.js} +1 -1
- package/dist/renderer/assets/{heart-CGqU-qfw.js → heart-DvLsV7tL.js} +1 -1
- package/dist/renderer/assets/{index-Df-Trovt.js → index-B2L4G-b_.js} +1 -1
- package/dist/renderer/assets/index-CO4fGqmv.css +11 -0
- package/dist/renderer/assets/{index-DwhTjLA1.js → index-dy-g2Bh4.js} +3 -3
- package/dist/renderer/assets/{pencil-CHiy1MvK.js → pencil-qBYOgW5M.js} +1 -1
- package/dist/renderer/assets/{play-CGYnmC4Q.js → play-Dn6b4AGj.js} +1 -1
- package/dist/renderer/assets/{plus-B_Q5-Oj7.js → plus-CaApUwEm.js} +1 -1
- package/dist/renderer/assets/projects-BwF5RlNV.js +1 -0
- package/dist/renderer/assets/save-CN6yvTfD.js +11 -0
- package/dist/renderer/assets/{search-D8Dkhsyq.js → search-Dn2MxYiO.js} +1 -1
- package/dist/renderer/assets/{server-Cd96R7WL.js → server-DpcVLHeh.js} +1 -1
- package/dist/renderer/assets/{session-utils-BNUbQBfF.js → session-utils-DnD2Q_y1.js} +1 -1
- package/dist/renderer/assets/{sessions-BACfV8s1.js → sessions-eK5D4FLt.js} +1 -1
- package/dist/renderer/assets/{shield-check-Cnn-yQUA.js → shield-check-DSSJkacw.js} +1 -1
- package/dist/renderer/assets/{trash-2-oWCxwQ9D.js → trash-2-DmYJlEvO.js} +1 -1
- package/dist/renderer/assets/user-Cvf_uiyQ.js +6 -0
- package/dist/renderer/assets/{wifi-off-DHxnNkdY.js → wifi-off-CCTloj-V.js} +1 -1
- package/dist/renderer/index.html +2 -2
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-session-coordinator.js +2 -1
- package/dist-electron/services/local-ai-core/src/agents/pi/launch.js +1 -1
- package/dist-electron/services/local-ai-core/src/agents/shared/launch-utils.js +22 -0
- package/dist-electron/services/local-ai-core/src/channel/lark/inbound.js +55 -1
- package/dist-electron/services/local-ai-core/src/channel/lark/local-core-lark-gateway.js +132 -348
- package/dist-electron/services/local-ai-core/src/channel/shared/base-channel-gateway.js +303 -0
- package/dist-electron/services/local-ai-core/src/channel/weixin/local-core-weixin-gateway.js +131 -382
- package/dist-electron/services/local-ai-core/src/runtime/agent-runtime-detector.js +2 -1
- package/dist-electron/services/local-ai-core/src/runtime/channel-service.js +150 -0
- package/dist-electron/services/local-ai-core/src/runtime/env-utils.js +12 -0
- package/dist-electron/services/local-ai-core/src/runtime/external-service.js +234 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/automation-handler.js +34 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/capabilities-handler.js +12 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/channel-handler.js +65 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/external-handler.js +17 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/knowledge-handler.js +65 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/openai-handler.js +496 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/provider-handler.js +24 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/runtime-handler.js +68 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/runtimes-handler.js +37 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/scheduler-handler.js +34 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/security-handler.js +49 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/task-handler.js +27 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/thread-handler.js +42 -0
- package/dist-electron/services/local-ai-core/src/runtime/handlers/workspace-handler.js +29 -0
- package/dist-electron/services/local-ai-core/src/runtime/local-core-controller.js +40 -592
- package/dist-electron/services/local-ai-core/src/runtime/server-helpers.js +96 -0
- package/dist-electron/services/local-ai-core/src/runtime/server.js +107 -1084
- package/dist-electron/services/local-ai-core/src/runtime/standalone.js +13 -1
- package/dist-electron/src/pages/Projects/project-provider-config.js +75 -0
- package/dist-electron/tests/contracts/architecture-docs.test.js +1 -0
- package/dist-electron/tests/electron/agent-runtime-detector.test.js +18 -0
- package/dist-electron/tests/electron/knowledge-skill-script.test.js +15 -5
- package/dist-electron/tests/electron/lac-cli.test.js +591 -688
- package/dist-electron/tests/electron/plugin-kernel.test.js +47 -31
- package/dist-electron/tests/electron/project-provider-config.test.js +71 -0
- package/dist-electron/tests/electron/workspace-task-store.test.js +19 -9
- package/dist-electron/tests/integration/lark-gateway.test.js +80 -0
- package/dist-electron/tests/integration/local-core-cors.test.js +22 -0
- package/package.json +1 -1
- package/dist/renderer/assets/Chat-wjBR3XEX.js +0 -2
- package/dist/renderer/assets/Config-BDCHs5A2.js +0 -21
- package/dist/renderer/assets/CronList-CEWQYTov.js +0 -1
- package/dist/renderer/assets/Dashboard-DrWftfk3.js +0 -26
- package/dist/renderer/assets/KnowledgeHome-hhDTZMDO.js +0 -11
- package/dist/renderer/assets/Logs-C9xPEhFT.js +0 -1
- package/dist/renderer/assets/MonitorList-CayKbfwJ.js +0 -1
- package/dist/renderer/assets/ProjectDetail-B1GyAr7a.js +0 -11
- package/dist/renderer/assets/ProjectList-BoipQypE.js +0 -1
- package/dist/renderer/assets/SessionChat-BAVy5221.js +0 -1
- package/dist/renderer/assets/SessionList-BZpuMvh0.js +0 -1
- package/dist/renderer/assets/ThreadChat-JX7m9biG.js +0 -23
- package/dist/renderer/assets/Workspace-CFW8otjU.js +0 -14
- package/dist/renderer/assets/index-RaTga2BC.css +0 -11
- package/dist/renderer/assets/plug-Mexu4gyV.js +0 -6
- package/dist/renderer/assets/projects-C6bbkC-O.js +0 -1
- package/dist/renderer/assets/save-CJ_QFPw0.js +0 -6
- package/dist/renderer/assets/user-BzE9BwsY.js +0 -11
package/README.md
CHANGED
|
@@ -94,6 +94,17 @@ flowchart LR
|
|
|
94
94
|
|
|
95
95
|
## New
|
|
96
96
|
|
|
97
|
+
### 2026-05-24
|
|
98
|
+
|
|
99
|
+
- 重构 Local AI Core 控制器:提取 ChannelService 与 ExternalService 为独立领域服务,Controller 缩至约 20 个方法,只保留生命周期、配置和事件编排。
|
|
100
|
+
- 拆分 Server 路由:102 路 switch 替换为 Map-based handler 调度,按 domain 提取为 14 个独立 handler 模块(runtime、runtimes、thread、workspace、security、task、scheduler、automation、knowledge、capabilities、provider、channel、external、openai),server.ts 从 1518 行缩减至 396 行。
|
|
101
|
+
- 修复 lac-cli 与 knowledge-skill-script 测试在沙箱环境下的兼容性:用全局 fetch mock 替代 TCP server.listen,EPERM 时优雅跳过。
|
|
102
|
+
|
|
103
|
+
### 2026-05-16
|
|
104
|
+
|
|
105
|
+
- 优化桌面与 Web 聊天界面视觉层级:统一会话列表、消息气泡、工具结果卡片和输入区样式,降低装饰噪音,提升长对话可读性。
|
|
106
|
+
- 统一工作区、概览、知识库、自动化、系统诊断、项目与会话列表页面的轻量面板、列表行、状态摘要和操作按钮样式。
|
|
107
|
+
|
|
97
108
|
### 2026-05-15
|
|
98
109
|
|
|
99
110
|
- 删除旧的 sandbox WebSocket proxy 兼容路径,云端 sandbox ACP 通信统一走 HTTP NDJSON bridge。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,g as a}from"./index-
|
|
1
|
+
import{j as t,g as a}from"./index-dy-g2Bh4.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as ze,x 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-dy-g2Bh4.js";import{M as be}from"./Modal-ChSm7tk6.js";import{E as $}from"./EmptyState-DCqmct2y.js";import{C as Le,A as Be}from"./ChatMarkdown-_slLloCh.js";import{l as Ke}from"./projects-BwF5RlNV.js";import{l as Ue,g as $e,s as qe,a as je,r as Fe,d as Oe}from"./sessions-eK5D4FLt.js";import{s as We,a as we,b as w,L as _,t as He}from"./session-utils-DnD2Q_y1.js";import{S as Ve}from"./search-Dn2MxYiO.js";import{P as Ge}from"./pencil-qBYOgW5M.js";import{T as Je}from"./trash-2-DmYJlEvO.js";import{B as Qe}from"./bot-IYNh8tH5.js";import{U as Xe}from"./user-Cvf_uiyQ.js";import"./index-B2L4G-b_.js";import"./check-CCZ0JO_S.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
|
+
`)}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,H as dr,j as Te,g as Bo,r as Fo}from"./index-
|
|
1
|
+
import{c as qi,H as dr,j as Te,g as Bo,r as Fo}from"./index-dy-g2Bh4.js";import{C as zo}from"./check-CCZ0JO_S.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
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 as V}from"./index-dy-g2Bh4.js";import{g as F,q as X,v as R,w as G,x as J}from"./desktop-D0k2aGSj.js";import{B as x}from"./Badge-BYREM3t3.js";import{P as O,S as l,a as C}from"./Page-DhD-zgMU.js";import{S as Q}from"./shield-check-DSSJkacw.js";import{S as W,P as Y}from"./save-CN6yvTfD.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Z=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],ee=m("file-code",Z);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const se=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],te=m("rotate-ccw",se);/**
|
|
12
|
+
* @license lucide-react v0.487.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ae=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],ne=m("scroll-text",ae);/**
|
|
17
|
+
* @license lucide-react v0.487.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const 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($,{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(H,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{J as P,l as R,K as z,N as D,O as W,P as O,u as B,r as n,j as t,s as F,B as c,G as L,C as U,E as k,I as f,T as G}from"./index-dy-g2Bh4.js";import{B as u}from"./Badge-BYREM3t3.js";import{M as H}from"./Modal-ChSm7tk6.js";import{S as w}from"./Select-rHs9CSam.js";import{E as K}from"./EmptyState-DCqmct2y.js";import{P as _}from"./Page-DhD-zgMU.js";import{P as $}from"./plus-CaApUwEm.js";import{P as q}from"./play-Dn6b4AGj.js";import{P as Q}from"./pencil-qBYOgW5M.js";import{T as V}from"./trash-2-DmYJlEvO.js";import"./index-B2L4G-b_.js";import"./chevron-down-00bRZi15.js";import"./check-CCZ0JO_S.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),[E,v]=n.useState(!1),[p,h]=n.useState(null),[s,r]=n.useState(x),S=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(_,{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(q,{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(H,{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"}),S]}),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(G,{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:E,children:a(p?"common.save":"cron.add")})]})]})})]})}export{ye as default};
|
|
@@ -0,0 +1,26 @@
|
|
|
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-dy-g2Bh4.js";import{B as d}from"./Badge-BYREM3t3.js";import{E as j}from"./EmptyState-DCqmct2y.js";import{P as pe}from"./Page-DhD-zgMU.js";import{l as ge}from"./projects-BwF5RlNV.js";import{l as fe,r as je,o as be,a as ve}from"./desktop-D0k2aGSj.js";import{S as ke,A as K}from"./server-DpcVLHeh.js";import{B as ye}from"./book-open-D-TGvWwa.js";import{S as O}from"./shield-check-DSSJkacw.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Ne=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],we=b("activity",Ne);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Re=[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Ae=b("calendar-clock",Re);/**
|
|
12
|
+
* @license lucide-react v0.487.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Se=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Le=b("circle-check",Se);/**
|
|
17
|
+
* @license lucide-react v0.487.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Me=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],U=b("cpu",Me);/**
|
|
22
|
+
* @license lucide-react v0.487.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const 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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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 as V,j as e,L as _,B as p,S as Z,C as x,g as G,E as F,I as J}from"./index-
|
|
1
|
+
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 as V,j as e,L as _,B as p,S as Z,C as x,g as G,E as F,I as J}from"./index-dy-g2Bh4.js";import{E}from"./EmptyState-DCqmct2y.js";import{A as W}from"./arrow-left-BU2NB2LA.js";import{S as X}from"./search-Dn2MxYiO.js";import{T as Y}from"./trash-2-DmYJlEvO.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
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 le,aV as oe,aW 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,aX as xe,E as ge,T as pe}from"./index-dy-g2Bh4.js";import{M as L}from"./Modal-ChSm7tk6.js";import{E as R}from"./EmptyState-DCqmct2y.js";import{P}from"./pencil-qBYOgW5M.js";import{T as O}from"./trash-2-DmYJlEvO.js";import{S as he}from"./search-Dn2MxYiO.js";import{P as ue}from"./plus-CaApUwEm.js";import{B as ye}from"./book-open-D-TGvWwa.js";import"./index-B2L4G-b_.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const fe=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],je=_("folder-plus",fe);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const 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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as b,r as t,aN as N,j as e,L as S,B as m,I as L,C}from"./index-dy-g2Bh4.js";import{B as E}from"./Badge-BYREM3t3.js";import{S as f}from"./Select-rHs9CSam.js";import{P as k}from"./Page-DhD-zgMU.js";import{A as z}from"./arrow-left-BU2NB2LA.js";import{F as B}from"./funnel-UbcrCBCp.js";import{S as I}from"./search-Dn2MxYiO.js";import"./index-B2L4G-b_.js";import"./chevron-down-00bRZi15.js";import"./check-CCZ0JO_S.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 $(){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{$ as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as K,r as s,aO as C,j as i,g as P}from"./index-
|
|
1
|
+
import{c as K,r as s,aO as C,j as i,g as P}from"./index-dy-g2Bh4.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-B2L4G-b_.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Q as q,l as D,U as W,V as B,X as F,Y as $,u as L,r as l,j as s,s as R,B as p,_ as O,C as U,E as V,I as x,T as H}from"./index-dy-g2Bh4.js";import{B as h}from"./Badge-BYREM3t3.js";import{M as Q}from"./Modal-ChSm7tk6.js";import{S as y}from"./Select-rHs9CSam.js";import{E as X}from"./EmptyState-DCqmct2y.js";import{P as Y}from"./Page-DhD-zgMU.js";import{P as Z}from"./plus-CaApUwEm.js";import{P as G}from"./play-Dn6b4AGj.js";import{P as J}from"./pencil-qBYOgW5M.js";import{T as K}from"./trash-2-DmYJlEvO.js";import"./index-B2L4G-b_.js";import"./chevron-down-00bRZi15.js";import"./check-CCZ0JO_S.js";const ee=t=>q(),te=t=>B(t),se=(t,o)=>W(t,o),ae=t=>F(t),ne=t=>$(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(G,{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(J,{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(K,{size:14})})]})]})},e.id))}),s.jsx(Q,{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(H,{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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,C as m,g as a}from"./index-
|
|
1
|
+
import{j as e,C as m,g as a}from"./index-dy-g2Bh4.js";function u({title:s,description:r,actions:t}){return e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s}),r?e.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-6 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]})}function o({title:s,description:r,actions:t,children:l,className:d,bodyClassName:n}){return e.jsxs(m,{className:a("p-0",d),children:[(s||r||t)&&e.jsxs("div",{className:"flex flex-col gap-3 border-b px-5 py-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[s?e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s}):null,r?e.jsx("p",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]}),e.jsx("div",{className:a("p-5",n),children:l})]})}const x={neutral:"border-border bg-muted text-muted-foreground",success:"border-primary/20 bg-primary/10 text-primary",warning:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-200",danger:"border-destructive/20 bg-destructive/10 text-destructive dark:text-red-200",info:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-400/20 dark:bg-blue-500/10 dark:text-blue-200"};function b({children:s,tone:r="neutral"}){return e.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium",x[r]),children:s})}export{u as P,o as S,b as a};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as oe,A as M,u as we,D as Ne,r as c,j as s,L as Se,B as h,Z as Ce,g as Y,C as w,I as j,E as ke,G as Pe}from"./index-dy-g2Bh4.js";import{B as I}from"./Badge-BYREM3t3.js";import{M as ee}from"./Modal-ChSm7tk6.js";import{S as se}from"./Select-rHs9CSam.js";import{E as ae}from"./EmptyState-DCqmct2y.js";import{P as ze,S as B}from"./Page-DhD-zgMU.js";import{g as Ae}from"./projects-BwF5RlNV.js";import{d as Ie,c as P,h as Ee,f as E,j as Me}from"./desktop-D0k2aGSj.js";import{D as T,e as Le}from"./desktop-JQkhNOF4.js";import{A as $e}from"./arrow-left-BU2NB2LA.js";import{S as Re}from"./shield-check-DSSJkacw.js";import{H as te}from"./heart-DvLsV7tL.js";import{P as De,S as He}from"./save-CN6yvTfD.js";import{P as Be}from"./plus-CaApUwEm.js";import{C as Te}from"./check-CCZ0JO_S.js";import{T as Fe}from"./trash-2-DmYJlEvO.js";import{P as Oe}from"./play-Dn6b4AGj.js";import"./index-B2L4G-b_.js";import"./chevron-down-00bRZi15.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Ue=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],qe=oe("layers",Ue);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Ge=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],Je=oe("pause",Ge),Ke=e=>M.get(`/projects/${e}/heartbeat`),Ze=e=>M.post(`/projects/${e}/heartbeat/pause`),Ve=e=>M.post(`/projects/${e}/heartbeat/resume`),We=e=>M.post(`/projects/${e}/heartbeat/run`),Xe=(e,r)=>M.post(`/projects/${e}/heartbeat/interval`,{minutes:r});function F(e){return JSON.parse(JSON.stringify(e||{}))}function Qe(e,r){var i,o,d;const n=(i=e==null?void 0:e.projects)==null?void 0:i.find(m=>m.name===r);return String(((d=(o=n==null?void 0:n.agent)==null?void 0:o.options)==null?void 0:d.provider_id)||"")}function re(e,r,n){var f;const i=F(e),o=Array.isArray(i.projects)?i.projects:[],d=o.findIndex(_=>_.name===r);if(d<0)throw new Error(`Project not found in config: ${r}`);const m=o[d];return o[d]={...m,agent:{...m.agent,options:{...((f=m.agent)==null?void 0:f.options)||{},provider_id:n}}},i.projects=o,i}function Ye(e,r,n){var f;const i=F(e),o=Array.isArray(i.projects)?i.projects:[],d=o.findIndex(_=>_.name===r);if(d<0)throw new Error(`Project not found in config: ${r}`);const m=o[d];return o[d]={...m,agent:{...m.agent,options:{...((f=m.agent)==null?void 0:f.options)||{},model:n}}},i.projects=o,i}function es(e,r){const n=F(e),i=Array.isArray(n.projects)?n.projects:[];return n.projects=i.map(o=>{var d,m,f;return((m=(d=o.agent)==null?void 0:d.options)==null?void 0:m.provider_id)!==r?o:{...o,agent:{...o.agent,options:{...((f=o.agent)==null?void 0:f.options)||{},provider_id:""}}}}),n}const l={enabled:!1,provider_id:T,runtime_image_id:Le("pi").id,server_url:"http://127.0.0.1:8080",image:"agentdock/pi-acp:local",acp_port:"8080",state_scope:"project",timeout_seconds:"7200",sandbox_lifecycle:"per_thread",idle_seconds:"900",warm_pool_size:"0",cpu:"1000m",memory:"2Gi",workspace_mount_path:"/workspace",state_mount_path:"/agent-state"};function ss(e){const r=new Set,n=String((e==null?void 0:e.model)||"").trim();n&&r.add(n);for(const i of(e==null?void 0:e.models)||[]){const o=String((i==null?void 0:i.model)||"").trim();o&&r.add(o)}return[...r]}function ws(){var K,Z;const{t:e}=we(),{name:r}=Ne(),[n,i]=c.useState("overview"),[o,d]=c.useState(null),[m,f]=c.useState([]),[_,ne]=c.useState(""),[u,ie]=c.useState(null),[O,le]=c.useState([]),[ce,de]=c.useState(""),[me,U]=c.useState(!0),[g,b]=c.useState(l),[xe,q]=c.useState(!1),[G,x]=c.useState(""),[he,L]=c.useState(!1),[v,z]=c.useState({name:"",api_key:"",base_url:"",model:""}),[pe,$]=c.useState(!1),[J,fe]=c.useState("30"),p=c.useCallback(async()=>{var a,t,N,y,S;if(r)try{U(!0);const[C,A,V,W]=await Promise.allSettled([Ae(r),Ie(),Ke(r),P()]);C.status==="fulfilled"&&d(C.value);const X=A.status==="fulfilled"?A.value.providers||[]:[];if(A.status==="fulfilled"&&f(X),V.status==="fulfilled"&&ie(V.value),W.status==="fulfilled"){const R=W.value.parsed,k=(a=R==null?void 0:R.projects)==null?void 0:a.find(H=>H.name===r),Q=Qe(R,r),D=X.find(H=>H.id===Q);ne(Q),le(ss(D)),de(String(((N=(t=k==null?void 0:k.agent)==null?void 0:t.options)==null?void 0:N.model)||(D==null?void 0:D.model)||"")),b(as((S=(y=k==null?void 0:k.agent)==null?void 0:y.options)==null?void 0:S.sandbox))}}finally{U(!1)}},[r]);c.useEffect(()=>{p();const a=()=>p();return window.addEventListener("cc:refresh",a),()=>window.removeEventListener("cc:refresh",a)},[p]);const ue=async()=>{if(!(!r||!v.name)){x("");try{const a=await Ee(v),t=await P();if(!t.parsed)throw new Error("Config file is unavailable.");await E(re(t.parsed,r,a.id)),L(!1),z({name:"",api_key:"",base_url:"",model:""}),x("Provider created."),await p()}catch(a){x(a instanceof Error?a.message:String(a))}}},ge=async a=>{if(r){x("");try{const t=await P();if(!t.parsed)throw new Error("Config file is unavailable.");await E(re(t.parsed,r,a)),x("Provider selected."),await p()}catch(t){x(t instanceof Error?t.message:String(t))}}},ve=async a=>{if(r){x("");try{const t=await P();if(!t.parsed)throw new Error("Config file is unavailable.");await E(es(t.parsed,a)),await Me(a),x("Provider removed."),await p()}catch(t){x(t instanceof Error?t.message:String(t))}}},je=async a=>{if(r){x("");try{const t=await P();if(!t.parsed)throw new Error("Config file is unavailable.");await E(Ye(t.parsed,r,a)),x("Model selected."),await p()}catch(t){x(t instanceof Error?t.message:String(t))}}},be=async()=>{r&&(await Xe(r,parseInt(J)),$(!1),p())},_e=[{key:"overview",icon:qe},{key:"providers",icon:Ce},{key:"sandbox",icon:Re},{key:"heartbeat",icon:te}],ye=async()=>{var a;if(r){q(!0),x("");try{const N=(await P()).parsed||{},y=Array.isArray(N.projects)?[...N.projects]:[],S=y.findIndex(A=>A.name===r);if(S<0)throw new Error(`Project not found in config: ${r}`);const C=y[S];y[S]={...C,agent:{...C.agent,options:{...((a=C.agent)==null?void 0:a.options)||{},sandbox:ts(g)}}},await E({...N,projects:y}),x("Sandbox settings saved."),await p()}catch(t){x((t==null?void 0:t.message)||String(t))}finally{q(!1)}}};return me&&!o?s.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):s.jsxs("div",{className:"space-y-6 animate-fade-in",children:[s.jsx(ze,{title:r,description:"Project overview, providers, and heartbeat status. Low-frequency settings are no longer editable in the daily UI.",actions:s.jsx(Se,{to:"/projects",children:s.jsxs(h,{variant:"secondary",size:"sm",children:[s.jsx($e,{size:14})," Back"]})})}),o?s.jsxs("div",{className:"app-toolbar flex flex-wrap items-center gap-2",children:[s.jsx(I,{variant:"info",children:o.agent_type}),s.jsx(I,{variant:o.heartbeat_enabled?"success":"secondary",children:o.heartbeat_enabled?"heartbeat on":"heartbeat off"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.sessions_count," sessions"]})]}):null,G?s.jsx("div",{role:"status",className:"rounded-lg border border-primary/20 bg-primary/10 px-4 py-3 text-sm text-primary",children:G}):null,s.jsx("div",{className:"flex gap-2 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:_e.map(({key:a,icon:t})=>s.jsxs("button",{onClick:()=>i(a),className:Y("app-segment flex items-center gap-2",n===a?"app-segment-active":"app-segment-idle"),children:[s.jsx(t,{size:16}),e(`projects.tabs.${a}`)]},a))}),n==="overview"&&o&&s.jsxs("div",{className:"space-y-4",children:[s.jsx(B,{className:"app-panel",title:e("projects.platforms"),children:s.jsx("div",{className:"flex flex-wrap gap-2",children:(K=o.platforms)==null?void 0:K.map(a=>s.jsxs(I,{variant:a.connected?"success":"danger",children:[s.jsx(De,{size:12,className:"mr-1"})," ",a.type," ",a.connected?"✓":"✗"]},a.type))})}),s.jsxs(B,{className:"app-panel",title:e("sessions.title"),children:[s.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.sessions_count," ",e("nav.sessions").toLowerCase()]}),((Z=o.active_session_keys)==null?void 0:Z.length)>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:o.active_session_keys.map(a=>s.jsx(I,{variant:"default",children:a},a))})]})]}),n==="providers"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:e("providers.title")}),s.jsxs(h,{size:"sm",onClick:()=>L(!0),children:[s.jsx(Be,{size:14})," ",e("providers.add")]})]}),m.length===0?s.jsx(ae,{message:e("common.noData")}):s.jsx("div",{className:"space-y-2",children:m.map(a=>s.jsx(w,{className:"app-panel",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium text-foreground",children:a.name}),a.id===_&&s.jsx(I,{variant:"success",children:e("providers.active")})]}),s.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a.model," ",a.base_url?`· ${a.base_url}`:""]})]}),s.jsxs("div",{className:"flex gap-2",children:[a.id!==_&&s.jsxs(h,{size:"sm",variant:"secondary",onClick:()=>{ge(a.id)},children:[s.jsx(Te,{size:14})," ",e("providers.activate")]}),a.id!==_&&s.jsx(h,{size:"sm",variant:"danger",onClick:()=>{ve(a.id)},children:s.jsx(Fe,{size:14})})]})]})},a.id))}),O.length>0&&s.jsxs(w,{children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground mb-3",children:e("providers.models")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:O.map(a=>s.jsx("button",{onClick:()=>{je(a)},className:Y("px-3 py-1.5 rounded-lg text-xs font-medium transition-all",a===ce?"bg-primary/15 text-primary border border-primary/30":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:a},a))})]}),s.jsx(ee,{open:he,onClose:()=>L(!1),title:e("providers.add"),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(j,{label:e("providers.name"),value:v.name,onChange:a=>z({...v,name:a.target.value})}),s.jsx(j,{label:"API Key",type:"password",value:v.api_key,onChange:a=>z({...v,api_key:a.target.value})}),s.jsx(j,{label:e("providers.baseUrl"),value:v.base_url,onChange:a=>z({...v,base_url:a.target.value}),placeholder:"https://api.example.com"}),s.jsx(j,{label:e("providers.model"),value:v.model,onChange:a=>z({...v,model:a.target.value})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(h,{variant:"secondary",onClick:()=>L(!1),children:e("common.cancel")}),s.jsx(h,{onClick:ue,children:e("providers.add")})]})]})})]}),n==="sandbox"&&s.jsx(B,{title:"Sandbox",description:"Run this project agent inside an OpenSandbox container.",actions:s.jsxs(h,{size:"sm",onClick:()=>void ye(),loading:xe,children:[s.jsx(He,{size:14})," Save"]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"flex items-center gap-3 text-sm font-medium text-foreground",children:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:g.enabled,onChange:a=>b(t=>({...t,enabled:a.target.checked}))}),"Enable sandbox mode"]}),g.enabled?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[s.jsxs(se,{label:"State scope",value:g.state_scope,onChange:a=>b(t=>({...t,state_scope:a.target.value})),children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"project",children:"Project"}),s.jsx("option",{value:"thread",children:"Thread"}),s.jsx("option",{value:"run",children:"Run"})]}),s.jsx(j,{label:"Timeout seconds",type:"number",value:g.timeout_seconds,onChange:a=>b(t=>({...t,timeout_seconds:a.target.value}))}),s.jsxs(se,{label:"Sandbox lifecycle",value:g.sandbox_lifecycle,onChange:a=>b(t=>({...t,sandbox_lifecycle:a.target.value})),children:[s.jsx("option",{value:"per_thread",children:"Keep warm per thread"}),s.jsx("option",{value:"per_run",children:"Close after each run"})]}),s.jsx(j,{label:"Idle seconds",type:"number",value:g.idle_seconds,onChange:a=>b(t=>({...t,idle_seconds:a.target.value}))}),s.jsx(j,{label:"Warm pool",type:"number",value:g.warm_pool_size,onChange:a=>b(t=>({...t,warm_pool_size:a.target.value}))}),s.jsx(j,{label:"CPU",value:g.cpu,onChange:a=>b(t=>({...t,cpu:a.target.value}))}),s.jsx(j,{label:"Memory",value:g.memory,onChange:a=>b(t=>({...t,memory:a.target.value}))})]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"OpenSandbox URL, API key env, image, ACP port, and sandbox mount paths are resolved from the global sandbox provider and runtime image registry."})]}):s.jsx("p",{className:"text-sm text-muted-foreground",children:"Local bundled runtime execution is active for this project."})]})}),n==="heartbeat"&&s.jsxs("div",{className:"space-y-4",children:[u?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs(w,{children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:e("heartbeat.status")}),s.jsx("p",{className:"text-lg font-bold text-foreground mt-1",children:u.paused?e("heartbeat.paused"):e("heartbeat.running")})]}),s.jsxs(w,{children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:e("heartbeat.interval")}),s.jsxs("p",{className:"text-lg font-bold text-foreground mt-1",children:[u.interval_mins,"m"]})]}),s.jsxs(w,{children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:e("heartbeat.runCount")}),s.jsx("p",{className:"text-lg font-bold text-foreground mt-1",children:u.run_count})]}),s.jsxs(w,{children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:e("heartbeat.errorCount")}),s.jsx("p",{className:"text-lg font-bold text-foreground mt-1",children:u.error_count})]})]}),s.jsx(w,{children:s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("p",{className:"text-muted-foreground",children:[e("heartbeat.lastRun"),": ",s.jsx("span",{className:"text-foreground",children:ke(u.last_run)})]}),s.jsxs("p",{className:"text-muted-foreground",children:[e("heartbeat.skippedBusy"),": ",s.jsx("span",{className:"text-foreground",children:u.skipped_busy})]}),u.last_error&&s.jsx("p",{className:"text-destructive",children:u.last_error})]})}),s.jsxs("div",{className:"flex gap-2",children:[u.paused?s.jsxs(h,{onClick:()=>{Ve(r).then(p)},children:[s.jsx(Oe,{size:14})," ",e("heartbeat.resume")]}):s.jsxs(h,{variant:"secondary",onClick:()=>{Ze(r).then(p)},children:[s.jsx(Je,{size:14})," ",e("heartbeat.pause")]}),s.jsxs(h,{variant:"secondary",onClick:()=>{We(r).then(p)},children:[s.jsx(te,{size:14})," ",e("heartbeat.trigger")]}),s.jsxs(h,{variant:"secondary",onClick:()=>$(!0),children:[s.jsx(Pe,{size:14})," ",e("heartbeat.setInterval")]})]})]}):s.jsx(ae,{message:e("common.noData")}),s.jsx(ee,{open:pe,onClose:()=>$(!1),title:e("heartbeat.setInterval"),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(j,{label:`${e("heartbeat.interval")} (min)`,type:"number",value:J,onChange:a=>fe(a.target.value)}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(h,{variant:"secondary",onClick:()=>$(!1),children:e("common.cancel")}),s.jsx(h,{onClick:be,children:e("common.save")})]})]})})]})]})}function as(e){return{enabled:!!(e!=null&&e.enabled),provider_id:(e==null?void 0:e.provider_id)||T,runtime_image_id:(e==null?void 0:e.runtime_image_id)||l.runtime_image_id,server_url:(e==null?void 0:e.server_url)||l.server_url,image:(e==null?void 0:e.image)||l.image,acp_port:String((e==null?void 0:e.acp_port)||l.acp_port),state_scope:(e==null?void 0:e.state_scope)||l.state_scope,timeout_seconds:String((e==null?void 0:e.timeout_seconds)||l.timeout_seconds),sandbox_lifecycle:(e==null?void 0:e.sandbox_lifecycle)||l.sandbox_lifecycle,idle_seconds:String((e==null?void 0:e.idle_seconds)||l.idle_seconds),warm_pool_size:String((e==null?void 0:e.warm_pool_size)??l.warm_pool_size),cpu:(e==null?void 0:e.cpu)||l.cpu,memory:(e==null?void 0:e.memory)||l.memory,workspace_mount_path:(e==null?void 0:e.workspace_mount_path)||l.workspace_mount_path,state_mount_path:(e==null?void 0:e.state_mount_path)||l.state_mount_path}}function ts(e){return{enabled:e.enabled,provider_id:e.provider_id.trim()||T,runtime_image_id:e.runtime_image_id.trim()||l.runtime_image_id,state_scope:e.state_scope,timeout_seconds:Number(e.timeout_seconds)||Number(l.timeout_seconds),sandbox_lifecycle:e.sandbox_lifecycle,idle_seconds:Number(e.idle_seconds)||Number(l.idle_seconds),warm_pool_size:Math.max(0,Number(e.warm_pool_size)||0),cpu:e.cpu.trim()||l.cpu,memory:e.memory.trim()||l.memory}}export{ws as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as x,r,j as e,F as f,L as j,C as p}from"./index-dy-g2Bh4.js";import{B as l}from"./Badge-BYREM3t3.js";import{E as u}from"./EmptyState-DCqmct2y.js";import{P as h}from"./Page-DhD-zgMU.js";import{l as g}from"./projects-BwF5RlNV.js";import{S as v,A as b}from"./server-DpcVLHeh.js";import{H as y}from"./heart-DvLsV7tL.js";function C(){const{t}=x(),[a,d]=r.useState([]),[m,i]=r.useState(!0),n=r.useCallback(async()=>{try{i(!0);const s=await g();d(s.projects||[])}finally{i(!1)}},[]);return r.useEffect(()=>{n();const s=()=>n();return window.addEventListener("cc:refresh",s),()=>window.removeEventListener("cc:refresh",s)},[n]),m&&a.length===0?e.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):a.length===0?e.jsx(u,{message:t("projects.noProjects"),icon:f}):e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(h,{title:t("nav.projects"),description:"Project summaries with provider, platform, and session status."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:a.map(s=>{var o;return e.jsx(j,{to:`/projects/${s.name}`,children:e.jsxs(p,{hover:!0,className:"app-panel h-full",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-primary/10 text-primary",children:e.jsx(v,{size:18})}),e.jsx("h3",{className:"font-semibold text-foreground",children:s.name})]}),e.jsx(b,{size:16,className:"text-muted-foreground/45"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[e.jsx(l,{variant:"info",children:s.agent_type}),(o=s.platforms)==null?void 0:o.map(c=>e.jsx(l,{children:c},c))]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between rounded-[16px] bg-black/[0.035] px-3 py-2 text-xs text-muted-foreground dark:bg-white/[0.05]",children:[e.jsxs("span",{children:[s.sessions_count," ",t("nav.sessions").toLowerCase()]}),s.heartbeat_enabled&&e.jsxs("span",{className:"flex items-center gap-1 text-primary",children:[e.jsx(y,{size:12})," ",t("heartbeat.title")]})]})]})},s.name)})})]})}export{C as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as jn,z as he,aO as Y,j as S,r as p,g as vt}from"./index-
|
|
1
|
+
import{c as jn,z as he,aO as Y,j as S,r as p,g as vt}from"./index-dy-g2Bh4.js";import{c as ct,a as Je,r as lt,P as z,u as J,b as kt,d as yt,e as at,f as $,g as kn,h as Hn,i as Vn,R as Bn,F as Wn,D as Fn}from"./index-B2L4G-b_.js";import{C as St}from"./chevron-down-00bRZi15.js";import{C as $n}from"./check-CCZ0JO_S.js";/**
|
|
2
2
|
* @license lucide-react v0.487.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as C,D as z,r,j as e,L as S,B as g,g as b,T as B}from"./index-dy-g2Bh4.js";import{B as j}from"./Badge-BYREM3t3.js";import{g as E,a as L}from"./sessions-eK5D4FLt.js";import{C as A,A as D}from"./ChatMarkdown-_slLloCh.js";import{A as I}from"./arrow-left-BU2NB2LA.js";import{C as M}from"./circle-CpQ8x4k_.js";import{W as y,R}from"./wifi-off-CCTloj-V.js";import{B as T}from"./bot-IYNh8tH5.js";import{U}from"./user-Cvf_uiyQ.js";import"./check-CCZ0JO_S.js";function J(){var p;const{t:a}=C(),{project:i,id:l}=z(),[s,v]=r.useState(null),[d,m]=r.useState(""),[c,x]=r.useState(!1),[w,f]=r.useState(!0),u=r.useRef(null),o=r.useCallback(async()=>{if(!(!i||!l))try{f(!0);const t=await E(i,l,200);v(t)}finally{f(!1)}},[i,l]);r.useEffect(()=>{o()},[o]),r.useEffect(()=>{var t;(t=u.current)==null||t.scrollIntoView({behavior:"smooth"})},[s==null?void 0:s.history]);const h=async()=>{if(!d.trim()||!i||!s)return;const t=d.trim();m(""),x(!0);try{await L(i,{session_key:s.session_key,message:t}),setTimeout(o,1500)}finally{x(!1)}},N=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),h())};return w&&!s?e.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):e.jsxs("div",{className:"flex flex-col h-[calc(100vh-8rem)] animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200/80 pb-4 dark:border-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(S,{to:"/sessions",className:"p-2 rounded-md hover:bg-accent/10 transition-colors",children:e.jsx(I,{size:18,className:"text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-[1.4rem] font-semibold text-foreground",children:(s==null?void 0:s.name)||l}),s!=null&&s.live?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] text-primary",children:[e.jsx(M,{size:5,className:"fill-current"})," live"]}):e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded-full",children:[e.jsx(y,{size:9})," ",a("sessions.offline")]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(j,{children:i}),(s==null?void 0:s.platform)&&e.jsx(j,{variant:"info",children:s.platform}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s==null?void 0:s.session_key})]})]})]}),e.jsxs(g,{size:"sm",variant:"ghost",onClick:o,children:[e.jsx(R,{size:14})," ",a("common.refresh")]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-6",children:[(!(s!=null&&s.history)||s.history.length===0)&&e.jsx("p",{className:"text-center text-sm text-muted-foreground py-12",children:a("sessions.noMessages")}),e.jsx("div",{className:"mx-auto max-w-4xl space-y-5",children:(p=s==null?void 0:s.history)==null?void 0:p.map((t,k)=>{const n=t.role==="user";return e.jsxs("div",{className:b("flex gap-3",n?"justify-end":"justify-start"),children:[!n&&e.jsx("div",{className:"mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 dark:bg-white/[0.06]",children:e.jsx(T,{size:16,className:"text-primary"})}),e.jsx("div",{className:b("rounded-[20px] px-5 py-3.5 text-sm",n?"chat-user-glass max-w-[70%] rounded-br-sm text-slate-950 dark:text-slate-50":"max-w-[78%] rounded-bl-sm border border-slate-200 bg-[#fbfbfd] text-card-foreground dark:border-white/[0.08] dark:bg-white/[0.04]"),children:e.jsx(A,{content:t.content,isUser:n})}),n&&e.jsx("div",{className:"mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted dark:bg-white/[0.08]",children:e.jsx(U,{size:16,className:"text-muted-foreground"})})]},k)})}),e.jsx("div",{ref:u})]}),e.jsx("div",{className:"border-t pt-4",children:s!=null&&s.live?e.jsx("div",{className:"mx-auto max-w-4xl",children:e.jsxs("div",{className:"relative",children:[e.jsx(B,{value:d,onChange:t=>m(t.target.value),onKeyDown:N,placeholder:a("sessions.messageInput"),rows:2,className:"min-h-[88px] rounded-[22px] border-gray-200 bg-[#fbfbfd] px-4 pb-14 pt-3 text-[15px] leading-6 dark:border-white/[0.08] dark:bg-[rgba(255,255,255,0.04)] sm:min-h-[96px] sm:px-5 sm:pt-4",disabled:c}),e.jsx(g,{onClick:h,disabled:c||!d.trim(),size:"icon","aria-label":a("sessions.messageInput"),className:"absolute bottom-3 right-3 h-10 w-10 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-11 sm:w-11",children:c?e.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):e.jsx(D,{size:20,strokeWidth:2.2})})]})}):e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground bg-muted rounded-lg",children:[e.jsx(y,{size:14}),e.jsx("span",{children:a("sessions.notLiveHint")})]})})]})}export{J as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as v,r as n,j as s,M as x,L as N,C as w}from"./index-dy-g2Bh4.js";import{B as f}from"./Badge-BYREM3t3.js";import{S as y}from"./Select-rHs9CSam.js";import{E as _}from"./EmptyState-DCqmct2y.js";import{P as S}from"./Page-DhD-zgMU.js";import{l as C}from"./projects-BwF5RlNV.js";import{l as k}from"./sessions-eK5D4FLt.js";import{F as L}from"./funnel-UbcrCBCp.js";import{C as M}from"./circle-CpQ8x4k_.js";import{U as P}from"./user-Cvf_uiyQ.js";import{B as b}from"./bot-IYNh8tH5.js";import"./index-B2L4G-b_.js";import"./chevron-down-00bRZi15.js";import"./check-CCZ0JO_S.js";function E(t,o){if(!t)return"";const m=Date.now()-new Date(t).getTime(),i=Math.floor(m/6e4);if(i<1)return o("sessions.justNow");if(i<60)return`${i}m`;const c=Math.floor(i/60);return c<24?`${c}h`:`${Math.floor(c/24)}d`}function K(){const{t}=v(),[o,m]=n.useState([]),[i,c]=n.useState([]),[l,j]=n.useState(""),[h,u]=n.useState(!0),d=n.useCallback(async()=>{u(!0);try{const{projects:e}=await C();c(e||[]);const a=await Promise.all((e||[]).map(async r=>{try{const{sessions:g}=await k(r.name);return{project:r.name,sessions:g||[]}}catch{return{project:r.name,sessions:[]}}}));m(a)}finally{u(!1)}},[]);n.useEffect(()=>{d();const e=()=>d();return window.addEventListener("cc:refresh",e),()=>window.removeEventListener("cc:refresh",e)},[d]);const p=n.useMemo(()=>(l?o.filter(a=>a.project===l):o).flatMap(a=>a.sessions.map(r=>({...r,_project:a.project}))).sort((a,r)=>(r.updated_at||r.created_at||"").localeCompare(a.updated_at||a.created_at||"")),[o,l]);return h&&o.length===0?s.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Loading..."}):s.jsxs("div",{className:"space-y-4 animate-fade-in",children:[s.jsx(S,{title:t("sessions.title"),description:"Browse recent conversations across projects."}),s.jsxs("div",{className:"app-toolbar flex items-center gap-3",children:[s.jsx(L,{size:16,className:"text-muted-foreground"}),s.jsxs(y,{value:l,onChange:e=>j(e.target.value),className:"w-auto min-w-48",children:[s.jsx("option",{value:"",children:t("sessions.allProjects")}),i.map(e=>s.jsx("option",{value:e.name,children:e.name},e.name))]}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.length," ",t("nav.sessions").toLowerCase()]})]}),p.length===0?s.jsx(_,{message:t("sessions.noSessions"),icon:x}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-3",children:p.map(e=>s.jsx(N,{to:`/sessions/${encodeURIComponent(e._project)}/${encodeURIComponent(e.id)}`,children:s.jsxs(w,{hover:!0,className:"group app-panel relative h-full p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(x,{size:14,className:e.live?"text-primary shrink-0":"text-muted-foreground shrink-0"}),s.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.name||e.user_name||e.id.slice(0,8)}),e.live&&s.jsx(M,{size:5,className:"fill-primary text-primary shrink-0"})]}),s.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 mt-0.5",children:E(e.updated_at||e.created_at,t)})]}),s.jsx("div",{className:"mb-2.5 min-h-[2.5rem]",children:e.last_message?s.jsxs("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed",children:[e.last_message.role==="user"?s.jsx(P,{size:10,className:"inline mr-1 -mt-0.5 opacity-60"}):s.jsx(b,{size:10,className:"inline mr-1 -mt-0.5 opacity-60"}),e.last_message.content.replace(/\n/g," ").slice(0,100)]}):s.jsx("p",{className:"text-xs text-muted-foreground italic",children:t("sessions.noMessages")})}),s.jsxs("div",{className:"mt-3 flex items-center gap-1.5 flex-wrap rounded-[16px] bg-black/[0.035] px-3 py-2 dark:bg-white/[0.05]",children:[s.jsx(f,{children:e._project}),e.platform&&s.jsx(f,{variant:"info",children:e.platform}),s.jsxs("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[e.history_count," msgs"]})]})]})},`${e._project}-${e.id}`))})]})}export{K as default};
|