@standardagents/builder 0.24.5 → 0.24.6
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/built-in-routes.js +153 -15
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-CmObAp7n.js → ApiKeysView-CmZKVcOR.js} +1 -1
- package/dist/client/CenteredContentView-DK7rPUK2.js +1 -0
- package/dist/client/{CompositionView-BohQwGLE.js → CompositionView-BvVMnyYP.js} +1 -1
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-A1C0eTY7.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-h7YuRPAr.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-D5q8qf4n.js → CopyButton.vue_vue_type_script_setup_true_lang-BpQ6CMUp.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-DzPpurCp.js → DataTable.vue_vue_type_script_setup_true_lang-DCUZbvUM.js} +1 -1
- package/dist/client/{JsonViewer-CKqMMqjU.js → JsonViewer-CvwfQYW-.js} +1 -1
- package/dist/client/{LoginView-BY2NMQQF.js → LoginView-DnaG5knS.js} +1 -1
- package/dist/client/{MarketplaceView-DVEMUvDq.js → MarketplaceView-fX_Juw54.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-1t6cxO9H.js → Modal.vue_vue_type_script_setup_true_lang-CFFVfl1g.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-WFlATqyT.js → ModelModal.vue_vue_type_script_setup_true_lang-B68s7Jo1.js} +1 -1
- package/dist/client/{ModelsView-_qZmXle8.js → ModelsView-lv4-IyA2.js} +1 -1
- package/dist/client/{PromptEditView-DzY493YB.js → PromptEditView-DGaxlMMx.js} +1 -1
- package/dist/client/{PromptModal-BQYwnWKw.js → PromptModal-DaW1J_W6.js} +1 -1
- package/dist/client/{PromptsView-DBiQ9X1g.js → PromptsView-CdiBqZey.js} +1 -1
- package/dist/client/{ProvidersView-DEH34_v0.js → ProvidersView-B37bgFKh.js} +1 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DHlNdv7o.js +22 -0
- package/dist/client/ThreadsView-BAfuNShv.js +1 -0
- package/dist/client/{ToolsView-D-qvyctb.js → ToolsView-BMKgNq7O.js} +1 -1
- package/dist/client/{UiCodeBlock.vue_vue_type_script_setup_true_lang-BawOR_eB.js → UiCodeBlock.vue_vue_type_script_setup_true_lang-BH3WC9G_.js} +1 -1
- package/dist/client/{UsersView-DaXRB61v.js → UsersView-BDKchqNQ.js} +1 -1
- package/dist/client/{VariablesView-DDomn-IB.js → VariablesView-BPioaCbu.js} +1 -1
- package/dist/client/assets/{ThreadInspectorPane-CjK6SKEi.css → ThreadInspectorPane-lJJckks4.css} +1 -1
- package/dist/client/assets/index-Djjx6d3k.css +1 -0
- package/dist/client/{check-DKLwABgc.js → check-Dkzs1C3V.js} +1 -1
- package/dist/client/{chevron-right-DJJGHNE5.js → chevron-right-BGirddPg.js} +1 -1
- package/dist/client/{copy-CLWiDcxB.js → copy-C08OR8rY.js} +1 -1
- package/dist/client/{formkit-DcuuXZjC.js → formkit-YJ1Z7D5r.js} +1 -1
- package/dist/client/{index-DihZBCmQ.js → index-BVfRoUms.js} +3 -3
- package/dist/client/index.html +4 -4
- package/dist/client/{package-CarOhnUs.js → package-guyzMTDG.js} +1 -1
- package/dist/client/{plus-zGapov7j.js → plus-DG3ZN5wg.js} +1 -1
- package/dist/client/{timeAgo-ASgzq6bq.js → timeAgo-D7V247YG.js} +1 -1
- package/dist/client/{useActionFeedback-uUrfjlCo.js → useActionFeedback-byARNQjQ.js} +1 -1
- package/dist/client/vue-BqC6IZDY.js +1 -0
- package/dist/{index-D7KMmRgr.d.ts → index-D3FNNQWC.d.ts} +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +47 -6
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +9 -2
- package/dist/runtime.js +47 -6
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client/CenteredContentView-gJXa9UHE.js +0 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-Dtd1VFrj.js +0 -22
- package/dist/client/ThreadsView-m1CAq3Aw.js +0 -1
- package/dist/client/assets/index-V68N0r_5.css +0 -1
- package/dist/client/vue-2tGL2Ulx.js +0 -1
package/dist/built-in-routes.js
CHANGED
|
@@ -224,6 +224,18 @@ function getFallbackPricing(providerName, modelId) {
|
|
|
224
224
|
const pricing = getProviderModelPricing(providerName, modelId);
|
|
225
225
|
return pricing ? toResolvedModelPricing(pricing) : null;
|
|
226
226
|
}
|
|
227
|
+
function resolveUsageReportedPricing(usage) {
|
|
228
|
+
const pricing = usage.pricing;
|
|
229
|
+
if (!pricing || typeof pricing.inputPerMillion !== "number" || typeof pricing.outputPerMillion !== "number") {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
inputPrice: pricing.inputPerMillion,
|
|
234
|
+
outputPrice: pricing.outputPerMillion,
|
|
235
|
+
cachedPrice: pricing.cachedInputPerMillion,
|
|
236
|
+
source: "provider"
|
|
237
|
+
};
|
|
238
|
+
}
|
|
227
239
|
function resolveModelPricing(modelDef, providerName) {
|
|
228
240
|
if (typeof modelDef.inputPrice === "number" && typeof modelDef.outputPrice === "number") {
|
|
229
241
|
return {
|
|
@@ -1374,7 +1386,8 @@ function convertUsage(usage) {
|
|
|
1374
1386
|
prompt_tokens_details: usage.cachedTokens ? { cached_tokens: usage.cachedTokens } : void 0,
|
|
1375
1387
|
completion_tokens_details: usage.reasoningTokens ? { reasoning_tokens: usage.reasoningTokens } : void 0,
|
|
1376
1388
|
cost: usage.cost,
|
|
1377
|
-
provider: usage.provider
|
|
1389
|
+
provider: usage.provider,
|
|
1390
|
+
pricing: usage.pricing
|
|
1378
1391
|
};
|
|
1379
1392
|
}
|
|
1380
1393
|
function inferProviderFromModelId(model) {
|
|
@@ -2069,7 +2082,7 @@ var init_LLMRequest = __esm({
|
|
|
2069
2082
|
const toolsCalled = response.tool_calls ? JSON.stringify(response.tool_calls.map((tc) => tc.function.name)) : null;
|
|
2070
2083
|
const providerName = response._provider?.name;
|
|
2071
2084
|
const standardAgentsRouterUsed = response._viaPlatform === true || providerName === "platform";
|
|
2072
|
-
const resolvedPricing = resolveModelPricing(modelDef, providerName);
|
|
2085
|
+
const resolvedPricing = resolveModelPricing(modelDef) ?? resolveUsageReportedPricing(response.usage) ?? resolveModelPricing(modelDef, providerName);
|
|
2073
2086
|
const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
|
|
2074
2087
|
const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
|
|
2075
2088
|
const cost_total = providerReportedCost != null && !Number.isNaN(providerReportedCost) ? providerReportedCost : calculatedCost?.costTotal ?? null;
|
|
@@ -56247,6 +56260,25 @@ function getModelIconDataUri(modelId) {
|
|
|
56247
56260
|
}
|
|
56248
56261
|
return void 0;
|
|
56249
56262
|
}
|
|
56263
|
+
function usagePricingFromCatalogPricing(pricing) {
|
|
56264
|
+
if (!pricing) return void 0;
|
|
56265
|
+
const perMillion = (value) => {
|
|
56266
|
+
if (value === void 0) return void 0;
|
|
56267
|
+
const parsed = Number.parseFloat(value);
|
|
56268
|
+
if (!Number.isFinite(parsed)) return void 0;
|
|
56269
|
+
return Number((parsed * 1e6).toFixed(12));
|
|
56270
|
+
};
|
|
56271
|
+
const inputPerMillion = perMillion(pricing.prompt);
|
|
56272
|
+
const outputPerMillion = perMillion(pricing.completion);
|
|
56273
|
+
if (inputPerMillion === void 0 || outputPerMillion === void 0) {
|
|
56274
|
+
return void 0;
|
|
56275
|
+
}
|
|
56276
|
+
return {
|
|
56277
|
+
inputPerMillion,
|
|
56278
|
+
cachedInputPerMillion: perMillion(pricing.input_cache_read),
|
|
56279
|
+
outputPerMillion
|
|
56280
|
+
};
|
|
56281
|
+
}
|
|
56250
56282
|
var OPENROUTER_SERVER_TOOL_NAMES, google_default3, meta_default4, mistralai_default3, moonshotai_default3, nvidia_default2, openai_default5, qwen_default4, zai_org_default4, ANTHROPIC_ICON2, GOOGLE_ICON3, META_ICON3, NVIDIA_ICON, ALIBABA_ICON2, DEEPSEEK_ICON2, QWEN_ICON2, MINIMAX_ICON, MOONSHOTAI_ICON, XAI_ICON, ZAI_ICON3, EXAONE_ICON, OPENROUTER_ICON, OPENAI_ICON4, MISTRAL_ICON2, COHERE_ICON, PERPLEXITY_ICON, LAB_ICONS, OPENROUTER_PROVIDER_ICON_PREFIX, OPENROUTER_PROVIDER_URL_ENTRIES, OPENROUTER_PROVIDER_URLS, OpenRouterProvider, percentileSchema, providerRoutingSchema, serverToolParametersSchema, serverToolsSchema, openrouterProviderOptions, openrouter;
|
|
56251
56283
|
var init_dist6 = __esm({
|
|
56252
56284
|
"../openrouter/dist/index.js"() {
|
|
@@ -56548,6 +56580,11 @@ var init_dist6 = __esm({
|
|
|
56548
56580
|
static modelsCacheTime = 0;
|
|
56549
56581
|
static CACHE_TTL = 5 * 60 * 1e3;
|
|
56550
56582
|
// 5 minutes
|
|
56583
|
+
/** In-flight catalog download shared by concurrent callers. */
|
|
56584
|
+
static modelsFetchPromise = null;
|
|
56585
|
+
/** Timestamp of the last failed catalog fetch, for negative caching. */
|
|
56586
|
+
static modelsFetchFailedAt = 0;
|
|
56587
|
+
static FAILURE_RETRY_MS = 60 * 1e3;
|
|
56551
56588
|
/**
|
|
56552
56589
|
* Get capabilities for a specific model.
|
|
56553
56590
|
* Fetches from OpenRouter's models API which provides rich metadata.
|
|
@@ -56565,19 +56602,73 @@ var init_dist6 = __esm({
|
|
|
56565
56602
|
return null;
|
|
56566
56603
|
}
|
|
56567
56604
|
}
|
|
56605
|
+
/**
|
|
56606
|
+
* How long a streaming finish chunk may wait on the catalog pricing lookup.
|
|
56607
|
+
* The lookup is started when the stream starts, so by finish time it is
|
|
56608
|
+
* almost always resolved; the bound guarantees a slow catalog download can
|
|
56609
|
+
* never stall the finish chunk into the runtime's stream watchdog.
|
|
56610
|
+
*/
|
|
56611
|
+
static USAGE_PRICING_FINISH_WAIT_MS = 2500;
|
|
56612
|
+
static async settleUsagePricing(pricingPromise) {
|
|
56613
|
+
let timer;
|
|
56614
|
+
const timeout = new Promise((resolve2) => {
|
|
56615
|
+
timer = setTimeout(() => resolve2(void 0), _OpenRouterProvider.USAGE_PRICING_FINISH_WAIT_MS);
|
|
56616
|
+
});
|
|
56617
|
+
try {
|
|
56618
|
+
return await Promise.race([pricingPromise, timeout]);
|
|
56619
|
+
} finally {
|
|
56620
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
56621
|
+
}
|
|
56622
|
+
}
|
|
56623
|
+
/** Bounded-wait pricing attachment shared by the non-streaming paths. */
|
|
56624
|
+
async attachUsagePricing(result, pricingPromise) {
|
|
56625
|
+
const pricing = await _OpenRouterProvider.settleUsagePricing(pricingPromise);
|
|
56626
|
+
if (pricing) result.usage.pricing = pricing;
|
|
56627
|
+
return result;
|
|
56628
|
+
}
|
|
56629
|
+
/**
|
|
56630
|
+
* Exact unit prices for a model from OpenRouter's live catalog (cached),
|
|
56631
|
+
* attached to response usage so request logs can record specific prices.
|
|
56632
|
+
* Best-effort: any failure just leaves pricing off the usage payload.
|
|
56633
|
+
*/
|
|
56634
|
+
async getUsagePricing(modelId) {
|
|
56635
|
+
if (!modelId) return void 0;
|
|
56636
|
+
try {
|
|
56637
|
+
const models = await this.fetchModelsWithCache();
|
|
56638
|
+
const model = models.find((m) => m.id === modelId);
|
|
56639
|
+
return usagePricingFromCatalogPricing(model?.pricing);
|
|
56640
|
+
} catch {
|
|
56641
|
+
return void 0;
|
|
56642
|
+
}
|
|
56643
|
+
}
|
|
56568
56644
|
async fetchModelsWithCache() {
|
|
56569
56645
|
const now = Date.now();
|
|
56570
56646
|
if (_OpenRouterProvider.modelsCache && now - _OpenRouterProvider.modelsCacheTime < _OpenRouterProvider.CACHE_TTL) {
|
|
56571
56647
|
return _OpenRouterProvider.modelsCache;
|
|
56572
56648
|
}
|
|
56573
|
-
|
|
56574
|
-
|
|
56575
|
-
throw new Error(`OpenRouter API error: ${response.status}`);
|
|
56649
|
+
if (now - _OpenRouterProvider.modelsFetchFailedAt < _OpenRouterProvider.FAILURE_RETRY_MS) {
|
|
56650
|
+
throw new Error("OpenRouter models fetch recently failed");
|
|
56576
56651
|
}
|
|
56577
|
-
|
|
56578
|
-
|
|
56579
|
-
|
|
56580
|
-
|
|
56652
|
+
if (!_OpenRouterProvider.modelsFetchPromise) {
|
|
56653
|
+
_OpenRouterProvider.modelsFetchPromise = (async () => {
|
|
56654
|
+
try {
|
|
56655
|
+
const response = await fetch("https://openrouter.ai/api/v1/models");
|
|
56656
|
+
if (!response.ok) {
|
|
56657
|
+
throw new Error(`OpenRouter API error: ${response.status}`);
|
|
56658
|
+
}
|
|
56659
|
+
const data = await response.json();
|
|
56660
|
+
_OpenRouterProvider.modelsCache = data.data || [];
|
|
56661
|
+
_OpenRouterProvider.modelsCacheTime = Date.now();
|
|
56662
|
+
return _OpenRouterProvider.modelsCache;
|
|
56663
|
+
} catch (error) {
|
|
56664
|
+
_OpenRouterProvider.modelsFetchFailedAt = Date.now();
|
|
56665
|
+
throw error;
|
|
56666
|
+
} finally {
|
|
56667
|
+
_OpenRouterProvider.modelsFetchPromise = null;
|
|
56668
|
+
}
|
|
56669
|
+
})();
|
|
56670
|
+
}
|
|
56671
|
+
return _OpenRouterProvider.modelsFetchPromise;
|
|
56581
56672
|
}
|
|
56582
56673
|
mapOpenRouterCapabilities(model) {
|
|
56583
56674
|
const capabilities = {
|
|
@@ -56662,6 +56753,7 @@ var init_dist6 = __esm({
|
|
|
56662
56753
|
if (this.config.providers && this.config.providers.length > 0) {
|
|
56663
56754
|
params.provider = { only: this.config.providers };
|
|
56664
56755
|
}
|
|
56756
|
+
const pricingPromise = this.getUsagePricing(params.model);
|
|
56665
56757
|
const response = await fetch(`${baseUrl}/chat/completions`, {
|
|
56666
56758
|
method: "POST",
|
|
56667
56759
|
headers: {
|
|
@@ -56683,7 +56775,7 @@ var init_dist6 = __esm({
|
|
|
56683
56775
|
throw new ProviderError(errorMessage, "invalid_request", response.status);
|
|
56684
56776
|
}
|
|
56685
56777
|
const data = await response.json();
|
|
56686
|
-
return transformChatResponse3(data);
|
|
56778
|
+
return this.attachUsagePricing(transformChatResponse3(data), pricingPromise);
|
|
56687
56779
|
} catch (error) {
|
|
56688
56780
|
throw this.toProviderError(error);
|
|
56689
56781
|
}
|
|
@@ -56697,6 +56789,7 @@ var init_dist6 = __esm({
|
|
|
56697
56789
|
try {
|
|
56698
56790
|
const params = buildCreateParams3(request);
|
|
56699
56791
|
this.applyConfiguredProvidersToResponses(params);
|
|
56792
|
+
const pricingPromise = this.getUsagePricing(params.model);
|
|
56700
56793
|
if (this.hasOpenRouterServerTools(params)) {
|
|
56701
56794
|
const response2 = await fetch(`${baseUrl}/responses`, {
|
|
56702
56795
|
method: "POST",
|
|
@@ -56714,14 +56807,14 @@ var init_dist6 = __esm({
|
|
|
56714
56807
|
await this.throwOpenRouterFetchError(response2);
|
|
56715
56808
|
}
|
|
56716
56809
|
const data = await response2.json();
|
|
56717
|
-
return transformResponse3(data);
|
|
56810
|
+
return this.attachUsagePricing(transformResponse3(data), pricingPromise);
|
|
56718
56811
|
}
|
|
56719
56812
|
const client = await this.getClient();
|
|
56720
56813
|
const response = await client.beta.responses.send({
|
|
56721
56814
|
...this.toSdkResponsesRequest(params),
|
|
56722
56815
|
stream: false
|
|
56723
56816
|
});
|
|
56724
|
-
return transformResponse3(response);
|
|
56817
|
+
return this.attachUsagePricing(transformResponse3(response), pricingPromise);
|
|
56725
56818
|
} catch (error) {
|
|
56726
56819
|
throw this.toProviderError(error);
|
|
56727
56820
|
}
|
|
@@ -56745,6 +56838,7 @@ var init_dist6 = __esm({
|
|
|
56745
56838
|
if (this.config.providers && this.config.providers.length > 0) {
|
|
56746
56839
|
params.provider = { only: this.config.providers };
|
|
56747
56840
|
}
|
|
56841
|
+
const pricingPromise = this.getUsagePricing(params.model);
|
|
56748
56842
|
const response = await fetch(`${baseUrl}/chat/completions`, {
|
|
56749
56843
|
method: "POST",
|
|
56750
56844
|
headers: {
|
|
@@ -56784,6 +56878,10 @@ var init_dist6 = __esm({
|
|
|
56784
56878
|
}
|
|
56785
56879
|
}
|
|
56786
56880
|
if (finishChunk) {
|
|
56881
|
+
if (finishChunk.type === "finish") {
|
|
56882
|
+
const pricing = await _OpenRouterProvider.settleUsagePricing(pricingPromise);
|
|
56883
|
+
if (pricing) finishChunk.usage.pricing = pricing;
|
|
56884
|
+
}
|
|
56787
56885
|
const finishWithMeta = {
|
|
56788
56886
|
...finishChunk,
|
|
56789
56887
|
_asyncMetadata: responseId ? {
|
|
@@ -56814,6 +56912,7 @@ var init_dist6 = __esm({
|
|
|
56814
56912
|
try {
|
|
56815
56913
|
const params = buildCreateParams3(request);
|
|
56816
56914
|
this.applyConfiguredProvidersToResponses(params);
|
|
56915
|
+
const pricingPromise = this.getUsagePricing(params.model);
|
|
56817
56916
|
const response = await fetch(`${baseUrl}/responses`, {
|
|
56818
56917
|
method: "POST",
|
|
56819
56918
|
headers: {
|
|
@@ -56852,6 +56951,10 @@ var init_dist6 = __esm({
|
|
|
56852
56951
|
}
|
|
56853
56952
|
}
|
|
56854
56953
|
if (finishChunk) {
|
|
56954
|
+
if (finishChunk.type === "finish") {
|
|
56955
|
+
const pricing = await _OpenRouterProvider.settleUsagePricing(pricingPromise);
|
|
56956
|
+
if (pricing) finishChunk.usage.pricing = pricing;
|
|
56957
|
+
}
|
|
56855
56958
|
const finishWithMeta = {
|
|
56856
56959
|
...finishChunk,
|
|
56857
56960
|
// Include what's needed to fetch metadata later
|
|
@@ -69112,14 +69215,31 @@ var continue_post_default = defineController2(async ({ req, params, env: env2 })
|
|
|
69112
69215
|
|
|
69113
69216
|
// src/agents/cost-summary.ts
|
|
69114
69217
|
function emptyCostSummary() {
|
|
69115
|
-
return {
|
|
69218
|
+
return {
|
|
69219
|
+
totalCost: 0,
|
|
69220
|
+
inputCost: 0,
|
|
69221
|
+
cachedCost: 0,
|
|
69222
|
+
outputCost: 0,
|
|
69223
|
+
requestCount: 0,
|
|
69224
|
+
messageCount: 0,
|
|
69225
|
+
byModel: {}
|
|
69226
|
+
};
|
|
69116
69227
|
}
|
|
69117
69228
|
function mergeByModel(summaries) {
|
|
69118
69229
|
const merged = {};
|
|
69119
69230
|
for (const summary of summaries) {
|
|
69120
69231
|
for (const [modelName, acc] of Object.entries(summary.byModel)) {
|
|
69121
|
-
const entry = merged[modelName] ?? {
|
|
69232
|
+
const entry = merged[modelName] ?? {
|
|
69233
|
+
totalCost: 0,
|
|
69234
|
+
inputCost: 0,
|
|
69235
|
+
cachedCost: 0,
|
|
69236
|
+
outputCost: 0,
|
|
69237
|
+
count: 0
|
|
69238
|
+
};
|
|
69122
69239
|
entry.totalCost += acc.totalCost;
|
|
69240
|
+
entry.inputCost = (entry.inputCost ?? 0) + (acc.inputCost ?? 0);
|
|
69241
|
+
entry.cachedCost = (entry.cachedCost ?? 0) + (acc.cachedCost ?? 0);
|
|
69242
|
+
entry.outputCost = (entry.outputCost ?? 0) + (acc.outputCost ?? 0);
|
|
69123
69243
|
entry.count += acc.count;
|
|
69124
69244
|
merged[modelName] = entry;
|
|
69125
69245
|
}
|
|
@@ -69128,19 +69248,28 @@ function mergeByModel(summaries) {
|
|
|
69128
69248
|
}
|
|
69129
69249
|
function sumSummaries(summaries) {
|
|
69130
69250
|
let totalCost = 0;
|
|
69251
|
+
let inputCost = 0;
|
|
69252
|
+
let cachedCost = 0;
|
|
69253
|
+
let outputCost = 0;
|
|
69131
69254
|
let requestCount = 0;
|
|
69132
69255
|
let messageCount = 0;
|
|
69133
69256
|
for (const summary of summaries) {
|
|
69134
69257
|
totalCost += summary.totalCost;
|
|
69258
|
+
inputCost += summary.inputCost ?? 0;
|
|
69259
|
+
cachedCost += summary.cachedCost ?? 0;
|
|
69260
|
+
outputCost += summary.outputCost ?? 0;
|
|
69135
69261
|
requestCount += summary.requestCount;
|
|
69136
69262
|
messageCount += summary.messageCount;
|
|
69137
69263
|
}
|
|
69138
|
-
return { totalCost, requestCount, messageCount };
|
|
69264
|
+
return { totalCost, inputCost, cachedCost, outputCost, requestCount, messageCount };
|
|
69139
69265
|
}
|
|
69140
69266
|
function buildModelBreakdown(byModel) {
|
|
69141
69267
|
return Object.entries(byModel).map(([modelName, acc]) => ({
|
|
69142
69268
|
modelName,
|
|
69143
69269
|
totalCost: acc.totalCost,
|
|
69270
|
+
inputCost: acc.inputCost ?? 0,
|
|
69271
|
+
cachedCost: acc.cachedCost ?? 0,
|
|
69272
|
+
outputCost: acc.outputCost ?? 0,
|
|
69144
69273
|
requestCount: acc.count,
|
|
69145
69274
|
avgCostPerRequest: acc.count > 0 ? acc.totalCost / acc.count : 0
|
|
69146
69275
|
})).sort((a, b) => b.totalCost - a.totalCost);
|
|
@@ -69215,6 +69344,9 @@ var cost_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
69215
69344
|
parent: null,
|
|
69216
69345
|
isRoot: true,
|
|
69217
69346
|
totalCost: ownSummary.totalCost,
|
|
69347
|
+
inputCost: ownSummary.inputCost ?? 0,
|
|
69348
|
+
cachedCost: ownSummary.cachedCost ?? 0,
|
|
69349
|
+
outputCost: ownSummary.outputCost ?? 0,
|
|
69218
69350
|
requestCount: ownSummary.requestCount
|
|
69219
69351
|
},
|
|
69220
69352
|
...descendants.map((child, index) => ({
|
|
@@ -69224,11 +69356,17 @@ var cost_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
69224
69356
|
parent: child.parent,
|
|
69225
69357
|
isRoot: false,
|
|
69226
69358
|
totalCost: descendantSummaries[index]?.totalCost ?? 0,
|
|
69359
|
+
inputCost: descendantSummaries[index]?.inputCost ?? 0,
|
|
69360
|
+
cachedCost: descendantSummaries[index]?.cachedCost ?? 0,
|
|
69361
|
+
outputCost: descendantSummaries[index]?.outputCost ?? 0,
|
|
69227
69362
|
requestCount: descendantSummaries[index]?.requestCount ?? 0
|
|
69228
69363
|
})).filter((row) => row.requestCount > 0)
|
|
69229
69364
|
];
|
|
69230
69365
|
return Response.json({
|
|
69231
69366
|
totalCost: totals.totalCost,
|
|
69367
|
+
inputCost: totals.inputCost,
|
|
69368
|
+
cachedCost: totals.cachedCost,
|
|
69369
|
+
outputCost: totals.outputCost,
|
|
69232
69370
|
ownCost: ownSummary.totalCost,
|
|
69233
69371
|
requestCount: totals.requestCount,
|
|
69234
69372
|
messageCount: totals.messageCount,
|