@swirls/looms 0.3.0 → 0.5.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 (253) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/actor/cell.d.ts +21 -2
  3. package/dist/actor/cell.js +15 -3
  4. package/dist/actor/host.d.ts +10 -2
  5. package/dist/actor/host.js +27 -4
  6. package/dist/actor/index.d.ts +2 -1
  7. package/dist/actor/index.js +1 -1
  8. package/dist/actor/routing.d.ts +3 -0
  9. package/dist/actor/routing.js +13 -2
  10. package/dist/agent/debugger/agent-chat.js +3 -30
  11. package/dist/agent/debugger/streaming-text.d.ts +6 -0
  12. package/dist/agent/debugger/streaming-text.js +33 -0
  13. package/dist/agent/definitions-store.d.ts +1 -1
  14. package/dist/agent/definitions-store.js +1 -1
  15. package/dist/agent/definitions.d.ts +48 -0
  16. package/dist/agent/definitions.js +44 -0
  17. package/dist/agent/effects.d.ts +184 -0
  18. package/dist/agent/effects.js +172 -40
  19. package/dist/agent/events.d.ts +89 -0
  20. package/dist/agent/events.js +25 -0
  21. package/dist/agent/module.d.ts +819 -407
  22. package/dist/agent/module.js +5 -1
  23. package/dist/agent/scope.d.ts +88 -0
  24. package/dist/agent/threads.js +39 -3
  25. package/dist/agent/types.d.ts +4 -0
  26. package/dist/approval/effects.d.ts +40 -0
  27. package/dist/approval/module.d.ts +80 -0
  28. package/dist/client/client.d.ts +468 -119
  29. package/dist/client/client.js +214 -21
  30. package/dist/client/index.d.ts +1 -1
  31. package/dist/client/sse.d.ts +1 -1
  32. package/dist/client/sse.js +2 -2
  33. package/dist/cloudflare/durable-object.d.ts +66 -2
  34. package/dist/cloudflare/durable-object.js +96 -1
  35. package/dist/cloudflare/event-store.d.ts +7 -3
  36. package/dist/cloudflare/event-store.js +16 -3
  37. package/dist/cloudflare/index.d.ts +7 -1
  38. package/dist/cloudflare/index.js +7 -1
  39. package/dist/cloudflare/memory-queue.d.ts +18 -0
  40. package/dist/cloudflare/memory-queue.js +53 -0
  41. package/dist/cloudflare/queue-consumer.d.ts +52 -0
  42. package/dist/cloudflare/queue-consumer.js +102 -0
  43. package/dist/cloudflare/queue-message.d.ts +31 -0
  44. package/dist/cloudflare/queue-message.js +33 -0
  45. package/dist/cloudflare/queue-pull.d.ts +62 -0
  46. package/dist/cloudflare/queue-pull.js +130 -0
  47. package/dist/cloudflare/queue-worker.d.ts +39 -0
  48. package/dist/cloudflare/queue-worker.js +62 -0
  49. package/dist/cloudflare/r2-blob-store.d.ts +33 -0
  50. package/dist/cloudflare/r2-blob-store.js +60 -0
  51. package/dist/cloudflare/router.d.ts +4 -1
  52. package/dist/cloudflare/router.js +8 -3
  53. package/dist/cloudflare/websocket.d.ts +27 -0
  54. package/dist/cloudflare/websocket.js +215 -0
  55. package/dist/core/attempts.d.ts +8 -0
  56. package/dist/core/attempts.js +27 -0
  57. package/dist/core/blob-offload.d.ts +21 -0
  58. package/dist/core/blob-offload.js +143 -0
  59. package/dist/core/blob-store.d.ts +45 -0
  60. package/dist/core/blob-store.js +164 -0
  61. package/dist/core/blobs.d.ts +37 -0
  62. package/dist/core/blobs.js +160 -0
  63. package/dist/core/definition-resolver.d.ts +40 -0
  64. package/dist/core/definition-resolver.js +129 -0
  65. package/dist/core/definition-store.d.ts +6 -0
  66. package/dist/core/definition-store.js +37 -1
  67. package/dist/core/effects.d.ts +86 -3
  68. package/dist/core/effects.js +99 -3
  69. package/dist/core/envelope.d.ts +9 -0
  70. package/dist/core/envelope.js +4 -0
  71. package/dist/core/event-codec.js +3 -0
  72. package/dist/core/fold.js +83 -1
  73. package/dist/core/ids.d.ts +2 -0
  74. package/dist/core/ids.js +4 -0
  75. package/dist/core/index.d.ts +10 -0
  76. package/dist/core/index.js +9 -0
  77. package/dist/core/launcher.d.ts +97 -0
  78. package/dist/core/launcher.js +67 -0
  79. package/dist/core/module-scope.d.ts +7 -3
  80. package/dist/core/module-scope.js +3 -0
  81. package/dist/core/module.d.ts +10 -0
  82. package/dist/core/projection.d.ts +5 -4
  83. package/dist/core/projection.js +4 -0
  84. package/dist/core/protocol.d.ts +36 -1
  85. package/dist/core/protocol.js +35 -0
  86. package/dist/core/published.d.ts +2 -0
  87. package/dist/core/published.js +4 -1
  88. package/dist/{react → core}/register.d.ts +9 -8
  89. package/dist/core/replay.d.ts +96 -0
  90. package/dist/core/run-context.d.ts +33 -0
  91. package/dist/core/run-context.js +23 -0
  92. package/dist/core/sqlite-store.js +57 -5
  93. package/dist/core/state.d.ts +60 -0
  94. package/dist/core/state.js +19 -0
  95. package/dist/core/store.d.ts +6 -0
  96. package/dist/core/store.js +7 -0
  97. package/dist/core/subscription.d.ts +97 -0
  98. package/dist/core/subscription.js +224 -0
  99. package/dist/core/thread.d.ts +7 -0
  100. package/dist/core/thread.js +1 -0
  101. package/dist/core/trace.d.ts +21 -0
  102. package/dist/core/trace.js +45 -0
  103. package/dist/core/worker-callback.d.ts +25 -1
  104. package/dist/debugger/app/assets/{index-CgDzWJg7.css → index-B7GdT1UA.css} +1 -1
  105. package/dist/debugger/app/assets/index-C31SnCuN.js +22 -0
  106. package/dist/debugger/app/assets/routes-DPA3O5AF.js +47 -0
  107. package/dist/debugger/app/index.html +2 -2
  108. package/dist/debugger/components/event-inspector.d.ts +3 -1
  109. package/dist/debugger/components/event-inspector.js +25 -4
  110. package/dist/debugger/components/event-stream.d.ts +4 -1
  111. package/dist/debugger/components/event-stream.js +2 -2
  112. package/dist/debugger/components/run-tree.d.ts +5 -2
  113. package/dist/debugger/components/run-tree.js +10 -4
  114. package/dist/debugger/context.d.ts +8 -1
  115. package/dist/debugger/context.js +15 -3
  116. package/dist/debugger/events/protocol-summarize.js +18 -3
  117. package/dist/debugger/index.d.ts +1 -1
  118. package/dist/debugger/index.js +1 -1
  119. package/dist/debugger/shell/debugger-shell.js +1 -1
  120. package/dist/debugger/shell/events-pane.js +4 -3
  121. package/dist/debugger/styles.css +1 -0
  122. package/dist/evaluator/definitions-store.d.ts +3 -4
  123. package/dist/evaluator/definitions-store.js +3 -3
  124. package/dist/evaluator/definitions.d.ts +4 -1
  125. package/dist/evaluator/definitions.js +5 -2
  126. package/dist/evaluator/effects.d.ts +41 -0
  127. package/dist/evaluator/effects.js +6 -2
  128. package/dist/evaluator/module.d.ts +84 -0
  129. package/dist/evaluator/module.js +7 -3
  130. package/dist/evaluator/threads.d.ts +2 -0
  131. package/dist/evaluator/threads.js +4 -0
  132. package/dist/projectors/event-log.d.ts +87 -0
  133. package/dist/projectors/event-log.js +396 -0
  134. package/dist/projectors/index-model.d.ts +12 -0
  135. package/dist/projectors/index-model.js +12 -3
  136. package/dist/projectors/memory.js +7 -0
  137. package/dist/projectors/postgres.d.ts +1 -0
  138. package/dist/projectors/postgres.js +32 -15
  139. package/dist/projectors/schema.d.ts +5 -0
  140. package/dist/projectors/schema.js +26 -1
  141. package/dist/projectors/sqlite.js +47 -19
  142. package/dist/projectors/with-projectors.d.ts +7 -1
  143. package/dist/projectors/with-projectors.js +13 -3
  144. package/dist/react/derived.d.ts +26 -8
  145. package/dist/react/derived.js +23 -26
  146. package/dist/react/index.d.ts +3 -3
  147. package/dist/react/index.js +2 -2
  148. package/dist/react/materialize.js +5 -1
  149. package/dist/react/react.d.ts +16 -9
  150. package/dist/react/react.js +47 -23
  151. package/dist/react/store.d.ts +14 -6
  152. package/dist/react/store.js +104 -12
  153. package/dist/react/tables.d.ts +4 -1
  154. package/dist/runtime/cancellation.d.ts +2 -1
  155. package/dist/runtime/cancellation.js +35 -2
  156. package/dist/runtime/child-run.d.ts +10 -0
  157. package/dist/runtime/child-run.js +58 -0
  158. package/dist/runtime/deadline-transition-planner.js +11 -2
  159. package/dist/runtime/dispatch-effect.d.ts +2 -2
  160. package/dist/runtime/dispatch-effect.js +43 -19
  161. package/dist/runtime/errors.d.ts +14 -1
  162. package/dist/runtime/errors.js +10 -0
  163. package/dist/runtime/filesystem-blob-store.d.ts +6 -0
  164. package/dist/runtime/filesystem-blob-store.js +59 -0
  165. package/dist/runtime/helpers.d.ts +15 -6
  166. package/dist/runtime/helpers.js +46 -6
  167. package/dist/runtime/index.d.ts +4 -2
  168. package/dist/runtime/index.js +3 -1
  169. package/dist/runtime/local-effect-executor.d.ts +11 -2
  170. package/dist/runtime/local-effect-executor.js +80 -4
  171. package/dist/runtime/looms.d.ts +38 -4
  172. package/dist/runtime/looms.js +17 -3
  173. package/dist/runtime/repository.d.ts +5 -4
  174. package/dist/runtime/repository.js +5 -2
  175. package/dist/runtime/retry-policy.d.ts +5 -0
  176. package/dist/runtime/retry-policy.js +10 -2
  177. package/dist/runtime/run-start.d.ts +1 -1
  178. package/dist/runtime/run-start.js +10 -0
  179. package/dist/runtime/runtime.d.ts +2 -2
  180. package/dist/runtime/runtime.js +191 -68
  181. package/dist/runtime/server/auth.d.ts +3 -0
  182. package/dist/runtime/server/fetch-handler.d.ts +2 -2
  183. package/dist/runtime/server/fetch-handler.js +35 -4
  184. package/dist/runtime/server/grant.d.ts +49 -0
  185. package/dist/runtime/server/grant.js +177 -0
  186. package/dist/runtime/server/routes/effects.js +47 -5
  187. package/dist/runtime/server/routes/runs.js +6 -1
  188. package/dist/runtime/server/run-route.d.ts +18 -0
  189. package/dist/runtime/server/run-route.js +26 -0
  190. package/dist/runtime/server.d.ts +3 -1
  191. package/dist/runtime/server.js +3 -1
  192. package/dist/runtime/sse.js +26 -4
  193. package/dist/runtime/subscription.d.ts +8 -0
  194. package/dist/runtime/subscription.js +23 -0
  195. package/dist/runtime/types.d.ts +87 -8
  196. package/dist/runtime/wake-engine.d.ts +4 -2
  197. package/dist/runtime/wake-engine.js +57 -6
  198. package/dist/runtime/worker-callbacks.d.ts +12 -2
  199. package/dist/runtime/worker-callbacks.js +102 -72
  200. package/dist/runtime/worker-effect-dispatch.d.ts +14 -5
  201. package/dist/runtime/worker-effect-dispatch.js +84 -18
  202. package/dist/schedule/debugger/index.d.ts +4 -0
  203. package/dist/schedule/debugger/index.js +11 -0
  204. package/dist/schedule/debugger/schedule-view.d.ts +3 -0
  205. package/dist/schedule/debugger/schedule-view.js +68 -0
  206. package/dist/schedule/debugger/summarize.d.ts +2 -0
  207. package/dist/schedule/debugger/summarize.js +43 -0
  208. package/dist/schedule/definitions-store.d.ts +10 -0
  209. package/dist/schedule/definitions-store.js +8 -0
  210. package/dist/schedule/definitions.d.ts +57 -0
  211. package/dist/schedule/definitions.js +30 -0
  212. package/dist/schedule/effects.d.ts +756 -0
  213. package/dist/schedule/effects.js +244 -0
  214. package/dist/schedule/ensure.d.ts +55 -0
  215. package/dist/schedule/ensure.js +109 -0
  216. package/dist/schedule/events.d.ts +116 -0
  217. package/dist/schedule/events.js +49 -0
  218. package/dist/schedule/index.d.ts +11 -0
  219. package/dist/schedule/index.js +11 -0
  220. package/dist/schedule/module.d.ts +1474 -0
  221. package/dist/schedule/module.js +22 -0
  222. package/dist/schedule/projections.d.ts +55 -0
  223. package/dist/schedule/projections.js +88 -0
  224. package/dist/schedule/scope.d.ts +121 -0
  225. package/dist/schedule/scope.js +7 -0
  226. package/dist/schedule/signals.d.ts +25 -0
  227. package/dist/schedule/signals.js +33 -0
  228. package/dist/schedule/specs.d.ts +59 -0
  229. package/dist/schedule/specs.js +231 -0
  230. package/dist/schedule/threads.d.ts +25 -0
  231. package/dist/schedule/threads.js +259 -0
  232. package/dist/testing/corpus-module.d.ts +34 -0
  233. package/dist/testing/corpus-module.js +87 -0
  234. package/dist/testing/index.d.ts +2 -0
  235. package/dist/testing/index.js +5 -6
  236. package/dist/testing/replay-corpus.d.ts +22 -0
  237. package/dist/testing/replay-corpus.js +50 -0
  238. package/dist/workflow/definitions-store.d.ts +1 -1
  239. package/dist/workflow/definitions-store.js +1 -1
  240. package/dist/workflow/definitions.d.ts +14 -0
  241. package/dist/workflow/effects.d.ts +122 -0
  242. package/dist/workflow/effects.js +16 -6
  243. package/dist/workflow/events.d.ts +42 -0
  244. package/dist/workflow/events.js +4 -0
  245. package/dist/workflow/module.d.ts +345 -32
  246. package/dist/workflow/module.js +7 -3
  247. package/dist/workflow/scope.d.ts +42 -0
  248. package/dist/workflow/threads.d.ts +72 -0
  249. package/dist/workflow/threads.js +106 -38
  250. package/package.json +11 -2
  251. package/dist/debugger/app/assets/index-BevQYa-U.js +0 -22
  252. package/dist/debugger/app/assets/routes-B17Om93i.js +0 -47
  253. /package/dist/{react → core}/register.js +0 -0
