@angelmsger/wecom-channel-cli 0.0.0-stage → 0.2.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/LICENSE +22 -0
- package/README.md +28 -2
- package/bin/wecom-channel-cli.js +14 -0
- package/install.js +101 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AngelMsger
|
|
4
|
+
Copyright (c) 2026 wecom-channel-cli contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WeCom Channel CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An independent channel connector for agents. Named channel contexts, a protected
|
|
4
|
+
credential broker, polling without public ingress, optional authenticated
|
|
5
|
+
callbacks, native emoji reactions, and exact-intent operator approvals.
|
|
6
|
+
|
|
7
|
+
Install or upgrade:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g @angelmsger/wecom-channel-cli@0.2.0
|
|
11
|
+
wecom-channel-cli auth guide
|
|
12
|
+
wecom-channel-cli skill install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
For initial operator setup, supply `WECOM_CHANNEL_BOT_SECRET` locally and run
|
|
16
|
+
`wecom-channel-cli channel list --bot-id BOT_ID` before configuring a channel.
|
|
17
|
+
Choose `data.topic_id`, generate policy with `config example --bot-id BOT_ID
|
|
18
|
+
--channel CHANNEL_ID`, then provision the broker and matching client context.
|
|
19
|
+
Normal `channel list` uses the configured broker socket.
|
|
20
|
+
|
|
21
|
+
Reload the agent context after refreshing the Skill. Operator provisioning and
|
|
22
|
+
OS isolation are required before unattended use. Installation downloads the
|
|
23
|
+
matching Linux/macOS binary and requires a valid SHA-256 checksum manifest.
|
|
24
|
+
The launcher never downloads a missing binary during an agent command; if scripts
|
|
25
|
+
were disabled, run `npm rebuild @angelmsger/wecom-channel-cli` in a trusted setup
|
|
26
|
+
session. Windows is not supported in this release.
|
|
27
|
+
|
|
28
|
+
[Documentation](https://angelmsger.github.io/wecom-channel-cli/)
|
|
29
|
+
· [Source](https://github.com/AngelMsger/wecom-channel-cli)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const { spawnSync } = require('node:child_process');
|
|
5
|
+
const { binPath } = require('../install.js');
|
|
6
|
+
const { file } = binPath();
|
|
7
|
+
if (!fs.existsSync(file)) {
|
|
8
|
+
process.stderr.write('wecom-channel-cli: binary missing; run npm rebuild @angelmsger/wecom-channel-cli in a trusted setup session. No automatic download occurs in an agent command.\n');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const result = spawnSync(file, process.argv.slice(2), { stdio: 'inherit' });
|
|
12
|
+
if (result.error) { process.stderr.write('wecom-channel-cli: cannot start the installed binary.\n'); process.exit(1); }
|
|
13
|
+
if (result.signal) { process.kill(process.pid, result.signal); }
|
|
14
|
+
else process.exit(result.status === null ? 1 : result.status);
|
package/install.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Based on the family's MIT-licensed installer (Copyright 2026 AngelMsger),
|
|
3
|
+
// with mandatory checksums and bounded downloads for this connector.
|
|
4
|
+
// install.js downloads the prebuilt wecom-channel-cli binary that matches the
|
|
5
|
+
// host platform from the matching GitHub Release. It runs as the npm
|
|
6
|
+
// `postinstall` script. The runtime launcher never downloads implicitly.
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const https = require('https');
|
|
11
|
+
const crypto = require('crypto');
|
|
12
|
+
|
|
13
|
+
const pkg = require('./package.json');
|
|
14
|
+
|
|
15
|
+
const REPO = 'AngelMsger/wecom-channel-cli';
|
|
16
|
+
|
|
17
|
+
const goosByPlatform = { darwin: 'darwin', linux: 'linux' };
|
|
18
|
+
const goarchByArch = { x64: 'amd64', arm64: 'arm64' };
|
|
19
|
+
|
|
20
|
+
// assetName returns the release asset file name for the current platform.
|
|
21
|
+
function assetName(platform = process.platform, arch = process.arch) {
|
|
22
|
+
const goos = goosByPlatform[platform];
|
|
23
|
+
const goarch = goarchByArch[arch];
|
|
24
|
+
if (!goos || !goarch) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`unsupported platform ${platform}/${arch}; ` +
|
|
27
|
+
`build from source instead (see https://github.com/${REPO})`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return `wecom-channel-cli-${goos}-${goarch}` + (goos === 'windows' ? '.exe' : '');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// binPath returns the directory and file path for the installed binary.
|
|
34
|
+
function binPath(platform = process.platform) {
|
|
35
|
+
const dir = path.join(__dirname, 'binary');
|
|
36
|
+
const exe = platform === 'win32' ? 'wecom-channel-cli.exe' : 'wecom-channel-cli';
|
|
37
|
+
return { dir, file: path.join(dir, exe) };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// releaseBaseURL is the GitHub Release download prefix for this package version.
|
|
41
|
+
function releaseBaseURL() {
|
|
42
|
+
return `https://github.com/${REPO}/releases/download/v${pkg.version}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Fetch only HTTPS release assets, with finite time, size and redirect budgets.
|
|
46
|
+
function httpGet(raw, redirects = 0) {
|
|
47
|
+
const url = new URL(raw);
|
|
48
|
+
if (url.protocol !== 'https:' || (url.port && url.port !== '443') || url.username || url.password ||
|
|
49
|
+
!(url.hostname === 'github.com' || url.hostname.endsWith('.githubusercontent.com')) || redirects > 5) {
|
|
50
|
+
return Promise.reject(new Error('release download destination rejected'));
|
|
51
|
+
}
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const req = https.get(url, { headers: { 'User-Agent': 'wecom-channel-cli-installer' } }, res => {
|
|
54
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
55
|
+
res.resume(); resolve(httpGet(new URL(res.headers.location, url).href, redirects + 1)); return;
|
|
56
|
+
}
|
|
57
|
+
if (res.statusCode !== 200) { res.resume(); reject(new Error(`release download returned HTTP ${res.statusCode}`)); return; }
|
|
58
|
+
let size = 0; const chunks = [];
|
|
59
|
+
res.on('data', chunk => { size += chunk.length; if (size > 128 * 1024 * 1024) { req.destroy(new Error('release asset exceeds size limit')); return; } chunks.push(chunk); });
|
|
60
|
+
res.on('end', () => resolve(Buffer.concat(chunks))); res.on('error', reject);
|
|
61
|
+
});
|
|
62
|
+
const deadline = setTimeout(() => req.destroy(new Error('release download timed out')), 30000);
|
|
63
|
+
req.on('close', () => clearTimeout(deadline));
|
|
64
|
+
req.on('error', reject);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function verifyChecksum(data, manifest, asset) {
|
|
68
|
+
const matches = manifest.split('\n').map(line => line.trim().split(/\s+/)).filter(parts => parts[1] === asset);
|
|
69
|
+
if (matches.length !== 1 || !/^[a-fA-F0-9]{64}$/.test(matches[0][0])) throw new Error('missing or ambiguous release checksum');
|
|
70
|
+
const actual = crypto.createHash('sha256').update(data).digest('hex');
|
|
71
|
+
if (actual !== matches[0][0].toLowerCase()) throw new Error(`checksum mismatch for ${asset}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// install downloads, verifies and writes the binary. It is idempotent.
|
|
75
|
+
async function install() {
|
|
76
|
+
if (!pkg.version || pkg.version === '0.0.0') {
|
|
77
|
+
throw new Error('package version is unset; install from a published release');
|
|
78
|
+
}
|
|
79
|
+
const asset = assetName();
|
|
80
|
+
const { dir, file } = binPath();
|
|
81
|
+
|
|
82
|
+
const data = await httpGet(`${releaseBaseURL()}/${asset}`);
|
|
83
|
+
|
|
84
|
+
const manifest = (await httpGet(`${releaseBaseURL()}/checksums.txt`)).toString('utf8');
|
|
85
|
+
verifyChecksum(data, manifest, asset);
|
|
86
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
87
|
+
const temporary = path.join(dir, `.download-${process.pid}-${crypto.randomBytes(8).toString('hex')}`);
|
|
88
|
+
try { fs.writeFileSync(temporary, data, { mode: 0o755, flag: 'wx' }); fs.renameSync(temporary, file); }
|
|
89
|
+
finally { fs.rmSync(temporary, { force: true }); }
|
|
90
|
+
return file;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function welcomeText() {
|
|
94
|
+
return 'After upgrading: wecom-channel-cli skill install, then reload the agent context.\nSetup: wecom-channel-cli auth guide; wecom-channel-cli config get-contexts\n';
|
|
95
|
+
}
|
|
96
|
+
module.exports = { install, binPath, assetName, verifyChecksum, httpGet, welcomeText, REPO };
|
|
97
|
+
if (require.main === module) {
|
|
98
|
+
install().then(() => process.stderr.write(welcomeText())).catch(err => {
|
|
99
|
+
process.stderr.write(`wecom-channel-cli: ${err.message}\n`); process.exitCode = 1;
|
|
100
|
+
});
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angelmsger/wecom-channel-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "WeCom channel connector for agents: isolated contexts, callback-free polling and operator-approved drafts.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/AngelMsger/wecom-channel-cli.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://angelmsger.github.io/wecom-channel-cli/",
|
|
11
|
+
"bin": {
|
|
12
|
+
"wecom-channel-cli": "bin/wecom-channel-cli.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node install.js",
|
|
16
|
+
"test": "node --test install.test.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin/",
|
|
20
|
+
"install.js",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"os": [
|
|
28
|
+
"darwin",
|
|
29
|
+
"linux"
|
|
30
|
+
],
|
|
31
|
+
"cpu": [
|
|
32
|
+
"x64",
|
|
33
|
+
"arm64"
|
|
34
|
+
],
|
|
35
|
+
"keywords": [
|
|
36
|
+
"wecom",
|
|
37
|
+
"channels",
|
|
38
|
+
"agents",
|
|
39
|
+
"cli",
|
|
40
|
+
"security"
|
|
41
|
+
],
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
}
|
|
46
|
+
}
|