@opencode/ai 2.2.7 → 2.3.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 +114 -96
- package/dist/effect.d.ts +8 -7
- package/dist/effect.js +2 -1
- package/dist/experimental.d.ts +0 -4
- package/dist/experimental.js +0 -3
- package/dist/image-client.d.ts +1 -1
- package/dist/image-client.js +2 -6
- package/dist/index.d.ts +11 -48
- package/dist/index.js +30 -13
- package/dist/media-model.d.ts +2 -0
- package/dist/media-model.js +3 -1
- package/dist/media.d.ts +9 -3
- package/dist/media.js +27 -7
- package/dist/protocols/google-decisions.d.ts +13 -0
- package/dist/protocols/google-decisions.js +133 -0
- package/dist/protocols/google-interactions-video.d.ts +43 -0
- package/dist/protocols/google-interactions-video.js +186 -0
- package/dist/protocols/google-interactions.d.ts +14 -1
- package/dist/protocols/google-interactions.js +1 -1
- package/dist/protocols/index.d.ts +1 -0
- package/dist/protocols/index.js +1 -0
- package/dist/protocols/minimax-video.d.ts +54 -0
- package/dist/protocols/minimax-video.js +292 -0
- package/dist/protocols/openrouter-video.d.ts +41 -0
- package/dist/protocols/openrouter-video.js +138 -0
- package/dist/protocols/seedance-video.d.ts +50 -0
- package/dist/protocols/seedance-video.js +216 -0
- package/dist/protocols/system-one.d.ts +45 -1
- package/dist/protocols/system-one.js +42 -7
- package/dist/protocols/utils/responses-compaction.js +1 -1
- package/dist/protocols/xai-video.d.ts +8 -2
- package/dist/protocols/xai-video.js +20 -15
- package/dist/provider-error.js +7 -1
- package/dist/providers/byteplus/videos.d.ts +2 -0
- package/dist/providers/byteplus/videos.js +1 -0
- package/dist/providers/byteplus.d.ts +26 -0
- package/dist/providers/byteplus.js +21 -0
- package/dist/providers/google/decisions.d.ts +2 -0
- package/dist/providers/google/decisions.js +1 -0
- package/dist/providers/google/videos.d.ts +2 -0
- package/dist/providers/google/videos.js +1 -0
- package/dist/providers/google.d.ts +11 -4
- package/dist/providers/google.js +13 -3
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.js +2 -1
- package/dist/providers/minimax/videos.d.ts +3 -0
- package/dist/providers/minimax/videos.js +1 -0
- package/dist/providers/minimax.d.ts +6 -1
- package/dist/providers/minimax.js +10 -1
- package/dist/providers/openai-compatible/decisions.d.ts +2 -0
- package/dist/providers/openai-compatible/decisions.js +1 -0
- package/dist/providers/openai-compatible.d.ts +2 -0
- package/dist/providers/openai-compatible.js +14 -0
- package/dist/providers/openrouter/videos.d.ts +2 -0
- package/dist/providers/openrouter/videos.js +1 -0
- package/dist/providers/openrouter.d.ts +5 -0
- package/dist/providers/openrouter.js +8 -0
- package/dist/providers/volcengine/videos.d.ts +2 -0
- package/dist/providers/volcengine/videos.js +1 -0
- package/dist/providers/volcengine.d.ts +26 -0
- package/dist/providers/volcengine.js +21 -0
- package/dist/public.d.ts +2 -0
- package/dist/public.js +1 -0
- package/dist/route/executor-service.d.ts +6 -0
- package/dist/route/executor-service.js +7 -0
- package/dist/route/executor.d.ts +7 -1
- package/dist/route/executor.js +7 -2
- package/dist/route/media-protocol.d.ts +12 -11
- package/dist/route/media.d.ts +2 -0
- package/dist/route/media.js +31 -22
- package/dist/route/transport/http.js +1 -1
- package/dist/schema/messages.d.ts +1 -1
- package/dist/schema/messages.js +1 -5
- package/dist/schema/options.d.ts +8 -0
- package/dist/schema/options.js +1 -0
- package/dist/speech-client.d.ts +1 -1
- package/dist/speech-client.js +4 -4
- package/dist/transcription-client.d.ts +1 -1
- package/dist/transcription-client.js +1 -2
- package/dist/video-client.d.ts +16 -84
- package/dist/video-client.js +28 -13
- package/dist/video.d.ts +56 -1072
- package/dist/video.js +28 -65
- package/package.json +55 -7
- package/dist/protocols/google-video.d.ts +0 -26
- package/dist/protocols/google-video.js +0 -146
- package/dist/protocols/runway-video.d.ts +0 -38
- package/dist/protocols/runway-video.js +0 -141
- package/dist/providers/runway.d.ts +0 -20
- package/dist/providers/runway.js +0 -17
|
@@ -3,15 +3,17 @@ import type { ProviderPackage } from "../provider-package.js";
|
|
|
3
3
|
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
4
4
|
import { Gemini } from "../protocols/gemini.js";
|
|
5
5
|
import { type OptionsInput as GoogleEmbeddingOptionsInput } from "../protocols/google-embed-content.js";
|
|
6
|
+
import { GoogleDecisions } from "../protocols/google-decisions.js";
|
|
6
7
|
import { GoogleInteractions } from "../protocols/google-interactions.js";
|
|
7
8
|
export type { OptionsInput as GoogleEmbeddingOptions } from "../protocols/google-embed-content.js";
|
|
8
9
|
export type { GoogleImageOptions } from "../protocols/google-images.js";
|
|
10
|
+
export type { GoogleVideoOptions } from "../protocols/google-interactions-video.js";
|
|
9
11
|
export type { GoogleSpeechOptions } from "../protocols/google-speech.js";
|
|
10
12
|
export type { GoogleTranscriptionOptions } from "../protocols/google-transcription.js";
|
|
11
|
-
export type { GoogleVideoOptions } from "../protocols/google-video.js";
|
|
12
13
|
export type GeminiOptionsInput = Gemini.OptionsInput;
|
|
13
14
|
export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput;
|
|
14
15
|
export type GoogleInteractionsOptionsInput = GoogleInteractions.OptionsInput;
|
|
16
|
+
export type GoogleDecisionsOptionsInput = GoogleDecisions.OptionsInput;
|
|
15
17
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
16
18
|
export declare const routes: (import("../route.js").Route<{
|
|
17
19
|
readonly cachedContent?: string | undefined;
|
|
@@ -180,10 +182,11 @@ export declare const configure: (input?: Config) => {
|
|
|
180
182
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
181
183
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
182
184
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
183
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-video.js").GoogleVideoOptions>;
|
|
185
|
+
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-interactions-video.js").GoogleVideoOptions>;
|
|
184
186
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/google-speech.js").GoogleSpeechOptions>;
|
|
185
187
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/google-transcription.js").GoogleTranscriptionOptions>;
|
|
186
188
|
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
189
|
+
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<GoogleDecisions.OptionsInput>;
|
|
187
190
|
configure: typeof configure;
|
|
188
191
|
};
|
|
189
192
|
export declare const provider: {
|
|
@@ -198,16 +201,20 @@ export declare const provider: {
|
|
|
198
201
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
199
202
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
200
203
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
201
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-video.js").GoogleVideoOptions>;
|
|
204
|
+
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-interactions-video.js").GoogleVideoOptions>;
|
|
202
205
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/google-speech.js").GoogleSpeechOptions>;
|
|
203
206
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/google-transcription.js").GoogleTranscriptionOptions>;
|
|
204
207
|
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
208
|
+
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<GoogleDecisions.OptionsInput>;
|
|
205
209
|
configure: typeof configure;
|
|
206
210
|
};
|
|
207
211
|
export declare const model: ProviderPackage.Model<Settings, Gemini.ProviderOptionsInput>;
|
|
208
212
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
213
|
+
export declare const videoModel: (modelID: string, settings?: Settings) => import("../video.js").VideoModel<import("../protocols/google-interactions-video.js").GoogleVideoOptions>;
|
|
209
214
|
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
215
|
+
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<GoogleDecisions.OptionsInput>;
|
|
210
216
|
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
217
|
+
export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-interactions-video.js").GoogleVideoOptions>;
|
|
211
218
|
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
212
219
|
export declare const gemini: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<Gemini.OptionsInput, import("../route.js").CompactionOperations | undefined>;
|
|
213
220
|
export declare const interactions: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
@@ -217,6 +224,6 @@ export declare const interactions: (modelID: string | ModelID) => import("../sch
|
|
|
217
224
|
readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
|
|
218
225
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
219
226
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
220
|
-
export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-video.js").GoogleVideoOptions>;
|
|
221
227
|
export declare const speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/google-speech.js").GoogleSpeechOptions>;
|
|
222
228
|
export declare const transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/google-transcription.js").GoogleTranscriptionOptions>;
|
|
229
|
+
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<GoogleDecisions.OptionsInput>;
|
package/dist/providers/google.js
CHANGED
|
@@ -4,11 +4,12 @@ import { MediaRoute } from "../route/media.js";
|
|
|
4
4
|
import { ProviderID } from "../schema/index.js";
|
|
5
5
|
import { Gemini } from "../protocols/gemini.js";
|
|
6
6
|
import { GoogleEmbedContent, } from "../protocols/google-embed-content.js";
|
|
7
|
+
import { GoogleDecisions } from "../protocols/google-decisions.js";
|
|
7
8
|
import { GoogleInteractions } from "../protocols/google-interactions.js";
|
|
9
|
+
import { GoogleInteractionsVideo } from "../protocols/google-interactions-video.js";
|
|
8
10
|
import { GoogleImages } from "../protocols/google-images.js";
|
|
9
11
|
import { GoogleSpeech } from "../protocols/google-speech.js";
|
|
10
12
|
import { GoogleTranscription } from "../protocols/google-transcription.js";
|
|
11
|
-
import { GoogleVideo } from "../protocols/google-video.js";
|
|
12
13
|
import { toConfig } from "./settings.js";
|
|
13
14
|
export const id = ProviderID.make("google");
|
|
14
15
|
export const routes = [Gemini.route, GoogleInteractions.route];
|
|
@@ -38,10 +39,13 @@ export const configure = (input = {}) => {
|
|
|
38
39
|
gemini,
|
|
39
40
|
interactions: (modelID) => interactionsRoute(input).model({ id: modelID }),
|
|
40
41
|
image: (modelID, providerOptions) => GoogleImages.model({ ...media, id: modelID, providerOptions }),
|
|
41
|
-
video: (modelID) =>
|
|
42
|
+
video: (modelID) => GoogleInteractionsVideo.model({ ...media, id: modelID }),
|
|
42
43
|
speech: (modelID) => GoogleSpeech.model({ ...media, id: modelID }),
|
|
43
44
|
transcription: (modelID) => GoogleTranscription.model({ ...media, id: modelID }),
|
|
44
45
|
embedding: (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions }),
|
|
46
|
+
decision: (modelID, providerOptions) => GoogleDecisions.route
|
|
47
|
+
.with({ endpoint: { baseURL: media.baseURL }, auth: media.auth, headers: media.headers, http: media.http })
|
|
48
|
+
.model({ id: modelID, providerOptions }),
|
|
45
49
|
configure,
|
|
46
50
|
};
|
|
47
51
|
};
|
|
@@ -51,14 +55,20 @@ export const imageModel = (modelID, settings) => {
|
|
|
51
55
|
const input = toConfig(settings);
|
|
52
56
|
return configure(input).image(modelID, input.providerOptions);
|
|
53
57
|
};
|
|
58
|
+
export const videoModel = (modelID, settings) => configure(toConfig(settings)).video(modelID);
|
|
54
59
|
export const embeddingModel = (modelID, settings) => {
|
|
55
60
|
const input = toConfig(settings);
|
|
56
61
|
return configure(input).embedding(modelID, input.providerOptions);
|
|
57
62
|
};
|
|
63
|
+
export const decisionModel = (modelID, settings) => {
|
|
64
|
+
const input = toConfig(settings);
|
|
65
|
+
return configure(input).decision(modelID, input.providerOptions);
|
|
66
|
+
};
|
|
58
67
|
export const image = provider.image;
|
|
68
|
+
export const video = provider.video;
|
|
59
69
|
export const embedding = provider.embedding;
|
|
60
70
|
export const gemini = provider.gemini;
|
|
61
71
|
export const interactions = provider.interactions;
|
|
62
|
-
export const video = provider.video;
|
|
63
72
|
export const speech = provider.speech;
|
|
64
73
|
export const transcription = provider.transcription;
|
|
74
|
+
export const decision = provider.decision;
|
|
@@ -6,6 +6,7 @@ export * as AmazonBedrockMantle from "./amazon-bedrock-mantle.js";
|
|
|
6
6
|
export * as AssemblyAI from "./assemblyai.js";
|
|
7
7
|
export * as Azure from "./azure.js";
|
|
8
8
|
export * as Baseten from "./baseten.js";
|
|
9
|
+
export * as BytePlus from "./byteplus.js";
|
|
9
10
|
export * as Cartesia from "./cartesia.js";
|
|
10
11
|
export * as Cerebras from "./cerebras.js";
|
|
11
12
|
export * as Cohere from "./cohere.js";
|
|
@@ -34,11 +35,11 @@ export * as OpenAICompatible from "./openai-compatible.js";
|
|
|
34
35
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
35
36
|
export * as OpenCode from "./opencode.js";
|
|
36
37
|
export * as OpenRouter from "./openrouter.js";
|
|
37
|
-
export * as Runway from "./runway.js";
|
|
38
38
|
export * as TogetherAI from "./togetherai.js";
|
|
39
39
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
40
40
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
|
41
41
|
export * as Venice from "./venice.js";
|
|
42
|
+
export * as Volcengine from "./volcengine.js";
|
|
42
43
|
export * as XAI from "./xai.js";
|
|
43
44
|
export * as ZAI from "./zai.js";
|
|
44
45
|
export * as ZAICodingPlan from "./zai-coding-plan.js";
|
package/dist/providers/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * as AmazonBedrockMantle from "./amazon-bedrock-mantle.js";
|
|
|
6
6
|
export * as AssemblyAI from "./assemblyai.js";
|
|
7
7
|
export * as Azure from "./azure.js";
|
|
8
8
|
export * as Baseten from "./baseten.js";
|
|
9
|
+
export * as BytePlus from "./byteplus.js";
|
|
9
10
|
export * as Cartesia from "./cartesia.js";
|
|
10
11
|
export * as Cerebras from "./cerebras.js";
|
|
11
12
|
export * as Cohere from "./cohere.js";
|
|
@@ -34,11 +35,11 @@ export * as OpenAICompatible from "./openai-compatible.js";
|
|
|
34
35
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
35
36
|
export * as OpenCode from "./opencode.js";
|
|
36
37
|
export * as OpenRouter from "./openrouter.js";
|
|
37
|
-
export * as Runway from "./runway.js";
|
|
38
38
|
export * as TogetherAI from "./togetherai.js";
|
|
39
39
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
40
40
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
|
41
41
|
export * as Venice from "./venice.js";
|
|
42
|
+
export * as Volcengine from "./volcengine.js";
|
|
42
43
|
export * as XAI from "./xai.js";
|
|
43
44
|
export * as ZAI from "./zai.js";
|
|
44
45
|
export * as ZAICodingPlan from "./zai-coding-plan.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { videoModel as model } from "../minimax.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
3
|
import { type MiniMaxImageOptions } from "../protocols/minimax-images.js";
|
|
4
|
+
import { type MiniMaxVideoOptions } from "../protocols/minimax-video.js";
|
|
4
5
|
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
5
6
|
import { Route } from "../route/client.js";
|
|
6
7
|
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
@@ -34,7 +35,7 @@ export type Settings<Options = MessagesOptionsInput> = ProviderPackage.Settings
|
|
|
34
35
|
readonly apiKey?: string | false;
|
|
35
36
|
readonly baseURL?: string;
|
|
36
37
|
};
|
|
37
|
-
export type { MiniMaxImageOptions };
|
|
38
|
+
export type { MiniMaxImageOptions, MiniMaxVideoOptions };
|
|
38
39
|
export declare const routes: (Route<{
|
|
39
40
|
readonly context_management?: {
|
|
40
41
|
readonly edits: readonly {
|
|
@@ -725,6 +726,7 @@ export declare const configure: (input?: Config) => {
|
|
|
725
726
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
726
727
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
727
728
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<MiniMaxImageOptions>;
|
|
729
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<MiniMaxVideoOptions>;
|
|
728
730
|
configure: typeof configure;
|
|
729
731
|
};
|
|
730
732
|
export declare const provider: {
|
|
@@ -734,12 +736,15 @@ export declare const provider: {
|
|
|
734
736
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
735
737
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
736
738
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<MiniMaxImageOptions>;
|
|
739
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<MiniMaxVideoOptions>;
|
|
737
740
|
configure: typeof configure;
|
|
738
741
|
};
|
|
739
742
|
export declare const model: ProviderPackage.Model<Settings<MessagesOptionsInput>, MessagesOptionsInput>;
|
|
740
743
|
export declare const imageModel: (modelID: string, settings?: Settings<MiniMaxImageOptions>) => import("../image.js").ImageModel<MiniMaxImageOptions>;
|
|
744
|
+
export declare const videoModel: (modelID: string, settings?: Settings<MiniMaxVideoOptions>) => import("../video.js").VideoModel<MiniMaxVideoOptions>;
|
|
741
745
|
export declare const messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<MessagesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
742
746
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
743
747
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
744
748
|
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<MiniMaxImageOptions>;
|
|
749
|
+
export declare const video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<MiniMaxVideoOptions>;
|
|
745
750
|
export * as MiniMax from "./minimax.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
3
|
import { MiniMaxImages } from "../protocols/minimax-images.js";
|
|
4
|
+
import { MiniMaxVideo } from "../protocols/minimax-video.js";
|
|
4
5
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
5
6
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
6
7
|
import { ProviderShared } from "../protocols/shared.js";
|
|
@@ -75,7 +76,10 @@ export const configure = (input = {}) => {
|
|
|
75
76
|
const responses = (modelID) => responsesRoute.with(defaults).model({ id: modelID });
|
|
76
77
|
const media = MediaRoute.deployment(input, defaults.auth);
|
|
77
78
|
const image = (modelID, providerOptions) => MiniMaxImages.model({ ...media, id: modelID, providerOptions });
|
|
78
|
-
|
|
79
|
+
// H3 is under /v2 and Hailuo under /v1, so video drops the version a shared `baseURL` carries for the other APIs.
|
|
80
|
+
const videoBaseURL = media.baseURL?.replace(/(\/v1)?\/*$/, "");
|
|
81
|
+
const video = (modelID, providerOptions) => MiniMaxVideo.model({ ...media, baseURL: videoBaseURL, id: modelID, providerOptions });
|
|
82
|
+
return { id, model: messages, messages, chat, responses, image, video, configure };
|
|
79
83
|
};
|
|
80
84
|
export const provider = configure();
|
|
81
85
|
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
@@ -83,8 +87,13 @@ export const imageModel = (modelID, settings) => {
|
|
|
83
87
|
const input = toConfig(settings);
|
|
84
88
|
return configure(input).image(modelID, input.providerOptions);
|
|
85
89
|
};
|
|
90
|
+
export const videoModel = (modelID, settings) => {
|
|
91
|
+
const input = toConfig(settings);
|
|
92
|
+
return configure(input).video(modelID, input.providerOptions);
|
|
93
|
+
};
|
|
86
94
|
export const messages = provider.messages;
|
|
87
95
|
export const chat = provider.chat;
|
|
88
96
|
export const responses = provider.responses;
|
|
89
97
|
export const image = provider.image;
|
|
98
|
+
export const video = provider.video;
|
|
90
99
|
export * as MiniMax from "./minimax.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { decisionModel as model } from "../openai-compatible.js";
|
|
@@ -194,6 +194,7 @@ export declare const configure: (input: Config) => {
|
|
|
194
194
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route.js").CompactionOperations | undefined>;
|
|
195
195
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
196
196
|
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
197
|
+
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
197
198
|
configure: typeof configure;
|
|
198
199
|
};
|
|
199
200
|
export declare const provider: {
|
|
@@ -203,4 +204,5 @@ export declare const provider: {
|
|
|
203
204
|
export declare const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
204
205
|
export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
205
206
|
export declare const embeddingModel: (modelID: string, settings: Settings) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
207
|
+
export declare const decisionModel: (modelID: string, settings: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
206
208
|
export * as OpenAICompatible from "./openai-compatible.js";
|
|
@@ -2,6 +2,7 @@ import { mergeProviderOptions, ProviderID, } from "../schema/index.js";
|
|
|
2
2
|
import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat.js";
|
|
3
3
|
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
4
4
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
5
|
+
import { SystemOne } from "../protocols/system-one.js";
|
|
5
6
|
import { MediaRoute } from "../route/media.js";
|
|
6
7
|
import { AuthOptions } from "../route/auth-options.js";
|
|
7
8
|
import { toConfig } from "./settings.js";
|
|
@@ -25,6 +26,13 @@ export const configure = (input) => {
|
|
|
25
26
|
headers: input.headers,
|
|
26
27
|
http: input.http,
|
|
27
28
|
});
|
|
29
|
+
const decisionRoute = SystemOne.route.with({
|
|
30
|
+
provider,
|
|
31
|
+
endpoint: { baseURL },
|
|
32
|
+
auth,
|
|
33
|
+
headers: input.headers,
|
|
34
|
+
http: input.http,
|
|
35
|
+
});
|
|
28
36
|
return {
|
|
29
37
|
id: ProviderID.make(provider),
|
|
30
38
|
model: (modelID) => route.model({ id: modelID }),
|
|
@@ -37,6 +45,8 @@ export const configure = (input) => {
|
|
|
37
45
|
providerOptions: mergeProviderOptions(/gpt-image|chatgpt-image/.test(modelID) ? undefined : { response_format: "b64_json" }, providerOptions),
|
|
38
46
|
}),
|
|
39
47
|
embedding: (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions }),
|
|
48
|
+
// Compatible hosts follow llama.cpp's System One API, which takes inline media in root `images` (alias of `files`).
|
|
49
|
+
decision: (modelID, providerOptions) => decisionRoute.model({ id: modelID, compatibility: { mediaInput: "root" }, providerOptions }),
|
|
40
50
|
configure,
|
|
41
51
|
};
|
|
42
52
|
};
|
|
@@ -53,6 +63,10 @@ export const embeddingModel = (modelID, settings) => {
|
|
|
53
63
|
const input = config(settings);
|
|
54
64
|
return configure(input).embedding(modelID, input.providerOptions);
|
|
55
65
|
};
|
|
66
|
+
export const decisionModel = (modelID, settings) => {
|
|
67
|
+
const input = config(settings);
|
|
68
|
+
return configure(input).decision(modelID, input.providerOptions);
|
|
69
|
+
};
|
|
56
70
|
function config({ provider, ...settings }) {
|
|
57
71
|
return { ...toConfig(settings), provider };
|
|
58
72
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { videoModel as model } from "../openrouter.js";
|
|
@@ -7,6 +7,7 @@ import type { ProviderPackage } from "../provider-package.js";
|
|
|
7
7
|
import { HttpTransport } from "../route/transport/index.js";
|
|
8
8
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
9
9
|
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
10
|
+
export type { OpenRouterVideoOptions } from "../protocols/openrouter-video.js";
|
|
10
11
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
11
12
|
export interface OpenRouterProviderRouting {
|
|
12
13
|
readonly [key: string]: unknown;
|
|
@@ -1146,6 +1147,7 @@ export declare const configure: (input?: Config) => {
|
|
|
1146
1147
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1147
1148
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1148
1149
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1150
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("./openrouter.js").OpenRouterVideoOptions>;
|
|
1149
1151
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1150
1152
|
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1151
1153
|
configure: typeof configure;
|
|
@@ -1156,6 +1158,7 @@ export declare const provider: {
|
|
|
1156
1158
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1157
1159
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1158
1160
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1161
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("./openrouter.js").OpenRouterVideoOptions>;
|
|
1159
1162
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1160
1163
|
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1161
1164
|
configure: typeof configure;
|
|
@@ -1163,11 +1166,13 @@ export declare const provider: {
|
|
|
1163
1166
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1164
1167
|
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1165
1168
|
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1169
|
+
export declare const video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("./openrouter.js").OpenRouterVideoOptions>;
|
|
1166
1170
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1167
1171
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1168
1172
|
export declare const model: ProviderPackage.Model<Settings, OpenRouterProviderOptionsInput>;
|
|
1169
1173
|
export declare const responsesModel: ProviderPackage.Model<Settings<OpenRouterResponsesProviderOptionsInput>, OpenRouterResponsesProviderOptionsInput>;
|
|
1170
1174
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1175
|
+
export declare const videoModel: (modelID: string, settings?: Settings) => import("../video.js").VideoModel<import("./openrouter.js").OpenRouterVideoOptions>;
|
|
1171
1176
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1172
1177
|
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1173
1178
|
export * as OpenRouter from "./openrouter.js";
|
|
@@ -6,6 +6,7 @@ import { ProviderID, } from "../schema/index.js";
|
|
|
6
6
|
import { SystemOne } from "../protocols/system-one.js";
|
|
7
7
|
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
8
8
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
9
|
+
import { OpenRouterVideo } from "../protocols/openrouter-video.js";
|
|
9
10
|
import { MediaRoute } from "../route/media.js";
|
|
10
11
|
import { HttpTransport } from "../route/transport/index.js";
|
|
11
12
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
@@ -155,6 +156,7 @@ export const configure = (input = {}) => {
|
|
|
155
156
|
sizing: imageSizing,
|
|
156
157
|
imageInput: "references",
|
|
157
158
|
});
|
|
159
|
+
const video = (modelID, providerOptions) => OpenRouterVideo.model({ ...media, id: modelID, providerOptions });
|
|
158
160
|
const decision = (modelID, providerOptions) => decisionRoute.model({
|
|
159
161
|
id: modelID,
|
|
160
162
|
compatibility: { mediaInput: "state" },
|
|
@@ -175,6 +177,7 @@ export const configure = (input = {}) => {
|
|
|
175
177
|
chat,
|
|
176
178
|
responses: (modelID) => configuredResponses.model({ id: modelID }),
|
|
177
179
|
image,
|
|
180
|
+
video,
|
|
178
181
|
decision,
|
|
179
182
|
embedding,
|
|
180
183
|
configure,
|
|
@@ -184,6 +187,7 @@ export const provider = configure();
|
|
|
184
187
|
export const decision = provider.decision;
|
|
185
188
|
export const embedding = provider.embedding;
|
|
186
189
|
export const image = provider.image;
|
|
190
|
+
export const video = provider.video;
|
|
187
191
|
export const chat = provider.chat;
|
|
188
192
|
export const responses = provider.responses;
|
|
189
193
|
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
@@ -192,6 +196,10 @@ export const imageModel = (modelID, settings) => {
|
|
|
192
196
|
const input = toConfig(settings);
|
|
193
197
|
return configure(input).image(modelID, input.providerOptions);
|
|
194
198
|
};
|
|
199
|
+
export const videoModel = (modelID, settings) => {
|
|
200
|
+
const input = toConfig(settings);
|
|
201
|
+
return configure(input).video(modelID, input.providerOptions);
|
|
202
|
+
};
|
|
195
203
|
export const decisionModel = (modelID, settings) => {
|
|
196
204
|
const input = toConfig(settings);
|
|
197
205
|
return configure(input).decision(modelID, input.providerOptions);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { videoModel as model } from "../volcengine.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import { type HttpOptions, type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
4
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
|
+
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
|
+
readonly baseURL?: string;
|
|
7
|
+
readonly headers?: Record<string, string>;
|
|
8
|
+
readonly http?: HttpOptions;
|
|
9
|
+
};
|
|
10
|
+
export type Settings = ProviderPackage.Settings & {
|
|
11
|
+
readonly apiKey?: string | false;
|
|
12
|
+
readonly baseURL?: string;
|
|
13
|
+
};
|
|
14
|
+
export type { SeedanceVideoOptions } from "../protocols/seedance-video.js";
|
|
15
|
+
export declare const configure: (input?: Config) => {
|
|
16
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
17
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
18
|
+
configure: typeof configure;
|
|
19
|
+
};
|
|
20
|
+
export declare const provider: {
|
|
21
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
22
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
23
|
+
configure: typeof configure;
|
|
24
|
+
};
|
|
25
|
+
export declare const videoModel: (modelID: string, settings?: Settings) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
26
|
+
export declare const video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SeedanceVideo } from "../protocols/seedance-video.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
|
+
import { MediaRoute } from "../route/media.js";
|
|
4
|
+
import { ProviderID } from "../schema/index.js";
|
|
5
|
+
import { toConfig } from "./settings.js";
|
|
6
|
+
export const id = ProviderID.make("volcengine");
|
|
7
|
+
const auth = (options) => AuthOptions.bearer(options, "ARK_API_KEY");
|
|
8
|
+
export const configure = (input = {}) => {
|
|
9
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
10
|
+
return {
|
|
11
|
+
id,
|
|
12
|
+
video: (modelID, providerOptions) => SeedanceVideo.volcengine.model({ ...media, id: modelID, providerOptions }),
|
|
13
|
+
configure,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const provider = configure();
|
|
17
|
+
export const videoModel = (modelID, settings) => {
|
|
18
|
+
const input = toConfig(settings);
|
|
19
|
+
return configure(input).video(modelID, input.providerOptions);
|
|
20
|
+
};
|
|
21
|
+
export const video = provider.video;
|
package/dist/public.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, T
|
|
|
3
3
|
export type { BaseRequest, ContentPartInput, GenerationOptionsFields, HttpOptions, RequestOptions, LanguageModelInput, LanguageModelProviderOptions, LLMRequest, MediaPartInput, RequestTimeout, TimeoutConfig, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, TransportOptions, UsageInput, } from "./schema/index.js";
|
|
4
4
|
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
5
5
|
export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
|
|
6
|
+
export { VideoAspectRatio, VideoDuration, VideoModel, VideoModelSchema, VideoResponse } from "./video.js";
|
|
7
|
+
export type { VideoJob, VideoModelOptions, VideoOptions, VideoRequest, VideoRequestInput, VideoResolution, VideoRoute, VideoStatus, } from "./video.js";
|
|
6
8
|
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
7
9
|
export type { AnswerFor, AnswersFor, DecisionInput, DecisionMediaPartInput, DecisionModelOptions, DecisionOptions, DecisionPartInput, DecisionQuestions, DecisionRequest, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
|
|
8
10
|
export { EmbeddingModel, EmbeddingModelSchema, EmbeddingResponse, EmbeddingUsage, EmbeddingValue } from "./embedding.js";
|
package/dist/public.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
2
2
|
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, GENERATION_KEYS, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, SystemMessage, UserMessage, AssistantMessage, ToolMessage, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
3
3
|
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
4
|
+
export { VideoAspectRatio, VideoDuration, VideoModel, VideoModelSchema, VideoResponse } from "./video.js";
|
|
4
5
|
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
5
6
|
export { EmbeddingModel, EmbeddingModelSchema, EmbeddingResponse, EmbeddingUsage, EmbeddingValue } from "./embedding.js";
|
|
6
7
|
export { Media } from "./media.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Context, type Effect } from "effect";
|
|
2
2
|
import type { Headers, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
3
3
|
import { HttpContext, type AIError } from "../schema/errors.js";
|
|
4
|
+
import type { ClientTls } from "../schema/options.js";
|
|
4
5
|
export interface Interface {
|
|
5
6
|
readonly execute: (request: HttpClientRequest.HttpClientRequest, middleware?: HttpMiddleware) => Effect.Effect<HttpClientResponse.HttpClientResponse, AIError>;
|
|
6
7
|
}
|
|
@@ -10,6 +11,11 @@ declare const RequestExecutorService_base: Context.ServiceClass<RequestExecutorS
|
|
|
10
11
|
export declare class RequestExecutorService extends RequestExecutorService_base {
|
|
11
12
|
}
|
|
12
13
|
export declare const Service: typeof RequestExecutorService;
|
|
14
|
+
/**
|
|
15
|
+
* The client certificate for the HTTP request being executed. Transports set it from `http.tls`; the executor's HTTP
|
|
16
|
+
* client presents it, since only the runtime's fetch can.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CurrentTls: Context.Reference<ClientTls | undefined>;
|
|
13
19
|
export type Service = RequestExecutorService;
|
|
14
20
|
export declare const headerDetails: (headers: Headers.Headers) => {
|
|
15
21
|
[k: string]: string;
|
|
@@ -3,6 +3,13 @@ import { HttpContext } from "../schema/errors.js";
|
|
|
3
3
|
export class RequestExecutorService extends Context.Service()("@opencode/AI/RequestExecutor") {
|
|
4
4
|
}
|
|
5
5
|
export const Service = RequestExecutorService;
|
|
6
|
+
/**
|
|
7
|
+
* The client certificate for the HTTP request being executed. Transports set it from `http.tls`; the executor's HTTP
|
|
8
|
+
* client presents it, since only the runtime's fetch can.
|
|
9
|
+
*/
|
|
10
|
+
export const CurrentTls = Context.Reference("@opencode/AI/RequestExecutor/CurrentTls", {
|
|
11
|
+
defaultValue: () => undefined,
|
|
12
|
+
});
|
|
6
13
|
export const headerDetails = (headers) => Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, value]));
|
|
7
14
|
export const responseHttp = (response) => new HttpContext({
|
|
8
15
|
url: response.request.url,
|
package/dist/route/executor.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { Layer, Stream } from "effect";
|
|
|
2
2
|
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
3
3
|
import { AIError } from "../schema/index.js";
|
|
4
4
|
import { Service, type HttpMiddleware, type Interface } from "./executor-service.js";
|
|
5
|
-
|
|
5
|
+
import type { ClientTls } from "../schema/options.js";
|
|
6
|
+
export { CurrentTls, responseHttp, Service } from "./executor-service.js";
|
|
6
7
|
export type { HttpHandler, HttpMiddleware, Interface, RequestExecutorService } from "./executor-service.js";
|
|
7
8
|
/** Preserve HTTP diagnostics for executor and externally captured failures alike. */
|
|
8
9
|
export declare const httpFailure: (input: {
|
|
@@ -18,6 +19,11 @@ export declare const responseStream: (response: HttpClientResponse.HttpClientRes
|
|
|
18
19
|
export declare const stream: (executor: Interface, request: HttpClientRequest.HttpClientRequest, middleware?: HttpMiddleware) => Stream.Stream<Uint8Array, AIError>;
|
|
19
20
|
export declare const layer: Layer.Layer<Service, never, HttpClient.HttpClient>;
|
|
20
21
|
export declare const fetchLayer: Layer.Layer<import("./executor-service.js").RequestExecutorService, never, never>;
|
|
22
|
+
/**
|
|
23
|
+
* Sends through `execute`, presenting `tls` on each request. Apply it only where a provider request is sent, so
|
|
24
|
+
* downloads made through the plain executor never carry the certificate. The executor's HTTP client reads `CurrentTls`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const withTls: (execute: Interface["execute"], tls: ClientTls | undefined) => Interface["execute"];
|
|
21
27
|
/**
|
|
22
28
|
* Per-call middleware that sends through `fetch` instead of the executor's HTTP client. Executor middleware and
|
|
23
29
|
* `middleware` still wrap the call, and status classification still applies.
|
package/dist/route/executor.js
CHANGED
|
@@ -2,8 +2,8 @@ import { Cause, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
|
2
2
|
import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/http";
|
|
3
3
|
import { HttpContext, HttpRateLimitDetails, AIError, TransportError } from "../schema/index.js";
|
|
4
4
|
import { classifyProviderFailure, providerErrorMessage } from "../provider-error.js";
|
|
5
|
-
import { headerDetails, responseHttp, Service } from "./executor-service.js";
|
|
6
|
-
export { responseHttp, Service } from "./executor-service.js";
|
|
5
|
+
import { CurrentTls, headerDetails, responseHttp, Service, } from "./executor-service.js";
|
|
6
|
+
export { CurrentTls, responseHttp, Service } from "./executor-service.js";
|
|
7
7
|
const normalizedHeaders = (headers) => Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
8
8
|
const clampRetryAfterMs = (millis) => Math.min(Number.MAX_SAFE_INTEGER, Math.max(0, Math.ceil(millis)));
|
|
9
9
|
const retryAfterMs = (headers) => {
|
|
@@ -186,6 +186,11 @@ export const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
|
186
186
|
});
|
|
187
187
|
}));
|
|
188
188
|
export const fetchLayer = layer.pipe(Layer.provide(FetchHttpClient.layer));
|
|
189
|
+
/**
|
|
190
|
+
* Sends through `execute`, presenting `tls` on each request. Apply it only where a provider request is sent, so
|
|
191
|
+
* downloads made through the plain executor never carry the certificate. The executor's HTTP client reads `CurrentTls`.
|
|
192
|
+
*/
|
|
193
|
+
export const withTls = (execute, tls) => tls ? (request, middleware) => execute(request, middleware).pipe(Effect.provideService(CurrentTls, tls)) : execute;
|
|
189
194
|
/**
|
|
190
195
|
* Per-call middleware that sends through `fetch` instead of the executor's HTTP client. Executor middleware and
|
|
191
196
|
* `middleware` still wrap the call, and status classification still applies.
|
|
@@ -50,19 +50,25 @@ export interface Started<Token> {
|
|
|
50
50
|
readonly token: Token;
|
|
51
51
|
readonly snapshot: Snapshot;
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
54
|
-
* A follow-up call's inputs: the decoded token and the auth headers the route sent, so a protocol can attach them
|
|
55
|
-
* to output URLs that require the same credentials to download (Veo).
|
|
56
|
-
*/
|
|
53
|
+
/** A follow-up call's inputs: the decoded token. */
|
|
57
54
|
export interface PollContext<Token> {
|
|
58
55
|
readonly token: Token;
|
|
59
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The headers an authenticated GET of `url` would send (deployment headers plus auth), for result URLs that need
|
|
58
|
+
* the API key to download. URLs on another origin than the route's base URL get no headers.
|
|
59
|
+
*/
|
|
60
|
+
readonly headers: (url: string) => Effect.Effect<Record<string, string>, AIError>;
|
|
61
|
+
/**
|
|
62
|
+
* A further GET with the same auth and headers, retried like the poll itself, for providers whose result needs a
|
|
63
|
+
* second lookup (MiniMax v1 answers with a file id that resolves to a download URL).
|
|
64
|
+
*/
|
|
65
|
+
readonly get: (path: string) => Effect.Effect<HttpClientResponse.HttpClientResponse, AIError>;
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
62
68
|
* Submit, then poll. `start` posts the body to the route endpoint; `status`, `result`, and `cancel` are follow-up
|
|
63
69
|
* calls addressed by the token. Paths are relative to the route base URL unless the provider hands back absolute
|
|
64
70
|
* URLs, in which case they are used verbatim. `result` is always its own GET: providers that
|
|
65
|
-
* return the output inside the status body (
|
|
71
|
+
* return the output inside the status body (xAI) point `result.path` at the status path and decode the
|
|
66
72
|
* same document, so `Generation.await` and `Video.resume(...).await()` behave identically everywhere.
|
|
67
73
|
*/
|
|
68
74
|
export interface Queued<Request, Response, Token> {
|
|
@@ -91,11 +97,6 @@ export interface Queued<Request, Response, Token> {
|
|
|
91
97
|
readonly cancel?: {
|
|
92
98
|
readonly method: AuthInput["method"];
|
|
93
99
|
readonly path: (token: Token) => string;
|
|
94
|
-
/**
|
|
95
|
-
* Fetch a fresh status first and skip the call for terminal generations, for providers whose cancel endpoint
|
|
96
|
-
* destroys finished work (Runway's `DELETE /v1/tasks/{id}` deletes completed tasks and their outputs).
|
|
97
|
-
*/
|
|
98
|
-
readonly activeOnly?: boolean;
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
export declare const queued: <Request, Response, Token>(route: Identity, input: Omit<Queued<Request, Response, Token>, "kind" | "id" | "provider">) => Queued<Request, Response, Token>;
|