@opencode/ai 0.0.0-dev-177 → 0.0.0-dev-189
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 +13 -58
- package/dist/image-client.d.ts +45 -0
- package/dist/index.d.ts +36 -19
- package/dist/index.js +13 -2
- package/dist/media-client.d.ts +1 -0
- package/dist/media-client.js +1 -0
- package/dist/provider-error.js +0 -2
- package/dist/providers/digitalocean/responses.d.ts +4 -0
- package/dist/providers/digitalocean/responses.js +1 -0
- package/dist/providers/digitalocean.d.ts +206 -4
- package/dist/providers/digitalocean.js +17 -6
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.js +0 -4
- package/dist/providers/openrouter/responses.d.ts +4 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter.d.ts +207 -5
- package/dist/providers/openrouter.js +20 -11
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +206 -4
- package/dist/providers/venice.js +33 -17
- 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/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/transcription-client.d.ts +64 -0
- package/dist/video-client.d.ts +41 -0
- package/package.json +14 -18
- 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 -36
- package/dist/protocols/fal-images.js +0 -96
- 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,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. */
|
|
@@ -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<{
|
package/dist/video-client.d.ts
CHANGED
|
@@ -8,6 +8,47 @@ export declare class VideoClientService extends VideoClientService_base {
|
|
|
8
8
|
export declare const Service: typeof VideoClientService;
|
|
9
9
|
export type Service = VideoClientService;
|
|
10
10
|
export declare const VideoClient: {
|
|
11
|
+
readonly responseEvents: (response: VideoResponse) => readonly ({
|
|
12
|
+
readonly type: "video";
|
|
13
|
+
readonly index: number;
|
|
14
|
+
readonly video: import("./media.js").Asset;
|
|
15
|
+
} | {
|
|
16
|
+
readonly type: "generation-queued";
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly position?: number | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
readonly type: "generation-progress";
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly progress?: number | undefined;
|
|
23
|
+
} | {
|
|
24
|
+
readonly type: "finish";
|
|
25
|
+
readonly usage?: {
|
|
26
|
+
readonly type: "seconds";
|
|
27
|
+
readonly seconds: number;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "characters";
|
|
30
|
+
readonly characters: number;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "credits";
|
|
33
|
+
readonly credits: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "compute";
|
|
36
|
+
readonly seconds: number;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "tokens";
|
|
39
|
+
readonly input?: number | undefined;
|
|
40
|
+
readonly output?: number | undefined;
|
|
41
|
+
readonly total?: number | undefined;
|
|
42
|
+
readonly details?: {
|
|
43
|
+
readonly [x: string]: unknown;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} | undefined;
|
|
46
|
+
readonly providerMetadata?: {
|
|
47
|
+
readonly [x: string]: {
|
|
48
|
+
readonly [x: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
} | undefined;
|
|
51
|
+
})[];
|
|
11
52
|
readonly layer: import("effect/Layer").Layer<VideoClientService, never, import("./route.js").RequestExecutorService>;
|
|
12
53
|
readonly generate: (request: VideoRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<VideoResponse, import("./effect.js").AIError, VideoClientService>;
|
|
13
54
|
readonly stream: (request: VideoRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-189",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -116,10 +116,6 @@
|
|
|
116
116
|
"import": "./dist/providers/baseten/decisions.js",
|
|
117
117
|
"types": "./dist/providers/baseten/decisions.d.ts"
|
|
118
118
|
},
|
|
119
|
-
"./providers/black-forest-labs": {
|
|
120
|
-
"import": "./dist/providers/black-forest-labs.js",
|
|
121
|
-
"types": "./dist/providers/black-forest-labs.d.ts"
|
|
122
|
-
},
|
|
123
119
|
"./providers/cartesia": {
|
|
124
120
|
"import": "./dist/providers/cartesia.js",
|
|
125
121
|
"types": "./dist/providers/cartesia.d.ts"
|
|
@@ -180,14 +176,14 @@
|
|
|
180
176
|
"import": "./dist/providers/digitalocean/images.js",
|
|
181
177
|
"types": "./dist/providers/digitalocean/images.d.ts"
|
|
182
178
|
},
|
|
179
|
+
"./providers/digitalocean/responses": {
|
|
180
|
+
"import": "./dist/providers/digitalocean/responses.js",
|
|
181
|
+
"types": "./dist/providers/digitalocean/responses.d.ts"
|
|
182
|
+
},
|
|
183
183
|
"./providers/elevenlabs": {
|
|
184
184
|
"import": "./dist/providers/elevenlabs.js",
|
|
185
185
|
"types": "./dist/providers/elevenlabs.d.ts"
|
|
186
186
|
},
|
|
187
|
-
"./providers/fal": {
|
|
188
|
-
"import": "./dist/providers/fal.js",
|
|
189
|
-
"types": "./dist/providers/fal.d.ts"
|
|
190
|
-
},
|
|
191
187
|
"./providers/fireworks": {
|
|
192
188
|
"import": "./dist/providers/fireworks.js",
|
|
193
189
|
"types": "./dist/providers/fireworks.d.ts"
|
|
@@ -352,18 +348,14 @@
|
|
|
352
348
|
"import": "./dist/providers/openrouter/images.js",
|
|
353
349
|
"types": "./dist/providers/openrouter/images.d.ts"
|
|
354
350
|
},
|
|
355
|
-
"./providers/
|
|
356
|
-
"import": "./dist/providers/
|
|
357
|
-
"types": "./dist/providers/
|
|
351
|
+
"./providers/openrouter/responses": {
|
|
352
|
+
"import": "./dist/providers/openrouter/responses.js",
|
|
353
|
+
"types": "./dist/providers/openrouter/responses.d.ts"
|
|
358
354
|
},
|
|
359
355
|
"./providers/runway": {
|
|
360
356
|
"import": "./dist/providers/runway.js",
|
|
361
357
|
"types": "./dist/providers/runway.d.ts"
|
|
362
358
|
},
|
|
363
|
-
"./providers/stability": {
|
|
364
|
-
"import": "./dist/providers/stability.js",
|
|
365
|
-
"types": "./dist/providers/stability.d.ts"
|
|
366
|
-
},
|
|
367
359
|
"./providers/togetherai": {
|
|
368
360
|
"import": "./dist/providers/togetherai.js",
|
|
369
361
|
"types": "./dist/providers/togetherai.d.ts"
|
|
@@ -380,6 +372,10 @@
|
|
|
380
372
|
"import": "./dist/providers/venice.js",
|
|
381
373
|
"types": "./dist/providers/venice.d.ts"
|
|
382
374
|
},
|
|
375
|
+
"./providers/venice/responses": {
|
|
376
|
+
"import": "./dist/providers/venice/responses.js",
|
|
377
|
+
"types": "./dist/providers/venice/responses.d.ts"
|
|
378
|
+
},
|
|
383
379
|
"./providers/vercel-ai-gateway": {
|
|
384
380
|
"import": "./dist/providers/vercel-ai-gateway.js",
|
|
385
381
|
"types": "./dist/providers/vercel-ai-gateway.d.ts"
|
|
@@ -516,7 +512,7 @@
|
|
|
516
512
|
"devDependencies": {
|
|
517
513
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
518
514
|
"@effect/platform-node": "4.0.1",
|
|
519
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
515
|
+
"@opencode/http-recorder": "0.0.0-dev-189",
|
|
520
516
|
"@tsconfig/bun": "1.0.9",
|
|
521
517
|
"@types/bun": "1.4.3",
|
|
522
518
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
@@ -526,7 +522,7 @@
|
|
|
526
522
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
527
523
|
"@smithy/eventstream-codec": "4.2.14",
|
|
528
524
|
"@smithy/util-utf8": "4.2.2",
|
|
529
|
-
"@opencode/schema": "0.0.0-dev-
|
|
525
|
+
"@opencode/schema": "0.0.0-dev-189",
|
|
530
526
|
"aws4fetch": "1.0.20",
|
|
531
527
|
"effect": "4.0.1",
|
|
532
528
|
"google-auth-library": "10.5.0"
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { ImageModel, ImageResponse, type ImageRequestFor } from "../image.js";
|
|
3
|
-
import { Media } from "../media.js";
|
|
4
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
5
|
-
import { MediaRoute } from "../route/media.js";
|
|
6
|
-
import { type OpenString } from "../schema/index.js";
|
|
7
|
-
export declare const DEFAULT_BASE_URL = "https://api.bfl.ai";
|
|
8
|
-
/** Native body fields; `aspect` and `resolution` lower to `width`/`height` or `aspect_ratio` depending on the model. */
|
|
9
|
-
export type BlackForestLabsImageOptions = {
|
|
10
|
-
readonly width?: number;
|
|
11
|
-
readonly height?: number;
|
|
12
|
-
readonly seed?: number;
|
|
13
|
-
readonly output_format?: OpenString<"jpeg" | "png" | "webp">;
|
|
14
|
-
/** Inpainting mask for `flux-pro-1.0-fill`. */
|
|
15
|
-
readonly mask?: Media.Asset;
|
|
16
|
-
readonly safety_tolerance?: number;
|
|
17
|
-
readonly prompt_upsampling?: boolean;
|
|
18
|
-
readonly disable_pup?: boolean;
|
|
19
|
-
readonly raw?: boolean;
|
|
20
|
-
readonly guidance?: number;
|
|
21
|
-
readonly steps?: number;
|
|
22
|
-
} & Record<string, unknown>;
|
|
23
|
-
export type Request = ImageRequestFor<BlackForestLabsImageOptions>;
|
|
24
|
-
/**
|
|
25
|
-
* Regional clusters answer on different hosts, so the returned `polling_url` is followed verbatim. BFL reports the
|
|
26
|
-
* credit cost on submit, so it rides on the token; it is optional so tokens persisted before it existed still decode.
|
|
27
|
-
*/
|
|
28
|
-
export declare const Token: Schema.Struct<{
|
|
29
|
-
readonly id: Schema.String;
|
|
30
|
-
readonly pollingURL: Schema.String;
|
|
31
|
-
readonly cost: Schema.optionalKey<Schema.Number>;
|
|
32
|
-
}>;
|
|
33
|
-
export type Token = Schema.Schema.Type<typeof Token>;
|
|
34
|
-
export declare const protocol: MediaProtocol.Queued<Request, ImageResponse, {
|
|
35
|
-
readonly id: string;
|
|
36
|
-
readonly pollingURL: string;
|
|
37
|
-
readonly cost?: number | undefined;
|
|
38
|
-
}>;
|
|
39
|
-
export declare const model: (input: MediaRoute.ModelInput) => ImageModel<BlackForestLabsImageOptions>;
|
|
40
|
-
export declare const BlackForestLabsImages: {
|
|
41
|
-
readonly protocol: MediaProtocol.Queued<Request, ImageResponse, {
|
|
42
|
-
readonly id: string;
|
|
43
|
-
readonly pollingURL: string;
|
|
44
|
-
readonly cost?: number | undefined;
|
|
45
|
-
}>;
|
|
46
|
-
readonly model: typeof model;
|
|
47
|
-
};
|