@tomflow/chatloop-extension 0.4.28 → 0.4.29
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.
|
@@ -277,6 +277,10 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
277
277
|
}
|
|
278
278
|
reply({contract:CONTRACT,status:"VERIFIED",page:path,
|
|
279
279
|
userKey,rVersion,pVersion,priorAssistantKey:messageId(pAssistant.el,"assistant"),
|
|
280
|
+
// Ephemeral approval source for Native/Context comparison at permit
|
|
281
|
+
// consumption. Never persisted in Chrome storage, logs or Owner state.
|
|
282
|
+
approvalTurns:{rUserKey:messageId(rUser.el,"user"),
|
|
283
|
+
rUserText:textOf(rUser),pUserText:textOf(pUser)},
|
|
280
284
|
// Idle post-approval assistant was completed BEFORE adoption.
|
|
281
285
|
// This is a historical baseline, never a fresh execution Turn.
|
|
282
286
|
...(scopedIdle?{postApprovalAssistantKey:snap.assistantKey}:{})});
|
package/extension/manifest.json
CHANGED
|
@@ -27,7 +27,7 @@ async function approvedAdoptionTarget(chatUrl=null,taskId=null){
|
|
|
27
27
|
const proof=await chrome.tabs.sendMessage(opened.id,
|
|
28
28
|
{type:"CHAT_LOOP_APPROVAL_EVIDENCE_V1",
|
|
29
29
|
explicitChatId:requestedId,
|
|
30
|
-
...(taskId?{expectedTaskId:taskId}:{})}).catch(()=>null);
|
|
30
|
+
...(!requestedId&&taskId?{expectedTaskId:taskId}:{})}).catch(()=>null);
|
|
31
31
|
if(proof?.contract==="chat-loop.turn-observer.v1"
|
|
32
32
|
&&proof.status==="VERIFIED"
|
|
33
33
|
&&chatIdOf('https://chatgpt.com'+proof.page)===requestedId){
|
|
@@ -199,6 +199,36 @@ async function sessionStartTake(message,sender){
|
|
|
199
199
|
if(!sessionPage(sender,'start',message.requestId)||run?.machineRequestId!==message.requestId
|
|
200
200
|
||run.machineActionTabId!==sender.tab.id||run.token!==message.token
|
|
201
201
|
||run.phase!=='STARTING')return {status:'DENIED',code:'START_OWNER_CHANGED'};
|
|
202
|
+
// Verify the real R/P source again immediately before asking Context to
|
|
203
|
+
// consume the Start lease. Never persist approval text in Worker storage.
|
|
204
|
+
let approvalEvidence=null;
|
|
205
|
+
if(run.contextLeaseRef&&run.mode==='adopt'
|
|
206
|
+
&&run.purpose!=='REPAIR_SAME_SCOPE'){
|
|
207
|
+
const proof=await chrome.tabs.sendMessage(run.adoptTabId,{
|
|
208
|
+
type:'CHAT_LOOP_APPROVAL_EVIDENCE_V1',
|
|
209
|
+
...(run.adoptExplicitChatId?{explicitChatId:run.adoptExplicitChatId}:{}),
|
|
210
|
+
...(run.adoptExpectedTaskId?{expectedTaskId:run.adoptExpectedTaskId}:{})
|
|
211
|
+
}).catch(()=>null);
|
|
212
|
+
const current=policy.normalizeAdoptionEvidence(proof,{page:run.adoptPage});
|
|
213
|
+
const original={page:run.adoptPage,userKey:run.adoptUserKey,
|
|
214
|
+
priorAssistantKey:run.adoptPriorAssistantKey||null,
|
|
215
|
+
postApprovalAssistantKey:run.adoptPostApprovalAssistantKey||null,
|
|
216
|
+
rVersion:run.adoptRVersion,pVersion:run.adoptPVersion};
|
|
217
|
+
const source=proof?.approvalTurns;
|
|
218
|
+
if(!policy.sameAdoptionEvidence(original,current)
|
|
219
|
+
||!source||typeof source.rUserKey!=='string'
|
|
220
|
+
||!/^user:[^\s]{8,}$/.test(source.rUserKey)
|
|
221
|
+
||source.rUserKey===run.adoptUserKey
|
|
222
|
+
||!['rUserText','pUserText'].every(k=>typeof source[k]==='string'
|
|
223
|
+
&&source[k].length>0&&source[k].length<=1000)){
|
|
224
|
+
await saveRun({...run,phase:'BLOCKED',
|
|
225
|
+
reason:'ADOPTION_APPROVAL_SOURCE_UNVERIFIED'});
|
|
226
|
+
return {status:'DENIED',code:'ADOPTION_APPROVAL_SOURCE_UNVERIFIED'};
|
|
227
|
+
}
|
|
228
|
+
approvalEvidence={rUserText:source.rUserText,rUserKey:source.rUserKey,
|
|
229
|
+
rVersion:run.adoptRVersion,pUserText:source.pUserText,
|
|
230
|
+
pUserKey:run.adoptUserKey,pVersion:run.adoptPVersion};
|
|
231
|
+
}
|
|
202
232
|
await saveRun({...run,phase:'PENDING'});
|
|
203
233
|
// Native validates current durable Session and signs the narrow Context IPC.
|
|
204
234
|
// No Context adapter? Legacy Start behavior remains unchanged.
|
|
@@ -208,7 +238,9 @@ async function sessionStartTake(message,sender){
|
|
|
208
238
|
args:{expectedStoreEpoch:run.contextStoreEpoch,writeRequestId:run.token,
|
|
209
239
|
expectedTaskRevision:run.contextTaskRevision,
|
|
210
240
|
expectedApprovalRevision:run.contextApprovalRevision,
|
|
211
|
-
actionToken:run.token,kind:'START',leaseRef:run.contextLeaseRef
|
|
241
|
+
actionToken:run.token,kind:'START',leaseRef:run.contextLeaseRef,
|
|
242
|
+
...(run.mode==='adopt'&&run.purpose!=='REPAIR_SAME_SCOPE'
|
|
243
|
+
?{adopt:true,approvalEvidence}:{})}
|
|
212
244
|
}).catch(()=>null);
|
|
213
245
|
if(allowed?.status!=='OK'||allowed.result?.status!=='PERMITTED'){
|
|
214
246
|
await saveRun({...run,phase:'BLOCKED',reason:'CONTEXT_START_PERMIT_UNVERIFIED'});
|