@absolutejs/ai 0.0.51 → 0.0.53

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.
@@ -0,0 +1,37 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ // src/ai/providers/openrouterSDK.ts
5
+ import {
6
+ OpenRouter as OfficialOpenRouterSDK
7
+ } from "@openrouter/sdk";
8
+ var createOpenRouterSDK = (config = {}) => {
9
+ if (config.appCategories && config.appCategories.length > 2)
10
+ throw new Error("createOpenRouterSDK() appCategories supports at most 2 entries");
11
+ if (!config.apiKey && !config.tokenSource)
12
+ throw new Error("createOpenRouterSDK() requires either apiKey or tokenSource");
13
+ const {
14
+ apiKey,
15
+ appCategories,
16
+ appName,
17
+ appUrl,
18
+ baseUrl,
19
+ tokenSource,
20
+ ...options
21
+ } = config;
22
+ return new OfficialOpenRouterSDK({
23
+ ...options,
24
+ apiKey: tokenSource ? async () => Promise.resolve(tokenSource()) : apiKey,
25
+ appCategories: appCategories?.join(","),
26
+ appTitle: appName,
27
+ httpReferer: appUrl,
28
+ serverURL: baseUrl
29
+ });
30
+ };
31
+ export {
32
+ createOpenRouterSDK,
33
+ OfficialOpenRouterSDK as OpenRouterSDK
34
+ };
35
+
36
+ //# debugId=7959A7816069F74364756E2164756E21
37
+ //# sourceMappingURL=openrouterSDK.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/ai/providers/openrouterSDK.ts"],
4
+ "sourcesContent": [
5
+ "import {\n OpenRouter as OfficialOpenRouterSDK,\n type SDKOptions,\n} from \"@openrouter/sdk\";\n\nexport type OpenRouterSDKConfig = Omit<\n SDKOptions,\n \"apiKey\" | \"appCategories\" | \"appTitle\" | \"httpReferer\" | \"serverURL\"\n> & {\n apiKey?: string;\n /** Comma-separated marketplace categories are produced from this list. */\n appCategories?: readonly string[];\n appName?: string;\n appUrl?: string;\n baseUrl?: string;\n tokenSource?: () => Promise<string> | string;\n};\n\n/**\n * Create OpenRouter's generated SDK with AbsoluteJS-style configuration.\n *\n * Use this for the complete REST surface: API keys, BYOK, guardrails,\n * observability, organizations, SCIM, datasets, benchmarks, and future\n * OpenAPI-generated additions. Use `openrouter()` for policy-aware inference.\n */\nexport const createOpenRouterSDK = (config: OpenRouterSDKConfig = {}) => {\n if (config.appCategories && config.appCategories.length > 2)\n throw new Error(\n \"createOpenRouterSDK() appCategories supports at most 2 entries\",\n );\n if (!config.apiKey && !config.tokenSource)\n throw new Error(\n \"createOpenRouterSDK() requires either apiKey or tokenSource\",\n );\n const {\n apiKey,\n appCategories,\n appName,\n appUrl,\n baseUrl,\n tokenSource,\n ...options\n } = config;\n return new OfficialOpenRouterSDK({\n ...options,\n apiKey: tokenSource ? async () => Promise.resolve(tokenSource()) : apiKey,\n appCategories: appCategories?.join(\",\"),\n appTitle: appName,\n httpReferer: appUrl,\n serverURL: baseUrl,\n });\n};\n\nexport { OfficialOpenRouterSDK as OpenRouterSDK };\nexport type { SDKOptions as OfficialOpenRouterSDKOptions } from \"@openrouter/sdk\";\nexport type { RequestOptions as OpenRouterSDKRequestOptions } from \"@openrouter/sdk/lib/sdks.js\";\n"
6
+ ],
7
+ "mappings": ";;;;AAAA;AAAA,gBACE;AAAA;AAwBK,IAAM,sBAAsB,CAAC,SAA8B,CAAC,MAAM;AAAA,EACvE,IAAI,OAAO,iBAAiB,OAAO,cAAc,SAAS;AAAA,IACxD,MAAM,IAAI,MACR,gEACF;AAAA,EACF,IAAI,CAAC,OAAO,UAAU,CAAC,OAAO;AAAA,IAC5B,MAAM,IAAI,MACR,6DACF;AAAA,EACF;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA,MACD;AAAA,EACJ,OAAO,IAAI,sBAAsB;AAAA,OAC5B;AAAA,IACH,QAAQ,cAAc,YAAY,QAAQ,QAAQ,YAAY,CAAC,IAAI;AAAA,IACnE,eAAe,eAAe,KAAK,GAAG;AAAA,IACtC,UAAU;AAAA,IACV,aAAa;AAAA,IACb,WAAW;AAAA,EACb,CAAC;AAAA;",
8
+ "debugId": "7959A7816069F74364756E2164756E21",
9
+ "names": []
10
+ }
@@ -24,8 +24,8 @@ export { gemini } from "./providers/gemini";
24
24
  export { anthropic } from "./providers/anthropic";
