@swirls/looms 0.24.0 → 0.25.0
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/CHANGELOG.md +16 -0
- package/dist/agent/threads.js +4 -1
- package/dist/approval/effects.d.ts +26 -26
- package/dist/approval/module.d.ts +52 -52
- package/dist/debugger/app/assets/index-GLtrulmj.js +23 -0
- package/dist/debugger/app/assets/{routes-Ch30UGik.js → routes-CECZJJob.js} +1 -1
- package/dist/debugger/app/index.html +1 -1
- package/dist/evaluator/effects.d.ts +33 -33
- package/dist/evaluator/module.d.ts +66 -66
- package/dist/schedule/module.d.ts +36 -36
- package/dist/swarm/board.d.ts +292 -0
- package/dist/swarm/board.js +123 -0
- package/dist/swarm/conformance.d.ts +15 -0
- package/dist/swarm/conformance.js +225 -0
- package/dist/swarm/definitions.d.ts +94 -0
- package/dist/swarm/definitions.js +51 -0
- package/dist/swarm/effects.d.ts +4720 -0
- package/dist/swarm/effects.js +296 -0
- package/dist/swarm/ensure.d.ts +16 -0
- package/dist/swarm/ensure.js +24 -0
- package/dist/swarm/events.d.ts +240 -0
- package/dist/swarm/events.js +49 -0
- package/dist/swarm/index.d.ts +15 -0
- package/dist/swarm/index.js +15 -0
- package/dist/swarm/memory-board.d.ts +10 -0
- package/dist/swarm/memory-board.js +344 -0
- package/dist/swarm/module.d.ts +9593 -0
- package/dist/swarm/module.js +94 -0
- package/dist/swarm/projections.d.ts +60 -0
- package/dist/swarm/projections.js +102 -0
- package/dist/swarm/prompt.d.ts +4 -0
- package/dist/swarm/prompt.js +35 -0
- package/dist/swarm/scope.d.ts +357 -0
- package/dist/swarm/scope.js +8 -0
- package/dist/swarm/services.d.ts +29 -0
- package/dist/swarm/services.js +40 -0
- package/dist/swarm/signals.d.ts +14 -0
- package/dist/swarm/signals.js +15 -0
- package/dist/swarm/steps.d.ts +15 -0
- package/dist/swarm/steps.js +27 -0
- package/dist/swarm/threads.d.ts +41 -0
- package/dist/swarm/threads.js +244 -0
- package/dist/swarm/tools.d.ts +19 -0
- package/dist/swarm/tools.js +100 -0
- package/package.json +7 -2
- package/dist/debugger/app/assets/index-CxbIGkpY.js +0 -22
|
@@ -43,6 +43,39 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
43
43
|
readonly definitionVersion?: string | undefined;
|
|
44
44
|
readonly input?: import("effect/Schema").Json | undefined;
|
|
45
45
|
}, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
46
|
+
readonly type: "evaluator.evaluated";
|
|
47
|
+
readonly payload: {
|
|
48
|
+
readonly evaluationId: string;
|
|
49
|
+
readonly definitionName?: string | undefined;
|
|
50
|
+
readonly answers: {
|
|
51
|
+
readonly [x: string]: {
|
|
52
|
+
readonly type: "boolean";
|
|
53
|
+
readonly value: boolean;
|
|
54
|
+
readonly probability: number;
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: "choice";
|
|
57
|
+
readonly value: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "score";
|
|
60
|
+
readonly value: number;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly route: string;
|
|
64
|
+
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
65
|
+
readonly usage?: {
|
|
66
|
+
readonly input: number;
|
|
67
|
+
readonly output: number;
|
|
68
|
+
} | undefined;
|
|
69
|
+
};
|
|
70
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
71
|
+
readonly type: "evaluator.requested";
|
|
72
|
+
readonly payload: {
|
|
73
|
+
readonly evaluationId: string;
|
|
74
|
+
readonly definitionName?: string | undefined;
|
|
75
|
+
readonly state: string;
|
|
76
|
+
readonly model?: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
46
79
|
readonly type: "runtime.child.close.requested";
|
|
47
80
|
readonly payload: {
|
|
48
81
|
readonly policy: "terminate" | "wait";
|
|
@@ -288,39 +321,6 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
288
321
|
readonly payload: import("effect/Schema").Json;
|
|
289
322
|
};
|
|
290
323
|
};
|
|
291
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
292
|
-
readonly type: "evaluator.evaluated";
|
|
293
|
-
readonly payload: {
|
|
294
|
-
readonly evaluationId: string;
|
|
295
|
-
readonly definitionName?: string | undefined;
|
|
296
|
-
readonly answers: {
|
|
297
|
-
readonly [x: string]: {
|
|
298
|
-
readonly type: "boolean";
|
|
299
|
-
readonly value: boolean;
|
|
300
|
-
readonly probability: number;
|
|
301
|
-
} | {
|
|
302
|
-
readonly type: "choice";
|
|
303
|
-
readonly value: string;
|
|
304
|
-
} | {
|
|
305
|
-
readonly type: "score";
|
|
306
|
-
readonly value: number;
|
|
307
|
-
};
|
|
308
|
-
};
|
|
309
|
-
readonly route: string;
|
|
310
|
-
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
311
|
-
readonly usage?: {
|
|
312
|
-
readonly input: number;
|
|
313
|
-
readonly output: number;
|
|
314
|
-
} | undefined;
|
|
315
|
-
};
|
|
316
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
317
|
-
readonly type: "evaluator.requested";
|
|
318
|
-
readonly payload: {
|
|
319
|
-
readonly evaluationId: string;
|
|
320
|
-
readonly definitionName?: string | undefined;
|
|
321
|
-
readonly state: string;
|
|
322
|
-
readonly model?: string | undefined;
|
|
323
|
-
};
|
|
324
324
|
})>;
|
|
325
325
|
}, {
|
|
326
326
|
evaluator: import("@swirls/looms/core").ThreadDefinition<{
|
|
@@ -391,6 +391,39 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
391
391
|
readonly definitionVersion?: string | undefined;
|
|
392
392
|
readonly input?: import("effect/Schema").Json | undefined;
|
|
393
393
|
}, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
394
|
+
readonly type: "evaluator.evaluated";
|
|
395
|
+
readonly payload: {
|
|
396
|
+
readonly evaluationId: string;
|
|
397
|
+
readonly definitionName?: string | undefined;
|
|
398
|
+
readonly answers: {
|
|
399
|
+
readonly [x: string]: {
|
|
400
|
+
readonly type: "boolean";
|
|
401
|
+
readonly value: boolean;
|
|
402
|
+
readonly probability: number;
|
|
403
|
+
} | {
|
|
404
|
+
readonly type: "choice";
|
|
405
|
+
readonly value: string;
|
|
406
|
+
} | {
|
|
407
|
+
readonly type: "score";
|
|
408
|
+
readonly value: number;
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
readonly route: string;
|
|
412
|
+
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
413
|
+
readonly usage?: {
|
|
414
|
+
readonly input: number;
|
|
415
|
+
readonly output: number;
|
|
416
|
+
} | undefined;
|
|
417
|
+
};
|
|
418
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
419
|
+
readonly type: "evaluator.requested";
|
|
420
|
+
readonly payload: {
|
|
421
|
+
readonly evaluationId: string;
|
|
422
|
+
readonly definitionName?: string | undefined;
|
|
423
|
+
readonly state: string;
|
|
424
|
+
readonly model?: string | undefined;
|
|
425
|
+
};
|
|
426
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
394
427
|
readonly type: "runtime.child.close.requested";
|
|
395
428
|
readonly payload: {
|
|
396
429
|
readonly policy: "terminate" | "wait";
|
|
@@ -636,39 +669,6 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
636
669
|
readonly payload: import("effect/Schema").Json;
|
|
637
670
|
};
|
|
638
671
|
};
|
|
639
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
640
|
-
readonly type: "evaluator.evaluated";
|
|
641
|
-
readonly payload: {
|
|
642
|
-
readonly evaluationId: string;
|
|
643
|
-
readonly definitionName?: string | undefined;
|
|
644
|
-
readonly answers: {
|
|
645
|
-
readonly [x: string]: {
|
|
646
|
-
readonly type: "boolean";
|
|
647
|
-
readonly value: boolean;
|
|
648
|
-
readonly probability: number;
|
|
649
|
-
} | {
|
|
650
|
-
readonly type: "choice";
|
|
651
|
-
readonly value: string;
|
|
652
|
-
} | {
|
|
653
|
-
readonly type: "score";
|
|
654
|
-
readonly value: number;
|
|
655
|
-
};
|
|
656
|
-
};
|
|
657
|
-
readonly route: string;
|
|
658
|
-
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
659
|
-
readonly usage?: {
|
|
660
|
-
readonly input: number;
|
|
661
|
-
readonly output: number;
|
|
662
|
-
} | undefined;
|
|
663
|
-
};
|
|
664
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
665
|
-
readonly type: "evaluator.requested";
|
|
666
|
-
readonly payload: {
|
|
667
|
-
readonly evaluationId: string;
|
|
668
|
-
readonly definitionName?: string | undefined;
|
|
669
|
-
readonly state: string;
|
|
670
|
-
readonly model?: string | undefined;
|
|
671
|
-
};
|
|
672
672
|
})>;
|
|
673
673
|
};
|
|
674
674
|
readonly threads: {
|
|
@@ -342,6 +342,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
342
342
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
343
343
|
readonly type: "schedule.paused";
|
|
344
344
|
readonly payload: {};
|
|
345
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
346
|
+
readonly type: "schedule.resumed";
|
|
347
|
+
readonly payload: {};
|
|
348
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
349
|
+
readonly type: "schedule.retired";
|
|
350
|
+
readonly payload: {};
|
|
351
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
352
|
+
readonly type: "schedule.triggered";
|
|
353
|
+
readonly payload: {};
|
|
345
354
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
346
355
|
readonly type: "schedule.planned";
|
|
347
356
|
readonly payload: {
|
|
@@ -365,12 +374,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
365
374
|
readonly payload: {
|
|
366
375
|
readonly reason: string;
|
|
367
376
|
};
|
|
368
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
369
|
-
readonly type: "schedule.resumed";
|
|
370
|
-
readonly payload: {};
|
|
371
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
372
|
-
readonly type: "schedule.retired";
|
|
373
|
-
readonly payload: {};
|
|
374
377
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
375
378
|
readonly type: "schedule.skipped";
|
|
376
379
|
readonly payload: {
|
|
@@ -381,9 +384,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
381
384
|
readonly manual: boolean;
|
|
382
385
|
readonly triggerId?: string | undefined;
|
|
383
386
|
};
|
|
384
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
385
|
-
readonly type: "schedule.triggered";
|
|
386
|
-
readonly payload: {};
|
|
387
387
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
388
388
|
readonly type: "schedule.updated";
|
|
389
389
|
readonly payload: {
|
|
@@ -693,6 +693,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
693
693
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
694
694
|
readonly type: "schedule.paused";
|
|
695
695
|
readonly payload: {};
|
|
696
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
697
|
+
readonly type: "schedule.resumed";
|
|
698
|
+
readonly payload: {};
|
|
699
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
700
|
+
readonly type: "schedule.retired";
|
|
701
|
+
readonly payload: {};
|
|
702
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
703
|
+
readonly type: "schedule.triggered";
|
|
704
|
+
readonly payload: {};
|
|
696
705
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
697
706
|
readonly type: "schedule.planned";
|
|
698
707
|
readonly payload: {
|
|
@@ -716,12 +725,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
716
725
|
readonly payload: {
|
|
717
726
|
readonly reason: string;
|
|
718
727
|
};
|
|
719
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
720
|
-
readonly type: "schedule.resumed";
|
|
721
|
-
readonly payload: {};
|
|
722
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
723
|
-
readonly type: "schedule.retired";
|
|
724
|
-
readonly payload: {};
|
|
725
728
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
726
729
|
readonly type: "schedule.skipped";
|
|
727
730
|
readonly payload: {
|
|
@@ -732,9 +735,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
732
735
|
readonly manual: boolean;
|
|
733
736
|
readonly triggerId?: string | undefined;
|
|
734
737
|
};
|
|
735
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
736
|
-
readonly type: "schedule.triggered";
|
|
737
|
-
readonly payload: {};
|
|
738
738
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
739
739
|
readonly type: "schedule.updated";
|
|
740
740
|
readonly payload: {
|
|
@@ -1120,6 +1120,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1120
1120
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1121
1121
|
readonly type: "schedule.paused";
|
|
1122
1122
|
readonly payload: {};
|
|
1123
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1124
|
+
readonly type: "schedule.resumed";
|
|
1125
|
+
readonly payload: {};
|
|
1126
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1127
|
+
readonly type: "schedule.retired";
|
|
1128
|
+
readonly payload: {};
|
|
1129
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1130
|
+
readonly type: "schedule.triggered";
|
|
1131
|
+
readonly payload: {};
|
|
1123
1132
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1124
1133
|
readonly type: "schedule.planned";
|
|
1125
1134
|
readonly payload: {
|
|
@@ -1143,12 +1152,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1143
1152
|
readonly payload: {
|
|
1144
1153
|
readonly reason: string;
|
|
1145
1154
|
};
|
|
1146
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1147
|
-
readonly type: "schedule.resumed";
|
|
1148
|
-
readonly payload: {};
|
|
1149
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1150
|
-
readonly type: "schedule.retired";
|
|
1151
|
-
readonly payload: {};
|
|
1152
1155
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1153
1156
|
readonly type: "schedule.skipped";
|
|
1154
1157
|
readonly payload: {
|
|
@@ -1159,9 +1162,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1159
1162
|
readonly manual: boolean;
|
|
1160
1163
|
readonly triggerId?: string | undefined;
|
|
1161
1164
|
};
|
|
1162
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1163
|
-
readonly type: "schedule.triggered";
|
|
1164
|
-
readonly payload: {};
|
|
1165
1165
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1166
1166
|
readonly type: "schedule.updated";
|
|
1167
1167
|
readonly payload: {
|
|
@@ -1471,6 +1471,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1471
1471
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1472
1472
|
readonly type: "schedule.paused";
|
|
1473
1473
|
readonly payload: {};
|
|
1474
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1475
|
+
readonly type: "schedule.resumed";
|
|
1476
|
+
readonly payload: {};
|
|
1477
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1478
|
+
readonly type: "schedule.retired";
|
|
1479
|
+
readonly payload: {};
|
|
1480
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1481
|
+
readonly type: "schedule.triggered";
|
|
1482
|
+
readonly payload: {};
|
|
1474
1483
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1475
1484
|
readonly type: "schedule.planned";
|
|
1476
1485
|
readonly payload: {
|
|
@@ -1494,12 +1503,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1494
1503
|
readonly payload: {
|
|
1495
1504
|
readonly reason: string;
|
|
1496
1505
|
};
|
|
1497
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1498
|
-
readonly type: "schedule.resumed";
|
|
1499
|
-
readonly payload: {};
|
|
1500
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1501
|
-
readonly type: "schedule.retired";
|
|
1502
|
-
readonly payload: {};
|
|
1503
1506
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1504
1507
|
readonly type: "schedule.skipped";
|
|
1505
1508
|
readonly payload: {
|
|
@@ -1510,9 +1513,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1510
1513
|
readonly manual: boolean;
|
|
1511
1514
|
readonly triggerId?: string | undefined;
|
|
1512
1515
|
};
|
|
1513
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1514
|
-
readonly type: "schedule.triggered";
|
|
1515
|
-
readonly payload: {};
|
|
1516
1516
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1517
1517
|
readonly type: "schedule.updated";
|
|
1518
1518
|
readonly payload: {
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* A message board is the only thing swarm members share. It holds channels of threaded messages,
|
|
4
|
+
* tasks that members claim under a lease, and one ordered event log that a swarm follows.
|
|
5
|
+
*
|
|
6
|
+
* Implement {@link MessageBoard} over any store and check it with `boardConformance`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BoardLabelsSchema: Schema.$Record<Schema.String, Schema.String>;
|
|
9
|
+
export type BoardLabels = Schema.Schema.Type<typeof BoardLabelsSchema>;
|
|
10
|
+
export declare const BoardMessageSchema: Schema.Struct<{
|
|
11
|
+
readonly id: Schema.String;
|
|
12
|
+
/** A path such as `support` or `support/billing`. The first post creates it. */
|
|
13
|
+
readonly channel: Schema.String;
|
|
14
|
+
readonly text: Schema.String;
|
|
15
|
+
/** The member or person who wrote it. */
|
|
16
|
+
readonly by: Schema.String;
|
|
17
|
+
/** The root message of the thread, or null when this message is a root. */
|
|
18
|
+
readonly re: Schema.NullOr<Schema.String>;
|
|
19
|
+
/** Names written as `@name` in `text`. */
|
|
20
|
+
readonly mentions: Schema.$Array<Schema.String>;
|
|
21
|
+
/** `key=value` state. Keys under `board.` belong to the board. */
|
|
22
|
+
readonly labels: Schema.$Record<Schema.String, Schema.String>;
|
|
23
|
+
readonly createdAt: Schema.Finite;
|
|
24
|
+
}>;
|
|
25
|
+
export type BoardMessage = Schema.Schema.Type<typeof BoardMessageSchema>;
|
|
26
|
+
export declare const TaskStateSchema: Schema.Union<readonly [Schema.Literal<"waiting">, Schema.Literal<"ready">, Schema.Literal<"claimed">, Schema.Literal<"blocked">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"canceled">]>;
|
|
27
|
+
export type TaskState = Schema.Schema.Type<typeof TaskStateSchema>;
|
|
28
|
+
/** A task is a thread with state the board keeps. Its id is the id of its root message. */
|
|
29
|
+
export declare const BoardTaskSchema: Schema.Struct<{
|
|
30
|
+
readonly id: Schema.String;
|
|
31
|
+
readonly channel: Schema.String;
|
|
32
|
+
readonly text: Schema.String;
|
|
33
|
+
readonly by: Schema.String;
|
|
34
|
+
/** The only member who may claim it, or null when anyone may. */
|
|
35
|
+
readonly for: Schema.NullOr<Schema.String>;
|
|
36
|
+
/** Tasks that must complete before this one is ready. */
|
|
37
|
+
readonly needs: Schema.$Array<Schema.String>;
|
|
38
|
+
readonly state: Schema.Union<readonly [Schema.Literal<"waiting">, Schema.Literal<"ready">, Schema.Literal<"claimed">, Schema.Literal<"blocked">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"canceled">]>;
|
|
39
|
+
/** Who holds the current claim. */
|
|
40
|
+
readonly holder: Schema.NullOr<Schema.String>;
|
|
41
|
+
/** Counts claims. A claim from an earlier epoch can no longer change the task. */
|
|
42
|
+
readonly epoch: Schema.Finite;
|
|
43
|
+
readonly leaseUntil: Schema.NullOr<Schema.Finite>;
|
|
44
|
+
/** The result, failure reason, or blocker written when the task last changed state. */
|
|
45
|
+
readonly note: Schema.NullOr<Schema.String>;
|
|
46
|
+
readonly createdAt: Schema.Finite;
|
|
47
|
+
readonly updatedAt: Schema.Finite;
|
|
48
|
+
}>;
|
|
49
|
+
export type BoardTask = Schema.Schema.Type<typeof BoardTaskSchema>;
|
|
50
|
+
export declare const TaskClaimSchema: Schema.Struct<{
|
|
51
|
+
readonly task: Schema.Struct<{
|
|
52
|
+
readonly id: Schema.String;
|
|
53
|
+
readonly channel: Schema.String;
|
|
54
|
+
readonly text: Schema.String;
|
|
55
|
+
readonly by: Schema.String;
|
|
56
|
+
/** The only member who may claim it, or null when anyone may. */
|
|
57
|
+
readonly for: Schema.NullOr<Schema.String>;
|
|
58
|
+
/** Tasks that must complete before this one is ready. */
|
|
59
|
+
readonly needs: Schema.$Array<Schema.String>;
|
|
60
|
+
readonly state: Schema.Union<readonly [Schema.Literal<"waiting">, Schema.Literal<"ready">, Schema.Literal<"claimed">, Schema.Literal<"blocked">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"canceled">]>;
|
|
61
|
+
/** Who holds the current claim. */
|
|
62
|
+
readonly holder: Schema.NullOr<Schema.String>;
|
|
63
|
+
/** Counts claims. A claim from an earlier epoch can no longer change the task. */
|
|
64
|
+
readonly epoch: Schema.Finite;
|
|
65
|
+
readonly leaseUntil: Schema.NullOr<Schema.Finite>;
|
|
66
|
+
/** The result, failure reason, or blocker written when the task last changed state. */
|
|
67
|
+
readonly note: Schema.NullOr<Schema.String>;
|
|
68
|
+
readonly createdAt: Schema.Finite;
|
|
69
|
+
readonly updatedAt: Schema.Finite;
|
|
70
|
+
}>;
|
|
71
|
+
/** Proves the holder to `renew` and `settle`. It stops working when the claim is lost. */
|
|
72
|
+
readonly token: Schema.String;
|
|
73
|
+
readonly until: Schema.Finite;
|
|
74
|
+
}>;
|
|
75
|
+
export type TaskClaim = Schema.Schema.Type<typeof TaskClaimSchema>;
|
|
76
|
+
export declare const BoardEventTypeSchema: Schema.Union<readonly [Schema.Literal<"message.posted">, Schema.Literal<"message.labeled">, Schema.Literal<"task.created">, Schema.Literal<"task.ready">, Schema.Literal<"task.claimed">, Schema.Literal<"task.blocked">, Schema.Literal<"task.completed">, Schema.Literal<"task.failed">, Schema.Literal<"task.canceled">, Schema.Literal<"task.reopened">]>;
|
|
77
|
+
export type BoardEventType = Schema.Schema.Type<typeof BoardEventTypeSchema>;
|
|
78
|
+
export declare const BoardEventSchema: Schema.Struct<{
|
|
79
|
+
/** Opaque position in the board's log. Pass it back unchanged; do not compare or parse it. */
|
|
80
|
+
readonly cursor: Schema.String;
|
|
81
|
+
readonly type: Schema.Union<readonly [Schema.Literal<"message.posted">, Schema.Literal<"message.labeled">, Schema.Literal<"task.created">, Schema.Literal<"task.ready">, Schema.Literal<"task.claimed">, Schema.Literal<"task.blocked">, Schema.Literal<"task.completed">, Schema.Literal<"task.failed">, Schema.Literal<"task.canceled">, Schema.Literal<"task.reopened">]>;
|
|
82
|
+
readonly at: Schema.Finite;
|
|
83
|
+
/** Who caused the event. `BOARD_ACTOR` when the board did, such as an expired lease. */
|
|
84
|
+
readonly by: Schema.String;
|
|
85
|
+
/** The message as it was after the event. Present on message events and on `task.created`. */
|
|
86
|
+
readonly message: Schema.optional<Schema.Struct<{
|
|
87
|
+
readonly id: Schema.String;
|
|
88
|
+
/** A path such as `support` or `support/billing`. The first post creates it. */
|
|
89
|
+
readonly channel: Schema.String;
|
|
90
|
+
readonly text: Schema.String;
|
|
91
|
+
/** The member or person who wrote it. */
|
|
92
|
+
readonly by: Schema.String;
|
|
93
|
+
/** The root message of the thread, or null when this message is a root. */
|
|
94
|
+
readonly re: Schema.NullOr<Schema.String>;
|
|
95
|
+
/** Names written as `@name` in `text`. */
|
|
96
|
+
readonly mentions: Schema.$Array<Schema.String>;
|
|
97
|
+
/** `key=value` state. Keys under `board.` belong to the board. */
|
|
98
|
+
readonly labels: Schema.$Record<Schema.String, Schema.String>;
|
|
99
|
+
readonly createdAt: Schema.Finite;
|
|
100
|
+
}>>;
|
|
101
|
+
/** The task as it was after the event. Present on every task event. */
|
|
102
|
+
readonly task: Schema.optional<Schema.Struct<{
|
|
103
|
+
readonly id: Schema.String;
|
|
104
|
+
readonly channel: Schema.String;
|
|
105
|
+
readonly text: Schema.String;
|
|
106
|
+
readonly by: Schema.String;
|
|
107
|
+
/** The only member who may claim it, or null when anyone may. */
|
|
108
|
+
readonly for: Schema.NullOr<Schema.String>;
|
|
109
|
+
/** Tasks that must complete before this one is ready. */
|
|
110
|
+
readonly needs: Schema.$Array<Schema.String>;
|
|
111
|
+
readonly state: Schema.Union<readonly [Schema.Literal<"waiting">, Schema.Literal<"ready">, Schema.Literal<"claimed">, Schema.Literal<"blocked">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"canceled">]>;
|
|
112
|
+
/** Who holds the current claim. */
|
|
113
|
+
readonly holder: Schema.NullOr<Schema.String>;
|
|
114
|
+
/** Counts claims. A claim from an earlier epoch can no longer change the task. */
|
|
115
|
+
readonly epoch: Schema.Finite;
|
|
116
|
+
readonly leaseUntil: Schema.NullOr<Schema.Finite>;
|
|
117
|
+
/** The result, failure reason, or blocker written when the task last changed state. */
|
|
118
|
+
readonly note: Schema.NullOr<Schema.String>;
|
|
119
|
+
readonly createdAt: Schema.Finite;
|
|
120
|
+
readonly updatedAt: Schema.Finite;
|
|
121
|
+
}>>;
|
|
122
|
+
}>;
|
|
123
|
+
export type BoardEvent = Schema.Schema.Type<typeof BoardEventSchema>;
|
|
124
|
+
/** The `by` of events the board causes itself. */
|
|
125
|
+
export declare const BOARD_ACTOR = "board";
|
|
126
|
+
/** The label a task's root message carries. Its value is the task state. */
|
|
127
|
+
export declare const TASK_LABEL = "board.task";
|
|
128
|
+
/** Label keys with this prefix are written only by the board. */
|
|
129
|
+
export declare const RESERVED_LABEL_PREFIX = "board.";
|
|
130
|
+
export declare const DEFAULT_LEASE_MS: number;
|
|
131
|
+
export declare const MAX_LEASE_MS: number;
|
|
132
|
+
export type BoardErrorCode = 'invalid_input' | 'message_not_found' | 'task_not_found' | 'duplicate_key' | 'reserved_label' | 'label_conflict' | 'invalid_needs' | 'task_claimed' | 'task_assigned' | 'task_not_ready' | 'task_finished' | 'claim_lost';
|
|
133
|
+
declare const BoardError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
134
|
+
readonly _tag: "BoardError";
|
|
135
|
+
} & Readonly<A>;
|
|
136
|
+
/**
|
|
137
|
+
* A request the board refused. Retrying the same request fails the same way, so the swarm module
|
|
138
|
+
* reports it to the calling agent and does not retry. Throw any other error for a fault that a
|
|
139
|
+
* retry might clear.
|
|
140
|
+
*/
|
|
141
|
+
export declare class BoardError extends BoardError_base<{
|
|
142
|
+
readonly code: BoardErrorCode;
|
|
143
|
+
readonly message: string;
|
|
144
|
+
}> {
|
|
145
|
+
}
|
|
146
|
+
export interface PostInput {
|
|
147
|
+
readonly by: string;
|
|
148
|
+
readonly channel: string;
|
|
149
|
+
readonly text: string;
|
|
150
|
+
readonly labels?: BoardLabels;
|
|
151
|
+
/**
|
|
152
|
+
* Idempotency key. Posting the same key again returns the first message and writes nothing.
|
|
153
|
+
* The same key in a different channel or thread fails with `duplicate_key`.
|
|
154
|
+
*/
|
|
155
|
+
readonly key?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface ReplyInput {
|
|
158
|
+
readonly by: string;
|
|
159
|
+
/** Any message of the thread. The reply attaches to that thread's root. */
|
|
160
|
+
readonly to: string;
|
|
161
|
+
readonly text: string;
|
|
162
|
+
readonly labels?: BoardLabels;
|
|
163
|
+
readonly key?: string;
|
|
164
|
+
}
|
|
165
|
+
export interface LabelInput {
|
|
166
|
+
readonly by: string;
|
|
167
|
+
readonly message: string;
|
|
168
|
+
readonly set?: BoardLabels;
|
|
169
|
+
readonly unset?: readonly string[];
|
|
170
|
+
/**
|
|
171
|
+
* Compare-and-set. Each key must hold the given value, or be absent for `null`, or the call
|
|
172
|
+
* fails with `label_conflict` and changes nothing.
|
|
173
|
+
*/
|
|
174
|
+
readonly if?: {
|
|
175
|
+
readonly [key: string]: string | null;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export interface MessageQuery {
|
|
179
|
+
/** `support` matches that channel. `support/` matches it and every channel below it. */
|
|
180
|
+
readonly channel?: string;
|
|
181
|
+
/** Only the thread with this root: the root itself and its replies. */
|
|
182
|
+
readonly thread?: string;
|
|
183
|
+
readonly by?: string;
|
|
184
|
+
readonly mentions?: string;
|
|
185
|
+
/** Every pair must be on the message. */
|
|
186
|
+
readonly labels?: BoardLabels;
|
|
187
|
+
/** Only messages after the one with this id. */
|
|
188
|
+
readonly after?: string;
|
|
189
|
+
/** At most this many. Without `after` these are the latest matches. Default 50. */
|
|
190
|
+
readonly limit?: number;
|
|
191
|
+
}
|
|
192
|
+
export interface CreateTaskInput {
|
|
193
|
+
readonly by: string;
|
|
194
|
+
readonly channel: string;
|
|
195
|
+
readonly text: string;
|
|
196
|
+
readonly for?: string;
|
|
197
|
+
readonly needs?: readonly string[];
|
|
198
|
+
readonly labels?: BoardLabels;
|
|
199
|
+
readonly key?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface TaskQuery {
|
|
202
|
+
readonly channel?: string;
|
|
203
|
+
readonly state?: TaskState;
|
|
204
|
+
readonly for?: string;
|
|
205
|
+
readonly holder?: string;
|
|
206
|
+
readonly limit?: number;
|
|
207
|
+
}
|
|
208
|
+
export interface ClaimInput {
|
|
209
|
+
readonly by: string;
|
|
210
|
+
/** Claim this task. Fails when it is held, assigned to someone else, or not ready. */
|
|
211
|
+
readonly task?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Without `task`: claim the oldest ready task in this channel filter that is assigned to the
|
|
214
|
+
* caller, then the oldest unassigned one. Resolves to null when there is none.
|
|
215
|
+
*/
|
|
216
|
+
readonly channel?: string;
|
|
217
|
+
/** Default {@link DEFAULT_LEASE_MS}, at most {@link MAX_LEASE_MS}. */
|
|
218
|
+
readonly leaseMs?: number;
|
|
219
|
+
}
|
|
220
|
+
export interface RenewInput {
|
|
221
|
+
readonly task: string;
|
|
222
|
+
readonly token: string;
|
|
223
|
+
readonly leaseMs?: number;
|
|
224
|
+
}
|
|
225
|
+
/** `released` returns the task to ready without finishing it. */
|
|
226
|
+
export type SettleOutcome = 'completed' | 'failed' | 'blocked' | 'released';
|
|
227
|
+
export interface SettleInput {
|
|
228
|
+
readonly task: string;
|
|
229
|
+
readonly token: string;
|
|
230
|
+
readonly outcome: SettleOutcome;
|
|
231
|
+
readonly note?: string;
|
|
232
|
+
}
|
|
233
|
+
export interface TaskChangeInput {
|
|
234
|
+
readonly by: string;
|
|
235
|
+
readonly task: string;
|
|
236
|
+
readonly note?: string;
|
|
237
|
+
}
|
|
238
|
+
export interface EventQuery {
|
|
239
|
+
/** Only events after this cursor. Omit to read from the start of the log. */
|
|
240
|
+
readonly after?: string;
|
|
241
|
+
/** Default 100. */
|
|
242
|
+
readonly limit?: number;
|
|
243
|
+
}
|
|
244
|
+
export interface EventPage {
|
|
245
|
+
readonly events: readonly BoardEvent[];
|
|
246
|
+
/** The cursor of the last event returned, or the `after` that was passed when there were none. */
|
|
247
|
+
readonly cursor: string | null;
|
|
248
|
+
/** Whether more events were already in the log past this page. */
|
|
249
|
+
readonly more: boolean;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The storage contract behind a swarm. One instance is one board.
|
|
253
|
+
*
|
|
254
|
+
* Rules every implementation keeps:
|
|
255
|
+
*
|
|
256
|
+
* - Every write appends to one totally ordered event log, in the order the writes took effect.
|
|
257
|
+
* - `post`, `reply` and `createTask` are idempotent on `key`.
|
|
258
|
+
* - At most one claim holds a task. `claim` on a held task fails with `task_claimed`.
|
|
259
|
+
* - A claim ends when it is settled, when its lease passes, or when the task is canceled. After
|
|
260
|
+
* that its token fails with `claim_lost` and changes nothing, so a member that stalled cannot
|
|
261
|
+
* settle a task another member has since claimed.
|
|
262
|
+
* - A task whose lease has passed is ready again, and the log gains a `task.ready` event no later
|
|
263
|
+
* than the next call that reads tasks or events.
|
|
264
|
+
* - Completing a task makes ready every waiting task whose `needs` are now all completed.
|
|
265
|
+
* - Refusals reject with {@link BoardError}. Any other rejection is treated as a fault and retried.
|
|
266
|
+
*/
|
|
267
|
+
export interface MessageBoard {
|
|
268
|
+
post(input: PostInput): Promise<BoardMessage>;
|
|
269
|
+
reply(input: ReplyInput): Promise<BoardMessage>;
|
|
270
|
+
label(input: LabelInput): Promise<BoardMessage>;
|
|
271
|
+
/** Oldest first. */
|
|
272
|
+
messages(query?: MessageQuery): Promise<readonly BoardMessage[]>;
|
|
273
|
+
createTask(input: CreateTaskInput): Promise<BoardTask>;
|
|
274
|
+
/** Oldest first. */
|
|
275
|
+
tasks(query?: TaskQuery): Promise<readonly BoardTask[]>;
|
|
276
|
+
claim(input: ClaimInput): Promise<TaskClaim | null>;
|
|
277
|
+
renew(input: RenewInput): Promise<TaskClaim>;
|
|
278
|
+
settle(input: SettleInput): Promise<BoardTask>;
|
|
279
|
+
/** Return a blocked, failed or canceled task to ready, or to waiting if it has unmet needs. */
|
|
280
|
+
reopen(input: TaskChangeInput): Promise<BoardTask>;
|
|
281
|
+
cancel(input: TaskChangeInput): Promise<BoardTask>;
|
|
282
|
+
events(query?: EventQuery): Promise<EventPage>;
|
|
283
|
+
}
|
|
284
|
+
/** Looks a board up by id, so one host can serve a board per tenant. */
|
|
285
|
+
export type BoardResolver = (boardId: string) => MessageBoard | Promise<MessageBoard>;
|
|
286
|
+
/** The distinct `@name` handles in `text`, lowercased, in the order they first appear. */
|
|
287
|
+
export declare function parseMentions(text: string): string[];
|
|
288
|
+
/** Whether `channel` is selected by `filter`. A filter ending in `/` selects a whole subtree. */
|
|
289
|
+
export declare function channelMatches(filter: string, channel: string): boolean;
|
|
290
|
+
/** Whether a task is finished and will not change state again without `reopen`. */
|
|
291
|
+
export declare function isFinishedTask(state: TaskState): boolean;
|
|
292
|
+
export {};
|