@opencode/protocol 0.0.0-dev-70 → 0.0.0-dev-80
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/client.js +7 -1
- package/dist/errors.d.ts +26 -0
- package/dist/errors.js +30 -0
- package/dist/groups/generate.d.ts +194 -3
- package/dist/groups/generate.js +41 -5
- package/dist/groups/model.d.ts +4 -0
- package/dist/groups/provider.d.ts +4 -0
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -46,7 +46,12 @@ export const groupNames = {
|
|
|
46
46
|
"server.vcs": "vcs",
|
|
47
47
|
"server.config": "config",
|
|
48
48
|
};
|
|
49
|
-
export const promiseOmitEndpoints = new Set([
|
|
49
|
+
export const promiseOmitEndpoints = new Set([
|
|
50
|
+
"pty.connect",
|
|
51
|
+
"persistentPty.connect",
|
|
52
|
+
"mcp.client",
|
|
53
|
+
"generate.textLegacy",
|
|
54
|
+
]);
|
|
50
55
|
export const effectOmitEndpoints = new Set([
|
|
51
56
|
"fs.read",
|
|
52
57
|
"fs.write",
|
|
@@ -54,4 +59,5 @@ export const effectOmitEndpoints = new Set([
|
|
|
54
59
|
"pty.connect",
|
|
55
60
|
"persistentPty.connect",
|
|
56
61
|
"mcp.client",
|
|
62
|
+
"generate.textLegacy",
|
|
57
63
|
]);
|
package/dist/errors.d.ts
CHANGED
|
@@ -196,4 +196,30 @@ declare const ShellNotFoundError_base: Schema.Class<ShellNotFoundError, Schema.T
|
|
|
196
196
|
}>, import("effect/Cause").YieldableError>;
|
|
197
197
|
export declare class ShellNotFoundError extends ShellNotFoundError_base {
|
|
198
198
|
}
|
|
199
|
+
declare const ModelNotFoundError_base: Schema.Class<ModelNotFoundError, Schema.TaggedStruct<"ModelNotFoundError", {
|
|
200
|
+
readonly providerID: Schema.String;
|
|
201
|
+
readonly modelID: Schema.String;
|
|
202
|
+
readonly message: Schema.String;
|
|
203
|
+
}>, import("effect/Cause").YieldableError>;
|
|
204
|
+
export declare class ModelNotFoundError extends ModelNotFoundError_base {
|
|
205
|
+
}
|
|
206
|
+
declare const UnsupportedModelError_base: Schema.Class<UnsupportedModelError, Schema.TaggedStruct<"UnsupportedModelError", {
|
|
207
|
+
readonly providerID: Schema.String;
|
|
208
|
+
readonly modelID: Schema.String;
|
|
209
|
+
readonly capability: Schema.String;
|
|
210
|
+
readonly message: Schema.String;
|
|
211
|
+
}>, import("effect/Cause").YieldableError>;
|
|
212
|
+
/** The model exists but cannot serve this request, such as a chat model asked for images. */
|
|
213
|
+
export declare class UnsupportedModelError extends UnsupportedModelError_base {
|
|
214
|
+
}
|
|
215
|
+
declare const ProviderRequestError_base: Schema.Class<ProviderRequestError, Schema.TaggedStruct<"ProviderRequestError", {
|
|
216
|
+
readonly providerID: Schema.String;
|
|
217
|
+
readonly reason: Schema.Literals<readonly ["authentication", "rate_limit", "content_filter", "invalid_request", "overloaded", "provider"]>;
|
|
218
|
+
readonly message: Schema.String;
|
|
219
|
+
readonly status: Schema.optional<Schema.Int>;
|
|
220
|
+
readonly retryAfterMs: Schema.optional<Schema.Int>;
|
|
221
|
+
}>, import("effect/Cause").YieldableError>;
|
|
222
|
+
/** The provider rejected or failed the request after the server sent it. */
|
|
223
|
+
export declare class ProviderRequestError extends ProviderRequestError_base {
|
|
224
|
+
}
|
|
199
225
|
export {};
|
package/dist/errors.js
CHANGED
|
@@ -155,3 +155,33 @@ export class ShellNotFoundError extends Schema.TaggedError()("ShellNotFoundError
|
|
|
155
155
|
message: Schema.String,
|
|
156
156
|
}, { httpApiStatus: 404 }) {
|
|
157
157
|
}
|
|
158
|
+
export class ModelNotFoundError extends Schema.TaggedError()("ModelNotFoundError", {
|
|
159
|
+
providerID: Schema.String,
|
|
160
|
+
modelID: Schema.String,
|
|
161
|
+
message: Schema.String,
|
|
162
|
+
}, { httpApiStatus: 404 }) {
|
|
163
|
+
}
|
|
164
|
+
/** The model exists but cannot serve this request, such as a chat model asked for images. */
|
|
165
|
+
export class UnsupportedModelError extends Schema.TaggedError()("UnsupportedModelError", {
|
|
166
|
+
providerID: Schema.String,
|
|
167
|
+
modelID: Schema.String,
|
|
168
|
+
capability: Schema.String,
|
|
169
|
+
message: Schema.String,
|
|
170
|
+
}, { httpApiStatus: 422 }) {
|
|
171
|
+
}
|
|
172
|
+
/** The provider rejected or failed the request after the server sent it. */
|
|
173
|
+
export class ProviderRequestError extends Schema.TaggedError()("ProviderRequestError", {
|
|
174
|
+
providerID: Schema.String,
|
|
175
|
+
reason: Schema.Literals([
|
|
176
|
+
"authentication",
|
|
177
|
+
"rate_limit",
|
|
178
|
+
"content_filter",
|
|
179
|
+
"invalid_request",
|
|
180
|
+
"overloaded",
|
|
181
|
+
"provider",
|
|
182
|
+
]),
|
|
183
|
+
message: Schema.String,
|
|
184
|
+
status: Schema.optional(Schema.Int),
|
|
185
|
+
retryAfterMs: Schema.optional(Schema.Int),
|
|
186
|
+
}, { httpApiStatus: 502 }) {
|
|
187
|
+
}
|
|
@@ -1,7 +1,198 @@
|
|
|
1
|
+
import { Generate } from "@opencode/schema/generate";
|
|
1
2
|
import { Schema } from "effect";
|
|
2
3
|
import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
|
|
3
|
-
import { LocationNotFoundError,
|
|
4
|
-
export declare const GenerateGroup: HttpApiGroup.HttpApiGroup<"server.generate", HttpApiEndpoint.HttpApiEndpoint<"generate.
|
|
4
|
+
import { InvalidRequestError, LocationNotFoundError, ModelNotFoundError, ProviderNotFoundError, ProviderRequestError, ServiceUnavailableError, UnsupportedModelError } from "../errors.js";
|
|
5
|
+
export declare const GenerateGroup: HttpApiGroup.HttpApiGroup<"server.generate", HttpApiEndpoint.HttpApiEndpoint<"generate.decisions", "POST", "/api/experimental/generate/decisions", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
6
|
+
readonly model: Schema.Struct<{
|
|
7
|
+
readonly id: Schema.brand<Schema.String, "Model.ID">;
|
|
8
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
9
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
10
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
11
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
12
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
13
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
14
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
15
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
16
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
17
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
18
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
19
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
20
|
+
};
|
|
21
|
+
readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
|
|
22
|
+
}> & {
|
|
23
|
+
parse: (input: string) => {
|
|
24
|
+
readonly id: string & import("effect/Brand").Brand<"Model.ID">;
|
|
25
|
+
readonly providerID: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
26
|
+
readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly input: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
30
|
+
readonly type: Schema.Literal<"text">;
|
|
31
|
+
readonly text: Schema.String;
|
|
32
|
+
}>, Schema.Struct<{
|
|
33
|
+
readonly type: Schema.Literal<"json">;
|
|
34
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
35
|
+
}>, Schema.Struct<{
|
|
36
|
+
readonly data: Schema.String;
|
|
37
|
+
readonly mime: Schema.String;
|
|
38
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
39
|
+
readonly type: Schema.Literal<"file">;
|
|
40
|
+
}>]>>;
|
|
41
|
+
readonly questions: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
42
|
+
readonly type: Schema.Literal<"predicate">;
|
|
43
|
+
readonly name: Schema.String;
|
|
44
|
+
readonly instructions: Schema.String;
|
|
45
|
+
}>, Schema.Struct<{
|
|
46
|
+
readonly type: Schema.Literal<"choice">;
|
|
47
|
+
readonly name: Schema.String;
|
|
48
|
+
readonly instructions: Schema.String;
|
|
49
|
+
readonly choices: Schema.$Array<Schema.Struct<{
|
|
50
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
|
|
51
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
52
|
+
}>>;
|
|
53
|
+
}>, Schema.Struct<{
|
|
54
|
+
readonly type: Schema.Literal<"score">;
|
|
55
|
+
readonly name: Schema.String;
|
|
56
|
+
readonly instructions: Schema.String;
|
|
57
|
+
readonly levels: Schema.$Array<Schema.Struct<{
|
|
58
|
+
readonly label: Schema.String;
|
|
59
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
60
|
+
}>>;
|
|
61
|
+
}>]>>;
|
|
62
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
63
|
+
readonly data: Schema.Struct<{
|
|
64
|
+
readonly answers: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
65
|
+
readonly type: Schema.Literal<"predicate">;
|
|
66
|
+
readonly name: Schema.String;
|
|
67
|
+
readonly probability: Schema.Finite;
|
|
68
|
+
}>, Schema.Struct<{
|
|
69
|
+
readonly type: Schema.Literal<"choice">;
|
|
70
|
+
readonly name: Schema.String;
|
|
71
|
+
readonly choice: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
|
|
72
|
+
readonly probabilities: Schema.$Array<Schema.Struct<{
|
|
73
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
|
|
74
|
+
readonly probability: Schema.Finite;
|
|
75
|
+
}>>;
|
|
76
|
+
readonly confidence: Schema.Finite;
|
|
77
|
+
}>, Schema.Struct<{
|
|
78
|
+
readonly type: Schema.Literal<"score">;
|
|
79
|
+
readonly name: Schema.String;
|
|
80
|
+
readonly score: Schema.Finite;
|
|
81
|
+
readonly probabilities: Schema.$Array<Schema.Struct<{
|
|
82
|
+
readonly value: Schema.Int;
|
|
83
|
+
readonly label: Schema.String;
|
|
84
|
+
readonly probability: Schema.Finite;
|
|
85
|
+
}>>;
|
|
86
|
+
readonly confidence: Schema.Finite;
|
|
87
|
+
}>, Schema.Struct<{
|
|
88
|
+
readonly type: Schema.Literal<"error">;
|
|
89
|
+
readonly name: Schema.String;
|
|
90
|
+
readonly reason: Schema.String;
|
|
91
|
+
readonly message: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
92
|
+
}>]>>;
|
|
93
|
+
readonly cost: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
94
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
95
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
96
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
97
|
+
}>, never, never>;
|
|
98
|
+
readonly tokens: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
99
|
+
readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
100
|
+
readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
101
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
102
|
+
readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
103
|
+
readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
104
|
+
}>>, never, never>;
|
|
105
|
+
readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
106
|
+
}>;
|
|
107
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError | typeof ProviderNotFoundError | typeof ModelNotFoundError | typeof UnsupportedModelError | typeof ProviderRequestError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"generate.image", "POST", "/api/experimental/generate/image", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
108
|
+
readonly model: Schema.Struct<{
|
|
109
|
+
readonly id: Schema.brand<Schema.String, "Model.ID">;
|
|
110
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
111
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
112
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
113
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
114
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
115
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
116
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
117
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
118
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
119
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
120
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
121
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
122
|
+
};
|
|
123
|
+
readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
|
|
124
|
+
}> & {
|
|
125
|
+
parse: (input: string) => {
|
|
126
|
+
readonly id: string & import("effect/Brand").Brand<"Model.ID">;
|
|
127
|
+
readonly providerID: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
128
|
+
readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
readonly prompt: Schema.String;
|
|
132
|
+
readonly images: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
133
|
+
readonly data: Schema.String;
|
|
134
|
+
readonly mime: Schema.String;
|
|
135
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
136
|
+
}>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
137
|
+
readonly data: Schema.String;
|
|
138
|
+
readonly mime: Schema.String;
|
|
139
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
140
|
+
}>>>, never, never>;
|
|
141
|
+
readonly n: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
142
|
+
readonly aspect: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<`${number}:${number}`, `${number}:${number}`, never, never>>>, Schema.optionalKey<Schema.Codec<`${number}:${number}`, `${number}:${number}`, never, never>>, never, never>;
|
|
143
|
+
readonly resolution: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Generate.ImageResolution, Generate.ImageResolution, never, never>>>, Schema.optionalKey<Schema.Codec<Generate.ImageResolution, Generate.ImageResolution, never, never>>, never, never>;
|
|
144
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
145
|
+
readonly data: Schema.Struct<{
|
|
146
|
+
readonly images: Schema.$Array<Schema.Struct<{
|
|
147
|
+
readonly data: Schema.String;
|
|
148
|
+
readonly mime: Schema.String;
|
|
149
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
150
|
+
readonly type: Schema.Literal<"image">;
|
|
151
|
+
}>>;
|
|
152
|
+
readonly cost: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
153
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
154
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
155
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
156
|
+
}>, never, never>;
|
|
157
|
+
readonly tokens: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
158
|
+
readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
159
|
+
readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
160
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
161
|
+
readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
162
|
+
readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
|
|
163
|
+
}>>, never, never>;
|
|
164
|
+
readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
165
|
+
}>;
|
|
166
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError | typeof ProviderNotFoundError | typeof ModelNotFoundError | typeof UnsupportedModelError | typeof ProviderRequestError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"generate.text", "POST", "/api/experimental/generate/text", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
167
|
+
readonly prompt: Schema.String;
|
|
168
|
+
readonly model: Schema.optional<Schema.Struct<{
|
|
169
|
+
readonly id: Schema.brand<Schema.String, "Model.ID">;
|
|
170
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
171
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
172
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
173
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
174
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
175
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
176
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
177
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
178
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
179
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
180
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
181
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
182
|
+
};
|
|
183
|
+
readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
|
|
184
|
+
}> & {
|
|
185
|
+
parse: (input: string) => {
|
|
186
|
+
readonly id: string & import("effect/Brand").Brand<"Model.ID">;
|
|
187
|
+
readonly providerID: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
188
|
+
readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
|
|
189
|
+
};
|
|
190
|
+
}>;
|
|
191
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
192
|
+
readonly data: Schema.Struct<{
|
|
193
|
+
readonly text: Schema.String;
|
|
194
|
+
}>;
|
|
195
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError | typeof ProviderNotFoundError | typeof ModelNotFoundError | typeof UnsupportedModelError | typeof ProviderRequestError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"generate.textLegacy", "POST", "/api/experimental/generate", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
5
196
|
readonly prompt: Schema.String;
|
|
6
197
|
readonly model: Schema.optional<Schema.Struct<{
|
|
7
198
|
readonly id: Schema.brand<Schema.String, "Model.ID">;
|
|
@@ -30,4 +221,4 @@ export declare const GenerateGroup: HttpApiGroup.HttpApiGroup<"server.generate",
|
|
|
30
221
|
readonly data: Schema.Struct<{
|
|
31
222
|
readonly text: Schema.String;
|
|
32
223
|
}>;
|
|
33
|
-
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
|
|
224
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError | typeof ProviderNotFoundError | typeof ModelNotFoundError | typeof UnsupportedModelError | typeof ProviderRequestError>, never, never>, false>;
|
package/dist/groups/generate.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import { Generate } from "@opencode/schema/generate";
|
|
1
2
|
import { Model } from "@opencode/schema/model";
|
|
2
3
|
import { Schema } from "effect";
|
|
3
4
|
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
|
|
4
|
-
import { LocationNotFoundError,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { InvalidRequestError, LocationNotFoundError, ModelNotFoundError, ProviderNotFoundError, ProviderRequestError, ServiceUnavailableError, UnsupportedModelError, } from "../errors.js";
|
|
6
|
+
const errors = [
|
|
7
|
+
InvalidRequestError,
|
|
8
|
+
ProviderNotFoundError,
|
|
9
|
+
ModelNotFoundError,
|
|
10
|
+
UnsupportedModelError,
|
|
11
|
+
ProviderRequestError,
|
|
12
|
+
ServiceUnavailableError,
|
|
13
|
+
LocationNotFoundError,
|
|
14
|
+
];
|
|
15
|
+
const textContract = {
|
|
7
16
|
payload: Schema.Struct({
|
|
8
17
|
prompt: Schema.String,
|
|
9
18
|
model: Model.Ref.pipe(Schema.optional),
|
|
@@ -11,11 +20,38 @@ export const GenerateGroup = HttpApiGroup.make("server.generate")
|
|
|
11
20
|
success: Schema.Struct({
|
|
12
21
|
data: Schema.Struct({ text: Schema.String }),
|
|
13
22
|
}).annotate({ identifier: "GenerateTextResponse" }),
|
|
14
|
-
error:
|
|
15
|
-
}
|
|
23
|
+
error: errors,
|
|
24
|
+
};
|
|
25
|
+
export const GenerateGroup = HttpApiGroup.make("server.generate")
|
|
26
|
+
.add(HttpApiEndpoint.post("generate.text", "/api/experimental/generate/text", textContract).annotateMerge(OpenApi.annotations({
|
|
16
27
|
identifier: "experimental.generate.text",
|
|
17
28
|
summary: "Generate text",
|
|
18
29
|
description: "Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.",
|
|
30
|
+
})))
|
|
31
|
+
// Kept so clients built before the move to /generate/text keep working; omitted from generated clients.
|
|
32
|
+
.add(HttpApiEndpoint.post("generate.textLegacy", "/api/experimental/generate", textContract).annotateMerge(OpenApi.annotations({
|
|
33
|
+
identifier: "experimental.generate.textLegacy",
|
|
34
|
+
summary: "Generate text (deprecated path)",
|
|
35
|
+
description: "Deprecated alias of POST /api/experimental/generate/text.",
|
|
36
|
+
deprecated: true,
|
|
37
|
+
})))
|
|
38
|
+
.add(HttpApiEndpoint.post("generate.image", "/api/experimental/generate/image", {
|
|
39
|
+
payload: Generate.ImageRequest,
|
|
40
|
+
success: Schema.Struct({ data: Generate.ImageResult }).annotate({ identifier: "GenerateImageResponse" }),
|
|
41
|
+
error: errors,
|
|
42
|
+
}).annotateMerge(OpenApi.annotations({
|
|
43
|
+
identifier: "experimental.generate.image",
|
|
44
|
+
summary: "Generate images",
|
|
45
|
+
description: "Generate or edit images with an image model using the server's base configuration and return them as base64. Stateless: nothing is stored.",
|
|
46
|
+
})))
|
|
47
|
+
.add(HttpApiEndpoint.post("generate.decisions", "/api/experimental/generate/decisions", {
|
|
48
|
+
payload: Generate.DecisionRequest,
|
|
49
|
+
success: Schema.Struct({ data: Generate.DecisionResult }).annotate({ identifier: "GenerateDecisionsResponse" }),
|
|
50
|
+
error: errors,
|
|
51
|
+
}).annotateMerge(OpenApi.annotations({
|
|
52
|
+
identifier: "experimental.generate.decisions",
|
|
53
|
+
summary: "Generate decisions",
|
|
54
|
+
description: "Ask a decision model typed predicate, choice and score questions about the input and return one probability-bearing answer per question, in question order. Stateless: nothing is stored.",
|
|
19
55
|
})))
|
|
20
56
|
.annotateMerge(OpenApi.annotations({
|
|
21
57
|
title: "generate",
|
package/dist/groups/model.d.ts
CHANGED
|
@@ -100,6 +100,7 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
|
|
|
100
100
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
101
101
|
readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
102
102
|
readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
103
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
103
104
|
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
104
105
|
readonly reasoningField: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Model.ReasoningField, Model.ReasoningField, never, never>>>, Schema.optionalKey<Schema.Codec<Model.ReasoningField, Model.ReasoningField, never, never>>, never, never>;
|
|
105
106
|
readonly requireReasoning: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
@@ -111,6 +112,7 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
|
|
|
111
112
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
112
113
|
readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
113
114
|
readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
115
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
114
116
|
}>>, never, never>;
|
|
115
117
|
readonly package: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
116
118
|
readonly capabilities: Schema.Struct<{
|
|
@@ -319,6 +321,7 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
|
|
|
319
321
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
320
322
|
readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
321
323
|
readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
324
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
322
325
|
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
323
326
|
readonly reasoningField: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Model.ReasoningField, Model.ReasoningField, never, never>>>, Schema.optionalKey<Schema.Codec<Model.ReasoningField, Model.ReasoningField, never, never>>, never, never>;
|
|
324
327
|
readonly requireReasoning: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
@@ -330,6 +333,7 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
|
|
|
330
333
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
331
334
|
readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
332
335
|
readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
336
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
333
337
|
}>>, never, never>;
|
|
334
338
|
readonly package: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
335
339
|
readonly capabilities: Schema.Struct<{
|
|
@@ -119,6 +119,7 @@ export declare const ProviderGroup: HttpApiGroup.HttpApiGroup<"server.provider",
|
|
|
119
119
|
readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
120
120
|
readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
121
121
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
122
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
122
123
|
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
123
124
|
readonly reasoningField: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<import("@opencode/schema/model-compatibility").ReasoningField, import("@opencode/schema/model-compatibility").ReasoningField, never, never>>>, Schema.optionalKey<Schema.Codec<import("@opencode/schema/model-compatibility").ReasoningField, import("@opencode/schema/model-compatibility").ReasoningField, never, never>>, never, never>;
|
|
124
125
|
readonly requireReasoning: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
@@ -128,6 +129,7 @@ export declare const ProviderGroup: HttpApiGroup.HttpApiGroup<"server.provider",
|
|
|
128
129
|
readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
129
130
|
readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
130
131
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
132
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
131
133
|
}>>, never, never>;
|
|
132
134
|
}> & {
|
|
133
135
|
empty: (id: Provider.ID) => Provider.Info;
|
|
@@ -235,6 +237,7 @@ export declare const ProviderGroup: HttpApiGroup.HttpApiGroup<"server.provider",
|
|
|
235
237
|
readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
236
238
|
readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
237
239
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
240
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
238
241
|
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
239
242
|
readonly reasoningField: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<import("@opencode/schema/model-compatibility").ReasoningField, import("@opencode/schema/model-compatibility").ReasoningField, never, never>>>, Schema.optionalKey<Schema.Codec<import("@opencode/schema/model-compatibility").ReasoningField, import("@opencode/schema/model-compatibility").ReasoningField, never, never>>, never, never>;
|
|
240
243
|
readonly requireReasoning: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
@@ -244,6 +247,7 @@ export declare const ProviderGroup: HttpApiGroup.HttpApiGroup<"server.provider",
|
|
|
244
247
|
readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
245
248
|
readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
246
249
|
readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
|
|
250
|
+
readonly mediaInput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["assets", "state", "root"]>>>, Schema.optionalKey<Schema.Literals<readonly ["assets", "state", "root"]>>, never, never>;
|
|
247
251
|
}>>, never, never>;
|
|
248
252
|
}> & {
|
|
249
253
|
empty: (id: Provider.ID) => Provider.Info;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/protocol",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-80",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"typecheck:tsc": "tsc --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@opencode/schema": "0.0.0-dev-
|
|
38
|
+
"@opencode/schema": "0.0.0-dev-80",
|
|
39
39
|
"effect": "4.0.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|