agentstudio 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{AgentsPage-DgoZNP6l.js → AgentsPage-rLPOC44M.js} +1 -1
- package/public/assets/{Button-BHiMThm4.js → Button-CfU7z0eT.js} +1 -1
- package/public/assets/{ChatPage-LoTJrT43.js → ChatPage-Cl0wXezZ.js} +88 -88
- package/public/assets/{CommandsPage-CwEoyASk.js → CommandsPage-BgFvm2GI.js} +1 -1
- package/public/assets/{DashboardPage-BSi_T1tY.js → DashboardPage-BoonTnMH.js} +1 -1
- package/public/assets/{FileBrowser-Df-zwNDa.js → FileBrowser-BiAm3yrg.js} +1 -1
- package/public/assets/{GeneralSettingsPage-DcGmAzci.js → GeneralSettingsPage-BDayH81k.js} +1 -1
- package/public/assets/{LandingPage-DPKvTTja.js → LandingPage-DqS5qWgL.js} +1 -1
- package/public/assets/{LoginPage-BPJUgLru.js → LoginPage-C87yR34d.js} +1 -1
- package/public/assets/{McpAdminSettingsPage-CZZS-pa0.js → McpAdminSettingsPage-DIJs6UrH.js} +1 -1
- package/public/assets/{McpPage-CPF7txxc.js → McpPage-Dc4U_68i.js} +1 -1
- package/public/assets/{MemorySettingsPage-YenW4l-g.js → MemorySettingsPage-TErKrnR2.js} +1 -1
- package/public/assets/{PluginsPage-zlAB63Im.js → PluginsPage-DmCoLCdj.js} +1 -1
- package/public/assets/{ProjectSelector-Bq0NQ_bV.js → ProjectSelector-CFrsNw4L.js} +1 -1
- package/public/assets/{ProjectsPage-BMBRp4RN.js → ProjectsPage-DjumWKPo.js} +1 -1
- package/public/assets/{ScheduledTasksPage-B_hOD6AS.js → ScheduledTasksPage-CsFL7MD9.js} +1 -1
- package/public/assets/{SettingsLayout-CY9Siffq.js → SettingsLayout-D18ZK4TY.js} +1 -1
- package/public/assets/{SkillsPage-X-LMnwZd.js → SkillsPage-DxIdnjRM.js} +1 -1
- package/public/assets/{SubagentsPage-DIG_rKjQ.js → SubagentsPage-DWCgPFzI.js} +1 -1
- package/public/assets/{SystemInfoPage-CWgKWnQg.js → SystemInfoPage-C_kd76VQ.js} +1 -1
- package/public/assets/{TelemetrySettingsPage-BLnMagRZ.js → TelemetrySettingsPage-recK8TS7.js} +1 -1
- package/public/assets/{ToastTestPage-CQ0nobQd.js → ToastTestPage-DYwSASe6.js} +1 -1
- package/public/assets/{VersionSettingsPage-BxjDPWm0.js → VersionSettingsPage-DC_PL1Lo.js} +1 -1
- package/public/assets/{_basePickBy-D_S4EWYL.js → _basePickBy-DtI5oYel.js} +1 -1
- package/public/assets/{_baseUniq-BmQef9o6.js → _baseUniq-kP1SFZPO.js} +1 -1
- package/public/assets/{arc-DzCTkvPU.js → arc-cZ3PN_u0.js} +1 -1
- package/public/assets/{architectureDiagram-VXUJARFQ-8nWlVbiO.js → architectureDiagram-VXUJARFQ-BRn1b9Ct.js} +1 -1
- package/public/assets/{blockDiagram-VD42YOAC-DbHo3vzo.js → blockDiagram-VD42YOAC-B6Fmf92Z.js} +1 -1
- package/public/assets/{c4Diagram-YG6GDRKO-DqFGiZ7Y.js → c4Diagram-YG6GDRKO-BdApn9Kl.js} +1 -1
- package/public/assets/channel-CIc09SLj.js +1 -0
- package/public/assets/{chunk-4BX2VUAB-KZtUHSw3.js → chunk-4BX2VUAB-CFByNt-E.js} +1 -1
- package/public/assets/{chunk-55IACEB6-DTotxzVH.js → chunk-55IACEB6-DOcPvMrL.js} +1 -1
- package/public/assets/{chunk-B4BG7PRW-CkjDO6x_.js → chunk-B4BG7PRW-CYQhDwZH.js} +1 -1
- package/public/assets/{chunk-DI55MBZ5-ZN0hc9BQ.js → chunk-DI55MBZ5-fO-G4DQE.js} +1 -1
- package/public/assets/{chunk-FMBD7UC4--jXmtjeY.js → chunk-FMBD7UC4-CvFCkBe9.js} +1 -1
- package/public/assets/{chunk-QN33PNHL-D-FiWiLB.js → chunk-QN33PNHL-C4dfuLJX.js} +1 -1
- package/public/assets/{chunk-QZHKN3VN-BRs4hln6.js → chunk-QZHKN3VN-BHcbArKX.js} +1 -1
- package/public/assets/{chunk-TZMSLE5B-BUZTflc7.js → chunk-TZMSLE5B-NAHq3aeT.js} +1 -1
- package/public/assets/{classDiagram-2ON5EDUG-7Lo3C-C9.js → classDiagram-2ON5EDUG-BX8bS8-I.js} +1 -1
- package/public/assets/{classDiagram-v2-WZHVMYZB-7Lo3C-C9.js → classDiagram-v2-WZHVMYZB-BX8bS8-I.js} +1 -1
- package/public/assets/clone-CPcgYjA1.js +1 -0
- package/public/assets/{cose-bilkent-S5V4N54A-s2WN1XmV.js → cose-bilkent-S5V4N54A-C06C9ZJa.js} +1 -1
- package/public/assets/{dagre-6UL2VRFP-CxaKwQyB.js → dagre-6UL2VRFP-DCPyTNLq.js} +1 -1
- package/public/assets/{diagram-PSM6KHXK-SU1hlbjn.js → diagram-PSM6KHXK-D_EHe21D.js} +1 -1
- package/public/assets/{diagram-QEK2KX5R-hcM85tep.js → diagram-QEK2KX5R-BlulhQOc.js} +1 -1
- package/public/assets/{diagram-S2PKOQOG-BOmtKWhQ.js → diagram-S2PKOQOG-DeNVHhsT.js} +1 -1
- package/public/assets/{erDiagram-Q2GNP2WA-CsTay3Qr.js → erDiagram-Q2GNP2WA-Bnz9kE57.js} +1 -1
- package/public/assets/{flowDiagram-NV44I4VS-QLwVU4W3.js → flowDiagram-NV44I4VS-CFn031Y3.js} +1 -1
- package/public/assets/{ganttDiagram-LVOFAZNH-CEJd76u6.js → ganttDiagram-LVOFAZNH-BSduoCu_.js} +1 -1
- package/public/assets/{gitGraphDiagram-NY62KEGX-Cr7KuVc8.js → gitGraphDiagram-NY62KEGX-Bjbb7yAS.js} +1 -1
- package/public/assets/{graph-B12xs1JB.js → graph-D2RBy8e5.js} +1 -1
- package/public/assets/{index-BFYHztzB.js → index-BLjehayc.js} +2 -2
- package/public/assets/{infoDiagram-F6ZHWCRC-B6PyESp0.js → infoDiagram-F6ZHWCRC-BfeoDjKc.js} +1 -1
- package/public/assets/{journeyDiagram-XKPGCS4Q-DSlyGZSv.js → journeyDiagram-XKPGCS4Q-8tSVYPVe.js} +1 -1
- package/public/assets/{kanban-definition-3W4ZIXB7-DbDLw__g.js → kanban-definition-3W4ZIXB7-DwrpLyOH.js} +1 -1
- package/public/assets/{layout-OtboCb25.js → layout-B6w-fMcI.js} +1 -1
- package/public/assets/{linear-Bg3HtxIB.js → linear-ClbokBhh.js} +1 -1
- package/public/assets/{mindmap-definition-VGOIOE7T-DZ4bp0qm.js → mindmap-definition-VGOIOE7T-BurOGP_m.js} +1 -1
- package/public/assets/{pieDiagram-ADFJNKIX-Am2n8jc0.js → pieDiagram-ADFJNKIX-MUQTeIhp.js} +1 -1
- package/public/assets/{quadrantDiagram-AYHSOK5B-DPm8iQzH.js → quadrantDiagram-AYHSOK5B-COgCGFdz.js} +1 -1
- package/public/assets/{requirementDiagram-UZGBJVZJ-hVW5YE3R.js → requirementDiagram-UZGBJVZJ-DlYkINPo.js} +1 -1
- package/public/assets/{sankeyDiagram-TZEHDZUN-DX8gGHoq.js → sankeyDiagram-TZEHDZUN-oj7WNP67.js} +1 -1
- package/public/assets/{sequenceDiagram-WL72ISMW-Brl8T0m9.js → sequenceDiagram-WL72ISMW-TUi1zhlp.js} +1 -1
- package/public/assets/{stateDiagram-FKZM4ZOC-CxrXSnfX.js → stateDiagram-FKZM4ZOC-B7tNjdp0.js} +1 -1
- package/public/assets/{stateDiagram-v2-4FDKWEC3-BJfGHaLv.js → stateDiagram-v2-4FDKWEC3-9TkkItno.js} +1 -1
- package/public/assets/{table-D-FJ6K6j.js → table-Br8ioTXr.js} +1 -1
- package/public/assets/{timeline-definition-IT6M3QCI-CO6fKxuR.js → timeline-definition-IT6M3QCI-CSSGR7Wj.js} +1 -1
- package/public/assets/{treemap-KMMF4GRG-BsoblFM5.js → treemap-KMMF4GRG-BAb3Fz4w.js} +1 -1
- package/public/assets/{xychartDiagram-PRI3JC2R-B6g-H_PO.js → xychartDiagram-PRI3JC2R-Cd2BfyOw.js} +1 -1
- package/public/index.html +1 -1
- package/routes/sessions.d.ts.map +1 -1
- package/routes/sessions.js +17 -3
- package/routes/sessions.js.map +1 -1
- package/services/__tests__/projectMetadataStorage.test.d.ts +5 -0
- package/services/__tests__/projectMetadataStorage.test.d.ts.map +1 -0
- package/services/__tests__/projectMetadataStorage.test.js +154 -0
- package/services/__tests__/projectMetadataStorage.test.js.map +1 -0
- package/services/projectMetadataStorage.d.ts +7 -1
- package/services/projectMetadataStorage.d.ts.map +1 -1
- package/services/projectMetadataStorage.js +102 -27
- package/services/projectMetadataStorage.js.map +1 -1
- package/services/sessionManager.d.ts.map +1 -1
- package/services/sessionManager.js +17 -3
- package/services/sessionManager.js.map +1 -1
- package/public/assets/channel-DlGw39mX.js +0 -1
- package/public/assets/clone-180En6VP.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i,W as ve}from"./monaco-editor-DHKm5-VF.js";import{T as ue,a as ge,b as Y,c as N,d as he,e as j}from"./table-D-FJ6K6j.js";import{b as z,u as I,c as P,a as k,A as w}from"./agents-D9dWnZr0.js";import{u as Ne}from"./useAgents-BlQGwXjx.js";import{u as Se}from"./useProjects-cgsJNlsy.js";import{u as Ce}from"./useClaudeVersions-DJ6VKG1y.js";import{a as g,s as C}from"./index-BFYHztzB.js";import{m as O,t as Te,f as Ee,az as ce,k as me,a5 as Ae,aA as ye,ag as pe,a3 as Ie,aB as $e,L as ae,l as qe,e as oe,n as be,C as fe,A as Me,r as Fe,v as xe,aC as Pe,aD as De,U as Re,aE as Ke,J as Oe,y as Qe,X as Le}from"./ui-components-BsYwJvCF.js";import"./syntax-highlighting-CnREyncB.js";import"./tools-zTM46-tZ.js";const d={all:["scheduled-tasks"],lists:()=>[...d.all,"list"],list:()=>[...d.lists()],details:()=>[...d.all,"detail"],detail:t=>[...d.details(),t],history:t=>[...d.all,"history",t],status:()=>[...d.all,"status"]},Ve=()=>z({queryKey:d.list(),queryFn:async()=>{const t=await k(`${w}/scheduled-tasks`);if(!t.ok)throw new Error("Failed to fetch scheduled tasks");return t.json()},refetchInterval:t=>t.state.data?.some(c=>c.lastRunStatus==="running")?3e3:!1}),He=(t,n=50)=>z({queryKey:d.history(t),queryFn:async()=>{const l=await k(`${w}/scheduled-tasks/${t}/history?limit=${n}`);if(!l.ok)throw new Error("Failed to fetch task execution history");return l.json()},enabled:!!t,refetchInterval:l=>l.state.data?.some($=>$.status==="running")?3e3:!1}),Be=()=>z({queryKey:d.status(),queryFn:async()=>{const t=await k(`${w}/scheduled-tasks/status`);if(!t.ok)throw new Error("Failed to fetch scheduler status");return t.json()},refetchInterval:3e4}),ze=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to create scheduled task")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.status()})}})},Ue=()=>{const t=I();return P({mutationFn:async({taskId:n,data:l})=>{const c=await k(`${w}/scheduled-tasks/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!c.ok){const p=await c.json().catch(()=>({}));throw new Error(p.error||"Failed to update scheduled task")}return c.json()},onSuccess:n=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.detail(n.id)}),t.invalidateQueries({queryKey:d.status()})}})},_e=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/${n}`,{method:"DELETE"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to delete scheduled task")}},onSuccess:()=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.status()})}})},Je=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/${n}/toggle`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to toggle scheduled task")}return l.json()},onSuccess:n=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.detail(n.id)}),t.invalidateQueries({queryKey:d.status()})}})},je=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/${n}/run`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to run scheduled task")}return l.json()},onSuccess:(n,l)=>{t.invalidateQueries({queryKey:d.detail(l)}),t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.history(l)})}})},We=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/executions/${n}/stop`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to stop execution")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.all})}})},Xe=()=>z({queryKey:[...d.all,"running"],queryFn:async()=>{const t=await k(`${w}/scheduled-tasks/running`);if(!t.ok)throw new Error("Failed to fetch running executions");return t.json()},refetchInterval:3e3}),Ge=()=>{const t=I();return P({mutationFn:async()=>{const n=await k(`${w}/scheduled-tasks/scheduler/enable`,{method:"POST"});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.error||"Failed to enable scheduler")}return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.status()})}})},Ye=()=>{const t=I();return P({mutationFn:async()=>{const n=await k(`${w}/scheduled-tasks/scheduler/disable`,{method:"POST"});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.error||"Failed to disable scheduler")}return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.status()})}})},Z={all:["task-executor"],stats:()=>[...Z.all,"stats"],health:()=>[...Z.all,"health"]},Ze=()=>z({queryKey:Z.stats(),queryFn:async()=>{const t=await k(`${w}/task-executor/stats`);if(!t.ok)throw new Error("Failed to fetch task executor stats");return t.json()},refetchInterval:5e3}),et=()=>z({queryKey:[...Z.all,"config"],queryFn:async()=>{const t=await k(`${w}/task-executor/config`);if(!t.ok)throw new Error("Failed to fetch task executor config");return t.json()}}),tt=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/task-executor/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to update executor config")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:Z.all})}})},rt=[{label:"每 5 分钟",value:"*/5 * * * *"},{label:"每 15 分钟",value:"*/15 * * * *"},{label:"每 30 分钟",value:"*/30 * * * *"},{label:"每小时",value:"0 * * * *"},{label:"每天 9:00",value:"0 9 * * *"},{label:"每天 18:00",value:"0 18 * * *"},{label:"每周一 9:00",value:"0 9 * * 1"},{label:"每月 1 日 9:00",value:"0 9 1 * *"}],st=t=>{if(!t){const n=new Date;return n.setHours(n.getHours()+1),n.setMinutes(0),n.setSeconds(0),n.toISOString().slice(0,16)}return new Date(t).toISOString().slice(0,16)},at=t=>new Date(t).toISOString(),nt=({task:t,agents:n,onSave:l,onCancel:c})=>{const p=!!t,$=ze(),Q=Ue(),L=je(),{data:U}=Se(),D=U?.projects||[],{data:o}=Ce(),[v,_]=i.useState(t?.name||""),[S,J]=i.useState(t?.description||""),[b,q]=i.useState(t?.agentId||""),[f,V]=i.useState(t?.projectPath||""),[m,s]=i.useState(t?.schedule.type||"interval"),[x,u]=i.useState(t?.schedule.intervalMinutes||30),[h,H]=i.useState(t?.schedule.cronExpression||"*/30 * * * *"),[W,ee]=i.useState(st(t?.schedule.executeAt)),[M,ne]=i.useState(t?.triggerMessage||""),[E,le]=i.useState(t?.enabled??!0),[T,de]=i.useState(!!t?.modelOverride?.modelId),[A,te]=i.useState(t?.modelOverride?.versionId||""),[K,B]=i.useState(t?.modelOverride?.modelId||""),[X,re]=i.useState(!1),[G,r]=i.useState(!1),y=i.useMemo(()=>o?.versions?A?o.versions.find(ie=>ie.id===A)?.models||[]:(o.versions.find(R=>R.id===o.defaultVersionId)||o.versions[0])?.models||[]:[],[o,A]);i.useEffect(()=>{T&&o?.versions&&A&&(o.versions.some(R=>R.id===A)||(te(o.defaultVersionId||""),B("")))},[o,A,T]),i.useEffect(()=>{T&&y.length>0&&(y.some(R=>R.id===K)||B(y[0].id))},[y,K,T]),i.useEffect(()=>{!b&&n.length>0&&q(n[0].id)},[b,n]),i.useEffect(()=>{!f&&D.length>0&&V(D[0].path)},[f,D]);const F=()=>m==="interval"?{type:"interval",intervalMinutes:x}:m==="once"?{type:"once",executeAt:at(W)}:{type:"cron",cronExpression:h},se=()=>{if(!(!T||!K))return{versionId:A||void 0,modelId:K}},ke=async()=>{if(!v.trim()){g("请输入任务名称");return}if(!b){g("请选择 Agent");return}if(!f){g("请选择项目路径");return}if(!M.trim()){g("请输入触发消息");return}if(m==="interval"&&(!x||x<1)){g("间隔时间必须大于 0");return}if(m==="cron"&&!h.trim()){g("请输入 Cron 表达式");return}if(m==="once"){const a=new Date(W).getTime();if(isNaN(a)){g("请选择有效的执行时间");return}if(a<=Date.now()){g("执行时间必须在未来");return}}re(!0);try{if(p)await Q.mutateAsync({taskId:t.id,data:{name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()}}),C("任务已更新");else{const a={name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()};await $.mutateAsync(a),C("任务已创建")}l()}catch{g(p?"更新失败":"创建失败")}finally{re(!1)}},we=async()=>{if(!v.trim()){g("请输入任务名称");return}if(!b){g("请选择 Agent");return}if(!f){g("请选择项目路径");return}if(!M.trim()){g("请输入触发消息");return}r(!0);try{let a;if(p)await Q.mutateAsync({taskId:t.id,data:{name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()}}),a=t.id,C("任务已更新");else{const R={name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()};a=(await $.mutateAsync(R)).id,C("任务已创建")}await L.mutateAsync(a),C("任务已开始执行,请在执行历史中查看结果"),l()}catch{g("操作失败")}finally{r(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:p?"编辑定时任务":"创建定时任务"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"配置 Agent 的自动执行计划"})]}),e.jsx("button",{onClick:c,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(O,{className:"w-5 h-5"}),"基本信息"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"任务名称 *"}),e.jsx("input",{type:"text",value:v,onChange:a=>_(a.target.value),placeholder:"例如:每日代码检查",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"描述"}),e.jsx("input",{type:"text",value:S,onChange:a=>J(a.target.value),placeholder:"可选的任务描述",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(Te,{className:"w-5 h-5"}),"执行配置"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"执行 Agent *"}),e.jsx("select",{value:b,onChange:a=>q(a.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:n.map(a=>e.jsxs("option",{value:a.id,children:[a.ui?.icon||"🤖"," ",a.name]},a.id))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4"}),"项目路径 *"]}),e.jsx("select",{value:f,onChange:a=>V(a.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:D.map(a=>e.jsx("option",{value:a.path,children:a.name||a.path},a.path))}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Agent 将在此项目目录下执行"})]}),e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"覆盖模型配置"})]}),e.jsx("button",{type:"button",onClick:()=>de(!T),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${T?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${T?"translate-x-5":"translate-x-1"}`})})]}),T&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"可以为定时任务指定不同于 Agent 默认的模型"}),o?.versions&&o.versions.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"供应商"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:A,onChange:a=>te(a.target.value),className:"w-full appearance-none px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[e.jsx("option",{value:"",children:o.defaultVersionId?`默认 (${o.versions.find(a=>a.id===o.defaultVersionId)?.name})`:"默认"}),o.versions.filter(a=>a.id!==o.defaultVersionId).map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]}),e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none text-gray-500",children:e.jsx(me,{className:"w-4 h-4"})})]})]}),y.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"模型"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:y.map(a=>e.jsxs("button",{type:"button",onClick:()=>B(a.id),className:`flex items-center justify-between px-3 py-2 text-sm rounded-lg border transition-all ${K===a.id?"border-purple-500 bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300 shadow-sm":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 text-gray-700 dark:text-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ce,{className:"w-4 h-4 opacity-70"}),e.jsx("span",{className:"font-medium",children:a.name})]}),a.isVision&&e.jsx("span",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded text-gray-500",children:"Vision"})]},a.id))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(O,{className:"w-5 h-5"}),"调度规则"]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"interval",checked:m==="interval",onChange:()=>s("interval"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"间隔执行"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"cron",checked:m==="cron",onChange:()=>s("cron"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Cron 表达式"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"once",checked:m==="once",onChange:()=>s("once"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"仅执行一次"})]})]}),m==="interval"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"间隔时间(分钟)"}),e.jsx("input",{type:"number",min:1,max:10080,value:x,onChange:a=>u(parseInt(a.target.value)||30),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["每隔 ",x," 分钟执行一次"]})]}),m==="cron"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Cron 表达式"}),e.jsx("input",{type:"text",value:h,onChange:a=>H(a.target.value),placeholder:"*/30 * * * *",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white font-mono focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:rt.map(a=>e.jsx("button",{type:"button",onClick:()=>H(a.value),className:`px-2 py-1 text-xs rounded-full border transition-colors ${h===a.value?"bg-blue-100 border-blue-300 text-blue-700 dark:bg-blue-900 dark:border-blue-700 dark:text-blue-300":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700"}`,children:a.label},a.value))})]}),m==="once"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 flex items-center gap-2",children:[e.jsx(Ae,{className:"w-4 h-4"}),"执行时间"]}),e.jsx("input",{type:"datetime-local",value:W,onChange:a=>ee(a.target.value),min:new Date().toISOString().slice(0,16),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"任务将在指定时间执行一次后自动禁用"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(ye,{className:"w-5 h-5"}),"触发消息"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"发送给 Agent 的消息 *"}),e.jsx("textarea",{value:M,onChange:a=>ne(a.target.value),placeholder:"请检查代码质量并生成报告...",rows:5,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-y"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"定时触发时,这条消息会发送给选定的 Agent"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启用任务"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"创建后立即开始调度"})]}),e.jsx("button",{type:"button",onClick:()=>le(!E),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${E?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${E?"translate-x-6":"translate-x-1"}`})})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:c,className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",children:"取消"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:we,disabled:X||G,className:"inline-flex items-center px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors disabled:opacity-50",title:"保存任务并立即执行一次",children:[e.jsx(pe,{className:"w-4 h-4 mr-2"}),G?"执行中...":"保存并执行"]}),e.jsxs("button",{onClick:ke,disabled:X||G,className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:[e.jsx(Ie,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})]})})]})})},lt=({taskId:t,taskName:n,agentId:l,projectPath:c,onBack:p})=>{const{data:$=[],isLoading:Q}=He(t),[L,U]=i.useState(new Set),D=s=>{U(x=>{const u=new Set(x);return u.has(s)?u.delete(s):u.add(s),u})},o=s=>s?new Date(s).toLocaleString("zh-CN"):"-",v=s=>new Date(s).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),_=s=>{if(!s.completedAt)return"-";const x=new Date(s.startedAt).getTime(),h=new Date(s.completedAt).getTime()-x;return h<1e3?`${h}ms`:h<6e4?`${(h/1e3).toFixed(1)}s`:`${Math.floor(h/6e4)}m ${Math.floor(h%6e4/1e3)}s`},S=s=>{switch(s){case"running":return e.jsx(ae,{className:"w-5 h-5 text-blue-500 animate-spin"});case"success":return e.jsx(fe,{className:"w-5 h-5 text-green-500"});case"error":return e.jsx(be,{className:"w-5 h-5 text-red-500"});default:return e.jsx(O,{className:"w-5 h-5 text-gray-400"})}},J=s=>{switch(s){case"running":return e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"运行中"});case"success":return e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"成功"});case"error":return e.jsx("span",{className:"text-red-600 dark:text-red-400",children:"失败"});default:return e.jsx("span",{className:"text-gray-500",children:"未知"})}},b=s=>{switch(s){case"error":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20";case"warn":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20";case"info":return"text-blue-600 dark:text-blue-400";case"debug":return"text-gray-500 dark:text-gray-400";default:return"text-gray-600 dark:text-gray-400"}},q=s=>{switch(s){case"system":return"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400";case"assistant":return"bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-400";case"tool_use":return"bg-purple-100 text-purple-600 dark:bg-purple-900 dark:text-purple-400";case"result":return"bg-green-100 text-green-600 dark:bg-green-900 dark:text-green-400";case"error":return"bg-red-100 text-red-600 dark:bg-red-900 dark:text-red-400";default:return"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}},f=s=>{const x=s.agentId||l,u=s.projectPath||c;if(!x||!s.sessionId)return null;let h=`/chat/${encodeURIComponent(x)}?session=${encodeURIComponent(s.sessionId)}`;return u&&(h+=`&project=${encodeURIComponent(u)}`),h},V=(s,x)=>{x.stopPropagation();const u=f(s);u&&window.open(u,"_blank")},m=s=>!s||s.length===0?e.jsx("div",{className:"text-center py-4 text-gray-500 dark:text-gray-400",children:"暂无执行日志"}):e.jsx("div",{className:"space-y-1 max-h-96 overflow-y-auto",children:s.map((x,u)=>e.jsxs("div",{className:`flex items-start gap-2 px-3 py-1.5 rounded text-sm font-mono ${b(x.level)}`,children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-500 shrink-0 w-24",children:v(x.timestamp)}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs shrink-0 ${q(x.type)}`,children:x.type}),e.jsx("span",{className:"flex-1 break-all whitespace-pre-wrap",children:x.message})]},u))});return e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("button",{onClick:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",children:e.jsx($e,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"执行历史"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["任务:",n]})]})]}),Q?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ae,{className:"w-8 h-8 animate-spin text-gray-400"})}):$.length===0?e.jsxs("div",{className:"text-center py-12 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx(O,{className:"w-12 h-12 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"暂无执行记录"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"任务尚未执行过"})]}):e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(ue,{children:[e.jsx(ge,{children:e.jsxs(Y,{children:[e.jsx(N,{className:"w-[40px]"}),e.jsx(N,{className:"w-[80px]",children:"状态"}),e.jsx(N,{children:"开始时间"}),e.jsx(N,{children:"完成时间"}),e.jsx(N,{children:"耗时"}),e.jsx(N,{children:"结果摘要"}),e.jsx(N,{className:"w-[100px]",children:"操作"})]})}),e.jsx(he,{children:$.map(s=>e.jsxs(ve.Fragment,{children:[e.jsxs(Y,{className:"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800",onClick:()=>D(s.id),children:[e.jsx(j,{className:"p-2",children:e.jsx("button",{className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:L.has(s.id)?e.jsx(me,{className:"w-4 h-4 text-gray-500"}):e.jsx(qe,{className:"w-4 h-4 text-gray-500"})})}),e.jsx(j,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[S(s.status),J(s.status)]})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:o(s.startedAt)})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:o(s.completedAt)})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm font-mono text-gray-600 dark:text-gray-400",children:_(s)})}),e.jsx(j,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.logs&&s.logs.length>0&&e.jsx("span",{title:"有详细日志",children:e.jsx(oe,{className:"w-4 h-4 text-gray-400 shrink-0"})}),s.error?e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 max-w-md truncate",children:s.error}):s.responseSummary?e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 max-w-md truncate",children:s.responseSummary}):e.jsx("span",{className:"text-sm text-gray-400",children:"-"})]})}),e.jsx(j,{children:s.sessionId&&f(s)&&e.jsx("button",{onClick:x=>V(s,x),className:"inline-flex items-center justify-center p-2 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors",title:"在新窗口继续会话",children:e.jsx(ye,{className:"w-4 h-4"})})})]}),L.has(s.id)&&e.jsx(Y,{children:e.jsx(j,{colSpan:7,className:"bg-gray-50 dark:bg-gray-800/50 p-4",children:e.jsxs("div",{className:"space-y-3",children:[s.errorStack&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-red-700 dark:text-red-400 mb-2",children:"错误堆栈"}),e.jsx("pre",{className:"text-xs text-red-600 dark:text-red-400 whitespace-pre-wrap overflow-x-auto",children:s.errorStack})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4"}),"执行日志",s.logs&&e.jsxs("span",{className:"text-xs text-gray-400",children:["(",s.logs.length," 条)"]})]}),m(s.logs)]}),s.sessionId&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Session ID: ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded",children:s.sessionId})]})]})})})]},s.id))})]})})]})},bt=()=>{const t=I(),{data:n=[],isLoading:l}=Ve(),{data:c}=Ne(!0),{data:p}=Be(),$=_e(),Q=Je(),L=je(),U=We(),{data:D}=Xe(),o=Ge(),v=Ye(),[_,S]=i.useState(null),[J,b]=i.useState(!1),[q,f]=i.useState(null),[V,m]=i.useState(!1),[s,x]=i.useState(2),{data:u}=Ze(),{data:h}=et(),H=tt(),W=r=>D?.executions?.find(F=>F.taskId===r)?.executionId||null,ee=c?.agents||[],M=r=>ee.find(F=>F.id===r)?.name||r,ne=r=>{if(r.schedule.type==="interval"&&r.schedule.intervalMinutes){const y=r.schedule.intervalMinutes;return y<60?`每 ${y} 分钟`:`每 ${Math.floor(y/60)} 小时`}return r.schedule.type==="cron"&&r.schedule.cronExpression?r.schedule.cronExpression:r.schedule.type==="once"&&r.schedule.executeAt?`一次性 @ ${new Date(r.schedule.executeAt).toLocaleString("zh-CN")}`:"-"},E=r=>r?new Date(r).toLocaleString("zh-CN"):"-",le=async r=>{try{await Q.mutateAsync(r.id),C(r.enabled?"任务已暂停":"任务已启用")}catch{g("操作失败")}},T=async r=>{if(confirm(`确定要删除任务 "${r.name}" 吗?`))try{await $.mutateAsync(r.id),C("任务已删除")}catch{g("删除失败")}},de=async r=>{try{await L.mutateAsync(r.id),C("任务已开始执行"),t.invalidateQueries({queryKey:d.lists()})}catch{g("执行失败")}},A=async r=>{const y=W(r.id);if(!y){g("找不到正在运行的执行");return}try{await U.mutateAsync(y),C("任务已停止"),t.invalidateQueries({queryKey:d.lists()})}catch{g("停止失败")}},te=async()=>{if(p)try{p.enabled?(await v.mutateAsync(),C("调度器已禁用")):(await o.mutateAsync(),C("调度器已启用"))}catch{g("操作失败")}},K=r=>{S(r),b(!0)},B=()=>{S(null),b(!0)},X=()=>{S(null),b(!1),t.invalidateQueries({queryKey:d.lists()})},re=()=>{S(null),b(!1)},G=r=>r.lastRunStatus==="running"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:[e.jsx(ae,{className:"w-3 h-3 mr-1 animate-spin"}),"运行中"]}):r.lastRunStatus==="success"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(fe,{className:"w-3 h-3 mr-1"}),"成功"]}):r.lastRunStatus==="error"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),"失败"]}):e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:"未执行"});if(q){const r=n.find(y=>y.id===q);return e.jsx(lt,{taskId:q,taskName:r?.name||q,agentId:r?.agentId,projectPath:r?.projectPath,onBack:()=>f(null)})}return e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(O,{className:"w-8 h-8"}),"定时任务"]}),e.jsx("p",{className:"mt-2 text-gray-600 dark:text-gray-400",children:"配置 Agent 的自动执行计划"})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[p&&e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("button",{onClick:te,disabled:o.isPending||v.isPending,className:`flex items-center gap-2 px-3 py-1.5 rounded-lg transition-colors ${p.enabled?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 hover:bg-green-100 dark:hover:bg-green-900/30":"bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300 hover:bg-orange-100 dark:hover:bg-orange-900/30"} ${o.isPending||v.isPending?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,title:p.enabled?"点击禁用调度器":"点击启用调度器",children:[e.jsx(O,{className:`w-4 h-4 ${o.isPending||v.isPending?"animate-pulse":""}`}),e.jsx("span",{className:"font-medium",children:p.enabled?"调度器已启用":"调度器已禁用"})]}),u&&e.jsxs("div",{className:"flex items-center gap-3 text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsxs("span",{className:`flex items-center gap-1 ${u.runningTasks>0?"text-blue-600 dark:text-blue-400":""}`,children:[e.jsx(Me,{className:`w-4 h-4 ${u.runningTasks>0?"animate-pulse":""}`}),"运行: ",u.runningTasks]}),e.jsxs("span",{className:"text-yellow-600 dark:text-yellow-400",children:["队列: ",u.queuedTasks]}),e.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["完成: ",u.completedTasks]}),e.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["失败: ",u.failedTasks]}),e.jsx("button",{onClick:()=>{h&&x(h.maxConcurrent),m(!0)},className:"ml-2 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"执行器设置",children:e.jsx(Fe,{className:"w-4 h-4"})})]})]}),e.jsxs("button",{onClick:B,className:"inline-flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(xe,{className:"w-5 h-5 mr-2"}),"新建任务"]})]})]}),l?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ae,{className:"w-8 h-8 animate-spin text-gray-400"})}):n.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx(O,{className:"w-16 h-16 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:"暂无定时任务"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"创建定时任务来让 Agent 自动执行工作"}),e.jsxs("button",{onClick:B,className:"inline-flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(xe,{className:"w-5 h-5 mr-2"}),"创建第一个任务"]})]}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(ue,{children:[e.jsx(ge,{children:e.jsxs(Y,{children:[e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"状态"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"任务名称"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Agent"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"调度规则"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"上次执行"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"下次执行"}),e.jsx(N,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"操作"})]})}),e.jsx(he,{children:n.map(r=>e.jsxs(Y,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("button",{onClick:()=>le(r),className:`p-1 rounded-full transition-colors ${r.enabled?"text-green-600 hover:bg-green-100 dark:hover:bg-green-900":"text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:r.enabled?"点击暂停":"点击启用",children:r.enabled?e.jsx(pe,{className:"w-5 h-5 fill-current"}):e.jsx(Pe,{className:"w-5 h-5"})})}),e.jsx(j,{className:"px-6 py-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r.name}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-[200px]",children:r.description})]})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:M(r.agentId)})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm font-mono text-gray-600 dark:text-gray-400",children:ne(r)})}),e.jsx(j,{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[G(r),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:E(r.lastRunAt)})]})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:r.enabled?E(r.nextRunAt):"-"})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.lastRunStatus==="running"?e.jsx("button",{onClick:()=>A(r),className:"p-2 text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded-lg transition-colors",title:"停止执行",children:e.jsx(De,{className:"w-4 h-4"})}):e.jsx("button",{onClick:()=>de(r),className:"p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded-lg transition-colors",title:"立即执行",children:e.jsx(Re,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>f(r.id),className:"p-2 text-gray-500 hover:text-purple-600 hover:bg-purple-50 dark:hover:bg-purple-900 rounded-lg transition-colors",title:"执行历史",children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>K(r),className:"p-2 text-gray-500 hover:text-green-600 hover:bg-green-50 dark:hover:bg-green-900 rounded-lg transition-colors",title:"编辑",children:e.jsx(Oe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>T(r),className:"p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded-lg transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-4 h-4"})})]})})]},r.id))})]})}),J&&e.jsx(nt,{task:_,agents:ee,onSave:X,onCancel:re}),V&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"执行器设置"}),e.jsx("button",{onClick:()=>m(!1),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Le,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"最大并发数 (1-10)"}),e.jsx("input",{type:"number",min:1,max:10,value:s,onChange:r=>x(Math.min(10,Math.max(1,parseInt(r.target.value)||1))),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"允许同时执行的最大任务数量"})]}),h&&e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["当前配置: 并发 ",h.maxConcurrent]})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:()=>m(!1),className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:"取消"}),e.jsx("button",{onClick:async()=>{try{await H.mutateAsync({maxConcurrent:s}),C(`并发数已更新为 ${s}`),m(!1)}catch(r){g(r instanceof Error?r.message:"更新失败")}},disabled:H.isPending,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50",children:H.isPending?"保存中...":"保存"})]})]})})]})};export{bt as ScheduledTasksPage,bt as default};
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i,W as ve}from"./monaco-editor-DHKm5-VF.js";import{T as ue,a as ge,b as Y,c as N,d as he,e as j}from"./table-Br8ioTXr.js";import{b as z,u as I,c as P,a as k,A as w}from"./agents-D9dWnZr0.js";import{u as Ne}from"./useAgents-BlQGwXjx.js";import{u as Se}from"./useProjects-cgsJNlsy.js";import{u as Ce}from"./useClaudeVersions-DJ6VKG1y.js";import{a as g,s as C}from"./index-BLjehayc.js";import{m as O,t as Te,f as Ee,az as ce,k as me,a5 as Ae,aA as ye,ag as pe,a3 as Ie,aB as $e,L as ae,l as qe,e as oe,n as be,C as fe,A as Me,r as Fe,v as xe,aC as Pe,aD as De,U as Re,aE as Ke,J as Oe,y as Qe,X as Le}from"./ui-components-BsYwJvCF.js";import"./syntax-highlighting-CnREyncB.js";import"./tools-zTM46-tZ.js";const d={all:["scheduled-tasks"],lists:()=>[...d.all,"list"],list:()=>[...d.lists()],details:()=>[...d.all,"detail"],detail:t=>[...d.details(),t],history:t=>[...d.all,"history",t],status:()=>[...d.all,"status"]},Ve=()=>z({queryKey:d.list(),queryFn:async()=>{const t=await k(`${w}/scheduled-tasks`);if(!t.ok)throw new Error("Failed to fetch scheduled tasks");return t.json()},refetchInterval:t=>t.state.data?.some(c=>c.lastRunStatus==="running")?3e3:!1}),He=(t,n=50)=>z({queryKey:d.history(t),queryFn:async()=>{const l=await k(`${w}/scheduled-tasks/${t}/history?limit=${n}`);if(!l.ok)throw new Error("Failed to fetch task execution history");return l.json()},enabled:!!t,refetchInterval:l=>l.state.data?.some($=>$.status==="running")?3e3:!1}),Be=()=>z({queryKey:d.status(),queryFn:async()=>{const t=await k(`${w}/scheduled-tasks/status`);if(!t.ok)throw new Error("Failed to fetch scheduler status");return t.json()},refetchInterval:3e4}),ze=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to create scheduled task")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.status()})}})},Ue=()=>{const t=I();return P({mutationFn:async({taskId:n,data:l})=>{const c=await k(`${w}/scheduled-tasks/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!c.ok){const p=await c.json().catch(()=>({}));throw new Error(p.error||"Failed to update scheduled task")}return c.json()},onSuccess:n=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.detail(n.id)}),t.invalidateQueries({queryKey:d.status()})}})},_e=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/${n}`,{method:"DELETE"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to delete scheduled task")}},onSuccess:()=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.status()})}})},Je=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/${n}/toggle`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to toggle scheduled task")}return l.json()},onSuccess:n=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.detail(n.id)}),t.invalidateQueries({queryKey:d.status()})}})},je=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/${n}/run`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to run scheduled task")}return l.json()},onSuccess:(n,l)=>{t.invalidateQueries({queryKey:d.detail(l)}),t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.history(l)})}})},We=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/scheduled-tasks/executions/${n}/stop`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to stop execution")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.all})}})},Xe=()=>z({queryKey:[...d.all,"running"],queryFn:async()=>{const t=await k(`${w}/scheduled-tasks/running`);if(!t.ok)throw new Error("Failed to fetch running executions");return t.json()},refetchInterval:3e3}),Ge=()=>{const t=I();return P({mutationFn:async()=>{const n=await k(`${w}/scheduled-tasks/scheduler/enable`,{method:"POST"});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.error||"Failed to enable scheduler")}return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.status()})}})},Ye=()=>{const t=I();return P({mutationFn:async()=>{const n=await k(`${w}/scheduled-tasks/scheduler/disable`,{method:"POST"});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.error||"Failed to disable scheduler")}return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.status()})}})},Z={all:["task-executor"],stats:()=>[...Z.all,"stats"],health:()=>[...Z.all,"health"]},Ze=()=>z({queryKey:Z.stats(),queryFn:async()=>{const t=await k(`${w}/task-executor/stats`);if(!t.ok)throw new Error("Failed to fetch task executor stats");return t.json()},refetchInterval:5e3}),et=()=>z({queryKey:[...Z.all,"config"],queryFn:async()=>{const t=await k(`${w}/task-executor/config`);if(!t.ok)throw new Error("Failed to fetch task executor config");return t.json()}}),tt=()=>{const t=I();return P({mutationFn:async n=>{const l=await k(`${w}/task-executor/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to update executor config")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:Z.all})}})},rt=[{label:"每 5 分钟",value:"*/5 * * * *"},{label:"每 15 分钟",value:"*/15 * * * *"},{label:"每 30 分钟",value:"*/30 * * * *"},{label:"每小时",value:"0 * * * *"},{label:"每天 9:00",value:"0 9 * * *"},{label:"每天 18:00",value:"0 18 * * *"},{label:"每周一 9:00",value:"0 9 * * 1"},{label:"每月 1 日 9:00",value:"0 9 1 * *"}],st=t=>{if(!t){const n=new Date;return n.setHours(n.getHours()+1),n.setMinutes(0),n.setSeconds(0),n.toISOString().slice(0,16)}return new Date(t).toISOString().slice(0,16)},at=t=>new Date(t).toISOString(),nt=({task:t,agents:n,onSave:l,onCancel:c})=>{const p=!!t,$=ze(),Q=Ue(),L=je(),{data:U}=Se(),D=U?.projects||[],{data:o}=Ce(),[v,_]=i.useState(t?.name||""),[S,J]=i.useState(t?.description||""),[b,q]=i.useState(t?.agentId||""),[f,V]=i.useState(t?.projectPath||""),[m,s]=i.useState(t?.schedule.type||"interval"),[x,u]=i.useState(t?.schedule.intervalMinutes||30),[h,H]=i.useState(t?.schedule.cronExpression||"*/30 * * * *"),[W,ee]=i.useState(st(t?.schedule.executeAt)),[M,ne]=i.useState(t?.triggerMessage||""),[E,le]=i.useState(t?.enabled??!0),[T,de]=i.useState(!!t?.modelOverride?.modelId),[A,te]=i.useState(t?.modelOverride?.versionId||""),[K,B]=i.useState(t?.modelOverride?.modelId||""),[X,re]=i.useState(!1),[G,r]=i.useState(!1),y=i.useMemo(()=>o?.versions?A?o.versions.find(ie=>ie.id===A)?.models||[]:(o.versions.find(R=>R.id===o.defaultVersionId)||o.versions[0])?.models||[]:[],[o,A]);i.useEffect(()=>{T&&o?.versions&&A&&(o.versions.some(R=>R.id===A)||(te(o.defaultVersionId||""),B("")))},[o,A,T]),i.useEffect(()=>{T&&y.length>0&&(y.some(R=>R.id===K)||B(y[0].id))},[y,K,T]),i.useEffect(()=>{!b&&n.length>0&&q(n[0].id)},[b,n]),i.useEffect(()=>{!f&&D.length>0&&V(D[0].path)},[f,D]);const F=()=>m==="interval"?{type:"interval",intervalMinutes:x}:m==="once"?{type:"once",executeAt:at(W)}:{type:"cron",cronExpression:h},se=()=>{if(!(!T||!K))return{versionId:A||void 0,modelId:K}},ke=async()=>{if(!v.trim()){g("请输入任务名称");return}if(!b){g("请选择 Agent");return}if(!f){g("请选择项目路径");return}if(!M.trim()){g("请输入触发消息");return}if(m==="interval"&&(!x||x<1)){g("间隔时间必须大于 0");return}if(m==="cron"&&!h.trim()){g("请输入 Cron 表达式");return}if(m==="once"){const a=new Date(W).getTime();if(isNaN(a)){g("请选择有效的执行时间");return}if(a<=Date.now()){g("执行时间必须在未来");return}}re(!0);try{if(p)await Q.mutateAsync({taskId:t.id,data:{name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()}}),C("任务已更新");else{const a={name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()};await $.mutateAsync(a),C("任务已创建")}l()}catch{g(p?"更新失败":"创建失败")}finally{re(!1)}},we=async()=>{if(!v.trim()){g("请输入任务名称");return}if(!b){g("请选择 Agent");return}if(!f){g("请选择项目路径");return}if(!M.trim()){g("请输入触发消息");return}r(!0);try{let a;if(p)await Q.mutateAsync({taskId:t.id,data:{name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()}}),a=t.id,C("任务已更新");else{const R={name:v.trim(),description:S.trim()||void 0,agentId:b,projectPath:f,schedule:F(),triggerMessage:M.trim(),enabled:E,modelOverride:se()};a=(await $.mutateAsync(R)).id,C("任务已创建")}await L.mutateAsync(a),C("任务已开始执行,请在执行历史中查看结果"),l()}catch{g("操作失败")}finally{r(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:p?"编辑定时任务":"创建定时任务"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"配置 Agent 的自动执行计划"})]}),e.jsx("button",{onClick:c,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(O,{className:"w-5 h-5"}),"基本信息"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"任务名称 *"}),e.jsx("input",{type:"text",value:v,onChange:a=>_(a.target.value),placeholder:"例如:每日代码检查",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"描述"}),e.jsx("input",{type:"text",value:S,onChange:a=>J(a.target.value),placeholder:"可选的任务描述",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(Te,{className:"w-5 h-5"}),"执行配置"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"执行 Agent *"}),e.jsx("select",{value:b,onChange:a=>q(a.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:n.map(a=>e.jsxs("option",{value:a.id,children:[a.ui?.icon||"🤖"," ",a.name]},a.id))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4"}),"项目路径 *"]}),e.jsx("select",{value:f,onChange:a=>V(a.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:D.map(a=>e.jsx("option",{value:a.path,children:a.name||a.path},a.path))}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Agent 将在此项目目录下执行"})]}),e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"覆盖模型配置"})]}),e.jsx("button",{type:"button",onClick:()=>de(!T),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${T?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${T?"translate-x-5":"translate-x-1"}`})})]}),T&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"可以为定时任务指定不同于 Agent 默认的模型"}),o?.versions&&o.versions.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"供应商"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:A,onChange:a=>te(a.target.value),className:"w-full appearance-none px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[e.jsx("option",{value:"",children:o.defaultVersionId?`默认 (${o.versions.find(a=>a.id===o.defaultVersionId)?.name})`:"默认"}),o.versions.filter(a=>a.id!==o.defaultVersionId).map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]}),e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none text-gray-500",children:e.jsx(me,{className:"w-4 h-4"})})]})]}),y.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"模型"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:y.map(a=>e.jsxs("button",{type:"button",onClick:()=>B(a.id),className:`flex items-center justify-between px-3 py-2 text-sm rounded-lg border transition-all ${K===a.id?"border-purple-500 bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300 shadow-sm":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 text-gray-700 dark:text-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ce,{className:"w-4 h-4 opacity-70"}),e.jsx("span",{className:"font-medium",children:a.name})]}),a.isVision&&e.jsx("span",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded text-gray-500",children:"Vision"})]},a.id))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(O,{className:"w-5 h-5"}),"调度规则"]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"interval",checked:m==="interval",onChange:()=>s("interval"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"间隔执行"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"cron",checked:m==="cron",onChange:()=>s("cron"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Cron 表达式"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"once",checked:m==="once",onChange:()=>s("once"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"仅执行一次"})]})]}),m==="interval"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"间隔时间(分钟)"}),e.jsx("input",{type:"number",min:1,max:10080,value:x,onChange:a=>u(parseInt(a.target.value)||30),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["每隔 ",x," 分钟执行一次"]})]}),m==="cron"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Cron 表达式"}),e.jsx("input",{type:"text",value:h,onChange:a=>H(a.target.value),placeholder:"*/30 * * * *",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white font-mono focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:rt.map(a=>e.jsx("button",{type:"button",onClick:()=>H(a.value),className:`px-2 py-1 text-xs rounded-full border transition-colors ${h===a.value?"bg-blue-100 border-blue-300 text-blue-700 dark:bg-blue-900 dark:border-blue-700 dark:text-blue-300":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700"}`,children:a.label},a.value))})]}),m==="once"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 flex items-center gap-2",children:[e.jsx(Ae,{className:"w-4 h-4"}),"执行时间"]}),e.jsx("input",{type:"datetime-local",value:W,onChange:a=>ee(a.target.value),min:new Date().toISOString().slice(0,16),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"任务将在指定时间执行一次后自动禁用"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(ye,{className:"w-5 h-5"}),"触发消息"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"发送给 Agent 的消息 *"}),e.jsx("textarea",{value:M,onChange:a=>ne(a.target.value),placeholder:"请检查代码质量并生成报告...",rows:5,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-y"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"定时触发时,这条消息会发送给选定的 Agent"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启用任务"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"创建后立即开始调度"})]}),e.jsx("button",{type:"button",onClick:()=>le(!E),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${E?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${E?"translate-x-6":"translate-x-1"}`})})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:c,className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",children:"取消"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:we,disabled:X||G,className:"inline-flex items-center px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors disabled:opacity-50",title:"保存任务并立即执行一次",children:[e.jsx(pe,{className:"w-4 h-4 mr-2"}),G?"执行中...":"保存并执行"]}),e.jsxs("button",{onClick:ke,disabled:X||G,className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:[e.jsx(Ie,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})]})})]})})},lt=({taskId:t,taskName:n,agentId:l,projectPath:c,onBack:p})=>{const{data:$=[],isLoading:Q}=He(t),[L,U]=i.useState(new Set),D=s=>{U(x=>{const u=new Set(x);return u.has(s)?u.delete(s):u.add(s),u})},o=s=>s?new Date(s).toLocaleString("zh-CN"):"-",v=s=>new Date(s).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),_=s=>{if(!s.completedAt)return"-";const x=new Date(s.startedAt).getTime(),h=new Date(s.completedAt).getTime()-x;return h<1e3?`${h}ms`:h<6e4?`${(h/1e3).toFixed(1)}s`:`${Math.floor(h/6e4)}m ${Math.floor(h%6e4/1e3)}s`},S=s=>{switch(s){case"running":return e.jsx(ae,{className:"w-5 h-5 text-blue-500 animate-spin"});case"success":return e.jsx(fe,{className:"w-5 h-5 text-green-500"});case"error":return e.jsx(be,{className:"w-5 h-5 text-red-500"});default:return e.jsx(O,{className:"w-5 h-5 text-gray-400"})}},J=s=>{switch(s){case"running":return e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"运行中"});case"success":return e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"成功"});case"error":return e.jsx("span",{className:"text-red-600 dark:text-red-400",children:"失败"});default:return e.jsx("span",{className:"text-gray-500",children:"未知"})}},b=s=>{switch(s){case"error":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20";case"warn":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20";case"info":return"text-blue-600 dark:text-blue-400";case"debug":return"text-gray-500 dark:text-gray-400";default:return"text-gray-600 dark:text-gray-400"}},q=s=>{switch(s){case"system":return"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400";case"assistant":return"bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-400";case"tool_use":return"bg-purple-100 text-purple-600 dark:bg-purple-900 dark:text-purple-400";case"result":return"bg-green-100 text-green-600 dark:bg-green-900 dark:text-green-400";case"error":return"bg-red-100 text-red-600 dark:bg-red-900 dark:text-red-400";default:return"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}},f=s=>{const x=s.agentId||l,u=s.projectPath||c;if(!x||!s.sessionId)return null;let h=`/chat/${encodeURIComponent(x)}?session=${encodeURIComponent(s.sessionId)}`;return u&&(h+=`&project=${encodeURIComponent(u)}`),h},V=(s,x)=>{x.stopPropagation();const u=f(s);u&&window.open(u,"_blank")},m=s=>!s||s.length===0?e.jsx("div",{className:"text-center py-4 text-gray-500 dark:text-gray-400",children:"暂无执行日志"}):e.jsx("div",{className:"space-y-1 max-h-96 overflow-y-auto",children:s.map((x,u)=>e.jsxs("div",{className:`flex items-start gap-2 px-3 py-1.5 rounded text-sm font-mono ${b(x.level)}`,children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-500 shrink-0 w-24",children:v(x.timestamp)}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs shrink-0 ${q(x.type)}`,children:x.type}),e.jsx("span",{className:"flex-1 break-all whitespace-pre-wrap",children:x.message})]},u))});return e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("button",{onClick:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",children:e.jsx($e,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"执行历史"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["任务:",n]})]})]}),Q?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ae,{className:"w-8 h-8 animate-spin text-gray-400"})}):$.length===0?e.jsxs("div",{className:"text-center py-12 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx(O,{className:"w-12 h-12 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"暂无执行记录"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"任务尚未执行过"})]}):e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(ue,{children:[e.jsx(ge,{children:e.jsxs(Y,{children:[e.jsx(N,{className:"w-[40px]"}),e.jsx(N,{className:"w-[80px]",children:"状态"}),e.jsx(N,{children:"开始时间"}),e.jsx(N,{children:"完成时间"}),e.jsx(N,{children:"耗时"}),e.jsx(N,{children:"结果摘要"}),e.jsx(N,{className:"w-[100px]",children:"操作"})]})}),e.jsx(he,{children:$.map(s=>e.jsxs(ve.Fragment,{children:[e.jsxs(Y,{className:"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800",onClick:()=>D(s.id),children:[e.jsx(j,{className:"p-2",children:e.jsx("button",{className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:L.has(s.id)?e.jsx(me,{className:"w-4 h-4 text-gray-500"}):e.jsx(qe,{className:"w-4 h-4 text-gray-500"})})}),e.jsx(j,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[S(s.status),J(s.status)]})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:o(s.startedAt)})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:o(s.completedAt)})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm font-mono text-gray-600 dark:text-gray-400",children:_(s)})}),e.jsx(j,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.logs&&s.logs.length>0&&e.jsx("span",{title:"有详细日志",children:e.jsx(oe,{className:"w-4 h-4 text-gray-400 shrink-0"})}),s.error?e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 max-w-md truncate",children:s.error}):s.responseSummary?e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 max-w-md truncate",children:s.responseSummary}):e.jsx("span",{className:"text-sm text-gray-400",children:"-"})]})}),e.jsx(j,{children:s.sessionId&&f(s)&&e.jsx("button",{onClick:x=>V(s,x),className:"inline-flex items-center justify-center p-2 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors",title:"在新窗口继续会话",children:e.jsx(ye,{className:"w-4 h-4"})})})]}),L.has(s.id)&&e.jsx(Y,{children:e.jsx(j,{colSpan:7,className:"bg-gray-50 dark:bg-gray-800/50 p-4",children:e.jsxs("div",{className:"space-y-3",children:[s.errorStack&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-red-700 dark:text-red-400 mb-2",children:"错误堆栈"}),e.jsx("pre",{className:"text-xs text-red-600 dark:text-red-400 whitespace-pre-wrap overflow-x-auto",children:s.errorStack})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4"}),"执行日志",s.logs&&e.jsxs("span",{className:"text-xs text-gray-400",children:["(",s.logs.length," 条)"]})]}),m(s.logs)]}),s.sessionId&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Session ID: ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded",children:s.sessionId})]})]})})})]},s.id))})]})})]})},bt=()=>{const t=I(),{data:n=[],isLoading:l}=Ve(),{data:c}=Ne(!0),{data:p}=Be(),$=_e(),Q=Je(),L=je(),U=We(),{data:D}=Xe(),o=Ge(),v=Ye(),[_,S]=i.useState(null),[J,b]=i.useState(!1),[q,f]=i.useState(null),[V,m]=i.useState(!1),[s,x]=i.useState(2),{data:u}=Ze(),{data:h}=et(),H=tt(),W=r=>D?.executions?.find(F=>F.taskId===r)?.executionId||null,ee=c?.agents||[],M=r=>ee.find(F=>F.id===r)?.name||r,ne=r=>{if(r.schedule.type==="interval"&&r.schedule.intervalMinutes){const y=r.schedule.intervalMinutes;return y<60?`每 ${y} 分钟`:`每 ${Math.floor(y/60)} 小时`}return r.schedule.type==="cron"&&r.schedule.cronExpression?r.schedule.cronExpression:r.schedule.type==="once"&&r.schedule.executeAt?`一次性 @ ${new Date(r.schedule.executeAt).toLocaleString("zh-CN")}`:"-"},E=r=>r?new Date(r).toLocaleString("zh-CN"):"-",le=async r=>{try{await Q.mutateAsync(r.id),C(r.enabled?"任务已暂停":"任务已启用")}catch{g("操作失败")}},T=async r=>{if(confirm(`确定要删除任务 "${r.name}" 吗?`))try{await $.mutateAsync(r.id),C("任务已删除")}catch{g("删除失败")}},de=async r=>{try{await L.mutateAsync(r.id),C("任务已开始执行"),t.invalidateQueries({queryKey:d.lists()})}catch{g("执行失败")}},A=async r=>{const y=W(r.id);if(!y){g("找不到正在运行的执行");return}try{await U.mutateAsync(y),C("任务已停止"),t.invalidateQueries({queryKey:d.lists()})}catch{g("停止失败")}},te=async()=>{if(p)try{p.enabled?(await v.mutateAsync(),C("调度器已禁用")):(await o.mutateAsync(),C("调度器已启用"))}catch{g("操作失败")}},K=r=>{S(r),b(!0)},B=()=>{S(null),b(!0)},X=()=>{S(null),b(!1),t.invalidateQueries({queryKey:d.lists()})},re=()=>{S(null),b(!1)},G=r=>r.lastRunStatus==="running"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:[e.jsx(ae,{className:"w-3 h-3 mr-1 animate-spin"}),"运行中"]}):r.lastRunStatus==="success"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(fe,{className:"w-3 h-3 mr-1"}),"成功"]}):r.lastRunStatus==="error"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),"失败"]}):e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:"未执行"});if(q){const r=n.find(y=>y.id===q);return e.jsx(lt,{taskId:q,taskName:r?.name||q,agentId:r?.agentId,projectPath:r?.projectPath,onBack:()=>f(null)})}return e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(O,{className:"w-8 h-8"}),"定时任务"]}),e.jsx("p",{className:"mt-2 text-gray-600 dark:text-gray-400",children:"配置 Agent 的自动执行计划"})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[p&&e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("button",{onClick:te,disabled:o.isPending||v.isPending,className:`flex items-center gap-2 px-3 py-1.5 rounded-lg transition-colors ${p.enabled?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 hover:bg-green-100 dark:hover:bg-green-900/30":"bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300 hover:bg-orange-100 dark:hover:bg-orange-900/30"} ${o.isPending||v.isPending?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,title:p.enabled?"点击禁用调度器":"点击启用调度器",children:[e.jsx(O,{className:`w-4 h-4 ${o.isPending||v.isPending?"animate-pulse":""}`}),e.jsx("span",{className:"font-medium",children:p.enabled?"调度器已启用":"调度器已禁用"})]}),u&&e.jsxs("div",{className:"flex items-center gap-3 text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsxs("span",{className:`flex items-center gap-1 ${u.runningTasks>0?"text-blue-600 dark:text-blue-400":""}`,children:[e.jsx(Me,{className:`w-4 h-4 ${u.runningTasks>0?"animate-pulse":""}`}),"运行: ",u.runningTasks]}),e.jsxs("span",{className:"text-yellow-600 dark:text-yellow-400",children:["队列: ",u.queuedTasks]}),e.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["完成: ",u.completedTasks]}),e.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["失败: ",u.failedTasks]}),e.jsx("button",{onClick:()=>{h&&x(h.maxConcurrent),m(!0)},className:"ml-2 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"执行器设置",children:e.jsx(Fe,{className:"w-4 h-4"})})]})]}),e.jsxs("button",{onClick:B,className:"inline-flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(xe,{className:"w-5 h-5 mr-2"}),"新建任务"]})]})]}),l?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ae,{className:"w-8 h-8 animate-spin text-gray-400"})}):n.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx(O,{className:"w-16 h-16 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:"暂无定时任务"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"创建定时任务来让 Agent 自动执行工作"}),e.jsxs("button",{onClick:B,className:"inline-flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(xe,{className:"w-5 h-5 mr-2"}),"创建第一个任务"]})]}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(ue,{children:[e.jsx(ge,{children:e.jsxs(Y,{children:[e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"状态"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"任务名称"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Agent"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"调度规则"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"上次执行"}),e.jsx(N,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"下次执行"}),e.jsx(N,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"操作"})]})}),e.jsx(he,{children:n.map(r=>e.jsxs(Y,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("button",{onClick:()=>le(r),className:`p-1 rounded-full transition-colors ${r.enabled?"text-green-600 hover:bg-green-100 dark:hover:bg-green-900":"text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:r.enabled?"点击暂停":"点击启用",children:r.enabled?e.jsx(pe,{className:"w-5 h-5 fill-current"}):e.jsx(Pe,{className:"w-5 h-5"})})}),e.jsx(j,{className:"px-6 py-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r.name}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-[200px]",children:r.description})]})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:M(r.agentId)})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm font-mono text-gray-600 dark:text-gray-400",children:ne(r)})}),e.jsx(j,{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[G(r),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:E(r.lastRunAt)})]})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:r.enabled?E(r.nextRunAt):"-"})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.lastRunStatus==="running"?e.jsx("button",{onClick:()=>A(r),className:"p-2 text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded-lg transition-colors",title:"停止执行",children:e.jsx(De,{className:"w-4 h-4"})}):e.jsx("button",{onClick:()=>de(r),className:"p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded-lg transition-colors",title:"立即执行",children:e.jsx(Re,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>f(r.id),className:"p-2 text-gray-500 hover:text-purple-600 hover:bg-purple-50 dark:hover:bg-purple-900 rounded-lg transition-colors",title:"执行历史",children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>K(r),className:"p-2 text-gray-500 hover:text-green-600 hover:bg-green-50 dark:hover:bg-green-900 rounded-lg transition-colors",title:"编辑",children:e.jsx(Oe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>T(r),className:"p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded-lg transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-4 h-4"})})]})})]},r.id))})]})}),J&&e.jsx(nt,{task:_,agents:ee,onSave:X,onCancel:re}),V&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"执行器设置"}),e.jsx("button",{onClick:()=>m(!1),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Le,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"最大并发数 (1-10)"}),e.jsx("input",{type:"number",min:1,max:10,value:s,onChange:r=>x(Math.min(10,Math.max(1,parseInt(r.target.value)||1))),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"允许同时执行的最大任务数量"})]}),h&&e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["当前配置: 并发 ",h.maxConcurrent]})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:()=>m(!1),className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:"取消"}),e.jsx("button",{onClick:async()=>{try{await H.mutateAsync({maxConcurrent:s}),C(`并发数已更新为 ${s}`),m(!1)}catch(r){g(r instanceof Error?r.message:"更新失败")}},disabled:H.isPending,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50",children:H.isPending?"保存中...":"保存"})]})]})})]})};export{bt as ScheduledTasksPage,bt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./data-structures-C0h9Oap1.js";import{b as i,O as r}from"./index-
|
|
1
|
+
import{j as t}from"./data-structures-C0h9Oap1.js";import{b as i,O as r}from"./index-BLjehayc.js";import"./monaco-editor-DHKm5-VF.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-D9dWnZr0.js";import"./tools-zTM46-tZ.js";import"./ui-components-BsYwJvCF.js";const l=()=>{const{isMobile:o}=i();return t.jsx("div",{className:o?"p-4":"p-8",children:t.jsx("div",{children:t.jsx(r,{})})})};export{l as SettingsLayout};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as c}from"./monaco-editor-DHKm5-VF.js";import{T as pe,a as be,b as Z,c as q,d as fe,e as O}from"./table-D-FJ6K6j.js";import{g as ye,a as f,b as te,u as X,c as J,A as _}from"./agents-D9dWnZr0.js";import{U as ke}from"./UnifiedToolSelector-Bw-E7HW4.js";import{u as V}from"./tools-zTM46-tZ.js";import{r as we,e as je,aJ as ve,X as Q,v as ae,g as Ne,E as Se,f as Te,J as Ce,y as Fe}from"./ui-components-BsYwJvCF.js";import{B as z}from"./Button-BHiMThm4.js";import{F as $e}from"./FileExplorer-BB3suHzW.js";import{T as Ee}from"./ToolsList-C9LELdNX.js";import"./syntax-highlighting-CnREyncB.js";import"./index-BFYHztzB.js";class De{baseURL=`${ye()}/skills`;async getAllSkills(r){const s=new URLSearchParams;r?.scope&&s.append("scope",r.scope),r?.includeDisabled&&s.append("includeDisabled","true");const l=await f(`${this.baseURL}?${s.toString()}`);if(!l.ok)throw new Error(`Failed to fetch skills: ${l.statusText}`);const o=await l.json();return this.transformToSkillListItems(o.skills)}async getSkill(r,s){const l=s?`?scope=${s}`:"",o=await f(`${this.baseURL}/${r}${l}`);if(o.status===404)return null;if(!o.ok)throw new Error(`Failed to fetch skill: ${o.statusText}`);return(await o.json()).skill}async createSkill(r){const s=await f(`${this.baseURL}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok){const o=await s.json();throw new Error(o.error||"Failed to create skill")}return(await s.json()).skill}async updateSkill(r,s){const l=await f(`${this.baseURL}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok){const x=await l.json();throw new Error(x.error||"Failed to update skill")}return(await l.json()).skill}async deleteSkill(r,s){const l=s?`?scope=${s}`:"",o=await f(`${this.baseURL}/${r}${l}`,{method:"DELETE"});if(o.status===404)return!1;if(!o.ok)throw new Error(`Failed to delete skill: ${o.statusText}`);return!0}async getSkillDirectoryInfo(r){const s=await f(`${this.baseURL}/${r}/directory`);if(s.status===404)return null;if(!s.ok)throw new Error(`Failed to fetch skill directory info: ${s.statusText}`);return(await s.json()).directoryInfo}async validateSkillManifest(r){const s=await f(`${this.baseURL}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})});if(!s.ok)throw new Error(`Failed to validate skill manifest: ${s.statusText}`);return await s.json()}async getSkillFile(r,s){const l=await f(`${this.baseURL}/${r}/files/${s}`);if(!l.ok)throw new Error(`Failed to fetch skill file: ${l.statusText}`);return(await l.json()).content}async updateSkillFile(r,s,l){const o=await f(`${this.baseURL}/${r}/files/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l})});if(!o.ok)throw new Error(`Failed to update skill file: ${o.statusText}`)}transformToSkillListItems(r){return r.map(s=>({id:s.id,name:s.name,description:s.description,scope:s.scope,projectName:s.scope==="project"?"Current Project":void 0,source:s.source,enabled:s.enabled,createdAt:s.createdAt,updatedAt:s.updatedAt,allowedTools:s.allowedTools,toolCount:s.allowedTools?.length||0,usageCount:0,lastUsed:void 0}))}}const A=new De,y={all:["skills"],lists:()=>[...y.all,"list"],list:a=>[...y.lists(),a],details:()=>[...y.all,"detail"],detail:a=>[...y.details(),a],directory:a=>[...y.all,"directory",a]},Le=a=>te({queryKey:y.list(a||{}),queryFn:()=>A.getAllSkills(a),staleTime:300*1e3}),Me=(a,r)=>te({queryKey:y.detail(a),queryFn:()=>A.getSkill(a,r),enabled:!!a,staleTime:300*1e3}),Pe=()=>{const a=X();return J({mutationFn:r=>A.createSkill(r),onSuccess:r=>{a.invalidateQueries({queryKey:y.lists()}),a.setQueryData(y.detail(r.id),r)},onError:r=>{console.error("Failed to create skill:",r)}})},Ae=()=>{const a=X();return J({mutationFn:({skillId:r,updates:s})=>A.updateSkill(r,s),onSuccess:r=>{a.setQueryData(y.detail(r.id),r),a.invalidateQueries({queryKey:y.lists()})},onError:r=>{console.error("Failed to update skill:",r)}})},Ie=()=>{const a=X();return J({mutationFn:({skillId:r,scope:s})=>A.deleteSkill(r,s),onSuccess:(r,{skillId:s})=>{a.removeQueries({queryKey:y.detail(s)}),a.invalidateQueries({queryKey:y.lists()})},onError:r=>{console.error("Failed to delete skill:",r)}})},Re=()=>J({mutationFn:a=>A.validateSkillManifest(a),onError:a=>{console.error("Failed to validate skill manifest:",a)}}),Ue=({onClose:a,onSuccess:r,editSkill:s})=>{const{t:l}=V(["skills","common"]),o=!!s,[x,g]=c.useState("basic"),[n,h]=c.useState({name:"",description:"",allowedTools:[],content:"",additionalFiles:[]}),[m,j]=c.useState([]),[k,F]=c.useState(""),[$,M]=c.useState(!1),[S,E]=c.useState([]),[p,v]=c.useState([]),[T,I]=c.useState(!1),P=Pe(),R=Ae(),U=Re(),B=Me(s?.id||"",s?.scope||"user"),C=o?B.data:null,K=o?B.isLoading:!1,[d,N]=c.useState(0),[H,D]=c.useState(0),[L,Y]=c.useState(!1);c.useEffect(()=>{if(!L){const t=[...S];T&&t.push(...p),h(i=>({...i,allowedTools:t})),N(Date.now())}},[S,p,T,L]),c.useEffect(()=>{!L&&(n.name||n.description)&&N(Date.now())},[n.name,n.description,L]),c.useEffect(()=>{!L&&n.content&&D(Date.now())},[n.content,L]),c.useEffect(()=>{if(o&&C){h({name:C.name,description:C.description,allowedTools:C.allowedTools||[],content:"",additionalFiles:(C.files||[]).filter(u=>!u.path.endsWith("SKILL.md")).map(u=>({id:Math.random().toString(36).substr(2,9),name:u.name,path:u.path,type:u.type,content:""}))});const t=C.allowedTools||[],i=t.filter(u=>!u.startsWith("mcp__")),b=t.filter(u=>u.startsWith("mcp__"));E(i),v(b),I(b.length>0),(async()=>{try{const u=await fetch(`/api/skills/${s.id}/files/SKILL.md`);if(u.ok){const he=await u.json();h(ge=>({...ge,content:he.content})),D(Date.now())}}catch(u){console.error("Failed to load skill manifest:",u)}})()}},[o,C,s]),c.useEffect(()=>{if(n.content){const i=setTimeout(async()=>{try{const b=await U.mutateAsync(n.content);j(b.errors.map(w=>w.message)||[])}catch{j(["Validation failed"])}},500);return()=>clearTimeout(i)}},[n.content,U]);const se=async()=>{try{if(o){const t={name:n.name,description:n.description,allowedTools:n.allowedTools,content:n.content,additionalFiles:n.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await R.mutateAsync({skillId:s.id,updates:t})}else{const t={name:n.name,description:n.description,scope:"user",allowedTools:n.allowedTools,content:n.content,additionalFiles:n.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await P.mutateAsync(t)}r()}catch(t){console.error(o?"Failed to update skill:":"Failed to create skill:",t),alert(l(o?"errors.updateFailed":"errors.createFailed"))}},re=()=>{const t={id:Math.random().toString(36).substr(2,9),name:"New File",path:"new-file.md",type:"markdown",content:""};h(i=>({...i,additionalFiles:[...i.additionalFiles,t]}))},le=t=>{h(i=>({...i,additionalFiles:i.additionalFiles.filter(b=>b.id!==t)}))},W=(t,i)=>{h(b=>({...b,additionalFiles:b.additionalFiles.map(w=>w.id===t?{...w,...i}:w)}))},ne=n.name.trim()!==""&&!k&&n.description.trim()!==""&&n.content.trim()!==""&&m.length===0,oe=()=>{switch(x){case"basic":return n.name.trim()!==""&&!k&&n.description.trim()!=="";case"manifest":return n.content.trim()!==""&&m.length===0;case"files":return!0;default:return!1}},G=()=>{if(!L){if(Y(!0),d>H){if(n.name&&n.description){const t=ee(n.name,n.description,n.allowedTools);h(i=>({...i,content:t})),D(Date.now())}}else if(H>d){const t=Be(n.content);if(t&&(t.name&&t.name!==n.name||t.description&&t.description!==n.description||t.allowedTools&&JSON.stringify(t.allowedTools)!==JSON.stringify(n.allowedTools))){h(u=>({...u,name:t.name||u.name,description:t.description||u.description,allowedTools:t.allowedTools||u.allowedTools}));const b=(t.allowedTools||[]).filter(u=>!u.startsWith("mcp__")),w=(t.allowedTools||[]).filter(u=>u.startsWith("mcp__"));E(b),v(w),I(w.length>0),N(Date.now())}}else if(!n.content&&n.name&&n.description){const t=ee(n.name,n.description,n.allowedTools);h(i=>({...i,content:t})),D(Date.now())}setTimeout(()=>Y(!1),100)}},ie=()=>{G(),x==="basic"?g("manifest"):x==="manifest"&&g("files")},de=t=>{G(),g(t)},ce=[{id:"basic",label:l("create.tabs.basic"),icon:we},{id:"manifest",label:l("create.tabs.manifest"),icon:je},{id:"files",label:l("create.tabs.files"),icon:ve}],xe=t=>t?t.length>64?"技能名称不能超过64个字符":/^[a-z0-9-]+$/.test(t)?t.startsWith("-")||t.endsWith("-")?"不能以连字符开始或结束":t.includes("--")?"不能包含连续的连字符":"":"只能使用小写字母、数字和连字符":"",ue=t=>{h(i=>({...i,name:t})),F(xe(t))},me=t=>{t.key==="Escape"&&a()};return o&&K?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white rounded-lg p-6 w-full max-w-md",children:e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})})})}):e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onKeyDown:me,children:[e.jsxs("div",{className:"bg-white rounded-lg w-full max-w-3xl max-h-[90vh] overflow-hidden flex flex-col dark:bg-gray-800 dark:text-white",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:o?`编辑技能 - ${s?.name}`:l("create.title")}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 dark:text-gray-300",children:o?"修改现有技能的配置和功能":l("create.subtitle")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[x!=="files"?e.jsx("button",{onClick:ie,disabled:!oe(),className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors dark:bg-blue-500 dark:hover:bg-blue-600",children:l("common:actions.next")}):e.jsx("button",{onClick:se,disabled:!ne||P.isPending||R.isPending,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors dark:bg-blue-500 dark:hover:bg-blue-600",children:P.isPending||R.isPending?l("common:status.saving"):l(o?"common:actions.save":"common:actions.create")}),e.jsx("button",{onClick:a,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700",children:e.jsx(Q,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:ce.map(t=>{const i=t.icon,b=x===t.id,w=t.id==="basic"&&n.name.trim()!==""&&n.description.trim()!==""||t.id==="manifest"&&n.content.trim()!==""&&m.length===0||t.id==="files";return e.jsxs("button",{onClick:()=>de(t.id),className:`flex items-center gap-2 px-6 py-3 font-medium text-sm transition-colors ${b?"text-blue-600 border-b-2 border-blue-600 dark:text-blue-400 dark:border-blue-400":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"}`,children:[e.jsx(i,{className:"w-4 h-4"}),t.label,w&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"})]},t.id)})}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x==="basic"&&e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:"技能名称 (Slug)"}),e.jsx("input",{type:"text",value:n.name,onChange:t=>ue(t.target.value),disabled:o,className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400 font-mono ${o?"bg-gray-100 text-gray-500 cursor-not-allowed dark:bg-gray-600 dark:text-gray-400":k?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300"}`,placeholder:"my-awesome-skill"}),k?e.jsx("p",{className:"text-xs text-red-500 mt-1 dark:text-red-400",children:k}):e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:o?"技能名称在编辑模式下不能修改":"只能使用小写字母、数字和连字符,最多64个字符"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.basic.description")}),e.jsx("textarea",{value:n.description,onChange:t=>{h(i=>({...i,description:t.target.value}))},rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.basic.descriptionPlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:l("create.basic.descriptionHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.basic.allowedTools")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{type:"button",onClick:()=>M(!$),className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg transition-colors text-sm",children:l("create.basic.selectTools")}),(S.length>0||p.length>0)&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["常规工具 ",S.length," 个",p.length>0&&`, MCP工具 ${p.length} 个`]})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:l("create.basic.allowedToolsHint")})]})]}),x==="manifest"&&e.jsx("div",{className:"space-y-6 max-w-2xl",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.content.skillManifest")}),e.jsx("textarea",{value:n.content,onChange:t=>h(i=>({...i,content:t.target.value})),rows:15,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400"}),m.length>0&&e.jsxs("div",{className:"mt-2 p-3 bg-red-50 border border-red-200 rounded-lg dark:bg-red-900/20 dark:border-red-800",children:[e.jsxs("h4",{className:"text-sm font-medium text-red-800 mb-1 dark:text-red-400",children:[l("editor.errors.validationErrors"),":"]}),e.jsx("ul",{className:"text-sm text-red-700 space-y-1 dark:text-red-300",children:m.map((t,i)=>e.jsxs("li",{children:["• ",t]},i))})]})]})}),x==="files"&&e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:l("create.content.additionalFiles")}),e.jsxs("button",{onClick:re,className:"flex items-center gap-2 px-3 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors dark:bg-green-500 dark:hover:bg-green-600",children:[e.jsx(ae,{className:"w-4 h-4"}),l("create.content.addFile")]})]}),n.additionalFiles.length===0?e.jsxs("div",{className:"text-center py-8 border-2 border-dashed border-gray-300 rounded-lg",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:l("create.content.noFiles")}),e.jsx("p",{className:"text-sm text-gray-500 mt-1 dark:text-gray-400",children:l("create.content.noFilesHint")})]}):e.jsx("div",{className:"space-y-4",children:n.additionalFiles.map(t=>e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("input",{type:"text",value:t.name,onChange:i=>W(t.id,{name:i.target.value}),className:"flex-1 px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.fileName")}),e.jsx("input",{type:"text",value:t.path,onChange:i=>W(t.id,{path:i.target.value}),className:"flex-1 px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.filePath")}),e.jsxs("select",{value:t.type,onChange:i=>W(t.id,{type:i.target.value}),className:"px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",children:[e.jsx("option",{value:"markdown",children:l("create.content.fileType.markdown")}),e.jsx("option",{value:"text",children:l("create.content.fileType.text")}),e.jsx("option",{value:"script",children:l("create.content.fileType.script")}),e.jsx("option",{value:"template",children:l("create.content.fileType.template")}),e.jsx("option",{value:"other",children:l("create.content.fileType.other")})]})]}),e.jsx("button",{onClick:()=>le(t.id),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded transition-colors dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20",children:e.jsx(Q,{className:"w-4 h-4"})})]}),e.jsx("textarea",{value:t.content,onChange:i=>W(t.id,{content:i.target.value}),rows:6,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.fileContent")})]},t.id))})]})]})]}),e.jsx(ke,{isOpen:$,onClose:()=>M(!1),selectedRegularTools:S,onRegularToolsChange:E,selectedMcpTools:p,onMcpToolsChange:v,mcpToolsEnabled:T,onMcpEnabledChange:I})]})};function Be(a){try{const r=a.match(/^---\s*\n(.*?)\n---/s);if(!r)return null;const l=r[1].split(`
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as c}from"./monaco-editor-DHKm5-VF.js";import{T as pe,a as be,b as Z,c as q,d as fe,e as O}from"./table-Br8ioTXr.js";import{g as ye,a as f,b as te,u as X,c as J,A as _}from"./agents-D9dWnZr0.js";import{U as ke}from"./UnifiedToolSelector-Bw-E7HW4.js";import{u as V}from"./tools-zTM46-tZ.js";import{r as we,e as je,aJ as ve,X as Q,v as ae,g as Ne,E as Se,f as Te,J as Ce,y as Fe}from"./ui-components-BsYwJvCF.js";import{B as z}from"./Button-CfU7z0eT.js";import{F as $e}from"./FileExplorer-BB3suHzW.js";import{T as Ee}from"./ToolsList-C9LELdNX.js";import"./syntax-highlighting-CnREyncB.js";import"./index-BLjehayc.js";class De{baseURL=`${ye()}/skills`;async getAllSkills(r){const s=new URLSearchParams;r?.scope&&s.append("scope",r.scope),r?.includeDisabled&&s.append("includeDisabled","true");const l=await f(`${this.baseURL}?${s.toString()}`);if(!l.ok)throw new Error(`Failed to fetch skills: ${l.statusText}`);const o=await l.json();return this.transformToSkillListItems(o.skills)}async getSkill(r,s){const l=s?`?scope=${s}`:"",o=await f(`${this.baseURL}/${r}${l}`);if(o.status===404)return null;if(!o.ok)throw new Error(`Failed to fetch skill: ${o.statusText}`);return(await o.json()).skill}async createSkill(r){const s=await f(`${this.baseURL}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok){const o=await s.json();throw new Error(o.error||"Failed to create skill")}return(await s.json()).skill}async updateSkill(r,s){const l=await f(`${this.baseURL}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok){const x=await l.json();throw new Error(x.error||"Failed to update skill")}return(await l.json()).skill}async deleteSkill(r,s){const l=s?`?scope=${s}`:"",o=await f(`${this.baseURL}/${r}${l}`,{method:"DELETE"});if(o.status===404)return!1;if(!o.ok)throw new Error(`Failed to delete skill: ${o.statusText}`);return!0}async getSkillDirectoryInfo(r){const s=await f(`${this.baseURL}/${r}/directory`);if(s.status===404)return null;if(!s.ok)throw new Error(`Failed to fetch skill directory info: ${s.statusText}`);return(await s.json()).directoryInfo}async validateSkillManifest(r){const s=await f(`${this.baseURL}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})});if(!s.ok)throw new Error(`Failed to validate skill manifest: ${s.statusText}`);return await s.json()}async getSkillFile(r,s){const l=await f(`${this.baseURL}/${r}/files/${s}`);if(!l.ok)throw new Error(`Failed to fetch skill file: ${l.statusText}`);return(await l.json()).content}async updateSkillFile(r,s,l){const o=await f(`${this.baseURL}/${r}/files/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l})});if(!o.ok)throw new Error(`Failed to update skill file: ${o.statusText}`)}transformToSkillListItems(r){return r.map(s=>({id:s.id,name:s.name,description:s.description,scope:s.scope,projectName:s.scope==="project"?"Current Project":void 0,source:s.source,enabled:s.enabled,createdAt:s.createdAt,updatedAt:s.updatedAt,allowedTools:s.allowedTools,toolCount:s.allowedTools?.length||0,usageCount:0,lastUsed:void 0}))}}const A=new De,y={all:["skills"],lists:()=>[...y.all,"list"],list:a=>[...y.lists(),a],details:()=>[...y.all,"detail"],detail:a=>[...y.details(),a],directory:a=>[...y.all,"directory",a]},Le=a=>te({queryKey:y.list(a||{}),queryFn:()=>A.getAllSkills(a),staleTime:300*1e3}),Me=(a,r)=>te({queryKey:y.detail(a),queryFn:()=>A.getSkill(a,r),enabled:!!a,staleTime:300*1e3}),Pe=()=>{const a=X();return J({mutationFn:r=>A.createSkill(r),onSuccess:r=>{a.invalidateQueries({queryKey:y.lists()}),a.setQueryData(y.detail(r.id),r)},onError:r=>{console.error("Failed to create skill:",r)}})},Ae=()=>{const a=X();return J({mutationFn:({skillId:r,updates:s})=>A.updateSkill(r,s),onSuccess:r=>{a.setQueryData(y.detail(r.id),r),a.invalidateQueries({queryKey:y.lists()})},onError:r=>{console.error("Failed to update skill:",r)}})},Ie=()=>{const a=X();return J({mutationFn:({skillId:r,scope:s})=>A.deleteSkill(r,s),onSuccess:(r,{skillId:s})=>{a.removeQueries({queryKey:y.detail(s)}),a.invalidateQueries({queryKey:y.lists()})},onError:r=>{console.error("Failed to delete skill:",r)}})},Re=()=>J({mutationFn:a=>A.validateSkillManifest(a),onError:a=>{console.error("Failed to validate skill manifest:",a)}}),Ue=({onClose:a,onSuccess:r,editSkill:s})=>{const{t:l}=V(["skills","common"]),o=!!s,[x,g]=c.useState("basic"),[n,h]=c.useState({name:"",description:"",allowedTools:[],content:"",additionalFiles:[]}),[m,j]=c.useState([]),[k,F]=c.useState(""),[$,M]=c.useState(!1),[S,E]=c.useState([]),[p,v]=c.useState([]),[T,I]=c.useState(!1),P=Pe(),R=Ae(),U=Re(),B=Me(s?.id||"",s?.scope||"user"),C=o?B.data:null,K=o?B.isLoading:!1,[d,N]=c.useState(0),[H,D]=c.useState(0),[L,Y]=c.useState(!1);c.useEffect(()=>{if(!L){const t=[...S];T&&t.push(...p),h(i=>({...i,allowedTools:t})),N(Date.now())}},[S,p,T,L]),c.useEffect(()=>{!L&&(n.name||n.description)&&N(Date.now())},[n.name,n.description,L]),c.useEffect(()=>{!L&&n.content&&D(Date.now())},[n.content,L]),c.useEffect(()=>{if(o&&C){h({name:C.name,description:C.description,allowedTools:C.allowedTools||[],content:"",additionalFiles:(C.files||[]).filter(u=>!u.path.endsWith("SKILL.md")).map(u=>({id:Math.random().toString(36).substr(2,9),name:u.name,path:u.path,type:u.type,content:""}))});const t=C.allowedTools||[],i=t.filter(u=>!u.startsWith("mcp__")),b=t.filter(u=>u.startsWith("mcp__"));E(i),v(b),I(b.length>0),(async()=>{try{const u=await fetch(`/api/skills/${s.id}/files/SKILL.md`);if(u.ok){const he=await u.json();h(ge=>({...ge,content:he.content})),D(Date.now())}}catch(u){console.error("Failed to load skill manifest:",u)}})()}},[o,C,s]),c.useEffect(()=>{if(n.content){const i=setTimeout(async()=>{try{const b=await U.mutateAsync(n.content);j(b.errors.map(w=>w.message)||[])}catch{j(["Validation failed"])}},500);return()=>clearTimeout(i)}},[n.content,U]);const se=async()=>{try{if(o){const t={name:n.name,description:n.description,allowedTools:n.allowedTools,content:n.content,additionalFiles:n.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await R.mutateAsync({skillId:s.id,updates:t})}else{const t={name:n.name,description:n.description,scope:"user",allowedTools:n.allowedTools,content:n.content,additionalFiles:n.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await P.mutateAsync(t)}r()}catch(t){console.error(o?"Failed to update skill:":"Failed to create skill:",t),alert(l(o?"errors.updateFailed":"errors.createFailed"))}},re=()=>{const t={id:Math.random().toString(36).substr(2,9),name:"New File",path:"new-file.md",type:"markdown",content:""};h(i=>({...i,additionalFiles:[...i.additionalFiles,t]}))},le=t=>{h(i=>({...i,additionalFiles:i.additionalFiles.filter(b=>b.id!==t)}))},W=(t,i)=>{h(b=>({...b,additionalFiles:b.additionalFiles.map(w=>w.id===t?{...w,...i}:w)}))},ne=n.name.trim()!==""&&!k&&n.description.trim()!==""&&n.content.trim()!==""&&m.length===0,oe=()=>{switch(x){case"basic":return n.name.trim()!==""&&!k&&n.description.trim()!=="";case"manifest":return n.content.trim()!==""&&m.length===0;case"files":return!0;default:return!1}},G=()=>{if(!L){if(Y(!0),d>H){if(n.name&&n.description){const t=ee(n.name,n.description,n.allowedTools);h(i=>({...i,content:t})),D(Date.now())}}else if(H>d){const t=Be(n.content);if(t&&(t.name&&t.name!==n.name||t.description&&t.description!==n.description||t.allowedTools&&JSON.stringify(t.allowedTools)!==JSON.stringify(n.allowedTools))){h(u=>({...u,name:t.name||u.name,description:t.description||u.description,allowedTools:t.allowedTools||u.allowedTools}));const b=(t.allowedTools||[]).filter(u=>!u.startsWith("mcp__")),w=(t.allowedTools||[]).filter(u=>u.startsWith("mcp__"));E(b),v(w),I(w.length>0),N(Date.now())}}else if(!n.content&&n.name&&n.description){const t=ee(n.name,n.description,n.allowedTools);h(i=>({...i,content:t})),D(Date.now())}setTimeout(()=>Y(!1),100)}},ie=()=>{G(),x==="basic"?g("manifest"):x==="manifest"&&g("files")},de=t=>{G(),g(t)},ce=[{id:"basic",label:l("create.tabs.basic"),icon:we},{id:"manifest",label:l("create.tabs.manifest"),icon:je},{id:"files",label:l("create.tabs.files"),icon:ve}],xe=t=>t?t.length>64?"技能名称不能超过64个字符":/^[a-z0-9-]+$/.test(t)?t.startsWith("-")||t.endsWith("-")?"不能以连字符开始或结束":t.includes("--")?"不能包含连续的连字符":"":"只能使用小写字母、数字和连字符":"",ue=t=>{h(i=>({...i,name:t})),F(xe(t))},me=t=>{t.key==="Escape"&&a()};return o&&K?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white rounded-lg p-6 w-full max-w-md",children:e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})})})}):e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onKeyDown:me,children:[e.jsxs("div",{className:"bg-white rounded-lg w-full max-w-3xl max-h-[90vh] overflow-hidden flex flex-col dark:bg-gray-800 dark:text-white",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:o?`编辑技能 - ${s?.name}`:l("create.title")}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 dark:text-gray-300",children:o?"修改现有技能的配置和功能":l("create.subtitle")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[x!=="files"?e.jsx("button",{onClick:ie,disabled:!oe(),className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors dark:bg-blue-500 dark:hover:bg-blue-600",children:l("common:actions.next")}):e.jsx("button",{onClick:se,disabled:!ne||P.isPending||R.isPending,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors dark:bg-blue-500 dark:hover:bg-blue-600",children:P.isPending||R.isPending?l("common:status.saving"):l(o?"common:actions.save":"common:actions.create")}),e.jsx("button",{onClick:a,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700",children:e.jsx(Q,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:ce.map(t=>{const i=t.icon,b=x===t.id,w=t.id==="basic"&&n.name.trim()!==""&&n.description.trim()!==""||t.id==="manifest"&&n.content.trim()!==""&&m.length===0||t.id==="files";return e.jsxs("button",{onClick:()=>de(t.id),className:`flex items-center gap-2 px-6 py-3 font-medium text-sm transition-colors ${b?"text-blue-600 border-b-2 border-blue-600 dark:text-blue-400 dark:border-blue-400":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"}`,children:[e.jsx(i,{className:"w-4 h-4"}),t.label,w&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"})]},t.id)})}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x==="basic"&&e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:"技能名称 (Slug)"}),e.jsx("input",{type:"text",value:n.name,onChange:t=>ue(t.target.value),disabled:o,className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400 font-mono ${o?"bg-gray-100 text-gray-500 cursor-not-allowed dark:bg-gray-600 dark:text-gray-400":k?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300"}`,placeholder:"my-awesome-skill"}),k?e.jsx("p",{className:"text-xs text-red-500 mt-1 dark:text-red-400",children:k}):e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:o?"技能名称在编辑模式下不能修改":"只能使用小写字母、数字和连字符,最多64个字符"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.basic.description")}),e.jsx("textarea",{value:n.description,onChange:t=>{h(i=>({...i,description:t.target.value}))},rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.basic.descriptionPlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:l("create.basic.descriptionHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.basic.allowedTools")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{type:"button",onClick:()=>M(!$),className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg transition-colors text-sm",children:l("create.basic.selectTools")}),(S.length>0||p.length>0)&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["常规工具 ",S.length," 个",p.length>0&&`, MCP工具 ${p.length} 个`]})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:l("create.basic.allowedToolsHint")})]})]}),x==="manifest"&&e.jsx("div",{className:"space-y-6 max-w-2xl",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.content.skillManifest")}),e.jsx("textarea",{value:n.content,onChange:t=>h(i=>({...i,content:t.target.value})),rows:15,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400"}),m.length>0&&e.jsxs("div",{className:"mt-2 p-3 bg-red-50 border border-red-200 rounded-lg dark:bg-red-900/20 dark:border-red-800",children:[e.jsxs("h4",{className:"text-sm font-medium text-red-800 mb-1 dark:text-red-400",children:[l("editor.errors.validationErrors"),":"]}),e.jsx("ul",{className:"text-sm text-red-700 space-y-1 dark:text-red-300",children:m.map((t,i)=>e.jsxs("li",{children:["• ",t]},i))})]})]})}),x==="files"&&e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:l("create.content.additionalFiles")}),e.jsxs("button",{onClick:re,className:"flex items-center gap-2 px-3 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors dark:bg-green-500 dark:hover:bg-green-600",children:[e.jsx(ae,{className:"w-4 h-4"}),l("create.content.addFile")]})]}),n.additionalFiles.length===0?e.jsxs("div",{className:"text-center py-8 border-2 border-dashed border-gray-300 rounded-lg",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:l("create.content.noFiles")}),e.jsx("p",{className:"text-sm text-gray-500 mt-1 dark:text-gray-400",children:l("create.content.noFilesHint")})]}):e.jsx("div",{className:"space-y-4",children:n.additionalFiles.map(t=>e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("input",{type:"text",value:t.name,onChange:i=>W(t.id,{name:i.target.value}),className:"flex-1 px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.fileName")}),e.jsx("input",{type:"text",value:t.path,onChange:i=>W(t.id,{path:i.target.value}),className:"flex-1 px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.filePath")}),e.jsxs("select",{value:t.type,onChange:i=>W(t.id,{type:i.target.value}),className:"px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",children:[e.jsx("option",{value:"markdown",children:l("create.content.fileType.markdown")}),e.jsx("option",{value:"text",children:l("create.content.fileType.text")}),e.jsx("option",{value:"script",children:l("create.content.fileType.script")}),e.jsx("option",{value:"template",children:l("create.content.fileType.template")}),e.jsx("option",{value:"other",children:l("create.content.fileType.other")})]})]}),e.jsx("button",{onClick:()=>le(t.id),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded transition-colors dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20",children:e.jsx(Q,{className:"w-4 h-4"})})]}),e.jsx("textarea",{value:t.content,onChange:i=>W(t.id,{content:i.target.value}),rows:6,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.fileContent")})]},t.id))})]})]})]}),e.jsx(ke,{isOpen:$,onClose:()=>M(!1),selectedRegularTools:S,onRegularToolsChange:E,selectedMcpTools:p,onMcpToolsChange:v,mcpToolsEnabled:T,onMcpEnabledChange:I})]})};function Be(a){try{const r=a.match(/^---\s*\n(.*?)\n---/s);if(!r)return null;const l=r[1].split(`
|
|
2
2
|
`),o={};for(const x of l){const g=x.trim();if(g.startsWith("name:"))o.name=g.replace("name:","").trim();else if(g.startsWith("description:"))o.description=g.replace("description:","").trim();else if(g.startsWith("allowed-tools:")){const n=g.replace("allowed-tools:","").trim();if(n.startsWith("[")&&n.endsWith("]")){const h=n.slice(1,-1).split(",").map(m=>m.trim().replace(/^"(.*)"$/,"$1")).filter(m=>m.length>0);o.allowedTools=h}}}return o}catch(r){return console.error("Failed to parse skill content:",r),null}}function ee(a,r,s){const l=s.length>0?`
|
|
3
3
|
allowed-tools: [${s.map(x=>`"${x}"`).join(", ")}]`:"",o=a.split("-").map(x=>x.charAt(0).toUpperCase()+x.slice(1)).join(" ");return`---
|
|
4
4
|
name: ${a}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i}from"./monaco-editor-DHKm5-VF.js";import{T as D,a as B,b as f,c as o,d as R,e as m}from"./table-D-FJ6K6j.js";import{u as H,a as L,S as q}from"./SubagentForm-Cq06CQqr.js";import{f as N}from"./dateFormat-CXa8VnEC.js";import{b as z}from"./index-BFYHztzB.js";import{T as k}from"./ToolsList-C9LELdNX.js";import{u as J}from"./tools-zTM46-tZ.js";import{j as G,g as I,v as K,a5 as v,E as w,J as $,y as h}from"./ui-components-BsYwJvCF.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-D9dWnZr0.js";import"./UnifiedToolSelector-Bw-E7HW4.js";const re=()=>{const{t:s}=J("pages"),{isMobile:t}=z(),[a,S]=i.useState(""),[C,n]=i.useState(!1),[T,d]=i.useState(null),[g,c]=i.useState(null),[p,y]=i.useState({}),{data:b=[],isLoading:F,error:E,refetch:j}=H({search:a.trim()||void 0}),u=L(),M=async r=>{try{await u.mutateAsync(r.id),c(null)}catch(l){console.error("Failed to delete subagent:",l)}},x=r=>{d(r),n(!0)},A=()=>{n(!1),d(null)},P=()=>{j()};return F?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:`animate-spin rounded-full ${t?"h-8 w-8":"h-12 w-12"} border-b-2 border-blue-600 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("div",{className:`text-gray-600 dark:text-gray-400 ${t?"text-sm":""}`,children:s("settings.subagents.loading")})]})}):E?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(G,{className:`${t?"h-8 w-8":"h-12 w-12"} text-red-500 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white mb-2`,children:s("settings.subagents.loadFailed")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mb-4 text-sm":"mb-4"}`,children:s("settings.subagents.loadFailedMessage")}),e.jsx("button",{onClick:()=>j(),className:`${t?"px-4 py-2.5 text-sm":"px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:t?"mb-4":"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:`${t?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("settings.subagents.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mt-1":"mt-2"}`,children:s("settings.subagents.subtitle")})]})}),e.jsxs("div",{className:t?"space-y-3":"flex items-center space-x-4",children:[e.jsxs("div",{className:`${t?"":"flex-1"} relative`,children:[e.jsx(I,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${t?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:s("settings.subagents.searchPlaceholder"),value:a,onChange:r=>S(r.target.value),className:`pl-10 pr-4 ${t?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${t?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-2.5 px-4 flex items-center justify-center space-x-2":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${t?"text-sm":"whitespace-nowrap"}`,children:[e.jsx(K,{className:t?"w-4 h-4":"w-5 h-5"}),e.jsx("span",{children:s("settings.subagents.createButton")})]})]})]}),b.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:`${t?"text-4xl":"text-6xl"} mb-4`,children:"🤖"}),e.jsx("h3",{className:`${t?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:s(a?"settings.subagents.noSubagentsSearch":"settings.subagents.noSubagents")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:s(a?"settings.subagents.adjustSearch":"settings.subagents.createFirst")}),!a&&e.jsx("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.createButton")})]}):e.jsx(e.Fragment,{children:t?e.jsx("div",{className:"space-y-4",children:b.map((r,l)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`${t?"text-lg":"text-xl"} mr-3`,children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`${t?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[s("settings.subagents.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!0,emptyMessage:s("settings.subagents.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[s("settings.subagents.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(v,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:N(r.createdAt)})]})]})]}),e.jsx("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})]},r.id+"-"+l))}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(D,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.subagent")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.tools")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.createdAt")}),e.jsx(o,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.actions")})]})}),e.jsx(R,{children:b.map((r,l)=>e.jsxs(f,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(m,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs",children:r.description})]})]})}),e.jsx(m,{className:"px-6 py-4",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!1,emptyMessage:s("settings.subagents.table.inheritSettings")})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(v,{className:"w-4 h-4"}),e.jsx("span",{children:N(r.createdAt)})]})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.viewTitle"),children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.editTitle"),children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})})]},r.id+"-"+l))})]})})}),C&&e.jsx(q,{subagent:T,onClose:A,onSuccess:P}),g&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl ${t?"w-full max-w-sm":"max-w-md w-full"}`,children:[e.jsx("div",{className:`${t?"px-4 py-3":"px-6 py-4"} border-b border-gray-200 dark:border-gray-700`,children:e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white`,children:s("settings.subagents.deleteConfirm.title")})}),e.jsxs("div",{className:`${t?"px-4 py-3":"px-6 py-4"}`,children:[e.jsx("p",{className:`${t?"text-sm":""} text-gray-600 dark:text-gray-400`,children:s("settings.subagents.deleteConfirm.message",{name:g.name})}),e.jsx("p",{className:`text-gray-500 dark:text-gray-400 ${t?"mt-1 text-xs":"mt-2"}`,children:s("settings.subagents.deleteConfirm.warning")})]}),e.jsxs("div",{className:`${t?"grid grid-cols-2 gap-2 px-4 py-3":"flex items-center justify-end space-x-3 px-6 py-4"} border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-700/50`,children:[e.jsx("button",{onClick:()=>c(null),className:`${t?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors`,children:s("settings.subagents.deleteConfirm.cancel")}),e.jsxs("button",{onClick:()=>M(g),disabled:u.isPending,className:`${t?"flex items-center justify-center space-x-1 px-3 py-2.5 text-sm":"flex items-center space-x-2 px-4 py-2"} bg-red-600 hover:bg-red-700 disabled:bg-red-400 text-white rounded-lg transition-colors`,children:[u.isPending?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}):e.jsx(h,{className:`${t?"h-3 w-3":"h-4 w-4"}`}),e.jsx("span",{children:s("settings.subagents.deleteConfirm.delete")})]})]})]})})]})};export{re as SubagentsPage};
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i}from"./monaco-editor-DHKm5-VF.js";import{T as D,a as B,b as f,c as o,d as R,e as m}from"./table-Br8ioTXr.js";import{u as H,a as L,S as q}from"./SubagentForm-Cq06CQqr.js";import{f as N}from"./dateFormat-CXa8VnEC.js";import{b as z}from"./index-BLjehayc.js";import{T as k}from"./ToolsList-C9LELdNX.js";import{u as J}from"./tools-zTM46-tZ.js";import{j as G,g as I,v as K,a5 as v,E as w,J as $,y as h}from"./ui-components-BsYwJvCF.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-D9dWnZr0.js";import"./UnifiedToolSelector-Bw-E7HW4.js";const re=()=>{const{t:s}=J("pages"),{isMobile:t}=z(),[a,S]=i.useState(""),[C,n]=i.useState(!1),[T,d]=i.useState(null),[g,c]=i.useState(null),[p,y]=i.useState({}),{data:b=[],isLoading:F,error:E,refetch:j}=H({search:a.trim()||void 0}),u=L(),M=async r=>{try{await u.mutateAsync(r.id),c(null)}catch(l){console.error("Failed to delete subagent:",l)}},x=r=>{d(r),n(!0)},A=()=>{n(!1),d(null)},P=()=>{j()};return F?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:`animate-spin rounded-full ${t?"h-8 w-8":"h-12 w-12"} border-b-2 border-blue-600 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("div",{className:`text-gray-600 dark:text-gray-400 ${t?"text-sm":""}`,children:s("settings.subagents.loading")})]})}):E?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(G,{className:`${t?"h-8 w-8":"h-12 w-12"} text-red-500 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white mb-2`,children:s("settings.subagents.loadFailed")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mb-4 text-sm":"mb-4"}`,children:s("settings.subagents.loadFailedMessage")}),e.jsx("button",{onClick:()=>j(),className:`${t?"px-4 py-2.5 text-sm":"px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:t?"mb-4":"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:`${t?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("settings.subagents.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mt-1":"mt-2"}`,children:s("settings.subagents.subtitle")})]})}),e.jsxs("div",{className:t?"space-y-3":"flex items-center space-x-4",children:[e.jsxs("div",{className:`${t?"":"flex-1"} relative`,children:[e.jsx(I,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${t?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:s("settings.subagents.searchPlaceholder"),value:a,onChange:r=>S(r.target.value),className:`pl-10 pr-4 ${t?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${t?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-2.5 px-4 flex items-center justify-center space-x-2":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${t?"text-sm":"whitespace-nowrap"}`,children:[e.jsx(K,{className:t?"w-4 h-4":"w-5 h-5"}),e.jsx("span",{children:s("settings.subagents.createButton")})]})]})]}),b.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:`${t?"text-4xl":"text-6xl"} mb-4`,children:"🤖"}),e.jsx("h3",{className:`${t?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:s(a?"settings.subagents.noSubagentsSearch":"settings.subagents.noSubagents")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:s(a?"settings.subagents.adjustSearch":"settings.subagents.createFirst")}),!a&&e.jsx("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.createButton")})]}):e.jsx(e.Fragment,{children:t?e.jsx("div",{className:"space-y-4",children:b.map((r,l)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`${t?"text-lg":"text-xl"} mr-3`,children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`${t?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[s("settings.subagents.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!0,emptyMessage:s("settings.subagents.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[s("settings.subagents.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(v,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:N(r.createdAt)})]})]})]}),e.jsx("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})]},r.id+"-"+l))}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(D,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.subagent")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.tools")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.createdAt")}),e.jsx(o,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.actions")})]})}),e.jsx(R,{children:b.map((r,l)=>e.jsxs(f,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(m,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs",children:r.description})]})]})}),e.jsx(m,{className:"px-6 py-4",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!1,emptyMessage:s("settings.subagents.table.inheritSettings")})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(v,{className:"w-4 h-4"}),e.jsx("span",{children:N(r.createdAt)})]})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.viewTitle"),children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.editTitle"),children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})})]},r.id+"-"+l))})]})})}),C&&e.jsx(q,{subagent:T,onClose:A,onSuccess:P}),g&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl ${t?"w-full max-w-sm":"max-w-md w-full"}`,children:[e.jsx("div",{className:`${t?"px-4 py-3":"px-6 py-4"} border-b border-gray-200 dark:border-gray-700`,children:e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white`,children:s("settings.subagents.deleteConfirm.title")})}),e.jsxs("div",{className:`${t?"px-4 py-3":"px-6 py-4"}`,children:[e.jsx("p",{className:`${t?"text-sm":""} text-gray-600 dark:text-gray-400`,children:s("settings.subagents.deleteConfirm.message",{name:g.name})}),e.jsx("p",{className:`text-gray-500 dark:text-gray-400 ${t?"mt-1 text-xs":"mt-2"}`,children:s("settings.subagents.deleteConfirm.warning")})]}),e.jsxs("div",{className:`${t?"grid grid-cols-2 gap-2 px-4 py-3":"flex items-center justify-end space-x-3 px-6 py-4"} border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-700/50`,children:[e.jsx("button",{onClick:()=>c(null),className:`${t?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors`,children:s("settings.subagents.deleteConfirm.cancel")}),e.jsxs("button",{onClick:()=>M(g),disabled:u.isPending,className:`${t?"flex items-center justify-center space-x-1 px-3 py-2.5 text-sm":"flex items-center space-x-2 px-4 py-2"} bg-red-600 hover:bg-red-700 disabled:bg-red-400 text-white rounded-lg transition-colors`,children:[u.isPending?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}):e.jsx(h,{className:`${t?"h-3 w-3":"h-4 w-4"}`}),e.jsx("span",{children:s("settings.subagents.deleteConfirm.delete")})]})]})]})})]})};export{re as SubagentsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{d as h,e as y}from"./index-
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{d as h,e as y}from"./index-BLjehayc.js";import{u as b}from"./tools-zTM46-tZ.js";import{R as p,U as j,K as u,M as r,V as l,Y as f,_ as k,$ as N,e as v}from"./ui-components-BsYwJvCF.js";import"./monaco-editor-DHKm5-VF.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-D9dWnZr0.js";const A=()=>{const{t:s}=b("pages"),{currentVersion:d,latestVersion:a,hasUpdate:n,forceCheck:o,isChecking:i,dismissUpdate:m,showUpdateNotification:x}=h(),{systemInfo:t,refetch:c}=y(),g=()=>{o(),c()};return e.jsxs("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center",children:[e.jsx(p,{className:"w-6 h-6 mr-2"}),s("settings.systemInfo.title")]}),e.jsx("p",{className:"mt-1 text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.subtitle")})]}),e.jsxs("button",{onClick:g,disabled:i,className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(j,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),s("settings.systemInfo.checkUpdate")]})]}),x&&a&&e.jsx("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-900/30 dark:to-indigo-900/30 border border-blue-200 dark:border-blue-800 rounded-xl p-6",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-start space-x-4",children:[e.jsx("div",{className:"p-3 bg-blue-100 dark:bg-blue-800 rounded-full",children:e.jsx(u,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-blue-900 dark:text-blue-100",children:s("settings.systemInfo.updateAvailable")}),e.jsx("p",{className:"mt-1 text-blue-700 dark:text-blue-300",children:s("version.newVersionAvailable",{version:a})}),e.jsxs("div",{className:"mt-4 flex space-x-3",children:[e.jsxs("a",{href:"https://github.com/okguitar/agentstudio/releases",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(r,{className:"w-4 h-4 mr-2"}),s("settings.systemInfo.viewReleases")]}),e.jsx("button",{onClick:m,className:"inline-flex items-center px-4 py-2 text-blue-700 dark:text-blue-300 bg-blue-100 dark:bg-blue-800 hover:bg-blue-200 dark:hover:bg-blue-700 rounded-lg transition-colors",children:s("version.dismiss")})]})]})]})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(l,{className:"w-5 h-5 mr-2"}),s("settings.systemInfo.versionInfo")]})}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.appName")}),e.jsx("p",{className:"mt-1 text-lg font-semibold text-gray-900 dark:text-white",children:t?.app.name||"AgentStudio"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.currentVersion")}),e.jsxs("div",{className:"mt-1 flex items-center",children:[e.jsxs("span",{className:"text-lg font-mono text-gray-900 dark:text-white",children:["v",d||t?.app.version||"-"]}),!n&&e.jsxs("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:[e.jsx(f,{className:"w-3 h-3 mr-1"}),s("settings.systemInfo.upToDate")]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.latestVersion")}),e.jsx("p",{className:"mt-1 text-lg font-mono text-gray-900 dark:text-white",children:a?`v${a}`:"-"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:["Node.js ",s("settings.systemInfo.version")]}),e.jsx("p",{className:"mt-1 font-mono text-gray-900 dark:text-white",children:t?.runtime.nodeVersion||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.platform")}),e.jsxs("p",{className:"mt-1 text-gray-900 dark:text-white capitalize",children:[t?.runtime.platform||"-"," (",t?.runtime.arch||"-",")"]})]})]})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(k,{className:"w-5 h-5 mr-2"}),s("settings.systemInfo.runtimeInfo")]})}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Node.js"}),e.jsx("p",{className:"mt-1 font-mono text-gray-900 dark:text-white",children:t?.runtime.nodeVersion||"-"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.platform")}),e.jsx("p",{className:"mt-1 text-gray-900 dark:text-white capitalize",children:t?.runtime.platform||"-"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.architecture")}),e.jsx("p",{className:"mt-1 text-gray-900 dark:text-white",children:t?.runtime.arch||"-"})]})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(r,{className:"w-5 h-5 mr-2"}),s("settings.systemInfo.links")]})}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("a",{href:t?.links.github||"https://github.com/okguitar/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(N,{className:"w-6 h-6 text-gray-700 dark:text-gray-300 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"GitHub"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewSource")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]}),e.jsxs("a",{href:t?.links.releases||"https://github.com/okguitar/agentstudio/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(l,{className:"w-6 h-6 text-gray-700 dark:text-gray-300 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"Releases"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewReleases")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]}),e.jsxs("a",{href:t?.links.changelog||"https://github.com/okguitar/agentstudio/blob/main/CHANGELOG.md",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(v,{className:"w-6 h-6 text-gray-700 dark:text-gray-300 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"Changelog"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewChangelog")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]}),e.jsxs("a",{href:t?.links.npm||"https://www.npmjs.com/package/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(l,{className:"w-6 h-6 text-red-600 dark:text-red-400 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"npm"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewNpm")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]})]})})]})]})};export{A as SystemInfoPage};
|
package/public/assets/{TelemetrySettingsPage-BLnMagRZ.js → TelemetrySettingsPage-recK8TS7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{W as i}from"./monaco-editor-DHKm5-VF.js";import{i as d,f as c}from"./index-
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{W as i}from"./monaco-editor-DHKm5-VF.js";import{i as d,f as c}from"./index-BLjehayc.js";import{u as m}from"./tools-zTM46-tZ.js";import{a0 as o,a1 as a,a2 as x,j as g}from"./ui-components-BsYwJvCF.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-D9dWnZr0.js";const f=()=>{const{t:s}=m("pages"),[t,l]=i.useState(d()),n=()=>{const r=!t;c(r),l(r)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:s("settings.telemetry.title","Telemetry & Analytics")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s("settings.telemetry.description","Manage anonymous usage data collection")})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`p-3 rounded-xl ${t?"bg-blue-100 dark:bg-blue-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:e.jsx(o,{className:`w-6 h-6 ${t?"text-blue-600 dark:text-blue-400":"text-gray-500"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white",children:s("settings.telemetry.enableTelemetry","Enable Anonymous Telemetry")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:s("settings.telemetry.enableDescription","Help improve AgentStudio by sharing anonymous usage data")})]})]}),e.jsx("button",{onClick:n,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${t?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t?"translate-x-6":"translate-x-1"}`})})]})}),e.jsx("div",{className:`px-6 py-3 border-t ${t?"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800":"bg-gray-50 dark:bg-gray-700/50 border-gray-200 dark:border-gray-700"}`,children:e.jsx("div",{className:"flex items-center gap-2 text-sm",children:t?e.jsxs(e.Fragment,{children:[e.jsx(a,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-green-700 dark:text-green-400",children:s("settings.telemetry.statusEnabled","Telemetry is enabled. Thank you for helping improve AgentStudio!")})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("settings.telemetry.statusDisabled","Telemetry is disabled. No data is being collected.")})]})})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2",children:[e.jsx(a,{className:"w-5 h-5 text-green-500"}),s("settings.telemetry.whatWeCollect","What We Collect")]}),e.jsxs("ul",{className:"space-y-3 text-sm text-gray-600 dark:text-gray-300",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.installId","Anonymous Installation ID")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.installIdDesc","A random UUID to distinguish installations, not linked to your identity")})]})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.version","App Version & OS")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.versionDesc","Helps us understand which versions and platforms are most used")})]})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.features","Feature Usage")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.featuresDesc","Which features are used (without content or personal data)")})]})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.errors","Error Reports")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.errorsDesc","Sanitized error messages and stack traces (file paths removed)")})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2",children:[e.jsx(g,{className:"w-5 h-5 text-red-500"}),s("settings.telemetry.whatWeNeverCollect","What We Never Collect")]}),e.jsxs("ul",{className:"space-y-3 text-sm text-gray-600 dark:text-gray-300",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.files","File contents, code, or project data")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.keys","API keys, passwords, or credentials")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.pii","Personal identifying information (name, email, IP)")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.conversations","Chat conversations or AI responses")})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-xl border border-blue-200 dark:border-blue-800 p-4",children:e.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsxs("strong",{children:[s("settings.telemetry.privacyNote","Privacy First"),":"]})," ",s("settings.telemetry.privacyNoteDesc","All telemetry data is anonymized and aggregated. We cannot identify individual users. You can disable telemetry at any time.")]})})]})};export{f as TelemetrySettingsPage,f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./data-structures-C0h9Oap1.js";import{s as e,a as o,c as r}from"./index-
|
|
1
|
+
import{j as s}from"./data-structures-C0h9Oap1.js";import{s as e,a as o,c as r}from"./index-BLjehayc.js";import"./monaco-editor-DHKm5-VF.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-D9dWnZr0.js";import"./tools-zTM46-tZ.js";import"./ui-components-BsYwJvCF.js";const l=()=>s.jsxs("div",{className:"p-8 space-y-4",children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Toast Test Page"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("button",{onClick:()=>e("Success!","This is a success message"),className:"px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700",children:"Show Success Toast"}),s.jsx("button",{onClick:()=>o("Error!","This is an error message"),className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 ml-4",children:"Show Error Toast"}),s.jsx("button",{onClick:()=>r("Info","This is an info message"),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 ml-4",children:"Show Info Toast"})]})]});export{l as ToastTestPage};
|