@swirls/looms 0.14.0 → 0.15.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 +10 -0
- package/dist/actor/cell.d.ts +3 -9
- package/dist/actor/host.d.ts +2 -4
- package/dist/cloudflare/durable-object.d.ts +5 -17
- package/dist/core/event-codec.js +3 -0
- package/dist/debugger/app/assets/{index-CtGiJU8b.js → index-CZwbkhFX.js} +3 -3
- package/dist/debugger/app/assets/routes-CSuFE23L.js +47 -0
- package/dist/debugger/app/index.html +1 -1
- package/dist/react/derived.d.ts +5 -2
- package/dist/react/derived.js +27 -4
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/react.d.ts +16 -4
- package/dist/react/react.js +20 -10
- package/dist/react/store.d.ts +43 -1
- package/dist/react/store.js +201 -24
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/looms.d.ts +2 -4
- package/dist/runtime/runtime.d.ts +1 -1
- package/dist/runtime/runtime.js +7 -1
- package/dist/runtime/server/http.d.ts +6 -0
- package/dist/runtime/server/http.js +13 -0
- package/dist/runtime/server/routes/runs.js +22 -5
- package/dist/runtime/types.d.ts +15 -8
- package/package.json +1 -1
- package/dist/debugger/app/assets/routes-Bg0vNEOr.js +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @swirls/looms
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 890bacc: `store.commit` in `@swirls/looms/react` can show its events before the host confirms them. Pass `{ optimistic: true }`, or set `optimistic` on `createLoomsStore`: the events are folded into projections and live folds at once, after every confirmed event, replaced by the host's copies when those arrive, and removed if the commit fails, in which case `commit` rejects. `store.pending()` lists the events still waiting and `isPendingEvent` identifies one. `commit` also takes an `idempotencyKey` and a `send` function for writes that go through a route of your own. Events decoded from the wire now keep their `idempotencyKey`, which is how a pending event is matched to its confirmed one.
|
|
8
|
+
|
|
9
|
+
The store also reports when it has caught up: `store.synced()` and `useRunSummary(store).synced` are false until it holds everything the log had when it connected. `LoomsProvider` and `useRunStore` take `retainMs`, how long a store stays connected after its last component unmounts, and `useRunStore` and `createLoomsStore` take `fromSeq` to follow a run from a later point in its log.
|
|
10
|
+
|
|
11
|
+
- 890bacc: A signal can be answered as soon as its events are committed, without waiting for the run to finish acting on them. Pass `{ wake: 'schedule' }` to `signal` on the runtime, `createLooms`, an actor host or a Durable Object stub: it resolves once the events are on the log and leaves the wake to the scheduler, as `launchRun` does. Over HTTP, `POST /runs/:id/events` and `POST /runs/:id/signals/:namespace/:name` do the same when sent with `Prefer: respond-async` or `?respond=async`, and answer `202`. The `state` in that answer is the one the events were committed against; follow the event stream for what the run does next. `store.commit` in `@swirls/looms/react` now asks for this, so it resolves when the event is committed and no longer stays open for the length of an agent turn.
|
|
12
|
+
|
|
3
13
|
## 0.14.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/actor/cell.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnyRuntimeModule, type DefinitionResolver, type EventInput, type EventStore, type EventStoreTrimCoverage, type LaunchRunArgs, type RunAttributeFields, type RunLauncher, type RunState, type RunStatusSnapshot, type SnapshotStore } from '@swirls/looms/core';
|
|
2
|
-
import { type Authorize, type EffectWorker, type LoomsRuntime, type StartResult, type StartRunArgs, type WakeScheduler } from '@swirls/looms/runtime';
|
|
2
|
+
import { type Authorize, type EffectWorker, type LoomsRuntime, type RunSignalOptions, 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;
|
|
@@ -41,15 +41,9 @@ export interface ActorCell<TModules extends readonly AnyRuntimeModule[] = readon
|
|
|
41
41
|
launch(args: LaunchRunArgs): Promise<void>;
|
|
42
42
|
status(): Promise<RunStatusSnapshot | null>;
|
|
43
43
|
startRun(args: StartRunArgs): Promise<StartResult>;
|
|
44
|
-
signal(events: ReadonlyArray<EventInput>, options?:
|
|
45
|
-
idempotencyKey?: string;
|
|
46
|
-
coalesce?: boolean;
|
|
47
|
-
}): Promise<RunState>;
|
|
44
|
+
signal(events: ReadonlyArray<EventInput>, options?: RunSignalOptions): Promise<RunState>;
|
|
48
45
|
/** Append runtime-originated events. Not the client signal path. */
|
|
49
|
-
accept(events: ReadonlyArray<EventInput>, options?:
|
|
50
|
-
idempotencyKey?: string;
|
|
51
|
-
coalesce?: boolean;
|
|
52
|
-
}): Promise<RunState>;
|
|
46
|
+
accept(events: ReadonlyArray<EventInput>, options?: RunSignalOptions): Promise<RunState>;
|
|
53
47
|
cancel(): Promise<void>;
|
|
54
48
|
getRun(): Promise<RunState>;
|
|
55
49
|
}
|
package/dist/actor/host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyRuntimeModule, DefinitionResolver, EventInput, EventStore, EventStoreTrimCoverage, RunAttributeFields, RunLauncher, RunState, SnapshotStore } from '@swirls/looms/core';
|
|
2
|
-
import { type Authorize, type StartResult, type StartRunArgs } from '@swirls/looms/runtime';
|
|
2
|
+
import { type Authorize, type RunSignalOptions, type StartResult, type StartRunArgs } from '@swirls/looms/runtime';
|
|
3
3
|
import { type ActorCell } from './cell';
|
|
4
4
|
export interface LocalActorHostOptions<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
|
|
5
5
|
readonly createStore: (runId: string) => EventStore | Promise<EventStore>;
|
|
@@ -27,9 +27,7 @@ export interface LocalActorHost<TModules extends readonly AnyRuntimeModule[] = r
|
|
|
27
27
|
getCell(runId: string): Promise<ActorCell<TModules>>;
|
|
28
28
|
readonly launcher: RunLauncher;
|
|
29
29
|
startRun(args: StartRunArgs): Promise<StartResult>;
|
|
30
|
-
signal(runId: string, events: ReadonlyArray<EventInput>, options?:
|
|
31
|
-
idempotencyKey?: string;
|
|
32
|
-
}): Promise<RunState>;
|
|
30
|
+
signal(runId: string, events: ReadonlyArray<EventInput>, options?: RunSignalOptions): Promise<RunState>;
|
|
33
31
|
getRun(runId: string): Promise<RunState>;
|
|
34
32
|
fetch(req: Request): Promise<Response | null>;
|
|
35
33
|
dispose(): Promise<void>;
|
|
@@ -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 RunAttributeFields, type RunLauncher, type RunState, type RunStatusSnapshot } from '@swirls/looms/core';
|
|
3
3
|
import type { Projector } from '@swirls/looms/projectors';
|
|
4
|
-
import { type Authorize, type EffectWorker, type StartResult, type StartRunArgs } from '@swirls/looms/runtime';
|
|
4
|
+
import { type Authorize, type EffectWorker, type RunSignalOptions, type StartResult, type StartRunArgs } from '@swirls/looms/runtime';
|
|
5
5
|
import { type DeleteTerminalRunStorageOptions } from './delete-terminal-run-storage';
|
|
6
6
|
export interface LoomsDurableObjectConfig {
|
|
7
7
|
readonly modules: readonly AnyRuntimeModule[];
|
|
@@ -61,14 +61,8 @@ export declare abstract class LoomsDurableObject<Env = unknown> extends DurableO
|
|
|
61
61
|
launch(args: LaunchRunArgs): Promise<void>;
|
|
62
62
|
status(): Promise<RunStatusSnapshot | null>;
|
|
63
63
|
startRun(args: StartRunArgs): Promise<StartResult>;
|
|
64
|
-
signal(events: ReadonlyArray<EventInput>, options?:
|
|
65
|
-
|
|
66
|
-
coalesce?: boolean;
|
|
67
|
-
}): Promise<RunState>;
|
|
68
|
-
accept(events: ReadonlyArray<EventInput>, options?: {
|
|
69
|
-
idempotencyKey?: string;
|
|
70
|
-
coalesce?: boolean;
|
|
71
|
-
}): Promise<RunState>;
|
|
64
|
+
signal(events: ReadonlyArray<EventInput>, options?: RunSignalOptions): Promise<RunState>;
|
|
65
|
+
accept(events: ReadonlyArray<EventInput>, options?: RunSignalOptions): Promise<RunState>;
|
|
72
66
|
cancel(): Promise<void>;
|
|
73
67
|
getRun(): Promise<RunState>;
|
|
74
68
|
/**
|
|
@@ -85,14 +79,8 @@ export interface DurableObjectRunStub {
|
|
|
85
79
|
launch(args: LaunchRunArgs): Promise<void>;
|
|
86
80
|
status(): Promise<RunStatusSnapshot | null>;
|
|
87
81
|
startRun(args: StartRunArgs): Promise<StartResult>;
|
|
88
|
-
signal(events: ReadonlyArray<EventInput>, options?:
|
|
89
|
-
|
|
90
|
-
coalesce?: boolean;
|
|
91
|
-
}): Promise<RunState>;
|
|
92
|
-
accept(events: ReadonlyArray<EventInput>, options?: {
|
|
93
|
-
idempotencyKey?: string;
|
|
94
|
-
coalesce?: boolean;
|
|
95
|
-
}): Promise<RunState>;
|
|
82
|
+
signal(events: ReadonlyArray<EventInput>, options?: RunSignalOptions): Promise<RunState>;
|
|
83
|
+
accept(events: ReadonlyArray<EventInput>, options?: RunSignalOptions): Promise<RunState>;
|
|
96
84
|
cancel(): Promise<void>;
|
|
97
85
|
getRun(): Promise<RunState>;
|
|
98
86
|
deleteTerminalRunStorage?(options?: DeleteTerminalRunStorageOptions): Promise<void>;
|
package/dist/core/event-codec.js
CHANGED
|
@@ -75,6 +75,9 @@ export function decodeLoomsEvent(raw, runId) {
|
|
|
75
75
|
effectId: 'effectId' in raw && Predicate.isString(raw.effectId) ? raw.effectId : null,
|
|
76
76
|
ephemeral,
|
|
77
77
|
origin,
|
|
78
|
+
idempotencyKey: 'idempotencyKey' in raw && Predicate.isString(raw.idempotencyKey)
|
|
79
|
+
? raw.idempotencyKey
|
|
80
|
+
: null,
|
|
78
81
|
}, { seq });
|
|
79
82
|
}
|
|
80
83
|
throw new Error('Invalid event payload: missing type');
|