@opencode-ai/ai 0.0.0-bootstrap.0 → 0.0.0-next-15617
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 +176 -1
- package/dist/cache-policy.d.ts +2 -0
- package/dist/cache-policy.js +108 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +9 -0
- package/dist/llm.d.ts +223 -0
- package/dist/llm.js +81 -0
- package/dist/protocols/anthropic-messages.d.ts +503 -0
- package/dist/protocols/anthropic-messages.js +745 -0
- package/dist/protocols/bedrock-converse.d.ts +476 -0
- package/dist/protocols/bedrock-converse.js +526 -0
- package/dist/protocols/bedrock-event-stream.d.ts +9 -0
- package/dist/protocols/bedrock-event-stream.js +64 -0
- package/dist/protocols/gemini.d.ts +220 -0
- package/dist/protocols/gemini.js +420 -0
- package/dist/protocols/google-vertex-anthropic.d.ts +494 -0
- package/dist/protocols/google-vertex-anthropic.js +33 -0
- package/dist/protocols/google-vertex-gemini.d.ts +59 -0
- package/dist/protocols/google-vertex-gemini.js +18 -0
- package/dist/protocols/index.d.ts +9 -0
- package/dist/protocols/index.js +9 -0
- package/dist/protocols/openai-chat.d.ts +391 -0
- package/dist/protocols/openai-chat.js +423 -0
- package/dist/protocols/openai-compatible-chat.d.ts +73 -0
- package/dist/protocols/openai-compatible-chat.js +20 -0
- package/dist/protocols/openai-compatible-responses.d.ts +85 -0
- package/dist/protocols/openai-compatible-responses.js +18 -0
- package/dist/protocols/openai-responses.d.ts +613 -0
- package/dist/protocols/openai-responses.js +828 -0
- package/dist/protocols/shared.d.ts +192 -0
- package/dist/protocols/shared.js +236 -0
- package/dist/protocols/utils/bedrock-auth.d.ts +18 -0
- package/dist/protocols/utils/bedrock-auth.js +41 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +15 -0
- package/dist/protocols/utils/bedrock-cache.js +29 -0
- package/dist/protocols/utils/bedrock-media.d.ts +49 -0
- package/dist/protocols/utils/bedrock-media.js +68 -0
- package/dist/protocols/utils/cache.d.ts +6 -0
- package/dist/protocols/utils/cache.js +8 -0
- package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
- package/dist/protocols/utils/gemini-tool-schema.js +83 -0
- package/dist/protocols/utils/lifecycle.d.ts +19 -0
- package/dist/protocols/utils/lifecycle.js +65 -0
- package/dist/protocols/utils/openai-options.d.ts +22 -0
- package/dist/protocols/utils/openai-options.js +64 -0
- package/dist/protocols/utils/tool-schema.d.ts +7 -0
- package/dist/protocols/utils/tool-schema.js +79 -0
- package/dist/protocols/utils/tool-stream.d.ts +155 -0
- package/dist/protocols/utils/tool-stream.js +136 -0
- package/dist/protocols.d.ts +1 -0
- package/dist/protocols.js +1 -0
- package/dist/provider-error.d.ts +13 -0
- package/dist/provider-error.js +122 -0
- package/dist/provider-package.d.ts +13 -0
- package/dist/provider-package.js +1 -0
- package/dist/provider.d.ts +23 -0
- package/dist/provider.js +2 -0
- package/dist/providers/amazon-bedrock.d.ts +150 -0
- package/dist/providers/amazon-bedrock.js +41 -0
- package/dist/providers/anthropic-compatible.d.ts +183 -0
- package/dist/providers/anthropic-compatible.js +44 -0
- package/dist/providers/anthropic.d.ts +181 -0
- package/dist/providers/anthropic.js +39 -0
- package/dist/providers/azure/chat.d.ts +2 -0
- package/dist/providers/azure/chat.js +1 -0
- package/dist/providers/azure/responses.d.ts +2 -0
- package/dist/providers/azure/responses.js +1 -0
- package/dist/providers/azure.d.ts +183 -0
- package/dist/providers/azure.js +89 -0
- package/dist/providers/cloudflare.d.ts +232 -0
- package/dist/providers/cloudflare.js +87 -0
- package/dist/providers/github-copilot.d.ts +167 -0
- package/dist/providers/github-copilot.js +47 -0
- package/dist/providers/google-vertex/anthropic.d.ts +2 -0
- package/dist/providers/google-vertex/anthropic.js +1 -0
- package/dist/providers/google-vertex-anthropic.d.ts +181 -0
- package/dist/providers/google-vertex-anthropic.js +46 -0
- package/dist/providers/google-vertex-shared.d.ts +22 -0
- package/dist/providers/google-vertex-shared.js +61 -0
- package/dist/providers/google-vertex.d.ts +93 -0
- package/dist/providers/google-vertex.js +49 -0
- package/dist/providers/google.d.ts +85 -0
- package/dist/providers/google.js +33 -0
- package/dist/providers/index.d.ts +15 -0
- package/dist/providers/index.js +15 -0
- package/dist/providers/openai/chat.d.ts +2 -0
- package/dist/providers/openai/chat.js +1 -0
- package/dist/providers/openai/responses.d.ts +2 -0
- package/dist/providers/openai/responses.js +1 -0
- package/dist/providers/openai-compatible/responses.d.ts +1 -0
- package/dist/providers/openai-compatible/responses.js +1 -0
- package/dist/providers/openai-compatible-profile.d.ts +43 -0
- package/dist/providers/openai-compatible-profile.js +12 -0
- package/dist/providers/openai-compatible-responses.d.ts +107 -0
- package/dist/providers/openai-compatible-responses.js +33 -0
- package/dist/providers/openai-compatible.d.ts +130 -0
- package/dist/providers/openai-compatible.js +55 -0
- package/dist/providers/openai-options.d.ts +30 -0
- package/dist/providers/openai-options.js +42 -0
- package/dist/providers/openai.d.ts +264 -0
- package/dist/providers/openai.js +62 -0
- package/dist/providers/openrouter.d.ts +321 -0
- package/dist/providers/openrouter.js +65 -0
- package/dist/providers/xai.d.ts +169 -0
- package/dist/providers/xai.js +43 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1 -0
- package/dist/route/auth-options.d.ts +34 -0
- package/dist/route/auth-options.js +14 -0
- package/dist/route/auth.d.ts +49 -0
- package/dist/route/auth.js +89 -0
- package/dist/route/client.d.ts +330 -0
- package/dist/route/client.js +211 -0
- package/dist/route/endpoint.d.ts +28 -0
- package/dist/route/endpoint.js +21 -0
- package/dist/route/executor.d.ts +12 -0
- package/dist/route/executor.js +229 -0
- package/dist/route/framing.d.ts +23 -0
- package/dist/route/framing.js +4 -0
- package/dist/route/index.d.ts +16 -0
- package/dist/route/index.js +9 -0
- package/dist/route/protocol.d.ts +76 -0
- package/dist/route/protocol.js +17 -0
- package/dist/route/transport/http.d.ts +33 -0
- package/dist/route/transport/http.js +98 -0
- package/dist/route/transport/index.d.ts +27 -0
- package/dist/route/transport/index.js +4 -0
- package/dist/route/transport/websocket.d.ts +56 -0
- package/dist/route/transport/websocket.js +181 -0
- package/dist/route.d.ts +1 -0
- package/dist/route.js +1 -0
- package/dist/schema/errors.d.ts +153 -0
- package/dist/schema/errors.js +150 -0
- package/dist/schema/events.d.ts +4292 -0
- package/dist/schema/events.js +482 -0
- package/dist/schema/ids.d.ts +30 -0
- package/dist/schema/ids.js +18 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/messages.d.ts +385 -0
- package/dist/schema/messages.js +246 -0
- package/dist/schema/options.d.ts +143 -0
- package/dist/schema/options.js +195 -0
- package/dist/tool-runtime.d.ts +15 -0
- package/dist/tool-runtime.js +35 -0
- package/dist/tool.d.ts +134 -0
- package/dist/tool.js +66 -0
- package/dist/utils/record.d.ts +2 -0
- package/dist/utils/record.js +2 -0
- package/package.json +36 -9
- package/index.js +0 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { ModelID, ProviderID } from "./ids";
|
|
3
|
+
import type { AnyRoute } from "../route/client";
|
|
4
|
+
export declare const mergeJsonRecords: (...items: ReadonlyArray<Record<string, unknown> | undefined>) => Record<string, unknown> | undefined;
|
|
5
|
+
export declare const ProviderOptions: Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
6
|
+
export type ProviderOptions = Schema.Schema.Type<typeof ProviderOptions>;
|
|
7
|
+
export declare const mergeProviderOptions: (...items: ReadonlyArray<ProviderOptions | undefined>) => ProviderOptions | undefined;
|
|
8
|
+
declare const HttpOptions_base: Schema.Class<HttpOptions, Schema.Struct<{
|
|
9
|
+
readonly body: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
10
|
+
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
11
|
+
readonly query: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
12
|
+
}>, {}>;
|
|
13
|
+
export declare class HttpOptions extends HttpOptions_base {
|
|
14
|
+
}
|
|
15
|
+
export declare namespace HttpOptions {
|
|
16
|
+
type Input = HttpOptions | ConstructorParameters<typeof HttpOptions>[0];
|
|
17
|
+
/** Normalize HTTP option input into the canonical `HttpOptions` class. */
|
|
18
|
+
const make: (input: Input) => HttpOptions;
|
|
19
|
+
}
|
|
20
|
+
export declare const mergeHttpOptions: (...items: ReadonlyArray<HttpOptions | undefined>) => HttpOptions | undefined;
|
|
21
|
+
declare const GenerationOptions_base: Schema.Class<GenerationOptions, Schema.Struct<{
|
|
22
|
+
readonly maxTokens: Schema.optional<Schema.Number>;
|
|
23
|
+
readonly temperature: Schema.optional<Schema.Number>;
|
|
24
|
+
readonly topP: Schema.optional<Schema.Number>;
|
|
25
|
+
readonly topK: Schema.optional<Schema.Number>;
|
|
26
|
+
readonly frequencyPenalty: Schema.optional<Schema.Number>;
|
|
27
|
+
readonly presencePenalty: Schema.optional<Schema.Number>;
|
|
28
|
+
readonly seed: Schema.optional<Schema.Number>;
|
|
29
|
+
readonly stop: Schema.optional<Schema.$Array<Schema.String>>;
|
|
30
|
+
}>, {}>;
|
|
31
|
+
export declare class GenerationOptions extends GenerationOptions_base {
|
|
32
|
+
}
|
|
33
|
+
export declare namespace GenerationOptions {
|
|
34
|
+
type Input = GenerationOptions | ConstructorParameters<typeof GenerationOptions>[0];
|
|
35
|
+
/** Normalize generation option input into the canonical `GenerationOptions` class. */
|
|
36
|
+
const make: (input?: Input) => GenerationOptions;
|
|
37
|
+
}
|
|
38
|
+
export type GenerationOptionsFields = {
|
|
39
|
+
readonly maxTokens?: number;
|
|
40
|
+
readonly temperature?: number;
|
|
41
|
+
readonly topP?: number;
|
|
42
|
+
readonly topK?: number;
|
|
43
|
+
readonly frequencyPenalty?: number;
|
|
44
|
+
readonly presencePenalty?: number;
|
|
45
|
+
readonly seed?: number;
|
|
46
|
+
readonly stop?: ReadonlyArray<string>;
|
|
47
|
+
};
|
|
48
|
+
export type GenerationOptionsInput = GenerationOptions | GenerationOptionsFields;
|
|
49
|
+
export declare const mergeGenerationOptions: (...items: ReadonlyArray<GenerationOptionsInput | undefined>) => GenerationOptions | undefined;
|
|
50
|
+
declare const ModelLimits_base: Schema.Class<ModelLimits, Schema.Struct<{
|
|
51
|
+
readonly context: Schema.optional<Schema.Number>;
|
|
52
|
+
readonly output: Schema.optional<Schema.Number>;
|
|
53
|
+
}>, {}>;
|
|
54
|
+
export declare class ModelLimits extends ModelLimits_base {
|
|
55
|
+
}
|
|
56
|
+
export declare namespace ModelLimits {
|
|
57
|
+
type Input = ModelLimits | ConstructorParameters<typeof ModelLimits>[0];
|
|
58
|
+
/** Normalize model limit input into the canonical `ModelLimits` class. */
|
|
59
|
+
const make: (input: Input | undefined) => ModelLimits;
|
|
60
|
+
}
|
|
61
|
+
declare const ModelDefaults_base: Schema.Class<ModelDefaults, Schema.Struct<{
|
|
62
|
+
readonly limits: Schema.optional<typeof ModelLimits>;
|
|
63
|
+
readonly generation: Schema.optional<typeof GenerationOptions>;
|
|
64
|
+
readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
65
|
+
readonly http: Schema.optional<typeof HttpOptions>;
|
|
66
|
+
}>, {}>;
|
|
67
|
+
export declare class ModelDefaults extends ModelDefaults_base {
|
|
68
|
+
}
|
|
69
|
+
export declare namespace ModelDefaults {
|
|
70
|
+
type Input = ModelDefaults | {
|
|
71
|
+
readonly limits?: ModelLimits.Input;
|
|
72
|
+
readonly generation?: GenerationOptions.Input;
|
|
73
|
+
readonly providerOptions?: ProviderOptions;
|
|
74
|
+
readonly http?: HttpOptions.Input;
|
|
75
|
+
};
|
|
76
|
+
/** Normalize selected-model request defaults without applying precedence. */
|
|
77
|
+
const make: (input: Input) => ModelDefaults;
|
|
78
|
+
}
|
|
79
|
+
export declare const ModelToolSchemaCompatibility: Schema.Literals<readonly ["gemini", "moonshot"]>;
|
|
80
|
+
export type ModelToolSchemaCompatibility = Schema.Schema.Type<typeof ModelToolSchemaCompatibility>;
|
|
81
|
+
declare const ModelCompatibility_base: Schema.Class<ModelCompatibility, Schema.Struct<{
|
|
82
|
+
readonly toolSchema: Schema.optional<Schema.Literals<readonly ["gemini", "moonshot"]>>;
|
|
83
|
+
}>, {}>;
|
|
84
|
+
export declare class ModelCompatibility extends ModelCompatibility_base {
|
|
85
|
+
}
|
|
86
|
+
export declare namespace ModelCompatibility {
|
|
87
|
+
type Input = ModelCompatibility | ConstructorParameters<typeof ModelCompatibility>[0];
|
|
88
|
+
/** Normalize model/upstream compatibility metadata without projecting requests. */
|
|
89
|
+
const make: (input: Input) => ModelCompatibility;
|
|
90
|
+
}
|
|
91
|
+
export declare class Model {
|
|
92
|
+
readonly id: ModelID;
|
|
93
|
+
readonly provider: ProviderID;
|
|
94
|
+
readonly route: AnyRoute;
|
|
95
|
+
readonly defaults?: ModelDefaults;
|
|
96
|
+
readonly compatibility?: ModelCompatibility;
|
|
97
|
+
constructor(input: Model.ConstructorInput);
|
|
98
|
+
static make(input: Model.Input): Model;
|
|
99
|
+
static input(model: Model): Model.ConstructorInput;
|
|
100
|
+
static update(model: Model, patch: Partial<Model.Input>): Model;
|
|
101
|
+
}
|
|
102
|
+
export declare namespace Model {
|
|
103
|
+
type ConstructorInput = {
|
|
104
|
+
readonly id: ModelID;
|
|
105
|
+
readonly provider: ProviderID;
|
|
106
|
+
readonly route: AnyRoute;
|
|
107
|
+
readonly defaults?: ModelDefaults;
|
|
108
|
+
readonly compatibility?: ModelCompatibility;
|
|
109
|
+
};
|
|
110
|
+
type Input = Omit<ConstructorInput, "id" | "provider" | "defaults" | "compatibility"> & {
|
|
111
|
+
readonly id: string | ModelID;
|
|
112
|
+
readonly provider: string | ProviderID;
|
|
113
|
+
readonly defaults?: ModelDefaults.Input;
|
|
114
|
+
readonly compatibility?: ModelCompatibility.Input;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export type ModelInput = Model.Input;
|
|
118
|
+
export declare const ModelSchema: Schema.declare<Model, Model>;
|
|
119
|
+
declare const CacheHint_base: Schema.Class<CacheHint, Schema.Struct<{
|
|
120
|
+
readonly type: Schema.Literals<readonly ["ephemeral", "persistent"]>;
|
|
121
|
+
readonly ttlSeconds: Schema.optional<Schema.Number>;
|
|
122
|
+
}>, {}>;
|
|
123
|
+
export declare class CacheHint extends CacheHint_base {
|
|
124
|
+
}
|
|
125
|
+
export declare const CachePolicyObject: Schema.Struct<{
|
|
126
|
+
readonly tools: Schema.optional<Schema.Boolean>;
|
|
127
|
+
readonly system: Schema.optional<Schema.Boolean>;
|
|
128
|
+
readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
|
|
129
|
+
readonly tail: Schema.Number;
|
|
130
|
+
}>]>>;
|
|
131
|
+
readonly ttlSeconds: Schema.optional<Schema.Number>;
|
|
132
|
+
}>;
|
|
133
|
+
export type CachePolicyObject = Schema.Schema.Type<typeof CachePolicyObject>;
|
|
134
|
+
export declare const CachePolicy: Schema.Union<readonly [Schema.Literal<"auto">, Schema.Literal<"none">, Schema.Struct<{
|
|
135
|
+
readonly tools: Schema.optional<Schema.Boolean>;
|
|
136
|
+
readonly system: Schema.optional<Schema.Boolean>;
|
|
137
|
+
readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
|
|
138
|
+
readonly tail: Schema.Number;
|
|
139
|
+
}>]>>;
|
|
140
|
+
readonly ttlSeconds: Schema.optional<Schema.Number>;
|
|
141
|
+
}>]>;
|
|
142
|
+
export type CachePolicy = Schema.Schema.Type<typeof CachePolicy>;
|
|
143
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { JsonSchema, ModelID, ProviderID } from "./ids";
|
|
3
|
+
import { isRecord } from "../utils/record";
|
|
4
|
+
export const mergeJsonRecords = (...items) => {
|
|
5
|
+
const defined = items.filter((item) => item !== undefined);
|
|
6
|
+
if (defined.length === 0)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (defined.length === 1 && Object.values(defined[0]).every((value) => value !== undefined))
|
|
9
|
+
return defined[0];
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const item of defined) {
|
|
12
|
+
for (const [key, value] of Object.entries(item)) {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
continue;
|
|
15
|
+
result[key] = isRecord(result[key]) && isRecord(value) ? mergeJsonRecords(result[key], value) : value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return Object.keys(result).length === 0 ? undefined : result;
|
|
19
|
+
};
|
|
20
|
+
const mergeStringRecords = (...items) => {
|
|
21
|
+
const defined = items.filter((item) => item !== undefined);
|
|
22
|
+
if (defined.length === 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (defined.length === 1)
|
|
25
|
+
return defined[0];
|
|
26
|
+
const result = Object.fromEntries(defined.flatMap((item) => Object.entries(item).filter((entry) => entry[1] !== undefined)));
|
|
27
|
+
return Object.keys(result).length === 0 ? undefined : result;
|
|
28
|
+
};
|
|
29
|
+
export const ProviderOptions = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Unknown));
|
|
30
|
+
export const mergeProviderOptions = (...items) => {
|
|
31
|
+
const result = {};
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
if (!item)
|
|
34
|
+
continue;
|
|
35
|
+
for (const [provider, options] of Object.entries(item)) {
|
|
36
|
+
const merged = mergeJsonRecords(result[provider], options);
|
|
37
|
+
if (merged)
|
|
38
|
+
result[provider] = merged;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return Object.keys(result).length === 0 ? undefined : result;
|
|
42
|
+
};
|
|
43
|
+
export class HttpOptions extends Schema.Class("LLM.HttpOptions")({
|
|
44
|
+
body: Schema.optional(JsonSchema),
|
|
45
|
+
headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
46
|
+
query: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
47
|
+
}) {
|
|
48
|
+
}
|
|
49
|
+
(function (HttpOptions) {
|
|
50
|
+
/** Normalize HTTP option input into the canonical `HttpOptions` class. */
|
|
51
|
+
HttpOptions.make = (input) => (input instanceof HttpOptions ? input : new HttpOptions(input));
|
|
52
|
+
})(HttpOptions || (HttpOptions = {}));
|
|
53
|
+
export const mergeHttpOptions = (...items) => {
|
|
54
|
+
const body = mergeJsonRecords(...items.map((item) => item?.body));
|
|
55
|
+
const headers = mergeStringRecords(...items.map((item) => item?.headers));
|
|
56
|
+
const query = mergeStringRecords(...items.map((item) => item?.query));
|
|
57
|
+
if (!body && !headers && !query)
|
|
58
|
+
return undefined;
|
|
59
|
+
return new HttpOptions({ body, headers, query });
|
|
60
|
+
};
|
|
61
|
+
export class GenerationOptions extends Schema.Class("LLM.GenerationOptions")({
|
|
62
|
+
maxTokens: Schema.optional(Schema.Number),
|
|
63
|
+
temperature: Schema.optional(Schema.Number),
|
|
64
|
+
topP: Schema.optional(Schema.Number),
|
|
65
|
+
topK: Schema.optional(Schema.Number),
|
|
66
|
+
frequencyPenalty: Schema.optional(Schema.Number),
|
|
67
|
+
presencePenalty: Schema.optional(Schema.Number),
|
|
68
|
+
seed: Schema.optional(Schema.Number),
|
|
69
|
+
stop: Schema.optional(Schema.Array(Schema.String)),
|
|
70
|
+
}) {
|
|
71
|
+
}
|
|
72
|
+
(function (GenerationOptions) {
|
|
73
|
+
/** Normalize generation option input into the canonical `GenerationOptions` class. */
|
|
74
|
+
GenerationOptions.make = (input = {}) => (input instanceof GenerationOptions ? input : new GenerationOptions(input));
|
|
75
|
+
})(GenerationOptions || (GenerationOptions = {}));
|
|
76
|
+
const latestGeneration = (items, key) => items.findLast((item) => item?.[key] !== undefined)?.[key];
|
|
77
|
+
export const mergeGenerationOptions = (...items) => {
|
|
78
|
+
const result = new GenerationOptions({
|
|
79
|
+
maxTokens: latestGeneration(items, "maxTokens"),
|
|
80
|
+
temperature: latestGeneration(items, "temperature"),
|
|
81
|
+
topP: latestGeneration(items, "topP"),
|
|
82
|
+
topK: latestGeneration(items, "topK"),
|
|
83
|
+
frequencyPenalty: latestGeneration(items, "frequencyPenalty"),
|
|
84
|
+
presencePenalty: latestGeneration(items, "presencePenalty"),
|
|
85
|
+
seed: latestGeneration(items, "seed"),
|
|
86
|
+
stop: latestGeneration(items, "stop"),
|
|
87
|
+
});
|
|
88
|
+
return Object.values(result).some((value) => value !== undefined) ? result : undefined;
|
|
89
|
+
};
|
|
90
|
+
export class ModelLimits extends Schema.Class("LLM.ModelLimits")({
|
|
91
|
+
context: Schema.optional(Schema.Number),
|
|
92
|
+
output: Schema.optional(Schema.Number),
|
|
93
|
+
}) {
|
|
94
|
+
}
|
|
95
|
+
(function (ModelLimits) {
|
|
96
|
+
/** Normalize model limit input into the canonical `ModelLimits` class. */
|
|
97
|
+
ModelLimits.make = (input) => input instanceof ModelLimits ? input : new ModelLimits(input ?? {});
|
|
98
|
+
})(ModelLimits || (ModelLimits = {}));
|
|
99
|
+
export class ModelDefaults extends Schema.Class("LLM.ModelDefaults")({
|
|
100
|
+
limits: Schema.optional(ModelLimits),
|
|
101
|
+
generation: Schema.optional(GenerationOptions),
|
|
102
|
+
providerOptions: Schema.optional(ProviderOptions),
|
|
103
|
+
http: Schema.optional(HttpOptions),
|
|
104
|
+
}) {
|
|
105
|
+
}
|
|
106
|
+
(function (ModelDefaults) {
|
|
107
|
+
/** Normalize selected-model request defaults without applying precedence. */
|
|
108
|
+
ModelDefaults.make = (input) => {
|
|
109
|
+
if (input instanceof ModelDefaults)
|
|
110
|
+
return input;
|
|
111
|
+
return new ModelDefaults({
|
|
112
|
+
limits: input.limits === undefined ? undefined : ModelLimits.make(input.limits),
|
|
113
|
+
generation: input.generation === undefined ? undefined : GenerationOptions.make(input.generation),
|
|
114
|
+
providerOptions: input.providerOptions,
|
|
115
|
+
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
})(ModelDefaults || (ModelDefaults = {}));
|
|
119
|
+
export const ModelToolSchemaCompatibility = Schema.Literals(["gemini", "moonshot"]);
|
|
120
|
+
export class ModelCompatibility extends Schema.Class("LLM.ModelCompatibility")({
|
|
121
|
+
toolSchema: Schema.optional(ModelToolSchemaCompatibility),
|
|
122
|
+
}) {
|
|
123
|
+
}
|
|
124
|
+
(function (ModelCompatibility) {
|
|
125
|
+
/** Normalize model/upstream compatibility metadata without projecting requests. */
|
|
126
|
+
ModelCompatibility.make = (input) => (input instanceof ModelCompatibility ? input : new ModelCompatibility(input));
|
|
127
|
+
})(ModelCompatibility || (ModelCompatibility = {}));
|
|
128
|
+
export class Model {
|
|
129
|
+
id;
|
|
130
|
+
provider;
|
|
131
|
+
route;
|
|
132
|
+
defaults;
|
|
133
|
+
compatibility;
|
|
134
|
+
constructor(input) {
|
|
135
|
+
this.id = input.id;
|
|
136
|
+
this.provider = input.provider;
|
|
137
|
+
this.route = input.route;
|
|
138
|
+
this.defaults = input.defaults;
|
|
139
|
+
this.compatibility = input.compatibility;
|
|
140
|
+
}
|
|
141
|
+
static make(input) {
|
|
142
|
+
return new Model({
|
|
143
|
+
id: ModelID.make(input.id),
|
|
144
|
+
provider: ProviderID.make(input.provider),
|
|
145
|
+
route: input.route,
|
|
146
|
+
defaults: input.defaults === undefined ? undefined : ModelDefaults.make(input.defaults),
|
|
147
|
+
compatibility: input.compatibility === undefined ? undefined : ModelCompatibility.make(input.compatibility),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
static input(model) {
|
|
151
|
+
return {
|
|
152
|
+
id: model.id,
|
|
153
|
+
provider: model.provider,
|
|
154
|
+
route: model.route,
|
|
155
|
+
defaults: model.defaults,
|
|
156
|
+
compatibility: model.compatibility,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
static update(model, patch) {
|
|
160
|
+
if (Object.keys(patch).length === 0)
|
|
161
|
+
return model;
|
|
162
|
+
return Model.make({
|
|
163
|
+
...Model.input(model),
|
|
164
|
+
...patch,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
export const ModelSchema = Schema.declare((value) => value instanceof Model, { expected: "LLM.Model" });
|
|
169
|
+
export class CacheHint extends Schema.Class("LLM.CacheHint")({
|
|
170
|
+
type: Schema.Literals(["ephemeral", "persistent"]),
|
|
171
|
+
ttlSeconds: Schema.optional(Schema.Number),
|
|
172
|
+
}) {
|
|
173
|
+
}
|
|
174
|
+
// Auto-placement policy for prompt caching. The protocol-neutral lowering step
|
|
175
|
+
// reads this and injects `CacheHint`s at the configured boundaries; the
|
|
176
|
+
// per-protocol body builders then translate those hints into wire markers as
|
|
177
|
+
// usual. `"auto"` is the recommended default for agent loops — it places one
|
|
178
|
+
// breakpoint at the last tool definition, one at the last system part, and one
|
|
179
|
+
// at the latest user message. The combination of provider invalidation
|
|
180
|
+
// hierarchy (tools → system → messages) and Anthropic/Bedrock's 20-block
|
|
181
|
+
// lookback means three trailing breakpoints reliably cover the static prefix.
|
|
182
|
+
//
|
|
183
|
+
// Pass `"none"` to opt out entirely (the legacy behavior). Pass the granular
|
|
184
|
+
// object form to override individual choices.
|
|
185
|
+
export const CachePolicyObject = Schema.Struct({
|
|
186
|
+
tools: Schema.optional(Schema.Boolean),
|
|
187
|
+
system: Schema.optional(Schema.Boolean),
|
|
188
|
+
messages: Schema.optional(Schema.Union([
|
|
189
|
+
Schema.Literal("latest-user-message"),
|
|
190
|
+
Schema.Literal("latest-assistant"),
|
|
191
|
+
Schema.Struct({ tail: Schema.Number }),
|
|
192
|
+
])),
|
|
193
|
+
ttlSeconds: Schema.optional(Schema.Number),
|
|
194
|
+
});
|
|
195
|
+
export const CachePolicy = Schema.Union([Schema.Literal("auto"), Schema.Literal("none"), CachePolicyObject]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { LLMEvent, type ToolCallPart, type ToolOutput as ToolOutputType, type ToolResultValue as ToolResultValueType } from "./schema";
|
|
3
|
+
import { type Tools } from "./tool";
|
|
4
|
+
export interface ToolSettlement {
|
|
5
|
+
readonly result: ToolResultValueType;
|
|
6
|
+
readonly output?: ToolOutputType;
|
|
7
|
+
}
|
|
8
|
+
export interface DispatchResult extends ToolSettlement {
|
|
9
|
+
readonly events: ReadonlyArray<LLMEvent>;
|
|
10
|
+
}
|
|
11
|
+
/** Execute one canonical tool call without owning provider IO or continuation. */
|
|
12
|
+
export declare const dispatch: (tools: Tools, call: ToolCallPart) => Effect.Effect<DispatchResult>;
|
|
13
|
+
export declare const ToolRuntime: {
|
|
14
|
+
readonly dispatch: (tools: Tools, call: ToolCallPart) => Effect.Effect<DispatchResult>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { LLMEvent, ToolFailure, ToolOutput, ToolResultValue, } from "./schema";
|
|
3
|
+
import {} from "./tool";
|
|
4
|
+
/** Execute one canonical tool call without owning provider IO or continuation. */
|
|
5
|
+
export const dispatch = (tools, call) => {
|
|
6
|
+
const tool = tools[call.name];
|
|
7
|
+
if (!tool)
|
|
8
|
+
return Effect.succeed(result(call, { type: "error", value: `Unknown tool: ${call.name}` }));
|
|
9
|
+
if (!tool.execute)
|
|
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("LLM.ToolFailure", (failure) => Effect.succeed(result(call, { type: "error", value: failure.message }, failure.error))));
|
|
12
|
+
};
|
|
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
|
+
message: `Tool returned an invalid value for its success schema: ${error.message}`,
|
|
15
|
+
})))), Effect.map((encoded) => {
|
|
16
|
+
if (tool._legacyResult && ToolResultValue.is(encoded))
|
|
17
|
+
return { result: encoded, output: ToolOutput.fromResultValue(encoded) };
|
|
18
|
+
const output = tool._project(decoded, call.id, encoded);
|
|
19
|
+
const result = ToolOutput.toResultValue(output);
|
|
20
|
+
return result.type === "error" ? { result } : { result, output };
|
|
21
|
+
}))));
|
|
22
|
+
const result = (call, value, error) => {
|
|
23
|
+
const settlement = ToolResultValue.is(value) ? { result: value } : value;
|
|
24
|
+
return {
|
|
25
|
+
result: settlement.result,
|
|
26
|
+
output: settlement.output,
|
|
27
|
+
events: settlement.result.type === "error"
|
|
28
|
+
? [
|
|
29
|
+
LLMEvent.toolError({ id: call.id, name: call.name, message: String(settlement.result.value), error }),
|
|
30
|
+
LLMEvent.toolResult({ id: call.id, name: call.name, result: settlement.result }),
|
|
31
|
+
]
|
|
32
|
+
: [LLMEvent.toolResult({ id: call.id, name: call.name, result: settlement.result, output: settlement.output })],
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export const ToolRuntime = { dispatch };
|
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Effect, JsonSchema, Schema } from "effect";
|
|
2
|
+
import type { ToolCallPart, ToolContent, ToolDefinition as ToolDefinitionClass, ToolOutput as ToolOutputType } from "./schema";
|
|
3
|
+
import { ToolFailure } from "./schema";
|
|
4
|
+
/**
|
|
5
|
+
* Schema constraint for tool parameters / success values: no decoding or
|
|
6
|
+
* encoding services are allowed. Tools should be self-contained — anything
|
|
7
|
+
* beyond pure data conversion belongs in the handler closure.
|
|
8
|
+
*/
|
|
9
|
+
export type ToolSchema<T> = Schema.Codec<T, any, never, never>;
|
|
10
|
+
export interface ToolExecuteContext {
|
|
11
|
+
readonly id: ToolCallPart["id"];
|
|
12
|
+
readonly name: ToolCallPart["name"];
|
|
13
|
+
}
|
|
14
|
+
export type ToolExecute<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>> = (params: Schema.Schema.Type<Parameters>, context?: ToolExecuteContext) => Effect.Effect<Schema.Schema.Type<Success>, ToolFailure>;
|
|
15
|
+
export interface ToolModelOutputInput<Parameters, Output> {
|
|
16
|
+
readonly callID: ToolCallPart["id"];
|
|
17
|
+
readonly parameters: Parameters;
|
|
18
|
+
readonly output: Output;
|
|
19
|
+
}
|
|
20
|
+
export type ToolToModelOutput<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>> = (input: ToolModelOutputInput<Schema.Schema.Type<Parameters>, Success["Encoded"]>) => ReadonlyArray<ToolContent>;
|
|
21
|
+
/**
|
|
22
|
+
* A type-safe LLM tool. Each tool bundles its own description, parameter
|
|
23
|
+
* Schema and success Schema. The execute handler is optional: omit it when you
|
|
24
|
+
* only want to expose a tool schema to the model and handle tool calls outside
|
|
25
|
+
* this package.
|
|
26
|
+
*
|
|
27
|
+
* Errors must be expressed as `ToolFailure`. Unmapped errors and defects fail
|
|
28
|
+
* the stream.
|
|
29
|
+
*
|
|
30
|
+
* Internally each tool also carries memoized codecs and a precomputed
|
|
31
|
+
* `ToolDefinition` so callers do not rebuild them per invocation.
|
|
32
|
+
*/
|
|
33
|
+
export interface Definition<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>> {
|
|
34
|
+
readonly description: string;
|
|
35
|
+
readonly parameters: Parameters;
|
|
36
|
+
readonly success: Success;
|
|
37
|
+
readonly execute?: ToolExecute<Parameters, Success>;
|
|
38
|
+
readonly toModelOutput?: ToolToModelOutput<Parameters, Success>;
|
|
39
|
+
readonly toStructuredOutput?: (output: Success["Encoded"]) => unknown;
|
|
40
|
+
/** @internal */
|
|
41
|
+
readonly _decode: (input: unknown) => Effect.Effect<Schema.Schema.Type<Parameters>, Schema.SchemaError>;
|
|
42
|
+
/** @internal */
|
|
43
|
+
readonly _encode: (value: Schema.Schema.Type<Success>) => Effect.Effect<unknown, Schema.SchemaError>;
|
|
44
|
+
/** @internal */
|
|
45
|
+
readonly _project: (parameters: Schema.Schema.Type<Parameters>, callID: ToolCallPart["id"], output: unknown) => ToolOutputType;
|
|
46
|
+
/** @internal */
|
|
47
|
+
readonly _legacyResult: boolean;
|
|
48
|
+
/** @internal */
|
|
49
|
+
readonly _definition: ToolDefinitionClass;
|
|
50
|
+
}
|
|
51
|
+
export type AnyTool = Definition<any, any>;
|
|
52
|
+
export type ExecutableTool<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>> = Definition<Parameters, Success> & {
|
|
53
|
+
readonly execute: ToolExecute<Parameters, Success>;
|
|
54
|
+
};
|
|
55
|
+
export type AnyExecutableTool = ExecutableTool<any, any>;
|
|
56
|
+
export type ExecutableTools = Record<string, AnyExecutableTool>;
|
|
57
|
+
/**
|
|
58
|
+
* Constructs a tool. Two input modes:
|
|
59
|
+
*
|
|
60
|
+
* 1. **Typed** — pass Effect `parameters` and `success` Schemas; inputs and
|
|
61
|
+
* outputs are statically typed and decoded/encoded automatically.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* Tool.make({
|
|
65
|
+
* description: "Get current weather",
|
|
66
|
+
* parameters: Schema.Struct({ city: Schema.String }),
|
|
67
|
+
* success: Schema.Struct({ temperature: Schema.Number }),
|
|
68
|
+
* execute: ({ city }) => Effect.succeed({ temperature: 22 }),
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* 2. **Dynamic** — pass raw JSON Schema as `jsonSchema`. Use this when the
|
|
73
|
+
* schema comes from an external source (MCP server, plugin manifest,
|
|
74
|
+
* dynamic config) and is not known at compile time. Inputs are typed as
|
|
75
|
+
* `unknown`; the handler is responsible for any validation it needs.
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* Tool.make({
|
|
79
|
+
* description: "Look something up",
|
|
80
|
+
* jsonSchema: { type: "object", properties: { ... } },
|
|
81
|
+
* execute: (params) => Effect.succeed(...),
|
|
82
|
+
* })
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* In both modes the produced tool flows through `toDefinitions(...)`
|
|
86
|
+
* identically.
|
|
87
|
+
*/
|
|
88
|
+
export declare function make<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>>(config: {
|
|
89
|
+
readonly description: string;
|
|
90
|
+
readonly parameters: Parameters;
|
|
91
|
+
readonly success: Success;
|
|
92
|
+
readonly execute: ToolExecute<Parameters, Success>;
|
|
93
|
+
readonly toModelOutput?: ToolToModelOutput<Parameters, Success>;
|
|
94
|
+
readonly toStructuredOutput?: (output: Success["Encoded"]) => unknown;
|
|
95
|
+
}): ExecutableTool<Parameters, Success>;
|
|
96
|
+
export declare function make<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>>(config: {
|
|
97
|
+
readonly description: string;
|
|
98
|
+
readonly parameters: Parameters;
|
|
99
|
+
readonly success: Success;
|
|
100
|
+
readonly execute?: undefined;
|
|
101
|
+
readonly toModelOutput?: ToolToModelOutput<Parameters, Success>;
|
|
102
|
+
readonly toStructuredOutput?: (output: Success["Encoded"]) => unknown;
|
|
103
|
+
}): Definition<Parameters, Success>;
|
|
104
|
+
export declare function make(config: {
|
|
105
|
+
readonly description: string;
|
|
106
|
+
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
107
|
+
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
108
|
+
readonly execute: (params: unknown, context?: ToolExecuteContext) => Effect.Effect<unknown, ToolFailure>;
|
|
109
|
+
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<ToolContent>;
|
|
110
|
+
readonly toStructuredOutput?: (output: unknown) => unknown;
|
|
111
|
+
}): AnyExecutableTool;
|
|
112
|
+
export declare function make(config: {
|
|
113
|
+
readonly description: string;
|
|
114
|
+
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
115
|
+
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
116
|
+
readonly execute?: undefined;
|
|
117
|
+
readonly toModelOutput?: (input: ToolModelOutputInput<unknown, unknown>) => ReadonlyArray<ToolContent>;
|
|
118
|
+
readonly toStructuredOutput?: (output: unknown) => unknown;
|
|
119
|
+
}): AnyTool;
|
|
120
|
+
/**
|
|
121
|
+
* A record of named tools. The record key becomes the tool name on the wire.
|
|
122
|
+
*/
|
|
123
|
+
export type Tools = Record<string, AnyTool>;
|
|
124
|
+
/**
|
|
125
|
+
* Convert a tools record into the `ToolDefinition[]` shape that
|
|
126
|
+
* `LLMRequest.tools` expects.
|
|
127
|
+
*
|
|
128
|
+
* Tool names come from the record keys, so the per-tool cached
|
|
129
|
+
* `_definition` is rebuilt with the correct name here. The JSON Schema body
|
|
130
|
+
* is reused.
|
|
131
|
+
*/
|
|
132
|
+
export declare const toDefinitions: (tools: Tools) => ReadonlyArray<ToolDefinitionClass>;
|
|
133
|
+
export { ToolFailure };
|
|
134
|
+
export * as Tool from "./tool";
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Effect, JsonSchema, Schema } from "effect";
|
|
2
|
+
import { ToolDefinition, ToolFailure, ToolOutput } from "./schema";
|
|
3
|
+
export function make(config) {
|
|
4
|
+
if ("jsonSchema" in config) {
|
|
5
|
+
return {
|
|
6
|
+
description: config.description,
|
|
7
|
+
parameters: Schema.Unknown,
|
|
8
|
+
success: Schema.Unknown,
|
|
9
|
+
execute: config.execute,
|
|
10
|
+
toModelOutput: config.toModelOutput,
|
|
11
|
+
toStructuredOutput: config.toStructuredOutput,
|
|
12
|
+
_decode: Effect.succeed,
|
|
13
|
+
_encode: Effect.succeed,
|
|
14
|
+
_project: (parameters, callID, output) => project(config.toModelOutput, config.toStructuredOutput, parameters, callID, output),
|
|
15
|
+
_legacyResult: config.toModelOutput === undefined && config.toStructuredOutput === undefined,
|
|
16
|
+
_definition: new ToolDefinition({
|
|
17
|
+
name: "",
|
|
18
|
+
description: config.description,
|
|
19
|
+
inputSchema: config.jsonSchema,
|
|
20
|
+
outputSchema: config.outputSchema,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
description: config.description,
|
|
26
|
+
parameters: config.parameters,
|
|
27
|
+
success: config.success,
|
|
28
|
+
execute: config.execute,
|
|
29
|
+
toModelOutput: config.toModelOutput,
|
|
30
|
+
toStructuredOutput: config.toStructuredOutput,
|
|
31
|
+
_decode: Schema.decodeUnknownEffect(config.parameters),
|
|
32
|
+
_encode: Schema.encodeEffect(config.success),
|
|
33
|
+
_project: (parameters, callID, output) => project(config.toModelOutput, config.toStructuredOutput, parameters, callID, output),
|
|
34
|
+
_legacyResult: false,
|
|
35
|
+
_definition: new ToolDefinition({
|
|
36
|
+
name: "",
|
|
37
|
+
description: config.description,
|
|
38
|
+
inputSchema: toJsonSchema(config.parameters),
|
|
39
|
+
outputSchema: toJsonSchema(config.success),
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convert a tools record into the `ToolDefinition[]` shape that
|
|
45
|
+
* `LLMRequest.tools` expects.
|
|
46
|
+
*
|
|
47
|
+
* Tool names come from the record keys, so the per-tool cached
|
|
48
|
+
* `_definition` is rebuilt with the correct name here. The JSON Schema body
|
|
49
|
+
* is reused.
|
|
50
|
+
*/
|
|
51
|
+
export const toDefinitions = (tools) => Object.entries(tools).map(([name, item]) => new ToolDefinition({
|
|
52
|
+
name,
|
|
53
|
+
description: item._definition.description,
|
|
54
|
+
inputSchema: item._definition.inputSchema,
|
|
55
|
+
outputSchema: item._definition.outputSchema,
|
|
56
|
+
}));
|
|
57
|
+
const toJsonSchema = (schema) => {
|
|
58
|
+
const document = Schema.toJsonSchemaDocument(schema);
|
|
59
|
+
if (Object.keys(document.definitions).length === 0)
|
|
60
|
+
return document.schema;
|
|
61
|
+
return { ...document.schema, $defs: document.definitions };
|
|
62
|
+
};
|
|
63
|
+
const project = (toModelOutput, toStructuredOutput, parameters, callID, output) => ToolOutput.make(toStructuredOutput?.(output) ?? output, toModelOutput?.({ callID, parameters, output }) ??
|
|
64
|
+
(typeof output === "string" ? [{ type: "text", text: output }] : []));
|
|
65
|
+
export { ToolFailure };
|
|
66
|
+
export * as Tool from "./tool";
|
package/package.json
CHANGED
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"version": "0.0.0-next-15617",
|
|
2
4
|
"name": "@opencode-ai/ai",
|
|
3
|
-
"version": "0.0.0-bootstrap.0",
|
|
4
|
-
"description": "Bootstrap package for @opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
7
|
+
"scripts": {
|
|
8
|
+
"setup:recording-env": "bun run script/setup-recording-env.ts",
|
|
9
|
+
"test": "bun test --timeout 30000 --only-failures",
|
|
10
|
+
"typecheck": "tsgo --noEmit",
|
|
11
|
+
"build": "tsc -p tsconfig.build.json"
|
|
12
|
+
},
|
|
8
13
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"README.md"
|
|
14
|
+
"dist"
|
|
11
15
|
],
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./*": {
|
|
22
|
+
"import": "./dist/*.js",
|
|
23
|
+
"types": "./dist/*.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@clack/prompts": "1.0.0-alpha.1",
|
|
28
|
+
"@effect/platform-node": "4.0.0-beta.83",
|
|
29
|
+
"@opencode-ai/http-recorder": "0.0.0-next-15617",
|
|
30
|
+
"@tsconfig/bun": "1.0.9",
|
|
31
|
+
"@types/bun": "1.3.13",
|
|
32
|
+
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
33
|
+
"typescript": "5.8.2"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@smithy/eventstream-codec": "4.2.14",
|
|
37
|
+
"@smithy/util-utf8": "4.2.2",
|
|
38
|
+
"@opencode-ai/schema": "0.0.0-next-15617",
|
|
39
|
+
"aws4fetch": "1.0.20",
|
|
40
|
+
"effect": "4.0.0-beta.83",
|
|
41
|
+
"google-auth-library": "10.5.0"
|
|
15
42
|
}
|
|
16
|
-
}
|
|
43
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|