@swirls/looms 0.3.0 → 0.4.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 +9 -0
- package/dist/agent/debugger/agent-chat.js +3 -30
- package/dist/agent/debugger/streaming-text.d.ts +6 -0
- package/dist/agent/debugger/streaming-text.js +33 -0
- package/dist/agent/module.d.ts +413 -413
- package/dist/core/attempts.d.ts +8 -0
- package/dist/core/attempts.js +27 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +1 -0
- package/dist/core/projection.d.ts +5 -4
- package/dist/{react → core}/register.d.ts +9 -8
- package/dist/debugger/app/assets/index-D--9esm9.js +22 -0
- package/dist/debugger/app/assets/routes-Dakrdusf.js +47 -0
- package/dist/debugger/app/index.html +1 -1
- package/dist/evaluator/effects.d.ts +33 -33
- package/dist/evaluator/module.d.ts +66 -66
- package/dist/react/derived.d.ts +26 -8
- package/dist/react/derived.js +23 -26
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +2 -2
- package/dist/react/react.d.ts +7 -8
- package/dist/react/react.js +4 -4
- package/dist/react/store.d.ts +4 -5
- package/package.json +2 -2
- package/dist/debugger/app/assets/index-BevQYa-U.js +0 -22
- package/dist/debugger/app/assets/routes-B17Om93i.js +0 -47
- /package/dist/{react → core}/register.js +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Looms debugger</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-D--9esm9.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-CbXtAM7H.js">
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-CgDzWJg7.css">
|
|
10
10
|
</head>
|
|
@@ -6,39 +6,6 @@ export declare const evaluateEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
6
6
|
readonly definitionName?: string | undefined;
|
|
7
7
|
readonly input?: Schema.Json | undefined;
|
|
8
8
|
}, EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
9
|
-
readonly type: "evaluator.evaluated";
|
|
10
|
-
readonly payload: {
|
|
11
|
-
readonly evaluationId: string;
|
|
12
|
-
readonly definitionName?: string | undefined;
|
|
13
|
-
readonly answers: {
|
|
14
|
-
readonly [x: string]: {
|
|
15
|
-
readonly type: "boolean";
|
|
16
|
-
readonly value: boolean;
|
|
17
|
-
readonly probability: number;
|
|
18
|
-
} | {
|
|
19
|
-
readonly type: "choice";
|
|
20
|
-
readonly value: string;
|
|
21
|
-
} | {
|
|
22
|
-
readonly type: "score";
|
|
23
|
-
readonly value: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
readonly route: string;
|
|
27
|
-
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
28
|
-
readonly usage?: {
|
|
29
|
-
readonly input: number;
|
|
30
|
-
readonly output: number;
|
|
31
|
-
} | undefined;
|
|
32
|
-
};
|
|
33
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
34
|
-
readonly type: "evaluator.requested";
|
|
35
|
-
readonly payload: {
|
|
36
|
-
readonly evaluationId: string;
|
|
37
|
-
readonly definitionName?: string | undefined;
|
|
38
|
-
readonly state: string;
|
|
39
|
-
readonly model?: string | undefined;
|
|
40
|
-
};
|
|
41
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
42
9
|
readonly type: "runtime.effect.ambiguous";
|
|
43
10
|
readonly payload: {
|
|
44
11
|
readonly effectId: string;
|
|
@@ -235,4 +202,37 @@ export declare const evaluateEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
235
202
|
readonly payload: Schema.Json;
|
|
236
203
|
};
|
|
237
204
|
};
|
|
205
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
206
|
+
readonly type: "evaluator.evaluated";
|
|
207
|
+
readonly payload: {
|
|
208
|
+
readonly evaluationId: string;
|
|
209
|
+
readonly definitionName?: string | undefined;
|
|
210
|
+
readonly answers: {
|
|
211
|
+
readonly [x: string]: {
|
|
212
|
+
readonly type: "boolean";
|
|
213
|
+
readonly value: boolean;
|
|
214
|
+
readonly probability: number;
|
|
215
|
+
} | {
|
|
216
|
+
readonly type: "choice";
|
|
217
|
+
readonly value: string;
|
|
218
|
+
} | {
|
|
219
|
+
readonly type: "score";
|
|
220
|
+
readonly value: number;
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
readonly route: string;
|
|
224
|
+
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
225
|
+
readonly usage?: {
|
|
226
|
+
readonly input: number;
|
|
227
|
+
readonly output: number;
|
|
228
|
+
} | undefined;
|
|
229
|
+
};
|
|
230
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
231
|
+
readonly type: "evaluator.requested";
|
|
232
|
+
readonly payload: {
|
|
233
|
+
readonly evaluationId: string;
|
|
234
|
+
readonly definitionName?: string | undefined;
|
|
235
|
+
readonly state: string;
|
|
236
|
+
readonly model?: string | undefined;
|
|
237
|
+
};
|
|
238
238
|
})>>;
|
|
@@ -41,39 +41,6 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
41
41
|
readonly definitionName?: string | undefined;
|
|
42
42
|
readonly input?: import("effect/Schema").Json | undefined;
|
|
43
43
|
}, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
44
|
-
readonly type: "evaluator.evaluated";
|
|
45
|
-
readonly payload: {
|
|
46
|
-
readonly evaluationId: string;
|
|
47
|
-
readonly definitionName?: string | undefined;
|
|
48
|
-
readonly answers: {
|
|
49
|
-
readonly [x: string]: {
|
|
50
|
-
readonly type: "boolean";
|
|
51
|
-
readonly value: boolean;
|
|
52
|
-
readonly probability: number;
|
|
53
|
-
} | {
|
|
54
|
-
readonly type: "choice";
|
|
55
|
-
readonly value: string;
|
|
56
|
-
} | {
|
|
57
|
-
readonly type: "score";
|
|
58
|
-
readonly value: number;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
readonly route: string;
|
|
62
|
-
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
63
|
-
readonly usage?: {
|
|
64
|
-
readonly input: number;
|
|
65
|
-
readonly output: number;
|
|
66
|
-
} | undefined;
|
|
67
|
-
};
|
|
68
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
69
|
-
readonly type: "evaluator.requested";
|
|
70
|
-
readonly payload: {
|
|
71
|
-
readonly evaluationId: string;
|
|
72
|
-
readonly definitionName?: string | undefined;
|
|
73
|
-
readonly state: string;
|
|
74
|
-
readonly model?: string | undefined;
|
|
75
|
-
};
|
|
76
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
77
44
|
readonly type: "runtime.effect.ambiguous";
|
|
78
45
|
readonly payload: {
|
|
79
46
|
readonly effectId: string;
|
|
@@ -270,6 +237,39 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
270
237
|
readonly payload: import("effect/Schema").Json;
|
|
271
238
|
};
|
|
272
239
|
};
|
|
240
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
241
|
+
readonly type: "evaluator.evaluated";
|
|
242
|
+
readonly payload: {
|
|
243
|
+
readonly evaluationId: string;
|
|
244
|
+
readonly definitionName?: string | undefined;
|
|
245
|
+
readonly answers: {
|
|
246
|
+
readonly [x: string]: {
|
|
247
|
+
readonly type: "boolean";
|
|
248
|
+
readonly value: boolean;
|
|
249
|
+
readonly probability: number;
|
|
250
|
+
} | {
|
|
251
|
+
readonly type: "choice";
|
|
252
|
+
readonly value: string;
|
|
253
|
+
} | {
|
|
254
|
+
readonly type: "score";
|
|
255
|
+
readonly value: number;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
readonly route: string;
|
|
259
|
+
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
260
|
+
readonly usage?: {
|
|
261
|
+
readonly input: number;
|
|
262
|
+
readonly output: number;
|
|
263
|
+
} | undefined;
|
|
264
|
+
};
|
|
265
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
266
|
+
readonly type: "evaluator.requested";
|
|
267
|
+
readonly payload: {
|
|
268
|
+
readonly evaluationId: string;
|
|
269
|
+
readonly definitionName?: string | undefined;
|
|
270
|
+
readonly state: string;
|
|
271
|
+
readonly model?: string | undefined;
|
|
272
|
+
};
|
|
273
273
|
})>;
|
|
274
274
|
}, {
|
|
275
275
|
evaluator: import("@swirls/looms/core").ThreadDefinition<{
|
|
@@ -336,39 +336,6 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
336
336
|
readonly definitionName?: string | undefined;
|
|
337
337
|
readonly input?: import("effect/Schema").Json | undefined;
|
|
338
338
|
}, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
339
|
-
readonly type: "evaluator.evaluated";
|
|
340
|
-
readonly payload: {
|
|
341
|
-
readonly evaluationId: string;
|
|
342
|
-
readonly definitionName?: string | undefined;
|
|
343
|
-
readonly answers: {
|
|
344
|
-
readonly [x: string]: {
|
|
345
|
-
readonly type: "boolean";
|
|
346
|
-
readonly value: boolean;
|
|
347
|
-
readonly probability: number;
|
|
348
|
-
} | {
|
|
349
|
-
readonly type: "choice";
|
|
350
|
-
readonly value: string;
|
|
351
|
-
} | {
|
|
352
|
-
readonly type: "score";
|
|
353
|
-
readonly value: number;
|
|
354
|
-
};
|
|
355
|
-
};
|
|
356
|
-
readonly route: string;
|
|
357
|
-
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
358
|
-
readonly usage?: {
|
|
359
|
-
readonly input: number;
|
|
360
|
-
readonly output: number;
|
|
361
|
-
} | undefined;
|
|
362
|
-
};
|
|
363
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
364
|
-
readonly type: "evaluator.requested";
|
|
365
|
-
readonly payload: {
|
|
366
|
-
readonly evaluationId: string;
|
|
367
|
-
readonly definitionName?: string | undefined;
|
|
368
|
-
readonly state: string;
|
|
369
|
-
readonly model?: string | undefined;
|
|
370
|
-
};
|
|
371
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
372
339
|
readonly type: "runtime.effect.ambiguous";
|
|
373
340
|
readonly payload: {
|
|
374
341
|
readonly effectId: string;
|
|
@@ -565,6 +532,39 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
|
|
|
565
532
|
readonly payload: import("effect/Schema").Json;
|
|
566
533
|
};
|
|
567
534
|
};
|
|
535
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
536
|
+
readonly type: "evaluator.evaluated";
|
|
537
|
+
readonly payload: {
|
|
538
|
+
readonly evaluationId: string;
|
|
539
|
+
readonly definitionName?: string | undefined;
|
|
540
|
+
readonly answers: {
|
|
541
|
+
readonly [x: string]: {
|
|
542
|
+
readonly type: "boolean";
|
|
543
|
+
readonly value: boolean;
|
|
544
|
+
readonly probability: number;
|
|
545
|
+
} | {
|
|
546
|
+
readonly type: "choice";
|
|
547
|
+
readonly value: string;
|
|
548
|
+
} | {
|
|
549
|
+
readonly type: "score";
|
|
550
|
+
readonly value: number;
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
readonly route: string;
|
|
554
|
+
readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
|
|
555
|
+
readonly usage?: {
|
|
556
|
+
readonly input: number;
|
|
557
|
+
readonly output: number;
|
|
558
|
+
} | undefined;
|
|
559
|
+
};
|
|
560
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
561
|
+
readonly type: "evaluator.requested";
|
|
562
|
+
readonly payload: {
|
|
563
|
+
readonly evaluationId: string;
|
|
564
|
+
readonly definitionName?: string | undefined;
|
|
565
|
+
readonly state: string;
|
|
566
|
+
readonly model?: string | undefined;
|
|
567
|
+
};
|
|
568
568
|
})>;
|
|
569
569
|
};
|
|
570
570
|
readonly threads: {
|
package/dist/react/derived.d.ts
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
|
-
import { type EventEnvelope, type ProjectionDefinition } from '@swirls/looms/core';
|
|
2
|
-
import type { AnyEventEnvelope, RegisteredEvent } from './register';
|
|
3
|
-
export type { AnyEventEnvelope } from './register';
|
|
1
|
+
import { type AnyEventEnvelope, type EventEnvelope, type InferSchemaOutput, type ProjectionDefinition, type RegisteredEvent, type SchemaInput } from '@swirls/looms/core';
|
|
4
2
|
export { EventIndex, eventThreadKey } from '@swirls/looms/core';
|
|
5
|
-
export interface
|
|
3
|
+
export interface LiveFoldDefinition<S, TEvent extends AnyEventEnvelope = RegisteredEvent> {
|
|
4
|
+
readonly kind: 'liveFold';
|
|
6
5
|
readonly name?: string;
|
|
6
|
+
readonly shape?: unknown;
|
|
7
7
|
readonly initialState: S;
|
|
8
8
|
reduce(state: S, event: TEvent): S;
|
|
9
|
-
readonly includeEphemeral?: boolean;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Client-side fold that sees ephemeral events, which projections skip. Ephemeral events from an
|
|
12
|
+
* effect attempt that the runtime later retried never reach the reducer. The reducer still owns
|
|
13
|
+
* resets on domain events, such as the durable message that replaces streamed text. Use a
|
|
14
|
+
* projection for anything else.
|
|
15
|
+
*/
|
|
16
|
+
export declare function defineLiveFold<S, TEvent extends AnyEventEnvelope = RegisteredEvent>(def: {
|
|
17
|
+
readonly name?: string;
|
|
18
|
+
readonly shape?: undefined;
|
|
19
|
+
readonly initialState: S;
|
|
20
|
+
reduce(state: S, event: TEvent): S;
|
|
21
|
+
}): LiveFoldDefinition<S, TEvent>;
|
|
22
|
+
export declare function defineLiveFold<TShape extends SchemaInput, TEvent extends AnyEventEnvelope = RegisteredEvent>(def: {
|
|
23
|
+
readonly name?: string;
|
|
24
|
+
readonly shape: TShape;
|
|
25
|
+
readonly initialState: InferSchemaOutput<TShape>;
|
|
26
|
+
reduce(state: NoInfer<InferSchemaOutput<TShape>>, event: TEvent): InferSchemaOutput<TShape>;
|
|
27
|
+
}): LiveFoldDefinition<InferSchemaOutput<TShape>, TEvent>;
|
|
28
|
+
/** Fold events through a live fold, as `useLiveFold` does, including ephemeral events. */
|
|
29
|
+
export declare function foldLive<S, TEvent extends AnyEventEnvelope = RegisteredEvent>(definition: LiveFoldDefinition<S, TEvent>, events: readonly TEvent[]): S;
|
|
13
30
|
export declare class ProjectionCache {
|
|
14
31
|
private projectionCache;
|
|
15
32
|
private foldCache;
|
|
16
33
|
project<S>(definition: ProjectionDefinition<S>, events: readonly EventEnvelope[]): S;
|
|
17
|
-
|
|
34
|
+
/** A retry can supersede events already folded, so a batch containing one refolds from scratch. */
|
|
35
|
+
fold<S, TEvent extends AnyEventEnvelope = RegisteredEvent>(definition: LiveFoldDefinition<S, TEvent>, events: readonly TEvent[]): S;
|
|
18
36
|
clear(): void;
|
|
19
37
|
}
|
package/dist/react/derived.js
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import { project } from '@swirls/looms/core';
|
|
1
|
+
import { dropSupersededAttempts, project, retriedEffectId, } from '@swirls/looms/core';
|
|
2
2
|
export { EventIndex, eventThreadKey } from '@swirls/looms/core';
|
|
3
|
-
export function
|
|
4
|
-
return def;
|
|
3
|
+
export function defineLiveFold(def) {
|
|
4
|
+
return { ...def, kind: 'liveFold' };
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
let state = from
|
|
8
|
-
const
|
|
9
|
-
for (const event of events) {
|
|
10
|
-
if (event.ephemeral && !includeEphemeral) {
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
6
|
+
function foldFrom(definition, events, from) {
|
|
7
|
+
let state = from;
|
|
8
|
+
for (const event of dropSupersededAttempts(events)) {
|
|
13
9
|
state = definition.reduce(state, event);
|
|
14
10
|
}
|
|
15
11
|
return state;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
/** Fold events through a live fold, as `useLiveFold` does, including ephemeral events. */
|
|
14
|
+
export function foldLive(definition, events) {
|
|
15
|
+
return foldFrom(definition, events, definition.initialState);
|
|
16
|
+
}
|
|
17
|
+
function hasNoRetries(batch) {
|
|
18
|
+
return !batch.some((event) => retriedEffectId(event) !== undefined);
|
|
19
|
+
}
|
|
20
|
+
/** Folds only the events appended since the last call, unless `canAppend` rejects them. */
|
|
21
|
+
function advanceCache(cache, definition, events, compute, canAppend = () => true) {
|
|
19
22
|
const cached = cache.get(definition);
|
|
20
|
-
if (
|
|
21
|
-
const state = compute(definition, events);
|
|
22
|
-
cache.set(definition, { state, upTo: total });
|
|
23
|
-
return state;
|
|
24
|
-
}
|
|
25
|
-
if (cached.upTo === total) {
|
|
23
|
+
if (cached?.upTo === events.length) {
|
|
26
24
|
return cached.state;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
const state = compute(definition, events);
|
|
34
|
-
cache.set(definition, { state, upTo: total });
|
|
26
|
+
const batch = cached && cached.upTo < events.length ? events.slice(cached.upTo) : undefined;
|
|
27
|
+
const state = cached && batch && canAppend(batch)
|
|
28
|
+
? compute(definition, batch, cached.state)
|
|
29
|
+
: compute(definition, events, definition.initialState);
|
|
30
|
+
cache.set(definition, { state, upTo: events.length });
|
|
35
31
|
return state;
|
|
36
32
|
}
|
|
37
33
|
export class ProjectionCache {
|
|
@@ -40,8 +36,9 @@ export class ProjectionCache {
|
|
|
40
36
|
project(definition, events) {
|
|
41
37
|
return advanceCache(this.projectionCache, definition, events, project);
|
|
42
38
|
}
|
|
39
|
+
/** A retry can supersede events already folded, so a batch containing one refolds from scratch. */
|
|
43
40
|
fold(definition, events) {
|
|
44
|
-
return advanceCache(this.foldCache, definition, events,
|
|
41
|
+
return advanceCache(this.foldCache, definition, events, foldFrom, hasNoRetries);
|
|
45
42
|
}
|
|
46
43
|
clear() {
|
|
47
44
|
this.projectionCache = new WeakMap();
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createLoomsStore, type LoomsClientStore, type LoomsClientStoreOptions, type LoomsConnectionStatus, type LoomsStoreQuery, type CoalesceOption, type StoreListener, } from './store';
|
|
2
|
-
export {
|
|
2
|
+
export { defineLiveFold, foldLive, EventIndex, eventThreadKey, type LiveFoldDefinition, } from './derived';
|
|
3
3
|
export { materializeEvents } from './materialize';
|
|
4
4
|
export { emptyTables, type MaterializedTables, type RunRow, type ThreadRow } from './tables';
|
|
5
|
-
export type { LoomsRegister, RegisteredEvent, AnyEventEnvelope } from '
|
|
6
|
-
export { LoomsProvider, useRunStore, useProjection, useRunSelector, useRunSummary, useRunEvents, useThreadTree, useEventCounts, useEventBySeq, useLatestEvent,
|
|
5
|
+
export type { LoomsRegister, RegisteredEvent, AnyEventEnvelope } from '@swirls/looms/core';
|
|
6
|
+
export { LoomsProvider, useRunStore, useProjection, useRunSelector, useRunSummary, useRunEvents, useThreadTree, useEventCounts, useEventBySeq, useLatestEvent, useLiveFold, type LoomsProviderProps, type UseRunStoreOptions, type RunSummary, } from './react';
|
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createLoomsStore, } from './store.js';
|
|
2
|
-
export {
|
|
2
|
+
export { defineLiveFold, foldLive, EventIndex, eventThreadKey, } from './derived.js';
|
|
3
3
|
export { materializeEvents } from './materialize.js';
|
|
4
4
|
export { emptyTables } from './tables.js';
|
|
5
|
-
export { LoomsProvider, useRunStore, useProjection, useRunSelector, useRunSummary, useRunEvents, useThreadTree, useEventCounts, useEventBySeq, useLatestEvent,
|
|
5
|
+
export { LoomsProvider, useRunStore, useProjection, useRunSelector, useRunSummary, useRunEvents, useThreadTree, useEventCounts, useEventBySeq, useLatestEvent, useLiveFold, } from './react.js';
|
package/dist/react/react.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { type ProjectionDefinition, type RunStatus, type ThreadTree } from '@swirls/looms/core';
|
|
3
|
-
import {
|
|
4
|
-
import type { AnyEventEnvelope, RegisteredEvent } from './register';
|
|
2
|
+
import { type AnyEventEnvelope, type ProjectionDefinition, type RegisteredEvent, type RunStatus, type ThreadTree } from '@swirls/looms/core';
|
|
3
|
+
import { defineLiveFold, foldLive, type LiveFoldDefinition } from './derived';
|
|
5
4
|
import { createLoomsStore, type CoalesceOption, type LoomsClientStore, type LoomsConnectionStatus } from './store';
|
|
6
5
|
export interface LoomsProviderProps {
|
|
7
6
|
children: ReactNode;
|
|
@@ -55,10 +54,10 @@ export declare function useEventCounts<TEvent extends AnyEventEnvelope = Registe
|
|
|
55
54
|
export declare function useEventBySeq<TEvent extends AnyEventEnvelope = RegisteredEvent>(store: LoomsClientStore<TEvent>, seq: number | undefined): TEvent | undefined;
|
|
56
55
|
/** Subscribe to the latest event of a given type. */
|
|
57
56
|
export declare function useLatestEvent<TEvent extends AnyEventEnvelope = RegisteredEvent>(store: LoomsClientStore<TEvent>, type: string): TEvent | undefined;
|
|
58
|
-
/** Subscribe to a
|
|
59
|
-
export declare function
|
|
57
|
+
/** Subscribe to a live fold, which includes ephemeral events. */
|
|
58
|
+
export declare function useLiveFold<S, TEvent extends AnyEventEnvelope = RegisteredEvent>(store: LoomsClientStore<TEvent>, fold: LiveFoldDefinition<S, TEvent>): S;
|
|
60
59
|
export { createLoomsStore };
|
|
61
|
-
export {
|
|
60
|
+
export { defineLiveFold, foldLive };
|
|
62
61
|
export type { LoomsClientStore, LoomsClientStoreOptions, LoomsConnectionStatus, LoomsStoreQuery, CoalesceOption, StoreListener, } from './store';
|
|
63
|
-
export type {
|
|
64
|
-
export type { LoomsRegister, RegisteredEvent, AnyEventEnvelope } from '
|
|
62
|
+
export type { LiveFoldDefinition } from './derived';
|
|
63
|
+
export type { LoomsRegister, RegisteredEvent, AnyEventEnvelope } from '@swirls/looms/core';
|
package/dist/react/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Fiber } from 'effect';
|
|
2
2
|
import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore, } from 'react';
|
|
3
3
|
import { isTerminalStatus, threadTree, toThreadTree, } from '@swirls/looms/core';
|
|
4
|
-
import {
|
|
4
|
+
import { defineLiveFold, foldLive } from './derived.js';
|
|
5
5
|
import { createLoomsStore, } from './store.js';
|
|
6
6
|
const LoomsContext = createContext({ endpoint: '' });
|
|
7
7
|
const GRACE_MS = 5_000;
|
|
@@ -165,10 +165,10 @@ export function useLatestEvent(store, type) {
|
|
|
165
165
|
const selector = useCallback((s) => s.query.latest(type), [type]);
|
|
166
166
|
return useRunSelector(store, selector);
|
|
167
167
|
}
|
|
168
|
-
/** Subscribe to a
|
|
169
|
-
export function
|
|
168
|
+
/** Subscribe to a live fold, which includes ephemeral events. */
|
|
169
|
+
export function useLiveFold(store, fold) {
|
|
170
170
|
const getSnapshot = useCallback(() => store.fold(fold), [store, fold]);
|
|
171
171
|
return useStoreSnapshot(store, getSnapshot);
|
|
172
172
|
}
|
|
173
173
|
export { createLoomsStore };
|
|
174
|
-
export {
|
|
174
|
+
export { defineLiveFold, foldLive };
|
package/dist/react/store.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type EventInput, type ProjectionDefinition } from '@swirls/looms/core';
|
|
2
|
-
import { type
|
|
1
|
+
import { type AnyEventEnvelope, type EventInput, type ProjectionDefinition, type RegisteredEvent } from '@swirls/looms/core';
|
|
2
|
+
import { type LiveFoldDefinition } from './derived';
|
|
3
3
|
import { type CoalesceOption } from './notify';
|
|
4
|
-
import type { AnyEventEnvelope, RegisteredEvent } from './register';
|
|
5
4
|
import { type MaterializedTables } from './tables';
|
|
6
5
|
export type { CoalesceOption } from './notify';
|
|
7
6
|
/** Fired after the store version bumps. Re-read via `events()` / `getState()` / `query`. */
|
|
@@ -30,7 +29,7 @@ export interface LoomsStoreQuery<TEvent extends AnyEventEnvelope = RegisteredEve
|
|
|
30
29
|
bySeq: (seq: number) => TEvent | undefined;
|
|
31
30
|
startedAt: () => number | undefined;
|
|
32
31
|
latest: (type: string) => TEvent | undefined;
|
|
33
|
-
fold: <S>(def:
|
|
32
|
+
fold: <S>(def: LiveFoldDefinition<S, TEvent>) => S;
|
|
34
33
|
}
|
|
35
34
|
export interface LoomsClientStore<TEvent extends AnyEventEnvelope = RegisteredEvent> {
|
|
36
35
|
storeId: string;
|
|
@@ -43,7 +42,7 @@ export interface LoomsClientStore<TEvent extends AnyEventEnvelope = RegisteredEv
|
|
|
43
42
|
query: LoomsStoreQuery<TEvent>;
|
|
44
43
|
subscribe: (listener: StoreListener) => () => void;
|
|
45
44
|
project<S>(definition: ProjectionDefinition<S>): S;
|
|
46
|
-
fold<S>(definition:
|
|
45
|
+
fold<S>(definition: LiveFoldDefinition<S, TEvent>): S;
|
|
47
46
|
flush: () => void;
|
|
48
47
|
commit: (event: EventInput | readonly EventInput[]) => Promise<void>;
|
|
49
48
|
sync: () => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swirls/looms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Pluggable event-sourced runtime for durable agents and workflows",
|
|
5
5
|
"homepage": "https://github.com/ByteSliceHQ/looms#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
},
|
|
138
138
|
"scripts": {
|
|
139
139
|
"build": "bun run scripts/assemble.ts",
|
|
140
|
-
"check-types": "bun -
|
|
140
|
+
"check-types": "bun x tsc -p type-tests/unregistered/tsconfig.json --noEmit && bun x tsc -p type-tests/registered/tsconfig.json --noEmit && bun x tsc -p type-tests/registered-core/tsconfig.json --noEmit",
|
|
141
141
|
"test": "bun -e \"void 0\""
|
|
142
142
|
},
|
|
143
143
|
"dependencies": {
|