@@ -1,9 +1,14 @@
1
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
+ import { type DefinitionInput, type DefinitionRef, type EventEnvelope, type EventInput, type JsonValue, type RunAttributes, type RunState, type SecretContext, type SubscriptionTransport, type TraceContext, type WorkerCallback, type WorkerCallbackInput, type WorkerCallbackResult, type WorkerSecretsResult } from '@swirls/looms/core';
3
3
  export interface LoomsClientOptions {
4
4
  baseUrl?: string;
5
5
  fetch?: typeof fetch;
6
6
  workerCallbackToken?: string;
7
+ /**
8
+ * Appended as `grant` to the event-stream URL, for both SSE and WebSocket subscriptions. A read
9
+ * grant cannot authorize other requests, so it is not sent on them.
10
+ */
11
+ grant?: string;
7
12
  }
8
13
  export interface StartResult {
9
14
  runId: string;
@@ -21,6 +26,10 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
21
26
  definitionVersion?: string;
22
27
  input?: JsonValue;
23
28
  runId?: string;
29
+ attributes?: RunAttributes;
30
+ secrets?: SecretContext;
31
+ /** Sent as the W3C `traceparent` and `tracestate` headers. */
32
+ trace?: TraceContext;
24
33
  }) => Promise<{
25
34
  readonly runId: string;
26
35
  readonly threadId: string;
@@ -36,7 +45,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
36
45
  readonly requestedThreadId: string | null;
37
46
  readonly idempotencyKey: string | null;
38
47
  readonly rootThreadId: string;
48
+ readonly launchedBy: {
49
+ readonly runId: string;
50
+ readonly threadId: string;
51
+ readonly effectId: string;
52
+ readonly causationId: string;
53
+ readonly causationSeq: number;
54
+ } | null;
55
+ readonly correlationId: string | null;
56
+ readonly attributes: {
57
+ readonly [x: string]: string;
58
+ };
59
+ readonly trace: {
60
+ readonly traceparent: string;
61
+ readonly tracestate?: string | undefined;
62
+ } | null;
39
63
  } | null;
