@opencode/schema 0.0.0-dev-210 → 0.0.0-dev-220

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.
@@ -5,23 +5,43 @@ declare const Info_base: Schema.Class<Info, Schema.Struct<{
5
5
  readonly todo: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
6
6
  readonly background_compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
7
7
  readonly media_blob: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
8
- readonly image_model: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.Struct<{
9
- readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
10
- readonly model: Schema.brand<Schema.String, "Model.ID">;
11
- readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
12
- }>, Schema.Union<readonly [Schema.String, Schema.Struct<{
13
- readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
14
- readonly model: Schema.brand<Schema.String, "Model.ID">;
15
- readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
16
- }>]>, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.Struct<{
17
- readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
18
- readonly model: Schema.brand<Schema.String, "Model.ID">;
19
- readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
20
- }>, Schema.Union<readonly [Schema.String, Schema.Struct<{
21
- readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
22
- readonly model: Schema.brand<Schema.String, "Model.ID">;
23
- readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
24
- }>]>, never, never>>, never, never>;
8
+ readonly image_generate: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Boolean, Schema.Struct<{
9
+ readonly model: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.Struct<{
10
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
11
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
12
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
13
+ }>, Schema.Union<readonly [Schema.String, Schema.Struct<{
14
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
15
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
16
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
17
+ }>]>, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.Struct<{
18
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
19
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
20
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
21
+ }>, Schema.Union<readonly [Schema.String, Schema.Struct<{
22
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
23
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
24
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
25
+ }>]>, never, never>>, never, never>;
26
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Boolean, Schema.Struct<{
27
+ readonly model: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.Struct<{
28
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
29
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
30
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
31
+ }>, Schema.Union<readonly [Schema.String, Schema.Struct<{
32
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
33
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
34
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
35
+ }>]>, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.Struct<{
36
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
37
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
38
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
39
+ }>, Schema.Union<readonly [Schema.String, Schema.Struct<{
40
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID">;
41
+ readonly model: Schema.brand<Schema.String, "Model.ID">;
42
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
43
+ }>]>, never, never>>, never, never>;
44
+ }>]>>, never, never>;
25
45
  readonly schedules: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
26
46
  readonly subagent_depth: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
27
47
  readonly location_idle_timeout: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.DurationFromString, Schema.Literal<false>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.DurationFromString, Schema.Literal<false>]>>, never, never>;
