rivetkit 0.0.0-sqlite-profiling-compat.87d61c0 → 0.0.0-sqlite-sync-3x-release.a00b07f

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 (277) hide show
  1. package/dist/browser/client.d.ts +1317 -765
  2. package/dist/browser/client.js +1457 -737
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +252 -129
  5. package/dist/browser/inspector/client.js +2042 -228
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/actor/errors.cjs +6 -2
  8. package/dist/tsup/actor/errors.cjs.map +1 -1
  9. package/dist/tsup/actor/errors.d.cts +1 -1
  10. package/dist/tsup/actor/errors.d.ts +1 -1
  11. package/dist/tsup/actor/errors.js +5 -1
  12. package/dist/tsup/agent-os/index.cjs +3 -2367
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +1 -2277
  15. package/dist/tsup/agent-os/index.d.ts +1 -2277
  16. package/dist/tsup/agent-os/index.js +3 -2367
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-E4LNLI3W.cjs → chunk-2MOLY6AM.cjs} +444 -29
  19. package/dist/tsup/chunk-2MOLY6AM.cjs.map +1 -0
  20. package/dist/tsup/{chunk-OAUFXOG7.js → chunk-3DONDAMG.js} +2 -2
  21. package/dist/tsup/{chunk-XIX5DOZN.js → chunk-6FEYCVZC.js} +196 -20
  22. package/dist/tsup/chunk-6FEYCVZC.js.map +1 -0
  23. package/dist/tsup/chunk-6KXVLIXL.cjs +14 -0
  24. package/dist/tsup/chunk-6KXVLIXL.cjs.map +1 -0
  25. package/dist/tsup/chunk-73RNTXHB.cjs +243 -0
  26. package/dist/tsup/chunk-73RNTXHB.cjs.map +1 -0
  27. package/dist/tsup/{chunk-HXUEHHJF.js → chunk-A2CF6PFH.js} +19 -11
  28. package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
  29. package/dist/tsup/{chunk-EFU4JW3T.js → chunk-BRH4PQS5.js} +436 -21
  30. package/dist/tsup/chunk-BRH4PQS5.js.map +1 -0
  31. package/dist/tsup/{chunk-GM45LG7L.cjs → chunk-BTSDFFDC.cjs} +18 -11
  32. package/dist/tsup/chunk-BTSDFFDC.cjs.map +1 -0
  33. package/dist/tsup/{chunk-B3GLD4IN.js → chunk-D5WUPE47.js} +50 -3
  34. package/dist/tsup/chunk-D5WUPE47.js.map +1 -0
  35. package/dist/tsup/{chunk-O3ZUMAN7.js → chunk-DJUBJQEQ.js} +3 -3
  36. package/dist/tsup/chunk-DJUBJQEQ.js.map +1 -0
  37. package/dist/tsup/{chunk-3MHDOUD7.cjs → chunk-HDVZ6YZG.cjs} +197 -21
  38. package/dist/tsup/chunk-HDVZ6YZG.cjs.map +1 -0
  39. package/dist/tsup/{chunk-JZ7TWV65.js → chunk-JTHHCZCZ.js} +24 -1
  40. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  41. package/dist/tsup/{chunk-D363DMNH.cjs → chunk-JUHXV3HF.cjs} +3 -3
  42. package/dist/tsup/chunk-JUHXV3HF.cjs.map +1 -0
  43. package/dist/tsup/chunk-JUWMP5O3.js +14 -0
  44. package/dist/tsup/chunk-JUWMP5O3.js.map +1 -0
  45. package/dist/tsup/{chunk-ZA7FLHKH.cjs → chunk-KVFIONKQ.cjs} +25 -2
  46. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  47. package/dist/tsup/{chunk-4FC7TVS6.cjs → chunk-MGI2VVF6.cjs} +39 -7
  48. package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
  49. package/dist/tsup/{chunk-BWERJMV6.cjs → chunk-OTVJYZ2L.cjs} +1139 -470
  50. package/dist/tsup/chunk-OTVJYZ2L.cjs.map +1 -0
  51. package/dist/tsup/{chunk-VE2X4KMG.cjs → chunk-RTWH3AX3.cjs} +18 -10
  52. package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
  53. package/dist/tsup/{chunk-DTRDGPHU.cjs → chunk-TM76Z7XT.cjs} +7 -7
  54. package/dist/tsup/chunk-TM76Z7XT.cjs.map +1 -0
  55. package/dist/tsup/{chunk-3GVMLSND.js → chunk-TRUHDXOU.js} +1023 -354
  56. package/dist/tsup/chunk-TRUHDXOU.js.map +1 -0
  57. package/dist/tsup/{chunk-PT7AC5PC.js → chunk-TSQTI6H6.js} +16 -9
  58. package/dist/tsup/chunk-TSQTI6H6.js.map +1 -0
  59. package/dist/tsup/{chunk-FNAXD5BQ.cjs → chunk-Z7E2G3JZ.cjs} +52 -5
  60. package/dist/tsup/chunk-Z7E2G3JZ.cjs.map +1 -0
  61. package/dist/tsup/{chunk-ZZ3WBRPD.js → chunk-ZOVJDAOW.js} +38 -6
  62. package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
  63. package/dist/tsup/chunk-ZYK4B5WV.js +243 -0
  64. package/dist/tsup/chunk-ZYK4B5WV.js.map +1 -0
  65. package/dist/tsup/client/mod.cjs +8 -9
  66. package/dist/tsup/client/mod.cjs.map +1 -1
  67. package/dist/tsup/client/mod.d.cts +32 -6
  68. package/dist/tsup/client/mod.d.ts +32 -6
  69. package/dist/tsup/client/mod.js +7 -8
  70. package/dist/tsup/common/log.cjs +5 -3
  71. package/dist/tsup/common/log.cjs.map +1 -1
  72. package/dist/tsup/common/log.d.cts +5 -1
  73. package/dist/tsup/common/log.d.ts +5 -1
  74. package/dist/tsup/common/log.js +6 -4
  75. package/dist/tsup/common/websocket.cjs +4 -4
  76. package/dist/tsup/common/websocket.cjs.map +1 -1
  77. package/dist/tsup/common/websocket.js +3 -3
  78. package/dist/tsup/{config-BR1Nn0QQ.d.ts → config-B4erdavw.d.ts} +571 -65
  79. package/dist/tsup/{config-B0LNDrLY.d.cts → config-BfG1qpYz.d.cts} +80 -14
  80. package/dist/tsup/{config-B0LNDrLY.d.ts → config-BfG1qpYz.d.ts} +80 -14
  81. package/dist/tsup/{config-tCvkwzyN.d.cts → config-DK144OAw.d.cts} +571 -65
  82. package/dist/tsup/{context-D4WDwf9m.d.cts → context-Cvnf3BRe.d.cts} +3 -2
  83. package/dist/tsup/{context-oc9zhA3x.d.ts → context-Oxi6YWcG.d.ts} +3 -2
  84. package/dist/tsup/db/drizzle.cjs +127 -67
  85. package/dist/tsup/db/drizzle.cjs.map +1 -1
  86. package/dist/tsup/db/drizzle.d.cts +8 -4
  87. package/dist/tsup/db/drizzle.d.ts +8 -4
  88. package/dist/tsup/db/drizzle.js +127 -67
  89. package/dist/tsup/db/drizzle.js.map +1 -1
  90. package/dist/tsup/db/mod.cjs +6 -126
  91. package/dist/tsup/db/mod.cjs.map +1 -1
  92. package/dist/tsup/db/mod.d.cts +8 -4
  93. package/dist/tsup/db/mod.d.ts +8 -4
  94. package/dist/tsup/db/mod.js +5 -125
  95. package/dist/tsup/db/mod.js.map +1 -1
  96. package/dist/tsup/dynamic/mod.cjs +2 -2
  97. package/dist/tsup/dynamic/mod.cjs.map +1 -1
  98. package/dist/tsup/dynamic/mod.d.cts +6 -4
  99. package/dist/tsup/dynamic/mod.d.ts +6 -4
  100. package/dist/tsup/dynamic/mod.js +1 -1
  101. package/dist/tsup/inspector/mod.cjs +47 -12
  102. package/dist/tsup/inspector/mod.cjs.map +1 -1
  103. package/dist/tsup/inspector/mod.d.cts +26 -136
  104. package/dist/tsup/inspector/mod.d.ts +26 -136
  105. package/dist/tsup/inspector/mod.js +46 -11
  106. package/dist/tsup/inspector/mod.js.map +1 -1
  107. package/dist/tsup/inspector/workflow.cjs +21 -0
  108. package/dist/tsup/inspector/workflow.cjs.map +1 -0
  109. package/dist/tsup/inspector/workflow.d.cts +144 -0
  110. package/dist/tsup/inspector/workflow.d.ts +144 -0
  111. package/dist/tsup/inspector/workflow.js +21 -0
  112. package/dist/tsup/inspector/workflow.js.map +1 -0
  113. package/dist/tsup/inspector-tab/mod.cjs +2 -13
  114. package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
  115. package/dist/tsup/inspector-tab/mod.d.cts +9 -17
  116. package/dist/tsup/inspector-tab/mod.d.ts +9 -17
  117. package/dist/tsup/inspector-tab/mod.js +1 -12
  118. package/dist/tsup/inspector-tab/mod.js.map +1 -1
  119. package/dist/tsup/mod.cjs +2724 -611
  120. package/dist/tsup/mod.cjs.map +1 -1
  121. package/dist/tsup/mod.d.cts +9 -7
  122. package/dist/tsup/mod.d.ts +9 -7
  123. package/dist/tsup/mod.js +2641 -528
  124. package/dist/tsup/mod.js.map +1 -1
  125. package/dist/tsup/test/mod.cjs +19 -17
  126. package/dist/tsup/test/mod.cjs.map +1 -1
  127. package/dist/tsup/test/mod.d.cts +6 -4
  128. package/dist/tsup/test/mod.d.ts +6 -4
  129. package/dist/tsup/test/mod.js +18 -16
  130. package/dist/tsup/test/mod.js.map +1 -1
  131. package/dist/tsup/unstable/migrations.cjs +101 -0
  132. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  133. package/dist/tsup/unstable/migrations.d.cts +29 -0
  134. package/dist/tsup/unstable/migrations.d.ts +29 -0
  135. package/dist/tsup/unstable/migrations.js +101 -0
  136. package/dist/tsup/unstable/migrations.js.map +1 -0
  137. package/dist/tsup/{utils-CqDnC_PS.d.cts → utils-3rsE0JvI.d.cts} +25 -2
  138. package/dist/tsup/{utils-CqDnC_PS.d.ts → utils-3rsE0JvI.d.ts} +25 -2
  139. package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
  140. package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
  141. package/dist/tsup/utils.cjs +7 -3
  142. package/dist/tsup/utils.cjs.map +1 -1
  143. package/dist/tsup/utils.d.cts +4 -147
  144. package/dist/tsup/utils.d.ts +4 -147
  145. package/dist/tsup/utils.js +6 -2
  146. package/dist/tsup/workflow/mod.cjs +260 -200
  147. package/dist/tsup/workflow/mod.cjs.map +1 -1
  148. package/dist/tsup/workflow/mod.d.cts +8 -6
  149. package/dist/tsup/workflow/mod.d.ts +8 -6
  150. package/dist/tsup/workflow/mod.js +249 -189
  151. package/dist/tsup/workflow/mod.js.map +1 -1
  152. package/package.json +34 -14
  153. package/src/actor/actions.ts +155 -0
  154. package/src/actor/config.ts +403 -43
  155. package/src/actor/definition.ts +26 -7
  156. package/src/actor/errors.ts +87 -5
  157. package/src/actor/keys.ts +86 -0
  158. package/src/actor/mod.ts +15 -1
  159. package/src/actor/tracing.ts +28 -0
  160. package/src/agent-os/index.ts +5 -65
  161. package/src/client/actor-common.ts +8 -15
  162. package/src/client/actor-conn.ts +135 -8
  163. package/src/client/actor-handle.ts +180 -42
  164. package/src/client/actor-query.ts +8 -1
  165. package/src/client/auth.ts +37 -0
  166. package/src/client/client.ts +89 -21
  167. package/src/client/config.ts +27 -2
  168. package/src/client/errors.ts +2 -1
  169. package/src/client/lifecycle-errors.ts +16 -1
  170. package/src/client/mod.ts +9 -0
  171. package/src/client/outbound-telemetry.ts +66 -0
  172. package/src/client/query.ts +2 -0
  173. package/src/client/queue.ts +3 -0
  174. package/src/client/raw-utils.ts +37 -8
  175. package/src/client/resolve-gateway-target.ts +2 -0
  176. package/src/client/retry-budget.ts +78 -0
  177. package/src/client/token-provider.ts +93 -0
  178. package/src/client/utils.ts +16 -2
  179. package/src/common/actor-router-consts.ts +5 -0
  180. package/src/common/actor-telemetry-context.ts +19 -0
  181. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
  182. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  183. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  184. package/src/common/bare/transport/v1.ts +36 -0
  185. package/src/common/database/config.ts +108 -15
  186. package/src/common/database/mod.ts +247 -76
  187. package/src/common/database/native-database.ts +433 -23
  188. package/src/common/database/shared.ts +24 -0
  189. package/src/common/encoding.ts +31 -21
  190. package/src/common/fetch-like.ts +63 -0
  191. package/src/common/inspector-transport.ts +12 -2
  192. package/src/common/log.ts +14 -8
  193. package/src/common/otel-context.ts +99 -0
  194. package/src/common/router.ts +1 -1
  195. package/src/common/utils.ts +7 -19
  196. package/src/db/drizzle.ts +182 -80
  197. package/src/db/mod.ts +2 -0
  198. package/src/dynamic/isolate-runtime.ts +0 -2
  199. package/src/engine-api/actors.ts +3 -3
  200. package/src/engine-client/actor-http-client.ts +29 -20
  201. package/src/engine-client/actor-websocket-client.ts +6 -3
  202. package/src/engine-client/api-endpoints.ts +72 -14
  203. package/src/engine-client/driver.ts +8 -15
  204. package/src/engine-client/mod.ts +248 -112
  205. package/src/inspector/client.browser.ts +134 -16
  206. package/src/inspector/mod.ts +1 -1
  207. package/src/inspector/workflow.ts +61 -0
  208. package/src/inspector-tab/mod.ts +1 -15
  209. package/src/registry/config/envoy.ts +2 -18
  210. package/src/registry/config/index.ts +53 -61
  211. package/src/registry/index.ts +311 -21
  212. package/src/registry/napi-runtime.ts +583 -39
  213. package/src/registry/native-http.ts +225 -0
  214. package/src/registry/native.ts +1365 -414
  215. package/src/registry/run-handler-coordinator.ts +219 -0
  216. package/src/registry/runtime.ts +372 -7
  217. package/src/registry/wasm-runtime.ts +490 -21
  218. package/src/registry/write-through-proxy.ts +101 -0
  219. package/src/test/mod.ts +1 -19
  220. package/src/test/ready.ts +22 -0
  221. package/src/unstable/migrations.ts +141 -0
  222. package/src/utils/env-vars.ts +15 -6
  223. package/src/utils/node.ts +44 -28
  224. package/src/utils.ts +3 -0
  225. package/src/workflow/context.ts +9 -27
  226. package/src/workflow/driver.ts +253 -116
  227. package/src/workflow/inspector.ts +23 -24
  228. package/src/workflow/mod.ts +50 -72
  229. package/dist/tsup/chunk-3GVMLSND.js.map +0 -1
  230. package/dist/tsup/chunk-3MHDOUD7.cjs.map +0 -1
  231. package/dist/tsup/chunk-4FC7TVS6.cjs.map +0 -1
  232. package/dist/tsup/chunk-B3GLD4IN.js.map +0 -1
  233. package/dist/tsup/chunk-BWERJMV6.cjs.map +0 -1
  234. package/dist/tsup/chunk-D363DMNH.cjs.map +0 -1
  235. package/dist/tsup/chunk-DTRDGPHU.cjs.map +0 -1
  236. package/dist/tsup/chunk-E4LNLI3W.cjs.map +0 -1
  237. package/dist/tsup/chunk-EFU4JW3T.js.map +0 -1
  238. package/dist/tsup/chunk-FNAXD5BQ.cjs.map +0 -1
  239. package/dist/tsup/chunk-GM45LG7L.cjs.map +0 -1
  240. package/dist/tsup/chunk-HXUEHHJF.js.map +0 -1
  241. package/dist/tsup/chunk-JZ7TWV65.js.map +0 -1
  242. package/dist/tsup/chunk-O3ZUMAN7.js.map +0 -1
  243. package/dist/tsup/chunk-P6F5MEWX.cjs +0 -382
  244. package/dist/tsup/chunk-P6F5MEWX.cjs.map +0 -1
  245. package/dist/tsup/chunk-PT7AC5PC.js.map +0 -1
  246. package/dist/tsup/chunk-UV7INX3N.js +0 -382
  247. package/dist/tsup/chunk-UV7INX3N.js.map +0 -1
  248. package/dist/tsup/chunk-VE2X4KMG.cjs.map +0 -1
  249. package/dist/tsup/chunk-XIX5DOZN.js.map +0 -1
  250. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +0 -1
  251. package/dist/tsup/chunk-ZZ3WBRPD.js.map +0 -1
  252. package/src/actor/driver.ts +0 -141
  253. package/src/actor/instance/mod.ts +0 -2484
  254. package/src/actor/keys.test.ts +0 -275
  255. package/src/actor/utils.test.ts +0 -48
  256. package/src/agent-os/actor/cron.ts +0 -84
  257. package/src/agent-os/actor/db.ts +0 -54
  258. package/src/agent-os/actor/filesystem.ts +0 -131
  259. package/src/agent-os/actor/index.ts +0 -285
  260. package/src/agent-os/actor/network.ts +0 -58
  261. package/src/agent-os/actor/preview.ts +0 -190
  262. package/src/agent-os/actor/process.ts +0 -177
  263. package/src/agent-os/actor/session.ts +0 -518
  264. package/src/agent-os/actor/shell.ts +0 -60
  265. package/src/agent-os/config.ts +0 -79
  266. package/src/agent-os/fs/database-vfs.ts +0 -624
  267. package/src/agent-os/types.ts +0 -148
  268. package/src/client/test.ts +0 -44
  269. package/src/common/database/mod.test.ts +0 -137
  270. package/src/common/database/native-database.test.ts +0 -211
  271. package/src/common/inline-websocket-adapter.test.ts +0 -51
  272. package/src/drivers/engine/actor-driver.ts +0 -2473
  273. package/src/registry/process-metrics.ts +0 -250
  274. package/src/registry/runtime.test.ts +0 -50
  275. package/src/utils/endpoint-parser.test.ts +0 -206
  276. package/src/utils.test.ts +0 -34
  277. /package/dist/tsup/{chunk-OAUFXOG7.js.map → chunk-3DONDAMG.js.map} +0 -0
