@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
@@ -1,7 +1,9 @@
1
- import { type DefinitionInput, type DefinitionRef, type EventEnvelope, type EventInput, type JsonValue, type RunState } from '@swirls/looms/core';
1
+ import { Schema } from 'effect';
2
+ import { type DefinitionInput, type DefinitionRef, type EventEnvelope, type EventInput, type JsonValue, type RunState, type WorkerCallbackInput } from '@swirls/looms/core';
2
3
  export interface LoomsClientOptions {
3
4
  baseUrl?: string;
4
5
  fetch?: typeof fetch;
6
+ workerCallbackToken?: string;
5
7
  }
6
8
  export interface StartResult {
7
9
  runId: string;
@@ -16,42 +18,1216 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
16
18
  startRun: (args: {
17
19
  kind: string;
18
20
  definitionName: string;
21
+ definitionVersion?: string;
19
22
  input?: JsonValue;
20
23
  runId?: string;
21
- }) => Promise<StartResult>;
24
+ }) => Promise<{
25
+ readonly runId: string;
26
+ readonly threadId: string;
27
+ readonly state: {
28
+ readonly runId: string;
29
+ readonly status: "cancelled" | "completed" | "failed" | "running";
30
+ readonly rootThreadId: string | null;
31
+ readonly startIdentity: {
32
+ readonly kind: string;
33
+ readonly definitionName: string;
34
+ readonly definitionVersion: string;
35
+ readonly input: Schema.Json;
36
+ readonly requestedThreadId: string | null;
37
+ readonly idempotencyKey: string | null;
38
+ readonly rootThreadId: string;
39
+ } | null;
40
+ readonly threads: {
41
+ readonly [x: string]: {
42
+ readonly threadId: string;
43
+ readonly kind: string;
44
+ readonly definitionName: string;
45
+ readonly definitionVersion: string;
46
+ readonly parentThreadId: string | null;
47
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
48
+ readonly input: Schema.Json;
49
+ readonly output: Schema.Json;
50
+ readonly error: string | null;
51
+ readonly state: Schema.Json;
52
+ };
53
+ };
54
+ readonly waits: {
55
+ readonly [x: string]: {
56
+ readonly waitId: string;
57
+ readonly threadId: string;
58
+ readonly on: {
59
+ readonly type: string | readonly string[];
60
+ readonly match?: Schema.Json | undefined;
61
+ } | {
62
+ readonly timerAt: number;
63
+ };
64
+ readonly tag?: Schema.Json | undefined;
65
+ };
66
+ };
67
+ readonly outstandingEffects: readonly {
68
+ readonly effectId: string;
69
+ readonly threadId: string;
70
+ readonly causingSeq: number;
71
+ readonly causingEventId: string;
72
+ readonly effect: {
73
+ readonly type: "runtime.spawn";
74
+ readonly childThreadId: string;
75
+ readonly kind: string;
76
+ readonly definitionName: string;
77
+ readonly definitionVersion: string;
78
+ readonly input: Schema.Json;
79
+ } | {
80
+ readonly type: "runtime.wait";
81
+ readonly waitId: string;
82
+ readonly on: {
83
+ readonly type: string | readonly string[];
84
+ readonly match?: Schema.Json | undefined;
85
+ } | {
86
+ readonly timerAt: number;
87
+ };
88
+ readonly tag?: Schema.Json | undefined;
89
+ } | {
90
+ readonly type: "runtime.emit";
91
+ readonly event: {
92
+ readonly type: string;
93
+ readonly payload: Schema.Json;
94
+ readonly threadId?: string | null | undefined;
95
+ readonly parentThreadId?: string | null | undefined;
96
+ readonly causationId?: string | null | undefined;
97
+ readonly correlationId?: string | null | undefined;
98
+ readonly effectId?: string | null | undefined;
99
+ readonly origin?: {
100
+ readonly type: "thread";
101
+ readonly threadId: string;
102
+ } | {
103
+ readonly type: "external";
104
+ readonly actorId?: string | undefined;
105
+ } | {
106
+ readonly type: "system";
107
+ } | undefined;
108
+ readonly ephemeral?: boolean | undefined;
109
+ readonly id?: string | undefined;
110
+ readonly ts?: number | undefined;
111
+ readonly idempotencyKey?: string | null | undefined;
112
+ };
113
+ readonly tag?: string | undefined;
114
+ } | {
115
+ readonly type: "runtime.complete";
116
+ readonly output: Schema.Json;
117
+ } | {
118
+ readonly type: "runtime.fail";
119
+ readonly error: string;
120
+ } | {
121
+ readonly type: "runtime.cancel";
122
+ readonly threadId: string;
123
+ readonly tag?: string | undefined;
124
+ } | {
125
+ readonly type: string;
126
+ readonly input: Schema.Json;
127
+ readonly tag?: string | undefined;
128
+ };
129
+ }[];
130
+ readonly effectExecutions: {
131
+ readonly [x: string]: {
132
+ readonly effectId: string;
133
+ readonly attempt: number;
134
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
135
+ readonly nextAttemptAt: number | null;
136
+ readonly deadlineAt: number | null;
137
+ readonly startedAt: number | null;
138
+ readonly lastHeartbeatAt: number | null;
139
+ readonly lastError: string | null;
140
+ };
141
+ };
142
+ readonly completedEffectIds: readonly string[];
143
+ readonly processedIdempotencyKeys: readonly string[];
144
+ };
145
+ }>;
22
146
  /** Start a run from a definition object (agent, workflow, or your own kind). */
