@opencode-ai/ai 0.0.0-next-16783 → 0.0.0-next-16789
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/dist/route/client.js +12 -3
- package/dist/schema/errors.d.ts +1 -0
- package/dist/schema/errors.js +1 -0
- package/package.json +3 -3
package/dist/route/client.js
CHANGED
|
@@ -8,7 +8,7 @@ import { HttpTransport } from "./transport";
|
|
|
8
8
|
import { WebSocketExecutor } from "./transport";
|
|
9
9
|
import { applyCachePolicy } from "../cache-policy";
|
|
10
10
|
import * as ProviderShared from "../protocols/shared";
|
|
11
|
-
import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LanguageModelLimits, LLMEvent, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema";
|
|
11
|
+
import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LanguageModelLimits, LLMEvent, InvalidProviderOutputReason, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema";
|
|
12
12
|
const makeRouteLanguageModel = (route, mapped) => {
|
|
13
13
|
const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined);
|
|
14
14
|
if (!provider)
|
|
@@ -64,6 +64,15 @@ const streamError = (route, message, cause) => {
|
|
|
64
64
|
return failed;
|
|
65
65
|
return ProviderShared.eventError(route, message, Cause.pretty(cause));
|
|
66
66
|
};
|
|
67
|
+
const incompleteStreamError = (route) => new AIError({
|
|
68
|
+
module: "LLMClient",
|
|
69
|
+
method: "stream",
|
|
70
|
+
reason: new InvalidProviderOutputReason({
|
|
71
|
+
classification: "incomplete-stream",
|
|
72
|
+
message: "The provider response ended unexpectedly.",
|
|
73
|
+
route,
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
67
76
|
const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
|
|
68
77
|
let terminal = false;
|
|
69
78
|
return events.pipe(Stream.mapEffect((event) => {
|
|
@@ -74,7 +83,7 @@ const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
|
|
|
74
83
|
return Effect.succeed(event);
|
|
75
84
|
}), Stream.onEnd(Effect.suspend(() => terminal
|
|
76
85
|
? Effect.void
|
|
77
|
-
: Effect.fail(
|
|
86
|
+
: Effect.fail(incompleteStreamError(route)))));
|
|
78
87
|
});
|
|
79
88
|
function makeFromTransport(input) {
|
|
80
89
|
const protocol = input.protocol;
|
|
@@ -177,7 +186,7 @@ const generateWith = (stream) => Effect.fn("LLM.generate")(function* (request, o
|
|
|
177
186
|
const response = LLMResponse.complete(state);
|
|
178
187
|
if (response)
|
|
179
188
|
return response;
|
|
180
|
-
return yield*
|
|
189
|
+
return yield* incompleteStreamError(`${request.model.provider}/${request.model.route.id}`);
|
|
181
190
|
});
|
|
182
191
|
export function stream(request, options) {
|
|
183
192
|
return Stream.unwrap(Effect.gen(function* () {
|
package/dist/schema/errors.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ export declare class TransportReason extends TransportReason_base {
|
|
|
109
109
|
declare const InvalidProviderOutputReason_base: Schema.Class<InvalidProviderOutputReason, Schema.Struct<{
|
|
110
110
|
readonly _tag: Schema.tag<"InvalidProviderOutput">;
|
|
111
111
|
readonly message: Schema.String;
|
|
112
|
+
readonly classification: Schema.optional<Schema.Literals<readonly ["incomplete-stream"]>>;
|
|
112
113
|
readonly route: Schema.optional<Schema.String>;
|
|
113
114
|
readonly raw: Schema.optional<Schema.String>;
|
|
114
115
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
package/dist/schema/errors.js
CHANGED
|
@@ -99,6 +99,7 @@ export class TransportReason extends Schema.Class("AI.Error.Transport")({
|
|
|
99
99
|
export class InvalidProviderOutputReason extends Schema.Class("AI.Error.InvalidProviderOutput")({
|
|
100
100
|
_tag: Schema.tag("InvalidProviderOutput"),
|
|
101
101
|
message: Schema.String,
|
|
102
|
+
classification: Schema.optional(Schema.Literals(["incomplete-stream"])),
|
|
102
103
|
route: Schema.optional(Schema.String),
|
|
103
104
|
raw: Schema.optional(Schema.String),
|
|
104
105
|
providerMetadata: Schema.optional(ProviderMetadata),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-16789",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
32
32
|
"@effect/platform-node": "4.0.0-beta.101",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-next-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-next-16789",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.3.13",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@smithy/eventstream-codec": "4.2.14",
|
|
41
41
|
"@smithy/util-utf8": "4.2.2",
|
|
42
|
-
"@opencode-ai/schema": "0.0.0-next-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-next-16789",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-beta.101",
|
|
45
45
|
"google-auth-library": "10.5.0"
|