@tomflow/chatloop-tools 0.4.23 → 0.4.24

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/README.md CHANGED
@@ -44,6 +44,8 @@ npx --yes --package=@tomflow/chatloop-tools@latest chatloop-tools upgrade
44
44
 
45
45
  **0.4.23 正式 Mac 用户环境(本轮目标)**:Chat Loop 自己的 MCP Gateway 仍路由同一 pinned Desktop Commander 子进程;Supervisor 不再给它创建 `~/.chat-loop/local-tools/tools/desktop-commander/home` 假 HOME,改从 OS 实际登录账号 `userInfo()` 取得用户 HOME/USER/LOGNAME,保留原有 PATH 和本机服务环境。意味着 MCP 文件、shell、npm、配置与用户的 Mac 账号目录一致,不必使用 Local Dev 或桌面 Terminal 中转。独立 Local Dev MCP 仅用于本轮迁移/研发;新 Gateway 仍拒绝图形 Terminal/iTerm 启动。新增真实 Gateway→Desktop Commander→`node os.homedir()` 的本机回读测试。**该包需单独正式发布和真实生产激活;源码回归通过不等于云端已切换。**
46
46
 
47
+ **0.4.24 防止文字误拦截**:`0.4.23` 在 Mac 本机执行已通过,但 Gateway 的图形终端拦截会把文档或 heredoc 内提及的命令当成真实执行,造成误拒。本版只检查实际 shell 命令位置,跳过 heredoc 正文;真实启动图形 Terminal/iTerm 的命令仍被阻止,普通代码、文档、目录和服务命令不受影响。独立回归覆盖实际启动和字符串/文档反例。**本机 MCP 权限/资源模型与 0.4.23 相同**。
48
+
47
49
  **Start 长页面准备(0.4.17)**:私人 MCP `chat_loop_extension__start` 的 CLI 子调用等待窗口最多 330 秒,仅用于允许 Chrome 安全校验和 ChatGPT 编辑器自然就绪。超时仍返回不确定错误,不重新启动或重发,必须单独查询 Status。
48
50
 
49
51
 
package/lib/release.mjs CHANGED
@@ -9,8 +9,9 @@ import {PACKAGE_VERSION} from './control.mjs';
9
9
  const name='@tomflow/chatloop-tools';
10
10
  const entryIn=prefix=>join(prefix,'node_modules','@tomflow','chatloop-tools','bin','cli.mjs');
11
11
  const runtimeRoot=()=>join(homedir(),'.chat-loop');
12
- // The local MCP/Desktop Commander process has an intentionally isolated
13
- // HOME. It must never treat that sandbox as the user's running release root.
12
+ // An external MCP or test shell may still inherit an isolated HOME. The
13
+ // production Tools Desktop Commander now uses the actual Mac account HOME;
14
+ // upgrades must also resolve that same account root, never a sandbox copy.
14
15
  function checkedUpgradeBase(options){
15
16
  if(options.base!==undefined)return options.base; // Explicit test/API base.
16
17
  try{
@@ -1,18 +1,36 @@
1
- // Prevent accidental GUI Terminal launches from Chat Loop's local MCP command API.
2
- // This does not restrict ordinary CLI/shell execution, files, services or directories.
1
+ // Direct macOS GUI Terminal launch prevention at the Chat Loop MCP boundary.
2
+ // Ordinary shell/CLI commands and text containing examples are not blocked.
3
3
  const terminalApp=String.raw`(?:Terminal|iTerm2?)(?:\.app)?`;
4
4
  const appTarget=new RegExp(String.raw`(?:^|\s|\/|["'])${terminalApp}(?:\/|["'\s;]|$)`,'i');
5
+ function shellStatementsOnly(input){
6
+ const lines=input.split(/\r?\n/),outside=[];
7
+ let hereEnd=null;
8
+ for(const line of lines){
9
+ if(hereEnd!==null){
10
+ if(line.trim()===hereEnd)hereEnd=null;
11
+ continue;
12
+ }
13
+ outside.push(line);
14
+ const here=line.match(/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/);
15
+ if(here)hereEnd=here[2];
16
+ }
17
+ return outside.join('\n');
18
+ }
5
19
  export function isGraphicalTerminalCommand(toolName,args){
6
- if(toolName!=='start_process' && toolName!=='interact_with_process')return false;
20
+ if(toolName!=='start_process'&&toolName!=='interact_with_process')return false;
7
21
  const command=toolName==='start_process'?args?.command:args?.input;
8
22
  if(typeof command!=='string')return false;
9
- // open -n -a Terminal / open -a /System/Applications/Utilities/Terminal.app
10
- const open=/\b(?:\/usr\/bin\/)?open\s+[^;\n|]{0,240}/gi;
11
- for(const m of command.matchAll(open)){
12
- if(/(?:^|\s)-a(?:\s|=)/.test(m[0]) && appTarget.test(m[0]))return true;
23
+ const statements=shellStatementsOnly(command);
24
+ // A command has to be at shell position, not quoted as data or in a heredoc.
25
+ const start=String.raw`(?:^|[;&|]\s*|\bthen\s+|\bdo\s+)\s*`;
26
+ const open=new RegExp(start+String.raw`(?:\/usr\/bin\/)?open\s+[^;\n|]{0,240}`,'gim');
27
+ for(const match of statements.matchAll(open)){
28
+ if(/(?:^|\s)-a(?:\s|=)/.test(match[0])&&appTarget.test(match[0]))return true;
29
+ }
30
+ const osa=new RegExp(start+String.raw`(?:\/usr\/bin\/)?osascript\s+[^;\n|]{0,450}`,'gim');
31
+ for(const match of statements.matchAll(osa)){
32
+ if(/\b(?:Terminal|iTerm2?)\b/i.test(match[0]))return true;
13
33
  }
14
- // AppleScript calls into Terminal/iTerm and direct .app binary launch.
15
- if(/\b(?:\/usr\/bin\/)?osascript\b[\s\S]{0,450}\b(?:Terminal|iTerm2?)\b/i.test(command))return true;
16
- if(/\/(?:Terminal|iTerm2?)\.app\/Contents\/MacOS\//i.test(command))return true;
17
- return false;
34
+ const direct=new RegExp(start+String.raw`\/[^;\n|]*\/(?:Terminal|iTerm2?)\.app\/Contents\/MacOS\/\S+`,'gim');
35
+ return direct.test(statements);
18
36
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.4.23",
6
+ "version": "0.4.24",
7
7
  "type": "module",
8
8
  "description": "Chat Loop local tools: MCP gateway, isolated bundled tunnel-client and unified CLI",
9
9
  "bin": {