@swirls/looms 0.0.2 → 0.2.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 (375) hide show
  1. package/CHANGELOG.md +24 -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 +57 -33
  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/debugger/agent-chat.d.ts +2 -0
  13. package/dist/agent/debugger/agent-chat.js +176 -0
  14. package/dist/agent/debugger/index.d.ts +5 -0
  15. package/dist/agent/debugger/index.js +19 -0
  16. package/dist/agent/debugger/summarize.d.ts +2 -0
  17. package/dist/agent/debugger/summarize.js +51 -0
  18. package/dist/agent/debugger/token-usage.d.ts +3 -0
  19. package/dist/agent/debugger/token-usage.js +11 -0
  20. package/dist/agent/definitions-store.d.ts +2 -3
  21. package/dist/agent/definitions-store.js +2 -4
  22. package/dist/agent/definitions.d.ts +47 -29
  23. package/dist/agent/definitions.js +39 -12
  24. package/dist/agent/effects.d.ts +359 -2
  25. package/dist/agent/effects.js +60 -34
  26. package/dist/agent/events.d.ts +175 -19
  27. package/dist/agent/events.js +45 -10
  28. package/dist/agent/index.d.ts +1 -0
  29. package/dist/agent/index.js +1 -0
  30. package/dist/agent/llm.d.ts +11 -2
  31. package/dist/agent/llm.js +13 -3
  32. package/dist/agent/module.d.ts +812 -78
  33. package/dist/agent/module.js +16 -4
  34. package/dist/agent/scope.d.ts +174 -18
  35. package/dist/agent/signals.d.ts +26 -1
  36. package/dist/agent/signals.js +79 -0
  37. package/dist/agent/threads.d.ts +3 -33
  38. package/dist/agent/threads.js +20 -25
  39. package/dist/agent/tool-schema.d.ts +1 -17
  40. package/dist/agent/tool-schema.js +3 -43
  41. package/dist/agent/types.d.ts +49 -4
  42. package/dist/agent/types.js +5 -5
  43. package/dist/ai-vercel/index.d.ts +1 -0
  44. package/dist/ai-vercel/index.js +1 -0
  45. package/dist/ai-vercel/messages.js +22 -7
  46. package/dist/ai-vercel/vercel-evaluator.d.ts +36 -0
  47. package/dist/ai-vercel/vercel-evaluator.js +73 -0
  48. package/dist/ai-vercel/vercel-llm.js +64 -44
  49. package/dist/approval/debugger/approvals-view.d.ts +3 -0
  50. package/dist/approval/debugger/approvals-view.js +16 -0
  51. package/dist/approval/debugger/index.d.ts +4 -0
  52. package/dist/approval/debugger/index.js +11 -0
  53. package/dist/approval/debugger/summarize.d.ts +2 -0
  54. package/dist/approval/debugger/summarize.js +17 -0
  55. package/dist/approval/effects.d.ts +89 -0
  56. package/dist/approval/module.d.ts +179 -29
  57. package/dist/approval/projections.d.ts +0 -14
  58. package/dist/approval/projections.js +20 -3
  59. package/dist/approval/signals.d.ts +2 -0
  60. package/dist/approval/signals.js +18 -2
  61. package/dist/cli/cli.js +2 -0
  62. package/dist/cli/commands.js +12 -16
  63. package/dist/client/client.d.ts +1213 -18
  64. package/dist/client/client.js +120 -120
  65. package/dist/client/index.d.ts +1 -1
  66. package/dist/client/index.js +1 -1
  67. package/dist/client/sse.d.ts +13 -0
  68. package/dist/client/sse.js +38 -44
  69. package/dist/cloudflare/alarm-scheduler.d.ts +12 -2
  70. package/dist/cloudflare/alarm-scheduler.js +34 -7
  71. package/dist/cloudflare/durable-object.d.ts +10 -2
  72. package/dist/cloudflare/durable-object.js +59 -28
  73. package/dist/cloudflare/event-store.d.ts +7 -2
  74. package/dist/cloudflare/event-store.js +8 -7
  75. package/dist/cloudflare/index.d.ts +2 -2
  76. package/dist/cloudflare/index.js +2 -2
  77. package/dist/cloudflare/router.d.ts +1 -1
  78. package/dist/cloudflare/router.js +15 -16
  79. package/dist/core/catalog.d.ts +3 -3
  80. package/dist/core/catalog.js +2 -5
  81. package/dist/core/coalesce.js +5 -3
  82. package/dist/core/compose.d.ts +2 -1
  83. package/dist/core/compose.js +19 -2
  84. package/dist/core/debugger-host.d.ts +16 -0
  85. package/dist/core/debugger-host.js +1 -0
  86. package/dist/core/definition-store.d.ts +11 -0
  87. package/dist/core/definition-store.js +6 -0
  88. package/dist/core/effects.d.ts +127 -15
  89. package/dist/core/effects.js +89 -17
  90. package/dist/core/envelope.d.ts +27 -7
  91. package/dist/core/envelope.js +20 -6
  92. package/dist/core/event-codec.d.ts +4 -2
  93. package/dist/core/event-codec.js +10 -5
  94. package/dist/core/event-index.js +1 -3
  95. package/dist/core/fold.d.ts +3 -0
  96. package/dist/core/fold.js +171 -24
  97. package/dist/core/ids.d.ts +5 -0
  98. package/dist/core/ids.js +35 -2
  99. package/dist/core/index.d.ts +7 -1
  100. package/dist/core/index.js +6 -1
  101. package/dist/core/kind.d.ts +22 -0
  102. package/dist/core/kind.js +17 -0
  103. package/dist/core/limits.d.ts +34 -0
  104. package/dist/core/limits.js +46 -0
  105. package/dist/core/match.d.ts +1 -0
  106. package/dist/core/match.js +10 -1
  107. package/dist/core/module-scope.d.ts +22 -20
  108. package/dist/core/module-scope.js +38 -28
  109. package/dist/core/module.d.ts +18 -5
  110. package/dist/core/module.js +4 -0
  111. package/dist/core/projection.d.ts +13 -13
  112. package/dist/core/projection.js +9 -5
  113. package/dist/core/protocol.d.ts +68 -11
  114. package/dist/core/protocol.js +82 -11
  115. package/dist/core/published.d.ts +43 -0
  116. package/dist/core/published.js +44 -0
  117. package/dist/core/replay.d.ts +312 -3
  118. package/dist/core/replay.js +11 -1
  119. package/dist/core/schema.d.ts +11 -20
  120. package/dist/core/schema.js +63 -80
  121. package/dist/core/serialize.js +2 -4
  122. package/dist/core/snapshot-store.d.ts +6 -1
  123. package/dist/core/snapshot-store.js +15 -2
  124. package/dist/core/snapshots.d.ts +5 -1
  125. package/dist/core/snapshots.js +10 -15
  126. package/dist/core/sqlite-store.js +95 -11
  127. package/dist/core/state.d.ts +142 -4
  128. package/dist/core/state.js +78 -0
  129. package/dist/core/store.d.ts +38 -3
  130. package/dist/core/store.js +77 -22
  131. package/dist/core/thread.d.ts +10 -9
  132. package/dist/core/types.d.ts +5 -8
  133. package/dist/core/types.js +28 -24
  134. package/dist/core/validate-event.js +14 -4
  135. package/dist/core/worker-callback.d.ts +17 -0
  136. package/dist/core/worker-callback.js +1 -0
  137. package/dist/debugger/app/assets/index-B3Ah8WAE.css +2 -0
  138. package/dist/debugger/app/assets/index-Qb371t_O.js +22 -0
  139. package/dist/debugger/app/assets/rolldown-runtime-CbXtAM7H.js +1 -0
  140. package/dist/debugger/app/assets/routes-CjtEHgPQ.js +47 -0
  141. package/dist/debugger/app/index.html +14 -0
  142. package/dist/debugger/components/composer.d.ts +17 -0
  143. package/dist/debugger/components/composer.js +25 -0
  144. package/dist/debugger/components/debugger-split.d.ts +2 -1
  145. package/dist/debugger/components/debugger-split.js +2 -2
  146. package/dist/debugger/components/event-inspector.d.ts +2 -1
  147. package/dist/debugger/components/event-inspector.js +25 -16
  148. package/dist/debugger/components/event-stream.d.ts +2 -1
  149. package/dist/debugger/components/event-stream.js +14 -74
  150. package/dist/debugger/components/follow-list.d.ts +19 -0
  151. package/dist/debugger/components/follow-list.js +96 -0
  152. package/dist/debugger/components/json-tree.d.ts +11 -0
  153. package/dist/debugger/components/json-tree.js +120 -0
  154. package/dist/debugger/components/json-view.js +2 -2
  155. package/dist/debugger/components/run-tree.js +53 -20
  156. package/dist/debugger/components/status-dot.d.ts +4 -0
  157. package/dist/debugger/components/status-dot.js +6 -2
  158. package/dist/debugger/context.d.ts +14 -0
  159. package/dist/debugger/context.js +17 -0
  160. package/dist/debugger/contracts.d.ts +7 -4
  161. package/dist/debugger/events/builtin-families.d.ts +3 -0
  162. package/dist/debugger/events/builtin-families.js +9 -0
  163. package/dist/debugger/events/catalog.d.ts +3 -4
  164. package/dist/debugger/events/catalog.js +27 -17
  165. package/dist/debugger/events/protocol-summarize.d.ts +1 -2
  166. package/dist/debugger/events/protocol-summarize.js +42 -24
  167. package/dist/debugger/index.d.ts +20 -6
  168. package/dist/debugger/index.js +19 -5
  169. package/dist/debugger/lib/cn.d.ts +1 -0
  170. package/dist/debugger/lib/cn.js +3 -0
  171. package/dist/debugger/lib/event-meta.d.ts +2 -3
  172. package/dist/debugger/lib/event-meta.js +6 -12
  173. package/dist/debugger/lib/json.d.ts +25 -0
  174. package/dist/debugger/lib/json.js +87 -0
  175. package/dist/debugger/lib/payload.d.ts +7 -0
  176. package/dist/debugger/lib/payload.js +11 -0
  177. package/dist/debugger/lib/time.d.ts +3 -0
  178. package/dist/debugger/lib/time.js +24 -0
  179. package/dist/debugger/plugin.d.ts +36 -0
  180. package/dist/debugger/plugin.js +14 -0
  181. package/dist/debugger/server/index.d.ts +14 -0
  182. package/dist/debugger/server/index.js +114 -0
  183. package/dist/debugger/shell/debugger-shell.d.ts +15 -0
  184. package/dist/debugger/shell/debugger-shell.js +43 -0
  185. package/dist/debugger/shell/definition-key.d.ts +3 -0
  186. package/dist/debugger/shell/definition-key.js +4 -0
  187. package/dist/debugger/shell/events-pane.d.ts +12 -0
  188. package/dist/debugger/shell/events-pane.js +25 -0
  189. package/dist/debugger/shell/projections-panel.d.ts +4 -0
  190. package/dist/debugger/shell/projections-panel.js +59 -0
  191. package/dist/debugger/shell/run-controls.d.ts +4 -0
  192. package/dist/debugger/shell/run-controls.js +72 -0
  193. package/dist/debugger/shell/run-search.d.ts +6 -0
  194. package/dist/debugger/shell/run-search.js +102 -0
  195. package/dist/debugger/shell/run-type-menu.d.ts +6 -0
  196. package/dist/debugger/shell/run-type-menu.js +11 -0
  197. package/dist/debugger/shell/schema-form.d.ts +31 -0
  198. package/dist/debugger/shell/schema-form.js +117 -0
  199. package/dist/debugger/shell/start-form.d.ts +3 -0
  200. package/dist/debugger/shell/start-form.js +75 -0
  201. package/dist/debugger/shell/use-start-run.d.ts +14 -0
  202. package/dist/debugger/shell/use-start-run.js +32 -0
  203. package/dist/debugger/shell/workspace.d.ts +6 -0
  204. package/dist/debugger/shell/workspace.js +15 -0
  205. package/dist/debugger/styles.css +111 -27
  206. package/dist/debugger/ui/button.d.ts +24 -0
  207. package/dist/debugger/ui/button.js +24 -0
  208. package/dist/debugger/ui/command.d.ts +9 -0
  209. package/dist/debugger/ui/command.js +24 -0
  210. package/dist/debugger/ui/dropdown-menu.d.ts +13 -0
  211. package/dist/debugger/ui/dropdown-menu.js +37 -0
  212. package/dist/debugger/ui/panel.d.ts +14 -0
  213. package/dist/debugger/ui/panel.js +16 -0
  214. package/dist/debugger/ui/popover.d.ts +7 -0
  215. package/dist/debugger/ui/popover.js +17 -0
  216. package/dist/debugger/ui/resizable.d.ts +7 -0
  217. package/dist/debugger/ui/resizable.js +14 -0
  218. package/dist/debugger/ui/scroll-area.d.ts +2 -1
  219. package/dist/debugger/ui/scroll-area.js +5 -3
  220. package/dist/debugger/ui/select.d.ts +10 -0
  221. package/dist/debugger/ui/select.js +21 -0
  222. package/dist/debugger/ui/tabs.js +2 -2
  223. package/dist/debugger/ui/textarea.d.ts +3 -0
  224. package/dist/debugger/ui/textarea.js +7 -0
  225. package/dist/evaluator/definitions-store.d.ts +11 -0
  226. package/dist/evaluator/definitions-store.js +8 -0
  227. package/dist/evaluator/definitions.d.ts +18 -0
  228. package/dist/evaluator/definitions.js +4 -0
  229. package/dist/evaluator/effects.d.ts +226 -0
  230. package/dist/evaluator/effects.js +132 -0
  231. package/dist/evaluator/evaluator.d.ts +24 -0
  232. package/dist/evaluator/evaluator.js +67 -0
  233. package/dist/evaluator/events.d.ts +59 -0
  234. package/dist/evaluator/events.js +21 -0
  235. package/dist/evaluator/index.d.ts +11 -0
  236. package/dist/evaluator/index.js +11 -0
  237. package/dist/evaluator/module.d.ts +606 -0
  238. package/dist/evaluator/module.js +25 -0
  239. package/dist/evaluator/projections.d.ts +50 -0
  240. package/dist/evaluator/projections.js +20 -0
  241. package/dist/evaluator/scope.d.ts +59 -0
  242. package/dist/evaluator/scope.js +7 -0
  243. package/dist/evaluator/signals.d.ts +3 -0
  244. package/dist/evaluator/signals.js +17 -0
  245. package/dist/evaluator/threads.d.ts +62 -0
  246. package/dist/evaluator/threads.js +117 -0
  247. package/dist/evaluator/types.d.ts +125 -0
  248. package/dist/evaluator/types.js +51 -0
  249. package/dist/projectors/delivery.d.ts +83 -0
  250. package/dist/projectors/delivery.js +182 -0
  251. package/dist/projectors/index-model.d.ts +1 -1
  252. package/dist/projectors/index-model.js +4 -6
  253. package/dist/projectors/index.d.ts +2 -0
  254. package/dist/projectors/index.js +2 -0
  255. package/dist/projectors/memory.d.ts +1 -1
  256. package/dist/projectors/memory.js +10 -8
  257. package/dist/projectors/postgres.js +44 -58
  258. package/dist/projectors/projector.d.ts +17 -0
  259. package/dist/projectors/projector.js +26 -1
  260. package/dist/projectors/sqlite-delivery.d.ts +4 -0
  261. package/dist/projectors/sqlite-delivery.js +147 -0
  262. package/dist/projectors/sqlite.js +23 -23
  263. package/dist/projectors/with-projectors.d.ts +7 -2
  264. package/dist/projectors/with-projectors.js +27 -28
  265. package/dist/react/notify.js +11 -8
  266. package/dist/react/react.d.ts +2 -3
  267. package/dist/react/react.js +14 -30
  268. package/dist/react/sse.d.ts +1 -1
  269. package/dist/react/sse.js +1 -1
  270. package/dist/react/store.d.ts +3 -3
  271. package/dist/react/store.js +109 -119
  272. package/dist/runtime/cancellation.d.ts +16 -0
  273. package/dist/runtime/cancellation.js +129 -0
  274. package/dist/runtime/deadline-transition-planner.d.ts +31 -0
  275. package/dist/runtime/deadline-transition-planner.js +139 -0
  276. package/dist/runtime/dispatch-effect.d.ts +3 -2
  277. package/dist/runtime/dispatch-effect.js +7 -13
  278. package/dist/runtime/errors.d.ts +51 -0
  279. package/dist/runtime/errors.js +39 -0
  280. package/dist/runtime/{runtime-helpers.d.ts → helpers.d.ts} +24 -4
  281. package/dist/runtime/{runtime-helpers.js → helpers.js} +56 -19
  282. package/dist/runtime/index.d.ts +3 -3
  283. package/dist/runtime/index.js +3 -3
  284. package/dist/runtime/ingress.d.ts +15 -0
  285. package/dist/runtime/ingress.js +42 -0
  286. package/dist/runtime/local-effect-executor.d.ts +21 -0
  287. package/dist/runtime/local-effect-executor.js +137 -0
  288. package/dist/runtime/looms.d.ts +30 -4
  289. package/dist/runtime/looms.js +57 -37
  290. package/dist/runtime/observer.d.ts +45 -0
  291. package/dist/runtime/observer.js +11 -0
  292. package/dist/runtime/repository.d.ts +55 -0
  293. package/dist/runtime/repository.js +293 -0
  294. package/dist/runtime/retry-policy.d.ts +16 -0
  295. package/dist/runtime/retry-policy.js +29 -0
  296. package/dist/runtime/run-execution-context.d.ts +30 -0
  297. package/dist/runtime/run-execution-context.js +56 -0
  298. package/dist/runtime/run-start.d.ts +4 -0
  299. package/dist/runtime/run-start.js +44 -0
  300. package/dist/runtime/runtime.d.ts +6 -87
  301. package/dist/runtime/runtime.js +248 -470
  302. package/dist/runtime/server/auth.d.ts +41 -0
  303. package/dist/runtime/server/auth.js +45 -0
  304. package/dist/runtime/server/debugger-host.d.ts +11 -0
  305. package/dist/runtime/server/debugger-host.js +32 -0
  306. package/dist/runtime/server/fetch-handler.d.ts +18 -0
  307. package/dist/runtime/server/fetch-handler.js +62 -0
  308. package/dist/runtime/server/http.d.ts +38 -0
  309. package/dist/runtime/server/http.js +66 -0
  310. package/dist/runtime/server/route-table.d.ts +55 -0
  311. package/dist/runtime/server/route-table.js +74 -0
  312. package/dist/runtime/server/routes/definitions.d.ts +3 -0
  313. package/dist/runtime/server/routes/definitions.js +20 -0
  314. package/dist/runtime/server/routes/effects.d.ts +3 -0
  315. package/dist/runtime/server/routes/effects.js +59 -0
  316. package/dist/runtime/server/routes/operations.d.ts +3 -0
  317. package/dist/runtime/server/routes/operations.js +14 -0
  318. package/dist/runtime/server/routes/runs.d.ts +3 -0
  319. package/dist/runtime/server/routes/runs.js +199 -0
  320. package/dist/runtime/server.d.ts +4 -8
  321. package/dist/runtime/server.js +6 -211
  322. package/dist/runtime/sse.d.ts +2 -1
  323. package/dist/runtime/sse.js +24 -17
  324. package/dist/runtime/types.d.ts +117 -0
  325. package/dist/runtime/types.js +1 -0
  326. package/dist/runtime/wake-engine.d.ts +20 -0
  327. package/dist/runtime/wake-engine.js +311 -0
  328. package/dist/runtime/wake-scheduler.d.ts +3 -4
  329. package/dist/runtime/wake-scheduler.js +25 -31
  330. package/dist/runtime/worker-callbacks.d.ts +16 -0
  331. package/dist/runtime/worker-callbacks.js +167 -0
  332. package/dist/runtime/worker-effect-dispatch.d.ts +36 -0
  333. package/dist/runtime/worker-effect-dispatch.js +126 -0
  334. package/dist/s2/config.d.ts +1 -1
  335. package/dist/s2/config.js +1 -1
  336. package/dist/s2/lite.js +70 -82
  337. package/dist/s2/pagination.d.ts +15 -0
  338. package/dist/s2/pagination.js +36 -0
  339. package/dist/s2/projector.js +6 -5
  340. package/dist/s2/snapshot-store.js +188 -161
  341. package/dist/s2/store.d.ts +3 -21
  342. package/dist/s2/store.js +71 -165
  343. package/dist/testing/index.d.ts +15 -0
  344. package/dist/testing/index.js +53 -16
  345. package/dist/workflow/debugger/index.d.ts +4 -0
  346. package/dist/workflow/debugger/index.js +11 -0
  347. package/dist/workflow/debugger/nodes-view.d.ts +3 -0
  348. package/dist/workflow/debugger/nodes-view.js +13 -0
  349. package/dist/workflow/debugger/summarize.d.ts +2 -0
  350. package/dist/workflow/debugger/summarize.js +30 -0
  351. package/dist/workflow/definitions-store.d.ts +2 -3
  352. package/dist/workflow/definitions-store.js +2 -2
  353. package/dist/workflow/definitions.d.ts +78 -22
  354. package/dist/workflow/definitions.js +80 -14
  355. package/dist/workflow/effects.d.ts +453 -107
  356. package/dist/workflow/effects.js +214 -115
  357. package/dist/workflow/events.d.ts +149 -5
  358. package/dist/workflow/events.js +27 -5
  359. package/dist/workflow/graph.d.ts +56 -0
  360. package/dist/workflow/graph.js +207 -0
  361. package/dist/workflow/index.d.ts +1 -0
  362. package/dist/workflow/index.js +1 -0
  363. package/dist/workflow/module.d.ts +1047 -266
  364. package/dist/workflow/projections.d.ts +14 -12
  365. package/dist/workflow/projections.js +30 -8
  366. package/dist/workflow/scope.d.ts +146 -4
  367. package/dist/workflow/threads.d.ts +383 -155
  368. package/dist/workflow/threads.js +308 -110
  369. package/package.json +26 -2
  370. package/dist/debugger/events/domain-summarize.d.ts +0 -3
  371. package/dist/debugger/events/domain-summarize.js +0 -107
  372. package/dist/debugger/events/family.d.ts +0 -8
  373. package/dist/debugger/events/family.js +0 -44
  374. package/dist/runtime/events-api.d.ts +0 -4
  375. 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,1234 @@ 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
