@opencode/ai 2.2.5 → 2.2.7
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 +228 -72
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +1 -1
- package/dist/cache-policy.js +16 -4
- package/dist/decision-client.d.ts +3 -3
- package/dist/decision.d.ts +30 -125
- package/dist/decision.js +27 -15
- package/dist/effect.d.ts +10 -15
- package/dist/effect.js +6 -6
- package/dist/effort-updates.d.ts +3 -3
- package/dist/effort-updates.js +2 -2
- package/dist/embedding-client.d.ts +21 -0
- package/dist/embedding-client.js +30 -0
- package/dist/embedding.d.ts +111 -0
- package/dist/embedding.js +75 -0
- package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
- package/dist/experimental/cloudflare-run-extraction.js +4 -1
- package/dist/experimental/extraction.d.ts +10 -40
- package/dist/experimental/extraction.js +14 -13
- package/dist/experimental.d.ts +8 -8
- package/dist/experimental.js +4 -4
- package/dist/generation.d.ts +0 -2
- package/dist/generation.js +2 -2
- package/dist/image-client.d.ts +13 -7
- package/dist/image-client.js +1 -1
- package/dist/image.d.ts +357 -465
- package/dist/image.js +17 -18
- package/dist/index.d.ts +35 -467
- package/dist/index.js +23 -17
- package/dist/llm.d.ts +65 -266
- package/dist/llm.js +101 -92
- package/dist/loop.d.ts +38 -0
- package/dist/loop.js +136 -0
- package/dist/media-model.d.ts +1 -1
- package/dist/media-model.js +8 -6
- package/dist/media.d.ts +9 -0
- package/dist/media.js +37 -2
- package/dist/protocols/alibaba-chat.d.ts +9 -1
- package/dist/protocols/alibaba-chat.js +3 -3
- package/dist/protocols/alibaba-images.d.ts +2 -2
- package/dist/protocols/alibaba-messages.js +3 -3
- package/dist/protocols/alibaba-responses.js +8 -20
- package/dist/protocols/anthropic-messages.d.ts +1 -1
- package/dist/protocols/anthropic-messages.js +57 -176
- package/dist/protocols/assemblyai-transcription.d.ts +2 -2
- package/dist/protocols/bedrock-converse.js +10 -16
- package/dist/protocols/cartesia-speech.d.ts +2 -2
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
- package/dist/protocols/cohere-chat.js +9 -12
- package/dist/protocols/deepgram-speech.d.ts +2 -2
- package/dist/protocols/deepgram-transcription.d.ts +2 -2
- package/dist/protocols/elevenlabs-speech.d.ts +2 -2
- package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
- package/dist/protocols/gemini.d.ts +3 -0
- package/dist/protocols/gemini.js +54 -72
- package/dist/protocols/google-embed-content.d.ts +34 -0
- package/dist/protocols/google-embed-content.js +110 -0
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-interactions.d.ts +3 -4
- package/dist/protocols/google-interactions.js +44 -30
- package/dist/protocols/google-speech.d.ts +2 -2
- package/dist/protocols/google-transcription.d.ts +2 -2
- package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
- package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
- package/dist/protocols/google-video.d.ts +2 -2
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +2 -2
- package/dist/protocols/meta-responses.js +26 -23
- package/dist/protocols/minimax-images.d.ts +2 -2
- package/dist/protocols/mistral-chat.js +7 -10
- package/dist/protocols/open-responses-channel.js +6 -19
- package/dist/protocols/open-responses-continuation.d.ts +1 -5
- package/dist/protocols/open-responses-continuation.js +1 -3
- package/dist/protocols/open-responses.d.ts +2 -22
- package/dist/protocols/open-responses.js +41 -23
- package/dist/protocols/openai-chat.d.ts +27 -23
- package/dist/protocols/openai-chat.js +62 -57
- package/dist/protocols/openai-compatible-chat.d.ts +2 -1
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-compatible-responses.js +1 -1
- package/dist/protocols/openai-decisions.js +15 -2
- package/dist/protocols/openai-embeddings.d.ts +16 -0
- package/dist/protocols/openai-embeddings.js +76 -0
- package/dist/protocols/openai-images.d.ts +2 -2
- package/dist/protocols/openai-responses.js +10 -29
- package/dist/protocols/openai-speech.d.ts +2 -2
- package/dist/protocols/openai-transcription.d.ts +2 -2
- package/dist/protocols/runway-video.d.ts +2 -2
- package/dist/protocols/shared.d.ts +14 -7
- package/dist/protocols/shared.js +40 -15
- package/dist/protocols/system-one.d.ts +4 -4
- package/dist/protocols/system-one.js +8 -1
- package/dist/protocols/utils/bedrock-cache.js +2 -5
- package/dist/protocols/utils/bedrock-media.d.ts +0 -3
- package/dist/protocols/utils/cache.d.ts +3 -0
- package/dist/protocols/utils/cache.js +15 -2
- package/dist/protocols/utils/image-sizing.d.ts +1 -1
- package/dist/protocols/utils/responses-checkpoint.js +1 -1
- package/dist/protocols/utils/responses-compaction.d.ts +1 -1
- package/dist/protocols/utils/responses-compaction.js +6 -5
- package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
- package/dist/protocols/utils/responses-hosted-tools.js +31 -0
- package/dist/protocols/utils/tool-stream.d.ts +5 -271
- package/dist/protocols/utils/tool-stream.js +3 -13
- package/dist/protocols/venice-chat.d.ts +7 -1
- package/dist/protocols/venice-chat.js +4 -4
- package/dist/protocols/xai-images.d.ts +2 -2
- package/dist/protocols/xai-responses.js +5 -25
- package/dist/protocols/xai-video.d.ts +2 -2
- package/dist/protocols/zai-chat.d.ts +9 -1
- package/dist/protocols/zai-chat.js +1 -1
- package/dist/protocols/zai-images.d.ts +2 -2
- package/dist/protocols/zai-messages.js +3 -3
- package/dist/provider-error.d.ts +0 -1
- package/dist/provider-error.js +7 -80
- package/dist/providers/alibaba/embeddings.d.ts +2 -0
- package/dist/providers/alibaba/embeddings.js +1 -0
- package/dist/providers/alibaba.d.ts +70 -4
- package/dist/providers/alibaba.js +20 -2
- package/dist/providers/amazon-bedrock-mantle.d.ts +7 -3
- package/dist/providers/amazon-bedrock-mantle.js +6 -3
- package/dist/providers/amazon-bedrock.d.ts +6 -7
- package/dist/providers/amazon-bedrock.js +1 -1
- package/dist/providers/anthropic-compatible.d.ts +7 -8
- package/dist/providers/anthropic-compatible.js +2 -5
- package/dist/providers/anthropic.d.ts +8 -9
- package/dist/providers/anthropic.js +2 -7
- package/dist/providers/assemblyai.d.ts +2 -2
- package/dist/providers/assemblyai.js +2 -7
- package/dist/providers/azure/embeddings.d.ts +2 -0
- package/dist/providers/azure/embeddings.js +1 -0
- package/dist/providers/azure/messages.d.ts +2 -0
- package/dist/providers/azure/messages.js +1 -0
- package/dist/providers/azure.d.ts +325 -7
- package/dist/providers/azure.js +40 -9
- package/dist/providers/baseten.d.ts +7 -5
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cartesia.d.ts +1 -1
- package/dist/providers/cerebras.d.ts +7 -5
- package/dist/providers/cerebras.js +4 -15
- package/dist/providers/cloudflare-ai-gateway.d.ts +23 -13
- package/dist/providers/cloudflare-ai-gateway.js +28 -40
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +6 -4
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere/embeddings.d.ts +2 -0
- package/dist/providers/cohere/embeddings.js +1 -0
- package/dist/providers/cohere.d.ts +14 -5
- package/dist/providers/cohere.js +23 -13
- package/dist/providers/deepgram.d.ts +2 -2
- package/dist/providers/deepgram.js +2 -7
- package/dist/providers/deepinfra/embeddings.d.ts +2 -0
- package/dist/providers/deepinfra/embeddings.js +1 -0
- package/dist/providers/deepinfra.d.ts +10 -5
- package/dist/providers/deepinfra.js +20 -14
- package/dist/providers/deepseek.d.ts +7 -5
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean/embeddings.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.js +1 -0
- package/dist/providers/digitalocean.d.ts +18 -5
- package/dist/providers/digitalocean.js +28 -14
- package/dist/providers/elevenlabs.d.ts +2 -2
- package/dist/providers/elevenlabs.js +2 -7
- package/dist/providers/fireworks/embeddings.d.ts +2 -0
- package/dist/providers/fireworks/embeddings.js +1 -0
- package/dist/providers/fireworks.d.ts +10 -5
- package/dist/providers/fireworks.js +17 -14
- package/dist/providers/google/embeddings.d.ts +2 -0
- package/dist/providers/google/embeddings.js +1 -0
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex/embeddings.d.ts +2 -0
- package/dist/providers/google-vertex/embeddings.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +4 -3
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-interactions.d.ts +3 -3
- package/dist/providers/google-vertex-messages.d.ts +3 -3
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.d.ts +3 -3
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.d.ts +3 -3
- package/dist/providers/google-vertex-responses.js +4 -30
- package/dist/providers/google-vertex-shared.d.ts +31 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/google-vertex.d.ts +10 -3
- package/dist/providers/google-vertex.js +52 -0
- package/dist/providers/google.d.ts +21 -13
- package/dist/providers/google.js +23 -19
- package/dist/providers/groq.d.ts +10 -5
- package/dist/providers/groq.js +4 -15
- package/dist/providers/meta.d.ts +6 -5
- package/dist/providers/meta.js +10 -23
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +6 -5
- package/dist/providers/minimax.js +7 -22
- package/dist/providers/mistral.d.ts +10 -11
- package/dist/providers/mistral.js +3 -14
- package/dist/providers/moonshot/messages.js +2 -7
- package/dist/providers/moonshot/responses.js +2 -7
- package/dist/providers/moonshot.d.ts +6 -5
- package/dist/providers/moonshot.js +4 -16
- package/dist/providers/openai/embeddings.d.ts +2 -0
- package/dist/providers/openai/embeddings.js +1 -0
- package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
- package/dist/providers/openai-compatible/embeddings.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +6 -7
- package/dist/providers/openai-compatible-responses.js +2 -8
- package/dist/providers/openai-compatible.d.ts +10 -7
- package/dist/providers/openai-compatible.js +17 -10
- package/dist/providers/openai.d.ts +11 -4
- package/dist/providers/openai.js +17 -3
- package/dist/providers/opencode.d.ts +4 -4
- package/dist/providers/opencode.js +6 -2
- package/dist/providers/openrouter/embeddings.d.ts +2 -0
- package/dist/providers/openrouter/embeddings.js +1 -0
- package/dist/providers/openrouter.d.ts +24 -5
- package/dist/providers/openrouter.js +31 -24
- package/dist/providers/runway.d.ts +1 -1
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +19 -0
- package/dist/providers/togetherai.d.ts +7 -5
- package/dist/providers/togetherai.js +5 -15
- package/dist/providers/typesafe-ai.d.ts +4 -4
- package/dist/providers/typesafe-ai.js +6 -2
- package/dist/providers/venice.d.ts +5 -4
- package/dist/providers/venice.js +6 -2
- package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +9 -5
- package/dist/providers/vercel-ai-gateway.js +30 -29
- package/dist/providers/xai.d.ts +5 -4
- package/dist/providers/xai.js +4 -12
- package/dist/providers/zai-coding-plan/messages.js +2 -7
- package/dist/providers/zai-coding-plan/responses.js +2 -7
- package/dist/providers/zai-coding-plan.d.ts +6 -5
- package/dist/providers/zai-coding-plan.js +8 -15
- package/dist/providers/zai.d.ts +6 -5
- package/dist/providers/zai.js +10 -22
- package/dist/public.d.ts +14 -0
- package/dist/public.js +6 -0
- package/dist/route/auth-options.d.ts +9 -5
- package/dist/route/auth-options.js +10 -7
- package/dist/route/client.d.ts +50 -37
- package/dist/route/client.js +42 -53
- package/dist/route/decision.d.ts +8 -8
- package/dist/route/decision.js +3 -3
- package/dist/route/embedding.d.ts +61 -0
- package/dist/route/embedding.js +88 -0
- package/dist/route/executor.d.ts +5 -0
- package/dist/route/executor.js +10 -0
- package/dist/route/index.d.ts +5 -7
- package/dist/route/index.js +1 -1
- package/dist/route/media.d.ts +7 -11
- package/dist/route/media.js +22 -26
- package/dist/route/transport/http.js +6 -5
- package/dist/route/transport/websocket.js +7 -1
- package/dist/schema/errors.d.ts +16 -17
- package/dist/schema/errors.js +63 -12
- package/dist/schema/events.d.ts +2563 -2954
- package/dist/schema/events.js +54 -109
- package/dist/schema/messages.d.ts +194 -137
- package/dist/schema/messages.js +66 -83
- package/dist/schema/options.d.ts +112 -65
- package/dist/schema/options.js +52 -101
- package/dist/speech-client.d.ts +7 -7
- package/dist/speech.d.ts +306 -316
- package/dist/speech.js +16 -14
- package/dist/testing.d.ts +31 -175
- package/dist/testing.js +60 -5
- package/dist/tool-history.d.ts +1 -1
- package/dist/tool-history.js +3 -10
- package/dist/tool-runtime.d.ts +9 -2
- package/dist/tool-runtime.js +17 -31
- package/dist/tool.d.ts +39 -43
- package/dist/tool.js +16 -26
- package/dist/transcription-client.d.ts +7 -7
- package/dist/transcription.d.ts +314 -265
- package/dist/transcription.js +16 -14
- package/dist/utils/provider-codes.d.ts +3 -0
- package/dist/utils/provider-codes.js +41 -0
- package/dist/video-client.d.ts +7 -7
- package/dist/video-client.js +1 -1
- package/dist/video.d.ts +269 -287
- package/dist/video.js +16 -14
- package/package.json +309 -257
- package/dist/experimental/testing.d.ts +0 -3
- package/dist/experimental/testing.js +0 -3
- package/dist/testing/decision.d.ts +0 -16
- package/dist/testing/decision.js +0 -20
- package/dist/testing/image.d.ts +0 -14
- package/dist/testing/image.js +0 -12
- package/dist/testing/media.d.ts +0 -18
- package/dist/testing/media.js +0 -36
- package/dist/testing/script.d.ts +0 -28
- package/dist/testing/script.js +0 -60
- package/dist/testing/speech.d.ts +0 -14
- package/dist/testing/speech.js +0 -12
- package/dist/testing/transcription.d.ts +0 -14
- package/dist/testing/transcription.js +0 -12
- package/dist/testing/video.d.ts +0 -14
- package/dist/testing/video.js +0 -12
|
@@ -1,16 +0,0 @@
|
|
|
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";
|
package/dist/testing/decision.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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";
|
package/dist/testing/image.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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";
|
package/dist/testing/image.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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";
|
package/dist/testing/media.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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";
|
package/dist/testing/media.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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";
|
package/dist/testing/script.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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";
|
package/dist/testing/script.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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";
|
package/dist/testing/speech.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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";
|
package/dist/testing/speech.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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";
|
|
@@ -1,14 +0,0 @@
|
|
|
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";
|
|
@@ -1,12 +0,0 @@
|
|
|
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";
|
package/dist/testing/video.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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";
|
package/dist/testing/video.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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";
|