@swirls/looms 0.0.2 → 0.1.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.
Files changed (256) hide show
  1. package/CHANGELOG.md +9 -2
  2. package/dist/actor/cell.d.ts +9 -4
  3. package/dist/actor/cell.js +7 -11
  4. package/dist/actor/host.d.ts +7 -3
  5. package/dist/actor/host.js +55 -32
  6. package/dist/actor/index.d.ts +1 -1
  7. package/dist/actor/index.js +1 -1
  8. package/dist/actor/routing.d.ts +12 -1
  9. package/dist/actor/routing.js +57 -51
  10. package/dist/agent/agent-session.d.ts +5 -0
  11. package/dist/agent/agent-session.js +270 -0
  12. package/dist/agent/definitions-store.d.ts +2 -3
  13. package/dist/agent/definitions-store.js +2 -4
  14. package/dist/agent/definitions.d.ts +46 -20
  15. package/dist/agent/definitions.js +36 -8
  16. package/dist/agent/effects.d.ts +359 -2
  17. package/dist/agent/effects.js +60 -34
  18. package/dist/agent/events.d.ts +175 -19
  19. package/dist/agent/events.js +45 -10
  20. package/dist/agent/index.d.ts +1 -0
  21. package/dist/agent/index.js +1 -0
  22. package/dist/agent/llm.d.ts +11 -2
  23. package/dist/agent/llm.js +13 -3
  24. package/dist/agent/module.d.ts +812 -78
  25. package/dist/agent/module.js +16 -4
  26. package/dist/agent/scope.d.ts +174 -18
  27. package/dist/agent/signals.d.ts +24 -1
  28. package/dist/agent/signals.js +77 -0
  29. package/dist/agent/threads.d.ts +3 -33
  30. package/dist/agent/threads.js +20 -25
  31. package/dist/agent/tool-schema.js +0 -1
  32. package/dist/agent/types.d.ts +49 -4
  33. package/dist/agent/types.js +5 -5
  34. package/dist/ai-vercel/index.d.ts +1 -0
  35. package/dist/ai-vercel/index.js +1 -0
  36. package/dist/ai-vercel/messages.js +22 -7
  37. package/dist/ai-vercel/vercel-evaluator.d.ts +23 -0
  38. package/dist/ai-vercel/vercel-evaluator.js +68 -0
  39. package/dist/ai-vercel/vercel-llm.js +64 -44
  40. package/dist/approval/effects.d.ts +89 -0
  41. package/dist/approval/module.d.ts +179 -29
  42. package/dist/approval/projections.d.ts +0 -14
  43. package/dist/approval/projections.js +20 -3
  44. package/dist/approval/signals.d.ts +2 -0
  45. package/dist/approval/signals.js +18 -2
  46. package/dist/cli/cli.js +2 -0
  47. package/dist/cli/commands.js +12 -16
  48. package/dist/client/client.d.ts +1195 -18
  49. package/dist/client/client.js +118 -120
  50. package/dist/client/index.d.ts +1 -1
  51. package/dist/client/index.js +1 -1
  52. package/dist/client/sse.d.ts +13 -0
  53. package/dist/client/sse.js +38 -44
  54. package/dist/cloudflare/alarm-scheduler.d.ts +12 -2
  55. package/dist/cloudflare/alarm-scheduler.js +34 -7
  56. package/dist/cloudflare/durable-object.d.ts +10 -2
  57. package/dist/cloudflare/durable-object.js +59 -28
  58. package/dist/cloudflare/event-store.d.ts +7 -2
  59. package/dist/cloudflare/event-store.js +8 -7
  60. package/dist/cloudflare/index.d.ts +2 -2
  61. package/dist/cloudflare/index.js +2 -2
  62. package/dist/cloudflare/router.js +13 -14
  63. package/dist/core/catalog.d.ts +3 -3
  64. package/dist/core/catalog.js +2 -5
  65. package/dist/core/coalesce.js +5 -3
  66. package/dist/core/compose.d.ts +2 -1
  67. package/dist/core/compose.js +18 -2
  68. package/dist/core/definition-store.d.ts +11 -0
  69. package/dist/core/definition-store.js +6 -0
  70. package/dist/core/effects.d.ts +127 -15
  71. package/dist/core/effects.js +89 -17
  72. package/dist/core/envelope.d.ts +27 -7
  73. package/dist/core/envelope.js +20 -6
  74. package/dist/core/event-codec.d.ts +4 -2
  75. package/dist/core/event-codec.js +10 -5
  76. package/dist/core/event-index.js +1 -3
  77. package/dist/core/fold.d.ts +3 -0
  78. package/dist/core/fold.js +171 -24
  79. package/dist/core/ids.d.ts +5 -0
  80. package/dist/core/ids.js +35 -2
  81. package/dist/core/index.d.ts +5 -1
  82. package/dist/core/index.js +5 -1
  83. package/dist/core/kind.d.ts +22 -0
  84. package/dist/core/kind.js +17 -0
  85. package/dist/core/limits.d.ts +34 -0
  86. package/dist/core/limits.js +46 -0
  87. package/dist/core/match.d.ts +1 -0
  88. package/dist/core/match.js +10 -1
  89. package/dist/core/module-scope.d.ts +22 -20
  90. package/dist/core/module-scope.js +38 -28
  91. package/dist/core/module.d.ts +16 -5
  92. package/dist/core/module.js +4 -0
  93. package/dist/core/projection.d.ts +13 -13
  94. package/dist/core/projection.js +9 -5
  95. package/dist/core/protocol.d.ts +68 -11
  96. package/dist/core/protocol.js +82 -11
  97. package/dist/core/replay.d.ts +312 -3
  98. package/dist/core/replay.js +11 -1
  99. package/dist/core/schema.d.ts +8 -19
  100. package/dist/core/schema.js +25 -80
  101. package/dist/core/serialize.js +2 -4
  102. package/dist/core/snapshot-store.d.ts +2 -1
  103. package/dist/core/snapshot-store.js +8 -2
  104. package/dist/core/snapshots.d.ts +5 -1
  105. package/dist/core/snapshots.js +10 -15
  106. package/dist/core/sqlite-store.js +56 -11
  107. package/dist/core/state.d.ts +142 -4
  108. package/dist/core/state.js +78 -0
  109. package/dist/core/store.d.ts +38 -3
  110. package/dist/core/store.js +77 -22
  111. package/dist/core/thread.d.ts +10 -9
  112. package/dist/core/types.d.ts +5 -8
  113. package/dist/core/types.js +28 -24
  114. package/dist/core/validate-event.js +14 -4
  115. package/dist/core/worker-callback.d.ts +17 -0
  116. package/dist/core/worker-callback.js +1 -0
  117. package/dist/debugger/components/event-stream.js +9 -10
  118. package/dist/debugger/events/protocol-summarize.js +26 -0
  119. package/dist/debugger/lib/event-meta.js +1 -2
  120. package/dist/evaluator/definitions-store.d.ts +11 -0
  121. package/dist/evaluator/definitions-store.js +8 -0
  122. package/dist/evaluator/definitions.d.ts +18 -0
  123. package/dist/evaluator/definitions.js +4 -0
  124. package/dist/evaluator/effects.d.ts +226 -0
  125. package/dist/evaluator/effects.js +132 -0
  126. package/dist/evaluator/evaluator.d.ts +24 -0
  127. package/dist/evaluator/evaluator.js +67 -0
  128. package/dist/evaluator/events.d.ts +59 -0
  129. package/dist/evaluator/events.js +21 -0
  130. package/dist/evaluator/index.d.ts +11 -0
  131. package/dist/evaluator/index.js +11 -0
  132. package/dist/evaluator/module.d.ts +606 -0
  133. package/dist/evaluator/module.js +25 -0
  134. package/dist/evaluator/projections.d.ts +50 -0
  135. package/dist/evaluator/projections.js +20 -0
  136. package/dist/evaluator/scope.d.ts +59 -0
  137. package/dist/evaluator/scope.js +7 -0
  138. package/dist/evaluator/signals.d.ts +3 -0
  139. package/dist/evaluator/signals.js +17 -0
  140. package/dist/evaluator/threads.d.ts +62 -0
  141. package/dist/evaluator/threads.js +117 -0
  142. package/dist/evaluator/types.d.ts +125 -0
  143. package/dist/evaluator/types.js +51 -0
  144. package/dist/projectors/delivery.d.ts +83 -0
  145. package/dist/projectors/delivery.js +182 -0
  146. package/dist/projectors/index-model.d.ts +1 -1
  147. package/dist/projectors/index-model.js +4 -6
  148. package/dist/projectors/index.d.ts +2 -0
  149. package/dist/projectors/index.js +2 -0
  150. package/dist/projectors/memory.d.ts +1 -1
  151. package/dist/projectors/memory.js +10 -8
  152. package/dist/projectors/postgres.js +44 -58
  153. package/dist/projectors/projector.d.ts +17 -0
  154. package/dist/projectors/projector.js +26 -1
  155. package/dist/projectors/sqlite-delivery.d.ts +4 -0
  156. package/dist/projectors/sqlite-delivery.js +147 -0
  157. package/dist/projectors/sqlite.js +23 -23
  158. package/dist/projectors/with-projectors.d.ts +7 -2
  159. package/dist/projectors/with-projectors.js +27 -28
  160. package/dist/react/notify.js +11 -8
  161. package/dist/react/react.d.ts +2 -3
  162. package/dist/react/react.js +14 -30
  163. package/dist/react/sse.d.ts +1 -1
  164. package/dist/react/sse.js +1 -1
  165. package/dist/react/store.d.ts +2 -2
  166. package/dist/react/store.js +109 -119
  167. package/dist/runtime/cancellation.d.ts +16 -0
  168. package/dist/runtime/cancellation.js +129 -0
  169. package/dist/runtime/deadline-transition-planner.d.ts +31 -0
  170. package/dist/runtime/deadline-transition-planner.js +139 -0
  171. package/dist/runtime/dispatch-effect.d.ts +3 -2
  172. package/dist/runtime/dispatch-effect.js +7 -13
  173. package/dist/runtime/errors.d.ts +51 -0
  174. package/dist/runtime/errors.js +39 -0
  175. package/dist/runtime/{runtime-helpers.d.ts → helpers.d.ts} +24 -4
  176. package/dist/runtime/{runtime-helpers.js → helpers.js} +56 -19
  177. package/dist/runtime/index.d.ts +3 -3
  178. package/dist/runtime/index.js +3 -3
  179. package/dist/runtime/ingress.d.ts +15 -0
  180. package/dist/runtime/ingress.js +42 -0
  181. package/dist/runtime/local-effect-executor.d.ts +21 -0
  182. package/dist/runtime/local-effect-executor.js +137 -0
  183. package/dist/runtime/looms.d.ts +22 -4
  184. package/dist/runtime/looms.js +54 -36
  185. package/dist/runtime/observer.d.ts +45 -0
  186. package/dist/runtime/observer.js +11 -0
  187. package/dist/runtime/repository.d.ts +55 -0
  188. package/dist/runtime/repository.js +278 -0
  189. package/dist/runtime/retry-policy.d.ts +16 -0
  190. package/dist/runtime/retry-policy.js +29 -0
  191. package/dist/runtime/run-execution-context.d.ts +30 -0
  192. package/dist/runtime/run-execution-context.js +56 -0
  193. package/dist/runtime/run-start.d.ts +4 -0
  194. package/dist/runtime/run-start.js +44 -0
  195. package/dist/runtime/runtime.d.ts +6 -87
  196. package/dist/runtime/runtime.js +233 -470
  197. package/dist/runtime/server/auth.d.ts +40 -0
  198. package/dist/runtime/server/auth.js +40 -0
  199. package/dist/runtime/server/fetch-handler.d.ts +14 -0
  200. package/dist/runtime/server/fetch-handler.js +51 -0
  201. package/dist/runtime/server/http.d.ts +37 -0
  202. package/dist/runtime/server/http.js +62 -0
  203. package/dist/runtime/server/route-table.d.ts +55 -0
  204. package/dist/runtime/server/route-table.js +74 -0
  205. package/dist/runtime/server/routes/effects.d.ts +3 -0
  206. package/dist/runtime/server/routes/effects.js +59 -0
  207. package/dist/runtime/server/routes/operations.d.ts +3 -0
  208. package/dist/runtime/server/routes/operations.js +14 -0
  209. package/dist/runtime/server/routes/runs.d.ts +3 -0
  210. package/dist/runtime/server/routes/runs.js +192 -0
  211. package/dist/runtime/server.d.ts +2 -8
  212. package/dist/runtime/server.js +4 -211
  213. package/dist/runtime/sse.d.ts +2 -1
  214. package/dist/runtime/sse.js +24 -17
  215. package/dist/runtime/types.d.ts +115 -0
  216. package/dist/runtime/types.js +1 -0
  217. package/dist/runtime/wake-engine.d.ts +20 -0
  218. package/dist/runtime/wake-engine.js +311 -0
  219. package/dist/runtime/wake-scheduler.d.ts +3 -4
  220. package/dist/runtime/wake-scheduler.js +25 -31
  221. package/dist/runtime/worker-callbacks.d.ts +16 -0
  222. package/dist/runtime/worker-callbacks.js +167 -0
  223. package/dist/runtime/worker-effect-dispatch.d.ts +36 -0
  224. package/dist/runtime/worker-effect-dispatch.js +126 -0
  225. package/dist/s2/config.d.ts +1 -1
  226. package/dist/s2/config.js +1 -1
  227. package/dist/s2/lite.js +70 -82
  228. package/dist/s2/pagination.d.ts +15 -0
  229. package/dist/s2/pagination.js +36 -0
  230. package/dist/s2/projector.js +6 -5
  231. package/dist/s2/snapshot-store.js +148 -163
  232. package/dist/s2/store.d.ts +3 -21
  233. package/dist/s2/store.js +71 -165
  234. package/dist/testing/index.d.ts +15 -0
  235. package/dist/testing/index.js +53 -16
  236. package/dist/workflow/definitions-store.d.ts +2 -3
  237. package/dist/workflow/definitions-store.js +2 -2
  238. package/dist/workflow/definitions.d.ts +78 -22
  239. package/dist/workflow/definitions.js +80 -14
  240. package/dist/workflow/effects.d.ts +453 -107
  241. package/dist/workflow/effects.js +214 -115
  242. package/dist/workflow/events.d.ts +149 -5
  243. package/dist/workflow/events.js +27 -5
  244. package/dist/workflow/graph.d.ts +56 -0
  245. package/dist/workflow/graph.js +207 -0
  246. package/dist/workflow/index.d.ts +1 -0
  247. package/dist/workflow/index.js +1 -0
  248. package/dist/workflow/module.d.ts +1047 -266
  249. package/dist/workflow/projections.d.ts +14 -12
  250. package/dist/workflow/projections.js +30 -8
  251. package/dist/workflow/scope.d.ts +146 -4
  252. package/dist/workflow/threads.d.ts +383 -155
  253. package/dist/workflow/threads.js +308 -110
  254. package/package.json +7 -2
  255. package/dist/runtime/events-api.d.ts +0 -4
  256. package/dist/runtime/events-api.js +0 -84
