Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: stock mode keeps the engine prompt stock and the model list carries efforts

ogsamrata3251559a5e0
diff --git a/apps/server/src/engine-v2-preview.ts b/apps/server/src/engine-v2-preview.ts
index 1473ee65..4b30a1fe 100644
--- a/apps/server/src/engine-v2-preview.ts
+++ b/apps/server/src/engine-v2-preview.ts
@@ -31,7 +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";
+import { stockMode, stockProviders } from "./stock-mode/stock-mode.mjs";
const PREVIEW_STATE_FILE = "engine-v2-preview.json";
const UNSET_API_KEY = "omnirush-engine-v2-preview-unset";
@@ -461,8 +461,10 @@ export function createEngineV2Preview(options: {
}
const mapped = mapRuntimeProvidersToV2Specs(providerMap, credentials);
// Claude Code under the engine: its own spec (an `aisdk:file://` package the mapping above never takes).
- const claude = await options.claude?.().catch(() => null);
+ const claude = stockMode() ? null : await options.claude?.().catch(() => null);
if (claude) mapped.specs.push(claude);
+ // Stock mode (stock-mode.mjs): the gateway's GPT 6 Astra only, so the engine is not waited on for the rest.
+ if (stockMode()) mapped.specs = stockProviders(mapped.specs);
const nextMirroredProviderIds = mapped.specs.map((spec) => spec.id);
await active.setProviders(mapped.specs);
mirroredSpecs = mapped.specs;
diff --git a/apps/server/src/managed-opencode-v2.effort.test.ts b/apps/server/src/managed-opencode-v2.effort.test.ts
index 32a7f820..27c6d237 100644
--- a/apps/server/src/managed-opencode-v2.effort.test.ts
+++ b/apps/server/src/managed-opencode-v2.effort.test.ts
@@ -32,3 +32,14 @@ test("the app catalog's efforts come through in catalog order", () => {
const entry = v2ModelConfig({ id: "gpt-6-astra", name: "GPT 6 Astra", config: catalog["gpt-6-astra"] });
expect((entry.capabilities as { reasoning: unknown }).reasoning).toEqual({ supported: true, effort: ["low", "high", "xhigh", "max"] });
});
+
+test("the window's model list keeps the efforts' names and never their settings", async () => {
+ const { publicV2Model } = await import("./server.js");
+ const model = publicV2Model({
+ id: "gpt-6-astra", providerID: "omnirush", name: "GPT 6 Astra", settings: { apiKey: "secret" },
+ variants: [{ id: "low", settings: { reasoningEffort: "low", apiKey: "secret" } }, { id: "max", settings: {} }],
+ });
+ expect(model).toEqual({ id: "gpt-6-astra", providerID: "omnirush", name: "GPT 6 Astra", variants: [{ id: "low" }, { id: "max" }] });
+ expect(JSON.stringify(model)).not.toContain("secret");
+ expect(publicV2Model({ id: "plain", providerID: "omnirush" })).toEqual({ id: "plain", providerID: "omnirush" });
+});
diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts
index 9ba31ca8..dea4cf67 100644
--- a/apps/server/src/server.ts
+++ b/apps/server/src/server.ts
@@ -2199,6 +2199,25 @@ function stoppedSendResponse(config: ServerConfig, sessionId: string | null | un
return jsonResponse({ code: "send_stopped", message: "The send was stopped before it reached the engine." }, 409);
}
+/**
+ * A 2.x model as the window may see it: model overrides and variants can carry credentials too, so only the metadata
+ * needed for selection, and the variants' names (the effort picker), never their settings.
+ */
+export function publicV2Model(value: unknown): Record<string, unknown> | null {
+ if (value === null) return null;
+ if (!isRecord(value) || typeof value.id !== "string" || typeof value.providerID !== "string") {
+ throw new ApiError(502, "invalid_engine_response", "Invalid model metadata");
+ }
+ const picked = Object.fromEntries(Object.entries(value).filter(([key]) => [
+ "id", "modelID", "providerID", "canonical", "family", "name", "package",
+ "capabilities", "time", "cost", "status", "enabled", "limit",
+ ].includes(key)));
+ const variants = Array.isArray(value.variants)
+ ? value.variants.flatMap((variant) => (isRecord(variant) && typeof variant.id === "string" ? [{ id: variant.id }] : []))
+ : [];
+ return variants.length ? { ...picked, variants } : picked;
+}
+
export async function proxyOpencodeV2Request(input: {
config: ServerConfig;
request: Request;
@@ -2311,7 +2330,8 @@ export async function proxyOpencodeV2Request(input: {
throw new ApiError(403, "engine_instructions_managed", "OmniRush.ai instructions are managed by the server");
}
- if (method === "POST" && sessionId && /^\/api\/session\/[^/]+\/(?:prompt|command|generate)$/.test(routePath)) {
+ // Stock mode (stock-mode.mjs): the engine's own system prompt only, no OmniRush guidance.
+ if (method === "POST" && sessionId && !stockMode() && /^\/api\/session\/[^/]+\/(?:prompt|command|generate)$/.test(routePath)) {
// Session ownership was verified above. Replace one native instruction
// entry immediately before admission; never append to conversation text.
const internalHeaders = new Headers({ authorization: headers.get("authorization") ?? "", "content-type": "application/json" });
@@ -2497,21 +2517,10 @@ export async function proxyOpencodeV2Request(input: {
return jsonResponse({ data });
}
if (method === "GET" && /^\/api\/model(?:\/|$)/.test(decodedPath) && response.ok) {
- // Model overrides and variants can carry credentials too. Keep only the
- // metadata needed for selection; request settings remain inside the engine.
+ // Only what selection needs (publicV2Model); request settings remain inside the engine.
const payload: unknown = await response.json();
const raw = isRecord(payload) && "data" in payload ? payload.data : payload;
- const publicModel = (value: unknown) => {
- if (value === null) return null;
- if (!isRecord(value) || typeof value.id !== "string" || typeof value.providerID !== "string") {
- throw new ApiError(502, "invalid_engine_response", "Invalid model metadata");
- }
- return Object.fromEntries(Object.entries(value).filter(([key]) => [
- "id", "modelID", "providerID", "canonical", "family", "name", "package",
- "capabilities", "time", "cost", "status", "enabled", "limit",
- ].includes(key)));
- };
- return jsonResponse({ data: Array.isArray(raw) ? raw.map(publicModel) : publicModel(raw) });
+ return jsonResponse({ data: Array.isArray(raw) ? raw.map(publicV2Model) : publicV2Model(raw) });
}
if (method === "GET" && /^\/api\/event\/*$/.test(decodedPath) && response.ok && response.body) {
const expected = await realpath(input.workspace.path);