@yansigit/opencodex 2.36.1-dev.20260829.35 → 2.36.1-dev.20260829.39

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 (42) hide show
  1. package/gui/dist/assets/{ApiKeys-Dmc3vk4f.js → ApiKeys-BDLkAqHs.js} +1 -1
  2. package/gui/dist/assets/{Claude-B8nBn_TE.js → Claude-CbTHl2B0.js} +1 -1
  3. package/gui/dist/assets/{CodexSet-RKnAl3Rr.js → CodexSet-BWMY8up4.js} +1 -1
  4. package/gui/dist/assets/{FileIntegrationPage-LBYKB5gf.js → FileIntegrationPage-BFywFnu_.js} +1 -1
  5. package/gui/dist/assets/{Grok-B6nDl-pq.js → Grok-D7_rD_UK.js} +1 -1
  6. package/gui/dist/assets/{Integrations-DPcI3mwy.js → Integrations-BM5cNRt8.js} +2 -2
  7. package/gui/dist/assets/{IntegrationsOverview-BLgOYwUO.js → IntegrationsOverview-DUL8qhww.js} +1 -1
  8. package/gui/dist/assets/{Logs-BkM5ic5m.js → Logs-BG9kIs3A.js} +1 -1
  9. package/gui/dist/assets/Models-BJWzO0Kh.js +1 -0
  10. package/gui/dist/assets/{NumberStepper-Dsiahf_V.js → NumberStepper-K9tocDBx.js} +1 -1
  11. package/gui/dist/assets/{Providers-DFBGM2BG.js → Providers-BLweq_Hw.js} +1 -1
  12. package/gui/dist/assets/{RestoreDialog-0YZ3cmhw.js → RestoreDialog-D9aPE4O0.js} +1 -1
  13. package/gui/dist/assets/{Startup-BRXwp250.js → Startup-CkcpO3Jv.js} +1 -1
  14. package/gui/dist/assets/{Storage-D0Ve2fj0.js → Storage-YIqUviJJ.js} +1 -1
  15. package/gui/dist/assets/Subagents-C1AfLEl9.js +1 -0
  16. package/gui/dist/assets/{Usage-C0T5SUrf.js → Usage-BerHlEN0.js} +1 -1
  17. package/gui/dist/assets/codex-stale-banner-D4gvSWnO.js +1 -0
  18. package/gui/dist/assets/{data-surface-D8RXShV2.js → data-surface-BtO3lwam.js} +1 -1
  19. package/gui/dist/assets/{data-surface-Bfu-W0pf.js → data-surface-DCct07RT.js} +1 -1
  20. package/gui/dist/assets/{index-WNYAjf83.js → index-Bs27ITj_.js} +3 -3
  21. package/gui/dist/assets/{model-display-hWp9VTdv.js → model-display-KCeq505s.js} +1 -1
  22. package/gui/dist/assets/{provider-payload-F7zzYMeI.js → provider-payload-DHs_ctdK.js} +1 -1
  23. package/gui/dist/assets/{section-tabs-DEASco68.js → section-tabs-BP7gEPK6.js} +1 -1
  24. package/gui/dist/assets/shared-BdYGV-yJ.js +69 -0
  25. package/gui/dist/index.html +2 -2
  26. package/package.json +1 -1
  27. package/src/codex/app-server-processes.ts +160 -54
  28. package/src/codex/internal/catalog-writer.ts +3 -0
  29. package/src/codex/subagent-defaults.ts +114 -0
  30. package/src/codex/sync.ts +5 -0
  31. package/src/generated/compatibility-version.json +13 -13
  32. package/src/server/effort-policy.ts +43 -12
  33. package/src/server/index.ts +6 -0
  34. package/src/server/management/agent-settings-routes.ts +2 -0
  35. package/src/server/request-log.ts +7 -0
  36. package/src/server/responses/collaboration.ts +20 -4
  37. package/src/server/responses/core.ts +6 -4
  38. package/src/server/ws-bridge.ts +5 -0
  39. package/src/usage/log.ts +9 -0
  40. package/gui/dist/assets/Models-uh6UTNK5.js +0 -1
  41. package/gui/dist/assets/Subagents-TaTl5eEL.js +0 -1
  42. package/gui/dist/assets/shared-p0R307IX.js +0 -69
