@oai2lmapi/opencode-provider 0.1.3 → 0.2.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/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # @oai2lmapi/opencode-provider
2
2
 
3
- OpenAI-compatible provider for [OpenCode](https://github.com/anomalyco/opencode), built with the Vercel AI SDK.
3
+ AI SDK Provider for **OpenAI-compatible APIs** with **automatic model discovery**.
4
4
 
5
- ## Features
5
+ Use this provider in [OpenCode](https://opencode.ai) to connect to any OpenAI-compatible API endpoint. Unlike static configurations, this provider automatically discovers all available models from your API's `/models` endpoint.
6
6
 
7
- - **Auto-Discovery**: Automatically discovers models from your API's `/models` endpoint
8
- - **Smart Configuration**: Automatically detects model capabilities (tool calling, vision, context limits)
9
- - **Flexible Overrides**: Per-model configuration via OpenCode settings
10
- - **Based on AI SDK**: Built on top of Vercel AI SDK's `@ai-sdk/openai-compatible`
7
+ ## Features
11
8
 
12
- > **Note**: Advanced features like chain-of-thought handling (`<think>` tags) and prompt-based tool calling are planned for future releases.
9
+ - **AI SDK Provider**: Native provider for OpenCode and Vercel AI SDK
10
+ - **Auto-discovery**: Automatically fetches models from `$baseURL/models`
11
+ - **Zero model configuration**: No need to manually list each model
12
+ - **Metadata enrichment**: Merges API-returned metadata with `@oai2lmapi/model-metadata` registry
13
+ - **Wildcard overrides**: Apply settings to multiple models using patterns like `gpt-4*`
14
+ - **Config file support**: Optional `oai2lm.json` for persistent configuration
13
15
 
14
16
  ## Installation
15
17
 
@@ -17,325 +19,221 @@ OpenAI-compatible provider for [OpenCode](https://github.com/anomalyco/opencode)
17
19
  npm install @oai2lmapi/opencode-provider
18
20
  # or
19
21
  pnpm add @oai2lmapi/opencode-provider
20
- # or
21
- yarn add @oai2lmapi/opencode-provider
22
22
  ```
23
23
 
24
- ## Usage
24
+ ## Usage with OpenCode
25
25
 
26
- ### Basic Setup
26
+ Add to your `opencode.json`:
27
27
 
28
- Create a provider configuration file for OpenCode (e.g., `opencode.config.ts`):
28
+ ```json
29
+ {
30
+ "$schema": "https://opencode.ai/config.json",
31
+ "provider": {
32
+ "my-api": {
33
+ "npm": "@oai2lmapi/opencode-provider",
34
+ "options": {
35
+ "baseURL": "https://api.example.com/v1",
36
+ "apiKey": "your-api-key"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
29
42
 
30
- ```typescript
31
- import { createOAI2LMProvider } from '@oai2lmapi/opencode-provider';
32
-
33
- export default {
34
- providers: {
35
- myapi: createOAI2LMProvider({
36
- apiKey: process.env.MY_API_KEY,
37
- baseURL: 'https://api.example.com/v1',
38
- }),
39
- },
40
- };
43
+ That's it! OpenCode will automatically discover all available models from your API.
44
+
45
+ ### Using environment variables
46
+
47
+ ```json
48
+ {
49
+ "provider": {
50
+ "my-api": {
51
+ "npm": "@oai2lmapi/opencode-provider",
52
+ "env": ["MY_API_KEY"],
53
+ "options": {
54
+ "baseURL": "https://api.example.com/v1"
55
+ }
56
+ }
57
+ }
58
+ }
41
59
  ```
42
60
 
43
- ### With Model Auto-Discovery
61
+ Set `MY_API_KEY` in your environment:
62
+
63
+ ```bash
64
+ export MY_API_KEY=your-api-key
65
+ ```
44
66
 
45
- The provider will automatically fetch available models on initialization:
67
+ ## Programmatic Usage
46
68
 
47
69
  ```typescript
48
- import { createOAI2LMProvider } from '@oai2lmapi/opencode-provider';
70
+ import { createOai2lm } from "@oai2lmapi/opencode-provider";
71
+ import { streamText } from "ai";
49
72
 
50
- const provider = await createOAI2LMProvider({
51
- apiKey: process.env.MY_API_KEY,
52
- baseURL: 'https://api.example.com/v1',
53
- autoDiscoverModels: true, // default
73
+ // Create provider
74
+ const provider = createOai2lm({
75
+ baseURL: "https://api.example.com/v1",
76
+ apiKey: "your-api-key",
54
77
  });
55
78
 
56
- // Use with OpenCode
57
- const result = await generateText({
58
- model: provider('gpt-4'),
59
- prompt: 'Hello, world!',
79
+ // List discovered models
80
+ const models = await provider.listModels();
81
+ console.log(models);
82
+
83
+ // Use a model
84
+ const model = provider.languageModel("gpt-4");
85
+ const result = await streamText({
86
+ model,
87
+ messages: [{ role: "user", content: "Hello!" }],
60
88
  });
61
89
  ```
62
90
 
63
- ### Model Overrides
91
+ ## Provider Options
64
92
 
65
- Configure per-model settings:
93
+ | Option | Type | Required | Description |
94
+ | ---------------- | --------- | -------- | ----------------------------------------------------------- |
95
+ | `baseURL` | `string` | Yes | Base URL for API calls (e.g., `https://api.example.com/v1`) |
96
+ | `apiKey` | `string` | No | API key for authentication |
97
+ | `name` | `string` | No | Provider name (default: `"oai2lm"`) |
98
+ | `headers` | `object` | No | Custom headers for all requests |
99
+ | `modelFilter` | `string` | No | Regex pattern to filter models |
100
+ | `modelOverrides` | `object` | No | Per-model configuration overrides (supports wildcards) |
101
+ | `useConfigFile` | `boolean` | No | Merge settings from `oai2lm.json` (default: `true`) |
66
102
 
67
- ```typescript
68
- const provider = createOAI2LMProvider({
69
- apiKey: process.env.MY_API_KEY,
70
- baseURL: 'https://api.example.com/v1',
71
- modelOverrides: {
72
- 'deepseek-*': {
73
- // Use prompt-based tool calling for DeepSeek models
74
- usePromptBasedToolCalling: true,
75
- // Strip chain-of-thought tags
76
- suppressChainOfThought: true,
77
- },
78
- 'o1-*': {
79
- // Enable reasoning capture for o1 models
80
- captureReasoning: true,
81
- },
82
- 'gpt-4-vision': {
83
- // Override capabilities
84
- supportsImageInput: true,
85
- maxInputTokens: 128000,
86
- },
87
- },
88
- });
89
- ```
90
-
91
- ### Chain-of-Thought Handling
103
+ ## Config File
92
104
 
93
- For reasoning models that output `<think>` tags:
105
+ For persistent configuration, create `oai2lm.json` in one of these locations:
94
106
 
95
- ```typescript
96
- const provider = createOAI2LMProvider({
97
- apiKey: process.env.MY_API_KEY,
98
- baseURL: 'https://api.example.com/v1',
99
- modelOverrides: {
100
- 'reasoning-model-*': {
101
- // Capture and expose chain-of-thought
102
- captureReasoning: true,
103
- // Or suppress it from output
104
- suppressChainOfThought: false,
105
- },
106
- },
107
- });
107
+ 1. `~/.local/share/opencode/oai2lm.json`
108
+ 2. `~/.config/opencode/oai2lm.json`
108
109
 
109
- const result = await generateText({
110
- model: provider('reasoning-model-v1'),
111
- prompt: 'Solve this puzzle...',
112
- });
110
+ ```jsonc
111
+ {
112
+ // Base URL for your OpenAI-compatible API
113
+ "baseURL": "https://api.example.com/v1",
113
114
 
114
- // Access reasoning if captured
115
- console.log(result.reasoning); // Chain-of-thought content
116
- console.log(result.text); // Final answer without <think> tags
117
- ```
115
+ // API key (supports variable substitution)
116
+ "apiKey": "{env:MY_API_KEY}",
118
117
 
119
- ### Prompt-Based Tool Calling
118
+ // Provider ID
119
+ "name": "myapi",
120
120
 
121
- For models without native function calling:
121
+ // Display name
122
+ "displayName": "My API",
122
123
 
123
- ```typescript
124
- const provider = createOAI2LMProvider({
125
- apiKey: process.env.MY_API_KEY,
126
- baseURL: 'https://api.example.com/v1',
127
- modelOverrides: {
128
- 'legacy-model': {
129
- usePromptBasedToolCalling: true,
130
- },
124
+ // Custom headers
125
+ "headers": {
126
+ "X-Custom-Header": "value",
131
127
  },
132
- });
133
128
 
134
- // Tools are automatically converted to XML format in system prompt
135
- const result = await generateText({
136
- model: provider('legacy-model'),
137
- prompt: 'What is the weather in Tokyo?',
138
- tools: {
139
- getWeather: {
140
- description: 'Get current weather',
141
- parameters: z.object({
142
- location: z.string(),
143
- }),
144
- execute: async ({ location }) => {
145
- // ... fetch weather
146
- },
129
+ // Filter models by regex
130
+ "modelFilter": "^(gpt-|claude-)",
131
+
132
+ // Override model metadata (supports wildcards)
133
+ "modelOverrides": {
134
+ "gpt-4*": {
135
+ "maxInputTokens": 128000,
136
+ "supportsImageInput": true,
147
137
  },
148
138
  },
149
- });
139
+ }
150
140
  ```
151
141
 
152
- ## Configuration Options
142
+ ### Variable substitution
153
143
 
154
- ### Provider Settings
144
+ The `apiKey` field supports:
155
145
 
156
- ```typescript
157
- interface OAI2LMProviderSettings {
158
- /** API key for authentication */
159
- apiKey: string;
160
-
161
- /** Base URL for API calls (e.g., 'https://api.example.com/v1') */
162
- baseURL: string;
163
-
164
- /** Provider name (defaults to 'oai2lm') */
165
- name?: string;
166
-
167
- /** Custom headers */
168
- headers?: Record<string, string>;
169
-
170
- /** Auto-discover models on initialization (default: true) */
171
- autoDiscoverModels?: boolean;
172
-
173
- /** Per-model configuration overrides */
174
- modelOverrides?: Record<string, ModelOverride>;
175
-
176
- /** Custom fetch implementation */
177
- fetch?: typeof fetch;
178
- }
179
- ```
146
+ - `{env:VAR_NAME}` - Read from environment variable
147
+ - `{file:/path/to/file}` - Read from file
180
148
 
181
- ### Model Override Options
149
+ ## Extended API
150
+
151
+ ### `provider.listModels()`
152
+
153
+ Returns a list of discovered models with metadata:
182
154
 
183
155
  ```typescript
184
- interface ModelOverride {
185
- /** Max input tokens */
186
- maxInputTokens?: number;
187
-
188
- /** Max output tokens */
189
- maxOutputTokens?: number;
190
-
191
- /** Supports native tool/function calling */
192
- supportsToolCalling?: boolean;
193
-
194
- /** Supports image inputs */
195
- supportsImageInput?: boolean;
196
-
197
- /** Default temperature */
198
- temperature?: number;
199
-
200
- /** Use XML-based prompt engineering for tools */
201
- usePromptBasedToolCalling?: boolean;
202
-
203
- /** Strip <think>...</think> blocks from output */
204
- suppressChainOfThought?: boolean;
205
-
206
- /** Capture reasoning content separately */
207
- captureReasoning?: boolean;
208
-
209
- /** Thinking level: token budget or 'low'/'medium'/'high' */
210
- thinkingLevel?: number | 'low' | 'medium' | 'high' | 'auto';
211
- }
156
+ const models = await provider.listModels();
157
+ // [{ id: "gpt-4", name: "GPT-4", object: "model", ... }]
212
158
  ```
213
159
 
214
- ## How It Works
160
+ ### `provider.getModelMetadata(modelId)`
215
161
 
216
- 1. **Model Discovery**: On initialization, the provider fetches the `/models` endpoint
217
- 2. **Capability Detection**: Analyzes model metadata to determine capabilities
218
- 3. **Shared Metadata Registry**: Uses `@oai2lmapi/model-metadata` for fallback model info
219
- 4. **Metadata Caching**: Model info is cached to reduce API calls
220
- 5. **Override Application**: User-defined overrides are applied on top of discovered capabilities
221
- 6. **Request Translation**: Converts AI SDK requests to OpenAI-compatible format
222
- 7. **Response Parsing**: Handles special formats like `<think>` tags and XML tool calls
162
+ Returns enriched metadata for a specific model:
223
163
 
224
- ## Configuration with OpenCode
164
+ ```typescript
165
+ const metadata = await provider.getModelMetadata("gpt-4");
166
+ // { maxInputTokens: 128000, maxOutputTokens: 4096, supportsToolCalling: true, ... }
167
+ ```
225
168
 
226
- This provider integrates with OpenCode's data directory for configuration. By default (following the XDG base directory spec), it looks for a config file at:
169
+ ### `provider.refreshModels()`
227
170
 
228
- - `~/.local/share/opencode/oai2lm.json` (primary location, checked first — corresponds to `$XDG_DATA_HOME/opencode/oai2lm.json` with the common default of `~/.local/share`)
229
- - `~/.config/opencode/oai2lm.json` (alternative location, checked second as a fallback — corresponds to `$XDG_CONFIG_HOME/opencode/oai2lm.json` with the common default of `~/.config`)
171
+ Force refresh the model list from the API:
230
172
 
231
- If you are on a non-standard system or use custom XDG paths, you can override these locations by setting `XDG_DATA_HOME` and/or `XDG_CONFIG_HOME`. The provider will then resolve the config file as `$XDG_DATA_HOME/opencode/oai2lm.json` and `$XDG_CONFIG_HOME/opencode/oai2lm.json` respectively, and it will still search these locations in the order shown, using the first config file it finds (so the data directory location takes precedence if both files exist).
173
+ ```typescript
174
+ await provider.refreshModels();
175
+ ```
176
+
177
+ ## Example Configurations
232
178
 
233
- ### Config File Format
179
+ ### OpenRouter
234
180
 
235
181
  ```json
236
182
  {
237
- "apiKey": "your-api-key",
238
- "baseURL": "https://api.example.com/v1",
239
- "name": "my-provider",
240
- "autoDiscoverModels": true,
241
- "modelOverrides": {
242
- "deepseek-*": {
243
- "usePromptBasedToolCalling": true,
244
- "suppressChainOfThought": true
245
- },
246
- "gpt-4-vision": {
247
- "supportsImageInput": true,
248
- "maxInputTokens": 128000
183
+ "provider": {
184
+ "openrouter": {
185
+ "npm": "@oai2lmapi/opencode-provider",
186
+ "env": ["OPENROUTER_API_KEY"],
187
+ "options": {
188
+ "baseURL": "https://openrouter.ai/api/v1"
189
+ }
249
190
  }
250
191
  }
251
192
  }
252
193
  ```
253
194
 
254
- ### Using Config File
195
+ ### Local Ollama
255
196
 
256
- ```typescript
257
- import { createOAI2LMProviderFromConfig, OAI2LMProvider } from '@oai2lmapi/opencode-provider';
258
-
259
- // Create provider from config file
260
- const provider = createOAI2LMProviderFromConfig();
261
-
262
- // Or use the static method
263
- const provider2 = OAI2LMProvider.fromConfig();
264
-
265
- // Override specific settings
266
- const provider3 = createOAI2LMProviderFromConfig({
267
- baseURL: 'https://api.custom.com/v1', // Override base URL
268
- });
197
+ ```json
198
+ {
199
+ "provider": {
200
+ "ollama": {
201
+ "npm": "@oai2lmapi/opencode-provider",
202
+ "options": {
203
+ "baseURL": "http://localhost:11434/v1",
204
+ "apiKey": "ollama"
205
+ }
206
+ }
207
+ }
208
+ }
269
209
  ```
270
210
 
271
- ### Environment Variables
272
-
273
- You can also configure via environment variables:
274
-
275
- - `OAI2LM_API_KEY` - API key for authentication
276
- - `OAI2LM_BASE_URL` - Base URL for API calls
211
+ ### Together AI
277
212
 
278
- Priority order (highest to lowest):
279
- 1. Explicit settings passed to function
280
- 2. Environment variables
281
- 3. Config file values
282
-
283
- ## Integration with OpenCode
284
-
285
- This provider is designed to work seamlessly with OpenCode's configuration system:
286
-
287
- ```javascript
288
- // ~/.opencode/config.js
289
- export default {
290
- providers: {
291
- myapi: {
292
- type: '@oai2lmapi/opencode-provider',
293
- apiKey: process.env.MY_API_KEY,
294
- baseURL: 'https://api.example.com/v1',
295
- modelOverrides: {
296
- // Configure models as needed
297
- },
298
- },
299
- },
300
- models: {
301
- default: 'myapi:gpt-4',
302
- },
303
- };
213
+ ```json
214
+ {
215
+ "provider": {
216
+ "together": {
217
+ "npm": "@oai2lmapi/opencode-provider",
218
+ "env": ["TOGETHER_API_KEY"],
219
+ "options": {
220
+ "baseURL": "https://api.together.xyz/v1"
221
+ }
222
+ }
223
+ }
224
+ }
304
225
  ```
305
226
 
306
- ## Examples
307
-
308
- ### Using with Multiple Providers
309
-
310
- ```typescript
311
- import { createOAI2LMProvider } from '@oai2lmapi/opencode-provider';
312
-
313
- const openai = createOAI2LMProvider({
314
- name: 'openai',
315
- apiKey: process.env.OPENAI_API_KEY,
316
- baseURL: 'https://api.openai.com/v1',
317
- });
318
-
319
- const deepseek = createOAI2LMProvider({
320
- name: 'deepseek',
321
- apiKey: process.env.DEEPSEEK_API_KEY,
322
- baseURL: 'https://api.deepseek.com/v1',
323
- modelOverrides: {
324
- '*': {
325
- usePromptBasedToolCalling: true,
326
- },
327
- },
328
- });
227
+ ## How It Works
329
228
 
330
- // Use either provider
331
- await generateText({ model: openai('gpt-4'), prompt: '...' });
332
- await generateText({ model: deepseek('deepseek-chat'), prompt: '...' });
333
- ```
229
+ 1. When loaded, the provider creates an `@ai-sdk/openai-compatible` instance
230
+ 2. On first model request or `listModels()` call, it fetches `/models` from your API
231
+ 3. Each model is enriched with metadata from:
232
+ - API response (context_length, max_tokens, etc.)
233
+ - `@oai2lmapi/model-metadata` pattern matching
234
+ - Your config file overrides
235
+ 4. The provider then works like any standard AI SDK provider
334
236
 
335
237
  ## License
336
238
 
337
239
  MIT
338
-
339
- ## Contributing
340
-
341
- Contributions are welcome! Please see the main repository for guidelines.
package/dist/config.d.ts CHANGED
@@ -9,7 +9,19 @@
9
9
  * - ~/.local/share/opencode/ contains data files (auth.json, etc.)
10
10
  * - ~/.config/opencode/ contains user configuration
11
11
  */
12
- import { OAI2LMProviderSettings, ModelOverride } from './types.js';
12
+ /**
13
+ * Model override configuration.
14
+ */
15
+ export interface ModelOverride {
16
+ /** Max input tokens */
17
+ maxInputTokens?: number;
18
+ /** Max output tokens */
19
+ maxOutputTokens?: number;
20
+ /** Supports native tool/function calling */
21
+ supportsToolCalling?: boolean;
22
+ /** Supports image inputs */
23
+ supportsImageInput?: boolean;
24
+ }
13
25
  /**
14
26
  * Configuration file structure for oai2lm.json
15
27
  */
@@ -18,32 +30,27 @@ export interface OAI2LMConfig {
18
30
  apiKey?: string;
19
31
  /** Base URL for API calls */
20
32
  baseURL?: string;
21
- /** Provider name (defaults to 'oai2lm') */
33
+ /** Provider ID used in OpenCode (defaults to 'oai2lm') */
22
34
  name?: string;
35
+ /** Display name shown in OpenCode UI */
36
+ displayName?: string;
23
37
  /**
24
38
  * Custom headers applied to all requests.
25
- *
26
- * When combined with override headers (e.g. from model overrides or
27
- * runtime settings), config file headers are applied first and then
28
- * override headers are spread on top. This means any override header
29
- * with the same key will replace the corresponding config file value.
30
39
  */
31
40
  headers?: Record<string, string>;
32
- /** Auto-discover models on initialization (default: true) */
33
- autoDiscoverModels?: boolean;
34
41
  /** Per-model configuration overrides (supports wildcards) */
35
42
  modelOverrides?: Record<string, ModelOverride>;
43
+ /** Filter function pattern - only include models matching this pattern */
44
+ modelFilter?: string;
36
45
  }
37
46
  /**
38
47
  * Get the OpenCode data directory path
39
48
  * Follows XDG Base Directory Specification
40
- * Note: XDG spec requires absolute paths; relative paths are ignored
41
49
  */
42
50
  export declare function getDataDir(): string;
43
51
  /**
44
52
  * Get the OpenCode config directory path
45
53
  * Follows XDG Base Directory Specification
46
- * Note: XDG spec requires absolute paths; relative paths are ignored
47
54
  */
48
55
  export declare function getConfigDir(): string;
49
56
  /**
@@ -57,40 +64,16 @@ export declare const CONFIG_FILENAME = "oai2lm.json";
57
64
  * 1. ~/.local/share/opencode/oai2lm.json (data directory)
58
65
  * 2. ~/.config/opencode/oai2lm.json (config directory)
59
66
  *
60
- * The data directory location takes precedence over the config directory;
61
- * the first readable file found in this order is used.
67
+ * @returns Merged configuration or undefined if no config found
62
68
  */
63
69
  export declare function loadConfig(): OAI2LMConfig | undefined;
64
70
  /**
65
- * Load API key from environment or config
66
- *
67
- * Priority:
68
- * 1. Explicit apiKey in settings
69
- * 2. Environment variable OAI2LM_API_KEY
70
- * 3. Config file apiKey
71
- */
72
- export declare function resolveApiKey(explicitKey?: string, config?: OAI2LMConfig): string | undefined;
73
- /**
74
- * Load base URL from environment or config
75
- *
76
- * Priority:
77
- * 1. Explicit baseURL in settings
78
- * 2. Environment variable OAI2LM_BASE_URL
79
- * 3. Config file baseURL
80
- * 4. Default: https://api.openai.com/v1
81
- */
82
- export declare function resolveBaseURL(explicitURL?: string, config?: OAI2LMConfig): string;
83
- /**
84
- * Create provider settings from config file and overrides
85
- *
86
- * This is a convenience function that:
87
- * 1. Loads config from oai2lm.json
88
- * 2. Applies explicit settings as overrides
89
- * 3. Returns complete settings ready for provider creation
71
+ * Get the path to the configuration file if it exists.
90
72
  */
91
- export declare function createSettingsFromConfig(overrides?: Partial<OAI2LMProviderSettings>): OAI2LMProviderSettings;
73
+ export declare function getConfigFilePath(): string | undefined;
92
74
  /**
93
- * Get the path to the config file (for user guidance)
75
+ * Resolve API key from config or environment variable.
76
+ * Supports {env:VAR} and {file:path} syntax.
94
77
  */
95
- export declare function getConfigFilePath(): string;
78
+ export declare function resolveApiKey(config: OAI2LMConfig): string | undefined;
96
79
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAMnC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAuB7C;;;;;;;;;GASG;AACH,wBAAgB,UAAU,IAAI,YAAY,GAAG,SAAS,CAcrD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,GAAG,SAAS,CAYpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,CAkBR;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAC1C,sBAAsB,CAkCxB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uBAAuB;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wBAAwB;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4BAA4B;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC/C,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAMnC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAwB7C;;;;;;;;GAQG;AACH,wBAAgB,UAAU,IAAI,YAAY,GAAG,SAAS,CA6BrD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAYtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CA0BtE"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Model discovery: fetch models from OpenAI-compatible /models endpoint
3
+ */
4
+ /**
5
+ * Partial metadata extracted from API response
6
+ */
7
+ export interface PartialModelMetadata {
8
+ maxInputTokens?: number;
9
+ maxOutputTokens?: number;
10
+ supportsToolCalling?: boolean;
11
+ supportsImageInput?: boolean;
12
+ }
13
+ /**
14
+ * Discovered model from API
15
+ */
16
+ export interface DiscoveredModel {
17
+ id: string;
18
+ name?: string;
19
+ object: string;
20
+ created?: number;
21
+ owned_by?: string;
22
+ metadata?: PartialModelMetadata;
23
+ }
24
+ /**
25
+ * Fetch models from the OpenAI-compatible /models endpoint
26
+ */
27
+ export declare function discoverModels(baseURL: string, apiKey: string, headers?: Record<string, string>): Promise<DiscoveredModel[]>;
28
+ //# sourceMappingURL=discover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC;AA2BD;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,eAAe,EAAE,CAAC,CA8B5B"}