feat(local): 少说教、多干活——缺什么让模型自己装,提示压到一句

本地形态是用户自己的机器 + 用户自己的 agent,目标是事做成,不是按生产环境守着:
- env-local 去掉「先问用户才能装运行时」这道闸,也不再把 sudo/系统包列成禁令。
  改为「需要什么就装、装完继续;只有需要用户密码时才停下来问」——sudo 本来就卡在
  密码上,不必用规则去禁。
- 启动器与终端的提示去掉解释性长句:探活只报版本或「未安装」,启动总结压成
  「技能:已启用 / python3 未安装」「语音:可用 / 未启用」这类一行话。

docs/local-mode(4.4 / 4.13 / 限制表)与 local/README 同步。
This commit is contained in:
2026-11-11 17:08:45 +08:00
parent a7eecdbe97
commit 5b45368f58
4 changed files with 23 additions and 25 deletions
+6 -7
View File
@@ -1,7 +1,6 @@
- You run on the user's own machine, not in a disposable sandbox: `terminal` is a
real shell with their permissions, other conversations share the same machine,
and `/tmp` is the system temp directory (shared, never cleaned for you). Work
inside the working directory; treat everything outside it as the user's.
- `python3` may be missing. Never run `sudo` or install system packages. When a
skill lacks a Python module, install it into `$AGENT_SKILLS_DEPS` and retry;
when `python3` itself is missing, ask the user before installing a runtime.
- You run on the user's own machine with their permissions, not a sandbox; other
conversations share it and `/tmp` is the system temp dir. Work inside the
working directory; treat everything outside it as the user's.
- `python3` may be missing. Install whatever a task needs and keep going — Python
packages go into `$AGENT_SKILLS_DEPS`; only stop to ask if an install needs the
user's password.
+6 -7
View File
@@ -127,8 +127,8 @@
1. **技能不一定是 Python 的**。`office` 只有 `SKILL.md` + `scripts/office`,模型在 `terminal` 里调
`office <cmd>`,完全不需要 python3——一刀切会把这类技能一并藏掉。
2. **没必要防**。`skills.js` 的 `runEntry` 对 `spawn` 的 `error` 有处理,缺解释器时模型拿到的是
「技能入口启动失败:spawn python3 ENOENT」,干净可读、不崩不挂。模型能据此自己决定:装模块、
问你装运行时,或者放弃。
「技能入口启动失败:spawn python3 ENOENT」,干净可读、不崩不挂。模型据此自己装解释器或模块,
装完继续跑即可。
所以现在只有一种行为:技能总是可见;python3 缺失只影响 `run.py` 类技能能否执行。装好 python3 后
(若在 core 启动时 `PATH` 已有的目录里,如 brew 的 `/opt/homebrew/bin`)无需重启即生效,否则重跑脚本。
@@ -267,10 +267,9 @@ health 只作为「端口上有服务但不是本启动器拉起的」兜底提
import;而不指定位置的话,它很可能装到别处(或去改系统 Python)。pip 对 `--target` 的
PEP 668 拦截明确豁免(`pip/_internal/commands/install.py`),所以这条路在 Homebrew 那种
externally-managed 解释器上也走得通——但这话不写进提示词,交给模型自己判断。
- 缺 `python3` 本体时:提示词允许模型装运行时,但**必须先问用户**(`ask the user before
installing a runtime`)。理由:macOS 的 `/usr/bin/python3` 是 Xcode CLT 的桩,真装要走 brew
或官方安装器,耗时长且可能改 `PATH`/要管理员权限——这种级别的改动不能默许模型自主做。
同时仍然禁止 `sudo` 与装系统包。
- 缺 `python3` 本体时也放给模型自己处理:本地形态是「用户自己的机器 + 用户自己的 agent」,
目标是把事做成,而不是把它当生产环境保护。提示词只说「需要什么就装、装完继续;只有需要
用户密码时才停下来问」——`sudo` 本来就会卡在密码上,不必再用规则去禁。
- 技能自己的 `requirements.txt` 一律**不写版本号**:服务端 init 用
`pip install --no-index --dry-run` 探测,pin 到与镜像不同的版本会让探测失败 → 真的往
`skills/deps` 装一份旧的,而 `PYTHONPATH` 优先于系统 site-packages,等于反向遮蔽镜像包。
@@ -348,7 +347,7 @@ tail -f local/.runtime/core.log # 以及 npm-install.log / mcp-*.log
| `mcp_asr` 监听 `0.0.0.0` | 它只认 `PORT` 环境变量、`listen` 不带 host(已启动时才是问题)。不存密钥(上游参数随请求带入),暴露面有限;要收紧需给 `mcp/asr` 加 `--host` 支持 |
| Windows 不支持 | `spawn('/bin/sh')`、`process.kill(-pid)`、模型写的 bash 语法都是 POSIX 语义 |
| `mint_public_link` 不可用 | 本地 `public_link.base_url` 为空,工具会回明确的「未配置」错误 |
| 技能依赖 | 本地不预装:缺包时模型会把包装进 `skills/deps`(`$AGENT_SKILLS_DEPS`,已在该进程 `PYTHONPATH` 里,装完下次运行即生效)。怎么装由模型自己决定。缺 `python3` 本体时它会先问你,同意后才装。需要系统库的包(`weasyprint`→pango/cairo)pip 装不了,仍需手工 `brew install`。服务器上由 `agent-executor-init` 处理 |
| 技能依赖 | 本地不预装:缺包时模型会把包装进 `skills/deps`(`$AGENT_SKILLS_DEPS`,已在该进程 `PYTHONPATH` 里,装完下次运行即生效);连 `python3` 都没有时也由它自己装。怎么装由模型自己决定。需要系统库的包(`weasyprint`→pango/cairo)pip 装不了,仍需手工 `brew install`。服务器上由 `agent-executor-init` 处理 |
| 首个 `npm install` 要联网 | 支持 `NPM_REGISTRY` 覆盖源;`app/package-lock.json` 的 `resolved` 已改指向公共 registry(原来钉在内网镜像,外部机器必失败) |
## 8. 回滚
+1 -1
View File
@@ -142,7 +142,7 @@ git pull
- **技能依赖不预装**:本地没有 `agent-executor-init`,`skills/*/requirements.txt` 不会在启动时
自动安装。技能缺包时会报 `ModuleNotFoundError`,模型会把缺的包装进 `skills/deps`
(`AGENT_SKILLS_DEPS` 指向它,且已在该进程的 `PYTHONPATH` 里,装完下次运行即生效)。
连 `python3` 都没有时,技能清单仍是完整的,模型会先问你、得到同意后才装解释器。
连 `python3` 都没有时技能清单依旧完整,模型会自己把它装上再继续。
需要系统库的包(如 `weasyprint` 依赖 pango/cairo)pip 装不了,得自己 `brew install`。
- **首个 `npm install` 要联网**:启动器会自动选源、换源重试、并把装好的依赖缓存到
`~/.cache/agent-local/`;之后重启 / 换 clone 都是本地解压,不需要网络。真要手动指定源:
+10 -10
View File
@@ -353,10 +353,10 @@ ui_checks() {
else ui_step "Node.js 缺失或版本过低:$NODE_HINT" bad; fi
if [ "$NPM_OK" = 1 ]; then ui_step 'npm 可用(装依赖用)' ok
else ui_step 'npm 缺失:随 Node.js 一起装,重装 Node 即可' bad; fi
if [ "$PY_OK" = 1 ]; then ui_step "python3 ${PY_VER}(Python 技能可用)" ok
else ui_step 'python3 未安装(Python 技能会失败;office 等非 Python 技能不受影响)' warn; fi
if [ "$FF_OK" = 1 ]; then ui_step "ffmpeg ${FF_VER}(语音可用)" ok
else ui_step 'ffmpeg 未安装(可选,麦克风入口隐藏)' warn; fi
if [ "$PY_OK" = 1 ]; then ui_step "python3 ${PY_VER}" ok
else ui_step 'python3 未安装(Python 技能会失败)' warn; fi
if [ "$FF_OK" = 1 ]; then ui_step "ffmpeg ${FF_VER}" ok
else ui_step 'ffmpeg 未安装(语音不可用)' warn; fi
if [ "$PORT_FREE" = 1 ]; then ui_step "端口 $PORT 可用" ok
else ui_step "端口 $PORT 已被占用(换 PORT=8099)" bad; fi
}
@@ -961,8 +961,8 @@ if ! ensure_deps; then
fi
if link_skills; then
if [ "$PY_OK" = 1 ]; then ui_step '技能:已启用(python3 就绪)' ok
else ui_step '技能已暴露,但 python3 未安装:Python 技能会执行失败' warn; fi
if [ "$PY_OK" = 1 ]; then ui_step '技能:已启用' ok
else ui_step '技能:python3 未安装(Python 技能会失败)' warn; fi
else
ui_step '技能目录软链创建失败,技能不可用' warn
fi
@@ -1026,14 +1026,14 @@ while :; do
say "已启动:http://$HOST_ADDR:$PORT"
sleep 1
if [ "$FF_OK" = 1 ]; then
say '语音:可用(ffmpeg 已就绪;还需在设置页给 asr 填上游地址与模型)'
say '语音:可用'
else
say '语音:不可用(未装 ffmpeg,麦克风入口隐藏、asr 子进程未启动;core 日志里的 asr 发现失败是预期的)'
say '语音:未启用(缺 ffmpeg)'
fi
if [ "$PY_OK" = 1 ]; then
say '技能:已启用(python3 就绪)'
say '技能:已启用'
else
say '技能:已暴露,但 python3 未安装——Python 技能调用会失败,其余照常'
say '技能:python3 未安装(Python 技能暂不可用)'
fi
if [ "$FIRST_RUN" = 1 ]; then
printf '\n首次使用:左下角「用户区」→ 设置 → 模型池,添加平台和 API Key,然后点「重启」。\n'