@kb-labs/agent-entry 2.94.0 → 2.96.0
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/commands/diff.js +4 -4
- package/dist/cli/commands/diff.js.map +1 -1
- package/dist/cli/commands/history.js +6 -6
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/quality-report.js +3 -3
- package/dist/cli/commands/quality-report.js.map +1 -1
- package/dist/cli/commands/rollback.js +1 -1
- package/dist/cli/commands/rollback.js.map +1 -1
- package/dist/cli/commands/run.js +24 -7
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/trace-context.js +3 -3
- package/dist/cli/commands/trace-context.js.map +1 -1
- package/dist/cli/commands/trace-diagnose.js +3 -3
- package/dist/cli/commands/trace-diagnose.js.map +1 -1
- package/dist/cli/commands/trace-stats.js +3 -3
- package/dist/cli/commands/trace-stats.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -35
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +62 -7
- package/dist/manifest.js +40 -35
- package/dist/manifest.js.map +1 -1
- package/dist/rest/handlers/approve-handler.js +51 -47
- package/dist/rest/handlers/approve-handler.js.map +1 -1
- package/dist/rest/handlers/approve-session-plan-handler.js +38 -34
- package/dist/rest/handlers/approve-session-plan-handler.js.map +1 -1
- package/dist/rest/handlers/correct-handler.js +49 -45
- package/dist/rest/handlers/correct-handler.js.map +1 -1
- package/dist/rest/handlers/create-session-handler.js +17 -13
- package/dist/rest/handlers/create-session-handler.js.map +1 -1
- package/dist/rest/handlers/execute-session-plan-handler.js +216 -208
- package/dist/rest/handlers/execute-session-plan-handler.js.map +1 -1
- package/dist/rest/handlers/generate-spec-handler.js +103 -98
- package/dist/rest/handlers/generate-spec-handler.js.map +1 -1
- package/dist/rest/handlers/get-file-diff-handler.js +35 -31
- package/dist/rest/handlers/get-file-diff-handler.js.map +1 -1
- package/dist/rest/handlers/get-session-handler.js +15 -11
- package/dist/rest/handlers/get-session-handler.js.map +1 -1
- package/dist/rest/handlers/get-session-plan-handler.js +28 -24
- package/dist/rest/handlers/get-session-plan-handler.js.map +1 -1
- package/dist/rest/handlers/get-session-turns-handler.js +27 -23
- package/dist/rest/handlers/get-session-turns-handler.js.map +1 -1
- package/dist/rest/handlers/get-spec-handler.js +22 -18
- package/dist/rest/handlers/get-spec-handler.js.map +1 -1
- package/dist/rest/handlers/list-file-changes-handler.js +25 -21
- package/dist/rest/handlers/list-file-changes-handler.js.map +1 -1
- package/dist/rest/handlers/list-sessions-handler.js +16 -12
- package/dist/rest/handlers/list-sessions-handler.js.map +1 -1
- package/dist/rest/handlers/rollback-handler.js +73 -69
- package/dist/rest/handlers/rollback-handler.js.map +1 -1
- package/dist/rest/handlers/run-handler.js +151 -147
- package/dist/rest/handlers/run-handler.js.map +1 -1
- package/dist/rest/handlers/sessions-handler.js +47 -35
- package/dist/rest/handlers/sessions-handler.js.map +1 -1
- package/dist/rest/handlers/status-handler.js +33 -29
- package/dist/rest/handlers/status-handler.js.map +1 -1
- package/dist/rest/handlers/stop-handler.js +37 -33
- package/dist/rest/handlers/stop-handler.js.map +1 -1
- package/dist/widgets/117.js +24 -1
- package/dist/widgets/{300.js → 215.js} +1 -1
- package/dist/widgets/370.js +1 -1
- package/dist/widgets/{805.js → 46.js} +92 -92
- package/dist/widgets/50.js +1 -1
- package/dist/widgets/62.js +96 -0
- package/dist/widgets/648.js +1 -0
- package/dist/widgets/669.js +1 -1
- package/dist/widgets/775.js +1 -1
- package/dist/widgets/78.js +1 -0
- package/dist/widgets/968.js +2 -2
- package/dist/widgets/__federation_expose_AgentsPage.js +1 -1
- package/dist/widgets/mf-manifest.json +31 -31
- package/dist/widgets/mf-stats.json +39 -39
- package/dist/widgets/remoteEntry.js +2 -2
- package/dist/ws/session-stream-handler.js +17 -6
- package/dist/ws/session-stream-handler.js.map +1 -1
- package/package.json +15 -14
- package/dist/widgets/418.js +0 -38
- package/dist/widgets/451.js +0 -1
- package/dist/widgets/694.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.rspackChunk_kb_labs_agent_entry=self.rspackChunk_kb_labs_agent_entry||[]).push([[78],{453(t,e,s){let r,i,n,a,u,o,h;s.r(e),s.d(e,{CancelledError:()=>Y,HydrationBoundary:()=>t5,InfiniteQueryObserver:()=>tp,IsRestoringProvider:()=>tA,Mutation:()=>ty,MutationCache:()=>tv,MutationObserver:()=>tg,QueriesObserver:()=>tR,Query:()=>ts,QueryCache:()=>tC,QueryClient:()=>tQ,QueryClientContext:()=>tD,QueryClientProvider:()=>tF,QueryErrorResetBoundary:()=>tK,QueryObserver:()=>ta,dataTagErrorSymbol:()=>tP,dataTagSymbol:()=>tw,defaultScheduler:()=>W,defaultShouldDehydrateMutation:()=>_,defaultShouldDehydrateQuery:()=>G,dehydrate:()=>z,environmentManager:()=>K,experimental_streamedQuery:()=>tS,focusManager:()=>l,hashKey:()=>Q,hydrate:()=>B,infiniteQueryOptions:()=>t3,isCancelledError:()=>Z,isServer:()=>p,keepPreviousData:()=>F,matchMutation:()=>R,matchQuery:()=>O,mutationOptions:()=>t6,noop:()=>y,notifyManager:()=>$,onlineManager:()=>J,partialMatchKey:()=>S,queryOptions:()=>t1,replaceEqualDeep:()=>P,shouldThrowError:()=>U,skipToken:()=>A,timeoutManager:()=>f,unsetMarker:()=>tq,useInfiniteQuery:()=>et,useIsFetching:()=>t2,useIsMutating:()=>t4,useIsRestoring:()=>tx,useMutation:()=>t9,useMutationState:()=>t8,usePrefetchInfiniteQuery:()=>t0,usePrefetchQuery:()=>tZ,useQueries:()=>tW,useQuery:()=>tJ,useQueryClient:()=>tI,useQueryErrorResetBoundary:()=>tj,useSuspenseInfiniteQuery:()=>tX,useSuspenseQueries:()=>tY,useSuspenseQuery:()=>tV});var c=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},l=new class extends c{#t;#e;#s;constructor(){super(),this.#s=t=>{if("u">typeof window&&window.addEventListener){let e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#s=t,this.#e?.(),this.#e=t(t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return"boolean"==typeof this.#t?this.#t:globalThis.document?.visibilityState!=="hidden"}},d={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},f=new class{#r=d;#i=!1;setTimeoutProvider(t){this.#r=t}setTimeout(t,e){return this.#r.setTimeout(t,e)}clearTimeout(t){this.#r.clearTimeout(t)}setInterval(t,e){return this.#r.setInterval(t,e)}clearInterval(t){this.#r.clearInterval(t)}},p="u"<typeof window||"Deno"in globalThis;function y(){}function m(t){return"number"==typeof t&&t>=0&&t!==1/0}function v(t,e){return Math.max(t+(e||0)-Date.now(),0)}function b(t,e){return"function"==typeof t?t(e):t}function g(t,e){return"function"==typeof t?t(e):t}function O(t,e){let{type:s="all",exact:r,fetchStatus:i,predicate:n,queryKey:a,stale:u}=t;if(a){if(r){if(e.queryHash!==C(a,e.options))return!1}else if(!S(e.queryKey,a))return!1}if("all"!==s){let t=e.isActive();if("active"===s&&!t||"inactive"===s&&t)return!1}return("boolean"!=typeof u||e.isStale()===u)&&(!i||i===e.state.fetchStatus)&&(!n||!!n(e))}function R(t,e){let{exact:s,status:r,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(s){if(Q(e.options.mutationKey)!==Q(n))return!1}else if(!S(e.options.mutationKey,n))return!1}return(!r||e.state.status===r)&&(!i||!!i(e))}function C(t,e){return(e?.queryKeyHashFn||Q)(t)}function Q(t){return JSON.stringify(t,(t,e)=>M(e)?Object.keys(e).sort().reduce((t,s)=>(t[s]=e[s],t),{}):e)}function S(t,e){return t===e||typeof t==typeof e&&!!t&&!!e&&"object"==typeof t&&"object"==typeof e&&Object.keys(e).every(s=>S(t[s],e[s]))}var w=Object.prototype.hasOwnProperty;function P(t,e,s=0){if(t===e)return t;if(s>500)return e;let r=E(t)&&E(e);if(!r&&!(M(t)&&M(e)))return e;let i=(r?t:Object.keys(t)).length,n=r?e:Object.keys(e),a=n.length,u=r?Array(a):{},o=0;for(let h=0;h<a;h++){let a=r?h:n[h],c=t[a],l=e[a];if(c===l){u[a]=c,(r?h<i:w.call(t,a))&&o++;continue}if(null===c||null===l||"object"!=typeof c||"object"!=typeof l){u[a]=l;continue}let d=P(c,l,s+1);u[a]=d,d===c&&o++}return i===a&&o===i?t:u}function q(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let s in t)if(t[s]!==e[s])return!1;return!0}function E(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function M(t){if(!D(t))return!1;let e=t.constructor;if(void 0===e)return!0;let s=e.prototype;return!!D(s)&&!!s.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(t)===Object.prototype}function D(t){return"[object Object]"===Object.prototype.toString.call(t)}function I(t,e,s){return"function"==typeof s.structuralSharing?s.structuralSharing(t,e):!1!==s.structuralSharing?P(t,e):e}function F(t){return t}function T(t,e,s=0){let r=[...t,e];return s&&r.length>s?r.slice(1):r}function x(t,e,s=0){let r=[e,...t];return s&&r.length>s?r.slice(0,-1):r}var A=Symbol();function k(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:t.queryFn&&t.queryFn!==A?t.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${t.queryHash}'`))}function U(t,e){return"function"==typeof t?t(...e):!!t}function j(t,e,s){let r,i=!1;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(r??=e(),i||(i=!0,r.aborted?s():r.addEventListener("abort",s,{once:!0})),r)}),t}var K=(r=()=>p,{isServer:()=>r(),setIsServer(t){r=t}});function H(){let t,e,s=new Promise((s,r)=>{t=s,e=r});function r(t){Object.assign(s,t),delete s.resolve,delete s.reject}return s.status="pending",s.catch(()=>{}),s.resolve=e=>{r({status:"fulfilled",value:e}),t(e)},s.reject=t=>{r({status:"rejected",reason:t}),e(t)},s}function L(t){return t}function _(t){return t.state.isPaused}function G(t){return"success"===t.state.status}function N(t){return!0}function z(t,e={}){let s=e.shouldDehydrateMutation??t.getDefaultOptions().dehydrate?.shouldDehydrateMutation??_,r=t.getMutationCache().getAll().flatMap(t=>s(t)?[{mutationKey:t.options.mutationKey,state:t.state,...t.options.scope&&{scope:t.options.scope},...t.meta&&{meta:t.meta}}]:[]),i=e.shouldDehydrateQuery??t.getDefaultOptions().dehydrate?.shouldDehydrateQuery??G,n=e.shouldRedactErrors??t.getDefaultOptions().dehydrate?.shouldRedactErrors??N,a=e.serializeData??t.getDefaultOptions().dehydrate?.serializeData??L;return{mutations:r,queries:t.getQueryCache().getAll().flatMap(t=>{let e;return i(t)?[{dehydratedAt:Date.now(),state:{...t.state,...void 0!==t.state.data&&{data:a(t.state.data)}},queryKey:t.queryKey,queryHash:t.queryHash,..."pending"===t.state.status&&{promise:(e=t.promise?.then(a).catch(t=>n(t)?Promise.reject(Error("redacted")):Promise.reject(t)),e?.catch(y),e)},...t.meta&&{meta:t.meta}}]:[]})}}function B(t,e,s){if("object"!=typeof e||null===e)return;let r=t.getMutationCache(),i=t.getQueryCache(),n=s?.defaultOptions?.deserializeData??t.getDefaultOptions().hydrate?.deserializeData??L,a=e.mutations||[],u=e.queries||[];a.forEach(({state:e,...i})=>{r.build(t,{...t.getDefaultOptions().hydrate?.mutations,...s?.defaultOptions?.mutations,...i},e)}),u.forEach(({queryKey:e,state:r,queryHash:a,meta:u,promise:o,dehydratedAt:h})=>{let c=o?function(t){let e;if(t.then(t=>(e=t,t),y)?.catch(y),void 0!==e)return{data:e}}(o):void 0,l=void 0===r.data?c?.data:r.data,d=void 0===l?l:n(l),f=i.get(a),p=f?.state.status==="pending",m=f?.state.fetchStatus==="fetching";if(f){let t=c&&void 0!==h&&h>f.state.dataUpdatedAt;if(r.dataUpdatedAt>f.state.dataUpdatedAt||t){let{fetchStatus:t,...e}=r;f.setState({...e,data:d})}}else f=i.build(t,{...t.getDefaultOptions().hydrate?.queries,...s?.defaultOptions?.queries,queryKey:e,queryHash:a,meta:u},{...r,data:d,fetchStatus:"idle",status:void 0!==d?"success":r.status});o&&!p&&!m&&(void 0===h||h>f.state.dataUpdatedAt)&&f.fetch(void 0,{initialPromise:Promise.resolve(o).then(n)}).catch(y)})}var W=function(t){setTimeout(t,0)},$=(i=[],n=0,a=t=>{t()},u=t=>{t()},o=W,{batch:t=>{let e;n++;try{e=t()}finally{let t;--n||(t=i,i=[],t.length&&o(()=>{u(()=>{t.forEach(t=>{a(t)})})}))}return e},batchCalls:t=>(...e)=>{h(()=>{t(...e)})},schedule:h=t=>{n?i.push(t):o(()=>{a(t)})},setNotifyFunction:t=>{a=t},setBatchNotifyFunction:t=>{u=t},setScheduler:t=>{o=t}}),J=new class extends c{#n=!0;#e;#s;constructor(){super(),this.#s=t=>{if("u">typeof window&&window.addEventListener){let e=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#s=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#n!==t&&(this.#n=t,this.listeners.forEach(e=>{e(t)}))}isOnline(){return this.#n}};function V(t){return Math.min(1e3*2**t,3e4)}function X(t){return(t??"online")!=="online"||J.isOnline()}var Y=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Z(t){return t instanceof Y}function tt(t){let e,s=!1,r=0,i=H(),n=()=>l.isFocused()&&("always"===t.networkMode||J.isOnline())&&t.canRun(),a=()=>X(t.networkMode)&&t.canRun(),u=t=>{"pending"===i.status&&(e?.(),i.resolve(t))},o=t=>{"pending"===i.status&&(e?.(),i.reject(t))},h=()=>new Promise(s=>{e=t=>{("pending"!==i.status||n())&&s(t)},t.onPause?.()}).then(()=>{e=void 0,"pending"===i.status&&t.onContinue?.()}),c=()=>{let e;if("pending"!==i.status)return;let a=0===r?t.initialPromise:void 0;try{e=a??t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(u).catch(e=>{if("pending"!==i.status)return;let a=t.retry??3*!K.isServer(),u=t.retryDelay??V,l="function"==typeof u?u(r,e):u,d=!0===a||"number"==typeof a&&r<a||"function"==typeof a&&a(r,e);s||!d?o(e):(r++,t.onFail?.(r,e),new Promise(t=>{f.setTimeout(t,l)}).then(()=>n()?void 0:h()).then(()=>{s?o(e):c()}))})};return{promise:i,status:()=>i.status,cancel:e=>{if("pending"===i.status){let s=new Y(e);o(s),t.onCancel?.(s)}},continue:()=>(e?.(),i),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:a,start:()=>(a()?c():h().then(c),i)}}var te=class{#a;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),m(this.gcTime)&&(this.#a=f.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(K.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#a&&(f.clearTimeout(this.#a),this.#a=void 0)}},ts=class extends te{#u;#o;#h;#c;#l;#d;#f;constructor(t){super(),this.#f=!1,this.#d=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#c=t.client,this.#h=this.#c.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#u=tn(this.options),this.state=t.state??this.#u,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#l?.promise}setOptions(t){if(this.options={...this.#d,...t},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let t=tn(this.options);void 0!==t.data&&(this.setState(ti(t.data,t.dataUpdatedAt)),this.#u=t)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#h.remove(this)}setData(t,e){let s=I(this.state.data,t,this.options);return this.#p({data:s,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),s}setState(t,e){this.#p({type:"setState",state:t,setStateOptions:e})}cancel(t){let e=this.#l?.promise;return this.#l?.cancel(t),e?e.then(y).catch(y):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#u}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>!1!==g(t.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===A||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(t=>"static"===b(t.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(t=0){return void 0===this.state.data||"static"!==t&&(!!this.state.isInvalidated||!v(this.state.dataUpdatedAt,t))}onFocus(){let t=this.observers.find(t=>t.shouldFetchOnWindowFocus());t?.refetch({cancelRefetch:!1}),this.#l?.continue()}onOnline(){let t=this.observers.find(t=>t.shouldFetchOnReconnect());t?.refetch({cancelRefetch:!1}),this.#l?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#h.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#l&&(this.#f||this.#y()?this.#l.cancel({revert:!0}):this.#l.cancelRetry()),this.scheduleGc()),this.#h.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#y(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}async fetch(t,e){let s;if("idle"!==this.state.fetchStatus&&this.#l?.status()!=="rejected"){if(void 0!==this.state.data&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#l)return this.#l.continueRetry(),this.#l.promise}if(t&&this.setOptions(t),!this.options.queryFn){let t=this.observers.find(t=>t.options.queryFn);t&&this.setOptions(t.options)}let r=new AbortController,i=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(this.#f=!0,r.signal)})},n=()=>{let t,s=k(this.options,e),r=(i(t={client:this.#c,queryKey:this.queryKey,meta:this.meta}),t);return(this.#f=!1,this.options.persister)?this.options.persister(s,r,this):s(r)},a=(i(s={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#c,state:this.state,fetchFn:n}),s);this.options.behavior?.onFetch(a,this),this.#o=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#p({type:"fetch",meta:a.fetchOptions?.meta}),this.#l=tt({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:t=>{t instanceof Y&&t.revert&&this.setState({...this.#o,fetchStatus:"idle"}),r.abort()},onFail:(t,e)=>{this.#p({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let t=await this.#l.start();if(void 0===t)throw Error(`${this.queryHash} data is undefined`);return this.setData(t),this.#h.config.onSuccess?.(t,this),this.#h.config.onSettled?.(t,this.state.error,this),t}catch(t){if(t instanceof Y){if(t.silent)return this.#l.promise;else if(t.revert){if(void 0===this.state.data)throw t;return this.state.data}}throw this.#p({type:"error",error:t}),this.#h.config.onError?.(t,this),this.#h.config.onSettled?.(this.state.data,t,this),t}finally{this.scheduleGc()}}#p(t){let e=e=>{switch(t.type){case"failed":return{...e,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,...tr(e.data,this.options),fetchMeta:t.meta??null};case"success":let s={...e,...ti(t.data,t.dataUpdatedAt),dataUpdateCount:e.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#o=t.manual?s:void 0,s;case"error":let r=t.error;return{...e,error:r,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}};this.state=e(this.state),$.batch(()=>{this.observers.forEach(t=>{t.onQueryUpdate()}),this.#h.notify({query:this,type:"updated",action:t})})}};function tr(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:X(e.networkMode)?"fetching":"paused",...void 0===t&&{error:null,status:"pending"}}}function ti(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function tn(t){let e="function"==typeof t.initialData?t.initialData():t.initialData,s=void 0!==e,r=s?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var ta=class extends c{constructor(t,e){super(),this.options=e,this.#c=t,this.#m=null,this.#v=H(),this.bindMethods(),this.setOptions(e)}#c;#b=void 0;#g=void 0;#O=void 0;#R;#C;#v;#m;#Q;#S;#w;#P;#q;#E;#M=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#b.addObserver(this),tu(this.#b,this.options)?this.#D():this.updateResult(),this.#I())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return to(this.#b,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return to(this.#b,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#F(),this.#T(),this.#b.removeObserver(this)}setOptions(t){let e=this.options,s=this.#b;if(this.options=this.#c.defaultQueryOptions(t),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof g(this.options.enabled,this.#b))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#b.setOptions(this.options),e._defaulted&&!q(this.options,e)&&this.#c.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#b,observer:this});let r=this.hasListeners();r&&th(this.#b,s,this.options,e)&&this.#D(),this.updateResult(),r&&(this.#b!==s||g(this.options.enabled,this.#b)!==g(e.enabled,this.#b)||b(this.options.staleTime,this.#b)!==b(e.staleTime,this.#b))&&this.#A();let i=this.#k();r&&(this.#b!==s||g(this.options.enabled,this.#b)!==g(e.enabled,this.#b)||i!==this.#E)&&this.#U(i)}getOptimisticResult(t){var e,s;let r=this.#c.getQueryCache().build(this.#c,t),i=this.createResult(r,t);return e=this,s=i,q(e.getCurrentResult(),s)||(this.#O=i,this.#C=this.options,this.#R=this.#b.state),i}getCurrentResult(){return this.#O}trackResult(t,e){return new Proxy(t,{get:(t,s)=>(this.trackProp(s),e?.(s),"promise"===s&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#v.status||this.#v.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(t,s))})}trackProp(t){this.#M.add(t)}getCurrentQuery(){return this.#b}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#c.defaultQueryOptions(t),s=this.#c.getQueryCache().build(this.#c,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#D({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#O))}#D(t){this.#x();let e=this.#b.fetch(this.options,t);return t?.throwOnError||(e=e.catch(y)),e}#A(){this.#F();let t=b(this.options.staleTime,this.#b);if(K.isServer()||this.#O.isStale||!m(t))return;let e=v(this.#O.dataUpdatedAt,t);this.#P=f.setTimeout(()=>{this.#O.isStale||this.updateResult()},e+1)}#k(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#b):this.options.refetchInterval)??!1}#U(t){this.#T(),this.#E=t,!K.isServer()&&!1!==g(this.options.enabled,this.#b)&&m(this.#E)&&0!==this.#E&&(this.#q=f.setInterval(()=>{(this.options.refetchIntervalInBackground||l.isFocused())&&this.#D()},this.#E))}#I(){this.#A(),this.#U(this.#k())}#F(){void 0!==this.#P&&(f.clearTimeout(this.#P),this.#P=void 0)}#T(){void 0!==this.#q&&(f.clearInterval(this.#q),this.#q=void 0)}createResult(t,e){let s,r=this.#b,i=this.options,n=this.#O,a=this.#R,u=this.#C,o=t!==r?t.state:this.#g,{state:h}=t,c={...h},l=!1;if(e._optimisticResults){let s=this.hasListeners(),n=!s&&tu(t,e),a=s&&th(t,r,e,i);(n||a)&&(c={...c,...tr(h.data,t.options)}),"isRestoring"===e._optimisticResults&&(c.fetchStatus="idle")}let{error:d,errorUpdatedAt:f,status:p}=c;s=c.data;let y=!1;if(void 0!==e.placeholderData&&void 0===s&&"pending"===p){let t;n?.isPlaceholderData&&e.placeholderData===u?.placeholderData?(t=n.data,y=!0):t="function"==typeof e.placeholderData?e.placeholderData(this.#w?.state.data,this.#w):e.placeholderData,void 0!==t&&(p="success",s=I(n?.data,t,e),l=!0)}if(e.select&&void 0!==s&&!y)if(n&&s===a?.data&&e.select===this.#Q)s=this.#S;else try{this.#Q=e.select,s=e.select(s),s=I(n?.data,s,e),this.#S=s,this.#m=null}catch(t){this.#m=t}this.#m&&(d=this.#m,s=this.#S,f=Date.now(),p="error");let m="fetching"===c.fetchStatus,v="pending"===p,b="error"===p,O=v&&m,R=void 0!==s,C={status:p,fetchStatus:c.fetchStatus,isPending:v,isSuccess:"success"===p,isError:b,isInitialLoading:O,isLoading:O,data:s,dataUpdatedAt:c.dataUpdatedAt,error:d,errorUpdatedAt:f,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:c.dataUpdateCount>o.dataUpdateCount||c.errorUpdateCount>o.errorUpdateCount,isFetching:m,isRefetching:m&&!v,isLoadingError:b&&!R,isPaused:"paused"===c.fetchStatus,isPlaceholderData:l,isRefetchError:b&&R,isStale:tc(t,e),refetch:this.refetch,promise:this.#v,isEnabled:!1!==g(e.enabled,t)};if(this.options.experimental_prefetchInRender){let e=void 0!==C.data,s="error"===C.status&&!e,i=t=>{s?t.reject(C.error):e&&t.resolve(C.data)},n=()=>{i(this.#v=C.promise=H())},a=this.#v;switch(a.status){case"pending":t.queryHash===r.queryHash&&i(a);break;case"fulfilled":(s||C.data!==a.value)&&n();break;case"rejected":s&&C.error===a.reason||n()}}return C}updateResult(){let t=this.#O,e=this.createResult(this.#b,this.options);if(this.#R=this.#b.state,this.#C=this.options,void 0!==this.#R.data&&(this.#w=this.#b),q(e,t))return;this.#O=e;let s=()=>{if(!t)return!0;let{notifyOnChangeProps:e}=this.options,s="function"==typeof e?e():e;if("all"===s||!s&&!this.#M.size)return!0;let r=new Set(s??this.#M);return this.options.throwOnError&&r.add("error"),Object.keys(this.#O).some(e=>this.#O[e]!==t[e]&&r.has(e))};this.#j({listeners:s()})}#x(){let t=this.#c.getQueryCache().build(this.#c,this.options);if(t===this.#b)return;let e=this.#b;this.#b=t,this.#g=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#I()}#j(t){$.batch(()=>{t.listeners&&this.listeners.forEach(t=>{t(this.#O)}),this.#c.getQueryCache().notify({query:this.#b,type:"observerResultsUpdated"})})}};function tu(t,e){return!1!==g(e.enabled,t)&&void 0===t.state.data&&("error"!==t.state.status||!1!==e.retryOnMount)||void 0!==t.state.data&&to(t,e,e.refetchOnMount)}function to(t,e,s){if(!1!==g(e.enabled,t)&&"static"!==b(e.staleTime,t)){let r="function"==typeof s?s(t):s;return"always"===r||!1!==r&&tc(t,e)}return!1}function th(t,e,s,r){return(t!==e||!1===g(r.enabled,t))&&(!s.suspense||"error"!==t.state.status)&&tc(t,s)}function tc(t,e){return!1!==g(e.enabled,t)&&t.isStaleByTime(b(e.staleTime,t))}function tl(t){return{onFetch:(e,s)=>{let r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],a=e.state.data?.pageParams||[],u={pages:[],pageParams:[]},o=0,h=async()=>{let s=!1,h=k(e.options,e.fetchOptions),c=async(t,r,i)=>{let n;if(s)return Promise.reject();if(null==r&&t.pages.length)return Promise.resolve(t);let a=(j(n={client:e.client,queryKey:e.queryKey,pageParam:r,direction:i?"backward":"forward",meta:e.options.meta},()=>e.signal,()=>s=!0),n),u=await h(a),{maxPages:o}=e.options,c=i?x:T;return{pages:c(t.pages,u,o),pageParams:c(t.pageParams,r,o)}};if(i&&n.length){let t="backward"===i,e={pages:n,pageParams:a},s=(t?tf:td)(r,e);u=await c(e,s,t)}else{let e=t??n.length;do{let t=0===o?a[0]??r.initialPageParam:td(r,u);if(o>0&&null==t)break;u=await c(u,t),o++}while(o<e)}return u};e.options.persister?e.fetchFn=()=>e.options.persister?.(h,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s):e.fetchFn=h}}}function td(t,{pages:e,pageParams:s}){let r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,s[r],s):void 0}function tf(t,{pages:e,pageParams:s}){return e.length>0?t.getPreviousPageParam?.(e[0],e,s[0],s):void 0}var tp=class extends ta{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:tl()})}getOptimisticResult(t){return t.behavior=tl(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){var s,r;let{state:i}=t,n=super.createResult(t,e),{isFetching:a,isRefetching:u,isError:o,isRefetchError:h}=n,c=i.fetchMeta?.fetchMore?.direction,l=o&&"forward"===c,d=a&&"forward"===c,f=o&&"backward"===c,p=a&&"backward"===c;return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:!!(s=i.data)&&null!=td(e,s),hasPreviousPage:!!(r=i.data)&&!!e.getPreviousPageParam&&null!=tf(e,r),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:p,isRefetchError:h&&!l&&!f,isRefetching:u&&!d&&!p}}},ty=class extends te{#c;#K;#H;#l;constructor(t){super(),this.#c=t.client,this.mutationId=t.mutationId,this.#H=t.mutationCache,this.#K=[],this.state=t.state||tm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#K.includes(t)||(this.#K.push(t),this.clearGcTimeout(),this.#H.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#K=this.#K.filter(e=>e!==t),this.scheduleGc(),this.#H.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#K.length||("pending"===this.state.status?this.scheduleGc():this.#H.remove(this))}continue(){return this.#l?.continue()??this.execute(this.state.variables)}async execute(t){let e=()=>{this.#p({type:"continue"})},s={client:this.#c,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#l=tt({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(Error("No mutationFn found")),onFail:(t,e)=>{this.#p({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#p({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#H.canRun(this)});let r="pending"===this.state.status,i=!this.#l.canStart();try{if(r)e();else{this.#p({type:"pending",variables:t,isPaused:i}),this.#H.config.onMutate&&await this.#H.config.onMutate(t,this,s);let e=await this.options.onMutate?.(t,s);e!==this.state.context&&this.#p({type:"pending",context:e,variables:t,isPaused:i})}let n=await this.#l.start();return await this.#H.config.onSuccess?.(n,t,this.state.context,this,s),await this.options.onSuccess?.(n,t,this.state.context,s),await this.#H.config.onSettled?.(n,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(n,null,t,this.state.context,s),this.#p({type:"success",data:n}),n}catch(e){try{await this.#H.config.onError?.(e,t,this.state.context,this,s)}catch(t){Promise.reject(t)}try{await this.options.onError?.(e,t,this.state.context,s)}catch(t){Promise.reject(t)}try{await this.#H.config.onSettled?.(void 0,e,this.state.variables,this.state.context,this,s)}catch(t){Promise.reject(t)}try{await this.options.onSettled?.(void 0,e,t,this.state.context,s)}catch(t){Promise.reject(t)}throw this.#p({type:"error",error:e}),e}finally{this.#H.runNext(this)}}#p(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),$.batch(()=>{this.#K.forEach(e=>{e.onMutationUpdate(t)}),this.#H.notify({mutation:this,type:"updated",action:t})})}};function tm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var tv=class extends c{constructor(t={}){super(),this.config=t,this.#L=new Set,this.#_=new Map,this.#G=0}#L;#_;#G;build(t,e,s){let r=new ty({client:t,mutationCache:this,mutationId:++this.#G,options:t.defaultMutationOptions(e),state:s});return this.add(r),r}add(t){this.#L.add(t);let e=tb(t);if("string"==typeof e){let s=this.#_.get(e);s?s.push(t):this.#_.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#L.delete(t)){let e=tb(t);if("string"==typeof e){let s=this.#_.get(e);if(s)if(s.length>1){let e=s.indexOf(t);-1!==e&&s.splice(e,1)}else s[0]===t&&this.#_.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=tb(t);if("string"!=typeof e)return!0;{let s=this.#_.get(e),r=s?.find(t=>"pending"===t.state.status);return!r||r===t}}runNext(t){let e=tb(t);if("string"!=typeof e)return Promise.resolve();{let s=this.#_.get(e)?.find(e=>e!==t&&e.state.isPaused);return s?.continue()??Promise.resolve()}}clear(){$.batch(()=>{this.#L.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#L.clear(),this.#_.clear()})}getAll(){return Array.from(this.#L)}find(t){let e={exact:!0,...t};return this.getAll().find(t=>R(e,t))}findAll(t={}){return this.getAll().filter(e=>R(t,e))}notify(t){$.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(t=>t.state.isPaused);return $.batch(()=>Promise.all(t.map(t=>t.continue().catch(y))))}};function tb(t){return t.options.scope?.id}var tg=class extends c{#c;#O=void 0;#N;#z;constructor(t,e){super(),this.#c=t,this.setOptions(e),this.bindMethods(),this.#B()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){let e=this.options;this.options=this.#c.defaultMutationOptions(t),q(this.options,e)||this.#c.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#N,observer:this}),e?.mutationKey&&this.options.mutationKey&&Q(e.mutationKey)!==Q(this.options.mutationKey)?this.reset():this.#N?.state.status==="pending"&&this.#N.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#N?.removeObserver(this)}onMutationUpdate(t){this.#B(),this.#j(t)}getCurrentResult(){return this.#O}reset(){this.#N?.removeObserver(this),this.#N=void 0,this.#B(),this.#j()}mutate(t,e){return this.#z=e,this.#N?.removeObserver(this),this.#N=this.#c.getMutationCache().build(this.#c,this.options),this.#N.addObserver(this),this.#N.execute(t)}#B(){let t=this.#N?.state??tm();this.#O={...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset}}#j(t){$.batch(()=>{if(this.#z&&this.hasListeners()){let e=this.#O.variables,s=this.#O.context,r={client:this.#c,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#z.onSuccess?.(t.data,e,s,r)}catch(t){Promise.reject(t)}try{this.#z.onSettled?.(t.data,null,e,s,r)}catch(t){Promise.reject(t)}}else if(t?.type==="error"){try{this.#z.onError?.(t.error,e,s,r)}catch(t){Promise.reject(t)}try{this.#z.onSettled?.(void 0,t.error,e,s,r)}catch(t){Promise.reject(t)}}}this.listeners.forEach(t=>{t(this.#O)})})}};function tO(t,e){let s=new Set(e);return t.filter(t=>!s.has(t))}var tR=class extends c{#c;#W;#$;#J;#K;#V;#X;#Y;#Z;#tt=[];constructor(t,e,s){super(),this.#c=t,this.#J=s,this.#$=[],this.#K=[],this.#W=[],this.setQueries(e)}onSubscribe(){1===this.listeners.size&&this.#K.forEach(t=>{t.subscribe(e=>{this.#te(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#K.forEach(t=>{t.destroy()})}setQueries(t,e){this.#$=t,this.#J=e,$.batch(()=>{let t=this.#K,e=this.#ts(this.#$);e.forEach(t=>t.observer.setOptions(t.defaultedQueryOptions));let s=e.map(t=>t.observer),r=s.map(t=>t.getCurrentResult()),i=t.length!==s.length,n=s.some((e,s)=>e!==t[s]),a=i||n,u=!!a||r.some((t,e)=>{let s=this.#W[e];return!s||!q(t,s)});(a||u)&&(a&&(this.#tt=e,this.#K=s),this.#W=r,this.hasListeners()&&(a&&(tO(t,s).forEach(t=>{t.destroy()}),tO(s,t).forEach(t=>{t.subscribe(e=>{this.#te(t,e)})})),this.#j()))})}getCurrentResult(){return this.#W}getQueries(){return this.#K.map(t=>t.getCurrentQuery())}getObservers(){return this.#K}getOptimisticResult(t,e){let s=this.#ts(t),r=s.map(t=>t.observer.getOptimisticResult(t.defaultedQueryOptions)),i=s.map(t=>t.defaultedQueryOptions.queryHash);return[r,t=>this.#tr(t??r,e,i),()=>this.#ti(r,s)]}#ti(t,e){return e.map((s,r)=>{let i=t[r];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,t=>{e.forEach(e=>{e.observer.trackProp(t)})})})}#tr(t,e,s){if(e){let r=this.#Z,i=void 0!==s&&void 0!==r&&(r.length!==s.length||s.some((t,e)=>t!==r[e]));return(!this.#V||this.#W!==this.#Y||i||e!==this.#X)&&(this.#X=e,this.#Y=this.#W,void 0!==s&&(this.#Z=s),this.#V=P(this.#V,e(t))),this.#V}return t}#ts(t){let e=new Map;this.#K.forEach(t=>{let s=t.options.queryHash;if(!s)return;let r=e.get(s);r?r.push(t):e.set(s,[t])});let s=[];return t.forEach(t=>{let r=this.#c.defaultQueryOptions(t),i=e.get(r.queryHash)?.shift()??new ta(this.#c,r);s.push({defaultedQueryOptions:r,observer:i})}),s}#te(t,e){let s=this.#K.indexOf(t);if(-1!==s){var r;let t;this.#W=(r=this.#W,(t=r.slice(0))[s]=e,t),this.#j()}}#j(){if(this.hasListeners()){let t=this.#V,e=this.#ti(this.#W,this.#tt);t!==this.#tr(e,this.#J?.combine)&&$.batch(()=>{this.listeners.forEach(t=>{t(this.#W)})})}}},tC=class extends c{constructor(t={}){super(),this.config=t,this.#$=new Map}#$;build(t,e,s){let r=e.queryKey,i=e.queryHash??C(r,e),n=this.get(i);return n||(n=new ts({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(n)),n}add(t){this.#$.has(t.queryHash)||(this.#$.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#$.get(t.queryHash);e&&(t.destroy(),e===t&&this.#$.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){$.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#$.get(t)}getAll(){return[...this.#$.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(t=>O(e,t))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(e=>O(t,e)):e}notify(t){$.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){$.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){$.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},tQ=class{#tn;#H;#d;#ta;#tu;#to;#th;#tc;constructor(t={}){this.#tn=t.queryCache||new tC,this.#H=t.mutationCache||new tv,this.#d=t.defaultOptions||{},this.#ta=new Map,this.#tu=new Map,this.#to=0}mount(){this.#to++,1===this.#to&&(this.#th=l.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#tn.onFocus())}),this.#tc=J.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#tn.onOnline())}))}unmount(){this.#to--,0===this.#to&&(this.#th?.(),this.#th=void 0,this.#tc?.(),this.#tc=void 0)}isFetching(t){return this.#tn.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#H.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#tn.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),s=this.#tn.build(this,e),r=s.state.data;return void 0===r?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(b(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#tn.findAll(t).map(({queryKey:t,state:e})=>[t,e.data])}setQueryData(t,e,s){let r=this.defaultQueryOptions({queryKey:t}),i=this.#tn.get(r.queryHash),n=i?.state.data,a="function"==typeof e?e(n):e;if(void 0!==a)return this.#tn.build(this,r).setData(a,{...s,manual:!0})}setQueriesData(t,e,s){return $.batch(()=>this.#tn.findAll(t).map(({queryKey:t})=>[t,this.setQueryData(t,e,s)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#tn.get(e.queryHash)?.state}removeQueries(t){let e=this.#tn;$.batch(()=>{e.findAll(t).forEach(t=>{e.remove(t)})})}resetQueries(t,e){let s=this.#tn;return $.batch(()=>(s.findAll(t).forEach(t=>{t.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let s={revert:!0,...e};return Promise.all($.batch(()=>this.#tn.findAll(t).map(t=>t.cancel(s)))).then(y).catch(y)}invalidateQueries(t,e={}){return $.batch(()=>(this.#tn.findAll(t).forEach(t=>{t.invalidate()}),t?.refetchType==="none")?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e))}refetchQueries(t,e={}){let s={...e,cancelRefetch:e.cancelRefetch??!0};return Promise.all($.batch(()=>this.#tn.findAll(t).filter(t=>!t.isDisabled()&&!t.isStatic()).map(t=>{let e=t.fetch(void 0,s);return s.throwOnError||(e=e.catch(y)),"paused"===t.state.fetchStatus?Promise.resolve():e}))).then(y)}fetchQuery(t){let e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);let s=this.#tn.build(this,e);return s.isStaleByTime(b(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(y).catch(y)}fetchInfiniteQuery(t){return t.behavior=tl(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(y).catch(y)}ensureInfiniteQueryData(t){return t.behavior=tl(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return J.isOnline()?this.#H.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#tn}getMutationCache(){return this.#H}getDefaultOptions(){return this.#d}setDefaultOptions(t){this.#d=t}setQueryDefaults(t,e){this.#ta.set(Q(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#ta.values()],s={};return e.forEach(e=>{S(t,e.queryKey)&&Object.assign(s,e.defaultOptions)}),s}setMutationDefaults(t,e){this.#tu.set(Q(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#tu.values()],s={};return e.forEach(e=>{S(t,e.mutationKey)&&Object.assign(s,e.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#d.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=C(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.throwOnError&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===A&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#d.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#tn.clear(),this.#H.clear()}};function tS({streamFn:t,refetchMode:e="reset",reducer:s=(t,e)=>T(t,e),initialValue:r=[]}){return async i=>{let n=i.client.getQueryCache().find({queryKey:i.queryKey,exact:!0}),a=!!n&&n.isFetched();a&&"reset"===e&&n.setState({...n.resetState,fetchStatus:"fetching"});let u=r,o=!1,h=j({client:i.client,meta:i.meta,queryKey:i.queryKey,pageParam:i.pageParam,direction:i.direction},()=>i.signal,()=>o=!0),c=await t(h),l=a&&"replace"===e;for await(let t of c){if(o)break;l?u=s(u,t):i.client.setQueryData(i.queryKey,e=>s(void 0===e?r:e,t))}return l&&!o&&i.client.setQueryData(i.queryKey,u),i.client.getQueryData(i.queryKey)??r}}var tw=Symbol("dataTagSymbol"),tP=Symbol("dataTagErrorSymbol"),tq=Symbol("unsetMarker"),tE=s(2913),tM=s(4552),tD=tE.createContext(void 0),tI=t=>{let e=tE.useContext(tD);if(t)return t;if(!e)throw Error("No QueryClient set, use QueryClientProvider to set one");return e},tF=({client:t,children:e})=>(tE.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,tM.jsx)(tD.Provider,{value:t,children:e})),tT=tE.createContext(!1),tx=()=>tE.useContext(tT),tA=tT.Provider;function tk(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var tU=tE.createContext(tk()),tj=()=>tE.useContext(tU),tK=({children:t})=>{let[e]=tE.useState(()=>tk());return(0,tM.jsx)(tU.Provider,{value:e,children:"function"==typeof t?t(e):t})},tH=(t,e,s)=>{let r=s?.state.error&&"function"==typeof t.throwOnError?U(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&!e.isReset()&&(t.retryOnMount=!1)},tL=t=>{tE.useEffect(()=>{t.clearReset()},[t])},t_=({result:t,errorResetBoundary:e,throwOnError:s,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&void 0===t.data||U(s,[t.error,r])),tG=(t,e)=>void 0===e.state.data,tN=t=>{if(t.suspense){let e=t=>"static"===t?t:Math.max(t??1e3,1e3),s=t.staleTime;t.staleTime="function"==typeof s?(...t)=>e(s(...t)):e(s),"number"==typeof t.gcTime&&(t.gcTime=Math.max(t.gcTime,1e3))}},tz=(t,e)=>t?.suspense&&e.isPending,tB=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function tW({queries:t,...e},s){let r=tI(s),i=tx(),n=tj(),a=tE.useMemo(()=>t.map(t=>{let e=r.defaultQueryOptions(t);return e._optimisticResults=i?"isRestoring":"optimistic",e}),[t,r,i]);a.forEach(t=>{tN(t);let e=r.getQueryCache().get(t.queryHash);tH(t,n,e)}),tL(n);let[u]=tE.useState(()=>new tR(r,a,e)),[o,h,c]=u.getOptimisticResult(a,e.combine),l=!i&&!1!==e.subscribed;tE.useSyncExternalStore(tE.useCallback(t=>l?u.subscribe($.batchCalls(t)):y,[u,l]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),tE.useEffect(()=>{u.setQueries(a,e)},[a,e,u]);let d=o.some((t,e)=>tz(a[e],t))?o.flatMap((t,e)=>{let s=a[e];if(s&&tz(s,t)){let t=new ta(r,s);return tB(s,t,n)}return[]}):[];if(d.length>0)throw Promise.all(d);let f=o.find((t,e)=>{let s=a[e];return s&&t_({result:t,errorResetBoundary:n,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash),suspense:s.suspense})});if(f?.error)throw f.error;return h(c())}function t$(t,e,s){let r=tx(),i=tj(),n=tI(s),a=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(a);let u=n.getQueryCache().get(a.queryHash);a._optimisticResults=r?"isRestoring":"optimistic",tN(a),tH(a,i,u),tL(i);let o=!n.getQueryCache().get(a.queryHash),[h]=tE.useState(()=>new e(n,a)),c=h.getOptimisticResult(a),l=!r&&!1!==t.subscribed;if(tE.useSyncExternalStore(tE.useCallback(t=>{let e=l?h.subscribe($.batchCalls(t)):y;return h.updateResult(),e},[h,l]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),tE.useEffect(()=>{h.setOptions(a)},[a,h]),tz(a,c))throw tB(a,h,i);if(t_({result:c,errorResetBoundary:i,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw c.error;if(n.getDefaultOptions().queries?._experimental_afterQuery?.(a,c),a.experimental_prefetchInRender&&!K.isServer()&&c.isLoading&&c.isFetching&&!r){let t=o?tB(a,h,i):u?.promise;t?.catch(y).finally(()=>{h.updateResult()})}return a.notifyOnChangeProps?c:h.trackResult(c)}function tJ(t,e){return t$(t,ta,e)}function tV(t,e){return t$({...t,enabled:!0,suspense:!0,throwOnError:tG,placeholderData:void 0},ta,e)}function tX(t,e){return t$({...t,enabled:!0,suspense:!0,throwOnError:tG},tp,e)}function tY(t,e){return tW({...t,queries:t.queries.map(t=>({...t,suspense:!0,throwOnError:tG,enabled:!0,placeholderData:void 0}))},e)}function tZ(t,e){let s=tI(e);s.getQueryState(t.queryKey)||s.prefetchQuery(t)}function t0(t,e){let s=tI(e);s.getQueryState(t.queryKey)||s.prefetchInfiniteQuery(t)}function t1(t){return t}function t3(t){return t}var t5=({children:t,options:e={},state:s,queryClient:r})=>{let i=tI(r),n=tE.useRef(e);tE.useEffect(()=>{n.current=e});let a=tE.useMemo(()=>{if(s){if("object"!=typeof s)return;let t=i.getQueryCache(),e=s.queries||[],r=[],a=[];for(let s of e){let e=t.get(s.queryHash);e?(s.state.dataUpdatedAt>e.state.dataUpdatedAt||s.promise&&"pending"!==e.state.status&&"fetching"!==e.state.fetchStatus&&void 0!==s.dehydratedAt&&s.dehydratedAt>e.state.dataUpdatedAt)&&a.push(s):r.push(s)}if(r.length>0&&B(i,{queries:r},n.current),a.length>0)return a}},[i,s]);return tE.useEffect(()=>{a&&B(i,{queries:a},n.current)},[i,a]),t};function t2(t,e){let s=tI(e),r=s.getQueryCache();return tE.useSyncExternalStore(tE.useCallback(t=>r.subscribe($.batchCalls(t)),[r]),()=>s.isFetching(t),()=>s.isFetching(t))}function t4(t,e){let s=tI(e);return t8({filters:{...t,status:"pending"}},s).length}function t7(t,e){return t.findAll(e.filters).map(t=>e.select?e.select(t):t.state)}function t8(t={},e){let s=tI(e).getMutationCache(),r=tE.useRef(t),i=tE.useRef(null);return null===i.current&&(i.current=t7(s,t)),tE.useEffect(()=>{r.current=t}),tE.useSyncExternalStore(tE.useCallback(t=>s.subscribe(()=>{let e=P(i.current,t7(s,r.current));i.current!==e&&(i.current=e,$.schedule(t))}),[s]),()=>i.current,()=>i.current)}function t9(t,e){let s=tI(e),[r]=tE.useState(()=>new tg(s,t));tE.useEffect(()=>{r.setOptions(t)},[r,t]);let i=tE.useSyncExternalStore(tE.useCallback(t=>r.subscribe($.batchCalls(t)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),n=tE.useCallback((t,e)=>{r.mutate(t,e).catch(y)},[r]);if(i.error&&U(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:n,mutateAsync:i.mutate}}function t6(t){return t}function et(t,e){return t$(t,tp,e)}}}]);
|
package/dist/widgets/968.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(self.rspackChunk_kb_labs_agent_entry=self.rspackChunk_kb_labs_agent_entry||[]).push([[968],{3755(e,r,a){a.r(r)
|
|
1
|
+
"use strict";(self.rspackChunk_kb_labs_agent_entry=self.rspackChunk_kb_labs_agent_entry||[]).push([[968],{3755(e,r,a){a.r(r);var t={primary:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},secondary:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},success:{50:"#f0fdf4",500:"#22c55e",600:"#16a34a",700:"#15803d"},warning:{50:"#fffbeb",500:"#f59e0b",600:"#d97706",700:"#b45309"},error:{50:"#fef2f2",500:"#ef4444",600:"#dc2626",700:"#b91c1c"},neutral:{0:"#ffffff",50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d4d4d4",400:"#9ca3af",500:"#6b7280",600:"#525252",700:"#404040",800:"#27272a",900:"#1a1a1c",950:"#0d0d0f"},muted:{background:"#F3F4F6",foreground:"#6B7280"}},s={0:"0",1:"0.25rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",10:"2.5rem",12:"3rem",16:"4rem"},n={fontFamily:{sans:["Inter","system-ui","-apple-system","sans-serif"],mono:["Fira Code","Courier New","monospace"]},fontSize:{xs:["0.75rem",{lineHeight:"1rem"}],sm:["0.875rem",{lineHeight:"1.25rem"}],base:["1rem",{lineHeight:"1.5rem"}],lg:["1.125rem",{lineHeight:"1.75rem"}],xl:["1.25rem",{lineHeight:"1.75rem"}],"2xl":["1.5rem",{lineHeight:"2rem"}],"3xl":["1.875rem",{lineHeight:"2.25rem"}],"4xl":["2.25rem",{lineHeight:"2.5rem"}]},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"}},i={none:"0",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem",full:"9999px"},o={sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)","2xl":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",none:"none"},f={colors:t,spacing:s,typography:n,radius:i,shadows:o},c={colors:t,spacing:s,typography:n,radius:i,shadows:o},m={"bg-primary":"#F9FAFB","bg-secondary":"#FFFFFF","bg-tertiary":"#F3F4F6","text-primary":"#111827","text-secondary":"#6B7280","text-tertiary":"#6B7280","text-inverse":"#FFFFFF","border-primary":"#E5E7EB","border-secondary":"#D4D4D4",link:"#2563EB","link-hover":"#1E40AF","accent-subtle":"#DBEAFE",success:"#16A34A",warning:"#F59E0B",error:"#DC2626",info:"#0EA5E9",disabled:"#9CA3AF",shadow:"rgba(0, 0, 0, 0.05)"},b={"bg-primary":"#0D0D0F","bg-secondary":"#1A1A1C","bg-tertiary":"#27272A","text-primary":"#F5F5F7","text-secondary":"#A1A1AA","text-tertiary":"#A1A1AA","text-inverse":"#1A1A1C","border-primary":"#3F3F46","border-secondary":"#52525B",link:"#3B82F6","link-hover":"#60A5FA","accent-subtle":"#1E3A8A",success:"#22C55E",warning:"#EAB308",error:"#EF4444",info:"#38BDF8",disabled:"#52525B",shadow:"rgba(0, 0, 0, 0.4)"};function p(e,r){let{colors:a,spacing:t,typography:s,radius:n,shadows:i}=e,o=[];return Object.entries(r).forEach(([e,r])=>{o.push(` --${e}: ${r};`)}),Object.entries(a).forEach(([e,r])=>{"object"==typeof r&&null!==r&&Object.entries(r).forEach(([r,a])=>{o.push(` --color-${e}-${r}: ${a};`)})}),Object.entries(t).forEach(([e,r])=>{o.push(` --spacing-${e}: ${r};`)}),Object.entries(s).forEach(([e,r])=>{"object"==typeof r?Object.entries(r).forEach(([r,a])=>{o.push(` --typography-${e}-${r}: ${a};`)}):o.push(` --typography-${e}: ${r};`)}),Object.entries(n).forEach(([e,r])=>{o.push(` --radius-${e}: ${r};`)}),Object.entries(i).forEach(([e,r])=>{o.push(` --shadow-${e}: ${r};`)}),o.join("\n")}function d(e,r){return`
|
|
2
2
|
:root {
|
|
3
3
|
${p(e,m)}
|
|
4
4
|
}
|
|
@@ -6,4 +6,4 @@ ${p(e,m)}
|
|
|
6
6
|
.dark {
|
|
7
7
|
${p(r,b)}
|
|
8
8
|
}
|
|
9
|
-
`.trim()}}}]);
|
|
9
|
+
`.trim()}a.d(r,{colors:()=>t,darkSemanticColors:()=>b,darkTheme:()=>c,generateCSSVars:()=>p,generateThemeCSS:()=>d,lightSemanticColors:()=>m,lightTheme:()=>f,radius:()=>i,shadows:()=>o,spacing:()=>s,typography:()=>n})}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.rspackChunk_kb_labs_agent_entry=self.rspackChunk_kb_labs_agent_entry||[]).push([[596],{6026(e,t){var n=Symbol.for("react.transitional.element");function r(e,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var l in r={},t)"key"!==l&&(r[l]=t[l]);else r=t;return{$$typeof:n,type:e,key:o,ref:void 0!==(t=r.ref)?t:null,props:r}}t.Fragment=Symbol.for("react.fragment"),t.jsx=r,t.jsxs=r},4552(e,t,n){e.exports=n(6026)},5387(e,t,n){n.r(t),n.d(t,{default:()=>K});var r=n(4552),o=n(2913),l=n.n(o),i=n(6831),s=n(1349),a=n(2383);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],i=!0,s=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);i=!0);}catch(e){s=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(s)throw r}}return l}}(e,t)||f(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||f(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}}function p(e){var t,n=e.currentSessionId,o=e.onSessionChange,l=e.onNewChat,i=(0,s.useUITheme)().token,c=(0,a.useData)("/v1/plugins/agents/sessions?limit=20"),u=c.data,d=c.isLoading,f=null!=(t=null==u?void 0:u.sessions)?t:[],p=function(e){var t=f.find(function(t){return t.id===e});t&&o(e,t)};return(0,r.jsxs)(s.UISpace,{size:"small",style:{width:"100%"},children:[(0,r.jsx)(s.UIIcon,{name:"HistoryOutlined",style:{color:i.colorTextTertiary}}),(0,r.jsx)(s.UISelect,{style:{flex:1,minWidth:200},placeholder:"New chat",value:null!=n?n:void 0,onChange:function(e){return p(e)},loading:d,allowClear:!0,onClear:l,notFoundContent:d?(0,r.jsx)(s.UISpin,{size:"small"}):(0,r.jsx)(s.UITypographyText,{type:"secondary",children:"No sessions yet"}),optionLabelProp:"label",options:f.map(function(e){return{value:e.id,label:e.name||e.task||"Untitled",lastActivityAt:e.lastActivityAt}}),optionRender:function(e){var t,n,o,l,i;return(0,r.jsxs)(s.UISpace,{style:{width:"100%",justifyContent:"space-between"},children:[(0,r.jsx)(s.UITypographyText,{ellipsis:!0,style:{maxWidth:180},children:e.label}),(0,r.jsx)(s.UITypographyText,{type:"secondary",style:{fontSize:11},children:(t=new Date(e.data.lastActivityAt),o=Math.floor((n=new Date().getTime()-t.getTime())/6e4),l=Math.floor(n/36e5),i=Math.floor(n/864e5),o<1?"just now":o<60?"".concat(o,"m ago"):l<24?"".concat(l,"h ago"):i<7?"".concat(i,"d ago"):t.toLocaleDateString())})]})}}),(0,r.jsx)(s.UITooltip,{title:"New Chat",children:(0,r.jsx)(s.UIButton,{variant:"primary",icon:(0,r.jsx)(s.UIIcon,{name:"PlusOutlined"}),onClick:l})})]})}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,l,i){try{var s=e[l](i),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){h(l,r,o,i,s,"next",e)}function s(e){h(l,r,o,i,s,"throw",e)}i(void 0)})}}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function m(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],i=!0,s=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);i=!0);}catch(e){s=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(s)throw r}}return l}}(e,t)||b(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(e,t)}}function S(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(i,"next",{value:a(0)}),s(i,"throw",{value:a(1)}),s(i,"return",{value:a(2)}),"function"==typeof Symbol&&s(i,Symbol.iterator,{value:function(){return this}}),i;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var j=n(296).theme.useToken;function k(e){var t=e.turns,n=e.isLoading,o=e.sessionId,l=j().token;return n?(0,r.jsxs)(s.UIFlex,{justify:"center",align:"center",style:{minHeight:240,gap:8},children:[(0,r.jsx)(s.UISpin,{size:"small"}),(0,r.jsx)(s.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Loading history..."})]}):0===t.length?(0,r.jsx)(s.UIFlex,{justify:"center",align:"center",style:{minHeight:240},children:(0,r.jsx)(s.UITypographyText,{type:"secondary",style:{fontSize:14},children:"Ask anything to get started"})}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",padding:"16px 16px 40px",gap:24},children:t.map(function(e){return(0,r.jsx)(I,{turn:e,sessionId:o,token:l},e.id)})})}function I(e){var t,n,o,l=e.turn,i=e.sessionId,a=e.token;if("user"===l.type){var c=l.steps.find(function(e){return"text"===e.type});return(0,r.jsx)("div",{style:{display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)("span",{style:{maxWidth:"68%",background:a.colorFillTertiary,borderRadius:"".concat(a.borderRadiusLG,"px ").concat(a.borderRadiusLG,"px 3px ").concat(a.borderRadiusLG,"px"),padding:"10px 16px",fontSize:14,lineHeight:1.55,color:a.colorText,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(null==c?void 0:c.type)==="text"?c.content:""})})}var u="streaming"===l.status,d=l.steps.filter(function(e){return"text"===e.type}),f=d.filter(function(e){var t,n;return!D(null!=(t=e.content)?t:"")&&(null==(n=e.content)?void 0:n.trim())}),p=d.some(function(e){var t;return D(null!=(t=e.content)?t:"")}),y=l.steps.find(function(e){return"tool_use"===e.type&&"report"===e.toolName}),h=null==y||null==(t=y.input)?void 0:t.answer,g=l.steps.filter(function(e){return"text"!==e.type&&("tool_use"!==e.type||"report"!==e.toolName)}),x=g.length>0||u||p,m=h||null,v=null==(n=l.metadata)?void 0:n.fileChanges,b=null==(o=l.metadata)?void 0:o.runId,S=!u&&v&&v.length>0&&!!i&&!!b,j={display:"flex",flexDirection:"column",borderLeft:"2px solid ".concat(a.colorBorderSecondary),paddingLeft:12,gap:6,marginLeft:6};return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[x&&(0,r.jsxs)("div",{style:j,children:[g.map(function(e,t){return(0,r.jsx)(C,{step:e,isLast:!1,isStreaming:u&&t===g.length-1&&!m&&0===f.length,token:a},e.id)}),u&&(0===l.steps.length||p)&&(0,r.jsx)(T,{token:a})]}),m&&(0,r.jsx)("div",{style:j,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:a.colorPrimary,pulse:!1}),(0,r.jsx)(s.UIMarkdownViewer,{content:m,style:{flex:1}})]})}),!m&&f.map(function(e){var t;return"text"===e.type&&(null==(t=e.content)?void 0:t.trim())?(0,r.jsx)("div",{style:j,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:a.colorPrimary,pulse:!1}),(0,r.jsx)(s.UIMarkdownViewer,{content:e.content,style:{flex:1}})]})},e.id):null}),S&&(0,r.jsx)("div",{style:j,children:(0,r.jsx)(z,{sessionId:i,runId:b,fileChanges:v,token:a})})]})}function w(e){var t=e.color,n=e.pulse;return(0,r.jsx)("span",{style:{flexShrink:0,width:10,height:10,marginTop:5,borderRadius:"50%",background:t,opacity:n?.7:1,animation:n?"none":void 0}})}function T(e){var t=e.token;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)(w,{color:t.colorTextTertiary,pulse:!0}),(0,r.jsx)(s.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Agent is analyzing and executing steps..."})]})}function C(e){var t,n,o,l=e.step,i=e.isStreaming,a=e.token;switch(l.type){case"thinking":var c,u,d=null!=(c=null==(u=l.content)?void 0:u.trim())?c:"";if(D(d))return null;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:a.colorWarning,pulse:i}),(0,r.jsx)("div",{style:{flex:1},children:(0,r.jsx)(s.UIMarkdownViewer,{content:d,style:{fontSize:13,opacity:.8}})})]});case"tool_use":return(0,r.jsx)(R,{step:l,isStreaming:i,token:a});case"tool_result":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:l.success?a.colorSuccess:a.colorError}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsx)("span",{style:{fontWeight:500,color:a.colorText},children:M(l.toolName)}),void 0!==l.durationMs&&(0,r.jsxs)("span",{style:{marginLeft:6,fontSize:11,color:a.colorTextTertiary},children:[l.durationMs,"ms"]})]}),!l.success&&l.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:l.error})]})]});case"subagent":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:a.colorPrimary}),(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsxs)("span",{style:{fontWeight:500,color:a.colorText},children:["Agent: ",l.agentName]}),(0,r.jsxs)("span",{style:{marginLeft:6},children:[" — ",null==(n=l.task)?void 0:n.slice(0,60),(null!=(t=null==(o=l.task)?void 0:o.length)?t:0)>60?"...":""]})]})]});case"error":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:a.colorError}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:500,color:a.colorError},children:l.code}),(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:l.message})]})]});default:return null}}function R(e){var t,n,o=e.step,i=e.isStreaming,s=e.token,a=v(l().useState(!1),2),c=a[0],u=a[1],d="pending"===o.status,f="done"===o.status,p="error"===o.status,y=f&&!1===o.success,h=function(e){var t=e.input;if(!t)return{};var n=e.toolName.toLowerCase(),r=n.includes("read"),o=n.includes("write")||n.includes("patch")||n.includes("edit"),l=null!=(s=null!=(a=null!=(c=t.path)?c:t.filePath)?a:t.file_path)?s:t.file;if(l){var i=null!=(h=String(l).split("/").pop())?h:String(l);if(r){var s,a,c,u,d,f,p,y,h,g,x,m,v,b,S=null!=(x=null!=(m=t.offset)?m:t.startLine)?x:t.start_line,j=null!=(v=null!=(b=t.limit)?b:t.endLine)?v:t.end_line;void 0!==S&&void 0!==j?g="".concat(S,"-").concat(Number(S)+Number(j)):void 0!==j&&(g="".concat(j," lines"))}return{summary:i,filePath:String(l),badge:g}}var k=null!=(u=null!=(d=null!=(f=t.query)?f:t.text)?d:t.pattern)?u:t.search;if(k)return{summary:String(k).slice(0,100)};var I=null!=(p=t.command)?p:t.cmd;if(I)return{summary:String(I).slice(0,100)};if(o)return{};var w=null!=(y=t.content)?y:t.message;return w?{summary:String(w).slice(0,100)}:{}}(o),g=f&&!!(null==(n=o.metadata)?void 0:n.diff),x=f&&null!=o.output,m=o.input,b=/write|patch|edit/i.test(o.toolName)&&f&&!!(null!=(t=null==m?void 0:m.content)?t:null==m?void 0:m.new_content),S=x||g||b||p,j=d?i?s.colorTextTertiary:s.colorPrimary:f&&!y?s.colorSuccess:s.colorError,k=o.metadata,I=f&&(null==k?void 0:k.uiHint)==="todo"&&null!=k.structured?k.structured.todoList:void 0;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:j,pulse:d&&i}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("button",{onClick:function(){return S&&u(function(e){return!e})},disabled:!S,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:"none",padding:0,cursor:S?"pointer":"default",fontSize:13,color:s.colorText,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontWeight:500},children:M(o.toolName)}),h.badge&&(0,r.jsx)("span",{style:{fontSize:11,color:s.colorTextSecondary,background:s.colorFillSecondary,borderRadius:s.borderRadiusSM,padding:"0 5px"},children:h.badge}),f&&(null==k?void 0:k.resultCount)!==void 0&&(0,r.jsxs)("span",{style:{fontSize:11,color:s.colorTextSecondary,background:s.colorFillSecondary,borderRadius:s.borderRadiusSM,padding:"0 5px"},children:[k.resultCount," results"]}),f&&(null==k?void 0:k.confidence)!==void 0&&(0,r.jsxs)("span",{style:{fontSize:11,color:s.colorTextSecondary,background:s.colorFillSecondary,borderRadius:s.borderRadiusSM,padding:"0 5px"},children:[Math.round(100*k.confidence),"%"]}),f&&(null==k?void 0:k.exitCode)!==void 0&&0!==k.exitCode&&(0,r.jsxs)("span",{style:{fontSize:11,color:s.colorError,background:s.colorErrorBg,borderRadius:s.borderRadiusSM,padding:"0 5px"},children:["exit ",k.exitCode]}),f&&((null==k?void 0:k.linesAdded)!==void 0||(null==k?void 0:k.linesRemoved)!==void 0)&&(0,r.jsxs)("span",{style:{fontSize:11,color:s.colorSuccess,background:s.colorSuccessBg,borderRadius:s.borderRadiusSM,padding:"0 5px"},children:[(null==k?void 0:k.linesAdded)!=null&&k.linesAdded>0?"+".concat(k.linesAdded):"",(null==k?void 0:k.linesRemoved)!=null&&k.linesRemoved>0?" -".concat(k.linesRemoved):""]}),!d&&void 0!==o.durationMs&&(0,r.jsxs)("span",{style:{fontSize:11,color:s.colorTextTertiary},children:[o.durationMs,"ms"]}),S&&(0,r.jsx)("span",{style:{fontSize:11,color:s.colorTextTertiary},children:c?"collapse":"expand"})]}),h.summary&&(0,r.jsx)("p",{style:{margin:"2px 0 0",fontSize:12,color:s.colorTextSecondary},children:h.filePath?(0,r.jsx)(U,{path:h.filePath,label:h.summary,token:s}):h.summary}),null!=I&&(0,r.jsx)(L,{todoList:I,token:s}),p&&o.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:s.colorError},children:o.error}),y&&!c&&null!=o.output&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:s.colorError},children:String(o.output)}),c&&(0,r.jsx)("div",{style:{marginTop:6},children:(0,r.jsx)(A,{step:o,hasDiff:g,hasOutput:x,token:s})})]})]})}function A(e){var t=e.step,n=e.hasDiff,o=e.hasOutput,l=e.token,i=t.input,a=t.toolName.toLowerCase(),c=a.includes("write")||a.includes("patch")||a.includes("edit"),u=a.includes("read"),d=a.includes("bash")||a.includes("exec")||a.includes("shell")||a.includes("run"),f=a.includes("grep")||a.includes("search")||a.includes("glob")||a.includes("list")||a.includes("rag"),p={margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:l.borderRadius,overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"};if(c){if(n)return(0,r.jsx)(O,{diff:t.metadata.diff,token:l});var y=null!=(h=null!=(g=null==i?void 0:i.content)?g:null==i?void 0:i.new_content)?h:null==i?void 0:i.text;if(y){var h,g,v,b,S,j=null!=(v=null!=(b=null!=(S=null==i?void 0:i.path)?S:null==i?void 0:i.filePath)?b:null==i?void 0:i.file_path)?v:null==i?void 0:i.file,k=j?j.split(".").pop():void 0;return(0,r.jsxs)("div",{children:[j&&(0,r.jsx)("div",{style:{fontSize:11,color:l.colorTextTertiary,padding:"3px 8px",background:l.colorFillSecondary,borderRadius:"".concat(l.borderRadius,"px ").concat(l.borderRadius,"px 0 0")},children:j}),(0,r.jsx)("pre",{style:m(x({},p),{background:l.colorFillSecondary,borderRadius:j?"0 0 ".concat(l.borderRadius,"px ").concat(l.borderRadius,"px"):l.borderRadius}),className:k?"lang-".concat(k):void 0,children:String(y)})]})}return null}if(u&&o)return(0,r.jsx)("pre",{style:m(x({},p),{background:l.colorFillSecondary}),children:B(t.output)});if(d&&o)return(0,r.jsx)("pre",{style:m(x({},p),{background:l.colorBgSpotlight,color:l.colorTextLightSolid}),children:B(t.output)});if(f&&o)return(0,r.jsx)("pre",{style:m(x({},p),{background:l.colorFillSecondary}),children:B(t.output)});if(n)return(0,r.jsx)(O,{diff:t.metadata.diff,token:l});if(o){var I="done"===t.status&&!1===t.success,w=B(t.output);return I?(0,r.jsx)("pre",{style:m(x({},p),{background:l.colorErrorBg,color:l.colorError}),children:w}):(0,r.jsx)(s.UIMarkdownViewer,{content:w,style:{fontSize:12}})}return null}function O(e){var t=e.diff,n=e.token,o=t.split("\n");return(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:n.borderRadius,overflow:"auto",maxHeight:300,background:n.colorFillSecondary,whiteSpace:"pre"},children:o.map(function(e,t){var o=e.startsWith("+")&&!e.startsWith("+++")?n.colorSuccess:e.startsWith("-")&&!e.startsWith("---")?n.colorError:e.startsWith("@@")?n.colorInfo:void 0;return(0,r.jsxs)("span",{style:o?{color:o}:void 0,children:[e,"\n"]},t)})})}function U(e){var t=e.path,n=e.label,o=e.token,i=v(l().useState(!1),2),s=i[0],a=i[1];return(0,r.jsxs)("span",{onClick:function(e){e.stopPropagation(),navigator.clipboard.writeText(t).then(function(){a(!0),setTimeout(function(){return a(!1)},1500)})},title:t,style:{cursor:"pointer",color:s?o.colorSuccess:o.colorTextSecondary,fontFamily:"monospace",fontSize:12},children:[n,s?" ✓":""]})}function z(e){var t=e.sessionId,n=e.runId,o=e.fileChanges,i=e.token,c=v(l().useState(new Set),2),u=c[0],d=c[1],f=(0,a.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/rollback"),"POST"),p=(0,a.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/approve"),"POST"),h=o.filter(function(e){return!u.has(e.changeId)&&!e.approved});if(0===h.length)return null;var x=h.every(function(e){return e.approved});return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(w,{color:i.colorSuccess}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[(0,r.jsxs)(s.UITypographyText,{style:{fontSize:13,fontWeight:500},children:[h.length," ",W(h.length)," changed"]}),!x&&(0,r.jsxs)(s.UIFlex,{gap:4,children:[(0,r.jsx)("button",{onClick:function(){return g(function(){return S(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,p.mutateAsync({runId:n})];case 1:return e.sent(),d(new Set(h.map(function(e){return e.changeId}))),[3,3];case 2:return e.sent(),console.error("Failed to approve changes"),[3,3];case 3:return[2]}})})()},disabled:p.isLoading||f.isLoading,title:"Approve all changes",style:{background:i.colorSuccessBg,border:"1px solid ".concat(i.colorSuccessBorder),color:i.colorSuccess,borderRadius:i.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✓"}),(0,r.jsx)("button",{onClick:function(){(0,s.UIModalConfirm)({title:"Rollback changes?",content:"This will revert ".concat(h.length," ").concat(W(h.length)," to the state before the agent run."),okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return g(function(){var e,t;return S(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,f.mutateAsync({runId:n})];case 1:return(null==(e=(t=r.sent()).conflicts)?void 0:e.length)&&console.warn("Rolled back: ".concat(t.rolledBack,", skipped due to conflicts: ").concat(t.skipped)),d(new Set(h.map(function(e){return e.changeId}))),[3,3];case 2:return r.sent(),console.error("Failed to rollback changes"),[3,3];case 3:return[2]}})})()}})},disabled:f.isLoading||p.isLoading,title:"Rollback all changes",style:{background:i.colorErrorBg,border:"1px solid ".concat(i.colorErrorBorder),color:i.colorError,borderRadius:i.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✕"})]})]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:h.map(function(e){return(0,r.jsx)(P,{change:e,sessionId:t,onDismiss:function(){return d(function(t){return new Set(((function(e){if(Array.isArray(e))return y(e)})(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||b(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([e.changeId]))})},token:i},e.changeId)})})]})]})}function P(e){var t,n=e.change,o=e.sessionId,i=e.onDismiss,c=e.token,u=v(l().useState(!1),2),d=u[0],f=u[1],p=(0,a.useMutateData)("/v1/plugins/agents/sessions/".concat(o,"/rollback"),"POST"),y=(0,a.useMutateData)("/v1/plugins/agents/sessions/".concat(o,"/approve"),"POST"),h=d?"/v1/plugins/agents/sessions/".concat(o,"/changes/").concat(encodeURIComponent(n.changeId),"/diff"):"",x=(0,a.useData)(h,{enabled:d}),m=x.data,b=x.isLoading,j=x.isError,k=n.isNew?(0,r.jsx)(s.UITag,{color:"success",children:"new"}):"delete"===n.operation?(0,r.jsx)(s.UITag,{color:"error",children:"del"}):(0,r.jsx)(s.UITag,{color:"blue",children:"mod"});return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{onClick:function(){return f(function(e){return!e})},style:{display:"flex",alignItems:"center",gap:6,fontSize:12,cursor:"pointer",padding:"2px 4px",borderRadius:c.borderRadiusSM,background:d?c.colorFillSecondary:"transparent"},children:[k,(0,r.jsx)("span",{style:{flex:1,fontFamily:"monospace",color:c.colorTextSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:null!=(t=n.filePath.split("/").pop())?t:n.filePath}),(0,r.jsx)("span",{style:{color:c.colorTextTertiary,fontFamily:"monospace",fontSize:11},children:n.filePath.includes("/")?n.filePath.slice(0,n.filePath.lastIndexOf("/")):""}),!n.approved&&(0,r.jsxs)("div",{style:{display:"flex",gap:4},onClick:function(e){return e.stopPropagation()},children:[(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),y.mutateAsync({changeIds:[n.changeId]}).then(i).catch(function(){console.error("Failed to approve file")})},disabled:y.isLoading,title:"Approve",style:{background:"none",border:"none",cursor:"pointer",color:c.colorSuccess,fontSize:13,padding:"0 2px"},children:"✓"}),(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),(0,s.UIModalConfirm)({title:"Rollback file?",content:n.filePath,okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return g(function(){return S(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,p.mutateAsync({changeIds:[n.changeId]})];case 1:return e.sent(),i(),[3,3];case 2:return e.sent(),console.error("Failed to rollback file"),[3,3];case 3:return[2]}})})()}})},disabled:p.isLoading,title:"Rollback",style:{background:"none",border:"none",cursor:"pointer",color:c.colorError,fontSize:13,padding:"0 2px"},children:"✕"})]})]}),d&&(0,r.jsxs)("div",{style:{marginTop:4,marginLeft:4},children:[b&&(0,r.jsx)(s.UISpin,{size:"small"}),(null==m?void 0:m.diff)&&(0,r.jsx)(O,{diff:m.diff,token:c}),j&&(0,r.jsx)("span",{style:{color:c.colorError,fontSize:12},children:"Failed to load diff"})]})]})}var E={completed:"✓","in-progress":"●",blocked:"✕",pending:"○"};function L(e){var t,n=e.todoList,o=e.token;if(!(null==n||null==(t=n.items)?void 0:t.length))return null;var l=n.items.filter(function(e){return"completed"===e.status}).length;return(0,r.jsxs)("div",{style:{marginTop:6,background:o.colorFillTertiary,borderRadius:o.borderRadius,padding:"8px 10px"},children:[(0,r.jsxs)("div",{style:{fontSize:11,color:o.colorTextTertiary,marginBottom:6,fontWeight:500},children:[l,"/",n.items.length]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:n.items.map(function(e){var t;return(0,r.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,lineHeight:1.5,padding:"2px 0"},children:[(0,r.jsx)("span",{style:{fontSize:12,flexShrink:0,width:14,textAlign:"center",lineHeight:1},children:null!=(t=E[e.status])?t:"○"}),"completed"===e.status?(0,r.jsx)(s.UITypographyText,{type:"success",style:{flex:1,minWidth:0,textDecoration:"line-through"},children:e.description}):"pending"===e.status||"blocked"===e.status?(0,r.jsx)(s.UITypographyText,{type:"secondary",style:{flex:1,minWidth:0},children:e.description}):(0,r.jsx)(s.UITypographyText,{style:{flex:1,minWidth:0},children:e.description}),"medium"!==e.priority&&(0,r.jsx)(s.UITypographyText,{type:"secondary",style:{fontSize:11,flexShrink:0},children:e.priority})]},e.id)})})]})}function M(e){var t=e.trim().toLowerCase().replace(/[_-]/g," ");if(t.includes("fs read")||t.includes("read file"))return"Read";if(t.includes("fs write")||t.includes("write file"))return"Write";if(t.includes("fs patch")||t.includes("patch file")||t.includes("fs edit")||t.includes("edit file"))return"Edit";if(t.includes("fs delete")||t.includes("delete file")||t.includes("remove file"))return"Delete";if(t.includes("fs list")||t.includes("list files")||t.includes("glob"))return"Glob";if(t.includes("grep")||t.includes("search content"))return"Grep";if(t.includes("bash")||t.includes("exec")||t.includes("shell")||t.includes("run command"))return"Bash";if(t.includes("rag")||t.includes("mind"))return"Mind";if(t.includes("todo"))return"TodoWrite";var n=e.indexOf(":");return(n>=0?e.slice(n+1):e).replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,function(e){return e.toUpperCase()})}function D(e){var t=e.trim().toLowerCase();return!!("[executing tools...]"===t||"[thinking...]"===t||"[planning...]"===t||"[analyzing...]"===t||"analyzing context and choosing the next step."===t||t.startsWith("checking facts with tool:")||t.startsWith("running step with tool:")||t.startsWith("running the next step"))||"done."===t||"ok."===t||"done"===t||"ok"===t}function W(e){return 1===e?"file":"files"}function B(e){if("string"==typeof e)return e.slice(0,2e3);try{return JSON.stringify(e,null,2).slice(0,2e3)}catch(t){return String(e).slice(0,2e3)}}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function N(e,t,n,r,o,l,i){try{var s=e[l](i),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function _(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){N(l,r,o,i,s,"next",e)}function s(e){N(l,r,o,i,s,"throw",e)}i(void 0)})}}function q(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function H(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],i=!0,s=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);i=!0);}catch(e){s=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(s)throw r}}return l}}(e,t)||$(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(e){return function(e){if(Array.isArray(e))return F(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||$(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){if(e){if("string"==typeof e)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return F(e,t)}}function V(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(i,"next",{value:a(0)}),s(i,"throw",{value:a(1)}),s(i,"return",{value:a(2)}),"function"==typeof Symbol&&s(i,Symbol.iterator,{value:function(){return this}}),i;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function J(e,t){if(e.sequence!==t.sequence)return e.sequence-t.sequence;if(e.type!==t.type){if("user"===e.type)return -1;if("user"===t.type)return 1}return e.startedAt.localeCompare(t.startedAt)}let K=function(){var e,t,n,c,f,y,h,g,x,m,v,b,S,j,I,w,T,C,R,A,O,U,z,P,E,L,M,D,W,B,F,N,$,K,Z=(0,s.useUITheme)().token,Q=l().useRef(null),X=H((0,i.useSearchParams)(),2),Y=X[0],ee=X[1],et=H((0,o.useState)(function(){return Y.get("session")}),2),en=et[0],er=et[1],eo=H((0,o.useState)(function(){return Y.get("session")}),2),el=eo[0],ei=eo[1],es=H((0,o.useState)(""),2),ea=es[0],ec=es[1],eu=H((0,o.useState)(null),2),ed=eu[0],ef=eu[1],ep=H((0,o.useState)("idle"),2),ey=ep[0],eh=ep[1],eg=H((0,o.useState)([]),2),ex=eg[0],em=eg[1],ev=H((0,o.useState)("auto"),2),eb=ev[0],eS=ev[1],ej=H((0,o.useState)("medium"),2),ek=ej[0],eI=ej[1],ew=H((0,o.useState)(!0),2),eT=ew[0],eC=ew[1],eR=H((0,o.useState)("execute"),2),eA=eR[0],eO=eR[1],eU=H((0,o.useState)(!1),2),ez=eU[0],eP=eU[1],eE="mind-assistant",eL=en?(e="https:"===window.location.protocol?"wss:":"ws:",t=window.location.host,"".concat(e,"//").concat(t,"/api/v1/ws/plugins/agents/session/").concat(en)):null,eM=(0,a.useMutateData)("/v1/plugins/agents/run","POST"),eD=(0,a.useMutateData)(ed?"/v1/plugins/agents/run/".concat(ed,"/stop"):"/v1/plugins/agents/run/noop/stop","POST"),eW=en?"/v1/plugins/agents/sessions/".concat(en,"/turns"):"",eB=(0,a.useData)(eW,{enabled:!!en}),eF=eB.data,eN=eB.isFetching,e_=eB.refetch;(0,o.useEffect)(function(){en&&eF&&!eN&&ei(en)},[en,eF,eN]);var eq=(c=(n={url:eL,onComplete:function(e,t){eh(e?"completed":"failed"),e_(),console.log("[AgentsPage] Run completed:",t)},onTurnsChanged:function(){em([])},onError:function(e){console.error("[AgentsPage] WebSocket error:",e),s.UIMessage.error("Connection error: ".concat(e.message))}}).url,y=void 0===(f=n.autoReconnect)||f,g=void 0===(h=n.reconnectDelay)?1e3:h,m=void 0===(x=n.maxReconnectAttempts)?5:x,v=n.onComplete,b=n.onTurnsChanged,S=n.onError,I=(j=u((0,o.useState)("disconnected"),2))[0],w=j[1],C=(T=u((0,o.useState)([]),2))[0],R=T[1],O=(A=u((0,o.useState)(null),2))[0],U=A[1],z=(0,o.useRef)(null),P=(0,o.useRef)(0),E=(0,o.useRef)(null),L=(0,o.useRef)(!1),M=(0,o.useRef)(!1),D=(0,o.useRef)(v),W=(0,o.useRef)(S),B=(0,o.useRef)(b),(0,o.useEffect)(function(){D.current=v},[v]),(0,o.useEffect)(function(){W.current=S},[S]),(0,o.useEffect)(function(){B.current=b},[b]),F=(0,o.useCallback)(function(){null!==E.current&&(clearTimeout(E.current),E.current=null),z.current&&(z.current.onclose=null,z.current.onerror=null,z.current.onmessage=null,z.current.close(),z.current=null)},[]),N=(0,o.useCallback)(function(e){F(),w("connecting"),P.current=0;var t=new WebSocket(e);z.current=t,t.onopen=function(){},t.onmessage=function(e){try{var t=JSON.parse(e.data);switch(t.type){case"conversation:snapshot":var n,r=t.payload,o=r.completedTurns,l=r.activeTurns,i=d(o).concat(d(l)).sort(function(e,t){return e.sequence-t.sequence});M.current=!1,R(function(e){if(0===e.length)return i;var t=new Map,n=!0,r=!1,o=void 0;try{for(var l,s=i[Symbol.iterator]();!(n=(l=s.next()).done);n=!0){var a=l.value;t.set(a.id,a)}}catch(e){r=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}var c=!0,u=!1,f=void 0;try{for(var p,y=e[Symbol.iterator]();!(c=(p=y.next()).done);c=!0){var h=p.value,g=t.get(h.id);g&&"streaming"===h.status&&"streaming"===g.status&&h.steps.length>g.steps.length&&t.set(h.id,h)}}catch(e){u=!0,f=e}finally{try{c||null==y.return||y.return()}finally{if(u)throw f}}return d(t.values()).sort(function(e,t){return e.sequence-t.sequence})}),null==(n=B.current)||n.call(B);break;case"turn:snapshot":var s,a=t.payload.turn;M.current=!1,R(function(e){var t=d(e),n=t.findIndex(function(e){return e.id===a.id});if(n>=0){var r=t[n];if("streaming"===r.status&&"streaming"===a.status&&a.steps.length<r.steps.length)return e;t[n]=a}else{var o=t.findIndex(function(e){return e.sequence>a.sequence});o>=0?t.splice(o,0,a):t.push(a)}return t}),null==(s=B.current)||s.call(B);break;case"connection:ready":P.current=0,w("connected");break;case"run:completed":var c,u=t.payload,f=u.success,p=u.summary;M.current=!0,null==(c=D.current)||c.call(D,f,p);break;case"error":var y,h=t.payload,g=h.code,x=h.message;U({code:g,message:x}),null==(y=W.current)||y.call(W,{code:g,message:x})}}catch(e){console.error("[useAgentWebSocket] Failed to parse message:",e)}},t.onerror=function(){w("error")},t.onclose=function(t){L.current&&!M.current&&y&&P.current<m?(P.current++,w("reconnecting"),E.current=setTimeout(function(){L.current&&N(e)},g*P.current)):w("disconnected")}},[y,F,m,g]),$=(0,o.useCallback)(function(e){var t;(null==(t=z.current)?void 0:t.readyState)===WebSocket.OPEN&&z.current.send(JSON.stringify(e))},[]),K=(0,o.useCallback)(function(){R([]),U(null),M.current=!1},[]),(0,o.useEffect)(function(){return L.current=!1,F(),R([]),U(null),M.current=!1,c?(L.current=!0,N(c)):w("disconnected"),function(){L.current=!1,F()}},[c]),{status:I,isConnected:"connected"===I,turns:C,error:O,send:$,clearTurns:K}),eH=(0,o.useCallback)(function(e,t){er(e),ei(null),ee({session:e},{replace:!0}),ef(null),eh("idle"),em([]),eq.clearTurns()},[eq,ee]),eG=(0,o.useCallback)(function(){er(null),ei(null),ee({},{replace:!0}),ef(null),eh("idle"),em([]),eq.clearTurns()},[eq,ee]),e$=(0,o.useCallback)(function(){return _(function(){var e,t,n,r;return V(this,function(o){switch(o.label){case 0:if(!ea.trim())return[2];e=ea.trim(),ec(""),eh("running"),t={id:"optimistic-user-".concat(Date.now()),type:"user",sequence:9999,startedAt:new Date().toISOString(),completedAt:new Date().toISOString(),status:"completed",steps:[{type:"text",id:"opt-1",timestamp:new Date().toISOString(),content:e,role:"user"}],metadata:{agentId:"user"}},em(function(e){return G(e).concat([t])}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,eM.mutateAsync({task:e,agentId:eE,sessionId:null!=en?en:void 0,tier:ek,enableEscalation:eT,responseMode:eb})];case 2:return n=o.sent(),en||(er(n.sessionId),ei(n.sessionId),ee({session:n.sessionId},{replace:!0})),ef(n.runId),[3,4];case 3:return r=o.sent(),em(function(e){return e.filter(function(e){return e.id!==t.id})}),eh("failed"),s.UIMessage.error("Failed to start: ".concat(q(r,Error)?r.message:String(r))),[3,4];case 4:return[2]}})})()},[ea,eE,en,ek,eT,eb,ee,eM]),eV=(0,o.useCallback)(function(){return _(function(){var e;return V(this,function(t){switch(t.label){case 0:if(!ed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,eD.mutateAsync({reason:"Stopped by user"})];case 2:return t.sent(),eh("stopped"),s.UIMessage.info("Stopped"),[3,4];case 3:return e=t.sent(),s.UIMessage.error("Failed to stop: ".concat(q(e,Error)?e.message:String(e))),[3,4];case 4:return[2]}})})()},[ed,eD]),eJ="running"===ey||eM.isLoading,eK=null!==en&&en!==el,eZ=function(){if(eK)return[];var e=null!=(i=null==eF?void 0:eF.turns)?i:[],t=eq.turns,n=new Map;if(0===t.length){var r=!0,o=!1,l=void 0;try{for(var i,s,a=e[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var c=s.value;n.set(c.id,c)}}catch(e){o=!0,l=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw l}}}else{var u=!0,d=!1,f=void 0;try{for(var p,y=e[Symbol.iterator]();!(u=(p=y.next()).done);u=!0){var h=p.value;n.set(h.id,h)}}catch(e){d=!0,f=e}finally{try{u||null==y.return||y.return()}finally{if(d)throw f}}var g=!0,x=!1,m=void 0;try{for(var v,b=t[Symbol.iterator]();!(g=(v=b.next()).done);g=!0){var S=v.value;n.set(S.id,S)}}catch(e){x=!0,m=e}finally{try{g||null==b.return||b.return()}finally{if(x)throw m}}}var j=new Set(G(n.values()).filter(function(e){return"user"===e.type}).flatMap(function(e){return e.steps.filter(function(e){return"text"===e.type}).map(function(e){var t;return null==(t=e.content)?void 0:t.trim()})}).filter(Boolean)),k=!0,I=!1,w=void 0;try{for(var T,C=ex[Symbol.iterator]();!(k=(T=C.next()).done);k=!0){var R,A,O=T.value,U=null==(A=O.steps.find(function(e){return"text"===e.type}))||null==(R=A.content)?void 0:R.trim();U&&!j.has(U)&&n.set(O.id,O)}}catch(e){I=!0,w=e}finally{try{k||null==C.return||C.return()}finally{if(I)throw w}}return G(n.values()).sort(J)}(),eQ=function(){if(!eJ||eZ.some(function(e){return"assistant"===e.type&&"streaming"===e.status}))return eZ;var e=G(eZ).reverse().find(function(e){return"user"===e.type});if(!e||eZ.some(function(t){return"assistant"===t.type&&"completed"===t.status&&t.sequence>e.sequence}))return eZ;var t={id:"thinking-loader-".concat(e.id),type:"assistant",sequence:e.sequence+.1,startedAt:new Date().toISOString(),completedAt:null,status:"streaming",steps:[],metadata:{agentId:"assistant-loader"}};return G(eZ).concat([t]).sort(J)}(),eX=eK||eN&&0===eZ.length&&!!en;return(0,r.jsx)("div",{style:{padding:16,height:"100%"},children:(0,r.jsxs)(s.UICard,{title:(0,r.jsxs)(s.UISpace,{children:[(0,r.jsx)(s.UIIcon,{name:"RobotOutlined"}),(0,r.jsx)("span",{children:"Agent"})]}),extra:(0,r.jsx)(p,{currentSessionId:en,onSessionChange:eH,onNewChat:eG}),style:{height:"100%",display:"flex",flexDirection:"column"},styles:{body:{flex:1,display:"flex",flexDirection:"column",padding:0,overflow:"hidden"}},children:[(0,r.jsx)("div",{ref:Q,style:{flex:1,overflow:"auto"},children:(0,r.jsx)(k,{turns:eQ,isLoading:eX,sessionId:en})}),(0,r.jsx)("div",{style:{borderTop:"1px solid ".concat(Z.colorBorderSecondary),padding:"12px 16px",background:Z.colorBgContainer,display:"flex",justifyContent:"center"},children:(0,r.jsxs)("div",{onFocus:function(){return eP(!0)},onBlur:function(){return eP(!1)},style:{width:"65%",maxWidth:780,border:"1px solid ".concat(ez?"execute"===eA?Z.colorError:Z.colorPrimary:"plan"===eA?Z.colorPrimary:Z.colorBorder),borderRadius:Z.borderRadiusLG,background:Z.colorBgContainer,boxShadow:ez?"0 0 0 2px ".concat("execute"===eA?Z.colorErrorBg:Z.colorPrimaryBg):"none",transition:"border-color 0.2s, box-shadow 0.2s",overflow:"hidden"},children:[(0,r.jsx)(s.UIInputTextArea,{value:ea,onChange:function(e){return ec(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||"running"===ey||eM.isLoading||(e.preventDefault(),e$())},placeholder:"Message...",autoSize:{minRows:2,maxRows:8},disabled:eJ,variant:"borderless",style:{resize:"none",padding:"10px 12px 4px",border:"none",boxShadow:"none",outline:"none"}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 8px 8px"},children:[(0,r.jsxs)(s.UISpace,{size:6,children:[(0,r.jsx)(s.UISelect,{value:eA,onChange:function(e){return eO(e)},disabled:eJ,size:"small",variant:"borderless",style:{width:110},options:[{value:"execute",label:"Execute"},{value:"plan",label:"Plan"}]}),(0,r.jsx)(s.UISelect,{value:eb,onChange:function(e){return eS(e)},disabled:eJ,size:"small",variant:"borderless",style:{width:80},options:[{value:"auto",label:"Auto"},{value:"brief",label:"Brief"},{value:"deep",label:"Deep"}]}),(0,r.jsx)(s.UISelect,{value:ek,onChange:function(e){return eI(e)},disabled:eJ,size:"small",variant:"borderless",style:{width:100},options:[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}]}),(0,r.jsxs)(s.UISpace,{size:4,align:"center",children:[(0,r.jsx)(s.UISwitch,{checked:eT,onChange:eC,disabled:eJ||"large"===ek,size:"small"}),(0,r.jsx)(s.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Auto escalate"})]})]}),(0,r.jsx)("div",{children:eJ?(0,r.jsx)(s.UIButton,{danger:!0,size:"small",icon:eD.isLoading?(0,r.jsx)(s.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(s.UIIcon,{name:"StopOutlined"}),onClick:eV,disabled:eD.isLoading,children:"Stop"}):(0,r.jsx)(s.UIButton,{variant:"primary",size:"small",icon:eM.isLoading?(0,r.jsx)(s.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(s.UIIcon,{name:"SendOutlined"}),onClick:e$,disabled:!ea.trim()||eM.isLoading,children:"Send"})})]})]})})]})})}}}]);
|
|
1
|
+
"use strict";(self.rspackChunk_kb_labs_agent_entry=self.rspackChunk_kb_labs_agent_entry||[]).push([[596],{6026(e,t){var n=Symbol.for("react.transitional.element");function r(e,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var i in r={},t)"key"!==i&&(r[i]=t[i]);else r=t;return{$$typeof:n,type:e,key:o,ref:void 0!==(t=r.ref)?t:null,props:r}}t.Fragment=Symbol.for("react.fragment"),t.jsx=r,t.jsxs=r},4552(e,t,n){e.exports=n(6026)},5916(e,t,n){n.r(t),n.d(t,{default:()=>$});var r=n(4552),o=n(2913),i=n(6831),l=n(1030),s=n(3218);function a(e){var t,n=e.currentSessionId,o=e.onSessionChange,i=e.onNewChat,a=(0,l.useUITheme)().token,c=(0,s.useData)("/v1/plugins/agents/sessions?limit=20"),u=c.data,d=c.isLoading,p=null!=(t=null==u?void 0:u.sessions)?t:[],f=function(e){var t=p.find(function(t){return t.id===e});t&&o(e,t)};return(0,r.jsxs)(l.UISpace,{size:"small",style:{width:"100%"},children:[(0,r.jsx)(l.UIIcon,{name:"HistoryOutlined",style:{color:a.colorTextTertiary}}),(0,r.jsx)(l.UISelect,{style:{flex:1,minWidth:200},placeholder:"New chat",value:null!=n?n:void 0,onChange:function(e){return f(e)},loading:d,allowClear:!0,onClear:i,notFoundContent:d?(0,r.jsx)(l.UISpin,{size:"small"}):(0,r.jsx)(l.UITypographyText,{type:"secondary",children:"No sessions yet"}),optionLabelProp:"label",options:p.map(function(e){return{value:e.id,label:e.name||e.task||"Untitled",lastActivityAt:e.lastActivityAt}}),optionRender:function(e){var t,n,o,i,s;return(0,r.jsxs)(l.UISpace,{style:{width:"100%",justifyContent:"space-between"},children:[(0,r.jsx)(l.UITypographyText,{ellipsis:!0,style:{maxWidth:180},children:e.label}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:11},children:(t=new Date(e.data.lastActivityAt),o=Math.floor((n=new Date().getTime()-t.getTime())/6e4),i=Math.floor(n/36e5),s=Math.floor(n/864e5),o<1?"just now":o<60?"".concat(o,"m ago"):i<24?"".concat(i,"h ago"):s<7?"".concat(s,"d ago"):t.toLocaleDateString())})]})}}),(0,r.jsx)(l.UITooltip,{title:"New Chat",children:(0,r.jsx)(l.UIButton,{variant:"primary",icon:(0,r.jsx)(l.UIIcon,{name:"PlusOutlined"}),onClick:i})})]})}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t,n,r,o,i,l){try{var s=e[i](l),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){u(i,r,o,l,s,"next",e)}function s(e){u(i,r,o,l,s,"throw",e)}l(void 0)})}}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function f(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,s=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){s=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(s)throw r}}return i}}(e,t)||h(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}}function g(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(l,"next",{value:a(0)}),s(l,"throw",{value:a(1)}),s(l,"return",{value:a(2)}),"function"==typeof Symbol&&s(l,Symbol.iterator,{value:function(){return this}}),l;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var x=n(296).theme.useToken;function m(e){var t=e.turns,n=e.isLoading,o=e.isError,i=e.onRetry,s=e.sessionId,a=x().token;return n?(0,r.jsxs)(l.UIFlex,{justify:"center",align:"center",style:{minHeight:240,gap:8},children:[(0,r.jsx)(l.UISpin,{size:"small"}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Loading history..."})]}):o?(0,r.jsxs)("div",{style:{minHeight:240,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12},children:[(0,r.jsx)(l.UIIcon,{name:"DisconnectOutlined",style:{fontSize:24,color:a.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",children:"Failed to load history"}),i&&(0,r.jsx)(l.UIButton,{size:"small",onClick:i,children:"Retry"})]}):0===t.length?(0,r.jsx)(l.UIFlex,{justify:"center",align:"center",style:{minHeight:240},children:(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:14},children:"Ask anything to get started"})}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",padding:"16px 16px 40px",gap:24},children:t.map(function(e){return(0,r.jsx)(v,{turn:e,sessionId:s,token:a},e.id)})})}function v(e){var t,n,o,i,s,a,c,u,d=e.turn,p=e.sessionId,f=e.token;if("user"===d.type){var y=d.steps.find(function(e){return"text"===e.type});return(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"flex-end",gap:8},children:[(0,r.jsx)("span",{style:{maxWidth:"68%",background:f.colorFillTertiary,borderRadius:"".concat(f.borderRadiusLG,"px ").concat(f.borderRadiusLG,"px 3px ").concat(f.borderRadiusLG,"px"),padding:"10px 16px",fontSize:14,lineHeight:1.55,color:f.colorText,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(null==y?void 0:y.type)==="text"?y.content:""}),(0,r.jsx)("div",{style:{width:28,height:28,borderRadius:"50%",background:f.colorFillSecondary,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(l.UIIcon,{name:"UserOutlined",style:{fontSize:13,color:f.colorTextSecondary}})})]})}var h="streaming"===d.status,g=d.steps.filter(function(e){return"text"===e.type}),x=g.filter(function(e){var t,n;return!P(null!=(t=e.content)?t:"")&&(null==(n=e.content)?void 0:n.trim())}),m=d.steps.find(function(e){return"tool_use"===e.type&&"report"===e.toolName}),v=null==m||null==(a=m.input)?void 0:a.answer,j=d.steps.filter(function(e){return"text"!==e.type&&("tool_use"!==e.type||"report"!==e.toolName)}),I=j.length>0||h&&g.every(function(e){var t;return P(null!=(t=e.content)?t:"")}),k=null!=v?v:null,w=null==(c=d.metadata)?void 0:c.fileChanges,T=null==(u=d.metadata)?void 0:u.runId,U=!h&&w&&w.length>0&&!!p&&!!T,z={display:"flex",flexDirection:"column",borderLeft:"2px solid ".concat(f.colorBorderSecondary),paddingLeft:12,gap:6,marginLeft:6};return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("div",{style:{width:22,height:22,borderRadius:"50%",background:f.colorFillSecondary,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(l.UIIcon,{name:"RobotOutlined",style:{fontSize:12,color:f.colorTextSecondary}})}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Agent"}),(0,r.jsxs)(l.UITypographyText,{type:"secondary",style:{fontSize:11},children:["\xb7 ",(t=new Date(d.startedAt),o=Math.floor((n=new Date().getTime()-t.getTime())/6e4),i=Math.floor(n/36e5),s=Math.floor(n/864e5),o<1?"just now":o<60?"".concat(o,"m ago"):i<24?"".concat(i,"h ago"):s<7?"".concat(s,"d ago"):t.toLocaleDateString())]}),h&&(0,r.jsx)(l.UITag,{color:"processing",style:{fontSize:11,lineHeight:"18px"},children:"Running"}),"failed"===d.status&&(0,r.jsx)(l.UITag,{color:"error",style:{fontSize:11,lineHeight:"18px"},children:"Failed"})]}),I&&(0,r.jsx)("div",{style:z,children:(0,r.jsx)(b,{steps:j,isStreaming:h,token:f})}),k&&(0,r.jsx)("div",{style:z,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:f.colorPrimary}),(0,r.jsx)(l.UIMarkdownViewer,{content:k,style:{flex:1}})]})}),!k&&x.map(function(e){var t;return"text"===e.type&&(null==(t=e.content)?void 0:t.trim())?(0,r.jsx)("div",{style:z,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:f.colorPrimary}),(0,r.jsx)(l.UIMarkdownViewer,{content:e.content,style:{flex:1}})]})},e.id):null}),U&&(0,r.jsx)("div",{style:z,children:(0,r.jsx)(O,{sessionId:p,runId:T,fileChanges:w,token:f})})]})}function b(e){var t=e.steps,n=e.isStreaming,i=e.token,s=y((0,o.useState)(n),2),a=s[0],c=s[1];(0,o.useEffect)(function(){n&&c(!0)},[n]);var u=Object.entries(function(e){var t={},n=!0,r=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){var s=i.value;if("tool_use"===s.type){var a,c=A(s.toolName);t[c]=(null!=(a=t[c])?a:0)+1}}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}return t}(t)).map(function(e){var t=y(e,2),n=t[0],r=t[1];return r>1?"".concat(n," \xd7").concat(r):n}),d=t.reduce(function(e,t){var n;return e+("tool_use"===t.type&&null!=(n=t.durationMs)?n:0)},0),p={display:"inline-flex",alignItems:"center",gap:5,background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontSize:12,color:i.colorTextSecondary,fontFamily:"inherit"};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{style:p,onClick:function(){return c(function(e){return!e})},children:[(0,r.jsx)(l.UIIcon,{name:a?"DownOutlined":"RightOutlined",style:{fontSize:9,color:i.colorTextTertiary}}),n?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:11,color:i.colorTextTertiary}}):null,(0,r.jsxs)("span",{style:{fontWeight:500,color:i.colorText},children:[t.length," ",1===t.length?"action":"actions"]}),!a&&u.length>0&&(0,r.jsxs)("span",{style:{color:i.colorTextTertiary},children:["— ",u.join(" ")]}),!a&&d>0&&(0,r.jsxs)("span",{style:{color:i.colorTextTertiary},children:["\xb7 ",(d/1e3).toFixed(1),"s"]})]}),a&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5,marginTop:4},children:[t.map(function(e,o){return(0,r.jsx)(I,{step:e,isLast:!1,isStreaming:n&&o===t.length-1,token:i},e.id)}),n&&0===t.length&&(0,r.jsx)(j,{token:i})]})]})}function S(e){var t=e.color,n=e.pulse;return(0,r.jsx)("span",{style:{flexShrink:0,width:8,height:8,marginTop:6,borderRadius:"50%",background:t,opacity:n?.6:1}})}function j(e){var t=e.token;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:11,color:t.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Thinking..."})]})}function I(e){var t,n,o,i=e.step,s=e.isStreaming,a=e.token;switch(i.type){case"thinking":var c,u,d=null!=(c=null==(u=i.content)?void 0:u.trim())?c:"";if(P(d))return null;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:a.colorWarning,pulse:s}),(0,r.jsx)("div",{style:{flex:1},children:(0,r.jsx)(l.UIMarkdownViewer,{content:d,style:{fontSize:13,opacity:.8}})})]});case"tool_use":return(0,r.jsx)(k,{step:i,isStreaming:s,token:a});case"tool_result":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:i.success?"CheckCircleOutlined":"CloseCircleOutlined",style:{fontSize:13,marginTop:2,color:i.success?a.colorSuccess:a.colorError}}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsx)("span",{style:{fontWeight:500,color:a.colorText},children:A(i.toolName)}),void 0!==i.durationMs&&(0,r.jsxs)("span",{style:{marginLeft:6,fontSize:11,color:a.colorTextTertiary},children:[i.durationMs,"ms"]})]}),!i.success&&i.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:i.error})]})]});case"subagent":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"RobotOutlined",style:{fontSize:13,marginTop:2,color:a.colorPrimary}}),(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsxs)("span",{style:{fontWeight:500,color:a.colorText},children:["Agent: ",i.agentName]}),(0,r.jsxs)("span",{style:{marginLeft:6},children:["— ",null==(n=i.task)?void 0:n.slice(0,60),(null!=(t=null==(o=i.task)?void 0:o.length)?t:0)>60?"...":""]})]})]});case"error":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"ExclamationCircleOutlined",style:{fontSize:13,marginTop:2,color:a.colorError}}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:500,color:a.colorError},children:i.code}),(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:i.message})]})]});default:return null}}function k(e){var t,n,i,s=e.step,a=e.isStreaming,c=e.token,u=y((0,o.useState)(!1),2),d=u[0],p=u[1],f="pending"===s.status,h="done"===s.status,g="error"===s.status,x=h&&!1===s.success,m=function(e){var t=e.input;if(!t)return{};var n=e.toolName.toLowerCase(),r=n.includes("read"),o=n.includes("write")||n.includes("patch")||n.includes("edit"),i=null!=(s=null!=(a=null!=(c=t.path)?c:t.filePath)?a:t.file_path)?s:t.file;if(i){var l=null!=(h=String(i).split("/").pop())?h:String(i);if(r){var s,a,c,u,d,p,f,y,h,g,x,m,v,b,S=null!=(x=null!=(m=t.offset)?m:t.startLine)?x:t.start_line,j=null!=(v=null!=(b=t.limit)?b:t.endLine)?v:t.end_line;void 0!==S&&void 0!==j?g="".concat(S,"-").concat(Number(S)+Number(j)):void 0!==j&&(g="".concat(j," lines"))}return{summary:l,filePath:String(i),badge:g}}var I=null!=(u=null!=(d=null!=(p=t.query)?p:t.text)?d:t.pattern)?u:t.search;if(I)return{summary:String(I).slice(0,100)};var k=null!=(f=t.command)?f:t.cmd;if(k)return{summary:String(k).slice(0,100)};if(o)return{};var w=null!=(y=t.content)?y:t.message;return w?{summary:String(w).slice(0,100)}:{}}(s),v=h&&!!(null==(i=s.metadata)?void 0:i.diff),b=h&&null!=s.output,S=s.input,j=/write|patch|edit/i.test(s.toolName)&&h&&!!(null!=(n=null==S?void 0:S.content)?n:null==S?void 0:S.new_content),I=b||v||j||g,k=f?a?c.colorTextTertiary:c.colorPrimary:h&&!x?c.colorSuccess:c.colorError,T=s.metadata,O=h&&(null==T?void 0:T.uiHint)==="todo"&&null!=T.structured?T.structured.todoList:void 0;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:f&&a?"LoadingOutlined":(t=s.toolName.toLowerCase(),/read|open/.test(t)?"FileTextOutlined":/write|patch|edit/.test(t)?"EditOutlined":/bash|exec|shell|run/.test(t)?"CodeOutlined":/grep|search|glob|find/.test(t)?"SearchOutlined":/todo/.test(t)?"CheckSquareOutlined":/rag|mind|embed/.test(t)?"BulbOutlined":/agent|subagent/.test(t)?"RobotOutlined":/delete|remove/.test(t)?"DeleteOutlined":"ApiOutlined"),style:{fontSize:13,marginTop:2,color:k,flexShrink:0}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("button",{onClick:function(){return I&&p(function(e){return!e})},disabled:!I,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:"none",padding:0,cursor:I?"pointer":"default",fontSize:13,color:c.colorText,flexWrap:"wrap",fontFamily:"inherit"},children:[(0,r.jsx)("span",{style:{fontWeight:500},children:A(s.toolName)}),m.badge&&(0,r.jsx)("span",{style:{fontSize:11,color:c.colorTextSecondary,background:c.colorFillSecondary,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:m.badge}),h&&(null==T?void 0:T.resultCount)!==void 0&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorTextSecondary,background:c.colorFillSecondary,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:[T.resultCount," results"]}),h&&(null==T?void 0:T.exitCode)!==void 0&&0!==T.exitCode&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorError,background:c.colorErrorBg,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:["exit ",T.exitCode]}),h&&((null==T?void 0:T.linesAdded)!==void 0||(null==T?void 0:T.linesRemoved)!==void 0)&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorSuccess,background:c.colorSuccessBg,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:[(null==T?void 0:T.linesAdded)!=null&&T.linesAdded>0?"+".concat(T.linesAdded):"",(null==T?void 0:T.linesRemoved)!=null&&T.linesRemoved>0?" -".concat(T.linesRemoved):""]}),!f&&void 0!==s.durationMs&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorTextTertiary},children:[s.durationMs,"ms"]}),I&&(0,r.jsx)("span",{style:{fontSize:11,color:c.colorTextTertiary},children:d?"▲":"▼"})]}),m.summary&&(0,r.jsx)("p",{style:{margin:"2px 0 0",fontSize:12,color:c.colorTextSecondary},children:m.filePath?(0,r.jsx)(U,{path:m.filePath,label:m.summary,token:c}):m.summary}),null!=O&&(0,r.jsx)(R,{todoList:O,token:c}),g&&s.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:c.colorError},children:s.error}),x&&!d&&null!=s.output&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:c.colorError},children:String(s.output)}),d&&(0,r.jsx)("div",{style:{marginTop:6},children:(0,r.jsx)(w,{step:s,hasDiff:v,hasOutput:b,token:c})})]})]})}function w(e){var t=e.step,n=e.hasDiff,o=e.hasOutput,i=e.token,s=t.input,a=t.toolName.toLowerCase(),c=a.includes("write")||a.includes("patch")||a.includes("edit"),u=a.includes("read"),d=a.includes("bash")||a.includes("exec")||a.includes("shell")||a.includes("run"),y=a.includes("grep")||a.includes("search")||a.includes("glob")||a.includes("list")||a.includes("rag"),h={margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:i.borderRadius,overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"};if(c){if(n)return(0,r.jsx)(T,{diff:t.metadata.diff,token:i});var g=null!=(x=null!=(m=null==s?void 0:s.content)?m:null==s?void 0:s.new_content)?x:null==s?void 0:s.text;if(g){var x,m,v,b,S,j=null!=(v=null!=(b=null!=(S=null==s?void 0:s.path)?S:null==s?void 0:s.filePath)?b:null==s?void 0:s.file_path)?v:null==s?void 0:s.file,I=j?j.split(".").pop():void 0;return(0,r.jsxs)("div",{children:[j&&(0,r.jsx)("div",{style:{fontSize:11,color:i.colorTextTertiary,padding:"3px 8px",background:i.colorFillSecondary,borderRadius:"".concat(i.borderRadius,"px ").concat(i.borderRadius,"px 0 0")},children:j}),(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary,borderRadius:j?"0 0 ".concat(i.borderRadius,"px ").concat(i.borderRadius,"px"):i.borderRadius}),className:I?"lang-".concat(I):void 0,children:String(g)})]})}return null}if(u&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary}),children:D(t.output)});if(d&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorBgSpotlight,color:i.colorTextLightSolid}),children:D(t.output)});if(y&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary}),children:D(t.output)});if(n)return(0,r.jsx)(T,{diff:t.metadata.diff,token:i});if(o){var k="done"===t.status&&!1===t.success,w=D(t.output);return k?(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorErrorBg,color:i.colorError}),children:w}):(0,r.jsx)(l.UIMarkdownViewer,{content:w,style:{fontSize:12}})}return null}function T(e){var t=e.diff,n=e.token,o=t.split("\n");return(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:n.borderRadius,overflow:"auto",maxHeight:300,background:n.colorFillSecondary,whiteSpace:"pre"},children:o.map(function(e,t){var o=e.startsWith("+")&&!e.startsWith("+++")?n.colorSuccess:e.startsWith("-")&&!e.startsWith("---")?n.colorError:e.startsWith("@@")?n.colorInfo:void 0;return(0,r.jsxs)("span",{style:o?{color:o}:void 0,children:[e,"\n"]},t)})})}function U(e){var t=e.path,n=e.label,i=e.token,l=y((0,o.useState)(!1),2),s=l[0],a=l[1];return(0,r.jsxs)("span",{onClick:function(e){e.stopPropagation(),navigator.clipboard.writeText(t).then(function(){a(!0),setTimeout(function(){return a(!1)},1500)})},title:t,style:{cursor:"pointer",color:s?i.colorSuccess:i.colorTextSecondary,fontFamily:"monospace",fontSize:12},children:[n,s?" ✓":""]})}function O(e){var t=e.sessionId,n=e.runId,i=e.fileChanges,a=e.token,u=y((0,o.useState)(new Set),2),p=u[0],f=u[1],x=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/rollback"),"POST"),m=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/approve"),"POST"),v=i.filter(function(e){return!p.has(e.changeId)&&!e.approved});return 0===v.length?null:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"FileOutlined",style:{fontSize:13,marginTop:2,color:a.colorSuccess}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[(0,r.jsxs)(l.UITypographyText,{style:{fontSize:13,fontWeight:500},children:[v.length," ",L(v.length)," changed"]}),(0,r.jsxs)(l.UIFlex,{gap:4,children:[(0,r.jsx)("button",{onClick:function(){d(function(){return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,m.mutateAsync({runId:n})];case 1:return e.sent(),f(new Set(v.map(function(e){return e.changeId}))),[3,3];case 2:return e.sent(),console.error("Failed to approve changes"),[3,3];case 3:return[2]}})})()},disabled:m.isLoading||x.isLoading,title:"Approve all",style:{background:a.colorSuccessBg,border:"1px solid ".concat(a.colorSuccessBorder),color:a.colorSuccess,borderRadius:a.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✓"}),(0,r.jsx)("button",{onClick:function(){(0,l.UIModalConfirm)({title:"Rollback changes?",content:"This will revert ".concat(v.length," ").concat(L(v.length)," to the state before the agent run."),okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return d(function(){var e,t;return g(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,x.mutateAsync({runId:n})];case 1:return(null==(e=(t=r.sent()).conflicts)?void 0:e.length)&&console.warn("Rolled back: ".concat(t.rolledBack,", skipped: ").concat(t.skipped)),f(new Set(v.map(function(e){return e.changeId}))),[3,3];case 2:return r.sent(),console.error("Failed to rollback changes"),[3,3];case 3:return[2]}})})()}})},disabled:x.isLoading||m.isLoading,title:"Rollback all",style:{background:a.colorErrorBg,border:"1px solid ".concat(a.colorErrorBorder),color:a.colorError,borderRadius:a.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✕"})]})]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:v.map(function(e){return(0,r.jsx)(z,{change:e,sessionId:t,onDismiss:function(){return f(function(t){return new Set(((function(e){if(Array.isArray(e))return c(e)})(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||h(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([e.changeId]))})},token:a},e.changeId)})})]})]})}function z(e){var t,n=e.change,i=e.sessionId,a=e.onDismiss,c=e.token,u=y((0,o.useState)(!1),2),p=u[0],f=u[1],h=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(i,"/rollback"),"POST"),x=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(i,"/approve"),"POST"),m=p?"/v1/plugins/agents/sessions/".concat(i,"/changes/").concat(encodeURIComponent(n.changeId),"/diff"):"",v=(0,s.useData)(m,{enabled:p}),b=v.data,S=v.isLoading,j=v.isError,I=n.isNew?(0,r.jsx)(l.UITag,{color:"success",children:"new"}):"delete"===n.operation?(0,r.jsx)(l.UITag,{color:"error",children:"del"}):(0,r.jsx)(l.UITag,{color:"blue",children:"mod"});return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{onClick:function(){return f(function(e){return!e})},style:{display:"flex",alignItems:"center",gap:6,fontSize:12,cursor:"pointer",padding:"2px 4px",borderRadius:c.borderRadiusSM,background:p?c.colorFillSecondary:"transparent"},children:[I,(0,r.jsx)("span",{style:{flex:1,fontFamily:"monospace",color:c.colorTextSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:null!=(t=n.filePath.split("/").pop())?t:n.filePath}),(0,r.jsx)("span",{style:{color:c.colorTextTertiary,fontFamily:"monospace",fontSize:11},children:n.filePath.includes("/")?n.filePath.slice(0,n.filePath.lastIndexOf("/")):""}),!n.approved&&(0,r.jsxs)("div",{style:{display:"flex",gap:4},onClick:function(e){return e.stopPropagation()},children:[(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),x.mutateAsync({changeIds:[n.changeId]}).then(a).catch(function(){console.error("Failed to approve file")})},disabled:x.isLoading,title:"Approve",style:{background:"none",border:"none",cursor:"pointer",color:c.colorSuccess,fontSize:13,padding:"0 2px"},children:"✓"}),(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),(0,l.UIModalConfirm)({title:"Rollback file?",content:n.filePath,okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return d(function(){return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,h.mutateAsync({changeIds:[n.changeId]})];case 1:return e.sent(),a(),[3,3];case 2:return e.sent(),console.error("Failed to rollback file"),[3,3];case 3:return[2]}})})()}})},disabled:h.isLoading,title:"Rollback",style:{background:"none",border:"none",cursor:"pointer",color:c.colorError,fontSize:13,padding:"0 2px"},children:"✕"})]})]}),p&&(0,r.jsxs)("div",{style:{marginTop:4,marginLeft:4},children:[S&&(0,r.jsx)(l.UISpin,{size:"small"}),(null==b?void 0:b.diff)&&(0,r.jsx)(T,{diff:b.diff,token:c}),j&&(0,r.jsx)("span",{style:{color:c.colorError,fontSize:12},children:"Failed to load diff"})]})]})}var C={completed:"✓","in-progress":"●",blocked:"✕",pending:"○"};function R(e){var t,n=e.todoList,o=e.token;if(!(null==n||null==(t=n.items)?void 0:t.length))return null;var i=n.items.filter(function(e){return"completed"===e.status}).length;return(0,r.jsxs)("div",{style:{marginTop:6,background:o.colorFillTertiary,borderRadius:o.borderRadius,padding:"8px 10px"},children:[(0,r.jsxs)("div",{style:{fontSize:11,color:o.colorTextTertiary,marginBottom:6,fontWeight:500},children:[i,"/",n.items.length]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:n.items.map(function(e){var t;return(0,r.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,lineHeight:1.5,padding:"2px 0"},children:[(0,r.jsx)("span",{style:{fontSize:12,flexShrink:0,width:14,textAlign:"center",lineHeight:1},children:null!=(t=C[e.status])?t:"○"}),"completed"===e.status?(0,r.jsx)(l.UITypographyText,{type:"success",style:{flex:1,minWidth:0,textDecoration:"line-through"},children:e.description}):"pending"===e.status||"blocked"===e.status?(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{flex:1,minWidth:0},children:e.description}):(0,r.jsx)(l.UITypographyText,{style:{flex:1,minWidth:0},children:e.description}),"medium"!==e.priority&&(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:11,flexShrink:0},children:e.priority})]},e.id)})})]})}function A(e){var t=e.trim().toLowerCase().replace(/[_-]/g," ");if(t.includes("fs read")||t.includes("read file"))return"Read";if(t.includes("fs write")||t.includes("write file"))return"Write";if(t.includes("fs patch")||t.includes("patch file")||t.includes("fs edit")||t.includes("edit file"))return"Edit";if(t.includes("fs delete")||t.includes("delete file")||t.includes("remove file"))return"Delete";if(t.includes("fs list")||t.includes("list files")||t.includes("glob"))return"Glob";if(t.includes("grep")||t.includes("search content"))return"Grep";if(t.includes("bash")||t.includes("exec")||t.includes("shell")||t.includes("run command"))return"Bash";if(t.includes("rag")||t.includes("mind"))return"Mind";if(t.includes("todo"))return"TodoWrite";var n=e.indexOf(":");return(n>=0?e.slice(n+1):e).replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,function(e){return e.toUpperCase()})}function P(e){var t=e.trim().toLowerCase();return!!("[executing tools...]"===t||"[thinking...]"===t||"[planning...]"===t||"[analyzing...]"===t||"analyzing context and choosing the next step."===t||t.startsWith("checking facts with tool:")||t.startsWith("running step with tool:")||t.startsWith("running the next step"))||"done."===t||"ok."===t||"done"===t||"ok"===t}function L(e){return 1===e?"file":"files"}function D(e){if("string"==typeof e)return e.slice(0,2e3);try{return JSON.stringify(e,null,2).slice(0,2e3)}catch(t){return String(e).slice(0,2e3)}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t,n,r,o,i,l){try{var s=e[i](l),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function F(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){M(i,r,o,l,s,"next",e)}function s(e){M(i,r,o,l,s,"throw",e)}l(void 0)})}}function B(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,s=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){s=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(s)throw r}}return i}}(e,t)||N(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||N(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){if(e){if("string"==typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return E(e,t)}}function q(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(l,"next",{value:a(0)}),s(l,"throw",{value:a(1)}),s(l,"return",{value:a(2)}),"function"==typeof Symbol&&s(l,Symbol.iterator,{value:function(){return this}}),l;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function H(e,t){if(e.sequence!==t.sequence)return e.sequence-t.sequence;if(e.type!==t.type){if("user"===e.type)return -1;if("user"===t.type)return 1}return e.startedAt.localeCompare(t.startedAt)}function G(e){var t=e.status,n=e.sessionId,o=e.onReconnect,i=(0,l.useUITheme)().token;return n&&"connected"!==t?"connecting"===t?(0,r.jsxs)(l.UISpace,{size:4,children:[(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:12,color:i.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Connecting..."})]}):(0,r.jsxs)(l.UISpace,{size:4,children:[(0,r.jsx)(l.UIIcon,{name:"DisconnectOutlined",style:{fontSize:12,color:i.colorError}}),(0,r.jsx)(l.UIButton,{variant:"link",size:"small",style:{padding:0,fontSize:12,height:"auto"},onClick:o,children:"Reconnect"})]}):null}let $=function(){var e,t,n=(0,l.useUITheme)().token,c=(0,o.useRef)(null),u=W((0,i.useSearchParams)(),2),d=u[0],p=u[1],f=W((0,o.useState)(function(){return d.get("session")}),2),y=f[0],h=f[1],g=W((0,o.useState)(function(){return d.get("session")}),2),x=g[0],v=g[1],b=W((0,o.useState)(""),2),S=b[0],j=b[1],I=W((0,o.useState)(null),2),k=I[0],w=I[1],T=W((0,o.useState)("idle"),2),U=T[0],O=T[1],z=W((0,o.useState)([]),2),C=z[0],R=z[1],A=W((0,o.useState)([]),2),P=A[0],L=A[1],D=W((0,o.useState)("auto"),2),E=D[0],M=D[1],N=W((0,o.useState)("medium"),2),$=N[0],V=N[1],K=W((0,o.useState)(!0),2),J=K[0],Z=K[1],Q=W((0,o.useState)("execute"),2),X=Q[0],Y=Q[1],ee=W((0,o.useState)(!1),2),et=ee[0],en=ee[1],er="mind-assistant",eo=y?(e="https:"===window.location.protocol?"wss:":"ws:",t=window.location.host,"".concat(e,"//").concat(t,"/api/v1/ws/plugins/agents/session/").concat(y)):null,ei=(0,s.useMutateData)("/v1/plugins/agents/run","POST"),el=(0,s.useMutateData)(k?"/v1/plugins/agents/run/".concat(k,"/stop"):"/v1/plugins/agents/run/noop/stop","POST"),es=y?"/v1/plugins/agents/sessions/".concat(y,"/turns"):"",ea=(0,s.useData)(es,{enabled:!!y}),ec=ea.data,eu=ea.isFetching,ed=ea.isError,ep=ea.refetch;(0,o.useEffect)(function(){y&&(ec||ed)&&!eu&&v(y)},[y,ec,ed,eu]);var ef=(0,s.useWebSocket)(eo,{reconnect:!0,maxReconnects:10,reconnectIntervalMs:2e3,onMessage:function(e){switch(e.type){case"conversation:snapshot":L(_(e.payload.completedTurns).concat(_(e.payload.activeTurns)).sort(function(e,t){return e.sequence-t.sequence})),R([]);break;case"turn:snapshot":var t=e.payload.turn;L(function(e){var n=e.findIndex(function(e){return e.id===t.id});if(n>=0){var r=_(e);return r[n]=t,r}return _(e).concat([t]).sort(function(e,t){return e.sequence-t.sequence})});break;case"run:completed":var n=e.payload,r=n.success,o=n.summary;O(r?"completed":"failed"),R([]),ep(),console.log("[AgentsPage] Run completed:",o);break;case"error":var i=e.payload,s=i.code,a=i.message;l.UIMessage.error("Agent error [".concat(s,"]: ").concat(a))}}});(0,o.useEffect)(function(){var e=c.current;e&&(e.scrollTop=e.scrollHeight)},[P.length,C.length]);var ey=(0,o.useCallback)(function(e,t){h(e),v(null),p({session:e},{replace:!0}),w(null),O("idle"),R([]),L([]),ef.clear()},[ef,p]),eh=(0,o.useCallback)(function(){h(null),v(null),p({},{replace:!0}),w(null),O("idle"),R([]),L([]),ef.clear()},[ef,p]),eg=(0,o.useCallback)(function(){return F(function(){var e,t,n,r;return q(this,function(o){switch(o.label){case 0:if(!S.trim())return[2];e=S.trim(),j(""),O("running"),t={id:"optimistic-user-".concat(Date.now()),type:"user",sequence:9999,startedAt:new Date().toISOString(),completedAt:new Date().toISOString(),status:"completed",steps:[{type:"text",id:"opt-1",timestamp:new Date().toISOString(),content:e,role:"user"}],metadata:{agentId:"user"}},R(function(e){return _(e).concat([t])}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,ei.mutateAsync({task:e,agentId:er,sessionId:null!=y?y:void 0,tier:$,enableEscalation:J,responseMode:E,mode:X})];case 2:return n=o.sent(),y||(h(n.sessionId),v(n.sessionId),p({session:n.sessionId},{replace:!0})),w(n.runId),ef.isConnected&&setTimeout(function(){return R([])},500),[3,4];case 3:return r=o.sent(),R(function(e){return e.filter(function(e){return e.id!==t.id})}),O("failed"),l.UIMessage.error("Failed to start: ".concat(B(r,Error)?r.message:String(r))),[3,4];case 4:return[2]}})})()},[S,er,y,$,J,E,X,p,ei,ef]),ex=(0,o.useCallback)(function(){return F(function(){var e;return q(this,function(t){switch(t.label){case 0:if(!k)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,el.mutateAsync({reason:"Stopped by user"})];case 2:return t.sent(),O("stopped"),l.UIMessage.info("Stopped"),[3,4];case 3:return e=t.sent(),l.UIMessage.error("Failed to stop: ".concat(B(e,Error)?e.message:String(e))),[3,4];case 4:return[2]}})})()},[k,el]),em="running"===U||ei.isLoading,ev=null!==y&&y!==x,eb=function(){if(ev)return[];var e=null!=(i=null==ec?void 0:ec.turns)?i:[],t=new Map;if(0===P.length){var n=!0,r=!1,o=void 0;try{for(var i,l,s=e[Symbol.iterator]();!(n=(l=s.next()).done);n=!0){var a=l.value;t.set(a.id,a)}}catch(e){r=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}}else{var c=!0,u=!1,d=void 0;try{for(var p,f=e[Symbol.iterator]();!(c=(p=f.next()).done);c=!0){var y=p.value;t.set(y.id,y)}}catch(e){u=!0,d=e}finally{try{c||null==f.return||f.return()}finally{if(u)throw d}}var h=!0,g=!1,x=void 0;try{for(var m,v=P[Symbol.iterator]();!(h=(m=v.next()).done);h=!0){var b=m.value;t.set(b.id,b)}}catch(e){g=!0,x=e}finally{try{h||null==v.return||v.return()}finally{if(g)throw x}}}var S=new Set(_(t.values()).filter(function(e){return"user"===e.type}).flatMap(function(e){return e.steps.filter(function(e){return"text"===e.type}).map(function(e){var t;return null==(t=e.content)?void 0:t.trim()})}).filter(Boolean)),j=!0,I=!1,k=void 0;try{for(var w,T=C[Symbol.iterator]();!(j=(w=T.next()).done);j=!0){var U,O,z=w.value,R=null==(O=z.steps.find(function(e){return"text"===e.type}))||null==(U=O.content)?void 0:U.trim();R&&!S.has(R)&&t.set(z.id,z)}}catch(e){I=!0,k=e}finally{try{j||null==T.return||T.return()}finally{if(I)throw k}}return _(t.values()).sort(H)}(),eS=function(){if(!em||eb.some(function(e){return"assistant"===e.type&&"streaming"===e.status}))return eb;var e=_(eb).reverse().find(function(e){return"user"===e.type});if(!e||eb.some(function(t){return"assistant"===t.type&&"completed"===t.status&&t.sequence>e.sequence}))return eb;var t={id:"thinking-loader-".concat(e.id),type:"assistant",sequence:e.sequence+.1,startedAt:new Date().toISOString(),completedAt:null,status:"streaming",steps:[],metadata:{agentId:"assistant-loader"}};return _(eb).concat([t]).sort(H)}(),ej=ev||eu&&0===eb.length&&!!y;return(0,r.jsx)("div",{style:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:(0,r.jsxs)(l.UICard,{title:(0,r.jsxs)(l.UISpace,{children:[(0,r.jsx)(l.UIIcon,{name:"RobotOutlined"}),(0,r.jsx)("span",{children:"Agent"})]}),extra:(0,r.jsx)(a,{currentSessionId:y,onSessionChange:ey,onNewChat:eh}),style:{height:"100%",display:"flex",flexDirection:"column"},styles:{body:{flex:1,display:"flex",flexDirection:"column",padding:0,overflow:"hidden"}},children:[(0,r.jsx)("div",{ref:c,style:{flex:1,overflow:"auto"},children:(0,r.jsx)(m,{turns:eS,isLoading:ej,isError:ed,onRetry:function(){ep()},sessionId:y})}),(0,r.jsx)("div",{style:{borderTop:"1px solid ".concat(n.colorBorderSecondary),padding:"12px 16px",background:n.colorBgContainer},children:(0,r.jsxs)("div",{onFocus:function(){return en(!0)},onBlur:function(){return en(!1)},style:{border:"1px solid ".concat(et?"execute"===X?n.colorError:n.colorPrimary:"plan"===X?n.colorPrimary:n.colorBorder),borderRadius:n.borderRadiusLG,background:n.colorBgContainer,boxShadow:et?"0 0 0 2px ".concat("execute"===X?n.colorErrorBg:n.colorPrimaryBg):"none",transition:"border-color 0.2s, box-shadow 0.2s",overflow:"hidden"},children:[(0,r.jsx)(l.UIInputTextArea,{value:S,onChange:function(e){return j(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||"running"===U||ei.isLoading||(e.preventDefault(),eg())},placeholder:"Message...",autoSize:{minRows:2,maxRows:8},disabled:em,variant:"borderless",style:{resize:"none",padding:"10px 12px 4px",border:"none",boxShadow:"none",outline:"none"}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 8px 8px"},children:[(0,r.jsxs)(l.UISpace,{size:6,children:[(0,r.jsx)(G,{status:ef.status,sessionId:y,onReconnect:function(){return ef.connect()}}),(0,r.jsx)(l.UISelect,{value:X,onChange:function(e){return Y(e)},disabled:em,size:"small",variant:"borderless",style:{width:110},options:[{value:"execute",label:"Execute"},{value:"plan",label:"Plan"}]}),(0,r.jsx)(l.UISelect,{value:E,onChange:function(e){return M(e)},disabled:em,size:"small",variant:"borderless",style:{width:80},options:[{value:"auto",label:"Auto"},{value:"brief",label:"Brief"},{value:"deep",label:"Deep"}]}),(0,r.jsx)(l.UISelect,{value:$,onChange:function(e){return V(e)},disabled:em,size:"small",variant:"borderless",style:{width:100},options:[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}]}),(0,r.jsxs)(l.UISpace,{size:4,align:"center",children:[(0,r.jsx)(l.UISwitch,{checked:J,onChange:Z,disabled:em||"large"===$,size:"small"}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Auto escalate"})]})]}),(0,r.jsx)("div",{children:em?(0,r.jsx)(l.UIButton,{danger:!0,size:"small",icon:el.isLoading?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(l.UIIcon,{name:"StopOutlined"}),onClick:ex,disabled:el.isLoading,children:"Stop"}):(0,r.jsx)(l.UIButton,{variant:"primary",size:"small",icon:ei.isLoading?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(l.UIIcon,{name:"SendOutlined"}),onClick:eg,disabled:!S.trim()||ei.isLoading,children:"Send"})})]})]})})]})})}}}]);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "agentPlugin",
|
|
6
6
|
"globalName": "agentPlugin",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "2.
|
|
8
|
+
"buildVersion": "2.94.0",
|
|
9
9
|
"buildName": "@kb-labs/agent-entry"
|
|
10
10
|
},
|
|
11
11
|
"publicPath": "auto",
|
|
@@ -25,16 +25,15 @@
|
|
|
25
25
|
},
|
|
26
26
|
"shared": [
|
|
27
27
|
{
|
|
28
|
-
"id": "agentPlugin
|
|
29
|
-
"name": "
|
|
30
|
-
"version": "
|
|
28
|
+
"id": "agentPlugin:react-router-dom",
|
|
29
|
+
"name": "react-router-dom",
|
|
30
|
+
"version": "7.14.0",
|
|
31
31
|
"singleton": true,
|
|
32
|
-
"requiredVersion": "^0.
|
|
32
|
+
"requiredVersion": "^7.0.0",
|
|
33
33
|
"assets": {
|
|
34
34
|
"js": {
|
|
35
35
|
"sync": [
|
|
36
|
-
"
|
|
37
|
-
"669.js"
|
|
36
|
+
"215.js"
|
|
38
37
|
],
|
|
39
38
|
"async": []
|
|
40
39
|
},
|
|
@@ -47,9 +46,9 @@
|
|
|
47
46
|
{
|
|
48
47
|
"id": "agentPlugin:@kb-labs/studio-ui-core",
|
|
49
48
|
"name": "@kb-labs/studio-ui-core",
|
|
50
|
-
"version": "2.
|
|
49
|
+
"version": "2.94.0",
|
|
51
50
|
"singleton": true,
|
|
52
|
-
"requiredVersion": "^0.
|
|
51
|
+
"requiredVersion": "^2.0.0",
|
|
53
52
|
"assets": {
|
|
54
53
|
"js": {
|
|
55
54
|
"sync": [
|
|
@@ -72,8 +71,8 @@
|
|
|
72
71
|
"assets": {
|
|
73
72
|
"js": {
|
|
74
73
|
"sync": [
|
|
75
|
-
"
|
|
76
|
-
"
|
|
74
|
+
"46.js",
|
|
75
|
+
"648.js"
|
|
77
76
|
],
|
|
78
77
|
"async": []
|
|
79
78
|
},
|
|
@@ -86,9 +85,9 @@
|
|
|
86
85
|
{
|
|
87
86
|
"id": "agentPlugin:@kb-labs/studio-hooks",
|
|
88
87
|
"name": "@kb-labs/studio-hooks",
|
|
89
|
-
"version": "2.
|
|
88
|
+
"version": "2.94.0",
|
|
90
89
|
"singleton": true,
|
|
91
|
-
"requiredVersion": "^0.
|
|
90
|
+
"requiredVersion": "^2.0.0",
|
|
92
91
|
"assets": {
|
|
93
92
|
"js": {
|
|
94
93
|
"sync": [
|
|
@@ -106,16 +105,16 @@
|
|
|
106
105
|
{
|
|
107
106
|
"id": "agentPlugin:@kb-labs/studio-ui-kit",
|
|
108
107
|
"name": "@kb-labs/studio-ui-kit",
|
|
109
|
-
"version": "2.
|
|
108
|
+
"version": "2.94.0",
|
|
110
109
|
"singleton": true,
|
|
111
|
-
"requiredVersion": "^0.
|
|
110
|
+
"requiredVersion": "^2.0.0",
|
|
112
111
|
"assets": {
|
|
113
112
|
"js": {
|
|
114
113
|
"sync": [
|
|
115
114
|
"117.js",
|
|
116
115
|
"326.js",
|
|
117
|
-
"
|
|
118
|
-
"
|
|
116
|
+
"62.js",
|
|
117
|
+
"648.js"
|
|
119
118
|
],
|
|
120
119
|
"async": []
|
|
121
120
|
},
|
|
@@ -126,15 +125,16 @@
|
|
|
126
125
|
}
|
|
127
126
|
},
|
|
128
127
|
{
|
|
129
|
-
"id": "agentPlugin:react",
|
|
130
|
-
"name": "react",
|
|
128
|
+
"id": "agentPlugin:react-dom",
|
|
129
|
+
"name": "react-dom",
|
|
131
130
|
"version": "19.2.5",
|
|
132
131
|
"singleton": true,
|
|
133
132
|
"requiredVersion": "^19.0.0",
|
|
134
133
|
"assets": {
|
|
135
134
|
"js": {
|
|
136
135
|
"sync": [
|
|
137
|
-
"
|
|
136
|
+
"165.js",
|
|
137
|
+
"546.js"
|
|
138
138
|
],
|
|
139
139
|
"async": []
|
|
140
140
|
},
|
|
@@ -145,16 +145,15 @@
|
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
|
-
"id": "agentPlugin:react
|
|
149
|
-
"name": "react
|
|
148
|
+
"id": "agentPlugin:react",
|
|
149
|
+
"name": "react",
|
|
150
150
|
"version": "19.2.5",
|
|
151
151
|
"singleton": true,
|
|
152
152
|
"requiredVersion": "^19.0.0",
|
|
153
153
|
"assets": {
|
|
154
154
|
"js": {
|
|
155
155
|
"sync": [
|
|
156
|
-
"
|
|
157
|
-
"546.js"
|
|
156
|
+
"405.js"
|
|
158
157
|
],
|
|
159
158
|
"async": []
|
|
160
159
|
},
|
|
@@ -173,8 +172,8 @@
|
|
|
173
172
|
"assets": {
|
|
174
173
|
"js": {
|
|
175
174
|
"sync": [
|
|
176
|
-
"
|
|
177
|
-
"
|
|
175
|
+
"707.js",
|
|
176
|
+
"78.js"
|
|
178
177
|
],
|
|
179
178
|
"async": []
|
|
180
179
|
},
|
|
@@ -185,15 +184,16 @@
|
|
|
185
184
|
}
|
|
186
185
|
},
|
|
187
186
|
{
|
|
188
|
-
"id": "agentPlugin
|
|
189
|
-
"name": "
|
|
190
|
-
"version": "
|
|
187
|
+
"id": "agentPlugin:@kb-labs/studio-event-bus",
|
|
188
|
+
"name": "@kb-labs/studio-event-bus",
|
|
189
|
+
"version": "2.94.0",
|
|
191
190
|
"singleton": true,
|
|
192
|
-
"requiredVersion": "^
|
|
191
|
+
"requiredVersion": "^2.0.0",
|
|
193
192
|
"assets": {
|
|
194
193
|
"js": {
|
|
195
194
|
"sync": [
|
|
196
|
-
"
|
|
195
|
+
"50.js",
|
|
196
|
+
"669.js"
|
|
197
197
|
],
|
|
198
198
|
"async": []
|
|
199
199
|
},
|