@kafca/agentdock 0.1.46 → 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.
Files changed (87) hide show
  1. package/README.md +6 -0
  2. package/dist/renderer/assets/{Badge-BIesaDYG.js → Badge-BYREM3t3.js} +1 -1
  3. package/dist/renderer/assets/{Chat-CpataoDh.js → Chat-Dtb5X7sB.js} +1 -1
  4. package/dist/renderer/assets/{ChatMarkdown-_Mdmltgv.js → ChatMarkdown-_slLloCh.js} +1 -1
  5. package/dist/renderer/assets/{Config-Pe5-zKZk.js → Config-pHichs7H.js} +1 -1
  6. package/dist/renderer/assets/{CronList-BnaOSPT8.js → CronList-CJQMeCjz.js} +1 -1
  7. package/dist/renderer/assets/{Dashboard-D05l8GKE.js → Dashboard-CY77Imde.js} +2 -2
  8. package/dist/renderer/assets/{EmptyState-BDBavDll.js → EmptyState-DCqmct2y.js} +1 -1
  9. package/dist/renderer/assets/{KnowledgeDetail-DvR798l_.js → KnowledgeDetail-DFrxa-pv.js} +1 -1
  10. package/dist/renderer/assets/{KnowledgeHome-r2ZuvU8-.js → KnowledgeHome-DL-vAfrH.js} +1 -1
  11. package/dist/renderer/assets/{Logs-BaljtmAV.js → Logs-jw9Uv590.js} +1 -1
  12. package/dist/renderer/assets/{Modal-CXhD_OWR.js → Modal-ChSm7tk6.js} +1 -1
  13. package/dist/renderer/assets/{MonitorList-D7tyipbx.js → MonitorList-DrEwyS71.js} +1 -1
  14. package/dist/renderer/assets/{Page-KUuFYgjg.js → Page-DhD-zgMU.js} +1 -1
  15. package/dist/renderer/assets/ProjectDetail-BVSjpfpL.js +11 -0
  16. package/dist/renderer/assets/{ProjectList-CbdHd5Ev.js → ProjectList-CHGbTJjk.js} +1 -1
  17. package/dist/renderer/assets/{Select-Djc8BXMC.js → Select-rHs9CSam.js} +1 -1
  18. package/dist/renderer/assets/{SessionChat-DOy0iKQR.js → SessionChat-CDc2FNMA.js} +1 -1
  19. package/dist/renderer/assets/{SessionList-DHgl1s1D.js → SessionList-Mr1uAnRW.js} +1 -1
  20. package/dist/renderer/assets/ThreadChat-Detu5UfN.js +23 -0
  21. package/dist/renderer/assets/{Workspace-DTocqY-F.js → Workspace-MRRg8ndJ.js} +1 -1
  22. package/dist/renderer/assets/{arrow-left-CXyya3hP.js → arrow-left-BU2NB2LA.js} +1 -1
  23. package/dist/renderer/assets/{book-open-9n4Kxc7E.js → book-open-D-TGvWwa.js} +1 -1
  24. package/dist/renderer/assets/{bot-C9HBk5XH.js → bot-IYNh8tH5.js} +1 -1
  25. package/dist/renderer/assets/{check-CutSg9a5.js → check-CCZ0JO_S.js} +1 -1
  26. package/dist/renderer/assets/{chevron-down-DrydR4i3.js → chevron-down-00bRZi15.js} +1 -1
  27. package/dist/renderer/assets/{circle-BEjtahw6.js → circle-CpQ8x4k_.js} +1 -1
  28. package/dist/renderer/assets/{desktop-DATgk_ka.js → desktop-D0k2aGSj.js} +1 -1
  29. package/dist/renderer/assets/{funnel-BhqZpS4f.js → funnel-UbcrCBCp.js} +1 -1
  30. package/dist/renderer/assets/{heart-Dp8Vs-7_.js → heart-DvLsV7tL.js} +1 -1
  31. package/dist/renderer/assets/{index-BKpv0P0s.js → index-B2L4G-b_.js} +1 -1
  32. package/dist/renderer/assets/{index-cI3pWBnN.js → index-dy-g2Bh4.js} +2 -2
  33. package/dist/renderer/assets/{pencil-ywcJzeOo.js → pencil-qBYOgW5M.js} +1 -1
  34. package/dist/renderer/assets/{play-AtN492Cx.js → play-Dn6b4AGj.js} +1 -1
  35. package/dist/renderer/assets/{plus-BEj14BBV.js → plus-CaApUwEm.js} +1 -1
  36. package/dist/renderer/assets/projects-BwF5RlNV.js +1 -0
  37. package/dist/renderer/assets/{save-D6ov4CNv.js → save-CN6yvTfD.js} +1 -1
  38. package/dist/renderer/assets/{search-C3bvw7AR.js → search-Dn2MxYiO.js} +1 -1
  39. package/dist/renderer/assets/{server-C1Uyedyx.js → server-DpcVLHeh.js} +1 -1
  40. package/dist/renderer/assets/{session-utils-DpRwJ6Nh.js → session-utils-DnD2Q_y1.js} +1 -1
  41. package/dist/renderer/assets/{sessions-BWmAppwK.js → sessions-eK5D4FLt.js} +1 -1
  42. package/dist/renderer/assets/{shield-check-CVx1mEs2.js → shield-check-DSSJkacw.js} +1 -1
  43. package/dist/renderer/assets/{trash-2-o-heXOgs.js → trash-2-DmYJlEvO.js} +1 -1
  44. package/dist/renderer/assets/{user-dPOzUqIc.js → user-Cvf_uiyQ.js} +1 -1
  45. package/dist/renderer/assets/{wifi-off-Fz5c3_x_.js → wifi-off-CCTloj-V.js} +1 -1
  46. package/dist/renderer/index.html +1 -1
  47. package/dist-electron/services/local-ai-core/src/acp/local-core-acp-session-coordinator.js +2 -1
  48. package/dist-electron/services/local-ai-core/src/agents/pi/launch.js +1 -1
  49. package/dist-electron/services/local-ai-core/src/agents/shared/launch-utils.js +22 -0
  50. package/dist-electron/services/local-ai-core/src/channel/lark/local-core-lark-gateway.js +132 -348
  51. package/dist-electron/services/local-ai-core/src/channel/shared/base-channel-gateway.js +303 -0
  52. package/dist-electron/services/local-ai-core/src/channel/weixin/local-core-weixin-gateway.js +131 -382
  53. package/dist-electron/services/local-ai-core/src/runtime/agent-runtime-detector.js +2 -1
  54. package/dist-electron/services/local-ai-core/src/runtime/channel-service.js +150 -0
  55. package/dist-electron/services/local-ai-core/src/runtime/env-utils.js +12 -0
  56. package/dist-electron/services/local-ai-core/src/runtime/external-service.js +234 -0
  57. package/dist-electron/services/local-ai-core/src/runtime/handlers/automation-handler.js +34 -0
  58. package/dist-electron/services/local-ai-core/src/runtime/handlers/capabilities-handler.js +12 -0
  59. package/dist-electron/services/local-ai-core/src/runtime/handlers/channel-handler.js +65 -0
  60. package/dist-electron/services/local-ai-core/src/runtime/handlers/external-handler.js +17 -0
  61. package/dist-electron/services/local-ai-core/src/runtime/handlers/knowledge-handler.js +65 -0
  62. package/dist-electron/services/local-ai-core/src/runtime/handlers/openai-handler.js +496 -0
  63. package/dist-electron/services/local-ai-core/src/runtime/handlers/provider-handler.js +24 -0
  64. package/dist-electron/services/local-ai-core/src/runtime/handlers/runtime-handler.js +68 -0
  65. package/dist-electron/services/local-ai-core/src/runtime/handlers/runtimes-handler.js +37 -0
  66. package/dist-electron/services/local-ai-core/src/runtime/handlers/scheduler-handler.js +34 -0
  67. package/dist-electron/services/local-ai-core/src/runtime/handlers/security-handler.js +49 -0
  68. package/dist-electron/services/local-ai-core/src/runtime/handlers/task-handler.js +27 -0
  69. package/dist-electron/services/local-ai-core/src/runtime/handlers/thread-handler.js +42 -0
  70. package/dist-electron/services/local-ai-core/src/runtime/handlers/workspace-handler.js +29 -0
  71. package/dist-electron/services/local-ai-core/src/runtime/local-core-controller.js +40 -592
  72. package/dist-electron/services/local-ai-core/src/runtime/server-helpers.js +96 -0
  73. package/dist-electron/services/local-ai-core/src/runtime/server.js +107 -1084
  74. package/dist-electron/services/local-ai-core/src/runtime/standalone.js +13 -1
  75. package/dist-electron/src/pages/Projects/project-provider-config.js +75 -0
  76. package/dist-electron/tests/contracts/architecture-docs.test.js +1 -0
  77. package/dist-electron/tests/electron/agent-runtime-detector.test.js +18 -0
  78. package/dist-electron/tests/electron/knowledge-skill-script.test.js +15 -5
  79. package/dist-electron/tests/electron/lac-cli.test.js +591 -688
  80. package/dist-electron/tests/electron/plugin-kernel.test.js +47 -31
  81. package/dist-electron/tests/electron/project-provider-config.test.js +71 -0
  82. package/dist-electron/tests/electron/workspace-task-store.test.js +19 -9
  83. package/dist-electron/tests/integration/local-core-cors.test.js +22 -0
  84. package/package.json +1 -1
  85. package/dist/renderer/assets/ProjectDetail-Ddq94-yu.js +0 -11
  86. package/dist/renderer/assets/ThreadChat-I7dYibDc.js +0 -23
  87. package/dist/renderer/assets/projects-Clar8lgb.js +0 -1