@@ -16,8 +16,17 @@ export class Info extends Schema.Class("ConfigExperimental.Info")({
16
16
  media_blob: Schema.Boolean.pipe(optional).annotate({
17
17
  description: "Store new session media once in a deduplicated blob table instead of inline in every message row. Defaults to false.",
18
18
  }),
19
- image_model: ConfigModel.Selection.pipe(optional).annotate({
20
- description: "Default model for the image_generate tool when the agent doesn't choose one, as providerID/modelID. Falls back to automatic selection when it isn't available.",
19
+ image_generate: Schema.Union([
20
+ Schema.Boolean,
21
+ Schema.Struct({
22
+ model: ConfigModel.Selection.pipe(optional).annotate({
23
+ description: "Default model for the image_generate tool when the agent doesn't choose one, as providerID/modelID. Falls back to automatic selection when it isn't available.",
24
+ }),
25
+ }),
26
+ ])
27
+ .pipe(optional)
28
+ .annotate({
29
+ description: "Enable the experimental image_generate tool, offered while a connected provider has an image model. Set to true, or to an object with an optional default model. Defaults to false.",
21
30
  }),
22
31
  schedules: Schema.Boolean.pipe(optional).annotate({
23
32
  description: "Enable experimental scheduled tasks that wake a session with a prompt. Defaults to false.",
@@ -1,12 +1,13 @@
1
1
  export * as Schedule from "./schedule.js";
2
2
  import { Option, Schema } from "effect";
3
+ import { SessionID } from "./session-id.js";
3
4
  export declare const ID: Schema.brand<Schema.String, "Schedule.ID"> & {
4
5
  create: () => string & import("effect/Brand").Brand<"Schedule.ID">;
5
6
  };
6
7
  export type ID = typeof ID.Type;
7
8
  /** Milliseconds in a duration string, or `None` when it is not one. */
8
9
  export declare const durationMillis: (value: string) => Option.Option<number>;
9
- /** A duration such as "90 seconds", "5 minutes" or "2 hours". */
10
+ /** A duration such as "90 seconds", "5 minutes" or "2 hours". The service validates it, since clients cannot run a custom check. */
10
11
  export declare const DurationString: Schema.String;
11
12
  export declare const In: Schema.Struct<{
12
13
  readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
@@ -149,3 +150,71 @@ export declare const CreateInput: Schema.Struct<{
149
150
  }>]>;
150
151
  }>;
151
152
  export type CreateInput = typeof CreateInput.Type;
153
+ /** The `when` callers write: exactly one of `in`, `at`, `every` or `cron`, with an optional `tz`. */
154
+ export declare const WhenInput: Schema.Union<readonly [Schema.Struct<{
155
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
156
+ readonly in: Schema.String;
157
+ readonly at: Schema.optionalKey<Schema.Never>;
158
+ readonly every: Schema.optionalKey<Schema.Never>;
159
+ readonly cron: Schema.optionalKey<Schema.Never>;
160
+ }>, Schema.Struct<{
161
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
162
+ readonly at: Schema.String;
163
+ readonly in: Schema.optionalKey<Schema.Never>;
164
+ readonly every: Schema.optionalKey<Schema.Never>;
165
+ readonly cron: Schema.optionalKey<Schema.Never>;
166
+ }>, Schema.Struct<{
167
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
168
+ readonly every: Schema.String;
169
+ readonly in: Schema.optionalKey<Schema.Never>;
170
+ readonly at: Schema.optionalKey<Schema.Never>;
171
+ readonly cron: Schema.optionalKey<Schema.Never>;
172
+ }>, Schema.Struct<{
173
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
174
+ readonly cron: Schema.String;
175
+ readonly in: Schema.optionalKey<Schema.Never>;
176
+ readonly at: Schema.optionalKey<Schema.Never>;
177
+ readonly every: Schema.optionalKey<Schema.Never>;
178
+ }>]>;
179
+ export type WhenInput = typeof WhenInput.Type;
180
+ /** A schedule as callers describe it: when it fires, when it stops, and the prompt it wakes the Session with. */
181
+ export declare const Request: Schema.Struct<{
182
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
183
+ readonly when: Schema.Union<readonly [Schema.Struct<{
184
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
185
+ readonly in: Schema.String;
186
+ readonly at: Schema.optionalKey<Schema.Never>;
187
+ readonly every: Schema.optionalKey<Schema.Never>;
188
+ readonly cron: Schema.optionalKey<Schema.Never>;
189
+ }>, Schema.Struct<{
190
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
191
+ readonly at: Schema.String;
192
+ readonly in: Schema.optionalKey<Schema.Never>;
193
+ readonly every: Schema.optionalKey<Schema.Never>;
194
+ readonly cron: Schema.optionalKey<Schema.Never>;
195
+ }>, Schema.Struct<{
196
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
197
+ readonly every: Schema.String;
198
+ readonly in: Schema.optionalKey<Schema.Never>;
199
+ readonly at: Schema.optionalKey<Schema.Never>;
200
+ readonly cron: Schema.optionalKey<Schema.Never>;
201
+ }>, Schema.Struct<{
202
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
203
+ readonly cron: Schema.String;
204
+ readonly in: Schema.optionalKey<Schema.Never>;
205
+ readonly at: Schema.optionalKey<Schema.Never>;
206
+ readonly every: Schema.optionalKey<Schema.Never>;
207
+ }>]>;
208
+ readonly ends: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
209
+ readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
210
+ readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
211
+ readonly times: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
212
+ }>>>, Schema.optionalKey<Schema.Struct<{
213
+ readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
214
+ readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
215
+ readonly times: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
216
+ }>>, never, never>;
217
+ readonly prompt: Schema.String;
218
+ }>;
219
+ export type Request = typeof Request.Type;
220
+ export declare const toCreateInput: (sessionID: SessionID, request: Request) => CreateInput;
package/dist/schedule.js CHANGED
@@ -9,11 +9,11 @@ export const ID = Schema.String.check(Schema.isStartingWith("sch_")).pipe(Schema
9
9
  const decodeDuration = Schema.decodeUnknownOption(Schema.DurationFromString);
10
10
  /** Milliseconds in a duration string, or `None` when it is not one. */
11
11
  export const durationMillis = (value) => decodeDuration(value).pipe(Option.map(Duration.toMillis));
12
- /** A duration such as "90 seconds", "5 minutes" or "2 hours". */
13
- export const DurationString = Schema.String.check(Schema.makeFilter((value) => Option.match(durationMillis(value), {
14
- onNone: () => `expected a duration such as "5 minutes", got ${JSON.stringify(value)}`,
15
- onSome: (millis) => millis > 0 || "expected a positive duration",
16
- }))).annotate({ identifier: "Schedule.Duration" });
12
+ /** A duration such as "90 seconds", "5 minutes" or "2 hours". The service validates it, since clients cannot run a custom check. */
13
+ export const DurationString = Schema.String.annotate({
14
+ identifier: "Schedule.Duration",
15
+ description: 'A duration such as "90 seconds", "5 minutes" or "2 hours".',
16
+ });
17
17
  const zone = {
18
18
  tz: Schema.String.pipe(optional).annotate({
19
19
  description: "IANA time zone. Defaults to the configured timezone, then the server's local zone.",
@@ -70,3 +70,41 @@ export const CreateInput = Schema.Struct({
70
70
  ends: Ends.pipe(optional),
71
71
  action: Action,
72
72
  }).annotate({ identifier: "Schedule.CreateInput" });
73
+ /** Declares a trigger absent, so `{ in, every }` fails instead of decoding as a one-shot. */
74
+ const absent = Schema.optionalKey(Schema.Never);
75
+ /** The `when` callers write: exactly one of `in`, `at`, `every` or `cron`, with an optional `tz`. */
76
+ export const WhenInput = Schema.Union([
77
+ Schema.Struct({ in: In.fields.in, at: absent, every: absent, cron: absent, ...zone }),
78
+ Schema.Struct({ at: At.fields.at, in: absent, every: absent, cron: absent, ...zone }),
79
+ Schema.Struct({ every: Every.fields.every, in: absent, at: absent, cron: absent, ...zone }),
80
+ Schema.Struct({ cron: Cron.fields.cron, in: absent, at: absent, every: absent, ...zone }),
81
+ ]).annotate({ identifier: "Schedule.WhenInput" });
82
+ /** A schedule as callers describe it: when it fires, when it stops, and the prompt it wakes the Session with. */
83
+ export const Request = Schema.Struct({
84
+ name: Schema.String.pipe(optional).annotate({ description: "A short label for the schedule." }),
85
+ when: WhenInput.annotate({
86
+ description: 'When it fires: { in: "20 minutes" }, { at: "2026-10-27T09:00" }, { every: "1 hour" } or { cron: "0 9 * * 1-5" }. Wall-clock times use tz.',
87
+ }),
88
+ ends: Ends.pipe(optional).annotate({
89
+ description: 'Stops a repeating schedule at the first limit reached: { after: "8 hours" }, { at }, { times: 3 }.',
90
+ }),
91
+ prompt: Schema.String.check(Schema.isMinLength(1)).annotate({
92
+ description: "The message the Session receives each time the schedule fires.",
93
+ }),
94
+ }).annotate({ identifier: "Schedule.Request" });
95
+ export const toCreateInput = (sessionID, request) => ({
96
+ sessionID,
97
+ name: request.name,
98
+ when: toWhen(request.when),
99
+ ends: request.ends,
100
+ action: { type: "prompt", prompt: request.prompt },
101
+ });
102
+ const toWhen = (when) => {
103
+ if (when.in !== undefined)
104
+ return { type: "in", in: when.in, tz: when.tz };
105
+ if (when.at !== undefined)
106
+ return { type: "at", at: when.at, tz: when.tz };
107
+ if (when.every !== undefined)
108
+ return { type: "every", every: when.every, tz: when.tz };
109
+ return { type: "cron", cron: when.cron, tz: when.tz };
110
+ };
@@ -5,3 +5,5 @@ export declare function event(type: string, data: unknown): unknown;
5
5
  export declare function message(type: unknown, data: Record<string, unknown>): Record<string, unknown>;
6
6
  /** Upgrades complete messages, such as those in an exported session, before decoding. */
7
7
  export declare function messages(values: ReadonlyArray<unknown>): unknown[];
8
+ /** Upgrades an assistant content part written before v2.1. */
9
+ export declare function part(value: unknown): unknown;
@@ -47,7 +47,8 @@ function content(data) {
47
47
  return data;
48
48
  return { ...data, content: data.content.map(part) };
49
49
  }
50
- function part(value) {
50
+ /** Upgrades an assistant content part written before v2.1. */
51
+ export function part(value) {
51
52
  if (!isRecord(value))
52
53
  return value;
53
54
  if (value.type === "text" || value.type === "reasoning")
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/schema",
4
- "version": "0.0.0-dev-210",
4
+ "version": "0.0.0-dev-220",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {