@omnicross/core 0.1.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.
- package/LICENSE +21 -0
- package/NOTICE +57 -0
- package/README.md +15 -0
- package/dist/ApiKeyPoolService-BmMkau07.d.cts +170 -0
- package/dist/ApiKeyPoolService-BmMkau07.d.ts +170 -0
- package/dist/ProviderProxy-f_8ziIhW.d.cts +120 -0
- package/dist/ProviderProxy-vjt8sQQk.d.ts +120 -0
- package/dist/SubscriptionAuthSource-Cr4fVEYY.d.cts +264 -0
- package/dist/SubscriptionAuthSource-D89zmiSS.d.ts +264 -0
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +218 -0
- package/dist/auth/GeminiCodeAssistProjectResolver.d.cts +68 -0
- package/dist/auth/GeminiCodeAssistProjectResolver.d.ts +68 -0
- package/dist/auth/GeminiCodeAssistProjectResolver.js +189 -0
- package/dist/completion/ApiKeyPoolService.cjs +331 -0
- package/dist/completion/ApiKeyPoolService.d.cts +2 -0
- package/dist/completion/ApiKeyPoolService.d.ts +2 -0
- package/dist/completion/ApiKeyPoolService.js +306 -0
- package/dist/completion.cjs +4027 -0
- package/dist/completion.d.cts +17 -0
- package/dist/completion.d.ts +17 -0
- package/dist/completion.js +3983 -0
- package/dist/index-BTSmc9Sm.d.ts +645 -0
- package/dist/index-DXazdTzZ.d.cts +645 -0
- package/dist/index.cjs +10428 -0
- package/dist/index.d.cts +128 -0
- package/dist/index.d.ts +128 -0
- package/dist/index.js +10339 -0
- package/dist/outbound-api/subscriptionRegistryPort.cjs +38 -0
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +73 -0
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +73 -0
- package/dist/outbound-api/subscriptionRegistryPort.js +12 -0
- package/dist/outbound-api.cjs +5264 -0
- package/dist/outbound-api.d.cts +320 -0
- package/dist/outbound-api.d.ts +320 -0
- package/dist/outbound-api.js +5218 -0
- package/dist/pipeline/SubscriptionAuthSource.cjs +131 -0
- package/dist/pipeline/SubscriptionAuthSource.d.cts +3 -0
- package/dist/pipeline/SubscriptionAuthSource.d.ts +3 -0
- package/dist/pipeline/SubscriptionAuthSource.js +103 -0
- package/dist/pipeline/SubscriptionAuthStrategy.cjs +18 -0
- package/dist/pipeline/SubscriptionAuthStrategy.d.cts +61 -0
- package/dist/pipeline/SubscriptionAuthStrategy.d.ts +61 -0
- package/dist/pipeline/SubscriptionAuthStrategy.js +0 -0
- package/dist/ports/gemini-code-assist-resolver.cjs +38 -0
- package/dist/ports/gemini-code-assist-resolver.d.cts +26 -0
- package/dist/ports/gemini-code-assist-resolver.d.ts +26 -0
- package/dist/ports/gemini-code-assist-resolver.js +12 -0
- package/dist/ports.cjs +18 -0
- package/dist/ports.d.cts +15 -0
- package/dist/ports.d.ts +15 -0
- package/dist/ports.js +0 -0
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +2958 -0
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +77 -0
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +77 -0
- package/dist/provider-proxy/ingress/providerProxyShared.js +2925 -0
- package/dist/provider-proxy/matchText.cjs +73 -0
- package/dist/provider-proxy/matchText.d.cts +47 -0
- package/dist/provider-proxy/matchText.d.ts +47 -0
- package/dist/provider-proxy/matchText.js +45 -0
- package/dist/provider-proxy/types.cjs +18 -0
- package/dist/provider-proxy/types.d.cts +12 -0
- package/dist/provider-proxy/types.d.ts +12 -0
- package/dist/provider-proxy/types.js +0 -0
- package/dist/provider-proxy.cjs +4667 -0
- package/dist/provider-proxy.d.cts +69 -0
- package/dist/provider-proxy.d.ts +69 -0
- package/dist/provider-proxy.js +4636 -0
- package/dist/serializeError.cjs +82 -0
- package/dist/serializeError.d.cts +24 -0
- package/dist/serializeError.d.ts +24 -0
- package/dist/serializeError.js +57 -0
- package/dist/sse-parser.cjs +456 -0
- package/dist/sse-parser.d.cts +143 -0
- package/dist/sse-parser.d.ts +143 -0
- package/dist/sse-parser.js +430 -0
- package/dist/transformer/TransformerChainExecutor.cjs +321 -0
- package/dist/transformer/TransformerChainExecutor.d.cts +104 -0
- package/dist/transformer/TransformerChainExecutor.d.ts +104 -0
- package/dist/transformer/TransformerChainExecutor.js +294 -0
- package/dist/transformer/TransformerService.cjs +290 -0
- package/dist/transformer/TransformerService.d.cts +138 -0
- package/dist/transformer/TransformerService.d.ts +138 -0
- package/dist/transformer/TransformerService.js +265 -0
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +1115 -0
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.cts +102 -0
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.ts +102 -0
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +1085 -0
- package/dist/transformer/transformers/GeminiTransformer.cjs +1013 -0
- package/dist/transformer/transformers/GeminiTransformer.d.cts +70 -0
- package/dist/transformer/transformers/GeminiTransformer.d.ts +70 -0
- package/dist/transformer/transformers/GeminiTransformer.js +986 -0
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +538 -0
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +53 -0
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +53 -0
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +513 -0
- package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +73 -0
- package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +51 -0
- package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +51 -0
- package/dist/transformer/transformers/OpenCodeGoTransformer.js +48 -0
- package/dist/transformer/types.cjs +18 -0
- package/dist/transformer/types.d.cts +405 -0
- package/dist/transformer/types.d.ts +405 -0
- package/dist/transformer/types.js +0 -0
- package/dist/transformer.cjs +3736 -0
- package/dist/transformer.d.cts +33 -0
- package/dist/transformer.d.ts +33 -0
- package/dist/transformer.js +3712 -0
- package/dist/types-CGGrKqC_.d.cts +142 -0
- package/dist/types-CbCN2NQP.d.ts +142 -0
- package/dist/types-DCzHkhJt.d.ts +467 -0
- package/dist/types-DZIQbgp0.d.cts +467 -0
- package/dist/usage-event-sink-BX7FE1NL.d.cts +59 -0
- package/dist/usage-event-sink-BX7FE1NL.d.ts +59 -0
- package/package.json +62 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { LLMProvider } from '@omnicross/contracts/llm-config';
|
|
3
|
+
import { TransformerChainExecutor } from '../../transformer/TransformerChainExecutor.cjs';
|
|
4
|
+
import { Transformer } from '../../transformer/types.cjs';
|
|
5
|
+
import { a as ProviderProxyDeps } from '../../types-DZIQbgp0.cjs';
|
|
6
|
+
import '@omnicross/contracts/completion-types';
|
|
7
|
+
import '@omnicross/contracts/subscription-types';
|
|
8
|
+
import '@omnicross/contracts/usage-types';
|
|
9
|
+
import '../../ApiKeyPoolService-BmMkau07.cjs';
|
|
10
|
+
import '../../SubscriptionAuthSource-Cr4fVEYY.cjs';
|
|
11
|
+
import '../../pipeline/SubscriptionAuthStrategy.cjs';
|
|
12
|
+
import '../../transformer/TransformerService.cjs';
|
|
13
|
+
import '@omnicross/contracts/websearch-types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Shared helpers for the ProviderProxy ingress parsers.
|
|
17
|
+
*
|
|
18
|
+
* All ingress parsers (Anthropic Messages, OpenAI Responses, OpenAI Chat,
|
|
19
|
+
* Gemini generateContent) read the full request body, share one stateless
|
|
20
|
+
* `TransformerChainExecutor`, and relay an already-wire-shaped `Response` (JSON
|
|
21
|
+
* or SSE) back to the http `res`. This module owns ONLY that common plumbing so
|
|
22
|
+
* each parser stays under the size cap and the relay shape is identical across
|
|
23
|
+
* ingresses (parity with the host's codex relay / stream manager). It also
|
|
24
|
+
* vends the lazy-singleton endpoint transformers
|
|
25
|
+
* (Responses, Gemini, Anthropic) the factory-less BYO paths reuse.
|
|
26
|
+
*
|
|
27
|
+
* @module provider-proxy/ingress/providerProxyShared
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
declare function getSharedExecutor(): TransformerChainExecutor;
|
|
31
|
+
declare function getResponsesEndpointTransformer(): Transformer;
|
|
32
|
+
declare function getAnthropicEndpointTransformer(): Transformer;
|
|
33
|
+
declare function getGeminiEndpointTransformer(): Transformer;
|
|
34
|
+
/** Read the full request body from an IncomingMessage. */
|
|
35
|
+
declare function readBody(req: http.IncomingMessage): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Relay an already-wire-shaped `Response` to the http `res`.
|
|
38
|
+
* - `text/event-stream` (or `isStream`): pipe the ReadableStream chunk-by-chunk.
|
|
39
|
+
* - else: read the JSON text and write it once, returning it so the caller can
|
|
40
|
+
* tap usage. Mirrors the host's codex relay.
|
|
41
|
+
*
|
|
42
|
+
* @returns the JSON body text for non-stream responses, else `null`.
|
|
43
|
+
*/
|
|
44
|
+
declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean): Promise<string | null>;
|
|
45
|
+
/** Write a JSON error response if the headers have not been sent. */
|
|
46
|
+
declare function writeError(res: http.ServerResponse, status: number, message: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve the FIRST-CHOICE BYO request key for a `buildByoPlan`, threading the
|
|
49
|
+
* ApiKeyPool through TWO gates so 429/529/401/403 failover actually fires on the
|
|
50
|
+
* outbound serving path (omnicross-daemon-parity-poolseam, design D2(b)).
|
|
51
|
+
*
|
|
52
|
+
* MIRRORS the host engine adapter's `resolveApiKeyForProvider` (the reference impl whose
|
|
53
|
+
* pool failover already works internally):
|
|
54
|
+
* - pool present AND a (synthesized outbound) sessionId present →
|
|
55
|
+
* `getKeyForSession(providerId, sessionId)`. This SEEDS `sessionBindings`
|
|
56
|
+
* with the chosen key AND returns that same key, so it becomes the first
|
|
57
|
+
* request's key. WHY both gates matter: `LlmConfigProviderAuth.onResult`
|
|
58
|
+
* short-circuits on a null sessionId (gate 1); even with a sessionId,
|
|
59
|
+
* `ApiKeyPoolService.reportError` short-circuits when there is no binding for
|
|
60
|
+
* that session (gate 2) — and the binding only exists once `getKeyForSession`
|
|
61
|
+
* has run. The first request MUST use the bound key (not the row's `apiKey`)
|
|
62
|
+
* so the key the pool cools/rebinds on error === the key actually used.
|
|
63
|
+
* - otherwise (pool null, no sessionId, or the pool returns empty) → fall back
|
|
64
|
+
* to `resolveProviderEndpoint(provider).apiKey` with the same `$ENV`
|
|
65
|
+
* resolution the ingresses' own `resolveApiKey` used → BYTE-IDENTICAL to the
|
|
66
|
+
* pre-seam path. (Single-key pools also short-circuit inside
|
|
67
|
+
* `getKeyForSession` → `selectWeightedRoundRobin`'s `length===1`, returning
|
|
68
|
+
* the one key, so the wire key is unchanged there too.)
|
|
69
|
+
*
|
|
70
|
+
* `$ENV` semantics MUST match the ingresses' original `resolveApiKey`
|
|
71
|
+
* (`$VAR → process.env[VAR] ?? ''`, else literal). The pool returns an
|
|
72
|
+
* already-`resolveKey`-resolved string (its loader passes the host resolver),
|
|
73
|
+
* so the pool branch needs no further `$ENV` expansion.
|
|
74
|
+
*/
|
|
75
|
+
declare function resolvePoolBoundKey(deps: ProviderProxyDeps, providerId: string, provider: LLMProvider, sessionId: string | null): Promise<string>;
|
|
76
|
+
|
|
77
|
+
export { getAnthropicEndpointTransformer, getGeminiEndpointTransformer, getResponsesEndpointTransformer, getSharedExecutor, readBody, relayResponse, resolvePoolBoundKey, writeError };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { LLMProvider } from '@omnicross/contracts/llm-config';
|
|
3
|
+
import { TransformerChainExecutor } from '../../transformer/TransformerChainExecutor.js';
|
|
4
|
+
import { Transformer } from '../../transformer/types.js';
|
|
5
|
+
import { a as ProviderProxyDeps } from '../../types-DCzHkhJt.js';
|
|
6
|
+
import '@omnicross/contracts/completion-types';
|
|
7
|
+
import '@omnicross/contracts/subscription-types';
|
|
8
|
+
import '@omnicross/contracts/usage-types';
|
|
9
|
+
import '../../ApiKeyPoolService-BmMkau07.js';
|
|
10
|
+
import '../../SubscriptionAuthSource-D89zmiSS.js';
|
|
11
|
+
import '../../pipeline/SubscriptionAuthStrategy.js';
|
|
12
|
+
import '../../transformer/TransformerService.js';
|
|
13
|
+
import '@omnicross/contracts/websearch-types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Shared helpers for the ProviderProxy ingress parsers.
|
|
17
|
+
*
|
|
18
|
+
* All ingress parsers (Anthropic Messages, OpenAI Responses, OpenAI Chat,
|
|
19
|
+
* Gemini generateContent) read the full request body, share one stateless
|
|
20
|
+
* `TransformerChainExecutor`, and relay an already-wire-shaped `Response` (JSON
|
|
21
|
+
* or SSE) back to the http `res`. This module owns ONLY that common plumbing so
|
|
22
|
+
* each parser stays under the size cap and the relay shape is identical across
|
|
23
|
+
* ingresses (parity with the host's codex relay / stream manager). It also
|
|
24
|
+
* vends the lazy-singleton endpoint transformers
|
|
25
|
+
* (Responses, Gemini, Anthropic) the factory-less BYO paths reuse.
|
|
26
|
+
*
|
|
27
|
+
* @module provider-proxy/ingress/providerProxyShared
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
declare function getSharedExecutor(): TransformerChainExecutor;
|
|
31
|
+
declare function getResponsesEndpointTransformer(): Transformer;
|
|
32
|
+
declare function getAnthropicEndpointTransformer(): Transformer;
|
|
33
|
+
declare function getGeminiEndpointTransformer(): Transformer;
|
|
34
|
+
/** Read the full request body from an IncomingMessage. */
|
|
35
|
+
declare function readBody(req: http.IncomingMessage): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Relay an already-wire-shaped `Response` to the http `res`.
|
|
38
|
+
* - `text/event-stream` (or `isStream`): pipe the ReadableStream chunk-by-chunk.
|
|
39
|
+
* - else: read the JSON text and write it once, returning it so the caller can
|
|
40
|
+
* tap usage. Mirrors the host's codex relay.
|
|
41
|
+
*
|
|
42
|
+
* @returns the JSON body text for non-stream responses, else `null`.
|
|
43
|
+
*/
|
|
44
|
+
declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean): Promise<string | null>;
|
|
45
|
+
/** Write a JSON error response if the headers have not been sent. */
|
|
46
|
+
declare function writeError(res: http.ServerResponse, status: number, message: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve the FIRST-CHOICE BYO request key for a `buildByoPlan`, threading the
|
|
49
|
+
* ApiKeyPool through TWO gates so 429/529/401/403 failover actually fires on the
|
|
50
|
+
* outbound serving path (omnicross-daemon-parity-poolseam, design D2(b)).
|
|
51
|
+
*
|
|
52
|
+
* MIRRORS the host engine adapter's `resolveApiKeyForProvider` (the reference impl whose
|
|
53
|
+
* pool failover already works internally):
|
|
54
|
+
* - pool present AND a (synthesized outbound) sessionId present →
|
|
55
|
+
* `getKeyForSession(providerId, sessionId)`. This SEEDS `sessionBindings`
|
|
56
|
+
* with the chosen key AND returns that same key, so it becomes the first
|
|
57
|
+
* request's key. WHY both gates matter: `LlmConfigProviderAuth.onResult`
|
|
58
|
+
* short-circuits on a null sessionId (gate 1); even with a sessionId,
|
|
59
|
+
* `ApiKeyPoolService.reportError` short-circuits when there is no binding for
|
|
60
|
+
* that session (gate 2) — and the binding only exists once `getKeyForSession`
|
|
61
|
+
* has run. The first request MUST use the bound key (not the row's `apiKey`)
|
|
62
|
+
* so the key the pool cools/rebinds on error === the key actually used.
|
|
63
|
+
* - otherwise (pool null, no sessionId, or the pool returns empty) → fall back
|
|
64
|
+
* to `resolveProviderEndpoint(provider).apiKey` with the same `$ENV`
|
|
65
|
+
* resolution the ingresses' own `resolveApiKey` used → BYTE-IDENTICAL to the
|
|
66
|
+
* pre-seam path. (Single-key pools also short-circuit inside
|
|
67
|
+
* `getKeyForSession` → `selectWeightedRoundRobin`'s `length===1`, returning
|
|
68
|
+
* the one key, so the wire key is unchanged there too.)
|
|
69
|
+
*
|
|
70
|
+
* `$ENV` semantics MUST match the ingresses' original `resolveApiKey`
|
|
71
|
+
* (`$VAR → process.env[VAR] ?? ''`, else literal). The pool returns an
|
|
72
|
+
* already-`resolveKey`-resolved string (its loader passes the host resolver),
|
|
73
|
+
* so the pool branch needs no further `$ENV` expansion.
|
|
74
|
+
*/
|
|
75
|
+
declare function resolvePoolBoundKey(deps: ProviderProxyDeps, providerId: string, provider: LLMProvider, sessionId: string | null): Promise<string>;
|
|
76
|
+
|
|
77
|
+
export { getAnthropicEndpointTransformer, getGeminiEndpointTransformer, getResponsesEndpointTransformer, getSharedExecutor, readBody, relayResponse, resolvePoolBoundKey, writeError };
|