@opencode/schema 2.2.0 → 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.
@@ -5,6 +5,44 @@ 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_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>;
45
+ readonly schedules: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
8
46
  readonly subagent_depth: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
9
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>;
10
48
  readonly policies: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
@@ -1,6 +1,7 @@
1
1
  export * as ConfigExperimental from "./experimental.js";
2
2
  import { Schema } from "effect";
3
3
  import { NonNegativeInt, optional } from "../schema.js";
4
+ import { ConfigModel } from "./model.js";
4
5
  import { ConfigPolicy } from "./policy.js";
5
6
  export class Info extends Schema.Class("ConfigExperimental.Info")({
6
7
  portable_shell_scanner: Schema.Boolean.pipe(optional).annotate({
@@ -15,6 +16,21 @@ export class Info extends Schema.Class("ConfigExperimental.Info")({
15
16
  media_blob: Schema.Boolean.pipe(optional).annotate({
16
17
  description: "Store new session media once in a deduplicated blob table instead of inline in every message row. Defaults to false.",
17
18
  }),
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.",
30
+ }),
31
+ schedules: Schema.Boolean.pipe(optional).annotate({
32
+ description: "Enable experimental scheduled tasks that wake a session with a prompt. Defaults to false.",
33
+ }),
18
34
  subagent_depth: NonNegativeInt.pipe(optional).annotate({
19
35
  description: "Maximum subagent nesting depth. Defaults to 1.",
20
36
  }),
@@ -279,6 +279,9 @@ declare const ModelConfig_base: Schema.Class<ModelConfig, Schema.Struct<{
279
279
  }>]>>, never, never>;
280
280
  }>>, never, never>;
281
281
  readonly variants: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
282
+ readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
283
+ readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>, never, never>;
284
+ readonly id: Schema.brand<Schema.String, "Model.VariantID">;
282
285
  readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
283
286
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
284
287
  readonly type: Schema.Literal<"summary">;
@@ -289,11 +292,6 @@ declare const ModelConfig_base: Schema.Class<ModelConfig, Schema.Struct<{
289
292
  }>, Schema.Struct<{
290
293
  readonly type: Schema.Literal<"native">;
291
294
  }>]>>, never, never>;
292
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
293
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
294
- }>>>, Schema.optionalKey<Schema.Struct<{
295
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
296
- }>>, never, never>;
297
295
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
298
296
  }>, readonly [Schema.$Record<Schema.String, Schema.UndefinedOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>]>>>, Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
299
297
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
@@ -305,17 +303,12 @@ declare const ModelConfig_base: Schema.Class<ModelConfig, Schema.Struct<{
305
303
  }>, Schema.Struct<{
306
304
  readonly type: Schema.Literal<"native">;
307
305
  }>]>>, never, never>;
308
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
309
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
310
- }>>>, Schema.optionalKey<Schema.Struct<{
311
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
312
- }>>, never, never>;
313
306
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
314
307
  }>, readonly [Schema.$Record<Schema.String, Schema.UndefinedOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>]>>, never, never>;
308
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
315
309
  readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
316
310
  readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>, never, never>;
317
311
  readonly id: Schema.brand<Schema.String, "Model.VariantID">;
318
- }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
319
312
  readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
320
313
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
321
314
  readonly type: Schema.Literal<"summary">;
@@ -326,11 +319,6 @@ declare const ModelConfig_base: Schema.Class<ModelConfig, Schema.Struct<{
326
319
  }>, Schema.Struct<{
327
320
  readonly type: Schema.Literal<"native">;
328
321
  }>]>>, never, never>;
329
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
330
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
331
- }>>>, Schema.optionalKey<Schema.Struct<{
332
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
333
- }>>, never, never>;
334
322
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
335
323
  }>, readonly [Schema.$Record<Schema.String, Schema.UndefinedOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>]>>>, Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
336
324
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
@@ -342,16 +330,8 @@ declare const ModelConfig_base: Schema.Class<ModelConfig, Schema.Struct<{
342
330
  }>, Schema.Struct<{
343
331
  readonly type: Schema.Literal<"native">;
344
332
  }>]>>, never, never>;
345
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
346
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
347
- }>>>, Schema.optionalKey<Schema.Struct<{
348
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
349
- }>>, never, never>;
350
333
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
351
334
  }>, readonly [Schema.$Record<Schema.String, Schema.UndefinedOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>]>>, never, never>;
352
- readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
353
- readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>, never, never>;
354
- readonly id: Schema.brand<Schema.String, "Model.VariantID">;
355
335
  }>>>, never, never>;