@@ -0,0 +1,34 @@
1
+ import type { AppendableEvent } from './envelope';
2
+ import type { RunSnapshot } from './snapshot-store';
3
+ import type { JsonValue } from './types';
4
+ export declare const DEFAULT_MAX_EVENT_BYTES: number;
5
+ export declare const DEFAULT_MAX_SNAPSHOT_BYTES: number;
6
+ declare const EventPayloadTooLargeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
7
+ readonly _tag: "EventPayloadTooLargeError";
8
+ } & Readonly<A>;
9
+ export declare class EventPayloadTooLargeError extends EventPayloadTooLargeError_base<{
10
+ readonly runId: string;
11
+ readonly eventType: string;
12
+ readonly bytes: number;
13
+ readonly maxBytes: number;
14
+ readonly message: string;
15
+ }> {
16
+ constructor(runId: string, eventType: string, bytes: number, maxBytes: number);
17
+ }
18
+ declare const SnapshotPayloadTooLargeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
19
+ readonly _tag: "SnapshotPayloadTooLargeError";
20
+ } & Readonly<A>;
21
+ export declare class SnapshotPayloadTooLargeError extends SnapshotPayloadTooLargeError_base<{
22
+ readonly runId: string;
23
+ readonly bytes: number;
24
+ readonly maxBytes: number;
25
+ readonly message: string;
26
+ }> {
27
+ constructor(runId: string, bytes: number, maxBytes: number);
28
+ }
29
+ /** Size of `value` as serialized JSON, in UTF-8 bytes. */
30
+ export declare function utf8JsonBytes(value: JsonValue | Readonly<object>): number;
31
+ /** Validate every event before any storage mutation begins. */
32
+ export declare function assertEventByteLimits(runId: string, events: ReadonlyArray<AppendableEvent>, maxBytes?: number): void;
33
+ export declare function assertSnapshotByteLimit(snapshot: RunSnapshot, maxBytes?: number): void;
34
+ export {};
@@ -0,0 +1,46 @@
1
+ import { Data } from 'effect';
2
+ export const DEFAULT_MAX_EVENT_BYTES = 1024 * 1024;
3
+ export const DEFAULT_MAX_SNAPSHOT_BYTES = 8 * 1024 * 1024;
4
+ const utf8 = new TextEncoder();
5
+ export class EventPayloadTooLargeError extends Data.TaggedError('EventPayloadTooLargeError') {
6
+ constructor(runId, eventType, bytes, maxBytes) {
7
+ super({
8
+ runId,
9
+ eventType,
10
+ bytes,
11
+ maxBytes,
12
+ message: `EventPayloadTooLarge: event "${eventType}" for run "${runId}" is ${bytes} UTF-8 bytes; limit is ${maxBytes}`,
13
+ });
14
+ this.name = 'EventPayloadTooLargeError';
15
+ }
16
+ }
17
+ export class SnapshotPayloadTooLargeError extends Data.TaggedError('SnapshotPayloadTooLargeError') {
18
+ constructor(runId, bytes, maxBytes) {
19
+ super({
20
+ runId,
21
+ bytes,
22
+ maxBytes,
23
+ message: `SnapshotPayloadTooLarge: snapshot for run "${runId}" is ${bytes} UTF-8 bytes; limit is ${maxBytes}`,
24
+ });
25
+ this.name = 'SnapshotPayloadTooLargeError';
26
+ }
27
+ }
28
+ /** Size of `value` as serialized JSON, in UTF-8 bytes. */
29
+ export function utf8JsonBytes(value) {
30
+ return utf8.encode(JSON.stringify(value)).byteLength;
31
+ }
32
+ /** Validate every event before any storage mutation begins. */
33
+ export function assertEventByteLimits(runId, events, maxBytes = DEFAULT_MAX_EVENT_BYTES) {
34
+ for (const event of events) {
35
+ const bytes = utf8JsonBytes({ ...event, runId, seq: event.seq ?? 0 });
36
+ if (bytes > maxBytes) {
37
+ throw new EventPayloadTooLargeError(runId, event.type, bytes, maxBytes);
38
+ }
39
+ }
40
+ }
41
+ export function assertSnapshotByteLimit(snapshot, maxBytes = DEFAULT_MAX_SNAPSHOT_BYTES) {
42
+ const bytes = utf8JsonBytes(snapshot);
43
+ if (bytes > maxBytes) {
44
+ throw new SnapshotPayloadTooLargeError(snapshot.runId, bytes, maxBytes);
45
+ }
46
+ }
@@ -4,5 +4,6 @@ import type { JsonValue } from './types';
4
4
  export declare function isSubset(match: JsonValue, payload: JsonValue): boolean;
