@tomflow/chatloop-extension 0.3.64 → 0.3.66

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 CHANGED
@@ -12,6 +12,10 @@
12
12
 
13
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。
14
14
 
15
+ **0.3.65 Start 只读诊断(源码候选)**:当真实 Chrome Start 创建了首页标签,但返回 `NEW_CHAT_NOT_READY` 时,Status 读取精确 Session 的未确认标签资源;经原 Native Session 一致性校验,仅返回当前 URL 类型、DOM 加载阶段、可见 main 数、输入框数量/可见性/编辑性/空状态及消息节点数量,**不读取消息正文、不点击、不重新发送、不转移 Owner**。此诊断用于区分页面未水合与选择器失效,不能把该状态当作 `NOT_SENT`。专项回归测试对未知 Tab 和跨 Session 标签均拒绝归属。
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
+
15
19
  **验收边界**:离线源码回归不等于已安装 Chrome 真机通过;正式安装包的 Owner、资源配额及受控发送需要独立实测,不能用旧版证据替代。
16
20
 
17
21
  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
- if(!owner)throw Error('CLEAN_MACHINE_TARGET_NOT_OWNED');
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
- return location.origin==='https://chatgpt.com'&&location.pathname==='/'&&mains.length===1
36
- &&visible(editor)&&!(editor.innerText||editor.textContent||'').trim()
37
- &&!mains[0].querySelector('[data-chatgpt-search-message-ids],[data-message-author-role]');
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,8 @@ 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'].includes(e.message) ? e.message : null;
220
+ 'START_COMPOSER_NOT_EMPTY','FIRST_TURN_OBSERVER_UNAVAILABLE']
221
+ .includes(e.message) ? e.message : null;
216
222
  await chrome.runtime.sendMessage({type:'CHAT_LOOP_SESSION_START_RESULT_V1',
217
223
  requestId:id,token:prepared.token,result:'UNVERIFIED',newTabId:newTab?.id,
218
224
  ...(failureCode?{failureCode}:{})}).catch(()=>{});
@@ -485,7 +485,8 @@ 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'].includes(message.failureCode)
488
+ 'START_COMPOSER_NOT_EMPTY','FIRST_TURN_OBSERVER_UNAVAILABLE']
489
+ .includes(message.failureCode)
489
490
  ?{lastStartFailureCode:message.failureCode}:{}),
490
491
  ...(confirmed?{tabId:message.newTabId,page:message.newPage,
491
492
  newUserKey:message.newUserKey}:{attemptedNewTabId:Number.isInteger(message.newTabId)?message.newTabId:null})};
@@ -567,6 +568,44 @@ async function handoffTabEvidence(run){
567
568
  pageState:tab.url==="https://chatgpt.com/"?"BLANK_HOME":"CHANGED_UNVERIFIED",
568
569
  sendReceipt:"UNVERIFIED"};
569
570
  }
571
+ // Read-only diagnosis for a START that created an unconfirmed Chat home.
572
+ // Never infers a send receipt, creates a tab, reads message text, or changes Owner.
573
+ async function startReadinessEvidence(run){
574
+ if(run?.phase!=='BLOCKED'||run.action!=='START'||!run.sessionId
575
+ ||!Number.isSafeInteger(run.attemptedNewTabId))return null;
576
+ const saved=(await chrome.storage.local.get(resources.KEY).catch(()=>null))
577
+ ?.[resources.KEY];
578
+ const candidates=Array.isArray(saved?.entries)?saved.entries.filter(entry=>
579
+ entry?.kind==='chat'&&entry.confirmed===false
580
+ &&entry.sessionId===run.sessionId&&entry.id===run.attemptedNewTabId):[];
581
+ if(candidates.length!==1)return null;
582
+ const tab=await Promise.race([
583
+ chrome.tabs.get(run.attemptedNewTabId).catch(()=>null),
584
+ new Promise(resolve=>setTimeout(()=>resolve(null),1500))
585
+ ]);
586
+ if(!tab||typeof tab.url!=='string'||!tab.url.startsWith('https://chatgpt.com/'))
587
+ return null;
588
+ const result=await Promise.race([
589
+ chrome.scripting.executeScript({target:{tabId:tab.id},func:()=>{
590
+ const visible=e=>Boolean(e?.getClientRects?.().length);
591
+ const mains=[...document.querySelectorAll('main')].filter(visible);
592
+ const editors=[...document.querySelectorAll(
593
+ '[contenteditable="true"][data-composer-markdown],#prompt-textarea[contenteditable="true"]')];
594
+ const editor=editors.find(visible);
595
+ const messages=mains.flatMap(m=>[...m.querySelectorAll(
596
+ '[data-chatgpt-search-message-ids],[data-message-author-role]')]);
597
+ return {path:location.pathname,readyState:document.readyState,
598
+ mainCount:mains.length,editorCount:editors.length,
599
+ editorVisible:Boolean(editor),editorEditable:Boolean(editor?.isContentEditable),
600
+ editorEmpty:editor?!(editor.innerText||editor.textContent||'').trim():null,
601
+ messageNodeCount:messages.length};
602
+ }}).then(rows=>rows?.[0]?.result||null).catch(()=>null),
603
+ new Promise(resolve=>setTimeout(()=>resolve(null),1500))
604
+ ]);
605
+ return {tabId:tab.id,confirmed:false,sendReceipt:'UNVERIFIED',
606
+ pageState:tab.url==='https://chatgpt.com/'?'BLANK_HOME':'CHANGED_UNVERIFIED',
607
+ ...(result&&typeof result.mainCount==='number'?{readiness:result}:{})};
608
+ }
570
609
  async function sessionStatus(message,sender){
571
610
  if(!sessionPage(sender,'status',message.requestId))
572
611
  return {status:'DENIED',code:'INVALID_STATUS_SOURCE'};
@@ -599,9 +638,12 @@ async function sessionStatus(message,sender){
599
638
  // Native's durable CAS revision. Never report a synthetic timestamp as a
600
639
  // usable recovery credential.
601
640
  const tabEvidence=await handoffTabEvidence(run);
641
+ const startEvidence=await startReadinessEvidence(run);
602
642
  return {status:'OK',state:run.phase==='BLOCKED'?'BLOCKED':'ACTIVE',session:disk.session,
603
643
  diagnostics:{extensionVersion:chrome.runtime.getManifest?.().version||null,
604
644
  ...(tabEvidence?{handoffTabEvidence:tabEvidence}:{}),
645
+ ...(startEvidence?{startReadinessEvidence:startEvidence}:{}),
646
+ ...(run.lastStartFailureCode?{lastStartFailureCode:run.lastStartFailureCode}:{}),
605
647
  // The numeric tab ID is a locator, never a send capability. Expose only
606
648
  // for an exactly verified terminal/awaiting Owner, not a guessed tab.
607
649
  ownerTabId:['WAITING_REPLY','BLOCKED'].includes(run.phase)?run.tabId:null,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Chat Loop Extension",
4
- "version": "0.3.64",
4
+ "version": "0.3.66",
5
5
  "description": "Chat Loop browser companion: Eye actions, Turn observer, Continue and Handoff Actions",
6
6
  "permissions": [
7
7
  "activeTab",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/chatloop-extension",
3
- "version": "0.3.64",
3
+ "version": "0.3.66",
4
4
  "type": "module",
5
5
  "description": "Chat Loop Extension package: nine formal Action pages and its own native CLI bridge",
6
6
  "bin": {