@opencode/ai 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -114
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +21 -0
- package/dist/decision-client.js +55 -0
- package/dist/decision.d.ts +472 -0
- package/dist/decision.js +158 -0
- package/dist/effect.d.ts +38 -0
- package/dist/effect.js +27 -0
- package/dist/effort-updates.d.ts +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +13 -0
- package/dist/experimental/cloudflare-run-extraction.js +83 -0
- package/dist/experimental/extraction.d.ts +183 -0
- package/dist/experimental/extraction.js +102 -0
- package/dist/experimental/realtime.d.ts +7 -2
- package/dist/experimental/realtime.js +5 -5
- package/dist/experimental.d.ts +2 -3
- package/dist/experimental.js +1 -2
- package/dist/image-client.d.ts +13 -22
- package/dist/image-client.js +0 -1
- package/dist/image.d.ts +154 -324
- package/dist/image.js +4 -11
- package/dist/index.d.ts +1426 -34
- package/dist/index.js +127 -24
- package/dist/llm.d.ts +16 -1
- package/dist/llm.js +34 -0
- package/dist/media-client.d.ts +2 -1
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/media.d.ts +0 -7
- package/dist/media.js +0 -6
- package/dist/protocols/alibaba-chat.d.ts +32 -12
- package/dist/protocols/alibaba-images.d.ts +22 -0
- package/dist/protocols/alibaba-images.js +77 -0
- package/dist/protocols/alibaba-messages.d.ts +62 -27
- package/dist/protocols/alibaba-responses.d.ts +41 -38
- package/dist/protocols/anthropic-messages.d.ts +196 -94
- package/dist/protocols/anthropic-messages.js +47 -16
- package/dist/protocols/bedrock-converse.d.ts +140 -47
- package/dist/protocols/bedrock-converse.js +114 -18
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/bfl-images.d.ts +9 -0
- package/dist/protocols/bfl-images.js +17 -15
- package/dist/protocols/cartesia-speech.d.ts +32 -50
- package/dist/protocols/cloudflare-run-decisions.d.ts +9 -0
- package/dist/protocols/cloudflare-run-decisions.js +36 -0
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +23 -0
- package/dist/protocols/cloudflare-workers-ai-images.js +80 -0
- package/dist/protocols/cohere-chat.d.ts +7 -8
- package/dist/protocols/deepgram-speech.d.ts +32 -50
- package/dist/protocols/elevenlabs-speech.d.ts +32 -50
- package/dist/protocols/fal-images.d.ts +10 -1
- package/dist/protocols/fal-images.js +16 -25
- package/dist/protocols/fal-video.js +1 -1
- package/dist/protocols/gemini.d.ts +37 -34
- package/dist/protocols/gemini.js +13 -8
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-images.js +8 -37
- package/dist/protocols/google-interactions.d.ts +18 -14
- package/dist/protocols/google-interactions.js +14 -7
- package/dist/protocols/google-speech.d.ts +32 -50
- package/dist/protocols/google-speech.js +0 -1
- package/dist/protocols/google-transcription.d.ts +32 -50
- package/dist/protocols/google-transcription.js +0 -1
- package/dist/protocols/google-video.d.ts +1 -1
- package/dist/protocols/google-video.js +2 -7
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +7 -1
- package/dist/protocols/meta-images.js +10 -8
- package/dist/protocols/meta-messages.d.ts +73 -38
- package/dist/protocols/meta-messages.js +14 -1
- package/dist/protocols/meta-responses.d.ts +84 -78
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/mistral-chat.d.ts +81 -78
- package/dist/protocols/mistral-chat.js +2 -1
- package/dist/protocols/open-responses-channel.js +47 -46
- package/dist/protocols/open-responses-continuation.d.ts +8 -2
- package/dist/protocols/open-responses-continuation.js +3 -1
- package/dist/protocols/open-responses.d.ts +426 -396
- package/dist/protocols/open-responses.js +16 -25
- package/dist/protocols/openai-chat.d.ts +764 -52
- package/dist/protocols/openai-chat.js +38 -25
- package/dist/protocols/openai-compatible-chat.d.ts +35 -15
- package/dist/protocols/openai-compatible-responses.d.ts +44 -42
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +128 -0
- package/dist/protocols/openai-images.d.ts +53 -56
- package/dist/protocols/openai-images.js +100 -34
- package/dist/protocols/openai-responses.d.ts +322 -264
- package/dist/protocols/openai-responses.js +33 -3
- package/dist/protocols/openai-speech.d.ts +32 -50
- package/dist/protocols/openai-speech.js +15 -5
- package/dist/protocols/openai-transcription.d.ts +32 -50
- package/dist/protocols/openai-transcription.js +15 -11
- package/dist/protocols/replicate-images.js +1 -1
- package/dist/protocols/runway-video.d.ts +1 -1
- package/dist/protocols/runway-video.js +1 -1
- package/dist/protocols/shared.d.ts +9 -1
- package/dist/protocols/shared.js +13 -2
- package/dist/protocols/stability-images.d.ts +5 -0
- package/dist/protocols/stability-images.js +4 -9
- package/dist/protocols/system-one.d.ts +101 -0
- package/dist/protocols/system-one.js +230 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-generate-content.d.ts +3 -3
- package/dist/protocols/utils/gemini-generate-content.js +10 -16
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/image-sizing.d.ts +31 -0
- package/dist/protocols/utils/image-sizing.js +73 -0
- package/dist/protocols/utils/media-input.d.ts +4 -5
- package/dist/protocols/utils/media-input.js +8 -5
- package/dist/protocols/utils/partial-json-options.d.ts +0 -1
- package/dist/protocols/utils/partial-json-options.js +0 -1
- package/dist/protocols/utils/speech-stream.d.ts +0 -1
- package/dist/protocols/utils/speech-stream.js +0 -1
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +10 -1
- package/dist/protocols/venice-chat.d.ts +71 -53
- package/dist/protocols/venice-chat.js +7 -6
- package/dist/protocols/xai-images.d.ts +1 -2
- package/dist/protocols/xai-images.js +9 -2
- package/dist/protocols/xai-responses.d.ts +88 -78
- package/dist/protocols/xai-responses.js +28 -2
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/xai-video.js +11 -8
- package/dist/protocols/zai-chat.d.ts +54 -30
- package/dist/protocols/zai-chat.js +8 -3
- package/dist/protocols/zai-images.d.ts +3 -1
- package/dist/protocols/zai-images.js +12 -11
- package/dist/protocols/zai-messages.d.ts +72 -35
- package/dist/protocols/zai-messages.js +3 -2
- package/dist/provider-error.js +24 -7
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +146 -85
- package/dist/providers/alibaba.js +16 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +277 -218
- package/dist/providers/amazon-bedrock.d.ts +48 -28
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +64 -29
- package/dist/providers/anthropic.d.ts +64 -29
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +156 -115
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +75 -25
- package/dist/providers/baseten.js +41 -8
- package/dist/providers/cerebras.d.ts +66 -24
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +409 -272
- package/dist/providers/cloudflare-ai-gateway.js +33 -6
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +79 -25
- package/dist/providers/cloudflare-workers-ai.js +45 -9
- package/dist/providers/cohere.d.ts +117 -75
- package/dist/providers/deepinfra.d.ts +66 -24
- package/dist/providers/deepseek.d.ts +66 -24
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean.d.ts +108 -37
- package/dist/providers/digitalocean.js +39 -8
- package/dist/providers/fireworks.d.ts +66 -24
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +33 -12
- package/dist/providers/google-vertex-messages.d.ts +64 -29
- package/dist/providers/google-vertex-mistral.d.ts +17 -17
- package/dist/providers/google-vertex-responses.d.ts +38 -35
- package/dist/providers/google-vertex.d.ts +20 -18
- package/dist/providers/google-vertex.js +32 -15
- package/dist/providers/google.d.ts +22 -21
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +66 -28
- package/dist/providers/groq.js +0 -6
- package/dist/providers/meta.d.ts +144 -85
- package/dist/providers/minimax.d.ts +145 -86
- package/dist/providers/mistral.d.ts +28 -28
- package/dist/providers/moonshot.d.ts +277 -218
- package/dist/providers/open-responses-options.d.ts +0 -1
- package/dist/providers/open-responses-options.js +1 -1
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +38 -35
- package/dist/providers/openai-compatible.d.ts +36 -13
- package/dist/providers/openai-compatible.js +22 -10
- package/dist/providers/openai-options.d.ts +3 -2
- package/dist/providers/openai-options.js +0 -1
- package/dist/providers/openai.d.ts +146 -109
- package/dist/providers/openai.js +20 -4
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +9 -10
- package/dist/providers/opencode.js +10 -8
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter.d.ts +128 -47
- package/dist/providers/openrouter.js +38 -16
- package/dist/providers/togetherai.d.ts +66 -24
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +9 -10
- package/dist/providers/typesafe-ai.js +10 -8
- package/dist/providers/venice.d.ts +214 -20
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +10 -16
- package/dist/providers/vercel-ai-gateway.js +31 -85
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +40 -17
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan.d.ts +224 -85
- package/dist/providers/zai.d.ts +110 -23
- package/dist/providers/zai.js +15 -8
- package/dist/route/auth-options.d.ts +0 -3
- package/dist/route/auth.d.ts +0 -2
- package/dist/route/auth.js +0 -2
- package/dist/route/client.d.ts +2 -4
- package/dist/route/client.js +29 -8
- package/dist/route/decision.d.ts +58 -0
- package/dist/route/decision.js +75 -0
- package/dist/route/executor-service.js +1 -1
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media-protocol.d.ts +1 -0
- package/dist/route/media-protocol.js +12 -8
- package/dist/route/media.d.ts +5 -1
- package/dist/route/media.js +6 -2
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +148 -6
- package/dist/schema/events.js +20 -0
- package/dist/schema/messages.d.ts +6 -2
- package/dist/schema/messages.js +3 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +13 -22
- package/dist/speech-client.js +0 -1
- package/dist/speech.d.ts +148 -283
- package/dist/speech.js +2 -4
- package/dist/testing.d.ts +25 -24
- package/dist/testing.js +3 -21
- package/dist/transcription-client.d.ts +13 -22
- package/dist/transcription.d.ts +148 -283
- package/dist/transcription.js +1 -1
- package/dist/utils/media-type.js +22 -1
- package/dist/video-client.d.ts +13 -22
- package/dist/video-client.js +0 -1
- package/dist/video.d.ts +115 -250
- package/dist/video.js +3 -5
- package/package.json +516 -13
- package/dist/experimental/evaluation-client.d.ts +0 -21
- package/dist/experimental/evaluation-client.js +0 -64
- package/dist/experimental/evaluation.d.ts +0 -242
- package/dist/experimental/evaluation.js +0 -115
- package/dist/experimental/system-one.d.ts +0 -16
- package/dist/experimental/system-one.js +0 -135
- package/dist/promise.d.ts +0 -1021
- package/dist/promise.js +0 -101
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
|
@@ -2,7 +2,7 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
import { ImageModel, ImageResponse } from "../image.js";
|
|
3
3
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import { mergeJsonRecords } from "../schema/index.js";
|
|
5
|
+
import { mergeJsonRecords, tokenUsage } from "../schema/index.js";
|
|
6
6
|
import { ProviderShared } from "./shared.js";
|
|
7
7
|
import { GeminiGenerateContent } from "./utils/gemini-generate-content.js";
|
|
8
8
|
import { MediaInput } from "./utils/media-input.js";
|
|
@@ -49,13 +49,12 @@ const GoogleImageResponse = Schema.Struct({
|
|
|
49
49
|
// 5. Request body construction
|
|
50
50
|
// ---------------------------------------------------------------------------
|
|
51
51
|
const generationConfig = (request) => {
|
|
52
|
-
const {
|
|
53
|
-
const imageConfig = { aspectRatio: request.
|
|
52
|
+
const { thinkingLevel, includeThoughts, ...native } = request.providerOptions ?? {};
|
|
53
|
+
const imageConfig = { aspectRatio: request.aspect, imageSize: request.resolution };
|
|
54
54
|
const thinkingConfig = { thinkingLevel, includeThoughts };
|
|
55
55
|
return (mergeJsonRecords({
|
|
56
56
|
responseModalities: ["IMAGE"],
|
|
57
57
|
imageConfig: Object.values(imageConfig).some((value) => value !== undefined) ? imageConfig : undefined,
|
|
58
|
-
seed: request.seed,
|
|
59
58
|
thinkingConfig: Object.values(thinkingConfig).some((value) => value !== undefined) ? thinkingConfig : undefined,
|
|
60
59
|
}, native) ?? { responseModalities: ["IMAGE"] });
|
|
61
60
|
};
|
|
@@ -119,45 +118,18 @@ const decodeResponse = Effect.fn("GoogleImages.decodeResponse")(function* (respo
|
|
|
119
118
|
}));
|
|
120
119
|
if (images.length === 0) {
|
|
121
120
|
const finishReasons = candidates.flatMap((candidate) => candidate.finishReason === undefined ? [] : [candidate.finishReason]);
|
|
121
|
+
// Safety and recitation stops are Google refusing the prompt, not a malformed response.
|
|
122
|
+
if (finishReasons.some(GeminiGenerateContent.contentFiltered))
|
|
123
|
+
return yield* output.contentPolicy(`${route.name} withheld its images (finish reasons: ${finishReasons.join(", ")})`);
|
|
122
124
|
return yield* output.invalid(`${route.name} returned no final images${finishReasons.length === 0 ? "" : ` (finish reasons: ${finishReasons.join(", ")})`}; inspect body for prompt feedback and candidate details`);
|
|
123
125
|
}
|
|
124
|
-
// Candidates that stopped for a safety or policy reason are partial results, not a silent drop.
|
|
125
|
-
const notices = [
|
|
126
|
-
...(decoded.promptFeedback === undefined
|
|
127
|
-
? []
|
|
128
|
-
: [
|
|
129
|
-
{
|
|
130
|
-
type: "filtered",
|
|
131
|
-
message: `${route.name} reported prompt feedback`,
|
|
132
|
-
providerMetadata: { google: { promptFeedback: decoded.promptFeedback } },
|
|
133
|
-
},
|
|
134
|
-
]),
|
|
135
|
-
...candidates.flatMap((candidate, index) => candidate.finishReason === undefined || candidate.finishReason === "STOP"
|
|
136
|
-
? []
|
|
137
|
-
: [
|
|
138
|
-
{
|
|
139
|
-
type: "filtered",
|
|
140
|
-
message: `${route.name} candidate ${candidate.index ?? index} finished with ${candidate.finishReason}${candidate.finishMessage === undefined ? "" : `: ${candidate.finishMessage}`}`,
|
|
141
|
-
providerMetadata: {
|
|
142
|
-
google: {
|
|
143
|
-
candidateIndex: candidate.index ?? index,
|
|
144
|
-
finishReason: candidate.finishReason,
|
|
145
|
-
finishMessage: candidate.finishMessage,
|
|
146
|
-
safetyRatings: candidate.safetyRatings,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
]),
|
|
151
|
-
];
|
|
152
126
|
const usage = decoded.usageMetadata;
|
|
153
127
|
const outputTokens = usage?.candidatesTokenCount === undefined ? undefined : usage.candidatesTokenCount + (usage.thoughtsTokenCount ?? 0);
|
|
154
128
|
return new ImageResponse({
|
|
155
129
|
images,
|
|
156
|
-
notices: notices.length === 0 ? undefined : notices,
|
|
157
130
|
usage: usage === undefined
|
|
158
131
|
? undefined
|
|
159
|
-
: {
|
|
160
|
-
type: "tokens",
|
|
132
|
+
: tokenUsage({
|
|
161
133
|
input: usage.promptTokenCount,
|
|
162
134
|
output: outputTokens,
|
|
163
135
|
total: ProviderShared.totalTokens(usage.promptTokenCount, outputTokens, usage.totalTokenCount),
|
|
@@ -166,7 +138,7 @@ const decodeResponse = Effect.fn("GoogleImages.decodeResponse")(function* (respo
|
|
|
166
138
|
cacheReadInputTokens: usage.cachedContentTokenCount,
|
|
167
139
|
google: usage,
|
|
168
140
|
},
|
|
169
|
-
},
|
|
141
|
+
}),
|
|
170
142
|
providerMetadata: {
|
|
171
143
|
google: {
|
|
172
144
|
modelVersion: decoded.modelVersion,
|
|
@@ -181,7 +153,6 @@ const decodeResponse = Effect.fn("GoogleImages.decodeResponse")(function* (respo
|
|
|
181
153
|
// 7. Protocol and route
|
|
182
154
|
// ---------------------------------------------------------------------------
|
|
183
155
|
export const protocol = MediaProtocol.inline(route, {
|
|
184
|
-
unsupported: ["mask", "size", "format"],
|
|
185
156
|
body: { from: fromRequest },
|
|
186
157
|
response: { decode: decodeResponse },
|
|
187
158
|
});
|
|
@@ -42,13 +42,13 @@ export declare const protocol: Protocol<{
|
|
|
42
42
|
readonly input: readonly ({
|
|
43
43
|
readonly type: "model_output" | "user_input";
|
|
44
44
|
readonly content: readonly ({
|
|
45
|
+
readonly type: "text";
|
|
46
|
+
readonly text: string;
|
|
47
|
+
} | {
|
|
45
48
|
readonly type: "audio" | "document" | "image" | "video";
|
|
46
49
|
readonly data?: string | undefined;
|
|
47
50
|
readonly uri?: string | undefined;
|
|
48
51
|
readonly mime_type: string;
|
|
49
|
-
} | {
|
|
50
|
-
readonly type: "text";
|
|
51
|
-
readonly text: string;
|
|
52
52
|
})[];
|
|
53
53
|
} | {
|
|
54
54
|
readonly type: "thought";
|
|
@@ -99,6 +99,8 @@ export declare const protocol: Protocol<{
|
|
|
99
99
|
} | undefined;
|
|
100
100
|
};
|
|
101
101
|
}, string, {
|
|
102
|
+
readonly event_type: "unknown";
|
|
103
|
+
} | {
|
|
102
104
|
readonly event_type: "step.start";
|
|
103
105
|
readonly index: number;
|
|
104
106
|
readonly step: {
|
|
@@ -122,6 +124,9 @@ export declare const protocol: Protocol<{
|
|
|
122
124
|
readonly event_type: "step.delta";
|
|
123
125
|
readonly index: number;
|
|
124
126
|
readonly delta: {
|
|
127
|
+
readonly type: "unknown";
|
|
128
|
+
readonly rawType: string;
|
|
129
|
+
} | {
|
|
125
130
|
readonly type: "text";
|
|
126
131
|
readonly text: string;
|
|
127
132
|
} | {
|
|
@@ -136,9 +141,6 @@ export declare const protocol: Protocol<{
|
|
|
136
141
|
readonly type: "text";
|
|
137
142
|
readonly text: string;
|
|
138
143
|
};
|
|
139
|
-
} | {
|
|
140
|
-
readonly type: "unknown";
|
|
141
|
-
readonly rawType: string;
|
|
142
144
|
};
|
|
143
145
|
} | {
|
|
144
146
|
readonly event_type: "step.stop";
|
|
@@ -148,10 +150,6 @@ export declare const protocol: Protocol<{
|
|
|
148
150
|
readonly interaction: {
|
|
149
151
|
readonly id?: string | undefined;
|
|
150
152
|
};
|
|
151
|
-
} | {
|
|
152
|
-
readonly event_type: "interaction.status_update";
|
|
153
|
-
readonly interaction_id?: string | undefined;
|
|
154
|
-
readonly status: string;
|
|
155
153
|
} | {
|
|
156
154
|
readonly event_type: "interaction.completed";
|
|
157
155
|
readonly interaction: {
|
|
@@ -167,25 +165,31 @@ export declare const protocol: Protocol<{
|
|
|
167
165
|
readonly total_tokens?: number | null | undefined;
|
|
168
166
|
readonly raw_prompt_token?: number | null | undefined;
|
|
169
167
|
} | undefined;
|
|
168
|
+
readonly errors?: readonly {
|
|
169
|
+
readonly code?: string | undefined;
|
|
170
|
+
readonly message?: string | undefined;
|
|
171
|
+
}[] | undefined;
|
|
170
172
|
};
|
|
171
173
|
} | {
|
|
172
174
|
readonly event_type: "error";
|
|
173
175
|
readonly error: unknown;
|
|
174
176
|
} | {
|
|
175
|
-
readonly event_type: "
|
|
177
|
+
readonly event_type: "interaction.status_update";
|
|
178
|
+
readonly interaction_id?: string | undefined;
|
|
179
|
+
readonly status: string;
|
|
176
180
|
}, ParserState>;
|
|
177
181
|
export declare const route: Route<{
|
|
178
182
|
readonly model: string;
|
|
179
183
|
readonly input: readonly ({
|
|
180
184
|
readonly type: "model_output" | "user_input";
|
|
181
185
|
readonly content: readonly ({
|
|
186
|
+
readonly type: "text";
|
|
187
|
+
readonly text: string;
|
|
188
|
+
} | {
|
|
182
189
|
readonly type: "audio" | "document" | "image" | "video";
|
|
183
190
|
readonly data?: string | undefined;
|
|
184
191
|
readonly uri?: string | undefined;
|
|
185
192
|
readonly mime_type: string;
|
|
186
|
-
} | {
|
|
187
|
-
readonly type: "text";
|
|
188
|
-
readonly text: string;
|
|
189
193
|
})[];
|
|
190
194
|
} | {
|
|
191
195
|
readonly type: "thought";
|
|
@@ -11,6 +11,7 @@ import { encodeJson } from "../utils/json.js";
|
|
|
11
11
|
import { JsonObject, knownString, lenient, optionalNull, ProviderShared } from "./shared.js";
|
|
12
12
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
13
13
|
import { MediaInput } from "./utils/media-input.js";
|
|
14
|
+
import { GeminiGenerateContent } from "./utils/gemini-generate-content.js";
|
|
14
15
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
15
16
|
const ADAPTER = "google-interactions";
|
|
16
17
|
export const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
@@ -127,6 +128,7 @@ const Interaction = Schema.StructWithRest(Schema.Struct({
|
|
|
127
128
|
id: Schema.optional(Schema.String),
|
|
128
129
|
status: Schema.String,
|
|
129
130
|
usage: Schema.optional(RawUsage),
|
|
131
|
+
errors: Schema.optional(Schema.Array(Schema.Struct({ code: Schema.optional(Schema.String), message: Schema.optional(Schema.String) }))),
|
|
130
132
|
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
131
133
|
const KNOWN_EVENT_TYPES = new Set([
|
|
132
134
|
"step.start",
|
|
@@ -172,7 +174,9 @@ const mediaContent = Effect.fnUntraced(function* (asset) {
|
|
|
172
174
|
asset.mediaType !== "text/csv")
|
|
173
175
|
return yield* ProviderShared.invalidRequest(`Google Interactions does not support ${asset.mediaType} document input`);
|
|
174
176
|
const type = asset.kind === "image" || asset.kind === "audio" || asset.kind === "video" ? asset.kind : "document";
|
|
175
|
-
const uri =
|
|
177
|
+
const uri = asset.kind === "video" && asset.source.type === "url" && /^https?:\/\//i.test(asset.source.url)
|
|
178
|
+
? asset.source.url
|
|
179
|
+
: MediaInput.refID(asset, ProviderID.make("google"));
|
|
176
180
|
if (uri !== undefined)
|
|
177
181
|
return { type, uri, mime_type: asset.mediaType };
|
|
178
182
|
const inline = yield* ProviderShared.requireInlineMedia("Google Interactions", asset);
|
|
@@ -184,7 +188,7 @@ const signature = (metadata, key) => {
|
|
|
184
188
|
};
|
|
185
189
|
const lowerMessages = Effect.fnUntraced(function* (request) {
|
|
186
190
|
const steps = [];
|
|
187
|
-
const key = request.model.route.providerMetadataKey ??
|
|
191
|
+
const key = request.model.route.providerMetadataKey ?? request.model.provider;
|
|
188
192
|
for (const message of request.messages) {
|
|
189
193
|
if (message.role === "system") {
|
|
190
194
|
const part = yield* ProviderShared.wrappedSystemUpdate("Google Interactions", message);
|
|
@@ -253,7 +257,7 @@ const lowerToolResult = Effect.fnUntraced(function* (part) {
|
|
|
253
257
|
return yield* Effect.forEach(part.result.value, (item) => {
|
|
254
258
|
if (item.type === "text")
|
|
255
259
|
return Effect.succeed({ type: "text", text: item.text });
|
|
256
|
-
return mediaContent(
|
|
260
|
+
return mediaContent(GeminiGenerateContent.toolMedia(item));
|
|
257
261
|
});
|
|
258
262
|
});
|
|
259
263
|
const fromRequest = Effect.fn("GoogleInteractions.fromRequest")(function* (request) {
|
|
@@ -437,14 +441,17 @@ const step = Effect.fnUntraced(function* (state, event) {
|
|
|
437
441
|
});
|
|
438
442
|
case "interaction.completed": {
|
|
439
443
|
const interaction = event.interaction;
|
|
440
|
-
if (interaction.status === "failed" || interaction.status === "cancelled")
|
|
444
|
+
if (interaction.status === "failed" || interaction.status === "cancelled") {
|
|
445
|
+
const messages = (interaction.errors ?? []).flatMap((error) => (error.message?.trim() ? [error.message] : []));
|
|
441
446
|
return yield* new AIError({
|
|
442
447
|
reason: classifyProviderFailure({
|
|
443
|
-
message: `Google Interactions ${interaction.status}`,
|
|
444
|
-
|
|
448
|
+
message: messages.length > 0 ? messages.join("\n") : `Google Interactions ${interaction.status}`,
|
|
449
|
+
// The first coded error decides the classification; every message stays visible.
|
|
450
|
+
data: interaction.errors?.find((error) => error.code) ?? interaction,
|
|
445
451
|
rawBody: encodeJson(event),
|
|
446
452
|
}),
|
|
447
453
|
});
|
|
454
|
+
}
|
|
448
455
|
if (!["completed", "requires_action", "incomplete"].includes(interaction.status))
|
|
449
456
|
return yield* ProviderShared.eventError(ADAPTER, `Unexpected terminal Interactions status: ${interaction.status}`, encodeJson(event));
|
|
450
457
|
const pending = yield* ToolStream.finishAll(ADAPTER, state.tools);
|
|
@@ -476,7 +483,7 @@ export const protocol = Protocol.make({
|
|
|
476
483
|
event: Protocol.jsonEvent(Event),
|
|
477
484
|
initial: (request) => ({
|
|
478
485
|
route: `${request.model.provider}/${ADAPTER}`,
|
|
479
|
-
metadataKey: request.model.route.providerMetadataKey ??
|
|
486
|
+
metadataKey: request.model.route.providerMetadataKey ?? request.model.provider,
|
|
480
487
|
lifecycle: Lifecycle.initial(),
|
|
481
488
|
steps: {},
|
|
482
489
|
tools: ToolStream.empty(),
|
|
@@ -26,14 +26,6 @@ interface State extends SpeechStream.Audio, GeminiGenerateContent.Metadata {
|
|
|
26
26
|
readonly mimeType?: string;
|
|
27
27
|
}
|
|
28
28
|
export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
29
|
-
readonly type: "generation-queued";
|
|
30
|
-
readonly id: string;
|
|
31
|
-
readonly position?: number | undefined;
|
|
32
|
-
} | {
|
|
33
|
-
readonly type: "generation-progress";
|
|
34
|
-
readonly id: string;
|
|
35
|
-
readonly progress?: number | undefined;
|
|
36
|
-
} | {
|
|
37
29
|
readonly type: "audio-delta";
|
|
38
30
|
readonly chunk: Uint8Array<ArrayBufferLike>;
|
|
39
31
|
} | {
|
|
@@ -43,18 +35,18 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
43
35
|
readonly startSeconds: number;
|
|
44
36
|
readonly endSeconds: number;
|
|
45
37
|
}[];
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: "generation-queued";
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly position?: number | undefined;
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: "generation-progress";
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly progress?: number | undefined;
|
|
46
46
|
} | {
|
|
47
47
|
readonly type: "finish";
|
|
48
48
|
readonly audio: import("../media.js").Asset;
|
|
49
49
|
readonly usage?: {
|
|
50
|
-
readonly type: "tokens";
|
|
51
|
-
readonly input?: number | undefined;
|
|
52
|
-
readonly output?: number | undefined;
|
|
53
|
-
readonly total?: number | undefined;
|
|
54
|
-
readonly details?: {
|
|
55
|
-
readonly [x: string]: unknown;
|
|
56
|
-
} | undefined;
|
|
57
|
-
} | {
|
|
58
50
|
readonly type: "seconds";
|
|
59
51
|
readonly seconds: number;
|
|
60
52
|
} | {
|
|
@@ -66,16 +58,15 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
66
58
|
} | {
|
|
67
59
|
readonly type: "compute";
|
|
68
60
|
readonly seconds: number;
|
|
69
|
-
} |
|
|
70
|
-
|
|
71
|
-
readonly
|
|
72
|
-
readonly
|
|
73
|
-
readonly
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "tokens";
|
|
63
|
+
readonly input?: number | undefined;
|
|
64
|
+
readonly output?: number | undefined;
|
|
65
|
+
readonly total?: number | undefined;
|
|
66
|
+
readonly details?: {
|
|
67
|
+
readonly [x: string]: unknown;
|
|
77
68
|
} | undefined;
|
|
78
|
-
}
|
|
69
|
+
} | undefined;
|
|
79
70
|
readonly providerMetadata?: {
|
|
80
71
|
readonly [x: string]: {
|
|
81
72
|
readonly [x: string]: unknown;
|
|
@@ -85,14 +76,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
85
76
|
export declare const model: (input: MediaRoute.ModelInput) => SpeechModel<GoogleSpeechOptions>;
|
|
86
77
|
export declare const GoogleSpeech: {
|
|
87
78
|
readonly protocol: MediaProtocol.Streamed<Request, {
|
|
88
|
-
readonly type: "generation-queued";
|
|
89
|
-
readonly id: string;
|
|
90
|
-
readonly position?: number | undefined;
|
|
91
|
-
} | {
|
|
92
|
-
readonly type: "generation-progress";
|
|
93
|
-
readonly id: string;
|
|
94
|
-
readonly progress?: number | undefined;
|
|
95
|
-
} | {
|
|
96
79
|
readonly type: "audio-delta";
|
|
97
80
|
readonly chunk: Uint8Array<ArrayBufferLike>;
|
|
98
81
|
} | {
|
|
@@ -102,18 +85,18 @@ export declare const GoogleSpeech: {
|
|
|
102
85
|
readonly startSeconds: number;
|
|
103
86
|
readonly endSeconds: number;
|
|
104
87
|
}[];
|
|
88
|
+
} | {
|
|
89
|
+
readonly type: "generation-queued";
|
|
90
|
+
readonly id: string;
|
|
91
|
+
readonly position?: number | undefined;
|
|
92
|
+
} | {
|
|
93
|
+
readonly type: "generation-progress";
|
|
94
|
+
readonly id: string;
|
|
95
|
+
readonly progress?: number | undefined;
|
|
105
96
|
} | {
|
|
106
97
|
readonly type: "finish";
|
|
107
98
|
readonly audio: import("../media.js").Asset;
|
|
108
99
|
readonly usage?: {
|
|
109
|
-
readonly type: "tokens";
|
|
110
|
-
readonly input?: number | undefined;
|
|
111
|
-
readonly output?: number | undefined;
|
|
112
|
-
readonly total?: number | undefined;
|
|
113
|
-
readonly details?: {
|
|
114
|
-
readonly [x: string]: unknown;
|
|
115
|
-
} | undefined;
|
|
116
|
-
} | {
|
|
117
100
|
readonly type: "seconds";
|
|
118
101
|
readonly seconds: number;
|
|
119
102
|
} | {
|
|
@@ -125,16 +108,15 @@ export declare const GoogleSpeech: {
|
|
|
125
108
|
} | {
|
|
126
109
|
readonly type: "compute";
|
|
127
110
|
readonly seconds: number;
|
|
128
|
-
} |
|
|
129
|
-
|
|
130
|
-
readonly
|
|
131
|
-
readonly
|
|
132
|
-
readonly
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
111
|
+
} | {
|
|
112
|
+
readonly type: "tokens";
|
|
113
|
+
readonly input?: number | undefined;
|
|
114
|
+
readonly output?: number | undefined;
|
|
115
|
+
readonly total?: number | undefined;
|
|
116
|
+
readonly details?: {
|
|
117
|
+
readonly [x: string]: unknown;
|
|
136
118
|
} | undefined;
|
|
137
|
-
}
|
|
119
|
+
} | undefined;
|
|
138
120
|
readonly providerMetadata?: {
|
|
139
121
|
readonly [x: string]: {
|
|
140
122
|
readonly [x: string]: unknown;
|
|
@@ -67,7 +67,6 @@ const finish = (state, context) => {
|
|
|
67
67
|
return SpeechStream.finish(route, state, {
|
|
68
68
|
...output,
|
|
69
69
|
usage: GeminiGenerateContent.usage(state.usage),
|
|
70
|
-
notices: GeminiGenerateContent.notices(route.name, state),
|
|
71
70
|
providerMetadata: GeminiGenerateContent.providerMetadata(state),
|
|
72
71
|
detail: `finish reason: ${state.finishReason}`,
|
|
73
72
|
});
|
|
@@ -22,14 +22,6 @@ interface State extends GeminiGenerateContent.Metadata {
|
|
|
22
22
|
readonly words: Array<TranscriptionWord>;
|
|
23
23
|
}
|
|
24
24
|
export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
25
|
-
readonly type: "generation-queued";
|
|
26
|
-
readonly id: string;
|
|
27
|
-
readonly position?: number | undefined;
|
|
28
|
-
} | {
|
|
29
|
-
readonly type: "generation-progress";
|
|
30
|
-
readonly id: string;
|
|
31
|
-
readonly progress?: number | undefined;
|
|
32
|
-
} | {
|
|
33
25
|
readonly type: "text-delta";
|
|
34
26
|
readonly delta: string;
|
|
35
27
|
} | {
|
|
@@ -40,6 +32,14 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
40
32
|
readonly endSeconds: number;
|
|
41
33
|
readonly speaker?: string | undefined;
|
|
42
34
|
};
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "generation-queued";
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly position?: number | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "generation-progress";
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly progress?: number | undefined;
|
|
43
43
|
} | {
|
|
44
44
|
readonly text: string;
|
|
45
45
|
readonly segments?: readonly {
|
|
@@ -58,14 +58,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
58
58
|
readonly language?: string | undefined;
|
|
59
59
|
readonly durationSeconds?: number | undefined;
|
|
60
60
|
readonly usage?: {
|
|
61
|
-
readonly type: "tokens";
|
|
62
|
-
readonly input?: number | undefined;
|
|
63
|
-
readonly output?: number | undefined;
|
|
64
|
-
readonly total?: number | undefined;
|
|
65
|
-
readonly details?: {
|
|
66
|
-
readonly [x: string]: unknown;
|
|
67
|
-
} | undefined;
|
|
68
|
-
} | {
|
|
69
61
|
readonly type: "seconds";
|
|
70
62
|
readonly seconds: number;
|
|
71
63
|
} | {
|
|
@@ -77,16 +69,15 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
77
69
|
} | {
|
|
78
70
|
readonly type: "compute";
|
|
79
71
|
readonly seconds: number;
|
|
80
|
-
} |
|
|
81
|
-
|
|
82
|
-
readonly
|
|
83
|
-
readonly
|
|
84
|
-
readonly
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: "tokens";
|
|
74
|
+
readonly input?: number | undefined;
|
|
75
|
+
readonly output?: number | undefined;
|
|
76
|
+
readonly total?: number | undefined;
|
|
77
|
+
readonly details?: {
|
|
78
|
+
readonly [x: string]: unknown;
|
|
88
79
|
} | undefined;
|
|
89
|
-
}
|
|
80
|
+
} | undefined;
|
|
90
81
|
readonly providerMetadata?: {
|
|
91
82
|
readonly [x: string]: {
|
|
92
83
|
readonly [x: string]: unknown;
|
|
@@ -97,14 +88,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
97
88
|
export declare const model: (input: MediaRoute.ModelInput) => TranscriptionModel<GoogleTranscriptionOptions>;
|
|
98
89
|
export declare const GoogleTranscription: {
|
|
99
90
|
readonly protocol: MediaProtocol.Streamed<Request, {
|
|
100
|
-
readonly type: "generation-queued";
|
|
101
|
-
readonly id: string;
|
|
102
|
-
readonly position?: number | undefined;
|
|
103
|
-
} | {
|
|
104
|
-
readonly type: "generation-progress";
|
|
105
|
-
readonly id: string;
|
|
106
|
-
readonly progress?: number | undefined;
|
|
107
|
-
} | {
|
|
108
91
|
readonly type: "text-delta";
|
|
109
92
|
readonly delta: string;
|
|
110
93
|
} | {
|
|
@@ -115,6 +98,14 @@ export declare const GoogleTranscription: {
|
|
|
115
98
|
readonly endSeconds: number;
|
|
116
99
|
readonly speaker?: string | undefined;
|
|
117
100
|
};
|
|
101
|
+
} | {
|
|
102
|
+
readonly type: "generation-queued";
|
|
103
|
+
readonly id: string;
|
|
104
|
+
readonly position?: number | undefined;
|
|
105
|
+
} | {
|
|
106
|
+
readonly type: "generation-progress";
|
|
107
|
+
readonly id: string;
|
|
108
|
+
readonly progress?: number | undefined;
|
|
118
109
|
} | {
|
|
119
110
|
readonly text: string;
|
|
120
111
|
readonly segments?: readonly {
|
|
@@ -133,14 +124,6 @@ export declare const GoogleTranscription: {
|
|
|
133
124
|
readonly language?: string | undefined;
|
|
134
125
|
readonly durationSeconds?: number | undefined;
|
|
135
126
|
readonly usage?: {
|
|
136
|
-
readonly type: "tokens";
|
|
137
|
-
readonly input?: number | undefined;
|
|
138
|
-
readonly output?: number | undefined;
|
|
139
|
-
readonly total?: number | undefined;
|
|
140
|
-
readonly details?: {
|
|
141
|
-
readonly [x: string]: unknown;
|
|
142
|
-
} | undefined;
|
|
143
|
-
} | {
|
|
144
127
|
readonly type: "seconds";
|
|
145
128
|
readonly seconds: number;
|
|
146
129
|
} | {
|
|
@@ -152,16 +135,15 @@ export declare const GoogleTranscription: {
|
|
|
152
135
|
} | {
|
|
153
136
|
readonly type: "compute";
|
|
154
137
|
readonly seconds: number;
|
|
155
|
-
} |
|
|
156
|
-
|
|
157
|
-
readonly
|
|
158
|
-
readonly
|
|
159
|
-
readonly
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
138
|
+
} | {
|
|
139
|
+
readonly type: "tokens";
|
|
140
|
+
readonly input?: number | undefined;
|
|
141
|
+
readonly output?: number | undefined;
|
|
142
|
+
readonly total?: number | undefined;
|
|
143
|
+
readonly details?: {
|
|
144
|
+
readonly [x: string]: unknown;
|
|
163
145
|
} | undefined;
|
|
164
|
-
}
|
|
146
|
+
} | undefined;
|
|
165
147
|
readonly providerMetadata?: {
|
|
166
148
|
readonly [x: string]: {
|
|
167
149
|
readonly [x: string]: unknown;
|
|
@@ -103,7 +103,6 @@ const finish = (state) => {
|
|
|
103
103
|
segments: state.segments.length === 0 ? undefined : state.segments,
|
|
104
104
|
words: state.words.length === 0 ? undefined : state.words,
|
|
105
105
|
usage: GeminiGenerateContent.usage(state.usage),
|
|
106
|
-
notices: GeminiGenerateContent.notices(route.name, state),
|
|
107
106
|
providerMetadata: GeminiGenerateContent.providerMetadata(state),
|
|
108
107
|
}),
|
|
109
108
|
]);
|
|
@@ -4,7 +4,7 @@ import { MediaRoute } from "../route/media.js";
|
|
|
4
4
|
import { type OpenString } from "../schema/index.js";
|
|
5
5
|
import { VideoModel, VideoResponse, type VideoRequestFor } from "../video.js";
|
|
6
6
|
export declare const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
7
|
-
/** Provider-native `parameters`. Common fields (`
|
|
7
|
+
/** Provider-native `parameters`. Common fields (`aspect`, `resolution`, `durationSeconds`, `seed`) live on the request. */
|
|
8
8
|
export type GoogleVideoOptions = {
|
|
9
9
|
readonly personGeneration?: OpenString<"allow_all" | "allow_adult" | "dont_allow">;
|
|
10
10
|
} & Record<string, unknown>;
|
|
@@ -68,7 +68,7 @@ const fromRequest = Effect.fn("GoogleVideo.fromRequest")(function* (request) {
|
|
|
68
68
|
},
|
|
69
69
|
],
|
|
70
70
|
parameters: mergeJsonRecords({
|
|
71
|
-
aspectRatio: request.
|
|
71
|
+
aspectRatio: request.aspect,
|
|
72
72
|
resolution: request.resolution,
|
|
73
73
|
durationSeconds: request.durationSeconds,
|
|
74
74
|
negativePrompt: request.negativePrompt,
|
|
@@ -109,22 +109,17 @@ const decodeResult = Effect.fn("GoogleVideo.decodeResult")(function* (response,
|
|
|
109
109
|
headers: context.auth,
|
|
110
110
|
}));
|
|
111
111
|
const reasons = generated?.raiMediaFilteredReasons ?? [];
|
|
112
|
-
const notices = reasons.map((reason) => ({
|
|
113
|
-
type: "filtered",
|
|
114
|
-
message: `${route.name} filtered media: ${reason}`,
|
|
115
|
-
providerMetadata: { google: { raiMediaFilteredReason: reason } },
|
|
116
|
-
}));
|
|
117
112
|
if (videos.length === 0 && (reasons.length > 0 || (generated?.raiMediaFilteredCount ?? 0) > 0))
|
|
118
113
|
return yield* output.contentPolicy(`${route.name} filtered every video${reasons.length === 0 ? "" : `: ${reasons.join("; ")}`}`);
|
|
119
114
|
if (videos.length === 0)
|
|
120
115
|
return yield* output.invalid(`${route.name} operation completed without any video`);
|
|
121
116
|
return new VideoResponse({
|
|
122
117
|
videos,
|
|
123
|
-
notices: notices.length === 0 ? undefined : notices,
|
|
124
118
|
providerMetadata: {
|
|
125
119
|
google: {
|
|
126
120
|
operation: context.token.operation,
|
|
127
121
|
raiMediaFilteredCount: generated?.raiMediaFilteredCount,
|
|
122
|
+
raiMediaFilteredReasons: generated?.raiMediaFilteredReasons,
|
|
128
123
|
metadata: operation.metadata,
|
|
129
124
|
},
|
|
130
125
|
},
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
export * as AnthropicMessages from "./anthropic-messages.js";
|
|
2
2
|
export * as BedrockConverse from "./bedrock-converse.js";
|
|
3
|
+
export * as CloudflareRunDecisions from "./cloudflare-run-decisions.js";
|
|
3
4
|
export * as CohereChat from "./cohere-chat.js";
|
|
4
5
|
export * as Gemini from "./gemini.js";
|
|
5
6
|
export * as GoogleInteractions from "./google-interactions.js";
|
|
6
7
|
export * as MistralChat from "./mistral-chat.js";
|
|
7
8
|
export * as OpenAIChat from "./openai-chat.js";
|
|
9
|
+
export * as OpenAIDecisions from "./openai-decisions.js";
|
|
8
10
|
export * as OpenAIImages from "./openai-images.js";
|
|
9
11
|
export * as OpenAICompatibleChat from "./openai-compatible-chat.js";
|
|
10
12
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
11
13
|
export * as OpenAIResponses from "./openai-responses.js";
|
|
12
14
|
export * as OpenResponses from "./open-responses.js";
|
|
13
15
|
export * as OpenResponsesChannel from "./open-responses-channel.js";
|
|
16
|
+
export * as SystemOne from "./system-one.js";
|
|
14
17
|
export * as XAIResponses from "./xai-responses.js";
|
package/dist/protocols/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
export * as AnthropicMessages from "./anthropic-messages.js";
|
|
2
2
|
export * as BedrockConverse from "./bedrock-converse.js";
|
|
3
|
+
export * as CloudflareRunDecisions from "./cloudflare-run-decisions.js";
|
|
3
4
|
export * as CohereChat from "./cohere-chat.js";
|
|
4
5
|
export * as Gemini from "./gemini.js";
|
|
5
6
|
export * as GoogleInteractions from "./google-interactions.js";
|
|
6
7
|
export * as MistralChat from "./mistral-chat.js";
|
|
7
8
|
export * as OpenAIChat from "./openai-chat.js";
|
|
9
|
+
export * as OpenAIDecisions from "./openai-decisions.js";
|
|
8
10
|
export * as OpenAIImages from "./openai-images.js";
|
|
9
11
|
export * as OpenAICompatibleChat from "./openai-compatible-chat.js";
|
|
10
12
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
11
13
|
export * as OpenAIResponses from "./openai-responses.js";
|
|
12
14
|
export * as OpenResponses from "./open-responses.js";
|
|
13
15
|
export * as OpenResponsesChannel from "./open-responses-channel.js";
|
|
16
|
+
export * as SystemOne from "./system-one.js";
|
|
14
17
|
export * as XAIResponses from "./xai-responses.js";
|
|
@@ -3,8 +3,14 @@ import { MediaProtocol } from "../route/media-protocol.js";
|
|
|
3
3
|
import { MediaRoute } from "../route/media.js";
|
|
4
4
|
import { type OpenString } from "../schema/index.js";
|
|
5
5
|
export declare const DEFAULT_BASE_URL = "https://api.meta.ai/v1";
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Provider-native options. Common fields (`n`, `aspect`, `images`) live on the request; Meta picks its own output
|
|
8
|
+
* resolution (about 2.5 megapixels), so `resolution` is ignored.
|
|
9
|
+
*/
|
|
7
10
|
export type ImageOptions = {
|
|
11
|
+
/** `WIDTHxHEIGHT` aspect ratio hint; it replaces `aspect`, so setting both fails. */
|
|
12
|
+
readonly size?: string;
|
|
13
|
+
readonly outputFormat?: OpenString<"webp" | "png" | "jpeg">;
|
|
8
14
|
readonly responseFormat?: OpenString<"b64_json" | "url">;
|
|
9
15
|
readonly reasoningStrength?: OpenString<"low" | "high">;
|
|
10
16
|
readonly toolEnablement?: {
|