@tomflow/chatloop-extension 0.4.21 → 0.4.22
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/extension/loop/core.js
CHANGED
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
||proof.status!=='VERIFIED'
|
|
81
81
|
||typeof proof.page!=='string'
|
|
82
82
|
||pathOf('https://chatgpt.com'+proof.page)!==proof.page
|
|
83
|
-
||!/^user:[
|
|
83
|
+
||!/^user:[^\s]{8,}$/.test(proof.userKey||'')
|
|
84
84
|
||!/^R[1-9][0-9]*$/.test(proof.rVersion||'')
|
|
85
85
|
||!/^P[1-9][0-9]*$/.test(proof.pVersion||''))
|
|
86
86
|
return null;
|
package/extension/manifest.json
CHANGED
|
@@ -41,8 +41,14 @@ async function sessionStartPrepare(message,sender){
|
|
|
41
41
|
|| prior.phase==='DONE'&&!terminalFenceVerified(prior)))
|
|
42
42
|
return {status:'DENIED',code:'CONTEXT_TERMINAL_FENCE_UNVERIFIED'};
|
|
43
43
|
const replace=intent.replaceBlockedSessionId||null;
|
|
44
|
+
// Project is shared context, not Task identity. Same-Project replacement
|
|
45
|
+
// requires a freshly approved, Context-backed Adopt into a distinct Task.
|
|
46
|
+
// Legacy sessions without taskId can only yield to that verified new Task.
|
|
47
|
+
const independentTask=Boolean(intent.mode==='adopt'&&intent.contextLeaseRef
|
|
48
|
+
&&intent.taskId && (!prior?.taskId && !prior?.contextManaged
|
|
49
|
+
||prior?.taskId&&prior.taskId!==intent.taskId));
|
|
44
50
|
const matchingBlocked=prior?.phase==='BLOCKED' && prior.sessionId===replace
|
|
45
|
-
&& prior.projectId!==intent.projectId;
|
|
51
|
+
&& (prior.projectId!==intent.projectId || independentTask);
|
|
46
52
|
if(replace&&!matchingBlocked)return {status:'DENIED',code:'BLOCKED_REPLACEMENT_MISMATCH'};
|
|
47
53
|
if(prior&&prior.phase!=='DONE'&&!matchingBlocked)
|
|
48
54
|
return {status:'DENIED',code:'LOOP_ALREADY_ACTIVE'};
|
|
@@ -80,6 +86,8 @@ async function sessionStartPrepare(message,sender){
|
|
|
80
86
|
:await approvedAdoptionTarget(intent.chatUrl||null,
|
|
81
87
|
intent.contextLeaseRef?intent.taskId:null):null;
|
|
82
88
|
if(adoption?.error)return {status:'DENIED',code:adoption.error};
|
|
89
|
+
if(matchingBlocked&&adoption?.target?.page===prior.page&&prior.page)
|
|
90
|
+
return {status:'DENIED',code:'BLOCKED_REPLACEMENT_CHAT_REUSE'};
|
|
83
91
|
// A Project-scoped Chat cannot safely hand off to the ordinary home route:
|
|
84
92
|
// reject BEFORE claiming Owner instead of failing after four hours.
|
|
85
93
|
// Explicit /g/ intent remains Project-scoped even if Chrome aliases the
|
|
@@ -88,8 +96,8 @@ async function sessionStartPrepare(message,sender){
|
|
|
88
96
|
pathOf(intent.chatUrl||'').startsWith('/g/')
|
|
89
97
|
||adoption?.target?.page?.startsWith('/g/')))
|
|
90
98
|
return {status:'DENIED',code:'AUTO_HANDOFF_ROUTE_UNSUPPORTED'};
|
|
91
|
-
//
|
|
92
|
-
//
|
|
99
|
+
// Replacement must not replay the old Task. A new independent Task may
|
|
100
|
+
// share its Project after exact blocked Owner and Context-fence checks.
|
|
93
101
|
const promptDigest=adoption?null:await startPromptFingerprint(intent.prompt);
|
|
94
102
|
const next={sessionId:crypto.randomUUID(),projectId:intent.projectId,
|
|
95
103
|
...(intent.taskId?{taskId:intent.taskId}:{}),
|
package/lib/owner-evidence.mjs
CHANGED
|
@@ -56,8 +56,12 @@ function checkedExtensionIdle(){
|
|
|
56
56
|
*/
|
|
57
57
|
export function verifyOrphanOwnerIdle({oldRunRef,projectId}){
|
|
58
58
|
const native=checkedNative(),extension=checkedExtensionIdle();
|
|
59
|
-
const oldId=oldRunRef.split(':')
|
|
60
|
-
ensure(
|
|
59
|
+
const [oldId,oldTaskId,oldGeneration,...extra]=oldRunRef.split(':');
|
|
60
|
+
ensure(extra.length===0&&oldTaskId&&/^\d+$/.test(oldGeneration),
|
|
61
|
+
'ORPHAN_RUN_REF_INVALID');
|
|
62
|
+
ensure(native.sessionId!==oldId
|
|
63
|
+
&&(native.projectId!==projectId
|
|
64
|
+
||typeof native.taskId==='string'&&native.taskId!==oldTaskId),
|
|
61
65
|
'ORPHAN_OWNER_STILL_CURRENT');
|
|
62
66
|
const live=readSession();
|
|
63
67
|
ensure(live?.phase==='DONE'&&
|
package/lib/session-file.mjs
CHANGED
|
@@ -90,7 +90,9 @@ export function writeSession(input,replaceBlockedSessionId=null,resumeBlockedSes
|
|
|
90
90
|
throw fail('SESSION_REPLACEMENT_MISMATCH');
|
|
91
91
|
if(old&&old.sessionId!==next.sessionId&&old.phase!=='DONE'
|
|
92
92
|
&& !(old.phase==='BLOCKED' && next.phase==='STARTING'
|
|
93
|
-
&& replaceBlockedSessionId===old.sessionId
|
|
93
|
+
&& replaceBlockedSessionId===old.sessionId
|
|
94
|
+
&& (next.projectId!==old.projectId
|
|
95
|
+
||next.taskId!==undefined&&next.taskId!==old.taskId)))
|
|
94
96
|
throw fail('SESSION_ALREADY_ACTIVE');
|
|
95
97
|
if(old&&old.sessionId===next.sessionId){
|
|
96
98
|
if(next.projectId!==old.projectId)throw fail('SESSION_PROJECT_CHANGED');
|