@tomflow/chatloop-extension 0.3.57 → 0.3.58

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
@@ -58,6 +58,8 @@ Clean 只清空输入框,不发送,不更改 Owner;必须指定精确标
58
58
  **历史 0.3.49 接管候选**:此前用于实现同 Chat adopt;后续版本已演进并发布。最新安装、Owner 与真实验收进度只查 [CURRENT](../../context/CURRENT.md),不要沿用历史‘未发布’结论。
59
59
 
60
60
 
61
+ **可视化消息定位(0.3.58)**:真实 Chat 若因历史片段挂载而无法从当前 DOM 验证最新 BLOCKED Turn,不允许依赖旧消息直接 Continue。正式 Status 仅在真实 Owner tab URL 已核实且为 WAITING_REPLY/BLOCKED 时,于 diagnostics 返回只作定位用的 ownerTabId,绝非发送凭证。只有操作员明确打开原内置 Continue Action 并提供精确 tabId 与 Native 最新 updatedAt(resumeBlockedAt),Worker 才能只读核验原 Session/Chat/generation、BLOCKED 类型、独立故障、精确 tab/URL、正式 Action 来源和 Native CAS;核验通过后**仅由 Action 页**尝试滚动原 Chat 到最新挂载区。不更新 Worker 或 Native 会话状态,不点击提交。随后仍要求原有两次稳定最新 user/assistant 身份、无待审批表单和唯一发送许可;任何滚动/身份/状态不明均 fail-closed。普通 Continue/Handoff 与其它 Chat 不触发此行为,不能以滚动成功宣称业务恢复。
62
+
61
63
  ## 原 Owner 的有界技术恢复
62
64
 
63
65
  Worker仍是唯一发送裁决者,Native会话文件只是带身份校验的持久投影。正式Status返回当前Session/Chat及有限diagnostics(版本、失败码、消息身份、恢复预算、执行时钟),不返回发送token或任务正文;终态BLOCKED的Eye可只读检查同一个已确认Owner,不获得发送权。
@@ -179,6 +179,32 @@ async function retryNativeOnce(target) {
179
179
  });
180
180
  return execution?.result || {status:'UNVERIFIED',reason:'RETRY_RESULT_UNKNOWN'};
181
181
  }
