webhelm 1.0.29 → 1.0.31
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/package.json
CHANGED
|
@@ -13,6 +13,7 @@ const transitions = new Set([
|
|
|
13
13
|
"CHECKING>SENDING",
|
|
14
14
|
"CHECKING>BLOCKED",
|
|
15
15
|
"SENDING>SENT",
|
|
16
|
+
"SENDING>WAITING",
|
|
16
17
|
"SENDING>UNCERTAIN",
|
|
17
18
|
"UNCERTAIN>SENT",
|
|
18
19
|
"UNCERTAIN>WAITING",
|
|
@@ -99,7 +100,7 @@ export class ChatGPTQueue extends DurableQueueCore {
|
|
|
99
100
|
startSession,
|
|
100
101
|
execSession,
|
|
101
102
|
stopSession,
|
|
102
|
-
intervalMs =
|
|
103
|
+
intervalMs = 10000,
|
|
103
104
|
concurrency = 4,
|
|
104
105
|
leaseSeconds = 120,
|
|
105
106
|
now = () => Date.now() / 1000,
|
|
@@ -304,13 +305,27 @@ export class ChatGPTQueue extends DurableQueueCore {
|
|
|
304
305
|
}
|
|
305
306
|
this.transition(item.id, owner, "CHECKING", "SENDING");
|
|
306
307
|
const receipt = await this._send(item);
|
|
307
|
-
|
|
308
|
+
// These diagnostics are all returned before clicking Send. A safe retry
|
|
309
|
+
// must not block this thread forever as an ambiguous delivery.
|
|
310
|
+
if (["pre_send_gate_not_ready", "send_control_not_found", "thread_redirect_mismatch"]
|
|
311
|
+
.includes(receipt?.diagnostic)) {
|
|
312
|
+
this.transition(item.id, owner, "SENDING", "WAITING", {
|
|
313
|
+
delay: this.intervalMs / 1000,
|
|
314
|
+
receipt: receipt.diagnostic,
|
|
315
|
+
});
|
|
316
|
+
} else if (["send-button-disabled", "user-turn"].includes(receipt?.verified_by)) {
|
|
317
|
+
// A confirmed user turn does not need a fixed 60s same-thread gap.
|
|
318
|
+
// A follow-up is re-probed; RUNNING still blocks overlapping sends.
|
|
319
|
+
this.transition(item.id, owner, "SENDING", "SENT", {
|
|
320
|
+
delay: 0, receipt: receipt.verified_by,
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
// After any unverified click, keep UNCERTAIN until a read-only check
|
|
324
|
+
// proves that the turn is present or absent; never send twice blindly.
|
|
308
325
|
this.transition(item.id, owner, "SENDING", "UNCERTAIN", {
|
|
309
326
|
receipt: receipt?.diagnostic || "missing_user_turn_receipt",
|
|
310
327
|
});
|
|
311
|
-
}
|
|
312
|
-
receipt: "send-button-disabled",
|
|
313
|
-
});}
|
|
328
|
+
}
|
|
314
329
|
} catch (e) {
|
|
315
330
|
const diagnostic = this._safeDiagnostic(e),
|
|
316
331
|
current = this._one("SELECT * FROM turns WHERE id=?", item.id);
|
|
@@ -4,15 +4,14 @@ import { SEND_ENABLED_JS } from "./lifecycle-common.mjs";
|
|
|
4
4
|
/** Source executed inside a caller-owned WebHelm Session, never a separate tab. */
|
|
5
5
|
export function submissionScript(item) {
|
|
6
6
|
const prompt = item.message.slice(0, 120);
|
|
7
|
-
const selectorJS = "(() => {
|
|
7
|
+
const selectorJS = "(() => { const selector=\'button[aria-label=\"Send\"],button[data-testid=\"send-button\"],button[aria-label=\"Send prompt\"],form button[type=\"submit\"]\'; for(const b of document.querySelectorAll(\'[data-webhelm-queue-send]\'))b.removeAttribute(\'data-webhelm-queue-send\'); for(const b of document.querySelectorAll(selector)){if(!b.getClientRects().length||b.disabled||b.getAttribute(\'aria-disabled\')===\'true\')continue;b.setAttribute(\'data-webhelm-queue-send\',\'1\');return \'[data-webhelm-queue-send=\"1\"]\';} return null; })()";
|
|
8
8
|
const userTurnsJS = "(() => [...document.querySelectorAll('h4[data-conversation-role=\"user\"]')].filter(h=>(h.parentElement?.innerText||'').includes(" +
|
|
9
9
|
JSON.stringify(prompt) + ")).length)()";
|
|
10
10
|
return [
|
|
11
11
|
"return await (async()=>{",
|
|
12
12
|
"const gate=await js("+JSON.stringify(PROBE_JS)+");",
|
|
13
|
-
"const
|
|
14
|
-
"
|
|
15
|
-
"if(decodeURIComponent(actualId)!=="+JSON.stringify(item.thread_id)+
|
|
13
|
+
"const actualId=await js("+JSON.stringify("location.pathname.split('/c/')[1]?.split('/')[0]||''")+");",
|
|
14
|
+
"if(actualId!=="+JSON.stringify(item.thread_id)+
|
|
16
15
|
")return {diagnostic:'thread_redirect_mismatch'};",
|
|
17
16
|
"if(gate?.state!=='READY'||!(await js("+JSON.stringify(SEND_ENABLED_JS)+")))",
|
|
18
17
|
" return {diagnostic:'pre_send_gate_not_ready'};",
|