rivetkit 2.3.0-rc.9 → 2.3.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.
- package/dist/browser/client.d.ts +498 -62
- package/dist/browser/client.js +227 -171
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +50 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2163 -2087
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +496 -69
- package/dist/tsup/agent-os/index.d.ts +496 -69
- package/dist/tsup/agent-os/index.js +2163 -2087
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
- package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
- package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
- package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
- package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +730 -336
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +633 -239
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +32 -11
- package/src/actor/config.ts +159 -51
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +9 -3
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +87 -54
- package/src/client/actor-conn.ts +8 -36
- package/src/client/actor-handle.ts +69 -51
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -150
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +58 -56
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +154 -74
- package/src/registry/napi-runtime.ts +13 -2
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +367 -181
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +41 -1
- package/src/registry/wasm-runtime.ts +18 -2
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
- package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
- package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
- package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
- package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
- package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
- package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
- package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
- package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
- /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
|
@@ -1,22 +1,23 @@
|
|
|
1
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(); } } var _class; var _class2;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkB6VUNZUDcjs = require('../chunk-B6VUNZUD.cjs');
|
|
4
|
+
require('../chunk-47HHIEXH.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
var _chunkWQ4HNA4Wcjs = require('../chunk-WQ4HNA4W.cjs');
|
|
8
|
-
require('../chunk-4CGA6QJO.cjs');
|
|
9
8
|
|
|
9
|
+
var _chunkNIY3RSPXcjs = require('../chunk-NIY3RSPX.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var _chunkLD5YASJUcjs = require('../chunk-LD5YASJU.cjs');
|
|
13
|
-
require('../chunk-VJFRBJVQ.cjs');
|
|
14
12
|
|
|
13
|
+
var _chunkVE2X4KMGcjs = require('../chunk-VE2X4KMG.cjs');
|
|
14
|
+
require('../chunk-3677IIOV.cjs');
|
|
15
15
|
|
|
16
|
-
var _chunkY5NSCZA2cjs = require('../chunk-Y5NSCZA2.cjs');
|
|
17
16
|
|
|
17
|
+
var _chunkDXXJPH55cjs = require('../chunk-DXXJPH55.cjs');
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
var _chunkKORQB2IRcjs = require('../chunk-KORQB2IR.cjs');
|
|
20
21
|
|
|
21
22
|
// src/workflow/mod.ts
|
|
22
23
|
|
|
@@ -33,269 +34,6 @@ var _chunkQAZLM4WTcjs = require('../chunk-QAZLM4WT.cjs');
|
|
|
33
34
|
var _workflowengine = require('@rivetkit/workflow-engine');
|
|
34
35
|
var _invariant = require('invariant'); var _invariant2 = _interopRequireDefault(_invariant);
|
|
35
36
|
|
|
36
|
-
// src/workflow/driver.ts
|
|
37
|
-
var WORKFLOW_STORAGE_PREFIX = _chunkLD5YASJUcjs.workflowStoragePrefix.call(void 0, );
|
|
38
|
-
function stripWorkflowKey(prefixed) {
|
|
39
|
-
return prefixed.slice(WORKFLOW_STORAGE_PREFIX.length);
|
|
40
|
-
}
|
|
41
|
-
function computeUpperBound(prefix) {
|
|
42
|
-
const upperBound = prefix.slice();
|
|
43
|
-
for (let i = upperBound.length - 1; i >= 0; i--) {
|
|
44
|
-
if (upperBound[i] !== 255) {
|
|
45
|
-
upperBound[i]++;
|
|
46
|
-
return upperBound.slice(0, i + 1);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
var ActorWorkflowMessageDriver = class {
|
|
52
|
-
#actor;
|
|
53
|
-
#runCtx;
|
|
54
|
-
constructor(actor, runCtx) {
|
|
55
|
-
this.#actor = actor;
|
|
56
|
-
this.#runCtx = runCtx;
|
|
57
|
-
}
|
|
58
|
-
async addMessage(message) {
|
|
59
|
-
await this.#runCtx.internalKeepAwake(
|
|
60
|
-
this.#actor.queueManager.enqueue(message.name, message.data)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
async receiveMessages(opts) {
|
|
64
|
-
const messages = await this.#runCtx.internalKeepAwake(
|
|
65
|
-
this.#actor.queueManager.receive(
|
|
66
|
-
opts.names && opts.names.length > 0 ? [...opts.names] : void 0,
|
|
67
|
-
opts.count,
|
|
68
|
-
0,
|
|
69
|
-
void 0,
|
|
70
|
-
opts.completable
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
return messages.map((message) => ({
|
|
74
|
-
id: message.id.toString(),
|
|
75
|
-
name: message.name,
|
|
76
|
-
data: message.body,
|
|
77
|
-
sentAt: message.createdAt,
|
|
78
|
-
...opts.completable ? {
|
|
79
|
-
complete: async (response) => {
|
|
80
|
-
await this.#runCtx.internalKeepAwake(
|
|
81
|
-
this.#actor.queueManager.completeMessage(
|
|
82
|
-
message,
|
|
83
|
-
response
|
|
84
|
-
)
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
} : {}
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
async completeMessage(messageId, response) {
|
|
91
|
-
let parsedId;
|
|
92
|
-
try {
|
|
93
|
-
parsedId = BigInt(messageId);
|
|
94
|
-
} catch (e) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
await this.#runCtx.internalKeepAwake(
|
|
98
|
-
this.#actor.queueManager.completeMessageById(parsedId, response)
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var ActorWorkflowDriver = (_class = class {
|
|
103
|
-
__init() {this.workerPollInterval = 100}
|
|
104
|
-
|
|
105
|
-
#actor;
|
|
106
|
-
#runCtx;
|
|
107
|
-
constructor(actor, runCtx) {;_class.prototype.__init.call(this);
|
|
108
|
-
this.#actor = actor;
|
|
109
|
-
this.#runCtx = runCtx;
|
|
110
|
-
this.messageDriver = new ActorWorkflowMessageDriver(actor, runCtx);
|
|
111
|
-
}
|
|
112
|
-
async get(key) {
|
|
113
|
-
const [value] = await this.#runCtx.internalKeepAwake(
|
|
114
|
-
this.#actor.driver.kvBatchGet(this.#actor.id, [
|
|
115
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key)
|
|
116
|
-
])
|
|
117
|
-
);
|
|
118
|
-
return _nullishCoalesce(value, () => ( null));
|
|
119
|
-
}
|
|
120
|
-
async set(key, value) {
|
|
121
|
-
await this.#runCtx.internalKeepAwake(
|
|
122
|
-
this.#actor.driver.kvBatchPut(this.#actor.id, [
|
|
123
|
-
[_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key), value]
|
|
124
|
-
])
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
async delete(key) {
|
|
128
|
-
await this.#runCtx.internalKeepAwake(
|
|
129
|
-
this.#actor.driver.kvBatchDelete(this.#actor.id, [
|
|
130
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key)
|
|
131
|
-
])
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
async deletePrefix(prefix) {
|
|
135
|
-
const start = _chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, prefix);
|
|
136
|
-
const end = computeUpperBound(start);
|
|
137
|
-
if (end) {
|
|
138
|
-
await this.#runCtx.internalKeepAwake(
|
|
139
|
-
this.#actor.driver.kvDeleteRange(this.#actor.id, start, end)
|
|
140
|
-
);
|
|
141
|
-
} else {
|
|
142
|
-
const entries = await this.#runCtx.internalKeepAwake(
|
|
143
|
-
this.#actor.driver.kvListPrefix(this.#actor.id, start)
|
|
144
|
-
);
|
|
145
|
-
if (entries.length === 0) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
await this.#runCtx.internalKeepAwake(
|
|
149
|
-
this.#actor.driver.kvBatchDelete(
|
|
150
|
-
this.#actor.id,
|
|
151
|
-
entries.map(([key]) => key)
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
async deleteRange(start, end) {
|
|
157
|
-
await this.#runCtx.internalKeepAwake(
|
|
158
|
-
this.#actor.driver.kvDeleteRange(
|
|
159
|
-
this.#actor.id,
|
|
160
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, start),
|
|
161
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, end)
|
|
162
|
-
)
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
async list(prefix) {
|
|
166
|
-
const entries = await this.#runCtx.internalKeepAwake(
|
|
167
|
-
this.#actor.driver.kvListPrefix(
|
|
168
|
-
this.#actor.id,
|
|
169
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, prefix)
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
return entries.map(([key, value]) => ({
|
|
173
|
-
key: stripWorkflowKey(key),
|
|
174
|
-
value
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
async batch(writes) {
|
|
178
|
-
if (writes.length === 0) return;
|
|
179
|
-
await this.#runCtx.internalKeepAwake(
|
|
180
|
-
Promise.all([
|
|
181
|
-
this.#actor.driver.kvBatchPut(
|
|
182
|
-
this.#actor.id,
|
|
183
|
-
writes.map(({ key, value }) => [
|
|
184
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key),
|
|
185
|
-
value
|
|
186
|
-
])
|
|
187
|
-
),
|
|
188
|
-
this.#actor.stateManager.saveState({
|
|
189
|
-
immediate: true
|
|
190
|
-
})
|
|
191
|
-
])
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
async setAlarm(_workflowId, wakeAt) {
|
|
195
|
-
await this.#runCtx.internalKeepAwake(
|
|
196
|
-
this.#actor.driver.setAlarm(this.#actor, wakeAt)
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
async clearAlarm(_workflowId) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
waitForMessages(messageNames, abortSignal) {
|
|
203
|
-
return this.#actor.queueManager.waitForNames(
|
|
204
|
-
messageNames.length > 0 ? messageNames : void 0,
|
|
205
|
-
abortSignal
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
}, _class);
|
|
209
|
-
var NoopWorkflowMessageDriver = class {
|
|
210
|
-
async addMessage(_message) {
|
|
211
|
-
throw new Error("Workflow control driver does not support messages");
|
|
212
|
-
}
|
|
213
|
-
async receiveMessages(_opts) {
|
|
214
|
-
throw new Error("Workflow control driver does not support messages");
|
|
215
|
-
}
|
|
216
|
-
async completeMessage(_messageId, _response) {
|
|
217
|
-
throw new Error("Workflow control driver does not support messages");
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
var ActorWorkflowControlDriver = (_class2 = class {
|
|
221
|
-
__init2() {this.workerPollInterval = 100}
|
|
222
|
-
__init3() {this.messageDriver = new NoopWorkflowMessageDriver()}
|
|
223
|
-
#actor;
|
|
224
|
-
constructor(actor) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);
|
|
225
|
-
this.#actor = actor;
|
|
226
|
-
}
|
|
227
|
-
async get(key) {
|
|
228
|
-
const [value] = await this.#actor.driver.kvBatchGet(this.#actor.id, [
|
|
229
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key)
|
|
230
|
-
]);
|
|
231
|
-
return _nullishCoalesce(value, () => ( null));
|
|
232
|
-
}
|
|
233
|
-
async set(key, value) {
|
|
234
|
-
await this.#actor.driver.kvBatchPut(this.#actor.id, [
|
|
235
|
-
[_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key), value]
|
|
236
|
-
]);
|
|
237
|
-
}
|
|
238
|
-
async delete(key) {
|
|
239
|
-
await this.#actor.driver.kvBatchDelete(this.#actor.id, [
|
|
240
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key)
|
|
241
|
-
]);
|
|
242
|
-
}
|
|
243
|
-
async deletePrefix(prefix) {
|
|
244
|
-
const start = _chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, prefix);
|
|
245
|
-
const end = computeUpperBound(start);
|
|
246
|
-
if (end) {
|
|
247
|
-
await this.#actor.driver.kvDeleteRange(this.#actor.id, start, end);
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
const entries = await this.#actor.driver.kvListPrefix(
|
|
251
|
-
this.#actor.id,
|
|
252
|
-
start
|
|
253
|
-
);
|
|
254
|
-
if (entries.length === 0) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
await this.#actor.driver.kvBatchDelete(
|
|
258
|
-
this.#actor.id,
|
|
259
|
-
entries.map(([key]) => key)
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
async deleteRange(start, end) {
|
|
263
|
-
await this.#actor.driver.kvDeleteRange(
|
|
264
|
-
this.#actor.id,
|
|
265
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, start),
|
|
266
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, end)
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
async list(prefix) {
|
|
270
|
-
const entries = await this.#actor.driver.kvListPrefix(
|
|
271
|
-
this.#actor.id,
|
|
272
|
-
_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, prefix)
|
|
273
|
-
);
|
|
274
|
-
return entries.map(([key, value]) => ({
|
|
275
|
-
key: stripWorkflowKey(key),
|
|
276
|
-
value
|
|
277
|
-
}));
|
|
278
|
-
}
|
|
279
|
-
async batch(writes) {
|
|
280
|
-
if (writes.length === 0) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
await this.#actor.driver.kvBatchPut(
|
|
284
|
-
this.#actor.id,
|
|
285
|
-
writes.map(({ key, value }) => [_chunkLD5YASJUcjs.makeWorkflowKey.call(void 0, key), value])
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
async setAlarm(_workflowId, wakeAt) {
|
|
289
|
-
await this.#actor.driver.setAlarm(this.#actor, wakeAt);
|
|
290
|
-
}
|
|
291
|
-
async clearAlarm(_workflowId) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
waitForMessages(_messageNames, _abortSignal) {
|
|
295
|
-
throw new Error("Workflow control driver does not support messages");
|
|
296
|
-
}
|
|
297
|
-
}, _class2);
|
|
298
|
-
|
|
299
37
|
// src/workflow/constants.ts
|
|
300
38
|
var WORKFLOW_GUARD_KV_KEY = "__rivet_actor_workflow_guard_triggered";
|
|
301
39
|
|
|
@@ -346,14 +84,14 @@ var ActorWorkflowContext = class _ActorWorkflowContext {
|
|
|
346
84
|
return await this.#wrapActive(
|
|
347
85
|
() => this.#inner.step(
|
|
348
86
|
nameOrConfig,
|
|
349
|
-
() => this.#
|
|
87
|
+
() => this.#withActorAccessAndStateRollback(run)
|
|
350
88
|
)
|
|
351
89
|
);
|
|
352
90
|
}
|
|
353
91
|
const stepConfig = nameOrConfig;
|
|
354
92
|
const config = {
|
|
355
93
|
...stepConfig,
|
|
356
|
-
run: () => this.#
|
|
94
|
+
run: () => this.#withActorAccessAndStateRollback(stepConfig.run)
|
|
357
95
|
};
|
|
358
96
|
return await this.#wrapActive(() => this.#inner.step(config));
|
|
359
97
|
}
|
|
@@ -365,14 +103,14 @@ var ActorWorkflowContext = class _ActorWorkflowContext {
|
|
|
365
103
|
return await this.#wrapActive(
|
|
366
104
|
() => this.#inner.tryStep(
|
|
367
105
|
nameOrConfig,
|
|
368
|
-
() => this.#
|
|
106
|
+
() => this.#withActorAccessAndStateRollback(run)
|
|
369
107
|
)
|
|
370
108
|
);
|
|
371
109
|
}
|
|
372
110
|
const stepConfig = nameOrConfig;
|
|
373
111
|
const config = {
|
|
374
112
|
...stepConfig,
|
|
375
|
-
run: () => this.#
|
|
113
|
+
run: () => this.#withActorAccessAndStateRollback(stepConfig.run)
|
|
376
114
|
};
|
|
377
115
|
return await this.#wrapActive(() => this.#inner.tryStep(config));
|
|
378
116
|
}
|
|
@@ -515,7 +253,7 @@ var ActorWorkflowContext = class _ActorWorkflowContext {
|
|
|
515
253
|
let id;
|
|
516
254
|
try {
|
|
517
255
|
id = BigInt(message.id);
|
|
518
|
-
} catch (
|
|
256
|
+
} catch (e) {
|
|
519
257
|
throw new Error(`Invalid queue message id "${message.id}"`);
|
|
520
258
|
}
|
|
521
259
|
return {
|
|
@@ -543,6 +281,30 @@ var ActorWorkflowContext = class _ActorWorkflowContext {
|
|
|
543
281
|
}
|
|
544
282
|
}
|
|
545
283
|
}
|
|
284
|
+
async #withActorAccessAndStateRollback(run) {
|
|
285
|
+
let stateSnapshot = null;
|
|
286
|
+
try {
|
|
287
|
+
stateSnapshot = { state: this.#runCtx[_chunkNIY3RSPXcjs.RAW_STATE_SYMBOL]() };
|
|
288
|
+
} catch (error) {
|
|
289
|
+
this.#runCtx.log.debug({
|
|
290
|
+
msg: "failed to get state, likely due to being stateless workflow",
|
|
291
|
+
error
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (stateSnapshot) {
|
|
295
|
+
stateSnapshot.state = structuredClone(stateSnapshot.state);
|
|
296
|
+
}
|
|
297
|
+
const varsSnapshot = structuredClone(this.#runCtx.vars);
|
|
298
|
+
try {
|
|
299
|
+
return await this.#withActorAccess(run);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (stateSnapshot) {
|
|
302
|
+
this.#runCtx.state = stateSnapshot.state;
|
|
303
|
+
}
|
|
304
|
+
this.#runCtx.vars = varsSnapshot;
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
546
308
|
#ensureActorAccess(feature) {
|
|
547
309
|
if (!this.#allowActorAccess) {
|
|
548
310
|
this.#guardViolation = true;
|
|
@@ -563,7 +325,7 @@ var ActorWorkflowContext = class _ActorWorkflowContext {
|
|
|
563
325
|
if (state && typeof state === "object" && "guardTriggered" in state) {
|
|
564
326
|
state.guardTriggered = true;
|
|
565
327
|
}
|
|
566
|
-
} catch (
|
|
328
|
+
} catch (e2) {
|
|
567
329
|
}
|
|
568
330
|
this.#runCtx.waitUntil(
|
|
569
331
|
(async () => {
|
|
@@ -583,6 +345,269 @@ var ActorWorkflowContext = class _ActorWorkflowContext {
|
|
|
583
345
|
}
|
|
584
346
|
};
|
|
585
347
|
|
|
348
|
+
// src/workflow/driver.ts
|
|
349
|
+
var WORKFLOW_STORAGE_PREFIX = _chunkVE2X4KMGcjs.workflowStoragePrefix.call(void 0, );
|
|
350
|
+
function stripWorkflowKey(prefixed) {
|
|
351
|
+
return prefixed.slice(WORKFLOW_STORAGE_PREFIX.length);
|
|
352
|
+
}
|
|
353
|
+
function computeUpperBound(prefix) {
|
|
354
|
+
const upperBound = prefix.slice();
|
|
355
|
+
for (let i = upperBound.length - 1; i >= 0; i--) {
|
|
356
|
+
if (upperBound[i] !== 255) {
|
|
357
|
+
upperBound[i]++;
|
|
358
|
+
return upperBound.slice(0, i + 1);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
var ActorWorkflowMessageDriver = class {
|
|
364
|
+
#actor;
|
|
365
|
+
#runCtx;
|
|
366
|
+
constructor(actor, runCtx) {
|
|
367
|
+
this.#actor = actor;
|
|
368
|
+
this.#runCtx = runCtx;
|
|
369
|
+
}
|
|
370
|
+
async addMessage(message) {
|
|
371
|
+
await this.#runCtx.internalKeepAwake(
|
|
372
|
+
this.#actor.queueManager.enqueue(message.name, message.data)
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
async receiveMessages(opts) {
|
|
376
|
+
const messages = await this.#runCtx.internalKeepAwake(
|
|
377
|
+
this.#actor.queueManager.receive(
|
|
378
|
+
opts.names && opts.names.length > 0 ? [...opts.names] : void 0,
|
|
379
|
+
opts.count,
|
|
380
|
+
0,
|
|
381
|
+
void 0,
|
|
382
|
+
opts.completable
|
|
383
|
+
)
|
|
384
|
+
);
|
|
385
|
+
return messages.map((message) => ({
|
|
386
|
+
id: message.id.toString(),
|
|
387
|
+
name: message.name,
|
|
388
|
+
data: message.body,
|
|
389
|
+
sentAt: message.createdAt,
|
|
390
|
+
...opts.completable ? {
|
|
391
|
+
complete: async (response) => {
|
|
392
|
+
await this.#runCtx.internalKeepAwake(
|
|
393
|
+
this.#actor.queueManager.completeMessage(
|
|
394
|
+
message,
|
|
395
|
+
response
|
|
396
|
+
)
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
} : {}
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
async completeMessage(messageId, response) {
|
|
403
|
+
let parsedId;
|
|
404
|
+
try {
|
|
405
|
+
parsedId = BigInt(messageId);
|
|
406
|
+
} catch (e3) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
await this.#runCtx.internalKeepAwake(
|
|
410
|
+
this.#actor.queueManager.completeMessageById(parsedId, response)
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
var ActorWorkflowDriver = (_class = class {
|
|
415
|
+
__init() {this.workerPollInterval = 100}
|
|
416
|
+
|
|
417
|
+
#actor;
|
|
418
|
+
#runCtx;
|
|
419
|
+
constructor(actor, runCtx) {;_class.prototype.__init.call(this);
|
|
420
|
+
this.#actor = actor;
|
|
421
|
+
this.#runCtx = runCtx;
|
|
422
|
+
this.messageDriver = new ActorWorkflowMessageDriver(actor, runCtx);
|
|
423
|
+
}
|
|
424
|
+
async get(key) {
|
|
425
|
+
const [value] = await this.#runCtx.internalKeepAwake(
|
|
426
|
+
this.#actor.driver.kvBatchGet(this.#actor.id, [
|
|
427
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
|
|
428
|
+
])
|
|
429
|
+
);
|
|
430
|
+
return _nullishCoalesce(value, () => ( null));
|
|
431
|
+
}
|
|
432
|
+
async set(key, value) {
|
|
433
|
+
await this.#runCtx.internalKeepAwake(
|
|
434
|
+
this.#actor.driver.kvBatchPut(this.#actor.id, [
|
|
435
|
+
[_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key), value]
|
|
436
|
+
])
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
async delete(key) {
|
|
440
|
+
await this.#runCtx.internalKeepAwake(
|
|
441
|
+
this.#actor.driver.kvBatchDelete(this.#actor.id, [
|
|
442
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
|
|
443
|
+
])
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
async deletePrefix(prefix) {
|
|
447
|
+
const start = _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix);
|
|
448
|
+
const end = computeUpperBound(start);
|
|
449
|
+
if (end) {
|
|
450
|
+
await this.#runCtx.internalKeepAwake(
|
|
451
|
+
this.#actor.driver.kvDeleteRange(this.#actor.id, start, end)
|
|
452
|
+
);
|
|
453
|
+
} else {
|
|
454
|
+
const entries = await this.#runCtx.internalKeepAwake(
|
|
455
|
+
this.#actor.driver.kvListPrefix(this.#actor.id, start)
|
|
456
|
+
);
|
|
457
|
+
if (entries.length === 0) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
await this.#runCtx.internalKeepAwake(
|
|
461
|
+
this.#actor.driver.kvBatchDelete(
|
|
462
|
+
this.#actor.id,
|
|
463
|
+
entries.map(([key]) => key)
|
|
464
|
+
)
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async deleteRange(start, end) {
|
|
469
|
+
await this.#runCtx.internalKeepAwake(
|
|
470
|
+
this.#actor.driver.kvDeleteRange(
|
|
471
|
+
this.#actor.id,
|
|
472
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, start),
|
|
473
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, end)
|
|
474
|
+
)
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
async list(prefix) {
|
|
478
|
+
const entries = await this.#runCtx.internalKeepAwake(
|
|
479
|
+
this.#actor.driver.kvListPrefix(
|
|
480
|
+
this.#actor.id,
|
|
481
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix)
|
|
482
|
+
)
|
|
483
|
+
);
|
|
484
|
+
return entries.map(([key, value]) => ({
|
|
485
|
+
key: stripWorkflowKey(key),
|
|
486
|
+
value
|
|
487
|
+
}));
|
|
488
|
+
}
|
|
489
|
+
async batch(writes) {
|
|
490
|
+
if (writes.length === 0) return;
|
|
491
|
+
await this.#runCtx.internalKeepAwake(
|
|
492
|
+
Promise.all([
|
|
493
|
+
this.#actor.driver.kvBatchPut(
|
|
494
|
+
this.#actor.id,
|
|
495
|
+
writes.map(({ key, value }) => [
|
|
496
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key),
|
|
497
|
+
value
|
|
498
|
+
])
|
|
499
|
+
),
|
|
500
|
+
this.#actor.stateManager.saveState({
|
|
501
|
+
immediate: true
|
|
502
|
+
})
|
|
503
|
+
])
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
async setAlarm(_workflowId, wakeAt) {
|
|
507
|
+
await this.#runCtx.internalKeepAwake(
|
|
508
|
+
this.#actor.driver.setAlarm(this.#actor, wakeAt)
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
async clearAlarm(_workflowId) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
waitForMessages(messageNames, abortSignal) {
|
|
515
|
+
return this.#actor.queueManager.waitForNames(
|
|
516
|
+
messageNames.length > 0 ? messageNames : void 0,
|
|
517
|
+
abortSignal
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
}, _class);
|
|
521
|
+
var NoopWorkflowMessageDriver = class {
|
|
522
|
+
async addMessage(_message) {
|
|
523
|
+
throw new Error("Workflow control driver does not support messages");
|
|
524
|
+
}
|
|
525
|
+
async receiveMessages(_opts) {
|
|
526
|
+
throw new Error("Workflow control driver does not support messages");
|
|
527
|
+
}
|
|
528
|
+
async completeMessage(_messageId, _response) {
|
|
529
|
+
throw new Error("Workflow control driver does not support messages");
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
var ActorWorkflowControlDriver = (_class2 = class {
|
|
533
|
+
__init2() {this.workerPollInterval = 100}
|
|
534
|
+
__init3() {this.messageDriver = new NoopWorkflowMessageDriver()}
|
|
535
|
+
#actor;
|
|
536
|
+
constructor(actor) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);
|
|
537
|
+
this.#actor = actor;
|
|
538
|
+
}
|
|
539
|
+
async get(key) {
|
|
540
|
+
const [value] = await this.#actor.driver.kvBatchGet(this.#actor.id, [
|
|
541
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
|
|
542
|
+
]);
|
|
543
|
+
return _nullishCoalesce(value, () => ( null));
|
|
544
|
+
}
|
|
545
|
+
async set(key, value) {
|
|
546
|
+
await this.#actor.driver.kvBatchPut(this.#actor.id, [
|
|
547
|
+
[_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key), value]
|
|
548
|
+
]);
|
|
549
|
+
}
|
|
550
|
+
async delete(key) {
|
|
551
|
+
await this.#actor.driver.kvBatchDelete(this.#actor.id, [
|
|
552
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key)
|
|
553
|
+
]);
|
|
554
|
+
}
|
|
555
|
+
async deletePrefix(prefix) {
|
|
556
|
+
const start = _chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix);
|
|
557
|
+
const end = computeUpperBound(start);
|
|
558
|
+
if (end) {
|
|
559
|
+
await this.#actor.driver.kvDeleteRange(this.#actor.id, start, end);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
const entries = await this.#actor.driver.kvListPrefix(
|
|
563
|
+
this.#actor.id,
|
|
564
|
+
start
|
|
565
|
+
);
|
|
566
|
+
if (entries.length === 0) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
await this.#actor.driver.kvBatchDelete(
|
|
570
|
+
this.#actor.id,
|
|
571
|
+
entries.map(([key]) => key)
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
async deleteRange(start, end) {
|
|
575
|
+
await this.#actor.driver.kvDeleteRange(
|
|
576
|
+
this.#actor.id,
|
|
577
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, start),
|
|
578
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, end)
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
async list(prefix) {
|
|
582
|
+
const entries = await this.#actor.driver.kvListPrefix(
|
|
583
|
+
this.#actor.id,
|
|
584
|
+
_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, prefix)
|
|
585
|
+
);
|
|
586
|
+
return entries.map(([key, value]) => ({
|
|
587
|
+
key: stripWorkflowKey(key),
|
|
588
|
+
value
|
|
589
|
+
}));
|
|
590
|
+
}
|
|
591
|
+
async batch(writes) {
|
|
592
|
+
if (writes.length === 0) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
await this.#actor.driver.kvBatchPut(
|
|
596
|
+
this.#actor.id,
|
|
597
|
+
writes.map(({ key, value }) => [_chunkVE2X4KMGcjs.makeWorkflowKey.call(void 0, key), value])
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
async setAlarm(_workflowId, wakeAt) {
|
|
601
|
+
await this.#actor.driver.setAlarm(this.#actor, wakeAt);
|
|
602
|
+
}
|
|
603
|
+
async clearAlarm(_workflowId) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
waitForMessages(_messageNames, _abortSignal) {
|
|
607
|
+
throw new Error("Workflow control driver does not support messages");
|
|
608
|
+
}
|
|
609
|
+
}, _class2);
|
|
610
|
+
|
|
586
611
|
// src/workflow/mod.ts
|
|
587
612
|
|
|
588
613
|
function shouldRethrowWorkflowError(error) {
|
|
@@ -595,7 +620,7 @@ function shouldRethrowWorkflowError(error) {
|
|
|
595
620
|
return true;
|
|
596
621
|
}
|
|
597
622
|
function workflowReplayInFlightError() {
|
|
598
|
-
return new (0,
|
|
623
|
+
return new (0, _chunkKORQB2IRcjs.RivetError)(
|
|
599
624
|
"actor",
|
|
600
625
|
"workflow_in_flight",
|
|
601
626
|
"Workflow replay is unavailable while the workflow is currently in flight.",
|
|
@@ -614,13 +639,13 @@ function workflow(fn, options = {}) {
|
|
|
614
639
|
function getWorkflowInspector(actorId) {
|
|
615
640
|
let workflowInspector = workflowInspectors.get(actorId);
|
|
616
641
|
if (!workflowInspector) {
|
|
617
|
-
workflowInspector =
|
|
642
|
+
workflowInspector = _chunkB6VUNZUDcjs.createWorkflowInspectorAdapter.call(void 0, );
|
|
618
643
|
workflowInspectors.set(actorId, workflowInspector);
|
|
619
644
|
}
|
|
620
645
|
return workflowInspector;
|
|
621
646
|
}
|
|
622
647
|
async function run(runCtx) {
|
|
623
|
-
const actor = runCtx[
|
|
648
|
+
const actor = runCtx[_chunkNIY3RSPXcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL];
|
|
624
649
|
_invariant2.default.call(void 0, actor, "workflow() requires an actor instance");
|
|
625
650
|
const workflowInspector = getWorkflowInspector(actor.id);
|
|
626
651
|
const driver = new ActorWorkflowDriver(actor, runCtx);
|
|
@@ -680,20 +705,20 @@ function workflow(fn, options = {}) {
|
|
|
680
705
|
if (shouldRethrowWorkflowError(error)) {
|
|
681
706
|
runCtx.log.error({
|
|
682
707
|
msg: "workflow run failed",
|
|
683
|
-
error:
|
|
708
|
+
error: _chunkDXXJPH55cjs.stringifyError.call(void 0, error)
|
|
684
709
|
});
|
|
685
710
|
throw error;
|
|
686
711
|
}
|
|
687
712
|
runCtx.log.warn({
|
|
688
713
|
msg: "workflow failed and will sleep until woken",
|
|
689
|
-
error:
|
|
714
|
+
error: _chunkDXXJPH55cjs.stringifyError.call(void 0, error)
|
|
690
715
|
});
|
|
691
716
|
} finally {
|
|
692
717
|
runCtx.abortSignal.removeEventListener("abort", onAbort);
|
|
693
718
|
}
|
|
694
719
|
}
|
|
695
720
|
const runWithConfig = run;
|
|
696
|
-
runWithConfig[
|
|
721
|
+
runWithConfig[_chunkNIY3RSPXcjs.RUN_FUNCTION_CONFIG_SYMBOL] = {
|
|
697
722
|
icon: "diagram-project",
|
|
698
723
|
inspectorFactory: (actor) => {
|
|
699
724
|
const actorId = resolveWorkflowInspectorActorId(actor);
|