rivetkit 2.3.12-rc.4 → 2.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/browser/client.d.ts +17 -4
  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 +3 -19
  9. package/dist/tsup/agent-os/index.cjs.map +1 -1
  10. package/dist/tsup/agent-os/index.d.cts +17 -4
  11. package/dist/tsup/agent-os/index.d.ts +17 -4
  12. package/dist/tsup/agent-os/index.js +3 -19
  13. package/dist/tsup/agent-os/index.js.map +1 -1
  14. package/dist/tsup/{chunk-AF2VKCFA.js → chunk-2EV7TJGB.js} +2 -2
  15. package/dist/tsup/{chunk-SPJORZMM.cjs → chunk-2JSYYH6P.cjs} +1 -1
  16. package/dist/tsup/chunk-2JSYYH6P.cjs.map +1 -0
  17. package/dist/tsup/{chunk-ARFTQ5HY.cjs → chunk-4ATT4NFN.cjs} +17 -11
  18. package/dist/tsup/chunk-4ATT4NFN.cjs.map +1 -0
  19. package/dist/tsup/{chunk-IAH47VDZ.cjs → chunk-4KGXFC6M.cjs} +2 -19
  20. package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
  21. package/dist/tsup/{chunk-DLQSZ6Q7.js → chunk-6W5VGLFT.js} +2 -19
  22. package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
  23. package/dist/tsup/{chunk-GMBCKV6C.js → chunk-AH4ZKYQ4.js} +3 -3
  24. package/dist/tsup/{chunk-NVMHEG5J.js → chunk-AS47KFZD.js} +2 -2
  25. package/dist/tsup/{chunk-NKLM6C5A.cjs → chunk-BGHQTX2Y.cjs} +10 -10
  26. package/dist/tsup/{chunk-NKLM6C5A.cjs.map → chunk-BGHQTX2Y.cjs.map} +1 -1
  27. package/dist/tsup/{chunk-S3GXVCIM.cjs → chunk-BVTP654F.cjs} +4 -4
  28. package/dist/tsup/{chunk-S3GXVCIM.cjs.map → chunk-BVTP654F.cjs.map} +1 -1
  29. package/dist/tsup/{chunk-3CBQIP37.js → chunk-F3O3L4BR.js} +4 -4
  30. package/dist/tsup/{chunk-F7G5WHOD.cjs → chunk-I47EOXIN.cjs} +202 -194
  31. package/dist/tsup/chunk-I47EOXIN.cjs.map +1 -0
  32. package/dist/tsup/{chunk-P5JJG4KY.js → chunk-J5JIPBBI.js} +2 -2
  33. package/dist/tsup/{chunk-4LRWLBTR.cjs → chunk-NLQMRNGG.cjs} +3 -3
  34. package/dist/tsup/{chunk-4LRWLBTR.cjs.map → chunk-NLQMRNGG.cjs.map} +1 -1
  35. package/dist/tsup/{chunk-XDYECGCT.cjs → chunk-NOU4GGLT.cjs} +7 -7
  36. package/dist/tsup/{chunk-XDYECGCT.cjs.map → chunk-NOU4GGLT.cjs.map} +1 -1
  37. package/dist/tsup/{chunk-IXBD7BXC.js → chunk-OUQUIBVW.js} +1 -1
  38. package/dist/tsup/chunk-OUQUIBVW.js.map +1 -0
  39. package/dist/tsup/{chunk-O74736N5.js → chunk-RZPPOGEQ.js} +38 -30
  40. package/dist/tsup/chunk-RZPPOGEQ.js.map +1 -0
  41. package/dist/tsup/{chunk-BQ7YJ3PG.js → chunk-UQINOZ6M.js} +2 -2
  42. package/dist/tsup/{chunk-64DT44V2.js → chunk-UZWKXBMV.js} +9 -3
  43. package/dist/tsup/chunk-UZWKXBMV.js.map +1 -0
  44. package/dist/tsup/{chunk-JIOLC5I2.cjs → chunk-W6EVBFUB.cjs} +3 -3
  45. package/dist/tsup/{chunk-JIOLC5I2.cjs.map → chunk-W6EVBFUB.cjs.map} +1 -1
  46. package/dist/tsup/{chunk-OCXHNHGQ.cjs → chunk-X53X7M5A.cjs} +3 -3
  47. package/dist/tsup/{chunk-OCXHNHGQ.cjs.map → chunk-X53X7M5A.cjs.map} +1 -1
  48. package/dist/tsup/client/mod.cjs +6 -6
  49. package/dist/tsup/client/mod.d.cts +2 -2
  50. package/dist/tsup/client/mod.d.ts +2 -2
  51. package/dist/tsup/client/mod.js +5 -5
  52. package/dist/tsup/common/log.cjs +3 -3
  53. package/dist/tsup/common/log.js +2 -2
  54. package/dist/tsup/common/websocket.cjs +4 -4
  55. package/dist/tsup/common/websocket.js +3 -3
  56. package/dist/tsup/{config-DzaddF-j.d.ts → config-BGTanB_3.d.ts} +19 -10
  57. package/dist/tsup/{config-VxDc6yMu.d.cts → config-NHz6oMb9.d.cts} +19 -10
  58. package/dist/tsup/{context-Cn8CIrOR.d.cts → context-DB8zG_Ib.d.cts} +1 -1
  59. package/dist/tsup/{context-B6HYokje.d.ts → context-SHomdVV8.d.ts} +1 -1
  60. package/dist/tsup/db/drizzle.cjs +3 -3
  61. package/dist/tsup/db/drizzle.js +2 -2
  62. package/dist/tsup/db/mod.cjs +4 -4
  63. package/dist/tsup/db/mod.js +3 -3
  64. package/dist/tsup/dynamic/mod.cjs +2 -2
  65. package/dist/tsup/dynamic/mod.d.cts +1 -1
  66. package/dist/tsup/dynamic/mod.d.ts +1 -1
  67. package/dist/tsup/dynamic/mod.js +1 -1
  68. package/dist/tsup/inspector/mod.cjs +6 -6
  69. package/dist/tsup/inspector/mod.js +5 -5
  70. package/dist/tsup/inspector/workflow.cjs +5 -5
  71. package/dist/tsup/inspector/workflow.js +4 -4
  72. package/dist/tsup/inspector-tab/mod.cjs +2 -2
  73. package/dist/tsup/inspector-tab/mod.d.cts +2 -2
  74. package/dist/tsup/inspector-tab/mod.d.ts +2 -2
  75. package/dist/tsup/inspector-tab/mod.js +1 -1
  76. package/dist/tsup/mod.cjs +444 -199
  77. package/dist/tsup/mod.cjs.map +1 -1
  78. package/dist/tsup/mod.d.cts +3 -3
  79. package/dist/tsup/mod.d.ts +3 -3
  80. package/dist/tsup/mod.js +323 -78
  81. package/dist/tsup/mod.js.map +1 -1
  82. package/dist/tsup/test/mod.cjs +7 -7
  83. package/dist/tsup/test/mod.d.cts +1 -1
  84. package/dist/tsup/test/mod.d.ts +1 -1
  85. package/dist/tsup/test/mod.js +5 -5
  86. package/dist/tsup/utils.cjs +3 -3
  87. package/dist/tsup/utils.js +2 -2
  88. package/dist/tsup/workflow/mod.cjs +14 -14
  89. package/dist/tsup/workflow/mod.d.cts +3 -3
  90. package/dist/tsup/workflow/mod.d.ts +3 -3
  91. package/dist/tsup/workflow/mod.js +6 -6
  92. package/package.json +9 -8
  93. package/src/actor/config.test.ts +0 -8
  94. package/src/actor/config.ts +1 -24
  95. package/src/actor/errors.ts +2 -1
  96. package/src/client/actor-handle.ts +10 -3
  97. package/src/client/raw-utils.ts +8 -0
  98. package/src/common/actor-router-consts.ts +2 -0
  99. package/src/engine-client/actor-http-client.ts +6 -22
  100. package/src/engine-client/mod.ts +1 -1
  101. package/src/registry/config/index.ts +27 -1
  102. package/src/registry/index.ts +48 -14
  103. package/src/registry/napi-runtime.ts +32 -5
  104. package/src/registry/native-http.ts +225 -0
  105. package/src/registry/native.ts +130 -65
  106. package/src/registry/runtime.ts +30 -3
  107. package/src/utils/env-vars.ts +4 -0
  108. package/dist/tsup/chunk-64DT44V2.js.map +0 -1
  109. package/dist/tsup/chunk-ARFTQ5HY.cjs.map +0 -1
  110. package/dist/tsup/chunk-DLQSZ6Q7.js.map +0 -1
  111. package/dist/tsup/chunk-F7G5WHOD.cjs.map +0 -1
  112. package/dist/tsup/chunk-IAH47VDZ.cjs.map +0 -1
  113. package/dist/tsup/chunk-IXBD7BXC.js.map +0 -1
  114. package/dist/tsup/chunk-O74736N5.js.map +0 -1
  115. package/dist/tsup/chunk-SPJORZMM.cjs.map +0 -1
  116. /package/dist/tsup/{chunk-AF2VKCFA.js.map → chunk-2EV7TJGB.js.map} +0 -0
  117. /package/dist/tsup/{chunk-GMBCKV6C.js.map → chunk-AH4ZKYQ4.js.map} +0 -0
  118. /package/dist/tsup/{chunk-NVMHEG5J.js.map → chunk-AS47KFZD.js.map} +0 -0
  119. /package/dist/tsup/{chunk-3CBQIP37.js.map → chunk-F3O3L4BR.js.map} +0 -0
  120. /package/dist/tsup/{chunk-P5JJG4KY.js.map → chunk-J5JIPBBI.js.map} +0 -0
  121. /package/dist/tsup/{chunk-BQ7YJ3PG.js.map → chunk-UQINOZ6M.js.map} +0 -0
