async-bulkhead-llm 3.7.0 → 3.9.0

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.
Files changed (56) hide show
  1. package/README.md +282 -8
  2. package/dist/cjs/adaptive.cjs +128 -0
  3. package/dist/cjs/adaptive.cjs.map +1 -0
  4. package/dist/cjs/bulkhead.cjs +1063 -0
  5. package/dist/cjs/bulkhead.cjs.map +1 -0
  6. package/dist/cjs/dedup.cjs +111 -0
  7. package/dist/cjs/dedup.cjs.map +1 -0
  8. package/dist/cjs/errors.cjs +16 -0
  9. package/dist/cjs/errors.cjs.map +1 -0
  10. package/dist/cjs/estimators.cjs +205 -0
  11. package/dist/cjs/estimators.cjs.map +1 -0
  12. package/dist/cjs/index.cjs +27 -1123
  13. package/dist/cjs/index.cjs.map +1 -1
  14. package/dist/cjs/profiles.cjs +16 -0
  15. package/dist/cjs/profiles.cjs.map +1 -0
  16. package/dist/cjs/types.cjs +3 -0
  17. package/dist/cjs/types.cjs.map +1 -0
  18. package/dist/cjs/validation.cjs +39 -0
  19. package/dist/cjs/validation.cjs.map +1 -0
  20. package/dist/esm/adaptive.js +125 -0
  21. package/dist/esm/adaptive.js.map +1 -0
  22. package/dist/esm/bulkhead.js +1060 -0
  23. package/dist/esm/bulkhead.js.map +1 -0
  24. package/dist/esm/dedup.js +106 -0
  25. package/dist/esm/dedup.js.map +1 -0
  26. package/dist/esm/errors.js +12 -0
  27. package/dist/esm/errors.js.map +1 -0
  28. package/dist/esm/estimators.js +200 -0
  29. package/dist/esm/estimators.js.map +1 -0
  30. package/dist/esm/index.js +19 -1117
  31. package/dist/esm/index.js.map +1 -1
  32. package/dist/esm/profiles.js +13 -0
  33. package/dist/esm/profiles.js.map +1 -0
  34. package/dist/esm/types.js +2 -0
  35. package/dist/esm/types.js.map +1 -0
  36. package/dist/esm/validation.js +32 -0
  37. package/dist/esm/validation.js.map +1 -0
  38. package/dist/types/adaptive.d.ts +109 -0
  39. package/dist/types/adaptive.d.ts.map +1 -0
  40. package/dist/types/bulkhead.d.ts +31 -0
  41. package/dist/types/bulkhead.d.ts.map +1 -0
  42. package/dist/types/dedup.d.ts +32 -0
  43. package/dist/types/dedup.d.ts.map +1 -0
  44. package/dist/types/errors.d.ts +9 -0
  45. package/dist/types/errors.d.ts.map +1 -0
  46. package/dist/types/estimators.d.ts +91 -0
  47. package/dist/types/estimators.d.ts.map +1 -0
  48. package/dist/types/index.d.ts +27 -660
  49. package/dist/types/index.d.ts.map +1 -1
  50. package/dist/types/profiles.d.ts +11 -0
  51. package/dist/types/profiles.d.ts.map +1 -0
  52. package/dist/types/types.d.ts +666 -0
  53. package/dist/types/types.d.ts.map +1 -0
  54. package/dist/types/validation.d.ts +12 -0
  55. package/dist/types/validation.d.ts.map +1 -0
  56. package/package.json +1 -1