23
- start: <TDef extends DefinitionRef>(definition: TDef, input?: DefinitionInput<TDef>) => Promise<StartResult>;
147
+ start: <TDef extends DefinitionRef>(definition: TDef, input?: DefinitionInput<TDef>) => Promise<{
148
+ readonly runId: string;
149
+ readonly threadId: string;
150
+ readonly state: {
151
+ readonly runId: string;
152
+ readonly status: "cancelled" | "completed" | "failed" | "running";
153
+ readonly rootThreadId: string | null;
154
+ readonly startIdentity: {
155
+ readonly kind: string;
156
+ readonly definitionName: string;
157
+ readonly definitionVersion: string;
158
+ readonly input: Schema.Json;
159
+ readonly requestedThreadId: string | null;
160
+ readonly idempotencyKey: string | null;
161
+ readonly rootThreadId: string;
162
+ } | null;
163
+ readonly threads: {
164
+ readonly [x: string]: {
165
+ readonly threadId: string;
166
+ readonly kind: string;
167
+ readonly definitionName: string;
168
+ readonly definitionVersion: string;
169
+ readonly parentThreadId: string | null;
170
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
171
+ readonly input: Schema.Json;
172
+ readonly output: Schema.Json;
173
+ readonly error: string | null;
174
+ readonly state: Schema.Json;
175
+ };
176
+ };
177
+ readonly waits: {
178
+ readonly [x: string]: {
179
+ readonly waitId: string;
180
+ readonly threadId: string;
181
+ readonly on: {
182
+ readonly type: string | readonly string[];
183
+ readonly match?: Schema.Json | undefined;
184
+ } | {
185
+ readonly timerAt: number;
186
+ };
187
+ readonly tag?: Schema.Json | undefined;
188
+ };
189
+ };
190
+ readonly outstandingEffects: readonly {
191
+ readonly effectId: string;
192
+ readonly threadId: string;
193
+ readonly causingSeq: number;
194
+ readonly causingEventId: string;
195
+ readonly effect: {
196
+ readonly type: "runtime.spawn";
197
+ readonly childThreadId: string;
198
+ readonly kind: string;
199
+ readonly definitionName: string;
200
+ readonly definitionVersion: string;
201
+ readonly input: Schema.Json;
202
+ } | {
203
+ readonly type: "runtime.wait";
204
+ readonly waitId: string;
205
+ readonly on: {
206
+ readonly type: string | readonly string[];
207
+ readonly match?: Schema.Json | undefined;
208
+ } | {
209
+ readonly timerAt: number;
210
+ };
211
+ readonly tag?: Schema.Json | undefined;
212
+ } | {
213
+ readonly type: "runtime.emit";
214
+ readonly event: {
215
+ readonly type: string;
216
+ readonly payload: Schema.Json;
217
+ readonly threadId?: string | null | undefined;
218
+ readonly parentThreadId?: string | null | undefined;
219
+ readonly causationId?: string | null | undefined;
220
+ readonly correlationId?: string | null | undefined;
221
+ readonly effectId?: string | null | undefined;
222
+ readonly origin?: {
223
+ readonly type: "thread";
224
+ readonly threadId: string;
225
+ } | {
226
+ readonly type: "external";
227
+ readonly actorId?: string | undefined;
228
+ } | {
229
+ readonly type: "system";
230
+ } | undefined;
231
+ readonly ephemeral?: boolean | undefined;
232
+ readonly id?: string | undefined;
233
+ readonly ts?: number | undefined;
234
+ readonly idempotencyKey?: string | null | undefined;
235
+ };
236
+ readonly tag?: string | undefined;
237
+ } | {
238
+ readonly type: "runtime.complete";
239
+ readonly output: Schema.Json;
240
+ } | {
241
+ readonly type: "runtime.fail";
242
+ readonly error: string;
243
+ } | {
244
+ readonly type: "runtime.cancel";
245
+ readonly threadId: string;
246
+ readonly tag?: string | undefined;
247
+ } | {
248
+ readonly type: string;
249
+ readonly input: Schema.Json;
250
+ readonly tag?: string | undefined;
251
+ };
252
+ }[];
253
+ readonly effectExecutions: {
254
+ readonly [x: string]: {
255
+ readonly effectId: string;
256
+ readonly attempt: number;
257
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
258
+ readonly nextAttemptAt: number | null;
259
+ readonly deadlineAt: number | null;
260
+ readonly startedAt: number | null;
261
+ readonly lastHeartbeatAt: number | null;
262
+ readonly lastError: string | null;
263
+ };
264
+ };
265
+ readonly completedEffectIds: readonly string[];
266
+ readonly processedIdempotencyKeys: readonly string[];
267
+ };
268
+ }>;
24
269
  getRun: (runId: string) => Promise<{
25
- runId: string;
26
- state: RunState;
270
+ readonly runId: string;
271
+ readonly state: {
272
+ readonly runId: string;
273
+ readonly status: "cancelled" | "completed" | "failed" | "running";
274
+ readonly rootThreadId: string | null;
275
+ readonly startIdentity: {
276
+ readonly kind: string;
277
+ readonly definitionName: string;
278
+ readonly definitionVersion: string;
279
+ readonly input: Schema.Json;
280
+ readonly requestedThreadId: string | null;
281
+ readonly idempotencyKey: string | null;
282
+ readonly rootThreadId: string;
283
+ } | null;
284
+ readonly threads: {
285
+ readonly [x: string]: {
286
+ readonly threadId: string;
287
+ readonly kind: string;
288
+ readonly definitionName: string;
289
+ readonly definitionVersion: string;
290
+ readonly parentThreadId: string | null;
291
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
292
+ readonly input: Schema.Json;
293
+ readonly output: Schema.Json;
294
+ readonly error: string | null;
295
+ readonly state: Schema.Json;
296
+ };
297
+ };
298
+ readonly waits: {
299
+ readonly [x: string]: {
300
+ readonly waitId: string;
301
+ readonly threadId: string;
302
+ readonly on: {
303
+ readonly type: string | readonly string[];
304
+ readonly match?: Schema.Json | undefined;
305
+ } | {
306
+ readonly timerAt: number;
307
+ };
308
+ readonly tag?: Schema.Json | undefined;
309
+ };
310
+ };
311
+ readonly outstandingEffects: readonly {
312
+ readonly effectId: string;
313
+ readonly threadId: string;
314
+ readonly causingSeq: number;
315
+ readonly causingEventId: string;
316
+ readonly effect: {
317
+ readonly type: "runtime.spawn";
318
+ readonly childThreadId: string;
319
+ readonly kind: string;
320
+ readonly definitionName: string;
321
+ readonly definitionVersion: string;
322
+ readonly input: Schema.Json;
323
+ } | {
324
+ readonly type: "runtime.wait";
325
+ readonly waitId: string;
326
+ readonly on: {
327
+ readonly type: string | readonly string[];
328
+ readonly match?: Schema.Json | undefined;
329
+ } | {
330
+ readonly timerAt: number;
331
+ };
332
+ readonly tag?: Schema.Json | undefined;
333
+ } | {
334
+ readonly type: "runtime.emit";
335
+ readonly event: {
336
+ readonly type: string;
337
+ readonly payload: Schema.Json;
338
+ readonly threadId?: string | null | undefined;
339
+ readonly parentThreadId?: string | null | undefined;
340
+ readonly causationId?: string | null | undefined;
341
+ readonly correlationId?: string | null | undefined;
342
+ readonly effectId?: string | null | undefined;
343
+ readonly origin?: {
344
+ readonly type: "thread";
345
+ readonly threadId: string;
346
+ } | {
347
+ readonly type: "external";
348
+ readonly actorId?: string | undefined;
349
+ } | {
350
+ readonly type: "system";
351
+ } | undefined;
352
+ readonly ephemeral?: boolean | undefined;
353
+ readonly id?: string | undefined;
354
+ readonly ts?: number | undefined;
355
+ readonly idempotencyKey?: string | null | undefined;
356
+ };
357
+ readonly tag?: string | undefined;
358
+ } | {
359
+ readonly type: "runtime.complete";
360
+ readonly output: Schema.Json;
361
+ } | {
362
+ readonly type: "runtime.fail";
363
+ readonly error: string;
364
+ } | {
365
+ readonly type: "runtime.cancel";
366
+ readonly threadId: string;
367
+ readonly tag?: string | undefined;
368
+ } | {
369
+ readonly type: string;
370
+ readonly input: Schema.Json;
371
+ readonly tag?: string | undefined;
372
+ };
373
+ }[];
374
+ readonly effectExecutions: {
375
+ readonly [x: string]: {
376
+ readonly effectId: string;
377
+ readonly attempt: number;
378
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
379
+ readonly nextAttemptAt: number | null;
380
+ readonly deadlineAt: number | null;
381
+ readonly startedAt: number | null;
382
+ readonly lastHeartbeatAt: number | null;
383
+ readonly lastError: string | null;
384
+ };
385
+ };
386
+ readonly completedEffectIds: readonly string[];
387
+ readonly processedIdempotencyKeys: readonly string[];
388
+ };
27
389
  }>;
