rivetkit 2.3.12-rc.3 → 2.3.12

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 (109) hide show
  1. package/dist/browser/client.d.ts +17 -2
  2. package/dist/browser/client.js +32 -24
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +2 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +2 -2
  7. package/dist/tsup/actor/errors.js +1 -1
  8. package/dist/tsup/agent-os/index.cjs +2 -1
  9. package/dist/tsup/agent-os/index.cjs.map +1 -1
  10. package/dist/tsup/agent-os/index.d.cts +17 -2
  11. package/dist/tsup/agent-os/index.d.ts +17 -2
  12. package/dist/tsup/agent-os/index.js +2 -1
  13. package/dist/tsup/agent-os/index.js.map +1 -1
  14. package/dist/tsup/{chunk-SPJORZMM.cjs → chunk-2JSYYH6P.cjs} +1 -1
  15. package/dist/tsup/chunk-2JSYYH6P.cjs.map +1 -0
  16. package/dist/tsup/{chunk-IJWTHKH6.cjs → chunk-AN7WO7BM.cjs} +3 -3
  17. package/dist/tsup/{chunk-IJWTHKH6.cjs.map → chunk-AN7WO7BM.cjs.map} +1 -1
  18. package/dist/tsup/{chunk-PSXMESQJ.js → chunk-EBXARMGI.js} +2 -2
  19. package/dist/tsup/{chunk-O6H3BUN4.cjs → chunk-FGQABMXZ.cjs} +3 -3
  20. package/dist/tsup/{chunk-O6H3BUN4.cjs.map → chunk-FGQABMXZ.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-WVFTFWJL.js → chunk-GEN4NHXM.js} +2 -2
  22. package/dist/tsup/{chunk-XI4MEUUI.js → chunk-JYTXOMM7.js} +2 -2
  23. package/dist/tsup/{chunk-OX6WVQE6.cjs → chunk-MEF7RVQ7.cjs} +10 -10
  24. package/dist/tsup/{chunk-OX6WVQE6.cjs.map → chunk-MEF7RVQ7.cjs.map} +1 -1
  25. package/dist/tsup/{chunk-OLGQYFUW.js → chunk-MF42PRF2.js} +9 -3
  26. package/dist/tsup/chunk-MF42PRF2.js.map +1 -0
  27. package/dist/tsup/{chunk-IXBD7BXC.js → chunk-OUQUIBVW.js} +1 -1
  28. package/dist/tsup/chunk-OUQUIBVW.js.map +1 -0
  29. package/dist/tsup/{chunk-QLOBB27M.cjs → chunk-PW2VSGUR.cjs} +4 -4
  30. package/dist/tsup/{chunk-QLOBB27M.cjs.map → chunk-PW2VSGUR.cjs.map} +1 -1
  31. package/dist/tsup/{chunk-NHI5L7C7.js → chunk-RBXJWAJB.js} +3 -3
  32. package/dist/tsup/{chunk-UBB32UOG.cjs → chunk-SSPTEGTX.cjs} +7 -7
  33. package/dist/tsup/{chunk-UBB32UOG.cjs.map → chunk-SSPTEGTX.cjs.map} +1 -1
  34. package/dist/tsup/{chunk-4ESGNS3Z.cjs → chunk-TAG6UEL5.cjs} +17 -11
  35. package/dist/tsup/chunk-TAG6UEL5.cjs.map +1 -0
  36. package/dist/tsup/{chunk-EQKSWDIH.cjs → chunk-TXUHVBKH.cjs} +3 -3
  37. package/dist/tsup/{chunk-EQKSWDIH.cjs.map → chunk-TXUHVBKH.cjs.map} +1 -1
  38. package/dist/tsup/{chunk-PZBWSCQR.cjs → chunk-TZPNSOG2.cjs} +203 -195
  39. package/dist/tsup/chunk-TZPNSOG2.cjs.map +1 -0
  40. package/dist/tsup/{chunk-YYIDQBBM.js → chunk-VOYNLY57.js} +41 -33
  41. package/dist/tsup/chunk-VOYNLY57.js.map +1 -0
  42. package/dist/tsup/{chunk-UN5JNDBT.js → chunk-XUODFCRJ.js} +4 -4
  43. package/dist/tsup/{chunk-34Q4YVCX.js → chunk-ZIPXAVKR.js} +2 -2
  44. package/dist/tsup/client/mod.cjs +6 -6
  45. package/dist/tsup/client/mod.d.cts +2 -2
  46. package/dist/tsup/client/mod.d.ts +2 -2
  47. package/dist/tsup/client/mod.js +5 -5
  48. package/dist/tsup/common/log.cjs +3 -3
  49. package/dist/tsup/common/log.js +2 -2
  50. package/dist/tsup/common/websocket.cjs +4 -4
  51. package/dist/tsup/common/websocket.js +3 -3
  52. package/dist/tsup/{config-Bi1r6gI7.d.ts → config-BGTanB_3.d.ts} +18 -2
  53. package/dist/tsup/{config-BXSV17G7.d.cts → config-NHz6oMb9.d.cts} +18 -2
  54. package/dist/tsup/{context-4fJemY0D.d.cts → context-DB8zG_Ib.d.cts} +1 -1
  55. package/dist/tsup/{context-D4sNYboo.d.ts → context-SHomdVV8.d.ts} +1 -1
  56. package/dist/tsup/db/drizzle.cjs +3 -3
  57. package/dist/tsup/db/drizzle.js +2 -2
  58. package/dist/tsup/db/mod.cjs +4 -4
  59. package/dist/tsup/db/mod.js +3 -3
  60. package/dist/tsup/dynamic/mod.d.cts +1 -1
  61. package/dist/tsup/dynamic/mod.d.ts +1 -1
  62. package/dist/tsup/inspector/mod.cjs +6 -6
  63. package/dist/tsup/inspector/mod.js +5 -5
  64. package/dist/tsup/inspector/workflow.cjs +5 -5
  65. package/dist/tsup/inspector/workflow.js +4 -4
  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/mod.cjs +423 -177
  69. package/dist/tsup/mod.cjs.map +1 -1
  70. package/dist/tsup/mod.d.cts +3 -3
  71. package/dist/tsup/mod.d.ts +3 -3
  72. package/dist/tsup/mod.js +322 -76
  73. package/dist/tsup/mod.js.map +1 -1
  74. package/dist/tsup/test/mod.cjs +7 -7
  75. package/dist/tsup/test/mod.d.cts +1 -1
  76. package/dist/tsup/test/mod.d.ts +1 -1
  77. package/dist/tsup/test/mod.js +5 -5
  78. package/dist/tsup/utils.cjs +3 -3
  79. package/dist/tsup/utils.js +2 -2
  80. package/dist/tsup/workflow/mod.cjs +11 -11
  81. package/dist/tsup/workflow/mod.d.cts +3 -3
  82. package/dist/tsup/workflow/mod.d.ts +3 -3
  83. package/dist/tsup/workflow/mod.js +5 -5
  84. package/package.json +9 -8
  85. package/src/actor/errors.ts +2 -1
  86. package/src/client/actor-handle.ts +10 -3
  87. package/src/client/raw-utils.ts +8 -0
  88. package/src/common/actor-router-consts.ts +2 -0
  89. package/src/engine-client/actor-http-client.ts +6 -22
  90. package/src/engine-client/mod.ts +1 -1
  91. package/src/registry/config/index.ts +27 -1
  92. package/src/registry/index.ts +48 -14
  93. package/src/registry/napi-runtime.ts +32 -5
  94. package/src/registry/native-http.ts +225 -0
  95. package/src/registry/native.ts +130 -64
  96. package/src/registry/runtime.ts +30 -2
  97. package/src/utils/env-vars.ts +4 -0
  98. package/dist/tsup/chunk-4ESGNS3Z.cjs.map +0 -1
  99. package/dist/tsup/chunk-IXBD7BXC.js.map +0 -1
  100. package/dist/tsup/chunk-OLGQYFUW.js.map +0 -1
  101. package/dist/tsup/chunk-PZBWSCQR.cjs.map +0 -1
  102. package/dist/tsup/chunk-SPJORZMM.cjs.map +0 -1
  103. package/dist/tsup/chunk-YYIDQBBM.js.map +0 -1
  104. /package/dist/tsup/{chunk-PSXMESQJ.js.map → chunk-EBXARMGI.js.map} +0 -0
  105. /package/dist/tsup/{chunk-WVFTFWJL.js.map → chunk-GEN4NHXM.js.map} +0 -0
  106. /package/dist/tsup/{chunk-XI4MEUUI.js.map → chunk-JYTXOMM7.js.map} +0 -0
  107. /package/dist/tsup/{chunk-NHI5L7C7.js.map → chunk-RBXJWAJB.js.map} +0 -0
  108. /package/dist/tsup/{chunk-UN5JNDBT.js.map → chunk-XUODFCRJ.js.map} +0 -0
  109. /package/dist/tsup/{chunk-34Q4YVCX.js.map → chunk-ZIPXAVKR.js.map} +0 -0
