@tomflow/chatloop-extension 0.4.36 → 0.4.38
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/actions/start.js +4 -2
- package/extension/manifest.json +1 -1
- package/extension/worker/readiness.js +32 -1
- package/extension/worker/router.js +4 -3
- package/extension/worker/task-routes-v2.js +5 -1
- package/lib/owner-kernel-lock.mjs +3 -0
- package/package.json +2 -1
- package/scripts/build-actions.mjs +5 -0
|
@@ -188,7 +188,8 @@ async function run(){
|
|
|
188
188
|
// Versioned task-first original Chat Adopt. There is NO composer write,
|
|
189
189
|
// send click, new Chat or V1 global Run in this path.
|
|
190
190
|
prepared=await chrome.runtime.sendMessage({
|
|
191
|
-
type:'CHAT_LOOP_TASK_START_PREPARE_V2',requestId:id
|
|
191
|
+
type:'CHAT_LOOP_TASK_START_PREPARE_V2',requestId:id,
|
|
192
|
+
...(proof.traceParent?{traceParent:proof.traceParent}:{})});
|
|
192
193
|
if(prepared?.status!=='PREPARED'
|
|
193
194
|
||prepared.scope!=='TASK_SCOPED_ADOPT_NO_SEND'
|
|
194
195
|
||!Number.isSafeInteger(prepared.tabId)
|
|
@@ -196,7 +197,8 @@ async function run(){
|
|
|
196
197
|
throw Error(prepared?.code||'SCOPED_START_PREPARE_UNVERIFIED');
|
|
197
198
|
await observerReady(prepared.tabId);
|
|
198
199
|
committed=await chrome.runtime.sendMessage({
|
|
199
|
-
type:'CHAT_LOOP_TASK_START_COMMIT_V2',requestId:id
|
|
200
|
+
type:'CHAT_LOOP_TASK_START_COMMIT_V2',requestId:id,
|
|
201
|
+
...(proof.traceParent?{traceParent:proof.traceParent}:{})});
|
|
200
202
|
if(committed?.status!=='OK'
|
|
201
203
|
||committed.scope!=='TASK_SCOPED_ADOPTED_NO_SEND'
|
|
202
204
|
||committed.sessionId!==prepared.sessionId
|
package/extension/manifest.json
CHANGED
|
@@ -103,6 +103,21 @@ async function startReadinessEvidence(run){
|
|
|
103
103
|
...(result&&typeof result.mainCount==='number'?{readiness:result}:{})};
|
|
104
104
|
}
|
|
105
105
|
// TEST_ONLY is an independent native @ App first-turn, never a managed Owner.
|
|
106
|
+
// An old Native CANCELLED pointer is harmless only when its own Context
|
|
107
|
+
// independently confirms the precise terminal fence and no unknown effects.
|
|
108
|
+
// Never rewrite the stale V1 Worker projection to make this admission pass.
|
|
109
|
+
async function verifiedCancelledLegacyPointer(record){
|
|
110
|
+
if(record?.phase!=='CANCELLED')return false;
|
|
111
|
+
const checked=await chrome.runtime.sendNativeMessage(SESSION_HOST,{
|
|
112
|
+
op:'context-control',command:'run.terminalStatus',args:{}
|
|
113
|
+
}).catch(()=>null);
|
|
114
|
+
const state=checked?.result,closed=state?.sessionCancellation;
|
|
115
|
+
return checked?.status==='OK'&&state?.runRef===null
|
|
116
|
+
&&state.unknownEffectCount===0&&state.pendingHandoff===false
|
|
117
|
+
&&closed?.status==='CANCELLED_NOT_DELIVERED'
|
|
118
|
+
&&closed.sessionId===record.sessionId
|
|
119
|
+
&&closed.generation===record.generation;
|
|
120
|
+
}
|
|
106
121
|
// A frozen BLOCKED run with a lost Owner tab must not disable ordinary first-
|
|
107
122
|
// turn testing forever. Keep its Native pointer untouched: this read-only
|
|
108
123
|
// gate checks both authorities and denies any live/unknown Owner transition.
|
|
@@ -115,11 +130,27 @@ async function entryTestAdmission(message,sender){
|
|
|
115
130
|
const run=await readRun(),record=disk.session;
|
|
116
131
|
if(!run?.sessionId){
|
|
117
132
|
return !record||record.phase==='DONE'
|
|
133
|
+
||await verifiedCancelledLegacyPointer(record)
|
|
118
134
|
?{status:'OK',scope:'TEST_ONLY'}
|
|
119
135
|
:{status:'DENIED',code:'ENTRY_TEST_OWNER_UNVERIFIED'};
|
|
120
136
|
}
|
|
121
|
-
if(!matchesNativeProjection(sessionProjection(run),record))
|
|
137
|
+
if(!matchesNativeProjection(sessionProjection(run),record)){
|
|
138
|
+
// A terminal Native/Context pointer may belong to a different, older V1
|
|
139
|
+
// Task than the stale Worker snapshot. TEST_ONLY sends no managed Owner
|
|
140
|
+
// actions; admit only if the Worker is terminal/frozen and its old Chat is
|
|
141
|
+
// not open. A live Worker or ambiguous Native fence still fails closed.
|
|
142
|
+
if(['BLOCKED','DONE','CANCELLED'].includes(run.phase)
|
|
143
|
+
&&!run.handoffPending&&await verifiedCancelledLegacyPointer(record)){
|
|
144
|
+
const tabs=await chrome.tabs.query({url:'https://chatgpt.com/*'})
|
|
145
|
+
.catch(()=>null);
|
|
146
|
+
const oldChatId=typeof run.page==='string'
|
|
147
|
+
?chatIdOf('https://chatgpt.com'+run.page):null;
|
|
148
|
+
if(Array.isArray(tabs)&&(!oldChatId
|
|
149
|
+
||!tabs.some(t=>chatIdOf(t.url)===oldChatId)))
|
|
150
|
+
return {status:'OK',scope:'TEST_ONLY',mode:'FENCED_LEGACY_DRIFT'};
|
|
151
|
+
}
|
|
122
152
|
return {status:'DENIED',code:'ENTRY_TEST_OWNER_MISMATCH'};
|
|
153
|
+
}
|
|
123
154
|
if(run.phase==='DONE')
|
|
124
155
|
return !run.contextManaged||run.taskId&&terminalFenceVerified(run)
|
|
125
156
|
?{status:'OK',scope:'TEST_ONLY'}
|
|
@@ -185,8 +185,8 @@ chrome.runtime.onMessage.addListener((message,sender,reply)=>{
|
|
|
185
185
|
}catch{/* Reply telemetry cannot change the browser callback. */}
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
|
-
//
|
|
189
|
-
//
|
|
188
|
+
// An exact privileged Action page may offer a soft AOP parent. This
|
|
189
|
+
// never grants task authority; native proof and Owner gates remain separate.
|
|
190
190
|
const sourceId=message?.requestId||message?.id;
|
|
191
191
|
const actionSource=/^[a-f0-9]{32}$/.test(sourceId||'')&&(
|
|
192
192
|
type==='CHAT_LOOP_SESSION_STATUS_V1'&&
|
|
@@ -196,7 +196,8 @@ chrome.runtime.onMessage.addListener((message,sender,reply)=>{
|
|
|
196
196
|
sender?.url===chrome.runtime.getURL(message.action.toLowerCase()+'.html')+
|
|
197
197
|
'?requestId='+sourceId||
|
|
198
198
|
['CHAT_LOOP_SESSION_START_PREPARE_V1','CHAT_LOOP_SESSION_START_TAKE_V1',
|
|
199
|
-
'CHAT_LOOP_SESSION_START_RESULT_V1'
|
|
199
|
+
'CHAT_LOOP_SESSION_START_RESULT_V1','CHAT_LOOP_TASK_START_PREPARE_V2',
|
|
200
|
+
'CHAT_LOOP_TASK_START_COMMIT_V2'].includes(type)&&
|
|
200
201
|
sender?.url===chrome.runtime.getURL('start.html')+'?requestId='+sourceId);
|
|
201
202
|
return workerApi.audit.observe('browser.dispatch.'+type,
|
|
202
203
|
// Read dispatchSpan only when the AOP invokes its target: onBegin has
|
|
@@ -211,7 +211,11 @@ const onScopedBrowserMessage=(message,sender,reply)=>{
|
|
|
211
211
|
void (async()=>{
|
|
212
212
|
if(!scopedTaskRuns||!scopedTaskScheduler)
|
|
213
213
|
throw Error('TASK_SCOPED_ROUTER_NOT_READY');
|
|
214
|
-
|
|
214
|
+
// A signed Start Action may carry its existing traceParent for soft
|
|
215
|
+
// correlation; it is not a Task identity, permit or business input.
|
|
216
|
+
if(!message||(Object.keys(message).length!==2
|
|
217
|
+
&&(Object.keys(message).length!==3
|
|
218
|
+
||!Object.hasOwn(message,'traceParent')))
|
|
215
219
|
||!/^[a-f0-9]{32}$/.test(message.requestId||''))
|
|
216
220
|
throw Error('SCOPED_START_MESSAGE_INVALID');
|
|
217
221
|
const source=await scopedStartIntent(message,sender);
|
|
@@ -85,6 +85,9 @@ function ensureMarker(){
|
|
|
85
85
|
export function withOwnerKernelLock(kind,args){
|
|
86
86
|
if(!['legacy-write','scoped-write','scoped-retire'].includes(kind)
|
|
87
87
|
||!Array.isArray(args))throw fail('OWNER_LOCK_REQUEST_INVALID');
|
|
88
|
+
const executable=stat(lockExec);
|
|
89
|
+
if(!executable?.isFile()||executable.isSymbolicLink())
|
|
90
|
+
throw fail('OWNER_LOCK_EXEC_MISSING');
|
|
88
91
|
const file=ensureMarker();
|
|
89
92
|
const result=spawnSync('/usr/bin/python3',
|
|
90
93
|
['-B',lockExec,file,process.execPath,helper],{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomflow/chatloop-extension",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Chat Loop Extension: reviewed formal Action pages, including TEST_ONLY native App entry",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"extension/",
|
|
21
21
|
"bin/",
|
|
22
22
|
"lib/",
|
|
23
|
+
"lib/owner-lock-exec.py",
|
|
23
24
|
"README.md"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
@@ -116,6 +116,11 @@ async function main(){
|
|
|
116
116
|
const pkg=JSON.parse(readFileSync(join(root,'package.json'),'utf8'));
|
|
117
117
|
if(manifest.version!==pkg.version||manifest.manifest_version!==3)
|
|
118
118
|
throw fail('EXTENSION_PACKAGE_VERSION_MISMATCH');
|
|
119
|
+
// The Darwin Native lock executor must survive npm pack. A missing helper
|
|
120
|
+
// makes every V1/V2 Owner CAS fail before any Context or Chrome binding.
|
|
121
|
+
if(!pkg.files?.includes('lib/owner-lock-exec.py')
|
|
122
|
+
||!existsSync(join(root,'lib','owner-lock-exec.py')))
|
|
123
|
+
throw fail('OWNER_LOCK_EXEC_PACKAGE_MISSING');
|
|
119
124
|
const targets=[[join(root,'actions.generated.mjs'),expected.node],
|
|
120
125
|
[join(ext,'loop','action-catalog.generated.js'),expected.browser],
|
|
121
126
|
...Object.entries(expected.aliases).map(([page,html])=>[join(ext,page),html])];
|