64
+ readonly attributes: {
65
+ readonly [x: string]: string;
66
+ };
40
67
  readonly forkedFrom: {
41
68
  readonly runId: string;
42
69
  readonly seq: number;
@@ -108,6 +135,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
108
135
  readonly actorId?: string | undefined;
109
136
  } | {
110
137
  readonly type: "system";
138
+ } | {
139
+ readonly type: "run";
140
+ readonly runId: string;
111
141
  } | undefined;
112
142
  readonly ephemeral?: boolean | undefined;
113
143
  readonly id?: string | undefined;
@@ -125,10 +155,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
125
155
  readonly type: "runtime.cancel";
126
156
  readonly threadId: string;
127
157
  readonly tag?: string | undefined;
158
+ } | {
159
+ readonly type: "runtime.launch";
160
+ readonly runId: string;
161
+ readonly kind: string;
162
+ readonly definitionName: string;
163
+ readonly definitionVersion: string;
164
+ readonly input: Schema.Json;
165
+ readonly close: "terminate" | "wait";
166
+ readonly tag?: string | undefined;
167
+ } | {
168
+ readonly type: "runtime.cancelRun";
169
+ readonly runId: string;
170
+ readonly tag?: string | undefined;
128
171
  } | {
129
172
  readonly type: string;
130
173
  readonly input: Schema.Json;
131
174
  readonly tag?: string | undefined;
175
+ readonly at?: number | undefined;
132
176
  };
133
177
  }[];
134
178
  readonly effectExecutions: {
@@ -140,11 +184,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
140
184
  readonly deadlineAt: number | null;
141
185
  readonly startedAt: number | null;
142
186
  readonly lastHeartbeatAt: number | null;
187
+ readonly heartbeatDetails: Schema.Json;
143
188
  readonly lastError: string | null;
144
189
  };
145
190
  };
146
191
  readonly completedEffectIds: readonly string[];
147
192
  readonly processedIdempotencyKeys: readonly string[];
193
+ readonly launchedRuns: readonly {
194
+ readonly runId: string;
195
+ readonly close: "terminate" | "wait";
196
+ }[];
197
+ readonly closeWaiting: boolean;
198
+ readonly childCloseSent: boolean;
148
199
  };
149
200
  }>;
150
201
  /** Start a run from a definition object (agent, workflow, or your own kind). */
@@ -163,7 +214,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
163
214
  readonly requestedThreadId: string | null;
164
215
  readonly idempotencyKey: string | null;
165
216
  readonly rootThreadId: string;
217
+ readonly launchedBy: {
218
+ readonly runId: string;
219
+ readonly threadId: string;
220
+ readonly effectId: string;
221
+ readonly causationId: string;
222
+ readonly causationSeq: number;
223
+ } | null;
224
+ readonly correlationId: string | null;
225
+ readonly attributes: {
226
+ readonly [x: string]: string;
227
+ };
228
+ readonly trace: {
229
+ readonly traceparent: string;
230
+ readonly tracestate?: string | undefined;
231
+ } | null;
166
232
  } | null;
233
+ readonly attributes: {
234
+ readonly [x: string]: string;
235
+ };
167
236
  readonly forkedFrom: {
168
237
  readonly runId: string;
169
238
  readonly seq: number;
@@ -235,6 +304,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
235
304
  readonly actorId?: string | undefined;
236
305
  } | {
237
306
  readonly type: "system";
307
+ } | {
308
+ readonly type: "run";
309
+ readonly runId: string;
238
310
  } | undefined;
239
311
  readonly ephemeral?: boolean | undefined;
240
312
  readonly id?: string | undefined;
@@ -252,10 +324,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
252
324
  readonly type: "runtime.cancel";
253
325
  readonly threadId: string;
254
326
  readonly tag?: string | undefined;
