@tomflow/chatloop-extension 0.4.39 → 0.4.41

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.
@@ -8,6 +8,7 @@ importScripts("worker/bootstrap.js");
8
8
  importScripts("worker/admission.js");
9
9
  importScripts("worker/adopt-prepare.js");
10
10
  importScripts("worker/adopt-result.js");
11
+ importScripts("worker/task-start-evidence-v2.js");
11
12
  importScripts("worker/task-start-v2.js");
12
13
  importScripts("worker/task-intent-v2.js");
13
14
  importScripts("worker/task-intent-dispatch-v2.js");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Chat Loop Extension",
4
- "version": "0.4.39",
4
+ "version": "0.4.41",
5
5
  "description": "Chat Loop browser companion: Eye actions, Turn observer, Continue and Handoff Actions",
6
6
  "permissions": [
7
7
  "activeTab",
@@ -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);
@@ -0,0 +1,59 @@
1
+ // Task-first Start only: read-only approval evidence and bounded Observer reconnect.
2
+ async function scopedStartEvidence(intent){
3
+ const page=pathOf(intent.chatUrl),chatId=chatIdOf(intent.chatUrl);
4
+ scopedStartAssert(page&&chatId,'SCOPED_ADOPTION_URL_INVALID');
5
+ // Never implicitly open/select the latest Chat, including across Projects.
6
+ const tabs=await chrome.tabs.query({url:'https://chatgpt.com/*'});
7
+ const matches=tabs.filter(t=>Number.isSafeInteger(t.id)
8
+ &&pathOf(t.url)===page);
9
+ scopedStartAssert(matches.length===1,'SCOPED_ADOPTION_CHAT_UNVERIFIED');
10
+ const tab=matches[0];
11
+ const observe=()=>chrome.tabs.sendMessage(tab.id,{
12
+ type:'CHAT_LOOP_APPROVAL_EVIDENCE_V1',explicitChatId:chatId
13
+ }).catch(()=>null);
14
+ let first=await observe();
15
+ if(!first){
16
+ // Reload invalidates the old content-script connection. Reinject only
17
+ // the existing read-only Observer in the exact, already-open Chat.
18
+ const current=await chrome.tabs.get(tab.id).catch(()=>null);
19
+ scopedStartAssert(current&&pathOf(current.url)===page,
20
+ 'SCOPED_ADOPTION_TAB_CHANGED');
21
+ const files=['content.js','loop/core.js','loop/observer-inspect.js',
22
+ 'loop/observer-poll.js','loop/observer-recovery.js',
23
+ 'loop/observer-approval.js','loop/observer.js'];
24
+ const loaded=await chrome.scripting.executeScript({
25
+ target:{tabId:tab.id,allFrames:false},files
26
+ }).catch(()=>null);
27
+ scopedStartAssert(Array.isArray(loaded)&&loaded.length===1
28
+ &&loaded[0].frameId===0,
29
+ 'SCOPED_ADOPTION_OBSERVER_RECONNECT_FAILED');
30
+ const after=await chrome.tabs.get(tab.id).catch(()=>null);
31
+ scopedStartAssert(after&&pathOf(after.url)===page,
32
+ 'SCOPED_ADOPTION_TAB_CHANGED');
33
+ first=await observe();
34
+ }
35
+ const candidate=policy.normalizeAdoptionEvidence(first,{page});
36
+ scopedStartAssert(candidate,'SCOPED_ADOPTION_APPROVAL_UNVERIFIED');
37
+ const second=await observe();
38
+ scopedStartAssert(policy.sameAdoptionEvidence(candidate,
39
+ policy.normalizeAdoptionEvidence(second,{page})),
40
+ 'SCOPED_ADOPTION_APPROVAL_CHANGED');
41
+ const source=second?.approvalTurns;
42
+ scopedStartAssert(source&&typeof source==='object'
43
+ &&typeof source.rUserText==='string'&&source.rUserText.length>0
44
+ &&source.rUserText.length<=1000
45
+ &&typeof source.pUserText==='string'&&source.pUserText.length>0
46
+ &&source.pUserText.length<=1000
47
+ &&/^user:[^\s]{8,}$/.test(source.rUserKey||'')
48
+ &&source.rUserKey!==candidate.userKey,
49
+ 'SCOPED_ADOPTION_SOURCE_UNVERIFIED');
50
+ const fresh=await chrome.tabs.get(tab.id).catch(()=>null);
51
+ scopedStartAssert(fresh&&pathOf(fresh.url)===page,
52
+ 'SCOPED_ADOPTION_TAB_CHANGED');
53
+ return {tabId:tab.id,chatId,page,
54
+ evidence:candidate,approvalEvidence:{
55
+ rUserText:source.rUserText,rUserKey:source.rUserKey,
56
+ rVersion:candidate.rVersion,
57
+ pUserText:source.pUserText,pUserKey:candidate.userKey,
58
+ pVersion:candidate.pVersion}};
59
+ }
@@ -41,44 +41,6 @@ async function scopedStartIntent(message,sender){
41
41
  'SCOPED_START_INTENT_UNVERIFIED');
