@tomflow/chatloop-extension 0.3.67 → 0.3.73
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 +8 -0
- package/extension/actions/start.js +13 -8
- package/extension/background.js +60 -11
- package/extension/loop/observer.js +8 -0
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
|
|
19
19
|
**0.3.67 BLOCKED Start 手动发送只读证据**:针对同一 Session 登记的失败 Start 首页,Extension Status 只读返回用户消息 ID、匹配原 Start 提示词的不同消息 ID 数量、助手消息 ID,以及页面节点状态;不返回聊天正文、不点击、不修改 Chrome Owner,也**不把手动点击/DOM 匹配冒充 Native 已确认发送**。新增输入按钮/点击/首条发送回执等精确故障码,专门用于判断未知发送边界。重复匹配消息明确显示数量,不能自动接管或重试。
|
|
20
20
|
|
|
21
|
+
**0.3.68 Start 原始提示词指纹验收**:修复 0.3.67 的旧会话误判:Start 在写入结果后会删除一次性提示词,旧 Status 因此总显示匹配 0 条。现在 Start 准备阶段仅保留规范化文本的 SHA-256 指纹、后续删除提示词正文;只读 Status 比较同一未确认测试标签里的消息身份与摘要,返回 `startPromptComparison=AVAILABLE/UNAVAILABLE`。没有历史指纹一律显示 `matchedStartPromptCount=null`,不再把缺少证据解释为不匹配,也不据此确认发送、恢复 Owner 或自动重试。新增 SHA 一致性及历史缺失负例。
|
|
22
|
+
|
|
23
|
+
**0.3.70 失败 Start 的只读 Eye 取证(含临时地址严格匹配修正)**:在 `FIRST_SEND_RECEIPT_UNKNOWN` 导致 `BLOCKED` 且 Native 未绑定 Chat Owner 时,原有 `chat_text/chat_dom/chat_screenshot` 只允许检查**同一 Session 资源登记的未确认 Start 标签页**;需原提示词 SHA-256 指纹与恰好一条独立用户消息 ID 匹配,且 DOM 路径和 Chrome 标签 URL 再次一致。其他 Project、未登记资源、重复匹配、页面漂移、来源不符均拒绝。此权限仅用于证据读取,**不更改 Owner、不宣称消息送达、不允许 Continue/Handoff、不重发**。Screenshot Action 会短暂激活该精确标签以取真正的可见 PNG,不新建测试聊天;正式 E2E 必须将页面 Text/DOM/Screenshot 与 Native 和 Trace 一起核对。
|
|
24
|
+
|
|
25
|
+
**0.3.71 账号切换故障诊断**:失败 Start 的精确未确认标签页只读检查 ChatGPT 页面显式账号切换错误,返回 `startReadinessEvidence.readiness.uiErrorCode=ACCOUNT_SWITCHED_RETRY_REQUIRED`。该值只代表页面提示(不泄漏用户正文),不能推定是否已送达,不释放 BLOCKED Owner、不重发或点击重试;没有错误或提示仅在用户消息正文时为 `null`。本地源码通过测试后仍须验证已安装 Chrome Worker 的 Status,未部署不得声称实站通过。
|
|
26
|
+
|
|
27
|
+
**0.3.72 首轮发送回执窗口(源码候选)**:首次点击只执行一次;随后仅做最多 120 秒、最多 200 次的有界只读检查,允许临时 `local-chatgpt` 地址延迟转成正式 `/c/<Chat ID>`,避免旧 90 次约 38 秒窗口过早将慢成功判为 UNKNOWN。`tabs.get` 和 DOM 读取各自有 1.2 秒超时,整体仍低于原 330 秒 Worker 看门狗。窗口结束仍无匹配的正式 Chat ID 与原用户消息身份,必须保持 `FIRST_SEND_RECEIPT_UNKNOWN/BLOCKED`;不会重发、自动刷新或追认旧 Session。
|
|
28
|
+
|
|
21
29
|
**验收边界**:离线源码回归不等于已安装 Chrome 真机通过;正式安装包的 Owner、资源配额及受控发送需要独立实测,不能用旧版证据替代。
|
|
22
30
|
|
|
23
31
|
Chrome 扩展(9 个独立 Action,含 Status / Start)及其独立 CLI / Native Messaging Host。执行前先看 Help:
|
|
@@ -103,12 +103,17 @@ async function sendFirst(id,text){
|
|
|
103
103
|
},args:[text]});
|
|
104
104
|
if(clicked?.result?.clickedOnce!==true)
|
|
105
105
|
throw Error(clicked?.result?.reason||'START_CLICK_UNVERIFIED');
|
|
106
|
-
// Once clicked: read-only receipt
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
// Once clicked: ONLY bounded read-only receipt probes. A provisional
|
|
107
|
+
// local-chatgpt URL can settle late; never retry typing or clicking.
|
|
108
|
+
// Keep even the worst-case read budget below the 330s Worker watchdog,
|
|
109
|
+
// including the preceding 90s cold-page readiness window.
|
|
110
|
+
const deadline=Date.now()+120_000;
|
|
111
|
+
for(let i=0;i<200&&Date.now()<deadline;i++){
|
|
112
|
+
const tab=await boundedRead(()=>chrome.tabs.get(id),
|
|
113
|
+
Math.min(1200,Math.max(1,deadline-Date.now())));
|
|
109
114
|
const page=tab?.url&&new URL(tab.url).pathname;
|
|
110
115
|
if(/^\/c\/[0-9a-f-]{12,}$/i.test(page||'')){
|
|
111
|
-
const
|
|
116
|
+
const rows=await boundedRead(()=>chrome.scripting.executeScript({target:{tabId:id},func:expected=>{
|
|
112
117
|
const visible=e=>Boolean(e?.getClientRects?.().length);
|
|
113
118
|
const mains=[...document.querySelectorAll('main')].filter(visible);
|
|
114
119
|
if(mains.length!==1)return null;
|
|
@@ -124,11 +129,11 @@ async function sendFirst(id,text){
|
|
|
124
129
|
const canonical=v=>String(v||'').replace(/\s+/g,'');
|
|
125
130
|
return id&&canonical(bubble?.innerText||bubble?.textContent)===canonical(expected)
|
|
126
131
|
?{userKey:'user:'+id}:null;
|
|
127
|
-
},args:[text]}).
|
|
128
|
-
if(
|
|
129
|
-
newPage:page,newTabId:id};
|
|
132
|
+
},args:[text]}),Math.min(1200,Math.max(1,deadline-Date.now())));
|
|
133
|
+
if(rows?.[0]?.result?.userKey)return {status:'SENT_CONFIRMED',
|
|
134
|
+
newUserKey:rows[0].result.userKey,newPage:page,newTabId:id};
|
|
130
135
|
}
|
|
131
|
-
await pause(420);
|
|
136
|
+
await pause(Math.min(420,Math.max(1,deadline-Date.now())));
|
|
132
137
|
}
|
|
133
138
|
throw Error('FIRST_SEND_RECEIPT_UNKNOWN');
|
|
134
139
|
}
|
package/extension/background.js
CHANGED
|
@@ -48,6 +48,16 @@ const pathOf = url => {
|
|
|
48
48
|
// create a second Chat because the visible path prefix differs.
|
|
49
49
|
const chatIdOf = url => pathOf(url)?.match(/\/c\/([0-9a-f-]{12,})$/i)?.[1].toLowerCase() || null;
|
|
50
50
|
const readRun = async () => (await chrome.storage.local.get(RUN_KEY))[RUN_KEY] || null;
|
|
51
|
+
// Keep only a fixed-size fingerprint after Start's one-shot prompt is erased.
|
|
52
|
+
// A missing historical fingerprint means NOT_COMPARABLE, not "zero matches".
|
|
53
|
+
async function startPromptFingerprint(prompt) {
|
|
54
|
+
if(typeof prompt!=='string'||!globalThis.crypto?.subtle||
|
|
55
|
+
typeof TextEncoder!=='function')return null;
|
|
56
|
+
const normalized=prompt.replace(/\s+/g,'');
|
|
57
|
+
if(!normalized)return null;
|
|
58
|
+
const digest=await crypto.subtle.digest('SHA-256',new TextEncoder().encode(normalized));
|
|
59
|
+
return Array.from(new Uint8Array(digest),v=>v.toString(16).padStart(2,'0')).join('');
|
|
60
|
+
}
|
|
51
61
|
const windowMsOf = run => Number.isSafeInteger(run?.windowMs) && run.windowMs > 0
|
|
52
62
|
? run.windowMs : RUN_BUDGET_MS;
|
|
53
63
|
const deadlineOf = run => Number.isSafeInteger(run?.startedAt) && run.startedAt > 0
|
|
@@ -381,6 +391,7 @@ async function sessionStartPrepare(message,sender){
|
|
|
381
391
|
return {status:'DENIED',code:'AUTO_HANDOFF_ROUTE_UNSUPPORTED'};
|
|
382
392
|
// The same blocked task may never be replayed implicitly: a replacement
|
|
383
393
|
// requires a new project ID and leaves the old Chat intact for audit.
|
|
394
|
+
const promptDigest=adoption?null:await startPromptFingerprint(intent.prompt);
|
|
384
395
|
const next={sessionId:crypto.randomUUID(),projectId:intent.projectId,
|
|
385
396
|
...(intent.taskId?{taskId:intent.taskId}:{}),
|
|
386
397
|
...(intent.purpose?{purpose:intent.purpose}:{}),
|
|
@@ -404,7 +415,7 @@ async function sessionStartPrepare(message,sender){
|
|
|
404
415
|
...(intent.purpose==='REPAIR_SAME_SCOPE'
|
|
405
416
|
?{repairUserText:adoption.target.repairUserText,
|
|
406
417
|
repairDoneAssistantKey:adoption.target.repairDoneAssistantKey}:{})}
|
|
407
|
-
:{startPrompt:intent.prompt})};
|
|
418
|
+
:{startPrompt:intent.prompt,...(promptDigest?{startPromptDigest:promptDigest}:{})})};
|
|
408
419
|
await saveRun(next); // Reserve BEFORE any new Chrome tab or send.
|
|
409
420
|
return {status:'PREPARED',token:next.token,sessionId:next.sessionId,
|
|
410
421
|
...(next.taskId?{taskId:next.taskId}:{})};
|
|
@@ -589,7 +600,7 @@ async function startReadinessEvidence(run){
|
|
|
589
600
|
if(!tab||typeof tab.url!=='string'||!tab.url.startsWith('https://chatgpt.com/'))
|
|
590
601
|
return null;
|
|
591
602
|
const result=await Promise.race([
|
|
592
|
-
chrome.scripting.executeScript({target:{tabId:tab.id},func:
|
|
603
|
+
chrome.scripting.executeScript({target:{tabId:tab.id},func:async expectedDigest=>{
|
|
593
604
|
const visible=e=>Boolean(e?.getClientRects?.().length);
|
|
594
605
|
const mains=[...document.querySelectorAll('main')].filter(visible);
|
|
595
606
|
const editors=[...document.querySelectorAll(
|
|
@@ -611,26 +622,41 @@ async function startReadinessEvidence(run){
|
|
|
611
622
|
const canonical=v=>String(v||'').replace(/\s+/g,'');
|
|
612
623
|
const users=units.filter(n=>role(n)==='user');
|
|
613
624
|
const assistants=units.filter(n=>role(n)==='assistant');
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
625
|
+
const comparable=typeof expectedDigest==='string'&&/^[a-f0-9]{64}$/.test(expectedDigest)
|
|
626
|
+
&&Boolean(globalThis.crypto?.subtle)&&typeof TextEncoder==='function';
|
|
627
|
+
const matched=[];
|
|
628
|
+
if(comparable)for(const user of users){
|
|
629
|
+
if(!messageId(user))continue;
|
|
630
|
+
const bubble=user.querySelector('[data-search-result-target]')
|
|
631
|
+
||user.querySelector('[data-user-message-bubble="true"]')||user;
|
|
632
|
+
const normalized=canonical(bubble.innerText||bubble.textContent);
|
|
633
|
+
const bytes=new TextEncoder().encode(normalized);
|
|
634
|
+
const hash=await crypto.subtle.digest('SHA-256',bytes);
|
|
635
|
+
const digest=Array.from(new Uint8Array(hash),v=>v.toString(16).padStart(2,'0')).join('');
|
|
636
|
+
if(digest===expectedDigest)matched.push(user);
|
|
637
|
+
}
|
|
621
638
|
const key=(prefix,node)=>node&&messageId(node)?prefix+messageId(node):null;
|
|
639
|
+
// Diagnostic only: an account-switch error can leave a local-chatgpt
|
|
640
|
+
// user bubble visible without any server-confirmed first send.
|
|
641
|
+
// Never infer NOT_SENT or a retry permit from this UI text.
|
|
642
|
+
const switched=/你的账户已切换[。.!!\s]*请重新发送消息|your account (?:has been |was )?switched[.!\s]*please (?:re-?send|send again) (?:your )?message/i;
|
|
643
|
+
const inUserMessage=users.some(n=>switched.test(n.innerText||n.textContent||''));
|
|
644
|
+
const accountSwitchVisible=!inUserMessage&&mains.some(m=>
|
|
645
|
+
switched.test(m.innerText||m.textContent||''));
|
|
622
646
|
return {path:location.pathname,readyState:document.readyState,
|
|
647
|
+
uiErrorCode:accountSwitchVisible?'ACCOUNT_SWITCHED_RETRY_REQUIRED':null,
|
|
623
648
|
mainCount:mains.length,editorCount:editors.length,
|
|
624
649
|
editorVisible:Boolean(editor),editorEditable:Boolean(editor?.isContentEditable),
|
|
625
650
|
editorEmpty:editor?!(editor.innerText||editor.textContent||'').trim():null,
|
|
626
651
|
messageNodeCount:messages.length,
|
|
627
652
|
// Read-only identity and equality evidence. No message text or send permit.
|
|
628
653
|
userMessageCount:users.length,assistantMessageCount:assistants.length,
|
|
629
|
-
|
|
654
|
+
startPromptComparison:comparable?'AVAILABLE':'UNAVAILABLE',
|
|
655
|
+
matchedStartPromptCount:comparable?new Set(matched.map(messageId)).size:null,
|
|
630
656
|
lastUserKey:key('user:',users.at(-1)),
|
|
631
657
|
lastMatchedUserKey:key('user:',matched.at(-1)),
|
|
632
658
|
lastAssistantKey:key('assistant:',assistants.at(-1))};
|
|
633
|
-
},args:[typeof run.
|
|
659
|
+
},args:[typeof run.startPromptDigest==='string'?run.startPromptDigest:null]
|
|
634
660
|
}).then(rows=>rows?.[0]?.result||null).catch(()=>null),
|
|
635
661
|
new Promise(resolve=>setTimeout(()=>resolve(null),1500))
|
|
636
662
|
]);
|
|
@@ -1861,6 +1887,29 @@ async function onExtensionCliTarget(message,sender) {
|
|
|
1861
1887
|
return {status:"DENIED",code:"INVALID_EXTENSION_ACTION_SOURCE"};
|
|
1862
1888
|
if(message.action==="reload")return {status:"OK"};
|
|
1863
1889
|
const run=await readRun();
|
|
1890
|
+
// A failed first send has no Chat Owner. Eye may inspect only the exact
|
|
1891
|
+
// unconfirmed tab created by this START, and only after verifying its
|
|
1892
|
+
// original prompt fingerprint. No ownership, recovery or send is granted.
|
|
1893
|
+
if(run?.phase==='BLOCKED'&&run.action==='START'
|
|
1894
|
+
&&run.lastStartFailureCode==='FIRST_SEND_RECEIPT_UNKNOWN'){
|
|
1895
|
+
const evidence=await startReadinessEvidence(run);
|
|
1896
|
+
const observed=evidence?.readiness;
|
|
1897
|
+
if(evidence?.sendReceipt==='UNVERIFIED'
|
|
1898
|
+
&&observed?.startPromptComparison==='AVAILABLE'
|
|
1899
|
+
&&observed.matchedStartPromptCount===1
|
|
1900
|
+
&&observed.userMessageCount>=1
|
|
1901
|
+
&&typeof observed.path==='string'&&observed.path.startsWith('/c/')){
|
|
1902
|
+
const candidate=await chrome.tabs.get(evidence.tabId).catch(()=>null);
|
|
1903
|
+
// pathOf deliberately rejects provisional local-chatgpt paths for
|
|
1904
|
+
// Ownership. Eye instead checks the exact observed HTTPS path only.
|
|
1905
|
+
try {
|
|
1906
|
+
const url=new URL(candidate?.url);
|
|
1907
|
+
if(url.origin==='https://chatgpt.com'&&url.pathname===observed.path)
|
|
1908
|
+
return {status:'OK',tabId:candidate.id,page:observed.path};
|
|
1909
|
+
} catch { /* A changed or malformed tab is not a read target. */ }
|
|
1910
|
+
}
|
|
1911
|
+
return {status:'DENIED',code:'START_EYE_EVIDENCE_UNVERIFIED'};
|
|
1912
|
+
}
|
|
1864
1913
|
// Read-only Eye may inspect the last confirmed terminal Owner while the same
|
|
1865
1914
|
// Chat URL and exact tab still match. This does not reactivate the Loop,
|
|
1866
1915
|
// grant Continue/Handoff permission or select another Chat tab.
|
|
@@ -559,6 +559,14 @@
|
|
|
559
559
|
fail("APPROVAL_REQUIREMENTS_MISSING");return false;
|
|
560
560
|
}
|
|
561
561
|
const rAssistant=rows[rIndex-1],rUser=rows[rIndex];
|
|
562
|
+
// Only document-level TEST_ONLY markers deny production adoption:
|
|
563
|
+
// normal P plans can legitimately mention test-only scenarios.
|
|
564
|
+
const testOnlyReview=x=>
|
|
565
|
+
/(?:^|\n)\s*(?:#{1,6}\s*|>\s*)?(?:\*\*)?TEST_ONLY(?:\*\*)?(?:\s*$|\s*[/||:]\s*NOT_APPROVED)/mi
|
|
566
|
+
.test(textOf(x));
|
|
567
|
+
if(testOnlyReview(rAssistant)||testOnlyReview(pAssistant)){
|
|
568
|
+
fail("APPROVAL_TEST_ONLY");return false;
|
|
569
|
+
}
|
|
562
570
|
if(!/(?:需求|范围|验收)/.test(textOf(rAssistant))
|
|
563
571
|
|| !/\bR[1-9][0-9]*\b/i.test(textOf(rAssistant))) {
|
|
564
572
|
fail("APPROVAL_REQUIREMENTS_MISSING");return false;
|
package/extension/manifest.json
CHANGED