@fungi.computer/shiitake-extensions 0.0.2 → 0.1.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.
Files changed (66) hide show
  1. package/README.md +43 -13
  2. package/dist/almanac/contract.d.ts +94 -0
  3. package/dist/almanac/contract.js +71 -5
  4. package/dist/goal/client.d.ts +5 -2
  5. package/dist/goal/client.js +66 -72
  6. package/dist/goal/contract.d.ts +181 -64
  7. package/dist/goal/contract.js +102 -12
  8. package/dist/goal/host.js +206 -124
  9. package/dist/home/contract.d.ts +18 -0
  10. package/dist/home/contract.js +24 -3
  11. package/dist/home/host.d.ts +3 -0
  12. package/dist/home/host.js +1 -2
  13. package/dist/home/routing.js +13 -24
  14. package/dist/internal/history.d.ts +16 -0
  15. package/dist/internal/history.js +8 -0
  16. package/dist/loop/client.d.ts +1 -1
  17. package/dist/loop/client.js +28 -34
  18. package/dist/loop/contract.d.ts +129 -84
  19. package/dist/loop/contract.js +79 -9
  20. package/dist/loop/host.d.ts +1 -0
  21. package/dist/loop/host.js +89 -48
  22. package/dist/plan/client.d.ts +1 -1
  23. package/dist/plan/contract.d.ts +33 -0
  24. package/dist/plan/contract.js +28 -3
  25. package/dist/plan/host.js +12 -7
  26. package/dist/question/client.d.ts +1 -1
  27. package/dist/question/contract.d.ts +158 -0
  28. package/dist/question/contract.js +92 -7
  29. package/dist/question/host.js +34 -20
  30. package/dist/roster/conversation-agents.d.ts +31 -0
  31. package/dist/roster/conversation-agents.js +114 -0
  32. package/dist/roster.js +1 -0
  33. package/dist/skills/host.d.ts +1 -0
  34. package/dist/skills/host.js +22 -17
  35. package/dist/skills/source.d.ts +34 -0
  36. package/dist/subagents/client.d.ts +1 -1
  37. package/dist/subagents/client.js +43 -12
  38. package/dist/subagents/contract.d.ts +46 -8
  39. package/dist/subagents/contract.js +38 -8
  40. package/dist/subagents/host.d.ts +20 -8
  41. package/dist/subagents/host.js +58 -12
  42. package/docs/api/README.md +35 -0
  43. package/docs/api/almanac/contract.md +90 -0
  44. package/docs/api/almanac/host.md +19 -0
  45. package/docs/api/goal/client.md +26 -0
  46. package/docs/api/goal/contract.md +247 -0
  47. package/docs/api/goal/host.md +29 -0
  48. package/docs/api/home/contract.md +58 -0
  49. package/docs/api/home/host.md +55 -0
  50. package/docs/api/loop/client.md +25 -0
  51. package/docs/api/loop/contract.md +161 -0
  52. package/docs/api/loop/host.md +30 -0
  53. package/docs/api/plan/client.md +26 -0
  54. package/docs/api/plan/contract.md +163 -0
  55. package/docs/api/plan/host.md +19 -0
  56. package/docs/api/question/client.md +25 -0
  57. package/docs/api/question/contract.md +377 -0
  58. package/docs/api/question/host.md +19 -0
  59. package/docs/api/roster/conversation-agents.md +80 -0
  60. package/docs/api/roster.md +40 -0
  61. package/docs/api/skills/host.md +39 -0
  62. package/docs/api/skills/source.md +104 -0
  63. package/docs/api/subagents/client.md +26 -0
  64. package/docs/api/subagents/contract.md +131 -0
  65. package/docs/api/subagents/host.md +115 -0
  66. package/package.json +14 -8
@@ -1,22 +1,31 @@
1
1
  import * as Schema from "effect/Schema";
2
2
  /** A named cron cadence evaluated in one IANA time zone. */
3
3
  export declare const LoopCron: Schema.Struct<{
4
+ /** Cron expression for the fixed cadence. */
4
5
  readonly expression: Schema.String;
6
+ /** IANA time zone in which the expression is evaluated. */
5
7
  readonly timeZone: Schema.String;
6
8
  }>;
