@zonease/aiworker-cli 0.1.0 → 0.2.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/README.md CHANGED
@@ -43,7 +43,7 @@ worker ─无凭证─────► /enroll-ws ──────► gatewa
43
43
 
44
44
  ## Install
45
45
 
46
- ### Published(待 FEAT-027 npm publish 上线启用)
46
+ ### Published
47
47
 
48
48
  ```sh
49
49
  bun install -g @zonease/aiworker-cli
@@ -52,12 +52,13 @@ bun install -g @zonease/aiworker-cli
52
52
  # curl -fsSL https://github.com/ZonEaseTech/aiworker/releases/latest/download/aiworker-linux-x64 -o /usr/local/bin/aiworker
53
53
  # chmod +x /usr/local/bin/aiworker
54
54
 
55
- aiworker serve
55
+ aiworker init # 首次 mint master key 写到 ~/.aiworker/.env
56
+ aiworker serve # 默认监听 :9217
56
57
  aiworker fleet list
57
58
  aiworker chat <workerId> 'hello'
58
59
  ```
59
60
 
60
- ### 本地开发(当前主路径)
61
+ ### 本地开发
61
62
 
62
63
  ```sh
63
64
  git clone <repo-url>
@@ -65,7 +66,7 @@ cd aiworker && bun install
65
66
  bun apps/cli/src/aiworker.ts <subcmd>
66
67
  ```
67
68
 
68
- 下面的 Quickstart / cheat sheet 用本地开发态 `bun apps/cli/src/aiworker.ts ...` 调用;Stage B 完成后等价改写为全局 `aiworker ...`,命令树不变。
69
+ 下面的 Quickstart / cheat sheet 默认用 `aiworker ...`(已发布命令);本地开发态等价 `bun apps/cli/src/aiworker.ts ...`。
69
70
 
70
71
  ---
71
72
 
@@ -91,26 +92,24 @@ worker deployer ─── 跑 aiworker serve ────────── 加
91
92
 
92
93
  ## 路径 1:OTP 入网(最简)
93
94
 
94
- ### Worker deployer(任何机器,**零 fleet 凭证**)
95
+ ### Worker deployer(任何机器,**零 fleet 凭证 + 零本地 secret 输入**)
95
96
 
96
97
  ```sh
97
- # 1. 装 bun
98
+ # 1. 装 bun(如果没装)
98
99
  curl -fsSL https://bun.sh/install | bash
99
100
 
100
- # 2. clone + install
101
- git clone <repo-url>
102
- cd aiworker && bun install
101
+ # 2. aiworker CLI
102
+ bun install -g @zonease/aiworker-cli
103
+ # npm install -g @zonease/aiworker-cli
103
104
 
104
- # 3. 最小 env
105
- export AIWORKER_HOME="$HOME/.aiworker"
106
- export AIWORKER_MASTER_KEY=$(openssl rand -hex 32) # worker 自己的 vault key
107
- export WORKER_DB_PATH="$AIWORKER_HOME/worker.db"
108
- export AIWORKER_GATEWAY_URL="wss://your-gateway.example/" # ← 仅这一个公网地址
109
- export AIWORKER_DISPLAY_NAME="my-laptop" # 可选
105
+ # 3. 第一次 init —— 自动 mint master key 写到 ~/.aiworker/.env (chmod 600),
106
+ # 控制台显示**一次**,请离线备份。
107
+ aiworker init
110
108
 
111
- # 4. init + serve
112
- bun apps/cli/src/aiworker.ts init
113
- bun apps/cli/src/aiworker.ts serve --port 3001
109
+ # 4. 启动 worker,指向你的 gateway(默认监听 :9217)
110
+ export AIWORKER_GATEWAY_URL="wss://your-gateway.example/"
111
+ export AIWORKER_DISPLAY_NAME="my-laptop" # 可选;默认取 hostname
112
+ aiworker serve
114
113
  ```
115
114
 
116
115
  控制台输出:
@@ -152,7 +151,7 @@ export AIWORKER_JOIN_TOKEN="<gateway 端配的 join token>"
152
151
  export AIWORKER_DISPLAY_NAME="ci-runner-12"
153
152
 
154
153
  bun apps/cli/src/aiworker.ts init
155
- bun apps/cli/src/aiworker.ts serve --port 3001
154
+ bun apps/cli/src/aiworker.ts serve --port 9217
156
155
  # 自动加入;operator 端 aiworker fleet list 直接见到
157
156
  ```
158
157
 
@@ -166,16 +165,16 @@ bun apps/cli/src/aiworker.ts serve --port 3001
166
165
  # Worker 端:
167
166
  bun apps/cli/src/aiworker.ts init
168
167
  # 抓 stdout 的 wtk_xxx
169
- bun apps/cli/src/aiworker.ts serve --port 3001 --gateway wss://operator:<pwd>@gateway/ws
168
+ bun apps/cli/src/aiworker.ts serve --port 9217 --gateway wss://operator:<pwd>@gateway/ws
170
169
 
171
170
  # Operator 端:
172
171
  aiworker pair --url wss://operator:<pwd>@gateway/ws \
173
- --worker-url http://<worker-host>:3001 \
172
+ --worker-url http://<worker-host>:9217 \
174
173
  --bootstrap-token wtk_xxx \
175
174
  --display-name production-1
176
175
  ```
177
176
 
178
- > 限制:gateway 必须能 inbound 到 worker `:3001` 验 token。worker 在 NAT 后需要反向 tunnel;改用 OTP 模式避坑。
177
+ > 限制:gateway 必须能 inbound 到 worker `:9217` 验 token。worker 在 NAT 后需要反向 tunnel;改用 OTP 模式避坑。
179
178
 
180
179
  ---
181
180
 
@@ -245,7 +244,7 @@ EOF
245
244
  chmod 600 ~/.aiworker/aim.json
246
245
  ```
247
246
 
248
- 如果在 gateway 同机跑(loopback),用 `ws://127.0.0.1:3000/ws`,无需 basicauth/token。
247
+ 如果在 gateway 同机跑(loopback),用 `ws://127.0.0.1:9218/ws`,无需 basicauth/token。
249
248
 
250
249
  ---
251
250
 
@@ -284,7 +283,8 @@ aiworker config set <workerId> "$NEW" --if-match <current-version>
284
283
  | `AIWORKER_HOME` | gateway / worker | 默认 `~/.aiworker` |
285
284
  | `WORKER_DB_PATH` | worker | 默认 `$AIWORKER_HOME/worker.db` |
286
285
  | `AIWORKER_FLEET_DB_PATH` | gateway | 默认 `$AIWORKER_HOME/fleet.db` |
287
- | `AIWORKER_GATEWAY_PORT` | gateway | 默认 3000 |
286
+ | `AIWORKER_GATEWAY_PORT` | gateway | 默认 `9218` |
287
+ | `PORT` | worker | 默认 `9217` |
288
288
  | `AIWORKER_ENROLL_OTP_TTL_SEC` | gateway | OTP 过期秒数,默认 300,[30, 3600] |
289
289
 
290
290
  完整列表见 `apps/api/.env.example` 与 `ops/compose/.env.example`。