@urun-sh/openai 0.6.32 → 0.6.33

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.
@@ -1,5 +1,5 @@
1
1
  import { Server } from 'node:http';
2
- import { c as LedgerOutcome, I as InferenceRecord, i as RouteTarget, S as SessionGoneError, k as billingIdentityOf, P as ProxyClients, M as ModelRouter, j as UsageRowReporter, b as InferenceUsageRecord, e as LedgerWrite, d as LedgerRecorded, L as LedgerFailure, R as RealtimeCompanionsFor } from '../composite-DtBebn0Y.cjs';
2
+ import { c as LedgerOutcome, I as InferenceRecord, i as RouteTarget, S as SessionGoneError, k as billingIdentityOf, P as ProxyClients, M as ModelRouter, j as UsageRowReporter, b as InferenceUsageRecord, e as LedgerWrite, d as LedgerRecorded, L as LedgerFailure, R as RealtimeCompanionsFor } from '../composite-CwfOOT0b.cjs';
3
3
  import * as _prometheus_io_client from '@prometheus-io/client';
4
4
  import { Registry } from '@prometheus-io/client';
5
5
  import { createClientToken, SessionPhaseName } from '@urun-sh/core';
@@ -216,10 +216,22 @@ declare class ControlPlaneUnavailableError extends Error {
216
216
  readonly detail?: string;
217
217
  constructor(message: string, detail?: string);
218
218
  }
219
- /** The verified caller: their key, and the org the control plane bound it to. */
219
+ /** The verified caller: their key, the org the control plane bound it to, and
220
+ * the ENG-509 request-lane admission verdict the binding carries.
221
+ *
222
+ * The verdict fields are UNDEFINED on a cache hit from an older control
223
+ * plane (or a failed best-effort verdict read) — every consumer treats
224
+ * absent fields as ADMIT; the gate must never brick the endpoint on a
225
+ * control plane that does not speak the fields. */
220
226
  interface CallerIdentity {
221
227
  apiKey: string;
222
228
  orgId: string;
229
+ /** 'platform' | 'distributor' — organizations.billing_audience (ENG-490). */
230
+ billingAudience?: string;
231
+ /** False = refuse NEW /v1 requests (402); in-flight requests always finish. */
232
+ creditsAdmissionOk?: boolean;
233
+ /** 'spend_cap_reached' | 'insufficient_credits' — present only on a refusal. */
234
+ creditsRefusalReason?: string;
223
235
  }
224
236
  /**
225
237
  * Pull the raw key off `Authorization: Bearer <key>`. Missing, malformed, or
@@ -257,17 +269,6 @@ declare class OrgResolver {
257
269
  private readonly mint;
258
270
  private readonly now;
259
271
  constructor(opts: OrgResolverOptions);
260
- /**
261
- * Verify a Bearer key against the control plane and return its org binding.
262
- *
263
- * Three outcomes, all explicit:
264
- * - the control plane binds the key to an org → {@link CallerIdentity};
265
- * - the control plane rejects the key (401/403) → {@link ProxyAuthError};
266
- * - the control plane cannot be asked → loud
267
- * {@link ControlPlaneUnavailableError} (502). NEVER a pass: a proxy that
268
- * admitted requests while it could not verify keys would be an open
269
- * relay into every org.
270
- */
271
272
  resolve(apiKey: string): Promise<CallerIdentity>;
272
273
  /** Test/ops seam: forget every cached binding. */
273
274
  clear(): void;
@@ -1,5 +1,5 @@
1
1
  import { Server } from 'node:http';
2
- import { c as LedgerOutcome, I as InferenceRecord, i as RouteTarget, S as SessionGoneError, k as billingIdentityOf, P as ProxyClients, M as ModelRouter, j as UsageRowReporter, b as InferenceUsageRecord, e as LedgerWrite, d as LedgerRecorded, L as LedgerFailure, R as RealtimeCompanionsFor } from '../composite-DMawda97.js';
2
+ import { c as LedgerOutcome, I as InferenceRecord, i as RouteTarget, S as SessionGoneError, k as billingIdentityOf, P as ProxyClients, M as ModelRouter, j as UsageRowReporter, b as InferenceUsageRecord, e as LedgerWrite, d as LedgerRecorded, L as LedgerFailure, R as RealtimeCompanionsFor } from '../composite-D9VDruCV.js';
3
3
  import * as _prometheus_io_client from '@prometheus-io/client';
4
4
  import { Registry } from '@prometheus-io/client';
5
5
  import { createClientToken, SessionPhaseName } from '@urun-sh/core';
