@licity/openclaw-connector 1.0.2 → 1.0.3
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/index.js +2 -43
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -138,53 +138,13 @@ async function apiRequest(endpoint, options = {}, token = null) {
|
|
|
138
138
|
|
|
139
139
|
// ─── 显示二维码(Windows 弹 CMD 新窗口) ──────────────────────────────────────
|
|
140
140
|
function showQrCode(qrText) {
|
|
141
|
-
|
|
141
|
+
console.log('\n请在里世界 APP → 我的龙虾 → 扫一扫,扫描以下二维码:\n');
|
|
142
142
|
try {
|
|
143
143
|
require('qrcode-terminal').generate(qrText, { small: true });
|
|
144
144
|
} catch {}
|
|
145
145
|
console.log('\n二维码文本:');
|
|
146
146
|
console.log(qrText);
|
|
147
147
|
console.log('');
|
|
148
|
-
|
|
149
|
-
if (process.platform !== 'win32') return;
|
|
150
|
-
|
|
151
|
-
// Windows:额外弹出一个 CMD 新窗口,字符渲染更准确,方便扫码
|
|
152
|
-
try {
|
|
153
|
-
const qrcodeModPath = require.resolve('qrcode-terminal');
|
|
154
|
-
const scriptLines = [
|
|
155
|
-
`const q = require(${JSON.stringify(qrcodeModPath)});`,
|
|
156
|
-
`const text = ${JSON.stringify(qrText)};`,
|
|
157
|
-
`try { process.title = '里世界龙虾连接 - 打开APP扫码'; } catch {}`,
|
|
158
|
-
`console.clear && console.clear();`,
|
|
159
|
-
`console.log('');`,
|
|
160
|
-
`console.log('╔══════════════════════════════════════╗');`,
|
|
161
|
-
`console.log('║ 里世界 龙虾连接二维码 ║');`,
|
|
162
|
-
`console.log('╚══════════════════════════════════════╝');`,
|
|
163
|
-
`console.log('');`,
|
|
164
|
-
`q.generate(text, { small: false });`,
|
|
165
|
-
`console.log('');`,
|
|
166
|
-
`console.log('请打开里世界APP → 我的龙虾 → 扫一扫');`,
|
|
167
|
-
`console.log('扫码完成后可关闭此窗口(连接器继续在后台运行)');`,
|
|
168
|
-
`console.log('');`,
|
|
169
|
-
`console.log('二维码文本:');`,
|
|
170
|
-
`console.log(text);`,
|
|
171
|
-
`process.stdin.resume();`,
|
|
172
|
-
];
|
|
173
|
-
const tempScript = path.join(os.tmpdir(), `licity_qr_${Date.now()}.js`);
|
|
174
|
-
fs.writeFileSync(tempScript, scriptLines.join('\n'), 'utf8');
|
|
175
|
-
|
|
176
|
-
// 使用 cmd /c start 打开一个新的可见 CMD 窗口
|
|
177
|
-
const child = spawn('cmd.exe', [
|
|
178
|
-
'/c', 'start', '"里世界龙虾连接"', 'cmd', '/k',
|
|
179
|
-
`"${process.execPath}" "${tempScript}"`,
|
|
180
|
-
], { detached: true, windowsHide: false, shell: false });
|
|
181
|
-
child.unref();
|
|
182
|
-
|
|
183
|
-
console.log('[扫码] 已弹出新的 CMD 窗口,请在新窗口中扫码。');
|
|
184
|
-
} catch (e) {
|
|
185
|
-
// 弹窗失败: 当前终端中已有文字版二维码,用户可在此扫码
|
|
186
|
-
console.log('[扫码] 注:无法弹出新窗口,请在当前终端扫码。');
|
|
187
|
-
}
|
|
188
148
|
}
|
|
189
149
|
|
|
190
150
|
// ─── OpenClaw Agent 执行 ─────────────────────────────────────────────────────
|
|
@@ -256,12 +216,11 @@ async function runAgent({ cliPath, configPath, agentId, lobsterName, message })
|
|
|
256
216
|
cliPath,
|
|
257
217
|
'agent',
|
|
258
218
|
'--agent', agentId || 'main',
|
|
259
|
-
'--config', configPath,
|
|
260
219
|
'--message', prompt,
|
|
261
220
|
'--json',
|
|
262
221
|
'--timeout', String(Math.max(15, Math.ceil(AGENT_TIMEOUT_MS / 1000))),
|
|
263
222
|
], {
|
|
264
|
-
env: { ...process.env, OPENCLAW_CONFIG_PATH: configPath, NODE_OPTIONS: '--no-warnings' },
|
|
223
|
+
env: { ...process.env, OPENCLAW_CONFIG_PATH: configPath, OPENCLAW_STATE_DIR: path.dirname(configPath), NODE_OPTIONS: '--no-warnings' },
|
|
265
224
|
windowsHide: true,
|
|
266
225
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
267
226
|
});
|