@warpmetrics/warp 0.0.20 → 0.0.22
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/package.json +1 -1
- package/src/core/registry.js +1 -1
- package/src/core/transport.js +8 -14
- package/src/providers/anthropic.js +2 -2
- package/src/trace/trace.js +1 -1
package/package.json
CHANGED
package/src/core/registry.js
CHANGED
package/src/core/transport.js
CHANGED
|
@@ -139,20 +139,14 @@ export async function flush() {
|
|
|
139
139
|
if (config.debug) {
|
|
140
140
|
console.error('[warpmetrics] Flush failed:', err.message);
|
|
141
141
|
}
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
queue.links.unshift(...batch.links);
|
|
151
|
-
queue.outcomes.unshift(...batch.outcomes);
|
|
152
|
-
queue.acts.unshift(...batch.acts);
|
|
153
|
-
} else if (config.debug) {
|
|
154
|
-
console.warn('[warpmetrics] Rate limited - discarding batch to avoid retry loop. Will retry on next flush.');
|
|
155
|
-
}
|
|
142
|
+
// Re-queue so nothing is lost.
|
|
143
|
+
queue.runs.unshift(...batch.runs);
|
|
144
|
+
queue.groups.unshift(...batch.groups);
|
|
145
|
+
queue.calls.unshift(...batch.calls);
|
|
146
|
+
queue.links.unshift(...batch.links);
|
|
147
|
+
queue.outcomes.unshift(...batch.outcomes);
|
|
148
|
+
queue.acts.unshift(...batch.acts);
|
|
149
|
+
throw err;
|
|
156
150
|
}
|
|
157
151
|
}
|
|
158
152
|
|
|
@@ -15,7 +15,7 @@ export function extract(result) {
|
|
|
15
15
|
response: Array.isArray(result?.content)
|
|
16
16
|
? result.content.filter(c => c.type === 'text').map(c => c.text).join('')
|
|
17
17
|
: '',
|
|
18
|
-
tokens: { prompt: input, completion: output, total: input + output, cacheWrite, cacheRead },
|
|
18
|
+
tokens: { prompt: input + cacheWrite + cacheRead, completion: output, total: input + output + cacheWrite + cacheRead, cacheWrite, cacheRead },
|
|
19
19
|
toolCalls: null,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -38,7 +38,7 @@ export function normalizeUsage(usage) {
|
|
|
38
38
|
const completion = usage?.output_tokens || 0;
|
|
39
39
|
const cacheWrite = usage?.cache_creation_input_tokens || 0;
|
|
40
40
|
const cacheRead = usage?.cache_read_input_tokens || 0;
|
|
41
|
-
return { prompt, completion, total: prompt + completion, cacheWrite, cacheRead };
|
|
41
|
+
return { prompt: prompt + cacheWrite + cacheRead, completion, total: prompt + completion + cacheWrite + cacheRead, cacheWrite, cacheRead };
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export function proxy(client, intercept) {
|
package/src/trace/trace.js
CHANGED
|
@@ -49,7 +49,7 @@ export function trace(target, data) {
|
|
|
49
49
|
if (data.opts) event.opts = data.opts;
|
|
50
50
|
if (data.cost != null) {
|
|
51
51
|
const costNum = Number(data.cost);
|
|
52
|
-
if (!isNaN(costNum)) event.
|
|
52
|
+
if (!isNaN(costNum)) event.cost = costNum;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
logCall(event);
|