Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Merge origin/main into feat/clarify-timeout-finish to resolve conflicts

Emre Sokullu6372c03e959e
diff --cc src/chrome/src/agent/agent.js
index 0cbef29e1,a51f9c833..02d183253
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@@ -163,11 -163,7 +163,11 @@@ import { generateImage, readMediaConfi
import { GENERATIVE_MEDIA_SETUP_NOTE, isImageGenConfigured, mediaPermissionUrl, validateMediaConfig } from './media-config.js';
import { extractFirstJsonObject } from './json-extract.js';
import { repairAssistantDisplayText, repairClarifyText, sanitizeText as sanitizePlannerText } from './text-sanitize.js';
+import { clarifyQuestionIsHard, clarifyTimedAnswer, clarifyTimeoutChoice, normalizeClarifyConsequence, normalizeClarifyTimeoutPolicy } from './clarify-timeout.js';
+import { guardAdvisory, guardEntry, guardOutcome, withGuardAdvisories } from './guard-policy.js';
+import { UNVERIFIED_STEP_CONTENT_LIMIT, UNVERIFIED_STEP_PROMPT_KIND, clipUnverifiedStepContent, normalizeUnverifiedStepConfirmation } from './unverified-step.js';
+import { leanSkipsGuard, normalizeLeanModeSetting, resolveLeanMode } from './lean-mode.js';
- import { emptyOutputFailureMessage, modelOutputDiagnostics } from './model-output-diagnostics.js';
+ import { RESPONSE_CUT_OFF_NOTICE, cutOffPartialFromError, emptyOutputFailureMessage, modelOutputDiagnostics, outputWasCutOff } from './model-output-diagnostics.js';
import { stepLimitUserMessage, terminalGuardUserMessage } from './terminal-messages.js';
import { buildCustomSkillsPrompt, buildSkillLoaderDefinition, buildSkillToolDefinitions, buildSkillToolRegistry, getEligibleCustomSkills, getEligibleSkillCatalog, normalizeCustomSkills } from './skills.js';
import { OTP_EMAIL_PROVIDER_IDS, OTP_EMAIL_SKILL_ID, OTP_EMAIL_TOOL_NAME, otpEmailCandidates, otpEmailProviderForUrl, otpEmailUrlLooksLikeMessage, otpOpenMessageRootRef, otpRedactRefs, otpServiceDisplay, otpServiceKey, otpVerificationMessageExcerpt, selectOtpMailboxTab, selectUniqueOtpCandidateByPreview } from './otp-email-tool.js';
@@@ -9516,8 -8500,19 +9518,20 @@@ export class Agent extends LoopDetecto
const after = await this._recordCostUsage(provider, result?.usage, costState);
if (after) result.costAllowanceMessage = after;
return result;
+ } catch (error) {
+ // A call that ends in a provider error can still have been billed (OpenAI Responses
+ // stopped at max_output_tokens): count what it reports before the error moves on.
+ if (error?.billedUsage) {
+ try {
+ // A call that is the one to reach the allowance says so on the error, as a
+ // completed call says so on its result, for callers that show it.
+ const stopped = await this._recordCostUsage(provider, error.billedUsage, costState);
+ if (stopped) error.costAllowanceMessage = stopped;
+ } catch { /* the original error matters more */ }
+ }
+ throw error;
} finally {
+ hold?.release();
linked.dispose();
}
}
diff --cc src/chrome/src/config-transfer.js
index bb75b00dc,889e10cda..40f480b82
--- a/src/chrome/src/config-transfer.js
+++ b/src/chrome/src/config-transfer.js
@@@ -242,9 -236,8 +242,9 @@@ function sanitizeProviders(value, { str
}
function validSettingValue(key, value) {
- if (key === 'decisionProvider') return ['', 'openrouter', 'typesafe', 'local', 'webgpu_d1'].includes(value);
+ if (key === 'decisionProvider') return ['', 'openrouter', 'typesafe', 'local', 'webgpu_d1', 'webgpu_chat'].includes(value);
if (key === 'decisionVisionMode') return ['auto', 'on', 'off'].includes(value);
+ if (key === 'leanMode') return ['auto', 'on', 'off'].includes(value);
if (key === 'decisionBaseUrl') {
if (typeof value !== 'string') return false;
try { resolveDecisionConfig({ decisionProvider: 'local', decisionBaseUrl: value }); return true; }
diff --cc src/chrome/src/ui/settings.js
index 4888c4d0c,3ce8d59a2..b73d4eef9
--- a/src/chrome/src/ui/settings.js
+++ b/src/chrome/src/ui/settings.js
@@@ -1,5 -1,4 +1,5 @@@
- import { DECISION_SETTINGS_KEYS, DEFAULT_DECISION_MODEL, resolveDecisionConfig } from '../agent/decision-config.js';
+ import { DECISION_SETTINGS_KEYS, DEFAULT_DECISION_MODEL, WEBGPU_CHAT_DECISION_MODEL, resolveDecisionConfig } from '../agent/decision-config.js';
+import { normalizeLeanModeSetting } from '../agent/lean-mode.js';
import { D1_MODEL_ID } from '../providers/d1-config.js';
import { initD1Settings } from './d1-settings.js';
/**
@@@ -634,7 -685,7 +689,7 @@@ async function init()
chrome.storage.local.remove(['authToken', 'authEmail', 'authDefaultModel']).catch(() => {});
// Load display settings
- const stored = await chrome.storage.local.get([...DECISION_SETTINGS_KEYS, 'verboseMode', 'composerDeliveryMode', 'selectionShortcutEnabled', 'pdfViewerEnabled', AUTO_GROUP_TABS_KEY, 'helpImproveWebBrain', 'screenshotFallback', 'maxAgentSteps', 'autoScreenshot', 'useSiteAdapters', 'researchEscalationEnabled', 'researchEscalationEngine', 'voiceInputEnabled', 'alwaysAllowApiMutations', 'apiMutationObserverEnabled', 'webMcpEnabled', 'openaiAskStreamingEnabled', 'planBeforeActMode', 'planBeforeAct', 'planReviewMode', 'planReviewConfidenceThreshold', DOWNLOAD_DIRECTORY_STORAGE_KEY, 'notifySound', 'completionConfetti', 'completionFlashTab', 'tracingEnabled', 'feedbackDiagnosticsEnabled', 'losslessTrace', 'strictSecretMode', 'strictGuards', 'leanMode', 'agentAllowLocalNetwork', 'scheduledTasksEnabled', 'scheduledRequireConsequentialConfirmation', 'systemOneEnabled', 'systemOneWatchEnabled', 'systemOneCompletionEnabled', 'systemOneFastClassifications', 'systemOneFastBrowser', 'systemOneWatchThreshold', 'systemOneCompletionThreshold', 'typesafeApiKey', 'providerFilter', 'requestTimeoutMs', 'clarifyTimeoutSec', 'clarifyTimeoutSemanticsV2', 'clarifyTimeoutPolicy', 'costAllowanceSessionUsd', 'costAllowanceTotalUsd', 'meteredProviderCostSpentUsd', 'screenshotRedaction', 'imageDetail', 'maxScreenshotsPerTurn', 'maxImageDimension']);
- const stored = await chrome.storage.local.get([...DECISION_SETTINGS_KEYS, 'verboseMode', 'composerDeliveryMode', 'selectionShortcutEnabled', 'pdfViewerEnabled', AUTO_GROUP_TABS_KEY, 'helpImproveWebBrain', 'screenshotFallback', 'maxAgentSteps', 'autoScreenshot', 'useSiteAdapters', 'researchEscalationEnabled', 'researchEscalationEngine', 'voiceInputEnabled', 'alwaysAllowApiMutations', 'apiMutationObserverEnabled', 'webMcpEnabled', 'openaiAskStreamingEnabled', 'planBeforeActMode', 'planBeforeAct', 'planReviewMode', 'planReviewConfidenceThreshold', DOWNLOAD_DIRECTORY_STORAGE_KEY, 'notifySound', 'completionConfetti', 'completionFlashTab', 'tracingEnabled', 'feedbackDiagnosticsEnabled', 'losslessTrace', 'strictSecretMode', 'agentAllowLocalNetwork', 'scheduledTasksEnabled', 'scheduledRequireConsequentialConfirmation', 'systemOneEnabled', 'systemOneWatchEnabled', 'systemOneCompletionEnabled', 'systemOneFastClassifications', 'systemOneFastBrowser', 'systemOneWatchThreshold', 'systemOneCompletionThreshold', 'typesafeApiKey', DECISION_SUGGESTION_DISMISSED_KEY, 'providerFilter', 'requestTimeoutMs', 'clarifyTimeoutSec', 'clarifyTimeoutSemanticsV2', 'costAllowanceSessionUsd', 'costAllowanceTotalUsd', 'meteredProviderCostSpentUsd', 'screenshotRedaction', 'imageDetail', 'maxScreenshotsPerTurn', 'maxImageDimension']);
++ const stored = await chrome.storage.local.get([...DECISION_SETTINGS_KEYS, 'verboseMode', 'composerDeliveryMode', 'selectionShortcutEnabled', 'pdfViewerEnabled', AUTO_GROUP_TABS_KEY, 'helpImproveWebBrain', 'screenshotFallback', 'maxAgentSteps', 'autoScreenshot', 'useSiteAdapters', 'researchEscalationEnabled', 'researchEscalationEngine', 'voiceInputEnabled', 'alwaysAllowApiMutations', 'apiMutationObserverEnabled', 'webMcpEnabled', 'openaiAskStreamingEnabled', 'planBeforeActMode', 'planBeforeAct', 'planReviewMode', 'planReviewConfidenceThreshold', DOWNLOAD_DIRECTORY_STORAGE_KEY, 'notifySound', 'completionConfetti', 'completionFlashTab', 'tracingEnabled', 'feedbackDiagnosticsEnabled', 'losslessTrace', 'strictSecretMode', 'strictGuards', 'leanMode', 'agentAllowLocalNetwork', 'scheduledTasksEnabled', 'scheduledRequireConsequentialConfirmation', 'systemOneEnabled', 'systemOneWatchEnabled', 'systemOneCompletionEnabled', 'systemOneFastClassifications', 'systemOneFastBrowser', 'systemOneWatchThreshold', 'systemOneCompletionThreshold', 'typesafeApiKey', DECISION_SUGGESTION_DISMISSED_KEY, 'providerFilter', 'requestTimeoutMs', 'clarifyTimeoutSec', 'clarifyTimeoutSemanticsV2', 'clarifyTimeoutPolicy', 'costAllowanceSessionUsd', 'costAllowanceTotalUsd', 'meteredProviderCostSpentUsd', 'screenshotRedaction', 'imageDetail', 'maxScreenshotsPerTurn', 'maxImageDimension']);
if (typeof stored.providerFilter === 'string' && ['all','active','local','cloud','router'].includes(stored.providerFilter)) {
providerFilter = stored.providerFilter;
}
diff --cc src/firefox/src/agent/agent.js
index 995070b7a,c27d4e71d..5c9b8c557
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@@ -155,11 -155,7 +155,11 @@@ import { generateImage, readMediaConfi
import { GENERATIVE_MEDIA_SETUP_NOTE, isImageGenConfigured, mediaPermissionUrl, validateMediaConfig } from './media-config.js';
import { extractFirstJsonObject } from './json-extract.js';
import { repairAssistantDisplayText, repairClarifyText, sanitizeText as sanitizePlannerText } from './text-sanitize.js';
+import { clarifyQuestionIsHard, clarifyTimedAnswer, clarifyTimeoutChoice, normalizeClarifyConsequence, normalizeClarifyTimeoutPolicy } from './clarify-timeout.js';
+import { guardAdvisory, guardEntry, guardOutcome, withGuardAdvisories } from './guard-policy.js';
+import { UNVERIFIED_STEP_CONTENT_LIMIT, UNVERIFIED_STEP_PROMPT_KIND, clipUnverifiedStepContent, normalizeUnverifiedStepConfirmation } from './unverified-step.js';
+import { leanSkipsGuard, normalizeLeanModeSetting, resolveLeanMode } from './lean-mode.js';
- import { emptyOutputFailureMessage, modelOutputDiagnostics } from './model-output-diagnostics.js';
+ import { RESPONSE_CUT_OFF_NOTICE, cutOffPartialFromError, emptyOutputFailureMessage, modelOutputDiagnostics, outputWasCutOff } from './model-output-diagnostics.js';
import { stepLimitUserMessage, terminalGuardUserMessage } from './terminal-messages.js';
import { buildCustomSkillsPrompt, buildSkillLoaderDefinition, buildSkillToolDefinitions, buildSkillToolRegistry, getEligibleCustomSkills, getEligibleSkillCatalog, normalizeCustomSkills } from './skills.js';
import { OTP_EMAIL_PROVIDER_IDS, OTP_EMAIL_SKILL_ID, OTP_EMAIL_TOOL_NAME, otpEmailCandidates, otpEmailProviderForUrl, otpEmailUrlLooksLikeMessage, otpOpenMessageRootRef, otpRedactRefs, otpServiceDisplay, otpServiceKey, otpVerificationMessageExcerpt, selectOtpMailboxTab, selectUniqueOtpCandidateByPreview } from './otp-email-tool.js';
@@@ -9229,8 -8213,19 +9231,20 @@@ export class Agent extends LoopDetecto
const after = await this._recordCostUsage(provider, result?.usage, costState);
if (after) result.costAllowanceMessage = after;
return result;
+ } catch (error) {
+ // A call that ends in a provider error can still have been billed (OpenAI Responses
+ // stopped at max_output_tokens): count what it reports before the error moves on.
+ if (error?.billedUsage) {
+ try {
+ // A call that is the one to reach the allowance says so on the error, as a
+ // completed call says so on its result, for callers that show it.
+ const stopped = await this._recordCostUsage(provider, error.billedUsage, costState);
+ if (stopped) error.costAllowanceMessage = stopped;
+ } catch { /* the original error matters more */ }
+ }
+ throw error;
} finally {
+ hold?.release();
linked.dispose();
}
}
diff --cc src/firefox/src/config-transfer.js
index bb75b00dc,112dc1683..f2060cdfd
--- a/src/firefox/src/config-transfer.js
+++ b/src/firefox/src/config-transfer.js
@@@ -242,9 -236,8 +242,9 @@@ function sanitizeProviders(value, { str
}
function validSettingValue(key, value) {
- if (key === 'decisionProvider') return ['', 'openrouter', 'typesafe', 'local', 'webgpu_d1'].includes(value);
+ if (key === 'decisionProvider') return ['', 'openrouter', 'typesafe', 'local', 'webgpu_d1', 'webgpu_chat'].includes(value);
if (key === 'decisionVisionMode') return ['auto', 'on', 'off'].includes(value);
+ if (key === 'leanMode') return ['auto', 'on', 'off'].includes(value);
if (key === 'decisionBaseUrl') {
if (typeof value !== 'string') return false;
try { resolveDecisionConfig({ decisionProvider: 'local', decisionBaseUrl: value }); return true; }