@tomflow/chatloop-extension 0.3.66 → 0.3.70
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 +6 -0
- package/extension/actions/start.js +4 -1
- package/extension/background.js +78 -5
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,12 @@
|
|
|
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
|
+
|
|
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
|
+
|
|
19
25
|
**验收边界**:离线源码回归不等于已安装 Chrome 真机通过;正式安装包的 Owner、资源配额及受控发送需要独立实测,不能用旧版证据替代。
|
|
20
26
|
|
|
21
27
|
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
|
@@ -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}:{})};
|
|
@@ -485,7 +496,10 @@ async function sessionStartResult(message,sender){
|
|
|
485
496
|
lastStartActionTabId:sender.tab.id,
|
|
486
497
|
reason:confirmed?'':adopted?'ADOPTION_UNVERIFIED':'START_SEND_UNVERIFIED',
|
|
487
498
|
...(!confirmed&&['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
488
|
-
'START_COMPOSER_NOT_EMPTY','FIRST_TURN_OBSERVER_UNAVAILABLE'
|
|
499
|
+
'START_COMPOSER_NOT_EMPTY','FIRST_TURN_OBSERVER_UNAVAILABLE',
|
|
500
|
+
'START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
501
|
+
'START_INPUT_UNVERIFIED','START_INPUT_REJECTED',
|
|
502
|
+
'START_CLICK_UNVERIFIED','FIRST_SEND_RECEIPT_UNKNOWN']
|
|
489
503
|
.includes(message.failureCode)
|
|
490
504
|
?{lastStartFailureCode:message.failureCode}:{}),
|
|
491
505
|
...(confirmed?{tabId:message.newTabId,page:message.newPage,
|
|
@@ -586,7 +600,7 @@ async function startReadinessEvidence(run){
|
|
|
586
600
|
if(!tab||typeof tab.url!=='string'||!tab.url.startsWith('https://chatgpt.com/'))
|
|
587
601
|
return null;
|
|
588
602
|
const result=await Promise.race([
|
|
589
|
-
chrome.scripting.executeScript({target:{tabId:tab.id},func:
|
|
603
|
+
chrome.scripting.executeScript({target:{tabId:tab.id},func:async expectedDigest=>{
|
|
590
604
|
const visible=e=>Boolean(e?.getClientRects?.().length);
|
|
591
605
|
const mains=[...document.querySelectorAll('main')].filter(visible);
|
|
592
606
|
const editors=[...document.querySelectorAll(
|
|
@@ -594,12 +608,48 @@ async function startReadinessEvidence(run){
|
|
|
594
608
|
const editor=editors.find(visible);
|
|
595
609
|
const messages=mains.flatMap(m=>[...m.querySelectorAll(
|
|
596
610
|
'[data-chatgpt-search-message-ids],[data-message-author-role]')]);
|
|
611
|
+
const modern=mains.flatMap(m=>[...m.querySelectorAll(
|
|
612
|
+
'[data-chatgpt-search-unit-key][data-chatgpt-search-message-ids]')]);
|
|
613
|
+
const units=modern.length?modern:messages;
|
|
614
|
+
const role=n=>n.getAttribute('data-message-author-role')
|
|
615
|
+
||n.getAttribute('data-chatgpt-search-unit-key')?.split(':').at(-1);
|
|
616
|
+
const messageId=n=>{
|
|
617
|
+
const id=n.getAttribute('data-message-id')
|
|
618
|
+
||n.getAttribute('data-chatgpt-search-message-ids')?.trim().split(/\s+/)[0];
|
|
619
|
+
return typeof id==='string'&&/^[A-Za-z0-9][A-Za-z0-9._:-]{0,115}$/.test(id)
|
|
620
|
+
?id:null;
|
|
621
|
+
};
|
|
622
|
+
const canonical=v=>String(v||'').replace(/\s+/g,'');
|
|
623
|
+
const users=units.filter(n=>role(n)==='user');
|
|
624
|
+
const assistants=units.filter(n=>role(n)==='assistant');
|
|
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
|
+
}
|
|
638
|
+
const key=(prefix,node)=>node&&messageId(node)?prefix+messageId(node):null;
|
|
597
639
|
return {path:location.pathname,readyState:document.readyState,
|
|
598
640
|
mainCount:mains.length,editorCount:editors.length,
|
|
599
641
|
editorVisible:Boolean(editor),editorEditable:Boolean(editor?.isContentEditable),
|
|
600
642
|
editorEmpty:editor?!(editor.innerText||editor.textContent||'').trim():null,
|
|
601
|
-
messageNodeCount:messages.length
|
|
602
|
-
|
|
643
|
+
messageNodeCount:messages.length,
|
|
644
|
+
// Read-only identity and equality evidence. No message text or send permit.
|
|
645
|
+
userMessageCount:users.length,assistantMessageCount:assistants.length,
|
|
646
|
+
startPromptComparison:comparable?'AVAILABLE':'UNAVAILABLE',
|
|
647
|
+
matchedStartPromptCount:comparable?new Set(matched.map(messageId)).size:null,
|
|
648
|
+
lastUserKey:key('user:',users.at(-1)),
|
|
649
|
+
lastMatchedUserKey:key('user:',matched.at(-1)),
|
|
650
|
+
lastAssistantKey:key('assistant:',assistants.at(-1))};
|
|
651
|
+
},args:[typeof run.startPromptDigest==='string'?run.startPromptDigest:null]
|
|
652
|
+
}).then(rows=>rows?.[0]?.result||null).catch(()=>null),
|
|
603
653
|
new Promise(resolve=>setTimeout(()=>resolve(null),1500))
|
|
604
654
|
]);
|
|
605
655
|
return {tabId:tab.id,confirmed:false,sendReceipt:'UNVERIFIED',
|
|
@@ -1829,6 +1879,29 @@ async function onExtensionCliTarget(message,sender) {
|
|
|
1829
1879
|
return {status:"DENIED",code:"INVALID_EXTENSION_ACTION_SOURCE"};
|
|
1830
1880
|
if(message.action==="reload")return {status:"OK"};
|
|
1831
1881
|
const run=await readRun();
|
|
1882
|
+
// A failed first send has no Chat Owner. Eye may inspect only the exact
|
|
1883
|
+
// unconfirmed tab created by this START, and only after verifying its
|
|
1884
|
+
// original prompt fingerprint. No ownership, recovery or send is granted.
|
|
1885
|
+
if(run?.phase==='BLOCKED'&&run.action==='START'
|
|
1886
|
+
&&run.lastStartFailureCode==='FIRST_SEND_RECEIPT_UNKNOWN'){
|
|
1887
|
+
const evidence=await startReadinessEvidence(run);
|
|
1888
|
+
const observed=evidence?.readiness;
|
|
1889
|
+
if(evidence?.sendReceipt==='UNVERIFIED'
|
|
1890
|
+
&&observed?.startPromptComparison==='AVAILABLE'
|
|
1891
|
+
&&observed.matchedStartPromptCount===1
|
|
1892
|
+
&&observed.userMessageCount>=1
|
|
1893
|
+
&&typeof observed.path==='string'&&observed.path.startsWith('/c/')){
|
|
1894
|
+
const candidate=await chrome.tabs.get(evidence.tabId).catch(()=>null);
|
|
1895
|
+
// pathOf deliberately rejects provisional local-chatgpt paths for
|
|
1896
|
+
// Ownership. Eye instead checks the exact observed HTTPS path only.
|
|
1897
|
+
try {
|
|
1898
|
+
const url=new URL(candidate?.url);
|
|
1899
|
+
if(url.origin==='https://chatgpt.com'&&url.pathname===observed.path)
|
|
1900
|
+
return {status:'OK',tabId:candidate.id,page:observed.path};
|
|
1901
|
+
} catch { /* A changed or malformed tab is not a read target. */ }
|
|
1902
|
+
}
|
|
1903
|
+
return {status:'DENIED',code:'START_EYE_EVIDENCE_UNVERIFIED'};
|
|
1904
|
+
}
|
|
1832
1905
|
// Read-only Eye may inspect the last confirmed terminal Owner while the same
|
|
1833
1906
|
// Chat URL and exact tab still match. This does not reactivate the Loop,
|
|
1834
1907
|
// grant Continue/Handoff permission or select another Chat tab.
|
package/extension/manifest.json
CHANGED