veryfront 0.1.847 → 0.1.848

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 (62) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/extensions/ext-llm-google/src/google-stream.d.ts.map +1 -1
  3. package/esm/extensions/ext-llm-google/src/google-stream.js +2 -0
  4. package/esm/extensions/ext-llm-openai/src/openai-chat-stream.d.ts.map +1 -1
  5. package/esm/extensions/ext-llm-openai/src/openai-chat-stream.js +3 -0
  6. package/esm/extensions/ext-llm-openai/src/openai-provider.d.ts.map +1 -1
  7. package/esm/extensions/ext-llm-openai/src/openai-provider.js +3 -0
  8. package/esm/extensions/ext-llm-openai/src/openai-responses-stream.d.ts +1 -0
  9. package/esm/extensions/ext-llm-openai/src/openai-responses-stream.d.ts.map +1 -1
  10. package/esm/extensions/ext-llm-openai/src/openai-responses-stream.js +3 -0
  11. package/esm/src/agent/ag-ui/browser-encoder.d.ts +5 -0
  12. package/esm/src/agent/ag-ui/browser-encoder.d.ts.map +1 -1
  13. package/esm/src/agent/ag-ui/browser-encoder.js +42 -0
  14. package/esm/src/agent/ag-ui/browser-finalize-tracker.d.ts.map +1 -1
  15. package/esm/src/agent/ag-ui/browser-finalize-tracker.js +15 -0
  16. package/esm/src/agent/ag-ui/chat-ui-chunk-browser-encoder.d.ts +1 -1
  17. package/esm/src/agent/ag-ui/chat-ui-chunk-browser-encoder.d.ts.map +1 -1
  18. package/esm/src/agent/ag-ui/chat-ui-chunk-browser-encoder.js +20 -0
  19. package/esm/src/agent/hosted/agent-run-lifecycle.d.ts +3 -0
  20. package/esm/src/agent/hosted/agent-run-lifecycle.d.ts.map +1 -1
  21. package/esm/src/agent/hosted/lifecycle.d.ts +3 -0
  22. package/esm/src/agent/hosted/lifecycle.d.ts.map +1 -1
  23. package/esm/src/agent/hosted/trace-attributes.d.ts +3 -0
  24. package/esm/src/agent/hosted/trace-attributes.d.ts.map +1 -1
  25. package/esm/src/agent/hosted/trace-attributes.js +10 -2
  26. package/esm/src/agent/runtime/chat-stream-handler.d.ts +8 -0
  27. package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
  28. package/esm/src/agent/runtime/chat-stream-handler.js +11 -1
  29. package/esm/src/agent/runtime/index.d.ts.map +1 -1
  30. package/esm/src/agent/runtime/index.js +6 -1
  31. package/esm/src/agent/runtime/input-utils.d.ts +8 -0
  32. package/esm/src/agent/runtime/input-utils.d.ts.map +1 -1
  33. package/esm/src/agent/runtime/input-utils.js +13 -0
  34. package/esm/src/agent/runtime/runtime-tool-types.d.ts +9 -0
  35. package/esm/src/agent/runtime/runtime-tool-types.d.ts.map +1 -1
  36. package/esm/src/agent/schemas/agent.schema.d.ts +4 -0
  37. package/esm/src/agent/schemas/agent.schema.d.ts.map +1 -1
  38. package/esm/src/agent/schemas/agent.schema.js +4 -0
  39. package/esm/src/channels/invoke.d.ts +8 -0
  40. package/esm/src/channels/invoke.d.ts.map +1 -1
  41. package/esm/src/channels/invoke.js +16 -0
  42. package/esm/src/chat/ag-ui.d.ts +4 -0
  43. package/esm/src/chat/ag-ui.d.ts.map +1 -1
  44. package/esm/src/chat/ag-ui.js +2 -0
  45. package/esm/src/chat/chat-ui-message-helpers.d.ts.map +1 -1
  46. package/esm/src/chat/chat-ui-message-helpers.js +26 -6
  47. package/esm/src/chat/protocol.d.ts +2 -0
  48. package/esm/src/chat/protocol.d.ts.map +1 -1
  49. package/esm/src/chat/types.d.ts +6 -0
  50. package/esm/src/chat/types.d.ts.map +1 -1
  51. package/esm/src/chat/types.js +2 -0
  52. package/esm/src/provider/runtime-loader/provider-usage.d.ts +1 -0
  53. package/esm/src/provider/runtime-loader/provider-usage.d.ts.map +1 -1
  54. package/esm/src/provider/runtime-loader/provider-usage.js +10 -0
  55. package/esm/src/rendering/renderer.d.ts +7 -0
  56. package/esm/src/rendering/renderer.d.ts.map +1 -1
  57. package/esm/src/rendering/renderer.js +169 -1
  58. package/esm/src/runtime/runtime-bridge.d.ts.map +1 -1
  59. package/esm/src/runtime/runtime-bridge.js +46 -0
  60. package/esm/src/utils/version-constant.d.ts +1 -1
  61. package/esm/src/utils/version-constant.js +1 -1
  62. package/package.json +1 -1
