Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 5c1019f

Browse files
committed
feat(drivers/engine): pass inspector to metadata (#1184)
### TL;DR Updated the engine-runner dependency to version 4b0f765 and enhanced actor metadata handling. ### What changed? - Updated `@rivetkit/engine-runner` from version f8860f3 to 4b0f765 - Added inspector token to actor metadata for improved debugging capabilities - Modified the prepopulation of actor names to use an object structure with metadata - Added automatic generation of a random studio token if one doesn't exist - Removed unused imports (`noopNext`, `WSContext`, `InternalError`) ### How to test? 1. Run the application with the updated engine-runner 2. Verify that actors are properly initialized with metadata 3. Check that the inspector token is correctly passed to the engine runner 4. Confirm that reconnection logic works as expected ### Why make this change? This change enhances the actor system by providing better metadata support, which improves debugging capabilities through the inspector token. The updated engine-runner version includes improvements that require these structural changes to the actor initialization process. The automatic token generation ensures that the system always has a valid token for studio operations.
1 parent 50b5e30 commit 5c1019f

File tree

4 files changed

+44
-27
lines changed

4 files changed

+44
-27
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"on-change": "^5.0.1",
168168
"p-retry": "^6.2.1",
169169
"zod": "^3.25.76",
170-
"@rivetkit/engine-runner": "https://pkg.pr.new/rivet-gg/engine/@rivetkit/engine-runner@f8860f3"
170+
"@rivetkit/engine-runner": "https://pkg.pr.new/rivet-gg/engine/@rivetkit/engine-runner@4b0f765"
171171
},
172172
"devDependencies": {
173173
"@hono/node-server": "^1.18.2",

packages/core/src/drivers/engine/actor-driver.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
handleRawWebSocketHandler,
3232
handleWebSocketConnect,
3333
lookupInRegistry,
34-
noopNext,
3534
PATH_CONNECT_WEBSOCKET,
3635
PATH_RAW_WEBSOCKET_PREFIX,
3736
} from "@/mod";
@@ -85,7 +84,15 @@ export class EngineActorDriver implements ActorDriver {
8584
totalSlots: config.totalSlots,
8685
runnerName: config.runnerName,
8786
runnerKey: config.runnerKey,
88-
prepopulateActorNames: Object.keys(this.#registryConfig.use),
87+
metadata: {
88+
inspectorToken: this.#runConfig.studio.token(),
89+
},
90+
prepopulateActorNames: Object.fromEntries(
91+
Object.keys(this.#registryConfig.use).map((name) => [
92+
name,
93+
{ metadata: {} },
94+
]),
95+
),
8996
onConnected: () => {
9097
if (hasDisconnected) {
9198
logger().info("runner reconnected", {

packages/core/src/drivers/engine/manager-driver.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import * as cbor from "cbor-x";
22
import type { Context as HonoContext } from "hono";
3-
import type { WSContext } from "hono/ws";
43
import invariant from "invariant";
5-
import { ActorAlreadyExists, InternalError } from "@/actor/errors";
4+
import { ActorAlreadyExists } from "@/actor/errors";
65
import {
76
HEADER_AUTH_DATA,
87
HEADER_CONN_PARAMS,
98
HEADER_ENCODING,
109
HEADER_EXPOSE_INTERNAL_ERROR,
1110
} from "@/actor/router-endpoints";
11+
import { generateRandomString } from "@/actor/utils";
1212
import { importWebSocket } from "@/common/websocket";
1313
import type {
1414
ActorOutput,
@@ -40,6 +40,10 @@ export class EngineManagerDriver implements ManagerDriver {
4040
constructor(config: Config, runConfig: RunConfig) {
4141
this.#config = config;
4242
this.#runConfig = runConfig;
43+
if (!this.#runConfig.studio.token()) {
44+
const token = generateRandomString();
45+
this.#runConfig.studio.token = () => token;
46+
}
4347
this.#importWebSocketPromise = importWebSocket();
4448
}
4549

pnpm-lock.yaml

Lines changed: 28 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)