@tomflow/chatloop-extension 0.3.75 → 0.3.77
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.
|
@@ -36,11 +36,18 @@ async function newChatReady(id){
|
|
|
36
36
|
||mains.length!==1||!visible(editor)
|
|
37
37
|
||mains[0].querySelector('[data-chatgpt-search-message-ids],[data-message-author-role]'))
|
|
38
38
|
return false;
|
|
39
|
+
// A visible account-switch notice invalidates the first-send
|
|
40
|
+
// environment. Catch it before any editor mutation or send click.
|
|
41
|
+
const switched=/你的账户已切换[。.!!\s]*请重新发送消息|your account (?:has been |was )?switched[.!\s]*please (?:re-?send|send again) (?:your )?message/i;
|
|
42
|
+
if(switched.test(mains[0].innerText||mains[0].textContent||''))
|
|
43
|
+
return 'START_ACCOUNT_SWITCH_VISIBLE';
|
|
39
44
|
return (editor.innerText||editor.textContent||'').trim()
|
|
40
45
|
?'START_COMPOSER_NOT_EMPTY':true;
|
|
41
46
|
}}),Math.min(1500,deadline-Date.now()));
|
|
42
47
|
if(result?.[0]?.result==='START_COMPOSER_NOT_EMPTY')
|
|
43
48
|
throw Error('START_COMPOSER_NOT_EMPTY');
|
|
49
|
+
if(result?.[0]?.result==='START_ACCOUNT_SWITCH_VISIBLE')
|
|
50
|
+
throw Error('START_ACCOUNT_SWITCH_VISIBLE');
|
|
44
51
|
if(result?.[0]?.result===true)return;
|
|
45
52
|
}
|
|
46
53
|
await pause(Math.min(420,Math.max(1,deadline-Date.now())));
|
|
@@ -73,6 +80,11 @@ async function sendFirst(id,text){
|
|
|
73
80
|
||(editor.innerText||editor.textContent||'').trim()
|
|
74
81
|
||mains[0].querySelector('[data-chatgpt-search-message-ids],[data-message-author-role]'))
|
|
75
82
|
throw Error('START_COMPOSER_UNVERIFIED');
|
|
83
|
+
// Recheck immediately before changing the composer; account
|
|
84
|
+
// identity may have switched after the initial readiness probe.
|
|
85
|
+
const switched=/你的账户已切换[。.!!\s]*请重新发送消息|your account (?:has been |was )?switched[.!\s]*please (?:re-?send|send again) (?:your )?message/i;
|
|
86
|
+
if(switched.test(mains[0].innerText||mains[0].textContent||''))
|
|
87
|
+
throw Error('START_ACCOUNT_SWITCH_VISIBLE');
|
|
76
88
|
const canonical=v=>String(v||'').replace(/\s+/g,'');
|
|
77
89
|
editor.focus();
|
|
78
90
|
if(!document.execCommand('insertText',false,instruction))throw Error('START_INPUT_REJECTED');
|
|
@@ -222,8 +234,8 @@ async function run(){
|
|
|
222
234
|
// This is diagnostics only; it does NOT authorize a retry or prove a
|
|
223
235
|
// message was never sent. Keep the existing fail-closed Owner semantics.
|
|
224
236
|
const failureCode=['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
225
|
-
'START_COMPOSER_NOT_EMPTY','
|
|
226
|
-
'START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
237
|
+
'START_COMPOSER_NOT_EMPTY','START_ACCOUNT_SWITCH_VISIBLE',
|
|
238
|
+
'FIRST_TURN_OBSERVER_UNAVAILABLE','START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
227
239
|
'START_INPUT_UNVERIFIED','START_INPUT_REJECTED',
|
|
228
240
|
'START_CLICK_UNVERIFIED','FIRST_SEND_RECEIPT_UNKNOWN']
|
|
229
241
|
.includes(e.message) ? e.message : null;
|
package/extension/background.js
CHANGED
|
@@ -496,8 +496,8 @@ async function sessionStartResult(message,sender){
|
|
|
496
496
|
lastStartActionTabId:sender.tab.id,
|
|
497
497
|
reason:confirmed?'':adopted?'ADOPTION_UNVERIFIED':'START_SEND_UNVERIFIED',
|
|
498
498
|
...(!confirmed&&['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
499
|
-
'START_COMPOSER_NOT_EMPTY','
|
|
500
|
-
'START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
499
|
+
'START_COMPOSER_NOT_EMPTY','START_ACCOUNT_SWITCH_VISIBLE',
|
|
500
|
+
'FIRST_TURN_OBSERVER_UNAVAILABLE','START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
501
501
|
'START_INPUT_UNVERIFIED','START_INPUT_REJECTED',
|
|
502
502
|
'START_CLICK_UNVERIFIED','FIRST_SEND_RECEIPT_UNKNOWN']
|
|
503
503
|
.includes(message.failureCode)
|
|
@@ -522,6 +522,23 @@
|
|
|
522
522
|
const confirms=(value,type)=>{
|
|
523
523
|
const line=value.replace(/\s+/g," ").trim();
|
|
524
524
|
if(!line||line.length>500)return false;
|
|
525
|
+
// Native R/P review controls send two explicit, task-scoped fields:
|
|
526
|
+
// "TASK|R2-ISSUE:<uuid>|我确认 R2 v2。..." (and likewise P2).
|
|
527
|
+
// Accept only a matching kind+version from a genuine user message,
|
|
528
|
+
// never arbitrary prose containing an approval quote or TEST_ONLY.
|
|
529
|
+
const native=line.match(/^([A-Z][A-Z0-9._:-]{7,120})[||]\s*([RP][1-9][0-9]*)-ISSUE:([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})[||]\s*我确认\s+([RP][1-9][0-9]*)\s+v([1-9][0-9]*)[。.!!]\s*(.{0,320})$/i);
|
|
530
|
+
if(native){
|
|
531
|
+
const declared=native[2].toUpperCase(),approved=native[4].toUpperCase();
|
|
532
|
+
if(declared[0]!==type||declared!==approved
|
|
533
|
+
||Number(declared.slice(1))!==Number(native[5]))return false;
|
|
534
|
+
const note=native[6];
|
|
535
|
+
if(/TEST_ONLY|NOT_APPROVED|只是测试|仅供测试|仅为引用|复制示例|不作为.{0,15}(?:审批|批准)|此确认无效/i.test(note))return false;
|
|
536
|
+
if(type==="R"&&/(?:撤销|拒绝|不批准|不确认|不同意).{0,12}(?:需求|R[1-9][0-9]*)/i.test(note)
|
|
537
|
+
||type==="P"&&/(?:撤销|拒绝|不批准|不确认|不同意).{0,12}(?:方案|计划|P[1-9][0-9]*)/i.test(note)
|
|
538
|
+
||type==="P"&&/(?:不授权|未授权|禁止|不要|不能).{0,15}(?:Start|执行|实施|开始|启动)/i.test(note))
|
|
539
|
+
return false;
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
525
542
|
const target=type==="R"
|
|
526
543
|
? "(?:这份|当前|本版|上述)?(?:需求(?:R[1-9][0-9]*)?|R[1-9][0-9]*)"
|
|
527
544
|
: "(?:这份|当前|本版|上述)?(?:方案(?:与|及|和)?计划|实施计划|方案|计划|P[1-9][0-9]*)(?:P[1-9][0-9]*)?";
|
package/extension/manifest.json
CHANGED