327
+ } | {
328
+ readonly type: "runtime.launch";
329
+ readonly runId: string;
330
+ readonly kind: string;
331
+ readonly definitionName: string;
332
+ readonly definitionVersion: string;
333
+ readonly input: Schema.Json;
334
+ readonly close: "terminate" | "wait";
335
+ readonly tag?: string | undefined;
336
+ } | {
337
+ readonly type: "runtime.cancelRun";
338
+ readonly runId: string;
339
+ readonly tag?: string | undefined;
255
340
  } | {
256
341
  readonly type: string;
257
342
  readonly input: Schema.Json;
258
343
  readonly tag?: string | undefined;
344
+ readonly at?: number | undefined;
259
345
  };
260
346
  }[];
261
347
  readonly effectExecutions: {
@@ -267,11 +353,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
267
353
  readonly deadlineAt: number | null;
268
354
  readonly startedAt: number | null;
269
355
  readonly lastHeartbeatAt: number | null;
356
+ readonly heartbeatDetails: Schema.Json;
270
357
  readonly lastError: string | null;
271
358
  };
272
359
  };
273
360
  readonly completedEffectIds: readonly string[];
274
361
  readonly processedIdempotencyKeys: readonly string[];
362
+ readonly launchedRuns: readonly {
363
+ readonly runId: string;
364
+ readonly close: "terminate" | "wait";
365
+ }[];
366
+ readonly closeWaiting: boolean;
367
+ readonly childCloseSent: boolean;
275
368
  };
276
369
  }>;
277
370
  getRun: (runId: string) => Promise<{
@@ -288,7 +381,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
288
381
  readonly requestedThreadId: string | null;
289
382
  readonly idempotencyKey: string | null;
290
383
  readonly rootThreadId: string;
384
+ readonly launchedBy: {
385
+ readonly runId: string;
386
+ readonly threadId: string;
387
+ readonly effectId: string;
388
+ readonly causationId: string;
389
+ readonly causationSeq: number;
390
+ } | null;
391
+ readonly correlationId: string | null;
392
+ readonly attributes: {
393
+ readonly [x: string]: string;
394
+ };
395
+ readonly trace: {
396
+ readonly traceparent: string;
397
+ readonly tracestate?: string | undefined;
398
+ } | null;
291
399
  } | null;
400
+ readonly attributes: {
401
+ readonly [x: string]: string;
402
+ };
292
403
  readonly forkedFrom: {
293
404
  readonly runId: string;
294
405
  readonly seq: number;
@@ -360,6 +471,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
360
471
  readonly actorId?: string | undefined;
361
472
  } | {
362
473
  readonly type: "system";
474
+ } | {
475
+ readonly type: "run";
476
+ readonly runId: string;
363
477
  } | undefined;
364
478
  readonly ephemeral?: boolean | undefined;
365
479
  readonly id?: string | undefined;
@@ -377,10 +491,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
377
491
  readonly type: "runtime.cancel";
378
492
  readonly threadId: string;
379
493
  readonly tag?: string | undefined;
494
+ } | {
495
+ readonly type: "runtime.launch";
496
+ readonly runId: string;
497
+ readonly kind: string;
498
+ readonly definitionName: string;
499
+ readonly definitionVersion: string;
500
+ readonly input: Schema.Json;
501
+ readonly close: "terminate" | "wait";
502
+ readonly tag?: string | undefined;
503
+ } | {
504
+ readonly type: "runtime.cancelRun";
505
+ readonly runId: string;
506
+ readonly tag?: string | undefined;
380
507
  } | {
381
508
  readonly type: string;
382
509
  readonly input: Schema.Json;
383
510
  readonly tag?: string | undefined;
511
+ readonly at?: number | undefined;
384
512
  };
385
513
  }[];
386
514
  readonly effectExecutions: {
@@ -392,11 +520,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
392
520
  readonly deadlineAt: number | null;
393
521
  readonly startedAt: number | null;
394
522
  readonly lastHeartbeatAt: number | null;
523
+ readonly heartbeatDetails: Schema.Json;
395
524
  readonly lastError: string | null;
396
525
  };
397
526
  };
398
527
  readonly completedEffectIds: readonly string[];
399
528
  readonly processedIdempotencyKeys: readonly string[];
529
+ readonly launchedRuns: readonly {
530
+ readonly runId: string;
531
+ readonly close: "terminate" | "wait";
532
+ }[];
533
+ readonly closeWaiting: boolean;
534
+ readonly childCloseSent: boolean;
400
535
  };
401
536
  }>;
402
537
  getState: (runId: string) => Promise<{
@@ -413,7 +548,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
413
548
  readonly requestedThreadId: string | null;
414
549
  readonly idempotencyKey: string | null;
415
550
  readonly rootThreadId: string;
551
+ readonly launchedBy: {
552
+ readonly runId: string;
553
+ readonly threadId: string;
554
+ readonly effectId: string;
555
+ readonly causationId: string;
556
+ readonly causationSeq: number;
557
+ } | null;
558
+ readonly correlationId: string | null;
559
+ readonly attributes: {
560
+ readonly [x: string]: string;
561
+ };
562
+ readonly trace: {
563
+ readonly traceparent: string;
564
+ readonly tracestate?: string | undefined;
565
+ } | null;
416
566
  } | null;
567
+ readonly attributes: {
568
+ readonly [x: string]: string;
569
+ };
417
570
  readonly forkedFrom: {
418
571
  readonly runId: string;
419
572
  readonly seq: number;
@@ -485,6 +638,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
485
638
  readonly actorId?: string | undefined;
486
639
  } | {
487
640
  readonly type: "system";
641
+ } | {
642
+ readonly type: "run";
643
+ readonly runId: string;
488
644
  } | undefined;
489
645
  readonly ephemeral?: boolean | undefined;
490
646
  readonly id?: string | undefined;
@@ -502,10 +658,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
502
658
  readonly type: "runtime.cancel";
503
659
  readonly threadId: string;
504
660
  readonly tag?: string | undefined;
661
+ } | {
662
+ readonly type: "runtime.launch";
663
+ readonly runId: string;
664
+ readonly kind: string;
665
+ readonly definitionName: string;
666
+ readonly definitionVersion: string;
667
+ readonly input: Schema.Json;
668
+ readonly close: "terminate" | "wait";
669
+ readonly tag?: string | undefined;
670
+ } | {
671
+ readonly type: "runtime.cancelRun";
672
+ readonly runId: string;
673
+ readonly tag?: string | undefined;
505
674
  } | {
506
675
  readonly type: string;
507
676
  readonly input: Schema.Json;
508
677
  readonly tag?: string | undefined;
678
+ readonly at?: number | undefined;
509
679
  };
510
680
  }[];
511
681
  readonly effectExecutions: {
@@ -517,11 +687,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
517
687
  readonly deadlineAt: number | null;
518
688
  readonly startedAt: number | null;
519
689
  readonly lastHeartbeatAt: number | null;
690
+ readonly heartbeatDetails: Schema.Json;
520
691
  readonly lastError: string | null;
521
692
  };
522
693
  };
523
694
  readonly completedEffectIds: readonly string[];
524
695
  readonly processedIdempotencyKeys: readonly string[];
