agent-tower 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/executors/codex.executor.d.ts +2 -6
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +3 -11
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/executors/default-providers.json +1 -2
- package/dist/web/assets/{AgentDemoPage-DSyU6XMx.js → AgentDemoPage-YmanLcCN.js} +1 -1
- package/dist/web/assets/{DemoPage-BxYQv1Wa.js → DemoPage-BqY38vpM.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-mln4lAxn.js → NotificationSettingsPage-BCHTrcGM.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-CS-WK307.js → ProfileSettingsPage-BUjwXVis.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-Bz0Q0ZZy.js → ProjectKanbanPage-BnV1bfmb.js} +3 -3
- package/dist/web/assets/{ProjectSettingsPage-CBnahNua.js → ProjectSettingsPage-n3WgEYp1.js} +1 -1
- package/dist/web/assets/ProviderSettingsPage-BNb3ixUl.js +54 -0
- package/dist/web/assets/{api-client-iFY2ykuZ.js → api-client-CvkWGC57.js} +1 -1
- package/dist/web/assets/{chevron-down-CxTrrnvp.js → chevron-down-gMypHmvg.js} +1 -1
- package/dist/web/assets/{circle-alert-CHDHEO67.js → circle-alert-R4XXB7n4.js} +1 -1
- package/dist/web/assets/{circle-check-uswR_cEa.js → circle-check-gk9yWlOW.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-VVSDpKw-.js → code-block-OCS4YCEC-37w58MP9.js} +1 -1
- package/dist/web/assets/{folder-picker-DshGpYNS.js → folder-picker-BNSXB4UX.js} +1 -1
- package/dist/web/assets/{index-hdGFeHu1.js → index-DFLmhfiK.js} +2 -2
- package/dist/web/assets/{loader-circle-BYF33K7x.js → loader-circle-DkuE984n.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-CQLrOBEw.js → mermaid-NOHMQCX5-BCuuUgP6.js} +3 -3
- package/dist/web/assets/{modal-BCL0660p.js → modal-Cs0LO1_I.js} +1 -1
- package/dist/web/assets/{pencil-SJi1qbh9.js → pencil-DBXkFcMj.js} +1 -1
- package/dist/web/assets/{query-keys-B2VhRmAm.js → query-keys-Ddm69Sh0.js} +1 -1
- package/dist/web/assets/{select-WuDnj3zN.js → select-CXYXolOw.js} +1 -1
- package/dist/web/assets/{use-profiles-DYTDOkn8.js → use-profiles-C--W_RiQ.js} +1 -1
- package/dist/web/assets/{use-projects-BLI6qXx-.js → use-projects-Cnz3uQZV.js} +1 -1
- package/dist/web/assets/{use-providers-C1i5uxRH.js → use-providers-BkyYy5Sg.js} +1 -1
- package/dist/web/assets/{x-Bn5zgMLL.js → x-Yu7IY3ea.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/ProviderSettingsPage-D-Lrg1Sj.js +0 -54
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as f,r as a,j as e}from"./index-
|
|
1
|
+
import{c as f,r as a,j as e}from"./index-DFLmhfiK.js";import{c as i}from"./api-client-CvkWGC57.js";import{X as x}from"./x-Yu7IY3ea.js";const y=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],j=f("trash-2",y),b=({isOpen:t,onClose:r,title:d,children:c,action:l,className:u})=>{const[m,n]=a.useState(!1);a.useEffect(()=>{if(t)n(!0),document.body.style.overflow="hidden";else{const o=setTimeout(()=>n(!1),200);return document.body.style.overflow="unset",()=>clearTimeout(o)}},[t]);const s=a.useCallback(o=>{o.key==="Escape"&&r()},[r]);return a.useEffect(()=>{if(t)return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,s]),!m&&!t?null:e.jsxs("div",{className:i("fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200",t?"opacity-100":"opacity-0"),children:[e.jsx("div",{className:"absolute inset-0 bg-white/80 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:i("relative w-full max-w-lg bg-white rounded-xl shadow-2xl shadow-neutral-200/50 border border-neutral-100 transform transition-all duration-200",t?"scale-100 translate-y-0":"scale-95 translate-y-2",u),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-neutral-50",children:[e.jsx("h3",{className:"font-semibold text-neutral-900",children:d}),e.jsx("button",{onClick:r,className:"text-neutral-400 hover:text-neutral-900 transition-colors",children:e.jsx(x,{size:18})})]}),e.jsx("div",{className:"p-6",children:c}),l?e.jsx("div",{className:"px-6 py-4 bg-neutral-50 rounded-b-xl border-t border-neutral-100 flex justify-end gap-3",children:l}):null]})]})},w=Object.freeze(Object.defineProperty({__proto__:null,Modal:b},Symbol.toStringTag,{value:"Module"}));export{b as M,j as T,w as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./index-
|
|
1
|
+
import{c as a}from"./index-DFLmhfiK.js";const c=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],o=a("pencil",c);export{o as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G,p as K,b as d,d as w,e as y,n as M,f as P,h as A,t as Y,k as C,l as Z,m as $,o as B,q as I,v as H,w as q,r as c,x as _,u as J}from"./index-hdGFeHu1.js";var tt=class extends G{constructor(t,e){super(),this.options=e,this.#s=t,this.#o=null,this.#n=K(),this.bindMethods(),this.setOptions(e)}#s;#t=void 0;#i=void 0;#e=void 0;#r;#a;#n;#o;#m;#d;#f;#c;#u;#h;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),W(this.#t,this.options)?this.#l():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return k(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return k(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#R(),this.#S(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#s.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof d(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!w(this.options,e)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&z(this.#t,s,this.options,e)&&this.#l(),this.updateResult(),i&&(this.#t!==s||d(this.options.enabled,this.#t)!==d(e.enabled,this.#t)||y(this.options.staleTime,this.#t)!==y(e.staleTime,this.#t))&&this.#v();const r=this.#b();i&&(this.#t!==s||d(this.options.enabled,this.#t)!==d(e.enabled,this.#t)||r!==this.#h)&&this.#g(r)}getOptimisticResult(t){const e=this.#s.getQueryCache().build(this.#s,t),s=this.createResult(e,t);return st(this,s)&&(this.#e=s,this.#a=this.options,this.#r=this.#t.state),s}getCurrentResult(){return this.#e}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#n.status==="pending"&&this.#n.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,i))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#s.defaultQueryOptions(t),s=this.#s.getQueryCache().build(this.#s,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#l({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#e))}#l(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(M)),e}#v(){this.#R();const t=y(this.options.staleTime,this.#t);if(P||this.#e.isStale||!A(t))return;const s=Y(this.#e.dataUpdatedAt,t)+1;this.#c=C.setTimeout(()=>{this.#e.isStale||this.updateResult()},s)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(t){this.#S(),this.#h=t,!(P||d(this.options.enabled,this.#t)===!1||!A(this.#h)||this.#h===0)&&(this.#u=C.setInterval(()=>{(this.options.refetchIntervalInBackground||Z.isFocused())&&this.#l()},this.#h))}#y(){this.#v(),this.#g(this.#b())}#R(){this.#c&&(C.clearTimeout(this.#c),this.#c=void 0)}#S(){this.#u&&(C.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#e,u=this.#r,a=this.#a,v=t!==s?t.state:this.#i,{state:h}=t;let n={...h},b=!1,o;if(e._optimisticResults){const l=this.hasListeners(),g=!l&&W(t,e),S=l&&z(t,s,e,i);(g||S)&&(n={...n,...$(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:D,status:m}=n;o=n.data;let F=!1;if(e.placeholderData!==void 0&&o===void 0&&m==="pending"){let l;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(l=r.data,F=!0):l=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,l!==void 0&&(m="success",o=B(r?.data,l,e),b=!0)}if(e.select&&o!==void 0&&!F)if(r&&o===u?.data&&e.select===this.#m)o=this.#d;else try{this.#m=e.select,o=e.select(o),o=B(r?.data,o,e),this.#d=o,this.#o=null}catch(l){this.#o=l}this.#o&&(R=this.#o,o=this.#d,D=Date.now(),m="error");const T=n.fetchStatus==="fetching",x=m==="pending",Q=m==="error",j=x&&T,L=o!==void 0,p={status:m,fetchStatus:n.fetchStatus,isPending:x,isSuccess:m==="success",isError:Q,isInitialLoading:j,isLoading:j,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:D,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:n.dataUpdateCount>0||n.errorUpdateCount>0,isFetchedAfterMount:n.dataUpdateCount>v.dataUpdateCount||n.errorUpdateCount>v.errorUpdateCount,isFetching:T,isRefetching:T&&!x,isLoadingError:Q&&!L,isPaused:n.fetchStatus==="paused",isPlaceholderData:b,isRefetchError:Q&&L,isStale:U(t,e),refetch:this.refetch,promise:this.#n,isEnabled:d(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const l=p.data!==void 0,g=p.status==="error"&&!l,S=E=>{g?E.reject(p.error):l&&E.resolve(p.data)},N=()=>{const E=this.#n=p.promise=K();S(E)},O=this.#n;switch(O.status){case"pending":t.queryHash===s.queryHash&&S(O);break;case"fulfilled":(g||p.data!==O.value)&&N();break;case"rejected":(!g||p.error!==O.reason)&&N();break}}return p}updateResult(){const t=this.#e,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#f=this.#t),w(e,t))return;this.#e=e;const s=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,r=typeof i=="function"?i():i;if(r==="all"||!r&&!this.#p.size)return!0;const u=new Set(r??this.#p);return this.options.throwOnError&&u.add("error"),Object.keys(this.#e).some(a=>{const f=a;return this.#e[f]!==t[f]&&u.has(f)})};this.#E({listeners:s()})}#O(){const t=this.#s.getQueryCache().build(this.#s,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#i=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#E(t){I.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#e)}),this.#s.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function et(t,e){return d(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function W(t,e){return et(t,e)||t.state.data!==void 0&&k(t,e,e.refetchOnMount)}function k(t,e,s){if(d(e.enabled,t)!==!1&&y(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&U(t,e)}return!1}function z(t,e,s,i){return(t!==e||d(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&U(t,s)}function U(t,e){return d(e.enabled,t)!==!1&&t.isStaleByTime(y(e.staleTime,t))}function st(t,e){return!w(t.getCurrentResult(),e)}var it=class extends G{#s;#t=void 0;#i;#e;constructor(t,e){super(),this.#s=t,this.setOptions(e),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.#s.defaultMutationOptions(t),w(this.options,e)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#i,observer:this}),e?.mutationKey&&this.options.mutationKey&&H(e.mutationKey)!==H(this.options.mutationKey)?this.reset():this.#i?.state.status==="pending"&&this.#i.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#i?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#a(t)}getCurrentResult(){return this.#t}reset(){this.#i?.removeObserver(this),this.#i=void 0,this.#r(),this.#a()}mutate(t,e){return this.#e=e,this.#i?.removeObserver(this),this.#i=this.#s.getMutationCache().build(this.#s,this.options),this.#i.addObserver(this),this.#i.execute(t)}#r(){const t=this.#i?.state??q();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){I.batch(()=>{if(this.#e&&this.hasListeners()){const e=this.#t.variables,s=this.#t.context,i={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#e.onSuccess?.(t.data,e,s,i)}catch(r){Promise.reject(r)}try{this.#e.onSettled?.(t.data,null,e,s,i)}catch(r){Promise.reject(r)}}else if(t?.type==="error"){try{this.#e.onError?.(t.error,e,s,i)}catch(r){Promise.reject(r)}try{this.#e.onSettled?.(void 0,t.error,e,s,i)}catch(r){Promise.reject(r)}}}this.listeners.forEach(e=>{e(this.#t)})})}},X=c.createContext(!1),rt=()=>c.useContext(X);X.Provider;function at(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var nt=c.createContext(at()),ot=()=>c.useContext(nt),ht=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?_(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||i)&&(e.isReset()||(t.retryOnMount=!1))},ct=t=>{c.useEffect(()=>{t.clearReset()},[t])},ut=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||_(s,[t.error,i])),lt=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},dt=(t,e)=>t.isLoading&&t.isFetching&&!e,ft=(t,e)=>t?.suspense&&e.isPending,V=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function pt(t,e,s){const i=rt(),r=ot(),u=J(),a=u.defaultQueryOptions(t);u.getDefaultOptions().queries?._experimental_beforeQuery?.(a);const f=u.getQueryCache().get(a.queryHash);a._optimisticResults=i?"isRestoring":"optimistic",lt(a),ht(a,r,f),ct(r);const v=!u.getQueryCache().get(a.queryHash),[h]=c.useState(()=>new e(u,a)),n=h.getOptimisticResult(a),b=!i&&t.subscribed!==!1;if(c.useSyncExternalStore(c.useCallback(o=>{const R=b?h.subscribe(I.batchCalls(o)):M;return h.updateResult(),R},[h,b]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),c.useEffect(()=>{h.setOptions(a)},[a,h]),ft(a,n))throw V(a,h,r);if(ut({result:n,errorResetBoundary:r,throwOnError:a.throwOnError,query:f,suspense:a.suspense}))throw n.error;return u.getDefaultOptions().queries?._experimental_afterQuery?.(a,n),a.experimental_prefetchInRender&&!P&&dt(n,i)&&(v?V(a,h,r):f?.promise)?.catch(M).finally(()=>{h.updateResult()}),a.notifyOnChangeProps?n:h.trackResult(n)}function bt(t,e){return pt(t,tt)}function gt(t,e){const s=J(),[i]=c.useState(()=>new it(s,t));c.useEffect(()=>{i.setOptions(t)},[i,t]);const r=c.useSyncExternalStore(c.useCallback(a=>i.subscribe(I.batchCalls(a)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),u=c.useCallback((a,f)=>{i.mutate(a,f).catch(M)},[i]);if(r.error&&_(i.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:u,mutateAsync:r.mutate}}const yt={projects:{all:["projects"],list:t=>["projects","list",t],detail:t=>["projects","detail",t]},tasks:{all:["tasks"],list:(t,e)=>["tasks","list",t,e],detail:t=>["tasks","detail",t],stats:t=>["tasks","stats",t]},workspaces:{all:["workspaces"],list:t=>["workspaces","list",t],detail:t=>["workspaces","detail",t],diff:t=>["workspaces","diff",t],gitStatus:t=>["workspaces","gitStatus",t]},sessions:{all:["sessions"],detail:t=>["sessions","detail",t]},files:{all:["files"],tree:(t,e)=>["files","tree",t,e],content:(t,e)=>["files","content",t,e]},git:{all:["git"],changes:t=>["git","changes",t],diff:(t,e,s)=>["git","diff",t,e,s],log:t=>["git","log",t],commitFiles:(t,e)=>["git","commitFiles",t,e],commitDiff:(t,e,s)=>["git","commitDiff",t,e,s]},profiles:{all:["profiles"],defaults:["profiles","defaults"],agent:t=>["profiles","agent",t],variant:(t,e)=>["profiles","variant",t,e]},providers:{all:["providers"],detail:t=>["providers","detail",t]},tunnel:{status:["tunnel","status"]},notifications:{settings:["notifications","settings"]}};export{tt as Q,gt as a,rt as b,ot as c,ht as d,lt as e,ct as f,V as g,ut as h,pt as i,yt as q,ft as s,bt as u,dt as w};
|
|
1
|
+
import{a as G,p as K,b as d,d as w,e as y,n as M,f as P,h as A,t as Y,k as C,l as Z,m as $,o as B,q as I,v as H,w as q,r as c,x as _,u as J}from"./index-DFLmhfiK.js";var tt=class extends G{constructor(t,e){super(),this.options=e,this.#s=t,this.#o=null,this.#n=K(),this.bindMethods(),this.setOptions(e)}#s;#t=void 0;#i=void 0;#e=void 0;#r;#a;#n;#o;#m;#d;#f;#c;#u;#h;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),W(this.#t,this.options)?this.#l():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return k(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return k(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#R(),this.#S(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#s.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof d(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!w(this.options,e)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&z(this.#t,s,this.options,e)&&this.#l(),this.updateResult(),i&&(this.#t!==s||d(this.options.enabled,this.#t)!==d(e.enabled,this.#t)||y(this.options.staleTime,this.#t)!==y(e.staleTime,this.#t))&&this.#v();const r=this.#b();i&&(this.#t!==s||d(this.options.enabled,this.#t)!==d(e.enabled,this.#t)||r!==this.#h)&&this.#g(r)}getOptimisticResult(t){const e=this.#s.getQueryCache().build(this.#s,t),s=this.createResult(e,t);return st(this,s)&&(this.#e=s,this.#a=this.options,this.#r=this.#t.state),s}getCurrentResult(){return this.#e}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#n.status==="pending"&&this.#n.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,i))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#s.defaultQueryOptions(t),s=this.#s.getQueryCache().build(this.#s,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#l({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#e))}#l(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(M)),e}#v(){this.#R();const t=y(this.options.staleTime,this.#t);if(P||this.#e.isStale||!A(t))return;const s=Y(this.#e.dataUpdatedAt,t)+1;this.#c=C.setTimeout(()=>{this.#e.isStale||this.updateResult()},s)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(t){this.#S(),this.#h=t,!(P||d(this.options.enabled,this.#t)===!1||!A(this.#h)||this.#h===0)&&(this.#u=C.setInterval(()=>{(this.options.refetchIntervalInBackground||Z.isFocused())&&this.#l()},this.#h))}#y(){this.#v(),this.#g(this.#b())}#R(){this.#c&&(C.clearTimeout(this.#c),this.#c=void 0)}#S(){this.#u&&(C.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#e,u=this.#r,a=this.#a,v=t!==s?t.state:this.#i,{state:h}=t;let n={...h},b=!1,o;if(e._optimisticResults){const l=this.hasListeners(),g=!l&&W(t,e),S=l&&z(t,s,e,i);(g||S)&&(n={...n,...$(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:D,status:m}=n;o=n.data;let F=!1;if(e.placeholderData!==void 0&&o===void 0&&m==="pending"){let l;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(l=r.data,F=!0):l=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,l!==void 0&&(m="success",o=B(r?.data,l,e),b=!0)}if(e.select&&o!==void 0&&!F)if(r&&o===u?.data&&e.select===this.#m)o=this.#d;else try{this.#m=e.select,o=e.select(o),o=B(r?.data,o,e),this.#d=o,this.#o=null}catch(l){this.#o=l}this.#o&&(R=this.#o,o=this.#d,D=Date.now(),m="error");const T=n.fetchStatus==="fetching",x=m==="pending",Q=m==="error",j=x&&T,L=o!==void 0,p={status:m,fetchStatus:n.fetchStatus,isPending:x,isSuccess:m==="success",isError:Q,isInitialLoading:j,isLoading:j,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:D,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:n.dataUpdateCount>0||n.errorUpdateCount>0,isFetchedAfterMount:n.dataUpdateCount>v.dataUpdateCount||n.errorUpdateCount>v.errorUpdateCount,isFetching:T,isRefetching:T&&!x,isLoadingError:Q&&!L,isPaused:n.fetchStatus==="paused",isPlaceholderData:b,isRefetchError:Q&&L,isStale:U(t,e),refetch:this.refetch,promise:this.#n,isEnabled:d(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const l=p.data!==void 0,g=p.status==="error"&&!l,S=E=>{g?E.reject(p.error):l&&E.resolve(p.data)},N=()=>{const E=this.#n=p.promise=K();S(E)},O=this.#n;switch(O.status){case"pending":t.queryHash===s.queryHash&&S(O);break;case"fulfilled":(g||p.data!==O.value)&&N();break;case"rejected":(!g||p.error!==O.reason)&&N();break}}return p}updateResult(){const t=this.#e,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#f=this.#t),w(e,t))return;this.#e=e;const s=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,r=typeof i=="function"?i():i;if(r==="all"||!r&&!this.#p.size)return!0;const u=new Set(r??this.#p);return this.options.throwOnError&&u.add("error"),Object.keys(this.#e).some(a=>{const f=a;return this.#e[f]!==t[f]&&u.has(f)})};this.#E({listeners:s()})}#O(){const t=this.#s.getQueryCache().build(this.#s,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#i=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#E(t){I.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#e)}),this.#s.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function et(t,e){return d(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function W(t,e){return et(t,e)||t.state.data!==void 0&&k(t,e,e.refetchOnMount)}function k(t,e,s){if(d(e.enabled,t)!==!1&&y(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&U(t,e)}return!1}function z(t,e,s,i){return(t!==e||d(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&U(t,s)}function U(t,e){return d(e.enabled,t)!==!1&&t.isStaleByTime(y(e.staleTime,t))}function st(t,e){return!w(t.getCurrentResult(),e)}var it=class extends G{#s;#t=void 0;#i;#e;constructor(t,e){super(),this.#s=t,this.setOptions(e),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.#s.defaultMutationOptions(t),w(this.options,e)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#i,observer:this}),e?.mutationKey&&this.options.mutationKey&&H(e.mutationKey)!==H(this.options.mutationKey)?this.reset():this.#i?.state.status==="pending"&&this.#i.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#i?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#a(t)}getCurrentResult(){return this.#t}reset(){this.#i?.removeObserver(this),this.#i=void 0,this.#r(),this.#a()}mutate(t,e){return this.#e=e,this.#i?.removeObserver(this),this.#i=this.#s.getMutationCache().build(this.#s,this.options),this.#i.addObserver(this),this.#i.execute(t)}#r(){const t=this.#i?.state??q();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){I.batch(()=>{if(this.#e&&this.hasListeners()){const e=this.#t.variables,s=this.#t.context,i={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#e.onSuccess?.(t.data,e,s,i)}catch(r){Promise.reject(r)}try{this.#e.onSettled?.(t.data,null,e,s,i)}catch(r){Promise.reject(r)}}else if(t?.type==="error"){try{this.#e.onError?.(t.error,e,s,i)}catch(r){Promise.reject(r)}try{this.#e.onSettled?.(void 0,t.error,e,s,i)}catch(r){Promise.reject(r)}}}this.listeners.forEach(e=>{e(this.#t)})})}},X=c.createContext(!1),rt=()=>c.useContext(X);X.Provider;function at(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var nt=c.createContext(at()),ot=()=>c.useContext(nt),ht=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?_(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||i)&&(e.isReset()||(t.retryOnMount=!1))},ct=t=>{c.useEffect(()=>{t.clearReset()},[t])},ut=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||_(s,[t.error,i])),lt=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},dt=(t,e)=>t.isLoading&&t.isFetching&&!e,ft=(t,e)=>t?.suspense&&e.isPending,V=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function pt(t,e,s){const i=rt(),r=ot(),u=J(),a=u.defaultQueryOptions(t);u.getDefaultOptions().queries?._experimental_beforeQuery?.(a);const f=u.getQueryCache().get(a.queryHash);a._optimisticResults=i?"isRestoring":"optimistic",lt(a),ht(a,r,f),ct(r);const v=!u.getQueryCache().get(a.queryHash),[h]=c.useState(()=>new e(u,a)),n=h.getOptimisticResult(a),b=!i&&t.subscribed!==!1;if(c.useSyncExternalStore(c.useCallback(o=>{const R=b?h.subscribe(I.batchCalls(o)):M;return h.updateResult(),R},[h,b]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),c.useEffect(()=>{h.setOptions(a)},[a,h]),ft(a,n))throw V(a,h,r);if(ut({result:n,errorResetBoundary:r,throwOnError:a.throwOnError,query:f,suspense:a.suspense}))throw n.error;return u.getDefaultOptions().queries?._experimental_afterQuery?.(a,n),a.experimental_prefetchInRender&&!P&&dt(n,i)&&(v?V(a,h,r):f?.promise)?.catch(M).finally(()=>{h.updateResult()}),a.notifyOnChangeProps?n:h.trackResult(n)}function bt(t,e){return pt(t,tt)}function gt(t,e){const s=J(),[i]=c.useState(()=>new it(s,t));c.useEffect(()=>{i.setOptions(t)},[i,t]);const r=c.useSyncExternalStore(c.useCallback(a=>i.subscribe(I.batchCalls(a)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),u=c.useCallback((a,f)=>{i.mutate(a,f).catch(M)},[i]);if(r.error&&_(i.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:u,mutateAsync:r.mutate}}const yt={projects:{all:["projects"],list:t=>["projects","list",t],detail:t=>["projects","detail",t]},tasks:{all:["tasks"],list:(t,e)=>["tasks","list",t,e],detail:t=>["tasks","detail",t],stats:t=>["tasks","stats",t]},workspaces:{all:["workspaces"],list:t=>["workspaces","list",t],detail:t=>["workspaces","detail",t],diff:t=>["workspaces","diff",t],gitStatus:t=>["workspaces","gitStatus",t]},sessions:{all:["sessions"],detail:t=>["sessions","detail",t]},files:{all:["files"],tree:(t,e)=>["files","tree",t,e],content:(t,e)=>["files","content",t,e]},git:{all:["git"],changes:t=>["git","changes",t],diff:(t,e,s)=>["git","diff",t,e,s],log:t=>["git","log",t],commitFiles:(t,e)=>["git","commitFiles",t,e],commitDiff:(t,e,s)=>["git","commitDiff",t,e,s]},profiles:{all:["profiles"],defaults:["profiles","defaults"],agent:t=>["profiles","agent",t],variant:(t,e)=>["profiles","variant",t,e]},providers:{all:["providers"],detail:t=>["providers","detail",t]},tunnel:{status:["tunnel","status"]},notifications:{settings:["notifications","settings"]}};export{tt as Q,gt as a,rt as b,ot as c,ht as d,lt as e,ct as f,V as g,ut as h,pt as i,yt as q,ft as s,bt as u,dt as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as t}from"./index-
|
|
1
|
+
import{r as n,j as t}from"./index-DFLmhfiK.js";import{c as r}from"./api-client-CvkWGC57.js";import{C as h,a as p}from"./chevron-down-gMypHmvg.js";function j({value:l,onChange:i,options:o,placeholder:d="Select...",disabled:m=!1,className:f}){const[s,a]=n.useState(!1),c=n.useRef(null),u=o.find(e=>e.value===l);n.useEffect(()=>{if(!s)return;const e=b=>{c.current&&!c.current.contains(b.target)&&a(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]);const x=n.useCallback(e=>{e.key==="Escape"&&a(!1)},[]);return t.jsxs("div",{ref:c,className:r("relative",f),onKeyDown:x,children:[t.jsxs("button",{type:"button",disabled:m,onClick:()=>a(e=>!e),className:r("flex items-center justify-between w-full h-9 px-3 border rounded-lg text-sm transition-colors","bg-white border-neutral-200 hover:border-neutral-300","focus:outline-none focus:border-neutral-400","disabled:opacity-50 disabled:cursor-not-allowed",s&&"border-neutral-400",!u&&"text-neutral-400"),children:[t.jsx("span",{className:"truncate",children:u?u.label:d}),t.jsx(h,{size:14,className:r("ml-2 shrink-0 text-neutral-400 transition-transform duration-150",s&&"rotate-180")})]}),s&&t.jsx("div",{className:"absolute z-50 mt-1 w-full min-w-[160px] bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 max-h-[200px] overflow-y-auto",children:o.length===0?t.jsx("div",{className:"px-3 py-2 text-sm text-neutral-400",children:"No options"}):o.map(e=>t.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>{i(e.value),a(!1)},className:r("flex items-center w-full px-3 py-1.5 text-sm text-left transition-colors","hover:bg-neutral-50",e.value===l?"text-neutral-900 font-medium":"text-neutral-600",e.disabled&&"opacity-40 cursor-not-allowed"),children:[t.jsx(p,{size:14,className:r("mr-2 shrink-0",e.value===l?"opacity-100":"opacity-0")}),t.jsx("span",{className:"truncate",children:e.label})]},e.value))})]})}export{j as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as i,a as n,q as r}from"./query-keys-
|
|
1
|
+
import{u as i,a as n,q as r}from"./query-keys-Ddm69Sh0.js";import{u as a}from"./index-DFLmhfiK.js";import{a as u}from"./api-client-CvkWGC57.js";function y(){return i({queryKey:r.profiles.all,queryFn:()=>u.get("/profiles")})}function c(){return i({queryKey:r.profiles.defaults,queryFn:()=>u.get("/profiles/defaults")})}function q(e){return i({queryKey:r.profiles.agent(e),queryFn:()=>u.get(`/profiles/${e}`),enabled:!!e})}function d(){const e=a();return n({mutationFn:({agentType:s,variant:t,config:o})=>u.put(`/profiles/${s}/${t}`,o),onSuccess:()=>{e.invalidateQueries({queryKey:r.profiles.all})}})}function m(){const e=a();return n({mutationFn:({agentType:s,variant:t})=>u.delete(`/profiles/${s}/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:r.profiles.all})}})}export{c as a,d as b,m as c,q as d,y as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u,u as n}from"./index-
|
|
1
|
+
import{c as u,u as n}from"./index-DFLmhfiK.js";import{u as i,a as o,q as a}from"./query-keys-Ddm69Sh0.js";import{a as r}from"./api-client-CvkWGC57.js";const c=[["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"}]],j=u("file",c);const l=[["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"}]],f=u("folder",l);function m(e){const t={};return e?.page!=null&&(t.page=String(e.page)),e?.limit!=null&&(t.limit=String(e.limit)),i({queryKey:a.projects.list(e),queryFn:()=>r.get("/projects",{params:t})})}function q(e){return i({queryKey:a.projects.detail(e),queryFn:()=>r.get(`/projects/${e}`),enabled:!!e})}function g(){const e=n();return o({mutationFn:t=>r.post("/projects",t),onSuccess:()=>{e.invalidateQueries({queryKey:a.projects.all})}})}function F(){const e=n();return o({mutationFn:({id:t,...s})=>r.put(`/projects/${t}`,s),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:a.projects.all}),e.invalidateQueries({queryKey:a.projects.detail(s.id)})}})}export{f as F,j as a,F as b,q as c,g as d,m as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as p,a as o,q as n}from"./query-keys-
|
|
1
|
+
import{u as p,a as o,q as n}from"./query-keys-Ddm69Sh0.js";import{u}from"./index-DFLmhfiK.js";import{a as i}from"./api-client-CvkWGC57.js";var E;(function(r){r.TODO="TODO",r.IN_PROGRESS="IN_PROGRESS",r.IN_REVIEW="IN_REVIEW",r.DONE="DONE",r.CANCELLED="CANCELLED"})(E||(E={}));var t;(function(r){r.ACTIVE="ACTIVE",r.MERGED="MERGED",r.ABANDONED="ABANDONED"})(t||(t={}));var s;(function(r){r.CLAUDE_CODE="CLAUDE_CODE",r.GEMINI_CLI="GEMINI_CLI",r.CURSOR_AGENT="CURSOR_AGENT",r.CODEX="CODEX"})(s||(s={}));var a;(function(r){r.PENDING="PENDING",r.RUNNING="RUNNING",r.COMPLETED="COMPLETED",r.FAILED="FAILED",r.CANCELLED="CANCELLED"})(a||(a={}));var c;(function(r){r.CHAT="CHAT",r.COMMIT_MSG="COMMIT_MSG"})(c||(c={}));var v;(function(r){r.REBASE="REBASE",r.MERGE="MERGE"})(v||(v={}));function I(){return p({queryKey:n.providers.all,queryFn:()=>i.get("/providers")})}function O(){const r=u();return o({mutationFn:e=>i.post("/providers",e),onSuccess:()=>{r.invalidateQueries({queryKey:n.providers.all})}})}function A(){const r=u();return o({mutationFn:({id:e,data:C})=>i.put(`/providers/${e}`,C),onSuccess:()=>{r.invalidateQueries({queryKey:n.providers.all})}})}function l(){const r=u();return o({mutationFn:e=>i.delete(`/providers/${e}`),onSuccess:()=>{r.invalidateQueries({queryKey:n.providers.all})}})}function R(){return o({mutationFn:()=>i.get("/providers/backup")})}function f(){return o({mutationFn:r=>i.post("/providers/import/preview",r)})}function m(){const r=u();return o({mutationFn:e=>i.post("/providers/import",e),onSuccess:()=>{r.invalidateQueries({queryKey:n.providers.all})}})}export{s as A,v as C,a as S,E as T,O as a,A as b,l as c,R as d,f as e,m as f,I as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o}from"./index-
|
|
1
|
+
import{c as o}from"./index-DFLmhfiK.js";const e=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],s=o("plus",e);const t=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],a=o("x",t);export{s as P,a as X};
|
package/dist/web/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
|
7
7
|
<title>web</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-DFLmhfiK.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-Br9066ZX.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -1,54 +0,0 @@
|
|
|
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};
|