@tomflow/chatloop-extension 0.3.63 → 0.3.64
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 +3 -1
- package/extension/actions/start.js +29 -15
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
**0.3.62 Handoff 门禁修复(源码候选,未安装)**:Handoff 新 Chat 的只读编辑器就绪等待从历史最长约 234 秒收紧至最多 100×450ms≈45 秒,避免在前置旧 Chat 核验已耗时的情况下撞上 Worker 330 秒未知结果看门狗。编辑器不就绪会以 `NEW_CHAT_NOT_READY` 提交原 Action 的终态 BLOCKED 回执,不点击发送、不重试、不删除已创建的接班标签。已有 Status 只在原 Native/Worker Owner 精确一致且旧 Handoff BLOCKED 时,额外回报从旧 `chat-loop.resources.v1` **纯只读**匹配的 `diagnostics.handoffTabEvidence`(`tabId/recorded/confirmed=false/pageState/sendReceipt=UNVERIFIED`),不触发资源 reconcile、发送或 Owner 变更。候选通过离线单测不代表旧 `ACTION_RESULT_TIMEOUT_UNVERIFIED` 已得到 `NOT_SENT` 证明,旧版会话不自动恢复。
|
|
10
10
|
|
|
11
|
-
**0.3.63 Handoff API
|
|
11
|
+
**0.3.63 Handoff API 悬挂保护(已发行历史版本)**:即使 `chrome.tabs.get` 或仅用于新 Chat 就绪检查的 `chrome.scripting.executeScript` 永不 settle,现有 `waitForNewChat` 也会对只读 probe 设置有界 Promise 竞争与整体 45 秒墙钟上限;任何无法确认准备完成的路径返回 `NEW_CHAT_NOT_READY`,不触发 composer 写入、发送或第二次建 Chat。和 0.3.62 旧本地候选同为未发布候选,本次以 0.3.63 唯一归档继续验收。
|
|
12
|
+
|
|
13
|
+
**0.3.64 Start 只读等待收敛(新增发行候选)**:真实 Chrome 的一次 Start 在先收到失败的替换回执后,Native 却登记了新 Session PENDING、无 Chat ID;后续 330 秒 watchdog 把同一 Start 标成 `ACTION_RESULT_TIMEOUT_UNVERIFIED`。因缺原始用户消息回执,不能断言尚未发送。本版本收敛 Start 新 Chat 的 HOME 检查、编辑器就绪和 Observer 检查:保留超过 35 秒的慢页面能力,整体准备墙钟限约 90 秒;Chrome 只读 Promise 不响应时及时结束为明确故障,严格保留一次建页/一次发送;发送动作及发送后回执仍不自动重试。新增 Chrome 读 API 永不返回的回归反例。此改动不能追认旧 UNKNOWN,也不等于真实 Chrome E2E PASS。
|
|
12
14
|
|
|
13
15
|
**验收边界**:离线源码回归不等于已安装 Chrome 真机通过;正式安装包的 Owner、资源配额及受控发送需要独立实测,不能用旧版证据替代。
|
|
14
16
|
|
|
@@ -2,21 +2,32 @@
|
|
|
2
2
|
// All subsequent turns are owned by the existing Observer / Continue / Handoff flow.
|
|
3
3
|
const info=document.getElementById('details'),label=document.getElementById('status');
|
|
4
4
|
const pause=ms=>new Promise(resolve=>setTimeout(resolve,ms));
|
|
5
|
+
// Timeout only read-only Chrome probes. Never race/retry a composer write or click.
|
|
6
|
+
const boundedRead=(call,ms)=>Promise.race([
|
|
7
|
+
Promise.resolve().then(call).catch(()=>null),
|
|
8
|
+
pause(Math.max(1,ms)).then(()=>null)
|
|
9
|
+
]);
|
|
5
10
|
const show=(s,d)=>{label.textContent=s;info.textContent=d;document.body.dataset.result=s==='SUCCESS'?'success':'error';};
|
|
6
11
|
const host='com.tomflow.chatloop.extension';
|
|
7
12
|
async function waitForHomeUrl(id){
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
const deadline=Date.now()+12_000;
|
|
14
|
+
for(let i=0;i<40 && Date.now()<deadline;i++){
|
|
15
|
+
const tab=await boundedRead(()=>chrome.tabs.get(id),
|
|
16
|
+
Math.min(1200,deadline-Date.now()));
|
|
10
17
|
if(tab?.url==='https://chatgpt.com/')return;
|
|
11
|
-
await pause(250);
|
|
18
|
+
await pause(Math.min(250,Math.max(1,deadline-Date.now())));
|
|
12
19
|
}
|
|
13
20
|
throw Error('START_HOME_URL_UNVERIFIED');
|
|
14
21
|
}
|
|
15
22
|
async function newChatReady(id){
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
// Preserve 35s+ cold hydration but return well before the Worker watchdog.
|
|
24
|
+
// A never-settling Chrome read must not leave Start PENDING indefinitely.
|
|
25
|
+
const deadline=Date.now()+90_000;
|
|
26
|
+
for(let i=0;i<200 && Date.now()<deadline;i++){
|
|
27
|
+
const tab=await boundedRead(()=>chrome.tabs.get(id),
|
|
28
|
+
Math.min(1500,deadline-Date.now()));
|
|
18
29
|
if(tab?.url==='https://chatgpt.com/'){
|
|
19
|
-
const
|
|
30
|
+
const result=await boundedRead(()=>chrome.scripting.executeScript({target:{tabId:id},func:()=>{
|
|
20
31
|
const visible=e=>Boolean(e?.getClientRects?.().length);
|
|
21
32
|
const mains=[...document.querySelectorAll('main')].filter(visible);
|
|
22
33
|
const editor=document.querySelector('[contenteditable="true"][data-composer-markdown]')
|
|
@@ -24,22 +35,25 @@ async function newChatReady(id){
|
|
|
24
35
|
return location.origin==='https://chatgpt.com'&&location.pathname==='/'&&mains.length===1
|
|
25
36
|
&&visible(editor)&&!(editor.innerText||editor.textContent||'').trim()
|
|
26
37
|
&&!mains[0].querySelector('[data-chatgpt-search-message-ids],[data-message-author-role]');
|
|
27
|
-
}}).
|
|
28
|
-
if(
|
|
29
|
-
// A newly opened ChatGPT home may hydrate slowly; never fail at 6 seconds.
|
|
30
|
-
// Security interstitials may outlast 2 minutes; wait up to ~218 seconds without sending.
|
|
38
|
+
}}),Math.min(1500,deadline-Date.now()));
|
|
39
|
+
if(result?.[0]?.result===true)return;
|
|
31
40
|
}
|
|
32
|
-
await pause(420);
|
|
41
|
+
await pause(Math.min(420,Math.max(1,deadline-Date.now())));
|
|
33
42
|
}
|
|
34
43
|
throw Error('NEW_CHAT_NOT_READY');
|
|
35
44
|
}
|
|
36
45
|
async function observerReady(id){
|
|
37
|
-
let proof=await chrome.tabs.sendMessage(id,
|
|
46
|
+
let proof=await boundedRead(()=>chrome.tabs.sendMessage(id,
|
|
47
|
+
{type:'CHAT_LOOP_TURN_OBSERVE_V1'}),3000);
|
|
38
48
|
if(proof?.contract!=='chat-loop.turn-observer.v1'){
|
|
39
|
-
await chrome.scripting.executeScript({
|
|
40
|
-
|
|
49
|
+
const injected=await boundedRead(()=>chrome.scripting.executeScript({
|
|
50
|
+
target:{tabId:id},files:['content.js','loop/observer.js']}),3000);
|
|
51
|
+
if(!injected)throw Error('FIRST_TURN_OBSERVER_UNAVAILABLE');
|
|
52
|
+
proof=await boundedRead(()=>chrome.tabs.sendMessage(id,
|
|
53
|
+
{type:'CHAT_LOOP_TURN_OBSERVE_V1'}),3000);
|
|
41
54
|
}
|
|
42
|
-
if(proof?.contract!=='chat-loop.turn-observer.v1')
|
|
55
|
+
if(proof?.contract!=='chat-loop.turn-observer.v1')
|
|
56
|
+
throw Error('FIRST_TURN_OBSERVER_UNAVAILABLE');
|
|
43
57
|
}
|
|
44
58
|
async function sendFirst(id,text){
|
|
45
59
|
const [clicked]=await chrome.scripting.executeScript({target:{tabId:id},
|
package/extension/manifest.json
CHANGED