rivetkit 2.3.8 → 2.3.10

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 (90) hide show
  1. package/dist/browser/client.d.ts +6 -34
  2. package/dist/browser/client.js +14 -33
  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 +1 -1
  7. package/dist/tsup/agent-os/index.cjs.map +1 -1
  8. package/dist/tsup/agent-os/index.d.cts +6 -34
  9. package/dist/tsup/agent-os/index.d.ts +6 -34
  10. package/dist/tsup/agent-os/index.js +1 -1
  11. package/dist/tsup/agent-os/index.js.map +1 -1
  12. package/dist/tsup/{chunk-YFXQ7DBH.js → chunk-6UHZLL6S.js} +3 -3
  13. package/dist/tsup/{chunk-BL6ERZQO.js → chunk-DPM73GAL.js} +18 -39
  14. package/dist/tsup/chunk-DPM73GAL.js.map +1 -0
  15. package/dist/tsup/{chunk-MY6BRV3S.js → chunk-E6IEX6AP.js} +3 -3
  16. package/dist/tsup/{chunk-IJMVVULS.cjs → chunk-G6XA2OSW.cjs} +4 -4
  17. package/dist/tsup/{chunk-IJMVVULS.cjs.map → chunk-G6XA2OSW.cjs.map} +1 -1
  18. package/dist/tsup/{chunk-F6GCLL5Z.cjs → chunk-INXPYXN6.cjs} +7 -7
  19. package/dist/tsup/{chunk-F6GCLL5Z.cjs.map → chunk-INXPYXN6.cjs.map} +1 -1
  20. package/dist/tsup/{chunk-5MJPN3QU.cjs → chunk-LCWHS6K7.cjs} +152 -173
  21. package/dist/tsup/chunk-LCWHS6K7.cjs.map +1 -0
  22. package/dist/tsup/{chunk-7TNEDX3Y.cjs → chunk-PCJSDS7N.cjs} +3 -3
  23. package/dist/tsup/{chunk-7TNEDX3Y.cjs.map → chunk-PCJSDS7N.cjs.map} +1 -1
  24. package/dist/tsup/{chunk-V7PJYBA5.js → chunk-Q5H37KNQ.js} +2 -2
  25. package/dist/tsup/{chunk-TMTJPSHQ.cjs → chunk-U2A3Y7OK.cjs} +9 -9
  26. package/dist/tsup/{chunk-TMTJPSHQ.cjs.map → chunk-U2A3Y7OK.cjs.map} +1 -1
  27. package/dist/tsup/{chunk-ZKDZW5DQ.js → chunk-X7XY6NCU.js} +3 -6
  28. package/dist/tsup/chunk-X7XY6NCU.js.map +1 -0
  29. package/dist/tsup/{chunk-HWBISPRP.js → chunk-XSPAARQ5.js} +2 -2
  30. package/dist/tsup/{chunk-NUMGL52R.cjs → chunk-Z2ESFE5Z.cjs} +3 -6
  31. package/dist/tsup/chunk-Z2ESFE5Z.cjs.map +1 -0
  32. package/dist/tsup/client/mod.cjs +5 -5
  33. package/dist/tsup/client/mod.d.cts +2 -2
  34. package/dist/tsup/client/mod.d.ts +2 -2
  35. package/dist/tsup/client/mod.js +4 -4
  36. package/dist/tsup/common/log.cjs +2 -2
  37. package/dist/tsup/common/log.js +1 -1
  38. package/dist/tsup/common/websocket.cjs +3 -3
  39. package/dist/tsup/common/websocket.js +2 -2
  40. package/dist/tsup/{config-CUymbyM6.d.ts → config-BRpVbJCD.d.ts} +7 -35
  41. package/dist/tsup/{config-CpB-e4I9.d.cts → config-BobvQpex.d.cts} +7 -35
  42. package/dist/tsup/{context-YBUBTwTS.d.ts → context-Cj-DFyiy.d.ts} +1 -1
  43. package/dist/tsup/{context-c-6G4mjk.d.cts → context-YEBNJrws.d.cts} +1 -1
  44. package/dist/tsup/db/drizzle.cjs +2 -2
  45. package/dist/tsup/db/drizzle.js +1 -1
  46. package/dist/tsup/db/mod.cjs +2 -2
  47. package/dist/tsup/db/mod.js +1 -1
  48. package/dist/tsup/dynamic/mod.d.cts +1 -1
  49. package/dist/tsup/dynamic/mod.d.ts +1 -1
  50. package/dist/tsup/inspector/mod.cjs +4 -4
  51. package/dist/tsup/inspector/mod.js +3 -3
  52. package/dist/tsup/inspector-tab/mod.d.cts +2 -2
  53. package/dist/tsup/inspector-tab/mod.d.ts +2 -2
  54. package/dist/tsup/mod.cjs +124 -449
  55. package/dist/tsup/mod.cjs.map +1 -1
  56. package/dist/tsup/mod.d.cts +3 -3
  57. package/dist/tsup/mod.d.ts +3 -3
  58. package/dist/tsup/mod.js +63 -388
  59. package/dist/tsup/mod.js.map +1 -1
  60. package/dist/tsup/test/mod.cjs +6 -6
  61. package/dist/tsup/test/mod.d.cts +1 -1
  62. package/dist/tsup/test/mod.d.ts +1 -1
  63. package/dist/tsup/test/mod.js +4 -4
  64. package/dist/tsup/utils.cjs +2 -2
  65. package/dist/tsup/utils.js +1 -1
  66. package/dist/tsup/workflow/mod.cjs +6 -6
  67. package/dist/tsup/workflow/mod.d.cts +3 -3
  68. package/dist/tsup/workflow/mod.d.ts +3 -3
  69. package/dist/tsup/workflow/mod.js +3 -3
  70. package/package.json +8 -8
  71. package/src/client/actor-handle.ts +1 -3
  72. package/src/client/raw-utils.ts +2 -11
  73. package/src/common/actor-router-consts.ts +0 -1
  74. package/src/common/encoding.ts +1 -4
  75. package/src/engine-client/actor-http-client.ts +22 -6
  76. package/src/registry/index.ts +14 -159
  77. package/src/registry/napi-runtime.ts +0 -74
  78. package/src/registry/native.ts +63 -111
  79. package/src/registry/runtime.ts +0 -35
  80. package/src/registry/wasm-runtime.ts +0 -11
  81. package/dist/tsup/chunk-5MJPN3QU.cjs.map +0 -1
  82. package/dist/tsup/chunk-BL6ERZQO.js.map +0 -1
  83. package/dist/tsup/chunk-NUMGL52R.cjs.map +0 -1
  84. package/dist/tsup/chunk-ZKDZW5DQ.js.map +0 -1
  85. package/src/common/fetch-like.ts +0 -49
  86. package/src/registry/native-http.ts +0 -208
  87. /package/dist/tsup/{chunk-YFXQ7DBH.js.map → chunk-6UHZLL6S.js.map} +0 -0
  88. /package/dist/tsup/{chunk-MY6BRV3S.js.map → chunk-E6IEX6AP.js.map} +0 -0
  89. /package/dist/tsup/{chunk-V7PJYBA5.js.map → chunk-Q5H37KNQ.js.map} +0 -0
  90. /package/dist/tsup/{chunk-HWBISPRP.js.map → chunk-XSPAARQ5.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 _chunkF6GCLL5Zcjs = require('../chunk-F6GCLL5Z.cjs');
3
+ var _chunkINXPYXN6cjs = require('../chunk-INXPYXN6.cjs');
4
4
 
5
5
 
6
- var _chunk5MJPN3QUcjs = require('../chunk-5MJPN3QU.cjs');
6
+ var _chunkLCWHS6K7cjs = require('../chunk-LCWHS6K7.cjs');
7
7
  require('../chunk-MYWZCDML.cjs');
8
- require('../chunk-7TNEDX3Y.cjs');
9
8
  require('../chunk-UEULFXUI.cjs');
10
- require('../chunk-NUMGL52R.cjs');
9
+ require('../chunk-PCJSDS7N.cjs');
10
+ require('../chunk-Z2ESFE5Z.cjs');
11
11
  require('../chunk-4FC7TVS6.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 = _chunkF6GCLL5Zcjs.createClient.call(void 0, {
40
- ..._chunk5MJPN3QUcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
39
+ const client = _chunkINXPYXN6cjs.createClient.call(void 0, {
40
+ ..._chunkLCWHS6K7cjs.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 { aC as Registry, a2 as Client } from '../config-CpB-e4I9.cjs';
2
+ import { aC as Registry, a2 as Client } from '../config-BobvQpex.cjs';
3
3
  import 'zod/v4';
4
4
  import '../config-BxOimoGX.cjs';
5
5
  import '@rivetkit/rivetkit-wasm';
@@ -1,5 +1,5 @@
1
1
  import { TestContext } from 'vitest';
2
- import { aC as Registry, a2 as Client } from '../config-CUymbyM6.js';
2
+ import { aC as Registry, a2 as Client } from '../config-BRpVbJCD.js';
3
3
  import 'zod/v4';
4
4
  import '../config-BxOimoGX.js';
5
5
  import '@rivetkit/rivetkit-wasm';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createClient
3
- } from "../chunk-YFXQ7DBH.js";
3
+ } from "../chunk-6UHZLL6S.js";
4
4
  import {
5
5
  convertRegistryConfigToClientConfig
6
- } from "../chunk-BL6ERZQO.js";
6
+ } from "../chunk-DPM73GAL.js";
7
7
  import "../chunk-JI6GZ2C2.js";
8
- import "../chunk-V7PJYBA5.js";
9
8
  import "../chunk-7AFZMFPQ.js";
10
- import "../chunk-ZKDZW5DQ.js";
9
+ import "../chunk-Q5H37KNQ.js";
10
+ import "../chunk-X7XY6NCU.js";
11
11
  import "../chunk-ZZ3WBRPD.js";
12
12
 
13
13
  // src/test/ready.ts
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkNUMGL52Rcjs = require('./chunk-NUMGL52R.cjs');
22
+ var _chunkZ2ESFE5Zcjs = require('./chunk-Z2ESFE5Z.cjs');
23
23
  require('./chunk-4FC7TVS6.cjs');
24
24
 
25
25
 
@@ -42,5 +42,5 @@ require('./chunk-4FC7TVS6.cjs');
42
42
 
43
43
 
44
44
 
45
- exports.EXTRA_ERROR_LOG = _chunkNUMGL52Rcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkNUMGL52Rcjs.SinglePromiseQueue; exports.VERSION = _chunkNUMGL52Rcjs.VERSION; exports.arrayBuffersEqual = _chunkNUMGL52Rcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkNUMGL52Rcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkNUMGL52Rcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkNUMGL52Rcjs.combineUrlPath; exports.dbg = _chunkNUMGL52Rcjs.dbg; exports.detectRuntime = _chunkNUMGL52Rcjs.detectRuntime; exports.getEnvUniversal = _chunkNUMGL52Rcjs.getEnvUniversal; exports.httpUserAgent = _chunkNUMGL52Rcjs.httpUserAgent; exports.interval = _chunkNUMGL52Rcjs.interval; exports.joinSignals = _chunkNUMGL52Rcjs.joinSignals; exports.jsonParseCompat = _chunkNUMGL52Rcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkNUMGL52Rcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkNUMGL52Rcjs.promiseWithResolvers; exports.setLongTimeout = _chunkNUMGL52Rcjs.setLongTimeout; exports.sleep = _chunkNUMGL52Rcjs.sleep; exports.stringifyError = _chunkNUMGL52Rcjs.stringifyError; exports.toUint8Array = _chunkNUMGL52Rcjs.toUint8Array;
45
+ exports.EXTRA_ERROR_LOG = _chunkZ2ESFE5Zcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkZ2ESFE5Zcjs.SinglePromiseQueue; exports.VERSION = _chunkZ2ESFE5Zcjs.VERSION; exports.arrayBuffersEqual = _chunkZ2ESFE5Zcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkZ2ESFE5Zcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkZ2ESFE5Zcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkZ2ESFE5Zcjs.combineUrlPath; exports.dbg = _chunkZ2ESFE5Zcjs.dbg; exports.detectRuntime = _chunkZ2ESFE5Zcjs.detectRuntime; exports.getEnvUniversal = _chunkZ2ESFE5Zcjs.getEnvUniversal; exports.httpUserAgent = _chunkZ2ESFE5Zcjs.httpUserAgent; exports.interval = _chunkZ2ESFE5Zcjs.interval; exports.joinSignals = _chunkZ2ESFE5Zcjs.joinSignals; exports.jsonParseCompat = _chunkZ2ESFE5Zcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkZ2ESFE5Zcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkZ2ESFE5Zcjs.promiseWithResolvers; exports.setLongTimeout = _chunkZ2ESFE5Zcjs.setLongTimeout; exports.sleep = _chunkZ2ESFE5Zcjs.sleep; exports.stringifyError = _chunkZ2ESFE5Zcjs.stringifyError; exports.toUint8Array = _chunkZ2ESFE5Zcjs.toUint8Array;
46
46
  //# sourceMappingURL=utils.cjs.map
@@ -19,7 +19,7 @@ import {
19
19
  sleep,
20
20
  stringifyError,
21
21
  toUint8Array
22
- } from "./chunk-ZKDZW5DQ.js";
22
+ } from "./chunk-X7XY6NCU.js";
23
23
  import "./chunk-ZZ3WBRPD.js";
