@tomflow/chatloop-extension 0.4.23 → 0.4.25
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.
|
@@ -96,7 +96,18 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
96
96
|
return versions.length===1?versions[0]:null;
|
|
97
97
|
};
|
|
98
98
|
const lastUser=rows.findLastIndex(x=>x.role==="user");
|
|
99
|
-
|
|
99
|
+
// ChatGPT can virtualize the initial R issuing assistant while keeping
|
|
100
|
+
// both original Form A user Turns and the issued P assistant mounted.
|
|
101
|
+
// Only an explicitly named current Chat plus the exact Form template
|
|
102
|
+
// may use this bounded partial-DOM proof. A Context Start lease must
|
|
103
|
+
// still independently authorize the R/P approvals and current Task.
|
|
104
|
+
const currentChatId=path.match(/\/c\/([0-9a-f-]{12,})$/i)?.[1].toLowerCase();
|
|
105
|
+
const explicitFormChat=typeof message.explicitChatId==='string'
|
|
106
|
+
&&message.explicitChatId.toLowerCase()===currentChatId;
|
|
107
|
+
const virtualizedR=lastUser===2&&explicitFormChat
|
|
108
|
+
&&rows[0]?.role==='user'&&!!formApprovalVersion(textOf(rows[0]),'R')
|
|
109
|
+
&&rows[1]?.role==='assistant'&&rows[2]?.role==='user';
|
|
110
|
+
if((lastUser<3&&!virtualizedR)||rows[lastUser-1]?.role!=="assistant") {
|
|
100
111
|
fail("APPROVAL_SEQUENCE_UNVERIFIED");return false;
|
|
101
112
|
}
|
|
102
113
|
const pUser=rows[lastUser],pAssistant=rows[lastUser-1];
|
|
@@ -137,6 +148,7 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
137
148
|
?nativeR[1].toUpperCase():null;
|
|
138
149
|
const rAssistant=rIndex>0?rows[rIndex-1]:null;
|
|
139
150
|
if(rIndex<0 || rIndex===0&&!nativeRVersion
|
|
151
|
+
&&!(virtualizedR&&rForm)
|
|
140
152
|
||rIndex>0&&rAssistant?.role!=="assistant"){
|
|
141
153
|
fail("APPROVAL_REQUIREMENTS_MISSING");return false;
|
|
142
154
|
}
|
|
@@ -169,7 +181,8 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
169
181
|
|| !/\bR[1-9][0-9]*\b/i.test(textOf(rAssistant)))) {
|
|
170
182
|
fail("APPROVAL_REQUIREMENTS_MISSING");return false;
|
|
171
183
|
}
|
|
172
|
-
const rVersion=rAssistant?versionOf(textOf(rAssistant),"R")
|
|
184
|
+
const rVersion=rAssistant?versionOf(textOf(rAssistant),"R")
|
|
185
|
+
:nativeRVersion||virtualizedR&&rForm?.version;
|
|
173
186
|
// A stage-02 plan can generate an immutable Rn synchronization SNAPSHOT
|
|
174
187
|
// after its P approval. It is not a new R approval: Context retains the
|
|
175
188
|
// original R/P approvals and exact P.requirementRef. Only a precisely
|
package/extension/manifest.json
CHANGED
|
@@ -47,8 +47,29 @@ async function sessionStartPrepare(message,sender){
|
|
|
47
47
|
const independentTask=Boolean(intent.mode==='adopt'&&intent.contextLeaseRef
|
|
48
48
|
&&intent.taskId && (!prior?.taskId && !prior?.contextManaged
|
|
49
49
|
||prior?.taskId&&prior.taskId!==intent.taskId));
|
|
50
|
+
// A first Adopt that failed BEFORE permit.consume completed has no Chat
|
|
51
|
+
// send, tab binding, or Context writer. A fresh Context lease (which
|
|
52
|
+
// independently requires runRef=null) may replace this exact BLOCKED
|
|
53
|
+
// pre-permit Session at most once for the SAME approved Task. Unknown
|
|
54
|
+
// post-permit / browser outcomes are never eligible for this route.
|
|
55
|
+
const prePermitRecovery=Boolean(prior?.phase==='BLOCKED'
|
|
56
|
+
&&prior.reason==='CONTEXT_START_PERMIT_UNVERIFIED'
|
|
57
|
+
&&prior.action==='START'&&prior.mode==='adopt'
|
|
58
|
+
&&prior.contextLeaseRef&&!prior.prePermitRetryUsed
|
|
59
|
+
&&!prior.contextManaged&&prior.projectId===intent.projectId
|
|
60
|
+
&&prior.taskId===intent.taskId&&intent.mode==='adopt'
|
|
61
|
+
&&intent.contextLeaseRef&&intent.contextLeaseRef!==prior.contextLeaseRef
|
|
62
|
+
&&prior.contextStoreEpoch===intent.contextStoreEpoch
|
|
63
|
+
&&prior.contextTaskRevision===intent.contextTaskRevision
|
|
64
|
+
&&prior.contextApprovalRevision===intent.contextApprovalRevision
|
|
65
|
+
&&prior.tabId===null&&prior.page==='/'&&!prior.newUserKey
|
|
66
|
+
&&!prior.userKey&&!prior.attemptedNewTabId
|
|
67
|
+
&&!!intent.chatUrl&&prior.adoptPage===pathOf(intent.chatUrl)
|
|
68
|
+
&&Number.isInteger(prior.adoptTabId)
|
|
69
|
+
&&typeof prior.adoptUserKey==='string');
|
|
50
70
|
const matchingBlocked=prior?.phase==='BLOCKED' && prior.sessionId===replace
|
|
51
|
-
&& (prior.projectId!==intent.projectId || independentTask
|
|
71
|
+
&& (prior.projectId!==intent.projectId || independentTask
|
|
72
|
+
||prePermitRecovery);
|
|
52
73
|
if(replace&&!matchingBlocked)return {status:'DENIED',code:'BLOCKED_REPLACEMENT_MISMATCH'};
|
|
53
74
|
if(prior&&prior.phase!=='DONE'&&!matchingBlocked)
|
|
54
75
|
return {status:'DENIED',code:'LOOP_ALREADY_ACTIVE'};
|
|
@@ -112,6 +133,7 @@ async function sessionStartPrepare(message,sender){
|
|
|
112
133
|
page:'/',tabId:null,startedAt:Date.now(),
|
|
113
134
|
machineRequestId:message.requestId,machineActionTabId:sender.tab.id,
|
|
114
135
|
...(matchingBlocked?{replacedBlockedSessionId:replace}:{}),
|
|
136
|
+
...(prePermitRecovery?{prePermitRetryUsed:true}:{}),
|
|
115
137
|
...(adoption?{mode:'adopt',adoptTabId:adoption.target.tabId,
|
|
116
138
|
adoptPage:adoption.target.page,adoptUserKey:adoption.target.userKey,
|
|
117
139
|
...((intent.chatUrl||adoption.target.explicitChatId)
|