@omnicross/core 0.1.0 → 0.1.1
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/dist/ApiConverter.cjs +799 -0
- package/dist/ApiConverter.d.cts +82 -0
- package/dist/ApiConverter.d.ts +82 -0
- package/dist/ApiConverter.js +763 -0
- package/dist/BuiltinToolExecutor-BluWyeob.d.ts +81 -0
- package/dist/BuiltinToolExecutor-CS2WpXhM.d.cts +81 -0
- package/dist/CompletionService-7fCmKAP3.d.ts +212 -0
- package/dist/CompletionService-DtOF_War.d.cts +212 -0
- package/dist/{ProviderProxy-f_8ziIhW.d.cts → ProviderProxy-C-xqrkKi.d.ts} +7 -2
- package/dist/{ProviderProxy-vjt8sQQk.d.ts → ProviderProxy-CnMQYN59.d.cts} +7 -2
- package/dist/completion/BuiltinToolExecutor.cjs +327 -0
- package/dist/completion/BuiltinToolExecutor.d.cts +4 -0
- package/dist/completion/BuiltinToolExecutor.d.ts +4 -0
- package/dist/completion/BuiltinToolExecutor.js +296 -0
- package/dist/completion/CompletionService.cjs +3487 -0
- package/dist/completion/CompletionService.d.cts +21 -0
- package/dist/completion/CompletionService.d.ts +21 -0
- package/dist/completion/CompletionService.js +3461 -0
- package/dist/completion/NativeSearchInjector.cjs +196 -0
- package/dist/completion/NativeSearchInjector.d.cts +42 -0
- package/dist/completion/NativeSearchInjector.d.ts +42 -0
- package/dist/completion/NativeSearchInjector.js +167 -0
- package/dist/completion/ProviderSearchInjector.cjs +87 -0
- package/dist/completion/ProviderSearchInjector.d.cts +47 -0
- package/dist/completion/ProviderSearchInjector.d.ts +47 -0
- package/dist/completion/ProviderSearchInjector.js +60 -0
- package/dist/completion/native-search-types.cjs +67 -0
- package/dist/completion/native-search-types.d.cts +3 -0
- package/dist/completion/native-search-types.d.ts +3 -0
- package/dist/completion/native-search-types.js +38 -0
- package/dist/completion/openrouter-headers.cjs +72 -0
- package/dist/completion/openrouter-headers.d.cts +44 -0
- package/dist/completion/openrouter-headers.d.ts +44 -0
- package/dist/completion/openrouter-headers.js +42 -0
- package/dist/completion/openrouter-models.cjs +86 -0
- package/dist/completion/openrouter-models.d.cts +27 -0
- package/dist/completion/openrouter-models.d.ts +27 -0
- package/dist/completion/openrouter-models.js +59 -0
- package/dist/completion/types.cjs +18 -0
- package/dist/completion/types.d.cts +3 -0
- package/dist/completion/types.d.ts +3 -0
- package/dist/completion/types.js +0 -0
- package/dist/completion/url-builder.cjs +138 -0
- package/dist/completion/url-builder.d.cts +87 -0
- package/dist/completion/url-builder.d.ts +87 -0
- package/dist/completion/url-builder.js +104 -0
- package/dist/completion.d.cts +148 -7
- package/dist/completion.d.ts +148 -7
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +27 -90
- package/dist/index.d.ts +27 -90
- package/dist/index.js +1 -0
- package/dist/outbound-api/routeResolver.cjs +221 -0
- package/dist/outbound-api/routeResolver.d.cts +18 -0
- package/dist/outbound-api/routeResolver.d.ts +18 -0
- package/dist/outbound-api/routeResolver.js +192 -0
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +5 -2
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +5 -2
- package/dist/outbound-api/types.cjs +18 -0
- package/dist/{types-CbCN2NQP.d.ts → outbound-api/types.d.cts} +17 -3
- package/dist/{types-CGGrKqC_.d.cts → outbound-api/types.d.ts} +17 -3
- package/dist/outbound-api/types.js +0 -0
- package/dist/outbound-api.cjs +1 -0
- package/dist/outbound-api.d.cts +14 -87
- package/dist/outbound-api.d.ts +14 -87
- package/dist/outbound-api.js +1 -0
- package/dist/pipeline/AuthSource.cjs +18 -0
- package/dist/pipeline/AuthSource.d.cts +101 -0
- package/dist/pipeline/AuthSource.d.ts +101 -0
- package/dist/pipeline/AuthSource.js +0 -0
- package/dist/pipeline/LlmConfigProviderAuth.cjs +169 -0
- package/dist/pipeline/LlmConfigProviderAuth.d.cts +86 -0
- package/dist/pipeline/LlmConfigProviderAuth.d.ts +86 -0
- package/dist/pipeline/LlmConfigProviderAuth.js +142 -0
- package/dist/pipeline/SubscriptionAuthSource.d.cts +165 -3
- package/dist/pipeline/SubscriptionAuthSource.d.ts +165 -3
- package/dist/pipeline/executeProviderCall.cjs +70 -0
- package/dist/pipeline/executeProviderCall.d.cts +149 -0
- package/dist/pipeline/executeProviderCall.d.ts +149 -0
- package/dist/pipeline/executeProviderCall.js +45 -0
- package/dist/pipeline/resolveProviderChain.cjs +47 -0
- package/dist/pipeline/resolveProviderChain.d.cts +58 -0
- package/dist/pipeline/resolveProviderChain.d.ts +58 -0
- package/dist/pipeline/resolveProviderChain.js +22 -0
- package/dist/pipeline/resolveSubscriptionChain.cjs +68 -0
- package/dist/pipeline/resolveSubscriptionChain.d.cts +68 -0
- package/dist/pipeline/resolveSubscriptionChain.d.ts +68 -0
- package/dist/pipeline/resolveSubscriptionChain.js +43 -0
- package/dist/ports/provider-config-source.cjs +18 -0
- package/dist/ports/provider-config-source.d.cts +51 -0
- package/dist/ports/provider-config-source.d.ts +51 -0
- package/dist/ports/provider-config-source.js +0 -0
- package/dist/ports/web-search-backend.cjs +18 -0
- package/dist/ports/web-search-backend.d.cts +29 -0
- package/dist/ports/web-search-backend.d.ts +29 -0
- package/dist/ports/web-search-backend.js +0 -0
- package/dist/ports.d.cts +10 -7
- package/dist/ports.d.ts +10 -7
- package/dist/provider-proxy/ProviderProxy.cjs +4643 -0
- package/dist/provider-proxy/ProviderProxy.d.cts +16 -0
- package/dist/provider-proxy/ProviderProxy.d.ts +16 -0
- package/dist/provider-proxy/ProviderProxy.js +4618 -0
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +5 -2
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +5 -2
- package/dist/provider-proxy/types.d.cts +406 -8
- package/dist/provider-proxy/types.d.ts +406 -8
- package/dist/provider-proxy.cjs +1 -0
- package/dist/provider-proxy.d.cts +8 -5
- package/dist/provider-proxy.d.ts +8 -5
- package/dist/provider-proxy.js +1 -0
- package/dist/routeResolver-BrbK6ja9.d.cts +88 -0
- package/dist/routeResolver-HE-ZO0fO.d.ts +88 -0
- package/dist/transformer/anthropicBetaInject.cjs +51 -0
- package/dist/transformer/anthropicBetaInject.d.cts +20 -0
- package/dist/transformer/anthropicBetaInject.d.ts +20 -0
- package/dist/transformer/anthropicBetaInject.js +25 -0
- package/dist/transformer/transformers/AnthropicTransformer.cjs +1017 -0
- package/dist/transformer/transformers/AnthropicTransformer.d.cts +148 -0
- package/dist/transformer/transformers/AnthropicTransformer.d.ts +148 -0
- package/dist/transformer/transformers/AnthropicTransformer.js +990 -0
- package/dist/transformer/transformers/ReasoningTransformer.cjs +273 -0
- package/dist/transformer/transformers/ReasoningTransformer.d.cts +47 -0
- package/dist/transformer/transformers/ReasoningTransformer.d.ts +47 -0
- package/dist/transformer/transformers/ReasoningTransformer.js +253 -0
- package/dist/transformer/transformers.cjs +3206 -0
- package/dist/transformer/transformers.d.cts +100 -0
- package/dist/transformer/transformers.d.ts +100 -0
- package/dist/transformer/transformers.js +3174 -0
- package/dist/transformer.d.cts +8 -31
- package/dist/transformer.d.ts +8 -31
- package/dist/types-BScIHmPr.d.cts +153 -0
- package/dist/types-BScIHmPr.d.ts +153 -0
- package/package.json +3 -3
- package/dist/SubscriptionAuthSource-Cr4fVEYY.d.cts +0 -264
- package/dist/SubscriptionAuthSource-D89zmiSS.d.ts +0 -264
- package/dist/index-BTSmc9Sm.d.ts +0 -645
- package/dist/index-DXazdTzZ.d.cts +0 -645
- package/dist/types-DCzHkhJt.d.ts +0 -467
- package/dist/types-DZIQbgp0.d.cts +0 -467
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ProviderConfigSource } from './ports/provider-config-source.js';
|
|
2
|
+
import { IngressFormat, RouteContext } from './provider-proxy/types.js';
|
|
3
|
+
import { OutboundEndpoint, EndpointRoutingConfig, RequestRole } from './outbound-api/types.js';
|
|
4
|
+
import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* subscriptionSupport — single source of truth for (a) which provider ids are
|
|
8
|
+
* subscription-backed and (b) which outbound endpoints can soundly serve a
|
|
9
|
+
* subscription route (`outbound-api-server`, design D2 + review M1/m1).
|
|
10
|
+
*
|
|
11
|
+
* The subscription-id catalog mirrors `SubscriptionProviderRegistry`'s ids; the
|
|
12
|
+
* static fast-path is backstopped at runtime by a live registry lookup (see
|
|
13
|
+
* `isSubscriptionProviderId`) so it degrades gracefully if it drifts. Both
|
|
14
|
+
* `routeResolver` and `apiServerHandlers` import from here — no duplicated set.
|
|
15
|
+
*
|
|
16
|
+
* @module outbound-api/subscriptionSupport
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The registry-aligned subscription provider ids — the outbound layer's SSOT
|
|
21
|
+
* fast-path. NOTE: `SubscriptionProviderId` is currently a `z.string()` alias,
|
|
22
|
+
* so this `readonly SubscriptionProviderId[]` typing does NOT compile-enforce
|
|
23
|
+
* alignment with the registry; drift is instead tolerated at runtime by
|
|
24
|
+
* `isSubscriptionProviderId`'s live `registry.getProfile` fallback.
|
|
25
|
+
*/
|
|
26
|
+
declare const SUBSCRIPTION_PROVIDER_IDS: readonly SubscriptionProviderId[];
|
|
27
|
+
/**
|
|
28
|
+
* True when a provider id refers to a subscription-backed provider. Checks the
|
|
29
|
+
* registry-aligned static catalog first, then falls back to a live registry
|
|
30
|
+
* lookup (so a registry addition is honored even before this list is updated).
|
|
31
|
+
*
|
|
32
|
+
* NOTE (review m2): this classifies by id string. The resolver MUST confirm the
|
|
33
|
+
* id does not resolve to a real BYO provider row before treating it as
|
|
34
|
+
* subscription-backed — see `routeResolver` (BYO rows win).
|
|
35
|
+
*/
|
|
36
|
+
declare function isSubscriptionProviderId(providerId: string): boolean;
|
|
37
|
+
/** True when the endpoint's ingress can soundly serve a subscription route. */
|
|
38
|
+
declare function endpointSupportsSubscription(endpoint: OutboundEndpoint): boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* routeResolver — turn an endpoint's `EndpointRoutingConfig` + the detected
|
|
42
|
+
* request role into a `RouteContext` for the shared `provider-proxy` dispatch
|
|
43
|
+
* (`outbound-api-server`, design D2).
|
|
44
|
+
*
|
|
45
|
+
* Steps:
|
|
46
|
+
* 1. Pick the model for the role (vision → default fallback when `visionModel`
|
|
47
|
+
* is unset; vision is optional).
|
|
48
|
+
* 2. Parse the chosen `"providerId,modelId"` ref.
|
|
49
|
+
* 3. Gate by `useSubscription`: OFF → only BYO-key providers are eligible
|
|
50
|
+
* (subscription-backed providers excluded); ON → subscription-backed
|
|
51
|
+
* providers are eligible.
|
|
52
|
+
* 4. Resolve the provider (BYO via the `ProviderConfigSource`; subscription via the
|
|
53
|
+
* subscription registry) and build the `RouteContext` exactly as the
|
|
54
|
+
* internal callers do.
|
|
55
|
+
* 5. Return a clear `503`-style error when the role's required model is unset,
|
|
56
|
+
* the provider is unavailable, or the subscription gate excludes it.
|
|
57
|
+
*
|
|
58
|
+
* @module outbound-api/routeResolver
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** A 503-style resolution failure. */
|
|
62
|
+
interface RouteResolveError {
|
|
63
|
+
status: number;
|
|
64
|
+
message: string;
|
|
65
|
+
}
|
|
66
|
+
type RouteResolveResult = {
|
|
67
|
+
ok: true;
|
|
68
|
+
route: RouteContext;
|
|
69
|
+
usedRole: RequestRole;
|
|
70
|
+
} | {
|
|
71
|
+
ok: false;
|
|
72
|
+
error: RouteResolveError;
|
|
73
|
+
};
|
|
74
|
+
/** Parse a `"providerId,modelId"` ref. Returns null on a malformed/empty ref. */
|
|
75
|
+
declare function parseModelRef(ref: string | undefined): {
|
|
76
|
+
providerId: string;
|
|
77
|
+
modelId: string;
|
|
78
|
+
} | null;
|
|
79
|
+
/** Resolve a route for one authenticated outbound request. */
|
|
80
|
+
declare function resolveRoute(args: {
|
|
81
|
+
config: EndpointRoutingConfig;
|
|
82
|
+
role: RequestRole;
|
|
83
|
+
ingressFormat: IngressFormat;
|
|
84
|
+
llmConfig: ProviderConfigSource;
|
|
85
|
+
sessionId?: string | null;
|
|
86
|
+
}): Promise<RouteResolveResult>;
|
|
87
|
+
|
|
88
|
+
export { type RouteResolveError as R, SUBSCRIPTION_PROVIDER_IDS as S, type RouteResolveResult as a, endpointSupportsSubscription as e, isSubscriptionProviderId as i, parseModelRef as p, resolveRoute as r };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/transformer/anthropicBetaInject.ts
|
|
21
|
+
var anthropicBetaInject_exports = {};
|
|
22
|
+
__export(anthropicBetaInject_exports, {
|
|
23
|
+
EXTENDED_CONTEXT_BETA: () => EXTENDED_CONTEXT_BETA,
|
|
24
|
+
injectExtendedContextBeta: () => injectExtendedContextBeta
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(anthropicBetaInject_exports);
|
|
27
|
+
var import_extended_context = require("@omnicross/contracts/extended-context");
|
|
28
|
+
var EXTENDED_CONTEXT_BETA = "context-1m-2025-08-07";
|
|
29
|
+
var ANTHROPIC_BETA_HEADER = "anthropic-beta";
|
|
30
|
+
function injectExtendedContextBeta(headers, model, useExtendedContext) {
|
|
31
|
+
if (!useExtendedContext) return;
|
|
32
|
+
if (!(0, import_extended_context.isExtendedContextCapable)(model)) return;
|
|
33
|
+
let existingValue = "";
|
|
34
|
+
for (const key of Object.keys(headers)) {
|
|
35
|
+
if (key.toLowerCase() === ANTHROPIC_BETA_HEADER) {
|
|
36
|
+
const v = headers[key];
|
|
37
|
+
if (typeof v === "string") existingValue = v;
|
|
38
|
+
if (key !== ANTHROPIC_BETA_HEADER) delete headers[key];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const parts = existingValue.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
42
|
+
if (!parts.includes(EXTENDED_CONTEXT_BETA)) {
|
|
43
|
+
parts.push(EXTENDED_CONTEXT_BETA);
|
|
44
|
+
}
|
|
45
|
+
headers[ANTHROPIC_BETA_HEADER] = parts.join(",");
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
EXTENDED_CONTEXT_BETA,
|
|
50
|
+
injectExtendedContextBeta
|
|
51
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const EXTENDED_CONTEXT_BETA = "context-1m-2025-08-07";
|
|
2
|
+
/**
|
|
3
|
+
* Idempotently merge the 1M-context beta flag into an Anthropic request's
|
|
4
|
+
* `anthropic-beta` HTTP header (comma-separated list).
|
|
5
|
+
*
|
|
6
|
+
* Mutates `headers` in place. No-op when:
|
|
7
|
+
* - `useExtendedContext` is false (user has not opted in), OR
|
|
8
|
+
* - `model` is not in the 1M-capable allowlist (defensive — guards against
|
|
9
|
+
* stale flag set on a model whose 1M variant isn't supported), OR
|
|
10
|
+
* - the flag already appears in the existing header value (re-entry safe).
|
|
11
|
+
*
|
|
12
|
+
* Header-name lookup is case-insensitive: HTTP headers are conventionally
|
|
13
|
+
* stored in different casings by different code paths (Node IncomingMessage
|
|
14
|
+
* lowercases; some libraries preserve `Anthropic-Beta`). The helper deletes
|
|
15
|
+
* any case-variant key it finds and re-emits the canonical lowercase
|
|
16
|
+
* `anthropic-beta`.
|
|
17
|
+
*/
|
|
18
|
+
declare function injectExtendedContextBeta(headers: Record<string, string>, model: string, useExtendedContext: boolean): void;
|
|
19
|
+
|
|
20
|
+
export { EXTENDED_CONTEXT_BETA, injectExtendedContextBeta };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const EXTENDED_CONTEXT_BETA = "context-1m-2025-08-07";
|
|
2
|
+
/**
|
|
3
|
+
* Idempotently merge the 1M-context beta flag into an Anthropic request's
|
|
4
|
+
* `anthropic-beta` HTTP header (comma-separated list).
|
|
5
|
+
*
|
|
6
|
+
* Mutates `headers` in place. No-op when:
|
|
7
|
+
* - `useExtendedContext` is false (user has not opted in), OR
|
|
8
|
+
* - `model` is not in the 1M-capable allowlist (defensive — guards against
|
|
9
|
+
* stale flag set on a model whose 1M variant isn't supported), OR
|
|
10
|
+
* - the flag already appears in the existing header value (re-entry safe).
|
|
11
|
+
*
|
|
12
|
+
* Header-name lookup is case-insensitive: HTTP headers are conventionally
|
|
13
|
+
* stored in different casings by different code paths (Node IncomingMessage
|
|
14
|
+
* lowercases; some libraries preserve `Anthropic-Beta`). The helper deletes
|
|
15
|
+
* any case-variant key it finds and re-emits the canonical lowercase
|
|
16
|
+
* `anthropic-beta`.
|
|
17
|
+
*/
|
|
18
|
+
declare function injectExtendedContextBeta(headers: Record<string, string>, model: string, useExtendedContext: boolean): void;
|
|
19
|
+
|
|
20
|
+
export { EXTENDED_CONTEXT_BETA, injectExtendedContextBeta };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/transformer/anthropicBetaInject.ts
|
|
2
|
+
import { isExtendedContextCapable } from "@omnicross/contracts/extended-context";
|
|
3
|
+
var EXTENDED_CONTEXT_BETA = "context-1m-2025-08-07";
|
|
4
|
+
var ANTHROPIC_BETA_HEADER = "anthropic-beta";
|
|
5
|
+
function injectExtendedContextBeta(headers, model, useExtendedContext) {
|
|
6
|
+
if (!useExtendedContext) return;
|
|
7
|
+
if (!isExtendedContextCapable(model)) return;
|
|
8
|
+
let existingValue = "";
|
|
9
|
+
for (const key of Object.keys(headers)) {
|
|
10
|
+
if (key.toLowerCase() === ANTHROPIC_BETA_HEADER) {
|
|
11
|
+
const v = headers[key];
|
|
12
|
+
if (typeof v === "string") existingValue = v;
|
|
13
|
+
if (key !== ANTHROPIC_BETA_HEADER) delete headers[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const parts = existingValue.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
17
|
+
if (!parts.includes(EXTENDED_CONTEXT_BETA)) {
|
|
18
|
+
parts.push(EXTENDED_CONTEXT_BETA);
|
|
19
|
+
}
|
|
20
|
+
headers[ANTHROPIC_BETA_HEADER] = parts.join(",");
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
EXTENDED_CONTEXT_BETA,
|
|
24
|
+
injectExtendedContextBeta
|
|
25
|
+
};
|