@omnicross/core 0.1.3 → 0.1.4
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/LICENSE +21 -21
- package/NOTICE +57 -57
- package/README.md +15 -15
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +4 -4
- package/dist/auth/GeminiCodeAssistProjectResolver.js +3 -3
- package/dist/chunk-3QFXFCHG.js +33 -0
- package/dist/chunk-4YINUUKQ.cjs +33 -0
- package/dist/chunk-7Y47UCF2.js +142 -0
- package/dist/chunk-APYG5QD7.cjs +50 -0
- package/dist/{chunk-CWM2ZDU5.js → chunk-BPKCU575.js} +3 -10
- package/dist/{chunk-2FMI2B6V.cjs → chunk-DKPXN34V.cjs} +222 -448
- package/dist/chunk-E3UCVHLP.cjs +142 -0
- package/dist/chunk-FCR77GYM.cjs +33 -0
- package/dist/{chunk-N5QFKSDO.js → chunk-HRRYG2AX.js} +2 -1
- package/dist/{chunk-KUU2RNG6.cjs → chunk-HYN75H6G.cjs} +3 -0
- package/dist/{chunk-JO5NLTLY.js → chunk-IK3KE3AU.js} +3 -0
- package/dist/chunk-K5NM7VAH.js +33 -0
- package/dist/{chunk-Y6OM7EV7.cjs → chunk-KFI44N2R.cjs} +2 -1
- package/dist/{chunk-S6JGLF3G.cjs → chunk-OCEUVQHW.cjs} +27 -4
- package/dist/chunk-OE6TDIWW.js +22 -0
- package/dist/chunk-OZFM4X3S.js +18 -0
- package/dist/{chunk-4DECIFU7.js → chunk-QYTT6GE3.js} +62 -288
- package/dist/{chunk-FFALUUZZ.cjs → chunk-RGTR7CIO.cjs} +5 -5
- package/dist/{chunk-3QOSDDNI.cjs → chunk-SNYBEXLB.cjs} +6 -13
- package/dist/{chunk-2DCNB7DF.cjs → chunk-SU2GCLAC.cjs} +30 -10
- package/dist/{chunk-5HTVET6E.js → chunk-TIER4SUC.js} +24 -4
- package/dist/{chunk-CZHZGRU7.js → chunk-UHGVBFU3.js} +2 -0
- package/dist/chunk-UIBD2YY5.cjs +22 -0
- package/dist/{chunk-SVXC36MU.cjs → chunk-VACWOIRE.cjs} +2 -0
- package/dist/{chunk-MQNDWYPN.js → chunk-VPBAUQ2M.js} +4 -4
- package/dist/chunk-WLYIIEAF.js +50 -0
- package/dist/{chunk-BO4RFWBR.js → chunk-XK5CIRMQ.js} +24 -1
- package/dist/chunk-XSVNC2UD.cjs +18 -0
- package/dist/completion/CompletionService.cjs +22 -16
- package/dist/completion/CompletionService.js +21 -15
- package/dist/completion.cjs +24 -18
- package/dist/completion.js +23 -17
- package/dist/index.cjs +33 -24
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +42 -33
- package/dist/keyPolicy-Cp0FntZl.d.cts +90 -0
- package/dist/keyPolicy-Cp0FntZl.d.ts +90 -0
- package/dist/outbound-api/auditCapture.cjs +9 -0
- package/dist/outbound-api/auditCapture.d.cts +52 -0
- package/dist/outbound-api/auditCapture.d.ts +52 -0
- package/dist/outbound-api/auditCapture.js +9 -0
- package/dist/outbound-api/auditRedact.cjs +8 -0
- package/dist/outbound-api/auditRedact.d.cts +30 -0
- package/dist/outbound-api/auditRedact.d.ts +30 -0
- package/dist/outbound-api/auditRedact.js +8 -0
- package/dist/outbound-api/billingCapture.cjs +8 -0
- package/dist/outbound-api/billingCapture.d.cts +61 -0
- package/dist/outbound-api/billingCapture.d.ts +61 -0
- package/dist/outbound-api/billingCapture.js +8 -0
- package/dist/outbound-api/quotaWarn.cjs +12 -0
- package/dist/outbound-api/quotaWarn.d.cts +43 -0
- package/dist/outbound-api/quotaWarn.d.ts +43 -0
- package/dist/outbound-api/quotaWarn.js +12 -0
- package/dist/outbound-api/routeResolver.cjs +2 -2
- package/dist/outbound-api/routeResolver.d.cts +3 -2
- package/dist/outbound-api/routeResolver.d.ts +3 -2
- package/dist/outbound-api/routeResolver.js +1 -1
- package/dist/outbound-api/types.d.cts +2 -1
- package/dist/outbound-api/types.d.ts +2 -1
- package/dist/outbound-api.cjs +29 -20
- package/dist/outbound-api.d.cts +9 -140
- package/dist/outbound-api.d.ts +9 -140
- package/dist/outbound-api.js +28 -19
- package/dist/pipeline/AuthSource.d.cts +6 -0
- package/dist/pipeline/AuthSource.d.ts +6 -0
- package/dist/pipeline/SubscriptionAuthSource.cjs +2 -2
- package/dist/pipeline/SubscriptionAuthSource.js +1 -1
- package/dist/pipeline/SubscriptionAuthStrategy.d.cts +6 -0
- package/dist/pipeline/SubscriptionAuthStrategy.d.ts +6 -0
- package/dist/pipeline/auditUsageStash.cjs +10 -0
- package/dist/pipeline/auditUsageStash.d.cts +37 -0
- package/dist/pipeline/auditUsageStash.d.ts +37 -0
- package/dist/pipeline/auditUsageStash.js +10 -0
- package/dist/pipeline/executeProviderCall.cjs +2 -2
- package/dist/pipeline/executeProviderCall.js +1 -1
- package/dist/pipeline/upstreamFetch.cjs +14 -0
- package/dist/pipeline/upstreamFetch.d.cts +83 -0
- package/dist/pipeline/upstreamFetch.d.ts +83 -0
- package/dist/pipeline/upstreamFetch.js +14 -0
- package/dist/pipeline/webhookEmit.cjs +10 -0
- package/dist/pipeline/webhookEmit.d.cts +36 -0
- package/dist/pipeline/webhookEmit.d.ts +36 -0
- package/dist/pipeline/webhookEmit.js +10 -0
- package/dist/ports.d.cts +2 -1
- package/dist/ports.d.ts +2 -1
- package/dist/provider-proxy/ProviderProxy.cjs +22 -16
- package/dist/provider-proxy/ProviderProxy.js +21 -15
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +22 -16
- package/dist/provider-proxy/ingress/providerProxyShared.js +21 -15
- package/dist/provider-proxy/types.d.cts +7 -0
- package/dist/provider-proxy/types.d.ts +7 -0
- package/dist/provider-proxy.cjs +22 -16
- package/dist/provider-proxy.js +21 -15
- package/dist/{routeResolver-B1NglTfe.d.ts → routeResolver-C4T7yClx.d.ts} +1 -1
- package/dist/{routeResolver-CbG5uBgm.d.cts → routeResolver-CB3tvJKy.d.cts} +1 -1
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
- package/dist/transformer/transformers.cjs +6 -6
- package/dist/transformer/transformers.js +5 -5
- package/dist/transformer.cjs +7 -7
- package/dist/transformer.js +6 -6
- package/dist/{types-aBFFXoBz.d.cts → types-B8Arpxn0.d.cts} +14 -90
- package/dist/{types-6OUY_xfA.d.ts → types-lgPYQuZS.d.ts} +14 -90
- package/dist/usage/usage-recorder.cjs +3 -2
- package/dist/usage/usage-recorder.js +2 -1
- package/dist/usage.cjs +3 -2
- package/dist/usage.js +2 -1
- package/package.json +64 -64
package/dist/outbound-api.d.cts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { VoucherConfig } from '@omnicross/contracts/voucher-types';
|
|
2
|
-
import {
|
|
3
|
-
export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS,
|
|
2
|
+
import { e as KindMappedEndpoint, f as ModelKind, m as OutboundEndpoint, b as EndpointRoutingConfig, k as OutboundApiServerConfig, U as UserMessageQueueConfig, a as ConcurrencyQueueConfig, h as OutboundApiDeps, l as OutboundApiServerStatus, n as OutboundFormatUrls, A as AccountProbeConfig, F as FingerprintConfig, g as ModelPrefixTargets, r as OutboundProxyConfig, G as ModelRef, O as OutboundKeyDb, i as OutboundApiKeyCreated, R as RequestRole } from './types-B8Arpxn0.cjs';
|
|
3
|
+
export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS, K as KeySpendReader, c as KeySpendSeeder, d as KeySpendTracker, M as MessagesModelKind, j as OutboundApiKeyInfo, o as OutboundKeyActivationMode, p as OutboundKeyDbRow, q as OutboundKeyPolicy, s as ResponsesModelKind, V as VoucherCreateInput, t as VoucherDb, u as computeVoucherGrant, v as generateVoucherCode, w as hashVoucherCode, x as newVoucherId, y as startOfLocalDay, z as startOfLocalWeek, B as toVoucherInfo, D as voucherCodePrefix } from './types-B8Arpxn0.cjs';
|
|
4
4
|
import { ProxyConfig } from '@omnicross/contracts/account-tokens-types';
|
|
5
5
|
import { AuditConfig } from '@omnicross/contracts/audit-types';
|
|
6
6
|
import { BillingConfig } from '@omnicross/contracts/billing-types';
|
|
7
7
|
import { WebhookDestination, WebhookConfig } from '@omnicross/contracts/webhook-types';
|
|
8
|
+
export { AUDIT_REDACTED, redactAuditText } from './outbound-api/auditRedact.cjs';
|
|
9
|
+
export { AuditCaptureContext, beginAuditCapture } from './outbound-api/auditCapture.cjs';
|
|
10
|
+
export { BillingCaptureContext, beginBillingCapture } from './outbound-api/billingCapture.cjs';
|
|
11
|
+
import { K as KeyCostLimits, M as ModelRestriction } from './keyPolicy-Cp0FntZl.cjs';
|
|
12
|
+
export { a as KeyExpiryInput, b as KeyExpiryResult, c as KeySpend, Q as QuotaDecision, d as checkKeyQuota, e as computeKeyExpiry } from './keyPolicy-Cp0FntZl.cjs';
|
|
8
13
|
import http from 'node:http';
|
|
9
14
|
import { IngressFormat } from './provider-proxy/types.cjs';
|
|
10
|
-
export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-
|
|
15
|
+
export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-CB3tvJKy.cjs';
|
|
11
16
|
import '@omnicross/contracts/health-logging-types';
|
|
12
17
|
import './logger-4GvQNzhE.cjs';
|
|
13
18
|
import './ports/provider-config-source.cjs';
|
|
@@ -369,142 +374,6 @@ declare function saveServerConfig(store: ApiServerSettingsStore, config: Outboun
|
|
|
369
374
|
/** Apply a partial patch to a config, returning the merged whole. */
|
|
370
375
|
declare function mergeServerConfig(current: OutboundApiServerConfig, patch: Partial<OutboundApiServerConfig>): OutboundApiServerConfig;
|
|
371
376
|
|
|
372
|
-
/**
|
|
373
|
-
* auditRedact — the pure secret-redaction pass for captured audit bodies
|
|
374
|
-
* (request-audit-log, design D3/D7).
|
|
375
|
-
*
|
|
376
|
-
* Body capture is opt-in and inherently sensitive: a prompt or tool argument can
|
|
377
|
-
* embed a secret. {@link redactAuditText} is run over EVERY captured body (and
|
|
378
|
-
* any other free text stored in a record) BEFORE it is persisted — defense in
|
|
379
|
-
* depth on top of "request headers are NEVER captured" (so an Authorization /
|
|
380
|
-
* x-api-key HEADER value never enters a record in the first place).
|
|
381
|
-
*
|
|
382
|
-
* It masks the obvious, high-confidence secret shapes ONLY (frozen list) — never
|
|
383
|
-
* a broad heuristic that would gut a legitimate prompt:
|
|
384
|
-
* - `sk-…` API keys (covers `sk-ant-…`, `sk-omnicross-…`, `sk-proj-…`, OpenAI).
|
|
385
|
-
* - `Bearer <token>` authorization values.
|
|
386
|
-
* - `x-api-key` / `api-key` / `authorization` values written inline as text.
|
|
387
|
-
* - Google `AIza…` API keys.
|
|
388
|
-
*
|
|
389
|
-
* Pure + allocation-light + never throws.
|
|
390
|
-
*
|
|
391
|
-
* @module @omnicross/core/outbound-api/auditRedact
|
|
392
|
-
*/
|
|
393
|
-
/** The sentinel a masked secret is replaced with. */
|
|
394
|
-
declare const AUDIT_REDACTED = "***REDACTED***";
|
|
395
|
-
/**
|
|
396
|
-
* Mask obvious secrets in `text`. Pure; returns the input unchanged when it holds
|
|
397
|
-
* no recognized secret shape. Never throws (a bad input returns `''`).
|
|
398
|
-
*/
|
|
399
|
-
declare function redactAuditText(text: string): string;
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* auditCapture — the outbound server's post-response audit capture hook
|
|
403
|
-
* (request-audit-log, design D1/D3/D5).
|
|
404
|
-
*
|
|
405
|
-
* {@link beginAuditCapture} is called at the TOP of `handleOutboundRequest`. It
|
|
406
|
-
* reads the active capture config from the core slot; when audit is DISABLED it
|
|
407
|
-
* returns `null` immediately (one slot read — no assembly, no listener, zero
|
|
408
|
-
* regression). When enabled it:
|
|
409
|
-
* - registers a one-shot `res.on('close')` listener that, at response end,
|
|
410
|
-
* assembles the {@link AuditRecord} from the http `req` (IP via the socket, or
|
|
411
|
-
* a trusted `X-Forwarded-For` only when configured — LEAD OQ1 anti-spoof; UA;
|
|
412
|
-
* method; path with the query string DROPPED), the response `statusCode`, the
|
|
413
|
-
* elapsed ms, and the fields the handler fills in (keyId / model / provider /
|
|
414
|
-
* error / bodies) — then hands it to the fire-and-forget `recordAudit`;
|
|
415
|
-
* - when `captureBodies` is ALSO on, wraps `res.write`/`res.end` to accumulate a
|
|
416
|
-
* BOUNDED response body (metadata-only for a streaming `text/event-stream`
|
|
417
|
-
* response — a full stream is unbounded), and truncates+redacts both bodies.
|
|
418
|
-
*
|
|
419
|
-
* Request HEADERS are NEVER read into a record (Authorization / x-api-key live
|
|
420
|
-
* there). Every stored body passes through {@link redactAuditText}. The assembly
|
|
421
|
-
* is wrapped so a capture failure can never surface into the relay path.
|
|
422
|
-
*
|
|
423
|
-
* @module @omnicross/core/outbound-api/auditCapture
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* The mutable context the request handler enriches as it progresses. `null` is
|
|
428
|
-
* returned by {@link beginAuditCapture} when audit is disabled — the handler
|
|
429
|
-
* guards every write with `if (audit)`.
|
|
430
|
-
*/
|
|
431
|
-
interface AuditCaptureContext {
|
|
432
|
-
/** Outbound key id (set after auth). NEVER the key material. */
|
|
433
|
-
keyId?: string | null;
|
|
434
|
-
/** Resolved upstream model (set after route resolution). */
|
|
435
|
-
model?: string;
|
|
436
|
-
/** Upstream provider id (set after route resolution). */
|
|
437
|
-
provider?: string;
|
|
438
|
-
/** Sanitized error message (set on a relay/dispatch failure). */
|
|
439
|
-
error?: string;
|
|
440
|
-
/** Stash the raw request body for capture (a no-op unless `captureBodies`). */
|
|
441
|
-
setRequestBody(raw: string): void;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Begin audit capture for one request. Returns a mutable context the handler
|
|
445
|
-
* enriches, or `null` when audit is disabled (zero-cost path). The record is
|
|
446
|
-
* emitted on response `close` via the fire-and-forget sink.
|
|
447
|
-
*/
|
|
448
|
-
declare function beginAuditCapture(req: http.IncomingMessage, res: http.ServerResponse, now: number): AuditCaptureContext | null;
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* billingCapture — the outbound server's post-response billing capture hook
|
|
452
|
-
* (billing-event-stream, design D1/D4).
|
|
453
|
-
*
|
|
454
|
-
* {@link beginBillingCapture} is called at the TOP of `handleOutboundRequest`. It
|
|
455
|
-
* reads the active billing config from the core slot; when billing is DISABLED it
|
|
456
|
-
* returns `null` immediately (one slot read — no assembly, no listener, zero
|
|
457
|
-
* regression). When enabled it registers a one-shot `res.close` listener that
|
|
458
|
-
* assembles a {@link BillingEvent} from the handler-filled context (keyId / model
|
|
459
|
-
* / provider / authMode), the response `statusCode`, and this request's METERED
|
|
460
|
-
* FACTS (token counts + the ALREADY-COMPUTED cost) — then hands it to the
|
|
461
|
-
* no-throw {@link publishBillingEvent}.
|
|
462
|
-
*
|
|
463
|
-
* COST REUSE (design D3 — no double pricing): the metered facts are read from the
|
|
464
|
-
* per-request usage stash the usage tap populates ({@link readAuditUsage} — the
|
|
465
|
-
* SAME stash `usage-events.jsonl` correlation uses, populated UNCONDITIONALLY by
|
|
466
|
-
* the taps, independent of whether request-audit is enabled). Token counts are
|
|
467
|
-
* stashed SYNCHRONOUSLY at `record()`; the cost lands on the recorder's deferred
|
|
468
|
-
* pricing tick (scheduled BEFORE the response closes). So the assembly is deferred
|
|
469
|
-
* one macrotask past `close` — by then the earlier-scheduled pricing tick has run
|
|
470
|
-
* and stashed the computed cost we REUSE (we never re-price).
|
|
471
|
-
*
|
|
472
|
-
* BILLABLE-ONLY: an event is emitted ONLY when the request produced usage (an
|
|
473
|
-
* upstream call was billed). Auth failures / rate-limit / model-restriction
|
|
474
|
-
* rejections return before dispatch, stash no usage, and emit NO billing event.
|
|
475
|
-
*
|
|
476
|
-
* @module @omnicross/core/outbound-api/billingCapture
|
|
477
|
-
*/
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* The mutable context the request handler enriches as it progresses. `null` is
|
|
481
|
-
* returned by {@link beginBillingCapture} when billing is disabled — the handler
|
|
482
|
-
* guards every write with `if (billing)`.
|
|
483
|
-
*/
|
|
484
|
-
interface BillingCaptureContext {
|
|
485
|
-
/** Outbound key id (set after auth). NEVER the key material. */
|
|
486
|
-
keyId?: string | null;
|
|
487
|
-
/** Resolved upstream model (set after route resolution). */
|
|
488
|
-
model?: string;
|
|
489
|
-
/** Upstream provider id (set after route resolution). */
|
|
490
|
-
provider?: string;
|
|
491
|
-
/** Re-auth mode the request billed under (set after route resolution). */
|
|
492
|
-
authMode?: 'byo' | 'subscription';
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Deferral used to schedule the event assembly one macrotask past `close`, so the
|
|
496
|
-
* usage tap's earlier-scheduled pricing tick has stashed the cost we reuse.
|
|
497
|
-
* Injectable ONLY for deterministic tests; production uses a zero-delay timer.
|
|
498
|
-
*/
|
|
499
|
-
type BillingDefer = (fn: () => void) => void;
|
|
500
|
-
/**
|
|
501
|
-
* Begin billing capture for one request. Returns a mutable context the handler
|
|
502
|
-
* enriches, or `null` when billing is disabled (zero-cost path). The event is
|
|
503
|
-
* emitted on response `close` via the no-throw sink — but ONLY when the request
|
|
504
|
-
* produced usage (a billable request).
|
|
505
|
-
*/
|
|
506
|
-
declare function beginBillingCapture(_req: http.IncomingMessage, res: http.ServerResponse, now: number, defer?: BillingDefer): BillingCaptureContext | null;
|
|
507
|
-
|
|
508
377
|
/**
|
|
509
378
|
* modelPrefixDispatch — pure model-name PREFIX classification for the `chat`
|
|
510
379
|
* endpoint's opt-in `dispatchMode: 'prefix'` (openai-chat-bridge #11, design D2).
|
|
@@ -1006,4 +875,4 @@ declare function getOutboundApiServer(deps?: OutboundApiDeps, onPortChange?: (po
|
|
|
1006
875
|
/** Reset the singleton (tests / teardown only). */
|
|
1007
876
|
declare function __resetOutboundApiServerForTests(): void;
|
|
1008
877
|
|
|
1009
|
-
export {
|
|
878
|
+
export { AccountProbeConfig, type ApiServerSettingsStore, type ApplyConfigInput, ConcurrencyQueueConfig, ConcurrencyQueueFullError, ConcurrencyWaitCancelledError, ConcurrencyWaitTimeoutError, DEFAULT_ACCOUNT_PROBE, DEFAULT_CONCURRENCY_QUEUE, DEFAULT_FINGERPRINT, DEFAULT_OUTBOUND_PORT, DEFAULT_USER_MESSAGE_QUEUE, type EndpointModelConfigError, EndpointRoutingConfig, FingerprintConfig, type GateAcquireOptions, type GateAcquisition, type GateSlot, type GateStatusEntry, KeyCostLimits, type KeyVerification, KeyedMutex, KindMappedEndpoint, ModelKind, type ModelPrefixKind, ModelPrefixTargets, OUTBOUND_API_SERVER_CONFIG_KEY, OutboundApiConfigError, OutboundApiDeps, OutboundApiKeyCreated, OutboundApiServer, OutboundApiServerConfig, OutboundApiServerStatus, OutboundConcurrencyGate, OutboundEndpoint, OutboundFormatUrls, OutboundKeyDb, OutboundProxyConfig, OutboundRateLimiter, RequestRole, type SerialAcquireOptions, type SerialQueueStatusEntry, SerialQueueTimeoutError, type SerialSlot, UserMessageQueueConfig, UserMessageSerialQueue, type VerifiedKey, __resetOutboundApiServerForTests, classifyModelPrefix, createNamedKey, defaultServerConfig, detectModelKind, detectRequestRole, endpointToIngressFormat, formatUrls, getOutboundApiServer, handleVoucherRedeem, hashKey, isConcurrencyRejection, isKindMappedEndpoint, isRedeemRequest, isSerialQueueTimeout, isUserMessageRequest, loadServerConfig, mergeServerConfig, modelKindsForEndpoint, normalizeAccountProbe, normalizeAudit, normalizeBilling, normalizeFingerprint, normalizePrefixTargets, normalizeProxyConfig, normalizeProxySegment, normalizeQueueSegments, normalizeServerConfig, normalizeVoucher, normalizeWebhookDestination, normalizeWebhookSegment, randomBase62, resolvePrefixTarget, saveServerConfig, validateEndpointModelConfig, validateServerModelConfig, verifyKey, verifyPresentedKey };
|
package/dist/outbound-api.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { VoucherConfig } from '@omnicross/contracts/voucher-types';
|
|
2
|
-
import {
|
|
3
|
-
export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS,
|
|
2
|
+
import { e as KindMappedEndpoint, f as ModelKind, m as OutboundEndpoint, b as EndpointRoutingConfig, k as OutboundApiServerConfig, U as UserMessageQueueConfig, a as ConcurrencyQueueConfig, h as OutboundApiDeps, l as OutboundApiServerStatus, n as OutboundFormatUrls, A as AccountProbeConfig, F as FingerprintConfig, g as ModelPrefixTargets, r as OutboundProxyConfig, G as ModelRef, O as OutboundKeyDb, i as OutboundApiKeyCreated, R as RequestRole } from './types-lgPYQuZS.js';
|
|
3
|
+
export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS, K as KeySpendReader, c as KeySpendSeeder, d as KeySpendTracker, M as MessagesModelKind, j as OutboundApiKeyInfo, o as OutboundKeyActivationMode, p as OutboundKeyDbRow, q as OutboundKeyPolicy, s as ResponsesModelKind, V as VoucherCreateInput, t as VoucherDb, u as computeVoucherGrant, v as generateVoucherCode, w as hashVoucherCode, x as newVoucherId, y as startOfLocalDay, z as startOfLocalWeek, B as toVoucherInfo, D as voucherCodePrefix } from './types-lgPYQuZS.js';
|
|
4
4
|
import { ProxyConfig } from '@omnicross/contracts/account-tokens-types';
|
|
5
5
|
import { AuditConfig } from '@omnicross/contracts/audit-types';
|
|
6
6
|
import { BillingConfig } from '@omnicross/contracts/billing-types';
|
|
7
7
|
import { WebhookDestination, WebhookConfig } from '@omnicross/contracts/webhook-types';
|
|
8
|
+
export { AUDIT_REDACTED, redactAuditText } from './outbound-api/auditRedact.js';
|
|
9
|
+
export { AuditCaptureContext, beginAuditCapture } from './outbound-api/auditCapture.js';
|
|
10
|
+
export { BillingCaptureContext, beginBillingCapture } from './outbound-api/billingCapture.js';
|
|
11
|
+
import { K as KeyCostLimits, M as ModelRestriction } from './keyPolicy-Cp0FntZl.js';
|
|
12
|
+
export { a as KeyExpiryInput, b as KeyExpiryResult, c as KeySpend, Q as QuotaDecision, d as checkKeyQuota, e as computeKeyExpiry } from './keyPolicy-Cp0FntZl.js';
|
|
8
13
|
import http from 'node:http';
|
|
9
14
|
import { IngressFormat } from './provider-proxy/types.js';
|
|
10
|
-
export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-
|
|
15
|
+
export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-C4T7yClx.js';
|
|
11
16
|
import '@omnicross/contracts/health-logging-types';
|
|
12
17
|
import './logger-4GvQNzhE.js';
|
|
13
18
|
import './ports/provider-config-source.js';
|
|
@@ -369,142 +374,6 @@ declare function saveServerConfig(store: ApiServerSettingsStore, config: Outboun
|
|
|
369
374
|
/** Apply a partial patch to a config, returning the merged whole. */
|
|
370
375
|
declare function mergeServerConfig(current: OutboundApiServerConfig, patch: Partial<OutboundApiServerConfig>): OutboundApiServerConfig;
|
|
371
376
|
|
|
372
|
-
/**
|
|
373
|
-
* auditRedact — the pure secret-redaction pass for captured audit bodies
|
|
374
|
-
* (request-audit-log, design D3/D7).
|
|
375
|
-
*
|
|
376
|
-
* Body capture is opt-in and inherently sensitive: a prompt or tool argument can
|
|
377
|
-
* embed a secret. {@link redactAuditText} is run over EVERY captured body (and
|
|
378
|
-
* any other free text stored in a record) BEFORE it is persisted — defense in
|
|
379
|
-
* depth on top of "request headers are NEVER captured" (so an Authorization /
|
|
380
|
-
* x-api-key HEADER value never enters a record in the first place).
|
|
381
|
-
*
|
|
382
|
-
* It masks the obvious, high-confidence secret shapes ONLY (frozen list) — never
|
|
383
|
-
* a broad heuristic that would gut a legitimate prompt:
|
|
384
|
-
* - `sk-…` API keys (covers `sk-ant-…`, `sk-omnicross-…`, `sk-proj-…`, OpenAI).
|
|
385
|
-
* - `Bearer <token>` authorization values.
|
|
386
|
-
* - `x-api-key` / `api-key` / `authorization` values written inline as text.
|
|
387
|
-
* - Google `AIza…` API keys.
|
|
388
|
-
*
|
|
389
|
-
* Pure + allocation-light + never throws.
|
|
390
|
-
*
|
|
391
|
-
* @module @omnicross/core/outbound-api/auditRedact
|
|
392
|
-
*/
|
|
393
|
-
/** The sentinel a masked secret is replaced with. */
|
|
394
|
-
declare const AUDIT_REDACTED = "***REDACTED***";
|
|
395
|
-
/**
|
|
396
|
-
* Mask obvious secrets in `text`. Pure; returns the input unchanged when it holds
|
|
397
|
-
* no recognized secret shape. Never throws (a bad input returns `''`).
|
|
398
|
-
*/
|
|
399
|
-
declare function redactAuditText(text: string): string;
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* auditCapture — the outbound server's post-response audit capture hook
|
|
403
|
-
* (request-audit-log, design D1/D3/D5).
|
|
404
|
-
*
|
|
405
|
-
* {@link beginAuditCapture} is called at the TOP of `handleOutboundRequest`. It
|
|
406
|
-
* reads the active capture config from the core slot; when audit is DISABLED it
|
|
407
|
-
* returns `null` immediately (one slot read — no assembly, no listener, zero
|
|
408
|
-
* regression). When enabled it:
|
|
409
|
-
* - registers a one-shot `res.on('close')` listener that, at response end,
|
|
410
|
-
* assembles the {@link AuditRecord} from the http `req` (IP via the socket, or
|
|
411
|
-
* a trusted `X-Forwarded-For` only when configured — LEAD OQ1 anti-spoof; UA;
|
|
412
|
-
* method; path with the query string DROPPED), the response `statusCode`, the
|
|
413
|
-
* elapsed ms, and the fields the handler fills in (keyId / model / provider /
|
|
414
|
-
* error / bodies) — then hands it to the fire-and-forget `recordAudit`;
|
|
415
|
-
* - when `captureBodies` is ALSO on, wraps `res.write`/`res.end` to accumulate a
|
|
416
|
-
* BOUNDED response body (metadata-only for a streaming `text/event-stream`
|
|
417
|
-
* response — a full stream is unbounded), and truncates+redacts both bodies.
|
|
418
|
-
*
|
|
419
|
-
* Request HEADERS are NEVER read into a record (Authorization / x-api-key live
|
|
420
|
-
* there). Every stored body passes through {@link redactAuditText}. The assembly
|
|
421
|
-
* is wrapped so a capture failure can never surface into the relay path.
|
|
422
|
-
*
|
|
423
|
-
* @module @omnicross/core/outbound-api/auditCapture
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* The mutable context the request handler enriches as it progresses. `null` is
|
|
428
|
-
* returned by {@link beginAuditCapture} when audit is disabled — the handler
|
|
429
|
-
* guards every write with `if (audit)`.
|
|
430
|
-
*/
|
|
431
|
-
interface AuditCaptureContext {
|
|
432
|
-
/** Outbound key id (set after auth). NEVER the key material. */
|
|
433
|
-
keyId?: string | null;
|
|
434
|
-
/** Resolved upstream model (set after route resolution). */
|
|
435
|
-
model?: string;
|
|
436
|
-
/** Upstream provider id (set after route resolution). */
|
|
437
|
-
provider?: string;
|
|
438
|
-
/** Sanitized error message (set on a relay/dispatch failure). */
|
|
439
|
-
error?: string;
|
|
440
|
-
/** Stash the raw request body for capture (a no-op unless `captureBodies`). */
|
|
441
|
-
setRequestBody(raw: string): void;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Begin audit capture for one request. Returns a mutable context the handler
|
|
445
|
-
* enriches, or `null` when audit is disabled (zero-cost path). The record is
|
|
446
|
-
* emitted on response `close` via the fire-and-forget sink.
|
|
447
|
-
*/
|
|
448
|
-
declare function beginAuditCapture(req: http.IncomingMessage, res: http.ServerResponse, now: number): AuditCaptureContext | null;
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* billingCapture — the outbound server's post-response billing capture hook
|
|
452
|
-
* (billing-event-stream, design D1/D4).
|
|
453
|
-
*
|
|
454
|
-
* {@link beginBillingCapture} is called at the TOP of `handleOutboundRequest`. It
|
|
455
|
-
* reads the active billing config from the core slot; when billing is DISABLED it
|
|
456
|
-
* returns `null` immediately (one slot read — no assembly, no listener, zero
|
|
457
|
-
* regression). When enabled it registers a one-shot `res.close` listener that
|
|
458
|
-
* assembles a {@link BillingEvent} from the handler-filled context (keyId / model
|
|
459
|
-
* / provider / authMode), the response `statusCode`, and this request's METERED
|
|
460
|
-
* FACTS (token counts + the ALREADY-COMPUTED cost) — then hands it to the
|
|
461
|
-
* no-throw {@link publishBillingEvent}.
|
|
462
|
-
*
|
|
463
|
-
* COST REUSE (design D3 — no double pricing): the metered facts are read from the
|
|
464
|
-
* per-request usage stash the usage tap populates ({@link readAuditUsage} — the
|
|
465
|
-
* SAME stash `usage-events.jsonl` correlation uses, populated UNCONDITIONALLY by
|
|
466
|
-
* the taps, independent of whether request-audit is enabled). Token counts are
|
|
467
|
-
* stashed SYNCHRONOUSLY at `record()`; the cost lands on the recorder's deferred
|
|
468
|
-
* pricing tick (scheduled BEFORE the response closes). So the assembly is deferred
|
|
469
|
-
* one macrotask past `close` — by then the earlier-scheduled pricing tick has run
|
|
470
|
-
* and stashed the computed cost we REUSE (we never re-price).
|
|
471
|
-
*
|
|
472
|
-
* BILLABLE-ONLY: an event is emitted ONLY when the request produced usage (an
|
|
473
|
-
* upstream call was billed). Auth failures / rate-limit / model-restriction
|
|
474
|
-
* rejections return before dispatch, stash no usage, and emit NO billing event.
|
|
475
|
-
*
|
|
476
|
-
* @module @omnicross/core/outbound-api/billingCapture
|
|
477
|
-
*/
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* The mutable context the request handler enriches as it progresses. `null` is
|
|
481
|
-
* returned by {@link beginBillingCapture} when billing is disabled — the handler
|
|
482
|
-
* guards every write with `if (billing)`.
|
|
483
|
-
*/
|
|
484
|
-
interface BillingCaptureContext {
|
|
485
|
-
/** Outbound key id (set after auth). NEVER the key material. */
|
|
486
|
-
keyId?: string | null;
|
|
487
|
-
/** Resolved upstream model (set after route resolution). */
|
|
488
|
-
model?: string;
|
|
489
|
-
/** Upstream provider id (set after route resolution). */
|
|
490
|
-
provider?: string;
|
|
491
|
-
/** Re-auth mode the request billed under (set after route resolution). */
|
|
492
|
-
authMode?: 'byo' | 'subscription';
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Deferral used to schedule the event assembly one macrotask past `close`, so the
|
|
496
|
-
* usage tap's earlier-scheduled pricing tick has stashed the cost we reuse.
|
|
497
|
-
* Injectable ONLY for deterministic tests; production uses a zero-delay timer.
|
|
498
|
-
*/
|
|
499
|
-
type BillingDefer = (fn: () => void) => void;
|
|
500
|
-
/**
|
|
501
|
-
* Begin billing capture for one request. Returns a mutable context the handler
|
|
502
|
-
* enriches, or `null` when billing is disabled (zero-cost path). The event is
|
|
503
|
-
* emitted on response `close` via the no-throw sink — but ONLY when the request
|
|
504
|
-
* produced usage (a billable request).
|
|
505
|
-
*/
|
|
506
|
-
declare function beginBillingCapture(_req: http.IncomingMessage, res: http.ServerResponse, now: number, defer?: BillingDefer): BillingCaptureContext | null;
|
|
507
|
-
|
|
508
377
|
/**
|
|
509
378
|
* modelPrefixDispatch — pure model-name PREFIX classification for the `chat`
|
|
510
379
|
* endpoint's opt-in `dispatchMode: 'prefix'` (openai-chat-bridge #11, design D2).
|
|
@@ -1006,4 +875,4 @@ declare function getOutboundApiServer(deps?: OutboundApiDeps, onPortChange?: (po
|
|
|
1006
875
|
/** Reset the singleton (tests / teardown only). */
|
|
1007
876
|
declare function __resetOutboundApiServerForTests(): void;
|
|
1008
877
|
|
|
1009
|
-
export {
|
|
878
|
+
export { AccountProbeConfig, type ApiServerSettingsStore, type ApplyConfigInput, ConcurrencyQueueConfig, ConcurrencyQueueFullError, ConcurrencyWaitCancelledError, ConcurrencyWaitTimeoutError, DEFAULT_ACCOUNT_PROBE, DEFAULT_CONCURRENCY_QUEUE, DEFAULT_FINGERPRINT, DEFAULT_OUTBOUND_PORT, DEFAULT_USER_MESSAGE_QUEUE, type EndpointModelConfigError, EndpointRoutingConfig, FingerprintConfig, type GateAcquireOptions, type GateAcquisition, type GateSlot, type GateStatusEntry, KeyCostLimits, type KeyVerification, KeyedMutex, KindMappedEndpoint, ModelKind, type ModelPrefixKind, ModelPrefixTargets, OUTBOUND_API_SERVER_CONFIG_KEY, OutboundApiConfigError, OutboundApiDeps, OutboundApiKeyCreated, OutboundApiServer, OutboundApiServerConfig, OutboundApiServerStatus, OutboundConcurrencyGate, OutboundEndpoint, OutboundFormatUrls, OutboundKeyDb, OutboundProxyConfig, OutboundRateLimiter, RequestRole, type SerialAcquireOptions, type SerialQueueStatusEntry, SerialQueueTimeoutError, type SerialSlot, UserMessageQueueConfig, UserMessageSerialQueue, type VerifiedKey, __resetOutboundApiServerForTests, classifyModelPrefix, createNamedKey, defaultServerConfig, detectModelKind, detectRequestRole, endpointToIngressFormat, formatUrls, getOutboundApiServer, handleVoucherRedeem, hashKey, isConcurrencyRejection, isKindMappedEndpoint, isRedeemRequest, isSerialQueueTimeout, isUserMessageRequest, loadServerConfig, mergeServerConfig, modelKindsForEndpoint, normalizeAccountProbe, normalizeAudit, normalizeBilling, normalizeFingerprint, normalizePrefixTargets, normalizeProxyConfig, normalizeProxySegment, normalizeQueueSegments, normalizeServerConfig, normalizeVoucher, normalizeWebhookDestination, normalizeWebhookSegment, randomBase62, resolvePrefixTarget, saveServerConfig, validateEndpointModelConfig, validateServerModelConfig, verifyKey, verifyPresentedKey };
|
package/dist/outbound-api.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AUDIT_REDACTED,
|
|
3
2
|
ConcurrencyQueueFullError,
|
|
4
3
|
ConcurrencyWaitCancelledError,
|
|
5
4
|
ConcurrencyWaitTimeoutError,
|
|
@@ -18,8 +17,6 @@ import {
|
|
|
18
17
|
SerialQueueTimeoutError,
|
|
19
18
|
UserMessageSerialQueue,
|
|
20
19
|
__resetOutboundApiServerForTests,
|
|
21
|
-
beginAuditCapture,
|
|
22
|
-
beginBillingCapture,
|
|
23
20
|
checkKeyQuota,
|
|
24
21
|
computeKeyExpiry,
|
|
25
22
|
computeVoucherGrant,
|
|
@@ -51,7 +48,6 @@ import {
|
|
|
51
48
|
normalizeWebhookDestination,
|
|
52
49
|
normalizeWebhookSegment,
|
|
53
50
|
randomBase62,
|
|
54
|
-
redactAuditText,
|
|
55
51
|
saveServerConfig,
|
|
56
52
|
startOfLocalDay,
|
|
57
53
|
startOfLocalWeek,
|
|
@@ -59,35 +55,38 @@ import {
|
|
|
59
55
|
verifyKey,
|
|
60
56
|
verifyPresentedKey,
|
|
61
57
|
voucherCodePrefix
|
|
62
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-QYTT6GE3.js";
|
|
63
59
|
import "./chunk-VVEHS2LI.js";
|
|
64
60
|
import "./chunk-46RLHI7D.js";
|
|
65
|
-
import "./chunk-G2UTNSGU.js";
|
|
66
61
|
import "./chunk-DK4A7DLE.js";
|
|
67
|
-
import "./chunk-
|
|
68
|
-
import "./chunk-Z7LUNECE.js";
|
|
62
|
+
import "./chunk-VPBAUQ2M.js";
|
|
69
63
|
import "./chunk-ZJZAOKI7.js";
|
|
70
64
|
import "./chunk-FTQ7IQUC.js";
|
|
71
65
|
import "./chunk-C7PSERMH.js";
|
|
72
|
-
import "./chunk-
|
|
66
|
+
import "./chunk-TIER4SUC.js";
|
|
67
|
+
import "./chunk-Z7LUNECE.js";
|
|
73
68
|
import "./chunk-7VU7V2E4.js";
|
|
74
69
|
import "./chunk-ZLX3KGXX.js";
|
|
75
|
-
import "./chunk-
|
|
70
|
+
import "./chunk-BPKCU575.js";
|
|
71
|
+
import "./chunk-G2UTNSGU.js";
|
|
76
72
|
import "./chunk-MZNPGW5Q.js";
|
|
77
73
|
import "./chunk-XTEI64OU.js";
|
|
78
74
|
import "./chunk-XX6NQJMA.js";
|
|
79
75
|
import "./chunk-IAXWICZU.js";
|
|
76
|
+
import "./chunk-OE6TDIWW.js";
|
|
77
|
+
import "./chunk-DRWHTIIZ.js";
|
|
78
|
+
import "./chunk-IK3KE3AU.js";
|
|
79
|
+
import "./chunk-ZY6KU6P3.js";
|
|
80
|
+
import "./chunk-JWC6APFQ.js";
|
|
80
81
|
import "./chunk-5ERIZW3D.js";
|
|
81
82
|
import "./chunk-5ENKBSWO.js";
|
|
82
|
-
import "./chunk-
|
|
83
|
+
import "./chunk-HRRYG2AX.js";
|
|
83
84
|
import "./chunk-AVYJ4YBN.js";
|
|
84
|
-
import
|
|
85
|
-
|
|
85
|
+
import {
|
|
86
|
+
beginBillingCapture
|
|
87
|
+
} from "./chunk-WLYIIEAF.js";
|
|
86
88
|
import "./chunk-TKJMZBAH.js";
|
|
87
|
-
import "./chunk-
|
|
88
|
-
import "./chunk-ZY6KU6P3.js";
|
|
89
|
-
import "./chunk-JWC6APFQ.js";
|
|
90
|
-
import "./chunk-H5JUT3KV.js";
|
|
89
|
+
import "./chunk-3QFXFCHG.js";
|
|
91
90
|
import {
|
|
92
91
|
SUBSCRIPTION_PROVIDER_IDS,
|
|
93
92
|
classifyModelPrefix,
|
|
@@ -104,15 +103,25 @@ import {
|
|
|
104
103
|
resolveRoute,
|
|
105
104
|
validateEndpointModelConfig,
|
|
106
105
|
validateServerModelConfig
|
|
107
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-UHGVBFU3.js";
|
|
108
107
|
import "./chunk-AQ5TNQB7.js";
|
|
109
108
|
import {
|
|
110
109
|
ENDPOINT_MODEL_KINDS
|
|
111
110
|
} from "./chunk-XEKD23J5.js";
|
|
111
|
+
import "./chunk-H5JUT3KV.js";
|
|
112
|
+
import {
|
|
113
|
+
beginAuditCapture
|
|
114
|
+
} from "./chunk-7Y47UCF2.js";
|
|
115
|
+
import {
|
|
116
|
+
AUDIT_REDACTED,
|
|
117
|
+
redactAuditText
|
|
118
|
+
} from "./chunk-K5NM7VAH.js";
|
|
119
|
+
import "./chunk-WNY4WMRF.js";
|
|
120
|
+
import "./chunk-OZFM4X3S.js";
|
|
112
121
|
import "./chunk-5ZQBEOMD.js";
|
|
113
|
-
import "./chunk-BO4RFWBR.js";
|
|
114
122
|
import "./chunk-Z7Y2NPHY.js";
|
|
115
123
|
import "./chunk-S4WBV25P.js";
|
|
124
|
+
import "./chunk-XK5CIRMQ.js";
|
|
116
125
|
import "./chunk-CDHS2QDC.js";
|
|
117
126
|
import "./chunk-Y7FO65VT.js";
|
|
118
127
|
import "./chunk-FMOBD2OQ.js";
|
|
@@ -52,6 +52,12 @@ interface AuthApplyHints {
|
|
|
52
52
|
* (no cross-request race). BYO auth sources ignore it.
|
|
53
53
|
*/
|
|
54
54
|
reportSelection?: (accountId: string, isActive: boolean, remappedModel?: string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* OPTIONAL preferred subscription account id (provider/subscription duality).
|
|
57
|
+
* When set and schedulable the account picker resolves it directly; absent or
|
|
58
|
+
* unschedulable ⇒ pool auto-schedule. BYO auth sources ignore it.
|
|
59
|
+
*/
|
|
60
|
+
preferredAccountId?: string;
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* Result of {@link AuthSource.onResult}.
|
|
@@ -52,6 +52,12 @@ interface AuthApplyHints {
|
|
|
52
52
|
* (no cross-request race). BYO auth sources ignore it.
|
|
53
53
|
*/
|
|
54
54
|
reportSelection?: (accountId: string, isActive: boolean, remappedModel?: string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* OPTIONAL preferred subscription account id (provider/subscription duality).
|
|
57
|
+
* When set and schedulable the account picker resolves it directly; absent or
|
|
58
|
+
* unschedulable ⇒ pool auto-schedule. BYO auth sources ignore it.
|
|
59
|
+
*/
|
|
60
|
+
preferredAccountId?: string;
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* Result of {@link AuthSource.onResult}.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkKFI44N2Rcjs = require('../chunk-KFI44N2R.cjs');
|
|
5
5
|
require('../chunk-SVNDB62D.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports.SubscriptionAuthSource =
|
|
9
|
+
exports.SubscriptionAuthSource = _chunkKFI44N2Rcjs.SubscriptionAuthSource; exports.stripAuthHeaders = _chunkKFI44N2Rcjs.stripAuthHeaders;
|
|
@@ -49,6 +49,12 @@ interface AuthApplyHints {
|
|
|
49
49
|
* pre-health behavior).
|
|
50
50
|
*/
|
|
51
51
|
reportSelection?: (accountId: string, isActive: boolean, remappedModel?: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* OPTIONAL preferred subscription account id (provider/subscription duality).
|
|
54
|
+
* When set and schedulable the account picker resolves it directly; absent or
|
|
55
|
+
* unschedulable ⇒ pool auto-schedule.
|
|
56
|
+
*/
|
|
57
|
+
preferredAccountId?: string;
|
|
52
58
|
}
|
|
53
59
|
interface AuthStrategy {
|
|
54
60
|
/** Discriminator — also surfaced through `subscription:list` to renderers. */
|
|
@@ -49,6 +49,12 @@ interface AuthApplyHints {
|
|
|
49
49
|
* pre-health behavior).
|
|
50
50
|
*/
|
|
51
51
|
reportSelection?: (accountId: string, isActive: boolean, remappedModel?: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* OPTIONAL preferred subscription account id (provider/subscription duality).
|
|
54
|
+
* When set and schedulable the account picker resolves it directly; absent or
|
|
55
|
+
* unschedulable ⇒ pool auto-schedule.
|
|
56
|
+
*/
|
|
57
|
+
preferredAccountId?: string;
|
|
52
58
|
}
|
|
53
59
|
interface AuthStrategy {
|
|
54
60
|
/** Discriminator — also surfaced through `subscription:list` to renderers. */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkXSVNC2UDcjs = require('../chunk-XSVNC2UD.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.__clearAuditUsageForTests = _chunkXSVNC2UDcjs.__clearAuditUsageForTests; exports.readAuditUsage = _chunkXSVNC2UDcjs.readAuditUsage; exports.stashAuditUsage = _chunkXSVNC2UDcjs.stashAuditUsage;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auditUsageStash — a per-request usage correlation stash for the audit capture
|
|
3
|
+
* (request-audit-log, design D1). The audit record is assembled at the outbound
|
|
4
|
+
* router's post-response point, but token counts + cost are produced downstream
|
|
5
|
+
* by the usage tap → `UsageRecorder`. This `WeakMap<res, detail>` bridges them:
|
|
6
|
+
* the recorder stashes the usage detail keyed by the SAME `http.ServerResponse`
|
|
7
|
+
* the audit capture holds, so `beginAuditCapture` can read it at response close.
|
|
8
|
+
*
|
|
9
|
+
* The token counts + model/provider are stashed SYNCHRONOUSLY at `record()` time
|
|
10
|
+
* (before the response closes ⇒ reliably present); the cost is stashed on the
|
|
11
|
+
* deferred pricing tick (best-effort — populated when it lands before close).
|
|
12
|
+
* Keyed by the response OBJECT (a `WeakMap`, so a completed request's entry is
|
|
13
|
+
* GC'd with the response — no leak, no cleanup needed).
|
|
14
|
+
*
|
|
15
|
+
* This is OPT-IN + gated: only the outbound taps set `auditResponse`, and the
|
|
16
|
+
* audit capture only reads when audit is enabled. Any other `UsageRecorder`
|
|
17
|
+
* caller leaves `auditResponse` unset ⇒ this map is never touched ⇒ zero
|
|
18
|
+
* regression.
|
|
19
|
+
*
|
|
20
|
+
* @module @omnicross/core/pipeline/auditUsageStash
|
|
21
|
+
*/
|
|
22
|
+
/** The subset of usage numbers an audit record carries (all optional). */
|
|
23
|
+
interface AuditUsageDetail {
|
|
24
|
+
inputTokens?: number;
|
|
25
|
+
outputTokens?: number;
|
|
26
|
+
costUsd?: number;
|
|
27
|
+
model?: string;
|
|
28
|
+
provider?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Merge a partial usage detail into the entry keyed by `key` (the response). */
|
|
31
|
+
declare function stashAuditUsage(key: object, detail: AuditUsageDetail): void;
|
|
32
|
+
/** Read the accumulated usage detail for `key`, or `undefined` when none. */
|
|
33
|
+
declare function readAuditUsage(key: object): AuditUsageDetail | undefined;
|
|
34
|
+
/** TEST SEAM — drop a stashed entry so a suite starts clean. */
|
|
35
|
+
declare function __clearAuditUsageForTests(key: object): void;
|
|
36
|
+
|
|
37
|
+
export { type AuditUsageDetail, __clearAuditUsageForTests, readAuditUsage, stashAuditUsage };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auditUsageStash — a per-request usage correlation stash for the audit capture
|
|
3
|
+
* (request-audit-log, design D1). The audit record is assembled at the outbound
|
|
4
|
+
* router's post-response point, but token counts + cost are produced downstream
|
|
5
|
+
* by the usage tap → `UsageRecorder`. This `WeakMap<res, detail>` bridges them:
|
|
6
|
+
* the recorder stashes the usage detail keyed by the SAME `http.ServerResponse`
|
|
7
|
+
* the audit capture holds, so `beginAuditCapture` can read it at response close.
|
|
8
|
+
*
|
|
9
|
+
* The token counts + model/provider are stashed SYNCHRONOUSLY at `record()` time
|
|
10
|
+
* (before the response closes ⇒ reliably present); the cost is stashed on the
|
|
11
|
+
* deferred pricing tick (best-effort — populated when it lands before close).
|
|
12
|
+
* Keyed by the response OBJECT (a `WeakMap`, so a completed request's entry is
|
|
13
|
+
* GC'd with the response — no leak, no cleanup needed).
|
|
14
|
+
*
|
|
15
|
+
* This is OPT-IN + gated: only the outbound taps set `auditResponse`, and the
|
|
16
|
+
* audit capture only reads when audit is enabled. Any other `UsageRecorder`
|
|
17
|
+
* caller leaves `auditResponse` unset ⇒ this map is never touched ⇒ zero
|
|
18
|
+
* regression.
|
|
19
|
+
*
|
|
20
|
+
* @module @omnicross/core/pipeline/auditUsageStash
|
|
21
|
+
*/
|
|
22
|
+
/** The subset of usage numbers an audit record carries (all optional). */
|
|
23
|
+
interface AuditUsageDetail {
|
|
24
|
+
inputTokens?: number;
|
|
25
|
+
outputTokens?: number;
|
|
26
|
+
costUsd?: number;
|
|
27
|
+
model?: string;
|
|
28
|
+
provider?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Merge a partial usage detail into the entry keyed by `key` (the response). */
|
|
31
|
+
declare function stashAuditUsage(key: object, detail: AuditUsageDetail): void;
|
|
32
|
+
/** Read the accumulated usage detail for `key`, or `undefined` when none. */
|
|
33
|
+
declare function readAuditUsage(key: object): AuditUsageDetail | undefined;
|
|
34
|
+
/** TEST SEAM — drop a stashed entry so a suite starts clean. */
|
|
35
|
+
declare function __clearAuditUsageForTests(key: object): void;
|
|
36
|
+
|
|
37
|
+
export { type AuditUsageDetail, __clearAuditUsageForTests, readAuditUsage, stashAuditUsage };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHYN75H6Gcjs = require('../chunk-HYN75H6G.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
exports.executeProviderCall =
|
|
6
|
+
exports.executeProviderCall = _chunkHYN75H6Gcjs.executeProviderCall;
|