@opencode/ai 0.0.0-dev-20048 → 0.0.0-dev-20052
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 +65 -1
- package/dist/generation.d.ts +13 -9
- package/dist/generation.js +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/promise.d.ts +164 -3
- package/dist/promise.js +11 -1
- package/dist/protocols/assemblyai-transcription.d.ts +40 -0
- package/dist/protocols/assemblyai-transcription.js +138 -0
- package/dist/protocols/deepgram-speech.js +17 -15
- package/dist/protocols/deepgram-transcription.d.ts +25 -0
- package/dist/protocols/deepgram-transcription.js +129 -0
- package/dist/protocols/gemini.d.ts +2 -2
- package/dist/protocols/gemini.js +2 -6
- package/dist/protocols/google-images.js +2 -14
- package/dist/protocols/google-speech.d.ts +2 -32
- package/dist/protocols/google-speech.js +22 -60
- package/dist/protocols/google-transcription.d.ts +173 -0
- package/dist/protocols/google-transcription.js +138 -0
- package/dist/protocols/openai-images.js +4 -7
- package/dist/protocols/openai-transcription.d.ts +207 -0
- package/dist/protocols/openai-transcription.js +190 -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/media-input.d.ts +4 -0
- package/dist/protocols/utils/media-input.js +14 -0
- package/dist/providers/assemblyai.d.ts +25 -0
- package/dist/providers/assemblyai.js +29 -0
- package/dist/providers/deepgram.d.ts +5 -0
- package/dist/providers/deepgram.js +5 -2
- package/dist/providers/google.d.ts +5 -0
- package/dist/providers/google.js +3 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/openai.d.ts +5 -0
- package/dist/providers/openai.js +4 -0
- package/dist/route/media-protocol.d.ts +15 -3
- package/dist/route/media-protocol.js +6 -0
- package/dist/route/media.d.ts +5 -2
- package/dist/route/media.js +62 -40
- package/dist/transcription-client.d.ts +28 -0
- package/dist/transcription-client.js +69 -0
- package/dist/transcription.d.ts +1504 -0
- package/dist/transcription.js +140 -0
- package/dist/utils/media-type.d.ts +1 -0
- package/dist/utils/media-type.js +14 -0
- package/dist/video-client.d.ts +1 -1
- package/dist/video-client.js +3 -6
- package/dist/video.d.ts +1 -15
- package/dist/video.js +2 -14
- package/package.json +3 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Stream } from "effect";
|
|
2
|
+
import { type AwaitOptions, type Generation } from "./generation.js";
|
|
3
|
+
import { RequestExecutor } from "./route/executor.js";
|
|
4
|
+
import type { AIError } from "./schema/index.js";
|
|
5
|
+
import { type TranscriptionEvent, type TranscriptionModel, type TranscriptionOptions, type TranscriptionRequestFor, type TranscriptionResponse } from "./transcription.js";
|
|
6
|
+
export interface Interface {
|
|
7
|
+
readonly generate: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Effect.Effect<TranscriptionResponse, AIError>;
|
|
8
|
+
readonly stream: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Stream.Stream<TranscriptionEvent, AIError>;
|
|
9
|
+
readonly start: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>) => Effect.Effect<Generation<TranscriptionResponse>, AIError>;
|
|
10
|
+
readonly resume: <Options extends TranscriptionOptions>(model: TranscriptionModel<Options>, token: unknown) => Effect.Effect<Generation<TranscriptionResponse>, AIError>;
|
|
11
|
+
}
|
|
12
|
+
declare const Service_base: Context.ServiceClass<Service, "@opencode/TranscriptionClient", Interface>;
|
|
13
|
+
export declare class Service extends Service_base {
|
|
14
|
+
}
|
|
15
|
+
export declare const generate: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Effect.Effect<TranscriptionResponse, AIError, Service>;
|
|
16
|
+
export declare const stream: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Stream.Stream<TranscriptionEvent, AIError, Service>;
|
|
17
|
+
export declare const start: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
|
|
18
|
+
export declare const resume: <Options extends TranscriptionOptions>(model: TranscriptionModel<Options>, token: unknown) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
|
|
19
|
+
export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>;
|
|
20
|
+
export declare const TranscriptionClient: {
|
|
21
|
+
readonly Service: typeof Service;
|
|
22
|
+
readonly layer: Layer.Layer<Service, never, RequestExecutor.Service>;
|
|
23
|
+
readonly generate: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Effect.Effect<TranscriptionResponse, AIError, Service>;
|
|
24
|
+
readonly stream: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Stream.Stream<TranscriptionEvent, AIError, Service>;
|
|
25
|
+
readonly start: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
|
|
26
|
+
readonly resume: <Options extends TranscriptionOptions>(model: TranscriptionModel<Options>, token: unknown) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Stream } from "effect";
|
|
2
|
+
import { resultEvents } from "./generation.js";
|
|
3
|
+
import { ProviderShared } from "./protocols/shared.js";
|
|
4
|
+
import { RequestExecutor } from "./route/executor.js";
|
|
5
|
+
import { responseEvents, } from "./transcription.js";
|
|
6
|
+
export class Service extends Context.Service()("@opencode/TranscriptionClient") {
|
|
7
|
+
}
|
|
8
|
+
export const generate = (request, options) => Effect.gen(function* () {
|
|
9
|
+
const client = yield* Service;
|
|
10
|
+
return yield* client.generate(request, options);
|
|
11
|
+
});
|
|
12
|
+
export const stream = (request, options) => Stream.unwrap(Effect.gen(function* () {
|
|
13
|
+
const client = yield* Service;
|
|
14
|
+
return client.stream(request, options);
|
|
15
|
+
}));
|
|
16
|
+
export const start = (request) => Effect.gen(function* () {
|
|
17
|
+
const client = yield* Service;
|
|
18
|
+
return yield* client.start(request);
|
|
19
|
+
});
|
|
20
|
+
export const resume = (model, token) => Effect.gen(function* () {
|
|
21
|
+
const client = yield* Service;
|
|
22
|
+
return yield* client.resume(model, token);
|
|
23
|
+
});
|
|
24
|
+
const notQueued = (route, operation) => ProviderShared.unsupportedOperation({
|
|
25
|
+
operation: `transcription.${operation}`,
|
|
26
|
+
provider: route.provider,
|
|
27
|
+
route: route.id,
|
|
28
|
+
message: `${route.provider}/${route.id} is not a queued route; use Transcription.generate or Transcription.stream`,
|
|
29
|
+
});
|
|
30
|
+
export const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
31
|
+
const executor = yield* RequestExecutor.Service;
|
|
32
|
+
const start = (request) => {
|
|
33
|
+
const route = request.model.route;
|
|
34
|
+
if (route.kind !== "queued")
|
|
35
|
+
return Effect.fail(notQueued(route, "start"));
|
|
36
|
+
return route.start(request, executor.execute);
|
|
37
|
+
};
|
|
38
|
+
return Service.of({
|
|
39
|
+
start,
|
|
40
|
+
resume: (model, token) => {
|
|
41
|
+
const route = model.route;
|
|
42
|
+
if (route.kind !== "queued")
|
|
43
|
+
return Effect.fail(notQueued(route, "resume"));
|
|
44
|
+
return route.resume(model, token, executor.execute);
|
|
45
|
+
},
|
|
46
|
+
generate: (request, options) => {
|
|
47
|
+
const route = request.model.route;
|
|
48
|
+
if (route.kind !== "queued")
|
|
49
|
+
return route.generate(request, executor.execute);
|
|
50
|
+
return start(request).pipe(Effect.flatMap((generation) => generation.await(options)));
|
|
51
|
+
},
|
|
52
|
+
stream: (request, options) => {
|
|
53
|
+
const route = request.model.route;
|
|
54
|
+
if (route.kind === "stream")
|
|
55
|
+
return route.stream(request, executor.execute);
|
|
56
|
+
if (route.kind === "queued")
|
|
57
|
+
return Stream.unwrap(start(request).pipe(Effect.map((generation) => resultEvents(generation, responseEvents, options))));
|
|
58
|
+
return Stream.fromIterableEffect(Effect.map(route.generate(request, executor.execute), responseEvents));
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}));
|
|
62
|
+
export const TranscriptionClient = {
|
|
63
|
+
Service,
|
|
64
|
+
layer,
|
|
65
|
+
generate,
|
|
66
|
+
stream,
|
|
67
|
+
start,
|
|
68
|
+
resume,
|
|
69
|
+
};
|