agent-tower 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/executors/__tests__/providers.test.d.ts +2 -0
- package/dist/executors/__tests__/providers.test.d.ts.map +1 -0
- package/dist/executors/__tests__/providers.test.js +129 -0
- package/dist/executors/__tests__/providers.test.js.map +1 -0
- package/dist/executors/base.executor.d.ts.map +1 -1
- package/dist/executors/base.executor.js +7 -11
- package/dist/executors/base.executor.js.map +1 -1
- package/dist/executors/claude-code.executor.d.ts +2 -2
- package/dist/executors/claude-code.executor.d.ts.map +1 -1
- package/dist/executors/claude-code.executor.js +1 -1
- package/dist/executors/claude-code.executor.js.map +1 -1
- package/dist/executors/codex.executor.d.ts +9 -1
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +102 -13
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/executors/default-profiles.json +2 -1
- package/dist/executors/default-providers.json +2 -1
- package/dist/executors/image-utils.d.ts +8 -0
- package/dist/executors/image-utils.d.ts.map +1 -1
- package/dist/executors/image-utils.js +25 -0
- package/dist/executors/image-utils.js.map +1 -1
- package/dist/executors/index.d.ts +1 -1
- package/dist/executors/index.d.ts.map +1 -1
- package/dist/executors/index.js +23 -5
- package/dist/executors/index.js.map +1 -1
- package/dist/executors/providers.d.ts +7 -2
- package/dist/executors/providers.d.ts.map +1 -1
- package/dist/executors/providers.js +120 -1
- package/dist/executors/providers.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/output/codex-parser.d.ts +22 -3
- package/dist/output/codex-parser.d.ts.map +1 -1
- package/dist/output/codex-parser.js +106 -11
- package/dist/output/codex-parser.js.map +1 -1
- package/dist/routes/providers.d.ts +3 -0
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +70 -3
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/workspaces.d.ts.map +1 -1
- package/dist/routes/workspaces.js +1 -0
- package/dist/routes/workspaces.js.map +1 -1
- package/dist/services/terminal-manager.d.ts +1 -1
- package/dist/services/terminal-manager.d.ts.map +1 -1
- package/dist/services/terminal-manager.js +4 -3
- package/dist/services/terminal-manager.js.map +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/process-launch.d.ts +11 -0
- package/dist/utils/process-launch.d.ts.map +1 -0
- package/dist/utils/process-launch.js +119 -0
- package/dist/utils/process-launch.js.map +1 -0
- package/dist/utils/process-launch.test.d.ts +2 -0
- package/dist/utils/process-launch.test.d.ts.map +1 -0
- package/dist/utils/process-launch.test.js +52 -0
- package/dist/utils/process-launch.test.js.map +1 -0
- package/dist/web/assets/{AgentDemoPage-DbReHEIF.js → AgentDemoPage-DSyU6XMx.js} +1 -1
- package/dist/web/assets/{DemoPage-U0U06JBX.js → DemoPage-BxYQv1Wa.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-CdbIEiFm.js → NotificationSettingsPage-mln4lAxn.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-DXdb0LKC.js → ProfileSettingsPage-CS-WK307.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-DmTUqq3c.js → ProjectKanbanPage-Bz0Q0ZZy.js} +3 -3
- package/dist/web/assets/{ProjectSettingsPage-X9m7tZ5R.js → ProjectSettingsPage-CBnahNua.js} +1 -1
- package/dist/web/assets/ProviderSettingsPage-D-Lrg1Sj.js +54 -0
- package/dist/web/assets/{api-client-DEke6rQ4.js → api-client-iFY2ykuZ.js} +1 -1
- package/dist/web/assets/{chevron-down-CpFVmwPg.js → chevron-down-CxTrrnvp.js} +1 -1
- package/dist/web/assets/{circle-alert-Gs_wxunt.js → circle-alert-CHDHEO67.js} +1 -1
- package/dist/web/assets/{circle-check-BPbbKebL.js → circle-check-uswR_cEa.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-B9uttJeR.js → code-block-OCS4YCEC-VVSDpKw-.js} +1 -1
- package/dist/web/assets/{folder-picker-q3bDqZNK.js → folder-picker-DshGpYNS.js} +1 -1
- package/dist/web/assets/index-Br9066ZX.css +1 -0
- package/dist/web/assets/{index-yP6NT0d4.js → index-hdGFeHu1.js} +2 -2
- package/dist/web/assets/{loader-circle-BPfuUlPS.js → loader-circle-BYF33K7x.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-tkavilGV.js → mermaid-NOHMQCX5-CQLrOBEw.js} +3 -3
- package/dist/web/assets/{modal-Cm1qLsdb.js → modal-BCL0660p.js} +1 -1
- package/dist/web/assets/{pencil-BJvmRaTF.js → pencil-SJi1qbh9.js} +1 -1
- package/dist/web/assets/{query-keys-DfqkAgsV.js → query-keys-B2VhRmAm.js} +1 -1
- package/dist/web/assets/{select-Dchwldvd.js → select-WuDnj3zN.js} +1 -1
- package/dist/web/assets/{use-profiles-DVKFw38N.js → use-profiles-DYTDOkn8.js} +1 -1
- package/dist/web/assets/{use-projects-CYLR7Ikg.js → use-projects-BLI6qXx-.js} +1 -1
- package/dist/web/assets/use-providers-C1i5uxRH.js +1 -0
- package/dist/web/assets/{x-C1fyolLz.js → x-Bn5zgMLL.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +29 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/package.json +2 -1
- package/dist/web/assets/ProviderSettingsPage-rrgndhUT.js +0 -1
- package/dist/web/assets/index-Bdp1rkP7.css +0 -1
- package/dist/web/assets/use-providers-Ce2CzdA7.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-
|
|
2
|
-
import{y as Pr,z as wo,A as Eo,a as ko,q as tr,d as Ro,B as Do,u as Ie,r as R,n as To,c as ve,R as ee,D as Rt,j as a,s as ht,S as We,C as nt,i as Yt,g as Vt,E as Fi,G as jo,H as Lo,L as Or,_ as Hi}from"./index-yP6NT0d4.js";import{Q as dr,b as Ao,c as No,e as Mo,d as Po,f as Oo,s as Br,g as Ir,w as Bo,h as Io,i as Fo,a as Ge,q as ce,u as at}from"./query-keys-DfqkAgsV.js";import{C as kt,h as fr,b as pr,d as mr,c as vr,i as gr,G as Es,u as zi,a as Wi,Q as $i,e as Ui,T as qi,P as ds,f as Ki,S as Fr}from"./mermaid-NOHMQCX5-tkavilGV.js";import{C as gt,a as fs}from"./chevron-down-CpFVmwPg.js";import{P as sr,X as ks}from"./x-C1fyolLz.js";import{u as _r,C as Ho,S as Oe,T as it,A as is}from"./use-providers-Ce2CzdA7.js";import"./log-adapter-50wgehrc.js";import{a as be,c as Se,B as ot,t as Xi}from"./api-client-DEke6rQ4.js";import{F as zo,a as Wo,c as $o,u as Uo,d as qo}from"./use-projects-CYLR7Ikg.js";import{L as Be}from"./loader-circle-BPfuUlPS.js";import{M as Rs,T as Yi}from"./modal-Cm1qLsdb.js";import{S as ns}from"./select-Dchwldvd.js";var Ko=class extends dr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Pr()})}getOptimisticResult(e){return e.behavior=Pr(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,l=super.createResult(e,t),{isFetching:m,isRefetching:b,isError:C,isRefetchError:r}=l,i=s.fetchMeta?.fetchMore?.direction,c=C&&i==="forward",d=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Eo(t,s.data),hasPreviousPage:wo(t,s.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:b&&!d&&!p}}};function Hr(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function Xo(e,t,s){const l=e.slice(0);return l[t]=s,l}var Yo=class extends ko{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,s){super(),this.#r=e,this.#n=s,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,tr.batch(()=>{const s=this.#t,l=this.#d(this.#i);l.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const m=l.map(d=>d.observer),b=m.map(d=>d.getCurrentResult()),C=s.length!==m.length,r=m.some((d,o)=>d!==s[o]),i=C||r,c=i?!0:b.some((d,o)=>{const p=this.#e[o];return!p||!Ro(d,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=b,this.hasListeners()&&(i&&(Hr(s,m).forEach(d=>{d.destroy()}),Hr(m,s).forEach(d=>{d.subscribe(o=>{this.#f(d,o)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),l=s.map(b=>b.observer.getOptimisticResult(b.defaultedQueryOptions)),m=s.map(b=>b.defaultedQueryOptions.queryHash);return[l,b=>this.#u(b??l,t,m),()=>this.#h(l,s)]}#h(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,b=>{t.forEach(C=>{C.observer.trackProp(b)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((b,C)=>b!==l[C]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=Do(this.#s,t(e))),this.#s}return e}#d(e){const t=new Map;this.#t.forEach(l=>{const m=l.options.queryHash;if(!m)return;const b=t.get(m);b?b.push(l):t.set(m,[l])});const s=[];return e.forEach(l=>{const m=this.#r.defaultQueryOptions(l),C=t.get(m.queryHash)?.shift()??new dr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=Xo(this.#e,s,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&tr.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function Vo({queries:e,...t},s){const l=Ie(),m=Ao(),b=No(),C=R.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{Mo(g);const n=l.getQueryCache().get(g.queryHash);Po(g,b,n)}),Oo(b);const[r]=R.useState(()=>new Yo(l,C,t)),[i,c,d]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(g=>o?r.subscribe(tr.batchCalls(g)):To,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),R.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const _=i.some((g,n)=>Br(C[n],g))?i.flatMap((g,n)=>{const f=C[n];if(f){const h=new dr(l,f);if(Br(f,g))return Ir(f,h,b);Bo(g,m)&&Ir(f,h,b)}return[]}):[];if(_.length>0)throw Promise.all(_);const S=i.find((g,n)=>{const f=C[n];return f&&Io({result:g,errorResetBoundary:b,throwOnError:f.throwOnError,query:l.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(S?.error)throw S.error;return c(d())}function Vi(e,t){return Fo(e,Ko)}const Go=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Gi=ve("arrow-down",Go);const Qo=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Qi=ve("arrow-right",Qo);const Zo=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Zi=ve("arrow-up",Zo);const Jo=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],zr=ve("circle-check-big",Jo);const ea=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Ds=ve("code-xml",ea);const ta=[["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"}]],Wr=ve("copy",ta);const sa=[["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"}]],Ji=ve("ellipsis-vertical",sa);const ra=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],ia=ve("file-braces-corner",ra);const na=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Wt=ve("file-code-corner",na);const oa=[["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:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aa=ve("file-exclamation-point",oa);const la=[["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"}]],en=ve("file-text",la);const ca=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],tn=ve("folder-open",ca);const ha=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ua=ve("gauge",ha);const da=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],fa=ve("git-branch",da);const pa=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],ma=ve("git-fork",pa);const va=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],$t=ve("git-graph",va);const ga=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],sn=ve("git-merge",ga);const _a=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],At=ve("history",_a);const ba=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],br=ve("image",ba);const xa=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],$r=ve("layers",xa);const Sa=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],ya=ve("maximize",Sa);const Ca=[["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"}]],wa=ve("message-square",Ca);const Ea=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],ka=ve("panel-left-close",Ea);const Ra=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Da=ve("panel-left-open",Ra);const Ta=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],ja=ve("panel-right-close",Ta);const La=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Aa=ve("panel-right-open",La);const Na=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],jt=ve("play",Na);const Ma=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Pa=ve("refresh-cw",Ma);const Oa=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Ba=ve("shield",Oa);const Ia=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ps=ve("terminal",Ia);const Fa=[["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"}]],xr=ve("triangle-alert",Fa);const Ha=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],za=ve("zap",Ha);const Wa=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],$a=ve("zoom-in",Wa);const Ua=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],qa=ve("zoom-out",Ua),Ts=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Nt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Sr(e){return"nodeType"in e}function Ye(e){var t,s;return e?Nt(e)?e:Sr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function yr(e){const{Document:t}=Ye(e);return e instanceof t}function Gt(e){return Nt(e)?!1:e instanceof Ye(e).HTMLElement}function rn(e){return e instanceof Ye(e).SVGElement}function Mt(e){return e?Nt(e)?e.document:Sr(e)?yr(e)?e:Gt(e)||rn(e)?e.ownerDocument:document:document:document}const ut=Ts?R.useLayoutEffect:R.useEffect;function js(e){const t=R.useRef(e);return ut(()=>{t.current=e}),R.useCallback(function(){for(var s=arguments.length,l=new Array(s),m=0;m<s;m++)l[m]=arguments[m];return t.current==null?void 0:t.current(...l)},[])}function Ka(){const e=R.useRef(null),t=R.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=R.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function Ut(e,t){t===void 0&&(t=[e]);const s=R.useRef(e);return ut(()=>{s.current!==e&&(s.current=e)},t),s}function Qt(e,t){const s=R.useRef();return R.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function ms(e){const t=js(e),s=R.useRef(null),l=R.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function vs(e){const t=R.useRef();return R.useEffect(()=>{t.current=e},[e]),t.current}let Hs={};function Ls(e,t){return R.useMemo(()=>{if(t)return t;const s=Hs[e]==null?0:Hs[e]+1;return Hs[e]=s,e+"-"+s},[e,t])}function nn(e){return function(t){for(var s=arguments.length,l=new Array(s>1?s-1:0),m=1;m<s;m++)l[m-1]=arguments[m];return l.reduce((b,C)=>{const r=Object.entries(C);for(const[i,c]of r){const d=b[i];d!=null&&(b[i]=d+e*c)}return b},{...t})}}const Lt=nn(1),gs=nn(-1);function Xa(e){return"clientX"in e&&"clientY"in e}function Cr(e){if(!e)return!1;const{KeyboardEvent:t}=Ye(e.target);return t&&e instanceof t}function Ya(e){if(!e)return!1;const{TouchEvent:t}=Ye(e.target);return t&&e instanceof t}function _s(e){if(Ya(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return Xa(e)?{x:e.clientX,y:e.clientY}:null}const qt=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[qt.Translate.toString(e),qt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),Ur="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Va(e){return e.matches(Ur)?e:e.querySelector(Ur)}const Ga={display:"none"};function Qa(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:Ga},s)}function Za(e){let{id:t,announcement:s,ariaLiveType:l="assertive"}=e;const m={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ee.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Ja(){const[e,t]=R.useState("");return{announce:R.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const on=R.createContext(null);function el(e){const t=R.useContext(on);R.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function tl(){const[e]=R.useState(()=>new Set),t=R.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[R.useCallback(l=>{let{type:m,event:b}=l;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,b)})},[e]),t]}const sl={draggable:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-BCL0660p.js","assets/index-hdGFeHu1.js","assets/index-Br9066ZX.css","assets/api-client-iFY2ykuZ.js","assets/x-Bn5zgMLL.js","assets/folder-picker-DshGpYNS.js","assets/mermaid-NOHMQCX5-CQLrOBEw.js","assets/log-adapter-50wgehrc.js","assets/chevron-down-CxTrrnvp.js","assets/mermaid-NOHMQCX5-lI9o3AWT.css","assets/loader-circle-BYF33K7x.js","assets/circle-alert-CHDHEO67.js","assets/use-projects-BLI6qXx-.js","assets/query-keys-B2VhRmAm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{z as Pr,A as wo,B as Eo,a as ko,q as tr,d as Ro,D as Do,u as Ie,r as R,n as To,c as ve,R as ee,E as Rt,j as a,s as ht,S as We,C as nt,i as Yt,g as Vt,G as Fi,H as jo,y as Lo,L as Or,_ as Hi}from"./index-hdGFeHu1.js";import{Q as dr,b as Ao,c as No,e as Mo,d as Po,f as Oo,s as Br,g as Ir,w as Bo,h as Io,i as Fo,a as Ge,q as ce,u as at}from"./query-keys-B2VhRmAm.js";import{C as kt,h as fr,b as pr,d as mr,c as vr,i as gr,G as Es,u as zi,a as Wi,Q as $i,e as Ui,T as qi,P as ds,f as Ki,S as Fr}from"./mermaid-NOHMQCX5-CQLrOBEw.js";import{C as gt,a as fs}from"./chevron-down-CxTrrnvp.js";import{P as sr,X as ks}from"./x-Bn5zgMLL.js";import{u as _r,C as Ho,S as Oe,T as it,A as is}from"./use-providers-C1i5uxRH.js";import"./log-adapter-50wgehrc.js";import{a as be,c as Se,B as ot,t as Xi}from"./api-client-iFY2ykuZ.js";import{F as zo,a as Wo,c as $o,u as Uo,d as qo}from"./use-projects-BLI6qXx-.js";import{L as Be}from"./loader-circle-BYF33K7x.js";import{M as Rs,T as Yi}from"./modal-BCL0660p.js";import{S as ns}from"./select-WuDnj3zN.js";var Ko=class extends dr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Pr()})}getOptimisticResult(e){return e.behavior=Pr(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,l=super.createResult(e,t),{isFetching:m,isRefetching:b,isError:C,isRefetchError:r}=l,i=s.fetchMeta?.fetchMore?.direction,c=C&&i==="forward",d=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Eo(t,s.data),hasPreviousPage:wo(t,s.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:b&&!d&&!p}}};function Hr(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function Xo(e,t,s){const l=e.slice(0);return l[t]=s,l}var Yo=class extends ko{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,s){super(),this.#r=e,this.#n=s,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,tr.batch(()=>{const s=this.#t,l=this.#d(this.#i);l.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const m=l.map(d=>d.observer),b=m.map(d=>d.getCurrentResult()),C=s.length!==m.length,r=m.some((d,o)=>d!==s[o]),i=C||r,c=i?!0:b.some((d,o)=>{const p=this.#e[o];return!p||!Ro(d,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=b,this.hasListeners()&&(i&&(Hr(s,m).forEach(d=>{d.destroy()}),Hr(m,s).forEach(d=>{d.subscribe(o=>{this.#f(d,o)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),l=s.map(b=>b.observer.getOptimisticResult(b.defaultedQueryOptions)),m=s.map(b=>b.defaultedQueryOptions.queryHash);return[l,b=>this.#u(b??l,t,m),()=>this.#h(l,s)]}#h(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,b=>{t.forEach(C=>{C.observer.trackProp(b)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((b,C)=>b!==l[C]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=Do(this.#s,t(e))),this.#s}return e}#d(e){const t=new Map;this.#t.forEach(l=>{const m=l.options.queryHash;if(!m)return;const b=t.get(m);b?b.push(l):t.set(m,[l])});const s=[];return e.forEach(l=>{const m=this.#r.defaultQueryOptions(l),C=t.get(m.queryHash)?.shift()??new dr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=Xo(this.#e,s,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&tr.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function Vo({queries:e,...t},s){const l=Ie(),m=Ao(),b=No(),C=R.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{Mo(g);const n=l.getQueryCache().get(g.queryHash);Po(g,b,n)}),Oo(b);const[r]=R.useState(()=>new Yo(l,C,t)),[i,c,d]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(g=>o?r.subscribe(tr.batchCalls(g)):To,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),R.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const _=i.some((g,n)=>Br(C[n],g))?i.flatMap((g,n)=>{const f=C[n];if(f){const h=new dr(l,f);if(Br(f,g))return Ir(f,h,b);Bo(g,m)&&Ir(f,h,b)}return[]}):[];if(_.length>0)throw Promise.all(_);const S=i.find((g,n)=>{const f=C[n];return f&&Io({result:g,errorResetBoundary:b,throwOnError:f.throwOnError,query:l.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(S?.error)throw S.error;return c(d())}function Vi(e,t){return Fo(e,Ko)}const Go=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Gi=ve("arrow-down",Go);const Qo=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Qi=ve("arrow-right",Qo);const Zo=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Zi=ve("arrow-up",Zo);const Jo=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],zr=ve("circle-check-big",Jo);const ea=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Ds=ve("code-xml",ea);const ta=[["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"}]],Wr=ve("copy",ta);const sa=[["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"}]],Ji=ve("ellipsis-vertical",sa);const ra=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],ia=ve("file-braces-corner",ra);const na=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Wt=ve("file-code-corner",na);const oa=[["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:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aa=ve("file-exclamation-point",oa);const la=[["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"}]],en=ve("file-text",la);const ca=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],tn=ve("folder-open",ca);const ha=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ua=ve("gauge",ha);const da=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],fa=ve("git-branch",da);const pa=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],ma=ve("git-fork",pa);const va=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],$t=ve("git-graph",va);const ga=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],sn=ve("git-merge",ga);const _a=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],At=ve("history",_a);const ba=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],br=ve("image",ba);const xa=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],$r=ve("layers",xa);const Sa=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],ya=ve("maximize",Sa);const Ca=[["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"}]],wa=ve("message-square",Ca);const Ea=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],ka=ve("panel-left-close",Ea);const Ra=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Da=ve("panel-left-open",Ra);const Ta=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],ja=ve("panel-right-close",Ta);const La=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Aa=ve("panel-right-open",La);const Na=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],jt=ve("play",Na);const Ma=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Pa=ve("refresh-cw",Ma);const Oa=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Ba=ve("shield",Oa);const Ia=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ps=ve("terminal",Ia);const Fa=[["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"}]],xr=ve("triangle-alert",Fa);const Ha=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],za=ve("zap",Ha);const Wa=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],$a=ve("zoom-in",Wa);const Ua=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],qa=ve("zoom-out",Ua),Ts=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Nt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Sr(e){return"nodeType"in e}function Ye(e){var t,s;return e?Nt(e)?e:Sr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function yr(e){const{Document:t}=Ye(e);return e instanceof t}function Gt(e){return Nt(e)?!1:e instanceof Ye(e).HTMLElement}function rn(e){return e instanceof Ye(e).SVGElement}function Mt(e){return e?Nt(e)?e.document:Sr(e)?yr(e)?e:Gt(e)||rn(e)?e.ownerDocument:document:document:document}const ut=Ts?R.useLayoutEffect:R.useEffect;function js(e){const t=R.useRef(e);return ut(()=>{t.current=e}),R.useCallback(function(){for(var s=arguments.length,l=new Array(s),m=0;m<s;m++)l[m]=arguments[m];return t.current==null?void 0:t.current(...l)},[])}function Ka(){const e=R.useRef(null),t=R.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=R.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function Ut(e,t){t===void 0&&(t=[e]);const s=R.useRef(e);return ut(()=>{s.current!==e&&(s.current=e)},t),s}function Qt(e,t){const s=R.useRef();return R.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function ms(e){const t=js(e),s=R.useRef(null),l=R.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function vs(e){const t=R.useRef();return R.useEffect(()=>{t.current=e},[e]),t.current}let Hs={};function Ls(e,t){return R.useMemo(()=>{if(t)return t;const s=Hs[e]==null?0:Hs[e]+1;return Hs[e]=s,e+"-"+s},[e,t])}function nn(e){return function(t){for(var s=arguments.length,l=new Array(s>1?s-1:0),m=1;m<s;m++)l[m-1]=arguments[m];return l.reduce((b,C)=>{const r=Object.entries(C);for(const[i,c]of r){const d=b[i];d!=null&&(b[i]=d+e*c)}return b},{...t})}}const Lt=nn(1),gs=nn(-1);function Xa(e){return"clientX"in e&&"clientY"in e}function Cr(e){if(!e)return!1;const{KeyboardEvent:t}=Ye(e.target);return t&&e instanceof t}function Ya(e){if(!e)return!1;const{TouchEvent:t}=Ye(e.target);return t&&e instanceof t}function _s(e){if(Ya(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return Xa(e)?{x:e.clientX,y:e.clientY}:null}const qt=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[qt.Translate.toString(e),qt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),Ur="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Va(e){return e.matches(Ur)?e:e.querySelector(Ur)}const Ga={display:"none"};function Qa(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:Ga},s)}function Za(e){let{id:t,announcement:s,ariaLiveType:l="assertive"}=e;const m={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ee.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Ja(){const[e,t]=R.useState("");return{announce:R.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const on=R.createContext(null);function el(e){const t=R.useContext(on);R.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function tl(){const[e]=R.useState(()=>new Set),t=R.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[R.useCallback(l=>{let{type:m,event:b}=l;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,b)})},[e]),t]}const sl={draggable:`
|
|
3
3
|
To pick up a draggable item, press the space bar.
|
|
4
4
|
While dragging, use the arrow keys to move the item.
|
|
5
5
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
@@ -78,7 +78,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
78
78
|
`);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((i,c)=>{let d="",o="text-neutral-400";return i.startsWith("+")&&!i.startsWith("+++")?(d="bg-emerald-950/40",o="text-emerald-400"):i.startsWith("-")&&!i.startsWith("---")?(d="bg-red-950/40",o="text-red-400"):i.startsWith("@@")&&(d="bg-blue-950/30",o="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",d,o),children:i},c)})})}function Yf({entry:e,type:t,workingDir:s}){const[l,m]=R.useState(!1),b=Ti[e.status]||Ti.M,C=Kf(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:Se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[a.jsx("span",{className:Se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",b),children:e.status}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:qf(e.path)}),C&&a.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),a.jsx("span",{className:"text-neutral-400 shrink-0",children:l?a.jsx(gt,{size:14}):a.jsx(kt,{size:14})})]}),l&&a.jsx(Xf,{workingDir:s,filePath:e.path,type:t})]})}function ji({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const[b,C]=R.useState(m);return t.length===0?null:a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>C(r=>!r),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[a.jsx("span",{className:"text-neutral-400",children:b?a.jsx(gt,{size:14}):a.jsx(kt,{size:14})}),a.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:e}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),b&&a.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(r=>a.jsx(Yf,{entry:r,type:s,workingDir:l},`${s}:${r.path}`))})]})}function Vf({workingDir:e}){const{data:t,isLoading:s,isError:l}=Qn(e);if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:"No workspace selected."});if(s)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:"Loading changes..."})]});if(l)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:"Failed to load changes."});const m=t?.uncommitted||[],b=t?.committed||[];return m.length+b.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx($t,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:"No pending changes"})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx(ji,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),a.jsx(ji,{title:"Committed",entries:b,type:"committed",workingDir:e,defaultOpen:!1})]})}const Js=50,Li={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function Gf(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:s<86400?`${Math.floor(s/3600)}h ago`:s<604800?`${Math.floor(s/86400)}d ago`:new Date(e*1e3).toLocaleDateString()}function Qf(e){const t=e.split("/");return t[t.length-1]||e}function Zf(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Jf({workingDir:e,hash:t,filePath:s}){const{data:l,isLoading:m,isError:b}=eo(e,t,s);if(m)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(Be,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:"Failed to load diff."});const C=l?.diff||"";if(!C.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No diff content."});const r=C.split(`
|
|
79
79
|
`);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((i,c)=>{let d="",o="text-neutral-400";return i.startsWith("+")&&!i.startsWith("+++")?(d="bg-emerald-950/40",o="text-emerald-400"):i.startsWith("-")&&!i.startsWith("---")?(d="bg-red-950/40",o="text-red-400"):i.startsWith("@@")&&(d="bg-blue-950/30",o="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",d,o),children:i},c)})})}function ep({entry:e,workingDir:t,hash:s}){const[l,m]=R.useState(!1),b=Li[e.status]||Li.M,C=Zf(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:Se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[a.jsx("span",{className:Se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",b),children:e.status}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Qf(e.path)}),C&&a.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),a.jsx("span",{className:"text-neutral-400 shrink-0",children:l?a.jsx(gt,{size:14}):a.jsx(kt,{size:14})})]}),l&&a.jsx(Jf,{workingDir:t,hash:s,filePath:e.path})]})}function tp({commit:e,workingDir:t}){const[s,l]=R.useState(!1),{data:m,isLoading:b}=Jn(t,s?e.hash:null),C=m?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>l(r=>!r),className:Se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",s&&"bg-neutral-50"),children:[a.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:a.jsx("div",{className:Se("w-2.5 h-2.5 rounded-full shrink-0",s?"bg-blue-500":"bg-neutral-300")})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),a.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[a.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),a.jsx("span",{className:"text-[11px] text-neutral-400",children:Gf(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:s?a.jsx(gt,{size:14}):a.jsx(kt,{size:14})})]}),s&&a.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&a.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),b?a.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[a.jsx(Be,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:"Loading files..."})]}):C.length===0?a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No files changed"}):a.jsx("div",{className:"divide-y divide-neutral-100",children:C.map(r=>a.jsx(ep,{entry:r,workingDir:t,hash:e.hash},r.path))})]})]})}function sp({workingDir:e}){const{data:t,isLoading:s,isError:l,fetchNextPage:m,hasNextPage:b,isFetchingNextPage:C}=Vi({queryKey:ce.git.log(e||""),queryFn:({pageParam:i=0})=>be.get("/git/log",{params:{workingDir:e||"",limit:String(Js),skip:String(i)}}),initialPageParam:0,getNextPageParam:(i,c)=>i.commits.length<Js?void 0:c.length*Js,enabled:!!e}),r=t?.pages.flatMap(i=>i.commits)||[];return e?s?a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:"Loading history..."})]}):l?a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:"Failed to load history."}):r.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(At,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:"No commit history"})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx("div",{className:"divide-y divide-neutral-100",children:r.map(i=>a.jsx(tp,{commit:i,workingDir:e},i.hash))}),b&&a.jsx("button",{type:"button",onClick:()=>m(),disabled:C,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:C?a.jsxs(a.Fragment,{children:[a.jsx(Be,{size:14,className:"animate-spin"})," Loading..."]}):"Load more"})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:"No workspace selected."})}const rp="/api";function ip(e){if(!Yt())return e;const t=Vt();if(!t)return e;const s=e.includes("?")?"&":"?";return`${e}${s}token=${encodeURIComponent(t)}`}const np=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?ip(`${rp}/attachments/by-path?path=${encodeURIComponent(e)}`):e,op=({src:e,alt:t,...s})=>a.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:a.jsx("img",{src:e,alt:t,...s,className:"max-w-[300px] max-h-[200px] object-contain rounded-lg border border-neutral-200 cursor-pointer active:opacity-90 transition-opacity"})}),ap={img:op};function lp({status:e}){const t={[le.Running]:"bg-blue-500",[le.Review]:"bg-amber-500",[le.Pending]:"bg-neutral-400",[le.Done]:"bg-emerald-500",[le.Cancelled]:"bg-neutral-400"};return a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const cp=[{key:"chat",label:"Chat",icon:wa},{key:"changes",label:"Changes",icon:$t},{key:"history",label:"History",icon:At},{key:"workspace",label:"Workspace",icon:tn}];function hp({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const[m,b]=R.useState("chat"),[C,r]=R.useState(""),[i,c]=R.useState(!1),[d,o]=R.useState(!1),[p,_]=R.useState(!1),S=R.useRef(null),g=R.useRef(null),n=R.useRef(null),{scrollRef:f,contentRef:h,isAtBottom:u,scrollToBottom:v}=Cn({resize:"smooth",initial:"instant"}),x=Ie();R.useEffect(()=>{if(!p)return;const Q=se=>{S.current&&!S.current.contains(se.target)&&_(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[p]);const{data:w,isLoading:k}=so(e.id),y=R.useMemo(()=>{if(!w)return null;const Q=w.filter(ne=>ne.status==="ACTIVE"&&Array.isArray(ne.sessions)).flatMap(ne=>ne.sessions??[]),se=ne=>{const ge=ne.createdAt,me=ne.endedAt??ne.startedAt??ge;if(!me)return 0;const ye=Date.parse(me);return Number.isNaN(ye)?0:ye},ue=ne=>{const ge=Q.filter(me=>ne.includes(me.status));return ge.length===0?null:ge.sort((me,ye)=>se(ye)-se(me))[0]??null};return ue([Oe.RUNNING])??ue([Oe.PENDING])??ue([Oe.COMPLETED,Oe.FAILED,Oe.CANCELLED])},[w]),E=y?.id??"",j=y?.status===Oe.RUNNING||y?.status===Oe.PENDING,A=oo(y),L=R.useMemo(()=>{if(w){for(const Q of w)if(Q.status==="ACTIVE"&&Q.worktreePath)return Q.worktreePath;return w[0]?.worktreePath}},[w]),N=R.useMemo(()=>{if(w)return w.find(Q=>Q.status==="ACTIVE")?.id},[w]),B=R.useMemo(()=>{const Q=[];if(w&&w.length>0){const se=w.some(ne=>ne.status==="ACTIVE");w.some(ne=>ne.sessions?.some(ge=>ge.status===Oe.RUNNING||ge.status===Oe.PENDING))&&Q.push("正在运行的 Agent 将被停止"),se&&(Q.push("分支上未合并的变更将丢失"),Q.push("关联的工作目录(worktree)将被清理"))}return Q},[w]),I=Nr(),H=Ar(),W=no(),{isConnected:D,isLoadingSnapshot:M,logs:P,entries:O,attach:U}=zi({sessionId:E,onExit:R.useCallback(()=>{x.invalidateQueries({queryKey:["workspaces"]})},[x])}),{todos:K}=Wi(O),{files:V,addFiles:Y,removeFile:ie,clear:T,buildMarkdownLinks:F,hasFiles:$,isUploading:z}=Mr(),J=R.useMemo(()=>{if(!y?.tokenUsage)return;const Q=y.tokenUsage;if(typeof Q.totalTokens=="number")return Q},[y?.tokenUsage]),X=ao(P,J);R.useEffect(()=>{E&&D&&U()},[E,D,U]),R.useEffect(()=>{v()},[e.id,v]);const oe=R.useRef(!1),he=R.useCallback(async()=>{if(!C.trim()&&!$||!E||oe.current||z)return;oe.current=!0;const Q=F(),se=[C.trim(),Q].filter(Boolean).join(`
|
|
80
80
|
|
|
81
|
-
`);r(""),T(),g.current&&(g.current.style.height="40px"),I.mutate({id:E,message:se},{onSuccess:()=>U(),onSettled:()=>{oe.current=!1}})},[C,E,I,U,$,z,F,T]),we=R.useCallback(async()=>{E&&(await W.mutateAsync(E),x.invalidateQueries({queryKey:["workspaces"]}))},[E,W,x]),je=R.useCallback(Q=>{const se=Q.target.files;se&&se.length>0&&Y(Array.from(se)),Q.target.value=""},[Y]),Z=R.useCallback(Q=>{const se=Q.clipboardData.items,ue=[];for(const ne of se)if(ne.kind==="file"){const ge=ne.getAsFile();ge&&ue.push(ge)}ue.length>0&&(Q.preventDefault(),Y(ue))},[Y]),ze=R.useCallback(Q=>{r(Q.target.value);const se=Q.target;se.style.height="auto",se.style.height=`${Math.max(40,Math.min(se.scrollHeight,140))}px`},[]),Fe=R.useCallback(()=>{N&&H.mutate({workspaceId:N})},[N,H]),Re=R.useRef(null);return R.useEffect(()=>{const Q=window.visualViewport;if(!Q)return;let se=!1;const ue=()=>{Re.current&&(Re.current.style.height=`${Q.height}px`,Re.current.style.top=`${Q.offsetTop}px`)},ne=()=>ue(),ge=()=>{se||ue()},me=()=>{se=!0},ye=()=>{se=!1,requestAnimationFrame(ue)};return Q.addEventListener("resize",ne),Q.addEventListener("scroll",ge),document.addEventListener("touchstart",me,{passive:!0}),document.addEventListener("touchend",ye,{passive:!0}),document.addEventListener("touchcancel",ye,{passive:!0}),()=>{Q.removeEventListener("resize",ne),Q.removeEventListener("scroll",ge),document.removeEventListener("touchstart",me),document.removeEventListener("touchend",ye),document.removeEventListener("touchcancel",ye)}},[]),R.useEffect(()=>{const Q=Re.current;if(!Q)return;const se=ue=>{let ne=ue.target;for(;ne&&ne!==Q;){if(ne.tagName==="TEXTAREA"){if(ne.scrollHeight>ne.clientHeight)return;ne=ne.parentElement;continue}const me=window.getComputedStyle(ne).overflowY;if((me==="auto"||me==="scroll")&&ne.scrollHeight>ne.clientHeight)return;ne=ne.parentElement}ue.preventDefault()};return Q.addEventListener("touchmove",se,{passive:!1}),()=>Q.removeEventListener("touchmove",se)},[]),a.jsxs("div",{ref:Re,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[a.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[a.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[a.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:a.jsx(jo,{size:18})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),a.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[a.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),a.jsx("span",{className:"text-neutral-300",children:"/"}),a.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),a.jsx(lp,{status:e.status}),a.jsx("button",{onClick:Fe,disabled:!N,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:a.jsx(Ds,{size:16})}),s&&a.jsxs("div",{className:"relative",ref:S,children:[a.jsx("button",{onClick:()=>_(Q=>!Q),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(Ji,{size:16})}),p&&a.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:a.jsxs("button",{onClick:()=>{o(!0),_(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[a.jsx(Yi,{size:15}),a.jsx("span",{children:"删除任务"})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:cp.map(({key:Q,label:se,icon:ue})=>a.jsxs("button",{onClick:()=>b(Q),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${m===Q?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(ue,{size:13}),a.jsx("span",{children:se})]},Q))})]}),m==="chat"&&a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:f,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:a.jsxs("div",{ref:h,children:[a.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?a.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:a.jsx($i,{urlTransform:np,components:ap,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),k?a.jsx(Ai,{label:"Loading..."}):E?M?a.jsx(Ai,{label:"Loading logs..."}):P.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:j?"Waiting for agent output...":"No logs recorded."}):a.jsx(Ui,{logs:P}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:a.jsx(jt,{size:20,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:"尚未启动 Agent"}),a.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:"选择一个 Agent 来执行此任务"}),a.jsxs(ot,{onClick:()=>c(!0),children:[a.jsx(jt,{size:16,className:"mr-1.5"}),"启动 Agent"]})]})]})}),!u&&a.jsxs("button",{onClick:()=>v(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[a.jsx(Gi,{size:12}),a.jsx("span",{children:"回到底部"})]})]}),K.length>0&&a.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:a.jsx(qi,{todos:K,compact:!0})}),E&&a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsxs("div",{className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[a.jsx(Cs,{files:V,onRemove:ie}),a.jsx("textarea",{ref:g,value:C,onChange:ze,onPaste:Z,onKeyDown:Q=>{Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),he())},rows:1,placeholder:j?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),a.jsx("input",{ref:n,type:"file",multiple:!0,className:"hidden",onChange:je}),a.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[a.jsx("div",{className:"flex items-center gap-0.5",children:a.jsx("button",{onClick:()=>n.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:a.jsx(ds,{size:15})})}),a.jsxs("div",{className:"flex items-center gap-1",children:[A&&a.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-neutral-400 px-1.5 py-0.5 select-none",children:[a.jsx(Fi,{size:12,className:"shrink-0"}),a.jsx("span",{children:Xi(A,10)})]}),a.jsx(En,{usage:X}),j&&!C.trim()&&!$?a.jsx("button",{onClick:we,disabled:W.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(Ki,{size:12})}):a.jsx("button",{onClick:he,disabled:!C.trim()&&!$||z,className:`p-1.5 rounded-lg transition-colors ${(C.trim()||$)&&!z?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Zi,{size:15})})]})]})]})})]}),m==="changes"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Vf,{workingDir:L})}),m==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(sp,{workingDir:L})}),m==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(to,{sessionId:E||void 0,workingDir:L,projectId:e.projectId,className:"h-full",hideChanges:!0})}),a.jsx(lo,{isOpen:i,onClose:()=>c(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(co,{isOpen:d,onClose:()=>o(!1),onConfirm:()=>{s?.(e.id),o(!1)},title:"删除任务",description:a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["确认删除任务「",e.title,"」?此操作不可撤销。"]}),B.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:B.map((Q,se)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:Q})]},se))})]}),confirmText:"删除",variant:"danger",isLoading:l})]})}function Ai({label:e}){return a.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[a.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsx("span",{className:"text-sm",children:e})]})}var up=Object.defineProperty,ws=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,fo=Object.prototype.propertyIsEnumerable,Ni=(e,t,s)=>t in e?up(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,hr=(e,t)=>{for(var s in t||(t={}))uo.call(t,s)&&Ni(e,s,t[s]);if(ws)for(var s of ws(t))fo.call(t,s)&&Ni(e,s,t[s]);return e},ur=(e,t)=>{var s={};for(var l in e)uo.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&ws)for(var l of ws(e))t.indexOf(l)<0&&fo.call(e,l)&&(s[l]=e[l]);return s};var Et;(e=>{const t=class fe{constructor(i,c,d,o){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<fe.MIN_VERSION||i>fe.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let p=[];for(let S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(d);if(this.drawCodewords(_),o==-1){let S=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<S&&(o=g,S=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,c){const d=e.QrSegment.makeSegments(i);return fe.encodeSegments(d,c)}static encodeBinary(i,c){const d=e.QrSegment.makeBytes(i);return fe.encodeSegments([d],c)}static encodeSegments(i,c,d=1,o=40,p=-1,_=!0){if(!(fe.MIN_VERSION<=d&&d<=o&&o<=fe.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,g;for(S=d;;S++){const u=fe.getNumDataCodewords(S,c)*8,v=C.getTotalBits(i,S);if(v<=u){g=v;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[fe.Ecc.MEDIUM,fe.Ecc.QUARTILE,fe.Ecc.HIGH])_&&g<=fe.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const v of u.getData())n.push(v)}m(n.length==g);const f=fe.getNumDataCodewords(S,c)*8;m(n.length<=f),s(0,Math.min(4,f-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<f;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,v)=>h[v>>>3]|=u<<7-(v&7)),new fe(S,c,h,p)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let d=0;d<c;d++)for(let o=0;o<c;o++)d==0&&o==0||d==0&&o==c-1||d==c-1&&o==0||this.drawAlignmentPattern(i[d],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let d=c;for(let p=0;p<10;p++)d=d<<1^(d>>>9)*1335;const o=(c<<10|d)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,l(o,p));this.setFunctionModule(8,7,l(o,6)),this.setFunctionModule(8,8,l(o,7)),this.setFunctionModule(7,8,l(o,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,l(o,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,l(o,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,l(o,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let d=0;d<12;d++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let d=0;d<18;d++){const o=l(c,d),p=this.size-11+d%3,_=Math.floor(d/3);this.setFunctionModule(p,_,o),this.setFunctionModule(_,p,o)}}drawFinderPattern(i,c){for(let d=-4;d<=4;d++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(d)),_=i+o,S=c+d;0<=_&&_<this.size&&0<=S&&S<this.size&&this.setFunctionModule(_,S,p!=2&&p!=4)}}drawAlignmentPattern(i,c){for(let d=-2;d<=2;d++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,c+d,Math.max(Math.abs(o),Math.abs(d))!=1)}setFunctionModule(i,c,d){this.modules[c][i]=d,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,d=this.errorCorrectionLevel;if(i.length!=fe.getNumDataCodewords(c,d))throw new RangeError("Invalid argument");const o=fe.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c],p=fe.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c],_=Math.floor(fe.getNumRawDataModules(c)/8),S=o-_%o,g=Math.floor(_/o);let n=[];const f=fe.reedSolomonComputeDivisor(p);for(let u=0,v=0;u<o;u++){let x=i.slice(v,v+g-p+(u<S?0:1));v+=x.length;const w=fe.reedSolomonComputeRemainder(x,f);u<S&&x.push(0),n.push(x.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((v,x)=>{(u!=g-p||x>=S)&&h.push(v[u])});return m(h.length==_),h}drawCodewords(i){if(i.length!=Math.floor(fe.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const _=d-p,g=(d+1&2)==0?this.size-1-o:o;!this.isFunction[g][_]&&c<i.length*8&&(this.modules[g][_]=l(i[c>>>3],7-(c&7)),c++)}}m(c==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let d=0;d<this.size;d++){let o;switch(i){case 0:o=(d+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=d%3==0;break;case 3:o=(d+c)%3==0;break;case 4:o=(Math.floor(d/3)+Math.floor(c/2))%2==0;break;case 5:o=d*c%2+d*c%3==0;break;case 6:o=(d*c%2+d*c%3)%2==0;break;case 7:o=((d+c)%2+d*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][d]&&o&&(this.modules[c][d]=!this.modules[c][d])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let _=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==_?(S++,S==5?i+=fe.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),_||(i+=this.finderPenaltyCountPatterns(g)*fe.PENALTY_N3),_=this.modules[p][n],S=1);i+=this.finderPenaltyTerminateAndCount(_,S,g)*fe.PENALTY_N3}for(let p=0;p<this.size;p++){let _=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==_?(S++,S==5?i+=fe.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),_||(i+=this.finderPenaltyCountPatterns(g)*fe.PENALTY_N3),_=this.modules[n][p],S=1);i+=this.finderPenaltyTerminateAndCount(_,S,g)*fe.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let _=0;_<this.size-1;_++){const S=this.modules[p][_];S==this.modules[p][_+1]&&S==this.modules[p+1][_]&&S==this.modules[p+1][_+1]&&(i+=fe.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((_,S)=>_+(S?1:0),c);const d=this.size*this.size,o=Math.ceil(Math.abs(c*20-d*10)/d)-1;return m(0<=o&&o<=9),i+=o*fe.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let d=[6];for(let o=this.size-7;d.length<i;o-=c)d.splice(1,0,o);return d}}static getNumRawDataModules(i){if(i<fe.MIN_VERSION||i>fe.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const d=Math.floor(i/7)+2;c-=(25*d-10)*d-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(fe.getNumRawDataModules(i)/8)-fe.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*fe.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let c=[];for(let o=0;o<i-1;o++)c.push(0);c.push(1);let d=1;for(let o=0;o<i;o++){for(let p=0;p<c.length;p++)c[p]=fe.reedSolomonMultiply(c[p],d),p+1<c.length&&(c[p]^=c[p+1]);d=fe.reedSolomonMultiply(d,2)}return c}static reedSolomonComputeRemainder(i,c){let d=c.map(o=>0);for(const o of i){const p=o^d.shift();d.push(0),c.forEach((_,S)=>d[S]^=fe.reedSolomonMultiply(_,p))}return d}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let d=0;for(let o=7;o>=0;o--)d=d<<1^(d>>>7)*285,d^=(c>>>o&1)*i;return m(d>>>8==0),d}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const d=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(d&&i[0]>=c*4&&i[6]>=c?1:0)+(d&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,d){return i&&(this.finderPenaltyAddHistory(c,d),c=0),c+=this.size,this.finderPenaltyAddHistory(c,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(i,c){c[0]==0&&(i+=this.size),c.pop(),c.unshift(i)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function s(r,i,c){if(i<0||i>31||r>>>i)throw new RangeError("Value out of range");for(let d=i-1;d>=0;d--)c.push(r>>>d&1)}function l(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const b=class Te{constructor(i,c,d){if(this.mode=i,this.numChars=c,this.bitData=d,c<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(i){let c=[];for(const d of i)s(d,8,c);return new Te(Te.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Te.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let d=0;d<i.length;){const o=Math.min(i.length-d,3);s(parseInt(i.substring(d,d+o),10),o*3+1,c),d+=o}return new Te(Te.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Te.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],d;for(d=0;d+2<=i.length;d+=2){let o=Te.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d))*45;o+=Te.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d+1)),s(o,11,c)}return d<i.length&&s(Te.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d)),6,c),new Te(Te.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Te.isNumeric(i)?[Te.makeNumeric(i)]:Te.isAlphanumeric(i)?[Te.makeAlphanumeric(i)]:[Te.makeBytes(Te.toUtf8ByteArray(i))]}static makeEci(i){let c=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)s(i,8,c);else if(i<16384)s(2,2,c),s(i,14,c);else if(i<1e6)s(6,3,c),s(i,21,c);else throw new RangeError("ECI assignment value out of range");return new Te(Te.Mode.ECI,0,c)}static isNumeric(i){return Te.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Te.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let d=0;for(const o of i){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;d+=4+p+o.bitData.length}return d}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let d=0;d<i.length;d++)i.charAt(d)!="%"?c.push(i.charCodeAt(d)):(c.push(parseInt(i.substring(d+1,d+3),16)),d+=2);return c}};b.NUMERIC_REGEX=/^[0-9]*$/,b.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,b.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=b;e.QrSegment=b})(Et||(Et={}));(e=>{(t=>{const s=class{constructor(m,b){this.ordinal=m,this.formatBits=b}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(Et||(Et={}));(e=>{(t=>{const s=class{constructor(m,b){this.modeBits=m,this.numBitsCharCount=b}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(Et||(Et={}));var Tt=Et;var dp={L:Tt.QrCode.Ecc.LOW,M:Tt.QrCode.Ecc.MEDIUM,Q:Tt.QrCode.Ecc.QUARTILE,H:Tt.QrCode.Ecc.HIGH},po=128,mo="L",vo="#FFFFFF",go="#000000",_o=!1,bo=1,fp=4,pp=0,mp=.1;function xo(e,t=0){const s=[];return e.forEach(function(l,m){let b=null;l.forEach(function(C,r){if(!C&&b!==null){s.push(`M${b+t} ${m+t}h${r-b}v1H${b+t}z`),b=null;return}if(r===l.length-1){if(!C)return;b===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${b+t},${m+t} h${r+1-b}v1H${b+t}z`);return}C&&b===null&&(b=r)})}),s.join("")}function So(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,b)=>b<t.x||b>=t.x+t.w?m:!1))}function vp(e,t,s,l){if(l==null)return null;const m=e.length+s*2,b=Math.floor(t*mp),C=m/t,r=(l.width||b)*C,i=(l.height||b)*C,c=l.x==null?e.length/2-r/2:l.x*C,d=l.y==null?e.length/2-i/2:l.y*C,o=l.opacity==null?1:l.opacity;let p=null;if(l.excavate){let S=Math.floor(c),g=Math.floor(d),n=Math.ceil(r+c-S),f=Math.ceil(i+d-g);p={x:S,y:g,w:n,h:f}}const _=l.crossOrigin;return{x:c,y:d,h:i,w:r,excavation:p,opacity:o,crossOrigin:_}}function gp(e,t){return t!=null?Math.max(Math.floor(t),0):e?fp:pp}function yo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:b,size:C,boostLevel:r}){let i=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...Tt.QrSegment.makeSegments(n)),g),[]);return Tt.QrCode.encodeSegments(S,dp[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:d,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let _=i.getModules();const S=gp(l,m),g=_.length+S*2,n=vp(_,C,S,b);return{cells:_,margin:S,numCells:g,calculatedImageSettings:n}},[i,C,b,l,m]);return{qrcode:i,margin:d,cells:c,numCells:o,calculatedImageSettings:p}}var _p=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),bp=ee.forwardRef(function(t,s){const l=t,{value:m,size:b=po,level:C=mo,bgColor:r=vo,fgColor:i=go,includeMargin:c=_o,minVersion:d=bo,boostLevel:o,marginSize:p,imageSettings:_}=l,g=ur(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,f=ur(g,["style"]),h=_?.src,u=ee.useRef(null),v=ee.useRef(null),x=ee.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,k]=ee.useState(!1),{margin:y,cells:E,numCells:j,calculatedImageSettings:A}=yo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:_,size:b});ee.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=E;const W=v.current,D=A!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;D&&A.excavation!=null&&(H=So(E,A.excavation));const M=window.devicePixelRatio||1;B.height=B.width=b*M;const P=b/j*M;I.scale(P,P),I.fillStyle=r,I.fillRect(0,0,j,j),I.fillStyle=i,_p?I.fill(new Path2D(xo(H,y))):E.forEach(function(O,U){O.forEach(function(K,V){K&&I.fillRect(V+y,U+y,1,1)})}),A&&(I.globalAlpha=A.opacity),D&&I.drawImage(W,A.x+y,A.y+y,A.w,A.h)}}),ee.useEffect(()=>{k(!1)},[h]);const L=hr({height:b,width:b},n);let N=null;return h!=null&&(N=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{k(!0)},ref:v,crossOrigin:A?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",hr({style:L,height:b,width:b,ref:x,role:"img"},f)),N)});bp.displayName="QRCodeCanvas";var Co=ee.forwardRef(function(t,s){const l=t,{value:m,size:b=po,level:C=mo,bgColor:r=vo,fgColor:i=go,includeMargin:c=_o,minVersion:d=bo,boostLevel:o,title:p,marginSize:_,imageSettings:S}=l,g=ur(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:f,numCells:h,calculatedImageSettings:u}=yo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:c,marginSize:_,imageSettings:S,size:b});let v=f,x=null;S!=null&&u!=null&&(u.excavation!=null&&(v=So(f,u.excavation)),x=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=xo(v,n);return ee.createElement("svg",hr({height:b,width:b,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),x)});Co.displayName="QRCodeSVG";function xp(){return at({queryKey:ce.tunnel.status,queryFn:()=>be.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function Sp(){const e=Ie();return Ge({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return be.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function yp(){const e=Ie();return Ge({mutationFn:()=>be.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Mi(){const{data:e}=xp(),t=Sp(),s=yp(),[l,m]=R.useState(!1),[b,C]=R.useState(null),r=R.useRef(null),[i,c]=R.useState({top:0,right:0}),[d,o]=R.useState(!1),p=e?.running??!1,_=t.isPending,S=e?.shareableUrl,g=e?.token;R.useEffect(()=>{if(l&&r.current){const v=r.current.getBoundingClientRect();c({top:v.bottom+8,right:window.innerWidth-v.right})}},[l]);const n=R.useCallback(()=>{p?m(!0):t.mutate(void 0,{onSuccess:()=>m(!0)})},[p,t]),f=R.useCallback(()=>{S&&(navigator.clipboard.writeText(S),C("url"),setTimeout(()=>C(null),2e3))},[S]),h=R.useCallback(()=>{g&&(navigator.clipboard.writeText(g),C("token"),setTimeout(()=>C(null),2e3))},[g]),u=R.useCallback(()=>{s.mutate(),m(!1),o(!1)},[s]);return a.jsxs("div",{className:"relative",children:[a.jsx("button",{ref:r,onClick:n,disabled:_,className:`p-1.5 rounded-md transition-colors ${p?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:p?"Tunnel active":"Share via tunnel",children:_?a.jsx(Be,{size:16,className:"animate-spin"}):a.jsx(Es,{size:16})}),p&&!_&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),l&&p&&Rt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>m(!1)}),a.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:i.top,right:i.right},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),"Tunnel Active"]}),a.jsx("button",{onClick:()=>m(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:a.jsx(ks,{size:14})})]}),g&&a.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-emerald-50 rounded text-xs text-emerald-700",children:[a.jsx(Ba,{size:12}),a.jsx("span",{children:"Token protected"})]}),S&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Co,{value:S,size:160})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{readOnly:!0,value:S??e?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:v=>v.target.select()}),a.jsx("button",{onClick:f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:"Copy shareable link",children:b==="url"?a.jsx(fs,{size:14,className:"text-emerald-500"}):a.jsx(Wr,{size:14})})]}),g&&a.jsxs("div",{className:"mt-2",children:[a.jsx("button",{onClick:()=>o(!d),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:d?"Hide token":"Show token"}),d&&a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("code",{className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:g}),a.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:"Copy token",children:b==="token"?a.jsx(fs,{size:14,className:"text-emerald-500"}):a.jsx(Wr,{size:14})})]})]}),a.jsx("button",{onClick:u,disabled:s.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:s.isPending?"Stopping...":"Stop Tunnel"})]})]}),document.body)]})}const Pi={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Ot=R.lazy(()=>Hi(()=>import("./modal-Cm1qLsdb.js").then(e=>e.m),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.Modal}))),er=R.lazy(()=>Hi(()=>import("./folder-picker-q3bDqZNK.js"),__vite__mapDeps([5,1,2,3,6,7,8,9,10,11,12,13])).then(e=>({default:e.FolderPicker}))),Oi=a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-900",children:[a.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),a.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Bi=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),Cp=260,wp=600,Ii=400;function Fp(){const[e,t]=R.useState(null),[s,l]=R.useState(null),[m,b]=R.useState(Ii),[C,r]=R.useState(!1),[i,c]=R.useState(!1),[d,o]=R.useState(""),[p,_]=R.useState(""),[S,g]=R.useState(""),[n,f]=R.useState(""),[h,u]=R.useState(""),[v,x]=R.useState(""),[w,k]=R.useState("idle"),{files:y,addFiles:E,removeFile:j,clear:A,buildMarkdownLinks:L,isUploading:N}=Mr(),B=R.useRef(null),I=R.useRef(!1),H=R.useRef(0),W=R.useRef(Ii),D=R.useRef(null),M=Ie(),{data:P,isLoading:O}=_r(),{data:U,isLoading:K}=Uo(),V=U?.data??[],Y=R.useMemo(()=>V.map(Nf),[V]),ie=R.useMemo(()=>V.map(q=>q.id),[V]);Hf(ie);const{data:T,isLoading:F}=Of(s??""),$=Vo({queries:s?[]:V.map(q=>({queryKey:ce.tasks.list(q.id),queryFn:()=>be.get(`/projects/${q.id}/tasks`,{params:{limit:"100"}})}))}),z=!s&&$.some(q=>q.isLoading),J=R.useMemo(()=>{if(s)return T?.data??[];const q=[];for(const re of $)re.data?.data&&q.push(...re.data.data);return q},[s,T,$]),X=R.useMemo(()=>{const q=new Map;for(const re of J){const ae=re.createdAt?new Date(re.createdAt).getTime():0,pe=q.get(re.projectId)??0;ae>pe&&q.set(re.projectId,ae)}return[...V].sort((re,ae)=>{const pe=q.get(re.id)??(re.createdAt?new Date(re.createdAt).getTime():0);return(q.get(ae.id)??(ae.createdAt?new Date(ae.createdAt).getTime():0))-pe})},[V,J]),oe=R.useMemo(()=>{if(!P)return[];const q=localStorage.getItem("providerUsageCount"),re=q?JSON.parse(q):{};return[...P].sort((ae,pe)=>{const xe=ae.availability.type!=="NOT_FOUND",Me=pe.availability.type!=="NOT_FOUND";if(xe!==Me)return xe?-1:1;const qe=re[ae.provider.id]??0;return(re[pe.provider.id]??0)-qe})},[P]),he=R.useMemo(()=>J.map(Pf),[J]),we=R.useMemo(()=>new Set,[]),je=R.useMemo(()=>{if(!e)return null;const q=he.find(ae=>ae.id===e);if(!q)return null;const re=V.find(ae=>ae.id===q.projectId);return{id:q.id,projectId:q.projectId,projectName:re?.name??"Unknown",projectColor:re?.color??"text-neutral-500",title:q.title,status:q.status,branch:q.branch,mainBranch:re?.mainBranch??"main",description:q.description}},[e,he,V]),Z=qo(),ze=Bf(h),Fe=Ff(),Re=If(),Q=R.useCallback(q=>{Fe.mutate(q,{onSuccess:()=>{e===q&&t(null),M.invalidateQueries({queryKey:ce.tasks.all})}})},[Fe,e,M]),se=R.useCallback((q,re)=>{Re.mutate({id:q,status:jf(re)},{onError:()=>{Lo.error("状态变更失败,该操作不被允许")}})},[Re]),ue=R.useCallback(q=>{q.preventDefault(),I.current=!0,H.current=q.clientX,W.current=m,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[m]);R.useEffect(()=>{const q=ae=>{if(!I.current)return;const pe=ae.clientX-H.current,xe=Math.max(Cp,Math.min(wp,W.current+pe));b(xe)},re=()=>{I.current&&(I.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",re),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",re)}},[]);const ne=R.useCallback(()=>{r(!0)},[]),ge=R.useCallback(()=>{const q=localStorage.getItem("lastSelectedProjectId"),re=localStorage.getItem("lastSelectedProviderId"),ae=q&&X.find(Me=>Me.id===q)?q:s??X[0]?.id??"";u(ae);const pe=oe?.find(Me=>Me.availability.type!=="NOT_FOUND"),xe=re&&oe?.find(Me=>Me.provider.id===re&&Me.availability.type!=="NOT_FOUND")?re:pe?.provider.id??"";x(xe),k("idle"),c(!0)},[s,X,oe]),me=R.useCallback(()=>{r(!1),o(""),_("")},[]),ye=R.useCallback(()=>{w==="idle"&&(c(!1),g(""),f(""),u(""),x(""),k("idle"),A())},[w,A]),Le=R.useCallback(async()=>{if(!(!d.trim()||!p.trim()))try{await Z.mutateAsync({name:d.trim(),repoPath:p.trim()}),me()}catch{}},[d,p,Z,me]),Ve=io(),Ae=R.useCallback(async()=>{if(!(!S.trim()||!h))try{const q=L(),re=[n.trim(),q].filter(Boolean).join(`
|
|
81
|
+
`);r(""),T(),g.current&&(g.current.style.height="40px"),I.mutate({id:E,message:se},{onSuccess:()=>U(),onSettled:()=>{oe.current=!1}})},[C,E,I,U,$,z,F,T]),we=R.useCallback(async()=>{E&&(await W.mutateAsync(E),x.invalidateQueries({queryKey:["workspaces"]}))},[E,W,x]),je=R.useCallback(Q=>{const se=Q.target.files;se&&se.length>0&&Y(Array.from(se)),Q.target.value=""},[Y]),Z=R.useCallback(Q=>{const se=Q.clipboardData.items,ue=[];for(const ne of se)if(ne.kind==="file"){const ge=ne.getAsFile();ge&&ue.push(ge)}ue.length>0&&(Q.preventDefault(),Y(ue))},[Y]),ze=R.useCallback(Q=>{r(Q.target.value);const se=Q.target;se.style.height="auto",se.style.height=`${Math.max(40,Math.min(se.scrollHeight,140))}px`},[]),Fe=R.useCallback(()=>{N&&H.mutate({workspaceId:N})},[N,H]),Re=R.useRef(null);return R.useEffect(()=>{const Q=window.visualViewport;if(!Q)return;let se=!1;const ue=()=>{Re.current&&(Re.current.style.height=`${Q.height}px`,Re.current.style.top=`${Q.offsetTop}px`)},ne=()=>ue(),ge=()=>{se||ue()},me=()=>{se=!0},ye=()=>{se=!1,requestAnimationFrame(ue)};return Q.addEventListener("resize",ne),Q.addEventListener("scroll",ge),document.addEventListener("touchstart",me,{passive:!0}),document.addEventListener("touchend",ye,{passive:!0}),document.addEventListener("touchcancel",ye,{passive:!0}),()=>{Q.removeEventListener("resize",ne),Q.removeEventListener("scroll",ge),document.removeEventListener("touchstart",me),document.removeEventListener("touchend",ye),document.removeEventListener("touchcancel",ye)}},[]),R.useEffect(()=>{const Q=Re.current;if(!Q)return;const se=ue=>{let ne=ue.target;for(;ne&&ne!==Q;){if(ne.tagName==="TEXTAREA"){if(ne.scrollHeight>ne.clientHeight)return;ne=ne.parentElement;continue}const me=window.getComputedStyle(ne).overflowY;if((me==="auto"||me==="scroll")&&ne.scrollHeight>ne.clientHeight)return;ne=ne.parentElement}ue.preventDefault()};return Q.addEventListener("touchmove",se,{passive:!1}),()=>Q.removeEventListener("touchmove",se)},[]),a.jsxs("div",{ref:Re,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[a.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[a.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[a.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:a.jsx(jo,{size:18})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),a.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[a.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),a.jsx("span",{className:"text-neutral-300",children:"/"}),a.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),a.jsx(lp,{status:e.status}),a.jsx("button",{onClick:Fe,disabled:!N,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:a.jsx(Ds,{size:16})}),s&&a.jsxs("div",{className:"relative",ref:S,children:[a.jsx("button",{onClick:()=>_(Q=>!Q),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(Ji,{size:16})}),p&&a.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:a.jsxs("button",{onClick:()=>{o(!0),_(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[a.jsx(Yi,{size:15}),a.jsx("span",{children:"删除任务"})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:cp.map(({key:Q,label:se,icon:ue})=>a.jsxs("button",{onClick:()=>b(Q),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${m===Q?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(ue,{size:13}),a.jsx("span",{children:se})]},Q))})]}),m==="chat"&&a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:f,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:a.jsxs("div",{ref:h,children:[a.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?a.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:a.jsx($i,{urlTransform:np,components:ap,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),k?a.jsx(Ai,{label:"Loading..."}):E?M?a.jsx(Ai,{label:"Loading logs..."}):P.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:j?"Waiting for agent output...":"No logs recorded."}):a.jsx(Ui,{logs:P}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:a.jsx(jt,{size:20,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:"尚未启动 Agent"}),a.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:"选择一个 Agent 来执行此任务"}),a.jsxs(ot,{onClick:()=>c(!0),children:[a.jsx(jt,{size:16,className:"mr-1.5"}),"启动 Agent"]})]})]})}),!u&&a.jsxs("button",{onClick:()=>v(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[a.jsx(Gi,{size:12}),a.jsx("span",{children:"回到底部"})]})]}),K.length>0&&a.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:a.jsx(qi,{todos:K,compact:!0})}),E&&a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsxs("div",{className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[a.jsx(Cs,{files:V,onRemove:ie}),a.jsx("textarea",{ref:g,value:C,onChange:ze,onPaste:Z,onKeyDown:Q=>{Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),he())},rows:1,placeholder:j?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),a.jsx("input",{ref:n,type:"file",multiple:!0,className:"hidden",onChange:je}),a.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[a.jsx("div",{className:"flex items-center gap-0.5",children:a.jsx("button",{onClick:()=>n.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:a.jsx(ds,{size:15})})}),a.jsxs("div",{className:"flex items-center gap-1",children:[A&&a.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-neutral-400 px-1.5 py-0.5 select-none",children:[a.jsx(Fi,{size:12,className:"shrink-0"}),a.jsx("span",{children:Xi(A,10)})]}),a.jsx(En,{usage:X}),j&&!C.trim()&&!$?a.jsx("button",{onClick:we,disabled:W.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(Ki,{size:12})}):a.jsx("button",{onClick:he,disabled:!C.trim()&&!$||z,className:`p-1.5 rounded-lg transition-colors ${(C.trim()||$)&&!z?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Zi,{size:15})})]})]})]})})]}),m==="changes"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Vf,{workingDir:L})}),m==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(sp,{workingDir:L})}),m==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(to,{sessionId:E||void 0,workingDir:L,projectId:e.projectId,className:"h-full",hideChanges:!0})}),a.jsx(lo,{isOpen:i,onClose:()=>c(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(co,{isOpen:d,onClose:()=>o(!1),onConfirm:()=>{s?.(e.id),o(!1)},title:"删除任务",description:a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["确认删除任务「",e.title,"」?此操作不可撤销。"]}),B.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:B.map((Q,se)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:Q})]},se))})]}),confirmText:"删除",variant:"danger",isLoading:l})]})}function Ai({label:e}){return a.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[a.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsx("span",{className:"text-sm",children:e})]})}var up=Object.defineProperty,ws=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,fo=Object.prototype.propertyIsEnumerable,Ni=(e,t,s)=>t in e?up(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,hr=(e,t)=>{for(var s in t||(t={}))uo.call(t,s)&&Ni(e,s,t[s]);if(ws)for(var s of ws(t))fo.call(t,s)&&Ni(e,s,t[s]);return e},ur=(e,t)=>{var s={};for(var l in e)uo.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&ws)for(var l of ws(e))t.indexOf(l)<0&&fo.call(e,l)&&(s[l]=e[l]);return s};var Et;(e=>{const t=class fe{constructor(i,c,d,o){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<fe.MIN_VERSION||i>fe.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let p=[];for(let S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(d);if(this.drawCodewords(_),o==-1){let S=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<S&&(o=g,S=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,c){const d=e.QrSegment.makeSegments(i);return fe.encodeSegments(d,c)}static encodeBinary(i,c){const d=e.QrSegment.makeBytes(i);return fe.encodeSegments([d],c)}static encodeSegments(i,c,d=1,o=40,p=-1,_=!0){if(!(fe.MIN_VERSION<=d&&d<=o&&o<=fe.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,g;for(S=d;;S++){const u=fe.getNumDataCodewords(S,c)*8,v=C.getTotalBits(i,S);if(v<=u){g=v;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[fe.Ecc.MEDIUM,fe.Ecc.QUARTILE,fe.Ecc.HIGH])_&&g<=fe.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const v of u.getData())n.push(v)}m(n.length==g);const f=fe.getNumDataCodewords(S,c)*8;m(n.length<=f),s(0,Math.min(4,f-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<f;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,v)=>h[v>>>3]|=u<<7-(v&7)),new fe(S,c,h,p)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let d=0;d<c;d++)for(let o=0;o<c;o++)d==0&&o==0||d==0&&o==c-1||d==c-1&&o==0||this.drawAlignmentPattern(i[d],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let d=c;for(let p=0;p<10;p++)d=d<<1^(d>>>9)*1335;const o=(c<<10|d)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,l(o,p));this.setFunctionModule(8,7,l(o,6)),this.setFunctionModule(8,8,l(o,7)),this.setFunctionModule(7,8,l(o,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,l(o,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,l(o,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,l(o,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let d=0;d<12;d++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let d=0;d<18;d++){const o=l(c,d),p=this.size-11+d%3,_=Math.floor(d/3);this.setFunctionModule(p,_,o),this.setFunctionModule(_,p,o)}}drawFinderPattern(i,c){for(let d=-4;d<=4;d++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(d)),_=i+o,S=c+d;0<=_&&_<this.size&&0<=S&&S<this.size&&this.setFunctionModule(_,S,p!=2&&p!=4)}}drawAlignmentPattern(i,c){for(let d=-2;d<=2;d++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,c+d,Math.max(Math.abs(o),Math.abs(d))!=1)}setFunctionModule(i,c,d){this.modules[c][i]=d,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,d=this.errorCorrectionLevel;if(i.length!=fe.getNumDataCodewords(c,d))throw new RangeError("Invalid argument");const o=fe.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c],p=fe.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c],_=Math.floor(fe.getNumRawDataModules(c)/8),S=o-_%o,g=Math.floor(_/o);let n=[];const f=fe.reedSolomonComputeDivisor(p);for(let u=0,v=0;u<o;u++){let x=i.slice(v,v+g-p+(u<S?0:1));v+=x.length;const w=fe.reedSolomonComputeRemainder(x,f);u<S&&x.push(0),n.push(x.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((v,x)=>{(u!=g-p||x>=S)&&h.push(v[u])});return m(h.length==_),h}drawCodewords(i){if(i.length!=Math.floor(fe.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const _=d-p,g=(d+1&2)==0?this.size-1-o:o;!this.isFunction[g][_]&&c<i.length*8&&(this.modules[g][_]=l(i[c>>>3],7-(c&7)),c++)}}m(c==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let d=0;d<this.size;d++){let o;switch(i){case 0:o=(d+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=d%3==0;break;case 3:o=(d+c)%3==0;break;case 4:o=(Math.floor(d/3)+Math.floor(c/2))%2==0;break;case 5:o=d*c%2+d*c%3==0;break;case 6:o=(d*c%2+d*c%3)%2==0;break;case 7:o=((d+c)%2+d*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][d]&&o&&(this.modules[c][d]=!this.modules[c][d])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let _=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==_?(S++,S==5?i+=fe.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),_||(i+=this.finderPenaltyCountPatterns(g)*fe.PENALTY_N3),_=this.modules[p][n],S=1);i+=this.finderPenaltyTerminateAndCount(_,S,g)*fe.PENALTY_N3}for(let p=0;p<this.size;p++){let _=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==_?(S++,S==5?i+=fe.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),_||(i+=this.finderPenaltyCountPatterns(g)*fe.PENALTY_N3),_=this.modules[n][p],S=1);i+=this.finderPenaltyTerminateAndCount(_,S,g)*fe.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let _=0;_<this.size-1;_++){const S=this.modules[p][_];S==this.modules[p][_+1]&&S==this.modules[p+1][_]&&S==this.modules[p+1][_+1]&&(i+=fe.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((_,S)=>_+(S?1:0),c);const d=this.size*this.size,o=Math.ceil(Math.abs(c*20-d*10)/d)-1;return m(0<=o&&o<=9),i+=o*fe.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let d=[6];for(let o=this.size-7;d.length<i;o-=c)d.splice(1,0,o);return d}}static getNumRawDataModules(i){if(i<fe.MIN_VERSION||i>fe.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const d=Math.floor(i/7)+2;c-=(25*d-10)*d-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(fe.getNumRawDataModules(i)/8)-fe.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*fe.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let c=[];for(let o=0;o<i-1;o++)c.push(0);c.push(1);let d=1;for(let o=0;o<i;o++){for(let p=0;p<c.length;p++)c[p]=fe.reedSolomonMultiply(c[p],d),p+1<c.length&&(c[p]^=c[p+1]);d=fe.reedSolomonMultiply(d,2)}return c}static reedSolomonComputeRemainder(i,c){let d=c.map(o=>0);for(const o of i){const p=o^d.shift();d.push(0),c.forEach((_,S)=>d[S]^=fe.reedSolomonMultiply(_,p))}return d}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let d=0;for(let o=7;o>=0;o--)d=d<<1^(d>>>7)*285,d^=(c>>>o&1)*i;return m(d>>>8==0),d}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const d=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(d&&i[0]>=c*4&&i[6]>=c?1:0)+(d&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,d){return i&&(this.finderPenaltyAddHistory(c,d),c=0),c+=this.size,this.finderPenaltyAddHistory(c,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(i,c){c[0]==0&&(i+=this.size),c.pop(),c.unshift(i)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function s(r,i,c){if(i<0||i>31||r>>>i)throw new RangeError("Value out of range");for(let d=i-1;d>=0;d--)c.push(r>>>d&1)}function l(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const b=class Te{constructor(i,c,d){if(this.mode=i,this.numChars=c,this.bitData=d,c<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(i){let c=[];for(const d of i)s(d,8,c);return new Te(Te.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Te.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let d=0;d<i.length;){const o=Math.min(i.length-d,3);s(parseInt(i.substring(d,d+o),10),o*3+1,c),d+=o}return new Te(Te.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Te.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],d;for(d=0;d+2<=i.length;d+=2){let o=Te.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d))*45;o+=Te.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d+1)),s(o,11,c)}return d<i.length&&s(Te.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d)),6,c),new Te(Te.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Te.isNumeric(i)?[Te.makeNumeric(i)]:Te.isAlphanumeric(i)?[Te.makeAlphanumeric(i)]:[Te.makeBytes(Te.toUtf8ByteArray(i))]}static makeEci(i){let c=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)s(i,8,c);else if(i<16384)s(2,2,c),s(i,14,c);else if(i<1e6)s(6,3,c),s(i,21,c);else throw new RangeError("ECI assignment value out of range");return new Te(Te.Mode.ECI,0,c)}static isNumeric(i){return Te.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Te.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let d=0;for(const o of i){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;d+=4+p+o.bitData.length}return d}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let d=0;d<i.length;d++)i.charAt(d)!="%"?c.push(i.charCodeAt(d)):(c.push(parseInt(i.substring(d+1,d+3),16)),d+=2);return c}};b.NUMERIC_REGEX=/^[0-9]*$/,b.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,b.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=b;e.QrSegment=b})(Et||(Et={}));(e=>{(t=>{const s=class{constructor(m,b){this.ordinal=m,this.formatBits=b}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(Et||(Et={}));(e=>{(t=>{const s=class{constructor(m,b){this.modeBits=m,this.numBitsCharCount=b}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(Et||(Et={}));var Tt=Et;var dp={L:Tt.QrCode.Ecc.LOW,M:Tt.QrCode.Ecc.MEDIUM,Q:Tt.QrCode.Ecc.QUARTILE,H:Tt.QrCode.Ecc.HIGH},po=128,mo="L",vo="#FFFFFF",go="#000000",_o=!1,bo=1,fp=4,pp=0,mp=.1;function xo(e,t=0){const s=[];return e.forEach(function(l,m){let b=null;l.forEach(function(C,r){if(!C&&b!==null){s.push(`M${b+t} ${m+t}h${r-b}v1H${b+t}z`),b=null;return}if(r===l.length-1){if(!C)return;b===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${b+t},${m+t} h${r+1-b}v1H${b+t}z`);return}C&&b===null&&(b=r)})}),s.join("")}function So(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,b)=>b<t.x||b>=t.x+t.w?m:!1))}function vp(e,t,s,l){if(l==null)return null;const m=e.length+s*2,b=Math.floor(t*mp),C=m/t,r=(l.width||b)*C,i=(l.height||b)*C,c=l.x==null?e.length/2-r/2:l.x*C,d=l.y==null?e.length/2-i/2:l.y*C,o=l.opacity==null?1:l.opacity;let p=null;if(l.excavate){let S=Math.floor(c),g=Math.floor(d),n=Math.ceil(r+c-S),f=Math.ceil(i+d-g);p={x:S,y:g,w:n,h:f}}const _=l.crossOrigin;return{x:c,y:d,h:i,w:r,excavation:p,opacity:o,crossOrigin:_}}function gp(e,t){return t!=null?Math.max(Math.floor(t),0):e?fp:pp}function yo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:b,size:C,boostLevel:r}){let i=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...Tt.QrSegment.makeSegments(n)),g),[]);return Tt.QrCode.encodeSegments(S,dp[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:d,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let _=i.getModules();const S=gp(l,m),g=_.length+S*2,n=vp(_,C,S,b);return{cells:_,margin:S,numCells:g,calculatedImageSettings:n}},[i,C,b,l,m]);return{qrcode:i,margin:d,cells:c,numCells:o,calculatedImageSettings:p}}var _p=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),bp=ee.forwardRef(function(t,s){const l=t,{value:m,size:b=po,level:C=mo,bgColor:r=vo,fgColor:i=go,includeMargin:c=_o,minVersion:d=bo,boostLevel:o,marginSize:p,imageSettings:_}=l,g=ur(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,f=ur(g,["style"]),h=_?.src,u=ee.useRef(null),v=ee.useRef(null),x=ee.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,k]=ee.useState(!1),{margin:y,cells:E,numCells:j,calculatedImageSettings:A}=yo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:_,size:b});ee.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=E;const W=v.current,D=A!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;D&&A.excavation!=null&&(H=So(E,A.excavation));const M=window.devicePixelRatio||1;B.height=B.width=b*M;const P=b/j*M;I.scale(P,P),I.fillStyle=r,I.fillRect(0,0,j,j),I.fillStyle=i,_p?I.fill(new Path2D(xo(H,y))):E.forEach(function(O,U){O.forEach(function(K,V){K&&I.fillRect(V+y,U+y,1,1)})}),A&&(I.globalAlpha=A.opacity),D&&I.drawImage(W,A.x+y,A.y+y,A.w,A.h)}}),ee.useEffect(()=>{k(!1)},[h]);const L=hr({height:b,width:b},n);let N=null;return h!=null&&(N=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{k(!0)},ref:v,crossOrigin:A?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",hr({style:L,height:b,width:b,ref:x,role:"img"},f)),N)});bp.displayName="QRCodeCanvas";var Co=ee.forwardRef(function(t,s){const l=t,{value:m,size:b=po,level:C=mo,bgColor:r=vo,fgColor:i=go,includeMargin:c=_o,minVersion:d=bo,boostLevel:o,title:p,marginSize:_,imageSettings:S}=l,g=ur(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:f,numCells:h,calculatedImageSettings:u}=yo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:c,marginSize:_,imageSettings:S,size:b});let v=f,x=null;S!=null&&u!=null&&(u.excavation!=null&&(v=So(f,u.excavation)),x=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=xo(v,n);return ee.createElement("svg",hr({height:b,width:b,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),x)});Co.displayName="QRCodeSVG";function xp(){return at({queryKey:ce.tunnel.status,queryFn:()=>be.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function Sp(){const e=Ie();return Ge({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return be.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function yp(){const e=Ie();return Ge({mutationFn:()=>be.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Mi(){const{data:e}=xp(),t=Sp(),s=yp(),[l,m]=R.useState(!1),[b,C]=R.useState(null),r=R.useRef(null),[i,c]=R.useState({top:0,right:0}),[d,o]=R.useState(!1),p=e?.running??!1,_=t.isPending,S=e?.shareableUrl,g=e?.token;R.useEffect(()=>{if(l&&r.current){const v=r.current.getBoundingClientRect();c({top:v.bottom+8,right:window.innerWidth-v.right})}},[l]);const n=R.useCallback(()=>{p?m(!0):t.mutate(void 0,{onSuccess:()=>m(!0)})},[p,t]),f=R.useCallback(()=>{S&&(navigator.clipboard.writeText(S),C("url"),setTimeout(()=>C(null),2e3))},[S]),h=R.useCallback(()=>{g&&(navigator.clipboard.writeText(g),C("token"),setTimeout(()=>C(null),2e3))},[g]),u=R.useCallback(()=>{s.mutate(),m(!1),o(!1)},[s]);return a.jsxs("div",{className:"relative",children:[a.jsx("button",{ref:r,onClick:n,disabled:_,className:`p-1.5 rounded-md transition-colors ${p?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:p?"Tunnel active":"Share via tunnel",children:_?a.jsx(Be,{size:16,className:"animate-spin"}):a.jsx(Es,{size:16})}),p&&!_&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),l&&p&&Rt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>m(!1)}),a.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:i.top,right:i.right},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),"Tunnel Active"]}),a.jsx("button",{onClick:()=>m(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:a.jsx(ks,{size:14})})]}),g&&a.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-emerald-50 rounded text-xs text-emerald-700",children:[a.jsx(Ba,{size:12}),a.jsx("span",{children:"Token protected"})]}),S&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Co,{value:S,size:160})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{readOnly:!0,value:S??e?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:v=>v.target.select()}),a.jsx("button",{onClick:f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:"Copy shareable link",children:b==="url"?a.jsx(fs,{size:14,className:"text-emerald-500"}):a.jsx(Wr,{size:14})})]}),g&&a.jsxs("div",{className:"mt-2",children:[a.jsx("button",{onClick:()=>o(!d),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:d?"Hide token":"Show token"}),d&&a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("code",{className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:g}),a.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:"Copy token",children:b==="token"?a.jsx(fs,{size:14,className:"text-emerald-500"}):a.jsx(Wr,{size:14})})]})]}),a.jsx("button",{onClick:u,disabled:s.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:s.isPending?"Stopping...":"Stop Tunnel"})]})]}),document.body)]})}const Pi={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Ot=R.lazy(()=>Hi(()=>import("./modal-BCL0660p.js").then(e=>e.m),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.Modal}))),er=R.lazy(()=>Hi(()=>import("./folder-picker-DshGpYNS.js"),__vite__mapDeps([5,1,2,3,6,7,8,9,10,11,12,13])).then(e=>({default:e.FolderPicker}))),Oi=a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-900",children:[a.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),a.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Bi=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),Cp=260,wp=600,Ii=400;function Fp(){const[e,t]=R.useState(null),[s,l]=R.useState(null),[m,b]=R.useState(Ii),[C,r]=R.useState(!1),[i,c]=R.useState(!1),[d,o]=R.useState(""),[p,_]=R.useState(""),[S,g]=R.useState(""),[n,f]=R.useState(""),[h,u]=R.useState(""),[v,x]=R.useState(""),[w,k]=R.useState("idle"),{files:y,addFiles:E,removeFile:j,clear:A,buildMarkdownLinks:L,isUploading:N}=Mr(),B=R.useRef(null),I=R.useRef(!1),H=R.useRef(0),W=R.useRef(Ii),D=R.useRef(null),M=Ie(),{data:P,isLoading:O}=_r(),{data:U,isLoading:K}=Uo(),V=U?.data??[],Y=R.useMemo(()=>V.map(Nf),[V]),ie=R.useMemo(()=>V.map(q=>q.id),[V]);Hf(ie);const{data:T,isLoading:F}=Of(s??""),$=Vo({queries:s?[]:V.map(q=>({queryKey:ce.tasks.list(q.id),queryFn:()=>be.get(`/projects/${q.id}/tasks`,{params:{limit:"100"}})}))}),z=!s&&$.some(q=>q.isLoading),J=R.useMemo(()=>{if(s)return T?.data??[];const q=[];for(const re of $)re.data?.data&&q.push(...re.data.data);return q},[s,T,$]),X=R.useMemo(()=>{const q=new Map;for(const re of J){const ae=re.createdAt?new Date(re.createdAt).getTime():0,pe=q.get(re.projectId)??0;ae>pe&&q.set(re.projectId,ae)}return[...V].sort((re,ae)=>{const pe=q.get(re.id)??(re.createdAt?new Date(re.createdAt).getTime():0);return(q.get(ae.id)??(ae.createdAt?new Date(ae.createdAt).getTime():0))-pe})},[V,J]),oe=R.useMemo(()=>{if(!P)return[];const q=localStorage.getItem("providerUsageCount"),re=q?JSON.parse(q):{};return[...P].sort((ae,pe)=>{const xe=ae.availability.type!=="NOT_FOUND",Me=pe.availability.type!=="NOT_FOUND";if(xe!==Me)return xe?-1:1;const qe=re[ae.provider.id]??0;return(re[pe.provider.id]??0)-qe})},[P]),he=R.useMemo(()=>J.map(Pf),[J]),we=R.useMemo(()=>new Set,[]),je=R.useMemo(()=>{if(!e)return null;const q=he.find(ae=>ae.id===e);if(!q)return null;const re=V.find(ae=>ae.id===q.projectId);return{id:q.id,projectId:q.projectId,projectName:re?.name??"Unknown",projectColor:re?.color??"text-neutral-500",title:q.title,status:q.status,branch:q.branch,mainBranch:re?.mainBranch??"main",description:q.description}},[e,he,V]),Z=qo(),ze=Bf(h),Fe=Ff(),Re=If(),Q=R.useCallback(q=>{Fe.mutate(q,{onSuccess:()=>{e===q&&t(null),M.invalidateQueries({queryKey:ce.tasks.all})}})},[Fe,e,M]),se=R.useCallback((q,re)=>{Re.mutate({id:q,status:jf(re)},{onError:()=>{Lo.error("状态变更失败,该操作不被允许")}})},[Re]),ue=R.useCallback(q=>{q.preventDefault(),I.current=!0,H.current=q.clientX,W.current=m,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[m]);R.useEffect(()=>{const q=ae=>{if(!I.current)return;const pe=ae.clientX-H.current,xe=Math.max(Cp,Math.min(wp,W.current+pe));b(xe)},re=()=>{I.current&&(I.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",re),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",re)}},[]);const ne=R.useCallback(()=>{r(!0)},[]),ge=R.useCallback(()=>{const q=localStorage.getItem("lastSelectedProjectId"),re=localStorage.getItem("lastSelectedProviderId"),ae=q&&X.find(Me=>Me.id===q)?q:s??X[0]?.id??"";u(ae);const pe=oe?.find(Me=>Me.availability.type!=="NOT_FOUND"),xe=re&&oe?.find(Me=>Me.provider.id===re&&Me.availability.type!=="NOT_FOUND")?re:pe?.provider.id??"";x(xe),k("idle"),c(!0)},[s,X,oe]),me=R.useCallback(()=>{r(!1),o(""),_("")},[]),ye=R.useCallback(()=>{w==="idle"&&(c(!1),g(""),f(""),u(""),x(""),k("idle"),A())},[w,A]),Le=R.useCallback(async()=>{if(!(!d.trim()||!p.trim()))try{await Z.mutateAsync({name:d.trim(),repoPath:p.trim()}),me()}catch{}},[d,p,Z,me]),Ve=io(),Ae=R.useCallback(async()=>{if(!(!S.trim()||!h))try{const q=L(),re=[n.trim(),q].filter(Boolean).join(`
|
|
82
82
|
|
|
83
83
|
`);k("creating-task");const ae=await ze.mutateAsync({title:S.trim(),description:re||void 0});if(localStorage.setItem("lastSelectedProjectId",h),v){localStorage.setItem("lastSelectedProviderId",v);const pe=localStorage.getItem("providerUsageCount"),xe=pe?JSON.parse(pe):{};xe[v]=(xe[v]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(xe))}if(v){const pe=[S.trim(),re].filter(Boolean).join(`
|
|
84
84
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as P,r as o,j as e}from"./index-
|
|
1
|
+
import{c as P,r as o,j as e}from"./index-hdGFeHu1.js";import{a as k,F as w,u as z,b as q}from"./use-projects-BLI6qXx-.js";import{a as R,B as I}from"./api-client-iFY2ykuZ.js";import{S as L}from"./select-WuDnj3zN.js";import{X as C,P as S}from"./x-Bn5zgMLL.js";import"./query-keys-B2VhRmAm.js";import"./chevron-down-CxTrrnvp.js";const A=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],K=P("folder-plus",A);function M({value:r,onChange:h,repoPath:d,placeholder:m}){const[l,c]=o.useState(""),[u,x]=o.useState([]),[p,s]=o.useState(!1),[a,g]=o.useState(-1),j=o.useRef(null),y=o.useRef(null),i=o.useRef(void 0),f=o.useCallback(async t=>{if(!d||!t){x([]),s(!1);return}try{const n=await R.get("/filesystem/complete",{params:{basePath:d,prefix:t}});x(n.results),s(n.results.length>0),g(-1)}catch{x([]),s(!1)}},[d]);o.useEffect(()=>{if(clearTimeout(i.current),!l){x([]),s(!1);return}return i.current=setTimeout(()=>f(l),200),()=>clearTimeout(i.current)},[l,f]),o.useEffect(()=>{const t=n=>{y.current&&!y.current.contains(n.target)&&j.current&&!j.current.contains(n.target)&&s(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const b=t=>{const n=t.trim();!n||r.includes(n)||(h([...r,n]),c(""),s(!1),j.current?.focus())},E=t=>{h(r.filter((n,v)=>v!==t))},N=t=>{t.type==="directory"?(c(t.path),j.current?.focus()):b(t.path)},D=(t,n)=>{n.stopPropagation(),b(t.path.replace(/\/$/,""))},F=t=>{t.nativeEvent.isComposing||t.nativeEvent.keyCode===229||(p&&u.length>0?t.key==="ArrowDown"?(t.preventDefault(),g(n=>Math.min(n+1,u.length-1))):t.key==="ArrowUp"?(t.preventDefault(),g(n=>Math.max(n-1,-1))):t.key==="Enter"?(t.preventDefault(),a>=0?N(u[a]):b(l)):t.key==="Escape"&&s(!1):t.key==="Enter"&&(t.preventDefault(),b(l)))};return e.jsxs("div",{children:[r.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:r.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[t.includes(".")&&!t.endsWith("/")?e.jsx(k,{size:14,className:"text-neutral-400 shrink-0"}):e.jsx(w,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-700 truncate flex-1",children:t}),e.jsx("button",{onClick:()=>E(n),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(C,{size:14})})]},t))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:j,type:"text",value:l,onChange:t=>c(t.target.value),onKeyDown:F,onFocus:()=>{l&&u.length>0&&s(!0)},placeholder:m??"输入文件路径...",className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:()=>b(l),disabled:!l.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(S,{size:14}),e.jsx("span",{children:"添加"})]})]}),p&&e.jsx("div",{ref:y,className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg max-h-[200px] overflow-y-auto",children:u.map((t,n)=>e.jsxs("button",{onClick:()=>N(t),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${n===a?"bg-neutral-100":""}`,children:[t.type==="directory"?e.jsx(w,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(k,{size:14,className:"text-neutral-400 shrink-0"}),e.jsx("span",{className:"font-mono text-neutral-700 truncate flex-1",children:t.path}),t.type==="directory"&&e.jsx("span",{onClick:v=>D(t,v),className:"p-0.5 text-neutral-300 hover:text-emerald-600 shrink-0",title:"添加此目录",children:e.jsx(K,{size:14})})]},t.path))})]})]})}function _({value:r,onChange:h}){const[d,m]=o.useState(""),[l,c]=o.useState(""),u=()=>{const s=d.trim(),a=l.trim();!s||!a||(h([...r,{name:s,command:a}]),m(""),c(""))},x=s=>{h(r.filter((a,g)=>g!==s))},p=s=>{s.key==="Enter"&&!s.nativeEvent.isComposing&&s.nativeEvent.keyCode!==229&&(s.preventDefault(),u())};return e.jsxs("div",{children:[r.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:r.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-neutral-700 w-28 shrink-0 truncate",children:s.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:s.command}),e.jsx("button",{onClick:()=>x(a),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(C,{size:14})})]},a))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:d,onChange:s=>m(s.target.value),onKeyDown:p,placeholder:"名称",className:"w-28 shrink-0 px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsx("input",{type:"text",value:l,onChange:s=>c(s.target.value),onKeyDown:p,placeholder:"命令",className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:u,disabled:!d.trim()||!l.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(S,{size:14}),e.jsx("span",{children:"添加"})]})]})]})}function B(r){return r?r.split(",").map(h=>h.trim()).filter(Boolean):[]}function O(r){if(!r)return[];try{return JSON.parse(r)}catch{return[]}}function W(){const{data:r,isLoading:h}=z({limit:100}),d=q(),[m,l]=o.useState(""),[c,u]=o.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[x,p]=o.useState(!1),s=r?.data??[],a=s.find(i=>i.id===m);if(o.useEffect(()=>{!m&&s.length>0&&l(s[0].id)},[s,m]),o.useEffect(()=>{a&&!x&&u({copyFiles:B(a.copyFiles),setupScript:a.setupScript??"",quickCommands:O(a.quickCommands)})},[a,x]),h)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:"加载中..."});if(s.length===0)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:"暂无项目,请先创建项目"});const g=s.map(i=>({value:i.id,label:i.name})),j=()=>{m&&d.mutate({id:m,copyFiles:c.copyFiles.length>0?c.copyFiles.join(", "):null,setupScript:c.setupScript.trim()||null,quickCommands:c.quickCommands.length>0?JSON.stringify(c.quickCommands):null},{onSuccess:()=>p(!1)})},y=i=>{l(i),p(!1)};return e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-3xl space-y-8",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:"选择项目"}),e.jsx(L,{value:m,onChange:y,options:g,placeholder:"选择项目..."})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:"自动复制文件"}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:"创建 worktree 时自动从主仓库复制的文件或目录。支持 glob 模式。"}),e.jsx(M,{value:c.copyFiles,onChange:i=>{u(f=>({...f,copyFiles:i})),p(!0)},repoPath:a?.repoPath??""}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-2",children:"适用于不在 git 管理中但启动必需的文件,如 .env、node_modules、数据库文件等"})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:"Setup 脚本"}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:"创建 worktree 后自动执行的命令,每行一条,按顺序执行。"}),e.jsx("textarea",{value:c.setupScript,onChange:i=>{u(f=>({...f,setupScript:i.target.value})),p(!0)},placeholder:`pnpm install
|
|
2
2
|
pnpm run setup`,rows:4,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300 resize-none"}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-1",children:"命令在 worktree 目录下执行,单条命令超时 5 分钟,失败不会阻断后续命令"})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:"常用命令"}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:"在终端中可快速执行的命令,不会自动运行。"}),e.jsx(_,{value:c.quickCommands,onChange:i=>{u(f=>({...f,quickCommands:i})),p(!0)}})]}),x&&e.jsx("div",{className:"sticky bottom-6 flex justify-end",children:e.jsx(I,{size:"sm",onClick:j,disabled:d.isPending,children:d.isPending?"保存中...":"保存"})})]})}export{W as ProjectSettingsPage};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import{c as B,r as C,j as n,y as P}from"./index-hdGFeHu1.js";import{u as de,a as ue,b as me,c as fe,d as xe,e as pe,f as he,A as v}from"./use-providers-C1i5uxRH.js";import{B as j}from"./api-client-iFY2ykuZ.js";import{T as Q,M as G}from"./modal-BCL0660p.js";import{S as ee}from"./select-WuDnj3zN.js";import"./log-adapter-50wgehrc.js";import{P as te}from"./x-Bn5zgMLL.js";import{P as ge}from"./pencil-SJi1qbh9.js";import{C as be}from"./circle-check-uswR_cEa.js";import{C as ve}from"./chevron-down-CxTrrnvp.js";import"./query-keys-B2VhRmAm.js";const ye=[["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"}]],je=B("circle-x",ye);const we=[["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"}]],Ne=B("download",we);const Ee=[["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"}]],Ce=B("upload",Ee);function Oe(e,t){let l=e.slice(0,t).split(/\r\n|\n|\r/g);return[l.length,l.pop().length+1]}function ke(e,t,l){let i=e.split(/\r\n|\n|\r/g),s="",r=(Math.log10(t+1)|0)+1;for(let a=t-1;a<=t+1;a++){let o=i[a-1];o&&(s+=a.toString().padEnd(r," "),s+=": ",s+=o,s+=`
|
|
2
|
+
`,a===t&&(s+=" ".repeat(r+l+2),s+=`^
|
|
3
|
+
`))}return s}class f extends Error{line;column;codeblock;constructor(t,l){const[i,s]=Oe(l.toml,l.ptr),r=ke(l.toml,i,s);super(`Invalid TOML document: ${t}
|
|
4
|
+
|
|
5
|
+
${r}`,l),this.line=i,this.column=s,this.codeblock=r}}function Pe(e,t){let l=0;for(;e[t-++l]==="\\";);return--l&&l%2}function M(e,t=0,l=e.length){let i=e.indexOf(`
|
|
6
|
+
`,t);return e[i-1]==="\r"&&i--,i<=l?i:-1}function L(e,t){for(let l=t;l<e.length;l++){let i=e[l];if(i===`
|
|
7
|
+
`)return l;if(i==="\r"&&e[l+1]===`
|
|
8
|
+
`)return l+1;if(i<" "&&i!==" "||i==="")throw new f("control characters are not allowed in comments",{toml:e,ptr:t})}return e.length}function w(e,t,l,i){let s;for(;(s=e[t])===" "||s===" "||!l&&(s===`
|
|
9
|
+
`||s==="\r"&&e[t+1]===`
|
|
10
|
+
`);)t++;return i||s!=="#"?t:w(e,L(e,t),l)}function _e(e,t,l,i,s=!1){if(!i)return t=M(e,t),t<0?e.length:t;for(let r=t;r<e.length;r++){let a=e[r];if(a==="#")r=M(e,r);else{if(a===l)return r+1;if(a===i||s&&(a===`
|
|
11
|
+
`||a==="\r"&&e[r+1]===`
|
|
12
|
+
`))return r}}throw new f("cannot find end of structure",{toml:e,ptr:t})}function ne(e,t){let l=e[t],i=l===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):l;t+=i.length-1;do t=e.indexOf(i,++t);while(t>-1&&l!=="'"&&Pe(e,t));return t>-1&&(t+=i.length,i.length>1&&(e[t]===l&&t++,e[t]===l&&t++)),t}let Te=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class I extends Date{#t=!1;#n=!1;#e=null;constructor(t){let l=!0,i=!0,s="Z";if(typeof t=="string"){let r=t.match(Te);r?(r[1]||(l=!1,t=`0000-01-01T${t}`),i=!!r[2],i&&t[10]===" "&&(t=t.replace(" ","T")),r[2]&&+r[2]>23?t="":(s=r[3]||null,t=t.toUpperCase(),!s&&i&&(t+="Z"))):t=""}super(t),isNaN(this.getTime())||(this.#t=l,this.#n=i,this.#e=s)}isDateTime(){return this.#t&&this.#n}isLocal(){return!this.#t||!this.#n||!this.#e}isDate(){return this.#t&&!this.#n}isTime(){return this.#n&&!this.#t}isValid(){return this.#t||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#e===null)return t.slice(0,-1);if(this.#e==="Z")return t;let l=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return l=this.#e[0]==="-"?l:-l,new Date(this.getTime()-l*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(t,l="Z"){let i=new I(t);return i.#e=l,i}static wrapAsLocalDateTime(t){let l=new I(t);return l.#e=null,l}static wrapAsLocalDate(t){let l=new I(t);return l.#n=!1,l.#e=null,l}static wrapAsLocalTime(t){let l=new I(t);return l.#t=!1,l.#e=null,l}}let Ie=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Ae=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Se=/^[+-]?0[0-9_]/,De=/^[0-9a-f]{2,8}$/i,Y={b:"\b",t:" ",n:`
|
|
13
|
+
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function re(e,t=0,l=e.length){let i=e[t]==="'",s=e[t++]===e[t]&&e[t]===e[t+1];s&&(l-=2,e[t+=2]==="\r"&&t++,e[t]===`
|
|
14
|
+
`&&t++);let r=0,a,o="",c=t;for(;t<l-1;){let d=e[t++];if(d===`
|
|
15
|
+
`||d==="\r"&&e[t]===`
|
|
16
|
+
`){if(!s)throw new f("newlines are not allowed in strings",{toml:e,ptr:t-1})}else if(d<" "&&d!==" "||d==="")throw new f("control characters are not allowed in strings",{toml:e,ptr:t-1});if(a){if(a=!1,d==="x"||d==="u"||d==="U"){let p=e.slice(t,t+=d==="x"?2:d==="u"?4:8);if(!De.test(p))throw new f("invalid unicode escape",{toml:e,ptr:r});try{o+=String.fromCodePoint(parseInt(p,16))}catch{throw new f("invalid unicode escape",{toml:e,ptr:r})}}else if(s&&(d===`
|
|
17
|
+
`||d===" "||d===" "||d==="\r")){if(t=w(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:r});t=w(e,t)}else if(d in Y)o+=Y[d];else throw new f("unrecognized escape sequence",{toml:e,ptr:r});c=t}else!i&&d==="\\"&&(r=t-1,a=!0,o+=e.slice(c,r))}return o+e.slice(c,l-1)}function Le(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 s=Ie.test(e);if(s||Ae.test(e)){if(Se.test(e))throw new f("leading zeroes are not allowed",{toml:t,ptr:l});e=e.replace(/_/g,"");let a=+e;if(isNaN(a))throw new f("invalid number",{toml:t,ptr:l});if(s){if((s=!Number.isSafeInteger(a))&&!i)throw new f("integer value cannot be represented losslessly",{toml:t,ptr:l});(s||i===!0)&&(a=BigInt(e))}return a}const r=new I(e);if(!r.isValid())throw new f("invalid value",{toml:t,ptr:l});return r}function Re(e,t,l){let i=e.slice(t,l),s=i.indexOf("#");return s>-1&&(L(e,s),i=i.slice(0,s)),[i.trimEnd(),s]}function X(e,t,l,i,s){if(i===0)throw new f("document contains excessively nested structures. aborting.",{toml:e,ptr:t});let r=e[t];if(r==="["||r==="{"){let[c,d]=r==="["?Me(e,t,i,s):Fe(e,t,i,s);if(l){if(d=w(e,d),e[d]===",")d++;else if(e[d]!==l)throw new f("expected comma or end of structure",{toml:e,ptr:d})}return[c,d]}let a;if(r==='"'||r==="'"){a=ne(e,t);let c=re(e,t,a);if(l){if(a=w(e,a),e[a]&&e[a]!==","&&e[a]!==l&&e[a]!==`
|
|
19
|
+
`&&e[a]!=="\r")throw new f("unexpected character encountered",{toml:e,ptr:a});a+=+(e[a]===",")}return[c,a]}a=_e(e,t,",",l);let o=Re(e,t,a-+(e[a-1]===","));if(!o[0])throw new f("incomplete key-value declaration: no value specified",{toml:e,ptr:t});return l&&o[1]>-1&&(a=w(e,t+o[1]),a+=+(e[a]===",")),[Le(o[0],e,t,s),a]}let Ue=/^[a-zA-Z0-9-_]+[ \t]*$/;function z(e,t,l="="){let i=t-1,s=[],r=e.indexOf(l,t);if(r<0)throw new f("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let a=e[t=++i];if(a!==" "&&a!==" ")if(a==='"'||a==="'"){if(a===e[t+1]&&a===e[t+2])throw new f("multiline strings are not allowed in keys",{toml:e,ptr:t});let o=ne(e,t);if(o<0)throw new f("unfinished string encountered",{toml:e,ptr:t});i=e.indexOf(".",o);let c=e.slice(o,i<0||i>r?r:i),d=M(c);if(d>-1)throw new f("newlines are not allowed in keys",{toml:e,ptr:t+i+d});if(c.trimStart())throw new f("found extra tokens after the string part",{toml:e,ptr:o});if(r<o&&(r=e.indexOf(l,o),r<0))throw new f("incomplete key-value: cannot find end of key",{toml:e,ptr:t});s.push(re(e,t,o))}else{i=e.indexOf(".",t);let o=e.slice(t,i<0||i>r?r:i);if(!Ue.test(o))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});s.push(o.trimEnd())}}while(i+1&&i<r);return[s,w(e,r+1,!0,!0)]}function Fe(e,t,l,i){let s={},r=new Set,a;for(t++;(a=e[t++])!=="}"&&a;){if(a===",")throw new f("expected value, found comma",{toml:e,ptr:t-1});if(a==="#")t=L(e,t);else if(a!==" "&&a!==" "&&a!==`
|
|
20
|
+
`&&a!=="\r"){let o,c=s,d=!1,[p,_]=z(e,t-1);for(let b=0;b<p.length;b++){if(b&&(c=d?c[o]:c[o]={}),o=p[b],(d=Object.hasOwn(c,o))&&(typeof c[o]!="object"||r.has(c[o])))throw new f("trying to redefine an already defined value",{toml:e,ptr:t});!d&&o==="__proto__"&&Object.defineProperty(c,o,{enumerable:!0,configurable:!0,writable:!0})}if(d)throw new f("trying to redefine an already defined value",{toml:e,ptr:t});let[m,h]=X(e,_,"}",l-1,i);r.add(m),c[o]=m,t=h}}if(!a)throw new f("unfinished table encountered",{toml:e,ptr:t});return[s,t]}function Me(e,t,l,i){let s=[],r;for(t++;(r=e[t++])!=="]"&&r;){if(r===",")throw new f("expected value, found comma",{toml:e,ptr:t-1});if(r==="#")t=L(e,t);else if(r!==" "&&r!==" "&&r!==`
|
|
21
|
+
`&&r!=="\r"){let a=X(e,t-1,"]",l-1,i);s.push(a[0]),t=a[1]}}if(!r)throw new f("unfinished array encountered",{toml:e,ptr:t});return[s,t]}function H(e,t,l,i){let s=t,r=l,a,o=!1,c;for(let d=0;d<e.length;d++){if(d){if(s=o?s[a]:s[a]={},r=(c=r[a]).c,i===0&&(c.t===1||c.t===2))return null;if(c.t===2){let p=s.length-1;s=s[p],r=r[p].c}}if(a=e[d],(o=Object.hasOwn(s,a))&&r[a]?.t===0&&r[a]?.d)return null;o||(a==="__proto__"&&(Object.defineProperty(s,a,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(r,a,{enumerable:!0,configurable:!0,writable:!0})),r[a]={t:d<e.length-1&&i===2?3:i,d:!1,i:0,c:{}})}if(c=r[a],c.t!==i&&!(i===1&&c.t===3)||(i===2&&(c.d||(c.d=!0,s[a]=[]),s[a].push(s={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,i===1)s=o?s[a]:s[a]={};else if(i===0&&o)return null;return[a,s,c.c]}function ze(e,{maxDepth:t=1e3,integersAsBigInt:l}={}){let i={},s={},r=i,a=s;for(let o=w(e,0);o<e.length;){if(e[o]==="["){let c=e[++o]==="[",d=z(e,o+=+c,"]");if(c){if(e[d[1]-1]!=="]")throw new f("expected end of table declaration",{toml:e,ptr:d[1]-1});d[1]++}let p=H(d[0],i,s,c?2:1);if(!p)throw new f("trying to redefine an already defined table or value",{toml:e,ptr:o});a=p[2],r=p[1],o=d[1]}else{let c=z(e,o),d=H(c[0],r,a,0);if(!d)throw new f("trying to redefine an already defined table or value",{toml:e,ptr:o});let p=X(e,c[1],void 0,t,l);d[1][d[0]]=p[0],o=p[1]}if(o=w(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=w(e,o)}return i}const V={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent",CODEX:"Codex"},D={key:"appendPrompt",label:"追加 Prompt",type:"textarea",rows:3,placeholder:"追加到每次 prompt 末尾的文本"},$e=[{value:"read-only",label:"只读"},{value:"workspace-write",label:"工作区可写"},{value:"danger-full-access",label:"完全开放"}],Be=[{value:"untrusted",label:"仅不受信命令需审批"},{value:"on-request",label:"按需审批"},{value:"never",label:"从不审批"}],K={[v.CLAUDE_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"claude-sonnet-4-20250514"},D],[v.GEMINI_CLI]:[{key:"yolo",label:"跳过权限确认",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"gemini-2.5-pro"},D],[v.CURSOR_AGENT]:[{key:"force",label:"强制执行",type:"switch"},{key:"model",label:"模型",type:"select",options:[{value:"",label:"默认 (auto)"},{value:"claude-sonnet-4-20250514",label:"Claude Sonnet 4"},{value:"claude-sonnet-4-5-20250514",label:"Claude Sonnet 4.5"},{value:"gpt-4o",label:"GPT-4o"}]},D],[v.CODEX]:[{key:"sandbox",label:"执行沙盒",type:"select",options:$e},{key:"approvalPolicy",label:"命令审批",type:"select",options:Be},{key:"model",label:"模型",type:"input",placeholder:"o3"},{key:"profile",label:"Profile",type:"input",placeholder:"~/.codex/config.toml 中的 profile 名称"},D]};function W(e){return e===v.CODEX?{sandbox:"workspace-write",approvalPolicy:"on-request"}:{}}function $(e,t){const l={...t};return e===v.CODEX&&l.fullAuto===!0&&((typeof l.sandbox!="string"||!l.sandbox)&&(l.sandbox="workspace-write"),(typeof l.approvalPolicy!="string"||!l.approvalPolicy)&&(l.approvalPolicy="on-request")),delete l.fullAuto,l}const Ge=JSON.stringify({env:{ANTHROPIC_API_KEY:"",ANTHROPIC_BASE_URL:""}},null,2),Xe=`# Codex config.toml 配置片段 — 通过 -c 参数注入,不会修改 ~/.codex/config.toml
|
|
23
|
+
# 参考: https://developers.openai.com/codex/config-sample
|
|
24
|
+
|
|
25
|
+
# ─── 模型与推理 ─────────────────────────────────────────────
|
|
26
|
+
# model_reasoning_effort = "medium" # minimal | low | medium | high | xhigh
|
|
27
|
+
# model_reasoning_summary = "auto" # auto | concise | detailed | none
|
|
28
|
+
# model_verbosity = "medium" # low | medium | high
|
|
29
|
+
# service_tier = "flex" # fast | flex
|
|
30
|
+
|
|
31
|
+
# ─── 自定义 Model Provider ──────────────────────────────────
|
|
32
|
+
# model_provider = "azure"
|
|
33
|
+
#
|
|
34
|
+
# [model_providers.azure]
|
|
35
|
+
# name = "Azure OpenAI"
|
|
36
|
+
# base_url = "https://YOUR_PROJECT.openai.azure.com/openai"
|
|
37
|
+
# env_key = "AZURE_OPENAI_API_KEY"
|
|
38
|
+
# env_key_instructions = "Set AZURE_OPENAI_API_KEY in Provider env"
|
|
39
|
+
# wire_api = "responses"
|
|
40
|
+
# query_params = { api-version = "2025-04-01-preview" }
|
|
41
|
+
|
|
42
|
+
# ─── OpenAI 数据驻留 ────────────────────────────────────────
|
|
43
|
+
# [model_providers.openai-us]
|
|
44
|
+
# name = "OpenAI US"
|
|
45
|
+
# base_url = "https://us.api.openai.com/v1"
|
|
46
|
+
# wire_api = "responses"
|
|
47
|
+
# requires_openai_auth = true
|
|
48
|
+
|
|
49
|
+
# ─── 本地 OSS (Ollama) ──────────────────────────────────────
|
|
50
|
+
# [model_providers.ollama]
|
|
51
|
+
# name = "Ollama"
|
|
52
|
+
# base_url = "http://localhost:11434/v1"
|
|
53
|
+
# wire_api = "responses"
|
|
54
|
+
`;function R(e){return e===v.CLAUDE_CODE?Ge:e===v.CODEX?Xe:""}function Ve(e){return e===v.CLAUDE_CODE||e===v.CODEX}const Ke=Object.values(K).flat().reduce((e,t)=>(e[t.key]||(e[t.key]=t.label),e),{}),Ze=Object.values(K).flat().reduce((e,t)=>(t.options&&(e[t.key]=Object.fromEntries(t.options.map(l=>[l.value,l.label]))),e),{});function qe(e,t){return typeof t=="boolean"?t?"是":"否":typeof t=="string"&&t?Ze[e]?.[t]??t:String(t)}function U(e,t){return e instanceof Error?e.message:t}function Je(e){return`agent-tower-provider-backup-${e.replace(/[:.]/g,"-")}.json`}function Ye(e,t){const l=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),i=URL.createObjectURL(l),s=document.createElement("a");s.href=i,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function He(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 We({type:e}){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(be,{size:12}),"可用"]}):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(je,{size:12}),"不可用"]})}function F({title:e,defaultOpen:t=!1,children:l}){const[i,s]=C.useState(t);return n.jsxs("div",{className:"border border-neutral-200 rounded-lg",children:[n.jsxs("button",{type:"button",onClick:()=>s(r=>!r),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(ve,{size:14,className:`transition-transform ${i?"rotate-180":""}`})]}),i&&n.jsx("div",{className:"px-4 pb-4 space-y-3",children:l})]})}function Qe({agentType:e,config:t,onChange:l}){const i=K[e]??[];if(i.length===0)return n.jsx("p",{className:"text-xs text-neutral-400",children:"该类型暂无运行配置"});const s=(r,a)=>{l({...t,[r]:a})};return n.jsx("div",{className:"space-y-3",children:i.map(r=>r.type==="textarea"?n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm text-neutral-700 mb-1",children:r.label}),n.jsx("textarea",{value:t[r.key]??"",onChange:a=>s(r.key,a.target.value||void 0),placeholder:r.placeholder,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):n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0",children: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:a=>s(r.key,a.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:a=>s(r.key,a.target.value||void 0),placeholder:r.placeholder,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(ee,{value:t[r.key]??"",onChange:a=>s(r.key,a||void 0),options:r.options,placeholder:"选择..."})]},r.key))})}function et({isOpen:e,onClose:t,initialData:l,onSave:i}){const[s,r]=C.useState(l??{name:"",agentType:v.CLAUDE_CODE,config:W(v.CLAUDE_CODE),settings:"",env:[],isDefault:!1}),[a,o]=C.useState("");C.useEffect(()=>{if(!l&&!s.settings){const m=R(s.agentType);m&&r(h=>({...h,settings:m}))}},[]);const c=m=>{r(h=>({...h,agentType:m,config:W(m),settings:R(m)}))},d=()=>{o("");const m=$(s.agentType,s.config),h={};for(const[N,O]of Object.entries(m))O!==void 0&&O!==""&&(h[N]=O);const b=s.settings.trim();if(b){if(s.agentType===v.CODEX)try{ze(b)}catch(N){o(`TOML 语法错误: ${N instanceof Error?N.message:String(N)}`);return}else if(s.agentType===v.CLAUDE_CODE)try{JSON.parse(b)}catch{o("JSON 语法错误");return}}const g={};for(const{key:N,value:O}of s.env){const A=N.trim();A&&(g[A]=O)}const y={name:s.name,agentType:s.agentType,config:h,settings:b||void 0,env:Object.keys(g).length>0?g:void 0,isDefault:s.isDefault};i(y)};if(!e)return null;const p=Ve(s.agentType),_=s.agentType===v.CODEX;return n.jsx(G,{isOpen:e,onClose:t,title: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:"名称"}),n.jsx("input",{type:"text",value:s.name,onChange:m=>r(h=>({...h,name:m.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:"例如: Claude Code (官方)"})]}),!l&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:"Agent 类型"}),n.jsx(ee,{value:s.agentType,onChange:m=>c(m),options:Object.values(v).map(m=>({value:m,label:V[m]??m})),placeholder:"选择 Agent 类型"})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",id:"isDefault",checked:s.isDefault,onChange:m=>r(h=>({...h,isDefault:m.target.checked})),className:"w-4 h-4"}),n.jsx("label",{htmlFor:"isDefault",className:"text-sm text-neutral-700",children:"设为该类型的默认 Provider"})]}),n.jsx(F,{title:"运行配置",defaultOpen:!0,children:n.jsx(Qe,{agentType:s.agentType,config:s.config,onChange:m=>r(h=>({...h,config:m}))})}),n.jsxs(F,{title:"环境变量",defaultOpen:s.env.length>0,children:[n.jsxs("p",{className:"text-xs text-neutral-500 mb-2",children:["注入到 Agent 进程的环境变量。Codex 的 ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env_key"})," 指定的是变量名,实际值需在此处设置。"]}),n.jsxs("div",{className:"space-y-2",children:[s.env.map((m,h)=>n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("input",{type:"text",value:m.key,onChange:b=>{const g=[...s.env];g[h]={...g[h],key:b.target.value},r(y=>({...y,env:g}))},placeholder:"变量名,如 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:m.value,onChange:b=>{const g=[...s.env];g[h]={...g[h],value:b.target.value},r(y=>({...y,env:g}))},placeholder:"值",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 b=s.env.filter((g,y)=>y!==h);r(g=>({...g,env:b}))},className:"p-1.5 text-neutral-400 hover:text-red-500",children:n.jsx(Q,{size:14})})]},h)),n.jsxs(j,{variant:"outline",size:"sm",onClick:()=>r(m=>({...m,env:[...m.env,{key:"",value:""}]})),children:[n.jsx(te,{size:12,className:"mr-1"}),"添加变量"]})]})]}),p&&n.jsxs(F,{title:_?"CLI 原生配置 (config.toml)":"CLI 原生配置 (settings.json)",children:[n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:_?n.jsxs(n.Fragment,{children:["直接填写 Codex ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"config.toml"})," 格式的配置片段, 通过 ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"-c"})," 参数注入。 不会修改你的 ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.codex/config.toml"})," 文件。 如与上方“执行沙盒”或“命令审批”重复,以上方运行配置为准。"]}):n.jsxs(n.Fragment,{children:["对应 Claude Code 的 ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.claude/settings.json"}),", 通过 ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"--settings"})," 参数注入。 在 ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env"})," 中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。"]})}),n.jsx("textarea",{value:s.settings,onChange:m=>{r(h=>({...h,settings:m.target.value})),o("")},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:R(s.agentType)}),a&&n.jsx("p",{className:"mt-1 text-xs text-red-600",children:a})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(j,{variant:"outline",onClick:t,children:"取消"}),n.jsx(j,{onClick:d,disabled:!s.name.trim(),children:"保存"})]})]})})}function tt({isOpen:e,onClose:t,onConfirm:l,acknowledged:i,onAcknowledgedChange:s,isLoading:r}){return n.jsx(G,{isOpen:e,onClose:t,title:"导出 Provider 备份",className:"max-w-xl",action:n.jsxs(n.Fragment,{children:[n.jsx(j,{variant:"outline",onClick:t,disabled:r,children:"取消"}),n.jsx(j,{onClick:l,disabled:!i||r,children:r?"导出中...":"导出备份"})]}),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:"导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。"}),n.jsxs("div",{className:"text-sm text-neutral-600 space-y-2",children:[n.jsx("p",{children:"这个功能用于备份和迁移,不用于分享配置。"}),n.jsx("p",{children:"导出内容只包含用户层配置:自定义 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:a=>s(a.target.checked),className:"mt-0.5 h-4 w-4"}),n.jsx("span",{children:"我已知晓该备份文件包含敏感信息,只会保存在安全位置。"})]})]})})}function nt({isOpen:e,onClose:t,preview:l,backup:i,onConfirm:s,isLoading:r}){if(!l||!i)return null;const a=l.summary.create+l.summary.overwrite,o=[...l.items].sort((c,d)=>{const p={CREATE:0,OVERWRITE:1,SKIP:2};return p[c.action]-p[d.action]});return n.jsx(G,{isOpen:e,onClose:t,title:"导入 Provider 备份",className:"max-w-3xl",action:n.jsxs(n.Fragment,{children:[n.jsx(j,{variant:"outline",onClick:t,disabled:r,children:"取消"}),n.jsx(j,{onClick:s,disabled:a===0||r,children:r?"导入中...":`确认导入 ${a} 项`})]}),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.jsxs("div",{children:["导出时间:",new Date(i.exportedAt).toLocaleString()]}),n.jsx("div",{children:"模式:完整备份(含敏感信息)"}),n.jsxs("div",{children:["文件内 Provider 数量:",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:"新增"}),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:"覆盖"}),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:"跳过"}),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:o.map(c=>{const d=He(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 ${d.className}`,children:d.label})]}),n.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[V[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.jsxs("p",{className:"mt-2 text-xs text-amber-700",children:["将覆盖当前已有的 Provider:",c.existing.name]}),c.action==="SKIP"&&n.jsx("p",{className:"mt-2 text-xs text-neutral-500",children:"当前同 ID Provider 配置一致,本次不会重复写入。"}),c.action==="CREATE"&&n.jsx("p",{className:"mt-2 text-xs text-green-700",children:"当前不存在同 ID Provider,将直接新增。"})]},c.incoming.id)})})]})})}function xt(){const{data:e,isLoading:t}=de(),l=ue(),i=me(),s=fe(),r=xe(),a=pe(),o=he(),c=C.useRef(null),[d,p]=C.useState(null),[_,m]=C.useState(!1),[h,b]=C.useState(!1),[g,y]=C.useState(null),N=x=>{l.mutate(x,{onSuccess:()=>p(null)})},O=(x,u)=>{i.mutate({id:x,data:u},{onSuccess:()=>p(null)})},A=(x,u,E)=>{if(E){P.error("内置 Provider 不可删除");return}confirm(`确定删除 "${u}"?`)&&s.mutate(x)},Z=()=>{m(!1),b(!1)},q=()=>{y(null)},le=()=>{r.mutate(void 0,{onSuccess:x=>{Ye(Je(x.exportedAt),x),P.success("Provider 备份已导出"),Z()},onError:x=>{P.error(U(x,"导出 Provider 备份失败"))}})},se=()=>{c.current&&(c.current.value="",c.current.click())},ae=async x=>{const u=x.target.files?.[0];if(x.target.value="",!u)return;let E;try{E=JSON.parse(await u.text())}catch{P.error("备份文件不是有效的 JSON");return}a.mutate(E,{onSuccess:k=>{y({backup:E,preview:k})},onError:k=>{P.error(U(k,"导入预览失败"))}})},ie=()=>{g&&o.mutate(g.backup,{onSuccess:x=>{const u=x.summary.create+x.summary.overwrite;P.success(u===0?"导入完成,当前配置无需变更":`导入完成:新增 ${x.summary.create},覆盖 ${x.summary.overwrite},跳过 ${x.summary.skip}`),q()},onError:x=>{P.error(U(x,"导入 Provider 备份失败"))}})},oe=x=>{const u=x.provider,E=u.env?Object.entries(u.env).map(([k,S])=>({key:k,value:S})):[];p({id:u.id,data:{name:u.name,agentType:u.agentType,config:$(u.agentType,u.config),settings:u.settings??"",env:E,isDefault:u.isDefault}})};if(t)return n.jsx("div",{className:"p-6 text-sm text-neutral-400",children:"加载中..."});const J=e??[];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:ae}),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:"Provider 配置"}),n.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:"管理 AI Agent 的连接配置和运行参数"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(j,{variant:"outline",onClick:se,disabled:a.isPending||o.isPending,children:[n.jsx(Ce,{size:14}),"导入备份"]}),n.jsxs(j,{variant:"outline",onClick:()=>m(!0),disabled:r.isPending,children:[n.jsx(Ne,{size:14}),"导出备份"]}),n.jsxs(j,{onClick:()=>p({}),children:[n.jsx(te,{size:14,className:"mr-1"}),"新建 Provider"]})]})]}),J.length===0?n.jsx("div",{className:"text-center py-12 text-sm text-neutral-400",children:"暂无 Provider 配置"}):n.jsx("div",{className:"space-y-3",children:J.map(x=>{const u=x.provider,E=x.availability,k=$(u.agentType,u.config),S=Object.entries(k).filter(([T])=>T!=="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:u.name}),n.jsx(We,{type:E.type}),u.isDefault&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-blue-700 bg-blue-50 rounded",children:"默认"}),u.builtIn&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:"内置"})]}),n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:V[u.agentType]??u.agentType}),S.length>0&&n.jsx("div",{className:"text-xs text-neutral-600 mb-1",children:S.map(([T,ce])=>n.jsxs("span",{className:"inline-flex items-center mr-3",children:[n.jsxs("span",{className:"font-medium",children:[Ke[T]??T,":"]})," ",qe(T,ce)]},T))}),u.settings?.trim()&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:"CLI 配置:"})," 已配置"]}),Object.keys(u.env).length>0&&!u.settings&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:"环境变量:"})," ",Object.keys(u.env).join(", ")]})]}),n.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[n.jsx("button",{onClick:()=>oe(x),className:"p-2 text-neutral-400 hover:text-neutral-900 transition-colors",title:"编辑",children:n.jsx(ge,{size:14})}),n.jsx("button",{onClick:()=>A(u.id,u.name,u.builtIn),className:"p-2 text-neutral-400 hover:text-red-600 transition-colors",title:"删除",disabled:u.builtIn,children:n.jsx(Q,{size:14})})]})]})},u.id)})}),d&&n.jsx(et,{isOpen:!0,onClose:()=>p(null),initialData:d.data,onSave:x=>{d.id?O(d.id,x):N(x)}}),n.jsx(tt,{isOpen:_,onClose:Z,onConfirm:le,acknowledged:h,onAcknowledgedChange:b,isLoading:r.isPending}),n.jsx(nt,{isOpen:!!g,onClose:q,preview:g?.preview??null,backup:g?.backup??null,onConfirm:ie,isLoading:o.isPending})]})}export{xt as ProviderSettingsPage};
|