Skip to content

Commit d5a6b40

Browse files
committed
refactor(rivetkit): move devtools to local script
1 parent 27c5231 commit d5a6b40

File tree

13 files changed

+108
-34
lines changed

13 files changed

+108
-34
lines changed

.cargo/config.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
[build]
22
rustflags = ["--cfg", "tokio_unstable"]
33

4+
# Target-specific flags must repeat tokio_unstable because target rustflags
5+
# override [build] rustflags. The link args are required on macOS for native
6+
# Node.js addons (dynamic_lookup defers symbol resolution to runtime).
7+
[target.aarch64-apple-darwin]
8+
rustflags = [
9+
"--cfg", "tokio_unstable",
10+
"-C", "link-arg=-undefined",
11+
"-C", "link-arg=dynamic_lookup",
12+
]
13+
14+
[target.x86_64-apple-darwin]
15+
rustflags = [
16+
"--cfg", "tokio_unstable",
17+
"-C", "link-arg=-undefined",
18+
"-C", "link-arg=dynamic_lookup",
19+
]
20+
421
[env]
522
LIBSQLITE3_FLAGS = "SQLITE_ENABLE_BATCH_ATOMIC_WRITE"

.github/workflows/publish.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,6 @@ jobs:
461461
--version ${{ needs.context.outputs.version }} \
462462
--latest ${{ needs.context.outputs.latest }}
463463
464-
- name: Upload @rivetkit/devtools to R2
465-
if: needs.context.outputs.trigger == 'release'
466-
env:
467-
R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
468-
R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
469-
run: |
470-
pnpm --filter=publish exec tsx src/ci/bin.ts upload-devtools \
471-
--sha ${{ needs.context.outputs.sha }} \
472-
--version ${{ needs.context.outputs.version }} \
473-
--latest ${{ needs.context.outputs.latest }}
474464
475465
- name: Retag Docker manifests to version
476466
if: needs.context.outputs.trigger == 'release'

rivetkit-typescript/packages/devtools/src/mod.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ const openDevtools = () => {
5959
console.error("RivetKit Devtools: No client config found");
6060
return;
6161
}
62-
const url = new URL("http://localhost:6420/ui");
6362
if (!config.endpoint) {
6463
console.error("RivetKit Devtools: No endpoint found in client config");
6564
return;
6665
}
66+
const url = new URL(`${config.endpoint.replace(/\/$/, "")}/ui`);
6767
url.searchParams.set("u", config.endpoint);
6868
if (config.token) {
6969
url.searchParams.set("t", config.token);

rivetkit-typescript/packages/rivetkit/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@
317317
"dump-asyncapi": "tsx scripts/dump-asyncapi.ts",
318318
"registry-config-schema-gen": "tsx scripts/registry-config-schema-gen.ts",
319319
"actor-config-schema-gen": "tsx scripts/actor-config-schema-gen.ts",
320-
"build:pack-inspector": "tsx scripts/pack-inspector.ts"
320+
"build:pack-inspector": "tsx scripts/pack-inspector.ts",
321+
"build:pack-devtools": "tsx scripts/pack-devtools.ts"
321322
},
322323
"dependencies": {
323324
"@rivet-dev/agent-os-core": "^0.1.1",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { existsSync } from "node:fs";
2+
import { copyFile, mkdir } from "node:fs/promises";
3+
import { dirname, join } from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
const src = join(__dirname, "../../devtools/dist/mod.js");
8+
const destDir = join(__dirname, "../dist/devtools");
9+
const dest = join(destDir, "mod.js");
10+
11+
if (!existsSync(src)) {
12+
throw new Error(
13+
`Devtools build not found at: ${src}. Run 'pnpm build -F @rivetkit/devtools' first.`,
14+
);
15+
}
16+
17+
await mkdir(destDir, { recursive: true });
18+
await copyFile(src, dest);
19+
console.log(`Packed devtools into ${dest}`);

rivetkit-typescript/packages/rivetkit/src/devtools-loader/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import type { ClientConfigInput } from "@/client/client";
2-
import { VERSION } from "@/utils";
32
import { logger } from "./log";
43

54
declare global {
65
// Injected via tsup config
7-
// biome-ignore lint/style/noVar: required for global declaration
86
var CUSTOM_RIVETKIT_DEVTOOLS_URL: string | undefined;
97
}
108

11-
const DEFAULT_DEVTOOLS_URL = (version = VERSION) =>
12-
`https://releases.rivet.dev/rivet/latest/devtools/mod.js?v=${version}`;
13-
149
const scriptId = "rivetkit-devtools-script";
1510

1611
export function injectDevtools(config: ClientConfigInput) {
@@ -20,10 +15,12 @@ export function injectDevtools(config: ClientConfigInput) {
2015
}
2116

2217
if (!document.getElementById(scriptId)) {
18+
const src =
19+
globalThis.CUSTOM_RIVETKIT_DEVTOOLS_URL ||
20+
`${config.endpoint?.replace(/\/$/, "")}/devtools/mod.js`;
2321
const script = document.createElement("script");
2422
script.id = scriptId;
25-
script.src =
26-
globalThis.CUSTOM_RIVETKIT_DEVTOOLS_URL || DEFAULT_DEVTOOLS_URL();
23+
script.src = src;
2724
script.async = true;
2825
document.head.appendChild(script);
2926
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { getNodeFs, getNodePath, getNodeUrl } from "@/utils/node";
2+
3+
export async function getDevtoolsPath(): Promise<string> {
4+
const url = getNodeUrl();
5+
const path = getNodePath();
6+
7+
const devtoolsPath = path.join(
8+
path.dirname(url.fileURLToPath(import.meta.url)),
9+
"../../dist/devtools/mod.js",
10+
);
11+
12+
try {
13+
await getNodeFs().access(devtoolsPath);
14+
} catch {
15+
throw new Error(
16+
`Devtools bundle not found at ${devtoolsPath}. Run 'pnpm build:pack-devtools' first.`,
17+
);
18+
}
19+
20+
return devtoolsPath;
21+
}
22+
23+
export async function readDevtoolsBundle(): Promise<Buffer> {
24+
const devtoolsPath = await getDevtoolsPath();
25+
return getNodeFs().readFile(devtoolsPath);
26+
}

rivetkit-typescript/packages/rivetkit/src/drivers/engine/actor-driver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export class EngineActorDriver implements ActorDriver {
183183
token: config.token,
184184
namespace: config.namespace,
185185
poolName: config.envoy.poolName,
186+
notGlobal: false,
186187
metadata: {
187188
rivetkit: { version: VERSION },
188189
},

rivetkit-typescript/packages/rivetkit/src/engine-client/api-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class EngineApiError extends Error {
2121
export function getEndpoint(config: ClientConfig | RegistryConfig) {
2222
// Endpoint is always defined for ClientConfig (has default in schema).
2323
// RegistryConfig may not have endpoint before the local runtime is prepared.
24-
return config.endpoint ?? "http://127.0.0.1:6420";
24+
return config.endpoint ?? "http://127.0.0.1:6423";
2525
}
2626

2727
// Helper function for making API calls
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
export const ENGINE_PORT = 6420;
1+
// The engine guard (public HTTP API) runs on this internal port.
2+
// The rivetkit manager runs on port 6420 (managerPort default) and proxies to
3+
// the engine here, so clients always connect to the manager on 6420.
4+
export const ENGINE_PORT = 6423;
25
export const ENGINE_ENDPOINT = `http://127.0.0.1:${ENGINE_PORT}`;

0 commit comments

Comments
 (0)