@opencode/ai 0.0.0-dev-1286 → 0.0.0-dev-1288
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 +52 -10
- package/dist/effect.d.ts +3 -1
- package/dist/image-client.d.ts +52 -59
- package/dist/image-client.js +47 -8
- package/dist/image.d.ts +27 -7
- package/dist/image.js +10 -6
- package/dist/index.d.ts +12 -7
- package/dist/index.js +12 -7
- package/dist/media-client.d.ts +13 -5
- package/dist/media-client.js +42 -37
- package/dist/media.d.ts +8 -0
- package/dist/media.js +14 -0
- package/dist/protocols/google-interactions-video.d.ts +38 -0
- package/dist/protocols/google-interactions-video.js +187 -0
- package/dist/protocols/google-interactions.d.ts +14 -1
- package/dist/protocols/google-interactions.js +1 -1
- package/dist/protocols/minimax-video.d.ts +45 -0
- package/dist/protocols/minimax-video.js +293 -0
- package/dist/protocols/openrouter-video.d.ts +4 -9
- package/dist/protocols/openrouter-video.js +8 -7
- package/dist/protocols/seedance-video.d.ts +4 -9
- package/dist/protocols/seedance-video.js +9 -8
- package/dist/protocols/utils/responses-compaction.js +1 -1
- package/dist/protocols/xai-video.d.ts +4 -9
- package/dist/protocols/xai-video.js +8 -7
- package/dist/providers/google/videos.d.ts +2 -0
- package/dist/providers/google/videos.js +1 -0
- package/dist/providers/google.d.ts +5 -0
- package/dist/providers/google.js +7 -0
- 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/xai/videos.d.ts +2 -0
- package/dist/providers/xai/videos.js +1 -0
- package/dist/providers/xai.d.ts +4 -3
- package/dist/providers/xai.js +5 -1
- package/dist/public.d.ts +1 -1
- 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 +5 -0
- package/dist/route/media.js +4 -3
- package/dist/route/transport/http.js +1 -1
- package/dist/schema/options.d.ts +8 -0
- package/dist/schema/options.js +1 -0
- package/dist/video-client.d.ts +6 -6
- package/dist/video-client.js +13 -11
- package/dist/video.d.ts +14 -72
- package/dist/video.js +9 -8
- package/package.json +19 -3
|
@@ -25,17 +25,12 @@ export type OpenRouterVideoOptions = {
|
|
|
25
25
|
readonly session_id?: string;
|
|
26
26
|
} & Record<string, unknown>;
|
|
27
27
|
export type Request = VideoRequest<VideoModel<OpenRouterVideoOptions>>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}>;
|
|
28
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
29
|
+
export declare const Token: Schema.String;
|
|
31
30
|
export type Token = Schema.Schema.Type<typeof Token>;
|
|
32
|
-
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
33
|
-
readonly id: string;
|
|
34
|
-
}>;
|
|
31
|
+
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
35
32
|
export declare const model: (input: MediaRoute.ModelInput) => VideoModel<OpenRouterVideoOptions>;
|
|
36
33
|
export declare const OpenRouterVideo: {
|
|
37
|
-
readonly protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
38
|
-
readonly id: string;
|
|
39
|
-
}>;
|
|
34
|
+
readonly protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
40
35
|
readonly model: typeof model;
|
|
41
36
|
};
|
|
@@ -11,7 +11,8 @@ export const PATH = "/videos";
|
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
// 2. Token and response schemas
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
|
-
|
|
14
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
15
|
+
export const Token = Schema.String;
|
|
15
16
|
const StartResponse = Schema.Struct({ id: Schema.String, status: optionalNull(Schema.String) });
|
|
16
17
|
const Job = Schema.Struct({
|
|
17
18
|
id: optionalNull(Schema.String),
|
|
@@ -77,20 +78,20 @@ const resolution = (value) => (/^\dk$/.test(value) ? value.toUpperCase() : value
|
|
|
77
78
|
// 5. Response decoding
|
|
78
79
|
// ---------------------------------------------------------------------------
|
|
79
80
|
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
80
|
-
token:
|
|
81
|
+
token: value.id,
|
|
81
82
|
snapshot: { id: value.id, status: MediaProtocol.status(STATUS, value.status ?? "pending") },
|
|
82
83
|
}));
|
|
83
84
|
const decodeJob = route.decodeJson(Job);
|
|
84
85
|
const decodeStatus = Effect.fn("OpenRouterVideo.decodeStatus")(function* (response, context) {
|
|
85
86
|
const output = yield* decodeJob(response);
|
|
86
|
-
return { id: context.token
|
|
87
|
+
return { id: context.token, status: MediaProtocol.status(STATUS, output.value.status) };
|
|
87
88
|
});
|
|
88
89
|
const decodeResult = Effect.fn("OpenRouterVideo.decodeResult")(function* (response, context) {
|
|
89
90
|
const output = yield* decodeJob(response);
|
|
90
91
|
const job = output.value;
|
|
91
92
|
const status = MediaProtocol.status(STATUS, job.status);
|
|
92
93
|
if (status === "queued" || status === "running")
|
|
93
|
-
return yield* output.pending(context.token
|
|
94
|
+
return yield* output.pending(context.token);
|
|
94
95
|
if (status === "failed") {
|
|
95
96
|
const message = `${route.name} generation failed${job.error ? `: ${job.error}` : ""}`;
|
|
96
97
|
if (job.error && /content policy|moderat/i.test(job.error))
|
|
@@ -98,7 +99,7 @@ const decodeResult = Effect.fn("OpenRouterVideo.decodeResult")(function* (respon
|
|
|
98
99
|
return yield* output.ended("failed", message);
|
|
99
100
|
}
|
|
100
101
|
if (status !== "completed")
|
|
101
|
-
return yield* output.ended(status, `${route.name} job ${context.token
|
|
102
|
+
return yield* output.ended(status, `${route.name} job ${context.token} ${status}${job.error ? `: ${job.error}` : ""}`);
|
|
102
103
|
const urls = job.unsigned_urls ?? [];
|
|
103
104
|
if (urls.length === 0)
|
|
104
105
|
return yield* output.invalid(`${route.name} completed without a video URL`);
|
|
@@ -112,7 +113,7 @@ const decodeResult = Effect.fn("OpenRouterVideo.decodeResult")(function* (respon
|
|
|
112
113
|
videos,
|
|
113
114
|
providerMetadata: {
|
|
114
115
|
openrouter: {
|
|
115
|
-
id: context.token
|
|
116
|
+
id: context.token,
|
|
116
117
|
generationId: job.generation_id ?? undefined,
|
|
117
118
|
cost: job.usage?.cost ?? undefined,
|
|
118
119
|
isByok: job.usage?.is_byok ?? undefined,
|
|
@@ -123,7 +124,7 @@ const decodeResult = Effect.fn("OpenRouterVideo.decodeResult")(function* (respon
|
|
|
123
124
|
// ---------------------------------------------------------------------------
|
|
124
125
|
// 6. Protocol and route
|
|
125
126
|
// ---------------------------------------------------------------------------
|
|
126
|
-
const jobPath = (token) => `${PATH}/${encodeURIComponent(token
|
|
127
|
+
const jobPath = (token) => `${PATH}/${encodeURIComponent(token)}`;
|
|
127
128
|
// OpenRouter has no cancel endpoint; `cancelled` only appears when it stops a job itself.
|
|
128
129
|
export const protocol = MediaProtocol.queued(route, {
|
|
129
130
|
token: Token,
|
|
@@ -29,22 +29,17 @@ export type SeedanceVideoOptions = {
|
|
|
29
29
|
readonly safety_identifier?: string;
|
|
30
30
|
} & Record<string, unknown>;
|
|
31
31
|
export type Request = VideoRequest<VideoModel<SeedanceVideoOptions>>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}>;
|
|
32
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
33
|
+
export declare const Token: Schema.String;
|
|
35
34
|
export type Token = Schema.Schema.Type<typeof Token>;
|
|
36
35
|
export type Provider = "volcengine" | "byteplus";
|
|
37
36
|
export declare const SeedanceVideo: {
|
|
38
37
|
readonly volcengine: {
|
|
39
|
-
protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
40
|
-
readonly taskID: string;
|
|
41
|
-
}>;
|
|
38
|
+
protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
42
39
|
model: (input: MediaRoute.ModelInput) => VideoModel<SeedanceVideoOptions>;
|
|
43
40
|
};
|
|
44
41
|
readonly byteplus: {
|
|
45
|
-
protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
46
|
-
readonly taskID: string;
|
|
47
|
-
}>;
|
|
42
|
+
protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
48
43
|
model: (input: MediaRoute.ModelInput) => VideoModel<SeedanceVideoOptions>;
|
|
49
44
|
};
|
|
50
45
|
};
|
|
@@ -14,7 +14,8 @@ const OUTPUT_RETENTION = Duration.hours(24);
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
// 2. Token and response schemas
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
|
-
|
|
17
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
18
|
+
export const Token = Schema.String;
|
|
18
19
|
const StartResponse = Schema.Struct({ id: Schema.String });
|
|
19
20
|
const Task = Schema.Struct({
|
|
20
21
|
id: optionalNull(Schema.String),
|
|
@@ -125,20 +126,20 @@ const make = (provider) => {
|
|
|
125
126
|
}, nativeOptions(request.providerOptions), request.http?.body) ?? {});
|
|
126
127
|
});
|
|
127
128
|
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
128
|
-
token:
|
|
129
|
+
token: value.id,
|
|
129
130
|
snapshot: { id: value.id, status: "queued" },
|
|
130
131
|
}));
|
|
131
132
|
const decodeTask = route.decodeJson(Task);
|
|
132
133
|
const decodeStatus = Effect.fn("SeedanceVideo.decodeStatus")(function* (response, context) {
|
|
133
134
|
const output = yield* decodeTask(response);
|
|
134
|
-
return { id: context.token
|
|
135
|
+
return { id: context.token, status: MediaProtocol.status(STATUS, output.value.status) };
|
|
135
136
|
});
|
|
136
137
|
const decodeResult = Effect.fn("SeedanceVideo.decodeResult")(function* (response, context) {
|
|
137
138
|
const output = yield* decodeTask(response);
|
|
138
139
|
const task = output.value;
|
|
139
140
|
const status = MediaProtocol.status(STATUS, task.status);
|
|
140
141
|
if (status === "queued" || status === "running")
|
|
141
|
-
return yield* output.pending(context.token
|
|
142
|
+
return yield* output.pending(context.token);
|
|
142
143
|
if (status === "failed") {
|
|
143
144
|
const code = task.error?.code ?? undefined;
|
|
144
145
|
const detail = task.error?.message ?? undefined;
|
|
@@ -148,9 +149,9 @@ const make = (provider) => {
|
|
|
148
149
|
return yield* output.ended("failed", message, MediaProtocol.failure(FAILURE, code?.split(".")[0]));
|
|
149
150
|
}
|
|
150
151
|
if (status === "cancelled")
|
|
151
|
-
return yield* output.ended("cancelled", `${route.name} task ${context.token
|
|
152
|
+
return yield* output.ended("cancelled", `${route.name} task ${context.token} was cancelled`);
|
|
152
153
|
if (status === "expired")
|
|
153
|
-
return yield* output.ended("expired", `${route.name} task ${context.token
|
|
154
|
+
return yield* output.ended("expired", `${route.name} task ${context.token} expired`);
|
|
154
155
|
const videoURL = task.content?.video_url ?? undefined;
|
|
155
156
|
if (videoURL === undefined)
|
|
156
157
|
return yield* output.invalid(`${route.name} completed without a video URL`);
|
|
@@ -177,7 +178,7 @@ const make = (provider) => {
|
|
|
177
178
|
},
|
|
178
179
|
providerMetadata: {
|
|
179
180
|
[provider]: {
|
|
180
|
-
taskId: context.token
|
|
181
|
+
taskId: context.token,
|
|
181
182
|
model: task.model ?? undefined,
|
|
182
183
|
seed: task.seed ?? undefined,
|
|
183
184
|
ratio: task.ratio ?? undefined,
|
|
@@ -194,7 +195,7 @@ const make = (provider) => {
|
|
|
194
195
|
},
|
|
195
196
|
});
|
|
196
197
|
});
|
|
197
|
-
const taskPath = (token) => `${PATH}/${token
|
|
198
|
+
const taskPath = (token) => `${PATH}/${encodeURIComponent(token)}`;
|
|
198
199
|
// DELETE cancels a queued task. Ark refuses it for a running task, and deletes the record of a finished one.
|
|
199
200
|
const protocol = MediaProtocol.queued(route, {
|
|
200
201
|
token: Token,
|
|
@@ -88,7 +88,7 @@ export const make = (adapter, lowerTools) => Effect.fn("ResponsesCompaction.exec
|
|
|
88
88
|
auth: route.auth,
|
|
89
89
|
encodeBody: Schema.encodeSync(Schema.fromJsonString(Body)),
|
|
90
90
|
});
|
|
91
|
-
const response = yield* executor.execute(ProviderShared.jsonPost({
|
|
91
|
+
const response = yield* RequestExecutor.withTls(executor.execute, request.http?.tls)(ProviderShared.jsonPost({
|
|
92
92
|
url: parts.url,
|
|
93
93
|
body: parts.bodyText,
|
|
94
94
|
headers: parts.headers,
|
|
@@ -24,17 +24,12 @@ export type XAIVideoOptions = {
|
|
|
24
24
|
}>;
|
|
25
25
|
} & Record<string, unknown>;
|
|
26
26
|
export type Request = VideoRequest<VideoModel<XAIVideoOptions>>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}>;
|
|
27
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
28
|
+
export declare const Token: Schema.String;
|
|
30
29
|
export type Token = Schema.Schema.Type<typeof Token>;
|
|
31
|
-
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
32
|
-
readonly requestID: string;
|
|
33
|
-
}>;
|
|
30
|
+
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
34
31
|
export declare const model: (input: MediaRoute.ModelInput) => VideoModel<XAIVideoOptions>;
|
|
35
32
|
export declare const XAIVideo: {
|
|
36
|
-
readonly protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
37
|
-
readonly requestID: string;
|
|
38
|
-
}>;
|
|
33
|
+
readonly protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
39
34
|
readonly model: typeof model;
|
|
40
35
|
};
|
|
@@ -14,7 +14,8 @@ export const STATUS_PATH = "/videos";
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
// 2. Token and response schemas
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
|
-
|
|
17
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
18
|
+
export const Token = Schema.String;
|
|
18
19
|
const StartResponse = Schema.Struct({ request_id: Schema.String });
|
|
19
20
|
const VideoStatus = Schema.Struct({
|
|
20
21
|
status: Schema.String,
|
|
@@ -78,7 +79,7 @@ const fromRequest = Effect.fn("XAIVideo.fromRequest")(function* (request) {
|
|
|
78
79
|
// 6. Response decoding
|
|
79
80
|
// ---------------------------------------------------------------------------
|
|
80
81
|
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
81
|
-
token:
|
|
82
|
+
token: value.request_id,
|
|
82
83
|
snapshot: { id: value.request_id, status: "running" },
|
|
83
84
|
}));
|
|
84
85
|
// `progress` is undocumented but observed live as a 0..100 percentage (recorded cassette: 1 → 10 → 37 → 100).
|
|
@@ -87,21 +88,21 @@ const decodeVideoStatus = route.decodeJson(VideoStatus);
|
|
|
87
88
|
const decodeStatus = Effect.fn("XAIVideo.decodeStatus")(function* (response, context) {
|
|
88
89
|
const output = yield* decodeVideoStatus(response);
|
|
89
90
|
const status = MediaProtocol.status(STATUS, output.value.status);
|
|
90
|
-
return { id: context.token
|
|
91
|
+
return { id: context.token, status, progress: fraction(output.value.progress) };
|
|
91
92
|
});
|
|
92
93
|
const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, context) {
|
|
93
94
|
const output = yield* decodeVideoStatus(response);
|
|
94
95
|
const decoded = output.value;
|
|
95
96
|
const status = MediaProtocol.status(STATUS, decoded.status);
|
|
96
97
|
if (status === "running")
|
|
97
|
-
return yield* output.pending(context.token
|
|
98
|
+
return yield* output.pending(context.token);
|
|
98
99
|
if (status === "failed") {
|
|
99
100
|
const code = decoded.error?.code ?? undefined;
|
|
100
101
|
const message = decoded.error?.message ?? undefined;
|
|
101
102
|
return yield* output.ended("failed", `${route.name} generation failed${code === undefined ? "" : ` (${code})`}${message === undefined ? "" : `: ${message}`}`, MediaProtocol.failure(FAILURE, code));
|
|
102
103
|
}
|
|
103
104
|
if (status !== "completed")
|
|
104
|
-
return yield* output.ended("expired", `${route.name} request ${context.token
|
|
105
|
+
return yield* output.ended("expired", `${route.name} request ${context.token} expired`);
|
|
105
106
|
// `respect_moderation: false` marks a filtered result; a URL may still be present, so only a missing one fails.
|
|
106
107
|
const moderated = decoded.video?.respect_moderation === false;
|
|
107
108
|
const url = decoded.video?.url ?? undefined;
|
|
@@ -119,7 +120,7 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
119
120
|
],
|
|
120
121
|
providerMetadata: {
|
|
121
122
|
xai: {
|
|
122
|
-
requestId: context.token
|
|
123
|
+
requestId: context.token,
|
|
123
124
|
model: decoded.model ?? undefined,
|
|
124
125
|
respectModeration: decoded.video?.respect_moderation ?? undefined,
|
|
125
126
|
},
|
|
@@ -129,7 +130,7 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
129
130
|
// ---------------------------------------------------------------------------
|
|
130
131
|
// 7. Protocol and route
|
|
131
132
|
// ---------------------------------------------------------------------------
|
|
132
|
-
const statusPath = (token) => `${STATUS_PATH}/${token
|
|
133
|
+
const statusPath = (token) => `${STATUS_PATH}/${encodeURIComponent(token)}`;
|
|
133
134
|
export const protocol = MediaProtocol.queued(route, {
|
|
134
135
|
token: Token,
|
|
135
136
|
start: { body: { from: fromRequest }, decode: decodeStart },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { videoModel as model } from "../google.js";
|
|
@@ -7,6 +7,7 @@ import { GoogleDecisions } from "../protocols/google-decisions.js";
|
|
|
7
7
|
import { GoogleInteractions } from "../protocols/google-interactions.js";
|
|
8
8
|
export type { OptionsInput as GoogleEmbeddingOptions } from "../protocols/google-embed-content.js";
|
|
9
9
|
export type { GoogleImageOptions } from "../protocols/google-images.js";
|
|
10
|
+
export type { GoogleVideoOptions } from "../protocols/google-interactions-video.js";
|
|
10
11
|
export type { GoogleSpeechOptions } from "../protocols/google-speech.js";
|
|
11
12
|
export type { GoogleTranscriptionOptions } from "../protocols/google-transcription.js";
|
|
12
13
|
export type GeminiOptionsInput = Gemini.OptionsInput;
|
|
@@ -181,6 +182,7 @@ export declare const configure: (input?: Config) => {
|
|
|
181
182
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
182
183
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
183
184
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
185
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => 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>;
|
|
@@ -199,6 +201,7 @@ export declare const provider: {
|
|
|
199
201
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
200
202
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
201
203
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
204
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => 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>;
|
|
@@ -207,9 +210,11 @@ export declare const provider: {
|
|
|
207
210
|
};
|
|
208
211
|
export declare const model: ProviderPackage.Model<Settings, Gemini.ProviderOptionsInput>;
|
|
209
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>;
|
|
210
214
|
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
211
215
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<GoogleDecisions.OptionsInput>;
|
|
212
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, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/google-interactions-video.js").GoogleVideoOptions>;
|
|
213
218
|
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
214
219
|
export declare const gemini: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<Gemini.OptionsInput, import("../route.js").CompactionOperations | undefined>;
|
|
215
220
|
export declare const interactions: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
package/dist/providers/google.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Gemini } from "../protocols/gemini.js";
|
|
|
6
6
|
import { GoogleEmbedContent, } from "../protocols/google-embed-content.js";
|
|
7
7
|
import { GoogleDecisions } from "../protocols/google-decisions.js";
|
|
8
8
|
import { GoogleInteractions } from "../protocols/google-interactions.js";
|
|
9
|
+
import { GoogleInteractionsVideo } from "../protocols/google-interactions-video.js";
|
|
9
10
|
import { GoogleImages } from "../protocols/google-images.js";
|
|
10
11
|
import { GoogleSpeech } from "../protocols/google-speech.js";
|
|
11
12
|
import { GoogleTranscription } from "../protocols/google-transcription.js";
|
|
@@ -38,6 +39,7 @@ 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 }),
|
|
42
|
+
video: (modelID, providerOptions) => GoogleInteractionsVideo.model({ ...media, id: modelID, providerOptions }),
|
|
41
43
|
speech: (modelID) => GoogleSpeech.model({ ...media, id: modelID }),
|
|
42
44
|
transcription: (modelID) => GoogleTranscription.model({ ...media, id: modelID }),
|
|
43
45
|
embedding: (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions }),
|
|
@@ -53,6 +55,10 @@ export const imageModel = (modelID, settings) => {
|
|
|
53
55
|
const input = toConfig(settings);
|
|
54
56
|
return configure(input).image(modelID, input.providerOptions);
|
|
55
57
|
};
|
|
58
|
+
export const videoModel = (modelID, settings) => {
|
|
59
|
+
const input = toConfig(settings);
|
|
60
|
+
return configure(input).video(modelID, input.providerOptions);
|
|
61
|
+
};
|
|
56
62
|
export const embeddingModel = (modelID, settings) => {
|
|
57
63
|
const input = toConfig(settings);
|
|
58
64
|
return configure(input).embedding(modelID, input.providerOptions);
|
|
@@ -62,6 +68,7 @@ export const decisionModel = (modelID, settings) => {
|
|
|
62
68
|
return configure(input).decision(modelID, input.providerOptions);
|
|
63
69
|
};
|
|
64
70
|
export const image = provider.image;
|
|
71
|
+
export const video = provider.video;
|
|
65
72
|
export const embedding = provider.embedding;
|
|
66
73
|
export const gemini = provider.gemini;
|
|
67
74
|
export const interactions = provider.interactions;
|
|
@@ -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 { videoModel as model } from "../xai.js";
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -208,7 +208,7 @@ export declare const configure: (input?: Config) => {
|
|
|
208
208
|
}>;
|
|
209
209
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
210
210
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
211
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
211
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
212
212
|
configure: typeof configure;
|
|
213
213
|
};
|
|
214
214
|
export declare const provider: {
|
|
@@ -221,14 +221,15 @@ export declare const provider: {
|
|
|
221
221
|
}>;
|
|
222
222
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
223
223
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
224
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
224
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
225
225
|
configure: typeof configure;
|
|
226
226
|
};
|
|
227
227
|
export declare const model: ProviderPackage.Model<Settings, XAIProviderOptionsInput, typeof responsesRoute.compact>;
|
|
228
228
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
229
|
+
export declare const videoModel: (modelID: string, settings?: Settings) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
229
230
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
|
|
230
231
|
endpoint: import("../route/client.js").CompactOperation;
|
|
231
232
|
}>;
|
|
232
233
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
233
234
|
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
234
|
-
export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
235
|
+
export declare const video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
package/dist/providers/xai.js
CHANGED
|
@@ -69,7 +69,7 @@ export const configure = (input = {}) => {
|
|
|
69
69
|
responses,
|
|
70
70
|
chat,
|
|
71
71
|
image: (modelID, providerOptions) => XAIImages.model({ ...media, id: modelID, providerOptions }),
|
|
72
|
-
video: (modelID) => XAIVideo.model({ ...media, id: modelID }),
|
|
72
|
+
video: (modelID, providerOptions) => XAIVideo.model({ ...media, id: modelID, providerOptions }),
|
|
73
73
|
configure,
|
|
74
74
|
};
|
|
75
75
|
};
|
|
@@ -79,6 +79,10 @@ export const imageModel = (modelID, settings) => {
|
|
|
79
79
|
const input = toConfig(settings);
|
|
80
80
|
return configure(input).image(modelID, input.providerOptions);
|
|
81
81
|
};
|
|
82
|
+
export const videoModel = (modelID, settings) => {
|
|
83
|
+
const input = toConfig(settings);
|
|
84
|
+
return configure(input).video(modelID, input.providerOptions);
|
|
85
|
+
};
|
|
82
86
|
export const responses = provider.responses;
|
|
83
87
|
export const chat = provider.chat;
|
|
84
88
|
export const image = provider.image;
|
package/dist/public.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./prov
|
|
|
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 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
|
-
export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
|
|
5
|
+
export type { ImageJob, ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, ImageStatus, } from "./image.js";
|
|
6
6
|
export { VideoAspectRatio, VideoDuration, VideoModel, VideoModelSchema, VideoResponse } from "./video.js";
|
|
7
7
|
export type { VideoJob, VideoModelOptions, VideoOptions, VideoRequest, VideoRequestInput, VideoResolution, VideoRoute, VideoStatus, } from "./video.js";
|
|
8
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";
|
|
@@ -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.
|
|
@@ -58,6 +58,11 @@ export interface PollContext<Token> {
|
|
|
58
58
|
* the API key to download. URLs on another origin than the route's base URL get no headers.
|
|
59
59
|
*/
|
|
60
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>;
|
|
61
66
|
}
|
|
62
67
|
/**
|
|
63
68
|
* Submit, then poll. `start` posts the body to the route endpoint; `status`, `result`, and `cancel` are follow-up
|