rivetkit 2.3.19 → 2.3.20

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 (101) hide show
  1. package/dist/browser/client.d.ts +39 -0
  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/agent-os/index.cjs +34 -1
  7. package/dist/tsup/agent-os/index.cjs.map +1 -1
  8. package/dist/tsup/agent-os/index.d.cts +39 -0
  9. package/dist/tsup/agent-os/index.d.ts +39 -0
  10. package/dist/tsup/agent-os/index.js +34 -1
  11. package/dist/tsup/agent-os/index.js.map +1 -1
  12. package/dist/tsup/{chunk-RJC5O2SD.cjs → chunk-2CE5UNWK.cjs} +2 -2
  13. package/dist/tsup/{chunk-RJC5O2SD.cjs.map → chunk-2CE5UNWK.cjs.map} +1 -1
  14. package/dist/tsup/{chunk-7HTST3NX.js → chunk-2NXLTFWI.js} +3 -3
  15. package/dist/tsup/{chunk-OGPFN6BT.cjs → chunk-3WS7Z64U.cjs} +3 -3
  16. package/dist/tsup/{chunk-OGPFN6BT.cjs.map → chunk-3WS7Z64U.cjs.map} +1 -1
  17. package/dist/tsup/{chunk-X7RMJQGY.js → chunk-553CIQJY.js} +2 -2
  18. package/dist/tsup/{chunk-BKX7UDTA.js → chunk-5G2J26VM.js} +3 -3
  19. package/dist/tsup/{chunk-PPEIPCW4.cjs → chunk-76YTS32R.cjs} +4 -4
  20. package/dist/tsup/{chunk-PPEIPCW4.cjs.map → chunk-76YTS32R.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-IJUXBWH4.cjs → chunk-A36FMKOV.cjs} +138 -138
  22. package/dist/tsup/{chunk-IJUXBWH4.cjs.map → chunk-A36FMKOV.cjs.map} +1 -1
  23. package/dist/tsup/{chunk-EB77NZL4.js → chunk-CSOHAAZK.js} +33 -1
  24. package/dist/tsup/chunk-CSOHAAZK.js.map +1 -0
  25. package/dist/tsup/{chunk-Z4RAXFSD.cjs → chunk-CVLNRT7O.cjs} +3 -3
  26. package/dist/tsup/{chunk-Z4RAXFSD.cjs.map → chunk-CVLNRT7O.cjs.map} +1 -1
  27. package/dist/tsup/{chunk-DN6MD3KK.js → chunk-DHWZTUKA.js} +2 -2
  28. package/dist/tsup/{chunk-DN6MD3KK.js.map → chunk-DHWZTUKA.js.map} +1 -1
  29. package/dist/tsup/{chunk-464WE4RF.js → chunk-DMQUERRN.js} +2 -2
  30. package/dist/tsup/{chunk-G4U5L6AX.cjs → chunk-IHKDFKM4.cjs} +3 -3
  31. package/dist/tsup/{chunk-G4U5L6AX.cjs.map → chunk-IHKDFKM4.cjs.map} +1 -1
  32. package/dist/tsup/{chunk-EO5UOXXY.cjs → chunk-NWCAIWHL.cjs} +34 -2
  33. package/dist/tsup/chunk-NWCAIWHL.cjs.map +1 -0
  34. package/dist/tsup/{chunk-7A5EIXJJ.cjs → chunk-RSIOGT2U.cjs} +7 -7
  35. package/dist/tsup/{chunk-7A5EIXJJ.cjs.map → chunk-RSIOGT2U.cjs.map} +1 -1
  36. package/dist/tsup/{chunk-4SC2NSAV.js → chunk-SNNVRHLX.js} +2 -2
  37. package/dist/tsup/{chunk-DK3L22R6.js → chunk-TZVAVPGJ.js} +4 -4
  38. package/dist/tsup/{chunk-WME6KOXW.js → chunk-W2PXGWMR.js} +2 -2
  39. package/dist/tsup/{chunk-7BRRGBRY.cjs → chunk-WAISW7KR.cjs} +10 -10
  40. package/dist/tsup/{chunk-7BRRGBRY.cjs.map → chunk-WAISW7KR.cjs.map} +1 -1
  41. package/dist/tsup/client/mod.cjs +5 -5
  42. package/dist/tsup/client/mod.d.cts +2 -2
  43. package/dist/tsup/client/mod.d.ts +2 -2
  44. package/dist/tsup/client/mod.js +4 -4
  45. package/dist/tsup/common/log.cjs +2 -2
  46. package/dist/tsup/common/log.js +1 -1
  47. package/dist/tsup/common/websocket.cjs +3 -3
  48. package/dist/tsup/common/websocket.js +2 -2
  49. package/dist/tsup/{config-DEm0yIVV.d.ts → config-Be-VOHaX.d.ts} +42 -2
  50. package/dist/tsup/{config-8n2AOhXK.d.cts → config-Ct5uXxXk.d.cts} +42 -2
  51. package/dist/tsup/{context-DGg2-IOm.d.ts → context-CXLa0BIM.d.ts} +1 -1
  52. package/dist/tsup/{context-DwjOVvlE.d.cts → context-Cw-11Q-B.d.cts} +1 -1
  53. package/dist/tsup/db/drizzle.cjs +2 -2
  54. package/dist/tsup/db/drizzle.js +1 -1
  55. package/dist/tsup/db/mod.cjs +3 -3
  56. package/dist/tsup/db/mod.js +2 -2
  57. package/dist/tsup/dynamic/mod.cjs +2 -2
  58. package/dist/tsup/dynamic/mod.d.cts +1 -1
  59. package/dist/tsup/dynamic/mod.d.ts +1 -1
  60. package/dist/tsup/dynamic/mod.js +1 -1
  61. package/dist/tsup/inspector/mod.cjs +5 -5
  62. package/dist/tsup/inspector/mod.js +4 -4
  63. package/dist/tsup/inspector/workflow.cjs +4 -4
  64. package/dist/tsup/inspector/workflow.js +3 -3
  65. package/dist/tsup/inspector-tab/mod.cjs +2 -2
  66. package/dist/tsup/inspector-tab/mod.d.cts +2 -2
  67. package/dist/tsup/inspector-tab/mod.d.ts +2 -2
  68. package/dist/tsup/inspector-tab/mod.js +1 -1
  69. package/dist/tsup/mod.cjs +115 -101
  70. package/dist/tsup/mod.cjs.map +1 -1
  71. package/dist/tsup/mod.d.cts +3 -3
  72. package/dist/tsup/mod.d.ts +3 -3
  73. package/dist/tsup/mod.js +20 -6
  74. package/dist/tsup/mod.js.map +1 -1
  75. package/dist/tsup/test/mod.cjs +6 -6
  76. package/dist/tsup/test/mod.d.cts +1 -1
  77. package/dist/tsup/test/mod.d.ts +1 -1
  78. package/dist/tsup/test/mod.js +4 -4
  79. package/dist/tsup/utils.cjs +2 -2
  80. package/dist/tsup/utils.js +1 -1
  81. package/dist/tsup/workflow/mod.cjs +10 -10
  82. package/dist/tsup/workflow/mod.d.cts +3 -3
  83. package/dist/tsup/workflow/mod.d.ts +3 -3
  84. package/dist/tsup/workflow/mod.js +5 -5
  85. package/package.json +8 -8
  86. package/src/actor/actions.ts +36 -0
  87. package/src/actor/config.ts +27 -0
  88. package/src/actor/definition.ts +6 -1
  89. package/src/actor/mod.ts +5 -0
  90. package/src/actor/tracing.ts +28 -0
  91. package/src/registry/native.ts +18 -0
  92. package/src/registry/runtime.ts +8 -0
  93. package/dist/tsup/chunk-EB77NZL4.js.map +0 -1
  94. package/dist/tsup/chunk-EO5UOXXY.cjs.map +0 -1
  95. /package/dist/tsup/{chunk-7HTST3NX.js.map → chunk-2NXLTFWI.js.map} +0 -0
  96. /package/dist/tsup/{chunk-X7RMJQGY.js.map → chunk-553CIQJY.js.map} +0 -0
  97. /package/dist/tsup/{chunk-BKX7UDTA.js.map → chunk-5G2J26VM.js.map} +0 -0
  98. /package/dist/tsup/{chunk-464WE4RF.js.map → chunk-DMQUERRN.js.map} +0 -0
  99. /package/dist/tsup/{chunk-4SC2NSAV.js.map → chunk-SNNVRHLX.js.map} +0 -0
  100. /package/dist/tsup/{chunk-DK3L22R6.js.map → chunk-TZVAVPGJ.js.map} +0 -0
  101. /package/dist/tsup/{chunk-WME6KOXW.js.map → chunk-W2PXGWMR.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 _chunk7A5EIXJJcjs = require('../chunk-7A5EIXJJ.cjs');
3
+ var _chunkRSIOGT2Ucjs = require('../chunk-RSIOGT2U.cjs');
4
4
 
5
5
 
6
- var _chunkIJUXBWH4cjs = require('../chunk-IJUXBWH4.cjs');
6
+ var _chunkA36FMKOVcjs = require('../chunk-A36FMKOV.cjs');
7
7
  require('../chunk-MYWZCDML.cjs');
8
- require('../chunk-OGPFN6BT.cjs');
8
+ require('../chunk-3WS7Z64U.cjs');
9
9
  require('../chunk-KVFIONKQ.cjs');
10
- require('../chunk-RJC5O2SD.cjs');
10
+ require('../chunk-2CE5UNWK.cjs');
11
11
  require('../chunk-JX2ITWAV.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 = _chunk7A5EIXJJcjs.createClient.call(void 0, {
40
- ..._chunkIJUXBWH4cjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
39
+ const client = _chunkRSIOGT2Ucjs.createClient.call(void 0, {
40
+ ..._chunkA36FMKOVcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
41
41
  disableMetadataLookup: false
42
42
  });
43
43
  c.onTestFinished(async () => {
@@ -1,5 +1,5 @@
1
1
  import { TestContext } from 'vitest';
2
- import { aF as Registry, a3 as Client } from '../config-8n2AOhXK.cjs';
2
+ import { aI as Registry, a6 as Client } from '../config-Ct5uXxXk.cjs';
3
3
  import 'zod/v4';
4
4
  import '../config-ey2I2zz5.cjs';
5
5
  import '@rivetkit/rivetkit-wasm';
@@ -1,5 +1,5 @@
1
1
  import { TestContext } from 'vitest';
2
- import { aF as Registry, a3 as Client } from '../config-DEm0yIVV.js';
2
+ import { aI as Registry, a6 as Client } from '../config-Be-VOHaX.js';
3
3
  import 'zod/v4';
4
4
  import '../config-ey2I2zz5.js';
5
5
  import '@rivetkit/rivetkit-wasm';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createClient
3
- } from "../chunk-7HTST3NX.js";
3
+ } from "../chunk-2NXLTFWI.js";
4
4
  import {
5
5
  convertRegistryConfigToClientConfig
6
- } from "../chunk-BKX7UDTA.js";
6
+ } from "../chunk-5G2J26VM.js";
7
7
  import "../chunk-JI6GZ2C2.js";
8
- import "../chunk-X7RMJQGY.js";
8
+ import "../chunk-553CIQJY.js";
9
9
  import "../chunk-JTHHCZCZ.js";
10
- import "../chunk-DN6MD3KK.js";
10
+ import "../chunk-DHWZTUKA.js";
11
11
  import "../chunk-P2OFXH4G.js";
12
12
 
13
13
  // src/test/ready.ts
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkRJC5O2SDcjs = require('./chunk-RJC5O2SD.cjs');
22
+ var _chunk2CE5UNWKcjs = require('./chunk-2CE5UNWK.cjs');
23
23
  require('./chunk-JX2ITWAV.cjs');
24
24
 
25
25
 
@@ -42,5 +42,5 @@ require('./chunk-JX2ITWAV.cjs');
42
42
 
43
43
 
44
44
 
45
- exports.EXTRA_ERROR_LOG = _chunkRJC5O2SDcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkRJC5O2SDcjs.SinglePromiseQueue; exports.VERSION = _chunkRJC5O2SDcjs.VERSION; exports.arrayBuffersEqual = _chunkRJC5O2SDcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkRJC5O2SDcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkRJC5O2SDcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkRJC5O2SDcjs.combineUrlPath; exports.dbg = _chunkRJC5O2SDcjs.dbg; exports.detectRuntime = _chunkRJC5O2SDcjs.detectRuntime; exports.getEnvUniversal = _chunkRJC5O2SDcjs.getEnvUniversal; exports.httpUserAgent = _chunkRJC5O2SDcjs.httpUserAgent; exports.interval = _chunkRJC5O2SDcjs.interval; exports.joinSignals = _chunkRJC5O2SDcjs.joinSignals; exports.jsonParseCompat = _chunkRJC5O2SDcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkRJC5O2SDcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkRJC5O2SDcjs.promiseWithResolvers; exports.setLongTimeout = _chunkRJC5O2SDcjs.setLongTimeout; exports.sleep = _chunkRJC5O2SDcjs.sleep; exports.stringifyError = _chunkRJC5O2SDcjs.stringifyError; exports.toUint8Array = _chunkRJC5O2SDcjs.toUint8Array;
45
+ exports.EXTRA_ERROR_LOG = _chunk2CE5UNWKcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunk2CE5UNWKcjs.SinglePromiseQueue; exports.VERSION = _chunk2CE5UNWKcjs.VERSION; exports.arrayBuffersEqual = _chunk2CE5UNWKcjs.arrayBuffersEqual; exports.assertUnreachable = _chunk2CE5UNWKcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunk2CE5UNWKcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunk2CE5UNWKcjs.combineUrlPath; exports.dbg = _chunk2CE5UNWKcjs.dbg; exports.detectRuntime = _chunk2CE5UNWKcjs.detectRuntime; exports.getEnvUniversal = _chunk2CE5UNWKcjs.getEnvUniversal; exports.httpUserAgent = _chunk2CE5UNWKcjs.httpUserAgent; exports.interval = _chunk2CE5UNWKcjs.interval; exports.joinSignals = _chunk2CE5UNWKcjs.joinSignals; exports.jsonParseCompat = _chunk2CE5UNWKcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunk2CE5UNWKcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunk2CE5UNWKcjs.promiseWithResolvers; exports.setLongTimeout = _chunk2CE5UNWKcjs.setLongTimeout; exports.sleep = _chunk2CE5UNWKcjs.sleep; exports.stringifyError = _chunk2CE5UNWKcjs.stringifyError; exports.toUint8Array = _chunk2CE5UNWKcjs.toUint8Array;
46
46
  //# sourceMappingURL=utils.cjs.map
@@ -19,7 +19,7 @@ import {
19
19
  sleep,
20
20
  stringifyError,
21
21
  toUint8Array
22
- } from "./chunk-DN6MD3KK.js";
22
+ } from "./chunk-DHWZTUKA.js";
23
23
  import "./chunk-P2OFXH4G.js";