356
336
  readonly cost: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [typeof Cost, Schema.$Array<typeof Cost>]>>>, Schema.optionalKey<Schema.Union<readonly [typeof Cost, Schema.$Array<typeof Cost>]>>, never, never>;
357
337
  readonly disabled: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
@@ -1,5 +1,5 @@
1
1
  export * as ConfigProvider from "./provider.js";
2
- import { Schema } from "effect";
2
+ import { Schema, Struct } from "effect";
3
3
  import { Money } from "../money.js";
4
4
  import { Capabilities, Compatibility, Family, ID, Model, Type, VariantID } from "../model.js";
5
5
  import { ProviderCompatibility } from "../model-compatibility.js";
@@ -85,6 +85,10 @@ class ModelConfig extends Schema.Class("Config.Model")({
85
85
  variants: Schema.Struct({
86
86
  id: VariantID,
87
87
  ...ModelOverlays,
88
+ // The prompt cache belongs to the model, so a variant can't change it.
89
+ settings: Schema.StructWithRest(Schema.Struct(Struct.omit(ModelSettings.schema.fields, ["cache"])), ModelSettings.records)
90
+ .annotate({ identifier: "Config.Model.VariantSettings" })
91
+ .pipe(optional),
88
92
  }).pipe(Schema.Array, optional),
89
93
  cost: Schema.Union([Cost, Cost.pipe(Schema.Array)]).pipe(optional),
90
94
  disabled: Schema.Boolean.pipe(optional),
package/dist/config.d.ts CHANGED
@@ -44,6 +44,7 @@ declare const Info_base: Schema.Class<Info, Schema.Struct<{
44
44
  readonly url: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
45
45
  }>>, never, never>;
46
46
  readonly username: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
47
+ readonly timezone: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
47
48
  readonly permissions: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
48
49
  readonly action: Schema.String;
49
50
  readonly resource: Schema.String;
package/dist/config.js CHANGED
@@ -50,6 +50,9 @@ export class Info extends Schema.Class("Config.Info")({
50
50
  username: Schema.String.pipe(optional).annotate({
51
51
  description: "Username displayed in conversations and used for telemetry identity",
52
52
  }),
53
+ timezone: Schema.String.pipe(optional).annotate({
54
+ description: "IANA time zone for schedules, e.g. America/Los_Angeles. Defaults to the server's local zone",
55
+ }),
53
56
  permissions: Permission.Ruleset.pipe(optional).annotate({
54
57
  description: "Ordered tool permission rules applied to agent tool use",
55
58
  }),
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
+ });
package/dist/model.d.ts CHANGED
@@ -203,6 +203,9 @@ export declare const Cost: Schema.Struct<{
203
203
  export interface Variant extends Schema.Schema.Type<typeof Variant> {
204
204
  }
205
205
  export declare const Variant: Schema.Struct<{
206
+ readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
207
+ readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Any>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Any>>, never, never>;
208
+ readonly id: Schema.brand<Schema.String, "Model.VariantID">;
206
209
  readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
207
210
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
208
211
  readonly type: Schema.Literal<"summary">;
@@ -213,11 +216,6 @@ export declare const Variant: Schema.Struct<{
213
216
  }>, Schema.Struct<{
214
217
  readonly type: Schema.Literal<"native">;
215
218
  }>]>>, never, never>;
216
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
217
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
218
- }>>>, Schema.optionalKey<Schema.Struct<{
219
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
220
- }>>, never, never>;
221
219
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
222
220
  }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>>, Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
223
221
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
@@ -229,16 +227,8 @@ export declare const Variant: Schema.Struct<{
229
227
  }>, Schema.Struct<{
230
228
  readonly type: Schema.Literal<"native">;
231
229
  }>]>>, never, never>;
232
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
233
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
234
- }>>>, Schema.optionalKey<Schema.Struct<{
235
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
236
- }>>, never, never>;
237
230
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
238
231
  }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>, never, never>;
239
- readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
240
- readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Any>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Any>>, never, never>;
241
- readonly id: Schema.brand<Schema.String, "Model.VariantID">;
242
232
  }>;
243
233
  export interface Info extends Schema.Schema.Type<typeof Info> {
244
234
  }
@@ -361,6 +351,9 @@ export declare const Info: Schema.Struct<{
361
351
  };
362
352
  };
