@bivelio/savings-layer 0.4.15 → 0.4.17

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
@@ -197,6 +197,16 @@ declare const CATALOGO: Readonly<Record<string, CostModel>>;
197
197
  */
198
198
  declare function precioDeLista(model: string): CostModel | undefined;
199
199
 
200
+ /**
201
+ * The version the SDK reports for itself.
202
+ *
203
+ * Written by hand and deliberately NOT read from package.json: the published
204
+ * bundle does not ship package.json, so a `require` here would fail at runtime
205
+ * on the customer's machine. `test/version-declarada.test.ts` ties this
206
+ * constant to package.json so the two can never drift.
207
+ */
208
+ declare const BV_SALA_VERSION = "0.4.17";
209
+
200
210
  /**
201
211
  * Environment-agnostic UUID generation.
202
212
  * ---------------------------------------------------------------------------
@@ -919,6 +929,20 @@ interface SavingsReport {
919
929
  * and adding `shadow` to either would be making the savings up.
920
930
  */
921
931
  basis: CostBasis;
932
+ /**
933
+ * Provider-side context clearing, priced at the FLOOR: the input tokens the
934
+ * provider itself reported as cleared, valued at this model's cached-input
935
+ * read rate — never at the input rate. Present only when the clearing is
936
+ * attributable to this layer's context-management settings (the request
937
+ * did not already carry them) and the model has a cached-input price.
938
+ *
939
+ * A separate lane on purpose: it is not part of `baselineEstimate`,
940
+ * `actual` or `netSavings`, it is never folded into measured money, and it
941
+ * is not part of the commission base. It is a lower bound of what those
942
+ * tokens would have cost to keep reading, not a claim about the net effect
943
+ * of clearing them.
944
+ */
945
+ eliminatedInputFloorCost?: number;
922
946
  };
