@tomflow/chatloop-tools 0.9.59 → 0.9.61
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/lib/extension-proxy.mjs +2 -1
- package/node_modules/@tomflow/chatloop-context/package.json +2 -2
- package/node_modules/@tomflow/chatloop-extension/README.md +16 -1
- package/node_modules/@tomflow/chatloop-extension/extension/actions/screenshot.js +9 -1
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-approval.js +13 -5
- package/node_modules/@tomflow/chatloop-extension/extension/manifest.json +1 -1
- package/node_modules/@tomflow/chatloop-extension/extension/worker/admission.js +3 -1
- package/node_modules/@tomflow/chatloop-extension/lib/bridge.mjs +13 -1
- package/node_modules/@tomflow/chatloop-extension/package.json +1 -1
- package/package.json +3 -3
package/lib/extension-proxy.mjs
CHANGED
|
@@ -61,7 +61,8 @@ function screenshotSourceVerified(path){
|
|
|
61
61
|
if(typeof path!=='string')return false;
|
|
62
62
|
const parent=dirname(path),id=basename(parent);
|
|
63
63
|
if(!/^[a-f0-9]{32}$/.test(id))return false;
|
|
64
|
-
const
|
|
64
|
+
const base=trustedTempRoot()||tmpdir();
|
|
65
|
+
const root=join(base,'chatloop-extension-v2-'+
|
|
65
66
|
(process.getuid?.()??process.env.USERNAME??'user'));
|
|
66
67
|
if(path!==join(root,id,'result.png'))return false;
|
|
67
68
|
try{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomflow/chatloop-context",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.24",
|
|
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.32",
|
|
38
38
|
"@tomflow/chatloop-trace": "0.4.6"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -48,6 +48,12 @@ handlers and existing trust boundaries. New send/Owner/Native mutation
|
|
|
48
48
|
requires a separate authorized security review and implementation; it cannot
|
|
49
49
|
be enabled by dropping in a capability file. Browser read actions never
|
|
50
50
|
clear an unknown send result or adopt a different Chat Owner.
|
|
51
|
+
Screenshot uses Chrome `captureVisibleTab` with the existing per-tab user
|
|
52
|
+
invocation (`activeTab`) or already granted capture permission; opening an
|
|
53
|
+
Action page programmatically does not itself grant this permission. Missing
|
|
54
|
+
permission is reported as `CAPTURE_PERMISSION_REQUIRED`, other capture API
|
|
55
|
+
failures as `CAPTURE_API_FAILED`, without exposing raw browser diagnostics.
|
|
56
|
+
Do not broaden host permissions or change the current Owner to obtain a screenshot.
|
|
51
57
|
|
|
52
58
|
### Validation
|
|
53
59
|
|
|
@@ -93,7 +99,16 @@ a Worker-only failed Native sync permits at most one additional fenced repair,
|
|
|
93
99
|
never a general BLOCKED retry. Two distinct genuine Form A-confirmation
|
|
94
100
|
user Turns may serve as SOFT R/P evidence in an explicitly
|
|
95
101
|
specified original Chat; this never substitutes for Context approval or Start
|
|
96
|
-
permission.
|
|
102
|
+
permission. Without a supplied Chat URL, a distinct exact Form A pair in an
|
|
103
|
+
already-open, actively processing P-confirmation Turn can be a candidate.
|
|
104
|
+
The candidate must be unique; Native Context still compares both approval
|
|
105
|
+
sources to the reserved Task before Owner binding. Idle generic Form pairs,
|
|
106
|
+
multiple candidates and mismatched approval sources do not grant an Owner.
|
|
107
|
+
No URL means no Chat creation. IPC messages are one-shot and have durable identity checks. CLI and Native
|
|
108
|
+
Host resolve the same private `chatloop-extension-v2-<uid>` IPC directory in
|
|
109
|
+
the fixed system temporary root (macOS `/private/tmp`, Linux `/tmp`),
|
|
110
|
+
independent of TMPDIR/TMP/TEMP. The prior namespace is retained as historical
|
|
111
|
+
receipt evidence and is never searched or replayed by this protocol.
|
|
97
112
|
|
|
98
113
|
This package's source version is read from its own `package.json`. Installed
|
|
99
114
|
Tools/Context consumers may pin a different Extension version; updating
|
|
@@ -19,7 +19,15 @@ async function saveScreenshot(tab,machine) {
|
|
|
19
19
|
if (active?.id !== tab.id) throw Error("TARGET_NOT_VISIBLE");
|
|
20
20
|
const current = await chrome.tabs.get(tab.id);
|
|
21
21
|
if (current.url !== tab.url) throw Error("TARGET_CHANGED_BEFORE_CAPTURE");
|
|
22
|
-
|
|
22
|
+
let dataUrl;
|
|
23
|
+
try { dataUrl = await chrome.tabs.captureVisibleTab(tab.windowId, {format: "png"}); }
|
|
24
|
+
catch (error) {
|
|
25
|
+
const message = String(error?.message || '');
|
|
26
|
+
if (/activeTab|<all_urls>|permission|not allowed to capture/i.test(message))
|
|
27
|
+
throw Error('CAPTURE_PERMISSION_REQUIRED');
|
|
28
|
+
if (/^[A-Z][A-Z0-9_]{1,95}$/.test(message)) throw error;
|
|
29
|
+
throw Error('CAPTURE_API_FAILED');
|
|
30
|
+
}
|
|
23
31
|
if (!dataUrl?.startsWith("data:image/png;base64,")) throw Error("CAPTURE_FAILED");
|
|
24
32
|
if(machine) { await machineResult(machine,dataUrl.slice("data:image/png;base64,".length)); return; }
|
|
25
33
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
@@ -152,11 +152,18 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
152
152
|
||rIndex>0&&rAssistant?.role!=="assistant"){
|
|
153
153
|
fail("APPROVAL_REQUIREMENTS_MISSING");return false;
|
|
154
154
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
// For a managed no-URL Start the Worker supplies each already-open
|
|
156
|
+
// Chat's own ID. Exact current Form A pairs are *candidates* only while
|
|
157
|
+
// the P-confirmation Turn is live. The Task is NOT inferred from Form
|
|
158
|
+
// prose; Native Context must compare both original approval sources
|
|
159
|
+
// against the reserved Task before any Owner can be committed.
|
|
160
|
+
const task=message.expectedTaskId;
|
|
161
|
+
const formPairCandidate=Boolean(typeof task==='string'
|
|
162
|
+
&&/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(task)
|
|
163
|
+
&&explicitFormChat&&rForm&&pForm);
|
|
164
|
+
if(task!==undefined&&!formPairCandidate){
|
|
165
|
+
// A no-URL idle adoption still needs both Task-scoped issued turns.
|
|
158
166
|
// No standalone historical affirmations or copied Task summaries.
|
|
159
|
-
const task=message.expectedTaskId;
|
|
160
167
|
const nativeIssue=(row,type)=>typeof task==="string"
|
|
161
168
|
&&/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(task)
|
|
162
169
|
&&textOf(row).startsWith(task+"|")
|
|
@@ -262,7 +269,8 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
262
269
|
&&message.expectedTaskId.length>=8
|
|
263
270
|
&&issueTask(rUser)===message.expectedTaskId
|
|
264
271
|
&&issueTask(pUser)===message.expectedTaskId;
|
|
265
|
-
if(message.expectedTaskId!==undefined&&!taskScoped
|
|
272
|
+
if(message.expectedTaskId!==undefined&&!taskScoped
|
|
273
|
+
&&!(formPairCandidate&&(snap.stop||snap.busy)&&!snap.pendingConfirmation)){
|
|
266
274
|
fail("APPROVAL_TASK_SCOPE_MISMATCH");return false;
|
|
267
275
|
}
|
|
268
276
|
const scopedIdle=Boolean(
|
|
@@ -46,7 +46,9 @@ async function approvedAdoptionTarget(chatUrl=null,taskId=null){
|
|
|
46
46
|
||(requestedId && chatIdOf(tab.url)!==requestedId))continue;
|
|
47
47
|
// No chatUrl means the caller does not authorize opening any Chat.
|
|
48
48
|
// For the approved Task only, inspect each ALREADY OPEN tab by its own
|
|
49
|
-
// immutable Chat ID
|
|
49
|
+
// immutable Chat ID. An exact live Form A pair may be a candidate, but
|
|
50
|
+
// only the later Native Context permit proves its Task identity. Idle
|
|
51
|
+
// no-URL candidates still require Task-scoped issued user Turns.
|
|
50
52
|
const scopedId=requestedId||taskId&&chatIdOf(tab.url);
|
|
51
53
|
const proof=await chrome.tabs.sendMessage(tab.id,
|
|
52
54
|
{type:"CHAT_LOOP_APPROVAL_EVIDENCE_V1",
|
|
@@ -27,7 +27,19 @@ function pathEntryExists(path){
|
|
|
27
27
|
catch(error){if(error.code==='ENOENT')return false;throw error}
|
|
28
28
|
}
|
|
29
29
|
export const configFile = () => join(homedir(), '.chat-loop', 'extension', 'config.json');
|
|
30
|
-
|
|
30
|
+
// The CLI and Chrome Native Host have independent environments. A fixed
|
|
31
|
+
// v2 namespace also fences unresolved requests from the former TMPDIR-based
|
|
32
|
+
// transport: never scan, migrate or replay those records.
|
|
33
|
+
export const tempRoot = () => {
|
|
34
|
+
const base=process.platform==='darwin'?'/private/tmp':process.platform==='linux'?'/tmp':tmpdir();
|
|
35
|
+
if(process.platform!=='win32'){
|
|
36
|
+
const st=lstatSync(base);
|
|
37
|
+
if(!st.isDirectory()||st.isSymbolicLink()||st.uid!==0
|
|
38
|
+
||!(st.mode&0o1000)||!(st.mode&0o002))
|
|
39
|
+
throw Object.assign(Error('Untrusted IPC temp root'),{code:'UNTRUSTED_STATE'});
|
|
40
|
+
}
|
|
41
|
+
return join(base,'chatloop-extension-v2-'+(process.getuid?.()??process.env.USERNAME??'user'));
|
|
42
|
+
};
|
|
31
43
|
export function privateDir(path) {
|
|
32
44
|
mkdirSync(path, {recursive:true, mode:0o700});
|
|
33
45
|
const st=lstatSync(path);
|
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.61",
|
|
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.24",
|
|
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.32"
|
|
41
41
|
},
|
|
42
42
|
"bundleDependencies": [
|
|
43
43
|
"@tomflow/chatloop-context",
|