@opencode/ai 2.0.15 → 2.0.17
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 +441 -99
- package/dist/ai-client.d.ts +8 -0
- package/dist/ai-client.js +12 -0
- package/dist/experimental/evaluation-client.d.ts +3 -3
- package/dist/experimental/evaluation-client.js +1 -1
- package/dist/experimental/evaluation.js +1 -1
- package/dist/generation.d.ts +39 -29
- package/dist/generation.js +62 -36
- package/dist/image-client.d.ts +59 -17
- package/dist/image-client.js +16 -24
- package/dist/image.d.ts +394 -55
- package/dist/image.js +48 -57
- package/dist/index.d.ts +15 -2
- package/dist/index.js +10 -0
- package/dist/llm.d.ts +7 -5
- package/dist/llm.js +10 -4
- package/dist/media-client.d.ts +30 -0
- package/dist/media-client.js +51 -0
- package/dist/media-model.d.ts +43 -0
- package/dist/media-model.js +47 -0
- package/dist/media.d.ts +10 -9
- package/dist/media.js +11 -12
- package/dist/promise.d.ts +473 -15
- package/dist/promise.js +71 -13
- package/dist/protocols/alibaba-chat.d.ts +12 -0
- package/dist/protocols/alibaba-chat.js +4 -1
- package/dist/protocols/alibaba-messages.d.ts +1 -1
- package/dist/protocols/alibaba-messages.js +6 -4
- package/dist/protocols/alibaba-responses.d.ts +2 -2
- package/dist/protocols/anthropic-messages.d.ts +34 -34
- package/dist/protocols/anthropic-messages.js +14 -9
- package/dist/protocols/assemblyai-transcription.d.ts +41 -0
- package/dist/protocols/assemblyai-transcription.js +136 -0
- package/dist/protocols/bedrock-converse.d.ts +7 -0
- package/dist/protocols/bedrock-converse.js +39 -19
- package/dist/protocols/bfl-images.d.ts +38 -0
- package/dist/protocols/bfl-images.js +153 -0
- package/dist/protocols/cartesia-speech.d.ts +143 -0
- package/dist/protocols/cartesia-speech.js +120 -0
- package/dist/protocols/deepgram-speech.d.ts +135 -0
- package/dist/protocols/deepgram-speech.js +91 -0
- package/dist/protocols/deepgram-transcription.d.ts +26 -0
- package/dist/protocols/deepgram-transcription.js +125 -0
- package/dist/protocols/elevenlabs-speech.d.ts +138 -0
- package/dist/protocols/elevenlabs-speech.js +111 -0
- package/dist/protocols/fal-images.d.ts +25 -0
- package/dist/protocols/fal-images.js +104 -0
- package/dist/protocols/fal-video.d.ts +29 -0
- package/dist/protocols/fal-video.js +73 -0
- package/dist/protocols/gemini.d.ts +22 -22
- package/dist/protocols/gemini.js +19 -36
- package/dist/protocols/google-images.d.ts +3 -3
- package/dist/protocols/google-images.js +12 -34
- package/dist/protocols/google-speech.d.ts +146 -0
- package/dist/protocols/google-speech.js +88 -0
- package/dist/protocols/google-transcription.d.ts +174 -0
- package/dist/protocols/google-transcription.js +126 -0
- package/dist/protocols/google-video.d.ts +26 -0
- package/dist/protocols/google-video.js +142 -0
- package/dist/protocols/meta-images.d.ts +3 -4
- package/dist/protocols/meta-images.js +13 -29
- package/dist/protocols/meta-messages.d.ts +5 -5
- package/dist/protocols/meta-responses.d.ts +4 -4
- package/dist/protocols/meta-responses.js +6 -4
- package/dist/protocols/open-responses.d.ts +10 -9
- package/dist/protocols/open-responses.js +4 -9
- package/dist/protocols/openai-chat.d.ts +84 -0
- package/dist/protocols/openai-chat.js +28 -17
- package/dist/protocols/openai-compatible-chat.d.ts +12 -0
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-images.d.ts +130 -7
- package/dist/protocols/openai-images.js +143 -91
- package/dist/protocols/openai-responses.d.ts +20 -20
- package/dist/protocols/openai-responses.js +31 -31
- package/dist/protocols/openai-speech.d.ts +136 -0
- package/dist/protocols/openai-speech.js +97 -0
- package/dist/protocols/openai-transcription.d.ts +211 -0
- package/dist/protocols/openai-transcription.js +202 -0
- package/dist/protocols/replicate-images.d.ts +28 -0
- package/dist/protocols/replicate-images.js +127 -0
- package/dist/protocols/runway-video.d.ts +38 -0
- package/dist/protocols/runway-video.js +140 -0
- package/dist/protocols/shared.d.ts +21 -17
- package/dist/protocols/shared.js +27 -36
- package/dist/protocols/stability-images.d.ts +39 -0
- package/dist/protocols/stability-images.js +136 -0
- package/dist/protocols/utils/fal-queue.d.ts +26 -0
- package/dist/protocols/utils/fal-queue.js +67 -0
- package/dist/protocols/utils/gemini-generate-content.d.ts +65 -0
- package/dist/protocols/utils/gemini-generate-content.js +65 -0
- package/dist/protocols/utils/gemini-json-schema.d.ts +3 -0
- package/dist/protocols/utils/gemini-json-schema.js +76 -0
- package/dist/protocols/utils/media-input.d.ts +23 -1
- package/dist/protocols/utils/media-input.js +40 -0
- package/dist/protocols/utils/responses-checkpoint.js +3 -7
- package/dist/protocols/utils/responses-compaction.d.ts +3 -1
- package/dist/protocols/utils/responses-compaction.js +16 -3
- package/dist/protocols/utils/speech-stream.d.ts +49 -0
- package/dist/protocols/utils/speech-stream.js +64 -0
- package/dist/protocols/utils/tool-schema.d.ts +2 -2
- package/dist/protocols/utils/tool-schema.js +62 -19
- package/dist/protocols/xai-images.d.ts +4 -4
- package/dist/protocols/xai-images.js +14 -40
- package/dist/protocols/xai-responses.d.ts +2 -2
- package/dist/protocols/xai-responses.js +1 -1
- package/dist/protocols/xai-video.d.ts +34 -0
- package/dist/protocols/xai-video.js +141 -0
- package/dist/protocols/zai-chat.d.ts +13 -1
- package/dist/protocols/zai-images.d.ts +2 -2
- package/dist/protocols/zai-images.js +11 -14
- package/dist/protocols/zai-messages.d.ts +1 -1
- package/dist/provider-error.js +10 -1
- package/dist/providers/alibaba.d.ts +15 -3
- package/dist/providers/amazon-bedrock-mantle.d.ts +14 -2
- package/dist/providers/amazon-bedrock.d.ts +2 -0
- package/dist/providers/amazon-bedrock.js +1 -0
- package/dist/providers/anthropic-compatible.d.ts +5 -5
- package/dist/providers/anthropic.d.ts +5 -5
- package/dist/providers/assemblyai.d.ts +25 -0
- package/dist/providers/assemblyai.js +24 -0
- package/dist/providers/azure.d.ts +20 -8
- package/dist/providers/azure.js +2 -2
- package/dist/providers/baseten.d.ts +24 -0
- package/dist/providers/black-forest-labs.d.ts +25 -0
- package/dist/providers/black-forest-labs.js +23 -0
- package/dist/providers/cartesia.d.ts +24 -0
- package/dist/providers/cartesia.js +17 -0
- package/dist/providers/cerebras.d.ts +24 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +42 -18
- package/dist/providers/cloudflare-workers-ai.d.ts +24 -0
- package/dist/providers/deepgram.d.ts +29 -0
- package/dist/providers/deepgram.js +25 -0
- package/dist/providers/deepinfra.d.ts +24 -0
- package/dist/providers/deepseek.d.ts +24 -0
- package/dist/providers/elevenlabs.d.ts +24 -0
- package/dist/providers/elevenlabs.js +23 -0
- package/dist/providers/fal.d.ts +29 -0
- package/dist/providers/fal.js +26 -0
- package/dist/providers/fireworks.d.ts +24 -0
- package/dist/providers/google-vertex-chat.d.ts +12 -0
- package/dist/providers/google-vertex-messages.d.ts +5 -5
- package/dist/providers/google-vertex-responses.d.ts +2 -2
- package/dist/providers/google-vertex.d.ts +6 -6
- package/dist/providers/google.d.ts +21 -6
- package/dist/providers/google.js +13 -9
- package/dist/providers/groq.d.ts +24 -0
- package/dist/providers/index.d.ts +9 -0
- package/dist/providers/index.js +9 -0
- package/dist/providers/meta.d.ts +22 -10
- package/dist/providers/meta.js +4 -8
- package/dist/providers/minimax.d.ts +19 -7
- package/dist/providers/moonshot.d.ts +19 -7
- package/dist/providers/moonshot.js +3 -3
- package/dist/providers/openai-compatible-responses.d.ts +2 -2
- package/dist/providers/openai-compatible.d.ts +12 -0
- package/dist/providers/openai-options.d.ts +3 -9
- package/dist/providers/openai-options.js +4 -7
- package/dist/providers/openai.d.ts +33 -12
- package/dist/providers/openai.js +17 -9
- package/dist/providers/opencode-zen.js +1 -1
- package/dist/providers/openrouter.d.ts +54 -7
- package/dist/providers/openrouter.js +10 -5
- package/dist/providers/replicate.d.ts +25 -0
- package/dist/providers/replicate.js +17 -0
- package/dist/providers/runway.d.ts +24 -0
- package/dist/providers/runway.js +17 -0
- package/dist/providers/stability.d.ts +28 -0
- package/dist/providers/stability.js +18 -0
- package/dist/providers/togetherai.d.ts +24 -0
- package/dist/providers/typesafe-ai.js +1 -1
- package/dist/providers/vercel-ai-gateway.js +1 -1
- package/dist/providers/xai.d.ts +17 -0
- package/dist/providers/xai.js +7 -9
- package/dist/providers/zai-coding-plan.d.ts +16 -4
- package/dist/providers/zai.d.ts +13 -1
- package/dist/providers/zai.js +4 -8
- package/dist/route/auth.d.ts +5 -2
- package/dist/route/auth.js +20 -13
- package/dist/route/client.d.ts +9 -7
- package/dist/route/client.js +6 -8
- package/dist/route/endpoint.d.ts +1 -0
- package/dist/route/endpoint.js +2 -2
- package/dist/route/executor-service.d.ts +4 -2
- package/dist/route/executor-service.js +2 -1
- package/dist/route/executor.d.ts +3 -1
- package/dist/route/executor.js +7 -0
- package/dist/route/framing.d.ts +15 -2
- package/dist/route/framing.js +53 -4
- package/dist/route/index.d.ts +1 -1
- package/dist/route/media-protocol.d.ts +145 -18
- package/dist/route/media-protocol.js +96 -28
- package/dist/route/media.d.ts +54 -9
- package/dist/route/media.js +194 -38
- package/dist/route/protocol.d.ts +3 -1
- package/dist/schema/events.d.ts +0 -6
- package/dist/schema/messages.d.ts +0 -3
- package/dist/schema/options.d.ts +10 -6
- package/dist/schema/options.js +10 -5
- package/dist/speech-client.d.ts +66 -0
- package/dist/speech-client.js +21 -0
- package/dist/speech.d.ts +1307 -0
- package/dist/speech.js +124 -0
- package/dist/testing.d.ts +2 -2
- package/dist/transcription-client.d.ts +82 -0
- package/dist/transcription-client.js +13 -0
- package/dist/transcription.d.ts +1492 -0
- package/dist/transcription.js +127 -0
- package/dist/utils/bytes.d.ts +1 -0
- package/dist/utils/bytes.js +10 -0
- package/dist/utils/json.d.ts +4 -0
- package/dist/utils/json.js +4 -0
- package/dist/utils/media-type.d.ts +3 -1
- package/dist/utils/media-type.js +25 -2
- package/dist/video-client.d.ts +59 -0
- package/dist/video-client.js +20 -0
- package/dist/video.d.ts +1351 -0
- package/dist/video.js +118 -0
- package/package.json +3 -3
- package/dist/protocols/utils/gemini-tool-schema.d.ts +0 -2
- package/dist/protocols/utils/gemini-tool-schema.js +0 -103
- package/dist/protocols/utils/meta-image.d.ts +0 -2
- package/dist/protocols/utils/meta-image.js +0 -13
- package/dist/protocols/utils/openai-image.d.ts +0 -5
- package/dist/protocols/utils/openai-image.js +0 -18
package/dist/schema/options.js
CHANGED
|
@@ -39,8 +39,12 @@ export class HttpOptions extends Schema.Class("AI.HttpOptions")({
|
|
|
39
39
|
}) {
|
|
40
40
|
}
|
|
41
41
|
(function (HttpOptions) {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
function make(input) {
|
|
43
|
+
if (input === undefined || input instanceof HttpOptions)
|
|
44
|
+
return input;
|
|
45
|
+
return new HttpOptions(input);
|
|
46
|
+
}
|
|
47
|
+
HttpOptions.make = make;
|
|
44
48
|
})(HttpOptions || (HttpOptions = {}));
|
|
45
49
|
export const mergeHttpOptions = (...items) => {
|
|
46
50
|
const body = mergeJsonRecords(...items.map((item) => item?.body));
|
|
@@ -93,16 +97,17 @@ export class LanguageModelDefaults extends Schema.Class("LLM.LanguageModelDefaul
|
|
|
93
97
|
return new LanguageModelDefaults({
|
|
94
98
|
generation: input.generation === undefined ? undefined : GenerationOptions.make(input.generation),
|
|
95
99
|
providerOptions: input.providerOptions,
|
|
96
|
-
http:
|
|
100
|
+
http: HttpOptions.make(input.http),
|
|
97
101
|
});
|
|
98
102
|
};
|
|
99
103
|
})(LanguageModelDefaults || (LanguageModelDefaults = {}));
|
|
100
104
|
export const ReasoningEfforts = ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
101
105
|
export const ReasoningEffort = Schema.declare((value) => typeof value === "string", { title: "ReasoningEffort" });
|
|
102
|
-
|
|
106
|
+
/** Tool schema sanitizer for a model family. `none` opts out of the protocol and model-name defaults. */
|
|
107
|
+
export const LanguageModelSanitizerCompatibility = Schema.Literals(["gemini", "moonshot", "none"]);
|
|
103
108
|
export const LanguageModelMaxTokensFieldCompatibility = Schema.Literals(["max_completion_tokens", "max_tokens"]);
|
|
104
109
|
export class LanguageModelCompatibility extends Schema.Class("LLM.LanguageModelCompatibility")({
|
|
105
|
-
|
|
110
|
+
sanitizer: Schema.optional(LanguageModelSanitizerCompatibility),
|
|
106
111
|
reasoningField: Schema.optional(Schema.String),
|
|
107
112
|
/** Require every assistant message to include its reasoning field, even when empty. */
|
|
108
113
|
requireReasoning: Schema.optional(Schema.Boolean),
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { MediaClient } from "./media-client.js";
|
|
3
|
+
import { type SpeechEvent, type SpeechRequestFor, type SpeechResponse } from "./speech.js";
|
|
4
|
+
export type Interface = MediaClient.Interface<SpeechRequestFor, SpeechEvent, SpeechResponse>;
|
|
5
|
+
declare const SpeechClientService_base: Context.ServiceClass<SpeechClientService, "@opencode/SpeechClient", Interface>;
|
|
6
|
+
export declare class SpeechClientService extends SpeechClientService_base {
|
|
7
|
+
}
|
|
8
|
+
export declare const Service: typeof SpeechClientService;
|
|
9
|
+
export type Service = SpeechClientService;
|
|
10
|
+
export declare const SpeechClient: {
|
|
11
|
+
readonly layer: import("effect/Layer").Layer<SpeechClientService, never, import("./route/executor-service.js").RequestExecutorService>;
|
|
12
|
+
readonly generate: (request: SpeechRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<SpeechResponse, import("./index.js").AIError, SpeechClientService>;
|
|
13
|
+
readonly stream: (request: SpeechRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<import("./generation.js").Observation | {
|
|
14
|
+
readonly type: "audio-delta";
|
|
15
|
+
readonly chunk: Uint8Array<ArrayBufferLike>;
|
|
16
|
+
} | {
|
|
17
|
+
readonly type: "timestamps";
|
|
18
|
+
readonly items: readonly {
|
|
19
|
+
readonly text: string;
|
|
20
|
+
readonly startSeconds: number;
|
|
21
|
+
readonly endSeconds: number;
|
|
22
|
+
}[];
|
|
23
|
+
} | {
|
|
24
|
+
readonly type: "finish";
|
|
25
|
+
readonly audio: import("./media.js").Asset;
|
|
26
|
+
readonly providerMetadata?: {
|
|
27
|
+
readonly [x: string]: {
|
|
28
|
+
readonly [x: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
} | undefined;
|
|
31
|
+
readonly usage?: {
|
|
32
|
+
readonly type: "tokens";
|
|
33
|
+
readonly input?: number | undefined;
|
|
34
|
+
readonly output?: number | undefined;
|
|
35
|
+
readonly total?: number | undefined;
|
|
36
|
+
readonly details?: {
|
|
37
|
+
readonly [x: string]: unknown;
|
|
38
|
+
} | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "seconds";
|
|
41
|
+
readonly seconds: number;
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: "characters";
|
|
44
|
+
readonly characters: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "credits";
|
|
47
|
+
readonly credits: number;
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "compute";
|
|
50
|
+
readonly seconds: number;
|
|
51
|
+
} | undefined;
|
|
52
|
+
readonly notices?: readonly {
|
|
53
|
+
readonly type: "other" | "moderated" | "filtered";
|
|
54
|
+
readonly message: string;
|
|
55
|
+
readonly providerMetadata?: {
|
|
56
|
+
readonly [x: string]: {
|
|
57
|
+
readonly [x: string]: unknown;
|
|
58
|
+
};
|
|
59
|
+
} | undefined;
|
|
60
|
+
}[] | undefined;
|
|
61
|
+
}, import("./index.js").AIError, SpeechClientService>;
|
|
62
|
+
readonly start: (request: SpeechRequestFor) => import("effect/Effect").Effect<import("./generation.js").Generation<SpeechResponse>, import("./index.js").AIError, SpeechClientService>;
|
|
63
|
+
readonly resume: (model: import("./speech.js").SpeechModel<import("./media-model.js").MediaModel.Options>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<SpeechResponse>, import("./index.js").AIError, SpeechClientService>;
|
|
64
|
+
readonly Service: typeof SpeechClientService;
|
|
65
|
+
};
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { MediaClient } from "./media-client.js";
|
|
3
|
+
import { SpeechTimestampsEvent, SpeechFinishEvent, } from "./speech.js";
|
|
4
|
+
export class SpeechClientService extends Context.Service()("@opencode/SpeechClient") {
|
|
5
|
+
}
|
|
6
|
+
export const Service = SpeechClientService;
|
|
7
|
+
export const SpeechClient = {
|
|
8
|
+
Service,
|
|
9
|
+
...MediaClient.make(Service, {
|
|
10
|
+
modality: "speech",
|
|
11
|
+
responseEvents: (response) => [
|
|
12
|
+
...(response.timestamps === undefined ? [] : [SpeechTimestampsEvent.make({ items: response.timestamps })]),
|
|
13
|
+
SpeechFinishEvent.make({
|
|
14
|
+
audio: response.audio,
|
|
15
|
+
usage: response.usage,
|
|
16
|
+
notices: response.notices,
|
|
17
|
+
providerMetadata: response.providerMetadata,
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
};
|