24
24
  export {
25
25
  EXTRA_ERROR_LOG,
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2;
2
2
 
3
- var _chunk7BRRGBRYcjs = require('../chunk-7BRRGBRY.cjs');
4
- require('../chunk-G4U5L6AX.cjs');
3
+ var _chunkWAISW7KRcjs = require('../chunk-WAISW7KR.cjs');
4
+ require('../chunk-IHKDFKM4.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkEO5UOXXYcjs = require('../chunk-EO5UOXXY.cjs');
9
- require('../chunk-PPEIPCW4.cjs');
8
+ var _chunkNWCAIWHLcjs = require('../chunk-NWCAIWHL.cjs');
9
+ require('../chunk-76YTS32R.cjs');
10
10
 
11
11
 
12
12
 
13
13
  var _chunkMYWZCDMLcjs = require('../chunk-MYWZCDML.cjs');
14
14
 
15
15
 
16
- var _chunkRJC5O2SDcjs = require('../chunk-RJC5O2SD.cjs');
16
+ var _chunk2CE5UNWKcjs = require('../chunk-2CE5UNWK.cjs');
17
17
 
18
18
 
19
19
 
@@ -743,13 +743,13 @@ function workflow(fn, options = {}) {
743
743
  function getWorkflowInspector(actorId) {
744
744
  let workflowInspector = workflowInspectors.get(actorId);
745
745
  if (!workflowInspector) {
746
- workflowInspector = _chunk7BRRGBRYcjs.createWorkflowInspectorAdapter.call(void 0, );
746
+ workflowInspector = _chunkWAISW7KRcjs.createWorkflowInspectorAdapter.call(void 0, );
747
747
  workflowInspectors.set(actorId, workflowInspector);
748
748
  }
749
749
  return workflowInspector;
750
750
  }
751
751
  async function run(runCtx) {
752
- const actor = runCtx[_chunkEO5UOXXYcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL];
752
+ const actor = runCtx[_chunkNWCAIWHLcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL];
753
753
  _invariant2.default.call(void 0, actor, "workflow() requires an actor instance");
754
754
  const workflowInspector = getWorkflowInspector(actor.id);
755
755
  const driver = new ActorWorkflowDriver(actor, runCtx);
@@ -816,19 +816,19 @@ function workflow(fn, options = {}) {
816
816
  if (shouldRethrowWorkflowError(error)) {
817
817
  runCtx.log.error({
818
818
  msg: "workflow run failed",
819
- error: _chunkRJC5O2SDcjs.stringifyError.call(void 0, error)
819
+ error: _chunk2CE5UNWKcjs.stringifyError.call(void 0, error)
820
820
  });
821
821
  throw error;
822
822
  }
823
823
  runCtx.log.warn({
824
824
  msg: "workflow failed and will sleep until woken",
825
- error: _chunkRJC5O2SDcjs.stringifyError.call(void 0, error)
825
+ error: _chunk2CE5UNWKcjs.stringifyError.call(void 0, error)
826
826
  });
827
827
  } finally {
828
828
  runCtx.abortSignal.removeEventListener("abort", onAbort);
829
829
  }
830
830
  }
831
- return _chunkEO5UOXXYcjs.defineRunHandler.call(void 0, run, {
831
+ return _chunkNWCAIWHLcjs.defineRunHandler.call(void 0, run, {
832
832
  icon: "diagram-project",
833
833
  inspectorKind: "workflow",
834
834
  createInspector: ({ actorId, control }) => {
@@ -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-8n2AOhXK.cjs';
3
+ import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-Ct5uXxXk.cjs';
4
4
  import { A as AnyDatabaseProvider } from '../config-ey2I2zz5.cjs';
5
- import { d as WorkflowContext } from '../context-DwjOVvlE.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-DwjOVvlE.cjs';
5
+ import { d as WorkflowContext } from '../context-Cw-11Q-B.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-Cw-11Q-B.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-DEm0yIVV.js';
3
+ import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-Be-VOHaX.js';
4
4
  import { A as AnyDatabaseProvider } from '../config-ey2I2zz5.js';
5
- import { d as WorkflowContext } from '../context-DGg2-IOm.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-DGg2-IOm.js';
5
+ import { d as WorkflowContext } from '../context-CXLa0BIM.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-CXLa0BIM.js';
7
7
  import 'zod/v4';
8
8
  import '@rivetkit/rivetkit-wasm';
9
9
  import 'zod';
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  createWorkflowInspectorAdapter
3
- } from "../chunk-DK3L22R6.js";
4
- import "../chunk-464WE4RF.js";
3
+ } from "../chunk-TZVAVPGJ.js";
4
+ import "../chunk-DMQUERRN.js";
5
5
  import {
6
6
  ACTOR_CONTEXT_INTERNAL_SYMBOL,
7
7
  defineRunHandler
8
- } from "../chunk-EB77NZL4.js";
9
- import "../chunk-4SC2NSAV.js";
8
+ } from "../chunk-CSOHAAZK.js";
9
+ import "../chunk-SNNVRHLX.js";
10
10
  import {
11
11
  makeWorkflowKey,
12
12
  workflowStoragePrefix
13
13
  } from "../chunk-JI6GZ2C2.js";
14
14
  import {
15
15
  stringifyError
16
- } from "../chunk-DN6MD3KK.js";
16
+ } from "../chunk-DHWZTUKA.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": "2.3.19",
3
+ "version": "2.3.20",
4
4
  "description": "Lightweight libraries for building stateful actors on edge platforms",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -213,14 +213,14 @@
213
213
  "@rivet-dev/agent-os-core": "^0.1.1",
214
214
  "@rivet-dev/services": "^0.1.5",
215
215
  "@rivetkit/bare-ts": "^0.6.2",
216
- "@rivetkit/engine-cli": "2.3.19",
217
- "@rivetkit/engine-envoy-protocol": "2.3.19",
216
+ "@rivetkit/engine-cli": "2.3.20",
217
+ "@rivetkit/engine-envoy-protocol": "2.3.20",
218
218
  "@rivetkit/on-change": "6.0.1",
219
- "@rivetkit/rivetkit-napi": "2.3.19",
220
- "@rivetkit/rivetkit-wasm": "2.3.19",
221
- "@rivetkit/traces": "2.3.19",
222
- "@rivetkit/virtual-websocket": "2.3.19",
223
- "@rivetkit/workflow-engine": "2.3.19",
219
+ "@rivetkit/rivetkit-napi": "2.3.20",
220
+ "@rivetkit/rivetkit-wasm": "2.3.20",
221
+ "@rivetkit/traces": "2.3.20",
222
+ "@rivetkit/virtual-websocket": "2.3.20",
223
+ "@rivetkit/workflow-engine": "2.3.20",
224
224
  "cbor-x": "^1.6.0",
225
225
  "drizzle-orm": "0.45.2",
226
226
  "hono": "^4.7.0",
@@ -1,4 +1,5 @@
1
1
  import type { PrimitiveSchema } from "./schema";
2
+ import type { ActionSampleRates } from "./tracing";
2
3
 
3
4
  export type RuntimeActionHandler = (...args: any[]) => any;
4
5
 
@@ -46,6 +47,41 @@ export function flattenActionInputSchemas(
46
47
  return flattened;
47
48
  }
48
49
 
50
+ /**
51
+ * Flatten per-action sample rates into dot-separated action names.
52
+ *
53
+ * @throws TypeError when a rate names something that is not an action.
54
+ */
55
+ export function flattenActionTraceSamplers(
56
+ actions: unknown,
57
+ rates: ActionSampleRates = {},
58
+ ): Record<string, number> {
59
+ const handlers = flattenActionHandlers(actions);
60
+ const flattened = Object.fromEntries(flattenSampleRates(rates, []));
61
+ for (const name of Object.keys(flattened)) {
62
+ if (!Object.hasOwn(handlers, name)) {
63
+ throw new TypeError(
64
+ `tracing.actions.${name} does not name an action`,
65
+ );
66
+ }
67
+ }
68
+ return flattened;
69
+ }
70
+
71
+ function flattenSampleRates(
72
+ rates: ActionSampleRates,
73
+ path: readonly string[],
74
+ ): Array<[name: string, rate: number]> {
75
+ return Object.entries(rates).flatMap(
76
+ ([segment, rate]): Array<[name: string, rate: number]> => {
77
+ const childPath = [...path, segment];
78
+ return typeof rate === "number"
79
+ ? [[childPath.join("."), rate]]
80
+ : flattenSampleRates(rate, childPath);
81
+ },
82
+ );
83
+ }
84
+
49
85
  interface ActionEntry {
50
86
  name: string;
51
87
  path: string[];
@@ -16,6 +16,7 @@ import type {
16
16
  PrimitiveSchema,
17
17
  QueueSchemaConfig,
18
18
  } from "./schema";
19
+ import type { ActionSampleRates, ActorTracingOptions } from "./tracing";
19
20
 
20
21
  export const DEFAULT_SLEEP_GRACE_PERIOD = 15_000;
21
22
 
@@ -1342,6 +1343,12 @@ export const ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
1342
1343
  export type ActorOptions = z.infer<typeof ActorOptionsSchema>;
1343
1344
  export type ActorOptionsInput = z.input<typeof ActorOptionsSchema>;
1344
1345
 
1346
+ const zSampleRate = z.number().min(0).max(1);
1347
+
1348
+ const zActionSampleRates: z.ZodType<ActionSampleRates> = z.lazy(() =>
1349
+ z.record(z.string(), z.union([zSampleRate, zActionSampleRates])),
1350
+ );
1351
+
1345
1352
  export const ActorConfigSchema = z
1346
1353
  .object({
1347
1354
  onCreate: zFunction().optional(),
@@ -1359,6 +1366,13 @@ export const ActorConfigSchema = z
1359
1366
  onWebSocket: zFunction().optional(),
1360
1367
  actions: zActionTree.default(() => ({})),
1361
1368
  actionInputSchemas: z.record(z.string(), z.any()).optional(),
1369
+ tracing: z
1370
+ .object({
1371
+ sampler: zSampleRate.optional(),
1372
+ actions: zActionSampleRates.optional(),
1373
+ })
1374
+ .strict()
1375
+ .optional(),
1362
1376
  connParamsSchema: z.any().optional(),
1363
1377
  events: z.record(z.string(), z.any()).optional(),
1364
1378
  queues: z.record(z.string(), z.any()).optional(),
@@ -1904,6 +1918,12 @@ interface BaseActorConfig<
1904
1918
  */
1905
1919
  actionInputSchemas?: ActionInputSchemas;
1906
1920
 
1921
+ /**
1922
+ * How much of this actor's work is recorded in traces. Defaults to the
1923
+ * process sampler from `OTEL_TRACES_SAMPLER`.
1924
+ */
1925
+ tracing?: ActorTracingOptions<TActions>;
1926
+
1907
1927
  /**
1908
1928
  * Optional schema for validating connection params in native runtimes.
1909
1929
  */
@@ -2061,6 +2081,7 @@ export type ActorConfigInput<
2061
2081
  } & Omit<
2062
2082
  z.input<typeof ActorConfigSchema>,
2063
2083
  | "actions"
2084
+ | "tracing"
2064
2085
  | "events"
2065
2086
  | "queues"
2066
2087
  | "onCreate"
@@ -2437,6 +2458,12 @@ export const DocActorConfigSchema = z
2437
2458
  .describe(
2438
2459
  "Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names.",
2439
2460
  ),
2461
+ tracing: z
2462
+ .unknown()
2463
+ .optional()
2464
+ .describe(
2465
+ "Trace sampling for this actor: `sampler` is the share of its invocations that are recorded, from 0 to 1, with optional per-action rates under `actions`. A rate lowers what is recorded and never raises it. Defaults to the process sampler from OTEL_TRACES_SAMPLER.",
2466
+ ),
2440
2467
  connParamsSchema: z
2441
2468
  .unknown()
2442
2469
  .optional()
@@ -1,6 +1,10 @@
1
1
  import type { AnyDatabaseProvider } from "@/common/database/config";
2
2
  import type { RegistryConfig } from "@/registry/config";
3
- import { flattenActionHandlers, flattenActionInputSchemas } from "./actions";
3
+ import {
4
+ flattenActionHandlers,
5
+ flattenActionInputSchemas,
6
+ flattenActionTraceSamplers,
7
+ } from "./actions";
4
8
  import {
5
9
  type Actions,
6
10
  type ActorConfig,
@@ -209,6 +213,7 @@ export function actor<
209
213
  >;
210
214
  flattenActionHandlers(config.actions);
211
215
  flattenActionInputSchemas(config.actions, config.actionInputSchemas);
216
+ flattenActionTraceSamplers(config.actions, config.tracing?.actions);
212
217
  return new ActorDefinition(config);
213
218
  }
214
219
 
package/src/actor/mod.ts CHANGED
@@ -67,3 +67,8 @@ export {
67
67
  queue,
68
68
  type Type,
69
69
  } from "./schema";
70
+ export type {
71
+ ActionSampleRates,
72
+ ActionTraceSamplers,
73
+ ActorTracingOptions,
74
+ } from "./tracing";
@@ -0,0 +1,28 @@
1
+ /** Sample rates keyed by action name, nested like the actor's action groups. */
2
+ export interface ActionSampleRates {
3
+ readonly [name: string]: number | ActionSampleRates;
4
+ }
5
+
6
+ /**
7
+ * {@link ActionSampleRates} limited to the actions of one actor, so a rate for
8
+ * an action that does not exist is a compile error.
9
+ */
10
+ export type ActionTraceSamplers<TActions> = {
11
+ readonly [K in keyof TActions]?: TActions[K] extends (
12
+ ...args: never[]
13
+ ) => unknown
14
+ ? number
15
+ : ActionTraceSamplers<TActions[K]>;
16
+ };
17
+
18
+ /** Trace sampling for one actor definition. */
19
+ export interface ActorTracingOptions<TActions> {
20
+ /**
21
+ * Share of this actor's invocations that are recorded, from 0 to 1. A rate
22
+ * lowers what is recorded and never raises it, so an invocation inside a
23
+ * trace the caller did not record is not recorded at any rate.
24
+ */
25
+ readonly sampler?: number;
26
+ /** Rates that replace `sampler` for single actions. */
27
+ readonly actions?: ActionTraceSamplers<TActions>;
28
+ }
@@ -2,6 +2,7 @@ import { VirtualWebSocket } from "@rivetkit/virtual-websocket";
2
2
  import {
3
3
  flattenActionHandlers,
4
4
  flattenActionInputSchemas,
5
+ flattenActionTraceSamplers,
5
6
  } from "@/actor/actions";
6
7
  import {
7
8
  ACTOR_CONTEXT_INTERNAL_SYMBOL,
@@ -41,6 +42,7 @@ import {
41
42
  getQueueCanPublish,
42
43
  hasSchemaConfigKey,
43
44
  } from "@/actor/schema";
45
+ import type { ActionSampleRates } from "@/actor/tracing";
44
46
  import {
45
47
  type AnyClient,
46
48
  type Client,
@@ -112,6 +114,7 @@ import type {
112
114
  CoreRuntime,
113
115
  RegistryHandle,
114
116
  RuntimeActorConfig,
117
+ RuntimeActorTracingConfig,
115
118
  RuntimeBytes,
116
119
  RuntimeCronFire,
117
120
  RuntimeCronJobInfo,
@@ -3854,6 +3857,17 @@ function withConnContext(
3854
3857
  });
3855
3858
  }
3856
3859
 
3860
+ function buildActorTracingConfig(
3861
+ actions: unknown,
3862
+ tracing: { sampler?: number; actions?: ActionSampleRates } | undefined,
3863
+ ): RuntimeActorTracingConfig | undefined {
3864
+ if (tracing === undefined) return undefined;
3865
+ return {
3866
+ sampler: tracing.sampler,
3867
+ actions: flattenActionTraceSamplers(actions, tracing.actions),
3868
+ };
3869
+ }
3870
+
3857
3871
  function buildActorConfig(
3858
3872
  definition: AnyActorDefinition,
3859
3873
  registryConfig: RegistryConfig,
@@ -3874,6 +3888,10 @@ function buildActorConfig(
3874
3888
  hasDatabase: true,
3875
3889
  remoteSqlite: usesRemoteSqlite,
3876
3890
  sqliteProfiling,
3891
+ tracing: buildActorTracingConfig(
3892
+ definition.config.actions,
3893
+ definition.config.tracing,
3894
+ ),
3877
3895
  enableActorRuntimeSocket: options.enableActorRuntimeSocket === true,
3878
3896
  hasState:
3879
3897
  config.state !== undefined ||
@@ -318,12 +318,20 @@ export interface RuntimeSqlTransactionDatabase {
318
318
  rollback(): Promise<void>;
319
319
  }
320
320
 
321
+ /** Sample rates for the traces an actor starts, in the shape core takes. */
322
+ export interface RuntimeActorTracingConfig {
323
+ sampler?: number;
324
+ /** Keyed by flattened, dot-separated action name. */
325
+ actions?: Record<string, number>;
326
+ }
327
+
321
328
  export interface RuntimeActorConfig {
322
329
  name?: string;
323
330
  icon?: string;
324
331
  hasDatabase?: boolean;
325
332
  remoteSqlite?: boolean;
326
333
  sqliteProfiling?: SqliteProfilingOptions;
334
+ tracing?: RuntimeActorTracingConfig;
327
335
  enableActorRuntimeSocket?: boolean;
328
336
  hasState?: boolean;
329
337
  canHibernateWebsocket?: boolean;