A desktop coding agent with free access to frontier models.
TypeScript
fix: chats on the new engine use the account's models
ogsamrat8359ec66f342
diff --git a/apps/desktop/scripts/engine-v2-release.json b/apps/desktop/scripts/engine-v2-release.jsonindex 3ddc3b62..cf5208fa 100644--- a/apps/desktop/scripts/engine-v2-release.json+++ b/apps/desktop/scripts/engine-v2-release.json@@ -1,8 +1,8 @@{"repo": "omnirush-ai/omnirush-gui",- "tag": "engine-2.0.32-r2",+ "tag": "engine-2.0.32-r3","version": "2.0.32",- "origin": "OmniRush.ai's build of OpenCode 2.0.32 (engine-2.0.32-r2, the archives the CLI pins), copied to a public pre-release of this repo that is never marked latest. Until it is uploaded, set OMNIRUSH_ENGINE_ARCHIVE_DIR to a folder holding these archives.",+ "origin": "OmniRush.ai's build of OpenCode 2.0.32 (engine-2.0.32-r3, the archives the CLI pins), copied to a public pre-release of this repo that is never marked latest. Until it is uploaded, set OMNIRUSH_ENGINE_ARCHIVE_DIR to a folder holding these archives.","license": {"name": "LICENSE-opencode-MIT","sha256": "625f0f619133f89bbbb2abe37369613dfa1885eba1e50d02170deb62bb42cb6b"@@ -10,27 +10,27 @@"assets": {"aarch64-apple-darwin": {"name": "omnirush-engine-darwin-arm64-2.0.32.tar.gz",- "sha256": "f4a968d5c07703a49c64427bd0632707b0c0151a9c78a8f7382626bc2aec0d49"+ "sha256": "a9e9b8f8ef139bb1b541738cce19019d815638ca2f69d7ee567595a40c136501"},"x86_64-apple-darwin": {"name": "omnirush-engine-darwin-x64-2.0.32.tar.gz",- "sha256": "f7a008de7c170e2917918a8647b027ed9f6a4eaadee289b05ce9b82385122e24"+ "sha256": "a5994be040960d732c88ec9fcdbe588213434e3e4cab3aed93523b53c5cb2b61"},"x86_64-unknown-linux-gnu": {"name": "omnirush-engine-linux-x64-2.0.32.tar.gz",- "sha256": "b1cfaf8d6f260671d92d45082b73f0b6a675824a5cce9fab533c56038d2b5b58"+ "sha256": "6b1d3e722f507b7f81945e5289198736d6c379604121a2ca15af99421e53653c"},"aarch64-unknown-linux-gnu": {"name": "omnirush-engine-linux-arm64-2.0.32.tar.gz",- "sha256": "2a3279dc0610009042aa262577caf9876041a7c30ea456073f67adf4091bc1e6"+ "sha256": "60c4d124cc21f91aad25069ecf720a208b7b50d8011f9402d8710a455063d2cd"},"x86_64-pc-windows-msvc": {"name": "omnirush-engine-win32-x64-2.0.32.tar.gz",- "sha256": "918699dd8e9faaf965fa9463f4ff656bce03abbe40ef27805bb0134df1705c14"+ "sha256": "e7327a984c383d3360fc90606f6e27e67e6aad1ce1e145e8574186a9ee45419b"},"aarch64-pc-windows-msvc": {"name": "omnirush-engine-win32-arm64-2.0.32.tar.gz",- "sha256": "26a2a867481d603bd7be781471362ae9ed3cc9fbed68629848c5dd260d248066"+ "sha256": "d9e568e53a874fab762ccd7e1dd424bb7381f685484d70e327bdbcd3db89be71"}}}diff --git a/apps/server/src/engine-v2-preview.ts b/apps/server/src/engine-v2-preview.tsindex 4d169522..c2bcae33 100644--- a/apps/server/src/engine-v2-preview.ts+++ b/apps/server/src/engine-v2-preview.ts@@ -21,6 +21,8 @@ import type { EnvService } from "./env-file.js";import { selectPrimaryCredentialEnvName } from "./managed-provider-auth.js";import { isReleaseBuild } from "./release-guard.js";import { webSearchSetting } from "./web-search.js";+import { buildOmniRushRuntimeConfigObject } from "./omnirush-runtime-config.js";+import { OMNIRUSH_PROVIDER_ID } from "./provider-lock/provider-lock.mjs";import { desiredV2Mcp, v2McpGate } from "./engine-v2-mcp.js";import { engineDataDir } from "./engine-data-home.js";import { computerUseEngineEnv } from "./computer-use/desktop.js";@@ -29,10 +31,13 @@ import type { ServerConfig } from "./types.js";const PREVIEW_STATE_FILE = "engine-v2-preview.json";const UNSET_API_KEY = "omnirush-engine-v2-preview-unset";+/** The local gateway broker's key for the engine (the 1.x engine reads the same variable). */+const ENGINE_TOKEN_ENV = "OMNIRUSH_ACCESS_TOKEN";/** opencode-plugins/omnirush-session-next.ts's id (server modules never import plugin files). */export const OMNIRUSH_SESSION_PLUGIN_ID = "omnirush.session";/** How long a prompt waits for a project's MCP servers to connect. */const MCP_READY_TIMEOUT_MS = 15_000;+const MCP_TOOLS_SETTLE_MS = 750;// A cold sidecar can return HTTP 503 while its model catalog initializes for 17–20 seconds.const CATALOG_MIRROR_TIMEOUT_MS = 60_000;@@ -346,6 +351,9 @@ export function createEngineV2Preview(options: { config: ServerConfig; env?: Picif (!waiting) break;await new Promise((resolve) => setTimeout(resolve, 200));}+ // The engine reports a server connected a moment before a new session gets its tools (measured on 2.0.32-r3).+ // shortcut: a fixed settle; replace with an engine signal for "tools ready" if one is added.+ if (Object.keys(desired).length > 0) await new Promise((resolve) => setTimeout(resolve, MCP_TOOLS_SETTLE_MS));mcpCleaned.add(directory);})();mcpInFlight.set(directory, pending);@@ -378,6 +386,14 @@ export function createEngineV2Preview(options: { config: ServerConfig; env?: Picif (!active) return;const providerMap = runtimeProviderMap(await readGlobalRuntimeOpencodeConfig(config));const credentials = new Map((await options.env?.list() ?? []).map((entry) => [entry.key, entry.value]));+ // The account's own provider (the local gateway broker, with the synced model catalog), as the 1.x engine+ // gets it. Its key stays in the engine's environment (blanked in agent shells), never in a config file.+ const injected = await buildOmniRushRuntimeConfigObject(config).catch(() => ({}) as Record<string, unknown>);+ const gateway = isRecord(injected.provider) ? injected.provider[OMNIRUSH_PROVIDER_ID] : undefined;+ if (isRecord(gateway) && config.omnirushEngineToken) {+ providerMap[OMNIRUSH_PROVIDER_ID] = gateway;+ credentials.set(ENGINE_TOKEN_ENV, `{env:${ENGINE_TOKEN_ENV}}`);+ }const mapped = mapRuntimeProvidersToV2Specs(providerMap, credentials);const nextMirroredProviderIds = mapped.specs.map((spec) => spec.id);await active.setProviders(mapped.specs);@@ -459,7 +475,10 @@ export function createEngineV2Preview(options: { config: ServerConfig; env?: Picconst managed = await createManagedOpencodeV2Server({bin: resolved.bin,rootDir,- env: { ...opencodeModelsEnv, OMNIRUSH_SERVER_URL: `http://127.0.0.1:${config.port}`, OMNIRUSH_POLICY_TOKEN: managedDesktopPolicy(config).evaluationToken },+ env: {+ ...opencodeModelsEnv, OMNIRUSH_SERVER_URL: `http://127.0.0.1:${config.port}`, OMNIRUSH_POLICY_TOKEN: managedDesktopPolicy(config).evaluationToken,+ ...(config.omnirushEngineToken ? { [ENGINE_TOKEN_ENV]: config.omnirushEngineToken } : {}),+ },permissions: async () => executionRules((await readGlobalRuntimeOpencodeConfig(config)).managedPolicy?.execution),webSearch: () => webSearchSetting({ env: process.env, stateDir: runtimeStorageDir(config) }).enabled,mcpGate: v2McpGate(runtimeStorageDir(config), { ...process.env, ...computerUseEngineEnv(runtimeStorageDir(config)) }),@@ -576,7 +595,8 @@ export function createEngineV2Preview(options: { config: ServerConfig; env?: Picconst payload = isRecord(response.json) ? response.json.data : undefined;if (response.status === 200 && Array.isArray(payload) && mirroredSpecs.every((spec) =>payload.some((provider) => isRecord(provider) && provider.id === spec.id- && isRecord(provider.settings) && provider.settings.apiKey === spec.apiKey)+ // A key the engine reads from its environment shows resolved (or not at all): its presence is enough.+ && (spec.apiKey.startsWith("{env:") || (isRecord(provider.settings) && provider.settings.apiKey === spec.apiKey))))) return;await new Promise((resolve) => setTimeout(resolve, 100));} while (Date.now() < deadline);diff --git a/apps/server/src/managed-opencode-v2.ts b/apps/server/src/managed-opencode-v2.tsindex 655888fc..6ca801de 100644--- a/apps/server/src/managed-opencode-v2.ts+++ b/apps/server/src/managed-opencode-v2.ts@@ -136,7 +136,7 @@ export async function createManagedOpencodeV2Server(// cloud, database, or control-plane credentials. Unknown keys stay private.const inherited: Record<string, string> = {};for (const key of [- "OMNIRUSH_SERVER_URL", "OMNIRUSH_POLICY_TOKEN",+ "OMNIRUSH_SERVER_URL", "OMNIRUSH_POLICY_TOKEN", "OMNIRUSH_ACCESS_TOKEN","PATH", "HOME", "USER", "LOGNAME", "SHELL", "TMPDIR", "TMP", "TEMP","LANG", "LC_ALL", "LC_CTYPE", "TZ", "TERM", "CI","XDG_CACHE_HOME", "XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_STATE_HOME", "XDG_RUNTIME_DIR",diff --git a/apps/server/src/server.ts b/apps/server/src/server.tsindex ab3b85da..341b3ca7 100644--- a/apps/server/src/server.ts+++ b/apps/server/src/server.ts@@ -1749,6 +1749,9 @@ export async function startServer(config: ServerConfig): Promise<ServeResult> {if (mount && (mount.restPath === "/opencode" || mount.restPath.startsWith("/opencode/"))) {return proxyWorkspaceOpencodeMount(mount);}+ if (mount && (mount.restPath === "/opencode2" || mount.restPath.startsWith("/opencode2/"))) {+ return proxyWorkspaceOpencodeV2Mount(mount);+ }// Allow clients to use a mounted base URL (e.g. http://host:8787/w/<id>) while// still calling the existing /workspace/:id/* API surface.@@ -1767,6 +1770,11 @@ export async function startServer(config: ServerConfig): Promise<ServeResult> {url.pathname = mount.restPath;}+ // The global 2.x client (web, gateway): the first workspace's engine, as /opencode below.+ if ((url.pathname === "/opencode2" || url.pathname.startsWith("/opencode2/")) && config.workspaces[0]) {+ return proxyWorkspaceOpencodeV2Mount({ workspaceId: config.workspaces[0].id, restPath: url.pathname });+ }+if (url.pathname === "/opencode" || url.pathname.startsWith("/opencode/")) {authMode = "client";proxyBaseUrl = config.workspaces[0]?.baseUrl?.trim() || undefined;@@ -2052,11 +2060,11 @@ export async function proxyOpencodeV2Request(input: {try { decodedPath = decodeURIComponent(forwardedPath); } catch { decodedPath = routePath; }// Runtime provider configuration contains server-owned credentials. The// renderer uses the catalog/status APIs; it must not read or mutate this file.- if (/^\/api\/config(?:\/|$)/.test(decodedPath)) {+ if (/^\/api\/(?:experimental\/)?config(?:\/|$)/.test(decodedPath)) {throw new ApiError(403, "engine_config_private", "Engine configuration is private");}// MCP servers follow the server's list (engine-v2-mcp.ts): the engine's own MCP routes stay closed.- if (/^(?:\/api)?\/mcp(?:\/|$)/.test(decodedPath) && method !== "GET" && method !== "HEAD") {+ if (/^(?:\/api(?:\/experimental)?)?\/mcp(?:\/|$)/.test(decodedPath) && method !== "GET" && method !== "HEAD") {throw new ApiError(403, "engine_mcp_managed", "Manage connections through OmniRush.ai");}const sessionMatch = routePath.match(/^\/api\/session\/([^/]+)(?:\/|$)/);diff --git a/constants.json b/constants.jsonindex 4c5613f0..b9c3cac1 100644--- a/constants.json+++ b/constants.json@@ -2,5 +2,5 @@"opencodeVersion": "v1.18.32","opencodeV2Version": "2.0.32","engineReleaseTag": "engine-1.18.32-ux4-ed3-pl4",- "engineV2ReleaseTag": "engine-2.0.32-r2"+ "engineV2ReleaseTag": "engine-2.0.32-r3"}