@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.
Files changed (139) hide show
  1. package/dist/ApiConverter.cjs +799 -0
  2. package/dist/ApiConverter.d.cts +82 -0
  3. package/dist/ApiConverter.d.ts +82 -0
  4. package/dist/ApiConverter.js +763 -0
  5. package/dist/BuiltinToolExecutor-BluWyeob.d.ts +81 -0
  6. package/dist/BuiltinToolExecutor-CS2WpXhM.d.cts +81 -0
  7. package/dist/CompletionService-7fCmKAP3.d.ts +212 -0
  8. package/dist/CompletionService-DtOF_War.d.cts +212 -0
  9. package/dist/{ProviderProxy-f_8ziIhW.d.cts → ProviderProxy-C-xqrkKi.d.ts} +7 -2
  10. package/dist/{ProviderProxy-vjt8sQQk.d.ts → ProviderProxy-CnMQYN59.d.cts} +7 -2
  11. package/dist/completion/BuiltinToolExecutor.cjs +327 -0
  12. package/dist/completion/BuiltinToolExecutor.d.cts +4 -0
  13. package/dist/completion/BuiltinToolExecutor.d.ts +4 -0
  14. package/dist/completion/BuiltinToolExecutor.js +296 -0
  15. package/dist/completion/CompletionService.cjs +3487 -0
  16. package/dist/completion/CompletionService.d.cts +21 -0
  17. package/dist/completion/CompletionService.d.ts +21 -0
  18. package/dist/completion/CompletionService.js +3461 -0
  19. package/dist/completion/NativeSearchInjector.cjs +196 -0
  20. package/dist/completion/NativeSearchInjector.d.cts +42 -0
  21. package/dist/completion/NativeSearchInjector.d.ts +42 -0
  22. package/dist/completion/NativeSearchInjector.js +167 -0
  23. package/dist/completion/ProviderSearchInjector.cjs +87 -0
  24. package/dist/completion/ProviderSearchInjector.d.cts +47 -0
  25. package/dist/completion/ProviderSearchInjector.d.ts +47 -0
  26. package/dist/completion/ProviderSearchInjector.js +60 -0
  27. package/dist/completion/native-search-types.cjs +67 -0
  28. package/dist/completion/native-search-types.d.cts +3 -0
  29. package/dist/completion/native-search-types.d.ts +3 -0
  30. package/dist/completion/native-search-types.js +38 -0
  31. package/dist/completion/openrouter-headers.cjs +72 -0
  32. package/dist/completion/openrouter-headers.d.cts +44 -0
  33. package/dist/completion/openrouter-headers.d.ts +44 -0
  34. package/dist/completion/openrouter-headers.js +42 -0
  35. package/dist/completion/openrouter-models.cjs +86 -0
  36. package/dist/completion/openrouter-models.d.cts +27 -0
  37. package/dist/completion/openrouter-models.d.ts +27 -0
  38. package/dist/completion/openrouter-models.js +59 -0
  39. package/dist/completion/types.cjs +18 -0
  40. package/dist/completion/types.d.cts +3 -0
  41. package/dist/completion/types.d.ts +3 -0
  42. package/dist/completion/types.js +0 -0
  43. package/dist/completion/url-builder.cjs +138 -0
  44. package/dist/completion/url-builder.d.cts +87 -0
  45. package/dist/completion/url-builder.d.ts +87 -0
  46. package/dist/completion/url-builder.js +104 -0
  47. package/dist/completion.d.cts +148 -7
  48. package/dist/completion.d.ts +148 -7
  49. package/dist/index.cjs +1 -0
  50. package/dist/index.d.cts +27 -90
  51. package/dist/index.d.ts +27 -90
  52. package/dist/index.js +1 -0
  53. package/dist/outbound-api/routeResolver.cjs +221 -0
  54. package/dist/outbound-api/routeResolver.d.cts +18 -0
  55. package/dist/outbound-api/routeResolver.d.ts +18 -0
  56. package/dist/outbound-api/routeResolver.js +192 -0
  57. package/dist/outbound-api/subscriptionRegistryPort.d.cts +5 -2
  58. package/dist/outbound-api/subscriptionRegistryPort.d.ts +5 -2
  59. package/dist/outbound-api/types.cjs +18 -0
  60. package/dist/{types-CbCN2NQP.d.ts → outbound-api/types.d.cts} +17 -3
  61. package/dist/{types-CGGrKqC_.d.cts → outbound-api/types.d.ts} +17 -3
  62. package/dist/outbound-api/types.js +0 -0
  63. package/dist/outbound-api.cjs +1 -0
  64. package/dist/outbound-api.d.cts +14 -87
  65. package/dist/outbound-api.d.ts +14 -87
  66. package/dist/outbound-api.js +1 -0
  67. package/dist/pipeline/AuthSource.cjs +18 -0
  68. package/dist/pipeline/AuthSource.d.cts +101 -0
  69. package/dist/pipeline/AuthSource.d.ts +101 -0
  70. package/dist/pipeline/AuthSource.js +0 -0
  71. package/dist/pipeline/LlmConfigProviderAuth.cjs +169 -0
  72. package/dist/pipeline/LlmConfigProviderAuth.d.cts +86 -0
  73. package/dist/pipeline/LlmConfigProviderAuth.d.ts +86 -0
  74. package/dist/pipeline/LlmConfigProviderAuth.js +142 -0
  75. package/dist/pipeline/SubscriptionAuthSource.d.cts +165 -3
  76. package/dist/pipeline/SubscriptionAuthSource.d.ts +165 -3
  77. package/dist/pipeline/executeProviderCall.cjs +70 -0
  78. package/dist/pipeline/executeProviderCall.d.cts +149 -0
  79. package/dist/pipeline/executeProviderCall.d.ts +149 -0
  80. package/dist/pipeline/executeProviderCall.js +45 -0
  81. package/dist/pipeline/resolveProviderChain.cjs +47 -0
  82. package/dist/pipeline/resolveProviderChain.d.cts +58 -0
  83. package/dist/pipeline/resolveProviderChain.d.ts +58 -0
  84. package/dist/pipeline/resolveProviderChain.js +22 -0
  85. package/dist/pipeline/resolveSubscriptionChain.cjs +68 -0
  86. package/dist/pipeline/resolveSubscriptionChain.d.cts +68 -0
  87. package/dist/pipeline/resolveSubscriptionChain.d.ts +68 -0
  88. package/dist/pipeline/resolveSubscriptionChain.js +43 -0
  89. package/dist/ports/provider-config-source.cjs +18 -0
  90. package/dist/ports/provider-config-source.d.cts +51 -0
  91. package/dist/ports/provider-config-source.d.ts +51 -0
  92. package/dist/ports/provider-config-source.js +0 -0
  93. package/dist/ports/web-search-backend.cjs +18 -0
  94. package/dist/ports/web-search-backend.d.cts +29 -0
  95. package/dist/ports/web-search-backend.d.ts +29 -0
  96. package/dist/ports/web-search-backend.js +0 -0
  97. package/dist/ports.d.cts +10 -7
  98. package/dist/ports.d.ts +10 -7
  99. package/dist/provider-proxy/ProviderProxy.cjs +4643 -0
  100. package/dist/provider-proxy/ProviderProxy.d.cts +16 -0
  101. package/dist/provider-proxy/ProviderProxy.d.ts +16 -0
  102. package/dist/provider-proxy/ProviderProxy.js +4618 -0
  103. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +5 -2
  104. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +5 -2
  105. package/dist/provider-proxy/types.d.cts +406 -8
  106. package/dist/provider-proxy/types.d.ts +406 -8
  107. package/dist/provider-proxy.cjs +1 -0
  108. package/dist/provider-proxy.d.cts +8 -5
  109. package/dist/provider-proxy.d.ts +8 -5
  110. package/dist/provider-proxy.js +1 -0
  111. package/dist/routeResolver-BrbK6ja9.d.cts +88 -0
  112. package/dist/routeResolver-HE-ZO0fO.d.ts +88 -0
  113. package/dist/transformer/anthropicBetaInject.cjs +51 -0
  114. package/dist/transformer/anthropicBetaInject.d.cts +20 -0
  115. package/dist/transformer/anthropicBetaInject.d.ts +20 -0
  116. package/dist/transformer/anthropicBetaInject.js +25 -0
  117. package/dist/transformer/transformers/AnthropicTransformer.cjs +1017 -0
  118. package/dist/transformer/transformers/AnthropicTransformer.d.cts +148 -0
  119. package/dist/transformer/transformers/AnthropicTransformer.d.ts +148 -0
  120. package/dist/transformer/transformers/AnthropicTransformer.js +990 -0
  121. package/dist/transformer/transformers/ReasoningTransformer.cjs +273 -0
  122. package/dist/transformer/transformers/ReasoningTransformer.d.cts +47 -0
  123. package/dist/transformer/transformers/ReasoningTransformer.d.ts +47 -0
  124. package/dist/transformer/transformers/ReasoningTransformer.js +253 -0
  125. package/dist/transformer/transformers.cjs +3206 -0
  126. package/dist/transformer/transformers.d.cts +100 -0
  127. package/dist/transformer/transformers.d.ts +100 -0
  128. package/dist/transformer/transformers.js +3174 -0
  129. package/dist/transformer.d.cts +8 -31
  130. package/dist/transformer.d.ts +8 -31
  131. package/dist/types-BScIHmPr.d.cts +153 -0
  132. package/dist/types-BScIHmPr.d.ts +153 -0
  133. package/package.json +3 -3
  134. package/dist/SubscriptionAuthSource-Cr4fVEYY.d.cts +0 -264
  135. package/dist/SubscriptionAuthSource-D89zmiSS.d.ts +0 -264
  136. package/dist/index-BTSmc9Sm.d.ts +0 -645
  137. package/dist/index-DXazdTzZ.d.cts +0 -645
  138. package/dist/types-DCzHkhJt.d.ts +0 -467
  139. package/dist/types-DZIQbgp0.d.cts +0 -467
