@online-tools/agent-runner 0.0.0-stage → 0.0.1-alpha-1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tangpingchuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # @online-tools/agent-runner
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ GitCode 在线工具的 Agent 执行机器:把「在线 Agent」里的 **PR 描述 / Issue**、**代码检视(全量 / 快速)** 放到你自己的机器上运行,不占网站服务器的资源。
4
+
5
+ 程序只**主动连出**到网站(HTTPS),适用于没有公网 IP、在 NAT 或公司代理后面的机器;网站从不主动连接你的机器。
6
+
7
+ ## 安装与首次运行
8
+
9
+ 需要 Linux 或 macOS,Node.js 22.21+(或 24.5+、25+)。
10
+
11
+ ```bash
12
+ npm i -g @online-tools/agent-runner
13
+ gitcode-agent-runner # 首次运行:粘贴接入令牌 → 连接 → 检查并安装依赖 → 保持在线
14
+ gitcode-agent-runner service install # 可选:注册为后台服务,开机自启
15
+ ```
16
+
17
+ 接入令牌在网页「在线 Agent → 模型配置 → 接入令牌」里新建。粘贴后先向网站校验,通过才保存;以后启动直接连接。
18
+
19
+ 首次运行会检查依赖并列出要执行的安装命令,确认后才执行:
20
+
21
+ - `git`、`curl`、`python3`、`jq`、`sed`、`base64`:Skill 需要(各功能需要的不完全一样)
22
+ - `bubblewrap`、`socat`:Linux 上 Claude Code 沙箱需要(macOS 用系统自带的 Seatbelt)
23
+ - `claude`(`npm install -g @anthropic-ai/claude-code@latest`)
24
+
25
+ 拒绝安装或安装失败时程序照样接入,缺少的依赖只让用到它的功能不可用,网页上会显示原因。之后可以随时运行 `gitcode-agent-runner setup`。
26
+
27
+ 在网页「PR 描述 / Issue」「代码检视」页的「执行位置」里选择这台机器(或在「模型配置」里设为默认),任务就会在这里运行。
28
+
29
+ ## 命令
30
+
31
+ | 命令 | 作用 |
32
+ |---|---|
33
+ | `gitcode-agent-runner [start]` | 连接网站并等待任务 |
34
+ | `login [--new-id] [--token-stdin]` | 输入(更换)接入令牌,校验通过才保存。`--new-id` 重新生成机器标识;`--token-stdin` 从标准输入读令牌 |
35
+ | `logout` | 清除本机保存的令牌(机器标识保留) |
36
+ | `setup [--yes]` | 检查并安装缺少或版本过低的依赖(只在终端里运行;`--yes` 跳过确认) |
37
+ | `doctor [--json]` | 检查依赖、沙箱和各功能是否可用 |
38
+ | `status` | 网站地址、令牌前 12 位、机器标识、工作目录、服务状态和连接测试 |
39
+ | `service install \| uninstall \| status` | 后台服务:Linux 为 systemd 用户服务,macOS 为 launchd |
40
+ | `version` / `help` | — |
41
+
42
+ 全局选项:`--server <url>`(默认 `https://online-tools.closerouter.site`,会保存)、`--work-dir <dir>`(会保存)、`--allow-root`。
43
+
44
+ 文件位置:
45
+
46
+ - 配置:`${XDG_CONFIG_HOME:-~/.config}/gitcode-agent-runner/config.json`(0600)
47
+ - Skill 缓存:`${XDG_CACHE_HOME:-~/.cache}/gitcode-agent-runner/skills/`
48
+ - 工作目录:Linux `/var/tmp/gitcode-agent-runner-<uid>/`,macOS `$TMPDIR/gitcode-agent-runner/`。**不能在主目录之内**(沙箱不允许读取主目录)
49
+
50
+ ## 任务怎么运行
51
+
52
+ 网站只下发任务数据:任务文本、模型、你的模型 API Key、GitCode 授权、超时和 Skill 版本。claude 的命令行、环境变量、工具白名单和沙箱设置都由本程序生成,网站改不了。
53
+
54
+ 每个任务:
55
+
56
+ 1. 从网站下载这个版本的 Skill(逐个校验 sha256,缓存最近 3 个版本)
57
+ 2. 在工作目录下建立独立的运行目录
58
+ 3. 以独立进程组启动 `claude -p`,带上沙箱设置(`--settings`),超时由本程序执行
59
+ 4. 把 claude 的输出按顺序回传网站,结束后删除运行目录
60
+
61
+ 沙箱设置:
62
+
63
+ - 沙箱必须可用(`failIfUnavailable`),起不来时任务失败,**不会退化为不进沙箱运行**;模型要求「不进沙箱运行命令」一律被忽略
64
+ - 网络只允许 `gitcode.com`、`*.gitcode.com`(claude 自己访问模型 API 不受影响)
65
+ - 不能读写你的主目录(PATH 里位于主目录的目录除外,只读),不能改写 Skill 副本和设置;只能写本次任务的工作目录
66
+ - 沙箱里的命令看不到模型 API Key;hooks 一律关闭
67
+
68
+ ## 安全须知
69
+
70
+ - 选择执行机器运行任务时,你的**模型 API Key 和 GitCode 授权会发送到这台机器**,只注入本次任务的 claude 进程,不写入文件或日志。
71
+ - **建议用一个专用的低权限账号运行本程序**。沙箱之外、主目录之外的可读文件仍然可能被读到;GitCode 本身在网络白名单里。
72
+ - 程序拒绝以 root 运行(容器里确有需要时加 `--allow-root`)。
73
+ - 接入令牌只能用来接入机器,不能登录网页。**令牌泄露时在网页上删除它**,用它接入的机器会立即断开;之后新建令牌,在需要的机器上运行 `gitcode-agent-runner login`。网页上的「封禁」只针对单台机器,拿到令牌的人可以换个标识重新接入,所以防泄露要靠删除令牌。
74
+ - 有新机器接入时网页会提示;不是你的机器请封禁或删除令牌。
75
+ - 本程序没有任何依赖和安装脚本。
76
+
77
+ ## 日常维护
78
+
79
+ | 场景 | 操作 |
80
+ |---|---|
81
+ | 更新程序 | `npm i -g @online-tools/agent-runner@latest`,然后重启程序或服务(`systemctl --user restart gitcode-agent-runner`)。网页上会提示「有新版本」或「版本过低」 |
82
+ | 令牌泄露 | 在网页上删除该令牌,新建令牌后运行 `gitcode-agent-runner login` |
83
+ | 复制了配置 / 克隆了虚拟机 | 在复制出来的那台上运行 `gitcode-agent-runner login --new-id` |
84
+ | 退出登录后服务停止(Linux) | 让管理员执行一次 `loginctl enable-linger <用户名>` |
85
+ | 查看日志 | `journalctl --user -u gitcode-agent-runner -f`,或 macOS 的 `~/Library/Logs/gitcode-agent-runner.log` |
86
+
87
+ 退出码:0 正常退出;1 出错;78 需要人处理(没有令牌、令牌已删除、机器已封禁、同一配置在两台机器上运行、系统或 Node 不支持、以 root 运行、已有实例在运行),后台服务遇到 78 不会自动重启。
88
+
89
+ 沙箱不可用时请先运行 `gitcode-agent-runner setup`;在非特权容器或禁用了非特权 user namespace 的系统(例如开启了 AppArmor 限制的 Ubuntu 24.04+)上沙箱可能无法启动,详见 https://code.claude.com/docs/en/sandboxing 。
90
+
91
+ ## 卸载
92
+
93
+ ```bash
94
+ gitcode-agent-runner service uninstall
95
+ gitcode-agent-runner logout
96
+ npm rm -g @online-tools/agent-runner
97
+ ```
98
+
99
+ 最后在网页「在线 Agent → 模型配置 → 执行机器」里移除这台机器。
100
+
101
+ ## 许可证
102
+
103
+ MIT