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