182
+ // Recovery-only UI reveal. A Worker+Native CAS check must grant the exact
183
+ // terminal Owner before this Action can move its viewport. No message is sent.
184
+ async function revealLatestOwnerTurn(tabId, expectedPage) {
185
+ const [execution]=await chrome.scripting.executeScript({
186
+ target:{tabId},
187
+ func: page => {
188
+ if(location.origin!=='https://chatgpt.com'||location.pathname!==page)
189
+ return 'CHAT_PAGE_CHANGED';
190
+ const marks=[...document.querySelectorAll('main [data-chatgpt-search-unit-key]')];
191
+ let ancestor=marks.at(-1);
192
+ if(!ancestor)return 'NO_VISIBLE_TURN';
193
+ while(ancestor){
194
+ const style=getComputedStyle(ancestor);
195
+ if(/^(auto|scroll)$/.test(style.overflowY)
196
+ &&ancestor.scrollHeight-ancestor.clientHeight>24){
197
+ ancestor.scrollTop=ancestor.scrollHeight;
198
+ return 'SCROLLED';
199
+ }
200
+ ancestor=ancestor.parentElement;
201
+ }
202
+ return 'CHAT_SCROLL_CONTAINER_UNVERIFIED';
203
+ },args:[expectedPage]
204
+ });
205
+ if(execution?.result!=='SCROLLED')
206
+ throw Error(execution?.result||'CHAT_SCROLL_UNVERIFIED');
207
+ }
182
208
  async function run() {
183
209
  const params = new URLSearchParams(location.search);
184
210
  const raw = params.get("tabId") || "";
@@ -194,6 +220,18 @@ async function run() {
194
220
  if (!own?.id || own.url !== location.href) throw Error("ACTION_TAB_UNVERIFIED");
195
221
  if (!token) {
196
222
  show("VERIFYING", "手动打开 Continue:核对当前已完成的 Turn,并申请单次发送许可。");
223
+ if(params.has("resumeBlockedAt")){
224
+ // A terminal Chat may be displaying an older virtualized segment. Only
225
+ // the exact operator-acknowledged Native revision can authorize a
226
+ // one-time scroll by this formal Action, before double identity proof.
227
+ const reveal=await chrome.runtime.sendMessage({
228
+ type:"CHAT_LOOP_ACTION_MANUAL_REVEAL_V1",
229
+ tabId,resumeBlockedAt:Number(params.get("resumeBlockedAt"))
230
+ });
231
+ if(reveal?.status!=="OK")throw Error(reveal?.code||"REVEAL_NOT_AUTHORIZED");
232
+ await revealLatestOwnerTurn(tabId,reveal.page);
233
+ await new Promise(resolve=>setTimeout(resolve,400));
234
+ }
197
235
  const prepared = await chrome.runtime.sendMessage({
198
236
  type: "CHAT_LOOP_ACTION_MANUAL_PREPARE_V1", action: "CONTINUE",
199
237
  ...(raw ? {tabId} : {})
@@ -405,7 +405,7 @@ async function sessionStatus(message,sender){
405
405
  const projectContext=disk.contextStatus==='VERIFIED'
406
406
  &&disk.projectContext?.projectId===run.projectId
407
407
  ?disk.projectContext:null;
408
- if(record.activeChatId&&run.phase==='WAITING_REPLY'){
408
+ if(record.activeChatId&&['WAITING_REPLY','BLOCKED'].includes(run.phase)){
409
409
  const tab=await chrome.tabs.get(run.tabId).catch(()=>null);
410
410
  if(!tab||pathOf(tab.url)!==run.page)
411
411
  return {status:'UNVERIFIED',code:'OWNER_TAB_MISSING',session:record};
@@ -415,6 +415,9 @@ async function sessionStatus(message,sender){
415
415
  // usable recovery credential.
416
416
  return {status:'OK',state:run.phase==='BLOCKED'?'BLOCKED':'ACTIVE',session:disk.session,
417
417
  diagnostics:{extensionVersion:chrome.runtime.getManifest?.().version||null,
418
+ // The numeric tab ID is a locator, never a send capability. Expose only
419
+ // for an exactly verified terminal/awaiting Owner, not a guessed tab.
420
+ ownerTabId:['WAITING_REPLY','BLOCKED'].includes(run.phase)?run.tabId:null,
418
421
  reason:run.reason||null,action:run.action||null,
419
422
  userKey:run.userKey||null,assistantKey:run.assistantKey||null,
420
423
  newUserKey:run.newUserKey||null,recoveryAttempts:run.recoveryAttempts||0,
@@ -864,6 +867,38 @@ async function repairUncommittedBlockedRecovery(){
864
867
  await saveRun(restored);
865
868
  return restored;
866
869
  }
870
+ // Only an explicitly opened, existing Continue Action may reveal a
871
+ // scroll-virtualized *terminal Owner* before the normal double Turn check.
872
+ // This grants no send permit and changes neither Worker nor Native state.
873
+ // The Action alone may scroll the verified Chat UI; the Worker never does.
874
+ async function onManualReveal(message,sender) {
875
+ const run=await readRun();
876
+ if(!run?.sessionId||run.phase!=='BLOCKED'||run.reason!=='BLOCKED'
877
+ ||run.action!=='CONTINUE'||run.recoveryProtocol!==1
878
+ ||!(run.recoveryAttempts>0)
879
+ ||run.recoverySourceAssistantKey===run.assistantKey
880
+ ||run.newUserKey!==run.userKey
881
+ ||!Number.isInteger(run.tabId)||message.tabId!==run.tabId
882
+ ||!Number.isSafeInteger(message.resumeBlockedAt)
883
+ ||message.resumeBlockedAt<=0 ||!Number.isInteger(sender.tab?.id))
884
+ return {status:'DENIED',code:'REVEAL_OWNER_UNVERIFIED'};
885
+ let url;
886
+ try{url=new URL(sender.url);}catch{return {status:'DENIED',code:'REVEAL_SOURCE_INVALID'};}
887
+ if(url.origin!==new URL(chrome.runtime.getURL('continue.html')).origin
888
+ ||url.pathname!=='/continue.html'
889
+ ||url.searchParams.size!==2
890
+ ||url.searchParams.get('tabId')!==String(run.tabId)
891
+ ||url.searchParams.get('resumeBlockedAt')!==String(message.resumeBlockedAt))
892
+ return {status:'DENIED',code:'REVEAL_SOURCE_INVALID'};
893
+ const tab=await chrome.tabs.get(run.tabId).catch(()=>null);
894
+ if(!tab||pathOf(tab.url)!==run.page)
895
+ return {status:'DENIED',code:'REVEAL_CHAT_CHANGED'};
896
+ const disk=await chrome.runtime.sendNativeMessage(SESSION_HOST,{op:'session-read'}).catch(()=>null);
897
+ if(disk?.status!=='OK'||!matchesNativeProjection(sessionProjection(run),disk.session)
898
+ ||disk.session.updatedAt!==message.resumeBlockedAt)
899
+ return {status:'DENIED',code:'REVEAL_NATIVE_CAS_UNVERIFIED'};
900
+ return {status:'OK',page:run.page};
901
+ }
867
902
  async function onManualPrepare(message, sender) {
868
903
  const requested = message.action;
869
904
  if (!["CONTINUE", "HANDOFF"].includes(requested)
@@ -1347,6 +1382,7 @@ const SERIAL_ROUTES=new Map([
1347
1382
  ['CHAT_LOOP_TURN_BLOCKED_V1',onTurnBlocked],
1348
1383
  ['CHAT_LOOP_ACTION_TAKE_V1',onTake],
1349
1384
  ['CHAT_LOOP_ACTION_RESULT_V1',onResult],
1385
+ ['CHAT_LOOP_ACTION_MANUAL_REVEAL_V1',onManualReveal],
1350
1386
  ['CHAT_LOOP_ACTION_MANUAL_PREPARE_V1',onManualPrepare],
1351
1387
  ['CHAT_LOOP_MODEL_INTENT_V1',onModelIntent],
1352
1388
  ['CHAT_LOOP_MODEL_INTENT_STATUS_V1',onModelIntentStatus],
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Chat Loop Extension",
4
- "version": "0.3.57",
4
+ "version": "0.3.58",
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.57",
3
+ "version": "0.3.58",
4
4
  "type": "module",
5
5
  "description": "Chat Loop Extension package: nine formal Action pages and its own native CLI bridge",
6
6
  "bin": {