7
9
  /** One Session's loop as every client sees it. */
8
10
  export declare const Loop: Schema.Struct<{
11
+ /** Identity of the loop whose occurrences are being tracked. */
9
12
  readonly loopId: Schema.String;
13
+ /** Whether a person or the model started this loop. */
10
14
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
15
+ /** Configured expiry timestamp, or null when absent. */
11
16
  readonly expiresAt: Schema.NullOr<Schema.Int>;
12
17
  /** Original instruction repeated for every occurrence. */
13
18
  readonly prompt: Schema.String;
19
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
14
20
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
15
21
  /** Cadence of a fixed-interval loop; null when the model paces it. */
16
22
  readonly cron: Schema.NullOr<Schema.Struct<{
23
+ /** Cron expression for the fixed cadence. */
17
24
  readonly expression: Schema.String;
25
+ /** IANA time zone in which the expression is evaluated. */
18
26
  readonly timeZone: Schema.String;
19
27
  }>>;
28
+ /** Current loop lifecycle state. */
20
29
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
21
30
  /** Latest accepted command associated with this loop. */
22
31
  readonly commandId: Schema.String;
@@ -26,6 +35,8 @@ export declare const Loop: Schema.Struct<{
26
35
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
27
36
  /** Visible explanation when loop work failed. */
28
37
  readonly lastError: Schema.NullOr<Schema.String>;
38
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
39
+ readonly consecutiveFailures: Schema.Int;
29
40
  }>;
30
41
  /** One Session's loop. */
31
42
  export type Loop = Schema.Schema.Type<typeof Loop>;
@@ -35,26 +46,38 @@ export type Loop = Schema.Schema.Type<typeof Loop>;
35
46
  * interval. A bare call opens the controls.
36
47
  */
37
48
  export declare const LoopCommandInput: Schema.Union<readonly [Schema.Struct<{
49
+ /** Select the loop-starting control. */
38
50
  readonly action: Schema.Literal<"start">;
51
+ /** Human prompt text, optionally prefixed with an interval. */
39
52
  readonly text: Schema.String;
53
+ /** Idempotency key for this start command. */
40
54
  readonly requestId: Schema.String;
41
55
  }>, Schema.Struct<{
56
+ /** Select an existing-loop control or open new-loop entry. */
42
57
  readonly action: Schema.Literals<readonly ["status", "pause", "resume", "stop", "new"]>;
43
58
  }>, Schema.Struct<{}>]>;
44
59
  /** Loop's contract: Session-scope controls and one projection slot. */
45
60
  export declare const LoopProjection: Schema.Struct<{
46
- readonly loop: Schema.NullOr<Schema.Struct<{
61
+ /** Loop currently visible to Session clients. */
62
+ readonly loop: Schema.Struct<{
63
+ /** Identity of the loop whose occurrences are being tracked. */
47
64
  readonly loopId: Schema.String;
65
+ /** Whether a person or the model started this loop. */
48
66
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
67
+ /** Configured expiry timestamp, or null when absent. */
49
68
  readonly expiresAt: Schema.NullOr<Schema.Int>;
50
69
  /** Original instruction repeated for every occurrence. */
51
70
  readonly prompt: Schema.String;
71
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
52
72
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
53
73
  /** Cadence of a fixed-interval loop; null when the model paces it. */
54
74
  readonly cron: Schema.NullOr<Schema.Struct<{
75
+ /** Cron expression for the fixed cadence. */
55
76
  readonly expression: Schema.String;
77
+ /** IANA time zone in which the expression is evaluated. */
56
78
  readonly timeZone: Schema.String;
57
79
  }>>;
80
+ /** Current loop lifecycle state. */
58
81
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
59
82
  /** Latest accepted command associated with this loop. */
60
83
  readonly commandId: Schema.String;
@@ -64,82 +87,68 @@ export declare const LoopProjection: Schema.Struct<{
64
87
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
65
88
  /** Visible explanation when loop work failed. */
66
89
  readonly lastError: Schema.NullOr<Schema.String>;
67
- }>>;
68
- readonly history: Schema.Struct<{
69
- readonly nextSequence: Schema.Int;
70
- readonly omitted: Schema.Int;
71
- readonly events: Schema.$Array<Schema.Struct<{
72
- readonly id: Schema.String;
73
- readonly sequence: Schema.Int;
74
- readonly at: Schema.Int;
75
- readonly commandId: Schema.NullOr<Schema.String>;
76
- readonly event: Schema.Codec<{
77
- readonly loopId: string;
78
- readonly origin: "human" | "model";
79
- readonly expiresAt: number | null;
80
- readonly prompt: string;
81
- readonly mode: "self_paced" | "fixed_interval";
82
- readonly cron: {
83
- readonly expression: string;
84
- readonly timeZone: string;
85
- } | null;
86
- readonly state: "active" | "paused" | "cancelled" | "finished" | "failed";
87
- readonly commandId: string;
88
- readonly reason: string | null;
89
- readonly nextDueAt: number | null;
90
- readonly lastError: string | null;
91
- }, {
92
- readonly loopId: string;
93
- readonly origin: "human" | "model";
94
- readonly expiresAt: number | null;
95
- readonly prompt: string;
96
- readonly mode: "self_paced" | "fixed_interval";
97
- readonly cron: {
98
- readonly expression: string;
99
- readonly timeZone: string;
100
- } | null;
101
- readonly state: "active" | "paused" | "cancelled" | "finished" | "failed";
102
- readonly commandId: string;
103
- readonly reason: string | null;
104
- readonly nextDueAt: number | null;
105
- readonly lastError: string | null;
106
- }, never, never>;
107
- }>>;
90
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
91
+ readonly consecutiveFailures: Schema.Int;
108
92
  }>;
109
93
  }>;
94
+ /** Session-owned loop controls and their visible state. */
110
95
  export declare const loopContract: {
96
+ /** Stable extension identity. */
111
97
  readonly id: string & import("effect/Brand").Brand<"ExtensionId">;
98
+ /** Loop operations admitted by the Session owner. */
112
99
  readonly commands: {
100
+ /** Open or answer the human loop controls. */
113
101
  readonly loop: {
102
+ /** The Session owns this loop. */
114
103
  readonly scope: "session";
104
+ /** Decode the selected human action. */
115
105
  readonly input: Schema.Union<readonly [Schema.Struct<{
106
+ /** Select the loop-starting control. */
116
107
  readonly action: Schema.Literal<"start">;
108
+ /** Human prompt text, optionally prefixed with an interval. */
117
109
  readonly text: Schema.String;
110
+ /** Idempotency key for this start command. */
118
111
  readonly requestId: Schema.String;
119
112
  }>, Schema.Struct<{
113
+ /** Select an existing-loop control or open new-loop entry. */
120
114
  readonly action: Schema.Literals<readonly ["status", "pause", "resume", "stop", "new"]>;
121
115
  }>, Schema.Struct<{}>]>;
116
+ /** Return the server-owned conversation step. */
122
117
  readonly output: Schema.declare<import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1, import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1>;
123
118
  };
119
+ /** Start a loop whose next occurrence is chosen by the model. */
124
120
  readonly startSelfPaced: {
121
+ /** The Session owns this loop. */
125
122
  readonly scope: "session";
123
+ /** Decode the repeated prompt and command identity. */
126
124
  readonly input: Schema.Struct<{
125
+ /** Instruction repeated on every occurrence. */
127
126
  readonly prompt: Schema.String;
127
+ /** Idempotency key for the start command. */
128
128
  readonly requestId: Schema.String;
129
129
  }>;
130
+ /** Return the loop and admission receipt. */
130
131
  readonly output: Schema.Struct<{
132
+ /** Newly started loop. */
131
133
  readonly loop: Schema.Struct<{
134
+ /** Identity of the loop whose occurrences are being tracked. */
132
135
  readonly loopId: Schema.String;
136
+ /** Whether a person or the model started this loop. */
133
137
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
138
+ /** Configured expiry timestamp, or null when absent. */
134
139
  readonly expiresAt: Schema.NullOr<Schema.Int>;
135
140
  /** Original instruction repeated for every occurrence. */
136
141
  readonly prompt: Schema.String;
142
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
137
143
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
138
144
  /** Cadence of a fixed-interval loop; null when the model paces it. */
139
145
  readonly cron: Schema.NullOr<Schema.Struct<{
146
+ /** Cron expression for the fixed cadence. */
140
147
  readonly expression: Schema.String;
148
+ /** IANA time zone in which the expression is evaluated. */
141
149
  readonly timeZone: Schema.String;
142
150
  }>>;
151
+ /** Current loop lifecycle state. */
143
152
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
144
153
  /** Latest accepted command associated with this loop. */
145
154
  readonly commandId: Schema.String;
@@ -149,34 +158,55 @@ export declare const loopContract: {
149
158
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
150
159
  /** Visible explanation when loop work failed. */
151
160
  readonly lastError: Schema.NullOr<Schema.String>;
161
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
162
+ readonly consecutiveFailures: Schema.Int;
152
163
  }>;
164
+ /** Admission receipt for the start command. */
153
165
  readonly accepted: Schema.Struct<{
166
+ /** Successful admission discriminator. */
154
167
  readonly status: Schema.Literal<"accepted">;
168
+ /** Identity of the accepted start command. */
155
169
  readonly commandId: Schema.String;
156
170
  }>;
157
171
  }>;
158
172
  };
173
+ /** Start a loop with a fixed cron cadence. */
159
174
  readonly startFixedInterval: {
175
+ /** The Session owns this loop. */
160
176
  readonly scope: "session";
177
+ /** Decode the prompt, cadence and command identity. */
161
178
  readonly input: Schema.Struct<{
179
+ /** Cron expression for the fixed cadence. */
162
180
  readonly expression: Schema.String;
181
+ /** IANA time zone in which the expression is evaluated. */
163
182
  readonly timeZone: Schema.String;
183
+ /** Instruction repeated on every occurrence. */
164
184
  readonly prompt: Schema.String;
185
+ /** Idempotency key for the start command. */
165
186
  readonly requestId: Schema.String;
166
187
  }>;
188
+ /** Return the loop and admission receipt. */
167
189
  readonly output: Schema.Struct<{
190
+ /** Newly started loop. */
168
191
  readonly loop: Schema.Struct<{
192
+ /** Identity of the loop whose occurrences are being tracked. */
169
193
  readonly loopId: Schema.String;
194
+ /** Whether a person or the model started this loop. */
170
195
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
196
+ /** Configured expiry timestamp, or null when absent. */
171
197
  readonly expiresAt: Schema.NullOr<Schema.Int>;
172
198
  /** Original instruction repeated for every occurrence. */
173
199
  readonly prompt: Schema.String;
200
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
174
201
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
175
202
  /** Cadence of a fixed-interval loop; null when the model paces it. */
176
203
  readonly cron: Schema.NullOr<Schema.Struct<{
204
+ /** Cron expression for the fixed cadence. */
177
205
  readonly expression: Schema.String;
206
+ /** IANA time zone in which the expression is evaluated. */
178
207
  readonly timeZone: Schema.String;
179
208
  }>>;
209
+ /** Current loop lifecycle state. */
180
210
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
181
211
  /** Latest accepted command associated with this loop. */
182
212
  readonly commandId: Schema.String;
@@ -186,28 +216,44 @@ export declare const loopContract: {
186
216
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
187
217
  /** Visible explanation when loop work failed. */
188
218
  readonly lastError: Schema.NullOr<Schema.String>;
219
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
220
+ readonly consecutiveFailures: Schema.Int;
189
221
  }>;
222
+ /** Admission receipt for the start command. */
190
223
  readonly accepted: Schema.Struct<{
224
+ /** Successful admission discriminator. */
191
225
  readonly status: Schema.Literal<"accepted">;
226
+ /** Identity of the accepted start command. */
192
227
  readonly commandId: Schema.String;
193
228
  }>;
194
229
  }>;
195
230
  };
231
+ /** Suspend the current loop. */
196
232
  readonly pause: {
233
+ /** The Session owns this loop. */
197
234
  readonly scope: "session";
235
+ /** No additional arguments are required. */
198
236
  readonly input: Schema.Struct<{}>;
237
+ /** Return the paused loop. */
199
238
  readonly output: Schema.Struct<{
239
+ /** Identity of the loop whose occurrences are being tracked. */
200
240
  readonly loopId: Schema.String;
241
+ /** Whether a person or the model started this loop. */
201
242
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
243
+ /** Configured expiry timestamp, or null when absent. */
202
244
  readonly expiresAt: Schema.NullOr<Schema.Int>;
203
245
  /** Original instruction repeated for every occurrence. */
204
246
  readonly prompt: Schema.String;
247
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
205
248
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
206
249
  /** Cadence of a fixed-interval loop; null when the model paces it. */
207
250
  readonly cron: Schema.NullOr<Schema.Struct<{
251
+ /** Cron expression for the fixed cadence. */
208
252
  readonly expression: Schema.String;
253
+ /** IANA time zone in which the expression is evaluated. */
209
254
  readonly timeZone: Schema.String;
210
255
  }>>;
256
+ /** Current loop lifecycle state. */
211
257
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
212
258
  /** Latest accepted command associated with this loop. */
213
259
  readonly commandId: Schema.String;
@@ -217,23 +263,36 @@ export declare const loopContract: {
217
263
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
218
264
  /** Visible explanation when loop work failed. */
219
265
  readonly lastError: Schema.NullOr<Schema.String>;
266
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
267
+ readonly consecutiveFailures: Schema.Int;
220
268
  }>;
221
269
  };
270
+ /** Resume the current paused loop. */
222
271
  readonly resume: {
272
+ /** The Session owns this loop. */
223
273
  readonly scope: "session";
274
+ /** No additional arguments are required. */
224
275
  readonly input: Schema.Struct<{}>;
276
+ /** Return the resumed loop. */
225
277
  readonly output: Schema.Struct<{
278
+ /** Identity of the loop whose occurrences are being tracked. */
226
279
  readonly loopId: Schema.String;
280
+ /** Whether a person or the model started this loop. */
227
281
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
282
+ /** Configured expiry timestamp, or null when absent. */
228
283
  readonly expiresAt: Schema.NullOr<Schema.Int>;
229
284
  /** Original instruction repeated for every occurrence. */
230
285
  readonly prompt: Schema.String;
286
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
231
287
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
232
288
  /** Cadence of a fixed-interval loop; null when the model paces it. */
233
289
  readonly cron: Schema.NullOr<Schema.Struct<{
290
+ /** Cron expression for the fixed cadence. */
234
291
  readonly expression: Schema.String;
292
+ /** IANA time zone in which the expression is evaluated. */
235
293
  readonly timeZone: Schema.String;
236
294
  }>>;
295
+ /** Current loop lifecycle state. */
237
296
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
238
297
  /** Latest accepted command associated with this loop. */
239
298
  readonly commandId: Schema.String;
@@ -243,23 +302,36 @@ export declare const loopContract: {
243
302
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
244
303
  /** Visible explanation when loop work failed. */
245
304
  readonly lastError: Schema.NullOr<Schema.String>;
305
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
306
+ readonly consecutiveFailures: Schema.Int;
246
307
  }>;
247
308
  };
309
+ /** Stop future occurrences of the current loop. */
248
310
  readonly stop: {
311
+ /** The Session owns this loop. */
249
312
  readonly scope: "session";
313
+ /** No additional arguments are required. */
250
314
  readonly input: Schema.Struct<{}>;
315
+ /** Return the stopped loop. */
251
316
  readonly output: Schema.Struct<{
317
+ /** Identity of the loop whose occurrences are being tracked. */
252
318
  readonly loopId: Schema.String;
319
+ /** Whether a person or the model started this loop. */
253
320
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
321
+ /** Configured expiry timestamp, or null when absent. */
254
322
  readonly expiresAt: Schema.NullOr<Schema.Int>;
255
323
  /** Original instruction repeated for every occurrence. */
256
324
  readonly prompt: Schema.String;
325
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
257
326
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
258
327
  /** Cadence of a fixed-interval loop; null when the model paces it. */
259
328
  readonly cron: Schema.NullOr<Schema.Struct<{
329
+ /** Cron expression for the fixed cadence. */
260
330
  readonly expression: Schema.String;
331
+ /** IANA time zone in which the expression is evaluated. */
261
332
  readonly timeZone: Schema.String;
262
333
  }>>;
334
+ /** Current loop lifecycle state. */
263
335
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
264
336
  /** Latest accepted command associated with this loop. */
265
337
  readonly commandId: Schema.String;
@@ -269,23 +341,35 @@ export declare const loopContract: {
269
341
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
270
342
  /** Visible explanation when loop work failed. */
271
343
  readonly lastError: Schema.NullOr<Schema.String>;
344
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
345
+ readonly consecutiveFailures: Schema.Int;
272
346
  }>;
273
347
  };
274
348
  };
349
+ /** Current loop visible to Session clients. */
275
350
  readonly projection: {
351
+ /** Decoder for projected loop state. */
276
352
  readonly schema: Schema.Struct<{
277
- readonly loop: Schema.NullOr<Schema.Struct<{
353
+ /** Loop currently visible to Session clients. */
354
+ readonly loop: Schema.Struct<{
355
+ /** Identity of the loop whose occurrences are being tracked. */
278
356
  readonly loopId: Schema.String;
357
+ /** Whether a person or the model started this loop. */
279
358
  readonly origin: Schema.Literals<readonly ["human", "model"]>;
359
+ /** Configured expiry timestamp, or null when absent. */
280
360
  readonly expiresAt: Schema.NullOr<Schema.Int>;
281
361
  /** Original instruction repeated for every occurrence. */
282
362
  readonly prompt: Schema.String;
363
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
283
364
  readonly mode: Schema.Literals<readonly ["self_paced", "fixed_interval"]>;
284
365
  /** Cadence of a fixed-interval loop; null when the model paces it. */
285
366
  readonly cron: Schema.NullOr<Schema.Struct<{
367
+ /** Cron expression for the fixed cadence. */
286
368
  readonly expression: Schema.String;
369
+ /** IANA time zone in which the expression is evaluated. */
287
370
  readonly timeZone: Schema.String;
288
371
  }>>;
372
+ /** Current loop lifecycle state. */
289
373
  readonly state: Schema.Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>;
290
374
  /** Latest accepted command associated with this loop. */
291
375
  readonly commandId: Schema.String;
@@ -295,47 +379,8 @@ export declare const loopContract: {
295
379
  readonly nextDueAt: Schema.NullOr<Schema.Int>;
296
380
  /** Visible explanation when loop work failed. */
297
381
  readonly lastError: Schema.NullOr<Schema.String>;
298
- }>>;
299
- readonly history: Schema.Struct<{
300
- readonly nextSequence: Schema.Int;
301
- readonly omitted: Schema.Int;
302
- readonly events: Schema.$Array<Schema.Struct<{
303
- readonly id: Schema.String;
304
- readonly sequence: Schema.Int;
305
- readonly at: Schema.Int;
306
- readonly commandId: Schema.NullOr<Schema.String>;
307
- readonly event: Schema.Codec<{
308
- readonly loopId: string;
309
- readonly origin: "human" | "model";
310
- readonly expiresAt: number | null;
311
- readonly prompt: string;
312
- readonly mode: "self_paced" | "fixed_interval";
313
- readonly cron: {
314
- readonly expression: string;
315
- readonly timeZone: string;
316
- } | null;
317
- readonly state: "active" | "paused" | "cancelled" | "finished" | "failed";
318
- readonly commandId: string;
319
- readonly reason: string | null;
320
- readonly nextDueAt: number | null;
321
- readonly lastError: string | null;
322
- }, {
323
- readonly loopId: string;
324
- readonly origin: "human" | "model";
325
- readonly expiresAt: number | null;
326
- readonly prompt: string;
327
- readonly mode: "self_paced" | "fixed_interval";
328
- readonly cron: {
329
- readonly expression: string;
330
- readonly timeZone: string;
331
- } | null;
332
- readonly state: "active" | "paused" | "cancelled" | "finished" | "failed";
333
- readonly commandId: string;
334
- readonly reason: string | null;
335
- readonly nextDueAt: number | null;
336
- readonly lastError: string | null;
337
- }, never, never>;
338
- }>>;
382
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
383
+ readonly consecutiveFailures: Schema.Int;
339
384
  }>;
340
385
  }>;
341
386
  };
@@ -1,4 +1,3 @@
1
- import { historySchema } from "../internal/history.js";
2
1
  import { ExtensionId } from "@fungi.computer/shiitake/extensions";
3
2
  import * as Schema from "effect/Schema";
4
3
  import { CatalogStep } from "../internal/catalog.js";
@@ -11,19 +10,26 @@ const Prompt = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.ch
11
10
  const RequestId = Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(200)));
12
11
  /** A named cron cadence evaluated in one IANA time zone. */
13
12
  export const LoopCron = Schema.Struct({
13
+ /** Cron expression for the fixed cadence. */
14
14
  expression: Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(256))),
15
+ /** IANA time zone in which the expression is evaluated. */
15
16
  timeZone: Schema.String.pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.isMaxLength(128))),
16
17
  });
17
18
  /** One Session's loop as every client sees it. */
18
19
  export const Loop = Schema.Struct({
20
+ /** Identity of the loop whose occurrences are being tracked. */
19
21
  loopId: Schema.String,
22
+ /** Whether a person or the model started this loop. */
20
23
  origin: Schema.Literals(["human", "model"]),
24
+ /** Configured expiry timestamp, or null when absent. */
21
25
  expiresAt: Schema.NullOr(Schema.Int),
22
26
  /** Original instruction repeated for every occurrence. */
23
27
  prompt: Prompt,
28
+ /** Whether the model or a fixed cron cadence schedules occurrences. */
24
29
  mode: Schema.Literals(["self_paced", "fixed_interval"]),
25
30
  /** Cadence of a fixed-interval loop; null when the model paces it. */
26
31
  cron: Schema.NullOr(LoopCron),
32
+ /** Current loop lifecycle state. */
27
33
  state: Schema.Literals([
28
34
  "active",
29
35
  "paused",
@@ -39,11 +45,17 @@ export const Loop = Schema.Struct({
39
45
  nextDueAt: Schema.NullOr(Schema.Int),
40
46
  /** Visible explanation when loop work failed. */
41
47
  lastError: Schema.NullOr(Schema.String),
48
+ /** Consecutive failed work outcomes; successful work resets this to zero. */
49
+ consecutiveFailures: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
42
50
  });
43
51
  const StartResult = Schema.Struct({
52
+ /** Newly started loop. */
44
53
  loop: Loop,
54
+ /** Admission receipt for the start command. */
45
55
  accepted: Schema.Struct({
56
+ /** Successful admission discriminator. */
46
57
  status: Schema.Literal("accepted"),
58
+ /** Identity of the accepted start command. */
47
59
  commandId: Schema.String,
48
60
  }),
49
61
  });
@@ -54,41 +66,99 @@ const StartResult = Schema.Struct({
54
66
  */
55
67
  export const LoopCommandInput = Schema.Union([
56
68
  Schema.Struct({
69
+ /** Select the loop-starting control. */
57
70
  action: Schema.Literal("start"),
71
+ /** Human prompt text, optionally prefixed with an interval. */
58
72
  text: Prompt,
73
+ /** Idempotency key for this start command. */
59
74
  requestId: RequestId,
60
75
  }),
61
76
  Schema.Struct({
77
+ /** Select an existing-loop control or open new-loop entry. */
62
78
  action: Schema.Literals(["status", "pause", "resume", "stop", "new"]),
63
79
  }),
64
80
  Schema.Struct({}),
65
81
  ]);
66
82
  /** Loop's contract: Session-scope controls and one projection slot. */
67
83
  export const LoopProjection = Schema.Struct({
68
- loop: Schema.NullOr(Loop),
69
- history: historySchema(Loop),
84
+ /** Loop currently visible to Session clients. */
85
+ loop: Loop,
70
86
  });
87
+ /** Session-owned loop controls and their visible state. */
71
88
  export const loopContract = {
89
+ /** Stable extension identity. */
72
90
  id: ExtensionId.make("botanical-session-loop"),
91
+ /** Loop operations admitted by the Session owner. */
73
92
  commands: {
74
- loop: { scope: "session", input: LoopCommandInput, output: CatalogStep },
93
+ /** Open or answer the human loop controls. */
94
+ loop: {
95
+ /** The Session owns this loop. */
96
+ scope: "session",
97
+ /** Decode the selected human action. */
98
+ input: LoopCommandInput,
99
+ /** Return the server-owned conversation step. */
100
+ output: CatalogStep,
101
+ },
102
+ /** Start a loop whose next occurrence is chosen by the model. */
75
103
  startSelfPaced: {
104
+ /** The Session owns this loop. */
76
105
  scope: "session",
77
- input: Schema.Struct({ prompt: Prompt, requestId: RequestId }),
106
+ /** Decode the repeated prompt and command identity. */
107
+ input: Schema.Struct({
108
+ /** Instruction repeated on every occurrence. */
109
+ prompt: Prompt,
110
+ /** Idempotency key for the start command. */
111
+ requestId: RequestId,
112
+ }),
113
+ /** Return the loop and admission receipt. */
78
114
  output: StartResult,
79
115
  },
116
+ /** Start a loop with a fixed cron cadence. */
80
117
  startFixedInterval: {
118
+ /** The Session owns this loop. */
81
119
  scope: "session",
120
+ /** Decode the prompt, cadence and command identity. */
82
121
  input: Schema.Struct({
122
+ /** Instruction repeated on every occurrence. */
83
123
  prompt: Prompt,
124
+ /** Idempotency key for the start command. */
84
125
  requestId: RequestId,
85
126
  ...LoopCron.fields,
86
127
  }),
128
+ /** Return the loop and admission receipt. */
87
129
  output: StartResult,
88
130
  },
89
- pause: { scope: "session", input: Schema.Struct({}), output: Loop },
90
- resume: { scope: "session", input: Schema.Struct({}), output: Loop },
91
- stop: { scope: "session", input: Schema.Struct({}), output: Loop },
131
+ /** Suspend the current loop. */
132
+ pause: {
133
+ /** The Session owns this loop. */
134
+ scope: "session",
135
+ /** No additional arguments are required. */
136
+ input: Schema.Struct({}),
137
+ /** Return the paused loop. */
138
+ output: Loop,
139
+ },
140
+ /** Resume the current paused loop. */
141
+ resume: {
142
+ /** The Session owns this loop. */
143
+ scope: "session",
144
+ /** No additional arguments are required. */
145
+ input: Schema.Struct({}),
146
+ /** Return the resumed loop. */
147
+ output: Loop,
148
+ },
149
+ /** Stop future occurrences of the current loop. */
150
+ stop: {
151
+ /** The Session owns this loop. */
152
+ scope: "session",
153
+ /** No additional arguments are required. */
154
+ input: Schema.Struct({}),
155
+ /** Return the stopped loop. */
156
+ output: Loop,
157
+ },
158
+ },
159
+ /** Current loop visible to Session clients. */
160
+ projection: {
161
+ /** Decoder for projected loop state. */
162
+ schema: LoopProjection,
92
163
  },
93
- projection: { schema: LoopProjection },
94
164
  };
@@ -1,4 +1,5 @@
1
1
  import { type RosteredExtensionV0 } from "@fungi.computer/shiitake/extensions";
2
2
  /** The commands this extension advertises to every client. */
3
3
  export declare const loopCatalog: import("@fungi.computer/shiitake/extensions").Json;
4
+ /** Durable Session loop implementation with prompts, controls and scheduled occurrences. */
4
5
  export declare const loopExtension: RosteredExtensionV0;