@agent-spaces/server 0.3.1 → 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.
Files changed (129) hide show
  1. package/dist/agents/agent-message-parts.js +2 -2
  2. package/dist/agents/issue-agent-runner.js +0 -1
  3. package/dist/app.js +0 -2
  4. package/dist/routes/issue.js +12 -0
  5. package/dist/routes/speech-recognition.js +21 -2
  6. package/dist/services/issue.js +11 -2
  7. package/dist/services/speech-recognition/tencent.js +6 -1
  8. package/dist/storage/speech-recognition-store.js +4 -1
  9. package/dist/web/404.html +1 -1
  10. package/dist/web/__next.__PAGE__.txt +4 -4
  11. package/dist/web/__next._full.txt +25 -25
  12. package/dist/web/__next._head.txt +4 -4
  13. package/dist/web/__next._index.txt +17 -17
  14. package/dist/web/__next._tree.txt +2 -2
  15. package/dist/web/_next/static/chunks/01hrib8z5bn-6.js +5 -0
  16. package/dist/web/_next/static/chunks/{02unyp1obddyn.js → 08nbjuc5i-ewu.js} +1 -1
  17. package/dist/web/_next/static/chunks/{0d.v1csiyl.1~.js → 0anuxr11yn5iv.js} +2 -2
  18. package/dist/web/_next/static/chunks/0cxrev-hb8gkk.js +2 -0
  19. package/dist/web/_next/static/chunks/0f_dcx0nu5z7o.js +1 -0
  20. package/dist/web/_next/static/chunks/{0-mtp2au0a0nh.js → 0jc-4igj54z00.js} +48 -48
  21. package/dist/web/_next/static/chunks/0uo5x.bu.5u2-.css +1 -0
  22. package/dist/web/_next/static/chunks/{0m1ud--um8kjh.js → 0utxlfbckz4f5.js} +1 -1
  23. package/dist/web/_next/static/chunks/{0~xn0gfqxa20r.js → 0w1iudd1d46sw.js} +3 -3
  24. package/dist/web/_not-found/__next._full.txt +23 -23
  25. package/dist/web/_not-found/__next._head.txt +4 -4
  26. package/dist/web/_not-found/__next._index.txt +17 -17
  27. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
  28. package/dist/web/_not-found/__next._not-found.txt +3 -3
  29. package/dist/web/_not-found/__next._tree.txt +2 -2
  30. package/dist/web/_not-found.html +1 -1
  31. package/dist/web/_not-found.txt +23 -23
  32. package/dist/web/index.html +1 -1
  33. package/dist/web/index.txt +25 -25
  34. package/dist/web/login/__next._full.txt +25 -25
  35. package/dist/web/login/__next._head.txt +4 -4
  36. package/dist/web/login/__next._index.txt +17 -17
  37. package/dist/web/login/__next._tree.txt +2 -2
  38. package/dist/web/login/__next.login.__PAGE__.txt +4 -4
  39. package/dist/web/login/__next.login.txt +3 -3
  40. package/dist/web/login.html +1 -1
  41. package/dist/web/login.txt +25 -25
  42. package/dist/web/settings/__next._full.txt +27 -27
  43. package/dist/web/settings/__next._head.txt +4 -4
  44. package/dist/web/settings/__next._index.txt +17 -17
  45. package/dist/web/settings/__next._tree.txt +2 -2
  46. package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
  47. package/dist/web/settings/__next.settings.txt +5 -5
  48. package/dist/web/settings/agents/__next._full.txt +27 -27
  49. package/dist/web/settings/agents/__next._head.txt +4 -4
  50. package/dist/web/settings/agents/__next._index.txt +17 -17
  51. package/dist/web/settings/agents/__next._tree.txt +2 -2
  52. package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
  53. package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
  54. package/dist/web/settings/agents/__next.settings.txt +5 -5
  55. package/dist/web/settings/agents.html +1 -1
  56. package/dist/web/settings/agents.txt +27 -27
  57. package/dist/web/settings/mcps/__next._full.txt +27 -27
  58. package/dist/web/settings/mcps/__next._head.txt +4 -4
  59. package/dist/web/settings/mcps/__next._index.txt +17 -17
  60. package/dist/web/settings/mcps/__next._tree.txt +2 -2
  61. package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
  62. package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
  63. package/dist/web/settings/mcps/__next.settings.txt +5 -5
  64. package/dist/web/settings/mcps.html +1 -1
  65. package/dist/web/settings/mcps.txt +27 -27
  66. package/dist/web/settings/models/__next._full.txt +27 -27
  67. package/dist/web/settings/models/__next._head.txt +4 -4
  68. package/dist/web/settings/models/__next._index.txt +17 -17
  69. package/dist/web/settings/models/__next._tree.txt +2 -2
  70. package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
  71. package/dist/web/settings/models/__next.settings.models.txt +3 -3
  72. package/dist/web/settings/models/__next.settings.txt +5 -5
  73. package/dist/web/settings/models.html +1 -1
  74. package/dist/web/settings/models.txt +27 -27
  75. package/dist/web/settings/providers/__next._full.txt +27 -27
  76. package/dist/web/settings/providers/__next._head.txt +4 -4
  77. package/dist/web/settings/providers/__next._index.txt +17 -17
  78. package/dist/web/settings/providers/__next._tree.txt +2 -2
  79. package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
  80. package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
  81. package/dist/web/settings/providers/__next.settings.txt +5 -5
  82. package/dist/web/settings/providers.html +1 -1
  83. package/dist/web/settings/providers.txt +27 -27
  84. package/dist/web/settings/skills/__next._full.txt +27 -27
  85. package/dist/web/settings/skills/__next._head.txt +4 -4
  86. package/dist/web/settings/skills/__next._index.txt +17 -17
  87. package/dist/web/settings/skills/__next._tree.txt +2 -2
  88. package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
  89. package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
  90. package/dist/web/settings/skills/__next.settings.txt +5 -5
  91. package/dist/web/settings/skills.html +1 -1
  92. package/dist/web/settings/skills.txt +27 -27
  93. package/dist/web/settings.html +1 -1
  94. package/dist/web/settings.txt +27 -27
  95. package/dist/web/workflows/__next._full.txt +25 -25
  96. package/dist/web/workflows/__next._head.txt +4 -4
  97. package/dist/web/workflows/__next._index.txt +17 -17
  98. package/dist/web/workflows/__next._tree.txt +2 -2
  99. package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
  100. package/dist/web/workflows/__next.workflows.txt +3 -3
  101. package/dist/web/workflows.html +1 -1
  102. package/dist/web/workflows.txt +25 -25
  103. package/dist/web/workspace/_/__next._full.txt +25 -25
  104. package/dist/web/workspace/_/__next._head.txt +4 -4
  105. package/dist/web/workspace/_/__next._index.txt +17 -17
  106. package/dist/web/workspace/_/__next._tree.txt +2 -2
  107. package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
  108. package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
  109. package/dist/web/workspace/_/__next.workspace.txt +3 -3
  110. package/dist/web/workspace/_.html +1 -1
  111. package/dist/web/workspace/_.txt +25 -25
  112. package/dist/web/workspaces/__next._full.txt +25 -25
  113. package/dist/web/workspaces/__next._head.txt +4 -4
  114. package/dist/web/workspaces/__next._index.txt +17 -17
  115. package/dist/web/workspaces/__next._tree.txt +2 -2
  116. package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
  117. package/dist/web/workspaces/__next.workspaces.txt +3 -3
  118. package/dist/web/workspaces.html +1 -1
  119. package/dist/web/workspaces.txt +25 -25
  120. package/dist/ws/agent-runner.js +6 -2
  121. package/dist/ws/message-parts.js +2 -2
  122. package/package.json +1 -1
  123. package/dist/web/_next/static/chunks/0glol5jdarfma.js +0 -2
  124. package/dist/web/_next/static/chunks/0o6w-uw2p.phy.js +0 -5
  125. package/dist/web/_next/static/chunks/0os7q6w~-tmg7.css +0 -1
  126. package/dist/web/_next/static/chunks/0~3uikgc074il.js +0 -1
  127. /package/dist/web/_next/static/{4dBAEZ275uRqcyeaRmXSx → 9X6R42UNn3h4WL_zj_Yh4}/_buildManifest.js +0 -0
  128. /package/dist/web/_next/static/{4dBAEZ275uRqcyeaRmXSx → 9X6R42UNn3h4WL_zj_Yh4}/_clientMiddlewareManifest.js +0 -0
  129. /package/dist/web/_next/static/{4dBAEZ275uRqcyeaRmXSx → 9X6R42UNn3h4WL_zj_Yh4}/_ssgManifest.js +0 -0