package/README.md CHANGED
@@ -94,6 +94,12 @@ 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
+
97
103
  ### 2026-05-16
98
104
 
99
105
  - 优化桌面与 Web 聊天界面视觉层级:统一会话列表、消息气泡、工具结果卡片和输入区样式,降低装饰噪音,提升长对话可读性。
@@ -1 +1 @@
1
- import{j as t,g as a}from"./index-cI3pWBnN.js";const n={default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",success:"border-transparent bg-primary/10 text-primary dark:bg-primary/15 dark:text-primary",warning:"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-200",danger:"border-transparent bg-destructive/10 text-destructive dark:bg-destructive/20 dark:text-red-200",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",info:"border-transparent bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-200"};function s({children:r,variant:e="default"}){return t.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",n[e]),children:r})}export{s as B};
1
+ 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};
@@ -1,2 +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-cI3pWBnN.js";import{M as be}from"./Modal-CXhD_OWR.js";import{E as $}from"./EmptyState-BDBavDll.js";import{C as Le,A as Be}from"./ChatMarkdown-_Mdmltgv.js";import{l as Ke}from"./projects-Clar8lgb.js";import{l as Ue,g as $e,s as qe,a as je,r as Fe,d as Oe}from"./sessions-BWmAppwK.js";import{s as We,a as we,b as w,L as _,t as He}from"./session-utils-DpRwJ6Nh.js";import{S as Ve}from"./search-C3bvw7AR.js";import{P as Ge}from"./pencil-ywcJzeOo.js";import{T as Je}from"./trash-2-o-heXOgs.js";import{B as Qe}from"./bot-C9HBk5XH.js";import{U as Xe}from"./user-dPOzUqIc.js";import"./index-BKpv0P0s.js";import"./check-CutSg9a5.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(`
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
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-cI3pWBnN.js";import{C as zo}from"./check-CutSg9a5.js";/**
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.
@@ -1,4 +1,4 @@
1
- import{c as m,u as B,r as n,j as e,B as c,R as E,L as $,$ as H,I as q,a0 as T,a1 as V}from"./index-cI3pWBnN.js";import{g as F,q as X,v as R,w as G,x as J}from"./desktop-DATgk_ka.js";import{B as x}from"./Badge-BIesaDYG.js";import{P as O,S as l,a as C}from"./Page-KUuFYgjg.js";import{S as Q}from"./shield-check-CVx1mEs2.js";import{S as W,P as Y}from"./save-D6ov4CNv.js";/**
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
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +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-cI3pWBnN.js";import{B as u}from"./Badge-BIesaDYG.js";import{M as H}from"./Modal-CXhD_OWR.js";import{S as w}from"./Select-Djc8BXMC.js";import{E as K}from"./EmptyState-BDBavDll.js";import{P as _}from"./Page-KUuFYgjg.js";import{P as $}from"./plus-BEj14BBV.js";import{P as q}from"./play-AtN492Cx.js";import{P as Q}from"./pencil-ywcJzeOo.js";import{T as V}from"./trash-2-o-heXOgs.js";import"./index-BKpv0P0s.js";import"./chevron-down-DrydR4i3.js";import"./check-CutSg9a5.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};
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};
@@ -1,4 +1,4 @@
1
- import{c as b,u as ae,r,a as re,l as ie,b as L,d as ne,e as de,j as e,M as le,W as ce,F as V,C as f,B as oe,R as me,f as xe,L as E,S as ue,g as he}from"./index-cI3pWBnN.js";import{B as d}from"./Badge-BIesaDYG.js";import{E as j}from"./EmptyState-BDBavDll.js";import{P as pe}from"./Page-KUuFYgjg.js";import{l as ge}from"./projects-Clar8lgb.js";import{l as fe,r as je,o as be,a as ve}from"./desktop-DATgk_ka.js";import{S as ke,A as K}from"./server-C1Uyedyx.js";import{B as ye}from"./book-open-9n4Kxc7E.js";import{S as O}from"./shield-check-CVx1mEs2.js";/**
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
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -23,4 +23,4 @@ import{c as b,u as ae,r,a as re,l as ie,b as L,d as ne,e as de,j as e,M as le,W
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const Ee=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Ce=b("list-checks",Ee);function _e({title:a,description:t,to:l,icon:o,primary:m}){return e.jsxs(E,{to:l,className:["group flex min-h-[112px] flex-col justify-between rounded-[18px] border p-5 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring",m?"border-primary/20 bg-primary/5 text-foreground hover:bg-primary/10 dark:bg-primary/10 dark:hover:bg-primary/15":"border-black/[0.08] bg-white text-foreground hover:bg-[#fcfcfd] dark:border-white/[0.07] dark:bg-white/[0.04] dark:hover:bg-white/[0.07]"].join(" "),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary dark:bg-primary/15",children:e.jsx(o,{size:20})}),e.jsx(K,{size:17,className:"mt-1 text-muted-foreground/45 transition-colors group-hover:text-foreground"})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-2 max-w-sm text-sm leading-5 text-muted-foreground",children:t})]})]})}function N({label:a,value:t,detail:l,tone:o="neutral"}){return e.jsxs("div",{className:"app-surface p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a}),e.jsx("p",{className:he("mt-2 text-2xl font-semibold",o==="primary"?"text-primary":o==="warning"?"text-amber-600 dark:text-amber-300":"text-foreground"),children:t}),e.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:l})]})}function ze(a){return a.readiness==="ready"?"success":a.readiness==="failed"?"danger":a.readiness==="degraded"?"warning":a.status==="installed"?"success":a.status==="error"?"danger":"warning"}function De(a){return a.readiness||(a.status==="installed"?"ready":"unknown")}function M({title:a,description:t,tasks:l,empty:o,urgent:m}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]}),e.jsx(d,{variant:m&&l.length>0?"warning":"secondary",children:l.length})]})}),l.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:o,icon:Ce})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:l.map(c=>e.jsxs("div",{className:"px-5 py-4 transition-colors hover:bg-black/[0.025] dark:hover:bg-white/[0.035]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:c.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[c.workspaceId," · ",c.runtimeId]})]}),e.jsx(d,{variant:c.status==="failed"?"danger":c.status==="completed"?"success":"info",children:c.status})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",new Date(c.updatedAt).toLocaleString()]})]},c.taskId))})]})}function Pe({approvals:a}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"待审批"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"高风险操作会在这里等待确认或拒绝。"})]}),e.jsx(d,{variant:a.length>0?"warning":"secondary",children:a.length})]})}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无待审批操作",icon:O})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.workspaceId," · ",t.kind]})]}),e.jsx(d,{variant:t.riskLevel==="high"?"danger":"warning",children:t.riskLevel})]}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs leading-5 text-muted-foreground",children:t.description})]},t.approvalId))})]})}function Te({events:a}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsxs("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"审计记录"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"最近的任务、审批和权限事件。"})]}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无审计记录",icon:O})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.summary}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.type," · ",t.actor||"system"]})]}),t.riskLevel?e.jsx(d,{variant:t.riskLevel==="high"?"danger":"secondary",children:t.riskLevel}):null]}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleString()})]},t.auditId))})]})}function Ke(){const{t:a}=ae(),[t,l]=r.useState([]),[o,m]=r.useState([]),[c,C]=r.useState([]),[w,_]=r.useState([]),[Q,z]=r.useState([]),[R,D]=r.useState([]),[G,P]=r.useState([]),[J,T]=r.useState(!0),[X,I]=r.useState(!1),[Y,p]=r.useState(!1),[q,$]=r.useState(""),[B,g]=r.useState(""),{desktopRuntime:x,desktopWorkspace:W,knowledgeModule:F,schedulerModule:H}=re(),A=o.filter(s=>s.installed),v=[{title:"继续聊天",description:"打开本地对话,继续当前项目里的 agent 线程。",to:"/chat",icon:le,primary:!0},{title:"工作区",description:"管理项目、平台、模型和本地运行配置。",to:W?"/workspace":"/projects",icon:W?ce:V}];F&&v.push({title:"知识库",description:"上传文档,维护可被检索的项目资料。",to:"/knowledge",icon:ye}),H&&v.push({title:"定时任务",description:"查看和管理自动执行的计划任务。",to:"/cron",icon:Ae}),(!F||!H)&&v.push({title:"系统设置",description:"查看配置、日志和桌面应用偏好。",to:"/system",icon:ue});const k=r.useCallback(async()=>{var s;T(!0),$(""),g("");try{if(x){const[h,i]=await Promise.all([ie(),fe().then(u=>({status:"fulfilled",runtimes:u}),u=>({status:"rejected",error:u}))]),[S,y,ee]=await Promise.all([L({status:["created","queued","running"],limit:6}),L({status:"waiting_for_user",limit:6}),L({status:["completed","failed","cancelled"],limit:6})]),[se,te]=await Promise.all([ne({status:"pending",limit:6}),de({limit:6})]);C(S.tasks||[]),_(y.tasks||[]),z(ee.tasks||[]),D(se.approvals||[]),P(te.events||[]),l((h.workspaces||[]).map(u=>({name:u.name,agent_type:u.agentType,platforms:u.platforms,sessions_count:u.sessionsCount,heartbeat_enabled:u.heartbeatEnabled}))),i.status==="fulfilled"?m(i.runtimes):(m([]),g(((s=i.error)==null?void 0:s.message)||String(i.error)));return}const n=await ge();l(n.projects||[]),m([]),C([]),_([]),z([]),D([]),P([])}catch(n){$(n.message||String(n))}finally{T(!1)}},[x]),Z=r.useCallback(async()=>{I(!0),p(!0),g("");try{m(await je())}catch(s){g(s.message||String(s))}finally{I(!1),p(!1)}},[]);return r.useEffect(()=>{k();const s=()=>k();window.addEventListener("cc:refresh",s);const n=x?be(()=>{k()}):()=>{},h=x?ve(i=>{if(i.type==="runtime.detect.started"){p(!0);return}if(i.type==="runtime.detect.completed"){p(!1),m(i.runtimes);return}if(i.type==="runtime.detect.failed"){p(!1),g(i.error);return}i.type==="runtime.status.changed"&&m(S=>S.map(y=>y.runtimeId===i.runtime.runtimeId?i.runtime:y))}):()=>{};return()=>{window.removeEventListener("cc:refresh",s),n(),h()}},[x,k]),J&&t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:e.jsx(we,{className:"animate-pulse",size:24})}):e.jsxs("div",{className:"animate-fade-in space-y-8",children:[e.jsx(pe,{title:"概览",description:"继续最近的工作,或进入项目、知识和自动化配置。当前版本 v0.1.46"}),e.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(N,{label:"Projects",value:t.length,detail:"configured workspaces",tone:"primary"}),e.jsx(N,{label:"Running",value:c.length,detail:"active agent tasks"}),e.jsx(N,{label:"Waiting",value:w.length+R.length,detail:"needs attention",tone:w.length+R.length>0?"warning":"neutral"}),e.jsx(N,{label:"Runtimes",value:A.length,detail:"installed locally"})]}),q?e.jsx("div",{role:"alert",className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-700 dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-200",children:q}):null,e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-end justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:"快速开始"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"常用入口会保留在最前面。"})]})}),e.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:v.map(s=>e.jsx(_e,{...s},s.to))})]}),x?e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"本机 Agent Runtime"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"显示本机 runtime 安装检测状态,不执行安装或登录检查。"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(d,{variant:A.length>0?"success":"default",children:[A.length," installed"]}),Y?e.jsx(d,{variant:"info",children:"checking"}):null,e.jsxs(oe,{variant:"outline",size:"sm",loading:X,onClick:Z,title:"刷新 runtime 检测",children:[e.jsx(me,{size:15}),"刷新"]})]})]}),B?e.jsxs("div",{className:"px-5 py-4 text-sm text-amber-700 dark:text-amber-200",children:["检测失败:",B]}):o.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"还没有 runtime 检测结果",icon:U})}):e.jsx("div",{className:"grid grid-cols-1 gap-3 p-5 md:grid-cols-2 xl:grid-cols-3",children:o.map(s=>{var n,h;return e.jsxs("div",{className:"app-list-row",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:["flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",s.status==="installed"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-300":s.status==="error"?"bg-red-500/10 text-red-600 dark:text-red-200":"bg-amber-500/10 text-amber-700 dark:text-amber-200"].join(" "),children:e.jsx(U,{size:19})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:s.displayName}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:s.agentType})]})]}),s.status==="installed"?e.jsx(Le,{size:18,className:"mt-0.5 shrink-0 text-emerald-500"}):e.jsx(xe,{size:18,className:"mt-0.5 shrink-0 text-amber-500"})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(d,{variant:s.status==="installed"?"success":s.status==="error"?"danger":"warning",children:s.status}),e.jsx(d,{variant:ze(s),children:De(s)}),e.jsx(d,{children:s.source}),s.version?e.jsxs(d,{variant:"secondary",children:["v",s.version]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-5 text-muted-foreground",children:s.summary}),s.lastLaunchError?e.jsx("p",{className:"mt-2 text-xs leading-5 text-red-600 dark:text-red-200",children:s.lastLaunchError.userMessage}):s.issues[0]?e.jsx("p",{className:"mt-2 text-xs leading-5 text-amber-700 dark:text-amber-200",children:s.issues[0].message}):null,(n=s.lastLaunchError)!=null&&n.suggestedAction?e.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:s.lastLaunchError.suggestedAction}):null,s.binaryPath||s.command?e.jsx("p",{className:"mt-3 truncate rounded-lg bg-black/[0.045] px-2.5 py-2 font-mono text-xs text-muted-foreground dark:bg-white/[0.06]",children:s.binaryPath||s.command}):null,s.recommendedActions[0]&&!((h=s.lastLaunchError)!=null&&h.suggestedAction)?e.jsx("p",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:s.recommendedActions[0].description}):null,e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["Last checked ",new Date(s.lastCheckedAt||s.detectedAt).toLocaleString()]})]},s.agentType)})})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-3",children:[e.jsx(M,{title:"运行中任务",description:"正在排队或执行的 agent 工作。",tasks:c,empty:"暂无运行中的任务"}),e.jsx(M,{title:"等待处理",description:"需要用户输入或审批的任务。",tasks:w,empty:"暂无等待处理的任务",urgent:!0}),e.jsx(M,{title:"最近完成",description:"最近结束、失败或取消的任务。",tasks:Q,empty:"暂无最近任务"})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[e.jsx(Pe,{approvals:R}),e.jsx(Te,{events:G})]}):null,e.jsxs(f,{className:"app-panel p-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a("nav.projects")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"最近配置和会话概览。"})]}),e.jsx(E,{to:x?"/workspace":"/projects",className:"text-sm font-medium text-primary transition-colors hover:text-primary/80",children:a("common.viewAll")})]}),t.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:a("projects.noProjects"),icon:V})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:t.slice(0,6).map(s=>{var n;return e.jsxs(E,{to:x?`/workspace?project=${encodeURIComponent(s.name)}`:`/projects/${s.name}`,className:"group flex items-center justify-between gap-3 px-5 py-4 transition-colors duration-200 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(ke,{size:17})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:s.name}),e.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[s.agent_type," · ",((n=s.platforms)==null?void 0:n.join(", "))||"no platform"," · ",s.sessions_count," sessions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.heartbeat_enabled?e.jsx(d,{variant:"success",children:"heartbeat"}):null,e.jsx(K,{size:16,className:"text-muted-foreground/45 transition-colors group-hover:text-foreground"})]})]},s.name)})})]})]})}export{Ke as default};
26
+ */const Ee=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Ce=b("list-checks",Ee);function _e({title:a,description:t,to:l,icon:o,primary:m}){return e.jsxs(E,{to:l,className:["group flex min-h-[112px] flex-col justify-between rounded-[18px] border p-5 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring",m?"border-primary/20 bg-primary/5 text-foreground hover:bg-primary/10 dark:bg-primary/10 dark:hover:bg-primary/15":"border-black/[0.08] bg-white text-foreground hover:bg-[#fcfcfd] dark:border-white/[0.07] dark:bg-white/[0.04] dark:hover:bg-white/[0.07]"].join(" "),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary dark:bg-primary/15",children:e.jsx(o,{size:20})}),e.jsx(K,{size:17,className:"mt-1 text-muted-foreground/45 transition-colors group-hover:text-foreground"})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-2 max-w-sm text-sm leading-5 text-muted-foreground",children:t})]})]})}function N({label:a,value:t,detail:l,tone:o="neutral"}){return e.jsxs("div",{className:"app-surface p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a}),e.jsx("p",{className:he("mt-2 text-2xl font-semibold",o==="primary"?"text-primary":o==="warning"?"text-amber-600 dark:text-amber-300":"text-foreground"),children:t}),e.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:l})]})}function ze(a){return a.readiness==="ready"?"success":a.readiness==="failed"?"danger":a.readiness==="degraded"?"warning":a.status==="installed"?"success":a.status==="error"?"danger":"warning"}function De(a){return a.readiness||(a.status==="installed"?"ready":"unknown")}function M({title:a,description:t,tasks:l,empty:o,urgent:m}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]}),e.jsx(d,{variant:m&&l.length>0?"warning":"secondary",children:l.length})]})}),l.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:o,icon:Ce})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:l.map(c=>e.jsxs("div",{className:"px-5 py-4 transition-colors hover:bg-black/[0.025] dark:hover:bg-white/[0.035]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:c.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[c.workspaceId," · ",c.runtimeId]})]}),e.jsx(d,{variant:c.status==="failed"?"danger":c.status==="completed"?"success":"info",children:c.status})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",new Date(c.updatedAt).toLocaleString()]})]},c.taskId))})]})}function Pe({approvals:a}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"待审批"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"高风险操作会在这里等待确认或拒绝。"})]}),e.jsx(d,{variant:a.length>0?"warning":"secondary",children:a.length})]})}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无待审批操作",icon:O})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.workspaceId," · ",t.kind]})]}),e.jsx(d,{variant:t.riskLevel==="high"?"danger":"warning",children:t.riskLevel})]}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs leading-5 text-muted-foreground",children:t.description})]},t.approvalId))})]})}function Te({events:a}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsxs("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"审计记录"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"最近的任务、审批和权限事件。"})]}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无审计记录",icon:O})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.summary}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.type," · ",t.actor||"system"]})]}),t.riskLevel?e.jsx(d,{variant:t.riskLevel==="high"?"danger":"secondary",children:t.riskLevel}):null]}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleString()})]},t.auditId))})]})}function Ke(){const{t:a}=ae(),[t,l]=r.useState([]),[o,m]=r.useState([]),[c,C]=r.useState([]),[w,_]=r.useState([]),[Q,z]=r.useState([]),[R,D]=r.useState([]),[G,P]=r.useState([]),[J,T]=r.useState(!0),[X,I]=r.useState(!1),[Y,p]=r.useState(!1),[q,$]=r.useState(""),[B,g]=r.useState(""),{desktopRuntime:x,desktopWorkspace:W,knowledgeModule:F,schedulerModule:H}=re(),A=o.filter(s=>s.installed),v=[{title:"继续聊天",description:"打开本地对话,继续当前项目里的 agent 线程。",to:"/chat",icon:le,primary:!0},{title:"工作区",description:"管理项目、平台、模型和本地运行配置。",to:W?"/workspace":"/projects",icon:W?ce:V}];F&&v.push({title:"知识库",description:"上传文档,维护可被检索的项目资料。",to:"/knowledge",icon:ye}),H&&v.push({title:"定时任务",description:"查看和管理自动执行的计划任务。",to:"/cron",icon:Ae}),(!F||!H)&&v.push({title:"系统设置",description:"查看配置、日志和桌面应用偏好。",to:"/system",icon:ue});const k=r.useCallback(async()=>{var s;T(!0),$(""),g("");try{if(x){const[h,i]=await Promise.all([ie(),fe().then(u=>({status:"fulfilled",runtimes:u}),u=>({status:"rejected",error:u}))]),[S,y,ee]=await Promise.all([L({status:["created","queued","running"],limit:6}),L({status:"waiting_for_user",limit:6}),L({status:["completed","failed","cancelled"],limit:6})]),[se,te]=await Promise.all([ne({status:"pending",limit:6}),de({limit:6})]);C(S.tasks||[]),_(y.tasks||[]),z(ee.tasks||[]),D(se.approvals||[]),P(te.events||[]),l((h.workspaces||[]).map(u=>({name:u.name,agent_type:u.agentType,platforms:u.platforms,sessions_count:u.sessionsCount,heartbeat_enabled:u.heartbeatEnabled}))),i.status==="fulfilled"?m(i.runtimes):(m([]),g(((s=i.error)==null?void 0:s.message)||String(i.error)));return}const n=await ge();l(n.projects||[]),m([]),C([]),_([]),z([]),D([]),P([])}catch(n){$(n.message||String(n))}finally{T(!1)}},[x]),Z=r.useCallback(async()=>{I(!0),p(!0),g("");try{m(await je())}catch(s){g(s.message||String(s))}finally{I(!1),p(!1)}},[]);return r.useEffect(()=>{k();const s=()=>k();window.addEventListener("cc:refresh",s);const n=x?be(()=>{k()}):()=>{},h=x?ve(i=>{if(i.type==="runtime.detect.started"){p(!0);return}if(i.type==="runtime.detect.completed"){p(!1),m(i.runtimes);return}if(i.type==="runtime.detect.failed"){p(!1),g(i.error);return}i.type==="runtime.status.changed"&&m(S=>S.map(y=>y.runtimeId===i.runtime.runtimeId?i.runtime:y))}):()=>{};return()=>{window.removeEventListener("cc:refresh",s),n(),h()}},[x,k]),J&&t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:e.jsx(we,{className:"animate-pulse",size:24})}):e.jsxs("div",{className:"animate-fade-in space-y-8",children:[e.jsx(pe,{title:"概览",description:"继续最近的工作,或进入项目、知识和自动化配置。当前版本 v0.1.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 s,j as e}from"./index-cI3pWBnN.js";/**
1
+ import{c as s,j as e}from"./index-dy-g2Bh4.js";/**
2
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as 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-cI3pWBnN.js";import{E}from"./EmptyState-BDBavDll.js";import{A as W}from"./arrow-left-CXyya3hP.js";import{S as X}from"./search-C3bvw7AR.js";import{T as Y}from"./trash-2-o-heXOgs.js";/**
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.
@@ -1,4 +1,4 @@
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-cI3pWBnN.js";import{M as L}from"./Modal-CXhD_OWR.js";import{E as R}from"./EmptyState-BDBavDll.js";import{P}from"./pencil-ywcJzeOo.js";import{T as O}from"./trash-2-o-heXOgs.js";import{S as he}from"./search-C3bvw7AR.js";import{P as ue}from"./plus-BEj14BBV.js";import{B as ye}from"./book-open-9n4Kxc7E.js";import"./index-BKpv0P0s.js";/**
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
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +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-cI3pWBnN.js";import{B as E}from"./Badge-BIesaDYG.js";import{S as f}from"./Select-Djc8BXMC.js";import{P as k}from"./Page-KUuFYgjg.js";import{A as z}from"./arrow-left-CXyya3hP.js";import{F as B}from"./funnel-BhqZpS4f.js";import{S as I}from"./search-C3bvw7AR.js";import"./index-BKpv0P0s.js";import"./chevron-down-DrydR4i3.js";import"./check-CutSg9a5.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
+ 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-cI3pWBnN.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-BKpv0P0s.js";/**
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.
@@ -1 +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-cI3pWBnN.js";import{B as h}from"./Badge-BIesaDYG.js";import{M as Q}from"./Modal-CXhD_OWR.js";import{S as y}from"./Select-Djc8BXMC.js";import{E as X}from"./EmptyState-BDBavDll.js";import{P as Y}from"./Page-KUuFYgjg.js";import{P as Z}from"./plus-BEj14BBV.js";import{P as G}from"./play-AtN492Cx.js";import{P as J}from"./pencil-ywcJzeOo.js";import{T as K}from"./trash-2-o-heXOgs.js";import"./index-BKpv0P0s.js";import"./chevron-down-DrydR4i3.js";import"./check-CutSg9a5.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
+ 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-cI3pWBnN.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};
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};
@@ -1 +1 @@
1
- import{u as x,r,j as e,F as f,L as j,C as p}from"./index-cI3pWBnN.js";import{B as l}from"./Badge-BIesaDYG.js";import{E as u}from"./EmptyState-BDBavDll.js";import{P as h}from"./Page-KUuFYgjg.js";import{l as g}from"./projects-Clar8lgb.js";import{S as v,A as b}from"./server-C1Uyedyx.js";import{H as y}from"./heart-Dp8Vs-7_.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
+ 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-cI3pWBnN.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-BKpv0P0s.js";import{C as St}from"./chevron-down-DrydR4i3.js";import{C as $n}from"./check-CutSg9a5.js";/**
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.
@@ -1 +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-cI3pWBnN.js";import{B as j}from"./Badge-BIesaDYG.js";import{g as E,a as L}from"./sessions-BWmAppwK.js";import{C as A,A as D}from"./ChatMarkdown-_Mdmltgv.js";import{A as I}from"./arrow-left-CXyya3hP.js";import{C as M}from"./circle-BEjtahw6.js";import{W as y,R}from"./wifi-off-Fz5c3_x_.js";import{B as T}from"./bot-C9HBk5XH.js";import{U}from"./user-dPOzUqIc.js";import"./check-CutSg9a5.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};
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};
@@ -1 +1 @@
1
- import{u as v,r as n,j as s,M as x,L as N,C as w}from"./index-cI3pWBnN.js";import{B as f}from"./Badge-BIesaDYG.js";import{S as y}from"./Select-Djc8BXMC.js";import{E as _}from"./EmptyState-BDBavDll.js";import{P as S}from"./Page-KUuFYgjg.js";import{l as C}from"./projects-Clar8lgb.js";import{l as k}from"./sessions-BWmAppwK.js";import{F as L}from"./funnel-BhqZpS4f.js";import{C as M}from"./circle-BEjtahw6.js";import{U as P}from"./user-dPOzUqIc.js";import{B as b}from"./bot-C9HBk5XH.js";import"./index-BKpv0P0s.js";import"./chevron-down-DrydR4i3.js";import"./check-CutSg9a5.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};
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};