@swirls/looms 0.5.1 → 0.5.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @swirls/looms
2
2
 
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a51bc1a: Allow Durable Object hosts to pass an `EffectWorker` through `LoomsDurableObjectConfig.worker` so queue-routed effects can leave the cell.
8
+
3
9
  ## 0.5.1
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import { type AnyRuntimeModule, type DefinitionResolver, type EventInput, type EventStore, type EventStoreTrimCoverage, type LaunchRunArgs, type RunLauncher, type RunState, type RunStatusSnapshot, type SnapshotStore } from '@swirls/looms/core';
2
- import { type Authorize, type LoomsRuntime, type StartResult, type StartRunArgs, type WakeScheduler } from '@swirls/looms/runtime';
2
+ import { type Authorize, type EffectWorker, type LoomsRuntime, type StartResult, type StartRunArgs, type WakeScheduler } from '@swirls/looms/runtime';
3
3
  export interface ActorCellOptions<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
4
4
  readonly runId: string;
5
5
  readonly store: EventStore;
@@ -19,6 +19,11 @@ export interface ActorCellOptions<TModules extends readonly AnyRuntimeModule[] =
19
19
  readonly authorize?: Authorize;
20
20
  /** Starts runs from effect handlers. Required for schedules; there is no default inside a cell. */
21
21
  readonly launcher?: RunLauncher;
22
+ /**
23
+ * Dispatches `execution: 'worker'` effects out of the cell (for example a
24
+ * Cloudflare Queue producer). Without it, worker effects cannot leave the object.
25
+ */
26
+ readonly worker?: EffectWorker;
22
27
  }
23
28
  export interface ActorCell<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
24
29
  readonly runId: string;