25
25
  export { ollama } from "./providers/ollama";
26
26
  export { openai } from "./providers/openai";
27
- export { createOpenRouterClient, openrouter, openrouterMessages, openrouterResponses, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./providers/openrouter";
28
- export type { OpenRouterClient, OpenRouterClientConfig, OpenRouterConfig, OpenRouterDataCollection, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterMaxPrice, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterPerformancePreference, OpenRouterPlugin, OpenRouterProviderRouting, OpenRouterQuantization, OpenRouterRequestOptions, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponseCache, OpenRouterResponsesRequest, OpenRouterServerTool, OpenRouterServiceTier, OpenRouterSpeechRequest, OpenRouterSort, OpenRouterSortStrategy, OpenRouterTrace, OpenRouterTranscriptionRequest, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterZdrEndpoint, } from "./providers/openrouter";
27
+ export { createOpenRouterAuthorizationUrl, createOpenRouterClient, createOpenRouterKeyLinks, estimateOpenRouterCost, estimateOpenRouterModelCost, exchangeOpenRouterAuthCode, generateOpenRouterPKCE, openrouter, openrouterMessages, openrouterResponses, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./providers/openrouter";
28
+ export type { OpenRouterActivityItem, OpenRouterActivityQuery, OpenRouterAdvisorParameters, OpenRouterAnalyticsMeta, OpenRouterAnalyticsQuery, OpenRouterAnalyticsResponse, OpenRouterAuthCodeExchangeRequest, OpenRouterAuthCodeExchangeResponse, OpenRouterAutoRouterCostTier, OpenRouterAutoRouterPlugin, OpenRouterAuthorizationUrlOptions, OpenRouterBatch, OpenRouterBatchEndpoint, OpenRouterBatchRequest, OpenRouterBatchResult, OpenRouterBatchStatus, OpenRouterChatRequest, OpenRouterChatResponse, OpenRouterClient, OpenRouterClientConfig, OpenRouterConfig, OpenRouterCostEstimate, OpenRouterCostUnits, OpenRouterCreateAuthCodeRequest, OpenRouterCreateAuthCodeResponse, OpenRouterCreateBatchRequest, OpenRouterCreateWorkspaceRequest, OpenRouterDataCollection, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterImageGenerationParameters, OpenRouterMaxPrice, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterPerformancePreference, OpenRouterPlugin, OpenRouterPKCE, OpenRouterPreset, OpenRouterPresetInferenceRequest, OpenRouterPresetResponse, OpenRouterPresetVersion, OpenRouterPresetVersionResponse, OpenRouterPricing, OpenRouterPricingKey, OpenRouterProviderRouting, OpenRouterQuantization, OpenRouterRequestOptions, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponseCache, OpenRouterResponsesRequest, OpenRouterServerTool, OpenRouterShellParameters, OpenRouterServiceTier, OpenRouterSpeechRequest, OpenRouterSort, OpenRouterSortStrategy, OpenRouterTrace, OpenRouterFusionPlugin, OpenRouterFusionServerToolParameters, OpenRouterResponseHealingPlugin, OpenRouterSubagentParameters, OpenRouterTaskClassifications, OpenRouterTranscriptionRequest, OpenRouterTranscriptionResponse, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterWorkspace, OpenRouterWorkspaceBudget, OpenRouterWorkspaceBudgetInterval, OpenRouterWorkspaceMember, OpenRouterWorkspaceOptions, OpenRouterWebFetchParameters, OpenRouterWebSearchParameters, OpenRouterWebSearchPlugin, OpenRouterZdrEndpoint, } from "./providers/openrouter";
29
29
  export { createOAuth2ClientCredentialsTokenSource } from "./providers/oauth2TokenSource";
30
30
  export type { OAuth2ClientCredentialsConfig } from "./providers/oauth2TokenSource";
31
31
  export { ProviderError, PROVIDER_STATUS_PAGES, providerStatusPage, } from "./errors/providerError";
@@ -72,13 +72,161 @@ export type OpenRouterAudioOutput = {
72
72
  format: "wav" | "mp3" | "flac" | "opus" | "pcm16";
73
73
  voice: string;
74
74
  };
75
- export type OpenRouterPlugin = {
75
+ export type OpenRouterAutoRouterCostTier = "low" | "medium" | "high" | "xhigh" | "max";
76
+ export type OpenRouterAutoRouterPlugin = {
77
+ id: "auto-router";
78
+ /** Restrict Auto Router candidates; omitted means the full catalog. */
79
+ allowed_models?: readonly string[];
80
+ cost_tier?: OpenRouterAutoRouterCostTier;
81
+ /** Legacy numeric control. When present, OpenRouter prioritizes it over cost_tier. */
82
+ cost_quality_tradeoff?: number;
83
+ };
84
+ /** @deprecated OpenRouter recommends the `openrouter:web_search` server tool. */
85
+ export type OpenRouterWebSearchPlugin = {
86
+ id: "web";
87
+ engine?: "native" | "exa" | "firecrawl" | "parallel" | "perplexity";
88
+ exclude_domains?: readonly string[];
89
+ include_domains?: readonly string[];
90
+ max_results?: number;
91
+ search_prompt?: string;
92
+ };
93
+ export type OpenRouterFusionPlugin = {
94
+ id: "fusion";
95
+ analysis_models?: readonly string[];
96
+ enabled?: boolean;
97
+ max_tool_calls?: number;
98
+ model?: string;
99
+ preset?: string;
100
+ };
101
+ export type OpenRouterResponseHealingPlugin = {
102
+ id: "response-healing";
103
+ };
104
+ export type OpenRouterPlugin = OpenRouterAutoRouterPlugin | OpenRouterFusionPlugin | OpenRouterResponseHealingPlugin | OpenRouterWebSearchPlugin | {
76
105
  id: string;
77
106
  [option: string]: unknown;
78
107
  };
108
+ export type OpenRouterWebSearchParameters = {
109
+ allowed_domains?: readonly string[];
110
+ engine?: "auto" | "native" | "exa" | "firecrawl" | "parallel" | "perplexity";
111
+ excluded_domains?: readonly string[];
112
+ max_characters?: number;
113
+ max_results?: number;
114
+ max_total_results?: number;
115
+ search_context_size?: "low" | "medium" | "high";
116
+ user_location?: {
117
+ city?: string;
118
+ country?: string;
119
+ region?: string;
120
+ timezone?: string;
121
+ type: "approximate";
122
+ };
123
+ };
124
+ export type OpenRouterWebFetchParameters = {
125
+ allowed_domains?: readonly string[];
126
+ blocked_domains?: readonly string[];
127
+ engine?: "auto" | "native" | "exa" | "openrouter" | "firecrawl" | "parallel";
128
+ max_content_tokens?: number;
129
+ max_uses?: number;
130
+ };
131
+ export type OpenRouterImageGenerationParameters = {
132
+ aspect_ratio?: string;
133
+ background?: string;
134
+ model?: string;
135
+ moderation?: string;
136
+ output_compression?: number;
137
+ output_format?: string;
138
+ quality?: string;
139
+ size?: string;
140
+ };
141
+ export type OpenRouterSubagentParameters = {
142
+ inherit_functions?: boolean;
143
+ inherited_function_names?: readonly string[];
144
+ instructions?: string;
145
+ max_completion_tokens?: number;
146
+ max_tool_calls?: number;
147
+ model?: string;
148
+ name?: string;
149
+ reasoning?: {
150
+ effort?: OpenRouterReasoning["effort"];
151
+ max_tokens?: number;
152
+ };
153
+ temperature?: number;
154
+ tools?: readonly Exclude<OpenRouterServerTool, {
155
+ type: "openrouter:subagent";
156
+ }>[];
157
+ };
158
+ export type OpenRouterAdvisorParameters = {
159
+ forward_transcript?: boolean;
160
+ instructions?: string;
161
+ max_completion_tokens?: number;
162
+ model?: string;
163
+ name?: string;
164
+ reasoning?: {
165
+ effort?: string;
166
+ max_tokens?: number;
167
+ };
168
+ stream?: boolean;
169
+ temperature?: number;
170
+ };
171
+ export type OpenRouterFusionServerToolParameters = {
172
+ analysis_models?: readonly string[];
173
+ cache_control?: OpenRouterCacheControl;
174
+ max_completion_tokens?: number;
175
+ max_tool_calls?: number;
176
+ model?: string;
177
+ reasoning?: {
178
+ effort?: string;
179
+ max_tokens?: number;
180
+ };
181
+ temperature?: number;
182
+ tools?: readonly OpenRouterServerTool[];
183
+ };
184
+ export type OpenRouterShellParameters = {
185
+ engine?: "auto" | "openrouter";
186
+ environment?: {
187
+ type: "container_auto";
188
+ } | {
189
+ container_id: string;
190
+ type: "container_reference";
191
+ };
192
+ sleep_after_seconds?: number;
193
+ };
79
194
  export type OpenRouterServerTool = {
80
- type: "openrouter:web_search" | "openrouter:web_fetch" | "openrouter:datetime" | "openrouter:image_generation" | "openrouter:apply_patch" | "openrouter:shell" | "openrouter:fusion" | "openrouter:advisor" | "openrouter:subagent" | "openrouter:experimental__search_models";
81
- parameters?: Record<string, unknown>;
195
+ type: "openrouter:web_search";
196
+ parameters?: OpenRouterWebSearchParameters;
197
+ } | {
198
+ type: "openrouter:web_fetch";
199
+ parameters?: OpenRouterWebFetchParameters;
200
+ } | {
201
+ type: "openrouter:datetime";
202
+ parameters?: {
203
+ timezone?: string;
204
+ };
205
+ } | {
206
+ type: "openrouter:image_generation";
207
+ parameters?: OpenRouterImageGenerationParameters;
208
+ } | {
209
+ type: "openrouter:apply_patch";
210
+ parameters?: {
211
+ engine?: "auto" | "native" | "openrouter";
212
+ };
213
+ } | {
214
+ type: "openrouter:subagent";
215
+ parameters: OpenRouterSubagentParameters;
216
+ } | {
217
+ type: "openrouter:advisor";
218
+ parameters?: OpenRouterAdvisorParameters;
219
+ } | {
220
+ type: "openrouter:fusion";
221
+ parameters?: OpenRouterFusionServerToolParameters;
222
+ } | {
223
+ type: "openrouter:shell";
224
+ parameters?: OpenRouterShellParameters;
225
+ } | {
226
+ type: "openrouter:experimental__search_models";
227
+ parameters?: {
228
+ max_results?: number;
229
+ };
82
230
  };
83
231
  export type OpenRouterRequestOptions = {
84
232
  /** Stream text and synthesized audio from an audio-output chat model. */
@@ -153,5 +301,5 @@ export declare const openrouter: (config: OpenRouterConfig) => AIProviderConfig;
153
301
  export declare const openrouterResponses: (config: OpenRouterConfig) => AIProviderConfig;
154
302
  /** OpenRouter provider using the native Anthropic Messages protocol skin. */
155
303
  export declare const openrouterMessages: (config: OpenRouterConfig) => AIProviderConfig;
156
- export { createOpenRouterClient, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./openrouterClient";
157
- export type { OpenRouterClient, OpenRouterClientConfig, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponsesRequest, OpenRouterSpeechRequest, OpenRouterTranscriptionRequest, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterZdrEndpoint, } from "./openrouterClient";
304
+ export { createOpenRouterAuthorizationUrl, createOpenRouterClient, createOpenRouterKeyLinks, estimateOpenRouterCost, estimateOpenRouterModelCost, exchangeOpenRouterAuthCode, generateOpenRouterPKCE, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./openrouterClient";
305
+ export type { OpenRouterActivityItem, OpenRouterActivityQuery, OpenRouterAnalyticsMeta, OpenRouterAnalyticsQuery, OpenRouterAnalyticsResponse, OpenRouterAuthCodeExchangeRequest, OpenRouterAuthCodeExchangeResponse, OpenRouterAuthorizationUrlOptions, OpenRouterBatch, OpenRouterBatchEndpoint, OpenRouterBatchRequest, OpenRouterBatchResult, OpenRouterBatchStatus, OpenRouterChatRequest, OpenRouterChatResponse, OpenRouterClient, OpenRouterClientConfig, OpenRouterCostEstimate, OpenRouterCostUnits, OpenRouterCreateAuthCodeRequest, OpenRouterCreateAuthCodeResponse, OpenRouterCreateBatchRequest, OpenRouterCreateWorkspaceRequest, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterPreset, OpenRouterPresetInferenceRequest, OpenRouterPresetResponse, OpenRouterPresetVersion, OpenRouterPresetVersionResponse, OpenRouterPricing, OpenRouterPricingKey, OpenRouterPKCE, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponsesRequest, OpenRouterSpeechRequest, OpenRouterTranscriptionRequest, OpenRouterTranscriptionResponse, OpenRouterTaskClassifications, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterWorkspace, OpenRouterWorkspaceBudget, OpenRouterWorkspaceBudgetInterval, OpenRouterWorkspaceMember, OpenRouterWorkspaceOptions, OpenRouterZdrEndpoint, } from "./openrouterClient";