feat: update plugin entry, install script, and docs for API Key auth
- plugin/index.ts: use apiKey instead of challengeUuid - scripts/install.mjs: update prompts and examples - README.md: update config docs and examples
This commit is contained in:
@@ -76,7 +76,7 @@ node scripts/install.mjs --verbose
|
||||
|
||||
## 配置
|
||||
|
||||
1. 在 HarborForge Monitor 中注册服务器,获取 `challengeUuid`
|
||||
1. 在 HarborForge Monitor 中注册服务器,获取 `apiKey`
|
||||
|
||||
2. 编辑 `~/.openclaw/openclaw.json`:
|
||||
|
||||
@@ -87,7 +87,7 @@ node scripts/install.mjs --verbose
|
||||
"enabled": true,
|
||||
"backendUrl": "https://monitor.hangman-lab.top",
|
||||
"identifier": "my-server-01",
|
||||
"challengeUuid": "your-challenge-uuid-here",
|
||||
"apiKey": "your-api-key-here",
|
||||
"reportIntervalSec": 30,
|
||||
"httpFallbackIntervalSec": 60,
|
||||
"logLevel": "info"
|
||||
@@ -109,7 +109,7 @@ openclaw gateway restart
|
||||
| `enabled` | boolean | `true` | 是否启用插件 |
|
||||
| `backendUrl` | string | `https://monitor.hangman-lab.top` | Monitor 后端地址 |
|
||||
| `identifier` | string | 自动检测 hostname | 服务器标识符 |
|
||||
| `challengeUuid` | string | 必填 | 注册挑战 UUID |
|
||||
| `apiKey` | string | 可选 | API Key 认证(从 HarborForge Monitor 获取) |
|
||||
| `reportIntervalSec` | number | `30` | 报告间隔(秒) |
|
||||
| `httpFallbackIntervalSec` | number | `60` | HTTP 回退间隔(秒) |
|
||||
| `logLevel` | string | `"info"` | 日志级别: debug/info/warn/error |
|
||||
@@ -151,7 +151,7 @@ npm run build
|
||||
|
||||
```bash
|
||||
cd server
|
||||
HF_MONITOR_CHALLENGE_UUID=test-uuid \
|
||||
HF_MONITOR_API_KEY=your-api-key \
|
||||
HF_MONITOR_BACKEND_URL=http://localhost:8000 \
|
||||
HF_MONITOR_LOG_LEVEL=debug \
|
||||
node telemetry.mjs
|
||||
|
||||
@@ -15,7 +15,7 @@ interface PluginConfig {
|
||||
enabled?: boolean;
|
||||
backendUrl?: string;
|
||||
identifier?: string;
|
||||
challengeUuid?: string;
|
||||
apiKey?: string;
|
||||
reportIntervalSec?: number;
|
||||
httpFallbackIntervalSec?: number;
|
||||
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
||||
@@ -47,10 +47,9 @@ export default function register(api: PluginAPI, config: PluginConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.challengeUuid) {
|
||||
logger.error('Missing required config: challengeUuid');
|
||||
logger.error('Please register server in HarborForge Monitor first');
|
||||
return;
|
||||
if (!config.apiKey) {
|
||||
logger.warn('Missing config: apiKey');
|
||||
logger.warn('API authentication will be disabled. Generate apiKey from HarborForge Monitor admin.');
|
||||
}
|
||||
|
||||
const serverPath = join(__dirname, '..', 'server', 'telemetry.mjs');
|
||||
@@ -74,7 +73,7 @@ export default function register(api: PluginAPI, config: PluginConfig) {
|
||||
...process.env,
|
||||
HF_MONITOR_BACKEND_URL: config.backendUrl || 'https://monitor.hangman-lab.top',
|
||||
HF_MONITOR_IDENTIFIER: config.identifier || '',
|
||||
HF_MONITOR_CHALLENGE_UUID: config.challengeUuid,
|
||||
HF_MONITOR_API_KEY: config.apiKey || '',
|
||||
HF_MONITOR_REPORT_INTERVAL: String(config.reportIntervalSec || 30),
|
||||
HF_MONITOR_HTTP_FALLBACK_INTERVAL: String(config.httpFallbackIntervalSec || 60),
|
||||
HF_MONITOR_LOG_LEVEL: config.logLevel || 'info',
|
||||
|
||||
@@ -240,8 +240,8 @@ async function configure() {
|
||||
}
|
||||
logOk(`plugins.allow includes ${PLUGIN_NAME}`);
|
||||
|
||||
// Note: challengeUuid must be configured manually by user
|
||||
logOk('Plugin configured (remember to set challengeUuid in ~/.openclaw/openclaw.json)');
|
||||
// Note: apiKey must be configured manually by user
|
||||
logOk('Plugin configured (remember to set apiKey in ~/.openclaw/openclaw.json)');
|
||||
|
||||
} catch (err) {
|
||||
logWarn(`Config failed: ${err.message}`);
|
||||
@@ -262,13 +262,13 @@ function summary() {
|
||||
|
||||
console.log('');
|
||||
log('Next steps:', 'blue');
|
||||
log(' 1. Register server in HarborForge Monitor to get challengeUuid', 'cyan');
|
||||
log(' 1. Register server in HarborForge Monitor to get apiKey', 'cyan');
|
||||
log(' 2. Edit ~/.openclaw/openclaw.json:', 'cyan');
|
||||
log(' {', 'cyan');
|
||||
log(' "plugins": {', 'cyan');
|
||||
log(' "harborforge-monitor": {', 'cyan');
|
||||
log(' "enabled": true,', 'cyan');
|
||||
log(' "challengeUuid": "your-challenge-uuid"', 'cyan');
|
||||
log(' "apiKey": "your-api-key"', 'cyan');
|
||||
log(' }', 'cyan');
|
||||
log(' }', 'cyan');
|
||||
log(' }', 'cyan');
|
||||
|
||||
Reference in New Issue
Block a user