@opencode/schema 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.
Files changed (43) hide show
  1. package/dist/agent.d.ts +5 -0
  2. package/dist/config/experimental.d.ts +39 -0
  3. package/dist/config/experimental.js +19 -0
  4. package/dist/config/provider.d.ts +57 -11
  5. package/dist/config/provider.js +15 -16
  6. package/dist/config.d.ts +1 -0
  7. package/dist/config.js +3 -0
  8. package/dist/event-manifest.d.ts +8 -0
  9. package/dist/file-diff.d.ts +2 -0
  10. package/dist/file-diff.js +2 -0
  11. package/dist/generate.d.ts +355 -0
  12. package/dist/generate.js +134 -0
  13. package/dist/goal.d.ts +126 -0
  14. package/dist/goal.js +40 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/mcp.d.ts +1 -0
  18. package/dist/mcp.js +2 -0
  19. package/dist/model-compatibility.d.ts +15 -4
  20. package/dist/model-compatibility.js +15 -4
  21. package/dist/model.d.ts +39 -8
  22. package/dist/model.js +12 -7
  23. package/dist/plugin.d.ts +15 -0
  24. package/dist/plugin.js +11 -1
  25. package/dist/prompt.d.ts +96 -0
  26. package/dist/prompt.js +17 -1
  27. package/dist/provider.d.ts +40 -0
  28. package/dist/provider.js +14 -3
  29. package/dist/schedule.d.ts +220 -0
  30. package/dist/schedule.js +110 -0
  31. package/dist/session-event.d.ts +20 -0
  32. package/dist/session-inbox.d.ts +714 -86
  33. package/dist/session-inbox.js +10 -1
  34. package/dist/session-message.d.ts +968 -0
  35. package/dist/session-message.js +19 -1
  36. package/dist/session-revert.d.ts +37 -0
  37. package/dist/session-transfer.d.ts +4 -0
  38. package/dist/session.d.ts +4 -0
  39. package/dist/usage-limits.d.ts +227 -0
  40. package/dist/usage-limits.js +59 -0
  41. package/dist/vcs.d.ts +3 -0
  42. package/dist/vcs.js +2 -0
  43. package/package.json +2 -1
