@opencode/schema 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/provider.js CHANGED
@@ -11,6 +11,7 @@ export const ID = Schema.String.pipe(Schema.brand("Provider.ID"), Schema.annotat
11
11
  google: schema.make("google"),
12
12
  googleVertex: schema.make("google-vertex"),
13
13
  githubCopilot: schema.make("github-copilot"),
14
+ claudeAgent: schema.make("claude-agent"),
14
15
  amazonBedrock: schema.make("amazon-bedrock"),
15
16
  azure: schema.make("azure"),
16
17
  openrouter: schema.make("openrouter"),
@@ -64,9 +64,61 @@ export declare const Action: Schema.Union<readonly [Schema.Struct<{
64
64
  readonly prompt: Schema.String;
65
65
  }>]>;
66
66
  export type Action = typeof Action.Type;
67
+ /**
68
+ * Runs `run` in the Session's directory before firing, with no model call. With none of `is`, `matches` or `changes`
69
+ * set, exit 0 wakes and any non-zero exit is "not yet". With `is`, `matches` or `changes`, non-zero exit is a check
70
+ * error, and exit 0 wakes when trimmed stdout equals `is`, stdout matches `matches`, or stdout differs from the
71
+ * previous run (`changes`).
72
+ */
73
+ export declare const ShellCondition: Schema.Struct<{
74
+ readonly type: Schema.tag<"shell">;
75
+ readonly run: Schema.String;
76
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
77
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
78
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
79
+ }>;
80
+ export type ShellCondition = typeof ShellCondition.Type;
81
+ /**
82
+ * Runs `code` in a confined Code Mode runtime before firing, with no model call and no `fetch`. Tools called statically
83
+ * as `tools.<path>(...)` are extracted from the AST and authorized at creation; the program receives `state` (initially
84
+ * `null`), `now` (epoch ms) and `runs` (completed checks), and returns a boolean or `{ wake, state?, message? }`.
85
+ */
86
+ export declare const CodeCondition: Schema.Struct<{
87
+ readonly type: Schema.tag<"code">;
88
+ readonly code: Schema.String;
89
+ }>;
90
+ export type CodeCondition = typeof CodeCondition.Type;
91
+ /** Checked before firing; the schedule wakes the Session only when the condition passes. */
92
+ export declare const Condition: Schema.Union<readonly [Schema.Struct<{
93
+ readonly type: Schema.tag<"shell">;
94
+ readonly run: Schema.String;
95
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
96
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
97
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
98
+ }>, Schema.Struct<{
99
+ readonly type: Schema.tag<"code">;
100
+ readonly code: Schema.String;
101
+ }>]>;
102
+ export type Condition = typeof Condition.Type;
103
+ export declare const CheckMode: Schema.Literals<readonly ["if", "until"]>;
104
+ export type CheckMode = typeof CheckMode.Type;
105
+ export declare const StoredCheck: Schema.Struct<{
106
+ readonly mode: Schema.Literals<readonly ["if", "until"]>;
107
+ readonly condition: Schema.Union<readonly [Schema.Struct<{
108
+ readonly type: Schema.tag<"shell">;
109
+ readonly run: Schema.String;
110
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
111
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
112
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
113
+ }>, Schema.Struct<{
114
+ readonly type: Schema.tag<"code">;
115
+ readonly code: Schema.String;
116
+ }>]>;
117
+ }>;
118
+ export type StoredCheck = typeof StoredCheck.Type;
67
119
  export declare const Status: Schema.Literals<readonly ["active", "paused", "done"]>;
68
120
  export type Status = typeof Status.Type;
69
- export declare const Outcome: Schema.Literals<readonly ["fired", "late", "skipped", "disabled", "failed"]>;
121
+ export declare const Outcome: Schema.Literals<readonly ["fired", "late", "checked", "expired", "skipped", "disabled", "failed"]>;
70
122
  export type Outcome = typeof Outcome.Type;
71
123
  export declare const Info: Schema.Struct<{
72
124
  readonly id: Schema.brand<Schema.String, "Schedule.ID"> & {
@@ -96,6 +148,44 @@ export declare const Info: Schema.Struct<{
96
148
  readonly cron: Schema.String;
97
149
  }>]>;
98
150
  readonly tz: Schema.String;
151
+ readonly if: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
152
+ readonly type: Schema.tag<"shell">;
153
+ readonly run: Schema.String;
154
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
155
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
156
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
157
+ }>, Schema.Struct<{
158
+ readonly type: Schema.tag<"code">;
159
+ readonly code: Schema.String;
160
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
161
+ readonly type: Schema.tag<"shell">;
162
+ readonly run: Schema.String;
163
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
164
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
165
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
166
+ }>, Schema.Struct<{
167
+ readonly type: Schema.tag<"code">;
168
+ readonly code: Schema.String;
169
+ }>]>>, never, never>;
170
+ readonly until: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
171
+ readonly type: Schema.tag<"shell">;
172
+ readonly run: Schema.String;
173
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
174
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
175
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
176
+ }>, Schema.Struct<{
177
+ readonly type: Schema.tag<"code">;
178
+ readonly code: Schema.String;
179
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
180
+ readonly type: Schema.tag<"shell">;
181
+ readonly run: Schema.String;
182
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
183
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
184
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
185
+ }>, Schema.Struct<{
186
+ readonly type: Schema.tag<"code">;
187
+ readonly code: Schema.String;
188
+ }>]>>, never, never>;
99
189
  readonly action: Schema.Union<readonly [Schema.Struct<{
100
190
  readonly type: Schema.tag<"prompt">;
101
191
  readonly prompt: Schema.String;
@@ -106,7 +196,8 @@ export declare const Info: Schema.Struct<{
106
196
  readonly remainingRuns: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
107
197
  readonly runCount: Schema.Int;
108
198
  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>;
199
+ readonly lastOutcome: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["fired", "late", "checked", "expired", "skipped", "disabled", "failed"]>>>, Schema.optionalKey<Schema.Literals<readonly ["fired", "late", "checked", "expired", "skipped", "disabled", "failed"]>>, never, never>;
200
+ readonly lastOutput: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
110
201
  readonly time: Schema.Struct<{
111
202
  readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
112
203
  readonly updated: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
@@ -118,7 +209,7 @@ export declare const CreateInput: Schema.Struct<{
118
209
  create: () => string & import("effect/Brand").Brand<"SessionID">;
119
210
  };
120
211
  readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
121
- readonly when: Schema.Union<readonly [Schema.Struct<{
212
+ readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
122
213
  readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
123
214
  readonly type: Schema.tag<"in">;
124
215
  readonly in: Schema.String;
@@ -134,7 +225,61 @@ export declare const CreateInput: Schema.Struct<{
134
225
  readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
135
226
  readonly type: Schema.tag<"cron">;
136
227
  readonly cron: Schema.String;
137
- }>]>;
228
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
229
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
230
+ readonly type: Schema.tag<"in">;
231
+ readonly in: Schema.String;
232
+ }>, Schema.Struct<{
233
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
234
+ readonly type: Schema.tag<"at">;
235
+ readonly at: Schema.String;
236
+ }>, Schema.Struct<{
237
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
238
+ readonly type: Schema.tag<"every">;
239
+ readonly every: Schema.String;
240
+ }>, Schema.Struct<{
241
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
242
+ readonly type: Schema.tag<"cron">;
243
+ readonly cron: Schema.String;
244
+ }>]>>, never, never>;
245
+ readonly if: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
246
+ readonly type: Schema.tag<"shell">;
247
+ readonly run: Schema.String;
248
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
249
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
250
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
251
+ }>, Schema.Struct<{
252
+ readonly type: Schema.tag<"code">;
253
+ readonly code: Schema.String;
254
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
255
+ readonly type: Schema.tag<"shell">;
256
+ readonly run: Schema.String;
257
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
258
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
259
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
260
+ }>, Schema.Struct<{
261
+ readonly type: Schema.tag<"code">;
262
+ readonly code: Schema.String;
263
+ }>]>>, never, never>;
264
+ readonly until: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
265
+ readonly type: Schema.tag<"shell">;
266
+ readonly run: Schema.String;
267
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
268
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
269
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
270
+ }>, Schema.Struct<{
271
+ readonly type: Schema.tag<"code">;
272
+ readonly code: Schema.String;
273
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
274
+ readonly type: Schema.tag<"shell">;
275
+ readonly run: Schema.String;
276
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
277
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
278
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
279
+ }>, Schema.Struct<{
280
+ readonly type: Schema.tag<"code">;
281
+ readonly code: Schema.String;
282
+ }>]>>, never, never>;
138
283
  readonly ends: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
