@nexum-hub/agent 0.0.3-next.12 → 0.0.3-next.13
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 +1 -1
- package/package.json +1 -1
- package/scripts/npm-install.mjs +40 -14
- package/scripts/service.mjs +3 -0
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ Agent 的 `nexum-agent` CLI 命令名称保留;npm 分发不意味着已注册
|
|
|
57
57
|
|
|
58
58
|
### Cloud 一键安装与强制版本更新(本地实现候选)
|
|
59
59
|
|
|
60
|
-
用户应从相应 Nexum Cloud 的 Agent 创建或详情页面复制平台专用安装命令,不需要在终端自行选择 npm 通道。Cloud 使用 `production → latest` 或 `development → next` 映射,命令包含当前 Server URL、长期 Agent Token、profile 以及 **Cloud 已确认的精确目标版本**。安装命令调用 Cloud 提供的 `/agent/install.sh`(macOS/Linux)或 `/agent/install.ps1`(Windows
|
|
60
|
+
用户应从相应 Nexum Cloud 的 Agent 创建或详情页面复制平台专用安装命令,不需要在终端自行选择 npm 通道。Cloud 使用 `production → latest` 或 `development → next` 映射,命令包含当前 Server URL、长期 Agent Token、profile 以及 **Cloud 已确认的精确目标版本**。安装命令调用 Cloud 提供的 `/agent/install.sh`(macOS/Linux)或 `/agent/install.ps1`(Windows);引导脚本仅复用当前 profile 的 `program/runtime` 里 Node.js 24.22.1 与完整 npm/npx,**不寻找系统 Node 或 nvm**;首次安装及缺少受管运行时时下载固定版本,并核验官方 SHA-256。大陆时区优先国内 Node/npm 源,Node 下载失败回退官方源;自动升级的 npm 包解析也有官方 Registry 回退。Agent 程序、固定 Node/npm、私有配置以及服务启动器落在所选用户 profile,分别注册 LaunchAgent、systemd user service 或 InteractiveToken 用户任务;Windows 任务以隐藏窗口启动,不依赖安装 PowerShell 窗口;默认登录自启,异常退出按各平台有界策略重试,不承诺用户未登录时启动。
|
|
61
61
|
|
|
62
62
|
后台服务不在每次启动时运行 npx;它通过本地 `program/service-runner.mjs` 执行 `active.json` 指向的确定版本。Cloud 启动时必须成功从 npm 查询最新版本,运行期间由管理员手动「刷新 Agent 版本」;旧版 Agent 的 WSS 被断开,在下一次握手收到 `426 upgrade_required` 和目标精确版本。Agent 写入待升级状态、退出旧进程,启动器在没有旧进程占用时由 npm 下载和准备新程序,再切换 `active.json`、启动新进程。升级失败保留旧版本与 Token/本地记录,但 Cloud 不允许旧版重新上线。此流程已经接线并进行本机隔离测试,**未发布包含这些新安装脚本的 npm 版本,亦未完成三平台真实用户安装/登录恢复/更新和生产上线验收**;不可把当前 Registry 旧包视为已交付该新 CLI。
|
|
63
63
|
|
package/package.json
CHANGED
package/scripts/npm-install.mjs
CHANGED
|
@@ -33,6 +33,22 @@ const npmBin = (root) =>
|
|
|
33
33
|
? "node_modules/npm/bin/npm-cli.js"
|
|
34
34
|
: "lib/node_modules/npm/bin/npm-cli.js",
|
|
35
35
|
);
|
|
36
|
+
// Mainland timezone IDs, not an ambiguous UTC+8 offset, select the China mirror.
|
|
37
|
+
export function npmRegistries(
|
|
38
|
+
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
39
|
+
) {
|
|
40
|
+
const mainland = [
|
|
41
|
+
"Asia/Shanghai",
|
|
42
|
+
"Asia/Chongqing",
|
|
43
|
+
"Asia/Harbin",
|
|
44
|
+
"Asia/Urumqi",
|
|
45
|
+
"PRC",
|
|
46
|
+
].includes(timeZone);
|
|
47
|
+
return [
|
|
48
|
+
...(mainland ? ["https://registry.npmmirror.com/"] : []),
|
|
49
|
+
"https://registry.npmjs.org/",
|
|
50
|
+
];
|
|
51
|
+
}
|
|
36
52
|
const fail = (condition, reason) => {
|
|
37
53
|
if (!condition) throw new Error(reason);
|
|
38
54
|
};
|
|
@@ -159,20 +175,30 @@ async function packageStage(stage, version, managedNode, source) {
|
|
|
159
175
|
const scratch = path.join(stage, ".resolve");
|
|
160
176
|
let from = source;
|
|
161
177
|
if (!from) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
const registries = npmRegistries();
|
|
179
|
+
for (const [index, registry] of registries.entries()) {
|
|
180
|
+
// Retry package resolution only; the Agent is activated after this stage.
|
|
181
|
+
await rm(scratch, { recursive: true, force: true });
|
|
182
|
+
await directory(scratch);
|
|
183
|
+
try {
|
|
184
|
+
exec(nodeBin(managedNode), [
|
|
185
|
+
npmBin(managedNode),
|
|
186
|
+
"install",
|
|
187
|
+
"--prefix",
|
|
188
|
+
scratch,
|
|
189
|
+
"--no-save",
|
|
190
|
+
"--no-package-lock",
|
|
191
|
+
"--omit=dev",
|
|
192
|
+
"--no-audit",
|
|
193
|
+
"--no-fund",
|
|
194
|
+
`--registry=${registry}`,
|
|
195
|
+
`@nexum-hub/agent@${version}`,
|
|
196
|
+
]);
|
|
197
|
+
break;
|
|
198
|
+
} catch (error) {
|
|
199
|
+
if (index === registries.length - 1) throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
176
202
|
from = path.join(scratch, "node_modules", "@nexum-hub", "agent");
|
|
177
203
|
}
|
|
178
204
|
const manifest = JSON.parse(
|
package/scripts/service.mjs
CHANGED