@@ -0,0 +1,666 @@
1
+ /**
2
+ * Public request, result, options, stats, and event types shared across
3
+ * the library. Type declarations only — no runtime code lives here.
4
+ */
5
+ import type { AcquireOptions, Stats, RejectReason as BaseRejectReason } from "async-bulkhead-ts";
6
+ import type { LLMBulkheadPreset } from "./profiles.js";
7
+ /**
8
+ * A text content block. The only block type that contributes to
9
+ * character-based token estimation.
10
+ */
11
+ export type TextContentBlock = {
12
+ type: "text";
13
+ text: string;
14
+ };
15
+ /**
16
+ * A non-text content block (image, tool_result, document, etc.).
17
+ *
18
+ * By default, built-in estimators ignore non-text blocks — token
19
+ * estimates for multimodal requests should then be treated as a lower
20
+ * bound. To charge a fixed reservation per opaque block instead, use
21
+ * `createModelAwareTokenEstimator`'s `opaqueBlockTokens` option, or
22
+ * carry a caller-computed total in `LLMRequest.extraInputTokens`, or
23
+ * provide a custom estimator.
24
+ */
25
+ export type OpaqueContentBlock = {
26
+ type: string;
27
+ [key: string]: unknown;
28
+ };
29
+ export type ContentBlock = TextContentBlock | OpaqueContentBlock;
30
+ /**
31
+ * Minimal message shape shared across estimators.
32
+ *
33
+ * `content` may be a plain string (backward-compatible with v1) or
34
+ * an array of content blocks for multimodal requests.
35
+ */
36
+ export type LLMMessage = {
37
+ role: string;
38
+ content: string | ContentBlock[];
39
+ };
40
+ /**
41
+ * Minimal request shape.
42
+ *
43
+ * `model` is optional at the request level. When present, the estimator
44
+ * uses it for ratio lookup instead of the bulkhead-level default.
45
+ * This supports A/B testing, canary deployments, and mixed-model routing
46
+ * through a single bulkhead.
47
+ */
48
+ export type LLMRequest = {
49
+ model?: string;
50
+ messages: LLMMessage[];
51
+ max_tokens?: number;
52
+ /**
53
+ * Optional system prompt (v3.7). Counted by the built-in estimators
54
+ * exactly like message content: a plain string, or an array of content
55
+ * blocks (text blocks counted by characters, non-text blocks subject
56
+ * to the model-aware estimator's `opaqueBlockTokens` surcharge).
57
+ *
58
+ * Before v3.7, callers had to fold the system prompt into a synthetic
59
+ * message for it to participate in estimation — which also distorted
60
+ * events, logs, and deduplication keys. Carry it here instead.
61
+ */
62
+ system?: string | ContentBlock[];
63
+ /**
64
+ * Additional input tokens the character-based estimators cannot see
65
+ * (v3.7) — e.g. provider-side cost of tool schemas kept outside
66
+ * `messages`, or media priced by out-of-band rules. Built-in
67
+ * estimators add this verbatim to their input estimate; custom
68
+ * estimators may honor or ignore it.
69
+ *
70
+ * Must be a non-negative integer when present. Participates in the
71
+ * default deduplication key like any other request field, so requests
72
+ * differing only here are never conflated.
73
+ */
74
+ extraInputTokens?: number;
75
+ };
76
+ export type TokenEstimate = {
77
+ input: number;
78
+ maxOutput: number;
79
+ };
80
+ /**
81
+ * Exact token reservation the bulkhead will use for admission.
82
+ *
83
+ * `null` is returned by `bulkhead.estimate()` when `tokenBudget` is not
84
+ * configured, because no token reservation participates in admission in
85
+ * that mode.
86
+ */
87
+ export type LLMReservationEstimate = {
88
+ readonly input: number;
89
+ readonly maxOutput: number;
90
+ readonly reserved: number;
91
+ };
92
+ export type TokenEstimator = (request: LLMRequest) => TokenEstimate;
93
+ /**
94
+ * Accepted shape for the per-call `reservation` override (v3.8).
95
+ *
96
+ * Structurally this is a `TokenEstimate` plus an optional `reserved`
97
+ * field, which means the object returned by `bulkhead.estimate()`
98
+ * (an `LLMReservationEstimate`) can be passed back verbatim — no need
99
+ * to strip `reserved` first. When `reserved` is present it is treated
100
+ * as a consistency check: it must equal `input + maxOutput`, otherwise
101
+ * admission throws. This catches hand-built overrides whose fields
102
+ * drifted apart (e.g. a cached `reserved` paired with edited parts).
103
+ */
104
+ export type LLMReservationOverride = TokenEstimate & {
105
+ /** Optional cross-check; must equal `input + maxOutput` when present. */
106
+ reserved?: number;
107
+ };
108
+ /**
109
+ * Result of `wouldAdmit()` (v3.8: optional capacity snapshot).
110
+ *
111
+ * `detail` is present only when the call passed `detail: true`. It is
112
+ * the same `LLMRejectDetail` snapshot attached to real rejections —
113
+ * including on an `admit: true` result, where it describes the capacity
114
+ * the request *would* be admitted against. Like the boolean itself, it
115
+ * is advisory: capacity can change before a subsequent `acquire()`.
116
+ */
117
+ export type LLMWouldAdmitResult = {
118
+ admit: boolean;
119
+ reason?: LLMRejectReason;
120
+ detail?: LLMRejectDetail;
121
+ };
122
+ /**
123
+ * Result of `drain({ timeoutMs })` (v3.8).
124
+ *
125
+ * `drained: true` means all in-flight work and pending waiters
126
+ * completed within the deadline (`inFlight`/`pending` are then 0).
127
+ * `drained: false` means the deadline elapsed first; `inFlight` and
128
+ * `pending` report what was still outstanding at that moment.
129
+ */
130
+ export type LLMDrainResult = {
131
+ drained: boolean;
132
+ inFlight: number;
133
+ pending: number;
134
+ };
135
+ /**
136
+ * Actual token usage returned by the provider after a call completes.
137
+ *
138
+ * In v2, this drives the refund mechanism: when usage is reported at
139
+ * release time, the difference between the pre-admission reservation
140
+ * and actual consumption is returned to the budget immediately.
141
+ */
142
+ export type TokenUsage = {
143
+ input: number;
144
+ output: number;
145
+ };
146
+ /**
147
+ * Rejection reasons.
148
+ *
149
+ * `"unshareable_result"` (v3.5) is raised only for deduplication
150
+ * *followers*: the shared call resolved to a single-consumer value
151
+ * (stream, `Response` with a body, async iterable) that cannot be
152
+ * safely handed to more than one caller, and no
153
+ * `deduplication.shareResult` hook was configured. The leader always
154
+ * receives the original result unaffected.
155
+ */
156
+ export type LLMRejectReason = BaseRejectReason | "budget_limit" | "unshareable_result";
157
+ /**
158
+ * Admission priority.
159
+ *
160
+ * `"high"` requests may use the full token budget. `"normal"` requests
161
+ * (the default) are rejected once available budget drops to
162
+ * `tokenBudget.highPriorityReserve`, keeping headroom for high-priority
163
+ * traffic. Priority has no effect when `tokenBudget` is not configured
164
+ * or `highPriorityReserve` is 0/unset.
165
+ */
166
+ export type LLMPriority = "high" | "normal";
167
+ /**
168
+ * Admission behavior for `run()`.
169
+ *
170
+ * - `"enforce"` (default) preserves normal fail-fast behavior.
171
+ * - `"observe"` executes the callback without holding capacity when a
172
+ * configured capacity-related rejection occurs, while recording the
173
+ * simulated rejection and usage separately.
174
+ */
175
+ export type LLMAdmissionMode = "enforce" | "observe";
176
+ /**
177
+ * Rejection reasons that observe mode is allowed to bypass.
178
+ *
179
+ * Shutdown, caller cancellation, and unsafe deduplication fan-out remain
180
+ * hard failures and are intentionally excluded from this type.
181
+ */
182
+ export type LLMShadowableRejectReason = Extract<LLMRejectReason, "budget_limit" | "concurrency_limit" | "queue_limit" | "timeout">;
183
+ /** Whether a `run()` callback holds real bulkhead capacity. */
184
+ export type LLMRunAdmission = "admitted" | "bypassed";
185
+ /**
186
+ * Capacity snapshot attached to rejections so callers (e.g. gateways)
187
+ * can build informative 429/503 responses.
188
+ *
189
+ * Note: no retry-after estimate is provided — a fail-fast bulkhead has
190
+ * no honest ETA for capacity. Expose these numbers instead.
191
+ */
192
+ export type LLMRejectDetail = {
193
+ inFlight: number;
194
+ maxConcurrent: number;
195
+ pending: number;
196
+ maxQueue: number;
197
+ tokenBudget?: {
198
+ /** Configured budget ceiling. */
199
+ budget: number;
200
+ /** Tokens currently held by in-flight reservations. */
201
+ inFlightTokens: number;
202
+ /** Budget this request was admitted against (priority-adjusted). */
203
+ effectiveBudget: number;
204
+ /** Tokens available at this priority (clamped at 0). */
205
+ available: number;
206
+ /** Tokens this request needed. */
207
+ requested: number;
208
+ };
209
+ };
210
+ /** Options accepted by `acquire()` / `run()` (base options + priority). */
211
+ export type LLMAcquireOptions = AcquireOptions & {
212
+ priority?: LLMPriority;
213
+ /**
214
+ * Per-call token reservation override (v3.7).
215
+ *
216
+ * When provided and `tokenBudget` is configured, admission reserves
217
+ * `input + maxOutput` from this value verbatim and the bulkhead's
218
+ * estimator is not consulted for this call. Intended for callers —
219
+ * typically gateways — that already compute a more accurate estimate
220
+ * from the full provider request (tool schemas, response formats,
221
+ * provider-priced media) than any character-ratio estimator could.
222
+ *
223
+ * Both fields must be non-negative integers. Ignored when
224
+ * `tokenBudget` is not configured (no reservation participates in
225
+ * admission in that mode). Not reflected by `estimate()`, which
226
+ * always previews the estimator path.
227
+ *
228
+ * v3.8: the object returned by `bulkhead.estimate()` can be passed
229
+ * here directly. When a `reserved` field is present it must equal
230
+ * `input + maxOutput` (see `LLMReservationOverride`).
231
+ */
232
+ reservation?: LLMReservationOverride;
233
+ };
234
+ export type LLMRequestStats = {
235
+ /** Successful LLM admissions (slot + budget acquired). */
236
+ admitted: number;
237
+ /** Successful LLM releases via the wrapped LLM token. */
238
+ released: number;
239
+ /** Total LLM-layer rejections. */
240
+ rejected: number;
241
+ /** LLM-layer rejections by reason. */
242
+ rejectedByReason: Partial<Record<LLMRejectReason, number>>;
243
+ };
244
+ export type LLMObserveStats = {
245
+ /** Callbacks executed without acquiring concurrency or token capacity. */
246
+ bypassed: number;
247
+ /** Bypasses caused by a rejection after an advisory positive decision. */
248
+ raceBypassed: number;
249
+ /** Bypassed callbacks grouped by the simulated/authoritative reason. */
250
+ bypassedByReason: Partial<Record<LLMShadowableRejectReason, number>>;
251
+ /** Bypassed callbacks for which final usage was available. */
252
+ usageReported: number;
253
+ /** Cumulative final input usage from bypassed callbacks. */
254
+ totalInputTokens: number;
255
+ /** Cumulative final output usage from bypassed callbacks. */
256
+ totalOutputTokens: number;
257
+ };
258
+ export type LLMStats = {
259
+ /** Underlying async-bulkhead-ts stats. */
260
+ bulkhead: Stats;
261
+ /** LLM-layer request stats. */
262
+ llm: LLMRequestStats;
263
+ /** Present only when `tokenBudget` is configured. */
264
+ tokenBudget?: {
265
+ budget: number;
266
+ inFlightTokens: number;
267
+ available: number;
268
+ /**
269
+ * Cumulative tokens reserved at admission across all successful
270
+ * admissions. Monotonically increasing.
271
+ */
272
+ totalReserved: number;
273
+ /**
274
+ * Cumulative actual tokens consumed (`usage.input + usage.output`),
275
+ * summed across releases that reported `TokenUsage`. Releases without
276
+ * usage contribute 0 — `totalConsumed` is meaningful only when
277
+ * `getUsage` is wired up consistently. Not clamped: over-consumption
278
+ * (actual > reserved) is reported as-is.
279
+ */
280
+ totalConsumed: number;
281
+ /**
282
+ * Cumulative tokens returned to the budget via the refund mechanism —
283
+ * both early refunds from `reportUsage()` and refunds at release.
284
+ */
285
+ totalRefunded: number;
286
+ /**
287
+ * Cumulative tokens held *beyond* original reservations because
288
+ * `reportUsage()` reported consumption exceeding the reserved hold.
289
+ * Overrun expands `inFlightTokens` (possibly above `budget`), which
290
+ * correctly blocks new admissions until the overrunning work releases.
291
+ */
292
+ totalOverrun: number;
293
+ /** Budget headroom reserved for `priority: "high"` requests. */
294
+ highPriorityReserve: number;
295
+ };
296
+ /** Present after at least one observe-mode bypass has occurred. */
297
+ observe?: LLMObserveStats;
298
+ /** Present only when deduplication is enabled. */
299
+ deduplication?: {
300
+ /** Number of distinct in-flight deduplication keys. */
301
+ active: number;
302
+ /** Cumulative requests that shared an existing in-flight call. */
303
+ hits: number;
304
+ };
305
+ };
306
+ export type LLMEventMap = {
307
+ /** Fired after a request is admitted (slot + budget acquired). */
308
+ admit: {
309
+ request: LLMRequest;
310
+ admissionId: string;
311
+ priority: LLMPriority;
312
+ reservedTokens: number;
313
+ };
314
+ /** Fired when a request is rejected at any stage. */
315
+ reject: {
316
+ request: LLMRequest;
317
+ reason: LLMRejectReason;
318
+ /** Capacity snapshot; absent for dedup-wait rejections. */
319
+ detail?: LLMRejectDetail;
320
+ };
321
+ /**
322
+ * Fired when a slot is released.
323
+ *
324
+ * `reservedTokens` is the pre-admission reservation (input estimate +
325
+ * `max_tokens` reservation). `refundedTokens` is what was returned to
326
+ * the budget — non-zero only when `usage` was reported and
327
+ * `usage.input + usage.output < reservedTokens`.
328
+ *
329
+ * Per-request actual consumption: `usage ? usage.input + usage.output : null`.
330
+ * The library does not pre-derive this onto the event payload — `null`
331
+ * (no usage reported) and `0` (genuinely zero usage) are different
332
+ * states that observers should distinguish.
333
+ *
334
+ * For cumulative consumption across all releases, prefer
335
+ * `stats().tokenBudget.totalConsumed` over aggregating these events.
336
+ */
337
+ release: {
338
+ request: LLMRequest;
339
+ admissionId: string;
340
+ priority: LLMPriority;
341
+ reservedTokens: number;
342
+ /** Tokens held immediately before release returned them. */
343
+ heldTokens: number;
344
+ refundedTokens: number;
345
+ /** Last emitted usage-event sequence for this admission. */
346
+ usageSequence: number;
347
+ usage?: TokenUsage;
348
+ };
349
+ /**
350
+ * Fired after an effective cumulative `reportUsage()` update.
351
+ *
352
+ * Stale or duplicate reports that do not increase either cumulative
353
+ * usage field are ignored and do not emit an event. `sequence` starts at
354
+ * 1 per admission and increases monotonically, allowing external
355
+ * coordinators to reject duplicate or out-of-order updates.
356
+ */
357
+ usage: {
358
+ request: LLMRequest;
359
+ admissionId: string;
360
+ priority: LLMPriority;
361
+ sequence: number;
362
+ reservedTokens: number;
363
+ previousHeldTokens: number;
364
+ heldTokens: number;
365
+ deltaTokens: number;
366
+ usage: TokenUsage;
367
+ outputCap: number | null;
368
+ outputRemaining: number | null;
369
+ overReservation: boolean;
370
+ };
371
+ /**
372
+ * Fired when observe mode executes a callback without holding capacity.
373
+ * This is separate from `admit`: bypassed work does not affect concurrency
374
+ * or token-budget accounting.
375
+ */
376
+ bypass: {
377
+ request: LLMRequest;
378
+ admissionId: string;
379
+ priority: LLMPriority;
380
+ reason: LLMShadowableRejectReason;
381
+ detail?: LLMRejectDetail;
382
+ reservation: LLMReservationEstimate | null;
383
+ /** True when an advisory positive decision raced with a real rejection. */
384
+ raced: boolean;
385
+ };
386
+ /** Fired after an effective cumulative usage update for bypassed work. */
387
+ bypassUsage: {
388
+ request: LLMRequest;
389
+ admissionId: string;
390
+ priority: LLMPriority;
391
+ reason: LLMShadowableRejectReason;
392
+ sequence: number;
393
+ reservation: LLMReservationEstimate | null;
394
+ usage: TokenUsage;
395
+ outputCap: number | null;
396
+ outputRemaining: number | null;
397
+ overReservation: boolean;
398
+ };
399
+ /** Fired when bypassed work settles, whether successfully or by throwing. */
400
+ bypassRelease: {
401
+ request: LLMRequest;
402
+ admissionId: string;
403
+ priority: LLMPriority;
404
+ reason: LLMShadowableRejectReason;
405
+ reservation: LLMReservationEstimate | null;
406
+ usageSequence: number;
407
+ usage?: TokenUsage;
408
+ };
409
+ /** Fired when a request joins an existing in-flight call via dedup. */
410
+ dedup: {
411
+ request: LLMRequest;
412
+ };
413
+ };
414
+ export type LLMEventType = keyof LLMEventMap;
415
+ export type Listener<K extends LLMEventType> = (payload: LLMEventMap[K]) => void;
416
+ export type TokenBudgetOptions = {
417
+ /**
418
+ * Maximum tokens allowed in-flight simultaneously across all active requests.
419
+ * Admission is always fail-fast when this ceiling is reached,
420
+ * independent of concurrency headroom and independent of `profile`.
421
+ *
422
+ * Must be a non-negative integer. `0` is valid and intentional — it
423
+ * represents a pool with no budget to grant this cycle (e.g. a lease
424
+ * ledger reporting exhaustion) and results in every budget-gated
425
+ * admission being rejected with `"budget_limit"` until the ceiling is
426
+ * raised (via `setBudget()`) or `tokenBudget` admits a zero-token
427
+ * request.
428
+ */
429
+ budget: number;
430
+ /**
431
+ * Estimator used to calculate token reservation pre-admission.
432
+ * Defaults to `createModelAwareTokenEstimator` seeded with the bulkhead's `model`.
433
+ */
434
+ estimator?: TokenEstimator;
435
+ /**
436
+ * Fallback output reservation when `request.max_tokens` is absent.
437
+ * Default: 2048.
438
+ */
439
+ outputCap?: number;
440
+ /**
441
+ * Tokens of budget headroom reserved for `priority: "high"` requests.
442
+ *
443
+ * Normal-priority admission is checked against
444
+ * `budget - highPriorityReserve`; high-priority admission is checked
445
+ * against the full `budget`. This lets interactive traffic keep
446
+ * admitting while batch traffic has saturated the shared pool.
447
+ *
448
+ * Must satisfy `0 <= highPriorityReserve <= budget`. Default: 0
449
+ * (priority has no effect).
450
+ */
451
+ highPriorityReserve?: number;
452
+ };
453
+ export type DeduplicationOptions = {
454
+ /**
455
+ * Custom function to derive a deduplication key from a request.
456
+ * Requests with the same key that arrive while a matching call is
457
+ * already in-flight share that call.
458
+ *
459
+ * Default (v3.4): a key-order-stable serialization of the **entire
460
+ * request object**. Any own enumerable property difference —
461
+ * `temperature`, `tools`, `system`, etc., not just `messages` /
462
+ * `max_tokens` / `model` — prevents conflation. The tradeoff: volatile
463
+ * per-request fields (request IDs, timestamps) also defeat
464
+ * deduplication. If your requests carry such fields, supply a `keyFn`
465
+ * that omits them. Non-serializable values (functions, symbols) are
466
+ * dropped by JSON serialization and do not distinguish requests.
467
+ *
468
+ * Keys are SHA-256 hashed before being stored, so the in-flight map
469
+ * never retains prompt text and per-entry key memory is bounded.
470
+ *
471
+ * Deduplication applies to `run()` only — `acquire()` never
472
+ * deduplicates.
473
+ *
474
+ * **Multi-tenant callers:** the default key has no tenant dimension.
475
+ * Two tenants sending byte-identical requests would share one
476
+ * response. Pass `dedupScope` (per-call, on `run()` options) or bake
477
+ * the tenant into a custom `keyFn` to prevent cross-tenant sharing.
478
+ *
479
+ * Return an empty string to opt a specific request out of deduplication.
480
+ */
481
+ keyFn?: (request: LLMRequest) => string;
482
+ /**
483
+ * Fan-out hook for delivering a shared in-flight result to
484
+ * deduplication *followers* (v3.5).
485
+ *
486
+ * Called once per follower with the leader's resolved result; the
487
+ * return value is what that follower receives. The leader always
488
+ * receives the original result — `shareResult` is never called for
489
+ * the leader.
490
+ *
491
+ * Why this exists: without it, followers receive the *same object*
492
+ * the leader does. For plain JSON results that is fine (and remains
493
+ * the default), but single-consumer values — `ReadableStream`,
494
+ * Node `Readable`, async iterables, `Response` bodies — can only be
495
+ * consumed once. Whichever caller reads first wins; the rest get a
496
+ * locked or drained stream. The library cannot tee arbitrary stream
497
+ * types on your behalf, so it provides this seam instead:
498
+ *
499
+ * ```ts
500
+ * // fetch Response: hand each follower an independent clone.
501
+ * // (clone() must be called before any consumer reads the body —
502
+ * // guaranteed here, since fan-out happens at resolution time.)
503
+ * deduplication: { shareResult: (r) => (r as Response).clone() }
504
+ * ```
505
+ *
506
+ * When `shareResult` is provided it is called for **every** follower
507
+ * delivery, including safe (non-stream) results — it is a general
508
+ * fan-out policy, usable e.g. for defensive deep-cloning.
509
+ *
510
+ * If `shareResult` throws, that follower's `run()` rejects with the
511
+ * thrown error as-is; the leader and other followers are unaffected.
512
+ *
513
+ * When `shareResult` is **not** provided and the shared result is
514
+ * detected as single-consumer, followers are rejected with
515
+ * `LLMBulkheadRejectedError("unshareable_result")` rather than being
516
+ * silently handed a stream they cannot read. Detection is shallow:
517
+ * it inspects the result value itself, not nested properties — a
518
+ * stream buried inside `{ stream: ... }` is not detected and will be
519
+ * shared by reference as before.
520
+ */
521
+ shareResult?: (result: unknown) => unknown;
522
+ };
523
+ export type LLMBulkheadOptions = {
524
+ /**
525
+ * Model identifier. Used by the default estimator for ratio lookup.
526
+ *
527
+ * One bulkhead per model is the strongly recommended deployment pattern.
528
+ * When routing multiple models through one bulkhead, set `model` on
529
+ * individual `LLMRequest` objects for accurate estimation.
530
+ */
531
+ model: string;
532
+ /** Maximum number of requests in-flight simultaneously. */
533
+ maxConcurrent: number;
534
+ /**
535
+ * Maximum number of requests waiting for admission.
536
+ * Default: 0 (fail-fast). Prefer setting via `profile`.
537
+ */
538
+ maxQueue?: number;
539
+ /**
540
+ * Waiting timeout in milliseconds. Applies to queued requests only.
541
+ * Has no effect when `maxQueue` is 0.
542
+ */
543
+ timeoutMs?: number;
544
+ /**
545
+ * Opinionated defaults for common deployment patterns.
546
+ * Explicit options always override profile defaults.
547
+ */
548
+ profile?: "interactive" | "batch" | LLMBulkheadPreset;
549
+ /**
550
+ * Token budget enforcement. Admission fails fast when the in-flight token
551
+ * ceiling is reached, regardless of concurrency headroom or `profile`.
552
+ * Omit to disable token-aware admission.
553
+ */
554
+ tokenBudget?: TokenBudgetOptions;
555
+ /**
556
+ * Enable in-flight request deduplication.
557
+ *
558
+ * - `true` — use the default key function
559
+ * - `DeduplicationOptions` — customize the key function
560
+ * - `false` / omitted — disabled
561
+ */
562
+ deduplication?: boolean | DeduplicationOptions;
563
+ };
564
+ /**
565
+ * Snapshot returned by `LLMToken.reportUsage()`.
566
+ *
567
+ * `outputCap` / `outputRemaining` are `null` when `tokenBudget` is not
568
+ * configured (there is no reservation to measure against).
569
+ */
570
+ export type UsageReport = {
571
+ /** Stable identifier of the admission this usage belongs to. */
572
+ admissionId: string;
573
+ /**
574
+ * Last effective usage-update sequence for this admission.
575
+ * Starts at 0 before any effective report, increments only when either
576
+ * cumulative usage field increases, and remains stable for stale reports.
577
+ */
578
+ sequence: number;
579
+ /** Original pre-admission reservation (0 when budget disabled). */
580
+ reserved: number;
581
+ /** Tokens currently held against the budget for this request. */
582
+ held: number;
583
+ /** Cumulative reported consumption (`input + output`). */
584
+ consumed: number;
585
+ /** Output tokens reserved for this request (`max_tokens`/`outputCap`). */
586
+ outputCap: number | null;
587
+ /** Output reservation remaining before the stream overruns it. */
588
+ outputRemaining: number | null;
589
+ /** True once cumulative consumption exceeds the original reservation. */
590
+ overReservation: boolean;
591
+ };
592
+ /** Context passed to `run()` callbacks for mid-flight usage reporting. */
593
+ export type LLMRunContext = {
594
+ /** Stable identifier for this execution. Bypasses use a `shadow-` prefix. */
595
+ readonly admissionId: string;
596
+ /** Exact reservation evaluated for this call, or `null` without a budget. */
597
+ readonly reservation: LLMReservationEstimate | null;
598
+ /** Whether the callback holds real bulkhead capacity. */
599
+ readonly admission: LLMRunAdmission;
600
+ /** Simulated or authoritative reason when `admission === "bypassed"`. */
601
+ readonly bypassReason?: LLMShadowableRejectReason;
602
+ /** Capacity snapshot associated with the bypass decision, when available. */
603
+ readonly bypassDetail?: LLMRejectDetail;
604
+ reportUsage(usage: TokenUsage): UsageReport;
605
+ };
606
+ /** Options accepted by `run()`. */
607
+ export type LLMRunOptions<T> = LLMAcquireOptions & {
608
+ getUsage?: (result: T) => TokenUsage | undefined;
609
+ /**
610
+ * Admission behavior. `"enforce"` is the default. In `"observe"` mode,
611
+ * configured capacity-related rejections execute without holding capacity.
612
+ */
613
+ mode?: LLMAdmissionMode;
614
+ /**
615
+ * Capacity reasons observe mode may bypass. Defaults to all four
616
+ * `LLMShadowableRejectReason` values. Pass an empty array to observe the
617
+ * callback context without bypassing any rejection.
618
+ */
619
+ shadowReasons?: readonly LLMShadowableRejectReason[];
620
+ /**
621
+ * Deduplication scope. Requests deduplicate only within the same scope.
622
+ * Ignored when deduplication is disabled. Default: `""`.
623
+ */
624
+ dedupScope?: string;
625
+ /** Per-call deduplication opt-out. */
626
+ dedup?: boolean;
627
+ };
628
+ /**
629
+ * Admission token returned by `acquire()`.
630
+ *
631
+ * Call `release()` exactly once when the request completes.
632
+ * Pass `TokenUsage` to enable the refund mechanism — the bulkhead
633
+ * returns the difference between the pre-admission reservation and
634
+ * actual consumption to the budget immediately.
635
+ *
636
+ * For streaming workloads, call `reportUsage()` with *cumulative* usage
637
+ * as stream events arrive:
638
+ *
639
+ * - If the reported input is lower than the pre-admission estimate, the
640
+ * surplus is refunded to the budget immediately (the full output
641
+ * reservation is retained).
642
+ * - If reported consumption exceeds the hold, the hold expands (overrun),
643
+ * which blocks new admissions until this request releases.
644
+ * - Reports are clamped to be monotonically non-decreasing per field.
645
+ * - If `release()` is later called without usage, the last reported
646
+ * usage is used for the final refund.
647
+ */
648
+ export type LLMToken = {
649
+ /** Stable identifier for this successful admission. */
650
+ readonly admissionId: string;
651
+ /** Exact reservation used at admission, or `null` without a token budget. */
652
+ readonly reservation: LLMReservationEstimate | null;
653
+ release(usage?: TokenUsage): void;
654
+ reportUsage(usage: TokenUsage): UsageReport;
655
+ };
656
+ export type LLMAcquireResult = {
657
+ ok: true;
658
+ admissionId: string;
659
+ reservation: LLMReservationEstimate | null;
660
+ token: LLMToken;
661
+ } | {
662
+ ok: false;
663
+ reason: LLMRejectReason;
664
+ detail?: LLMRejectDetail;
665
+ };
666
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,YAAY,IAAI,gBAAgB,EACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMvD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;AAMjE;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;CAClC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;IAEjC;;;;;;;;;;OAUG;IACH,gBAAgB,CA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