@@ -1,24 +1,23 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2;
2
2
 
3
- var _chunkGM45LG7Lcjs = require('../chunk-GM45LG7L.cjs');
3
+ var _chunkBTSDFFDCcjs = require('../chunk-BTSDFFDC.cjs');
4
+ require('../chunk-6KXVLIXL.cjs');
4
5
 
5
6
 
6
7
 
8
+ var _chunkHDVZ6YZGcjs = require('../chunk-HDVZ6YZG.cjs');
9
+ require('../chunk-Z7E2G3JZ.cjs');
7
10
 
8
- var _chunk3MHDOUD7cjs = require('../chunk-3MHDOUD7.cjs');
9
- require('../chunk-FNAXD5BQ.cjs');
10
11
 
11
12
 
13
+ var _chunkRTWH3AX3cjs = require('../chunk-RTWH3AX3.cjs');
12
14
 
13
- var _chunkVE2X4KMGcjs = require('../chunk-VE2X4KMG.cjs');
14
- require('../chunk-P6F5MEWX.cjs');
15
15
 
16
+ var _chunk2MOLY6AMcjs = require('../chunk-2MOLY6AM.cjs');
16
17
 
17
- var _chunkE4LNLI3Wcjs = require('../chunk-E4LNLI3W.cjs');
18
18
 