42
42
  return {requestId:id,intent,actionTabId:sender.tab.id};
43
43
  }
44
- async function scopedStartEvidence(intent){
45
- const page=pathOf(intent.chatUrl),chatId=chatIdOf(intent.chatUrl);
46
- scopedStartAssert(page&&chatId,'SCOPED_ADOPTION_URL_INVALID');
47
- // Never implicitly open/select the latest Chat, including across Projects.
48
- const tabs=await chrome.tabs.query({url:'https://chatgpt.com/*'});
49
- const matches=tabs.filter(t=>Number.isSafeInteger(t.id)
50
- &&pathOf(t.url)===page);
51
- scopedStartAssert(matches.length===1,'SCOPED_ADOPTION_CHAT_UNVERIFIED');
52
- const tab=matches[0];
53
- const observe=()=>chrome.tabs.sendMessage(tab.id,{
54
- type:'CHAT_LOOP_APPROVAL_EVIDENCE_V1',explicitChatId:chatId
55
- }).catch(()=>null);
56
- const first=await observe();
57
- const candidate=policy.normalizeAdoptionEvidence(first,{page});
58
- scopedStartAssert(candidate,'SCOPED_ADOPTION_APPROVAL_UNVERIFIED');
59
- const second=await observe();
60
- scopedStartAssert(policy.sameAdoptionEvidence(candidate,
61
- policy.normalizeAdoptionEvidence(second,{page})),
62
- 'SCOPED_ADOPTION_APPROVAL_CHANGED');
63
- const source=second?.approvalTurns;
64
- scopedStartAssert(source&&typeof source==='object'
65
- &&typeof source.rUserText==='string'&&source.rUserText.length>0
66
- &&source.rUserText.length<=1000
67
- &&typeof source.pUserText==='string'&&source.pUserText.length>0
68
- &&source.pUserText.length<=1000
69
- &&/^user:[^\s]{8,}$/.test(source.rUserKey||'')
70
- &&source.rUserKey!==candidate.userKey,
71
- 'SCOPED_ADOPTION_SOURCE_UNVERIFIED');
72
- const fresh=await chrome.tabs.get(tab.id).catch(()=>null);
73
- scopedStartAssert(fresh&&pathOf(fresh.url)===page,
74
- 'SCOPED_ADOPTION_TAB_CHANGED');
75
- return {tabId:tab.id,chatId,page,
76
- evidence:candidate,approvalEvidence:{
77
- rUserText:source.rUserText,rUserKey:source.rUserKey,
78
- rVersion:candidate.rVersion,
79
- pUserText:source.pUserText,pUserKey:candidate.userKey,
80
- pVersion:candidate.pVersion}};
81
- }
82
44
  const scopedStartRecord=(scope,phase,chatId=null)=>({
83
45
  projectId:scope.projectId,taskId:scope.taskId,sessionId:scope.sessionId,
84
46
  generation:0,phase,activeChatId:chatId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/chatloop-extension",
3
- "version": "0.4.39",
3
+ "version": "0.4.41",
4
4
  "type": "module",
5
5
  "description": "Chat Loop Extension: reviewed formal Action pages, including TEST_ONLY native App entry",
6
6
  "bin": {