🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.
Python ai-agentai-assistantchatbotclaudecomputer-usedeepseekdesktop-appdshelectronfeishugeminigptgrokllmlocal-firstmodelflaremulti-modelopenai-compatiblepersonal-ai-agentwechat
docs: app-managed PowerShell 7; scripts/pwsh-hashes.mjs to bump the pinned release
Marlac7a17f7b9051
diff --git a/.env.example b/.env.exampleindex 57c9e72..529a613 100644--- a/.env.example+++ b/.env.example@@ -32,5 +32,11 @@# 微信 iLink 接口地址(一般不用改)# AMB_WEIXIN_API_BASE=https://ilinkai.weixin.qq.com+# Windows:代理执行命令用的 PowerShell。没有能用的 PowerShell 7 时应用会在后台自动装一份(%LOCALAPPDATA%\AnyModelBot\pwsh)+# AMB_PWSH_AUTO_INSTALL=0 # 不自动安装(设置 → 故障排查 里仍可手动安装)+# AMB_PWSH_MIRROR=https://…/ # 下载镜像前缀(后面接 PowerShell-<版本>-win-<架构>.zip;照样核对 SHA256 和签名)+# AMB_PWSH_HOME= # 安装位置+# AMB_PWSH_IGNORE_SYSTEM=1 # 仅测试:不用系统里的 PowerShell(CI 用它验证内置副本)+# 日志级别 debug|info|warn|error# AMB_LOG_LEVEL=infodiff --git a/README.md b/README.mdindex bd4cf4c..78585ca 100644--- a/README.md+++ b/README.md@@ -55,6 +55,7 @@ npm run test:dsh-bundle # 用 Electron 跑真实 DSH 集成测试,加载打- DSH 代理运行时:`scripts/prepare-dsh.mjs` 按目标平台安装 `dsh-runtime/`,`scripts/bundle-dsh.mjs` 把它打成 `resources/dsh/dsh.asar`(全部 JS,一个文件)加上 `resources/dsh/node_modules/`(只有原生包,约 55 个文件)。Electron 主进程和 `ELECTRON_RUN_AS_NODE` 子进程直接读 asar,无需首启解压;安装包因此只需解出几百个文件(Windows 上解压与杀毒逐个扫描是安装慢的主因)。开发时仍直接用 `dsh-runtime/`。+- Windows 上代理执行命令用的 PowerShell:经沙箱时 Windows PowerShell 5.1 每条命令要二三十秒,PowerShell 7 约 1 秒。应用按这个顺序选:系统里能用的 PowerShell 7(后台按 DSH 的方式试运行一次,什么都不下载)→ 应用内置的 PowerShell 7 → Windows PowerShell 5.1。没有能用的 7 且代理模式开着时,应用在后台自动下载官方 PowerShell 7.6.9(LTS)的 zip,装到 `%LOCALAPPDATA%\AnyModelBot\pwsh\`:不需要管理员权限,不写注册表、不改 PATH,不影响你自己的 PowerShell。版本和 x64 / arm64 两个 zip 的 SHA256 写死在 `src/agent/pwsh-private.ts`(升级用 `node scripts/pwsh-hashes.mjs <版本>`),下载后核对哈希、解压后核对微软 Authenticode 签名,再按 DSH 的方式试运行(版本、读写临时文件、拉起外部程序)通过才用;装失败或装了一半的不会被用,下次启动会清掉。装的时候对话页和 设置 → 常规 显示进度,`/status` 也有,装好之前命令照常用 5.1;装好后空闲的代理进程在后台换用它,不用重启应用。运行中代理拉不起它(被杀毒软件删除或隔离、被策略拦截)就自动退回上一种并提示原因;设置 → 故障排查 可以安装、重新安装、改回系统默认。Windows 10 1607 / Server 2016 以前的系统不下载。桌面版下载走系统代理(Chromium 网络栈);命令行版用 Node 的 fetch(较新的 Node 设 `NODE_USE_ENV_PROXY=1` 后认 `HTTPS_PROXY`);`AMB_PWSH_MIRROR` 可换成镜像前缀(照样核对哈希和签名),`AMB_PWSH_AUTO_INSTALL=0` 关掉自动安装。- 数据目录:`<userData>/data`(macOS `~/Library/Application Support/anymodel bot/data`,Windows `%APPDATA%\anymodel bot\data`,Linux `~/.config/anymodel bot/data`)- 单实例;关闭窗口默认隐藏到托盘(设置 → 常规 可改为退出);托盘菜单:打开 / 在浏览器中打开 / 开机自启(macOS、Windows)/ 打开数据目录 / 退出- macOS 下窗口无标题栏,红绿灯嵌在侧栏顶部;窗口最小宽度 860diff --git a/scripts/pwsh-hashes.mjs b/scripts/pwsh-hashes.mjsnew file mode 100644index 0000000..6badf9e--- /dev/null+++ b/scripts/pwsh-hashes.mjs@@ -0,0 +1,61 @@+#!/usr/bin/env node+// 升级应用内置的 PowerShell 7 时用:打印某个版本 win-x64 / win-arm64 zip 的 SHA256 和大小,贴进 src/agent/pwsh-private.ts 的 PRIVATE_PWSH。+// 哈希取自该 release 里的 hashes.sha256,再和 GitHub API 的 asset digest 对一遍(不一致就报错);--verify 时再把两个 zip 下载下来复算。+// 选版本:最新的稳定版或 LTS(不要 preview / rc);再看一眼 .NET 支持的最低 Windows 版本,必要时改 minBuild。+//+// node scripts/pwsh-hashes.mjs 7.6.9 [--verify]+import crypto from "node:crypto";++const args = process.argv.slice(2);+const ver = args.find((a) => !a.startsWith("--"));+const verify = args.includes("--verify");+if (!/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(ver ?? "")) {+ console.error("usage: node scripts/pwsh-hashes.mjs <version> [--verify]");+ process.exit(2);+}+const base = `https://github.com/PowerShell/PowerShell/releases/download/v${ver}`;+const names = { x64: `PowerShell-${ver}-win-x64.zip`, arm64: `PowerShell-${ver}-win-arm64.zip` };++async function get(url, headers = {}) {+ const r = await fetch(url, { headers, redirect: "follow" });+ if (!r.ok) throw new Error(`${url}: HTTP ${r.status}`);+ return r;+}++// 1. release 里的 hashes.sha256("<hex> *<文件名>";这个文件是 UTF-16LE 带 BOM 的)+const raw = Buffer.from(await (await get(`${base}/hashes.sha256`)).arrayBuffer());+const text = raw[0] === 0xff && raw[1] === 0xfe ? raw.subarray(2).toString("utf16le") : raw.toString("utf8").replace(/^\uFEFF/, "");+const listed = {};+for (const line of text.split(/\r?\n/)) {+ const m = /^([0-9a-f]{64})\s+\*?(\S+)$/i.exec(line.trim());+ if (m) listed[m[2]] = m[1].toLowerCase();+}+// 2. GitHub API:asset 的 digest 与大小,release 是否预发布(GITHUB_TOKEN 可选,只用来放宽限流)+const auth = process.env.GITHUB_TOKEN ? { authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {};+const rel = await (await get(`https://api.github.com/repos/PowerShell/PowerShell/releases/tags/v${ver}`, { accept: "application/vnd.github+json", ...auth })).json();+if (rel.prerelease) console.error(`warning: v${ver} is a prerelease; pin a stable or LTS release`);++const out = { sha256: {}, size: {} };+for (const [arch, name] of Object.entries(names)) {+ const sha = listed[name];+ const asset = (rel.assets ?? []).find((a) => a.name === name);+ if (!sha || !asset) throw new Error(`${name} is missing from the v${ver} release`);+ const digest = String(asset.digest ?? "").replace(/^sha256:/, "").toLowerCase();+ if (digest && digest !== sha) throw new Error(`${name}: hashes.sha256 says ${sha}, the API digest says ${digest}`);+ if (verify) {+ const buf = Buffer.from(await (await get(`${base}/${name}`)).arrayBuffer());+ const got = crypto.createHash("sha256").update(buf).digest("hex");+ if (got !== sha || buf.length !== asset.size) throw new Error(`${name}: downloaded ${got} (${buf.length} bytes), expected ${sha} (${asset.size} bytes)`);+ console.error(`verified ${name}: ${buf.length} bytes`);+ }+ out.sha256[arch] = sha;+ out.size[arch] = asset.size;+}++console.log(`// ${rel.name ?? `v${ver}`}, published ${rel.published_at}; hashes from the release's hashes.sha256, matching the GitHub API asset digests${verify ? " and the downloaded zips" : ""}+ version: "${ver}",+ sha256: {+ x64: "${out.sha256.x64}",+ arm64: "${out.sha256.arm64}",+ },+ size: { x64: ${out.size.x64}, arm64: ${out.size.arm64} },`);