@licity/qclaw-local-connector 1.1.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/.env.example +14 -0
- package/README.md +419 -0
- package/index.js +986 -0
- package/package.json +37 -0
- package/setup.js +78 -0
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@licity/qclaw-local-connector",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "里世界龙虾本地连接器 — 把 QClaw 或其他第三方本地 Runtime 接入里世界 APP",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"licity-connector": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"setup.js",
|
|
12
|
+
".env.example",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"setup": "node setup.js",
|
|
17
|
+
"doctor": "node setup.js --doctor",
|
|
18
|
+
"quickstart": "node setup.js --prepare-only && node index.js",
|
|
19
|
+
"start": "node index.js"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"licity",
|
|
23
|
+
"qclaw",
|
|
24
|
+
"openclaw",
|
|
25
|
+
"connector",
|
|
26
|
+
"lobster",
|
|
27
|
+
"local-connector"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"dotenv": "^17.2.3",
|
|
35
|
+
"qrcode-terminal": "^0.12.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/setup.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const rootDir = __dirname;
|
|
6
|
+
const envPath = path.join(rootDir, '.env');
|
|
7
|
+
const exampleEnvPath = path.join(rootDir, '.env.example');
|
|
8
|
+
const dataDir = path.join(rootDir, 'data');
|
|
9
|
+
const screenshotDir = path.join(dataDir, 'screenshots');
|
|
10
|
+
|
|
11
|
+
function readEnvFile(filePath) {
|
|
12
|
+
if (!fs.existsSync(filePath)) return {};
|
|
13
|
+
return fs.readFileSync(filePath, 'utf8')
|
|
14
|
+
.split(/\r?\n/)
|
|
15
|
+
.map(line => line.trim())
|
|
16
|
+
.filter(line => line && !line.startsWith('#') && line.includes('='))
|
|
17
|
+
.reduce((acc, line) => {
|
|
18
|
+
const index = line.indexOf('=');
|
|
19
|
+
const key = line.slice(0, index).trim();
|
|
20
|
+
const value = line.slice(index + 1);
|
|
21
|
+
acc[key] = value;
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function ensureDir(dirPath) {
|
|
27
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function ensureEnvFile() {
|
|
31
|
+
if (fs.existsSync(envPath)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const template = fs.existsSync(exampleEnvPath)
|
|
36
|
+
? fs.readFileSync(exampleEnvPath, 'utf8')
|
|
37
|
+
: '';
|
|
38
|
+
fs.writeFileSync(envPath, template, 'utf8');
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function printCheck(label, ok, extra = '') {
|
|
43
|
+
console.log(`${ok ? '√' : '!'} ${label}${extra ? `: ${extra}` : ''}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function main() {
|
|
47
|
+
const isDoctorOnly = process.argv.includes('--doctor');
|
|
48
|
+
const isPrepareOnly = process.argv.includes('--prepare-only');
|
|
49
|
+
|
|
50
|
+
console.log('里世界 QClaw 连接器安装助手');
|
|
51
|
+
const createdEnv = ensureEnvFile();
|
|
52
|
+
ensureDir(dataDir);
|
|
53
|
+
ensureDir(screenshotDir);
|
|
54
|
+
|
|
55
|
+
const env = readEnvFile(envPath);
|
|
56
|
+
const qclawPath = String(env.QCLAW_PATH || 'D:\\QClaw\\QClaw.exe').trim();
|
|
57
|
+
const qclawStateDir = String(env.QCLAW_STATE_DIR || path.join(os.homedir(), '.qclaw')).trim();
|
|
58
|
+
const openclawConfigPath = String(env.OPENCLAW_CONFIG_PATH || path.join(qclawStateDir, 'openclaw.json')).trim();
|
|
59
|
+
const connectorSecret = String(env.OPENCLAW_CONNECTOR_SECRET || '').trim();
|
|
60
|
+
|
|
61
|
+
printCheck('.env 文件', true, createdEnv ? '已按模板创建,请补全密钥后再启动' : '已存在');
|
|
62
|
+
printCheck('数据目录', true, dataDir);
|
|
63
|
+
printCheck('截图目录', true, screenshotDir);
|
|
64
|
+
printCheck('QClaw 程序路径', fs.existsSync(qclawPath), qclawPath);
|
|
65
|
+
printCheck('OpenClaw 配置文件', fs.existsSync(openclawConfigPath), openclawConfigPath);
|
|
66
|
+
printCheck('连接器密钥', !!connectorSecret, connectorSecret ? '已配置' : '请在 .env 中填写 OPENCLAW_CONNECTOR_SECRET');
|
|
67
|
+
|
|
68
|
+
if (isDoctorOnly || isPrepareOnly) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!connectorSecret) {
|
|
73
|
+
console.log('未检测到连接器密钥,已停止。先打开 .env 填入 OPENCLAW_CONNECTOR_SECRET,再执行 npm run quickstart。');
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
main();
|