mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-20 01:00:32 +00:00
Integrate OpenHandoff factory workspace (#212)
This commit is contained in:
parent
3d9476ed0b
commit
bf282199b5
251 changed files with 42824 additions and 692 deletions
7
factory/packages/frontend/src/lib/backend.ts
Normal file
7
factory/packages/frontend/src/lib/backend.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { createBackendClient } from "@openhandoff/client";
|
||||
import { backendEndpoint, defaultWorkspaceId } from "./env";
|
||||
|
||||
export const backendClient = createBackendClient({
|
||||
endpoint: backendEndpoint,
|
||||
defaultWorkspaceId,
|
||||
});
|
||||
33
factory/packages/frontend/src/lib/env.ts
Normal file
33
factory/packages/frontend/src/lib/env.ts
Normal 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";
|
||||
9
factory/packages/frontend/src/lib/workbench.ts
Normal file
9
factory/packages/frontend/src/lib/workbench.ts
Normal 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,
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue