@swirls/looms 0.6.0 → 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 +24 -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 +540 -504
- package/dist/approval/effects.d.ts +36 -27
- 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 +87 -14
- 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 +30 -8
- 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 +40 -4
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @swirls/looms
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f2bef2f: Effects declare `placement: 'local' | 'worker'` on `m.effect`, `scope.effect`, or `defineEffect`. Local effects require `execute`; worker effects forbid it and implement the handler with `workerHandlers`. Queue routes take worker definitions, local and worker handlers get distinct context types, and `defineModule` rejects effects built outside the module's catalog. `GET /definitions/effects` publishes each declared effect, including placement, retry policy, and input schema.
|
|
8
|
+
|
|
9
|
+
## Unreleased
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- **Breaking:** Effect placement is explicit. `m.effect`, `scope.effect`, and `defineEffect` require `placement: 'local' | 'worker'`. Local effects must define `execute`; worker effects must not, and their handlers go in `workerHandlers`. Worker definitions no longer carry a no-op `execute`, and `hasHandler` is removed; branch on `placement` instead. The old inferred `execution` / handler-less / string-`handles` overlap model is removed. `cloudflareQueueWorker` routes take `{ effects: [definition], queue }` instead of `handles` type strings. `onEffect` only accepts local definitions; `workerHandlers` only accepts worker definitions. Handlers receive `LocalEffectContext` or `WorkerEffectContext` (`placement` discriminant); worker `emit` stays buffered until complete.
|
|
14
|
+
- **Breaking:** `defineModule` rejects effects whose events fall outside the module's catalog and `observes`, such as an effect built with another module's scope or an unscoped `defineEffect` that returns untyped events. Build effects that live in their own file with `createModuleScope(...).effect`.
|
|
15
|
+
- Effect admission hooks (`admission` / `onAdmit`) run in the host before every local attempt and before every worker dispatch, so credit checks and feature flags cover both paths. `failEffect` from admission becomes `runtime.effect.failed`; a rejected worker admission never queues. Execution middleware remains local-only.
|
|
16
|
+
- `onAdmit` and `onEffect` decode the input with the definition's schema before the hook runs, so hooks see defaults and transforms. An input that fails to decode fails the attempt.
|
|
17
|
+
- Queue tasks carry `threadId`, `causingEventId`, and `attributes`. Secrets load through the worker callback before the handler runs. `GET /definitions/effects` lists declared effects, including placement, retry policy, and input schema. `runtime.effectPlacements` lists placements; `inspectRun` / effect status includes each outstanding effect's `placement`.
|
|
18
|
+
- Creating a runtime fails when worker-placed effects have no `EffectWorker`, or when a worker claims a local-placed effect type.
|
|
19
|
+
- Unacknowledged worker dispatch failures no longer park as `ambiguous` on the first push. The attempt enters `dispatch_wait` via `runtime.effect.dispatch.deferred`, and the wake engine retries the same attempt with dedicated outbox backoff. `ambiguous` remains for missing workers, cancellation timeouts, and exhausted relays. Acknowledged transports (Cloudflare Queues) are unchanged. `retryEffect` can target `dispatch_wait`.
|
|
20
|
+
|
|
21
|
+
## 0.6.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 979055d: Fix a wake-loop spin that failed a run with `MaxWakeIterationsError` whenever a workflow node finished while a sibling node was still busy (an effect in `retry_wait`, a sleep, or a child wait) and nothing else was runnable. The workflow scheduler legitimately returned no events in that situation, but the local executor recorded the empty result as a failed attempt (`empty-outcome`), and because an untagged effect takes its id from the event that caused it, the failure event re-derived an identical scheduler effect under a new id, over and over. An effect handler that returns no events is now recorded as `runtime.effect.completed`, matching the worker path, and the fold no longer re-issues an untagged effect that the completion event itself would reproduce unchanged; any later event for the thread still re-derives it with a fresh id. Parallel root nodes no longer need to be serialised into a dependency chain to survive a retry.
|
|
26
|
+
|
|
3
27
|
## 0.6.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
package/dist/actor/cell.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ActorCellOptions<TModules extends readonly AnyRuntimeModule[] =
|
|
|
20
20
|
/** Starts runs from effect handlers. Required for schedules; there is no default inside a cell. */
|
|
21
21
|
readonly launcher?: RunLauncher;
|
|
22
22
|
/**
|
|
23
|
-
* Dispatches
|
|
23
|
+
* Dispatches worker-placed effects out of the cell (for example a
|
|
24
24
|
* Cloudflare Queue producer). Without it, worker effects cannot leave the object.
|
|
25
25
|
*/
|
|
26
26
|
readonly worker?: EffectWorker;
|
package/dist/actor/routing.d.ts
CHANGED
|
@@ -9,7 +9,11 @@ export declare function runIdFromRequest(req: Request): string | null;
|
|
|
9
9
|
* runs needs a global index, and a fork writes a second run. `host` names the backend.
|
|
10
10
|
*/
|
|
11
11
|
export declare function crossRunResponse(req: Request, host: string): Response | null;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Answers definition catalogs from a module list or lazy factory without touching any run cell.
|
|
14
|
+
* `GET /definitions` is the thread-definition catalog. `GET /definitions/effects` is each declared
|
|
15
|
+
* effect, including placement.
|
|
16
|
+
*/
|
|
13
17
|
export declare function definitionsResponse(req: Request, modules: readonly AnyRuntimeModule[] | (() => readonly AnyRuntimeModule[]) | undefined): Response | null;
|
|
14
18
|
export interface ResolvedRunTarget {
|
|
15
19
|
readonly runId: string;
|
package/dist/actor/routing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data, Effect, Option, Predicate, Schema } from 'effect';
|
|
2
|
-
import { composeModules, createRunId, isJsonObject, publishDefinition, stringifyJson, } from '@swirls/looms/core';
|
|
2
|
+
import { composeModules, createRunId, isJsonObject, publishDefinition, publishEffects, stringifyJson, } from '@swirls/looms/core';
|
|
3
3
|
const RunTargetBodySchema = Schema.Struct({
|
|
4
4
|
runId: Schema.optional(Schema.NonEmptyString),
|
|
5
5
|
});
|
|
@@ -36,12 +36,23 @@ export function crossRunResponse(req, host) {
|
|
|
36
36
|
}
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Answers definition catalogs from a module list or lazy factory without touching any run cell.
|
|
41
|
+
* `GET /definitions` is the thread-definition catalog. `GET /definitions/effects` is each declared
|
|
42
|
+
* effect, including placement.
|
|
43
|
+
*/
|
|
40
44
|
export function definitionsResponse(req, modules) {
|
|
41
|
-
if (!modules || req.method !== 'GET'
|
|
45
|
+
if (!modules || req.method !== 'GET') {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const pathname = new URL(req.url).pathname;
|
|
49
|
+
if (pathname !== '/definitions' && pathname !== '/definitions/effects') {
|
|
42
50
|
return null;
|
|
43
51
|
}
|
|
44
52
|
const registry = composeModules(Predicate.isFunction(modules) ? modules() : modules);
|
|
53
|
+
if (pathname === '/definitions/effects') {
|
|
54
|
+
return Response.json({ effects: publishEffects(registry.effects.values()) });
|
|
55
|
+
}
|
|
45
56
|
return Response.json({
|
|
46
57
|
definitions: registry.definitions.map(publishDefinition),
|
|
47
58
|
projections: [...registry.projections.keys()],
|
package/dist/agent/effects.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type JsonValue } from '@swirls/looms/core';
|
|
|
3
3
|
import { AgentDefinitionsTag } from './definitions-store';
|
|
4
4
|
import { LlmTag } from './llm';
|
|
5
5
|
import { type ToolCall } from './types';
|
|
6
|
-
export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").
|
|
6
|
+
export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
|
|
7
7
|
readonly turn: number;
|
|
8
8
|
readonly definitionName?: string | undefined;
|
|
9
9
|
readonly definitionVersion: string;
|
|
@@ -309,6 +309,15 @@ export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
309
309
|
readonly effectId: string;
|
|
310
310
|
readonly attempt: number;
|
|
311
311
|
};
|
|
312
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
313
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
314
|
+
readonly payload: {
|
|
315
|
+
readonly effectId: string;
|
|
316
|
+
readonly attempt: number;
|
|
317
|
+
readonly retryAt: number;
|
|
318
|
+
readonly error: string;
|
|
319
|
+
readonly try: number;
|
|
320
|
+
};
|
|
312
321
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
313
322
|
readonly type: "runtime.effect.dispatched";
|
|
314
323
|
readonly payload: {
|
|
@@ -502,7 +511,7 @@ export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
502
511
|
};
|
|
503
512
|
};
|
|
504
513
|
})>>;
|
|
505
|
-
export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").
|
|
514
|
+
export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
|
|
506
515
|
readonly turn: number;
|
|
507
516
|
readonly definitionName?: string | undefined;
|
|
508
517
|
readonly definitionVersion: string;
|
|
@@ -800,6 +809,15 @@ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").Eff
|
|
|
800
809
|
readonly effectId: string;
|
|
801
810
|
readonly attempt: number;
|
|
802
811
|
};
|
|
812
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
813
|
+
readonly type: "runtime.effect.dispatch.deferred";
|
|
814
|
+
readonly payload: {
|
|
815
|
+
readonly effectId: string;
|
|
816
|
+
readonly attempt: number;
|
|
817
|
+
readonly retryAt: number;
|
|
818
|
+
readonly error: string;
|
|
819
|
+
readonly try: number;
|
|
820
|
+
};
|
|
803
821
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
804
822
|
readonly type: "runtime.effect.dispatched";
|
|
805
823
|
readonly payload: {
|
package/dist/agent/effects.js
CHANGED
|
@@ -74,6 +74,7 @@ function toolError(input, threadId, error) {
|
|
|
74
74
|
}
|
|
75
75
|
export const callLlmEffect = agentModule.effect({
|
|
76
76
|
type: 'agent.callLLM',
|
|
77
|
+
placement: 'local',
|
|
77
78
|
input: CallLlmInput,
|
|
78
79
|
execute: (input, ctx) => runCallLlm({
|
|
79
80
|
turn: input.turn,
|
|
@@ -263,6 +264,7 @@ function runCallLlm(args) {
|
|
|
263
264
|
}
|
|
264
265
|
export const executeToolEffect = agentModule.effect({
|
|
265
266
|
type: 'agent.executeTool',
|
|
267
|
+
placement: 'local',
|
|
266
268
|
input: ExecuteToolInput,
|
|
267
269
|
execute: (input, ctx) => Effect.gen(function* () {
|
|
268
270
|
const threadId = ctx.threadId;
|