@@ -0,0 +1,67 @@
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/completion/native-search-types.ts
21
+ var native_search_types_exports = {};
22
+ __export(native_search_types_exports, {
23
+ API_FORMAT_PROVIDER_MAP: () => API_FORMAT_PROVIDER_MAP,
24
+ NATIVE_SEARCH_EXCLUDED_MODELS: () => NATIVE_SEARCH_EXCLUDED_MODELS,
25
+ NATIVE_SEARCH_MODEL_PATTERNS: () => NATIVE_SEARCH_MODEL_PATTERNS,
26
+ NATIVE_SEARCH_TOOL_NAMES: () => NATIVE_SEARCH_TOOL_NAMES,
27
+ OPENAI_CHAT_COMPLETION_SEARCH_MODELS: () => OPENAI_CHAT_COMPLETION_SEARCH_MODELS
28
+ });
29
+ module.exports = __toCommonJS(native_search_types_exports);
30
+ var NATIVE_SEARCH_MODEL_PATTERNS = {
31
+ openai: [/^gpt-4/, /^o[134]/, /^gpt-5/],
32
+ // Claude 3.x: claude-3-opus-*, claude-3-5-sonnet-*, etc.
33
+ // Claude 4.x: claude-sonnet-4-*, claude-opus-4-*, claude-haiku-4-*, etc.
34
+ anthropic: [/^claude-/],
35
+ google: [/^gemini-(?:2|3|flash|pro)/],
36
+ xai: [/^grok/],
37
+ openrouter: []
38
+ // Detected via provider, not model pattern
39
+ };
40
+ var OPENAI_CHAT_COMPLETION_SEARCH_MODELS = [
41
+ "gpt-4o-search-preview",
42
+ "gpt-4o-mini-search-preview",
43
+ "gpt-5-search-api"
44
+ ];
45
+ var NATIVE_SEARCH_EXCLUDED_MODELS = [
46
+ "gpt-4.1-nano"
47
+ ];
48
+ var NATIVE_SEARCH_TOOL_NAMES = [
49
+ "web_search",
50
+ "web_search_20250305",
51
+ "web_search_20260209",
52
+ "google_search",
53
+ "googleSearchRetrieval"
54
+ ];
55
+ var API_FORMAT_PROVIDER_MAP = {
56
+ "openai-response": "openai",
57
+ anthropic: "anthropic",
58
+ google: "google"
59
+ };
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ API_FORMAT_PROVIDER_MAP,
63
+ NATIVE_SEARCH_EXCLUDED_MODELS,
64
+ NATIVE_SEARCH_MODEL_PATTERNS,
65
+ NATIVE_SEARCH_TOOL_NAMES,
66
+ OPENAI_CHAT_COMPLETION_SEARCH_MODELS
67
+ });
@@ -0,0 +1,3 @@
1
+ export { f as API_FORMAT_PROVIDER_MAP, g as NATIVE_SEARCH_EXCLUDED_MODELS, h as NATIVE_SEARCH_MODEL_PATTERNS, N as NATIVE_SEARCH_TOOL_NAMES, b as NativeSearchAugmentation, c as NativeSearchDetectionResult, d as NativeSearchProvider, e as NativeSearchUserConfig, O as OPENAI_CHAT_COMPLETION_SEARCH_MODELS } from '../types-BScIHmPr.cjs';
2
+ import '@omnicross/contracts/message-blocks';
3
+ import '@omnicross/contracts/completion-types';
@@ -0,0 +1,3 @@
1
+ export { f as API_FORMAT_PROVIDER_MAP, g as NATIVE_SEARCH_EXCLUDED_MODELS, h as NATIVE_SEARCH_MODEL_PATTERNS, N as NATIVE_SEARCH_TOOL_NAMES, b as NativeSearchAugmentation, c as NativeSearchDetectionResult, d as NativeSearchProvider, e as NativeSearchUserConfig, O as OPENAI_CHAT_COMPLETION_SEARCH_MODELS } from '../types-BScIHmPr.js';
2
+ import '@omnicross/contracts/message-blocks';
3
+ import '@omnicross/contracts/completion-types';
@@ -0,0 +1,38 @@
1
+ // src/completion/native-search-types.ts
2
+ var NATIVE_SEARCH_MODEL_PATTERNS = {
3
+ openai: [/^gpt-4/, /^o[134]/, /^gpt-5/],
4
+ // Claude 3.x: claude-3-opus-*, claude-3-5-sonnet-*, etc.
5
+ // Claude 4.x: claude-sonnet-4-*, claude-opus-4-*, claude-haiku-4-*, etc.
6
+ anthropic: [/^claude-/],
7
+ google: [/^gemini-(?:2|3|flash|pro)/],
8
+ xai: [/^grok/],
9
+ openrouter: []
10
+ // Detected via provider, not model pattern
11
+ };
12
+ var OPENAI_CHAT_COMPLETION_SEARCH_MODELS = [
13
+ "gpt-4o-search-preview",
14
+ "gpt-4o-mini-search-preview",
15
+ "gpt-5-search-api"
16
+ ];
17
+ var NATIVE_SEARCH_EXCLUDED_MODELS = [
18
+ "gpt-4.1-nano"
19
+ ];
20
+ var NATIVE_SEARCH_TOOL_NAMES = [
21
+ "web_search",
22
+ "web_search_20250305",
23
+ "web_search_20260209",
24
+ "google_search",
25
+ "googleSearchRetrieval"
26
+ ];
27
+ var API_FORMAT_PROVIDER_MAP = {
28
+ "openai-response": "openai",
29
+ anthropic: "anthropic",
30
+ google: "google"
31
+ };
32
+ export {
33
+ API_FORMAT_PROVIDER_MAP,
34
+ NATIVE_SEARCH_EXCLUDED_MODELS,
35
+ NATIVE_SEARCH_MODEL_PATTERNS,
36
+ NATIVE_SEARCH_TOOL_NAMES,
37
+ OPENAI_CHAT_COMPLETION_SEARCH_MODELS
38
+ };
@@ -0,0 +1,72 @@
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/completion/openrouter-headers.ts
21
+ var openrouter_headers_exports = {};
22
+ __export(openrouter_headers_exports, {
23
+ OPENROUTER_DEFAULT_BASE_URL: () => OPENROUTER_DEFAULT_BASE_URL,
24
+ OPENROUTER_HTTP_REFERER: () => OPENROUTER_HTTP_REFERER,
25
+ OPENROUTER_X_TITLE: () => OPENROUTER_X_TITLE,
26
+ buildOpenRouterHeaders: () => buildOpenRouterHeaders,
27
+ buildOpenRouterUrl: () => buildOpenRouterUrl,
28
+ resolveOpenRouterBaseUrl: () => resolveOpenRouterBaseUrl
29
+ });
30
+ module.exports = __toCommonJS(openrouter_headers_exports);
31
+ var OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
32
+ var OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
33
+ var OPENROUTER_X_TITLE = "Omnicross";
34
+ function buildOpenRouterHeaders(credentials, options = {}) {
35
+ const apiKey = credentials.apiKey?.trim();
36
+ if (!apiKey) {
37
+ throw new Error("OpenRouter API key is required");
38
+ }
39
+ const headers = {
40
+ Authorization: `Bearer ${apiKey}`,
41
+ "HTTP-Referer": OPENROUTER_HTTP_REFERER,
42
+ "X-Title": OPENROUTER_X_TITLE
43
+ };
44
+ if (options.contentType !== false) {
45
+ headers["Content-Type"] = options.contentType ?? "application/json";
46
+ }
47
+ if (options.extra) {
48
+ for (const [key, value] of Object.entries(options.extra)) {
49
+ headers[key] = value;
50
+ }
51
+ }
52
+ return headers;
53
+ }
54
+ function resolveOpenRouterBaseUrl(endpoint) {
55
+ const raw = endpoint?.trim();
56
+ const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
57
+ return base.replace(/\/+$/, "");
58
+ }
59
+ function buildOpenRouterUrl(endpoint, path) {
60
+ const base = resolveOpenRouterBaseUrl(endpoint);
61
+ const cleanPath = path.startsWith("/") ? path : `/${path}`;
62
+ return `${base}${cleanPath}`;
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ OPENROUTER_DEFAULT_BASE_URL,
67
+ OPENROUTER_HTTP_REFERER,
68
+ OPENROUTER_X_TITLE,
69
+ buildOpenRouterHeaders,
70
+ buildOpenRouterUrl,
71
+ resolveOpenRouterBaseUrl
72
+ });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * OpenRouter request header / endpoint helpers.
3
+ *
4
+ * Shared by the multimodal subsystems (image / music / video / asr / tts) that
5
+ * route through OpenRouter. The LLM side has its own header path via
6
+ * `header-builder.ts` + `OPENROUTER_APP_HEADERS`; this helper exists so media
7
+ * services don't need to depend on the LLM provider type.
8
+ */
9
+ declare const OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
10
+ /**
11
+ * Default HTTP-Referer / X-Title for every OpenRouter request the serving core
12
+ * makes. OpenRouter uses these for app-stats attribution. A host embedder may
13
+ * override the values it sends; these are the package defaults.
14
+ */
15
+ declare const OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
16
+ declare const OPENROUTER_X_TITLE = "Omnicross";
17
+ interface OpenRouterCredentialFields {
18
+ apiKey?: string;
19
+ endpoint?: string;
20
+ }
21
+ interface OpenRouterHeaderOptions {
22
+ /** Defaults to `application/json`. Pass `false` to omit. */
23
+ contentType?: string | false;
24
+ /** Extra headers to merge after the standard set. */
25
+ extra?: Record<string, string>;
26
+ }
27
+ /**
28
+ * Build the standard OpenRouter request header set from a credential record.
29
+ * Throws when `apiKey` is missing — every OpenRouter request requires one.
30
+ * `HTTP-Referer` and `X-Title` are always hard-coded; not user-configurable.
31
+ */
32
+ declare function buildOpenRouterHeaders(credentials: OpenRouterCredentialFields, options?: OpenRouterHeaderOptions): Record<string, string>;
33
+ /**
34
+ * Resolve the OpenRouter base URL from the provider's `endpoint` config,
35
+ * falling back to the default. The returned value never has a trailing slash.
36
+ */
37
+ declare function resolveOpenRouterBaseUrl(endpoint?: string | null): string;
38
+ /**
39
+ * Join the OpenRouter base URL with a sub-path. Leading slashes on the path
40
+ * are tolerated.
41
+ */
42
+ declare function buildOpenRouterUrl(endpoint: string | undefined, path: string): string;
43
+
44
+ export { OPENROUTER_DEFAULT_BASE_URL, OPENROUTER_HTTP_REFERER, OPENROUTER_X_TITLE, type OpenRouterCredentialFields, type OpenRouterHeaderOptions, buildOpenRouterHeaders, buildOpenRouterUrl, resolveOpenRouterBaseUrl };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * OpenRouter request header / endpoint helpers.
3
+ *
4
+ * Shared by the multimodal subsystems (image / music / video / asr / tts) that
5
+ * route through OpenRouter. The LLM side has its own header path via
6
+ * `header-builder.ts` + `OPENROUTER_APP_HEADERS`; this helper exists so media
7
+ * services don't need to depend on the LLM provider type.
8
+ */
9
+ declare const OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
10
+ /**
11
+ * Default HTTP-Referer / X-Title for every OpenRouter request the serving core
12
+ * makes. OpenRouter uses these for app-stats attribution. A host embedder may
13
+ * override the values it sends; these are the package defaults.
14
+ */
15
+ declare const OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
16
+ declare const OPENROUTER_X_TITLE = "Omnicross";
17
+ interface OpenRouterCredentialFields {
18
+ apiKey?: string;
19
+ endpoint?: string;
20
+ }
21
+ interface OpenRouterHeaderOptions {
22
+ /** Defaults to `application/json`. Pass `false` to omit. */
23
+ contentType?: string | false;
24
+ /** Extra headers to merge after the standard set. */
25
+ extra?: Record<string, string>;
26
+ }
27
+ /**
28
+ * Build the standard OpenRouter request header set from a credential record.
29
+ * Throws when `apiKey` is missing — every OpenRouter request requires one.
30
+ * `HTTP-Referer` and `X-Title` are always hard-coded; not user-configurable.
31
+ */
32
+ declare function buildOpenRouterHeaders(credentials: OpenRouterCredentialFields, options?: OpenRouterHeaderOptions): Record<string, string>;
33
+ /**
34
+ * Resolve the OpenRouter base URL from the provider's `endpoint` config,
35
+ * falling back to the default. The returned value never has a trailing slash.
36
+ */
37
+ declare function resolveOpenRouterBaseUrl(endpoint?: string | null): string;
38
+ /**
39
+ * Join the OpenRouter base URL with a sub-path. Leading slashes on the path
40
+ * are tolerated.
41
+ */
42
+ declare function buildOpenRouterUrl(endpoint: string | undefined, path: string): string;
43
+
44
+ export { OPENROUTER_DEFAULT_BASE_URL, OPENROUTER_HTTP_REFERER, OPENROUTER_X_TITLE, type OpenRouterCredentialFields, type OpenRouterHeaderOptions, buildOpenRouterHeaders, buildOpenRouterUrl, resolveOpenRouterBaseUrl };
@@ -0,0 +1,42 @@
1
+ // src/completion/openrouter-headers.ts
2
+ var OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
3
+ var OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
4
+ var OPENROUTER_X_TITLE = "Omnicross";
5
+ function buildOpenRouterHeaders(credentials, options = {}) {
6
+ const apiKey = credentials.apiKey?.trim();
7
+ if (!apiKey) {
8
+ throw new Error("OpenRouter API key is required");
9
+ }
10
+ const headers = {
11
+ Authorization: `Bearer ${apiKey}`,
12
+ "HTTP-Referer": OPENROUTER_HTTP_REFERER,
13
+ "X-Title": OPENROUTER_X_TITLE
14
+ };
15
+ if (options.contentType !== false) {
16
+ headers["Content-Type"] = options.contentType ?? "application/json";
17
+ }
18
+ if (options.extra) {
19
+ for (const [key, value] of Object.entries(options.extra)) {
20
+ headers[key] = value;
21
+ }
22
+ }
23
+ return headers;
24
+ }
25
+ function resolveOpenRouterBaseUrl(endpoint) {
26
+ const raw = endpoint?.trim();
27
+ const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
28
+ return base.replace(/\/+$/, "");
29
+ }
30
+ function buildOpenRouterUrl(endpoint, path) {
31
+ const base = resolveOpenRouterBaseUrl(endpoint);
32
+ const cleanPath = path.startsWith("/") ? path : `/${path}`;
33
+ return `${base}${cleanPath}`;
34
+ }
35
+ export {
36
+ OPENROUTER_DEFAULT_BASE_URL,
37
+ OPENROUTER_HTTP_REFERER,
38
+ OPENROUTER_X_TITLE,
39
+ buildOpenRouterHeaders,
40
+ buildOpenRouterUrl,
41
+ resolveOpenRouterBaseUrl
42
+ };
@@ -0,0 +1,86 @@
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/completion/openrouter-models.ts
21
+ var openrouter_models_exports = {};
22
+ __export(openrouter_models_exports, {
23
+ fetchOpenRouterModels: () => fetchOpenRouterModels
24
+ });
25
+ module.exports = __toCommonJS(openrouter_models_exports);
26
+
27
+ // src/completion/openrouter-headers.ts
28
+ var OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
29
+ var OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
30
+ var OPENROUTER_X_TITLE = "Omnicross";
31
+ function buildOpenRouterHeaders(credentials, options = {}) {
32
+ const apiKey = credentials.apiKey?.trim();
33
+ if (!apiKey) {
34
+ throw new Error("OpenRouter API key is required");
35
+ }
36
+ const headers = {
37
+ Authorization: `Bearer ${apiKey}`,
38
+ "HTTP-Referer": OPENROUTER_HTTP_REFERER,
39
+ "X-Title": OPENROUTER_X_TITLE
40
+ };
41
+ if (options.contentType !== false) {
42
+ headers["Content-Type"] = options.contentType ?? "application/json";
43
+ }
44
+ if (options.extra) {
45
+ for (const [key, value] of Object.entries(options.extra)) {
46
+ headers[key] = value;
47
+ }
48
+ }
49
+ return headers;
50
+ }
51
+ function resolveOpenRouterBaseUrl(endpoint) {
52
+ const raw = endpoint?.trim();
53
+ const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
54
+ return base.replace(/\/+$/, "");
55
+ }
56
+ function buildOpenRouterUrl(endpoint, path) {
57
+ const base = resolveOpenRouterBaseUrl(endpoint);
58
+ const cleanPath = path.startsWith("/") ? path : `/${path}`;
59
+ return `${base}${cleanPath}`;
60
+ }
61
+
62
+ // src/completion/openrouter-models.ts
63
+ async function fetchOpenRouterModels(credentials, outputModality) {
64
+ const headers = buildOpenRouterHeaders(credentials);
65
+ const url = buildOpenRouterUrl(
66
+ credentials.endpoint,
67
+ `/models?output_modalities=${encodeURIComponent(outputModality)}`
68
+ );
69
+ const response = await fetch(url, { method: "GET", headers });
70
+ if (!response.ok) {
71
+ const text = await response.text().catch(() => "");
72
+ let message = text.slice(0, 300);
73
+ try {
74
+ const parsed = JSON.parse(text);
75
+ message = parsed?.error?.message || parsed?.message || message;
76
+ } catch {
77
+ }
78
+ throw new Error(`OpenRouter /models failed (${response.status}): ${message}`);
79
+ }
80
+ const data = await response.json();
81
+ return data?.data ?? [];
82
+ }
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ fetchOpenRouterModels
86
+ });
@@ -0,0 +1,27 @@
1
+ import { OpenRouterCredentialFields } from './openrouter-headers.cjs';
2
+
3
+ /**
4
+ * OpenRouter `/api/v1/models` discovery helper.
5
+ *
6
+ * Used by the multimodal subsystems (image / music / asr / tts) to refresh their
7
+ * model lists from the OpenRouter catalog, filtered by `output_modalities`.
8
+ * Video uses a dedicated `/api/v1/videos/models` endpoint (see video/adapters/openrouter.ts).
9
+ */
10
+
11
+ interface OpenRouterRawModel {
12
+ id: string;
13
+ name?: string;
14
+ description?: string;
15
+ input_modalities?: string[];
16
+ output_modalities?: string[];
17
+ context_length?: number;
18
+ pricing?: Record<string, unknown>;
19
+ }
20
+ /**
21
+ * Fetch the OpenRouter model catalog filtered by output modality.
22
+ *
23
+ * @param outputModality — `image` | `audio` | `transcription` | `speech` (per OpenRouter docs)
24
+ */
25
+ declare function fetchOpenRouterModels(credentials: OpenRouterCredentialFields, outputModality: string): Promise<OpenRouterRawModel[]>;
26
+
27
+ export { type OpenRouterRawModel, fetchOpenRouterModels };
@@ -0,0 +1,27 @@
1
+ import { OpenRouterCredentialFields } from './openrouter-headers.js';
2
+
3
+ /**
4
+ * OpenRouter `/api/v1/models` discovery helper.
5
+ *
6
+ * Used by the multimodal subsystems (image / music / asr / tts) to refresh their
7
+ * model lists from the OpenRouter catalog, filtered by `output_modalities`.
8
+ * Video uses a dedicated `/api/v1/videos/models` endpoint (see video/adapters/openrouter.ts).
9
+ */
10
+
11
+ interface OpenRouterRawModel {
12
+ id: string;
13
+ name?: string;
14
+ description?: string;
15
+ input_modalities?: string[];
16
+ output_modalities?: string[];
17
+ context_length?: number;
18
+ pricing?: Record<string, unknown>;
19
+ }
20
+ /**
21
+ * Fetch the OpenRouter model catalog filtered by output modality.
22
+ *
23
+ * @param outputModality — `image` | `audio` | `transcription` | `speech` (per OpenRouter docs)
24
+ */
25
+ declare function fetchOpenRouterModels(credentials: OpenRouterCredentialFields, outputModality: string): Promise<OpenRouterRawModel[]>;
26
+
27
+ export { type OpenRouterRawModel, fetchOpenRouterModels };
@@ -0,0 +1,59 @@
1
+ // src/completion/openrouter-headers.ts
2
+ var OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
3
+ var OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
4
+ var OPENROUTER_X_TITLE = "Omnicross";
5
+ function buildOpenRouterHeaders(credentials, options = {}) {
6
+ const apiKey = credentials.apiKey?.trim();
7
+ if (!apiKey) {
8
+ throw new Error("OpenRouter API key is required");
9
+ }
10
+ const headers = {
11
+ Authorization: `Bearer ${apiKey}`,
12
+ "HTTP-Referer": OPENROUTER_HTTP_REFERER,
13
+ "X-Title": OPENROUTER_X_TITLE
14
+ };
15
+ if (options.contentType !== false) {
16
+ headers["Content-Type"] = options.contentType ?? "application/json";
17
+ }
18
+ if (options.extra) {
19
+ for (const [key, value] of Object.entries(options.extra)) {
20
+ headers[key] = value;
21
+ }
22
+ }
23
+ return headers;
24
+ }
25
+ function resolveOpenRouterBaseUrl(endpoint) {
26
+ const raw = endpoint?.trim();
27
+ const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
28
+ return base.replace(/\/+$/, "");
29
+ }
30
+ function buildOpenRouterUrl(endpoint, path) {
31
+ const base = resolveOpenRouterBaseUrl(endpoint);
32
+ const cleanPath = path.startsWith("/") ? path : `/${path}`;
33
+ return `${base}${cleanPath}`;
34
+ }
35
+
36
+ // src/completion/openrouter-models.ts
37
+ async function fetchOpenRouterModels(credentials, outputModality) {
38
+ const headers = buildOpenRouterHeaders(credentials);
39
+ const url = buildOpenRouterUrl(
40
+ credentials.endpoint,
41
+ `/models?output_modalities=${encodeURIComponent(outputModality)}`
42
+ );
43
+ const response = await fetch(url, { method: "GET", headers });
44
+ if (!response.ok) {
45
+ const text = await response.text().catch(() => "");
46
+ let message = text.slice(0, 300);
47
+ try {
48
+ const parsed = JSON.parse(text);
49
+ message = parsed?.error?.message || parsed?.message || message;
50
+ } catch {
51
+ }
52
+ throw new Error(`OpenRouter /models failed (${response.status}): ${message}`);
53
+ }
54
+ const data = await response.json();
55
+ return data?.data ?? [];
56
+ }
57
+ export {
58
+ fetchOpenRouterModels
59
+ };
@@ -0,0 +1,18 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/completion/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,3 @@
1
+ import '@omnicross/contracts/message-blocks';
2
+ import '@omnicross/contracts/completion-types';
3
+ export { A as ApiFormat, C as CompletionOptions, a as CompletionResult, b as NativeSearchAugmentation, e as NativeSearchUserConfig, S as StreamCallbacks } from '../types-BScIHmPr.cjs';
@@ -0,0 +1,3 @@
1
+ import '@omnicross/contracts/message-blocks';
2
+ import '@omnicross/contracts/completion-types';
3
+ export { A as ApiFormat, C as CompletionOptions, a as CompletionResult, b as NativeSearchAugmentation, e as NativeSearchUserConfig, S as StreamCallbacks } from '../types-BScIHmPr.js';
File without changes