19
19
 
20
-
21
- var _chunk4FC7TVS6cjs = require('../chunk-4FC7TVS6.cjs');
20
+ var _chunkMGI2VVF6cjs = require('../chunk-MGI2VVF6.cjs');
22
21
 
23
22
  // src/workflow/mod.ts
24
23
 
@@ -283,35 +282,19 @@ var WorkflowContext = class _WorkflowContext {
283
282
  async removed(name, originalType) {
284
283
  await this.#wrapActive(() => this.#inner.removed(name, originalType));
285
284
  }
285
+ getVersion(name, latest) {
286
+ return this.#wrapActive(() => this.#inner.getVersion(name, latest));
287
+ }
286
288
  isEvicted() {
287
289
  return this.#inner.isEvicted();
288
290
  }
289
- // Runs a user step body inside a fresh step context, snapshotting actor
290
- // state/vars so a thrown step rolls back its mutations, and deactivating the
291
- // step context once the body settles so it cannot be used after the step.
291
+ // Runs a user step body inside a fresh step context and deactivates the step
292
+ // context once the body settles. Workflows are roll-forward only, so state and
293
+ // vars mutations made before a failure always remain visible.
292
294
  async #runStep(run) {
293
295
  const stepCtx = new WorkflowStepContext(this.#runCtx, () => this.#markGuardTriggered());
294
- let stateSnapshot = null;
295
- try {
296
- stateSnapshot = { state: this.#runCtx[_chunk3MHDOUD7cjs.RAW_STATE_SYMBOL]() };
297
- } catch (error) {
298
- this.#runCtx.log.debug({
299
- msg: "failed to get state, likely due to being stateless workflow",
300
- error
301
- });
302
- }
303
- if (stateSnapshot) {
304
- stateSnapshot.state = structuredClone(stateSnapshot.state);
305
- }
306
- const varsSnapshot = structuredClone(this.#runCtx.vars);
307
296
  try {
308
297
  return await run(stepCtx);
309
- } catch (error) {
310
- if (stateSnapshot) {
311
- this.#runCtx.state = stateSnapshot.state;
312
- }
313
- this.#runCtx.vars = varsSnapshot;
314
- throw error;
315
298
  } finally {
316
299
  stepCtx[DEACTIVATE_STEP]();
317
300
  }
@@ -331,8 +314,7 @@ var WorkflowContext = class _WorkflowContext {
331
314
  ...message.complete ? { complete: message.complete } : {}
332
315
  };
333
316
  }
334
- // Runs a step rollback compensation with an active step context. Rollbacks
335
- // intentionally mutate actor state, so their writes are not snapshotted.
317
+ // Runs a step rollback compensation with an active step context.
336
318
  async #runRollback(rollback, output) {
337
319
  const stepCtx = new WorkflowStepContext(this.#runCtx, () => this.#markGuardTriggered());
338
320
  try {
@@ -373,7 +355,9 @@ var WorkflowContext = class _WorkflowContext {
373
355
  };
374
356
 
375
357
  // src/workflow/driver.ts
376
- var WORKFLOW_STORAGE_PREFIX = _chunkVE2X4KMGcjs.workflowStoragePrefix.call(void 0, );
358
+ var WORKFLOW_STORAGE_PREFIX = _chunkRTWH3AX3cjs.workflowStoragePrefix.call(void 0, );
359
+ var WORKFLOW_SQLITE_MAX_BATCH_ROWS = 128;
360
+ var WORKFLOW_SQLITE_MAX_BATCH_BYTES = 512 * 1024;
377
361
  function stripWorkflowKey(prefixed) {
378
362
  return prefixed.slice(WORKFLOW_STORAGE_PREFIX.length);
379
363
  }
@@ -387,6 +371,170 @@ function computeUpperBound(prefix) {
387
371
  }
388
372
  return null;
389
373
  }
374
+ function normalizeSqlBlob(value) {
375
+ if (value instanceof Uint8Array) {
376
+ return value;
377
+ }
378
+ if (value instanceof ArrayBuffer) {
379
+ return new Uint8Array(value);
380
+ }
381
+ if (ArrayBuffer.isView(value)) {
382
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
383
+ }
384
+ if (Array.isArray(value)) {
385
+ const bytes = new Uint8Array(value.length);
386
+ for (const [i, item] of value.entries()) {
387
+ if (!Number.isInteger(item) || item < 0 || item > 255) {
388
+ throw new Error("workflow sqlite value was not a byte array");
389
+ }
390
+ bytes[i] = item;
391
+ }
392
+ return bytes;
393
+ }
394
+ throw new Error("workflow sqlite value was not a blob");
395
+ }
396
+ function runtimeDbFromContext(runCtx) {
397
+ const db = runCtx == null ? void 0 : runCtx.db;
398
+ if (db && typeof db === "object" && "execute" in db && "transaction" in db) {
399
+ return db;
400
+ }
401
+ return void 0;
402
+ }
403
+ var WorkflowStorage = class {
404
+ #db;
405
+ constructor(db) {
406
+ if (!db) {
407
+ throw new Error(
408
+ "workflow storage requires embedded SQLite; actor KV workflow storage is no longer supported"
409
+ );
410
+ }
411
+ this.#db = db;
412
+ }
413
+ async get(key) {
414
+ var _a;
415
+ const prefixed = _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, key);
416
+ const rows = await this.#db.execute(
417
+ "SELECT value FROM _rivet_wf_kv WHERE key = ?",
418
+ prefixed
419
+ );
420
+ return ((_a = rows[0]) == null ? void 0 : _a.value) == null ? null : normalizeSqlBlob(rows[0].value);
421
+ }
422
+ async set(key, value) {
423
+ await this.batch([{ key, value }]);
424
+ }
425
+ async delete(key) {
426
+ const prefixed = _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, key);
427
+ await this.#db.execute(
428
+ "DELETE FROM _rivet_wf_kv WHERE key = ?",
429
+ prefixed
430
+ );
431
+ }
432
+ async batchDelete(keys) {
433
+ if (keys.length === 0) return;
434
+ await this.deleteRawKeys(keys.map((key) => _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, key)));
435
+ }
436
+ async deletePrefix(prefix) {
437
+ const start = _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, prefix);
438
+ const end = computeUpperBound(start);
439
+ if (end) {
440
+ await this.#db.execute(
441
+ "DELETE FROM _rivet_wf_kv WHERE key >= ? AND key < ?",
442
+ start,
443
+ end
444
+ );
445
+ return;
446
+ }
447
+ const entries = await this.listRaw(start);
448
+ await this.deleteRawKeys(
449
+ entries.filter(([key]) => keyStartsWith(key, start)).map(([key]) => key)
450
+ );
451
+ }
452
+ async deleteRange(start, end) {
453
+ const prefixedStart = _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, start);
454
+ const prefixedEnd = _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, end);
455
+ await this.#db.execute(
456
+ "DELETE FROM _rivet_wf_kv WHERE key >= ? AND key < ?",
457
+ prefixedStart,
458
+ prefixedEnd
459
+ );
460
+ }
461
+ async list(prefix) {
462
+ const prefixed = _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, prefix);
463
+ const entries = await this.listRaw(prefixed);
464
+ return entries.filter(([key]) => keyStartsWith(key, prefixed)).map(([key, value]) => ({
465
+ key: stripWorkflowKey(key),
466
+ value
467
+ }));
468
+ }
469
+ async batch(writes) {
470
+ if (writes.length === 0) return;
471
+ for (const chunk of chunkWorkflowWrites(writes)) {
472
+ await this.#db.transaction(async (tx) => {
473
+ for (const { key, value } of chunk) {
474
+ await tx.execute(
475
+ "INSERT INTO _rivet_wf_kv (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
476
+ _chunkRTWH3AX3cjs.makeWorkflowKey.call(void 0, key),
477
+ value
478
+ );
479
+ }
480
+ });
481
+ }
482
+ }
483
+ async listRaw(prefix) {
484
+ const end = computeUpperBound(prefix);
485
+ const rows = end ? await this.#db.execute(
486
+ "SELECT key, value FROM _rivet_wf_kv WHERE key >= ? AND key < ? ORDER BY key ASC",
487
+ prefix,
488
+ end
489
+ ) : await this.#db.execute(
490
+ "SELECT key, value FROM _rivet_wf_kv WHERE key >= ? ORDER BY key ASC",
491
+ prefix
492
+ );
493
+ return rows.map((row) => [
494
+ normalizeSqlBlob(row.key),
495
+ normalizeSqlBlob(row.value)
496
+ ]);
497
+ }
498
+ async deleteRawKeys(keys) {
499
+ for (let start = 0; start < keys.length; start += WORKFLOW_SQLITE_MAX_BATCH_ROWS) {
500
+ await this.#db.transaction(async (tx) => {
501
+ for (const key of keys.slice(
502
+ start,
503
+ start + WORKFLOW_SQLITE_MAX_BATCH_ROWS
504
+ )) {
505
+ await tx.execute(
506
+ "DELETE FROM _rivet_wf_kv WHERE key = ?",
507
+ key
508
+ );
509
+ }
510
+ });
511
+ }
512
+ }
513
+ };
514
+ function chunkWorkflowWrites(writes) {
515
+ const chunks = [];
516
+ let chunk = [];
517
+ let chunkBytes = 0;
518
+ for (const write of writes) {
519
+ const writeBytes = WORKFLOW_STORAGE_PREFIX.length + write.key.length + write.value.length;
520
+ if (chunk.length > 0 && (chunk.length >= WORKFLOW_SQLITE_MAX_BATCH_ROWS || chunkBytes + writeBytes > WORKFLOW_SQLITE_MAX_BATCH_BYTES)) {
521
+ chunks.push(chunk);
522
+ chunk = [];
523
+ chunkBytes = 0;
524
+ }
525
+ chunk.push(write);
526
+ chunkBytes += writeBytes;
527
+ }
528
+ if (chunk.length > 0) chunks.push(chunk);
529
+ return chunks;
530
+ }
531
+ function keyStartsWith(key, prefix) {
532
+ if (key.length < prefix.length) return false;
533
+ for (let i = 0; i < prefix.length; i++) {
534
+ if (key[i] !== prefix[i]) return false;
535
+ }
536
+ return true;
537
+ }
390
538
  var ActorWorkflowMessageDriver = class {
391
539
  #actor;
392
540
  #runCtx;
@@ -439,95 +587,53 @@ var ActorWorkflowMessageDriver = class {
439
587
  }
440
588
  };