5
5
  export declare function matchesWait(event: EventEnvelope, on: WaitCondition): boolean;
6
6
  export declare function matchingWaits<T extends {
7
+ waitId: string;
7
8
  on: WaitCondition;
8
9
  }>(event: EventEnvelope, waits: readonly T[]): T[];
@@ -54,5 +54,14 @@ export function matchesWait(event, on) {
54
54
  return isSubset(on.match, event.payload);
55
55
  }
56
56
  export function matchingWaits(event, waits) {
57
- return waits.filter((record) => matchesWait(event, record.on));
57
+ return waits.filter((record) => {
58
+ if (isWaitOnTimer(record.on)) {
59
+ if (event.type !== 'runtime.timer.fired' || !Predicate.isObject(event.payload)) {
60
+ return false;
61
+ }
62
+ const firedWaitId = event.payload.waitId;
63
+ return Predicate.isString(firedWaitId) && firedWaitId === record.waitId;
64
+ }
65
+ return matchesWait(event, record.on);
66
+ });
58
67
  }
@@ -1,9 +1,9 @@
1
1
  import type { Layer } from 'effect';
2
2
  import { type CatalogEntries, type EventCatalog, type EventInputOf, type EventsOfCatalog, type InferPayload } from './catalog';
3
3
  import type { EventsOf, ProtocolEvents } from './compose';
