openclaw-xiaoyou 1.2.0 → 1.2.1
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/docs/install-xiaoyou.sh +100 -24
- package/package.json +1 -1
- package/setup-entry.ts +1 -1
package/docs/install-xiaoyou.sh
CHANGED
|
@@ -323,24 +323,57 @@ install_or_upgrade() {
|
|
|
323
323
|
patch_config() {
|
|
324
324
|
[[ -n "$WS_URL" || -n "$TOKEN" ]] || return 0
|
|
325
325
|
|
|
326
|
-
log "写入 xiaoyou channel
|
|
327
|
-
run openclaw config set "channels.${CHANNEL_KEY}.enabled" true --strict-json
|
|
326
|
+
log "写入 xiaoyou channel 配置(直接修改配置文件)"
|
|
328
327
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
fi
|
|
332
|
-
if [[ -n "$TOKEN" ]]; then
|
|
333
|
-
run openclaw config set "channels.${CHANNEL_KEY}.authToken" "$TOKEN"
|
|
334
|
-
fi
|
|
328
|
+
local config_file
|
|
329
|
+
config_file="$(openclaw_config_file)"
|
|
335
330
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
run openclaw config set "channels.${CHANNEL_KEY}.heartbeatTimeoutMs" 10000 --strict-json
|
|
331
|
+
if [[ ! -f "$config_file" ]]; then
|
|
332
|
+
die "配置文件不存在: $config_file"
|
|
333
|
+
fi
|
|
340
334
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
335
|
+
# 使用 python3 直接写入配置,绕过 openclaw config set 的 channel id 校验
|
|
336
|
+
python3 -c "
|
|
337
|
+
import json, sys
|
|
338
|
+
|
|
339
|
+
config_file = '$config_file'
|
|
340
|
+
ws_url = '$WS_URL'
|
|
341
|
+
token = '$TOKEN'
|
|
342
|
+
|
|
343
|
+
try:
|
|
344
|
+
with open(config_file, 'r') as f:
|
|
345
|
+
cfg = json.load(f)
|
|
346
|
+
except Exception as e:
|
|
347
|
+
print(f'[xiaoyou-install][error] 无法读取配置文件: {e}', file=sys.stderr)
|
|
348
|
+
sys.exit(1)
|
|
349
|
+
|
|
350
|
+
# 确保 channels 对象存在
|
|
351
|
+
cfg.setdefault('channels', {})
|
|
352
|
+
|
|
353
|
+
# 写入 xiaoyou channel 配置
|
|
354
|
+
xiaoyou = cfg['channels'].get('xiaoyou', {})
|
|
355
|
+
xiaoyou['enabled'] = True
|
|
356
|
+
if ws_url:
|
|
357
|
+
xiaoyou['wsUrl'] = ws_url
|
|
358
|
+
if token:
|
|
359
|
+
xiaoyou['authToken'] = token
|
|
360
|
+
xiaoyou.setdefault('dmSecurity', 'open')
|
|
361
|
+
xiaoyou.setdefault('allowFrom', ['*'])
|
|
362
|
+
xiaoyou.setdefault('reconnectIntervalMs', 3000)
|
|
363
|
+
xiaoyou.setdefault('heartbeatIntervalMs', 30000)
|
|
364
|
+
xiaoyou.setdefault('heartbeatTimeoutMs', 10000)
|
|
365
|
+
cfg['channels']['xiaoyou'] = xiaoyou
|
|
366
|
+
|
|
367
|
+
try:
|
|
368
|
+
with open(config_file, 'w') as f:
|
|
369
|
+
json.dump(cfg, f, indent=2, ensure_ascii=False)
|
|
370
|
+
print('[xiaoyou-install] 配置写入成功')
|
|
371
|
+
except Exception as e:
|
|
372
|
+
print(f'[xiaoyou-install][error] 写入配置失败: {e}', file=sys.stderr)
|
|
373
|
+
sys.exit(1)
|
|
374
|
+
" || die "写入配置失败"
|
|
375
|
+
|
|
376
|
+
log "已写入配置: $config_file"
|
|
344
377
|
}
|
|
345
378
|
|
|
346
379
|
# -----------------------------------------------------------------------------
|
|
@@ -375,11 +408,31 @@ xiayou_status() {
|
|
|
375
408
|
|
|
376
409
|
xiayou_uninstall_plugin_only() {
|
|
377
410
|
# 仅删除插件记录和文件,不删除配置(升级时用)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
411
|
+
local config_file
|
|
412
|
+
config_file="$(openclaw_config_file)"
|
|
413
|
+
|
|
414
|
+
if [[ -f "$config_file" ]] && command_exists python3; then
|
|
415
|
+
python3 -c "
|
|
416
|
+
import json
|
|
417
|
+
config_file = '$config_file'
|
|
418
|
+
with open(config_file, 'r') as f:
|
|
419
|
+
cfg = json.load(f)
|
|
420
|
+
changed = False
|
|
421
|
+
for key in ['xiaoyou', 'openclaw-xiaoyou']:
|
|
422
|
+
if cfg.get('plugins', {}).get('entries', {}).pop(key, None): changed = True
|
|
423
|
+
if cfg.get('plugins', {}).get('installs', {}).pop(key, None): changed = True
|
|
424
|
+
allow = cfg.get('plugins', {}).get('allow', [])
|
|
425
|
+
if key in allow:
|
|
426
|
+
allow.remove(key)
|
|
427
|
+
changed = True
|
|
428
|
+
if changed:
|
|
429
|
+
with open(config_file, 'w') as f:
|
|
430
|
+
json.dump(cfg, f, indent=2, ensure_ascii=False)
|
|
431
|
+
print('[xiaoyou-install] 已清理插件注册记录')
|
|
432
|
+
" || true
|
|
381
433
|
fi
|
|
382
|
-
|
|
434
|
+
|
|
435
|
+
run_or_dry_run rm -rf "$HOME/.openclaw/extensions/xiaoyou" "$HOME/.openclaw/extensions/openclaw-xiaoyou" "$HOME"/.openclaw/extensions/.openclaw-* || true
|
|
383
436
|
}
|
|
384
437
|
|
|
385
438
|
xiayou_uninstall() {
|
|
@@ -392,13 +445,29 @@ xiayou_uninstall() {
|
|
|
392
445
|
fi
|
|
393
446
|
|
|
394
447
|
log "开始卸载 xiaoyou channel"
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
448
|
+
|
|
449
|
+
local config_file
|
|
450
|
+
config_file="$(openclaw_config_file)"
|
|
451
|
+
|
|
452
|
+
if [[ -f "$config_file" ]] && command_exists python3; then
|
|
453
|
+
run_or_dry_run python3 -c "
|
|
454
|
+
import json
|
|
455
|
+
config_file = '$config_file'
|
|
456
|
+
with open(config_file, 'r') as f:
|
|
457
|
+
cfg = json.load(f)
|
|
458
|
+
cfg.get('channels', {}).pop('xiaoyou', None)
|
|
459
|
+
for key in ['xiaoyou', 'openclaw-xiaoyou']:
|
|
460
|
+
cfg.get('plugins', {}).get('entries', {}).pop(key, None)
|
|
461
|
+
cfg.get('plugins', {}).get('installs', {}).pop(key, None)
|
|
462
|
+
allow = cfg.get('plugins', {}).get('allow', [])
|
|
463
|
+
if key in allow: allow.remove(key)
|
|
464
|
+
with open(config_file, 'w') as f:
|
|
465
|
+
json.dump(cfg, f, indent=2, ensure_ascii=False)
|
|
466
|
+
print('[xiaoyou-install] 已清理所有 xiaoyou 配置')
|
|
467
|
+
" || warn "清理配置失败"
|
|
399
468
|
fi
|
|
400
469
|
|
|
401
|
-
run_or_dry_run rm -rf "$HOME/.openclaw/extensions
|
|
470
|
+
run_or_dry_run rm -rf "$HOME/.openclaw/extensions/xiaoyou" "$HOME/.openclaw/extensions/openclaw-xiaoyou" "$HOME"/.openclaw/extensions/.openclaw-* || warn "删除插件文件失败"
|
|
402
471
|
|
|
403
472
|
if [[ "$CHECK_ONLY" -eq 1 ]]; then
|
|
404
473
|
phase_end "xiaoyou.uninstall" "planned" "check-only:已输出计划,未执行"
|
|
@@ -424,6 +493,13 @@ main() {
|
|
|
424
493
|
|
|
425
494
|
install_or_upgrade
|
|
426
495
|
|
|
496
|
+
# 重启 gateway 让插件和配置生效
|
|
497
|
+
if [[ "$CHECK_ONLY" -eq 0 ]] && openclaw_gateway_running; then
|
|
498
|
+
log "重启 gateway 以加载插件和配置..."
|
|
499
|
+
run openclaw gateway restart || warn "gateway 重启失败,请手动执行: openclaw gateway restart"
|
|
500
|
+
sleep 5
|
|
501
|
+
fi
|
|
502
|
+
|
|
427
503
|
log "完成。企业服务端应能收到来自 xiaoyou 插件的 WebSocket 连接。"
|
|
428
504
|
phase_end "main.entry" "ok" "安装流程完成"
|
|
429
505
|
}
|
package/package.json
CHANGED
package/setup-entry.ts
CHANGED
|
@@ -13,6 +13,6 @@ export default {
|
|
|
13
13
|
description: "Bridge OpenClaw to enterprise services via WebSocket",
|
|
14
14
|
setup: {
|
|
15
15
|
resolveAccount: xiayouPlugin.config.resolveAccount,
|
|
16
|
-
|
|
16
|
+
isConfigured: xiayouPlugin.config.isConfigured,
|
|
17
17
|
},
|
|
18
18
|
};
|