@@ -2,13 +2,13 @@ import {
2
2
  deserializeActorKey,
3
3
  serializeActorKey
4
4
  } from "./chunk-JI6GZ2C2.js";
5
- import {
6
- AsyncMutex
7
- } from "./chunk-JTHHCZCZ.js";
8
5
  import {
9
6
  importWebSocket,
10
7
  logger
11
- } from "./chunk-XI4MEUUI.js";
8
+ } from "./chunk-JYTXOMM7.js";
9
+ import {
10
+ AsyncMutex
11
+ } from "./chunk-JTHHCZCZ.js";
12
12
  import {
13
13
  EncodingSchema,
14
14
  assertUnreachable,
@@ -35,13 +35,13 @@ import {
35
35
  serializeWithEncoding,
36
36
  stringifyError,
37
37
  uint8ArrayToBase64
38
- } from "./chunk-OLGQYFUW.js";
38
+ } from "./chunk-MF42PRF2.js";
39
39
  import {
40
40
  INTERNAL_ERROR_CODE,
41
41
  RivetError,
42
42
  actorNotFound,
43
43
  invalidRequest
44
- } from "./chunk-IXBD7BXC.js";
44
+ } from "./chunk-OUQUIBVW.js";
45
45
 
46
46
  // src/common/actor-router-consts.ts