@@ -1355,7 +1355,6 @@ declare const ActorConfigSchema: z.ZodObject<{
1355
1355
  options: z.ZodPrefault<z.ZodObject<{
1356
1356
  name: z.ZodOptional<z.ZodString>;
1357
1357
  icon: z.ZodOptional<z.ZodString>;
1358
- maxActions: z.ZodDefault<z.ZodNumber>;
1359
1358
  enableActorRuntimeSocket: z.ZodDefault<z.ZodBoolean>;
1360
1359
  canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
1361
1360
  createVarsTimeout: z.ZodDefault<z.ZodNumber>;
@@ -1680,6 +1679,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1680
1679
  engineHost: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1681
1680
  enginePort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1682
1681
  engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1682
+ startServices: z$2.ZodOptional<z$2.ZodBoolean>;
1683
1683
  configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
1684
1684
  name: z$2.ZodOptional<z$2.ZodString>;
1685
1685
  url: z$2.ZodString;
@@ -1711,6 +1711,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1711
1711
  backend: "local" | "remote";
1712
1712
  } | undefined;
1713
1713
  endpoint: string | undefined;
1714
+ startServices: boolean;
1714
1715
  namespace: string;
1715
1716
  token: string | undefined;
1716
1717
  publicEndpoint: string | undefined;
@@ -1822,6 +1823,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1822
1823
  };
