@omnicross/core 0.1.2 → 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 +6 -1
- package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -1
- package/dist/chunk-3QFXFCHG.js +33 -0
- package/dist/chunk-4IH4EL7M.cjs +9 -0
- package/dist/chunk-4YINUUKQ.cjs +33 -0
- package/dist/chunk-5ENKBSWO.js +311 -0
- package/dist/chunk-6RPZADX3.cjs +92 -0
- package/dist/chunk-7Y47UCF2.js +142 -0
- package/dist/chunk-AEOZIDEB.cjs +32 -0
- package/dist/chunk-APYG5QD7.cjs +50 -0
- package/dist/{chunk-MNYKI4CI.js → chunk-BPKCU575.js} +29 -0
- package/dist/{chunk-SN3YWBX7.cjs → chunk-DKPXN34V.cjs} +2108 -538
- package/dist/{chunk-4NBS6KPV.cjs → chunk-DQ5VAYZ6.cjs} +7 -8
- package/dist/chunk-E3UCVHLP.cjs +142 -0
- package/dist/chunk-FCR77GYM.cjs +33 -0
- package/dist/{chunk-74TMJA7Z.js → chunk-HRRYG2AX.js} +8 -4
- package/dist/chunk-HUZZZ3JL.js +32 -0
- package/dist/{chunk-KUU2RNG6.cjs → chunk-HYN75H6G.cjs} +3 -0
- package/dist/{chunk-QOCNX236.js → chunk-IAXWICZU.js} +24 -1
- package/dist/{chunk-JO5NLTLY.js → chunk-IK3KE3AU.js} +3 -0
- package/dist/{chunk-V5KPWNYX.cjs → chunk-JMJBSACD.cjs} +3 -3
- package/dist/chunk-K5NM7VAH.js +33 -0
- package/dist/{chunk-N3V2J5ZO.cjs → chunk-KFI44N2R.cjs} +8 -4
- package/dist/chunk-L74VDN4A.cjs +32 -0
- package/dist/chunk-OCEUVQHW.cjs +112 -0
- package/dist/chunk-OE6TDIWW.js +22 -0
- package/dist/chunk-OZFM4X3S.js +18 -0
- package/dist/{chunk-LKZJEL6E.cjs → chunk-Q27JY5RG.cjs} +6 -4
- package/dist/{chunk-SPVWWUHX.cjs → chunk-QWBWGODS.cjs} +24 -1
- package/dist/{chunk-2FEVTJWG.js → chunk-QYTT6GE3.js} +1929 -359
- package/dist/{chunk-UYPEN5XE.cjs → chunk-RGTR7CIO.cjs} +6 -6
- package/dist/chunk-RPII3E6Z.cjs +145 -0
- package/dist/{chunk-XBSYYZIY.cjs → chunk-SNYBEXLB.cjs} +31 -2
- package/dist/{chunk-2DCNB7DF.cjs → chunk-SU2GCLAC.cjs} +30 -10
- package/dist/{chunk-5HTVET6E.js → chunk-TIER4SUC.js} +24 -4
- package/dist/chunk-TKJMZBAH.js +32 -0
- package/dist/{chunk-ZSVQT3PW.js → chunk-UBWEBKRC.js} +5 -6
- package/dist/chunk-UHGVBFU3.js +385 -0
- package/dist/chunk-UIBD2YY5.cjs +22 -0
- package/dist/chunk-UNEFIWXI.cjs +32 -0
- package/dist/chunk-VACWOIRE.cjs +385 -0
- package/dist/{chunk-O466Y272.js → chunk-VPBAUQ2M.js} +7 -7
- package/dist/chunk-VQY5W4YW.cjs +311 -0
- package/dist/chunk-WLYIIEAF.js +50 -0
- package/dist/chunk-WNY4WMRF.js +32 -0
- package/dist/chunk-XEKD23J5.js +9 -0
- package/dist/chunk-XK5CIRMQ.js +112 -0
- package/dist/chunk-XSVNC2UD.cjs +18 -0
- package/dist/chunk-XTEI64OU.js +145 -0
- package/dist/chunk-XX6NQJMA.js +92 -0
- package/dist/{chunk-745DV5FL.js → chunk-Y7FO65VT.js} +3 -3
- package/dist/{chunk-PXUJF5HS.js → chunk-ZY6KU6P3.js} +4 -2
- package/dist/completion/CompletionService.cjs +30 -17
- package/dist/completion/CompletionService.js +29 -16
- package/dist/completion/NativeSearchInjector.cjs +3 -3
- package/dist/completion/NativeSearchInjector.js +2 -2
- package/dist/completion/openrouter-headers.cjs +3 -6
- package/dist/completion/openrouter-headers.d.cts +9 -12
- package/dist/completion/openrouter-headers.d.ts +9 -12
- package/dist/completion/openrouter-headers.js +2 -5
- package/dist/completion/openrouter-models.cjs +4 -3
- package/dist/completion/openrouter-models.js +2 -1
- package/dist/completion.cjs +30 -17
- package/dist/completion.js +29 -16
- package/dist/index.cjs +151 -20
- package/dist/index.d.cts +44 -10
- package/dist/index.d.ts +44 -10
- package/dist/index.js +160 -29
- 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 +5 -2
- package/dist/outbound-api/routeResolver.d.cts +9 -2
- package/dist/outbound-api/routeResolver.d.ts +9 -2
- package/dist/outbound-api/routeResolver.js +4 -1
- package/dist/outbound-api/types.cjs +6 -1
- package/dist/outbound-api/types.d.cts +12 -144
- package/dist/outbound-api/types.d.ts +12 -144
- package/dist/outbound-api/types.js +6 -0
- package/dist/outbound-api.cjs +144 -17
- package/dist/outbound-api.d.cts +655 -25
- package/dist/outbound-api.d.ts +655 -25
- package/dist/outbound-api.js +148 -21
- package/dist/pipeline/AuthSource.d.cts +29 -1
- package/dist/pipeline/AuthSource.d.ts +29 -1
- package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
- package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.cjs +22 -0
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +235 -0
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +235 -0
- package/dist/pipeline/SubscriptionAccountHealth.js +22 -0
- package/dist/pipeline/SubscriptionAuthSource.cjs +2 -2
- package/dist/pipeline/SubscriptionAuthSource.d.cts +3 -2
- package/dist/pipeline/SubscriptionAuthSource.d.ts +3 -2
- package/dist/pipeline/SubscriptionAuthSource.js +1 -1
- package/dist/pipeline/SubscriptionAuthStrategy.d.cts +30 -1
- package/dist/pipeline/SubscriptionAuthStrategy.d.ts +30 -1
- package/dist/pipeline/auditSink.cjs +14 -0
- package/dist/pipeline/auditSink.d.cts +48 -0
- package/dist/pipeline/auditSink.d.ts +48 -0
- package/dist/pipeline/auditSink.js +14 -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/billingEmit.cjs +14 -0
- package/dist/pipeline/billingEmit.d.cts +49 -0
- package/dist/pipeline/billingEmit.d.ts +49 -0
- package/dist/pipeline/billingEmit.js +14 -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/usage-event-store.d.cts +26 -1
- package/dist/ports/usage-event-store.d.ts +26 -1
- package/dist/ports.d.cts +8 -1
- package/dist/ports.d.ts +8 -1
- package/dist/provider-proxy/ProviderProxy.cjs +30 -17
- package/dist/provider-proxy/ProviderProxy.js +29 -16
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.cjs +15 -0
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.cts +121 -0
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.ts +121 -0
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.js +15 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.cjs +20 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.d.cts +89 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.d.ts +89 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.js +20 -0
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +30 -17
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +11 -2
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +11 -2
- package/dist/provider-proxy/ingress/providerProxyShared.js +29 -16
- package/dist/provider-proxy/matchText.cjs +4 -2
- package/dist/provider-proxy/matchText.d.cts +14 -1
- package/dist/provider-proxy/matchText.d.ts +14 -1
- package/dist/provider-proxy/matchText.js +3 -1
- package/dist/provider-proxy/types.d.cts +30 -0
- package/dist/provider-proxy/types.d.ts +30 -0
- package/dist/provider-proxy.cjs +30 -17
- package/dist/provider-proxy.js +29 -16
- package/dist/{routeResolver-HE-ZO0fO.d.ts → routeResolver-C4T7yClx.d.ts} +36 -10
- package/dist/{routeResolver-BrbK6ja9.d.cts → routeResolver-CB3tvJKy.d.cts} +36 -10
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
- package/dist/transformer/transformers.cjs +7 -7
- package/dist/transformer/transformers.js +8 -8
- package/dist/transformer.cjs +9 -9
- package/dist/transformer.js +8 -8
- package/dist/types-B8Arpxn0.d.cts +754 -0
- package/dist/types-lgPYQuZS.d.ts +754 -0
- package/dist/usage/usage-recorder.cjs +3 -2
- package/dist/usage/usage-recorder.d.cts +19 -1
- package/dist/usage/usage-recorder.d.ts +19 -1
- package/dist/usage/usage-recorder.js +2 -1
- package/dist/usage.cjs +3 -2
- package/dist/usage.js +2 -1
- package/package.json +64 -62
- package/dist/chunk-3MEACFK3.js +0 -193
- package/dist/chunk-6VIXXLMX.cjs +0 -14
- package/dist/chunk-E3WHL7CO.js +0 -14
- package/dist/chunk-G2FUJNA2.cjs +0 -193
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkSNYBEXLBcjs = require('../chunk-SNYBEXLB.cjs');
|
|
4
|
+
require('../chunk-XSVNC2UD.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
exports.UsageRecorder =
|
|
7
|
+
exports.UsageRecorder = _chunkSNYBEXLBcjs.UsageRecorder;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PricingEngine } from './pricing-engine.cjs';
|
|
2
|
-
import { UsageDateRange, UsageTotals, ModelUsageRow, ApiKeyUsageRow, MessageUsageRow, SessionCacheStats } from '@omnicross/contracts/usage-stats-types';
|
|
2
|
+
import { UsageDateRange, UsageTotals, ModelUsageRow, ApiKeyUsageRow, UsageTimeBucket, UsageTimeSeriesBucket, MessageUsageRow, SessionCacheStats } from '@omnicross/contracts/usage-stats-types';
|
|
3
3
|
import { UsageEngineOrigin, UsageTokens } from '@omnicross/contracts/usage-types';
|
|
4
4
|
import { L as Logger } from '../logger-4GvQNzhE.cjs';
|
|
5
5
|
import { UsageEventStore } from '../ports/usage-event-store.cjs';
|
|
@@ -34,6 +34,15 @@ interface UsageRecordInput {
|
|
|
34
34
|
runId?: string | null;
|
|
35
35
|
/** Host event-correlation id for this call. Optional / additive. */
|
|
36
36
|
eventId?: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* OPTIONAL per-request audit correlation key (request-audit-log). When the
|
|
39
|
+
* OUTBOUND relay taps set this to the request's `http.ServerResponse`, the
|
|
40
|
+
* recorder stashes this request's token counts (synchronously) + cost (on the
|
|
41
|
+
* deferred pricing tick) keyed by it, so the audit capture can enrich its
|
|
42
|
+
* record. Any other caller leaves it unset ⇒ the audit stash is never touched
|
|
43
|
+
* (byte-identical zero regression). Opaque object; NEVER inspected/serialized.
|
|
44
|
+
*/
|
|
45
|
+
auditResponse?: object;
|
|
37
46
|
}
|
|
38
47
|
/** Optional knobs (mostly for hosts/tests). */
|
|
39
48
|
interface UsageRecorderOptions {
|
|
@@ -43,12 +52,20 @@ interface UsageRecorderOptions {
|
|
|
43
52
|
* `setImmediate` to preserve their exact scheduling.
|
|
44
53
|
*/
|
|
45
54
|
defer?: (fn: () => void) => void;
|
|
55
|
+
/**
|
|
56
|
+
* OPTIONAL per-request hook (outbound-key-policy). Called synchronously after
|
|
57
|
+
* cost is computed for each recorded request that carries an `apiKeyId`, so a
|
|
58
|
+
* host can keep a live per-key spend aggregate WITHOUT re-scanning the store.
|
|
59
|
+
* Absent ⇒ no-op (byte-identical for hosts/tests that do not wire it).
|
|
60
|
+
*/
|
|
61
|
+
onRecord?: (apiKeyId: string, costUsd: number, now: number) => void;
|
|
46
62
|
}
|
|
47
63
|
declare class UsageRecorder {
|
|
48
64
|
private store;
|
|
49
65
|
private pricing;
|
|
50
66
|
private logger;
|
|
51
67
|
private defer;
|
|
68
|
+
private onRecord?;
|
|
52
69
|
constructor(store: UsageEventStore, pricing: PricingEngine, logger: Logger, options?: UsageRecorderOptions);
|
|
53
70
|
/**
|
|
54
71
|
* Record one LLM request. Returns immediately — the actual store insert is
|
|
@@ -65,6 +82,7 @@ declare class UsageRecorder {
|
|
|
65
82
|
getTotals(range: UsageDateRange): Promise<UsageTotals>;
|
|
66
83
|
getByModel(range: UsageDateRange): Promise<ModelUsageRow[]>;
|
|
67
84
|
getByApiKey(range: UsageDateRange): Promise<ApiKeyUsageRow[]>;
|
|
85
|
+
getTimeSeries(range: UsageDateRange, bucket: UsageTimeBucket): Promise<UsageTimeSeriesBucket[]>;
|
|
68
86
|
getMessagesForSession(sessionId: string): Promise<MessageUsageRow[]>;
|
|
69
87
|
/** Cumulative cache hit/miss stats for one session. */
|
|
70
88
|
getSessionCacheStats(sessionId: string): Promise<SessionCacheStats>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PricingEngine } from './pricing-engine.js';
|
|
2
|
-
import { UsageDateRange, UsageTotals, ModelUsageRow, ApiKeyUsageRow, MessageUsageRow, SessionCacheStats } from '@omnicross/contracts/usage-stats-types';
|
|
2
|
+
import { UsageDateRange, UsageTotals, ModelUsageRow, ApiKeyUsageRow, UsageTimeBucket, UsageTimeSeriesBucket, MessageUsageRow, SessionCacheStats } from '@omnicross/contracts/usage-stats-types';
|
|
3
3
|
import { UsageEngineOrigin, UsageTokens } from '@omnicross/contracts/usage-types';
|
|
4
4
|
import { L as Logger } from '../logger-4GvQNzhE.js';
|
|
5
5
|
import { UsageEventStore } from '../ports/usage-event-store.js';
|
|
@@ -34,6 +34,15 @@ interface UsageRecordInput {
|
|
|
34
34
|
runId?: string | null;
|
|
35
35
|
/** Host event-correlation id for this call. Optional / additive. */
|
|
36
36
|
eventId?: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* OPTIONAL per-request audit correlation key (request-audit-log). When the
|
|
39
|
+
* OUTBOUND relay taps set this to the request's `http.ServerResponse`, the
|
|
40
|
+
* recorder stashes this request's token counts (synchronously) + cost (on the
|
|
41
|
+
* deferred pricing tick) keyed by it, so the audit capture can enrich its
|
|
42
|
+
* record. Any other caller leaves it unset ⇒ the audit stash is never touched
|
|
43
|
+
* (byte-identical zero regression). Opaque object; NEVER inspected/serialized.
|
|
44
|
+
*/
|
|
45
|
+
auditResponse?: object;
|
|
37
46
|
}
|
|
38
47
|
/** Optional knobs (mostly for hosts/tests). */
|
|
39
48
|
interface UsageRecorderOptions {
|
|
@@ -43,12 +52,20 @@ interface UsageRecorderOptions {
|
|
|
43
52
|
* `setImmediate` to preserve their exact scheduling.
|
|
44
53
|
*/
|
|
45
54
|
defer?: (fn: () => void) => void;
|
|
55
|
+
/**
|
|
56
|
+
* OPTIONAL per-request hook (outbound-key-policy). Called synchronously after
|
|
57
|
+
* cost is computed for each recorded request that carries an `apiKeyId`, so a
|
|
58
|
+
* host can keep a live per-key spend aggregate WITHOUT re-scanning the store.
|
|
59
|
+
* Absent ⇒ no-op (byte-identical for hosts/tests that do not wire it).
|
|
60
|
+
*/
|
|
61
|
+
onRecord?: (apiKeyId: string, costUsd: number, now: number) => void;
|
|
46
62
|
}
|
|
47
63
|
declare class UsageRecorder {
|
|
48
64
|
private store;
|
|
49
65
|
private pricing;
|
|
50
66
|
private logger;
|
|
51
67
|
private defer;
|
|
68
|
+
private onRecord?;
|
|
52
69
|
constructor(store: UsageEventStore, pricing: PricingEngine, logger: Logger, options?: UsageRecorderOptions);
|
|
53
70
|
/**
|
|
54
71
|
* Record one LLM request. Returns immediately — the actual store insert is
|
|
@@ -65,6 +82,7 @@ declare class UsageRecorder {
|
|
|
65
82
|
getTotals(range: UsageDateRange): Promise<UsageTotals>;
|
|
66
83
|
getByModel(range: UsageDateRange): Promise<ModelUsageRow[]>;
|
|
67
84
|
getByApiKey(range: UsageDateRange): Promise<ApiKeyUsageRow[]>;
|
|
85
|
+
getTimeSeries(range: UsageDateRange, bucket: UsageTimeBucket): Promise<UsageTimeSeriesBucket[]>;
|
|
68
86
|
getMessagesForSession(sessionId: string): Promise<MessageUsageRow[]>;
|
|
69
87
|
/** Cumulative cache hit/miss stats for one session. */
|
|
70
88
|
getSessionCacheStats(sessionId: string): Promise<SessionCacheStats>;
|
package/dist/usage.cjs
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
var _chunkYMFAJFQTcjs = require('./chunk-YMFAJFQT.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkSNYBEXLBcjs = require('./chunk-SNYBEXLB.cjs');
|
|
8
|
+
require('./chunk-XSVNC2UD.cjs');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
exports.PricingEngine = _chunkYMFAJFQTcjs.PricingEngine; exports.UsageRecorder =
|
|
12
|
+
exports.PricingEngine = _chunkYMFAJFQTcjs.PricingEngine; exports.UsageRecorder = _chunkSNYBEXLBcjs.UsageRecorder;
|
package/dist/usage.js
CHANGED
package/package.json
CHANGED
|
@@ -1,62 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@omnicross/core",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Omnicross LLM serving core
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Sayo (https://github.com/Dumoedss)",
|
|
7
|
-
"homepage": "https://github.com/Dumoedss/omnicross#readme",
|
|
8
|
-
"keywords": [
|
|
9
|
-
"omnicross",
|
|
10
|
-
"llm",
|
|
11
|
-
"openai",
|
|
12
|
-
"anthropic",
|
|
13
|
-
"gemini",
|
|
14
|
-
"proxy",
|
|
15
|
-
"router",
|
|
16
|
-
"completion",
|
|
17
|
-
"transformer"
|
|
18
|
-
],
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/Dumoedss/omnicross.git",
|
|
22
|
-
"directory": "packages/core"
|
|
23
|
-
},
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"access": "public"
|
|
26
|
-
},
|
|
27
|
-
"engines": {
|
|
28
|
-
"node": ">=20"
|
|
29
|
-
},
|
|
30
|
-
"type": "module",
|
|
31
|
-
"main": "dist/index.cjs",
|
|
32
|
-
"module": "dist/index.js",
|
|
33
|
-
"types": "dist/index.d.ts",
|
|
34
|
-
"exports": {
|
|
35
|
-
".": {
|
|
36
|
-
"types": "./dist/index.d.ts",
|
|
37
|
-
"import": "./dist/index.js",
|
|
38
|
-
"require": "./dist/index.cjs"
|
|
39
|
-
},
|
|
40
|
-
"./*": {
|
|
41
|
-
"types": "./dist/*.d.ts",
|
|
42
|
-
"import": "./dist/*.js",
|
|
43
|
-
"require": "./dist/*.cjs"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"files": [
|
|
47
|
-
"dist",
|
|
48
|
-
"LICENSE",
|
|
49
|
-
"NOTICE",
|
|
50
|
-
"README.md"
|
|
51
|
-
],
|
|
52
|
-
"scripts": {
|
|
53
|
-
"build": "tsup",
|
|
54
|
-
"typecheck": "tsc -p tsconfig.typecheck.json --noEmit"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@mozilla/readability": "^0.6.0",
|
|
58
|
-
"@omnicross/contracts": "^0.1.0",
|
|
59
|
-
"jsdom": "^24.1.3",
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@omnicross/core",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Omnicross LLM serving core 鈥?provider dispatch, completion pipeline, transformers, and the provider proxy.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Sayo (https://github.com/Dumoedss)",
|
|
7
|
+
"homepage": "https://github.com/Dumoedss/omnicross#readme",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"omnicross",
|
|
10
|
+
"llm",
|
|
11
|
+
"openai",
|
|
12
|
+
"anthropic",
|
|
13
|
+
"gemini",
|
|
14
|
+
"proxy",
|
|
15
|
+
"router",
|
|
16
|
+
"completion",
|
|
17
|
+
"transformer"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/Dumoedss/omnicross.git",
|
|
22
|
+
"directory": "packages/core"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "dist/index.cjs",
|
|
32
|
+
"module": "dist/index.js",
|
|
33
|
+
"types": "dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"require": "./dist/index.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./*": {
|
|
41
|
+
"types": "./dist/*.d.ts",
|
|
42
|
+
"import": "./dist/*.js",
|
|
43
|
+
"require": "./dist/*.cjs"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"LICENSE",
|
|
49
|
+
"NOTICE",
|
|
50
|
+
"README.md"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"typecheck": "tsc -p tsconfig.typecheck.json --noEmit"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@mozilla/readability": "^0.6.0",
|
|
58
|
+
"@omnicross/contracts": "^0.1.0",
|
|
59
|
+
"jsdom": "^24.1.3",
|
|
60
|
+
"socks": "^2.8.3",
|
|
61
|
+
"turndown": "^7.2.2",
|
|
62
|
+
"undici": "^6.21.1"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/chunk-3MEACFK3.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getSubscriptionRegistryForOutbound
|
|
3
|
-
} from "./chunk-AQ5TNQB7.js";
|
|
4
|
-
|
|
5
|
-
// src/outbound-api/subscriptionSupport.ts
|
|
6
|
-
var SUBSCRIPTION_PROVIDER_IDS = [
|
|
7
|
-
"claude",
|
|
8
|
-
"codex",
|
|
9
|
-
"gemini",
|
|
10
|
-
"opencodego"
|
|
11
|
-
];
|
|
12
|
-
var SUBSCRIPTION_ID_SET = new Set(SUBSCRIPTION_PROVIDER_IDS);
|
|
13
|
-
function isSubscriptionProviderId(providerId) {
|
|
14
|
-
if (SUBSCRIPTION_ID_SET.has(providerId)) return true;
|
|
15
|
-
const registry = getSubscriptionRegistryForOutbound();
|
|
16
|
-
return registry?.getProfile(providerId) != null;
|
|
17
|
-
}
|
|
18
|
-
var SUBSCRIPTION_SUPPORTED_ENDPOINTS = /* @__PURE__ */ new Set([
|
|
19
|
-
"messages",
|
|
20
|
-
"responses"
|
|
21
|
-
]);
|
|
22
|
-
function endpointSupportsSubscription(endpoint) {
|
|
23
|
-
return SUBSCRIPTION_SUPPORTED_ENDPOINTS.has(endpoint);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/outbound-api/routeResolver.ts
|
|
27
|
-
function parseModelRef(ref) {
|
|
28
|
-
if (!ref) return null;
|
|
29
|
-
const idx = ref.indexOf(",");
|
|
30
|
-
if (idx <= 0) return null;
|
|
31
|
-
const providerId = ref.slice(0, idx).trim();
|
|
32
|
-
const modelId = ref.slice(idx + 1).trim();
|
|
33
|
-
if (!providerId || !modelId) return null;
|
|
34
|
-
return { providerId, modelId };
|
|
35
|
-
}
|
|
36
|
-
function pickModelRefForRole(config, role) {
|
|
37
|
-
if (role === "vision") {
|
|
38
|
-
if (config.visionModel && config.visionModel.trim()) {
|
|
39
|
-
return { ref: config.visionModel, effectiveRole: "vision" };
|
|
40
|
-
}
|
|
41
|
-
return { ref: config.defaultModel, effectiveRole: "default" };
|
|
42
|
-
}
|
|
43
|
-
if (role === "background") {
|
|
44
|
-
return { ref: config.backgroundModel, effectiveRole: "background" };
|
|
45
|
-
}
|
|
46
|
-
return { ref: config.defaultModel, effectiveRole: "default" };
|
|
47
|
-
}
|
|
48
|
-
async function resolveRoute(args) {
|
|
49
|
-
const { config, role, ingressFormat, llmConfig } = args;
|
|
50
|
-
const sessionId = args.sessionId ?? null;
|
|
51
|
-
const { ref, effectiveRole } = pickModelRefForRole(config, role);
|
|
52
|
-
if (!ref || !ref.trim()) {
|
|
53
|
-
return {
|
|
54
|
-
ok: false,
|
|
55
|
-
error: {
|
|
56
|
-
status: 503,
|
|
57
|
-
message: `endpoint '${config.endpoint}' has no ${effectiveRole} model configured`
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const parsed = parseModelRef(ref);
|
|
62
|
-
if (!parsed) {
|
|
63
|
-
return {
|
|
64
|
-
ok: false,
|
|
65
|
-
error: {
|
|
66
|
-
status: 503,
|
|
67
|
-
message: `endpoint '${config.endpoint}' ${effectiveRole} model ref is malformed: '${ref}'`
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const { providerId, modelId } = parsed;
|
|
72
|
-
const provider = await llmConfig.getProvider(providerId);
|
|
73
|
-
if (!provider) {
|
|
74
|
-
if (isSubscriptionProviderId(providerId)) {
|
|
75
|
-
return await resolveSubscriptionRoute({
|
|
76
|
-
config,
|
|
77
|
-
providerId,
|
|
78
|
-
modelId,
|
|
79
|
-
ingressFormat,
|
|
80
|
-
sessionId,
|
|
81
|
-
effectiveRole
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
ok: false,
|
|
86
|
-
error: {
|
|
87
|
-
status: 503,
|
|
88
|
-
message: `provider '${providerId}' not found for endpoint '${config.endpoint}'`
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
const isOfficialProvider = provider.isOfficial === true || provider.id === "anthropic";
|
|
93
|
-
const targetProviderFormat = isOfficialProvider ? "anthropic" : "transform";
|
|
94
|
-
let anthropicSdkHints = null;
|
|
95
|
-
if (ingressFormat === "anthropic-messages") {
|
|
96
|
-
anthropicSdkHints = {
|
|
97
|
-
apiKey: resolveApiKey(provider.api_key),
|
|
98
|
-
isOfficialProvider,
|
|
99
|
-
passThrough: false,
|
|
100
|
-
attribution: { sessionId, apiKeyId: null }
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const route = {
|
|
104
|
-
sessionId,
|
|
105
|
-
targetProviderFormat,
|
|
106
|
-
model: modelId,
|
|
107
|
-
ingressFormat,
|
|
108
|
-
authMode: "byo",
|
|
109
|
-
providerId,
|
|
110
|
-
anthropicSdkHints
|
|
111
|
-
};
|
|
112
|
-
return { ok: true, route, usedRole: effectiveRole };
|
|
113
|
-
}
|
|
114
|
-
async function resolveSubscriptionRoute(args) {
|
|
115
|
-
const { config, providerId, modelId, ingressFormat, sessionId, effectiveRole } = args;
|
|
116
|
-
if (!config.useSubscription) {
|
|
117
|
-
return {
|
|
118
|
-
ok: false,
|
|
119
|
-
error: {
|
|
120
|
-
status: 503,
|
|
121
|
-
message: `subscription routing disabled for endpoint '${config.endpoint}'`
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
if (!endpointSupportsSubscription(config.endpoint)) {
|
|
126
|
-
return {
|
|
127
|
-
ok: false,
|
|
128
|
-
error: {
|
|
129
|
-
status: 503,
|
|
130
|
-
message: `subscription routing is not supported on the '${config.endpoint}' endpoint; use a BYO API-key provider, or the /v1/messages or /v1/responses endpoint`
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const registry = getSubscriptionRegistryForOutbound();
|
|
135
|
-
const profile = registry?.getProfile(providerId) ?? null;
|
|
136
|
-
if (!profile) {
|
|
137
|
-
return {
|
|
138
|
-
ok: false,
|
|
139
|
-
error: {
|
|
140
|
-
status: 503,
|
|
141
|
-
message: `subscription provider '${providerId}' is not available`
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
const hints = {
|
|
146
|
-
apiKey: "",
|
|
147
|
-
isOfficialProvider: false,
|
|
148
|
-
passThrough: false,
|
|
149
|
-
subscriptionProfile: profile,
|
|
150
|
-
attribution: { sessionId, apiKeyId: null }
|
|
151
|
-
};
|
|
152
|
-
const subscriptionConfig = providerId === "opencodego" ? await registry?.getOpenCodeGoConfig?.() : void 0;
|
|
153
|
-
const route = {
|
|
154
|
-
sessionId,
|
|
155
|
-
targetProviderFormat: "transform",
|
|
156
|
-
model: modelId,
|
|
157
|
-
ingressFormat,
|
|
158
|
-
authMode: "subscription",
|
|
159
|
-
providerId,
|
|
160
|
-
// Anthropic delegation carries the dispatch profile inside
|
|
161
|
-
// `anthropicSdkHints.subscriptionProfile`. The Responses ingress reads the
|
|
162
|
-
// TOP-LEVEL `route.subscriptionProfile`, and so does the built-in
|
|
163
|
-
// (factory-absent) `/v1/messages` subscription path (RT2.1) — the registry's
|
|
164
|
-
// `SubscriptionDispatchProfile` structurally satisfies `SubscriptionAuthProfile`
|
|
165
|
-
// ({ authStrategy, resolveUpstreamUrl, providerTransformerNames }), so set it
|
|
166
|
-
// for BOTH. This is INERT when an Anthropic ingress factory is present: that
|
|
167
|
-
// delegation reads the hint-bundle field above (and uses a different
|
|
168
|
-
// route-minting path), never the top-level field. (chat/gemini never reach
|
|
169
|
-
// here — Gate 2 rejected them.)
|
|
170
|
-
subscriptionProfile: ingressFormat === "openai-responses" || ingressFormat === "anthropic-messages" ? profile : void 0,
|
|
171
|
-
// Opaque per-account config (opencodego-only; `undefined` otherwise). Read by
|
|
172
|
-
// the built-in `/v1/messages` plan builder; INERT for the factory-present
|
|
173
|
-
// delegation path + non-opencodego.
|
|
174
|
-
subscriptionConfig,
|
|
175
|
-
anthropicSdkHints: hints
|
|
176
|
-
};
|
|
177
|
-
return { ok: true, route, usedRole: effectiveRole };
|
|
178
|
-
}
|
|
179
|
-
function resolveApiKey(apiKey) {
|
|
180
|
-
if (!apiKey) return "";
|
|
181
|
-
if (apiKey.startsWith("$")) {
|
|
182
|
-
return process.env[apiKey.slice(1)] || "";
|
|
183
|
-
}
|
|
184
|
-
return apiKey;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export {
|
|
188
|
-
SUBSCRIPTION_PROVIDER_IDS,
|
|
189
|
-
isSubscriptionProviderId,
|
|
190
|
-
endpointSupportsSubscription,
|
|
191
|
-
parseModelRef,
|
|
192
|
-
resolveRoute
|
|
193
|
-
};
|
package/dist/chunk-6VIXXLMX.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/openrouter.ts
|
|
2
|
-
function isOpenRouterProvider(provider) {
|
|
3
|
-
const baseUrl = (provider.api_base_url || "").toLowerCase();
|
|
4
|
-
return baseUrl.includes("openrouter.ai");
|
|
5
|
-
}
|
|
6
|
-
var OPENROUTER_APP_HEADERS = {
|
|
7
|
-
"HTTP-Referer": "https://omnicross.dev",
|
|
8
|
-
"X-Title": "omnicross"
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.isOpenRouterProvider = isOpenRouterProvider; exports.OPENROUTER_APP_HEADERS = OPENROUTER_APP_HEADERS;
|
package/dist/chunk-E3WHL7CO.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/openrouter.ts
|
|
2
|
-
function isOpenRouterProvider(provider) {
|
|
3
|
-
const baseUrl = (provider.api_base_url || "").toLowerCase();
|
|
4
|
-
return baseUrl.includes("openrouter.ai");
|
|
5
|
-
}
|
|
6
|
-
var OPENROUTER_APP_HEADERS = {
|
|
7
|
-
"HTTP-Referer": "https://omnicross.dev",
|
|
8
|
-
"X-Title": "omnicross"
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
isOpenRouterProvider,
|
|
13
|
-
OPENROUTER_APP_HEADERS
|
|
14
|
-
};
|