browser-assistant 2.9.29 → 2.9.30
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 +22 -7
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
- package/server/main.py +1 -1
package/extension/content.js
CHANGED
|
@@ -518,7 +518,8 @@ function mountJournalCountdown(signal) {
|
|
|
518
518
|
if (question.compoundQuestions) {
|
|
519
519
|
return { ...question, signature: JSON.stringify([question.type,
|
|
520
520
|
question.compoundSubmit ? question.compoundContext : '',
|
|
521
|
-
question.compoundQuestions.map(group => [group.
|
|
521
|
+
question.compoundQuestions.map(group => [group.selectionType, group.identityText || group.text,
|
|
522
|
+
group.options.map(option => option.identityText || option.text)]),
|
|
522
523
|
]) };
|
|
523
524
|
}
|
|
524
525
|
if (question.type !== 'short-answer' && question.options.length < 2)
|
|
@@ -862,7 +863,7 @@ function mountJournalCountdown(signal) {
|
|
|
862
863
|
throw new Error('Target policy does not permit submission on this page.');
|
|
863
864
|
}
|
|
864
865
|
const fresh = getAuthorizedQuestion(context);
|
|
865
|
-
if (fresh && (fresh.signature !== question.signature || fresh.selectionType !== question.selectionType)) {
|
|
866
|
+
if (fresh && (fresh.signature !== question.signature || (!linkedAnswers && fresh.selectionType !== question.selectionType))) {
|
|
866
867
|
throw new Error('Question changed before submission. No Submit was clicked.');
|
|
867
868
|
}
|
|
868
869
|
if (adapter.isSaving?.(document)) {
|
|
@@ -899,7 +900,9 @@ function mountJournalCountdown(signal) {
|
|
|
899
900
|
function linkedAnswerMatches(group, answer) {
|
|
900
901
|
if (group.input)
|
|
901
902
|
return !group.input.disabled && !group.input.readOnly && group.input.value === answer;
|
|
902
|
-
|
|
903
|
+
const indexes = group.selectionType === 'multiple' ? (Array.isArray(answer) ? answer : [])
|
|
904
|
+
: (typeof answer === 'number' ? [answer] : []);
|
|
905
|
+
return indexes.length > 0 && !group.options.some(option => option.disabled) && selectionMatches(group, indexes);
|
|
903
906
|
}
|
|
904
907
|
function fillPracticeField(field, value) {
|
|
905
908
|
const prototype = field.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
@@ -1619,8 +1622,10 @@ function mountJournalCountdown(signal) {
|
|
|
1619
1622
|
automation.state = 'SOLVING';
|
|
1620
1623
|
updateAutomationUI();
|
|
1621
1624
|
const keyword = question.requiredWord;
|
|
1625
|
+
const multiple = question.selectionType === 'multiple';
|
|
1626
|
+
const choiceFormat = multiple ? 'Select ALL correct options.' : 'Question format: select one answer.';
|
|
1622
1627
|
const format = freeResponse ? (keyword ? `Question format: 2 to 5 words including the given word ${keyword}.` : 'Question format: one word.')
|
|
1623
|
-
:
|
|
1628
|
+
: `${choiceFormat}\n${question.options.map((option, index) => `${String.fromCharCode(65 + index)}. ${option.text}`).join('\n')}`;
|
|
1624
1629
|
const prompt = `Reading context:\n${compound.compoundContext || ''}\n\nAnswer only this question: ${question.text}\n${format}`;
|
|
1625
1630
|
const response = await window.BrowserAssistantAnswerRequests.run({
|
|
1626
1631
|
request: () => apiRequest('/solve', 'POST', {
|
|
@@ -1640,6 +1645,8 @@ function mountJournalCountdown(signal) {
|
|
|
1640
1645
|
return null;
|
|
1641
1646
|
if (response.data?.answer_agreement !== true)
|
|
1642
1647
|
throw new Error('Update and restart the Browser Assistant backend to verify linked answers.');
|
|
1648
|
+
if (multiple && response.data.selection_set_verified !== true)
|
|
1649
|
+
throw new Error('The complete linked checkbox answer could not be verified.');
|
|
1643
1650
|
let results;
|
|
1644
1651
|
try {
|
|
1645
1652
|
results = JSON.parse(response.data.results);
|
|
@@ -1662,9 +1669,10 @@ function mountJournalCountdown(signal) {
|
|
|
1662
1669
|
}
|
|
1663
1670
|
else {
|
|
1664
1671
|
const indexes = answerIndexesFromResult(results, question);
|
|
1665
|
-
if (indexes.length !== 1)
|
|
1672
|
+
if (!indexes.length || (!multiple && indexes.length !== 1)) {
|
|
1666
1673
|
throw new Error('The verified answer did not match this linked question’s displayed options.');
|
|
1667
|
-
|
|
1674
|
+
}
|
|
1675
|
+
answers.push(multiple ? indexes : indexes[0]);
|
|
1668
1676
|
}
|
|
1669
1677
|
}
|
|
1670
1678
|
automation.error = '';
|
|
@@ -1680,8 +1688,15 @@ function mountJournalCountdown(signal) {
|
|
|
1680
1688
|
if (question.input.value !== answer)
|
|
1681
1689
|
fillPracticeField(question.input, answer);
|
|
1682
1690
|
}
|
|
1691
|
+
else if (Array.isArray(answer)) {
|
|
1692
|
+
for (const [index, option] of question.options.entries()) {
|
|
1693
|
+
if (Boolean(option.isSelected?.() || option.input?.checked) !== answer.includes(index)) {
|
|
1694
|
+
(option.input || option.control)?.click();
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1683
1698
|
else {
|
|
1684
|
-
const option = question.options[answer];
|
|
1699
|
+
const option = question.options[Number(answer)];
|
|
1685
1700
|
if (!(option.isSelected?.() || option.input?.checked))
|
|
1686
1701
|
(option.input || option.control)?.click();
|
|
1687
1702
|
}
|
package/extension/manifest.json
CHANGED
package/package.json
CHANGED
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.
|
|
198
|
+
app = FastAPI(title="Browser Assistant API", version="2.9.30", lifespan=lifespan)
|
|
199
199
|
install_local_guards(app)
|
|
200
200
|
|
|
201
201
|
@app.exception_handler(HTTPException)
|