@@ -0,0 +1,355 @@
1
+ export * as Generate from "./generate.js";
2
+ import { Schema } from "effect";
3
+ export interface File extends Schema.Schema.Type<typeof File> {
4
+ }
5
+ export declare const File: Schema.Struct<{
6
+ readonly data: Schema.String;
7
+ readonly mime: Schema.String;
8
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
9
+ }>;
10
+ export interface Usage extends Schema.Schema.Type<typeof Usage> {
11
+ }
12
+ export declare const Usage: Schema.Struct<{
13
+ readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
14
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
15
+ }>;
16
+ export declare const Native: Schema.$Record<Schema.String, Schema.Unknown>;
17
+ export type Native = typeof Native.Type;
18
+ export type ImageAspect = `${number}:${number}`;
19
+ export declare const ImageAspect: Schema.Codec<ImageAspect>;
20
+ /** Open-ended: providers add size tiers beyond these. */
21
+ export type ImageResolution = "1K" | "2K" | "4K" | (string & {});
22
+ export declare const ImageResolution: Schema.Codec<ImageResolution>;
23
+ export interface ImageRequest extends Schema.Schema.Type<typeof ImageRequest> {
24
+ }
25
+ export declare const ImageRequest: Schema.Struct<{
26
+ readonly model: Schema.Struct<{
27
+ readonly id: Schema.brand<Schema.String, "Model.ID">;
28
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
29
+ opencode: string & import("effect/Brand").Brand<"Provider.ID">;
30
+ anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
31
+ openai: string & import("effect/Brand").Brand<"Provider.ID">;
32
+ google: string & import("effect/Brand").Brand<"Provider.ID">;
33
+ googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
34
+ githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
35
+ amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
36
+ azure: string & import("effect/Brand").Brand<"Provider.ID">;
37
+ openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
38
+ mistral: string & import("effect/Brand").Brand<"Provider.ID">;
39
+ gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
40
+ };
41
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
42
+ }> & {
43
+ parse: (input: string) => {
44
+ readonly id: string & import("effect/Brand").Brand<"Model.ID">;
45
+ readonly providerID: string & import("effect/Brand").Brand<"Provider.ID">;
46
+ readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
47
+ };
48
+ };
49
+ readonly prompt: Schema.String;
50
+ readonly images: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
51
+ readonly data: Schema.String;
52
+ readonly mime: Schema.String;
53
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
54
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
55
+ readonly data: Schema.String;
56
+ readonly mime: Schema.String;
57
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
58
+ }>>>, never, never>;
59
+ readonly n: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
60
+ 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>;
61
+ readonly resolution: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<ImageResolution, ImageResolution, never, never>>>, Schema.optionalKey<Schema.Codec<ImageResolution, ImageResolution, never, never>>, never, never>;
62
+ }>;
63
+ export interface ImageOutput extends Schema.Schema.Type<typeof ImageOutput> {
64
+ }
65
+ export declare const ImageOutput: Schema.Struct<{
66
+ readonly data: Schema.String;
67
+ readonly mime: Schema.String;
68
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
69
+ readonly type: Schema.Literal<"image">;
70
+ }>;
71
+ export interface ImageResult extends Schema.Schema.Type<typeof ImageResult> {
72
+ }
73
+ export declare const ImageResult: Schema.Struct<{
74
+ readonly images: Schema.$Array<Schema.Struct<{
75
+ readonly data: Schema.String;
76
+ readonly mime: Schema.String;
77
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
78
+ readonly type: Schema.Literal<"image">;
79
+ }>>;
80
+ readonly cost: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
81
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
82
+ }>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
83
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
84
+ }>, never, never>;
85
+ readonly tokens: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
86
+ readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
87
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
88
+ }>>>, Schema.optionalKey<Schema.Struct<{
89
+ readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
90
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
91
+ }>>, never, never>;
92
+ readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
93
+ }>;
94
+ export interface DecisionTextPart extends Schema.Schema.Type<typeof DecisionTextPart> {
95
+ }
96
+ export declare const DecisionTextPart: Schema.Struct<{
97
+ readonly type: Schema.Literal<"text">;
98
+ readonly text: Schema.String;
99
+ }>;
100
+ export interface DecisionJsonPart extends Schema.Schema.Type<typeof DecisionJsonPart> {
101
+ }
102
+ export declare const DecisionJsonPart: Schema.Struct<{
103
+ readonly type: Schema.Literal<"json">;
104
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
105
+ }>;
106
+ export interface DecisionFilePart extends Schema.Schema.Type<typeof DecisionFilePart> {
107
+ }
108
+ export declare const DecisionFilePart: Schema.Struct<{
109
+ readonly data: Schema.String;
110
+ readonly mime: Schema.String;
111
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
112
+ readonly type: Schema.Literal<"file">;
113
+ }>;
114
+ export type DecisionPart = DecisionTextPart | DecisionJsonPart | DecisionFilePart;
115
+ export declare const DecisionPart: Schema.Union<readonly [Schema.Struct<{
116
+ readonly type: Schema.Literal<"text">;
117
+ readonly text: Schema.String;
118
+ }>, Schema.Struct<{
119
+ readonly type: Schema.Literal<"json">;
120
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
121
+ }>, Schema.Struct<{
122
+ readonly data: Schema.String;
123
+ readonly mime: Schema.String;
124
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
125
+ readonly type: Schema.Literal<"file">;
126
+ }>]>;
127
+ export declare const ChoiceValue: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
128
+ export type ChoiceValue = typeof ChoiceValue.Type;
129
+ export interface PredicateQuestion extends Schema.Schema.Type<typeof PredicateQuestion> {
130
+ }
131
+ export declare const PredicateQuestion: Schema.Struct<{
132
+ readonly type: Schema.Literal<"predicate">;
133
+ readonly name: Schema.String;
134
+ readonly instructions: Schema.String;
135
+ }>;
136
+ export interface ChoiceQuestion extends Schema.Schema.Type<typeof ChoiceQuestion> {
137
+ }
138
+ export declare const ChoiceQuestion: Schema.Struct<{
139
+ readonly type: Schema.Literal<"choice">;
140
+ readonly name: Schema.String;
141
+ readonly instructions: Schema.String;
142
+ readonly choices: Schema.$Array<Schema.Struct<{
143
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
144
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
145
+ }>>;
146
+ }>;
147
+ export interface ScoreQuestion extends Schema.Schema.Type<typeof ScoreQuestion> {
148
+ }
149
+ export declare const ScoreQuestion: Schema.Struct<{
150
+ readonly type: Schema.Literal<"score">;
151
+ readonly name: Schema.String;
152
+ readonly instructions: Schema.String;
153
+ readonly levels: Schema.$Array<Schema.Struct<{
154
+ readonly label: Schema.String;
155
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
156
+ }>>;
157
+ }>;
158
+ export type DecisionQuestion = PredicateQuestion | ChoiceQuestion | ScoreQuestion;
159
+ export declare const DecisionQuestion: Schema.Union<readonly [Schema.Struct<{
160
+ readonly type: Schema.Literal<"predicate">;
161
+ readonly name: Schema.String;
162
+ readonly instructions: Schema.String;
163
+ }>, Schema.Struct<{
164
+ readonly type: Schema.Literal<"choice">;
165
+ readonly name: Schema.String;
166
+ readonly instructions: Schema.String;
167
+ readonly choices: Schema.$Array<Schema.Struct<{
168
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
169
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
170
+ }>>;
171
+ }>, Schema.Struct<{
172
+ readonly type: Schema.Literal<"score">;
173
+ readonly name: Schema.String;
174
+ readonly instructions: Schema.String;
175
+ readonly levels: Schema.$Array<Schema.Struct<{
176
+ readonly label: Schema.String;
177
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
178
+ }>>;
179
+ }>]>;
180
+ export interface DecisionRequest extends Schema.Schema.Type<typeof DecisionRequest> {
181
+ }
182
+ export declare const DecisionRequest: Schema.Struct<{
183
+ readonly model: Schema.Struct<{
184
+ readonly id: Schema.brand<Schema.String, "Model.ID">;
185
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
186
+ opencode: string & import("effect/Brand").Brand<"Provider.ID">;
187
+ anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
188
+ openai: string & import("effect/Brand").Brand<"Provider.ID">;
189
+ google: string & import("effect/Brand").Brand<"Provider.ID">;
190
+ googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
191
+ githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
192
+ amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
193
+ azure: string & import("effect/Brand").Brand<"Provider.ID">;
194
+ openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
195
+ mistral: string & import("effect/Brand").Brand<"Provider.ID">;
196
+ gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
197
+ };
198
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
199
+ }> & {
200
+ parse: (input: string) => {
201
+ readonly id: string & import("effect/Brand").Brand<"Model.ID">;
202
+ readonly providerID: string & import("effect/Brand").Brand<"Provider.ID">;
203
+ readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
204
+ };
205
+ };
206
+ readonly input: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
207
+ readonly type: Schema.Literal<"text">;
208
+ readonly text: Schema.String;
209
+ }>, Schema.Struct<{
210
+ readonly type: Schema.Literal<"json">;
211
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
212
+ }>, Schema.Struct<{
213
+ readonly data: Schema.String;
214
+ readonly mime: Schema.String;
215
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
216
+ readonly type: Schema.Literal<"file">;
217
+ }>]>>;
218
+ readonly questions: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
219
+ readonly type: Schema.Literal<"predicate">;
220
+ readonly name: Schema.String;
221
+ readonly instructions: Schema.String;
222
+ }>, Schema.Struct<{
223
+ readonly type: Schema.Literal<"choice">;
224
+ readonly name: Schema.String;
225
+ readonly instructions: Schema.String;
226
+ readonly choices: Schema.$Array<Schema.Struct<{
227
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
228
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
229
+ }>>;
230
+ }>, Schema.Struct<{
231
+ readonly type: Schema.Literal<"score">;
232
+ readonly name: Schema.String;
233
+ readonly instructions: Schema.String;
234
+ readonly levels: Schema.$Array<Schema.Struct<{
235
+ readonly label: Schema.String;
236
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
237
+ }>>;
238
+ }>]>>;
239
+ }>;
240
+ export interface PredicateAnswer extends Schema.Schema.Type<typeof PredicateAnswer> {
241
+ }
242
+ export declare const PredicateAnswer: Schema.Struct<{
243
+ readonly type: Schema.Literal<"predicate">;
244
+ readonly name: Schema.String;
245
+ readonly probability: Schema.Finite;
246
+ }>;
247
+ export interface ChoiceAnswer extends Schema.Schema.Type<typeof ChoiceAnswer> {
248
+ }
249
+ export declare const ChoiceAnswer: Schema.Struct<{
250
+ readonly type: Schema.Literal<"choice">;
251
+ readonly name: Schema.String;
252
+ readonly choice: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
253
+ readonly probabilities: Schema.$Array<Schema.Struct<{
254
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
255
+ readonly probability: Schema.Finite;
256
+ }>>;
257
+ readonly confidence: Schema.Finite;
258
+ }>;
259
+ export interface ScoreAnswer extends Schema.Schema.Type<typeof ScoreAnswer> {
260
+ }
261
+ export declare const ScoreAnswer: Schema.Struct<{
262
+ readonly type: Schema.Literal<"score">;
263
+ readonly name: Schema.String;
264
+ readonly score: Schema.Finite;
265
+ readonly probabilities: Schema.$Array<Schema.Struct<{
266
+ readonly value: Schema.Int;
267
+ readonly label: Schema.String;
268
+ readonly probability: Schema.Finite;
269
+ }>>;
270
+ readonly confidence: Schema.Finite;
271
+ }>;
272
+ export interface ErrorAnswer extends Schema.Schema.Type<typeof ErrorAnswer> {
273
+ }
274
+ export declare const ErrorAnswer: Schema.Struct<{
275
+ readonly type: Schema.Literal<"error">;
276
+ readonly name: Schema.String;
277
+ readonly reason: Schema.String;
278
+ readonly message: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
279
+ }>;
280
+ export type DecisionAnswer = PredicateAnswer | ChoiceAnswer | ScoreAnswer | ErrorAnswer;
281
+ export declare const DecisionAnswer: Schema.Union<readonly [Schema.Struct<{
282
+ readonly type: Schema.Literal<"predicate">;
283
+ readonly name: Schema.String;
284
+ readonly probability: Schema.Finite;
285
+ }>, Schema.Struct<{
286
+ readonly type: Schema.Literal<"choice">;
287
+ readonly name: Schema.String;
288
+ readonly choice: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
289
+ readonly probabilities: Schema.$Array<Schema.Struct<{
290
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
291
+ readonly probability: Schema.Finite;
292
+ }>>;
293
+ readonly confidence: Schema.Finite;
294
+ }>, Schema.Struct<{
295
+ readonly type: Schema.Literal<"score">;
296
+ readonly name: Schema.String;
297
+ readonly score: Schema.Finite;
298
+ readonly probabilities: Schema.$Array<Schema.Struct<{
299
+ readonly value: Schema.Int;
300
+ readonly label: Schema.String;
301
+ readonly probability: Schema.Finite;
302
+ }>>;
303
+ readonly confidence: Schema.Finite;
304
+ }>, Schema.Struct<{
305
+ readonly type: Schema.Literal<"error">;
306
+ readonly name: Schema.String;
307
+ readonly reason: Schema.String;
308
+ readonly message: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
309
+ }>]>;
310
+ export interface DecisionResult extends Schema.Schema.Type<typeof DecisionResult> {
311
+ }
312
+ export declare const DecisionResult: Schema.Struct<{
313
+ readonly answers: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
314
+ readonly type: Schema.Literal<"predicate">;
315
+ readonly name: Schema.String;
316
+ readonly probability: Schema.Finite;
317
+ }>, Schema.Struct<{
318
+ readonly type: Schema.Literal<"choice">;
319
+ readonly name: Schema.String;
320
+ readonly choice: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
321
+ readonly probabilities: Schema.$Array<Schema.Struct<{
322
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Boolean]>;
323
+ readonly probability: Schema.Finite;
324
+ }>>;
325
+ readonly confidence: Schema.Finite;
326
+ }>, Schema.Struct<{
327
+ readonly type: Schema.Literal<"score">;
328
+ readonly name: Schema.String;
329
+ readonly score: Schema.Finite;
330
+ readonly probabilities: Schema.$Array<Schema.Struct<{
331
+ readonly value: Schema.Int;
332
+ readonly label: Schema.String;
333
+ readonly probability: Schema.Finite;
334
+ }>>;
335
+ readonly confidence: Schema.Finite;
336
+ }>, Schema.Struct<{
337
+ readonly type: Schema.Literal<"error">;
338
+ readonly name: Schema.String;
339
+ readonly reason: Schema.String;
340
+ readonly message: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
341
+ }>]>>;
342
+ readonly cost: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
343
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
344
+ }>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
345
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
346
+ }>, never, never>;
347
+ readonly tokens: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
348
+ readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
349
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
350
+ }>>>, Schema.optionalKey<Schema.Struct<{
351
+ readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
352
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
353
+ }>>, never, never>;
354
+ readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
355
+ }>;
@@ -0,0 +1,134 @@
1
+ export * as Generate from "./generate.js";
2
+ import { Schema } from "effect";
3
+ import { Model } from "./model.js";
4
+ import { Money } from "./money.js";
5
+ import { Base64 } from "./prompt.js";
6
+ import { PositiveInt, optional } from "./schema.js";
7
+ const description = (text) => ({ description: text });
8
+ export const File = Schema.Struct({
9
+ data: Base64,
10
+ mime: Schema.String,
11
+ name: Schema.String.pipe(optional),
12
+ }).annotate({ identifier: "Generate.File" });
13
+ export const Usage = Schema.Struct({
14
+ input: Schema.Finite.pipe(optional),
15
+ output: Schema.Finite.pipe(optional),
16
+ }).annotate({ identifier: "Generate.Usage", description: "Token counts, when the provider reports them" });
17
+ export const Native = Schema.Record(Schema.String, Schema.Unknown).annotate({
18
+ identifier: "Generate.Native",
19
+ description: "Provider-specific data the shared fields do not cover",
20
+ });
21
+ // The template literal gives clients the type; the pattern also rejects signs and exponents it would allow.
22
+ export const ImageAspect = Schema.TemplateLiteral([Schema.Number, ":", Schema.Number])
23
+ .check(Schema.isPattern(/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/))
24
+ .annotate({ identifier: "Generate.ImageAspect", description: "Aspect ratio as width:height, for example 16:9" });
25
+ export const ImageResolution = Schema.Union([
26
+ Schema.Literals(["1K", "2K", "4K"]),
27
+ Schema.String,
28
+ ]).annotate({
29
+ identifier: "Generate.ImageResolution",
30
+ description: "Size tier such as 1K, 2K or 4K; 1K is about as many pixels as 1024x1024 at the requested aspect",
31
+ });
32
+ export const ImageRequest = Schema.Struct({
33
+ model: Model.Ref,
34
+ prompt: Schema.String,
35
+ images: Schema.Array(File)
36
+ .pipe(optional)
37
+ .annotate(description("Edit sources or style and subject references, in order")),
38
+ n: PositiveInt.pipe(optional).annotate(description("Number of images to generate; defaults to 1")),
39
+ aspect: ImageAspect.pipe(optional),
40
+ resolution: ImageResolution.pipe(optional),
41
+ }).annotate({ identifier: "Generate.ImageRequest" });
42
+ export const ImageOutput = Schema.Struct({
43
+ type: Schema.Literal("image"),
44
+ ...File.fields,
45
+ }).annotate({ identifier: "Generate.ImageOutput" });
46
+ export const ImageResult = Schema.Struct({
47
+ images: Schema.Array(ImageOutput),
48
+ cost: Money.USD.pipe(optional),
49
+ tokens: Usage.pipe(optional),
50
+ native: Native.pipe(optional),
51
+ }).annotate({ identifier: "Generate.ImageResult" });
52
+ export const DecisionTextPart = Schema.Struct({ type: Schema.Literal("text"), text: Schema.String }).annotate({
53
+ identifier: "Generate.DecisionTextPart",
54
+ });
55
+ export const DecisionJsonPart = Schema.Struct({ type: Schema.Literal("json"), value: Schema.Json }).annotate({
56
+ identifier: "Generate.DecisionJsonPart",
57
+ });
58
+ export const DecisionFilePart = Schema.Struct({
59
+ type: Schema.Literal("file"),
60
+ ...File.fields,
61
+ }).annotate({ identifier: "Generate.DecisionFilePart" });
62
+ export const DecisionPart = Schema.Union([DecisionTextPart, DecisionJsonPart, DecisionFilePart]).annotate({
63
+ identifier: "Generate.DecisionPart",
64
+ });
65
+ export const ChoiceValue = Schema.Union([Schema.String, Schema.Boolean]).annotate({
66
+ identifier: "Generate.ChoiceValue",
67
+ description: 'Choice values are typed: true and "true" are different values',
68
+ });
69
+ const QuestionName = Schema.String.annotate(description("Unique within the request; echoed on the matching answer"));
70
+ export const PredicateQuestion = Schema.Struct({
71
+ type: Schema.Literal("predicate"),
72
+ name: QuestionName,
73
+ instructions: Schema.String,
74
+ }).annotate({ identifier: "Generate.PredicateQuestion", description: "The probability that a statement is true" });
75
+ export const ChoiceQuestion = Schema.Struct({
76
+ type: Schema.Literal("choice"),
77
+ name: QuestionName,
78
+ instructions: Schema.String,
79
+ choices: Schema.Array(Schema.Struct({ value: ChoiceValue, description: Schema.String.pipe(optional) })).check(Schema.isMinLength(1)),
80
+ }).annotate({ identifier: "Generate.ChoiceQuestion", description: "Pick one value from a fixed set" });
81
+ export const ScoreQuestion = Schema.Struct({
82
+ type: Schema.Literal("score"),
83
+ name: QuestionName,
84
+ instructions: Schema.String,
85
+ levels: Schema.Array(Schema.Struct({ label: Schema.String, description: Schema.String.pipe(optional) })).check(Schema.isMinLength(1)),
86
+ }).annotate({ identifier: "Generate.ScoreQuestion", description: "Place the input on ordered levels, lowest first" });
87
+ export const DecisionQuestion = Schema.Union([PredicateQuestion, ChoiceQuestion, ScoreQuestion]).annotate({
88
+ identifier: "Generate.DecisionQuestion",
89
+ });
90
+ export const DecisionRequest = Schema.Struct({
91
+ model: Model.Ref,
92
+ input: Schema.Array(DecisionPart).annotate(description("The evidence every question is asked about, in order")),
93
+ questions: Schema.Array(DecisionQuestion)
94
+ .check(Schema.isMinLength(1))
95
+ .annotate(description("Question names must be unique; duplicates fail with InvalidRequestError")),
96
+ }).annotate({ identifier: "Generate.DecisionRequest" });
97
+ const Probability = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 1 }));
98
+ export const PredicateAnswer = Schema.Struct({
99
+ type: Schema.Literal("predicate"),
100
+ name: Schema.String,
101
+ probability: Probability,
102
+ }).annotate({ identifier: "Generate.PredicateAnswer" });
103
+ export const ChoiceAnswer = Schema.Struct({
104
+ type: Schema.Literal("choice"),
105
+ name: Schema.String,
106
+ choice: ChoiceValue,
107
+ probabilities: Schema.Array(Schema.Struct({ value: ChoiceValue, probability: Probability })),
108
+ confidence: Probability,
109
+ }).annotate({ identifier: "Generate.ChoiceAnswer" });
110
+ export const ScoreAnswer = Schema.Struct({
111
+ type: Schema.Literal("score"),
112
+ name: Schema.String,
113
+ score: Schema.Finite.annotate(description("Probability-weighted level index, so it can fall between levels")),
114
+ probabilities: Schema.Array(Schema.Struct({ value: Schema.Int, label: Schema.String, probability: Probability })),
115
+ confidence: Probability,
116
+ }).annotate({ identifier: "Generate.ScoreAnswer" });
117
+ export const ErrorAnswer = Schema.Struct({
118
+ type: Schema.Literal("error"),
119
+ name: Schema.String,
120
+ reason: Schema.String.annotate(description("Why the question has no answer, for example refusal")),
121
+ message: Schema.String.pipe(optional),
122
+ }).annotate({
123
+ identifier: "Generate.ErrorAnswer",
124
+ description: "This one question has no answer; the other answers still came back",
125
+ });
126
+ export const DecisionAnswer = Schema.Union([PredicateAnswer, ChoiceAnswer, ScoreAnswer, ErrorAnswer]).annotate({
127
+ identifier: "Generate.DecisionAnswer",
128
+ });
129
+ export const DecisionResult = Schema.Struct({
130
+ answers: Schema.Array(DecisionAnswer).annotate(description("One answer per question, in question order")),
131
+ cost: Money.USD.pipe(optional),
132
+ tokens: Usage.pipe(optional),
133
+ native: Native.pipe(optional),
134
+ }).annotate({ identifier: "Generate.DecisionResult" });
package/dist/goal.d.ts ADDED
@@ -0,0 +1,126 @@
1
+ export * as Goal from "./goal.js";
2
+ import { Schema } from "effect";
3
+ export declare const Status: Schema.Literals<readonly ["active", "paused", "complete"]>;
4
+ export type Status = typeof Status.Type;
5
+ export interface State extends Schema.Schema.Type<typeof State> {
6
+ }
7
+ export declare const State: Schema.Struct<{
8
+ readonly id: Schema.String;
9
+ readonly objective: Schema.String;
10
+ readonly status: Schema.Literals<readonly ["active", "paused", "complete"]>;
11
+ /** Why the goal last changed: the reviewer's reason, or what paused it. */
12
+ readonly reason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
13
+ /** Continuations sent since the goal was set or last resumed. */
14
+ readonly rounds: Schema.Number;
15
+ /** A backstop for loops that stall detection misses. */
16
+ readonly maxRounds: Schema.Number;
17
+ /** Rounds in a row without progress: no tool calls, or the same reason as the round before. */
18
+ readonly stalls: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
19
+ /** The server process that armed the goal. */
20
+ readonly boot: Schema.String;
21
+ readonly updatedAt: Schema.Number;
22
+ }>;
23
+ /**
24
+ * The `/goal` plugin's RPC. Clients read a Session's goal with `get` and keep it current from `changed`, which the
25
+ * plugin publishes in the Session's Location on every write. A Session's goal is its own: children and forks start
26
+ * without one. The schemas are Standard Schemas too, so Promise clients can call it.
27
+ */
28
+ export declare const Definition: {
29
+ readonly id: "opencode.goal";
30
+ readonly methods: {
31
+ get: {
32
+ input: import("effect/StandardSchema").StandardSchemaV1<{
33
+ readonly sessionID: string;
34
+ }, {
35
+ readonly sessionID: string;
36
+ }> & Schema.Struct<{
37
+ readonly sessionID: Schema.String;
38
+ }>;
39
+ output: import("effect/StandardSchema").StandardSchemaV1<{
40
+ readonly id: string;
41
+ readonly objective: string;
42
+ readonly status: "active" | "complete" | "paused";
43
+ readonly reason?: string | undefined;
44
+ readonly rounds: number;
45
+ readonly maxRounds: number;
46
+ readonly stalls?: number | undefined;
47
+ readonly boot: string;
48
+ readonly updatedAt: number;
49
+ } | null, {
50
+ readonly id: string;
51
+ readonly objective: string;
52
+ readonly status: "active" | "complete" | "paused";
53
+ readonly reason?: string | undefined;
54
+ readonly rounds: number;
55
+ readonly maxRounds: number;
56
+ readonly stalls?: number | undefined;
57
+ readonly boot: string;
58
+ readonly updatedAt: number;
59
+ } | null> & Schema.NullOr<Schema.Struct<{
60
+ readonly id: Schema.String;
61
+ readonly objective: Schema.String;
62
+ readonly status: Schema.Literals<readonly ["active", "paused", "complete"]>;
63
+ /** Why the goal last changed: the reviewer's reason, or what paused it. */
64
+ readonly reason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
65
+ /** Continuations sent since the goal was set or last resumed. */
66
+ readonly rounds: Schema.Number;
67
+ /** A backstop for loops that stall detection misses. */
68
+ readonly maxRounds: Schema.Number;
69
+ /** Rounds in a row without progress: no tool calls, or the same reason as the round before. */
70
+ readonly stalls: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
71
+ /** The server process that armed the goal. */
72
+ readonly boot: Schema.String;
73
+ readonly updatedAt: Schema.Number;
74
+ }>>;
75
+ };
76
+ };
77
+ readonly events: {
78
+ changed: {
79
+ schema: import("effect/StandardSchema").StandardSchemaV1<{
80
+ readonly sessionID: string;
81
+ readonly goal: {
82
+ readonly id: string;
83
+ readonly objective: string;
84
+ readonly status: "active" | "complete" | "paused";
85
+ readonly reason?: string | undefined;
86
+ readonly rounds: number;
87
+ readonly maxRounds: number;
88
+ readonly stalls?: number | undefined;
89
+ readonly boot: string;
90
+ readonly updatedAt: number;
91
+ } | null;
92
+ }, {
93
+ readonly sessionID: string;
94
+ readonly goal: {
95
+ readonly id: string;
96
+ readonly objective: string;
97
+ readonly status: "active" | "complete" | "paused";
98
+ readonly reason?: string | undefined;
99
+ readonly rounds: number;
100
+ readonly maxRounds: number;
101
+ readonly stalls?: number | undefined;
102
+ readonly boot: string;
103
+ readonly updatedAt: number;
104
+ } | null;
105
+ }> & Schema.Struct<{
106
+ readonly sessionID: Schema.String;
107
+ readonly goal: Schema.NullOr<Schema.Struct<{
108
+ readonly id: Schema.String;
109
+ readonly objective: Schema.String;
110
+ readonly status: Schema.Literals<readonly ["active", "paused", "complete"]>;
111
+ /** Why the goal last changed: the reviewer's reason, or what paused it. */
112
+ readonly reason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
113
+ /** Continuations sent since the goal was set or last resumed. */
114
+ readonly rounds: Schema.Number;
115
+ /** A backstop for loops that stall detection misses. */
116
+ readonly maxRounds: Schema.Number;
117
+ /** Rounds in a row without progress: no tool calls, or the same reason as the round before. */
118
+ readonly stalls: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
119
+ /** The server process that armed the goal. */
120
+ readonly boot: Schema.String;
121
+ readonly updatedAt: Schema.Number;
122
+ }>>;
123
+ }>;
124
+ };
125
+ };
126
+ };
package/dist/goal.js ADDED
@@ -0,0 +1,40 @@
1
+ export * as Goal from "./goal.js";
2
+ import { Schema } from "effect";
3
+ import { Rpc } from "./rpc.js";
4
+ import { optional } from "./schema.js";
5
+ export const Status = Schema.Literals(["active", "paused", "complete"]);
6
+ export const State = Schema.Struct({
7
+ id: Schema.String,
8
+ objective: Schema.String,
9
+ status: Status,
10
+ /** Why the goal last changed: the reviewer's reason, or what paused it. */
11
+ reason: optional(Schema.String),
12
+ /** Continuations sent since the goal was set or last resumed. */
13
+ rounds: Schema.Number,
14
+ /** A backstop for loops that stall detection misses. */
15
+ maxRounds: Schema.Number,
16
+ /** Rounds in a row without progress: no tool calls, or the same reason as the round before. */
17
+ stalls: optional(Schema.Number),
18
+ /** The server process that armed the goal. */
19
+ boot: Schema.String,
20
+ updatedAt: Schema.Number,
21
+ }).annotate({ identifier: "Goal.State" });
22
+ /**
23
+ * The `/goal` plugin's RPC. Clients read a Session's goal with `get` and keep it current from `changed`, which the
24
+ * plugin publishes in the Session's Location on every write. A Session's goal is its own: children and forks start
25
+ * without one. The schemas are Standard Schemas too, so Promise clients can call it.
26
+ */
27
+ export const Definition = Rpc.define({
28
+ id: "opencode.goal",
29
+ methods: {
30
+ get: {
31
+ input: Schema.toStandardSchemaV1(Schema.Struct({ sessionID: Schema.String })),
32
+ output: Schema.toStandardSchemaV1(Schema.NullOr(State)),
33
+ },
34
+ },
35
+ events: {
36
+ changed: {
37
+ schema: Schema.toStandardSchemaV1(Schema.Struct({ sessionID: Schema.String, goal: Schema.NullOr(State) })),
38
+ },
39
+ },
40
+ });