441
589
  var ActorWorkflowDriver = (_class = class {
442
- __init() {this.workerPollInterval = 100}
590
+ __init() {this.atomicBatch = true}
591
+ __init2() {this.workerPollInterval = 100}
592
+
443
593
 
444
594
  #actor;
445
595
  #runCtx;
446
- constructor(actor, runCtx) {;_class.prototype.__init.call(this);
596
+ #storage;
597
+ constructor(actor, runCtx) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
447
598
  this.#actor = actor;
448
599
  this.#runCtx = runCtx;
449
600
  this.messageDriver = new ActorWorkflowMessageDriver(actor, runCtx);
601
+ this.telemetry = {
602
+ startSpan: () => runCtx.run.startWorkflowSpan()
603
+ };
604
+ this.#storage = new WorkflowStorage(runtimeDbFromContext(runCtx));
450
605
  }
451
- async get(key) {
452
- const [value] = await this.#runCtx.internalKeepAwake(
453
- this.#actor.driver.kvBatchGet(this.#actor.id, [
454
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
455
- ])
606
+ /** Keeps the engine's history storage out of the workflow run's trace. */
607
+ #untraced(run) {
608
+ return this.#runCtx.internalKeepAwake(
609
+ this.#runCtx.run.runOutsideWorkflowSpan(run)
456
610
  );