28
390
  getState: (runId: string) => Promise<{
29
- runId: string;
30
- state: RunState;
391
+ readonly runId: string;
392
+ readonly state: {
393
+ readonly runId: string;
394
+ readonly status: "cancelled" | "completed" | "failed" | "running";
395
+ readonly rootThreadId: string | null;
396
+ readonly startIdentity: {
397
+ readonly kind: string;
398
+ readonly definitionName: string;
399
+ readonly definitionVersion: string;
400
+ readonly input: Schema.Json;
401
+ readonly requestedThreadId: string | null;
402
+ readonly idempotencyKey: string | null;
403
+ readonly rootThreadId: string;
404
+ } | null;
405
+ readonly threads: {
406
+ readonly [x: string]: {
407
+ readonly threadId: string;
408
+ readonly kind: string;
409
+ readonly definitionName: string;
410
+ readonly definitionVersion: string;
411
+ readonly parentThreadId: string | null;
412
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
413
+ readonly input: Schema.Json;
414
+ readonly output: Schema.Json;
415
+ readonly error: string | null;
416
+ readonly state: Schema.Json;
417
+ };
418
+ };
419
+ readonly waits: {
420
+ readonly [x: string]: {
421
+ readonly waitId: string;
422
+ readonly threadId: string;
423
+ readonly on: {
424
+ readonly type: string | readonly string[];
425
+ readonly match?: Schema.Json | undefined;
426
+ } | {
427
+ readonly timerAt: number;
428
+ };
429
+ readonly tag?: Schema.Json | undefined;
430
+ };
431
+ };
432
+ readonly outstandingEffects: readonly {
433
+ readonly effectId: string;
434
+ readonly threadId: string;
435
+ readonly causingSeq: number;
436
+ readonly causingEventId: string;
437
+ readonly effect: {
438
+ readonly type: "runtime.spawn";
439
+ readonly childThreadId: string;
440
+ readonly kind: string;
441
+ readonly definitionName: string;
442
+ readonly definitionVersion: string;
443
+ readonly input: Schema.Json;
444
+ } | {
445
+ readonly type: "runtime.wait";
446
+ readonly waitId: string;
447
+ readonly on: {
448
+ readonly type: string | readonly string[];
449
+ readonly match?: Schema.Json | undefined;
450
+ } | {
451
+ readonly timerAt: number;
452
+ };
453
+ readonly tag?: Schema.Json | undefined;
454
+ } | {
455
+ readonly type: "runtime.emit";
456
+ readonly event: {
457
+ readonly type: string;
458
+ readonly payload: Schema.Json;
459
+ readonly threadId?: string | null | undefined;
460
+ readonly parentThreadId?: string | null | undefined;
461
+ readonly causationId?: string | null | undefined;
462
+ readonly correlationId?: string | null | undefined;
463
+ readonly effectId?: string | null | undefined;
464
+ readonly origin?: {
465
+ readonly type: "thread";
466
+ readonly threadId: string;
467
+ } | {
468
+ readonly type: "external";
469
+ readonly actorId?: string | undefined;
470
+ } | {
471
+ readonly type: "system";
472
+ } | undefined;
473
+ readonly ephemeral?: boolean | undefined;
474
+ readonly id?: string | undefined;
475
+ readonly ts?: number | undefined;
476
+ readonly idempotencyKey?: string | null | undefined;
477
+ };
478
+ readonly tag?: string | undefined;
479
+ } | {
480
+ readonly type: "runtime.complete";
481
+ readonly output: Schema.Json;
482
+ } | {
483
+ readonly type: "runtime.fail";
484
+ readonly error: string;
485
+ } | {
486
+ readonly type: "runtime.cancel";
487
+ readonly threadId: string;
488
+ readonly tag?: string | undefined;
489
+ } | {
490
+ readonly type: string;
491
+ readonly input: Schema.Json;
492
+ readonly tag?: string | undefined;
493
+ };
494
+ }[];
495
+ readonly effectExecutions: {
496
+ readonly [x: string]: {
497
+ readonly effectId: string;
498
+ readonly attempt: number;
499
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
500
+ readonly nextAttemptAt: number | null;
501
+ readonly deadlineAt: number | null;
502
+ readonly startedAt: number | null;
503
+ readonly lastHeartbeatAt: number | null;
504
+ readonly lastError: string | null;
505
+ };
506
+ };
507
+ readonly completedEffectIds: readonly string[];
508
+ readonly processedIdempotencyKeys: readonly string[];
509
+ };
31
510
  }>;
