@rivetkit/cloudflare-workers 2.0.3 → 2.0.5

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.
package/dist/mod.d.cts CHANGED
@@ -1,12 +1,11 @@
1
- import * as hono_types from 'hono/types';
1
+ import * as rivetkit from 'rivetkit';
2
+ import { Client, ActorKey, Registry } from 'rivetkit';
3
+ export { Client } from 'rivetkit';
4
+ import * as rivetkit_log from 'rivetkit/log';
2
5
  import * as hono from 'hono';
3
- import { Hono } from 'hono';
4
- import * as rivetkit_utils from 'rivetkit/utils';
5
6
  import * as rivetkit_driver_helpers from 'rivetkit/driver-helpers';
6
- import * as rivetkit from 'rivetkit';
7
- import { ActorKey, Registry } from 'rivetkit';
7
+ import * as rivetkit_utils from 'rivetkit/utils';
8
8
  import { z } from 'zod';
9
- import { Client } from 'rivetkit/client';
10
9
  import { DurableObject } from 'cloudflare:workers';
11
10
 
12
11
  interface DriverContext {
@@ -14,6 +13,23 @@ interface DriverContext {
14
13
  }
15
14
 
16
15
  declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
16
+ api: z.ZodDefault<z.ZodObject<{
17
+ host: z.ZodDefault<z.ZodString>;
18
+ port: z.ZodDefault<z.ZodNumber>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ host: string;
21
+ port: number;
22
+ }, {
23
+ host?: string | undefined;
24
+ port?: number | undefined;
25
+ }>>;
26
+ endpoint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
27
+ namespace: z.ZodDefault<z.ZodString>;
28
+ runnerName: z.ZodDefault<z.ZodString>;
29
+ encoding: z.ZodDefault<z.ZodEnum<["json", "cbor", "bare"]>>;
30
+ transport: z.ZodDefault<z.ZodEnum<["websocket", "sse"]>>;
31
+ getUpgradeWebSocket: z.ZodOptional<z.ZodType<() => rivetkit_utils.UpgradeWebSocket, z.ZodTypeDef, () => rivetkit_utils.UpgradeWebSocket>>;
32
+ } & {
17
33
  driver: z.ZodOptional<z.ZodObject<{
18
34
  name: z.ZodString;
19
35
  manager: z.ZodType<(registryConfig: rivetkit.RegistryConfig, runConfig: rivetkit.RunConfig) => rivetkit_driver_helpers.ManagerDriver, z.ZodTypeDef, (registryConfig: rivetkit.RegistryConfig, runConfig: rivetkit.RunConfig) => rivetkit_driver_helpers.ManagerDriver>;
@@ -27,9 +43,6 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
27
43
  name: string;
28
44
  manager: (registryConfig: rivetkit.RegistryConfig, runConfig: rivetkit.RunConfig) => rivetkit_driver_helpers.ManagerDriver;
29
45
  }>>;
30
- engine: z.ZodOptional<z.ZodString>;
31
- getUpgradeWebSocket: z.ZodOptional<z.ZodType<() => rivetkit_utils.UpgradeWebSocket, z.ZodTypeDef, () => rivetkit_utils.UpgradeWebSocket>>;
32
- role: z.ZodDefault<z.ZodOptional<z.ZodEnum<["all", "server", "runner"]>>>;
33
46
  cors: z.ZodOptional<z.ZodType<{
34
47
  origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
35
48
  allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
@@ -90,11 +103,38 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
90
103
  token?: ((...args: unknown[]) => string) | undefined;
91
104
  defaultEndpoint?: string | undefined;
92
105
  }>>>;
106
+ disableServer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
107
+ disableActorDriver: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
93
108
  basePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
94
- }, "driver" | "getUpgradeWebSocket"> & {
95
- app: z.ZodOptional<z.ZodType<Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">, z.ZodTypeDef, Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">>>;
109
+ noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
110
+ logging: z.ZodDefault<z.ZodOptional<z.ZodObject<{
111
+ baseLogger: z.ZodOptional<z.ZodType<rivetkit_log.Logger, z.ZodTypeDef, rivetkit_log.Logger>>;
112
+ level: z.ZodOptional<z.ZodEnum<["trace", "debug", "info", "warn", "error", "fatal", "silent"]>>;
113
+ }, "strip", z.ZodTypeAny, {
114
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
115
+ baseLogger?: rivetkit_log.Logger | undefined;
116
+ }, {
117
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
118
+ baseLogger?: rivetkit_log.Logger | undefined;
119
+ }>>>;
120
+ }, "getUpgradeWebSocket" | "driver"> & {
121
+ /** Path that the Rivet manager API will be mounted. */
122
+ managerPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
123
+ fetch: z.ZodOptional<z.ZodType<ExportedHandlerFetchHandler<{
124
+ RIVET: Client<any>;
125
+ }, unknown>, z.ZodTypeDef, ExportedHandlerFetchHandler<{
126
+ RIVET: Client<any>;
127
+ }, unknown>>>;
96
128
  }, "strip", z.ZodTypeAny, {
97
- role: "all" | "server" | "runner";
129
+ api: {
130
+ host: string;
131
+ port: number;
132
+ };
133
+ endpoint: string | null;
134
+ namespace: string;
135
+ runnerName: string;
136
+ encoding: "json" | "cbor" | "bare";
137
+ transport: "websocket" | "sse";
98
138
  maxIncomingMessageSize: number;
99
139
  inspector: {
100
140
  enabled: boolean;
@@ -109,8 +149,15 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
109
149
  token: (...args: unknown[]) => string;
110
150
  defaultEndpoint?: string | undefined;
111
151
  };
152
+ disableServer: boolean;
153
+ disableActorDriver: boolean;
112
154
  basePath: string;
113
- engine?: string | undefined;
155
+ noWelcome: boolean;
156
+ logging: {
157
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
158
+ baseLogger?: rivetkit_log.Logger | undefined;
159
+ };
160
+ managerPath: string;
114
161
  cors?: {
115
162
  origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
116
163
  allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
@@ -119,10 +166,19 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
119
166
  credentials?: boolean;
120
167
  exposeHeaders?: string[];
121
168
  } | undefined;
122
- app?: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/"> | undefined;
169
+ fetch?: ExportedHandlerFetchHandler<{
170
+ RIVET: Client<any>;
171
+ }, unknown> | undefined;
123
172
  }, {
124
- engine?: string | undefined;
125
- role?: "all" | "server" | "runner" | undefined;
173
+ api?: {
174
+ host?: string | undefined;
175
+ port?: number | undefined;
176
+ } | undefined;
177
+ endpoint?: string | null | undefined;
178
+ namespace?: string | undefined;
179
+ runnerName?: string | undefined;
180
+ encoding?: "json" | "cbor" | "bare" | undefined;
181
+ transport?: "websocket" | "sse" | undefined;
126
182
  cors?: {
127
183
  origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
128
184
  allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
@@ -145,8 +201,18 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
145
201
  token?: ((...args: unknown[]) => string) | undefined;
146
202
  defaultEndpoint?: string | undefined;
147
203
  } | undefined;
204
+ disableServer?: boolean | undefined;
205
+ disableActorDriver?: boolean | undefined;
148
206
  basePath?: string | undefined;
149
- app?: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/"> | undefined;
207
+ noWelcome?: boolean | undefined;
208
+ logging?: {
209
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
210
+ baseLogger?: rivetkit_log.Logger | undefined;
211
+ } | undefined;
212
+ managerPath?: string | undefined;
213
+ fetch?: ExportedHandlerFetchHandler<{
214
+ RIVET: Client<any>;
215
+ }, unknown> | undefined;
150
216
  }>>;
