From 0657037c84eb3c6976a4fa83543137113650176e Mon Sep 17 00:00:00 2001 From: -Puter <22245429+puterhimself@users.noreply.github.com> Date: Wed, 29 Jul 2026 19:32:22 +0530 Subject: [PATCH] feat: make Rivet endpoint optional for self-hosted runtime RIVET_ENDPOINT and RIVET_PUBLIC_ENDPOINT are now optional in the agent env schema; empty strings are coerced to undefined. The agent runtime only passes an endpoint override to the Rivet client when one is set, so the client falls back to its default (suitable for self-hosted Rivet where no explicit endpoint is required). --- packages/agents/src/runtime/agent-os.ts | 6 ++++-- packages/env/src/agent.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/agents/src/runtime/agent-os.ts b/packages/agents/src/runtime/agent-os.ts index 3c44b72..131c50a 100644 --- a/packages/agents/src/runtime/agent-os.ts +++ b/packages/agents/src/runtime/agent-os.ts @@ -80,9 +80,10 @@ export const executeAgentOsAttempt = async ( decodeWorkAttemptExecutionInput(rawInput) ); const env = parseAgentEnv(process.env); + const endpoint = env.RIVET_PUBLIC_ENDPOINT ?? env.RIVET_ENDPOINT; const client = createClient({ disableMetadataLookup: true, - endpoint: env.RIVET_PUBLIC_ENDPOINT ?? env.RIVET_ENDPOINT, + ...(endpoint ? { endpoint } : {}), }); const vm = client.workspace.getOrCreate([input.workspaceKey], { params: { token: env.RIVET_WORKSPACE_TOKEN }, @@ -243,9 +244,10 @@ export const cancelAgentOsAttempt = async ( attemptId: string ) => { const env = parseAgentEnv(process.env); + const endpoint = env.RIVET_PUBLIC_ENDPOINT ?? env.RIVET_ENDPOINT; const client = createClient({ disableMetadataLookup: true, - endpoint: env.RIVET_PUBLIC_ENDPOINT ?? env.RIVET_ENDPOINT, + ...(endpoint ? { endpoint } : {}), }); await client.workspace .getOrCreate([workspaceKey], { diff --git a/packages/env/src/agent.ts b/packages/env/src/agent.ts index e93d96b..648ce08 100644 --- a/packages/env/src/agent.ts +++ b/packages/env/src/agent.ts @@ -14,8 +14,14 @@ const agentEnvSchema = z.object({ GITEA_TOKEN: z.string().min(1).optional(), GITEA_URL: z.url().default("https://git.openputer.com"), OPENROUTER_API_KEY: z.string().min(1).optional(), - RIVET_ENDPOINT: z.url(), - RIVET_PUBLIC_ENDPOINT: z.url().optional(), + RIVET_ENDPOINT: z.preprocess( + (value) => (value === "" ? undefined : value), + z.url().optional() + ), + RIVET_PUBLIC_ENDPOINT: z.preprocess( + (value) => (value === "" ? undefined : value), + z.url().optional() + ), RIVET_WORKSPACE_TOKEN: z.string().min(32), ZOPU_SOURCE_REPOSITORY: z.string().min(1).default("/opt/zopu-source"), });