@revojs/ai 0.2.20 → 0.2.22
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 +34 -7
- package/dist/index.d.ts +76 -2
- package/dist/index.js +70 -3
- package/dist/module/index.d.ts +5 -0
- package/dist/module/index.js +11 -4
- package/dist/providers/anthropic.d.ts +5 -26
- package/dist/providers/anthropic.js +5 -28
- package/dist/providers/deepseek.d.ts +5 -12
- package/dist/providers/deepseek.js +5 -14
- package/dist/providers/google.d.ts +5 -22
- package/dist/providers/google.js +5 -24
- package/dist/providers/moonshotai.d.ts +5 -18
- package/dist/providers/moonshotai.js +5 -20
- package/dist/providers/openai.d.ts +5 -26
- package/dist/providers/openai.js +6 -29
- package/dist/providers/opencode-go.d.ts +6 -97
- package/dist/providers/opencode-go.js +16 -100
- package/dist/providers/opencode.d.ts +5 -160
- package/dist/providers/opencode.js +20 -166
- package/dist/providers/xai.d.ts +5 -14
- package/dist/providers/xai.js +5 -16
- package/dist/routes/v1/model-context-protocol/delete.d.ts +1 -2
- package/dist/routes/v1/model-context-protocol/delete.js +1 -1
- package/dist/routes/v1/model-context-protocol/get.d.ts +1 -2
- package/dist/routes/v1/model-context-protocol/get.js +1 -1
- package/dist/routes/v1/model-context-protocol/post.d.ts +1 -2
- package/dist/routes/v1/model-context-protocol/post.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -207,10 +207,37 @@ server-side `opencodeApiKey` variable. Supply a stable `x-opencode-session` head
|
|
|
207
207
|
for every request, normally the conversation ID. Caller headers cannot override
|
|
208
208
|
authorization, and Responses requests always use `store: false`.
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
Each model's protocol follows its models.dev `provider.npm`: `@ai-sdk/openai` uses Responses
|
|
211
|
+
(or Chat Completions when `provider.shape` is `completions`), `@ai-sdk/anthropic` uses
|
|
212
|
+
Anthropic Messages, and `@ai-sdk/openai-compatible` uses Chat Completions.
|
|
213
|
+
|
|
214
|
+
## Model catalogs
|
|
215
|
+
|
|
216
|
+
Every bundled provider takes its models from the [models.dev catalog](https://models.dev)
|
|
217
|
+
at runtime instead of a hard-coded list, so new models work as soon as models.dev lists
|
|
218
|
+
them, without a package release. IDs that models.dev does not list are rejected as unknown
|
|
219
|
+
models.
|
|
220
|
+
|
|
221
|
+
| Provider | models.dev ID | Protocol |
|
|
222
|
+
| ----------------------------------------- | ---------------- | ----------------------------------------------------------------- |
|
|
223
|
+
| `anthropic` | `anthropic` | Anthropic Messages |
|
|
224
|
+
| `openai` | `openai` | Responses |
|
|
225
|
+
| `deepseek`, `google`, `moonshotai`, `xai` | same as provider | Chat Completions (OpenAI-compatible endpoints) |
|
|
226
|
+
| `opencode` | `opencode` | Per model: Chat Completions, Responses, Messages or Google Models |
|
|
227
|
+
| `opencode-go` | `opencode-go` | Per model: Chat Completions, Responses or Messages |
|
|
228
|
+
|
|
229
|
+
`models()` returns the routable chat models as `Description`s (name, status, tool-call,
|
|
230
|
+
reasoning and attachment support, input/output modalities, limits and cost), so
|
|
231
|
+
applications can build model pickers and validate selections without hard-coded lists.
|
|
232
|
+
Filter on `status` (`deprecated`) and `toolCall` yourself.
|
|
233
|
+
|
|
234
|
+
The catalog is fetched once per isolate and cached. Configure it through the module's
|
|
235
|
+
`catalog` settings (defaults: `url` `https://models.dev/api.json?type=chat`, `maxAge`
|
|
236
|
+
3,600,000 ms, `timeout` 10,000 ms). A failed refresh keeps the previous catalog; without
|
|
237
|
+
one, provider setup throws.
|
|
238
|
+
|
|
239
|
+
Custom providers use the same mechanism: `useModelsDev(id, resolve)` returns `models`,
|
|
240
|
+
`textGenerate` and `textStream` for a models.dev provider, where `resolve(model, provider)`
|
|
241
|
+
returns the `TextProtocols` for a model or `undefined` to skip it.
|
|
242
|
+
`modelsDevProtocol(model, provider)` maps a model's AI SDK package to a protocol name.
|
|
243
|
+
Live availability and subscription limits stay controlled by the provider.
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export interface ToolDefinition {
|
|
|
50
50
|
export interface ToolExecutionOptions {
|
|
51
51
|
signal?: AbortSignal;
|
|
52
52
|
}
|
|
53
|
+
export interface ModelContextProtocolServerOptions {
|
|
54
|
+
filter?: (tool: ToolDescription) => boolean;
|
|
55
|
+
}
|
|
53
56
|
export interface ToolDescription extends LanguageModelFunctionTool {
|
|
54
57
|
inputSchema: JSONObject;
|
|
55
58
|
annotations?: ToolAnnotations;
|
|
@@ -585,7 +588,72 @@ export type LanguageModelFilePart = Omit<LanguageModelFile, "providerMetadata" |
|
|
|
585
588
|
providerOptions?: Record<string, JSONObject>;
|
|
586
589
|
};
|
|
587
590
|
export type Protocol<TOptions, TResult> = (options: TOptions) => PromiseLike<TResult>;
|
|
591
|
+
export type Modality = "text" | "audio" | "image" | "video" | "pdf";
|
|
592
|
+
export type Status = "alpha" | "beta" | "deprecated";
|
|
593
|
+
export type ModelsDevCatalog = Record<string, ModelsDevProvider>;
|
|
594
|
+
export type ModelsDevProtocol = "chat-completions" | "responses" | "messages" | "google-models";
|
|
595
|
+
export interface Description {
|
|
596
|
+
id: string;
|
|
597
|
+
name: string;
|
|
598
|
+
family?: string;
|
|
599
|
+
status?: Status;
|
|
600
|
+
toolCall: boolean;
|
|
601
|
+
reasoning: boolean;
|
|
602
|
+
attachment: boolean;
|
|
603
|
+
input: Array<Modality>;
|
|
604
|
+
output: Array<Modality>;
|
|
605
|
+
contextTokens?: number;
|
|
606
|
+
outputTokens?: number;
|
|
607
|
+
cost?: Cost;
|
|
608
|
+
}
|
|
609
|
+
export interface Cost {
|
|
610
|
+
input: number;
|
|
611
|
+
output: number;
|
|
612
|
+
cacheRead?: number;
|
|
613
|
+
cacheWrite?: number;
|
|
614
|
+
}
|
|
615
|
+
export interface TextProtocols {
|
|
616
|
+
textGenerate: Protocol<LanguageModelCallOptions, LanguageModelGenerateResult>;
|
|
617
|
+
textStream: Protocol<LanguageModelCallOptions, LanguageModelStreamResult>;
|
|
618
|
+
}
|
|
619
|
+
export interface ModelsDevModel {
|
|
620
|
+
id: string;
|
|
621
|
+
name: string;
|
|
622
|
+
type?: string;
|
|
623
|
+
family?: string;
|
|
624
|
+
status?: Status;
|
|
625
|
+
tool_call: boolean;
|
|
626
|
+
reasoning: boolean;
|
|
627
|
+
attachment: boolean;
|
|
628
|
+
modalities?: {
|
|
629
|
+
input: Array<Modality>;
|
|
630
|
+
output: Array<Modality>;
|
|
631
|
+
};
|
|
632
|
+
limit?: {
|
|
633
|
+
context?: number;
|
|
634
|
+
output?: number;
|
|
635
|
+
};
|
|
636
|
+
cost?: {
|
|
637
|
+
input: number;
|
|
638
|
+
output: number;
|
|
639
|
+
cache_read?: number;
|
|
640
|
+
cache_write?: number;
|
|
641
|
+
};
|
|
642
|
+
provider?: {
|
|
643
|
+
npm?: string;
|
|
644
|
+
api?: string;
|
|
645
|
+
shape?: "responses" | "completions";
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
export interface ModelsDevProvider {
|
|
649
|
+
id: string;
|
|
650
|
+
name: string;
|
|
651
|
+
npm: string;
|
|
652
|
+
api?: string;
|
|
653
|
+
models: Record<string, ModelsDevModel>;
|
|
654
|
+
}
|
|
588
655
|
export interface ProviderConnection {
|
|
656
|
+
models?: () => PromiseLike<Array<Description>>;
|
|
589
657
|
textGenerate?: Record<string, Protocol<LanguageModelCallOptions, LanguageModelGenerateResult>>;
|
|
590
658
|
textStream?: Record<string, Protocol<LanguageModelCallOptions, LanguageModelStreamResult>>;
|
|
591
659
|
embed?: Record<string, Protocol<EmbeddingModelCallOptions, EmbeddingModelResult>>;
|
|
@@ -667,7 +735,7 @@ export interface SkillsUploadSkillResult {
|
|
|
667
735
|
warnings: Array<SharedWarning>;
|
|
668
736
|
}
|
|
669
737
|
export interface Provider {
|
|
670
|
-
setup: (scope: Scope) => ProviderConnection
|
|
738
|
+
setup: (scope: Scope) => Awaitable<ProviderConnection>;
|
|
671
739
|
}
|
|
672
740
|
export declare class ModelContextProtocolConnection {
|
|
673
741
|
readonly client: Client;
|
|
@@ -683,10 +751,16 @@ export declare function useTools(scope: Scope): {
|
|
|
683
751
|
callTool: (name: string, input?: JSONObject, options?: ToolExecutionOptions) => Promise<CallToolResult>;
|
|
684
752
|
executeTool(call: LanguageModelToolCall, options?: ToolExecutionOptions): Promise<LanguageModelToolResultPart>;
|
|
685
753
|
};
|
|
686
|
-
export declare function handleModelContextProtocol(scope: Scope): Promise<Response>;
|
|
754
|
+
export declare function handleModelContextProtocol(scope: Scope, options?: ModelContextProtocolServerOptions): Promise<Response>;
|
|
687
755
|
export declare function useModelContextProtocol(options: ModelContextProtocolConnectOptions): Promise<ModelContextProtocolConnection>;
|
|
688
756
|
export declare function defineProvider<TProvider extends Provider>(provider: TProvider): TProvider;
|
|
689
757
|
export declare function useAi<TSource extends Source<Provider> = typeof import("#providers").default>(scope: Scope): AiConnections<TSource>;
|
|
758
|
+
export declare function useModelsDev(id: string, resolve: (model: ModelsDevModel, provider: ModelsDevProvider) => TextProtocols | undefined): Promise<{
|
|
759
|
+
models: () => Promise<Description[]>;
|
|
760
|
+
textGenerate: Record<string, Protocol<LanguageModelCallOptions<string>, LanguageModelGenerateResult>>;
|
|
761
|
+
textStream: Record<string, Protocol<LanguageModelCallOptions<string>, LanguageModelStreamResult>>;
|
|
762
|
+
}>;
|
|
763
|
+
export declare function modelsDevProtocol(model: ModelsDevModel, provider: ModelsDevProvider): ModelsDevProtocol | undefined;
|
|
690
764
|
export declare function mergeHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string>;
|
|
691
765
|
export declare function postJson(url: string, body: unknown, options?: {
|
|
692
766
|
headers?: Record<string, string | undefined>;
|
package/dist/index.js
CHANGED
|
@@ -206,7 +206,7 @@ function useTools(scope) {
|
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
async function handleModelContextProtocol(scope) {
|
|
209
|
+
async function handleModelContextProtocol(scope, options = {}) {
|
|
210
210
|
requireSameOrigin(scope);
|
|
211
211
|
const { request } = useServer(scope);
|
|
212
212
|
if (request.method !== "POST") return new Response(null, {
|
|
@@ -223,13 +223,18 @@ async function handleModelContextProtocol(scope) {
|
|
|
223
223
|
jsonSchemaValidator: new CfWorkerJsonSchemaValidator()
|
|
224
224
|
});
|
|
225
225
|
const transport = new WebStandardStreamableHTTPServerTransport({ enableJsonResponse: true });
|
|
226
|
-
|
|
226
|
+
const listTools = async () => {
|
|
227
|
+
const tools = await collection.listTools();
|
|
228
|
+
return options.filter ? tools.filter(options.filter) : tools;
|
|
229
|
+
};
|
|
230
|
+
server.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: (await listTools()).map((tool) => ({
|
|
227
231
|
name: tool.name,
|
|
228
232
|
description: tool.description,
|
|
229
233
|
inputSchema: tool.inputSchema,
|
|
230
234
|
annotations: tool.annotations
|
|
231
235
|
})) }));
|
|
232
236
|
server.server.setRequestHandler(CallToolRequestSchema, async ({ params }, extra) => {
|
|
237
|
+
if (options.filter && !(await listTools()).some((tool) => tool.name === params.name)) throw new McpError(ErrorCode.InvalidParams, `Unknown tool "${params.name}".`);
|
|
233
238
|
try {
|
|
234
239
|
return await collection.callTool(params.name, params.arguments ?? {}, { signal: AbortSignal.any([request.signal, extra.signal]) });
|
|
235
240
|
} catch (error) {
|
|
@@ -292,6 +297,7 @@ function useAi(scope) {
|
|
|
292
297
|
return protocol(options);
|
|
293
298
|
};
|
|
294
299
|
const provide = (name) => ({
|
|
300
|
+
models: () => invoke(name, "models", void 0),
|
|
295
301
|
textGenerate: (options) => invoke(name, "textGenerate", options),
|
|
296
302
|
textStream: (options) => invoke(name, "textStream", options),
|
|
297
303
|
embed: (options) => invoke(name, "embed", options),
|
|
@@ -305,6 +311,66 @@ function useAi(scope) {
|
|
|
305
311
|
});
|
|
306
312
|
return Object.fromEntries(names.map((name) => [name, provide(name)]));
|
|
307
313
|
}
|
|
314
|
+
async function useModelsDev(id, resolve) {
|
|
315
|
+
const now = Date.now();
|
|
316
|
+
if (!modelsDevCache.catalog || now - modelsDevCache.loadedAt >= config.catalog.maxAge) try {
|
|
317
|
+
const response = await globalThis.fetch(config.catalog.url, {
|
|
318
|
+
headers: { Accept: "application/json" },
|
|
319
|
+
signal: AbortSignal.timeout(config.catalog.timeout)
|
|
320
|
+
});
|
|
321
|
+
if (!response.ok) throw new Error(`models.dev responded with ${response.status}`);
|
|
322
|
+
const catalog = await response.json();
|
|
323
|
+
if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) throw new Error("models.dev returned an unexpected catalog");
|
|
324
|
+
modelsDevCache.catalog = catalog;
|
|
325
|
+
modelsDevCache.loadedAt = now;
|
|
326
|
+
} catch (error) {
|
|
327
|
+
if (!modelsDevCache.catalog) throw new Error("The models.dev catalog is unavailable.", { cause: error });
|
|
328
|
+
}
|
|
329
|
+
const provider = modelsDevCache.catalog?.[id];
|
|
330
|
+
if (provider === void 0 || typeof provider.models !== "object" || provider.models === null) throw new Error(`models.dev has no provider "${id}".`);
|
|
331
|
+
const models = new Array();
|
|
332
|
+
const textGenerate = {};
|
|
333
|
+
const textStream = {};
|
|
334
|
+
for (const model of Object.values(provider.models)) {
|
|
335
|
+
if ((model.type ?? "chat") !== "chat" || !(model.modalities?.output ?? ["text"]).includes("text")) continue;
|
|
336
|
+
const protocols = resolve(model, provider);
|
|
337
|
+
if (protocols === void 0) continue;
|
|
338
|
+
const description = {
|
|
339
|
+
id: model.id,
|
|
340
|
+
name: model.name,
|
|
341
|
+
family: model.family,
|
|
342
|
+
status: model.status,
|
|
343
|
+
toolCall: model.tool_call === true,
|
|
344
|
+
reasoning: model.reasoning === true,
|
|
345
|
+
attachment: model.attachment === true,
|
|
346
|
+
input: model.modalities?.input ?? ["text"],
|
|
347
|
+
output: model.modalities?.output ?? ["text"],
|
|
348
|
+
contextTokens: model.limit?.context,
|
|
349
|
+
outputTokens: model.limit?.output
|
|
350
|
+
};
|
|
351
|
+
if (model.cost) description.cost = {
|
|
352
|
+
input: model.cost.input,
|
|
353
|
+
output: model.cost.output,
|
|
354
|
+
cacheRead: model.cost.cache_read,
|
|
355
|
+
cacheWrite: model.cost.cache_write
|
|
356
|
+
};
|
|
357
|
+
models.push(description);
|
|
358
|
+
textGenerate[model.id] = protocols.textGenerate;
|
|
359
|
+
textStream[model.id] = protocols.textStream;
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
models: () => Promise.resolve(models),
|
|
363
|
+
textGenerate,
|
|
364
|
+
textStream
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function modelsDevProtocol(model, provider) {
|
|
368
|
+
const npm = model.provider?.npm ?? provider.npm;
|
|
369
|
+
if (npm === "@ai-sdk/anthropic") return "messages";
|
|
370
|
+
if (npm === "@ai-sdk/google") return "google-models";
|
|
371
|
+
if (npm === "@ai-sdk/openai") return model.provider?.shape === "completions" ? "chat-completions" : "responses";
|
|
372
|
+
if (npm === "@ai-sdk/openai-compatible") return "chat-completions";
|
|
373
|
+
}
|
|
308
374
|
function mergeHeaders(...headers) {
|
|
309
375
|
const merged = {};
|
|
310
376
|
for (const record of headers) for (const [name, value] of Object.entries(record ?? {})) if (value !== void 0) merged[name] = value;
|
|
@@ -353,5 +419,6 @@ function toStream(read) {
|
|
|
353
419
|
}
|
|
354
420
|
});
|
|
355
421
|
}
|
|
422
|
+
var modelsDevCache = { loadedAt: 0 };
|
|
356
423
|
//#endregion
|
|
357
|
-
export { ModelContextProtocolConnection, defineProvider, defineTool, handleModelContextProtocol, mergeHeaders, postJson, readDataFrames, toStream, useAi, useModelContextProtocol, useTools };
|
|
424
|
+
export { ModelContextProtocolConnection, defineProvider, defineTool, handleModelContextProtocol, mergeHeaders, modelsDevProtocol, postJson, readDataFrames, toStream, useAi, useModelContextProtocol, useModelsDev, useTools };
|
package/dist/module/index.d.ts
CHANGED
package/dist/module/index.js
CHANGED
|
@@ -3,10 +3,17 @@ import { defineModule, useModule } from "revojs/module";
|
|
|
3
3
|
//#region src/module/index.ts
|
|
4
4
|
var module_default = defineModule({
|
|
5
5
|
name: "ai",
|
|
6
|
-
config: () => ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
config: () => ({
|
|
7
|
+
catalog: {
|
|
8
|
+
url: "https://models.dev/api.json?type=chat",
|
|
9
|
+
maxAge: 36e5,
|
|
10
|
+
timeout: 1e4
|
|
11
|
+
},
|
|
12
|
+
modelContextProtocol: {
|
|
13
|
+
name: "revojs",
|
|
14
|
+
version: "1.0.0"
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
10
17
|
modules: [server],
|
|
11
18
|
setup(config) {
|
|
12
19
|
const { fromModule } = useModule(import.meta.url);
|
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
setup: (scope: import("revojs").Scope) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"claude-opus-4-8": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
8
|
-
"claude-opus-4-7": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
9
|
-
"claude-opus-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
10
|
-
"claude-opus-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
11
|
-
"claude-sonnet-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
12
|
-
"claude-sonnet-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
13
|
-
"claude-haiku-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
14
|
-
};
|
|
15
|
-
textStream: {
|
|
16
|
-
"claude-sonnet-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
17
|
-
"claude-opus-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
18
|
-
"claude-fable-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
19
|
-
"claude-opus-4-8": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
20
|
-
"claude-opus-4-7": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
21
|
-
"claude-opus-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
22
|
-
"claude-opus-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
23
|
-
"claude-sonnet-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
24
|
-
"claude-sonnet-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
25
|
-
"claude-haiku-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
2
|
+
setup: (scope: import("revojs").Scope) => Promise<{
|
|
3
|
+
models: () => Promise<import("../index").Description[]>;
|
|
4
|
+
textGenerate: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>>;
|
|
5
|
+
textStream: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>>;
|
|
6
|
+
}>;
|
|
28
7
|
};
|
|
29
8
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineProvider } from "../index.js";
|
|
1
|
+
import { defineProvider, useModelsDev } from "../index.js";
|
|
2
2
|
import { messagesGenerateProtocol, messagesStreamProtocol } from "../protocols/anthropic-messages.js";
|
|
3
3
|
import { useVariables } from "revojs";
|
|
4
4
|
//#region src/providers/anthropic.ts
|
|
@@ -7,34 +7,11 @@ var anthropic_default = defineProvider({ setup: (scope) => {
|
|
|
7
7
|
baseURL: "https://api.anthropic.com/v1",
|
|
8
8
|
apiKey: useVariables(scope).anthropicApiKey
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
textGenerate: {
|
|
14
|
-
"claude-sonnet-5": messagesGenerate,
|
|
15
|
-
"claude-opus-5": messagesGenerate,
|
|
16
|
-
"claude-fable-5": messagesGenerate,
|
|
17
|
-
"claude-opus-4-8": messagesGenerate,
|
|
18
|
-
"claude-opus-4-7": messagesGenerate,
|
|
19
|
-
"claude-opus-4-6": messagesGenerate,
|
|
20
|
-
"claude-opus-4-5": messagesGenerate,
|
|
21
|
-
"claude-sonnet-4-6": messagesGenerate,
|
|
22
|
-
"claude-sonnet-4-5": messagesGenerate,
|
|
23
|
-
"claude-haiku-4-5": messagesGenerate
|
|
24
|
-
},
|
|
25
|
-
textStream: {
|
|
26
|
-
"claude-sonnet-5": messagesStream,
|
|
27
|
-
"claude-opus-5": messagesStream,
|
|
28
|
-
"claude-fable-5": messagesStream,
|
|
29
|
-
"claude-opus-4-8": messagesStream,
|
|
30
|
-
"claude-opus-4-7": messagesStream,
|
|
31
|
-
"claude-opus-4-6": messagesStream,
|
|
32
|
-
"claude-opus-4-5": messagesStream,
|
|
33
|
-
"claude-sonnet-4-6": messagesStream,
|
|
34
|
-
"claude-sonnet-4-5": messagesStream,
|
|
35
|
-
"claude-haiku-4-5": messagesStream
|
|
36
|
-
}
|
|
10
|
+
const protocols = {
|
|
11
|
+
textGenerate: messagesGenerateProtocol(config),
|
|
12
|
+
textStream: messagesStreamProtocol(config)
|
|
37
13
|
};
|
|
14
|
+
return useModelsDev("anthropic", () => protocols);
|
|
38
15
|
} });
|
|
39
16
|
//#endregion
|
|
40
17
|
export { anthropic_default as default };
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
setup: (scope: import("revojs").Scope) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
textStream: {
|
|
9
|
-
"deepseek-v4-pro": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
10
|
-
"deepseek-v4-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
11
|
-
"deepseek-v4-flash-vision-exp": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
2
|
+
setup: (scope: import("revojs").Scope) => Promise<{
|
|
3
|
+
models: () => Promise<import("../index").Description[]>;
|
|
4
|
+
textGenerate: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>>;
|
|
5
|
+
textStream: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>>;
|
|
6
|
+
}>;
|
|
14
7
|
};
|
|
15
8
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineProvider } from "../index.js";
|
|
1
|
+
import { defineProvider, useModelsDev } from "../index.js";
|
|
2
2
|
import { chatCompletionsGenerateProtocol, chatCompletionsStreamProtocol } from "../protocols/openai-chat-completions.js";
|
|
3
3
|
import { useVariables } from "revojs";
|
|
4
4
|
//#region src/providers/deepseek.ts
|
|
@@ -7,20 +7,11 @@ var deepseek_default = defineProvider({ setup: (scope) => {
|
|
|
7
7
|
baseURL: "https://api.deepseek.com/v1",
|
|
8
8
|
apiKey: useVariables(scope).deepseekApiKey
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
textGenerate: {
|
|
14
|
-
"deepseek-v4-pro": chatCompletionsGenerate,
|
|
15
|
-
"deepseek-v4-flash": chatCompletionsGenerate,
|
|
16
|
-
"deepseek-v4-flash-vision-exp": chatCompletionsGenerate
|
|
17
|
-
},
|
|
18
|
-
textStream: {
|
|
19
|
-
"deepseek-v4-pro": chatCompletionsStream,
|
|
20
|
-
"deepseek-v4-flash": chatCompletionsStream,
|
|
21
|
-
"deepseek-v4-flash-vision-exp": chatCompletionsStream
|
|
22
|
-
}
|
|
10
|
+
const protocols = {
|
|
11
|
+
textGenerate: chatCompletionsGenerateProtocol(config),
|
|
12
|
+
textStream: chatCompletionsStreamProtocol(config)
|
|
23
13
|
};
|
|
14
|
+
return useModelsDev("deepseek", () => protocols);
|
|
24
15
|
} });
|
|
25
16
|
//#endregion
|
|
26
17
|
export { deepseek_default as default };
|
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
setup: (scope: import("revojs").Scope) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"gemini-3.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
8
|
-
"gemini-3.1-pro-preview": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
9
|
-
"gemini-2.5-pro": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
10
|
-
"gemini-2.5-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
11
|
-
"gemini-2.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
12
|
-
};
|
|
13
|
-
textStream: {
|
|
14
|
-
"gemini-3.7-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
15
|
-
"gemini-3.6-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
16
|
-
"gemini-3.5-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
17
|
-
"gemini-3.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
18
|
-
"gemini-3.1-pro-preview": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
19
|
-
"gemini-2.5-pro": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
20
|
-
"gemini-2.5-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
21
|
-
"gemini-2.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
2
|
+
setup: (scope: import("revojs").Scope) => Promise<{
|
|
3
|
+
models: () => Promise<import("../index").Description[]>;
|
|
4
|
+
textGenerate: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>>;
|
|
5
|
+
textStream: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>>;
|
|
6
|
+
}>;
|
|
24
7
|
};
|
|
25
8
|
export default _default;
|
package/dist/providers/google.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineProvider } from "../index.js";
|
|
1
|
+
import { defineProvider, useModelsDev } from "../index.js";
|
|
2
2
|
import { chatCompletionsGenerateProtocol, chatCompletionsStreamProtocol } from "../protocols/openai-chat-completions.js";
|
|
3
3
|
import { useVariables } from "revojs";
|
|
4
4
|
//#region src/providers/google.ts
|
|
@@ -7,30 +7,11 @@ var google_default = defineProvider({ setup: (scope) => {
|
|
|
7
7
|
baseURL: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
8
8
|
apiKey: useVariables(scope).googleApiKey
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
textGenerate: {
|
|
14
|
-
"gemini-3.7-flash": chatCompletionsGenerate,
|
|
15
|
-
"gemini-3.6-flash": chatCompletionsGenerate,
|
|
16
|
-
"gemini-3.5-flash": chatCompletionsGenerate,
|
|
17
|
-
"gemini-3.5-flash-lite": chatCompletionsGenerate,
|
|
18
|
-
"gemini-3.1-pro-preview": chatCompletionsGenerate,
|
|
19
|
-
"gemini-2.5-pro": chatCompletionsGenerate,
|
|
20
|
-
"gemini-2.5-flash": chatCompletionsGenerate,
|
|
21
|
-
"gemini-2.5-flash-lite": chatCompletionsGenerate
|
|
22
|
-
},
|
|
23
|
-
textStream: {
|
|
24
|
-
"gemini-3.7-flash": chatCompletionsStream,
|
|
25
|
-
"gemini-3.6-flash": chatCompletionsStream,
|
|
26
|
-
"gemini-3.5-flash": chatCompletionsStream,
|
|
27
|
-
"gemini-3.5-flash-lite": chatCompletionsStream,
|
|
28
|
-
"gemini-3.1-pro-preview": chatCompletionsStream,
|
|
29
|
-
"gemini-2.5-pro": chatCompletionsStream,
|
|
30
|
-
"gemini-2.5-flash": chatCompletionsStream,
|
|
31
|
-
"gemini-2.5-flash-lite": chatCompletionsStream
|
|
32
|
-
}
|
|
10
|
+
const protocols = {
|
|
11
|
+
textGenerate: chatCompletionsGenerateProtocol(config),
|
|
12
|
+
textStream: chatCompletionsStreamProtocol(config)
|
|
33
13
|
};
|
|
14
|
+
return useModelsDev("google", () => protocols);
|
|
34
15
|
} });
|
|
35
16
|
//#endregion
|
|
36
17
|
export { google_default as default };
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
setup: (scope: import("revojs").Scope) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"kimi-k2.6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
8
|
-
"kimi-k2-thinking": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
9
|
-
"kimi-k2-thinking-turbo": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
10
|
-
};
|
|
11
|
-
textStream: {
|
|
12
|
-
"kimi-k3": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
13
|
-
"kimi-k2.7-code": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
14
|
-
"kimi-k2.7-code-highspeed": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
15
|
-
"kimi-k2.6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
16
|
-
"kimi-k2-thinking": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
17
|
-
"kimi-k2-thinking-turbo": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
2
|
+
setup: (scope: import("revojs").Scope) => Promise<{
|
|
3
|
+
models: () => Promise<import("../index").Description[]>;
|
|
4
|
+
textGenerate: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>>;
|
|
5
|
+
textStream: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>>;
|
|
6
|
+
}>;
|
|
20
7
|
};
|
|
21
8
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineProvider } from "../index.js";
|
|
1
|
+
import { defineProvider, useModelsDev } from "../index.js";
|
|
2
2
|
import { chatCompletionsGenerateProtocol, chatCompletionsStreamProtocol } from "../protocols/openai-chat-completions.js";
|
|
3
3
|
import { useVariables } from "revojs";
|
|
4
4
|
//#region src/providers/moonshotai.ts
|
|
@@ -7,26 +7,11 @@ var moonshotai_default = defineProvider({ setup: (scope) => {
|
|
|
7
7
|
baseURL: "https://api.moonshot.ai/v1",
|
|
8
8
|
apiKey: useVariables(scope).moonshotaiApiKey
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
textGenerate: {
|
|
14
|
-
"kimi-k3": chatCompletionsGenerate,
|
|
15
|
-
"kimi-k2.7-code": chatCompletionsGenerate,
|
|
16
|
-
"kimi-k2.7-code-highspeed": chatCompletionsGenerate,
|
|
17
|
-
"kimi-k2.6": chatCompletionsGenerate,
|
|
18
|
-
"kimi-k2-thinking": chatCompletionsGenerate,
|
|
19
|
-
"kimi-k2-thinking-turbo": chatCompletionsGenerate
|
|
20
|
-
},
|
|
21
|
-
textStream: {
|
|
22
|
-
"kimi-k3": chatCompletionsStream,
|
|
23
|
-
"kimi-k2.7-code": chatCompletionsStream,
|
|
24
|
-
"kimi-k2.7-code-highspeed": chatCompletionsStream,
|
|
25
|
-
"kimi-k2.6": chatCompletionsStream,
|
|
26
|
-
"kimi-k2-thinking": chatCompletionsStream,
|
|
27
|
-
"kimi-k2-thinking-turbo": chatCompletionsStream
|
|
28
|
-
}
|
|
10
|
+
const protocols = {
|
|
11
|
+
textGenerate: chatCompletionsGenerateProtocol(config),
|
|
12
|
+
textStream: chatCompletionsStreamProtocol(config)
|
|
29
13
|
};
|
|
14
|
+
return useModelsDev("moonshotai", () => protocols);
|
|
30
15
|
} });
|
|
31
16
|
//#endregion
|
|
32
17
|
export { moonshotai_default as default };
|
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
setup: (scope: import("revojs").Scope) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"gpt-5.2": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
8
|
-
"gpt-5.1": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
9
|
-
"gpt-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
10
|
-
"gpt-5-mini": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
11
|
-
"gpt-5-nano": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
12
|
-
"gpt-4.1": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
13
|
-
"gpt-4o": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
14
|
-
};
|
|
15
|
-
textStream: {
|
|
16
|
-
"gpt-5.6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
17
|
-
"gpt-5.5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
18
|
-
"gpt-5.4": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
19
|
-
"gpt-5.2": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
20
|
-
"gpt-5.1": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
21
|
-
"gpt-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
22
|
-
"gpt-5-mini": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
23
|
-
"gpt-5-nano": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
24
|
-
"gpt-4.1": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
25
|
-
"gpt-4o": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
2
|
+
setup: (scope: import("revojs").Scope) => Promise<{
|
|
3
|
+
models: () => Promise<import("../index").Description[]>;
|
|
4
|
+
textGenerate: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>>;
|
|
5
|
+
textStream: Record<string, import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>>;
|
|
6
|
+
}>;
|
|
28
7
|
};
|
|
29
8
|
export default _default;
|