@buildanagent/gateway 0.1.0-alpha.0 → 0.1.0-alpha.2
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/README.md +11 -5
- package/dist/adapters/anthropic/failure.d.ts +8 -1
- package/dist/adapters/anthropic/failure.js +10 -3
- package/dist/adapters/anthropic/failure.js.map +1 -1
- package/dist/adapters/anthropic/response.d.ts +7 -0
- package/dist/adapters/anthropic/response.js +27 -2
- package/dist/adapters/anthropic/response.js.map +1 -1
- package/dist/adapters/openai-chat/failure.d.ts +8 -1
- package/dist/adapters/openai-chat/failure.js +10 -3
- package/dist/adapters/openai-chat/failure.js.map +1 -1
- package/dist/adapters/openai-chat/usage.d.ts +4 -1
- package/dist/adapters/openai-chat/usage.js +6 -3
- package/dist/adapters/openai-chat/usage.js.map +1 -1
- package/dist/adapters/wire.d.ts +22 -1
- package/dist/adapters/wire.js +54 -4
- package/dist/adapters/wire.js.map +1 -1
- package/dist/cost.d.ts +4 -2
- package/dist/cost.js +13 -3
- package/dist/cost.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/retry.d.ts +5 -2
- package/dist/retry.js +37 -9
- package/dist/retry.js.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.js.map +1 -1
- package/dist/usage.d.ts +9 -1
- package/dist/usage.js +12 -1
- package/dist/usage.js.map +1 -1
- package/package.json +1 -1
package/dist/usage.d.ts
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
import type { Usage } from "./types.js";
|
|
3
3
|
/** All input tokens: uncached, cache reads and both cache-write lifetimes. */
|
|
4
4
|
export declare function totalInput(u: Usage): number;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Adds two usage records; the result keeps the second record's `raw`. The sum is unreported when either record is,
|
|
7
|
+
* because its counts then miss what the unreported response used.
|
|
8
|
+
*/
|
|
6
9
|
export declare function addUsage(a: Usage, b: Usage): Usage;
|
|
7
10
|
/** A usage record with every count at zero. */
|
|
8
11
|
export declare function emptyUsage(raw?: unknown): Usage;
|
|
12
|
+
/**
|
|
13
|
+
* A usage record for a response whose provider reported no usage: every count is zero and `unreported` is `true`,
|
|
14
|
+
* so pricing gives an unknown cost instead of a known zero.
|
|
15
|
+
*/
|
|
16
|
+
export declare function unreportedUsage(raw?: unknown): Usage;
|
package/dist/usage.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
export function totalInput(u) {
|
|
3
3
|
return u.uncachedInput + u.cacheRead + u.cacheWrite["5m"] + u.cacheWrite["1h"];
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Adds two usage records; the result keeps the second record's `raw`. The sum is unreported when either record is,
|
|
7
|
+
* because its counts then miss what the unreported response used.
|
|
8
|
+
*/
|
|
6
9
|
export function addUsage(a, b) {
|
|
7
10
|
return {
|
|
8
11
|
uncachedInput: a.uncachedInput + b.uncachedInput,
|
|
@@ -11,10 +14,18 @@ export function addUsage(a, b) {
|
|
|
11
14
|
output: a.output + b.output,
|
|
12
15
|
reasoning: a.reasoning + b.reasoning,
|
|
13
16
|
raw: b.raw,
|
|
17
|
+
...(a.unreported || b.unreported ? { unreported: true } : {}),
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
/** A usage record with every count at zero. */
|
|
17
21
|
export function emptyUsage(raw = null) {
|
|
18
22
|
return { uncachedInput: 0, cacheRead: 0, cacheWrite: { "5m": 0, "1h": 0 }, output: 0, reasoning: 0, raw };
|
|
19
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* A usage record for a response whose provider reported no usage: every count is zero and `unreported` is `true`,
|
|
26
|
+
* so pricing gives an unknown cost instead of a known zero.
|
|
27
|
+
*/
|
|
28
|
+
export function unreportedUsage(raw = null) {
|
|
29
|
+
return { ...emptyUsage(raw), unreported: true };
|
|
30
|
+
}
|
|
20
31
|
//# sourceMappingURL=usage.js.map
|
package/dist/usage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,CAAQ;IACjC,OAAO,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,CAAQ;IACjC,OAAO,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAQ,EAAE,CAAQ;IACzC,OAAO;QACL,aAAa,EAAE,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa;QAChD,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS;QACpC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC5G,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM;QAC3B,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS;QACpC,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,UAAU,CAAC,GAAG,GAAY,IAAI;IAC5C,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAC5G,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAG,GAAY,IAAI;IACjD,OAAO,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAClD,CAAC","sourcesContent":["/** Usage helpers (D3). */\nimport type { Usage } from \"./types.js\";\n\n/** All input tokens: uncached, cache reads and both cache-write lifetimes. */\nexport function totalInput(u: Usage): number {\n return u.uncachedInput + u.cacheRead + u.cacheWrite[\"5m\"] + u.cacheWrite[\"1h\"];\n}\n\n/**\n * Adds two usage records; the result keeps the second record's `raw`. The sum is unreported when either record is,\n * because its counts then miss what the unreported response used.\n */\nexport function addUsage(a: Usage, b: Usage): Usage {\n return {\n uncachedInput: a.uncachedInput + b.uncachedInput,\n cacheRead: a.cacheRead + b.cacheRead,\n cacheWrite: { \"5m\": a.cacheWrite[\"5m\"] + b.cacheWrite[\"5m\"], \"1h\": a.cacheWrite[\"1h\"] + b.cacheWrite[\"1h\"] },\n output: a.output + b.output,\n reasoning: a.reasoning + b.reasoning,\n raw: b.raw,\n ...(a.unreported || b.unreported ? { unreported: true } : {}),\n };\n}\n\n/** A usage record with every count at zero. */\nexport function emptyUsage(raw: unknown = null): Usage {\n return { uncachedInput: 0, cacheRead: 0, cacheWrite: { \"5m\": 0, \"1h\": 0 }, output: 0, reasoning: 0, raw };\n}\n\n/**\n * A usage record for a response whose provider reported no usage: every count is zero and `unreported` is `true`,\n * so pricing gives an unknown cost instead of a known zero.\n */\nexport function unreportedUsage(raw: unknown = null): Usage {\n return { ...emptyUsage(raw), unreported: true };\n}\n"]}
|
package/package.json
CHANGED