696
+ readonly launchedRuns: readonly {
697
+ readonly runId: string;
698
+ readonly close: "terminate" | "wait";
699
+ }[];
700
+ readonly closeWaiting: boolean;
701
+ readonly childCloseSent: boolean;
525
702
  };
526
703
  }>;
527
704
  getEvents: (runId: string, opts?: {
@@ -549,6 +726,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
549
726
  readonly actorId?: string | undefined;
550
727
  } | {
551
728
  readonly type: "system";
729
+ } | {
730
+ readonly type: "run";
731
+ readonly runId: string;
552
732
  };
553
733
  readonly ephemeral?: boolean | undefined;
554
734
  readonly idempotencyKey?: string | null | undefined;
@@ -568,7 +748,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
568
748
  readonly requestedThreadId: string | null;
569
749
  readonly idempotencyKey: string | null;
570
750
  readonly rootThreadId: string;
751
+ readonly launchedBy: {
752
+ readonly runId: string;
753
+ readonly threadId: string;
754
+ readonly effectId: string;
755
+ readonly causationId: string;
756
+ readonly causationSeq: number;
757
+ } | null;
758
+ readonly correlationId: string | null;
759
+ readonly attributes: {
760
+ readonly [x: string]: string;
761
+ };
762
+ readonly trace: {
763
+ readonly traceparent: string;
764
+ readonly tracestate?: string | undefined;
765
+ } | null;
571
766
  } | null;
767
+ readonly attributes: {
768
+ readonly [x: string]: string;
769
+ };
572
770
  readonly forkedFrom: {
573
771
  readonly runId: string;
574
772
  readonly seq: number;
@@ -640,6 +838,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
640
838
  readonly actorId?: string | undefined;
641
839
  } | {
642
840
  readonly type: "system";
841
+ } | {
842
+ readonly type: "run";
843
+ readonly runId: string;
643
844
  } | undefined;
644
845
  readonly ephemeral?: boolean | undefined;
645
846
  readonly id?: string | undefined;
@@ -657,10 +858,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
657
858
  readonly type: "runtime.cancel";
658
859
  readonly threadId: string;
659
860
  readonly tag?: string | undefined;
861
+ } | {
862
+ readonly type: "runtime.launch";
863
+ readonly runId: string;
864
+ readonly kind: string;
865
+ readonly definitionName: string;
866
+ readonly definitionVersion: string;
867
+ readonly input: Schema.Json;
868
+ readonly close: "terminate" | "wait";
869
+ readonly tag?: string | undefined;
870
+ } | {
871
+ readonly type: "runtime.cancelRun";
872
+ readonly runId: string;
873
+ readonly tag?: string | undefined;
660
874
  } | {
661
875
  readonly type: string;
662
876
  readonly input: Schema.Json;
663
877
  readonly tag?: string | undefined;
878
+ readonly at?: number | undefined;
664
879
  };
665
880
  }[];
666
881
  readonly effectExecutions: {
@@ -672,11 +887,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
672
887
  readonly deadlineAt: number | null;
673
888
  readonly startedAt: number | null;
674
889
  readonly lastHeartbeatAt: number | null;
890
+ readonly heartbeatDetails: Schema.Json;
675
891
  readonly lastError: string | null;
676
892
  };
677
893
  };
678
894
  readonly completedEffectIds: readonly string[];
679
895
  readonly processedIdempotencyKeys: readonly string[];
896
+ readonly launchedRuns: readonly {
897
+ readonly runId: string;
898
+ readonly close: "terminate" | "wait";
899
+ }[];
900
+ readonly closeWaiting: boolean;
901
+ readonly childCloseSent: boolean;
680
902
  };
681
903
  }>;
682
904
  wake: (runId: string) => Promise<{
@@ -693,7 +915,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
693
915
  readonly requestedThreadId: string | null;
694
916
  readonly idempotencyKey: string | null;
695
917
  readonly rootThreadId: string;
918
+ readonly launchedBy: {
919
+ readonly runId: string;
920
+ readonly threadId: string;
921
+ readonly effectId: string;
922
+ readonly causationId: string;
923
+ readonly causationSeq: number;
924
+ } | null;
925
+ readonly correlationId: string | null;
926
+ readonly attributes: {
927
+ readonly [x: string]: string;
928
+ };
929
+ readonly trace: {
930
+ readonly traceparent: string;
931
+ readonly tracestate?: string | undefined;
932
+ } | null;
696
933
  } | null;
934
+ readonly attributes: {
935
+ readonly [x: string]: string;
936
+ };
697
937
  readonly forkedFrom: {
698
938
  readonly runId: string;
699
939
  readonly seq: number;
@@ -765,6 +1005,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
765
1005
  readonly actorId?: string | undefined;
766
1006
  } | {
767
1007
  readonly type: "system";
1008
+ } | {
1009
+ readonly type: "run";
1010
+ readonly runId: string;
768
1011
  } | undefined;
769
1012
  readonly ephemeral?: boolean | undefined;
770
1013
  readonly id?: string | undefined;
@@ -782,10 +1025,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
782
1025
  readonly type: "runtime.cancel";
783
1026
  readonly threadId: string;
784
1027
  readonly tag?: string | undefined;
1028
+ } | {
1029
+ readonly type: "runtime.launch";
1030
+ readonly runId: string;
1031
+ readonly kind: string;
1032
+ readonly definitionName: string;
1033
+ readonly definitionVersion: string;
1034
+ readonly input: Schema.Json;
1035
+ readonly close: "terminate" | "wait";
1036
+ readonly tag?: string | undefined;
1037
+ } | {
1038
+ readonly type: "runtime.cancelRun";
1039
+ readonly runId: string;
1040
+ readonly tag?: string | undefined;
785
1041
  } | {
786
1042
  readonly type: string;
787
1043
  readonly input: Schema.Json;
788
1044
  readonly tag?: string | undefined;
1045
+ readonly at?: number | undefined;
789
1046
  };
790
1047
  }[];
791
1048
  readonly effectExecutions: {
@@ -797,11 +1054,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
797
1054
  readonly deadlineAt: number | null;
798
1055
  readonly startedAt: number | null;
799
1056
  readonly lastHeartbeatAt: number | null;
1057
+ readonly heartbeatDetails: Schema.Json;
800
1058
  readonly lastError: string | null;
801
1059
  };
802
1060
  };
803
1061
  readonly completedEffectIds: readonly string[];
804
1062
  readonly processedIdempotencyKeys: readonly string[];
1063
+ readonly launchedRuns: readonly {
1064
+ readonly runId: string;
1065
+ readonly close: "terminate" | "wait";
1066
+ }[];
1067
+ readonly closeWaiting: boolean;
1068
+ readonly childCloseSent: boolean;
805
1069
  };
806
1070
  readonly appended: number;
807
1071
  }>;
@@ -820,7 +1084,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
820
1084
  readonly requestedThreadId: string | null;
821
1085
  readonly idempotencyKey: string | null;
822
1086
  readonly rootThreadId: string;
