@opencode/protocol 2.1.4 → 2.2.1
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/api.d.ts +4 -3
- package/dist/api.js +5 -3
- package/dist/client.d.ts +4 -0
- package/dist/client.js +13 -1
- package/dist/errors.d.ts +38 -0
- package/dist/errors.js +40 -0
- package/dist/groups/agent.d.ts +12 -2
- package/dist/groups/agent.js +2 -1
- package/dist/groups/event.d.ts +15 -2
- package/dist/groups/event.js +9 -0
- package/dist/groups/experimental.d.ts +523 -0
- package/dist/groups/experimental.js +5 -0
- package/dist/groups/fs.d.ts +15 -3
- package/dist/groups/fs.js +27 -1
- package/dist/groups/generate.d.ts +194 -3
- package/dist/groups/generate.js +41 -5
- package/dist/groups/mcp.d.ts +1 -0
- package/dist/groups/media.d.ts +8 -0
- package/dist/groups/media.js +18 -0
- package/dist/groups/message.d.ts +2240 -0
- package/dist/groups/message.js +29 -4
- package/dist/groups/model.d.ts +33 -6
- package/dist/groups/model.js +8 -2
- package/dist/groups/permission.d.ts +2 -2
- package/dist/groups/permission.js +4 -3
- package/dist/groups/persistent-pty.js +11 -10
- package/dist/groups/plugin.d.ts +18 -2
- package/dist/groups/plugin.js +15 -1
- package/dist/groups/provider.d.ts +24 -0
- package/dist/groups/schedule.d.ts +332 -0
- package/dist/groups/schedule.js +51 -0
- package/dist/groups/server.d.ts +2 -0
- package/dist/groups/server.js +2 -0
- package/dist/groups/session.d.ts +295 -11
- package/dist/groups/session.js +19 -35
- package/dist/groups/usage.d.ts +95 -0
- package/dist/groups/usage.js +22 -0
- package/dist/groups/vcs.d.ts +2 -0
- package/dist/groups/vcs.js +1 -0
- package/dist/groups/voice.d.ts +2 -18
- package/dist/groups/voice.js +3 -19
- package/package.json +3 -2
package/dist/groups/fs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
|
|
3
|
-
import { FileNotFoundError } from "../errors.js";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
3
|
+
import { FileNotFoundError, ServiceUnavailableError } from "../errors.js";
|
|
4
4
|
export declare const FileSystemGroup: HttpApiGroup.HttpApiGroup<"server.fs", HttpApiEndpoint.HttpApiEndpoint<"fs.find", "GET", "/api/fs/find", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
5
5
|
readonly location: Schema.optional<Schema.Struct<{
|
|
6
6
|
readonly directory: Schema.optional<Schema.String>;
|
|
@@ -33,7 +33,19 @@ export declare const FileSystemGroup: HttpApiGroup.HttpApiGroup<"server.fs", Htt
|
|
|
33
33
|
readonly location: Schema.optional<Schema.Struct<{
|
|
34
34
|
readonly directory: Schema.optional<Schema.String>;
|
|
35
35
|
}>>;
|
|
36
|
-
}>>, never, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.
|
|
36
|
+
}>>, never, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.unwatch", "DELETE", "/api/experimental/fs/watch", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
37
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
38
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
39
|
+
}>>;
|
|
40
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
41
|
+
readonly path: Schema.String;
|
|
42
|
+
}>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.watch", "POST", "/api/experimental/fs/watch", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
43
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
44
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
45
|
+
}>>;
|
|
46
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
47
|
+
readonly path: Schema.String;
|
|
48
|
+
}>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof ServiceUnavailableError | typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.write", "POST", "/api/experimental/fs/write", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
37
49
|
readonly location: Schema.optional<Schema.Struct<{
|
|
38
50
|
readonly directory: Schema.optional<Schema.String>;
|
|
39
51
|
}>>;
|
package/dist/groups/fs.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Location } from "@opencode/schema/location";
|
|
|
3
3
|
import { PositiveInt } from "@opencode/schema/schema";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
6
|
-
import { FileNotFoundError } from "../errors.js";
|
|
6
|
+
import { FileNotFoundError, ServiceUnavailableError } from "../errors.js";
|
|
7
7
|
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
8
8
|
const ListQuery = Schema.Struct({
|
|
9
9
|
...LocationQuery.fields,
|
|
@@ -17,6 +17,9 @@ const WriteQuery = Schema.Struct({
|
|
|
17
17
|
description: "An absolute path or a path relative to the requested location. Missing parent directories are created.",
|
|
18
18
|
}),
|
|
19
19
|
});
|
|
20
|
+
const WatchPayload = Schema.Struct({
|
|
21
|
+
path: Schema.String.annotate({ description: "A file path relative to the requested location." }),
|
|
22
|
+
});
|
|
20
23
|
const FindQuery = Schema.Struct({
|
|
21
24
|
...LocationQuery.fields,
|
|
22
25
|
query: FileSystem.FindInput.fields.query,
|
|
@@ -66,6 +69,29 @@ export const FileSystemGroup = HttpApiGroup.make("server.fs")
|
|
|
66
69
|
identifier: "experimental.fs.write",
|
|
67
70
|
summary: "Write file",
|
|
68
71
|
description: "Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.",
|
|
72
|
+
})))
|
|
73
|
+
.add(HttpApiEndpoint.post("fs.watch", "/api/experimental/fs/watch", {
|
|
74
|
+
query: LocationQuery,
|
|
75
|
+
payload: WatchPayload,
|
|
76
|
+
success: HttpApiSchema.NoContent,
|
|
77
|
+
error: [FileNotFoundError, ServiceUnavailableError],
|
|
78
|
+
})
|
|
79
|
+
.annotateMerge(locationQueryOpenApi)
|
|
80
|
+
.annotateMerge(OpenApi.annotations({
|
|
81
|
+
identifier: "experimental.fs.watch",
|
|
82
|
+
summary: "Watch file",
|
|
83
|
+
description: "Watch one file relative to the requested location for 24 hours, publishing filesystem.changed on that location when it changes. Watching an already watched file resets its expiry. Paths follow read confinement. Experimental: may change without compatibility guarantees.",
|
|
84
|
+
})))
|
|
85
|
+
.add(HttpApiEndpoint.delete("fs.unwatch", "/api/experimental/fs/watch", {
|
|
86
|
+
query: LocationQuery,
|
|
87
|
+
payload: WatchPayload,
|
|
88
|
+
success: HttpApiSchema.NoContent,
|
|
89
|
+
})
|
|
90
|
+
.annotateMerge(locationQueryOpenApi)
|
|
91
|
+
.annotateMerge(OpenApi.annotations({
|
|
92
|
+
identifier: "experimental.fs.unwatch",
|
|
93
|
+
summary: "Unwatch file",
|
|
94
|
+
description: "Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.",
|
|
69
95
|
})))
|
|
70
96
|
.annotateMerge(OpenApi.annotations({
|
|
71
97
|
title: "filesystem",
|
|
@@ -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/mcp.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare const makeMcpGroup: <LocationId extends HttpApiMiddleware.AnyId,
|
|
|
35
35
|
readonly status: Schema.Literal<"needs_auth">;
|
|
36
36
|
readonly error: Schema.String;
|
|
37
37
|
}>]>;
|
|
38
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
38
39
|
readonly integrationID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Integration.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Integration.ID">>, never, never>;
|
|
39
40
|
}>>;
|
|
40
41
|
}>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"mcp.resource.catalog", "GET", "/api/mcp/resource", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint } from "effect/http-api";
|
|
3
|
+
import { FileNotFoundError, InvalidRequestError } from "../errors.js";
|
|
4
|
+
export declare const MediaHash: Schema.String;
|
|
5
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
6
|
+
export declare const MediaGetEndpoint: HttpApiEndpoint.HttpApiEndpoint<"media.get", "GET", "/api/experimental/media/:hash", Schema.toCodecStringTree<Schema.Struct<{
|
|
7
|
+
hash: Schema.String;
|
|
8
|
+
}>>, never, never, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof InvalidRequestError | typeof FileNotFoundError>, never, never>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
3
|
+
import { FileNotFoundError, InvalidRequestError } from "../errors.js";
|
|
4
|
+
export const MediaHash = Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/u)).annotate({
|
|
5
|
+
identifier: "MediaHash",
|
|
6
|
+
});
|
|
7
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
8
|
+
export const MediaGetEndpoint = HttpApiEndpoint.get("media.get", "/api/experimental/media/:hash", {
|
|
9
|
+
params: { hash: MediaHash },
|
|
10
|
+
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
11
|
+
error: [FileNotFoundError, InvalidRequestError],
|
|
12
|
+
}).annotateMerge(OpenApi.annotations({
|
|
13
|
+
identifier: "experimental.media.get",
|
|
14
|
+
summary: "Read media blob",
|
|
15
|
+
description: "Read a content-addressed media blob by SHA-256 hash with immutable Cache-Control, ETag, and 304 Not Modified support. Only blobs a stored message or inbox item still references are served. Experimental: may change without compatibility guarantees.",
|
|
16
|
+
// The route shares the `server.experimental` group with the persistent PTY prototype; tag it on its own.
|
|
17
|
+
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
18
|
+
}));
|