+ };
903
+ }>;
904
+ listRunSummaries: () => Promise<{
905
+ readonly runs: readonly {
906
+ readonly runId: string;
907
+ readonly status: "cancelled" | "completed" | "failed" | "running";
908
+ readonly kind: string | null;
909
+ readonly definitionName: string | null;
910
+ }[];
911
+ }>;
912
+ listDefinitions: () => Promise<{
913
+ readonly definitions: readonly {
914
+ readonly kind: string;
915
+ readonly name: string;
916
+ readonly version: string;
917
+ readonly description?: string | undefined;
918
+ readonly inputSchema?: Schema.Json | undefined;
919
+ }[];
920
+ readonly projections: readonly string[];
46
921
  }>;
47
922
  replayTo: (runId: string, seq: number) => Promise<{
48
- runId: string;
49
- step: unknown;
923
+ readonly runId: string;
924
+ readonly step: {
925
+ readonly seq: number;
926
+ readonly event: {
927
+ readonly id: string;
928
+ readonly runId: string;
929
+ readonly seq: number;
930
+ readonly ts: number;
931
+ readonly type: string;
932
+ readonly payload: Schema.Json;
933
+ readonly threadId: string | null;
934
+ readonly parentThreadId?: string | null | undefined;
935
+ readonly causationId?: string | null | undefined;
936
+ readonly correlationId?: string | null | undefined;
937
+ readonly effectId?: string | null | undefined;
938
+ readonly origin: {
939
+ readonly type: "thread";
940
+ readonly threadId: string;
941
+ } | {
942
+ readonly type: "external";
943
+ readonly actorId?: string | undefined;
944
+ } | {
945
+ readonly type: "system";
946
+ };
947
+ readonly ephemeral?: boolean | undefined;
948
+ readonly idempotencyKey?: string | null | undefined;
949
+ };
950
+ readonly before: {
951
+ readonly runId: string;
952
+ readonly status: "cancelled" | "completed" | "failed" | "running";
953
+ readonly rootThreadId: string | null;
954
+ readonly startIdentity: {
955
+ readonly kind: string;
956
+ readonly definitionName: string;
957
+ readonly definitionVersion: string;
958
+ readonly input: Schema.Json;
959
+ readonly requestedThreadId: string | null;
960
+ readonly idempotencyKey: string | null;
961
+ readonly rootThreadId: string;
962
+ } | null;
963
+ readonly threads: {
964
+ readonly [x: string]: {
965
+ readonly threadId: string;
966
+ readonly kind: string;
967
+ readonly definitionName: string;
968
+ readonly definitionVersion: string;
969
+ readonly parentThreadId: string | null;
970
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
971
+ readonly input: Schema.Json;
972
+ readonly output: Schema.Json;
973
+ readonly error: string | null;
974
+ readonly state: Schema.Json;
975
+ };
976
+ };
977
+ readonly waits: {
978
+ readonly [x: string]: {
979
+ readonly waitId: string;
980
+ readonly threadId: string;
981
+ readonly on: {
982
+ readonly type: string | readonly string[];
983
+ readonly match?: Schema.Json | undefined;
984
+ } | {
985
+ readonly timerAt: number;
986
+ };
987
+ readonly tag?: Schema.Json | undefined;
988
+ };
989
+ };
990
+ readonly outstandingEffects: readonly {
991
+ readonly effectId: string;
992
+ readonly threadId: string;
993
+ readonly causingSeq: number;
994
+ readonly causingEventId: string;
995
+ readonly effect: {
996
+ readonly type: "runtime.spawn";
997
+ readonly childThreadId: string;
998
+ readonly kind: string;
999
+ readonly definitionName: string;
1000
+ readonly definitionVersion: string;
1001
+ readonly input: Schema.Json;
1002
+ } | {
1003
+ readonly type: "runtime.wait";
1004
+ readonly waitId: string;
1005
+ readonly on: {
1006
+ readonly type: string | readonly string[];
1007
+ readonly match?: Schema.Json | undefined;
1008
+ } | {
1009
+ readonly timerAt: number;
1010
+ };
1011
+ readonly tag?: Schema.Json | undefined;
1012
+ } | {
1013
+ readonly type: "runtime.emit";
1014
+ readonly event: {
1015
+ readonly type: string;
1016
+ readonly payload: Schema.Json;
1017
+ readonly threadId?: string | null | undefined;
1018
+ readonly parentThreadId?: string | null | undefined;
1019
+ readonly causationId?: string | null | undefined;
1020
+ readonly correlationId?: string | null | undefined;
1021
+ readonly effectId?: string | null | undefined;
1022
+ readonly origin?: {
1023
+ readonly type: "thread";
1024
+ readonly threadId: string;
1025
+ } | {
1026
+ readonly type: "external";
1027
+ readonly actorId?: string | undefined;
1028
+ } | {
1029
+ readonly type: "system";
1030
+ } | undefined;
1031
+ readonly ephemeral?: boolean | undefined;
1032
+ readonly id?: string | undefined;
1033
+ readonly ts?: number | undefined;
1034
+ readonly idempotencyKey?: string | null | undefined;
1035
+ };
1036
+ readonly tag?: string | undefined;
1037
+ } | {
1038
+ readonly type: "runtime.complete";
1039
+ readonly output: Schema.Json;
1040
+ } | {
1041
+ readonly type: "runtime.fail";
1042
+ readonly error: string;
1043
+ } | {
1044
+ readonly type: "runtime.cancel";
1045
+ readonly threadId: string;
1046
+ readonly tag?: string | undefined;
1047
+ } | {
1048
+ readonly type: string;
1049
+ readonly input: Schema.Json;
1050
+ readonly tag?: string | undefined;
1051
+ };
1052
+ }[];
1053
+ readonly effectExecutions: {
1054
+ readonly [x: string]: {
1055
+ readonly effectId: string;
1056
+ readonly attempt: number;
1057
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
1058
+ readonly nextAttemptAt: number | null;
1059
+ readonly deadlineAt: number | null;
1060
+ readonly startedAt: number | null;
1061
+ readonly lastHeartbeatAt: number | null;
1062
+ readonly lastError: string | null;
1063
+ };
1064
+ };
1065
+ readonly completedEffectIds: readonly string[];
1066
+ readonly processedIdempotencyKeys: readonly string[];
1067
+ };
1068
+ readonly after: {
1069
+ readonly runId: string;
1070
+ readonly status: "cancelled" | "completed" | "failed" | "running";
1071
+ readonly rootThreadId: string | null;
1072
+ readonly startIdentity: {
1073
+ readonly kind: string;
1074
+ readonly definitionName: string;
1075
+ readonly definitionVersion: string;
1076
+ readonly input: Schema.Json;
1077
+ readonly requestedThreadId: string | null;
1078
+ readonly idempotencyKey: string | null;
1079
+ readonly rootThreadId: string;
1080
+ } | null;
1081
+ readonly threads: {
1082
+ readonly [x: string]: {
1083
+ readonly threadId: string;
1084
+ readonly kind: string;
1085
+ readonly definitionName: string;
1086
+ readonly definitionVersion: string;
1087
+ readonly parentThreadId: string | null;
1088
+ readonly status: "cancelled" | "completed" | "failed" | "running" | "waiting";
1089
+ readonly input: Schema.Json;
1090
+ readonly output: Schema.Json;
1091
+ readonly error: string | null;
1092
+ readonly state: Schema.Json;
1093
+ };
1094
+ };
1095
+ readonly waits: {
1096
+ readonly [x: string]: {
1097
+ readonly waitId: string;
1098
+ readonly threadId: string;
1099
+ readonly on: {
1100
+ readonly type: string | readonly string[];
1101
+ readonly match?: Schema.Json | undefined;
1102
+ } | {
1103
+ readonly timerAt: number;
1104
+ };
1105
+ readonly tag?: Schema.Json | undefined;
1106
+ };
1107
+ };
1108
+ readonly outstandingEffects: readonly {
1109
+ readonly effectId: string;
1110
+ readonly threadId: string;
1111
+ readonly causingSeq: number;
1112
+ readonly causingEventId: string;
1113
+ readonly effect: {
1114
+ readonly type: "runtime.spawn";
1115
+ readonly childThreadId: string;
1116
+ readonly kind: string;
1117
+ readonly definitionName: string;
1118
+ readonly definitionVersion: string;
1119
+ readonly input: Schema.Json;
1120
+ } | {
1121
+ readonly type: "runtime.wait";
1122
+ readonly waitId: string;
1123
+ readonly on: {
1124
+ readonly type: string | readonly string[];
1125
+ readonly match?: Schema.Json | undefined;
1126
+ } | {
1127
+ readonly timerAt: number;
1128
+ };
1129
+ readonly tag?: Schema.Json | undefined;
1130
+ } | {
1131
+ readonly type: "runtime.emit";
1132
+ readonly event: {
1133
+ readonly type: string;
1134
+ readonly payload: Schema.Json;
1135
+ readonly threadId?: string | null | undefined;
1136
+ readonly parentThreadId?: string | null | undefined;
1137
+ readonly causationId?: string | null | undefined;
1138
+ readonly correlationId?: string | null | undefined;
1139
+ readonly effectId?: string | null | undefined;
1140
+ readonly origin?: {
1141
+ readonly type: "thread";
1142
+ readonly threadId: string;
1143
+ } | {
1144
+ readonly type: "external";
1145
+ readonly actorId?: string | undefined;
1146
+ } | {
1147
+ readonly type: "system";
1148
+ } | undefined;
1149
+ readonly ephemeral?: boolean | undefined;
1150
+ readonly id?: string | undefined;
1151
+ readonly ts?: number | undefined;
1152
+ readonly idempotencyKey?: string | null | undefined;
1153
+ };
1154
+ readonly tag?: string | undefined;
1155
+ } | {
1156
+ readonly type: "runtime.complete";
1157
+ readonly output: Schema.Json;
1158
+ } | {
1159
+ readonly type: "runtime.fail";
1160
+ readonly error: string;
1161
+ } | {
1162
+ readonly type: "runtime.cancel";
1163
+ readonly threadId: string;
1164
+ readonly tag?: string | undefined;
1165
+ } | {
1166
+ readonly type: string;
1167
+ readonly input: Schema.Json;
1168
+ readonly tag?: string | undefined;
1169
+ };
1170
+ }[];
1171
+ readonly effectExecutions: {
1172
+ readonly [x: string]: {
1173
+ readonly effectId: string;
1174
+ readonly attempt: number;
1175
+ readonly status: "ambiguous" | "cancel_requested" | "dispatched" | "heartbeat" | "queued" | "retry_wait" | "running" | "started" | "timed_out";
1176
+ readonly nextAttemptAt: number | null;
1177
+ readonly deadlineAt: number | null;
1178
+ readonly startedAt: number | null;
1179
+ readonly lastHeartbeatAt: number | null;
1180
+ readonly lastError: string | null;
1181
+ };
1182
+ };
1183
+ readonly completedEffectIds: readonly string[];
1184
+ readonly processedIdempotencyKeys: readonly string[];
1185
+ };
1186
+ readonly effects: readonly ({
1187
+ readonly type: "runtime.spawn";
1188
+ readonly childThreadId: string;
1189
+ readonly kind: string;
1190
+ readonly definitionName: string;
1191
+ readonly definitionVersion: string;
1192
+ readonly input: Schema.Json;
1193
+ } | {
1194
+ readonly type: "runtime.wait";
1195
+ readonly waitId: string;
1196
+ readonly on: {
1197
+ readonly type: string | readonly string[];
1198
+ readonly match?: Schema.Json | undefined;
1199
+ } | {
1200
+ readonly timerAt: number;
1201
+ };
1202
+ readonly tag?: Schema.Json | undefined;
1203
+ } | {
1204
+ readonly type: "runtime.emit";
1205
+ readonly event: {
1206
+ readonly type: string;
1207
+ readonly payload: Schema.Json;
1208
+ readonly threadId?: string | null | undefined;
1209
+ readonly parentThreadId?: string | null | undefined;
1210
+ readonly causationId?: string | null | undefined;
1211
+ readonly correlationId?: string | null | undefined;
1212
+ readonly effectId?: string | null | undefined;
1213
+ readonly origin?: {
1214
+ readonly type: "thread";
1215
+ readonly threadId: string;
1216
+ } | {
1217
+ readonly type: "external";
1218
+ readonly actorId?: string | undefined;
1219
+ } | {
1220
+ readonly type: "system";
1221
+ } | undefined;
1222
+ readonly ephemeral?: boolean | undefined;
1223
+ readonly id?: string | undefined;
1224
+ readonly ts?: number | undefined;
1225
+ readonly idempotencyKey?: string | null | undefined;
1226
+ };
1227
+ readonly tag?: string | undefined;
1228
+ } | {
1229
+ readonly type: "runtime.complete";
1230
+ readonly output: Schema.Json;
1231
+ } | {
1232
+ readonly type: "runtime.fail";
1233
+ readonly error: string;
1234
+ } | {
1235
+ readonly type: "runtime.cancel";
1236
+ readonly threadId: string;
1237
+ readonly tag?: string | undefined;
1238
+ } | {
1239
+ readonly type: string;
1240
+ readonly input: Schema.Json;
1241
+ readonly tag?: string | undefined;
1242
+ })[];
1243
+ } | null;
50
1244
  }>;
51
1245
  project: (runId: string, name: string) => Promise<{
52
- runId: string;
53
- name: string;
54
- value: unknown;
1246
+ readonly runId: string;
1247
+ readonly name: string;
1248
+ readonly value: unknown;
55
1249
  }>;
56
1250
  subscribeEvents: (runId: string, onEvent: (event: EventEnvelope) => void, reconnectDelayMs?: number) => () => void;
57
1251
  /**
@@ -61,6 +1255,7 @@ export declare function createLoomsClient(options?: LoomsClientOptions): {
61
1255
  streamRun: (args: {
62
1256
  kind: string;
63
1257
  definitionName: string;
1258
+ definitionVersion?: string;
64
1259
  input?: JsonValue;
65
1260
  runId?: string;
66
1261
  }) => StreamHandle;