@bivelio/savings-layer 0.4.29 → 0.4.30

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/index.d.ts CHANGED
@@ -232,6 +232,20 @@ declare class SavingsLedger {
232
232
  providerCached(tokens: number): void;
233
233
  /** Record the premium for `tokens` of cache write the provider bills at `multiplier`x on its own. */
234
234
  providerCacheWritePremium(tokens: number, multiplier: number, price: CostModel): void;
235
+ /** Input tokens of calls the provider documents as not billed; already included in `actualInput`. */
236
+ unbilledInput: number;
237
+ /** Output tokens of those calls; already included in `actualOutput`. */
238
+ unbilledOutput: number;
239
+ /** Provider-cached input tokens of those calls; already included in `providerCachedInput`. */
240
+ unbilledCachedInput: number;
241
+ /** True when the answer served is a refusal the provider does not bill: no saving is credited. */
242
+ servedUnbilledRefusal: boolean;
243
+ /** Record a call the provider documents as not billed: its tokens stay counted and are priced at 0. */
244
+ unbilledCall(usage: {
245
+ inputTokens: number;
246
+ outputTokens: number;
247
+ cachedInputTokens?: number;
248
+ }): void;
235
249
  /** Set when an avoided call is valued against the provider counter of an identical call that ran. */
236
250
  reference: ReferenceCredit | null;
237
251
  /** Set when an avoided cache or coalesced hit could not be valued by reference: why it stays estimated. */
@@ -311,7 +325,7 @@ declare function precioDeLista(model: string, at?: Date | number): CostModel | u
311
325
  * on the customer's machine. `test/version-declarada.test.ts` ties this
312
326
  * constant to package.json so the two can never drift.
313
327
  */
314
- declare const BV_SALA_VERSION = "0.4.29";
328
+ declare const BV_SALA_VERSION = "0.4.30";
315
329
 
316
330
  /**
317
331
  * Environment-agnostic UUID generation.
@@ -3189,6 +3203,19 @@ interface ProviderResponse {
3189
3203
  * replayed by reference. `text` and `finishReason` stay what the provider said.
3190
3204
  */
3191
3205
  refusal?: string;
3206
+ /**
3207
+ * True when this answer is a refusal the provider documents as NOT billed:
3208
+ * Anthropic's Messages API refusal that arrives before any output, in a
3209
+ * category its published table marks as not billed (`cyber`,
3210
+ * `general_harms`, or a `null` category). See
3211
+ * https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback
3212
+ * («How refusals are billed»).
3213
+ *
3214
+ * The layer then measures this call at cost 0 and credits no saving on the
3215
+ * request at all (measured, estimated or by reference). Absent means billed
3216
+ * like any other call. Set it only from the provider's own response.
3217
+ */
3218
+ unbilledRefusal?: boolean;
3192
3219
  /**
3193
3220
  * Llamadas a herramienta que pidió el modelo, tal cual las devolvió el
3194
3221
  * proveedor.
@@ -3777,6 +3804,17 @@ interface SavingsLayerConfig {
3777
3804
  * it when you have your own observability. Applies to the pipeline, the usage
3778
3805
  * emitter, the revocation poller and the provider adapters shipped in this
3779
3806
  * package alike.
3807
+ *
3808
+ * **One warning is NOT silenced: a rejected renewal credential.** When the
3809
+ * automatic pickup of the renewed license gets HTTP 401, 403 or 404 (the
3810
+ * `serviceAccountKey` was rotated, belongs to another organization, or
3811
+ * `licenseServerUrl` is wrong), the SDK warns even with this flag on. That is
3812
+ * not a degraded saving: the token will not renew and the layer will stop
3813
+ * operating when the grace period ends, and the failure happens inside the SDK
3814
+ * where your own observability cannot see it. It is printed once per status
3815
+ * code per layer, never on every renewal attempt, and it never contains the
3816
+ * key or any part of it. Fix the credential, or turn the pickup off with
3817
+ * {@link licenseRefresh}`.enabled = false`, to make it go away.
3780
3818
  */
3781
3819
  silenceWarnings?: boolean;
3782
3820
  /**