363
353
  readonly variants: Schema.$Array<Schema.Struct<{
354
+ readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
355
+ readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Any>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Any>>, never, never>;
356
+ readonly id: Schema.brand<Schema.String, "Model.VariantID">;
364
357
  readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
365
358
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
366
359
  readonly type: Schema.Literal<"summary">;
@@ -371,11 +364,6 @@ export declare const Info: Schema.Struct<{
371
364
  }>, Schema.Struct<{
372
365
  readonly type: Schema.Literal<"native">;
373
366
  }>]>>, never, never>;
374
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
375
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
376
- }>>>, Schema.optionalKey<Schema.Struct<{
377
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
378
- }>>, never, never>;
379
367
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
380
368
  }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>>, Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
381
369
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
@@ -387,16 +375,8 @@ export declare const Info: Schema.Struct<{
387
375
  }>, Schema.Struct<{
388
376
  readonly type: Schema.Literal<"native">;
389
377
  }>]>>, never, never>;
390
- readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
391
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
392
- }>>>, Schema.optionalKey<Schema.Struct<{
393
- readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
394
- }>>, never, never>;
395
378
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
396
379
  }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>, never, never>;
397
- readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
398
- readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Any>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Any>>, never, never>;
399
- readonly id: Schema.brand<Schema.String, "Model.VariantID">;
400
380
  }>>;