1823
1824
  staticDir?: string | undefined;
1824
1825
  httpHost?: string | undefined;
1826
+ startServices?: boolean | undefined;
1825
1827
  configurePool?: {
1826
1828
  url: string;
1827
1829
  name?: string | undefined;
@@ -1862,6 +1864,12 @@ interface RuntimeHttpRequest {
1862
1864
  headers?: Record<string, string>;
1863
1865
  body?: RuntimeBytes;
1864
1866
  }
1867
+ interface RuntimeHttpResponseBodyStream {
1868
+ cancelled(): Promise<void>;
1869
+ write(chunk: Uint8Array): Promise<void>;
1870
+ end(): Promise<void>;
1871
+ error(message: string): Promise<void>;
1872
+ }
1865
1873
  interface RuntimeStateDeltaPayload {
1866
1874
  state?: RuntimeBytes;
1867
1875
  connHibernation: Array<{
@@ -2013,7 +2021,6 @@ interface RuntimeSqlRunResult {
2013
2021
  interface RuntimeActorConfig {
2014
2022
  name?: string;
2015
2023
  icon?: string;
2016
- maxActions?: number;
2017
2024
  hasDatabase?: boolean;
2018
2025
  remoteSqlite?: boolean;
2019
2026
  sqliteProfiling?: SqliteProfilingOptions;
@@ -2070,6 +2077,8 @@ interface RuntimeServeConfig {
2070
2077
  namespace: string;
2071
2078
  poolName: string;
2072
2079
  engineBinaryPath?: string;
2080
+ startServices?: boolean;
2081
+ servicesBinaryPath?: string;
2073
2082
  engineHost?: string;
2074
2083
  enginePort?: number;
2075
2084
  handleInspectorHttpInRuntime?: boolean;
@@ -2094,12 +2103,16 @@ interface RuntimeServerlessRequest {
2094
2103
  headers: Record<string, string>;
2095
2104
  body: RuntimeBytes;
2096
2105
  }
2106
+ interface RuntimeApplicationRequest extends RuntimeServerlessRequest {
2107
+ cancelToken?: CancellationTokenHandle;
2108
+ }
2097
2109
  interface RuntimeApplicationResponse {
2098
2110
  status: number;
2099
2111
  headers: Record<string, string>;
2100
- body: RuntimeBytes;
2112
+ body?: RuntimeBytes;
2113
+ stream?: boolean;
2101
2114
  }
2102
- type RuntimeApplicationFetch = (request: RuntimeServerlessRequest) => Promise<RuntimeApplicationResponse>;
2115
+ type RuntimeApplicationFetch = (request: RuntimeApplicationRequest, responseBodyStream?: RuntimeHttpResponseBodyStream) => Promise<RuntimeApplicationResponse>;
2103
2116
  interface RuntimeApplicationListenerConfig extends RuntimeListenerConfig {
2104
2117
  application: RuntimeApplicationFetch;
2105
2118
  }
@@ -201,7 +201,7 @@ function noopNext() {
201
201
  // package.json
202
202
  var package_default = {
203
203
  name: "rivetkit",
204
- version: "2.3.12-rc.4",
204
+ version: "2.3.13",
205
205
  description: "Lightweight libraries for building stateful actors on edge platforms",
206
206
  license: "Apache-2.0",
207
207
  keywords: [
@@ -411,6 +411,7 @@ var package_default = {
411
411
  dependencies: {
412
412
  "@hono/zod-openapi": "^1.1.5",
413
413
  "@rivet-dev/agent-os-core": "^0.1.1",
414
+ "@rivet-dev/services": "^0.1.5",
414
415
  "@rivetkit/bare-ts": "^0.6.2",
415
416
  "@rivetkit/engine-cli": "workspace:*",
416
417
  "@rivetkit/engine-envoy-protocol": "workspace:*",
@@ -1129,6 +1130,7 @@ var PATH_WEBSOCKET_BASE = "/websocket";
1129
1130
  var PATH_WEBSOCKET_PREFIX = "/websocket/";
1130
1131
  var HEADER_ENCODING = "x-rivet-encoding";
1131
1132
  var HEADER_CONN_PARAMS = "x-rivet-conn-params";
1133
+ var HEADER_ORIGINAL_REQUEST_URL = "x-rivet-internal-original-request-url";
1132
1134
  var HEADER_RIVET_TOKEN = "x-rivet-token";
1133
1135
  var HEADER_RIVET_TARGET = "x-rivet-target";
1134
1136
  var HEADER_RIVET_ACTOR = "x-rivet-actor";
@@ -1155,23 +1157,19 @@ async function sendHttpRequestToGateway(runConfig, gatewayUrl, actorRequest, opt
1155
1157
  if (actorRequest.bodyUsed) {
1156
1158
  throw new Error("Request body has already been consumed");
1157
1159
  }
1158
- const reqBody = await actorRequest.arrayBuffer();
1159
- if (reqBody.byteLength !== 0) {
1160
- bodyToSend = reqBody;
1160
+ if (actorRequest.body) {
1161
+ bodyToSend = actorRequest.body;
1161
1162
  guardHeaders.delete("transfer-encoding");
1162
1163
  guardHeaders.delete("content-length");
1163
1164
  }
1164
1165
  }
1165
- const guardRequest = new Request(gatewayUrl, {
1166
+ return fetch(gatewayUrl, {
1166
1167
  method: actorRequest.method,
1167
1168
  headers: guardHeaders,
1168
1169
  body: bodyToSend,
1169
- signal: actorRequest.signal
1170
+ signal: actorRequest.signal,
1171
+ ...bodyToSend ? { duplex: "half" } : {}
1170
1172
  });
1171
- return mutableResponse(await fetch(guardRequest));
1172
- }
1173
- function mutableResponse(fetchRes) {
1174
- return new Response(fetchRes.body, fetchRes);
1175
1173
  }
1176
1174
  function buildGuardHeaders(runConfig, actorRequest, options) {
1177
1175
  const headers = new Headers();
@@ -5883,6 +5881,17 @@ var ActorConnRaw = class {
5883
5881
  }
5884
5882
  };
5885
5883
 
5884
+ // src/common/fetch-like.ts
5885
+ function isUrlLike(value) {
5886
+ return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
5887
+ }
5888
+ function isRequestLike(value) {
5889
+ return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
5890
+ }
5891
+ function isHeadersLike(value) {
5892
+ return typeof value === "object" && value !== null && typeof value.entries === "function";
5893
+ }
5894
+
5886
5895
  // src/common/database/shared.ts
5887
5896
  var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
5888
5897
  var AsyncMutex = class {
@@ -5911,28 +5920,20 @@ var AsyncMutex = class {
5911
5920
  }
5912
5921
  };
5913
5922
 
5914
- // src/common/fetch-like.ts
5915
- function isUrlLike(value) {
5916
- return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
5917
- }
5918
- function isRequestLike(value) {
5919
- return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
5920
- }
5921
- function isHeadersLike(value) {
5922
- return typeof value === "object" && value !== null && typeof value.entries === "function";
5923
- }
5924
-
5925
5923
  // src/client/raw-utils.ts
5926
5924
  async function rawHttpFetch(driver, target, params, input, init, options = {}) {
5927
5925
  let path;
5926
+ let originalUrl;
5928
5927
  let mergedInit = init || {};
5929
5928
  if (typeof input === "string") {
5930
5929
  path = input;
5931
5930
  } else if (isUrlLike(input)) {
5932
5931
  path = input.pathname + input.search;
5932
+ originalUrl = input.toString();
5933
5933
  } else if (isRequestLike(input)) {
5934
5934
  const url = new URL(input.url);
5935
5935
  path = url.pathname + url.search;
5936
+ originalUrl = url.toString();
5936
5937
  const requestHeaders = new Headers(input.headers);
5937
5938
  const initHeaders = new Headers(init?.headers || {});
5938
5939
  const mergedHeaders = new Headers(requestHeaders);
@@ -5974,6 +5975,10 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}) {
5974
5975
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
5975
5976
  const url = new URL(`http://actor/request/${normalizedPath}`);
5976
5977
  const proxyRequestHeaders = new Headers(mergedInit.headers);
5978
+ proxyRequestHeaders.delete(HEADER_ORIGINAL_REQUEST_URL);
5979
+ if (originalUrl) {
5980
+ proxyRequestHeaders.set(HEADER_ORIGINAL_REQUEST_URL, originalUrl);
5981
+ }
5977
5982
  if (params) {
5978
5983
  proxyRequestHeaders.set(HEADER_CONN_PARAMS, JSON.stringify(params));
5979
5984
  }
@@ -6103,7 +6108,9 @@ var ActorHandleRaw = class {
6103
6108
  async #sendQueueMessage(name, body, options) {
6104
6109
  return await this.#queueSendMutex.run(async () => {
6105
6110
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
6106
- let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
6111
+ let useQueryTarget = isDynamicActorQuery(
6112
+ this.#actorResolutionState
6113
+ );
6107
6114
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
6108
6115
  let actorId;
6109
6116
  try {
@@ -6452,9 +6459,10 @@ var ActorHandleRaw = class {
6452
6459
  return this.#fetchWithResolvedActor(input, init);
6453
6460
  }
6454
6461
  async #fetchWithResolvedActor(input, init) {
6455
- const maxAttempts = this.#getDynamicQueryMaxAttempts();
6456
- let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
6457
6462
  const { skipReadyWait, ...requestInit } = init ?? {};
6463
+ const hasBody = requestInit.body !== void 0 ? requestInit.body !== null : isRequestLike(input) && input.body !== null;
6464
+ const maxAttempts = hasBody ? 1 : this.#getDynamicQueryMaxAttempts();
6465
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
6458
6466
  const gatewayOptions = resolveActorGatewayOptions(
6459
6467
  this.#gatewayOptions,
6460
6468
  {