browser-assistant 2.9.20 → 2.9.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/extension/background.js +15 -1
- package/extension/content.js +150 -0
- package/extension/manifest.json +20 -2
- package/extension/popup.html +6 -6
- package/extension/styles.css +167 -145
- package/package.json +4 -2
- package/server/main.py +44 -9
- package/server/vision_images.py +27 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A Chrome Manifest V3 extension with a local Python backend for exploring multipl
|
|
|
10
10
|
- Displays results in an in-page panel, offers code copying, and saves successful scans in local SQLite history.
|
|
11
11
|
- Includes a local practice page and automation for selecting answers, filling editors, and submitting supported forms after starting a run.
|
|
12
12
|
- Resumes CCBP practice from an already submitted answer through its submitted-question Next control, without generating or submitting that answer again. Delayed Submit controls are awaited for up to 15 seconds while the question and selected answer remain unchanged.
|
|
13
|
-
- Press **Alt + A
|
|
13
|
+
- Press **⌥A** (Alt + A) on the webpage to start automation, then press it again to pause or resume. The previous **⌥⇧A** (Alt + Shift + A) shortcut also works, including with the code editor focused, and opens QA Control. Journal automation uses the same toggle; its **⌥⇧J** shortcut remains available. Panel chords are **⌃⇧O** (open), **⌃⇧X** (close), **⌃⇧S** (vision scan) and **⌃⇧M** (minimal mode).
|
|
14
14
|
|
|
15
15
|
AI answers can be wrong. Automation can change or submit page content: use it only where authorized, review results, and avoid restricted assessments. Site detection is heuristic; custom controls, frames, editors, and navigation can fail. The policy includes a general HTTP/HTTPS fallback, so it is not a strict site allowlist.
|
|
16
16
|
|
|
@@ -91,7 +91,7 @@ For local text inference, install [Ollama](https://github.com/ollama/ollama), ru
|
|
|
91
91
|
4. Open `http://127.0.0.1:8000/practice`, then use the floating panel's Text Scan. Review the answer before trying automation with Start.
|
|
92
92
|
5. For a local source checkout, run `npm run build` after updating the project. When the build version changes, Chrome reloads the unpacked extension once Browser Assistant is idle. A backend started with `server/main.py` also switches to the new version in the same terminal. Start it once with the updated launcher if an older backend is still running. For ZIP and npm installs, reload the extension manually after upgrading.
|
|
93
93
|
|
|
94
|
-
The toolbar popup reports backend status. In-page shortcuts are backtick (open), `]` (close), `\` (vision scan), and `[` (minimal mode).
|
|
94
|
+
The toolbar popup reports backend status. In-page shortcuts are backtick (open), `]` (close), `\` (vision scan), and `[` (minimal mode), plus the Control + Shift chords **⌃⇧O / ⌃⇧X / ⌃⇧S / ⌃⇧M** for the same four actions. The same four actions are also registered as browser-level Chrome commands, so they keep working on pages that swallow key events or when focus is inside an iframe; reassign them at `chrome://extensions/shortcuts`.
|
|
95
95
|
|
|
96
96
|
## Data and permissions
|
|
97
97
|
|
|
@@ -103,6 +103,10 @@ Text scans send extracted text and the current URL to the backend. Groq receives
|
|
|
103
103
|
|
|
104
104
|
Successful scans are saved by the extension through `/history`: URL, timestamp, scan type, provider, language, and answer JSON are kept in `server/scan_history.db`, capped at 100 entries. Clear History deletes rows, not a forensic secure erase. Stop the backend and remove the database and its `-wal`/`-shm` companions for file-level removal; backups may still contain data. Panel position uses the page's localStorage, and automation resume state uses its sessionStorage. Clear site data to remove those settings. Minimal/stealth controls change presentation; they do not guarantee invisibility or privacy.
|
|
105
105
|
|
|
106
|
+
## Interface design
|
|
107
|
+
|
|
108
|
+
The extension UI is transparent and monochrome. The floating panel, its cards, buttons, inputs, journal card, popup and separate window use no background fills, gradients, blur, shadows or coloured accents; the page stays visible through them, and structure comes from typography, spacing and 1px neutral rules. Theme tokens live at the top of `extension/styles.css` (`--ink`, `--muted`, `--line`, `--line-strong`). Each in-page surface reads the page behind it and switches between dark ink on light backgrounds and light ink on dark backgrounds (`data-tone`); the popup and separate window stay dark-on-white. Correct answers are green in both tones (`--correct`). Surfaces placed over photos or painted `background-image` areas cannot be sampled, so they keep the light-page default.
|
|
109
|
+
|
|
106
110
|
## Development and Docker
|
|
107
111
|
|
|
108
112
|
From the repository root:
|
package/extension/background.js
CHANGED
|
@@ -125,7 +125,7 @@ async function updateJournalBadge() {
|
|
|
125
125
|
const text = active ? (remaining < 60000 ? '<1m' : minutes > 999 ? '999+' : `${minutes}m`) : '';
|
|
126
126
|
await Promise.all([
|
|
127
127
|
chrome.action.setBadgeText({ text }),
|
|
128
|
-
chrome.action.setBadgeBackgroundColor({ color: '#
|
|
128
|
+
chrome.action.setBadgeBackgroundColor({ color: '#111315' }),
|
|
129
129
|
chrome.action.setTitle({ title: active ? `Browser Assistant · ${timers.length > 1 ? 'Next journal' : 'Journal'}: about ${minutes} min left` : 'Browser Assistant' }),
|
|
130
130
|
]);
|
|
131
131
|
}
|
|
@@ -137,6 +137,20 @@ chrome.storage?.local.onChanged?.addListener(changes => {
|
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
void updateJournalBadge();
|
|
140
|
+
// Browser-level shortcuts from manifest.commands. They still work when a site
|
|
141
|
+
// swallows keydown events or focus sits in a subframe.
|
|
142
|
+
chrome.commands?.onCommand.addListener(async (command) => {
|
|
143
|
+
const match = /^panel-(open|close|vision|minimal)$/.exec(command);
|
|
144
|
+
if (!match)
|
|
145
|
+
return;
|
|
146
|
+
const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
|
|
147
|
+
if (!tab?.id)
|
|
148
|
+
return;
|
|
149
|
+
try {
|
|
150
|
+
await chrome.tabs.sendMessage(tab.id, { action: `panel:${match[1]}` }, { frameId: 0 });
|
|
151
|
+
}
|
|
152
|
+
catch { /* Not a page the assistant can run on. */ }
|
|
153
|
+
});
|
|
140
154
|
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|
141
155
|
if (!request || typeof request.action !== 'string') {
|
|
142
156
|
sendResponse({ error: 'Invalid extension message' });
|
package/extension/content.js
CHANGED
|
@@ -173,6 +173,7 @@ function mountJournalCountdown(signal) {
|
|
|
173
173
|
// stationary badge press must open here rather than lose its click.
|
|
174
174
|
if (event.type === 'pointerup' && !dragState.moved && dragState.collapsedBadge)
|
|
175
175
|
openPanel();
|
|
176
|
+
scheduleSurfaceTones();
|
|
176
177
|
};
|
|
177
178
|
root.addEventListener('pointerup', stopDragging);
|
|
178
179
|
root.addEventListener('pointercancel', stopDragging);
|
|
@@ -191,6 +192,73 @@ function mountJournalCountdown(signal) {
|
|
|
191
192
|
}
|
|
192
193
|
initDrag();
|
|
193
194
|
restorePanelPosition();
|
|
195
|
+
// ── Backdrop tone ────────────────────────────────────────────────────────
|
|
196
|
+
// Surfaces are transparent, so the ink follows whatever sits behind them:
|
|
197
|
+
// dark text on light pages, light text on dark pages.
|
|
198
|
+
function parseLuminance(color) {
|
|
199
|
+
const match = /rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)/.exec(color);
|
|
200
|
+
if (!match)
|
|
201
|
+
return null;
|
|
202
|
+
let alpha = match[4] === undefined ? 1 : parseFloat(match[4]);
|
|
203
|
+
if (match[4]?.endsWith('%'))
|
|
204
|
+
alpha /= 100;
|
|
205
|
+
if (alpha < 0.4)
|
|
206
|
+
return null;
|
|
207
|
+
const channel = (value) => {
|
|
208
|
+
const v = Number(value) / 255;
|
|
209
|
+
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
210
|
+
};
|
|
211
|
+
return 0.2126 * channel(match[1]) + 0.7152 * channel(match[2]) + 0.0722 * channel(match[3]);
|
|
212
|
+
}
|
|
213
|
+
function backdropLuminance(x, y) {
|
|
214
|
+
const stack = document.elementsFromPoint(x, y).filter(element => !element.closest?.('#assistant-root, #assistant-journal, #assistant-journal-countdown-badge, #assistant-automation-notice'));
|
|
215
|
+
for (const element of stack) {
|
|
216
|
+
let node = element;
|
|
217
|
+
while (node) {
|
|
218
|
+
const style = getComputedStyle(node);
|
|
219
|
+
const luminance = parseLuminance(style.backgroundColor);
|
|
220
|
+
if (luminance !== null)
|
|
221
|
+
return luminance;
|
|
222
|
+
// Photographic or painted backgrounds cannot be sampled safely.
|
|
223
|
+
if (style.backgroundImage && style.backgroundImage !== 'none')
|
|
224
|
+
return null;
|
|
225
|
+
if (node === document.body || node === document.documentElement)
|
|
226
|
+
break;
|
|
227
|
+
node = node.parentElement;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
function applySurfaceTone(element) {
|
|
233
|
+
const rect = element.getBoundingClientRect();
|
|
234
|
+
if (rect.width < 24 || rect.height < 24)
|
|
235
|
+
return;
|
|
236
|
+
const samples = [];
|
|
237
|
+
for (const fx of [0.25, 0.5, 0.75]) {
|
|
238
|
+
for (const fy of [0.25, 0.5, 0.75]) {
|
|
239
|
+
const luminance = backdropLuminance(rect.left + rect.width * fx, rect.top + rect.height * fy);
|
|
240
|
+
if (luminance !== null)
|
|
241
|
+
samples.push(luminance);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// Without a readable backdrop assume a light page, the common case here.
|
|
245
|
+
const luminance = samples.length ? samples.reduce((sum, value) => sum + value, 0) / samples.length : 1;
|
|
246
|
+
element.dataset.tone = luminance < 0.18 ? 'dark' : 'light';
|
|
247
|
+
}
|
|
248
|
+
let toneTimer;
|
|
249
|
+
function scheduleSurfaceTones() {
|
|
250
|
+
if (toneTimer !== undefined)
|
|
251
|
+
return;
|
|
252
|
+
// Coalesce scroll bursts, then measure once the page settles.
|
|
253
|
+
toneTimer = window.setTimeout(() => {
|
|
254
|
+
toneTimer = undefined;
|
|
255
|
+
document.querySelectorAll('#assistant-root, #assistant-journal, #assistant-journal-countdown-badge')
|
|
256
|
+
.forEach(applySurfaceTone);
|
|
257
|
+
}, 120);
|
|
258
|
+
}
|
|
259
|
+
window.addEventListener('scroll', scheduleSurfaceTones, { capture: true, passive: true, signal: lifecycle.signal });
|
|
260
|
+
window.addEventListener('resize', scheduleSurfaceTones, { signal: lifecycle.signal });
|
|
261
|
+
scheduleSurfaceTones();
|
|
194
262
|
const panelResizeObserver = new ResizeObserver(() => {
|
|
195
263
|
if (!root.style.left || !root.offsetWidth || dragState.dragging)
|
|
196
264
|
return;
|
|
@@ -2555,6 +2623,72 @@ function mountJournalCountdown(signal) {
|
|
|
2555
2623
|
toggleDirectAutomation();
|
|
2556
2624
|
return true;
|
|
2557
2625
|
}
|
|
2626
|
+
// ⌃⇧ chords: Control + Shift. Control never rewrites the typed character,
|
|
2627
|
+
// so the physical key code arrives intact on every macOS keyboard layout.
|
|
2628
|
+
function isControlShiftChord(e, letter) {
|
|
2629
|
+
return !e.repeat && !e.isComposing && !e.defaultPrevented
|
|
2630
|
+
&& e.ctrlKey && e.shiftKey && !e.altKey && !e.metaKey
|
|
2631
|
+
&& (e.code === `Key${letter}` || String(e.key).toUpperCase() === letter);
|
|
2632
|
+
}
|
|
2633
|
+
const panelActions = ['open', 'close', 'vision', 'minimal'];
|
|
2634
|
+
let lastPanelGesture = { action: '', source: '', at: -Infinity };
|
|
2635
|
+
/** Shared by the page chords, the popup buttons and the browser commands. */
|
|
2636
|
+
function panelCommand(action, source = 'keyboard') {
|
|
2637
|
+
if (!panelActions.includes(action))
|
|
2638
|
+
return false;
|
|
2639
|
+
// A registered Chrome command can arrive alongside the same keydown that
|
|
2640
|
+
// triggered it. Run the gesture once, but never swallow a repeat from the
|
|
2641
|
+
// same source, so pressing the key twice still toggles twice.
|
|
2642
|
+
const now = performance.now();
|
|
2643
|
+
if (action === lastPanelGesture.action && source !== lastPanelGesture.source
|
|
2644
|
+
&& now - lastPanelGesture.at < 300) {
|
|
2645
|
+
// Consume the echo so an intentional repeat from the same source
|
|
2646
|
+
// still runs the action.
|
|
2647
|
+
lastPanelGesture = { action, source, at: now };
|
|
2648
|
+
return true;
|
|
2649
|
+
}
|
|
2650
|
+
lastPanelGesture = { action, source, at: now };
|
|
2651
|
+
if (action === 'open')
|
|
2652
|
+
openPanel();
|
|
2653
|
+
else if (action === 'close')
|
|
2654
|
+
closePanel();
|
|
2655
|
+
else if (action === 'vision') {
|
|
2656
|
+
openPanel();
|
|
2657
|
+
void visionScan();
|
|
2658
|
+
}
|
|
2659
|
+
else {
|
|
2660
|
+
isMinimalMode = !isMinimalMode;
|
|
2661
|
+
render();
|
|
2662
|
+
}
|
|
2663
|
+
return true;
|
|
2664
|
+
}
|
|
2665
|
+
/** ⌃⇧O open · ⌃⇧X close · ⌃⇧S vision scan · ⌃⇧M minimal mode. */
|
|
2666
|
+
function handlePanelShortcut(e) {
|
|
2667
|
+
if (panelToken)
|
|
2668
|
+
return false; // the detached panel window owns its shortcuts
|
|
2669
|
+
// Resolve the chord once: preventDefault() below would make a second
|
|
2670
|
+
// match fail, because the matcher ignores already-prevented events.
|
|
2671
|
+
const letter = ['O', 'X', 'S', 'M'].find(key => isControlShiftChord(e, key));
|
|
2672
|
+
if (!letter)
|
|
2673
|
+
return false;
|
|
2674
|
+
e.preventDefault();
|
|
2675
|
+
e.stopPropagation();
|
|
2676
|
+
return panelCommand({ O: 'open', X: 'close', S: 'vision', M: 'minimal' }[letter], 'keyboard');
|
|
2677
|
+
}
|
|
2678
|
+
// Browser commands (chrome://extensions/shortcuts) and the popup buttons
|
|
2679
|
+
// reach the page even when a site swallows keydown events or focus is in an
|
|
2680
|
+
// iframe. Only this extension can send them.
|
|
2681
|
+
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|
2682
|
+
const action = typeof request?.action === 'string' ? request.action : '';
|
|
2683
|
+
if (!action.startsWith('panel:'))
|
|
2684
|
+
return false;
|
|
2685
|
+
if (sender.id !== chrome.runtime.id || panelToken)
|
|
2686
|
+
return false;
|
|
2687
|
+
if (!panelCommand(action.slice(6), 'command'))
|
|
2688
|
+
return false;
|
|
2689
|
+
sendResponse({ ok: true });
|
|
2690
|
+
return false;
|
|
2691
|
+
});
|
|
2558
2692
|
// ── Keyboard shortcuts ────────────────────────────────────────────────────
|
|
2559
2693
|
document.addEventListener('keydown', (e) => {
|
|
2560
2694
|
// Block held-key auto-repeat to prevent rapid-fire race conditions
|
|
@@ -2574,8 +2708,13 @@ function mountJournalCountdown(signal) {
|
|
|
2574
2708
|
|| e.composedPath().some(node => node instanceof Element && node.matches(editorSelector));
|
|
2575
2709
|
if (handleAutomationShortcut(e, shortcutTyping))
|
|
2576
2710
|
return;
|
|
2711
|
+
if (handlePanelShortcut(e))
|
|
2712
|
+
return;
|
|
2577
2713
|
if (isTyping)
|
|
2578
2714
|
return;
|
|
2715
|
+
// Bare keys are unmodified only: ⌘[ / ⌘] must keep navigating history.
|
|
2716
|
+
if (e.altKey || e.ctrlKey || e.metaKey)
|
|
2717
|
+
return;
|
|
2579
2718
|
switch (e.key) {
|
|
2580
2719
|
// ── ` = OPEN panel ──
|
|
2581
2720
|
case '`':
|
|
@@ -2651,6 +2790,7 @@ function mountJournalCountdown(signal) {
|
|
|
2651
2790
|
practice_type: context.question ? 'mcq' : practiceType,
|
|
2652
2791
|
language: context.question ? undefined : requestedLanguage,
|
|
2653
2792
|
verify_answer: true,
|
|
2793
|
+
allow_overview: !context.question && practiceType === 'auto' && !requestedLanguage,
|
|
2654
2794
|
});
|
|
2655
2795
|
if (!res.ok) {
|
|
2656
2796
|
const err = res.data || {};
|
|
@@ -3103,6 +3243,7 @@ function mountJournalCountdown(signal) {
|
|
|
3103
3243
|
if (disposed)
|
|
3104
3244
|
return;
|
|
3105
3245
|
window.BrowserAssistantJournal?.detach();
|
|
3246
|
+
scheduleSurfaceTones();
|
|
3106
3247
|
if (isCollapsed) {
|
|
3107
3248
|
const content = lastResultSummary || "";
|
|
3108
3249
|
// Escape for safe attribute injection (B7)
|
|
@@ -3263,6 +3404,15 @@ function mountJournalCountdown(signal) {
|
|
|
3263
3404
|
container.appendChild(codeBox);
|
|
3264
3405
|
document.getElementById(`copy-btn-${index}`).onclick = () => copyToClipboard(codeContent, `copy-btn-${index}`);
|
|
3265
3406
|
}
|
|
3407
|
+
else if (res.type === 'overview') {
|
|
3408
|
+
const item = document.createElement('div');
|
|
3409
|
+
item.className = 'assistant-answer';
|
|
3410
|
+
item.innerHTML = `
|
|
3411
|
+
<div class="assistant-question-text">${escapeHtml(res.title || 'Visible instructions')}</div>
|
|
3412
|
+
<div class="assistant-reasoning-text">${escapeHtml(res.summary)}</div>
|
|
3413
|
+
`;
|
|
3414
|
+
container.appendChild(item);
|
|
3415
|
+
}
|
|
3266
3416
|
else {
|
|
3267
3417
|
const item = document.createElement('div');
|
|
3268
3418
|
item.className = 'assistant-answer';
|
package/extension/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Browser Assistant",
|
|
4
|
-
"version": "2.9.
|
|
4
|
+
"version": "2.9.22",
|
|
5
5
|
"description": "Scans webpages for MCQs and coding problems. Powered by Groq (cloud) and Ollama (local fallback).",
|
|
6
6
|
"permissions": [
|
|
7
7
|
"activeTab",
|
|
@@ -41,5 +41,23 @@
|
|
|
41
41
|
"http://localhost:8000/*",
|
|
42
42
|
"http://127.0.0.1:8000/*",
|
|
43
43
|
"<all_urls>"
|
|
44
|
-
]
|
|
44
|
+
],
|
|
45
|
+
"commands": {
|
|
46
|
+
"panel-open": {
|
|
47
|
+
"suggested_key": {"default": "Ctrl+Shift+O", "mac": "MacCtrl+Shift+O"},
|
|
48
|
+
"description": "Open the Browser Assistant panel (Control+Shift+O)"
|
|
49
|
+
},
|
|
50
|
+
"panel-close": {
|
|
51
|
+
"suggested_key": {"default": "Ctrl+Shift+X", "mac": "MacCtrl+Shift+X"},
|
|
52
|
+
"description": "Close the Browser Assistant panel (Control+Shift+X)"
|
|
53
|
+
},
|
|
54
|
+
"panel-vision": {
|
|
55
|
+
"suggested_key": {"default": "Ctrl+Shift+S", "mac": "MacCtrl+Shift+S"},
|
|
56
|
+
"description": "Run a Vision scan (Control+Shift+S)"
|
|
57
|
+
},
|
|
58
|
+
"panel-minimal": {
|
|
59
|
+
"suggested_key": {"default": "Ctrl+Shift+M", "mac": "MacCtrl+Shift+M"},
|
|
60
|
+
"description": "Toggle minimal mode (Control+Shift+M)"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
45
63
|
}
|
package/extension/popup.html
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
</section>
|
|
21
21
|
<section class="popup-card" aria-labelledby="popup-shortcuts">
|
|
22
22
|
<h2 id="popup-shortcuts">Keyboard shortcuts</h2>
|
|
23
|
-
<div class="shortcut-row"><span>Open panel</span> <kbd>`</kbd></div>
|
|
24
|
-
<div class="shortcut-row"><span>Close panel</span> <kbd>]</kbd></div>
|
|
25
|
-
<div class="shortcut-row"><span>Vision scan</span> <kbd>\</kbd></div>
|
|
26
|
-
<div class="shortcut-row"><span>Minimal mode</span> <kbd>[</kbd></div>
|
|
27
|
-
<div class="shortcut-row"><span>Fill and submit journal</span> <kbd
|
|
28
|
-
<div class="shortcut-row"><span>Start, pause or resume</span> <kbd
|
|
23
|
+
<div class="shortcut-row"><span>Open panel</span> <span><kbd>`</kbd> <kbd>⌃⇧O</kbd></span></div>
|
|
24
|
+
<div class="shortcut-row"><span>Close panel</span> <span><kbd>]</kbd> <kbd>⌃⇧X</kbd></span></div>
|
|
25
|
+
<div class="shortcut-row"><span>Vision scan</span> <span><kbd>\</kbd> <kbd>⌃⇧S</kbd></span></div>
|
|
26
|
+
<div class="shortcut-row"><span>Minimal mode</span> <span><kbd>[</kbd> <kbd>⌃⇧M</kbd></span></div>
|
|
27
|
+
<div class="shortcut-row"><span>Fill and submit journal</span> <kbd>⌥⇧J</kbd></div>
|
|
28
|
+
<div class="shortcut-row"><span>Start, pause or resume</span> <kbd>⌥A</kbd></div>
|
|
29
29
|
</section>
|
|
30
30
|
</main>
|
|
31
31
|
<script src="popup.js"></script>
|
package/extension/styles.css
CHANGED
|
@@ -1,30 +1,50 @@
|
|
|
1
|
-
/* Browser Assistant
|
|
1
|
+
/* Browser Assistant — transparent monochrome UI.
|
|
2
|
+
No fills, no blur, no gradients, no shadows. Structure comes from type,
|
|
3
|
+
spacing and 1px neutral rules, so the page stays visible through the panel. */
|
|
2
4
|
#assistant-root,
|
|
3
5
|
#assistant-journal,
|
|
4
6
|
#assistant-journal-countdown-badge,
|
|
7
|
+
#assistant-automation-notice,
|
|
8
|
+
body.detached-panel,
|
|
5
9
|
.assistant-popup {
|
|
6
|
-
--ink: #
|
|
7
|
-
--muted: #
|
|
8
|
-
--
|
|
9
|
-
--
|
|
10
|
-
|
|
11
|
-
--
|
|
12
|
-
--
|
|
13
|
-
--
|
|
14
|
-
--
|
|
15
|
-
--
|
|
16
|
-
--
|
|
17
|
-
--
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
--
|
|
21
|
-
--primary
|
|
22
|
-
--primary-
|
|
23
|
-
--
|
|
24
|
-
--
|
|
10
|
+
--ink: #111315;
|
|
11
|
+
--muted: #5b6167;
|
|
12
|
+
--line: rgb(17 19 21 / 20%);
|
|
13
|
+
--line-strong: rgb(17 19 21 / 45%);
|
|
14
|
+
/* Legacy accent names, intentionally monochrome so no rule can tint. */
|
|
15
|
+
--blue: var(--ink);
|
|
16
|
+
--mint: var(--ink);
|
|
17
|
+
--danger: var(--ink);
|
|
18
|
+
--amber: var(--muted);
|
|
19
|
+
--edge: var(--line);
|
|
20
|
+
--control-edge: var(--line-strong);
|
|
21
|
+
--surface: transparent;
|
|
22
|
+
--card: transparent;
|
|
23
|
+
--well: transparent;
|
|
24
|
+
--shell: transparent;
|
|
25
|
+
--primary: transparent;
|
|
26
|
+
--primary-hover: transparent;
|
|
27
|
+
--primary-ink: var(--ink);
|
|
28
|
+
--correct: #15803d;
|
|
29
|
+
--shadow: none;
|
|
30
|
+
--card-shadow: none;
|
|
25
31
|
--ui-font: Inter, system-ui, -apple-system, sans-serif;
|
|
26
32
|
}
|
|
27
33
|
|
|
34
|
+
/* The surfaces are transparent, so the ink follows the page behind them.
|
|
35
|
+
content.ts sets data-tone on every in-page surface after measuring it. */
|
|
36
|
+
#assistant-root[data-tone="dark"],
|
|
37
|
+
#assistant-journal[data-tone="dark"],
|
|
38
|
+
#assistant-journal-countdown-badge[data-tone="dark"],
|
|
39
|
+
#assistant-automation-notice[data-tone="dark"] {
|
|
40
|
+
--ink: #f4f6f8;
|
|
41
|
+
--muted: #b8c0c7;
|
|
42
|
+
--line: rgb(255 255 255 / 26%);
|
|
43
|
+
--line-strong: rgb(255 255 255 / 55%);
|
|
44
|
+
--correct: #5ee08f;
|
|
45
|
+
color-scheme: dark;
|
|
46
|
+
}
|
|
47
|
+
|
|
28
48
|
#assistant-root,
|
|
29
49
|
#assistant-journal-countdown-badge {
|
|
30
50
|
display: block;
|
|
@@ -57,12 +77,9 @@
|
|
|
57
77
|
#assistant-journal,
|
|
58
78
|
#assistant-journal-countdown-badge,
|
|
59
79
|
.assistant-popup .popup-shell {
|
|
60
|
-
background:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
border: 1px solid var(--edge);
|
|
64
|
-
box-shadow: var(--shadow);
|
|
65
|
-
color-scheme: dark;
|
|
80
|
+
background: transparent;
|
|
81
|
+
border: 1px solid var(--line-strong);
|
|
82
|
+
color-scheme: light;
|
|
66
83
|
}
|
|
67
84
|
#assistant-root .assistant-tab {
|
|
68
85
|
box-sizing: border-box;
|
|
@@ -92,12 +109,13 @@
|
|
|
92
109
|
cursor: grab;
|
|
93
110
|
overflow: visible;
|
|
94
111
|
font: 750 16px/1 var(--ui-font);
|
|
95
|
-
border-color: var(--
|
|
112
|
+
border-color: var(--line-strong);
|
|
96
113
|
}
|
|
97
|
-
#assistant-root .assistant-tab.collapsed:hover { border-color: var(--
|
|
114
|
+
#assistant-root .assistant-tab.collapsed:hover { border-color: var(--ink); }
|
|
98
115
|
#assistant-root .assistant-tab.collapsed.has-answer {
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
border-color: var(--ink);
|
|
117
|
+
font-weight: 800;
|
|
118
|
+
letter-spacing: -.02em;
|
|
101
119
|
}
|
|
102
120
|
#assistant-root .assistant-tab.collapsed.has-answer::before { content: attr(data-content); }
|
|
103
121
|
#assistant-root .assistant-mark {
|
|
@@ -106,10 +124,10 @@
|
|
|
106
124
|
width: 29px;
|
|
107
125
|
height: 29px;
|
|
108
126
|
flex: 0 0 auto;
|
|
109
|
-
border: 1px solid var(--
|
|
127
|
+
border: 1px solid var(--line-strong);
|
|
110
128
|
border-radius: 9px;
|
|
111
|
-
background:
|
|
112
|
-
color: var(--
|
|
129
|
+
background: transparent;
|
|
130
|
+
color: var(--ink);
|
|
113
131
|
font: 750 12px/1 var(--ui-font);
|
|
114
132
|
letter-spacing: -.04em;
|
|
115
133
|
}
|
|
@@ -117,10 +135,11 @@
|
|
|
117
135
|
#assistant-root .assistant-mode-indicator {
|
|
118
136
|
position: absolute;
|
|
119
137
|
inset: auto -4px -3px auto;
|
|
138
|
+
border: 1px solid var(--line-strong);
|
|
120
139
|
border-radius: 6px;
|
|
121
140
|
padding: 2px 4px;
|
|
122
|
-
background:
|
|
123
|
-
color: var(--
|
|
141
|
+
background: transparent;
|
|
142
|
+
color: var(--ink);
|
|
124
143
|
font-size: 9px;
|
|
125
144
|
}
|
|
126
145
|
|
|
@@ -141,7 +160,7 @@
|
|
|
141
160
|
#assistant-root .assistant-title {
|
|
142
161
|
margin: 0;
|
|
143
162
|
color: var(--ink);
|
|
144
|
-
font:
|
|
163
|
+
font: 750 15px/1.2 var(--ui-font);
|
|
145
164
|
letter-spacing: -.02em;
|
|
146
165
|
}
|
|
147
166
|
#assistant-root .assistant-build {
|
|
@@ -153,12 +172,13 @@
|
|
|
153
172
|
#assistant-root .assistant-title-row .status-dot {
|
|
154
173
|
width: 8px;
|
|
155
174
|
height: 8px;
|
|
175
|
+
box-sizing: border-box;
|
|
156
176
|
border-radius: 50%;
|
|
157
177
|
flex: 0 0 auto;
|
|
158
178
|
}
|
|
159
|
-
#assistant-root .status-dot.online { background: var(--
|
|
160
|
-
#assistant-root .status-dot.offline { background: var(--
|
|
161
|
-
#assistant-root .status-dot.unknown { background: var(--
|
|
179
|
+
#assistant-root .status-dot.online { background: var(--ink); }
|
|
180
|
+
#assistant-root .status-dot.offline { background: transparent; border: 1px solid var(--ink); }
|
|
181
|
+
#assistant-root .status-dot.unknown { background: transparent; border: 1px dotted var(--muted); }
|
|
162
182
|
|
|
163
183
|
#assistant-root :is(.assistant-content, .assistant-scan-panel) {
|
|
164
184
|
display: flex;
|
|
@@ -170,12 +190,9 @@
|
|
|
170
190
|
|
|
171
191
|
#assistant-root :is(.assistant-mode-switcher, .assistant-qa-panel),
|
|
172
192
|
.assistant-popup .popup-card {
|
|
173
|
-
background:
|
|
174
|
-
|
|
175
|
-
backdrop-filter: blur(18px);
|
|
176
|
-
border: 1px solid var(--edge);
|
|
193
|
+
background: transparent;
|
|
194
|
+
border: 1px solid var(--line);
|
|
177
195
|
border-radius: 13px;
|
|
178
|
-
box-shadow: var(--card-shadow);
|
|
179
196
|
}
|
|
180
197
|
#assistant-root .assistant-mode-switcher {
|
|
181
198
|
display: grid;
|
|
@@ -196,15 +213,16 @@
|
|
|
196
213
|
cursor: pointer;
|
|
197
214
|
}
|
|
198
215
|
#assistant-root .mode-btn:hover:not(.active) {
|
|
199
|
-
background:
|
|
200
|
-
border-color: var(--
|
|
216
|
+
background: transparent;
|
|
217
|
+
border-color: var(--line);
|
|
201
218
|
color: var(--ink);
|
|
202
219
|
}
|
|
203
220
|
#assistant-root .mode-btn.active {
|
|
204
|
-
background:
|
|
205
|
-
color: var(--
|
|
221
|
+
background: transparent;
|
|
222
|
+
border-color: var(--ink);
|
|
223
|
+
color: var(--ink);
|
|
224
|
+
font-weight: 800;
|
|
206
225
|
}
|
|
207
|
-
#assistant-root .mode-btn.qa-tab.active { background: #a5f6da; }
|
|
208
226
|
|
|
209
227
|
#assistant-root .assistant-btn-row,
|
|
210
228
|
#assistant-root .assistant-automation-actions { display: flex; gap: 8px; }
|
|
@@ -215,7 +233,7 @@
|
|
|
215
233
|
box-sizing: border-box;
|
|
216
234
|
border: 1px solid var(--control-edge);
|
|
217
235
|
border-radius: 9px;
|
|
218
|
-
background:
|
|
236
|
+
background: transparent;
|
|
219
237
|
color: var(--ink);
|
|
220
238
|
font: 650 12px/1.25 var(--ui-font);
|
|
221
239
|
cursor: pointer;
|
|
@@ -226,25 +244,31 @@
|
|
|
226
244
|
#assistant-root .assistant-auto-btn.start { flex: 1.5; }
|
|
227
245
|
#assistant-root :is(.assistant-btn:not(.secondary), .assistant-auto-btn.start),
|
|
228
246
|
#assistant-journal button {
|
|
229
|
-
background:
|
|
230
|
-
border-color:
|
|
231
|
-
color: var(--
|
|
247
|
+
background: transparent;
|
|
248
|
+
border-color: var(--ink);
|
|
249
|
+
color: var(--ink);
|
|
250
|
+
font-weight: 750;
|
|
232
251
|
}
|
|
233
252
|
#assistant-root :is(.assistant-btn:not(.secondary), .assistant-auto-btn.start):hover:not(:disabled),
|
|
234
|
-
#assistant-journal button:hover:not(:disabled) {
|
|
253
|
+
#assistant-journal button:hover:not(:disabled) {
|
|
254
|
+
background: transparent;
|
|
255
|
+
text-decoration: underline;
|
|
256
|
+
text-underline-offset: 3px;
|
|
257
|
+
}
|
|
235
258
|
#assistant-root :is(.assistant-btn.secondary, .assistant-auto-btn:not(.start), .assistant-history-btn,
|
|
236
259
|
.assistant-history-action, .assistant-history-item, .assistant-copy-btn, .assistant-icon-btn, .assistant-close):hover:not(:disabled) {
|
|
237
|
-
background:
|
|
238
|
-
border-color: var(--
|
|
260
|
+
background: transparent;
|
|
261
|
+
border-color: var(--ink);
|
|
239
262
|
}
|
|
240
263
|
#assistant-root :is(.assistant-auto-btn.stop, .assistant-history-action.danger) {
|
|
241
|
-
color: var(--
|
|
242
|
-
border-color:
|
|
264
|
+
color: var(--ink);
|
|
265
|
+
border-color: var(--ink);
|
|
266
|
+
font-weight: 750;
|
|
243
267
|
}
|
|
244
268
|
#assistant-root button:disabled,
|
|
245
269
|
#assistant-journal button:disabled {
|
|
246
|
-
background:
|
|
247
|
-
border: 1px dashed var(--
|
|
270
|
+
background: transparent;
|
|
271
|
+
border: 1px dashed var(--line-strong);
|
|
248
272
|
color: var(--muted);
|
|
249
273
|
cursor: not-allowed;
|
|
250
274
|
}
|
|
@@ -254,7 +278,7 @@
|
|
|
254
278
|
width: 32px;
|
|
255
279
|
height: 32px;
|
|
256
280
|
padding: 0;
|
|
257
|
-
color: var(--
|
|
281
|
+
color: var(--ink);
|
|
258
282
|
}
|
|
259
283
|
#assistant-root .assistant-icon-btn svg {
|
|
260
284
|
width: 16px;
|
|
@@ -272,7 +296,7 @@
|
|
|
272
296
|
min-height: 0;
|
|
273
297
|
overflow: auto;
|
|
274
298
|
scrollbar-width: thin;
|
|
275
|
-
scrollbar-color: #
|
|
299
|
+
scrollbar-color: #8a8f94 transparent;
|
|
276
300
|
}
|
|
277
301
|
#assistant-root .assistant-body {
|
|
278
302
|
padding: 3px;
|
|
@@ -281,12 +305,9 @@
|
|
|
281
305
|
#assistant-root :is(.assistant-placeholder, .assistant-loading, .assistant-error, .assistant-answer,
|
|
282
306
|
.assistant-code-container, .assistant-history-item, .assistant-qa-details > div, .assistant-qa-latest) {
|
|
283
307
|
box-sizing: border-box;
|
|
284
|
-
border: 1px solid var(--
|
|
308
|
+
border: 1px solid var(--line);
|
|
285
309
|
border-radius: 11px;
|
|
286
|
-
background:
|
|
287
|
-
-webkit-backdrop-filter: blur(14px);
|
|
288
|
-
backdrop-filter: blur(14px);
|
|
289
|
-
box-shadow: var(--card-shadow);
|
|
310
|
+
background: transparent;
|
|
290
311
|
}
|
|
291
312
|
#assistant-root :is(.assistant-placeholder, .assistant-loading) {
|
|
292
313
|
padding: 22px 12px;
|
|
@@ -299,18 +320,20 @@
|
|
|
299
320
|
#assistant-root .assistant-spinner {
|
|
300
321
|
width: 18px;
|
|
301
322
|
height: 18px;
|
|
302
|
-
|
|
303
|
-
border
|
|
323
|
+
box-sizing: border-box;
|
|
324
|
+
border: 2px solid var(--line);
|
|
325
|
+
border-top-color: var(--ink);
|
|
304
326
|
border-radius: 50%;
|
|
305
327
|
animation: assistant-glass-spin .8s linear infinite;
|
|
306
328
|
}
|
|
307
329
|
@keyframes assistant-glass-spin { to { transform: rotate(360deg); } }
|
|
308
330
|
#assistant-root .assistant-error {
|
|
309
331
|
padding: 10px 12px;
|
|
310
|
-
border-left: 3px solid var(--
|
|
311
|
-
background:
|
|
312
|
-
color: var(--
|
|
332
|
+
border-left: 3px solid var(--ink);
|
|
333
|
+
background: transparent;
|
|
334
|
+
color: var(--ink);
|
|
313
335
|
font-size: 13px;
|
|
336
|
+
font-weight: 650;
|
|
314
337
|
overflow-wrap: anywhere;
|
|
315
338
|
}
|
|
316
339
|
|
|
@@ -318,29 +341,30 @@
|
|
|
318
341
|
display: inline-block;
|
|
319
342
|
margin: 0 0 8px;
|
|
320
343
|
padding: 4px 8px;
|
|
321
|
-
border: 1px solid var(--
|
|
344
|
+
border: 1px solid var(--line);
|
|
322
345
|
border-radius: 999px;
|
|
323
|
-
background:
|
|
324
|
-
color: var(--
|
|
346
|
+
background: transparent;
|
|
347
|
+
color: var(--muted);
|
|
325
348
|
font: 700 10px/1.3 var(--ui-font);
|
|
326
349
|
letter-spacing: .04em;
|
|
327
350
|
text-transform: uppercase;
|
|
328
351
|
overflow-wrap: anywhere;
|
|
329
352
|
}
|
|
330
|
-
#assistant-root .assistant-provider-badge.verified { color: var(--
|
|
353
|
+
#assistant-root .assistant-provider-badge.verified { color: var(--ink); }
|
|
331
354
|
#assistant-root .assistant-answer { margin-bottom: 8px; padding: 12px; overflow-wrap: anywhere; }
|
|
332
355
|
#assistant-root .assistant-question-text { margin-bottom: 6px; color: var(--ink); font-weight: 620; }
|
|
333
|
-
#assistant-root .assistant-answer-text { color: var(--
|
|
334
|
-
#assistant-root .assistant-reasoning { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--
|
|
335
|
-
#assistant-root .assistant-reasoning summary { color: var(--
|
|
356
|
+
#assistant-root .assistant-answer-text { color: var(--correct); font-weight: 800; }
|
|
357
|
+
#assistant-root .assistant-reasoning { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
|
|
358
|
+
#assistant-root .assistant-reasoning summary { color: var(--ink); font-size: 12px; cursor: pointer; }
|
|
336
359
|
#assistant-root .assistant-reasoning-text {
|
|
337
360
|
margin-top: 6px;
|
|
338
361
|
padding: 9px;
|
|
339
362
|
max-height: 200px;
|
|
340
363
|
overflow: auto;
|
|
341
364
|
white-space: pre-wrap;
|
|
365
|
+
border: 1px solid var(--line);
|
|
342
366
|
border-radius: 8px;
|
|
343
|
-
background:
|
|
367
|
+
background: transparent;
|
|
344
368
|
color: var(--muted);
|
|
345
369
|
font-size: 12px;
|
|
346
370
|
}
|
|
@@ -352,13 +376,13 @@
|
|
|
352
376
|
justify-content: space-between;
|
|
353
377
|
gap: 8px;
|
|
354
378
|
padding: 9px;
|
|
355
|
-
border-bottom: 1px solid var(--
|
|
379
|
+
border-bottom: 1px solid var(--line);
|
|
356
380
|
color: var(--ink);
|
|
357
381
|
font-size: 12px;
|
|
358
382
|
}
|
|
359
383
|
#assistant-root .assistant-code-header span { overflow-wrap: anywhere; }
|
|
360
384
|
#assistant-root .assistant-copy-btn { padding: 5px 8px; }
|
|
361
|
-
#assistant-root .assistant-copy-btn.copied { color: var(--
|
|
385
|
+
#assistant-root .assistant-copy-btn.copied { color: var(--ink); border-color: var(--ink); }
|
|
362
386
|
#assistant-root :is(.assistant-code-approach, .assistant-code-complexity) { padding: 6px 10px 0; color: var(--muted); font-size: 12px; }
|
|
363
387
|
#assistant-root .assistant-code-block {
|
|
364
388
|
margin: 8px 5px 5px;
|
|
@@ -366,8 +390,9 @@
|
|
|
366
390
|
max-height: 240px;
|
|
367
391
|
overflow: auto;
|
|
368
392
|
white-space: pre;
|
|
393
|
+
border: 1px solid var(--line);
|
|
369
394
|
border-radius: 8px;
|
|
370
|
-
background:
|
|
395
|
+
background: transparent;
|
|
371
396
|
color: var(--ink);
|
|
372
397
|
font: 12px/1.55 "Cascadia Code", Consolas, monospace;
|
|
373
398
|
scrollbar-width: thin;
|
|
@@ -384,24 +409,24 @@
|
|
|
384
409
|
width: 100%;
|
|
385
410
|
margin-bottom: 7px;
|
|
386
411
|
padding: 10px;
|
|
387
|
-
border-color: var(--
|
|
412
|
+
border-color: var(--line);
|
|
388
413
|
text-align: left;
|
|
389
414
|
}
|
|
390
|
-
#assistant-root .assistant-history-type { color: var(--
|
|
391
|
-
#assistant-root .assistant-history-answer { color: var(--
|
|
415
|
+
#assistant-root .assistant-history-type { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
|
|
416
|
+
#assistant-root .assistant-history-answer { color: var(--correct); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
392
417
|
#assistant-root .assistant-history-time { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
|
|
393
418
|
|
|
394
419
|
#assistant-root .assistant-qa-panel { padding: 12px; }
|
|
395
420
|
#assistant-root .assistant-qa-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
|
|
396
|
-
#assistant-root .assistant-eyebrow { margin: 0 0 3px; color: var(--
|
|
397
|
-
#assistant-root .assistant-qa-heading h4 { margin: 0; color: var(--ink); font:
|
|
421
|
+
#assistant-root .assistant-eyebrow { margin: 0 0 3px; color: var(--muted); font: 700 10px/1.3 var(--ui-font); letter-spacing: .07em; }
|
|
422
|
+
#assistant-root .assistant-qa-heading h4 { margin: 0; color: var(--ink); font: 750 17px/1.2 var(--ui-font); letter-spacing: -.01em; }
|
|
398
423
|
#assistant-root .assistant-qa-state {
|
|
399
424
|
max-width: 50%;
|
|
400
425
|
padding: 4px 8px;
|
|
401
|
-
border: 1px solid var(--
|
|
426
|
+
border: 1px solid var(--line);
|
|
402
427
|
border-radius: 999px;
|
|
403
|
-
background:
|
|
404
|
-
color: var(--
|
|
428
|
+
background: transparent;
|
|
429
|
+
color: var(--ink);
|
|
405
430
|
font: 750 10px/1.2 var(--ui-font);
|
|
406
431
|
overflow: hidden;
|
|
407
432
|
text-overflow: ellipsis;
|
|
@@ -409,16 +434,16 @@
|
|
|
409
434
|
}
|
|
410
435
|
#assistant-root .assistant-qa-state::before { content: '● '; }
|
|
411
436
|
#assistant-root .assistant-qa-state[data-state="error"],
|
|
412
|
-
#assistant-root .assistant-qa-state[data-state="unauthorized"] { color: var(--
|
|
413
|
-
#assistant-root .assistant-qa-state[data-state="paused"] { color: var(--
|
|
437
|
+
#assistant-root .assistant-qa-state[data-state="unauthorized"] { color: var(--ink); border-color: var(--ink); }
|
|
438
|
+
#assistant-root .assistant-qa-state[data-state="paused"] { color: var(--muted); border-style: dashed; }
|
|
414
439
|
#assistant-root .assistant-automation-status { margin: 7px 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
|
|
415
440
|
#assistant-root .assistant-qa-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 0 0 9px; }
|
|
416
441
|
#assistant-root .assistant-qa-details > div { padding: 8px 9px; }
|
|
417
442
|
#assistant-root .assistant-qa-details .assistant-qa-wide { grid-column: 1 / -1; }
|
|
418
443
|
#assistant-root .assistant-qa-details dt { margin: 0 0 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
|
|
419
444
|
#assistant-root .assistant-qa-details dd { margin: 0; color: var(--ink); font-size: 12px; font-weight: 680; overflow-wrap: anywhere; }
|
|
420
|
-
#assistant-root .assistant-qa-latest { margin: 0 0 9px; padding: 8px 9px; border-left: 2px solid var(--
|
|
421
|
-
#assistant-root .assistant-qa-latest.has-error { border-left-color: var(--
|
|
445
|
+
#assistant-root .assistant-qa-latest { margin: 0 0 9px; padding: 8px 9px; border-left: 2px solid var(--line-strong); color: var(--ink); font-size: 12px; overflow-wrap: anywhere; }
|
|
446
|
+
#assistant-root .assistant-qa-latest.has-error { border-left-color: var(--ink); color: var(--ink); background: transparent; font-weight: 650; }
|
|
422
447
|
#assistant-root .assistant-qa-latest:empty { display: none; }
|
|
423
448
|
|
|
424
449
|
#assistant-journal {
|
|
@@ -442,13 +467,11 @@
|
|
|
442
467
|
margin: 0 0 10px;
|
|
443
468
|
padding: 11px;
|
|
444
469
|
border-radius: 11px;
|
|
445
|
-
background:
|
|
446
|
-
backdrop-filter: blur(18px);
|
|
447
|
-
box-shadow: var(--card-shadow);
|
|
470
|
+
background: transparent;
|
|
448
471
|
}
|
|
449
472
|
#assistant-journal strong { color: var(--ink); font-size: 15px; }
|
|
450
473
|
#assistant-journal p { margin: 5px 0 8px; color: var(--muted); }
|
|
451
|
-
#assistant-journal [data-countdown] { color: var(--
|
|
474
|
+
#assistant-journal [data-countdown] { color: var(--ink); font-weight: 750; font-variant-numeric: tabular-nums; }
|
|
452
475
|
#assistant-journal [role="status"] { color: var(--ink); overflow-wrap: anywhere; }
|
|
453
476
|
#assistant-journal p:empty { display: none; }
|
|
454
477
|
#assistant-journal label { display: block; margin-bottom: 8px; color: var(--ink); }
|
|
@@ -457,9 +480,9 @@
|
|
|
457
480
|
box-sizing: border-box;
|
|
458
481
|
width: 100%;
|
|
459
482
|
padding: 8px;
|
|
460
|
-
border: 1px solid var(--
|
|
483
|
+
border: 1px solid var(--line-strong);
|
|
461
484
|
border-radius: 8px;
|
|
462
|
-
background:
|
|
485
|
+
background: transparent;
|
|
463
486
|
color: var(--ink);
|
|
464
487
|
font: inherit;
|
|
465
488
|
}
|
|
@@ -468,25 +491,17 @@
|
|
|
468
491
|
#assistant-journal textarea::placeholder { color: var(--muted); }
|
|
469
492
|
#assistant-journal button { margin-top: 8px; min-height: 36px; padding: 8px 11px; }
|
|
470
493
|
|
|
471
|
-
#assistant-root :is(.assistant-btn.secondary, .assistant-auto-btn:not(.start), .assistant-reasoning-text,
|
|
472
|
-
.assistant-code-block, .assistant-provider-badge, .assistant-qa-state),
|
|
473
|
-
#assistant-journal :is(select, textarea) {
|
|
474
|
-
-webkit-backdrop-filter: blur(12px);
|
|
475
|
-
backdrop-filter: blur(12px);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
494
|
body.assistant-popup {
|
|
479
495
|
box-sizing: border-box;
|
|
480
496
|
width: 290px;
|
|
481
497
|
margin: 0;
|
|
482
498
|
padding: 10px;
|
|
483
|
-
background:
|
|
484
|
-
radial-gradient(ellipse at 0% 100%, #146166, transparent 58%), #0a1326;
|
|
499
|
+
background: transparent;
|
|
485
500
|
color: var(--ink);
|
|
486
501
|
font: 13px/1.45 var(--ui-font);
|
|
487
502
|
}
|
|
488
503
|
.assistant-popup .popup-shell {
|
|
489
|
-
background:
|
|
504
|
+
background: transparent;
|
|
490
505
|
padding: 13px;
|
|
491
506
|
border-radius: 15px;
|
|
492
507
|
}
|
|
@@ -496,18 +511,26 @@ body.assistant-popup {
|
|
|
496
511
|
place-items: center;
|
|
497
512
|
width: 33px;
|
|
498
513
|
height: 33px;
|
|
514
|
+
box-sizing: border-box;
|
|
515
|
+
border: 1px solid var(--line-strong);
|
|
499
516
|
border-radius: 10px;
|
|
500
|
-
background:
|
|
501
|
-
color: var(--
|
|
517
|
+
background: transparent;
|
|
518
|
+
color: var(--ink);
|
|
502
519
|
font-weight: 800;
|
|
503
520
|
}
|
|
504
|
-
.assistant-popup h1 {
|
|
505
|
-
|
|
521
|
+
.assistant-popup h1 {
|
|
522
|
+
margin: 0;
|
|
523
|
+
color: var(--ink);
|
|
524
|
+
font-size: 15px;
|
|
525
|
+
font-weight: 750;
|
|
526
|
+
letter-spacing: -.02em;
|
|
527
|
+
}
|
|
528
|
+
.assistant-popup h2 { margin: 0 0 5px; font-size: 12px; color: var(--ink); font-weight: 750; letter-spacing: .01em; }
|
|
506
529
|
.assistant-popup .popup-card { padding: 9px; margin-top: 8px; }
|
|
507
|
-
.assistant-popup #server-status { color: var(--
|
|
530
|
+
.assistant-popup #server-status { color: var(--muted); font-weight: 700; }
|
|
508
531
|
.assistant-popup #server-status.online,
|
|
509
|
-
.assistant-popup #journal-countdown { color: var(--
|
|
510
|
-
.assistant-popup #server-status.offline { color: var(--
|
|
532
|
+
.assistant-popup #journal-countdown { color: var(--ink); }
|
|
533
|
+
.assistant-popup #server-status.offline { color: var(--ink); font-weight: 800; }
|
|
511
534
|
.assistant-popup #journal-countdown { margin: 7px 0 0; font-variant-numeric: tabular-nums; }
|
|
512
535
|
.assistant-popup .shortcut-row {
|
|
513
536
|
display: flex;
|
|
@@ -522,9 +545,9 @@ body.assistant-popup {
|
|
|
522
545
|
.assistant-popup kbd {
|
|
523
546
|
display: inline-block;
|
|
524
547
|
padding: 1px 5px;
|
|
525
|
-
border: 1px solid var(--
|
|
548
|
+
border: 1px solid var(--line);
|
|
526
549
|
border-radius: 5px;
|
|
527
|
-
background:
|
|
550
|
+
background: transparent;
|
|
528
551
|
color: var(--ink);
|
|
529
552
|
white-space: nowrap;
|
|
530
553
|
font: 600 11px/1.5 var(--ui-font);
|
|
@@ -532,16 +555,12 @@ body.assistant-popup {
|
|
|
532
555
|
|
|
533
556
|
#assistant-root :is(button, summary):focus-visible,
|
|
534
557
|
#assistant-journal :is(button, select, textarea):focus-visible {
|
|
535
|
-
outline: 2px solid var(--
|
|
558
|
+
outline: 2px solid var(--ink);
|
|
536
559
|
outline-offset: 2px;
|
|
537
560
|
}
|
|
538
561
|
#assistant-root .assistant-history-item:focus-visible { outline-offset: -3px; }
|
|
539
|
-
#assistant-root .assistant-tab.collapsed:focus-visible {
|
|
562
|
+
#assistant-root .assistant-tab.collapsed:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
|
|
540
563
|
|
|
541
|
-
@supports not (backdrop-filter: blur(12px)) {
|
|
542
|
-
#assistant-root .assistant-tab:not(.has-answer), #assistant-journal,
|
|
543
|
-
#assistant-journal-countdown-badge, .assistant-popup .popup-shell { background: #13213a; }
|
|
544
|
-
}
|
|
545
564
|
@media (max-width: 360px) {
|
|
546
565
|
#assistant-root .assistant-tab:not(.collapsed) { padding: 10px; }
|
|
547
566
|
#assistant-root .assistant-qa-panel { padding: 9px; }
|
|
@@ -563,14 +582,15 @@ body.assistant-popup {
|
|
|
563
582
|
width: 100%;
|
|
564
583
|
margin-top: 8px;
|
|
565
584
|
padding: 7px 8px;
|
|
566
|
-
border: 1px solid var(--
|
|
585
|
+
border: 1px solid var(--line-strong);
|
|
567
586
|
border-radius: 6px;
|
|
568
|
-
background:
|
|
587
|
+
background: transparent;
|
|
569
588
|
color: var(--ink);
|
|
570
589
|
font: inherit;
|
|
571
590
|
cursor: pointer;
|
|
572
591
|
}
|
|
573
|
-
.assistant-popup #separate-panel
|
|
592
|
+
.assistant-popup #open-separate-panel:hover { border-color: var(--ink); }
|
|
593
|
+
.assistant-popup #separate-panel-status { color: var(--ink); font-weight: 650; }
|
|
574
594
|
#assistant-automation-notice {
|
|
575
595
|
position: fixed;
|
|
576
596
|
right: 16px;
|
|
@@ -578,10 +598,11 @@ body.assistant-popup {
|
|
|
578
598
|
z-index: 2147483647;
|
|
579
599
|
max-width: min(320px, calc(100vw - 48px));
|
|
580
600
|
padding: 8px 12px;
|
|
601
|
+
border: 1px solid var(--line-strong);
|
|
581
602
|
border-radius: 8px;
|
|
582
|
-
background:
|
|
583
|
-
color:
|
|
584
|
-
font: 13px/1.5 system-ui, sans-serif;
|
|
603
|
+
background: transparent;
|
|
604
|
+
color: var(--ink);
|
|
605
|
+
font: 650 13px/1.5 system-ui, sans-serif;
|
|
585
606
|
pointer-events: none;
|
|
586
607
|
}
|
|
587
608
|
#assistant-root.assistant-detached,
|
|
@@ -592,8 +613,8 @@ body.assistant-popup {
|
|
|
592
613
|
body.detached-panel {
|
|
593
614
|
margin: 0;
|
|
594
615
|
padding: 10px;
|
|
595
|
-
background:
|
|
596
|
-
color:
|
|
616
|
+
background: transparent;
|
|
617
|
+
color: var(--ink);
|
|
597
618
|
font: 13px/1.5 Inter, system-ui, sans-serif;
|
|
598
619
|
}
|
|
599
620
|
.detached-panel .detached-toolbar {
|
|
@@ -604,19 +625,20 @@ body.detached-panel {
|
|
|
604
625
|
margin-bottom: 10px;
|
|
605
626
|
}
|
|
606
627
|
.detached-panel #detached-status { overflow-wrap: anywhere; }
|
|
607
|
-
.detached-panel #detached-countdown { margin: 0 0 10px; color:
|
|
628
|
+
.detached-panel #detached-countdown { margin: 0 0 10px; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
|
|
608
629
|
.detached-panel #detached-return {
|
|
609
630
|
flex: 0 0 auto;
|
|
610
631
|
padding: 5px 8px;
|
|
611
|
-
border: 1px solid
|
|
632
|
+
border: 1px solid var(--line-strong);
|
|
612
633
|
border-radius: 6px;
|
|
613
|
-
background:
|
|
614
|
-
color:
|
|
634
|
+
background: transparent;
|
|
635
|
+
color: var(--ink);
|
|
615
636
|
font: inherit;
|
|
616
637
|
font-size: 11px;
|
|
617
638
|
cursor: pointer;
|
|
618
639
|
}
|
|
619
|
-
.detached-panel #detached-return:
|
|
640
|
+
.detached-panel #detached-return:hover { border-color: var(--ink); }
|
|
641
|
+
.detached-panel #detached-return:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
|
|
620
642
|
.detached-panel #assistant-root { position: static; }
|
|
621
643
|
.detached-panel #assistant-root[hidden],
|
|
622
644
|
.detached-panel #assistant-root [hidden] { display: none !important; }
|
|
@@ -633,16 +655,16 @@ body.detached-panel {
|
|
|
633
655
|
width: 100%;
|
|
634
656
|
box-sizing: border-box;
|
|
635
657
|
padding: 10px;
|
|
636
|
-
border: 1px solid
|
|
658
|
+
border: 1px solid var(--line);
|
|
637
659
|
border-radius: 8px;
|
|
638
|
-
background:
|
|
639
|
-
color:
|
|
640
|
-
font: 13px
|
|
660
|
+
background: transparent;
|
|
661
|
+
color: var(--ink);
|
|
662
|
+
font: 13px Inter, system-ui, sans-serif;
|
|
641
663
|
margin: 10px 0;
|
|
642
664
|
}
|
|
643
665
|
.detached-panel #assistant-journal label { display: block; margin: 8px 0; }
|
|
644
666
|
.detached-panel #assistant-journal select,
|
|
645
667
|
.detached-panel #assistant-journal textarea { display: block; width: 100%; box-sizing: border-box; }
|
|
646
|
-
.detached-panel #assistant-journal select { padding: 5px; color:
|
|
668
|
+
.detached-panel #assistant-journal select { padding: 5px; color: var(--ink); background: transparent; border: 1px solid var(--line-strong); }
|
|
647
669
|
.detached-panel #assistant-journal button { margin-top: 8px; padding: 10px; }
|
|
648
|
-
.detached-panel #assistant-journal [data-countdown] { margin: 8px 0; font-weight:
|
|
670
|
+
.detached-panel #assistant-journal [data-countdown] { margin: 8px 0; font-weight: 650; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-assistant",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.22",
|
|
4
4
|
"description": "Chrome extension and local Python backend for exploring webpage questions and coding exercises",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -47,7 +47,9 @@
|
|
|
47
47
|
"prepack": "npm run build",
|
|
48
48
|
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
49
49
|
"test": "npm run build && node --test extension/*.test.cts",
|
|
50
|
-
"test:browser": "npm run build && node --test scripts/test_separate_panel.cjs"
|
|
50
|
+
"test:browser": "npm run build && node --test scripts/test_separate_panel.cjs",
|
|
51
|
+
"test:shortcuts": "npm run build && node --test scripts/test_keyboard_shortcuts.cjs",
|
|
52
|
+
"test:tone": "npm run build && node --test scripts/test_panel_tone.cjs"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@types/chrome": "0.3.7",
|
package/server/main.py
CHANGED
|
@@ -27,6 +27,7 @@ from local_security import install_local_guards, redact, sanitize_data
|
|
|
27
27
|
from vision_images import (compress_image_base64, unique_image_blocks, collect_image_evidence,
|
|
28
28
|
cross_check_visual_answers, relative_percentage_question, RELATIVE_PERCENTAGE_INSTRUCTION,
|
|
29
29
|
answer_permutation, cross_check_text_answers, solve_matrix_choice, solve_row_parallel_choice,
|
|
30
|
+
solve_relu_parallel_choice,
|
|
30
31
|
ordering_question, solve_sorted_list_merge_order, solve_stack_empty_order, solve_pseudocode_choice,
|
|
31
32
|
reading_response_constraints,
|
|
32
33
|
VisionRateLimitError, VisionUnconfirmedError)
|
|
@@ -192,7 +193,7 @@ async def lifespan(_app: FastAPI):
|
|
|
192
193
|
client.close()
|
|
193
194
|
|
|
194
195
|
|
|
195
|
-
app = FastAPI(title="Browser Assistant API", version="2.9.
|
|
196
|
+
app = FastAPI(title="Browser Assistant API", version="2.9.22", lifespan=lifespan)
|
|
196
197
|
install_local_guards(app)
|
|
197
198
|
|
|
198
199
|
@app.exception_handler(HTTPException)
|
|
@@ -227,6 +228,7 @@ class VisionContent(BaseModel):
|
|
|
227
228
|
language: str | None = None
|
|
228
229
|
text: str = ""
|
|
229
230
|
verify_answer: bool = False
|
|
231
|
+
allow_overview: bool = False
|
|
230
232
|
images: list[str] = [] # Additional complete question/option illustrations.
|
|
231
233
|
|
|
232
234
|
@field_validator("text")
|
|
@@ -731,7 +733,14 @@ def normalize_web_response(parsed):
|
|
|
731
733
|
return parsed
|
|
732
734
|
|
|
733
735
|
|
|
734
|
-
def
|
|
736
|
+
def is_displayable_overview(item: dict) -> bool:
|
|
737
|
+
return item.get('type') == 'overview' and all(
|
|
738
|
+
isinstance(item.get(field), str) and item[field].strip() for field in ('title', 'summary')
|
|
739
|
+
)
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
def validate_code_results(results_json: str, language: str, require_code: bool = False,
|
|
743
|
+
starter_code: str | None = None, *, allow_overview: bool = False) -> str:
|
|
735
744
|
"""Validate generated code and ensure response metadata matches the locked language."""
|
|
736
745
|
parsed = json.loads(results_json)
|
|
737
746
|
if language == 'web':
|
|
@@ -749,6 +758,9 @@ def validate_code_results(results_json: str, language: str, require_code: bool =
|
|
|
749
758
|
else item for item in parsed]
|
|
750
759
|
if not isinstance(parsed, list):
|
|
751
760
|
raise ValueError('Expected a JSON array of solution objects')
|
|
761
|
+
if (allow_overview and not require_code and len(parsed) == 1
|
|
762
|
+
and isinstance(parsed[0], dict) and is_displayable_overview(parsed[0])):
|
|
763
|
+
return json.dumps(parsed)
|
|
752
764
|
code_items = [item for item in parsed if isinstance(item, dict) and item.get('type') == 'code']
|
|
753
765
|
if require_code and not code_items:
|
|
754
766
|
raise ValueError('Code mode response did not contain a code solution')
|
|
@@ -987,11 +999,20 @@ def build_ollama_code_messages(text: str, url: str, language: str) -> list:
|
|
|
987
999
|
]
|
|
988
1000
|
|
|
989
1001
|
|
|
990
|
-
def build_vision_system_prompt(language: str | None = None) -> str:
|
|
1002
|
+
def build_vision_system_prompt(language: str | None = None, *, allow_overview: bool = False) -> str:
|
|
991
1003
|
"""Build a vision prompt with the requested language locked for code output."""
|
|
992
1004
|
language = normalize_language(language) or CODE_DEFAULT_LANGUAGE
|
|
993
1005
|
language_name = LANGUAGE_NAMES[language]
|
|
1006
|
+
overview_instructions = (
|
|
1007
|
+
'\nFor a readable assignment overview or instruction page without a specific question or '
|
|
1008
|
+
'standalone coding problem, return one overview object: '
|
|
1009
|
+
'[{"type":"overview","title":"visible topic","summary":"concise summary of the visible requirements and next steps"}]. '
|
|
1010
|
+
'Describe only what is visible. Ignore unrelated navigation and do not invent missing content. '
|
|
1011
|
+
'An unreadable or incomplete question still requires [].\n'
|
|
1012
|
+
if allow_overview else ''
|
|
1013
|
+
)
|
|
994
1014
|
return f"""Analyze a screenshot using only readable visual evidence and the supplied question context.
|
|
1015
|
+
{overview_instructions}
|
|
995
1016
|
|
|
996
1017
|
CRITICAL REASONING RULES — FOLLOW EXACTLY:
|
|
997
1018
|
|
|
@@ -1067,6 +1088,8 @@ async def generate_validated_result(
|
|
|
1067
1088
|
reviewer=None,
|
|
1068
1089
|
review_code: bool = True,
|
|
1069
1090
|
starter_code: str | None = None,
|
|
1091
|
+
*,
|
|
1092
|
+
allow_overview: bool = False,
|
|
1070
1093
|
) -> str:
|
|
1071
1094
|
"""Generate, repair syntax/language/completeness errors, independently review, then return."""
|
|
1072
1095
|
raw_result = await generator(messages)
|
|
@@ -1074,7 +1097,8 @@ async def generate_validated_result(
|
|
|
1074
1097
|
if cleaned == "[]" and not require_code:
|
|
1075
1098
|
return cleaned
|
|
1076
1099
|
try:
|
|
1077
|
-
validated = validate_code_results(cleaned, language, require_code=require_code, starter_code=starter_code
|
|
1100
|
+
validated = validate_code_results(cleaned, language, require_code=require_code, starter_code=starter_code,
|
|
1101
|
+
allow_overview=allow_overview)
|
|
1078
1102
|
for item in json.loads(validated):
|
|
1079
1103
|
if isinstance(item, dict) and item.get('type') == 'code':
|
|
1080
1104
|
validate_starter_interface(item['code'], starter_code, language)
|
|
@@ -1085,8 +1109,9 @@ async def generate_validated_result(
|
|
|
1085
1109
|
"role": "user",
|
|
1086
1110
|
"content": (
|
|
1087
1111
|
f"The previous response failed validation: {validation_error}. "
|
|
1088
|
-
|
|
1089
|
-
|
|
1112
|
+
+ ("Regenerate a result matching the screenshot and the allowed response formats. "
|
|
1113
|
+
if allow_overview else f"Regenerate the complete solution in {LANGUAGE_NAMES[language]} only. ")
|
|
1114
|
+
+ f"Set every code result's language field to {language!r}. Return JSON only."
|
|
1090
1115
|
+ (build_system_prompt('code', 'web') if require_code and language == 'web' else
|
|
1091
1116
|
f' Required schema: [{{"type":"code","language":"{language}","title":"Solution","code":"complete solution","approach":"brief algorithm","time_complexity":"O(...)","space_complexity":"O(...)"}}]. Do not return MCQ answers or a review verdict.' if require_code else '')
|
|
1092
1117
|
+ starter_interface_instructions(starter_code, language)
|
|
@@ -1098,7 +1123,8 @@ async def generate_validated_result(
|
|
|
1098
1123
|
if retry_cleaned == "[]":
|
|
1099
1124
|
raise ValueError(f"Language correction retry returned no usable result: {validation_error}")
|
|
1100
1125
|
try:
|
|
1101
|
-
validated = validate_code_results(retry_cleaned, language, require_code=require_code, starter_code=starter_code
|
|
1126
|
+
validated = validate_code_results(retry_cleaned, language, require_code=require_code, starter_code=starter_code,
|
|
1127
|
+
allow_overview=allow_overview)
|
|
1102
1128
|
for item in json.loads(validated):
|
|
1103
1129
|
if isinstance(item, dict) and item.get('type') == 'code':
|
|
1104
1130
|
validate_starter_interface(item['code'], starter_code, language)
|
|
@@ -1259,6 +1285,9 @@ def local_choice_result(text, language):
|
|
|
1259
1285
|
if item is None:
|
|
1260
1286
|
item = solve_row_parallel_choice(text)
|
|
1261
1287
|
provider = "local tensor dimension check"
|
|
1288
|
+
if item is None:
|
|
1289
|
+
item = solve_relu_parallel_choice(text)
|
|
1290
|
+
provider = "local ReLU shard check"
|
|
1262
1291
|
if item is None:
|
|
1263
1292
|
item = solve_pseudocode_choice(text)
|
|
1264
1293
|
provider = "local pseudocode check"
|
|
@@ -1510,6 +1539,7 @@ async def _solve_vision(content: VisionContent):
|
|
|
1510
1539
|
except ValueError as exc:
|
|
1511
1540
|
raise HTTPException(422, f'Image {index}: {exc}') from exc
|
|
1512
1541
|
is_code_scan = content.practice_type == "code" or (content.practice_type == "auto" and bool(content.language))
|
|
1542
|
+
allow_overview = content.allow_overview and content.practice_type == 'auto' and not is_code_scan and not content.text.strip()
|
|
1513
1543
|
if not is_code_scan and content.practice_type in {'auto', 'mcq', 'math', 'aptitude'}:
|
|
1514
1544
|
local_result = local_choice_result(content.text, content.language or CODE_DEFAULT_LANGUAGE)
|
|
1515
1545
|
if local_result is not None:
|
|
@@ -1622,7 +1652,7 @@ async def _solve_vision(content: VisionContent):
|
|
|
1622
1652
|
extracted_text = ocr_payload["text"]
|
|
1623
1653
|
language = resolve_language(extracted_text)
|
|
1624
1654
|
logger.info(f"Locked requested code language to {language}")
|
|
1625
|
-
system_prompt = build_vision_system_prompt(language)
|
|
1655
|
+
system_prompt = build_vision_system_prompt(language, allow_overview=allow_overview)
|
|
1626
1656
|
if is_code_scan and language == 'web':
|
|
1627
1657
|
system_prompt = build_system_prompt('code', 'web') + (
|
|
1628
1658
|
'\nUse the attached screenshots and supplied context as the original problem. '
|
|
@@ -1631,13 +1661,15 @@ async def _solve_vision(content: VisionContent):
|
|
|
1631
1661
|
if comparison:
|
|
1632
1662
|
system_prompt += '\n' + RELATIVE_PERCENTAGE_INSTRUCTION
|
|
1633
1663
|
vision_prompt = "Identify and solve all visible questions using readable evidence."
|
|
1664
|
+
if allow_overview:
|
|
1665
|
+
vision_prompt += " If the screenshot instead shows an assignment overview or instructions, summarize the visible requirements."
|
|
1634
1666
|
if is_code_scan:
|
|
1635
1667
|
vision_prompt += (
|
|
1636
1668
|
f" The locked code language is {LANGUAGE_NAMES[language]} ({language}); "
|
|
1637
1669
|
f"generate code in that language only. "
|
|
1638
1670
|
f"Text transcribed from the screenshot: {extracted_text or '[language supplied by caller]'}"
|
|
1639
1671
|
)
|
|
1640
|
-
if content.text:
|
|
1672
|
+
if content.text.strip():
|
|
1641
1673
|
vision_prompt += ("\nSolve exactly the following question using the attached complete illustrations. "
|
|
1642
1674
|
"Use this ordered option list for the answer letter. The image may contain only the chart.\n"
|
|
1643
1675
|
+ content.text)
|
|
@@ -1676,6 +1708,7 @@ async def _solve_vision(content: VisionContent):
|
|
|
1676
1708
|
require_code=is_code_scan,
|
|
1677
1709
|
reviewer=vision_reviewer,
|
|
1678
1710
|
review_code=not content.verify_answer,
|
|
1711
|
+
allow_overview=allow_overview,
|
|
1679
1712
|
)
|
|
1680
1713
|
if cleaned != "[]":
|
|
1681
1714
|
items = json.loads(cleaned)
|
|
@@ -1910,6 +1943,8 @@ def has_usable_results(results_json: str) -> bool:
|
|
|
1910
1943
|
code = item.get("code") or item.get("answer")
|
|
1911
1944
|
if not isinstance(code, str) or not code.strip():
|
|
1912
1945
|
return False
|
|
1946
|
+
elif is_displayable_overview(item):
|
|
1947
|
+
continue
|
|
1913
1948
|
else:
|
|
1914
1949
|
return False
|
|
1915
1950
|
answer = str(item.get("answer", "")).lower()
|
package/server/vision_images.py
CHANGED
|
@@ -530,6 +530,33 @@ def solve_row_parallel_choice(text):
|
|
|
530
530
|
}
|
|
531
531
|
|
|
532
532
|
|
|
533
|
+
def solve_relu_parallel_choice(text):
|
|
534
|
+
"""Verify why ReLU can be applied to sharded intermediate activations."""
|
|
535
|
+
choices = displayed_single_choices(text)
|
|
536
|
+
if not choices:
|
|
537
|
+
return None
|
|
538
|
+
question = re.split(r'\n(?:Question format: )?Select one answer\.', text.strip(), maxsplit=1, flags=re.I)[0]
|
|
539
|
+
prompt = ' '.join(question.replace('\x60', '').split())
|
|
540
|
+
if not re.fullmatch(
|
|
541
|
+
r'(?:an? |the )?MLP (?:has|uses) (?:a )?ReLU between (?:two )?matrix multiplications\. '
|
|
542
|
+
r'Why (?:does|can) tensor parallelism (?:still )?work(?: here)?\?', prompt, re.I,
|
|
543
|
+
):
|
|
544
|
+
return None
|
|
545
|
+
elementwise = r'(?:element[- ]?wise|element by element|pointwise|independently on each element)'
|
|
546
|
+
matches = [(letter, option) for letter, option in choices.items() if re.fullmatch(
|
|
547
|
+
rf'ReLU (?:works|operates|acts) {elementwise}(?:,? so (?:each shard can apply it(?: independently)?|shards (?:can )?apply it))?\.?',
|
|
548
|
+
' '.join(option.replace('\x60', '').split()), re.I,
|
|
549
|
+
)]
|
|
550
|
+
if len(matches) != 1:
|
|
551
|
+
return None
|
|
552
|
+
letter, option = matches[0]
|
|
553
|
+
return {
|
|
554
|
+
'type': 'mcq', 'question': question, 'answer': f'Option {letter}: {option}',
|
|
555
|
+
'reasoning': 'ReLU computes max(0, x) for each activation independently. Each shard can apply it to its '
|
|
556
|
+
'own intermediate activations before the second multiplication.',
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
|
|
533
560
|
def bind_displayed_choice(value, choices, *, matrix_math):
|
|
534
561
|
if type(value) not in (str, int, float):
|
|
535
562
|
return None
|