rivetkit 2.3.0-rc.11 → 2.3.0-rc.13
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 +407 -20
- package/dist/browser/client.js +101 -86
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +12 -2
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/agent-os/index.cjs +66 -3
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +404 -17
- package/dist/tsup/agent-os/index.d.ts +404 -17
- package/dist/tsup/agent-os/index.js +66 -3
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-WXYWDLJY.js → chunk-33YE6XCI.js} +4 -4
- package/dist/tsup/{chunk-2NXFKPRB.cjs → chunk-7OR3CHD5.cjs} +10 -10
- package/dist/tsup/{chunk-2NXFKPRB.cjs.map → chunk-7OR3CHD5.cjs.map} +1 -1
- package/dist/tsup/{chunk-LW5HNCWD.cjs → chunk-7XQCARVY.cjs} +3 -3
- package/dist/tsup/{chunk-LW5HNCWD.cjs.map → chunk-7XQCARVY.cjs.map} +1 -1
- package/dist/tsup/{chunk-GX6W4MW3.cjs → chunk-BSPS6NSN.cjs} +5 -5
- package/dist/tsup/{chunk-GX6W4MW3.cjs.map → chunk-BSPS6NSN.cjs.map} +1 -1
- package/dist/tsup/{chunk-T3VCJ4PV.js → chunk-DPIMKYNB.js} +61 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-XG25CGSW.cjs → chunk-E5CLYAUZ.cjs} +146 -143
- package/dist/tsup/chunk-E5CLYAUZ.cjs.map +1 -0
- package/dist/tsup/{chunk-RDBGKI66.cjs → chunk-EBWOJRCC.cjs} +22 -5
- package/dist/tsup/chunk-EBWOJRCC.cjs.map +1 -0
- package/dist/tsup/{chunk-YRQ4F5CD.js → chunk-HHNYEQD3.js} +6 -6
- package/dist/tsup/chunk-HHNYEQD3.js.map +1 -0
- package/dist/tsup/{chunk-4FP4FFB5.js → chunk-IOUSQVXI.js} +21 -4
- package/dist/tsup/chunk-IOUSQVXI.js.map +1 -0
- package/dist/tsup/{chunk-LNP7Q6I6.cjs → chunk-ISDKSSYR.cjs} +4 -4
- package/dist/tsup/{chunk-LNP7Q6I6.cjs.map → chunk-ISDKSSYR.cjs.map} +1 -1
- package/dist/tsup/{chunk-TTLUIDVH.js → chunk-J72WHUBC.js} +12 -9
- package/dist/tsup/chunk-J72WHUBC.js.map +1 -0
- package/dist/tsup/{chunk-Y3JBOFBG.cjs → chunk-KWABEUUA.cjs} +10 -10
- package/dist/tsup/chunk-KWABEUUA.cjs.map +1 -0
- package/dist/tsup/{chunk-XCDCURZ4.cjs → chunk-NIY3RSPX.cjs} +62 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-3P2JUHWJ.js → chunk-T44AVAGW.js} +2 -2
- package/dist/tsup/{chunk-GRFBV2U7.js → chunk-TCXEM6PA.js} +2 -2
- package/dist/tsup/{chunk-KRC4L3YB.js → chunk-ZI5CNA2Z.js} +2 -2
- package/dist/tsup/client/mod.cjs +7 -7
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +6 -6
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-De5UVu0V.d.ts → config-BxWAw3iH.d.ts} +476 -20
- package/dist/tsup/{config-CTwe3WwC.d.cts → config-CZQQ-mso.d.cts} +476 -20
- package/dist/tsup/{context-Dmj477Uh.d.cts → context-Bw7xq8w3.d.cts} +1 -1
- package/dist/tsup/{context-DPHISlUi.d.ts → context-D8QA76sV.d.ts} +1 -1
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +341 -138
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +277 -74
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +11 -11
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +19 -9
- package/src/actor/config.ts +111 -10
- package/src/actor/definition.ts +6 -5
- package/src/actor/instance/mod.ts +4 -4
- package/src/actor/mod.ts +2 -0
- package/src/client/actor-common.ts +24 -27
- package/src/client/actor-handle.ts +2 -1
- package/src/common/engine.ts +28 -1
- package/src/common/utils.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +16 -5
- package/src/engine-client/actor-http-client.ts +2 -2
- package/src/engine-client/api-endpoints.ts +5 -1
- package/src/engine-client/ws-proxy.ts +5 -0
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +143 -62
- package/src/registry/napi-runtime.ts +6 -0
- package/src/registry/native.ts +170 -27
- package/src/registry/process-metrics.ts +16 -4
- package/src/registry/runtime.ts +26 -0
- package/src/registry/wasm-runtime.ts +16 -1
- package/src/utils/env-vars.ts +6 -0
- package/dist/tsup/chunk-4FP4FFB5.js.map +0 -1
- package/dist/tsup/chunk-RDBGKI66.cjs.map +0 -1
- package/dist/tsup/chunk-T3VCJ4PV.js.map +0 -1
- package/dist/tsup/chunk-TTLUIDVH.js.map +0 -1
- package/dist/tsup/chunk-XCDCURZ4.cjs.map +0 -1
- package/dist/tsup/chunk-XG25CGSW.cjs.map +0 -1
- package/dist/tsup/chunk-Y3JBOFBG.cjs.map +0 -1
- package/dist/tsup/chunk-YRQ4F5CD.js.map +0 -1
- /package/dist/tsup/{chunk-WXYWDLJY.js.map → chunk-33YE6XCI.js.map} +0 -0
- /package/dist/tsup/{chunk-3P2JUHWJ.js.map → chunk-T44AVAGW.js.map} +0 -0
- /package/dist/tsup/{chunk-GRFBV2U7.js.map → chunk-TCXEM6PA.js.map} +0 -0
- /package/dist/tsup/{chunk-KRC4L3YB.js.map → chunk-ZI5CNA2Z.js.map} +0 -0
package/dist/tsup/mod.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-
|
|
2
|
-
export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as
|
|
1
|
+
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-CZQQ-mso.cjs';
|
|
2
|
+
export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as ActorInspectorConfig, t as ActorInspectorConfigSchema, u as ActorKey, v as ActorKv, w as ActorLogger, x as ActorOptions, y as ActorOptionsInput, z as ActorOptionsSchema, F as ActorQuery, G as ActorQueue, H as ActorSchedule, I as ActorTypes, J as ActorsSchema, K as AnyActorInstance, L as AnyClient, N as AnyConn, O as AnyStaticActorDefinition, P as AnyStaticActorInstance, T as AuthIntent, U as BUILTIN_INSPECTOR_TAB_IDS, V as BaseActorInstance, X as BuiltinInspectorTabIdSchema, Y as CONN_DRIVER_SYMBOL, Z as CONN_STATE_MANAGER_SYMBOL, _ as Client, $ as Conn, a0 as CustomInspectorTabEntrySchema, a1 as DEFAULT_SLEEP_GRACE_PERIOD, a2 as DocActorConfigSchema, a3 as DocActorOptionsSchema, a4 as DocConfigurePoolSchema, a5 as DocEnvoyConfigSchema, a6 as DocRegistryConfigSchema, a7 as DocServerlessConfigSchema, a8 as DocSqliteConfigSchema, a9 as Encoding, aa as FetchHandler, ab as GlobalActorOptions, ac as GlobalActorOptionsInput, ad as GlobalActorOptionsSchema, ae as HideInspectorTabEntrySchema, af as InspectorTabEntrySchema, ag as InspectorUnsubscribe, ah as InstanceActorOptions, ai as InstanceActorOptionsInput, aj as InstanceActorOptionsSchema, ak as QueueEnqueueAndWaitOptions, al as QueueFilterName, am as QueueIterOptions, an as QueueMessageOf, ao as QueueName, ap as QueueNextBatchOptions, aq as QueueNextOptions, ar as QueueResultMessageForName, as as QueueTryNextBatchOptions, at as QueueTryNextOptions, au as QueueWaitOptions, av as RAW_STATE_SYMBOL, aw as RUN_FUNCTION_CONFIG_SYMBOL, ax as Registry, ay as RegistryActors, az as RegistryConfig, aA as RegistryConfigInput, aB as RegistryConfigSchema, aC as RegistryDeps, aD as RegistryRoutes, aE as RunConfig, aF as RunConfigSchema, aG as RunInspectorConfig, aH as RuntimeKind, aI as RuntimeKindSchema, aJ as ServerlessHandler, aK as SqliteBackend, aL as SqliteBackendSchema, aM as SqliteConfig, aN as SqliteConfigSchema, aO as TestConfig, aP as TestConfigSchema, aQ as Type, aR as WasmRuntimeBindings, aS as WasmRuntimeConfig, aT as WasmRuntimeConfigSchema, aU as WasmRuntimeInitInput, aV as WorkflowInspectorConfig, aW as actor, aX as buildActorNames, aY as createClientWithDriver, aZ as event, a_ as getRunFunction, a$ as getRunInspectorConfig, b0 as getRunMetadata, b1 as isStaticActorDefinition, b2 as isStaticActorInstance, b3 as lookupInRegistry, b4 as queue, b5 as setup, b6 as test } from './config-CZQQ-mso.cjs';
|
|
3
3
|
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
4
4
|
export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
5
5
|
import { A as AnyDatabaseProvider } from './config-D49x8NpL.cjs';
|
|
6
|
-
export { R as ActorError, R as RivetError, U as UserError,
|
|
6
|
+
export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-DQosb24I.cjs';
|
|
7
7
|
import { WSContext } from 'hono/ws';
|
|
8
8
|
export { toUint8Array } from './utils.cjs';
|
|
9
|
-
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-
|
|
9
|
+
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-Bw7xq8w3.cjs';
|
|
10
10
|
import 'zod/v4';
|
|
11
11
|
import '@rivetkit/rivetkit-wasm';
|
|
12
12
|
import 'zod';
|
package/dist/tsup/mod.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-
|
|
2
|
-
export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as
|
|
1
|
+
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-BxWAw3iH.js';
|
|
2
|
+
export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as ActorInspectorConfig, t as ActorInspectorConfigSchema, u as ActorKey, v as ActorKv, w as ActorLogger, x as ActorOptions, y as ActorOptionsInput, z as ActorOptionsSchema, F as ActorQuery, G as ActorQueue, H as ActorSchedule, I as ActorTypes, J as ActorsSchema, K as AnyActorInstance, L as AnyClient, N as AnyConn, O as AnyStaticActorDefinition, P as AnyStaticActorInstance, T as AuthIntent, U as BUILTIN_INSPECTOR_TAB_IDS, V as BaseActorInstance, X as BuiltinInspectorTabIdSchema, Y as CONN_DRIVER_SYMBOL, Z as CONN_STATE_MANAGER_SYMBOL, _ as Client, $ as Conn, a0 as CustomInspectorTabEntrySchema, a1 as DEFAULT_SLEEP_GRACE_PERIOD, a2 as DocActorConfigSchema, a3 as DocActorOptionsSchema, a4 as DocConfigurePoolSchema, a5 as DocEnvoyConfigSchema, a6 as DocRegistryConfigSchema, a7 as DocServerlessConfigSchema, a8 as DocSqliteConfigSchema, a9 as Encoding, aa as FetchHandler, ab as GlobalActorOptions, ac as GlobalActorOptionsInput, ad as GlobalActorOptionsSchema, ae as HideInspectorTabEntrySchema, af as InspectorTabEntrySchema, ag as InspectorUnsubscribe, ah as InstanceActorOptions, ai as InstanceActorOptionsInput, aj as InstanceActorOptionsSchema, ak as QueueEnqueueAndWaitOptions, al as QueueFilterName, am as QueueIterOptions, an as QueueMessageOf, ao as QueueName, ap as QueueNextBatchOptions, aq as QueueNextOptions, ar as QueueResultMessageForName, as as QueueTryNextBatchOptions, at as QueueTryNextOptions, au as QueueWaitOptions, av as RAW_STATE_SYMBOL, aw as RUN_FUNCTION_CONFIG_SYMBOL, ax as Registry, ay as RegistryActors, az as RegistryConfig, aA as RegistryConfigInput, aB as RegistryConfigSchema, aC as RegistryDeps, aD as RegistryRoutes, aE as RunConfig, aF as RunConfigSchema, aG as RunInspectorConfig, aH as RuntimeKind, aI as RuntimeKindSchema, aJ as ServerlessHandler, aK as SqliteBackend, aL as SqliteBackendSchema, aM as SqliteConfig, aN as SqliteConfigSchema, aO as TestConfig, aP as TestConfigSchema, aQ as Type, aR as WasmRuntimeBindings, aS as WasmRuntimeConfig, aT as WasmRuntimeConfigSchema, aU as WasmRuntimeInitInput, aV as WorkflowInspectorConfig, aW as actor, aX as buildActorNames, aY as createClientWithDriver, aZ as event, a_ as getRunFunction, a$ as getRunInspectorConfig, b0 as getRunMetadata, b1 as isStaticActorDefinition, b2 as isStaticActorInstance, b3 as lookupInRegistry, b4 as queue, b5 as setup, b6 as test } from './config-BxWAw3iH.js';
|
|
3
3
|
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
4
4
|
export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
5
5
|
import { A as AnyDatabaseProvider } from './config-D49x8NpL.js';
|
|
6
|
-
export { R as ActorError, R as RivetError, U as UserError,
|
|
6
|
+
export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-DQosb24I.js';
|
|
7
7
|
import { WSContext } from 'hono/ws';
|
|
8
8
|
export { toUint8Array } from './utils.js';
|
|
9
|
-
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-
|
|
9
|
+
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-D8QA76sV.js';
|
|
10
10
|
import 'zod/v4';
|
|
11
11
|
import '@rivetkit/rivetkit-wasm';
|
|
12
12
|
import 'zod';
|
package/dist/tsup/mod.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeWorkflowHistoryTransport
|
|
3
|
+
} from "./chunk-TCXEM6PA.js";
|
|
1
4
|
import {
|
|
2
5
|
ACTOR_CONTEXT_INTERNAL_SYMBOL,
|
|
3
6
|
ActorConfigSchema,
|
|
@@ -6,10 +9,7 @@ import {
|
|
|
6
9
|
getRunFunction,
|
|
7
10
|
getRunInspectorConfig,
|
|
8
11
|
getRunMetadata
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
decodeWorkflowHistoryTransport
|
|
12
|
-
} from "./chunk-GRFBV2U7.js";
|
|
12
|
+
} from "./chunk-DPIMKYNB.js";
|
|
13
13
|
import {
|
|
14
14
|
ALLOWED_PUBLIC_HEADERS,
|
|
15
15
|
HEADER_CONN_PARAMS,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getDatacenters,
|
|
20
20
|
tryParseEndpoint,
|
|
21
21
|
updateRunnerConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-J72WHUBC.js";
|
|
23
23
|
import {
|
|
24
24
|
KEYS,
|
|
25
25
|
makePrefixedKey,
|
|
@@ -32,9 +32,8 @@ import {
|
|
|
32
32
|
assertJsonCompatValue,
|
|
33
33
|
decodeCborCompat,
|
|
34
34
|
encodeCborCompat
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import "./chunk-
|
|
37
|
-
import "./chunk-3P2JUHWJ.js";
|
|
35
|
+
} from "./chunk-ZI5CNA2Z.js";
|
|
36
|
+
import "./chunk-T44AVAGW.js";
|
|
38
37
|
import {
|
|
39
38
|
LogLevelSchema,
|
|
40
39
|
VERSION,
|
|
@@ -51,6 +50,8 @@ import {
|
|
|
51
50
|
getRivetPublicEndpoint,
|
|
52
51
|
getRivetPublicToken,
|
|
53
52
|
getRivetRunEngine,
|
|
53
|
+
getRivetRunEngineHost,
|
|
54
|
+
getRivetRunEnginePort,
|
|
54
55
|
getRivetRunEngineVersion,
|
|
55
56
|
getRivetToken,
|
|
56
57
|
getRivetTotalSlots,
|
|
@@ -59,7 +60,7 @@ import {
|
|
|
59
60
|
noopNext,
|
|
60
61
|
stringifyError,
|
|
61
62
|
toUint8Array
|
|
62
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-IOUSQVXI.js";
|
|
63
64
|
import {
|
|
64
65
|
INTERNAL_ERROR_CODE,
|
|
65
66
|
RivetError,
|
|
@@ -71,6 +72,7 @@ import {
|
|
|
71
72
|
toRivetError,
|
|
72
73
|
unsupportedFeature
|
|
73
74
|
} from "./chunk-BRP62GZC.js";
|
|
75
|
+
import "./chunk-JZ7TWV65.js";
|
|
74
76
|
|
|
75
77
|
// src/actor/log.ts
|
|
76
78
|
function loggerWithoutContext() {
|
|
@@ -360,8 +362,23 @@ var InlineWebSocketAdapter = class {
|
|
|
360
362
|
import { Hono } from "hono";
|
|
361
363
|
|
|
362
364
|
// src/common/engine.ts
|
|
365
|
+
var ENGINE_HOST = "127.0.0.1";
|
|
363
366
|
var ENGINE_PORT = 6420;
|
|
364
|
-
var ENGINE_ENDPOINT =
|
|
367
|
+
var ENGINE_ENDPOINT = buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT);
|
|
368
|
+
function buildEngineEndpoint(host, port) {
|
|
369
|
+
const urlHost = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
370
|
+
return `http://${urlHost}:${port}`;
|
|
371
|
+
}
|
|
372
|
+
function isLocalEngineEndpoint(endpoint) {
|
|
373
|
+
let url;
|
|
374
|
+
try {
|
|
375
|
+
url = new URL(endpoint);
|
|
376
|
+
} catch {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
const hostname = url.hostname.toLowerCase();
|
|
380
|
+
return hostname === "localhost" || hostname === "0.0.0.0" || hostname === "::" || hostname === "[::]" || hostname === "::1" || hostname === "[::1]" || /^127(?:\.\d{1,3}){0,3}$/.test(hostname);
|
|
381
|
+
}
|
|
365
382
|
|
|
366
383
|
// src/registry/log.ts
|
|
367
384
|
function logger2() {
|
|
@@ -821,6 +838,18 @@ var RegistryConfigSchema = z3.object({
|
|
|
821
838
|
* Starts the full Rust engine process locally.
|
|
822
839
|
*/
|
|
823
840
|
startEngine: z3.boolean().default(() => getRivetRunEngine()),
|
|
841
|
+
/**
|
|
842
|
+
* @experimental
|
|
843
|
+
*
|
|
844
|
+
* Host to bind the spawned local engine process to.
|
|
845
|
+
*/
|
|
846
|
+
engineHost: z3.string().optional().default(() => getRivetRunEngineHost() ?? ENGINE_HOST),
|
|
847
|
+
/**
|
|
848
|
+
* @experimental
|
|
849
|
+
*
|
|
850
|
+
* Port to bind the spawned local engine process to.
|
|
851
|
+
*/
|
|
852
|
+
enginePort: z3.number().int().min(1).max(65535).optional().default(() => getRivetRunEnginePort() ?? ENGINE_PORT),
|
|
824
853
|
/** @experimental */
|
|
825
854
|
engineVersion: z3.string().optional().default(() => getRivetRunEngineVersion() ?? VERSION),
|
|
826
855
|
/**
|
|
@@ -853,12 +882,12 @@ var RegistryConfigSchema = z3.object({
|
|
|
853
882
|
shutdown: z3.object({
|
|
854
883
|
/**
|
|
855
884
|
* Wait this many milliseconds for the serve promise to resolve
|
|
856
|
-
* after calling `CoreRegistry::shutdown()`. Defaults to
|
|
857
|
-
*
|
|
885
|
+
* after calling `CoreRegistry::shutdown()`. Defaults to the
|
|
886
|
+
* engine-provided actor stop threshold once the envoy connects.
|
|
858
887
|
*
|
|
859
888
|
* Must be long enough for rivetkit-core to drain the envoy.
|
|
860
889
|
*/
|
|
861
|
-
gracePeriodMs: z3.number().int().min(1e3).optional()
|
|
890
|
+
gracePeriodMs: z3.number().int().min(1e3).optional(),
|
|
862
891
|
/**
|
|
863
892
|
* If true, rivetkit will not install SIGINT/SIGTERM handlers.
|
|
864
893
|
* Use when the host application owns signal policy and will
|
|
@@ -866,7 +895,6 @@ var RegistryConfigSchema = z3.object({
|
|
|
866
895
|
*/
|
|
867
896
|
disableSignalHandlers: z3.boolean().optional().default(false)
|
|
868
897
|
}).optional().default(() => ({
|
|
869
|
-
gracePeriodMs: 3e4,
|
|
870
898
|
disableSignalHandlers: false
|
|
871
899
|
}))
|
|
872
900
|
}).transform((config, ctx) => {
|
|
@@ -899,7 +927,11 @@ var RegistryConfigSchema = z3.object({
|
|
|
899
927
|
message: "configurePool requires either endpoint or startEngine"
|
|
900
928
|
});
|
|
901
929
|
}
|
|
902
|
-
const
|
|
930
|
+
const localEngineEndpoint = buildEngineEndpoint(
|
|
931
|
+
config.engineHost,
|
|
932
|
+
config.enginePort
|
|
933
|
+
);
|
|
934
|
+
const endpoint = config.startEngine ? localEngineEndpoint : (parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint) ?? (isDevEnv ? buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT) : void 0);
|
|
903
935
|
const validateServerlessEndpoint = Boolean(
|
|
904
936
|
config.startEngine || parsedEndpoint
|
|
905
937
|
);
|
|
@@ -916,7 +948,7 @@ var RegistryConfigSchema = z3.object({
|
|
|
916
948
|
path: ["serverless", "publicEndpoint"]
|
|
917
949
|
});
|
|
918
950
|
}
|
|
919
|
-
const publicEndpoint = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint) ?? (isDevEnv && config.startEngine ?
|
|
951
|
+
const publicEndpoint = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint) ?? (isDevEnv && config.startEngine ? endpoint : void 0);
|
|
920
952
|
const publicNamespace = parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.namespace;
|
|
921
953
|
const publicToken = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.token) ?? config.serverless.publicToken;
|
|
922
954
|
return {
|
|
@@ -1578,6 +1610,9 @@ var NapiCoreRuntime = class {
|
|
|
1578
1610
|
async actorWaitForTrackedShutdownWork(ctx) {
|
|
1579
1611
|
return await asNativeActorContext(ctx).waitForTrackedShutdownWork();
|
|
1580
1612
|
}
|
|
1613
|
+
async actorWaitForTrackedShutdownWorkUnbounded(ctx) {
|
|
1614
|
+
await asNativeActorContext(ctx).waitForTrackedShutdownWorkUnbounded();
|
|
1615
|
+
}
|
|
1581
1616
|
actorKeepAwake(ctx, promise) {
|
|
1582
1617
|
asNativeActorContext(ctx).keepAwake(promise);
|
|
1583
1618
|
}
|
|
@@ -2163,6 +2198,12 @@ var WasmCoreRuntime = class {
|
|
|
2163
2198
|
"waitForTrackedShutdownWork"
|
|
2164
2199
|
);
|
|
2165
2200
|
}
|
|
2201
|
+
async actorWaitForTrackedShutdownWorkUnbounded(ctx) {
|
|
2202
|
+
await callHandle(
|
|
2203
|
+
asWasmActorContext(ctx),
|
|
2204
|
+
"waitForTrackedShutdownWorkUnbounded"
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2166
2207
|
actorKeepAwake(ctx, promise) {
|
|
2167
2208
|
const wasmCtx = asWasmActorContext(ctx);
|
|
2168
2209
|
const regionId = callHandle(wasmCtx, "beginKeepAwake");
|
|
@@ -2312,7 +2353,13 @@ var WasmCoreRuntime = class {
|
|
|
2312
2353
|
}
|
|
2313
2354
|
async actorQueueWaitForNamesAvailable(ctx, names, options, signal) {
|
|
2314
2355
|
const queue2 = childHandle(asWasmActorContext(ctx), "queue");
|
|
2315
|
-
await callHandleAsync(
|
|
2356
|
+
await callHandleAsync(
|
|
2357
|
+
queue2,
|
|
2358
|
+
"waitForNamesAvailable",
|
|
2359
|
+
names,
|
|
2360
|
+
options,
|
|
2361
|
+
signal
|
|
2362
|
+
);
|
|
2316
2363
|
}
|
|
2317
2364
|
async actorQueueEnqueueAndWait(ctx, name, body, options, signal) {
|
|
2318
2365
|
const queue2 = childHandle(asWasmActorContext(ctx), "queue");
|
|
@@ -2404,6 +2451,10 @@ async function loadWasmRuntime(config) {
|
|
|
2404
2451
|
};
|
|
2405
2452
|
}
|
|
2406
2453
|
|
|
2454
|
+
// src/registry/native.ts
|
|
2455
|
+
import nodeFs from "fs";
|
|
2456
|
+
import nodePath from "path";
|
|
2457
|
+
|
|
2407
2458
|
// src/registry/write-through-proxy.ts
|
|
2408
2459
|
import onChange from "@rivetkit/on-change";
|
|
2409
2460
|
function createWriteThroughProxy(value, commit, beforeChange) {
|
|
@@ -2639,8 +2690,23 @@ function resolveNativeDestroy(runtime, ctx) {
|
|
|
2639
2690
|
function clearNativeRuntimeState(runtime, ctx) {
|
|
2640
2691
|
callNativeSync(() => runtime.actorClearRuntimeState(ctx));
|
|
2641
2692
|
}
|
|
2642
|
-
async function cleanupNativeSleepRuntimeState(runtime, ctx) {
|
|
2643
|
-
await runtime.actorWaitForTrackedShutdownWork(ctx);
|
|
2693
|
+
async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrained) {
|
|
2694
|
+
const drained = await runtime.actorWaitForTrackedShutdownWork(ctx);
|
|
2695
|
+
if (!drained) {
|
|
2696
|
+
await closeNativeDatabaseClient(runtime, ctx);
|
|
2697
|
+
await closeNativeSqlDatabase(runtime, ctx);
|
|
2698
|
+
void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
|
|
2699
|
+
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
2700
|
+
clearNativeRuntimeState(runtime, ctx);
|
|
2701
|
+
}).catch((error) => {
|
|
2702
|
+
logger2().warn({
|
|
2703
|
+
msg: "deferred native sleep cleanup failed",
|
|
2704
|
+
error: stringifyError(error)
|
|
2705
|
+
});
|
|
2706
|
+
});
|
|
2707
|
+
return;
|
|
2708
|
+
}
|
|
2709
|
+
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
2644
2710
|
await closeNativeDatabaseClient(runtime, ctx);
|
|
2645
2711
|
await closeNativeSqlDatabase(runtime, ctx);
|
|
2646
2712
|
clearNativeRuntimeState(runtime, ctx);
|
|
@@ -2750,6 +2816,9 @@ function decodeValue(value) {
|
|
|
2750
2816
|
function encodeValue(value) {
|
|
2751
2817
|
return encodeCborCompat(value);
|
|
2752
2818
|
}
|
|
2819
|
+
function normalizeArgs(value) {
|
|
2820
|
+
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
2821
|
+
}
|
|
2753
2822
|
function unwrapTsfnPayload(error, payload) {
|
|
2754
2823
|
if (error !== null && error !== void 0) {
|
|
2755
2824
|
throw error;
|
|
@@ -3012,7 +3081,7 @@ function wrapNativeCallback(callback) {
|
|
|
3012
3081
|
}
|
|
3013
3082
|
function decodeArgs(value) {
|
|
3014
3083
|
const decoded = decodeValue(value);
|
|
3015
|
-
return
|
|
3084
|
+
return normalizeArgs(decoded);
|
|
3016
3085
|
}
|
|
3017
3086
|
function buildRequest(init) {
|
|
3018
3087
|
const url = init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString();
|
|
@@ -4384,6 +4453,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4384
4453
|
return false;
|
|
4385
4454
|
}
|
|
4386
4455
|
sleep() {
|
|
4456
|
+
this.#flushStateChange();
|
|
4387
4457
|
callNativeSync(() => this.#runtime.actorSleep(this.#ctx));
|
|
4388
4458
|
}
|
|
4389
4459
|
destroy() {
|
|
@@ -4673,9 +4743,62 @@ function buildActorConfig(definition, registryConfig) {
|
|
|
4673
4743
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
4674
4744
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
4675
4745
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
4676
|
-
actions: Object.keys(config.actions ?? {}).sort().map((name) => ({ name }))
|
|
4746
|
+
actions: Object.keys(config.actions ?? {}).sort().map((name) => ({ name })),
|
|
4747
|
+
inspectorTabs: buildInspectorTabs(config.inspector)
|
|
4677
4748
|
};
|
|
4678
4749
|
}
|
|
4750
|
+
function buildInspectorTabs(inspector) {
|
|
4751
|
+
if (!inspector || typeof inspector !== "object") return void 0;
|
|
4752
|
+
const tabs = inspector.tabs;
|
|
4753
|
+
if (!Array.isArray(tabs) || tabs.length === 0) return void 0;
|
|
4754
|
+
return tabs.map((raw) => {
|
|
4755
|
+
const entry = raw;
|
|
4756
|
+
if (entry.hidden === true) {
|
|
4757
|
+
return { id: entry.id, hidden: true };
|
|
4758
|
+
}
|
|
4759
|
+
const resolved = entry.source !== void 0 ? nodePath.resolve(entry.source) : void 0;
|
|
4760
|
+
if (resolved !== void 0) {
|
|
4761
|
+
validateInspectorTabSource(entry.id, resolved);
|
|
4762
|
+
}
|
|
4763
|
+
return {
|
|
4764
|
+
id: entry.id,
|
|
4765
|
+
label: entry.label,
|
|
4766
|
+
icon: entry.icon,
|
|
4767
|
+
source: resolved
|
|
4768
|
+
};
|
|
4769
|
+
});
|
|
4770
|
+
}
|
|
4771
|
+
function validateInspectorTabSource(tabId, resolved) {
|
|
4772
|
+
if (resolved === nodePath.parse(resolved).root) {
|
|
4773
|
+
throw new Error(
|
|
4774
|
+
`inspector.tabs[id="${tabId}"].source resolves to the filesystem root (${resolved}). Point it at the tab's own static-asset directory instead.`
|
|
4775
|
+
);
|
|
4776
|
+
}
|
|
4777
|
+
let stat;
|
|
4778
|
+
try {
|
|
4779
|
+
stat = nodeFs.statSync(resolved);
|
|
4780
|
+
} catch (err) {
|
|
4781
|
+
const code = err == null ? void 0 : err.code;
|
|
4782
|
+
if (code === "ENOENT") {
|
|
4783
|
+
throw new Error(
|
|
4784
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) does not exist.`
|
|
4785
|
+
);
|
|
4786
|
+
}
|
|
4787
|
+
if (code === "EACCES") {
|
|
4788
|
+
throw new Error(
|
|
4789
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) is not readable (EACCES).`
|
|
4790
|
+
);
|
|
4791
|
+
}
|
|
4792
|
+
throw new Error(
|
|
4793
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) could not be stat'd: ${(err == null ? void 0 : err.message) ?? err}`
|
|
4794
|
+
);
|
|
4795
|
+
}
|
|
4796
|
+
if (!stat.isDirectory()) {
|
|
4797
|
+
throw new Error(
|
|
4798
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) must be a directory, got ${stat.isFile() ? "file" : "non-directory"}.`
|
|
4799
|
+
);
|
|
4800
|
+
}
|
|
4801
|
+
}
|
|
4679
4802
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
4680
4803
|
var _a;
|
|
4681
4804
|
const config = definition.config;
|
|
@@ -5008,13 +5131,26 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5008
5131
|
);
|
|
5009
5132
|
}
|
|
5010
5133
|
const body = await jsRequest.json();
|
|
5134
|
+
if (body.args !== void 0 && body.properties !== void 0) {
|
|
5135
|
+
return jsonResponse(
|
|
5136
|
+
{ error: "use either args or properties, not both" },
|
|
5137
|
+
{ status: 400 }
|
|
5138
|
+
);
|
|
5139
|
+
}
|
|
5140
|
+
if (body.properties !== void 0 && (body.properties === null || typeof body.properties !== "object" || Array.isArray(body.properties))) {
|
|
5141
|
+
return jsonResponse(
|
|
5142
|
+
{ error: "properties must be an object" },
|
|
5143
|
+
{ status: 400 }
|
|
5144
|
+
);
|
|
5145
|
+
}
|
|
5146
|
+
const args = body.properties !== void 0 ? [body.properties] : normalizeArgs(body.args);
|
|
5011
5147
|
try {
|
|
5012
5148
|
const output = await action(
|
|
5013
5149
|
actorCtx,
|
|
5014
5150
|
...validateActionArgs(
|
|
5015
5151
|
schemaConfig.actionInputSchemas,
|
|
5016
5152
|
actionName,
|
|
5017
|
-
|
|
5153
|
+
args
|
|
5018
5154
|
)
|
|
5019
5155
|
);
|
|
5020
5156
|
return jsonResponse({ output });
|
|
@@ -5162,24 +5298,30 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5162
5298
|
async (error, payload) => {
|
|
5163
5299
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
5164
5300
|
const actorCtx = makeActorCtx(ctx);
|
|
5301
|
+
const saveActorState = async () => {
|
|
5302
|
+
if (runtime.kind === "wasm") {
|
|
5303
|
+
await runtime.actorSaveState(
|
|
5304
|
+
ctx,
|
|
5305
|
+
actorCtx.serializeForTick("save")
|
|
5306
|
+
);
|
|
5307
|
+
} else {
|
|
5308
|
+
await actorCtx.saveState({
|
|
5309
|
+
immediate: true
|
|
5310
|
+
});
|
|
5311
|
+
}
|
|
5312
|
+
};
|
|
5165
5313
|
try {
|
|
5166
5314
|
if (onSleep) {
|
|
5167
|
-
|
|
5168
|
-
await onSleep(actorCtx);
|
|
5169
|
-
} finally {
|
|
5170
|
-
if (runtime.kind === "wasm") {
|
|
5171
|
-
await runtime.actorSaveState(
|
|
5172
|
-
ctx,
|
|
5173
|
-
actorCtx.serializeForTick("save")
|
|
5174
|
-
);
|
|
5175
|
-
} else {
|
|
5176
|
-
await actorCtx.saveState({ immediate: true });
|
|
5177
|
-
}
|
|
5178
|
-
}
|
|
5315
|
+
await onSleep(actorCtx);
|
|
5179
5316
|
}
|
|
5317
|
+
await saveActorState();
|
|
5180
5318
|
} finally {
|
|
5181
5319
|
try {
|
|
5182
|
-
await cleanupNativeSleepRuntimeState(
|
|
5320
|
+
await cleanupNativeSleepRuntimeState(
|
|
5321
|
+
runtime,
|
|
5322
|
+
ctx,
|
|
5323
|
+
saveActorState
|
|
5324
|
+
);
|
|
5183
5325
|
} finally {
|
|
5184
5326
|
await actorCtx.dispose();
|
|
5185
5327
|
}
|
|
@@ -5627,6 +5769,8 @@ async function buildServeConfig(config) {
|
|
|
5627
5769
|
if (config.startEngine) {
|
|
5628
5770
|
const { getEnginePath } = await loadEngineCli();
|
|
5629
5771
|
serveConfig.engineBinaryPath = getEnginePath();
|
|
5772
|
+
serveConfig.engineHost = config.engineHost;
|
|
5773
|
+
serveConfig.enginePort = config.enginePort;
|
|
5630
5774
|
}
|
|
5631
5775
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
5632
5776
|
serveConfig.inspectorTestToken = getEnvUniversal("_RIVET_TEST_INSPECTOR_TOKEN") ?? "token";
|
|
@@ -5661,8 +5805,23 @@ async function buildConfiguredRegistry(config) {
|
|
|
5661
5805
|
}
|
|
5662
5806
|
|
|
5663
5807
|
// src/registry/index.ts
|
|
5808
|
+
function signalExitCode(signal) {
|
|
5809
|
+
switch (signal) {
|
|
5810
|
+
case "SIGINT":
|
|
5811
|
+
return 130;
|
|
5812
|
+
case "SIGTERM":
|
|
5813
|
+
return 143;
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
function finishShutdownSignal(signal) {
|
|
5817
|
+
if (process.pid === 1) {
|
|
5818
|
+
process.exit(signalExitCode(signal));
|
|
5819
|
+
}
|
|
5820
|
+
process.kill(process.pid, signal);
|
|
5821
|
+
}
|
|
5664
5822
|
var Registry = class {
|
|
5665
5823
|
#config;
|
|
5824
|
+
#buildConfiguredRegistry;
|
|
5666
5825
|
routes;
|
|
5667
5826
|
get config() {
|
|
5668
5827
|
return this.#config;
|
|
@@ -5678,8 +5837,9 @@ var Registry = class {
|
|
|
5678
5837
|
#shutdownInstalled = false;
|
|
5679
5838
|
#shutdownInFlight = null;
|
|
5680
5839
|
#signalHandlers = {};
|
|
5681
|
-
constructor(config) {
|
|
5840
|
+
constructor(config, deps) {
|
|
5682
5841
|
this.#config = config;
|
|
5842
|
+
this.#buildConfiguredRegistry = (deps == null ? void 0 : deps.buildConfiguredRegistry) ?? buildConfiguredRegistry;
|
|
5683
5843
|
this.routes = {
|
|
5684
5844
|
health: () => this.#healthRoute(),
|
|
5685
5845
|
metadata: () => this.#metadataRoute(),
|
|
@@ -5715,7 +5875,7 @@ var Registry = class {
|
|
|
5715
5875
|
const config = this.parseConfig();
|
|
5716
5876
|
this.#printWelcome(config, "serverless");
|
|
5717
5877
|
if (!this.#runtimeServerlessPromise) {
|
|
5718
|
-
this.#runtimeServerlessPromise = buildConfiguredRegistry(config);
|
|
5878
|
+
this.#runtimeServerlessPromise = this.#buildConfiguredRegistry(config);
|
|
5719
5879
|
}
|
|
5720
5880
|
const { runtime, registry, serveConfig } = await this.#runtimeServerlessPromise;
|
|
5721
5881
|
const isStartRequest = isServerlessStartRequest(
|
|
@@ -5993,20 +6153,20 @@ var Registry = class {
|
|
|
5993
6153
|
*/
|
|
5994
6154
|
#startEnvoy(config, printWelcome) {
|
|
5995
6155
|
if (!this.#runtimeServePromise) {
|
|
5996
|
-
const configuredRegistryPromise = buildConfiguredRegistry(config);
|
|
6156
|
+
const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
|
|
5997
6157
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
5998
6158
|
this.#runtimeServePromise = configuredRegistryPromise.then(async ({ runtime, registry, serveConfig }) => {
|
|
5999
6159
|
await runtime.serveRegistry(registry, serveConfig);
|
|
6000
6160
|
}).catch((error) => {
|
|
6001
6161
|
logger2().warn({ error }, "runtime registry serve errored");
|
|
6002
6162
|
});
|
|
6003
|
-
this.#installSignalHandlers(config
|
|
6163
|
+
this.#installSignalHandlers(config);
|
|
6004
6164
|
}
|
|
6005
6165
|
if (printWelcome) {
|
|
6006
6166
|
this.#printWelcome(config, "serverful");
|
|
6007
6167
|
}
|
|
6008
6168
|
}
|
|
6009
|
-
#installSignalHandlers(config
|
|
6169
|
+
#installSignalHandlers(config) {
|
|
6010
6170
|
var _a;
|
|
6011
6171
|
if (this.#shutdownInstalled) return;
|
|
6012
6172
|
if ((_a = config.shutdown) == null ? void 0 : _a.disableSignalHandlers) return;
|
|
@@ -6015,54 +6175,82 @@ var Registry = class {
|
|
|
6015
6175
|
}
|
|
6016
6176
|
this.#shutdownInstalled = true;
|
|
6017
6177
|
const install = (signal) => {
|
|
6018
|
-
const handler = () => this.#onShutdownSignal(
|
|
6019
|
-
signal,
|
|
6020
|
-
config,
|
|
6021
|
-
configuredRegistryPromise
|
|
6022
|
-
);
|
|
6178
|
+
const handler = () => this.#onShutdownSignal(signal, config);
|
|
6023
6179
|
this.#signalHandlers[signal] = handler;
|
|
6024
6180
|
process.on(signal, handler);
|
|
6025
6181
|
};
|
|
6026
6182
|
install("SIGINT");
|
|
6027
6183
|
install("SIGTERM");
|
|
6028
6184
|
}
|
|
6029
|
-
#onShutdownSignal(signal, config
|
|
6185
|
+
#onShutdownSignal(signal, config) {
|
|
6030
6186
|
if (this.#shutdownInFlight !== null) {
|
|
6031
6187
|
this.#removeSignalHandlers();
|
|
6032
|
-
|
|
6188
|
+
finishShutdownSignal(signal);
|
|
6033
6189
|
return;
|
|
6034
6190
|
}
|
|
6035
|
-
this.#shutdownInFlight = this.#
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6191
|
+
this.#shutdownInFlight = this.#drain(config).catch((err) => {
|
|
6192
|
+
logger2().warn({ err }, "shutdown error");
|
|
6193
|
+
}).then(() => {
|
|
6194
|
+
this.#removeSignalHandlers();
|
|
6195
|
+
finishShutdownSignal(signal);
|
|
6196
|
+
});
|
|
6197
|
+
}
|
|
6198
|
+
/**
|
|
6199
|
+
* Gracefully drains all live registries.
|
|
6200
|
+
*
|
|
6201
|
+
* Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
|
|
6202
|
+
* every live `CoreRegistry` (both `start()` and `handler()` modes) and
|
|
6203
|
+
* waits for the serve promise to resolve, all bounded by the shutdown
|
|
6204
|
+
* grace period. Unlike a signal-driven shutdown, this does not re-raise a
|
|
6205
|
+
* signal or exit the process. The caller owns process lifetime.
|
|
6206
|
+
*
|
|
6207
|
+
* Idempotent: concurrent or repeated calls share a single drain. Safe to
|
|
6208
|
+
* call even if nothing has been started.
|
|
6209
|
+
*
|
|
6210
|
+
* @example
|
|
6211
|
+
* ```ts
|
|
6212
|
+
* const registry = setup({ use: { counter } });
|
|
6213
|
+
* registry.start();
|
|
6214
|
+
* // ...later, on your own shutdown trigger:
|
|
6215
|
+
* await registry.shutdown();
|
|
6216
|
+
* ```
|
|
6217
|
+
*/
|
|
6218
|
+
async shutdown() {
|
|
6219
|
+
if (this.#shutdownInFlight !== null) return this.#shutdownInFlight;
|
|
6220
|
+
const config = this.parseConfig();
|
|
6221
|
+
this.#removeSignalHandlers();
|
|
6222
|
+
this.#shutdownInFlight = this.#drain(config).catch((err) => {
|
|
6223
|
+
logger2().warn({ err }, "shutdown error");
|
|
6041
6224
|
});
|
|
6225
|
+
return this.#shutdownInFlight;
|
|
6042
6226
|
}
|
|
6043
|
-
async #
|
|
6227
|
+
async #drain(config) {
|
|
6044
6228
|
var _a;
|
|
6045
|
-
const
|
|
6229
|
+
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
6230
|
+
const modeBPromise = this.#runtimeServerlessPromise;
|
|
6231
|
+
const gracePeriodMs = ((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs) ?? await this.#actorStopThresholdMs(modeAPromise ?? modeBPromise) ?? 30 * 60 * 1e3;
|
|
6046
6232
|
const drain = async () => {
|
|
6047
|
-
const registries = [
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6233
|
+
const registries = [];
|
|
6234
|
+
if (modeAPromise !== void 0) {
|
|
6235
|
+
registries.push(
|
|
6236
|
+
(async () => {
|
|
6237
|
+
try {
|
|
6238
|
+
const { runtime, registry } = await modeAPromise;
|
|
6239
|
+
await runtime.shutdownRegistry(registry);
|
|
6240
|
+
} catch (err) {
|
|
6241
|
+
logger2().warn(
|
|
6242
|
+
{ err },
|
|
6243
|
+
"runtime registry shutdown errored (mode A)"
|
|
6244
|
+
);
|
|
6245
|
+
}
|
|
6246
|
+
})()
|
|
6247
|
+
);
|
|
6248
|
+
}
|
|
6249
|
+
if (modeBPromise !== void 0) {
|
|
6062
6250
|
registries.push(
|
|
6063
6251
|
(async () => {
|
|
6064
6252
|
try {
|
|
6065
|
-
const { runtime, registry } = await
|
|
6253
|
+
const { runtime, registry } = await modeBPromise;
|
|
6066
6254
|
await runtime.shutdownRegistry(registry);
|
|
6067
6255
|
} catch (err) {
|
|
6068
6256
|
logger2().warn(
|
|
@@ -6088,8 +6276,23 @@ var Registry = class {
|
|
|
6088
6276
|
}
|
|
6089
6277
|
)
|
|
6090
6278
|
]);
|
|
6091
|
-
|
|
6092
|
-
|
|
6279
|
+
}
|
|
6280
|
+
async #actorStopThresholdMs(configuredRegistryPromise) {
|
|
6281
|
+
var _a;
|
|
6282
|
+
if (configuredRegistryPromise === void 0) return void 0;
|
|
6283
|
+
try {
|
|
6284
|
+
const { runtime, registry } = await configuredRegistryPromise;
|
|
6285
|
+
const thresholdMs = await ((_a = runtime.registryActorStopThresholdMs) == null ? void 0 : _a.call(runtime, registry));
|
|
6286
|
+
if (thresholdMs !== void 0 && Number.isFinite(thresholdMs) && thresholdMs > 0) {
|
|
6287
|
+
return thresholdMs;
|
|
6288
|
+
}
|
|
6289
|
+
} catch (err) {
|
|
6290
|
+
logger2().warn(
|
|
6291
|
+
{ err },
|
|
6292
|
+
"failed to read actor stop threshold for shutdown grace"
|
|
6293
|
+
);
|
|
6294
|
+
}
|
|
6295
|
+
return void 0;
|
|
6093
6296
|
}
|
|
6094
6297
|
#removeSignalHandlers() {
|
|
6095
6298
|
for (const [signal, handler] of Object.entries(
|
|
@@ -6130,7 +6333,7 @@ var Registry = class {
|
|
|
6130
6333
|
logLine("Namespace", config.namespace);
|
|
6131
6334
|
}
|
|
6132
6335
|
if (config.endpoint) {
|
|
6133
|
-
const endpointType = config.
|
|
6336
|
+
const endpointType = config.startEngine || isLocalEngineEndpoint(config.endpoint) ? "local native" : "remote";
|
|
6134
6337
|
logLine("Endpoint", `${config.endpoint} (${endpointType})`);
|
|
6135
6338
|
}
|
|
6136
6339
|
if (kind === "serverless" && config.publicEndpoint) {
|