browser-assistant 2.9.35 → 2.9.37

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 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 **⌥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).
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 dedicated shortcut is **⌥J** (Alt + J). 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
 
@@ -157,7 +157,7 @@
157
157
  event.preventDefault();
158
158
  void send('automation');
159
159
  }
160
- else if (event.shiftKey && (key === 'j' || event.code === 'KeyJ')) {
160
+ else if (!event.shiftKey && (key === 'j' || event.code === 'KeyJ')) {
161
161
  event.preventDefault();
162
162
  void send('journal');
163
163
  }
@@ -228,13 +228,13 @@ function browserAssistantJournal(global) {
228
228
  publishedDeadline = undefined;
229
229
  }
230
230
  }
231
- button.title = 'Fill & Submit Journal (Alt + Shift + J)';
232
- button.setAttribute('aria-keyshortcuts', 'Alt+Shift+J');
231
+ button.title = 'Fill & Submit Journal (Alt + J)';
232
+ button.setAttribute('aria-keyshortcuts', 'Alt+J');
233
233
  const shortcutHint = document.createElement('p');
234
- shortcutHint.textContent = 'Shortcut: Alt + Shift + J';
234
+ shortcutHint.textContent = 'Shortcut: Alt + J';
235
235
  panel.insertBefore(shortcutHint, status);
