agent-tower 0.4.12-beta.0 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/core/event-bus.d.ts +1 -0
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/executors/claude-code.executor.d.ts +1 -1
- package/dist/executors/claude-code.executor.d.ts.map +1 -1
- package/dist/git/worktree.manager.d.ts.map +1 -1
- package/dist/git/worktree.manager.js +21 -2
- package/dist/git/worktree.manager.js.map +1 -1
- package/dist/output/msg-store.d.ts +5 -3
- package/dist/output/msg-store.d.ts.map +1 -1
- package/dist/output/msg-store.js +14 -5
- package/dist/output/msg-store.js.map +1 -1
- package/dist/output/types.d.ts +4 -0
- package/dist/output/types.d.ts.map +1 -1
- package/dist/output/types.js.map +1 -1
- package/dist/pipeline/agent-pipeline.js +2 -2
- package/dist/pipeline/agent-pipeline.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +7 -3
- package/dist/routes/sessions.js.map +1 -1
- package/dist/services/hibernation-scheduler.d.ts.map +1 -1
- package/dist/services/hibernation-scheduler.js +1 -0
- package/dist/services/hibernation-scheduler.js.map +1 -1
- package/dist/services/session-manager.js +2 -2
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +16 -4
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/socket/socket-gateway.js +2 -2
- package/dist/socket/socket-gateway.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-BFrnOvUV.js → AgentDemoPage-BskuObus.js} +1 -1
- package/dist/web/assets/{DemoPage-DzKv8uDU.js → DemoPage-DM2NLFlQ.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-Co-8z-sL.js → GeneralSettingsPage-DggKcdQM.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-Do3Og7G9.js → NotificationSettingsPage-fDjeTfPh.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-7rYry6Ql.js → ProfileSettingsPage-CWVSxzJw.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-wvZc6KmL.js → ProjectKanbanPage-DHNpmw-4.js} +3 -3
- package/dist/web/assets/{ProjectSettingsPage-7-FUoyM2.js → ProjectSettingsPage-Cf4D6UFs.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-DZsll4Bu.js → ProviderSettingsPage-A_AoWMBp.js} +7 -7
- package/dist/web/assets/{button-BCWr6Rvd.js → button-5iX1e_fm.js} +1 -1
- package/dist/web/assets/{chevron-down-DanWbYmL.js → chevron-down-BXQh2Wxh.js} +1 -1
- package/dist/web/assets/{chevron-right-DF-6zN98.js → chevron-right-Cpp4WiwB.js} +1 -1
- package/dist/web/assets/{circle-alert-CFdGx6uD.js → circle-alert-B4o7LpBN.js} +1 -1
- package/dist/web/assets/{circle-check-iVKaVABv.js → circle-check-0QrYHY8C.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-CC5lCZW2.js → code-block-OCS4YCEC-CyOCA4DG.js} +1 -1
- package/dist/web/assets/{confirm-dialog-B6ScE3zf.js → confirm-dialog-DnYr0-iE.js} +1 -1
- package/dist/web/assets/{folder-picker-CmwjQXjK.js → folder-picker-CTcrs_BC.js} +1 -1
- package/dist/web/assets/{index-bUdBNiUV.js → index-BLRui4ck.js} +2 -2
- package/dist/web/assets/{loader-circle-CdakhgnX.js → loader-circle-DvZK36Ga.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-DlkW-f-_.js → mermaid-NOHMQCX5-xPQ5tFq8.js} +42 -42
- package/dist/web/assets/{modal-DjFx0vpU.js → modal-CvoxLn2x.js} +1 -1
- package/dist/web/assets/{pencil-BTHTFDLJ.js → pencil-CNuySmPC.js} +1 -1
- package/dist/web/assets/{rotate-ccw-DfJiT691.js → rotate-ccw-BusOGXw0.js} +1 -1
- package/dist/web/assets/{select-6YNbjKSC.js → select-DOJOMQ5p.js} +1 -1
- package/dist/web/assets/{use-profiles-cjE3ZHLR.js → use-profiles-CGAx71Yx.js} +1 -1
- package/dist/web/assets/{use-providers-CRsJrkvm.js → use-providers-RzfgfeZ2.js} +1 -1
- package/dist/web/index.html +1 -1
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +1 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/web/assets/{ProviderSettingsPage-DZsll4Bu.js → ProviderSettingsPage-A_AoWMBp.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as X,d as be,q as ve,g as ye,u as T,r as w,j as n,t as P,n as Q}from"./index-
|
|
1
|
+
import{h as X,d as be,q as ve,g as ye,u as T,r as w,j as n,t as P,n as Q}from"./index-BLRui4ck.js";import{u as je,a as we,b as Ne,c as Ce,d as Ee,e as ke,f as Pe}from"./use-providers-RzfgfeZ2.js";import{B as E}from"./button-5iX1e_fm.js";import{C as _e}from"./confirm-dialog-DnYr0-iE.js";import{P as re,T as se,M as q}from"./modal-CvoxLn2x.js";import{S as le}from"./select-DOJOMQ5p.js";import{A as N}from"./log-adapter-CeKrvZcz.js";import{c as U}from"./utils-CkSf8FUe.js";import{C as ae}from"./chevron-down-BXQh2Wxh.js";import{P as Oe}from"./pencil-CNuySmPC.js";import{C as Ie}from"./circle-check-0QrYHY8C.js";const Te=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Ae=X("circle-x",Te);const Se=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],De=X("download",Se);const Le=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Re=X("upload",Le);function Me(e,t){let l=e.slice(0,t).split(/\r\n|\n|\r/g);return[l.length,l.pop().length+1]}function Fe(e,t,l){let i=e.split(/\r\n|\n|\r/g),a="",s=(Math.log10(t+1)|0)+1;for(let r=t-1;r<=t+1;r++){let o=i[r-1];o&&(a+=r.toString().padEnd(s," "),a+=": ",a+=o,a+=`
|
|
2
2
|
`,r===t&&(a+=" ".repeat(s+l+2),a+=`^
|
|
3
3
|
`))}return a}class f extends Error{line;column;codeblock;constructor(t,l){const[i,a]=Me(l.toml,l.ptr),s=Fe(l.toml,i,a);super(`Invalid TOML document: ${t}
|
|
4
4
|
|
|
@@ -15,11 +15,11 @@ ${s}`,l),this.line=i,this.column=a,this.codeblock=s}}function Ue(e,t){let l=0;fo
|
|
|
15
15
|
`||c==="\r"&&e[t]===`
|
|
16
16
|
`){if(!a)throw new f("newlines are not allowed in strings",{toml:e,ptr:t-1})}else if(c<" "&&c!==" "||c==="")throw new f("control characters are not allowed in strings",{toml:e,ptr:t-1});if(r){if(r=!1,c==="x"||c==="u"||c==="U"){let p=e.slice(t,t+=c==="x"?2:c==="u"?4:8);if(!Xe.test(p))throw new f("invalid unicode escape",{toml:e,ptr:s});try{o+=String.fromCodePoint(parseInt(p,16))}catch{throw new f("invalid unicode escape",{toml:e,ptr:s})}}else if(a&&(c===`
|
|
17
17
|
`||c===" "||c===" "||c==="\r")){if(t=k(e,t-1,!0),e[t]!==`
|
|
18
|
-
`&&e[t]!=="\r")throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:s});t=k(e,t)}else if(c in ee)o+=ee[c];else throw new f("unrecognized escape sequence",{toml:e,ptr:s});d=t}else!i&&c==="\\"&&(s=t-1,r=!0,o+=e.slice(d,s))}return o+e.slice(d,l-1)}function qe(e,t,l,i){if(e==="true")return!0;if(e==="false")return!1;if(e==="-inf")return-1/0;if(e==="inf"||e==="+inf")return 1/0;if(e==="nan"||e==="+nan"||e==="-nan")return NaN;if(e==="-0")return i?0n:0;let a=Ge.test(e);if(a||$e.test(e)){if(Ke.test(e))throw new f("leading zeroes are not allowed",{toml:t,ptr:l});e=e.replace(/_/g,"");let r=+e;if(isNaN(r))throw new f("invalid number",{toml:t,ptr:l});if(a){if((a=!Number.isSafeInteger(r))&&!i)throw new f("integer value cannot be represented losslessly",{toml:t,ptr:l});(a||i===!0)&&(r=BigInt(e))}return r}const s=new S(e);if(!s.isValid())throw new f("invalid value",{toml:t,ptr:l});return s}function Ve(e,t,l){let i=e.slice(t,l),a=i.indexOf("#");return a>-1&&(F(e,a),i=i.slice(0,a)),[i.trimEnd(),a]}function V(e,t,l,i,a){if(i===0)throw new f("document contains excessively nested structures. aborting.",{toml:e,ptr:t});let s=e[t];if(s==="["||s==="{"){let[d,c]=s==="["?
|
|
19
|
-
`&&e[r]!=="\r")throw new f("unexpected character encountered",{toml:e,ptr:r});r+=+(e[r]===",")}return[d,r]}r=ze(e,t,",",l);let o=Ve(e,t,r-+(e[r-1]===","));if(!o[0])throw new f("incomplete key-value declaration: no value specified",{toml:e,ptr:t});return l&&o[1]>-1&&(r=k(e,t+o[1]),r+=+(e[r]===",")),[qe(o[0],e,t,a),r]}let Ze=/^[a-zA-Z0-9-_]+[ \t]*$/;function $(e,t,l="="){let i=t-1,a=[],s=e.indexOf(l,t);if(s<0)throw new f("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let r=e[t=++i];if(r!==" "&&r!==" ")if(r==='"'||r==="'"){if(r===e[t+1]&&r===e[t+2])throw new f("multiline strings are not allowed in keys",{toml:e,ptr:t});let o=ie(e,t);if(o<0)throw new f("unfinished string encountered",{toml:e,ptr:t});i=e.indexOf(".",o);let d=e.slice(o,i<0||i>s?s:i),c=G(d);if(c>-1)throw new f("newlines are not allowed in keys",{toml:e,ptr:t+i+c});if(d.trimStart())throw new f("found extra tokens after the string part",{toml:e,ptr:o});if(s<o&&(s=e.indexOf(l,o),s<0))throw new f("incomplete key-value: cannot find end of key",{toml:e,ptr:t});a.push(oe(e,t,o))}else{i=e.indexOf(".",t);let o=e.slice(t,i<0||i>s?s:i);if(!Ze.test(o))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});a.push(o.trimEnd())}}while(i+1&&i<s);return[a,k(e,s+1,!0,!0)]}function
|
|
20
|
-
`&&r!=="\r"){let o,d=a,c=!1,[p,v]=$(e,t-1);for(let g=0;g<p.length;g++){if(g&&(d=c?d[o]:d[o]={}),o=p[g],(c=Object.hasOwn(d,o))&&(typeof d[o]!="object"||s.has(d[o])))throw new f("trying to redefine an already defined value",{toml:e,ptr:t});!c&&o==="__proto__"&&Object.defineProperty(d,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new f("trying to redefine an already defined value",{toml:e,ptr:t});let[h,u]=V(e,v,"}",l-1,i);s.add(h),d[o]=h,t=u}}if(!r)throw new f("unfinished table encountered",{toml:e,ptr:t});return[a,t]}function
|
|
21
|
-
`&&s!=="\r"){let r=V(e,t-1,"]",l-1,i);a.push(r[0]),t=r[1]}}if(!s)throw new f("unfinished array encountered",{toml:e,ptr:t});return[a,t]}function te(e,t,l,i){let a=t,s=l,r,o=!1,d;for(let c=0;c<e.length;c++){if(c){if(a=o?a[r]:a[r]={},s=(d=s[r]).c,i===0&&(d.t===1||d.t===2))return null;if(d.t===2){let p=a.length-1;a=a[p],s=s[p].c}}if(r=e[c],(o=Object.hasOwn(a,r))&&s[r]?.t===0&&s[r]?.d)return null;o||(r==="__proto__"&&(Object.defineProperty(a,r,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(s,r,{enumerable:!0,configurable:!0,writable:!0})),s[r]={t:c<e.length-1&&i===2?3:i,d:!1,i:0,c:{}})}if(d=s[r],d.t!==i&&!(i===1&&d.t===3)||(i===2&&(d.d||(d.d=!0,a[r]=[]),a[r].push(a={}),d.c[d.i++]=d={t:1,d:!1,i:0,c:{}}),d.d))return null;if(d.d=!0,i===1)a=o?a[r]:a[r]={};else if(i===0&&o)return null;return[r,a,d.c]}function
|
|
22
|
-
`&&e[o]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:o});o=k(e,o)}return i}function We(){return be({queryKey:ve.system.cursorAgentModels,queryFn:()=>ye.get("/system/cursor-agent-models"),staleTime:1e3*60*10})}function Qe({value:e,onChange:t}){const{t:l}=T(),{data:i,isLoading:a,isError:s}=We(),r=i?.models??[],[o,d]=w.useState(!1),[c,p]=w.useState(""),v=w.useMemo(()=>{const h=c.trim().toLowerCase();return h?r.filter(u=>u.id.toLowerCase().includes(h)||u.label.toLowerCase().includes(h)):r},[r,c]);return n.jsxs("div",{className:"flex flex-col gap-2 flex-1 min-w-0",children:[n.jsx("input",{type:"text",value:e,onChange:h=>{const u=h.target.value;t(u===""?void 0:u)},placeholder:l("留空为 auto;或直接输入模型 ID(与 cursor-agent --model 一致)"),className:"w-full px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900 font-mono"}),n.jsxs("button",{type:"button",onClick:()=>d(h=>!h),disabled:a,className:"flex items-center gap-1 text-xs text-neutral-600 hover:text-neutral-900 disabled:opacity-50 w-fit",children:[n.jsx(ae,{size:14,className:U("transition-transform",o&&"rotate-180")}),a?l("正在加载 cursor-agent 模型列表…"):o?l("收起列表"):l("从本机 cursor-agent 选择({count} 个)",{count:r.length})]}),o&&!a&&n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-white shadow-sm overflow-hidden",children:[n.jsx("input",{type:"text",value:c,onChange:h=>p(h.target.value),placeholder:l("筛选模型…"),className:"w-full px-3 py-2 text-sm border-b border-neutral-100 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-neutral-300"}),n.jsxs("div",{className:"max-h-[min(50vh,22rem)] overflow-y-auto py-1",children:[n.jsx("button",{type:"button",onClick:()=>{t(void 0),d(!1),p("")},className:U("w-full px-3 py-2 text-left text-sm hover:bg-neutral-50",e?"text-neutral-700":"bg-neutral-50 font-medium"),children:l("默认 (auto)")}),v.map(h=>n.jsxs("button",{type:"button",onClick:()=>{t(h.id),d(!1),p("")},className:U("w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 border-t border-neutral-100",e===h.id?"bg-blue-50/80":""),children:[n.jsx("div",{className:"font-mono text-xs text-neutral-900 break-all",children:h.id}),n.jsx("div",{className:"text-xs text-neutral-500 mt-0.5 break-words",children:h.label})]},h.id)),v.length===0&&n.jsx("div",{className:"px-3 py-4 text-xs text-neutral-400 text-center",children:l("无匹配项")})]})]}),(s||i?.error)&&n.jsxs("p",{className:"text-xs text-amber-700",children:[l("无法从本机加载模型列表({error})。仍可手动输入;或在安装 cursor-agent 的机器上运行",{error:i?.error??l("请求失败")}),n.jsx("code",{className:"mx-0.5 bg-neutral-100 px-1 rounded text-[11px]",children:"cursor-agent --list-models"}),l("查看 ID。")]})]})}const Z={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent",CODEX:"Codex"},R={key:"appendPrompt",label:"追加 Prompt",type:"textarea",rows:3,placeholder:"追加到每次 prompt 末尾的文本"},
|
|
18
|
+
`&&e[t]!=="\r")throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:s});t=k(e,t)}else if(c in ee)o+=ee[c];else throw new f("unrecognized escape sequence",{toml:e,ptr:s});d=t}else!i&&c==="\\"&&(s=t-1,r=!0,o+=e.slice(d,s))}return o+e.slice(d,l-1)}function qe(e,t,l,i){if(e==="true")return!0;if(e==="false")return!1;if(e==="-inf")return-1/0;if(e==="inf"||e==="+inf")return 1/0;if(e==="nan"||e==="+nan"||e==="-nan")return NaN;if(e==="-0")return i?0n:0;let a=Ge.test(e);if(a||$e.test(e)){if(Ke.test(e))throw new f("leading zeroes are not allowed",{toml:t,ptr:l});e=e.replace(/_/g,"");let r=+e;if(isNaN(r))throw new f("invalid number",{toml:t,ptr:l});if(a){if((a=!Number.isSafeInteger(r))&&!i)throw new f("integer value cannot be represented losslessly",{toml:t,ptr:l});(a||i===!0)&&(r=BigInt(e))}return r}const s=new S(e);if(!s.isValid())throw new f("invalid value",{toml:t,ptr:l});return s}function Ve(e,t,l){let i=e.slice(t,l),a=i.indexOf("#");return a>-1&&(F(e,a),i=i.slice(0,a)),[i.trimEnd(),a]}function V(e,t,l,i,a){if(i===0)throw new f("document contains excessively nested structures. aborting.",{toml:e,ptr:t});let s=e[t];if(s==="["||s==="{"){let[d,c]=s==="["?Je(e,t,i,a):He(e,t,i,a);if(l){if(c=k(e,c),e[c]===",")c++;else if(e[c]!==l)throw new f("expected comma or end of structure",{toml:e,ptr:c})}return[d,c]}let r;if(s==='"'||s==="'"){r=ie(e,t);let d=oe(e,t,r);if(l){if(r=k(e,r),e[r]&&e[r]!==","&&e[r]!==l&&e[r]!==`
|
|
19
|
+
`&&e[r]!=="\r")throw new f("unexpected character encountered",{toml:e,ptr:r});r+=+(e[r]===",")}return[d,r]}r=ze(e,t,",",l);let o=Ve(e,t,r-+(e[r-1]===","));if(!o[0])throw new f("incomplete key-value declaration: no value specified",{toml:e,ptr:t});return l&&o[1]>-1&&(r=k(e,t+o[1]),r+=+(e[r]===",")),[qe(o[0],e,t,a),r]}let Ze=/^[a-zA-Z0-9-_]+[ \t]*$/;function $(e,t,l="="){let i=t-1,a=[],s=e.indexOf(l,t);if(s<0)throw new f("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let r=e[t=++i];if(r!==" "&&r!==" ")if(r==='"'||r==="'"){if(r===e[t+1]&&r===e[t+2])throw new f("multiline strings are not allowed in keys",{toml:e,ptr:t});let o=ie(e,t);if(o<0)throw new f("unfinished string encountered",{toml:e,ptr:t});i=e.indexOf(".",o);let d=e.slice(o,i<0||i>s?s:i),c=G(d);if(c>-1)throw new f("newlines are not allowed in keys",{toml:e,ptr:t+i+c});if(d.trimStart())throw new f("found extra tokens after the string part",{toml:e,ptr:o});if(s<o&&(s=e.indexOf(l,o),s<0))throw new f("incomplete key-value: cannot find end of key",{toml:e,ptr:t});a.push(oe(e,t,o))}else{i=e.indexOf(".",t);let o=e.slice(t,i<0||i>s?s:i);if(!Ze.test(o))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});a.push(o.trimEnd())}}while(i+1&&i<s);return[a,k(e,s+1,!0,!0)]}function He(e,t,l,i){let a={},s=new Set,r;for(t++;(r=e[t++])!=="}"&&r;){if(r===",")throw new f("expected value, found comma",{toml:e,ptr:t-1});if(r==="#")t=F(e,t);else if(r!==" "&&r!==" "&&r!==`
|
|
20
|
+
`&&r!=="\r"){let o,d=a,c=!1,[p,v]=$(e,t-1);for(let g=0;g<p.length;g++){if(g&&(d=c?d[o]:d[o]={}),o=p[g],(c=Object.hasOwn(d,o))&&(typeof d[o]!="object"||s.has(d[o])))throw new f("trying to redefine an already defined value",{toml:e,ptr:t});!c&&o==="__proto__"&&Object.defineProperty(d,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new f("trying to redefine an already defined value",{toml:e,ptr:t});let[h,u]=V(e,v,"}",l-1,i);s.add(h),d[o]=h,t=u}}if(!r)throw new f("unfinished table encountered",{toml:e,ptr:t});return[a,t]}function Je(e,t,l,i){let a=[],s;for(t++;(s=e[t++])!=="]"&&s;){if(s===",")throw new f("expected value, found comma",{toml:e,ptr:t-1});if(s==="#")t=F(e,t);else if(s!==" "&&s!==" "&&s!==`
|
|
21
|
+
`&&s!=="\r"){let r=V(e,t-1,"]",l-1,i);a.push(r[0]),t=r[1]}}if(!s)throw new f("unfinished array encountered",{toml:e,ptr:t});return[a,t]}function te(e,t,l,i){let a=t,s=l,r,o=!1,d;for(let c=0;c<e.length;c++){if(c){if(a=o?a[r]:a[r]={},s=(d=s[r]).c,i===0&&(d.t===1||d.t===2))return null;if(d.t===2){let p=a.length-1;a=a[p],s=s[p].c}}if(r=e[c],(o=Object.hasOwn(a,r))&&s[r]?.t===0&&s[r]?.d)return null;o||(r==="__proto__"&&(Object.defineProperty(a,r,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(s,r,{enumerable:!0,configurable:!0,writable:!0})),s[r]={t:c<e.length-1&&i===2?3:i,d:!1,i:0,c:{}})}if(d=s[r],d.t!==i&&!(i===1&&d.t===3)||(i===2&&(d.d||(d.d=!0,a[r]=[]),a[r].push(a={}),d.c[d.i++]=d={t:1,d:!1,i:0,c:{}}),d.d))return null;if(d.d=!0,i===1)a=o?a[r]:a[r]={};else if(i===0&&o)return null;return[r,a,d.c]}function Ye(e,{maxDepth:t=1e3,integersAsBigInt:l}={}){let i={},a={},s=i,r=a;for(let o=k(e,0);o<e.length;){if(e[o]==="["){let d=e[++o]==="[",c=$(e,o+=+d,"]");if(d){if(e[c[1]-1]!=="]")throw new f("expected end of table declaration",{toml:e,ptr:c[1]-1});c[1]++}let p=te(c[0],i,a,d?2:1);if(!p)throw new f("trying to redefine an already defined table or value",{toml:e,ptr:o});r=p[2],s=p[1],o=c[1]}else{let d=$(e,o),c=te(d[0],s,r,0);if(!c)throw new f("trying to redefine an already defined table or value",{toml:e,ptr:o});let p=V(e,d[1],void 0,t,l);c[1][c[0]]=p[0],o=p[1]}if(o=k(e,o,!0),e[o]&&e[o]!==`
|
|
22
|
+
`&&e[o]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:o});o=k(e,o)}return i}function We(){return be({queryKey:ve.system.cursorAgentModels,queryFn:()=>ye.get("/system/cursor-agent-models"),staleTime:1e3*60*10})}function Qe({value:e,onChange:t}){const{t:l}=T(),{data:i,isLoading:a,isError:s}=We(),r=i?.models??[],[o,d]=w.useState(!1),[c,p]=w.useState(""),v=w.useMemo(()=>{const h=c.trim().toLowerCase();return h?r.filter(u=>u.id.toLowerCase().includes(h)||u.label.toLowerCase().includes(h)):r},[r,c]);return n.jsxs("div",{className:"flex flex-col gap-2 flex-1 min-w-0",children:[n.jsx("input",{type:"text",value:e,onChange:h=>{const u=h.target.value;t(u===""?void 0:u)},placeholder:l("留空为 auto;或直接输入模型 ID(与 cursor-agent --model 一致)"),className:"w-full px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900 font-mono"}),n.jsxs("button",{type:"button",onClick:()=>d(h=>!h),disabled:a,className:"flex items-center gap-1 text-xs text-neutral-600 hover:text-neutral-900 disabled:opacity-50 w-fit",children:[n.jsx(ae,{size:14,className:U("transition-transform",o&&"rotate-180")}),a?l("正在加载 cursor-agent 模型列表…"):o?l("收起列表"):l("从本机 cursor-agent 选择({count} 个)",{count:r.length})]}),o&&!a&&n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-white shadow-sm overflow-hidden",children:[n.jsx("input",{type:"text",value:c,onChange:h=>p(h.target.value),placeholder:l("筛选模型…"),className:"w-full px-3 py-2 text-sm border-b border-neutral-100 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-neutral-300"}),n.jsxs("div",{className:"max-h-[min(50vh,22rem)] overflow-y-auto py-1",children:[n.jsx("button",{type:"button",onClick:()=>{t(void 0),d(!1),p("")},className:U("w-full px-3 py-2 text-left text-sm hover:bg-neutral-50",e?"text-neutral-700":"bg-neutral-50 font-medium"),children:l("默认 (auto)")}),v.map(h=>n.jsxs("button",{type:"button",onClick:()=>{t(h.id),d(!1),p("")},className:U("w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 border-t border-neutral-100",e===h.id?"bg-blue-50/80":""),children:[n.jsx("div",{className:"font-mono text-xs text-neutral-900 break-all",children:h.id}),n.jsx("div",{className:"text-xs text-neutral-500 mt-0.5 break-words",children:h.label})]},h.id)),v.length===0&&n.jsx("div",{className:"px-3 py-4 text-xs text-neutral-400 text-center",children:l("无匹配项")})]})]}),(s||i?.error)&&n.jsxs("p",{className:"text-xs text-amber-700",children:[l("无法从本机加载模型列表({error})。仍可手动输入;或在安装 cursor-agent 的机器上运行",{error:i?.error??l("请求失败")}),n.jsx("code",{className:"mx-0.5 bg-neutral-100 px-1 rounded text-[11px]",children:"cursor-agent --list-models"}),l("查看 ID。")]})]})}const Z={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent",CODEX:"Codex"},R={key:"appendPrompt",label:"追加 Prompt",type:"textarea",rows:3,placeholder:"追加到每次 prompt 末尾的文本"},H={[N.CLAUDE_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"claude-sonnet-4-20250514"},{key:"effort",label:"推理强度",type:"select",options:[{value:"",label:"默认"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"XHigh"},{value:"max",label:"Max"}]},R],[N.GEMINI_CLI]:[{key:"yolo",label:"跳过权限确认",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"gemini-2.5-pro"},R],[N.CURSOR_AGENT]:[{key:"force",label:"强制执行",type:"switch"},{key:"model",label:"模型",type:"cursor_model"},R],[N.CODEX]:[{key:"dangerouslyBypassApprovalsAndSandbox",label:"跳过所有确认和沙盒",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"o3"},{key:"profile",label:"Profile",type:"input",placeholder:"~/.codex/config.toml 中的 profile 名称"},R]};function ne(){return{}}function K(e,t){return{...t}}const et=JSON.stringify({env:{ANTHROPIC_API_KEY:"",ANTHROPIC_BASE_URL:""}},null,2),tt=`# Codex config.toml 配置片段 — 通过 -c 参数注入,不会修改 ~/.codex/config.toml
|
|
23
23
|
# 参考: https://developers.openai.com/codex/config-sample
|
|
24
24
|
|
|
25
25
|
# ─── 模型与推理 ─────────────────────────────────────────────
|
|
@@ -51,4 +51,4 @@ ${s}`,l),this.line=i,this.column=a,this.codeblock=s}}function Ue(e,t){let l=0;fo
|
|
|
51
51
|
# name = "Ollama"
|
|
52
52
|
# base_url = "http://localhost:11434/v1"
|
|
53
53
|
# wire_api = "responses"
|
|
54
|
-
`;function z(e){return e===N.CLAUDE_CODE?et:e===N.CODEX?tt:""}function nt(e){return e===N.CLAUDE_CODE||e===N.CODEX}const rt=Object.values(J).flat().reduce((e,t)=>(e[t.key]||(e[t.key]=t.label),e),{}),st=Object.values(J).flat().reduce((e,t)=>(t.options&&(e[t.key]=Object.fromEntries(t.options.map(l=>[l.value,l.label]))),e),{});function lt(e,t){return typeof t=="boolean"?t?Q("是"):Q("否"):typeof t=="string"&&t?st[e]?.[t]??t:String(t)}function M(e,t){return e instanceof Error?e.message:t}function at(e){return`agent-tower-provider-backup-${e.replace(/[:.]/g,"-")}.json`}function it(e,t){const l=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),i=URL.createObjectURL(l),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function ot(e){switch(e){case"CREATE":return{label:"新增",className:"text-green-700 bg-green-50"};case"OVERWRITE":return{label:"覆盖",className:"text-amber-700 bg-amber-50"};case"SKIP":return{label:"跳过",className:"text-neutral-600 bg-neutral-100"}}}function ct({type:e}){const{t}=T();return e==="LOGIN_DETECTED"||e==="INSTALLATION_FOUND"?n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-green-700 bg-green-50 rounded",children:[n.jsx(Ie,{size:12}),t("可用")]}):n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:[n.jsx(Ae,{size:12}),t("不可用")]})}function B({title:e,defaultOpen:t=!1,children:l}){const[i,a]=w.useState(t);return n.jsxs("div",{className:"border border-neutral-200 rounded-lg",children:[n.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium text-neutral-700 hover:bg-neutral-50 transition-colors rounded-lg",children:[e,n.jsx(ae,{size:14,className:`transition-transform ${i?"rotate-180":""}`})]}),i&&n.jsx("div",{className:"px-4 pb-4 space-y-3",children:l})]})}function dt({agentType:e,config:t,onChange:l}){const{t:i}=T(),a=J[e]??[];if(a.length===0)return n.jsx("p",{className:"text-xs text-neutral-400",children:i("该类型暂无运行配置")});const s=(r,o)=>{l({...t,[r]:o})};return n.jsx("div",{className:"space-y-3",children:a.map(r=>r.type==="textarea"?n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm text-neutral-700 mb-1",children:i(r.label)}),n.jsx("textarea",{value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,rows:r.rows??3,className:"w-full px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"})]},r.key):r.type==="cursor_model"?n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0 sm:pt-2",children:i(r.label)}),n.jsx(Qe,{value:t[r.key]??"",onChange:o=>s(r.key,o)})]},r.key):n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0",children:i(r.label)}),r.type==="switch"&&n.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:!!t[r.key],onChange:o=>s(r.key,o.target.checked),className:"sr-only peer"}),n.jsx("div",{className:"w-9 h-5 bg-neutral-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-neutral-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-neutral-900"})]}),r.type==="input"&&n.jsx("input",{type:"text",value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,className:"flex-1 px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),r.type==="select"&&r.options&&n.jsx(le,{value:t[r.key]??"",onChange:o=>s(r.key,o||void 0),options:r.options,placeholder:i("选择...")})]},r.key))})}function ut({isOpen:e,onClose:t,initialData:l,onSave:i}){const{t:a}=T(),[s,r]=w.useState(l??{name:"",agentType:N.CLAUDE_CODE,config:ne(),settings:"",env:[],isDefault:!1}),[o,d]=w.useState("");w.useEffect(()=>{if(!l&&!s.settings){const u=z(s.agentType);u&&r(g=>({...g,settings:u}))}},[]);const c=u=>{r(g=>({...g,agentType:u,config:ne(),settings:z(u)}))},p=()=>{d("");const u=K(s.agentType,s.config),g={};for(const[j,_]of Object.entries(u))_!==void 0&&_!==""&&(g[j]=_);const y=s.settings.trim();if(y){if(s.agentType===N.CODEX)try{He(y)}catch(j){d(a("TOML 语法错误: {message}",{message:j instanceof Error?j.message:String(j)}));return}else if(s.agentType===N.CLAUDE_CODE)try{JSON.parse(y)}catch{d(a("JSON 语法错误"));return}}const b={};for(const{key:j,value:_}of s.env){const D=j.trim();D&&(b[D]=_)}const C={name:s.name,agentType:s.agentType,config:g,settings:y||void 0,env:Object.keys(b).length>0?b:void 0,isDefault:s.isDefault};i(C)};if(!e)return null;const v=nt(s.agentType),h=s.agentType===N.CODEX;return n.jsx(q,{isOpen:e,onClose:t,title:a(l?"编辑 Provider":"新建 Provider"),className:"max-w-2xl",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("名称")}),n.jsx("input",{type:"text",value:s.name,onChange:u=>r(g=>({...g,name:u.target.value})),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900",placeholder:a("例如: Claude Code (官方)")})]}),!l&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("Agent 类型")}),n.jsx(le,{value:s.agentType,onChange:u=>c(u),options:Object.values(N).map(u=>({value:u,label:Z[u]??u})),placeholder:a("选择 Agent 类型")})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",id:"isDefault",checked:s.isDefault,onChange:u=>r(g=>({...g,isDefault:u.target.checked})),className:"w-4 h-4"}),n.jsx("label",{htmlFor:"isDefault",className:"text-sm text-neutral-700",children:a("设为该类型的默认 Provider")})]}),n.jsx(B,{title:a("运行配置"),defaultOpen:!0,children:n.jsx(dt,{agentType:s.agentType,config:s.config,onChange:u=>r(g=>({...g,config:u}))})}),n.jsxs(B,{title:a("环境变量"),defaultOpen:s.env.length>0,children:[n.jsxs("p",{className:"text-xs text-neutral-500 mb-2",children:[a("注入到 Agent 进程的环境变量。Codex 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env_key"})," ",a("指定的是变量名,实际值需在此处设置。")]}),n.jsxs("div",{className:"space-y-2",children:[s.env.map((u,g)=>n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("input",{type:"text",value:u.key,onChange:y=>{const b=[...s.env];b[g]={...b[g],key:y.target.value},r(C=>({...C,env:b}))},placeholder:a("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("input",{type:"text",value:u.value,onChange:y=>{const b=[...s.env];b[g]={...b[g],value:y.target.value},r(C=>({...C,env:b}))},placeholder:a("值"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("button",{type:"button",onClick:()=>{const y=s.env.filter((b,C)=>C!==g);r(b=>({...b,env:y}))},className:"p-1.5 text-neutral-400 hover:text-red-500",children:n.jsx(se,{size:14})})]},g)),n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>r(u=>({...u,env:[...u.env,{key:"",value:""}]})),children:[n.jsx(re,{size:12,className:"mr-1"}),a("添加变量")]})]})]}),v&&n.jsxs(B,{title:a(h?"CLI 原生配置 (config.toml)":"CLI 原生配置 (settings.json)"),children:[n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:h?n.jsxs(n.Fragment,{children:[a("直接填写 Codex")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"config.toml"})," ",a("格式的配置片段,通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"-c"})," ",a("参数注入。不会修改你的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.codex/config.toml"})," ",a("文件。")]}):n.jsxs(n.Fragment,{children:[a("对应 Claude Code 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.claude/settings.json"}),",",a("通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"--settings"})," ",a("参数注入。在")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env"})," ",a("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),n.jsx("textarea",{value:s.settings,onChange:u=>{r(g=>({...g,settings:u.target.value})),d("")},rows:10,className:"w-full px-3 py-2 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900 bg-neutral-50",placeholder:z(s.agentType)}),o&&n.jsx("p",{className:"mt-1 text-xs text-red-600",children:o})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(E,{variant:"outline",onClick:t,children:a("取消")}),n.jsx(E,{onClick:p,disabled:!s.name.trim(),children:a("保存")})]})]})})}function mt({isOpen:e,onClose:t,onConfirm:l,acknowledged:i,onAcknowledgedChange:a,isLoading:s}){const{t:r}=T();return n.jsx(q,{isOpen:e,onClose:t,title:r("导出 Provider 备份"),className:"max-w-xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:l,disabled:!i||s,children:r(s?"导出中...":"导出备份")})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:r("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")}),n.jsxs("div",{className:"text-sm text-neutral-600 space-y-2",children:[n.jsx("p",{children:r("这个功能用于备份和迁移,不用于分享配置。")}),n.jsx("p",{children:r("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),n.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-neutral-200 px-4 py-3 text-sm text-neutral-700",children:[n.jsx("input",{type:"checkbox",checked:i,onChange:o=>a(o.target.checked),className:"mt-0.5 h-4 w-4"}),n.jsx("span",{children:r("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function xt({isOpen:e,onClose:t,preview:l,backup:i,onConfirm:a,isLoading:s}){const{t:r}=T();if(!l||!i)return null;const o=l.summary.create+l.summary.overwrite,d=[...l.items].sort((c,p)=>{const v={CREATE:0,OVERWRITE:1,SKIP:2};return v[c.action]-v[p.action]});return n.jsx(q,{isOpen:e,onClose:t,title:r("导入 Provider 备份"),className:"max-w-3xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:a,disabled:o===0||s,children:s?r("导入中..."):r("确认导入 {count} 项",{count:o})})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-600",children:[n.jsx("div",{children:r("导出时间:{value}",{value:new Date(i.exportedAt).toLocaleString()})}),n.jsx("div",{children:r("模式:完整备份(含敏感信息)")}),n.jsx("div",{children:r("文件内 Provider 数量:{count}",{count:i.providers.length})})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[n.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-green-700",children:r("新增")}),n.jsx("div",{className:"text-lg font-semibold text-green-900",children:l.summary.create})]}),n.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-amber-700",children:r("覆盖")}),n.jsx("div",{className:"text-lg font-semibold text-amber-900",children:l.summary.overwrite})]}),n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-neutral-500",children:r("跳过")}),n.jsx("div",{className:"text-lg font-semibold text-neutral-900",children:l.summary.skip})]})]}),n.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:d.map(c=>{const p=ot(c.action);return n.jsxs("div",{className:"rounded-lg border border-neutral-200 px-4 py-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h4",{className:"truncate text-sm font-medium text-neutral-900",children:c.incoming.name}),n.jsx("span",{className:`inline-flex rounded px-2 py-0.5 text-xs ${p.className}`,children:r(p.label)})]}),n.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[Z[c.incoming.agentType]??c.incoming.agentType," · ",n.jsx("code",{className:"rounded bg-neutral-100 px-1 py-0.5",children:c.incoming.id})]})]})}),c.action==="OVERWRITE"&&c.existing&&n.jsx("p",{className:"mt-2 text-xs text-amber-700",children:r("将覆盖当前已有的 Provider:{name}",{name:c.existing.name})}),c.action==="SKIP"&&n.jsx("p",{className:"mt-2 text-xs text-neutral-500",children:r("当前同 ID Provider 配置一致,本次不会重复写入。")}),c.action==="CREATE"&&n.jsx("p",{className:"mt-2 text-xs text-green-700",children:r("当前不存在同 ID Provider,将直接新增。")})]},c.incoming.id)})})]})})}function Et(){const{t:e}=T(),{data:t,isLoading:l}=je(),i=we(),a=Ne(),s=Ce(),r=Ee(),o=ke(),d=Pe(),c=w.useRef(null),[p,v]=w.useState(null),[h,u]=w.useState(null),[g,y]=w.useState(!1),[b,C]=w.useState(!1),[j,_]=w.useState(null),D=m=>{i.mutate(m,{onSuccess:()=>v(null)})},ce=(m,x)=>{a.mutate({id:m,data:x},{onSuccess:()=>v(null)})},de=m=>{if(!(m.deletable??!m.builtIn)){P.error(e("系统内置 Provider 不可删除"));return}u({id:m.id,name:m.name,builtIn:m.builtIn})},ue=()=>{h&&s.mutate(h.id,{onSuccess:()=>{P.success(h.builtIn?e("已恢复默认 Provider 配置"):e("Provider 已删除")),u(null)},onError:m=>{P.error(M(m,e("删除 Provider 失败")))}})},Y=()=>{y(!1),C(!1)},H=()=>{_(null)},me=()=>{r.mutate(void 0,{onSuccess:m=>{it(at(m.exportedAt),m),P.success(e("Provider 备份已导出")),Y()},onError:m=>{P.error(M(m,e("导出 Provider 备份失败")))}})},xe=()=>{c.current&&(c.current.value="",c.current.click())},fe=async m=>{const x=m.target.files?.[0];if(m.target.value="",!x)return;let O;try{O=JSON.parse(await x.text())}catch{P.error(e("备份文件不是有效的 JSON"));return}o.mutate(O,{onSuccess:I=>{_({backup:O,preview:I})},onError:I=>{P.error(M(I,e("导入预览失败")))}})},pe=()=>{j&&d.mutate(j.backup,{onSuccess:m=>{const x=m.summary.create+m.summary.overwrite;P.success(x===0?e("导入完成,当前配置无需变更"):e("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:m.summary.create,overwrite:m.summary.overwrite,skip:m.summary.skip})),H()},onError:m=>{P.error(M(m,e("导入 Provider 备份失败")))}})},he=m=>{const x=m.provider,O=x.env?Object.entries(x.env).map(([I,L])=>({key:I,value:L})):[];v({id:x.id,data:{name:x.name,agentType:x.agentType,config:K(x.agentType,x.config),settings:x.settings??"",env:O,isDefault:x.isDefault}})};if(l)return n.jsx("div",{className:"p-6 text-sm text-neutral-400",children:e("加载中...")});const W=t??[];return n.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl",children:[n.jsx("input",{ref:c,type:"file",accept:".json,application/json",className:"hidden",onChange:fe}),n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-neutral-900",children:e("Provider 配置")}),n.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:e("管理 AI Agent 的连接配置和运行参数")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(E,{variant:"outline",onClick:xe,disabled:o.isPending||d.isPending,children:[n.jsx(Re,{size:14}),e("导入备份")]}),n.jsxs(E,{variant:"outline",onClick:()=>y(!0),disabled:r.isPending,children:[n.jsx(De,{size:14}),e("导出备份")]}),n.jsxs(E,{onClick:()=>v({}),children:[n.jsx(re,{size:14,className:"mr-1"}),e("新建 Provider")]})]})]}),W.length===0?n.jsx("div",{className:"text-center py-12 text-sm text-neutral-400",children:e("暂无 Provider 配置")}):n.jsx("div",{className:"space-y-3",children:W.map(m=>{const x=m.provider,O=m.availability,I=K(x.agentType,x.config),L=Object.entries(I).filter(([A])=>A!=="cmd");return n.jsx("div",{className:"border border-neutral-200 rounded-lg p-4 hover:border-neutral-300 transition-colors",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("h3",{className:"text-sm font-medium text-neutral-900",children:x.name}),n.jsx(ct,{type:O.type}),x.isDefault&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-blue-700 bg-blue-50 rounded",children:e("默认")}),x.builtIn&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:e("内置")})]}),n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:Z[x.agentType]??x.agentType}),L.length>0&&n.jsx("div",{className:"text-xs text-neutral-600 mb-1",children:L.map(([A,ge])=>n.jsxs("span",{className:"inline-flex items-center mr-3",children:[n.jsxs("span",{className:"font-medium",children:[e(rt[A]??A),":"]})," ",lt(A,ge)]},A))}),x.settings?.trim()&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("CLI 配置:")})," ",e("已配置")]}),Object.keys(x.env).length>0&&!x.settings&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("环境变量:")})," ",Object.keys(x.env).join(", ")]})]}),n.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[n.jsx("button",{onClick:()=>he(m),className:"p-2 text-neutral-400 hover:text-neutral-900 transition-colors",title:e("编辑"),children:n.jsx(Oe,{size:14})}),n.jsx("button",{onClick:()=>de(x),className:"p-2 text-neutral-400 hover:text-red-600 transition-colors",title:x.deletable===!1?e("系统内置 Provider 不可删除"):x.builtIn?e("删除自定义覆盖并恢复默认"):e("删除"),disabled:x.deletable===!1,children:n.jsx(se,{size:14})})]})]})},x.id)})}),p&&n.jsx(ut,{isOpen:!0,onClose:()=>v(null),initialData:p.data,onSave:m=>{p.id?ce(p.id,m):D(m)}}),n.jsx(_e,{isOpen:h!==null,onClose:()=>{s.isPending||u(null)},onConfirm:ue,title:h?.builtIn?e("恢复默认 Provider"):e("删除 Provider"),description:h?.builtIn?e('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:h?.name}):e('确定删除 "{name}"?此操作不可撤销。',{name:h?.name}),confirmText:h?.builtIn?e("恢复默认"):e("删除"),cancelText:e("取消"),variant:"danger",isLoading:s.isPending}),n.jsx(mt,{isOpen:g,onClose:Y,onConfirm:me,acknowledged:b,onAcknowledgedChange:C,isLoading:r.isPending}),n.jsx(xt,{isOpen:!!j,onClose:H,preview:j?.preview??null,backup:j?.backup??null,onConfirm:pe,isLoading:d.isPending})]})}export{Et as ProviderSettingsPage};
|
|
54
|
+
`;function z(e){return e===N.CLAUDE_CODE?et:e===N.CODEX?tt:""}function nt(e){return e===N.CLAUDE_CODE||e===N.CODEX}const rt=Object.values(H).flat().reduce((e,t)=>(e[t.key]||(e[t.key]=t.label),e),{}),st=Object.values(H).flat().reduce((e,t)=>(t.options&&(e[t.key]=Object.fromEntries(t.options.map(l=>[l.value,l.label]))),e),{});function lt(e,t){return typeof t=="boolean"?t?Q("是"):Q("否"):typeof t=="string"&&t?st[e]?.[t]??t:String(t)}function M(e,t){return e instanceof Error?e.message:t}function at(e){return`agent-tower-provider-backup-${e.replace(/[:.]/g,"-")}.json`}function it(e,t){const l=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),i=URL.createObjectURL(l),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function ot(e){switch(e){case"CREATE":return{label:"新增",className:"text-green-700 bg-green-50"};case"OVERWRITE":return{label:"覆盖",className:"text-amber-700 bg-amber-50"};case"SKIP":return{label:"跳过",className:"text-neutral-600 bg-neutral-100"}}}function ct({type:e}){const{t}=T();return e==="LOGIN_DETECTED"||e==="INSTALLATION_FOUND"?n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-green-700 bg-green-50 rounded",children:[n.jsx(Ie,{size:12}),t("可用")]}):n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:[n.jsx(Ae,{size:12}),t("不可用")]})}function B({title:e,defaultOpen:t=!1,children:l}){const[i,a]=w.useState(t);return n.jsxs("div",{className:"border border-neutral-200 rounded-lg",children:[n.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium text-neutral-700 hover:bg-neutral-50 transition-colors rounded-lg",children:[e,n.jsx(ae,{size:14,className:`transition-transform ${i?"rotate-180":""}`})]}),i&&n.jsx("div",{className:"px-4 pb-4 space-y-3",children:l})]})}function dt({agentType:e,config:t,onChange:l}){const{t:i}=T(),a=H[e]??[];if(a.length===0)return n.jsx("p",{className:"text-xs text-neutral-400",children:i("该类型暂无运行配置")});const s=(r,o)=>{l({...t,[r]:o})};return n.jsx("div",{className:"space-y-3",children:a.map(r=>r.type==="textarea"?n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm text-neutral-700 mb-1",children:i(r.label)}),n.jsx("textarea",{value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,rows:r.rows??3,className:"w-full px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"})]},r.key):r.type==="cursor_model"?n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0 sm:pt-2",children:i(r.label)}),n.jsx(Qe,{value:t[r.key]??"",onChange:o=>s(r.key,o)})]},r.key):n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0",children:i(r.label)}),r.type==="switch"&&n.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:!!t[r.key],onChange:o=>s(r.key,o.target.checked),className:"sr-only peer"}),n.jsx("div",{className:"w-9 h-5 bg-neutral-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-neutral-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-neutral-900"})]}),r.type==="input"&&n.jsx("input",{type:"text",value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,className:"flex-1 px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),r.type==="select"&&r.options&&n.jsx(le,{value:t[r.key]??"",onChange:o=>s(r.key,o||void 0),options:r.options,placeholder:i("选择...")})]},r.key))})}function ut({isOpen:e,onClose:t,initialData:l,onSave:i}){const{t:a}=T(),[s,r]=w.useState(l??{name:"",agentType:N.CLAUDE_CODE,config:ne(),settings:"",env:[],isDefault:!1}),[o,d]=w.useState("");w.useEffect(()=>{if(!l&&!s.settings){const u=z(s.agentType);u&&r(g=>({...g,settings:u}))}},[]);const c=u=>{r(g=>({...g,agentType:u,config:ne(),settings:z(u)}))},p=()=>{d("");const u=K(s.agentType,s.config),g={};for(const[j,_]of Object.entries(u))_!==void 0&&_!==""&&(g[j]=_);const y=s.settings.trim();if(y){if(s.agentType===N.CODEX)try{Ye(y)}catch(j){d(a("TOML 语法错误: {message}",{message:j instanceof Error?j.message:String(j)}));return}else if(s.agentType===N.CLAUDE_CODE)try{JSON.parse(y)}catch{d(a("JSON 语法错误"));return}}const b={};for(const{key:j,value:_}of s.env){const D=j.trim();D&&(b[D]=_)}const C={name:s.name,agentType:s.agentType,config:g,settings:y||void 0,env:Object.keys(b).length>0?b:void 0,isDefault:s.isDefault};i(C)};if(!e)return null;const v=nt(s.agentType),h=s.agentType===N.CODEX;return n.jsx(q,{isOpen:e,onClose:t,title:a(l?"编辑 Provider":"新建 Provider"),className:"max-w-2xl",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("名称")}),n.jsx("input",{type:"text",value:s.name,onChange:u=>r(g=>({...g,name:u.target.value})),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900",placeholder:a("例如: Claude Code (官方)")})]}),!l&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("Agent 类型")}),n.jsx(le,{value:s.agentType,onChange:u=>c(u),options:Object.values(N).map(u=>({value:u,label:Z[u]??u})),placeholder:a("选择 Agent 类型")})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",id:"isDefault",checked:s.isDefault,onChange:u=>r(g=>({...g,isDefault:u.target.checked})),className:"w-4 h-4"}),n.jsx("label",{htmlFor:"isDefault",className:"text-sm text-neutral-700",children:a("设为该类型的默认 Provider")})]}),n.jsx(B,{title:a("运行配置"),defaultOpen:!0,children:n.jsx(dt,{agentType:s.agentType,config:s.config,onChange:u=>r(g=>({...g,config:u}))})}),n.jsxs(B,{title:a("环境变量"),defaultOpen:s.env.length>0,children:[n.jsxs("p",{className:"text-xs text-neutral-500 mb-2",children:[a("注入到 Agent 进程的环境变量。Codex 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env_key"})," ",a("指定的是变量名,实际值需在此处设置。")]}),n.jsxs("div",{className:"space-y-2",children:[s.env.map((u,g)=>n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("input",{type:"text",value:u.key,onChange:y=>{const b=[...s.env];b[g]={...b[g],key:y.target.value},r(C=>({...C,env:b}))},placeholder:a("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("input",{type:"text",value:u.value,onChange:y=>{const b=[...s.env];b[g]={...b[g],value:y.target.value},r(C=>({...C,env:b}))},placeholder:a("值"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("button",{type:"button",onClick:()=>{const y=s.env.filter((b,C)=>C!==g);r(b=>({...b,env:y}))},className:"p-1.5 text-neutral-400 hover:text-red-500",children:n.jsx(se,{size:14})})]},g)),n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>r(u=>({...u,env:[...u.env,{key:"",value:""}]})),children:[n.jsx(re,{size:12,className:"mr-1"}),a("添加变量")]})]})]}),v&&n.jsxs(B,{title:a(h?"CLI 原生配置 (config.toml)":"CLI 原生配置 (settings.json)"),children:[n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:h?n.jsxs(n.Fragment,{children:[a("直接填写 Codex")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"config.toml"})," ",a("格式的配置片段,通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"-c"})," ",a("参数注入。不会修改你的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.codex/config.toml"})," ",a("文件。")]}):n.jsxs(n.Fragment,{children:[a("对应 Claude Code 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.claude/settings.json"}),",",a("通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"--settings"})," ",a("参数注入。在")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env"})," ",a("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),n.jsx("textarea",{value:s.settings,onChange:u=>{r(g=>({...g,settings:u.target.value})),d("")},rows:10,className:"w-full px-3 py-2 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900 bg-neutral-50",placeholder:z(s.agentType)}),o&&n.jsx("p",{className:"mt-1 text-xs text-red-600",children:o})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(E,{variant:"outline",onClick:t,children:a("取消")}),n.jsx(E,{onClick:p,disabled:!s.name.trim(),children:a("保存")})]})]})})}function mt({isOpen:e,onClose:t,onConfirm:l,acknowledged:i,onAcknowledgedChange:a,isLoading:s}){const{t:r}=T();return n.jsx(q,{isOpen:e,onClose:t,title:r("导出 Provider 备份"),className:"max-w-xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:l,disabled:!i||s,children:r(s?"导出中...":"导出备份")})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:r("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")}),n.jsxs("div",{className:"text-sm text-neutral-600 space-y-2",children:[n.jsx("p",{children:r("这个功能用于备份和迁移,不用于分享配置。")}),n.jsx("p",{children:r("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),n.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-neutral-200 px-4 py-3 text-sm text-neutral-700",children:[n.jsx("input",{type:"checkbox",checked:i,onChange:o=>a(o.target.checked),className:"mt-0.5 h-4 w-4"}),n.jsx("span",{children:r("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function xt({isOpen:e,onClose:t,preview:l,backup:i,onConfirm:a,isLoading:s}){const{t:r}=T();if(!l||!i)return null;const o=l.summary.create+l.summary.overwrite,d=[...l.items].sort((c,p)=>{const v={CREATE:0,OVERWRITE:1,SKIP:2};return v[c.action]-v[p.action]});return n.jsx(q,{isOpen:e,onClose:t,title:r("导入 Provider 备份"),className:"max-w-3xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:a,disabled:o===0||s,children:s?r("导入中..."):r("确认导入 {count} 项",{count:o})})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-600",children:[n.jsx("div",{children:r("导出时间:{value}",{value:new Date(i.exportedAt).toLocaleString()})}),n.jsx("div",{children:r("模式:完整备份(含敏感信息)")}),n.jsx("div",{children:r("文件内 Provider 数量:{count}",{count:i.providers.length})})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[n.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-green-700",children:r("新增")}),n.jsx("div",{className:"text-lg font-semibold text-green-900",children:l.summary.create})]}),n.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-amber-700",children:r("覆盖")}),n.jsx("div",{className:"text-lg font-semibold text-amber-900",children:l.summary.overwrite})]}),n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-neutral-500",children:r("跳过")}),n.jsx("div",{className:"text-lg font-semibold text-neutral-900",children:l.summary.skip})]})]}),n.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:d.map(c=>{const p=ot(c.action);return n.jsxs("div",{className:"rounded-lg border border-neutral-200 px-4 py-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h4",{className:"truncate text-sm font-medium text-neutral-900",children:c.incoming.name}),n.jsx("span",{className:`inline-flex rounded px-2 py-0.5 text-xs ${p.className}`,children:r(p.label)})]}),n.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[Z[c.incoming.agentType]??c.incoming.agentType," · ",n.jsx("code",{className:"rounded bg-neutral-100 px-1 py-0.5",children:c.incoming.id})]})]})}),c.action==="OVERWRITE"&&c.existing&&n.jsx("p",{className:"mt-2 text-xs text-amber-700",children:r("将覆盖当前已有的 Provider:{name}",{name:c.existing.name})}),c.action==="SKIP"&&n.jsx("p",{className:"mt-2 text-xs text-neutral-500",children:r("当前同 ID Provider 配置一致,本次不会重复写入。")}),c.action==="CREATE"&&n.jsx("p",{className:"mt-2 text-xs text-green-700",children:r("当前不存在同 ID Provider,将直接新增。")})]},c.incoming.id)})})]})})}function Et(){const{t:e}=T(),{data:t,isLoading:l}=je(),i=we(),a=Ne(),s=Ce(),r=Ee(),o=ke(),d=Pe(),c=w.useRef(null),[p,v]=w.useState(null),[h,u]=w.useState(null),[g,y]=w.useState(!1),[b,C]=w.useState(!1),[j,_]=w.useState(null),D=m=>{i.mutate(m,{onSuccess:()=>v(null)})},ce=(m,x)=>{a.mutate({id:m,data:x},{onSuccess:()=>v(null)})},de=m=>{if(!(m.deletable??!m.builtIn)){P.error(e("系统内置 Provider 不可删除"));return}u({id:m.id,name:m.name,builtIn:m.builtIn})},ue=()=>{h&&s.mutate(h.id,{onSuccess:()=>{P.success(h.builtIn?e("已恢复默认 Provider 配置"):e("Provider 已删除")),u(null)},onError:m=>{P.error(M(m,e("删除 Provider 失败")))}})},J=()=>{y(!1),C(!1)},Y=()=>{_(null)},me=()=>{r.mutate(void 0,{onSuccess:m=>{it(at(m.exportedAt),m),P.success(e("Provider 备份已导出")),J()},onError:m=>{P.error(M(m,e("导出 Provider 备份失败")))}})},xe=()=>{c.current&&(c.current.value="",c.current.click())},fe=async m=>{const x=m.target.files?.[0];if(m.target.value="",!x)return;let O;try{O=JSON.parse(await x.text())}catch{P.error(e("备份文件不是有效的 JSON"));return}o.mutate(O,{onSuccess:I=>{_({backup:O,preview:I})},onError:I=>{P.error(M(I,e("导入预览失败")))}})},pe=()=>{j&&d.mutate(j.backup,{onSuccess:m=>{const x=m.summary.create+m.summary.overwrite;P.success(x===0?e("导入完成,当前配置无需变更"):e("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:m.summary.create,overwrite:m.summary.overwrite,skip:m.summary.skip})),Y()},onError:m=>{P.error(M(m,e("导入 Provider 备份失败")))}})},he=m=>{const x=m.provider,O=x.env?Object.entries(x.env).map(([I,L])=>({key:I,value:L})):[];v({id:x.id,data:{name:x.name,agentType:x.agentType,config:K(x.agentType,x.config),settings:x.settings??"",env:O,isDefault:x.isDefault}})};if(l)return n.jsx("div",{className:"p-6 text-sm text-neutral-400",children:e("加载中...")});const W=t??[];return n.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl",children:[n.jsx("input",{ref:c,type:"file",accept:".json,application/json",className:"hidden",onChange:fe}),n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-neutral-900",children:e("Provider 配置")}),n.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:e("管理 AI Agent 的连接配置和运行参数")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(E,{variant:"outline",onClick:xe,disabled:o.isPending||d.isPending,children:[n.jsx(Re,{size:14}),e("导入备份")]}),n.jsxs(E,{variant:"outline",onClick:()=>y(!0),disabled:r.isPending,children:[n.jsx(De,{size:14}),e("导出备份")]}),n.jsxs(E,{onClick:()=>v({}),children:[n.jsx(re,{size:14,className:"mr-1"}),e("新建 Provider")]})]})]}),W.length===0?n.jsx("div",{className:"text-center py-12 text-sm text-neutral-400",children:e("暂无 Provider 配置")}):n.jsx("div",{className:"space-y-3",children:W.map(m=>{const x=m.provider,O=m.availability,I=K(x.agentType,x.config),L=Object.entries(I).filter(([A])=>A!=="cmd");return n.jsx("div",{className:"border border-neutral-200 rounded-lg p-4 hover:border-neutral-300 transition-colors",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("h3",{className:"text-sm font-medium text-neutral-900",children:x.name}),n.jsx(ct,{type:O.type}),x.isDefault&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-blue-700 bg-blue-50 rounded",children:e("默认")}),x.builtIn&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:e("内置")})]}),n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:Z[x.agentType]??x.agentType}),L.length>0&&n.jsx("div",{className:"text-xs text-neutral-600 mb-1",children:L.map(([A,ge])=>n.jsxs("span",{className:"inline-flex items-center mr-3",children:[n.jsxs("span",{className:"font-medium",children:[e(rt[A]??A),":"]})," ",lt(A,ge)]},A))}),x.settings?.trim()&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("CLI 配置:")})," ",e("已配置")]}),Object.keys(x.env).length>0&&!x.settings&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("环境变量:")})," ",Object.keys(x.env).join(", ")]})]}),n.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[n.jsx("button",{onClick:()=>he(m),className:"p-2 text-neutral-400 hover:text-neutral-900 transition-colors",title:e("编辑"),children:n.jsx(Oe,{size:14})}),n.jsx("button",{onClick:()=>de(x),className:"p-2 text-neutral-400 hover:text-red-600 transition-colors",title:x.deletable===!1?e("系统内置 Provider 不可删除"):x.builtIn?e("删除自定义覆盖并恢复默认"):e("删除"),disabled:x.deletable===!1,children:n.jsx(se,{size:14})})]})]})},x.id)})}),p&&n.jsx(ut,{isOpen:!0,onClose:()=>v(null),initialData:p.data,onSave:m=>{p.id?ce(p.id,m):D(m)}}),n.jsx(_e,{isOpen:h!==null,onClose:()=>{s.isPending||u(null)},onConfirm:ue,title:h?.builtIn?e("恢复默认 Provider"):e("删除 Provider"),description:h?.builtIn?e('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:h?.name}):e('确定删除 "{name}"?此操作不可撤销。',{name:h?.name}),confirmText:h?.builtIn?e("恢复默认"):e("删除"),cancelText:e("取消"),variant:"danger",isLoading:s.isPending}),n.jsx(mt,{isOpen:g,onClose:J,onConfirm:me,acknowledged:b,onAcknowledgedChange:C,isLoading:r.isPending}),n.jsx(xt,{isOpen:!!j,onClose:Y,preview:j?.preview??null,backup:j?.backup??null,onConfirm:pe,isLoading:d.isPending})]})}export{Et as ProviderSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as p}from"./index-
|
|
1
|
+
import{r as a,j as p}from"./index-BLRui4ck.js";import{a as V,c as k}from"./utils-CkSf8FUe.js";const y=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,b=V,E=(t,n)=>e=>{var i;if(n?.variants==null)return b(t,e?.class,e?.className);const{variants:r,defaultVariants:s}=n,u=Object.keys(r).map(o=>{const c=e?.[o],d=s?.[o];if(c===null)return null;const v=y(c)||y(d);return r[o][v]}),l=e&&Object.entries(e).reduce((o,c)=>{let[d,v]=c;return v===void 0||(o[d]=v),o},{}),f=n==null||(i=n.compoundVariants)===null||i===void 0?void 0:i.reduce((o,c)=>{let{class:d,className:v,...x}=c;return Object.entries(x).every(C=>{let[m,g]=C;return Array.isArray(g)?g.includes({...s,...l}[m]):{...s,...l}[m]===g})?[...o,d,v]:o},[]);return b(t,u,f,e?.class,e?.className)};function h(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function S(...t){return n=>{let e=!1;const i=t.map(r=>{const s=h(r,n);return!e&&typeof s=="function"&&(e=!0),s});if(e)return()=>{for(let r=0;r<i.length;r++){const s=i[r];typeof s=="function"?s():h(t[r],null)}}}}function j(t){const n=_(t),e=a.forwardRef((i,r)=>{const{children:s,...u}=i,l=a.Children.toArray(s),f=l.find(R);if(f){const o=f.props.children,c=l.map(d=>d===f?a.Children.count(o)>1?a.Children.only(null):a.isValidElement(o)?o.props.children:null:d);return p.jsx(n,{...u,ref:r,children:a.isValidElement(o)?a.cloneElement(o,void 0,c):null})}return p.jsx(n,{...u,ref:r,children:s})});return e.displayName=`${t}.Slot`,e}var z=j("Slot");function _(t){const n=a.forwardRef((e,i)=>{const{children:r,...s}=e;if(a.isValidElement(r)){const u=w(r),l=O(s,r.props);return r.type!==a.Fragment&&(l.ref=i?S(i,u):u),a.cloneElement(r,l)}return a.Children.count(r)>1?a.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var N=Symbol("radix.slottable");function R(t){return a.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===N}function O(t,n){const e={...n};for(const i in n){const r=t[i],s=n[i];/^on[A-Z]/.test(i)?r&&s?e[i]=(...l)=>{const f=s(...l);return r(...l),f}:r&&(e[i]=r):i==="style"?e[i]={...r,...s}:i==="className"&&(e[i]=[r,s].filter(Boolean).join(" "))}return{...t,...e}}function w(t){let n=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}const P=E("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function I({className:t,variant:n="default",size:e="default",asChild:i=!1,...r}){const s=i?z:"button";return p.jsx(s,{"data-slot":"button","data-variant":n,"data-size":e,className:k(P({variant:n,size:e,className:t})),...r})}export{I as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as o}from"./index-
|
|
1
|
+
import{h as o}from"./index-BLRui4ck.js";const c=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=o("check",c);const e=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],s=o("chevron-down",e);export{s as C,t as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as o}from"./index-
|
|
1
|
+
import{h as o}from"./index-BLRui4ck.js";const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],h=o("chevron-right",t);export{h as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./index-
|
|
1
|
+
import{h as e}from"./index-BLRui4ck.js";const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],y=e("circle-alert",c);export{y as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as c}from"./index-
|
|
1
|
+
import{h as c}from"./index-BLRui4ck.js";const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],r=c("circle-check",e);export{r as C};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{L as h,Z as x,I as p,g as u}from"./mermaid-NOHMQCX5-
|
|
1
|
+
import{L as h,Z as x,I as p,g as u}from"./mermaid-NOHMQCX5-xPQ5tFq8.js";import{r as i,j as a}from"./index-BLRui4ck.js";import"./log-adapter-CeKrvZcz.js";import"./chevron-right-Cpp4WiwB.js";import"./chevron-down-BXQh2Wxh.js";import"./utils-CkSf8FUe.js";var v=u("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),k=r=>{let e={};for(let l of r.split(";")){let o=l.indexOf(":");if(o>0){let c=l.slice(0,o).trim(),n=l.slice(o+1).trim();c&&n&&(e[c]=n)}}return e},j=i.memo(({children:r,result:e,language:l,className:o,...c})=>{let n=i.useMemo(()=>{let s={};return e.bg&&(s["--sdm-bg"]=e.bg),e.fg&&(s["--sdm-fg"]=e.fg),e.rootStyle&&Object.assign(s,k(e.rootStyle)),s},[e.bg,e.fg,e.rootStyle]);return a.jsx("pre",{className:u(o,"p-4 text-sm","bg-[var(--sdm-bg,transparent)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,transparent))]"),"data-language":l,"data-streamdown":"code-block-body",style:n,...c,children:a.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((s,d)=>a.jsx("span",{className:v,children:s.map((t,b)=>a.jsx("span",{className:u("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",t.bgColor&&"bg-[var(--sdm-tbg)]",t.bgColor&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:{...t.color?{"--sdm-c":t.color}:{},...t.bgColor?{"--sdm-tbg":t.bgColor}:{},...t.htmlStyle},...t.htmlAttrs,children:t.content},b))},d))})})},(r,e)=>r.result===e.result&&r.language===e.language&&r.className===e.className),y=({className:r,language:e,style:l,...o})=>a.jsx("div",{className:u("my-4 w-full overflow-hidden rounded-xl border border-border",r),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...l},...o}),N=({language:r,children:e})=>a.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":r,"data-streamdown":"code-block-header",children:[a.jsx("span",{className:"ml-1 font-mono lowercase",children:r}),a.jsx("div",{className:"flex items-center gap-2",children:e})]}),w=/\n+$/,O=({code:r,language:e,className:l,children:o,...c})=>{let{shikiTheme:n}=i.useContext(h),s=x(),d=i.useMemo(()=>r.replace(w,""),[r]),t=i.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
2
2
|
`).map(g=>[{content:g,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]),[b,m]=i.useState(t);return i.useEffect(()=>{if(!s){m(t);return}let g=s.highlight({code:d,language:e,themes:n},f=>{m(f)});if(g){m(g);return}m(t)},[d,e,n,s,t]),a.jsx(p.Provider,{value:{code:r},children:a.jsxs(y,{language:e,children:[a.jsx(N,{language:e,children:o}),a.jsx(j,{className:l,language:e,result:b,...c})]})})};export{O as CodeBlock};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as x,u as h,j as e}from"./index-
|
|
1
|
+
import{h as x,u as h,j as e}from"./index-BLRui4ck.js";import{M as u}from"./modal-CvoxLn2x.js";import{c as p}from"./utils-CkSf8FUe.js";const b=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],f=x("triangle-alert",b),N=({isOpen:n,onClose:a,onConfirm:l,title:i,description:d,confirmText:o="确认",cancelText:c="取消",variant:m="default",isLoading:t=!1})=>{const{t:s}=h(),r=m==="danger";return e.jsx(u,{isOpen:n,onClose:a,title:i,className:"max-w-sm",action:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:a,disabled:t,className:"px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:s(c)}),e.jsx("button",{onClick:l,disabled:t,className:p("px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-50",r?"bg-red-500 text-white hover:bg-red-600":"bg-neutral-900 text-white hover:bg-black"),children:s(t?"处理中...":o)})]}),children:e.jsxs("div",{className:"flex gap-4",children:[r&&e.jsx("div",{className:"shrink-0 w-10 h-10 rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(f,{size:20,className:"text-red-500"})}),e.jsx("div",{className:"text-sm text-neutral-600 leading-relaxed pt-1",children:d})]})})};export{N as C,f as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as q,r as a,g as w,j as e,F as E}from"./index-
|
|
1
|
+
import{u as q,r as a,g as w,j as e,F as E}from"./index-BLRui4ck.js";import{c as o}from"./utils-CkSf8FUe.js";import{C as S}from"./chevron-right-Cpp4WiwB.js";import{L as z}from"./loader-circle-DvZK36Ga.js";import{C as D}from"./circle-alert-B4o7LpBN.js";import{F as G}from"./rotate-ccw-BusOGXw0.js";function X({value:n,onChange:m,placeholder:P}){const{t:R}=q(),[c,V]=a.useState(""),[h,F]=a.useState([]),[f,L]=a.useState(""),[I,B]=a.useState("/"),[j,U]=a.useState([]),[A,g]=a.useState(!1),[b,N]=a.useState(null),[p,v]=a.useState(n),[y,i]=a.useState(null),[K,C]=a.useState(!1),k=a.useRef(!1);a.useEffect(()=>{v(n)},[n]);const r=a.useCallback(async t=>{g(!0),N(null);try{const s={};t&&(s.path=t);const l=await w.get("/filesystem/browse",{params:s});V(l.current),L(l.parent),B(l.sep||"/"),F(l.dirs),l.drives&&U(l.drives)}catch(s){N(s instanceof Error?s.message:"Failed to browse directory")}finally{g(!1)}},[]);a.useEffect(()=>{k.current||(k.current=!0,r())},[r]);const x=a.useCallback(async t=>{C(!0),i(null);try{const s=await w.get("/filesystem/validate",{params:{path:t}});s.valid?(m(t),i(null)):i(s.error??"Not a Git repository")}catch(s){i(s instanceof Error?s.message:"Validation failed")}finally{C(!1)}},[m]),W=a.useCallback(t=>{t.isGitRepo?(x(t.path),r(t.path)):(r(t.path),i(null))},[x,r]),d=I==="\\",u=c?c.split(/[\\/]/).filter(Boolean):[],Z=a.useCallback(t=>{const s=u.slice(0,t+1);let l;d?(l=s.join("\\"),s.length===1&&/^[A-Za-z]:$/.test(s[0])&&(l+="\\")):l="/"+s.join("/"),r(l),i(null)},[u,r,d]),$=a.useCallback(t=>{if(t.key==="Enter"&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229){t.preventDefault();const s=p.trim();s&&(r(s),x(s))}},[p,r,x]);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:p,onChange:t=>v(t.target.value),onKeyDown:$,placeholder:P??"e.g., /Users/me/projects/my-repo",className:o("w-full px-3 py-2 border rounded-lg text-sm font-mono focus:outline-none transition-colors pr-8",n?"border-emerald-300 bg-emerald-50/50 focus:border-emerald-400":"border-neutral-200 focus:border-neutral-400")}),n&&e.jsx(E,{size:14,className:"absolute right-3 top-1/2 -translate-y-1/2 text-emerald-500"})]}),e.jsx("p",{className:"text-xs text-neutral-400",children:R("Browse and select a Git repository, or type a path and press Enter")}),j.length>0&&e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:j.map(t=>e.jsx("button",{onClick:()=>{r(t),i(null)},className:o("px-2 py-0.5 rounded text-xs font-mono transition-colors border",c.toUpperCase().startsWith(t.toUpperCase())?"bg-neutral-900 text-white border-neutral-900":"border-neutral-200 text-neutral-600 hover:bg-neutral-100"),children:t.replace("\\","")},t))}),e.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-neutral-500 overflow-x-auto pb-1 scrollbar-none",children:[!d&&e.jsx("button",{onClick:()=>r("/"),className:"hover:text-neutral-900 transition-colors flex-shrink-0 px-1 py-0.5 rounded hover:bg-neutral-100",children:"/"}),u.map((t,s)=>e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[(d?s>0:!0)&&e.jsx(S,{size:10,className:"text-neutral-300"}),e.jsx("button",{onClick:()=>Z(s),className:o("px-1 py-0.5 rounded transition-colors truncate max-w-[120px]",s===u.length-1?"font-medium text-neutral-900":"hover:text-neutral-900 hover:bg-neutral-100"),children:t})]},s))]}),e.jsx("div",{className:"border border-neutral-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"max-h-[200px] overflow-y-auto",children:A?e.jsxs("div",{className:"flex items-center justify-center py-8 text-neutral-400",children:[e.jsx(z,{size:16,className:"animate-spin mr-2"}),e.jsx("span",{className:"text-xs",children:"Loading..."})]}):b?e.jsxs("div",{className:"flex items-center justify-center py-8 text-red-500 gap-2",children:[e.jsx(D,{size:14}),e.jsx("span",{className:"text-xs",children:b})]}):h.length===0?e.jsx("div",{className:"flex items-center justify-center py-8 text-neutral-400",children:e.jsx("span",{className:"text-xs",children:"No subdirectories"})}):e.jsxs("ul",{className:"divide-y divide-neutral-100",children:[c!==f&&e.jsx("li",{children:e.jsxs("button",{onClick:()=>r(f),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-neutral-50 transition-colors group",children:[e.jsx(G,{size:14,className:"text-neutral-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-neutral-500 group-hover:text-neutral-700",children:".."})]})}),h.map(t=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>W(t),className:o("w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors group",t.path===n?"bg-emerald-50":"hover:bg-neutral-50"),children:[t.isGitRepo?e.jsx(E,{size:14,className:"text-emerald-500 flex-shrink-0"}):e.jsx(G,{size:14,className:"text-neutral-400 flex-shrink-0"}),e.jsx("span",{className:o("text-xs truncate",t.path===n?"font-medium text-emerald-700":"text-neutral-700 group-hover:text-neutral-900"),children:t.name}),t.isGitRepo&&e.jsx("span",{className:"ml-auto flex-shrink-0 text-[10px] font-medium bg-emerald-100 text-emerald-600 px-1.5 py-0.5 rounded",children:"Git"}),!t.isGitRepo&&e.jsx(S,{size:12,className:"ml-auto text-neutral-300 group-hover:text-neutral-400 flex-shrink-0"})]})},t.path))]})})}),K&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-400",children:[e.jsx(z,{size:12,className:"animate-spin"}),e.jsx("span",{children:"Validating..."})]}),y&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500",children:[e.jsx(D,{size:12}),e.jsx("span",{children:y})]})]})}export{X as FolderPicker};
|