@tomflow/chatloop-tools 0.9.55 → 0.9.56
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/node_modules/@tomflow/chatloop-context/package.json +2 -2
- package/node_modules/@tomflow/chatloop-extension/extension/manifest.json +1 -1
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-prepare.js +17 -7
- package/node_modules/@tomflow/chatloop-extension/extension/worker/bootstrap.js +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/readiness.js +9 -2
- package/node_modules/@tomflow/chatloop-extension/package.json +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomflow/chatloop-context",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Independent local Context SDK and short-lived CLI for Chat Loop projects",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"ps-list": "9.0.0",
|
|
37
|
-
"@tomflow/chatloop-extension": "0.4.
|
|
37
|
+
"@tomflow/chatloop-extension": "0.4.28",
|
|
38
38
|
"@tomflow/chatloop-trace": "0.4.6"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -87,14 +87,22 @@ async function sessionStartPrepare(message,sender){
|
|
|
87
87
|
&&!!intent.chatUrl&&prior.adoptPage===pathOf(intent.chatUrl)
|
|
88
88
|
&&Number.isInteger(prior.adoptTabId)
|
|
89
89
|
&&typeof prior.adoptUserKey==='string');
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const disk=await chrome.runtime.sendNativeMessage(SESSION_HOST,{op:'session-read'}).catch(()=>null);
|
|
91
|
+
if(disk?.status!=='OK')return {status:'DENIED',code:'SESSION_STATE_UNVERIFIED'};
|
|
92
|
+
// A Worker ghost from a timed-out, no-send Adopt may disagree with the
|
|
93
|
+
// durable Native BLOCKED ID. Only an independently approved DIFFERENT Task
|
|
94
|
+
// may supersede the exact Native pointer, never the same old Task or Chat.
|
|
95
|
+
const driftReplacement=Boolean(independentTask&&replace
|
|
96
|
+
&&replace===disk.session?.sessionId
|
|
97
|
+
&&independentBlockedAdoptDrift(prior,disk.session)
|
|
98
|
+
&&!!intent.chatUrl&&pathOf(intent.chatUrl)!==prior.adoptPage);
|
|
99
|
+
const matchingBlocked=Boolean(prior?.phase==='BLOCKED'
|
|
100
|
+
&&prior.sessionId===replace
|
|
101
|
+
&&(prior.projectId!==intent.projectId||independentTask
|
|
102
|
+
||prePermitRecovery)||preNativeGhost||driftReplacement);
|
|
93
103
|
if(replace&&!matchingBlocked)return {status:'DENIED',code:'BLOCKED_REPLACEMENT_MISMATCH'};
|
|
94
104
|
if(prior&&prior.phase!=='DONE'&&!matchingBlocked)
|
|
95
105
|
return {status:'DENIED',code:'LOOP_ALREADY_ACTIVE'};
|
|
96
|
-
const disk=await chrome.runtime.sendNativeMessage(SESSION_HOST,{op:'session-read'}).catch(()=>null);
|
|
97
|
-
if(disk?.status!=='OK')return {status:'DENIED',code:'SESSION_STATE_UNVERIFIED'};
|
|
98
106
|
const ownerMatches=Boolean(prior?.sessionId&&disk.session
|
|
99
107
|
&&matchesNativeProjection(sessionProjection(prior),disk.session));
|
|
100
108
|
const sameTaskNative=Boolean((prePermitRecovery||preNativeGhost)
|
|
@@ -104,7 +112,8 @@ async function sessionStartPrepare(message,sender){
|
|
|
104
112
|
&&disk.session.activeChatId===null&&disk.session.activeChatUrl===null
|
|
105
113
|
&&Number.isSafeInteger(disk.session.updatedAt)
|
|
106
114
|
&&disk.session.updatedAt>0);
|
|
107
|
-
if((matchingBlocked&&!(ownerMatches||(preNativeGhost&&sameTaskNative)
|
|
115
|
+
if((matchingBlocked&&!(ownerMatches||(preNativeGhost&&sameTaskNative)
|
|
116
|
+
||driftReplacement))
|
|
108
117
|
||((prePermitRecovery||preNativeGhost)&&!sameTaskNative))
|
|
109
118
|
return {status:'DENIED',code:'SESSION_REPLACEMENT_MISMATCH'};
|
|
110
119
|
// A terminal Worker record cannot authorize a new Start if a different
|
|
@@ -135,7 +144,8 @@ async function sessionStartPrepare(message,sender){
|
|
|
135
144
|
:await approvedAdoptionTarget(intent.chatUrl||null,
|
|
136
145
|
intent.contextLeaseRef?intent.taskId:null):null;
|
|
137
146
|
if(adoption?.error)return {status:'DENIED',code:adoption.error};
|
|
138
|
-
if(matchingBlocked&&adoption?.target?.page===prior.page&&prior.page)
|
|
147
|
+
if((matchingBlocked&&adoption?.target?.page===prior.page&&prior.page)
|
|
148
|
+
||(driftReplacement&&adoption?.target?.page===prior.adoptPage))
|
|
139
149
|
return {status:'DENIED',code:'BLOCKED_REPLACEMENT_CHAT_REUSE'};
|
|
140
150
|
// A Project-scoped Chat cannot safely hand off to the ordinary home route:
|
|
141
151
|
// reject BEFORE claiming Owner instead of failing after four hours.
|
|
@@ -148,6 +148,23 @@ const matchesNativeProjection=(projected,native)=>Boolean(native
|
|
|
148
148
|
// Read-only status diagnosis: reveal field NAMES only, never Owner identities.
|
|
149
149
|
const sessionProjectionDrift=(projected,native)=>SESSION_POINTER_KEYS.filter(
|
|
150
150
|
key=>projected[key]!==native?.[key]);
|
|
151
|
+
// Two distinct durable IDs may exist after an interrupted Adopt reservation.
|
|
152
|
+
// This narrow read-only shape proves NEITHER a previous send nor authority to
|
|
153
|
+
// replace it; only a DIFFERENT freshly approved Task can request Native CAS.
|
|
154
|
+
const independentBlockedAdoptDrift=(run,native)=>Boolean(
|
|
155
|
+
run?.phase==='BLOCKED'&&run.reason==='ACTION_RESULT_TIMEOUT_UNVERIFIED'
|
|
156
|
+
&&run.action==='START'&&run.mode==='adopt'
|
|
157
|
+
&&run.contextLeaseRef&&!run.contextManaged
|
|
158
|
+
&&run.generation===0&&run.tabId===null&&run.page==='/'
|
|
159
|
+
&&!run.userKey&&!run.newUserKey&&!run.assistantKey
|
|
160
|
+
&&!run.attemptedNewTabId&&!run.lastStartActionTabId
|
|
161
|
+
&&typeof run.adoptPage==='string'&&run.adoptPage.startsWith('/c/')
|
|
162
|
+
&&Number.isInteger(run.adoptTabId)&&typeof run.adoptUserKey==='string'
|
|
163
|
+
&&native?.phase==='BLOCKED'&&native.generation===0
|
|
164
|
+
&&native.activeChatId===null&&native.activeChatUrl===null
|
|
165
|
+
&&native.projectId===run.projectId&&native.taskId===run.taskId
|
|
166
|
+
&&typeof native.sessionId==='string'&&native.sessionId!==run.sessionId
|
|
167
|
+
&&Number.isSafeInteger(native.updatedAt)&&native.updatedAt>0);
|
|
151
168
|
const sessionPage=(sender,name,id)=> Number.isInteger(sender.tab?.id)
|
|
152
169
|
&& typeof id==='string'&&/^[a-f0-9]{32}$/.test(id)
|
|
153
170
|
&& sender.url===chrome.runtime.getURL(name+'.html')+'?requestId='+id;
|
|
@@ -154,9 +154,16 @@ async function sessionStatus(message,sender){
|
|
|
154
154
|
traceParent:message.auditDispatchParent}:{})}).catch(()=>null);
|
|
155
155
|
if(disk?.status!=='OK')return {status:'UNVERIFIED',code:'SESSION_STATE_UNVERIFIED'};
|
|
156
156
|
const projection=run?.sessionId?sessionProjection(run):null;
|
|
157
|
-
if(projection&&!matchesNativeProjection(projection,disk.session))
|
|
157
|
+
if(projection&&!matchesNativeProjection(projection,disk.session)){
|
|
158
|
+
const mismatchedFields=sessionProjectionDrift(projection,disk.session);
|
|
158
159
|
return {status:'UNVERIFIED',code:'SESSION_FILE_MISMATCH',
|
|
159
|
-
mismatchedFields
|
|
160
|
+
mismatchedFields,
|
|
161
|
+
...(mismatchedFields.length===1&&mismatchedFields[0]==='sessionId'
|
|
162
|
+
&&independentBlockedAdoptDrift(run,disk.session)
|
|
163
|
+
?{independentTaskReplacementCandidate:{
|
|
164
|
+
replaceBlockedSessionId:disk.session.sessionId,
|
|
165
|
+
requires:'FRESH_APPROVED_DISTINCT_TASK_AND_NATIVE_CAS'}}:{})};
|
|
166
|
+
}
|
|
160
167
|
if(!run?.sessionId&&disk.session&&disk.session.phase!=='DONE')
|
|
161
168
|
return {status:'UNVERIFIED',code:'SESSION_OWNER_MISMATCH'};
|
|
162
169
|
if(run&&run.phase!=='DONE'&&!run.sessionId)
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.9.
|
|
6
|
+
"version": "0.9.56",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"description": "Chat Loop local tools: MCP gateway, isolated bundled tunnel-client and unified CLI",
|
|
9
9
|
"bin": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"prepack": "node ./scripts/build-providers.mjs --check && node ./scripts/build-form-app.mjs --check && node ./scripts/build-document-app.mjs --check"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tomflow/chatloop-context": "0.6.
|
|
36
|
+
"@tomflow/chatloop-context": "0.6.19",
|
|
37
37
|
"@tomflow/chatloop-trace": "0.4.6",
|
|
38
38
|
"@wonderwhy-er/desktop-commander": "0.2.44",
|
|
39
39
|
"ps-list": "9.0.0",
|
|
40
|
-
"@tomflow/chatloop-extension": "0.4.
|
|
40
|
+
"@tomflow/chatloop-extension": "0.4.28"
|
|
41
41
|
},
|
|
42
42
|
"bundleDependencies": [
|
|
43
43
|
"@tomflow/chatloop-context",
|