veryfront 0.1.965 → 0.1.967

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 (52) hide show
  1. package/esm/cli/commands/eval/command.d.ts.map +1 -1
  2. package/esm/cli/commands/eval/command.js +16 -0
  3. package/esm/deno.js +1 -1
  4. package/esm/extensions/ext-llm-anthropic/src/anthropic-stream.d.ts +5 -1
  5. package/esm/extensions/ext-llm-anthropic/src/anthropic-stream.d.ts.map +1 -1
  6. package/esm/extensions/ext-llm-anthropic/src/anthropic-stream.js +290 -179
  7. package/esm/extensions/ext-llm-openai/src/openai-chat-stream.d.ts.map +1 -1
  8. package/esm/extensions/ext-llm-openai/src/openai-chat-stream.js +12 -0
  9. package/esm/extensions/ext-llm-openai/src/openai-provider.d.ts.map +1 -1
  10. package/esm/extensions/ext-llm-openai/src/openai-provider.js +12 -0
  11. package/esm/extensions/ext-llm-openai/src/openai-responses-stream.d.ts +13 -0
  12. package/esm/extensions/ext-llm-openai/src/openai-responses-stream.d.ts.map +1 -1
  13. package/esm/extensions/ext-llm-openai/src/openai-responses-stream.js +40 -0
  14. package/esm/src/agent/ag-ui/browser-chunk-encoder.d.ts.map +1 -1
  15. package/esm/src/agent/ag-ui/browser-chunk-encoder.js +12 -0
  16. package/esm/src/agent/ag-ui/browser-encoder.d.ts +4 -0
  17. package/esm/src/agent/ag-ui/browser-encoder.d.ts.map +1 -1
  18. package/esm/src/agent/ag-ui/browser-encoder.js +56 -0
  19. package/esm/src/agent/ag-ui/browser-finalize-tracker.d.ts.map +1 -1
  20. package/esm/src/agent/ag-ui/browser-finalize-tracker.js +12 -0
  21. package/esm/src/agent/runtime/chat-stream-handler.d.ts +8 -0
  22. package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
  23. package/esm/src/agent/runtime/chat-stream-handler.js +12 -0
  24. package/esm/src/agent/runtime/index.d.ts.map +1 -1
  25. package/esm/src/agent/runtime/index.js +4 -0
  26. package/esm/src/agent/runtime/input-utils.d.ts +8 -0
  27. package/esm/src/agent/runtime/input-utils.d.ts.map +1 -1
  28. package/esm/src/agent/runtime/input-utils.js +14 -0
  29. package/esm/src/agent/runtime/runtime-tool-types.d.ts +8 -0
  30. package/esm/src/agent/runtime/runtime-tool-types.d.ts.map +1 -1
  31. package/esm/src/agent/schemas/agent.schema.d.ts +4 -0
  32. package/esm/src/agent/schemas/agent.schema.d.ts.map +1 -1
  33. package/esm/src/agent/schemas/agent.schema.js +4 -0
  34. package/esm/src/eval/agent-service.d.ts.map +1 -1
  35. package/esm/src/eval/agent-service.js +12 -0
  36. package/esm/src/eval/model-comparison.d.ts.map +1 -1
  37. package/esm/src/eval/model-comparison.js +34 -5
  38. package/esm/src/eval/report.d.ts.map +1 -1
  39. package/esm/src/eval/report.js +4 -0
  40. package/esm/src/eval/studio.d.ts +8 -0
  41. package/esm/src/eval/studio.d.ts.map +1 -1
  42. package/esm/src/eval/studio.js +4 -0
  43. package/esm/src/eval/types.d.ts +13 -1
  44. package/esm/src/eval/types.d.ts.map +1 -1
  45. package/esm/src/provider/runtime-loader/provider-usage.d.ts +4 -0
  46. package/esm/src/provider/runtime-loader/provider-usage.d.ts.map +1 -1
  47. package/esm/src/provider/runtime-loader/provider-usage.js +9 -0
  48. package/esm/src/runtime/runtime-bridge.d.ts.map +1 -1
  49. package/esm/src/runtime/runtime-bridge.js +36 -0
  50. package/esm/src/utils/version-constant.d.ts +1 -1
  51. package/esm/src/utils/version-constant.js +1 -1
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/eval/command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAS,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EACV,cAAc,EAGd,mBAAmB,EAEnB,0BAA0B,EAE1B,UAAU,EACV,oBA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W,GAAG,OAAO,CAAC,IAAI,CAAC,CA8IrE"}
@@ -340,7 +340,11 @@ function usageRows(usage) {
340
340
  ["Total tokens", numberCell(usage.totalTokens)],
341
341
  ["Billable input tokens", numberCell(usage.billableInputTokens)],
342
342
  ["Billable output tokens", numberCell(usage.billableOutputTokens)],
343
+ ["Provider input cost USD", usdCell(usage.providerInputCostUsd)],
344
+ ["Provider output cost USD", usdCell(usage.providerOutputCostUsd)],
343
345
  ["Provider cost USD", usdCell(usage.providerCostUsd ?? usage.costUsd)],
346
+ ["Veryfront input charge USD", usdCell(usage.veryfrontInputChargeUsd)],
347
+ ["Veryfront output charge USD", usdCell(usage.veryfrontOutputChargeUsd)],
344
348
  ["Veryfront charge USD", usdCell(usage.veryfrontChargeUsd)],
345
349
  ["Veryfront billed USD", usdCell(usage.veryfrontBilledUsd)],
346
350
  ["Cost credits", decimalCell(usage.costCredits)],
@@ -477,9 +481,21 @@ export function normalizeUsage(response) {
477
481
  ? { billableOutputTokens: response.usage.billableOutputTokens }
478
482
  : {}),
479
483
  ...(response.usage.costUsd !== undefined ? { costUsd: response.usage.costUsd } : {}),
484
+ ...(response.usage.providerInputCostUsd !== undefined
485
+ ? { providerInputCostUsd: response.usage.providerInputCostUsd }
486
+ : {}),
487
+ ...(response.usage.providerOutputCostUsd !== undefined
488
+ ? { providerOutputCostUsd: response.usage.providerOutputCostUsd }
489
+ : {}),
480
490
  ...(response.usage.providerCostUsd !== undefined
481
491
  ? { providerCostUsd: response.usage.providerCostUsd }
482
492
  : {}),
493
+ ...(response.usage.veryfrontInputChargeUsd !== undefined
494
+ ? { veryfrontInputChargeUsd: response.usage.veryfrontInputChargeUsd }
495
+ : {}),
496
+ ...(response.usage.veryfrontOutputChargeUsd !== undefined
497
+ ? { veryfrontOutputChargeUsd: response.usage.veryfrontOutputChargeUsd }
498
+ : {}),
483
499
  ...(response.usage.veryfrontChargeUsd !== undefined
484
500
  ? { veryfrontChargeUsd: response.usage.veryfrontChargeUsd }
485
501
  : {}),
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.965",
3
+ "version": "0.1.967",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -1,8 +1,12 @@
1
1
  import type { RuntimeUsage } from "../../../src/provider/shared/index.js";
2
+ type AnthropicStreamOptions = {
3
+ clientToolUseTrailingUsageGraceMs?: number;
4
+ };
2
5
  export declare function normalizeAnthropicFinishReason(raw: unknown): string | {
3
6
  unified: string;
4
7
  raw: string;
5
8
  } | null;
6
9
  export declare function extractAnthropicUsage(payload: unknown): RuntimeUsage | undefined;
7
- export declare function streamAnthropicCompatibleParts(stream: ReadableStream<Uint8Array>): AsyncIterable<unknown>;
10
+ export declare function streamAnthropicCompatibleParts(stream: ReadableStream<Uint8Array>, options?: AnthropicStreamOptions): AsyncIterable<unknown>;
11
+ export {};
8
12
  //# sourceMappingURL=anthropic-stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-anthropic/src/anthropic-stream.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAyB1E,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,OAAO,GACX,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAgBlD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAiDhF;AAED,wBAAuB,8BAA8B,CACnD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,aAAa,CAAC,OAAO,CAAC,CA6QxB"}
1
+ {"version":3,"file":"anthropic-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-anthropic/src/anthropic-stream.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAgB1E,KAAK,sBAAsB,GAAG;IAC5B,iCAAiC,CAAC,EAAE,MAAM,CAAC;CAC5C,CAAC;AAmBF,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,OAAO,GACX,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAgBlD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CA6DhF;AAoED,wBAAuB,8BAA8B,CACnD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,GAAE,sBAA2B,GACnC,aAAa,CAAC,OAAO,CAAC,CAoUxB"}
@@ -1,4 +1,7 @@
1
+ import * as dntShim from "../../../_dnt.shims.js";
1
2
  import { mergeUsage, parseSseChunk, readRecord, stringifyJsonValue, } from "../../../src/provider/shared/index.js";
3
+ const CLIENT_TOOL_USE_FINISH_REASON = { unified: "tool-calls", raw: "tool_use" };
4
+ const DEFAULT_CLIENT_TOOL_USE_TRAILING_USAGE_GRACE_MS = 100;
2
5
  function isEmptyRecord(value) {
3
6
  return Boolean(value &&
4
7
  typeof value === "object" &&
@@ -49,9 +52,21 @@ export function extractAnthropicUsage(payload) {
49
52
  ...(typeof veryfront?.billable_output_tokens === "number"
50
53
  ? { billableOutputTokens: veryfront.billable_output_tokens }
51
54
  : {}),
55
+ ...(typeof veryfront?.provider_input_cost_usd === "number"
56
+ ? { providerInputCostUsd: veryfront.provider_input_cost_usd }
57
+ : {}),
58
+ ...(typeof veryfront?.provider_output_cost_usd === "number"
59
+ ? { providerOutputCostUsd: veryfront.provider_output_cost_usd }
60
+ : {}),
52
61
  ...(typeof veryfront?.provider_cost_usd === "number"
53
62
  ? { providerCostUsd: veryfront.provider_cost_usd }
54
63
  : {}),
64
+ ...(typeof veryfront?.veryfront_input_charge_usd === "number"
65
+ ? { veryfrontInputChargeUsd: veryfront.veryfront_input_charge_usd }
66
+ : {}),
67
+ ...(typeof veryfront?.veryfront_output_charge_usd === "number"
68
+ ? { veryfrontOutputChargeUsd: veryfront.veryfront_output_charge_usd }
69
+ : {}),
55
70
  ...(typeof veryfront?.veryfront_charge_usd === "number"
56
71
  ? { veryfrontChargeUsd: veryfront.veryfront_charge_usd }
57
72
  : {}),
@@ -69,231 +84,327 @@ export function extractAnthropicUsage(payload) {
69
84
  : {}),
70
85
  };
71
86
  }
72
- export async function* streamAnthropicCompatibleParts(stream) {
87
+ function isToolCallsFinishReason(finishReason) {
88
+ return finishReason === "tool-calls" ||
89
+ (typeof finishReason === "object" && finishReason?.unified === "tool-calls");
90
+ }
91
+ function hasGatewayUsageMetadata(usage) {
92
+ return usage?.billableInputTokens !== undefined ||
93
+ usage?.billableOutputTokens !== undefined ||
94
+ usage?.providerInputCostUsd !== undefined ||
95
+ usage?.providerOutputCostUsd !== undefined ||
96
+ usage?.providerCostUsd !== undefined ||
97
+ usage?.veryfrontInputChargeUsd !== undefined ||
98
+ usage?.veryfrontOutputChargeUsd !== undefined ||
99
+ usage?.veryfrontChargeUsd !== undefined ||
100
+ usage?.veryfrontBilledUsd !== undefined ||
101
+ usage?.costCredits !== undefined ||
102
+ usage?.costSource !== undefined ||
103
+ usage?.usageCaptureStatus !== undefined;
104
+ }
105
+ async function readStreamChunk(reader, timeoutMs) {
106
+ if (timeoutMs === undefined) {
107
+ const read = await reader.read();
108
+ return read.done ? { kind: "done" } : { kind: "chunk", chunk: read.value };
109
+ }
110
+ let timeoutId;
111
+ const readPromise = reader.read().then((read) => read.done ? { kind: "done" } : { kind: "chunk", chunk: read.value });
112
+ const timeoutPromise = new Promise((resolve) => {
113
+ timeoutId = dntShim.setTimeout(() => resolve({ kind: "timeout" }), Math.max(1, timeoutMs));
114
+ });
115
+ try {
116
+ const result = await Promise.race([readPromise, timeoutPromise]);
117
+ if (result.kind === "timeout") {
118
+ await cancelStreamReader(reader, "Timed out waiting for trailing Anthropic tool-use usage metadata");
119
+ }
120
+ return result;
121
+ }
122
+ finally {
123
+ if (timeoutId) {
124
+ clearTimeout(timeoutId);
125
+ }
126
+ }
127
+ }
128
+ async function cancelStreamReader(reader, reason) {
129
+ try {
130
+ await reader.cancel(reason);
131
+ }
132
+ catch {
133
+ // The upstream body may already be closed or canceled by the runtime.
134
+ }
135
+ }
136
+ export async function* streamAnthropicCompatibleParts(stream, options = {}) {
73
137
  const decoder = new TextDecoder();
138
+ const reader = stream.getReader();
139
+ const trailingUsageGraceMs = options.clientToolUseTrailingUsageGraceMs ??
140
+ DEFAULT_CLIENT_TOOL_USE_TRAILING_USAGE_GRACE_MS;
74
141
  let buffer = "";
75
142
  const toolCalls = new Map();
76
143
  const reasoningBlocks = new Map();
77
144
  let finishReason = null;
78
145
  let usage;
79
146
  let completedClientToolUseStep = false;
80
- for await (const chunk of stream) {
81
- buffer += decoder.decode(chunk, { stream: true });
82
- const parsed = parseSseChunk(buffer);
147
+ let clientToolUseIdleDeadlineMs = null;
148
+ let clientToolUseTerminalDeadlineMs = null;
149
+ const mergeTrailingBufferUsage = () => {
150
+ if (buffer.trim().length === 0) {
151
+ return;
152
+ }
153
+ const parsed = parseSseChunk(`${buffer}\n\n`);
83
154
  buffer = parsed.remainder;
84
155
  for (const event of parsed.events) {
85
156
  if (event === "[DONE]") {
86
157
  continue;
87
158
  }
88
159
  const record = readRecord(event);
89
- const eventType = typeof record?.type === "string" ? record.type : undefined;
90
160
  usage = mergeUsage(usage, extractAnthropicUsage(record));
91
- if (eventType === "message_start") {
92
- usage = mergeUsage(usage, extractAnthropicUsage(record?.message));
93
- continue;
161
+ }
162
+ };
163
+ const getClientToolUseReadTimeoutMs = () => {
164
+ if (!completedClientToolUseStep || toolCalls.size > 0) {
165
+ return undefined;
166
+ }
167
+ const deadline = isToolCallsFinishReason(finishReason)
168
+ ? clientToolUseTerminalDeadlineMs
169
+ : clientToolUseIdleDeadlineMs;
170
+ return deadline === null ? undefined : Math.max(1, deadline - Date.now());
171
+ };
172
+ const buildFinishPart = () => ({
173
+ type: "finish",
174
+ finishReason: finishReason ??
175
+ (completedClientToolUseStep ? CLIENT_TOOL_USE_FINISH_REASON : null),
176
+ ...(usage ? { usage } : {}),
177
+ });
178
+ try {
179
+ while (true) {
180
+ const read = await readStreamChunk(reader, getClientToolUseReadTimeoutMs());
181
+ if (read.kind === "timeout") {
182
+ mergeTrailingBufferUsage();
183
+ finishReason ??= CLIENT_TOOL_USE_FINISH_REASON;
184
+ yield buildFinishPart();
185
+ return;
186
+ }
187
+ if (read.kind === "done") {
188
+ break;
94
189
  }
95
- if (eventType === "content_block_start") {
96
- const index = typeof record?.index === "number" ? record.index : 0;
97
- const contentBlock = readRecord(record?.content_block);
98
- const blockType = typeof contentBlock?.type === "string" ? contentBlock.type : undefined;
99
- if (blockType === "text" && typeof contentBlock?.text === "string" &&
100
- contentBlock.text.length > 0) {
101
- yield { type: "text-delta", delta: contentBlock.text };
190
+ buffer += decoder.decode(read.chunk, { stream: true });
191
+ const parsed = parseSseChunk(buffer);
192
+ buffer = parsed.remainder;
193
+ for (const event of parsed.events) {
194
+ if (event === "[DONE]") {
102
195
  continue;
103
196
  }
104
- if (blockType === "thinking") {
105
- const reasoningId = `thinking-${index}`;
106
- reasoningBlocks.set(index, { id: reasoningId, text: "" });
107
- yield {
108
- type: "reasoning-start",
109
- id: reasoningId,
110
- };
111
- if (typeof contentBlock?.thinking === "string" && contentBlock.thinking.length > 0) {
112
- const current = reasoningBlocks.get(index);
113
- if (current) {
114
- current.text += contentBlock.thinking;
197
+ const record = readRecord(event);
198
+ const eventType = typeof record?.type === "string" ? record.type : undefined;
199
+ usage = mergeUsage(usage, extractAnthropicUsage(record));
200
+ if (eventType === "message_start") {
201
+ usage = mergeUsage(usage, extractAnthropicUsage(record?.message));
202
+ continue;
203
+ }
204
+ if (eventType === "content_block_start") {
205
+ const index = typeof record?.index === "number" ? record.index : 0;
206
+ const contentBlock = readRecord(record?.content_block);
207
+ const blockType = typeof contentBlock?.type === "string" ? contentBlock.type : undefined;
208
+ if (blockType === "text" && typeof contentBlock?.text === "string" &&
209
+ contentBlock.text.length > 0) {
210
+ yield { type: "text-delta", delta: contentBlock.text };
211
+ continue;
212
+ }
213
+ if (blockType === "thinking") {
214
+ const reasoningId = `thinking-${index}`;
215
+ reasoningBlocks.set(index, { id: reasoningId, text: "" });
216
+ yield {
217
+ type: "reasoning-start",
218
+ id: reasoningId,
219
+ };
220
+ if (typeof contentBlock?.thinking === "string" && contentBlock.thinking.length > 0) {
221
+ const current = reasoningBlocks.get(index);
222
+ if (current) {
223
+ current.text += contentBlock.thinking;
224
+ }
225
+ yield {
226
+ type: "reasoning-delta",
227
+ id: reasoningId,
228
+ delta: contentBlock.thinking,
229
+ };
115
230
  }
231
+ continue;
232
+ }
233
+ // Redacted thinking blocks arrive as opaque encrypted payloads when
234
+ // Claude's safety classifier flags the reasoning trace. Surface them
235
+ // as a zero-length reasoning block so callers know thinking happened
236
+ // without leaking the (legitimately hidden) contents.
237
+ if (blockType === "redacted_thinking") {
238
+ const reasoningId = `thinking-${index}`;
239
+ reasoningBlocks.set(index, {
240
+ id: reasoningId,
241
+ text: "",
242
+ ...(typeof contentBlock?.data === "string"
243
+ ? { redactedData: contentBlock.data }
244
+ : {}),
245
+ });
116
246
  yield {
117
- type: "reasoning-delta",
247
+ type: "reasoning-start",
118
248
  id: reasoningId,
119
- delta: contentBlock.thinking,
120
249
  };
250
+ continue;
121
251
  }
122
- continue;
123
- }
124
- // Redacted thinking blocks arrive as opaque encrypted payloads when
125
- // Claude's safety classifier flags the reasoning trace. Surface them
126
- // as a zero-length reasoning block so callers know thinking happened
127
- // without leaking the (legitimately hidden) contents.
128
- if (blockType === "redacted_thinking") {
129
- const reasoningId = `thinking-${index}`;
130
- reasoningBlocks.set(index, {
131
- id: reasoningId,
132
- text: "",
133
- ...(typeof contentBlock?.data === "string" ? { redactedData: contentBlock.data } : {}),
134
- });
135
- yield {
136
- type: "reasoning-start",
137
- id: reasoningId,
138
- };
139
- continue;
140
- }
141
- if ((blockType === "tool_use" || blockType === "server_tool_use") &&
142
- typeof contentBlock?.id === "string" &&
143
- typeof contentBlock?.name === "string") {
144
- const providerExecuted = blockType === "server_tool_use" ? true : undefined;
145
- const current = {
146
- id: contentBlock.id,
147
- name: contentBlock.name,
148
- input: "",
149
- ...(providerExecuted ? { providerExecuted } : {}),
150
- };
151
- toolCalls.set(index, current);
152
- yield {
153
- type: "tool-input-start",
154
- id: current.id,
155
- toolName: current.name,
156
- ...(providerExecuted ? { providerExecuted } : {}),
157
- };
158
- const initialInput = contentBlock.input;
159
- if (initialInput !== undefined && !isEmptyRecord(initialInput)) {
160
- const serializedInput = stringifyJsonValue(initialInput);
161
- current.input += serializedInput;
252
+ if ((blockType === "tool_use" || blockType === "server_tool_use") &&
253
+ typeof contentBlock?.id === "string" &&
254
+ typeof contentBlock?.name === "string") {
255
+ const providerExecuted = blockType === "server_tool_use" ? true : undefined;
256
+ const current = {
257
+ id: contentBlock.id,
258
+ name: contentBlock.name,
259
+ input: "",
260
+ ...(providerExecuted ? { providerExecuted } : {}),
261
+ };
262
+ toolCalls.set(index, current);
263
+ clientToolUseIdleDeadlineMs = null;
264
+ clientToolUseTerminalDeadlineMs = null;
162
265
  yield {
163
- type: "tool-input-delta",
266
+ type: "tool-input-start",
164
267
  id: current.id,
165
- delta: serializedInput,
268
+ toolName: current.name,
269
+ ...(providerExecuted ? { providerExecuted } : {}),
270
+ };
271
+ const initialInput = contentBlock.input;
272
+ if (initialInput !== undefined && !isEmptyRecord(initialInput)) {
273
+ const serializedInput = stringifyJsonValue(initialInput);
274
+ current.input += serializedInput;
275
+ yield {
276
+ type: "tool-input-delta",
277
+ id: current.id,
278
+ delta: serializedInput,
279
+ };
280
+ }
281
+ continue;
282
+ }
283
+ if (blockType === "web_search_tool_result" &&
284
+ typeof contentBlock?.tool_use_id === "string" &&
285
+ Array.isArray(contentBlock?.content)) {
286
+ yield {
287
+ type: "tool-result",
288
+ toolCallId: contentBlock.tool_use_id,
289
+ toolName: "web_search",
290
+ result: contentBlock.content,
291
+ providerExecuted: true,
292
+ };
293
+ }
294
+ if (blockType === "web_fetch_tool_result" &&
295
+ typeof contentBlock?.tool_use_id === "string" &&
296
+ readRecord(contentBlock?.content)) {
297
+ yield {
298
+ type: "tool-result",
299
+ toolCallId: contentBlock.tool_use_id,
300
+ toolName: "web_fetch",
301
+ result: contentBlock.content,
302
+ providerExecuted: true,
166
303
  };
167
304
  }
168
305
  continue;
169
306
  }
170
- if (blockType === "web_search_tool_result" &&
171
- typeof contentBlock?.tool_use_id === "string" &&
172
- Array.isArray(contentBlock?.content)) {
173
- yield {
174
- type: "tool-result",
175
- toolCallId: contentBlock.tool_use_id,
176
- toolName: "web_search",
177
- result: contentBlock.content,
178
- providerExecuted: true,
179
- };
180
- }
181
- if (blockType === "web_fetch_tool_result" &&
182
- typeof contentBlock?.tool_use_id === "string" &&
183
- readRecord(contentBlock?.content)) {
184
- yield {
185
- type: "tool-result",
186
- toolCallId: contentBlock.tool_use_id,
187
- toolName: "web_fetch",
188
- result: contentBlock.content,
189
- providerExecuted: true,
190
- };
191
- }
192
- continue;
193
- }
194
- if (eventType === "content_block_delta") {
195
- const index = typeof record?.index === "number" ? record.index : 0;
196
- const delta = readRecord(record?.delta);
197
- const deltaType = typeof delta?.type === "string" ? delta.type : undefined;
198
- if (deltaType === "text_delta" && typeof delta?.text === "string" && delta.text.length > 0) {
199
- yield { type: "text-delta", delta: delta.text };
200
- continue;
201
- }
202
- if (deltaType === "thinking_delta" && typeof delta?.thinking === "string" &&
203
- delta.thinking.length > 0) {
204
- const current = reasoningBlocks.get(index);
205
- if (!current) {
307
+ if (eventType === "content_block_delta") {
308
+ const index = typeof record?.index === "number" ? record.index : 0;
309
+ const delta = readRecord(record?.delta);
310
+ const deltaType = typeof delta?.type === "string" ? delta.type : undefined;
311
+ if (deltaType === "text_delta" && typeof delta?.text === "string" && delta.text.length > 0) {
312
+ yield { type: "text-delta", delta: delta.text };
206
313
  continue;
207
314
  }
208
- current.text += delta.thinking;
209
- yield {
210
- type: "reasoning-delta",
211
- id: current.id,
212
- delta: delta.thinking,
213
- };
214
- continue;
215
- }
216
- if (deltaType === "signature_delta" && typeof delta?.signature === "string") {
217
- const current = reasoningBlocks.get(index);
218
- if (current) {
219
- current.signature = delta.signature;
315
+ if (deltaType === "thinking_delta" && typeof delta?.thinking === "string" &&
316
+ delta.thinking.length > 0) {
317
+ const current = reasoningBlocks.get(index);
318
+ if (!current) {
319
+ continue;
320
+ }
321
+ current.text += delta.thinking;
322
+ yield {
323
+ type: "reasoning-delta",
324
+ id: current.id,
325
+ delta: delta.thinking,
326
+ };
327
+ continue;
328
+ }
329
+ if (deltaType === "signature_delta" && typeof delta?.signature === "string") {
330
+ const current = reasoningBlocks.get(index);
331
+ if (current) {
332
+ current.signature = delta.signature;
333
+ }
334
+ continue;
335
+ }
336
+ if (deltaType === "input_json_delta" && typeof delta?.partial_json === "string") {
337
+ const current = toolCalls.get(index);
338
+ if (!current) {
339
+ continue;
340
+ }
341
+ current.input += delta.partial_json;
342
+ yield {
343
+ type: "tool-input-delta",
344
+ id: current.id,
345
+ delta: delta.partial_json,
346
+ };
220
347
  }
221
348
  continue;
222
349
  }
223
- if (deltaType === "input_json_delta" && typeof delta?.partial_json === "string") {
350
+ if (eventType === "content_block_stop") {
351
+ const index = typeof record?.index === "number" ? record.index : 0;
352
+ const reasoning = reasoningBlocks.get(index);
353
+ if (reasoning) {
354
+ yield {
355
+ type: "reasoning-end",
356
+ id: reasoning.id,
357
+ ...(reasoning.signature ? { signature: reasoning.signature } : {}),
358
+ ...(reasoning.redactedData ? { redactedData: reasoning.redactedData } : {}),
359
+ };
360
+ reasoningBlocks.delete(index);
361
+ continue;
362
+ }
224
363
  const current = toolCalls.get(index);
225
364
  if (!current) {
226
365
  continue;
227
366
  }
228
- current.input += delta.partial_json;
229
- yield {
230
- type: "tool-input-delta",
231
- id: current.id,
232
- delta: delta.partial_json,
233
- };
234
- }
235
- continue;
236
- }
237
- if (eventType === "content_block_stop") {
238
- const index = typeof record?.index === "number" ? record.index : 0;
239
- const reasoning = reasoningBlocks.get(index);
240
- if (reasoning) {
241
367
  yield {
242
- type: "reasoning-end",
243
- id: reasoning.id,
244
- ...(reasoning.signature ? { signature: reasoning.signature } : {}),
245
- ...(reasoning.redactedData ? { redactedData: reasoning.redactedData } : {}),
368
+ type: "tool-call",
369
+ toolCallId: current.id,
370
+ toolName: current.name,
371
+ input: current.input.length > 0 ? current.input : "{}",
372
+ ...(current.providerExecuted ? { providerExecuted: true } : {}),
246
373
  };
247
- reasoningBlocks.delete(index);
248
- continue;
249
- }
250
- const current = toolCalls.get(index);
251
- if (!current) {
374
+ if (!current.providerExecuted) {
375
+ completedClientToolUseStep = true;
376
+ clientToolUseIdleDeadlineMs = null;
377
+ }
378
+ toolCalls.delete(index);
252
379
  continue;
253
380
  }
254
- yield {
255
- type: "tool-call",
256
- toolCallId: current.id,
257
- toolName: current.name,
258
- input: current.input.length > 0 ? current.input : "{}",
259
- ...(current.providerExecuted ? { providerExecuted: true } : {}),
260
- };
261
- if (!current.providerExecuted) {
262
- completedClientToolUseStep = true;
381
+ if (eventType === "message_delta") {
382
+ const delta = readRecord(record?.delta);
383
+ const normalizedFinishReason = normalizeAnthropicFinishReason(delta?.stop_reason);
384
+ if (normalizedFinishReason) {
385
+ finishReason = normalizedFinishReason;
386
+ }
263
387
  }
264
- toolCalls.delete(index);
265
- continue;
266
388
  }
267
- if (eventType === "message_delta") {
268
- const delta = readRecord(record?.delta);
269
- const normalizedFinishReason = normalizeAnthropicFinishReason(delta?.stop_reason);
270
- if (normalizedFinishReason) {
271
- finishReason = normalizedFinishReason;
389
+ if (completedClientToolUseStep && toolCalls.size === 0) {
390
+ if (isToolCallsFinishReason(finishReason)) {
391
+ clientToolUseIdleDeadlineMs = null;
392
+ clientToolUseTerminalDeadlineMs ??= Date.now() + trailingUsageGraceMs;
393
+ if (hasGatewayUsageMetadata(usage)) {
394
+ await cancelStreamReader(reader, "Finished Anthropic tool-use turn after gateway usage metadata");
395
+ yield buildFinishPart();
396
+ return;
397
+ }
398
+ }
399
+ else {
400
+ clientToolUseIdleDeadlineMs ??= Date.now() + trailingUsageGraceMs;
272
401
  }
273
402
  }
274
403
  }
275
- if (completedClientToolUseStep && toolCalls.size === 0) {
276
- yield {
277
- type: "finish",
278
- finishReason: { unified: "tool-calls", raw: "tool_use" },
279
- ...(usage ? { usage } : {}),
280
- };
281
- return;
282
- }
283
404
  }
284
- if (buffer.trim().length > 0) {
285
- const parsed = parseSseChunk(`${buffer}\n\n`);
286
- for (const event of parsed.events) {
287
- if (event === "[DONE]") {
288
- continue;
289
- }
290
- const record = readRecord(event);
291
- usage = mergeUsage(usage, extractAnthropicUsage(record));
292
- }
405
+ finally {
406
+ reader.releaseLock();
293
407
  }
294
- yield {
295
- type: "finish",
296
- finishReason,
297
- ...(usage ? { usage } : {}),
298
- };
408
+ mergeTrailingBufferUsage();
409
+ yield buildFinishPart();
299
410
  }
@@ -1 +1 @@
1
- {"version":3,"file":"openai-chat-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-stream.ts"],"names":[],"mappings":"AA2IA,wBAAuB,2BAA2B,CAChD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,aAAa,CAAC,OAAO,CAAC,CAsJxB"}
1
+ {"version":3,"file":"openai-chat-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-stream.ts"],"names":[],"mappings":"AA2JA,wBAAuB,2BAA2B,CAChD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,aAAa,CAAC,OAAO,CAAC,CAsJxB"}
@@ -40,9 +40,21 @@ function extractOpenAIUsage(payload) {
40
40
  ? { billableOutputTokens: veryfront.billable_output_tokens }
41
41
  : {}),
42
42
  ...(typeof veryfront?.cost_usd === "number" ? { costUsd: veryfront.cost_usd } : {}),
43
+ ...(typeof veryfront?.provider_input_cost_usd === "number"
44
+ ? { providerInputCostUsd: veryfront.provider_input_cost_usd }
45
+ : {}),
46
+ ...(typeof veryfront?.provider_output_cost_usd === "number"
47
+ ? { providerOutputCostUsd: veryfront.provider_output_cost_usd }
48
+ : {}),
43
49
  ...(typeof veryfront?.provider_cost_usd === "number"
44
50
  ? { providerCostUsd: veryfront.provider_cost_usd }
45
51
  : {}),
52
+ ...(typeof veryfront?.veryfront_input_charge_usd === "number"
53
+ ? { veryfrontInputChargeUsd: veryfront.veryfront_input_charge_usd }
54
+ : {}),
55
+ ...(typeof veryfront?.veryfront_output_charge_usd === "number"
56
+ ? { veryfrontOutputChargeUsd: veryfront.veryfront_output_charge_usd }
57
+ : {}),
46
58
  ...(typeof veryfront?.veryfront_charge_usd === "number"
47
59
  ? { veryfrontChargeUsd: veryfront.veryfront_charge_usd }
48
60
  : {}),