47
47
  var PATH_CONNECT = "/connect";
@@ -50,6 +50,7 @@ var PATH_WEBSOCKET_PREFIX = "/websocket/";
50
50
  var HEADER_ACTOR_QUERY = "x-rivet-query";
51
51
  var HEADER_ENCODING = "x-rivet-encoding";
52
52
  var HEADER_CONN_PARAMS = "x-rivet-conn-params";
53
+ var HEADER_ORIGINAL_REQUEST_URL = "x-rivet-internal-original-request-url";
53
54
  var HEADER_ACTOR_ID = "x-rivet-actor";
54
55
  var HEADER_ACTOR_GENERATION = "x-rivet-actor-generation";
55
56
  var HEADER_ACTOR_KEY = "x-rivet-actor-key";
@@ -2149,6 +2150,20 @@ async function checkForSchedulingError(group, code, actorId, query, driver, rayI
2149
2150
  return null;
2150
2151
  }
2151
2152
 
2153
+ // src/common/fetch-like.ts
2154
+ function isUrlLike(value) {
2155
+ return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
2156
+ }
2157
+ function isRequestLike(value) {
2158
+ return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
2159
+ }
2160
+ function isResponseLike(value) {
2161
+ return typeof value === "object" && value !== null && typeof value.status === "number" && isHeadersLike(value.headers) && typeof value.arrayBuffer === "function";
2162
+ }
2163
+ function isHeadersLike(value) {
2164
+ return typeof value === "object" && value !== null && typeof value.entries === "function";
2165
+ }
2166
+
2152
2167
  // src/client/lifecycle-errors.ts
2153
2168
  function* walkErrorChain(error, maxDepth = 8) {
2154
2169
  let current = error;
@@ -2581,31 +2596,20 @@ function createQueueSender(senderOptions) {
2581
2596
  };
2582
2597
  }
2583
2598
 
2584
- // src/common/fetch-like.ts
2585
- function isUrlLike(value) {
2586
- return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
2587
- }
2588
- function isRequestLike(value) {
2589
- return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
2590
- }
2591
- function isResponseLike(value) {
2592
- return typeof value === "object" && value !== null && typeof value.status === "number" && isHeadersLike(value.headers) && typeof value.arrayBuffer === "function";
2593
- }
2594
- function isHeadersLike(value) {
2595
- return typeof value === "object" && value !== null && typeof value.entries === "function";
2596
- }
2597
-
2598
2599
  // src/client/raw-utils.ts
