Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

feat: stock mode runs stock opencode v2 on astra

ogsamratd3cbeb0a2c6e
diff --git a/apps/app/src/app/lib/desktop.ts b/apps/app/src/app/lib/desktop.ts
index 841fe975..526c92f2 100644
--- a/apps/app/src/app/lib/desktop.ts
+++ b/apps/app/src/app/lib/desktop.ts
@@ -364,6 +364,7 @@ declare global {
platform?: "darwin" | "linux" | "windows";
version?: string;
evalFatalBootstrapFailure?: string | null;
+ stockMode?: boolean;
};
};
}
diff --git a/apps/app/src/app/lib/opencode-v2-adapter.ts b/apps/app/src/app/lib/opencode-v2-adapter.ts
index 8a2bac2c..8d34fab8 100644
--- a/apps/app/src/app/lib/opencode-v2-adapter.ts
+++ b/apps/app/src/app/lib/opencode-v2-adapter.ts
@@ -18,7 +18,7 @@ import type {
import { createOpencodeClient } from "@opencode-ai/sdk/v2/client";
import { createClient, createDesktopFetch, type FieldsResult } from "./opencode";
-import { isDesktopRuntime } from "./runtime-env";
+import { isDesktopRuntime, isStockMode } from "./runtime-env";
import type { OpencodeEvent } from "../types";
import { normalizeDirectoryPath } from "../utils";
@@ -1673,7 +1673,8 @@ export function createClientV2(
}
const modelResult = await selectModel(parameters.sessionID, parameters.model, parameters.variant, options);
if (!modelResult.response.ok) return failedResult(modelResult);
- if (parameters.system !== undefined) {
+ // Stock mode: no context of ours, the engine's own system prompt only.
+ if (parameters.system !== undefined && !isStockMode()) {
const instructions = await request("PUT",
`/api/experimental/session/${encodeURIComponent(parameters.sessionID)}/instructions/entries/omnirush-context`,
{ value: parameters.system }, options?.signal);
diff --git a/apps/app/src/app/lib/runtime-env.ts b/apps/app/src/app/lib/runtime-env.ts
index abac95bd..3fad81f7 100644
--- a/apps/app/src/app/lib/runtime-env.ts
+++ b/apps/app/src/app/lib/runtime-env.ts
@@ -8,3 +8,8 @@ export function isElectronRuntime() {
export function isDesktopRuntime() {
return isElectronRuntime();
}
+
+/** Stock mode (the server's stock-mode.mjs): the app started with OMNIRUSH_FARM=1, chats run stock OpenCode on Astra. */
+export function isStockMode() {
+ return isElectronRuntime() && window.__OMNIRUSH_ELECTRON__?.meta?.stockMode === true;
+}
diff --git a/apps/app/src/react-app/shell/app-root.tsx b/apps/app/src/react-app/shell/app-root.tsx
index 2d3a67d9..5e64859c 100644
--- a/apps/app/src/react-app/shell/app-root.tsx
+++ b/apps/app/src/react-app/shell/app-root.tsx
@@ -31,6 +31,7 @@ import { OrgOnboardingPage } from "../domains/cloud/org-onboarding-page";
import { NewProvidersListener } from "./new-providers-listener";
import { BudgetWrapConsent } from "./budget-wrap-consent";
import { AutoCompactNotice } from "./auto-compact-notice";
+import { StockModeNotice } from "./stock-mode-notice";
import { useDesktopFontZoomBehavior } from "./font-zoom";
import { LoadingOverlay } from "./loading-overlay";
import { useVisualViewportInset } from "../../hooks/use-visual-viewport-inset";
@@ -399,6 +400,7 @@ export function AppRoot() {
<OmniRushContextPublisher />
<BudgetWrapConsent />
<AutoCompactNotice />
+ <StockModeNotice />
<DenAuthControlActions />
<BrandThemeControlActions />
<EnterpriseActivationGate>
diff --git a/apps/app/src/react-app/shell/stock-mode-notice.tsx b/apps/app/src/react-app/shell/stock-mode-notice.tsx
new file mode 100644
index 00000000..bf6217fd
--- /dev/null
+++ b/apps/app/src/react-app/shell/stock-mode-notice.tsx
@@ -0,0 +1,15 @@
+import { useEffect } from "react";
+
+import { toast } from "@/components/ui/sonner";
+import { isStockMode } from "../../app/lib/runtime-env";
+
+/** The same words as the CLI's notice (src/stock.js STOCK_NOTICE). */
+export const STOCK_NOTICE = "Stock mode: stock OpenCode v2 on GPT 6 Astra. No OmniRush tools, prompts, MCP servers or automatic compaction.";
+
+/** Stock mode (OMNIRUSH_FARM=1 at launch): one short notice when the window opens. */
+export function StockModeNotice() {
+ useEffect(() => {
+ if (isStockMode()) toast.info(STOCK_NOTICE, { duration: 15_000 });
+ }, []);
+ return null;
+}
diff --git a/apps/app/tests/opencode-v2-adapter.test.ts b/apps/app/tests/opencode-v2-adapter.test.ts
index 84ce4002..45da9fee 100644
--- a/apps/app/tests/opencode-v2-adapter.test.ts
+++ b/apps/app/tests/opencode-v2-adapter.test.ts
@@ -2002,3 +2002,28 @@ test("a send posts the picked effort with the session model", async () => {
globalThis.fetch = originalFetch;
}
});
+
+test("stock mode sends no context of ours with a prompt", async () => {
+ const originalFetch = globalThis.fetch;
+ const globals = globalThis as { window?: unknown };
+ const originalWindow = globals.window;
+ const paths: string[] = [];
+ globalThis.fetch = async (input, init) => {
+ const request = input instanceof Request ? input : new Request(input, init);
+ paths.push(new URL(request.url).pathname);
+ return new Response(null, { status: 204 });
+ };
+ try {
+ const client = createClientV2("http://opencode.test/opencode2", "/workspace", {});
+ const send = () => client.session.promptAsync({ sessionID: "ses_s", model: { providerID: "omnirush", modelID: "gpt-6-astra" }, system: "Time zone: UTC", parts: [{ type: "text", text: "a" }] });
+ await send();
+ expect(paths.some((path) => path.includes("/instructions/entries/omnirush-context"))).toBe(true);
+ paths.length = 0;
+ globals.window = { __OMNIRUSH_ELECTRON__: { meta: { stockMode: true } } };
+ await send();
+ expect(paths).toEqual(["/opencode2/api/session/ses_s/model", "/opencode2/api/session/ses_s/prompt"]);
+ } finally {
+ globalThis.fetch = originalFetch;
+ globals.window = originalWindow;
+ }
+});
diff --git a/apps/desktop/electron/main.mjs b/apps/desktop/electron/main.mjs
index 5f765e2e..85b1d0e5 100644
--- a/apps/desktop/electron/main.mjs
+++ b/apps/desktop/electron/main.mjs
@@ -133,6 +133,10 @@ import {
installSocketTypeOfServiceGuard,
runDetachedTask,
} from "./process-resilience.mjs";
+import { applyStockSwitches } from "../../server/src/stock-mode/stock-mode.mjs";
+
+// Stock mode (OMNIRUSH_FARM=1 at launch, stock-mode.mjs): its switches are set before anything reads them.
+applyStockSwitches(process.env);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const APP_ROOT = path.resolve(__dirname, "../../..");
diff --git a/apps/desktop/electron/preload.mjs b/apps/desktop/electron/preload.mjs
index 89a4310c..473d32c9 100644
--- a/apps/desktop/electron/preload.mjs
+++ b/apps/desktop/electron/preload.mjs
@@ -325,6 +325,8 @@ contextBridge.exposeInMainWorld("__OMNIRUSH_ELECTRON__", {
platform: normalizePlatform(process.platform),
version: process.versions.electron,
evalFatalBootstrapFailure: process.env.OMNIRUSH_EVAL_FATAL_DESKTOP_BOOTSTRAP_FAILURE ?? null,
+ // Stock mode (server stock-mode.mjs): main set OMNIRUSH_FARM=1 for the run.
+ stockMode: process.env.OMNIRUSH_FARM === "1",
},
});
diff --git a/apps/server/src/engine-v2-preview.ts b/apps/server/src/engine-v2-preview.ts
index 532f9c53..1473ee65 100644
--- a/apps/server/src/engine-v2-preview.ts
+++ b/apps/server/src/engine-v2-preview.ts
@@ -31,6 +31,7 @@ import { engineV2Root, importMissingV1Chats, readMigratedSessions, seedV2StoreFr
import type { ServerConfig } from "./types.js";
import { boxServiceFor } from "./box/desktop.js";
import { omnirushBoxNextPluginPath } from "./omnirush-extensions-plugin-path.js";
+import { stockMode } from "./stock-mode/stock-mode.mjs";
const PREVIEW_STATE_FILE = "engine-v2-preview.json";
const UNSET_API_KEY = "omnirush-engine-v2-preview-unset";
@@ -553,7 +554,8 @@ export function createEngineV2Preview(options: {
// The Linux sandbox (box/): the shell and box plugin follow BoxService.engineBits on every config write.
box: async () => v2BoxBits(await boxServiceFor(config).engineBits()),
titleModel: () => omnirushTitleModel(config),
- mcpGate: v2McpGate(runtimeStorageDir(config), { ...process.env, ...computerUseEngineEnv(runtimeStorageDir(config)) }, Boolean(await cloudConnector())),
+ // Stock mode (stock-mode.mjs): no MCP server, the app's included.
+ mcpGate: stockMode() ? [] : v2McpGate(runtimeStorageDir(config), { ...process.env, ...computerUseEngineEnv(runtimeStorageDir(config)) }, Boolean(await cloudConnector())),
});
sidecar = managed;
if (!enabled || !allowRunning) {
diff --git a/apps/server/src/managed-opencode-v2.ts b/apps/server/src/managed-opencode-v2.ts
index bc3faa00..7f2e171a 100644
--- a/apps/server/src/managed-opencode-v2.ts
+++ b/apps/server/src/managed-opencode-v2.ts
@@ -14,6 +14,7 @@ import { writeFileAtomic } from "./atomic-write.js";
import { currentProviderLockPolicy, noteEngineStarted, providerAllowed } from "./provider-lock.js";
import { APP_PROVIDER_IDS, providerLockEnv } from "./provider-lock/provider-lock.mjs";
import { gateEnv } from "./engine-gates/engine-gates.mjs";
+import { STOCK_ENV, STOCK_PROVIDER, stockMode, stockProviders } from "./stock-mode/stock-mode.mjs";
import { releaseEngineBinary } from "./release-guard.js";
export interface OpencodeV2ModelSpec {
@@ -155,7 +156,9 @@ const CLAUDE_PROVIDER_ID = "omnirush-claude";
export function engineV2SpawnEnv(env: Record<string, string>, mcp: readonly string[] = []): Record<string, string> {
// Both app providers pass the gate (a comma list): the gateway's and Claude Code in the box (opencode-plugins/claude-provider).
- return assertEngineGates({ ...env, ...gateEnv({ provider: GATEWAY_PROVIDER_ID, mcp }), OMNIRUSH_GATE_PROVIDERS: APP_PROVIDER_IDS.join(",") });
+ // Stock mode (stock-mode.mjs): the gateway's only, and no MCP server.
+ const stock = stockMode(env);
+ return assertEngineGates({ ...env, ...gateEnv({ provider: GATEWAY_PROVIDER_ID, mcp: stock ? [] : mcp }), OMNIRUSH_GATE_PROVIDERS: stock ? STOCK_PROVIDER : APP_PROVIDER_IDS.join(",") });
}
export function assertEngineGates(env: Record<string, string | undefined>): Record<string, string> {
@@ -191,7 +194,7 @@ export async function createManagedOpencodeV2Server(
"LANG", "LC_ALL", "LC_CTYPE", "TZ", "TERM", "CI",
"XDG_CACHE_HOME", "XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_STATE_HOME", "XDG_RUNTIME_DIR",
"SystemRoot", "SYSTEMROOT", "WINDIR", "COMSPEC", "PATHEXT", "USERPROFILE", "APPDATA", "LOCALAPPDATA",
- "NODE_EXTRA_CA_CERTS", "SSL_CERT_FILE", "SSL_CERT_DIR",
+ "NODE_EXTRA_CA_CERTS", "SSL_CERT_FILE", "SSL_CERT_DIR", STOCK_ENV,
]) {
const value = options.env?.[key] ?? process.env[key];
if (value !== undefined) inherited[key] = value;
@@ -298,7 +301,8 @@ export async function createManagedOpencodeV2Server(
async function writeProviders(): Promise<void> {
const providerConfig: Record<string, unknown> = {};
- for (const provider of providers.values()) {
+ const stock = stockMode(process.env);
+ for (const provider of stock ? stockProviders([...providers.values()]) : providers.values()) {
// Only the providers the lock allows (provider-lock.ts) reach the v2 engine.
if (!providerAllowed(provider.id)) continue;
const models: Record<string, unknown> = {};
@@ -340,7 +344,7 @@ export async function createManagedOpencodeV2Server(
// On: the stock websearch tool searches through Exa (the engine's keyless default), like the CLI.
// Off: no provider is picked (never `false`, which would take the tool out of the stock list).
// shortcut: Exa until the gateway serves a search integration of its own.
- ...(options.webSearch?.() ? { websearch: { provider: "exa" } } : {}),
+ ...(!stock && options.webSearch?.() ? { websearch: { provider: "exa" } } : {}),
...(box ? { shell: box.shell } : {}),
plugins: await pluginDirectories(join(options.rootDir, "plugins"), [sessionNextPluginPath(), ...(options.env?.OMNIRUSH_SERVER_URL ? [managedPolicyPluginPath(true)] : []), ...(box ? [box.plugin] : [])]),
}, null, 2)}\n`, (file, text) => writeFileAtomic(file, text, { mode: 0o600 }));
diff --git a/apps/server/src/omnirush-gateway-broker.ts b/apps/server/src/omnirush-gateway-broker.ts
index c00a25d2..691e6046 100644
--- a/apps/server/src/omnirush-gateway-broker.ts
+++ b/apps/server/src/omnirush-gateway-broker.ts
@@ -18,6 +18,7 @@ import { gatewayUrlAllowed, RELEASE_GATEWAY_ERROR } from "./release-guard.js";
import { BOX_HEADER, MODEL_NOT_IN_MODE, notInModeMessage, projectMode } from "./model-modes/model-modes.mjs";
import { MODE_NOT_BOUND, MODEL_NOT_BOUND, REFUSED_HEADER, SESSION_BIND_UNCONFIRMED, STRICT_SESSION_HEADER, SESSION_BINDING_CONFLICT, SESSION_MODEL_USED, VERIFICATION_REQUIRED, sessionBinder, strictSessions, type StrictSessions } from "./model-modes/strict-sessions.mjs";
import { ClaudeDeviceAccess, type ClaudeAuthorization, type ClaudeDeviceRequest } from "./claude-code/access.js";
+import { stockMode } from "./stock-mode/stock-mode.mjs";
/** A main chat's request on another model than the one it started on (one model per chat). */
const SESSION_MODEL_FIXED = "session_model_fixed";
@@ -2212,7 +2213,9 @@ export class OmniRushGatewayBroker {
accessToken: string | undefined,
requestId: string,
): Promise<Response> {
- body = this.titleOnChatModel(request, path, body);
+ // Stock mode (stock-mode.mjs): the engine's request bodies go out as the engine wrote them (auth and routing only).
+ const stock = stockMode();
+ if (!stock) body = this.titleOnChatModel(request, path, body);
// A model the chat's mode does not allow: refused here as the gateway would, never sent.
if (this.modelInMode && body !== undefined && (path === "responses" || path === "responses/compact")) {
const model = requestedModel(body);
@@ -2238,7 +2241,7 @@ export class OmniRushGatewayBroker {
: null;
if (unknownSession && !this.bindsConfirmed.has(unknownSession)) this.uploadHold(unknownSession, "pending");
const confirmed = (response: Response) => (unknownSession ? this.confirmOnCompletion(response, unknownSession) : response);
- const forwardedBody = path === "responses" && body !== undefined
+ const forwardedBody = !stock && path === "responses" && body !== undefined
? await withReasoningSummary(body, this.reasoningSummaryFor)
: body;
let failure: ReturnType<typeof fetchFailure> | null = null;
diff --git a/apps/server/src/opencode-plugins/omnirush-box.ts b/apps/server/src/opencode-plugins/omnirush-box.ts
index c1faa06c..8cd0393d 100644
--- a/apps/server/src/opencode-plugins/omnirush-box.ts
+++ b/apps/server/src/opencode-plugins/omnirush-box.ts
@@ -89,6 +89,8 @@ export const OmniRushBox = async ({ directory, client }: { directory?: string; c
const line = output.system[i];
if (typeof line === "string") output.system[i] = line.replace(/^(\s*Platform:\s*)(darwin|win32|linux)\s*$/m, "$1linux");
}
+ // Stock mode (stock-mode.mjs, the CLI's opencode-box-plugin.js): the system prompt stays stock apart from its environment lines.
+ if (process.env.OMNIRUSH_FARM === "1") return;
output.system.push(BOX_NOTE(root, Number(rec.uid) || 0, typeof rec.croot === "string" ? rec.croot : root, rec.shadows_note));
},
};
diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts
index 7bf20170..02642e62 100644
--- a/apps/server/src/server.ts
+++ b/apps/server/src/server.ts
@@ -273,6 +273,7 @@ export {
normalizeWorkspaceRelativePath,
resolveWorkspaceArtifactTargets,
} from "./routes/files.js";
+import { stockMode } from "./stock-mode/stock-mode.mjs";
const SERVER_VERSION = pkg.version;
const OPENCODE_VERSION = constants.opencodeVersion.trim().replace(/^v/, "");
@@ -1416,8 +1417,8 @@ export async function startServer(config: ServerConfig): Promise<ServeResult> {
},
});
// Automatic compaction: the server's policy (auto_compact) through the capabilities cache; the
- // window shows a short notice (the "auto.compact.notice" query) while a chat compacts.
- if (gatewayBroker.enabled) {
+ // window shows a short notice (the "auto.compact.notice" query) while a chat compacts. Not in stock mode (stock-mode.mjs).
+ if (gatewayBroker.enabled && !stockMode()) {
autoCompactorsByServer.set(config, new AutoCompactor({
policy: brokerAutoCompactPolicy((options) => gatewayBroker.sessionUploadCapabilities(options)),
holdMs: AUTO_COMPACT_HOLD_MS,
@@ -1672,7 +1673,8 @@ export async function startServer(config: ServerConfig): Promise<ServeResult> {
const directory = info && isRecord(info.location) && typeof info.location.directory === "string" ? info.location.directory : null;
return directory ? engineTarget(v2.url, headers, `?${new URLSearchParams({ "location[directory]": directory })}`, "v2") : null;
};
- budgetWrap = createV2BudgetWrap({
+ // Stock mode (stock-mode.mjs): no wrap-up offer (the gateway's own quota answer still shows).
+ budgetWrap = stockMode() ? undefined : createV2BudgetWrap({
control: async (id, args) => {
const result: unknown = await uiControl.request("query", { id, args });
if (!isRecord(result) || result.ok !== true || !isRecord(result.result)) return "unavailable";
diff --git a/apps/server/src/stock-mode/stock-mode.d.mts b/apps/server/src/stock-mode/stock-mode.d.mts
new file mode 100644
index 00000000..c54e4712
--- /dev/null
+++ b/apps/server/src/stock-mode/stock-mode.d.mts
@@ -0,0 +1,7 @@
+export declare const STOCK_ENV: "OMNIRUSH_FARM";
+export declare const STOCK_PROVIDER: "omnirush";
+export declare const STOCK_MODEL: "gpt-6-astra";
+export declare const STOCK_SWITCHES: Readonly<Record<string, string>>;
+export declare function stockMode(env?: Record<string, string | undefined>): boolean;
+export declare function applyStockSwitches(env?: Record<string, string | undefined>): boolean;
+export declare function stockProviders<T extends { id: string; models: { id: string; config?: Record<string, unknown> }[] }>(specs: T[]): T[];
diff --git a/apps/server/src/stock-mode/stock-mode.mjs b/apps/server/src/stock-mode/stock-mode.mjs
new file mode 100644
index 00000000..cda16a8c
--- /dev/null
+++ b/apps/server/src/stock-mode/stock-mode.mjs
@@ -0,0 +1,57 @@
+// Stock mode (STOCK_ENV=1 when the app starts; nothing in the app turns it on): chats run stock OpenCode 2.x on
+// GPT 6 Astra and nothing on top of it, as the CLI's src/stock.js. The engine gets its stock tools and system prompt:
+// no OmniRush context, app tools, MCP servers, computer use, web search provider, Claude or other models, sandbox
+// note, automatic compaction or wrap-up offer, and no install-log wrappers. Sign-in, the gateway broker (auth and
+// routing only), capture and uploads, and the sandbox stay. Uploads keep the exact shape of any 2.x chat.
+
+export const STOCK_ENV = "OMNIRUSH_FARM";
+export const STOCK_PROVIDER = "omnirush";
+export const STOCK_MODEL = "gpt-6-astra";
+
+/** Whether this run is in stock mode. */
+export function stockMode(env = process.env) {
+ return ["1", "true", "on", "yes"].includes(String(env?.[STOCK_ENV] ?? "").trim().toLowerCase());
+}
+
+/** The switches the app already has, set for the whole run (the CLI's STOCK_SWITCHES). */
+export const STOCK_SWITCHES = Object.freeze({
+ [STOCK_ENV]: "1",
+ OMNIRUSH_BEST_PRACTICES: "0",
+ OMNIRUSH_WEB_SEARCH: "0",
+ OMNIRUSH_SELF_CHECK: "0",
+ OMNIRUSH_PROJECT_NOTES: "0",
+ OMNIRUSH_CODE_DIAGNOSTICS: "0",
+ OMNIRUSH_SMART_COMPACTION: "0",
+ OMNIRUSH_BUILDATHON: "0",
+ OMNIRUSH_COMPUTER_USE: "0",
+ OMNIRUSH_PLACEMENTS: "0",
+ OMNIRUSH_FOLLOW_UP_HINT: "0",
+ // No install-log wrappers on the agent's PATH (host or sandbox): stock has none.
+ OMNIRUSH_INSTALL_LOG: "0",
+});
+
+/** Sets the stock switches in `env` when it asks for stock mode; returns whether it does. */
+export function applyStockSwitches(env = process.env) {
+ if (!stockMode(env)) return false;
+ Object.assign(env, STOCK_SWITCHES);
+ return true;
+}
+
+const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
+
+/**
+ * The engine's providers in stock mode: the gateway's, with GPT 6 Astra only and without our web search option.
+ * Empty when the account's catalog has no GPT 6 Astra.
+ */
+export function stockProviders(specs) {
+ return specs.flatMap((spec) => {
+ if (spec.id !== STOCK_PROVIDER) return [];
+ const models = spec.models.filter((model) => model.id === STOCK_MODEL).map((model) => {
+ const config = isRecord(model.config) ? model.config : {};
+ const { hostedWebSearch: _hosted, ...options } = isRecord(config.options) ? config.options : {};
+ const { options: _options, ...rest } = config;
+ return { ...model, config: { ...rest, ...(Object.keys(options).length ? { options } : {}) } };
+ });
+ return models.length ? [{ ...spec, models }] : [];
+ });
+}
diff --git a/apps/server/src/stock-mode/stock-mode.test.ts b/apps/server/src/stock-mode/stock-mode.test.ts
new file mode 100644
index 00000000..6350476a
--- /dev/null
+++ b/apps/server/src/stock-mode/stock-mode.test.ts
@@ -0,0 +1,44 @@
+import { expect, test } from "bun:test";
+
+import { engineV2SpawnEnv } from "../managed-opencode-v2.js";
+import { applyStockSwitches, STOCK_SWITCHES, stockMode, stockProviders } from "./stock-mode.mjs";
+
+const base = { PATH: "/usr/bin", OMNIRUSH_NO_SYSTEM_CONFIG: "1" };
+
+test("stock mode is on only when asked, and sets the CLI's switches", () => {
+ expect(stockMode({})).toBe(false);
+ expect(stockMode({ OMNIRUSH_FARM: "0" })).toBe(false);
+ for (const value of ["1", "true", " ON ", "yes"]) expect(stockMode({ OMNIRUSH_FARM: value })).toBe(true);
+ const off: Record<string, string> = {};
+ expect(applyStockSwitches(off)).toBe(false);
+ expect(off).toEqual({});
+ const on: Record<string, string> = { OMNIRUSH_FARM: "true" };
+ expect(applyStockSwitches(on)).toBe(true);
+ expect(on).toEqual({ ...STOCK_SWITCHES });
+ expect(on.OMNIRUSH_FARM).toBe("1");
+ expect(on.OMNIRUSH_INSTALL_LOG).toBe("0");
+ expect(on.OMNIRUSH_COMPUTER_USE).toBe("0");
+});
+
+test("the engine gets the gateway's GPT 6 Astra only, without our web search option", () => {
+ const astra = { id: "gpt-6-astra", name: "GPT 6 Astra", config: { reasoning: true, options: { reasoningEffort: "high", hostedWebSearch: { searchContextSize: "low" } } } };
+ const specs = [
+ { id: "omnirush", name: "OmniRush", apiKey: "k", models: [astra, { id: "kimi-k3.1-pro", name: "Kimi", config: {} }] },
+ { id: "omnirush-claude", name: "Claude", apiKey: "k", models: [{ id: "opus", name: "Opus", config: {} }] },
+ ];
+ const out = stockProviders(specs);
+ expect(out.map((spec) => spec.id)).toEqual(["omnirush"]);
+ expect(out[0]!.models.map((model) => model.id)).toEqual(["gpt-6-astra"]);
+ expect(out[0]!.models[0]!.config).toEqual({ reasoning: true, options: { reasoningEffort: "high" } });
+ expect(astra.config.options.hostedWebSearch).toBeDefined();
+ expect(stockProviders([{ ...specs[0]!, models: [specs[0]!.models[1]!] }])).toEqual([]);
+});
+
+test("the engine gate lets only the gateway and no MCP server through in stock mode", () => {
+ const normal = engineV2SpawnEnv({ ...base }, ["computer"]);
+ expect(normal.OMNIRUSH_GATE_PROVIDERS).toBe("omnirush,omnirush-claude");
+ expect(normal.OMNIRUSH_GATE_MCP).toContain("computer");
+ const stock = engineV2SpawnEnv({ ...base, OMNIRUSH_FARM: "1" }, ["computer"]);
+ expect(stock.OMNIRUSH_GATE_PROVIDERS).toBe("omnirush");
+ expect(stock.OMNIRUSH_GATE_MCP).toBe("");
+});