browser-assistant 2.9.15 → 2.9.17
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/extension/content.js
CHANGED
|
@@ -12,7 +12,7 @@ function mountJournalCountdown(signal) {
|
|
|
12
12
|
function getCountdownLabel() {
|
|
13
13
|
const now = Date.now();
|
|
14
14
|
const path = location.pathname.replace(/\/$/, '');
|
|
15
|
-
const aurora = location.origin === 'https://
|
|
15
|
+
const aurora = location.origin === 'https://sidus.net';
|
|
16
16
|
const visible = timers.filter(timer => timer.deadline > now
|
|
17
17
|
&& (!aurora || (path.startsWith('/modules/reflective-journal/') && timer.path !== path)));
|
|
18
18
|
if (!visible.length)
|
|
@@ -1890,7 +1890,7 @@ function mountJournalCountdown(signal) {
|
|
|
1890
1890
|
}
|
|
1891
1891
|
const requestBody = {
|
|
1892
1892
|
text: `${requestText}\nQuestion format: ${question.type === 'short-answer' ? 'Free response. Return only the exact value to enter in the JSON answer field, without an option label, explanation, or Markdown.' : question.selectionType === 'multiple' ? 'select all that apply; return every correct option as "Option A: ...; Option B: ...".' : 'select one answer.'}\n${question.options.map((option, index) => `${String.fromCharCode(65 + index)}. ${option.text}`).join('\n')}`,
|
|
1893
|
-
...(question.type === 'ordering' ? { text: `${
|
|
1893
|
+
...(question.type === 'ordering' ? { text: `${requestText}\nReorder ALL items. Return the complete permutation as a JSON array of 1-based item numbers in the answer field (example: [2,1,3]). Check every item appears exactly once.\n${question.options.map((option, index) => `${index + 1}. ${option.text}`).join('\n')}` } : {}),
|
|
1894
1894
|
url: window.location.href, practice_type: 'mcq', verify_answer: true,
|
|
1895
1895
|
};
|
|
1896
1896
|
const visuals = window.BrowserAssistantQuestionVisuals;
|
|
@@ -111,7 +111,7 @@ function browserAssistantJournal(global) {
|
|
|
111
111
|
const api = { validate, metadata, fields, pageText, readField, writeField, remainingSeconds };
|
|
112
112
|
if (typeof module !== 'undefined')
|
|
113
113
|
module.exports = api;
|
|
114
|
-
if (!global.document || global.location?.origin !== 'https://
|
|
114
|
+
if (!global.document || global.location?.origin !== 'https://sidus.net')
|
|
115
115
|
return;
|
|
116
116
|
if (!/^\/modules\/reflective-journal\//.test(global.location.pathname))
|
|
117
117
|
return;
|
|
@@ -590,7 +590,7 @@ function browserAssistantJournal(global) {
|
|
|
590
590
|
document.removeEventListener('keydown', shortcutListener, true);
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
|
-
if (typeof window !== 'undefined' && location.origin === 'https://
|
|
593
|
+
if (typeof window !== 'undefined' && location.origin === 'https://sidus.net') {
|
|
594
594
|
const ongoingJournalStartLink = () => {
|
|
595
595
|
const links = [...document.querySelectorAll('a[href*="/modules/reflective-journal/"]')].filter(link => [...(link.closest('tr,[role="row"]')?.querySelectorAll('*') || [])].some(node => /^Ongoing$/i.test(node.textContent.trim())) && link.getClientRects().length
|
|
596
596
|
&& new URL(link.href, location.origin).origin === location.origin
|
|
@@ -645,7 +645,7 @@ if (typeof window !== 'undefined' && location.origin === 'https://admissions.aur
|
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
browserAssistantJournal(typeof window === 'undefined' ? globalThis : window);
|
|
648
|
-
if (typeof window !== 'undefined' && location.origin === 'https://
|
|
648
|
+
if (typeof window !== 'undefined' && location.origin === 'https://sidus.net' && !window.BrowserAssistantJournalBoot) {
|
|
649
649
|
window.BrowserAssistantJournalBoot = true;
|
|
650
650
|
let lastDeadline;
|
|
651
651
|
const storage = window.chrome?.storage?.local;
|
package/extension/manifest.json
CHANGED
package/package.json
CHANGED
package/server/main.py
CHANGED
|
@@ -27,7 +27,8 @@ 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
|
-
ordering_question, solve_sorted_list_merge_order,
|
|
30
|
+
ordering_question, solve_sorted_list_merge_order, solve_stack_empty_order, solve_pseudocode_choice,
|
|
31
|
+
reading_response_constraints,
|
|
31
32
|
VisionRateLimitError, VisionUnconfirmedError)
|
|
32
33
|
|
|
33
34
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
|
@@ -191,7 +192,7 @@ async def lifespan(_app: FastAPI):
|
|
|
191
192
|
client.close()
|
|
192
193
|
|
|
193
194
|
|
|
194
|
-
app = FastAPI(title="Browser Assistant API", version="2.9.
|
|
195
|
+
app = FastAPI(title="Browser Assistant API", version="2.9.17", lifespan=lifespan)
|
|
195
196
|
install_local_guards(app)
|
|
196
197
|
|
|
197
198
|
@app.exception_handler(HTTPException)
|
|
@@ -1329,8 +1330,12 @@ REPAIR MODE:
|
|
|
1329
1330
|
verify_answers = not require_code and (content.verify_answer or content.require_answer_agreement or not FAST_SCAN_MODE)
|
|
1330
1331
|
if ordering and not require_code:
|
|
1331
1332
|
item = solve_sorted_list_merge_order(ordering)
|
|
1333
|
+
provider = 'local merge-step check'
|
|
1334
|
+
if item is None:
|
|
1335
|
+
item = solve_stack_empty_order(ordering)
|
|
1336
|
+
provider = 'local stack empty check'
|
|
1332
1337
|
if item is not None:
|
|
1333
|
-
return {"results": json.dumps([item], ensure_ascii=False), "provider": "
|
|
1338
|
+
return {"results": json.dumps([item], ensure_ascii=False), "provider": f"{provider} [verified]",
|
|
1334
1339
|
"language": language, "answer_verified": True, "code_reviewed": False}
|
|
1335
1340
|
if not require_code and not content.require_answer_agreement and content.practice_type in {'auto', 'mcq', 'math', 'aptitude'}:
|
|
1336
1341
|
local_result = local_choice_result(trimmed_text, language)
|
package/server/vision_images.py
CHANGED
|
@@ -207,6 +207,27 @@ def solve_sorted_list_merge_order(ordering):
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
|
|
210
|
+
def solve_stack_empty_order(ordering):
|
|
211
|
+
if not ordering:
|
|
212
|
+
return None
|
|
213
|
+
prompt, options = ordering
|
|
214
|
+
if not re.fullmatch(r'arrange the steps in the correct order for the (?:stack )?(?:is)?empty\s*\(\s*\) operation[.:]?',
|
|
215
|
+
' '.join(prompt.split()), re.I):
|
|
216
|
+
return None
|
|
217
|
+
empty_test = r'(?:the )?top(?: pointer| index)?\s*(?:is equal to|equals|is|==)\s*-\s*1'
|
|
218
|
+
steps = (rf'check (?:if|whether) {empty_test}', rf'return true if {empty_test}', r'return false otherwise')
|
|
219
|
+
if len(options) != len(steps):
|
|
220
|
+
return None
|
|
221
|
+
normalized = [' '.join(option.split()).lower().replace('−', '-').replace('`', '').rstrip('.') for option in options]
|
|
222
|
+
matches = [[number for number, option in enumerate(normalized, 1) if re.fullmatch(step, option)] for step in steps]
|
|
223
|
+
if any(len(numbers) != 1 for numbers in matches):
|
|
224
|
+
return None
|
|
225
|
+
return {
|
|
226
|
+
'type': 'mcq', 'question': prompt, 'answer': [numbers[0] for numbers in matches],
|
|
227
|
+
'reasoning': 'Check whether top is -1. Return true if it is and return false otherwise.',
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
210
231
|
def ordering_key(value, size):
|
|
211
232
|
if isinstance(value, str):
|
|
212
233
|
try:
|
|
@@ -554,9 +575,9 @@ async def cross_check_text_answers(messages, results, complete, *, question_text
|
|
|
554
575
|
raise VisionUnconfirmedError('Expected one linked answer with displayed options or a reading response format.')
|
|
555
576
|
if step_count:
|
|
556
577
|
check_messages[0]['content'] = (
|
|
557
|
-
'Independently order the displayed steps. Use every
|
|
578
|
+
'Independently order the displayed steps. Use every displayed item number once, check all prerequisite '
|
|
558
579
|
f'relationships, and return only JSON with readable=true and one answers entry with id=1. '
|
|
559
|
-
f'The answer value must be a JSON array of all {step_count}
|
|
580
|
+
f'The answer value must be a JSON array of all {step_count} numbers from the list in this message.'
|
|
560
581
|
)
|
|
561
582
|
elif constraints:
|
|
562
583
|
_, _, keyword = constraints
|
|
@@ -586,10 +607,21 @@ async def cross_check_text_answers(messages, results, complete, *, question_text
|
|
|
586
607
|
first = answer_key(items)
|
|
587
608
|
previous = None
|
|
588
609
|
for attempt in range(2):
|
|
610
|
+
if step_count:
|
|
611
|
+
# A second view with different numbering tests the step order
|
|
612
|
+
# independently of the order in which the page lists the steps.
|
|
613
|
+
prompt, options = ordering
|
|
614
|
+
numbers = (*range(step_count, 0, -1),) if attempt == 0 else (*range(2, step_count + 1), 1)
|
|
615
|
+
if step_count == 2 and attempt == 1:
|
|
616
|
+
numbers = (1, 2)
|
|
617
|
+
rows = '\n'.join(f'{index}. {options[number - 1]}' for index, number in enumerate(numbers, 1))
|
|
618
|
+
check_messages = [check_messages[0], {'role': 'user', 'content': f'{prompt}\n\nNumbered steps:\n{rows}'}]
|
|
589
619
|
raw = await complete(check_messages)
|
|
590
620
|
try:
|
|
591
621
|
verified = parse_answer_check(raw, len(items))
|
|
592
622
|
current = answer_key(verified)
|
|
623
|
+
if step_count and current is not None:
|
|
624
|
+
current = tuple(numbers[index - 1] for index in current)
|
|
593
625
|
except ValueError:
|
|
594
626
|
current = None
|
|
595
627
|
if current is not None and (current == first or current == previous):
|
|
@@ -613,10 +645,11 @@ async def cross_check_text_answers(messages, results, complete, *, question_text
|
|
|
613
645
|
break
|
|
614
646
|
if not attempt:
|
|
615
647
|
previous = current
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
648
|
+
if not step_count:
|
|
649
|
+
check_messages = [*check_messages, {
|
|
650
|
+
'role': 'user',
|
|
651
|
+
'content': 'Solve again using the original question and its context. Return the full verification JSON with the required ids.',
|
|
652
|
+
}]
|
|
620
653
|
# When both independent verifications failed to parse, prefer delivering the
|
|
621
654
|
# primary answer over blocking the automation entirely. The primary solve was
|
|
622
655
|
# validated and the verification provider returned unusable JSON — a parsing
|