@opencode/ai 0.0.0-dev-20783 → 0.0.0-dev-20784
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/experimental/system-one.js +1 -1
- package/dist/media.js +7 -6
- package/dist/protocols/anthropic-messages.js +1 -1
- package/dist/protocols/bedrock-converse.js +4 -3
- package/dist/protocols/bedrock-event-stream.js +4 -3
- package/dist/protocols/meta-responses.js +3 -2
- package/dist/protocols/open-responses-channel.d.ts +1 -1
- package/dist/protocols/open-responses-channel.js +1 -1
- package/dist/protocols/openai-responses.d.ts +5 -5
- package/dist/protocols/openai-responses.js +4 -3
- package/dist/protocols/shared.d.ts +1 -1
- package/dist/protocols/shared.js +1 -1
- package/dist/protocols/utils/bedrock-auth.js +1 -1
- package/dist/protocols/utils/bedrock-media.js +4 -3
- package/dist/protocols/utils/fal-queue.d.ts +1 -1
- package/dist/protocols/utils/media-input.js +4 -3
- package/dist/protocols/utils/tool-schema.js +8 -2
- package/dist/providers/azure.d.ts +2 -2
- package/dist/providers/cloudflare-ai-gateway.d.ts +2 -2
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/vercel-ai-gateway.js +1 -1
- package/dist/route/auth.d.ts +1 -1
- package/dist/route/auth.js +2 -2
- package/dist/route/executor-service.d.ts +1 -1
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/executor.js +1 -1
- package/dist/route/framing.js +1 -1
- package/dist/route/media-protocol.d.ts +1 -1
- package/dist/route/media-protocol.js +1 -1
- package/dist/route/media.js +1 -1
- package/dist/route/transport/http.d.ts +1 -1
- package/dist/route/transport/http.js +1 -1
- package/dist/route/transport/websocket-channel.d.ts +1 -1
- package/dist/route/transport/websocket.d.ts +4 -4
- package/dist/route/transport/websocket.js +4 -9
- package/dist/schema/messages.js +9 -8
- package/dist/tool.d.ts +10 -0
- package/dist/tool.js +21 -2
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import { Headers, HttpClientRequest } from "effect/
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
3
|
import { ChoiceQuestion, EvaluationInput, EvaluationModel, EvaluationResponse, EvaluationRounding, ScoreQuestion, } from "./evaluation.js";
|
|
4
4
|
import { Auth } from "../route/auth.js";
|
|
5
5
|
import { AIError, HttpContext, HttpOptions, InvalidProviderOutputError, InvalidRequestError, ModelID, Usage, mergeJsonRecords, } from "../schema/index.js";
|
package/dist/media.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as Media from "./media.js";
|
|
2
|
-
import { Effect,
|
|
3
|
-
import {
|
|
2
|
+
import { Effect, FileSystem, Schema, SchemaGetter } from "effect";
|
|
3
|
+
import { Base64 } from "effect/encoding";
|
|
4
|
+
import { HttpClientRequest } from "effect/http";
|
|
4
5
|
import { ProviderID } from "./schema/ids.js";
|
|
5
6
|
import { AIError, HttpContext, InvalidProviderOutputError, InvalidRequestError } from "./schema/errors.js";
|
|
6
7
|
import { ProviderMetadata } from "./schema/options.js";
|
|
@@ -105,7 +106,7 @@ export class Asset {
|
|
|
105
106
|
const source = this.source;
|
|
106
107
|
if (source.type !== "bytes" && source.type !== "base64")
|
|
107
108
|
return undefined;
|
|
108
|
-
const base64 = source.type === "base64" ? source.data : (this.#base64 ??=
|
|
109
|
+
const base64 = source.type === "base64" ? source.data : (this.#base64 ??= Base64.encode(source.data));
|
|
109
110
|
const mime = this.mediaType.toLowerCase();
|
|
110
111
|
return { mime, base64, dataUrl: `data:${mime};base64,${base64}` };
|
|
111
112
|
}
|
|
@@ -120,7 +121,7 @@ export class Asset {
|
|
|
120
121
|
if (source.type === "ref")
|
|
121
122
|
return Effect.fail(invalid(`Cannot materialize provider ref ${source.provider}:${source.id}`));
|
|
122
123
|
const decoded = source.type === "base64"
|
|
123
|
-
? Effect.fromResult(
|
|
124
|
+
? Effect.fromResult(Base64.decode(source.data)).pipe(Effect.mapError((cause) => invalid(`Media asset contains invalid base64 data`, cause)))
|
|
124
125
|
: download(source, this.headers);
|
|
125
126
|
return decoded.pipe(Effect.tap((data) => Effect.sync(() => (this.#bytes = data))));
|
|
126
127
|
});
|
|
@@ -132,7 +133,7 @@ export class Asset {
|
|
|
132
133
|
return Effect.succeed(source.data);
|
|
133
134
|
if (this.#base64 !== undefined)
|
|
134
135
|
return Effect.succeed(this.#base64);
|
|
135
|
-
return this.bytes().pipe(Effect.map((data) => (this.#base64 =
|
|
136
|
+
return this.bytes().pipe(Effect.map((data) => (this.#base64 = Base64.encode(data))));
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
dataUrl() {
|
|
@@ -145,7 +146,7 @@ export class Asset {
|
|
|
145
146
|
toJSON() {
|
|
146
147
|
const source = this.source;
|
|
147
148
|
return {
|
|
148
|
-
source: source.type === "bytes" ? { ...source, data:
|
|
149
|
+
source: source.type === "bytes" ? { ...source, data: Base64.encode(source.data) } : source,
|
|
149
150
|
info: this.info,
|
|
150
151
|
providerMetadata: this.providerMetadata,
|
|
151
152
|
};
|
|
@@ -6,7 +6,7 @@ import { Auth } from "../route/auth.js";
|
|
|
6
6
|
import { Endpoint } from "../route/endpoint.js";
|
|
7
7
|
import { Framing } from "../route/framing.js";
|
|
8
8
|
import { Protocol } from "../route/protocol.js";
|
|
9
|
-
import { Headers } from "effect/
|
|
9
|
+
import { Headers } from "effect/http";
|
|
10
10
|
import { HttpTransport } from "../route/transport/index.js";
|
|
11
11
|
import { AIError, HttpOptions, LLMRequest, LLMEvent, mergeJsonRecords, Usage, } from "../schema/index.js";
|
|
12
12
|
import { JsonObject, knownString, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Base64 } from "effect/encoding";
|
|
2
3
|
import { Route } from "../route/client.js";
|
|
3
4
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
5
|
import { Protocol } from "../route/protocol.js";
|
|
@@ -489,7 +490,7 @@ const mapUsage = (usage, providerMetadataKey) => {
|
|
|
489
490
|
providerMetadata: { [providerMetadataKey]: usage },
|
|
490
491
|
});
|
|
491
492
|
};
|
|
492
|
-
const encodeRedactedContent = (chunks) =>
|
|
493
|
+
const encodeRedactedContent = (chunks) => Base64.encode(concatBytes(chunks));
|
|
493
494
|
const step = (state, event) => Effect.gen(function* () {
|
|
494
495
|
if (event.contentBlockStart?.start?.toolUse) {
|
|
495
496
|
const index = event.contentBlockStart.contentBlockIndex;
|
|
@@ -530,7 +531,7 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
530
531
|
const redactedChunk = yield* (() => {
|
|
531
532
|
if (reasoning.redactedContent === undefined)
|
|
532
533
|
return Effect.succeed(undefined);
|
|
533
|
-
return Effect.fromResult(
|
|
534
|
+
return Effect.fromResult(Base64.decode(reasoning.redactedContent)).pipe(Effect.mapError((cause) => ProviderShared.eventError(ADAPTER, "Bedrock Converse reasoningContent.redactedContent contains invalid base64 data", undefined, cause)));
|
|
534
535
|
})();
|
|
535
536
|
const redactedChunks = state.reasoningRedactedContent[index] ?? [];
|
|
536
537
|
if (redactedChunk !== undefined)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventStreamCodec } from "@smithy/eventstream-codec";
|
|
2
2
|
import { fromUtf8, toUtf8 } from "@smithy/util-utf8";
|
|
3
|
-
import { Effect,
|
|
3
|
+
import { Effect, Stream } from "effect";
|
|
4
|
+
import { Base64 } from "effect/encoding";
|
|
4
5
|
import { AIError, AIErrorReason, InvalidProviderOutputError } from "../schema/index.js";
|
|
5
6
|
import { Framing } from "../route/framing.js";
|
|
6
7
|
import { ProviderShared } from "./shared.js";
|
|
@@ -31,7 +32,7 @@ const consumeFrames = (route) => (state, input) => Effect.gen(function* () {
|
|
|
31
32
|
route,
|
|
32
33
|
classification: "incomplete-stream",
|
|
33
34
|
message: `Incomplete Bedrock Converse event-stream frame: ${remaining.length} buffered bytes remain at end of stream`,
|
|
34
|
-
body:
|
|
35
|
+
body: Base64.encode(remaining),
|
|
35
36
|
}),
|
|
36
37
|
});
|
|
37
38
|
return [state, []];
|
|
@@ -45,7 +46,7 @@ const consumeFrames = (route) => (state, input) => Effect.gen(function* () {
|
|
|
45
46
|
break;
|
|
46
47
|
const decoded = yield* Effect.try({
|
|
47
48
|
try: () => eventCodec.decode(view.subarray(0, totalLength)),
|
|
48
|
-
catch: (error) => ProviderShared.eventError(route, `Failed to decode Bedrock Converse event-stream frame: ${error instanceof Error ? error.message : String(error)}`,
|
|
49
|
+
catch: (error) => ProviderShared.eventError(route, `Failed to decode Bedrock Converse event-stream frame: ${error instanceof Error ? error.message : String(error)}`, Base64.encode(view.subarray(0, totalLength)), error),
|
|
49
50
|
});
|
|
50
51
|
cursor = { buffer: cursor.buffer, offset: cursor.offset + totalLength };
|
|
51
52
|
const payload = utf8.decode(decoded.body);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Base64 } from "effect/encoding";
|
|
2
3
|
import { Protocol } from "../route/protocol.js";
|
|
3
4
|
import { LLMEvent, LLMRequest, Message, ToolResultPart } from "../schema/index.js";
|
|
4
5
|
import { OpenResponses } from "./open-responses.js";
|
|
@@ -80,7 +81,7 @@ const HOSTED_TOOLS = {
|
|
|
80
81
|
return { type: "error", value: item.error };
|
|
81
82
|
if (!item.result)
|
|
82
83
|
return yield* ProviderShared.eventError(ADAPTER, "Meta returned an image without data", ProviderShared.encodeJson(raw));
|
|
83
|
-
const data = yield* Effect.fromResult(
|
|
84
|
+
const data = yield* Effect.fromResult(Base64.decode(item.result)).pipe(Effect.mapError((cause) => ProviderShared.eventError(ADAPTER, "Meta returned invalid image base64", ProviderShared.encodeJson(raw), cause)));
|
|
84
85
|
// Responses image items can omit output_format, including when PNG/JPEG was requested.
|
|
85
86
|
const mime = item.output_format === undefined
|
|
86
87
|
? (detectMediaType(data) ?? "application/octet-stream")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Headers } from "effect/
|
|
1
|
+
import { Headers } from "effect/http";
|
|
2
2
|
import { HttpTransport, type Transport, type WebSocketChannelDriver } from "../route/transport/index.js";
|
|
3
3
|
import { OpenResponsesContinuation } from "./open-responses-continuation.js";
|
|
4
4
|
export interface Options {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema, Stream } from "effect";
|
|
2
|
-
import { Headers } from "effect/
|
|
2
|
+
import { Headers } from "effect/http";
|
|
3
3
|
import { Framing } from "../route/framing.js";
|
|
4
4
|
import { HttpTransport, WebSocketTransport, } from "../route/transport/index.js";
|
|
5
5
|
import * as ProviderShared from "./shared.js";
|
|
@@ -348,7 +348,7 @@ export declare const protocol: Protocol<{
|
|
|
348
348
|
} | {
|
|
349
349
|
readonly type: "image_generation";
|
|
350
350
|
readonly size?: string | undefined;
|
|
351
|
-
readonly action?: "
|
|
351
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
352
352
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
353
353
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
354
354
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -610,7 +610,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
610
610
|
} | {
|
|
611
611
|
readonly type: "image_generation";
|
|
612
612
|
readonly size?: string | undefined;
|
|
613
|
-
readonly action?: "
|
|
613
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
614
614
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
615
615
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
616
616
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -814,7 +814,7 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
814
814
|
} | {
|
|
815
815
|
readonly type: "image_generation";
|
|
816
816
|
readonly size?: string | undefined;
|
|
817
|
-
readonly action?: "
|
|
817
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
818
818
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
819
819
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
820
820
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -1018,7 +1018,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1018
1018
|
} | {
|
|
1019
1019
|
readonly type: "image_generation";
|
|
1020
1020
|
readonly size?: string | undefined;
|
|
1021
|
-
readonly action?: "
|
|
1021
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
1022
1022
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
1023
1023
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
1024
1024
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -1222,7 +1222,7 @@ export declare const route: Route<{
|
|
|
1222
1222
|
} | {
|
|
1223
1223
|
readonly type: "image_generation";
|
|
1224
1224
|
readonly size?: string | undefined;
|
|
1225
|
-
readonly action?: "
|
|
1225
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
1226
1226
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
1227
1227
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
1228
1228
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Effect,
|
|
2
|
-
import {
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Base64 } from "effect/encoding";
|
|
3
|
+
import { Headers } from "effect/http";
|
|
3
4
|
import { Route } from "../route/client.js";
|
|
4
5
|
import { Auth } from "../route/auth.js";
|
|
5
6
|
import { Endpoint } from "../route/endpoint.js";
|
|
@@ -194,7 +195,7 @@ const checkpointBody = {
|
|
|
194
195
|
const hostedToolResult = Effect.fnUntraced(function* (item) {
|
|
195
196
|
const isError = item.error !== undefined && item.error !== null;
|
|
196
197
|
if (item.type === "image_generation_call" && item.result) {
|
|
197
|
-
yield* Effect.fromResult(
|
|
198
|
+
yield* Effect.fromResult(Base64.decode(item.result)).pipe(Effect.mapError((cause) => ProviderShared.eventError(ADAPTER, "OpenAI Responses returned invalid image base64", undefined, cause)));
|
|
198
199
|
const format = item.output_format ?? "png";
|
|
199
200
|
return {
|
|
200
201
|
type: "content",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tool } from "@opencode/schema/tool";
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
|
-
import { Headers, HttpClientRequest } from "effect/
|
|
3
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
4
4
|
import { Media } from "../media.js";
|
|
5
5
|
import { AIError, LLMRequest, Message, ToolDefinition, type ContentPart, type MediaPart, type OpenString, type ProviderID, type ToolEntry, type ToolResultPart } from "../schema/index.js";
|
|
6
6
|
import { Json, decodeJson, encodeJson } from "../utils/json.js";
|
package/dist/protocols/shared.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tool } from "@opencode/schema/tool";
|
|
2
2
|
import { Effect, Option, Schema } from "effect";
|
|
3
|
-
import { Headers, HttpClientRequest } from "effect/
|
|
3
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
4
4
|
import { Media } from "../media.js";
|
|
5
5
|
import { InvalidProviderOutputError, InvalidRequestError, UnsupportedOperationError, AIError, LLMRequest, Message, ToolDefinition, } from "../schema/index.js";
|
|
6
6
|
import { Json, decodeJson, encodeJson } from "../utils/json.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AwsV4Signer } from "aws4fetch";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import { Headers } from "effect/
|
|
3
|
+
import { Headers } from "effect/http";
|
|
4
4
|
import { Auth } from "../../route/auth.js";
|
|
5
5
|
import { AIError, AuthenticationError } from "../../schema/index.js";
|
|
6
6
|
import { ProviderShared } from "../shared.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Base64 } from "effect/encoding";
|
|
2
3
|
import { ProviderShared } from "../shared.js";
|
|
3
4
|
// Bedrock Converse accepts image `format` as the file extension and
|
|
4
5
|
// `source.bytes` as base64 in the JSON wire format.
|
|
@@ -63,8 +64,8 @@ function documentName(filename, names) {
|
|
|
63
64
|
}
|
|
64
65
|
const mediaBase64 = Effect.fnUntraced(function* (part) {
|
|
65
66
|
const media = yield* ProviderShared.requireInlineMedia("Bedrock Converse", part.media);
|
|
66
|
-
const bytes = yield* Effect.fromResult(
|
|
67
|
-
return
|
|
67
|
+
const bytes = yield* Effect.fromResult(Base64.decode(media.base64)).pipe(Effect.mapError((cause) => ProviderShared.invalidRequest("Bedrock Converse media data must be valid base64", cause)));
|
|
68
|
+
return Base64.encode(bytes);
|
|
68
69
|
});
|
|
69
70
|
// Route by MIME. Known image/document formats lower into a typed block; anything
|
|
70
71
|
// else fails with a clear error instead of silently degrading to a malformed
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import type { HttpClientResponse } from "effect/
|
|
2
|
+
import type { HttpClientResponse } from "effect/http";
|
|
3
3
|
import type { Media } from "../../media.js";
|
|
4
4
|
import { MediaProtocol } from "../../route/media-protocol.js";
|
|
5
5
|
import type { AIError } from "../../schema/index.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Effect
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Base64 } from "effect/encoding";
|
|
2
3
|
import { Media } from "../../media.js";
|
|
3
4
|
import { mergeJsonRecords } from "../../schema/index.js";
|
|
4
5
|
import { encodeJson } from "../../utils/json.js";
|
|
@@ -10,7 +11,7 @@ export const inlineBytes = (route, asset) => {
|
|
|
10
11
|
const inline = asset.inline();
|
|
11
12
|
if (!inline)
|
|
12
13
|
return Effect.fail(ProviderShared.inlineRequired(route, asset));
|
|
13
|
-
return Effect.fromResult(
|
|
14
|
+
return Effect.fromResult(Base64.decode(inline.base64)).pipe(Effect.mapError((cause) => ProviderShared.invalidRequest(`${route} media contains invalid base64 data`, cause)));
|
|
14
15
|
};
|
|
15
16
|
/** Copied because `BlobPart` requires a plain `ArrayBuffer`. */
|
|
16
17
|
export const blob = (data, mediaType) => {
|
|
@@ -33,7 +34,7 @@ export const dimensions = (size) => {
|
|
|
33
34
|
/** Provider file handle when the ref belongs to this provider; refs from other providers are never forwarded. */
|
|
34
35
|
export const refID = (asset, provider) => asset.source.type === "ref" && asset.source.provider === provider ? asset.source.id : undefined;
|
|
35
36
|
/** Decode a provider's base64 output once into an owned `bytes` asset, sniffing the type when it is not declared. */
|
|
36
|
-
export const decodedAsset = (invalid, label, data, mediaType, options) => Effect.fromResult(
|
|
37
|
+
export const decodedAsset = (invalid, label, data, mediaType, options) => Effect.fromResult(Base64.decode(data)).pipe(Effect.mapError((cause) => invalid(`${label} contains invalid base64 data`, cause)), Effect.map((bytes) => Media.bytes(bytes, mediaType, options)));
|
|
37
38
|
/** One image of an OpenAI-shaped `data` array, which carries either `b64_json` or a `url`. */
|
|
38
39
|
export const imageOutput = (invalid, label, item, mediaType, options) => {
|
|
39
40
|
if (item.b64_json)
|
|
@@ -56,9 +56,15 @@ const MODEL_NAMES = [
|
|
|
56
56
|
[/kimi/i, "moonshot"],
|
|
57
57
|
];
|
|
58
58
|
// Tool arguments are always a JSON object, and most providers reject a tool schema whose root does not
|
|
59
|
-
// declare `type: "object"`, such as `{}` or a bare `properties` map.
|
|
60
|
-
//
|
|
59
|
+
// declare `type: "object"`, such as `{}` or a bare `properties` map. An object root makes Effect's
|
|
60
|
+
// empty-struct markers redundant: `{ not: { type: "null" } }`, and `anyOf` object or array from older
|
|
61
|
+
// releases. Both are dropped so the root is a plain object schema.
|
|
61
62
|
const objectRoot = (schema) => {
|
|
63
|
+
if ((schema.type === undefined || schema.type === "object") &&
|
|
64
|
+
isRecord(schema.not) &&
|
|
65
|
+
schema.not.type === "null" &&
|
|
66
|
+
Object.keys(schema.not).length === 1)
|
|
67
|
+
return { type: "object", ...Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "not")) };
|
|
62
68
|
if (schema.type !== undefined)
|
|
63
69
|
return schema;
|
|
64
70
|
if (Array.isArray(schema.anyOf) &&
|
|
@@ -166,7 +166,7 @@ declare const responsesRoute: Route<{
|
|
|
166
166
|
} | {
|
|
167
167
|
readonly type: "image_generation";
|
|
168
168
|
readonly size?: string | undefined;
|
|
169
|
-
readonly action?: "
|
|
169
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
170
170
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
171
171
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
172
172
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -493,7 +493,7 @@ export declare const routes: (Route<{
|
|
|
493
493
|
} | {
|
|
494
494
|
readonly type: "image_generation";
|
|
495
495
|
readonly size?: string | undefined;
|
|
496
|
-
readonly action?: "
|
|
496
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
497
497
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
498
498
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
499
499
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -172,7 +172,7 @@ export declare const responsesRoute: import("../route/client.js").Route<{
|
|
|
172
172
|
} | {
|
|
173
173
|
readonly type: "image_generation";
|
|
174
174
|
readonly size?: string | undefined;
|
|
175
|
-
readonly action?: "
|
|
175
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
176
176
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
177
177
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
178
178
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -1167,7 +1167,7 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
1167
1167
|
} | {
|
|
1168
1168
|
readonly type: "image_generation";
|
|
1169
1169
|
readonly size?: string | undefined;
|
|
1170
|
-
readonly action?: "
|
|
1170
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
1171
1171
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
1172
1172
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
1173
1173
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -275,7 +275,7 @@ export declare const routes: (Route<{
|
|
|
275
275
|
} | {
|
|
276
276
|
readonly type: "image_generation";
|
|
277
277
|
readonly size?: string | undefined;
|
|
278
|
-
readonly action?: "
|
|
278
|
+
readonly action?: "auto" | "generate" | "edit" | undefined;
|
|
279
279
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
280
280
|
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
281
281
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import { Headers, HttpClientRequest } from "effect/
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
3
|
import { EvaluationAnswer, EvaluationInput, EvaluationModel, EvaluationQuestion, EvaluationResponse, EvaluationRounding, } from "../experimental/evaluation.js";
|
|
4
4
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
5
5
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
package/dist/route/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config, Effect, Redacted } from "effect";
|
|
2
|
-
import { Headers } from "effect/
|
|
2
|
+
import { Headers } from "effect/http";
|
|
3
3
|
import { AIError, type HttpOptions } from "../schema/index.js";
|
|
4
4
|
export declare class MissingCredentialError extends Error {
|
|
5
5
|
readonly source: string;
|
package/dist/route/auth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config, Effect, Option, Redacted } from "effect";
|
|
2
|
-
import { Headers } from "effect/
|
|
2
|
+
import { Headers } from "effect/http";
|
|
3
3
|
import { AuthenticationError, AIError } from "../schema/index.js";
|
|
4
4
|
export class MissingCredentialError extends Error {
|
|
5
5
|
source;
|
|
@@ -48,7 +48,7 @@ export const optional = (secret, source = "optional value") => secret === undefi
|
|
|
48
48
|
? credential(Effect.fail(new MissingCredentialError(source)))
|
|
49
49
|
: credentialFromSecret(secret, source);
|
|
50
50
|
export const config = (name) => credential(Effect.gen(function* () {
|
|
51
|
-
const secret = yield* Config.option(Config.
|
|
51
|
+
const secret = yield* Config.option(Config.Redacted(name));
|
|
52
52
|
if (Option.isSome(secret) && Redacted.value(secret.value) !== "")
|
|
53
53
|
return secret.value;
|
|
54
54
|
return yield* Effect.fail(new MissingCredentialError(name, `${name} is not set`));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, type Effect } from "effect";
|
|
2
|
-
import type { HttpClientRequest, HttpClientResponse } from "effect/
|
|
2
|
+
import type { HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
3
3
|
import type { AIError } from "../schema/errors.js";
|
|
4
4
|
export interface Interface {
|
|
5
5
|
readonly execute: (request: HttpClientRequest.HttpClientRequest, middleware?: HttpMiddleware) => Effect.Effect<HttpClientResponse.HttpClientResponse, AIError>;
|
package/dist/route/executor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Layer, Stream } from "effect";
|
|
2
|
-
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/
|
|
2
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
3
3
|
import { HttpContext, AIError } from "../schema/index.js";
|
|
4
4
|
import { Service, type HttpMiddleware, type Interface } from "./executor-service.js";
|
|
5
5
|
export { Service } from "./executor-service.js";
|
package/dist/route/executor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cause, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
2
|
-
import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/
|
|
2
|
+
import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/http";
|
|
3
3
|
import { HttpContext, HttpRateLimitDetails, AIError, TransportError } from "../schema/index.js";
|
|
4
4
|
import { classifyProviderFailure, providerErrorMessage } from "../provider-error.js";
|
|
5
5
|
import { Service } from "./executor-service.js";
|
package/dist/route/framing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Stream } from "effect";
|
|
2
|
-
import { makeParser } from "effect/
|
|
2
|
+
import { makeParser } from "effect/encoding/Sse";
|
|
3
3
|
import { AIError, InvalidProviderOutputError } from "../schema/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Duration, Effect, Schema, type Stream } from "effect";
|
|
2
|
-
import { HttpClientResponse } from "effect/
|
|
2
|
+
import { HttpClientResponse } from "effect/http";
|
|
3
3
|
import type { Snapshot, Status } from "../generation.js";
|
|
4
4
|
import { Media } from "../media.js";
|
|
5
5
|
import type { AuthInput } from "./auth.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Clock, Duration, Effect, Schema } from "effect";
|
|
2
|
-
import { HttpClientResponse } from "effect/
|
|
2
|
+
import { HttpClientResponse } from "effect/http";
|
|
3
3
|
import { Media } from "../media.js";
|
|
4
4
|
import { AIError, AuthenticationError, ContentPolicyError, HttpContext, InvalidProviderOutputError, InvalidRequestError, ProviderID, ProviderInternalError, RateLimitError, UnsupportedOperationError, } from "../schema/index.js";
|
|
5
5
|
export const json = (value, query) => ({
|
package/dist/route/media.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Duration, Effect, Schedule, Schema, Stream } from "effect";
|
|
2
|
-
import { Headers, HttpClientRequest } from "effect/
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
3
|
import { Auth } from "./auth.js";
|
|
4
4
|
import { Endpoint } from "./endpoint.js";
|
|
5
5
|
import { RequestExecutorService } from "./executor-service.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { Headers, HttpClientRequest } from "effect/
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
3
|
import { Framing } from "../framing.js";
|
|
4
4
|
import type { HttpMiddleware, Transport, TransportPrepareInput } from "./index.js";
|
|
5
5
|
import { AIError } from "../../schema/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Clock, Duration, Effect, Stream } from "effect";
|
|
2
|
-
import { Headers, HttpClientRequest } from "effect/
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
3
|
import { Auth } from "../auth.js";
|
|
4
4
|
import { render as renderEndpoint } from "../endpoint.js";
|
|
5
5
|
import { Framing } from "../framing.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Effect, Scope, Stream } from "effect";
|
|
2
|
-
import type { Headers } from "effect/
|
|
2
|
+
import type { Headers } from "effect/http";
|
|
3
3
|
import type { AIError, HttpContext } from "../../schema/index.js";
|
|
4
4
|
export interface WebSocketChannelExecutor {
|
|
5
5
|
readonly execute: (exchange: WebSocketChannelExchange) => Effect.Effect<WebSocketChannelExecution, AIError, Scope.Scope>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Stream } from "effect";
|
|
2
|
-
import { Headers } from "effect/
|
|
3
|
-
import { Socket } from "effect/
|
|
2
|
+
import { Headers } from "effect/http";
|
|
3
|
+
import { Socket } from "effect/socket";
|
|
4
4
|
import { AIError, type HttpContext } from "../../schema/index.js";
|
|
5
5
|
import type { Transport } from "./index.js";
|
|
6
6
|
import type { WebSocketChannelExecutor } from "./websocket-channel.js";
|
|
@@ -19,7 +19,7 @@ export interface WebSocketConnector {
|
|
|
19
19
|
}
|
|
20
20
|
export declare const toWebSocketUrl: (value: string) => Effect.Effect<string, AIError, never>;
|
|
21
21
|
export declare const open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError, Socket.WebSocketConstructor>;
|
|
22
|
-
export declare const fromWebSocket: (ws:
|
|
22
|
+
export declare const fromWebSocket: (ws: Socket.WebSocketLike, input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError>;
|
|
23
23
|
export declare const messageText: (message: string | Uint8Array, decoder: TextDecoder) => string;
|
|
24
24
|
export declare const makeDirect: (connector: WebSocketConnector) => WebSocketChannelExecutor;
|
|
25
25
|
export declare const direct: Effect.Effect<WebSocketChannelExecutor, never, Socket.WebSocketConstructor>;
|
|
@@ -50,7 +50,7 @@ export declare const WebSocketTransport: {
|
|
|
50
50
|
readonly direct: Effect.Effect<WebSocketChannelExecutor, never, Socket.WebSocketConstructor>;
|
|
51
51
|
readonly makeDirect: (connector: WebSocketConnector) => WebSocketChannelExecutor;
|
|
52
52
|
readonly open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError, Socket.WebSocketConstructor>;
|
|
53
|
-
readonly fromWebSocket: (ws:
|
|
53
|
+
readonly fromWebSocket: (ws: Socket.WebSocketLike, input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError>;
|
|
54
54
|
readonly messageText: (message: string | Uint8Array, decoder: TextDecoder) => string;
|
|
55
55
|
readonly toWebSocketUrl: (value: string) => Effect.Effect<string, AIError, never>;
|
|
56
56
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cause, Effect, Queue, Stream } from "effect";
|
|
2
|
-
import { Headers } from "effect/
|
|
3
|
-
import { Socket } from "effect/
|
|
2
|
+
import { Headers } from "effect/http";
|
|
3
|
+
import { Socket } from "effect/socket";
|
|
4
4
|
import { AIError, AIErrorReason, TransportError, } from "../../schema/index.js";
|
|
5
5
|
import * as HttpTransport from "./http.js";
|
|
6
6
|
const MAX_FRAME_BYTES = 16 * 1024 * 1024;
|
|
@@ -31,7 +31,7 @@ const annotateTransportError = (error, input) => error.reason._tag === "Transpor
|
|
|
31
31
|
const eventMessage = (event) => {
|
|
32
32
|
if ("message" in event && typeof event.message === "string")
|
|
33
33
|
return event.message;
|
|
34
|
-
return event.type;
|
|
34
|
+
return event.type ?? "error";
|
|
35
35
|
};
|
|
36
36
|
const binaryMessage = (data) => {
|
|
37
37
|
if (data instanceof Uint8Array)
|
|
@@ -127,12 +127,7 @@ export const toWebSocketUrl = (value) => Effect.try({
|
|
|
127
127
|
export const open = (input) => Effect.gen(function* () {
|
|
128
128
|
const constructor = yield* Socket.WebSocketConstructor;
|
|
129
129
|
const ws = yield* Effect.try({
|
|
130
|
-
try: () =>
|
|
131
|
-
// Platform implementations may extend Effect's browser-compatible constructor with handshake options.
|
|
132
|
-
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion
|
|
133
|
-
constructor(input.url, {
|
|
134
|
-
headers: input.headers,
|
|
135
|
-
}),
|
|
130
|
+
try: () => constructor(input.url, { headers: input.headers }),
|
|
136
131
|
catch: (error) => transportError(error instanceof Error ? error.message : "Failed to construct WebSocket", {
|
|
137
132
|
cause: error,
|
|
138
133
|
url: input.url,
|
package/dist/schema/messages.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { withStatics } from "@opencode/schema/schema";
|
|
2
3
|
import { Tool } from "@opencode/schema/tool";
|
|
3
4
|
import { CacheHint, CachePolicy, GenerationOptions, HttpOptions, JsonSchema, LanguageModelSchema, ProviderMetadata, ProviderOptions, ReasoningEffort, } from "./options.js";
|
|
4
5
|
import { ProviderID } from "./ids.js";
|
|
@@ -11,7 +12,7 @@ const systemPartSchema = Schema.Struct({
|
|
|
11
12
|
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
12
13
|
}).annotate({ identifier: "LLM.SystemPart" });
|
|
13
14
|
const makeSystemPart = (text) => ({ type: "text", text });
|
|
14
|
-
export const SystemPart =
|
|
15
|
+
export const SystemPart = withStatics(systemPartSchema, {
|
|
15
16
|
make: makeSystemPart,
|
|
16
17
|
content: (input) => {
|
|
17
18
|
if (input === undefined)
|
|
@@ -53,7 +54,7 @@ const toolResultValueSchema = Schema.Union([
|
|
|
53
54
|
}),
|
|
54
55
|
]).annotate({ identifier: "LLM.ToolResult" });
|
|
55
56
|
const isToolResultValue = Schema.is(toolResultValueSchema);
|
|
56
|
-
export const ToolResultValue =
|
|
57
|
+
export const ToolResultValue = withStatics(toolResultValueSchema, {
|
|
57
58
|
is: isToolResultValue,
|
|
58
59
|
make: (value, type = "json") => {
|
|
59
60
|
if (isToolResultValue(value))
|
|
@@ -63,7 +64,7 @@ export const ToolResultValue = Object.assign(toolResultValueSchema, {
|
|
|
63
64
|
return { type, value };
|
|
64
65
|
},
|
|
65
66
|
});
|
|
66
|
-
export const ToolOutput =
|
|
67
|
+
export const ToolOutput = withStatics(Schema.Struct({
|
|
67
68
|
structured: Schema.Unknown,
|
|
68
69
|
content: Schema.Array(Tool.Content),
|
|
69
70
|
}).annotate({ identifier: "LLM.ToolOutput" }), {
|
|
@@ -98,7 +99,7 @@ const toolResultText = (value) => {
|
|
|
98
99
|
return String(value);
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
|
-
export const ToolCallPart =
|
|
102
|
+
export const ToolCallPart = withStatics(Schema.Struct({
|
|
102
103
|
type: Schema.Literal("tool-call"),
|
|
103
104
|
id: Schema.String,
|
|
104
105
|
name: Schema.String,
|
|
@@ -111,7 +112,7 @@ export const ToolCallPart = Object.assign(Schema.Struct({
|
|
|
111
112
|
}).annotate({ identifier: "LLM.Content.ToolCall" }), {
|
|
112
113
|
make: (input) => ({ type: "tool-call", ...input }),
|
|
113
114
|
});
|
|
114
|
-
export const ToolResultPart =
|
|
115
|
+
export const ToolResultPart = withStatics(Schema.Struct({
|
|
115
116
|
type: Schema.Literal("tool-result"),
|
|
116
117
|
id: Schema.String,
|
|
117
118
|
name: Schema.String,
|
|
@@ -152,7 +153,7 @@ const compactionPartSchema = Schema.Struct({
|
|
|
152
153
|
})
|
|
153
154
|
.pipe(Schema.refine((part) => (part.encrypted !== undefined) !== (part.text !== undefined), { message: "Compaction requires either encrypted content or a summary" }))
|
|
154
155
|
.annotate({ identifier: "LLM.Content.Compaction" });
|
|
155
|
-
export const CompactionPart =
|
|
156
|
+
export const CompactionPart = withStatics(compactionPartSchema, {
|
|
156
157
|
make: (input) => Schema.decodeUnknownSync(compactionPartSchema)({ type: "compaction", ...input }),
|
|
157
158
|
});
|
|
158
159
|
/** Reasoning effort changed here, from `previous` to `effort`; `undefined` is the model default. */
|
|
@@ -225,7 +226,7 @@ export class ToolDefinition extends Schema.Class("LLM.ToolDefinition")({
|
|
|
225
226
|
/** Normalize tool definition input into the canonical `ToolDefinition` class. */
|
|
226
227
|
ToolDefinition.make = (input) => (input instanceof ToolDefinition ? input : new ToolDefinition(input));
|
|
227
228
|
})(ToolDefinition || (ToolDefinition = {}));
|
|
228
|
-
export const ToolNamespace =
|
|
229
|
+
export const ToolNamespace = withStatics(Schema.Struct({
|
|
229
230
|
type: Schema.Literal("namespace"),
|
|
230
231
|
name: Schema.String,
|
|
231
232
|
description: Schema.optional(Schema.UndefinedOr(Schema.String)),
|
|
@@ -237,7 +238,7 @@ export const ToolNamespace = Object.assign(Schema.Struct({
|
|
|
237
238
|
tools: input.tools.map(ToolEntry.make),
|
|
238
239
|
}),
|
|
239
240
|
});
|
|
240
|
-
export const ToolEntry =
|
|
241
|
+
export const ToolEntry = withStatics(Schema.Union([ToolDefinition, ToolNamespace]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "LLM.ToolEntry" })), {
|
|
241
242
|
make: (input) => "type" in input && input.type === "namespace" ? ToolNamespace.make(input) : ToolDefinition.make(input),
|
|
242
243
|
});
|
|
243
244
|
export class ToolChoice extends Schema.Class("LLM.ToolChoice")({
|
package/dist/tool.d.ts
CHANGED
|
@@ -132,5 +132,15 @@ export type Tools = Record<string, AnyTool>;
|
|
|
132
132
|
* is reused.
|
|
133
133
|
*/
|
|
134
134
|
export declare const toDefinitions: (tools: Tools) => ReadonlyArray<ToolDefinitionClass>;
|
|
135
|
+
/**
|
|
136
|
+
* Describes a no-argument Effect tool input as an empty object, or returns
|
|
137
|
+
* `undefined` when the input takes arguments.
|
|
138
|
+
*
|
|
139
|
+
* Effect emits `{ not: { type: "null" } }` only for an encoded struct with no
|
|
140
|
+
* properties or index signatures, but providers require tool parameters to
|
|
141
|
+
* describe an object. Annotations are kept; any other keyword, such as a
|
|
142
|
+
* check's `minProperties`, leaves the schema as Effect emitted it.
|
|
143
|
+
*/
|
|
144
|
+
export declare const emptyInputJsonSchema: (schema: Schema.Top) => JsonSchema.JsonSchema | undefined;
|
|
135
145
|
export { ToolFailure };
|
|
136
146
|
export * as Tool from "./tool.js";
|
package/dist/tool.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect, JsonSchema, Schema } from "effect";
|
|
2
2
|
import { Tool } from "@opencode/schema/tool";
|
|
3
3
|
import { ToolDefinition, ToolFailure, ToolOutput } from "./schema/index.js";
|
|
4
|
+
import { isRecord } from "./utils/record.js";
|
|
4
5
|
export function make(config) {
|
|
5
6
|
if ("jsonSchema" in config) {
|
|
6
7
|
return {
|
|
@@ -36,7 +37,7 @@ export function make(config) {
|
|
|
36
37
|
_definition: new ToolDefinition({
|
|
37
38
|
name: "",
|
|
38
39
|
description: config.description,
|
|
39
|
-
inputSchema: toJsonSchema(config.parameters),
|
|
40
|
+
inputSchema: emptyInputJsonSchema(config.parameters) ?? toJsonSchema(config.parameters),
|
|
40
41
|
outputSchema: toJsonSchema(config.success),
|
|
41
42
|
}),
|
|
42
43
|
};
|
|
@@ -55,8 +56,26 @@ export const toDefinitions = (tools) => Object.entries(tools).map(([name, item])
|
|
|
55
56
|
inputSchema: item._definition.inputSchema,
|
|
56
57
|
outputSchema: item._definition.outputSchema,
|
|
57
58
|
}));
|
|
59
|
+
/**
|
|
60
|
+
* Describes a no-argument Effect tool input as an empty object, or returns
|
|
61
|
+
* `undefined` when the input takes arguments.
|
|
62
|
+
*
|
|
63
|
+
* Effect emits `{ not: { type: "null" } }` only for an encoded struct with no
|
|
64
|
+
* properties or index signatures, but providers require tool parameters to
|
|
65
|
+
* describe an object. Annotations are kept; any other keyword, such as a
|
|
66
|
+
* check's `minProperties`, leaves the schema as Effect emitted it.
|
|
67
|
+
*/
|
|
68
|
+
export const emptyInputJsonSchema = (schema) => {
|
|
69
|
+
const { not, ...rest } = Schema.toJsonSchemaDocument(schema, { referencePolicy: () => undefined }).schema;
|
|
70
|
+
if (!isRecord(not) || not.type !== "null" || Object.keys(not).length !== 1)
|
|
71
|
+
return undefined;
|
|
72
|
+
if (!Object.keys(rest).every((key) => annotationKeywords.has(key)))
|
|
73
|
+
return undefined;
|
|
74
|
+
return { ...rest, type: "object", properties: {}, additionalProperties: false };
|
|
75
|
+
};
|
|
76
|
+
const annotationKeywords = new Set(["title", "description", "default", "examples", "readOnly", "writeOnly"]);
|
|
58
77
|
const toJsonSchema = (schema) => {
|
|
59
|
-
const document = Schema.toJsonSchemaDocument(schema);
|
|
78
|
+
const document = Schema.toJsonSchemaDocument(schema, { onExcessProperty: "error" });
|
|
60
79
|
if (Object.keys(document.definitions).length === 0)
|
|
61
80
|
return document.schema;
|
|
62
81
|
return { ...document.schema, $defs: document.definitions };
|
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-20784",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
36
|
-
"@effect/platform-node": "4.0.0-rc.
|
|
37
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
36
|
+
"@effect/platform-node": "4.0.0-rc.118",
|
|
37
|
+
"@opencode/http-recorder": "0.0.0-dev-20784",
|
|
38
38
|
"@tsconfig/bun": "1.0.9",
|
|
39
39
|
"@types/bun": "1.4.0",
|
|
40
40
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
45
45
|
"@smithy/eventstream-codec": "4.2.14",
|
|
46
46
|
"@smithy/util-utf8": "4.2.2",
|
|
47
|
-
"@opencode/schema": "0.0.0-dev-
|
|
47
|
+
"@opencode/schema": "0.0.0-dev-20784",
|
|
48
48
|
"aws4fetch": "1.0.20",
|
|
49
|
-
"effect": "4.0.0-rc.
|
|
49
|
+
"effect": "4.0.0-rc.118",
|
|
50
50
|
"google-auth-library": "10.5.0"
|
|
51
51
|
}
|
|
52
52
|
}
|