4
- import { type EffectDefinition, type EffectHandlerResult, type EmitEffect, type RetryPolicy, type RuntimeEffect, type ScopedEffectContext } from './effects';
4
+ import { type EffectDefinition, type EffectExecution, type EffectHandlerResult, type EmitEffect, type RetryPolicy, type RuntimeEffect, type ScopedEffectContext } from './effects';
5
5
  import type { EventEnvelope, EventInput } from './envelope';
6
- import { type AnyRuntimeModule, type EffectMiddleware, type RuntimeModule, type DefinitionRef, type RuntimeModuleDependency } from './module';
6
+ import { type AnyRuntimeModule, type EffectMiddleware, type RuntimeModule, type DefinitionRef, type RuntimeModuleDependency, type SignalInterruptRule } from './module';
7
7
  import { type ProjectionDefinition } from './projection';
8
8
  import type { InferDefinedSchema, InferSchemaOutput, SchemaInput } from './schema';
9
9
  import { type StartContext, type ThreadContext, type ThreadDefinition } from './thread';
@@ -32,40 +32,41 @@ export interface ModuleScope<TNamespace extends string, U extends EventEnvelope<
32
32
  readonly events?: TEvents;
33
33
  readonly observes?: TObserves;
34
34
  readonly dependencies?: readonly RuntimeModuleDependency[];
35
- thread<TShape, TInputSchema extends SchemaInput | undefined = undefined>(def: {
36
- readonly kind: string;
37
- readonly shape: TShape;
38
- readonly input?: TInputSchema;
39
- initialState(ctx: StartContext<InferDefinedSchema<TInputSchema>>): InferSchemaOutput<TShape>;
40
- step(state: InferSchemaOutput<TShape>, event: U, ctx: ThreadContext): InferSchemaOutput<TShape>;
41
- effects?(state: InferSchemaOutput<TShape>, ctx: ThreadContext): RuntimeEffect[];
42
- }): ThreadDefinition<InferSchemaOutput<TShape>>;
43
35
  thread<S = JsonValue, TInputSchema extends SchemaInput | undefined = undefined>(def: {
44
36
  readonly kind: string;
45
- readonly shape?: unknown;
37
+ readonly shape?: undefined;
46
38
  readonly input?: TInputSchema;
47
39
  initialState(ctx: StartContext<InferDefinedSchema<TInputSchema>>): S;
48
40
  step(state: S, event: U, ctx: ThreadContext): S;
49
41
  effects?(state: S, ctx: ThreadContext): RuntimeEffect[];
50
42
  }): ThreadDefinition<S>;
51
- projection<TShape>(def: {
52
- readonly name: string;
43
+ thread<TShape extends SchemaInput, TInputSchema extends SchemaInput | undefined = undefined>(def: {
44
+ readonly kind: string;
53
45
  readonly shape: TShape;
54
- readonly initialState: InferSchemaOutput<TShape>;
55
- reduce(state: InferSchemaOutput<TShape>, event: U): InferSchemaOutput<TShape>;
56
- }): ProjectionDefinition<InferSchemaOutput<TShape>>;
46
+ readonly input?: TInputSchema;
47
+ initialState(ctx: StartContext<InferDefinedSchema<TInputSchema>>): InferSchemaOutput<TShape>;
48
+ step(state: NoInfer<InferSchemaOutput<TShape>>, event: U, ctx: ThreadContext): InferSchemaOutput<TShape>;
49
+ effects?(state: NoInfer<InferSchemaOutput<TShape>>, ctx: ThreadContext): RuntimeEffect[];
50
+ }): ThreadDefinition<InferSchemaOutput<TShape>>;
57
51
  projection<S>(def: {
58
52
  readonly name: string;
59
- readonly shape?: unknown;
53
+ readonly shape?: undefined;
60
54
  readonly initialState: S;
61
55
  reduce(state: S, event: U): S;
62
56
  }): ProjectionDefinition<S>;
