@fungi.computer/shiitake-extensions 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/almanac/contract.d.ts +1 -107
- package/dist/almanac/contract.js +4 -40
- package/dist/almanac/schema.d.ts +41 -0
- package/dist/almanac/schema.js +40 -0
- package/dist/internal/schedule-fields.d.ts +5 -0
- package/dist/internal/schedule-fields.js +5 -0
- package/dist/loop/contract.d.ts +31 -185
- package/dist/loop/contract.js +13 -48
- package/dist/loop/host.js +4 -1
- package/dist/loop/schema.d.ts +49 -0
- package/dist/loop/schema.js +49 -0
- package/dist/schedules/client.d.ts +16 -0
- package/dist/schedules/client.js +81 -0
- package/dist/schedules.d.ts +1 -15
- package/dist/schedules.js +8 -83
- package/docs/api/README.md +1 -0
- package/docs/api/almanac/contract.md +46 -46
- package/docs/api/loop/contract.md +50 -46
- package/docs/api/roster/conversation-agents.md +22 -0
- package/docs/api/schedules/client.md +228 -0
- package/docs/api/schedules.md +0 -219
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -180,7 +180,10 @@ reason; the host can resume it without inventing a separate background loop.
|
|
|
180
180
|
|
|
181
181
|
## API reference and examples
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
The [generated API reference](docs/api/README.md) follows the public
|
|
184
|
+
entrypoints. Run `pnpm --dir packages/shiitake-extensions run docs:write` from
|
|
185
|
+
the repository root after changing them, then
|
|
186
|
+
`pnpm --dir packages/shiitake-extensions run docs` to check consistency.
|
|
184
187
|
[package.json](package.json) owns these exported subpaths:
|
|
185
188
|
|
|
186
189
|
| Entry | Source |
|
|
@@ -196,6 +199,8 @@ This package documents contracts beside source and has no generated API command.
|
|
|
196
199
|
| `/subagents/client` | [Subagents client entry](src/subagents/client.ts). |
|
|
197
200
|
| `/goal/client`, `/loop/client`, `/plan/client` | Client entries for [Goal](src/goal/client.ts), [Loop](src/loop/client.ts) and [Plan](src/plan/client.ts). |
|
|
198
201
|
| `/roster` | [Product roster and grants](src/roster.ts). |
|
|
202
|
+
| `/schedules` | [Schema-only schedule pages, targets and receipts](src/schedules.ts). |
|
|
203
|
+
| `/schedules/client` | [Native schedule reads and controls](src/schedules/client.ts). |
|
|
199
204
|
|
|
200
205
|
[Loop tests](test/loop.test.ts) exercise scheduling and mid-run pause.
|
|
201
206
|
[Almanac tests](test/almanac.test.ts) exercise admission and retry.
|
|
@@ -203,6 +208,15 @@ This package documents contracts beside source and has no generated API command.
|
|
|
203
208
|
These fixtures use the actual extension definitions on Shiitake with fake
|
|
204
209
|
models.
|
|
205
210
|
|
|
211
|
+
### Schedule consumers
|
|
212
|
+
|
|
213
|
+
Use `/schedules` for schedule schemas and types in an App bundle. It imports the
|
|
214
|
+
retained Almanac and Loop data schemas, not their native invocation clients.
|
|
215
|
+
Native host integrations use `/schedules/client` for `readAgentSchedulePage`,
|
|
216
|
+
`controlAgentSchedule` and `controlAgentScheduleWithContent` on an already
|
|
217
|
+
admitted Agent owner. These helpers own no admission policy, store or scheduler.
|
|
218
|
+
Reading and management remain separately admitted by the host.
|
|
219
|
+
|
|
206
220
|
## Home
|
|
207
221
|
|
|
208
222
|
The host creates `homeExtension({ computers })`, where `computers.read()`
|
|
@@ -1,32 +1,5 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
-
|
|
3
|
-
export declare const Schedule: Schema.Struct<{
|
|
4
|
-
/** Caller-chosen schedule identity. */
|
|
5
|
-
readonly id: Schema.String;
|
|
6
|
-
/** Session that receives each scheduled prompt. */
|
|
7
|
-
readonly sessionId: Schema.String;
|
|
8
|
-
/** Original prompt submitted to the destination Session. */
|
|
9
|
-
readonly prompt: Schema.String;
|
|
10
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
11
|
-
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
12
|
-
/** Cron expression used to calculate occurrences. */
|
|
13
|
-
readonly expression: Schema.String;
|
|
14
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
15
|
-
readonly timeZone: Schema.String;
|
|
16
|
-
}>>;
|
|
17
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
18
|
-
readonly nextDueAt: Schema.Int;
|
|
19
|
-
/** Current scheduling lifecycle state. */
|
|
20
|
-
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
21
|
-
/** Latest command admitted for this schedule. */
|
|
22
|
-
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
23
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
24
|
-
readonly lastError: Schema.NullOr<Schema.String>;
|
|
25
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
26
|
-
readonly attempt: Schema.Int;
|
|
27
|
-
}>;
|
|
28
|
-
/** One durable schedule. */
|
|
29
|
-
export type Schedule = Schema.Schema.Type<typeof Schedule>;
|
|
2
|
+
export { Schedule } from "./schema.js";
|
|
30
3
|
/** Almanac's contract: agent-scope schedule CRUD, no Session projection. */
|
|
31
4
|
export declare const almanacContract: {
|
|
32
5
|
/** Stable extension identity. */
|
|
@@ -50,28 +23,17 @@ export declare const almanacContract: {
|
|
|
50
23
|
}>;
|
|
51
24
|
/** Return the created durable schedule. */
|
|
52
25
|
readonly output: Schema.Struct<{
|
|
53
|
-
/** Caller-chosen schedule identity. */
|
|
54
26
|
readonly id: Schema.String;
|
|
55
|
-
/** Session that receives each scheduled prompt. */
|
|
56
27
|
readonly sessionId: Schema.String;
|
|
57
|
-
/** Original prompt submitted to the destination Session. */
|
|
58
28
|
readonly prompt: Schema.String;
|
|
59
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
60
29
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
61
|
-
/** Cron expression used to calculate occurrences. */
|
|
62
30
|
readonly expression: Schema.String;
|
|
63
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
64
31
|
readonly timeZone: Schema.String;
|
|
65
32
|
}>>;
|
|
66
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
67
33
|
readonly nextDueAt: Schema.Int;
|
|
68
|
-
/** Current scheduling lifecycle state. */
|
|
69
34
|
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
70
|
-
/** Latest command admitted for this schedule. */
|
|
71
35
|
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
72
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
73
36
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
74
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
75
37
|
readonly attempt: Schema.Int;
|
|
76
38
|
}>;
|
|
77
39
|
};
|
|
@@ -94,28 +56,17 @@ export declare const almanacContract: {
|
|
|
94
56
|
}>;
|
|
95
57
|
/** Return the created durable schedule. */
|
|
96
58
|
readonly output: Schema.Struct<{
|
|
97
|
-
/** Caller-chosen schedule identity. */
|
|
98
59
|
readonly id: Schema.String;
|
|
99
|
-
/** Session that receives each scheduled prompt. */
|
|
100
60
|
readonly sessionId: Schema.String;
|
|
101
|
-
/** Original prompt submitted to the destination Session. */
|
|
102
61
|
readonly prompt: Schema.String;
|
|
103
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
104
62
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
105
|
-
/** Cron expression used to calculate occurrences. */
|
|
106
63
|
readonly expression: Schema.String;
|
|
107
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
108
64
|
readonly timeZone: Schema.String;
|
|
109
65
|
}>>;
|
|
110
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
111
66
|
readonly nextDueAt: Schema.Int;
|
|
112
|
-
/** Current scheduling lifecycle state. */
|
|
113
67
|
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
114
|
-
/** Latest command admitted for this schedule. */
|
|
115
68
|
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
116
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
117
69
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
118
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
119
70
|
readonly attempt: Schema.Int;
|
|
120
71
|
}>;
|
|
121
72
|
};
|
|
@@ -130,28 +81,17 @@ export declare const almanacContract: {
|
|
|
130
81
|
}>;
|
|
131
82
|
/** Decode the schedule or its absence. */
|
|
132
83
|
readonly output: Schema.NullOr<Schema.Struct<{
|
|
133
|
-
/** Caller-chosen schedule identity. */
|
|
134
84
|
readonly id: Schema.String;
|
|
135
|
-
/** Session that receives each scheduled prompt. */
|
|
136
85
|
readonly sessionId: Schema.String;
|
|
137
|
-
/** Original prompt submitted to the destination Session. */
|
|
138
86
|
readonly prompt: Schema.String;
|
|
139
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
140
87
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
141
|
-
/** Cron expression used to calculate occurrences. */
|
|
142
88
|
readonly expression: Schema.String;
|
|
143
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
144
89
|
readonly timeZone: Schema.String;
|
|
145
90
|
}>>;
|
|
146
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
147
91
|
readonly nextDueAt: Schema.Int;
|
|
148
|
-
/** Current scheduling lifecycle state. */
|
|
149
92
|
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
150
|
-
/** Latest command admitted for this schedule. */
|
|
151
93
|
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
152
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
153
94
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
154
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
155
95
|
readonly attempt: Schema.Int;
|
|
156
96
|
}>>;
|
|
157
97
|
};
|
|
@@ -161,35 +101,22 @@ export declare const almanacContract: {
|
|
|
161
101
|
readonly scope: "agent";
|
|
162
102
|
/** Decode pagination arguments. */
|
|
163
103
|
readonly input: Schema.Struct<{
|
|
164
|
-
/** Exclusive schedule cursor. */
|
|
165
104
|
readonly after: Schema.optionalKey<Schema.String>;
|
|
166
|
-
/** Maximum number of schedules returned. */
|
|
167
105
|
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
168
106
|
}>;
|
|
169
107
|
/** Decode the returned schedule rows. */
|
|
170
108
|
readonly output: Schema.$Array<Schema.Struct<{
|
|
171
|
-
/** Caller-chosen schedule identity. */
|
|
172
109
|
readonly id: Schema.String;
|
|
173
|
-
/** Session that receives each scheduled prompt. */
|
|
174
110
|
readonly sessionId: Schema.String;
|
|
175
|
-
/** Original prompt submitted to the destination Session. */
|
|
176
111
|
readonly prompt: Schema.String;
|
|
177
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
178
112
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
179
|
-
/** Cron expression used to calculate occurrences. */
|
|
180
113
|
readonly expression: Schema.String;
|
|
181
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
182
114
|
readonly timeZone: Schema.String;
|
|
183
115
|
}>>;
|
|
184
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
185
116
|
readonly nextDueAt: Schema.Int;
|
|
186
|
-
/** Current scheduling lifecycle state. */
|
|
187
117
|
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
188
|
-
/** Latest command admitted for this schedule. */
|
|
189
118
|
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
190
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
191
119
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
192
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
193
120
|
readonly attempt: Schema.Int;
|
|
194
121
|
}>>;
|
|
195
122
|
};
|
|
@@ -204,28 +131,17 @@ export declare const almanacContract: {
|
|
|
204
131
|
}>;
|
|
205
132
|
/** Return its updated state. */
|
|
206
133
|
readonly output: Schema.Struct<{
|
|
207
|
-
/** Caller-chosen schedule identity. */
|
|
208
134
|
readonly id: Schema.String;
|
|
209
|
-
/** Session that receives each scheduled prompt. */
|
|
210
135
|
readonly sessionId: Schema.String;
|
|
211
|
-
/** Original prompt submitted to the destination Session. */
|
|
212
136
|
readonly prompt: Schema.String;
|
|
213
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
214
137
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
215
|
-
/** Cron expression used to calculate occurrences. */
|
|
216
138
|
readonly expression: Schema.String;
|
|
217
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
218
139
|
readonly timeZone: Schema.String;
|
|
219
140
|
}>>;
|
|
220
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
221
141
|
readonly nextDueAt: Schema.Int;
|
|
222
|
-
/** Current scheduling lifecycle state. */
|
|
223
142
|
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
224
|
-
/** Latest command admitted for this schedule. */
|
|
225
143
|
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
226
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
227
144
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
228
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
229
145
|
readonly attempt: Schema.Int;
|
|
230
146
|
}>;
|
|
231
147
|
};
|
|
@@ -240,28 +156,17 @@ export declare const almanacContract: {
|
|
|
240
156
|
}>;
|
|
241
157
|
/** Return its updated state. */
|
|
242
158
|
readonly output: Schema.Struct<{
|
|
243
|
-
/** Caller-chosen schedule identity. */
|
|
244
159
|
readonly id: Schema.String;
|
|
245
|
-
/** Session that receives each scheduled prompt. */
|
|
246
160
|
readonly sessionId: Schema.String;
|
|
247
|
-
/** Original prompt submitted to the destination Session. */
|
|
248
161
|
readonly prompt: Schema.String;
|
|
249
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
250
162
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
251
|
-
/** Cron expression used to calculate occurrences. */
|
|
252
163
|
readonly expression: Schema.String;
|
|
253
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
254
164
|
readonly timeZone: Schema.String;
|
|
255
165
|
}>>;
|
|
256
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
257
166
|
readonly nextDueAt: Schema.Int;
|
|
258
|
-
/** Current scheduling lifecycle state. */
|
|
259
167
|
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
260
|
-
/** Latest command admitted for this schedule. */
|
|
261
168
|
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
262
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
263
169
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
264
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
265
170
|
readonly attempt: Schema.Int;
|
|
266
171
|
}>;
|
|
267
172
|
};
|
|
@@ -276,28 +181,17 @@ export declare const almanacContract: {
|
|
|
276
181
|
}>;
|
|
277
182
|
/** Return its updated state. */
|
|
278
183
|
readonly output: Schema.Struct<{
|
|
279
|
-
/** Caller-chosen schedule identity. */
|
|
280
184
|
readonly id: Schema.String;
|
|
281
|
-
/** Session that receives each scheduled prompt. */
|
|
282
185
|
readonly sessionId: Schema.String;
|
|
283
|
-
/** Original prompt submitted to the destination Session. */
|
|
284
186
|
readonly prompt: Schema.String;
|
|
285
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
286
187
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
287
|
-
/** Cron expression used to calculate occurrences. */
|
|
288
188
|
readonly expression: Schema.String;
|
|
289
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
290
189
|
readonly timeZone: Schema.String;
|
|
291
190
|
}>>;
|
|
292
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
293
191
|
readonly nextDueAt: Schema.Int;
|
|
294
|
-
/** Current scheduling lifecycle state. */
|
|
295
192
|
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
296
|
-
/** Latest command admitted for this schedule. */
|
|
297
193
|
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
298
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
299
194
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
300
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
301
195
|
readonly attempt: Schema.Int;
|
|
302
196
|
}>;
|
|
303
197
|
};
|
package/dist/almanac/contract.js
CHANGED
|
@@ -1,44 +1,13 @@
|
|
|
1
1
|
import { ExtensionId } from "@fungi.computer/shiitake/extensions";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
|
+
import { Prompt, SessionId } from "../internal/schedule-fields.js";
|
|
4
|
+
import { ScheduleId, Instant, CronExpression, TimeZone, Schedule, ScheduleListInput, } from "./schema.js";
|
|
5
|
+
export { Schedule } from "./schema.js";
|
|
3
6
|
/**
|
|
4
7
|
* Almanac: durable one-shot and cron schedules that send ordinary Session
|
|
5
8
|
* prompts. This contract is shared by the server extension and its clients;
|
|
6
9
|
* its schemas are the only decoders of Almanac values.
|
|
7
10
|
*/
|
|
8
|
-
/** Caller-chosen schedule identity; also its create idempotency key. */
|
|
9
|
-
const ScheduleId = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(200)), Schema.check(Schema.isPattern(/^[A-Za-z0-9._:-]+$/u)));
|
|
10
|
-
const SessionId = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256)));
|
|
11
|
-
/** Human prompt grammar; the admission door re-checks the exact byte bound. */
|
|
12
|
-
const Prompt = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256 * 1024)));
|
|
13
|
-
const Instant = Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)));
|
|
14
|
-
const CronExpression = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256)));
|
|
15
|
-
const TimeZone = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(128)));
|
|
16
|
-
/** One durable schedule as every caller sees it. */
|
|
17
|
-
export const Schedule = Schema.Struct({
|
|
18
|
-
/** Caller-chosen schedule identity. */
|
|
19
|
-
id: ScheduleId,
|
|
20
|
-
/** Session that receives each scheduled prompt. */
|
|
21
|
-
sessionId: SessionId,
|
|
22
|
-
/** Original prompt submitted to the destination Session. */
|
|
23
|
-
prompt: Prompt,
|
|
24
|
-
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
25
|
-
cron: Schema.NullOr(Schema.Struct({
|
|
26
|
-
/** Cron expression used to calculate occurrences. */
|
|
27
|
-
expression: CronExpression,
|
|
28
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
29
|
-
timeZone: TimeZone,
|
|
30
|
-
})),
|
|
31
|
-
/** The occurrence that fires next (or fired last, once finished). */
|
|
32
|
-
nextDueAt: Instant,
|
|
33
|
-
/** Current scheduling lifecycle state. */
|
|
34
|
-
state: Schema.Literals(["active", "paused", "cancelled", "finished"]),
|
|
35
|
-
/** Latest command admitted for this schedule. */
|
|
36
|
-
lastCommandId: Schema.NullOr(Schema.String),
|
|
37
|
-
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
38
|
-
lastError: Schema.NullOr(Schema.String),
|
|
39
|
-
/** Consecutive failed admissions of the current occurrence. */
|
|
40
|
-
attempt: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
41
|
-
});
|
|
42
11
|
const ScheduleRef = Schema.Struct({
|
|
43
12
|
/** Existing schedule targeted by the command. */
|
|
44
13
|
scheduleId: ScheduleId,
|
|
@@ -101,12 +70,7 @@ export const almanacContract = {
|
|
|
101
70
|
/** Read from the Agent's schedule collection. */
|
|
102
71
|
scope: "agent",
|
|
103
72
|
/** Decode pagination arguments. */
|
|
104
|
-
input:
|
|
105
|
-
/** Exclusive schedule cursor. */
|
|
106
|
-
after: Schema.optionalKey(ScheduleId),
|
|
107
|
-
/** Maximum number of schedules returned. */
|
|
108
|
-
limit: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 1, maximum: 64 })))),
|
|
109
|
-
}),
|
|
73
|
+
input: ScheduleListInput,
|
|
110
74
|
/** Decode the returned schedule rows. */
|
|
111
75
|
output: Schema.Array(Schedule),
|
|
112
76
|
},
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** Caller-chosen schedule identity; also its create idempotency key. */
|
|
3
|
+
export declare const ScheduleId: Schema.String;
|
|
4
|
+
export declare const Instant: Schema.Int;
|
|
5
|
+
export declare const CronExpression: Schema.String;
|
|
6
|
+
export declare const TimeZone: Schema.String;
|
|
7
|
+
/** One durable schedule as every caller sees it. */
|
|
8
|
+
export declare const Schedule: Schema.Struct<{
|
|
9
|
+
/** Caller-chosen schedule identity. */
|
|
10
|
+
readonly id: Schema.String;
|
|
11
|
+
/** Session that receives each scheduled prompt. */
|
|
12
|
+
readonly sessionId: Schema.String;
|
|
13
|
+
/** Original prompt submitted to the destination Session. */
|
|
14
|
+
readonly prompt: Schema.String;
|
|
15
|
+
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
16
|
+
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
17
|
+
/** Cron expression used to calculate occurrences. */
|
|
18
|
+
readonly expression: Schema.String;
|
|
19
|
+
/** IANA time zone in which the expression is evaluated. */
|
|
20
|
+
readonly timeZone: Schema.String;
|
|
21
|
+
}>>;
|
|
22
|
+
/** The occurrence that fires next (or fired last, once finished). */
|
|
23
|
+
readonly nextDueAt: Schema.Int;
|
|
24
|
+
/** Current scheduling lifecycle state. */
|
|
25
|
+
readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
|
|
26
|
+
/** Latest command admitted for this schedule. */
|
|
27
|
+
readonly lastCommandId: Schema.NullOr<Schema.String>;
|
|
28
|
+
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
29
|
+
readonly lastError: Schema.NullOr<Schema.String>;
|
|
30
|
+
/** Consecutive failed admissions of the current occurrence. */
|
|
31
|
+
readonly attempt: Schema.Int;
|
|
32
|
+
}>;
|
|
33
|
+
/** One durable schedule. */
|
|
34
|
+
export type Schedule = Schema.Schema.Type<typeof Schedule>;
|
|
35
|
+
/** Native bounded Almanac page grammar, also used by shared continuations. */
|
|
36
|
+
export declare const ScheduleListInput: Schema.Struct<{
|
|
37
|
+
/** Exclusive schedule cursor. */
|
|
38
|
+
readonly after: Schema.optionalKey<Schema.String>;
|
|
39
|
+
/** Maximum number of schedules returned. */
|
|
40
|
+
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
41
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { Prompt, SessionId } from "../internal/schedule-fields.js";
|
|
3
|
+
/** Caller-chosen schedule identity; also its create idempotency key. */
|
|
4
|
+
export const ScheduleId = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(200)), Schema.check(Schema.isPattern(/^[A-Za-z0-9._:-]+$/u)));
|
|
5
|
+
export const Instant = Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)));
|
|
6
|
+
export const CronExpression = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256)));
|
|
7
|
+
export const TimeZone = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(128)));
|
|
8
|
+
/** One durable schedule as every caller sees it. */
|
|
9
|
+
export const Schedule = Schema.Struct({
|
|
10
|
+
/** Caller-chosen schedule identity. */
|
|
11
|
+
id: ScheduleId,
|
|
12
|
+
/** Session that receives each scheduled prompt. */
|
|
13
|
+
sessionId: SessionId,
|
|
14
|
+
/** Original prompt submitted to the destination Session. */
|
|
15
|
+
prompt: Prompt,
|
|
16
|
+
/** Cron expression and zone for a recurring schedule; null for one-shot. */
|
|
17
|
+
cron: Schema.NullOr(Schema.Struct({
|
|
18
|
+
/** Cron expression used to calculate occurrences. */
|
|
19
|
+
expression: CronExpression,
|
|
20
|
+
/** IANA time zone in which the expression is evaluated. */
|
|
21
|
+
timeZone: TimeZone,
|
|
22
|
+
})),
|
|
23
|
+
/** The occurrence that fires next (or fired last, once finished). */
|
|
24
|
+
nextDueAt: Instant,
|
|
25
|
+
/** Current scheduling lifecycle state. */
|
|
26
|
+
state: Schema.Literals(["active", "paused", "cancelled", "finished"]),
|
|
27
|
+
/** Latest command admitted for this schedule. */
|
|
28
|
+
lastCommandId: Schema.NullOr(Schema.String),
|
|
29
|
+
/** Why the current occurrence has not been admitted yet, if it failed. */
|
|
30
|
+
lastError: Schema.NullOr(Schema.String),
|
|
31
|
+
/** Consecutive failed admissions of the current occurrence. */
|
|
32
|
+
attempt: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
33
|
+
});
|
|
34
|
+
/** Native bounded Almanac page grammar, also used by shared continuations. */
|
|
35
|
+
export const ScheduleListInput = Schema.Struct({
|
|
36
|
+
/** Exclusive schedule cursor. */
|
|
37
|
+
after: Schema.optionalKey(ScheduleId),
|
|
38
|
+
/** Maximum number of schedules returned. */
|
|
39
|
+
limit: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 1, maximum: 64 })))),
|
|
40
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** Native Session address shared by Almanac and Loop inputs and rows. */
|
|
3
|
+
export declare const SessionId: Schema.String;
|
|
4
|
+
/** Human prompt grammar; the admission door re-checks the exact byte bound. */
|
|
5
|
+
export declare const Prompt: Schema.String;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** Native Session address shared by Almanac and Loop inputs and rows. */
|
|
3
|
+
export const SessionId = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256)));
|
|
4
|
+
/** Human prompt grammar; the admission door re-checks the exact byte bound. */
|
|
5
|
+
export const Prompt = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256 * 1024)));
|