@unionschool/easy-agents 1.0.23 → 1.0.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 +7 -7
- package/bin/easy-agents.js +4 -1
- package/bin/mac-service.js +73 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# EasyAgents
|
|
1
|
+
# EasyAgents
|
|
2
2
|
|
|
3
3
|
在要接任务的设备上单独安装客户端,首次用工作台生成的配对码绑定设备。Mac、Windows 和 Ubuntu 安装包自带 Node、Python 和客户端核心。设备要使用 Codex 或 Claude 时,还需安装并登录对应的工具。
|
|
4
4
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
| 设备 | 安装和打开 | 设备配置位置 |
|
|
8
8
|
| --- | --- | --- |
|
|
9
|
-
| macOS 14+ | Intel 和 Apple 芯片都使用 `EasyAgents-Mac-Universal.zip`。解压后把 `EasyAgents
|
|
10
|
-
| Windows x64 | 双击 `EasyAgents-Setup.exe`,按当前用户安装。从开始菜单打开 **EasyAgents
|
|
9
|
+
| macOS 14+ | Intel 和 Apple 芯片都使用 `EasyAgents-Mac-Universal.zip`。解压后把 `EasyAgents.app` 拖入「应用程序」并打开,点菜单栏图标。 | `~/Library/Application Support/EasyAgents Client/` |
|
|
10
|
+
| Windows x64 | 双击 `EasyAgents-Setup.exe`,按当前用户安装。从开始菜单打开 **EasyAgents**,以后可点托盘图标。在新终端输入 `easy-agents` 也可打开面板。 | `%APPDATA%\EasyAgents\` |
|
|
11
11
|
| Ubuntu x64 | 在压缩包所在目录执行下面两行,以运行客户端的普通用户安装。 | `~/.easyagents/` |
|
|
12
12
|
| Android 8+ | 安装交付的 `EasyAgents-Android-test.apk`,打开应用,用 Linux 设备配对码接入,点「上线接任务」。前台通知显示服务状态。 | 应用私有存储和 Android Keystore |
|
|
13
13
|
|
|
@@ -20,13 +20,13 @@ Ubuntu 的程序入口是 `~/.local/share/easyagents-client/current/easy-agents`
|
|
|
20
20
|
|
|
21
21
|
### 在 Mac 终端直接使用 easy-agents
|
|
22
22
|
|
|
23
|
-
应用内的命令是 `"/Applications/EasyAgents
|
|
23
|
+
应用内的命令是 `"/Applications/EasyAgents.app/Contents/Resources/easy-agents"`(2026-11-23 前应用叫 `EasyAgents Client.app`,装新版后面板会自动把后台、开机启动和下面这个入口改到新应用,旧应用移到废纸篓)。用 `command -v easy-agents` 核对现有入口。以下命令为当前用户创建启动脚本,已有入口时会跳过创建。
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
26
|
mkdir -p "$HOME/.local/bin"
|
|
27
27
|
launcher="$HOME/.local/bin/easy-agents"
|
|
28
28
|
if [ ! -e "$launcher" ] && [ ! -L "$launcher" ]; then
|
|
29
|
-
printf '%s\n' '#!/bin/sh' 'exec "/Applications/EasyAgents
|
|
29
|
+
printf '%s\n' '#!/bin/sh' 'exec "/Applications/EasyAgents.app/Contents/Resources/easy-agents" "$@"' > "$launcher" && chmod 755 "$launcher"
|
|
30
30
|
fi
|
|
31
31
|
export PATH="$HOME/.local/bin:$PATH"
|
|
32
32
|
command -v easy-agents
|
|
@@ -94,6 +94,6 @@ npm exec --offline -- easy-agents run
|
|
|
94
94
|
- Node 核心支持 `/sha256 <文本>`、本地 Markdown 文档里的同类计算和成员同步。文档与同步的目录需与本机选定工作目录相符,可用 `EASYAGENTS_WORKSPACE` 指定。成员同步使用包内实现、系统 Git 和 Python 3.10+,更新已有检出目录。Android 首版可执行 SHA-256 消息和用户选择目录里的计算文档。
|
|
95
95
|
- 客户端保存待回传结果,重连后补传。独立版尚未接入运行中 `/steer`、手动 `/sync`、平台远程读文档和编辑设备上的工具规则。
|
|
96
96
|
|
|
97
|
-
开发者在 `
|
|
97
|
+
开发者在 `client/` 中执行 `npm ci`、`npm pack` 构建通用包。包内包含 `runtime/easyagents_core/` 中的 Git、文件交付和 MCP 模块及其进程支持,并随包附带 WebSocket 依赖。桌面安装器从同一目录取工具、模型、额度和平台 API 模块,按 `scripts/desktop-requirements.txt` 安装固定版本的 Python 依赖。
|
|
98
98
|
|
|
99
|
-
在 Mac 上,从仓库根目录运行 `uv run --no-project --python 3.12 python
|
|
99
|
+
在 Mac 上,从仓库根目录运行 `uv run --no-project --python 3.12 python client/macos/install.py --zip /path/to/EasyAgents-Mac-Universal.zip` 生成通用 ZIP。该模式只写出压缩包。菜单栏程序、Node 和内置 Python 都包含 `x86_64` 与 `arm64`。
|
package/bin/easy-agents.js
CHANGED
|
@@ -87,7 +87,7 @@ function updater(automatic) {
|
|
|
87
87
|
const [command = desktop ? (process.platform === 'linux' ? 'status' : 'show') : '--help', ...args] = process.argv.slice(2);
|
|
88
88
|
try {
|
|
89
89
|
if (['--help', '-h'].includes(command) && !args.length) {
|
|
90
|
-
console.log('EasyAgents
|
|
90
|
+
console.log('EasyAgents\n\n'
|
|
91
91
|
+ 'easy-agents --version\n'
|
|
92
92
|
+ 'easy-agents configure <网关地址> <端口>\n'
|
|
93
93
|
+ 'easy-agents pair\n'
|
|
@@ -143,6 +143,9 @@ try {
|
|
|
143
143
|
} else if (desktop && command === 'auto-update' && args.length === 1 && ['on','off'].includes(args[0])) {
|
|
144
144
|
(await desktopState()).writeSnapshot(configDir, 'auto-update.json', { enabled: args[0] === 'on' });
|
|
145
145
|
console.log(args[0] === 'on' ? '自动更新已开启' : '自动更新已关闭');
|
|
146
|
+
} else if (mac && command === 'relocate' && !args.length) {
|
|
147
|
+
// 应用改名或换位置后,把开机启动、面板自启、后台任务的 launchd 配置改到当前应用(安装脚本和面板会自动调用)。
|
|
148
|
+
console.log(await (await controls()).relocate(configDir));
|
|
146
149
|
} else if (desktop && command === 'autostart' && args.length === 1 && ['on','off'].includes(args[0])) {
|
|
147
150
|
if (args[0] === 'on' && !readSettings(devicePath)) throw new Error('请先配对设备,再设置开机启动');
|
|
148
151
|
if (mac) await (await controls()).autostart(configDir, args[0] === 'on');
|
package/bin/mac-service.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
-
import { existsSync, mkdirSync, openSync, closeSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { existsSync, mkdirSync, openSync, closeSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir, userInfo } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { basename, dirname, join } from 'node:path';
|
|
6
6
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
7
7
|
import { macResources, readSnapshot, terminalEnabled, compactAt } from './mac-reports.js';
|
|
8
8
|
|
|
@@ -57,14 +57,76 @@ export async function autostart(folder, enabled) {
|
|
|
57
57
|
+ '/usr/sbin/chown root:wheel "$t"; /bin/chmod 644 "$t"; /bin/mv -f "$t" ' + target;
|
|
58
58
|
admin(cmd);
|
|
59
59
|
} else if (!enabled && bootEnabled(folder)) admin('/bin/rm -f ' + target);
|
|
60
|
-
if (enabled)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
if (enabled) writePanel(folder);
|
|
61
|
+
else rmSync(agent,{force:true});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const panelFile = folder => join(homedir(),'Library/LaunchAgents',bootLabel(folder) + '.panel.plist');
|
|
65
|
+
|
|
66
|
+
function writePanel(folder) {
|
|
67
|
+
const agent = panelFile(folder);
|
|
68
|
+
mkdirSync(dirname(agent), { recursive: true, mode: 0o700 });
|
|
69
|
+
const temporary = agent + '.' + process.pid;
|
|
70
|
+
const exe = join(dirname(macResources),'MacOS/EasyAgentsClient');
|
|
71
|
+
writeFileSync(temporary, plist(entry('Label',str(bootLabel(folder) + '.panel')) + entry('RunAtLoad','<true/>')
|
|
72
|
+
+ entry('ProgramArguments','<array>' + str(exe) + str('--background') + '</array>')), { mode: 0o600, flag:'wx' });
|
|
73
|
+
renameSync(temporary,agent);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 应用改名或挪了位置(2026-11-23 起 EasyAgents Client.app 改名 EasyAgents.app):launchd 配置里写死了程序路径,
|
|
77
|
+
// 指向旧应用的要换成当前应用,否则下次开机或重启后台就找不到程序。配置目录与设备身份不变。
|
|
78
|
+
const unxml = s => s.replaceAll('<','<').replaceAll('>','>').replaceAll('&','&');
|
|
79
|
+
export function programOf(file) {
|
|
80
|
+
try { const found = readFileSync(file,'utf8').match(/<key>ProgramArguments<\/key><array><string>([^<]*)<\/string>/); return found ? unxml(found[1]) : null; }
|
|
81
|
+
catch { return null; }
|
|
82
|
+
}
|
|
83
|
+
const currentBundle = () => dirname(dirname(macResources));
|
|
84
|
+
const elsewhere = file => { const program = programOf(file); return program !== null && !program.startsWith(currentBundle() + '/'); };
|
|
85
|
+
const launchdFiles = folder => [bootFile(folder), panelFile(folder), join(folder,'mac-worker.plist')];
|
|
86
|
+
export const moved = folder => launchdFiles(folder).some(elsewhere);
|
|
87
|
+
|
|
88
|
+
// 安装指南教用户建的命令行入口(一行 exec 应用内的 easy-agents),旧路径换成当前应用。
|
|
89
|
+
function relaunchers(old) {
|
|
90
|
+
for (const file of [join(homedir(),'.local/bin/easy-agents'), '/usr/local/bin/easy-agents', '/opt/homebrew/bin/easy-agents']) {
|
|
91
|
+
try {
|
|
92
|
+
const text = readFileSync(file, 'utf8');
|
|
93
|
+
if (text.length < 400 && text.includes('exec "' + old + '/Contents/Resources/easy-agents"'))
|
|
94
|
+
writeFileSync(file, text.replaceAll(old + '/Contents/Resources/', currentBundle() + '/Contents/Resources/'));
|
|
95
|
+
} catch {}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function relocate(folder) {
|
|
100
|
+
const stale = launchdFiles(folder).filter(elsewhere);
|
|
101
|
+
if (!stale.length) return '应用位置无需更新';
|
|
102
|
+
const old = stale.map(file => dirname(dirname(dirname(programOf(file))))).find(path => path.endsWith('.app'));
|
|
103
|
+
const running = job(folder).pid > 0;
|
|
104
|
+
await serviceCommand('stop', folder); // 先等当前任务回传
|
|
105
|
+
if (elsewhere(panelFile(folder))) writePanel(folder);
|
|
106
|
+
let bootKept = false;
|
|
107
|
+
if (elsewhere(bootFile(folder))) try {
|
|
108
|
+
const name = bootLabel(folder), target = bootFile(folder);
|
|
109
|
+
const data = Buffer.from(bootPlist(folder, macResources, userInfo().username, homedir())).toString('base64');
|
|
110
|
+
admin('set -eu; t=$(/usr/bin/mktemp /Library/LaunchDaemons/.' + name + '.XXXXXX); '
|
|
111
|
+
+ 'trap \'/bin/rm -f "$t"\' EXIT; /bin/echo ' + data + ' | /usr/bin/base64 -D > "$t"; /usr/bin/plutil -lint "$t" >/dev/null; '
|
|
112
|
+
+ '/usr/sbin/chown root:wheel "$t"; /bin/chmod 644 "$t"; /bin/mv -f "$t" ' + target + '; '
|
|
113
|
+
// 与“开机启动”开关一致:只改文件,下次开机生效;当前已载入的才重新载入(2026-11-23 本机实测时它没载入)。
|
|
114
|
+
+ 'if /bin/launchctl print system/' + name + ' >/dev/null 2>&1; then /bin/launchctl bootout system/' + name + '; /bin/launchctl bootstrap system ' + target + '; fi');
|
|
115
|
+
} catch { bootKept = true; } // 没给管理员授权:其余照常迁移,旧应用留着(开机配置还指着它)
|
|
116
|
+
const worker = join(folder,'mac-worker.plist');
|
|
117
|
+
if (elsewhere(worker)) {
|
|
118
|
+
if (lookup(service(folder)).loaded) launch('bootout', service(folder));
|
|
119
|
+
rmSync(worker, { force: true });
|
|
120
|
+
}
|
|
121
|
+
if (running && !job(folder).pid) await serviceCommand('start', folder); // 原来在跑的照原样拉起
|
|
122
|
+
if (old) relaunchers(old);
|
|
123
|
+
let note = '已改用当前应用:' + basename(currentBundle());
|
|
124
|
+
if (bootKept) note += ';开机启动未更新(没有管理员授权),旧应用先保留,请在面板关掉再打开开机启动后再删旧应用';
|
|
125
|
+
else if (old && old !== currentBundle() && existsSync(old)) {
|
|
126
|
+
try { renameSync(old, join(homedir(), '.Trash', basename(old) + '.' + Date.now())); note += ';旧应用已移到废纸篓'; }
|
|
127
|
+
catch { note += ';旧应用 ' + basename(old) + ' 请手动删除'; }
|
|
128
|
+
}
|
|
129
|
+
return note;
|
|
68
130
|
}
|
|
69
131
|
|
|
70
132
|
function admin(command) {
|
|
@@ -77,7 +139,7 @@ export function desktopStatus(folder) {
|
|
|
77
139
|
const { pid } = job(folder);
|
|
78
140
|
const saved = readSnapshot(folder, 'mac-worker.json');
|
|
79
141
|
const fresh = pid > 0 && saved?.pid === pid && Date.now() - saved.updated < 95000;
|
|
80
|
-
return { running: Boolean(pid), connected: Boolean(fresh && saved.connected), pid, terminalEnabled: terminalEnabled(folder), compactAt: compactAt(folder),
|
|
142
|
+
return { running: Boolean(pid), connected: Boolean(fresh && saved.connected), pid, terminalEnabled: terminalEnabled(folder), compactAt: compactAt(folder), moved: moved(folder),
|
|
81
143
|
report: saved || {}, task: fresh ? saved.task : null };
|
|
82
144
|
}
|
|
83
145
|
|