@runweave/server 0.0.0-stage → 0.1.0
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 +60 -2
- package/bin/runtime.cjs +95 -0
- package/package.json +28 -4
package/README.md
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Runweave Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
通过 NPM 安装的独立 Runweave 后台,包含 Backend、App Server 和网页;独立的 `@runweave/cli` 提供唯一的 rw 命令。
|
|
4
|
+
安装机器需要 Node 22;终端需要 tmux,Git 和 Agent CLI 根据所用功能单独安装及认证。
|
|
5
|
+
不需要 Electron、项目源码或编译工具链。当前支持目标为 macOS arm64/x64、Linux glibc arm64/x64;
|
|
6
|
+
每个目标必须先经过实际发布构建与安装验证。Windows、musl 和其他 Node ABI 不在第一阶段范围内。
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install -g @runweave/cli @runweave/server
|
|
10
|
+
rw server init
|
|
11
|
+
rw server doctor --json
|
|
12
|
+
rw server start
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
交互初始化生成强密码,显示一次,请保存。非交互初始化使用仅当前用户可读的绝对路径 JSON 文件,
|
|
16
|
+
内容为 username、password(至少 16 字符):
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
rw server init --auth-file /absolute/private-auth.json --host 0.0.0.0 --port 5001
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
独立服务使用 Activity 目录中仅当前服务用户可读的文件密钥,避免依赖 macOS 登录 Keychain;已有数据缺少原密钥时拒绝重建。
|
|
23
|
+
初始化不会覆盖已有配置,默认监听 127.0.0.1:5001。打开该地址可使用网页;桌面端通过现有连接功能接入。
|
|
24
|
+
远程访问需自行配置网络与 HTTPS/WSS。不包含 Electron 内嵌 Browser、原生远控 Host 或跨网中继。
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
rw server service install # 安装系统服务、启用开机启动并启动;需要管理员权限
|
|
28
|
+
rw server status --json
|
|
29
|
+
rw server logs --follow
|
|
30
|
+
rw server restart
|
|
31
|
+
rw server stop
|
|
32
|
+
rw server start
|
|
33
|
+
rw server update
|
|
34
|
+
rw server update --version 0.1.0
|
|
35
|
+
rw server update --force
|
|
36
|
+
rw server service uninstall # 注销并停止,保留配置与数据
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
后台用 systemd 或 launchd 分别托管两个组件,异常重启限速;前台错误会退出。
|
|
40
|
+
普通 tmux 任务在重启期间保留,连接暂断;依赖后台 API 的请求仍可能失败。
|
|
41
|
+
有服务托管执行时更新和重启默认拒绝,force 明确取消这些执行后继续。
|
|
42
|
+
排队或已持久化等待记录本身不会阻挡更新。更新失败保留日志和数据,不自动回退。
|
|
43
|
+
指定旧版本只允许数据合同兼容的版本,第一阶段使用保守的存储源码指纹校验,不执行逆向数据迁移。
|
|
44
|
+
|
|
45
|
+
运行文件放在配置目录下的 server/releases,数据和凭据使用现有配置路径,均在 npm 包目录之外。
|
|
46
|
+
直接 npm 全局安装新版本不会自动替换运行进程,使用 rw server update 激活。
|
|
47
|
+
Server 更新不会替换 CLI 或全局 rw。更新中断时查看 server/update.json,必要时重新安装分发包,再用 rw server update 恢复。
|
|
48
|
+
全局 npm 前缀需要当前用户可写,更新不会自动提升 npm 权限。
|
|
49
|
+
|
|
50
|
+
服务管理命令适用于一台机器一个 Stable 服务。安装前台与系统托管不得并存;已有桌面后台的共存/迁移暂不支持。
|
|
51
|
+
|
|
52
|
+
源码构建产物与 NPM 使用相同的激活路径:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
pnpm server:build
|
|
56
|
+
rw server update --server-package /absolute/repo/.runtime-artifacts/server/package
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
首次使用源码产物时,可在 `rw server init` 指定相同的 `--server-package`。
|
|
60
|
+
CLI 先查私有安装记录,再查同一全局前缀中的 Server 包,最后查询 npm 全局目录;不会按当前工作目录猜测源码。
|
|
61
|
+
Server 不注册 rw,也不携带 CLI;两个包通过 managementApiVersion=1 的管理合同配合,可独立升级。
|
package/bin/runtime.cjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS bootstrap must load the immutable CJS runtime without ESM resolution into npm replacement paths. */
|
|
2
|
+
"use strict";
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const crypto = require("node:crypto");
|
|
6
|
+
const { execFileSync } = require("node:child_process");
|
|
7
|
+
const { createRequire } = require("node:module");
|
|
8
|
+
function materialize(installed, home) {
|
|
9
|
+
{
|
|
10
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
11
|
+
let native;
|
|
12
|
+
try {
|
|
13
|
+
native = path.dirname(
|
|
14
|
+
createRequire(path.join(installed, "package.json")).resolve(
|
|
15
|
+
`@runweave/server-${platform}/package.json`,
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
|
20
|
+
// The source builder emits the same package next to its platform payload.
|
|
21
|
+
native = path.resolve(installed, "..", platform);
|
|
22
|
+
}
|
|
23
|
+
const pkg = JSON.parse(
|
|
24
|
+
fs.readFileSync(path.join(installed, "package.json"), "utf8"),
|
|
25
|
+
);
|
|
26
|
+
const nativePkg = JSON.parse(
|
|
27
|
+
fs.readFileSync(path.join(native, "package.json"), "utf8"),
|
|
28
|
+
);
|
|
29
|
+
if (
|
|
30
|
+
pkg.name !== "@runweave/server" ||
|
|
31
|
+
nativePkg.name !== `@runweave/server-${platform}` ||
|
|
32
|
+
pkg.version !== nativePkg.version
|
|
33
|
+
)
|
|
34
|
+
throw new Error("Server/platform package identity mismatch");
|
|
35
|
+
const manifest = JSON.parse(
|
|
36
|
+
fs.readFileSync(path.join(native, "manifest.json"), "utf8"),
|
|
37
|
+
);
|
|
38
|
+
if (
|
|
39
|
+
manifest.managementApiVersion !== 1 ||
|
|
40
|
+
manifest.version !== pkg.version ||
|
|
41
|
+
manifest.platform !== process.platform ||
|
|
42
|
+
manifest.arch !== process.arch ||
|
|
43
|
+
manifest.nodeModuleAbi !== process.versions.modules
|
|
44
|
+
)
|
|
45
|
+
throw new Error("Platform package does not match this Node ABI");
|
|
46
|
+
if (
|
|
47
|
+
process.platform === "linux" &&
|
|
48
|
+
!process.report.getReport().header.glibcVersionRuntime
|
|
49
|
+
)
|
|
50
|
+
throw new Error("Linux glibc is required");
|
|
51
|
+
const releases = path.join(home, "releases");
|
|
52
|
+
fs.mkdirSync(releases, { recursive: true, mode: 0o700 });
|
|
53
|
+
const stage = fs.mkdtempSync(path.join(releases, ".stage-"));
|
|
54
|
+
try {
|
|
55
|
+
fs.cpSync(path.join(native, "payload"), stage, { recursive: true });
|
|
56
|
+
const archive = path.join(native, "native.tar.gz");
|
|
57
|
+
const entries = execFileSync("tar", ["-tzf", archive], {
|
|
58
|
+
encoding: "utf8",
|
|
59
|
+
})
|
|
60
|
+
.trim()
|
|
61
|
+
.split("\n");
|
|
62
|
+
if (
|
|
63
|
+
entries.some(
|
|
64
|
+
(entry) => path.isAbsolute(entry) || entry.split("/").includes(".."),
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
throw new Error("Unsafe native archive");
|
|
68
|
+
execFileSync("tar", ["-xzf", archive, "-C", stage]);
|
|
69
|
+
fs.copyFileSync(
|
|
70
|
+
path.join(native, "manifest.json"),
|
|
71
|
+
path.join(stage, "server-manifest.json"),
|
|
72
|
+
);
|
|
73
|
+
for (const file of manifest.files) {
|
|
74
|
+
if (path.isAbsolute(file.path) || file.path.split("/").includes(".."))
|
|
75
|
+
throw new Error("Unsafe release path");
|
|
76
|
+
const bytes = fs.readFileSync(path.join(stage, file.path));
|
|
77
|
+
if (
|
|
78
|
+
bytes.length !== file.size ||
|
|
79
|
+
crypto.createHash("sha256").update(bytes).digest("hex") !==
|
|
80
|
+
file.sha256
|
|
81
|
+
)
|
|
82
|
+
throw new Error(`Release checksum mismatch: ${file.path}`);
|
|
83
|
+
}
|
|
84
|
+
const release = path.join(
|
|
85
|
+
releases,
|
|
86
|
+
`${manifest.version}-${crypto.createHash("sha256").update(JSON.stringify(manifest)).digest("hex").slice(0, 16)}`,
|
|
87
|
+
);
|
|
88
|
+
if (!fs.existsSync(release)) fs.renameSync(stage, release);
|
|
89
|
+
return release;
|
|
90
|
+
} finally {
|
|
91
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
module.exports = { materialize };
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runweave/server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standalone Runweave Backend, App Server and web resources",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"bin",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=22 <23"
|
|
12
|
+
},
|
|
13
|
+
"os": [
|
|
14
|
+
"darwin",
|
|
15
|
+
"linux"
|
|
16
|
+
],
|
|
17
|
+
"main": "bin/runtime.cjs",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@runweave/config-node": "workspace:*",
|
|
20
|
+
"@runweave/shared": "workspace:*",
|
|
21
|
+
"@types/node": "^22.13.10",
|
|
22
|
+
"esbuild": "^0.25.0"
|
|
23
|
+
},
|
|
24
|
+
"optionalDependencies": {
|
|
25
|
+
"@runweave/server-darwin-arm64": "0.1.0",
|
|
26
|
+
"@runweave/server-darwin-x64": "0.1.0",
|
|
27
|
+
"@runweave/server-linux-arm64": "0.1.0",
|
|
28
|
+
"@runweave/server-linux-x64": "0.1.0"
|
|
29
|
+
}
|
|
30
|
+
}
|