Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
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
5 changes: 3 additions & 2 deletions packages/rivetkit/src/remote-manager-driver/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
ManagerDriver,
} from "@/driver-helpers/mod";
import type { Encoding, UniversalWebSocket } from "@/mod";
import { uint8ArrayToBase64 } from "@/serde";
import { combineUrlPath } from "@/utils";
import { sendHttpRequestToActor } from "./actor-http-client";
import {
Expand Down Expand Up @@ -140,7 +141,7 @@ export class RemoteManagerDriver implements ManagerDriver {
key: serializeActorKey(key),
runner_name_selector: this.#config.runnerName,
input: actorInput
? cbor.encode(actorInput).toString("base64")
? uint8ArrayToBase64(cbor.encode(actorInput))
: undefined,
crash_policy: "sleep",
});
Expand Down Expand Up @@ -175,7 +176,7 @@ export class RemoteManagerDriver implements ManagerDriver {
name,
runner_name_selector: this.#config.runnerName,
key: serializeActorKey(key),
input: input ? cbor.encode(input).toString("base64") : null,
input: input ? uint8ArrayToBase64(cbor.encode(input)) : undefined,
crash_policy: "sleep",
});
const actorId = result.actor.actor_id;
Expand Down
15 changes: 15 additions & 0 deletions packages/rivetkit/src/serde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ import type { VersionedDataHandler } from "@/common/versioned-data";
import type { Encoding } from "@/mod";
import { jsonStringifyCompat } from "./actor/protocol/serde";

export function uint8ArrayToBase64(uint8Array: Uint8Array): string {
// Check if Buffer is available (Node.js)
if (typeof Buffer !== "undefined") {
return Buffer.from(uint8Array).toString("base64");
}

// Browser environment - use btoa
let binary = "";
const len = uint8Array.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(uint8Array[i]);
}
return btoa(binary);
}

export function encodingIsBinary(encoding: Encoding): boolean {
if (encoding === "json") {
return false;
Expand Down
Loading