@standardagents/builder 0.24.6 → 0.24.7
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 +151 -23
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-CmZKVcOR.js → ApiKeysView-C_QyBNy2.js} +1 -1
- package/dist/client/{CenteredContentView-DK7rPUK2.js → CenteredContentView-c7OLhxvd.js} +1 -1
- package/dist/client/CompositionView-DqKI6dJ9.js +32 -0
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-h7YuRPAr.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-DQIo2wlE.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-BpQ6CMUp.js → CopyButton.vue_vue_type_script_setup_true_lang-q-A7DQTq.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-DCUZbvUM.js → DataTable.vue_vue_type_script_setup_true_lang-B0UNyBiO.js} +1 -1
- package/dist/client/{JsonViewer-CvwfQYW-.js → JsonViewer-DrA7M9_g.js} +1 -1
- package/dist/client/{LoginView-DnaG5knS.js → LoginView-BxbNgfzz.js} +1 -1
- package/dist/client/{MarketplaceView-fX_Juw54.js → MarketplaceView-DXrtN6-0.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-CFFVfl1g.js → Modal.vue_vue_type_script_setup_true_lang-CLZzFYMW.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-B68s7Jo1.js → ModelModal.vue_vue_type_script_setup_true_lang-BaLZApRs.js} +1 -1
- package/dist/client/{ModelsView-lv4-IyA2.js → ModelsView-CVtPgAVZ.js} +1 -1
- package/dist/client/{PromptEditView-DGaxlMMx.js → PromptEditView-Dhc0rBHD.js} +1 -1
- package/dist/client/{PromptModal-DaW1J_W6.js → PromptModal-DXt6M359.js} +1 -1
- package/dist/client/{PromptsView-CdiBqZey.js → PromptsView-y3yvzkjM.js} +1 -1
- package/dist/client/{ProvidersView-B37bgFKh.js → ProvidersView-DN-SmDPF.js} +1 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-lIW3rtYB.js +22 -0
- package/dist/client/ThreadsView-B1Xo2bP0.js +1 -0
- package/dist/client/{ToolsView-BMKgNq7O.js → ToolsView-DYj_Mk9L.js} +1 -1
- package/dist/client/{UsersView-BDKchqNQ.js → UsersView-BLNNFDUM.js} +1 -1
- package/dist/client/{VariablesView-BPioaCbu.js → VariablesView-D4-5tNwt.js} +1 -1
- package/dist/client/assets/{ThreadInspectorPane-lJJckks4.css → ThreadInspectorPane-CGrBd6US.css} +1 -1
- package/dist/client/assets/index-B38KmIlM.css +1 -0
- package/dist/client/{index-BVfRoUms.js → index-0OxNDXyK.js} +2 -2
- package/dist/client/index.html +2 -2
- package/dist/{index-D3FNNQWC.d.ts → index-Bd--_E_1.d.ts} +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +177 -35
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +12 -2
- package/dist/runtime.js +175 -35
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client/CompositionView-BvVMnyYP.js +0 -32
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DHlNdv7o.js +0 -22
- package/dist/client/ThreadsView-BAfuNShv.js +0 -1
- package/dist/client/assets/index-Djjx6d3k.css +0 -1
package/dist/built-in-routes.js
CHANGED
|
@@ -250,6 +250,12 @@ function resolveModelPricing(modelDef, providerName) {
|
|
|
250
250
|
}
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
253
|
+
function calculateRouterFee(rawCost, feePercent) {
|
|
254
|
+
if (!(rawCost > 0) || !(feePercent > 0)) {
|
|
255
|
+
return 0;
|
|
256
|
+
}
|
|
257
|
+
return roundCost(rawCost * feePercent / 100);
|
|
258
|
+
}
|
|
253
259
|
function calculateUsageCost(usage, pricing) {
|
|
254
260
|
if (!pricing) {
|
|
255
261
|
return null;
|
|
@@ -280,6 +286,66 @@ var init_pricing = __esm({
|
|
|
280
286
|
TOKENS_PER_MILLION = 1e6;
|
|
281
287
|
}
|
|
282
288
|
});
|
|
289
|
+
|
|
290
|
+
// src/agents/providers/router-fee.ts
|
|
291
|
+
function requestUrl(input) {
|
|
292
|
+
if (typeof input === "string") return input;
|
|
293
|
+
if (input instanceof URL) return input.toString();
|
|
294
|
+
if (typeof input === "object" && input !== null && typeof input.url === "string") {
|
|
295
|
+
return input.url;
|
|
296
|
+
}
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
function observeResponse(url, headers) {
|
|
300
|
+
if (!url) return;
|
|
301
|
+
for (const origin of registeredOrigins) {
|
|
302
|
+
if (!url.startsWith(`${origin}/v1/proxy/`)) continue;
|
|
303
|
+
const raw = headers.get(ROUTER_FEE_HEADER);
|
|
304
|
+
if (raw !== null) {
|
|
305
|
+
const percent = Number(raw);
|
|
306
|
+
if (Number.isFinite(percent) && percent >= 0) {
|
|
307
|
+
observedFeePercentByOrigin.set(origin, percent);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function installObserver() {
|
|
314
|
+
if (observerInstalled) return;
|
|
315
|
+
const original = globalThis.fetch;
|
|
316
|
+
if (typeof original !== "function") return;
|
|
317
|
+
const bound = original.bind(globalThis);
|
|
318
|
+
const wrapped = async (input, init) => {
|
|
319
|
+
const response = await bound(input, init);
|
|
320
|
+
try {
|
|
321
|
+
observeResponse(requestUrl(input), response.headers);
|
|
322
|
+
} catch {
|
|
323
|
+
}
|
|
324
|
+
return response;
|
|
325
|
+
};
|
|
326
|
+
try {
|
|
327
|
+
globalThis.fetch = wrapped;
|
|
328
|
+
observerInstalled = true;
|
|
329
|
+
} catch {
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function registerPlatformProxyOrigin(origin) {
|
|
333
|
+
if (!origin) return;
|
|
334
|
+
registeredOrigins.add(origin.replace(/\/+$/, ""));
|
|
335
|
+
installObserver();
|
|
336
|
+
}
|
|
337
|
+
function getObservedRouterFeePercent(origin) {
|
|
338
|
+
return observedFeePercentByOrigin.get(origin.replace(/\/+$/, "")) ?? null;
|
|
339
|
+
}
|
|
340
|
+
var ROUTER_FEE_HEADER, registeredOrigins, observedFeePercentByOrigin, observerInstalled;
|
|
341
|
+
var init_router_fee = __esm({
|
|
342
|
+
"src/agents/providers/router-fee.ts"() {
|
|
343
|
+
ROUTER_FEE_HEADER = "X-Standard-Agents-Router-Fee-Percent";
|
|
344
|
+
registeredOrigins = /* @__PURE__ */ new Set();
|
|
345
|
+
observedFeePercentByOrigin = /* @__PURE__ */ new Map();
|
|
346
|
+
observerInstalled = false;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
283
349
|
async function readCompletedArg(partialJson, argName) {
|
|
284
350
|
if (!partialJson || !argName) return void 0;
|
|
285
351
|
try {
|
|
@@ -839,6 +905,7 @@ var init_ProviderRegistry = __esm({
|
|
|
839
905
|
"src/agents/providers/ProviderRegistry.ts"() {
|
|
840
906
|
init_TestProvider();
|
|
841
907
|
init_platform_routing();
|
|
908
|
+
init_router_fee();
|
|
842
909
|
init_factory();
|
|
843
910
|
ProviderRegistryImpl = class {
|
|
844
911
|
providerCache = /* @__PURE__ */ new Map();
|
|
@@ -933,21 +1000,22 @@ var init_ProviderRegistry = __esm({
|
|
|
933
1000
|
apiKey: routing.apiKey,
|
|
934
1001
|
baseUrl: routing.baseUrl
|
|
935
1002
|
};
|
|
1003
|
+
registerPlatformProxyOrigin(routing.origin);
|
|
936
1004
|
const fingerprint = this.getProviderFingerprint(`platform:${providerName}`, modelDef, config);
|
|
937
1005
|
const cached = this.providerCache.get(modelName);
|
|
938
1006
|
if (cached?.fingerprint === fingerprint) {
|
|
939
|
-
return this.buildResult(cached.provider, modelDef, true);
|
|
1007
|
+
return this.buildResult(cached.provider, modelDef, true, routing.origin);
|
|
940
1008
|
}
|
|
941
|
-
return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, true);
|
|
1009
|
+
return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, true, routing.origin);
|
|
942
1010
|
}
|
|
943
1011
|
throw new Error(`No API key found for provider: ${providerName}. Set the provider key or STANDARD_AGENTS_API_KEY.`);
|
|
944
1012
|
}
|
|
945
|
-
buildResult(provider, modelDef, viaPlatform) {
|
|
946
|
-
return { provider, modelName: modelDef.model, modelDef, viaPlatform };
|
|
1013
|
+
buildResult(provider, modelDef, viaPlatform, platformProxyOrigin) {
|
|
1014
|
+
return { provider, modelName: modelDef.model, modelDef, viaPlatform, platformProxyOrigin };
|
|
947
1015
|
}
|
|
948
|
-
cacheAndReturn(modelName, provider, modelDef, fingerprint, viaPlatform) {
|
|
1016
|
+
cacheAndReturn(modelName, provider, modelDef, fingerprint, viaPlatform, platformProxyOrigin) {
|
|
949
1017
|
this.providerCache.set(modelName, { provider, fingerprint, viaPlatform });
|
|
950
|
-
return this.buildResult(provider, modelDef, viaPlatform);
|
|
1018
|
+
return this.buildResult(provider, modelDef, viaPlatform, platformProxyOrigin);
|
|
951
1019
|
}
|
|
952
1020
|
getProviderFingerprint(providerName, modelDef, config) {
|
|
953
1021
|
return JSON.stringify({
|
|
@@ -1411,6 +1479,7 @@ var NON_VISION_PLACEHOLDER_TEXT, STREAM_FIRST_CHUNK_TIMEOUT_MS, STREAM_STALL_TIM
|
|
|
1411
1479
|
var init_LLMRequest = __esm({
|
|
1412
1480
|
"src/agents/LLMRequest.ts"() {
|
|
1413
1481
|
init_pricing();
|
|
1482
|
+
init_router_fee();
|
|
1414
1483
|
init_types();
|
|
1415
1484
|
init_FlowEngine();
|
|
1416
1485
|
init_toolProgress();
|
|
@@ -1674,11 +1743,7 @@ var init_LLMRequest = __esm({
|
|
|
1674
1743
|
*/
|
|
1675
1744
|
static async callModel(modelId, context, state, logId) {
|
|
1676
1745
|
const { ProviderRegistry: ProviderRegistry2 } = await Promise.resolve().then(() => (init_providers(), providers_exports));
|
|
1677
|
-
const { provider, modelName, modelDef, viaPlatform } = await ProviderRegistry2.getProvider(
|
|
1678
|
-
modelId,
|
|
1679
|
-
state.env,
|
|
1680
|
-
state.thread.instance
|
|
1681
|
-
);
|
|
1746
|
+
const { provider, modelName, modelDef, viaPlatform, platformProxyOrigin } = await ProviderRegistry2.getProvider(modelId, state.env, state.thread.instance);
|
|
1682
1747
|
const streamAbort = new AbortController();
|
|
1683
1748
|
const parentSignal = state.abortController?.signal;
|
|
1684
1749
|
let onParentAbort;
|
|
@@ -1957,6 +2022,12 @@ var init_LLMRequest = __esm({
|
|
|
1957
2022
|
};
|
|
1958
2023
|
response._provider = provider;
|
|
1959
2024
|
response._viaPlatform = viaPlatform;
|
|
2025
|
+
if (platformProxyOrigin) {
|
|
2026
|
+
const feePercent = getObservedRouterFeePercent(platformProxyOrigin);
|
|
2027
|
+
if (feePercent !== null) {
|
|
2028
|
+
response._routerFeePercent = feePercent;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
1960
2031
|
response._providerResponseId = providerResponseId;
|
|
1961
2032
|
response._timing = {
|
|
1962
2033
|
latencyMs: firstChunkAt > 0 ? firstChunkAt - requestSentAt : null,
|
|
@@ -2085,7 +2156,10 @@ var init_LLMRequest = __esm({
|
|
|
2085
2156
|
const resolvedPricing = resolveModelPricing(modelDef) ?? resolveUsageReportedPricing(response.usage) ?? resolveModelPricing(modelDef, providerName);
|
|
2086
2157
|
const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
|
|
2087
2158
|
const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
|
|
2088
|
-
const
|
|
2159
|
+
const rawProviderCost = providerReportedCost != null && !Number.isNaN(providerReportedCost) ? providerReportedCost : calculatedCost?.costTotal ?? null;
|
|
2160
|
+
const routerFeePercent = standardAgentsRouterUsed && typeof response._routerFeePercent === "number" && response._routerFeePercent > 0 ? response._routerFeePercent : null;
|
|
2161
|
+
const costRouterFee = routerFeePercent !== null && rawProviderCost !== null ? calculateRouterFee(rawProviderCost, routerFeePercent) : null;
|
|
2162
|
+
const cost_total = rawProviderCost !== null && costRouterFee !== null && costRouterFee > 0 ? roundCost(rawProviderCost + costRouterFee) : rawProviderCost;
|
|
2089
2163
|
const actualProvider = normalizeProviderMetadataValue(response.usage.provider) ?? null;
|
|
2090
2164
|
const aggregateResponse = response._aggregate_response;
|
|
2091
2165
|
const responseBody = aggregateResponse ? JSON.stringify(aggregateResponse) : JSON.stringify(response);
|
|
@@ -2151,6 +2225,8 @@ var init_LLMRequest = __esm({
|
|
|
2151
2225
|
cost_input: calculatedCost?.costInput,
|
|
2152
2226
|
cost_cached: calculatedCost?.costCached,
|
|
2153
2227
|
cost_output: calculatedCost?.costOutput,
|
|
2228
|
+
cost_router_fee: costRouterFee ?? void 0,
|
|
2229
|
+
router_fee_percent: routerFeePercent ?? void 0,
|
|
2154
2230
|
latency_ms: Date.now() - startTime,
|
|
2155
2231
|
time_to_first_token_ms: timing?.latencyMs ?? void 0,
|
|
2156
2232
|
generation_ms: timing?.generationMs ?? void 0,
|
|
@@ -2191,8 +2267,10 @@ var init_LLMRequest = __esm({
|
|
|
2191
2267
|
actual_provider = ?17,
|
|
2192
2268
|
standard_agents_router_used = ?18,
|
|
2193
2269
|
time_to_first_token_ms = ?19,
|
|
2194
|
-
generation_ms = ?20
|
|
2195
|
-
|
|
2270
|
+
generation_ms = ?20,
|
|
2271
|
+
cost_router_fee = ?21,
|
|
2272
|
+
router_fee_percent = ?22
|
|
2273
|
+
WHERE id = ?23
|
|
2196
2274
|
`,
|
|
2197
2275
|
logData.response_body,
|
|
2198
2276
|
logData.input_tokens,
|
|
@@ -2214,6 +2292,8 @@ var init_LLMRequest = __esm({
|
|
|
2214
2292
|
standardAgentsRouterUsed ? 1 : 0,
|
|
2215
2293
|
logData.time_to_first_token_ms ?? null,
|
|
2216
2294
|
logData.generation_ms ?? null,
|
|
2295
|
+
logData.cost_router_fee ?? null,
|
|
2296
|
+
logData.router_fee_percent ?? null,
|
|
2217
2297
|
logId
|
|
2218
2298
|
);
|
|
2219
2299
|
}
|
|
@@ -2552,9 +2632,24 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2552
2632
|
updates.push(`actual_provider = ?${paramIndex++}`);
|
|
2553
2633
|
values.push(actualProvider);
|
|
2554
2634
|
}
|
|
2635
|
+
let updatedCostTotal;
|
|
2636
|
+
let updatedRouterFee;
|
|
2555
2637
|
if (metadata.generation_cost !== void 0) {
|
|
2638
|
+
updatedCostTotal = metadata.generation_cost;
|
|
2639
|
+
const rawCost = typeof metadata.generation_cost === "number" ? metadata.generation_cost : Number(metadata.generation_cost);
|
|
2640
|
+
if (Number.isFinite(rawCost)) {
|
|
2641
|
+
const feePercent = await this.readRouterFeePercent(state, logId);
|
|
2642
|
+
if (feePercent !== null && feePercent > 0) {
|
|
2643
|
+
updatedRouterFee = calculateRouterFee(rawCost, feePercent);
|
|
2644
|
+
updatedCostTotal = roundCost(rawCost + updatedRouterFee);
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2556
2647
|
updates.push(`cost_total = ?${paramIndex++}`);
|
|
2557
|
-
values.push(
|
|
2648
|
+
values.push(updatedCostTotal);
|
|
2649
|
+
if (updatedRouterFee !== void 0) {
|
|
2650
|
+
updates.push(`cost_router_fee = ?${paramIndex++}`);
|
|
2651
|
+
values.push(updatedRouterFee);
|
|
2652
|
+
}
|
|
2558
2653
|
}
|
|
2559
2654
|
if (updates.length === 0) {
|
|
2560
2655
|
return;
|
|
@@ -2569,7 +2664,8 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2569
2664
|
data: {
|
|
2570
2665
|
id: logId,
|
|
2571
2666
|
...actualProvider !== void 0 && { actual_provider: actualProvider },
|
|
2572
|
-
...metadata.generation_cost !== void 0 && { cost_total:
|
|
2667
|
+
...metadata.generation_cost !== void 0 && { cost_total: updatedCostTotal },
|
|
2668
|
+
...updatedRouterFee !== void 0 && { cost_router_fee: updatedRouterFee }
|
|
2573
2669
|
}
|
|
2574
2670
|
});
|
|
2575
2671
|
}
|
|
@@ -2577,6 +2673,23 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2577
2673
|
console.error("Failed to update log with metadata (non-fatal):", error);
|
|
2578
2674
|
}
|
|
2579
2675
|
}
|
|
2676
|
+
/**
|
|
2677
|
+
* Router-fee percent recorded on a log row by logSuccess, or null when the
|
|
2678
|
+
* row has none (BYOK) or the storage shape doesn't expose it.
|
|
2679
|
+
*/
|
|
2680
|
+
static async readRouterFeePercent(state, logId) {
|
|
2681
|
+
try {
|
|
2682
|
+
const cursor = await state.storage.sql.exec(
|
|
2683
|
+
`SELECT router_fee_percent FROM logs WHERE id = ?`,
|
|
2684
|
+
logId
|
|
2685
|
+
);
|
|
2686
|
+
const row = cursor?.toArray?.()[0];
|
|
2687
|
+
const percent = row?.router_fee_percent;
|
|
2688
|
+
return typeof percent === "number" && Number.isFinite(percent) ? percent : null;
|
|
2689
|
+
} catch {
|
|
2690
|
+
return null;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2580
2693
|
};
|
|
2581
2694
|
}
|
|
2582
2695
|
});
|
|
@@ -54713,11 +54826,17 @@ function transformChatAssistantMessage3(msg) {
|
|
|
54713
54826
|
}));
|
|
54714
54827
|
}
|
|
54715
54828
|
if (msg.reasoningDetails && msg.reasoningDetails.length > 0) {
|
|
54716
|
-
const details = msg.reasoningDetails.filter((detail) =>
|
|
54717
|
-
|
|
54829
|
+
const details = msg.reasoningDetails.filter((detail) => {
|
|
54830
|
+
const type = detail.type;
|
|
54831
|
+
if (type !== "encrypted" && type !== "reasoning.encrypted") return true;
|
|
54832
|
+
return typeof detail.data === "string" && detail.data.length > 0;
|
|
54833
|
+
}).map((detail) => {
|
|
54834
|
+
const type = detail.type;
|
|
54835
|
+
const legacy = detail;
|
|
54836
|
+
if (type === "text" || type === "reasoning.text") {
|
|
54718
54837
|
return { type: "reasoning.text", text: detail.text, format: detail.format };
|
|
54719
|
-
} else if (
|
|
54720
|
-
return { type: "reasoning.summary", summary: detail.text, format: detail.format };
|
|
54838
|
+
} else if (type === "summary" || type === "reasoning.summary") {
|
|
54839
|
+
return { type: "reasoning.summary", summary: detail.text ?? legacy.summary, format: detail.format };
|
|
54721
54840
|
}
|
|
54722
54841
|
return { type: "reasoning.encrypted", data: detail.data, id: detail.id, format: detail.format };
|
|
54723
54842
|
});
|
|
@@ -64704,8 +64823,8 @@ function getHostname(urlValue) {
|
|
|
64704
64823
|
return null;
|
|
64705
64824
|
}
|
|
64706
64825
|
}
|
|
64707
|
-
function deriveOrbPlatformEndpoint(
|
|
64708
|
-
const requestHost = getHostname(
|
|
64826
|
+
function deriveOrbPlatformEndpoint(requestUrl2) {
|
|
64827
|
+
const requestHost = getHostname(requestUrl2);
|
|
64709
64828
|
if (!requestHost) return null;
|
|
64710
64829
|
const match2 = requestHost.match(ORB_CORE_HOST_PATTERN);
|
|
64711
64830
|
if (!match2 || !match2[1]) return null;
|
|
@@ -69220,6 +69339,7 @@ function emptyCostSummary() {
|
|
|
69220
69339
|
inputCost: 0,
|
|
69221
69340
|
cachedCost: 0,
|
|
69222
69341
|
outputCost: 0,
|
|
69342
|
+
routerFeeCost: 0,
|
|
69223
69343
|
requestCount: 0,
|
|
69224
69344
|
messageCount: 0,
|
|
69225
69345
|
byModel: {}
|
|
@@ -69234,12 +69354,14 @@ function mergeByModel(summaries) {
|
|
|
69234
69354
|
inputCost: 0,
|
|
69235
69355
|
cachedCost: 0,
|
|
69236
69356
|
outputCost: 0,
|
|
69357
|
+
routerFeeCost: 0,
|
|
69237
69358
|
count: 0
|
|
69238
69359
|
};
|
|
69239
69360
|
entry.totalCost += acc.totalCost;
|
|
69240
69361
|
entry.inputCost = (entry.inputCost ?? 0) + (acc.inputCost ?? 0);
|
|
69241
69362
|
entry.cachedCost = (entry.cachedCost ?? 0) + (acc.cachedCost ?? 0);
|
|
69242
69363
|
entry.outputCost = (entry.outputCost ?? 0) + (acc.outputCost ?? 0);
|
|
69364
|
+
entry.routerFeeCost = (entry.routerFeeCost ?? 0) + (acc.routerFeeCost ?? 0);
|
|
69243
69365
|
entry.count += acc.count;
|
|
69244
69366
|
merged[modelName] = entry;
|
|
69245
69367
|
}
|
|
@@ -69251,6 +69373,7 @@ function sumSummaries(summaries) {
|
|
|
69251
69373
|
let inputCost = 0;
|
|
69252
69374
|
let cachedCost = 0;
|
|
69253
69375
|
let outputCost = 0;
|
|
69376
|
+
let routerFeeCost = 0;
|
|
69254
69377
|
let requestCount = 0;
|
|
69255
69378
|
let messageCount = 0;
|
|
69256
69379
|
for (const summary of summaries) {
|
|
@@ -69258,10 +69381,11 @@ function sumSummaries(summaries) {
|
|
|
69258
69381
|
inputCost += summary.inputCost ?? 0;
|
|
69259
69382
|
cachedCost += summary.cachedCost ?? 0;
|
|
69260
69383
|
outputCost += summary.outputCost ?? 0;
|
|
69384
|
+
routerFeeCost += summary.routerFeeCost ?? 0;
|
|
69261
69385
|
requestCount += summary.requestCount;
|
|
69262
69386
|
messageCount += summary.messageCount;
|
|
69263
69387
|
}
|
|
69264
|
-
return { totalCost, inputCost, cachedCost, outputCost, requestCount, messageCount };
|
|
69388
|
+
return { totalCost, inputCost, cachedCost, outputCost, routerFeeCost, requestCount, messageCount };
|
|
69265
69389
|
}
|
|
69266
69390
|
function buildModelBreakdown(byModel) {
|
|
69267
69391
|
return Object.entries(byModel).map(([modelName, acc]) => ({
|
|
@@ -69270,6 +69394,7 @@ function buildModelBreakdown(byModel) {
|
|
|
69270
69394
|
inputCost: acc.inputCost ?? 0,
|
|
69271
69395
|
cachedCost: acc.cachedCost ?? 0,
|
|
69272
69396
|
outputCost: acc.outputCost ?? 0,
|
|
69397
|
+
routerFeeCost: acc.routerFeeCost ?? 0,
|
|
69273
69398
|
requestCount: acc.count,
|
|
69274
69399
|
avgCostPerRequest: acc.count > 0 ? acc.totalCost / acc.count : 0
|
|
69275
69400
|
})).sort((a, b) => b.totalCost - a.totalCost);
|
|
@@ -69347,6 +69472,7 @@ var cost_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
69347
69472
|
inputCost: ownSummary.inputCost ?? 0,
|
|
69348
69473
|
cachedCost: ownSummary.cachedCost ?? 0,
|
|
69349
69474
|
outputCost: ownSummary.outputCost ?? 0,
|
|
69475
|
+
routerFeeCost: ownSummary.routerFeeCost ?? 0,
|
|
69350
69476
|
requestCount: ownSummary.requestCount
|
|
69351
69477
|
},
|
|
69352
69478
|
...descendants.map((child, index) => ({
|
|
@@ -69359,6 +69485,7 @@ var cost_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
69359
69485
|
inputCost: descendantSummaries[index]?.inputCost ?? 0,
|
|
69360
69486
|
cachedCost: descendantSummaries[index]?.cachedCost ?? 0,
|
|
69361
69487
|
outputCost: descendantSummaries[index]?.outputCost ?? 0,
|
|
69488
|
+
routerFeeCost: descendantSummaries[index]?.routerFeeCost ?? 0,
|
|
69362
69489
|
requestCount: descendantSummaries[index]?.requestCount ?? 0
|
|
69363
69490
|
})).filter((row) => row.requestCount > 0)
|
|
69364
69491
|
];
|
|
@@ -69367,6 +69494,7 @@ var cost_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
69367
69494
|
inputCost: totals.inputCost,
|
|
69368
69495
|
cachedCost: totals.cachedCost,
|
|
69369
69496
|
outputCost: totals.outputCost,
|
|
69497
|
+
routerFeeCost: totals.routerFeeCost,
|
|
69370
69498
|
ownCost: ownSummary.totalCost,
|
|
69371
69499
|
requestCount: totals.requestCount,
|
|
69372
69500
|
messageCount: totals.messageCount,
|