32
511
  getEvents: (runId: string, opts?: {
33
512
  fromSeq?: number;
34
513
  limit?: number;
35
514
  }) => Promise<{
36
- runId: string;
37
- events: EventEnvelope[];
515
+ readonly runId: string;
516
+ readonly events: readonly {
517
+ readonly id: string;
518
+ readonly runId: string;
519
+ readonly seq: number;
520
+ readonly ts: number;
521
+ readonly type: string;
522
+ readonly payload: Schema.Json;
523
+ readonly threadId: string | null;
524
+ readonly parentThreadId?: string | null | undefined;
525
+ readonly causationId?: string | null | undefined;
526
+ readonly correlationId?: string | null | undefined;
527
+ readonly effectId?: string | null | undefined;
528
+ readonly origin: {
529
+ readonly type: "thread";
530
+ readonly threadId: string;
531
+ } | {
532
+ readonly type: "external";
533
+ readonly actorId?: string | undefined;
534
+ } | {
535
+ readonly type: "system";
536
+ };
537
+ readonly ephemeral?: boolean | undefined;
538
+ readonly idempotencyKey?: string | null | undefined;
539
+ }[];
38
540
  }>;
39
541
  signal: (runId: string, events: ReadonlyArray<EventInput>) => Promise<{
40
- runId: string;
41
- state: RunState;
542
+ readonly runId: string;
543
+ readonly state: {
544
+ readonly runId: string;
545
+ readonly status: "cancelled" | "completed" | "failed" | "running";
546
+ readonly rootThreadId: string | null;
547
+ readonly startIdentity: {
548
+ readonly kind: string;
549
+ readonly definitionName: string;
550
+ readonly definitionVersion: string;
551
+ readonly input: Schema.Json;
552
+ readonly requestedThreadId: string | null;
553
+ readonly idempotencyKey: string | null;
554
+ readonly rootThreadId: string;
555
+ } | null;
556
+ readonly threads: {
557
+ readonly [x: string]: {
558
+ readonly threadId: string;
559
+ readonly kind: string;
560
+ readonly definitionName: string;
561
+ readonly definitionVersion: string;
562
+ readonly parentThreadId: string | null;
563
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
564
+ readonly input: Schema.Json;
565
+ readonly output: Schema.Json;
566
+ readonly error: string | null;
567
+ readonly state: Schema.Json;
568
+ };
569
+ };
570
+ readonly waits: {
571
+ readonly [x: string]: {
572
+ readonly waitId: string;
573
+ readonly threadId: string;
574
+ readonly on: {
575
+ readonly type: string | readonly string[];
576
+ readonly match?: Schema.Json | undefined;
577
+ } | {
578
+ readonly timerAt: number;
579
+ };
580
+ readonly tag?: Schema.Json | undefined;
581
+ };
582
+ };
583
+ readonly outstandingEffects: readonly {
584
+ readonly effectId: string;
585
+ readonly threadId: string;
586
+ readonly causingSeq: number;
587
+ readonly causingEventId: string;
588
+ readonly effect: {
589
+ readonly type: "runtime.spawn";
590
+ readonly childThreadId: string;
591
+ readonly kind: string;
592
+ readonly definitionName: string;
593
+ readonly definitionVersion: string;
594
+ readonly input: Schema.Json;
595
+ } | {
596
+ readonly type: "runtime.wait";
597
+ readonly waitId: string;
598
+ readonly on: {
599
+ readonly type: string | readonly string[];
600
+ readonly match?: Schema.Json | undefined;
601
+ } | {
602
+ readonly timerAt: number;
603
+ };
604
+ readonly tag?: Schema.Json | undefined;
605
+ } | {
606
+ readonly type: "runtime.emit";
607
+ readonly event: {
608
+ readonly type: string;
609
+ readonly payload: Schema.Json;
610
+ readonly threadId?: string | null | undefined;
611
+ readonly parentThreadId?: string | null | undefined;
612
+ readonly causationId?: string | null | undefined;
613
+ readonly correlationId?: string | null | undefined;
614
+ readonly effectId?: string | null | undefined;
615
+ readonly origin?: {
616
+ readonly type: "thread";
617
+ readonly threadId: string;
618
+ } | {
619
+ readonly type: "external";
620
+ readonly actorId?: string | undefined;
621
+ } | {
622
+ readonly type: "system";
623
+ } | undefined;
624
+ readonly ephemeral?: boolean | undefined;
625
+ readonly id?: string | undefined;
626
+ readonly ts?: number | undefined;
627
+ readonly idempotencyKey?: string | null | undefined;
628
+ };
629
+ readonly tag?: string | undefined;
630
+ } | {
631
+ readonly type: "runtime.complete";
632
+ readonly output: Schema.Json;
633
+ } | {
634
+ readonly type: "runtime.fail";
635
+ readonly error: string;
636
+ } | {
637
+ readonly type: "runtime.cancel";
638
+ readonly threadId: string;
639
+ readonly tag?: string | undefined;
640
+ } | {
641
+ readonly type: string;
642
+ readonly input: Schema.Json;
643
+ readonly tag?: string | undefined;
644
+ };
645
+ }[];
646
+ readonly effectExecutions: {
647
+ readonly [x: string]: {
648
+ readonly effectId: string;
649
+ readonly attempt: number;
650
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
651
+ readonly nextAttemptAt: number | null;
652
+ readonly deadlineAt: number | null;
653
+ readonly startedAt: number | null;
654
+ readonly lastHeartbeatAt: number | null;
655
+ readonly lastError: string | null;
656
+ };
657
+ };
658
+ readonly completedEffectIds: readonly string[];
659
+ readonly processedIdempotencyKeys: readonly string[];
660
+ };
42
661
  }>;
