@tomflow/chatloop-extension 0.4.46 → 0.4.47
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.
|
@@ -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
|
@@ -83,7 +83,8 @@ async function scopedTaskRecoverCancel(message,sender){
|
|
|
83
83
|
if(fresh.runRevision!==stamped.runRevision
|
|
84
84
|
||fresh.run?.recoveryRequestId!==id)
|
|
85
85
|
throw cancelRecoveryFail('SCOPED_CANCEL_RECOVER_WORKER_CHANGED');
|
|
86
|
-
const
|
|
86
|
+
const {cancelReadSourceLost:historicalSourceFailure,...recoverable}=fresh.run;
|
|
87
|
+
const final={...recoverable,phase:'CANCELLED',
|
|
87
88
|
reason:'SESSION_CANCELLED',terminalAt:Date.now(),
|
|
88
89
|
nativeOwnerRevision:result.nativeOwnerRevision,
|
|
89
90
|
contextBindingRevision:result.contextBindingRevision};
|
|
@@ -6,6 +6,7 @@ async function reconcileScopedCancelled(){
|
|
|
6
6
|
const state=await scopedTaskRuns.read();
|
|
7
7
|
const candidates=Object.values(state.items).filter(({run})=>
|
|
8
8
|
run.phase==='BLOCKED'&&run.reason==='SESSION_CANCEL_PENDING'
|
|
9
|
+
&&!run.cancelReadSourceLost
|
|
9
10
|
&&/^[a-f0-9]{32}$/.test(run.cancelRequestId||''));
|
|
10
11
|
const jobs=candidates.map(({run,revision})=>scopedTaskScheduler.perTask(
|
|
11
12
|
run.projectId,run.taskId,async()=>{
|
|
@@ -14,6 +15,7 @@ async function reconcileScopedCancelled(){
|
|
|
14
15
|
if(current.runRevision!==revision
|
|
15
16
|
||s?.phase!=='BLOCKED'
|
|
16
17
|
||s.reason!=='SESSION_CANCEL_PENDING'
|
|
18
|
+
||s.cancelReadSourceLost
|
|
17
19
|
||s.cancelRequestId!==run.cancelRequestId
|
|
18
20
|
||s.sessionId!==run.sessionId
|
|
19
21
|
||s.generation!==run.generation)return;
|
|
@@ -38,6 +40,19 @@ async function reconcileScopedCancelled(){
|
|
|
38
40
|
expectedBindingRevision:s.contextBindingRevision,
|
|
39
41
|
expectedActiveChatUrl:'https://chatgpt.com'+s.page
|
|
40
42
|
}).catch(()=>null);
|
|
43
|
+
// Only a definitive missing/expired signed source is safe to fence.
|
|
44
|
+
// Never release Native Owner or replay Context cancellation.
|
|
45
|
+
if(verified?.status==='FAILED'
|
|
46
|
+
&&['NO_REQUEST','REQUEST_EXPIRED'].includes(verified.code)){
|
|
47
|
+
const fresh=await scopedTaskRuns.get(s.projectId,s.taskId);
|
|
48
|
+
if(fresh.runRevision!==current.runRevision)return;
|
|
49
|
+
await scopedTaskRuns.put({...s,cancelReadSourceLost:{
|
|
50
|
+
code:verified.code,at:Date.now()}},{
|
|
51
|
+
expectedStoreRevision:fresh.storeRevision,
|
|
52
|
+
expectedRunRevision:fresh.runRevision});
|
|
53
|
+
console.warn('TASK_CANCEL_SOURCE_UNAVAILABLE',verified.code);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
41
56
|
if(verified?.status!=='CONFIRMED'
|
|
42
57
|
||verified.scope!=='TASK_SCOPED_CANCELLED_NOT_DELIVERED'
|
|
43
58
|
||verified.readOnly!==true
|