63
- effect<TSchema = undefined, TInput = InferDefinedSchema<TSchema>, R = never, E extends EventInputOf<U> = EventInputOf<U>>(def: {
57
+ projection<TShape extends SchemaInput>(def: {
58
+ readonly name: string;
59
+ readonly shape: TShape;
60
+ readonly initialState: InferSchemaOutput<TShape>;
61
+ reduce(state: NoInfer<InferSchemaOutput<TShape>>, event: U): InferSchemaOutput<TShape>;
62
+ }): ProjectionDefinition<InferSchemaOutput<TShape>>;
63
+ effect<TSchema extends SchemaInput | undefined = undefined, TInput = InferDefinedSchema<TSchema>, R = never, HandlerError = never>(def: {
64
64
  type: `${TNamespace}.${string}`;
65
65
  input?: TSchema;
66
66
  retry?: RetryPolicy;
67
- execute: (input: TInput, ctx: ScopedEffectContext<EventInputOf<U>>) => EffectHandlerResult<R, EventInputOf<U>>;
68
- }): NoInfer<EffectDefinition<TInput, R, E>>;
67
+ execution?: EffectExecution;
68
+ execute?: (input: TInput, ctx: ScopedEffectContext<EventInputOf<U>>) => EffectHandlerResult<R, EventInputOf<U>, HandlerError>;
69
+ }): NoInfer<EffectDefinition<TInput, R, EventInputOf<U>>>;
69
70
  input<K extends keyof (TEvents extends EventCatalog<any, infer E> ? E : never) & string>(key: K, payload: InferPayload<(TEvents extends EventCatalog<any, infer E> ? E : never)[K]>, meta?: Omit<EventInput, 'type' | 'payload'>): Omit<EventInput, 'type' | 'payload'> & {
70
71
  readonly type: `${TNamespace}.${K}`;
71
72
  readonly payload: InferPayload<(TEvents extends EventCatalog<any, infer E> ? E : never)[K]>;
@@ -92,6 +93,7 @@ export declare function defineModule<const N extends string, E extends EventCata
92
93
  readonly projections?: PR;
93
94
  readonly definitions?: readonly DefinitionRef[];
94
95
  readonly middleware?: readonly EffectMiddleware[];
96
+ readonly interruptsOnSignal?: SignalInterruptRule;
95
97
  } & ModuleServicesConfig<EffectRequirementsOf<FX>>): RuntimeModule<N, Extract<ModuleCatalog<N, E>, EventCatalog>, FX, TH, PR> & {
96
98
  readonly effects: FX;
97
99
  readonly threads: TH;
@@ -4,11 +4,7 @@ import {} from './module.js';
4
4
  import { defineProjection } from './projection.js';
5
5
  import { defineThread, } from './thread.js';
6
6
  import { asJson } from './types.js';
7
- function buildScopeInput(namespace, events, key, payload, meta) {
8
- if (events) {
9
- // SAFETY: catalog input produces typed EventInput for the catalog entry.
10
- return events.input(key, payload, meta);
11
- }
7
+ function buildScopeInput(namespace, key, payload, meta) {
12
8
  return {
13
9
  ...meta,
14
10
  type: `${namespace}.${key}`,
@@ -33,40 +29,54 @@ export function createModuleScope(options) {
33
29
  return defineEffect(def);
34
30
  },
35
31
  input(key, payload, meta) {
36
- return buildScopeInput(namespace, events, key, payload, meta);
32
+ return buildScopeInput(namespace, key, payload, meta);
37
33
  },
38
34
  emit(key, payload, meta) {
39
- return emit(buildScopeInput(namespace, events, key, payload, meta));
35
+ return emit(buildScopeInput(namespace, key, payload, meta));
40
36
  },
41
37
  };
42
38
  return scope;
43
39
  }
44
- /** Construct a complete module. Only members returned by setup are installed. */
45
- /* oxlint-disable anti-slop/no-runtime-typeof, anti-slop/no-chained-type-assertions, anti-slop/no-conditional-empty-object-spread, anti-slop/require-safety-comment-for-type-assertion -- This compatibility boundary normalizes either a module builder or its finished catalog while preserving its generic member types. */
40
+ function isEventCatalog(source) {
41
+ return 'namespace' in source && 'entries' in source;
42
+ }
43
+ function isModuleScope(source) {
44
+ return 'thread' in source && 'effect' in source;
45
+ }
46
46
  export function defineModule(options, setup) {
47
47
  const source = options.events;
48
- // SAFETY: catalogs have an input builder; inline entries are normalized once here.
49
- const events = (source &&
50
- (typeof source.input === 'function'
48
+ const events = source
49
+ ? isEventCatalog(source)
51
50
  ? source
52
- : defineEventCatalog(options.namespace, source)));
53
- const scope = typeof options.effect === 'function'
54
- ? options
55
- : createModuleScope({ ...options, events });
51
+ : defineEventCatalog(options.namespace, source)
52
+ : undefined;
53
+ const scope = isModuleScope(options) ? options : createModuleScope({ ...options, events });
56
54
  const members = setup(scope);
57
- return {
55
+ const module = {
58
56
  namespace: options.namespace,
59
57
  protocolVersion: options.protocolVersion,
60
- events: events,
61
- ...(options.observes ? { observes: options.observes } : {}),
62
- ...(options.dependencies ? { dependencies: options.dependencies } : {}),
63
- ...(members.definitions ? { definitions: members.definitions } : {}),
64
- ...(members.middleware ? { middleware: members.middleware } : {}),
65
- ...(members.services ? { services: members.services } : {}),
66
- // SAFETY: absent member bags use the corresponding empty-object generic defaults.
67
- effects: (members.effects ?? {}),
68
- threads: (members.threads ?? {}),
69
- projections: (members.projections ?? {}),
58
+ events,
59
+ effects: members.effects ?? {},
60
+ threads: members.threads ?? {},
61
+ projections: members.projections ?? {},
70
62
  };
63
+ if (options.observes) {
64
+ module.observes = options.observes;
65
+ }
66
+ if (options.dependencies) {
67
+ module.dependencies = options.dependencies;
68
+ }
69
+ if (members.definitions) {
70
+ module.definitions = members.definitions;
71
+ }
72
+ if (members.middleware) {
73
+ module.middleware = members.middleware;
74
+ }
75
+ if (members.services) {
76
+ module.services = members.services;
77
+ }
78
+ if (members.interruptsOnSignal) {
79
+ module.interruptsOnSignal = members.interruptsOnSignal;
80
+ }
81
+ return module;
71
82
  }
72
- /* oxlint-enable anti-slop/no-runtime-typeof, anti-slop/no-chained-type-assertions, anti-slop/no-conditional-empty-object-spread, anti-slop/require-safety-comment-for-type-assertion */
@@ -1,4 +1,4 @@
1
- import type { Effect, Layer } from 'effect';
1
+ import type { Context, Effect, Layer } from 'effect';
2
2
  import type { EventCatalog } from './catalog';
3
3
  import type { EffectContext, EffectDefinition, RuntimeEffect } from './effects';
4
4
  import type { EventInput } from './envelope';
@@ -8,6 +8,12 @@ import type { ThreadDefinition } from './thread';
8
8
  import type { JsonValue } from './types';
9
9
  export type NextEffectHandler = (effect: RuntimeEffect, ctx: EffectContext) => Effect.Effect<ReadonlyArray<EventInput>, Error>;
10
10
  export type EffectMiddleware = (effect: RuntimeEffect, ctx: EffectContext, next: NextEffectHandler) => Effect.Effect<ReadonlyArray<EventInput>, Error>;
11
+ /**
12
+ * Names the threads whose in-process effects an admitted signal event interrupts, so a running
13
+ * effect (such as a model call) can stop early. Return an empty array when the event interrupts
14
+ * nothing.
15
+ */
16
+ export type SignalInterruptRule = (event: EventInput) => readonly string[];
11
17
  export interface RuntimeModuleDependency {
12
18
  readonly namespace: string;
13
19
  readonly protocolVersion?: string;
@@ -16,12 +22,16 @@ export interface RuntimeModuleDependency {
16
22
  export interface DefinitionRef {
17
23
  readonly kind: string;
18
24
  readonly name: string;
25
+ readonly version?: string;
19
26
  readonly input?: SchemaInput | undefined;
20
27
  }
21
- /** A definition registered on a host, keyed by `${kind}:${name}`. */
28
+ export declare const DEFAULT_DEFINITION_VERSION = "v1";
29
+ export declare function definitionKey(kind: string, name: string, version: string): string;
30
+ /** A definition registered on a host, keyed by `${kind}:${name}@${version}`. */
22
31
  export interface RegisteredDefinition {
23
32
  readonly kind: string;
24
33
  readonly name: string;
34
+ readonly version: string;
25
35
  readonly input?: SchemaInput | undefined;
26
36
  readonly value: DefinitionRef;
27
37
  }
@@ -44,7 +54,7 @@ export interface RuntimeModule<TNamespace extends string = string, TEvents exten
44
54
  readonly [key: string]: ProjectionDefinition;
45
55
  } = {
46
56
  readonly [key: string]: ProjectionDefinition;
47
- }, TServices = any> {
57
+ }, TServices = Context.Service.Any> {
48
58
  readonly namespace: TNamespace;
49
59
  readonly protocolVersion: string;
50
60
  readonly events?: TEvents;
@@ -55,6 +65,7 @@ export interface RuntimeModule<TNamespace extends string = string, TEvents exten
55
65
  readonly definitions?: readonly DefinitionRef[];
56
66
  readonly dependencies?: readonly RuntimeModuleDependency[];
57
67
  readonly middleware?: readonly EffectMiddleware[];
68
+ readonly interruptsOnSignal?: SignalInterruptRule;
58
69
  /** Host-side services this module's effect handlers need (an LLM, a definition lookup, a DB pool). */
59
70
  readonly services?: () => Layer.Layer<TServices>;
60
71
  }
@@ -64,9 +75,9 @@ export declare function defineRuntimeModule<TNamespace extends string, TEvents e
64
75
  readonly [key: string]: ThreadDefinition;
65
76
  }, TProjections extends {
66
77
  readonly [key: string]: ProjectionDefinition;
67
- }, TServices = any>(module: RuntimeModule<TNamespace, TEvents, TEffects, TThreads, TProjections, TServices>): RuntimeModule<TNamespace, TEvents, TEffects, TThreads, TProjections, TServices>;
78
+ }, TServices = Context.Service.Any>(module: RuntimeModule<TNamespace, TEvents, TEffects, TThreads, TProjections, TServices>): RuntimeModule<TNamespace, TEvents, TEffects, TThreads, TProjections, TServices>;
68
79
  export type AnyRuntimeModule = RuntimeModule<string, EventCatalog, {
69
- readonly [name: string]: EffectDefinition;
80
+ readonly [name: string]: EffectDefinition<any, any, any>;
70
81
  }, {
71
82
  readonly [kind: string]: ThreadDefinition;
72
83
  }, {
@@ -1,3 +1,7 @@
1
+ export const DEFAULT_DEFINITION_VERSION = 'v1';
2
+ export function definitionKey(kind, name, version) {
3
+ return `${kind}:${name}@${version}`;
4
+ }
1
5
  export function defineRuntimeModule(module) {
2
6
  return module;
3
7
  }
@@ -1,6 +1,6 @@
1
1
  import { Schema, Stream, type Effect } from 'effect';
2
2
  import type { EventEnvelope } from './envelope';
3
- import type { InferSchemaOutput } from './schema';
3
+ import type { InferSchemaOutput, SchemaInput } from './schema';
4
4
  import type { RunState, ThreadRecord } from './state';
5
5
  export interface ProjectionDefinition<S = unknown> {
6
6
  readonly name: string;
@@ -8,18 +8,18 @@ export interface ProjectionDefinition<S = unknown> {
8
8
  initialState: S;
9
9
  reduce(state: S, event: EventEnvelope): S;
10
10
  }
11
- export declare function defineProjection<TShape>(def: {
12
- readonly name: string;
13
- readonly shape: TShape;
14
- readonly initialState: InferSchemaOutput<TShape>;
15
- reduce(state: InferSchemaOutput<TShape>, event: EventEnvelope): InferSchemaOutput<TShape>;
16
- }): ProjectionDefinition<InferSchemaOutput<TShape>>;
17
11
  export declare function defineProjection<S = unknown>(def: {
18
12
  readonly name: string;
19
- readonly shape?: unknown;
13
+ readonly shape?: undefined;
20
14
  readonly initialState: S;
21
15
  reduce(state: S, event: EventEnvelope): S;
22
16
  }): ProjectionDefinition<S>;
17
+ export declare function defineProjection<TShape extends SchemaInput>(def: {
18
+ readonly name: string;
19
+ readonly shape: TShape;
20
+ readonly initialState: InferSchemaOutput<TShape>;
21
+ reduce(state: NoInfer<InferSchemaOutput<TShape>>, event: EventEnvelope): InferSchemaOutput<TShape>;
22
+ }): ProjectionDefinition<InferSchemaOutput<TShape>>;
23
23
  export declare function foldProjection<S>(projection: ProjectionDefinition<S>, events: readonly EventEnvelope[], initial?: S): S;
24
24
  /** Fold a projection over events, skipping ephemeral ones. */
25
25
  export declare function project<S>(definition: ProjectionDefinition<S>, events: readonly EventEnvelope[], from?: S): S;
@@ -29,6 +29,7 @@ export interface ThreadNode {
29
29
  threadId: string;
30
30
  kind: string;
31
31
  definitionName: string;
32
+ definitionVersion: string;
32
33
  status: ThreadRecord['status'];
33
34
  parentThreadId: string | null;
34
35
  children: ThreadNode[];
@@ -49,28 +50,27 @@ export interface TreeBuildState {
49
50
  [threadId: string]: string[];
50
51
  };
51
52
  }
52
- export declare const TreeBuildStateSchema: Schema.Schema<TreeBuildState>;
53
53
  export declare const threadTree: ProjectionDefinition<TreeBuildState>;
54
54
  export declare function toThreadTree(state: TreeBuildState): ThreadTree;
55
55
  export declare function treeFromRun(state: RunState): ThreadTree;
56
56
  export declare const TimelineEntrySchema: Schema.Struct<{
57
- readonly seq: Schema.Number;
57
+ readonly seq: Schema.Finite;
58
58
  readonly id: Schema.String;
59
59
  readonly type: Schema.String;
60
60
  readonly threadId: Schema.NullOr<Schema.String>;
61
61
  readonly causationId: Schema.NullOr<Schema.String>;
62
62
  readonly effectId: Schema.NullOr<Schema.String>;
63
- readonly ts: Schema.Number;
63
+ readonly ts: Schema.Finite;
64
64
  }>;
65
65
  export type TimelineEntry = Schema.Schema.Type<typeof TimelineEntrySchema>;
66
66
  export declare const TimelineSchema: Schema.mutable<Schema.$Array<Schema.Struct<{
67
- readonly seq: Schema.Number;
67
+ readonly seq: Schema.Finite;
68
68
  readonly id: Schema.String;
69
69
  readonly type: Schema.String;
70
70
  readonly threadId: Schema.NullOr<Schema.String>;
71
71
  readonly causationId: Schema.NullOr<Schema.String>;
72
72
  readonly effectId: Schema.NullOr<Schema.String>;
73
- readonly ts: Schema.Number;
73
+ readonly ts: Schema.Finite;
74
74
  }>>>;
75
75
  export declare const timeline: ProjectionDefinition<{
76
76
  readonly seq: number;
@@ -1,4 +1,5 @@
1
1
  import { Predicate, Schema, Stream } from 'effect';
2
+ import { DEFAULT_DEFINITION_VERSION } from './module.js';
2
3
  import { isTerminalStatus } from './thread.js';
3
4
  export function defineProjection(def) {
4
5
  return def;
@@ -26,8 +27,6 @@ export function projectStream(definition, stream, from) {
26
27
  const getInitial = () => (from !== undefined ? from : definition.initialState);
27
28
  return Stream.runFold(stream, getInitial, (state, event) => event.ephemeral ? state : definition.reduce(state, event));
28
29
  }
29
- // SAFETY: TreeBuildState is folded by reducers; Schema.Unknown is a typed placeholder, not a decoder.
30
- export const TreeBuildStateSchema = Schema.Unknown;
31
30
  function readPayload(event) {
32
31
  if (!Predicate.isObject(event.payload)) {
33
32
  return {};
@@ -40,7 +39,6 @@ function readString(obj, key) {
40
39
  }
41
40
  export const threadTree = defineProjection({
42
41
  name: 'threadTree',
43
- shape: TreeBuildStateSchema,
44
42
  initialState: { runId: '', records: {}, rootThreadId: null },
45
43
  reduce(state, event) {
46
44
  const payload = readPayload(event);
@@ -57,6 +55,7 @@ export const threadTree = defineProjection({
57
55
  const threadId = readString(payload, 'threadId') ?? event.threadId;
58
56
  const kind = readString(payload, 'kind');
59
57
  const definitionName = readString(payload, 'definitionName');
58
+ const definitionVersion = readString(payload, 'definitionVersion') ?? DEFAULT_DEFINITION_VERSION;
60
59
  if (!threadId || !kind || !definitionName) {
61
60
  return { ...state, runId: event.runId };
62
61
  }
@@ -66,6 +65,7 @@ export const threadTree = defineProjection({
66
65
  threadId,
67
66
  kind,
68
67
  definitionName,
68
+ definitionVersion,
69
69
  parentThreadId,
70
70
  status: 'running',
71
71
  input: payload.input ?? null,
@@ -173,10 +173,13 @@ export function toThreadTree(state) {
173
173
  runId: state.runId,
174
174
  status: 'running',
175
175
  rootThreadId: state.rootThreadId,
176
+ startIdentity: null,
176
177
  threads: state.records,
177
178
  waits: {},
178
179
  outstandingEffects: [],
180
+ effectExecutions: {},
179
181
  completedEffectIds: [],
182
+ processedIdempotencyKeys: [],
180
183
  });
181
184
  }
182
185
  export function treeFromRun(state) {
@@ -196,6 +199,7 @@ export function treeFromRun(state) {
196
199
  threadId: record.threadId,
197
200
  kind: record.kind,
198
201
  definitionName: record.definitionName,
202
+ definitionVersion: record.definitionVersion,
199
203
  status: isWaiting ? 'waiting' : record.status,
200
204
  parentThreadId: record.parentThreadId,
201
205
  children: (byParent.get(record.threadId) ?? []).map(toNode),
@@ -210,13 +214,13 @@ export function treeFromRun(state) {
210
214
  };
211
215
  }
212
216
  export const TimelineEntrySchema = Schema.Struct({
213
- seq: Schema.Number,
217
+ seq: Schema.Finite,
214
218
  id: Schema.String,
215
219
  type: Schema.String,
216
220
  threadId: Schema.NullOr(Schema.String),
217
221
  causationId: Schema.NullOr(Schema.String),
218
222
  effectId: Schema.NullOr(Schema.String),
219
- ts: Schema.Number,
223
+ ts: Schema.Finite,
220
224
  });
221
225
  export const TimelineSchema = Schema.mutable(Schema.Array(TimelineEntrySchema));
222
226
  export const timeline = defineProjection({
@@ -1,27 +1,27 @@
1
1
  import { Schema } from 'effect';
2
2
  import { type EventInputOf, type EventsOfCatalog } from './catalog';
3
- import type { WaitCondition } from './effects';
4
- export declare const WaitConditionSchema: Schema.Union<readonly [Schema.Struct<{
5
- readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
6
- readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
7
- }>, Schema.Struct<{
8
- readonly timerAt: Schema.Number;
9
- }>]>;
3
+ import { WaitConditionSchema, type WaitCondition } from './effects';
10
4
  export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime", {
11
5
  'run.started': Schema.Struct<{
12
6
  readonly rootThreadId: Schema.optional<Schema.String>;
13
7
  readonly kind: Schema.String;
14
8
  readonly definitionName: Schema.String;
9
+ readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
15
10
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
11
+ readonly requestedThreadId: Schema.optional<Schema.NullOr<Schema.String>>;
16
12
  }>;
17
13
  'run.completed': Schema.Struct<{
18
14
  readonly output: Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
19
15
  readonly error: Schema.NullOr<Schema.String>;
20
16
  }>;
17
+ 'run.cancelled': Schema.Struct<{
18
+ readonly reason: Schema.optional<Schema.String>;
19
+ }>;
21
20
  'thread.started': Schema.Struct<{
22
21
  readonly threadId: Schema.String;
23
22
  readonly kind: Schema.String;
24
23
  readonly definitionName: Schema.String;
24
+ readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
25
25
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
26
26
  readonly parentThreadId: Schema.NullOr<Schema.String>;
27
27
  }>;
@@ -37,6 +37,9 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
37
37
  readonly threadId: Schema.String;
38
38
  readonly reason: Schema.optional<Schema.String>;
39
39
  }>;
40
+ 'thread.cancel.requested': Schema.Struct<{
41
+ readonly threadId: Schema.String;
42
+ }>;
40
43
  'wait.registered': Schema.Struct<{
41
44
  readonly waitId: Schema.String;
42
45
  readonly threadId: Schema.optional<Schema.String>;
@@ -44,7 +47,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
44
47
  readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
45
48
  readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
46
49
  }>, Schema.Struct<{
47
- readonly timerAt: Schema.Number;
50
+ readonly timerAt: Schema.Finite;
48
51
  }>]>;
49
52
  readonly tag: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
50
53
  }>;
@@ -60,7 +63,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
60
63
  'timer.set': Schema.Struct<{
61
64
  readonly timerId: Schema.String;
62
65
  readonly waitId: Schema.String;
63
- readonly wakeAt: Schema.Number;
66
+ readonly wakeAt: Schema.Finite;
64
67
  }>;
65
68
  'timer.fired': Schema.Struct<{
66
69
  readonly timerId: Schema.String;
@@ -70,8 +73,62 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
70
73
  readonly effectId: Schema.String;
71
74
  readonly error: Schema.String;
72
75
  }>;
76
+ 'effect.attempt.started': Schema.Struct<{
77
+ readonly effectId: Schema.String;
78
+ readonly attempt: Schema.Finite;
79
+ }>;
80
+ 'effect.queued': Schema.Struct<{
81
+ readonly effectId: Schema.String;
82
+ readonly attempt: Schema.Finite;
83
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
84
+ }>;
85
+ 'effect.dispatched': Schema.Struct<{
86
+ readonly effectId: Schema.String;
87
+ readonly attempt: Schema.Finite;
88
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
89
+ }>;
90
+ 'effect.worker.started': Schema.Struct<{
91
+ readonly effectId: Schema.String;
92
+ readonly attempt: Schema.Finite;
93
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
94
+ }>;
95
+ 'effect.heartbeat': Schema.Struct<{
96
+ readonly effectId: Schema.String;
97
+ readonly attempt: Schema.Finite;
98
+ readonly heartbeatAt: Schema.Finite;
99
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
100
+ }>;
101
+ 'effect.cancel.requested': Schema.Struct<{
102
+ readonly effectId: Schema.String;
103
+ readonly attempt: Schema.Finite;
104
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
105
+ }>;
106
+ 'effect.cancelled': Schema.Struct<{
107
+ readonly effectId: Schema.String;
108
+ readonly attempt: Schema.Finite;
109
+ }>;
110
+ 'effect.completed': Schema.Struct<{
111
+ readonly effectId: Schema.String;
112
+ readonly attempt: Schema.Finite;
113
+ }>;
114
+ 'effect.timed_out': Schema.Struct<{
115
+ readonly effectId: Schema.String;
116
+ readonly attempt: Schema.Finite;
117
+ readonly timeout: Schema.String;
118
+ }>;
119
+ 'effect.ambiguous': Schema.Struct<{
120
+ readonly effectId: Schema.String;
121
+ readonly attempt: Schema.Finite;
122
+ readonly error: Schema.String;
123
+ }>;
124
+ 'effect.retry.scheduled': Schema.Struct<{
125
+ readonly effectId: Schema.String;
126
+ readonly attempt: Schema.Finite;
127
+ readonly nextAttemptAt: Schema.Finite;
128
+ readonly error: Schema.String;
129
+ }>;
73
130
  'snapshot.taken': Schema.Struct<{
74
- readonly seq: Schema.Number;
131
+ readonly seq: Schema.Finite;
75
132
  readonly stateHash: Schema.String;
76
133
  readonly state: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
77
134
  }>;
@@ -81,7 +138,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
81
138
  }>;
82
139
  export type ProtocolEvent = EventsOfCatalog<typeof protocolCatalog>;
83
140
  export type ProtocolEventInput = EventInputOf<typeof protocolCatalog>;
84
- export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.thread.started', 'runtime.thread.completed', 'runtime.thread.failed', 'runtime.thread.cancelled', 'runtime.wait.registered', 'runtime.wait.satisfied', 'runtime.timer.set', 'runtime.timer.fired', 'runtime.effect.failed', 'runtime.snapshot.taken', 'runtime.signal.received'];
141
+ export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.run.cancelled', 'runtime.thread.started', 'runtime.thread.completed', 'runtime.thread.failed', 'runtime.thread.cancelled', 'runtime.thread.cancel.requested', 'runtime.wait.registered', 'runtime.wait.satisfied', 'runtime.timer.set', 'runtime.timer.fired', 'runtime.effect.failed', 'runtime.effect.attempt.started', 'runtime.effect.queued', 'runtime.effect.dispatched', 'runtime.effect.worker.started', 'runtime.effect.heartbeat', 'runtime.effect.cancel.requested', 'runtime.effect.cancelled', 'runtime.effect.completed', 'runtime.effect.timed_out', 'runtime.effect.ambiguous', 'runtime.effect.retry.scheduled', 'runtime.snapshot.taken', 'runtime.signal.received'];
85
142
  export type ProtocolEventType = (typeof PROTOCOL_TYPES)[number];
86
143
  export declare function isProtocolType(type: string): type is ProtocolEventType;
87
144
  export type RunStartedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['run.started']>;