923
947
  latencyMs: {
924
948
  total: number;
@@ -2843,6 +2867,14 @@ interface UsageEmitterOptions {
2843
2867
  now?: () => number;
2844
2868
  /** Whether this process is a CI/ephemeral runner (excluded from billable seats). */
2845
2869
  ci?: boolean;
2870
+ /**
2871
+ * Which surface owns this process: the local gateway (`bvsala claude` and
2872
+ * friends) or the in-process SDK. Sent with the version in the batch's
2873
+ * `x-bvsala-version` header (`gateway/0.4.16`, `sdk/0.4.16`) so the control
2874
+ * plane can tell a gateway that lacks a lever from an SDK that never had it.
2875
+ * Defaults to `"sdk"`; the gateway sets `"gateway"`.
2876
+ */
2877
+ surface?: "gateway" | "sdk";
2846
2878
  /**
2847
2879
  * Se llama cuando el ingest rechaza la credencial (401/403). Existe para que un
2848
2880
  * despliegue con observabilidad pueda ENTERARSE: el aviso por consola sirve en
@@ -3292,33 +3324,4 @@ interface SavingsLayer {
3292
3324
  */
3293
3325
  declare function createSavingsLayer(config: Omit<SavingsLayerConfig, "tokenizer"> & Partial<Pick<SavingsLayerConfig, "tokenizer">>): SavingsLayer;
3294
3326
 
3295
- /**
3296
- * bivelio-savings-layer (BV-SALA)
3297
- * ---------------------------------------------------------------------------
3298
- * PROPRIETARY AND CONFIDENTIAL. Copyright (c) 2026 BiVelio Inc.
3299
- * All Rights Reserved. Unauthorized copying, distribution, or use of this
3300
- * software, in whole or in part, is strictly prohibited. See LICENSE.
3301
- * ---------------------------------------------------------------------------
3302
- *
3303
- * A provider-neutral LLM execution optimizer. For every request it answers, in
3304
- * order: Can I avoid this call? Can I avoid retrieval? Can I send fewer tools?
3305
- * What context is actually needed? Should I compress it? Which format costs
3306
- * least for this tokenizer? What is the minimal output contract? Is the saving
3307
- * still positive after all infrastructure is counted?
3308
- *
3309
- * It keeps FOUR separate ledgers — avoided_calls, eliminated_tokens,
3310
- * compressed_tokens, provider_cached_tokens — because mixing them produces
3311
- * misleading metrics.
3312
- */
3313
- /**
3314
- * The version the SDK reports for itself.
3315
- *
3316
- * Written by hand and deliberately NOT read from package.json: the published
3317
- * bundle does not ship package.json, so a `require` here would fail at runtime
3318
- * on the customer's machine. `test/version-declarada.test.ts` ties this
3319
- * constant to package.json so the two can never drift.
3320
- */
3321
-
3322
- declare const BV_SALA_VERSION = "0.4.15";
3323
-
3324
3327
  export { type AnthropicOptions, AnthropicProvider, BV_SALA_VERSION, type BivelioHandoff, CATALOGO, COMPACT_ROWS_INSTRUCTION, type CacheOutcome, type CacheTier, type CachedAnswer, type CanonicalRequest, type ChatMessage, type CompactRowsDecodeOptions, type CompactRowsOptions, type CompactVerification, type CompressionEconomics, type CompressionPolicyInput, type CompressionRequest, type CompressionResult, type Compressor, type ConstraintBackend, type ConstraintBackendId, type ConstraintPlan, type ConversationState, type CostBasis, type CostModel, DEFAULT_COST_MODEL, DEFAULT_MAX_STALENESS_SECONDS, type DeferredExecutionReport, type DeterministicResolver, EMBEDDED_PUBLIC_KEY, type EmbeddingFn, type EvidenceDoc, type ExactCache, ExactTokenizer, type ExecutionClass, ExecutionRouter, type FormatChoice, FormatSelector, type FormatSelectorOptions, type HandoffFact, HeuristicEstimator, InMemoryExactCache, InMemorySemanticCache, type JsonSchema, LicenseError, type LicenseGate, type LicenseKeyset, type LicenseStatus, type LicenseTokenPayload, type LocalClassifier, MODELOS_POR_CODIFICACION, MODELS_BY_ENCODING, type MemoryDelta, type MessageRole, MockProvider, type MockProviderOptions, type ModelCascadeMode, type ModelCascadeReport, type ModelCascadeSettings, type OpenAICompatibleOptions, OpenAICompatibleProvider, type OutputContract, PRECIOS_AL_DIA, type Policy, type ProtectedSpan, type Provider, type ProviderRequest, type ProviderResponse, type ProviderUsage, QUALITY_STATUSES, type QualityStatus, type RequestContext, type Reranker, type ResolvedDeps, type ResolvedGate, type ResolvedLicense, ResolverRegistry, type ResolverResult, type RetrievalOptions, type RetrievalOutcome, type RetrievalPlan, type Retriever, type RevocationListBody, type RevocationListVerification, type RevocationPollEvent, RevocationPoller, type RevocationPollerOptions, RevocationSnapshot, type RouteDecision, type SavingsLayer, type SavingsLayerConfig, SavingsLedger, type SavingsReport, type SavingsRequest, type SavingsResult, type SavingsToggles, SchemaRegistry, type SemanticCacheOptions, type SemanticHit, type SemanticRecord, type SemanticVerifier, type SerializationFormat, type Serializer, Singleflight, type TokenEstimator, TokenizerRegistry, type ToolCallRequest, type ToolDescriptor, type ToolRisk, type ToolSelection, ToolSelector, type ToolSelectorOptions, TraceCollector, type TraceEvent, UMBRAL_LOCAL, UsageEmitter, type UsageEmitterOptions, type ValidationError, type ValidationResult, adaptiveK, arithmeticResolver, buildExactKey, buildInflightKey, canonicalize, compactRowsSerializer, compresionFiel, computeNextDelay, cosine, createCompactRowsSerializer, createDefaultResolvers, createHandoff, createMockProvider, createSavingsLayer, csvSerializer, decodeCompactRows, dedupe, defaultTokenizerRegistry, deriveSeatId, deriveStatus, detectCi, embebedorLocal, emptyState, encodeCompactRows, evalArithmetic, evaluatePolicy, executeRetrievalPlan, gateFromKey, heuristicEstimator, isKeyset, isStrictCompatible, jsonCompactSerializer, keyTokensMatch, liveGateFromKey, mergeDelta, modelFamilyOf, multisetEqual, negationCount, noopCompressor, normalizeText, numericTokens, precioDeLista, projectContext, providerNativeBackend, randomId, registerExactTokenizer, registrarTokenizadorExacto, renderState, resolveConstraintBackend, resolveDependencies, resolveLicense, sha256, shouldCompress, stableStringify, uniformColumns, validateAgainstSchema, vectorLocal, verifyCompactSignature, verifyLicenseToken, verifyRevocationList, withProtectedSpans, words };