@openchambery/web 1.18.2-beta.28 → 1.18.2-beta.29
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/assets/AssistantView-Coj_BqNe.js +1 -0
- package/dist/assets/{ChatContainer-BMpzhPmB.js → ChatContainer-rXg0ZK5d.js} +23 -23
- package/dist/assets/{DiagramView-CrTRX9Y-.js → DiagramView-CmN3auk-.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DfxE7s_1.js → MarkdownRendererImpl-BdH1ynSb.js} +2 -2
- package/dist/assets/{MobileDetailNavigation-C2LwNG8B.js → MobileDetailNavigation-DpfpKgPu.js} +1 -1
- package/dist/assets/MobileShareBridge-d58Vzm3O.js +4 -0
- package/dist/assets/MobileSurface-S6hr1_7p.js +2 -0
- package/dist/assets/{MultiRunWindow-AtCafW3t.js → MultiRunWindow-C4Ike8AX.js} +1 -1
- package/dist/assets/{OnboardingScreen-CYeRZznl.js → OnboardingScreen-CW21rCqC.js} +1 -1
- package/dist/assets/OverlayScrollbar-BsFmRX3b.js +1 -0
- package/dist/assets/{SettingsView-DAbUmMO3.js → SettingsView-DLxzV2rK.js} +12 -11
- package/dist/assets/{SettingsWindow-CF87lKID.js → SettingsWindow-B-iCDv5r.js} +1 -1
- package/dist/assets/{TerminalView-95i-ukyJ.js → TerminalView-jsjZJ-hn.js} +1 -1
- package/dist/assets/{ToolOutputDialog-6dyRcTiq.js → ToolOutputDialog-RCrRpjSt.js} +1 -1
- package/dist/assets/appThemeRegistry-CnlbpoIa.js +2 -0
- package/dist/assets/capgoAdapter-LvGrONDp.js +1 -0
- package/dist/assets/{clipboard-BnElHSnO.js → clipboard-ByPKHEt8.js} +1 -1
- package/dist/assets/{context-menu-C0ReF3zt.js → context-menu-CvnY05Eg.js} +1 -1
- package/dist/assets/{dialog-COrLBm9O.js → dialog-CQLvE6F6.js} +1 -1
- package/dist/assets/{es-DIVYdoxi.js → es-ZHyqPb3M.js} +1 -1
- package/dist/assets/{fr-CNTlVypq.js → fr-nXAAl4qu.js} +1 -1
- package/dist/assets/{gitApi-BHEXs_kS.js → gitApi-itjXkp9E.js} +6 -6
- package/dist/assets/insertionBoundaries-BumXctlh.js +1 -0
- package/dist/assets/{ja-C_eW5ZM8.js → ja-CLcxQZ5K.js} +1 -1
- package/dist/assets/{ko-CE3cOv7v.js → ko-KgjBt0nP.js} +1 -1
- package/dist/assets/main-BWyu53zj.js +172 -0
- package/dist/assets/main-Drfmhboy.js +2 -0
- package/dist/assets/miniChat-CC3awYO5.js +2 -0
- package/dist/assets/mobile-DbOR4vtC.js +2 -0
- package/dist/assets/multirun-CrlXzIhD.js +4 -0
- package/dist/assets/{pl-BZKZOE99.js → pl-ZJkD7N-8.js} +1 -1
- package/dist/assets/platform-G8Cxe5wN.js +2 -0
- package/dist/assets/{projectMeta-BXvk9v0Y.js → projectMeta-C-VsUy14.js} +1 -1
- package/dist/assets/{pt-BR-DHDgp8S3.js → pt-BR-B6nleSMM.js} +1 -1
- package/dist/assets/{radio-Bz3wW90q.js → radio-CaoU7Lu-.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-BX-vxTMr.js +2 -0
- package/dist/assets/renderMobileApp-CSH0JwGO.js +23 -0
- package/dist/assets/runtimeConfig-D6Btfpc2.js +2 -0
- package/dist/assets/runtimeEndpointReset-DfILEKXr.js +145 -0
- package/dist/assets/{sortable-tabs-strip-DA7w0nsV.js → sortable-tabs-strip-DULPi5Jt.js} +1 -1
- package/dist/assets/{src-7UHu0sNZ.css → src-F6gEZAFJ.css} +1 -1
- package/dist/assets/{store-CUWqzRt7.js → store-BDxgw-Hx.js} +2 -2
- package/dist/assets/terminalApi-os4uWEou.js +1 -0
- package/dist/assets/types-BuiqMmh_.js +1 -0
- package/dist/assets/{uk-CfQK6cz1.js → uk-KTDMzdyl.js} +1 -1
- package/dist/assets/{useAppFontEffects-CXaNayQ6.js → useAppFontEffects-DGq7jjOF.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-DetZi3js.js → useDesktopWindowControlsLayout-DzesmOSh.js} +1 -1
- package/dist/assets/useEffectiveDirectory-BR3d8iyN.js +1 -0
- package/dist/assets/{useFontPreferences-92Qg-98H.js → useFontPreferences-B2QwnhAp.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BNXbEV2M.js → useMobileNavigationStore-BSreVaq2.js} +11 -11
- package/dist/assets/useSessionAutoCleanup-BNXZ_4Tj.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-B4w2EJ5y.js → useWorkerHighlightedLines-BCqkyru3.js} +1 -1
- package/dist/assets/{zh-CN-DvY2fKWp.js → zh-CN-BilLDIh_.js} +1 -1
- package/dist/assets/{zh-TW-eWe0lm3-.js → zh-TW-DBDsyRLQ.js} +1 -1
- package/dist/index.html +7 -5
- package/dist/mini-chat.html +7 -5
- package/dist/mobile.html +7 -5
- package/package.json +1 -1
- package/dist/assets/AssistantView-B34kl4il.js +0 -1
- package/dist/assets/MobileShareBridge-DqhQSf8z.js +0 -4
- package/dist/assets/MobileSurface-C2silN2X.js +0 -2
- package/dist/assets/OverlayScrollbar-Dk1uExgz.js +0 -1
- package/dist/assets/appThemeRegistry-CCk0bHI-.js +0 -2
- package/dist/assets/gitApiHttp-BxGAFLTf.js +0 -2
- package/dist/assets/insertionBoundaries-DbDVnbDC.js +0 -1
- package/dist/assets/main-DvKUAYFu.js +0 -172
- package/dist/assets/main-L6WiOyvO.js +0 -2
- package/dist/assets/miniChat-C9jmbnFh.js +0 -2
- package/dist/assets/mobile-BOin_sXb.js +0 -2
- package/dist/assets/multirun-D-6xkHW1.js +0 -4
- package/dist/assets/renderElectronMiniChatApp-BjJgTBYX.js +0 -2
- package/dist/assets/renderMobileApp-C1Mx2Onb.js +0 -23
- package/dist/assets/runtimeConfig-BXCt7ZsQ.js +0 -1
- package/dist/assets/runtimeEndpointReset-Bpu5TCuK.js +0 -145
- package/dist/assets/terminalApi-DpiAJlil.js +0 -1
- package/dist/assets/useEffectiveDirectory-B45LYDwZ.js +0 -1
- package/dist/assets/useSessionAutoCleanup-DoCX9MkG.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e,W as t}from"./useUIStore-5agS8bsW.js";import{kn as n}from"./persistence-D1lIuyqO.js";import{vt as r}from"./gitApiHttp-BxGAFLTf.js";var i=1,a=1,o=0,s=`/api/terminal/ws`,c=1200,l=250,u=2e4,d=5e3,f=`__openchamberTerminalTransportState`,p=new TextEncoder,m=new TextDecoder,h=t=>e().websocket(t),g=e=>{let t=p.encode(JSON.stringify(e)),n=new Uint8Array(t.length+1);return n[0]=i,n.set(t,1),n},_=e=>e?((e.transports??[]).includes(`ws`)||e.preferred===`ws`)&&typeof e.ws?.path==`string`&&e.ws.path.length>0:!1,v=e=>e.streamCapability?.ws?.path??e.inputCapability?.ws?.path??s,y=e=>{switch(e){case`SESSION_NOT_FOUND`:return Error(`Terminal session not found`);case`NOT_BOUND`:return Error(`Terminal session is not bound`);case`WRITE_FAIL`:return Error(`Failed to write to terminal`);case`RATE_LIMIT`:return Error(`Terminal websocket is rate limited`);case`BAD_FRAME`:return Error(`Terminal websocket protocol violation`);default:return Error(`Terminal websocket error`)}},b=class{socket=null;socketUrl=``;boundSessionId=null;requestedSessionId=null;openPromise=null;reconnectTimeout=null;keepaliveInterval=null;closed=!1;subscriptions=new Map;activeSubscriptionToken=null;replayCursorBySession=new Map;configure(e){if(e){if(this.socketUrl===e){this.closed=!1,this.isConnectedOrConnecting()||this.ensureConnected();return}this.socketUrl=e,this.closed=!1,this.resetConnection(),this.ensureConnected()}}subscribe(e,t,n,r){let i=Symbol(e),o={token:i,sessionId:e,onEvent:t,onError:n,maxRetries:r?.maxRetries??3,initialRetryDelay:r?.initialRetryDelay??1e3,maxRetryDelay:r?.maxRetryDelay??8e3,connectionTimeout:r?.connectionTimeout??1e4,retryCount:0,connected:!1,connectionTimeoutId:null};return this.subscriptions.set(i,o),this.activeSubscriptionToken=i,this.requestedSessionId=e,this.ensureConnected(),this.boundSessionId===e&&this.socket&&this.socket.readyState===a?(o.retryCount=0,o.connected=!0,o.onEvent({type:`connected`})):(this.boundSessionId=null,this.startConnectionTimeout(o),this.bindActiveSession()),()=>{if(this.clearConnectionTimeout(o),this.subscriptions.delete(i),this.activeSubscriptionToken===i&&(this.activeSubscriptionToken=null),this.hasSubscriptionForSession(e)||(this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null)),this.subscriptions.size===0){this.clearReconnectTimeout(),this.resetConnection();return}this.promoteActiveSubscription()}}async sendInput(e,t){if(!e||!t||this.closed||!this.socketUrl)return!1;let n=await this.getOpenSocket(c);if(!n||n.readyState!==a)return!1;try{return this.boundSessionId!==e&&(this.requestedSessionId=e,n.send(g({t:`b`,s:e,r:this.replayCursorBySession.get(e)??0,v:2}))),n.send(t),!0}catch{return this.handleSocketFailure(Error(`Terminal websocket send failed`)),!1}}unbindSession(e){e&&(this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null))}close(){this.closed=!0,this.clearReconnectTimeout();for(let e of this.subscriptions.values())this.clearConnectionTimeout(e);this.resetConnection(),this.socketUrl=``,this.subscriptions.clear(),this.activeSubscriptionToken=null,this.replayCursorBySession.clear()}prime(){this.closed||!this.socketUrl||this.isConnectedOrConnecting()||this.ensureConnected()}isConnectedOrConnecting(e){return this.closed||e&&this.socketUrl!==e?!1:this.socket&&(this.socket.readyState===a||this.socket.readyState===o)?!0:this.openPromise!==null}getActiveSubscription(){return this.activeSubscriptionToken?this.subscriptions.get(this.activeSubscriptionToken)??null:null}hasSubscriptionForSession(e){for(let t of this.subscriptions.values())if(t.sessionId===e)return!0;return!1}promoteActiveSubscription(){if(this.getActiveSubscription())return;let e=this.subscriptions.values().next().value;if(!e){this.activeSubscriptionToken=null;return}this.activeSubscriptionToken=e.token,this.requestedSessionId=e.sessionId,this.boundSessionId===e.sessionId?e.connected||(e.retryCount=0,e.connected=!0,this.clearConnectionTimeout(e),e.onEvent({type:`connected`})):(this.boundSessionId=null,this.startConnectionTimeout(e),this.bindActiveSession())}emitToSession(e,t){for(let n of this.subscriptions.values())n.sessionId===e&&n.onEvent(t)}markSessionConnected(e,t){for(let n of this.subscriptions.values())n.sessionId===e&&(n.retryCount=0,n.connected=!0,this.clearConnectionTimeout(n),n.onEvent(t))}emitErrorToSession(e,t,n){for(let r of this.subscriptions.values())r.sessionId===e&&(r.connected=!1,n&&this.clearConnectionTimeout(r),r.onError?.(t,n))}startConnectionTimeout(e){this.clearConnectionTimeout(e),e.connectionTimeoutId=setTimeout(()=>{e.connected||!this.subscriptions.has(e.token)||this.getActiveSubscription()?.token===e.token&&this.handleSocketFailure(Error(`Connection timeout`))},e.connectionTimeout)}clearConnectionTimeout(e){e.connectionTimeoutId&&=(clearTimeout(e.connectionTimeoutId),null)}async getOpenSocket(e){if(this.socket&&this.socket.readyState===a||(this.ensureConnected(),this.socket&&this.socket.readyState===a))return this.socket;let t=await Promise.race([this.openPromise??Promise.resolve(null),new Promise(t=>{setTimeout(()=>t(null),e)})]);return t&&t.readyState===a?t:this.socket&&this.socket.readyState===a?this.socket:null}ensureConnected(){this.closed||!this.socketUrl||this.socket&&(this.socket.readyState===a||this.socket.readyState===o)||(this.openPromise||=(this.clearReconnectTimeout(),(async()=>{try{await t()}catch{}return new Promise(e=>{let t=!1,n=null,i=r=>{t||(t=!0,n&&=(clearTimeout(n),null),this.openPromise=null,e(r))};try{let e=r(h(this.socketUrl));e.binaryType=`arraybuffer`,e.onopen=()=>{this.socket=e,this.startKeepalive(),i(e)},e.onmessage=e=>{this.handleSocketMessage(e.data)},e.onerror=()=>{!this.closed&&!this.getActiveSubscription()&&this.scheduleReconnect(Error(`Terminal websocket error`))},e.onclose=()=>{this.socket===e&&(this.socket=null,this.boundSessionId=null,this.stopKeepalive(),this.closed||this.scheduleReconnect(Error(`Terminal stream connection error`))),i(null)},this.socket=e,n=setTimeout(()=>{e.readyState===o&&(e.close(),i(null))},d)}catch{i(null),this.closed||this.scheduleReconnect(Error(`Terminal websocket open failed`))}})})()))}bindActiveSession(){let e=this.getActiveSubscription();if(!(!e||!this.socket||this.socket.readyState!==a)){this.requestedSessionId=e.sessionId;try{this.socket.send(g({t:`b`,s:e.sessionId,r:this.replayCursorBySession.get(e.sessionId)??0,v:2}))}catch{this.handleSocketFailure(Error(`Terminal websocket bind failed`))}}}scheduleReconnect(e){if(this.closed||!this.socketUrl||this.reconnectTimeout)return;this.promoteActiveSubscription();let t=this.getActiveSubscription();if(!t)return;let n=t.retryCount+1,r=t.initialRetryDelay,i=t.maxRetryDelay,a=t.maxRetries;if(n>a){this.clearConnectionTimeout(t),this.emitErrorToSession(t.sessionId,e,!0);return}t.retryCount=n;for(let e of this.subscriptions.values())e.sessionId===t.sessionId&&(e.connected=!1,e.retryCount=n,e.onEvent({type:`reconnecting`,attempt:n,maxAttempts:a}));this.startConnectionTimeout(t);let o=Math.min(r*2**Math.max(n-1,0),i)+Math.floor(Math.random()*l);this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.ensureConnected(),this.bindActiveSession()},o)}clearReconnectTimeout(){this.reconnectTimeout&&=(clearTimeout(this.reconnectTimeout),null)}sendControl(e){if(!this.socket||this.socket.readyState!==a)return!1;try{return this.socket.send(g(e)),!0}catch{return this.handleSocketFailure(Error(`Terminal websocket control send failed`)),!1}}startKeepalive(){this.stopKeepalive(),this.keepaliveInterval=setInterval(()=>{this.closed||this.sendControl({t:`p`,v:2})},u)}stopKeepalive(){this.keepaliveInterval&&=(clearInterval(this.keepaliveInterval),null)}async handleSocketMessage(e){let t=await this.asUint8Array(e);if(t&&t.length>0&&t[0]===i){this.handleControlMessage(t);return}let n=await this.asText(e);if(!n)return;let r=this.boundSessionId??this.requestedSessionId??this.getActiveSubscription()?.sessionId;r&&this.emitToSession(r,{type:`data`,data:n})}handleControlMessage(e){if(e.length<2)return;let t;try{t=JSON.parse(m.decode(e.subarray(1)))}catch{this.handleSocketFailure(Error(`Terminal websocket control parse failed`));return}let n=this.getActiveSubscription();switch(t.t){case`ok`:this.bindActiveSession();return;case`po`:return;case`d`:{let e=t.s??this.boundSessionId??this.requestedSessionId;if(!e)return;typeof t.i==`number`&&Number.isFinite(t.i)&&this.replayCursorBySession.set(e,Math.max(this.replayCursorBySession.get(e)??0,Math.trunc(t.i))),typeof t.d==`string`&&t.d.length>0&&this.emitToSession(e,{type:`data`,data:t.d});return}case`bok`:{let e=t.s??this.requestedSessionId;if(this.boundSessionId=e,!e)return;this.markSessionConnected(e,{type:`connected`,runtime:t.runtime,ptyBackend:t.ptyBackend});return}case`x`:{let e=t.s??this.boundSessionId??n?.sessionId??null;if(!e){this.boundSessionId=null;return}this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null),this.replayCursorBySession.delete(e);for(let n of this.subscriptions.values())n.sessionId===e&&(n.connected=!1,this.clearConnectionTimeout(n),n.onEvent({type:`exit`,exitCode:t.exitCode,signal:t.signal??null}));return}case`e`:{let e=y(t.c),r=t.f===!0;(t.c===`NOT_BOUND`||t.c===`SESSION_NOT_FOUND`)&&(this.boundSessionId=null);let i=t.s??this.requestedSessionId??n?.sessionId??null;if(i){if(t.c===`SESSION_NOT_FOUND`){this.emitErrorToSession(i,e,!0);return}this.emitErrorToSession(i,e,r)}else n&&(n.connected=!1,r&&this.clearConnectionTimeout(n),n.onError?.(e,r));t.f===!0&&this.handleSocketFailure(e);return}default:return}}async asUint8Array(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return e;if(typeof Blob<`u`&&e instanceof Blob){let t=await e.arrayBuffer();return new Uint8Array(t)}return null}async asText(e){if(typeof e==`string`)return e;let t=await this.asUint8Array(e);return t?m.decode(t):``}handleSocketFailure(e){this.boundSessionId=null,this.requestedSessionId=null,this.resetConnection(),this.scheduleReconnect(e)}resetConnection(){if(this.openPromise=null,this.stopKeepalive(),this.socket){let e=this.socket;this.socket=null,e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,(e.readyState===a||e.readyState===o)&&e.close()}this.boundSessionId=null}},x=()=>{let e=globalThis;return e[f]||(e[f]={inputCapability:null,streamCapability:null,manager:null}),e[f]},S=()=>{let e=x();return e.manager||=new b,e.manager},C=e=>{let t=x();if(t.inputCapability=e?.input??null,t.streamCapability=e?.stream??null,!_(t.inputCapability)&&!_(t.streamCapability)){t.manager?.close(),t.manager=null;return}let n=h(v(t));n&&S().configure(n)},w=async(e,t)=>{let r=await n(`/api/terminal/${e}/input`,{method:`POST`,headers:{"Content-Type":`text/plain`},body:t});if(!r.ok){let e=await r.json().catch(()=>({error:`Failed to send terminal input`}));throw Error(e.error||`Failed to send terminal input`)}};async function T(e){let t=await n(`/api/terminal/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e.cwd,cols:e.cols??80,rows:e.rows??24})});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to create terminal`}));throw Error(e.error||`Failed to create terminal session`)}let r=await t.json();return C(r.capabilities),r}var E=(t,n,r,i={})=>{let a=i.maxRetries??3,o=i.initialRetryDelay??1e3,s=i.maxRetryDelay??8e3,c=i.connectionTimeout??1e4,l=null,u=0,d=null,f=null,p=!1,m=!1,h=()=>{d&&=(clearTimeout(d),null),f&&=(clearTimeout(f),null)},g=()=>{p||(p=!0,h(),l&&=(l.close(),null))},_=(e,t)=>{if(!(p||m)){if(u<a&&!t){u+=1;let e=Math.min(o*2**(u-1),s);n({type:`reconnecting`,attempt:u,maxAttempts:a}),d=setTimeout(()=>{!p&&!m&&v()},e);return}r?.(e,!0),g()}},v=()=>{if(p||m||l&&l.readyState!==EventSource.CLOSED)return;l=new EventSource(e().sse(`/api/terminal/${t}/stream`));let i=!1;f=setTimeout(()=>{!i&&l?.readyState!==EventSource.OPEN&&(l?.close(),_(Error(`Connection timeout`),!1))},c),l.onopen=()=>{i||(i=!0,u=0,h(),n({type:`connected`}))},l.onmessage=e=>{try{let r=JSON.parse(e.data);r.type===`exit`&&(x().manager?.unbindSession(t),m=!0,g()),n(r)}catch(e){r?.(e,!1)}},l.onerror=()=>{h();let e=m||l?.readyState===EventSource.CLOSED;l?.close(),l=null,m||_(Error(`Terminal stream connection error`),e)}};return v(),g};function D(e,t,n,r={}){let i=x();if(i.streamCapability&&!_(i.streamCapability))return E(e,t,n,r);let a=S(),o=h(v(i));return o?(a.configure(o),a.subscribe(e,t,n,r)):E(e,t,n,r)}async function O(e,t){let n=x();n.manager&&await n.manager.sendInput(e,t)||await w(e,t)}async function k(e,t,r){let i=await n(`/api/terminal/${e}/resize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:t,rows:r})});if(!i.ok){let e=await i.json().catch(()=>({error:`Failed to resize terminal`}));throw Error(e.error||`Failed to resize terminal`)}}async function A(e){x().manager?.unbindSession(e);let t=await n(`/api/terminal/${e}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to close terminal`}));throw Error(e.error||`Failed to close terminal`)}}async function j(e,t){x().manager?.unbindSession(e);let r=await n(`/api/terminal/${e}/restart`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:t.cwd,cols:t.cols??80,rows:t.rows??24})});if(!r.ok){let e=await r.json().catch(()=>({error:`Failed to restart terminal`}));throw Error(e.error||`Failed to restart terminal`)}let i=await r.json();return C(i.capabilities),i}async function M(e){let t=await n(`/api/terminal/force-kill`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to force kill terminal`}));throw Error(e.error||`Failed to force kill terminal`)}e.sessionId&&x().manager?.unbindSession(e.sessionId)}function N(){let e=x();e.manager?.close(),e.manager=null,e.inputCapability=null,e.streamCapability=null}function P(){let e=x();if(e.inputCapability&&e.streamCapability&&!_(e.inputCapability)&&!_(e.streamCapability))return;let t=h(v(e)||s);if(!t)return;let n=S();n.isConnectedOrConnecting(t)||(n.configure(t),n.prime())}export{M as a,j as c,N as i,O as l,D as n,P as o,T as r,k as s,A as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{yt as e}from"./gitApiHttp-BxGAFLTf.js";import{n as t}from"./vendor-react-DLPElpoQ.js";import{Yt as n,_ as r,b as i,l as a}from"./useMobileNavigationStore-BNXbEV2M.js";var o=t(),s=()=>{let t=a.getState(),n=t.currentSessionId,o=t.newSessionDraft,s=t.worktreeMetadata,c=e.getState().currentDirectory;if(n){let e=i.getState().getAttachment(n),a=r(e);if(a)return a;let o=s.get(n);if(o?.path)return o.path;let c=t.getDirectoryForSession(n);if(c)return c}return o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride)?(o.bootstrapPendingDirectory||o.directoryOverride)??void 0:c??void 0},c=()=>{let t=(0,o.c)(7),s=a(l),c=a(u),p=n(s),m;t[0]===s?m=t[1]:(m=e=>s?e.getAttachment(s):void 0,t[0]=s,t[1]=m);let h=i(m),g=a(d),_=e(f);if(s){let e;t[2]===h?e=t[3]:(e=r(h),t[2]=h,t[3]=e);let n=e;if(n)return n;let i;t[4]!==s||t[5]!==g?(i=g.get(s),t[4]=s,t[5]=g,t[6]=i):i=t[6];let a=i;if(a?.path)return a.path;if(p)return p}return c?.open&&(c.bootstrapPendingDirectory||c.directoryOverride)?(c.bootstrapPendingDirectory||c.directoryOverride)??void 0:_??void 0};function l(e){return e.currentSessionId}function u(e){return e.newSessionDraft}function d(e){return e.worktreeMetadata}function f(e){return e.currentDirectory}export{c as n,s as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{M as t,t as n}from"./useUIStore-5agS8bsW.js";import{Kt as r,kn as i,qt as a,u as o}from"./persistence-D1lIuyqO.js";import{h as s}from"./desktopHosts-ZK_vkdzL.js";import{a as c,i as l,o as u,r as d}from"./desktopRelayRestore-CewM6-g5.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{kt as m}from"./gitApiHttp-BxGAFLTf.js";import{n as h}from"./vendor-react-DLPElpoQ.js";import{n as g}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as _,r as v}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as y,t as b}from"./clipboard-BnElHSnO.js";import{i as x,t as S}from"./store-CUWqzRt7.js";import{Qi as C,fr as ee,hr as w,l as T,or as E,vr as te}from"./useMobileNavigationStore-BNXbEV2M.js";import{t as D}from"./utils-BxJEIWv5.js";import{n as ne}from"./Icon-DiIuWOuC.js";import{t as re}from"./button-DaAoVF4X.js";import{i as ie,n as ae,r as oe,t as se}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{n as ce,r as le}from"./radio-Bz3wW90q.js";var O=h(),k=[`desktopHostSwitch`],A=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},ue=(e,t)=>S(x.getState().dictionary,e,t),de=async e=>{let{host:n}=e;if(n.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new A({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},n);return t({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:l(n)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}if(n.viaSshRelay){let e=await u(n);if(!e.ok)throw new A(e,n);return e}let r=await c(n,{cachedProbe:e.cachedProbe});if(!r.ok)throw new A(r,n);return r},j=null,fe=()=>j||(j=new g(o,{mutationKey:k,mutationFn:de,onError:(e,t)=>{e instanceof A&&e.result.reason!==`unsupported`&&te.error(ue(`desktopHostSwitcher.toast.instanceUnreachable`,{host:s(t.host.label)}))}}),j.subscribe(()=>void 0),j),pe=async e=>{if(d(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(o.isMutating({mutationKey:k})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await fe().mutate(e)}catch(e){if(e instanceof A)return e.result;throw e}},me=()=>{let e=(0,O.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:k},e[0]=t):t=e[0],v(t)>0},he=()=>{let e=(0,O.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:k,status:`pending`},select:ge},e[0]=t):t=e[0],_(t)[0]?.host.id??null};function ge(e){return e.state.variables}var M=e=>typeof e==`object`&&!!e,N=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},P=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},F=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},I=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],L=()=>r()?(e,t)=>a(e,t):null,R=e=>{if(!M(e))return;let t=F(e,`enabled`)??!1,n=N(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=N(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},_e=e=>e===`remote`||e===`dynamic`?e:`local`,ve=e=>{if(!M(e))return null;let t=N(e,`id`);if(!t)return null;let n=F(e,`enabled`)??!0,r=_e(N(e,`type`)),i=N(e,`localHost`)||N(e,`local_host`)||void 0,a=P(e,`localPort`)??P(e,`local_port`)??void 0,o=N(e,`remoteHost`)||N(e,`remote_host`)||void 0,s=P(e,`remotePort`)??P(e,`remote_port`)??void 0;return{id:t,enabled:n,type:r,...i?{localHost:i}:{},...typeof a==`number`?{localPort:a}:{},...o?{remoteHost:o}:{},...typeof s==`number`?{remotePort:s}:{}}},ye=e=>{if(!M(e))return null;let t=N(e,`id`),n=N(e,`sshCommand`)||N(e,`ssh_command`);if(!t||!n)return null;let r=N(e,`nickname`),i=e.sshParsed,a=M(i)?{destination:N(i,`destination`)||``,args:I(i.args)}:void 0,o=M(e.remoteOpenchamber)?e.remoteOpenchamber:M(e.remote_openchamber)?e.remote_openchamber:{},s=M(e.localForward)?e.localForward:M(e.local_forward)?e.local_forward:{},c=M(e.auth)?e.auth:{},l=N(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=N(o,`installMethod`)||N(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=N(s,`bindHost`)||N(s,`bind_host`)||`127.0.0.1`,p=f===`localhost`||f===`0.0.0.0`?f:`127.0.0.1`,m=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(e=>ve(e)).filter(e=>!!e),h=P(o,`preferredPort`)??P(o,`preferred_port`),g=P(s,`preferredLocalPort`)??P(s,`preferred_local_port`),_=R(c.sshPassword||c.ssh_password),v=R(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:P(e,`connectionTimeoutSec`)??P(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:F(o,`keepRunning`)??F(o,`keep_running`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:F(o,`uploadBundleOverSsh`)??F(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},be=e=>{switch(e){case`config_resolved`:case`auth_check`:case`master_connecting`:case`remote_probe`:case`installing`:case`updating`:case`server_detecting`:case`server_starting`:case`forwarding`:case`ready`:case`degraded`:case`error`:return e;default:return`idle`}},z=e=>{if(!M(e))return null;let t=N(e,`id`);return t?{id:t,phase:be(N(e,`phase`)),...N(e,`detail`)?{detail:N(e,`detail`)||void 0}:{},...N(e,`localUrl`)||N(e,`local_url`)?{localUrl:N(e,`localUrl`)||N(e,`local_url`)||void 0}:{},...typeof(P(e,`localPort`)??P(e,`local_port`))==`number`?{localPort:P(e,`localPort`)??P(e,`local_port`)??void 0}:{},...typeof(P(e,`remotePort`)??P(e,`remote_port`))==`number`?{remotePort:P(e,`remotePort`)??P(e,`remote_port`)??void 0}:{},startedByUs:F(e,`startedByUs`)??F(e,`started_by_us`)??!1,retryAttempt:P(e,`retryAttempt`)??P(e,`retry_attempt`)??0,requiresUserAction:F(e,`requiresUserAction`)??F(e,`requires_user_action`)??!1,updatedAtMs:P(e,`updatedAtMs`)??P(e,`updated_at_ms`)??Date.now()}:null},xe=e=>{if(!M(e))return null;let t=N(e,`host`),n=N(e,`source`),r=N(e,`sshCommand`)||N(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:F(e,`pattern`)??!1}},Se=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),Ce=async()=>{let e=L();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return M(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>ye(e)).filter(e=>!!e)}:{instances:[]}},we=async e=>{let t=L();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},Te=async()=>{let e=L();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>xe(e)).filter(e=>!!e):[]},Ee=async e=>{let t=L();t&&await t(`desktop_ssh_connect`,{id:e})},De=async e=>{let t=L();t&&await t(`desktop_ssh_disconnect`,{id:e})},Oe=async e=>{let t=L();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>z(e)).filter(e=>!!e):[]},ke=async(e,t)=>{let n=L();if(!n)return[];let r=await n(`desktop_ssh_logs`,{id:e,...typeof t==`number`?{limit:t}:{}});return Array.isArray(r)?r.filter(e=>typeof e==`string`):[]},Ae=async e=>{let t=L();t&&await t(`desktop_ssh_logs_clear`,{id:e})},je=(e,t)=>{let n=Math.max(0,Math.trunc(Number(e.fileGroups)||0)),r=Math.max(0,Math.trunc(Number(e.singleFiles)||0)),i=Math.max(0,Math.trunc(Number(e.directories)||0));return{fileGroups:Array.from({length:n},()=>!0),singleFiles:Array.from({length:r},()=>!0),directories:Array.from({length:i},()=>!0),agentsRoot:!0,authFile:t?.includeAuthFile===!0}},Me=e=>{if(!M(e))return null;let t=N(e,`path`),n=P(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Ne=e=>{if(!M(e))return null;let t=N(e,`path`),n=P(e,`fileCount`)??P(e,`file_count`),r=P(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Pe=e=>{if(e==null||!M(e))return null;let t=P(e,`fileCount`)??P(e,`file_count`),n=P(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},B=e=>{if(e==null||!M(e))return null;let t=P(e,`bytes`);return t===null?null:{bytes:t}},V=e=>{if(!M(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=I(e.deletes),i=P(e,`totalBytes`)??P(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>Me(e)).filter(e=>!!e),o=n.map(e=>Ne(e)).filter(e=>!!e);if(a.length!==t.length||o.length!==n.length)return null;let s=e.agentsRoot??e.agents_root,c=s==null?null:Pe(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:B(l),d=e.direction===`pull`||e.direction===`push`?e.direction:void 0,f=e.selections,p=M(f)?{fileGroups:Array.isArray(f.fileGroups)?f.fileGroups.map(e=>e!==!1):[],singleFiles:Array.isArray(f.singleFiles)?f.singleFiles.map(e=>e!==!1):[],directories:Array.isArray(f.directories)?f.directories.map(e=>e!==!1):[],agentsRoot:f.agentsRoot!==!1,authFile:f.authFile===!0}:void 0,m=H(e.selectionShape??e.selection_shape);return{files:a,directories:o,agentsRoot:c,authFile:u,deletes:r,totalBytes:i,...d?{direction:d}:{},...p?{selections:p}:{},...m?{selectionShape:m}:{}}},H=e=>{if(!M(e))return null;let t=P(e,`fileGroups`)??P(e,`file_groups`),n=P(e,`singleFiles`)??P(e,`single_files`),r=P(e,`directories`);return t===null||n===null||r===null||t<0||n<0||r<0?null:{fileGroups:t,singleFiles:n,directories:r}},Fe=e=>{if(!M(e))return null;let t=V(e.plan);if(!t)return null;let n=H(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:I(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:F(e,`remoteAgentsRootExists`)??F(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:F(e,`remoteAuthFileExists`)??F(e,`remote_auth_file_exists`)??!1,...typeof e.credentialAuthorized==`boolean`?{credentialAuthorized:e.credentialAuthorized}:{},...n?{selectionShape:n}:{}}},Ie=e=>{if(!M(e)||F(e,`ok`)!==!0)return null;let t=P(e,`files`),n=P(e,`directories`),r=P(e,`deletes`),i=P(e,`totalBytes`)??P(e,`total_bytes`);if(t===null||n===null||r===null||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=e.agentsRoot??e.agents_root,o=null;if(a!=null){if(!M(a))return null;let e=P(a,`fileCount`)??P(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:B(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Le=async(e={})=>{let t=L();if(!t)return null;let n=await t(`desktop_ssh_sync_opencode_config`,{stage:`local`,...e.direction?{direction:e.direction}:{},...e.selections?{selections:e.selections}:{}});if(!M(n))return null;let r=V(n.plan);if(!r)return null;let i=H(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Re=async(e,t={})=>{let n=L();return n?Fe(await n(`desktop_ssh_sync_opencode_config`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}})):null},ze=async(e,t={})=>{let n=L();return n?Ie(await n(`desktop_ssh_sync_opencode_config`,{id:e,apply:!0,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}})):null},Be=async(e,t={})=>{let n=L();if(!n)return[];let r=await n(`desktop_ssh_sync_runs_list`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}});return Array.isArray(r)?r.filter(e=>M(e)&&typeof e.syncRunId==`string`&&typeof e.targetId==`string`):[]},U=e=>{if(!M(e))return null;let t=typeof e.targetId==`string`?e.targetId.trim():``;if(!t)return null;let n=e.authorized===!0,r=typeof e.grantedAt==`string`&&e.grantedAt.trim()?e.grantedAt.trim():void 0,i=typeof e.channel==`string`&&e.channel.trim()?e.channel.trim():void 0;return{targetId:t,authorized:n,...r?{grantedAt:r}:{},...i?{channel:i}:{}}},Ve=async(e,t={})=>{let n=L();return n?U(await n(`desktop_ssh_credential_sync_get`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},He=async(e,t={})=>{let n=L();return n?U(await n(`desktop_ssh_credential_sync_grant`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},Ue=async(e,t={})=>{let n=L();return n?U(await n(`desktop_ssh_credential_sync_revoke`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},We=async e=>{if(!r())return async()=>{};let t=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof t!=`function`)return async()=>{};let n=await t(`openchamber:ssh-instance-status`,t=>{let n=z(t?.payload);n&&e(n)});return async()=>{await n()}},Ge=`/auth/passkey/authenticate/options`,Ke=`/auth/passkey/authenticate/verify`,qe=`/auth/passkey/register/options`,Je=`/auth/passkey/register/verify`,W=`/api/passkeys`,Ye=`/auth/passkey/status`,Xe=`/api/auth/reset`,G={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},K=async(e,t)=>i(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),q=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},Ze=e=>e instanceof ie&&e.code===`ERROR_CEREMONY_ABORTED`,Qe=()=>{oe.cancelCeremony()},J=()=>typeof window>`u`?{supported:!1,reason:`Passkeys are unavailable outside the browser.`}:window.isSecureContext?{supported:!0,reason:``}:{supported:!1,reason:`Passkeys require HTTPS or localhost.`},$e=async()=>{let e=J();if(!e.supported)throw Error(e.reason);let t=await K(qe,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await q(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await K(Je,{requestId:n,response:await ae({optionsJSON:r})});if(!i.ok)throw Error(await q(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},et=async(e,t={})=>{let n=J();if(!n.supported)throw Error(n.reason);let r=await K(Ge);if(!r.ok)throw Error(await q(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await K(Ke,{requestId:i,response:await se({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await q(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},tt=async()=>{let e=await i(Ye,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return G;let t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount==`number`?t.passkeyCount:0,rpID:typeof t?.rpID==`string`&&t.rpID?t.rpID:null}},nt=async()=>{let e=await i(W,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await q(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},rt=async e=>{let t=await i(`${W}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await q(t,`Could not remove passkey.`));return t.json().catch(()=>null)},it=async()=>{let e=await K(Xe);if(!e.ok)throw Error(await q(e,`Could not clear saved authentication.`));return e.json().catch(()=>null)},Y=e(p(),1),X=f();function Z(e){let t=(0,O.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=D(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`card`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function at(e){let t=(0,O.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=D(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`card-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ot(e){let t=(0,O.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=D(`leading-none font-semibold`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`card-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function st(e){let t=(0,O.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=D(`px-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`card-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var ct=class extends Y.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t,copied:!1}),console.error(`Error caught by boundary:`,e,t)}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};handleCopy=async()=>{let{strings:e}=this.props,t=`${this.state.error?String(this.state.error):e.unknownError}${this.state.error?.stack?`\n\nStack:\n${this.state.error.stack}`:``}${this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``}`;(await b(t)).ok&&(this.setState({copied:!0}),window.setTimeout(()=>{this.setState(e=>e.copied?{copied:!1}:null)},1500))};render(){let{strings:e}=this.props;return this.state.hasError?this.props.fallback?this.props.fallback:(0,X.jsx)(`div`,{className:`p-4 flex items-center justify-center min-h-screen`,children:(0,X.jsxs)(Z,{className:`w-full max-w-md`,children:[(0,X.jsx)(at,{className:`text-center`,children:(0,X.jsxs)(ot,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,X.jsx)(ne,{name:`error-warning`,className:`h-5 w-5`}),e.title]})}),(0,X.jsxs)(st,{className:`space-y-4`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:e.description}),this.state.error&&(0,X.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:e.detailsSummary}),(0,X.jsxs)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:[this.state.error.toString(),this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``]})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(re,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,X.jsx)(ne,{name:`restart`,className:`h-4 w-4 mr-2`}),e.tryAgain]}),(0,X.jsx)(re,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},lt=e=>{let t=(0,O.c)(29),{children:n,fallback:r}=e,{t:i}=y(),a;t[0]===i?a=t[1]:(a=i(`errorBoundary.state.unknownError`),t[0]=i,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`errorBoundary.title`),t[2]=i,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`errorBoundary.description`),t[4]=i,t[5]=s);let c;t[6]===i?c=t[7]:(c=i(`errorBoundary.actions.errorDetails`),t[6]=i,t[7]=c);let l;t[8]===i?l=t[9]:(l=i(`errorBoundary.state.componentStackLabel`),t[8]=i,t[9]=l);let u;t[10]===i?u=t[11]:(u=i(`errorBoundary.actions.tryAgain`),t[10]=i,t[11]=u);let d;t[12]===i?d=t[13]:(d=i(`errorBoundary.actions.copied`),t[12]=i,t[13]=d);let f;t[14]===i?f=t[15]:(f=i(`errorBoundary.actions.copy`),t[14]=i,t[15]=f);let p;t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f?(p={unknownError:a,title:o,description:s,detailsSummary:c,componentStackLabel:l,tryAgain:u,copied:d,copy:f},t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=p):p=t[24];let m=p,h;return t[25]!==n||t[26]!==r||t[27]!==m?(h=(0,X.jsx)(ct,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},Q=e=>S(x.getState().dictionary,e),ut=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),dt=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,ft=(e,t)=>e??dt(t),pt=(e,t,n=`auto`)=>{if(!e)return t??``;try{let r=new Date(e);if(!Number.isFinite(r.getTime()))return t??``;let i=new Date;return r.toDateString()===i.toDateString()?le(r,n,{fallback:t??``}):ce(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},mt=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,ht=e=>e===`5h`?Q(`quota.window.5h`):e===`7d`?Q(`quota.window.7d`):e===`7d-sonnet`?Q(`quota.window.7dSonnet`):e===`7d-opus`?Q(`quota.window.7dOpus`):e===`weekly`?Q(`quota.window.weekly`):e===`daily`?Q(`quota.window.daily`):e===`monthly`?Q(`quota.window.monthly`):e===`credits`?Q(`quota.window.credits`):e===`credits_balance`?Q(`quota.window.creditsBalance`):e===`billing_cycle`?Q(`quota.window.billingCycle`):e===`auto`?Q(`quota.window.auto`):e===`api`?Q(`quota.window.api`):e===`plan_limit`?Q(`quota.window.planLimit`):e===`on_demand`?Q(`quota.window.onDemand`):e===`session`?Q(`quota.window.session`):e===`premium`?Q(`quota.window.premium`):e===`chat`?Q(`quota.window.chat`):e===`completions`?Q(`quota.window.completions`):e===`premium_interactions`?Q(`quota.window.premiumInteractions`):e,gt=e=>{let t=e.toLowerCase().trim();if(t===`5h`)return 18e3;if(t===`7d`||t===`weekly`||t===`7d-sonnet`||t===`7d-opus`)return 604800;if(t===`monthly`)return 2592e3;if(t===`24h`||t===`daily`)return 86400;if(t===`1h`)return 3600;let n=t.match(/^(\d+)h$/);if(n)return parseInt(n[1],10)*3600;let r=t.match(/^(\d+)d$/);return r?parseInt(r[1],10)*86400:null},_t=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=gt(r)),e===null||t===null||i===null||i<=0)return null;let a=Math.max(0,(t-Date.now())/1e3),o=Math.max(0,Math.min(i,i-a)),s=Math.max(0,Math.min(1,o/i)),c=e/100,l=e>=100&&a>0,u;u=s>.01?Math.min(999,c/s*100):e;let d;d=l?`exhausted`:c<=s?`on-track`:u<=130?`slightly-fast`:`too-fast`;let f=i>=432e3,p=f?86400:3600,m=f?`d`:`h`,h=i/p,g=e/Math.max(o/p,h*.01),_=Number.isFinite(g)?`${Math.min(999.9,Math.max(0,g)).toFixed(1)}%/${m}`:`-`,v=u>100?`+${Math.round(u)}%`:`${Math.round(u)}%`,y=null,b=i/86400;return b>=7&&(y=100/b),{elapsedRatio:s,usageRatio:c,predictedFinalPercent:u,remainingSeconds:a,isExhausted:l,elapsedSeconds:o,totalSeconds:i,status:d,paceRateText:_,predictText:v,dailyAllocationPercent:y}},vt=e=>{switch(e){case`exhausted`:case`too-fast`:return`var(--status-error)`;case`slightly-fast`:return`var(--status-warning)`;case`on-track`:return`var(--status-success)`}},yt=e=>{let t=Math.floor(Math.max(0,Math.floor(e))/60),n=Math.floor(t/60),r=Math.floor(n/24),i=n%24,a=t%60;return r>0?`${r}d ${i}h`:n>0?`${n}h`:t===0?`<1m`:`${a}m`},bt=e=>Math.min(100,Math.max(0,e*100)),xt=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],St=`openchamber.pwaRecentSessions`,Ct=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,wt=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:xt.find(e=>Ct(e))??`browser`,Tt=864e5,Et=5,Dt=864e5,$=e=>e.time?.updated??e.time?.created??0,Ot=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Et,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*Tt,o=[...e].sort((e,t)=>$(t)-$(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=$(e);return n?n<a:!1}).map(e=>e.id)},kt=e=>{let t=typeof e==`object`?e:void 0,r=t?.autoRun!==!1,i=typeof e==`boolean`?e:t?.enabled??!0,a=T(e=>e.currentSessionId),o=T(e=>e.isLoading),s=w(e=>e.activeSessions),c=w(e=>e.hasLoadedFullCatalog),l=n(e=>e.autoDeleteEnabled),u=n(e=>e.autoDeleteAfterDays),d=n(e=>e.sessionRetentionAction),f=n(e=>e.autoDeleteLastRunAt),p=n(e=>e.setAutoDeleteLastRunAt),[h,g]=Y.useState(!1),_=Y.useRef(!1);Y.useEffect(()=>{if(!i||!r||!l||u<=0)return;let e=window.setTimeout(()=>{E(C())},8e3);return()=>window.clearTimeout(e)},[u,l,r,i]);let v=Y.useMemo(()=>u<=0?[]:Ot({sessions:s,currentSessionId:a,cutoffDays:u}),[u,a,s]),y=Y.useCallback(async({force:e=!1}={})=>{if(_.current)return{completedIds:[],failedIds:[],action:d,skippedReason:`running`};if((!l||u<=0)&&!e)return{completedIds:[],failedIds:[],action:d,skippedReason:`disabled`};if(o)return{completedIds:[],failedIds:[],action:d,skippedReason:`loading`};let t=Date.now();if(!e&&f&&t-f<Dt)return{completedIds:[],failedIds:[],action:d,skippedReason:`cooldown`};let{activeSessions:n}=await E(C());if(n.length===0)return{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};let r=Ot({sessions:n,currentSessionId:a,cutoffDays:u,now:t});if(r.length===0)return p(t),{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};_.current=!0,g(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?ee(r):null;if(!a){i.push(n);continue}try{d===`archive`?await m.updateSession(n,{time:{archived:Date.now()}},a):await m.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return d===`archive`?w.getState().archiveSessions(t):w.getState().removeSessions(t),{completedIds:t,failedIds:i,action:d}}finally{_.current=!1,g(!1),p(Date.now())}},[u,l,f,a,o,d,p]);return Y.useEffect(()=>{i&&r&&(!l||u<=0||o||!c||s.length===0||f&&Date.now()-f<Dt||y())},[u,l,f,r,i,c,s.length,o,y]),{candidates:v,isRunning:h,runCleanup:y,keepRecentCount:Et,action:d}};export{Ee as A,Oe as B,J as C,rt as D,it as E,Te as F,We as G,Le as H,Ce as I,he as J,pe as K,we as L,He as M,Ue as N,je as O,De as P,ke as R,nt as S,$e as T,Re as U,ze as V,Be as W,ot as _,_t as a,G as b,ft as c,vt as d,mt as f,at as g,st as h,bt as i,Ve as j,Se as k,yt as l,Z as m,St as n,ut as o,lt as p,me as q,wt as r,pt as s,kt as t,ht as u,et as v,Ze as w,tt as x,Qe as y,Ae as z};
|