@@ -68,14 +68,30 @@ function normalizeUsage(usage) {
68
68
  const inputTokens = "total" in usage.inputTokens && typeof usage.inputTokens.total === "number"
69
69
  ? usage.inputTokens.total
70
70
  : undefined;
71
+ const cacheReadInputTokens = "cached" in usage.inputTokens && typeof usage.inputTokens.cached === "number"
72
+ ? usage.inputTokens.cached
73
+ : "cacheRead" in usage.inputTokens && typeof usage.inputTokens.cacheRead === "number"
74
+ ? usage.inputTokens.cacheRead
75
+ : undefined;
76
+ const cacheCreationInputTokens = "cacheCreation" in usage.inputTokens && typeof usage.inputTokens.cacheCreation === "number"
77
+ ? usage.inputTokens.cacheCreation
78
+ : undefined;
71
79
  const outputTokens = "outputTokens" in usage && typeof usage.outputTokens === "object" && usage.outputTokens &&
72
80
  "total" in usage.outputTokens && typeof usage.outputTokens.total === "number"
73
81
  ? usage.outputTokens.total
74
82
  : undefined;
83
+ const reasoningTokens = "outputTokens" in usage && typeof usage.outputTokens === "object" && usage.outputTokens &&
84
+ "reasoning" in usage.outputTokens && typeof usage.outputTokens.reasoning === "number"
85
+ ? usage.outputTokens.reasoning
86
+ : undefined;
75
87
  return {
76
88
  inputTokens,
77
89
  outputTokens,
78
90
  totalTokens: (inputTokens ?? 0) + (outputTokens ?? 0),
91
+ ...(cacheCreationInputTokens !== undefined ? { cacheCreationInputTokens } : {}),
92
+ ...(cacheReadInputTokens !== undefined ? { cacheReadInputTokens } : {}),
93
+ ...(cacheReadInputTokens !== undefined ? { cachedInputTokens: cacheReadInputTokens } : {}),
94
+ ...(reasoningTokens !== undefined ? { reasoningTokens } : {}),
79
95
  };
80
96
  }
81
97
  const flatUsage = usage;
@@ -83,6 +99,20 @@ function normalizeUsage(usage) {
83
99
  inputTokens: flatUsage.inputTokens,
84
100
  outputTokens: flatUsage.outputTokens,
85
101
  totalTokens: flatUsage.totalTokens,
102
+ ...(typeof flatUsage.cacheCreationInputTokens === "number"
103
+ ? { cacheCreationInputTokens: flatUsage.cacheCreationInputTokens }
104
+ : {}),
105
+ ...(typeof flatUsage.cacheReadInputTokens === "number"
106
+ ? { cacheReadInputTokens: flatUsage.cacheReadInputTokens }
107
+ : {}),
108
+ ...(typeof flatUsage.cachedInputTokens === "number"
109
+ ? { cachedInputTokens: flatUsage.cachedInputTokens }
110
+ : typeof flatUsage.cacheReadInputTokens === "number"
111
+ ? { cachedInputTokens: flatUsage.cacheReadInputTokens }
112
+ : {}),
113
+ ...(typeof flatUsage.reasoningTokens === "number"
114
+ ? { reasoningTokens: flatUsage.reasoningTokens }
115
+ : {}),
86
116
  };
87
117
  }
88
118
  function normalizeFinishReason(finishReason) {
@@ -235,6 +265,7 @@ function normalizeStreamPart(part) {
235
265
  }
236
266
  const finishPart = part;
237
267
  const usage = normalizeUsage(finishPart.usage);
268
+ const recomputedTotal = usage ? (usage.inputTokens ?? 0) + (usage.outputTokens ?? 0) : undefined;
238
269
  return {
239
270
  type: "finish",
240
271
  finishReason: normalizeFinishReason(finishPart.finishReason),
@@ -243,6 +274,21 @@ function normalizeStreamPart(part) {
243
274
  totalUsage: {
244
275
  inputTokens: usage.inputTokens,
245
276
  outputTokens: usage.outputTokens,
277
+ ...(usage.totalTokens !== undefined && usage.totalTokens !== recomputedTotal
278
+ ? { totalTokens: usage.totalTokens }
279
+ : {}),
280
+ ...(usage.cacheCreationInputTokens !== undefined
281
+ ? { cacheCreationInputTokens: usage.cacheCreationInputTokens }
282
+ : {}),
283
+ ...(usage.cacheReadInputTokens !== undefined
284
+ ? { cacheReadInputTokens: usage.cacheReadInputTokens }
285
+ : {}),
286
+ ...(usage.cachedInputTokens !== undefined
287
+ ? { cachedInputTokens: usage.cachedInputTokens }
288
+ : {}),
289
+ ...(usage.reasoningTokens !== undefined
290
+ ? { reasoningTokens: usage.reasoningTokens }
291
+ : {}),
246
292
  },
247
293
  }
248
294
  : {}),
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.847";
2
+ export declare const VERSION = "0.1.848";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.847";
4
+ export const VERSION = "0.1.848";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.847",
3
+ "version": "0.1.848",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",