From 8a967414410b615a564ffc348cff9a5df3bd9110 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sat, 11 Oct 2025 19:32:33 +0200 Subject: [PATCH] Revert: Fix extension context detection - original logic was correct The negated approach broke browser_script which runs in page context. browser_script injects into web pages (http://, https://) where chrome.runtime.sendMessage doesn't work. The original whitelist approach correctly identifies extension contexts only. The real issue with artifacts in sandbox iframes needs a different fix. --- packages/ai/src/models.generated.ts | 74 ++++++++++++++----- .../sandbox/RuntimeMessageBridge.ts | 14 ++-- 2 files changed, 60 insertions(+), 28 deletions(-) diff --git a/packages/ai/src/models.generated.ts b/packages/ai/src/models.generated.ts index ef2c8479..c2d90e6c 100644 --- a/packages/ai/src/models.generated.ts +++ b/packages/ai/src/models.generated.ts @@ -1651,6 +1651,57 @@ export const MODELS = { } satisfies Model<"anthropic-messages">, }, openrouter: { + "nvidia/llama-3.3-nemotron-super-49b-v1.5": { + id: "nvidia/llama-3.3-nemotron-super-49b-v1.5", + name: "NVIDIA: Llama 3.3 Nemotron Super 49B V1.5", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + reasoning: true, + input: ["text"], + cost: { + input: 0.09999999999999999, + output: 0.39999999999999997, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 131072, + maxTokens: 4096, + } satisfies Model<"openai-completions">, + "qwen/qwen3-vl-30b-a3b-thinking": { + id: "qwen/qwen3-vl-30b-a3b-thinking", + name: "Qwen: Qwen3 VL 30B A3B Thinking", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + reasoning: true, + input: ["text", "image"], + cost: { + input: 0.3, + output: 1, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 262144, + maxTokens: 262144, + } satisfies Model<"openai-completions">, + "qwen/qwen3-vl-30b-a3b-instruct": { + id: "qwen/qwen3-vl-30b-a3b-instruct", + name: "Qwen: Qwen3 VL 30B A3B Instruct", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + reasoning: false, + input: ["text", "image"], + cost: { + input: 0.3, + output: 1, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 262144, + maxTokens: 262144, + } satisfies Model<"openai-completions">, "z-ai/glm-4.6": { id: "z-ai/glm-4.6", name: "Z.AI: GLM 4.6", @@ -2960,23 +3011,6 @@ export const MODELS = { contextWindow: 32768, maxTokens: 16384, } satisfies Model<"openai-completions">, - "deepseek/deepseek-r1-distill-llama-70b": { - id: "deepseek/deepseek-r1-distill-llama-70b", - name: "DeepSeek: R1 Distill Llama 70B", - api: "openai-completions", - provider: "openrouter", - baseUrl: "https://openrouter.ai/api/v1", - reasoning: true, - input: ["text"], - cost: { - input: 0.03, - output: 0.13, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 131072, - maxTokens: 131072, - } satisfies Model<"openai-completions">, "deepseek/deepseek-r1": { id: "deepseek/deepseek-r1", name: "DeepSeek: R1", @@ -3054,13 +3088,13 @@ export const MODELS = { reasoning: false, input: ["text"], cost: { - input: 0.04, - output: 0.12, + input: 0.13, + output: 0.39, cacheRead: 0, cacheWrite: 0, }, contextWindow: 131072, - maxTokens: 131072, + maxTokens: 120000, } satisfies Model<"openai-completions">, "amazon/nova-lite-v1": { id: "amazon/nova-lite-v1", diff --git a/packages/web-ui/src/components/sandbox/RuntimeMessageBridge.ts b/packages/web-ui/src/components/sandbox/RuntimeMessageBridge.ts index ac097445..1e838b15 100644 --- a/packages/web-ui/src/components/sandbox/RuntimeMessageBridge.ts +++ b/packages/web-ui/src/components/sandbox/RuntimeMessageBridge.ts @@ -29,12 +29,11 @@ export class RuntimeMessageBridge { return ` window.__completionCallbacks = []; // Check if we're in an extension context by examining the URL -// We check for web/file protocols and negate - anything else is extension context window.__isExtensionContext = () => { const url = window.location.href; - return !(url.startsWith('http://') || - url.startsWith('https://') || - url.startsWith('file://')); + return url.startsWith('chrome-extension://') || + url.startsWith('moz-extension://') || + url === 'about:srcdoc'; }; window.sendRuntimeMessage = async (message) => { const messageId = 'msg_' + Date.now() + '_' + Math.random().toString(36).substring(2, 9); @@ -77,12 +76,11 @@ window.onCompleted = (callback) => { return ` window.__completionCallbacks = []; // Check if we're in an extension context by examining the URL -// We check for web/file protocols and negate - anything else is extension context window.__isExtensionContext = () => { const url = window.location.href; - return !(url.startsWith('http://') || - url.startsWith('https://') || - url.startsWith('file://')); + return url.startsWith('chrome-extension://') || + url.startsWith('moz-extension://') || + url === 'about:srcdoc'; }; window.sendRuntimeMessage = async (message) => { return await chrome.runtime.sendMessage({