1087
+ readonly launchedBy: {
1088
+ readonly runId: string;
1089
+ readonly threadId: string;
1090
+ readonly effectId: string;
1091
+ readonly causationId: string;
1092
+ readonly causationSeq: number;
1093
+ } | null;
1094
+ readonly correlationId: string | null;
1095
+ readonly attributes: {
1096
+ readonly [x: string]: string;
1097
+ };
1098
+ readonly trace: {
1099
+ readonly traceparent: string;
1100
+ readonly tracestate?: string | undefined;
1101
+ } | null;
823
1102
  } | null;
1103
+ readonly attributes: {
1104
+ readonly [x: string]: string;
1105
+ };
824
1106
  readonly forkedFrom: {
825
1107
  readonly runId: string;
826
1108
  readonly seq: number;
@@ -892,6 +1174,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
892
1174
  readonly actorId?: string | undefined;
893
1175
  } | {
894
1176
  readonly type: "system";
1177
+ } | {
1178
+ readonly type: "run";
1179
+ readonly runId: string;
895
1180
  } | undefined;
896
1181
  readonly ephemeral?: boolean | undefined;
897
1182
  readonly id?: string | undefined;
@@ -909,10 +1194,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
909
1194
  readonly type: "runtime.cancel";
910
1195
  readonly threadId: string;
911
1196
  readonly tag?: string | undefined;
1197
+ } | {
1198
+ readonly type: "runtime.launch";
1199
+ readonly runId: string;
1200
+ readonly kind: string;
1201
+ readonly definitionName: string;
1202
+ readonly definitionVersion: string;
1203
+ readonly input: Schema.Json;
1204
+ readonly close: "terminate" | "wait";
1205
+ readonly tag?: string | undefined;
1206
+ } | {
1207
+ readonly type: "runtime.cancelRun";
1208
+ readonly runId: string;
1209
+ readonly tag?: string | undefined;
912
1210
  } | {
913
1211
  readonly type: string;
914
1212
  readonly input: Schema.Json;
915
1213
  readonly tag?: string | undefined;
1214
+ readonly at?: number | undefined;
916
1215
  };
917
1216
  }[];
918
1217
  readonly effectExecutions: {
@@ -924,11 +1223,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
924
1223
  readonly deadlineAt: number | null;
925
1224
  readonly startedAt: number | null;
926
1225
  readonly lastHeartbeatAt: number | null;
1226
+ readonly heartbeatDetails: Schema.Json;
927
1227
  readonly lastError: string | null;
928
1228
  };
929
1229
  };
930
1230
  readonly completedEffectIds: readonly string[];
931
1231
  readonly processedIdempotencyKeys: readonly string[];
1232
+ readonly launchedRuns: readonly {
1233
+ readonly runId: string;
1234
+ readonly close: "terminate" | "wait";
1235
+ }[];
1236
+ readonly closeWaiting: boolean;
1237
+ readonly childCloseSent: boolean;
932
1238
  };
933
1239
  }>;
934
1240
  /** Start a new run that continues where a finished run ended. */
@@ -949,7 +1255,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
949
1255
  readonly requestedThreadId: string | null;
950
1256
  readonly idempotencyKey: string | null;
951
1257
  readonly rootThreadId: string;
1258
+ readonly launchedBy: {
1259
+ readonly runId: string;
1260
+ readonly threadId: string;
1261
+ readonly effectId: string;
1262
+ readonly causationId: string;
1263
+ readonly causationSeq: number;
1264
+ } | null;
1265
+ readonly correlationId: string | null;
1266
+ readonly attributes: {
1267
+ readonly [x: string]: string;
1268
+ };
1269
+ readonly trace: {
1270
+ readonly traceparent: string;
1271
+ readonly tracestate?: string | undefined;
1272
+ } | null;
952
1273
  } | null;
1274
+ readonly attributes: {
1275
+ readonly [x: string]: string;
1276
+ };
953
1277
  readonly forkedFrom: {
954
1278
  readonly runId: string;
955
1279
  readonly seq: number;
@@ -1021,6 +1345,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1021
1345
  readonly actorId?: string | undefined;
1022
1346
  } | {
1023
1347
  readonly type: "system";
1348
+ } | {
1349
+ readonly type: "run";
1350
+ readonly runId: string;
1024
1351
  } | undefined;
1025
1352
  readonly ephemeral?: boolean | undefined;
1026
1353
  readonly id?: string | undefined;
@@ -1039,134 +1366,23 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1039
1366
  readonly threadId: string;
1040
1367
  readonly tag?: string | undefined;
