rivetkit 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/browser/client.d.ts +69 -7
  2. package/dist/browser/client.js +1 -1
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-2JSFY7XD.js → chunk-6XKZ4JI7.js} +2 -2
  7. package/dist/tsup/{chunk-3PFAODLE.cjs → chunk-7UGPT7WZ.cjs} +3 -3
  8. package/dist/tsup/{chunk-3PFAODLE.cjs.map → chunk-7UGPT7WZ.cjs.map} +1 -1
  9. package/dist/tsup/{chunk-4VEJIK7O.cjs → chunk-DQTCLK7I.cjs} +3 -3
  10. package/dist/tsup/{chunk-4VEJIK7O.cjs.map → chunk-DQTCLK7I.cjs.map} +1 -1
  11. package/dist/tsup/{chunk-NSQWB4QD.cjs → chunk-I4WHG6X3.cjs} +3 -3
  12. package/dist/tsup/{chunk-NSQWB4QD.cjs.map → chunk-I4WHG6X3.cjs.map} +1 -1
  13. package/dist/tsup/{chunk-57I7SSSV.js → chunk-IFIAM2WX.js} +4 -4
  14. package/dist/tsup/{chunk-JOCSSMLU.js → chunk-JEQKU2GS.js} +3 -3
  15. package/dist/tsup/{chunk-B5WDVY32.js → chunk-JHPMLQHW.js} +2 -2
  16. package/dist/tsup/{chunk-B5WDVY32.js.map → chunk-JHPMLQHW.js.map} +1 -1
  17. package/dist/tsup/{chunk-7K6MC544.js → chunk-KA2HY475.js} +2 -2
  18. package/dist/tsup/{chunk-PLZVADML.js → chunk-KXQU67B5.js} +2 -2
  19. package/dist/tsup/{chunk-QX7DWU46.js → chunk-MD5JLJL3.js} +2 -2
  20. package/dist/tsup/{chunk-N7V3BQUB.cjs → chunk-NEI2VMRH.cjs} +10 -10
  21. package/dist/tsup/{chunk-N7V3BQUB.cjs.map → chunk-NEI2VMRH.cjs.map} +1 -1
  22. package/dist/tsup/{chunk-LXSYHJ7E.cjs → chunk-PPEFSNNR.cjs} +4 -4
  23. package/dist/tsup/{chunk-LXSYHJ7E.cjs.map → chunk-PPEFSNNR.cjs.map} +1 -1
  24. package/dist/tsup/{chunk-B3MXZSPO.cjs → chunk-RZHBGWOL.cjs} +143 -143
  25. package/dist/tsup/{chunk-B3MXZSPO.cjs.map → chunk-RZHBGWOL.cjs.map} +1 -1
  26. package/dist/tsup/{chunk-QI7E2UH5.cjs → chunk-SUU72UBE.cjs} +2 -2
  27. package/dist/tsup/{chunk-QI7E2UH5.cjs.map → chunk-SUU72UBE.cjs.map} +1 -1
  28. package/dist/tsup/{chunk-HQ5JCCK6.cjs → chunk-UBEFOC6D.cjs} +7 -7
  29. package/dist/tsup/{chunk-HQ5JCCK6.cjs.map → chunk-UBEFOC6D.cjs.map} +1 -1
  30. package/dist/tsup/{chunk-BOVQ3JQK.js → chunk-XLQCNXZ6.js} +3 -3
  31. package/dist/tsup/client/mod.cjs +5 -5
  32. package/dist/tsup/client/mod.d.cts +3 -3
  33. package/dist/tsup/client/mod.d.ts +3 -3
  34. package/dist/tsup/client/mod.js +4 -4
  35. package/dist/tsup/common/log.cjs +2 -2
  36. package/dist/tsup/common/log.js +1 -1
  37. package/dist/tsup/common/websocket.cjs +3 -3
  38. package/dist/tsup/common/websocket.js +2 -2
  39. package/dist/tsup/{config-XfKwGYxx.d.ts → config-BtUHYdoj.d.ts} +21 -1
  40. package/dist/tsup/{config-B2wlj9wx.d.ts → config-CBTr4IhE.d.cts} +50 -8
  41. package/dist/tsup/{config-B2wlj9wx.d.cts → config-CBTr4IhE.d.ts} +50 -8
  42. package/dist/tsup/{config-K9uOKlok.d.cts → config-H6pJy_J1.d.cts} +21 -1
  43. package/dist/tsup/{context-Bm7mA4E3.d.ts → context-DrDoMXSD.d.ts} +2 -2
  44. package/dist/tsup/{context-CPCM-xn6.d.cts → context-TWrKZjqf.d.cts} +2 -2
  45. package/dist/tsup/db/drizzle.cjs +2 -2
  46. package/dist/tsup/db/drizzle.d.cts +1 -1
  47. package/dist/tsup/db/drizzle.d.ts +1 -1
  48. package/dist/tsup/db/drizzle.js +1 -1
  49. package/dist/tsup/db/mod.cjs +3 -3
  50. package/dist/tsup/db/mod.d.cts +2 -2
  51. package/dist/tsup/db/mod.d.ts +2 -2
  52. package/dist/tsup/db/mod.js +2 -2
  53. package/dist/tsup/dynamic/mod.d.cts +2 -2
  54. package/dist/tsup/dynamic/mod.d.ts +2 -2
  55. package/dist/tsup/inspector/mod.cjs +5 -5
  56. package/dist/tsup/inspector/mod.js +4 -4
  57. package/dist/tsup/inspector/workflow.cjs +4 -4
  58. package/dist/tsup/inspector/workflow.js +3 -3
  59. package/dist/tsup/inspector-tab/mod.d.cts +3 -3
  60. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  61. package/dist/tsup/mod.cjs +212 -87
  62. package/dist/tsup/mod.cjs.map +1 -1
  63. package/dist/tsup/mod.d.cts +4 -4
  64. package/dist/tsup/mod.d.ts +4 -4
  65. package/dist/tsup/mod.js +131 -6
  66. package/dist/tsup/mod.js.map +1 -1
  67. package/dist/tsup/test/mod.cjs +6 -6
  68. package/dist/tsup/test/mod.d.cts +2 -2
  69. package/dist/tsup/test/mod.d.ts +2 -2
  70. package/dist/tsup/test/mod.js +4 -4
  71. package/dist/tsup/unstable/migrations.d.cts +1 -1
  72. package/dist/tsup/unstable/migrations.d.ts +1 -1
  73. package/dist/tsup/utils.cjs +2 -2
  74. package/dist/tsup/utils.js +1 -1
  75. package/dist/tsup/workflow/mod.cjs +7 -7
  76. package/dist/tsup/workflow/mod.d.cts +4 -4
  77. package/dist/tsup/workflow/mod.d.ts +4 -4
  78. package/dist/tsup/workflow/mod.js +4 -4
  79. package/package.json +9 -9
  80. package/src/common/database/config.ts +50 -7
  81. package/src/db/mod.ts +1 -0
  82. package/src/registry/index.ts +142 -1
  83. package/src/registry/napi-runtime.ts +15 -0
  84. package/src/registry/runtime.ts +6 -0
  85. /package/dist/tsup/{chunk-2JSFY7XD.js.map → chunk-6XKZ4JI7.js.map} +0 -0
  86. /package/dist/tsup/{chunk-57I7SSSV.js.map → chunk-IFIAM2WX.js.map} +0 -0
  87. /package/dist/tsup/{chunk-JOCSSMLU.js.map → chunk-JEQKU2GS.js.map} +0 -0
  88. /package/dist/tsup/{chunk-7K6MC544.js.map → chunk-KA2HY475.js.map} +0 -0
  89. /package/dist/tsup/{chunk-PLZVADML.js.map → chunk-KXQU67B5.js.map} +0 -0
  90. /package/dist/tsup/{chunk-QX7DWU46.js.map → chunk-MD5JLJL3.js.map} +0 -0
  91. /package/dist/tsup/{chunk-BOVQ3JQK.js.map → chunk-XLQCNXZ6.js.map} +0 -0
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkHQ5JCCK6cjs = require('../chunk-HQ5JCCK6.cjs');
3
+ var _chunkUBEFOC6Dcjs = require('../chunk-UBEFOC6D.cjs');
4
4
 
