@tomflow/chatloop-extension 0.4.44 → 0.4.45
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
|
@@ -114,6 +114,7 @@ handlers and existing trust boundaries. New send/Owner/Native mutation
|
|
|
114
114
|
requires a separate authorized security review and implementation; it cannot
|
|
115
115
|
be enabled by dropping in a capability file. Browser read actions never
|
|
116
116
|
clear an unknown send result or adopt a different Chat Owner.
|
|
117
|
+
When a separate Task is frozen by a pending cancel, TEST_ONLY entry may proceed only after the Worker and Native both prove BLOCKED for the exact Task/Session, the original Chat tab is absent, and two reads confirm the Native fence is unchanged; the frozen Task, bound Context Writer and recovery request remain untouched. Unverified or live send-capable Owners still deny the test entry.
|
|
117
118
|
Screenshot uses Chrome `captureVisibleTab` with the existing per-tab user
|
|
118
119
|
invocation (`activeTab`) or already granted capture permission; opening an
|
|
119
120
|
Action page programmatically does not itself grant this permission. Missing
|
|
@@ -51,7 +51,7 @@ async function run(){
|
|
|
51
51
|
||acquired.action!=='session'||typeof acquired.nonce!=='string'
|
|
52
52
|
||acquired.intent?.operation!==operation)
|
|
53
53
|
throw Error(acquired?.code||'SESSION_INTENT_UNVERIFIED');
|
|
54
|
-
let result;
|
|
54
|
+
let result,dispatched=false;
|
|
55
55
|
try{
|
|
56
56
|
if(operation!=='cancel')await confirmRecoveryClick(acquired.intent);
|
|
57
57
|
show('RUNNING',operation==='cancel'
|
|
@@ -59,6 +59,7 @@ async function run(){
|
|
|
59
59
|
:operation==='recover-cancel'
|
|
60
60
|
?'核验旧取消请求和已冻结 Owner,完成 Context 围栏;不会发送消息…'
|
|
61
61
|
:'核验原 Handoff 未发送证据及一次性恢复许可;不会发送消息…');
|
|
62
|
+
dispatched=true;
|
|
62
63
|
result=await chrome.runtime.sendMessage({
|
|
63
64
|
type:operation==='recover-cancel'
|
|
64
65
|
?'CHAT_LOOP_TASK_CANCEL_RECOVER_V2'
|
|
@@ -86,7 +87,7 @@ async function run(){
|
|
|
86
87
|
// retry a mutation; the original request and persisted receipt are proof.
|
|
87
88
|
const raw=error?.message;
|
|
88
89
|
const code=/^[A-Z][A-Z0-9_]{1,95}$/.test(raw||'')?raw:'SESSION_ACTION_UNVERIFIED';
|
|
89
|
-
if(operation!=='cancel'){
|
|
90
|
+
if(operation!=='cancel'&&dispatched){
|
|
90
91
|
// A permit/bind/Native CAS may already have committed. Never seal
|
|
91
92
|
// an ambiguous recovery as a definitive FAILED Action receipt:
|
|
92
93
|
// preserve this exact signed request for read-only reconciliation.
|
|
@@ -97,9 +98,9 @@ async function run(){
|
|
|
97
98
|
op:'complete',id,nonce:acquired.nonce,action:'session',
|
|
98
99
|
status:'FAILED',code
|
|
99
100
|
}).catch(()=>null);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const saved=receipt?.status==='SAVED'&&receipt.id===id;
|
|
102
|
+
show('BLOCKED',saved?code:code+';终态回执未核实,仅核查原请求。');
|
|
103
|
+
if(saved)await chrome.tabs.remove(own.id).catch(()=>{});
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
void run().catch(e=>show('UNVERIFIED',
|
package/extension/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// TEST_ONLY new-Chat entry never takes an Owner or sends through an existing
|
|
2
|
+
// Task. A frozen cancel is a non-sending fence, not a global Chat monopoly.
|
|
3
|
+
// Verify Native/Worker and the absence of the old Chat before admitting a
|
|
4
|
+
// distinct native @ App first turn; do not unblock or touch the frozen Task.
|
|
5
5
|
async function verifiedScopedEntryAdmission(){
|
|
6
6
|
if(!scopedTaskRuns)return {status:'DENIED',code:'ENTRY_TEST_SCOPED_STORE_MISSING'};
|
|
7
7
|
const legacy=await readRun();
|
|
@@ -13,13 +13,28 @@ async function verifiedScopedEntryAdmission(){
|
|
|
13
13
|
.filter(run=>!['DONE','CANCELLED'].includes(run.phase));
|
|
14
14
|
if(!active.length||active.length>32)
|
|
15
15
|
return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_UNVERIFIED'};
|
|
16
|
+
const frozenProofs=[];
|
|
16
17
|
for(const run of active){
|
|
17
|
-
if(run.
|
|
18
|
-
||typeof run.
|
|
18
|
+
if(typeof run.projectId!=='string'||typeof run.taskId!=='string'
|
|
19
|
+
||typeof run.sessionId!=='string'
|
|
19
20
|
||!Number.isSafeInteger(run.generation)||run.generation<0
|
|
20
21
|
||!Number.isSafeInteger(run.nativeOwnerRevision)
|
|
21
22
|
||run.nativeOwnerRevision<1)
|
|
22
23
|
return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_UNVERIFIED'};
|
|
24
|
+
const frozen=run.phase==='BLOCKED'
|
|
25
|
+
&&run.reason==='SESSION_CANCEL_PENDING'
|
|
26
|
+
&&/^[a-f0-9]{32}$/.test(run.cancelRequestId||'')
|
|
27
|
+
&&Number.isSafeInteger(run.contextBindingRevision)
|
|
28
|
+
&&run.contextBindingRevision>0
|
|
29
|
+
&&!run.modelIntent&&!run.nextAttempt&&!run.lastIntentReceipt
|
|
30
|
+
&&!run.handoffFence
|
|
31
|
+
&&Number.isSafeInteger(run.tabId)&&run.tabId>0
|
|
32
|
+
&&typeof run.page==='string'
|
|
33
|
+
&&pathOf('https://chatgpt.com'+run.page)===run.page
|
|
34
|
+
&&typeof run.ownerChatId==='string'
|
|
35
|
+
&&chatIdOf('https://chatgpt.com'+run.page)===run.ownerChatId;
|
|
36
|
+
if(run.phase!=='WAITING_REPLY'&&!frozen)
|
|
37
|
+
return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_UNVERIFIED'};
|
|
23
38
|
const args={projectId:run.projectId,taskId:run.taskId,
|
|
24
39
|
sessionId:run.sessionId,generation:run.generation};
|
|
25
40
|
const native=await chrome.runtime.sendNativeMessage(SESSION_HOST,{
|
|
@@ -28,9 +43,27 @@ async function verifiedScopedEntryAdmission(){
|
|
|
28
43
|
if(native?.status!=='OK'||native.scope!=='TASK_SCOPED_SNAPSHOT'
|
|
29
44
|
||s?.projectId!==run.projectId||s.taskId!==run.taskId
|
|
30
45
|
||s.sessionId!==run.sessionId||s.generation!==run.generation
|
|
31
|
-
||s.phase!=='WAITING_REPLY'||s.revision!==run.nativeOwnerRevision
|
|
32
46
|
||typeof s.activeChatId!=='string'
|
|
33
|
-
||s.activeChatId!==run.ownerChatId
|
|
47
|
+
||s.activeChatId!==run.ownerChatId
|
|
48
|
+
||pathOf(s.activeChatUrl)!==run.page)
|
|
49
|
+
return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_MISMATCH'};
|
|
50
|
+
if(frozen){
|
|
51
|
+
// The first Native cancel CAS may advance exactly one revision while
|
|
52
|
+
// Worker retains its pre-cancel snapshot. Both MUST be BLOCKED.
|
|
53
|
+
if(s.phase!=='BLOCKED'
|
|
54
|
+
||![run.nativeOwnerRevision,run.nativeOwnerRevision+1]
|
|
55
|
+
.includes(s.revision))
|
|
56
|
+
return {status:'DENIED',code:'ENTRY_TEST_FROZEN_OWNER_MISMATCH'};
|
|
57
|
+
const tabs=await chrome.tabs.query({url:'https://chatgpt.com/*'})
|
|
58
|
+
.catch(()=>null);
|
|
59
|
+
if(!Array.isArray(tabs)
|
|
60
|
+
||tabs.some(tab=>tab.id===run.tabId
|
|
61
|
+
||chatIdOf(tab.url)===run.ownerChatId))
|
|
62
|
+
return {status:'DENIED',code:'ENTRY_TEST_FROZEN_CHAT_PRESENT'};
|
|
63
|
+
frozenProofs.push({args,revision:s.revision,phase:s.phase});
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if(s.phase!=='WAITING_REPLY'||s.revision!==run.nativeOwnerRevision)
|
|
34
67
|
return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_MISMATCH'};
|
|
35
68
|
const writer=await chrome.runtime.sendNativeMessage(SESSION_HOST,{
|
|
36
69
|
op:'context-writer-check-v2',...args,
|
|
@@ -45,9 +78,31 @@ async function verifiedScopedEntryAdmission(){
|
|
|
45
78
|
const current=Object.values(reread.items).map(x=>x.run)
|
|
46
79
|
.filter(run=>!['DONE','CANCELLED'].includes(run.phase));
|
|
47
80
|
const identity=run=>[run.projectId,run.taskId,run.sessionId,
|
|
48
|
-
run.generation,run.nativeOwnerRevision,run.phase,run.
|
|
81
|
+
run.generation,run.nativeOwnerRevision,run.phase,run.reason,
|
|
82
|
+
run.cancelRequestId,run.ownerChatId,run.tabId].join('|');
|
|
49
83
|
if(current.length!==active.length
|
|
50
84
|
||current.some((run,i)=>identity(run)!==identity(active[i])))
|
|
51
85
|
return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_CHANGED'};
|
|
52
|
-
|
|
86
|
+
// Recheck each frozen Native fence after async Chrome/Context queries.
|
|
87
|
+
// Reopening the old Chat or unfreezing Native while checking fails closed.
|
|
88
|
+
for(const proof of frozenProofs){
|
|
89
|
+
const native=await chrome.runtime.sendNativeMessage(SESSION_HOST,{
|
|
90
|
+
op:'session-snapshot-v2',...proof.args}).catch(()=>null);
|
|
91
|
+
if(native?.status!=='OK'||native.scope!=='TASK_SCOPED_SNAPSHOT'
|
|
92
|
+
||native.session?.revision!==proof.revision
|
|
93
|
+
||native.session.phase!=='BLOCKED')
|
|
94
|
+
return {status:'DENIED',code:'ENTRY_TEST_FROZEN_OWNER_CHANGED'};
|
|
95
|
+
}
|
|
96
|
+
if(frozenProofs.length){
|
|
97
|
+
const tabs=await chrome.tabs.query({url:'https://chatgpt.com/*'})
|
|
98
|
+
.catch(()=>null);
|
|
99
|
+
if(!Array.isArray(tabs)
|
|
100
|
+
||active.filter(run=>run.phase==='BLOCKED').some(run=>
|
|
101
|
+
tabs.some(tab=>tab.id===run.tabId
|
|
102
|
+
||chatIdOf(tab.url)===run.ownerChatId)))
|
|
103
|
+
return {status:'DENIED',code:'ENTRY_TEST_FROZEN_CHAT_PRESENT'};
|
|
104
|
+
}
|
|
105
|
+
return {status:'OK',scope:'TEST_ONLY',mode:frozenProofs.length
|
|
106
|
+
?'FROZEN_OWNER_FENCED_DISTINCT_CHAT'
|
|
107
|
+
:'VERIFIED_SCOPED_OWNER_DISTINCT_CHAT'};
|
|
53
108
|
}
|