Skip to content

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

Merge main into settings_reorg

Emre Sokullu5d1a4a0a15b4
diff --cc docs/providers-and-models.md
index 80f7f2a24,01af2a563..78f2abdb0
--- a/docs/providers-and-models.md
+++ b/docs/providers-and-models.md
@@@ -126,10 -135,10 +138,10 @@@ document with a dedicated decision Work
Worker when the corresponding browser capabilities are available. Mirrored
code is not evidence that every browser/GPU is supported. CPU/WASM control and
shape operators are permitted and explicitly disclosed; it is not a pure-GPU
- claim. Unload or disabling outsourcing releases the Worker/GPU resources and
+ claim. **Unload** or disabling outsourcing releases the Worker/GPU resources and
retains the cache; **Remove cached model** requires the model to be unloaded.
- After **Download and load** or **Load cached model**, D1 stays loaded until
+ After **Download and load** or **Load**, D1 stays loaded until
-it is unloaded, removed or switched off in Settings: a decision that finds it
+it is unloaded, removed or switched off on the Providers page: a decision that finds it
unloaded (a browser restart, a discarded stalled session, a lost GPU device)
starts one reload from the verified cache in the background and uses the
fallback chain meanwhile. A reload never downloads. A decision whose caller
diff --cc package.json
index 11aef62c8,bb48bd8c3..305ec2425
--- a/package.json
+++ b/package.json
@@@ -98,9 -97,9 +98,9 @@@
"test:quality:whatsapp": "node test/quality/whatsapp-contact-matrix.mjs",
"test:chat-draft-recovery": "node --test test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs && node test/quality/native-chat-presubmit-mv3.mjs",
"test:upload-owner": "node --test test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs",
- "test:shard:quick": "npm run test:cms && npm run test:markdown && npm run test:generative-media && npm run test:systemone && npm run test:systemone:fast && node --test test/guard-policy.mjs test/browser-dialogs.mjs test/capsolver-cloud-broker.mjs test/captcha-providers.mjs test/captcha-weighted-fallback.mjs test/captcha-hcaptcha-providers.mjs test/captcha-native-providers.mjs test/captcha-runtime-policy.mjs test/captcha-callback-bridge.mjs test/captcha-bridge-registration.mjs test/captcha-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs test/feedback-traces.mjs && npm run test:firefox-bidi && npm run test:billing-notice && npm run test:compass-quota && npm run test:provider-limits && npm run test:provider-catalog && npm run test:provider-instances:ui && npm run test:openrouter-capabilities && npm run test:anthropic && npm run test:browser-batch && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:cloud-bridge-approval && npm run test:discord && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && npm run test:workflow-editor && node --test test/profile-sync-stats.mjs && node --test test/memcode-recall.mjs",
+ "test:shard:quick": "npm run test:cms && npm run test:markdown && npm run test:generative-media && npm run test:systemone && npm run test:systemone:fast && node --test test/guard-policy.mjs test/browser-dialogs.mjs test/capsolver-cloud-broker.mjs test/captcha-providers.mjs test/captcha-weighted-fallback.mjs test/captcha-hcaptcha-providers.mjs test/captcha-native-providers.mjs test/captcha-runtime-policy.mjs test/captcha-callback-bridge.mjs test/captcha-bridge-registration.mjs test/captcha-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs test/feedback-traces.mjs && npm run test:firefox-bidi && npm run test:billing-notice && npm run test:compass-quota && npm run test:provider-limits && npm run test:provider-catalog && npm run test:provider-instances:ui && npm run test:settings-pages:ui && npm run test:openrouter-capabilities && npm run test:anthropic && npm run test:browser-batch && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:cloud-bridge-approval && npm run test:discord && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && npm run test:workflow-editor && node --test test/profile-sync-stats.mjs && node --test test/memcode-recall.mjs",
- "test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/auto-mode.mjs test/model-picker-icon.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/lean-mode.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs && npm run test:plan-notifications",
- "test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs",
+ "test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/guard-reading-carry-over.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/auto-mode.mjs test/model-picker-icon.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/lean-mode.mjs test/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs && npm run test:plan-notifications",
+ "test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs test/page-feedback-held-time.mjs test/page-monitor-held-observation.mjs",
"test:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/integration-mv3.mjs --batch && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs",
"test:shard:browser-b2": "node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs --selector-recovery && node test/quality/upload-release-binding-mv3.mjs --sequential-assets && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/shared-action-guards-mv3.mjs && node test/quality/video-upload-attachment-mv3.mjs",
"test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
diff --cc src/chrome/src/providers/d1-config.js
index 788248ae0,e63b7da19..8b6946ccc
--- a/src/chrome/src/providers/d1-config.js
+++ b/src/chrome/src/providers/d1-config.js
@@@ -1,7 -1,7 +1,7 @@@
export const D1_MODEL_ID = 'webbrain-one/d1-browser-decision-fp16';
export const D1_CONSENT_VERSION = 1;
export const D1_CONSENT_KEY = 'd1WebgpuConsentVersion';
- // Set by Settings' Download and load / Load cached model, cleared by Unload,
-// Set by Settings' Download and load (or Load, once cached), cleared by Unload,
++// Set by the Providers page's Download and load (or Load, once cached), cleared by Unload,
// Remove and switching D1 off there. While it is set, a decision that finds
// the model unloaded (a browser restart, a discarded stalled session, a lost
// GPU device) reloads the verified cache in the background; never downloads.
diff --cc src/chrome/src/providers/d1-worker.js
index 24cd127e5,b222d751b..9f5024871
--- a/src/chrome/src/providers/d1-worker.js
+++ b/src/chrome/src/providers/d1-worker.js
@@@ -71,7 -71,13 +71,13 @@@ async function readyMarker()
const currentPackage = marker => marker?.revision === D1_RELEASE.revision && marker?.manifestSha256 === D1_RELEASE.manifestSha256;
async function status() {
- if (transfer || runtime || loading || ['error', 'stopped'].includes(state.status)) return { ...state, ready: !!runtime };
+ if (transfer || runtime || loading || ['error', 'stopped'].includes(state.status)) {
+ // An error or a stop leaves the verified cache in place (a lost GPU device
- // after a good download, say); report it so Settings can retry with Load
++ // after a good download, say); report it so the Providers page can retry with Load
+ // instead of falling back to a full download pass.
+ const cached = !transfer && !runtime && !loading && currentPackage(await readyMarker());
+ return { ...state, ready: !!runtime, cached };
+ }
const marker = await readyMarker();
return marker ? { ...state, status: currentPackage(marker) ? 'cached' : 'idle', ready: false, loaded: false } : { ...state, ready: false };
}
diff --cc src/chrome/src/ui/providers.html
index 8f70f63b0,000000000..24ab9dd81
mode 100644,000000..100644
--- a/src/chrome/src/ui/providers.html
+++ b/src/chrome/src/ui/providers.html
@@@ -1,366 -1,0 +1,365 @@@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>WebBrain Providers</title>
+ <!-- Theme bootstrap β€” runs before the stylesheet so data-theme is set before any
+ paint. External classic script because MV3's default CSP forbids
+ inline scripts (same reason settings-tabs.js is external). -->
+ <script src="theme-bootstrap.js"></script>
+ <link rel="stylesheet" href="settings.css">
+ <link rel="stylesheet" href="download-tracker.css">
+</head>
+<body>
+ <div class="header-row">
+ <div>
+ <h1><img class="brand-mark" src="../../icons/icon128.png" alt="" aria-hidden="true"><a id="settings-title-link" href="#" data-i18n="st.providers_page.title"></a></h1>
+ <p class="subtitle" id="subtitle" data-subtitle-key="st.providers_page.subtitle"></p>
+ </div>
+ <div class="header-actions">
+ <a id="settings-page-link" class="support-link" href="settings.html">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
+ <span data-i18n="sp.btn.settings"></span>
+ </a>
+ <a class="support-link" href="https://webbrain.one/docs" target="_blank" rel="noopener noreferrer">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 2-3 4"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>
+ Support
+ </a>
+ </div>
+ </div>
+
+ <nav class="tabs" role="tablist" data-default-tab="llm" data-storage-key="webbrainProvidersTab" data-tab-aliases='{"providers":"llm","multimodal":"vision"}'>
+ <button class="tab-btn active" type="button" role="tab" data-tab="llm" data-i18n="st.tab.llm"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="vision" data-i18n="st.tab.vision"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="speech" data-i18n="st.tab.speech"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="generative" data-i18n="st.tab.generative"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="decision" data-i18n="st.tab.decision"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="safesocial" data-i18n="st.tab.safesocial"></button>
+ </nav>
+
+ <section class="tab-panel active" data-panel="llm" role="tabpanel">
+ <div id="providers"></div>
+
+ <div class="info-box" data-i18n-html="st.providers.info.html"></div>
+ </section>
+
+ <section class="tab-panel" data-panel="vision" role="tabpanel">
+ <h3 class="mm-section-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
+ <circle cx="12" cy="12" r="3"/>
+ </svg>
+ <span data-i18n="st.vision.heading"></span>
+ </h3>
+ <div class="provider-card" id="vision-card">
+ <div style="font-size:12px;color:var(--text2);margin-bottom:12px;line-height:1.5;" data-i18n="st.vision.desc"></div>
+ <div class="vision-local-option" id="webgpu-vision-option">
+ <div class="vision-local-iris" aria-hidden="true">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6z"/>
+ <circle cx="12" cy="12" r="2.5" fill="currentColor" stroke="none"/>
+ </svg>
+ </div>
+ <div class="vision-local-main">
+ <div class="vision-local-heading">
+ <strong id="webgpu-vision-choice-label" data-i18n="st.vision.local.title"></strong>
+ <span class="vision-local-kicker">IN-BROWSER</span>
+ </div>
+ <div class="vision-local-desc" id="webgpu-vision-choice-desc" data-i18n="st.vision.local.desc"></div>
+ <div class="vision-local-controls">
+ <select id="webgpu-vision-choice" aria-labelledby="webgpu-vision-choice-label" aria-describedby="webgpu-vision-choice-desc webgpu-vision-status">
+ <option value="auto" data-i18n="st.vision.local.choice.auto"></option>
+ <option value="bonsai" data-i18n="st.vision.local.choice.bonsai"></option>
+ <option value="webbrain-vl" data-i18n="st.vision.local.choice.webbrain_vl"></option>
+ <option value="off" data-i18n="st.vision.local.choice.off"></option>
+ </select>
+ <button class="btn-secondary vision-local-action" id="btn-use-webgpu-vision" type="button" hidden data-i18n="st.vision.local.download"></button>
+ </div>
+ <div class="vision-local-status" id="webgpu-vision-status" role="status" aria-live="polite"></div>
+ </div>
+ </div>
+ <div class="vision-endpoint-divider"><span data-i18n="st.vision.endpoint_alternative"></span></div>
+ <fieldset class="vision-endpoint-fields" id="vision-endpoint-fields">
+ <div class="field">
+ <label class="mm-field-label">
+ <span data-i18n="st.provider.field.api_base_url"></span>
+ <span class="mm-detected-provider" id="vision-detected" hidden>
+ <img class="provider-icon" id="vision-detected-icon" alt="" width="16" height="16" decoding="async" draggable="false">
+ <span id="vision-detected-label"></span>
+ </span>
+ </label>
+ <input type="text" id="vision-base-url" placeholder="https://api.openai.com/v1">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.api_key"></label>
+ <input type="password" id="vision-api-key" placeholder="sk-...">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.model"></label>
+ <input type="text" id="vision-model" placeholder="gpt-4o">
+ </div>
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-vision" data-i18n="st.vision.save"></button>
+ </div>
+ </fieldset>
+ <div class="btn-row vision-test-actions">
+ <button class="btn-secondary" id="btn-test-vision" data-i18n="st.vision.test"></button>
+ <button class="btn-secondary" id="btn-clear-vision" data-i18n="st.vision.clear"></button>
+ </div>
+ <div class="test-result" id="test-vision"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="speech" role="tabpanel">
+ <h3 class="mm-section-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/>
+ <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>
+ <line x1="12" y1="19" x2="12" y2="23"/>
+ <line x1="8" y1="23" x2="16" y2="23"/>
+ </svg>
+ <span data-i18n="st.transcription.heading"></span>
+ </h3>
+ <div class="provider-card" id="transcription-card">
+ <div style="font-size:12px;color:var(--text2);margin-bottom:12px;line-height:1.5;" data-i18n="st.transcription.desc"></div>
+ <div class="field">
+ <label class="mm-field-label">
+ <span data-i18n="st.provider.field.api_base_url"></span>
+ <span class="mm-detected-provider" id="transcription-detected" hidden>
+ <img class="provider-icon" id="transcription-detected-icon" alt="" width="16" height="16" decoding="async" draggable="false">
+ <span id="transcription-detected-label"></span>
+ </span>
+ </label>
+ <input type="text" id="transcription-base-url" placeholder="https://api.openai.com/v1">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.api_key"></label>
+ <input type="password" id="transcription-api-key" placeholder="sk-...">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.model"></label>
+ <input type="text" id="transcription-model" placeholder="whisper-1">
+ </div>
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-transcription" data-i18n="st.transcription.save"></button>
+ <button class="btn-secondary" id="btn-test-transcription" data-i18n="st.transcription.test"></button>
+ <button class="btn-secondary" id="btn-clear-transcription" data-i18n="st.transcription.clear"></button>
+ </div>
+ <div class="test-result" id="test-transcription"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="generative" role="tabpanel">
+ <h3 class="mm-section-heading" id="image-gen-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
+ <circle cx="8.5" cy="8.5" r="1.5"/>
+ <polyline points="21 15 16 10 5 21"/>
+ </svg>
+ <span data-i18n="st.imagegen.heading"></span>
+ </h3>
+ <div class="provider-card" id="image-gen-card" aria-labelledby="image-gen-heading">
+ <div style="font-size:12px;color:var(--text2);margin-bottom:12px;line-height:1.5;" data-i18n="st.imagegen.desc"></div>
+ <div class="field">
+ <label for="image-gen-provider" data-i18n="st.imagegen.provider"></label>
+ <select id="image-gen-provider">
+ <option value="fal">fal.ai</option>
+ <option value="openrouter">OpenRouter</option>
+ <option value="comfyrouter">Comfy Router</option>
+ <option value="comfyui" data-i18n="st.imagegen.local_provider">ComfyUI (localhost)</option>
+ </select>
+ </div>
+ <div class="field" id="image-gen-key-field">
+ <label for="image-gen-api-key" data-i18n="st.provider.field.api_key"></label>
+ <input type="password" id="image-gen-api-key" placeholder="FAL_KEY" autocomplete="off">
+ </div>
+ <div class="field" id="image-gen-model-field">
+ <label for="image-gen-model" data-i18n="st.provider.field.model"></label>
+ <input type="text" id="image-gen-model" placeholder="fal-ai/flux/schnell">
+ </div>
+ <div class="field" id="image-gen-url-field" hidden>
+ <label for="image-gen-base-url" data-i18n="st.provider.field.api_base_url"></label>
+ <input type="url" id="image-gen-base-url" placeholder="http://127.0.0.1:8188">
+ </div>
+ <div class="field" id="image-gen-workflow-field" hidden>
+ <label for="image-gen-workflow" data-i18n="st.imagegen.workflow"></label>
+ <textarea id="image-gen-workflow" rows="8" spellcheck="false" placeholder='{"6":{"class_type":"CLIPTextEncode","inputs":{"text":"{{prompt}}"}}}'></textarea>
+ </div>
+ <div class="field" id="image-gen-parameters-field" hidden>
+ <label for="image-gen-parameters" data-i18n="st.imagegen.parameters"></label>
+ <textarea id="image-gen-parameters" rows="4" spellcheck="false" placeholder='{"prompt":"{{prompt}}"}'></textarea>
+ </div>
+ <div style="font-size:12px;color:var(--text2);line-height:1.5;margin-bottom:12px;">
+ <span id="image-gen-provider-hint"></span>
+ <a id="image-gen-docs" href="https://fal.ai/dashboard/keys" target="_blank" rel="noopener noreferrer" data-i18n="st.imagegen.setup"></a>
+ </div>
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-image-gen" data-i18n="st.transcription.save"></button>
+ <button class="btn-secondary" id="btn-test-image-gen" data-i18n="st.transcription.test"></button>
+ <button class="btn-secondary" id="btn-clear-image-gen" data-i18n="st.transcription.clear"></button>
+ </div>
+ <div class="test-result" id="test-image-gen" role="status"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="decision" role="tabpanel">
+ <h3 class="mm-section-heading" id="system-one-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="12" cy="12" r="9"/>
+ <path d="m8 12 3 3 5-6"/>
+ </svg>
+ <span data-i18n="st.system_one.title"></span>
+ </h3>
+ <div class="provider-card" id="system-one-card" aria-labelledby="system-one-heading">
+ <p class="decision-intro" data-i18n="st.decision.intro"></p>
+
+ <fieldset class="decision-mode" id="decision-mode" aria-describedby="decision-mode-desc">
+ <legend class="decision-mode-legend" data-i18n="st.decision.mode.label"></legend>
+ <div class="decision-mode-options">
+ <label class="decision-mode-option"><input type="radio" name="decision-mode" value="auto" checked><span data-i18n="st.decision.mode.auto"></span></label>
+ <label class="decision-mode-option"><input type="radio" name="decision-mode" value="on"><span data-i18n="st.decision.mode.on"></span></label>
+ <label class="decision-mode-option"><input type="radio" name="decision-mode" value="off"><span data-i18n="st.decision.mode.off"></span></label>
+ </div>
+ </fieldset>
+ <p class="decision-mode-desc" id="decision-mode-desc">
+ <span data-decision-mode-desc="auto" data-i18n="st.decision.mode.auto_desc"></span>
+ <span data-decision-mode-desc="on" data-i18n="st.decision.mode.on_desc" hidden></span>
+ <span data-decision-mode-desc="off" data-i18n="st.decision.mode.off_desc" hidden></span>
+ </p>
+ <div class="decision-status" id="decision-auto-status" role="status" aria-live="polite" hidden></div>
+
+ <div class="decision-configured" id="decision-configured" hidden>
+ <div class="field"><label for="decision-provider" data-i18n="st.decision.provider"></label>
+ <select id="decision-provider"><option value="openrouter">OpenRouter</option><option value="typesafe">TypeSafe</option><option value="local" data-i18n="st.decision.local"></option><option value="webgpu_d1" data-i18n="st.d1.provider"></option><option value="webgpu_chat" disabled data-i18n="st.decision.webgpu_chat"></option></select>
+ </div>
+ <p class="setting-desc decision-note" id="webgpu-decision-note" hidden data-i18n="st.decision.mode.off_desc"></p>
+ <div id="d1-controls" hidden>
+ <p class="setting-desc decision-note" data-i18n="st.d1.warning"></p>
+ <label><input type="checkbox" id="d1-consent"> <span data-i18n="st.d1.consent"></span></label>
+ <div class="btn-row" style="margin-top:10px;flex-wrap:wrap">
- <button class="btn-secondary" data-d1-command="download" data-i18n="st.d1.download"></button>
- <button class="btn-secondary" data-d1-command="load" data-i18n="st.d1.load"></button>
++ <button class="btn-secondary" id="d1-load" data-d1-command="download" data-i18n="st.d1.download"></button>
+ <button class="btn-secondary" data-d1-command="stop" data-i18n="st.d1.stop"></button>
+ <button class="btn-secondary" data-d1-command="reset" data-i18n="st.d1.unload"></button>
+ <button class="btn-secondary" data-d1-command="clear" data-i18n="st.d1.remove"></button>
+ </div>
+ <div class="test-result show" id="d1-status" role="status"></div>
+ </div>
+ <div class="field"><label for="decision-model" data-i18n="st.decision.model"></label>
+ <input id="decision-model" list="decision-models" autocomplete="off"><datalist id="decision-models"></datalist>
+ <button class="btn-secondary" id="btn-decision-models" data-i18n="st.decision.refresh"></button>
+ </div>
+ <div class="field" id="decision-endpoint-field"><label for="decision-endpoint" data-i18n="st.decision.endpoint"></label>
+ <input id="decision-endpoint" type="url" placeholder="http://127.0.0.1:8009">
+ </div>
+ <div class="field">
+ <label for="system-one-api-key" data-i18n="st.system_one.api_key.label"></label>
+ <input type="password" id="system-one-api-key" placeholder="API key" autocomplete="off" spellcheck="false">
+ </div>
+ <div class="field"><label for="decision-vision" data-i18n="st.decision.vision"></label>
+ <select id="decision-vision"><option value="auto" data-i18n="st.decision.auto"></option><option value="on" data-i18n="st.decision.on"></option><option value="off" data-i18n="st.decision.off"></option></select>
+ </div>
+ <p class="setting-desc decision-note" data-i18n="st.decision.compass"></p>
+
+ <details class="advanced-settings decision-features" id="decision-features">
+ <summary data-i18n="st.decision.features"></summary>
+ <div class="advanced-settings-body">
+ <p class="setting-desc decision-features-desc" data-i18n="st.decision.features_desc"></p>
+ <div class="setting-row"><div class="setting-info"><div class="setting-label" data-i18n="st.decision.done"></div><div class="setting-desc" data-i18n="st.decision.done_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-decision-done" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="field"><label for="decision-done-threshold" data-i18n="st.decision.threshold"></label>
+ <input id="decision-done-threshold" type="number" min="50" max="99" step="1" value="90">
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.watch.label"></div><div class="setting-desc" data-i18n="st.decision.watch_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-watch" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="field">
+ <label for="range-system-one-watch-threshold"><span data-i18n="st.system_one.watch_threshold"></span> <span id="system-one-watch-threshold-value">70%</span></label>
+ <input type="range" id="range-system-one-watch-threshold" min="50" max="95" step="5" value="70">
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.completion.label"></div><div class="setting-desc" data-i18n="st.decision.completion_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-completion" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="field">
+ <label for="range-system-one-completion-threshold"><span data-i18n="st.system_one.completion_threshold"></span> <span id="system-one-completion-threshold-value">70%</span></label>
+ <input type="range" id="range-system-one-completion-threshold" min="50" max="95" step="5" value="70">
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.fast_classifications"></div><div class="setting-desc" data-i18n="st.decision.classifications_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-classifications" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.fast_browser"></div><div class="setting-desc" data-i18n="st.decision.browser_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-browser" checked><span class="toggle-slider"></span></label>
+ </div>
+ </div>
+ </details>
+ </div>
+
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-system-one" data-i18n="st.providers.save" hidden></button>
+ <button class="btn-secondary" id="btn-test-system-one" data-i18n="st.providers.test"></button>
+ <button class="btn-secondary" id="btn-clear-system-one" data-i18n="st.decision.reset"></button>
+ </div>
+ <div class="test-result" id="test-system-one"></div>
+
+ <div class="info-box" style="margin-top:16px;" data-i18n-html="st.system_one.security_html"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="safesocial" role="tabpanel">
+ <h3 id="safesocial-heading" class="mm-section-heading" data-i18n="st.safesocial.heading"></h3>
+ <div class="provider-card" id="safesocial-card" aria-labelledby="safesocial-heading">
+ <div class="setting-row">
+ <div class="setting-info">
+ <div class="setting-label" id="safesocial-enable-label" data-i18n="st.safesocial.enable"></div>
+ <div class="setting-desc" data-i18n="st.safesocial.desc"></div>
+ </div>
+ <label class="toggle">
+ <input type="checkbox" id="safesocial-enabled" aria-labelledby="safesocial-enable-label">
+ <span class="toggle-slider"></span>
+ </label>
+ </div>
+ <p class="setting-desc" data-i18n="st.safesocial.download"></p>
+ <p class="setting-desc"><a href="https://huggingface.co/webbrain-one/safesocial-trigger-classifier-efficientnet-lite0" target="_blank" rel="noopener noreferrer" data-i18n="st.safesocial.model"></a></p>
+ <div class="field">
+ <label for="safesocial-action" data-i18n="st.safesocial.action"></label>
+ <select id="safesocial-action">
+ <option value="blur" data-i18n="st.safesocial.blur"></option>
+ <option value="hide" data-i18n="st.safesocial.hide"></option>
+ <option value="dim" data-i18n="st.safesocial.dim"></option>
+ <option value="warn" data-i18n="st.safesocial.warn"></option>
+ </select>
+ </div>
+ <div class="field">
+ <label for="safesocial-threshold" data-i18n="st.safesocial.threshold"></label>
+ <div style="display:flex;align-items:center;gap:12px;">
+ <input id="safesocial-threshold" type="range" min="50" max="99" step="1" value="95" style="flex:1;min-width:0;">
+ <output for="safesocial-threshold">95%</output>
+ </div>
+ <div class="setting-desc" data-i18n="st.safesocial.threshold_desc"></div>
+ </div>
+ <fieldset class="safesocial-labels-fieldset">
+ <legend class="setting-label" data-i18n="st.safesocial.categories"></legend>
+ <div id="safesocial-labels"></div>
+ </fieldset>
+ <p class="setting-desc" data-i18n="st.safesocial.scope"></p>
+ <div id="safesocial-status" class="setting-desc" role="status" aria-live="polite"></div>
+ <div class="btn-row" style="margin-top:12px;">
+ <button type="button" class="btn-secondary" id="safesocial-retry" hidden data-i18n="st.safesocial.retry"></button>
+ <button type="button" class="btn-secondary" id="safesocial-remove" data-i18n="st.safesocial.remove"></button>
+ </div>
+ </div>
+ </section>
+
+ <!-- Tab switcher must be an external script β€” Manifest V3's default
+ CSP (`script-src 'self'`) blocks inline <script> execution. -->
+ <script src="settings-tabs.js"></script>
+ <script type="module" src="download-tracker.js"></script>
+ <script src="settings.js" type="module"></script>
+ <script src="safesocial-settings.js" type="module"></script>
+</body>
+</html>
diff --cc src/firefox/src/providers/d1-config.js
index 788248ae0,e63b7da19..8b6946ccc
--- a/src/firefox/src/providers/d1-config.js
+++ b/src/firefox/src/providers/d1-config.js
@@@ -1,7 -1,7 +1,7 @@@
export const D1_MODEL_ID = 'webbrain-one/d1-browser-decision-fp16';
export const D1_CONSENT_VERSION = 1;
export const D1_CONSENT_KEY = 'd1WebgpuConsentVersion';
- // Set by Settings' Download and load / Load cached model, cleared by Unload,
-// Set by Settings' Download and load (or Load, once cached), cleared by Unload,
++// Set by the Providers page's Download and load (or Load, once cached), cleared by Unload,
// Remove and switching D1 off there. While it is set, a decision that finds
// the model unloaded (a browser restart, a discarded stalled session, a lost
// GPU device) reloads the verified cache in the background; never downloads.
diff --cc src/firefox/src/providers/d1-worker.js
index 24cd127e5,b222d751b..9f5024871
--- a/src/firefox/src/providers/d1-worker.js
+++ b/src/firefox/src/providers/d1-worker.js
@@@ -71,7 -71,13 +71,13 @@@ async function readyMarker()
const currentPackage = marker => marker?.revision === D1_RELEASE.revision && marker?.manifestSha256 === D1_RELEASE.manifestSha256;
async function status() {
- if (transfer || runtime || loading || ['error', 'stopped'].includes(state.status)) return { ...state, ready: !!runtime };
+ if (transfer || runtime || loading || ['error', 'stopped'].includes(state.status)) {
+ // An error or a stop leaves the verified cache in place (a lost GPU device
- // after a good download, say); report it so Settings can retry with Load
++ // after a good download, say); report it so the Providers page can retry with Load
+ // instead of falling back to a full download pass.
+ const cached = !transfer && !runtime && !loading && currentPackage(await readyMarker());
+ return { ...state, ready: !!runtime, cached };
+ }
const marker = await readyMarker();
return marker ? { ...state, status: currentPackage(marker) ? 'cached' : 'idle', ready: false, loaded: false } : { ...state, ready: false };
}
diff --cc src/firefox/src/ui/providers.html
index 471a4b49a,000000000..e130765bf
mode 100644,000000..100644
--- a/src/firefox/src/ui/providers.html
+++ b/src/firefox/src/ui/providers.html
@@@ -1,335 -1,0 +1,334 @@@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>WebBrain Providers</title>
+ <!-- Theme bootstrap β€” runs before the stylesheet so data-theme is set before any
+ paint. External classic script because Firefox MV2's CSP forbids
+ inline scripts without an explicit unsafe-inline. -->
+ <script src="theme-bootstrap.js"></script>
+ <link rel="stylesheet" href="settings.css">
+ <link rel="stylesheet" href="download-tracker.css">
+</head>
+<body>
+ <div class="header-row">
+ <div>
+ <h1><img class="brand-mark" src="../../icons/icon128.png" alt="" aria-hidden="true"><a id="settings-title-link" href="#" data-i18n="st.providers_page.title"></a></h1>
+ <p class="subtitle" id="subtitle" data-subtitle-key="st.providers_page.subtitle"></p>
+ </div>
+ <div class="header-actions">
+ <a id="settings-page-link" class="support-link" href="settings.html">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
+ <span data-i18n="sp.btn.settings"></span>
+ </a>
+ <a class="support-link" href="https://webbrain.one/docs" target="_blank" rel="noopener noreferrer">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 2-3 4"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>
+ Support
+ </a>
+ </div>
+ </div>
+
+ <nav class="tabs" role="tablist" data-default-tab="llm" data-storage-key="webbrainProvidersTab" data-tab-aliases='{"providers":"llm","multimodal":"vision"}'>
+ <button class="tab-btn active" type="button" role="tab" data-tab="llm" data-i18n="st.tab.llm"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="vision" data-i18n="st.tab.vision"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="speech" data-i18n="st.tab.speech"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="generative" data-i18n="st.tab.generative"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="decision" data-i18n="st.tab.decision"></button>
+ <button class="tab-btn" type="button" role="tab" data-tab="safesocial" data-i18n="st.tab.safesocial"></button>
+ </nav>
+
+ <section class="tab-panel active" data-panel="llm" role="tabpanel">
+ <div id="providers"></div>
+
+ <div class="info-box" data-i18n-html="st.providers.info.html"></div>
+ </section>
+
+ <section class="tab-panel" data-panel="vision" role="tabpanel">
+ <h3 class="mm-section-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
+ <circle cx="12" cy="12" r="3"/>
+ </svg>
+ <span data-i18n="st.vision.heading"></span>
+ </h3>
+ <div class="provider-card" id="vision-card">
+ <div style="font-size:12px;color:var(--text2);margin-bottom:12px;line-height:1.5;" data-i18n="st.vision.desc"></div>
+ <div class="field">
+ <label class="mm-field-label">
+ <span data-i18n="st.provider.field.api_base_url"></span>
+ <span class="mm-detected-provider" id="vision-detected" hidden>
+ <img class="provider-icon" id="vision-detected-icon" alt="" width="16" height="16" decoding="async" draggable="false">
+ <span id="vision-detected-label"></span>
+ </span>
+ </label>
+ <input type="text" id="vision-base-url" placeholder="https://api.openai.com/v1">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.api_key"></label>
+ <input type="password" id="vision-api-key" placeholder="sk-...">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.model"></label>
+ <input type="text" id="vision-model" placeholder="gpt-4o">
+ </div>
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-vision" data-i18n="st.vision.save"></button>
+ <button class="btn-secondary" id="btn-test-vision" data-i18n="st.vision.test"></button>
+ <button class="btn-secondary" id="btn-clear-vision" data-i18n="st.vision.clear"></button>
+ </div>
+ <div class="test-result" id="test-vision"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="speech" role="tabpanel">
+ <h3 class="mm-section-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/>
+ <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>
+ <line x1="12" y1="19" x2="12" y2="23"/>
+ <line x1="8" y1="23" x2="16" y2="23"/>
+ </svg>
+ <span data-i18n="st.transcription.heading"></span>
+ </h3>
+ <div class="provider-card" id="transcription-card">
+ <div style="font-size:12px;color:var(--text2);margin-bottom:12px;line-height:1.5;" data-i18n="st.transcription.desc"></div>
+ <div class="field">
+ <label class="mm-field-label">
+ <span data-i18n="st.provider.field.api_base_url"></span>
+ <span class="mm-detected-provider" id="transcription-detected" hidden>
+ <img class="provider-icon" id="transcription-detected-icon" alt="" width="16" height="16" decoding="async" draggable="false">
+ <span id="transcription-detected-label"></span>
+ </span>
+ </label>
+ <input type="text" id="transcription-base-url" placeholder="https://api.openai.com/v1">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.api_key"></label>
+ <input type="password" id="transcription-api-key" placeholder="sk-...">
+ </div>
+ <div class="field">
+ <label data-i18n="st.provider.field.model"></label>
+ <input type="text" id="transcription-model" placeholder="whisper-1">
+ </div>
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-transcription" data-i18n="st.transcription.save"></button>
+ <button class="btn-secondary" id="btn-test-transcription" data-i18n="st.transcription.test"></button>
+ <button class="btn-secondary" id="btn-clear-transcription" data-i18n="st.transcription.clear"></button>
+ </div>
+ <div class="test-result" id="test-transcription"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="generative" role="tabpanel">
+ <h3 class="mm-section-heading" id="image-gen-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
+ <circle cx="8.5" cy="8.5" r="1.5"/>
+ <polyline points="21 15 16 10 5 21"/>
+ </svg>
+ <span data-i18n="st.imagegen.heading"></span>
+ </h3>
+ <div class="provider-card" id="image-gen-card" aria-labelledby="image-gen-heading">
+ <div style="font-size:12px;color:var(--text2);margin-bottom:12px;line-height:1.5;" data-i18n="st.imagegen.desc"></div>
+ <div class="field">
+ <label for="image-gen-provider" data-i18n="st.imagegen.provider"></label>
+ <select id="image-gen-provider">
+ <option value="fal">fal.ai</option>
+ <option value="openrouter">OpenRouter</option>
+ <option value="comfyrouter">Comfy Router</option>
+ <option value="comfyui" data-i18n="st.imagegen.local_provider">ComfyUI (localhost)</option>
+ </select>
+ </div>
+ <div class="field" id="image-gen-key-field">
+ <label for="image-gen-api-key" data-i18n="st.provider.field.api_key"></label>
+ <input type="password" id="image-gen-api-key" placeholder="FAL_KEY" autocomplete="off">
+ </div>
+ <div class="field" id="image-gen-model-field">
+ <label for="image-gen-model" data-i18n="st.provider.field.model"></label>
+ <input type="text" id="image-gen-model" placeholder="fal-ai/flux/schnell">
+ </div>
+ <div class="field" id="image-gen-url-field" hidden>
+ <label for="image-gen-base-url" data-i18n="st.provider.field.api_base_url"></label>
+ <input type="url" id="image-gen-base-url" placeholder="http://127.0.0.1:8188">
+ </div>
+ <div class="field" id="image-gen-workflow-field" hidden>
+ <label for="image-gen-workflow" data-i18n="st.imagegen.workflow"></label>
+ <textarea id="image-gen-workflow" rows="8" spellcheck="false" placeholder='{"6":{"class_type":"CLIPTextEncode","inputs":{"text":"{{prompt}}"}}}'></textarea>
+ </div>
+ <div class="field" id="image-gen-parameters-field" hidden>
+ <label for="image-gen-parameters" data-i18n="st.imagegen.parameters"></label>
+ <textarea id="image-gen-parameters" rows="4" spellcheck="false" placeholder='{"prompt":"{{prompt}}"}'></textarea>
+ </div>
+ <div style="font-size:12px;color:var(--text2);line-height:1.5;margin-bottom:12px;">
+ <span id="image-gen-provider-hint"></span>
+ <a id="image-gen-docs" href="https://fal.ai/dashboard/keys" target="_blank" rel="noopener noreferrer" data-i18n="st.imagegen.setup"></a>
+ </div>
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-image-gen" data-i18n="st.transcription.save"></button>
+ <button class="btn-secondary" id="btn-test-image-gen" data-i18n="st.transcription.test"></button>
+ <button class="btn-secondary" id="btn-clear-image-gen" data-i18n="st.transcription.clear"></button>
+ </div>
+ <div class="test-result" id="test-image-gen" role="status"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="decision" role="tabpanel">
+ <h3 class="mm-section-heading" id="system-one-heading">
+ <svg class="mm-section-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="12" cy="12" r="9"/>
+ <path d="m8 12 3 3 5-6"/>
+ </svg>
+ <span data-i18n="st.system_one.title"></span>
+ </h3>
+ <div class="provider-card" id="system-one-card" aria-labelledby="system-one-heading">
+ <p class="decision-intro" data-i18n="st.decision.intro"></p>
+
+ <fieldset class="decision-mode" id="decision-mode" aria-describedby="decision-mode-desc">
+ <legend class="decision-mode-legend" data-i18n="st.decision.mode.label"></legend>
+ <div class="decision-mode-options">
+ <label class="decision-mode-option"><input type="radio" name="decision-mode" value="auto" checked><span data-i18n="st.decision.mode.auto"></span></label>
+ <label class="decision-mode-option"><input type="radio" name="decision-mode" value="on"><span data-i18n="st.decision.mode.on"></span></label>
+ <label class="decision-mode-option"><input type="radio" name="decision-mode" value="off"><span data-i18n="st.decision.mode.off"></span></label>
+ </div>
+ </fieldset>
+ <p class="decision-mode-desc" id="decision-mode-desc">
+ <span data-decision-mode-desc="auto" data-i18n="st.decision.mode.auto_desc_firefox"></span>
+ <span data-decision-mode-desc="on" data-i18n="st.decision.mode.on_desc" hidden></span>
+ <span data-decision-mode-desc="off" data-i18n="st.decision.mode.off_desc" hidden></span>
+ </p>
+ <div class="decision-status" id="decision-auto-status" role="status" aria-live="polite" hidden></div>
+
+ <div class="decision-configured" id="decision-configured" hidden>
+ <div class="field"><label for="decision-provider" data-i18n="st.decision.provider"></label>
+ <select id="decision-provider"><option value="openrouter">OpenRouter</option><option value="typesafe">TypeSafe</option><option value="local" data-i18n="st.decision.local"></option><option value="webgpu_d1" data-i18n="st.d1.provider"></option></select>
+ </div>
+ <div id="d1-controls" hidden>
+ <p class="setting-desc decision-note" data-i18n="st.d1.warning"></p>
+ <label><input type="checkbox" id="d1-consent"> <span data-i18n="st.d1.consent"></span></label>
+ <div class="btn-row" style="margin-top:10px;flex-wrap:wrap">
- <button class="btn-secondary" data-d1-command="download" data-i18n="st.d1.download"></button>
- <button class="btn-secondary" data-d1-command="load" data-i18n="st.d1.load"></button>
++ <button class="btn-secondary" id="d1-load" data-d1-command="download" data-i18n="st.d1.download"></button>
+ <button class="btn-secondary" data-d1-command="stop" data-i18n="st.d1.stop"></button>
+ <button class="btn-secondary" data-d1-command="reset" data-i18n="st.d1.unload"></button>
+ <button class="btn-secondary" data-d1-command="clear" data-i18n="st.d1.remove"></button>
+ </div>
+ <div class="test-result show" id="d1-status" role="status"></div>
+ </div>
+ <div class="field"><label for="decision-model" data-i18n="st.decision.model"></label>
+ <input id="decision-model" list="decision-models" autocomplete="off"><datalist id="decision-models"></datalist>
+ <button class="btn-secondary" id="btn-decision-models" data-i18n="st.decision.refresh"></button>
+ </div>
+ <div class="field" id="decision-endpoint-field"><label for="decision-endpoint" data-i18n="st.decision.endpoint"></label>
+ <input id="decision-endpoint" type="url" placeholder="http://127.0.0.1:8009">
+ </div>
+ <div class="field">
+ <label for="system-one-api-key" data-i18n="st.system_one.api_key.label"></label>
+ <input type="password" id="system-one-api-key" placeholder="API key" autocomplete="off" spellcheck="false">
+ </div>
+ <div class="field"><label for="decision-vision" data-i18n="st.decision.vision"></label>
+ <select id="decision-vision"><option value="auto" data-i18n="st.decision.auto"></option><option value="on" data-i18n="st.decision.on"></option><option value="off" data-i18n="st.decision.off"></option></select>
+ </div>
+ <p class="setting-desc decision-note" data-i18n="st.decision.compass"></p>
+
+ <details class="advanced-settings decision-features" id="decision-features">
+ <summary data-i18n="st.decision.features"></summary>
+ <div class="advanced-settings-body">
+ <p class="setting-desc decision-features-desc" data-i18n="st.decision.features_desc"></p>
+ <div class="setting-row"><div class="setting-info"><div class="setting-label" data-i18n="st.decision.done"></div><div class="setting-desc" data-i18n="st.decision.done_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-decision-done" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="field"><label for="decision-done-threshold" data-i18n="st.decision.threshold"></label>
+ <input id="decision-done-threshold" type="number" min="50" max="99" step="1" value="90">
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.watch.label"></div><div class="setting-desc" data-i18n="st.decision.watch_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-watch" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="field">
+ <label for="range-system-one-watch-threshold"><span data-i18n="st.system_one.watch_threshold"></span> <span id="system-one-watch-threshold-value">70%</span></label>
+ <input type="range" id="range-system-one-watch-threshold" min="50" max="95" step="5" value="70">
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.completion.label"></div><div class="setting-desc" data-i18n="st.decision.completion_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-completion" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="field">
+ <label for="range-system-one-completion-threshold"><span data-i18n="st.system_one.completion_threshold"></span> <span id="system-one-completion-threshold-value">70%</span></label>
+ <input type="range" id="range-system-one-completion-threshold" min="50" max="95" step="5" value="70">
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.fast_classifications"></div><div class="setting-desc" data-i18n="st.decision.classifications_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-classifications" checked><span class="toggle-slider"></span></label>
+ </div>
+ <div class="setting-row">
+ <div class="setting-info"><div class="setting-label" data-i18n="st.system_one.fast_browser"></div><div class="setting-desc" data-i18n="st.decision.browser_desc"></div></div>
+ <label class="toggle"><input type="checkbox" id="toggle-system-one-browser" checked><span class="toggle-slider"></span></label>
+ </div>
+ </div>
+ </details>
+ </div>
+
+ <div class="btn-row">
+ <button class="btn-primary" id="btn-save-system-one" data-i18n="st.providers.save" hidden></button>
+ <button class="btn-secondary" id="btn-test-system-one" data-i18n="st.providers.test"></button>
+ <button class="btn-secondary" id="btn-clear-system-one" data-i18n="st.decision.reset"></button>
+ </div>
+ <div class="test-result" id="test-system-one"></div>
+
+ <div class="info-box" style="margin-top:16px;" data-i18n-html="st.system_one.security_html"></div>
+ </div>
+ </section>
+
+ <section class="tab-panel" data-panel="safesocial" role="tabpanel">
+ <h3 id="safesocial-heading" class="mm-section-heading" data-i18n="st.safesocial.heading"></h3>
+ <div class="provider-card" id="safesocial-card" aria-labelledby="safesocial-heading">
+ <div class="setting-row">
+ <div class="setting-info">
+ <div class="setting-label" id="safesocial-enable-label" data-i18n="st.safesocial.enable"></div>
+ <div class="setting-desc" data-i18n="st.safesocial.desc"></div>
+ </div>
+ <label class="toggle">
+ <input type="checkbox" id="safesocial-enabled" aria-labelledby="safesocial-enable-label">
+ <span class="toggle-slider"></span>
+ </label>
+ </div>
+ <p class="setting-desc" data-i18n="st.safesocial.download"></p>
+ <p class="setting-desc"><a href="https://huggingface.co/webbrain-one/safesocial-trigger-classifier-efficientnet-lite0" target="_blank" rel="noopener noreferrer" data-i18n="st.safesocial.model"></a></p>
+ <div class="field">
+ <label for="safesocial-action" data-i18n="st.safesocial.action"></label>
+ <select id="safesocial-action">
+ <option value="blur" data-i18n="st.safesocial.blur"></option>
+ <option value="hide" data-i18n="st.safesocial.hide"></option>
+ <option value="dim" data-i18n="st.safesocial.dim"></option>
+ <option value="warn" data-i18n="st.safesocial.warn"></option>
+ </select>
+ </div>
+ <div class="field">
+ <label for="safesocial-threshold" data-i18n="st.safesocial.threshold"></label>
+ <div style="display:flex;align-items:center;gap:12px;">
+ <input id="safesocial-threshold" type="range" min="50" max="99" step="1" value="95" style="flex:1;min-width:0;">
+ <output for="safesocial-threshold">95%</output>
+ </div>
+ <div class="setting-desc" data-i18n="st.safesocial.threshold_desc"></div>
+ </div>
+ <fieldset class="safesocial-labels-fieldset">
+ <legend class="setting-label" data-i18n="st.safesocial.categories"></legend>
+ <div id="safesocial-labels"></div>
+ </fieldset>
+ <p class="setting-desc" data-i18n="st.safesocial.scope"></p>
+ <div id="safesocial-status" class="setting-desc" role="status" aria-live="polite"></div>
+ <div class="btn-row" style="margin-top:12px;">
+ <button type="button" class="btn-secondary" id="safesocial-retry" hidden data-i18n="st.safesocial.retry"></button>
+ <button type="button" class="btn-secondary" id="safesocial-remove" data-i18n="st.safesocial.remove"></button>
+ </div>
+ </div>
+ </section>
+
+ <!-- Tab switcher must be an external script β€” Manifest V3's default
+ CSP (`script-src 'self'`) blocks inline <script> execution. -->
+ <script src="settings-tabs.js"></script>
+ <script type="module" src="download-tracker.js"></script>
+ <script src="settings.js" type="module"></script>
+ <script src="safesocial-settings.js" type="module"></script>
+</body>
+</html>
diff --cc test/d1-decision.mjs
index 51cf1e4a2,5a1178b72..57d4b50d4
--- a/test/d1-decision.mjs
+++ b/test/d1-decision.mjs
@@@ -49,7 -49,9 +49,9 @@@ for (const build of ['chrome', 'firefox
await new Promise(resolve => setTimeout(resolve, 0));
const result = messages.find(message => message.id === 2).result;
assert.equal(result.status, 'error'); assert.equal(result.ready, false); assert.equal(result.loaded, false);
- assert.match(result.error, /Hardware WebGPU/); assert.equal(cacheReads, 0);
+ assert.match(result.error, /Hardware WebGPU/);
- // The error stays, but the verified cache is reported so Settings can retry with Load.
++ // The error stays, but the verified cache is reported so the Providers page can retry with Load.
+ assert.equal(result.cached, true); assert.equal(cacheReads, 1);
} finally {
if (oldNavigator) Object.defineProperty(globalThis, 'navigator', oldNavigator); else delete globalThis.navigator;
if (oldSelf) Object.defineProperty(globalThis, 'self', oldSelf); else delete globalThis.self;
diff --cc test/d1-settings-ui.mjs
index 000000000,d6f71fe37..31a0368f2
mode 000000,100644..100644
--- a/test/d1-settings-ui.mjs
+++ b/test/d1-settings-ui.mjs
@@@ -1,0 -1,82 +1,82 @@@
-// Settings β†’ Decision models with D1 selected: one button downloads what is
++// Providers β†’ Decision with D1 selected: one button downloads what is
+ // missing and loads, and reads "Load" once the package is cached; Unload is
+ // short. Firefox runs only where its Playwright browser is installed.
+ import { chromium, firefox } from 'playwright';
+ import { createServer } from 'node:http';
+ import { readFile } from 'node:fs/promises';
+ import { resolve, extname, sep } from 'node:path';
+ import assert from 'node:assert/strict';
+ import { test } from 'node:test';
+
+ const root = resolve('.');
+ const { version } = JSON.parse(await readFile(resolve(root, 'package.json'), 'utf8'));
+ const server = createServer(async (req, res) => {
+ try {
+ const file = resolve(root, '.' + new URL(req.url, 'http://localhost').pathname);
+ if (!file.startsWith(root + sep)) throw Error();
+ res.setHeader('Content-Type', ({ '.js': 'text/javascript', '.mjs': 'text/javascript', '.html': 'text/html', '.css': 'text/css', '.svg': 'image/svg+xml' })[extname(file)] || 'text/plain');
+ res.end(await readFile(file));
+ } catch { res.statusCode = 404; res.end(); }
+ });
+ await new Promise(done => server.listen(0, '127.0.0.1', done));
+ const origin = `http://127.0.0.1:${server.address().port}`;
+
+ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
+ test(`${build}: D1 has one Download and load button that reads Load once cached`, async t => {
+ let browser;
+ try { browser = await engine.launch(); } catch (error) { t.skip(`${build} browser unavailable: ${error.message.split('\n')[0]}`); return; }
+ try {
+ const page = await browser.newPage({ viewport: { width: 1280, height: 1000 } });
+ const errors = []; page.on('pageerror', error => errors.push(error.message));
+ await page.addInitScript(({ build, version }) => {
+ localStorage.setItem('wbLocale', 'en');
+ const data = { wbLocale: 'en', decisionMode: 'on', systemOneEnabled: true, decisionProvider: 'webgpu_d1', d1WebgpuConsentVersion: 1 };
+ window.testRequests = []; window.d1Status = 'idle';
+ const storage = {
+ async get(keys) { return keys == null ? { ...data } : Object.fromEntries((Array.isArray(keys) ? keys : typeof keys === 'string' ? [keys] : Object.keys(keys)).map(k => [k, data[k]])); },
+ async set(values) { Object.assign(data, values); },
+ async remove(keys) { for (const key of Array.isArray(keys) ? keys : [keys]) delete data[key]; },
+ };
+ window.chrome = window.browser = {
+ storage: { local: storage, onChanged: { addListener() {} } },
+ runtime: { getURL: path => `${location.origin}/src/${build}/${path}`, getManifest: () => ({ version }), onMessage: { addListener() {} }, sendMessage(msg, callback) {
+ window.testRequests.push(msg);
+ const result = msg.action === 'd1_control'
+ ? { success: true, result: msg.command === 'status' ? { status: window.d1Status, ready: window.d1Status === 'ready', loaded: window.d1Status === 'ready', cached: window.d1Cached === true } : { started: true } }
+ : msg.action === 'get_providers' ? { providers: {}, active: '' } : { success: true };
+ callback?.(result); return Promise.resolve(result);
+ } },
+ commands: { getAll: async () => [] }, tabs: { create: async () => ({}) },
+ };
+ }, { build, version });
- await page.goto(`${origin}/src/${build}/src/ui/settings.html#multimodal`);
++ await page.goto(`${origin}/src/${build}/src/ui/providers.html#decision`);
+ await page.waitForFunction(() => !document.querySelector('#d1-controls')?.hidden);
+ const commands = await page.locator('#d1-controls button[data-d1-command]').evaluateAll(buttons => buttons.map(button => button.dataset.d1Command));
+ assert.deepEqual(commands, ['download', 'stop', 'reset', 'clear'], 'Download and Load share one button');
+ assert.equal(await page.locator('#d1-controls button[data-d1-command="reset"]').textContent(), 'Unload');
+ const load = page.locator('#d1-load');
+ await page.waitForFunction(() => document.querySelector('#d1-load').textContent === 'Download and load');
+ assert.equal(await load.getAttribute('data-d1-command'), 'download');
+ // Once the package is cached, the same button only loads it.
+ await page.evaluate(() => { window.d1Status = 'cached'; });
+ await page.waitForFunction(() => document.querySelector('#d1-load').textContent === 'Load', null, { timeout: 5000 });
+ assert.equal(await load.getAttribute('data-d1-command'), 'load');
+ // A transient load error keeps the cache: retrying still only loads.
+ await page.evaluate(() => { window.d1Status = 'error'; window.d1Cached = true; });
+ await page.waitForFunction(() => document.querySelector('#d1-status').textContent.startsWith('error'), null, { timeout: 5000 });
+ assert.equal(await load.getAttribute('data-d1-command'), 'load', 'a cached model with an error retries with Load');
+ await page.evaluate(() => { window.d1Cached = false; });
+ await page.waitForFunction(() => document.querySelector('#d1-load').dataset.d1Command === 'download', null, { timeout: 5000 });
+ await page.evaluate(() => { window.d1Status = 'cached'; window.d1Cached = false; });
+ await page.waitForFunction(() => document.querySelector('#d1-load').textContent === 'Load', null, { timeout: 5000 });
+ await page.locator('#d1-consent').check();
+ await load.click();
+ await page.waitForFunction(() => window.testRequests.some(msg => msg.action === 'd1_control' && msg.command === 'load'));
+ const sent = await page.evaluate(() => window.testRequests.find(msg => msg.action === 'd1_control' && msg.command === 'load'));
+ assert.equal(sent.consent, true); assert.equal(sent.consentVersion, 1);
+ assert.deepEqual(errors, []);
+ } finally { await browser.close(); }
+ });
+ }
+
+ test.after(() => server.close());
diff --cc test/systemone-ui.mjs
index 8c4fa22d2,f98631550..df4d125e0
--- a/test/systemone-ui.mjs
+++ b/test/systemone-ui.mjs
@@@ -49,40 -31,12 +49,40 @@@ async function captureDocScreenshots(br
return { x: card.x + scrollX, y: heading.y + scrollY, width: card.width, height: card.bottom - heading.y };
});
await page.screenshot({ animations: 'disabled', caret: 'hide', path: resolve(directory, 'settings-decision-models.jpg'), type: 'jpeg', quality: 85, fullPage: true, clip });
- await page.locator('[data-tab="display"]').click();
- await page.locator('#input-general-search').fill('Strict secret');
- await page.evaluate(() => { document.activeElement?.blur(); scrollTo(0, 0); });
- await page.mouse.move(0, 0);
- await page.screenshot({ animations: 'disabled', caret: 'hide', path: resolve(directory, 'settings-advanced.jpg'), type: 'jpeg', quality: 85 });
- await page.locator('#input-general-search').fill('');
+ await page.close();
+}
+
+// Made-up permission choices for the docs screenshot of the Permissions page.
+const DOC_SEED = {
+ wb_permissions: [
+ { host: 'docs.example.com', capability: 'click', action: 'allow' },
+ { host: 'mail.example.com', capability: 'type', action: 'deny' },
+ ],
+};
+
+function installStub({ lang, build, version, seed = {} }) {
+ localStorage.setItem('wbLocale', lang);
+ const data = { wbLocale: lang, typesafeApiKey: '', systemOneEnabled: false, systemOneWatchEnabled: true, systemOneCompletionEnabled: true,
+ ...seed, ...JSON.parse(sessionStorage.getItem('decision-profile') || '{}') };
+ window.testStore = data; window.testRequests = [];
+ const listeners = [];
+ const storage = {
+ async get(keys) { return keys == null ? { ...data } : Object.fromEntries((Array.isArray(keys) ? keys : typeof keys === 'string' ? [keys] : Object.keys(keys)).map(k => [k, data[k]])); },
+ async set(values) { Object.assign(data, values); listeners.forEach(fn => fn(Object.fromEntries(Object.entries(values).map(([k, v]) => [k, { newValue: v }])), 'local')); },
+ async remove(keys) { for (const key of Array.isArray(keys) ? keys : [keys]) delete data[key]; },
+ };
+ window.chrome = window.browser = {
+ storage: { local: storage, onChanged: { addListener: fn => listeners.push(fn) } },
+ runtime: { getURL: path => `${location.origin}/src/${build}/${path}`, getManifest: () => ({ version }), onMessage: { addListener() {} }, sendMessage(msg, callback) {
+ window.testRequests.push(msg);
+ const result = msg.action === 'get_providers' ? { providers: { llamacpp: { label: 'llama.cpp', category: 'local', baseUrl: 'http://localhost:8080/v1', model: 'local-model', configured: true }, openai: { label: 'OpenAI', category: 'cloud', apiKey: '', model: 'gpt-4o-mini' } }, active: 'llamacpp' }
+ : msg.action === 'test_system_one' ? { success: true, model: msg.settings?.decisionModel || 'jev-1.13.0', visionVerified: msg.settings?.decisionProvider === 'openrouter' }
- : msg.action === 'list_decision_models' ? { success: true, models: [{ id: 'perplexity/pplx-decider-v1.1-27b', name: 'Decider', supportsVision: true, inputRate: .02, outputRate: 0 }, { id: 'another/publisher', name: 'Another decision model', supportsVision: false, inputRate: .1, outputRate: 0 }] }
++ : msg.action === 'list_decision_models' ? { success: true, models: [{ id: 'cloudflare/clef-flash', name: 'Decider', supportsVision: true, inputRate: .02, outputRate: 0 }, { id: 'another/publisher', name: 'Another decision model', supportsVision: false, inputRate: .1, outputRate: 0 }] }
+ : msg.action === 'get_user_memory' ? { ok: true, enabled: true, records: [] } : {};
+ callback?.(result); return Promise.resolve(result);
+ } },
+ commands: { getAll: async () => [] }, tabs: { create: async () => ({}) },
+ };
}
try {
for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {