Integrate OpenHandoff factory workspace (#212)

This commit is contained in:
Nathan Flurry 2026-03-09 14:00:20 -07:00 committed by GitHub
parent 3d9476ed0b
commit bf282199b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
251 changed files with 42824 additions and 692 deletions

View file

@ -0,0 +1,7 @@
import { createBackendClient } from "@openhandoff/client";
import { backendEndpoint, defaultWorkspaceId } from "./env";
export const backendClient = createBackendClient({
endpoint: backendEndpoint,
defaultWorkspaceId,
});

View file

@ -0,0 +1,33 @@
function resolveDefaultBackendEndpoint(): string {
if (typeof window !== "undefined" && window.location?.origin) {
return `${window.location.origin}/api/rivet`;
}
return "http://127.0.0.1:7741/api/rivet";
}
type FrontendImportMetaEnv = ImportMetaEnv & {
OPENHANDOFF_FRONTEND_CLIENT_MODE?: string;
};
const frontendEnv = import.meta.env as FrontendImportMetaEnv;
export const backendEndpoint =
import.meta.env.VITE_HF_BACKEND_ENDPOINT?.trim() || resolveDefaultBackendEndpoint();
export const defaultWorkspaceId = import.meta.env.VITE_HF_WORKSPACE?.trim() || "default";
function resolveFrontendClientMode(): "mock" | "remote" {
const raw = frontendEnv.OPENHANDOFF_FRONTEND_CLIENT_MODE?.trim().toLowerCase();
if (raw === "mock") {
return "mock";
}
if (raw === "remote" || raw === "" || raw === undefined) {
return "remote";
}
throw new Error(
`Unsupported OPENHANDOFF_FRONTEND_CLIENT_MODE value "${frontendEnv.OPENHANDOFF_FRONTEND_CLIENT_MODE}". Expected "mock" or "remote".`,
);
}
export const frontendClientMode = resolveFrontendClientMode();
export const isMockFrontendClient = frontendClientMode === "mock";

View file

@ -0,0 +1,9 @@
import { createHandoffWorkbenchClient } from "@openhandoff/client";
import { backendClient } from "./backend";
import { defaultWorkspaceId, frontendClientMode } from "./env";
export const handoffWorkbenchClient = createHandoffWorkbenchClient({
mode: frontendClientMode,
backend: backendClient,
workspaceId: defaultWorkspaceId,
});