@@ -1,2 +1,2 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,788010,e=>{"use strict";var a=e.i(344180),t=e.i(465458);e.s(["Textarea",0,function({className:e,...s}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,t.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...s})}])},562918,928542,e=>{"use strict";var a=e.i(370383),t=e.i(969490);function s(e){return(0,t.useRenderElement)(e.defaultTagName??"div",e,e)}e.s(["useRender",0,s],928542);var i=e.i(294237),r=e.i(465458);let n=(0,i.cva)("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});e.s(["Badge",0,function({className:e,variant:t="default",render:i,...l}){return s({defaultTagName:"span",props:(0,a.mergeProps)({className:(0,r.cn)(n({variant:t}),e)},l),render:i,state:{slot:"badge",variant:t}})}],562918)},368942,e=>{"use strict";let a=(0,e.i(816709).create)((e,a)=>({models:[],providers:[],loaded:!1,ensure:async()=>{if(!a().loaded)try{let[a,t]=await Promise.all([fetch("/api/models").then(e=>e.json()),fetch("/api/providers").then(e=>e.json())]);e({models:a,providers:t,loaded:!0})}catch{}},addModel:a=>e(e=>({models:[...e.models,a]})),updateModel:a=>e(e=>({models:e.models.map(e=>e.id===a.id?a:e)})),removeModel:a=>e(e=>({models:e.models.filter(e=>e.id!==a)})),addProvider:a=>e(e=>({providers:[...e.providers,a]})),updateProvider:a=>e(e=>({providers:e.providers.map(e=>e.id===a.id?a:e)})),removeProvider:a=>e(e=>({providers:e.providers.filter(e=>e.id!==a)}))}));e.s(["useLLMStore",0,a])},226624,e=>{"use strict";var a,t=e.i(344180);e.s([],916562),e.i(916562),e.i(8890);var s=e.i(764556),i=e.i(535270),r=e.i(29905),n=e.i(204133),l=e.i(277642),d=e.i(236706),o=e.i(863728),c=e.i(969490),u=e.i(370383),p=e.i(139236),m=e.i(931709),h=e.i(267805);let g=s.createContext(void 0);var x=e.i(438904);let v=((a={}).checked="data-checked",a.unchecked="data-unchecked",a.disabled="data-disabled",a.readonly="data-readonly",a.required="data-required",a.valid="data-valid",a.invalid="data-invalid",a.touched="data-touched",a.dirty="data-dirty",a.filled="data-filled",a.focused="data-focused",a),f={...x.fieldValidityMapping,checked:e=>e?{[v.checked]:""}:{[v.unchecked]:""}};var b=e.i(125231),y=e.i(975698),k=e.i(380414),j=e.i(443124),N=e.i(575665),w=e.i(602453),C=e.i(742665),S=e.i(638144);let P=s.forwardRef(function(e,a){let{checked:h,className:x,defaultChecked:v,"aria-labelledby":P,form:T,id:z,inputRef:M,name:A,nativeButton:I=!1,onCheckedChange:O,readOnly:D=!1,required:B=!1,disabled:E=!1,render:K,uncheckedValue:R,value:L,style:F,..._}=e,{clearErrors:U}=(0,k.useFormContext)(),{state:q,setTouched:G,setDirty:V,validityData:W,setFilled:$,setFocused:H,shouldValidateOnChange:J,validationMode:Q,disabled:Z,name:X,validation:Y}=(0,b.useFieldRootContext)(),{labelId:ee}=(0,j.useLabelableContext)(),ea=Z||E,et=X??A,es=(0,r.useStableCallback)(O),ei=s.useRef(null),er=(0,n.useMergedRefs)(ei,M,Y.inputRef),en=s.useRef(null),el=(0,p.useBaseUiId)(),ed=(0,N.useLabelableId)({id:z,implicit:!1,controlRef:en}),eo=I?void 0:ed,[ec,eu]=(0,i.useControlled)({controlled:h,default:!!v,name:"Switch",state:"checked"});(0,y.useRegisterFieldControl)(en,{id:el,value:ec}),(0,l.useIsoLayoutEffect)(()=>{ei.current&&$(ei.current.checked)},[ei,$]),(0,S.useValueChanged)(ec,()=>{U(et),V(ec!==W.initialValue),$(ec),J()?Y.commit(ec):Y.commit(ec,!0)});let{getButtonProps:ep,buttonRef:em}=(0,m.useButton)({disabled:ea,native:I}),eh=function(e,a,t,i=!0,r){let[n,d]=s.useState(),o=(0,p.useBaseUiId)(r?`${r}-label`:void 0),c=e??a??n;return(0,l.useIsoLayoutEffect)(()=>{let s=e||a||!i?void 0:function(e,a){let t=function(e){if(!e)return;let a=e.parentElement;if(a&&"LABEL"===a.tagName)return a;let t=e.id;if(t){let a=e.nextElementSibling;if(a&&a.htmlFor===t)return a}let s=e.labels;return s&&s[0]}(e);if(t)return!t.id&&a&&(t.id=a),t.id||void 0}(t.current,o);n!==s&&d(s)}),c}(P,ee,ei,!I,eo),eg=s.useMemo(()=>(0,u.mergeProps)({checked:ec,disabled:ea,form:T,id:eo,name:et,required:B,style:et?d.visuallyHiddenInput:d.visuallyHidden,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:er,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(D)return void e.preventDefault();let a=e.currentTarget.checked,t=(0,w.createChangeEventDetails)(C.REASONS.none,e.nativeEvent);es?.(a,t),t.isCanceled||eu(a)},onFocus(){en.current?.focus()}},Y.getInputValidationProps,void 0!==L?{value:L}:o.EMPTY_OBJECT),[ec,ea,T,er,eo,et,es,D,B,eu,Y,L]),ex=s.useMemo(()=>({...q,checked:ec,disabled:ea,readOnly:D,required:B}),[q,ec,ea,D,B]),ev=(0,c.useRenderElement)("span",e,{state:ex,ref:[a,en,em],props:[{id:I?ed:el,role:"switch","aria-checked":ec,"aria-readonly":D||void 0,"aria-required":B||void 0,"aria-labelledby":eh,onFocus(){ea||H(!0)},onBlur(){let e=ei.current;e&&!ea&&(G(!0),H(!1),"onBlur"===Q&&Y.commit(e.checked))},onClick(e){D||ea||(e.preventDefault(),ei.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},Y.getValidationProps,_,ep],stateAttributesMapping:f});return(0,t.jsxs)(g.Provider,{value:ex,children:[ev,!ec&&et&&void 0!==R&&(0,t.jsx)("input",{type:"hidden",form:T,name:et,value:R}),(0,t.jsx)("input",{...eg,suppressHydrationWarning:!0})]})}),T=s.forwardRef(function(e,a){let{render:t,className:i,style:r,...n}=e,{state:l}=(0,b.useFieldRootContext)(),d=function(){let e=s.useContext(g);if(void 0===e)throw Error((0,h.default)(63));return e}(),o={...l,...d};return(0,c.useRenderElement)("span",e,{state:o,ref:a,stateAttributesMapping:f,props:n})});e.s(["Root",0,P,"Thumb",0,T],695728);var z=e.i(695728),z=z,M=e.i(465458);e.s(["Switch",0,function({className:e,size:a="default",...s}){return(0,t.jsx)(z.Root,{"data-slot":"switch","data-size":a,className:(0,M.cn)("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",e),...s,children:(0,t.jsx)(z.Thumb,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}],226624)},673478,e=>{"use strict";let a=(0,e.i(433721).default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);e.s(["Cpu",0,a],673478)},325443,946899,e=>{"use strict";let a=(0,e.i(433721).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);e.s(["default",0,a],946899),e.s(["Bot",0,a],325443)},415360,e=>{"use strict";let a=(0,e.i(433721).default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["Sparkles",0,a],415360)},511588,e=>{"use strict";let a=(0,e.i(433721).default)("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);e.s(["WandSparkles",0,a],511588)},444433,e=>{"use strict";e.s(["BUILT_IN_AGENT_TOOLS",0,[{name:"CreateCurrentChannelIssue",label:"Create Current Issue",description:"Create and bind an issue for the current channel."},{name:"ViewCurrentChannelIssue",label:"View Current Issue",description:"View the issue and comments bound to the current channel."},{name:"AddCurrentChannelComment",label:"Add Current Comment",description:"Add a comment to the issue bound to the current channel."},{name:"ReadTerminalOutput",label:"Read Terminal Output",description:"Read paginated terminal output by session ID. Defaults to the newest 100 lines."},{name:"ListQuickCommands",label:"List Quick Commands",description:"List all quick commands for a workspace with their running status."},{name:"RunQuickCommand",label:"Run Quick Command",description:"Start a quick command by its ID. Returns the terminal session ID."},{name:"StopQuickCommand",label:"Stop Quick Command",description:"Stop a running quick command by its ID."}]])},282180,e=>{"use strict";var a=e.i(344180),t=e.i(444433);let s=(t.BUILT_IN_AGENT_TOOLS??[]).map(e=>e.name),i=new Set(["openai-responses-to-anthropic-messages","openai-chat-completions-to-anthropic-messages"]);function r(e){return{mcpServers:Object.fromEntries(e.map(e=>[e,{}]))}}function n(e){return e.map(e=>({name:`${e}.md`,content:`# ${e}
2
- `}))}let l={agent:{name:"Agent",role:"agent",description:"通用 Agent,可在 workflow 中承担任意执行节点",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:r([]),skills:n(["coding","debugging","testing"]),tools:s,systemPrompt:"你是通用 Agent。根据 issue 和当前任务上下文完成被分配的工作,遵循项目规范,必要时修改代码、运行验证,并清晰汇报结果。",temperature:.3,maxTokens:8192,enabled:!0},scheduler:{name:"Scheduler",role:"scheduler",description:"任务调度者,负责任务分发和协调",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:r([]),skills:n(["planning","task-split"]),tools:s,systemPrompt:"你是调度者 Agent。负责接收用户任务,分析任务类型,分发给合适的执行者。你需要跟踪任务状态,确保所有子任务按时完成。",temperature:.3,maxTokens:4096,enabled:!0},task_creator:{name:"Task Creator",role:"task_creator",description:"任务创建者,负责把 issue 拆成可执行任务",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:r([]),skills:n(["planning","task-split"]),tools:s,systemPrompt:"你是任务创建者 Agent。负责读取 issue 上下文,把需求拆分为少量可执行任务,并用系统工具写入任务列表。只创建真正需要独立执行的任务,避免把细碎步骤拆成任务。",temperature:.3,maxTokens:4096,enabled:!0},bot:{name:"Bot Agent",role:"bot",description:"消息机器人,负责处理外部聊天平台中的用户消息",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:{},skills:[],tools:s,systemPrompt:"你是 Agent Spaces 的消息机器人。你会简洁回答来自外部聊天平台的用户消息。不要执行危险操作;需要用户提供更多信息时直接询问。",temperature:.3,maxTokens:4096,enabled:!0}};e.s(["FieldGroup",0,function({label:e,children:t}){return(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-xs text-muted-foreground",children:e}),t]})},"PROVIDER_OPTIONS",0,[{value:"anthropic-messages",labelKey:"anthropicMessages"},{value:"openai-chat-completions",labelKey:"openaiChatCompletions"},{value:"openai-responses",labelKey:"openaiResponses"},{value:"openai-responses-to-anthropic-messages",labelKey:"openaiResponsesToAnthropic"},{value:"openai-chat-completions-to-anthropic-messages",labelKey:"openaiChatToAnthropic"},{value:"gemini-generate-content",labelKey:"geminiGenerateContent"}],"ROLE_COLORS",0,{agent:"bg-gray-500/10 text-gray-600 border-gray-200",scheduler:"bg-blue-500/10 text-blue-600 border-blue-200",task_creator:"bg-green-500/10 text-green-600 border-green-200",bot:"bg-cyan-500/10 text-cyan-600 border-cyan-200"},"ROLE_OPTIONS",0,["agent","scheduler","task_creator","bot"],"RUNTIME_OPTIONS",0,[{value:"claude-code",labelKey:"claudeCode"},{value:"open-agent-sdk",labelKey:"openAgentSdk"},{value:"codex",labelKey:"codex"},{value:"langchain",labelKey:"langchain"}],"Section",0,function({icon:e,title:t,children:s}){return(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[e,t]}),s]})},"isAnthropicBridgeProvider",0,function(e){return!!(e&&i.has(e))},"isDraftAgent",0,function(e){return e.id.startsWith("draft-")},"newAgentDraft",0,function(e){return{id:`draft-${e}-${Date.now()}`,...l[e],mcps:structuredClone(l[e].mcps),skills:l[e].skills.map(e=>({...e})),tools:[...l[e].tools]}},"newEmptyAgent",0,function(){return{id:`draft-empty-${Date.now()}`,name:"",role:"agent",description:"",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"",modelId:"",apiBase:"",apiKey:"",workingDir:"",mcps:{},skills:[],tools:s,systemPrompt:"",temperature:.3,maxTokens:4096,enabled:!0}},"normalizeAgent",0,function(e){var a,i;return{...e,name:e.name||"New Agent",description:e.description||"",avatarUrl:e.avatarUrl||"",runtimeKind:e.runtimeKind||"open-agent-sdk",modelProvider:e.modelProvider||"",modelId:e.modelId||"claude-sonnet-4-6",apiBase:e.apiBase||"",apiKey:e.apiKey||"",workingDir:e.workingDir||"",mcps:(a=e.mcps)||{},skills:Array.isArray(i=e.skills)?i.map(e=>"string"==typeof e?{name:e.endsWith(".md")?e:`${e}.md`}:e):[],tools:function(e){if(!Array.isArray(e))return s;let a=new Set((t.BUILT_IN_AGENT_TOOLS??[]).map(e=>e.name));return e.filter(e=>a.has(e))}(e.tools),systemPrompt:e.systemPrompt||"",temperature:e.temperature??.3,maxTokens:e.maxTokens??4096,enabled:e.enabled??!0}},"serializeAgent",0,function(e){let{id:a,...t}=e;return{...t,modelProvider:t.modelProvider||void 0}}])},159619,839374,e=>{"use strict";let a=(0,e.i(433721).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["default",0,a],839374),e.s(["Copy",0,a],159619)},330044,92929,e=>{"use strict";var a=e.i(344180),t=e.i(244073),s=e.i(611176),i=e.i(260218),r=e.i(562918),n=e.i(226624),l=e.i(325443),d=e.i(159619),o=e.i(137340),c=e.i(465458);e.s(["AgentList",0,function({agents:e,onSelect:u,onDelete:p,onToggleEnabled:m}){let h=(0,t.useTranslations)("agent");return(0,a.jsxs)("div",{className:"flex flex-col p-2",children:[e.map(e=>{let t="agent-generator"===e.id;return(0,a.jsxs)("div",{className:(0,c.cn)("group flex items-center gap-3 rounded-lg px-3 py-2.5 hover:bg-muted/50 cursor-pointer transition-colors",!e.enabled&&!t&&"opacity-50"),onClick:()=>u(e),children:[(0,a.jsx)(s.AgentIcon,{name:e.name,avatarUrl:e.avatarUrl,apiBase:e.apiBase,className:"size-8"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,a.jsx)(r.Badge,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:t?"system":e.role})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.description||h("list.noDescription")})]}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.modelId.split("-").slice(0,2).join("-")}),(0,a.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,a.jsx)(n.Switch,{size:"sm",checked:t||e.enabled,disabled:t,onCheckedChange:()=>m?.(e.id)})}),(0,a.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(e.id)},children:(0,a.jsx)(d.Copy,{className:"size-3"})}),!t&&(0,a.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:a=>{a.stopPropagation(),p(e.id)},children:(0,a.jsx)(o.Trash2,{className:"size-3 text-destructive"})})]},e.id)}),0===e.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)(l.Bot,{className:"size-10 mb-2 opacity-30"}),(0,a.jsx)("p",{className:"text-sm",children:h("list.empty")})]})]})}],330044);let u=(0,e.i(433721).default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);e.s(["PlugZap",0,u],92929)},212068,e=>{"use strict";let a=(0,e.i(433721).default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]);e.s(["default",0,a])},119211,e=>{"use strict";var a=e.i(212068);e.s(["Wrench",()=>a.default])},426022,e=>{"use strict";let a=(0,e.i(433721).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);e.s(["MessageSquare",0,a],426022)},588591,e=>{"use strict";var a=e.i(344180),t=e.i(764556),s=e.i(244073),i=e.i(355819),r=e.i(209988),n=e.i(260218),l=e.i(788010),d=e.i(917955),o=e.i(465458),c=e.i(767467),u=e.i(325443),p=e.i(650654),m=e.i(953700),h=e.i(511588),g=e.i(282180),x=e.i(330044),v=e.i(368942),f=e.i(444433),b=e.i(611176),y=e.i(681622),k=e.i(188815),j=e.i(972846),N=e.i(673478),w=e.i(92929),C=e.i(451534),S=e.i(119211),P=e.i(415360),T=e.i(426022);let z=(0,e.i(433721).default)("sliders-vertical",[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]]);var M=e.i(129981);function A({agent:e,roleOptions:i,testing:r,testResult:d,onChange:c,onMcpChange:u,onAddSkillFiles:p,onRemoveSkill:m,onTestConnection:h}){let x=(0,s.useTranslations)("agent"),[I,O]=(0,t.useState)(()=>JSON.stringify(e.mcps,null,2)),[D,B]=(0,t.useState)(null),[E,K]=(0,t.useState)([]),{models:R,providers:L,ensure:F}=(0,v.useLLMStore)(),_=R.filter(e=>!e.embedding);(0,t.useEffect)(()=>{F()},[F]);let U=(0,t.useCallback)(e=>{c("apiBase",e.apiBase),c("apiKey",e.apiKey);let a=_.filter(a=>a.provider===e.name).map(e=>({value:e.modelId,label:e.name}));K(a),a.length>0&&c("modelId",a[0].value)},[_,c]),q=async e=>{if(!e?.length)return;let a=Array.from(e).filter(e=>e.name.toLowerCase().endsWith(".md"));p(await Promise.all(a.map(async e=>({name:e.name,content:await e.text()}))))};return(0,a.jsxs)("div",{className:"flex flex-col gap-5 p-5",children:[(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(T.MessageSquare,{className:"size-3.5"}),title:x("detail.basic"),children:[(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,a.jsx)(b.AgentIcon,{name:e.name,avatarUrl:e.avatarUrl,apiBase:e.apiBase,className:"size-16 rounded-xl border border-input"}),(0,a.jsxs)("label",{className:"text-[10px] text-primary cursor-pointer hover:underline",children:[x("detail.uploadAvatar"),(0,a.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:async e=>{let a=e.target.files?.[0];if(!a)return;let t=new FileReader;t.onload=async()=>{try{let e=await fetch("/api/upload/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataUrl:t.result,filename:a.name})}),s=await e.json();s.url&&c("avatarUrl",s.url)}catch{}},t.readAsDataURL(a),e.target.value=""}})]}),e.avatarUrl&&(0,a.jsx)("button",{type:"button",className:"text-[10px] text-destructive hover:underline",onClick:()=>c("avatarUrl",""),children:x("detail.removeAvatar")})]}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2.5",children:[(0,a.jsx)(g.FieldGroup,{label:x("detail.name"),children:(0,a.jsx)(y.Input,{value:e.name,onChange:e=>c("name",e.target.value)})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.role"),children:(0,a.jsx)("select",{value:e.role,onChange:e=>c("role",e.target.value),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring dark:bg-input/30",children:i.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})})]})]}),(0,a.jsx)(g.FieldGroup,{label:x("detail.description"),children:(0,a.jsx)(y.Input,{value:e.description,onChange:e=>c("description",e.target.value)})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.agentRuntime"),children:(0,a.jsx)(k.SearchSelect,{value:e.runtimeKind??"",onChange:e=>c("runtimeKind",e),options:g.RUNTIME_OPTIONS.map(e=>({value:e.value,label:x(`runtime.${e.labelKey}`)})),placeholder:x("detail.runtimePlaceholder"),searchPlaceholder:x("detail.runtimeSearchPlaceholder"),allowCustom:!1})})]}),(0,a.jsx)(g.Section,{icon:(0,a.jsx)(C.FolderOpen,{className:"size-3.5"}),title:x("detail.workingDirectory"),children:(0,a.jsx)(y.Input,{value:e.workingDir,onChange:e=>c("workingDir",e.target.value),placeholder:x("detail.workingDirPlaceholder")})}),(0,a.jsx)(g.Section,{icon:(0,a.jsx)(P.Sparkles,{className:"size-3.5"}),title:x("detail.systemPrompt"),children:(0,a.jsx)(l.Textarea,{value:e.systemPrompt,onChange:e=>c("systemPrompt",e.target.value),placeholder:x("detail.systemPromptPlaceholder"),className:"min-h-24 text-xs"})}),(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(S.Wrench,{className:"size-3.5"}),title:x("detail.mcpServers"),children:[(0,a.jsx)(l.Textarea,{value:I,onChange:e=>(e=>{O(e);try{let a=JSON.parse(e);if(!a||"object"!=typeof a||Array.isArray(a))throw Error("MCP config must be a JSON object");B(null),u(a)}catch(e){B(e instanceof Error?e.message:"Invalid JSON")}})(e.target.value),placeholder:'{\n "mcpServers": {}\n}',className:"min-h-28 font-mono text-xs"}),D&&(0,a.jsx)("div",{className:"text-xs text-destructive",children:D})]}),(0,a.jsx)(g.Section,{icon:(0,a.jsx)(S.Wrench,{className:"size-3.5"}),title:x("detail.tools"),children:(0,a.jsx)("div",{className:"grid gap-2",children:(f.BUILT_IN_AGENT_TOOLS??[]).map(t=>(0,a.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded-lg border border-input px-3 py-2 hover:bg-muted/50",children:[(0,a.jsx)("input",{type:"checkbox",checked:e.tools.includes(t.name),onChange:()=>{var a;let s;return a=t.name,void((s=new Set(e.tools)).has(a)?s.delete(a):s.add(a),c("tools",(f.BUILT_IN_AGENT_TOOLS??[]).map(e=>e.name).filter(e=>s.has(e))))},className:"mt-0.5 size-3.5"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block text-xs font-medium",children:t.label}),(0,a.jsx)("span",{className:"block text-[11px] text-muted-foreground",children:t.description})]})]},t.name))})}),(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(N.Cpu,{className:"size-3.5"}),title:x("detail.skills"),children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2",children:e.skills.map((e,t)=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground",children:[e.name,(0,a.jsx)("button",{type:"button",onClick:()=>m(t),className:"hover:text-destructive",children:(0,a.jsx)(j.X,{className:"size-2.5"})})]},t))}),(0,a.jsxs)("label",{className:"flex h-8 cursor-pointer items-center justify-center gap-2 rounded-lg border border-dashed border-input text-xs text-muted-foreground hover:bg-muted/50",children:[(0,a.jsx)(M.Upload,{className:"size-3.5"}),x("detail.uploadSkills"),(0,a.jsx)("input",{type:"file",accept:".md,text/markdown",multiple:!0,className:"hidden",onChange:e=>{q(e.target.files),e.target.value=""}})]})]}),(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(z,{className:"size-3.5"}),title:x("detail.model"),children:[(0,a.jsxs)("div",{className:"space-y-2.5",children:[(0,a.jsx)(g.FieldGroup,{label:x("detail.provider"),children:(0,a.jsx)(k.SearchSelect,{value:L.find(a=>a.apiBase===e.apiBase&&a.apiKey===e.apiKey)?.name||"",onChange:e=>{let a=L.find(a=>a.name===e);a&&U(a)},options:L.map(e=>({value:e.name,label:e.name})),placeholder:x("detail.providerPlaceholder"),searchPlaceholder:x("detail.providerSearchPlaceholder"),allowCustom:!1})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.modelField"),children:(0,a.jsx)(k.SearchSelect,{value:e.modelId,onChange:e=>c("modelId",e),options:E.length>0?E:[{value:e.modelId||"",label:e.modelId||x("detail.selectProviderFirst")}],placeholder:x("detail.modelPlaceholder"),searchPlaceholder:x("detail.modelSearchPlaceholder")})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.apiMessageType"),children:(0,a.jsx)(k.SearchSelect,{value:e.modelProvider||"",onChange:e=>c("modelProvider",e),options:g.PROVIDER_OPTIONS.map(e=>({value:e.value,label:x(`provider.${e.labelKey}`)})),placeholder:x("detail.apiMessageTypePlaceholder"),searchPlaceholder:x("detail.apiMessageTypeSearchPlaceholder"),allowCustom:!1})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.apiBase"),children:(0,a.jsx)(y.Input,{value:e.apiBase,onChange:e=>c("apiBase",e.target.value),placeholder:x("detail.apiBasePlaceholder"),className:"h-7 text-xs"})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.apiKey"),children:(0,a.jsx)(y.Input,{type:"password",value:e.apiKey,onChange:e=>c("apiKey",e.target.value),placeholder:x("detail.apiKeyPlaceholder"),className:"h-7 text-xs"})})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:x("detail.validateHelper")}),(0,a.jsxs)(n.Button,{type:"button",variant:"outline",size:"sm",onClick:h,disabled:r||!e.apiBase||!e.apiKey||!e.modelId,children:[(0,a.jsx)(w.PlugZap,{className:"size-3.5"}),r?x("detail.testing"):x("detail.test")]})]}),d&&(0,a.jsxs)("div",{className:(0,o.cn)("rounded-md border px-3 py-2 text-xs",d.success?"border-green-500/30 bg-green-500/10 text-green-700":"border-destructive/30 bg-destructive/10 text-destructive"),children:[d.message,d.debug&&(0,a.jsxs)("div",{className:"mt-2 space-y-1 font-mono text-[10px] opacity-80",children:[d.debug.status&&(0,a.jsxs)("div",{children:[x("debug.status")," ",d.debug.status]}),d.debug.provider&&(0,a.jsxs)("div",{children:[x("debug.provider")," ",d.debug.provider]}),d.debug.requestUrl&&(0,a.jsxs)("div",{children:[x("debug.url")," ",d.debug.requestUrl]}),d.debug.model&&(0,a.jsxs)("div",{children:[x("debug.model")," ",d.debug.model]}),d.debug.responseBody&&(0,a.jsxs)("div",{className:"max-h-20 overflow-auto whitespace-pre-wrap",children:[x("debug.body")," ",d.debug.responseBody]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsx)(g.FieldGroup,{label:x("detail.temperature"),children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"range",min:0,max:2,step:.1,value:e.temperature,onChange:e=>c("temperature",parseFloat(e.target.value)),className:"flex-1"}),(0,a.jsx)("span",{className:"text-xs font-mono w-8 text-right",children:e.temperature})]})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.maxTokens"),children:(0,a.jsx)(y.Input,{type:"number",value:e.maxTokens,onChange:e=>c("maxTokens",parseInt(e.target.value)||0),className:"h-7 text-xs"})})]})]})]})}let I="agent-generator";e.s(["AgentDialog",0,function({open:e,onOpenChange:v,roleFilter:f,initialAgentId:b,standalone:y}){let k=(0,s.useTranslations)("agent"),j=(0,s.useTranslations)("common"),[N,w]=(0,t.useState)([]),[C,S]=(0,t.useState)(null),[P,T]=(0,t.useState)(null),[z,M]=(0,t.useState)(!1),[O,D]=(0,t.useState)(!1),[B,E]=(0,t.useState)(!1),[K,R]=(0,t.useState)(!1),[L,F]=(0,t.useState)(""),[_,U]=(0,t.useState)(!1),[q,G]=(0,t.useState)(null),[V,W]=(0,t.useState)(null),$=f?new Set(Array.isArray(f)?f:[f]):null,H=$?N.filter(e=>e.id===I||$.has(e.role)):N,J=$?g.ROLE_OPTIONS.filter(e=>$.has(e)):g.ROLE_OPTIONS;(0,t.useEffect)(()=>{if(!e)return;let a=new AbortController;return queueMicrotask(()=>{M(!0),W(null)}),fetch("/api/agents/presets",{signal:a.signal}).then(async e=>{if(!e.ok)throw Error(await e.text());return e.json()}).then(e=>{let a=e.map(g.normalizeAgent);if(w(a),b){let e=a.find(e=>e.id===b);e&&(S(e),T({...e}))}}).catch(e=>{"AbortError"!==e.name&&W(k("error.loadFailed"))}).finally(()=>M(!1)),()=>a.abort()},[e,b,k]);let Q=()=>{S(null),T(null),G(null)},Z=async()=>{if(P){D(!0),W(null);try{let e=(0,g.isDraftAgent)(P),a=(0,g.serializeAgent)(P),t=await fetch(e?"/api/agents/presets":`/api/agents/presets/${P.id}`,{method:e?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?a:P)});if(!t.ok)throw Error(await t.text());let s=await t.json(),r=(0,g.normalizeAgent)(s);w(a=>e?[...a,r]:a.map(e=>e.id===r.id?r:e)),i.useAgentStore.setState(a=>({agents:e?[...a.agents,s]:a.agents.map(e=>e.id===s.id?s:e)})),S(null),T(null)}catch{W(k("error.saveFailed"))}finally{D(!1)}}},X=async()=>{if(P){E(!0),G(null),W(null);try{let e=await fetch("/api/agents/presets/test-connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),a=await e.json();G({success:!!a.success,message:a.message||a.error||k("error.connectionTestFailed"),debug:a.debug?{...a.debug,status:e.status}:{status:e.status}})}catch(e){G({success:!1,message:e instanceof Error?e.message:k("error.connectionTestFailed")})}finally{E(!1)}}},Y=e=>{let a="empty"===e?(0,g.newEmptyAgent)():(0,g.newAgentDraft)(e);W(null),S(a),T({...a})},ee=async()=>{let e=L.trim();if(e){U(!0),W(null);try{let a=await fetch("/api/agents/presets/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e})}),t=await a.json();if(!a.ok)throw Error(t.error||"Failed to generate agent");let s=P??(J[0]?(0,g.newAgentDraft)(J[0]):(0,g.newEmptyAgent)()),i={...s,name:t.name?.trim()||s.name,description:t.description?.trim()||s.description,systemPrompt:t.systemPrompt?.trim()||s.systemPrompt};S(i),T(i),R(!1),F(""),G(null)}catch(e){W(e instanceof Error?e.message:"智能创建 Agent 失败")}finally{U(!1)}}},ea=async e=>{e!==I&&(w(a=>a.map(a=>a.id===e?{...a,enabled:!a.enabled}:a)),await i.useAgentStore.getState().toggleEnabled(e))},et=async e=>{if(e!==I){if(e.startsWith("draft-")){S(null),T(null);return}D(!0),W(null);try{let a=await fetch(`/api/agents/presets/${e}`,{method:"DELETE"});if(!a.ok)throw Error(await a.text());w(a=>a.filter(a=>a.id!==e)),i.useAgentStore.setState(a=>({agents:a.agents.filter(a=>a.id!==e)})),C?.id===e&&(S(null),T(null))}catch{W(k("error.deleteFailed"))}finally{D(!1)}}},es=(0,a.jsxs)(a.Fragment,{children:[!y&&(0,a.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 pr-12 py-4",children:[C?(0,a.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:Q,children:(0,a.jsx)(c.ArrowLeft,{className:"size-4"})}):(0,a.jsx)("div",{className:"flex size-7 items-center justify-center rounded-lg bg-primary/10",children:(0,a.jsx)(u.Bot,{className:"size-4 text-primary"})}),(0,a.jsxs)(r.DialogHeader,{className:"flex-1 space-y-0",children:[(0,a.jsx)(r.DialogTitle,{className:"text-base",children:C?P?.name??"":k("dialog.title")}),(0,a.jsx)(r.DialogDescription,{className:"text-xs",children:C?k("dialog.editDescription"):k("dialog.listDescription")})]}),C&&(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),!C&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),(0,a.jsxs)(d.DropdownMenu,{children:[(0,a.jsx)(d.DropdownMenuTrigger,{render:(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O,children:[(0,a.jsx)(m.Plus,{className:"size-3.5"}),k("dialog.add"),(0,a.jsx)(p.ChevronDown,{className:"size-3.5"})]})}),(0,a.jsx)(d.DropdownMenuContent,{side:"bottom",align:"end",className:"w-44",children:(0,a.jsxs)(d.DropdownMenuGroup,{children:[!$&&(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y("empty"),children:[(0,a.jsx)("span",{className:"size-2 rounded-full bg-muted"}),(0,a.jsx)("span",{children:k("dialog.addEmpty")})]}),g.ROLE_OPTIONS.map(e=>(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y(e),children:[(0,a.jsx)("span",{className:(0,o.cn)("size-2 rounded-full",g.ROLE_COLORS[e].split(" ")[0])}),(0,a.jsx)("span",{className:"capitalize",children:k(`role.${e}.name`)})]},e))]})})]})]})]}),y&&!C&&(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-b",children:[(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),(0,a.jsxs)(d.DropdownMenu,{children:[(0,a.jsx)(d.DropdownMenuTrigger,{render:(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O,children:[(0,a.jsx)(m.Plus,{className:"size-3.5"}),k("dialog.add"),(0,a.jsx)(p.ChevronDown,{className:"size-3.5"})]})}),(0,a.jsx)(d.DropdownMenuContent,{side:"bottom",align:"end",className:"w-44",children:(0,a.jsxs)(d.DropdownMenuGroup,{children:[!$&&(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y("empty"),children:[(0,a.jsx)("span",{className:"size-2 rounded-full bg-muted"}),(0,a.jsx)("span",{children:k("dialog.addEmpty")})]}),g.ROLE_OPTIONS.map(e=>(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y(e),children:[(0,a.jsx)("span",{className:(0,o.cn)("size-2 rounded-full",g.ROLE_COLORS[e].split(" ")[0])}),(0,a.jsx)("span",{className:"capitalize",children:k(`role.${e}.name`)})]},e))]})})]})]}),y&&C&&(0,a.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,a.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:Q,children:(0,a.jsx)(c.ArrowLeft,{className:"size-4"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h2",{className:"text-base font-medium truncate",children:P?.name??""}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:k("dialog.editDescription")})]}),(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[V&&(0,a.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:V}),z?(0,a.jsx)("div",{className:"py-12 text-center text-sm text-muted-foreground",children:k("dialog.loading")}):C?P?(0,a.jsx)(A,{agent:P,roleOptions:J,testing:B,testResult:q,onChange:(e,a)=>{T(t=>t?"modelProvider"===e?{...t,modelProvider:a,runtimeKind:(0,g.isAnthropicBridgeProvider)(a)?"claude-code":t.runtimeKind}:"runtimeKind"===e?{...t,runtimeKind:a}:{...t,[e]:a}:t)},onMcpChange:e=>{T(a=>a?{...a,mcps:e}:a)},onAddSkillFiles:e=>{if(!P)return;let a=new Set(P.skills.map(e=>e.name));T(t=>t?{...t,skills:[...t.skills.filter(a=>!e.some(e=>e.name===a.name)),...e.filter(e=>e.name&&!a.has(e.name)),...e.filter(e=>a.has(e.name))]}:t)},onRemoveSkill:e=>{P&&T(a=>a?{...a,skills:a.skills.filter((a,t)=>t!==e)}:a)},onTestConnection:X},P.id):null:(0,a.jsx)(x.AgentList,{agents:H,onSelect:e=>{S(e),T({...e})},onDelete:et,onToggleEnabled:ea})]}),C&&(0,a.jsxs)("div",{className:"flex justify-end gap-2 border-t px-5 py-3",children:[(0,a.jsx)(n.Button,{variant:"outline",size:"sm",onClick:Q,disabled:O,children:j("cancel")}),(0,a.jsx)(n.Button,{size:"sm",onClick:Z,disabled:O,children:j(O?"saving":"save")})]}),(0,a.jsx)(r.Dialog,{open:K,onOpenChange:R,children:(0,a.jsxs)(r.DialogContent,{className:"sm:max-w-lg",children:[(0,a.jsxs)(r.DialogHeader,{children:[(0,a.jsx)(r.DialogTitle,{children:"智能创建 Agent"}),(0,a.jsx)(r.DialogDescription,{children:"输入 Agent 的职责、使用场景和约束,系统会生成名称、描述和 Markdown 系统提示。"})]}),(0,a.jsx)(l.Textarea,{value:L,onChange:e=>F(e.target.value),placeholder:"例如:创建一个代码评审 Agent,专注发现 TypeScript/React 项目中的缺陷、回归风险和缺失测试。",className:"min-h-32 text-sm"}),(0,a.jsxs)(r.DialogFooter,{children:[(0,a.jsx)(n.Button,{variant:"outline",onClick:()=>R(!1),disabled:_,children:j("cancel")}),(0,a.jsx)(n.Button,{onClick:ee,disabled:_||!L.trim(),children:_?"生成中...":"生成"})]})]})})]});return y?(0,a.jsx)("div",{className:"h-full flex flex-col",children:es}):(0,a.jsx)(r.Dialog,{open:e,onOpenChange:e=>{e||Q(),v(e)},children:(0,a.jsx)(r.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:es})})}],588591)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,788010,e=>{"use strict";var a=e.i(344180),t=e.i(465458);e.s(["Textarea",0,function({className:e,...s}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,t.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...s})}])},562918,928542,e=>{"use strict";var a=e.i(370383),t=e.i(969490);function s(e){return(0,t.useRenderElement)(e.defaultTagName??"div",e,e)}e.s(["useRender",0,s],928542);var i=e.i(294237),r=e.i(465458);let n=(0,i.cva)("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});e.s(["Badge",0,function({className:e,variant:t="default",render:i,...l}){return s({defaultTagName:"span",props:(0,a.mergeProps)({className:(0,r.cn)(n({variant:t}),e)},l),render:i,state:{slot:"badge",variant:t}})}],562918)},368942,e=>{"use strict";let a=(0,e.i(816709).create)((e,a)=>({models:[],providers:[],loaded:!1,ensure:async()=>{if(!a().loaded)try{let[a,t]=await Promise.all([fetch("/api/models").then(e=>e.json()),fetch("/api/providers").then(e=>e.json())]);e({models:a,providers:t,loaded:!0})}catch{}},addModel:a=>e(e=>({models:[...e.models,a]})),updateModel:a=>e(e=>({models:e.models.map(e=>e.id===a.id?a:e)})),removeModel:a=>e(e=>({models:e.models.filter(e=>e.id!==a)})),addProvider:a=>e(e=>({providers:[...e.providers,a]})),updateProvider:a=>e(e=>({providers:e.providers.map(e=>e.id===a.id?a:e)})),removeProvider:a=>e(e=>({providers:e.providers.filter(e=>e.id!==a)}))}));e.s(["useLLMStore",0,a])},226624,e=>{"use strict";var a,t=e.i(344180);e.s([],916562),e.i(916562),e.i(8890);var s=e.i(764556),i=e.i(535270),r=e.i(29905),n=e.i(204133),l=e.i(277642),d=e.i(236706),o=e.i(863728),c=e.i(969490),u=e.i(370383),p=e.i(139236),m=e.i(931709),h=e.i(267805);let g=s.createContext(void 0);var x=e.i(438904);let v=((a={}).checked="data-checked",a.unchecked="data-unchecked",a.disabled="data-disabled",a.readonly="data-readonly",a.required="data-required",a.valid="data-valid",a.invalid="data-invalid",a.touched="data-touched",a.dirty="data-dirty",a.filled="data-filled",a.focused="data-focused",a),f={...x.fieldValidityMapping,checked:e=>e?{[v.checked]:""}:{[v.unchecked]:""}};var b=e.i(125231),y=e.i(975698),j=e.i(380414),k=e.i(443124),N=e.i(575665),w=e.i(602453),C=e.i(742665),S=e.i(638144);let P=s.forwardRef(function(e,a){let{checked:h,className:x,defaultChecked:v,"aria-labelledby":P,form:T,id:z,inputRef:M,name:A,nativeButton:I=!1,onCheckedChange:O,readOnly:D=!1,required:B=!1,disabled:E=!1,render:K,uncheckedValue:R,value:L,style:F,..._}=e,{clearErrors:U}=(0,j.useFormContext)(),{state:q,setTouched:G,setDirty:V,validityData:W,setFilled:$,setFocused:H,shouldValidateOnChange:J,validationMode:Q,disabled:Z,name:X,validation:Y}=(0,b.useFieldRootContext)(),{labelId:ee}=(0,k.useLabelableContext)(),ea=Z||E,et=X??A,es=(0,r.useStableCallback)(O),ei=s.useRef(null),er=(0,n.useMergedRefs)(ei,M,Y.inputRef),en=s.useRef(null),el=(0,p.useBaseUiId)(),ed=(0,N.useLabelableId)({id:z,implicit:!1,controlRef:en}),eo=I?void 0:ed,[ec,eu]=(0,i.useControlled)({controlled:h,default:!!v,name:"Switch",state:"checked"});(0,y.useRegisterFieldControl)(en,{id:el,value:ec}),(0,l.useIsoLayoutEffect)(()=>{ei.current&&$(ei.current.checked)},[ei,$]),(0,S.useValueChanged)(ec,()=>{U(et),V(ec!==W.initialValue),$(ec),J()?Y.commit(ec):Y.commit(ec,!0)});let{getButtonProps:ep,buttonRef:em}=(0,m.useButton)({disabled:ea,native:I}),eh=function(e,a,t,i=!0,r){let[n,d]=s.useState(),o=(0,p.useBaseUiId)(r?`${r}-label`:void 0),c=e??a??n;return(0,l.useIsoLayoutEffect)(()=>{let s=e||a||!i?void 0:function(e,a){let t=function(e){if(!e)return;let a=e.parentElement;if(a&&"LABEL"===a.tagName)return a;let t=e.id;if(t){let a=e.nextElementSibling;if(a&&a.htmlFor===t)return a}let s=e.labels;return s&&s[0]}(e);if(t)return!t.id&&a&&(t.id=a),t.id||void 0}(t.current,o);n!==s&&d(s)}),c}(P,ee,ei,!I,eo),eg=s.useMemo(()=>(0,u.mergeProps)({checked:ec,disabled:ea,form:T,id:eo,name:et,required:B,style:et?d.visuallyHiddenInput:d.visuallyHidden,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:er,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(D)return void e.preventDefault();let a=e.currentTarget.checked,t=(0,w.createChangeEventDetails)(C.REASONS.none,e.nativeEvent);es?.(a,t),t.isCanceled||eu(a)},onFocus(){en.current?.focus()}},Y.getInputValidationProps,void 0!==L?{value:L}:o.EMPTY_OBJECT),[ec,ea,T,er,eo,et,es,D,B,eu,Y,L]),ex=s.useMemo(()=>({...q,checked:ec,disabled:ea,readOnly:D,required:B}),[q,ec,ea,D,B]),ev=(0,c.useRenderElement)("span",e,{state:ex,ref:[a,en,em],props:[{id:I?ed:el,role:"switch","aria-checked":ec,"aria-readonly":D||void 0,"aria-required":B||void 0,"aria-labelledby":eh,onFocus(){ea||H(!0)},onBlur(){let e=ei.current;e&&!ea&&(G(!0),H(!1),"onBlur"===Q&&Y.commit(e.checked))},onClick(e){D||ea||(e.preventDefault(),ei.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},Y.getValidationProps,_,ep],stateAttributesMapping:f});return(0,t.jsxs)(g.Provider,{value:ex,children:[ev,!ec&&et&&void 0!==R&&(0,t.jsx)("input",{type:"hidden",form:T,name:et,value:R}),(0,t.jsx)("input",{...eg,suppressHydrationWarning:!0})]})}),T=s.forwardRef(function(e,a){let{render:t,className:i,style:r,...n}=e,{state:l}=(0,b.useFieldRootContext)(),d=function(){let e=s.useContext(g);if(void 0===e)throw Error((0,h.default)(63));return e}(),o={...l,...d};return(0,c.useRenderElement)("span",e,{state:o,ref:a,stateAttributesMapping:f,props:n})});e.s(["Root",0,P,"Thumb",0,T],695728);var z=e.i(695728),z=z,M=e.i(465458);e.s(["Switch",0,function({className:e,size:a="default",...s}){return(0,t.jsx)(z.Root,{"data-slot":"switch","data-size":a,className:(0,M.cn)("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",e),...s,children:(0,t.jsx)(z.Thumb,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}],226624)},673478,e=>{"use strict";let a=(0,e.i(433721).default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);e.s(["Cpu",0,a],673478)},325443,946899,e=>{"use strict";let a=(0,e.i(433721).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);e.s(["default",0,a],946899),e.s(["Bot",0,a],325443)},415360,e=>{"use strict";let a=(0,e.i(433721).default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["Sparkles",0,a],415360)},511588,e=>{"use strict";let a=(0,e.i(433721).default)("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);e.s(["WandSparkles",0,a],511588)},444433,e=>{"use strict";e.s(["BUILT_IN_AGENT_TOOLS",0,[{name:"CreateCurrentChannelIssue",label:"Create Current Issue",description:"Create and bind an issue for the current channel."},{name:"ViewCurrentChannelIssue",label:"View Current Issue",description:"View the issue and comments bound to the current channel."},{name:"AddCurrentChannelComment",label:"Add Current Comment",description:"Add a comment to the issue bound to the current channel."},{name:"ReadTerminalOutput",label:"Read Terminal Output",description:"Read paginated terminal output by session ID. Defaults to the newest 100 lines."},{name:"ListQuickCommands",label:"List Quick Commands",description:"List all quick commands for a workspace with their running status."},{name:"RunQuickCommand",label:"Run Quick Command",description:"Start a quick command by its ID. Returns the terminal session ID."},{name:"StopQuickCommand",label:"Stop Quick Command",description:"Stop a running quick command by its ID."}]])},282180,e=>{"use strict";var a=e.i(344180),t=e.i(444433);let s=(t.BUILT_IN_AGENT_TOOLS??[]).map(e=>e.name),i=new Set(["openai-responses-to-anthropic-messages","openai-chat-completions-to-anthropic-messages"]);function r(e){return{mcpServers:Object.fromEntries(e.map(e=>[e,{}]))}}function n(e){return e.map(e=>({name:`${e}.md`,content:`# ${e}
2
+ `}))}let l={agent:{name:"Agent",role:"agent",description:"通用 Agent,可在 workflow 中承担任意执行节点",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:r([]),skills:n(["coding","debugging","testing"]),tools:s,systemPrompt:"你是通用 Agent。根据 issue 和当前任务上下文完成被分配的工作,遵循项目规范,必要时修改代码、运行验证,并清晰汇报结果。",temperature:.3,maxTokens:8192,enabled:!0},scheduler:{name:"Scheduler",role:"scheduler",description:"任务调度者,负责任务分发和协调",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:r([]),skills:n(["planning","task-split"]),tools:s,systemPrompt:"你是调度者 Agent。负责接收用户任务,分析任务类型,分发给合适的执行者。你需要跟踪任务状态,确保所有子任务按时完成。",temperature:.3,maxTokens:4096,enabled:!0},task_creator:{name:"Task Creator",role:"task_creator",description:"任务创建者,负责把 issue 拆成可执行任务",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:r([]),skills:n(["planning","task-split"]),tools:s,systemPrompt:"你是任务创建者 Agent。负责读取 issue 上下文,把需求拆分为少量可执行任务,并用系统工具写入任务列表。只创建真正需要独立执行的任务,避免把细碎步骤拆成任务。",temperature:.3,maxTokens:4096,enabled:!0},bot:{name:"Bot Agent",role:"bot",description:"消息机器人,负责处理外部聊天平台中的用户消息",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"anthropic-messages",modelId:"claude-sonnet-4-6",apiBase:"",apiKey:"",workingDir:"",mcps:{},skills:[],tools:s,systemPrompt:"你是 Agent Spaces 的消息机器人。你会简洁回答来自外部聊天平台的用户消息。不要执行危险操作;需要用户提供更多信息时直接询问。",temperature:.3,maxTokens:4096,enabled:!0}};e.s(["FieldGroup",0,function({label:e,children:t}){return(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-xs text-muted-foreground",children:e}),t]})},"PROVIDER_OPTIONS",0,[{value:"anthropic-messages",labelKey:"anthropicMessages"},{value:"openai-chat-completions",labelKey:"openaiChatCompletions"},{value:"openai-responses",labelKey:"openaiResponses"},{value:"openai-responses-to-anthropic-messages",labelKey:"openaiResponsesToAnthropic"},{value:"openai-chat-completions-to-anthropic-messages",labelKey:"openaiChatToAnthropic"},{value:"gemini-generate-content",labelKey:"geminiGenerateContent"}],"ROLE_COLORS",0,{agent:"bg-gray-500/10 text-gray-600 border-gray-200",scheduler:"bg-blue-500/10 text-blue-600 border-blue-200",task_creator:"bg-green-500/10 text-green-600 border-green-200",bot:"bg-cyan-500/10 text-cyan-600 border-cyan-200"},"ROLE_OPTIONS",0,["agent","scheduler","task_creator","bot"],"RUNTIME_OPTIONS",0,[{value:"claude-code",labelKey:"claudeCode"},{value:"open-agent-sdk",labelKey:"openAgentSdk"},{value:"codex",labelKey:"codex"},{value:"langchain",labelKey:"langchain"}],"Section",0,function({icon:e,title:t,children:s}){return(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[e,t]}),s]})},"isAnthropicBridgeProvider",0,function(e){return!!(e&&i.has(e))},"isDraftAgent",0,function(e){return e.id.startsWith("draft-")},"newAgentDraft",0,function(e){return{id:`draft-${e}-${Date.now()}`,...l[e],mcps:structuredClone(l[e].mcps),skills:l[e].skills.map(e=>({...e})),tools:[...l[e].tools]}},"newEmptyAgent",0,function(){return{id:`draft-empty-${Date.now()}`,name:"",role:"agent",description:"",avatarUrl:"",runtimeKind:"claude-code",modelProvider:"",modelId:"",apiBase:"",apiKey:"",workingDir:"",mcps:{},skills:[],tools:s,systemPrompt:"",temperature:.3,maxTokens:4096,enabled:!0}},"normalizeAgent",0,function(e){var a,i;return{...e,name:e.name||"New Agent",description:e.description||"",avatarUrl:e.avatarUrl||"",runtimeKind:e.runtimeKind||"open-agent-sdk",modelProvider:e.modelProvider||"",modelId:e.modelId||"claude-sonnet-4-6",apiBase:e.apiBase||"",apiKey:e.apiKey||"",workingDir:e.workingDir||"",mcps:(a=e.mcps)||{},skills:Array.isArray(i=e.skills)?i.map(e=>"string"==typeof e?{name:e.endsWith(".md")?e:`${e}.md`}:e):[],tools:function(e){if(!Array.isArray(e))return s;let a=new Set((t.BUILT_IN_AGENT_TOOLS??[]).map(e=>e.name));return e.filter(e=>a.has(e))}(e.tools),systemPrompt:e.systemPrompt||"",temperature:e.temperature??.3,maxTokens:e.maxTokens??4096,enabled:e.enabled??!0}},"serializeAgent",0,function(e){let{id:a,...t}=e;return{...t,modelProvider:t.modelProvider||void 0}}])},159619,839374,e=>{"use strict";let a=(0,e.i(433721).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["default",0,a],839374),e.s(["Copy",0,a],159619)},330044,92929,e=>{"use strict";var a=e.i(344180),t=e.i(244073),s=e.i(611176),i=e.i(260218),r=e.i(562918),n=e.i(226624),l=e.i(325443),d=e.i(159619),o=e.i(137340),c=e.i(465458);e.s(["AgentList",0,function({agents:e,onSelect:u,onDelete:p,onToggleEnabled:m}){let h=(0,t.useTranslations)("agent");return(0,a.jsxs)("div",{className:"flex flex-col p-2",children:[e.map(e=>{let t="agent-generator"===e.id;return(0,a.jsxs)("div",{className:(0,c.cn)("group flex items-center gap-3 rounded-lg px-3 py-2.5 hover:bg-muted/50 cursor-pointer transition-colors",!e.enabled&&!t&&"opacity-50"),onClick:()=>u(e),children:[(0,a.jsx)(s.AgentIcon,{name:e.name,avatarUrl:e.avatarUrl,apiBase:e.apiBase,className:"size-8"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,a.jsx)(r.Badge,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:t?"system":e.role})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.description||h("list.noDescription")})]}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.modelId.split("-").slice(0,2).join("-")}),(0,a.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,a.jsx)(n.Switch,{size:"sm",checked:t||e.enabled,disabled:t,onCheckedChange:()=>m?.(e.id)})}),(0,a.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(e.id)},children:(0,a.jsx)(d.Copy,{className:"size-3"})}),!t&&(0,a.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:a=>{a.stopPropagation(),p(e.id)},children:(0,a.jsx)(o.Trash2,{className:"size-3 text-destructive"})})]},e.id)}),0===e.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)(l.Bot,{className:"size-10 mb-2 opacity-30"}),(0,a.jsx)("p",{className:"text-sm",children:h("list.empty")})]})]})}],330044);let u=(0,e.i(433721).default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);e.s(["PlugZap",0,u],92929)},212068,e=>{"use strict";let a=(0,e.i(433721).default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]);e.s(["default",0,a])},119211,e=>{"use strict";var a=e.i(212068);e.s(["Wrench",()=>a.default])},426022,e=>{"use strict";let a=(0,e.i(433721).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);e.s(["MessageSquare",0,a],426022)},588591,e=>{"use strict";var a=e.i(344180),t=e.i(764556),s=e.i(244073),i=e.i(355819),r=e.i(209988),n=e.i(260218),l=e.i(788010),d=e.i(917955),o=e.i(465458),c=e.i(767467),u=e.i(325443),p=e.i(650654),m=e.i(953700),h=e.i(511588),g=e.i(282180),x=e.i(330044),v=e.i(368942),f=e.i(444433),b=e.i(611176),y=e.i(681622),j=e.i(188815),k=e.i(972846),N=e.i(673478),w=e.i(92929),C=e.i(451534),S=e.i(119211),P=e.i(415360),T=e.i(426022);let z=(0,e.i(433721).default)("sliders-vertical",[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]]);var M=e.i(129981);function A({agent:e,roleOptions:i,testing:r,testResult:d,onChange:c,onMcpChange:u,onAddSkillFiles:p,onRemoveSkill:m,onTestConnection:h}){let x=(0,s.useTranslations)("agent"),[I,O]=(0,t.useState)(()=>JSON.stringify(e.mcps,null,2)),[D,B]=(0,t.useState)(null),[E,K]=(0,t.useState)([]),{models:R,providers:L,ensure:F}=(0,v.useLLMStore)(),_=R.filter(e=>!e.embedding);(0,t.useEffect)(()=>{F()},[F]);let U=(0,t.useCallback)(e=>{c("apiBase",e.apiBase),c("apiKey",e.apiKey);let a=_.filter(a=>a.provider===e.name).map(e=>({value:e.modelId,label:e.name}));K(a),a.length>0&&c("modelId",a[0].value)},[_,c]),q=async e=>{if(!e?.length)return;let a=Array.from(e).filter(e=>e.name.toLowerCase().endsWith(".md"));p(await Promise.all(a.map(async e=>({name:e.name,content:await e.text()}))))};return(0,a.jsxs)("div",{className:"flex flex-col gap-5 p-5",children:[(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(T.MessageSquare,{className:"size-3.5"}),title:x("detail.basic"),children:[(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,a.jsx)(b.AgentIcon,{name:e.name,avatarUrl:e.avatarUrl,apiBase:e.apiBase,className:"size-16 rounded-xl border border-input"}),(0,a.jsxs)("label",{className:"text-[10px] text-primary cursor-pointer hover:underline",children:[x("detail.uploadAvatar"),(0,a.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:async e=>{let a=e.target.files?.[0];if(!a)return;let t=new FileReader;t.onload=async()=>{try{let e=await fetch("/api/upload/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataUrl:t.result,filename:a.name})}),s=await e.json();s.url&&c("avatarUrl",s.url)}catch{}},t.readAsDataURL(a),e.target.value=""}})]}),e.avatarUrl&&(0,a.jsx)("button",{type:"button",className:"text-[10px] text-destructive hover:underline",onClick:()=>c("avatarUrl",""),children:x("detail.removeAvatar")})]}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2.5",children:[(0,a.jsx)(g.FieldGroup,{label:x("detail.name"),children:(0,a.jsx)(y.Input,{value:e.name,onChange:e=>c("name",e.target.value)})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.role"),children:(0,a.jsx)("select",{value:e.role,onChange:e=>c("role",e.target.value),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring dark:bg-input/30",children:i.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})})]})]}),(0,a.jsx)(g.FieldGroup,{label:x("detail.description"),children:(0,a.jsx)(y.Input,{value:e.description,onChange:e=>c("description",e.target.value)})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.agentRuntime"),children:(0,a.jsx)(j.SearchSelect,{value:e.runtimeKind??"",onChange:e=>c("runtimeKind",e),options:g.RUNTIME_OPTIONS.map(e=>({value:e.value,label:x(`runtime.${e.labelKey}`)})),placeholder:x("detail.runtimePlaceholder"),searchPlaceholder:x("detail.runtimeSearchPlaceholder"),allowCustom:!1})})]}),(0,a.jsx)(g.Section,{icon:(0,a.jsx)(C.FolderOpen,{className:"size-3.5"}),title:x("detail.workingDirectory"),children:(0,a.jsx)(y.Input,{value:e.workingDir,onChange:e=>c("workingDir",e.target.value),placeholder:x("detail.workingDirPlaceholder")})}),(0,a.jsx)(g.Section,{icon:(0,a.jsx)(P.Sparkles,{className:"size-3.5"}),title:x("detail.systemPrompt"),children:(0,a.jsx)(l.Textarea,{value:e.systemPrompt,onChange:e=>c("systemPrompt",e.target.value),placeholder:x("detail.systemPromptPlaceholder"),className:"min-h-24 text-xs"})}),(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(S.Wrench,{className:"size-3.5"}),title:x("detail.mcpServers"),children:[(0,a.jsx)(l.Textarea,{value:I,onChange:e=>(e=>{O(e);try{let a=JSON.parse(e);if(!a||"object"!=typeof a||Array.isArray(a))throw Error("MCP config must be a JSON object");B(null),u(a)}catch(e){B(e instanceof Error?e.message:"Invalid JSON")}})(e.target.value),placeholder:'{\n "mcpServers": {}\n}',className:"min-h-28 font-mono text-xs"}),D&&(0,a.jsx)("div",{className:"text-xs text-destructive",children:D})]}),(0,a.jsx)(g.Section,{icon:(0,a.jsx)(S.Wrench,{className:"size-3.5"}),title:x("detail.tools"),children:(0,a.jsx)("div",{className:"grid gap-2",children:(f.BUILT_IN_AGENT_TOOLS??[]).map(t=>(0,a.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded-lg border border-input px-3 py-2 hover:bg-muted/50",children:[(0,a.jsx)("input",{type:"checkbox",checked:e.tools.includes(t.name),onChange:()=>{var a;let s;return a=t.name,void((s=new Set(e.tools)).has(a)?s.delete(a):s.add(a),c("tools",(f.BUILT_IN_AGENT_TOOLS??[]).map(e=>e.name).filter(e=>s.has(e))))},className:"mt-0.5 size-3.5"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block text-xs font-medium",children:t.label}),(0,a.jsx)("span",{className:"block text-[11px] text-muted-foreground",children:t.description})]})]},t.name))})}),(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(N.Cpu,{className:"size-3.5"}),title:x("detail.skills"),children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2",children:e.skills.map((e,t)=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground",children:[e.name,(0,a.jsx)("button",{type:"button",onClick:()=>m(t),className:"hover:text-destructive",children:(0,a.jsx)(k.X,{className:"size-2.5"})})]},t))}),(0,a.jsxs)("label",{className:"flex h-8 cursor-pointer items-center justify-center gap-2 rounded-lg border border-dashed border-input text-xs text-muted-foreground hover:bg-muted/50",children:[(0,a.jsx)(M.Upload,{className:"size-3.5"}),x("detail.uploadSkills"),(0,a.jsx)("input",{type:"file",accept:".md,text/markdown",multiple:!0,className:"hidden",onChange:e=>{q(e.target.files),e.target.value=""}})]})]}),(0,a.jsxs)(g.Section,{icon:(0,a.jsx)(z,{className:"size-3.5"}),title:x("detail.model"),children:[(0,a.jsxs)("div",{className:"space-y-2.5",children:[(0,a.jsx)(g.FieldGroup,{label:x("detail.provider"),children:(0,a.jsx)(j.SearchSelect,{value:L.find(a=>a.apiBase===e.apiBase&&a.apiKey===e.apiKey)?.name||"",onChange:e=>{let a=L.find(a=>a.name===e);a&&U(a)},options:L.map(e=>({value:e.name,label:e.name})),placeholder:x("detail.providerPlaceholder"),searchPlaceholder:x("detail.providerSearchPlaceholder"),allowCustom:!1})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.modelField"),children:(0,a.jsx)(j.SearchSelect,{value:e.modelId,onChange:e=>c("modelId",e),options:E.length>0?E:[{value:e.modelId||"",label:e.modelId||x("detail.selectProviderFirst")}],placeholder:x("detail.modelPlaceholder"),searchPlaceholder:x("detail.modelSearchPlaceholder")})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.apiMessageType"),children:(0,a.jsx)(j.SearchSelect,{value:e.modelProvider||"",onChange:e=>c("modelProvider",e),options:g.PROVIDER_OPTIONS.map(e=>({value:e.value,label:x(`provider.${e.labelKey}`)})),placeholder:x("detail.apiMessageTypePlaceholder"),searchPlaceholder:x("detail.apiMessageTypeSearchPlaceholder"),allowCustom:!1})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.apiBase"),children:(0,a.jsx)(y.Input,{value:e.apiBase,onChange:e=>c("apiBase",e.target.value),placeholder:x("detail.apiBasePlaceholder"),className:"h-7 text-xs"})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.apiKey"),children:(0,a.jsx)(y.Input,{type:"password",value:e.apiKey,onChange:e=>c("apiKey",e.target.value),placeholder:x("detail.apiKeyPlaceholder"),className:"h-7 text-xs"})})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:x("detail.validateHelper")}),(0,a.jsxs)(n.Button,{type:"button",variant:"outline",size:"sm",onClick:h,disabled:r||!e.apiBase||!e.apiKey||!e.modelId,children:[(0,a.jsx)(w.PlugZap,{className:"size-3.5"}),r?x("detail.testing"):x("detail.test")]})]}),d&&(0,a.jsxs)("div",{className:(0,o.cn)("rounded-md border px-3 py-2 text-xs",d.success?"border-green-500/30 bg-green-500/10 text-green-700":"border-destructive/30 bg-destructive/10 text-destructive"),children:[d.message,d.debug&&(0,a.jsxs)("div",{className:"mt-2 space-y-1 font-mono text-[10px] opacity-80",children:[d.debug.status&&(0,a.jsxs)("div",{children:[x("debug.status")," ",d.debug.status]}),d.debug.provider&&(0,a.jsxs)("div",{children:[x("debug.provider")," ",d.debug.provider]}),d.debug.requestUrl&&(0,a.jsxs)("div",{children:[x("debug.url")," ",d.debug.requestUrl]}),d.debug.model&&(0,a.jsxs)("div",{children:[x("debug.model")," ",d.debug.model]}),d.debug.responseBody&&(0,a.jsxs)("div",{className:"max-h-20 overflow-auto whitespace-pre-wrap",children:[x("debug.body")," ",d.debug.responseBody]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsx)(g.FieldGroup,{label:x("detail.temperature"),children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"range",min:0,max:2,step:.1,value:e.temperature,onChange:e=>c("temperature",parseFloat(e.target.value)),className:"flex-1"}),(0,a.jsx)("span",{className:"text-xs font-mono w-8 text-right",children:e.temperature})]})}),(0,a.jsx)(g.FieldGroup,{label:x("detail.maxTokens"),children:(0,a.jsx)(y.Input,{type:"number",value:e.maxTokens,onChange:e=>c("maxTokens",parseInt(e.target.value)||0),className:"h-7 text-xs"})})]})]})]})}let I="agent-generator";e.s(["AgentDialog",0,function({open:e,onOpenChange:v,roleFilter:f,initialAgentId:b,standalone:y}){let j=(0,s.useTranslations)("agent"),k=(0,s.useTranslations)("common"),[N,w]=(0,t.useState)([]),[C,S]=(0,t.useState)(null),[P,T]=(0,t.useState)(null),[z,M]=(0,t.useState)(!1),[O,D]=(0,t.useState)(!1),[B,E]=(0,t.useState)(!1),[K,R]=(0,t.useState)(!1),[L,F]=(0,t.useState)(""),[_,U]=(0,t.useState)(!1),[q,G]=(0,t.useState)(null),[V,W]=(0,t.useState)(null),$=f?new Set(Array.isArray(f)?f:[f]):null,H=$?N.filter(e=>e.id===I||$.has(e.role)):N,J=$?g.ROLE_OPTIONS.filter(e=>$.has(e)):g.ROLE_OPTIONS;(0,t.useEffect)(()=>{if(!e)return;let a=new AbortController;return queueMicrotask(()=>{M(!0),W(null)}),fetch("/api/agents/presets",{signal:a.signal}).then(async e=>{if(!e.ok)throw Error(await e.text());return e.json()}).then(e=>{let a=e.map(g.normalizeAgent);if(w(a),b){let e=a.find(e=>e.id===b);e&&(S(e),T({...e}))}}).catch(e=>{"AbortError"!==e.name&&W(j("error.loadFailed"))}).finally(()=>M(!1)),()=>a.abort()},[e,b,j]);let Q=()=>{S(null),T(null),G(null)},Z=async()=>{if(P){D(!0),W(null);try{let e=(0,g.isDraftAgent)(P),a=(0,g.serializeAgent)(P),t=await fetch(e?"/api/agents/presets":`/api/agents/presets/${P.id}`,{method:e?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?a:P)});if(!t.ok)throw Error(await t.text());let s=await t.json(),r=(0,g.normalizeAgent)(s);w(a=>e?[...a,r]:a.map(e=>e.id===r.id?r:e)),i.useAgentStore.setState(a=>({agents:e?[...a.agents,s]:a.agents.map(e=>e.id===s.id?s:e)})),S(null),T(null)}catch{W(j("error.saveFailed"))}finally{D(!1)}}},X=async()=>{if(P){E(!0),G(null),W(null);try{let e=await fetch("/api/agents/presets/test-connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),a=await e.json();G({success:!!a.success,message:a.message||a.error||j("error.connectionTestFailed"),debug:a.debug?{...a.debug,status:e.status}:{status:e.status}})}catch(e){G({success:!1,message:e instanceof Error?e.message:j("error.connectionTestFailed")})}finally{E(!1)}}},Y=e=>{let a="empty"===e?(0,g.newEmptyAgent)():(0,g.newAgentDraft)(e);W(null),S(a),T({...a})},ee=async()=>{let e=L.trim();if(e){U(!0),W(null);try{let a=await fetch("/api/agents/presets/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e})}),t=await a.json();if(!a.ok)throw Error(t.error||"Failed to generate agent");let s=P??(J[0]?(0,g.newAgentDraft)(J[0]):(0,g.newEmptyAgent)()),i={...s,name:t.name?.trim()||s.name,description:t.description?.trim()||s.description,systemPrompt:t.systemPrompt?.trim()||s.systemPrompt};S(i),T(i),R(!1),F(""),G(null)}catch(e){W(e instanceof Error?e.message:"智能创建 Agent 失败")}finally{U(!1)}}},ea=async e=>{e!==I&&(w(a=>a.map(a=>a.id===e?{...a,enabled:!a.enabled}:a)),await i.useAgentStore.getState().toggleEnabled(e))},et=async e=>{if(e!==I){if(e.startsWith("draft-")){S(null),T(null);return}D(!0),W(null);try{let a=await fetch(`/api/agents/presets/${e}`,{method:"DELETE"});if(!a.ok)throw Error(await a.text());w(a=>a.filter(a=>a.id!==e)),i.useAgentStore.setState(a=>({agents:a.agents.filter(a=>a.id!==e)})),C?.id===e&&(S(null),T(null))}catch{W(j("error.deleteFailed"))}finally{D(!1)}}},es=(0,a.jsxs)(a.Fragment,{children:[!y&&(0,a.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 pr-12 py-4",children:[C?(0,a.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:Q,children:(0,a.jsx)(c.ArrowLeft,{className:"size-4"})}):(0,a.jsx)("div",{className:"flex size-7 items-center justify-center rounded-lg bg-primary/10",children:(0,a.jsx)(u.Bot,{className:"size-4 text-primary"})}),(0,a.jsxs)(r.DialogHeader,{className:"flex-1 space-y-0",children:[(0,a.jsx)(r.DialogTitle,{className:"text-base",children:C?P?.name??"":j("dialog.title")}),(0,a.jsx)(r.DialogDescription,{className:"text-xs",children:C?j("dialog.editDescription"):j("dialog.listDescription")})]}),C&&(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),!C&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),(0,a.jsxs)(d.DropdownMenu,{children:[(0,a.jsx)(d.DropdownMenuTrigger,{render:(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O,children:[(0,a.jsx)(m.Plus,{className:"size-3.5"}),j("dialog.add"),(0,a.jsx)(p.ChevronDown,{className:"size-3.5"})]})}),(0,a.jsx)(d.DropdownMenuContent,{side:"bottom",align:"end",className:"w-44",children:(0,a.jsxs)(d.DropdownMenuGroup,{children:[!$&&(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y("empty"),children:[(0,a.jsx)("span",{className:"size-2 rounded-full bg-muted"}),(0,a.jsx)("span",{children:j("dialog.addEmpty")})]}),g.ROLE_OPTIONS.map(e=>(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y(e),children:[(0,a.jsx)("span",{className:(0,o.cn)("size-2 rounded-full",g.ROLE_COLORS[e].split(" ")[0])}),(0,a.jsx)("span",{className:"capitalize",children:j(`role.${e}.name`)})]},e))]})})]})]})]}),y&&!C&&(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-b",children:[(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),(0,a.jsxs)(d.DropdownMenu,{children:[(0,a.jsx)(d.DropdownMenuTrigger,{render:(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O,children:[(0,a.jsx)(m.Plus,{className:"size-3.5"}),j("dialog.add"),(0,a.jsx)(p.ChevronDown,{className:"size-3.5"})]})}),(0,a.jsx)(d.DropdownMenuContent,{side:"bottom",align:"end",className:"w-44",children:(0,a.jsxs)(d.DropdownMenuGroup,{children:[!$&&(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y("empty"),children:[(0,a.jsx)("span",{className:"size-2 rounded-full bg-muted"}),(0,a.jsx)("span",{children:j("dialog.addEmpty")})]}),g.ROLE_OPTIONS.map(e=>(0,a.jsxs)(d.DropdownMenuItem,{className:"gap-2",onClick:()=>Y(e),children:[(0,a.jsx)("span",{className:(0,o.cn)("size-2 rounded-full",g.ROLE_COLORS[e].split(" ")[0])}),(0,a.jsx)("span",{className:"capitalize",children:j(`role.${e}.name`)})]},e))]})})]})]}),y&&C&&(0,a.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,a.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:Q,children:(0,a.jsx)(c.ArrowLeft,{className:"size-4"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h2",{className:"text-base font-medium truncate",children:P?.name??""}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:j("dialog.editDescription")})]}),(0,a.jsxs)(n.Button,{variant:"outline",size:"sm",disabled:O||_,onClick:()=>R(!0),children:[(0,a.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[V&&(0,a.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:V}),z?(0,a.jsx)("div",{className:"flex flex-col p-2 space-y-1",children:Array.from({length:5},(e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2.5",children:[(0,a.jsx)("div",{className:"size-8 rounded-full bg-muted animate-pulse"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-4 w-20 rounded bg-muted animate-pulse"}),(0,a.jsx)("div",{className:"h-4 w-10 rounded-full bg-muted animate-pulse"})]}),(0,a.jsx)("div",{className:"h-3 w-32 rounded bg-muted animate-pulse"})]}),(0,a.jsx)("div",{className:"h-3 w-12 rounded bg-muted animate-pulse"})]},t))}):C?P?(0,a.jsx)(A,{agent:P,roleOptions:J,testing:B,testResult:q,onChange:(e,a)=>{T(t=>t?"modelProvider"===e?{...t,modelProvider:a,runtimeKind:(0,g.isAnthropicBridgeProvider)(a)?"claude-code":t.runtimeKind}:"runtimeKind"===e?{...t,runtimeKind:a}:{...t,[e]:a}:t)},onMcpChange:e=>{T(a=>a?{...a,mcps:e}:a)},onAddSkillFiles:e=>{if(!P)return;let a=new Set(P.skills.map(e=>e.name));T(t=>t?{...t,skills:[...t.skills.filter(a=>!e.some(e=>e.name===a.name)),...e.filter(e=>e.name&&!a.has(e.name)),...e.filter(e=>a.has(e.name))]}:t)},onRemoveSkill:e=>{P&&T(a=>a?{...a,skills:a.skills.filter((a,t)=>t!==e)}:a)},onTestConnection:X},P.id):null:(0,a.jsx)(x.AgentList,{agents:H,onSelect:e=>{S(e),T({...e})},onDelete:et,onToggleEnabled:ea})]}),C&&(0,a.jsxs)("div",{className:"flex justify-end gap-2 border-t px-5 py-3",children:[(0,a.jsx)(n.Button,{variant:"outline",size:"sm",onClick:Q,disabled:O,children:k("cancel")}),(0,a.jsx)(n.Button,{size:"sm",onClick:Z,disabled:O,children:k(O?"saving":"save")})]}),(0,a.jsx)(r.Dialog,{open:K,onOpenChange:R,children:(0,a.jsxs)(r.DialogContent,{className:"sm:max-w-lg",children:[(0,a.jsxs)(r.DialogHeader,{children:[(0,a.jsx)(r.DialogTitle,{children:"智能创建 Agent"}),(0,a.jsx)(r.DialogDescription,{children:"输入 Agent 的职责、使用场景和约束,系统会生成名称、描述和 Markdown 系统提示。"})]}),(0,a.jsx)(l.Textarea,{value:L,onChange:e=>F(e.target.value),placeholder:"例如:创建一个代码评审 Agent,专注发现 TypeScript/React 项目中的缺陷、回归风险和缺失测试。",className:"min-h-32 text-sm"}),(0,a.jsxs)(r.DialogFooter,{children:[(0,a.jsx)(n.Button,{variant:"outline",onClick:()=>R(!1),disabled:_,children:k("cancel")}),(0,a.jsx)(n.Button,{onClick:ee,disabled:_||!L.trim(),children:_?"生成中...":"生成"})]})]})})]});return y?(0,a.jsx)("div",{className:"h-full flex flex-col",children:es}):(0,a.jsx)(r.Dialog,{open:e,onOpenChange:e=>{e||Q(),v(e)},children:(0,a.jsx)(r.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:es})})}],588591)}]);
@@ -0,0 +1,2 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,837121,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"warnOnce",{enumerable:!0,get:function(){return a}});let a=e=>{}},989484,905724,e=>{"use strict";let t=(0,e.i(433721).default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);e.s(["default",0,t],905724),e.s(["FileText",0,t],989484)},267624,e=>{"use strict";let t=(0,e.i(433721).default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);e.s(["LayoutGrid",0,t],267624)},100694,e=>{"use strict";var t,s,a,i,n;function l(e,t,s,a){if("a"===s&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)}function r(e,t,s,a,i){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?i.call(e,s):i?i.value=s:t.set(e,s),s}"function"==typeof SuppressedError&&SuppressedError;let o="__TAURI_TO_IPC_KEY__";function c(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}class d{constructor(e){t.set(this,void 0),s.set(this,0),a.set(this,[]),i.set(this,void 0),r(this,t,e||(()=>{}),"f"),this.id=c(e=>{let n=e.index;if("end"in e)return void(n==l(this,s,"f")?this.cleanupCallback():r(this,i,n,"f"));let o=e.message;if(n==l(this,s,"f")){for(l(this,t,"f").call(this,o),r(this,s,l(this,s,"f")+1,"f");l(this,s,"f")in l(this,a,"f");){let e=l(this,a,"f")[l(this,s,"f")];l(this,t,"f").call(this,e),delete l(this,a,"f")[l(this,s,"f")],r(this,s,l(this,s,"f")+1,"f")}l(this,s,"f")===l(this,i,"f")&&this.cleanupCallback()}else l(this,a,"f")[n]=o})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){r(this,t,e,"f")}get onmessage(){return l(this,t,"f")}[(t=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}class m{constructor(e,t,s){this.plugin=e,this.event=t,this.channelId=s}async unregister(){return x(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function u(e,t,s){let a=new d(s);try{return await x(`plugin:${e}|register_listener`,{event:t,handler:a}),new m(e,t,a.id)}catch{return await x(`plugin:${e}|registerListener`,{event:t,handler:a}),new m(e,t,a.id)}}async function x(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}n=new WeakMap,e.s(["Resource",0,class{get rid(){return l(this,n,"f")}constructor(e){n.set(this,void 0),r(this,n,e,"f")}async close(){return x("plugin:resources|close",{rid:this.rid})}},"SERIALIZE_TO_IPC_FN",0,o,"addPluginListener",0,u,"invoke",0,x,"transformCallback",0,c],100694)},757106,e=>{"use strict";let t=(0,e.i(433721).default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);e.s(["default",0,t])},990336,e=>{"use strict";var t=e.i(757106);e.s(["Brain",()=>t.default])},307858,e=>{"use strict";let t=(0,e.i(433721).default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);e.s(["ExternalLink",0,t],307858)},100559,e=>{"use strict";let t=(0,e.i(433721).default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);e.s(["Server",0,t],100559)},549705,e=>{"use strict";var t=e.i(344180),s=e.i(764556),a=e.i(244073),i=e.i(209988),n=e.i(260218),l=e.i(681622),r=e.i(562918),o=e.i(767467),c=e.i(100559),d=e.i(953700),m=e.i(137340),u=e.i(990336),x=e.i(307858),h=e.i(368942);let p={vision:"bg-blue-500/10 text-blue-600 border-blue-200",reasoning:"bg-purple-500/10 text-purple-600 border-purple-200",embedding:"bg-green-500/10 text-green-600 border-green-200"};function f({providers:e,providerModels:s,onEdit:i,onDelete:l,onAddModel:o}){let d=(0,a.useTranslations)("providers");return(0,t.jsxs)("div",{className:"flex flex-col p-2",children:[e.map(e=>{let a=s.find(t=>t.id===e.id),h=a?.models??[];return(0,t.jsxs)("div",{className:"group rounded-lg px-3 py-2.5 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>i(e),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex size-8 items-center justify-center rounded-lg bg-primary/10",children:(0,t.jsx)(c.Server,{className:"size-4 text-primary"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.apiBase||d("list.noApiBase")})]}),(0,t.jsxs)(r.Badge,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:[h.length," ",d("list.modelsCount")]}),(0,t.jsx)(n.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,t.jsx)(m.Trash2,{className:"size-3 text-destructive"})})]}),h.length>0&&(0,t.jsx)("div",{className:"mt-2 ml-11 flex flex-wrap gap-1",children:h.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] text-muted-foreground",children:[(0,t.jsx)(u.Brain,{className:"size-3"}),e.name,["vision","reasoning","embedding"].map(s=>e[s]?(0,t.jsx)("span",{className:`inline-block rounded px-1 text-[9px] font-medium border ${p[s]}`,children:s[0].toUpperCase()},s):null)]},e.id))}),(0,t.jsxs)(n.Button,{variant:"ghost",size:"xs",className:"mt-1 ml-11 h-6 text-[11px] text-muted-foreground",onClick:t=>{t.stopPropagation(),o(e.name)},children:[(0,t.jsx)(x.ExternalLink,{className:"size-3"}),d("list.addModel")]})]},e.id)}),0===e.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,t.jsx)(c.Server,{className:"size-10 mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm",children:d("list.empty")})]})]})}function g({draft:e,onChange:s}){let i=(0,a.useTranslations)("providers");return(0,t.jsx)("div",{className:"flex flex-col gap-5 p-5",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:i("form.connection")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:i("form.name")}),(0,t.jsx)(l.Input,{value:e.name||"",onChange:e=>s("name",e.target.value),placeholder:i("form.namePlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:i("form.apiBase")}),(0,t.jsx)(l.Input,{value:e.apiBase||"",onChange:e=>s("apiBase",e.target.value),placeholder:i("form.apiBasePlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:i("form.apiKey")}),(0,t.jsx)(l.Input,{type:"password",value:e.apiKey||"",onChange:e=>s("apiKey",e.target.value),placeholder:i("form.apiKeyPlaceholder")})]})]})})}e.s(["ProvidersDialog",0,function({open:e,onOpenChange:l,onAddModel:r,standalone:c}){let m=(0,a.useTranslations)("providers"),u=(0,a.useTranslations)("common"),{models:x,providers:p,ensure:j,addProvider:v,updateProvider:N,removeProvider:y}=(0,h.useLLMStore)(),[b,k]=(0,s.useState)(null),[w,C]=(0,s.useState)(null),[S,T]=(0,s.useState)(!1),[z,D]=(0,s.useState)(!1),[I,P]=(0,s.useState)(null);(0,s.useEffect)(()=>{e&&(T(!0),P(null),j().finally(()=>T(!1)))},[e,j]);let $=()=>{k(null),C(null)},M=()=>{k(null),C({name:"",apiBase:"",apiKey:""})},A=async()=>{if(w&&w.name){D(!0),P(null);try{let e=!b,t=await fetch(e?"/api/providers":`/api/providers/${b.id}`,{method:e?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!t.ok)throw Error();let s=await t.json();e?v(s):N(s),$()}catch{P(m("error.saveFailed"))}finally{D(!1)}}},E=async e=>{if(confirm(m("confirm.delete"))){D(!0);try{if(!(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok)throw Error();y(e),b?.id===e&&$()}catch{P(m("error.deleteFailed"))}finally{D(!1)}}},B=(0,t.jsxs)(t.Fragment,{children:[!c&&(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 py-4",children:[w&&(0,t.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:$,children:(0,t.jsx)(o.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)(i.DialogHeader,{className:"flex-1 space-y-0",children:[(0,t.jsx)(i.DialogTitle,{className:"text-base",children:w?b?m("dialog.editTitle"):m("dialog.addTitle"):m("dialog.title")}),(0,t.jsx)(i.DialogDescription,{className:"text-xs",children:w?m("dialog.editDescription"):m("dialog.listDescription")})]}),!w&&(0,t.jsxs)(n.Button,{variant:"outline",size:"sm",onClick:M,className:"mr-6",children:[(0,t.jsx)(d.Plus,{className:"size-3.5"}),m("dialog.add")]})]}),c&&!w&&(0,t.jsx)("div",{className:"flex items-center justify-end px-5 py-3 border-b",children:(0,t.jsxs)(n.Button,{variant:"outline",size:"sm",onClick:M,children:[(0,t.jsx)(d.Plus,{className:"size-3.5"}),m("dialog.add")]})}),c&&w&&(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,t.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:$,children:(0,t.jsx)(o.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h2",{className:"text-base font-medium truncate",children:b?m("dialog.editTitle"):m("dialog.addTitle")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:m("dialog.editDescription")})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[I&&(0,t.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:I}),S?(0,t.jsx)("div",{className:"py-12 text-center text-sm text-muted-foreground",children:m("dialog.loading")}):w?(0,t.jsx)(g,{draft:w,onChange:(e,t)=>{C(s=>s?{...s,[e]:t}:s)}}):(0,t.jsx)(f,{providers:p,providerModels:p.map(e=>{let t;return{id:e.id,models:(t=e.name,x.filter(e=>e.provider===t))}}),onEdit:e=>{k(e),C({...e})},onDelete:E,onAddModel:e=>{c||l(!1),r(e)}})]}),w&&(0,t.jsxs)("div",{className:"flex justify-end gap-2 border-t px-5 py-3",children:[(0,t.jsx)(n.Button,{variant:"outline",size:"sm",onClick:$,disabled:z,children:u("cancel")}),(0,t.jsx)(n.Button,{size:"sm",onClick:A,disabled:z||!w.name,children:u(z?"saving":"save")})]})]});return c?(0,t.jsx)("div",{className:"h-full flex flex-col",children:B}):(0,t.jsx)(i.Dialog,{open:e,onOpenChange:e=>{e||$(),l(e)},children:(0,t.jsx)(i.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:B})})}])},86477,e=>{"use strict";var t=e.i(344180),s=e.i(764556),a=e.i(244073),i=e.i(209988),n=e.i(260218),l=e.i(681622),r=e.i(607452),o=e.i(562918),c=e.i(226624),d=e.i(767467),m=e.i(990336),u=e.i(953700),x=e.i(137340),h=e.i(368942);let p={vision:"bg-blue-500/10 text-blue-600 border-blue-200",reasoning:"bg-purple-500/10 text-purple-600 border-purple-200",embedding:"bg-green-500/10 text-green-600 border-green-200"},f=[{label:"8K",value:8192},{label:"16K",value:16384},{label:"32K",value:32768},{label:"64K",value:65536},{label:"128K",value:128e3},{label:"200K",value:2e5},{label:"256K",value:256e3},{label:"1M",value:1e6}],g=["low","medium","high"];function j({groups:e,providerNames:s,onEdit:i,onDelete:l}){let r=(0,a.useTranslations)("models"),c=s.length>0?s:["Other"],d=Object.keys(e).sort((e,t)=>{let s=c.indexOf(e),a=c.indexOf(t);return s>=0&&a>=0?s-a:s>=0?-1:a>=0?1:e.localeCompare(t)});return(0,t.jsxs)("div",{className:"flex flex-col p-4 gap-4",children:[d.map(s=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2 px-1",children:s}),(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:e[s].map(e=>{var s;return(0,t.jsxs)("div",{className:"group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>i(e),children:[(0,t.jsx)(m.Brain,{className:"size-4 text-muted-foreground shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground font-mono ml-2",children:e.modelId}),e.cost?(0,t.jsxs)("span",{className:"ml-2 text-[11px] text-muted-foreground font-mono",children:["$",y(e.cost.inputPerMillion),"/$",y(e.cost.outputPerMillion)]}):null,e.maxContextTokens?(0,t.jsxs)("span",{className:"ml-2 text-[11px] text-muted-foreground font-mono",children:[(s=e.maxContextTokens,new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(s))," ",r("list.contextAbbr")]}):null]}),(0,t.jsx)("div",{className:"flex items-center gap-1",children:["vision","reasoning","embedding"].map(s=>e[s]?(0,t.jsx)(o.Badge,{variant:"outline",className:`text-[10px] h-5 px-1.5 ${p[s]}`,children:r(`capability.${s}`)},s):null)}),(0,t.jsx)(n.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,t.jsx)(x.Trash2,{className:"size-3 text-destructive"})})]},e.id)})})]},s)),0===d.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,t.jsx)(m.Brain,{className:"size-10 mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm",children:r("list.empty")})]})]})}function v({draft:e,providerNames:i,onChange:n}){let o=(0,a.useTranslations)("models"),d=(0,s.useRef)(!1),[m,u]=(0,s.useState)(()=>(function(e){if(!e)return f.length;let t=f.findIndex(t=>t.value===e);return t>=0?t:f.length})(e.maxContextTokens)),x=i.length>0?i:["Other"];return(0,t.jsxs)("div",{className:"flex flex-col gap-5 p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.details")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.modelId")}),(0,t.jsx)(l.Input,{value:e.modelId||"",onChange:e=>{let t=e.target.value;n("modelId",t),d.current||n("name",t)},placeholder:o("form.modelIdPlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.displayName")}),(0,t.jsx)(l.Input,{value:e.name||"",onChange:e=>{d.current=!0,n("name",e.target.value)},placeholder:o("form.displayNamePlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.provider")}),(0,t.jsx)("select",{value:e.provider||"Other",onChange:e=>n("provider",e.target.value),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring dark:bg-input/30",children:x.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.context")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.maxContextTokens")}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(r.Slider,{min:0,max:f.length,step:1,value:m,onValueChange:e=>{u(e),e<f.length&&n("maxContextTokens",f[e].value)},className:"flex-1"}),m<f.length?(0,t.jsx)("span",{className:"text-sm tabular-nums min-w-[3.5rem] text-right",children:f[m].label}):(0,t.jsx)(l.Input,{type:"number",min:"1",step:"1",value:e.maxContextTokens??"",onChange:e=>n("maxContextTokens",function(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):void 0}(e.target.value)),placeholder:o("form.customContextPlaceholder"),className:"h-7 w-24 text-sm tabular-nums"})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.thinking")}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-input px-3 py-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:o("form.enableThinking")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:o("form.enableThinkingHelper")})]}),(0,t.jsx)(c.Switch,{checked:e.thinkingEnabled??!0,onCheckedChange:e=>n("thinkingEnabled",e)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.effort")}),(0,t.jsx)("select",{value:e.thinkingEffort||"medium",onChange:e=>n("thinkingEffort",e.target.value),disabled:!(e.thinkingEnabled??!0),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30",children:g.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.cost")}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.inputPerMillion")}),(0,t.jsx)(l.Input,{type:"number",min:"0",step:"0.0001",value:e.cost?.inputPerMillion??0,onChange:t=>n("cost",{inputPerMillion:N(t.target.value),outputPerMillion:e.cost?.outputPerMillion??0}),placeholder:o("form.costPlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.outputPerMillion")}),(0,t.jsx)(l.Input,{type:"number",min:"0",step:"0.0001",value:e.cost?.outputPerMillion??0,onChange:t=>n("cost",{inputPerMillion:e.cost?.inputPerMillion??0,outputPerMillion:N(t.target.value)}),placeholder:o("form.costPlaceholder")})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.capabilities")}),(0,t.jsx)("div",{className:"flex items-center gap-1.5",children:["vision","reasoning","embedding"].map(s=>{let a=!!e[s];return(0,t.jsx)("button",{type:"button",onClick:()=>n(s,!a),className:`rounded-md border px-2 py-1 text-xs font-medium transition-colors cursor-pointer
2
+ ${a?p[s]:"text-muted-foreground border-input hover:bg-muted/50"}`,children:o(`capability.${s}`)},s)})})]})]})}function N(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:0}function y(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:4}).format(e)}e.s(["ModelsDialog",0,function({open:e,onOpenChange:l,initialProvider:r,standalone:o}){let c=(0,a.useTranslations)("models"),m=(0,a.useTranslations)("common"),{models:x,providers:p,ensure:f,addModel:g,updateModel:N,removeModel:y}=(0,h.useLLMStore)(),b=p.map(e=>e.name),[k,w]=(0,s.useState)(null),[C,S]=(0,s.useState)(null),[T,z]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[P,$]=(0,s.useState)(null),M=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!e){M.current=!1;return}queueMicrotask(()=>{z(!0),$(null)}),f().finally(()=>z(!1))},[e,f]),(0,s.useEffect)(()=>{e&&r&&!C&&!M.current&&(M.current=!0,queueMicrotask(()=>{w(null),S({modelId:"",name:"",provider:r,cost:{inputPerMillion:0,outputPerMillion:0},maxContextTokens:128e3,thinkingEnabled:!0,thinkingEffort:"medium",vision:!1,reasoning:!1,embedding:!1})}))},[e,r,C]);let A=()=>{w(null),S(null)},E=()=>{w(null),S({modelId:"",name:"",provider:"Other",cost:{inputPerMillion:0,outputPerMillion:0},maxContextTokens:128e3,thinkingEnabled:!0,thinkingEffort:"medium",vision:!1,reasoning:!1,embedding:!1})},B=async()=>{if(C&&C.modelId&&C.name){I(!0),$(null);try{let e=!k,t=await fetch(e?"/api/models":`/api/models/${k.id}`,{method:e?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)});if(!t.ok)throw Error();let s=await t.json();e?g(s):N(s),A()}catch{$(c("error.saveFailed"))}finally{I(!1)}}},O=async e=>{if(confirm(c("confirm.delete"))){I(!0);try{if(!(await fetch(`/api/models/${e}`,{method:"DELETE"})).ok)throw Error();y(e),k?.id===e&&A()}catch{$(c("error.deleteFailed"))}finally{I(!1)}}},L=function(e){let t={};for(let s of e){let e=s.provider||"Other";(t[e]??=[]).push(s)}return t}(x),U=(0,t.jsxs)(t.Fragment,{children:[!o&&(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 py-4",children:[C&&(0,t.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:A,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)(i.DialogHeader,{className:"flex-1 space-y-0",children:[(0,t.jsx)(i.DialogTitle,{className:"text-base",children:C?k?c("dialog.editTitle"):c("dialog.addTitle"):c("dialog.title")}),(0,t.jsx)(i.DialogDescription,{className:"text-xs",children:C?c("dialog.editDescription"):c("dialog.listDescription")})]}),!C&&(0,t.jsxs)(n.Button,{variant:"outline",size:"sm",onClick:E,className:"mr-6",children:[(0,t.jsx)(u.Plus,{className:"size-3.5"}),c("dialog.add")]})]}),o&&!C&&(0,t.jsx)("div",{className:"flex items-center justify-end px-5 py-3 border-b",children:(0,t.jsxs)(n.Button,{variant:"outline",size:"sm",onClick:E,children:[(0,t.jsx)(u.Plus,{className:"size-3.5"}),c("dialog.add")]})}),o&&C&&(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,t.jsx)(n.Button,{variant:"ghost",size:"icon-sm",onClick:A,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h2",{className:"text-base font-medium truncate",children:k?c("dialog.editTitle"):c("dialog.addTitle")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c("dialog.editDescription")})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[P&&(0,t.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:P}),T?(0,t.jsx)("div",{className:"py-12 text-center text-sm text-muted-foreground",children:c("dialog.loading")}):C?(0,t.jsx)(v,{draft:C,providerNames:b,onChange:(e,t)=>{S(s=>s?{...s,[e]:t}:s)}}):(0,t.jsx)(j,{groups:L,providerNames:b,onEdit:e=>{w(e),S({...e,thinkingEnabled:e.thinkingEnabled??!0,thinkingEffort:e.thinkingEffort??"medium"})},onDelete:O})]}),C&&(0,t.jsxs)("div",{className:"flex justify-end gap-2 border-t px-5 py-3",children:[(0,t.jsx)(n.Button,{variant:"outline",size:"sm",onClick:A,disabled:D,children:m("cancel")}),(0,t.jsx)(n.Button,{size:"sm",onClick:B,disabled:D||!C.modelId||!C.name,children:m(D?"saving":"save")})]})]});return o?(0,t.jsx)("div",{className:"h-full flex flex-col",children:U}):(0,t.jsx)(i.Dialog,{open:e,onOpenChange:e=>{e||A(),l(e)},children:(0,t.jsx)(i.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:U})})}])},515104,e=>{"use strict";function t(){return"tauri.localhost"===window.location.hostname||"__TAURI_INTERNALS__"in window}function s(){return t()&&"u">typeof navigator&&/android/i.test(navigator.userAgent)}async function a(){return t()?c():"Notification"in window?o(Notification.permission):"unsupported"}async function i(){return t()?d():r()}async function n(e,s,a={}){var i,l;return t()?m(e,s,a):(i=e,l=s,void("Notification"in window&&"granted"===Notification.permission&&new Notification(i,{body:l,icon:"/favicon.ico"})))}async function l(e){if(s())return n("Agent Spaces",e,{id:10001,ongoing:!0})}async function r(){return"Notification"in window?o(await Notification.requestPermission()):"unsupported"}function o(e){switch(e){case"granted":return"granted";case"denied":return"denied";default:return"default"}}async function c(){try{let{isPermissionGranted:t}=await e.A(678001);return await t()?"granted":"default"}catch{return"unsupported"}}async function d(){try{let{requestPermission:t,isPermissionGranted:s}=await e.A(678001),a=await t();if("granted"===a||await s())return"granted";return"denied"}catch{return"unsupported"}}async function m(t,s,a={}){try{let{sendNotification:i,isPermissionGranted:n}=await e.A(678001);if(!await n())return;i({title:t,body:s,...a})}catch{}}e.s(["getNotificationPermission",0,a,"isTauriAndroidEnvironment",0,s,"isTauriEnvironment",0,t,"requestNotificationPermission",0,i,"sendAndroidOngoingTaskNotification",0,l,"sendNativeNotification",0,n])},437122,233297,286117,e=>{"use strict";var t=e.i(523592);function s(e){let[t,s=""]=e.split("#",2),[a,i=""]=t.split("?",2);if(!a.startsWith("/")||a.startsWith("/api/"))return e;if("/"===a)return`/${i?`?${i}`:""}${s?`#${s}`:""}`;if(a.startsWith("/workspace/")){let e=a.slice(11).split("/")[0],t=new URLSearchParams(i);return t.set("workspaceId",e),`/workspace/_.html${t.toString()?`?${t.toString()}`:""}${s?`#${s}`:""}`}let n=a.endsWith(".html")?a:`${a}.html`;return`${n}${i?`?${i}`:""}${s?`#${s}`:""}`}function a(e){return"/index.html"===e?"/":e.endsWith(".html")?e.slice(0,-5):e}function i(e){return"/login"===a(e)}e.i(8890),e.i(515104),e.s(["tauriNavigate",0,function(e,t,a=!1){t=s(t),a?window.location.replace(t):window.location.href=t},"toStaticHref",0,s],233297),e.s(["isLoginPath",0,i,"isWorkspacePath",0,function(e){return a(e).startsWith("/workspace/")},"workspaceIdFromLocation",0,function(e,t){let s=new URLSearchParams(t).get("workspaceId");if(s)return s;let i=a(e).match(/^\/workspace\/([^/]+)/);return i?.[1]??null}],286117);let n="agent-spaces-token",l="agent-spaces-auth-verified";function r(){let e=localStorage.getItem(n);if(null!==e)return e;let s=(0,t.getActiveServer)()?.secret;return void 0!==s?s:null}function o(){localStorage.removeItem(n),localStorage.removeItem(l)}function c(){let e=r();return null===e?{}:{Authorization:`Bearer ${e}`}}async function d(e,a){let n=function(e){if("string"!=typeof e||e.startsWith("http"))return e;let s=(0,t.getActiveServerUrl)();return s?`${s}${e.startsWith("/")?"":"/"}${e}`:e}(e),l={...c(),...a?.headers},r=await fetch(n,{...a,headers:l});return(401===r.status||403===r.status)&&(o(),i(window.location.pathname)||window.location.replace(s("/login"))),r}e.s(["authHeaders",0,c,"fetchWithAuth",0,d,"getToken",0,r,"isAuthenticated",0,function(){return"1"===localStorage.getItem(l)},"removeToken",0,o,"setToken",0,function(e){localStorage.setItem(n,e),localStorage.setItem(l,"1")}],437122)},962562,995684,e=>{"use strict";let t=(0,e.i(433721).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);e.s(["default",0,t],995684),e.s(["Pencil",0,t],962562)},210,e=>{"use strict";let t=(0,e.i(433721).default)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);e.s(["Settings2",0,t],210)},894920,e=>{"use strict";var t=e.i(344180),s=e.i(764556),a=e.i(209988),i=e.i(260218),n=e.i(681622),l=e.i(788010),r=e.i(344118),o=e.i(962562),c=e.i(953700),d=e.i(100559),m=e.i(137340);let u=(0,e.i(433721).default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);var x=e.i(244073);e.s(["ServerManagerDialog",0,function({open:e,onOpenChange:h,servers:p,activeId:f,onUpdate:g,onRemove:j,onSwitch:v}){let N=(0,x.useTranslations)("sidebar"),y=(0,x.useTranslations)("common"),[b,k]=s.useState(null),[w,C]=s.useState(""),[S,T]=s.useState(""),[z,D]=s.useState(""),[I,P]=s.useState(""),[$,M]=s.useState(""),[A,E]=s.useState(""),[B,O]=s.useState(""),[L,U]=s.useState(null),_=()=>{k(null),C(""),T(""),D("")},F=()=>{if(!w.trim()||!S.trim())return;let e=S.trim().replace(/\/$/,"");/^https?:\/\//.test(e)||(e="http://"+e),g(p.map(t=>t.id===b?{...t,name:w.trim(),url:e,secret:z.trim()||void 0}:t)),_()},R=s.useCallback(e=>{console.log(`[server-diagnostic] ${e}`),O(t=>`${t}${t?"\n":""}${e}`)},[]),H=async e=>{U(e.id),O("");let t=e.url.replace(/\/$/,""),s=`${t}/api/health`,a=new URL("/ws",t);a.protocol="https:"===a.protocol?"wss:":"ws:",a.searchParams.set("workspaceId","__diagnostic__"),a.searchParams.set("token",e.secret||"__diagnostic__"),R(`time: ${new Date().toISOString()}`),R(`window.origin: ${window.location.origin}`),R(`window.href: ${window.location.href}`),R(`navigator.onLine: ${navigator.onLine}`),R(`target: ${t}`),R(`health: ${s}`);let i=performance.now();try{let e=new AbortController,t=window.setTimeout(()=>e.abort(),1e4),a=await fetch(s,{method:"GET",cache:"no-store",mode:"cors",signal:e.signal});window.clearTimeout(t);let n=await a.text();R(`fetch /api/health: OK ${a.status} ${a.statusText} (${Math.round(performance.now()-i)}ms)`),R(`fetch response: ${n.slice(0,500)||"<empty>"}`)}catch(t){let e=t instanceof Error?t:Error(String(t));R(`fetch /api/health: FAILED ${e.name}: ${e.message} (${Math.round(performance.now()-i)}ms)`)}R(`websocket: ${a.toString()}`),await new Promise(e=>{let t=performance.now(),s=!1,i=(a,i)=>{if(!s){s=!0,R(`${a} (${Math.round(performance.now()-t)}ms)`);try{i?.close()}catch{}e()}};try{let e=new WebSocket(a.toString()),t=window.setTimeout(()=>i("websocket: TIMEOUT",e),1e4);e.onopen=()=>{window.clearTimeout(t),i("websocket: OPEN",e)},e.onerror=()=>{window.clearTimeout(t),i("websocket: ERROR",e)},e.onclose=s=>{window.clearTimeout(t),i(`websocket: CLOSE code=${s.code} reason=${s.reason||"<empty>"}`,e)}}catch(t){let e=t instanceof Error?t:Error(String(t));i(`websocket: FAILED ${e.name}: ${e.message}`)}}),U(null)};return(0,t.jsx)(a.Dialog,{open:e,onOpenChange:e=>{h(e),e||_()},children:(0,t.jsxs)(a.DialogContent,{className:"max-w-md",children:[(0,t.jsxs)(a.DialogHeader,{children:[(0,t.jsx)(a.DialogTitle,{children:N("server.manageServers")}),(0,t.jsx)(a.DialogDescription,{children:N("server.manageDescription")})]}),(0,t.jsx)("div",{className:"space-y-1",children:p.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2",children:[(0,t.jsx)(d.Server,{className:"size-4 shrink-0 text-muted-foreground"}),b===e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.Input,{className:"h-7 text-sm flex-1",value:w,onChange:e=>C(e.target.value),placeholder:"Name",autoFocus:!0}),(0,t.jsx)(n.Input,{className:"h-7 text-sm flex-[1.5]",value:S,onChange:e=>T(e.target.value),placeholder:"http://...",onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(i.Button,{size:"sm",variant:"ghost",onClick:F,className:"h-7 px-2",children:y("save")}),(0,t.jsx)(i.Button,{size:"sm",variant:"ghost",onClick:_,className:"h-7 px-2",children:y("cancel")})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>{e.id!==f&&v(e)},children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.url})]}),e.id===f?(0,t.jsx)(r.Check,{className:"size-4 shrink-0 text-primary"}):(0,t.jsx)(i.Button,{size:"sm",variant:"ghost",onClick:()=>v(e),className:"h-7 px-2 text-xs shrink-0",children:N("server.switch")}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u,{className:"size-3.5 shrink-0 text-muted-foreground cursor-pointer hover:text-foreground",onClick:()=>H(e)}),(0,t.jsx)(o.Pencil,{className:"size-3.5 shrink-0 text-muted-foreground cursor-pointer hover:text-foreground",onClick:()=>{k(e.id),C(e.name),T(e.url),D(e.secret||"")}}),"default"!==e.id&&(0,t.jsx)(m.Trash2,{className:"size-3.5 shrink-0 text-muted-foreground cursor-pointer hover:text-destructive",onClick:()=>j(e.id)})]})]})]},e.id))}),null===b&&(0,t.jsxs)("div",{className:"border-t pt-3 mt-2 space-y-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground mb-2",children:N("server.newServer")}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(n.Input,{className:"h-8 text-sm",value:I,onChange:e=>P(e.target.value),placeholder:"Name"}),(0,t.jsx)(i.Button,{size:"sm",onClick:()=>{if(!I.trim()||!$.trim())return;let e=$.trim().replace(/\/$/,"");/^https?:\/\//.test(e)||(e="http://"+e),g([...p,{id:Date.now().toString(),name:I.trim(),url:e,secret:A.trim()||void 0}]),P(""),M(""),E("")},disabled:!I.trim()||!$.trim(),children:(0,t.jsx)(c.Plus,{className:"size-4"})})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(n.Input,{className:"h-8 text-sm flex-1",value:$,onChange:e=>M(e.target.value),placeholder:"http://..."})}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(n.Input,{className:"h-8 text-sm flex-1",type:"password",value:A,onChange:e=>E(e.target.value),placeholder:N("server.secretOptionalPlaceholder"),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})})]}),(0,t.jsxs)("div",{className:"border-t pt-3 mt-2 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Network diagnostics"}),(0,t.jsx)(i.Button,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",disabled:!p.find(e=>e.id===f)||null!==L,onClick:()=>{let e=p.find(e=>e.id===f);e&&H(e)},children:L?"Testing...":"Test active"})]}),(0,t.jsx)(l.Textarea,{readOnly:!0,value:B||"Tap the Wi-Fi icon next to a server, or use Test active.",className:"h-36 resize-none font-mono text-[11px]"})]})]})})}],894920)},111343,e=>{"use strict";let t=(0,e.i(433721).default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);e.s(["Save",0,t],111343)},255742,973767,401058,977694,e=>{"use strict";var t=e.i(433721);let s=(0,t.default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);e.s(["Star",0,s],255742);let a=(0,t.default)("star-off",[["path",{d:"m10.344 4.688 1.181-2.393a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.237 3.152",key:"19ctli"}],["path",{d:"m17.945 17.945.43 2.505a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a8 8 0 0 0 .4-.099",key:"ptqqvy"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);e.s(["StarOff",0,a],973767);let i=(0,t.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);e.s(["MoreVertical",0,i],401058);let n=(0,t.default)("rocket",[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]]);e.s(["Rocket",0,n],977694)},22906,191202,e=>{"use strict";var t=e.i(344180),s=e.i(764556),a=e.i(244073),i=e.i(887836),n=e.i(209988),l=e.i(260218),r=e.i(681622),o=e.i(788010),c=e.i(191118),d=e.i(917955),m=e.i(996652),u=e.i(188815),x=e.i(611176),h=e.i(255742),p=e.i(973767),f=e.i(129981),g=e.i(887354);let j=(0,e.i(433721).default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]);e.s(["Plug",0,j],191202);var v=e.i(972846),N=e.i(401058),y=e.i(137340),b=e.i(977694),k=e.i(111343),w=e.i(465458);e.i(462506);let C=(0,i.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});e.s(["McpsDialog",0,function({open:e,onOpenChange:i,standalone:S}){let T=(0,a.useTranslations)("mcps"),z=(0,a.useTranslations)("common"),[D,I]=(0,s.useState)([]),[P,$]=(0,s.useState)([]),[M,A]=(0,s.useState)(!1),[E,B]=(0,s.useState)(""),[O,L]=(0,s.useState)("all"),[U,_]=(0,s.useState)(""),[F,R]=(0,s.useState)(!1),[H,W]=(0,s.useState)(""),[K,J]=(0,s.useState)(""),[q,V]=(0,s.useState)(null),[G,X]=(0,s.useState)([]),[Y,Z]=(0,s.useState)(null),[Q,ee]=(0,s.useState)(""),et=(0,s.useCallback)(async()=>{A(!0);try{let e=await fetch("/api/mcps");e.ok&&I(await e.json())}catch{}A(!1)},[]),es=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/agents/presets");if(e.ok){let t=await e.json();$(t.map(e=>({id:e.id,name:e.name,avatarUrl:e.avatarUrl,description:e.description})))}}catch{}},[]);(0,s.useEffect)(()=>{(e||S)&&(et(),es())},[e,S,et,es]);let ea=async e=>{try{let t=await fetch(`/api/mcps/${encodeURIComponent(e.name)}/favorite`,{method:"POST"});if(t.ok){let{favorited:s}=await t.json();I(t=>t.map(t=>t.name===e.name?{...t,favorited:s}:t))}}catch{}},ei=async()=>{J("");try{JSON.parse(H)}catch{J(T("importInvalidJson"));return}try{let e=await fetch("/api/mcps/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonText:H})});if(e.ok)W(""),R(!1),et();else{let t=await e.json();J(t.error||T("importFailed"))}}catch{J(T("importFailed"))}},en=async()=>{let e;if(Y){try{e=JSON.parse(Q)}catch{return}try{(await fetch(`/api/mcps/${encodeURIComponent(Y.name)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:e})})).ok&&(I(t=>t.map(t=>t.name===Y.name?{...t,config:e}:t)),Z(null))}catch{}}},el=async e=>{try{(await fetch(`/api/mcps/${encodeURIComponent(e.name)}`,{method:"DELETE"})).ok&&I(t=>t.filter(t=>t.name!==e.name))}catch{}},er=async()=>{if(q){for(let e of P){let t=q.boundAgents.some(t=>t.id===e.id),s=G.includes(e.id);if(t&&!s){let t=await fetch(`/api/agents/presets/${e.id}`);if(!t.ok)continue;let s=await t.json(),a=s.mcps||{},i={...a.mcpServers||{}};delete i[q.name],await fetch(`/api/agents/presets/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,mcps:{...a,mcpServers:i}})})}else if(!t&&s){let t=await fetch(`/api/agents/presets/${e.id}`);if(!t.ok)continue;let s=await t.json(),a=s.mcps||{},i={...a.mcpServers||{}};q.name in i||(i[q.name]=q.config,await fetch(`/api/agents/presets/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,mcps:{...a,mcpServers:i}})}))}}V(null),et()}},eo=e=>{X(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},ec=D.filter(e=>{if(E){let t=E.toLowerCase();if(!e.name.toLowerCase().includes(t)&&!e.description.toLowerCase().includes(t))return!1}return("favorites"!==O||!!e.favorited)&&("agent"!==O||!U||!!e.boundAgents.some(e=>e.id===U))}),ed=(S||e)&&!q&&!Y,em=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-end pr-8 pt-2",children:[(0,t.jsxs)("div",{className:"hidden md:block",children:[S?(0,t.jsx)("h2",{className:"text-base font-semibold",children:T("title")}):(0,t.jsx)(n.DialogTitle,{children:T("title")}),S?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:T("description")}):(0,t.jsx)(n.DialogDescription,{children:T("description")})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)(m.Popover,{open:F,onOpenChange:R,children:[(0,t.jsx)(m.PopoverTrigger,{render:(0,t.jsxs)(l.Button,{variant:"outline",size:"sm",children:[(0,t.jsx)(f.Upload,{className:"size-3.5 mr-1"}),T("import")]})}),(0,t.jsx)(m.PopoverContent,{className:"w-96",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:T("importTitle")}),(0,t.jsx)(o.Textarea,{value:H,onChange:e=>{W(e.target.value),J("")},placeholder:'{\n "mcpServers": {\n "server-name": {\n "command": "npx",\n "args": ["-y", "package"],\n "env": {}\n }\n }\n}',className:"font-mono text-xs min-h-[180px] resize-none"}),K&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:K}),(0,t.jsx)(l.Button,{size:"sm",onClick:ei,disabled:!H.trim(),className:"w-full",children:T("importConfirm")})]})})]})})]})}),(0,t.jsxs)("div",{className:"flex flex-1 min-h-0 gap-4 pt-2",children:[(0,t.jsxs)("div",{className:"hidden md:flex w-44 shrink-0 flex-col gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)(l.Button,{variant:"all"===O?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{L("all"),_("")},children:[(0,t.jsx)(j,{className:"size-3.5 mr-1.5"}),T("filterAll")]}),(0,t.jsxs)(l.Button,{variant:"favorites"===O?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{L("favorites"),_("")},children:[(0,t.jsx)(h.Star,{className:"size-3.5 mr-1.5"}),T("filterFavorites")]})]}),P.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground px-2",children:T("filterByAgent")}),(0,t.jsx)(c.ScrollArea,{className:"max-h-48",children:P.map(e=>(0,t.jsxs)(l.Button,{variant:"agent"===O&&U===e.id?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{L("agent"),_(e.id)},children:[(0,t.jsx)(x.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-4 mr-1.5 rounded-full"}),(0,t.jsx)("span",{className:"truncate",children:e.name})]},e.id))})]})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex md:hidden flex-col gap-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(g.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(r.Input,{value:E,onChange:e=>B(e.target.value),placeholder:T("search"),className:"pl-8"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex rounded-lg border border-input p-0.5",children:[(0,t.jsx)("button",{type:"button",className:(0,w.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors","all"===O?"bg-muted":"text-muted-foreground hover:text-foreground"),onClick:()=>{L("all"),_("")},children:T("filterAll")}),(0,t.jsxs)("button",{type:"button",className:(0,w.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors","favorites"===O?"bg-muted":"text-muted-foreground hover:text-foreground"),onClick:()=>{L("favorites"),_("")},children:[(0,t.jsx)(h.Star,{className:"size-3 inline-block mr-0.5 -mt-px"}),T("filterFavorites")]})]}),P.length>0&&(0,t.jsx)(u.SearchSelect,{value:"agent"===O?U:"",onChange:e=>{e?(L("agent"),_(e)):(L("all"),_(""))},options:P.map(e=>({value:e.id,label:e.name})),placeholder:T("filterByAgent"),allowCustom:!1,className:"flex-1 min-w-0"})]})]}),(0,t.jsxs)("div",{className:"hidden md:block relative",children:[(0,t.jsx)(g.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(r.Input,{value:E,onChange:e=>B(e.target.value),placeholder:T("search"),className:"pl-8"})]}),(0,t.jsx)(c.ScrollArea,{className:"flex-1",children:M?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:z("loading")}):0===ec.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:T("empty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 pr-2",children:ec.map(e=>(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{Z(e),ee(JSON.stringify(e.config,null,2))},children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(j,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium text-sm",children:e.name}),(0,t.jsx)("button",{type:"button",className:"flex items-center justify-center size-5 rounded hover:bg-accent",onClick:t=>{t.stopPropagation(),ea(e)},children:e.favorited?(0,t.jsx)(h.Star,{className:"size-3.5 text-yellow-500 fill-yellow-500"}):(0,t.jsx)(p.StarOff,{className:"size-3.5 text-muted-foreground"})})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.description||e.config.command||e.config.url||JSON.stringify(e.config).slice(0,100)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)(l.Button,{variant:"outline",size:"sm",onClick:()=>{V(e),X(e.boundAgents.map(e=>e.id))},children:[(0,t.jsx)(b.Rocket,{className:"size-3.5 mr-1"}),T("apply")]}),(0,t.jsxs)(d.DropdownMenu,{children:[(0,t.jsx)(d.DropdownMenuTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",className:"size-7"}),children:(0,t.jsx)(N.MoreVertical,{className:"size-3.5"})}),(0,t.jsx)(d.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(d.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>el(e),children:[(0,t.jsx)(y.Trash2,{className:"size-3.5 mr-1.5"}),T("delete")]})})]})]})]}),e.boundAgents.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-2.5 pt-2.5 border-t border-border/50",children:[e.boundAgents.map(e=>(0,t.jsx)(x.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-5 rounded-full"},e.id)),(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:e.boundAgents.length})]})]},e.name))})})]})]})]});return(0,t.jsxs)(t.Fragment,{children:[S&&ed&&(0,t.jsx)("div",{className:"h-full flex flex-col",children:em}),!S&&(0,t.jsx)(n.Dialog,{open:ed,onOpenChange:i,children:(0,t.jsx)(n.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:em})}),(0,t.jsx)(n.Dialog,{open:!!Y,onOpenChange:e=>{e||Z(null)},children:(0,t.jsxs)(n.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:[(0,t.jsx)(n.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(n.DialogTitle,{children:T("editTitle",{name:Y?.name||""})}),(0,t.jsx)(n.DialogDescription,{children:T("editDescription")})]}),(0,t.jsxs)(l.Button,{size:"sm",onClick:en,children:[(0,t.jsx)(k.Save,{className:"size-3.5 mr-1"}),z("save")]})]})}),(0,t.jsx)("div",{className:"flex-1 min-h-0 pt-2",children:(0,t.jsx)(C,{height:"100%",language:"json",value:Q,onChange:e=>ee(e||""),theme:"vs-dark",options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter",wordWrap:"on",formatOnPaste:!0}})})]})}),(0,t.jsx)(n.Dialog,{open:!!q,onOpenChange:e=>{e||V(null)},children:(0,t.jsxs)(n.DialogContent,{className:"sm:max-w-sm",children:[(0,t.jsxs)(n.DialogHeader,{children:[(0,t.jsx)(n.DialogTitle,{children:T("bindTitle",{name:q?.name||""})}),(0,t.jsx)(n.DialogDescription,{children:T("bindDescription")})]}),(0,t.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,t.jsx)("div",{className:"max-h-52 overflow-y-auto space-y-0.5",children:P.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>eo(e.id),className:(0,w.cn)("flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors"),children:[(0,t.jsx)(x.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.name}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:(0,w.cn)("flex items-center justify-center size-4 rounded border shrink-0",G.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input")})]},e.id))}),G.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:G.map(e=>{let s=P.find(t=>t.id===e);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:[(0,t.jsx)(x.AgentIcon,{agentId:e,name:s?.name,className:"size-3.5 rounded-full"}),s?.name||e,(0,t.jsx)("button",{type:"button",onClick:()=>eo(e),className:"hover:text-destructive",children:(0,t.jsx)(v.X,{className:"size-3"})})]},e)})}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,t.jsx)(l.Button,{variant:"outline",onClick:()=>V(null),children:z("cancel")}),(0,t.jsx)(l.Button,{onClick:er,children:z("confirm")})]})]})]})})]})}],22906)},625873,e=>{"use strict";var t=e.i(344180),s=e.i(764556),a=e.i(244073),i=e.i(887836),n=e.i(209988),l=e.i(260218),r=e.i(681622),o=e.i(191118),c=e.i(917955),d=e.i(996652),m=e.i(460578),u=e.i(188815),x=e.i(611176),h=e.i(255742),p=e.i(973767),f=e.i(129981),g=e.i(887354),j=e.i(989484),v=e.i(972846),N=e.i(401058),y=e.i(137340),b=e.i(977694),k=e.i(111343),w=e.i(601039),C=e.i(465458);e.i(462506);let S=(0,i.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});e.s(["SkillsDialog",0,function({open:e,onOpenChange:i,standalone:T}){let z=(0,a.useTranslations)("skills"),D=(0,a.useTranslations)("common"),[I,P]=(0,s.useState)([]),[$,M]=(0,s.useState)([]),[A,E]=(0,s.useState)(!1),[B,O]=(0,s.useState)(""),[L,U]=(0,s.useState)("all"),[_,F]=(0,s.useState)(""),[R,H]=(0,s.useState)(!1),[W,K]=(0,s.useState)([]),[J,q]=(0,s.useState)(null),[V,G]=(0,s.useState)([]),[X,Y]=(0,s.useState)(null),[Z,Q]=(0,s.useState)(""),[ee,et]=(0,s.useState)([]),[es,ea]=(0,s.useState)(new Set),[ei,en]=(0,s.useState)(!1),[el,er]=(0,s.useState)(!1),eo=(0,s.useCallback)(async()=>{E(!0);try{let e=await fetch("/api/skills");e.ok&&P(await e.json())}catch{}E(!1)},[]),ec=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/agents/presets");if(e.ok){let t=await e.json();M(t.map(e=>({id:e.id,name:e.name,avatarUrl:e.avatarUrl,description:e.description})))}}catch{}},[]);(0,s.useEffect)(()=>{(e||T)&&(eo(),ec())},[e,T,eo,ec]);let ed=async e=>{try{let t=await fetch(`/api/skills/${encodeURIComponent(e.name)}/favorite`,{method:"POST"});if(t.ok){let{favorited:s}=await t.json();P(t=>t.map(t=>t.name===e.name?{...t,favorited:s}:t))}}catch{}},em=async()=>{for(let e of W){let t=await e.file.text();await fetch("/api/skills/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:e.file.name,content:t})})}K([]),H(!1),eo()},eu=async()=>{if(X)try{(await fetch(`/api/skills/${encodeURIComponent(X.name)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:Z})})).ok&&(P(e=>e.map(e=>e.name===X.name?{...e,content:Z}:e)),Y(null))}catch{}},ex=async e=>{try{(await fetch(`/api/skills/${encodeURIComponent(e.name)}`,{method:"DELETE"})).ok&&P(t=>t.filter(t=>t.name!==e.name))}catch{}},eh=async()=>{if(J){for(let e of $){let t=J.boundAgents.some(t=>t.id===e.id),s=V.includes(e.id);if(t&&!s){let t=await fetch(`/api/agents/presets/${e.id}`);if(!t.ok)continue;let s=await t.json(),a=(s.skills||[]).filter(e=>e.replace(/\.md$/i,"")!==J.name);console.log("[skills] remove skill",J.name,"from agent",e.name,"updatedSkills:",a),await fetch(`/api/agents/presets/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,skills:a})})}else if(!t&&s){let t=await fetch(`/api/agents/presets/${e.id}`);if(!t.ok)continue;let s=await t.json();if(!(s.skills||[]).map(e=>e.replace(/\.md$/i,"")).includes(J.name)){let t=[...s.skills||[],`${J.name}.md`];console.log("[skills] add skill",J.name,"to agent",e.name,"updatedSkills:",t),await fetch(`/api/agents/presets/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,skills:t})})}}}q(null),eo()}},ep=e=>{G(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},ef=async()=>{er(!0);try{let e=await fetch("/api/skills/sync-check");if(e.ok){let t=await e.json();et(t),ea(new Set(t.map(e=>`${e.agentId}::${e.skillName}`))),en(!0)}}catch{}er(!1)},eg=async()=>{let e=ee.filter(e=>es.has(`${e.agentId}::${e.skillName}`));if(0!==e.length)try{(await fetch("/api/skills/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:e.map(e=>({agentId:e.agentId,skillName:e.skillName}))})})).ok&&(en(!1),eo())}catch{}},ej=I.filter(e=>{if(B){let t=B.toLowerCase();if(!e.name.toLowerCase().includes(t)&&!e.content.toLowerCase().includes(t))return!1}return("favorites"!==L||!!e.favorited)&&("agent"!==L||!_||!!e.boundAgents.some(e=>e.id===_))}),ev=(T||e)&&!J&&!X,eN=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,t.jsxs)("div",{className:"hidden md:block",children:[T?(0,t.jsx)("h2",{className:"text-base font-semibold",children:z("title")}):(0,t.jsx)(n.DialogTitle,{children:z("title")}),T?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:z("description")}):(0,t.jsx)(n.DialogDescription,{children:z("description")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-auto shrink-0 pt-2",children:[(0,t.jsxs)(l.Button,{variant:"outline",size:"sm",onClick:ef,disabled:el,children:[(0,t.jsx)(w.RefreshCw,{className:(0,C.cn)("size-3.5 mr-1",el&&"animate-spin")}),z("syncToAgents")]}),(0,t.jsxs)(d.Popover,{open:R,onOpenChange:H,children:[(0,t.jsx)(d.PopoverTrigger,{render:(0,t.jsxs)(l.Button,{variant:"outline",size:"sm",children:[(0,t.jsx)(f.Upload,{className:"size-3.5 mr-1"}),z("import")]})}),(0,t.jsx)(d.PopoverContent,{className:"w-80",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:z("importTitle")}),(0,t.jsx)(m.FileUpload,{value:W,onChange:K,accept:{"text/markdown":[".md"],"":[".md"]},placeholder:z("importPlaceholder"),maxFiles:10}),(0,t.jsx)(l.Button,{size:"sm",onClick:em,disabled:0===W.length,className:"w-full",children:z("importConfirm")})]})})]})]})]})}),(0,t.jsxs)("div",{className:"flex flex-1 min-h-0 gap-4 pt-2",children:[(0,t.jsxs)("div",{className:"hidden md:flex w-44 shrink-0 flex-col gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)(l.Button,{variant:"all"===L?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{U("all"),F("")},children:[(0,t.jsx)(j.FileText,{className:"size-3.5 mr-1.5"}),z("filterAll")]}),(0,t.jsxs)(l.Button,{variant:"favorites"===L?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{U("favorites"),F("")},children:[(0,t.jsx)(h.Star,{className:"size-3.5 mr-1.5"}),z("filterFavorites")]})]}),$.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground px-2",children:z("filterByAgent")}),(0,t.jsx)(o.ScrollArea,{className:"max-h-48",children:$.map(e=>(0,t.jsxs)(l.Button,{variant:"agent"===L&&_===e.id?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{U("agent"),F(e.id)},children:[(0,t.jsx)(x.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-4 mr-1.5 rounded-full"}),(0,t.jsx)("span",{className:"truncate",children:e.name})]},e.id))})]})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex md:hidden flex-col gap-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(g.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(r.Input,{value:B,onChange:e=>O(e.target.value),placeholder:z("search"),className:"pl-8"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex rounded-lg border border-input p-0.5",children:[(0,t.jsx)("button",{type:"button",className:(0,C.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors","all"===L?"bg-muted":"text-muted-foreground hover:text-foreground"),onClick:()=>{U("all"),F("")},children:z("filterAll")}),(0,t.jsxs)("button",{type:"button",className:(0,C.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors","favorites"===L?"bg-muted":"text-muted-foreground hover:text-foreground"),onClick:()=>{U("favorites"),F("")},children:[(0,t.jsx)(h.Star,{className:"size-3 inline-block mr-0.5 -mt-px"}),z("filterFavorites")]})]}),$.length>0&&(0,t.jsx)(u.SearchSelect,{value:"agent"===L?_:"",onChange:e=>{e?(U("agent"),F(e)):(U("all"),F(""))},options:$.map(e=>({value:e.id,label:e.name})),placeholder:z("filterByAgent"),allowCustom:!1,className:"flex-1 min-w-0"})]})]}),(0,t.jsxs)("div",{className:"hidden md:block relative",children:[(0,t.jsx)(g.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(r.Input,{value:B,onChange:e=>O(e.target.value),placeholder:z("search"),className:"pl-8"})]}),(0,t.jsx)(o.ScrollArea,{className:"flex-1",children:A?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:D("loading")}):0===ej.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:z("empty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 pr-2",children:ej.map(e=>(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{Y(e),Q(e.content)},children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"font-medium text-sm",children:e.name}),(0,t.jsx)("button",{type:"button",className:"flex items-center justify-center size-5 rounded hover:bg-accent",onClick:t=>{t.stopPropagation(),ed(e)},children:e.favorited?(0,t.jsx)(h.Star,{className:"size-3.5 text-yellow-500 fill-yellow-500"}):(0,t.jsx)(p.StarOff,{className:"size-3.5 text-muted-foreground"})})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.description||e.content.slice(0,120).replace(/^#\s+/,"")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)(l.Button,{variant:"outline",size:"sm",onClick:()=>{q(e),G(e.boundAgents.map(e=>e.id))},children:[(0,t.jsx)(b.Rocket,{className:"size-3.5 mr-1"}),z("apply")]}),(0,t.jsxs)(c.DropdownMenu,{children:[(0,t.jsx)(c.DropdownMenuTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",className:"size-7"}),children:(0,t.jsx)(N.MoreVertical,{className:"size-3.5"})}),(0,t.jsx)(c.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(c.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>ex(e),children:[(0,t.jsx)(y.Trash2,{className:"size-3.5 mr-1.5"}),z("delete")]})})]})]})]}),e.boundAgents.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-2.5 pt-2.5 border-t border-border/50",children:[e.boundAgents.map(e=>(0,t.jsx)(x.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-5 rounded-full"},e.id)),(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:e.boundAgents.length})]})]},e.name))})})]})]})]});return(0,t.jsxs)(t.Fragment,{children:[T&&ev&&(0,t.jsx)("div",{className:"h-full flex flex-col",children:eN}),!T&&(0,t.jsx)(n.Dialog,{open:ev,onOpenChange:i,children:(0,t.jsx)(n.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:eN})}),(0,t.jsx)(n.Dialog,{open:!!X,onOpenChange:e=>{e||Y(null)},children:(0,t.jsxs)(n.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:[(0,t.jsx)(n.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(n.DialogTitle,{children:z("editTitle",{name:X?.name||""})}),(0,t.jsx)(n.DialogDescription,{children:z("editDescription")})]}),(0,t.jsxs)(l.Button,{size:"sm",onClick:eu,children:[(0,t.jsx)(k.Save,{className:"size-3.5 mr-1"}),D("save")]})]})}),(0,t.jsx)("div",{className:"flex-1 min-h-0 pt-2",children:(0,t.jsx)(S,{height:"100%",language:"markdown",value:Z,onChange:e=>Q(e||""),theme:"vs-dark",options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter",wordWrap:"on"}})})]})}),(0,t.jsx)(n.Dialog,{open:!!J,onOpenChange:e=>{e||q(null)},children:(0,t.jsxs)(n.DialogContent,{className:"sm:max-w-sm",children:[(0,t.jsxs)(n.DialogHeader,{children:[(0,t.jsx)(n.DialogTitle,{children:z("bindTitle",{name:J?.name||""})}),(0,t.jsx)(n.DialogDescription,{children:z("bindDescription")})]}),(0,t.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,t.jsx)("div",{className:"max-h-52 overflow-y-auto space-y-0.5",children:$.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>ep(e.id),className:(0,C.cn)("flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors"),children:[(0,t.jsx)(x.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.name}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:(0,C.cn)("flex items-center justify-center size-4 rounded border shrink-0",V.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input")})]},e.id))}),V.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:V.map(e=>{let s=$.find(t=>t.id===e);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:[(0,t.jsx)(x.AgentIcon,{agentId:e,name:s?.name,className:"size-3.5 rounded-full"}),s?.name||e,(0,t.jsx)("button",{type:"button",onClick:()=>ep(e),className:"hover:text-destructive",children:(0,t.jsx)(v.X,{className:"size-3"})})]},e)})}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,t.jsx)(l.Button,{variant:"outline",onClick:()=>q(null),children:D("cancel")}),(0,t.jsx)(l.Button,{onClick:eh,children:D("confirm")})]})]})]})}),(0,t.jsx)(n.Dialog,{open:ei,onOpenChange:en,children:(0,t.jsxs)(n.DialogContent,{className:"sm:max-w-lg",children:[(0,t.jsxs)(n.DialogHeader,{children:[(0,t.jsx)(n.DialogTitle,{children:z("syncTitle")}),(0,t.jsx)(n.DialogDescription,{children:z("syncDescription")})]}),(0,t.jsxs)("div",{className:"space-y-3 pt-2",children:[0===ee.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:z("syncEmpty")}):(0,t.jsx)(o.ScrollArea,{className:"max-h-72",children:(0,t.jsx)("div",{className:"space-y-1",children:ee.map(e=>{let s=`${e.agentId}::${e.skillName}`;return(0,t.jsxs)("button",{type:"button",onClick:()=>{var t,s;let a;return t=e.agentId,s=e.skillName,a=`${t}::${s}`,void ea(e=>{let t=new Set(e);return t.has(a)?t.delete(a):t.add(a),t})},className:"flex items-center gap-3 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)("div",{className:(0,C.cn)("flex items-center justify-center size-4 rounded border shrink-0",es.has(s)?"bg-primary border-primary text-primary-foreground":"border-input")}),(0,t.jsx)(x.AgentIcon,{agentId:e.agentId,name:e.agentName,className:"size-5 rounded-full"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.agentName}),(0,t.jsxs)("span",{className:"text-muted-foreground text-xs shrink-0",children:[e.skillName,".md"]})]},s)})})}),ee.length>0&&(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,t.jsx)(l.Button,{variant:"outline",onClick:()=>en(!1),children:D("cancel")}),(0,t.jsx)(l.Button,{onClick:eg,disabled:0===es.size,children:z("syncConfirm")})]})]})]})})]})}])},678001,e=>{e.v(t=>Promise.all(["static/chunks/0vesz93a98px4.js"].map(t=>e.l(t))).then(()=>t(228394)))},863812,e=>{e.v(t=>Promise.all(["static/chunks/168ojsxhm7ypc.js"].map(t=>e.l(t))).then(()=>t(158480)))}]);