@swirls/looms 0.6.1 → 0.7.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 +18 -0
- package/dist/actor/cell.d.ts +1 -1
- package/dist/actor/routing.d.ts +5 -1
- package/dist/actor/routing.js +14 -3
- package/dist/agent/effects.d.ts +20 -2
- package/dist/agent/effects.js +2 -0
- package/dist/agent/module.d.ts +40 -4
- package/dist/approval/effects.d.ts +10 -1
- package/dist/approval/effects.js +1 -0
- package/dist/approval/module.d.ts +20 -2
- package/dist/client/client.d.ts +38 -10
- package/dist/client/client.js +2 -1
- package/dist/cloudflare/durable-object.d.ts +1 -1
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.js +1 -1
- package/dist/cloudflare/queue-consumer.d.ts +17 -10
- package/dist/cloudflare/queue-consumer.js +63 -27
- package/dist/cloudflare/queue-message.d.ts +4 -1
- package/dist/cloudflare/queue-message.js +4 -1
- package/dist/cloudflare/queue-worker.d.ts +7 -3
- package/dist/cloudflare/queue-worker.js +7 -2
- package/dist/cloudflare/queues.d.ts +1 -1
- package/dist/cloudflare/queues.js +1 -1
- package/dist/core/compose.d.ts +2 -1
- package/dist/core/compose.js +5 -0
- package/dist/core/effects.d.ts +84 -39
- package/dist/core/effects.js +29 -8
- package/dist/core/fold.js +34 -0
- package/dist/core/module-scope.d.ts +22 -8
- package/dist/core/module-scope.js +3 -0
- package/dist/core/module.d.ts +40 -9
- package/dist/core/module.js +25 -6
- package/dist/core/protocol.d.ts +12 -1
- package/dist/core/protocol.js +12 -0
- package/dist/core/published.d.ts +52 -0
- package/dist/core/published.js +45 -0
- package/dist/core/replay.d.ts +4 -2
- package/dist/core/state.d.ts +8 -2
- package/dist/core/state.js +2 -0
- package/dist/debugger/app/assets/{index-CUO1xyYW.js → index-CMRl_aWQ.js} +2 -2
- package/dist/debugger/app/assets/routes-CfXxKG45.js +47 -0
- package/dist/debugger/app/index.html +1 -1
- package/dist/debugger/events/protocol-summarize.js +2 -0
- package/dist/evaluator/effects.d.ts +10 -1
- package/dist/evaluator/effects.js +1 -0
- package/dist/evaluator/module.d.ts +20 -2
- package/dist/runtime/cancellation.js +1 -1
- package/dist/runtime/dispatch-effect.d.ts +2 -2
- package/dist/runtime/dispatch-effect.js +12 -4
- package/dist/runtime/effect-admission.d.ts +45 -0
- package/dist/runtime/effect-admission.js +70 -0
- package/dist/runtime/helpers.d.ts +6 -1
- package/dist/runtime/helpers.js +14 -5
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/local-effect-executor.js +25 -3
- package/dist/runtime/retry-policy.js +6 -1
- package/dist/runtime/runtime.js +7 -2
- package/dist/runtime/server/routes/definitions.js +8 -1
- package/dist/runtime/types.d.ts +20 -5
- package/dist/runtime/wake-engine.js +20 -0
- package/dist/runtime/worker-callbacks.js +2 -2
- package/dist/runtime/worker-effect-dispatch.d.ts +35 -9
- package/dist/runtime/worker-effect-dispatch.js +105 -26
- package/dist/schedule/effects.d.ts +20 -2
- package/dist/schedule/effects.js +2 -0
- package/dist/schedule/module.d.ts +76 -40
- package/dist/testing/corpus-module.d.ts +2 -2
- package/dist/testing/corpus-module.js +27 -19
- package/dist/testing/index.js +12 -23
- package/dist/workflow/effects.d.ts +20 -2
- package/dist/workflow/effects.js +2 -0
- package/dist/workflow/module.d.ts +40 -4
- package/package.json +1 -1
- package/dist/debugger/app/assets/routes-lt_6J025.js +0 -47
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import { type ComposedRegistry, type EffectExecutionRecord, type EventEnvelope, type OutstandingEffect, type RetryPolicy, type RunState, type SecretContext } from '@swirls/looms/core';
|
|
2
|
+
import { type ComposedRegistry, type EffectDefinition, type EffectExecutionRecord, type EffectPlacement, type EventEnvelope, type OutstandingEffect, type RetryPolicy, type RunState, type SecretContext } from '@swirls/looms/core';
|
|
3
3
|
import type { EffectWorker, EffectWorkerTask } from './types';
|
|
4
|
+
/** Caps how many times one attempt's unacknowledged dispatch can be deferred before parking as ambiguous. */
|
|
5
|
+
export declare const DEFAULT_MAX_WORKER_DISPATCH_DEFERRALS = 32;
|
|
4
6
|
export interface WorkerEffectDispatchPlan {
|
|
5
7
|
readonly item: OutstandingEffect;
|
|
6
8
|
readonly attempt: number;
|
|
@@ -8,12 +10,13 @@ export interface WorkerEffectDispatchPlan {
|
|
|
8
10
|
readonly task: EffectWorkerTask;
|
|
9
11
|
readonly retry: RetryPolicy | undefined;
|
|
10
12
|
readonly scheduleToStartDeadlineAt: number | null;
|
|
13
|
+
/** Next outbox dispatch try for this attempt (1 on first push). */
|
|
14
|
+
readonly dispatchTry: number;
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Decides where an outstanding effect runs. An attempt already in flight keeps
|
|
14
|
-
* its durable placement. Otherwise
|
|
15
|
-
*
|
|
16
|
-
* go to the worker.
|
|
18
|
+
* its durable placement. Otherwise the definition's `placement` wins. Unregistered
|
|
19
|
+
* types go to a configured worker unless it declines them.
|
|
17
20
|
*/
|
|
18
21
|
export declare function isWorkerEffect(input: {
|
|
19
22
|
readonly runId: string;
|
|
@@ -32,12 +35,19 @@ export declare function planWorkerEffects(input: {
|
|
|
32
35
|
readonly secrets?: SecretContext;
|
|
33
36
|
}): ReadonlyArray<WorkerEffectDispatchPlan>;
|
|
34
37
|
/**
|
|
35
|
-
* Hand a planned attempt to the worker.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
38
|
+
* Hand a planned attempt to the worker.
|
|
39
|
+
*
|
|
40
|
+
* - **acknowledged** reject: nothing was sent → fail under the retry policy.
|
|
41
|
+
* - **unacknowledged** reject: enter `dispatch_wait` (`runtime.effect.dispatch.deferred`) and the
|
|
42
|
+
* wake engine retries later with dedicated outbox backoff. After
|
|
43
|
+
* {@link DEFAULT_MAX_WORKER_DISPATCH_DEFERRALS} tries, park as ambiguous for an operator.
|
|
44
|
+
* Workers must treat `(runId, effectId, attempt)` as idempotent — a rejected push may still have
|
|
45
|
+
* arrived, so a later `started` from `dispatch_wait` is accepted.
|
|
46
|
+
* - Missing worker: ambiguous (misconfiguration).
|
|
39
47
|
*/
|
|
40
|
-
export declare function dispatchWorkerEffect(runId: string, plan: WorkerEffectDispatchPlan, worker: EffectWorker | undefined, now: number
|
|
48
|
+
export declare function dispatchWorkerEffect(runId: string, plan: WorkerEffectDispatchPlan, worker: EffectWorker | undefined, now: number, options?: {
|
|
49
|
+
readonly maxDispatchDeferrals?: number;
|
|
50
|
+
}): Effect.Effect<EventEnvelope>;
|
|
41
51
|
/**
|
|
42
52
|
* An acknowledged transport can lose a message it accepted, for example to a dead-letter queue.
|
|
43
53
|
* schedule-to-start covers a message that never starts. After `started` is acked, only
|
|
@@ -45,3 +55,19 @@ export declare function dispatchWorkerEffect(runId: string, plan: WorkerEffectDi
|
|
|
45
55
|
* effect needs one of those as well.
|
|
46
56
|
*/
|
|
47
57
|
export declare function assertWorkerDeadlines(registry: ComposedRegistry, worker: EffectWorker | undefined): void;
|
|
58
|
+
/** Registered effect types with their declared placement, sorted by type for stable output. */
|
|
59
|
+
export declare function listEffectPlacements(registry: ComposedRegistry): ReadonlyArray<{
|
|
60
|
+
readonly type: string;
|
|
61
|
+
readonly placement: EffectPlacement;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Worker-placed effects need a configured `EffectWorker`. Without one they would park as
|
|
65
|
+
* ambiguous on every attempt.
|
|
66
|
+
*/
|
|
67
|
+
export declare function assertWorkerConfigured(registry: ComposedRegistry, worker: EffectWorker | undefined): void;
|
|
68
|
+
/**
|
|
69
|
+
* A worker must not claim a local-placed effect. Declare the effect with `placement: 'worker'` (or a
|
|
70
|
+
* hybrid when that lands) instead of overlapping `handles` with a local definition.
|
|
71
|
+
*/
|
|
72
|
+
export declare function assertWorkerClaimsExplicit(registry: ComposedRegistry, worker: EffectWorker | undefined): void;
|
|
73
|
+
export declare function claimsType(worker: EffectWorker, definition: EffectDefinition): boolean;
|
|
@@ -2,7 +2,15 @@ import { Effect, Predicate } from 'effect';
|
|
|
2
2
|
import { createEvent, deferredUntil, isPrimitiveEffect, } from '@swirls/looms/core';
|
|
3
3
|
import { RuntimeExecutionError } from './errors.js';
|
|
4
4
|
import { workerTask } from './helpers.js';
|
|
5
|
-
import { planAttemptFailure } from './retry-policy.js';
|
|
5
|
+
import { planAttemptFailure, retryBackoff } from './retry-policy.js';
|
|
6
|
+
/** Caps how many times one attempt's unacknowledged dispatch can be deferred before parking as ambiguous. */
|
|
7
|
+
export const DEFAULT_MAX_WORKER_DISPATCH_DEFERRALS = 32;
|
|
8
|
+
const DISPATCH_BACKOFF = {
|
|
9
|
+
maxAttempts: DEFAULT_MAX_WORKER_DISPATCH_DEFERRALS,
|
|
10
|
+
backoffMs: 100,
|
|
11
|
+
maxBackoffMs: 30_000,
|
|
12
|
+
backoffMultiplier: 2,
|
|
13
|
+
};
|
|
6
14
|
function workerClaims(worker, runId, item) {
|
|
7
15
|
if (!worker.handles && !worker.canDispatch) {
|
|
8
16
|
return undefined;
|
|
@@ -15,6 +23,7 @@ function workerClaims(worker, runId, item) {
|
|
|
15
23
|
}
|
|
16
24
|
const WORKER_ATTEMPT_STATUSES = new Set([
|
|
17
25
|
'queued',
|
|
26
|
+
'dispatch_wait',
|
|
18
27
|
'dispatched',
|
|
19
28
|
'started',
|
|
20
29
|
'heartbeat',
|
|
@@ -22,11 +31,14 @@ const WORKER_ATTEMPT_STATUSES = new Set([
|
|
|
22
31
|
'timed_out',
|
|
23
32
|
'ambiguous',
|
|
24
33
|
]);
|
|
34
|
+
const SAME_ATTEMPT_STATUSES = new Set([
|
|
35
|
+
'queued',
|
|
36
|
+
'dispatch_wait',
|
|
37
|
+
]);
|
|
25
38
|
/**
|
|
26
39
|
* Decides where an outstanding effect runs. An attempt already in flight keeps
|
|
27
|
-
* its durable placement. Otherwise
|
|
28
|
-
*
|
|
29
|
-
* go to the worker.
|
|
40
|
+
* its durable placement. Otherwise the definition's `placement` wins. Unregistered
|
|
41
|
+
* types go to a configured worker unless it declines them.
|
|
30
42
|
*/
|
|
31
43
|
export function isWorkerEffect(input) {
|
|
32
44
|
const { item, execution, worker } = input;
|
|
@@ -40,16 +52,13 @@ export function isWorkerEffect(input) {
|
|
|
40
52
|
return true;
|
|
41
53
|
}
|
|
42
54
|
const definition = input.registry.effects.get(item.effect.type);
|
|
43
|
-
if (definition
|
|
44
|
-
return definition.
|
|
55
|
+
if (definition) {
|
|
56
|
+
return definition.placement === 'worker';
|
|
45
57
|
}
|
|
46
58
|
const claim = worker ? workerClaims(worker, input.runId, item) : undefined;
|
|
47
59
|
if (claim) {
|
|
48
60
|
return true;
|
|
49
61
|
}
|
|
50
|
-
if (definition) {
|
|
51
|
-
return !definition.hasHandler;
|
|
52
|
-
}
|
|
53
62
|
return worker !== undefined && claim !== false;
|
|
54
63
|
}
|
|
55
64
|
export function planWorkerEffects(input) {
|
|
@@ -62,13 +71,17 @@ export function planWorkerEffects(input) {
|
|
|
62
71
|
const execution = input.state.effectExecutions[item.effectId];
|
|
63
72
|
return (!execution ||
|
|
64
73
|
execution.status === 'queued' ||
|
|
74
|
+
(execution.status === 'dispatch_wait' &&
|
|
75
|
+
execution.nextAttemptAt !== null &&
|
|
76
|
+
execution.nextAttemptAt <= input.now + 5) ||
|
|
65
77
|
(execution.status === 'retry_wait' &&
|
|
66
78
|
execution.nextAttemptAt !== null &&
|
|
67
79
|
execution.nextAttemptAt <= input.now + 5));
|
|
68
80
|
});
|
|
69
81
|
return withinInFlightLimit(input, workerItems, due).map((item) => {
|
|
70
82
|
const existing = input.state.effectExecutions[item.effectId];
|
|
71
|
-
const
|
|
83
|
+
const sameAttempt = existing !== undefined && SAME_ATTEMPT_STATUSES.has(existing.status);
|
|
84
|
+
const attempt = sameAttempt ? existing.attempt : (existing?.attempt ?? 0) + 1;
|
|
72
85
|
const retry = input.registry.effects.get(item.effect.type)?.retry;
|
|
73
86
|
const scheduleToStartDeadlineAt = retry?.scheduleToStartTimeoutMs
|
|
74
87
|
? input.now + retry.scheduleToStartTimeoutMs
|
|
@@ -77,7 +90,8 @@ export function planWorkerEffects(input) {
|
|
|
77
90
|
item,
|
|
78
91
|
attempt,
|
|
79
92
|
retry,
|
|
80
|
-
|
|
93
|
+
dispatchTry: sameAttempt ? existing.dispatchTry + 1 : 1,
|
|
94
|
+
queuedEvent: sameAttempt
|
|
81
95
|
? undefined
|
|
82
96
|
: createEvent(input.runId, {
|
|
83
97
|
type: 'runtime.effect.queued',
|
|
@@ -89,6 +103,7 @@ export function planWorkerEffects(input) {
|
|
|
89
103
|
task: workerTask(input.runId, item, attempt, {
|
|
90
104
|
details: existing?.heartbeatDetails,
|
|
91
105
|
secrets: input.secrets,
|
|
106
|
+
attributes: input.state.attributes,
|
|
92
107
|
trace: input.state.startIdentity?.trace,
|
|
93
108
|
retry,
|
|
94
109
|
scheduleToStartAt: scheduleToStartDeadlineAt,
|
|
@@ -115,12 +130,17 @@ function withinInFlightLimit(input, workerItems, due) {
|
|
|
115
130
|
return due.slice(0, Math.max(0, max - inFlight));
|
|
116
131
|
}
|
|
117
132
|
/**
|
|
118
|
-
* Hand a planned attempt to the worker.
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
133
|
+
* Hand a planned attempt to the worker.
|
|
134
|
+
*
|
|
135
|
+
* - **acknowledged** reject: nothing was sent → fail under the retry policy.
|
|
136
|
+
* - **unacknowledged** reject: enter `dispatch_wait` (`runtime.effect.dispatch.deferred`) and the
|
|
137
|
+
* wake engine retries later with dedicated outbox backoff. After
|
|
138
|
+
* {@link DEFAULT_MAX_WORKER_DISPATCH_DEFERRALS} tries, park as ambiguous for an operator.
|
|
139
|
+
* Workers must treat `(runId, effectId, attempt)` as idempotent — a rejected push may still have
|
|
140
|
+
* arrived, so a later `started` from `dispatch_wait` is accepted.
|
|
141
|
+
* - Missing worker: ambiguous (misconfiguration).
|
|
122
142
|
*/
|
|
123
|
-
export function dispatchWorkerEffect(runId, plan, worker, now) {
|
|
143
|
+
export function dispatchWorkerEffect(runId, plan, worker, now, options = {}) {
|
|
124
144
|
const dispatched = createEvent(runId, {
|
|
125
145
|
type: 'runtime.effect.dispatched',
|
|
126
146
|
payload: {
|
|
@@ -158,9 +178,23 @@ export function dispatchWorkerEffect(runId, plan, worker, now) {
|
|
|
158
178
|
origin: { type: 'system' },
|
|
159
179
|
}).event;
|
|
160
180
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
:
|
|
181
|
+
const maxDeferrals = options.maxDispatchDeferrals ?? DEFAULT_MAX_WORKER_DISPATCH_DEFERRALS;
|
|
182
|
+
if (plan.dispatchTry >= maxDeferrals) {
|
|
183
|
+
return ambiguous(`worker dispatch relay exhausted after ${plan.dispatchTry} tries: ${error.message}`);
|
|
184
|
+
}
|
|
185
|
+
return createEvent(runId, {
|
|
186
|
+
type: 'runtime.effect.dispatch.deferred',
|
|
187
|
+
payload: {
|
|
188
|
+
effectId: plan.item.effectId,
|
|
189
|
+
attempt: plan.attempt,
|
|
190
|
+
retryAt: now + retryBackoff(DISPATCH_BACKOFF, plan.dispatchTry),
|
|
191
|
+
error: `worker dispatch deferred: ${error.message}`,
|
|
192
|
+
try: plan.dispatchTry,
|
|
193
|
+
},
|
|
194
|
+
threadId: plan.item.threadId,
|
|
195
|
+
causationId: plan.item.causingEventId,
|
|
196
|
+
origin: { type: 'system' },
|
|
197
|
+
});
|
|
164
198
|
},
|
|
165
199
|
onSuccess: () => dispatched,
|
|
166
200
|
}));
|
|
@@ -189,13 +223,58 @@ export function assertWorkerDeadlines(registry, worker) {
|
|
|
189
223
|
throw new Error(`An acknowledged worker claims effects without retry.startToCloseTimeoutMs or retry.heartbeatTimeoutMs: ${missingClose.join(', ')}`);
|
|
190
224
|
}
|
|
191
225
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
226
|
+
/** Registered effect types with their declared placement, sorted by type for stable output. */
|
|
227
|
+
export function listEffectPlacements(registry) {
|
|
228
|
+
return [...registry.effects.values()]
|
|
229
|
+
.map((definition) => ({ type: definition.type, placement: definition.placement }))
|
|
230
|
+
.toSorted((left, right) => left.type.localeCompare(right.type));
|
|
231
|
+
}
|
|
232
|
+
function formatEffectPlacements(registry) {
|
|
233
|
+
return listEffectPlacements(registry)
|
|
234
|
+
.map((entry) => `${entry.type}=${entry.placement}`)
|
|
235
|
+
.join(', ');
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Worker-placed effects need a configured `EffectWorker`. Without one they would park as
|
|
239
|
+
* ambiguous on every attempt.
|
|
240
|
+
*/
|
|
241
|
+
export function assertWorkerConfigured(registry, worker) {
|
|
242
|
+
if (worker) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const needingWorker = [...registry.effects.values()]
|
|
246
|
+
.filter((definition) => definition.placement === 'worker')
|
|
247
|
+
.map((definition) => definition.type);
|
|
248
|
+
if (needingWorker.length > 0) {
|
|
249
|
+
throw new Error(`Effects require an EffectWorker but none is configured: ${needingWorker.join(', ')} (registry: ${formatEffectPlacements(registry)})`);
|
|
195
250
|
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* A worker must not claim a local-placed effect. Declare the effect with `placement: 'worker'` (or a
|
|
254
|
+
* hybrid when that lands) instead of overlapping `handles` with a local definition.
|
|
255
|
+
*/
|
|
256
|
+
export function assertWorkerClaimsExplicit(registry, worker) {
|
|
257
|
+
if (!worker) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const claimedLocal = [...registry.effects.values()]
|
|
261
|
+
.filter((definition) => definition.placement === 'local' && workerHandlesType(worker, definition.type))
|
|
262
|
+
.map((definition) => definition.type);
|
|
263
|
+
if (claimedLocal.length > 0) {
|
|
264
|
+
throw new Error(`Worker claims local-placed effects; declare them with placement: 'worker' (or drop the claim): ${claimedLocal.join(', ')} (registry: ${formatEffectPlacements(registry)})`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
export function claimsType(worker, definition) {
|
|
268
|
+
if (definition.placement !== 'worker') {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
// A worker with no claim filter takes every worker-placed effect.
|
|
272
|
+
if (!worker.handles && !worker.canDispatch) {
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
return workerHandlesType(worker, definition.type);
|
|
276
|
+
}
|
|
277
|
+
function workerHandlesType(worker, type) {
|
|
196
278
|
const { handles } = worker;
|
|
197
|
-
|
|
198
|
-
? handles(definition.type)
|
|
199
|
-
: (handles?.includes(definition.type) ?? false);
|
|
200
|
-
return handled || !definition.hasHandler;
|
|
279
|
+
return Predicate.isFunction(handles) ? handles(type) : (handles?.includes(type) ?? false);
|
|
201
280
|
}
|
|
@@ -54,7 +54,7 @@ declare const FireInputSchema: Schema.Struct<{
|
|
|
54
54
|
}>;
|
|
55
55
|
type PlanInput = Schema.Schema.Type<typeof PlanInputSchema>;
|
|
56
56
|
type FireInput = Schema.Schema.Type<typeof FireInputSchema>;
|
|
57
|
-
export declare const planEffect: NoInfer<import("@swirls/looms/core").
|
|
57
|
+
export declare const planEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
|
|
58
58
|
readonly spec: {
|
|
59
59
|
readonly type: "cron";
|
|
60
60
|
readonly expr: string;
|
|
@@ -118,6 +118,15 @@ export declare const planEffect: NoInfer<import("@swirls/looms/core").EffectDefi
|
|
|
118
118
|
readonly effectId: string;
|
|
119
119
|
readonly attempt: number;
|
|
120
120
|
};
|
|
121
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
122
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
123
|
+
readonly payload: {
|
|
124
|
+
readonly effectId: string;
|
|
125
|
+
readonly attempt: number;
|
|
126
|
+
readonly retryAt: number;
|
|
127
|
+
readonly error: string;
|
|
128
|
+
readonly try: number;
|
|
129
|
+
};
|
|
121
130
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
122
131
|
readonly type: "runtime.effect.dispatched";
|
|
123
132
|
readonly payload: {
|
|
@@ -387,7 +396,7 @@ export declare const planEffect: NoInfer<import("@swirls/looms/core").EffectDefi
|
|
|
387
396
|
readonly definitionVersion?: string | undefined;
|
|
388
397
|
};
|
|
389
398
|
})>>;
|
|
390
|
-
export declare const fireEffect: NoInfer<import("@swirls/looms/core").
|
|
399
|
+
export declare const fireEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
|
|
391
400
|
readonly definitionName: string;
|
|
392
401
|
readonly definitionVersion: string;
|
|
393
402
|
readonly spec: {
|
|
@@ -460,6 +469,15 @@ export declare const fireEffect: NoInfer<import("@swirls/looms/core").EffectDefi
|
|
|
460
469
|
readonly effectId: string;
|
|
461
470
|
readonly attempt: number;
|
|
462
471
|
};
|
|
472
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
473
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
474
|
+
readonly payload: {
|
|
475
|
+
readonly effectId: string;
|
|
476
|
+
readonly attempt: number;
|
|
477
|
+
readonly retryAt: number;
|
|
478
|
+
readonly error: string;
|
|
479
|
+
readonly try: number;
|
|
480
|
+
};
|
|
463
481
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
464
482
|
readonly type: "runtime.effect.dispatched";
|
|
465
483
|
readonly payload: {
|
package/dist/schedule/effects.js
CHANGED
|
@@ -38,6 +38,7 @@ class ScheduleEffectError extends Data.TaggedError('ScheduleEffectError') {
|
|
|
38
38
|
}
|
|
39
39
|
export const planEffect = scheduleModule.effect({
|
|
40
40
|
type: 'schedule.plan',
|
|
41
|
+
placement: 'local',
|
|
41
42
|
input: PlanInputSchema,
|
|
42
43
|
retry: RETRY,
|
|
43
44
|
execute: (input, ctx) => Effect.gen(function* () {
|
|
@@ -54,6 +55,7 @@ export const planEffect = scheduleModule.effect({
|
|
|
54
55
|
});
|
|
55
56
|
export const fireEffect = scheduleModule.effect({
|
|
56
57
|
type: 'schedule.fire',
|
|
58
|
+
placement: 'local',
|
|
57
59
|
input: FireInputSchema,
|
|
58
60
|
retry: RETRY,
|
|
59
61
|
execute: (input, ctx) => Effect.gen(function* () {
|
|
@@ -64,7 +64,7 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
64
64
|
readonly reason: import("effect/Schema").String;
|
|
65
65
|
}>;
|
|
66
66
|
}>, {
|
|
67
|
-
plan: import("@swirls/looms/core").
|
|
67
|
+
plan: import("@swirls/looms/core").LocalEffectDefinition<{
|
|
68
68
|
readonly spec: {
|
|
69
69
|
readonly type: "cron";
|
|
70
70
|
readonly expr: string;
|
|
@@ -128,6 +128,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
128
128
|
readonly effectId: string;
|
|
129
129
|
readonly attempt: number;
|
|
130
130
|
};
|
|
131
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
132
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
133
|
+
readonly payload: {
|
|
134
|
+
readonly effectId: string;
|
|
135
|
+
readonly attempt: number;
|
|
136
|
+
readonly retryAt: number;
|
|
137
|
+
readonly error: string;
|
|
138
|
+
readonly try: number;
|
|
139
|
+
};
|
|
131
140
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
132
141
|
readonly type: "runtime.effect.dispatched";
|
|
133
142
|
readonly payload: {
|
|
@@ -333,15 +342,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
333
342
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
334
343
|
readonly type: "schedule.paused";
|
|
335
344
|
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
345
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
346
346
|
readonly type: "schedule.planned";
|
|
347
347
|
readonly payload: {
|
|
@@ -365,6 +365,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
365
365
|
readonly payload: {
|
|
366
366
|
readonly reason: string;
|
|
367
367
|
};
|
|
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: {};
|
|
368
374
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
369
375
|
readonly type: "schedule.skipped";
|
|
370
376
|
readonly payload: {
|
|
@@ -375,6 +381,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
375
381
|
readonly manual: boolean;
|
|
376
382
|
readonly triggerId?: string | undefined;
|
|
377
383
|
};
|
|
384
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
385
|
+
readonly type: "schedule.triggered";
|
|
386
|
+
readonly payload: {};
|
|
378
387
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
379
388
|
readonly type: "schedule.updated";
|
|
380
389
|
readonly payload: {
|
|
@@ -397,7 +406,7 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
397
406
|
readonly definitionVersion?: string | undefined;
|
|
398
407
|
};
|
|
399
408
|
})>;
|
|
400
|
-
fire: import("@swirls/looms/core").
|
|
409
|
+
fire: import("@swirls/looms/core").LocalEffectDefinition<{
|
|
401
410
|
readonly definitionName: string;
|
|
402
411
|
readonly definitionVersion: string;
|
|
403
412
|
readonly spec: {
|
|
@@ -470,6 +479,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
470
479
|
readonly effectId: string;
|
|
471
480
|
readonly attempt: number;
|
|
472
481
|
};
|
|
482
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
483
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
484
|
+
readonly payload: {
|
|
485
|
+
readonly effectId: string;
|
|
486
|
+
readonly attempt: number;
|
|
487
|
+
readonly retryAt: number;
|
|
488
|
+
readonly error: string;
|
|
489
|
+
readonly try: number;
|
|
490
|
+
};
|
|
473
491
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
474
492
|
readonly type: "runtime.effect.dispatched";
|
|
475
493
|
readonly payload: {
|
|
@@ -675,15 +693,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
675
693
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
676
694
|
readonly type: "schedule.paused";
|
|
677
695
|
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
696
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
688
697
|
readonly type: "schedule.planned";
|
|
689
698
|
readonly payload: {
|
|
@@ -707,6 +716,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
707
716
|
readonly payload: {
|
|
708
717
|
readonly reason: string;
|
|
709
718
|
};
|
|
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: {};
|
|
710
725
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
711
726
|
readonly type: "schedule.skipped";
|
|
712
727
|
readonly payload: {
|
|
@@ -717,6 +732,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
717
732
|
readonly manual: boolean;
|
|
718
733
|
readonly triggerId?: string | undefined;
|
|
719
734
|
};
|
|
735
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
736
|
+
readonly type: "schedule.triggered";
|
|
737
|
+
readonly payload: {};
|
|
720
738
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
721
739
|
readonly type: "schedule.updated";
|
|
722
740
|
readonly payload: {
|
|
@@ -767,7 +785,7 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
767
785
|
}>;
|
|
768
786
|
}, import("effect/Context").Service.Any> & {
|
|
769
787
|
readonly effects: {
|
|
770
|
-
plan: import("@swirls/looms/core").
|
|
788
|
+
plan: import("@swirls/looms/core").LocalEffectDefinition<{
|
|
771
789
|
readonly spec: {
|
|
772
790
|
readonly type: "cron";
|
|
773
791
|
readonly expr: string;
|
|
@@ -831,6 +849,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
831
849
|
readonly effectId: string;
|
|
832
850
|
readonly attempt: number;
|
|
833
851
|
};
|
|
852
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
853
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
854
|
+
readonly payload: {
|
|
855
|
+
readonly effectId: string;
|
|
856
|
+
readonly attempt: number;
|
|
857
|
+
readonly retryAt: number;
|
|
858
|
+
readonly error: string;
|
|
859
|
+
readonly try: number;
|
|
860
|
+
};
|
|
834
861
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
835
862
|
readonly type: "runtime.effect.dispatched";
|
|
836
863
|
readonly payload: {
|
|
@@ -1036,15 +1063,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1036
1063
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1037
1064
|
readonly type: "schedule.paused";
|
|
1038
1065
|
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
1066
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1049
1067
|
readonly type: "schedule.planned";
|
|
1050
1068
|
readonly payload: {
|
|
@@ -1068,6 +1086,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1068
1086
|
readonly payload: {
|
|
1069
1087
|
readonly reason: string;
|
|
1070
1088
|
};
|
|
1089
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1090
|
+
readonly type: "schedule.resumed";
|
|
1091
|
+
readonly payload: {};
|
|
1092
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1093
|
+
readonly type: "schedule.retired";
|
|
1094
|
+
readonly payload: {};
|
|
1071
1095
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1072
1096
|
readonly type: "schedule.skipped";
|
|
1073
1097
|
readonly payload: {
|
|
@@ -1078,6 +1102,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1078
1102
|
readonly manual: boolean;
|
|
1079
1103
|
readonly triggerId?: string | undefined;
|
|
1080
1104
|
};
|
|
1105
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1106
|
+
readonly type: "schedule.triggered";
|
|
1107
|
+
readonly payload: {};
|
|
1081
1108
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1082
1109
|
readonly type: "schedule.updated";
|
|
1083
1110
|
readonly payload: {
|
|
@@ -1100,7 +1127,7 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1100
1127
|
readonly definitionVersion?: string | undefined;
|
|
1101
1128
|
};
|
|
1102
1129
|
})>;
|
|
1103
|
-
fire: import("@swirls/looms/core").
|
|
1130
|
+
fire: import("@swirls/looms/core").LocalEffectDefinition<{
|
|
1104
1131
|
readonly definitionName: string;
|
|
1105
1132
|
readonly definitionVersion: string;
|
|
1106
1133
|
readonly spec: {
|
|
@@ -1173,6 +1200,15 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1173
1200
|
readonly effectId: string;
|
|
1174
1201
|
readonly attempt: number;
|
|
1175
1202
|
};
|
|
1203
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1204
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
1205
|
+
readonly payload: {
|
|
1206
|
+
readonly effectId: string;
|
|
1207
|
+
readonly attempt: number;
|
|
1208
|
+
readonly retryAt: number;
|
|
1209
|
+
readonly error: string;
|
|
1210
|
+
readonly try: number;
|
|
1211
|
+
};
|
|
1176
1212
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1177
1213
|
readonly type: "runtime.effect.dispatched";
|
|
1178
1214
|
readonly payload: {
|
|
@@ -1378,15 +1414,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1378
1414
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1379
1415
|
readonly type: "schedule.paused";
|
|
1380
1416
|
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
1417
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1391
1418
|
readonly type: "schedule.planned";
|
|
1392
1419
|
readonly payload: {
|
|
@@ -1410,6 +1437,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1410
1437
|
readonly payload: {
|
|
1411
1438
|
readonly reason: string;
|
|
1412
1439
|
};
|
|
1440
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1441
|
+
readonly type: "schedule.resumed";
|
|
1442
|
+
readonly payload: {};
|
|
1443
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1444
|
+
readonly type: "schedule.retired";
|
|
1445
|
+
readonly payload: {};
|
|
1413
1446
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1414
1447
|
readonly type: "schedule.skipped";
|
|
1415
1448
|
readonly payload: {
|
|
@@ -1420,6 +1453,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
|
|
|
1420
1453
|
readonly manual: boolean;
|
|
1421
1454
|
readonly triggerId?: string | undefined;
|
|
1422
1455
|
};
|
|
1456
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1457
|
+
readonly type: "schedule.triggered";
|
|
1458
|
+
readonly payload: {};
|
|
1423
1459
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
1424
1460
|
readonly type: "schedule.updated";
|
|
1425
1461
|
readonly payload: {
|
|
@@ -21,8 +21,8 @@ export declare function corpusModule(options?: {
|
|
|
21
21
|
decision: 'approve' | 'reject';
|
|
22
22
|
}>;
|
|
23
23
|
}>, {
|
|
24
|
-
charge: import("@swirls/looms/core").
|
|
25
|
-
chargeV2: import("@swirls/looms/core").
|
|
24
|
+
charge: import("@swirls/looms/core").LocalEffectDefinition<JsonValue, never, EventInput> | import("@swirls/looms/core").WorkerEffectDefinition<JsonValue, EventInput>;
|
|
25
|
+
chargeV2: import("@swirls/looms/core").LocalEffectDefinition<JsonValue, never, EventInput> | import("@swirls/looms/core").WorkerEffectDefinition<JsonValue, EventInput>;
|
|
26
26
|
}, {
|
|
27
27
|
'corpus.checkout': import("@swirls/looms/core").ThreadDefinition<{
|
|
28
28
|
readonly amount: number;
|