@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/speech.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Effect, Schema, Stream } from "effect";
|
|
2
|
+
import { ProgressEvent, QueuedEvent } from "./generation.js";
|
|
3
|
+
import { Media } from "./media.js";
|
|
4
|
+
import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
|
|
5
|
+
import { MediaRoute } from "./route/media.js";
|
|
6
|
+
import { AIError, HttpOptions, MediaUsage, ProviderMetadata } from "./schema/index.js";
|
|
7
|
+
import { SpeechClient, Service } from "./speech-client.js";
|
|
8
|
+
export class SpeechModel extends MediaModel {
|
|
9
|
+
static fromRoute(route, input) {
|
|
10
|
+
return new SpeechModel({
|
|
11
|
+
id: input.id,
|
|
12
|
+
provider: route.protocol.provider,
|
|
13
|
+
http: input.http,
|
|
14
|
+
route: composeRoute(route, input, collectResponse),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const SpeechModelSchema = Schema.declare((value) => value instanceof SpeechModel, {
|
|
19
|
+
expected: "Speech.Model",
|
|
20
|
+
});
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Request
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
/** Provider-native: a name on OpenAI and Gemini, a voice id on ElevenLabs and Cartesia; `{ id }` is an OpenAI custom voice. */
|
|
25
|
+
export const SpeechVoice = Schema.Union([Schema.String, Schema.Struct({ id: Schema.String })]).annotate({
|
|
26
|
+
identifier: "Speech.Voice",
|
|
27
|
+
});
|
|
28
|
+
/** Granularity is provider-native: characters on ElevenLabs, words on Cartesia. */
|
|
29
|
+
export const SpeechTimestamp = Schema.Struct({
|
|
30
|
+
text: Schema.String,
|
|
31
|
+
startSeconds: Schema.Number,
|
|
32
|
+
endSeconds: Schema.Number,
|
|
33
|
+
}).annotate({ identifier: "Speech.Timestamp" });
|
|
34
|
+
export class SpeechRequest extends Schema.Class("Speech.Request")({
|
|
35
|
+
model: SpeechModelSchema,
|
|
36
|
+
text: Schema.String,
|
|
37
|
+
voice: Schema.optional(SpeechVoice),
|
|
38
|
+
format: Schema.optional(Schema.String),
|
|
39
|
+
speed: Schema.optional(Schema.Number),
|
|
40
|
+
language: Schema.optional(Schema.String),
|
|
41
|
+
instructions: Schema.optional(Schema.String),
|
|
42
|
+
timestamps: Schema.optional(Schema.Boolean),
|
|
43
|
+
providerOptions: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
44
|
+
http: Schema.optional(HttpOptions),
|
|
45
|
+
}) {
|
|
46
|
+
}
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// Response and events
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
export class SpeechResponse extends Schema.Class("Speech.Response")({
|
|
51
|
+
/** The complete audio. Headerless PCM carries `info.encoding`, `info.sampleRate`, and `info.channels`. */
|
|
52
|
+
audio: Media.AssetSchema,
|
|
53
|
+
timestamps: Schema.optional(Schema.Array(SpeechTimestamp)),
|
|
54
|
+
usage: Schema.optional(MediaUsage),
|
|
55
|
+
notices: Schema.optional(Schema.Array(Media.Notice)),
|
|
56
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
57
|
+
}) {
|
|
58
|
+
}
|
|
59
|
+
export const SpeechAudioDeltaEvent = Schema.Struct({
|
|
60
|
+
type: Schema.tag("audio-delta"),
|
|
61
|
+
chunk: Schema.Uint8Array,
|
|
62
|
+
}).annotate({ identifier: "Speech.Event.AudioDelta" });
|
|
63
|
+
export const SpeechTimestampsEvent = Schema.Struct({
|
|
64
|
+
type: Schema.tag("timestamps"),
|
|
65
|
+
items: Schema.Array(SpeechTimestamp),
|
|
66
|
+
}).annotate({ identifier: "Speech.Event.Timestamps" });
|
|
67
|
+
/** `audio` is every `audio-delta` chunk concatenated, so the route holds the whole clip in memory until `finish`. */
|
|
68
|
+
export const SpeechFinishEvent = Schema.Struct({
|
|
69
|
+
type: Schema.tag("finish"),
|
|
70
|
+
audio: Media.AssetSchema,
|
|
71
|
+
usage: Schema.optional(MediaUsage),
|
|
72
|
+
notices: Schema.optional(Schema.Array(Media.Notice)),
|
|
73
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
74
|
+
}).annotate({ identifier: "Speech.Event.Finish" });
|
|
75
|
+
const speechEventTagged = Schema.Union([
|
|
76
|
+
QueuedEvent,
|
|
77
|
+
ProgressEvent,
|
|
78
|
+
SpeechAudioDeltaEvent,
|
|
79
|
+
SpeechTimestampsEvent,
|
|
80
|
+
SpeechFinishEvent,
|
|
81
|
+
]).pipe(Schema.toTaggedUnion("type"));
|
|
82
|
+
export const SpeechEvent = Object.assign(speechEventTagged, {
|
|
83
|
+
is: {
|
|
84
|
+
generationQueued: speechEventTagged.guards["generation-queued"],
|
|
85
|
+
generationProgress: speechEventTagged.guards["generation-progress"],
|
|
86
|
+
audioDelta: speechEventTagged.guards["audio-delta"],
|
|
87
|
+
timestamps: speechEventTagged.guards.timestamps,
|
|
88
|
+
finish: speechEventTagged.guards.finish,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
const collectResponse = (events) => {
|
|
92
|
+
const finish = events.find(SpeechEvent.is.finish);
|
|
93
|
+
// Every speech protocol's `finish` emits the terminal event or fails, so a completed stream always has one.
|
|
94
|
+
if (finish === undefined)
|
|
95
|
+
return Effect.die(new Error("The speech stream completed without a finish event"));
|
|
96
|
+
const timestamps = events.filter(SpeechEvent.is.timestamps).flatMap((event) => event.items);
|
|
97
|
+
return Effect.succeed(new SpeechResponse({
|
|
98
|
+
audio: finish.audio,
|
|
99
|
+
timestamps: timestamps.length === 0 ? undefined : timestamps,
|
|
100
|
+
usage: finish.usage,
|
|
101
|
+
notices: finish.notices,
|
|
102
|
+
providerMetadata: finish.providerMetadata,
|
|
103
|
+
}));
|
|
104
|
+
};
|
|
105
|
+
export function request(input) {
|
|
106
|
+
if (input instanceof SpeechRequest)
|
|
107
|
+
return input;
|
|
108
|
+
return new SpeechRequest({
|
|
109
|
+
...input,
|
|
110
|
+
http: HttpOptions.make(input.http),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const requestEffect = (input) => tryRequest(() => request(input));
|
|
114
|
+
export function generate(input) {
|
|
115
|
+
return requestEffect(input).pipe(Effect.flatMap((request) => SpeechClient.generate(request)));
|
|
116
|
+
}
|
|
117
|
+
export function stream(input) {
|
|
118
|
+
return Stream.unwrap(requestEffect(input).pipe(Effect.map((request) => SpeechClient.stream(request))));
|
|
119
|
+
}
|
|
120
|
+
export const Speech = {
|
|
121
|
+
request,
|
|
122
|
+
generate,
|
|
123
|
+
stream,
|
|
124
|
+
};
|
package/dist/testing.d.ts
CHANGED
|
@@ -1743,11 +1743,11 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
|
|
|
1743
1743
|
} | undefined;
|
|
1744
1744
|
}, never, never>;
|
|
1745
1745
|
/** Provides one shared implementation under the normal client and test-control tags. */
|
|
1746
|
-
export declare const testLayer: (options?: LayerOptions) => Layer.Layer<import("./route/client.js").
|
|
1746
|
+
export declare const testLayer: (options?: LayerOptions) => Layer.Layer<import("./route/client.js").LLMClientService | Test, never, never>;
|
|
1747
1747
|
/** @deprecated Use testLayer; retained for published callers of the legacy control interface. */
|
|
1748
1748
|
export declare const layer: (options?: LayerOptions) => Layer.Layer<Service, never, never>;
|
|
1749
1749
|
/** @deprecated testLayer provides LLMClient.Service directly. */
|
|
1750
|
-
export declare const clientLayer: Layer.Layer<import("./route/client.js").
|
|
1750
|
+
export declare const clientLayer: Layer.Layer<import("./route/client.js").LLMClientService, never, Service>;
|
|
1751
1751
|
export declare const push: (...responses: readonly Response[]) => Effect.Effect<void, never, Service>;
|
|
1752
1752
|
export declare const always: (response: Response) => Effect.Effect<void, never, Service>;
|
|
1753
1753
|
export declare const wait: (count: number) => Effect.Effect<void, never, Service>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { MediaClient } from "./media-client.js";
|
|
3
|
+
import { type TranscriptionEvent, type TranscriptionRequestFor, type TranscriptionResponse } from "./transcription.js";
|
|
4
|
+
export type Interface = MediaClient.Interface<TranscriptionRequestFor, TranscriptionEvent, TranscriptionResponse>;
|
|
5
|
+
declare const TranscriptionClientService_base: Context.ServiceClass<TranscriptionClientService, "@opencode/TranscriptionClient", Interface>;
|
|
6
|
+
export declare class TranscriptionClientService extends TranscriptionClientService_base {
|
|
7
|
+
}
|
|
8
|
+
export declare const Service: typeof TranscriptionClientService;
|
|
9
|
+
export type Service = TranscriptionClientService;
|
|
10
|
+
export declare const TranscriptionClient: {
|
|
11
|
+
readonly layer: import("effect/Layer").Layer<TranscriptionClientService, never, import("./route/executor-service.js").RequestExecutorService>;
|
|
12
|
+
readonly generate: (request: TranscriptionRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<TranscriptionResponse, import("./index.js").AIError, TranscriptionClientService>;
|
|
13
|
+
readonly stream: (request: TranscriptionRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<import("./generation.js").Observation | {
|
|
14
|
+
readonly type: "text-delta";
|
|
15
|
+
readonly delta: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly type: "segment";
|
|
18
|
+
readonly segment: {
|
|
19
|
+
readonly text: string;
|
|
20
|
+
readonly startSeconds: number;
|
|
21
|
+
readonly endSeconds: number;
|
|
22
|
+
readonly speaker?: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: "finish";
|
|
26
|
+
readonly text: string;
|
|
27
|
+
readonly durationSeconds?: number | undefined;
|
|
28
|
+
readonly providerMetadata?: {
|
|
29
|
+
readonly [x: string]: {
|
|
30
|
+
readonly [x: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
} | undefined;
|
|
33
|
+
readonly usage?: {
|
|
34
|
+
readonly type: "tokens";
|
|
35
|
+
readonly input?: number | undefined;
|
|
36
|
+
readonly output?: number | undefined;
|
|
37
|
+
readonly total?: number | undefined;
|
|
38
|
+
readonly details?: {
|
|
39
|
+
readonly [x: string]: unknown;
|
|
40
|
+
} | undefined;
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: "seconds";
|
|
43
|
+
readonly seconds: number;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "characters";
|
|
46
|
+
readonly characters: number;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "credits";
|
|
49
|
+
readonly credits: number;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: "compute";
|
|
52
|
+
readonly seconds: number;
|
|
53
|
+
} | undefined;
|
|
54
|
+
readonly notices?: readonly {
|
|
55
|
+
readonly type: "other" | "moderated" | "filtered";
|
|
56
|
+
readonly message: string;
|
|
57
|
+
readonly providerMetadata?: {
|
|
58
|
+
readonly [x: string]: {
|
|
59
|
+
readonly [x: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
} | undefined;
|
|
62
|
+
}[] | undefined;
|
|
63
|
+
readonly language?: string | undefined;
|
|
64
|
+
readonly segments?: readonly {
|
|
65
|
+
readonly text: string;
|
|
66
|
+
readonly startSeconds: number;
|
|
67
|
+
readonly endSeconds: number;
|
|
68
|
+
readonly speaker?: string | undefined;
|
|
69
|
+
}[] | undefined;
|
|
70
|
+
readonly words?: readonly {
|
|
71
|
+
readonly text: string;
|
|
72
|
+
readonly startSeconds: number;
|
|
73
|
+
readonly endSeconds: number;
|
|
74
|
+
readonly speaker?: string | undefined;
|
|
75
|
+
readonly confidence?: number | undefined;
|
|
76
|
+
}[] | undefined;
|
|
77
|
+
}, import("./index.js").AIError, TranscriptionClientService>;
|
|
78
|
+
readonly start: (request: TranscriptionRequestFor) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./index.js").AIError, TranscriptionClientService>;
|
|
79
|
+
readonly resume: (model: import("./transcription.js").TranscriptionModel<import("./media-model.js").MediaModel.Options>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./index.js").AIError, TranscriptionClientService>;
|
|
80
|
+
readonly Service: typeof TranscriptionClientService;
|
|
81
|
+
};
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { MediaClient } from "./media-client.js";
|
|
3
|
+
import { TranscriptionFinishEvent, } from "./transcription.js";
|
|
4
|
+
export class TranscriptionClientService extends Context.Service()("@opencode/TranscriptionClient") {
|
|
5
|
+
}
|
|
6
|
+
export const Service = TranscriptionClientService;
|
|
7
|
+
export const TranscriptionClient = {
|
|
8
|
+
Service,
|
|
9
|
+
...MediaClient.make(Service, {
|
|
10
|
+
modality: "transcription",
|
|
11
|
+
responseEvents: (response) => [TranscriptionFinishEvent.make({ ...response })],
|
|
12
|
+
}),
|
|
13
|
+
};
|