457
- return _nullishCoalesce(value, () => ( null));
611
+ }
612
+ async get(key) {
613
+ return await this.#untraced(() => this.#storage.get(key));
458
614
  }
459
615
  async set(key, value) {
460
- await this.#runCtx.internalKeepAwake(
461
- this.#actor.driver.kvBatchPut(this.#actor.id, [
462
- [_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key), value]
463
- ])
464
- );
616
+ await this.#untraced(() => this.#storage.set(key, value));
465
617
  }
466
618
  async delete(key) {
467
- await this.#runCtx.internalKeepAwake(
468
- this.#actor.driver.kvBatchDelete(this.#actor.id, [
469
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
470
- ])
471
- );
619
+ await this.#untraced(() => this.#storage.delete(key));
620
+ }
621
+ async batchDelete(keys) {
622
+ await this.#untraced(() => this.#storage.batchDelete(keys));
472
623
  }
473
624
  async deletePrefix(prefix) {
474
- const start = _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix);
475
- const end = computeUpperBound(start);
476
- if (end) {
477
- await this.#runCtx.internalKeepAwake(
478
- this.#actor.driver.kvDeleteRange(this.#actor.id, start, end)
479
- );
480
- } else {
481
- const entries = await this.#runCtx.internalKeepAwake(
482
- this.#actor.driver.kvListPrefix(this.#actor.id, start)
483
- );
484
- if (entries.length === 0) {
485
- return;
486
- }
487
- await this.#runCtx.internalKeepAwake(
488
- this.#actor.driver.kvBatchDelete(
489
- this.#actor.id,
490
- entries.map(([key]) => key)
491
- )
492
- );
493
- }
625
+ await this.#untraced(() => this.#storage.deletePrefix(prefix));
494
626
  }
