@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.
Files changed (51) hide show
  1. package/dist/built-in-routes.js +153 -15
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/{ApiKeysView-CmObAp7n.js → ApiKeysView-CmZKVcOR.js} +1 -1
  4. package/dist/client/CenteredContentView-DK7rPUK2.js +1 -0
  5. package/dist/client/{CompositionView-BohQwGLE.js → CompositionView-BvVMnyYP.js} +1 -1
  6. 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
  7. 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
  8. 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
  9. package/dist/client/{JsonViewer-CKqMMqjU.js → JsonViewer-CvwfQYW-.js} +1 -1
  10. package/dist/client/{LoginView-BY2NMQQF.js → LoginView-DnaG5knS.js} +1 -1
  11. package/dist/client/{MarketplaceView-DVEMUvDq.js → MarketplaceView-fX_Juw54.js} +1 -1
  12. 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
  13. 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
  14. package/dist/client/{ModelsView-_qZmXle8.js → ModelsView-lv4-IyA2.js} +1 -1
  15. package/dist/client/{PromptEditView-DzY493YB.js → PromptEditView-DGaxlMMx.js} +1 -1
  16. package/dist/client/{PromptModal-BQYwnWKw.js → PromptModal-DaW1J_W6.js} +1 -1
  17. package/dist/client/{PromptsView-DBiQ9X1g.js → PromptsView-CdiBqZey.js} +1 -1
  18. package/dist/client/{ProvidersView-DEH34_v0.js → ProvidersView-B37bgFKh.js} +1 -1
  19. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DHlNdv7o.js +22 -0
  20. package/dist/client/ThreadsView-BAfuNShv.js +1 -0
  21. package/dist/client/{ToolsView-D-qvyctb.js → ToolsView-BMKgNq7O.js} +1 -1
  22. 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
  23. package/dist/client/{UsersView-DaXRB61v.js → UsersView-BDKchqNQ.js} +1 -1
  24. package/dist/client/{VariablesView-DDomn-IB.js → VariablesView-BPioaCbu.js} +1 -1
  25. package/dist/client/assets/{ThreadInspectorPane-CjK6SKEi.css → ThreadInspectorPane-lJJckks4.css} +1 -1
  26. package/dist/client/assets/index-Djjx6d3k.css +1 -0
  27. package/dist/client/{check-DKLwABgc.js → check-Dkzs1C3V.js} +1 -1
  28. package/dist/client/{chevron-right-DJJGHNE5.js → chevron-right-BGirddPg.js} +1 -1
  29. package/dist/client/{copy-CLWiDcxB.js → copy-C08OR8rY.js} +1 -1
  30. package/dist/client/{formkit-DcuuXZjC.js → formkit-YJ1Z7D5r.js} +1 -1
  31. package/dist/client/{index-DihZBCmQ.js → index-BVfRoUms.js} +3 -3
  32. package/dist/client/index.html +4 -4
  33. package/dist/client/{package-CarOhnUs.js → package-guyzMTDG.js} +1 -1
  34. package/dist/client/{plus-zGapov7j.js → plus-DG3ZN5wg.js} +1 -1
  35. package/dist/client/{timeAgo-ASgzq6bq.js → timeAgo-D7V247YG.js} +1 -1
  36. package/dist/client/{useActionFeedback-uUrfjlCo.js → useActionFeedback-byARNQjQ.js} +1 -1
  37. package/dist/client/vue-BqC6IZDY.js +1 -0
  38. package/dist/{index-D7KMmRgr.d.ts → index-D3FNNQWC.d.ts} +7 -1
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +47 -6
  41. package/dist/index.js.map +1 -1
  42. package/dist/runtime.d.ts +9 -2
  43. package/dist/runtime.js +47 -6
  44. package/dist/runtime.js.map +1 -1
  45. package/dist/test.d.ts +1 -1
  46. package/package.json +5 -5
  47. package/dist/client/CenteredContentView-gJXa9UHE.js +0 -1
  48. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-Dtd1VFrj.js +0 -22
  49. package/dist/client/ThreadsView-m1CAq3Aw.js +0 -1
  50. package/dist/client/assets/index-V68N0r_5.css +0 -1
  51. package/dist/client/vue-2tGL2Ulx.js +0 -1
