rivetkit 0.0.0-active-actors-fix-active-count.253e406 → 0.0.0-bisect-sync-sqlite-1.910d1c7
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 +1286 -89
- package/dist/browser/client.js +1699 -704
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2083 -236
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +8 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +7 -1
- package/dist/tsup/agent-os/index.cjs +3 -2289
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -1813
- package/dist/tsup/agent-os/index.d.ts +1 -1813
- package/dist/tsup/agent-os/index.js +3 -2289
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/chunk-2JJU7IQ7.cjs +14 -0
- package/dist/tsup/chunk-2JJU7IQ7.cjs.map +1 -0
- package/dist/tsup/{chunk-DZJZLZ4R.js → chunk-2MXBZGUP.js} +2 -2
- package/dist/tsup/{chunk-L4FVS7GY.js → chunk-47IS5ZFI.js} +6 -6
- package/dist/tsup/chunk-47IS5ZFI.js.map +1 -0
- package/dist/tsup/{chunk-DXWOGCZY.js → chunk-5XWY5CBA.js} +70 -8
- package/dist/tsup/chunk-5XWY5CBA.js.map +1 -0
- package/dist/tsup/{chunk-OQEEZDIK.cjs → chunk-6XVNZKKP.cjs} +506 -31
- package/dist/tsup/chunk-6XVNZKKP.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-A2CF6PFH.js} +20 -12
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-AQJFKHBK.cjs} +276 -27
- package/dist/tsup/chunk-AQJFKHBK.cjs.map +1 -0
- package/dist/tsup/chunk-DPWLASMC.cjs +244 -0
- package/dist/tsup/chunk-DPWLASMC.cjs.map +1 -0
- package/dist/tsup/{chunk-VUF2YEF4.cjs → chunk-DYJOU3MF.cjs} +10 -10
- package/dist/tsup/chunk-DYJOU3MF.cjs.map +1 -0
- package/dist/tsup/{chunk-7WXCRV25.cjs → chunk-ELZ6MT3V.cjs} +18 -11
- package/dist/tsup/chunk-ELZ6MT3V.cjs.map +1 -0
- package/dist/tsup/chunk-HYIVSH5X.js +244 -0
- package/dist/tsup/chunk-HYIVSH5X.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-IHEO5OT3.js} +275 -26
- package/dist/tsup/chunk-IHEO5OT3.js.map +1 -0
- package/dist/tsup/chunk-IWACVNN5.js +14 -0
- package/dist/tsup/chunk-IWACVNN5.js.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-V4JUWAT6.js → chunk-K3AJOPSF.js} +498 -23
- package/dist/tsup/chunk-K3AJOPSF.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-MGI2VVF6.cjs} +45 -9
- package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
- package/dist/tsup/{chunk-QNLGOTQP.js → chunk-NPHTIUUJ.js} +1291 -420
- package/dist/tsup/chunk-NPHTIUUJ.js.map +1 -0
- package/dist/tsup/{chunk-7GKQJFSB.cjs → chunk-POCSZXPQ.cjs} +72 -10
- package/dist/tsup/chunk-POCSZXPQ.cjs.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-RTWH3AX3.cjs} +19 -11
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-ARRBQTAR.cjs → chunk-X76BM5JS.cjs} +1420 -549
- package/dist/tsup/chunk-X76BM5JS.cjs.map +1 -0
- package/dist/tsup/{chunk-AGBP757I.js → chunk-X7SYKFPM.js} +16 -9
- package/dist/tsup/chunk-X7SYKFPM.js.map +1 -0
- package/dist/tsup/{chunk-GKAMEBTZ.cjs → chunk-XLDJSZ3B.cjs} +3 -3
- package/dist/tsup/{chunk-GKAMEBTZ.cjs.map → chunk-XLDJSZ3B.cjs.map} +1 -1
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-ZOVJDAOW.js} +44 -8
- package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
- package/dist/tsup/client/mod.cjs +8 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +33 -7
- package/dist/tsup/client/mod.d.ts +33 -7
- package/dist/tsup/client/mod.js +7 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-nlTlOKaE.d.cts → config-BMGUEKMZ.d.cts} +1252 -75
- package/dist/tsup/config-CBTr4IhE.d.cts +224 -0
- package/dist/tsup/config-CBTr4IhE.d.ts +224 -0
- package/dist/tsup/{config-D7ykAntK.d.ts → config-iBpXyITj.d.ts} +1252 -75
- package/dist/tsup/context-hyVakgnU.d.ts +136 -0
- package/dist/tsup/context-qfvLuF0P.d.cts +136 -0
- package/dist/tsup/db/drizzle.cjs +127 -67
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +8 -4
- package/dist/tsup/db/drizzle.d.ts +8 -4
- package/dist/tsup/db/drizzle.js +127 -67
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +6 -124
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +12 -4
- package/dist/tsup/db/mod.d.ts +12 -4
- package/dist/tsup/db/mod.js +5 -123
- package/dist/tsup/db/mod.js.map +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 +39 -0
- package/dist/tsup/dynamic/mod.d.ts +39 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +26 -136
- package/dist/tsup/inspector/mod.d.ts +26 -136
- package/dist/tsup/inspector/mod.js +46 -11
- 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 +162 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +242 -0
- package/dist/tsup/inspector-tab/mod.d.ts +242 -0
- package/dist/tsup/inspector-tab/mod.js +162 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +3527 -753
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +11 -7
- package/dist/tsup/mod.d.ts +11 -7
- package/dist/tsup/mod.js +3468 -694
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +26 -21
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +7 -5
- package/dist/tsup/test/mod.d.ts +7 -5
- package/dist/tsup/test/mod.js +25 -20
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-3rsE0JvI.d.cts} +26 -2
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-3rsE0JvI.d.ts} +26 -2
- package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
- package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
- package/dist/tsup/utils.cjs +7 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +4 -147
- package/dist/tsup/utils.d.ts +4 -147
- package/dist/tsup/utils.js +6 -2
- package/dist/tsup/workflow/mod.cjs +557 -410
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +11 -9
- package/dist/tsup/workflow/mod.d.ts +11 -9
- package/dist/tsup/workflow/mod.js +551 -404
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +67 -18
- package/src/actor/actions.ts +155 -0
- package/src/actor/config.ts +679 -101
- package/src/actor/contexts/index.ts +9 -2
- package/src/actor/definition.ts +75 -26
- package/src/actor/errors.ts +107 -8
- package/src/actor/keys.ts +87 -1
- package/src/actor/mod.ts +36 -20
- package/src/actor/schema.ts +6 -2
- package/src/actor/tracing.ts +28 -0
- package/src/agent-os/index.ts +5 -64
- package/src/client/actor-common.ts +84 -54
- package/src/client/actor-conn.ts +231 -68
- package/src/client/actor-handle.ts +283 -89
- package/src/client/actor-query.ts +13 -6
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +182 -21
- package/src/client/config.ts +28 -3
- package/src/client/errors.ts +15 -2
- package/src/client/lifecycle-errors.ts +63 -5
- package/src/client/mod.ts +10 -0
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/query.ts +3 -1
- package/src/client/queue.ts +13 -3
- package/src/client/raw-utils.ts +59 -14
- package/src/client/resolve-gateway-target.ts +3 -1
- package/src/client/retry-budget.ts +81 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +22 -9
- package/src/common/actor-router-consts.ts +6 -0
- package/src/common/actor-telemetry-context.ts +19 -0
- 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/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/generated/inspector/v6.ts +1367 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +175 -9
- package/src/common/database/mod.ts +262 -77
- package/src/common/database/native-database.ts +442 -20
- package/src/common/database/shared.ts +25 -0
- package/src/common/encoding.ts +278 -34
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/fetch-like.ts +63 -0
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +15 -8
- package/src/common/otel-context.ts +99 -0
- package/src/common/router.ts +14 -18
- package/src/common/utils.ts +8 -169
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.ts +182 -80
- package/src/db/mod.ts +5 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +64 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-api/actors.ts +15 -3
- package/src/engine-client/actor-http-client.ts +37 -22
- package/src/engine-client/actor-websocket-client.ts +37 -9
- package/src/engine-client/api-endpoints.ts +128 -5
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +21 -16
- package/src/engine-client/mod.ts +280 -111
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +127 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +301 -0
- package/src/registry/config/envoy.ts +3 -20
- package/src/registry/config/index.ts +91 -74
- package/src/registry/index.ts +702 -80
- package/src/registry/napi-runtime.ts +643 -42
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +1881 -582
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.ts +441 -7
- package/src/registry/wasm-runtime.ts +516 -23
- package/src/registry/write-through-proxy.ts +141 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +2 -17
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +50 -2
- package/src/utils/node.ts +44 -28
- package/src/utils/router.ts +1 -1
- package/src/utils.ts +4 -2
- package/src/workflow/context.ts +703 -242
- package/src/workflow/driver.ts +284 -125
- package/src/workflow/inspector.ts +24 -24
- package/src/workflow/mod.ts +76 -84
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-6NT2LIFN.cjs +0 -268
- package/dist/tsup/chunk-6NT2LIFN.cjs.map +0 -1
- package/dist/tsup/chunk-7GKQJFSB.cjs.map +0 -1
- package/dist/tsup/chunk-7WXCRV25.cjs.map +0 -1
- package/dist/tsup/chunk-AGBP757I.js.map +0 -1
- package/dist/tsup/chunk-ARRBQTAR.cjs.map +0 -1
- package/dist/tsup/chunk-DXWOGCZY.js.map +0 -1
- package/dist/tsup/chunk-JGIPV3QU.js +0 -268
- package/dist/tsup/chunk-JGIPV3QU.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-L4FVS7GY.js.map +0 -1
- package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
- package/dist/tsup/chunk-OQEEZDIK.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-QAZLM4WT.cjs.map +0 -1
- package/dist/tsup/chunk-QNLGOTQP.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-V4JUWAT6.js.map +0 -1
- package/dist/tsup/chunk-VUF2YEF4.cjs.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/config-CxjGYf4K.d.cts +0 -121
- package/dist/tsup/config-CxjGYf4K.d.ts +0 -121
- package/dist/tsup/context-88opQsfZ.d.cts +0 -92
- package/dist/tsup/context-CVEG5zfg.d.ts +0 -92
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2492
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/agent-os/actor/cron.ts +0 -84
- package/src/agent-os/actor/db.ts +0 -54
- package/src/agent-os/actor/filesystem.ts +0 -131
- package/src/agent-os/actor/index.ts +0 -265
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -191
- package/src/agent-os/actor/process.ts +0 -177
- package/src/agent-os/actor/session.ts +0 -518
- package/src/agent-os/actor/shell.ts +0 -60
- package/src/agent-os/config.ts +0 -79
- package/src/agent-os/fs/database-vfs.ts +0 -624
- package/src/agent-os/types.ts +0 -148
- package/src/client/test.ts +0 -44
- package/src/common/database/mod.test.ts +0 -137
- package/src/common/database/native-database.test.ts +0 -211
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/drivers/engine/actor-driver.ts +0 -2460
- package/src/registry/runtime.test.ts +0 -50
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils/serve.ts +0 -217
- package/src/utils.test.ts +0 -34
- /package/dist/tsup/{chunk-DZJZLZ4R.js.map → chunk-2MXBZGUP.js.map} +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
-
import {
|
|
3
|
-
import { A as AnyDatabaseProvider, I as InferDatabaseClient } from './config-CxjGYf4K.js';
|
|
2
|
+
import { A as AnyDatabaseProvider, a as SqliteProfilingOptions, f as SqliteNativeMetrics, I as InferDatabaseClient } from './config-CBTr4IhE.js';
|
|
4
3
|
import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
|
|
5
4
|
import { z as z$1 } from 'zod';
|
|
6
5
|
import { Logger } from 'pino';
|
|
6
|
+
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
7
|
+
import { WorkflowState } from './inspector/workflow.js';
|
|
7
8
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
9
|
+
import { Rivet } from '@rivetkit/engine-api-full';
|
|
10
|
+
import { E as Encoding, G as GetUpgradeWebSocket } from './utils-C1O-SklO.js';
|
|
8
11
|
import { Context, Hono } from 'hono';
|
|
9
|
-
import {
|
|
10
|
-
import { R as RivetError } from './utils-DVekpm4I.js';
|
|
12
|
+
import { R as RivetError } from './utils-3rsE0JvI.js';
|
|
11
13
|
|
|
12
14
|
declare const ActorKeySchema: z.ZodArray<z.ZodString>;
|
|
13
15
|
type ActorKey = z.infer<typeof ActorKeySchema>;
|
|
@@ -28,6 +30,7 @@ declare const CreateRequestSchema: z.ZodObject<{
|
|
|
28
30
|
key: z.ZodArray<z.ZodString>;
|
|
29
31
|
input: z.ZodOptional<z.ZodUnknown>;
|
|
30
32
|
region: z.ZodOptional<z.ZodString>;
|
|
33
|
+
poolName: z.ZodOptional<z.ZodString>;
|
|
31
34
|
}, z.core.$strip>;
|
|
32
35
|
declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
33
36
|
getForId: z.ZodObject<{
|
|
@@ -45,6 +48,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
45
48
|
key: z.ZodArray<z.ZodString>;
|
|
46
49
|
input: z.ZodOptional<z.ZodUnknown>;
|
|
47
50
|
region: z.ZodOptional<z.ZodString>;
|
|
51
|
+
poolName: z.ZodOptional<z.ZodString>;
|
|
48
52
|
}, z.core.$strip>;
|
|
49
53
|
}, z.core.$strip>, z.ZodObject<{
|
|
50
54
|
create: z.ZodObject<{
|
|
@@ -52,6 +56,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
52
56
|
key: z.ZodArray<z.ZodString>;
|
|
53
57
|
input: z.ZodOptional<z.ZodUnknown>;
|
|
54
58
|
region: z.ZodOptional<z.ZodString>;
|
|
59
|
+
poolName: z.ZodOptional<z.ZodString>;
|
|
55
60
|
}, z.core.$strip>;
|
|
56
61
|
}, z.core.$strip>]>;
|
|
57
62
|
type ActorQuery = z.infer<typeof ActorQuerySchema>;
|
|
@@ -60,17 +65,7 @@ type ActorQuery = z.infer<typeof ActorQuerySchema>;
|
|
|
60
65
|
*/
|
|
61
66
|
type CreateRequest = z.infer<typeof CreateRequestSchema>;
|
|
62
67
|
|
|
63
|
-
declare const
|
|
64
|
-
json: "json";
|
|
65
|
-
cbor: "cbor";
|
|
66
|
-
bare: "bare";
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* Encoding used to communicate between the client & actor.
|
|
70
|
-
*/
|
|
71
|
-
type Encoding = z.infer<typeof EncodingSchema>;
|
|
72
|
-
|
|
73
|
-
declare const ActorsSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodCustom<BaseActorDefinition<any, any, any, any, any, any, any, any, any>, BaseActorDefinition<any, any, any, any, any, any, any, any, any>>>;
|
|
68
|
+
declare const ActorsSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
74
69
|
type RegistryActors = z$1.infer<typeof ActorsSchema>;
|
|
75
70
|
declare const RuntimeKindSchema: z$1.ZodEnum<{
|
|
76
71
|
auto: "auto";
|
|
@@ -167,7 +162,10 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
|
167
162
|
httpPort: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
168
163
|
httpHost: z$1.ZodOptional<z$1.ZodString>;
|
|
169
164
|
startEngine: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
165
|
+
engineHost: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
166
|
+
enginePort: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
170
167
|
engineVersion: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
168
|
+
startServices: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
171
169
|
configurePool: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
|
|
172
170
|
name: z$1.ZodOptional<z$1.ZodString>;
|
|
173
171
|
url: z$1.ZodString;
|
|
@@ -184,14 +182,14 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
|
184
182
|
publicEndpoint: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
185
183
|
publicToken: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
186
184
|
}, z$1.core.$strip>>>;
|
|
187
|
-
|
|
185
|
+
node: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
|
|
188
186
|
poolName: z$1.ZodDefault<z$1.ZodString>;
|
|
189
187
|
version: z$1.ZodDefault<z$1.ZodNumber>;
|
|
190
188
|
totalSlots: z$1.ZodDefault<z$1.ZodNumber>;
|
|
191
|
-
|
|
189
|
+
nodeKey: z$1.ZodOptional<z$1.ZodString>;
|
|
192
190
|
}, z$1.core.$strip>>>;
|
|
193
191
|
shutdown: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
|
|
194
|
-
gracePeriodMs: z$1.
|
|
192
|
+
gracePeriodMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
195
193
|
disableSignalHandlers: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
196
194
|
}, z$1.core.$strip>>>;
|
|
197
195
|
}, z$1.core.$strip>, z$1.ZodTransform<{
|
|
@@ -199,6 +197,8 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
|
199
197
|
backend: "local" | "remote";
|
|
200
198
|
} | undefined;
|
|
201
199
|
endpoint: string | undefined;
|
|
200
|
+
engineSpawn: boolean;
|
|
201
|
+
startServices: boolean;
|
|
202
202
|
namespace: string;
|
|
203
203
|
token: string | undefined;
|
|
204
204
|
publicEndpoint: string | undefined;
|
|
@@ -232,16 +232,18 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
|
232
232
|
httpBasePath: string;
|
|
233
233
|
httpPort: number;
|
|
234
234
|
startEngine: boolean;
|
|
235
|
+
engineHost: string;
|
|
236
|
+
enginePort: number;
|
|
235
237
|
engineVersion: string;
|
|
236
|
-
|
|
238
|
+
node: {
|
|
237
239
|
poolName: string;
|
|
238
240
|
version: number;
|
|
239
241
|
totalSlots: number;
|
|
240
|
-
|
|
242
|
+
nodeKey?: string | undefined;
|
|
241
243
|
};
|
|
242
244
|
shutdown: {
|
|
243
|
-
gracePeriodMs: number;
|
|
244
245
|
disableSignalHandlers: boolean;
|
|
246
|
+
gracePeriodMs?: number | undefined;
|
|
245
247
|
};
|
|
246
248
|
staticDir?: string | undefined;
|
|
247
249
|
httpHost?: string | undefined;
|
|
@@ -283,6 +285,8 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
|
283
285
|
httpBasePath: string;
|
|
284
286
|
httpPort: number;
|
|
285
287
|
startEngine: boolean;
|
|
288
|
+
engineHost: string;
|
|
289
|
+
enginePort: number;
|
|
286
290
|
engineVersion: string;
|
|
287
291
|
serverless: {
|
|
288
292
|
basePath: string;
|
|
@@ -290,18 +294,19 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
|
290
294
|
publicEndpoint: string | undefined;
|
|
291
295
|
publicToken: string | undefined;
|
|
292
296
|
};
|
|
293
|
-
|
|
297
|
+
node: {
|
|
294
298
|
poolName: string;
|
|
295
299
|
version: number;
|
|
296
300
|
totalSlots: number;
|
|
297
|
-
|
|
301
|
+
nodeKey?: string | undefined;
|
|
298
302
|
};
|
|
299
303
|
shutdown: {
|
|
300
|
-
gracePeriodMs: number;
|
|
301
304
|
disableSignalHandlers: boolean;
|
|
305
|
+
gracePeriodMs?: number | undefined;
|
|
302
306
|
};
|
|
303
307
|
staticDir?: string | undefined;
|
|
304
308
|
httpHost?: string | undefined;
|
|
309
|
+
startServices?: boolean | undefined;
|
|
305
310
|
configurePool?: {
|
|
306
311
|
url: string;
|
|
307
312
|
name?: string | undefined;
|
|
@@ -339,7 +344,7 @@ declare const DocServerlessConfigSchema: z$1.ZodObject<{
|
|
|
339
344
|
declare const DocEnvoyConfigSchema: z$1.ZodObject<{
|
|
340
345
|
totalSlots: z$1.ZodOptional<z$1.ZodNumber>;
|
|
341
346
|
poolName: z$1.ZodOptional<z$1.ZodString>;
|
|
342
|
-
|
|
347
|
+
nodeKey: z$1.ZodOptional<z$1.ZodString>;
|
|
343
348
|
version: z$1.ZodOptional<z$1.ZodNumber>;
|
|
344
349
|
}, z$1.core.$strip>;
|
|
345
350
|
declare const DocSqliteConfigSchema: z$1.ZodOptional<z$1.ZodObject<{
|
|
@@ -380,6 +385,7 @@ declare const DocRegistryConfigSchema: z$1.ZodObject<{
|
|
|
380
385
|
httpHost: z$1.ZodOptional<z$1.ZodString>;
|
|
381
386
|
startEngine: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
382
387
|
engineVersion: z$1.ZodOptional<z$1.ZodString>;
|
|
388
|
+
startServices: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
383
389
|
configurePool: z$1.ZodOptional<z$1.ZodObject<{
|
|
384
390
|
name: z$1.ZodOptional<z$1.ZodString>;
|
|
385
391
|
url: z$1.ZodString;
|
|
@@ -396,10 +402,10 @@ declare const DocRegistryConfigSchema: z$1.ZodObject<{
|
|
|
396
402
|
publicEndpoint: z$1.ZodOptional<z$1.ZodString>;
|
|
397
403
|
publicToken: z$1.ZodOptional<z$1.ZodString>;
|
|
398
404
|
}, z$1.core.$strip>>;
|
|
399
|
-
|
|
405
|
+
node: z$1.ZodOptional<z$1.ZodObject<{
|
|
400
406
|
totalSlots: z$1.ZodOptional<z$1.ZodNumber>;
|
|
401
407
|
poolName: z$1.ZodOptional<z$1.ZodString>;
|
|
402
|
-
|
|
408
|
+
nodeKey: z$1.ZodOptional<z$1.ZodString>;
|
|
403
409
|
version: z$1.ZodOptional<z$1.ZodNumber>;
|
|
404
410
|
}, z$1.core.$strip>>;
|
|
405
411
|
}, z$1.core.$strip>;
|
|
@@ -414,6 +420,7 @@ interface EventTypeToken<T, TContext = any> {
|
|
|
414
420
|
interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
|
|
415
421
|
readonly _queueMessage?: TMessage;
|
|
416
422
|
readonly _queueComplete?: TComplete;
|
|
423
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
417
424
|
readonly canPublish?: SchemaHook<TContext>;
|
|
418
425
|
readonly message?: PrimitiveSchema;
|
|
419
426
|
readonly complete?: PrimitiveSchema;
|
|
@@ -425,11 +432,13 @@ interface EventOptions<TContext = any> {
|
|
|
425
432
|
schema?: PrimitiveSchema;
|
|
426
433
|
}
|
|
427
434
|
interface QueueOptions<TContext = any> {
|
|
435
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
428
436
|
canPublish?: SchemaHook<TContext>;
|
|
429
437
|
message?: PrimitiveSchema;
|
|
430
438
|
complete?: PrimitiveSchema;
|
|
431
439
|
}
|
|
432
440
|
declare function event<T, TContext = any>(options?: EventOptions<TContext>): EventTypeToken<T, TContext>;
|
|
441
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
433
442
|
declare function queue<TMessage, TComplete = never, TContext = any>(options?: QueueOptions<TContext>): QueueTypeToken<TMessage, TComplete, TContext>;
|
|
434
443
|
type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
|
|
435
444
|
interface EventSchemaDefinition<TContext = any> {
|
|
@@ -439,12 +448,13 @@ interface EventSchemaDefinition<TContext = any> {
|
|
|
439
448
|
interface QueueSchemaDefinition<TContext = any> {
|
|
440
449
|
message: PrimitiveSchema;
|
|
441
450
|
complete?: PrimitiveSchema;
|
|
451
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
442
452
|
canPublish?: SchemaHook<TContext>;
|
|
443
453
|
}
|
|
444
454
|
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
445
455
|
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
446
456
|
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
447
|
-
type QueueSchemaConfig<
|
|
457
|
+
type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
|
|
448
458
|
type InferSchema<T> = T extends QueueSchemaDefinition<any> ? InferSchema<T["message"]> : T extends QueueTypeToken<infer M, unknown, any> ? M : T extends EventSchemaDefinition<any> ? InferSchema<T["schema"]> : T extends StandardSchemaV1<any, infer O> ? O : T extends EventTypeToken<infer R, any> ? R : never;
|
|
449
459
|
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
450
460
|
[K in keyof T]: InferSchema<T[K]>;
|
|
@@ -455,15 +465,17 @@ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
|
455
465
|
};
|
|
456
466
|
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
457
467
|
|
|
458
|
-
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>,
|
|
459
|
-
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
468
|
+
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, _R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> {
|
|
469
|
+
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
|
|
470
|
+
}
|
|
471
|
+
interface AnyActorDefinition {
|
|
472
|
+
readonly config: any;
|
|
460
473
|
}
|
|
461
|
-
type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
|
|
462
474
|
type AnyStaticActorDefinition = ActorDefinition<any, any, any, any, any, any, any, any, any>;
|
|
463
475
|
declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> implements BaseActorDefinition<S, CP, CS, V, I, DB, E, Q, R> {
|
|
464
476
|
#private;
|
|
465
|
-
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
|
|
466
|
-
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
477
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
|
|
478
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
467
479
|
}
|
|
468
480
|
interface BaseActorInstance<S = any, CP = any, CS = any, V = any, I = any, DB extends AnyDatabaseProvider = AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
|
|
469
481
|
id: string;
|
|
@@ -478,6 +490,26 @@ declare function actor<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
478
490
|
declare function isStaticActorDefinition(definition: AnyActorDefinition): definition is AnyStaticActorDefinition;
|
|
479
491
|
declare function lookupInRegistry(config: RegistryConfig, name: string): AnyActorDefinition;
|
|
480
492
|
|
|
493
|
+
/** A namespace-scoped Engine grant. The caller must provide every grant explicitly. */
|
|
494
|
+
type TokenGrant = Rivet.AuthTokenGrant;
|
|
495
|
+
/** Options for `client.auth.issueToken()`. `expiresIn` is in seconds. */
|
|
496
|
+
type IssueTokenOptions = Pick<Rivet.AuthTokenCreateRequest, "subject" | "grants"> & {
|
|
497
|
+
expiresIn?: Rivet.AuthTokenCreateRequest["duration"];
|
|
498
|
+
};
|
|
499
|
+
/** Token timestamps are Unix milliseconds. */
|
|
500
|
+
interface IssuedToken {
|
|
501
|
+
token: Rivet.AuthTokenCreateResponse["token"];
|
|
502
|
+
issuedAt: Rivet.AuthTokenCreateResponse["issuedTs"];
|
|
503
|
+
expiresAt: Rivet.AuthTokenCreateResponse["expiresTs"];
|
|
504
|
+
}
|
|
505
|
+
/** Resources that can be scoped to a single actor ID. */
|
|
506
|
+
type ActorTokenResource = Extract<Rivet.AuthTokenGrant["resource"], "actor_gateway" | "actor" | "actor_kv">;
|
|
507
|
+
type ActorTokenPermissions = Partial<Record<ActorTokenResource, Rivet.AuthTokenGrant["operations"]>>;
|
|
508
|
+
/** Options for `actor.issueToken()`. Omit permissions for gateway read access only. */
|
|
509
|
+
type ActorIssueTokenOptions = Pick<IssueTokenOptions, "subject" | "expiresIn"> & {
|
|
510
|
+
permissions?: ActorTokenPermissions;
|
|
511
|
+
};
|
|
512
|
+
|
|
481
513
|
type GatewayTarget = {
|
|
482
514
|
directId: string;
|
|
483
515
|
} | ActorQuery;
|
|
@@ -485,13 +517,18 @@ interface GatewayRequestOptions {
|
|
|
485
517
|
skipReadyWait?: boolean;
|
|
486
518
|
}
|
|
487
519
|
interface EngineControlClient {
|
|
520
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
488
521
|
getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
|
|
489
522
|
getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
|
|
490
523
|
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
491
524
|
createActor(input: CreateInput): Promise<ActorOutput>;
|
|
525
|
+
/** Forks the actor `actorId` into a new actor of the same name, started on a copy of its database. */
|
|
526
|
+
forkActor(input: ForkInput): Promise<ActorOutput>;
|
|
492
527
|
listActors(input: ListActorsInput): Promise<ActorOutput[]>;
|
|
493
528
|
sendRequest(target: GatewayTarget, actorRequest: Request, options?: GatewayRequestOptions): Promise<Response>;
|
|
494
529
|
openWebSocket(path: string, target: GatewayTarget, encoding: Encoding, params: unknown, options?: GatewayRequestOptions): Promise<UniversalWebSocket>;
|
|
530
|
+
/** Refresh a credential rejected during this WebSocket handshake, if supported. */
|
|
531
|
+
refreshAuthToken?(ws: UniversalWebSocket): Promise<boolean>;
|
|
495
532
|
proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
|
|
496
533
|
proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown): Promise<Response>;
|
|
497
534
|
buildGatewayUrl(target: GatewayTarget, options?: GatewayRequestOptions): Promise<string>;
|
|
@@ -504,11 +541,6 @@ interface EngineControlClient {
|
|
|
504
541
|
* Test-only helper that simulates an abrupt actor crash.
|
|
505
542
|
*/
|
|
506
543
|
hardCrashActor?(actorId: string): Promise<void>;
|
|
507
|
-
kvGet(actorId: string, key: Uint8Array): Promise<string | null>;
|
|
508
|
-
kvBatchGet(actorId: string, keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
|
|
509
|
-
kvBatchPut(actorId: string, entries: [Uint8Array, Uint8Array][]): Promise<void>;
|
|
510
|
-
kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
|
|
511
|
-
kvDeleteRange(actorId: string, start: Uint8Array, end: Uint8Array): Promise<void>;
|
|
512
544
|
}
|
|
513
545
|
interface RuntimeDisplayInformation {
|
|
514
546
|
properties: Record<string, string>;
|
|
@@ -530,6 +562,8 @@ interface GetOrCreateWithKeyInput {
|
|
|
530
562
|
input?: unknown;
|
|
531
563
|
region?: string;
|
|
532
564
|
crashPolicy?: CrashPolicy;
|
|
565
|
+
/** Overrides the client's configured pool name for this actor. */
|
|
566
|
+
poolName?: string;
|
|
533
567
|
}
|
|
534
568
|
interface CreateInput {
|
|
535
569
|
c?: Context | undefined;
|
|
@@ -538,6 +572,17 @@ interface CreateInput {
|
|
|
538
572
|
input?: unknown;
|
|
539
573
|
region?: string;
|
|
540
574
|
crashPolicy?: CrashPolicy;
|
|
575
|
+
/** Overrides the client's configured pool name for this actor. */
|
|
576
|
+
poolName?: string;
|
|
577
|
+
}
|
|
578
|
+
interface ForkInput {
|
|
579
|
+
c?: Context | undefined;
|
|
580
|
+
/** The source actor. */
|
|
581
|
+
actorId: string;
|
|
582
|
+
/** The new actor's key; omitted for a keyless actor. */
|
|
583
|
+
key?: ActorKey;
|
|
584
|
+
/** The fork input, given to the new actor's `onFork` hook. */
|
|
585
|
+
input?: unknown;
|
|
541
586
|
}
|
|
542
587
|
interface ListActorsInput {
|
|
543
588
|
c?: Context | undefined;
|
|
@@ -557,21 +602,571 @@ interface ActorOutput {
|
|
|
557
602
|
error?: unknown;
|
|
558
603
|
}
|
|
559
604
|
|
|
605
|
+
/** Correlation owned by the currently executing Core actor invocation. */
|
|
606
|
+
interface ActorInvocationTraceContext {
|
|
607
|
+
/** Ray ID the invocation received, absent when nothing upstream supplied one. */
|
|
608
|
+
readonly rayId?: string;
|
|
609
|
+
/** Core-owned invocation span context, absent when tracing is disabled. */
|
|
610
|
+
readonly span?: ActorInvocationSpanContext;
|
|
611
|
+
}
|
|
612
|
+
/** W3C span context of the Core invocation span. */
|
|
613
|
+
interface ActorInvocationSpanContext {
|
|
614
|
+
/** W3C trace identifier. */
|
|
615
|
+
readonly traceId: string;
|
|
616
|
+
/** W3C span identifier for the Core invocation. */
|
|
617
|
+
readonly spanId: string;
|
|
618
|
+
/** OpenTelemetry trace flags encoded as an integer. */
|
|
619
|
+
readonly traceFlags: number;
|
|
620
|
+
/** Optional vendor trace state inherited by the Core invocation. */
|
|
621
|
+
readonly tracestate?: string;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
declare const handleBrand: unique symbol;
|
|
625
|
+
type OpaqueHandle<Name extends string> = {
|
|
626
|
+
readonly [handleBrand]: Name;
|
|
627
|
+
};
|
|
628
|
+
type RegistryHandle = OpaqueHandle<"registry">;
|
|
629
|
+
type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
|
|
630
|
+
type ActorContextHandle = OpaqueHandle<"actorContext">;
|
|
631
|
+
type ConnHandle = OpaqueHandle<"conn">;
|
|
632
|
+
type WebSocketHandle = OpaqueHandle<"webSocket">;
|
|
633
|
+
type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
|
|
634
|
+
type ActorStateTransactionHandle = OpaqueHandle<"actorStateTransaction">;
|
|
635
|
+
type SqliteTransactionHandle = OpaqueHandle<"sqliteTransaction">;
|
|
636
|
+
type RuntimeBytes = Uint8Array;
|
|
637
|
+
interface RuntimeActorKeySegment {
|
|
638
|
+
kind: string;
|
|
639
|
+
stringValue?: string;
|
|
640
|
+
numberValue?: number;
|
|
641
|
+
}
|
|
642
|
+
/** One individual actor fork behind an actor, as the runtime reports it. */
|
|
643
|
+
interface RuntimeForkLink {
|
|
644
|
+
actorId: string;
|
|
645
|
+
key: RuntimeActorKeySegment[];
|
|
646
|
+
forkedAt: number;
|
|
647
|
+
}
|
|
648
|
+
/** Resolves correlation at operation time so retained clients cannot freeze stale context. */
|
|
649
|
+
type CurrentActorInvocation = () => ActorInvocationTraceContext | undefined;
|
|
650
|
+
/** One open call from an actor out to another actor. */
|
|
651
|
+
interface RuntimeOutboundCall {
|
|
652
|
+
/**
|
|
653
|
+
* W3C context of the call's own span, to send to the callee so it parents to
|
|
654
|
+
* the call. Absent when tracing is disabled.
|
|
655
|
+
*/
|
|
656
|
+
readonly span?: ActorInvocationSpanContext;
|
|
657
|
+
/**
|
|
658
|
+
* Records the call's outcome. `error` is the failure encoded the way the
|
|
659
|
+
* bridge encodes errors, so a structured error keeps its group and code.
|
|
660
|
+
*/
|
|
661
|
+
finish(error?: string): void;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Opens the span covering one call out to another actor, or returns `undefined`
|
|
665
|
+
* outside an invocation or on a runtime without invocation telemetry. Callers
|
|
666
|
+
* send their own context when it returns nothing.
|
|
667
|
+
*/
|
|
668
|
+
type StartCallSpan = (actorName: string, actionName: string) => RuntimeOutboundCall | undefined;
|
|
669
|
+
interface RuntimeHttpRequest {
|
|
670
|
+
method: string;
|
|
671
|
+
uri: string;
|
|
672
|
+
headers?: Record<string, string>;
|
|
673
|
+
body?: RuntimeBytes;
|
|
674
|
+
}
|
|
675
|
+
interface RuntimeHttpResponseBodyStream {
|
|
676
|
+
cancelled(): Promise<void>;
|
|
677
|
+
write(chunk: Uint8Array): Promise<void>;
|
|
678
|
+
end(): Promise<void>;
|
|
679
|
+
error(message: string): Promise<void>;
|
|
680
|
+
}
|
|
681
|
+
interface RuntimeStateDeltaPayload {
|
|
682
|
+
state?: RuntimeBytes;
|
|
683
|
+
connHibernation: Array<{
|
|
684
|
+
connId: string;
|
|
685
|
+
bytes: RuntimeBytes;
|
|
686
|
+
}>;
|
|
687
|
+
connHibernationRemoved: string[];
|
|
688
|
+
}
|
|
689
|
+
interface RuntimeWorkflowKvWrite {
|
|
690
|
+
key: RuntimeBytes;
|
|
691
|
+
value: RuntimeBytes;
|
|
692
|
+
}
|
|
693
|
+
interface RuntimeRequestSaveOpts {
|
|
694
|
+
immediate?: boolean;
|
|
695
|
+
maxWaitMs?: number;
|
|
696
|
+
}
|
|
697
|
+
interface RuntimeInspectorSnapshot {
|
|
698
|
+
stateRevision: number;
|
|
699
|
+
connectionsRevision: number;
|
|
700
|
+
queueRevision: number;
|
|
701
|
+
activeConnections: number;
|
|
702
|
+
queueSize: number;
|
|
703
|
+
connectedClients: number;
|
|
704
|
+
}
|
|
705
|
+
interface RuntimeQueueMessage {
|
|
706
|
+
id(): bigint;
|
|
707
|
+
name(): string;
|
|
708
|
+
body(): RuntimeBytes;
|
|
709
|
+
createdAt(): number;
|
|
710
|
+
isCompletable(): boolean;
|
|
711
|
+
complete(response?: RuntimeBytes | undefined | null): Promise<void>;
|
|
712
|
+
}
|
|
713
|
+
interface RuntimeQueueInspectMessage {
|
|
714
|
+
id: number;
|
|
715
|
+
name: string;
|
|
716
|
+
createdAtMs: number;
|
|
717
|
+
}
|
|
718
|
+
interface RuntimeScheduledEventInfo {
|
|
719
|
+
id: string;
|
|
720
|
+
action: string;
|
|
721
|
+
args: RuntimeBytes;
|
|
722
|
+
runAt: number;
|
|
723
|
+
}
|
|
724
|
+
interface RuntimeCronJobInfo {
|
|
725
|
+
name: string;
|
|
726
|
+
kind: "cron" | "every";
|
|
727
|
+
action: string;
|
|
728
|
+
args: RuntimeBytes;
|
|
729
|
+
nextRunAt: number;
|
|
730
|
+
lastRunAt?: number;
|
|
731
|
+
expression?: string;
|
|
732
|
+
timezone?: string;
|
|
733
|
+
intervalMs?: number;
|
|
734
|
+
maxHistory: number;
|
|
735
|
+
}
|
|
736
|
+
interface RuntimeScheduleErrorInfo {
|
|
737
|
+
group: string;
|
|
738
|
+
code: string;
|
|
739
|
+
message: string;
|
|
740
|
+
metadata?: unknown;
|
|
741
|
+
}
|
|
742
|
+
interface RuntimeCronFire {
|
|
743
|
+
action: string;
|
|
744
|
+
scheduledAt: number;
|
|
745
|
+
firedAt: number;
|
|
746
|
+
finishedAt?: number;
|
|
747
|
+
result: "running" | "ok" | "error" | "skipped";
|
|
748
|
+
error?: RuntimeScheduleErrorInfo;
|
|
749
|
+
}
|
|
750
|
+
interface RuntimeQueueNextBatchOptions {
|
|
751
|
+
names?: string[];
|
|
752
|
+
count?: number;
|
|
753
|
+
timeoutMs?: number;
|
|
754
|
+
completable?: boolean;
|
|
755
|
+
}
|
|
756
|
+
interface RuntimeQueueWaitOptions {
|
|
757
|
+
timeoutMs?: number;
|
|
758
|
+
completable?: boolean;
|
|
759
|
+
}
|
|
760
|
+
interface RuntimeQueueEnqueueAndWaitOptions {
|
|
761
|
+
timeoutMs?: number;
|
|
762
|
+
}
|
|
763
|
+
interface RuntimeQueueTryNextBatchOptions {
|
|
764
|
+
names?: string[];
|
|
765
|
+
count?: number;
|
|
766
|
+
completable?: boolean;
|
|
767
|
+
}
|
|
768
|
+
interface RuntimeKvListOptions {
|
|
769
|
+
reverse?: boolean;
|
|
770
|
+
limit?: number;
|
|
771
|
+
}
|
|
772
|
+
interface RuntimeKvEntry {
|
|
773
|
+
key: RuntimeBytes;
|
|
774
|
+
value: RuntimeBytes;
|
|
775
|
+
}
|
|
776
|
+
type RuntimeSqlBindNoValues = {
|
|
777
|
+
intValue?: never;
|
|
778
|
+
floatValue?: never;
|
|
779
|
+
textValue?: never;
|
|
780
|
+
blobValue?: never;
|
|
781
|
+
};
|
|
782
|
+
type RuntimeSqlBindParam = ({
|
|
783
|
+
kind: "null";
|
|
784
|
+
} & RuntimeSqlBindNoValues) | {
|
|
785
|
+
kind: "int";
|
|
786
|
+
intValue: number;
|
|
787
|
+
floatValue?: never;
|
|
788
|
+
textValue?: never;
|
|
789
|
+
blobValue?: never;
|
|
790
|
+
} | {
|
|
791
|
+
kind: "float";
|
|
792
|
+
intValue?: never;
|
|
793
|
+
floatValue: number;
|
|
794
|
+
textValue?: never;
|
|
795
|
+
blobValue?: never;
|
|
796
|
+
} | {
|
|
797
|
+
kind: "text";
|
|
798
|
+
intValue?: never;
|
|
799
|
+
floatValue?: never;
|
|
800
|
+
textValue: string;
|
|
801
|
+
blobValue?: never;
|
|
802
|
+
} | {
|
|
803
|
+
kind: "blob";
|
|
804
|
+
intValue?: never;
|
|
805
|
+
floatValue?: never;
|
|
806
|
+
textValue?: never;
|
|
807
|
+
blobValue: RuntimeBytes;
|
|
808
|
+
};
|
|
809
|
+
type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
810
|
+
interface RuntimeSqlQueryResult {
|
|
811
|
+
columns: string[];
|
|
812
|
+
rows: unknown[][];
|
|
813
|
+
}
|
|
814
|
+
type RuntimeSqlExecResult = RuntimeSqlQueryResult;
|
|
815
|
+
interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
|
|
816
|
+
changes: number;
|
|
817
|
+
lastInsertRowId?: number | null;
|
|
818
|
+
}
|
|
819
|
+
interface RuntimeSqlBatchStatement {
|
|
820
|
+
sql: string;
|
|
821
|
+
params?: RuntimeSqlBindParams;
|
|
822
|
+
}
|
|
823
|
+
interface RuntimeSqlRunResult {
|
|
824
|
+
changes: number;
|
|
825
|
+
}
|
|
826
|
+
/** Sample rates for the traces an actor starts, in the shape core takes. */
|
|
827
|
+
interface RuntimeActorTracingConfig {
|
|
828
|
+
sampler?: number;
|
|
829
|
+
/** Keyed by flattened, dot-separated action name. */
|
|
830
|
+
actions?: Record<string, number>;
|
|
831
|
+
}
|
|
832
|
+
interface RuntimeActorConfig {
|
|
833
|
+
name?: string;
|
|
834
|
+
icon?: string;
|
|
835
|
+
hasDatabase?: boolean;
|
|
836
|
+
remoteSqlite?: boolean;
|
|
837
|
+
sqliteDeferredCommits?: boolean;
|
|
838
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
839
|
+
tracing?: RuntimeActorTracingConfig;
|
|
840
|
+
hasState?: boolean;
|
|
841
|
+
canHibernateWebsocket?: boolean;
|
|
842
|
+
stateSaveIntervalMs?: number;
|
|
843
|
+
createStateTimeoutMs?: number;
|
|
844
|
+
onCreateTimeoutMs?: number;
|
|
845
|
+
createVarsTimeoutMs?: number;
|
|
846
|
+
createConnStateTimeoutMs?: number;
|
|
847
|
+
onBeforeConnectTimeoutMs?: number;
|
|
848
|
+
onConnectTimeoutMs?: number;
|
|
849
|
+
onMigrateTimeoutMs?: number;
|
|
850
|
+
onWakeTimeoutMs?: number;
|
|
851
|
+
onBeforeActorStartTimeoutMs?: number;
|
|
852
|
+
actionTimeoutMs?: number;
|
|
853
|
+
onRequestTimeoutMs?: number;
|
|
854
|
+
sleepTimeoutMs?: number;
|
|
855
|
+
noSleep?: boolean;
|
|
856
|
+
sleepGracePeriodMs?: number;
|
|
857
|
+
connectionLivenessTimeoutMs?: number;
|
|
858
|
+
connectionLivenessIntervalMs?: number;
|
|
859
|
+
maxQueueSize?: number;
|
|
860
|
+
maxSchedules?: number;
|
|
861
|
+
maxQueueMessageSize?: number;
|
|
862
|
+
maxIncomingMessageSize?: number;
|
|
863
|
+
maxOutgoingMessageSize?: number;
|
|
864
|
+
preloadMaxWorkflowBytes?: number;
|
|
865
|
+
preloadMaxConnectionsBytes?: number;
|
|
866
|
+
actions?: Array<{
|
|
867
|
+
name: string;
|
|
868
|
+
}>;
|
|
869
|
+
inspectorTabs?: Array<RuntimeInspectorTabEntry>;
|
|
870
|
+
}
|
|
871
|
+
interface RuntimeInspectorTabEntry {
|
|
872
|
+
id: string;
|
|
873
|
+
/** Required for custom entries; omitted for built-in hides. */
|
|
874
|
+
label?: string;
|
|
875
|
+
/**
|
|
876
|
+
* Required for custom entries — absolute path to the source directory.
|
|
877
|
+
* Resolved on the TS side before being handed to the runtime.
|
|
878
|
+
*/
|
|
879
|
+
source?: string;
|
|
880
|
+
/** Optional icon id for custom entries. */
|
|
881
|
+
icon?: string;
|
|
882
|
+
/** Set to true for built-in hide entries. */
|
|
883
|
+
hidden?: boolean;
|
|
884
|
+
}
|
|
885
|
+
interface RuntimeServeConfig {
|
|
886
|
+
version: number;
|
|
887
|
+
endpoint: string;
|
|
888
|
+
token?: string;
|
|
889
|
+
namespace: string;
|
|
890
|
+
poolName: string;
|
|
891
|
+
engineBinaryPath?: string;
|
|
892
|
+
startServices?: boolean;
|
|
893
|
+
servicesBinaryPath?: string;
|
|
894
|
+
/** Whether config resolution selected a managed local development engine. */
|
|
895
|
+
engineSpawn?: boolean;
|
|
896
|
+
engineHost?: string;
|
|
897
|
+
enginePort?: number;
|
|
898
|
+
handleInspectorHttpInRuntime?: boolean;
|
|
899
|
+
inspectorTestToken?: string;
|
|
900
|
+
serverlessBasePath?: string;
|
|
901
|
+
serverlessPackageVersion: string;
|
|
902
|
+
serverlessClientEndpoint?: string;
|
|
903
|
+
serverlessClientNamespace?: string;
|
|
904
|
+
serverlessClientToken?: string;
|
|
905
|
+
serverlessValidateEndpoint: boolean;
|
|
906
|
+
serverlessMaxStartPayloadBytes: number;
|
|
907
|
+
}
|
|
908
|
+
interface RuntimeListenerConfig {
|
|
909
|
+
port: number;
|
|
910
|
+
host?: string;
|
|
911
|
+
publicDir?: string;
|
|
912
|
+
application?: RuntimeApplicationFetch;
|
|
913
|
+
}
|
|
914
|
+
interface RuntimeServerlessRequest {
|
|
915
|
+
method: string;
|
|
916
|
+
url: string;
|
|
917
|
+
headers: Record<string, string>;
|
|
918
|
+
body: RuntimeBytes;
|
|
919
|
+
}
|
|
920
|
+
interface RuntimeApplicationRequest extends RuntimeServerlessRequest {
|
|
921
|
+
cancelToken?: CancellationTokenHandle;
|
|
922
|
+
}
|
|
923
|
+
interface RuntimeApplicationResponse {
|
|
924
|
+
status: number;
|
|
925
|
+
headers: Record<string, string>;
|
|
926
|
+
body?: RuntimeBytes;
|
|
927
|
+
stream?: boolean;
|
|
928
|
+
}
|
|
929
|
+
type RuntimeApplicationFetch = (request: RuntimeApplicationRequest, responseBodyStream?: RuntimeHttpResponseBodyStream) => Promise<RuntimeApplicationResponse>;
|
|
930
|
+
interface RuntimeApplicationListenerConfig extends RuntimeListenerConfig {
|
|
931
|
+
application: RuntimeApplicationFetch;
|
|
932
|
+
}
|
|
933
|
+
interface RuntimeServerlessResponseHead {
|
|
934
|
+
status: number;
|
|
935
|
+
headers: Record<string, string>;
|
|
936
|
+
}
|
|
937
|
+
interface RuntimeRegistryRouteResponse {
|
|
938
|
+
status: number;
|
|
939
|
+
headers: Record<string, string>;
|
|
940
|
+
body: RuntimeBytes;
|
|
941
|
+
}
|
|
942
|
+
type RuntimeServerlessStreamEvent = {
|
|
943
|
+
kind: "chunk";
|
|
944
|
+
chunk?: RuntimeBytes;
|
|
945
|
+
} | {
|
|
946
|
+
kind: "end";
|
|
947
|
+
error?: {
|
|
948
|
+
group: string;
|
|
949
|
+
code: string;
|
|
950
|
+
message: string;
|
|
951
|
+
};
|
|
952
|
+
};
|
|
953
|
+
type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
|
|
954
|
+
type RuntimeWebSocketEvent = {
|
|
955
|
+
kind: "message";
|
|
956
|
+
data: string | RuntimeBytes;
|
|
957
|
+
binary: boolean;
|
|
958
|
+
messageIndex?: number;
|
|
959
|
+
} | {
|
|
960
|
+
kind: "close";
|
|
961
|
+
code: number;
|
|
962
|
+
reason: string;
|
|
963
|
+
wasClean: boolean;
|
|
964
|
+
};
|
|
965
|
+
interface CoreRuntime {
|
|
966
|
+
readonly kind: "napi" | "wasm";
|
|
967
|
+
createRegistry(): RegistryHandle;
|
|
968
|
+
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
969
|
+
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
970
|
+
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
971
|
+
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
972
|
+
shutdownTelemetry?(): Promise<void>;
|
|
973
|
+
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
974
|
+
registryActiveActorCount?(registry: RegistryHandle): number;
|
|
975
|
+
onRegistryActiveActorCountChange?(registry: RegistryHandle, callback: (count: number) => void, cancelToken: CancellationTokenHandle): void;
|
|
976
|
+
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
977
|
+
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
978
|
+
serveApplicationListener(registry: RegistryHandle, listener: RuntimeApplicationListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
979
|
+
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
980
|
+
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
981
|
+
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
982
|
+
createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
|
|
983
|
+
createCancellationToken(): CancellationTokenHandle;
|
|
984
|
+
cancellationTokenAborted(token: CancellationTokenHandle): boolean;
|
|
985
|
+
cancelCancellationToken(token: CancellationTokenHandle): void;
|
|
986
|
+
/**
|
|
987
|
+
* Calls `callback` once when `token` is cancelled. Returns a release
|
|
988
|
+
* function that drops the registration without calling `callback`; call it
|
|
989
|
+
* once cancellation no longer matters so the native listener is freed.
|
|
990
|
+
*/
|
|
991
|
+
onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): () => void;
|
|
992
|
+
actorState(ctx: ActorContextHandle): RuntimeBytes;
|
|
993
|
+
actorBeginOnStateChange(ctx: ActorContextHandle): void;
|
|
994
|
+
actorEndOnStateChange(ctx: ActorContextHandle): void;
|
|
995
|
+
actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
|
|
996
|
+
actorSetRunWakeAt(ctx: ActorContextHandle, timestampMs?: number | undefined | null): Promise<void>;
|
|
997
|
+
actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
|
|
998
|
+
actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
|
|
999
|
+
actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
|
|
1000
|
+
actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
|
|
1001
|
+
actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
|
|
1002
|
+
actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
|
|
1003
|
+
actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
|
|
1004
|
+
actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
|
|
1005
|
+
actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
|
|
1006
|
+
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
1007
|
+
actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
|
|
1008
|
+
actorId(ctx: ActorContextHandle): string;
|
|
1009
|
+
/**
|
|
1010
|
+
* Runs one actor callback with `ctx` as the current invocation: operations
|
|
1011
|
+
* on retained handles for the same actor resolve to it, and its Core span
|
|
1012
|
+
* is the active OpenTelemetry span for the duration of `run`. Only actions,
|
|
1013
|
+
* raw requests, and queue dispatch run this way; other callbacks have no
|
|
1014
|
+
* invocation span.
|
|
1015
|
+
*/
|
|
1016
|
+
runWithActorInvocationContext<T>(ctx: ActorContextHandle, run: () => T): T;
|
|
1017
|
+
/**
|
|
1018
|
+
* Correlation of the invocation currently executing for this actor, or
|
|
1019
|
+
* `undefined` outside an invocation or after it finished. A sampled-out
|
|
1020
|
+
* invocation can still expose valid span context for propagation.
|
|
1021
|
+
*/
|
|
1022
|
+
actorInvocationTraceContext(ctx: ActorContextHandle): ActorInvocationTraceContext | undefined;
|
|
1023
|
+
/**
|
|
1024
|
+
* Opens the span covering one call this actor makes to another actor. See
|
|
1025
|
+
* `StartCallSpan` for when this returns nothing.
|
|
1026
|
+
*/
|
|
1027
|
+
startCallSpan(ctx: ActorContextHandle, actorName: string, actionName: string): RuntimeOutboundCall | undefined;
|
|
1028
|
+
/** Backs `ActorRun.startWorkflowSpan`. */
|
|
1029
|
+
startWorkflowSpan(ctx: ActorContextHandle): Promise<WorkflowSpan>;
|
|
1030
|
+
/** Backs `ActorRun.runOutsideWorkflowSpan`. */
|
|
1031
|
+
runOutsideActorInvocationContext<T>(run: () => T): T;
|
|
1032
|
+
/** Identity of the invocation the caller runs in, usable as a cache key. */
|
|
1033
|
+
currentInvocationScope(): object | undefined;
|
|
1034
|
+
actorName(ctx: ActorContextHandle): string;
|
|
1035
|
+
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
1036
|
+
/** The individual actor forks behind the actor, oldest first. */
|
|
1037
|
+
actorForkChain(ctx: ActorContextHandle): RuntimeForkLink[];
|
|
1038
|
+
actorRegion(ctx: ActorContextHandle): string;
|
|
1039
|
+
/** The name of the namespace the actor runs in. */
|
|
1040
|
+
actorNamespace(ctx: ActorContextHandle): string;
|
|
1041
|
+
actorSleep(ctx: ActorContextHandle): void;
|
|
1042
|
+
actorDestroy(ctx: ActorContextHandle): void;
|
|
1043
|
+
actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
|
|
1044
|
+
actorConns(ctx: ActorContextHandle): ConnHandle[];
|
|
1045
|
+
actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
|
|
1046
|
+
actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
|
|
1047
|
+
actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
1048
|
+
actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
|
|
1049
|
+
actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
|
|
1050
|
+
actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
1051
|
+
actorBeginKeepAwake(ctx: ActorContextHandle): number;
|
|
1052
|
+
actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
|
|
1053
|
+
actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
1054
|
+
actorRuntimeState(ctx: ActorContextHandle): object;
|
|
1055
|
+
actorClearRuntimeState(ctx: ActorContextHandle): void;
|
|
1056
|
+
actorRestartRunHandler(ctx: ActorContextHandle): void;
|
|
1057
|
+
actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
|
|
1058
|
+
actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
|
|
1059
|
+
actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
|
|
1060
|
+
actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
|
|
1061
|
+
actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
|
|
1062
|
+
actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
|
|
1063
|
+
actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
1064
|
+
actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
1065
|
+
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
1066
|
+
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
1067
|
+
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
1068
|
+
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
1069
|
+
actorSqlExecSync(ctx: ActorContextHandle, sql: string): RuntimeSqlExecResult;
|
|
1070
|
+
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1071
|
+
actorSqlExecuteSync(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1072
|
+
actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
|
|
1073
|
+
actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
|
|
1074
|
+
actorSqlBeginTransactionSync(ctx: ActorContextHandle, timeoutMs?: number, name?: string): SqliteTransactionHandle;
|
|
1075
|
+
actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
1076
|
+
actorSqlTransactionExecSync(transaction: SqliteTransactionHandle, sql: string): RuntimeSqlExecResult;
|
|
1077
|
+
actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1078
|
+
actorSqlTransactionExecuteSync(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1079
|
+
actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
|
|
1080
|
+
actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void;
|
|
1081
|
+
actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
|
|
1082
|
+
actorSqlTransactionRollbackSync(transaction: SqliteTransactionHandle): void;
|
|
1083
|
+
actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<ActorStateTransactionHandle>;
|
|
1084
|
+
actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1085
|
+
actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
1086
|
+
actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
|
|
1087
|
+
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
1088
|
+
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
1089
|
+
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
1090
|
+
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
1091
|
+
/** Opens the actor database so later synchronous calls never fetch its first pages. */
|
|
1092
|
+
actorSqlOpen(ctx: ActorContextHandle): Promise<void>;
|
|
1093
|
+
/** Returns the ticket of the latest local commit. */
|
|
1094
|
+
actorSqlCommitTicket(ctx: ActorContextHandle): number;
|
|
1095
|
+
/** Resolves once the commit `ticket` names and every earlier commit are durable. */
|
|
1096
|
+
actorSqlWhenDurable(ctx: ActorContextHandle, ticket: number): Promise<void>;
|
|
1097
|
+
actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void;
|
|
1098
|
+
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
1099
|
+
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
1100
|
+
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
1101
|
+
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
1102
|
+
actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
|
|
1103
|
+
actorQueueCompletePersisted(ctx: ActorContextHandle, messageId: bigint, expectedName: string, response?: RuntimeBytes | undefined | null): Promise<boolean>;
|
|
1104
|
+
actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
|
|
1105
|
+
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
1106
|
+
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
1107
|
+
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
1108
|
+
actorQueueReset(ctx: ActorContextHandle): Promise<void>;
|
|
1109
|
+
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
1110
|
+
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
1111
|
+
actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
|
|
1112
|
+
actorScheduleGet(ctx: ActorContextHandle, id: string): Promise<RuntimeScheduledEventInfo | undefined>;
|
|
1113
|
+
actorScheduleList(ctx: ActorContextHandle): Promise<RuntimeScheduledEventInfo[]>;
|
|
1114
|
+
actorCronSet(ctx: ActorContextHandle, name: string, expression: string, timezone: string | undefined, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
1115
|
+
actorCronEvery(ctx: ActorContextHandle, name: string, intervalMs: number, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
1116
|
+
actorCronGet(ctx: ActorContextHandle, name: string): Promise<RuntimeCronJobInfo | undefined>;
|
|
1117
|
+
actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
|
|
1118
|
+
actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
|
|
1119
|
+
actorCronHistory(ctx: ActorContextHandle, name: string, limit: number | undefined): Promise<RuntimeCronFire[]>;
|
|
1120
|
+
connId(conn: ConnHandle): string;
|
|
1121
|
+
connParams(conn: ConnHandle): RuntimeBytes;
|
|
1122
|
+
connState(conn: ConnHandle): RuntimeBytes;
|
|
1123
|
+
connSetState(conn: ConnHandle, state: RuntimeBytes): void;
|
|
1124
|
+
connIsHibernatable(conn: ConnHandle): boolean;
|
|
1125
|
+
connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
|
|
1126
|
+
connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
|
|
1127
|
+
webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
|
|
1128
|
+
webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
|
|
1129
|
+
webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
|
|
1133
|
+
runtime: CoreRuntime;
|
|
1134
|
+
registry: RegistryHandle;
|
|
1135
|
+
serveConfig: RuntimeServeConfig;
|
|
1136
|
+
}>;
|
|
1137
|
+
|
|
560
1138
|
type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
|
|
561
1139
|
interface ServerlessHandler {
|
|
562
1140
|
fetch: FetchHandler;
|
|
563
1141
|
}
|
|
1142
|
+
interface RegistryApplication {
|
|
1143
|
+
fetch: FetchHandler;
|
|
1144
|
+
}
|
|
1145
|
+
interface RegistryListenOptions {
|
|
1146
|
+
port?: number;
|
|
1147
|
+
host?: string;
|
|
1148
|
+
publicDir?: string;
|
|
1149
|
+
application?: RegistryApplication;
|
|
1150
|
+
}
|
|
564
1151
|
interface RegistryRoutes {
|
|
565
1152
|
health(): Promise<Response>;
|
|
566
1153
|
metadata(): Promise<Response>;
|
|
567
1154
|
prometheusMetrics(request?: Request): Promise<Response>;
|
|
568
1155
|
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Injectable dependencies for {@link Registry}. Production code uses the
|
|
1158
|
+
* defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
|
|
1159
|
+
* orchestration against a fake `CoreRuntime` without an engine.
|
|
1160
|
+
*/
|
|
1161
|
+
interface RegistryDeps {
|
|
1162
|
+
buildConfiguredRegistry: typeof buildConfiguredRegistry;
|
|
1163
|
+
}
|
|
569
1164
|
declare class Registry<A extends RegistryActors> {
|
|
570
1165
|
#private;
|
|
571
1166
|
readonly routes: RegistryRoutes;
|
|
572
1167
|
get config(): RegistryConfigInput<A>;
|
|
573
1168
|
parseConfig(): RegistryConfig;
|
|
574
|
-
constructor(config: RegistryConfigInput<A>);
|
|
1169
|
+
constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
|
|
575
1170
|
/**
|
|
576
1171
|
* Handle an incoming HTTP request for serverless deployments.
|
|
577
1172
|
*
|
|
@@ -592,10 +1187,64 @@ declare class Registry<A extends RegistryActors> {
|
|
|
592
1187
|
* ```
|
|
593
1188
|
*/
|
|
594
1189
|
serve(): ServerlessHandler;
|
|
1190
|
+
/**
|
|
1191
|
+
* Bind an HTTP listener provided by the native (Rust) runtime and serve
|
|
1192
|
+
* the registry's serverless endpoints over it. Resolves only after the
|
|
1193
|
+
* registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
|
|
1194
|
+
*
|
|
1195
|
+
* @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
|
|
1196
|
+
* if set, otherwise 3000.
|
|
1197
|
+
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
1198
|
+
* @param opts.publicDir If set, serves static files from this directory
|
|
1199
|
+
* as a fallback below the framework routes.
|
|
1200
|
+
* @param opts.application If set, handles requests that do not match a
|
|
1201
|
+
* framework route.
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* await registry.listen();
|
|
1206
|
+
* await registry.listen({ application: app });
|
|
1207
|
+
* ```
|
|
1208
|
+
*/
|
|
1209
|
+
listen(opts?: RegistryListenOptions): Promise<void>;
|
|
1210
|
+
/**
|
|
1211
|
+
* Gracefully drains all live registries.
|
|
1212
|
+
*
|
|
1213
|
+
* Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
|
|
1214
|
+
* every live `CoreRegistry` (both `start()` and `handler()` modes) and
|
|
1215
|
+
* waits for the serve promise to resolve, all bounded by the shutdown
|
|
1216
|
+
* grace period. Unlike a signal-driven shutdown, this does not re-raise a
|
|
1217
|
+
* signal or exit the process. The caller owns process lifetime.
|
|
1218
|
+
*
|
|
1219
|
+
* Idempotent: concurrent or repeated calls share a single drain. Safe to
|
|
1220
|
+
* call even if nothing has been started.
|
|
1221
|
+
*
|
|
1222
|
+
* @example
|
|
1223
|
+
* ```ts
|
|
1224
|
+
* const registry = setup({ use: { counter } });
|
|
1225
|
+
* registry.start();
|
|
1226
|
+
* // ...later, on your own shutdown trigger:
|
|
1227
|
+
* await registry.shutdown();
|
|
1228
|
+
* ```
|
|
1229
|
+
*/
|
|
1230
|
+
shutdown(): Promise<void>;
|
|
595
1231
|
startEnvoy(): void;
|
|
1232
|
+
/**
|
|
1233
|
+
* Starts the serverful registry if needed and waits until its envoy has
|
|
1234
|
+
* registered with the Engine. Repeated and concurrent calls share one
|
|
1235
|
+
* startup lifecycle and readiness promise.
|
|
1236
|
+
*
|
|
1237
|
+
* Unlike {@link start}, this reports startup failures and does not resolve
|
|
1238
|
+
* merely because an HTTP health endpoint is listening.
|
|
1239
|
+
*/
|
|
1240
|
+
startAndWait(): Promise<void>;
|
|
596
1241
|
/**
|
|
597
1242
|
* Starts the actor envoy for standalone server deployments.
|
|
598
1243
|
*
|
|
1244
|
+
* Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
|
|
1245
|
+
* via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
|
|
1246
|
+
* mutually exclusive per registry instance.
|
|
1247
|
+
*
|
|
599
1248
|
* @example
|
|
600
1249
|
* ```ts
|
|
601
1250
|
* const registry = setup({ use: { counter } });
|
|
@@ -603,6 +1252,24 @@ declare class Registry<A extends RegistryActors> {
|
|
|
603
1252
|
* ```
|
|
604
1253
|
*/
|
|
605
1254
|
start(): void;
|
|
1255
|
+
/**
|
|
1256
|
+
* Returns the number of actors hosted by this process's envoy, which is zero
|
|
1257
|
+
* while it is not serving. Requires the native runtime.
|
|
1258
|
+
*/
|
|
1259
|
+
activeActorCount(): number;
|
|
1260
|
+
/**
|
|
1261
|
+
* Calls `callback` with the number of actors hosted by this process's envoy
|
|
1262
|
+
* and again whenever it changes. Rapid changes may coalesce.
|
|
1263
|
+
* Returns a function that unsubscribes. Requires the native runtime.
|
|
1264
|
+
*
|
|
1265
|
+
* @example
|
|
1266
|
+
* ```ts
|
|
1267
|
+
* const unsubscribe = registry.onActiveActorCountChange((count) => {
|
|
1268
|
+
* setTaskProtection(count > 0);
|
|
1269
|
+
* });
|
|
1270
|
+
* ```
|
|
1271
|
+
*/
|
|
1272
|
+
onActiveActorCountChange(callback: (count: number) => void): () => void;
|
|
606
1273
|
}
|
|
607
1274
|
declare function setup<A extends RegistryActors>(input: RegistryConfigInput<A>): Registry<A>;
|
|
608
1275
|
|
|
@@ -631,6 +1298,14 @@ interface QueueSendResult<TResponse = unknown> {
|
|
|
631
1298
|
* @returns {Promise<Response>}
|
|
632
1299
|
*/
|
|
633
1300
|
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
1301
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1302
|
+
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
1303
|
+
type ActorActionMap<R> = {
|
|
1304
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : NonNullable<R>[K] extends Record<string, unknown> ? ActorActionMap<NonNullable<R>[K]> : never;
|
|
1305
|
+
};
|
|
1306
|
+
type ActionsOf<AD extends AnyActorDefinition> = AD["config"] extends {
|
|
1307
|
+
actions?: infer R;
|
|
1308
|
+
} ? R : never;
|
|
634
1309
|
interface ActorGatewayOptions {
|
|
635
1310
|
skipReadyWait?: boolean;
|
|
636
1311
|
}
|
|
@@ -643,26 +1318,46 @@ type ActorWebSocketOptions = ActorGatewayOptions;
|
|
|
643
1318
|
/**
|
|
644
1319
|
* Maps action methods from actor definition to typed function signatures.
|
|
645
1320
|
*/
|
|
646
|
-
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends
|
|
647
|
-
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
648
|
-
} : never;
|
|
1321
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
|
|
649
1322
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
1323
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
650
1324
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
|
|
1325
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
651
1326
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1327
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
652
1328
|
(name: keyof TQueues extends never ? string : never, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1329
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
653
1330
|
(name: keyof TQueues extends never ? string : never, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
654
1331
|
};
|
|
655
1332
|
type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
656
1333
|
<K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
|
|
657
1334
|
(eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
|
|
658
1335
|
};
|
|
659
|
-
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD
|
|
1336
|
+
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1337
|
+
send: ActorQueueSend<Record<string, any>>;
|
|
1338
|
+
} : AD extends {
|
|
1339
|
+
config: {
|
|
1340
|
+
queues?: infer Q;
|
|
1341
|
+
};
|
|
1342
|
+
} ? Q extends QueueSchemaConfig ? {
|
|
660
1343
|
send: ActorQueueSend<Q>;
|
|
661
|
-
} :
|
|
662
|
-
|
|
1344
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
|
|
1345
|
+
send: ActorQueueSend<Q>;
|
|
1346
|
+
} : {} : {};
|
|
1347
|
+
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1348
|
+
on: LooseEventSubscribe;
|
|
1349
|
+
once: LooseEventSubscribe;
|
|
1350
|
+
} : AD extends {
|
|
1351
|
+
config: {
|
|
1352
|
+
events?: infer E;
|
|
1353
|
+
};
|
|
1354
|
+
} ? E extends EventSchemaConfig ? {
|
|
663
1355
|
on: ActorEventSubscribe<E>;
|
|
664
1356
|
once: ActorEventSubscribe<E>;
|
|
665
|
-
} :
|
|
1357
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
|
|
1358
|
+
on: ActorEventSubscribe<E>;
|
|
1359
|
+
once: ActorEventSubscribe<E>;
|
|
1360
|
+
} : {} : {};
|
|
666
1361
|
|
|
667
1362
|
type ActorResolutionState = ActorQuery;
|
|
668
1363
|
|
|
@@ -714,8 +1409,10 @@ declare class ActorConnRaw {
|
|
|
714
1409
|
*
|
|
715
1410
|
* @protected
|
|
716
1411
|
*/
|
|
717
|
-
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
|
|
1412
|
+
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, currentActorInvocation?: CurrentActorInvocation);
|
|
1413
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
718
1414
|
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1415
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
719
1416
|
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
720
1417
|
/**
|
|
721
1418
|
* Call a raw action connection. See {@link ActorConn} for type-safe action calls.
|
|
@@ -835,6 +1532,27 @@ declare class ActorConnRaw {
|
|
|
835
1532
|
*/
|
|
836
1533
|
type ActorConn<AD extends AnyActorDefinition> = Omit<ActorConnRaw, "send" | "on" | "once"> & ActorDefinitionQueueSend<AD> & ActorDefinitionEventSubscriptions<AD> & ActorDefinitionActions<AD>;
|
|
837
1534
|
|
|
1535
|
+
/** How many retries a client may spend, as a share of the requests it sends. */
|
|
1536
|
+
interface RetryBudgetOptions {
|
|
1537
|
+
/** Retries allowed per 100 requests (default 10). */
|
|
1538
|
+
percent?: number;
|
|
1539
|
+
/** Retries the client can bank for a burst of refusals; the budget starts full (default 100). */
|
|
1540
|
+
maxTokens?: number;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Bounds the client's retries of refused requests. Each request adds a fraction of a token and
|
|
1544
|
+
* each retry spends one, so retries stay a fixed share of traffic while the service sheds load
|
|
1545
|
+
* instead of multiplying it.
|
|
1546
|
+
*/
|
|
1547
|
+
declare class RetryBudget {
|
|
1548
|
+
#private;
|
|
1549
|
+
constructor(options?: RetryBudgetOptions);
|
|
1550
|
+
/** Credits one request sent. */
|
|
1551
|
+
deposit(): void;
|
|
1552
|
+
/** Spends one token. Returns `false` when the budget is spent. */
|
|
1553
|
+
tryWithdraw(): boolean;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
838
1556
|
/**
|
|
839
1557
|
* Provides underlying functions for stateless {@link ActorHandle} for action calls.
|
|
840
1558
|
* Similar to ActorConnRaw but doesn't maintain a connection.
|
|
@@ -850,8 +1568,10 @@ declare class ActorHandleRaw {
|
|
|
850
1568
|
*
|
|
851
1569
|
* @protected
|
|
852
1570
|
*/
|
|
853
|
-
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
|
|
1571
|
+
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal, currentActorInvocation?: CurrentActorInvocation, startCallSpan?: StartCallSpan, retryBudget?: RetryBudget);
|
|
1572
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
854
1573
|
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1574
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
855
1575
|
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
856
1576
|
/**
|
|
857
1577
|
* Call a raw action. This method sends an HTTP request to invoke the named action.
|
|
@@ -884,6 +1604,8 @@ declare class ActorHandleRaw {
|
|
|
884
1604
|
* Resolves the actor to get its unique actor ID.
|
|
885
1605
|
*/
|
|
886
1606
|
resolve(): Promise<string>;
|
|
1607
|
+
/** Issue a token scoped to this actor. Defaults to actor gateway read access. */
|
|
1608
|
+
issueToken(options?: ActorIssueTokenOptions): Promise<IssuedToken>;
|
|
887
1609
|
/**
|
|
888
1610
|
* Returns the raw URL for routing traffic to the actor.
|
|
889
1611
|
*/
|
|
@@ -909,7 +1631,7 @@ declare class ActorHandleRaw {
|
|
|
909
1631
|
type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect" | "send"> & {
|
|
910
1632
|
connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AD>;
|
|
911
1633
|
resolve(): Promise<string>;
|
|
912
|
-
} & ActorDefinitionQueueSend<AD> & ActorDefinitionActions<AD>;
|
|
1634
|
+
} & ActorDefinitionQueueSend<AD> & Omit<ActorDefinitionActions<AD>, keyof ActorHandleRaw>;
|
|
913
1635
|
|
|
914
1636
|
/** Extract the actor registry from the registry definition. */
|
|
915
1637
|
type ExtractActorsFromRegistry<A extends Registry<any>> = A extends Registry<infer Actors> ? Actors : never;
|
|
@@ -970,6 +1692,20 @@ interface ActorAccessor<AD extends AnyActorDefinition> {
|
|
|
970
1692
|
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
971
1693
|
*/
|
|
972
1694
|
create(key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Forks the actor `actorId` into a new actor of this name, and returns a
|
|
1697
|
+
* stateless handle to the new actor with its ID resolved.
|
|
1698
|
+
*
|
|
1699
|
+
* The new actor starts at once on a copy of the source's database as of
|
|
1700
|
+
* its last committed write, runs `onFork` once with `opts.input`, and
|
|
1701
|
+
* keeps running independently of the source. A fork is not idempotent:
|
|
1702
|
+
* a `key` already held answers `actor.duplicate_key`.
|
|
1703
|
+
*
|
|
1704
|
+
* @param {string} actorId - The ID of the source actor.
|
|
1705
|
+
* @param {ForkOptions} [opts] - The new actor's key and the fork input.
|
|
1706
|
+
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the new actor.
|
|
1707
|
+
*/
|
|
1708
|
+
fork(actorId: string, opts?: ForkOptions): Promise<ActorHandle<AD>>;
|
|
973
1709
|
}
|
|
974
1710
|
/**
|
|
975
1711
|
* Options for querying actors.
|
|
@@ -1009,6 +1745,11 @@ interface GetOrCreateOptions extends QueryOptions {
|
|
|
1009
1745
|
createInRegion?: string;
|
|
1010
1746
|
/** Input data to pass to the actor. */
|
|
1011
1747
|
createWithInput?: unknown;
|
|
1748
|
+
/**
|
|
1749
|
+
* Name of the envoy pool to select for this actor if it is created.
|
|
1750
|
+
* Overrides the client's configured `poolName` for this call.
|
|
1751
|
+
*/
|
|
1752
|
+
poolName?: string;
|
|
1012
1753
|
}
|
|
1013
1754
|
/**
|
|
1014
1755
|
* Options for creating a actor.
|
|
@@ -1020,6 +1761,20 @@ interface CreateOptions extends QueryOptions {
|
|
|
1020
1761
|
region?: string;
|
|
1021
1762
|
/** Input data to pass to the actor. */
|
|
1022
1763
|
input?: unknown;
|
|
1764
|
+
/**
|
|
1765
|
+
* Name of the envoy pool to select for this actor.
|
|
1766
|
+
* Overrides the client's configured `poolName` for this call.
|
|
1767
|
+
*/
|
|
1768
|
+
poolName?: string;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Options for forking an actor.
|
|
1772
|
+
*/
|
|
1773
|
+
interface ForkOptions extends QueryOptions {
|
|
1774
|
+
/** The new actor's key. Omit for a keyless actor. */
|
|
1775
|
+
key?: string | string[];
|
|
1776
|
+
/** The fork input, passed to the new actor's `onFork` hook. */
|
|
1777
|
+
input?: unknown;
|
|
1023
1778
|
}
|
|
1024
1779
|
/**
|
|
1025
1780
|
* Represents a region to connect to.
|
|
@@ -1041,6 +1796,20 @@ interface Region {
|
|
|
1041
1796
|
}
|
|
1042
1797
|
declare const ACTOR_CONNS_SYMBOL: unique symbol;
|
|
1043
1798
|
declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
|
|
1799
|
+
/** Options for constructing a raw actor client. */
|
|
1800
|
+
interface ClientRawOptions {
|
|
1801
|
+
encoding?: Encoding;
|
|
1802
|
+
gateway?: ActorGatewayOptions;
|
|
1803
|
+
/** Bounds retries of refused requests across every handle of this client. */
|
|
1804
|
+
retryBudget?: RetryBudgetOptions;
|
|
1805
|
+
}
|
|
1806
|
+
/** Runtime-supplied wiring for clients created inside an actor. Set only by the native runtime. */
|
|
1807
|
+
interface ActorClientRuntimeOptions {
|
|
1808
|
+
/** Supplies the calling actor's invocation so actor-to-actor clients propagate its trace and ray ID. */
|
|
1809
|
+
currentActorInvocation?: CurrentActorInvocation;
|
|
1810
|
+
/** Opens and finishes the Core span covering an actor-to-actor call. */
|
|
1811
|
+
startCallSpan?: StartCallSpan;
|
|
1812
|
+
}
|
|
1044
1813
|
/**
|
|
1045
1814
|
* Client for managing & connecting to actors.
|
|
1046
1815
|
*
|
|
@@ -1049,11 +1818,15 @@ declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
|
|
|
1049
1818
|
*/
|
|
1050
1819
|
declare class ClientRaw {
|
|
1051
1820
|
#private;
|
|
1821
|
+
/** Issue namespace-scoped tokens with an explicit grant list. */
|
|
1822
|
+
readonly auth: {
|
|
1823
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
1824
|
+
};
|
|
1052
1825
|
[ACTOR_CONNS_SYMBOL]: Set<ActorConnRaw>;
|
|
1053
1826
|
/**
|
|
1054
1827
|
* Creates an instance of Client.
|
|
1055
1828
|
*/
|
|
1056
|
-
constructor(driver: EngineControlClient,
|
|
1829
|
+
constructor(driver: EngineControlClient, options?: ClientRawOptions & ActorClientRuntimeOptions);
|
|
1057
1830
|
/**
|
|
1058
1831
|
* Gets a stateless handle to a actor by its ID.
|
|
1059
1832
|
*
|
|
@@ -1095,6 +1868,16 @@ declare class ClientRaw {
|
|
|
1095
1868
|
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
1096
1869
|
*/
|
|
1097
1870
|
create<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
1871
|
+
/**
|
|
1872
|
+
* Forks the actor `actorId` into a new actor and returns a handle to it.
|
|
1873
|
+
*
|
|
1874
|
+
* @template AD The actor class that this handle is for.
|
|
1875
|
+
* @param {string} name - The name of the actor; the source has the same name.
|
|
1876
|
+
* @param {string} actorId - The ID of the source actor.
|
|
1877
|
+
* @param {ForkOptions} [opts] - The new actor's key and the fork input.
|
|
1878
|
+
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the new actor.
|
|
1879
|
+
*/
|
|
1880
|
+
fork<AD extends AnyActorDefinition>(name: string, actorId: string, opts?: ForkOptions): Promise<ActorHandle<AD>>;
|
|
1098
1881
|
[CREATE_ACTOR_CONN_PROXY]<AD extends AnyActorDefinition>(conn: ActorConnRaw): ActorConn<AD>;
|
|
1099
1882
|
/**
|
|
1100
1883
|
* Disconnects from all actors.
|
|
@@ -1109,17 +1892,38 @@ declare class ClientRaw {
|
|
|
1109
1892
|
*
|
|
1110
1893
|
* @template A The actor registry type.
|
|
1111
1894
|
*/
|
|
1112
|
-
type Client<A extends Registry<any>> = ClientRaw & {
|
|
1895
|
+
type Client<A extends Registry<any>> = ClientRaw & Omit<{
|
|
1113
1896
|
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
1114
|
-
}
|
|
1897
|
+
}, keyof ClientRaw>;
|
|
1115
1898
|
type AnyClient = Client<Registry<any>>;
|
|
1116
|
-
declare function createClientWithDriver<A extends Registry<any>>(driver: EngineControlClient,
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1899
|
+
declare function createClientWithDriver<A extends Registry<any>>(driver: EngineControlClient, options?: ClientRawOptions & ActorClientRuntimeOptions): Client<A>;
|
|
1900
|
+
|
|
1901
|
+
/** Sample rates keyed by action name, nested like the actor's action groups. */
|
|
1902
|
+
interface ActionSampleRates {
|
|
1903
|
+
readonly [name: string]: number | ActionSampleRates;
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* {@link ActionSampleRates} limited to the actions of one actor, so a rate for
|
|
1907
|
+
* an action that does not exist is a compile error.
|
|
1908
|
+
*/
|
|
1909
|
+
type ActionTraceSamplers<TActions> = {
|
|
1910
|
+
readonly [K in keyof TActions]?: TActions[K] extends (...args: never[]) => unknown ? number : ActionTraceSamplers<TActions[K]>;
|
|
1911
|
+
};
|
|
1912
|
+
/** Trace sampling for one actor definition. */
|
|
1913
|
+
interface ActorTracingOptions<TActions> {
|
|
1914
|
+
/**
|
|
1915
|
+
* Share of this actor's invocations that are recorded, from 0 to 1. A rate
|
|
1916
|
+
* lowers what is recorded and never raises it, so an invocation inside a
|
|
1917
|
+
* trace the caller did not record is not recorded at any rate.
|
|
1918
|
+
*/
|
|
1919
|
+
readonly sampler?: number;
|
|
1920
|
+
/** Rates that replace `sampler` for single actions. */
|
|
1921
|
+
readonly actions?: ActionTraceSamplers<TActions>;
|
|
1922
|
+
}
|
|
1120
1923
|
|
|
1121
1924
|
declare const DEFAULT_SLEEP_GRACE_PERIOD = 15000;
|
|
1122
1925
|
declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
|
|
1926
|
+
declare const RAW_STATE_SYMBOL: unique symbol;
|
|
1123
1927
|
declare const CONN_DRIVER_SYMBOL: unique symbol;
|
|
1124
1928
|
declare const CONN_STATE_MANAGER_SYMBOL: unique symbol;
|
|
1125
1929
|
interface ActorLogger {
|
|
@@ -1154,6 +1958,7 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
|
|
|
1154
1958
|
limit?: number;
|
|
1155
1959
|
};
|
|
1156
1960
|
type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
|
|
1961
|
+
/** @deprecated Actor KV was deprecated in 3.0 and will be removed in a future version. Store data in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/kv */
|
|
1157
1962
|
interface ActorKv {
|
|
1158
1963
|
get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
|
|
1159
1964
|
put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
|
|
@@ -1167,11 +1972,101 @@ interface ActorKv {
|
|
|
1167
1972
|
list<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(prefix: Uint8Array | string, options?: ActorKvListOptions<T, K>): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
|
|
1168
1973
|
[key: string]: any;
|
|
1169
1974
|
}
|
|
1975
|
+
/** One individual actor fork behind an actor, as `c.forkChain` lists it. */
|
|
1976
|
+
interface ActorForkLink {
|
|
1977
|
+
/** The source actor's ID. */
|
|
1978
|
+
actorId: string;
|
|
1979
|
+
/** The source actor's key. */
|
|
1980
|
+
key: string[];
|
|
1981
|
+
/** When the fork was made, in milliseconds since the epoch. */
|
|
1982
|
+
forkedAt: number;
|
|
1983
|
+
}
|
|
1984
|
+
/** The fork an `onFork` hook runs for: the newest entry of `c.forkChain` and the fork input. */
|
|
1985
|
+
interface ActorFork extends ActorForkLink {
|
|
1986
|
+
/**
|
|
1987
|
+
* The `input` passed to `client.<actor>.fork`, or `undefined`. It comes from the caller that
|
|
1988
|
+
* forked the actor, so validate it like any client input.
|
|
1989
|
+
*/
|
|
1990
|
+
input: unknown;
|
|
1991
|
+
}
|
|
1170
1992
|
interface ActorSchedule {
|
|
1171
|
-
after(duration: number, action: string, ...args: unknown[]): Promise<
|
|
1172
|
-
at(timestamp: number, action: string, ...args: unknown[]): Promise<
|
|
1993
|
+
after(duration: number, action: string, ...args: unknown[]): Promise<string>;
|
|
1994
|
+
at(timestamp: number, action: string, ...args: unknown[]): Promise<string>;
|
|
1995
|
+
cancel(id: string): Promise<boolean>;
|
|
1996
|
+
get(id: string): Promise<ScheduledEventInfo | undefined>;
|
|
1997
|
+
list(): Promise<ScheduledEventInfo[]>;
|
|
1173
1998
|
[key: string]: any;
|
|
1174
1999
|
}
|
|
2000
|
+
interface ActorCronSetOptions {
|
|
2001
|
+
name: string;
|
|
2002
|
+
expression: string;
|
|
2003
|
+
action: string;
|
|
2004
|
+
args?: unknown[];
|
|
2005
|
+
timezone?: string;
|
|
2006
|
+
/** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
|
|
2007
|
+
maxHistory?: number;
|
|
2008
|
+
}
|
|
2009
|
+
interface ActorCronEveryOptions {
|
|
2010
|
+
name: string;
|
|
2011
|
+
/** Fixed interval in milliseconds. Minimum 5,000. */
|
|
2012
|
+
interval: number;
|
|
2013
|
+
action: string;
|
|
2014
|
+
args?: unknown[];
|
|
2015
|
+
/** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
|
|
2016
|
+
maxHistory?: number;
|
|
2017
|
+
}
|
|
2018
|
+
interface ActorCron {
|
|
2019
|
+
set(options: ActorCronSetOptions): Promise<void>;
|
|
2020
|
+
every(options: ActorCronEveryOptions): Promise<void>;
|
|
2021
|
+
get(name: string): Promise<CronJobInfo | undefined>;
|
|
2022
|
+
list(): Promise<CronJobInfo[]>;
|
|
2023
|
+
delete(name: string): Promise<boolean>;
|
|
2024
|
+
history(name: string, options?: {
|
|
2025
|
+
limit?: number;
|
|
2026
|
+
}): Promise<CronFire[]>;
|
|
2027
|
+
[key: string]: any;
|
|
2028
|
+
}
|
|
2029
|
+
interface ScheduledEventInfo {
|
|
2030
|
+
id: string;
|
|
2031
|
+
action: string;
|
|
2032
|
+
args: unknown[];
|
|
2033
|
+
runAt: number;
|
|
2034
|
+
}
|
|
2035
|
+
type CronJobInfo = {
|
|
2036
|
+
name: string;
|
|
2037
|
+
action: string;
|
|
2038
|
+
args: unknown[];
|
|
2039
|
+
nextRunAt: number;
|
|
2040
|
+
lastRunAt?: number;
|
|
2041
|
+
maxHistory: number;
|
|
2042
|
+
} & ({
|
|
2043
|
+
kind: "cron";
|
|
2044
|
+
expression: string;
|
|
2045
|
+
timezone: string;
|
|
2046
|
+
} | {
|
|
2047
|
+
kind: "every";
|
|
2048
|
+
interval: number;
|
|
2049
|
+
});
|
|
2050
|
+
interface ScheduledFireInfo {
|
|
2051
|
+
kind: "at" | "cron" | "every";
|
|
2052
|
+
id: string;
|
|
2053
|
+
name?: string;
|
|
2054
|
+
scheduledAt: number;
|
|
2055
|
+
firedAt: number;
|
|
2056
|
+
}
|
|
2057
|
+
interface CronFire {
|
|
2058
|
+
action: string;
|
|
2059
|
+
scheduledAt: number;
|
|
2060
|
+
firedAt: number;
|
|
2061
|
+
finishedAt?: number;
|
|
2062
|
+
result: "running" | "ok" | "error" | "skipped";
|
|
2063
|
+
error?: {
|
|
2064
|
+
group: string;
|
|
2065
|
+
code: string;
|
|
2066
|
+
message: string;
|
|
2067
|
+
metadata?: unknown;
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
1175
2070
|
type QueueMessageOf<Name extends string, Body> = {
|
|
1176
2071
|
id: number | bigint;
|
|
1177
2072
|
name: Name;
|
|
@@ -1225,20 +2120,29 @@ interface QueueIterOptions<TName extends string = string, TCompletable extends b
|
|
|
1225
2120
|
signal?: AbortSignal;
|
|
1226
2121
|
completable?: TCompletable;
|
|
1227
2122
|
}
|
|
2123
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
1228
2124
|
interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1229
2125
|
send<TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"]): Promise<any>;
|
|
1230
2126
|
next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
|
|
1231
2127
|
nextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1232
2128
|
waitForNames<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(names: readonly TName[], opts?: QueueWaitOptions<TCompletable>): Promise<any>;
|
|
2129
|
+
/** @experimental */
|
|
2130
|
+
waitForAvailable<const TName extends QueueFilterName<TQueues>>(names?: readonly TName[], opts?: Omit<QueueWaitOptions<false>, "completable">): Promise<void>;
|
|
2131
|
+
/** @experimental */
|
|
2132
|
+
complete<const TName extends QueueFilterName<TQueues>>(message: {
|
|
2133
|
+
id: number | bigint;
|
|
2134
|
+
name: TName;
|
|
2135
|
+
}, ...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
|
|
1233
2136
|
enqueueAndWait<const TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"], opts?: QueueEnqueueAndWaitOptions): Promise<QueueCompletionResultForName<TQueues, TName>>;
|
|
1234
2137
|
tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
|
|
1235
2138
|
tryNextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1236
2139
|
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
|
|
1237
2140
|
[key: string]: any;
|
|
1238
2141
|
}
|
|
1239
|
-
interface Conn<
|
|
2142
|
+
interface Conn<_TState = unknown, TConnParams = unknown, TConnState = unknown, _TVars = unknown, _TInput = unknown, _TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider, _TEvents extends EventSchemaConfig = Record<never, never>, _TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1240
2143
|
id: string;
|
|
1241
2144
|
params: TConnParams;
|
|
2145
|
+
/** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
|
|
1242
2146
|
state: TConnState;
|
|
1243
2147
|
isHibernatable: boolean;
|
|
1244
2148
|
send(name: string, ...args: any[]): void;
|
|
@@ -1248,43 +2152,103 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
|
|
|
1248
2152
|
type AnyConn = Conn<any, any, any, any, any, any, any, any>;
|
|
1249
2153
|
interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1250
2154
|
[ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
|
|
2155
|
+
/** Returns the raw unwrapped state without the write-through proxy. */
|
|
2156
|
+
[RAW_STATE_SYMBOL](): TState;
|
|
2157
|
+
/** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
|
|
1251
2158
|
state: TState;
|
|
1252
2159
|
vars: TVars;
|
|
2160
|
+
/** @deprecated Actor KV was deprecated in 3.0 and will be removed in a future version. Store data in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/kv */
|
|
1253
2161
|
readonly kv: ActorKv;
|
|
1254
2162
|
readonly db: InferDatabaseClient<TDatabase>;
|
|
1255
2163
|
readonly schedule: ActorSchedule;
|
|
2164
|
+
readonly cron: ActorCron;
|
|
2165
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
1256
2166
|
readonly queue: ActorQueue<TQueues>;
|
|
2167
|
+
/** @experimental */
|
|
2168
|
+
readonly run: ActorRun;
|
|
1257
2169
|
readonly actorId: string;
|
|
1258
2170
|
readonly name: string;
|
|
1259
2171
|
readonly key: string[];
|
|
2172
|
+
/**
|
|
2173
|
+
* The individual actor forks behind this actor, oldest first; empty when it was never
|
|
2174
|
+
* forked. Namespace forks are not listed.
|
|
2175
|
+
*/
|
|
2176
|
+
readonly forkChain: ActorForkLink[];
|
|
1260
2177
|
readonly region: string;
|
|
2178
|
+
/**
|
|
2179
|
+
* The name of the namespace the actor runs in. After a namespace fork it differs from the
|
|
2180
|
+
* source actor's namespace while the actor id stays the same, so an actor that owns an
|
|
2181
|
+
* external resource can store this to detect that it was copied.
|
|
2182
|
+
*/
|
|
2183
|
+
readonly namespace: string;
|
|
1261
2184
|
readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1262
2185
|
readonly log: ActorLogger;
|
|
1263
2186
|
readonly abortSignal: AbortSignal;
|
|
1264
2187
|
readonly aborted: boolean;
|
|
1265
2188
|
readonly request?: Request;
|
|
1266
|
-
/** @deprecated
|
|
2189
|
+
/** @deprecated `preventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op that always returns `false`. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
|
|
1267
2190
|
readonly preventSleep: boolean;
|
|
1268
2191
|
broadcast(name: string, ...args: any[]): void;
|
|
2192
|
+
/** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
|
|
1269
2193
|
saveState(opts?: {
|
|
1270
2194
|
immediate?: boolean;
|
|
1271
2195
|
maxWait?: number;
|
|
1272
2196
|
}): Promise<void>;
|
|
1273
2197
|
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
1274
2198
|
waitUntil(promise: Promise<unknown>): void;
|
|
1275
|
-
/** @deprecated
|
|
2199
|
+
/** @deprecated `setPreventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
|
|
1276
2200
|
setPreventSleep(preventSleep: boolean): void;
|
|
1277
2201
|
sleep(): void;
|
|
1278
2202
|
destroy(): void;
|
|
1279
2203
|
client<T = any>(): ActorClientFor<T>;
|
|
1280
2204
|
[key: string]: any;
|
|
1281
2205
|
}
|
|
2206
|
+
/** @experimental How one run of a workflow function ended. */
|
|
2207
|
+
type WorkflowOutcome = "completed" | "sleeping" | "evicted" | "failed" | "cancelled";
|
|
2208
|
+
/** @experimental How one workflow step attempt ended. `retry` will be tried again, `failed` will not. */
|
|
2209
|
+
type WorkflowStepOutcome = "ok" | "retry" | "failed";
|
|
2210
|
+
/** @experimental One open run of a workflow function, traced as its own invocation. */
|
|
2211
|
+
interface WorkflowSpan {
|
|
2212
|
+
/** Runs `body` attributed to this run. */
|
|
2213
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
2214
|
+
/**
|
|
2215
|
+
* Called by a workflow engine before each attempt at a step. Returns
|
|
2216
|
+
* nothing when tracing is off.
|
|
2217
|
+
*/
|
|
2218
|
+
startStep(name: string, attempt: number): WorkflowStepSpan | undefined;
|
|
2219
|
+
finish(outcome: WorkflowOutcome): Promise<void>;
|
|
2220
|
+
}
|
|
2221
|
+
/** @experimental One open attempt at one workflow step. */
|
|
2222
|
+
interface WorkflowStepSpan {
|
|
2223
|
+
/** Runs `body` attributed to this attempt. */
|
|
2224
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
2225
|
+
/** `error` is what the step callback threw. */
|
|
2226
|
+
finish(outcome: WorkflowStepOutcome, error?: unknown): void;
|
|
2227
|
+
}
|
|
2228
|
+
/** @experimental */
|
|
2229
|
+
interface ActorRun {
|
|
2230
|
+
/**
|
|
2231
|
+
* @experimental Sets or clears the durable Unix-millisecond deadline that
|
|
2232
|
+
* ensures this actor's run handler is active, starting it if inactive.
|
|
2233
|
+
*/
|
|
2234
|
+
setWakeAt(timestamp: number | null): Promise<void>;
|
|
2235
|
+
/** @experimental Called by a workflow engine each time it runs the workflow function. */
|
|
2236
|
+
startWorkflowSpan(): Promise<WorkflowSpan>;
|
|
2237
|
+
/**
|
|
2238
|
+
* @experimental Runs `body` outside the current workflow run, so a workflow
|
|
2239
|
+
* engine's own history storage stays out of the trace.
|
|
2240
|
+
*/
|
|
2241
|
+
runOutsideWorkflowSpan<T>(body: () => T): T;
|
|
2242
|
+
}
|
|
1282
2243
|
type ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & {
|
|
2244
|
+
/** Present only when a durable schedule or cron invokes this action. */
|
|
2245
|
+
readonly scheduledFire?: ScheduledFireInfo;
|
|
1283
2246
|
conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1284
2247
|
};
|
|
1285
2248
|
type BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1286
2249
|
type BeforeConnectContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, unknown, unknown, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1287
2250
|
type ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
2251
|
+
/** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
|
|
1288
2252
|
type CreateConnStateContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, unknown, unknown, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1289
2253
|
type CreateContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, unknown, unknown, unknown, TInput, TDatabase, TEvents, TQueues>;
|
|
1290
2254
|
type CreateVarsContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = CreateContext<TState, TInput, TDatabase, TEvents, TQueues>;
|
|
@@ -1293,6 +2257,7 @@ type DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1293
2257
|
type RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1294
2258
|
type RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1295
2259
|
type SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
2260
|
+
/** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. See https://rivet.dev/actors/docs/deprecated/state */
|
|
1296
2261
|
type StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1297
2262
|
type WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1298
2263
|
type MigrateContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
@@ -1307,14 +2272,90 @@ interface ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
|
|
|
1307
2272
|
database?: TDatabase;
|
|
1308
2273
|
}
|
|
1309
2274
|
type InspectorUnsubscribe = () => void;
|
|
2275
|
+
/** @experimental */
|
|
1310
2276
|
interface WorkflowInspectorConfig<THistory = unknown> {
|
|
1311
2277
|
getHistory: () => THistory | null;
|
|
2278
|
+
getState?: () => Promise<WorkflowState | null>;
|
|
1312
2279
|
onHistoryUpdated?: (listener: (history: THistory) => void) => InspectorUnsubscribe;
|
|
1313
2280
|
replayFromStep?: (entryId?: string) => Promise<THistory | null>;
|
|
1314
2281
|
}
|
|
2282
|
+
/** @experimental */
|
|
1315
2283
|
interface RunInspectorConfig<THistory = unknown> {
|
|
1316
2284
|
workflow?: WorkflowInspectorConfig<THistory>;
|
|
1317
2285
|
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Built-in inspector tabs the dashboard ships. Used to validate
|
|
2288
|
+
* `hidden: true` entries and reject custom-tab ids that collide with
|
|
2289
|
+
* a built-in.
|
|
2290
|
+
*/
|
|
2291
|
+
declare const BUILTIN_INSPECTOR_TAB_IDS: readonly ["workflow", "database", "state", "queue", "schedules", "connections", "console"];
|
|
2292
|
+
declare const BuiltinInspectorTabIdSchema: z.ZodEnum<{
|
|
2293
|
+
workflow: "workflow";
|
|
2294
|
+
state: "state";
|
|
2295
|
+
database: "database";
|
|
2296
|
+
queue: "queue";
|
|
2297
|
+
schedules: "schedules";
|
|
2298
|
+
connections: "connections";
|
|
2299
|
+
console: "console";
|
|
2300
|
+
}>;
|
|
2301
|
+
declare const CustomInspectorTabEntrySchema: z.ZodObject<{
|
|
2302
|
+
id: z.ZodString;
|
|
2303
|
+
label: z.ZodString;
|
|
2304
|
+
source: z.ZodString;
|
|
2305
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
2306
|
+
hidden: z.ZodOptional<z.ZodLiteral<false>>;
|
|
2307
|
+
}, z.core.$strict>;
|
|
2308
|
+
declare const HideInspectorTabEntrySchema: z.ZodObject<{
|
|
2309
|
+
id: z.ZodEnum<{
|
|
2310
|
+
workflow: "workflow";
|
|
2311
|
+
state: "state";
|
|
2312
|
+
database: "database";
|
|
2313
|
+
queue: "queue";
|
|
2314
|
+
schedules: "schedules";
|
|
2315
|
+
connections: "connections";
|
|
2316
|
+
console: "console";
|
|
2317
|
+
}>;
|
|
2318
|
+
hidden: z.ZodLiteral<true>;
|
|
2319
|
+
}, z.core.$strict>;
|
|
2320
|
+
declare const InspectorTabEntrySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
2321
|
+
id: z.ZodString;
|
|
2322
|
+
label: z.ZodString;
|
|
2323
|
+
source: z.ZodString;
|
|
2324
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
2325
|
+
hidden: z.ZodOptional<z.ZodLiteral<false>>;
|
|
2326
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2327
|
+
id: z.ZodEnum<{
|
|
2328
|
+
workflow: "workflow";
|
|
2329
|
+
state: "state";
|
|
2330
|
+
database: "database";
|
|
2331
|
+
queue: "queue";
|
|
2332
|
+
schedules: "schedules";
|
|
2333
|
+
connections: "connections";
|
|
2334
|
+
console: "console";
|
|
2335
|
+
}>;
|
|
2336
|
+
hidden: z.ZodLiteral<true>;
|
|
2337
|
+
}, z.core.$strict>]>;
|
|
2338
|
+
declare const ActorInspectorConfigSchema: z.ZodObject<{
|
|
2339
|
+
tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
2340
|
+
id: z.ZodString;
|
|
2341
|
+
label: z.ZodString;
|
|
2342
|
+
source: z.ZodString;
|
|
2343
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
2344
|
+
hidden: z.ZodOptional<z.ZodLiteral<false>>;
|
|
2345
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2346
|
+
id: z.ZodEnum<{
|
|
2347
|
+
workflow: "workflow";
|
|
2348
|
+
state: "state";
|
|
2349
|
+
database: "database";
|
|
2350
|
+
queue: "queue";
|
|
2351
|
+
schedules: "schedules";
|
|
2352
|
+
connections: "connections";
|
|
2353
|
+
console: "console";
|
|
2354
|
+
}>;
|
|
2355
|
+
hidden: z.ZodLiteral<true>;
|
|
2356
|
+
}, z.core.$strict>]>>>;
|
|
2357
|
+
}, z.core.$strict>;
|
|
2358
|
+
type ActorInspectorConfig = z.input<typeof ActorInspectorConfigSchema>;
|
|
1318
2359
|
declare const RunConfigSchema: z.ZodObject<{
|
|
1319
2360
|
name: z.ZodOptional<z.ZodString>;
|
|
1320
2361
|
icon: z.ZodOptional<z.ZodString>;
|
|
@@ -1322,6 +2363,7 @@ declare const RunConfigSchema: z.ZodObject<{
|
|
|
1322
2363
|
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1323
2364
|
workflow: z.ZodOptional<z.ZodObject<{
|
|
1324
2365
|
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
2366
|
+
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1325
2367
|
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1326
2368
|
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1327
2369
|
}, z.core.$strip>>;
|
|
@@ -1332,7 +2374,59 @@ type RunConfig<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
|
|
|
1332
2374
|
run: (c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
1333
2375
|
};
|
|
1334
2376
|
type AnyRunConfig = RunConfig<any, any, any, any, any, AnyDatabaseProvider, any, any>;
|
|
1335
|
-
|
|
2377
|
+
/** @experimental */
|
|
2378
|
+
type RunInspectorKind = "workflow";
|
|
2379
|
+
/** @experimental */
|
|
2380
|
+
interface RunWithInactiveOptions {
|
|
2381
|
+
/** Restart the run handler before releasing the exclusive gate on success. */
|
|
2382
|
+
restartOnSuccess?: boolean;
|
|
2383
|
+
}
|
|
2384
|
+
/** @experimental */
|
|
2385
|
+
interface RunControl {
|
|
2386
|
+
run: {
|
|
2387
|
+
/**
|
|
2388
|
+
* Executes only while no run handler is active or waiting to start.
|
|
2389
|
+
*
|
|
2390
|
+
* This is a non-blocking acquisition: concurrent replay/control requests
|
|
2391
|
+
* fail instead of waiting behind an active run.
|
|
2392
|
+
*/
|
|
2393
|
+
withInactive<T>(options: RunWithInactiveOptions, callback: () => T | Promise<T>): Promise<T>;
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
/** @experimental */
|
|
2397
|
+
interface RunInspectorFactoryContext {
|
|
2398
|
+
actorId: string;
|
|
2399
|
+
control: RunControl;
|
|
2400
|
+
}
|
|
2401
|
+
/** @experimental */
|
|
2402
|
+
interface RunInspectorFactoryResult<THistory = unknown> {
|
|
2403
|
+
inspector: {
|
|
2404
|
+
workflow: Required<WorkflowInspectorConfig<THistory>> & {
|
|
2405
|
+
getState: () => Promise<WorkflowState | null>;
|
|
2406
|
+
};
|
|
2407
|
+
};
|
|
2408
|
+
/** Releases actor-specific listeners and encoded history. */
|
|
2409
|
+
dispose?: () => void;
|
|
2410
|
+
}
|
|
2411
|
+
interface RunHandlerDisplayOptions {
|
|
2412
|
+
name?: string;
|
|
2413
|
+
icon?: string;
|
|
2414
|
+
}
|
|
2415
|
+
/** @experimental */
|
|
2416
|
+
type DefineRunHandlerOptions<THistory = unknown> = RunHandlerDisplayOptions & ({
|
|
2417
|
+
inspectorKind?: never;
|
|
2418
|
+
createInspector?: never;
|
|
2419
|
+
} | {
|
|
2420
|
+
/** Static metadata used to install Inspector callbacks at registry build time. */
|
|
2421
|
+
inspectorKind: RunInspectorKind;
|
|
2422
|
+
/** Creates one Inspector adapter for each live actor. */
|
|
2423
|
+
createInspector: (context: RunInspectorFactoryContext) => RunInspectorFactoryResult<THistory>;
|
|
2424
|
+
});
|
|
2425
|
+
/**
|
|
2426
|
+
* @experimental Adds supported RivetKit run metadata while preserving the function's exact
|
|
2427
|
+
* callable type.
|
|
2428
|
+
*/
|
|
2429
|
+
declare function defineRunHandler<TRun extends (...args: any[]) => any, THistory = unknown>(run: TRun, options: DefineRunHandlerOptions<THistory>): TRun;
|
|
1336
2430
|
/** Extract the run function from either a function or RunConfig object. */
|
|
1337
2431
|
declare function getRunFunction(run: ((...args: any[]) => any) | AnyRunConfig | undefined): ((...args: any[]) => any) | undefined;
|
|
1338
2432
|
/** Extract run metadata (name/icon) from RunConfig if provided. */
|
|
@@ -1342,6 +2436,8 @@ declare function getRunMetadata(run: ((...args: any[]) => any) | AnyRunConfig |
|
|
|
1342
2436
|
};
|
|
1343
2437
|
/** Extract run inspector configuration if provided. */
|
|
1344
2438
|
declare function getRunInspectorConfig(run: ((...args: any[]) => any) | AnyRunConfig | undefined, actor?: unknown): RunInspectorConfig | undefined;
|
|
2439
|
+
/** Release per-actor inspector state for a destroyed actor, if the run handler registered a disposer. */
|
|
2440
|
+
declare function disposeRunInspector(run: ((...args: any[]) => any) | AnyRunConfig | undefined, actorId: string): void;
|
|
1345
2441
|
declare const GlobalActorOptionsSchema: z.ZodPrefault<z.ZodObject<{
|
|
1346
2442
|
name: z.ZodOptional<z.ZodString>;
|
|
1347
2443
|
icon: z.ZodOptional<z.ZodString>;
|
|
@@ -1365,6 +2461,7 @@ declare const InstanceActorOptionsSchema: z.ZodPrefault<z.ZodObject<{
|
|
|
1365
2461
|
noSleep: z.ZodDefault<z.ZodBoolean>;
|
|
1366
2462
|
sleepTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1367
2463
|
maxQueueSize: z.ZodDefault<z.ZodNumber>;
|
|
2464
|
+
maxSchedules: z.ZodDefault<z.ZodNumber>;
|
|
1368
2465
|
maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
|
|
1369
2466
|
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
1370
2467
|
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1390,6 +2487,7 @@ declare const ActorOptionsSchema: z.ZodPrefault<z.ZodObject<{
|
|
|
1390
2487
|
noSleep: z.ZodDefault<z.ZodBoolean>;
|
|
1391
2488
|
sleepTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1392
2489
|
maxQueueSize: z.ZodDefault<z.ZodNumber>;
|
|
2490
|
+
maxSchedules: z.ZodDefault<z.ZodNumber>;
|
|
1393
2491
|
maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
|
|
1394
2492
|
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
1395
2493
|
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1401,6 +2499,7 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1401
2499
|
onDestroy: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1402
2500
|
onMigrate: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1403
2501
|
onWake: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2502
|
+
onFork: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1404
2503
|
onSleep: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1405
2504
|
run: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>, z.ZodObject<{
|
|
1406
2505
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1409,6 +2508,7 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1409
2508
|
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1410
2509
|
workflow: z.ZodOptional<z.ZodObject<{
|
|
1411
2510
|
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
2511
|
+
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1412
2512
|
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1413
2513
|
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1414
2514
|
}, z.core.$strip>>;
|
|
@@ -1421,8 +2521,12 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1421
2521
|
onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1422
2522
|
onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1423
2523
|
onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1424
|
-
actions: z.ZodDefault<z.
|
|
2524
|
+
actions: z.ZodDefault<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
1425
2525
|
actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
2526
|
+
tracing: z.ZodOptional<z.ZodObject<{
|
|
2527
|
+
sampler: z.ZodOptional<z.ZodNumber>;
|
|
2528
|
+
actions: z.ZodOptional<z.ZodType<ActionSampleRates, unknown, z.core.$ZodTypeInternals<ActionSampleRates, unknown>>>;
|
|
2529
|
+
}, z.core.$strict>>;
|
|
1426
2530
|
connParamsSchema: z.ZodOptional<z.ZodAny>;
|
|
1427
2531
|
events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1428
2532
|
queues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -1452,25 +2556,50 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1452
2556
|
noSleep: z.ZodDefault<z.ZodBoolean>;
|
|
1453
2557
|
sleepTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1454
2558
|
maxQueueSize: z.ZodDefault<z.ZodNumber>;
|
|
2559
|
+
maxSchedules: z.ZodDefault<z.ZodNumber>;
|
|
1455
2560
|
maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
|
|
1456
2561
|
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
1457
2562
|
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
1458
2563
|
}, z.core.$strict>>;
|
|
2564
|
+
inspector: z.ZodOptional<z.ZodObject<{
|
|
2565
|
+
tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
2566
|
+
id: z.ZodString;
|
|
2567
|
+
label: z.ZodString;
|
|
2568
|
+
source: z.ZodString;
|
|
2569
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
2570
|
+
hidden: z.ZodOptional<z.ZodLiteral<false>>;
|
|
2571
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2572
|
+
id: z.ZodEnum<{
|
|
2573
|
+
workflow: "workflow";
|
|
2574
|
+
state: "state";
|
|
2575
|
+
database: "database";
|
|
2576
|
+
queue: "queue";
|
|
2577
|
+
schedules: "schedules";
|
|
2578
|
+
connections: "connections";
|
|
2579
|
+
console: "console";
|
|
2580
|
+
}>;
|
|
2581
|
+
hidden: z.ZodLiteral<true>;
|
|
2582
|
+
}, z.core.$strict>]>>>;
|
|
2583
|
+
}, z.core.$strict>>;
|
|
1459
2584
|
}, z.core.$strict>;
|
|
1460
|
-
type CreateState<TState,
|
|
2585
|
+
type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2586
|
+
/** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
|
|
1461
2587
|
state: TState;
|
|
1462
2588
|
} | {
|
|
2589
|
+
/** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
|
|
1463
2590
|
createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
|
|
1464
2591
|
} | Record<never, never>;
|
|
1465
2592
|
type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2593
|
+
/** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
|
|
1466
2594
|
connState: TConnState;
|
|
1467
2595
|
} | {
|
|
2596
|
+
/** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
|
|
1468
2597
|
createConnState: (c: CreateConnStateContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => TConnState | Promise<TConnState>;
|
|
1469
2598
|
} | Record<never, never>;
|
|
1470
2599
|
/**
|
|
1471
2600
|
* @experimental
|
|
1472
2601
|
*/
|
|
1473
|
-
type CreateVars<TState,
|
|
2602
|
+
type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1474
2603
|
/**
|
|
1475
2604
|
* @experimental
|
|
1476
2605
|
*/
|
|
@@ -1482,7 +2611,10 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extend
|
|
|
1482
2611
|
createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
|
|
1483
2612
|
} | Record<never, never>;
|
|
1484
2613
|
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1485
|
-
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any
|
|
2614
|
+
[Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
2615
|
+
}
|
|
2616
|
+
interface ActionInputSchemas {
|
|
2617
|
+
[Action: string]: PrimitiveSchema | ActionInputSchemas;
|
|
1486
2618
|
}
|
|
1487
2619
|
/**
|
|
1488
2620
|
* @experimental
|
|
@@ -1507,6 +2639,36 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1507
2639
|
* must run on both first boot and wake.
|
|
1508
2640
|
*/
|
|
1509
2641
|
onMigrate?: (c: MigrateContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, isNew: boolean) => void | Promise<void>;
|
|
2642
|
+
/**
|
|
2643
|
+
* Called once at the first start of an actor made by forking another actor
|
|
2644
|
+
* (`client.<actor>.fork`), after its state loads and before `onWake` and any
|
|
2645
|
+
* overdue schedule events run. `createState` and `onCreate` do not run for a fork.
|
|
2646
|
+
*
|
|
2647
|
+
* Use this hook to cancel schedules the fork inherited, drop resources copied
|
|
2648
|
+
* from the source, or record the fork input. `c.forkChain` already ends with
|
|
2649
|
+
* this fork. A throw fails the start, and the hook runs again on the next start.
|
|
2650
|
+
* Forks of a whole namespace do not call it.
|
|
2651
|
+
*
|
|
2652
|
+
* State edits made in this hook are saved in one commit with the record that the
|
|
2653
|
+
* fork ran, so a start that finds the fork recorded also finds the hook's final
|
|
2654
|
+
* state. On native SQLite the hook's `c.db` writes and any save it starts itself
|
|
2655
|
+
* join that commit too, and a failed start drops them. Two limits apply:
|
|
2656
|
+
*
|
|
2657
|
+
* - On remote SQLite (wasm runtimes), `c.db` writes, and state the hook writes
|
|
2658
|
+
* itself in a transaction (for example `c.db.transaction` with
|
|
2659
|
+
* `experimental.includeState`), are committed at once, without the fork record.
|
|
2660
|
+
* A `c.saveState` call is not such a write: the startup save carries its
|
|
2661
|
+
* state. Only state the hook leaves to the startup save is atomic with it. A
|
|
2662
|
+
* crash or a failed start before the record lands runs the hook again on top
|
|
2663
|
+
* of those writes, so the hook must be idempotent there.
|
|
2664
|
+
* - On native SQLite the hook's writes must fit one commit (32,768 pages, 128 MiB
|
|
2665
|
+
* at the default page size). A transaction that would take them past it fails as
|
|
2666
|
+
* too large instead of committing part of them early; a hook that lets the error
|
|
2667
|
+
* throw fails the start, and nothing it wrote lands. Move a backfill that large
|
|
2668
|
+
* into later actions.
|
|
2669
|
+
* `onCreate` differs: its writes held so far are committed early instead.
|
|
2670
|
+
*/
|
|
2671
|
+
onFork?: (c: WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, fork: ActorFork) => void | Promise<void>;
|
|
1510
2672
|
/**
|
|
1511
2673
|
* Called when the actor is started and ready to receive connections and action.
|
|
1512
2674
|
*
|
|
@@ -1552,6 +2714,12 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1552
2714
|
*
|
|
1553
2715
|
* Can be either a function or a RunConfig object with optional name/icon metadata.
|
|
1554
2716
|
*
|
|
2717
|
+
* Passing a plain function was deprecated in 3.0 and will be removed in a
|
|
2718
|
+
* future version; it logs a warning at startup. Start background work from
|
|
2719
|
+
* `onWake` with `c.keepAwake` and track it in `c.vars` instead.
|
|
2720
|
+
* `run: workflow(...)` is not deprecated. See
|
|
2721
|
+
* https://rivet.dev/actors/docs/deprecated/run
|
|
2722
|
+
*
|
|
1555
2723
|
* @returns Void or a Promise.
|
|
1556
2724
|
*/
|
|
1557
2725
|
run?: ((c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>) | RunConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
@@ -1565,6 +2733,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1565
2733
|
* another onStateChange call, preventing infinite recursion.
|
|
1566
2734
|
*
|
|
1567
2735
|
* @param newState The updated state
|
|
2736
|
+
* @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state
|
|
1568
2737
|
*/
|
|
1569
2738
|
onStateChange?: (c: StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, newState: TState) => void;
|
|
1570
2739
|
/**
|
|
@@ -1638,9 +2807,15 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1638
2807
|
onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
|
|
1639
2808
|
actions?: TActions;
|
|
1640
2809
|
/**
|
|
1641
|
-
* Optional
|
|
2810
|
+
* Optional schemas for validating action argument tuples in native runtimes.
|
|
2811
|
+
* May mirror nested action groups or use dot-separated low-level action names.
|
|
1642
2812
|
*/
|
|
1643
|
-
actionInputSchemas?:
|
|
2813
|
+
actionInputSchemas?: ActionInputSchemas;
|
|
2814
|
+
/**
|
|
2815
|
+
* How much of this actor's work is recorded in traces. Defaults to the
|
|
2816
|
+
* process sampler from `OTEL_TRACES_SAMPLER`.
|
|
2817
|
+
*/
|
|
2818
|
+
tracing?: ActorTracingOptions<TActions>;
|
|
1644
2819
|
/**
|
|
1645
2820
|
* Optional schema for validating connection params in native runtimes.
|
|
1646
2821
|
*/
|
|
@@ -1651,6 +2826,8 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1651
2826
|
events?: TEvents;
|
|
1652
2827
|
/**
|
|
1653
2828
|
* Schema map for queue payloads sent by this actor.
|
|
2829
|
+
*
|
|
2830
|
+
* @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues
|
|
1654
2831
|
*/
|
|
1655
2832
|
queues?: TQueues;
|
|
1656
2833
|
}
|
|
@@ -1660,10 +2837,10 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
|
1660
2837
|
*/
|
|
1661
2838
|
db: TDatabase;
|
|
1662
2839
|
} | Record<never, never>;
|
|
1663
|
-
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues,
|
|
2840
|
+
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onFork" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
|
|
1664
2841
|
type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined, TDatabase extends AnyDatabaseProvider = undefined, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Record<never, never>> = {
|
|
1665
2842
|
types?: ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
1666
|
-
} & Omit<z.input<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
|
|
2843
|
+
} & Omit<z.input<typeof ActorConfigSchema>, "actions" | "tracing" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onFork" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
|
|
1667
2844
|
declare function test<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>(input: ActorConfigInput<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions>): ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1668
2845
|
declare const DocActorOptionsSchema: z.ZodObject<{
|
|
1669
2846
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1683,10 +2860,9 @@ declare const DocActorOptionsSchema: z.ZodObject<{
|
|
|
1683
2860
|
noSleep: z.ZodOptional<z.ZodBoolean>;
|
|
1684
2861
|
sleepTimeout: z.ZodOptional<z.ZodNumber>;
|
|
1685
2862
|
maxQueueSize: z.ZodOptional<z.ZodNumber>;
|
|
2863
|
+
maxSchedules: z.ZodOptional<z.ZodNumber>;
|
|
1686
2864
|
maxQueueMessageSize: z.ZodOptional<z.ZodNumber>;
|
|
1687
2865
|
canHibernateWebSocket: z.ZodOptional<z.ZodBoolean>;
|
|
1688
|
-
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
1689
|
-
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
1690
2866
|
}, z.core.$strip>;
|
|
1691
2867
|
declare const DocActorConfigSchema: z.ZodObject<{
|
|
1692
2868
|
state: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -1700,6 +2876,7 @@ declare const DocActorConfigSchema: z.ZodObject<{
|
|
|
1700
2876
|
onDestroy: z.ZodOptional<z.ZodUnknown>;
|
|
1701
2877
|
onMigrate: z.ZodOptional<z.ZodUnknown>;
|
|
1702
2878
|
onWake: z.ZodOptional<z.ZodUnknown>;
|
|
2879
|
+
onFork: z.ZodOptional<z.ZodUnknown>;
|
|
1703
2880
|
onSleep: z.ZodOptional<z.ZodUnknown>;
|
|
1704
2881
|
run: z.ZodOptional<z.ZodUnknown>;
|
|
1705
2882
|
onStateChange: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -1711,6 +2888,7 @@ declare const DocActorConfigSchema: z.ZodObject<{
|
|
|
1711
2888
|
onWebSocket: z.ZodOptional<z.ZodUnknown>;
|
|
1712
2889
|
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1713
2890
|
actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2891
|
+
tracing: z.ZodOptional<z.ZodUnknown>;
|
|
1714
2892
|
connParamsSchema: z.ZodOptional<z.ZodUnknown>;
|
|
1715
2893
|
events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1716
2894
|
queues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1732,11 +2910,10 @@ declare const DocActorConfigSchema: z.ZodObject<{
|
|
|
1732
2910
|
noSleep: z.ZodOptional<z.ZodBoolean>;
|
|
1733
2911
|
sleepTimeout: z.ZodOptional<z.ZodNumber>;
|
|
1734
2912
|
maxQueueSize: z.ZodOptional<z.ZodNumber>;
|
|
2913
|
+
maxSchedules: z.ZodOptional<z.ZodNumber>;
|
|
1735
2914
|
maxQueueMessageSize: z.ZodOptional<z.ZodNumber>;
|
|
1736
2915
|
canHibernateWebSocket: z.ZodOptional<z.ZodBoolean>;
|
|
1737
|
-
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
1738
|
-
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
1739
2916
|
}, z.core.$strip>>;
|
|
1740
2917
|
}, z.core.$strip>;
|
|
1741
2918
|
|
|
1742
|
-
export {
|
|
2919
|
+
export { type AnyConn as $, type AnyActorDefinition as A, type BaseActorDefinition as B, type ConnectContext as C, type DestroyContext as D, type EventSchemaConfig as E, type ActorInspectorConfig as F, ActorInspectorConfigSchema as G, type ActorKey as H, type ActorKv as I, type ActorLogger as J, type ActorOptions as K, type ActorOptionsInput as L, type MigrateContext as M, ActorOptionsSchema as N, type ActorQuery as O, type ActorQueue as P, type QueueSchemaConfig as Q, type RequestContext as R, type SleepContext as S, type ActorRun as T, type ActorSchedule as U, type ActorTracingOptions as V, type WakeContext as W, type ActorTypes as X, ActorsSchema as Y, type AnyActorInstance as Z, type AnyClient as _, type ActionContext as a, type RuntimeKind as a$, type AnyStaticActorDefinition as a0, type AnyStaticActorInstance as a1, type AuthIntent as a2, BUILTIN_INSPECTOR_TAB_IDS as a3, type BaseActorInstance as a4, BuiltinInspectorTabIdSchema as a5, CONN_DRIVER_SYMBOL as a6, CONN_STATE_MANAGER_SYMBOL as a7, type Client as a8, type Conn as a9, type QueueIterOptions as aA, type QueueMessageOf as aB, type QueueName as aC, type QueueNextBatchOptions as aD, type QueueNextOptions as aE, type QueueResultMessageForName as aF, type QueueTryNextBatchOptions as aG, type QueueTryNextOptions as aH, type QueueWaitOptions as aI, RAW_STATE_SYMBOL as aJ, Registry as aK, type RegistryActors as aL, type RegistryApplication as aM, type RegistryConfig as aN, type RegistryConfigInput as aO, RegistryConfigSchema as aP, type RegistryDeps as aQ, type RegistryListenOptions as aR, type RegistryRoutes as aS, type RunConfig as aT, RunConfigSchema as aU, type RunControl as aV, type RunInspectorConfig as aW, type RunInspectorFactoryContext as aX, type RunInspectorFactoryResult as aY, type RunInspectorKind as aZ, type RunWithInactiveOptions as a_, type CronFire as aa, type CronJobInfo as ab, CustomInspectorTabEntrySchema as ac, DEFAULT_SLEEP_GRACE_PERIOD as ad, type DefineRunHandlerOptions as ae, DocActorConfigSchema as af, DocActorOptionsSchema as ag, DocConfigurePoolSchema as ah, DocEnvoyConfigSchema as ai, DocRegistryConfigSchema as aj, DocServerlessConfigSchema as ak, DocSqliteConfigSchema as al, type FetchHandler as am, type GlobalActorOptions as an, type GlobalActorOptionsInput as ao, GlobalActorOptionsSchema as ap, HideInspectorTabEntrySchema as aq, type InferEventArgs as ar, type InferSchemaMap as as, InspectorTabEntrySchema as at, type InspectorUnsubscribe as au, type InstanceActorOptions as av, type InstanceActorOptionsInput as aw, InstanceActorOptionsSchema as ax, type QueueEnqueueAndWaitOptions as ay, type QueueFilterName as az, type BeforeActionResponseContext as b, type TokenGrant as b$, RuntimeKindSchema as b0, type ScheduledEventInfo as b1, type ScheduledFireInfo as b2, type ServerlessHandler as b3, type SqliteBackend as b4, SqliteBackendSchema as b5, type SqliteConfig as b6, SqliteConfigSchema as b7, type TestConfig as b8, TestConfigSchema as b9, type ActorActionFunction as bA, type ActorActionOptions as bB, type ActorConn as bC, ActorConnRaw as bD, type ActorConnStatus as bE, type ActorConnectOptions as bF, type ActorGatewayOptions as bG, type ActorHandle as bH, ActorHandleRaw as bI, type ActorIssueTokenOptions as bJ, type ActorTokenPermissions as bK, type ActorTokenResource as bL, ClientRaw as bM, type ConnectionStateCallback as bN, type CreateOptions as bO, type CreateRequest as bP, type EventUnsubscribe as bQ, type ExtractActorsFromRegistry as bR, type ExtractRegistryFromClient as bS, type ForkOptions as bT, type GetOptions as bU, type GetWithIdOptions as bV, type IssueTokenOptions as bW, type IssuedToken as bX, type QueryOptions as bY, type Region as bZ, type StatusChangeCallback as b_, type Type as ba, type WasmRuntimeBindings as bb, type WasmRuntimeConfig as bc, WasmRuntimeConfigSchema as bd, type WasmRuntimeInitInput as be, type WorkflowInspectorConfig as bf, type WorkflowOutcome as bg, type WorkflowSpan as bh, type WorkflowStepOutcome as bi, type WorkflowStepSpan as bj, actor as bk, buildActorNames as bl, createClientWithDriver as bm, defineRunHandler as bn, disposeRunInspector as bo, event as bp, getRunFunction as bq, getRunInspectorConfig as br, getRunMetadata as bs, isStaticActorDefinition as bt, isStaticActorInstance as bu, lookupInRegistry as bv, queue as bw, setup as bx, test as by, type ActorAccessor as bz, type BeforeConnectContext as c, type CreateConnStateContext as d, type CreateContext as e, type CreateVarsContext as f, type DisconnectContext as g, type RunContext as h, type StateChangeContext as i, type WebSocketContext as j, ACTOR_CONTEXT_INTERNAL_SYMBOL as k, type ActionInputSchemas as l, type ActionSampleRates as m, type ActionTraceSamplers as n, type Actions as o, type ActorConfig as p, type ActorConfigInput as q, ActorConfigSchema as r, type ActorContext as s, type ActorContextOf as t, type ActorCron as u, type ActorCronEveryOptions as v, type ActorCronSetOptions as w, ActorDefinition as x, type ActorFork as y, type ActorForkLink as z };
|