495
627
  async deleteRange(start, end) {
496
- await this.#runCtx.internalKeepAwake(
497
- this.#actor.driver.kvDeleteRange(
498
- this.#actor.id,
499
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, start),
500
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, end)
501
- )
502
- );
628
+ await this.#untraced(() => this.#storage.deleteRange(start, end));
503
629
  }
504
630
  async list(prefix) {
505
- const entries = await this.#runCtx.internalKeepAwake(
506
- this.#actor.driver.kvListPrefix(
507
- this.#actor.id,
508
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix)
509
- )
510
- );
511
- return entries.map(([key, value]) => ({
512
- key: stripWorkflowKey(key),
513
- value
514
- }));
631
+ return await this.#untraced(() => this.#storage.list(prefix));
515
632
  }
516
633
  async batch(writes) {
517
634
  if (writes.length === 0) return;
518
- await this.#runCtx.internalKeepAwake(
519
- Promise.all([
520
- this.#actor.driver.kvBatchPut(
521
- this.#actor.id,
522
- writes.map(({ key, value }) => [
523
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key),
524
- value
525
- ])
526
- ),
527
- this.#actor.stateManager.saveState({
528
- immediate: true
529
- })
530
- ])
635
+ await this.#untraced(
636
+ () => this.#actor.stateManager.saveStateAndWorkflowBatch(writes)
531
637
  );
