agent-tower 0.3.0 → 0.3.2
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/dist/executors/__tests__/providers.test.js +33 -1
- package/dist/executors/__tests__/providers.test.js.map +1 -1
- package/dist/executors/index.d.ts +1 -1
- package/dist/executors/index.d.ts.map +1 -1
- package/dist/executors/index.js +1 -1
- package/dist/executors/index.js.map +1 -1
- package/dist/executors/providers.d.ts +1 -0
- package/dist/executors/providers.d.ts.map +1 -1
- package/dist/executors/providers.js +24 -3
- package/dist/executors/providers.js.map +1 -1
- package/dist/output/__tests__/claude-code-parser-token.test.js +44 -0
- package/dist/output/__tests__/claude-code-parser-token.test.js.map +1 -1
- package/dist/output/claude-code-parser.d.ts.map +1 -1
- package/dist/output/claude-code-parser.js +17 -2
- package/dist/output/claude-code-parser.js.map +1 -1
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +12 -3
- package/dist/routes/providers.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-BvaDaGTb.js → AgentDemoPage-aTNAVrNM.js} +1 -1
- package/dist/web/assets/{DemoPage-B7lfVxNj.js → DemoPage-B2EpMwHI.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-CUl8SV4s.js → NotificationSettingsPage-BHTMX9Zx.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-hPvylvwn.js → ProfileSettingsPage-DfSPgM-N.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-C2UFFwX_.js → ProjectKanbanPage-BiKbdIkU.js} +25 -25
- package/dist/web/assets/{ProjectSettingsPage-3_0cjA46.js → ProjectSettingsPage-BUzGVnh0.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-CzfHzUkE.js → ProviderSettingsPage-D3eFdZQ9.js} +15 -15
- package/dist/web/assets/{api-client-DQBFRKXh.js → api-client-Baduc3al.js} +1 -1
- package/dist/web/assets/{chevron-down-BxmO9AqF.js → chevron-down-CkF16nsG.js} +1 -1
- package/dist/web/assets/{circle-alert-CNojp6BL.js → circle-alert-eWOkoJBg.js} +1 -1
- package/dist/web/assets/{circle-check-PLh029g-.js → circle-check-Ch_L_rkj.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-DeKZRMJF.js → code-block-OCS4YCEC-CVUAVF-O.js} +1 -1
- package/dist/web/assets/confirm-dialog-DDn0KeEd.js +1 -0
- package/dist/web/assets/{folder-picker-DG3yX995.js → folder-picker-D3VeGx3H.js} +1 -1
- package/dist/web/assets/{index-BjoprLxq.js → index-C5ZLITAJ.js} +2 -2
- package/dist/web/assets/{loader-circle-BtsxMnMy.js → loader-circle-C4OXeViX.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-DGTR51GL.js → mermaid-NOHMQCX5-CTtvbRFz.js} +3 -3
- package/dist/web/assets/{modal-Cw8yKTAW.js → modal-BnLru52Y.js} +1 -1
- package/dist/web/assets/{pencil-ChfcWQRp.js → pencil-Dbg3HneB.js} +1 -1
- package/dist/web/assets/{query-keys-wUxyRw3p.js → query-keys-6MuNX7mv.js} +1 -1
- package/dist/web/assets/{select-CUxnXhcD.js → select-z5SlTxI3.js} +1 -1
- package/dist/web/assets/{use-profiles-DMBAv505.js → use-profiles-Nhlj3JSG.js} +1 -1
- package/dist/web/assets/{use-projects-D14i8o7S.js → use-projects-DeWkuRAC.js} +1 -1
- package/dist/web/assets/{x-CHwmHeMU.js → x-B7DA0CXz.js} +1 -1
- package/dist/web/index.html +1 -1
- package/node_modules/@agent-tower/shared/package.json +1 -0
- package/package.json +1 -1
- package/dist/web/assets/use-providers-DW_hHJcb.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as b,r as s,j as e,L as W}from"./index-BjoprLxq.js";import{a as f,B as y}from"./api-client-DQBFRKXh.js";import{u as Q,a as X,b as L,c as Y,d as Z,S as ee,e as te,T as se,P as ne,G as re,f as ae}from"./mermaid-NOHMQCX5-DGTR51GL.js";import{d as le}from"./use-profiles-DMBAv505.js";import{C as ie}from"./chevron-down-BxmO9AqF.js";import"./log-adapter-50wgehrc.js";import"./query-keys-wUxyRw3p.js";const oe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],ce=b("at-sign",oe);const de=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xe=b("chevron-up",de);const me=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ue=b("hash",me);const pe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],he=b("send",pe),ge=!0;function Se(){const[w,_]=s.useState([]),[l,S]=s.useState(""),[d,k]=s.useState("DEFAULT"),[i,A]=s.useState(""),[r,D]=s.useState(null),[a,o]=s.useState("idle"),[h,E]=s.useState(!1),[x,j]=s.useState(""),$=s.useRef(null),C=s.useRef(null),m=s.useRef(null),{data:u}=le(l),H=u?Object.keys(u):["DEFAULT"],U=t=>{S(t),k("DEFAULT")},F=s.useCallback(t=>{o(t===0?"stopped":"error")},[]),M=s.useCallback(t=>{console.error("Agent error:",t),o("error")},[]),{isConnected:p,isAttached:g,logs:v,entries:V,agentSessionId:I,attach:z,clearLogs:P}=Q({sessionId:r||"",onExit:F,onError:M}),{todos:R}=X(V);s.useEffect(()=>{f.get("/demo/agents").then(t=>{_(t.agents);const n=t.agents.find(N=>N.available);n&&S(n.type)})},[]),s.useEffect(()=>{$.current?.scrollToBottom("smooth")},[v]),s.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${r} isConnected=${p} isAttached=${g}`),r&&p&&!g&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[r,p,g,z]);const B=t=>{if(j(t.target.value),m.current){m.current.style.height="auto";const N=Math.min(m.current.scrollHeight,210);m.current.style.height=`${N}px`}},G=async()=>{if(!l||!i.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),o("starting"),P();try{const n=await f.post("/demo/start",{agentType:l,prompt:i.trim(),variant:d});ge&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${n.sessionId}`),D(n.sessionId),o("running")}catch(n){console.error("Start failed:",n),o("error")}},T=async()=>{if(!r||!x.trim())return;const t=x.trim();j("");try{await f.post(`/demo/${r}/message`,{message:t})}catch(n){console.error("Send failed:",n)}},O=async()=>{if(r)try{await f.post(`/demo/${r}/stop`),o("stopped")}catch(t){console.error("Stop failed:",t)}},K=()=>{D(null),o("idle"),A(""),j(""),P()},q=a==="running",c=r!==null,J=w.find(t=>t.type===l);return e.jsxs("div",{className:"flex flex-col h-full bg-white",children:[e.jsxs("div",{className:"px-8 py-5 border-b border-neutral-100 bg-white transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-blue-600",children:"Agent Demo"}),e.jsx("span",{className:"text-neutral-300 text-sm",children:"/"}),e.jsx("span",{className:"text-xl font-bold text-neutral-900 tracking-tight",children:c?i.slice(0,50)+(i.length>50?"...":""):"新会话"})]}),e.jsxs("div",{className:"flex items-center",children:[a==="running"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-blue-50 text-blue-700 rounded-full text-xs font-medium border border-blue-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-pulse"}),e.jsx("span",{children:"Running"})]}),a==="stopped"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-emerald-50 text-emerald-700 rounded-full text-xs font-medium border border-emerald-100",children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Done"})]}),a==="idle"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-neutral-100 text-neutral-600 rounded-full text-xs font-medium border border-neutral-200",children:[e.jsx(Z,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Idle"})]}),a==="starting"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-full text-xs font-medium border border-amber-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Starting..."})]}),a==="error"&&e.jsx("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-red-50 text-red-700 rounded-full text-xs font-medium border border-red-100",children:e.jsx("span",{children:"Error"})})]})]}),c&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2 group max-w-4xl",children:[e.jsx("div",{className:`text-sm text-neutral-600 leading-relaxed cursor-pointer transition-all ${h?"":"truncate"}`,onClick:()=>E(!h),children:i}),e.jsx("button",{onClick:()=>E(!h),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:h?e.jsx(xe,{size:14}):e.jsx(ie,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:J?.name||l||"未选择"})]}),d!=="DEFAULT"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Variant"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-700 font-medium bg-blue-50 px-2 py-1 rounded border border-blue-100",children:d})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Session"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-700 font-mono bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:[I.slice(0,8),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"连接"}),e.jsx("div",{className:`flex items-center gap-1.5 font-medium px-2 py-1 rounded border ${p?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:p?g?"已连接":"连接中...":"未连接"})]}),c&&e.jsx(y,{variant:"outline",size:"sm",onClick:K,className:"ml-auto",children:"新会话"}),e.jsxs(W,{to:"/settings/profiles",className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${c?"":"ml-auto"}`,children:[e.jsx(ee,{size:14}),e.jsx("span",{children:"Profiles 设置"})]})]})]}),e.jsx("div",{ref:C,className:"flex-1 overflow-y-auto px-8 py-6",children:c?e.jsx("div",{className:"min-h-[200px]",children:v.length===0?e.jsx("div",{className:"text-neutral-400 text-center py-8",children:"等待 Agent 响应..."}):e.jsx(te,{ref:$,logs:v,scrollElementRef:C})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:"选择 Agent"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(t=>e.jsxs(y,{variant:l===t.type?"default":"outline",disabled:!t.available,onClick:()=>U(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&" (不可用)"]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:"配置变体 (Profile Variant)"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:H.map(t=>e.jsx("button",{onClick:()=>k(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${d===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),u&&u[d]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(u[d]).map(([t,n])=>`${t}: ${JSON.stringify(n)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:"输入任务"}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:i,onChange:t=>A(t.target.value),rows:4,placeholder:"描述你想让 Agent 完成的任务...",className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:G,disabled:a==="starting"||!l||!i.trim(),children:a==="starting"?"启动中...":"开始"})})]})]})]})}),c&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(se,{todos:R})}),c&&e.jsx("div",{className:"px-8 py-6 border-t border-neutral-100 bg-white",children:e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{ref:m,value:x,onChange:B,rows:3,placeholder:"发送消息给 Agent...",className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm scrollbar-thin scrollbar-thumb-neutral-200 scrollbar-track-transparent",style:{minHeight:"80px",maxHeight:"210px"},onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229&&(t.preventDefault(),T())}}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1 border-t border-transparent",children:[e.jsxs("div",{className:"flex items-center gap-1 text-neutral-400",children:[e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Attach File",children:e.jsx(ne,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Mention",children:e.jsx(ce,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Reference Issue",children:e.jsx(ue,{size:18})}),e.jsx("div",{className:"w-px h-4 bg-neutral-200 mx-1"}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Search Web",children:e.jsx(re,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q&&e.jsxs("button",{onClick:O,className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(ae,{size:12,fill:"currentColor"}),e.jsx("span",{children:"Stop"})]}),e.jsxs("button",{onClick:T,disabled:!x.trim(),className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold rounded-lg transition-all ${x.trim()?"bg-neutral-900 text-white hover:bg-black shadow-sm":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:[e.jsx("span",{children:"Send"}),e.jsx(he,{size:14})]})]})]})]})})]})}export{Se as AgentDemoPage};
|
|
1
|
+
import{c as b,r as s,j as e,L as W}from"./index-C5ZLITAJ.js";import{a as f,B as y}from"./api-client-Baduc3al.js";import{u as Q,a as X,b as L,c as Y,d as Z,S as ee,e as te,T as se,P as ne,G as re,f as ae}from"./mermaid-NOHMQCX5-CTtvbRFz.js";import{d as le}from"./use-profiles-Nhlj3JSG.js";import{C as ie}from"./chevron-down-CkF16nsG.js";import"./log-adapter-50wgehrc.js";import"./query-keys-6MuNX7mv.js";const oe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],ce=b("at-sign",oe);const de=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xe=b("chevron-up",de);const me=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ue=b("hash",me);const pe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],he=b("send",pe),ge=!0;function Se(){const[w,_]=s.useState([]),[l,S]=s.useState(""),[d,k]=s.useState("DEFAULT"),[i,A]=s.useState(""),[r,D]=s.useState(null),[a,o]=s.useState("idle"),[h,E]=s.useState(!1),[x,j]=s.useState(""),$=s.useRef(null),C=s.useRef(null),m=s.useRef(null),{data:u}=le(l),H=u?Object.keys(u):["DEFAULT"],U=t=>{S(t),k("DEFAULT")},F=s.useCallback(t=>{o(t===0?"stopped":"error")},[]),M=s.useCallback(t=>{console.error("Agent error:",t),o("error")},[]),{isConnected:p,isAttached:g,logs:v,entries:V,agentSessionId:I,attach:z,clearLogs:P}=Q({sessionId:r||"",onExit:F,onError:M}),{todos:R}=X(V);s.useEffect(()=>{f.get("/demo/agents").then(t=>{_(t.agents);const n=t.agents.find(N=>N.available);n&&S(n.type)})},[]),s.useEffect(()=>{$.current?.scrollToBottom("smooth")},[v]),s.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${r} isConnected=${p} isAttached=${g}`),r&&p&&!g&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[r,p,g,z]);const B=t=>{if(j(t.target.value),m.current){m.current.style.height="auto";const N=Math.min(m.current.scrollHeight,210);m.current.style.height=`${N}px`}},G=async()=>{if(!l||!i.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),o("starting"),P();try{const n=await f.post("/demo/start",{agentType:l,prompt:i.trim(),variant:d});ge&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${n.sessionId}`),D(n.sessionId),o("running")}catch(n){console.error("Start failed:",n),o("error")}},T=async()=>{if(!r||!x.trim())return;const t=x.trim();j("");try{await f.post(`/demo/${r}/message`,{message:t})}catch(n){console.error("Send failed:",n)}},O=async()=>{if(r)try{await f.post(`/demo/${r}/stop`),o("stopped")}catch(t){console.error("Stop failed:",t)}},K=()=>{D(null),o("idle"),A(""),j(""),P()},q=a==="running",c=r!==null,J=w.find(t=>t.type===l);return e.jsxs("div",{className:"flex flex-col h-full bg-white",children:[e.jsxs("div",{className:"px-8 py-5 border-b border-neutral-100 bg-white transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-blue-600",children:"Agent Demo"}),e.jsx("span",{className:"text-neutral-300 text-sm",children:"/"}),e.jsx("span",{className:"text-xl font-bold text-neutral-900 tracking-tight",children:c?i.slice(0,50)+(i.length>50?"...":""):"新会话"})]}),e.jsxs("div",{className:"flex items-center",children:[a==="running"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-blue-50 text-blue-700 rounded-full text-xs font-medium border border-blue-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-pulse"}),e.jsx("span",{children:"Running"})]}),a==="stopped"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-emerald-50 text-emerald-700 rounded-full text-xs font-medium border border-emerald-100",children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Done"})]}),a==="idle"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-neutral-100 text-neutral-600 rounded-full text-xs font-medium border border-neutral-200",children:[e.jsx(Z,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Idle"})]}),a==="starting"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-full text-xs font-medium border border-amber-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Starting..."})]}),a==="error"&&e.jsx("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-red-50 text-red-700 rounded-full text-xs font-medium border border-red-100",children:e.jsx("span",{children:"Error"})})]})]}),c&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2 group max-w-4xl",children:[e.jsx("div",{className:`text-sm text-neutral-600 leading-relaxed cursor-pointer transition-all ${h?"":"truncate"}`,onClick:()=>E(!h),children:i}),e.jsx("button",{onClick:()=>E(!h),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:h?e.jsx(xe,{size:14}):e.jsx(ie,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:J?.name||l||"未选择"})]}),d!=="DEFAULT"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Variant"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-700 font-medium bg-blue-50 px-2 py-1 rounded border border-blue-100",children:d})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Session"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-700 font-mono bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:[I.slice(0,8),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"连接"}),e.jsx("div",{className:`flex items-center gap-1.5 font-medium px-2 py-1 rounded border ${p?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:p?g?"已连接":"连接中...":"未连接"})]}),c&&e.jsx(y,{variant:"outline",size:"sm",onClick:K,className:"ml-auto",children:"新会话"}),e.jsxs(W,{to:"/settings/profiles",className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${c?"":"ml-auto"}`,children:[e.jsx(ee,{size:14}),e.jsx("span",{children:"Profiles 设置"})]})]})]}),e.jsx("div",{ref:C,className:"flex-1 overflow-y-auto px-8 py-6",children:c?e.jsx("div",{className:"min-h-[200px]",children:v.length===0?e.jsx("div",{className:"text-neutral-400 text-center py-8",children:"等待 Agent 响应..."}):e.jsx(te,{ref:$,logs:v,scrollElementRef:C})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:"选择 Agent"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(t=>e.jsxs(y,{variant:l===t.type?"default":"outline",disabled:!t.available,onClick:()=>U(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&" (不可用)"]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:"配置变体 (Profile Variant)"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:H.map(t=>e.jsx("button",{onClick:()=>k(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${d===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),u&&u[d]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(u[d]).map(([t,n])=>`${t}: ${JSON.stringify(n)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:"输入任务"}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:i,onChange:t=>A(t.target.value),rows:4,placeholder:"描述你想让 Agent 完成的任务...",className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:G,disabled:a==="starting"||!l||!i.trim(),children:a==="starting"?"启动中...":"开始"})})]})]})]})}),c&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(se,{todos:R})}),c&&e.jsx("div",{className:"px-8 py-6 border-t border-neutral-100 bg-white",children:e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{ref:m,value:x,onChange:B,rows:3,placeholder:"发送消息给 Agent...",className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm scrollbar-thin scrollbar-thumb-neutral-200 scrollbar-track-transparent",style:{minHeight:"80px",maxHeight:"210px"},onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229&&(t.preventDefault(),T())}}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1 border-t border-transparent",children:[e.jsxs("div",{className:"flex items-center gap-1 text-neutral-400",children:[e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Attach File",children:e.jsx(ne,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Mention",children:e.jsx(ce,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Reference Issue",children:e.jsx(ue,{size:18})}),e.jsx("div",{className:"w-px h-4 bg-neutral-200 mx-1"}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Search Web",children:e.jsx(re,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q&&e.jsxs("button",{onClick:O,className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(ae,{size:12,fill:"currentColor"}),e.jsx("span",{children:"Stop"})]}),e.jsxs("button",{onClick:T,disabled:!x.trim(),className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold rounded-lg transition-all ${x.trim()?"bg-neutral-900 text-white hover:bg-black shadow-sm":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:[e.jsx("span",{children:"Send"}),e.jsx(he,{size:14})]})]})]})]})})]})}export{Se as AgentDemoPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as n,s as E,S as d,C as k,j as s}from"./index-
|
|
1
|
+
import{r as n,s as E,S as d,C as k,j as s}from"./index-C5ZLITAJ.js";import{c as _,a as R,B}from"./api-client-Baduc3al.js";function T(I){const{sessionId:a,onOutput:x,onExit:b,onError:u}=I,[j,c]=n.useState(()=>E.isConnected()),[v,m]=n.useState(!1),r=n.useRef({onOutput:x,onExit:b,onError:u});r.current={onOutput:x,onExit:b,onError:u},n.useEffect(()=>{const t=E.getSocket();c(t.connected);const i=()=>c(!0),p=()=>{c(!1),m(!1)},O=l=>{l.sessionId===a&&r.current.onOutput?.(l.data)},h=l=>{l.sessionId===a&&(m(!1),r.current.onExit?.(l.exitCode))},g=l=>{l.sessionId===a&&r.current.onError?.(l.message)},N=l=>{l.sessionId===a&&m(!0)},C=l=>{l.sessionId===a&&m(!1)};return t.on("connect",i),t.on("disconnect",p),t.on(d.SESSION_STDOUT,O),t.on(d.SESSION_EXIT,h),t.on(d.SESSION_ERROR,g),t.on(d.SESSION_SUBSCRIBED,N),t.on(d.SESSION_UNSUBSCRIBED,C),c(t.connected),()=>{t.off("connect",i),t.off("disconnect",p),t.off(d.SESSION_STDOUT,O),t.off(d.SESSION_EXIT,h),t.off(d.SESSION_ERROR,g),t.off(d.SESSION_SUBSCRIBED,N),t.off(d.SESSION_UNSUBSCRIBED,C),t.emit(k.UNSUBSCRIBE,{topic:"session",id:a})}},[a]);const y=n.useCallback(()=>new Promise(t=>{const i=E.getSocket();if(!i.connected){t(!1);return}i.emit(k.SUBSCRIBE,{topic:"session",id:a},p=>{t(p.success)})}),[a]),w=n.useCallback(()=>{E.getSocket().emit(k.UNSUBSCRIBE,{topic:"session",id:a})},[a]),S=n.useCallback(t=>{E.getSocket().emit(k.INPUT,{sessionId:a,data:t})},[a]),D=n.useCallback((t,i)=>{E.getSocket().emit(k.RESIZE,{sessionId:a,cols:t,rows:i})},[a]);return{isConnected:j,isAttached:v,attach:y,detach:w,sendInput:S,resize:D}}function U({className:I,...a}){return s.jsx("div",{"data-slot":"card",className:_("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",I),...a})}function P(){const[I,a]=n.useState([]),[x,b]=n.useState(""),[u,j]=n.useState(""),[c,v]=n.useState(null),[m,r]=n.useState([]),[y,w]=n.useState(!1),[S,D]=n.useState(""),t=n.useRef(null),i=n.useCallback(e=>{r(o=>{const f=o[o.length-1];return f&&f.role==="agent"?[...o.slice(0,-1),{...f,content:f.content+e}]:[...o,{role:"agent",content:e,timestamp:new Date}]})},[]),p=n.useCallback(e=>{r(o=>[...o,{role:"agent",content:`
|
|
2
2
|
[进程退出,退出码: ${e}]`,timestamp:new Date}]),v(null)},[]),O=n.useCallback(e=>{r(o=>[...o,{role:"agent",content:`
|
|
3
3
|
[错误: ${e}]`,timestamp:new Date}])},[]),{isConnected:h,isAttached:g,attach:N}=T({sessionId:c||"",onOutput:i,onExit:p,onError:O});n.useEffect(()=>{R.get("/demo/agents").then(e=>{a(e.agents);const o=e.agents.find(f=>f.available);o&&b(o.type)})},[]),n.useEffect(()=>{t.current?.scrollIntoView({behavior:"smooth"})},[m]),n.useEffect(()=>{c&&h&&!g&&N()},[c,h,g,N]);const C=async()=>{if(!(!x||!u.trim())){w(!0),r([{role:"user",content:u,timestamp:new Date}]);try{const e=await R.post("/demo/start",{agentType:x,prompt:u.trim()});v(e.sessionId),j("")}catch(e){r(o=>[...o,{role:"agent",content:`启动失败: ${e instanceof Error?e.message:"未知错误"}`,timestamp:new Date}])}finally{w(!1)}}},l=async()=>{if(!c||!S.trim())return;const e=S.trim();r(o=>[...o,{role:"user",content:e,timestamp:new Date}]),D("");try{await R.post(`/demo/${c}/message`,{message:e})}catch(o){r(f=>[...f,{role:"agent",content:`发送失败: ${o instanceof Error?o.message:"未知错误"}`,timestamp:new Date}])}},A=async()=>{if(c)try{await R.post(`/demo/${c}/stop`),r(e=>[...e,{role:"agent",content:`
|
|
4
4
|
[会话已停止]`,timestamp:new Date}]),v(null)}catch(e){console.error("Stop failed:",e)}};return s.jsxs("div",{className:"flex flex-col h-full max-w-4xl mx-auto p-4 gap-4",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Agent 交互演示"}),!c&&s.jsxs(U,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold mb-3",children:"选择 Agent"}),s.jsx("div",{className:"flex gap-2 flex-wrap mb-4",children:I.map(e=>s.jsxs(B,{variant:x===e.type?"default":"outline",disabled:!e.available,onClick:()=>b(e.type),children:[e.name,e.available&&e.version&&` (${e.version})`,!e.available&&" (不可用)"]},e.type))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:u,onChange:e=>j(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&C(),placeholder:"输入你的问题或任务...",className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),s.jsx(B,{onClick:C,disabled:y||!x||!u.trim(),children:y?"启动中...":"开始"})]})]}),s.jsxs(U,{className:"flex-1 p-4 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"对话"}),c&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-gray-500",children:h?g?"已连接":"连接中...":"未连接"}),s.jsx(B,{variant:"outline",size:"sm",onClick:A,children:"停止"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[m.length===0?s.jsx("div",{className:"text-gray-400 text-center py-8",children:"选择 Agent 并输入问题开始对话"}):m.map((e,o)=>s.jsxs("div",{className:`p-3 rounded-lg ${e.role==="user"?"bg-blue-100 ml-8":"bg-gray-100 mr-8"}`,children:[s.jsx("div",{className:"text-xs text-gray-500 mb-1",children:e.role==="user"?"你":"Agent"}),s.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:e.content})]},o)),s.jsx("div",{ref:t})]}),c&&s.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[s.jsx("input",{type:"text",value:S,onChange:e=>D(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&l(),placeholder:"发送后续消息...",className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),s.jsx(B,{onClick:l,disabled:!S.trim(),children:"发送"})]})]})]})}export{P as DemoPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as U,u as S,r as l,j as e}from"./index-
|
|
1
|
+
import{c as U,u as S,r as l,j as e}from"./index-C5ZLITAJ.js";import{u as E,a as j,q as y}from"./query-keys-6MuNX7mv.js";import{a as x,B as g}from"./api-client-Baduc3al.js";import{S as I}from"./select-z5SlTxI3.js";import{L as P}from"./loader-circle-C4OXeViX.js";import{C as q}from"./circle-check-Ch_L_rkj.js";import{C as R}from"./circle-alert-eWOkoJBg.js";import"./chevron-down-CkF16nsG.js";const z=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],L=U("link",z);function B(){return E({queryKey:y.notifications.settings,queryFn:()=>x.get("/notifications/settings")})}function A(){const s=S();return j({mutationFn:c=>x.put("/notifications/settings",c),onSuccess:()=>{s.invalidateQueries({queryKey:y.notifications.settings})}})}function F(){return j({mutationFn:s=>x.post("/notifications/test",s)})}const K=[{value:"none",label:"无"},{value:"feishu",label:"飞书"}];function G(){const{data:s,isLoading:c}=B(),r=A(),a=F(),[n,p]=l.useState({webhookUrl:"",baseUrl:"",titleTemplate:"",bodyTemplate:""}),[u,h]=l.useState(!1),[f,i]=l.useState("idle"),d=l.useRef(void 0);if(l.useEffect(()=>{s&&!u&&p({webhookUrl:s.feishuWebhookUrl??"",baseUrl:s.thirdPartyBaseUrl??"",titleTemplate:s.taskInReviewTitleTemplate??"",bodyTemplate:s.taskInReviewBodyTemplate??""})},[s,u]),l.useEffect(()=>(a.isSuccess?(i("success"),d.current=setTimeout(()=>i("idle"),3e3)):a.isError&&(i("error"),d.current=setTimeout(()=>i("idle"),5e3)),()=>clearTimeout(d.current)),[a.isSuccess,a.isError]),c)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:"加载中..."});const m=s?.osNotificationEnabled??!0,b=s?.thirdPartyChannel??"none",o=(t,w)=>{p(C=>({...C,[t]:w})),h(!0)},N=()=>{r.mutate({osNotificationEnabled:!m})},k=t=>{r.mutate({thirdPartyChannel:t})},v=()=>{r.mutate({feishuWebhookUrl:n.webhookUrl.trim()||null,thirdPartyBaseUrl:n.baseUrl.trim()||null,taskInReviewTitleTemplate:n.titleTemplate.trim()||"Agent Tower",taskInReviewBodyTemplate:n.bodyTemplate.trim()||'✅ "{taskTitle}" 已完成,等待审查'},{onSuccess:()=>h(!1)})},T=()=>{n.webhookUrl.trim()&&a.mutate({channel:"feishu",webhookUrl:n.webhookUrl.trim(),baseUrl:n.baseUrl.trim()||void 0})};return e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-3xl space-y-8",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:"系统通知"}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:"任务完成时弹出桌面通知"}),e.jsx("button",{onClick:N,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${m?"bg-neutral-900":"bg-neutral-200"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${m?"translate-x-[18px]":"translate-x-[3px]"}`})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:"第三方通知"}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:"选择一个第三方渠道接收通知"}),e.jsx(I,{value:b,onChange:t=>k(t),options:K}),b==="feishu"&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"p-4 border border-neutral-100 rounded-lg space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1 text-[13px] font-medium text-neutral-700 mb-1",children:[e.jsx(L,{size:12}),"Webhook URL"]}),e.jsx("input",{type:"text",value:n.webhookUrl,onChange:t=>o("webhookUrl",t.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{size:"sm",variant:"outline",onClick:T,disabled:!n.webhookUrl.trim()||a.isPending,children:[a.isPending&&e.jsx(P,{size:12,className:"animate-spin mr-1"}),"测试发送"]}),f==="success"&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600",children:[e.jsx(q,{size:12}),"发送成功"]}),f==="error"&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",children:[e.jsx(R,{size:12}),"发送失败"]})]})]}),e.jsx("div",{className:"p-4 border border-neutral-100 rounded-lg space-y-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-[13px] font-medium text-neutral-700 mb-1",children:"跳转地址(用于生成任务链接)"}),e.jsx("input",{type:"text",value:n.baseUrl,onChange:t=>o("baseUrl",t.target.value),placeholder:"http://localhost:5173",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("p",{className:"text-[11px] text-neutral-400 mt-1",children:['通知卡片中的"查看任务"按钮将跳转到 ',"{baseUrl}/projects/{projectId}/tasks/{taskId}"]})]})})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:"通知模板"}),e.jsxs("p",{className:"text-[12px] text-neutral-400 mb-3",children:["支持变量: ","{taskTitle}",", ","{taskId}",", ","{projectId}",", ","{projectName}",", ","{status}"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[13px] font-medium text-neutral-700 mb-1",children:"标题模板"}),e.jsx("input",{type:"text",value:n.titleTemplate,onChange:t=>o("titleTemplate",t.target.value),placeholder:"Agent Tower",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[13px] font-medium text-neutral-700 mb-1",children:"内容模板"}),e.jsx("textarea",{value:n.bodyTemplate,onChange:t=>o("bodyTemplate",t.target.value),placeholder:'✅ "{taskTitle}" 已完成,等待审查',rows:2,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300 resize-none"})]})]})]}),u&&e.jsx("div",{className:"sticky bottom-6 flex justify-end",children:e.jsx(g,{size:"sm",onClick:v,disabled:r.isPending,children:r.isPending?"保存中...":"保存所有更改"})})]})}export{G as NotificationSettingsPage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as o,j as e}from"./index-
|
|
1
|
+
import{r as o,j as e}from"./index-C5ZLITAJ.js";import{u as J,a as V,b as $,c as L}from"./use-profiles-Nhlj3JSG.js";import{B as N}from"./api-client-Baduc3al.js";import{T as A,M as D}from"./modal-BnLru52Y.js";import{P as I}from"./x-B7DA0CXz.js";import{P as M}from"./pencil-Dbg3HneB.js";import"./query-keys-6MuNX7mv.js";function U(i){return Object.entries(i).map(([c,u])=>`${c}: ${JSON.stringify(u)}`).join(", ")}const g={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function q(){const{data:i,isLoading:c}=J(),{data:u}=V(),d=$(),v=L(),[r,a]=o.useState(null),[f,x]=o.useState(""),[m,p]=o.useState(""),[h,l]=o.useState(""),C=(t,s,n)=>{a({agentType:t,variant:s,config:n,isNew:!1}),p(s),x(JSON.stringify(n,null,2)),l("")},S=t=>{a({agentType:t,variant:"",config:{},isNew:!0}),p(""),x(`{
|
|
2
2
|
|
|
3
3
|
}`),l("")},E=()=>{if(!(!r||!m.trim()))try{const t=JSON.parse(f);l(""),d.mutate({agentType:r.agentType,variant:m.trim().toUpperCase(),config:t},{onSuccess:()=>a(null)})}catch{l("JSON 格式错误")}},w=(t,s)=>{confirm(`确定删除 ${t} / ${s}?`)&&v.mutate({agentType:t,variant:s})},y=(t,s)=>!!u?.executors[t]?.[s];if(c)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:"加载中..."});const O=i?.executors??{};return e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-3xl",children:[Object.entries(O).map(([t,s])=>e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900",children:g[t]??t}),e.jsxs("button",{onClick:()=>S(t),className:"flex items-center gap-1 text-xs text-neutral-400 hover:text-neutral-900 transition-colors",children:[e.jsx(I,{size:12}),e.jsx("span",{children:"新增"})]})]}),e.jsx("div",{className:"border border-neutral-100 rounded-lg overflow-hidden",children:Object.entries(s).map(([n,b],P,k)=>{const j=y(t,n);return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-neutral-50 transition-colors group ${P<k.length-1?"border-b border-neutral-100":""}`,children:[e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-[11px] font-semibold tracking-wide ${n==="DEFAULT"?"bg-blue-50 text-blue-600":"bg-neutral-50 text-neutral-600"}`,children:n}),e.jsx("span",{className:"flex-1 text-[12px] text-neutral-400 font-mono truncate",children:U(b)}),j&&e.jsx("span",{className:"text-[11px] text-neutral-300 font-medium",children:"内置"}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>C(t,n,b),className:"p-1 text-neutral-300 hover:text-neutral-700 rounded transition-colors",children:e.jsx(M,{size:13})}),!j&&e.jsx("button",{onClick:()=>w(t,n),className:"p-1 text-neutral-300 hover:text-red-500 rounded transition-colors",children:e.jsx(A,{size:13})})]})]},n)})})]},t)),e.jsx(D,{isOpen:!!r,onClose:()=>a(null),title:r?.isNew?`新增 Variant — ${g[r.agentType]??r.agentType}`:`编辑 ${r?.variant}`,action:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:()=>a(null),children:"取消"}),e.jsx(N,{onClick:E,disabled:d.isPending,children:d.isPending?"保存中...":"保存"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[13px] font-medium text-neutral-700 mb-1",children:"Variant 名称"}),e.jsx("input",{type:"text",value:m,onChange:t=>p(t.target.value),disabled:!r?.isNew,placeholder:"例如: CUSTOM",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300 disabled:bg-neutral-50 disabled:text-neutral-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[13px] font-medium text-neutral-700 mb-1",children:"配置 (JSON)"}),e.jsx("textarea",{value:f,onChange:t=>{x(t.target.value),l("")},rows:6,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300 resize-none"}),h&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:h})]})]})})]})}export{q as ProfileSettingsPage};
|