1041
1368
  } | {
1042
- readonly type: string;
1043
- readonly input: Schema.Json;
1044
- readonly tag?: string | undefined;
1045
- };
1046
- }[];
1047
- readonly effectExecutions: {
1048
- readonly [x: string]: {
1049
- readonly effectId: string;
1050
- readonly attempt: number;
1051
- readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
1052
- readonly nextAttemptAt: number | null;
1053
- readonly deadlineAt: number | null;
1054
- readonly startedAt: number | null;
1055
- readonly lastHeartbeatAt: number | null;
1056
- readonly lastError: string | null;
1057
- };
1058
- };
1059
- readonly completedEffectIds: readonly string[];
1060
- readonly processedIdempotencyKeys: readonly string[];
1061
- };
1062
- }>;
1063
- workerCallback: (runId: string, input: WorkerCallbackInput) => Promise<{
1064
- readonly runId: string;
1065
- readonly state: {
1066
- readonly runId: string;
1067
- readonly status: "cancelled" | "completed" | "failed" | "running";
1068
- readonly rootThreadId: string | null;
1069
- readonly startIdentity: {
1070
- readonly kind: string;
1071
- readonly definitionName: string;
1072
- readonly definitionVersion: string;
1073
- readonly input: Schema.Json;
1074
- readonly requestedThreadId: string | null;
1075
- readonly idempotencyKey: string | null;
1076
- readonly rootThreadId: string;
1077
- } | null;
1078
- readonly forkedFrom: {
1079
- readonly runId: string;
1080
- readonly seq: number;
1081
- } | null;
1082
- readonly threads: {
1083
- readonly [x: string]: {
1084
- readonly threadId: string;
1085
- readonly kind: string;
1086
- readonly definitionName: string;
1087
- readonly definitionVersion: string;
1088
- readonly parentThreadId: string | null;
1089
- readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
1090
- readonly input: Schema.Json;
1091
- readonly output: Schema.Json;
1092
- readonly error: string | null;
1093
- readonly state: Schema.Json;
1094
- };
1095
- };
1096
- readonly waits: {
1097
- readonly [x: string]: {
1098
- readonly waitId: string;
1099
- readonly threadId: string;
1100
- readonly on: {
1101
- readonly type: string | readonly string[];
1102
- readonly match?: Schema.Json | undefined;
1103
- } | {
1104
- readonly timerAt: number;
1105
- };
1106
- readonly tag?: Schema.Json | undefined;
1107
- };
1108
- };
1109
- readonly outstandingEffects: readonly {
1110
- readonly effectId: string;
1111
- readonly threadId: string;
1112
- readonly causingSeq: number;
1113
- readonly causingEventId: string;
1114
- readonly effect: {
1115
- readonly type: "runtime.spawn";
1116
- readonly childThreadId: string;
1369
+ readonly type: "runtime.launch";
1370
+ readonly runId: string;
1117
1371
  readonly kind: string;
1118
1372
  readonly definitionName: string;
1119
1373
  readonly definitionVersion: string;
1120
1374
  readonly input: Schema.Json;
1121
- } | {
1122
- readonly type: "runtime.wait";
1123
- readonly waitId: string;
1124
- readonly on: {
1125
- readonly type: string | readonly string[];
1126
- readonly match?: Schema.Json | undefined;
1127
- } | {
1128
- readonly timerAt: number;
1129
- };
1130
- readonly tag?: Schema.Json | undefined;
1131
- } | {
1132
- readonly type: "runtime.emit";
1133
- readonly event: {
1134
- readonly type: string;
1135
- readonly payload: Schema.Json;
1136
- readonly threadId?: string | null | undefined;
1137
- readonly parentThreadId?: string | null | undefined;
1138
- readonly causationId?: string | null | undefined;
1139
- readonly correlationId?: string | null | undefined;
1140
- readonly effectId?: string | null | undefined;
1141
- readonly origin?: {
1142
- readonly type: "thread";
1143
- readonly threadId: string;
1144
- } | {
1145
- readonly type: "external";
1146
- readonly actorId?: string | undefined;
1147
- } | {
1148
- readonly type: "system";
1149
- } | undefined;
1150
- readonly ephemeral?: boolean | undefined;
1151
- readonly id?: string | undefined;
1152
- readonly ts?: number | undefined;
1153
- readonly idempotencyKey?: string | null | undefined;
1154
- };
1375
+ readonly close: "terminate" | "wait";
1155
1376
  readonly tag?: string | undefined;
1156
1377
  } | {
1157
- readonly type: "runtime.complete";
1158
- readonly output: Schema.Json;
1159
- } | {
1160
- readonly type: "runtime.fail";
1161
- readonly error: string;
1162
- } | {
1163
- readonly type: "runtime.cancel";
1164
- readonly threadId: string;
1378
+ readonly type: "runtime.cancelRun";
1379
+ readonly runId: string;
1165
1380
  readonly tag?: string | undefined;
1166
1381
  } | {
1167
1382
  readonly type: string;
1168
1383
  readonly input: Schema.Json;
1169
1384
  readonly tag?: string | undefined;
1385
+ readonly at?: number | undefined;
1170
1386
  };
1171
1387
  }[];
1172
1388
  readonly effectExecutions: {
@@ -1178,19 +1394,31 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1178
1394
  readonly deadlineAt: number | null;
1179
1395
  readonly startedAt: number | null;
1180
1396
  readonly lastHeartbeatAt: number | null;
1397
+ readonly heartbeatDetails: Schema.Json;
1181
1398
  readonly lastError: string | null;
1182
1399
  };
1183
1400
  };
1184
1401
  readonly completedEffectIds: readonly string[];
1185
1402
  readonly processedIdempotencyKeys: readonly string[];
1403
+ readonly launchedRuns: readonly {
1404
+ readonly runId: string;
1405
+ readonly close: "terminate" | "wait";
1406
+ }[];
1407
+ readonly closeWaiting: boolean;
1408
+ readonly childCloseSent: boolean;
1186
1409
  };
1187
1410
  }>;
1411
+ workerCallback: (runId: string, input: WorkerCallbackInput) => Promise<WorkerCallbackResult>;
1412
+ workerSecrets: (runId: string, attempt: WorkerCallback) => Promise<WorkerSecretsResult>;
1188
1413
  listRunSummaries: () => Promise<{
1189
1414
  readonly runs: readonly {
1190
1415
  readonly runId: string;
1191
1416
  readonly status: "cancelled" | "completed" | "failed" | "running";
1192
1417
  readonly kind: string | null;
1193
1418
  readonly definitionName: string | null;
1419
+ readonly attributes: {
1420
+ readonly [x: string]: string;
1421
+ };
1194
1422
  }[];
1195
1423
  }>;
1196
1424
  listDefinitions: () => Promise<{
@@ -1227,6 +1455,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1227
1455
  readonly actorId?: string | undefined;
1228
1456
  } | {
1229
1457
  readonly type: "system";
1458
+ } | {
1459
+ readonly type: "run";
1460
+ readonly runId: string;
1230
1461
  };
1231
1462
  readonly ephemeral?: boolean | undefined;
1232
1463
  readonly idempotencyKey?: string | null | undefined;
@@ -1243,7 +1474,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1243
1474
  readonly requestedThreadId: string | null;
1244
1475
  readonly idempotencyKey: string | null;
1245
1476
  readonly rootThreadId: string;
1477
+ readonly launchedBy: {
1478
+ readonly runId: string;
1479
+ readonly threadId: string;
1480
+ readonly effectId: string;
1481
+ readonly causationId: string;
1482
+ readonly causationSeq: number;
1483
+ } | null;
1484
+ readonly correlationId: string | null;
1485
+ readonly attributes: {
1486
+ readonly [x: string]: string;
1487
+ };
1488
+ readonly trace: {
1489
+ readonly traceparent: string;
1490
+ readonly tracestate?: string | undefined;
1491
+ } | null;
1246
1492
  } | null;
1493
+ readonly attributes: {
1494
+ readonly [x: string]: string;
1495
+ };
1247
1496
  readonly forkedFrom: {
1248
1497
  readonly runId: string;
1249
1498
  readonly seq: number;
@@ -1315,6 +1564,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1315
1564
  readonly actorId?: string | undefined;
1316
1565
  } | {
1317
1566
  readonly type: "system";
1567
+ } | {
1568
+ readonly type: "run";
1569
+ readonly runId: string;
1318
1570
  } | undefined;
1319
1571
  readonly ephemeral?: boolean | undefined;
1320
1572
  readonly id?: string | undefined;
@@ -1332,10 +1584,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1332
1584
  readonly type: "runtime.cancel";
1333
1585
  readonly threadId: string;
1334
1586
  readonly tag?: string | undefined;
1587
+ } | {
1588
+ readonly type: "runtime.launch";
1589
+ readonly runId: string;
1590
+ readonly kind: string;
1591
+ readonly definitionName: string;
1592
+ readonly definitionVersion: string;
1593
+ readonly input: Schema.Json;
1594
+ readonly close: "terminate" | "wait";
1595
+ readonly tag?: string | undefined;
1596
+ } | {
1597
+ readonly type: "runtime.cancelRun";
1598
+ readonly runId: string;
1599
+ readonly tag?: string | undefined;
1335
1600
  } | {
1336
1601
  readonly type: string;
1337
1602
  readonly input: Schema.Json;
1338
1603
  readonly tag?: string | undefined;
1604
+ readonly at?: number | undefined;
1339
1605
  };
1340
1606
  }[];
1341
1607
  readonly effectExecutions: {
@@ -1347,11 +1613,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1347
1613
  readonly deadlineAt: number | null;
1348
1614
  readonly startedAt: number | null;
1349
1615
  readonly lastHeartbeatAt: number | null;
1616
+ readonly heartbeatDetails: Schema.Json;
1350
1617
  readonly lastError: string | null;
1351
1618
  };