532
638
  }
533
639
  async setAlarm(_workflowId, wakeAt) {
@@ -557,72 +663,40 @@ var NoopWorkflowMessageDriver = class {
557
663
  }
558
664
  };
559
665
  var ActorWorkflowControlDriver = (_class2 = class {
560
- __init2() {this.workerPollInterval = 100}
561
- __init3() {this.messageDriver = new NoopWorkflowMessageDriver()}
666
+ __init3() {this.workerPollInterval = 100}
667
+ __init4() {this.messageDriver = new NoopWorkflowMessageDriver()}
562
668
  #actor;
563
- constructor(actor) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);
669
+ #storage;
670
+ constructor(actor, runCtx) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);
564
671
  this.#actor = actor;
672
+ this.#storage = new WorkflowStorage(runtimeDbFromContext(runCtx));
565
673
  }
566
674
  async get(key) {
567
- const [value] = await this.#actor.driver.kvBatchGet(this.#actor.id, [
568
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
569
- ]);
570
- return _nullishCoalesce(value, () => ( null));
675
+ return await this.#storage.get(key);
571
676
  }
572
677
  async set(key, value) {
573
- await this.#actor.driver.kvBatchPut(this.#actor.id, [
574
- [_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key), value]
575
- ]);
678
+ await this.#storage.set(key, value);
576
679
  }
577
680
  async delete(key) {
578
- await this.#actor.driver.kvBatchDelete(this.#actor.id, [
579
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
580
- ]);
681
+ await this.#storage.delete(key);
682
+ }
683
+ async batchDelete(keys) {
684
+ await this.#storage.batchDelete(keys);
581
685
  }
582
686
  async deletePrefix(prefix) {
583
- const start = _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix);
584
- const end = computeUpperBound(start);
585
- if (end) {
586
- await this.#actor.driver.kvDeleteRange(this.#actor.id, start, end);
587
- return;
588
- }
589
- const entries = await this.#actor.driver.kvListPrefix(
590
- this.#actor.id,
591
- start
592
- );
593
- if (entries.length === 0) {
594
- return;
595
- }
596
- await this.#actor.driver.kvBatchDelete(
597
- this.#actor.id,
598
- entries.map(([key]) => key)
599
- );
687
+ await this.#storage.deletePrefix(prefix);
600
688
  }
601
689
  async deleteRange(start, end) {
602
- await this.#actor.driver.kvDeleteRange(
603
- this.#actor.id,
604
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, start),
605
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, end)
606
- );
690
+ await this.#storage.deleteRange(start, end);
607
691
  }
608
692
  async list(prefix) {
609
- const entries = await this.#actor.driver.kvListPrefix(
610
- this.#actor.id,
611
- _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix)
612
- );
613
- return entries.map(([key, value]) => ({
614
- key: stripWorkflowKey(key),
615
- value
616
- }));
693
+ return await this.#storage.list(prefix);
617
694
  }
618
695
  async batch(writes) {
619
696
  if (writes.length === 0) {
620
697
  return;
621
698
  }
622
- await this.#actor.driver.kvBatchPut(
623
- this.#actor.id,
624
- writes.map(({ key, value }) => [_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key), value])
625
- );
699
+ await this.#storage.batch(writes);
626
700
  }