151
217
  type InputConfig = z.input<typeof ConfigSchema>;
152
218
 
@@ -169,11 +235,6 @@ interface Handler {
169
235
  handler: ExportedHandler<Bindings>;
170
236
  ActorHandler: DurableObjectConstructor;
171
237
  }
172
- interface SetupOutput<A extends Registry<any>> {
173
- client: Client<A>;
174
- createHandler: (hono?: Hono) => Handler;
175
- }
176
- declare function createServerHandler<R extends Registry<any>>(registry: R, inputConfig?: InputConfig): Handler;
177
- declare function createServer<R extends Registry<any>>(registry: R, inputConfig?: InputConfig): SetupOutput<R>;
238
+ declare function createHandler<R extends Registry<any>>(registry: R, inputConfig?: InputConfig): Handler;
178
239
 
179
- export { type Bindings, type InputConfig as Config, type DriverContext, createServer, createServerHandler };
240
+ export { type Bindings, type InputConfig as Config, type DriverContext, createHandler };
package/dist/mod.d.ts CHANGED
@@ -1,12 +1,11 @@
1
- import * as hono_types from 'hono/types';
1
+ import * as rivetkit from 'rivetkit';
2
+ import { Client, ActorKey, Registry } from 'rivetkit';
3
+ export { Client } from 'rivetkit';
4
+ import * as rivetkit_log from 'rivetkit/log';
2
5
  import * as hono from 'hono';