1352
1619
  };
1353
1620
  readonly completedEffectIds: readonly string[];
1354
1621
  readonly processedIdempotencyKeys: readonly string[];
1622
+ readonly launchedRuns: readonly {
1623
+ readonly runId: string;
1624
+ readonly close: "terminate" | "wait";
1625
+ }[];
1626
+ readonly closeWaiting: boolean;
1627
+ readonly childCloseSent: boolean;
1355
1628
  };
1356
1629
  readonly after: {
1357
1630
  readonly runId: string;
@@ -1365,7 +1638,25 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1365
1638
  readonly requestedThreadId: string | null;
1366
1639
  readonly idempotencyKey: string | null;
1367
1640
  readonly rootThreadId: string;
1641
+ readonly launchedBy: {
1642
+ readonly runId: string;
1643
+ readonly threadId: string;
1644
+ readonly effectId: string;
1645
+ readonly causationId: string;
1646
+ readonly causationSeq: number;
1647
+ } | null;
1648
+ readonly correlationId: string | null;
1649
+ readonly attributes: {
1650
+ readonly [x: string]: string;
1651
+ };
1652
+ readonly trace: {
1653
+ readonly traceparent: string;
1654
+ readonly tracestate?: string | undefined;
1655
+ } | null;
1368
1656
  } | null;
1657
+ readonly attributes: {
1658
+ readonly [x: string]: string;
1659
+ };
1369
1660
  readonly forkedFrom: {
1370
1661
  readonly runId: string;
1371
1662
  readonly seq: number;
@@ -1437,6 +1728,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1437
1728
  readonly actorId?: string | undefined;
1438
1729
  } | {
1439
1730
  readonly type: "system";
1731
+ } | {
1732
+ readonly type: "run";
1733
+ readonly runId: string;
1440
1734
  } | undefined;
1441
1735
  readonly ephemeral?: boolean | undefined;
1442
1736
  readonly id?: string | undefined;
@@ -1454,10 +1748,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1454
1748
  readonly type: "runtime.cancel";
1455
1749
  readonly threadId: string;
1456
1750
  readonly tag?: string | undefined;
1751
+ } | {
1752
+ readonly type: "runtime.launch";
1753
+ readonly runId: string;
1754
+ readonly kind: string;
1755
+ readonly definitionName: string;
1756
+ readonly definitionVersion: string;
1757
+ readonly input: Schema.Json;
1758
+ readonly close: "terminate" | "wait";
1759
+ readonly tag?: string | undefined;
1760
+ } | {
1761
+ readonly type: "runtime.cancelRun";
1762
+ readonly runId: string;
1763
+ readonly tag?: string | undefined;
1457
1764
  } | {
1458
1765
  readonly type: string;
1459
1766
  readonly input: Schema.Json;
1460
1767
  readonly tag?: string | undefined;
1768
+ readonly at?: number | undefined;
1461
1769
  };
1462
1770
  }[];
1463
1771
  readonly effectExecutions: {
@@ -1469,11 +1777,18 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1469
1777
  readonly deadlineAt: number | null;
1470
1778
  readonly startedAt: number | null;
1471
1779
  readonly lastHeartbeatAt: number | null;
1780
+ readonly heartbeatDetails: Schema.Json;
1472
1781
  readonly lastError: string | null;
1473
1782
  };
1474
1783
  };
1475
1784
  readonly completedEffectIds: readonly string[];
1476
1785
  readonly processedIdempotencyKeys: readonly string[];
1786
+ readonly launchedRuns: readonly {
1787
+ readonly runId: string;
1788
+ readonly close: "terminate" | "wait";
1789
+ }[];
1790
+ readonly closeWaiting: boolean;
1791
+ readonly childCloseSent: boolean;
1477
1792
  };
1478
1793
  readonly effects: readonly ({
1479
1794
  readonly type: "runtime.spawn";
@@ -1510,6 +1825,9 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1510
1825
  readonly actorId?: string | undefined;
1511
1826
  } | {
1512
1827
  readonly type: "system";
1828
+ } | {
1829
+ readonly type: "run";
1830
+ readonly runId: string;
1513
1831
  } | undefined;
1514
1832
  readonly ephemeral?: boolean | undefined;
1515
1833
  readonly id?: string | undefined;
@@ -1527,10 +1845,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1527
1845
  readonly type: "runtime.cancel";
1528
1846
  readonly threadId: string;
1529
1847
  readonly tag?: string | undefined;
1848
+ } | {
1849
+ readonly type: "runtime.launch";
1850
+ readonly runId: string;
1851
+ readonly kind: string;
1852
+ readonly definitionName: string;
1853
+ readonly definitionVersion: string;
1854
+ readonly input: Schema.Json;
1855
+ readonly close: "terminate" | "wait";
1856
+ readonly tag?: string | undefined;
1857
+ } | {
1858
+ readonly type: "runtime.cancelRun";
1859
+ readonly runId: string;
1860
+ readonly tag?: string | undefined;
1530
1861
  } | {
1531
1862
  readonly type: string;
1532
1863
  readonly input: Schema.Json;
1533
1864
  readonly tag?: string | undefined;
1865
+ readonly at?: number | undefined;
1534
1866
  })[];
1535
1867
  } | null;
1536
1868
  }>;
@@ -1539,7 +1871,7 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1539
1871
  readonly name: string;
1540
1872
  readonly value: unknown;
1541
1873
  }>;
1542
- subscribeEvents: (runId: string, onEvent: (event: EventEnvelope) => void, reconnectDelayMs?: number) => () => void;
1874
+ subscribeEvents: (runId: string, onEvent: (event: EventEnvelope) => void, third?: number | SubscribeEventsOptions) => () => void;
1543
1875
  /**
1544
1876
  * Subscribe to the run log, then start execution so deltas arrive live.
1545
1877
  * Yields events in store order, including live module events such as `agent.turn.text_delta`.
@@ -1550,7 +1882,24 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
1550
1882
  definitionVersion?: string;
1551
1883
  input?: JsonValue;
1552
1884
  runId?: string;
1885
+ trace?: TraceContext;
1553
1886
  }) => StreamHandle;
1554
1887
  stream: <TDef extends DefinitionRef>(definition: TDef, input?: DefinitionInput<TDef>) => StreamHandle;
1555
1888
  };
1556
1889
  export type LoomsClient = ReturnType<typeof createLoomsClient>;
1890
+ export interface SubscribeEventsOptions {
1891
+ readonly transport?: SubscriptionTransport;
1892
+ readonly reconnectDelayMs?: number;
1893
+ readonly threadId?: string;
1894
+ readonly includeEphemeral?: boolean;
1895
+ readonly webSocket?: SubscriptionSocketConstructor;
1896
+ }
1897
+ export interface SubscriptionSocket {
1898
+ addEventListener(type: string, listener: (event: {
1899
+ readonly data?: unknown;
1900
+ }) => void): void;
1901
+ close(code?: number, reason?: string): void;
1902
+ }
1903
+ export interface SubscriptionSocketConstructor {
1904
+ new (url: string): SubscriptionSocket;
1905
+ }