@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/dist/loop/contract.d.ts
CHANGED
|
@@ -1,45 +1,5 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
-
|
|
3
|
-
export declare const LoopCron: Schema.Struct<{
|
|
4
|
-
/** Cron expression for the fixed cadence. */
|
|
5
|
-
readonly expression: Schema.String;
|
|
6
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
7
|
-
readonly timeZone: Schema.String;
|
|
8
|
-
}>;
|
|
9
|
-
/** One Session's loop as every client sees it. */
|
|
10
|
-
export declare const Loop: Schema.Struct<{
|
|
11
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
12
|
-
readonly loopId: Schema.String;
|
|
13
|
-
/** Whether a person or the model started this loop. */
|
|
14
|
-
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
15
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
16
|
-
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
17
|
-
/** Original instruction repeated for every occurrence. */
|
|
18
|
-
readonly prompt: Schema.String;
|
|
19
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
20
|
-
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
21
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
22
|
-
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
23
|
-
/** Cron expression for the fixed cadence. */
|
|
24
|
-
readonly expression: Schema.String;
|
|
25
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
26
|
-
readonly timeZone: Schema.String;
|
|
27
|
-
}>>;
|
|
28
|
-
/** Current loop lifecycle state. */
|
|
29
|
-
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
30
|
-
/** Latest accepted command associated with this loop. */
|
|
31
|
-
readonly commandId: Schema.String;
|
|
32
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
33
|
-
readonly reason: Schema.NullOr<Schema.String>;
|
|
34
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
35
|
-
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
36
|
-
/** Visible explanation when loop work failed. */
|
|
37
|
-
readonly lastError: Schema.NullOr<Schema.String>;
|
|
38
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
39
|
-
readonly consecutiveFailures: Schema.Int;
|
|
40
|
-
}>;
|
|
41
|
-
/** One Session's loop. */
|
|
42
|
-
export type Loop = Schema.Schema.Type<typeof Loop>;
|
|
2
|
+
export { Loop, LoopCron } from "./schema.js";
|
|
43
3
|
/**
|
|
44
4
|
* Arguments of the human `/loop` command. `start` carries the typed text:
|
|
45
5
|
* `<prompt>` paces itself, `<N>m <prompt>` or `<N>h <prompt>` runs on an
|
|
@@ -62,34 +22,20 @@ export declare const LoopCommandInput: Schema.Union<readonly [Schema.Struct<{
|
|
|
62
22
|
export declare const LoopProjection: Schema.Struct<{
|
|
63
23
|
/** Loop currently visible to Session clients. */
|
|
64
24
|
readonly loop: Schema.Struct<{
|
|
65
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
66
25
|
readonly loopId: Schema.String;
|
|
67
|
-
/** Whether a person or the model started this loop. */
|
|
68
26
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
69
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
70
27
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
71
|
-
/** Original instruction repeated for every occurrence. */
|
|
72
28
|
readonly prompt: Schema.String;
|
|
73
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
74
29
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
75
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
76
30
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
77
|
-
/** Cron expression for the fixed cadence. */
|
|
78
31
|
readonly expression: Schema.String;
|
|
79
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
80
32
|
readonly timeZone: Schema.String;
|
|
81
33
|
}>>;
|
|
82
|
-
/** Current loop lifecycle state. */
|
|
83
34
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
84
|
-
/** Latest accepted command associated with this loop. */
|
|
85
35
|
readonly commandId: Schema.String;
|
|
86
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
87
36
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
88
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
89
37
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
90
|
-
/** Visible explanation when loop work failed. */
|
|
91
38
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
92
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
93
39
|
readonly consecutiveFailures: Schema.Int;
|
|
94
40
|
}>;
|
|
95
41
|
}>;
|
|
@@ -105,43 +51,27 @@ export declare const loopContract: {
|
|
|
105
51
|
readonly scope: "agent";
|
|
106
52
|
/** Page strictly after a Session identity, in identity order. */
|
|
107
53
|
readonly input: Schema.Struct<{
|
|
108
|
-
/** Exclusive Session cursor. */
|
|
109
54
|
readonly after: Schema.optionalKey<Schema.String>;
|
|
110
|
-
/** Maximum number of Loop rows to read. */
|
|
111
55
|
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
112
56
|
}>;
|
|
113
57
|
/** Public Loop values with Session targets, never private scheduling state. */
|
|
114
58
|
readonly output: Schema.$Array<Schema.Struct<{
|
|
115
59
|
/** Session that owns this identified Loop. */
|
|
116
60
|
readonly sessionId: Schema.String;
|
|
117
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
118
61
|
readonly loopId: Schema.String;
|
|
119
|
-
/** Whether a person or the model started this loop. */
|
|
120
62
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
121
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
122
63
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
123
|
-
/** Original instruction repeated for every occurrence. */
|
|
124
64
|
readonly prompt: Schema.String;
|
|
125
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
126
65
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
127
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
128
66
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
129
|
-
/** Cron expression for the fixed cadence. */
|
|
130
67
|
readonly expression: Schema.String;
|
|
131
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
132
68
|
readonly timeZone: Schema.String;
|
|
133
69
|
}>>;
|
|
134
|
-
/** Current loop lifecycle state. */
|
|
135
70
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
136
|
-
/** Latest accepted command associated with this loop. */
|
|
137
71
|
readonly commandId: Schema.String;
|
|
138
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
139
72
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
140
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
141
73
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
142
|
-
/** Visible explanation when loop work failed. */
|
|
143
74
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
144
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
145
75
|
readonly consecutiveFailures: Schema.Int;
|
|
146
76
|
}>>;
|
|
147
77
|
};
|
|
@@ -158,34 +88,50 @@ export declare const loopContract: {
|
|
|
158
88
|
}>;
|
|
159
89
|
/** Return the paused Loop without cancelling accepted work. */
|
|
160
90
|
readonly output: Schema.Struct<{
|
|
161
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
162
91
|
readonly loopId: Schema.String;
|
|
163
|
-
/** Whether a person or the model started this loop. */
|
|
164
92
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
165
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
166
93
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
167
|
-
/** Original instruction repeated for every occurrence. */
|
|
168
94
|
readonly prompt: Schema.String;
|
|
169
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
170
95
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
171
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
172
96
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
173
|
-
/** Cron expression for the fixed cadence. */
|
|
174
97
|
readonly expression: Schema.String;
|
|
175
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
176
98
|
readonly timeZone: Schema.String;
|
|
177
99
|
}>>;
|
|
178
|
-
/** Current loop lifecycle state. */
|
|
179
100
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
180
|
-
/** Latest accepted command associated with this loop. */
|
|
181
101
|
readonly commandId: Schema.String;
|
|
182
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
183
102
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
184
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
185
103
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
186
|
-
/** Visible explanation when loop work failed. */
|
|
187
104
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
188
|
-
|
|
105
|
+
readonly consecutiveFailures: Schema.Int;
|
|
106
|
+
}>;
|
|
107
|
+
};
|
|
108
|
+
/** Resume an identified Loop; refuse a stale target after replacement. */
|
|
109
|
+
readonly resumeLoop: {
|
|
110
|
+
/** The Agent owns the identified Loop and its Session. */
|
|
111
|
+
readonly scope: "agent";
|
|
112
|
+
/** The listed Session and Loop identities must both still match. */
|
|
113
|
+
readonly input: Schema.Struct<{
|
|
114
|
+
/** Session containing the identified Loop. */
|
|
115
|
+
readonly sessionId: Schema.String;
|
|
116
|
+
/** Exact Loop identity, not whichever Loop later replaces it. */
|
|
117
|
+
readonly loopId: Schema.String;
|
|
118
|
+
}>;
|
|
119
|
+
/** Return the resumed Loop without changing accepted work. */
|
|
120
|
+
readonly output: Schema.Struct<{
|
|
121
|
+
readonly loopId: Schema.String;
|
|
122
|
+
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
123
|
+
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
124
|
+
readonly prompt: Schema.String;
|
|
125
|
+
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
126
|
+
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
127
|
+
readonly expression: Schema.String;
|
|
128
|
+
readonly timeZone: Schema.String;
|
|
129
|
+
}>>;
|
|
130
|
+
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
131
|
+
readonly commandId: Schema.String;
|
|
132
|
+
readonly reason: Schema.NullOr<Schema.String>;
|
|
133
|
+
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
134
|
+
readonly lastError: Schema.NullOr<Schema.String>;
|
|
189
135
|
readonly consecutiveFailures: Schema.Int;
|
|
190
136
|
}>;
|
|
191
137
|
};
|
|
@@ -202,34 +148,20 @@ export declare const loopContract: {
|
|
|
202
148
|
}>;
|
|
203
149
|
/** Return the cancelled Loop; its Session and history remain. */
|
|
204
150
|
readonly output: Schema.Struct<{
|
|
205
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
206
151
|
readonly loopId: Schema.String;
|
|
207
|
-
/** Whether a person or the model started this loop. */
|
|
208
152
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
209
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
210
153
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
211
|
-
/** Original instruction repeated for every occurrence. */
|
|
212
154
|
readonly prompt: Schema.String;
|
|
213
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
214
155
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
215
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
216
156
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
217
|
-
/** Cron expression for the fixed cadence. */
|
|
218
157
|
readonly expression: Schema.String;
|
|
219
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
220
158
|
readonly timeZone: Schema.String;
|
|
221
159
|
}>>;
|
|
222
|
-
/** Current loop lifecycle state. */
|
|
223
160
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
224
|
-
/** Latest accepted command associated with this loop. */
|
|
225
161
|
readonly commandId: Schema.String;
|
|
226
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
227
162
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
228
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
229
163
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
230
|
-
/** Visible explanation when loop work failed. */
|
|
231
164
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
232
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
233
165
|
readonly consecutiveFailures: Schema.Int;
|
|
234
166
|
}>;
|
|
235
167
|
};
|
|
@@ -269,34 +201,20 @@ export declare const loopContract: {
|
|
|
269
201
|
readonly output: Schema.Struct<{
|
|
270
202
|
/** Newly started loop. */
|
|
271
203
|
readonly loop: Schema.Struct<{
|
|
272
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
273
204
|
readonly loopId: Schema.String;
|
|
274
|
-
/** Whether a person or the model started this loop. */
|
|
275
205
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
276
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
277
206
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
278
|
-
/** Original instruction repeated for every occurrence. */
|
|
279
207
|
readonly prompt: Schema.String;
|
|
280
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
281
208
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
282
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
283
209
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
284
|
-
/** Cron expression for the fixed cadence. */
|
|
285
210
|
readonly expression: Schema.String;
|
|
286
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
287
211
|
readonly timeZone: Schema.String;
|
|
288
212
|
}>>;
|
|
289
|
-
/** Current loop lifecycle state. */
|
|
290
213
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
291
|
-
/** Latest accepted command associated with this loop. */
|
|
292
214
|
readonly commandId: Schema.String;
|
|
293
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
294
215
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
295
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
296
216
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
297
|
-
/** Visible explanation when loop work failed. */
|
|
298
217
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
299
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
300
218
|
readonly consecutiveFailures: Schema.Int;
|
|
301
219
|
}>;
|
|
302
220
|
/** Admission receipt for the start command. */
|
|
@@ -314,9 +232,7 @@ export declare const loopContract: {
|
|
|
314
232
|
readonly scope: "session";
|
|
315
233
|
/** Decode the prompt, cadence and command identity. */
|
|
316
234
|
readonly input: Schema.Struct<{
|
|
317
|
-
/** Cron expression for the fixed cadence. */
|
|
318
235
|
readonly expression: Schema.String;
|
|
319
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
320
236
|
readonly timeZone: Schema.String;
|
|
321
237
|
/** Instruction repeated on every occurrence. */
|
|
322
238
|
readonly prompt: Schema.String;
|
|
@@ -327,34 +243,20 @@ export declare const loopContract: {
|
|
|
327
243
|
readonly output: Schema.Struct<{
|
|
328
244
|
/** Newly started loop. */
|
|
329
245
|
readonly loop: Schema.Struct<{
|
|
330
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
331
246
|
readonly loopId: Schema.String;
|
|
332
|
-
/** Whether a person or the model started this loop. */
|
|
333
247
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
334
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
335
248
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
336
|
-
/** Original instruction repeated for every occurrence. */
|
|
337
249
|
readonly prompt: Schema.String;
|
|
338
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
339
250
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
340
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
341
251
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
342
|
-
/** Cron expression for the fixed cadence. */
|
|
343
252
|
readonly expression: Schema.String;
|
|
344
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
345
253
|
readonly timeZone: Schema.String;
|
|
346
254
|
}>>;
|
|
347
|
-
/** Current loop lifecycle state. */
|
|
348
255
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
349
|
-
/** Latest accepted command associated with this loop. */
|
|
350
256
|
readonly commandId: Schema.String;
|
|
351
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
352
257
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
353
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
354
258
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
355
|
-
/** Visible explanation when loop work failed. */
|
|
356
259
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
357
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
358
260
|
readonly consecutiveFailures: Schema.Int;
|
|
359
261
|
}>;
|
|
360
262
|
/** Admission receipt for the start command. */
|
|
@@ -374,34 +276,20 @@ export declare const loopContract: {
|
|
|
374
276
|
readonly input: Schema.Struct<{}>;
|
|
375
277
|
/** Return the paused loop. */
|
|
376
278
|
readonly output: Schema.Struct<{
|
|
377
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
378
279
|
readonly loopId: Schema.String;
|
|
379
|
-
/** Whether a person or the model started this loop. */
|
|
380
280
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
381
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
382
281
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
383
|
-
/** Original instruction repeated for every occurrence. */
|
|
384
282
|
readonly prompt: Schema.String;
|
|
385
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
386
283
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
387
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
388
284
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
389
|
-
/** Cron expression for the fixed cadence. */
|
|
390
285
|
readonly expression: Schema.String;
|
|
391
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
392
286
|
readonly timeZone: Schema.String;
|
|
393
287
|
}>>;
|
|
394
|
-
/** Current loop lifecycle state. */
|
|
395
288
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
396
|
-
/** Latest accepted command associated with this loop. */
|
|
397
289
|
readonly commandId: Schema.String;
|
|
398
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
399
290
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
400
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
401
291
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
402
|
-
/** Visible explanation when loop work failed. */
|
|
403
292
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
404
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
405
293
|
readonly consecutiveFailures: Schema.Int;
|
|
406
294
|
}>;
|
|
407
295
|
};
|
|
@@ -413,34 +301,20 @@ export declare const loopContract: {
|
|
|
413
301
|
readonly input: Schema.Struct<{}>;
|
|
414
302
|
/** Return the resumed loop. */
|
|
415
303
|
readonly output: Schema.Struct<{
|
|
416
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
417
304
|
readonly loopId: Schema.String;
|
|
418
|
-
/** Whether a person or the model started this loop. */
|
|
419
305
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
420
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
421
306
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
422
|
-
/** Original instruction repeated for every occurrence. */
|
|
423
307
|
readonly prompt: Schema.String;
|
|
424
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
425
308
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
426
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
427
309
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
428
|
-
/** Cron expression for the fixed cadence. */
|
|
429
310
|
readonly expression: Schema.String;
|
|
430
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
431
311
|
readonly timeZone: Schema.String;
|
|
432
312
|
}>>;
|
|
433
|
-
/** Current loop lifecycle state. */
|
|
434
313
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
435
|
-
/** Latest accepted command associated with this loop. */
|
|
436
314
|
readonly commandId: Schema.String;
|
|
437
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
438
315
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
439
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
440
316
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
441
|
-
/** Visible explanation when loop work failed. */
|
|
442
317
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
443
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
444
318
|
readonly consecutiveFailures: Schema.Int;
|
|
445
319
|
}>;
|
|
446
320
|
};
|
|
@@ -452,34 +326,20 @@ export declare const loopContract: {
|
|
|
452
326
|
readonly input: Schema.Struct<{}>;
|
|
453
327
|
/** Return the stopped loop. */
|
|
454
328
|
readonly output: Schema.Struct<{
|
|
455
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
456
329
|
readonly loopId: Schema.String;
|
|
457
|
-
/** Whether a person or the model started this loop. */
|
|
458
330
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
459
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
460
331
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
461
|
-
/** Original instruction repeated for every occurrence. */
|
|
462
332
|
readonly prompt: Schema.String;
|
|
463
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
464
333
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
465
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
466
334
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
467
|
-
/** Cron expression for the fixed cadence. */
|
|
468
335
|
readonly expression: Schema.String;
|
|
469
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
470
336
|
readonly timeZone: Schema.String;
|
|
471
337
|
}>>;
|
|
472
|
-
/** Current loop lifecycle state. */
|
|
473
338
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
474
|
-
/** Latest accepted command associated with this loop. */
|
|
475
339
|
readonly commandId: Schema.String;
|
|
476
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
477
340
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
478
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
479
341
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
480
|
-
/** Visible explanation when loop work failed. */
|
|
481
342
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
482
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
483
343
|
readonly consecutiveFailures: Schema.Int;
|
|
484
344
|
}>;
|
|
485
345
|
};
|
|
@@ -490,34 +350,20 @@ export declare const loopContract: {
|
|
|
490
350
|
readonly schema: Schema.Struct<{
|
|
491
351
|
/** Loop currently visible to Session clients. */
|
|
492
352
|
readonly loop: Schema.Struct<{
|
|
493
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
494
353
|
readonly loopId: Schema.String;
|
|
495
|
-
/** Whether a person or the model started this loop. */
|
|
496
354
|
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
497
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
498
355
|
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
499
|
-
/** Original instruction repeated for every occurrence. */
|
|
500
356
|
readonly prompt: Schema.String;
|
|
501
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
502
357
|
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
503
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
504
358
|
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
505
|
-
/** Cron expression for the fixed cadence. */
|
|
506
359
|
readonly expression: Schema.String;
|
|
507
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
508
360
|
readonly timeZone: Schema.String;
|
|
509
361
|
}>>;
|
|
510
|
-
/** Current loop lifecycle state. */
|
|
511
362
|
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
512
|
-
/** Latest accepted command associated with this loop. */
|
|
513
363
|
readonly commandId: Schema.String;
|
|
514
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
515
364
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
516
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
517
365
|
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
518
|
-
/** Visible explanation when loop work failed. */
|
|
519
366
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
520
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
521
367
|
readonly consecutiveFailures: Schema.Int;
|
|
522
368
|
}>;
|
|
523
369
|
}>;
|
package/dist/loop/contract.js
CHANGED
|
@@ -1,54 +1,15 @@
|
|
|
1
1
|
import { ExtensionId } from "@fungi.computer/shiitake/extensions";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
import { CatalogStep } from "../internal/catalog.js";
|
|
4
|
+
import { Prompt, SessionId } from "../internal/schedule-fields.js";
|
|
5
|
+
import { LoopCron, Loop, LoopListInput } from "./schema.js";
|
|
6
|
+
export { Loop, LoopCron } from "./schema.js";
|
|
4
7
|
/**
|
|
5
8
|
* Session loop: one repeated prompt per Session, either paced by the model
|
|
6
9
|
* (`schedule_next`) or by a fixed cron cadence. Shared by the server
|
|
7
10
|
* extension and every client; its schemas are the one decoder.
|
|
8
11
|
*/
|
|
9
|
-
const Prompt = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256 * 1024)));
|
|
10
12
|
const RequestId = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(200)));
|
|
11
|
-
const SessionId = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256)));
|
|
12
|
-
/** A named cron cadence evaluated in one IANA time zone. */
|
|
13
|
-
export const LoopCron = Schema.Struct({
|
|
14
|
-
/** Cron expression for the fixed cadence. */
|
|
15
|
-
expression: Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256))),
|
|
16
|
-
/** IANA time zone in which the expression is evaluated. */
|
|
17
|
-
timeZone: Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(128))),
|
|
18
|
-
});
|
|
19
|
-
/** One Session's loop as every client sees it. */
|
|
20
|
-
export const Loop = Schema.Struct({
|
|
21
|
-
/** Identity of the loop whose occurrences are being tracked. */
|
|
22
|
-
loopId: Schema.String,
|
|
23
|
-
/** Whether a person or the model started this loop. */
|
|
24
|
-
origin: Schema.Literals(["human", "model"]),
|
|
25
|
-
/** Configured expiry timestamp, or null when absent. */
|
|
26
|
-
expiresAt: Schema.NullOr(Schema.Int),
|
|
27
|
-
/** Original instruction repeated for every occurrence. */
|
|
28
|
-
prompt: Prompt,
|
|
29
|
-
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
30
|
-
mode: Schema.Literals(["self_paced", "fixed_interval"]),
|
|
31
|
-
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
32
|
-
cron: Schema.NullOr(LoopCron),
|
|
33
|
-
/** Current loop lifecycle state. */
|
|
34
|
-
state: Schema.Literals([
|
|
35
|
-
"active",
|
|
36
|
-
"paused",
|
|
37
|
-
"finished",
|
|
38
|
-
"failed",
|
|
39
|
-
"cancelled",
|
|
40
|
-
]),
|
|
41
|
-
/** Latest accepted command associated with this loop. */
|
|
42
|
-
commandId: Schema.String,
|
|
43
|
-
/** The model's stated reason for the next self-paced occurrence. */
|
|
44
|
-
reason: Schema.NullOr(Schema.String),
|
|
45
|
-
/** When the next occurrence is due, if one is scheduled. */
|
|
46
|
-
nextDueAt: Schema.NullOr(Schema.Int),
|
|
47
|
-
/** Visible explanation when loop work failed. */
|
|
48
|
-
lastError: Schema.NullOr(Schema.String),
|
|
49
|
-
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
50
|
-
consecutiveFailures: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
51
|
-
});
|
|
52
13
|
const StartResult = Schema.Struct({
|
|
53
14
|
/** Newly started loop. */
|
|
54
15
|
loop: Loop,
|
|
@@ -111,12 +72,7 @@ export const loopContract = {
|
|
|
111
72
|
/** The Agent owns the collection of its Sessions' Loops. */
|
|
112
73
|
scope: "agent",
|
|
113
74
|
/** Page strictly after a Session identity, in identity order. */
|
|
114
|
-
input:
|
|
115
|
-
/** Exclusive Session cursor. */
|
|
116
|
-
after: Schema.optionalKey(SessionId),
|
|
117
|
-
/** Maximum number of Loop rows to read. */
|
|
118
|
-
limit: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 1, maximum: 64 })))),
|
|
119
|
-
}),
|
|
75
|
+
input: LoopListInput,
|
|
120
76
|
/** Public Loop values with Session targets, never private scheduling state. */
|
|
121
77
|
output: Schema.Array(Schema.Struct({
|
|
122
78
|
...Loop.fields,
|
|
@@ -133,6 +89,15 @@ export const loopContract = {
|
|
|
133
89
|
/** Return the paused Loop without cancelling accepted work. */
|
|
134
90
|
output: Loop,
|
|
135
91
|
},
|
|
92
|
+
/** Resume an identified Loop; refuse a stale target after replacement. */
|
|
93
|
+
resumeLoop: {
|
|
94
|
+
/** The Agent owns the identified Loop and its Session. */
|
|
95
|
+
scope: "agent",
|
|
96
|
+
/** The listed Session and Loop identities must both still match. */
|
|
97
|
+
input: LoopTarget,
|
|
98
|
+
/** Return the resumed Loop without changing accepted work. */
|
|
99
|
+
output: Loop,
|
|
100
|
+
},
|
|
136
101
|
/** Cancel an identified Loop's future occurrences, retaining accepted work. */
|
|
137
102
|
stopLoop: {
|
|
138
103
|
/** The Agent owns the identified Loop and its Session. */
|
package/dist/loop/host.js
CHANGED
|
@@ -506,7 +506,9 @@ function controlIdentifiedLoop(ctx, target, action) {
|
|
|
506
506
|
? Effect.fail(conflict("Session loop has been replaced"))
|
|
507
507
|
: action === "pause"
|
|
508
508
|
? pauseLoop(ctx, target.sessionId)
|
|
509
|
-
:
|
|
509
|
+
: action === "resume"
|
|
510
|
+
? resumeLoop(ctx, target.sessionId)
|
|
511
|
+
: stopLoop(ctx, target.sessionId)));
|
|
510
512
|
}
|
|
511
513
|
function cronForInterval(value, unit) {
|
|
512
514
|
if (unit === "m" || unit === "min")
|
|
@@ -678,6 +680,7 @@ export const loopExtension = defineExtension({
|
|
|
678
680
|
specs: loopContract.commands,
|
|
679
681
|
handlers: (ctx) => ({
|
|
680
682
|
pauseLoop: ({ input }) => controlIdentifiedLoop(ctx, input, "pause"),
|
|
683
|
+
resumeLoop: ({ input }) => controlIdentifiedLoop(ctx, input, "resume"),
|
|
681
684
|
stopLoop: ({ input }) => controlIdentifiedLoop(ctx, input, "stop"),
|
|
682
685
|
list: ({ input }) => ctx.state.loops
|
|
683
686
|
.page({ after: input.after, limit: input.limit ?? 64 })
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** A named cron cadence evaluated in one IANA time zone. */
|
|
3
|
+
export declare const LoopCron: Schema.Struct<{
|
|
4
|
+
/** Cron expression for the fixed cadence. */
|
|
5
|
+
readonly expression: Schema.String;
|
|
6
|
+
/** IANA time zone in which the expression is evaluated. */
|
|
7
|
+
readonly timeZone: Schema.String;
|
|
8
|
+
}>;
|
|
9
|
+
/** One Session's loop as every client sees it. */
|
|
10
|
+
export declare const Loop: Schema.Struct<{
|
|
11
|
+
/** Identity of the loop whose occurrences are being tracked. */
|
|
12
|
+
readonly loopId: Schema.String;
|
|
13
|
+
/** Whether a person or the model started this loop. */
|
|
14
|
+
readonly origin: Schema.Literals<readonly ["human", "model"]>;
|
|
15
|
+
/** Configured expiry timestamp, or null when absent. */
|
|
16
|
+
readonly expiresAt: Schema.NullOr<Schema.Int>;
|
|
17
|
+
/** Original instruction repeated for every occurrence. */
|
|
18
|
+
readonly prompt: Schema.String;
|
|
19
|
+
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
20
|
+
readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
|
|
21
|
+
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
22
|
+
readonly cron: Schema.NullOr<Schema.Struct<{
|
|
23
|
+
/** Cron expression for the fixed cadence. */
|
|
24
|
+
readonly expression: Schema.String;
|
|
25
|
+
/** IANA time zone in which the expression is evaluated. */
|
|
26
|
+
readonly timeZone: Schema.String;
|
|
27
|
+
}>>;
|
|
28
|
+
/** Current loop lifecycle state. */
|
|
29
|
+
readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
|
|
30
|
+
/** Latest accepted command associated with this loop. */
|
|
31
|
+
readonly commandId: Schema.String;
|
|
32
|
+
/** The model's stated reason for the next self-paced occurrence. */
|
|
33
|
+
readonly reason: Schema.NullOr<Schema.String>;
|
|
34
|
+
/** When the next occurrence is due, if one is scheduled. */
|
|
35
|
+
readonly nextDueAt: Schema.NullOr<Schema.Int>;
|
|
36
|
+
/** Visible explanation when loop work failed. */
|
|
37
|
+
readonly lastError: Schema.NullOr<Schema.String>;
|
|
38
|
+
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
39
|
+
readonly consecutiveFailures: Schema.Int;
|
|
40
|
+
}>;
|
|
41
|
+
/** One Session's loop. */
|
|
42
|
+
export type Loop = Schema.Schema.Type<typeof Loop>;
|
|
43
|
+
/** Native bounded Loop page grammar, also used by shared continuations. */
|
|
44
|
+
export declare const LoopListInput: Schema.Struct<{
|
|
45
|
+
/** Exclusive Session cursor. */
|
|
46
|
+
readonly after: Schema.optionalKey<Schema.String>;
|
|
47
|
+
/** Maximum number of Loop rows to read. */
|
|
48
|
+
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
49
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { Prompt, SessionId } from "../internal/schedule-fields.js";
|
|
3
|
+
/** A named cron cadence evaluated in one IANA time zone. */
|
|
4
|
+
export const LoopCron = Schema.Struct({
|
|
5
|
+
/** Cron expression for the fixed cadence. */
|
|
6
|
+
expression: Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256))),
|
|
7
|
+
/** IANA time zone in which the expression is evaluated. */
|
|
8
|
+
timeZone: Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(128))),
|
|
9
|
+
});
|
|
10
|
+
/** One Session's loop as every client sees it. */
|
|
11
|
+
export const Loop = Schema.Struct({
|
|
12
|
+
/** Identity of the loop whose occurrences are being tracked. */
|
|
13
|
+
loopId: Schema.String,
|
|
14
|
+
/** Whether a person or the model started this loop. */
|
|
15
|
+
origin: Schema.Literals(["human", "model"]),
|
|
16
|
+
/** Configured expiry timestamp, or null when absent. */
|
|
17
|
+
expiresAt: Schema.NullOr(Schema.Int),
|
|
18
|
+
/** Original instruction repeated for every occurrence. */
|
|
19
|
+
prompt: Prompt,
|
|
20
|
+
/** Whether the model or a fixed cron cadence schedules occurrences. */
|
|
21
|
+
mode: Schema.Literals(["self_paced", "fixed_interval"]),
|
|
22
|
+
/** Cadence of a fixed-interval loop; null when the model paces it. */
|
|
23
|
+
cron: Schema.NullOr(LoopCron),
|
|
24
|
+
/** Current loop lifecycle state. */
|
|
25
|
+
state: Schema.Literals([
|
|
26
|
+
"active",
|
|
27
|
+
"paused",
|
|
28
|
+
"finished",
|
|
29
|
+
"failed",
|
|
30
|
+
"cancelled",
|
|
31
|
+
]),
|
|
32
|
+
/** Latest accepted command associated with this loop. */
|
|
33
|
+
commandId: Schema.String,
|
|
34
|
+
/** The model's stated reason for the next self-paced occurrence. */
|
|
35
|
+
reason: Schema.NullOr(Schema.String),
|
|
36
|
+
/** When the next occurrence is due, if one is scheduled. */
|
|
37
|
+
nextDueAt: Schema.NullOr(Schema.Int),
|
|
38
|
+
/** Visible explanation when loop work failed. */
|
|
39
|
+
lastError: Schema.NullOr(Schema.String),
|
|
40
|
+
/** Consecutive failed work outcomes; successful work resets this to zero. */
|
|
41
|
+
consecutiveFailures: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
42
|
+
});
|
|
43
|
+
/** Native bounded Loop page grammar, also used by shared continuations. */
|
|
44
|
+
export const LoopListInput = Schema.Struct({
|
|
45
|
+
/** Exclusive Session cursor. */
|
|
46
|
+
after: Schema.optionalKey(SessionId),
|
|
47
|
+
/** Maximum number of Loop rows to read. */
|
|
48
|
+
limit: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 1, maximum: 64 })))),
|
|
49
|
+
});
|