@swirls/looms 0.5.0 → 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,17 @@
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
+
9
+ ## 0.5.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 86280a0: Export `@swirls/looms/cloudflare/queues` so Bun/Node pull consumers can load queue helpers without importing `cloudflare:workers`.
14
+
3
15
  ## 0.5.0
4
16
 
5
17
  ### Minor 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
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Queue producer/consumer helpers that do not import `cloudflare:workers`.
3
+ * Prefer this entry from Bun/Node pull consumers; use `@swirls/looms/cloudflare`
4
+ * only inside the Workers runtime that hosts Durable Objects.
5
+ */
6
+ export { createMemoryQueue, type MemoryQueue, type MemoryQueueOptions } from './memory-queue';
7
+ export { processQueueMessage, queueConsumer, QueueTaskError, type QueueBatchLike, type QueueConsumerOptions, type QueueTask, type QueueTaskContext, type QueueTaskHandler, type WorkerCallbackClient, } from './queue-consumer';
8
+ export { readQueueEffectMessage, type QueueEffectMessage, type QueueMessageLike, } from './queue-message';
9
+ export { cloudflareQueuePullSource, createQueuePullConsumer, QueuePullError, type CloudflareQueuePullSourceOptions, type PulledQueueMessage, type QueueLeaseRetry, type QueuePullConsumer, type QueuePullConsumerOptions, type QueuePullResult, type QueuePullSource, } from './queue-pull';
10
+ export { cloudflareQueueWorker, DEFAULT_MAX_QUEUE_MESSAGE_BYTES, QueueDispatchError, type CloudflareQueueWorkerOptions, type QueueProducer, type QueueRoute, } from './queue-worker';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Queue producer/consumer helpers that do not import `cloudflare:workers`.
3
+ * Prefer this entry from Bun/Node pull consumers; use `@swirls/looms/cloudflare`
4
+ * only inside the Workers runtime that hosts Durable Objects.
5
+ */
6
+ export { createMemoryQueue } from './memory-queue.js';
7
+ export { processQueueMessage, queueConsumer, QueueTaskError, } from './queue-consumer.js';
8
+ export { readQueueEffectMessage, } from './queue-message.js';
9
+ export { cloudflareQueuePullSource, createQueuePullConsumer, QueuePullError, } from './queue-pull.js';
10
+ export { cloudflareQueueWorker, DEFAULT_MAX_QUEUE_MESSAGE_BYTES, QueueDispatchError, } from './queue-worker.js';
@@ -143,14 +143,6 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
143
143
  } | undefined;
144
144
  readonly input?: import("effect/Schema").Json | undefined;
145
145
  }, import("./definitions-store").WorkflowDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
146
- readonly type: "runtime.effect.retry.scheduled";
147
- readonly payload: {
148
- readonly effectId: string;
149
- readonly attempt: number;
150
- readonly nextAttemptAt: number;
151
- readonly error: string;
152
- };
153
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
154
146
  readonly type: "runtime.child.close.requested";
155
147
  readonly payload: {
156
148
  readonly policy: "terminate" | "wait";
@@ -226,6 +218,14 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
226
218
  readonly attempt: number;
227
219
  readonly deadlineAt: number | null;
228
220
  };
221
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
222
+ readonly type: "runtime.effect.retry.scheduled";
223
+ readonly payload: {
224
+ readonly effectId: string;
225
+ readonly attempt: number;
226
+ readonly nextAttemptAt: number;
227
+ readonly error: string;
228
+ };
229
229
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
230
230
  readonly type: "runtime.effect.timed_out";
231
231
  readonly payload: {
@@ -539,14 +539,6 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
539
539
  };
540
540
  } | undefined;
541
541
  }, import("./definitions-store").WorkflowDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
542
- readonly type: "runtime.effect.retry.scheduled";
543
- readonly payload: {
544
- readonly effectId: string;
545
- readonly attempt: number;
546
- readonly nextAttemptAt: number;
547
- readonly error: string;
548
- };
549
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
550
542
  readonly type: "runtime.child.close.requested";
551
543
  readonly payload: {
552
544
  readonly policy: "terminate" | "wait";
@@ -622,6 +614,14 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
622
614
  readonly attempt: number;
623
615
  readonly deadlineAt: number | null;
624
616
  };
617
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
618
+ readonly type: "runtime.effect.retry.scheduled";
619
+ readonly payload: {
620
+ readonly effectId: string;
621
+ readonly attempt: number;
622
+ readonly nextAttemptAt: number;
623
+ readonly error: string;
624
+ };
625
625
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
626
626
  readonly type: "runtime.effect.timed_out";
627
627
  readonly payload: {
@@ -1113,14 +1113,6 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
1113
1113
  } | undefined;
1114
1114
  readonly input?: import("effect/Schema").Json | undefined;
1115
1115
  }, import("./definitions-store").WorkflowDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1116
- readonly type: "runtime.effect.retry.scheduled";
1117
- readonly payload: {
1118
- readonly effectId: string;
1119
- readonly attempt: number;
1120
- readonly nextAttemptAt: number;
1121
- readonly error: string;
1122
- };
1123
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1124
1116
  readonly type: "runtime.child.close.requested";
1125
1117
  readonly payload: {
1126
1118
  readonly policy: "terminate" | "wait";
@@ -1196,6 +1188,14 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
1196
1188
  readonly attempt: number;
1197
1189
  readonly deadlineAt: number | null;
1198
1190
  };
1191
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1192
+ readonly type: "runtime.effect.retry.scheduled";
1193
+ readonly payload: {
1194
+ readonly effectId: string;
1195
+ readonly attempt: number;
1196
+ readonly nextAttemptAt: number;
1197
+ readonly error: string;
1198
+ };
1199
1199
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1200
1200
  readonly type: "runtime.effect.timed_out";
1201
1201
  readonly payload: {
@@ -1509,14 +1509,6 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
1509
1509
  };
1510
1510
  } | undefined;
1511
1511
  }, import("./definitions-store").WorkflowDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1512
- readonly type: "runtime.effect.retry.scheduled";
1513
- readonly payload: {
1514
- readonly effectId: string;
1515
- readonly attempt: number;
1516
- readonly nextAttemptAt: number;
1517
- readonly error: string;
1518
- };
1519
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1520
1512
  readonly type: "runtime.child.close.requested";
1521
1513
  readonly payload: {
1522
1514
  readonly policy: "terminate" | "wait";
@@ -1592,6 +1584,14 @@ export declare function workflow(options?: WorkflowModuleOptions): import("@swir
1592
1584
  readonly attempt: number;
1593
1585
  readonly deadlineAt: number | null;
1594
1586
  };
1587
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1588
+ readonly type: "runtime.effect.retry.scheduled";
1589
+ readonly payload: {
1590
+ readonly effectId: string;
1591
+ readonly attempt: number;
1592
+ readonly nextAttemptAt: number;
1593
+ readonly error: string;
1594
+ };
1595
1595
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1596
1596
  readonly type: "runtime.effect.timed_out";
1597
1597
  readonly payload: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/looms",
3
- "version": "0.5.0",
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": {
@@ -65,6 +65,10 @@
65
65
  "types": "./dist/cloudflare/index.d.ts",
66
66
  "import": "./dist/cloudflare/index.js"
67
67
  },
68
+ "./cloudflare/queues": {
69
+ "types": "./dist/cloudflare/queues.d.ts",
70
+ "import": "./dist/cloudflare/queues.js"
71
+ },
68
72
  "./core": {
69
73
  "types": "./dist/core/index.d.ts",
70
74
  "import": "./dist/core/index.js"