2599
2600
  async function rawHttpFetch(driver, target, params, input, init, options = {}) {
2600
2601
  let path;
2602
+ let originalUrl;
2601
2603
  let mergedInit = init || {};
2602
2604
  if (typeof input === "string") {
2603
2605
  path = input;
2604
2606
  } else if (isUrlLike(input)) {
2605
2607
  path = input.pathname + input.search;
2608
+ originalUrl = input.toString();
2606
2609
  } else if (isRequestLike(input)) {
2607
2610
  const url = new URL(input.url);
2608
2611
  path = url.pathname + url.search;
2612
+ originalUrl = url.toString();
2609
2613
  const requestHeaders = new Headers(input.headers);
2610
2614
  const initHeaders = new Headers((init == null ? void 0 : init.headers) || {});
2611
2615
  const mergedHeaders = new Headers(requestHeaders);
@@ -2647,6 +2651,10 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}) {
2647
2651
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
2648
2652
  const url = new URL(`http://actor/request/${normalizedPath}`);
2649
2653
  const proxyRequestHeaders = new Headers(mergedInit.headers);
2654
+ proxyRequestHeaders.delete(HEADER_ORIGINAL_REQUEST_URL);
2655
+ if (originalUrl) {
2656
+ proxyRequestHeaders.set(HEADER_ORIGINAL_REQUEST_URL, originalUrl);
2657
+ }
2650
2658
  if (params) {
2651
2659
  proxyRequestHeaders.set(HEADER_CONN_PARAMS, JSON.stringify(params));
2652
2660
  }
@@ -2776,7 +2784,9 @@ var ActorHandleRaw = class {
2776
2784
  async #sendQueueMessage(name, body, options) {
2777
2785
  return await this.#queueSendMutex.run(async () => {
2778
2786
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
2779
- let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
2787
+ let useQueryTarget = isDynamicActorQuery(
2788
+ this.#actorResolutionState
2789
+ );
2780
2790
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
2781
2791
  let actorId;
2782
2792
  try {
@@ -3125,9 +3135,10 @@ var ActorHandleRaw = class {
3125
3135
  return this.#fetchWithResolvedActor(input, init);
3126
3136
  }
3127
3137
  async #fetchWithResolvedActor(input, init) {
3128
- const maxAttempts = this.#getDynamicQueryMaxAttempts();
3129
- let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
3130
3138
  const { skipReadyWait, ...requestInit } = init ?? {};
3139
+ const hasBody = requestInit.body !== void 0 ? requestInit.body !== null : isRequestLike(input) && input.body !== null;
3140
+ const maxAttempts = hasBody ? 1 : this.#getDynamicQueryMaxAttempts();
3141
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
3131
3142
  const gatewayOptions = resolveActorGatewayOptions(
3132
3143
  this.#gatewayOptions,
3133
3144
  {
@@ -4913,23 +4924,19 @@ async function sendHttpRequestToGateway(runConfig, gatewayUrl, actorRequest, opt
4913
4924
  if (actorRequest.bodyUsed) {
4914
4925
  throw new Error("Request body has already been consumed");
4915
4926
  }
4916
- const reqBody = await actorRequest.arrayBuffer();
4917
- if (reqBody.byteLength !== 0) {
4918
- bodyToSend = reqBody;
4927
+ if (actorRequest.body) {
4928
+ bodyToSend = actorRequest.body;
4919
4929
  guardHeaders.delete("transfer-encoding");
4920
4930
  guardHeaders.delete("content-length");
4921
4931
  }
4922
4932
  }
4923
- const guardRequest = new Request(gatewayUrl, {
4933
+ return fetch(gatewayUrl, {
4924
4934
  method: actorRequest.method,
4925
4935
  headers: guardHeaders,
4926
4936
  body: bodyToSend,
4927
- signal: actorRequest.signal
4937
+ signal: actorRequest.signal,
4938
+ ...bodyToSend ? { duplex: "half" } : {}
4928
4939
  });
4929
- return mutableResponse(await fetch(guardRequest));
4930
- }
4931
- function mutableResponse(fetchRes) {
4932
- return new Response(fetchRes.body, fetchRes);
4933
4940
  }
4934
4941
  function buildGuardHeaders(runConfig, actorRequest, options) {
4935
4942
  const headers = new Headers();
@@ -5899,6 +5906,7 @@ function apiActorToOutput(actor) {
5899
5906
 
5900
5907
  export {
5901
5908
  HEADER_CONN_PARAMS,
5909
+ HEADER_ORIGINAL_REQUEST_URL,
5902
5910
  ALLOWED_PUBLIC_HEADERS,
5903
5911
  ActorClientError,
5904
5912
  ManagerError,
@@ -5915,4 +5923,4 @@ export {
5915
5923
  updateRunnerConfig,
5916
5924
  RemoteEngineControlClient
5917
5925
  };
5918
- //# sourceMappingURL=chunk-YYIDQBBM.js.map
5926
+ //# sourceMappingURL=chunk-VOYNLY57.js.map