@coreplane/switchboard 1.229.0 → 1.231.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/config/config.example.yaml +10 -0
- package/dist/assets/deploy/cloudflare-memory/worker.ts +56 -29
- package/dist/assets/deploy/cloudflare-resident/worker.ts +39 -20
- package/dist/assets/package-lock.json +6 -3
- package/dist/assets/package.json +2 -1
- package/dist/assets/source.json +3 -3
- package/dist/assets/src/core/authz/actor.ts +24 -6
- package/dist/assets/src/core/coordinator/contract.ts +41 -14
- package/dist/assets/src/core/coordinator/driver.ts +4 -0
- package/dist/assets/src/core/runEvents.ts +22 -5
- package/dist/assets/src/core/runFriction.ts +4 -3
- package/dist/assets/src/core/runLedger/sessionLog.ts +13 -0
- package/dist/assets/src/core/runRecord.ts +33 -0
- package/dist/assets/src/core/ship/contract.ts +35 -29
- package/dist/assets/src/core/ship/coordinator.ts +89 -4
- package/dist/assets/src/core/trace/attrs.ts +3 -0
- package/dist/assets/src/core/trace/streamSpans.ts +4 -1
- package/dist/assets/src/execution/residentRebind.ts +27 -4
- package/dist/assets/web/dist/.vite/manifest.json +19 -19
- package/dist/assets/web/dist/assets/CostsPage-D-v8am88.js +2 -0
- package/dist/assets/web/dist/assets/{ResidentDetailPage-CkVYktwT.js → ResidentDetailPage-Df6D2emM.js} +1 -1
- package/dist/assets/web/dist/assets/{ResidentsIndexPage-BLanxf27.js → ResidentsIndexPage-B0yECe2z.js} +1 -1
- package/dist/assets/web/dist/assets/{RunRoutePage-U3nwL8Df.js → RunRoutePage-D4FG8JbC.js} +4 -4
- package/dist/assets/web/dist/assets/{RunsIndexPage-DrIVxmpl.js → RunsIndexPage-qxjCAVwQ.js} +1 -1
- package/dist/assets/web/dist/assets/{ScheduledPage-DpqubmIm.js → ScheduledPage-B0xQSZIS.js} +1 -1
- package/dist/assets/web/dist/assets/{StatusDot-BpD9MRge.js → StatusDot-D-h9p7Iv.js} +1 -1
- package/dist/assets/web/dist/assets/{Tooltip-BYv0WSrA.js → Tooltip-BuDnXjL7.js} +1 -1
- package/dist/assets/web/dist/assets/{dist-BZmA5qTt.js → dist-BjLBNLkl.js} +1 -1
- package/dist/assets/web/dist/assets/{main-C4GOEklV.js → main-BRrMt0Kr.js} +2 -2
- package/dist/cli.js +1895 -1039
- package/package.json +1 -1
- package/dist/assets/web/dist/assets/CostsPage-DQg30mHr.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreplane/switchboard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.231.0",
|
|
4
4
|
"description": "Mention it in Slack and an agent reviews the PR, ships the fix, or answers the question — on the model you choose, with its tools running where you decide.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://openswitchboard.dev",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./AppShell-lYVcj-k7.js";import{Ci as t,Lr as n,Lt as r,Vt as i,Xt as a,_n as o,ci as s,cn as c,gn as l,ir as u,ln as d,on as f,r as p,sn as m,un as h,ur as g,vi as _,wi as v,xi as y,yn as b,zr as x}from"./seed-DeKSHrt2.js";var S=`Durable Objects`,C=`Workers · storage · R2`,w=`LLM (Anthropic)`,T=(e,t=2)=>`$${e.toFixed(t)}`,E=e=>e.workersUsd+e.doRowsUsd+e.doStorageUsd+e.r2Usd+e.workflowsUsd;function ee(e){let t=[];for(let n of e.days)for(let e of Object.keys(n.containers))t.includes(e)||t.push(e);return e.days.some(e=>Object.keys(e.durableObjects).length>0)&&t.push(S),e.days.some(e=>E(e)>0)&&t.push(C),e.llmAvailable&&t.push(w),t}function D(e,t){return t===`Durable Objects`?Object.values(e.durableObjects).reduce((e,t)=>e+t,0)+e.doRequestsUsd:t===`Workers · storage · R2`?E(e):t===`LLM (Anthropic)`?e.llmUsd:e.containers[t]?.total??0}var O=30.4;function te(e){let t=e.range.partialLastDay?e.days.slice(0,-1):e.days,n=e.range.partialLastDay?e.days[e.days.length-1]:void 0,r=t[t.length-1],i=t.slice(-7),a=i.length?i.reduce((e,t)=>e+t.total,0)/i.length:void 0,o=e.account.cloudUsd>0?Math.round(e.totals.cloudUsd/e.account.cloudUsd*100):0;return{...r?{yesterday:{date:r.date,total:r.total}}:{},...n?{today:{date:n.date,total:n.total}}:{},...a===void 0?{}:{avg7:a},projection:j(e,t,n),llm:{range:e.totals.llmUsd,...r?{yesterday:r.llmUsd}:{},...n?{today:{usd:n.llmUsd,estimated:n.llmEstimated}}:{}},accountShare:o}}var k=e=>e.reduce((e,t)=>e+t,0)/e.length;function A(e,t){let n=Date.parse(`${t.date}T00:00:00Z`),r=(e.generatedAt-n)/864e5;return Math.min(1,Math.max(1/24,Number.isFinite(r)?r:1))}function j(e,t,n){let r=n?A(e,n):1,i=t.slice(-7),a=0,o=`full-days`;i.length?a=k(i.map(e=>e.cloudUsd)):n&&(a=n.cloudUsd/r,o=`today`);let s=0,c=`none`,l=0;if(e.llmAvailable){let e=t.findIndex(e=>e.llmUsd>0),i=e===-1?[]:t.slice(e).slice(-7);i.length?(s=k(i.map(e=>e.llmUsd)),c=`closed-days`,l=i.length):n&&n.llmUsd>0&&(s=n.llmUsd/r,c=`today`)}return{monthUsd:(a+s)*O,cloudRate:a,llmRate:s,cloudBasis:o,llmBasis:c,llmClosedDays:l}}function ne(e){let t=`https://dash.cloudflare.com/${e.account.id}`;return{account:t,billing:`${t}/billing`,containers:`${t}/workers/containers`,durableObjects:`${t}/workers/durable-objects`,workers:`${t}/workers-and-pages`,r2:`${t}/r2/overview`,workflows:`${t}/workers/workflows`,worker:e=>`${t}/workers/services/view/${encodeURIComponent(e)}/production/metrics`,bucket:e=>`${t}/r2/default/buckets/${encodeURIComponent(e)}`,anthropic:`https://platform.claude.com/cost`}}var M=e=>e.account.name??`${e.account.id.slice(0,8)}…`;function N(e,t,n){let r=[`${e.date} · total ${T(e.total)}${n?` (partial day)`:``}`];for(let n of t){let t=D(e,n);t<=0||r.push(`${n} ${T(t)}${n===`LLM (Anthropic)`&&e.llmEstimated?` (estimate)`:``}`)}return r.join(`
|
|
2
|
-
`)}function P(e){let t=new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())?e:`${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getUTCMonth()]} ${t.getUTCDate()}`}function F(e,t,n){let r=t.map(t=>({series:t,usd:D(e,t),estimated:t===`LLM (Anthropic)`&&e.llmEstimated})).filter(e=>e.usd>0).sort((e,t)=>t.usd-e.usd);return{date:e.date,label:P(e.date),partial:n,total:e.total,rows:r}}function I(e,t){let n={t:12,r:12,b:30,l:48},r=960-n.l-n.r,i=260-n.t-n.b,a=e.days,o=Math.max(1e-9,...a.map(e=>e.total))*1.08,s=r/Math.max(1,a.length),c=Math.min(10,s*.28),l=e=>n.t+i-e/o*i,u=Array.from({length:5},(e,t)=>{let n=o/4*t;return{y:Number(l(n).toFixed(1)),label:T(n)}}),d=[],f=[],p=[];return a.forEach((r,o)=>{let u=0,m=n.l+o*s+c/2,h=s-c;f.push({x:Number((n.l+o*s).toFixed(1)),y:n.t,width:Number(s.toFixed(1)),height:i,title:N(r,t,e.range.partialLastDay&&o===a.length-1),tip:F(r,t,e.range.partialLastDay&&o===a.length-1)}),t.forEach((e,t)=>{let n=D(r,e);if(n<=0)return;let i=l(u+n),a=l(u),o=Math.max(0,a-i-2);d.push({seriesIndex:t,x:Number(m.toFixed(1)),y:Number(i.toFixed(1)),width:Number(h.toFixed(1)),height:Number(o.toFixed(1))}),u+=n}),(a.length<=16||o%Math.ceil(a.length/16)===0)&&p.push({x:Number((m+h/2).toFixed(1)),label:r.date.slice(5)})}),{width:960,height:260,gridLines:u,segments:d,dayHovers:f,dayLabels:p,axisY:Number(l(0).toFixed(1)),marginLeft:n.l,marginRight:n.r}}function re(e){let t=e.totals.byResource,n=[[`Memory (provisioned while awake)`,t.memory],[`vCPU (active use only)`,t.cpu],[`Durable Object duration + requests`,t.durableObjects],[`Disk (provisioned while awake)`,t.disk],[`Workers requests + CPU`,t.workers],[`Durable Object SQLite rows`,t.doRows],[`Durable Object SQLite storage`,t.doStorage],[`R2 storage + operations`,t.r2],[`Workflow steps + state`,t.workflows]],r=n.reduce((e,t)=>e+t[1],0)||1;return n.map(([e,t])=>({label:e,usd:t,percent:t/r*100}))}var L=[`fill-[#4478b8] dark:fill-[#7aa7e0]`,`fill-[#c8823b] dark:fill-[#e0a95a]`,`fill-[#4c8c57] dark:fill-[#6fae7a]`,`fill-[#b8963e] dark:fill-[#d4b45a]`,`fill-[#b0568c] dark:fill-[#d489b8]`,`fill-[#6b7bcc] dark:fill-[#98a5e6]`,`fill-[#d05252] dark:fill-[#e07a74]`,`fill-[#3e8e96] dark:fill-[#6fb9c0]`],R=[`bg-[#4478b8] dark:bg-[#7aa7e0]`,`bg-[#c8823b] dark:bg-[#e0a95a]`,`bg-[#4c8c57] dark:bg-[#6fae7a]`,`bg-[#b8963e] dark:bg-[#d4b45a]`,`bg-[#b0568c] dark:bg-[#d489b8]`,`bg-[#6b7bcc] dark:bg-[#98a5e6]`,`bg-[#d05252] dark:bg-[#e07a74]`,`bg-[#3e8e96] dark:bg-[#6fb9c0]`],z={class:`overflow-x-auto`},B=[`viewBox`],V=[`x1`,`x2`,`y1`,`y2`],H=[`x`,`y`],U=[`x`,`y`,`width`,`height`],W=[`aria-label`,`x`,`y`,`width`,`height`,`onPointerenter`,`onPointermove`],G=[`x`,`y`],K=[`x1`,`x2`,`y1`,`y2`],q={class:`tip-head mb-1.5 flex items-baseline justify-between gap-3 border-b border-muted pb-1.5`},J={class:`font-medium text-highlighted`},Y={key:0,class:`ml-1.5 font-normal text-dimmed`},X={class:`font-medium text-highlighted`},ie={class:`tip-name truncate text-muted`},ae={class:`text-highlighted`},oe={class:`tip-usd`},se={key:0,class:`ml-1 text-dimmed`},Z=256,Q=12,ce=b({__name:`CostChart`,props:{report:{},series:{}},setup(e){let n=e,r=f(()=>I(n.report,n.series)),i=e=>44+e*20,o=s(null),c=s(null);function p(e,t){let n=c.value,r=n?.getBoundingClientRect(),a=t.clientX-(r?.left??0),s=t.clientY-(r?.top??0),l=n?.clientWidth??0,u=n?.clientHeight??0,d=i(e.tip.rows.length),f=l>0&&a+Q+Z>l,p=u>0&&s+Q+d>u;o.value={x:Math.max(0,f?a-Q-Z:a+Q),y:Math.max(0,p?s-Q-d:s+Q),data:e.tip}}return(e,n)=>(u(),h(`div`,{ref_key:`host`,ref:c,class:`chart-host relative`},[m(`div`,z,[(u(),h(`svg`,{class:`block h-auto w-full font-mono`,viewBox:`0 0 ${r.value.width} ${r.value.height}`,role:`img`,"aria-label":`Daily cost, stacked by component`},[(u(!0),h(a,null,g(r.value.gridLines,(e,t)=>(u(),h(a,{key:`g${t}`},[m(`line`,{class:`stroke-(--ui-border-muted)`,x1:r.value.marginLeft,x2:r.value.width-r.value.marginRight,y1:e.y,y2:e.y},null,8,V),m(`text`,{class:`fill-(--ui-text-dimmed) text-[11px] tabular-nums`,x:r.value.marginLeft-8,y:e.y+4,"text-anchor":`end`},v(e.label),9,H)],64))),128)),(u(!0),h(a,null,g(r.value.segments,(e,t)=>(u(),h(`rect`,{key:`s${t}`,class:y([`seg hover:opacity-85`,_(L)[e.seriesIndex%_(L).length]]),x:e.x,y:e.y,width:e.width,height:e.height},null,10,U))),128)),(u(!0),h(a,null,g(r.value.dayHovers,(e,t)=>(u(),h(`rect`,{key:`h${t}`,class:`day fill-transparent`,role:`img`,"aria-label":e.title,x:e.x,y:e.y,width:e.width,height:e.height,onPointerenter:t=>p(e,t),onPointermove:t=>p(e,t),onPointerleave:n[0]||=e=>o.value=null},null,40,W))),128)),(u(!0),h(a,null,g(r.value.dayLabels,(e,t)=>(u(),h(`text`,{key:`d${t}`,class:`fill-(--ui-text-dimmed) text-[11px]`,x:e.x,y:r.value.height-10,"text-anchor":`middle`},v(e.label),9,G))),128)),m(`line`,{class:`stroke-(--ui-border)`,x1:r.value.marginLeft,x2:r.value.width-r.value.marginRight,y1:r.value.axisY,y2:r.value.axisY},null,8,K)],8,B))]),o.value?(u(),h(`div`,{key:0,class:`chart-tip pointer-events-none absolute z-10 w-64 rounded-md border border-default bg-elevated px-3 py-2 font-mono text-xs tabular-nums whitespace-nowrap shadow-lg`,role:`tooltip`,style:t({left:`${o.value.x}px`,top:`${o.value.y}px`})},[m(`div`,q,[m(`span`,J,[l(v(o.value.data.label),1),o.value.data.partial?(u(),h(`span`,Y,`partial day`)):d(``,!0)]),m(`span`,X,v(_(T)(o.value.data.total)),1)]),(u(!0),h(a,null,g(o.value.data.rows,e=>(u(),h(`div`,{key:e.series,class:`tip-row flex items-baseline justify-between gap-3 leading-5`},[m(`span`,ie,v(e.series),1),m(`span`,ae,[m(`span`,oe,v(_(T)(e.usd)),1),e.estimated?(u(),h(`span`,se,`est.`)):d(``,!0)])]))),128))],4)):d(``,!0)],512))}}),le={class:`by-user grid gap-3`},ue={class:`flex flex-wrap items-center gap-x-4 gap-y-2`},de={class:`flex items-center gap-2 text-sm text-muted`},fe=[`title`],pe=[`disabled`,`aria-describedby`],me={key:0,id:`me-hint`,class:`me-hint text-xs text-dimmed`},he={class:`coverage font-mono text-xs tabular-nums text-muted`},ge={class:`overflow-x-auto`},_e={class:`users w-full min-w-[40rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},ve=[`title`],ye={class:`text-highlighted`},be={class:`ml-1.5 text-xs text-dimmed`},xe={key:0,class:`ml-1.5 rounded-xs bg-accented px-1 text-xs text-highlighted`},Se=[`title`],Ce={class:`border-b border-muted px-2.5 py-1.5 text-right`},we={class:`border-b border-muted px-2.5 py-1.5 text-right`},Te={class:`border-b border-muted px-2.5 py-1.5 text-right`},Ee={class:`border-b border-muted px-2.5 py-1.5 text-right font-medium text-highlighted`},De={class:`border-b border-muted px-2.5 py-1.5 text-right`},Oe={key:0},ke={class:`empty px-2.5 py-3 text-sm text-muted`,colspan:`6`},Ae={key:0},je={class:`px-2.5 py-1.5 text-right text-xs text-muted`},Me={class:`px-2.5 py-1.5 text-right text-xs text-muted`},Ne={class:`reconciliation font-mono text-xs tabular-nums text-muted`},Pe=b({__name:`CostsByUser`,props:{report:{}},setup(e){let t=e,n=s(``),o=s(!1),c=f(()=>t.report.viewer.userIds.length>0),p=f(()=>{let e=n.value.trim().toLowerCase(),r=new Set(t.report.viewer.userIds);return t.report.users.filter(t=>o.value&&!r.has(t.userId)?!1:!e||t.userId.toLowerCase().includes(e)||(t.userName??``).toLowerCase().includes(e))}),b=f(()=>t.report.users.reduce((e,t)=>e+t.totalUsd,0)),S=f(()=>p.value.reduce((e,t)=>e+t.totalUsd,0)),C=e=>t.report.viewer.userIds.includes(e.userId),w=e=>e.userName??e.userId.replace(/^[a-z]+:/,``),E=e=>e.userId.split(`:`)[0]??``;return(t,s)=>(u(),h(`section`,le,[m(`div`,ue,[m(`label`,de,[s[2]||=m(`span`,null,`Filter`,-1),x(m(`input`,{"onUpdate:modelValue":s[0]||=e=>n.value=e,class:`user-filter rounded-md border border-default bg-elevated px-2.5 py-1 font-mono text-xs text-highlighted`,type:`search`,placeholder:`name or id`,"aria-label":`Filter users`},null,512),[[i,n.value]])]),m(`label`,{class:y([`me-toggle flex items-center gap-2 text-sm`,c.value?`text-muted`:`text-dimmed`]),title:c.value?`Only your own runs`:void 0},[x(m(`input`,{"onUpdate:modelValue":s[1]||=e=>o.value=e,type:`checkbox`,disabled:!c.value,"aria-label":`Only me`,"aria-describedby":c.value?void 0:`me-hint`},null,8,pe),[[r,o.value]]),s[3]||=m(`span`,null,`me`,-1),c.value?d(``,!0):(u(),h(`span`,me,`— your sign-in email matched no Slack user in this range`))],10,fe),m(`p`,he,[e.report.coverage.historyOn?(u(),h(a,{key:1},[l(` runs from `+v(_(P)(e.report.coverage.from))+` to `+v(_(P)(e.report.range.to)),1),e.report.coverage.clamped?(u(),h(a,{key:0},[l(` · earlier days are past the history's `+v(e.report.coverage.retentionDays)+`-day window`,1)],64)):d(``,!0),e.report.pending>0?(u(),h(a,{key:1},[l(` · `+v(e.report.pending)+` run`+v(e.report.pending===1?``:`s`)+` still being priced`,1)],64)):d(``,!0)],64)):(u(),h(a,{key:0},[l(`run history is off — no runs to attribute`)],64))])]),m(`div`,ge,[m(`table`,_e,[s[5]||=m(`thead`,null,[m(`tr`,null,[m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-left text-xs font-medium text-muted`},` User `),m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` Runs `),m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` LLM `),m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},[l(` Cloud `),m(`span`,{class:`font-normal text-dimmed`},`allocated`)]),m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` Total `),m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` Share `)])],-1),m(`tbody`,null,[(u(!0),h(a,null,g(p.value,e=>(u(),h(`tr`,{key:e.userId,class:y([`user-row`,C(e)?`is-me`:``])},[m(`td`,{class:`border-b border-muted px-2.5 py-1.5`,title:e.userId},[m(`span`,ye,v(w(e)),1),m(`span`,be,v(E(e)),1),C(e)?(u(),h(`span`,xe,`me`)):d(``,!0),e.unpricedTokens>0?(u(),h(`span`,{key:1,class:`ml-1.5 text-xs text-warn`,title:`${e.unpricedTokens} tokens ran under a model with no list price`},`unpriced tokens`,8,Se)):d(``,!0)],8,ve),m(`td`,Ce,v(e.runs),1),m(`td`,we,v(_(T)(e.llmUsd)),1),m(`td`,Te,v(_(T)(e.cloudUsd)),1),m(`td`,Ee,v(_(T)(e.totalUsd)),1),m(`td`,De,v(b.value>0?Math.round(e.totalUsd/b.value*100):0)+`% `,1)],2))),128)),p.value.length===0?(u(),h(`tr`,Oe,[m(`td`,ke,v(e.report.users.length===0?`no runs in this range`:`no user matches`),1)])):d(``,!0)]),p.value.length>0&&p.value.length<e.report.users.length?(u(),h(`tfoot`,Ae,[m(`tr`,null,[s[4]||=m(`td`,{class:`px-2.5 py-1.5 text-xs text-muted`,colspan:`4`},`shown`,-1),m(`td`,je,v(_(T)(S.value)),1),m(`td`,Me,v(b.value>0?Math.round(S.value/b.value*100):0)+`% `,1)])])):d(``,!0)])]),m(`p`,Ne,[l(` LLM attributed `+v(_(T)(e.report.reconciliation.attributedLlmUsd))+` of `+v(_(T)(e.report.reconciliation.workspaceLlmUsd))+` on the workspace · `+v(_(T)(e.report.reconciliation.unattributedLlmUsd))+` unattributed (router, review abridges, runs without a record, list vs invoice) · cloud allocated `+v(_(T)(e.report.reconciliation.cloudAllocatedUsd)),1),e.report.reconciliation.cloudUnallocatedUsd>0?(u(),h(a,{key:0},[l(` · `+v(_(T)(e.report.reconciliation.cloudUnallocatedUsd))+` on days with no runs`,1)],64)):d(``,!0)]),s[6]||=m(`p`,{class:`text-xs text-dimmed`},` A user's LLM is their runs' tokens at Anthropic list (cache writes at the 5-minute rate); a child run bills to whoever started its parent. Cloud is each day's Cloudflare spend split by share of run wall-clock — an allocation, not a meter. `,-1)]))}}),Fe={class:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-2`},Ie={class:`flex items-center gap-1`,"aria-label":`Range`},Le={key:0,class:`rounded-md bg-accented px-2.5 py-1 font-mono text-xs font-medium tabular-nums text-highlighted`,"aria-current":`page`},Re=[`href`],ze={key:0,class:`flex items-center gap-1`,"aria-label":`Cost groups`},Be={key:0,class:`rounded-md bg-accented px-2.5 py-1 text-xs font-medium text-highlighted`,"aria-current":`page`},Ve=[`href`],He={class:`font-mono text-sm tabular-nums text-muted`},Ue={class:`mb-5 grid grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-3`},We={key:0,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},Ge={class:`font-mono text-2xl font-medium tabular-nums`},Ke={class:`text-xs text-muted`},qe={key:1,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},Je={class:`font-mono text-2xl font-medium tabular-nums`},Ye={class:`text-xs text-muted`},Xe={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},Ze={class:`font-mono text-2xl font-medium tabular-nums`},Qe={class:`text-xs text-muted`},$e={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},et={class:`font-mono text-2xl font-medium tabular-nums`},tt={class:`text-xs text-muted`},nt={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},rt={class:`font-mono text-2xl font-medium tabular-nums`},it={class:`text-xs text-muted`},at={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},ot={class:`font-mono text-2xl font-medium tabular-nums`},st={class:`text-xs text-muted`},ct=[`href`,`title`],lt=[`href`],ut={class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},dt={class:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-2`},ft={class:`legend flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted`},pt=[`href`,`title`],mt={key:0,class:`text-xs text-warn`},ht={key:1,class:`text-xs text-muted`},gt={class:`mb-3 flex items-center gap-1 border-b border-default`,"aria-label":`View`},_t={key:0,class:`-mb-px border-b-2 border-primary px-3 py-1.5 text-sm font-medium text-highlighted`,"aria-current":`page`},vt=[`href`],yt={key:0,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},bt={key:1,class:`text-sm text-warn`},xt={class:`text-xs text-muted`},St={class:`rounded bg-accented px-1 py-0.5`},Ct={key:1,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},wt={class:`w-full border-collapse font-mono text-[0.8125rem] tabular-nums`},Tt={class:`px-2.5 py-1.5`},Et=[`href`],Dt={class:`px-2.5 py-1.5 text-right`},Ot={class:`px-2.5 py-1.5 text-right`},kt={class:`w-2/5 px-2.5 py-1.5`},At={key:2,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},jt={open:``},Mt={class:`mt-2.5 overflow-x-auto`},Nt={class:`data w-full min-w-[38rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},$=[`title`],Pt={key:0,class:`text-xs text-dimmed`},Ft={key:1,class:`text-xs text-dimmed`},It={class:`border-b border-muted px-2.5 py-1.5 text-right font-medium`},Lt={class:`text-xs text-muted`},Rt={class:`rounded bg-accented px-1 py-0.5`},zt={class:`border-t border-default pt-3.5 text-xs text-dimmed`},Bt={class:`mt-2 grid gap-1.5`},Vt=[`href`],Ht={key:2},Ut=[`href`],Wt={key:2},Gt=[`href`],Kt=[`href`],qt=b({__name:`CostsPage`,setup(r){let i=p(`costs`),s=f(()=>i?.report??null),b=f(()=>i?.groups??[]),x=f(()=>i?.view??`daily`),S=f(()=>x.value===`users`?i?.users??null:null);function C(e,t,n){let r=[`days=${t}`];return n===`users`&&r.push(`view=users`),`/costs/${e}?${r.join(`&`)}`}let w=f(()=>s.value?ee(s.value):[]),E=f(()=>s.value?te(s.value):null),O=f(()=>s.value?re(s.value):[]),k=f(()=>s.value?ne(s.value):null),A=f(()=>s.value?M(s.value):``);function j(e){let t=k.value;if(t){if(/^(Memory|vCPU|Disk)/.test(e))return t.containers;if(e.startsWith(`Durable Object`))return t.durableObjects;if(e.startsWith(`Workers`))return t.workers;if(e.startsWith(`R2`))return t.r2;if(e.startsWith(`Workflow`))return t.workflows}}function N(e){let t=k.value;if(t)return e===`LLM (Anthropic)`?t.anthropic:e===`Durable Objects`?t.durableObjects:e===`Workers · storage · R2`?t.workers:t.containers}let P=f(()=>{let e=s.value,t=E.value;if(!e||!t)return``;let n=t.projection,r=`cloud ${T(n.cloudRate)}/day`,i=n.cloudBasis===`today`?`cloud from today so far`:`cloud from the last 7 full days`;if(!e.llmAvailable)return`${r} × 30.4 · ${i} · before plan fees and included allowances`;let a=`LLM ${T(n.llmRate)}/day`,o=n.llmBasis===`closed-days`?`LLM from ${n.llmClosedDays} closed day${n.llmClosedDays===1?``:`s`}`:n.llmBasis===`today`?`LLM from today so far`:`no LLM spend in range`;return`${r} + ${a} · × 30.4 · ${n.cloudBasis===`today`&&n.llmBasis===`today`?`both from today so far`:`${i} · ${o}`}`}),F=f(()=>s.value?[...s.value.days].reverse():[]),I=[1,7,30,90],L=e=>e===1?`today`:`${e}d`,z=f(()=>{let e=s.value,t=E.value;if(!e||!t)return``;if(!e.llmAvailable)return`LLM spend not configured`;let n=[];return t.llm.yesterday!==void 0&&n.push(`yesterday ${T(t.llm.yesterday)}`),t.llm.today&&n.push(`today ${T(t.llm.today.usd)}${t.llm.today.estimated?` (estimate)`:``}`),n.length?n.join(` · `):`in range`});function B(e){let t=new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())?e:`${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getUTCMonth()]} ${t.getUTCDate()}`}return(r,i)=>s.value&&E.value?(u(),c(e,{key:0,title:`${s.value.label} spend`,nav:`costs`},{default:n(()=>[m(`div`,Fe,[m(`nav`,Ie,[(u(),h(a,null,g(I,e=>(u(),h(a,{key:e},[e===s.value.range.days?(u(),h(`span`,Le,v(L(e)),1)):(u(),h(`a`,{key:1,class:`rounded-md px-2.5 py-1 font-mono text-xs tabular-nums text-muted no-underline hover:bg-elevated hover:text-highlighted`,href:C(s.value.group,e,x.value)},v(L(e)),9,Re))],64))),64))]),b.value.length>1?(u(),h(`nav`,ze,[(u(!0),h(a,null,g(b.value,e=>(u(),h(a,{key:e},[e===s.value.group?(u(),h(`span`,Be,v(e),1)):(u(),h(`a`,{key:1,class:`rounded-md px-2.5 py-1 text-xs text-muted no-underline hover:bg-elevated hover:text-highlighted`,href:C(e,s.value.range.days,x.value)},v(e),9,Ve))],64))),128))])):d(``,!0),m(`p`,He,[l(v(B(s.value.range.from))+` → `+v(B(s.value.range.to))+` · `+v(s.value.range.days)+`d`,1),s.value.range.partialLastDay?(u(),h(a,{key:0},[l(` · today partial`)],64)):d(``,!0)])]),m(`section`,Ue,[E.value.yesterday?(u(),h(`div`,We,[i[0]||=m(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Yesterday`,-1),m(`span`,Ge,v(_(T)(E.value.yesterday.total)),1),m(`span`,Ke,v(E.value.yesterday.date)+` · last full day`,1)])):(u(),h(`div`,qe,[i[1]||=m(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Today so far`,-1),m(`span`,Je,v(E.value.today?_(T)(E.value.today.total):`—`),1),m(`span`,Ye,v(E.value.today?`${E.value.today.date} · partial day, UTC`:`no day in range`),1)])),m(`div`,Xe,[i[2]||=m(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`7-day average`,-1),m(`span`,Ze,v(E.value.avg7===void 0?`—`:_(T)(E.value.avg7)),1),m(`span`,Qe,v(E.value.avg7===void 0?`no full day yet in this range`:`per day, full days only`),1)]),m(`div`,$e,[i[3]||=m(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Projected month`,-1),m(`span`,et,v(_(T)(E.value.projection.monthUsd,0)),1),m(`span`,tt,v(P.value),1)]),m(`div`,nt,[i[4]||=m(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`LLM spend`,-1),m(`span`,rt,v(s.value.llmAvailable?_(T)(E.value.llm.range):`—`),1),m(`span`,it,v(z.value),1)]),m(`div`,at,[i[6]||=m(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Share of account`,-1),m(`span`,ot,v(E.value.accountShare)+`%`,1),m(`span`,st,[l(v(_(T)(s.value.totals.cloudUsd))+` of `+v(_(T)(s.value.account.cloudUsd))+` on `,1),k.value?(u(),h(`a`,{key:0,class:`text-primary hover:underline`,href:k.value.account,target:`_blank`,rel:`noopener noreferrer`,title:`Cloudflare account ${s.value.account.id}`},v(A.value),9,ct)):d(``,!0),i[5]||=l(` · Cloudflare spend in range · `,-1),k.value?(u(),h(`a`,{key:1,class:`text-primary hover:underline`,href:k.value.billing,target:`_blank`,rel:`noopener noreferrer`},`billing`,8,lt)):d(``,!0)])])]),m(`section`,ut,[m(`div`,dt,[i[7]||=m(`div`,null,[m(`h2`,{class:`text-[0.9375rem] font-medium`},`Daily cost`),m(`p`,{class:`text-sm text-muted`},`Stacked by component · USD list price`)],-1),m(`div`,ft,[(u(!0),h(a,null,g(w.value,(e,t)=>(u(),h(`a`,{key:e,class:`inline-flex items-center gap-1.5 no-underline hover:text-highlighted hover:underline`,href:N(e),target:`_blank`,rel:`noopener noreferrer`,title:`Open where ${e} is billed`},[m(`i`,{class:y([`inline-block size-2.5 rounded-xs`,_(R)[t%_(R).length]])},null,2),l(v(e),1)],8,pt))),128))])]),o(ce,{report:s.value,series:w.value},null,8,[`report`,`series`]),s.value.llmAvailable?s.value.days.some(e=>e.llmEstimated)?(u(),h(`p`,ht,[i[9]||=l(` A day the Anthropic cost report has not closed yet (today, and yesterday until a few hours after midnight UTC) shows its LLM figure as an estimate: the hourly usage report priced at list. The closed days are the cost report itself. `,-1),s.value.days.some(e=>e.llmUnpricedTokens>0)?(u(),h(a,{key:0},[l(` Some tokens ran under a model this page has no price for and are not in the estimate. `)],64)):d(``,!0)])):d(``,!0):(u(),h(`p`,mt,[...i[8]||=[l(` LLM spend not configured — set `,-1),m(`code`,null,`ANTHROPIC_ADMIN_KEY`,-1),l(` and the group's `,-1),m(`code`,null,`anthropicWorkspaceId`,-1),l(` to layer it in. `,-1)]]))]),m(`nav`,gt,[(u(),h(a,null,g([`daily`,`users`],e=>(u(),h(a,{key:e},[e===x.value?(u(),h(`span`,_t,v(e===`daily`?`Daily`:`By user`),1)):(u(),h(`a`,{key:1,class:`-mb-px border-b-2 border-transparent px-3 py-1.5 text-sm text-muted no-underline hover:border-muted hover:text-highlighted`,href:C(s.value.group,s.value.range.days,e)},v(e===`daily`?`Daily`:`By user`),9,vt))],64))),64))]),x.value===`users`?(u(),h(`section`,yt,[i[12]||=m(`div`,null,[m(`h2`,{class:`text-[0.9375rem] font-medium`},`Cost by user`),m(`p`,{class:`text-sm text-muted`},` Who started the runs · LLM at list from their tokens · cloud allocated by wall-clock `)],-1),S.value?(u(),c(Pe,{key:0,report:S.value},null,8,[`report`])):(u(),h(`p`,bt,`The by-user report did not load with this page.`)),m(`p`,xt,[i[10]||=l(` Machine-readable twin: `,-1),m(`code`,St,`GET /costs/`+v(s.value.group)+`/users.json`,1),i[11]||=l(` (same Access gate). `,-1)])])):d(``,!0),x.value===`daily`?(u(),h(`section`,Ct,[i[13]||=m(`div`,null,[m(`h2`,{class:`text-[0.9375rem] font-medium`},`What each cloud dollar buys`)],-1),m(`table`,wt,[m(`tbody`,null,[(u(!0),h(a,null,g(O.value,e=>(u(),h(`tr`,{key:e.label,class:`border-b border-muted`},[m(`td`,Tt,[j(e.label)?(u(),h(`a`,{key:0,class:`no-underline hover:text-highlighted hover:underline`,href:j(e.label),target:`_blank`,rel:`noopener noreferrer`,title:`Open where this is billed on Cloudflare`},v(e.label),9,Et)):(u(),h(a,{key:1},[l(v(e.label),1)],64))]),m(`td`,Dt,v(_(T)(e.usd)),1),m(`td`,Ot,v(Math.round(e.percent))+`%`,1),m(`td`,kt,[m(`i`,{class:`block h-2.5 rounded-xs bg-primary opacity-75`,style:t({width:`${e.percent.toFixed(1)}%`})},null,4)])]))),128))])])])):d(``,!0),x.value===`daily`?(u(),h(`section`,At,[m(`details`,jt,[i[16]||=m(`summary`,{class:`cursor-pointer text-sm text-muted`},`Table view — daily cost by component (USD)`,-1),m(`div`,Mt,[m(`table`,Nt,[m(`thead`,null,[m(`tr`,null,[i[14]||=m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-left text-xs font-medium text-muted`},` Date `,-1),(u(!0),h(a,null,g(w.value,e=>(u(),h(`th`,{key:e,class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},v(e),1))),128)),i[15]||=m(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` Total `,-1)])]),m(`tbody`,null,[(u(!0),h(a,null,g(F.value,e=>(u(),h(`tr`,{key:e.date},[m(`td`,{class:`border-b border-muted px-2.5 py-1.5`,title:e.date},[l(v(B(e.date))+` `,1),s.value.range.partialLastDay&&e.date===s.value.range.to?(u(),h(`span`,Pt,`(partial day`+v(e.llmEstimated?` · LLM estimated`:``)+`)`,1)):e.llmEstimated?(u(),h(`span`,Ft,`(LLM estimated)`)):d(``,!0)],8,$),(u(!0),h(a,null,g(w.value,t=>(u(),h(`td`,{key:t,class:`border-b border-muted px-2.5 py-1.5 text-right`},v(_(T)(_(D)(e,t),3)),1))),128)),m(`td`,It,v(_(T)(e.total,3)),1)]))),128))])])])]),m(`p`,Lt,[i[17]||=l(` Machine-readable twin: `,-1),m(`code`,Rt,`GET /costs/`+v(s.value.group)+`.json`,1),i[18]||=l(` (same Access gate). `,-1)])])):d(``,!0),m(`footer`,zt,[m(`details`,null,[i[26]||=m(`summary`,{class:`cursor-pointer text-muted`},`How these numbers are computed`,-1),m(`div`,Bt,[i[24]||=m(`div`,null,[m(`b`,null,`Live.`),l(` Both billing sources are read live from this page — nothing cached, nothing stored. Cloudflare bills vCPU on active use only; memory and disk bill on the provisioned size for every second a container is awake. LLM spend is the Anthropic Admin API cost report for this group's workspace (gross, USD); a day the cost report has not closed is the Admin API usage report, hourly, priced at Anthropic list per model (input, output, cache writes, cache reads) and marked as an estimate. `)],-1),i[25]||=m(`div`,null,[m(`b`,null,`Method.`),l(` Cloudflare GraphQL Analytics, every meter a Workers deployment is billed on: `),m(`code`,null,`containersUsageAdaptiveGroups`),l(` (cpuTimeSec, allocatedMemory, allocatedDisk per app per UTC day), `),m(`code`,null,`durableObjectsPeriodicGroups`),l(` (billable `),m(`code`,null,`duration`),l(` GB-s and SQLite rows read and written per namespace), `),m(`code`,null,`durableObjectsInvocationsAdaptiveGroups`),l(` (requests per namespace), `),m(`code`,null,`durableObjectsSqlStorageGroups`),l(` (bytes stored), `),m(`code`,null,`workersInvocationsAdaptive`),l(` (requests, CPU time), `),m(`code`,null,`r2StorageAdaptiveGroups`),l(` and `),m(`code`,null,`r2OperationsAdaptiveGroups`),l(` (bytes stored, class A/B operations). Prices: vCPU $0.000020/s, memory $0.0000025/GiB-s, disk $0.00000007/GB-s, DO duration $12.50 per million GB-s, DO requests $0.15/M, SQLite rows $0.001/M read and $1.00/M written, DO storage $0.20/GB-month, Workers $0.30/M requests and $0.02/M CPU-ms, R2 $0.015/GB-month, $4.50/M class A and $0.36/M class B (deletes free). Storage is the day's peak, prorated over a 30.44-day month. Gross list price — plan fees and included allowances are not subtracted; Workers Logs volume has no analytics dataset and is not priced. `)],-1),m(`div`,null,[i[19]||=m(`b`,null,`Scope.`,-1),i[20]||=l(` Attributed to this group: the Workers `,-1),(u(!0),h(a,null,g(s.value.attribution.workers,(e,t)=>(u(),h(a,{key:e},[t>0?(u(),h(a,{key:0},[l(`, `)],64)):d(``,!0),k.value?(u(),h(`a`,{key:1,class:`font-mono hover:underline`,href:k.value.worker(e),target:`_blank`,rel:`noopener noreferrer`},v(e),9,Vt)):(u(),h(`code`,Ht,v(e),1))],64))),128)),l(`, every Durable Object namespace they host (`+v(Object.keys(s.value.attribution.durableObjectNamespaces).length)+`), the R2 buckets named after them (`,1),(u(!0),h(a,null,g(Object.keys(s.value.attribution.r2Buckets),(e,t)=>(u(),h(a,{key:e},[t>0?(u(),h(a,{key:0},[l(`, `)],64)):d(``,!0),k.value?(u(),h(`a`,{key:1,class:`font-mono hover:underline`,href:k.value.bucket(e),target:`_blank`,rel:`noopener noreferrer`},v(e),9,Ut)):(u(),h(`code`,Wt,v(e),1))],64))),128)),Object.keys(s.value.attribution.r2Buckets).length===0?(u(),h(a,{key:0},[l(`none`)],64)):d(``,!0),i[21]||=l(`), and the container apps mapped in `,-1),m(`code`,null,`costs.groups.`+v(s.value.group),1),l(` (`+v(Object.keys(s.value.attribution.containerApps).length)+`). Everything else in the account is priced the same way into the account total, which is what "share of account" divides by. Every figure above links to where it is billed: the `,1),k.value?(u(),h(`a`,{key:1,class:`hover:underline`,href:k.value.account,target:`_blank`,rel:`noopener noreferrer`},`Cloudflare dashboard`,8,Gt)):d(``,!0),i[22]||=l(` for the account `,-1),m(`code`,null,v(s.value.account.id),1),l(v(s.value.account.name?` (${s.value.account.name})`:``)+`, and `,1),k.value?(u(),h(`a`,{key:2,class:`hover:underline`,href:k.value.anthropic,target:`_blank`,rel:`noopener noreferrer`},`Anthropic's cost page`,8,Kt)):d(``,!0),i[23]||=l(` for the LLM line. `,-1)])])])])]),_:1},8,[`title`])):d(``,!0)}});export{qt as default};
|