@@ -14,6 +14,7 @@ export function createActorCell(options) {
14
14
  store,
15
15
  scheduler,
16
16
  launcher: options.launcher,
17
+ worker: options.worker,
17
18
  snapshotEvery: options.snapshotEvery,
18
19
  maxWakeIterations: options.maxWakeIterations,
19
20
  maxPendingRunOperations: options.maxPendingRunOperations,
@@ -1,7 +1,7 @@
1
1
  import { DurableObject } from 'cloudflare:workers';
2
2
  import { type AnyRuntimeModule, type DefinitionResolver, type EventInput, type BlobStore, type EventStoreTrimCoverage, type LaunchRunArgs, type RunLauncher, type RunState, type RunStatusSnapshot } from '@swirls/looms/core';
3
3
  import type { Projector } from '@swirls/looms/projectors';
4
- import { type Authorize, type StartResult, type StartRunArgs } from '@swirls/looms/runtime';
4
+ import { type Authorize, type EffectWorker, type StartResult, type StartRunArgs } from '@swirls/looms/runtime';
5
5
  export interface LoomsDurableObjectConfig {
6
6
  readonly modules: readonly AnyRuntimeModule[];
7
7
  /** Loads definitions that were not registered on a module. See `CreateRuntimeOptions`. */
@@ -23,6 +23,12 @@ export interface LoomsDurableObjectConfig {
23
23
  * land in the target's object. Without it, a fire fails instead of writing into this object.
24
24
  */
25
25
  readonly launcher?: RunLauncher;
26
+ /**
27
+ * Dispatches `execution: 'worker'` effects out of this object (typically a
28
+ * Cloudflare Queue producer via `cloudflareQueueWorker`). Without it, worker
29
+ * effects cannot leave the Durable Object.
30
+ */
31
+ readonly worker?: EffectWorker;
26
32
  }
27
33
  /**
28
34
  * Base Durable Object class for hosting a Looms actor cell.
@@ -56,6 +56,7 @@ export class LoomsDurableObject extends DurableObject {
56
56
  trimAfterSnapshot: config.trimAfterSnapshot,
57
57
  authorize: config.authorize,
58
58
  launcher: config.launcher,
59
+ worker: config.worker,
59
60
  });
60
61
  const delivery = store.projectorDelivery;
61
62
  const recoverProjectors = delivery
@@ -7,6 +7,39 @@ export declare const evaluateEffect: NoInfer<import("@swirls/looms/core").Effect
7
7
  readonly definitionVersion?: string | undefined;
8
8
  readonly input?: Schema.Json | undefined;
9
9
  }, EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
10
+ readonly type: "evaluator.evaluated";
11
+ readonly payload: {
12
+ readonly evaluationId: string;
13
+ readonly definitionName?: string | undefined;
14
+ readonly answers: {
15
+ readonly [x: string]: {
16
+ readonly type: "boolean";
17
+ readonly value: boolean;
18
+ readonly probability: number;
19
+ } | {
20
+ readonly type: "choice";
21
+ readonly value: string;
22
+ } | {
23
+ readonly type: "score";
24
+ readonly value: number;
25
+ };
26
+ };
27
+ readonly route: string;
28
+ readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
29
+ readonly usage?: {
30
+ readonly input: number;
31
+ readonly output: number;
32
+ } | undefined;
33
+ };
34
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
35
+ readonly type: "evaluator.requested";
36
+ readonly payload: {
37
+ readonly evaluationId: string;
38
+ readonly definitionName?: string | undefined;
39
+ readonly state: string;
40
+ readonly model?: string | undefined;
41
+ };
42
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
10
43
  readonly type: "runtime.child.close.requested";
11
44
  readonly payload: {
12
45
  readonly policy: "terminate" | "wait";
@@ -243,37 +276,4 @@ export declare const evaluateEffect: NoInfer<import("@swirls/looms/core").Effect
243
276
  readonly payload: Schema.Json;
244
277
  };
245
278
  };
246
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
247
- readonly type: "evaluator.evaluated";
248
- readonly payload: {
249
- readonly evaluationId: string;
250
- readonly definitionName?: string | undefined;
251
- readonly answers: {
252
- readonly [x: string]: {
253
- readonly type: "boolean";
254
- readonly value: boolean;
255
- readonly probability: number;
256
- } | {
257
- readonly type: "choice";
258
- readonly value: string;
259
- } | {
260
- readonly type: "score";
261
- readonly value: number;
262
- };
263
- };
264
- readonly route: string;
265
- readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
266
- readonly usage?: {
267
- readonly input: number;
268
- readonly output: number;
269
- } | undefined;
270
- };
271
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
272
- readonly type: "evaluator.requested";
273
- readonly payload: {
274
- readonly evaluationId: string;
275
- readonly definitionName?: string | undefined;
276
- readonly state: string;
277
- readonly model?: string | undefined;
278
- };
279
279
  })>>;
@@ -42,6 +42,39 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
42
42
  readonly definitionVersion?: string | undefined;
43
43
  readonly input?: import("effect/Schema").Json | undefined;
44
44
  }, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
45
+ readonly type: "evaluator.evaluated";
46
+ readonly payload: {
47
+ readonly evaluationId: string;
48
+ readonly definitionName?: string | undefined;
49
+ readonly answers: {
50
+ readonly [x: string]: {
51
+ readonly type: "boolean";
52
+ readonly value: boolean;
53
+ readonly probability: number;
54
+ } | {
55
+ readonly type: "choice";
56
+ readonly value: string;
57
+ } | {
58
+ readonly type: "score";
59
+ readonly value: number;
60
+ };
61
+ };
62
+ readonly route: string;
63
+ readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
64
+ readonly usage?: {
65
+ readonly input: number;
66
+ readonly output: number;
67
+ } | undefined;
68
+ };
69
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
70
+ readonly type: "evaluator.requested";
71
+ readonly payload: {
72
+ readonly evaluationId: string;
73
+ readonly definitionName?: string | undefined;
74
+ readonly state: string;
75
+ readonly model?: string | undefined;
76
+ };
77
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
45
78
  readonly type: "runtime.child.close.requested";
46
79
  readonly payload: {
47
80
  readonly policy: "terminate" | "wait";
@@ -278,39 +311,6 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
278
311
  readonly payload: import("effect/Schema").Json;
279
312
  };
280
313
  };
281
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
282
- readonly type: "evaluator.evaluated";
283
- readonly payload: {
284
- readonly evaluationId: string;
285
- readonly definitionName?: string | undefined;
286
- readonly answers: {
287
- readonly [x: string]: {
288
- readonly type: "boolean";
289
- readonly value: boolean;
290
- readonly probability: number;
291
- } | {
292
- readonly type: "choice";
293
- readonly value: string;
294
- } | {
295
- readonly type: "score";
296
- readonly value: number;
297
- };
298
- };
299
- readonly route: string;
300
- readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
301
- readonly usage?: {
302
- readonly input: number;
303
- readonly output: number;
304
- } | undefined;
305
- };
306
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
307
- readonly type: "evaluator.requested";
308
- readonly payload: {
309
- readonly evaluationId: string;
310
- readonly definitionName?: string | undefined;
311
- readonly state: string;
312
- readonly model?: string | undefined;
313
- };
314
314
  })>;
315
315
  }, {
316
316
  evaluator: import("@swirls/looms/core").ThreadDefinition<{
@@ -379,6 +379,39 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
379
379
  readonly definitionVersion?: string | undefined;
380
380
  readonly input?: import("effect/Schema").Json | undefined;
381
381
  }, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
382
+ readonly type: "evaluator.evaluated";
383
+ readonly payload: {
384
+ readonly evaluationId: string;
385
+ readonly definitionName?: string | undefined;
386
+ readonly answers: {
387
+ readonly [x: string]: {
388
+ readonly type: "boolean";
389
+ readonly value: boolean;
390
+ readonly probability: number;
391
+ } | {
392
+ readonly type: "choice";
393
+ readonly value: string;
394
+ } | {
395
+ readonly type: "score";
396
+ readonly value: number;
397
+ };
398
+ };
399
+ readonly route: string;
400
+ readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
401
+ readonly usage?: {
402
+ readonly input: number;
403
+ readonly output: number;
404
+ } | undefined;
405
+ };
406
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
407
+ readonly type: "evaluator.requested";
408
+ readonly payload: {
409
+ readonly evaluationId: string;
410
+ readonly definitionName?: string | undefined;
411
+ readonly state: string;
412
+ readonly model?: string | undefined;
413
+ };
414
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
382
415
  readonly type: "runtime.child.close.requested";
383
416
  readonly payload: {
384
417
  readonly policy: "terminate" | "wait";
@@ -615,39 +648,6 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
615
648
  readonly payload: import("effect/Schema").Json;
616
649
  };
617
650
  };
618
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
619
- readonly type: "evaluator.evaluated";
620
- readonly payload: {
621
- readonly evaluationId: string;
622
- readonly definitionName?: string | undefined;
623
- readonly answers: {
624
- readonly [x: string]: {
625
- readonly type: "boolean";
626
- readonly value: boolean;
627
- readonly probability: number;
628
- } | {
629
- readonly type: "choice";
630
- readonly value: string;
631
- } | {
632
- readonly type: "score";
633
- readonly value: number;
634
- };
635
- };
636
- readonly route: string;
637
- readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
638
- readonly usage?: {
639
- readonly input: number;
640
- readonly output: number;
641
- } | undefined;
642
- };
643
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
644
- readonly type: "evaluator.requested";
645
- readonly payload: {
646
- readonly evaluationId: string;
647
- readonly definitionName?: string | undefined;
648
- readonly state: string;
649
- readonly model?: string | undefined;
650
- };
651
651
  })>;
652
652
  };
653
653
  readonly threads: {
@@ -333,15 +333,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
333
333
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
334
334
  readonly type: "schedule.paused";
335
335
  readonly payload: {};
336
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
337
- readonly type: "schedule.resumed";
338
- readonly payload: {};
339
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
340
- readonly type: "schedule.retired";
341
- readonly payload: {};
342
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
343
- readonly type: "schedule.triggered";
344
- readonly payload: {};
345
336
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
346
337
  readonly type: "schedule.planned";
347
338
  readonly payload: {
@@ -365,6 +356,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
365
356
  readonly payload: {
366
357
  readonly reason: string;
367
358
  };
359
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
360
+ readonly type: "schedule.resumed";
361
+ readonly payload: {};
362
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
363
+ readonly type: "schedule.retired";
364
+ readonly payload: {};
368
365
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
369
366
  readonly type: "schedule.skipped";
370
367
  readonly payload: {
@@ -375,6 +372,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
375
372
  readonly manual: boolean;
376
373
  readonly triggerId?: string | undefined;
377
374
  };
375
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
376
+ readonly type: "schedule.triggered";
377
+ readonly payload: {};
378
378
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
379
379
  readonly type: "schedule.updated";
380
380
  readonly payload: {
@@ -675,15 +675,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
675
675
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
676
676
  readonly type: "schedule.paused";
677
677
  readonly payload: {};
678
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
679
- readonly type: "schedule.resumed";
680
- readonly payload: {};
681
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
682
- readonly type: "schedule.retired";
683
- readonly payload: {};
684
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
685
- readonly type: "schedule.triggered";
686
- readonly payload: {};
687
678
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
688
679
  readonly type: "schedule.planned";
689
680
  readonly payload: {
@@ -707,6 +698,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
707
698
  readonly payload: {
708
699
  readonly reason: string;
709
700
  };
701
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
702
+ readonly type: "schedule.resumed";
703
+ readonly payload: {};
704
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
705
+ readonly type: "schedule.retired";
706
+ readonly payload: {};
710
707
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
711
708
  readonly type: "schedule.skipped";
712
709
  readonly payload: {
@@ -717,6 +714,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
717
714
  readonly manual: boolean;
718
715
  readonly triggerId?: string | undefined;
719
716
  };
717
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
718
+ readonly type: "schedule.triggered";
719
+ readonly payload: {};
720
720
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
721
721
  readonly type: "schedule.updated";
722
722
  readonly payload: {
@@ -1036,15 +1036,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1036
1036
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1037
1037
  readonly type: "schedule.paused";
1038
1038
  readonly payload: {};
1039
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1040
- readonly type: "schedule.resumed";
1041
- readonly payload: {};
1042
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1043
- readonly type: "schedule.retired";
1044
- readonly payload: {};
1045
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1046
- readonly type: "schedule.triggered";
1047
- readonly payload: {};
1048
1039
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1049
1040
  readonly type: "schedule.planned";
1050
1041
  readonly payload: {
@@ -1068,6 +1059,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1068
1059
  readonly payload: {
1069
1060
  readonly reason: string;
1070
1061
  };
1062
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1063
+ readonly type: "schedule.resumed";
1064
+ readonly payload: {};
1065
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1066
+ readonly type: "schedule.retired";
1067
+ readonly payload: {};
1071
1068
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1072
1069
  readonly type: "schedule.skipped";
1073
1070
  readonly payload: {
@@ -1078,6 +1075,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1078
1075
  readonly manual: boolean;
1079
1076
  readonly triggerId?: string | undefined;
1080
1077
  };
1078
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1079
+ readonly type: "schedule.triggered";
1080
+ readonly payload: {};
1081
1081
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1082
1082
  readonly type: "schedule.updated";
1083
1083
  readonly payload: {
@@ -1378,15 +1378,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1378
1378
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1379
1379
  readonly type: "schedule.paused";
1380
1380
  readonly payload: {};
1381
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1382
- readonly type: "schedule.resumed";
1383
- readonly payload: {};
1384
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1385
- readonly type: "schedule.retired";
1386
- readonly payload: {};
1387
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1388
- readonly type: "schedule.triggered";
1389
- readonly payload: {};
1390
1381
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1391
1382
  readonly type: "schedule.planned";
1392
1383
  readonly payload: {
@@ -1410,6 +1401,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1410
1401
  readonly payload: {
1411
1402
  readonly reason: string;
1412
1403
  };
1404
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1405
+ readonly type: "schedule.resumed";
1406
+ readonly payload: {};
1407
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1408
+ readonly type: "schedule.retired";
1409
+ readonly payload: {};
1413
1410
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1414
1411
  readonly type: "schedule.skipped";
1415
1412
  readonly payload: {
@@ -1420,6 +1417,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1420
1417
  readonly manual: boolean;
1421
1418
  readonly triggerId?: string | undefined;
1422
1419
  };
1420
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1421
+ readonly type: "schedule.triggered";
1422
+ readonly payload: {};
1423
1423
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1424
1424
  readonly type: "schedule.updated";
1425
1425
  readonly payload: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/looms",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Pluggable event-sourced runtime for durable agents and workflows",
5
5
  "homepage": "https://github.com/ByteSliceHQ/looms#readme",
6
6
  "bugs": {