@licity/openclaw-local-connector 2.0.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/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@licity/openclaw-local-connector",
3
+ "version": "2.0.0",
4
+ "description": "里世界 OpenClaw 本地连接器,支持 OpenClaw 与 QClaw 等第三方本地 Runtime 扫码接入",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "licity-connector": "index.js",
8
+ "licity-openclaw": "index.js"
9
+ },
10
+ "files": [
11
+ "index.js",
12
+ "setup.js",
13
+ ".env.example",
14
+ "README.md",
15
+ "启动里世界OpenClaw连接器.bat"
16
+ ],
17
+ "scripts": {
18
+ "setup": "node setup.js",
19
+ "doctor": "node setup.js --doctor",
20
+ "quickstart": "node setup.js --prepare-only && node index.js",
21
+ "start": "node index.js"
22
+ },
23
+ "keywords": [
24
+ "licity",
25
+ "qclaw",
26
+ "openclaw",
27
+ "runtime",
28
+ "connector",
29
+ "lobster",
30
+ "local-connector"
31
+ ],
32
+ "license": "MIT",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "dotenv": "^17.2.3",
38
+ "qrcode-terminal": "^0.12.0"
39
+ }
40
+ }
package/setup.js ADDED
@@ -0,0 +1,89 @@
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 findFirstExistingPath(candidates, fallback = '') {
31
+ for (const candidate of candidates) {
32
+ const resolved = String(candidate || '').trim();
33
+ if (resolved && fs.existsSync(resolved)) {
34
+ return resolved;
35
+ }
36
+ }
37
+ return String(fallback || '').trim();
38
+ }
39
+
40
+ function ensureEnvFile() {
41
+ if (fs.existsSync(envPath)) {
42
+ return false;
43
+ }
44
+
45
+ const template = fs.existsSync(exampleEnvPath)
46
+ ? fs.readFileSync(exampleEnvPath, 'utf8')
47
+ : '';
48
+ fs.writeFileSync(envPath, template, 'utf8');
49
+ return true;
50
+ }
51
+
52
+ function printCheck(label, ok, extra = '') {
53
+ console.log(`${ok ? '√' : '!'} ${label}${extra ? `: ${extra}` : ''}`);
54
+ }
55
+
56
+ function main() {
57
+ const isDoctorOnly = process.argv.includes('--doctor');
58
+ const isPrepareOnly = process.argv.includes('--prepare-only');
59
+
60
+ console.log('里世界 OpenClaw 连接器安装助手');
61
+ const createdEnv = ensureEnvFile();
62
+ ensureDir(dataDir);
63
+ ensureDir(screenshotDir);
64
+
65
+ const env = readEnvFile(envPath);
66
+ const runtimePath = findFirstExistingPath(
67
+ [env.OPENCLAW_RUNTIME_PATH, env.QCLAW_PATH, 'D:\\QClaw\\QClaw.exe', 'C:\\QClaw\\QClaw.exe'],
68
+ env.OPENCLAW_RUNTIME_PATH || env.QCLAW_PATH || 'D:\\QClaw\\QClaw.exe'
69
+ );
70
+ const runtimeStateDir = findFirstExistingPath(
71
+ [env.OPENCLAW_STATE_DIR, env.QCLAW_STATE_DIR, path.join(os.homedir(), '.qclaw')],
72
+ path.join(os.homedir(), '.qclaw')
73
+ );
74
+ const openclawConfigPath = String(env.OPENCLAW_CONFIG_PATH || path.join(runtimeStateDir, 'openclaw.json')).trim();
75
+ const connectorSecret = String(env.OPENCLAW_CONNECTOR_SECRET || '').trim();
76
+
77
+ printCheck('.env 文件', true, createdEnv ? '已按模板创建,可直接扫码授权' : '已存在');
78
+ printCheck('数据目录', true, dataDir);
79
+ printCheck('截图目录', true, screenshotDir);
80
+ printCheck('Runtime 程序路径', fs.existsSync(runtimePath), runtimePath);
81
+ printCheck('OpenClaw 配置文件', fs.existsSync(openclawConfigPath), openclawConfigPath);
82
+ printCheck('连接器鉴权', true, connectorSecret ? '已配置手动密钥' : '扫码成功后自动下发本机令牌');
83
+
84
+ if (isDoctorOnly || isPrepareOnly) {
85
+ return;
86
+ }
87
+ }
88
+
89
+ main();
@@ -0,0 +1,31 @@
1
+ @echo off
2
+ setlocal
3
+ chcp 65001 >nul
4
+ title 里世界 OpenClaw 本地连接器
5
+
6
+ echo ========================================
7
+ echo 里世界 OpenClaw 本地连接器
8
+ echo ========================================
9
+ echo 首次运行会自动生成 .env,并直接显示二维码。
10
+ echo 扫码通过后会自动下发本机连接令牌,无需手填密钥。
11
+ echo.
12
+
13
+ where licity-openclaw >nul 2>nul
14
+ if %errorlevel%==0 (
15
+ licity-openclaw
16
+ goto end
17
+ )
18
+
19
+ where licity-connector >nul 2>nul
20
+ if %errorlevel%==0 (
21
+ licity-connector
22
+ goto end
23
+ )
24
+
25
+ echo 未找到连接器命令,请先执行:
26
+ echo npm install -g @licity/openclaw-local-connector
27
+ echo.
28
+ pause
29
+
30
+ :end
31
+ endlocal