myagent-ai 1.15.35 → 1.15.37
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 +23 -0
- package/main.py +14 -10
- package/package.json +1 -1
- package/start.js +26 -13
package/README.md
CHANGED
|
@@ -123,6 +123,29 @@ powershell -c "irm https://raw.githubusercontent.com/ctz168/myagent/main/install
|
|
|
123
123
|
curl -fsSL https://raw.githubusercontent.com/ctz168/myagent/main/install/install.sh | bash
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
+
### 一键重装(跳过依赖检查)
|
|
127
|
+
|
|
128
|
+
> 已安装过 MyAgent 的环境下,快速升级/重装,安装和启动时均不检查 pip 依赖。
|
|
129
|
+
|
|
130
|
+
**npm 方式(推荐,最简单):**
|
|
131
|
+
```bash
|
|
132
|
+
npx myagent-ai --skip-deps
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
> `npx` 会自动安装/升级最新版 `myagent-ai`,`--skip-deps` 跳过安装和启动时的所有依赖检查。
|
|
136
|
+
|
|
137
|
+
**脚本方式:**
|
|
138
|
+
|
|
139
|
+
**Windows(PowerShell):**
|
|
140
|
+
```powershell
|
|
141
|
+
powershell -c "& ([scriptblock]::Create((irm https://raw.githubusercontent.com/ctz168/myagent/main/install/install.ps1))) -NoDeps"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**macOS / Linux:**
|
|
145
|
+
```bash
|
|
146
|
+
curl -fsSL https://raw.githubusercontent.com/ctz168/myagent/main/install/install.sh | bash -s -- --no-deps
|
|
147
|
+
```
|
|
148
|
+
|
|
126
149
|
---
|
|
127
150
|
|
|
128
151
|
## 📋 系统要求
|
package/main.py
CHANGED
|
@@ -155,16 +155,20 @@ class MyAgentApp:
|
|
|
155
155
|
self.logger.info("=" * 60)
|
|
156
156
|
|
|
157
157
|
# 1.5 自动检测并安装缺失依赖(开箱即用)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
# 可通过 --skip-deps 参数或 MYAGENT_SKIP_DEPS=1 环境变量跳过
|
|
159
|
+
if os.environ.get("MYAGENT_SKIP_DEPS") == "1":
|
|
160
|
+
self.logger.info("跳过依赖检查(--skip-deps)")
|
|
161
|
+
else:
|
|
162
|
+
self.logger.info("检查依赖...")
|
|
163
|
+
deps_result = check_and_install_deps(auto_fix=True, silent=False)
|
|
164
|
+
if deps_result["installed"] > 0:
|
|
165
|
+
self.logger.info(
|
|
166
|
+
f"自动安装了 {deps_result['installed']} 个依赖"
|
|
167
|
+
)
|
|
168
|
+
if deps_result["failed"] > 0:
|
|
169
|
+
self.logger.warning(
|
|
170
|
+
f"{deps_result['failed']} 个依赖安装失败,相关功能可能不可用"
|
|
171
|
+
)
|
|
168
172
|
|
|
169
173
|
# 2. LLM 客户端
|
|
170
174
|
llm_cfg = self.config.llm
|
package/package.json
CHANGED
package/start.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* myagent-ai setup # 配置向导
|
|
18
18
|
* myagent-ai reinstall # 重新安装依赖到 venv
|
|
19
19
|
* myagent-ai uninstall # 卸载 MyAgent(删除npm包+数据)
|
|
20
|
+
* myagent-ai --skip-deps # 跳过依赖检查,直接启动
|
|
20
21
|
*/
|
|
21
22
|
"use strict";
|
|
22
23
|
|
|
@@ -524,11 +525,18 @@ function main() {
|
|
|
524
525
|
console.log(" \x1b[1m\x1b[36mMyAgent\x1b[0m - 本地桌面端执行型 AI 助手");
|
|
525
526
|
console.log("");
|
|
526
527
|
|
|
528
|
+
// 是否跳过依赖检查
|
|
529
|
+
const skipDeps = userArgs.includes("--skip-deps") || userArgs.includes("--no-deps");
|
|
530
|
+
// 从参数中移除 --skip-deps/--no-deps,避免传入 main.py
|
|
531
|
+
const filteredArgs = userArgs.filter(a => a !== "--skip-deps" && a !== "--no-deps");
|
|
532
|
+
|
|
527
533
|
// 确保 venv 存在
|
|
528
534
|
const { venvDir, venvPython, isNew } = ensureVenv();
|
|
529
535
|
|
|
530
|
-
//
|
|
531
|
-
if (
|
|
536
|
+
// 检查并安装依赖(--skip-deps 时跳过)
|
|
537
|
+
if (skipDeps) {
|
|
538
|
+
console.log(" \x1b[90m[i]\x1b[0m 跳过依赖检查(--skip-deps)");
|
|
539
|
+
} else if (isNew) {
|
|
532
540
|
installDeps(venvPython, getVenvPip(venvDir), pkgDir);
|
|
533
541
|
} else {
|
|
534
542
|
// 即使 venv 已存在,也快速检查核心依赖
|
|
@@ -550,9 +558,9 @@ function main() {
|
|
|
550
558
|
console.log(` \x1b[90m[i]\x1b[0m Python: ${venvPython}`);
|
|
551
559
|
console.log("");
|
|
552
560
|
|
|
553
|
-
// 构建 Python
|
|
554
|
-
let mode =
|
|
555
|
-
let pyArgs = buildArgs(
|
|
561
|
+
// 构建 Python 参数(使用过滤后的参数)
|
|
562
|
+
let mode = filteredArgs[0] || "";
|
|
563
|
+
let pyArgs = buildArgs(filteredArgs);
|
|
556
564
|
|
|
557
565
|
// 首次运行且未指定模式 → 自动选择 web 模式
|
|
558
566
|
if (isFirstRun && !mode) {
|
|
@@ -576,17 +584,22 @@ function main() {
|
|
|
576
584
|
}
|
|
577
585
|
|
|
578
586
|
// 使用 venv 的 Python 启动
|
|
587
|
+
const spawnEnv = {
|
|
588
|
+
...process.env,
|
|
589
|
+
// 设置 VIRTUAL_ENV 环境变量,让 Python 程序知道自己运行在 venv 中
|
|
590
|
+
VIRTUAL_ENV: venvDir,
|
|
591
|
+
PATH: IS_WIN
|
|
592
|
+
? `${path.join(venvDir, "Scripts")};${process.env.PATH}`
|
|
593
|
+
: `${path.join(venvDir, "bin")}:${process.env.PATH}`,
|
|
594
|
+
};
|
|
595
|
+
// 将 --skip-deps 信号传递给 Python,让 main.py 也跳过依赖检查
|
|
596
|
+
if (skipDeps) {
|
|
597
|
+
spawnEnv.MYAGENT_SKIP_DEPS = "1";
|
|
598
|
+
}
|
|
579
599
|
const child = spawn(venvPython, pyArgs, {
|
|
580
600
|
cwd: pkgDir,
|
|
581
601
|
stdio: "inherit",
|
|
582
|
-
env:
|
|
583
|
-
...process.env,
|
|
584
|
-
// 设置 VIRTUAL_ENV 环境变量,让 Python 程序知道自己运行在 venv 中
|
|
585
|
-
VIRTUAL_ENV: venvDir,
|
|
586
|
-
PATH: IS_WIN
|
|
587
|
-
? `${path.join(venvDir, "Scripts")};${process.env.PATH}`
|
|
588
|
-
: `${path.join(venvDir, "bin")}:${process.env.PATH}`,
|
|
589
|
-
},
|
|
602
|
+
env: spawnEnv,
|
|
590
603
|
});
|
|
591
604
|
|
|
592
605
|
child.on("error", (err) => {
|