236
236
  const shortcutListener = event => {
237
- if (!event.altKey || !event.shiftKey || event.ctrlKey || event.metaKey || event.repeat || event.isComposing)
237
+ if (!event.altKey || event.shiftKey || event.ctrlKey || event.metaKey || event.repeat || event.isComposing)
238
238
  return;
239
239
  if (event.code !== 'KeyJ' && String(event.key).toLowerCase() !== 'j')
240
240
  return;
@@ -637,7 +637,7 @@ if (typeof window !== 'undefined' && isSidusJournalOrigin(location.origin)) {
637
637
  if (!window.BrowserAssistantJournalListShortcut) {
638
638
  window.BrowserAssistantJournalListShortcut = true;
639
639
  document.addEventListener('keydown', event => {
640
- if (!/^\/modules\/assessments\/assessments\/?$/.test(location.pathname) || !event.altKey || !event.shiftKey || event.ctrlKey || event.metaKey || event.repeat || event.isComposing)
640
+ if (!/^\/modules\/assessments\/assessments\/?$/.test(location.pathname) || !event.altKey || event.shiftKey || event.ctrlKey || event.metaKey || event.repeat || event.isComposing)
641
641
  return;
642
642
  if (event.code !== 'KeyJ' && String(event.key).toLowerCase() !== 'j')
643
643
  return;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Assistant",
4
- "version": "2.9.35",
4
+ "version": "2.9.37",
5
5
  "description": "Scans webpages for MCQs and coding problems. Powered by Groq (cloud) and Ollama (local fallback).",
6
6
  "permissions": [
7
7
  "activeTab",
@@ -24,7 +24,7 @@
24
24
  <div class="shortcut-row"><span>Close panel</span> <span><kbd>]</kbd> <kbd>⌃⇧X</kbd></span></div>
25
25
  <div class="shortcut-row"><span>Vision scan</span> <span><kbd>\</kbd> <kbd>⌃⇧S</kbd></span></div>
26
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>
27
+ <div class="shortcut-row"><span>Fill and submit journal</span> <kbd>⌥J</kbd></div>
28
28
  <div class="shortcut-row"><span>Start, pause or resume</span> <kbd>⌥A</kbd></div>
29
29
  </section>
30
30
  </main>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-assistant",
3
- "version": "2.9.35",
3
+ "version": "2.9.37",
4
4
  "description": "Chrome extension and local Python backend for exploring webpage questions and coding exercises",
5
5
  "license": "MIT",
6
6
  "repository": {
package/server/journal.py CHANGED
@@ -99,7 +99,10 @@ def register_journal(app, cloud, local):
99
99
  except Exception:
100
100
  raw = await local(messages, temperature=0.2)
101
101
  except Exception as exc:
102
- raise HTTPException(503, 'Journal generation unavailable. Check AI provider settings.') from exc
102
+ raise HTTPException(
103
+ 503, 'Journal generation could not get a response from Groq or local Ollama. '
104
+ 'Try again shortly. If it keeps failing, check your Groq quota or start Ollama.'
105
+ ) from exc
103
106
  try:
104
107
  raw = re.sub(r'^```(?:json)?\s*|\s*```$', '', raw.strip())
105
108
  sections, count = validate_sections(json.loads(raw))
package/server/main.py CHANGED
@@ -195,7 +195,7 @@ async def lifespan(_app: FastAPI):
195
195
  client.close()
196
196
 
197
197
 
198
- app = FastAPI(title="Browser Assistant API", version="2.9.35", lifespan=lifespan)
198
+ app = FastAPI(title="Browser Assistant API", version="2.9.37", lifespan=lifespan)
199
199
  install_local_guards(app)
200
200
 
201
201
  @app.exception_handler(HTTPException)
@@ -429,7 +429,7 @@ def save_automation_history(entry: AutomationHistoryEntry):
429
429
 
430
430
  # ── AI providers ──────────────────────────────────────────────────────────────
431
431
 
432
- async def try_groq(messages: list, model: str = None, temperature: float = 0.0, _token_limit: int = GROQ_COMPLETION_TOKEN_LIMIT, _review: bool = False) -> str:
432
+ async def try_groq(messages: list, model: str = None, temperature: float = 0.0, _token_limit: int = GROQ_COMPLETION_TOKEN_LIMIT, _review: bool = False, *, structured: bool = False) -> str:
433
433
  """Call Groq with automatic API key rotation on rate limit (429)."""
434
434
  global _groq_disabled_until, _groq_key_index
435
435
  if time.monotonic() < _groq_disabled_until:
@@ -441,9 +441,8 @@ async def try_groq(messages: list, model: str = None, temperature: float = 0.0,
441
441
  use_model = model or GROQ_TEXT_MODEL
442
442
  loop = asyncio.get_running_loop()
443
443
  review_options = {}
444
- if _review:
445
- # Review returns a verdict, not another full program. Keep reasoning
446
- # bounded so GPT-OSS leaves room for its final JSON verdict.
444
+ if _review or structured:
445
+ # Keep reasoning bounded so GPT-OSS leaves room for the final JSON.
447
446
  review_options['response_format'] = {'type': 'json_object'}
448
447
  if use_model in {'openai/gpt-oss-20b', 'openai/gpt-oss-120b'}:
449
448
  review_options['reasoning_effort'] = 'low'
@@ -475,7 +474,7 @@ async def try_groq(messages: list, model: str = None, temperature: float = 0.0,
475
474
  if getattr(choice, "finish_reason", None) == "length":
476
475
  if _token_limit < GROQ_RETRY_TOKEN_LIMIT:
477
476
  logger.warning(f"{use_model} reached {_token_limit} tokens; retrying once with {GROQ_RETRY_TOKEN_LIMIT}")
478
- return await try_groq(messages, model=use_model, temperature=temperature, _token_limit=GROQ_RETRY_TOKEN_LIMIT, _review=_review)
477
+ return await try_groq(messages, model=use_model, temperature=temperature, _token_limit=GROQ_RETRY_TOKEN_LIMIT, _review=_review, structured=structured)
479
478
  raise RuntimeError(f"{use_model} stopped at the output token limit")
480
479
  content = choice.message.content or ""
481
480
  if not content.strip():
@@ -550,6 +549,17 @@ TEXT_MODELS = list(dict.fromkeys([
550
549
  "openai/gpt-oss-20b",
551
550
  ]))
552
551
 
552
+
553
+ async def try_journal_cloud(messages: list, temperature: float = 0.2) -> str:
554
+ for model in TEXT_MODELS:
555
+ if not _groq_clients or time.monotonic() < _groq_disabled_until:
556
+ break
557
+ try:
558
+ return await try_groq(messages, model=model, temperature=temperature, structured=True)
559
+ except Exception as exc:
560
+ logger.warning("Journal model %s failed (%s); trying the next provider.", model, type(exc).__name__)
561
+ raise RuntimeError("No Groq journal model responded.")
562
+
553
563
  # Vision model fallback chain
554
564
  VISION_MODELS = list(dict.fromkeys([
555
565
  GROQ_VISION_MODEL,
@@ -2069,7 +2079,7 @@ def normalize_vision_results(raw: str) -> str:
2069
2079
 
2070
2080
 
2071
2081
  from journal import register_journal, load_syllabus
2072
- register_journal(app, try_groq, try_ollama)
2082
+ register_journal(app, try_journal_cloud, try_ollama)
2073
2083
 
2074
2084
  if __name__ == "__main__":
2075
2085
  # The extension talks to this API through its background worker. Binding to