139
284
  readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
140
285
  readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
@@ -177,10 +322,33 @@ export declare const WhenInput: Schema.Union<readonly [Schema.Struct<{
177
322
  readonly every: Schema.optionalKey<Schema.Never>;
178
323
  }>]>;
179
324
  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. */
325
+ export declare const ShellConditionInput: Schema.Struct<{
326
+ readonly run: Schema.String;
327
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
328
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
329
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
330
+ }>;
331
+ export declare const CodeConditionInput: Schema.Struct<{
332
+ readonly code: Schema.String;
333
+ }>;
334
+ export declare const ConditionInput: Schema.Union<readonly [Schema.Struct<{
335
+ readonly run: Schema.String;
336
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
337
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
338
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
339
+ readonly code: Schema.optionalKey<Schema.Never>;
340
+ }>, Schema.Struct<{
341
+ readonly code: Schema.String;
342
+ readonly run: Schema.optionalKey<Schema.Never>;
343
+ readonly is: Schema.optionalKey<Schema.Never>;
344
+ readonly matches: Schema.optionalKey<Schema.Never>;
345
+ readonly changes: Schema.optionalKey<Schema.Never>;
346
+ }>]>;
347
+ export type ConditionInput = typeof ConditionInput.Type;
348
+ /** A schedule as callers describe it: when it fires, optional condition, when it stops, and the prompt it sends. */
181
349
  export declare const Request: Schema.Struct<{
182
350
  readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
183
- readonly when: Schema.Union<readonly [Schema.Struct<{
351
+ readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
184
352
  readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
185
353
  readonly in: Schema.String;
186
354
  readonly at: Schema.optionalKey<Schema.Never>;
@@ -204,7 +372,81 @@ export declare const Request: Schema.Struct<{
204
372
  readonly in: Schema.optionalKey<Schema.Never>;
205
373
  readonly at: Schema.optionalKey<Schema.Never>;
206
374
  readonly every: Schema.optionalKey<Schema.Never>;
207
- }>]>;
375
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
376
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
377
+ readonly in: Schema.String;
378
+ readonly at: Schema.optionalKey<Schema.Never>;
379
+ readonly every: Schema.optionalKey<Schema.Never>;
380
+ readonly cron: Schema.optionalKey<Schema.Never>;
381
+ }>, Schema.Struct<{
382
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
383
+ readonly at: Schema.String;
384
+ readonly in: Schema.optionalKey<Schema.Never>;
385
+ readonly every: Schema.optionalKey<Schema.Never>;
386
+ readonly cron: Schema.optionalKey<Schema.Never>;
387
+ }>, Schema.Struct<{
388
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
389
+ readonly every: Schema.String;
390
+ readonly in: Schema.optionalKey<Schema.Never>;
391
+ readonly at: Schema.optionalKey<Schema.Never>;
392
+ readonly cron: Schema.optionalKey<Schema.Never>;
393
+ }>, Schema.Struct<{
394
+ readonly tz: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
395
+ readonly cron: Schema.String;
396
+ readonly in: Schema.optionalKey<Schema.Never>;
397
+ readonly at: Schema.optionalKey<Schema.Never>;
398
+ readonly every: Schema.optionalKey<Schema.Never>;
399
+ }>]>>, never, never>;
400
+ readonly if: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
401
+ readonly run: Schema.String;
402
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
403
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
404
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
405
+ readonly code: Schema.optionalKey<Schema.Never>;
406
+ }>, Schema.Struct<{
407
+ readonly code: Schema.String;
408
+ readonly run: Schema.optionalKey<Schema.Never>;
409
+ readonly is: Schema.optionalKey<Schema.Never>;
410
+ readonly matches: Schema.optionalKey<Schema.Never>;
411
+ readonly changes: Schema.optionalKey<Schema.Never>;
412
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
413
+ readonly run: Schema.String;
414
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
415
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
416
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
417
+ readonly code: Schema.optionalKey<Schema.Never>;
418
+ }>, Schema.Struct<{
419
+ readonly code: Schema.String;
420
+ readonly run: Schema.optionalKey<Schema.Never>;
421
+ readonly is: Schema.optionalKey<Schema.Never>;
422
+ readonly matches: Schema.optionalKey<Schema.Never>;
423
+ readonly changes: Schema.optionalKey<Schema.Never>;
424
+ }>]>>, never, never>;
425
+ readonly until: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
426
+ readonly run: Schema.String;
427
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
428
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
429
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
430
+ readonly code: Schema.optionalKey<Schema.Never>;
431
+ }>, Schema.Struct<{
432
+ readonly code: Schema.String;
433
+ readonly run: Schema.optionalKey<Schema.Never>;
434
+ readonly is: Schema.optionalKey<Schema.Never>;
435
+ readonly matches: Schema.optionalKey<Schema.Never>;
436
+ readonly changes: Schema.optionalKey<Schema.Never>;
437
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
438
+ readonly run: Schema.String;
439
+ readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
440
+ readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
441
+ readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
442
+ readonly code: Schema.optionalKey<Schema.Never>;
443
+ }>, Schema.Struct<{
444
+ readonly code: Schema.String;
445
+ readonly run: Schema.optionalKey<Schema.Never>;
446
+ readonly is: Schema.optionalKey<Schema.Never>;
447
+ readonly matches: Schema.optionalKey<Schema.Never>;
448
+ readonly changes: Schema.optionalKey<Schema.Never>;
449
+ }>]>>, never, never>;
208
450
  readonly ends: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