43
662
  wake: (runId: string) => Promise<{
44
- runId: string;
45
- state: RunState;
663
+ readonly runId: string;
664
+ readonly state: {
665
+ readonly runId: string;
666
+ readonly status: "cancelled" | "completed" | "failed" | "running";
667
+ readonly rootThreadId: string | null;
668
+ readonly startIdentity: {
669
+ readonly kind: string;
670
+ readonly definitionName: string;
671
+ readonly definitionVersion: string;
672
+ readonly input: Schema.Json;
673
+ readonly requestedThreadId: string | null;
674
+ readonly idempotencyKey: string | null;
675
+ readonly rootThreadId: string;
676
+ } | null;
677
+ readonly threads: {
678
+ readonly [x: string]: {
679
+ readonly threadId: string;
680
+ readonly kind: string;
681
+ readonly definitionName: string;
682
+ readonly definitionVersion: string;
683
+ readonly parentThreadId: string | null;
684
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
685
+ readonly input: Schema.Json;
686
+ readonly output: Schema.Json;
687
+ readonly error: string | null;
688
+ readonly state: Schema.Json;
689
+ };
690
+ };
691
+ readonly waits: {
692
+ readonly [x: string]: {
693
+ readonly waitId: string;
694
+ readonly threadId: string;
695
+ readonly on: {
696
+ readonly type: string | readonly string[];
697
+ readonly match?: Schema.Json | undefined;
698
+ } | {
699
+ readonly timerAt: number;
700
+ };
701
+ readonly tag?: Schema.Json | undefined;
702
+ };
703
+ };
704
+ readonly outstandingEffects: readonly {
705
+ readonly effectId: string;
706
+ readonly threadId: string;
707
+ readonly causingSeq: number;
708
+ readonly causingEventId: string;
709
+ readonly effect: {
710
+ readonly type: "runtime.spawn";
711
+ readonly childThreadId: string;
712
+ readonly kind: string;
713
+ readonly definitionName: string;
714
+ readonly definitionVersion: string;
715
+ readonly input: Schema.Json;
716
+ } | {
717
+ readonly type: "runtime.wait";
718
+ readonly waitId: string;
719
+ readonly on: {
720
+ readonly type: string | readonly string[];
721
+ readonly match?: Schema.Json | undefined;
722
+ } | {
723
+ readonly timerAt: number;
724
+ };
725
+ readonly tag?: Schema.Json | undefined;
726
+ } | {
727
+ readonly type: "runtime.emit";
728
+ readonly event: {
729
+ readonly type: string;
730
+ readonly payload: Schema.Json;
731
+ readonly threadId?: string | null | undefined;
732
+ readonly parentThreadId?: string | null | undefined;
733
+ readonly causationId?: string | null | undefined;
734
+ readonly correlationId?: string | null | undefined;
735
+ readonly effectId?: string | null | undefined;
736
+ readonly origin?: {
737
+ readonly type: "thread";
738
+ readonly threadId: string;
739
+ } | {
740
+ readonly type: "external";
741
+ readonly actorId?: string | undefined;
742
+ } | {
743
+ readonly type: "system";
744
+ } | undefined;
745
+ readonly ephemeral?: boolean | undefined;
746
+ readonly id?: string | undefined;
747
+ readonly ts?: number | undefined;
748
+ readonly idempotencyKey?: string | null | undefined;
749
+ };
750
+ readonly tag?: string | undefined;
751
+ } | {
752
+ readonly type: "runtime.complete";
753
+ readonly output: Schema.Json;
754
+ } | {
755
+ readonly type: "runtime.fail";
756
+ readonly error: string;
757
+ } | {
758
+ readonly type: "runtime.cancel";
759
+ readonly threadId: string;
760
+ readonly tag?: string | undefined;
761
+ } | {
762
+ readonly type: string;
763
+ readonly input: Schema.Json;
764
+ readonly tag?: string | undefined;
765
+ };
766
+ }[];
767
+ readonly effectExecutions: {
768
+ readonly [x: string]: {
769
+ readonly effectId: string;
770
+ readonly attempt: number;
771
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
772
+ readonly nextAttemptAt: number | null;
773
+ readonly deadlineAt: number | null;
774
+ readonly startedAt: number | null;
775
+ readonly lastHeartbeatAt: number | null;
776
+ readonly lastError: string | null;
777
+ };
778
+ };
779
+ readonly completedEffectIds: readonly string[];
780
+ readonly processedIdempotencyKeys: readonly string[];
781
+ };
782
+ }>;
783
+ workerCallback: (runId: string, input: WorkerCallbackInput) => Promise<{
784
+ readonly runId: string;
785
+ readonly state: {
786
+ readonly runId: string;
787
+ readonly status: "cancelled" | "completed" | "failed" | "running";
788
+ readonly rootThreadId: string | null;
789
+ readonly startIdentity: {
790
+ readonly kind: string;
791
+ readonly definitionName: string;
792
+ readonly definitionVersion: string;
793
+ readonly input: Schema.Json;
794
+ readonly requestedThreadId: string | null;
795
+ readonly idempotencyKey: string | null;
796
+ readonly rootThreadId: string;
797
+ } | null;
798
+ readonly threads: {
799
+ readonly [x: string]: {
800
+ readonly threadId: string;
801
+ readonly kind: string;
802
+ readonly definitionName: string;
803
+ readonly definitionVersion: string;
804
+ readonly parentThreadId: string | null;
805
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
806
+ readonly input: Schema.Json;
807
+ readonly output: Schema.Json;
808
+ readonly error: string | null;
809
+ readonly state: Schema.Json;
810
+ };
811
+ };
812
+ readonly waits: {
813
+ readonly [x: string]: {
814
+ readonly waitId: string;
815
+ readonly threadId: string;
816
+ readonly on: {
817
+ readonly type: string | readonly string[];
818
+ readonly match?: Schema.Json | undefined;
819
+ } | {
820
+ readonly timerAt: number;
821
+ };
822
+ readonly tag?: Schema.Json | undefined;
823
+ };
824
+ };
825
+ readonly outstandingEffects: readonly {
826
+ readonly effectId: string;
827
+ readonly threadId: string;
828
+ readonly causingSeq: number;
829
+ readonly causingEventId: string;
830
+ readonly effect: {
831
+ readonly type: "runtime.spawn";
832
+ readonly childThreadId: string;
833
+ readonly kind: string;
834
+ readonly definitionName: string;
835
+ readonly definitionVersion: string;
836
+ readonly input: Schema.Json;
837
+ } | {
838
+ readonly type: "runtime.wait";
839
+ readonly waitId: string;
840
+ readonly on: {
841
+ readonly type: string | readonly string[];
842
+ readonly match?: Schema.Json | undefined;
843
+ } | {
844
+ readonly timerAt: number;
845
+ };
846
+ readonly tag?: Schema.Json | undefined;
847
+ } | {
848
+ readonly type: "runtime.emit";
849
+ readonly event: {
850
+ readonly type: string;
851
+ readonly payload: Schema.Json;
852
+ readonly threadId?: string | null | undefined;
853
+ readonly parentThreadId?: string | null | undefined;
854
+ readonly causationId?: string | null | undefined;
855
+ readonly correlationId?: string | null | undefined;
856
+ readonly effectId?: string | null | undefined;
857
+ readonly origin?: {
858
+ readonly type: "thread";
859
+ readonly threadId: string;
860
+ } | {
861
+ readonly type: "external";
862
+ readonly actorId?: string | undefined;
863
+ } | {
864
+ readonly type: "system";
865
+ } | undefined;
866
+ readonly ephemeral?: boolean | undefined;
867
+ readonly id?: string | undefined;
868
+ readonly ts?: number | undefined;
869
+ readonly idempotencyKey?: string | null | undefined;
870
+ };
871
+ readonly tag?: string | undefined;
872
+ } | {
873
+ readonly type: "runtime.complete";
874
+ readonly output: Schema.Json;
875
+ } | {
876
+ readonly type: "runtime.fail";
877
+ readonly error: string;
878
+ } | {
879
+ readonly type: "runtime.cancel";
880
+ readonly threadId: string;
881
+ readonly tag?: string | undefined;
882
+ } | {
883
+ readonly type: string;
884
+ readonly input: Schema.Json;
885
+ readonly tag?: string | undefined;
886
+ };
887
+ }[];
888
+ readonly effectExecutions: {
889
+ readonly [x: string]: {
890
+ readonly effectId: string;
891
+ readonly attempt: number;
892
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
893
+ readonly nextAttemptAt: number | null;
894
+ readonly deadlineAt: number | null;
895
+ readonly startedAt: number | null;
896
+ readonly lastHeartbeatAt: number | null;
897
+ readonly lastError: string | null;
898
+ };
899
+ };
900
+ readonly completedEffectIds: readonly string[];
901
+ readonly processedIdempotencyKeys: readonly string[];
902
+ };
46
903
  }>;
