@tomflow/chatloop-extension 0.3.65 → 0.3.67
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 +4 -0
- package/extension/actions/clean.js +7 -1
- package/extension/actions/start.js +13 -4
- package/extension/background.js +37 -4
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
**0.3.65 Start 只读诊断(源码候选)**:当真实 Chrome Start 创建了首页标签,但返回 `NEW_CHAT_NOT_READY` 时,Status 读取精确 Session 的未确认标签资源;经原 Native Session 一致性校验,仅返回当前 URL 类型、DOM 加载阶段、可见 main 数、输入框数量/可见性/编辑性/空状态及消息节点数量,**不读取消息正文、不点击、不重新发送、不转移 Owner**。此诊断用于区分页面未水合与选择器失效,不能把该状态当作 `NOT_SENT`。专项回归测试对未知 Tab 和跨 Session 标签均拒绝归属。
|
|
16
16
|
|
|
17
|
+
**0.3.66 Start/清理动作修复(源码候选)**:真实 Chrome `0.3.65` Status 确认失败 Start 的新首页 `mainCount=1/editorVisible=true/editorEditable=true/messageNodeCount=0`,唯一不满足的是 `editorEmpty=false`。新版 Start 会立即返回 `START_COMPOSER_NOT_EMPTY`,不再等待 90s;原 Clean Action 精确允许 `BLOCKED` Start 所登记的未确认首页,在核实同一 tab ID、失败原因和原首页后只清理输入框(不发送、不清理其他 Chat)。专项负例覆盖外来 tab、非终态、缺少失败原因及导航变更,不能自动重发旧 UNKNOWN。
|
|
18
|
+
|
|
19
|
+
**0.3.67 BLOCKED Start 手动发送只读证据**:针对同一 Session 登记的失败 Start 首页,Extension Status 只读返回用户消息 ID、匹配原 Start 提示词的不同消息 ID 数量、助手消息 ID,以及页面节点状态;不返回聊天正文、不点击、不修改 Chrome Owner,也**不把手动点击/DOM 匹配冒充 Native 已确认发送**。新增输入按钮/点击/首条发送回执等精确故障码,专门用于判断未知发送边界。重复匹配消息明确显示数量,不能自动接管或重试。
|
|
20
|
+
|
|
17
21
|
**验收边界**:离线源码回归不等于已安装 Chrome 真机通过;正式安装包的 Owner、资源配额及受控发送需要独立实测,不能用旧版证据替代。
|
|
18
22
|
|
|
19
23
|
Chrome 扩展(9 个独立 Action,含 Status / Start)及其独立 CLI / Native Messaging Host。执行前先看 Help:
|
|
@@ -12,7 +12,13 @@ function targetAuthorized(tab,run,machine,own){
|
|
|
12
12
|
if(tab.id===own.id)throw Error('CLEAN_SELF_TARGET');
|
|
13
13
|
if(machine){
|
|
14
14
|
const owner=run?.tabId===tab.id && tab.url==='https://chatgpt.com'+run?.page;
|
|
15
|
-
|
|
15
|
+
// This exact unconfirmed START home has no Chat Owner yet. The machine
|
|
16
|
+
// may clear its composer only after a terminal readiness failure.
|
|
17
|
+
const failedStartHome=run?.phase==='BLOCKED'&&run.action==='START'
|
|
18
|
+
&&run.attemptedNewTabId===tab.id&&tab.url==='https://chatgpt.com/'
|
|
19
|
+
&&['NEW_CHAT_NOT_READY','START_COMPOSER_NOT_EMPTY']
|
|
20
|
+
.includes(run.lastStartFailureCode);
|
|
21
|
+
if(!owner&&!failedStartHome)throw Error('CLEAN_MACHINE_TARGET_NOT_OWNED');
|
|
16
22
|
if(run && !['DONE','BLOCKED'].includes(run.phase))
|
|
17
23
|
throw Error('CLEAN_ACTIVE_LOOP_DENIED');
|
|
18
24
|
}else{
|
|
@@ -32,10 +32,15 @@ async function newChatReady(id){
|
|
|
32
32
|
const mains=[...document.querySelectorAll('main')].filter(visible);
|
|
33
33
|
const editor=document.querySelector('[contenteditable="true"][data-composer-markdown]')
|
|
34
34
|
||document.querySelector('#prompt-textarea[contenteditable="true"]');
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if(location.origin!=='https://chatgpt.com'||location.pathname!=='/'
|
|
36
|
+
||mains.length!==1||!visible(editor)
|
|
37
|
+
||mains[0].querySelector('[data-chatgpt-search-message-ids],[data-message-author-role]'))
|
|
38
|
+
return false;
|
|
39
|
+
return (editor.innerText||editor.textContent||'').trim()
|
|
40
|
+
?'START_COMPOSER_NOT_EMPTY':true;
|
|
38
41
|
}}),Math.min(1500,deadline-Date.now()));
|
|
42
|
+
if(result?.[0]?.result==='START_COMPOSER_NOT_EMPTY')
|
|
43
|
+
throw Error('START_COMPOSER_NOT_EMPTY');
|
|
39
44
|
if(result?.[0]?.result===true)return;
|
|
40
45
|
}
|
|
41
46
|
await pause(Math.min(420,Math.max(1,deadline-Date.now())));
|
|
@@ -212,7 +217,11 @@ async function run(){
|
|
|
212
217
|
// This is diagnostics only; it does NOT authorize a retry or prove a
|
|
213
218
|
// message was never sent. Keep the existing fail-closed Owner semantics.
|
|
214
219
|
const failureCode=['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
215
|
-
'FIRST_TURN_OBSERVER_UNAVAILABLE'
|
|
220
|
+
'START_COMPOSER_NOT_EMPTY','FIRST_TURN_OBSERVER_UNAVAILABLE',
|
|
221
|
+
'START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
222
|
+
'START_INPUT_UNVERIFIED','START_INPUT_REJECTED',
|
|
223
|
+
'START_CLICK_UNVERIFIED','FIRST_SEND_RECEIPT_UNKNOWN']
|
|
224
|
+
.includes(e.message) ? e.message : null;
|
|
216
225
|
await chrome.runtime.sendMessage({type:'CHAT_LOOP_SESSION_START_RESULT_V1',
|
|
217
226
|
requestId:id,token:prepared.token,result:'UNVERIFIED',newTabId:newTab?.id,
|
|
218
227
|
...(failureCode?{failureCode}:{})}).catch(()=>{});
|
package/extension/background.js
CHANGED
|
@@ -485,7 +485,11 @@ async function sessionStartResult(message,sender){
|
|
|
485
485
|
lastStartActionTabId:sender.tab.id,
|
|
486
486
|
reason:confirmed?'':adopted?'ADOPTION_UNVERIFIED':'START_SEND_UNVERIFIED',
|
|
487
487
|
...(!confirmed&&['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
488
|
-
'FIRST_TURN_OBSERVER_UNAVAILABLE'
|
|
488
|
+
'START_COMPOSER_NOT_EMPTY','FIRST_TURN_OBSERVER_UNAVAILABLE',
|
|
489
|
+
'START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
490
|
+
'START_INPUT_UNVERIFIED','START_INPUT_REJECTED',
|
|
491
|
+
'START_CLICK_UNVERIFIED','FIRST_SEND_RECEIPT_UNKNOWN']
|
|
492
|
+
.includes(message.failureCode)
|
|
489
493
|
?{lastStartFailureCode:message.failureCode}:{}),
|
|
490
494
|
...(confirmed?{tabId:message.newTabId,page:message.newPage,
|
|
491
495
|
newUserKey:message.newUserKey}:{attemptedNewTabId:Number.isInteger(message.newTabId)?message.newTabId:null})};
|
|
@@ -585,7 +589,7 @@ async function startReadinessEvidence(run){
|
|
|
585
589
|
if(!tab||typeof tab.url!=='string'||!tab.url.startsWith('https://chatgpt.com/'))
|
|
586
590
|
return null;
|
|
587
591
|
const result=await Promise.race([
|
|
588
|
-
chrome.scripting.executeScript({target:{tabId:tab.id},func:
|
|
592
|
+
chrome.scripting.executeScript({target:{tabId:tab.id},func:expectedPrompt=>{
|
|
589
593
|
const visible=e=>Boolean(e?.getClientRects?.().length);
|
|
590
594
|
const mains=[...document.querySelectorAll('main')].filter(visible);
|
|
591
595
|
const editors=[...document.querySelectorAll(
|
|
@@ -593,12 +597,41 @@ async function startReadinessEvidence(run){
|
|
|
593
597
|
const editor=editors.find(visible);
|
|
594
598
|
const messages=mains.flatMap(m=>[...m.querySelectorAll(
|
|
595
599
|
'[data-chatgpt-search-message-ids],[data-message-author-role]')]);
|
|
600
|
+
const modern=mains.flatMap(m=>[...m.querySelectorAll(
|
|
601
|
+
'[data-chatgpt-search-unit-key][data-chatgpt-search-message-ids]')]);
|
|
602
|
+
const units=modern.length?modern:messages;
|
|
603
|
+
const role=n=>n.getAttribute('data-message-author-role')
|
|
604
|
+
||n.getAttribute('data-chatgpt-search-unit-key')?.split(':').at(-1);
|
|
605
|
+
const messageId=n=>{
|
|
606
|
+
const id=n.getAttribute('data-message-id')
|
|
607
|
+
||n.getAttribute('data-chatgpt-search-message-ids')?.trim().split(/\s+/)[0];
|
|
608
|
+
return typeof id==='string'&&/^[A-Za-z0-9][A-Za-z0-9._:-]{0,115}$/.test(id)
|
|
609
|
+
?id:null;
|
|
610
|
+
};
|
|
611
|
+
const canonical=v=>String(v||'').replace(/\s+/g,'');
|
|
612
|
+
const users=units.filter(n=>role(n)==='user');
|
|
613
|
+
const assistants=units.filter(n=>role(n)==='assistant');
|
|
614
|
+
const matched=typeof expectedPrompt==='string'&&expectedPrompt.length
|
|
615
|
+
?users.filter(n=>{
|
|
616
|
+
const bubble=n.querySelector('[data-search-result-target]')
|
|
617
|
+
||n.querySelector('[data-user-message-bubble="true"]')||n;
|
|
618
|
+
return messageId(n)&&canonical(bubble.innerText||bubble.textContent)
|
|
619
|
+
===canonical(expectedPrompt);
|
|
620
|
+
}):[];
|
|
621
|
+
const key=(prefix,node)=>node&&messageId(node)?prefix+messageId(node):null;
|
|
596
622
|
return {path:location.pathname,readyState:document.readyState,
|
|
597
623
|
mainCount:mains.length,editorCount:editors.length,
|
|
598
624
|
editorVisible:Boolean(editor),editorEditable:Boolean(editor?.isContentEditable),
|
|
599
625
|
editorEmpty:editor?!(editor.innerText||editor.textContent||'').trim():null,
|
|
600
|
-
messageNodeCount:messages.length
|
|
601
|
-
|
|
626
|
+
messageNodeCount:messages.length,
|
|
627
|
+
// Read-only identity and equality evidence. No message text or send permit.
|
|
628
|
+
userMessageCount:users.length,assistantMessageCount:assistants.length,
|
|
629
|
+
matchedStartPromptCount:new Set(matched.map(messageId)).size,
|
|
630
|
+
lastUserKey:key('user:',users.at(-1)),
|
|
631
|
+
lastMatchedUserKey:key('user:',matched.at(-1)),
|
|
632
|
+
lastAssistantKey:key('assistant:',assistants.at(-1))};
|
|
633
|
+
},args:[typeof run.startPrompt==='string'?run.startPrompt:null]
|
|
634
|
+
}).then(rows=>rows?.[0]?.result||null).catch(()=>null),
|
|
602
635
|
new Promise(resolve=>setTimeout(()=>resolve(null),1500))
|
|
603
636
|
]);
|
|
604
637
|
return {tabId:tab.id,confirmed:false,sendReceipt:'UNVERIFIED',
|
package/extension/manifest.json
CHANGED