401
381
  readonly time: Schema.Struct<{
402
382
  readonly released: Schema.Finite;
package/dist/model.js CHANGED
@@ -42,6 +42,8 @@ export const Type = Schema.Union([
42
42
  export const Settings = Schema.StructWithRest(Schema.Struct(Struct.pick(Provider.Settings.schema.fields, ["compaction", "cache", "encoding"])),
43
43
  // Provider packages may define arbitrary model-level options beyond OpenCode's shared compaction policy.
44
44
  [Schema.Record(Schema.String, Schema.Any)]).annotate({ identifier: "Model.Settings" });
45
+ // Variants switch request settings. The prompt cache belongs to the model, so a variant can't change it.
46
+ const VariantSettings = Schema.StructWithRest(Schema.Struct(Struct.omit(Settings.schema.fields, ["cache"])), Settings.records).annotate({ identifier: "Model.VariantSettings" });
45
47
  export const Overlays = {
46
48
  settings: Settings.pipe(optional),
47
49
  headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
@@ -73,6 +75,7 @@ export const Cost = Schema.Struct({
73
75
  export const Variant = Schema.Struct({
74
76
  id: VariantID,
75
77
  ...Overlays,
78
+ settings: VariantSettings.pipe(optional),
76
79
  }).annotate({ identifier: "Model.Variant" });
77
80
  export const Info = Schema.Struct({
78
81
  id: ID,
@@ -0,0 +1,220 @@
1
+ export * as Schedule from "./schedule.js";
2
+ import { Option, Schema } from "effect";
3
+ import { SessionID } from "./session-id.js";
4
+ export declare const ID: Schema.brand<Schema.String, "Schedule.ID"> & {
5
+ create: () => string & import("effect/Brand").Brand<"Schedule.ID">;
6
+ };
7
+ export type ID = typeof ID.Type;
8
+ /** Milliseconds in a duration string, or `None` when it is not one. */
9
+ export declare const durationMillis: (value: string) => Option.Option<number>;
10
+ /** A duration such as "90 seconds", "5 minutes" or "2 hours". The service validates it, since clients cannot run a custom check. */
11
+ export declare const DurationString: Schema.String;
12
+ export declare const In: Schema.Struct<{
13
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
14
+ readonly type: Schema.tag<"in">;
15
+ readonly in: Schema.String;
16
+ }>;
17
+ /** An instant with an offset, or a wall-clock time in `tz`, e.g. "2026-10-27T09:00". */
18
+ export declare const At: Schema.Struct<{
19
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
20
+ readonly type: Schema.tag<"at">;
21
+ readonly at: Schema.String;
22
+ }>;
23
+ export declare const Every: Schema.Struct<{
24
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
25
+ readonly type: Schema.tag<"every">;
26
+ readonly every: Schema.String;
27
+ }>;
28
+ export declare const Cron: Schema.Struct<{
29
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
30
+ readonly type: Schema.tag<"cron">;
31
+ readonly cron: Schema.String;
32
+ }>;
33
+ export declare const When: Schema.Union<readonly [Schema.Struct<{
34
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
35
+ readonly type: Schema.tag<"in">;
36
+ readonly in: Schema.String;
37
+ }>, Schema.Struct<{
38
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
39
+ readonly type: Schema.tag<"at">;
40
+ readonly at: Schema.String;
41
+ }>, Schema.Struct<{
42
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
43
+ readonly type: Schema.tag<"every">;
44
+ readonly every: Schema.String;
45
+ }>, Schema.Struct<{
46
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
47
+ readonly type: Schema.tag<"cron">;
48
+ readonly cron: Schema.String;
49
+ }>]>;
50
+ export type When = typeof When.Type;
51
+ /** Stops a repeating schedule at whichever limit comes first. */
52
+ export declare const Ends: Schema.Struct<{
53
+ readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
54
+ readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
55
+ readonly times: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
56
+ }>;
57
+ export type Ends = typeof Ends.Type;
58
+ export declare const PromptAction: Schema.Struct<{
59
+ readonly type: Schema.tag<"prompt">;
60
+ readonly prompt: Schema.String;
61
+ }>;
62
+ export declare const Action: Schema.Union<readonly [Schema.Struct<{
63
+ readonly type: Schema.tag<"prompt">;
64
+ readonly prompt: Schema.String;
65
+ }>]>;
66
+ export type Action = typeof Action.Type;
67
+ export declare const Status: Schema.Literals<readonly ["active", "paused", "done"]>;
68
+ export type Status = typeof Status.Type;
69
+ export declare const Outcome: Schema.Literals<readonly ["fired", "late", "skipped", "disabled", "failed"]>;
70
+ export type Outcome = typeof Outcome.Type;
71
+ export declare const Info: Schema.Struct<{
72
+ readonly id: Schema.brand<Schema.String, "Schedule.ID"> & {
73
+ create: () => string & import("effect/Brand").Brand<"Schedule.ID">;
74
+ };
75
+ readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
76
+ create: () => string & import("effect/Brand").Brand<"SessionID">;
77
+ }>>, Schema.optionalKey<Schema.brand<Schema.String, "SessionID"> & {
78
+ create: () => string & import("effect/Brand").Brand<"SessionID">;
79
+ }>, never, never>;
80
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
81
+ readonly when: Schema.Union<readonly [Schema.Struct<{
82
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
83
+ readonly type: Schema.tag<"in">;
84
+ readonly in: Schema.String;
85
+ }>, Schema.Struct<{
86
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
87
+ readonly type: Schema.tag<"at">;
88
+ readonly at: Schema.String;
89
+ }>, Schema.Struct<{
90
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
91
+ readonly type: Schema.tag<"every">;
92
+ readonly every: Schema.String;
93
+ }>, Schema.Struct<{
94
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
95
+ readonly type: Schema.tag<"cron">;
96
+ readonly cron: Schema.String;
97
+ }>]>;
98
+ readonly tz: Schema.String;
99
+ readonly action: Schema.Union<readonly [Schema.Struct<{
100
+ readonly type: Schema.tag<"prompt">;
101
+ readonly prompt: Schema.String;
102
+ }>]>;
103
+ readonly status: Schema.Literals<readonly ["active", "paused", "done"]>;
104
+ readonly nextDueAt: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
105
+ readonly endsAt: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
106
+ readonly remainingRuns: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
107
+ readonly runCount: Schema.Int;
108
+ readonly lastFiredAt: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
109
+ readonly lastOutcome: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["fired", "late", "skipped", "disabled", "failed"]>>>, Schema.optionalKey<Schema.Literals<readonly ["fired", "late", "skipped", "disabled", "failed"]>>, never, never>;
110
+ readonly time: Schema.Struct<{
111
+ readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
112
+ readonly updated: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
113
+ }>;
114
+ }>;
115
+ export type Info = typeof Info.Type;
116
+ export declare const CreateInput: Schema.Struct<{
117
+ readonly sessionID: Schema.brand<Schema.String, "SessionID"> & {
118
+ create: () => string & import("effect/Brand").Brand<"SessionID">;
119
+ };
120
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
121
+ readonly when: Schema.Union<readonly [Schema.Struct<{
122
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
123
+ readonly type: Schema.tag<"in">;
124
+ readonly in: Schema.String;
125
+ }>, Schema.Struct<{
126
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
127
+ readonly type: Schema.tag<"at">;
128
+ readonly at: Schema.String;
129
+ }>, Schema.Struct<{
130
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
131
+ readonly type: Schema.tag<"every">;
132
+ readonly every: Schema.String;
133
+ }>, Schema.Struct<{
134
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
135
+ readonly type: Schema.tag<"cron">;
136
+ readonly cron: Schema.String;
137
+ }>]>;
138
+ readonly ends: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
139
+ readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
140
+ readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
141
+ readonly times: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
142
+ }>>>, Schema.optionalKey<Schema.Struct<{
143
+ readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
144
+ readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
145
+ readonly times: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
146
+ }>>, never, never>;
147
+ readonly action: Schema.Union<readonly [Schema.Struct<{
148
+ readonly type: Schema.tag<"prompt">;
149
+ readonly prompt: Schema.String;
150
+ }>]>;
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;
@@ -0,0 +1,110 @@
1
+ export * as Schedule from "./schedule.js";
2
+ import { Duration, Option, Schema } from "effect";
3
+ import { ascending } from "./identifier.js";
4
+ import { DateTimeUtcFromMillis, NonNegativeInt, PositiveInt, optional, statics } from "./schema.js";
5
+ import { SessionID } from "./session-id.js";
6
+ export const ID = Schema.String.check(Schema.isStartingWith("sch_")).pipe(Schema.brand("Schedule.ID"), Schema.annotate({ identifier: "Schedule.ID" }), statics((schema) => ({
7
+ create: () => schema.make("sch_" + ascending()),
8
+ })));
9
+ const decodeDuration = Schema.decodeUnknownOption(Schema.DurationFromString);
10
+ /** Milliseconds in a duration string, or `None` when it is not one. */
11
+ export const durationMillis = (value) => decodeDuration(value).pipe(Option.map(Duration.toMillis));
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
+ const zone = {
18
+ tz: Schema.String.pipe(optional).annotate({
19
+ description: "IANA time zone. Defaults to the configured timezone, then the server's local zone.",
20
+ }),
21
+ };
22
+ export const In = Schema.Struct({ type: Schema.tag("in"), in: DurationString, ...zone }).annotate({
23
+ identifier: "Schedule.When.In",
24
+ });
25
+ /** An instant with an offset, or a wall-clock time in `tz`, e.g. "2026-10-27T09:00". */
26
+ export const At = Schema.Struct({ type: Schema.tag("at"), at: Schema.String, ...zone }).annotate({
27
+ identifier: "Schedule.When.At",
28
+ });
29
+ export const Every = Schema.Struct({ type: Schema.tag("every"), every: DurationString, ...zone }).annotate({
30
+ identifier: "Schedule.When.Every",
31
+ });
32
+ export const Cron = Schema.Struct({ type: Schema.tag("cron"), cron: Schema.String, ...zone }).annotate({
33
+ identifier: "Schedule.When.Cron",
34
+ });
35
+ export const When = Schema.Union([In, At, Every, Cron]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Schedule.When" }));
36
+ /** Stops a repeating schedule at whichever limit comes first. */
37
+ export const Ends = Schema.Struct({
38
+ after: DurationString.pipe(optional),
39
+ at: Schema.String.pipe(optional),
40
+ times: PositiveInt.pipe(optional),
41
+ }).annotate({ identifier: "Schedule.Ends" });
42
+ export const PromptAction = Schema.Struct({ type: Schema.tag("prompt"), prompt: Schema.String }).annotate({
43
+ identifier: "Schedule.Action.Prompt",
44
+ });
45
+ export const Action = Schema.Union([PromptAction]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Schedule.Action" }));
46
+ export const Status = Schema.Literals(["active", "paused", "done"]).annotate({ identifier: "Schedule.Status" });
47
+ export const Outcome = Schema.Literals(["fired", "late", "skipped", "disabled", "failed"]).annotate({
48
+ identifier: "Schedule.Outcome",
49
+ });
50
+ export const Info = Schema.Struct({
51
+ id: ID,
52
+ sessionID: SessionID.pipe(optional),
53
+ name: Schema.String.pipe(optional),
54
+ when: When,
55
+ tz: Schema.String,
56
+ action: Action,
57
+ status: Status,
58
+ nextDueAt: DateTimeUtcFromMillis.pipe(optional),
59
+ endsAt: DateTimeUtcFromMillis.pipe(optional),
60
+ remainingRuns: NonNegativeInt.pipe(optional),
61
+ runCount: NonNegativeInt,
62
+ lastFiredAt: DateTimeUtcFromMillis.pipe(optional),
63
+ lastOutcome: Outcome.pipe(optional),
64
+ time: Schema.Struct({ created: DateTimeUtcFromMillis, updated: DateTimeUtcFromMillis }),
65
+ }).annotate({ identifier: "Schedule.Info" });
66
+ export const CreateInput = Schema.Struct({
67
+ sessionID: SessionID,
68
+ name: Schema.String.pipe(optional),
69
+ when: When,
70
+ ends: Ends.pipe(optional),
71
+ action: Action,
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
+ };
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": "2.2.0",
4
+ "version": "2.2.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {