@bitkyc08/opencodex 2.98.0 → 2.99.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.
Files changed (109) hide show
  1. package/bin/ocx.mjs +6 -19
  2. package/gui/dist/assets/App-BepstgEN.js +59 -0
  3. package/gui/dist/assets/{App-6TFtZsUF.css → App-C1hGwaN1.css} +1 -1
  4. package/gui/dist/assets/Tray-BinxbEZo.js +1 -0
  5. package/gui/dist/assets/{brand-mark-A03mw_9y.js → brand-mark-wzPe3R-J.js} +1 -1
  6. package/gui/dist/assets/{index-BjTIN4to.js → index-C-9X2yaI.js} +13 -13
  7. package/gui/dist/assets/index-bnUWypyz.css +2 -0
  8. package/gui/dist/assets/{segment-thumb-features-Bf6vpwf8.js → segment-thumb-features-fYEMxBaW.js} +1 -1
  9. package/gui/dist/classic/assets/App-DX88_GCW.js +58 -0
  10. package/gui/dist/classic/assets/Tray-BqZueZOx.js +1 -0
  11. package/gui/dist/classic/assets/{index-DFAFnven.js → index-fSP71pLB.js} +13 -13
  12. package/gui/dist/classic/assets/{quota-summary-C-4HP4_5.js → quota-summary-y2fl0WBv.js} +1 -1
  13. package/gui/dist/classic/index.html +1 -1
  14. package/gui/dist/index.html +2 -2
  15. package/package.json +1 -1
  16. package/src/adapters/coding-agent/protocol.ts +8 -3
  17. package/src/adapters/coding-agent/turn.ts +6 -2
  18. package/src/adapters/command-code.ts +8 -5
  19. package/src/adapters/devin.ts +11 -1
  20. package/src/adapters/kiro/stream.ts +5 -4
  21. package/src/adapters/openai-chat/destination-policy.ts +25 -0
  22. package/src/adapters/openai-chat/native-content.ts +32 -0
  23. package/src/adapters/openai-chat/passthrough.ts +14 -1
  24. package/src/adapters/openai-chat/reasoning-wire.ts +42 -1
  25. package/src/adapters/openai-chat.ts +2 -2
  26. package/src/adapters/qoder/adapter.ts +9 -0
  27. package/src/bridge/response-json.ts +13 -1
  28. package/src/bridge/sse.ts +112 -22
  29. package/src/cli/account-affinity-reset.ts +42 -0
  30. package/src/cli/account.ts +5 -0
  31. package/src/cli/capabilities-accounts.ts +8 -0
  32. package/src/cli/capabilities-agents-routing.ts +5 -4
  33. package/src/cli/message-command.ts +1 -1
  34. package/src/cli/message-mcp-command.ts +8 -5
  35. package/src/client/orphan-token-recovery.ts +1 -1
  36. package/src/codex/autostart-health.ts +4 -2
  37. package/src/generated/compatibility-version.json +128 -76
  38. package/src/lib/desktop-cli-handoff.mjs +5 -8
  39. package/src/lib/failure-detail.ts +5 -2
  40. package/src/lib/launcher-signal-forwarding.d.mts +8 -0
  41. package/src/lib/launcher-signal-forwarding.mjs +36 -0
  42. package/src/lib/privacy.ts +6 -0
  43. package/src/lib/request-execution-budget.ts +188 -33
  44. package/src/lib/upstream-validation-detail.ts +47 -0
  45. package/src/lib/workflow-budget.ts +35 -16
  46. package/src/messaging/mcp-queue-rpc.ts +7 -3
  47. package/src/messaging/mcp-queue-server.ts +6 -0
  48. package/src/messaging/mcp-reply-cursor.ts +34 -0
  49. package/src/messaging/mcp-reply-tools.ts +93 -0
  50. package/src/oauth/anthropic-routing.ts +46 -3
  51. package/src/oauth/anthropic-session-affinity-store.ts +23 -10
  52. package/src/protocols/codecs/ollama.ts +22 -12
  53. package/src/providers/registry/entries-extended.ts +14 -0
  54. package/src/remote/hub-usage.ts +7 -0
  55. package/src/responses/parser.ts +27 -0
  56. package/src/responses/reasoning-envelope.ts +4 -0
  57. package/src/responses/schema.ts +1 -0
  58. package/src/server/chat-completions.ts +3 -0
  59. package/src/server/chat-native-sse.ts +14 -10
  60. package/src/server/chat-native.ts +24 -11
  61. package/src/server/index/websocket-handler.ts +12 -1
  62. package/src/server/management/oauth-account-routes.ts +65 -13
  63. package/src/server/management/route-registry.ts +1 -0
  64. package/src/server/messages-native.ts +21 -5
  65. package/src/server/request-log-attempt-recovery.ts +17 -0
  66. package/src/server/request-log-failure-detail.ts +18 -1
  67. package/src/server/request-log.ts +5 -18
  68. package/src/server/responses/account-auto-pause-recovery.ts +29 -1
  69. package/src/server/responses/adapter-continuation.ts +12 -5
  70. package/src/server/responses/adapter-dispatch.ts +50 -51
  71. package/src/server/responses/antigravity-model-denial-recovery.ts +4 -2
  72. package/src/server/responses/codex-ws-exchange.ts +13 -4
  73. package/src/server/responses/combo-required-tool-contract.ts +22 -3
  74. package/src/server/responses/core-codex-account.ts +92 -86
  75. package/src/server/responses/core-combo-failure.ts +7 -0
  76. package/src/server/responses/core-combo.ts +11 -4
  77. package/src/server/responses/core-lifetime.ts +3 -0
  78. package/src/server/responses/deferred-send-reporter.ts +18 -1
  79. package/src/server/responses/fetch-helpers.ts +9 -3
  80. package/src/server/responses/native-continuation-refusal.ts +8 -0
  81. package/src/server/responses/native-continuation-send.ts +34 -0
  82. package/src/server/responses/passthrough-delivery.ts +6 -2
  83. package/src/server/responses/passthrough-dispatch.ts +48 -33
  84. package/src/server/responses/passthrough-execution.ts +1 -0
  85. package/src/server/responses/policy-fallback.ts +32 -5
  86. package/src/server/responses/policy-request-scope.ts +26 -0
  87. package/src/server/responses/request-prepare.ts +11 -2
  88. package/src/server/responses/request-send-budget.ts +96 -14
  89. package/src/server/responses/request-spend-target.ts +19 -0
  90. package/src/server/responses/request-spend.ts +80 -28
  91. package/src/server/responses/request-transport.ts +106 -53
  92. package/src/server/responses/run-turn-execution.ts +3 -0
  93. package/src/server/responses/sidecar-execution.ts +2 -1
  94. package/src/server/responses/ws-upstream.ts +2 -1
  95. package/src/server/workflow-refusal.ts +38 -4
  96. package/src/server/ws-bridge.ts +10 -3
  97. package/src/service/desktop-startup.ts +76 -13
  98. package/src/types/request.ts +2 -1
  99. package/src/usage/app-breakdown.ts +23 -0
  100. package/src/usage/summary.ts +34 -1
  101. package/src/web-search/anthropic-executor.ts +25 -9
  102. package/src/web-search/loop.ts +3 -1
  103. package/src/web-search/passthrough-bridge.ts +3 -0
  104. package/src/web-search/run-turn-loop.ts +3 -1
  105. package/gui/dist/assets/App-FQ0OtiMJ.js +0 -59
  106. package/gui/dist/assets/Tray-D2d5wqLq.js +0 -1
  107. package/gui/dist/assets/index-5REODpG3.css +0 -2
  108. package/gui/dist/classic/assets/App-C9Eg3nUo.js +0 -58
  109. package/gui/dist/classic/assets/Tray-B8P8cokE.js +0 -1
@@ -1 +0,0 @@
1
- import{A as e,C as t,F as n,G as r,U as i,d as a,h as o,r as s,u as c,w as l}from"./index-BjTIN4to.js";import{E as u,Y as d,Z as f,a as p,c as m,d as ee,f as h,h as g,i as _,it as v,l as y,m as b,mt as x,o as te,p as S,s as C,t as w,u as T,v as E,y as D,zt as O}from"./brand-mark-A03mw_9y.js";var k=r(i(),1),A={discover:l,configure:a,hasSharedSession:()=>o(`shared`),bootstrapShared:e=>c(`shared`,e)},j=()=>new DOMException(`Tray target resolution cancelled`,`AbortError`);async function ne(e,n=``,r=A){if(e.aborted)throw j();let i=await r.discover(n,e);if(e.aborted||(r.configure(i),i.connected&&!r.hasSharedSession()&&await r.bootstrapShared(e),e.aborted))throw j();return t(`shared`,i)}var M={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},N=((e,t,n,r)=>{let i=(0,k.forwardRef)(({color:n=`currentColor`,size:i=24,stroke:a=2,title:o,className:s,children:c,...l},u)=>(0,k.createElement)(`svg`,{ref:u,...M[e],width:i,height:i,className:[`tabler-icon`,`tabler-icon-${t}`,s].filter(Boolean).join(` `),strokeWidth:a,stroke:n,...l},[o&&(0,k.createElement)(`title`,{key:`svg-title`},o),...r.map(([e,t])=>(0,k.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return i.displayName=`${n}`,i})(`outline`,`settings`,`Settings`,[[`path`,{d:`M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065`,key:`svg-0`}],[`path`,{d:`M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0`,key:`svg-1`}]]),P=s(),F=`/?desktop=open#/usage`;function I({connection:e,refreshing:t,onRefresh:n,t:r}){let i=r(e===`up`?`dash.online`:e===`down`?`startup.tray.unavailable`:`common.loading`);return(0,P.jsxs)(`header`,{className:`tray-head`,children:[(0,P.jsxs)(`span`,{className:`tray-brand`,children:[(0,P.jsx)(w,{className:`tray-brand-mark`}),`OpenCodex`]}),(0,P.jsxs)(`span`,{className:`tray-status`,"data-state":e,children:[(0,P.jsx)(`span`,{className:`tray-status-dot`,"aria-hidden":`true`}),i]}),(0,P.jsxs)(`span`,{className:`tray-head-actions`,children:[(0,P.jsx)(`button`,{type:`button`,className:`tray-icon-btn`,onClick:n,disabled:t,"aria-label":r(`startup.refresh`),title:r(`startup.refresh`),children:(0,P.jsx)(O,{className:t?`tray-spin`:void 0,"aria-hidden":`true`})}),(0,P.jsx)(`a`,{className:`tray-icon-btn`,href:F,"aria-label":r(`sub.settings`),title:r(`sub.settings`),children:(0,P.jsx)(N,{"aria-hidden":`true`,stroke:1.75})})]})]})}function L({children:e,onRetry:t,t:n}){return(0,P.jsxs)(`p`,{role:`alert`,className:`tray-error`,children:[(0,P.jsx)(`span`,{children:e}),t&&(0,P.jsx)(`button`,{type:`button`,onClick:t,children:n(`common.retry`)})]})}function R({title:e,label:t,className:n,children:r}){return(0,P.jsxs)(`div`,{className:`tray-card${n?` ${n}`:``}`,role:t?`group`:void 0,"aria-label":t,children:[e&&(0,P.jsx)(`h2`,{className:`tray-card-head`,children:e}),(0,P.jsx)(`div`,{className:`tray-card-body`,children:r})]})}function z({updated:e,t}){return(0,P.jsxs)(`footer`,{className:`tray-foot`,children:[(0,P.jsx)(`span`,{role:`status`,children:e}),(0,P.jsxs)(`a`,{className:`tray-link`,href:F,children:[t(`nav.dashboard`),(0,P.jsx)(x,{"aria-hidden":`true`})]})]})}var B=e=>e?.usageIncomplete||e?.historyTruncated||e?.entriesTruncated;function V(e){return t=>m(t)?d(t,e):`—`}function H({raw:e,showCost:t,locale:n,t:r}){let i=V(n),a=e?y(e):void 0,o=a?.cacheReadInputTokens??a?.cachedInputTokens,s=m(o)&&m(a?.inputTokens)&&a.inputTokens>0?`${Math.round(o/a.inputTokens*100)}%`:`—`,c=m(a?.requests)&&m(a?.pricedRequests)&&a.pricedRequests<a.requests;return(0,P.jsxs)(`dl`,{children:[(0,P.jsxs)(`div`,{className:`tray-figure`,children:[(0,P.jsx)(`dt`,{children:r(`usage.card.totalTokens`)}),(0,P.jsx)(`dd`,{children:i(a?.totalTokens)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dt`,{children:r(`tray.input`)}),(0,P.jsxs)(`dd`,{children:[i(a?.inputTokens),` `,(0,P.jsx)(`small`,{title:r(`usage.card.cachedTokens`),children:r(`tray.cached`,{percent:s})})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dt`,{children:r(`tray.output`)}),(0,P.jsx)(`dd`,{children:i(a?.outputTokens)})]}),t&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dt`,{title:r(`logs.metric.estimatedCostTitle`),children:r(`tray.cost`)}),(0,P.jsx)(`dd`,{title:c?r(`usage.cost.unpricedNote`,{count:a.requests-a.pricedRequests}):r(`logs.metric.estimatedCostTitle`),children:m(a?.estimatedCostUsd)?new Intl.NumberFormat(n,{style:`currency`,currency:`USD`,maximumFractionDigits:2}).format(a.estimatedCostUsd)+(c?`*`:``):`—`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dt`,{children:r(`usage.card.requests`)}),(0,P.jsx)(`dd`,{children:i(a?.requests)})]}),m(a?.requests)&&a.requests>0&&m(a.measuredRequests)&&a.measuredRequests<a.requests&&(0,P.jsxs)(`div`,{className:`tray-coverage`,title:r(`usage.coverage.note`),children:[(0,P.jsx)(`dt`,{children:r(`usage.card.coverage`)}),(0,P.jsxs)(`dd`,{children:[Math.round(a.measuredRequests/a.requests*100),`%`]})]})]})}function U({label:e,data:t,t:n}){return(0,P.jsxs)(`h3`,{children:[e,B(t)&&(0,P.jsx)(`span`,{title:n(`usage.incomplete`),"aria-label":n(`usage.incomplete`),children:` *`})]})}function W({usage:e,settings:t,locale:n,t:r}){return(0,P.jsx)(R,{className:`tray-totals`,label:r(`usage.section.overview`),children:(0,P.jsxs)(`div`,{className:`tray-totals-grid`,children:[t.showToday&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(U,{label:r(`tray.today`),data:e[0],t:r}),(0,P.jsx)(H,{raw:e[0]?.summary,showCost:t.showCost,locale:n,t:r})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(U,{label:r(`usage.range.30d`),data:e[1],t:r}),(0,P.jsx)(H,{raw:e[1]?.summary,showCost:t.showCost,locale:n,t:r})]})]})})}function G({usage:e,locale:t,t:n}){let r=V(t);return(0,P.jsx)(R,{className:`tray-models`,title:n(`usage.section.models`),children:(0,P.jsx)(`ul`,{children:e.models.map(e=>(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`span`,{className:`tray-model-name`,title:`${e.provider}/${e.model}`,children:e.model}),(0,P.jsxs)(`span`,{className:`tray-model-metrics`,children:[(0,P.jsx)(`span`,{title:n(`usage.card.requests`),children:n(`pws.dashboard.requests`,{count:r(e.requests)})}),(0,P.jsx)(`span`,{title:n(`usage.card.totalTokens`),children:r(y(e).totalTokens)})]})]},`${e.provider}/${e.model}`))})})}function K({account:e,locale:t,t:n}){let r=S(e.quota);return r.length?(0,P.jsx)(P.Fragment,{children:r.map(e=>{let r=`key`in e?n(e.key):e.label,i=b(e.reset,t),a=m(e.percent)?Math.min(100,e.percent):null;return(0,P.jsxs)(`div`,{className:`tray-quota`,children:[(0,P.jsx)(`span`,{className:`tray-quota-label`,title:r,children:r}),(0,P.jsx)(`span`,{className:`tray-bar tray-bar--${_(a??void 0)}`,role:a===null?`img`:`meter`,"aria-label":a===null?`${r}: ${n(`pws.dashboard.noQuota`)}`:r,"aria-valuemin":a===null?void 0:0,"aria-valuemax":a===null?void 0:100,"aria-valuenow":a??void 0,"aria-valuetext":a===null?void 0:`${Math.round(a)}%`,children:(0,P.jsx)(`i`,{style:{width:a===null?`0%`:`${a}%`}})}),(0,P.jsx)(`span`,{className:`tray-quota-value`,children:a===null?`—`:`${Math.round(a)}%`}),(0,P.jsx)(`time`,{title:i.exact,children:i.text})]},e.id)})}):(0,P.jsx)(`p`,{className:`tray-missing`,children:n(e.unavailable?`startup.tray.unavailable`:`pws.dashboard.noQuota`)})}function re({provider:e,switching:t,onSwitch:n,locale:r,t:i}){let a=e.switchKind;return(0,P.jsxs)(R,{className:`tray-provider`,title:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(u,{name:e.name,cls:`provider-icon tray-provider-icon`}),f(e.name,i)]}),children:[!e.accounts.length&&(0,P.jsx)(`p`,{className:`tray-missing`,children:i(e.unavailable?`startup.tray.unavailable`:`pws.dashboard.noQuota`)}),e.accounts.map(o=>{let s=t===`${e.name}:${o.id}`;return(0,P.jsxs)(`div`,{className:`tray-account`,"data-active":o.active?`true`:void 0,children:[(0,P.jsxs)(`div`,{className:`tray-account-name`,children:[(0,P.jsx)(`span`,{className:`tray-account-label`,title:o.label,children:o.label}),o.exhausted&&(0,P.jsx)(`span`,{className:`tray-exhausted`,title:i(`quota.limitReached`),"aria-label":i(`quota.limitReached`),children:(0,P.jsx)(v,{"aria-hidden":`true`})}),o.active&&(0,P.jsx)(`span`,{className:`tray-badge tray-badge--active`,children:i(`prov.activeBadge`)}),o.plan&&(0,P.jsx)(`span`,{className:`tray-badge`,children:o.plan}),(0,P.jsxs)(`span`,{className:`tray-account-action`,children:[s&&(0,P.jsx)(`span`,{role:`status`,children:i(`pws.accountSwitching`)}),!s&&a&&o.switchState===`available`&&(0,P.jsx)(`button`,{type:`button`,className:`tray-use`,disabled:t!==null,onClick:()=>n(e.name,a,o.id),title:i(`prov.accountSwitchTitle`),"aria-label":`${i(`prov.accountSwitchTitle`)}: ${o.label}`,children:i(`prov.accountSwitchTitle`)})]})]}),o.email&&o.email!==o.label&&(0,P.jsx)(`div`,{className:`tray-account-email`,children:o.email}),(0,P.jsx)(K,{account:o,locale:r,t:i})]},o.id)})]})}var ie=2e4;function q({resolveApiBase:t=ne}={}){let{t:r,locale:i}=n(),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(!1),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(!1),[m,_]=(0,k.useState)([null,null]),[v,y]=(0,k.useState)(!1),[b,x]=(0,k.useState)([]),[S,w]=(0,k.useState)(!1),[O,A]=(0,k.useState)(null),[j,M]=(0,k.useState)(!1),[N,F]=(0,k.useState)(null),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(0),[K,q]=(0,k.useState)(null),[J,Y]=(0,k.useState)(null),X=()=>{c(!1),U(e=>e+1)},Z=(0,k.useRef)(!1),Q=(0,k.useRef)(null),$=(0,k.useRef)(!0);(0,k.useEffect)(()=>($.current=!0,document.documentElement.classList.add(`tray-document`),()=>{$.current=!1,Q.current?.abort(),document.documentElement.classList.remove(`tray-document`)}),[]),(0,k.useEffect)(()=>{if(a!==null)return;let e=new AbortController;return t(e.signal).then(t=>{e.signal.aborted||o(t)},()=>{e.signal.aborted||c(!0)}),()=>e.abort()},[H,a,t]);let ae=async(t,n,i)=>{if(a===null)return;q(`${t}:${i}`),Y(null);let o=e(ie);Q.current=o.controller;try{let e=p(t,n,i),r=await fetch(`${a}${e.path}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.body),signal:o.signal});if(!r.ok)throw Error(String(r.status));if(!$.current)return;Z.current=!0,X()}catch{if(!$.current)return;q(null),Y(r(n===`codex`?`codexAuth.switchFailed`:`prov.accountSwitchFail`))}finally{o.clear(),Q.current===o.controller&&(Q.current=null)}};(0,k.useEffect)(()=>{if(a===null)return;let e=null,t=!1,n=!0,r=!1,i=()=>!document.hidden&&(window.__OPENCODEX_TRAY_VISIBLE__??n),o=async()=>{if(!i()||t)return;t=!0,V(!0);let n=!1,s=new AbortController;e=s;let c=e=>te(`${a}${e}`,s.signal),l=()=>!r&&!s.signal.aborted;try{let e=(async()=>{try{let e=h(await c(`/api/config`)),t=await Promise.all(e.map(async e=>{if(!e.path)return{name:e.name,switchKind:e.switchKind,accounts:[]};try{let t=await c(e.path);if(e.name===`openai`)try{t.activeCodexAccountId=(await c(`/api/codex-auth/active`)).activeCodexAccountId??`__main__`}catch{}return{name:e.name,switchKind:e.switchKind,accounts:T(t)}}catch{return{name:e.name,switchKind:e.switchKind,accounts:[],unavailable:!0}}}));l()&&(x(t),w(!1),n=!0)}catch{l()&&(x([]),w(!0))}})(),t=(async()=>{let e;try{if(e=(await c(`/api/companion/settings`)).settings,!e||!Array.isArray(e.hiddenProviders)||!(e.models===null||Array.isArray(e.models)))throw Error(`Invalid settings`);l()&&(u(e),f(!1))}catch{l()&&f(!0);return}let t=Promise.allSettled([`/api/usage?range=today`,`/api/usage?range=30d`].map(async t=>{let n=ee(await c(t));return C(n,e)})).then(e=>{l()&&(n||=e.some(e=>e.status===`fulfilled`),_(e.map(e=>e.status===`fulfilled`?e.value:null)),y(e.some(e=>e.status===`rejected`)))}),r=(async()=>{if(!e.showChart)return;let t=D(e);try{let n=await c(`/api/usage/timeline?${t}`);l()&&(A(E(n,e)),M(!1))}catch{l()&&(A(null),M(!0))}})();await Promise.allSettled([t,r])})();await Promise.allSettled([e,t])}finally{t=!1,l()&&(V(!1),n&&F(Date.now()),Z.current&&(Z.current=!1,q(null))),!r&&s.signal.aborted&&i()&&o()}},s=()=>{i()?o():e?.abort()},c=()=>{n=!1,s()},l=()=>{n=!0,s()},d=e=>{let t=e.detail;typeof t==`boolean`&&(window.__OPENCODEX_TRAY_VISIBLE__=t),s()};o();let p=setInterval(()=>void o(),6e4);return document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,c),window.addEventListener(`focus`,l),window.addEventListener(`opencodex:tray-visibility`,d),()=>{r=!0,e?.abort(),clearInterval(p),document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`blur`,c),window.removeEventListener(`focus`,l),window.removeEventListener(`opencodex:tray-visibility`,d)}},[H,a]);let oe=new Set(l?.hiddenProviders??[]),se=s||S&&d?`down`:N===null?`loading`:`up`,ce=r(`tray.updated`,{time:N===null?`—`:new Date(N).toLocaleTimeString(i,{hour:`2-digit`,minute:`2-digit`})});return(0,P.jsxs)(`main`,{className:`tray-page`,children:[(0,P.jsx)(I,{connection:se,refreshing:B,onRefresh:X,t:r}),s&&(0,P.jsx)(L,{onRetry:X,t:r,children:r(`startup.tray.unavailable`)}),d&&(0,P.jsx)(L,{onRetry:X,t:r,children:r(`usage.companion.settingsUnavailable`)}),!l&&!d&&!s&&(0,P.jsx)(`p`,{role:`status`,className:`tray-loading`,children:r(`common.loading`)}),(l?.showAccounts??!0)&&(0,P.jsxs)(`section`,{className:`tray-providers`,"aria-label":r(`usage.section.providers`),children:[S&&(0,P.jsx)(L,{onRetry:X,t:r,children:r(`startup.tray.unavailable`)}),J&&(0,P.jsx)(L,{t:r,children:J}),b.filter(e=>!oe.has(e.name)).map(e=>(0,P.jsx)(re,{provider:e,switching:K,onSwitch:(e,t,n)=>void ae(e,t,n),locale:i,t:r},e.name))]}),l&&(0,P.jsx)(W,{usage:m,settings:l,locale:i,t:r}),v&&(0,P.jsx)(L,{onRetry:X,t:r,children:r(`usage.loadError`)}),l?.showChart&&(0,P.jsx)(R,{className:`tray-chart`,children:(0,P.jsx)(g,{timeline:O,chartStyle:l.chartStyle,hours:l.chartHours,loading:!O&&!j,error:j?r(`usage.companion.timelineUnavailable`):null,onRetry:X,locale:i,t:r})}),l?.showModels&&!!m[0]?.models.length&&(0,P.jsx)(G,{usage:m[0],locale:i,t:r}),(0,P.jsx)(z,{updated:ce,t:r})]})}export{q as default};