alink-cli 0.1.3 → 0.4.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 CHANGED
@@ -25,8 +25,20 @@ npx alink-cli
25
25
  | `--token <token>` | 机器凭证(控制台生成的 `al1.…` 整串)。也可用环境变量 `AGENTLINK_TOKEN` 提供(`--token` 优先)。 | 依次取 `AGENTLINK_TOKEN` → `~/.agentlink/credential` |
26
26
  | `--hub <wss://…>` | 要连接的 hub 地址。 | `wss://link.harmopath.com`(官方 hub) |
27
27
  | `--dir <path>` | 工作目录根,可重复给多次;运行时可用其下任意子目录,网页里以目录树浏览。 | 当前目录 `process.cwd()` |
28
+ | `--tunnel` | 不连任何 hub:本地起一个 hub + 免费 Cloudflare 隧道,打印公网链接(需 `cloudflared`)。与 `--hub` 互斥。 | — |
28
29
  | `--help`, `-h` | 显示用法。 | — |
29
30
 
31
+ ## 自建 hub Self-hosting
32
+
33
+ 连自己的 [agentlink-hub](https://www.npmjs.com/package/agentlink-hub) 时给 `--hub` 即可;单租户 hub 不需要预先铸凭证——不带 `--token` 时会自动生成一个并打印访问链接:
34
+
35
+ ```bash
36
+ npx alink-cli --hub wss://your-host:8080
37
+ # → prints: open https://your-host:8080/?token=<uuid>
38
+ ```
39
+
40
+ Point `--hub` at your own hub to skip the official one entirely. Against a single-tenant hub no minted credential is needed — without `--token` a fresh one is generated and the access link printed. The connection is **outbound** (works behind NAT, no port forwarding) and reconnects automatically; use `wss://` (TLS) for anything public.
41
+
30
42
  ## 凭证与端到端加密 Credential & E2EE
31
43
 
32
44
  凭证是这台机器的**远程执行凭据**,请妥善保管:公网请务必用 `wss://`(TLS)。多租户凭证(`al1.` 前缀)里的第四段是端到端加密(E2EE)主密钥——它**只留在本机、从不上网**,daemon 把它单独归档到 `~/.agentlink/enckeys.json`(`0600`),hub 永远只看到密文。撤销某台机器:在控制台里重新添加即可让旧凭证失效。
package/bin/agentlink.js CHANGED
@@ -114,7 +114,8 @@ if (explicitToken) {
114
114
  const saved = readCredentialFile();
115
115
  if (saved) {
116
116
  process.env.AGENTLINK_TOKEN = saved;
117
- } else if (!hasFlag("hub") || flagValue("hub") === OFFICIAL_HUB) {
117
+ } else if (!tunnelMode && (!hasFlag("hub") || flagValue("hub") === OFFICIAL_HUB)) {
118
+ // --tunnel 与自建 --hub 不需要预铸凭证:daemon 自己生成 token 并打印链接。
118
119
  // 什么凭证都没有且连的是官方 hub:直接给指引并退出——否则 daemon 会生成
119
120
  // 随机 token 去连 multi hub 然后被 4401 拒,报错对新用户完全不可解。
120
121
  // (自建 --hub 的 single 模式仍保留旧行为:daemon 自己生成 token 并打印。)
@@ -169,6 +170,8 @@ function printHelp() {
169
170
  ` AGENTLINK_TOKEN 提供(--token 优先)。`,
170
171
  ` --hub <url> hub 地址,缺省官方 hub ${OFFICIAL_HUB}。`,
171
172
  ` --dir <path> 工作目录根,可重复;缺省当前目录。运行时可用其下任意子目录。`,
173
+ ` --tunnel 不连任何 hub:本地起 hub + 免费 Cloudflare 隧道并打印公网链接`,
174
+ ` (需已安装 cloudflared)。与 --hub 互斥。`,
172
175
  ` --help, -h 显示本帮助。`,
173
176
  ``,
174
177
  `示例:`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alink-cli",
3
- "version": "0.1.3",
3
+ "version": "0.4.0",
4
4
  "description": "一条命令把工作机接入 AgentLink,随时随地遥控本机的编码 agent。One command to link your machine to AgentLink and control your coding agents from anywhere.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,7 +23,8 @@
23
23
  "joycode",
24
24
  "coding-agent",
25
25
  "remote-control",
26
- "cli"
26
+ "cli",
27
+ "self-hosted"
27
28
  ],
28
29
  "type": "module",
29
30
  "bin": {
@@ -35,10 +36,17 @@
35
36
  "README.md"
36
37
  ],
37
38
  "scripts": {
38
- "build": "esbuild ../daemon/src/main.ts --bundle --platform=node --format=esm --outfile=dist/daemon.js --external:bufferutil --external:utf-8-validate --banner:js=\"import { createRequire as __agentlinkRequire } from 'module'; const require = __agentlinkRequire(import.meta.url);\" && esbuild qr-entry.js --bundle --platform=node --format=esm --outfile=dist/qr.js"
39
+ "build": "esbuild src/main.ts --bundle --platform=node --format=esm --outfile=dist/daemon.js --external:bufferutil --external:utf-8-validate --banner:js=\"import { createRequire as __agentlinkRequire } from 'module'; const require = __agentlinkRequire(import.meta.url);\" && esbuild qr-entry.js --bundle --platform=node --format=esm --outfile=dist/qr.js",
40
+ "typecheck": "tsc",
41
+ "test": "npm run build && node test/self-test.js && node test/multi-tenant-test.js && node test/e2e-test.js",
42
+ "test:real": "npm run build && node test/real-run.js"
39
43
  },
40
44
  "devDependencies": {
45
+ "@types/node": "^24.0.0",
46
+ "@types/ws": "^8.5.0",
41
47
  "esbuild": "^0.25.0",
42
- "qrcode-terminal": "^0.12.0"
48
+ "qrcode-terminal": "^0.12.0",
49
+ "typescript": "^5.8.0",
50
+ "ws": "^8.18.0"
43
51
  }
44
52
  }