@tomflow/chatloop-extension 0.4.40 → 0.4.42

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.
@@ -22,6 +22,7 @@ importScripts("worker/task-cancel-v2.js");
22
22
  importScripts("worker/task-recover-v2.js");
23
23
  importScripts("worker/task-cancel-recovery-v2.js");
24
24
  importScripts("worker/session-control.js");
25
+ importScripts("worker/entry-admission-v2.js");
25
26
  importScripts("worker/readiness.js");
26
27
  importScripts("worker/turn-failure.js");
27
28
  importScripts("worker/turn-finished.js");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Chat Loop Extension",
4
- "version": "0.4.40",
4
+ "version": "0.4.42",
5
5
  "description": "Chat Loop browser companion: Eye actions, Turn observer, Continue and Handoff Actions",
6
6
  "permissions": [
7
7
  "activeTab",
@@ -0,0 +1,53 @@
1
+ // A live V2 Task is NOT a global blocker for an independent TEST_ONLY Chat.
2
+ // V1 Native session-read deliberately rejects active V2 Ledger state; retain
3
+ // that fence and verify each current scoped Worker/Native/Context writer instead.
4
+ // No Task is adopted, fenced, resumed, or sent through the Owner path here.
5
+ async function verifiedScopedEntryAdmission(){
6
+ if(!scopedTaskRuns)return {status:'DENIED',code:'ENTRY_TEST_SCOPED_STORE_MISSING'};
7
+ const legacy=await readRun();
8
+ if(legacy&&(!['DONE','CANCELLED','BLOCKED'].includes(legacy.phase)
9
+ ||legacy.handoffPending))
10
+ return {status:'DENIED',code:'ENTRY_TEST_LEGACY_RUN_ACTIVE'};
11
+ const snapshot=await scopedTaskRuns.read();
12
+ const active=Object.values(snapshot.items).map(x=>x.run)
13
+ .filter(run=>!['DONE','CANCELLED'].includes(run.phase));
14
+ if(!active.length||active.length>32)
15
+ return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_UNVERIFIED'};
16
+ for(const run of active){
17
+ if(run.phase!=='WAITING_REPLY'||typeof run.projectId!=='string'
18
+ ||typeof run.taskId!=='string'||typeof run.sessionId!=='string'
19
+ ||!Number.isSafeInteger(run.generation)||run.generation<0
20
+ ||!Number.isSafeInteger(run.nativeOwnerRevision)
21
+ ||run.nativeOwnerRevision<1)
22
+ return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_UNVERIFIED'};
23
+ const args={projectId:run.projectId,taskId:run.taskId,
24
+ sessionId:run.sessionId,generation:run.generation};
25
+ const native=await chrome.runtime.sendNativeMessage(SESSION_HOST,{
26
+ op:'session-snapshot-v2',...args}).catch(()=>null);
27
+ const s=native?.session;
28
+ if(native?.status!=='OK'||native.scope!=='TASK_SCOPED_SNAPSHOT'
29
+ ||s?.projectId!==run.projectId||s.taskId!==run.taskId
30
+ ||s.sessionId!==run.sessionId||s.generation!==run.generation
31
+ ||s.phase!=='WAITING_REPLY'||s.revision!==run.nativeOwnerRevision
32
+ ||typeof s.activeChatId!=='string'
33
+ ||s.activeChatId!==run.ownerChatId)
34
+ return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_MISMATCH'};
35
+ const writer=await chrome.runtime.sendNativeMessage(SESSION_HOST,{
36
+ op:'context-writer-check-v2',...args,
37
+ expectedSessionRevision:run.nativeOwnerRevision}).catch(()=>null);
38
+ if(writer?.status!=='OK'||writer.scope!=='TASK_SCOPED_WRITER_VERIFIED'
39
+ ||writer.projectId!==run.projectId||writer.taskId!==run.taskId
40
+ ||writer.sessionId!==run.sessionId
41
+ ||writer.nativeOwnerRevision!==run.nativeOwnerRevision)
42
+ return {status:'DENIED',code:'ENTRY_TEST_SCOPED_WRITER_UNVERIFIED'};
43
+ }
44
+ const reread=await scopedTaskRuns.read();
45
+ const current=Object.values(reread.items).map(x=>x.run)
46
+ .filter(run=>!['DONE','CANCELLED'].includes(run.phase));
47
+ const identity=run=>[run.projectId,run.taskId,run.sessionId,
48
+ run.generation,run.nativeOwnerRevision,run.phase,run.ownerChatId].join('|');
49
+ if(current.length!==active.length
50
+ ||current.some((run,i)=>identity(run)!==identity(active[i])))
51
+ return {status:'DENIED',code:'ENTRY_TEST_SCOPED_OWNER_CHANGED'};
52
+ return {status:'OK',scope:'TEST_ONLY',mode:'VERIFIED_SCOPED_OWNER_DISTINCT_CHAT'};
53
+ }
@@ -126,6 +126,8 @@ async function entryTestAdmission(message,sender){
126
126
  return {status:'DENIED',code:'ENTRY_TEST_SOURCE_UNVERIFIED'};
127
127
  const disk=await chrome.runtime.sendNativeMessage(SESSION_HOST,
128
128
  {op:'session-read'}).catch(()=>null);
129
+ if(disk?.code==='OWNER_LEDGER_ACTIVE_USE_SCOPED_QUERY')
130
+ return verifiedScopedEntryAdmission();
129
131
  if(disk?.status!=='OK')return {status:'DENIED',code:'ENTRY_TEST_NATIVE_UNVERIFIED'};
130
132
  const run=await readRun(),record=disk.session;
131
133
  if(!run?.sessionId){
@@ -87,9 +87,14 @@ const onBrowserMessage=(message, sender, reply, dispatchParent=null) => {
87
87
  try{
88
88
  // Fail BEFORE any old handler reads/consumes a permission or opens
89
89
  // an Action. saveRun's later guard is not early enough by itself.
90
- await assertLegacyWorkerWritable({native:![
91
- 'CHAT_LOOP_SESSION_STATUS_V1','CHAT_LOOP_MODEL_INTENT_STATUS_V1'
92
- ].includes(type)});
90
+ // TEST_ONLY entry has its own signed Action + Native cancellation
91
+ // admission. It never owns a Task or sends through a legacy Run;
92
+ // an unrelated live V2 Task must not block a new ordinary Chat.
93
+ // All legacy send/Owner routes still fail closed while V2 is active.
94
+ if(type!=='CHAT_LOOP_ENTRY_TEST_ADMISSION_V1')
95
+ await assertLegacyWorkerWritable({native:![
96
+ 'CHAT_LOOP_SESSION_STATUS_V1','CHAT_LOOP_MODEL_INTENT_STATUS_V1'
97
+ ].includes(type)});
93
98
  legacyAllowed=true;
94
99
  result=await handle(type==='CHAT_LOOP_SESSION_STATUS_V1'
95
100
  ?{...message,auditDispatchParent:dispatchParent}:message,sender);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/chatloop-extension",
3
- "version": "0.4.40",
3
+ "version": "0.4.42",
4
4
  "type": "module",
5
5
  "description": "Chat Loop Extension: reviewed formal Action pages, including TEST_ONLY native App entry",
6
6
  "bin": {