Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion clients/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@
"schema": {
"type": "string"
},
"required": true,
"required": false,
"name": "actor_ids",
"in": "query"
},
{
"schema": {
"type": "string"
},
"required": false,
"name": "key",
"in": "query"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/cloudflare-workers/src/actor-handler-do.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export function createActorDurableObject(
*/
return class ActorHandler
extends DurableObject<Bindings>
implements ActorHandlerInterface {
implements ActorHandlerInterface
{
#initialized?: InitializedData;
#initializedPromise?: ReturnType<typeof promiseWithResolvers<void>>;

Expand Down
2 changes: 1 addition & 1 deletion packages/rivetkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"@bare-ts/lib": "~0.3.0",
"@hono/standard-validator": "^0.1.3",
"@hono/zod-openapi": "^0.19.10",
"@rivetkit/engine-runner": "https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@b72b232",
"@rivetkit/engine-runner": "https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@9676fe4",
"@rivetkit/fast-json-patch": "^3.1.2",
"cbor-x": "^1.6.0",
"hono": "^4.9.8",
Expand Down
24 changes: 21 additions & 3 deletions packages/rivetkit/src/drivers/engine/actor-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import type { Client } from "@/client/client";
import {
PATH_CONNECT_WEBSOCKET,
PATH_RAW_WEBSOCKET_PREFIX,
WS_PROTOCOL_CONN_PARAMS,
WS_PROTOCOL_ENCODING,
} from "@/common/actor-router-consts";
import type { UpgradeWebSocketArgs } from "@/common/inline-websocket-adapter2";
import { getLogger } from "@/common/log";
Expand Down Expand Up @@ -85,6 +87,7 @@ export class EngineActorDriver implements ActorDriver {
totalSlots: config.totalSlots,
runnerName: config.runnerName,
runnerKey: config.runnerKey,
token: config.token,
metadata: {
inspectorToken: this.#runConfig.inspector.token(),
},
Expand Down Expand Up @@ -293,9 +296,24 @@ export class EngineActorDriver implements ActorDriver {

const url = new URL(request.url);

// Parse headers
const encodingRaw = request.headers.get(HEADER_ENCODING);
const connParamsRaw = request.headers.get(HEADER_CONN_PARAMS);
const protocols = request.headers.get("sec-websocket-protocol");
if (protocols === null)
throw new Error(`Missing sec-websocket-protocol header`);

let encodingRaw: string | undefined;
let connParamsRaw: string | undefined;

// Parse protocols
const protocolList = protocols.split(",").map((p) => p.trim());
for (const protocol of protocolList) {
if (protocol.startsWith(WS_PROTOCOL_ENCODING)) {
encodingRaw = protocol.substring(WS_PROTOCOL_ENCODING.length);
} else if (protocol.startsWith(WS_PROTOCOL_CONN_PARAMS)) {
connParamsRaw = decodeURIComponent(
protocol.substring(WS_PROTOCOL_CONN_PARAMS.length),
);
}
}

const encoding = EncodingSchema.parse(encodingRaw);
const connParams = connParamsRaw ? JSON.parse(connParamsRaw) : undefined;
Expand Down
4 changes: 4 additions & 0 deletions packages/rivetkit/src/drivers/engine/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export const ConfigSchema = z
.default(
() => getEnvUniversal("RIVET_RUNNER_KEY") ?? crypto.randomUUID(),
),
token: z
.string()
.optional()
.transform((val) => val ?? getEnvUniversal("RIVET_TOKEN")),
totalSlots: z.number().default(100_000),
})
.default({});
Expand Down
31 changes: 11 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading