@tomflow/chatloop-extension 0.3.66 → 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 +2 -0
- package/extension/actions/start.js +4 -1
- package/extension/background.js +36 -4
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
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
18
|
|
|
19
|
+
**0.3.67 BLOCKED Start 手动发送只读证据**:针对同一 Session 登记的失败 Start 首页,Extension Status 只读返回用户消息 ID、匹配原 Start 提示词的不同消息 ID 数量、助手消息 ID,以及页面节点状态;不返回聊天正文、不点击、不修改 Chrome Owner,也**不把手动点击/DOM 匹配冒充 Native 已确认发送**。新增输入按钮/点击/首条发送回执等精确故障码,专门用于判断未知发送边界。重复匹配消息明确显示数量,不能自动接管或重试。
|
|
20
|
+
|
|
19
21
|
**验收边界**:离线源码回归不等于已安装 Chrome 真机通过;正式安装包的 Owner、资源配额及受控发送需要独立实测,不能用旧版证据替代。
|
|
20
22
|
|
|
21
23
|
Chrome 扩展(9 个独立 Action,含 Status / Start)及其独立 CLI / Native Messaging Host。执行前先看 Help:
|
|
@@ -217,7 +217,10 @@ async function run(){
|
|
|
217
217
|
// This is diagnostics only; it does NOT authorize a retry or prove a
|
|
218
218
|
// message was never sent. Keep the existing fail-closed Owner semantics.
|
|
219
219
|
const failureCode=['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
220
|
-
'START_COMPOSER_NOT_EMPTY','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']
|
|
221
224
|
.includes(e.message) ? e.message : null;
|
|
222
225
|
await chrome.runtime.sendMessage({type:'CHAT_LOOP_SESSION_START_RESULT_V1',
|
|
223
226
|
requestId:id,token:prepared.token,result:'UNVERIFIED',newTabId:newTab?.id,
|
package/extension/background.js
CHANGED
|
@@ -485,7 +485,10 @@ 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
|
-
'START_COMPOSER_NOT_EMPTY','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']
|
|
489
492
|
.includes(message.failureCode)
|
|
490
493
|
?{lastStartFailureCode:message.failureCode}:{}),
|
|
491
494
|
...(confirmed?{tabId:message.newTabId,page:message.newPage,
|
|
@@ -586,7 +589,7 @@ async function startReadinessEvidence(run){
|
|
|
586
589
|
if(!tab||typeof tab.url!=='string'||!tab.url.startsWith('https://chatgpt.com/'))
|
|
587
590
|
return null;
|
|
588
591
|
const result=await Promise.race([
|
|
589
|
-
chrome.scripting.executeScript({target:{tabId:tab.id},func:
|
|
592
|
+
chrome.scripting.executeScript({target:{tabId:tab.id},func:expectedPrompt=>{
|
|
590
593
|
const visible=e=>Boolean(e?.getClientRects?.().length);
|
|
591
594
|
const mains=[...document.querySelectorAll('main')].filter(visible);
|
|
592
595
|
const editors=[...document.querySelectorAll(
|
|
@@ -594,12 +597,41 @@ async function startReadinessEvidence(run){
|
|
|
594
597
|
const editor=editors.find(visible);
|
|
595
598
|
const messages=mains.flatMap(m=>[...m.querySelectorAll(
|
|
596
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;
|
|
597
622
|
return {path:location.pathname,readyState:document.readyState,
|
|
598
623
|
mainCount:mains.length,editorCount:editors.length,
|
|
599
624
|
editorVisible:Boolean(editor),editorEditable:Boolean(editor?.isContentEditable),
|
|
600
625
|
editorEmpty:editor?!(editor.innerText||editor.textContent||'').trim():null,
|
|
601
|
-
messageNodeCount:messages.length
|
|
602
|
-
|
|
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),
|
|
603
635
|
new Promise(resolve=>setTimeout(()=>resolve(null),1500))
|
|
604
636
|
]);
|
|
605
637
|
return {tabId:tab.id,confirmed:false,sendReceipt:'UNVERIFIED',
|
package/extension/manifest.json
CHANGED