24
24
  export {
25
25
  EXTRA_ERROR_LOG,
@@ -1,7 +1,7 @@
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 _chunkTMTJPSHQcjs = require('../chunk-TMTJPSHQ.cjs');
4
- require('../chunk-IJMVVULS.cjs');
3
+ var _chunkU2A3Y7OKcjs = require('../chunk-U2A3Y7OK.cjs');
4
+ require('../chunk-G6XA2OSW.cjs');
5
5
 
6
6
 
7
7
 
@@ -12,7 +12,7 @@ var _chunkHNHLBM3Ycjs = require('../chunk-HNHLBM3Y.cjs');
12
12
  var _chunkMYWZCDMLcjs = require('../chunk-MYWZCDML.cjs');
13
13
 
14
14
 
15
- var _chunkNUMGL52Rcjs = require('../chunk-NUMGL52R.cjs');
15
+ var _chunkZ2ESFE5Zcjs = require('../chunk-Z2ESFE5Z.cjs');
16
16
 
17
17
 
18
18
 
@@ -716,7 +716,7 @@ function workflow(fn, options = {}) {
716
716
  function getWorkflowInspector(actorId) {
717
717
  let workflowInspector = workflowInspectors.get(actorId);
718
718
  if (!workflowInspector) {
719
- workflowInspector = _chunkTMTJPSHQcjs.createWorkflowInspectorAdapter.call(void 0, );
719
+ workflowInspector = _chunkU2A3Y7OKcjs.createWorkflowInspectorAdapter.call(void 0, );
720
720
  workflowInspectors.set(actorId, workflowInspector);
721
721
  }
722
722
  return workflowInspector;
@@ -784,13 +784,13 @@ function workflow(fn, options = {}) {
784
784
  if (shouldRethrowWorkflowError(error)) {
785
785
  runCtx.log.error({
786
786
  msg: "workflow run failed",
787
- error: _chunkNUMGL52Rcjs.stringifyError.call(void 0, error)
787
+ error: _chunkZ2ESFE5Zcjs.stringifyError.call(void 0, error)
788
788
  });
789
789
  throw error;
790
790
  }
791
791
  runCtx.log.warn({
792
792
  msg: "workflow failed and will sleep until woken",
793
- error: _chunkNUMGL52Rcjs.stringifyError.call(void 0, error)
793
+ error: _chunkZ2ESFE5Zcjs.stringifyError.call(void 0, error)
794
794
  });
795
795
  } finally {
796
796
  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-CpB-e4I9.cjs';
3
+ import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-BobvQpex.cjs';
4
4
  import { A as AnyDatabaseProvider } from '../config-BxOimoGX.cjs';
5
- import { d as WorkflowContext } from '../context-c-6G4mjk.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-c-6G4mjk.cjs';
5
+ import { d as WorkflowContext } from '../context-YEBNJrws.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-YEBNJrws.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-CUymbyM6.js';
3
+ import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-BRpVbJCD.js';
4
4
  import { A as AnyDatabaseProvider } from '../config-BxOimoGX.js';
5
- import { d as WorkflowContext } from '../context-YBUBTwTS.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-YBUBTwTS.js';
5
+ import { d as WorkflowContext } from '../context-Cj-DFyiy.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-Cj-DFyiy.js';
7
7
  import 'zod/v4';
8
8
  import '@rivetkit/rivetkit-wasm';
9
9
  import 'zod';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createWorkflowInspectorAdapter
3
- } from "../chunk-MY6BRV3S.js";
4
- import "../chunk-HWBISPRP.js";
3
+ } from "../chunk-E6IEX6AP.js";
4
+ import "../chunk-XSPAARQ5.js";
5
5
  import {
6
6
  ACTOR_CONTEXT_INTERNAL_SYMBOL,
7
7
  RUN_FUNCTION_CONFIG_SYMBOL
@@ -12,7 +12,7 @@ import {
12
12
  } from "../chunk-JI6GZ2C2.js";
13
13
  import {
14
14
  stringifyError
15
- } from "../chunk-ZKDZW5DQ.js";
15
+ } from "../chunk-X7XY6NCU.js";
16
16
  import {
17
17
  RivetError,
18
18
  isActorAbortedError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivetkit",
3
- "version": "2.3.8",
3
+ "version": "2.3.10",
4
4
  "description": "Lightweight libraries for building stateful actors on edge platforms",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -201,14 +201,14 @@
201
201
  "@hono/zod-openapi": "^1.1.5",
202
202
  "@rivet-dev/agent-os-core": "^0.1.1",
203
203
  "@rivetkit/bare-ts": "^0.6.2",
204
- "@rivetkit/engine-cli": "2.3.8",
205
- "@rivetkit/engine-envoy-protocol": "2.3.8",
204
+ "@rivetkit/engine-cli": "2.3.10",
205
+ "@rivetkit/engine-envoy-protocol": "2.3.10",
206
206
  "@rivetkit/on-change": "6.0.1",
207
- "@rivetkit/rivetkit-napi": "2.3.8",
208
- "@rivetkit/rivetkit-wasm": "2.3.8",
209
- "@rivetkit/traces": "2.3.8",
210
- "@rivetkit/virtual-websocket": "2.3.8",
211
- "@rivetkit/workflow-engine": "2.3.8",
207
+ "@rivetkit/rivetkit-napi": "2.3.10",
208
+ "@rivetkit/rivetkit-wasm": "2.3.10",
209
+ "@rivetkit/traces": "2.3.10",
210
+ "@rivetkit/virtual-websocket": "2.3.10",
211
+ "@rivetkit/workflow-engine": "2.3.10",
212
212
  "cbor-x": "^1.6.0",
213
213
  "drizzle-orm": "^0.44.2",
214
214
  "hono": "^4.7.0",
@@ -4,7 +4,6 @@ import {
4
4
  HEADER_CONN_PARAMS,
5
5
  HEADER_ENCODING,
6
6
  } from "@/common/actor-router-consts";
7
- import { isRequestLike } from "@/common/fetch-like";
8
7
  import type * as protocol from "@/common/client-protocol";
9
8
  import {
10
9
  CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
@@ -641,7 +640,6 @@ export class ActorHandleRaw {
641
640
  ) {
642
641
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
643
642
  let useQueryTarget = false;
644
- const retryableRequest = isRequestLike(input) ? input.clone() : undefined;
645
643
  const { skipReadyWait, ...requestInit } = init ?? {};
646
644
  const gatewayOptions = resolveActorGatewayOptions(
647
645
  this.#gatewayOptions,
@@ -662,7 +660,7 @@ export class ActorHandleRaw {
662
660
  this.#driver,
663
661
  target,
664
662
  this.#params,
665
- retryableRequest ? retryableRequest.clone() : input,
663
+ input,
666
664
  requestInit,
667
665
  gatewayOptions,
668
666
  );
@@ -1,10 +1,8 @@
1
1
  import {
2
2
  HEADER_CONN_PARAMS,
3
- HEADER_ORIGINAL_REQUEST_URL,
4
3
  PATH_WEBSOCKET_PREFIX,
5
4
  } from "@/common/actor-router-consts";
6
5
  import { deconstructError } from "@/common/utils";
7
- import { isRequestLike, isUrlLike } from "@/common/fetch-like";
8
6
  import type {
9
7
  EngineControlClient,
10
8
  GatewayRequestOptions,
@@ -26,19 +24,16 @@ export async function rawHttpFetch(
26
24
  ): Promise<Response> {
27
25
  // Extract path and merge init options
28
26
  let path: string;
29
- let originalUrl: string | undefined;
30
27
  let mergedInit: RequestInit = init || {};
31
28
 
32
29
  if (typeof input === "string") {
33
30
  path = input;
34
- } else if (isUrlLike(input)) {
31
+ } else if (input instanceof URL) {
35
32
  path = input.pathname + input.search;
36
- originalUrl = input.toString();
37
- } else if (isRequestLike(input)) {
33
+ } else if (input instanceof Request) {
38
34
  // Extract path from Request URL
39
35
  const url = new URL(input.url);
40
36
  path = url.pathname + url.search;
41
- originalUrl = url.toString();
42
37
  // Merge Request properties with init
43
38
  const requestHeaders = new Headers(input.headers);
44
39
  const initHeaders = new Headers(init?.headers || {});
@@ -90,10 +85,6 @@ export async function rawHttpFetch(
90
85
 
91
86
  // Forward conn params if provided
92
87
  const proxyRequestHeaders = new Headers(mergedInit.headers);
93
- proxyRequestHeaders.delete(HEADER_ORIGINAL_REQUEST_URL);
94
- if (originalUrl) {
95
- proxyRequestHeaders.set(HEADER_ORIGINAL_REQUEST_URL, originalUrl);
96
- }
97
88
  if (params) {
98
89
  proxyRequestHeaders.set(HEADER_CONN_PARAMS, JSON.stringify(params));
99
90
  }
@@ -12,7 +12,6 @@ export const HEADER_ENCODING = "x-rivet-encoding";
12
12
 
13
13
  // IMPORTANT: Params must be in headers or in an E2EE part of the request (i.e. NOT the URL or query string) in order to ensure that tokens can be securely passed in params.
14
14
  export const HEADER_CONN_PARAMS = "x-rivet-conn-params";
15
- export const HEADER_ORIGINAL_REQUEST_URL = "x-rivet-internal-original-request-url";
16
15
 
17
16
  export const HEADER_ACTOR_ID = "x-rivet-actor";
18
17
  export const HEADER_ACTOR_GENERATION = "x-rivet-actor-generation";
@@ -484,10 +484,7 @@ export function jsonStringifyCompat(
484
484
  return [JSON_COMPAT_BIGINT, value.toString()];
485
485
  }
486
486
  if (value instanceof ArrayBuffer) {
487
- return [
488
- JSON_COMPAT_ARRAY_BUFFER,
489
- base64EncodeArrayBuffer(value),
490
- ];
487
+ return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(value)];
491
488
  }
492
489
  if (value instanceof Uint8Array) {
493
490
  return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
@@ -17,7 +17,8 @@ export async function sendHttpRequestToGateway(
17
17
  actorRequest: Request,
18
18
  options: HttpGatewayRequestOptions = {},
19
19
  ): Promise<Response> {
20
- let bodyToSend: ReadableStream<Uint8Array> | null = null;
20
+ // Handle body properly based on method and presence
21
+ let bodyToSend: ArrayBuffer | null = null;
21
22
  const guardHeaders = buildGuardHeaders(runConfig, actorRequest, options);
22
23
 
23
24
  if (actorRequest.method !== "GET" && actorRequest.method !== "HEAD") {
@@ -25,20 +26,35 @@ export async function sendHttpRequestToGateway(
25
26
  throw new Error("Request body has already been consumed");
26
27
  }
27
28
 
28
- if (actorRequest.body) {
29
- bodyToSend = actorRequest.body;
29
+ // TODO: This buffers the entire request in memory every time. We
30
+ // need to properly implement streaming bodies.
31
+ const reqBody = await actorRequest.arrayBuffer();
32
+
33
+ if (reqBody.byteLength !== 0) {
34
+ bodyToSend = reqBody;
35
+
36
+ // If this is a streaming request, we need to convert the headers
37
+ // for the basic array buffer.
30
38
  guardHeaders.delete("transfer-encoding");
31
39
  guardHeaders.delete("content-length");
32
40
  }
33
41
  }
34
42
 
35
- return fetch(gatewayUrl, {
43
+ const guardRequest = new Request(gatewayUrl, {
36
44
  method: actorRequest.method,
37
45
  headers: guardHeaders,
38
46
  body: bodyToSend,
39
47
  signal: actorRequest.signal,
40
- ...(bodyToSend ? { duplex: "half" } : {}),
41
- } as RequestInit);
48
+ });
49
+
50
+ return mutableResponse(await fetch(guardRequest));
51
+ }
52
+
53
+ function mutableResponse(fetchRes: Response): Response {
54
+ // We cannot return the raw response from `fetch` since the response type is not mutable.
55
+ //
56
+ // In order for middleware to be able to mutate the response, we need to build a new Response object that is mutable.
57
+ return new Response(fetchRes.body, fetchRes);
42
58
  }
43
59
 
44
60
  function buildGuardHeaders(
@@ -1,5 +1,4 @@
1
1
  import { isLocalEngineEndpoint } from "@/common/engine";
2
- import { isResponseLike } from "@/common/fetch-like";
3
2
  import { configureBaseLogger } from "@/common/log";
4
3
  import { configureServerlessPool } from "@/serverless/configure";
5
4
  import { VERSION } from "@/utils";
@@ -15,16 +14,8 @@ import {
15
14
  RegistryConfigSchema,
16
15
  } from "./config";
17
16
  import { logger } from "./log";
18
- import {
19
- buildConfiguredRegistry,
20
- } from "./native";
21
- import { convertNativeHttpResponse } from "./native-http";
22
- import type {
23
- CoreRuntime,
24
- RuntimeApplicationFetch,
25
- RuntimeHttpResponseBodyStream,
26
- RuntimeServerlessResponseHead,
27
- } from "./runtime";
17
+ import { buildConfiguredRegistry } from "./native";
18
+ import type { RuntimeServerlessResponseHead } from "./runtime";
28
19
 
29
20
  type ShutdownSignal = "SIGINT" | "SIGTERM";
30
21
 
@@ -46,66 +37,6 @@ function finishShutdownSignal(signal: ShutdownSignal): void {
46
37
  process.kill(process.pid, signal);
47
38
  }
48
39
 
49
- function createApplicationFetch(
50
- application: RegistryApplication,
51
- runtime: CoreRuntime,
52
- ): RuntimeApplicationFetch {
53
- return async (
54
- request,
55
- responseBodyStream?: RuntimeHttpResponseBodyStream,
56
- ) => {
57
- const method = request.method.toUpperCase();
58
- const body =
59
- method === "GET" || method === "HEAD" || request.body.length === 0
60
- ? undefined
61
- : Uint8Array.from(request.body).buffer;
62
- const abortController = new AbortController();
63
- if (request.cancelToken) {
64
- if (runtime.cancellationTokenAborted(request.cancelToken)) {
65
- abortController.abort();
66
- } else {
67
- runtime.onCancellationTokenCancelled(
68
- request.cancelToken,
69
- () => abortController.abort(),
70
- );
71
- }
72
- }
73
- const response = await application.fetch(
74
- new Request(request.url, {
75
- method,
76
- headers: request.headers,
77
- body,
78
- signal: abortController.signal,
79
- }),
80
- );
81
- if (!isResponseLike(response)) {
82
- throw new TypeError(
83
- "registry.listen() application fetch must return a Response",
84
- );
85
- }
86
- const conversion = await convertNativeHttpResponse(
87
- response,
88
- responseBodyStream,
89
- );
90
- if (conversion.bodyCompletion) {
91
- void conversion.bodyCompletion.catch((error) => {
92
- logger().error({
93
- msg: "application response stream failed",
94
- error,
95
- });
96
- });
97
- }
98
- return {
99
- status: conversion.response.status ?? response.status,
100
- headers:
101
- conversion.response.headers ??
102
- Object.fromEntries(response.headers.entries()),
103
- body: conversion.response.body,
104
- stream: conversion.response.stream,
105
- };
106
- };
107
- }
108
-
109
40
  export type FetchHandler = (
110
41
  request: Request,
111
42
  ...args: any
@@ -115,17 +46,6 @@ export interface ServerlessHandler {
115
46
  fetch: FetchHandler;
116
47
  }
117
48
 
118
- export interface RegistryApplication {
119
- fetch: FetchHandler;
120
- }
121
-
122
- export interface RegistryListenOptions {
123
- port?: number;
124
- host?: string;
125
- publicDir?: string;
126
- application?: RegistryApplication;
127
- }
128
-
129
49
  export interface RegistryRoutes {
130
50
  health(): Promise<Response>;
131
51
  metadata(): Promise<Response>;
@@ -159,7 +79,6 @@ export class Registry<A extends RegistryActors> {
159
79
  #runtimeReadyPromise?: Promise<void>;
160
80
  #runtimeServeConfiguredPromise?: ReturnType<typeof buildConfiguredRegistry>;
161
81
  #runtimeServerlessPromise?: ReturnType<typeof buildConfiguredRegistry>;
162
- #applicationListenerPromise?: Promise<void>;
163
82
  #configureServerlessPoolPromise?: Promise<void>;
164
83
  #welcomePrinted = false;
165
84
  #shutdownInstalled = false;
@@ -429,72 +348,22 @@ export class Registry<A extends RegistryActors> {
429
348
  * @param opts.host Address to bind. Defaults to `0.0.0.0`.
430
349
  * @param opts.publicDir If set, serves static files from this directory
431
350
  * as a fallback below the framework routes.
432
- * @param opts.application If set, handles requests that do not match a
433
- * framework route.
434
351
  *
435
352
  * @example
436
353
  * ```ts
437
354
  * await registry.listen();
438
- * await registry.listen({ application: app });
355
+ * await registry.listen({ port: 8080, publicDir: "./public" });
439
356
  * ```
440
357
  */
441
- public async listen(opts: RegistryListenOptions = {}): Promise<void> {
358
+ public async listen(
359
+ opts: { port?: number; host?: string; publicDir?: string } = {},
360
+ ): Promise<void> {
442
361
  const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3000;
443
362
  const publicDir = opts.publicDir ?? getRivetkitPublicDir();
444
363
  const config = this.parseConfig();
445
364
 
446
- if (opts.application && getRivetkitRuntimeMode() !== "serverless") {
447
- if (config.runtime === "wasm") {
448
- throw new Error(
449
- "registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly",
450
- );
451
- }
452
- this.#installSignalHandlers(config);
453
- this.#printWelcome(config, "serverful", {
454
- port,
455
- host: opts.host,
456
- publicDir,
457
- });
458
- this.#startEnvoy(config, true);
459
- const readyPromise = this.startAndWait();
460
- const configuredRegistryPromise =
461
- this.#runtimeServeConfiguredPromise;
462
- if (!configuredRegistryPromise) {
463
- throw new Error("registry envoy startup did not initialize");
464
- }
465
- const { runtime, registry, serveConfig } =
466
- await configuredRegistryPromise;
467
- const application = createApplicationFetch(
468
- opts.application,
469
- runtime,
470
- );
471
- await readyPromise;
472
- const listenerPromise = runtime.serveApplicationListener(
473
- registry,
474
- {
475
- port,
476
- host: opts.host,
477
- publicDir,
478
- application,
479
- },
480
- serveConfig,
481
- );
482
- this.#applicationListenerPromise = listenerPromise;
483
- const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
484
- if (!serveLifecyclePromise) {
485
- throw new Error(
486
- "registry envoy serve lifecycle did not initialize",
487
- );
488
- }
489
- await Promise.all([
490
- listenerPromise,
491
- serveLifecyclePromise,
492
- ]);
493
- return;
494
- }
495
-
496
365
  // Cache on both promise fields so the shutdown drain sees Mode A and B.
497
- const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
366
+ const configuredRegistryPromise = buildConfiguredRegistry(config);
498
367
  this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
499
368
  this.#runtimeServerlessPromise = configuredRegistryPromise;
500
369
  this.#installSignalHandlers(config);
@@ -510,17 +379,9 @@ export class Registry<A extends RegistryActors> {
510
379
 
511
380
  const { runtime, registry, serveConfig } =
512
381
  await configuredRegistryPromise;
513
- const application = opts.application
514
- ? createApplicationFetch(opts.application, runtime)
515
- : undefined;
516
382
  await runtime.serveListener(
517
383
  registry,
518
- {
519
- port,
520
- host: opts.host,
521
- publicDir,
522
- application,
523
- },
384
+ { port, host: opts.host, publicDir },
524
385
  serveConfig,
525
386
  );
526
387
  }
@@ -638,14 +499,15 @@ export class Registry<A extends RegistryActors> {
638
499
  await runtime.serveRegistry(registry, serveConfig);
639
500
  },
640
501
  );
641
- this.#runtimeServePromise =
642
- this.#runtimeServeLifecyclePromise.catch((error) => {
502
+ this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
503
+ (error) => {
643
504
  // Always-attached catch so the stored promise never leaves a
644
505
  // rejection unhandled. Downstream awaits (e.g. #runShutdown's
645
506
  // Promise.race) attach their own catches and still observe
646
507
  // resolution via the race.
647
508
  logger().warn({ error }, "runtime registry serve errored");
648
- });
509
+ },
510
+ );
649
511
  // Install signal handlers once an envoy lifecycle has begun. Only
650
512
  // Mode A ever reaches here. Mode B (handler(request)) intentionally
651
513
  // does not install handlers because it runs on Workers/Vercel/Deno
@@ -791,9 +653,6 @@ export class Registry<A extends RegistryActors> {
791
653
  // already logged any serve-side error.
792
654
  await runtimeServePromise.catch(() => undefined);
793
655
  }
794
- if (this.#applicationListenerPromise !== undefined) {
795
- await this.#applicationListenerPromise.catch(() => undefined);
796
- }
797
656
  };
798
657
  await Promise.race([
799
658
  drain(),
@@ -853,9 +712,7 @@ export class Registry<A extends RegistryActors> {
853
712
  public startAndWait(): Promise<void> {
854
713
  if (this.#shutdownInFlight !== null) {
855
714
  return Promise.reject(
856
- new Error(
857
- "registry.startAndWait() cannot run after shutdown has begun",
858
- ),
715
+ new Error("registry.startAndWait() cannot run after shutdown has begun"),
859
716
  );
860
717
  }
861
718
  if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
@@ -898,9 +755,7 @@ export class Registry<A extends RegistryActors> {
898
755
  const readinessPromise = (async () => {
899
756
  const { runtime, registry } = await configuredRegistryPromise;
900
757
  const stoppedBeforeReady = serveLifecyclePromise.then(() => {
901
- throw new Error(
902
- "RivetKit registry stopped before becoming ready",
903
- );
758
+ throw new Error("RivetKit registry stopped before becoming ready");
904
759
  });
905
760
  await Promise.race([
906
761
  runtime.waitRegistryReady(registry),