5
5
 
6
- var _chunkB3MXZSPOcjs = require('../chunk-B3MXZSPO.cjs');
6
+ var _chunkRZHBGWOLcjs = require('../chunk-RZHBGWOL.cjs');
7
7
  require('../chunk-RTWH3AX3.cjs');
8
8
  require('../chunk-KVFIONKQ.cjs');
9
- require('../chunk-4VEJIK7O.cjs');
10
- require('../chunk-QI7E2UH5.cjs');
9
+ require('../chunk-DQTCLK7I.cjs');
10
+ require('../chunk-SUU72UBE.cjs');
11
11
  require('../chunk-MGI2VVF6.cjs');
12
12
 
13
13
  // src/test/ready.ts
@@ -36,8 +36,8 @@ async function setupTest(c, registry) {
36
36
  registry.config.noWelcome = true;
37
37
  registry.start();
38
38
  await waitForRegistryReady(registry);
39
- const client = _chunkHQ5JCCK6cjs.createClient.call(void 0, {
40
- ..._chunkB3MXZSPOcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
39
+ const client = _chunkUBEFOC6Dcjs.createClient.call(void 0, {
40
+ ..._chunkRZHBGWOLcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
41
41
  disableMetadataLookup: false
42
42
  });
43
43
  c.onTestFinished(async () => {
@@ -1,7 +1,7 @@
1
1
  import { TestContext } from 'vitest';
2
- import { aI as Registry, a6 as Client } from '../config-K9uOKlok.cjs';
2
+ import { aI as Registry, a6 as Client } from '../config-H6pJy_J1.cjs';
3
3
  import 'zod/v4';
4
- import '../config-B2wlj9wx.cjs';
4
+ import '../config-CBTr4IhE.cjs';
5
5
  import '@rivetkit/rivetkit-wasm';
6
6
  import 'zod';
7
7
  import 'pino';
@@ -1,7 +1,7 @@
1
1
  import { TestContext } from 'vitest';
2
- import { aI as Registry, a6 as Client } from '../config-XfKwGYxx.js';
2
+ import { aI as Registry, a6 as Client } from '../config-BtUHYdoj.js';
3
3
  import 'zod/v4';
4
- import '../config-B2wlj9wx.js';
4
+ import '../config-CBTr4IhE.js';
5
5
  import '@rivetkit/rivetkit-wasm';
6
6
  import 'zod';
7
7
  import 'pino';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createClient
3
- } from "../chunk-BOVQ3JQK.js";
3
+ } from "../chunk-XLQCNXZ6.js";
4
4
  import {
5
5
  convertRegistryConfigToClientConfig
6
- } from "../chunk-JOCSSMLU.js";
6
+ } from "../chunk-JEQKU2GS.js";
7
7
  import "../chunk-A2CF6PFH.js";
8
8
  import "../chunk-JTHHCZCZ.js";
9
- import "../chunk-PLZVADML.js";
10
- import "../chunk-B5WDVY32.js";
9
+ import "../chunk-KXQU67B5.js";
10
+ import "../chunk-JHPMLQHW.js";
11
11
  import "../chunk-ZOVJDAOW.js";
12
12
 
13
13
  // src/test/ready.ts
@@ -1,4 +1,4 @@
1
- import { R as RawAccess } from '../config-B2wlj9wx.cjs';
1
+ import { R as RawAccess } from '../config-CBTr4IhE.cjs';
2
2
 
3
3
  declare const DEFAULT_MIGRATION_TABLE_NAME = "rivetkit_schema_version";
4
4
  type MigrationDatabase = Pick<RawAccess, "execute">;
@@ -1,4 +1,4 @@
1
- import { R as RawAccess } from '../config-B2wlj9wx.js';
1
+ import { R as RawAccess } from '../config-CBTr4IhE.js';
2
2
 
3
3
  declare const DEFAULT_MIGRATION_TABLE_NAME = "rivetkit_schema_version";
4
4
  type MigrationDatabase = Pick<RawAccess, "execute">;
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkQI7E2UH5cjs = require('./chunk-QI7E2UH5.cjs');
22
+ var _chunkSUU72UBEcjs = require('./chunk-SUU72UBE.cjs');
23
23
  require('./chunk-MGI2VVF6.cjs');
24
24
 
25
25
 
@@ -42,5 +42,5 @@ require('./chunk-MGI2VVF6.cjs');
42
42
 
43
43
 
44
44
 
45
- exports.EXTRA_ERROR_LOG = _chunkQI7E2UH5cjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkQI7E2UH5cjs.SinglePromiseQueue; exports.VERSION = _chunkQI7E2UH5cjs.VERSION; exports.arrayBuffersEqual = _chunkQI7E2UH5cjs.arrayBuffersEqual; exports.assertUnreachable = _chunkQI7E2UH5cjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkQI7E2UH5cjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkQI7E2UH5cjs.combineUrlPath; exports.dbg = _chunkQI7E2UH5cjs.dbg; exports.detectRuntime = _chunkQI7E2UH5cjs.detectRuntime; exports.getEnvUniversal = _chunkQI7E2UH5cjs.getEnvUniversal; exports.httpUserAgent = _chunkQI7E2UH5cjs.httpUserAgent; exports.interval = _chunkQI7E2UH5cjs.interval; exports.joinSignals = _chunkQI7E2UH5cjs.joinSignals; exports.jsonParseCompat = _chunkQI7E2UH5cjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkQI7E2UH5cjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkQI7E2UH5cjs.promiseWithResolvers; exports.setLongTimeout = _chunkQI7E2UH5cjs.setLongTimeout; exports.sleep = _chunkQI7E2UH5cjs.sleep; exports.stringifyError = _chunkQI7E2UH5cjs.stringifyError; exports.toUint8Array = _chunkQI7E2UH5cjs.toUint8Array;
45
+ exports.EXTRA_ERROR_LOG = _chunkSUU72UBEcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkSUU72UBEcjs.SinglePromiseQueue; exports.VERSION = _chunkSUU72UBEcjs.VERSION; exports.arrayBuffersEqual = _chunkSUU72UBEcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkSUU72UBEcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkSUU72UBEcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkSUU72UBEcjs.combineUrlPath; exports.dbg = _chunkSUU72UBEcjs.dbg; exports.detectRuntime = _chunkSUU72UBEcjs.detectRuntime; exports.getEnvUniversal = _chunkSUU72UBEcjs.getEnvUniversal; exports.httpUserAgent = _chunkSUU72UBEcjs.httpUserAgent; exports.interval = _chunkSUU72UBEcjs.interval; exports.joinSignals = _chunkSUU72UBEcjs.joinSignals; exports.jsonParseCompat = _chunkSUU72UBEcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkSUU72UBEcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkSUU72UBEcjs.promiseWithResolvers; exports.setLongTimeout = _chunkSUU72UBEcjs.setLongTimeout; exports.sleep = _chunkSUU72UBEcjs.sleep; exports.stringifyError = _chunkSUU72UBEcjs.stringifyError; exports.toUint8Array = _chunkSUU72UBEcjs.toUint8Array;
46
46
  //# sourceMappingURL=utils.cjs.map
@@ -19,7 +19,7 @@ import {
19
19
  sleep,
20
20
  stringifyError,
21
21
  toUint8Array
22
- } from "./chunk-B5WDVY32.js";
22
+ } from "./chunk-JHPMLQHW.js";
23
23
  import "./chunk-ZOVJDAOW.js";
24
24
  export {
25
25
  EXTRA_ERROR_LOG,
@@ -1,8 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2;
2
2
 
3
- var _chunkN7V3BQUBcjs = require('../chunk-N7V3BQUB.cjs');
4
- require('../chunk-NSQWB4QD.cjs');
5
- require('../chunk-LXSYHJ7E.cjs');
3
+ var _chunkNEI2VMRHcjs = require('../chunk-NEI2VMRH.cjs');
4
+ require('../chunk-I4WHG6X3.cjs');
5
+ require('../chunk-PPEFSNNR.cjs');
6
6
 
7
7
 
8
8
 
@@ -13,7 +13,7 @@ var _chunkSSF2XC33cjs = require('../chunk-SSF2XC33.cjs');
13
13
  var _chunkRTWH3AX3cjs = require('../chunk-RTWH3AX3.cjs');
14
14
 
15
15
 
16
- var _chunkQI7E2UH5cjs = require('../chunk-QI7E2UH5.cjs');
16
+ var _chunkSUU72UBEcjs = require('../chunk-SUU72UBE.cjs');
17
17
 
18
18
 
19
19
 
@@ -746,7 +746,7 @@ function workflow(fn, options = {}) {
746
746
  function getWorkflowInspector(actorId) {
747
747
  let workflowInspector = workflowInspectors.get(actorId);
748
748
  if (!workflowInspector) {
749
- workflowInspector = _chunkN7V3BQUBcjs.createWorkflowInspectorAdapter.call(void 0, );
749
+ workflowInspector = _chunkNEI2VMRHcjs.createWorkflowInspectorAdapter.call(void 0, );
750
750
  workflowInspectors.set(actorId, workflowInspector);
751
751
  }
752
752
  return workflowInspector;
@@ -819,13 +819,13 @@ function workflow(fn, options = {}) {
819
819
  if (shouldRethrowWorkflowError(error)) {
820
820
  runCtx.log.error({
821
821
  msg: "workflow run failed",
822
- error: _chunkQI7E2UH5cjs.stringifyError.call(void 0, error)
822
+ error: _chunkSUU72UBEcjs.stringifyError.call(void 0, error)
823
823
  });
824
824
  throw error;
825
825
  }
826
826
  runCtx.log.warn({
827
827
  msg: "workflow failed and will sleep until woken",
828
- error: _chunkQI7E2UH5cjs.stringifyError.call(void 0, error)
828
+ error: _chunkSUU72UBEcjs.stringifyError.call(void 0, error)
829
829
  });
830
830
  } finally {
831
831
  runCtx.abortSignal.removeEventListener("abort", onAbort);
@@ -1,9 +1,9 @@
1
1
  import { WorkflowErrorEvent } from '@rivetkit/workflow-engine';
2
2
  export { Loop, TryBlockCatchKind, TryBlockConfig, TryBlockFailure, TryBlockResult, TryStepCatchKind, TryStepConfig, TryStepFailure, TryStepResult, WorkflowError, WorkflowErrorEvent } from '@rivetkit/workflow-engine';
3
- import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-K9uOKlok.cjs';
4
- import { A as AnyDatabaseProvider } from '../config-B2wlj9wx.cjs';
5
- import { d as WorkflowContext } from '../context-CPCM-xn6.cjs';
6
- export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-CPCM-xn6.cjs';
3
+ import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-H6pJy_J1.cjs';
4
+ import { A as AnyDatabaseProvider } from '../config-CBTr4IhE.cjs';
5
+ import { d as WorkflowContext } from '../context-TWrKZjqf.cjs';
6
+ export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-TWrKZjqf.cjs';
7
7
  import 'zod/v4';
8
8
  import '@rivetkit/rivetkit-wasm';
9
9
  import 'zod';
@@ -1,9 +1,9 @@
1
1
  import { WorkflowErrorEvent } from '@rivetkit/workflow-engine';
2
2
  export { Loop, TryBlockCatchKind, TryBlockConfig, TryBlockFailure, TryBlockResult, TryStepCatchKind, TryStepConfig, TryStepFailure, TryStepResult, WorkflowError, WorkflowErrorEvent } from '@rivetkit/workflow-engine';
3
- import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-XfKwGYxx.js';
4
- import { A as AnyDatabaseProvider } from '../config-B2wlj9wx.js';
5
- import { d as WorkflowContext } from '../context-Bm7mA4E3.js';
6
- export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-Bm7mA4E3.js';
3
+ import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-BtUHYdoj.js';
4
+ import { A as AnyDatabaseProvider } from '../config-CBTr4IhE.js';
5
+ import { d as WorkflowContext } from '../context-DrDoMXSD.js';
6
+ export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-DrDoMXSD.js';
7
7
  import 'zod/v4';
8
8
  import '@rivetkit/rivetkit-wasm';
9
9
  import 'zod';
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createWorkflowInspectorAdapter
3
- } from "../chunk-57I7SSSV.js";
4
- import "../chunk-2JSFY7XD.js";
5
- import "../chunk-QX7DWU46.js";
3
+ } from "../chunk-IFIAM2WX.js";
4
+ import "../chunk-6XKZ4JI7.js";
5
+ import "../chunk-MD5JLJL3.js";
6
6
  import {
7
7
  ACTOR_CONTEXT_INTERNAL_SYMBOL,
8
8
  defineRunHandler
@@ -13,7 +13,7 @@ import {
13
13
  } from "../chunk-A2CF6PFH.js";
14
14
  import {
15
15
  stringifyError
16
- } from "../chunk-B5WDVY32.js";
16
+ } from "../chunk-JHPMLQHW.js";
17
17
  import {
18
18
  RivetError,
19
19
  isActorAbortedError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivetkit",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Lightweight libraries for building stateful actors on edge platforms",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -211,15 +211,15 @@
211
211
  "@hono/zod-openapi": "^1.1.5",
212
212
  "@opentelemetry/api": "^1.1.0",
213
213
  "@rivetkit/bare-ts": "^0.6.2",
214
- "@rivetkit/engine-api-full": "3.0.1",
215
- "@rivetkit/engine-cli": "3.0.1",
216
- "@rivetkit/engine-envoy-protocol": "3.0.1",
214
+ "@rivetkit/engine-api-full": "3.0.3",
215
+ "@rivetkit/engine-cli": "3.0.3",
216
+ "@rivetkit/engine-envoy-protocol": "3.0.3",
217
217
  "@rivetkit/on-change": "6.0.1",
218
- "@rivetkit/rivetkit-napi": "3.0.1",
219
- "@rivetkit/rivetkit-wasm": "3.0.1",
220
- "@rivetkit/traces": "3.0.1",
221
- "@rivetkit/virtual-websocket": "3.0.1",
222
- "@rivetkit/workflow-engine": "3.0.1",
218
+ "@rivetkit/rivetkit-napi": "3.0.3",
219
+ "@rivetkit/rivetkit-wasm": "3.0.3",
220
+ "@rivetkit/traces": "3.0.3",
221
+ "@rivetkit/virtual-websocket": "3.0.3",
222
+ "@rivetkit/workflow-engine": "3.0.3",
223
223
  "cbor-x": "^1.6.0",
224
224
  "drizzle-orm": "0.45.2",
225
225
  "hono": "^4.7.0",
@@ -52,13 +52,16 @@ export interface SqliteTransactionOptions {
52
52
  * to change without notice.
53
53
  */
54
54
  export interface SqliteProfilingOptions {
55
- /** Exact SQL statements to give fingerprint labels. Profiling defaults to actor
56
- * aggregates without fingerprint labels. Profile logs remain enabled.
57
- * RIVETKIT_SQLITE_PROFILING overrides selection with a JSON object containing
58
- * queries and/or fingerprints arrays. An empty object clears fingerprint selection. */
59
- queries?: string[];
60
- /** Exact query fingerprints to label separately, as reported in profile logs. */
61
- fingerprints?: string[];
55
+ /** Exact SQL filter. Union with filterQueryFingerprints; both empty means all queries. */
56
+ filterQueries?: string[];
57
+ /** Fingerprint filter, including transaction fingerprints. Filters metrics, not diagnostic logs. */
58
+ filterQueryFingerprints?: string[];
59
+ /** Metric defaults apply even when omitted. Disabled metrics allocate no series. */
60
+ metrics?: SqliteProfilingMetricsOptions;
61
+ /** Duration buckets in seconds. Default [0.01, 0.1, 1]. Positive, finite, strictly increasing.
62
+ * All actors in a process enabling the duration histogram must use identical buckets. */
63
+ durationHistogramBucketsSeconds?: number[];
64
+ /** Maximum distinct statement fingerprints per process. Default: 512. */
62
65
  maxTrackedStatementFingerprints?: number;
63
66
  maxTrackedTransactionFingerprints?: number;
64
67
  maxPrometheusSeries?: number;
@@ -71,6 +74,46 @@ export interface SqliteProfilingOptions {
71
74
  diagnosticEventQueueCapacity?: number;
72
75
  }
73
76
 
77
+ /** SQLite profiling metrics. Physical-request metrics and gauges have no query labels. */
78
+ export interface SqliteProfilingMetricsOptions {
79
+ /** Execution count and cumulative seconds. Uses histogram count/sum when enabled, otherwise counters. Default: true. */
80
+ duration?: boolean;
81
+ /** Execution duration histogram. Only applies when duration is enabled. Default: true. */
82
+ durationHistogram?: boolean;
83
+ /** Outcome counters, including success and errors. Default: true. */
84
+ outcomes?: boolean;
85
+ /** Per-query timing phase histograms. Default: false. */
86
+ phaseDurationHistogram?: boolean;
87
+ /** Storage round trips per operation histogram. Default: false. */
88
+ getPagesRoundTripsHistogram?: boolean;
89
+ /** Statements per transaction histogram. Default: false. */
90
+ transactionStatementCountHistogram?: boolean;
91
+ /** Per-query pages returned from storage, including returned prefetch pages. Default: true. */
92
+ pagesFetched?: boolean;
93
+ /** Actor-level page counters by page kind (no query labels). Default: false. */
94
+ localPages?: boolean;
95
+ /** Actor-level byte counters by byte kind (no query labels). Default: false. */
96
+ localBytes?: boolean;
97
+ /** Actor-level physical storage request duration histogram. Default: false. */
98
+ getPagesDurationHistogram?: boolean;
99
+ /** Actor-level pages per storage request histograms, by page kind. Default: false. */
100
+ getPagesPagesHistogram?: boolean;
101
+ /** Actor-level storage response byte histogram. Default: false. */
102
+ getPagesResponseBytesHistogram?: boolean;
103
+ /** Actor-level missing response page counter. Default: false. */
104
+ getPagesMissingPages?: boolean;
105
+ /** Queued SQLite work, aggregated by actor name. Default: true. */
106
+ workerQueueDepth?: boolean;
107
+ /** Executing SQLite work, aggregated by actor name. Default: true. */
108
+ workerInflight?: boolean;
109
+ /** Transaction waiters, aggregated by actor name. Default: true. */
110
+ coordinatorQueueDepth?: boolean;
111
+ /** Counts observations exceeding fingerprint or series limits. Default: true. */
112
+ fingerprintOverflow?: boolean;
113
+ /** Counts diagnostic events dropped by rate limits or backpressure. Default: true. */
114
+ eventDropped?: boolean;
115
+ }
116
+
74
117
  export interface SqliteNativeMetrics {
75
118
  requestBuildNs: number;
76
119
  serializeNs: number;
package/src/db/mod.ts CHANGED
@@ -10,6 +10,7 @@ export type {
10
10
  SqliteDatabase,
11
11
  SqliteNativeMetrics,
12
12
  SqliteProfilingOptions,
13
+ SqliteProfilingMetricsOptions,
13
14
  SqliteQueryResult,
14
15
  SqliteTransactionOptions,
15
16
  } from "@/common/database/config";
@@ -20,6 +20,7 @@ import { logger } from "./log";
20
20
  import { buildConfiguredRegistry } from "./native";
21
21
  import { convertNativeHttpResponse } from "./native-http";
22
22
  import type {
23
+ CancellationTokenHandle,
23
24
  CoreRuntime,
24
25
  RuntimeApplicationFetch,
25
26
  RuntimeHttpResponseBodyStream,
@@ -28,6 +29,8 @@ import type {
28
29
 
29
30
  type ShutdownSignal = "SIGINT" | "SIGTERM";
30
31
 
32
+ type ConfiguredRegistry = Awaited<ReturnType<typeof buildConfiguredRegistry>>;
33
+
31
34
  const REGISTRY_READY_TIMEOUT_MS = 30_000;
32
35
  // A managed Engine restart can wait for the old process to release storage and
33
36
  // for its worker lease to expire before the replacement can register.
@@ -36,6 +39,9 @@ const LOCAL_ENGINE_READY_TIMEOUT_MS = 60_000;
36
39
  // reports. Leave time to close the node connection after that, while staying
37
40
  // below the five-second force-kill ceiling used by tsx watch.
38
41
  const LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS = 4_000;
42
+ // Matches the engine's default `pegboard.actor_stop_threshold`. Used only when the
43
+ // node has not received the engine's advertised threshold before shutdown begins.
44
+ const DEFAULT_ACTOR_STOP_THRESHOLD_MS = 30_000;
39
45
 
40
46
  // Serverless is disabled for v3; keep the implementation for a later release.
41
47
  function rejectServerless(): void {
@@ -176,6 +182,11 @@ export class Registry<A extends RegistryActors> {
176
182
  #shutdownInstalled = false;
177
183
  #shutdownInFlight: Promise<void> | null = null;
178
184
  #signalHandlers: Partial<Record<ShutdownSignal, () => void>> = {};
185
+ #envoyConfiguredRegistry?: ConfiguredRegistry;
186
+ #activeActorCountListeners = new Set<(count: number) => void>();
187
+ #activeActorCountToken?: CancellationTokenHandle;
188
+ #lastActiveActorCount?: number;
189
+ #activeActorCountSupported?: boolean;
179
190
 
180
191
  constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>) {
181
192
  this.#config = config;
@@ -674,6 +685,21 @@ export class Registry<A extends RegistryActors> {
674
685
  const configuredRegistryPromise =
675
686
  this.#buildConfiguredRegistry(config);
676
687
  this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
688
+ configuredRegistryPromise.then(
689
+ (configured) => {
690
+ this.#envoyConfiguredRegistry = configured;
691
+ try {
692
+ this.#syncActiveActorCountSubscription();
693
+ } catch (error) {
694
+ logger().error(
695
+ { error },
696
+ "failed to subscribe to the active actor count",
697
+ );
698
+ }
699
+ },
700
+ // The serve lifecycle below reports build failures.
701
+ () => undefined,
702
+ );
677
703
  this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
678
704
  async ({ runtime, registry, serveConfig }) => {
679
705
  await runtime.serveRegistry(registry, serveConfig);
@@ -799,7 +825,7 @@ export class Registry<A extends RegistryActors> {
799
825
  ? LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS
800
826
  : ((await this.#actorStopThresholdMs(
801
827
  modeAPromise ?? modeBPromise,
802
- )) ?? 30 * 60 * 1000);
828
+ )) ?? DEFAULT_ACTOR_STOP_THRESHOLD_MS);
803
829
  }
804
830
  // Race the entire drain sequence (both modes + serve promise) against
805
831
  // a single grace ceiling. Local dev signal shutdowns allow the watcher
@@ -1026,6 +1052,121 @@ export class Registry<A extends RegistryActors> {
1026
1052
  this.#startEnvoy(config, true);
1027
1053
  }
1028
1054
 
1055
+ /**
1056
+ * Returns the number of actors hosted by this process's envoy, which is zero
1057
+ * while it is not serving. Requires the native runtime.
1058
+ */
1059
+ public activeActorCount(): number {
1060
+ this.#assertActiveActorCountSupported("activeActorCount");
1061
+ const configured = this.#envoyConfiguredRegistry;
1062
+ if (!configured) return 0;
1063
+ const { runtime, registry } = configured;
1064
+ if (!runtime.registryActiveActorCount) {
1065
+ throw new Error(
1066
+ "registry.activeActorCount() is not supported by this runtime",
1067
+ );
1068
+ }
1069
+ return runtime.registryActiveActorCount(registry);
1070
+ }
1071
+
1072
+ /**
1073
+ * Calls `callback` with the number of actors hosted by this process's envoy
1074
+ * and again whenever it changes. Rapid changes may coalesce.
1075
+ * Returns a function that unsubscribes. Requires the native runtime.
1076
+ *
1077
+ * @example
1078
+ * ```ts
1079
+ * const unsubscribe = registry.onActiveActorCountChange((count) => {
1080
+ * setTaskProtection(count > 0);
1081
+ * });
1082
+ * ```
1083
+ */
1084
+ public onActiveActorCountChange(
1085
+ callback: (count: number) => void,
1086
+ ): () => void {
1087
+ this.#assertActiveActorCountSupported("onActiveActorCountChange");
1088
+ // Wrap so the same callback can subscribe twice and unsubscribe independently.
1089
+ const listener = (count: number) => callback(count);
1090
+ this.#activeActorCountListeners.add(listener);
1091
+ this.#syncActiveActorCountSubscription();
1092
+
1093
+ // Start late listeners from the stream, not a direct read, which could see a
1094
+ // change the stream coalesced away and never corrects.
1095
+ const lastCount = this.#lastActiveActorCount;
1096
+ if (lastCount !== undefined) {
1097
+ queueMicrotask(() => {
1098
+ if (this.#activeActorCountListeners.has(listener)) {
1099
+ this.#deliverActiveActorCount(listener, lastCount);
1100
+ }
1101
+ });
1102
+ }
1103
+
1104
+ return () => {
1105
+ this.#activeActorCountListeners.delete(listener);
1106
+ this.#syncActiveActorCountSubscription();
1107
+ };
1108
+ }
1109
+
1110
+ #assertActiveActorCountSupported(method: string): void {
1111
+ this.#activeActorCountSupported ??=
1112
+ this.parseConfig().runtime !== "wasm";
1113
+ if (!this.#activeActorCountSupported) {
1114
+ throw new Error(
1115
+ `registry.${method}() requires the native runtime; WebAssembly registries do not host an envoy`,
1116
+ );
1117
+ }
1118
+ }
1119
+
1120
+ /** Holds one native subscription while any listener is registered. */
1121
+ #syncActiveActorCountSubscription(): void {
1122
+ const configured = this.#envoyConfiguredRegistry;
1123
+ if (!configured) return;
1124
+ const { runtime, registry } = configured;
1125
+ const token = this.#activeActorCountToken;
1126
+
1127
+ if (this.#activeActorCountListeners.size === 0) {
1128
+ if (token !== undefined) {
1129
+ this.#activeActorCountToken = undefined;
1130
+ this.#lastActiveActorCount = undefined;
1131
+ runtime.cancelCancellationToken(token);
1132
+ }
1133
+ return;
1134
+ }
1135
+ if (token !== undefined) return;
1136
+
1137
+ if (!runtime.onRegistryActiveActorCountChange) {
1138
+ throw new Error(
1139
+ "active actor count subscriptions are not supported by this runtime",
1140
+ );
1141
+ }
1142
+ const nextToken = runtime.createCancellationToken();
1143
+ this.#activeActorCountToken = nextToken;
1144
+ runtime.onRegistryActiveActorCountChange(
1145
+ registry,
1146
+ (count) => {
1147
+ // Drop calls still queued from a released subscription.
1148
+ if (this.#activeActorCountToken !== nextToken) return;
1149
+ this.#lastActiveActorCount = count;
1150
+ // Iterate a copy so listeners added by a callback are not called twice.
1151
+ for (const listener of [...this.#activeActorCountListeners]) {
1152
+ this.#deliverActiveActorCount(listener, count);
1153
+ }
1154
+ },
1155
+ nextToken,
1156
+ );
1157
+ }
1158
+
1159
+ #deliverActiveActorCount(
1160
+ listener: (count: number) => void,
1161
+ count: number,
1162
+ ): void {
1163
+ try {
1164
+ listener(count);
1165
+ } catch (error) {
1166
+ logger().error({ error }, "active actor count listener threw");
1167
+ }
1168
+ }
1169
+
1029
1170
  #printWelcome(
1030
1171
  config: RegistryConfig,
1031
1172
  kind: "serverless" | "serverful",
@@ -354,6 +354,21 @@ export class NapiCoreRuntime implements CoreRuntime {
354
354
  );
355
355
  }
356
356
 
357
+ registryActiveActorCount(registry: RegistryHandle): number {
358
+ return asNativeRegistry(registry).activeActorCount();
359
+ }
360
+
361
+ onRegistryActiveActorCountChange(
362
+ registry: RegistryHandle,
363
+ callback: (count: number) => void,
364
+ cancelToken: CancellationTokenHandle,
365
+ ): void {
366
+ asNativeRegistry(registry).onActiveActorCountChange(
367
+ callback,
368
+ asNativeCancellationToken(cancelToken),
369
+ );
370
+ }
371
+
357
372
  async registryHealth(
358
373
  registry: RegistryHandle,
359
374
  ): Promise<RuntimeRegistryRouteResponse> {
@@ -500,6 +500,12 @@ export interface CoreRuntime {
500
500
  registryActorStopThresholdMs?(
501
501
  registry: RegistryHandle,
502
502
  ): Promise<number | undefined>;
503
+ registryActiveActorCount?(registry: RegistryHandle): number;
504
+ onRegistryActiveActorCountChange?(
505
+ registry: RegistryHandle,
506
+ callback: (count: number) => void,
507
+ cancelToken: CancellationTokenHandle,
508
+ ): void;
503
509
  handleServerlessRequest(
504
510
  registry: RegistryHandle,
505
511
  req: RuntimeServerlessRequest,