rivetkit 2.3.11-rc.9 → 2.3.11
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.
- package/dist/browser/client.d.ts +96 -14
- package/dist/browser/client.js +12 -2
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +139 -139
- package/dist/browser/inspector/client.js +12 -2
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/agent-os/index.cjs +146 -76
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +83 -9
- package/dist/tsup/agent-os/index.d.ts +83 -9
- package/dist/tsup/agent-os/index.js +146 -76
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-HOZ3ZLZ2.js → chunk-3ZR542SK.js} +6 -6
- package/dist/tsup/chunk-3ZR542SK.js.map +1 -0
- package/dist/tsup/{chunk-HNHLBM3Y.cjs → chunk-4KGXFC6M.cjs} +42 -5
- package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
- package/dist/tsup/chunk-5UYWLCRO.js +14 -0
- package/dist/tsup/chunk-5UYWLCRO.js.map +1 -0
- package/dist/tsup/{chunk-QWLJCP3X.js → chunk-6W5VGLFT.js} +42 -5
- package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
- package/dist/tsup/chunk-6WYATRS4.js +243 -0
- package/dist/tsup/chunk-6WYATRS4.js.map +1 -0
- package/dist/tsup/chunk-B3W74FBB.cjs +14 -0
- package/dist/tsup/chunk-B3W74FBB.cjs.map +1 -0
- package/dist/tsup/{chunk-XOOESJY7.js → chunk-FWROC5LA.js} +2 -2
- package/dist/tsup/{chunk-V5CVATRU.cjs → chunk-GLIPKKEC.cjs} +7 -7
- package/dist/tsup/{chunk-V5CVATRU.cjs.map → chunk-GLIPKKEC.cjs.map} +1 -1
- package/dist/tsup/{chunk-T5XVTVQY.cjs → chunk-GN2EUMEW.cjs} +3 -3
- package/dist/tsup/{chunk-T5XVTVQY.cjs.map → chunk-GN2EUMEW.cjs.map} +1 -1
- package/dist/tsup/{chunk-T56IZ42M.cjs → chunk-GU7ML3KE.cjs} +13 -3
- package/dist/tsup/chunk-GU7ML3KE.cjs.map +1 -0
- package/dist/tsup/{chunk-IOLZ3ONU.js → chunk-JQ2AZ5FN.js} +3 -3
- package/dist/tsup/{chunk-7AFZMFPQ.js → chunk-JTHHCZCZ.js} +10 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-UEULFXUI.cjs → chunk-KVFIONKQ.cjs} +11 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/chunk-LWQFXGKS.cjs +243 -0
- package/dist/tsup/chunk-LWQFXGKS.cjs.map +1 -0
- package/dist/tsup/{chunk-QVCO6DTZ.js → chunk-MO2SSUOR.js} +8 -7
- package/dist/tsup/chunk-MO2SSUOR.js.map +1 -0
- package/dist/tsup/{chunk-LZ4TSBIP.js → chunk-OUENKQHB.js} +13 -3
- package/dist/tsup/chunk-OUENKQHB.js.map +1 -0
- package/dist/tsup/{chunk-6SBPWTXJ.cjs → chunk-PUZY2XCD.cjs} +10 -9
- package/dist/tsup/chunk-PUZY2XCD.cjs.map +1 -0
- package/dist/tsup/{chunk-C5TORAVP.js → chunk-QFJ24MBU.js} +27 -2
- package/dist/tsup/{chunk-C5TORAVP.js.map → chunk-QFJ24MBU.js.map} +1 -1
- package/dist/tsup/{chunk-BZWKY6WO.cjs → chunk-RXXDNJXB.cjs} +140 -140
- package/dist/tsup/{chunk-BZWKY6WO.cjs.map → chunk-RXXDNJXB.cjs.map} +1 -1
- package/dist/tsup/{chunk-IMRDHZM2.cjs → chunk-VBJQIBXI.cjs} +30 -5
- package/dist/tsup/chunk-VBJQIBXI.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +4 -3
- package/dist/tsup/client/mod.d.ts +4 -3
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-CZcjyT5B.d.ts → config-C4OSv0QP.d.ts} +92 -7
- package/dist/tsup/{config-rGWrumlO.d.cts → config-DTGoWdkG.d.cts} +92 -7
- package/dist/tsup/{config-BxOimoGX.d.cts → config-ey2I2zz5.d.cts} +46 -6
- package/dist/tsup/{config-BxOimoGX.d.ts → config-ey2I2zz5.d.ts} +46 -6
- package/dist/tsup/{context-B8W8E8nW.d.cts → context-C6cvDNyk.d.cts} +2 -2
- package/dist/tsup/{context-_UrDZhEh.d.ts → context-CMygeBxS.d.ts} +2 -2
- package/dist/tsup/db/drizzle.cjs +18 -10
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +5 -6
- package/dist/tsup/db/drizzle.d.ts +5 -6
- package/dist/tsup/db/drizzle.js +13 -5
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +5 -175
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +11 -4
- package/dist/tsup/db/mod.d.ts +11 -4
- package/dist/tsup/db/mod.js +4 -174
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +3 -2
- package/dist/tsup/dynamic/mod.d.ts +3 -2
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +5 -4
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +12 -146
- package/dist/tsup/inspector/mod.d.ts +12 -146
- package/dist/tsup/inspector/mod.js +4 -3
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector/workflow.cjs +21 -0
- package/dist/tsup/inspector/workflow.cjs.map +1 -0
- package/dist/tsup/inspector/workflow.d.cts +144 -0
- package/dist/tsup/inspector/workflow.d.ts +144 -0
- package/dist/tsup/inspector/workflow.js +21 -0
- package/dist/tsup/inspector/workflow.js.map +1 -0
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +4 -3
- package/dist/tsup/inspector-tab/mod.d.ts +4 -3
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +743 -247
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +6 -5
- package/dist/tsup/mod.d.ts +6 -5
- package/dist/tsup/mod.js +670 -174
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +3 -2
- package/dist/tsup/test/mod.d.ts +3 -2
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +89 -95
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +5 -4
- package/dist/tsup/workflow/mod.d.ts +5 -4
- package/dist/tsup/workflow/mod.js +86 -92
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +19 -9
- package/src/actor/config.test.ts +65 -1
- package/src/actor/config.ts +169 -5
- package/src/actor/mod.ts +10 -1
- package/src/client/actor-common.ts +5 -14
- package/src/common/database/config.ts +50 -3
- package/src/common/database/mod.test.ts +142 -4
- package/src/common/database/mod.ts +210 -98
- package/src/common/database/native-database.ts +42 -3
- package/src/common/database/shared.ts +9 -0
- package/src/db/drizzle.test.ts +8 -1
- package/src/db/drizzle.ts +15 -4
- package/src/db/mod.ts +3 -0
- package/src/inspector/workflow.ts +61 -0
- package/src/registry/napi-runtime.ts +69 -1
- package/src/registry/native.ts +474 -161
- package/src/registry/run-handler-coordinator.test.ts +252 -0
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.ts +34 -1
- package/src/registry/wasm-runtime.ts +122 -17
- package/src/utils/node.ts +44 -28
- package/src/workflow/driver.ts +56 -58
- package/src/workflow/inspector.ts +10 -15
- package/src/workflow/mod.ts +48 -70
- package/dist/tsup/chunk-6SBPWTXJ.cjs.map +0 -1
- package/dist/tsup/chunk-7AFZMFPQ.js.map +0 -1
- package/dist/tsup/chunk-HNHLBM3Y.cjs.map +0 -1
- package/dist/tsup/chunk-HOZ3ZLZ2.js.map +0 -1
- package/dist/tsup/chunk-IMRDHZM2.cjs.map +0 -1
- package/dist/tsup/chunk-LZ4TSBIP.js.map +0 -1
- package/dist/tsup/chunk-QVCO6DTZ.js.map +0 -1
- package/dist/tsup/chunk-QWLJCP3X.js.map +0 -1
- package/dist/tsup/chunk-T56IZ42M.cjs.map +0 -1
- package/dist/tsup/chunk-UEULFXUI.cjs.map +0 -1
- /package/dist/tsup/{chunk-XOOESJY7.js.map → chunk-FWROC5LA.js.map} +0 -0
- /package/dist/tsup/{chunk-IOLZ3ONU.js.map → chunk-JQ2AZ5FN.js.map} +0 -0
package/dist/tsup/test/mod.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkGLIPKKECcjs = require('../chunk-GLIPKKEC.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkRXXDNJXBcjs = require('../chunk-RXXDNJXB.cjs');
|
|
7
7
|
require('../chunk-MYWZCDML.cjs');
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-
|
|
8
|
+
require('../chunk-KVFIONKQ.cjs');
|
|
9
|
+
require('../chunk-GN2EUMEW.cjs');
|
|
10
|
+
require('../chunk-GU7ML3KE.cjs');
|
|
11
11
|
require('../chunk-4FC7TVS6.cjs');
|
|
12
12
|
|
|
13
13
|
// src/test/ready.ts
|
|
@@ -36,8 +36,8 @@ async function setupTest(c, registry) {
|
|
|
36
36
|
registry.config.noWelcome = true;
|
|
37
37
|
registry.start();
|
|
38
38
|
await waitForRegistryReady(registry);
|
|
39
|
-
const client =
|
|
40
|
-
...
|
|
39
|
+
const client = _chunkGLIPKKECcjs.createClient.call(void 0, {
|
|
40
|
+
..._chunkRXXDNJXBcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
|
|
41
41
|
disableMetadataLookup: false
|
|
42
42
|
});
|
|
43
43
|
c.onTestFinished(async () => {
|
package/dist/tsup/test/mod.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { aF as Registry, a3 as Client } from '../config-DTGoWdkG.cjs';
|
|
3
3
|
import 'zod/v4';
|
|
4
|
-
import '../config-
|
|
4
|
+
import '../config-ey2I2zz5.cjs';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'pino';
|
|
8
8
|
import '@rivetkit/virtual-websocket';
|
|
9
|
+
import '../inspector/workflow.cjs';
|
|
9
10
|
import '@standard-schema/spec';
|
|
10
11
|
import '../utils-DQDCphrl.cjs';
|
|
11
12
|
import 'hono';
|
package/dist/tsup/test/mod.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { aF as Registry, a3 as Client } from '../config-C4OSv0QP.js';
|
|
3
3
|
import 'zod/v4';
|
|
4
|
-
import '../config-
|
|
4
|
+
import '../config-ey2I2zz5.js';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'pino';
|
|
8
8
|
import '@rivetkit/virtual-websocket';
|
|
9
|
+
import '../inspector/workflow.js';
|
|
9
10
|
import '@standard-schema/spec';
|
|
10
11
|
import '../utils-CV0akuDD.js';
|
|
11
12
|
import 'hono';
|
package/dist/tsup/test/mod.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClient
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-JQ2AZ5FN.js";
|
|
4
4
|
import {
|
|
5
5
|
convertRegistryConfigToClientConfig
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-3ZR542SK.js";
|
|
7
7
|
import "../chunk-JI6GZ2C2.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-JTHHCZCZ.js";
|
|
9
|
+
import "../chunk-FWROC5LA.js";
|
|
10
|
+
import "../chunk-OUENKQHB.js";
|
|
11
11
|
import "../chunk-ZZ3WBRPD.js";
|
|
12
12
|
|
|
13
13
|
// src/test/ready.ts
|
package/dist/tsup/utils.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkGU7ML3KEcjs = require('./chunk-GU7ML3KE.cjs');
|
|
23
23
|
require('./chunk-4FC7TVS6.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
@@ -42,5 +42,5 @@ require('./chunk-4FC7TVS6.cjs');
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
exports.EXTRA_ERROR_LOG =
|
|
45
|
+
exports.EXTRA_ERROR_LOG = _chunkGU7ML3KEcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkGU7ML3KEcjs.SinglePromiseQueue; exports.VERSION = _chunkGU7ML3KEcjs.VERSION; exports.arrayBuffersEqual = _chunkGU7ML3KEcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkGU7ML3KEcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkGU7ML3KEcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkGU7ML3KEcjs.combineUrlPath; exports.dbg = _chunkGU7ML3KEcjs.dbg; exports.detectRuntime = _chunkGU7ML3KEcjs.detectRuntime; exports.getEnvUniversal = _chunkGU7ML3KEcjs.getEnvUniversal; exports.httpUserAgent = _chunkGU7ML3KEcjs.httpUserAgent; exports.interval = _chunkGU7ML3KEcjs.interval; exports.joinSignals = _chunkGU7ML3KEcjs.joinSignals; exports.jsonParseCompat = _chunkGU7ML3KEcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkGU7ML3KEcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkGU7ML3KEcjs.promiseWithResolvers; exports.setLongTimeout = _chunkGU7ML3KEcjs.setLongTimeout; exports.sleep = _chunkGU7ML3KEcjs.sleep; exports.stringifyError = _chunkGU7ML3KEcjs.stringifyError; exports.toUint8Array = _chunkGU7ML3KEcjs.toUint8Array;
|
|
46
46
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/tsup/utils.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
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
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var _chunkPUZY2XCDcjs = require('../chunk-PUZY2XCD.cjs');
|
|
4
|
+
require('../chunk-B3W74FBB.cjs');
|
|
5
|
+
require('../chunk-VBJQIBXI.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
var
|
|
9
|
+
var _chunk4KGXFC6Mcjs = require('../chunk-4KGXFC6M.cjs');
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
var _chunkMYWZCDMLcjs = require('../chunk-MYWZCDML.cjs');
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var _chunkGU7ML3KEcjs = require('../chunk-GU7ML3KE.cjs');
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
@@ -392,53 +393,50 @@ function normalizeSqlBlob(value) {
|
|
|
392
393
|
}
|
|
393
394
|
throw new Error("workflow sqlite value was not a blob");
|
|
394
395
|
}
|
|
395
|
-
function
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
return
|
|
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;
|
|
399
400
|
}
|
|
400
401
|
return void 0;
|
|
401
402
|
}
|
|
402
403
|
var WorkflowStorage = class {
|
|
403
|
-
#
|
|
404
|
-
constructor(
|
|
405
|
-
if (!
|
|
404
|
+
#db;
|
|
405
|
+
constructor(db) {
|
|
406
|
+
if (!db) {
|
|
406
407
|
throw new Error(
|
|
407
408
|
"workflow storage requires embedded SQLite; actor KV workflow storage is no longer supported"
|
|
408
409
|
);
|
|
409
410
|
}
|
|
410
|
-
|
|
411
|
-
throw new Error(
|
|
412
|
-
"workflow storage requires a SQLite database with executeBatch support"
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
this.#sql = sql;
|
|
411
|
+
this.#db = db;
|
|
416
412
|
}
|
|
417
413
|
async get(key) {
|
|
418
414
|
var _a;
|
|
419
415
|
const prefixed = _chunkMYWZCDMLcjs.makeWorkflowKey.call(void 0, key);
|
|
420
|
-
const
|
|
416
|
+
const rows = await this.#db.execute(
|
|
421
417
|
"SELECT value FROM _rivet_wf_kv WHERE key = ?",
|
|
422
|
-
|
|
418
|
+
prefixed
|
|
423
419
|
);
|
|
424
|
-
return ((_a =
|
|
420
|
+
return ((_a = rows[0]) == null ? void 0 : _a.value) == null ? null : normalizeSqlBlob(rows[0].value);
|
|
425
421
|
}
|
|
426
422
|
async set(key, value) {
|
|
427
423
|
await this.batch([{ key, value }]);
|
|
428
424
|
}
|
|
429
425
|
async delete(key) {
|
|
430
426
|
const prefixed = _chunkMYWZCDMLcjs.makeWorkflowKey.call(void 0, key);
|
|
431
|
-
await this.#
|
|
427
|
+
await this.#db.execute(
|
|
428
|
+
"DELETE FROM _rivet_wf_kv WHERE key = ?",
|
|
432
429
|
prefixed
|
|
433
|
-
|
|
430
|
+
);
|
|
434
431
|
}
|
|
435
432
|
async deletePrefix(prefix) {
|
|
436
433
|
const start = _chunkMYWZCDMLcjs.makeWorkflowKey.call(void 0, prefix);
|
|
437
434
|
const end = computeUpperBound(start);
|
|
438
435
|
if (end) {
|
|
439
|
-
await this.#
|
|
436
|
+
await this.#db.execute(
|
|
440
437
|
"DELETE FROM _rivet_wf_kv WHERE key >= ? AND key < ?",
|
|
441
|
-
|
|
438
|
+
start,
|
|
439
|
+
end
|
|
442
440
|
);
|
|
443
441
|
return;
|
|
444
442
|
}
|
|
@@ -450,9 +448,10 @@ var WorkflowStorage = class {
|
|
|
450
448
|
async deleteRange(start, end) {
|
|
451
449
|
const prefixedStart = _chunkMYWZCDMLcjs.makeWorkflowKey.call(void 0, start);
|
|
452
450
|
const prefixedEnd = _chunkMYWZCDMLcjs.makeWorkflowKey.call(void 0, end);
|
|
453
|
-
await this.#
|
|
451
|
+
await this.#db.execute(
|
|
454
452
|
"DELETE FROM _rivet_wf_kv WHERE key >= ? AND key < ?",
|
|
455
|
-
|
|
453
|
+
prefixedStart,
|
|
454
|
+
prefixedEnd
|
|
456
455
|
);
|
|
457
456
|
}
|
|
458
457
|
async list(prefix) {
|
|
@@ -466,36 +465,45 @@ var WorkflowStorage = class {
|
|
|
466
465
|
async batch(writes) {
|
|
467
466
|
if (writes.length === 0) return;
|
|
468
467
|
for (const chunk of chunkWorkflowWrites(writes)) {
|
|
469
|
-
await this.#
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
468
|
+
await this.#db.transaction(async (tx) => {
|
|
469
|
+
for (const { key, value } of chunk) {
|
|
470
|
+
await tx.execute(
|
|
471
|
+
"INSERT INTO _rivet_wf_kv (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
|
|
472
|
+
_chunkMYWZCDMLcjs.makeWorkflowKey.call(void 0, key),
|
|
473
|
+
value
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
});
|
|
475
477
|
}
|
|
476
478
|
}
|
|
477
479
|
async listRaw(prefix) {
|
|
478
480
|
const end = computeUpperBound(prefix);
|
|
479
|
-
const
|
|
481
|
+
const rows = end ? await this.#db.execute(
|
|
480
482
|
"SELECT key, value FROM _rivet_wf_kv WHERE key >= ? AND key < ? ORDER BY key ASC",
|
|
481
|
-
|
|
482
|
-
|
|
483
|
+
prefix,
|
|
484
|
+
end
|
|
485
|
+
) : await this.#db.execute(
|
|
483
486
|
"SELECT key, value FROM _rivet_wf_kv WHERE key >= ? ORDER BY key ASC",
|
|
484
|
-
|
|
487
|
+
prefix
|
|
485
488
|
);
|
|
486
|
-
return
|
|
487
|
-
normalizeSqlBlob(row
|
|
488
|
-
normalizeSqlBlob(row
|
|
489
|
+
return rows.map((row) => [
|
|
490
|
+
normalizeSqlBlob(row.key),
|
|
491
|
+
normalizeSqlBlob(row.value)
|
|
489
492
|
]);
|
|
490
493
|
}
|
|
491
494
|
async deleteRawKeys(keys) {
|
|
492
495
|
for (let start = 0; start < keys.length; start += WORKFLOW_SQLITE_MAX_BATCH_ROWS) {
|
|
493
|
-
await this.#
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
496
|
+
await this.#db.transaction(async (tx) => {
|
|
497
|
+
for (const key of keys.slice(
|
|
498
|
+
start,
|
|
499
|
+
start + WORKFLOW_SQLITE_MAX_BATCH_ROWS
|
|
500
|
+
)) {
|
|
501
|
+
await tx.execute(
|
|
502
|
+
"DELETE FROM _rivet_wf_kv WHERE key = ?",
|
|
503
|
+
key
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
});
|
|
499
507
|
}
|
|
500
508
|
}
|
|
501
509
|
};
|
|
@@ -585,7 +593,7 @@ var ActorWorkflowDriver = (_class = class {
|
|
|
585
593
|
this.#actor = actor;
|
|
586
594
|
this.#runCtx = runCtx;
|
|
587
595
|
this.messageDriver = new ActorWorkflowMessageDriver(actor, runCtx);
|
|
588
|
-
this.#storage = new WorkflowStorage(
|
|
596
|
+
this.#storage = new WorkflowStorage(runtimeDbFromContext(runCtx));
|
|
589
597
|
}
|
|
590
598
|
async get(key) {
|
|
591
599
|
return await this.#runCtx.internalKeepAwake(this.#storage.get(key));
|
|
@@ -648,7 +656,7 @@ var ActorWorkflowControlDriver = (_class2 = class {
|
|
|
648
656
|
#storage;
|
|
649
657
|
constructor(actor, runCtx) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);
|
|
650
658
|
this.#actor = actor;
|
|
651
|
-
this.#storage = new WorkflowStorage(
|
|
659
|
+
this.#storage = new WorkflowStorage(runtimeDbFromContext(runCtx));
|
|
652
660
|
}
|
|
653
661
|
async get(key) {
|
|
654
662
|
return await this.#storage.get(key);
|
|
@@ -710,45 +718,53 @@ function workflowReplayInFlightError() {
|
|
|
710
718
|
function isWorkflowReplayBlockedByRunningEntry(error) {
|
|
711
719
|
return error instanceof Error && error.message === "Cannot replay a workflow while a step is currently running";
|
|
712
720
|
}
|
|
721
|
+
function isRunHandlerUnavailable(error) {
|
|
722
|
+
return error instanceof _chunk4FC7TVS6cjs.RivetError && error.group === "actor" && error.code === "run_handler_unavailable";
|
|
723
|
+
}
|
|
713
724
|
function workflow(fn, options = {}) {
|
|
714
725
|
const onError = options.onError;
|
|
715
726
|
const workflowInspectors = /* @__PURE__ */ new Map();
|
|
716
727
|
function getWorkflowInspector(actorId) {
|
|
717
728
|
let workflowInspector = workflowInspectors.get(actorId);
|
|
718
729
|
if (!workflowInspector) {
|
|
719
|
-
workflowInspector =
|
|
730
|
+
workflowInspector = _chunkPUZY2XCDcjs.createWorkflowInspectorAdapter.call(void 0, );
|
|
720
731
|
workflowInspectors.set(actorId, workflowInspector);
|
|
721
732
|
}
|
|
722
733
|
return workflowInspector;
|
|
723
734
|
}
|
|
724
735
|
async function run(runCtx) {
|
|
725
|
-
const actor = runCtx[
|
|
736
|
+
const actor = runCtx[_chunk4KGXFC6Mcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL];
|
|
726
737
|
_invariant2.default.call(void 0, actor, "workflow() requires an actor instance");
|
|
727
738
|
const workflowInspector = getWorkflowInspector(actor.id);
|
|
728
739
|
const driver = new ActorWorkflowDriver(actor, runCtx);
|
|
729
740
|
const controlDriver = new ActorWorkflowControlDriver(actor, runCtx);
|
|
730
741
|
workflowInspector.setReplayFromStep(async (entryId) => {
|
|
731
742
|
const workflowState = await workflowInspector.adapter.getState();
|
|
732
|
-
if (
|
|
743
|
+
if (workflowState === "pending" || workflowState === "running") {
|
|
733
744
|
throw workflowReplayInFlightError();
|
|
734
745
|
}
|
|
735
|
-
|
|
746
|
+
const control = workflowInspector.control;
|
|
747
|
+
_invariant2.default.call(void 0, control, "workflow Inspector control is not initialized");
|
|
736
748
|
try {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
749
|
+
return await control.run.withInactive(
|
|
750
|
+
{ restartOnSuccess: true },
|
|
751
|
+
async () => {
|
|
752
|
+
const snapshot = await _workflowengine.replayWorkflowFromStep.call(void 0,
|
|
753
|
+
actor.id,
|
|
754
|
+
controlDriver,
|
|
755
|
+
entryId,
|
|
756
|
+
{ scheduleAlarm: false }
|
|
757
|
+
);
|
|
758
|
+
workflowInspector.update(snapshot);
|
|
759
|
+
return workflowInspector.adapter.getHistory();
|
|
760
|
+
}
|
|
742
761
|
);
|
|
743
762
|
} catch (error) {
|
|
744
|
-
if (isWorkflowReplayBlockedByRunningEntry(error)) {
|
|
763
|
+
if (isWorkflowReplayBlockedByRunningEntry(error) || isRunHandlerUnavailable(error)) {
|
|
745
764
|
throw workflowReplayInFlightError();
|
|
746
765
|
}
|
|
747
766
|
throw error;
|
|
748
767
|
}
|
|
749
|
-
workflowInspector.update(snapshot);
|
|
750
|
-
await actor.restartRunHandler();
|
|
751
|
-
return workflowInspector.adapter.getHistory();
|
|
752
768
|
});
|
|
753
769
|
const handle = _workflowengine.runWorkflow.call(void 0,
|
|
754
770
|
actor.id,
|
|
@@ -784,56 +800,34 @@ function workflow(fn, options = {}) {
|
|
|
784
800
|
if (shouldRethrowWorkflowError(error)) {
|
|
785
801
|
runCtx.log.error({
|
|
786
802
|
msg: "workflow run failed",
|
|
787
|
-
error:
|
|
803
|
+
error: _chunkGU7ML3KEcjs.stringifyError.call(void 0, error)
|
|
788
804
|
});
|
|
789
805
|
throw error;
|
|
790
806
|
}
|
|
791
807
|
runCtx.log.warn({
|
|
792
808
|
msg: "workflow failed and will sleep until woken",
|
|
793
|
-
error:
|
|
809
|
+
error: _chunkGU7ML3KEcjs.stringifyError.call(void 0, error)
|
|
794
810
|
});
|
|
795
811
|
} finally {
|
|
796
812
|
runCtx.abortSignal.removeEventListener("abort", onAbort);
|
|
797
813
|
}
|
|
798
814
|
}
|
|
799
|
-
|
|
800
|
-
runWithConfig[_chunkHNHLBM3Ycjs.RUN_FUNCTION_CONFIG_SYMBOL] = {
|
|
815
|
+
return _chunk4KGXFC6Mcjs.defineRunHandler.call(void 0, run, {
|
|
801
816
|
icon: "diagram-project",
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
workflowInspectors.delete(actorId);
|
|
807
|
-
},
|
|
808
|
-
inspectorFactory: (actor) => {
|
|
809
|
-
const actorId = resolveWorkflowInspectorActorId(actor);
|
|
817
|
+
inspectorKind: "workflow",
|
|
818
|
+
createInspector: ({ actorId, control }) => {
|
|
819
|
+
const workflowInspector = getWorkflowInspector(actorId);
|
|
820
|
+
workflowInspector.control = control;
|
|
810
821
|
return {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
822
|
+
inspector: { workflow: workflowInspector.adapter },
|
|
823
|
+
dispose: () => {
|
|
824
|
+
if (workflowInspectors.get(actorId) === workflowInspector) {
|
|
825
|
+
workflowInspectors.delete(actorId);
|
|
826
|
+
}
|
|
816
827
|
}
|
|
817
828
|
};
|
|
818
829
|
}
|
|
819
|
-
};
|
|
820
|
-
return runWithConfig;
|
|
821
|
-
}
|
|
822
|
-
function resolveWorkflowInspectorActorId(actor) {
|
|
823
|
-
if (typeof actor === "string" && actor.length > 0) {
|
|
824
|
-
return actor;
|
|
825
|
-
}
|
|
826
|
-
if (!actor || typeof actor !== "object") {
|
|
827
|
-
return void 0;
|
|
828
|
-
}
|
|
829
|
-
const candidate = actor;
|
|
830
|
-
if (typeof candidate.id === "string" && candidate.id.length > 0) {
|
|
831
|
-
return candidate.id;
|
|
832
|
-
}
|
|
833
|
-
if (typeof candidate.actorId === "string" && candidate.actorId.length > 0) {
|
|
834
|
-
return candidate.actorId;
|
|
835
|
-
}
|
|
836
|
-
return void 0;
|
|
830
|
+
});
|
|
837
831
|
}
|
|
838
832
|
|
|
839
833
|
|