@opencode-ai/ai 0.0.0-next-16255 → 0.0.0-next-16274
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/llm.d.ts +60 -60
- package/dist/protocols/anthropic-messages.d.ts +303 -303
- package/dist/protocols/anthropic-messages.js +1 -0
- package/dist/protocols/bedrock-converse.d.ts +246 -242
- package/dist/protocols/gemini.d.ts +136 -132
- package/dist/protocols/gemini.js +1 -0
- package/dist/protocols/open-responses.d.ts +232 -232
- package/dist/protocols/openai-chat.d.ts +147 -141
- package/dist/protocols/openai-chat.js +1 -0
- package/dist/protocols/openai-compatible-chat.d.ts +48 -46
- package/dist/protocols/openai-compatible-responses.d.ts +56 -56
- package/dist/protocols/openai-responses.d.ts +388 -388
- package/dist/protocols/shared.d.ts +5 -4
- package/dist/protocols/shared.js +1 -0
- package/dist/protocols/utils/bedrock-media.d.ts +10 -10
- package/dist/protocols/utils/tool-stream.d.ts +180 -180
- package/dist/providers/amazon-bedrock.d.ts +109 -107
- package/dist/providers/anthropic-compatible.d.ts +145 -145
- package/dist/providers/anthropic.d.ts +145 -145
- package/dist/providers/azure.d.ts +112 -110
- package/dist/providers/cloudflare.d.ts +144 -138
- package/dist/providers/github-copilot.d.ts +112 -110
- package/dist/providers/google-vertex-chat.d.ts +48 -46
- package/dist/providers/google-vertex-messages.d.ts +145 -146
- package/dist/providers/google-vertex-responses.d.ts +56 -56
- package/dist/providers/google-vertex.d.ts +52 -50
- package/dist/providers/google.d.ts +52 -50
- package/dist/providers/openai-compatible-responses.d.ts +56 -56
- package/dist/providers/openai-compatible.d.ts +48 -46
- package/dist/providers/openai.d.ts +176 -174
- package/dist/providers/openrouter.d.ts +147 -141
- package/dist/providers/xai.d.ts +112 -110
- package/dist/route/client.d.ts +60 -60
- package/dist/schema/errors.d.ts +2 -6
- package/dist/schema/errors.js +2 -5
- package/dist/schema/events.d.ts +1117 -1115
- package/dist/schema/messages.d.ts +9 -9
- package/dist/schema/messages.js +3 -4
- package/dist/tool-runtime.js +1 -1
- package/dist/tool.d.ts +5 -4
- package/dist/tool.js +1 -0
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { Tool } from "@opencode-ai/schema/tool";
|
|
3
3
|
import { CacheHint, GenerationOptions, HttpOptions } from "./options";
|
|
4
4
|
declare const systemPartSchema: Schema.Struct<{
|
|
5
5
|
readonly type: Schema.Literal<"text">;
|
|
@@ -33,7 +33,6 @@ export declare const MediaPart: Schema.Struct<{
|
|
|
33
33
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
34
34
|
}>;
|
|
35
35
|
export type MediaPart = Schema.Schema.Type<typeof MediaPart>;
|
|
36
|
-
export { ToolContent, ToolFileContent, ToolTextContent };
|
|
37
36
|
export declare const ToolResultValue: Schema.Union<readonly [Schema.Struct<{
|
|
38
37
|
readonly type: Schema.Literal<"json">;
|
|
39
38
|
readonly value: Schema.Unknown;
|
|
@@ -52,7 +51,7 @@ export declare const ToolResultValue: Schema.Union<readonly [Schema.Struct<{
|
|
|
52
51
|
readonly type: Schema.Literal<"file">;
|
|
53
52
|
readonly uri: Schema.String;
|
|
54
53
|
readonly mime: Schema.String;
|
|
55
|
-
readonly name: Schema.
|
|
54
|
+
readonly name: Schema.optional<Schema.String>;
|
|
56
55
|
}>]>>;
|
|
57
56
|
}>]> & {
|
|
58
57
|
is: (value: unknown) => value is ToolResultValue;
|
|
@@ -61,7 +60,7 @@ export declare const ToolResultValue: Schema.Union<readonly [Schema.Struct<{
|
|
|
61
60
|
export type ToolResultValue = Schema.Schema.Type<typeof ToolResultValue>;
|
|
62
61
|
export interface ToolOutput {
|
|
63
62
|
readonly structured: unknown;
|
|
64
|
-
readonly content: ReadonlyArray<
|
|
63
|
+
readonly content: ReadonlyArray<Tool.Content>;
|
|
65
64
|
}
|
|
66
65
|
export declare const ToolOutput: Schema.Struct<{
|
|
67
66
|
readonly structured: Schema.Unknown;
|
|
@@ -72,10 +71,10 @@ export declare const ToolOutput: Schema.Struct<{
|
|
|
72
71
|
readonly type: Schema.Literal<"file">;
|
|
73
72
|
readonly uri: Schema.String;
|
|
74
73
|
readonly mime: Schema.String;
|
|
75
|
-
readonly name: Schema.
|
|
74
|
+
readonly name: Schema.optional<Schema.String>;
|
|
76
75
|
}>]>>;
|
|
77
76
|
}> & {
|
|
78
|
-
make: (structured: unknown, content?: ReadonlyArray<
|
|
77
|
+
make: (structured: unknown, content?: ReadonlyArray<Tool.Content>) => ToolOutput;
|
|
79
78
|
fromResultValue: (result: ToolResultValue) => ToolOutput | undefined;
|
|
80
79
|
toResultValue: (output: ToolOutput) => ToolResultValue;
|
|
81
80
|
};
|
|
@@ -113,7 +112,7 @@ export declare const ToolResultPart: Schema.Struct<{
|
|
|
113
112
|
readonly type: Schema.Literal<"file">;
|
|
114
113
|
readonly uri: Schema.String;
|
|
115
114
|
readonly mime: Schema.String;
|
|
116
|
-
readonly name: Schema.
|
|
115
|
+
readonly name: Schema.optional<Schema.String>;
|
|
117
116
|
}>]>>;
|
|
118
117
|
}>]> & {
|
|
119
118
|
is: (value: unknown) => value is ToolResultValue;
|
|
@@ -182,7 +181,7 @@ export declare const ContentPart: Schema.toTaggedUnion<"type", readonly [Schema.
|
|
|
182
181
|
readonly type: Schema.Literal<"file">;
|
|
183
182
|
readonly uri: Schema.String;
|
|
184
183
|
readonly mime: Schema.String;
|
|
185
|
-
readonly name: Schema.
|
|
184
|
+
readonly name: Schema.optional<Schema.String>;
|
|
186
185
|
}>]>>;
|
|
187
186
|
}>]> & {
|
|
188
187
|
is: (value: unknown) => value is ToolResultValue;
|
|
@@ -252,7 +251,7 @@ declare const Message_base: Schema.Class<Message, Schema.Struct<{
|
|
|
252
251
|
readonly type: Schema.Literal<"file">;
|
|
253
252
|
readonly uri: Schema.String;
|
|
254
253
|
readonly mime: Schema.String;
|
|
255
|
-
readonly name: Schema.
|
|
254
|
+
readonly name: Schema.optional<Schema.String>;
|
|
256
255
|
}>]>>;
|
|
257
256
|
}>]> & {
|
|
258
257
|
is: (value: unknown) => value is ToolResultValue;
|
|
@@ -364,3 +363,4 @@ export declare namespace LLMRequest {
|
|
|
364
363
|
const input: (request: LLMRequest) => Input;
|
|
365
364
|
const update: (request: LLMRequest, patch: Partial<Input>) => LLMRequest;
|
|
366
365
|
}
|
|
366
|
+
export {};
|
package/dist/schema/messages.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { Tool } from "@opencode-ai/schema/tool";
|
|
3
3
|
import { JsonSchema, MessageRole, ProviderMetadata } from "./ids";
|
|
4
4
|
import { CacheHint, CachePolicy, GenerationOptions, HttpOptions, ModelSchema, ProviderOptions } from "./options";
|
|
5
5
|
import { isRecord } from "../utils/record";
|
|
@@ -32,7 +32,6 @@ export const MediaPart = Schema.Struct({
|
|
|
32
32
|
filename: Schema.optional(Schema.String),
|
|
33
33
|
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
34
34
|
}).annotate({ identifier: "LLM.Content.Media" });
|
|
35
|
-
export { ToolContent, ToolFileContent, ToolTextContent };
|
|
36
35
|
const isToolResultValue = (value) => isRecord(value) &&
|
|
37
36
|
(value.type === "text" || value.type === "json" || value.type === "error" || value.type === "content") &&
|
|
38
37
|
"value" in value;
|
|
@@ -51,7 +50,7 @@ export const ToolResultValue = Object.assign(Schema.Union([
|
|
|
51
50
|
}),
|
|
52
51
|
Schema.Struct({
|
|
53
52
|
type: Schema.Literal("content"),
|
|
54
|
-
value: Schema.Array(
|
|
53
|
+
value: Schema.Array(Tool.Content),
|
|
55
54
|
}),
|
|
56
55
|
]).annotate({ identifier: "LLM.ToolResult" }), {
|
|
57
56
|
is: isToolResultValue,
|
|
@@ -65,7 +64,7 @@ export const ToolResultValue = Object.assign(Schema.Union([
|
|
|
65
64
|
});
|
|
66
65
|
export const ToolOutput = Object.assign(Schema.Struct({
|
|
67
66
|
structured: Schema.Unknown,
|
|
68
|
-
content: Schema.Array(
|
|
67
|
+
content: Schema.Array(Tool.Content),
|
|
69
68
|
}).annotate({ identifier: "LLM.ToolOutput" }), {
|
|
70
69
|
make: (structured, content = []) => ({ structured, content }),
|
|
71
70
|
fromResultValue: (result) => {
|
package/dist/tool-runtime.js
CHANGED
|
@@ -8,7 +8,7 @@ export const dispatch = (tools, call) => {
|
|
|
8
8
|
return Effect.succeed(result(call, { type: "error", value: `Unknown tool: ${call.name}` }));
|
|
9
9
|
if (!tool.execute)
|
|
10
10
|
return Effect.succeed(result(call, { type: "error", value: `Tool has no execute handler: ${call.name}` }));
|
|
11
|
-
return decodeAndExecute(tool, call).pipe(Effect.map((value) => result(call, value)), Effect.catchTag("
|
|
11
|
+
return decodeAndExecute(tool, call).pipe(Effect.map((value) => result(call, value)), Effect.catchTag("Tool.Error", (failure) => Effect.succeed(result(call, { type: "error", value: failure.message }, failure.error))));
|
|
12
12
|
};
|
|
13
13
|
const decodeAndExecute = (tool, call) => tool._decode(call.input).pipe(Effect.mapError((error) => new ToolFailure({ message: `Invalid tool input: ${error.message}` })), Effect.flatMap((decoded) => tool.execute(decoded, { id: call.id, name: call.name }).pipe(Effect.flatMap((value) => tool._encode(value).pipe(Effect.mapError((error) => new ToolFailure({
|
|
14
14
|
message: `Tool returned an invalid value for its success schema: ${error.message}`,
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect, JsonSchema, Schema } from "effect";
|
|
2
|
-
import
|
|
2
|
+
import { Tool } from "@opencode-ai/schema/tool";
|
|
3
|
+
import type { ToolCallPart, ToolDefinition as ToolDefinitionClass, ToolOutput as ToolOutputType } from "./schema";
|
|
3
4
|
import { ToolFailure } from "./schema";
|
|
4
5
|
/**
|
|
5
6
|
* Schema constraint for tool parameters / success values: no decoding or
|
|
@@ -17,7 +18,7 @@ export interface ToolModelOutputInput<Parameters, Output> {
|
|
|
17
18
|
readonly parameters: Parameters;
|
|
18
19
|
readonly output: Output;
|
|
19
20
|
}
|
|
20
|
-
export type ToolToModelOutput<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>> = (input: ToolModelOutputInput<Schema.Schema.Type<Parameters>, Success["Encoded"]>) => ReadonlyArray<
|
|
21
|
+
export type ToolToModelOutput<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>> = (input: ToolModelOutputInput<Schema.Schema.Type<Parameters>, Success["Encoded"]>) => ReadonlyArray<Tool.Content>;
|
|
21
22
|
/**
|
|
22
23
|
* A type-safe LLM tool. Each tool bundles its own description, parameter
|
|
23
24
|
* Schema and success Schema. The execute handler is optional: omit it when you
|
|
@@ -106,7 +107,7 @@ export declare function make(config: {
|
|
|
106
107
|
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
107
108
|
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
108
109
|
readonly execute: (params: unknown, context?: ToolExecuteContext) => Effect.Effect<unknown, ToolFailure>;
|
|
109
|
-
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<
|
|
110
|
+
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<Tool.Content>;
|
|
110
111
|
readonly toStructuredOutput?: (output: unknown) => unknown;
|
|
111
112
|
}): AnyExecutableTool;
|
|
112
113
|
export declare function make(config: {
|
|
@@ -114,7 +115,7 @@ export declare function make(config: {
|
|
|
114
115
|
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
115
116
|
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
116
117
|
readonly execute?: undefined;
|
|
117
|
-
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<
|
|
118
|
+
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<Tool.Content>;
|
|
118
119
|
readonly toStructuredOutput?: (output: unknown) => unknown;
|
|
119
120
|
}): AnyTool;
|
|
120
121
|
/**
|
package/dist/tool.js
CHANGED
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-16274",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
28
|
-
"@effect/platform-node": "4.0.0-beta.
|
|
29
|
-
"@opencode-ai/http-recorder": "0.0.0-next-
|
|
28
|
+
"@effect/platform-node": "4.0.0-beta.101",
|
|
29
|
+
"@opencode-ai/http-recorder": "0.0.0-next-16274",
|
|
30
30
|
"@tsconfig/bun": "1.0.9",
|
|
31
31
|
"@types/bun": "1.3.13",
|
|
32
32
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@smithy/eventstream-codec": "4.2.14",
|
|
37
37
|
"@smithy/util-utf8": "4.2.2",
|
|
38
|
-
"@opencode-ai/schema": "0.0.0-next-
|
|
38
|
+
"@opencode-ai/schema": "0.0.0-next-16274",
|
|
39
39
|
"aws4fetch": "1.0.20",
|
|
40
|
-
"effect": "4.0.0-beta.
|
|
40
|
+
"effect": "4.0.0-beta.101",
|
|
41
41
|
"google-auth-library": "10.5.0"
|
|
42
42
|
}
|
|
43
43
|
}
|