@@ -94,6 +94,12 @@ declare class ControlPlaneUnavailableError extends Error {
94
94
  interface CallerIdentity {
95
95
  apiKey: string;
96
96
  orgId: string;
97
+
98
+ billingAudience?: string;
99
+
100
+ creditsAdmissionOk?: boolean;
101
+
102
+ creditsRefusalReason?: string;
97
103
  }
98
104
 
99
105
  declare function bearerFrom(headerValue: string | undefined): string;
@@ -116,7 +122,6 @@ declare class OrgResolver {
116
122
  private readonly mint;
117
123
  private readonly now;
118
124
  constructor(opts: OrgResolverOptions);
119
-
120
125
  resolve(apiKey: string): Promise<CallerIdentity>;
121
126
 
122
127
  clear(): void;
@@ -1 +1 @@
1
- import{A as x,B as v,C as m,D as y,E as B,F as H,G as P,H as u,I as G,J as U,K as F,L as X,M as Y,N as b,O as h,P as k,Q as K,R as V,S as j,T as W,U as q,a as r,b as o,c as t,d as E,e as n,f as _,g as a,h as T,i as O,j as i,k as s,l as I,m as p,n as A,o as R,p as S,q as N,r as C,s as D,t as L,u as M,v as d,w as f,x as l,y as c,z as g}from"../chunk-5473ZAQ4.js";import"../chunk-KTMDSM7F.js";import"../chunk-CAR4AEQJ.js";import"../chunk-7OH7UJ2H.js";import"../chunk-3JWYIKHM.js";import"../chunk-6M5JK4YC.js";import"../chunk-PAYCMH5F.js";import"../chunk-L6HTHDVV.js";import"../chunk-M3YMNU5P.js";import"../chunk-GL7EWL3V.js";import"../chunk-NN6TQQUG.js";import"../chunk-OOCRI7ZM.js";import{c as e}from"../chunk-YSFSRI3D.js";e();export{N as ANONYMOUS_KEY_ID,y as BIND_HOST,R as BUCKET_DOMAIN,O as BoundedLabel,f as ControlPlaneUnavailableError,X as ConversationBackhauls,F as ConversationCapacityError,v as DEFAULT_PORT,I as EDGE_IDENTITY_PORT,A as EDGE_KEY_FINGERPRINT_HEADER,p as EDGE_KEY_ID_HEADER,i as InferenceMetrics,Y as LEDGER_FUNCTION_PATH,b as LEDGER_WRITE_TIMEOUT_MS,V as LedgerClient,h as LedgerDuplicateError,k as LedgerSurfaceError,g as MAX_CACHED_KEYS,G as MAX_CONVERSATIONS,U as MAX_CONVERSATION_HANDLES,n as MAX_MODEL_LABELS,_ as MAX_ORG_LABELS,H as MAX_TENANTS,o as METRICS_PATH,r as METRICS_PORT,E as NO_MODEL_LABEL,c as ORG_BINDING_TTL_MS,t as OTHER_LABEL,x as OrgResolver,d as ProxyAuthError,W as READINESS_TIMEOUT_MS,j as READINESS_TTL_MS,m as SERVE_FUNCTION,S as TIER_DOMAIN,u as TenantRegistry,l as bearerFrom,L as bearerTokenOf,M as createEdgeIdentityServer,q as createHostedProxy,s as createMetricsServer,C as edgeBucketId,D as edgeTierFingerprint,a as laneOf,K as parseLedgerRecorded,B as resolveHostedConfig,T as statusClassOf,P as tenantSubject};
1
+ import{A as x,B as v,C as m,D as y,E as B,F as H,G as P,H as u,I as G,J as U,K as F,L as X,M as Y,N as b,O as h,P as k,Q as K,R as V,S as j,T as W,U as q,a as r,b as o,c as t,d as E,e as n,f as _,g as a,h as T,i as O,j as i,k as s,l as I,m as p,n as A,o as R,p as S,q as N,r as C,s as D,t as L,u as M,v as d,w as f,x as l,y as c,z as g}from"../chunk-PBKCUSTI.js";import"../chunk-7D2HMQFC.js";import"../chunk-CAR4AEQJ.js";import"../chunk-GR3UAW6P.js";import"../chunk-3JWYIKHM.js";import"../chunk-6M5JK4YC.js";import"../chunk-PAYCMH5F.js";import"../chunk-L6HTHDVV.js";import"../chunk-NL3UBLXV.js";import"../chunk-GL7EWL3V.js";import"../chunk-NN6TQQUG.js";import"../chunk-OOCRI7ZM.js";import{c as e}from"../chunk-YSFSRI3D.js";e();export{N as ANONYMOUS_KEY_ID,y as BIND_HOST,R as BUCKET_DOMAIN,O as BoundedLabel,f as ControlPlaneUnavailableError,X as ConversationBackhauls,F as ConversationCapacityError,v as DEFAULT_PORT,I as EDGE_IDENTITY_PORT,A as EDGE_KEY_FINGERPRINT_HEADER,p as EDGE_KEY_ID_HEADER,i as InferenceMetrics,Y as LEDGER_FUNCTION_PATH,b as LEDGER_WRITE_TIMEOUT_MS,V as LedgerClient,h as LedgerDuplicateError,k as LedgerSurfaceError,g as MAX_CACHED_KEYS,G as MAX_CONVERSATIONS,U as MAX_CONVERSATION_HANDLES,n as MAX_MODEL_LABELS,_ as MAX_ORG_LABELS,H as MAX_TENANTS,o as METRICS_PATH,r as METRICS_PORT,E as NO_MODEL_LABEL,c as ORG_BINDING_TTL_MS,t as OTHER_LABEL,x as OrgResolver,d as ProxyAuthError,W as READINESS_TIMEOUT_MS,j as READINESS_TTL_MS,m as SERVE_FUNCTION,S as TIER_DOMAIN,u as TenantRegistry,l as bearerFrom,L as bearerTokenOf,M as createEdgeIdentityServer,q as createHostedProxy,s as createMetricsServer,C as edgeBucketId,D as edgeTierFingerprint,a as laneOf,K as parseLedgerRecorded,B as resolveHostedConfig,T as statusClassOf,P as tenantSubject};