209
451
  readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
210
452
  readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
package/dist/schedule.js CHANGED
@@ -43,8 +43,45 @@ export const PromptAction = Schema.Struct({ type: Schema.tag("prompt"), prompt:
43
43
  identifier: "Schedule.Action.Prompt",
44
44
  });
45
45
  export const Action = Schema.Union([PromptAction]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Schedule.Action" }));
46
+ /**
47
+ * Runs `run` in the Session's directory before firing, with no model call. With none of `is`, `matches` or `changes`
48
+ * set, exit 0 wakes and any non-zero exit is "not yet". With `is`, `matches` or `changes`, non-zero exit is a check
49
+ * error, and exit 0 wakes when trimmed stdout equals `is`, stdout matches `matches`, or stdout differs from the
50
+ * previous run (`changes`).
51
+ */
52
+ export const ShellCondition = Schema.Struct({
53
+ type: Schema.tag("shell"),
54
+ run: Schema.String,
55
+ is: Schema.String.pipe(optional),
56
+ matches: Schema.String.pipe(optional),
57
+ changes: Schema.Boolean.pipe(optional),
58
+ }).annotate({ identifier: "Schedule.Condition.Shell" });
59
+ /**
60
+ * Runs `code` in a confined Code Mode runtime before firing, with no model call and no `fetch`. Tools called statically
61
+ * as `tools.<path>(...)` are extracted from the AST and authorized at creation; the program receives `state` (initially
62
+ * `null`), `now` (epoch ms) and `runs` (completed checks), and returns a boolean or `{ wake, state?, message? }`.
63
+ */
64
+ export const CodeCondition = Schema.Struct({
65
+ type: Schema.tag("code"),
66
+ code: Schema.String,
67
+ }).annotate({ identifier: "Schedule.Condition.Code" });
68
+ /** Checked before firing; the schedule wakes the Session only when the condition passes. */
69
+ export const Condition = Schema.Union([ShellCondition, CodeCondition]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Schedule.Condition" }));
70
+ export const CheckMode = Schema.Literals(["if", "until"]).annotate({ identifier: "Schedule.CheckMode" });
71
+ export const StoredCheck = Schema.Struct({
72
+ mode: CheckMode,
73
+ condition: Condition,
74
+ }).annotate({ identifier: "Schedule.StoredCheck" });
46
75
  export const Status = Schema.Literals(["active", "paused", "done"]).annotate({ identifier: "Schedule.Status" });
47
- export const Outcome = Schema.Literals(["fired", "late", "skipped", "disabled", "failed"]).annotate({
76
+ export const Outcome = Schema.Literals([
77
+ "fired",
78
+ "late",
79
+ "checked",
80
+ "expired",
81
+ "skipped",
82
+ "disabled",
83
+ "failed",
84
+ ]).annotate({
48
85
  identifier: "Schedule.Outcome",
49
86
  });
50
87
  export const Info = Schema.Struct({
@@ -53,6 +90,8 @@ export const Info = Schema.Struct({
53
90
  name: Schema.String.pipe(optional),
54
91
  when: When,
55
92
  tz: Schema.String,
93
+ if: Condition.pipe(optional),
94
+ until: Condition.pipe(optional),
56
95
  action: Action,
57
96
  status: Status,
58
97
  nextDueAt: DateTimeUtcFromMillis.pipe(optional),
@@ -61,16 +100,19 @@ export const Info = Schema.Struct({
61
100
  runCount: NonNegativeInt,
62
101
  lastFiredAt: DateTimeUtcFromMillis.pipe(optional),
63
102
  lastOutcome: Outcome.pipe(optional),
103
+ lastOutput: Schema.String.pipe(optional),
64
104
  time: Schema.Struct({ created: DateTimeUtcFromMillis, updated: DateTimeUtcFromMillis }),
65
105
  }).annotate({ identifier: "Schedule.Info" });
66
106
  export const CreateInput = Schema.Struct({
67
107
  sessionID: SessionID,
68
108
  name: Schema.String.pipe(optional),
69
- when: When,
109
+ when: When.pipe(optional),
110
+ if: Condition.pipe(optional),
111
+ until: Condition.pipe(optional),
70
112
  ends: Ends.pipe(optional),
71
113
  action: Action,
72
114
  }).annotate({ identifier: "Schedule.CreateInput" });
73
- /** Declares a trigger absent, so `{ in, every }` fails instead of decoding as a one-shot. */
115
+ /** Declares a variant field absent, so `{ in, every }` or `{ run, code }` fails instead of silently dropping one. */
74
116
  const absent = Schema.optionalKey(Schema.Never);
75
117
  /** The `when` callers write: exactly one of `in`, `at`, `every` or `cron`, with an optional `tz`. */
76
118
  export const WhenInput = Schema.Union([
@@ -79,26 +121,80 @@ export const WhenInput = Schema.Union([
79
121
  Schema.Struct({ every: Every.fields.every, in: absent, at: absent, cron: absent, ...zone }),
80
122
  Schema.Struct({ cron: Cron.fields.cron, in: absent, at: absent, every: absent, ...zone }),
81
123
  ]).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. */
124
+ export const ShellConditionInput = Schema.Struct({
125
+ run: Schema.String.check(Schema.isMinLength(1)).annotate({
126
+ description: "Shell command to run in the Session's directory. Alone, exit 0 wakes and stdout is appended.",
127
+ }),
128
+ is: Schema.String.pipe(optional).annotate({
129
+ description: "Wake when exit is 0 and trimmed stdout equals this value.",
130
+ }),
131
+ matches: Schema.String.pipe(optional).annotate({
132
+ description: "Wake when exit is 0 and stdout matches this regular expression.",
133
+ }),
134
+ changes: Schema.Boolean.pipe(optional).annotate({
135
+ description: "Wake when exit is 0 and stdout differs from the previous check.",
136
+ }),
137
+ }).annotate({ identifier: "Schedule.ShellConditionInput" });
138
+ export const CodeConditionInput = Schema.Struct({
139
+ code: Schema.String.check(Schema.isMinLength(1)).annotate({
140
+ description: [
141
+ "Code Mode JavaScript check (no fetch; 30s, 20 tool calls, 32 KB output cap).",
142
+ 'Call tools statically as tools.<ns>.<tool>(...) or tools["ns-name"].tool(...); each is authorized once at creation to run unattended.',
143
+ "Runs once at creation with state = null (if baselines state without waking; until matches immediately if true), with globals state, now (epoch ms) and runs.",
144
+ "Return a boolean or { wake, state?, message? } (message is appended to prompt on wake), e.g.:",
145
+ 'const t = await tools.slack.read_thread({ id }); return { wake: state !== null && t.count > state.count, state: { count: t.count }, message: "New reply" }',
146
+ ].join(" "),
147
+ }),
148
+ }).annotate({ identifier: "Schedule.CodeConditionInput" });
149
+ export const ConditionInput = Schema.Union([
150
+ Schema.Struct({ ...ShellConditionInput.fields, code: absent }),
151
+ Schema.Struct({
152
+ ...CodeConditionInput.fields,
153
+ run: absent,
154
+ is: absent,
155
+ matches: absent,
156
+ changes: absent,
157
+ }),
158
+ ]).annotate({ identifier: "Schedule.ConditionInput" });
159
+ /** A schedule as callers describe it: when it fires, optional condition, when it stops, and the prompt it sends. */
83
160
  export const Request = Schema.Struct({
84
161
  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.',
162
+ when: WhenInput.pipe(optional).annotate({
163
+ description: 'When it fires: { in: "20 minutes" }, { at: "2026-10-27T09:00" }, { every: "1 hour" } or { cron: "0 9 * * 1-5" }. Optional with `until` (defaults to { every: "30 seconds" }).',
164
+ }),
165
+ if: ConditionInput.pipe(optional).annotate({
166
+ description: "Recurring gate ({ run } shell command or { code } Code Mode script): check on each slot with no model call, and wake on every slot where it passes.",
167
+ }),
168
+ until: ConditionInput.pipe(optional).annotate({
169
+ description: 'One-shot gate ({ run } shell command or { code } Code Mode script): poll with no model call, wake once when it passes, and stop. Defaults ends.after to "24 hours".',
87
170
  }),
88
171
  ends: Ends.pipe(optional).annotate({
89
172
  description: 'Stops a repeating schedule at the first limit reached: { after: "8 hours" }, { at }, { times: 3 }.',
90
173
  }),
91
174
  prompt: Schema.String.check(Schema.isMinLength(1)).annotate({
92
- description: "The message the Session receives each time the schedule fires.",
175
+ description: "The message the Session receives when the schedule wakes.",
93
176
  }),
94
177
  }).annotate({ identifier: "Schedule.Request" });
95
178
  export const toCreateInput = (sessionID, request) => ({
96
179
  sessionID,
97
180
  name: request.name,
98
- when: toWhen(request.when),
181
+ when: request.when === undefined ? undefined : toWhen(request.when),
182
+ if: request.if === undefined ? undefined : toCondition(request.if),
183
+ until: request.until === undefined ? undefined : toCondition(request.until),
99
184
  ends: request.ends,
100
185
  action: { type: "prompt", prompt: request.prompt },
101
186
  });
187
+ const toCondition = (condition) => {
188
+ if (condition.code !== undefined)
189
+ return { type: "code", code: condition.code };
190
+ return {
191
+ type: "shell",
192
+ run: condition.run,
193
+ is: condition.is,
194
+ matches: condition.matches,
195
+ changes: condition.changes,
196
+ };
197
+ };
102
198
  const toWhen = (when) => {
103
199
  if (when.in !== undefined)
104
200
  return { type: "in", in: when.in, tz: when.tz };