47
904
  replayTo: (runId: string, seq: number) => Promise<{
48
- runId: string;
49
- step: unknown;
905
+ readonly runId: string;
906
+ readonly step: {
907
+ readonly seq: number;
908
+ readonly event: {
909
+ readonly id: string;
910
+ readonly runId: string;
911
+ readonly seq: number;
912
+ readonly ts: number;
913
+ readonly type: string;
914
+ readonly payload: Schema.Json;
915
+ readonly threadId: string | null;
916
+ readonly parentThreadId?: string | null | undefined;
917
+ readonly causationId?: string | null | undefined;
918
+ readonly correlationId?: string | null | undefined;
919
+ readonly effectId?: string | null | undefined;
920
+ readonly origin: {
921
+ readonly type: "thread";
922
+ readonly threadId: string;
923
+ } | {
924
+ readonly type: "external";
925
+ readonly actorId?: string | undefined;
926
+ } | {
927
+ readonly type: "system";
928
+ };
929
+ readonly ephemeral?: boolean | undefined;
930
+ readonly idempotencyKey?: string | null | undefined;
931
+ };
932
+ readonly before: {
933
+ readonly runId: string;
934
+ readonly status: "cancelled" | "completed" | "failed" | "running";
935
+ readonly rootThreadId: string | null;
936
+ readonly startIdentity: {
937
+ readonly kind: string;
938
+ readonly definitionName: string;
939
+ readonly definitionVersion: string;
940
+ readonly input: Schema.Json;
941
+ readonly requestedThreadId: string | null;
942
+ readonly idempotencyKey: string | null;
943
+ readonly rootThreadId: string;
944
+ } | null;
945
+ readonly threads: {
946
+ readonly [x: string]: {
947
+ readonly threadId: string;
948
+ readonly kind: string;
949
+ readonly definitionName: string;
950
+ readonly definitionVersion: string;
951
+ readonly parentThreadId: string | null;
952
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
953
+ readonly input: Schema.Json;
954
+ readonly output: Schema.Json;
955
+ readonly error: string | null;
956
+ readonly state: Schema.Json;
957
+ };
958
+ };
959
+ readonly waits: {
960
+ readonly [x: string]: {
961
+ readonly waitId: string;
962
+ readonly threadId: string;
963
+ readonly on: {
964
+ readonly type: string | readonly string[];
965
+ readonly match?: Schema.Json | undefined;
966
+ } | {
967
+ readonly timerAt: number;
968
+ };
969
+ readonly tag?: Schema.Json | undefined;
970
+ };
971
+ };
972
+ readonly outstandingEffects: readonly {
973
+ readonly effectId: string;
974
+ readonly threadId: string;
975
+ readonly causingSeq: number;
976
+ readonly causingEventId: string;
977
+ readonly effect: {
978
+ readonly type: "runtime.spawn";
979
+ readonly childThreadId: string;
980
+ readonly kind: string;
981
+ readonly definitionName: string;
982
+ readonly definitionVersion: string;
983
+ readonly input: Schema.Json;
984
+ } | {
985
+ readonly type: "runtime.wait";
986
+ readonly waitId: string;
987
+ readonly on: {
988
+ readonly type: string | readonly string[];
989
+ readonly match?: Schema.Json | undefined;
990
+ } | {
991
+ readonly timerAt: number;
992
+ };
993
+ readonly tag?: Schema.Json | undefined;
994
+ } | {
995
+ readonly type: "runtime.emit";
996
+ readonly event: {
997
+ readonly type: string;
998
+ readonly payload: Schema.Json;
999
+ readonly threadId?: string | null | undefined;
1000
+ readonly parentThreadId?: string | null | undefined;
1001
+ readonly causationId?: string | null | undefined;
1002
+ readonly correlationId?: string | null | undefined;
1003
+ readonly effectId?: string | null | undefined;
1004
+ readonly origin?: {
1005
+ readonly type: "thread";
1006
+ readonly threadId: string;
1007
+ } | {
1008
+ readonly type: "external";
1009
+ readonly actorId?: string | undefined;
1010
+ } | {
1011
+ readonly type: "system";
1012
+ } | undefined;
1013
+ readonly ephemeral?: boolean | undefined;
1014
+ readonly id?: string | undefined;
1015
+ readonly ts?: number | undefined;
1016
+ readonly idempotencyKey?: string | null | undefined;
1017
+ };
1018
+ readonly tag?: string | undefined;
1019
+ } | {
1020
+ readonly type: "runtime.complete";
1021
+ readonly output: Schema.Json;
1022
+ } | {
1023
+ readonly type: "runtime.fail";
1024
+ readonly error: string;
1025
+ } | {
1026
+ readonly type: "runtime.cancel";
1027
+ readonly threadId: string;
1028
+ readonly tag?: string | undefined;
1029
+ } | {
1030
+ readonly type: string;
1031
+ readonly input: Schema.Json;
1032
+ readonly tag?: string | undefined;
1033
+ };
1034
+ }[];
1035
+ readonly effectExecutions: {
1036
+ readonly [x: string]: {
1037
+ readonly effectId: string;
1038
+ readonly attempt: number;
1039
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
1040
+ readonly nextAttemptAt: number | null;
1041
+ readonly deadlineAt: number | null;
1042
+ readonly startedAt: number | null;
1043
+ readonly lastHeartbeatAt: number | null;
1044
+ readonly lastError: string | null;
1045
+ };
1046
+ };
1047
+ readonly completedEffectIds: readonly string[];
1048
+ readonly processedIdempotencyKeys: readonly string[];
1049
+ };
1050
+ readonly after: {
1051
+ readonly runId: string;
1052
+ readonly status: "cancelled" | "completed" | "failed" | "running";
1053
+ readonly rootThreadId: string | null;
1054
+ readonly startIdentity: {
1055
+ readonly kind: string;
1056
+ readonly definitionName: string;
1057
+ readonly definitionVersion: string;
1058
+ readonly input: Schema.Json;
1059
+ readonly requestedThreadId: string | null;
1060
+ readonly idempotencyKey: string | null;
1061
+ readonly rootThreadId: string;
1062
+ } | null;
1063
+ readonly threads: {
1064
+ readonly [x: string]: {
1065
+ readonly threadId: string;
1066
+ readonly kind: string;
1067
+ readonly definitionName: string;
1068
+ readonly definitionVersion: string;
1069
+ readonly parentThreadId: string | null;
1070
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
1071
+ readonly input: Schema.Json;
1072
+ readonly output: Schema.Json;
1073
+ readonly error: string | null;
1074
+ readonly state: Schema.Json;
1075
+ };
1076
+ };
1077
+ readonly waits: {
1078
+ readonly [x: string]: {
1079
+ readonly waitId: string;
1080
+ readonly threadId: string;
1081
+ readonly on: {
1082
+ readonly type: string | readonly string[];
1083
+ readonly match?: Schema.Json | undefined;
1084
+ } | {
1085
+ readonly timerAt: number;
1086
+ };
1087
+ readonly tag?: Schema.Json | undefined;
1088
+ };
1089
+ };
1090
+ readonly outstandingEffects: readonly {
1091
+ readonly effectId: string;
1092
+ readonly threadId: string;
1093
+ readonly causingSeq: number;
1094
+ readonly causingEventId: string;
1095
+ readonly effect: {
1096
+ readonly type: "runtime.spawn";
1097
+ readonly childThreadId: string;
1098
+ readonly kind: string;
1099
+ readonly definitionName: string;
1100
+ readonly definitionVersion: string;
1101
+ readonly input: Schema.Json;
1102
+ } | {
1103
+ readonly type: "runtime.wait";
1104
+ readonly waitId: string;
1105
+ readonly on: {
1106
+ readonly type: string | readonly string[];
1107
+ readonly match?: Schema.Json | undefined;
1108
+ } | {
1109
+ readonly timerAt: number;
1110
+ };
1111
+ readonly tag?: Schema.Json | undefined;
1112
+ } | {
1113
+ readonly type: "runtime.emit";
1114
+ readonly event: {
1115
+ readonly type: string;
1116
+ readonly payload: Schema.Json;
1117
+ readonly threadId?: string | null | undefined;
1118
+ readonly parentThreadId?: string | null | undefined;
1119
+ readonly causationId?: string | null | undefined;
1120
+ readonly correlationId?: string | null | undefined;
1121
+ readonly effectId?: string | null | undefined;
1122
+ readonly origin?: {
1123
+ readonly type: "thread";
1124
+ readonly threadId: string;
1125
+ } | {
1126
+ readonly type: "external";
1127
+ readonly actorId?: string | undefined;
1128
+ } | {
1129
+ readonly type: "system";
1130
+ } | undefined;
1131
+ readonly ephemeral?: boolean | undefined;
1132
+ readonly id?: string | undefined;
1133
+ readonly ts?: number | undefined;
1134
+ readonly idempotencyKey?: string | null | undefined;
1135
+ };
1136
+ readonly tag?: string | undefined;
1137
+ } | {
1138
+ readonly type: "runtime.complete";
1139
+ readonly output: Schema.Json;
1140
+ } | {
1141
+ readonly type: "runtime.fail";
1142
+ readonly error: string;
1143
+ } | {
1144
+ readonly type: "runtime.cancel";
1145
+ readonly threadId: string;
1146
+ readonly tag?: string | undefined;
1147
+ } | {
1148
+ readonly type: string;
1149
+ readonly input: Schema.Json;
1150
+ readonly tag?: string | undefined;
1151
+ };
1152
+ }[];
1153
+ readonly effectExecutions: {
1154
+ readonly [x: string]: {
1155
+ readonly effectId: string;
1156
+ readonly attempt: number;
1157
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
1158
+ readonly nextAttemptAt: number | null;
1159
+ readonly deadlineAt: number | null;
1160
+ readonly startedAt: number | null;
1161
+ readonly lastHeartbeatAt: number | null;
1162
+ readonly lastError: string | null;
1163
+ };
1164
+ };
1165
+ readonly completedEffectIds: readonly string[];
1166
+ readonly processedIdempotencyKeys: readonly string[];
1167
+ };
1168
+ readonly effects: readonly ({
1169
+ readonly type: "runtime.spawn";
1170
+ readonly childThreadId: string;
1171
+ readonly kind: string;
1172
+ readonly definitionName: string;
1173
+ readonly definitionVersion: string;
1174
+ readonly input: Schema.Json;
1175
+ } | {
1176
+ readonly type: "runtime.wait";
1177
+ readonly waitId: string;
1178
+ readonly on: {
1179
+ readonly type: string | readonly string[];
1180
+ readonly match?: Schema.Json | undefined;
1181
+ } | {
1182
+ readonly timerAt: number;
1183
+ };
1184
+ readonly tag?: Schema.Json | undefined;
1185
+ } | {
1186
+ readonly type: "runtime.emit";
1187
+ readonly event: {
1188
+ readonly type: string;
1189
+ readonly payload: Schema.Json;
1190
+ readonly threadId?: string | null | undefined;
1191
+ readonly parentThreadId?: string | null | undefined;
1192
+ readonly causationId?: string | null | undefined;
1193
+ readonly correlationId?: string | null | undefined;
1194
+ readonly effectId?: string | null | undefined;
1195
+ readonly origin?: {
1196
+ readonly type: "thread";
1197
+ readonly threadId: string;
1198
+ } | {
1199
+ readonly type: "external";
1200
+ readonly actorId?: string | undefined;
1201
+ } | {
1202
+ readonly type: "system";
1203
+ } | undefined;
1204
+ readonly ephemeral?: boolean | undefined;
1205
+ readonly id?: string | undefined;
1206
+ readonly ts?: number | undefined;
1207
+ readonly idempotencyKey?: string | null | undefined;
1208
+ };
1209
+ readonly tag?: string | undefined;
1210
+ } | {
1211
+ readonly type: "runtime.complete";
1212
+ readonly output: Schema.Json;
1213
+ } | {
1214
+ readonly type: "runtime.fail";
1215
+ readonly error: string;
1216
+ } | {
1217
+ readonly type: "runtime.cancel";
1218
+ readonly threadId: string;
1219
+ readonly tag?: string | undefined;
1220
+ } | {
1221
+ readonly type: string;
1222
+ readonly input: Schema.Json;
1223
+ readonly tag?: string | undefined;
1224
+ })[];
1225
+ } | null;
50
1226
  }>;
51
1227
  project: (runId: string, name: string) => Promise<{
52
- runId: string;
53
- name: string;
54
- value: unknown;
1228
+ readonly runId: string;
1229
+ readonly name: string;
1230
+ readonly value: unknown;
55
1231
  }>;
56
1232
  subscribeEvents: (runId: string, onEvent: (event: EventEnvelope) => void, reconnectDelayMs?: number) => () => void;
57
1233
  /**
@@ -61,6 +1237,7 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
61
1237
  streamRun: (args: {
62
1238
  kind: string;
63
1239
  definitionName: string;
1240
+ definitionVersion?: string;
64
1241
  input?: JsonValue;
65
1242
  runId?: string;
66
1243
  }) => StreamHandle;