@bivelio/savings-layer 0.4.13 → 0.4.15

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
@@ -58,6 +58,19 @@ declare class SavingsLedger {
58
58
  sentInputLocal: number;
59
59
  /** Tokens que la capa quitó de ese prompt, en cuenta LOCAL. */
60
60
  removedInputLocal: number;
61
+ /**
62
+ * Tokens (LOCAL ruler) that tool_result ELISION removed from the sent prompt.
63
+ * They exist to be SUBTRACTED from `removedInputLocal`: live deletion really
64
+ * lowers `sentInputLocal`, so without this correction the elision saving would
65
+ * enter the reconstructed baseline and the commission, labelled "estimated".
66
+ * The doctrine is the opposite — "live count, shadow money": elision is a COUNT
67
+ * (ledger 2 `eliminatedInput`), its dollar is measured by the shadow lane out
68
+ * of commission, and `basis` stays "measured". Deliberately distinct from the
69
+ * tool-selector drop, which DOES count in the baseline (a declared tool that is
70
+ * not sent is an attributable saving; a superseded tool_result is redundancy
71
+ * not yet billed as verifiable against the invoice).
72
+ */
73
+ elididoLocal: number;
61
74
  /**
62
75
  * ¿El estimador que produjo las dos cifras anteriores cuenta con la regla del
63
76
  * proveedor? Lo fija el pipeline al resolver el tokenizador del modelo.
@@ -169,7 +182,7 @@ declare class SavingsLedger {
169
182
  * catalogue stays out of the way.
170
183
  */
171
184
  /** When these prices were last checked against the providers' public rates. */
172
- declare const PRECIOS_AL_DIA = "2026-08-24";
185
+ declare const PRECIOS_AL_DIA = "2026-09-06";
173
186
  /**
174
187
  * Key = the model id as the provider publishes it, without a vendor prefix.
175
188
  * Lookup tries the exact id, then the id without its provider prefix, then the
@@ -296,6 +309,27 @@ interface SavingsToggles {
296
309
  exactCache?: boolean;
297
310
  semanticCache?: boolean | "safe-only";
298
311
  compression?: boolean | "auto";
312
+ /**
313
+ * OPT-IN. Elide old, large tool_results from a multi-turn context before the
314
+ * request is sent, replacing each one's body with a short stable stub while
315
+ * keeping its `role:"tool"`, `toolCallId` and position. This is the v0
316
+ * (age × size) policy the shadow lane measures — productionized to actually
317
+ * shorten the outgoing prompt, on the generic tool_result segment nothing else
318
+ * in the pipeline touches.
319
+ *
320
+ * IT ONLY RUNS WHEN THE POLICY ALLOWS IT. Like the semantic cache, elision is
321
+ * disabled for write/destructive tools, freshness-sensitive, personalized or
322
+ * stochastic requests, and for `freshnessBucket: "day"` — dropping the output
323
+ * of a past action, or old context a fresh answer still needs, is exactly the
324
+ * degradation the layer must not cause.
325
+ *
326
+ * FIDELITY FLOOR. The newest tool_results are never elided (a keep-floor of at
327
+ * least 8, imported from the provider dial S4a); v0's own age≥2 rule is weaker
328
+ * than that floor, so the floor wins. What it removes is a COUNT on the panel
329
+ * (`eliminated_tokens`); its money value is estimated only in the shadow lane
330
+ * and never enters your commission — your invoice stays the source of truth.
331
+ */
332
+ elision?: boolean;
299
333
  serialization?: boolean | "auto";
300
334
  singleflight?: boolean;
301
335
  deterministicResolvers?: boolean;
@@ -1255,6 +1289,13 @@ interface Policy {
1255
1289
  allowSingleflight: boolean;
1256
1290
  /** May we run natural-language compression on the context? */
1257
1291
  allowCompression: boolean;
1292
+ /**
1293
+ * May the SDK elide old, large tool_results before resending? Computed, not
1294
+ * hardcoded like `allowCompression`: eliding drops whole tool outputs, so it
1295
+ * honors the same vetoes as the semantic cache — write tools, freshness,
1296
+ * personalization, stochastic sampling and `day`.
1297
+ */
1298
+ allowElision: boolean;
1258
1299
  /** Does the request demand current/live data? */
1259
1300
  requiresFreshData: boolean;
1260
1301
  /** Does the request have (or request) side effects? */
@@ -2362,6 +2403,22 @@ interface AnthropicOptions {
2362
2403
  * pointless: the extra breakpoints are rejected by the API, not ignored.
2363
2404
  */
2364
2405
  maxCacheBreakpoints?: number;
2406
+ /**
2407
+ * When true, requests that the pipeline decided to mark also carry the
2408
+ * request-level `cache_control` (Anthropic's automatic caching): the provider
2409
+ * places one extra breakpoint on the last cacheable block and moves it
2410
+ * forward as the conversation grows, so the history beyond the declared
2411
+ * stable prefix is cached incrementally too. It spends one of the four
2412
+ * breakpoint slots and never fires when the economic gate declined to mark.
2413
+ *
2414
+ * Off by default, and deliberately so: the moving breakpoint writes the
2415
+ * volatile tail of EVERY marked request at the 1.25x write premium. That
2416
+ * pays for itself on conversational or agentic traffic — the next turn reads
2417
+ * the whole history at 0.1x — and loses money on one-shot traffic where
2418
+ * nothing ever reads it back. It is also rejected by legacy Bedrock
2419
+ * deployments. Turn it on when your traffic is multi-turn.
2420
+ */
2421
+ automaticCache?: boolean;
2365
2422
  /**
2366
2423
  * Whether a request carrying BOTH the caller's tools and an output contract
2367
2424
  * may send `tool_choice: {type: "any"}`, which obliges the model to answer
@@ -3262,6 +3319,6 @@ declare function createSavingsLayer(config: Omit<SavingsLayerConfig, "tokenizer"
3262
3319
  * constant to package.json so the two can never drift.
3263
3320
  */
3264
3321
 
3265
- declare const BV_SALA_VERSION = "0.4.13";
3322
+ declare const BV_SALA_VERSION = "0.4.15";
3266
3323
 
3267
3324
  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 };