@@ -1 +1 @@
1
- import{_ as e,h as t,m as n,s as r}from"./shared-p0R307IX.js";import{C as i,F as a,P as o,St as s,b as c,h as l,p as u,x as d,y as f}from"./index-WNYAjf83.js";import{t as p}from"./data-surface-Bfu-W0pf.js";import{t as m}from"./data-surface-D8RXShV2.js";import{n as h,t as g}from"./section-tabs-DEASco68.js";import{t as _}from"./model-display-hWp9VTdv.js";import{r as v}from"./intl-formatters-CTcuZoAe.js";var y=e(t(),1),b=s(),x=n();function S(e){return`${Math.round(e*100)}%`}function C(e,t){let n=`${t}/${e}`,r=0;for(let e=0;e<n.length;e++)r=r*31+n.charCodeAt(e)>>>0;return`hsl(${r%360} 55% 55%)`}function w(e){let t=new Map(e.map(e=>[e.date,e]));return f(e,7).map(e=>({...e,models:t.get(e.date)?.models??[]}))}function T(e){let t=window.innerWidth,n=window.innerHeight,r=Math.min(240,Math.max(0,t-16));return{left:Math.max(8,Math.min(e.left+e.width/2-r/2,t-8-r)),maxWidth:r,...e.top-8>n-e.bottom-8?(()=>{let t=Math.max(8,Math.min(n-8,n-e.top+8));return{bottom:t,maxHeight:Math.max(0,n-t-8)}})():(()=>{let t=Math.max(8,Math.min(n-8,e.bottom+8));return{top:t,maxHeight:Math.max(0,n-t-8)}})()}}function E({anchor:e,className:t,children:n}){return(0,b.createPortal)((0,x.jsx)(`div`,{className:`${t} chart-overlay`,role:`tooltip`,style:T(e),children:n}),document.body)}function D(e,t,n){return n(`usage.chart.dayDetail`,{date:c(e.date,t),requests:e.requests,tokens:d(e.totalTokens,t)})}function O(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(e*t.length))];return[n(.25),n(.5),n(.75),n(.95)]}function k(e,t){return e<=0?0:e<=t[0]?1:e<=t[1]?2:e<=t[2]?3:4}function A(e,t){let n=O(e.map(e=>e.totalTokens)),r=new Map(e.map(e=>[e.date,e])),i=new Date;i.setHours(0,0,0,0);let a=new Date(i);a.setDate(a.getDate()-364),a.setDate(a.getDate()-a.getDay());let o=[],s=[],c=new Intl.DateTimeFormat(t,{month:`short`}),l=-4,u=-1,d=[],f=new Date(a);for(;f<=i;){let e=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,`0`)}-${String(f.getDate()).padStart(2,`0`)}`,t=f.getMonth();f.getDay()===0&&t!==u&&o.length-l>=4&&(s.push({label:c.format(f),col:o.length}),l=o.length,u=t);let i=r.get(e);d.push({date:e,requests:i?.requests??0,totalTokens:i?.totalTokens??0,level:i?k(i.totalTokens,n):0,dayOfWeek:f.getDay()}),f.getDay()===6&&(o.push(d),d=[]),f.setDate(f.getDate()+1)}if(d.length>0){for(;d.length<7;)d.push({date:``,requests:0,totalTokens:0,level:0,dayOfWeek:d.length});o.push(d)}return{weeks:o,months:s,buckets:n}}function j({surface:e,range:t,onSurface:n,onRange:r,t:i}){return(0,x.jsxs)(`div`,{className:`usage-filters`,children:[(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`logs.filter.surface.label`),children:[`all`,`codex`,`claude`,`grok`].map(t=>{let r=i(`logs.filter.surface.${t}`);return(0,x.jsxs)(`button`,{type:`button`,className:`usage-segmented-btn usage-source-btn${e===t?` active`:``}`,"aria-label":r,"aria-pressed":e===t,onClick:()=>n(t),children:[t===`codex`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/openai.svg`,alt:``,"aria-hidden":`true`}),t===`claude`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/claude-color.svg`,alt:``,"aria-hidden":`true`}),t===`grok`&&(0,x.jsx)(`img`,{className:`usage-source-mark usage-source-mark--mono`,src:`/provider-icons/grok.svg`,alt:``,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:t===`all`?`usage-source-label`:`usage-source-label usage-source-label-collapsible`,children:r})]},t)})}),(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`usage.title`),children:[`all`,`30d`,`7d`].map(e=>{let n=i(e===`all`?`usage.range.available`:`usage.range.${e}`);return(0,x.jsx)(`button`,{type:`button`,className:`usage-segmented-btn${t===e?` active`:``}`,"aria-label":n,"aria-pressed":t===e,onClick:()=>r(e),children:n},e)})})]})}function M({summary:e,activeDays:t,locale:n,t:r}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,role:`group`,"aria-label":r(`usage.title`),children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.requests`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.requests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.totalTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.totalTokens,n)})]}),(0,x.jsxs)(`div`,{className:`stat`,title:r(`usage.card.cachedTokensHint`),children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.cachedTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.cacheReadInputTokens??e.cachedInputTokens,n)}),(e.cacheCreationInputTokens??0)>0&&(0,x.jsxs)(`div`,{className:`muted text-caption`,children:[r(`usage.card.cacheWriteTokens`),`: `,d(e.cacheCreationInputTokens??0,n)]})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.coverage`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:S(e.coverageRatio)})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.activeDays`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:t})]})]}),e.estimatedCostUsd!==void 0&&(0,x.jsxs)(`div`,{className:`usage-cost-row`,role:`note`,children:[(0,x.jsx)(`span`,{className:`muted`,children:r(`usage.cost.total`)}),(0,x.jsx)(`span`,{className:`stat-value mono usage-cost-value`,children:v(e.estimatedCostUsd,n)}),(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.disclaimer`)}),(e.unpricedRequests??0)+(e.unmeteredRequests??0)>0&&(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.unpricedNote`).replace(`{count}`,String((e.unpricedRequests??0)+(e.unmeteredRequests??0)))})]})]})}function N({weekBars:e,locale:t,t:n}){let[r,i]=(0,y.useState)(null),a=Math.max(1,...e.map(e=>e.totalTokens)),o=e.find(e=>e.date===r?.date),s=(e,t)=>{i({date:e.date,anchor:t.getBoundingClientRect()})};return(0,x.jsxs)(`div`,{className:`daybars`,role:`group`,"aria-label":n(`usage.section.heatmap`),children:[e.map(e=>{let r=Math.round(e.totalTokens/a*100),o=new Intl.DateTimeFormat(t,{weekday:`short`}).format(new Date(`${e.date}T12:00:00`));return(0,x.jsxs)(`button`,{type:`button`,className:`daybar`,"aria-label":D(e,t,n),onFocus:t=>s(e,t.currentTarget),onBlur:()=>i(t=>t?.date===e.date?null:t),onPointerEnter:t=>s(e,t.currentTarget),onPointerDown:t=>s(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&i(t=>t?.date===e.date?null:t)},children:[(0,x.jsx)(`div`,{className:`daybar-track`,children:(0,x.jsxs)(`div`,{className:`daybar-stack`,style:{"--daybar-scale":String(Math.max(0,Math.min(1,r/100)))},children:[e.models.map(e=>(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:e.totalTokens,background:C(e.model,e.provider)}},`${e.provider}/${e.model}`)),e.models.length===0&&e.totalTokens>0&&(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:1,background:`var(--green)`}})]})}),(0,x.jsx)(`span`,{className:`daybar-count`,children:d(e.totalTokens,t)}),(0,x.jsx)(`span`,{className:`daybar-label muted`,children:o})]},e.date)}),r&&o&&(0,x.jsxs)(E,{className:`daybar-tip`,anchor:r.anchor,children:[(0,x.jsx)(`div`,{className:`daybar-tip-date`,children:c(o.date,t)}),(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{children:n(`usage.heatmap.tooltipRequests`,{requests:o.requests})}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:n(`usage.heatmap.tooltipTokens`,{tokens:d(o.totalTokens,t)})})]}),o.models.slice(0,8).map(e=>(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{className:`daybar-tip-swatch`,style:{background:C(e.model,e.provider)}}),(0,x.jsx)(`span`,{className:`daybar-tip-name`,children:_(e.model)}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:d(e.totalTokens,t)})]},`${e.provider}/${e.model}`))]})]})}function P({range:e,heatmap:t,weekBars:n,locale:r,t:i}){let a=(0,y.useRef)(null),o=(0,y.useMemo)(()=>t.weeks.flat().filter(e=>e.date),[t]),[s,l]=(0,y.useState)(()=>o.at(-1)?.date??``),[u,f]=(0,y.useState)(null),p=(0,y.useId)(),m=o.some(e=>e.date===s)?s:o.at(-1)?.date??``,h=(e,t)=>{l(e.date),f({date:e.date,anchor:t.getBoundingClientRect()})},g=(e,t)=>{let n=o.findIndex(e=>e.date===t.date),r=e.key===`ArrowUp`?-1:e.key===`ArrowDown`?1:e.key===`ArrowLeft`?-7:e.key===`ArrowRight`?7:0;if(!r||n<0)return;e.preventDefault();let i=o[Math.max(0,Math.min(o.length-1,n+r))];l(i.date);let s=a.current?.querySelector(`[data-date="${i.date}"]`);s&&(s.focus(),f({date:i.date,anchor:s.getBoundingClientRect()}))};return(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[t,e]),(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":`usage-heatmap-title`,children:[(0,x.jsx)(`h3`,{id:`usage-heatmap-title`,className:`panel-title`,children:i(`usage.section.heatmap`)}),e===`7d`?(0,x.jsx)(N,{weekBars:n,locale:r,t:i}):(0,x.jsxs)(`div`,{className:`heatmap`,ref:a,children:[(0,x.jsxs)(`div`,{className:`heatmap-months`,style:{gridTemplateColumns:`28px repeat(${t.weeks.length}, calc(var(--hm-cell) + var(--hm-gap)))`},children:[(0,x.jsx)(`span`,{className:`heatmap-day-spacer`}),t.months.map(e=>(0,x.jsx)(`span`,{className:`heatmap-month`,style:{gridColumn:e.col+2},children:e.label},`${e.label}-${e.col}`))]}),(0,x.jsxs)(`div`,{className:`heatmap-body`,children:[(0,x.jsxs)(`div`,{className:`heatmap-days`,children:[(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayMon`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayWed`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayFri`)}),(0,x.jsx)(`span`,{})]}),(0,x.jsx)(`div`,{className:`heatmap-grid`,role:`group`,"aria-labelledby":`usage-heatmap-title`,"aria-describedby":p,style:{gridTemplateColumns:`repeat(${t.weeks.length}, var(--hm-cell))`},children:t.weeks.map((e,t)=>(0,x.jsx)(`div`,{className:`heatmap-week`,children:e.map((e,n)=>e.date?(0,x.jsx)(`button`,{type:`button`,className:`heatmap-cell heatmap-cell-${e.level}`,"data-date":e.date,tabIndex:m===e.date?0:-1,"aria-label":D(e,r,i),onFocus:t=>h(e,t.currentTarget),onBlur:()=>f(t=>t?.date===e.date?null:t),onKeyDown:t=>g(t,e),onPointerEnter:t=>h(e,t.currentTarget),onPointerDown:t=>h(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&f(t=>t?.date===e.date?null:t)}},e.date):(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-0`,"aria-hidden":`true`},`pad-${t}-${n}`))},e[0]?.date||`week-${t}`))})]}),(0,x.jsx)(`span`,{id:p,className:`sr-only`,children:i(`usage.heatmap.keyboardLabel`)}),(0,x.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:o.find(e=>e.date===m)?D(o.find(e=>e.date===m),r,i):``}),u&&(()=>{let e=o.find(e=>e.date===u.date);return e?.date?(0,x.jsxs)(E,{className:`heatmap-tip`,anchor:u.anchor,children:[(0,x.jsx)(`div`,{className:`heatmap-tip-date`,children:c(e.date,r)}),(0,x.jsx)(`div`,{className:`heatmap-tip-val`,children:i(`usage.heatmap.tooltipTokens`,{tokens:d(e.totalTokens,r)})}),(0,x.jsx)(`div`,{className:`heatmap-tip-req muted`,children:i(`usage.heatmap.tooltipRequests`,{requests:e.requests})})]}):null})(),(0,x.jsxs)(`div`,{className:`heatmap-legend muted`,children:[(0,x.jsx)(`span`,{children:i(`usage.heatmap.less`)}),[0,1,2,3,4].map(e=>(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-${e}`},e)),(0,x.jsx)(`span`,{children:i(`usage.heatmap.more`)})]})]})]})}function F({title:e,titleId:t,children:n}){return(0,x.jsxs)(`section`,{className:`usw-section`,"aria-labelledby":t,children:[(0,x.jsx)(`h3`,{id:t,className:`h-section`,children:e}),n]})}function I({models:e,modelQuery:t,onModelQuery:n,locale:r,t:a,workspace:o=!1}){let s=a(`usage.search.models`),c=a(`usage.section.models`),l=`usage-models-title`,u=(0,x.jsx)(`input`,{className:`input`,"aria-label":s,placeholder:s,value:t,onChange:e=>n(e.target.value)}),f=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:a(`logs.col.model`)}),(0,x.jsx)(`th`,{children:a(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:a(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:_(e.model)}),(0,x.jsx)(`td`,{className:`muted`,children:i(e.provider,a)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,r)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},`${e.provider}/${e.model}`))})]})});return o?(0,x.jsxs)(F,{title:c,titleId:l,children:[(0,x.jsx)(`div`,{className:`usw-section-toolbar`,children:u}),f]}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":l,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{id:l,className:`panel-title`,children:c}),u]}),f]})}function L({providers:e,locale:t,t:n,workspace:r=!1}){let a=n(`usage.section.providers`),o=`usage-providers-title`,s=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:n(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:n(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:i(e.provider,n)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,t)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},e.provider))})]})});return r?(0,x.jsx)(F,{title:a,titleId:o,children:s}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":o,children:[(0,x.jsx)(`h3`,{id:o,className:`panel-title`,children:a}),s]})}function R({summary:e,t,workspace:n=!1}){let r=t(`usage.section.coverage`),i=`usage-coverage-title`,a=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.reported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.reportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.estimated`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.estimatedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unreported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unreportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unsupported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unsupportedRequests})]})]}),(0,x.jsx)(`p`,{className:`muted text-control`,style:{marginTop:12},children:t(`usage.coverage.note`)})]});return n?(0,x.jsx)(F,{title:r,titleId:i,children:a}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":i,children:[(0,x.jsx)(`h3`,{id:i,className:`panel-title`,children:r}),a]})}function z({data:e,heatmap:t,weekBars:n,activeDays:r,filteredModels:i,modelQuery:a,onModelQuery:s,sortedProviders:c,range:l,locale:u,t:d}){let f=!!e&&e.summary.requests===0,p=[{id:`overview`,label:d(`usage.section.overview`),meta:e?`${e.summary.requests}`:`—`,body:e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(M,{summary:e.summary,activeDays:r,locale:u,t:d}),(0,x.jsx)(P,{range:l,heatmap:t,weekBars:n,locale:u,t:d})]}):null},{id:`models`,label:d(`usage.section.models`),meta:e?`${e.models.length}`:`—`,body:e?(0,x.jsx)(I,{models:i,modelQuery:a,onModelQuery:s,locale:u,t:d,workspace:!0}):null},{id:`providers`,label:d(`usage.section.providers`),meta:e?`${e.providers.length}`:`—`,body:e?(0,x.jsx)(L,{providers:c,locale:u,t:d,workspace:!0}):null},{id:`coverage`,label:d(`usage.section.coverage`),meta:e?S(e.summary.coverageRatio):`—`,body:e?(0,x.jsx)(R,{summary:e.summary,t:d,workspace:!0}):null}];return(0,x.jsx)(`div`,{className:`usage-workspace-shell`,children:(0,x.jsxs)(`div`,{className:`usage-workspace-root`,children:[(0,x.jsx)(g,{scope:`usage`,ariaLabel:d(`usage.workspace.sections`),items:p.map(e=>({id:e.id,label:e.label,meta:e.meta}))}),(0,x.jsx)(`section`,{className:`usage-workspace-main`,"aria-label":d(`usage.workspace.report`),children:f?(0,x.jsx)(o,{title:d(`usage.empty`)}):p.map(e=>(0,x.jsx)(`div`,{id:h(`usage`,e.id),className:`usw-body usw-section-block`,children:e.body},e.id))})]})})}var B=new Map;function V(e,t,n){return`ocx.usage.v1:${e}:${t}:${n}`}function H(e,t,n){let r=V(e,t,n);return B.get(r)??u(r)}function U(e,t,n,r){let i=V(e,t,n);B.set(i,r),l(i,r)}function W({apiBase:e}){let{t,locale:n}=r(),[i,o]=(0,y.useState)(`30d`),[s,c]=(0,y.useState)(`all`),[l,u]=(0,y.useState)(``),d=(0,y.useCallback)(async t=>{let n=await fetch(`${e}/api/usage?range=${i}&surface=${s}`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let r=await n.json();return U(e,i,s,r),r},[e,i,s]),f=V(e,i,s),h=H(e,i,s),g=p(f,[e,i,s],d,{isEmpty:()=>!1,initialData:h??void 0}),{state:_}=g,v=_.data??h??null,b=(0,y.useMemo)(()=>A(v?.days??[],n),[v?.days,n]),S=(0,y.useMemo)(()=>w(v?.days??[]),[v?.days]),C=(0,y.useMemo)(()=>(v?.days??[]).filter(e=>e.requests>0).length,[v?.days]),T=(0,y.useMemo)(()=>{let e=l.trim().toLowerCase(),t=(v?.models??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens);return e?t.filter(t=>t.model.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)||(t.resolvedModel??``).toLowerCase().includes(e)).slice(0,100):t.slice(0,100)},[v?.models,l]),E=(0,y.useMemo)(()=>(v?.providers??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens),[v?.providers]);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`page-head usage-head`,children:[(0,x.jsx)(`h2`,{id:`usage-page-title`,children:t(`usage.title`)}),(0,x.jsx)(j,{surface:s,range:i,onSurface:c,onRange:o,t})]}),(0,x.jsx)(`p`,{className:`page-sub`,children:t(`usage.subtitle`)}),_.showSkeleton&&!v?(0,x.jsx)(m,{label:t(`usage.loading`),rows:5}):_.kind===`failed-cold`?(0,x.jsxs)(a,{tone:`err`,children:[_.error instanceof Error?`${t(`usage.loadError`)} ${_.error.message}`:t(`usage.loadError`),` `,(0,x.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>g.refresh(),children:t(`common.retry`)})]}):(0,x.jsxs)(x.Fragment,{children:[_.showError&&(0,x.jsx)(a,{tone:`err`,children:t(`usage.loadError`)}),v?.historyTruncated&&(0,x.jsx)(a,{tone:`warn`,children:(()=>{let e=G(v.snapshotWindowStart),n=G(v.snapshotWindowEnd);return e!==null&&n!==null?t(`usage.historyTruncatedWindow`,{start:e,end:n}):t(`usage.historyTruncated`)})()}),(0,x.jsx)(z,{data:v,heatmap:b,weekBars:S,activeDays:C,filteredModels:T,modelQuery:l,onModelQuery:u,sortedProviders:E,range:i,locale:n,t})]})]})}function G(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():null}export{W as default};
1
+ import{_ as e,h as t,m as n,s as r}from"./shared-BdYGV-yJ.js";import{C as i,F as a,P as o,St as s,b as c,h as l,p as u,x as d,y as f}from"./index-Bs27ITj_.js";import{t as p}from"./data-surface-DCct07RT.js";import{t as m}from"./data-surface-BtO3lwam.js";import{n as h,t as g}from"./section-tabs-BP7gEPK6.js";import{t as _}from"./model-display-KCeq505s.js";import{r as v}from"./intl-formatters-CTcuZoAe.js";var y=e(t(),1),b=s(),x=n();function S(e){return`${Math.round(e*100)}%`}function C(e,t){let n=`${t}/${e}`,r=0;for(let e=0;e<n.length;e++)r=r*31+n.charCodeAt(e)>>>0;return`hsl(${r%360} 55% 55%)`}function w(e){let t=new Map(e.map(e=>[e.date,e]));return f(e,7).map(e=>({...e,models:t.get(e.date)?.models??[]}))}function T(e){let t=window.innerWidth,n=window.innerHeight,r=Math.min(240,Math.max(0,t-16));return{left:Math.max(8,Math.min(e.left+e.width/2-r/2,t-8-r)),maxWidth:r,...e.top-8>n-e.bottom-8?(()=>{let t=Math.max(8,Math.min(n-8,n-e.top+8));return{bottom:t,maxHeight:Math.max(0,n-t-8)}})():(()=>{let t=Math.max(8,Math.min(n-8,e.bottom+8));return{top:t,maxHeight:Math.max(0,n-t-8)}})()}}function E({anchor:e,className:t,children:n}){return(0,b.createPortal)((0,x.jsx)(`div`,{className:`${t} chart-overlay`,role:`tooltip`,style:T(e),children:n}),document.body)}function D(e,t,n){return n(`usage.chart.dayDetail`,{date:c(e.date,t),requests:e.requests,tokens:d(e.totalTokens,t)})}function O(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(e*t.length))];return[n(.25),n(.5),n(.75),n(.95)]}function k(e,t){return e<=0?0:e<=t[0]?1:e<=t[1]?2:e<=t[2]?3:4}function A(e,t){let n=O(e.map(e=>e.totalTokens)),r=new Map(e.map(e=>[e.date,e])),i=new Date;i.setHours(0,0,0,0);let a=new Date(i);a.setDate(a.getDate()-364),a.setDate(a.getDate()-a.getDay());let o=[],s=[],c=new Intl.DateTimeFormat(t,{month:`short`}),l=-4,u=-1,d=[],f=new Date(a);for(;f<=i;){let e=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,`0`)}-${String(f.getDate()).padStart(2,`0`)}`,t=f.getMonth();f.getDay()===0&&t!==u&&o.length-l>=4&&(s.push({label:c.format(f),col:o.length}),l=o.length,u=t);let i=r.get(e);d.push({date:e,requests:i?.requests??0,totalTokens:i?.totalTokens??0,level:i?k(i.totalTokens,n):0,dayOfWeek:f.getDay()}),f.getDay()===6&&(o.push(d),d=[]),f.setDate(f.getDate()+1)}if(d.length>0){for(;d.length<7;)d.push({date:``,requests:0,totalTokens:0,level:0,dayOfWeek:d.length});o.push(d)}return{weeks:o,months:s,buckets:n}}function j({surface:e,range:t,onSurface:n,onRange:r,t:i}){return(0,x.jsxs)(`div`,{className:`usage-filters`,children:[(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`logs.filter.surface.label`),children:[`all`,`codex`,`claude`,`grok`].map(t=>{let r=i(`logs.filter.surface.${t}`);return(0,x.jsxs)(`button`,{type:`button`,className:`usage-segmented-btn usage-source-btn${e===t?` active`:``}`,"aria-label":r,"aria-pressed":e===t,onClick:()=>n(t),children:[t===`codex`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/openai.svg`,alt:``,"aria-hidden":`true`}),t===`claude`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/claude-color.svg`,alt:``,"aria-hidden":`true`}),t===`grok`&&(0,x.jsx)(`img`,{className:`usage-source-mark usage-source-mark--mono`,src:`/provider-icons/grok.svg`,alt:``,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:t===`all`?`usage-source-label`:`usage-source-label usage-source-label-collapsible`,children:r})]},t)})}),(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`usage.title`),children:[`all`,`30d`,`7d`].map(e=>{let n=i(e===`all`?`usage.range.available`:`usage.range.${e}`);return(0,x.jsx)(`button`,{type:`button`,className:`usage-segmented-btn${t===e?` active`:``}`,"aria-label":n,"aria-pressed":t===e,onClick:()=>r(e),children:n},e)})})]})}function M({summary:e,activeDays:t,locale:n,t:r}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,role:`group`,"aria-label":r(`usage.title`),children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.requests`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.requests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.totalTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.totalTokens,n)})]}),(0,x.jsxs)(`div`,{className:`stat`,title:r(`usage.card.cachedTokensHint`),children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.cachedTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.cacheReadInputTokens??e.cachedInputTokens,n)}),(e.cacheCreationInputTokens??0)>0&&(0,x.jsxs)(`div`,{className:`muted text-caption`,children:[r(`usage.card.cacheWriteTokens`),`: `,d(e.cacheCreationInputTokens??0,n)]})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.coverage`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:S(e.coverageRatio)})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.activeDays`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:t})]})]}),e.estimatedCostUsd!==void 0&&(0,x.jsxs)(`div`,{className:`usage-cost-row`,role:`note`,children:[(0,x.jsx)(`span`,{className:`muted`,children:r(`usage.cost.total`)}),(0,x.jsx)(`span`,{className:`stat-value mono usage-cost-value`,children:v(e.estimatedCostUsd,n)}),(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.disclaimer`)}),(e.unpricedRequests??0)+(e.unmeteredRequests??0)>0&&(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.unpricedNote`).replace(`{count}`,String((e.unpricedRequests??0)+(e.unmeteredRequests??0)))})]})]})}function N({weekBars:e,locale:t,t:n}){let[r,i]=(0,y.useState)(null),a=Math.max(1,...e.map(e=>e.totalTokens)),o=e.find(e=>e.date===r?.date),s=(e,t)=>{i({date:e.date,anchor:t.getBoundingClientRect()})};return(0,x.jsxs)(`div`,{className:`daybars`,role:`group`,"aria-label":n(`usage.section.heatmap`),children:[e.map(e=>{let r=Math.round(e.totalTokens/a*100),o=new Intl.DateTimeFormat(t,{weekday:`short`}).format(new Date(`${e.date}T12:00:00`));return(0,x.jsxs)(`button`,{type:`button`,className:`daybar`,"aria-label":D(e,t,n),onFocus:t=>s(e,t.currentTarget),onBlur:()=>i(t=>t?.date===e.date?null:t),onPointerEnter:t=>s(e,t.currentTarget),onPointerDown:t=>s(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&i(t=>t?.date===e.date?null:t)},children:[(0,x.jsx)(`div`,{className:`daybar-track`,children:(0,x.jsxs)(`div`,{className:`daybar-stack`,style:{"--daybar-scale":String(Math.max(0,Math.min(1,r/100)))},children:[e.models.map(e=>(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:e.totalTokens,background:C(e.model,e.provider)}},`${e.provider}/${e.model}`)),e.models.length===0&&e.totalTokens>0&&(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:1,background:`var(--green)`}})]})}),(0,x.jsx)(`span`,{className:`daybar-count`,children:d(e.totalTokens,t)}),(0,x.jsx)(`span`,{className:`daybar-label muted`,children:o})]},e.date)}),r&&o&&(0,x.jsxs)(E,{className:`daybar-tip`,anchor:r.anchor,children:[(0,x.jsx)(`div`,{className:`daybar-tip-date`,children:c(o.date,t)}),(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{children:n(`usage.heatmap.tooltipRequests`,{requests:o.requests})}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:n(`usage.heatmap.tooltipTokens`,{tokens:d(o.totalTokens,t)})})]}),o.models.slice(0,8).map(e=>(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{className:`daybar-tip-swatch`,style:{background:C(e.model,e.provider)}}),(0,x.jsx)(`span`,{className:`daybar-tip-name`,children:_(e.model)}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:d(e.totalTokens,t)})]},`${e.provider}/${e.model}`))]})]})}function P({range:e,heatmap:t,weekBars:n,locale:r,t:i}){let a=(0,y.useRef)(null),o=(0,y.useMemo)(()=>t.weeks.flat().filter(e=>e.date),[t]),[s,l]=(0,y.useState)(()=>o.at(-1)?.date??``),[u,f]=(0,y.useState)(null),p=(0,y.useId)(),m=o.some(e=>e.date===s)?s:o.at(-1)?.date??``,h=(e,t)=>{l(e.date),f({date:e.date,anchor:t.getBoundingClientRect()})},g=(e,t)=>{let n=o.findIndex(e=>e.date===t.date),r=e.key===`ArrowUp`?-1:e.key===`ArrowDown`?1:e.key===`ArrowLeft`?-7:e.key===`ArrowRight`?7:0;if(!r||n<0)return;e.preventDefault();let i=o[Math.max(0,Math.min(o.length-1,n+r))];l(i.date);let s=a.current?.querySelector(`[data-date="${i.date}"]`);s&&(s.focus(),f({date:i.date,anchor:s.getBoundingClientRect()}))};return(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[t,e]),(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":`usage-heatmap-title`,children:[(0,x.jsx)(`h3`,{id:`usage-heatmap-title`,className:`panel-title`,children:i(`usage.section.heatmap`)}),e===`7d`?(0,x.jsx)(N,{weekBars:n,locale:r,t:i}):(0,x.jsxs)(`div`,{className:`heatmap`,ref:a,children:[(0,x.jsxs)(`div`,{className:`heatmap-months`,style:{gridTemplateColumns:`28px repeat(${t.weeks.length}, calc(var(--hm-cell) + var(--hm-gap)))`},children:[(0,x.jsx)(`span`,{className:`heatmap-day-spacer`}),t.months.map(e=>(0,x.jsx)(`span`,{className:`heatmap-month`,style:{gridColumn:e.col+2},children:e.label},`${e.label}-${e.col}`))]}),(0,x.jsxs)(`div`,{className:`heatmap-body`,children:[(0,x.jsxs)(`div`,{className:`heatmap-days`,children:[(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayMon`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayWed`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayFri`)}),(0,x.jsx)(`span`,{})]}),(0,x.jsx)(`div`,{className:`heatmap-grid`,role:`group`,"aria-labelledby":`usage-heatmap-title`,"aria-describedby":p,style:{gridTemplateColumns:`repeat(${t.weeks.length}, var(--hm-cell))`},children:t.weeks.map((e,t)=>(0,x.jsx)(`div`,{className:`heatmap-week`,children:e.map((e,n)=>e.date?(0,x.jsx)(`button`,{type:`button`,className:`heatmap-cell heatmap-cell-${e.level}`,"data-date":e.date,tabIndex:m===e.date?0:-1,"aria-label":D(e,r,i),onFocus:t=>h(e,t.currentTarget),onBlur:()=>f(t=>t?.date===e.date?null:t),onKeyDown:t=>g(t,e),onPointerEnter:t=>h(e,t.currentTarget),onPointerDown:t=>h(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&f(t=>t?.date===e.date?null:t)}},e.date):(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-0`,"aria-hidden":`true`},`pad-${t}-${n}`))},e[0]?.date||`week-${t}`))})]}),(0,x.jsx)(`span`,{id:p,className:`sr-only`,children:i(`usage.heatmap.keyboardLabel`)}),(0,x.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:o.find(e=>e.date===m)?D(o.find(e=>e.date===m),r,i):``}),u&&(()=>{let e=o.find(e=>e.date===u.date);return e?.date?(0,x.jsxs)(E,{className:`heatmap-tip`,anchor:u.anchor,children:[(0,x.jsx)(`div`,{className:`heatmap-tip-date`,children:c(e.date,r)}),(0,x.jsx)(`div`,{className:`heatmap-tip-val`,children:i(`usage.heatmap.tooltipTokens`,{tokens:d(e.totalTokens,r)})}),(0,x.jsx)(`div`,{className:`heatmap-tip-req muted`,children:i(`usage.heatmap.tooltipRequests`,{requests:e.requests})})]}):null})(),(0,x.jsxs)(`div`,{className:`heatmap-legend muted`,children:[(0,x.jsx)(`span`,{children:i(`usage.heatmap.less`)}),[0,1,2,3,4].map(e=>(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-${e}`},e)),(0,x.jsx)(`span`,{children:i(`usage.heatmap.more`)})]})]})]})}function F({title:e,titleId:t,children:n}){return(0,x.jsxs)(`section`,{className:`usw-section`,"aria-labelledby":t,children:[(0,x.jsx)(`h3`,{id:t,className:`h-section`,children:e}),n]})}function I({models:e,modelQuery:t,onModelQuery:n,locale:r,t:a,workspace:o=!1}){let s=a(`usage.search.models`),c=a(`usage.section.models`),l=`usage-models-title`,u=(0,x.jsx)(`input`,{className:`input`,"aria-label":s,placeholder:s,value:t,onChange:e=>n(e.target.value)}),f=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:a(`logs.col.model`)}),(0,x.jsx)(`th`,{children:a(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:a(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:_(e.model)}),(0,x.jsx)(`td`,{className:`muted`,children:i(e.provider,a)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,r)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},`${e.provider}/${e.model}`))})]})});return o?(0,x.jsxs)(F,{title:c,titleId:l,children:[(0,x.jsx)(`div`,{className:`usw-section-toolbar`,children:u}),f]}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":l,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{id:l,className:`panel-title`,children:c}),u]}),f]})}function L({providers:e,locale:t,t:n,workspace:r=!1}){let a=n(`usage.section.providers`),o=`usage-providers-title`,s=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:n(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:n(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:i(e.provider,n)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,t)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},e.provider))})]})});return r?(0,x.jsx)(F,{title:a,titleId:o,children:s}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":o,children:[(0,x.jsx)(`h3`,{id:o,className:`panel-title`,children:a}),s]})}function R({summary:e,t,workspace:n=!1}){let r=t(`usage.section.coverage`),i=`usage-coverage-title`,a=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.reported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.reportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.estimated`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.estimatedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unreported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unreportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unsupported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unsupportedRequests})]})]}),(0,x.jsx)(`p`,{className:`muted text-control`,style:{marginTop:12},children:t(`usage.coverage.note`)})]});return n?(0,x.jsx)(F,{title:r,titleId:i,children:a}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":i,children:[(0,x.jsx)(`h3`,{id:i,className:`panel-title`,children:r}),a]})}function z({data:e,heatmap:t,weekBars:n,activeDays:r,filteredModels:i,modelQuery:a,onModelQuery:s,sortedProviders:c,range:l,locale:u,t:d}){let f=!!e&&e.summary.requests===0,p=[{id:`overview`,label:d(`usage.section.overview`),meta:e?`${e.summary.requests}`:`—`,body:e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(M,{summary:e.summary,activeDays:r,locale:u,t:d}),(0,x.jsx)(P,{range:l,heatmap:t,weekBars:n,locale:u,t:d})]}):null},{id:`models`,label:d(`usage.section.models`),meta:e?`${e.models.length}`:`—`,body:e?(0,x.jsx)(I,{models:i,modelQuery:a,onModelQuery:s,locale:u,t:d,workspace:!0}):null},{id:`providers`,label:d(`usage.section.providers`),meta:e?`${e.providers.length}`:`—`,body:e?(0,x.jsx)(L,{providers:c,locale:u,t:d,workspace:!0}):null},{id:`coverage`,label:d(`usage.section.coverage`),meta:e?S(e.summary.coverageRatio):`—`,body:e?(0,x.jsx)(R,{summary:e.summary,t:d,workspace:!0}):null}];return(0,x.jsx)(`div`,{className:`usage-workspace-shell`,children:(0,x.jsxs)(`div`,{className:`usage-workspace-root`,children:[(0,x.jsx)(g,{scope:`usage`,ariaLabel:d(`usage.workspace.sections`),items:p.map(e=>({id:e.id,label:e.label,meta:e.meta}))}),(0,x.jsx)(`section`,{className:`usage-workspace-main`,"aria-label":d(`usage.workspace.report`),children:f?(0,x.jsx)(o,{title:d(`usage.empty`)}):p.map(e=>(0,x.jsx)(`div`,{id:h(`usage`,e.id),className:`usw-body usw-section-block`,children:e.body},e.id))})]})})}var B=new Map;function V(e,t,n){return`ocx.usage.v1:${e}:${t}:${n}`}function H(e,t,n){let r=V(e,t,n);return B.get(r)??u(r)}function U(e,t,n,r){let i=V(e,t,n);B.set(i,r),l(i,r)}function W({apiBase:e}){let{t,locale:n}=r(),[i,o]=(0,y.useState)(`30d`),[s,c]=(0,y.useState)(`all`),[l,u]=(0,y.useState)(``),d=(0,y.useCallback)(async t=>{let n=await fetch(`${e}/api/usage?range=${i}&surface=${s}`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let r=await n.json();return U(e,i,s,r),r},[e,i,s]),f=V(e,i,s),h=H(e,i,s),g=p(f,[e,i,s],d,{isEmpty:()=>!1,initialData:h??void 0}),{state:_}=g,v=_.data??h??null,b=(0,y.useMemo)(()=>A(v?.days??[],n),[v?.days,n]),S=(0,y.useMemo)(()=>w(v?.days??[]),[v?.days]),C=(0,y.useMemo)(()=>(v?.days??[]).filter(e=>e.requests>0).length,[v?.days]),T=(0,y.useMemo)(()=>{let e=l.trim().toLowerCase(),t=(v?.models??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens);return e?t.filter(t=>t.model.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)||(t.resolvedModel??``).toLowerCase().includes(e)).slice(0,100):t.slice(0,100)},[v?.models,l]),E=(0,y.useMemo)(()=>(v?.providers??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens),[v?.providers]);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`page-head usage-head`,children:[(0,x.jsx)(`h2`,{id:`usage-page-title`,children:t(`usage.title`)}),(0,x.jsx)(j,{surface:s,range:i,onSurface:c,onRange:o,t})]}),(0,x.jsx)(`p`,{className:`page-sub`,children:t(`usage.subtitle`)}),_.showSkeleton&&!v?(0,x.jsx)(m,{label:t(`usage.loading`),rows:5}):_.kind===`failed-cold`?(0,x.jsxs)(a,{tone:`err`,children:[_.error instanceof Error?`${t(`usage.loadError`)} ${_.error.message}`:t(`usage.loadError`),` `,(0,x.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>g.refresh(),children:t(`common.retry`)})]}):(0,x.jsxs)(x.Fragment,{children:[_.showError&&(0,x.jsx)(a,{tone:`err`,children:t(`usage.loadError`)}),v?.historyTruncated&&(0,x.jsx)(a,{tone:`warn`,children:(()=>{let e=G(v.snapshotWindowStart),n=G(v.snapshotWindowEnd);return e!==null&&n!==null?t(`usage.historyTruncatedWindow`,{start:e,end:n}):t(`usage.historyTruncated`)})()}),(0,x.jsx)(z,{data:v,heatmap:b,weekBars:S,activeDays:C,filteredModels:T,modelQuery:l,onModelQuery:u,sortedProviders:E,range:i,locale:n,t})]})]})}function G(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():null}export{W as default};
@@ -0,0 +1 @@
1
+ import{m as e,s as t}from"./shared-BdYGV-yJ.js";var n=e();function r(e){let{t:r}=t();return e.state===`stale`?(0,n.jsxs)(`div`,{className:`codex-stale-banner`,role:`status`,children:[(0,n.jsx)(`span`,{className:`codex-stale-banner-text`,children:r(`models.staleBanner`)}),(0,n.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:e.controller.restarting,onClick:()=>{e.controller.restart()},children:e.controller.restarting?r(`dash.codexRestarting`):r(`dash.codexRestart`)})]}):null}export{r as t};
@@ -1 +1 @@
1
- import{m as e}from"./shared-p0R307IX.js";var t=e();function n({className:e,style:n}){return(0,t.jsx)(`span`,{"aria-hidden":`true`,className:e?`data-surface-skeleton__block ${e}`:`data-surface-skeleton__block`,style:n})}function r({label:e,rows:r=3,className:i}){let a=Math.max(1,Math.floor(r));return(0,t.jsxs)(`div`,{className:i?`data-surface-skeleton ${i}`:`data-surface-skeleton`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"aria-busy":`true`,children:[(0,t.jsx)(`span`,{className:`sr-only`,children:e}),Array.from({length:a},(e,r)=>(0,t.jsx)(`div`,{className:`data-surface-skeleton__row`,"aria-hidden":`true`,children:(0,t.jsx)(n,{})},r))]})}function i({children:e,busy:n=!0,live:r=!0,className:i}){return(0,t.jsxs)(`div`,{className:i?`data-surface-status ${i}`:`data-surface-status`,role:r?`status`:void 0,"aria-live":r?`polite`:void 0,"aria-atomic":r?`true`:void 0,"aria-busy":n||void 0,children:[n&&(0,t.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),(0,t.jsx)(`span`,{children:e})]})}export{i as n,r as t};
1
+ import{m as e}from"./shared-BdYGV-yJ.js";var t=e();function n({className:e,style:n}){return(0,t.jsx)(`span`,{"aria-hidden":`true`,className:e?`data-surface-skeleton__block ${e}`:`data-surface-skeleton__block`,style:n})}function r({label:e,rows:r=3,className:i}){let a=Math.max(1,Math.floor(r));return(0,t.jsxs)(`div`,{className:i?`data-surface-skeleton ${i}`:`data-surface-skeleton`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"aria-busy":`true`,children:[(0,t.jsx)(`span`,{className:`sr-only`,children:e}),Array.from({length:a},(e,r)=>(0,t.jsx)(`div`,{className:`data-surface-skeleton__row`,"aria-hidden":`true`,children:(0,t.jsx)(n,{})},r))]})}function i({children:e,busy:n=!0,live:r=!0,className:i}){return(0,t.jsxs)(`div`,{className:i?`data-surface-status ${i}`:`data-surface-status`,role:r?`status`:void 0,"aria-live":r?`polite`:void 0,"aria-atomic":r?`true`:void 0,"aria-busy":n||void 0,children:[n&&(0,t.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),(0,t.jsx)(`span`,{children:e})]})}export{i as n,r as t};
@@ -1 +1 @@
1
- import{_ as e,h as t}from"./shared-p0R307IX.js";import{g as n,m as r,xt as i}from"./index-WNYAjf83.js";var a=e(t(),1);function o(e,t,n){if(!n)return{kind:`disabled`,data:void 0,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1};let r=e.data!==void 0,i=!e.lastAttemptOk&&e.error!==void 0;return e.refreshing?r?{kind:`loading-with-stale-data`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!0,showError:i}:{kind:i?`retrying-cold`:`cold`,data:void 0,error:i?e.error:void 0,showSkeleton:!0,refreshing:!0,showError:!1}:i?r?{kind:`failed-with-stale`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:{kind:`failed-cold`,data:void 0,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:r?{kind:t(e.data)?`ready-empty`:`ready-populated`,data:e.data,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1}:{kind:`cold`,data:void 0,error:void 0,showSkeleton:!0,refreshing:!1,showError:!1}}function s(e,t,s,c){let{isEmpty:l,sessionCacheKey:u,...d}=c,f=(0,a.useMemo)(()=>u?r(u):null,[u]),p=(0,a.useCallback)(async e=>{let t=await s(e);return u&&n(u,t),t},[s,u]),m=i(e,t,p,{...d,...u?{initialData:d.initialData??f?.data,initialDataCachedAt:d.initialDataCachedAt??f?.cachedAt??null}:{}});return{...m,state:o(m,l,c.enabled!==!1)}}export{s as t};
1
+ import{_ as e,h as t}from"./shared-BdYGV-yJ.js";import{g as n,m as r,xt as i}from"./index-Bs27ITj_.js";var a=e(t(),1);function o(e,t,n){if(!n)return{kind:`disabled`,data:void 0,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1};let r=e.data!==void 0,i=!e.lastAttemptOk&&e.error!==void 0;return e.refreshing?r?{kind:`loading-with-stale-data`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!0,showError:i}:{kind:i?`retrying-cold`:`cold`,data:void 0,error:i?e.error:void 0,showSkeleton:!0,refreshing:!0,showError:!1}:i?r?{kind:`failed-with-stale`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:{kind:`failed-cold`,data:void 0,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:r?{kind:t(e.data)?`ready-empty`:`ready-populated`,data:e.data,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1}:{kind:`cold`,data:void 0,error:void 0,showSkeleton:!0,refreshing:!1,showError:!1}}function s(e,t,s,c){let{isEmpty:l,sessionCacheKey:u,...d}=c,f=(0,a.useMemo)(()=>u?r(u):null,[u]),p=(0,a.useCallback)(async e=>{let t=await s(e);return u&&n(u,t),t},[s,u]),m=i(e,t,p,{...d,...u?{initialData:d.initialData??f?.data,initialDataCachedAt:d.initialDataCachedAt??f?.cachedAt??null}:{}});return{...m,state:o(m,l,c.enabled!==!1)}}export{s as t};