comisai 1.0.15 → 1.0.17
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/node_modules/@comis/agent/dist/bootstrap/types.d.ts +1 -1
- package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.js +12 -11
- package/node_modules/@comis/agent/dist/context-engine/constants.d.ts +11 -0
- package/node_modules/@comis/agent/dist/context-engine/constants.js +11 -0
- package/node_modules/@comis/agent/dist/context-engine/index.d.ts +1 -1
- package/node_modules/@comis/agent/dist/context-engine/index.js +1 -1
- package/node_modules/@comis/agent/dist/context-engine/llm-compaction.js +32 -18
- package/node_modules/@comis/agent/dist/executor/cache-break-diff-writer.d.ts +2 -0
- package/node_modules/@comis/agent/dist/executor/cache-break-diff-writer.js +36 -0
- package/node_modules/@comis/agent/dist/executor/executor-post-execution.d.ts +12 -0
- package/node_modules/@comis/agent/dist/executor/executor-post-execution.js +117 -27
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.d.ts +1 -0
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +16 -4
- package/node_modules/@comis/agent/dist/executor/executor-stream-setup.js +17 -1
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +27 -1
- package/node_modules/@comis/agent/dist/executor/session-snapshot-cleanup.js +3 -1
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/index.d.ts +2 -0
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/index.js +2 -0
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.d.ts +9 -0
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.js +65 -3
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/stub-filter-injector.d.ts +28 -0
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/stub-filter-injector.js +63 -0
- package/node_modules/@comis/agent/dist/executor/tool-deferral.d.ts +18 -1
- package/node_modules/@comis/agent/dist/executor/tool-deferral.js +275 -133
- package/node_modules/@comis/agent/dist/executor/ttl-guard.d.ts +6 -0
- package/node_modules/@comis/agent/dist/executor/ttl-guard.js +8 -0
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/dist/shared/typing-controller.d.ts +7 -0
- package/node_modules/@comis/channels/dist/shared/typing-controller.js +33 -0
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/dist/commands/daemon.js +116 -28
- package/node_modules/@comis/cli/dist/wizard/non-interactive.js +1 -0
- package/node_modules/@comis/cli/dist/wizard/steps/01-detect-existing.js +4 -0
- package/node_modules/@comis/cli/dist/wizard/steps/07-gateway.js +9 -0
- package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +2 -0
- package/node_modules/@comis/cli/dist/wizard/steps/12-finish.js +5 -2
- package/node_modules/@comis/cli/dist/wizard/types.d.ts +1 -0
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/dist/config/schema-agent.d.ts +10 -0
- package/node_modules/@comis/core/dist/config/schema-agent.js +8 -0
- package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +17 -2
- package/node_modules/@comis/core/dist/config/schema-gateway.js +11 -0
- package/node_modules/@comis/core/dist/config/schema-skills.d.ts +16 -2
- package/node_modules/@comis/core/dist/config/schema-skills.js +9 -2
- package/node_modules/@comis/core/dist/config/schema.d.ts +66 -60
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +34 -6
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/package.json +1 -1
- package/node_modules/@comis/infra/package.json +1 -1
- package/node_modules/@comis/memory/package.json +1 -1
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.d.ts +1 -1
- package/node_modules/@comis/skills/package.json +1 -1
- package/node_modules/@comis/web/dist/android-chrome-192x192.png +0 -0
- package/node_modules/@comis/web/dist/android-chrome-512x512.png +0 -0
- package/node_modules/@comis/web/dist/apple-touch-icon.png +0 -0
- package/node_modules/@comis/web/dist/assets/agent-detail-BG9MGWWj.js +615 -0
- package/node_modules/@comis/web/dist/assets/agent-editor-C26Q_xCs.js +2173 -0
- package/node_modules/@comis/web/dist/assets/agent-list-LHCJ4rw2.js +504 -0
- package/node_modules/@comis/web/dist/assets/approvals-q9VH_IKr.js +54 -0
- package/node_modules/@comis/web/dist/assets/billing-view-CtYvBqTE.js +375 -0
- package/node_modules/@comis/web/dist/assets/channel-detail-CaInesJM.js +681 -0
- package/node_modules/@comis/web/dist/assets/channel-list-B8dj3O9a.js +323 -0
- package/node_modules/@comis/web/dist/assets/chat-console-CNmzl0JW.js +943 -0
- package/node_modules/@comis/web/dist/assets/config-editor-DX4ITw6y.js +1374 -0
- package/node_modules/@comis/web/dist/assets/context-dag-browser-BwiaF5tf.js +393 -0
- package/node_modules/@comis/web/dist/assets/context-engine-BZ5Am6hA.js +393 -0
- package/node_modules/@comis/web/dist/assets/delivery-view-OfBZof-m.js +392 -0
- package/node_modules/@comis/web/dist/assets/diagnostics-view-YFwCxgr2.js +231 -0
- package/node_modules/@comis/web/dist/assets/directive-DoeGSK_T.js +1 -0
- package/node_modules/@comis/web/dist/assets/extract-variables-BM5qyK-s.js +149 -0
- package/node_modules/@comis/web/dist/assets/ic-array-editor-B7m6x7-S.js +118 -0
- package/node_modules/@comis/web/dist/assets/ic-breadcrumb-CUMpp3BL.js +75 -0
- package/node_modules/@comis/web/dist/assets/ic-budget-segment-bar-BtJ6x5mN.js +64 -0
- package/node_modules/@comis/web/dist/assets/ic-chat-message-CFyDJd0z.js +352 -0
- package/node_modules/@comis/web/dist/assets/ic-confirm-dialog-CCDbB04e.js +110 -0
- package/node_modules/@comis/web/dist/assets/ic-connection-dot-CnT1b8xr.js +54 -0
- package/node_modules/@comis/web/dist/assets/ic-data-table-CKUNTxHw.js +277 -0
- package/node_modules/@comis/web/dist/assets/ic-delivery-row-GP5Fkygs.js +67 -0
- package/node_modules/@comis/web/dist/assets/ic-detail-panel-BF83r-if.js +116 -0
- package/node_modules/@comis/web/dist/assets/ic-empty-state-60l2ePhd.js +52 -0
- package/node_modules/@comis/web/dist/assets/ic-graph-canvas-C8FuSMe1.js +359 -0
- package/node_modules/@comis/web/dist/assets/ic-icon-xeGTVhVG.js +33 -0
- package/node_modules/@comis/web/dist/assets/ic-layer-waterfall-COvEYMg5.js +69 -0
- package/node_modules/@comis/web/dist/assets/ic-relative-time-3FqpjeAI.js +12 -0
- package/node_modules/@comis/web/dist/assets/ic-search-input-CSOxY9g7.js +92 -0
- package/node_modules/@comis/web/dist/assets/ic-select-Ce-Raudx.js +127 -0
- package/node_modules/@comis/web/dist/assets/ic-tabs-B7QtM_v8.js +95 -0
- package/node_modules/@comis/web/dist/assets/ic-tag-CPPUnDLF.js +33 -0
- package/node_modules/@comis/web/dist/assets/ic-time-range-picker-CypCT68y.js +93 -0
- package/node_modules/@comis/web/dist/assets/ic-tool-call-7MaXSsCW.js +146 -0
- package/node_modules/@comis/web/dist/assets/index-CEcM1R_C.js +2830 -0
- package/node_modules/@comis/web/dist/assets/index-CIJFuItj.css +1 -0
- package/node_modules/@comis/web/dist/assets/mcp-management-BNZPnpDn.js +582 -0
- package/node_modules/@comis/web/dist/assets/media-config-BBvTYxOX.js +314 -0
- package/node_modules/@comis/web/dist/assets/media-test-BkK3RCRK.js +496 -0
- package/node_modules/@comis/web/dist/assets/memory-inspector-1hDGCGat.js +1139 -0
- package/node_modules/@comis/web/dist/assets/message-center-CXefwsUu.js +785 -0
- package/node_modules/@comis/web/dist/assets/models-C1qcU_j3.js +894 -0
- package/node_modules/@comis/web/dist/assets/observability-types-D7jUtSde.js +1 -0
- package/node_modules/@comis/web/dist/assets/observe-view-C0VBhX4C.js +814 -0
- package/node_modules/@comis/web/dist/assets/pipeline-builder-DcUUIrm0.js +1496 -0
- package/node_modules/@comis/web/dist/assets/pipeline-history-DkfOQ6SW.js +317 -0
- package/node_modules/@comis/web/dist/assets/pipeline-history-detail-hyHgD0ai.js +287 -0
- package/node_modules/@comis/web/dist/assets/pipeline-list-BPW8hV-q.js +518 -0
- package/node_modules/@comis/web/dist/assets/pipeline-monitor-Bip16T7e.js +972 -0
- package/node_modules/@comis/web/dist/assets/scheduler-BGgwKd06.js +1182 -0
- package/node_modules/@comis/web/dist/assets/security-D15st4xx.js +1224 -0
- package/node_modules/@comis/web/dist/assets/session-detail-SGEYNJ0M.js +632 -0
- package/node_modules/@comis/web/dist/assets/session-key-parser-DPORMVyU.js +1 -0
- package/node_modules/@comis/web/dist/assets/session-list-6ybUTxbY.js +231 -0
- package/node_modules/@comis/web/dist/assets/setup-wizard-nT0tz9QP.js +853 -0
- package/node_modules/@comis/web/dist/assets/skills-D8yVfSUy.js +1051 -0
- package/node_modules/@comis/web/dist/assets/subagents-HHXMeHYo.js +193 -0
- package/node_modules/@comis/web/dist/assets/workspace-manager-BQlr10iH.js +785 -0
- package/node_modules/@comis/web/dist/comis-logo.png +0 -0
- package/node_modules/@comis/web/dist/favicon-16x16.png +0 -0
- package/node_modules/@comis/web/dist/favicon-32x32.png +0 -0
- package/node_modules/@comis/web/dist/favicon.ico +0 -0
- package/node_modules/@comis/web/dist/index.html +17 -0
- package/node_modules/@comis/web/package.json +29 -0
- package/package.json +15 -13
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import{s as _,i as f,n as p,a as y,b as r,t as C,S as w,A as h,f as x,r as v}from"./index-CEcM1R_C.js";import"./ic-time-range-picker-CypCT68y.js";import"./ic-empty-state-60l2ePhd.js";import"./ic-icon-xeGTVhVG.js";var $=Object.defineProperty,k=Object.getOwnPropertyDescriptor,m=(e,t,l,i)=>{for(var s=i>1?void 0:i?k(t,l):t,a=e.length-1,n;a>=0;a--)(n=e[a])&&(s=(i?n(t,l,s):n(s))||s);return i&&s&&$(t,l,s),s};let u=class extends y{constructor(){super(...arguments),this.segments=[],this.total=0,this.currency="$"}_getTotal(){return this.total>0?this.total:this.segments.reduce((e,t)=>e+t.value,0)}_formatValue(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:this.currency==="$"?"USD":this.currency,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}_onSegmentClick(e){this.dispatchEvent(new CustomEvent("segment-click",{detail:{label:e.label,value:e.value},bubbles:!0,composed:!0}))}render(){const e=this._getTotal();return e===0||this.segments.length===0?r`<div class="empty">No cost data available</div>`:r`
|
|
2
|
+
<div class="bar" role="img" aria-label="Cost breakdown">
|
|
3
|
+
${this.segments.map(t=>{const l=t.value/e*100;return r`
|
|
4
|
+
<div
|
|
5
|
+
class="segment"
|
|
6
|
+
style="width: ${l}%; background: ${t.color};"
|
|
7
|
+
title="${t.label}: ${this._formatValue(t.value)} (${l.toFixed(1)}%)"
|
|
8
|
+
@click=${()=>this._onSegmentClick(t)}
|
|
9
|
+
></div>
|
|
10
|
+
`})}
|
|
11
|
+
</div>
|
|
12
|
+
<div class="legend">
|
|
13
|
+
${this.segments.map(t=>r`
|
|
14
|
+
<span class="legend-item">
|
|
15
|
+
<span class="legend-dot" style="background: ${t.color};"></span>
|
|
16
|
+
${t.label}: ${this._formatValue(t.value)}
|
|
17
|
+
</span>
|
|
18
|
+
`)}
|
|
19
|
+
</div>
|
|
20
|
+
`}};u.styles=[_,f`
|
|
21
|
+
:host {
|
|
22
|
+
display: block;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.bar {
|
|
26
|
+
display: flex;
|
|
27
|
+
height: 20px;
|
|
28
|
+
border-radius: var(--ic-radius-sm, 4px);
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.segment {
|
|
33
|
+
min-width: 2px;
|
|
34
|
+
height: 100%;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
transition: filter 0.15s;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.segment:hover {
|
|
40
|
+
filter: brightness(1.2);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.legend {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-wrap: wrap;
|
|
46
|
+
gap: var(--ic-space-sm);
|
|
47
|
+
margin-top: var(--ic-space-sm);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.legend-item {
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: 4px;
|
|
54
|
+
font-size: var(--ic-text-xs);
|
|
55
|
+
color: var(--ic-text-dim);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.legend-dot {
|
|
59
|
+
width: 8px;
|
|
60
|
+
height: 8px;
|
|
61
|
+
border-radius: 50%;
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.empty {
|
|
66
|
+
font-size: var(--ic-text-sm);
|
|
67
|
+
color: var(--ic-text-dim);
|
|
68
|
+
font-style: italic;
|
|
69
|
+
}
|
|
70
|
+
`];m([p({attribute:!1})],u.prototype,"segments",2);m([p({type:Number})],u.prototype,"total",2);m([p({type:String})],u.prototype,"currency",2);u=m([C("ic-cost-breakdown")],u);var S=Object.defineProperty,T=Object.getOwnPropertyDescriptor,c=(e,t,l,i)=>{for(var s=i>1?void 0:i?T(t,l):t,a=e.length-1,n;a>=0;a--)(n=e[a])&&(s=(i?n(t,l,s):n(s))||s);return i&&s&&S(t,l,s),s};const D=3e4,L=6048e5,g=["var(--ic-accent)","var(--ic-success)","var(--ic-warning)","var(--ic-info, #3b82f6)","var(--ic-error)","#a78bfa","#f472b6","#34d399"];let o=class extends y{constructor(){super(...arguments),this.rpcClient=null,this.eventDispatcher=null,this._sse=null,this._reloadDebounce=null,this._loadState="loading",this._drillLevel="total",this._drillContext={},this._sinceMs=L,this._selectedRange="7d",this._billingTotal=null,this._previousTotal=null,this._providers=[],this._agentBillings=[],this._sessionBillings=[],this._refreshInterval=null,this._rpcStatusUnsub=null,this._fmtCost=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),this._fmtNum=new Intl.NumberFormat("en-US")}_formatCost(e){return this._fmtCost.format(e)}_formatNumber(e){return this._fmtNum.format(e)}connectedCallback(){super.connectedCallback(),this._initSse()}_initSse(){!this.eventDispatcher||this._sse||(this._sse=new w(this,this.eventDispatcher,{"observability:token_usage":()=>{this._scheduleReload()},"diagnostic:billing_snapshot":()=>{this._scheduleReload()}}))}_scheduleReload(e=300){this._reloadDebounce!==null&&clearTimeout(this._reloadDebounce),this._reloadDebounce=setTimeout(()=>{this._reloadDebounce=null,this._loadData()},e)}disconnectedCallback(){super.disconnectedCallback(),this._reloadDebounce!==null&&(clearTimeout(this._reloadDebounce),this._reloadDebounce=null),this._refreshInterval!==null&&(clearInterval(this._refreshInterval),this._refreshInterval=null),this._rpcStatusUnsub?.(),this._rpcStatusUnsub=null}willUpdate(e){e.has("rpcClient")&&this.rpcClient&&this._tryLoad(),e.has("eventDispatcher")&&this.eventDispatcher&&!this._sse&&this._initSse()}_tryLoad(){if(!this.rpcClient){this._loadState="loaded";return}this._rpcStatusUnsub?.(),this.rpcClient.status==="connected"?this._startLoading():this._rpcStatusUnsub=this.rpcClient.onStatusChange(e=>{e==="connected"&&this._startLoading()})}_startLoading(){this._loadData(),this._refreshInterval===null&&(this._refreshInterval=setInterval(()=>{this._loadData()},D))}async _loadData(){if(!this.rpcClient||this.rpcClient.status!=="connected"){this._loadState="loaded";return}const e=this.rpcClient;try{switch(this._drillLevel){case"total":await this._loadTotalLevel(e);break;case"provider":await this._loadProviderLevel(e);break;case"agent":await this._loadAgentLevel(e);break;case"session":await this._loadSessionLevel(e);break}this._loadState="loaded"}catch{this._loadState="error"}}async _loadTotalLevel(e){const t=await e.call("obs.billing.total",{sinceMs:this._sinceMs});this._billingTotal={totalCost:Number(t.totalCost??0),totalTokens:Number(t.totalTokens??0),callCount:Number(t.callCount??0)},Promise.allSettled([e.call("obs.billing.total",{sinceMs:this._sinceMs*2}),e.call("obs.billing.byProvider",{sinceMs:this._sinceMs})]).then(([l,i])=>{if(l.status==="fulfilled"&&this._billingTotal){const s=l.value,a={totalCost:Number(s.totalCost??0),totalTokens:Number(s.totalTokens??0),callCount:Number(s.callCount??0)};this._previousTotal={totalCost:a.totalCost-this._billingTotal.totalCost,totalTokens:a.totalTokens-this._billingTotal.totalTokens,callCount:a.callCount-this._billingTotal.callCount}}if(i.status==="fulfilled"){const s=i.value;if(Array.isArray(s))this._providers=s;else{const a=s;this._providers=Array.isArray(a.providers)?a.providers:[]}}})}async _loadProviderLevel(e){const t=await e.call("obs.billing.byProvider",{sinceMs:this._sinceMs});if(Array.isArray(t))this._providers=t;else{const l=t;this._providers=Array.isArray(l.providers)?l.providers:[]}}async _loadAgentLevel(e){const t=await e.call("agents.list"),i=(Array.isArray(t)?t:Array.isArray(t.agents)?t.agents:[]).map(a=>typeof a=="string"?a:a.id);if(i.length===0){this._agentBillings=[];return}const s=await Promise.allSettled(i.map(a=>e.call("obs.billing.byAgent",{agentId:a,sinceMs:this._sinceMs})));this._agentBillings=s.map((a,n)=>{if(a.status!=="fulfilled")return null;const d=a.value;return{agentId:i[n],totalTokens:Number(d.tokensToday??d.totalTokens??0),percentOfTotal:Number(d.percentOfTotal??0),cost:Number(d.costToday??d.cost??0)}}).filter(a=>a!==null).sort((a,n)=>n.cost-a.cost)}async _loadSessionLevel(e){const t=this._drillContext.agentId;if(!t){this._sessionBillings=[];return}try{const l=await e.call("obs.billing.bySession",{sessionKey:"all",agentId:t,sinceMs:this._sinceMs});if(Array.isArray(l))this._sessionBillings=l;else{const i=l;this._sessionBillings=Array.isArray(i.sessions)?i.sessions:[]}}catch{this._sessionBillings=[]}}_drillDown(e,t){this._drillLevel=e,this._drillContext={...this._drillContext,...t},this._loadData()}_drillUp(e){this._drillLevel=e,e==="total"?this._drillContext={}:e==="provider"?this._drillContext={provider:this._drillContext.provider}:e==="agent"&&(this._drillContext={provider:this._drillContext.provider,agentId:this._drillContext.agentId}),this._loadData()}_onTimeRangeChange(e){this._sinceMs=e.detail.sinceMs,this._selectedRange=e.detail.label,this._loadData()}_computeDelta(e,t){if(t===0)return e>0?{trend:"up",value:"new"}:{trend:"flat",value:""};const l=(e-t)/t*100;return Math.abs(l)<.1?{trend:"flat",value:"0%"}:{trend:l>0?"up":"down",value:`${Math.abs(l).toFixed(1)}%`}}_renderBreadcrumb(){const e=[{label:"Billing",level:"total"}];return this._drillLevel!=="total"&&this._drillContext.provider&&e.push({label:this._drillContext.provider,level:"provider"}),(this._drillLevel==="agent"||this._drillLevel==="session")&&this._drillContext.agentId&&e.push({label:this._drillContext.agentId,level:"agent"}),this._drillLevel==="session"&&this._drillContext.sessionKey&&e.push({label:this._drillContext.sessionKey,level:"session"}),r`
|
|
71
|
+
<nav class="breadcrumb" aria-label="Billing navigation">
|
|
72
|
+
${e.map((t,l)=>{const i=l===e.length-1;return r`
|
|
73
|
+
${l>0?r`<span class="breadcrumb-sep">/</span>`:h}
|
|
74
|
+
${i?r`<span>${t.label}</span>`:r`<button class="breadcrumb-link" @click=${()=>this._drillUp(t.level)}>${t.label}</button>`}
|
|
75
|
+
`})}
|
|
76
|
+
</nav>
|
|
77
|
+
`}_renderTotalLevel(){const e=this._billingTotal,t=this._previousTotal,l=e&&t?this._computeDelta(e.totalCost,t.totalCost):null,i=e&&t?this._computeDelta(e.totalTokens,t.totalTokens):null,s=e&&t?this._computeDelta(e.callCount,t.callCount):null,a=this._providers.map((d,b)=>({label:d.provider,value:d.totalCost,color:g[b%g.length]})),n=this._providers.reduce((d,b)=>d+(b.totalCacheSaved??0),0);return r`
|
|
78
|
+
<div class="stats-row">
|
|
79
|
+
<ic-stat-card
|
|
80
|
+
label="Total Cost"
|
|
81
|
+
.value=${e?this._formatCost(e.totalCost):"---"}
|
|
82
|
+
.trend=${l?.trend??""}
|
|
83
|
+
.trendValue=${l?.value??""}
|
|
84
|
+
></ic-stat-card>
|
|
85
|
+
<ic-stat-card
|
|
86
|
+
label="Total Tokens"
|
|
87
|
+
.value=${e?this._formatNumber(e.totalTokens):"---"}
|
|
88
|
+
.trend=${i?.trend??""}
|
|
89
|
+
.trendValue=${i?.value??""}
|
|
90
|
+
></ic-stat-card>
|
|
91
|
+
<ic-stat-card
|
|
92
|
+
label="API Calls"
|
|
93
|
+
.value=${e?this._formatNumber(e.callCount):"---"}
|
|
94
|
+
.trend=${s?.trend??""}
|
|
95
|
+
.trendValue=${s?.value??""}
|
|
96
|
+
></ic-stat-card>
|
|
97
|
+
${n>0?r`
|
|
98
|
+
<ic-stat-card
|
|
99
|
+
label="Cache Savings"
|
|
100
|
+
.value=${this._formatCost(n)}
|
|
101
|
+
trend="down"
|
|
102
|
+
trendValue="saved"
|
|
103
|
+
></ic-stat-card>
|
|
104
|
+
`:h}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
${a.length>0?r`
|
|
108
|
+
<div class="section">
|
|
109
|
+
<div class="section-title">Cost by Provider</div>
|
|
110
|
+
<div class="card">
|
|
111
|
+
<ic-cost-breakdown
|
|
112
|
+
.segments=${a}
|
|
113
|
+
@segment-click=${d=>{this._drillDown("provider",{provider:d.detail.label})}}
|
|
114
|
+
></ic-cost-breakdown>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
`:h}
|
|
118
|
+
`}_renderProviderLevel(){const e=this._providers.find(i=>i.provider===this._drillContext.provider);if(!e)return r`<ic-empty-state icon="dollar-sign" message="No data for this provider"></ic-empty-state>`;const t=e.models??[],l=t.map((i,s)=>({label:i.model,value:i.cost,color:g[s%g.length]}));return r`
|
|
119
|
+
${(e.totalCacheSaved??0)>0?r`
|
|
120
|
+
<div class="stats-row">
|
|
121
|
+
<ic-stat-card
|
|
122
|
+
label="Provider Cost"
|
|
123
|
+
.value=${this._formatCost(e.totalCost)}
|
|
124
|
+
></ic-stat-card>
|
|
125
|
+
<ic-stat-card
|
|
126
|
+
label="Cache Savings"
|
|
127
|
+
.value=${this._formatCost(e.totalCacheSaved)}
|
|
128
|
+
trend="down"
|
|
129
|
+
trendValue="saved"
|
|
130
|
+
></ic-stat-card>
|
|
131
|
+
</div>
|
|
132
|
+
`:h}
|
|
133
|
+
|
|
134
|
+
${l.length>0?r`
|
|
135
|
+
<div class="section">
|
|
136
|
+
<div class="section-title">Cost by Model</div>
|
|
137
|
+
<div class="card">
|
|
138
|
+
<ic-cost-breakdown .segments=${l}></ic-cost-breakdown>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
`:h}
|
|
142
|
+
|
|
143
|
+
<div class="section">
|
|
144
|
+
<div class="section-title">Model Breakdown</div>
|
|
145
|
+
<div class="card">
|
|
146
|
+
<div class="grid-table model-table" role="table" aria-label="Model breakdown">
|
|
147
|
+
<div class="grid-header" role="row">
|
|
148
|
+
<div class="cell" role="columnheader">Model</div>
|
|
149
|
+
<div class="cell cell-right" role="columnheader">Tokens</div>
|
|
150
|
+
<div class="cell cell-right" role="columnheader">Cost</div>
|
|
151
|
+
<div class="cell cell-right" role="columnheader">Calls</div>
|
|
152
|
+
</div>
|
|
153
|
+
${t.map(i=>{const s=e.totalCost>0?i.cost/e.totalCost*100:0;return r`
|
|
154
|
+
<div class="grid-row" role="row">
|
|
155
|
+
<div class="cell" role="cell">${i.model}</div>
|
|
156
|
+
<div class="cell cell-mono cell-right" role="cell">${this._formatNumber(i.tokens)}</div>
|
|
157
|
+
<div class="cell cell-mono cell-right" role="cell">
|
|
158
|
+
<span class="pct-bar" style="width: ${Math.max(s,2)}px"></span>
|
|
159
|
+
${this._formatCost(i.cost)} (${s.toFixed(1)}%)
|
|
160
|
+
</div>
|
|
161
|
+
<div class="cell cell-mono cell-right" role="cell">${this._formatNumber(i.calls)}</div>
|
|
162
|
+
</div>
|
|
163
|
+
`})}
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<div class="section">
|
|
169
|
+
<button
|
|
170
|
+
class="breadcrumb-link"
|
|
171
|
+
@click=${()=>this._drillDown("agent",{})}
|
|
172
|
+
>View agent breakdown</button>
|
|
173
|
+
</div>
|
|
174
|
+
`}_renderAgentLevel(){return this._agentBillings.length===0?r`<ic-empty-state icon="users" message="No agent billing data available"></ic-empty-state>`:r`
|
|
175
|
+
<div class="section">
|
|
176
|
+
<div class="section-title">Agent Billing</div>
|
|
177
|
+
<div class="card">
|
|
178
|
+
<div class="grid-table agent-table" role="table" aria-label="Agent billing">
|
|
179
|
+
<div class="grid-header" role="row">
|
|
180
|
+
<div class="cell" role="columnheader">Agent ID</div>
|
|
181
|
+
<div class="cell cell-right" role="columnheader">Tokens</div>
|
|
182
|
+
<div class="cell cell-right" role="columnheader">% of Total</div>
|
|
183
|
+
<div class="cell cell-right" role="columnheader">Cost</div>
|
|
184
|
+
</div>
|
|
185
|
+
${this._agentBillings.map(e=>r`
|
|
186
|
+
<div
|
|
187
|
+
class="grid-row clickable"
|
|
188
|
+
role="row"
|
|
189
|
+
@click=${()=>this._drillDown("session",{agentId:e.agentId})}
|
|
190
|
+
>
|
|
191
|
+
<div class="cell" role="cell">${e.agentId}</div>
|
|
192
|
+
<div class="cell cell-mono cell-right" role="cell">${this._formatNumber(e.totalTokens)}</div>
|
|
193
|
+
<div class="cell cell-mono cell-right" role="cell">${e.percentOfTotal.toFixed(1)}%</div>
|
|
194
|
+
<div class="cell cell-mono cell-right" role="cell">${this._formatCost(e.cost)}</div>
|
|
195
|
+
</div>
|
|
196
|
+
`)}
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
`}_renderSessionLevel(){if(this._sessionBillings.length===0)return r`<ic-empty-state icon="list" message="No session billing data available for this agent"></ic-empty-state>`;const e=[...this._sessionBillings].sort((t,l)=>l.totalCost-t.totalCost);return r`
|
|
201
|
+
<div class="section">
|
|
202
|
+
<div class="section-title">Session Billing</div>
|
|
203
|
+
<div class="card">
|
|
204
|
+
<div class="grid-table session-table" role="table" aria-label="Session billing">
|
|
205
|
+
<div class="grid-header" role="row">
|
|
206
|
+
<div class="cell" role="columnheader">Session Key</div>
|
|
207
|
+
<div class="cell cell-right" role="columnheader">Tokens</div>
|
|
208
|
+
<div class="cell cell-right" role="columnheader">Cost</div>
|
|
209
|
+
<div class="cell cell-right" role="columnheader">API Calls</div>
|
|
210
|
+
</div>
|
|
211
|
+
${e.map(t=>r`
|
|
212
|
+
<div class="grid-row" role="row">
|
|
213
|
+
<div class="cell cell-mono" role="cell">${t.sessionKey}</div>
|
|
214
|
+
<div class="cell cell-mono cell-right" role="cell">${this._formatNumber(t.totalTokens)}</div>
|
|
215
|
+
<div class="cell cell-mono cell-right" role="cell">${this._formatCost(t.totalCost)}</div>
|
|
216
|
+
<div class="cell cell-mono cell-right" role="cell">${this._formatNumber(t.callCount)}</div>
|
|
217
|
+
</div>
|
|
218
|
+
`)}
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
`}render(){return this._loadState==="loading"&&!this.rpcClient?r`<ic-skeleton-view variant="table"></ic-skeleton-view>`:this._loadState==="error"?r`
|
|
223
|
+
<div class="error-container">
|
|
224
|
+
<span class="error-message">Failed to load billing data</span>
|
|
225
|
+
<button class="retry-btn" @click=${()=>this._tryLoad()}>Retry</button>
|
|
226
|
+
</div>
|
|
227
|
+
`:r`
|
|
228
|
+
<div class="billing-view">
|
|
229
|
+
<div class="header">
|
|
230
|
+
${this._renderBreadcrumb()}
|
|
231
|
+
<ic-time-range-picker
|
|
232
|
+
.selected=${this._selectedRange}
|
|
233
|
+
@time-range-change=${this._onTimeRangeChange}
|
|
234
|
+
></ic-time-range-picker>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
${this._drillLevel==="total"?this._renderTotalLevel():h}
|
|
238
|
+
${this._drillLevel==="provider"?this._renderProviderLevel():h}
|
|
239
|
+
${this._drillLevel==="agent"?this._renderAgentLevel():h}
|
|
240
|
+
${this._drillLevel==="session"?this._renderSessionLevel():h}
|
|
241
|
+
</div>
|
|
242
|
+
`}};o.styles=[_,x,f`
|
|
243
|
+
:host { display: block; }
|
|
244
|
+
|
|
245
|
+
.billing-view { padding: 0; }
|
|
246
|
+
|
|
247
|
+
.header {
|
|
248
|
+
display: flex;
|
|
249
|
+
justify-content: space-between;
|
|
250
|
+
align-items: center;
|
|
251
|
+
margin-bottom: var(--ic-space-lg);
|
|
252
|
+
flex-wrap: wrap;
|
|
253
|
+
gap: var(--ic-space-sm);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.breadcrumb {
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
gap: var(--ic-space-xs);
|
|
260
|
+
font-size: var(--ic-text-base);
|
|
261
|
+
font-weight: 600;
|
|
262
|
+
color: var(--ic-text);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.breadcrumb-link {
|
|
266
|
+
color: var(--ic-accent);
|
|
267
|
+
cursor: pointer;
|
|
268
|
+
background: none;
|
|
269
|
+
border: none;
|
|
270
|
+
font-size: inherit;
|
|
271
|
+
font-weight: inherit;
|
|
272
|
+
font-family: inherit;
|
|
273
|
+
padding: 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.breadcrumb-link:hover { text-decoration: underline; }
|
|
277
|
+
.breadcrumb-link:focus-visible { outline: 2px solid var(--ic-accent); outline-offset: 2px; }
|
|
278
|
+
|
|
279
|
+
.breadcrumb-sep { color: var(--ic-text-dim); }
|
|
280
|
+
|
|
281
|
+
.section { margin-bottom: var(--ic-space-xl); }
|
|
282
|
+
|
|
283
|
+
.section-title {
|
|
284
|
+
font-size: var(--ic-text-base);
|
|
285
|
+
font-weight: 600;
|
|
286
|
+
color: var(--ic-text);
|
|
287
|
+
margin-bottom: var(--ic-space-md);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.stats-row {
|
|
291
|
+
display: grid;
|
|
292
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
293
|
+
gap: var(--ic-space-md);
|
|
294
|
+
margin-bottom: var(--ic-space-lg);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.card {
|
|
298
|
+
background: var(--ic-surface);
|
|
299
|
+
border: 1px solid var(--ic-border);
|
|
300
|
+
border-radius: var(--ic-radius-lg);
|
|
301
|
+
padding: var(--ic-space-lg);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* CSS grid tables */
|
|
305
|
+
.grid-table {
|
|
306
|
+
display: grid;
|
|
307
|
+
gap: 0;
|
|
308
|
+
font-size: var(--ic-text-sm);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.grid-header, .grid-row {
|
|
312
|
+
display: contents;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.grid-header > .cell {
|
|
316
|
+
font-weight: 600;
|
|
317
|
+
color: var(--ic-text-dim);
|
|
318
|
+
text-transform: uppercase;
|
|
319
|
+
letter-spacing: 0.05em;
|
|
320
|
+
font-size: var(--ic-text-xs);
|
|
321
|
+
padding: var(--ic-space-sm) var(--ic-space-md);
|
|
322
|
+
border-bottom: 1px solid var(--ic-border);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.grid-row > .cell {
|
|
326
|
+
padding: var(--ic-space-sm) var(--ic-space-md);
|
|
327
|
+
border-bottom: 1px solid var(--ic-border);
|
|
328
|
+
color: var(--ic-text);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.cell-right { text-align: right; }
|
|
332
|
+
|
|
333
|
+
.cell-mono {
|
|
334
|
+
font-family: var(--ic-font-mono, ui-monospace, monospace);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.grid-row.clickable > .cell { cursor: pointer; }
|
|
338
|
+
.grid-row.clickable:hover > .cell { background: var(--ic-surface-2, #1f2937); }
|
|
339
|
+
|
|
340
|
+
.provider-table, .model-table, .agent-table, .session-table {
|
|
341
|
+
grid-template-columns: 1fr repeat(3, auto);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.pct-bar {
|
|
345
|
+
display: inline-block;
|
|
346
|
+
height: 4px;
|
|
347
|
+
background: var(--ic-accent);
|
|
348
|
+
border-radius: 2px;
|
|
349
|
+
margin-right: var(--ic-space-xs);
|
|
350
|
+
vertical-align: middle;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.error-container {
|
|
354
|
+
display: flex;
|
|
355
|
+
flex-direction: column;
|
|
356
|
+
align-items: center;
|
|
357
|
+
gap: 0.75rem;
|
|
358
|
+
padding: 3rem;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.error-message { color: var(--ic-error); font-size: 0.875rem; }
|
|
362
|
+
|
|
363
|
+
.retry-btn {
|
|
364
|
+
padding: 0.5rem 1rem;
|
|
365
|
+
background: var(--ic-surface);
|
|
366
|
+
border: 1px solid var(--ic-border);
|
|
367
|
+
border-radius: 0.375rem;
|
|
368
|
+
color: var(--ic-text);
|
|
369
|
+
font-size: 0.8125rem;
|
|
370
|
+
cursor: pointer;
|
|
371
|
+
font-family: inherit;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.retry-btn:hover { background: var(--ic-surface-alt, #374151); }
|
|
375
|
+
`];c([p({attribute:!1})],o.prototype,"rpcClient",2);c([p({attribute:!1})],o.prototype,"eventDispatcher",2);c([v()],o.prototype,"_loadState",2);c([v()],o.prototype,"_drillLevel",2);c([v()],o.prototype,"_drillContext",2);c([v()],o.prototype,"_sinceMs",2);c([v()],o.prototype,"_selectedRange",2);c([v()],o.prototype,"_billingTotal",2);c([v()],o.prototype,"_previousTotal",2);c([v()],o.prototype,"_providers",2);c([v()],o.prototype,"_agentBillings",2);c([v()],o.prototype,"_sessionBillings",2);o=c([C("ic-billing-view")],o);export{o as IcBillingView};
|