package/dist/index.js CHANGED
@@ -217,6 +217,18 @@ function getFallbackPricing(providerName, modelId) {
217
217
  const pricing = getProviderModelPricing(providerName, modelId);
218
218
  return pricing ? toResolvedModelPricing(pricing) : null;
219
219
  }
220
+ function resolveUsageReportedPricing(usage) {
221
+ const pricing = usage.pricing;
222
+ if (!pricing || typeof pricing.inputPerMillion !== "number" || typeof pricing.outputPerMillion !== "number") {
223
+ return null;
224
+ }
225
+ return {
226
+ inputPrice: pricing.inputPerMillion,
227
+ outputPrice: pricing.outputPerMillion,
228
+ cachedPrice: pricing.cachedInputPerMillion,
229
+ source: "provider"
230
+ };
231
+ }
220
232
  function resolveModelPricing(modelDef, providerName) {
221
233
  if (typeof modelDef.inputPrice === "number" && typeof modelDef.outputPrice === "number") {
222
234
  return {
@@ -1358,7 +1370,8 @@ function convertUsage(usage) {
1358
1370
  prompt_tokens_details: usage.cachedTokens ? { cached_tokens: usage.cachedTokens } : void 0,
1359
1371
  completion_tokens_details: usage.reasoningTokens ? { reasoning_tokens: usage.reasoningTokens } : void 0,
1360
1372
  cost: usage.cost,
1361
- provider: usage.provider
1373
+ provider: usage.provider,
1374
+ pricing: usage.pricing
1362
1375
  };
1363
1376
  }
1364
1377
  function inferProviderFromModelId(model) {
@@ -2053,7 +2066,7 @@ var init_LLMRequest = __esm({
2053
2066
  const toolsCalled = response.tool_calls ? JSON.stringify(response.tool_calls.map((tc) => tc.function.name)) : null;
2054
2067
  const providerName = response._provider?.name;
2055
2068
  const standardAgentsRouterUsed = response._viaPlatform === true || providerName === "platform";
2056
- const resolvedPricing = resolveModelPricing(modelDef, providerName);
2069
+ const resolvedPricing = resolveModelPricing(modelDef) ?? resolveUsageReportedPricing(response.usage) ?? resolveModelPricing(modelDef, providerName);
2057
2070
  const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
2058
2071
  const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
2059
2072
  const cost_total = providerReportedCost != null && !Number.isNaN(providerReportedCost) ? providerReportedCost : calculatedCost?.costTotal ?? null;
@@ -24417,8 +24430,10 @@ var DurableThread = class _DurableThread extends DurableObject {
24417
24430
  async setValue(key, value) {
24418
24431
  await this.ensureMigrated();
24419
24432
  this.assertValidThreadValueKey(key);
24433
+ const updatedAt = Date.now() * 1e3;
24420
24434
  if (value === null || value === void 0) {
24421
24435
  await this.ctx.storage.sql.exec(`DELETE FROM thread_values WHERE key = ?`, key);
24436
+ this.broadcastLog({ type: "kv_data", key, deleted: true, updated_at: updatedAt });
24422
24437
  return;
24423
24438
  }
24424
24439
  const serialized = this.serializeThreadValue(value);
@@ -24432,8 +24447,9 @@ var DurableThread = class _DurableThread extends DurableObject {
24432
24447
  `,
24433
24448
  key,
24434
24449
  serialized,
24435
- Date.now() * 1e3
24450
+ updatedAt
24436
24451
  );
24452
+ this.broadcastLog({ type: "kv_data", key, deleted: false, updated_at: updatedAt });
24437
24453
  }
24438
24454
  async listValues(options = {}) {
24439
24455
  await this.ensureMigrated();
@@ -26489,7 +26505,7 @@ ${resultContent}${attachmentSummary}`;
26489
26505
  SELECT
26490
26506
  id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
26491
26507
  tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
26492
- input_tokens, output_tokens, total_tokens,
26508
+ input_tokens, cached_tokens, output_tokens, total_tokens,
26493
26509
  is_complete, created_at, request_body
26494
26510
  FROM logs
26495
26511
  ORDER BY created_at ${order}
@@ -26515,6 +26531,7 @@ ${resultContent}${attachmentSummary}`;
26515
26531
  error: row.error,
26516
26532
  cost_total: row.cost_total,
26517
26533
  input_tokens: row.input_tokens,
26534
+ cached_tokens: row.cached_tokens,
26518
26535
  output_tokens: row.output_tokens,
26519
26536
  total_tokens: row.total_tokens,
26520
26537
  is_complete: row.is_complete === 1,
@@ -26538,11 +26555,17 @@ ${resultContent}${attachmentSummary}`;
26538
26555
  await this.ensureMigrated();
26539
26556
  const byModel = {};
26540
26557
  let totalCost = 0;
26558
+ let inputCost = 0;
26559
+ let cachedCost = 0;
26560
+ let outputCost = 0;
26541
26561
  let requestCount = 0;
26542
26562
  const modelRows = await this.ctx.storage.sql.exec(
26543
26563
  `
26544
26564
  SELECT COALESCE(model_name, model, 'unknown') AS model_key,
26545
26565
  SUM(cost_total) AS total_cost,
26566
+ SUM(CASE WHEN cost_cached IS NOT NULL THEN cost_input END) AS input_cost,
26567
+ SUM(cost_cached) AS cached_cost,
26568
+ SUM(cost_output) AS output_cost,
26546
26569
  COUNT(*) AS request_count
26547
26570
  FROM logs
26548
26571
  WHERE cost_total IS NOT NULL
@@ -26550,15 +26573,32 @@ ${resultContent}${attachmentSummary}`;
26550
26573
  `
26551
26574
  );
26552
26575
  for (const row of modelRows.toArray()) {
26553
- byModel[row.model_key] = { totalCost: row.total_cost, count: row.request_count };
26576
+ byModel[row.model_key] = {
26577
+ totalCost: row.total_cost,
26578
+ inputCost: row.input_cost ?? 0,
26579
+ cachedCost: row.cached_cost ?? 0,
26580
+ outputCost: row.output_cost ?? 0,
26581
+ count: row.request_count
26582
+ };
26554
26583
  totalCost += row.total_cost;
26584
+ inputCost += row.input_cost ?? 0;
26585
+ cachedCost += row.cached_cost ?? 0;
26586
+ outputCost += row.output_cost ?? 0;
26555
26587
  requestCount += row.request_count;
26556
26588
  }
26557
26589
  const messageRow = await this.ctx.storage.sql.exec(
26558
26590
  `SELECT COUNT(DISTINCT message_id) AS message_count FROM logs WHERE cost_total IS NOT NULL`
26559
26591
  );
26560
26592
  const messageCount = messageRow.one().message_count || 0;
26561
- return { totalCost, requestCount, messageCount, byModel };
26593
+ return {
26594
+ totalCost,
26595
+ inputCost,
26596
+ cachedCost,
26597
+ outputCost,
26598
+ requestCount,
26599
+ messageCount,
26600
+ byModel
26601
+ };
26562
26602
  }
26563
26603
  /**
26564
26604
  * Get specific logs, optionally including all descendant logs.
@@ -27361,6 +27401,7 @@ ${resultContent}${attachmentSummary}`;
27361
27401
  * Broadcast a log record to all connected WebSocket clients
27362
27402
  */
27363
27403
  broadcastLog(log) {
27404
+ if (!this.logSockets || this.logSockets.size === 0) return;
27364
27405
  const payload = JSON.stringify(log);
27365
27406
  for (const ws of Array.from(this.logSockets)) {
27366
27407
  try {