627
701
  async setAlarm(_workflowId, wakeAt) {
628
702
  await this.#actor.driver.setAlarm(this.#actor, wakeAt);
@@ -647,7 +721,7 @@ function shouldRethrowWorkflowError(error) {
647
721
  return true;
648
722
  }
649
723
  function workflowReplayInFlightError() {
650
- return new (0, _chunk4FC7TVS6cjs.RivetError)(
724
+ return new (0, _chunkMGI2VVF6cjs.RivetError)(
651
725
  "actor",
652
726
  "workflow_in_flight",
653
727
  "Workflow replay is unavailable while the workflow is currently in flight.",
@@ -660,45 +734,53 @@ function workflowReplayInFlightError() {
660
734
  function isWorkflowReplayBlockedByRunningEntry(error) {
661
735
  return error instanceof Error && error.message === "Cannot replay a workflow while a step is currently running";
662
736
  }
737
+ function isRunHandlerUnavailable(error) {
738
+ return error instanceof _chunkMGI2VVF6cjs.RivetError && error.group === "actor" && error.code === "run_handler_unavailable";
739
+ }
663
740
  function workflow(fn, options = {}) {
664
741
  const onError = options.onError;
665
742
  const workflowInspectors = /* @__PURE__ */ new Map();
666
743
  function getWorkflowInspector(actorId) {
667
744
  let workflowInspector = workflowInspectors.get(actorId);
668
745
  if (!workflowInspector) {
669
- workflowInspector = _chunkGM45LG7Lcjs.createWorkflowInspectorAdapter.call(void 0, );
746
+ workflowInspector = _chunkBTSDFFDCcjs.createWorkflowInspectorAdapter.call(void 0, );
670
747
  workflowInspectors.set(actorId, workflowInspector);
671
748
  }
672
749
  return workflowInspector;
673
750
  }
674
751
  async function run(runCtx) {
675
- const actor = runCtx[_chunk3MHDOUD7cjs.ACTOR_CONTEXT_INTERNAL_SYMBOL];
752
+ const actor = runCtx[_chunkHDVZ6YZGcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL];
676
753
  _invariant2.default.call(void 0, actor, "workflow() requires an actor instance");
677
754
  const workflowInspector = getWorkflowInspector(actor.id);
678
755
  const driver = new ActorWorkflowDriver(actor, runCtx);
679
- const controlDriver = new ActorWorkflowControlDriver(actor);
756
+ const controlDriver = new ActorWorkflowControlDriver(actor, runCtx);
680
757
  workflowInspector.setReplayFromStep(async (entryId) => {
681
758
  const workflowState = await workflowInspector.adapter.getState();
682
- if (actor.isRunHandlerActive() || workflowState === "pending" || workflowState === "running") {
759
+ if (workflowState === "pending" || workflowState === "running") {
683
760
  throw workflowReplayInFlightError();
684
761
  }
685
- let snapshot;
762
+ const control = workflowInspector.control;
763
+ _invariant2.default.call(void 0, control, "workflow Inspector control is not initialized");
686
764
  try {
687
- snapshot = await _workflowengine.replayWorkflowFromStep.call(void 0,
688
- actor.id,
689
- controlDriver,
690
- entryId,
691
- { scheduleAlarm: false }
765
+ return await control.run.withInactive(
766
+ { restartOnSuccess: true },
767
+ async () => {
768
+ const snapshot = await _workflowengine.replayWorkflowFromStep.call(void 0,
769
+ actor.id,
770
+ controlDriver,
771
+ entryId,
772
+ { scheduleAlarm: false }
773
+ );
774
+ workflowInspector.update(snapshot);
775
+ return workflowInspector.adapter.getHistory();
776
+ }
692
777
  );
693
778
  } catch (error) {
694
- if (isWorkflowReplayBlockedByRunningEntry(error)) {
779
+ if (isWorkflowReplayBlockedByRunningEntry(error) || isRunHandlerUnavailable(error)) {
695
780
  throw workflowReplayInFlightError();
696
781
  }
697
782
  throw error;
698
783
  }
699
- workflowInspector.update(snapshot);
700
- await actor.restartRunHandler();
701
- return workflowInspector.adapter.getHistory();
702
784
  });
703
785
  const handle = _workflowengine.runWorkflow.call(void 0,
704
786
  actor.id,
@@ -728,62 +810,40 @@ function workflow(fn, options = {}) {
728
810
  try {
729
811
  await handle.result;
730
812
  } catch (error) {
731
- if (runCtx.abortSignal.aborted || _chunk4FC7TVS6cjs.isActorAbortedError.call(void 0, error)) {
813
+ if (runCtx.abortSignal.aborted || _chunkMGI2VVF6cjs.isActorAbortedError.call(void 0, error)) {
732
814
  return;
733
815
  }
734
816
  if (shouldRethrowWorkflowError(error)) {
735
817
  runCtx.log.error({
736
818
  msg: "workflow run failed",
737
- error: _chunkE4LNLI3Wcjs.stringifyError.call(void 0, error)
819
+ error: _chunk2MOLY6AMcjs.stringifyError.call(void 0, error)
738
820
  });
739
821
  throw error;
740
822
  }
741
823
  runCtx.log.warn({
742
824
  msg: "workflow failed and will sleep until woken",
743
- error: _chunkE4LNLI3Wcjs.stringifyError.call(void 0, error)
825
+ error: _chunk2MOLY6AMcjs.stringifyError.call(void 0, error)
744
826
  });
745
827
  } finally {
746
828
  runCtx.abortSignal.removeEventListener("abort", onAbort);
747
829
  }
748
830
  }
749
- const runWithConfig = run;
750
- runWithConfig[_chunk3MHDOUD7cjs.RUN_FUNCTION_CONFIG_SYMBOL] = {
831
+ return _chunkHDVZ6YZGcjs.defineRunHandler.call(void 0, run, {
751
832
  icon: "diagram-project",
752
- // Drop the per-actor inspector when the actor is destroyed so this map
753
- // does not retain one inspector (and its encoded history) per actor id
754
- // for the process lifetime.
755
- disposeInspector: (actorId) => {
756
- workflowInspectors.delete(actorId);
757
- },
758
- inspectorFactory: (actor) => {
759
- const actorId = resolveWorkflowInspectorActorId(actor);
833
+ inspectorKind: "workflow",
834
+ createInspector: ({ actorId, control }) => {
835
+ const workflowInspector = getWorkflowInspector(actorId);
836
+ workflowInspector.control = control;
760
837
  return {
761
- workflow: actorId ? getWorkflowInspector(actorId).adapter : {
762
- getHistory: () => null,
763
- onHistoryUpdated: () => () => {
764
- },
765
- replayFromStep: async () => null
838
+ inspector: { workflow: workflowInspector.adapter },
839
+ dispose: () => {
840
+ if (workflowInspectors.get(actorId) === workflowInspector) {
841
+ workflowInspectors.delete(actorId);
842
+ }
766
843
  }
767
844
  };
768
845
  }
769
- };
770
- return runWithConfig;
771
- }
772
- function resolveWorkflowInspectorActorId(actor) {
773
- if (typeof actor === "string" && actor.length > 0) {
774
- return actor;
775
- }
776
- if (!actor || typeof actor !== "object") {
777
- return void 0;
778
- }
779
- const candidate = actor;
780
- if (typeof candidate.id === "string" && candidate.id.length > 0) {
781
- return candidate.id;
782
- }
783
- if (typeof candidate.actorId === "string" && candidate.actorId.length > 0) {
784
- return candidate.actorId;
785
- }
786
- return void 0;
846
+ });
787
847
  }
788
848
 
789
849