mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-04 00:03:59 +00:00
feat: complete HomeAgent architecture v2
- IO abstraction layer with OutputChannel routing and capability validation - Three-layer memory (Context-Document-Graph) with TF-IDF relevance pruning - OneBot V11 QQ protocol plugin with Reverse WebSocket client - Plugin system with hot-reload (SKILL.md + native factories) - Knowledge system with TF-IDF vector indexing - Personality system (personal.md) - Text memory (JSONL with rotation) - Change tracker (overlayfs) with rollback - Lua adapter VM - Design document (DESIGN.md) Module: gitcode.com/JianFeeeee/HomeAgent
This commit is contained in:
91
config/config.go
Normal file
91
config/config.go
Normal file
@ -0,0 +1,91 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"gitcode.com/JianFeeeee/HomeAgent/pkg/types"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const DefaultConfigPath = "/etc/homeagent/config.yaml"
|
||||
|
||||
func DefaultConfig() types.Config {
|
||||
return types.Config{
|
||||
Daemon: types.DaemonConfig{
|
||||
ListenAddr: ":8080",
|
||||
DataDir: "/var/lib/homeagent",
|
||||
HeartbeatInterval: 15 * time.Second,
|
||||
CheckInterval: 30 * time.Second,
|
||||
LogLevel: "info",
|
||||
},
|
||||
LLM: types.LLMConfig{
|
||||
Provider: "openai",
|
||||
Model: "deepseek-v4-flash",
|
||||
BaseURL: "https://api.deepseek.com",
|
||||
Temperature: 0.7,
|
||||
MaxTokens: 4096,
|
||||
},
|
||||
Defaults: types.AgentConfig{
|
||||
Image: "homeagent/agent-base:latest",
|
||||
LLMEndpoints: []string{"https://api.openai.com/v1"},
|
||||
SnapshotPolicy: types.SnapshotPolicy{
|
||||
Interval: 10 * time.Minute,
|
||||
MaxSnapshots: 20,
|
||||
PreAction: true,
|
||||
PostAction: false,
|
||||
},
|
||||
RollbackPolicy: types.RollbackPolicy{
|
||||
MaxRetries: 3,
|
||||
HealthThreshold: types.HealthDown,
|
||||
CooldownPeriod: 30 * time.Second,
|
||||
AutoRollback: true,
|
||||
},
|
||||
ResourceLimit: types.ResourceLimit{
|
||||
CPU: "2",
|
||||
Memory: "2g",
|
||||
Disk: "10g",
|
||||
Network: true,
|
||||
},
|
||||
OpenClawEnabled: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func Load(path string) (*types.Config, error) {
|
||||
cfg := DefaultConfig()
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return &cfg, nil
|
||||
}
|
||||
return nil, fmt.Errorf("read config: %w", err)
|
||||
}
|
||||
|
||||
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
||||
return nil, fmt.Errorf("parse config: %w", err)
|
||||
}
|
||||
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
func Save(path string, cfg *types.Config) error {
|
||||
dir := filepath.Dir(path)
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return fmt.Errorf("create config dir: %w", err)
|
||||
}
|
||||
|
||||
data, err := yaml.Marshal(cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal config: %w", err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(path, data, 0644); err != nil {
|
||||
return fmt.Errorf("write config: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
34
config/config.yaml
Normal file
34
config/config.yaml
Normal file
@ -0,0 +1,34 @@
|
||||
daemon:
|
||||
listen_addr: ":8080"
|
||||
data_dir: "/var/lib/homeagent"
|
||||
heartbeat_interval: 15s
|
||||
check_interval: 30s
|
||||
log_level: "info"
|
||||
|
||||
defaults:
|
||||
image: "homeagent/agent-base:latest"
|
||||
llm_endpoints:
|
||||
- "https://api.openai.com/v1"
|
||||
snapshot_policy:
|
||||
interval: 10m
|
||||
max_snapshots: 20
|
||||
pre_action: true
|
||||
post_action: false
|
||||
rollback_policy:
|
||||
max_retries: 3
|
||||
health_threshold: 3
|
||||
cooldown_period: 30s
|
||||
auto_rollback: true
|
||||
resource_limit:
|
||||
cpu: "2"
|
||||
memory: "2g"
|
||||
disk: "10g"
|
||||
network: true
|
||||
openclaw_enabled: true
|
||||
|
||||
agents:
|
||||
- id: "default"
|
||||
name: "Default Agent"
|
||||
image: "homeagent/agent-base:latest"
|
||||
llm_endpoints:
|
||||
- "https://api.openai.com/v1"
|
||||
Reference in New Issue
Block a user