@opencode/ai 2.2.0 → 2.2.1
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 +66 -62
- package/dist/effect.d.ts +1 -1
- package/dist/effect.js +1 -1
- package/dist/image-client.d.ts +45 -0
- package/dist/index.d.ts +38 -20
- package/dist/index.js +14 -2
- package/dist/media-client.d.ts +1 -0
- package/dist/media-client.js +1 -0
- package/dist/protocols/alibaba-chat.d.ts +39 -4
- package/dist/protocols/alibaba-responses.d.ts +20 -3
- package/dist/protocols/google-images.js +3 -1
- package/dist/protocols/meta-responses.d.ts +40 -6
- package/dist/protocols/meta-responses.js +1 -1
- package/dist/protocols/minimax-images.d.ts +25 -0
- package/dist/protocols/minimax-images.js +150 -0
- package/dist/protocols/open-responses.d.ts +182 -27
- package/dist/protocols/open-responses.js +108 -36
- package/dist/protocols/openai-chat.d.ts +438 -46
- package/dist/protocols/openai-chat.js +121 -39
- package/dist/protocols/openai-compatible-chat.d.ts +35 -4
- package/dist/protocols/openai-compatible-responses.d.ts +20 -3
- package/dist/protocols/openai-freeform.d.ts +47 -0
- package/dist/protocols/openai-freeform.js +54 -0
- package/dist/protocols/openai-images.d.ts +16 -1
- package/dist/protocols/openai-images.js +49 -17
- package/dist/protocols/openai-responses.d.ts +120 -18
- package/dist/protocols/openai-responses.js +17 -8
- package/dist/protocols/venice-chat.d.ts +39 -4
- package/dist/protocols/venice-chat.js +1 -1
- package/dist/protocols/xai-images.d.ts +6 -0
- package/dist/protocols/xai-images.js +4 -5
- package/dist/protocols/xai-responses.d.ts +20 -3
- package/dist/protocols/xai-responses.js +2 -1
- package/dist/protocols/zai-chat.d.ts +39 -4
- package/dist/provider-error.js +5 -4
- package/dist/provider-package.d.ts +2 -0
- package/dist/providers/alibaba.d.ts +58 -10
- package/dist/providers/amazon-bedrock-mantle.d.ts +66 -11
- package/dist/providers/amazon-bedrock-mantle.js +1 -1
- package/dist/providers/amazon-bedrock.d.ts +1 -1
- package/dist/providers/amazon-bedrock.js +1 -1
- package/dist/providers/anthropic-compatible.d.ts +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/azure.d.ts +79 -15
- package/dist/providers/baseten.d.ts +74 -12
- package/dist/providers/baseten.js +1 -1
- package/dist/providers/cerebras.d.ts +73 -11
- package/dist/providers/cerebras.js +1 -1
- package/dist/providers/cloudflare-ai-gateway.d.ts +113 -17
- package/dist/providers/cloudflare-workers-ai.d.ts +73 -11
- package/dist/providers/cohere/chat.d.ts +1 -1
- package/dist/providers/cohere/chat.js +1 -1
- package/dist/providers/cohere.d.ts +73 -11
- package/dist/providers/cohere.js +1 -1
- package/dist/providers/deepinfra.d.ts +73 -11
- package/dist/providers/deepinfra.js +1 -1
- package/dist/providers/deepseek.d.ts +73 -11
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/digitalocean/responses.d.ts +4 -0
- package/dist/providers/digitalocean/responses.js +1 -0
- package/dist/providers/digitalocean.d.ts +320 -21
- package/dist/providers/digitalocean.js +18 -7
- package/dist/providers/fireworks.d.ts +73 -11
- package/dist/providers/fireworks.js +1 -1
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +1 -1
- package/dist/providers/google-vertex-chat.d.ts +36 -5
- package/dist/providers/google-vertex-chat.js +1 -1
- package/dist/providers/google-vertex-interactions.d.ts +1 -1
- package/dist/providers/google-vertex-interactions.js +1 -1
- package/dist/providers/google-vertex-messages.d.ts +1 -1
- package/dist/providers/google-vertex-messages.js +1 -1
- package/dist/providers/google-vertex-mistral.d.ts +1 -1
- package/dist/providers/google-vertex-mistral.js +1 -1
- package/dist/providers/google-vertex-responses.d.ts +21 -4
- package/dist/providers/google-vertex-responses.js +1 -1
- package/dist/providers/google-vertex.d.ts +2 -2
- package/dist/providers/google-vertex.js +1 -1
- package/dist/providers/google.d.ts +2 -2
- package/dist/providers/google.js +1 -1
- package/dist/providers/groq.d.ts +77 -11
- package/dist/providers/groq.js +1 -1
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.js +0 -4
- package/dist/providers/meta/images.d.ts +2 -0
- package/dist/providers/meta/images.js +1 -0
- package/dist/providers/meta.d.ts +61 -12
- package/dist/providers/meta.js +2 -1
- package/dist/providers/minimax/chat.d.ts +1 -1
- package/dist/providers/minimax/chat.js +1 -1
- package/dist/providers/minimax/images.d.ts +3 -0
- package/dist/providers/minimax/images.js +1 -0
- package/dist/providers/minimax/responses.d.ts +1 -1
- package/dist/providers/minimax/responses.js +1 -1
- package/dist/providers/minimax.d.ts +63 -9
- package/dist/providers/minimax.js +22 -9
- package/dist/providers/mistral.d.ts +3 -3
- package/dist/providers/mistral.js +1 -1
- package/dist/providers/moonshot/messages.d.ts +1 -1
- package/dist/providers/moonshot/messages.js +1 -1
- package/dist/providers/moonshot/responses.d.ts +1 -1
- package/dist/providers/moonshot/responses.js +1 -1
- package/dist/providers/moonshot.d.ts +56 -8
- package/dist/providers/moonshot.js +1 -1
- package/dist/providers/openai-compatible-responses.d.ts +21 -4
- package/dist/providers/openai-compatible.d.ts +38 -7
- package/dist/providers/openai-compatible.js +9 -2
- package/dist/providers/openai.d.ts +59 -11
- package/dist/providers/openai.js +4 -2
- package/dist/providers/opencode.d.ts +3 -3
- package/dist/providers/opencode.js +1 -1
- package/dist/providers/openrouter/responses.d.ts +4 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter.d.ts +356 -26
- package/dist/providers/openrouter.js +42 -13
- package/dist/providers/togetherai.d.ts +73 -11
- package/dist/providers/togetherai.js +1 -1
- package/dist/providers/typesafe-ai.d.ts +3 -3
- package/dist/providers/typesafe-ai.js +1 -1
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +242 -9
- package/dist/providers/venice.js +33 -17
- package/dist/providers/vercel-ai-gateway.d.ts +8 -8
- package/dist/providers/vercel-ai-gateway.js +12 -2
- package/dist/providers/xai.d.ts +39 -8
- package/dist/providers/xai.js +1 -1
- package/dist/providers/zai-coding-plan/messages.d.ts +1 -1
- package/dist/providers/zai-coding-plan/messages.js +1 -1
- package/dist/providers/zai-coding-plan/responses.d.ts +1 -1
- package/dist/providers/zai-coding-plan/responses.js +1 -1
- package/dist/providers/zai-coding-plan.d.ts +56 -8
- package/dist/providers/zai-coding-plan.js +1 -1
- package/dist/providers/zai.d.ts +37 -6
- package/dist/providers/zai.js +1 -1
- package/dist/route/auth.d.ts +1 -1
- package/dist/route/media-protocol.d.ts +2 -4
- package/dist/route/media.d.ts +1 -1
- package/dist/route/media.js +2 -4
- package/dist/schema/messages.d.ts +35 -1
- package/dist/schema/messages.js +20 -0
- package/dist/speech-client.d.ts +48 -0
- package/dist/testing/decision.d.ts +16 -0
- package/dist/testing/decision.js +20 -0
- package/dist/testing/image.d.ts +14 -0
- package/dist/testing/image.js +12 -0
- package/dist/testing/media.d.ts +18 -0
- package/dist/testing/media.js +36 -0
- package/dist/testing/script.d.ts +28 -0
- package/dist/testing/script.js +60 -0
- package/dist/testing/speech.d.ts +14 -0
- package/dist/testing/speech.js +12 -0
- package/dist/testing/transcription.d.ts +14 -0
- package/dist/testing/transcription.js +12 -0
- package/dist/testing/video.d.ts +14 -0
- package/dist/testing/video.js +12 -0
- package/dist/testing.d.ts +10 -21
- package/dist/testing.js +11 -54
- package/dist/tool.d.ts +12 -1
- package/dist/tool.js +10 -2
- package/dist/transcription-client.d.ts +64 -0
- package/dist/video-client.d.ts +41 -0
- package/package.json +22 -38
- package/dist/protocols/bfl-images.d.ts +0 -47
- package/dist/protocols/bfl-images.js +0 -155
- package/dist/protocols/fal-images.d.ts +0 -34
- package/dist/protocols/fal-images.js +0 -95
- package/dist/protocols/fal-video.d.ts +0 -29
- package/dist/protocols/fal-video.js +0 -73
- package/dist/protocols/replicate-images.d.ts +0 -28
- package/dist/protocols/replicate-images.js +0 -127
- package/dist/protocols/stability-images.d.ts +0 -44
- package/dist/protocols/stability-images.js +0 -131
- package/dist/protocols/utils/fal-queue.d.ts +0 -26
- package/dist/protocols/utils/fal-queue.js +0 -67
- package/dist/providers/black-forest-labs.d.ts +0 -21
- package/dist/providers/black-forest-labs.js +0 -23
- package/dist/providers/fal.d.ts +0 -24
- package/dist/providers/fal.js +0 -26
- package/dist/providers/replicate.d.ts +0 -21
- package/dist/providers/replicate.js +0 -17
- package/dist/providers/stability.d.ts +0 -23
- package/dist/providers/stability.js +0 -18
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
|
+
import { type Interface } from "../decision-client.js";
|
|
3
|
+
import type { DecisionRequestFor, DecisionResponse } from "../decision.js";
|
|
4
|
+
import { AIError } from "../schema/index.js";
|
|
5
|
+
import { TestScript } from "./script.js";
|
|
6
|
+
/** Returned as scripted, without checking its answers against the request's questions. */
|
|
7
|
+
export type Response = DecisionResponse | AIError;
|
|
8
|
+
export interface TestInterface extends Interface, TestScript.Controls<DecisionRequestFor, Response> {
|
|
9
|
+
}
|
|
10
|
+
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestDecision/Test", TestInterface>;
|
|
11
|
+
export declare class Test extends Test_base {
|
|
12
|
+
}
|
|
13
|
+
export type LayerOptions = TestScript.Options<DecisionRequestFor, Response>;
|
|
14
|
+
/** Provides one shared implementation under `DecisionClient.Service` and `TestDecision.Test`. */
|
|
15
|
+
export declare const testLayer: (options?: LayerOptions) => Layer.Layer<import("../decision-client.js").Service | Test, never, never>;
|
|
16
|
+
export * as TestDecision from "./decision.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import { DecisionClient } from "../decision-client.js";
|
|
3
|
+
import { AIError } from "../schema/index.js";
|
|
4
|
+
import { TestScript } from "./script.js";
|
|
5
|
+
export class Test extends Context.Service()("@opencode/ai/TestDecision/Test") {
|
|
6
|
+
}
|
|
7
|
+
/** Provides one shared implementation under `DecisionClient.Service` and `TestDecision.Test`. */
|
|
8
|
+
export const testLayer = (options = {}) => Layer.effectContext(Effect.sync(() => {
|
|
9
|
+
const script = TestScript.make("TestDecision", options);
|
|
10
|
+
const client = Test.of({
|
|
11
|
+
...script.controls,
|
|
12
|
+
generate: (request) => script
|
|
13
|
+
.take(request)
|
|
14
|
+
.pipe(Effect.flatMap((response) => response instanceof AIError
|
|
15
|
+
? Effect.fail(response)
|
|
16
|
+
: Effect.succeed(response))),
|
|
17
|
+
});
|
|
18
|
+
return Context.make(DecisionClient.Service, client).pipe(Context.add(Test, client));
|
|
19
|
+
}));
|
|
20
|
+
export * as TestDecision from "./decision.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import type { ImageEvent, ImageRequestFor, ImageResponse } from "../image.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
import type { TestScript } from "./script.js";
|
|
5
|
+
export type Response = TestMedia.Response<ImageResponse>;
|
|
6
|
+
export interface TestInterface extends TestMedia.TestInterface<ImageRequestFor, ImageEvent, ImageResponse> {
|
|
7
|
+
}
|
|
8
|
+
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestImage/Test", TestInterface>;
|
|
9
|
+
export declare class Test extends Test_base {
|
|
10
|
+
}
|
|
11
|
+
export type LayerOptions = TestScript.Options<ImageRequestFor, Response>;
|
|
12
|
+
/** Provides one shared implementation under `ImageClient.Service` and `TestImage.Test`. */
|
|
13
|
+
export declare const testLayer: (options?: LayerOptions) => import("effect/Layer").Layer<import("../image-client.js").ImageClientService | Test, never, never>;
|
|
14
|
+
export * as TestImage from "./image.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { ImageClient } from "../image-client.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
export class Test extends Context.Service()("@opencode/ai/TestImage/Test") {
|
|
5
|
+
}
|
|
6
|
+
/** Provides one shared implementation under `ImageClient.Service` and `TestImage.Test`. */
|
|
7
|
+
export const testLayer = (options = {}) => TestMedia.testLayer(ImageClient.Service, Test, {
|
|
8
|
+
name: "TestImage",
|
|
9
|
+
responseEvents: ImageClient.responseEvents,
|
|
10
|
+
options,
|
|
11
|
+
});
|
|
12
|
+
export * as TestImage from "./image.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
|
+
import type { MediaClient } from "../media-client.js";
|
|
3
|
+
import { AIError } from "../schema/index.js";
|
|
4
|
+
import { TestScript } from "./script.js";
|
|
5
|
+
/** A scripted reply: the response every operation returns, or the error it fails with. */
|
|
6
|
+
export type Response<Value> = Value | AIError;
|
|
7
|
+
export interface TestInterface<Req extends MediaClient.RoutedRequest<Req, Event, Value>, Event, Value> extends MediaClient.Interface<Req, Event, Value>, TestScript.Controls<Req, Response<Value>> {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Builds one media test client. `stream` expands the response like an inline route, and `start` returns an already
|
|
11
|
+
* finished generation whose token `resume` accepts.
|
|
12
|
+
*/
|
|
13
|
+
export declare const testLayer: <Self, Test, Req extends MediaClient.RoutedRequest<Req, Event, Value>, Event, Value>(service: Context.Service<Self, MediaClient.Interface<Req, Event, Value>>, test: Context.Service<Test, TestInterface<Req, Event, Value>>, input: {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly responseEvents: (response: Value) => ReadonlyArray<Event>;
|
|
16
|
+
readonly options: TestScript.Options<Req, Response<Value>>;
|
|
17
|
+
}) => Layer.Layer<Self | Test, never, never>;
|
|
18
|
+
export * as TestMedia from "./media.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Stream } from "effect";
|
|
2
|
+
import { Generation } from "../generation.js";
|
|
3
|
+
import { AIError } from "../schema/index.js";
|
|
4
|
+
import { TestScript } from "./script.js";
|
|
5
|
+
/**
|
|
6
|
+
* Builds one media test client. `stream` expands the response like an inline route, and `start` returns an already
|
|
7
|
+
* finished generation whose token `resume` accepts.
|
|
8
|
+
*/
|
|
9
|
+
export const testLayer = (service, test, input) => Layer.effectContext(Effect.sync(() => {
|
|
10
|
+
const script = TestScript.make(input.name, input.options);
|
|
11
|
+
const generations = new Map();
|
|
12
|
+
const result = (response) => response instanceof AIError ? Effect.fail(response) : Effect.succeed(response);
|
|
13
|
+
const completed = (id, response) => {
|
|
14
|
+
const snapshot = { id, status: response instanceof AIError ? "failed" : "completed" };
|
|
15
|
+
return new Generation({ status: Effect.succeed(snapshot), result: result(response) }, id, snapshot);
|
|
16
|
+
};
|
|
17
|
+
const generate = (request) => script.take(request).pipe(Effect.flatMap(result));
|
|
18
|
+
const client = test.of({
|
|
19
|
+
...script.controls,
|
|
20
|
+
generate,
|
|
21
|
+
stream: (request) => Stream.fromIterableEffect(Effect.map(generate(request), input.responseEvents)),
|
|
22
|
+
start: (request) => script.take(request).pipe(Effect.map((response) => {
|
|
23
|
+
const id = `${input.name}-${generations.size + 1}`;
|
|
24
|
+
generations.set(id, response);
|
|
25
|
+
return completed(id, response);
|
|
26
|
+
})),
|
|
27
|
+
resume: (_model, token) => {
|
|
28
|
+
const response = typeof token === "string" ? generations.get(token) : undefined;
|
|
29
|
+
if (response === undefined)
|
|
30
|
+
return Effect.die(new Error(`${input.name} has no generation ${String(token)}`));
|
|
31
|
+
return Effect.succeed(completed(String(token), response));
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return Context.make(service, client).pipe(Context.add(test, client));
|
|
35
|
+
}));
|
|
36
|
+
export * as TestMedia from "./media.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Effect, Scope } from "effect";
|
|
2
|
+
export type Gate = Readonly<{
|
|
3
|
+
started: Effect.Effect<void>;
|
|
4
|
+
release: Effect.Effect<void>;
|
|
5
|
+
}>;
|
|
6
|
+
export interface Controls<Request, Response> {
|
|
7
|
+
/** Returns a snapshot of requests observed at execution time. */
|
|
8
|
+
readonly requests: () => Effect.Effect<readonly Request[]>;
|
|
9
|
+
readonly push: (...responses: readonly Response[]) => Effect.Effect<void>;
|
|
10
|
+
/** Replaces the fallback without changing queued responses. */
|
|
11
|
+
readonly always: (response: Response) => Effect.Effect<void>;
|
|
12
|
+
/** Answers requests after the one-shot queue is exhausted; receives the original request. */
|
|
13
|
+
readonly serve: (responder: (request: Request) => Response) => Effect.Effect<void>;
|
|
14
|
+
/** Waits for request arrivals, not output or completion. */
|
|
15
|
+
readonly wait: (count: number) => Effect.Effect<void>;
|
|
16
|
+
readonly gate: () => Effect.Effect<Gate, never, Scope.Scope>;
|
|
17
|
+
}
|
|
18
|
+
export interface Options<Request, Response> {
|
|
19
|
+
readonly transformRequest?: (request: Request) => Request;
|
|
20
|
+
/** Used after the one-shot response queue is exhausted. Omit to defect on unexpected requests. */
|
|
21
|
+
readonly fallback?: Response;
|
|
22
|
+
}
|
|
23
|
+
/** The response queue, fallback, request log, and gates shared by every test client. */
|
|
24
|
+
export declare const make: <Request, Response>(name: string, options: Options<Request, Response>) => {
|
|
25
|
+
take: (request: Request) => Effect.Effect<NonNullable<Response>, never, never>;
|
|
26
|
+
controls: Controls<Request, Response>;
|
|
27
|
+
};
|
|
28
|
+
export * as TestScript from "./script.js";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Deferred, Effect, Latch, Queue, Scope } from "effect";
|
|
2
|
+
/** The response queue, fallback, request log, and gates shared by every test client. */
|
|
3
|
+
export const make = (name, options) => {
|
|
4
|
+
const requests = [];
|
|
5
|
+
const responses = [];
|
|
6
|
+
let started = Deferred.makeUnsafe();
|
|
7
|
+
const initial = options.fallback;
|
|
8
|
+
let fallback = initial === undefined ? undefined : () => initial;
|
|
9
|
+
let activeGate;
|
|
10
|
+
const wait = (count) => Effect.suspend(() => requests.length >= count ? Effect.void : Deferred.await(started).pipe(Effect.andThen(wait(count))));
|
|
11
|
+
const take = (request) => Effect.suspend(() => {
|
|
12
|
+
const count = requests.push(options.transformRequest?.(request) ?? request);
|
|
13
|
+
const waiting = started;
|
|
14
|
+
started = Deferred.makeUnsafe();
|
|
15
|
+
const gate = activeGate;
|
|
16
|
+
try {
|
|
17
|
+
const response = responses.shift() ?? fallback?.(request);
|
|
18
|
+
if (!response)
|
|
19
|
+
return Effect.die(new Error(`${name} has no response for request ${count}`));
|
|
20
|
+
if (!gate)
|
|
21
|
+
return Effect.succeed(response);
|
|
22
|
+
return Queue.offer(gate.started, undefined).pipe(Effect.andThen(gate.release.await), Effect.as(response));
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
// Waiters can resume synchronously; assign the reply and gate before notifying them.
|
|
26
|
+
Deferred.doneUnsafe(waiting, Effect.void);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const controls = {
|
|
30
|
+
requests: () => Effect.sync(() => [...requests]),
|
|
31
|
+
push: (...input) => Effect.sync(() => {
|
|
32
|
+
responses.push(...input);
|
|
33
|
+
}),
|
|
34
|
+
always: (response) => Effect.sync(() => {
|
|
35
|
+
fallback = () => response;
|
|
36
|
+
}),
|
|
37
|
+
serve: (responder) => Effect.sync(() => {
|
|
38
|
+
fallback = responder;
|
|
39
|
+
}),
|
|
40
|
+
wait,
|
|
41
|
+
gate: () => Effect.gen(function* () {
|
|
42
|
+
const gate = {
|
|
43
|
+
started: yield* Effect.acquireRelease(Queue.unbounded(), Queue.shutdown),
|
|
44
|
+
release: yield* Latch.make(),
|
|
45
|
+
};
|
|
46
|
+
activeGate = gate;
|
|
47
|
+
const release = Effect.sync(() => {
|
|
48
|
+
if (activeGate === gate)
|
|
49
|
+
activeGate = undefined;
|
|
50
|
+
}).pipe(Effect.andThen(gate.release.open), Effect.asVoid);
|
|
51
|
+
yield* Effect.addFinalizer(() => release);
|
|
52
|
+
return {
|
|
53
|
+
started: Queue.take(gate.started),
|
|
54
|
+
release,
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
return { take, controls };
|
|
59
|
+
};
|
|
60
|
+
export * as TestScript from "./script.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import type { SpeechEvent, SpeechRequestFor, SpeechResponse } from "../speech.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
import type { TestScript } from "./script.js";
|
|
5
|
+
export type Response = TestMedia.Response<SpeechResponse>;
|
|
6
|
+
export interface TestInterface extends TestMedia.TestInterface<SpeechRequestFor, SpeechEvent, SpeechResponse> {
|
|
7
|
+
}
|
|
8
|
+
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestSpeech/Test", TestInterface>;
|
|
9
|
+
export declare class Test extends Test_base {
|
|
10
|
+
}
|
|
11
|
+
export type LayerOptions = TestScript.Options<SpeechRequestFor, Response>;
|
|
12
|
+
/** Provides one shared implementation under `SpeechClient.Service` and `TestSpeech.Test`. */
|
|
13
|
+
export declare const testLayer: (options?: LayerOptions) => import("effect/Layer").Layer<import("../speech-client.js").SpeechClientService | Test, never, never>;
|
|
14
|
+
export * as TestSpeech from "./speech.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { SpeechClient } from "../speech-client.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
export class Test extends Context.Service()("@opencode/ai/TestSpeech/Test") {
|
|
5
|
+
}
|
|
6
|
+
/** Provides one shared implementation under `SpeechClient.Service` and `TestSpeech.Test`. */
|
|
7
|
+
export const testLayer = (options = {}) => TestMedia.testLayer(SpeechClient.Service, Test, {
|
|
8
|
+
name: "TestSpeech",
|
|
9
|
+
responseEvents: SpeechClient.responseEvents,
|
|
10
|
+
options,
|
|
11
|
+
});
|
|
12
|
+
export * as TestSpeech from "./speech.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import type { TranscriptionEvent, TranscriptionRequestFor, TranscriptionResponse } from "../transcription.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
import type { TestScript } from "./script.js";
|
|
5
|
+
export type Response = TestMedia.Response<TranscriptionResponse>;
|
|
6
|
+
export interface TestInterface extends TestMedia.TestInterface<TranscriptionRequestFor, TranscriptionEvent, TranscriptionResponse> {
|
|
7
|
+
}
|
|
8
|
+
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestTranscription/Test", TestInterface>;
|
|
9
|
+
export declare class Test extends Test_base {
|
|
10
|
+
}
|
|
11
|
+
export type LayerOptions = TestScript.Options<TranscriptionRequestFor, Response>;
|
|
12
|
+
/** Provides one shared implementation under `TranscriptionClient.Service` and `TestTranscription.Test`. */
|
|
13
|
+
export declare const testLayer: (options?: LayerOptions) => import("effect/Layer").Layer<Test | import("../transcription-client.js").TranscriptionClientService, never, never>;
|
|
14
|
+
export * as TestTranscription from "./transcription.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { TranscriptionClient } from "../transcription-client.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
export class Test extends Context.Service()("@opencode/ai/TestTranscription/Test") {
|
|
5
|
+
}
|
|
6
|
+
/** Provides one shared implementation under `TranscriptionClient.Service` and `TestTranscription.Test`. */
|
|
7
|
+
export const testLayer = (options = {}) => TestMedia.testLayer(TranscriptionClient.Service, Test, {
|
|
8
|
+
name: "TestTranscription",
|
|
9
|
+
responseEvents: TranscriptionClient.responseEvents,
|
|
10
|
+
options,
|
|
11
|
+
});
|
|
12
|
+
export * as TestTranscription from "./transcription.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import type { VideoEvent, VideoRequestFor, VideoResponse } from "../video.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
import type { TestScript } from "./script.js";
|
|
5
|
+
export type Response = TestMedia.Response<VideoResponse>;
|
|
6
|
+
export interface TestInterface extends TestMedia.TestInterface<VideoRequestFor, VideoEvent, VideoResponse> {
|
|
7
|
+
}
|
|
8
|
+
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestVideo/Test", TestInterface>;
|
|
9
|
+
export declare class Test extends Test_base {
|
|
10
|
+
}
|
|
11
|
+
export type LayerOptions = TestScript.Options<VideoRequestFor, Response>;
|
|
12
|
+
/** Provides one shared implementation under `VideoClient.Service` and `TestVideo.Test`. */
|
|
13
|
+
export declare const testLayer: (options?: LayerOptions) => import("effect/Layer").Layer<Test | import("../video-client.js").VideoClientService, never, never>;
|
|
14
|
+
export * as TestVideo from "./video.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { VideoClient } from "../video-client.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
export class Test extends Context.Service()("@opencode/ai/TestVideo/Test") {
|
|
5
|
+
}
|
|
6
|
+
/** Provides one shared implementation under `VideoClient.Service` and `TestVideo.Test`. */
|
|
7
|
+
export const testLayer = (options = {}) => TestMedia.testLayer(VideoClient.Service, Test, {
|
|
8
|
+
name: "TestVideo",
|
|
9
|
+
responseEvents: VideoClient.responseEvents,
|
|
10
|
+
options,
|
|
11
|
+
});
|
|
12
|
+
export * as TestVideo from "./video.js";
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
export * as TestLLM from "./testing.js";
|
|
2
2
|
export { compileRequest } from "./route/client.js";
|
|
3
|
+
export { TestDecision } from "./testing/decision.js";
|
|
4
|
+
export { TestImage } from "./testing/image.js";
|
|
5
|
+
export { TestSpeech } from "./testing/speech.js";
|
|
6
|
+
export { TestTranscription } from "./testing/transcription.js";
|
|
7
|
+
export { TestVideo } from "./testing/video.js";
|
|
3
8
|
import { LLMClient } from "./route/client.js";
|
|
4
9
|
import { LLMEvent, CompactionResponse, CompactionCheckpointResponse, type FinishReasonDetails, type AIError, type LLMRequest, type ProviderMetadata, type UsageInput } from "./schema/index.js";
|
|
5
|
-
import { Context,
|
|
10
|
+
import { Context, Layer, Stream } from "effect";
|
|
11
|
+
import { TestScript } from "./testing/script.js";
|
|
6
12
|
export type Response = readonly LLMEvent[] | Stream.Stream<LLMEvent, AIError> | CompactionResponse | CompactionCheckpointResponse;
|
|
7
|
-
export type Gate =
|
|
8
|
-
started: Effect.Effect<void>;
|
|
9
|
-
release: Effect.Effect<void>;
|
|
10
|
-
}>;
|
|
13
|
+
export type Gate = TestScript.Gate;
|
|
11
14
|
type ClientInterface = Context.Service.Shape<typeof LLMClient.Service>;
|
|
12
15
|
export type Responder = (request: LLMRequest) => Response;
|
|
13
|
-
export interface TestInterface extends ClientInterface {
|
|
14
|
-
/** Returns a snapshot of requests observed at execution time. */
|
|
15
|
-
readonly requests: () => Effect.Effect<readonly LLMRequest[]>;
|
|
16
|
-
readonly push: (...responses: readonly Response[]) => Effect.Effect<void>;
|
|
17
|
-
/** Replaces the fallback without changing queued responses. */
|
|
18
|
-
readonly always: (response: Response) => Effect.Effect<void>;
|
|
19
|
-
/** Answers requests after the one-shot queue is exhausted; receives the original request. */
|
|
20
|
-
readonly serve: (responder: Responder) => Effect.Effect<void>;
|
|
21
|
-
/** Waits for request arrivals, not output or completion. */
|
|
22
|
-
readonly wait: (count: number) => Effect.Effect<void>;
|
|
23
|
-
readonly gate: () => Effect.Effect<Gate, never, Scope.Scope>;
|
|
16
|
+
export interface TestInterface extends ClientInterface, TestScript.Controls<LLMRequest, Response> {
|
|
24
17
|
}
|
|
25
18
|
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestLLM/Test", TestInterface>;
|
|
26
19
|
export declare class Test extends Test_base {
|
|
27
20
|
}
|
|
28
|
-
export
|
|
29
|
-
readonly transformRequest?: (request: LLMRequest) => LLMRequest;
|
|
30
|
-
/** Used after the one-shot response queue is exhausted. Omit to defect on unexpected requests. */
|
|
31
|
-
readonly fallback?: Response;
|
|
32
|
-
}
|
|
21
|
+
export type LayerOptions = TestScript.Options<LLMRequest, Response>;
|
|
33
22
|
export declare const complete: (options: {
|
|
34
23
|
readonly reason: FinishReasonDetails;
|
|
35
24
|
readonly usage?: UsageInput;
|
package/dist/testing.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export * as TestLLM from "./testing.js";
|
|
2
2
|
export { compileRequest } from "./route/client.js";
|
|
3
|
+
export { TestDecision } from "./testing/decision.js";
|
|
4
|
+
export { TestImage } from "./testing/image.js";
|
|
5
|
+
export { TestSpeech } from "./testing/speech.js";
|
|
6
|
+
export { TestTranscription } from "./testing/transcription.js";
|
|
7
|
+
export { TestVideo } from "./testing/video.js";
|
|
3
8
|
import { LLMClient, } from "./route/client.js";
|
|
4
9
|
import { LLMEvent, LLMResponse, CompactionResponse, CompactionCheckpointResponse, } from "./schema/index.js";
|
|
5
|
-
import { Context,
|
|
10
|
+
import { Context, Effect, Layer, Stream } from "effect";
|
|
11
|
+
import { TestScript } from "./testing/script.js";
|
|
6
12
|
export class Test extends Context.Service()("@opencode/ai/TestLLM/Test") {
|
|
7
13
|
}
|
|
8
14
|
export const complete = (options, ...events) => [
|
|
@@ -29,37 +35,14 @@ export const tool = (id, name, input) => toolCalls(LLMEvent.toolCall({ id, name,
|
|
|
29
35
|
export const failAfter = (error, ...events) => Stream.fromIterable(events).pipe(Stream.concat(Stream.fail(error)));
|
|
30
36
|
export const hangAfter = (...events) => Stream.concat(Stream.fromIterable(events), Stream.never);
|
|
31
37
|
const make = (options) => Effect.sync(() => {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
let started = Deferred.makeUnsafe();
|
|
35
|
-
let fallback = options.fallback;
|
|
36
|
-
let activeGate;
|
|
37
|
-
const wait = (count) => Effect.suspend(() => requests.length >= count ? Effect.void : Deferred.await(started).pipe(Effect.andThen(wait(count))));
|
|
38
|
-
const take = (request) => Effect.suspend(() => {
|
|
39
|
-
const count = requests.push(options.transformRequest?.(request) ?? request);
|
|
40
|
-
const waiting = started;
|
|
41
|
-
started = Deferred.makeUnsafe();
|
|
42
|
-
const gate = activeGate;
|
|
43
|
-
try {
|
|
44
|
-
const response = responses.shift() ?? (typeof fallback === "function" ? fallback(request) : fallback);
|
|
45
|
-
if (!response)
|
|
46
|
-
return Effect.die(new Error(`TestLLM has no response for request ${count}`));
|
|
47
|
-
if (!gate)
|
|
48
|
-
return Effect.succeed(response);
|
|
49
|
-
return Queue.offer(gate.started, undefined).pipe(Effect.andThen(gate.release.await), Effect.as(response));
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
// Waiters can resume synchronously; assign the reply and gate before notifying them.
|
|
53
|
-
Deferred.doneUnsafe(waiting, Effect.void);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
const stream = (request) => Stream.unwrap(take(request).pipe(Effect.map((response) => {
|
|
38
|
+
const script = TestScript.make("TestLLM", options);
|
|
39
|
+
const stream = (request) => Stream.unwrap(script.take(request).pipe(Effect.map((response) => {
|
|
57
40
|
if (response instanceof CompactionResponse || response instanceof CompactionCheckpointResponse)
|
|
58
41
|
return Stream.die("TestLLM generation requires an event response");
|
|
59
42
|
return Stream.isStream(response) ? response : Stream.fromIterable(response);
|
|
60
43
|
})));
|
|
61
44
|
function compact(request, options) {
|
|
62
|
-
return take(request).pipe(Effect.flatMap((response) => {
|
|
45
|
+
return script.take(request).pipe(Effect.flatMap((response) => {
|
|
63
46
|
if (options?.mechanism === "trigger")
|
|
64
47
|
return response instanceof CompactionCheckpointResponse
|
|
65
48
|
? Effect.succeed(response)
|
|
@@ -70,6 +53,7 @@ const make = (options) => Effect.sync(() => {
|
|
|
70
53
|
}));
|
|
71
54
|
}
|
|
72
55
|
return Test.of({
|
|
56
|
+
...script.controls,
|
|
73
57
|
compact,
|
|
74
58
|
stream,
|
|
75
59
|
generate: (request) => stream(request).pipe(Stream.runFold(LLMResponse.empty, LLMResponse.reduce), Effect.flatMap((state) => {
|
|
@@ -78,33 +62,6 @@ const make = (options) => Effect.sync(() => {
|
|
|
78
62
|
return Effect.succeed(response);
|
|
79
63
|
return Effect.die("TestLLM response ended without a terminal finish event");
|
|
80
64
|
})),
|
|
81
|
-
requests: () => Effect.sync(() => [...requests]),
|
|
82
|
-
push: (...input) => Effect.sync(() => {
|
|
83
|
-
responses.push(...input);
|
|
84
|
-
}),
|
|
85
|
-
always: (response) => Effect.sync(() => {
|
|
86
|
-
fallback = response;
|
|
87
|
-
}),
|
|
88
|
-
serve: (responder) => Effect.sync(() => {
|
|
89
|
-
fallback = responder;
|
|
90
|
-
}),
|
|
91
|
-
wait,
|
|
92
|
-
gate: () => Effect.gen(function* () {
|
|
93
|
-
const gate = {
|
|
94
|
-
started: yield* Effect.acquireRelease(Queue.unbounded(), Queue.shutdown),
|
|
95
|
-
release: yield* Latch.make(),
|
|
96
|
-
};
|
|
97
|
-
activeGate = gate;
|
|
98
|
-
const release = Effect.sync(() => {
|
|
99
|
-
if (activeGate === gate)
|
|
100
|
-
activeGate = undefined;
|
|
101
|
-
}).pipe(Effect.andThen(gate.release.open), Effect.asVoid);
|
|
102
|
-
yield* Effect.addFinalizer(() => release);
|
|
103
|
-
return {
|
|
104
|
-
started: Queue.take(gate.started),
|
|
105
|
-
release,
|
|
106
|
-
};
|
|
107
|
-
}),
|
|
108
65
|
});
|
|
109
66
|
});
|
|
110
67
|
/** Provides one shared implementation under the normal client and test-control tags. */
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, JsonSchema, Schema } from "effect";
|
|
2
2
|
import { Tool } from "@opencode/schema/tool";
|
|
3
|
-
import type { ToolCallPart, ToolDefinition as ToolDefinitionClass, ToolOutput as ToolOutputType } from "./schema/index.js";
|
|
3
|
+
import type { Freeform, ToolCallPart, ToolDefinition as ToolDefinitionClass, ToolOutput as ToolOutputType } from "./schema/index.js";
|
|
4
4
|
import { ToolFailure } from "./schema/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Schema constraint for tool parameters / success values: no decoding or
|
|
@@ -20,6 +20,13 @@ export interface ToolModelOutputInput<Parameters, Output> {
|
|
|
20
20
|
readonly output: Output;
|
|
21
21
|
}
|
|
22
22
|
export type ToolToModelOutput<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>> = (input: ToolModelOutputInput<Schema.Schema.Type<Parameters>, Success["Encoded"]>) => ReadonlyArray<Tool.Content>;
|
|
23
|
+
type FreeformField<T> = {
|
|
24
|
+
[K in keyof T]-?: [Exclude<keyof T, K>] extends [never] ? {} extends Pick<T, K> ? never : T[K] extends string ? K : never : never;
|
|
25
|
+
}[keyof T];
|
|
26
|
+
/** `Freeform` when the parameters are exactly one required string field, otherwise `undefined`. */
|
|
27
|
+
export type FreeformOption<Parameters extends ToolSchema<any>> = [
|
|
28
|
+
FreeformField<Schema.Schema.Type<Parameters>>
|
|
29
|
+
] extends [never] ? undefined : Freeform;
|
|
23
30
|
/**
|
|
24
31
|
* A type-safe LLM tool. Each tool bundles its own description, parameter
|
|
25
32
|
* Schema and success Schema. The execute handler is optional: omit it when you
|
|
@@ -91,6 +98,7 @@ export declare function make<Parameters extends ToolSchema<any>, Success extends
|
|
|
91
98
|
readonly description: string;
|
|
92
99
|
readonly parameters: Parameters;
|
|
93
100
|
readonly success: Success;
|
|
101
|
+
readonly freeform?: FreeformOption<Parameters>;
|
|
94
102
|
readonly execute: ToolExecute<Parameters, Success>;
|
|
95
103
|
readonly toModelOutput?: ToolToModelOutput<Parameters, Success>;
|
|
96
104
|
readonly toStructuredOutput?: (output: Success["Encoded"]) => unknown;
|
|
@@ -99,6 +107,7 @@ export declare function make<Parameters extends ToolSchema<any>, Success extends
|
|
|
99
107
|
readonly description: string;
|
|
100
108
|
readonly parameters: Parameters;
|
|
101
109
|
readonly success: Success;
|
|
110
|
+
readonly freeform?: FreeformOption<Parameters>;
|
|
102
111
|
readonly execute?: undefined;
|
|
103
112
|
readonly toModelOutput?: ToolToModelOutput<Parameters, Success>;
|
|
104
113
|
readonly toStructuredOutput?: (output: Success["Encoded"]) => unknown;
|
|
@@ -107,6 +116,7 @@ export declare function make(config: {
|
|
|
107
116
|
readonly description: string;
|
|
108
117
|
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
109
118
|
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
119
|
+
readonly freeform?: Freeform;
|
|
110
120
|
readonly execute: (params: unknown, context?: ToolExecuteContext) => Effect.Effect<unknown, ToolFailure>;
|
|
111
121
|
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<Tool.Content>;
|
|
112
122
|
readonly toStructuredOutput?: (output: unknown) => unknown;
|
|
@@ -115,6 +125,7 @@ export declare function make(config: {
|
|
|
115
125
|
readonly description: string;
|
|
116
126
|
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
117
127
|
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
128
|
+
readonly freeform?: Freeform;
|
|
118
129
|
readonly execute?: undefined;
|
|
119
130
|
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<Tool.Content>;
|
|
120
131
|
readonly toStructuredOutput?: (output: unknown) => unknown;
|
package/dist/tool.js
CHANGED
|
@@ -15,11 +15,12 @@ export function make(config) {
|
|
|
15
15
|
_encode: Effect.succeed,
|
|
16
16
|
_project: (parameters, id, output) => project(config.toModelOutput, config.toStructuredOutput, parameters, id, output),
|
|
17
17
|
_legacyResult: config.toModelOutput === undefined && config.toStructuredOutput === undefined,
|
|
18
|
-
_definition:
|
|
18
|
+
_definition: definition({
|
|
19
19
|
name: "",
|
|
20
20
|
description: config.description,
|
|
21
21
|
inputSchema: config.jsonSchema,
|
|
22
22
|
outputSchema: config.outputSchema,
|
|
23
|
+
freeform: config.freeform,
|
|
23
24
|
}),
|
|
24
25
|
};
|
|
25
26
|
}
|
|
@@ -34,11 +35,12 @@ export function make(config) {
|
|
|
34
35
|
_encode: Schema.encodeEffect(config.success),
|
|
35
36
|
_project: (parameters, id, output) => project(config.toModelOutput, config.toStructuredOutput, parameters, id, output),
|
|
36
37
|
_legacyResult: false,
|
|
37
|
-
_definition:
|
|
38
|
+
_definition: definition({
|
|
38
39
|
name: "",
|
|
39
40
|
description: config.description,
|
|
40
41
|
inputSchema: emptyInputJsonSchema(config.parameters) ?? toJsonSchema(config.parameters),
|
|
41
42
|
outputSchema: toJsonSchema(config.success),
|
|
43
|
+
freeform: config.freeform,
|
|
42
44
|
}),
|
|
43
45
|
};
|
|
44
46
|
}
|
|
@@ -55,6 +57,7 @@ export const toDefinitions = (tools) => Object.entries(tools).map(([name, item])
|
|
|
55
57
|
description: item._definition.description,
|
|
56
58
|
inputSchema: item._definition.inputSchema,
|
|
57
59
|
outputSchema: item._definition.outputSchema,
|
|
60
|
+
freeform: item._definition.freeform,
|
|
58
61
|
}));
|
|
59
62
|
/**
|
|
60
63
|
* Describes a no-argument Effect tool input as an empty object, or returns
|
|
@@ -73,6 +76,11 @@ export const emptyInputJsonSchema = (schema) => {
|
|
|
73
76
|
return undefined;
|
|
74
77
|
return { ...rest, type: "object", properties: {}, additionalProperties: false };
|
|
75
78
|
};
|
|
79
|
+
const definition = (input) => {
|
|
80
|
+
if (input.freeform !== undefined && ToolDefinition.freeformField(input.inputSchema) === undefined)
|
|
81
|
+
throw new Error("A freeform tool needs exactly one parameter, a required string");
|
|
82
|
+
return new ToolDefinition(input);
|
|
83
|
+
};
|
|
76
84
|
const annotationKeywords = new Set(["title", "description", "default", "examples", "readOnly", "writeOnly"]);
|
|
77
85
|
const toJsonSchema = (schema) => {
|
|
78
86
|
const document = Schema.toJsonSchemaDocument(schema, { onExcessProperty: "error" });
|
|
@@ -8,6 +8,70 @@ export declare class TranscriptionClientService extends TranscriptionClientServi
|
|
|
8
8
|
export declare const Service: typeof TranscriptionClientService;
|
|
9
9
|
export type Service = TranscriptionClientService;
|
|
10
10
|
export declare const TranscriptionClient: {
|
|
11
|
+
readonly responseEvents: (response: TranscriptionResponse) => readonly ({
|
|
12
|
+
readonly type: "text-delta";
|
|
13
|
+
readonly delta: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: "segment";
|
|
16
|
+
readonly segment: {
|
|
17
|
+
readonly text: string;
|
|
18
|
+
readonly startSeconds: number;
|
|
19
|
+
readonly endSeconds: number;
|
|
20
|
+
readonly speaker?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: "generation-queued";
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly position?: number | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "generation-progress";
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly progress?: number | undefined;
|
|
30
|
+
} | {
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly segments?: readonly {
|
|
33
|
+
readonly text: string;
|
|
34
|
+
readonly startSeconds: number;
|
|
35
|
+
readonly endSeconds: number;
|
|
36
|
+
readonly speaker?: string | undefined;
|
|
37
|
+
}[] | undefined;
|
|
38
|
+
readonly words?: readonly {
|
|
39
|
+
readonly text: string;
|
|
40
|
+
readonly startSeconds: number;
|
|
41
|
+
readonly endSeconds: number;
|
|
42
|
+
readonly speaker?: string | undefined;
|
|
43
|
+
readonly confidence?: number | undefined;
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
readonly language?: string | undefined;
|
|
46
|
+
readonly durationSeconds?: number | undefined;
|
|
47
|
+
readonly usage?: {
|
|
48
|
+
readonly type: "seconds";
|
|
49
|
+
readonly seconds: number;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: "characters";
|
|
52
|
+
readonly characters: number;
|
|
53
|
+
} | {
|
|
54
|
+
readonly type: "credits";
|
|
55
|
+
readonly credits: number;
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: "compute";
|
|
58
|
+
readonly seconds: number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly type: "tokens";
|
|
61
|
+
readonly input?: number | undefined;
|
|
62
|
+
readonly output?: number | undefined;
|
|
63
|
+
readonly total?: number | undefined;
|
|
64
|
+
readonly details?: {
|
|
65
|
+
readonly [x: string]: unknown;
|
|
66
|
+
} | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
readonly providerMetadata?: {
|
|
69
|
+
readonly [x: string]: {
|
|
70
|
+
readonly [x: string]: unknown;
|
|
71
|
+
};
|
|
72
|
+
} | undefined;
|
|
73
|
+
readonly type: "finish";
|
|
74
|
+
})[];
|
|
11
75
|
readonly layer: import("effect/Layer").Layer<TranscriptionClientService, never, import("./route.js").RequestExecutorService>;
|
|
12
76
|
readonly generate: (request: TranscriptionRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<TranscriptionResponse, import("./effect.js").AIError, TranscriptionClientService>;
|
|
13
77
|
readonly stream: (request: TranscriptionRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|