always use engine (#1525)

<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Always route Dyad Pro through the Dyad engine (no gateway), simplify
logging/flags, and remove DYAD_GATEWAY usage and staging gateway script.
> 
> - **Engine/Model client (`src/ipc/utils/get_model_client.ts`)**:
> - Always use `createDyadEngine` when Dyad Pro is enabled; remove
gateway fallback and `DYAD_GATEWAY_URL` usage.
> - Simplify logs to engine-only; drop conditional gateway/engine
logging.
> - Always set `isEngineEnabled: true`; pass `{ files }` to the provider
unconditionally; strip `:free` from model names.
> - **Scripts (`package.json`)**:
>   - Remove `staging:gateway` script.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5fdbbb703c47de4623ceeb82e6678ace34dc268e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This commit is contained in:
Will Chen
2025-10-13 19:14:05 -07:00
committed by GitHub
parent 348521ce82
commit 4926a01a0f
3 changed files with 26 additions and 66 deletions

View File

@@ -1,19 +0,0 @@
import { testSkipIfWindows } from "./helpers/test_helper";
testSkipIfWindows("claude 4 sonnet", async ({ po }) => {
await po.setUpDyadPro();
// Disable the pro modes so it routes to gateway.
const proModesDialog = await po.openProModesDialog({
location: "home-chat-input-container",
});
await proModesDialog.toggleTurboEdits();
await proModesDialog.setSmartContextMode("off");
await proModesDialog.close();
await po.selectModel({ provider: "Anthropic", model: "Claude 4 Sonnet" });
await po.sendPrompt("[dump] tc=gateway-simple");
await po.snapshotServerDump("request");
await po.snapshotMessages({ replaceDumpPath: true });
});

View File

@@ -16,7 +16,6 @@
"start": "electron-forge start",
"dev:engine": "cross-env DYAD_ENGINE_URL=http://localhost:8080/v1 npm start",
"staging:engine": "cross-env DYAD_ENGINE_URL=https://staging---dyad-llm-engine-kq7pivehnq-uc.a.run.app/v1 npm start",
"staging:gateway": "cross-env DYAD_GATEWAY_URL=https://staging---litellm-gcp-cloud-run-kq7pivehnq-uc.a.run.app/v1 npm start",
"package": "npm run clean && electron-forge package",
"make": "npm run clean && electron-forge make",
"publish": "npm run clean && electron-forge publish",

View File

@@ -27,7 +27,6 @@ import { getOllamaApiUrl } from "../handlers/local_model_ollama_handler";
import { createFallback } from "./fallback_ai_model";
const dyadEngineUrl = process.env.DYAD_ENGINE_URL;
const dyadGatewayUrl = process.env.DYAD_GATEWAY_URL;
const AUTO_MODELS = [
{
@@ -85,12 +84,7 @@ export async function getModelClient(
// IMPORTANT: some providers like OpenAI have an empty string gateway prefix,
// so we do a nullish and not a truthy check here.
if (providerConfig.gatewayPrefix != null || dyadEngineUrl) {
const isEngineEnabled =
settings.enableProSmartFilesContextMode ||
settings.enableProLazyEditsMode ||
settings.enableProWebSearch;
const provider = isEngineEnabled
? createDyadEngine({
const provider = createDyadEngine({
apiKey: dyadApiKey,
baseURL: dyadEngineUrl ?? "https://engine.dyad.sh/v1",
originalProviderId: model.provider,
@@ -105,42 +99,28 @@ export async function getModelClient(
enableWebSearch: settings.enableProWebSearch,
},
settings,
})
: createOpenAICompatible({
name: "dyad-gateway",
apiKey: dyadApiKey,
baseURL: dyadGatewayUrl ?? "https://llm-gateway.dyad.sh/v1",
});
logger.info(
`\x1b[1;97;44m Using Dyad Pro API key for model: ${model.name}. engine_enabled=${isEngineEnabled} \x1b[0m`,
`\x1b[1;97;44m Using Dyad Pro API key for model: ${model.name} \x1b[0m`,
);
if (isEngineEnabled) {
logger.info(
`\x1b[1;30;42m Using Dyad Pro engine: ${dyadEngineUrl ?? "<prod>"} \x1b[0m`,
);
} else {
logger.info(
`\x1b[1;30;43m Using Dyad Pro gateway: ${dyadGatewayUrl ?? "<prod>"} \x1b[0m`,
);
}
// Do not use free variant (for openrouter).
const modelName = model.name.split(":free")[0];
const autoModelClient = {
model: provider(
`${providerConfig.gatewayPrefix || ""}${modelName}`,
isEngineEnabled
? {
model: provider(`${providerConfig.gatewayPrefix || ""}${modelName}`, {
files,
}
: undefined,
),
}),
builtinProviderId: model.provider,
};
return {
modelClient: autoModelClient,
isEngineEnabled,
isEngineEnabled: true,
};
} else {
logger.warn(