3
- import { Hono } from 'hono';
4
- import * as rivetkit_utils from 'rivetkit/utils';
5
6
  import * as rivetkit_driver_helpers from 'rivetkit/driver-helpers';
6
- import * as rivetkit from 'rivetkit';
7
- import { ActorKey, Registry } from 'rivetkit';
7
+ import * as rivetkit_utils from 'rivetkit/utils';
8
8
  import { z } from 'zod';
9
- import { Client } from 'rivetkit/client';
10
9
  import { DurableObject } from 'cloudflare:workers';
11
10
 
12
11
  interface DriverContext {
@@ -14,6 +13,23 @@ interface DriverContext {
14
13
  }
15
14
 
16
15
  declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
16
+ api: z.ZodDefault<z.ZodObject<{
17
+ host: z.ZodDefault<z.ZodString>;
18
+ port: z.ZodDefault<z.ZodNumber>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ host: string;
21
+ port: number;
22
+ }, {
23
+ host?: string | undefined;
24
+ port?: number | undefined;
25
+ }>>;
26
+ endpoint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
27
+ namespace: z.ZodDefault<z.ZodString>;
28
+ runnerName: z.ZodDefault<z.ZodString>;
29
+ encoding: z.ZodDefault<z.ZodEnum<["json", "cbor", "bare"]>>;
30
+ transport: z.ZodDefault<z.ZodEnum<["websocket", "sse"]>>;
31
+ getUpgradeWebSocket: z.ZodOptional<z.ZodType<() => rivetkit_utils.UpgradeWebSocket, z.ZodTypeDef, () => rivetkit_utils.UpgradeWebSocket>>;
32
+ } & {
17
33
  driver: z.ZodOptional<z.ZodObject<{
18
34
  name: z.ZodString;
19
35
  manager: z.ZodType<(registryConfig: rivetkit.RegistryConfig, runConfig: rivetkit.RunConfig) => rivetkit_driver_helpers.ManagerDriver, z.ZodTypeDef, (registryConfig: rivetkit.RegistryConfig, runConfig: rivetkit.RunConfig) => rivetkit_driver_helpers.ManagerDriver>;
@@ -27,9 +43,6 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
27
43
  name: string;
28
44
  manager: (registryConfig: rivetkit.RegistryConfig, runConfig: rivetkit.RunConfig) => rivetkit_driver_helpers.ManagerDriver;
29
45
  }>>;
30
- engine: z.ZodOptional<z.ZodString>;
31
- getUpgradeWebSocket: z.ZodOptional<z.ZodType<() => rivetkit_utils.UpgradeWebSocket, z.ZodTypeDef, () => rivetkit_utils.UpgradeWebSocket>>;
32
- role: z.ZodDefault<z.ZodOptional<z.ZodEnum<["all", "server", "runner"]>>>;
33
46
  cors: z.ZodOptional<z.ZodType<{
34
47
  origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
35
48
  allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
@@ -90,11 +103,38 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
90
103
  token?: ((...args: unknown[]) => string) | undefined;
91
104
  defaultEndpoint?: string | undefined;
92
105
  }>>>;
106
+ disableServer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
107
+ disableActorDriver: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
93
108
  basePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
94
- }, "driver" | "getUpgradeWebSocket"> & {
95
- app: z.ZodOptional<z.ZodType<Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">, z.ZodTypeDef, Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">>>;
109
+ noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
110
+ logging: z.ZodDefault<z.ZodOptional<z.ZodObject<{
111
+ baseLogger: z.ZodOptional<z.ZodType<rivetkit_log.Logger, z.ZodTypeDef, rivetkit_log.Logger>>;
112
+ level: z.ZodOptional<z.ZodEnum<["trace", "debug", "info", "warn", "error", "fatal", "silent"]>>;
113
+ }, "strip", z.ZodTypeAny, {
114
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
115
+ baseLogger?: rivetkit_log.Logger | undefined;
116
+ }, {
117
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
118
+ baseLogger?: rivetkit_log.Logger | undefined;
119
+ }>>>;
120
+ }, "getUpgradeWebSocket" | "driver"> & {
121
+ /** Path that the Rivet manager API will be mounted. */
122
+ managerPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
123
+ fetch: z.ZodOptional<z.ZodType<ExportedHandlerFetchHandler<{
124
+ RIVET: Client<any>;
125
+ }, unknown>, z.ZodTypeDef, ExportedHandlerFetchHandler<{
126
+ RIVET: Client<any>;
127
+ }, unknown>>>;
96
128
  }, "strip", z.ZodTypeAny, {
97
- role: "all" | "server" | "runner";
129
+ api: {
130
+ host: string;
131
+ port: number;
132
+ };
133
+ endpoint: string | null;
134
+ namespace: string;
135
+ runnerName: string;
136
+ encoding: "json" | "cbor" | "bare";
137
+ transport: "websocket" | "sse";
98
138
  maxIncomingMessageSize: number;
99
139
  inspector: {
100
140
  enabled: boolean;
@@ -109,8 +149,15 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
109
149
  token: (...args: unknown[]) => string;
110
150
  defaultEndpoint?: string | undefined;
111
151
  };
152
+ disableServer: boolean;
153
+ disableActorDriver: boolean;
112
154
  basePath: string;
113
- engine?: string | undefined;
155
+ noWelcome: boolean;
156
+ logging: {
157
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
158
+ baseLogger?: rivetkit_log.Logger | undefined;
159
+ };
160
+ managerPath: string;
114
161
  cors?: {
115
162
  origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
116
163
  allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
@@ -119,10 +166,19 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
119
166
  credentials?: boolean;
120
167
  exposeHeaders?: string[];
121
168
  } | undefined;
122
- app?: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/"> | undefined;
169
+ fetch?: ExportedHandlerFetchHandler<{
170
+ RIVET: Client<any>;
171
+ }, unknown> | undefined;
123
172
  }, {
124
- engine?: string | undefined;
125
- role?: "all" | "server" | "runner" | undefined;
173
+ api?: {
174
+ host?: string | undefined;
175
+ port?: number | undefined;
176
+ } | undefined;
177
+ endpoint?: string | null | undefined;
178
+ namespace?: string | undefined;
179
+ runnerName?: string | undefined;
180
+ encoding?: "json" | "cbor" | "bare" | undefined;
181
+ transport?: "websocket" | "sse" | undefined;
126
182
  cors?: {
127
183
  origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
128
184
  allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
@@ -145,8 +201,18 @@ declare const ConfigSchema: z.ZodDefault<z.ZodObject<Omit<{
145
201
  token?: ((...args: unknown[]) => string) | undefined;
146
202
  defaultEndpoint?: string | undefined;
147
203
  } | undefined;
204
+ disableServer?: boolean | undefined;
205
+ disableActorDriver?: boolean | undefined;
148
206
  basePath?: string | undefined;
149
- app?: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/"> | undefined;
207
+ noWelcome?: boolean | undefined;
208
+ logging?: {
209
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
210
+ baseLogger?: rivetkit_log.Logger | undefined;
211
+ } | undefined;
212
+ managerPath?: string | undefined;
213
+ fetch?: ExportedHandlerFetchHandler<{
214
+ RIVET: Client<any>;
215
+ }, unknown> | undefined;
150
216
  }>>;
151
217
  type InputConfig = z.input<typeof ConfigSchema>;
152
218
 
@@ -169,11 +235,6 @@ interface Handler {
169
235
  handler: ExportedHandler<Bindings>;
170
236
  ActorHandler: DurableObjectConstructor;
171
237
  }
172
- interface SetupOutput<A extends Registry<any>> {
173
- client: Client<A>;
174
- createHandler: (hono?: Hono) => Handler;
175
- }
176
- declare function createServerHandler<R extends Registry<any>>(registry: R, inputConfig?: InputConfig): Handler;
177
- declare function createServer<R extends Registry<any>>(registry: R, inputConfig?: InputConfig): SetupOutput<R>;
238
+ declare function createHandler<R extends Registry<any>>(registry: R, inputConfig?: InputConfig): Handler;
178
239
 
179
- export { type Bindings, type InputConfig as Config, type DriverContext, createServer, createServerHandler };
240
+ export { type Bindings, type InputConfig as Config, type DriverContext, createHandler };
package/dist/mod.js CHANGED
@@ -1,15 +1,10 @@
1
1
  // src/handler.ts
2
2
  import { env as env2 } from "cloudflare:workers";
3
- import { Hono } from "hono";
4
3
 
5
4
  // src/actor-handler-do.ts
6
5
  import { DurableObject, env } from "cloudflare:workers";
7
6
  import invariant2 from "invariant";
8
- import {
9
- createActorRouter,
10
- createClientWithDriver,
11
- createInlineClientDriver
12
- } from "rivetkit";
7
+ import { createActorRouter, createClientWithDriver } from "rivetkit";
13
8
  import { serializeEmptyPersistData } from "rivetkit/driver-helpers";
14
9
 
15
10
  // src/actor-driver.ts
@@ -132,9 +127,8 @@ function createCloudflareActorsActorDriverBuilder(globalState) {
132
127
 
133
128
  // src/log.ts
134
129
  import { getLogger } from "rivetkit/log";
135
- var LOGGER_NAME = "driver-cloudflare-workers";
136
130
  function logger() {
137
- return getLogger(LOGGER_NAME);
131
+ return getLogger("driver-cloudflare-workers");
138
132
  }
139
133
 
140
134
  // src/actor-handler-do.ts
@@ -166,7 +160,7 @@ function createActorDurableObject(registry, rootRunConfig) {
166
160
  if (!name) throw new Error("missing actor name");
167
161
  const key = res.get(KEYS.KEY);
168
162
  if (!key) throw new Error("missing actor key");
169
- logger().debug("already initialized", { name, key });
163
+ logger().debug({ msg: "already initialized", name, key });
170
164
  this.#initialized = { name, key };
171
165
  this.#initializedPromise.resolve();
172
166
  } else {
@@ -186,9 +180,7 @@ function createActorDurableObject(registry, rootRunConfig) {
186
180
  registry.config,
187
181
  runConfig
188
182
  );
189
- const inlineClient = createClientWithDriver(
190
- createInlineClientDriver(managerDriver)
191
- );
183
+ const inlineClient = createClientWithDriver(managerDriver);
192
184
  const actorDriver = runConfig.driver.actor(
193
185
  registry.config,
194
186
  runConfig,
@@ -213,7 +205,7 @@ function createActorDurableObject(registry, rootRunConfig) {
213
205
  name: req.name,
214
206
  key: req.key
215
207
  };
216
- logger().debug("initialized actor", { key: req.key });
208
+ logger().debug({ msg: "initialized actor", key: req.key });
217
209
  await this.#loadActor();
218
210
  }
219
211
  async fetch(request) {
@@ -231,9 +223,7 @@ function createActorDurableObject(registry, rootRunConfig) {
231
223
  registry.config,
232
224
  runConfig
233
225
  );
234
- const inlineClient = createClientWithDriver(
235
- createInlineClientDriver(managerDriver)
236
- );
226
+ const inlineClient = createClientWithDriver(managerDriver);
237
227
  const actorDriver = runConfig.driver.actor(
238
228
  registry.config,
239
229
  runConfig,
@@ -250,15 +240,16 @@ function createActorDurableObject(registry, rootRunConfig) {
250
240
  import { RunConfigSchema } from "rivetkit/driver-helpers";
251
241
  import { z } from "zod";
252
242
  var ConfigSchema = RunConfigSchema.removeDefault().omit({ driver: true, getUpgradeWebSocket: true }).extend({
253
- app: z.custom().optional()
243
+ /** Path that the Rivet manager API will be mounted. */
244
+ managerPath: z.string().optional().default("/rivet"),
245
+ fetch: z.custom().optional()
254
246
  }).default({});
255
247
 
256
248
  // src/manager-driver.ts
257
249
  import {
258
250
  HEADER_AUTH_DATA,
259
251
  HEADER_CONN_PARAMS,
260
- HEADER_ENCODING,
261
- HEADER_EXPOSE_INTERNAL_ERROR
252
+ HEADER_ENCODING
262
253
  } from "rivetkit/driver-helpers";
263
254
  import { ActorAlreadyExists, InternalError } from "rivetkit/errors";
264
255
 
@@ -310,7 +301,8 @@ var STANDARD_WEBSOCKET_HEADERS = [
310
301
  var CloudflareActorsManagerDriver = class {
311
302
  async sendRequest(actorId, actorRequest) {
312
303
  const env3 = getCloudflareAmbientEnv();
313
- logger().debug("sending request to durable object", {
304
+ logger().debug({
305
+ msg: "sending request to durable object",
314
306
  actorId,
315
307
  method: actorRequest.method,
316
308
  url: actorRequest.url
@@ -321,13 +313,16 @@ var CloudflareActorsManagerDriver = class {
321
313
  }
322
314
  async openWebSocket(path, actorId, encoding, params) {
323
315
  const env3 = getCloudflareAmbientEnv();
324
- logger().debug("opening websocket to durable object", { actorId, path });
316
+ logger().debug({
317
+ msg: "opening websocket to durable object",
318
+ actorId,
319
+ path
320
+ });
325
321
  const id = env3.ACTOR_DO.idFromString(actorId);
326
322
  const stub = env3.ACTOR_DO.get(id);
327
323
  const headers = {
328
324
  Upgrade: "websocket",
329
325
  Connection: "Upgrade",
330
- [HEADER_EXPOSE_INTERNAL_ERROR]: "true",
331
326
  [HEADER_ENCODING]: encoding
332
327
  };
333
328
  if (params) {
@@ -335,10 +330,7 @@ var CloudflareActorsManagerDriver = class {
335
330
  }
336
331
  headers["sec-websocket-protocol"] = "rivetkit";
337
332
  const url = `http://actor${path}`;
338
- logger().debug("rewriting websocket url", {
339
- from: path,
340
- to: url
341
- });
333
+ logger().debug({ msg: "rewriting websocket url", from: path, to: url });
342
334
  const response = await stub.fetch(url, {
343
335
  headers
344
336
  });
@@ -348,7 +340,8 @@ var CloudflareActorsManagerDriver = class {
348
340
  "missing websocket connection in response from DO"
349
341
  );
350
342
  }
351
- logger().debug("durable object websocket connection open", {
343
+ logger().debug({
344
+ msg: "durable object websocket connection open",
352
345
  actorId
353
346
  });
354
347
  webSocket.accept();
@@ -361,7 +354,8 @@ var CloudflareActorsManagerDriver = class {
361
354
  return webSocket;
362
355
  }
363
356
  async proxyRequest(c, actorRequest, actorId) {
364
- logger().debug("forwarding request to durable object", {
357
+ logger().debug({
358
+ msg: "forwarding request to durable object",
365
359
  actorId,
366
360
  method: actorRequest.method,
367
361
  url: actorRequest.url
@@ -371,7 +365,8 @@ var CloudflareActorsManagerDriver = class {
371
365
  return await stub.fetch(actorRequest);
372
366
  }
373
367
  async proxyWebSocket(c, path, actorId, encoding, params, authData) {
374
- logger().debug("forwarding websocket to durable object", {
368
+ logger().debug({
369
+ msg: "forwarding websocket to durable object",
375
370
  actorId,
376
371
  path
377
372
  });
@@ -383,7 +378,8 @@ var CloudflareActorsManagerDriver = class {
383
378
  }
384
379
  const newUrl = new URL(`http://actor${path}`);
385
380
  const actorRequest = new Request(newUrl, c.req.raw);
386
- logger().debug("rewriting websocket url", {
381
+ logger().debug({
382
+ msg: "rewriting websocket url",
387
383
  from: c.req.url,
388
384
  to: actorRequest.url
389
385
  });
@@ -394,7 +390,6 @@ var CloudflareActorsManagerDriver = class {
394
390
  actorRequest.headers.delete(k);
395
391
  }
396
392
  }
397
- actorRequest.headers.set(HEADER_EXPOSE_INTERNAL_ERROR, "true");
398
393
  actorRequest.headers.set(HEADER_ENCODING, encoding);
399
394
  if (params) {
400
395
  actorRequest.headers.set(HEADER_CONN_PARAMS, JSON.stringify(params));
@@ -429,21 +424,23 @@ var CloudflareActorsManagerDriver = class {
429
424
  key
430
425
  }) {
431
426
  const env3 = getCloudflareAmbientEnv();
432
- logger().debug("getWithKey: searching for actor", { name, key });
427
+ logger().debug({ msg: "getWithKey: searching for actor", name, key });
433
428
  const nameKeyString = serializeNameAndKey(name, key);
434
429
  const actorId = env3.ACTOR_DO.idFromName(nameKeyString).toString();
435
430
  const actorData = await env3.ACTOR_KV.get(KEYS2.ACTOR.metadata(actorId), {
436
431
  type: "json"
437
432
  });
438
433
  if (!actorData) {
439
- logger().debug("getWithKey: no actor found with matching name and key", {
434
+ logger().debug({
435
+ msg: "getWithKey: no actor found with matching name and key",
440
436
  name,
441
437
  key,
442
438
  actorId
443
439
  });
444
440
  return void 0;
445
441
  }
446
- logger().debug("getWithKey: found actor with matching name and key", {
442
+ logger().debug({
443
+ msg: "getWithKey: found actor with matching name and key",
447
444
  actorId,
448
445
  name,
449
446
  key
@@ -505,6 +502,12 @@ var CloudflareActorsManagerDriver = class {
505
502
  key: actorData.key
506
503
  };
507
504
  }
505
+ displayInformation() {
506
+ return {
507
+ name: "Cloudflare Workers",
508
+ properties: {}
509
+ };
510
+ }
508
511
  };
509
512
 
510
513
  // src/websocket.ts
@@ -575,16 +578,10 @@ var upgradeWebSocket = defineWebSocketHelper(async (c, events) => {
575
578
  function getCloudflareAmbientEnv() {
576
579
  return env2;
577
580
  }
578
- function createServerHandler(registry, inputConfig) {
579
- const { createHandler } = createServer(registry, inputConfig);
580
- return createHandler();
581
- }
582
- function createServer(registry, inputConfig) {
581
+ function createHandler(registry, inputConfig) {
583
582
  const config = ConfigSchema.parse(inputConfig);
584
583
  const runConfig = {
585
584
  ...config,
586
- // The worker acts as a server and doesn't run actors
587
- role: "server",
588
585
  driver: {
589
586
  name: "cloudflare-workers",
590
587
  manager: () => new CloudflareActorsManagerDriver(),
@@ -594,25 +591,30 @@ function createServer(registry, inputConfig) {
594
591
  getUpgradeWebSocket: () => upgradeWebSocket
595
592
  };
596
593
  const ActorHandler2 = createActorDurableObject(registry, runConfig);
597
- const serverOutput = registry.createServer(runConfig);
598
- return {
599
- client: serverOutput.client,
600
- createHandler: (hono) => {
601
- const app = hono ?? new Hono();
602
- if (!hono) {
603
- app.route("/registry", serverOutput.hono);
594
+ const serverOutput = registry.start(runConfig);
595
+ const handler = {
596
+ fetch: (request, cfEnv, ctx) => {
597
+ const url = new URL(request.url);
598
+ const env3 = Object.assign({ RIVET: serverOutput.client }, cfEnv);
599
+ if (url.pathname.startsWith(config.managerPath)) {
600
+ const strippedPath = url.pathname.substring(config.managerPath.length);
601
+ url.pathname = strippedPath;
602
+ const modifiedRequest = new Request(url.toString(), request);
603
+ return serverOutput.fetch(modifiedRequest, env3, ctx);
604
+ }
605
+ if (config.fetch) {
606
+ return config.fetch(request, env3, ctx);
607
+ } else {
608
+ return new Response(
609
+ "This is a RivetKit server.\n\nLearn more at https://rivetkit.org\n",
610
+ { status: 200 }
611
+ );
604
612
  }
605
- const handler = {
606
- fetch: (request, env3, ctx) => {
607
- return app.fetch(request, env3, ctx);
608
- }
609
- };
610
- return { handler, ActorHandler: ActorHandler2 };
611
613
  }
612
614
  };
615
+ return { handler, ActorHandler: ActorHandler2 };
613
616
  }
614
617
  export {
615
- createServer,
616
- createServerHandler
618
+ createHandler
617
619
  };
618
620
  //# sourceMappingURL=mod.js.map