craftclose 0.1.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/LICENSE +21 -0
- package/README.md +176 -0
- package/SKILL.md +139 -0
- package/craftclose.example.yml +84 -0
- package/dist/ai-analyzer.d.ts +96 -0
- package/dist/ai-analyzer.d.ts.map +1 -0
- package/dist/ai-analyzer.js +275 -0
- package/dist/ai-analyzer.js.map +1 -0
- package/dist/alerts/discord.d.ts +23 -0
- package/dist/alerts/discord.d.ts.map +1 -0
- package/dist/alerts/discord.js +95 -0
- package/dist/alerts/discord.js.map +1 -0
- package/dist/alerts/index.d.ts +5 -0
- package/dist/alerts/index.d.ts.map +1 -0
- package/dist/alerts/index.js +8 -0
- package/dist/alerts/index.js.map +1 -0
- package/dist/alerts/telegram.d.ts +25 -0
- package/dist/alerts/telegram.d.ts.map +1 -0
- package/dist/alerts/telegram.js +72 -0
- package/dist/alerts/telegram.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +410 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/connectors/index.d.ts +8 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/index.js +14 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/parsers.d.ts +24 -0
- package/dist/connectors/parsers.d.ts.map +1 -0
- package/dist/connectors/parsers.js +64 -0
- package/dist/connectors/parsers.js.map +1 -0
- package/dist/connectors/pterodactyl.d.ts +90 -0
- package/dist/connectors/pterodactyl.d.ts.map +1 -0
- package/dist/connectors/pterodactyl.js +221 -0
- package/dist/connectors/pterodactyl.js.map +1 -0
- package/dist/connectors/rcon.d.ts +51 -0
- package/dist/connectors/rcon.d.ts.map +1 -0
- package/dist/connectors/rcon.js +95 -0
- package/dist/connectors/rcon.js.map +1 -0
- package/dist/connectors/ssh.d.ts +65 -0
- package/dist/connectors/ssh.d.ts.map +1 -0
- package/dist/connectors/ssh.js +273 -0
- package/dist/connectors/ssh.js.map +1 -0
- package/dist/craft-close-skill.d.ts +106 -0
- package/dist/craft-close-skill.d.ts.map +1 -0
- package/dist/craft-close-skill.js +604 -0
- package/dist/craft-close-skill.js.map +1 -0
- package/dist/history.d.ts +32 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +194 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/openclaw-entry.d.ts +29 -0
- package/dist/openclaw-entry.d.ts.map +1 -0
- package/dist/openclaw-entry.js +45 -0
- package/dist/openclaw-entry.js.map +1 -0
- package/dist/patterns/index.d.ts +32 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +248 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/security/action-allowlist.d.ts +21 -0
- package/dist/security/action-allowlist.d.ts.map +1 -0
- package/dist/security/action-allowlist.js +54 -0
- package/dist/security/action-allowlist.js.map +1 -0
- package/dist/security/audit-log.d.ts +22 -0
- package/dist/security/audit-log.d.ts.map +1 -0
- package/dist/security/audit-log.js +49 -0
- package/dist/security/audit-log.js.map +1 -0
- package/dist/security/index.d.ts +10 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +20 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/input-sanitizer.d.ts +32 -0
- package/dist/security/input-sanitizer.d.ts.map +1 -0
- package/dist/security/input-sanitizer.js +81 -0
- package/dist/security/input-sanitizer.js.map +1 -0
- package/dist/security/path-jail.d.ts +25 -0
- package/dist/security/path-jail.d.ts.map +1 -0
- package/dist/security/path-jail.js +73 -0
- package/dist/security/path-jail.js.map +1 -0
- package/dist/security/rcon-filter.d.ts +24 -0
- package/dist/security/rcon-filter.d.ts.map +1 -0
- package/dist/security/rcon-filter.js +76 -0
- package/dist/security/rcon-filter.js.map +1 -0
- package/dist/types.d.ts +154 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LaunchDay Studio Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# CraftClose
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/craftclose)
|
|
4
|
+
[](https://github.com/LaunchDay-Studio-Inc/craftclose/actions/workflows/ci.yml)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**AI-powered Minecraft server monitoring** — crash detection, auto-restart, and smart alerts.
|
|
8
|
+
|
|
9
|
+
Open-source [OpenClaw](https://openclaw.dev) skill for monitoring Minecraft servers via SSH, RCON, or Pterodactyl panel. Includes AI-powered crash analysis via Google Gemini (BYOK).
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Multi-server monitoring** — SSH, RCON, Pterodactyl, or any combination
|
|
14
|
+
- **Crash detection** — 22 built-in patterns for OOM, plugin errors, watchdog timeouts, etc.
|
|
15
|
+
- **Auto-restart** — Automatically restart crashed servers with circuit breaker protection
|
|
16
|
+
- **Smart alerts** — Telegram and Discord notifications with severity levels
|
|
17
|
+
- **AI crash analysis** — Feed crash logs to Google Gemini for root cause + fix suggestions (BYOK)
|
|
18
|
+
- **AI config optimization** — Get specific recommendations for `server.properties`, `spigot.yml`, etc.
|
|
19
|
+
- **AI plugin conflict detection** — Scan your plugins folder for known incompatibilities
|
|
20
|
+
- **TPS & player history** — SQLite-backed tracking with trend analysis
|
|
21
|
+
- **Pterodactyl integration** — Full panel support: console, logs, file manager, resource stats
|
|
22
|
+
- **Security sandbox** — Path jail, RCON command filter, input sanitization, audit logging
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Install
|
|
28
|
+
npm install -g craftclose
|
|
29
|
+
|
|
30
|
+
# Configure
|
|
31
|
+
cp craftclose.example.yml craftclose.yml
|
|
32
|
+
# Edit craftclose.yml with your server details
|
|
33
|
+
|
|
34
|
+
# Test connectivity
|
|
35
|
+
craftclose test
|
|
36
|
+
|
|
37
|
+
# Start monitoring
|
|
38
|
+
craftclose monitor
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
Copy `craftclose.example.yml` and configure your servers:
|
|
44
|
+
|
|
45
|
+
### SSH + RCON (self-hosted)
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
servers:
|
|
49
|
+
- name: "survival"
|
|
50
|
+
host: "192.168.1.100"
|
|
51
|
+
type: "paper"
|
|
52
|
+
ssh:
|
|
53
|
+
user: "ubuntu"
|
|
54
|
+
key: "~/.ssh/id_ed25519"
|
|
55
|
+
rcon:
|
|
56
|
+
port: 25575
|
|
57
|
+
password: "your-rcon-password"
|
|
58
|
+
restart_command: "systemctl restart minecraft"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Pterodactyl (panel-hosted)
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
servers:
|
|
65
|
+
- name: "creative"
|
|
66
|
+
host: "play.example.com"
|
|
67
|
+
type: "paper"
|
|
68
|
+
pterodactyl:
|
|
69
|
+
panel_url: "https://panel.yourhost.com"
|
|
70
|
+
api_key: "ptlc_xxxxxxxxxxxx"
|
|
71
|
+
server_id: "a1b2c3d4"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Alerts
|
|
75
|
+
|
|
76
|
+
```yaml
|
|
77
|
+
alerts:
|
|
78
|
+
telegram:
|
|
79
|
+
bot_token: "123456:ABC-DEF..."
|
|
80
|
+
chat_id: "-1001234567890"
|
|
81
|
+
discord:
|
|
82
|
+
webhook_url: "https://discord.com/api/webhooks/..."
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### AI (BYOK — Bring Your Own Key)
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
ai:
|
|
89
|
+
gemini_key: "your-gemini-api-key"
|
|
90
|
+
model: "gemini-2.5-flash"
|
|
91
|
+
max_calls_per_hour: 10
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Get a free API key at [aistudio.google.com/apikey](https://aistudio.google.com/apikey).
|
|
95
|
+
|
|
96
|
+
## Commands
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
craftclose status Check all servers
|
|
100
|
+
craftclose monitor Start continuous monitoring
|
|
101
|
+
craftclose test Test connectivity
|
|
102
|
+
craftclose history <server> Show TPS/player history
|
|
103
|
+
craftclose analyze <logfile> AI crash analysis
|
|
104
|
+
craftclose optimize <configdir> AI config optimization
|
|
105
|
+
craftclose conflicts <plugindir> AI plugin conflict detection
|
|
106
|
+
craftclose ptero-test Test Pterodactyl connections
|
|
107
|
+
craftclose ptero-console <srv> <cmd> Send console command
|
|
108
|
+
craftclose ptero-logs <srv> Read server logs
|
|
109
|
+
craftclose ptero-files <srv> [dir] List server files
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Security Model
|
|
113
|
+
|
|
114
|
+
CraftClose includes a security sandbox that protects your servers:
|
|
115
|
+
|
|
116
|
+
| Layer | Protection |
|
|
117
|
+
|-------|------------|
|
|
118
|
+
| **Path Jail** | File access restricted to server directory — no `../` traversal |
|
|
119
|
+
| **RCON Filter** | Dangerous commands (`stop`, `op`, `ban`, `reload`) blocked by default |
|
|
120
|
+
| **Input Sanitizer** | Shell/RCON injection characters stripped from all inputs |
|
|
121
|
+
| **Audit Log** | All security-relevant actions logged to `craftclose-audit.jsonl` |
|
|
122
|
+
| **Action Allowlist** | Only approved config files can be read/written |
|
|
123
|
+
|
|
124
|
+
Configure in `craftclose.yml`:
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
security:
|
|
128
|
+
confirm_destructive: true
|
|
129
|
+
max_log_lines: 500
|
|
130
|
+
blocked_rcon_commands:
|
|
131
|
+
- timings
|
|
132
|
+
- spark
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Architecture
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
src/
|
|
139
|
+
├── craft-close-skill.ts # Main orchestrator
|
|
140
|
+
├── ai-analyzer.ts # BYOK Gemini AI (direct API)
|
|
141
|
+
├── config.ts # YAML config loader
|
|
142
|
+
├── history.ts # SQLite TPS/player tracking
|
|
143
|
+
├── types.ts # TypeScript interfaces
|
|
144
|
+
├── connectors/
|
|
145
|
+
│ ├── ssh.ts # SSH health checks + log reading
|
|
146
|
+
│ ├── rcon.ts # RCON TPS/players/commands
|
|
147
|
+
│ ├── pterodactyl.ts # Panel API integration
|
|
148
|
+
│ └── parsers.ts # TPS/player response parsers
|
|
149
|
+
├── alerts/
|
|
150
|
+
│ ├── telegram.ts # Telegram Bot API
|
|
151
|
+
│ └── discord.ts # Discord webhooks
|
|
152
|
+
├── patterns/
|
|
153
|
+
│ └── index.ts # 22 crash pattern matchers
|
|
154
|
+
└── security/
|
|
155
|
+
├── path-jail.ts # File access control
|
|
156
|
+
├── rcon-filter.ts # RCON command filter
|
|
157
|
+
├── input-sanitizer.ts # Input cleaning
|
|
158
|
+
├── audit-log.ts # Action audit trail
|
|
159
|
+
└── action-allowlist.ts # Config file allowlist
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm install
|
|
166
|
+
npm run build
|
|
167
|
+
npm test
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Contributing
|
|
171
|
+
|
|
172
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT — see [LICENSE](LICENSE) for details.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# CraftClose
|
|
2
|
+
|
|
3
|
+
AI-powered Minecraft server monitoring — crash detection, auto-restart, and smart alerts.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
1. Copy `craftclose.example.yml` to `craftclose.yml`
|
|
8
|
+
2. Configure your server(s):
|
|
9
|
+
- **SSH + RCON** — for self-hosted/VPS servers
|
|
10
|
+
- **Pterodactyl** — for panel-hosted servers (no SSH needed)
|
|
11
|
+
- **Hybrid** — Pterodactyl for resources + RCON for TPS/players
|
|
12
|
+
3. (Optional) Add alert channels: Telegram bot token or Discord webhook
|
|
13
|
+
4. (Optional) Add Google Gemini API key for AI crash analysis
|
|
14
|
+
5. Run `craftclose test` to verify connectivity
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
|
|
18
|
+
| Command | Description |
|
|
19
|
+
|---------|-------------|
|
|
20
|
+
| `craftclose status` | Check all servers once and print health |
|
|
21
|
+
| `craftclose monitor` | Start continuous monitoring |
|
|
22
|
+
| `craftclose test` | Test connectivity to all servers |
|
|
23
|
+
| `craftclose history <server>` | Show TPS/player history for a server |
|
|
24
|
+
| `craftclose analyze <logfile>` | AI crash log analysis (requires Gemini key) |
|
|
25
|
+
| `craftclose optimize <configdir>` | AI config optimization |
|
|
26
|
+
| `craftclose conflicts <plugindir>` | AI plugin conflict detection from jar filenames |
|
|
27
|
+
| `craftclose ptero-test` | Test Pterodactyl API connections |
|
|
28
|
+
| `craftclose ptero-console <server> <cmd>` | Send console command via Pterodactyl panel |
|
|
29
|
+
| `craftclose ptero-logs <server>` | Read server logs via Pterodactyl panel |
|
|
30
|
+
| `craftclose ptero-files <server> [dir]` | List server files via Pterodactyl panel |
|
|
31
|
+
| `craftclose --help` | Show help and all available commands |
|
|
32
|
+
| `craftclose --version` | Print version number |
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
### Server Config (required)
|
|
37
|
+
|
|
38
|
+
Each server needs at least one connector (SSH, RCON, or Pterodactyl):
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
servers:
|
|
42
|
+
- name: "my-server"
|
|
43
|
+
host: "192.168.1.100"
|
|
44
|
+
port: 25565
|
|
45
|
+
type: "paper"
|
|
46
|
+
ssh:
|
|
47
|
+
user: "ubuntu"
|
|
48
|
+
key: "~/.ssh/id_ed25519"
|
|
49
|
+
rcon:
|
|
50
|
+
port: 25575
|
|
51
|
+
password: "rcon-pass"
|
|
52
|
+
pterodactyl:
|
|
53
|
+
panel_url: "https://panel.yourhost.com"
|
|
54
|
+
api_key: "ptlc_xxxx"
|
|
55
|
+
server_id: "a1b2c3d4"
|
|
56
|
+
restart_command: "systemctl restart minecraft"
|
|
57
|
+
log_path: "/opt/minecraft/logs/latest.log"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Alert Config (optional)
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
alerts:
|
|
64
|
+
telegram:
|
|
65
|
+
bot_token: "123456:ABC-DEF..."
|
|
66
|
+
chat_id: "-1001234567890"
|
|
67
|
+
discord:
|
|
68
|
+
webhook_url: "https://discord.com/api/webhooks/..."
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### AI Config (optional — BYOK)
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
ai:
|
|
75
|
+
gemini_key: "your-gemini-api-key" # From https://aistudio.google.com/apikey
|
|
76
|
+
model: "gemini-2.5-flash" # gemini-2.5-flash, gemini-2.5-pro, gemini-3.1-flash, gemini-3.1-pro
|
|
77
|
+
max_calls_per_hour: 10 # Rate limit (default: 10)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Monitoring Config
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
monitoring:
|
|
84
|
+
interval: 60
|
|
85
|
+
auto_restart: true
|
|
86
|
+
max_restarts: 3
|
|
87
|
+
track_tps: true
|
|
88
|
+
track_players: true
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Security Config
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
security:
|
|
95
|
+
confirm_destructive: true # Require confirmation for restart/stop (default: true)
|
|
96
|
+
max_log_lines: 500 # Max log lines per request (default: 500)
|
|
97
|
+
max_backup_size_gb: 10 # Max backup size in GB (default: 10)
|
|
98
|
+
allowed_config_files: # Override default config file allowlist
|
|
99
|
+
- server.properties
|
|
100
|
+
- bukkit.yml
|
|
101
|
+
- spigot.yml
|
|
102
|
+
blocked_rcon_commands: # Extra blocked RCON commands
|
|
103
|
+
- timings
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Security Model
|
|
107
|
+
|
|
108
|
+
CraftClose includes a security sandbox to prevent accidental damage:
|
|
109
|
+
|
|
110
|
+
- **Path Jail** — File access restricted to server directory. No `../` traversal.
|
|
111
|
+
- **RCON Filter** — Dangerous commands (`stop`, `op`, `ban`, `reload`, etc.) are blocked by default.
|
|
112
|
+
- **Input Sanitizer** — All user-provided strings are cleaned before use in shell/RCON commands.
|
|
113
|
+
- **Audit Log** — All security-relevant actions are logged to `craftclose-audit.jsonl`.
|
|
114
|
+
- **Action Allowlist** — Only approved config files can be read/written. Destructive actions require confirmation.
|
|
115
|
+
|
|
116
|
+
## AI Features
|
|
117
|
+
|
|
118
|
+
### Crash Analysis
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
craftclose analyze /path/to/crash-2024-01-15-1.txt
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Config Optimization
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
craftclose optimize /opt/minecraft/
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Plugin Conflict Detection
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
craftclose conflicts /opt/minecraft/plugins/
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Requirements
|
|
137
|
+
|
|
138
|
+
- Node.js 20+
|
|
139
|
+
- At least one connector per server (SSH, RCON, or Pterodactyl)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# CraftClose Configuration
|
|
2
|
+
# Copy this to craftclose.yml and fill in your server details.
|
|
3
|
+
|
|
4
|
+
servers:
|
|
5
|
+
# Option 1: SSH + RCON (traditional setup)
|
|
6
|
+
- name: "my-server"
|
|
7
|
+
host: "192.168.1.100"
|
|
8
|
+
port: 25565
|
|
9
|
+
type: "paper"
|
|
10
|
+
|
|
11
|
+
ssh:
|
|
12
|
+
user: "ubuntu"
|
|
13
|
+
# Use key-based auth (recommended):
|
|
14
|
+
key: "~/.ssh/id_ed25519"
|
|
15
|
+
# Or password auth:
|
|
16
|
+
# password: "your-password"
|
|
17
|
+
|
|
18
|
+
rcon:
|
|
19
|
+
port: 25575
|
|
20
|
+
password: "your-rcon-password"
|
|
21
|
+
|
|
22
|
+
# Command to restart the server (via SSH)
|
|
23
|
+
restart_command: "docker restart my-minecraft-server"
|
|
24
|
+
|
|
25
|
+
# Path to server log (auto-detected if not specified)
|
|
26
|
+
# log_path: "/home/minecraft/server/logs/latest.log"
|
|
27
|
+
|
|
28
|
+
# Option 2: Pterodactyl Panel (easiest setup — no SSH needed!)
|
|
29
|
+
- name: "hosted-server"
|
|
30
|
+
host: "play.example.com" # Server IP (for ping checks)
|
|
31
|
+
type: "paper"
|
|
32
|
+
pterodactyl:
|
|
33
|
+
panel_url: "https://panel.yourhost.com"
|
|
34
|
+
api_key: "ptlc_xxxxxxxxxxxx" # Client API key from Panel → Account → API Credentials
|
|
35
|
+
server_id: "a1b2c3d4" # From your server URL: panel.yourhost.com/server/a1b2c3d4
|
|
36
|
+
|
|
37
|
+
# Option 3: Pterodactyl + RCON (panel for resources, RCON for TPS/players)
|
|
38
|
+
- name: "hybrid-server"
|
|
39
|
+
host: "play.example.com"
|
|
40
|
+
type: "paper"
|
|
41
|
+
pterodactyl:
|
|
42
|
+
panel_url: "https://panel.yourhost.com"
|
|
43
|
+
api_key: "ptlc_xxxxxxxxxxxx"
|
|
44
|
+
server_id: "a1b2c3d4"
|
|
45
|
+
rcon:
|
|
46
|
+
port: 25575
|
|
47
|
+
password: "rcon-pass"
|
|
48
|
+
|
|
49
|
+
# Alert channels (optional)
|
|
50
|
+
alerts:
|
|
51
|
+
telegram:
|
|
52
|
+
bot_token: "123456:ABC-DEF..."
|
|
53
|
+
chat_id: "-1001234567890"
|
|
54
|
+
discord:
|
|
55
|
+
webhook_url: "https://discord.com/api/webhooks/..."
|
|
56
|
+
|
|
57
|
+
# Monitoring settings
|
|
58
|
+
monitoring:
|
|
59
|
+
interval: 60 # Check every 60 seconds
|
|
60
|
+
auto_restart: true # Restart crashed servers automatically
|
|
61
|
+
max_restarts: 3 # Max restarts per 10-minute window (circuit breaker)
|
|
62
|
+
track_tps: true # Store TPS history
|
|
63
|
+
track_players: true # Store player count history
|
|
64
|
+
|
|
65
|
+
# AI Analysis (optional — requires Google Gemini API key)
|
|
66
|
+
# Get a key at https://aistudio.google.com/apikey
|
|
67
|
+
ai:
|
|
68
|
+
gemini_key: "your-gemini-api-key-here"
|
|
69
|
+
# model: "gemini-2.5-flash" # Options: gemini-2.5-flash (fast/cheap), gemini-2.5-pro (deep), gemini-3.1-flash (latest fast), gemini-3.1-pro (latest deep)
|
|
70
|
+
# max_calls_per_hour: 10 # Rate limit (default: 10)
|
|
71
|
+
|
|
72
|
+
# Security settings (all optional — safe defaults apply)
|
|
73
|
+
security:
|
|
74
|
+
confirm_destructive: true # Require confirmation for restart/stop
|
|
75
|
+
max_log_lines: 500 # Max log lines to read per request
|
|
76
|
+
max_backup_size_gb: 10 # Max backup size in GB
|
|
77
|
+
# allowed_config_files: # Override default config file allowlist
|
|
78
|
+
# - server.properties
|
|
79
|
+
# - bukkit.yml
|
|
80
|
+
# - spigot.yml
|
|
81
|
+
# - paper-global.yml
|
|
82
|
+
# blocked_rcon_commands: # Add extra blocked RCON commands
|
|
83
|
+
# - timings
|
|
84
|
+
# - spark
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CraftClose — BYOK AI Crash Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Uses the user's own Gemini API key for crash log analysis.
|
|
5
|
+
* No backend, no paid tier — direct Gemini API calls.
|
|
6
|
+
* AI analysis is always best-effort: returns null on failure, never blocks monitoring.
|
|
7
|
+
*/
|
|
8
|
+
import type { AiAnalysis } from "./types.js";
|
|
9
|
+
export interface AIAnalyzerOptions {
|
|
10
|
+
geminiKey: string;
|
|
11
|
+
/** Use flash (fast/cheap) or pro (deep) model */
|
|
12
|
+
model?: "gemini-2.5-flash" | "gemini-2.5-pro" | "gemini-3.1-flash" | "gemini-3.1-pro";
|
|
13
|
+
/** Max Gemini calls per hour (default: 10) */
|
|
14
|
+
maxCallsPerHour?: number;
|
|
15
|
+
/** Cache TTL in ms (default: 24 hours) */
|
|
16
|
+
cacheTtlMs?: number;
|
|
17
|
+
/** Request timeout in ms (default: 30000) */
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface CrashAnalysisRequest {
|
|
21
|
+
log: string;
|
|
22
|
+
context: {
|
|
23
|
+
version?: string;
|
|
24
|
+
plugins?: string[];
|
|
25
|
+
ram_mb?: number;
|
|
26
|
+
player_count?: number;
|
|
27
|
+
server_type?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface ConfigOptimizeRequest {
|
|
31
|
+
configs: Record<string, string>;
|
|
32
|
+
ram_mb: number;
|
|
33
|
+
player_target: number;
|
|
34
|
+
server_type: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ConfigRecommendation {
|
|
37
|
+
file: string;
|
|
38
|
+
setting: string;
|
|
39
|
+
current_value: string;
|
|
40
|
+
recommended_value: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
risk: "safe" | "low" | "medium";
|
|
43
|
+
}
|
|
44
|
+
export interface PluginConflictRequest {
|
|
45
|
+
plugins: Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
version: string;
|
|
48
|
+
}>;
|
|
49
|
+
crash_log?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface PluginConflict {
|
|
52
|
+
plugins: string[];
|
|
53
|
+
type: "known" | "suspected";
|
|
54
|
+
description: string;
|
|
55
|
+
resolution: string;
|
|
56
|
+
}
|
|
57
|
+
export declare class AIAnalyzer {
|
|
58
|
+
private readonly apiKey;
|
|
59
|
+
private readonly model;
|
|
60
|
+
private readonly maxCallsPerHour;
|
|
61
|
+
private readonly cacheTtlMs;
|
|
62
|
+
private readonly timeout;
|
|
63
|
+
private readonly crashCache;
|
|
64
|
+
private readonly callTimestamps;
|
|
65
|
+
constructor(options: AIAnalyzerOptions);
|
|
66
|
+
/**
|
|
67
|
+
* Analyze a crash log. Returns null if rate-limited, cached, or on error.
|
|
68
|
+
*/
|
|
69
|
+
analyzeCrash(request: CrashAnalysisRequest): Promise<AiAnalysis | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Optimize server configs. Returns null on failure.
|
|
72
|
+
*/
|
|
73
|
+
optimizeConfig(request: ConfigOptimizeRequest): Promise<ConfigRecommendation[] | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Detect plugin conflicts. Returns null on failure.
|
|
76
|
+
*/
|
|
77
|
+
detectConflicts(request: PluginConflictRequest): Promise<PluginConflict[] | null>;
|
|
78
|
+
/** Hash the first 2000 chars of a log for cache lookup. */
|
|
79
|
+
private hashLog;
|
|
80
|
+
/** Check cache for a previous analysis result. */
|
|
81
|
+
private getCached;
|
|
82
|
+
/** Sliding-window rate limiter. Returns false if limit exceeded. */
|
|
83
|
+
private checkRateLimit;
|
|
84
|
+
/** Call Gemini generateContent API. */
|
|
85
|
+
private callGemini;
|
|
86
|
+
/** Parse JSON from model response, with retry on parse failure. */
|
|
87
|
+
private parseJsonResponse;
|
|
88
|
+
private validateJson;
|
|
89
|
+
/** Build crash analysis prompt with few-shot examples and guardrails. */
|
|
90
|
+
private buildCrashAnalysisPrompt;
|
|
91
|
+
/** Build config optimization prompt. */
|
|
92
|
+
private buildConfigOptimizePrompt;
|
|
93
|
+
/** Build plugin conflict detection prompt. */
|
|
94
|
+
private buildConflictDetectionPrompt;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=ai-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-analyzer.d.ts","sourceRoot":"","sources":["../src/ai-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,i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