@tomflow/chatloop-extension 0.3.64 → 0.3.65

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,8 @@
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
+
15
17
  **验收边界**:离线源码回归不等于已安装 Chrome 真机通过;正式安装包的 Owner、资源配额及受控发送需要独立实测,不能用旧版证据替代。
16
18
 
17
19
  Chrome 扩展(9 个独立 Action,含 Status / Start)及其独立 CLI / Native Messaging Host。执行前先看 Help:
@@ -567,6 +567,44 @@ async function handoffTabEvidence(run){
567
567
  pageState:tab.url==="https://chatgpt.com/"?"BLANK_HOME":"CHANGED_UNVERIFIED",
568
568
  sendReceipt:"UNVERIFIED"};
569
569
  }
570
+ // Read-only diagnosis for a START that created an unconfirmed Chat home.
571
+ // Never infers a send receipt, creates a tab, reads message text, or changes Owner.
572
+ async function startReadinessEvidence(run){
573
+ if(run?.phase!=='BLOCKED'||run.action!=='START'||!run.sessionId
574
+ ||!Number.isSafeInteger(run.attemptedNewTabId))return null;
575
+ const saved=(await chrome.storage.local.get(resources.KEY).catch(()=>null))
576
+ ?.[resources.KEY];
577
+ const candidates=Array.isArray(saved?.entries)?saved.entries.filter(entry=>
578
+ entry?.kind==='chat'&&entry.confirmed===false
579
+ &&entry.sessionId===run.sessionId&&entry.id===run.attemptedNewTabId):[];
580
+ if(candidates.length!==1)return null;
581
+ const tab=await Promise.race([
582
+ chrome.tabs.get(run.attemptedNewTabId).catch(()=>null),
583
+ new Promise(resolve=>setTimeout(()=>resolve(null),1500))
584
+ ]);
585
+ if(!tab||typeof tab.url!=='string'||!tab.url.startsWith('https://chatgpt.com/'))
586
+ return null;
587
+ const result=await Promise.race([
588
+ chrome.scripting.executeScript({target:{tabId:tab.id},func:()=>{
589
+ const visible=e=>Boolean(e?.getClientRects?.().length);
590
+ const mains=[...document.querySelectorAll('main')].filter(visible);
591
+ const editors=[...document.querySelectorAll(
592
+ '[contenteditable="true"][data-composer-markdown],#prompt-textarea[contenteditable="true"]')];
593
+ const editor=editors.find(visible);
594
+ const messages=mains.flatMap(m=>[...m.querySelectorAll(
595
+ '[data-chatgpt-search-message-ids],[data-message-author-role]')]);
596
+ return {path:location.pathname,readyState:document.readyState,
597
+ mainCount:mains.length,editorCount:editors.length,
598
+ editorVisible:Boolean(editor),editorEditable:Boolean(editor?.isContentEditable),
599
+ editorEmpty:editor?!(editor.innerText||editor.textContent||'').trim():null,
600
+ messageNodeCount:messages.length};
601
+ }}).then(rows=>rows?.[0]?.result||null).catch(()=>null),
602
+ new Promise(resolve=>setTimeout(()=>resolve(null),1500))
603
+ ]);
604
+ return {tabId:tab.id,confirmed:false,sendReceipt:'UNVERIFIED',
605
+ pageState:tab.url==='https://chatgpt.com/'?'BLANK_HOME':'CHANGED_UNVERIFIED',
606
+ ...(result&&typeof result.mainCount==='number'?{readiness:result}:{})};
607
+ }
570
608
  async function sessionStatus(message,sender){
571
609
  if(!sessionPage(sender,'status',message.requestId))
572
610
  return {status:'DENIED',code:'INVALID_STATUS_SOURCE'};
@@ -599,9 +637,12 @@ async function sessionStatus(message,sender){
599
637
  // Native's durable CAS revision. Never report a synthetic timestamp as a
600
638
  // usable recovery credential.
601
639
  const tabEvidence=await handoffTabEvidence(run);
640
+ const startEvidence=await startReadinessEvidence(run);
602
641
  return {status:'OK',state:run.phase==='BLOCKED'?'BLOCKED':'ACTIVE',session:disk.session,
603
642
  diagnostics:{extensionVersion:chrome.runtime.getManifest?.().version||null,
604
643
  ...(tabEvidence?{handoffTabEvidence:tabEvidence}:{}),
644
+ ...(startEvidence?{startReadinessEvidence:startEvidence}:{}),
645
+ ...(run.lastStartFailureCode?{lastStartFailureCode:run.lastStartFailureCode}:{}),
605
646
  // The numeric tab ID is a locator, never a send capability. Expose only
606
647
  // for an exactly verified terminal/awaiting Owner, not a guessed tab.
607
648
  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.65",
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.65",
4
4
  "type": "module",
5
5
  "description": "Chat Loop Extension package: nine formal Action pages and its own native CLI bridge",
6
6
  "bin": {