Move Foundry HTTP APIs onto /v1

This commit is contained in:
Nathan Flurry 2026-03-12 19:53:52 -07:00
parent 58b19c2253
commit 9a2c60bf30
16 changed files with 62 additions and 51 deletions

View file

@ -259,7 +259,7 @@ export interface BackendClient {
}
export function rivetEndpoint(config: AppConfig): string {
return `http://${config.backend.host}:${config.backend.port}/api/rivet`;
return `http://${config.backend.host}:${config.backend.port}/v1/rivet`;
}
export function createBackendClientFromConfig(config: AppConfig): BackendClient {
@ -273,8 +273,18 @@ function stripTrailingSlash(value: string): string {
return value.replace(/\/$/, "");
}
function deriveAppApiEndpoint(endpoint: string): string {
return stripTrailingSlash(endpoint).replace(/\/api\/rivet$/, "/api");
function deriveBackendEndpoints(endpoint: string): { appEndpoint: string; rivetEndpoint: string } {
const normalized = stripTrailingSlash(endpoint);
if (normalized.endsWith("/rivet")) {
return {
appEndpoint: normalized.slice(0, -"/rivet".length),
rivetEndpoint: normalized,
};
}
return {
appEndpoint: normalized,
rivetEndpoint: `${normalized}/rivet`,
};
}
function isLoopbackHost(hostname: string): boolean {
@ -394,8 +404,9 @@ export function createBackendClient(options: BackendClientOptions): BackendClien
return createMockBackendClient(options.defaultWorkspaceId);
}
const rivetApiEndpoint = stripTrailingSlash(options.endpoint);
const appApiEndpoint = deriveAppApiEndpoint(options.endpoint);
const endpoints = deriveBackendEndpoints(options.endpoint);
const rivetApiEndpoint = endpoints.rivetEndpoint;
const appApiEndpoint = endpoints.appEndpoint;
let clientPromise: Promise<RivetClient> | null = null;
let appSessionId = typeof window !== "undefined" ? window.localStorage.getItem("sandbox-agent-foundry:remote-app-session") : null;
const workbenchSubscriptions = new Map<

View file

@ -107,7 +107,7 @@ async function ensureRemoteBranchExists(token: string, fullName: string, branchN
describe("e2e(client): full integration stack workflow", () => {
it.skipIf(!RUN_FULL_E2E)("adds repo, loads branch graph, and executes a stack restack action", { timeout: 8 * 60_000 }, async () => {
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/api/rivet";
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/v1/rivet";
const workspaceId = process.env.HF_E2E_WORKSPACE?.trim() || "default";
const repoRemote = requiredEnv("HF_E2E_GITHUB_REPO");
const githubToken = requiredEnv("GITHUB_TOKEN");

View file

@ -144,7 +144,7 @@ async function githubApi(token: string, path: string, init?: RequestInit): Promi
describe("e2e: backend -> sandbox-agent -> git -> PR", () => {
it.skipIf(!RUN_E2E)("creates a task, waits for agent to implement, and opens a PR", { timeout: 15 * 60_000 }, async () => {
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/api/rivet";
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/v1/rivet";
const workspaceId = process.env.HF_E2E_WORKSPACE?.trim() || "default";
const repoRemote = requiredEnv("HF_E2E_GITHUB_REPO");
const githubToken = requiredEnv("GITHUB_TOKEN");

View file

@ -145,7 +145,7 @@ function transcriptIncludesAgentText(transcript: WorkbenchTranscriptEvent[], exp
describe("e2e(client): workbench flows", () => {
it.skipIf(!RUN_WORKBENCH_E2E)("creates a task, adds sessions, exchanges messages, and manages workbench state", { timeout: 20 * 60_000 }, async () => {
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/api/rivet";
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/v1/rivet";
const workspaceId = process.env.HF_E2E_WORKSPACE?.trim() || "default";
const repoRemote = requiredEnv("HF_E2E_GITHUB_REPO");
const model = workbenchModelEnv("HF_E2E_MODEL", "gpt-4o");

View file

@ -175,7 +175,7 @@ async function measureWorkbenchSnapshot(
describe("e2e(client): workbench load", () => {
it.skipIf(!RUN_WORKBENCH_LOAD_E2E)("runs a simple sequential load profile against the real backend", { timeout: 30 * 60_000 }, async () => {
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/api/rivet";
const endpoint = process.env.HF_E2E_BACKEND_ENDPOINT?.trim() || "http://127.0.0.1:7741/v1/rivet";
const workspaceId = process.env.HF_E2E_WORKSPACE?.trim() || "default";
const repoRemote = requiredEnv("HF_E2E_GITHUB_REPO");
const model = workbenchModelEnv("HF_E2E_MODEL", "gpt-4o");