@trazum/cli 1.51.2 → 1.52.1
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/dist/gateway-server.d.ts +70 -2
- package/dist/gateway-server.d.ts.map +1 -1
- package/dist/gateway-server.js +136 -19
- package/dist/gateway-server.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +20 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +11 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +3 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/gateway-server.ts +186 -11
- package/src/i18n/en.ts +22 -0
- package/src/i18n/es.ts +13 -0
- package/src/i18n/types.ts +3 -0
- package/src/index.ts +46 -1
package/dist/gateway-server.d.ts
CHANGED
|
@@ -51,10 +51,58 @@ export declare const MAX_GATEWAY_BODY_BYTES: number;
|
|
|
51
51
|
* proxy for somebody's API key, and the budget decision only has meaning for
|
|
52
52
|
* the endpoint that spends tokens.
|
|
53
53
|
*/
|
|
54
|
-
export
|
|
54
|
+
export interface Upstream {
|
|
55
55
|
origin: string;
|
|
56
|
+
/**
|
|
57
|
+
* The one path, or the one *shape* of path when the model is part of it.
|
|
58
|
+
*
|
|
59
|
+
* A pattern is not a widening. It exists because Google puts the model in
|
|
60
|
+
* the URL rather than the body, so "one path" cannot be written down as a
|
|
61
|
+
* literal for that provider — and every pattern here is anchored at both
|
|
62
|
+
* ends with the model segment restricted to characters a model id is made
|
|
63
|
+
* of, which is a narrower grammar than a literal comparison against a string
|
|
64
|
+
* somebody could have put a `?` or a `..` in.
|
|
65
|
+
*/
|
|
66
|
+
path: string | RegExp;
|
|
67
|
+
/**
|
|
68
|
+
* Where the model name is, when the request body does not carry one.
|
|
69
|
+
*
|
|
70
|
+
* Gemini's body has `contents` and no `model` field. Reading it out of the
|
|
71
|
+
* validated path is the only honest source: the alternative is a gateway
|
|
72
|
+
* that forwards a call it could not price, which is the one thing standing
|
|
73
|
+
* in the path was for.
|
|
74
|
+
*/
|
|
75
|
+
modelIn?: 'path';
|
|
76
|
+
}
|
|
77
|
+
export declare const UPSTREAMS: Readonly<Record<string, Upstream>>;
|
|
78
|
+
/**
|
|
79
|
+
* The path this gateway forwards for a provider, as a person reads it.
|
|
80
|
+
*
|
|
81
|
+
* One phrasing, used by the refusal, the documentation guard and the security
|
|
82
|
+
* allowlist — because three renderings of the same fact is how the page, the
|
|
83
|
+
* refusal and the test come to disagree about what is actually forwarded.
|
|
84
|
+
*/
|
|
85
|
+
export declare function forwards(upstream: Upstream): string;
|
|
86
|
+
/**
|
|
87
|
+
* Whether this request is the one call this gateway speaks for, and the model
|
|
88
|
+
* the path named if it named one.
|
|
89
|
+
*
|
|
90
|
+
* The returned path is **built here**, never the caller's string echoed back.
|
|
91
|
+
* A pattern that matched is evidence the request was well formed; it is not a
|
|
92
|
+
* licence to forward whatever matched it. Nothing reaches the upstream URL
|
|
93
|
+
* except the compiled-in origin and a path assembled from a model id that has
|
|
94
|
+
* already been restricted to `[A-Za-z0-9._-]`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function route(upstream: Upstream, url: string | undefined): {
|
|
56
97
|
path: string;
|
|
57
|
-
|
|
98
|
+
model: string | null;
|
|
99
|
+
} | null;
|
|
100
|
+
/**
|
|
101
|
+
* Headers Trazum adds or removes. Everything else the caller sent is forwarded
|
|
102
|
+
* verbatim, including their credential, which this never reads.
|
|
103
|
+
*/
|
|
104
|
+
/** Why a forwarded call's cost could not be measured. */
|
|
105
|
+
export type UnmeasuredCause = 'stream-broke' | 'no-usage-event' | 'no-usage-in-body';
|
|
58
106
|
export interface GatewayContext {
|
|
59
107
|
provider: string;
|
|
60
108
|
catalogue: PricingCatalogue;
|
|
@@ -77,6 +125,26 @@ export interface GatewayContext {
|
|
|
77
125
|
cacheWriteTokens: number;
|
|
78
126
|
substituted: boolean;
|
|
79
127
|
}) => void;
|
|
128
|
+
/**
|
|
129
|
+
* A call that was forwarded and whose cost could not be measured.
|
|
130
|
+
*
|
|
131
|
+
* The money is spent either way — the provider generated what it generated —
|
|
132
|
+
* and the period's total will be lower than the bill by however much these
|
|
133
|
+
* came to. Naming them is the only honest option: a zero would be a
|
|
134
|
+
* measurement, and inventing an estimate would merge the two halves this
|
|
135
|
+
* product spent an arc separating.
|
|
136
|
+
*
|
|
137
|
+
* Two causes, and the second is not a failure at all:
|
|
138
|
+
*
|
|
139
|
+
* - `stream-broke` — the connection died before the event carrying the
|
|
140
|
+
* counts. Rare, and a real error.
|
|
141
|
+
* - `no-usage-event` — the stream simply carried no counts. On OpenAI that is
|
|
142
|
+
* **every streaming call** unless the caller passed `stream_options:
|
|
143
|
+
* {include_usage: true}`, so this is the common case rather than the
|
|
144
|
+
* exception, and an operator who is not told will read a total that is
|
|
145
|
+
* quietly missing most of their traffic.
|
|
146
|
+
*/
|
|
147
|
+
unmeasured?: (cause: UnmeasuredCause) => void;
|
|
80
148
|
/** A line for the operator's terminal. Never given a body, ever. */
|
|
81
149
|
note: (line: string) => void;
|
|
82
150
|
/** Injected so the proxy is testable against a stub upstream. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-server.d.ts","sourceRoot":"","sources":["../src/gateway-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,OAAO,KAAK,EAAmB,MAAM,EAAkB,MAAM,WAAW,CAAC;AAEzE,OAAO,KAAK,EAAmB,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEtG,wCAAwC;AACxC,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,QAAkB,CAAC;AAEtD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ACjB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IACvC;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,QAAQ,EAAE;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,OAAO,CAAC;KACtB,KAAK,IAAI,CAAC;IACX;;;;;;;;;;;;;;;;;;OAkBG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC9C,oEAAoE;IACpE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAoHD,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAkO5D;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3C,OAAO,CAAC,MAAM,CAAC,CAajB"}
|
package/dist/gateway-server.js
CHANGED
|
@@ -45,21 +45,75 @@ export const DEFAULT_GATEWAY_PORT = 7318;
|
|
|
45
45
|
* installed to protect.
|
|
46
46
|
*/
|
|
47
47
|
export const MAX_GATEWAY_BODY_BYTES = 8 * 1024 * 1024;
|
|
48
|
-
/**
|
|
49
|
-
* Where each provider actually is, and the one path this speaks for it.
|
|
50
|
-
*
|
|
51
|
-
* Deliberately narrow. A gateway that forwarded any path would be a general
|
|
52
|
-
* proxy for somebody's API key, and the budget decision only has meaning for
|
|
53
|
-
* the endpoint that spends tokens.
|
|
54
|
-
*/
|
|
55
48
|
export const UPSTREAMS = {
|
|
56
49
|
anthropic: { origin: 'https://api.anthropic.com', path: '/v1/messages' },
|
|
57
50
|
openai: { origin: 'https://api.openai.com', path: '/v1/chat/completions' },
|
|
51
|
+
/**
|
|
52
|
+
* DeepSeek's host is not a new fact: `scripts/measure-token-band.mjs` has
|
|
53
|
+
* sent a real API key to `https://api.deepseek.com/chat/completions` since
|
|
54
|
+
* the band harness learned a second provider. Reusing the endpoint this
|
|
55
|
+
* repository already trusts with a credential is the difference between
|
|
56
|
+
* adding an upstream and inventing one — and the path has no `/v1`, which is
|
|
57
|
+
* the kind of detail recall gets wrong.
|
|
58
|
+
*/
|
|
59
|
+
deepseek: { origin: 'https://api.deepseek.com', path: '/chat/completions' },
|
|
60
|
+
/**
|
|
61
|
+
* Google, on the same rule and from a fuller record than DeepSeek's.
|
|
62
|
+
*
|
|
63
|
+
* `packages/core/src/llm.ts` has sent a real key to
|
|
64
|
+
* `https://generativelanguage.googleapis.com` at
|
|
65
|
+
* `/v1beta/models/{model}:generateContent`, with the key in an
|
|
66
|
+
* `x-goog-api-key` header rather than the query string, since the Gemini
|
|
67
|
+
* provider landed. `packages/core/src/usage.ts` has read the counts that
|
|
68
|
+
* come back. Host, path, credential header and response shape are all
|
|
69
|
+
* facts this repository already holds — nothing here was recalled.
|
|
70
|
+
*
|
|
71
|
+
* Only `:generateContent`. `:streamGenerateContent` and `:countTokens` are
|
|
72
|
+
* different operations whose shapes nobody here has established, and a
|
|
73
|
+
* gateway that forwards an operation it cannot read is a general proxy for
|
|
74
|
+
* somebody's key with extra steps.
|
|
75
|
+
*/
|
|
76
|
+
google: {
|
|
77
|
+
origin: 'https://generativelanguage.googleapis.com',
|
|
78
|
+
path: /^\/v1beta\/models\/([A-Za-z0-9._-]+):generateContent$/,
|
|
79
|
+
modelIn: 'path',
|
|
80
|
+
},
|
|
58
81
|
};
|
|
59
82
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
83
|
+
* The path this gateway forwards for a provider, as a person reads it.
|
|
84
|
+
*
|
|
85
|
+
* One phrasing, used by the refusal, the documentation guard and the security
|
|
86
|
+
* allowlist — because three renderings of the same fact is how the page, the
|
|
87
|
+
* refusal and the test come to disagree about what is actually forwarded.
|
|
62
88
|
*/
|
|
89
|
+
export function forwards(upstream) {
|
|
90
|
+
return typeof upstream.path === 'string' ? upstream.path : '/v1beta/models/{model}:generateContent';
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether this request is the one call this gateway speaks for, and the model
|
|
94
|
+
* the path named if it named one.
|
|
95
|
+
*
|
|
96
|
+
* The returned path is **built here**, never the caller's string echoed back.
|
|
97
|
+
* A pattern that matched is evidence the request was well formed; it is not a
|
|
98
|
+
* licence to forward whatever matched it. Nothing reaches the upstream URL
|
|
99
|
+
* except the compiled-in origin and a path assembled from a model id that has
|
|
100
|
+
* already been restricted to `[A-Za-z0-9._-]`.
|
|
101
|
+
*/
|
|
102
|
+
export function route(upstream, url) {
|
|
103
|
+
if (url === undefined)
|
|
104
|
+
return null;
|
|
105
|
+
if (typeof upstream.path === 'string') {
|
|
106
|
+
return url === upstream.path ? { path: upstream.path, model: null } : null;
|
|
107
|
+
}
|
|
108
|
+
const matched = upstream.path.exec(url);
|
|
109
|
+
const model = matched?.[1];
|
|
110
|
+
// A pattern that matched but captured nothing would otherwise build a path
|
|
111
|
+
// containing the word `undefined` and forward it. Refusing is the only
|
|
112
|
+
// answer: there is no model, so there is nothing to price the call against.
|
|
113
|
+
if (model === undefined)
|
|
114
|
+
return null;
|
|
115
|
+
return { path: `/v1beta/models/${model}:generateContent`, model };
|
|
116
|
+
}
|
|
63
117
|
const HOP_BY_HOP = new Set([
|
|
64
118
|
'connection',
|
|
65
119
|
'keep-alive',
|
|
@@ -96,7 +150,7 @@ async function readBody(request) {
|
|
|
96
150
|
* of here, including the decision and the record, is structurally incapable of
|
|
97
151
|
* carrying a prompt.
|
|
98
152
|
*/
|
|
99
|
-
function describe(body, provider) {
|
|
153
|
+
function describe(body, provider, modelFromPath) {
|
|
100
154
|
let parsed;
|
|
101
155
|
try {
|
|
102
156
|
parsed = JSON.parse(body);
|
|
@@ -107,7 +161,15 @@ function describe(body, provider) {
|
|
|
107
161
|
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
108
162
|
return null;
|
|
109
163
|
const request = parsed;
|
|
110
|
-
|
|
164
|
+
/**
|
|
165
|
+
* The body's model, or the one the validated path named.
|
|
166
|
+
*
|
|
167
|
+
* Never both, and the path never overrides a body that carried one: a
|
|
168
|
+
* gateway that preferred the URL could price a call as one model and forward
|
|
169
|
+
* it as another, which is the substitution this product exists to refuse.
|
|
170
|
+
*/
|
|
171
|
+
const model = typeof request.model === 'string' ? request.model : modelFromPath;
|
|
172
|
+
if (model === null)
|
|
111
173
|
return null;
|
|
112
174
|
// Every text field the wire format puts in front of the model, counted and
|
|
113
175
|
// then dropped. `JSON.stringify` of the messages over-counts by the
|
|
@@ -121,10 +183,24 @@ function describe(body, provider) {
|
|
|
121
183
|
parts.push(JSON.stringify(request.messages));
|
|
122
184
|
if (Array.isArray(request.input))
|
|
123
185
|
parts.push(JSON.stringify(request.input));
|
|
186
|
+
// Gemini names the same two things differently: the system prompt is a
|
|
187
|
+
// `systemInstruction` document rather than a string, and the turns are
|
|
188
|
+
// `contents` rather than `messages`. Counted the same way and dropped the
|
|
189
|
+
// same way.
|
|
190
|
+
if (typeof request.systemInstruction === 'object' && request.systemInstruction !== null) {
|
|
191
|
+
parts.push(JSON.stringify(request.systemInstruction));
|
|
192
|
+
}
|
|
193
|
+
if (Array.isArray(request.contents))
|
|
194
|
+
parts.push(JSON.stringify(request.contents));
|
|
124
195
|
const text = parts.join('\n');
|
|
125
|
-
const
|
|
196
|
+
const generation = typeof request.generationConfig === 'object' && request.generationConfig !== null
|
|
197
|
+
? request.generationConfig.maxOutputTokens
|
|
198
|
+
: undefined;
|
|
199
|
+
const max = provider === 'anthropic'
|
|
200
|
+
? request.max_tokens
|
|
201
|
+
: request.max_completion_tokens ?? request.max_tokens ?? generation;
|
|
126
202
|
return {
|
|
127
|
-
model
|
|
203
|
+
model,
|
|
128
204
|
inputTokens: text === '' ? null : estimateTokens(text),
|
|
129
205
|
maxOutputTokens: typeof max === 'number' && Number.isFinite(max) ? max : null,
|
|
130
206
|
/**
|
|
@@ -167,11 +243,18 @@ export function buildGateway(context) {
|
|
|
167
243
|
response.end(`${JSON.stringify({ error: 'no upstream configured for this provider' })}\n`);
|
|
168
244
|
return;
|
|
169
245
|
}
|
|
170
|
-
|
|
246
|
+
const routed = request.method === 'POST' ? route(upstream, request.url) : null;
|
|
247
|
+
if (routed === null) {
|
|
171
248
|
// Only the one path that spends tokens. A gateway forwarding anything
|
|
172
249
|
// else is a general proxy for somebody's API key.
|
|
173
250
|
response.writeHead(404, { 'content-type': 'application/json' });
|
|
174
|
-
response.end(
|
|
251
|
+
response.end(
|
|
252
|
+
// A refusal never arrives bare: the one thing it does forward, said
|
|
253
|
+
// from the upstream table rather than written out again here.
|
|
254
|
+
`${JSON.stringify({
|
|
255
|
+
error: 'not a path this gateway forwards',
|
|
256
|
+
forwards: `POST ${forwards(upstream)}`,
|
|
257
|
+
})}\n`);
|
|
175
258
|
return;
|
|
176
259
|
}
|
|
177
260
|
const body = await readBody(request);
|
|
@@ -180,7 +263,7 @@ export function buildGateway(context) {
|
|
|
180
263
|
response.end(`${JSON.stringify({ error: 'request body too large' })}\n`);
|
|
181
264
|
return;
|
|
182
265
|
}
|
|
183
|
-
const described = describe(body, context.provider);
|
|
266
|
+
const described = describe(body, context.provider, routed.model);
|
|
184
267
|
if (described === null) {
|
|
185
268
|
response.writeHead(400, { 'content-type': 'application/json' });
|
|
186
269
|
response.end(`${JSON.stringify({ error: 'could not read a model out of this request' })}\n`);
|
|
@@ -225,7 +308,7 @@ export function buildGateway(context) {
|
|
|
225
308
|
}
|
|
226
309
|
let upstreamResponse;
|
|
227
310
|
try {
|
|
228
|
-
upstreamResponse = await doFetch(`${upstream.origin}${
|
|
311
|
+
upstreamResponse = await doFetch(`${upstream.origin}${routed.path}`, {
|
|
229
312
|
method: 'POST',
|
|
230
313
|
headers: outgoing,
|
|
231
314
|
body: forwarded,
|
|
@@ -284,7 +367,30 @@ export function buildGateway(context) {
|
|
|
284
367
|
catch {
|
|
285
368
|
measured = null;
|
|
286
369
|
}
|
|
287
|
-
|
|
370
|
+
const buffered = usageFromResponse(context.provider, measured);
|
|
371
|
+
/**
|
|
372
|
+
* The buffered path was the silent one.
|
|
373
|
+
*
|
|
374
|
+
* 1.52 taught the streaming path to say *this call is unmeasured*
|
|
375
|
+
* when no usage event arrived, and left this branch recording nothing
|
|
376
|
+
* and saying nothing — the same silence, on the other side of one
|
|
377
|
+
* `if`. A guard that covers one branch of a fork reads as coverage of
|
|
378
|
+
* the fork.
|
|
379
|
+
*
|
|
380
|
+
* Only on a response the provider called **ok**. An upstream error
|
|
381
|
+
* carries no counts because it produced none, and its own status
|
|
382
|
+
* already says so; announcing those as unmeasured calls would bury the
|
|
383
|
+
* ones that actually spent money.
|
|
384
|
+
*/
|
|
385
|
+
if (buffered === null && upstreamResponse.ok) {
|
|
386
|
+
// The word "body" is deliberately not in this sentence. A security
|
|
387
|
+
// test refuses any `note(...)` mentioning it, prose or variable,
|
|
388
|
+
// because the cost of that rule being blunt is one word of wording
|
|
389
|
+
// and the cost of it being clever is somebody's prompt in a log.
|
|
390
|
+
context.note(`${described.model} answered with no usage counts — this call is unmeasured`);
|
|
391
|
+
context.unmeasured?.('no-usage-in-body');
|
|
392
|
+
}
|
|
393
|
+
recordUsage(buffered);
|
|
288
394
|
response.writeHead(upstreamResponse.status, back);
|
|
289
395
|
response.end(text);
|
|
290
396
|
return;
|
|
@@ -316,10 +422,21 @@ export function buildGateway(context) {
|
|
|
316
422
|
* would be a measurement of the part that arrived and read as the cost.
|
|
317
423
|
*/
|
|
318
424
|
context.note(`stream broke before its usage event: ${error instanceof Error ? error.message : String(error)} — this call is unmeasured`);
|
|
425
|
+
context.unmeasured?.('stream-broke');
|
|
319
426
|
response.destroy();
|
|
320
427
|
return;
|
|
321
428
|
}
|
|
322
|
-
|
|
429
|
+
const streamed = reader.done();
|
|
430
|
+
if (streamed === null) {
|
|
431
|
+
/**
|
|
432
|
+
* The stream ended cleanly and carried no counts. Not an error, and on
|
|
433
|
+
* OpenAI not even unusual — but the call is still unmeasured, and the
|
|
434
|
+
* operator has to hear it from here rather than infer it from a total
|
|
435
|
+
* that looks too small.
|
|
436
|
+
*/
|
|
437
|
+
context.unmeasured?.('no-usage-event');
|
|
438
|
+
}
|
|
439
|
+
recordUsage(streamed);
|
|
323
440
|
response.end();
|
|
324
441
|
})();
|
|
325
442
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-server.js","sourceRoot":"","sources":["../src/gateway-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGxG,wCAAwC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAA+D;IACnF,SAAS,EAAE,EAAE,MAAM,EAAE,2BAA2B,EAAE,IAAI,EAAE,cAAc,EAAE;IACxE,MAAM,EAAE,EAAE,MAAM,EAAE,wBAAwB,EAAE,IAAI,EAAE,sBAAsB,EAAE;CAC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O,EAAE,MAAM,CAAC,CAAC;QAC7B,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACzD,OAAO;QACT,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE;YACxC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;YACzF,OAAO,CAAC,UAAU,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/i18n/en.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9C;;;;;;GAMG;AACH,eAAO,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9C;;;;;;GAMG;AACH,eAAO,MAAM,EAAE,EAAE,WA44EhB,CAAC"}
|
package/dist/i18n/en.js
CHANGED
|
@@ -1106,8 +1106,27 @@ ${bold('EXAMPLES')}
|
|
|
1106
1106
|
badProvider: (given, known) => given === ''
|
|
1107
1107
|
? `Name the provider to stand in front of. Known: ${known}.`
|
|
1108
1108
|
: `"${given}" is not a provider this gateway speaks for. Known: ${known}.`,
|
|
1109
|
+
pricedNotFronted: (given, known) => `Trazum prices ${given} but this gateway does not stand in front of it yet — it fronts ${known}. That is a real gap and it is on the roadmap, not a typo on your part. Until then: "trazum profile" prices a ${given} log you export, and its --max-usd gate fails a build on the bill after the fact. What you do not get is a refusal before the money is spent, which is the whole point of the gateway and the reason this is worth saying rather than listing ${given} as unknown.`,
|
|
1109
1110
|
needsPolicy: (policies) => `--on-cannot-tell is required, and there is no default: ${policies}. When the gateway cannot judge a call — no budget, nothing measured, an unpriced model — one of these happens, and only you know which failure your product can survive. fail-open keeps it working and lets the bill run; fail-closed stops the bill and takes it down with it. Picking one for you would be the most consequential decision in your architecture, made silently at install time.`,
|
|
1110
1111
|
listening: (where, provider) => `Gateway on ${where}, in front of ${provider}`,
|
|
1112
|
+
/**
|
|
1113
|
+
* One sentence per cause, and no `else`.
|
|
1114
|
+
*
|
|
1115
|
+
* This was a two-branch ternary whose second arm explained OpenAI's
|
|
1116
|
+
* `stream_options`. A third cause added later would have inherited that
|
|
1117
|
+
* sentence and told a Gemini user about a setting that does not exist in
|
|
1118
|
+
* their SDK — a message bounded by its neighbour rather than by its
|
|
1119
|
+
* subject, which is this project's most repeated mistake.
|
|
1120
|
+
*/
|
|
1121
|
+
unmeasured: (cause, sofar) => {
|
|
1122
|
+
if (cause === 'stream-broke') {
|
|
1123
|
+
return `unmeasured: the stream broke before its usage event — the provider billed this call and this session cannot see it (${sofar} unmeasured so far)`;
|
|
1124
|
+
}
|
|
1125
|
+
if (cause === 'no-usage-event') {
|
|
1126
|
+
return `unmeasured: the stream carried no usage event — on OpenAI that is every streaming call without stream_options.include_usage, so the total below is short by these (${sofar} unmeasured so far)`;
|
|
1127
|
+
}
|
|
1128
|
+
return `unmeasured: the provider answered without any usage in the body — the call was made and its cost is not knowable from the response, so the total below is short by these (${sofar} unmeasured so far)`;
|
|
1129
|
+
},
|
|
1111
1130
|
pointYourSdk: (where) => `Point your SDK's base URL at ${where} and change nothing else. It speaks the provider's own wire format, so no code changes and no new client.`,
|
|
1112
1131
|
credential: () => 'Your credential is forwarded untouched and never read, never stored, never logged and never put in a URL. Trazum holds no key here and cannot make a call of its own through this.',
|
|
1113
1132
|
neverSubstitutes: () => 'A call over budget is refused with HTTP 402 and the cheaper alternatives named — never silently swapped, trimmed or downgraded. 402 rather than 429 on purpose: every provider SDK retries a 429, which would turn one refusal into a retry storm.',
|
|
@@ -1776,6 +1795,7 @@ ${bold('EXAMPLES')}
|
|
|
1776
1795
|
connect: {
|
|
1777
1796
|
noTarget: (providers) => `Name a provider to read your bill from: trazum connect anthropic. Available: ${providers}. The credential comes from the environment and is never stored — add --dry-run to see exactly what would be called and which variable it would be read from.`,
|
|
1778
1797
|
unknownProvider: (id, providers) => `There is no connector for "${id}". The ones that exist are: ${providers}.`,
|
|
1798
|
+
pricedNoConnector: (id, providers) => `Trazum prices ${id} but has no connector for it yet — it connects to ${providers}. Either that provider publishes no usage API, or one has not been written; both are gaps rather than mistakes of yours. Until then, export a log and run "trazum profile" on it: every figure works except the ones a usage API would supply on its own.`,
|
|
1779
1799
|
dryRun: (provider, from, to, envVars, keyKind) => `Would read ${provider} usage from ${from} to ${to}, using ${keyKind} taken from ${envVars}. Nothing was sent and no credential was needed to print this.`,
|
|
1780
1800
|
heading: (provider, from, to, usd, calls) => calls === null
|
|
1781
1801
|
? `${provider} · ${from} → ${to} · ${usd}`
|