tmailcli 0.0.0-stage → 0.1.4
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 +88 -2
- package/bin/darwin-arm64/tmailcli +0 -0
- package/bin/linux-x64/tmailcli +0 -0
- package/bin/tmailcli.js +31 -0
- package/bin/win32-x64/tmailcli.exe +0 -0
- package/package.json +20 -4
- package/scripts/install.js +34 -0
package/README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tmailcli npm 包
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
这个 npm 包内置 `tmailcli` Go 二进制,支持 Windows x64、macOS arm64 和
|
|
4
|
+
Linux x64。安装时由 npm 生命周期脚本选择当前平台的二进制,不需要访问
|
|
5
|
+
公共二进制镜像。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
需要 Node.js 18+。从私有源安装已发布的包:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install --global tmailcli --registry https://nexus.tul.cn/repository/npm-releases/
|
|
13
|
+
tmailcli --version
|
|
14
|
+
tmailcli --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
从私有源安装无需 npm 认证。官方源版本经维护者批准上线后,也可以使用:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install --global tmailcli --registry https://registry.npmjs.org/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 正式默认配置
|
|
24
|
+
|
|
25
|
+
- 授权平台:`https://ai.tul.cn/tmail/`
|
|
26
|
+
- U-Mail API:`https://mail.tul.com.cn/api/v1`
|
|
27
|
+
- OAuth 客户端 ID:`tmailcli`
|
|
28
|
+
|
|
29
|
+
环境变量名称和默认客户端 ID:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
export TMAILCLI_PLATFORM_URL="https://ai.tul.cn/tmail/"
|
|
33
|
+
export TMAILCLI_URL="https://mail.tul.com.cn/api/v1"
|
|
34
|
+
export TMAILCLI_CLIENT_ID="tmailcli"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
如需绑定或解绑邮箱,或查看中转平台侧的邮箱绑定情况,请替用户打开中转平台:
|
|
38
|
+
<https://ai.tul.cn/tmail/>。CLI 授权命令管理本机客户端授权记录,不替代中转平台的绑定页面。
|
|
39
|
+
必须使用用户本机的操作系统默认浏览器,不使用 agent 内置浏览器、网页工具或远程浏览器。
|
|
40
|
+
|
|
41
|
+
## 多邮箱授权
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
tmailcli auth add
|
|
45
|
+
tmailcli auth ls
|
|
46
|
+
tmailcli auth su work@example.com
|
|
47
|
+
tmailcli auth whoami
|
|
48
|
+
tmailcli auth status
|
|
49
|
+
tmailcli --account work@example.com msg ls
|
|
50
|
+
tmailcli auth rm work@example.com
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`auth add` 通过浏览器授权添加邮箱并切为当前邮箱;同一地址再次授权会更新
|
|
54
|
+
凭据。`auth ls` 标记当前邮箱,`auth su <addr>` 持久切换,`auth whoami`
|
|
55
|
+
输出生效邮箱 JSON,`auth status` 查看详细授权状态。
|
|
56
|
+
`--account <addr>` 临时指定邮件命令、`auth status` 或 `auth whoami` 使用的
|
|
57
|
+
邮箱。`auth rm <addr>` 撤销远端授权并删除本地凭据;删除当前邮箱后需
|
|
58
|
+
重新选择。升级后运行 `auth add` 重新添加邮箱,旧单邮箱凭据保留在原存储中。
|
|
59
|
+
|
|
60
|
+
使用 `auth --help` 查看授权命令。旧裸 `auth`、`auth login`、`auth logout`
|
|
61
|
+
以及 `TMAILCLI_PROFILE`、`UMAIL_PROFILE` 已弃用;选择邮箱使用 `auth su`
|
|
62
|
+
或 `--account`。
|
|
63
|
+
|
|
64
|
+
## 源码构建与发布
|
|
65
|
+
|
|
66
|
+
构建和发布需要完整源码仓库,操作步骤见源码仓库根目录的 `README.md`,
|
|
67
|
+
其中包含私有源发布和官方源 staged publishing 的手动流程。
|
|
68
|
+
源码仓库中的 `npm/` 是分发包目录;打包脚本位于仓库根目录的 `scripts/`。
|
|
69
|
+
|
|
70
|
+
## Skill 安装
|
|
71
|
+
|
|
72
|
+
调用方 agent 必须按本节指令安装 `tmailcli` skill,并在使用 CLI 前读取安装后的
|
|
73
|
+
`tmailcli/SKILL.md`。只安装 npm 二进制而跳过 skill 安装是不完整的集成。
|
|
74
|
+
|
|
75
|
+
`postinstall` 会调用内置 CLI 安装 `tmailcli` skill,过程无需联网。
|
|
76
|
+
建议调用方 agent 显式传入自己的 skills 根目录:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
tmailcli install-skill --dir /path/to/agent/skills
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
skill 写入该目录下的 `tmailcli/`。目录优先使用 `--dir`,其次使用
|
|
83
|
+
`TMAILCLI_SKILLS_DIR`;默认安装到 `~/.agents/skills` 及已检测到的
|
|
84
|
+
Claude、OpenClaw skills 目录,并遵循显式配置的 `CODEX_HOME`。
|
|
85
|
+
|
|
86
|
+
npm 安装时可设置 `TMAILCLI_SKILLS_DIR` 指定目录,或设置
|
|
87
|
+
`TMAILCLI_SKIP_SKILLS=1` 跳过 skill 安装。使用 `npm --ignore-scripts` 后,
|
|
88
|
+
可运行上述命令补装。skill 安装失败会使 `postinstall` 失败;按报错修复
|
|
89
|
+
目录权限或指定可写目录后,重新安装 npm 包或手动补装即可。
|
|
Binary file
|
|
Binary file
|
package/bin/tmailcli.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { spawnSync } = require('node:child_process');
|
|
6
|
+
|
|
7
|
+
const targets = {
|
|
8
|
+
'win32-x64': 'win32-x64/tmailcli.exe',
|
|
9
|
+
'darwin-arm64': 'darwin-arm64/tmailcli',
|
|
10
|
+
'linux-x64': 'linux-x64/tmailcli',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const target = targets[`${process.platform}-${process.arch}`];
|
|
14
|
+
if (!target) {
|
|
15
|
+
console.error(`tmailcli does not provide a binary for ${process.platform}/${process.arch}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const executable = path.join(__dirname, target);
|
|
20
|
+
if (!fs.existsSync(executable)) {
|
|
21
|
+
console.error(`The tmailcli package is missing its ${process.platform}/${process.arch} binary.`);
|
|
22
|
+
console.error('Reinstall tmailcli from your npm registry for this platform.');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const result = spawnSync(executable, process.argv.slice(2), { stdio: 'inherit' });
|
|
27
|
+
if (result.error) {
|
|
28
|
+
console.error(`Cannot start tmailcli: ${result.error.message}`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tmailcli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Command-line client for U-Mail",
|
|
5
|
+
"bin": {
|
|
6
|
+
"tmailcli": "bin/tmailcli.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"scripts/install.js",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"registry": "https://nexus.tul.cn/repository/npm-releases/"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"postinstall": "node scripts/install.js"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { spawnSync } = require('node:child_process');
|
|
4
|
+
|
|
5
|
+
const target = `${process.platform}-${process.arch}`;
|
|
6
|
+
const files = {
|
|
7
|
+
'win32-x64': 'win32-x64/tmailcli.exe',
|
|
8
|
+
'darwin-arm64': 'darwin-arm64/tmailcli',
|
|
9
|
+
'linux-x64': 'linux-x64/tmailcli',
|
|
10
|
+
};
|
|
11
|
+
const relativePath = files[target];
|
|
12
|
+
|
|
13
|
+
if (!relativePath) {
|
|
14
|
+
throw new Error(`tmailcli does not provide a binary for ${process.platform}/${process.arch}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const executable = path.join(__dirname, '..', 'bin', relativePath);
|
|
18
|
+
if (!fs.existsSync(executable)) {
|
|
19
|
+
throw new Error(`The tmailcli package is missing its ${target} binary`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (process.platform !== 'win32') {
|
|
23
|
+
fs.chmodSync(executable, 0o755);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (process.env.TMAILCLI_SKIP_SKILLS !== '1') {
|
|
27
|
+
const result = spawnSync(executable, ['install-skill'], { stdio: 'inherit' });
|
|
28
|
+
if (result.error || result.status !== 0) {
|
|
29
|
+
console.error(`Cannot install tmailcli skills: ${result.error ? result.error.message : `exit code ${result.status}`}`);
|
|
30
|
+
console.error('Retry with tmailcli install-skill --dir <your-agent-skills-directory>.');
|
|
31
|
+
console.error('Set TMAILCLI_SKIP_SKILLS=1 to install the npm package without skills.');
|
|
32
|
+
process.exit(result.status || 1);
|
|
33
|
+
}
|
|
34
|
+
}
|