shell: support Windows cmd /C; normalize date/time; allow all commands; add tests
This commit is contained in:
@@ -11,22 +11,23 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
MessageChannel string
|
||||
LogLevel string
|
||||
SoulPath string
|
||||
SkillsDir string
|
||||
ReactMaxSteps int
|
||||
ToolCallTimeoutSec int
|
||||
ToolOutputMaxChars int
|
||||
EnableCapabilityGap bool
|
||||
AutoSkillDir string
|
||||
GapDraftTriggerCount int
|
||||
GapClusterLookbackHours int
|
||||
MessageChannel string
|
||||
LogLevel string
|
||||
SoulPath string
|
||||
SkillsDir string
|
||||
ReactMaxSteps int
|
||||
ToolCallTimeoutSec int
|
||||
ToolOutputMaxChars int
|
||||
EnableCapabilityGap bool
|
||||
AutoSkillDir string
|
||||
GapDraftTriggerCount int
|
||||
GapClusterLookbackHours int
|
||||
|
||||
Telegram TelegramConfig
|
||||
Feishu FeishuConfig
|
||||
LLM LLMConfig
|
||||
Security SecurityConfig
|
||||
Telegram TelegramConfig
|
||||
Feishu FeishuConfig
|
||||
LLM LLMConfig
|
||||
Security SecurityConfig
|
||||
WebSearch WebSearchConfig
|
||||
|
||||
SQLitePath string
|
||||
}
|
||||
@@ -56,6 +57,11 @@ type SecurityConfig struct {
|
||||
WorkDir string
|
||||
}
|
||||
|
||||
type WebSearchConfig struct {
|
||||
Engine string // "duckduckgo" or "brave"
|
||||
APIKey string
|
||||
}
|
||||
|
||||
func Load() (Config, error) {
|
||||
agentWorkspaceDir := resolveAgentWorkspaceDir()
|
||||
if err := preloadEnvFiles(); err != nil {
|
||||
@@ -65,14 +71,14 @@ func Load() (Config, error) {
|
||||
defaultDataDir := filepath.Join(agentWorkspaceDir, "data")
|
||||
|
||||
cfg := Config{
|
||||
MessageChannel: defaultIfEmpty(os.Getenv("MESSAGE_CHANNEL"), "telegram"),
|
||||
LogLevel: defaultIfEmpty(os.Getenv("LOG_LEVEL"), "info"),
|
||||
SoulPath: defaultIfEmpty(os.Getenv("SOUL_PATH"), filepath.Join(agentWorkspaceDir, "bot_context", "soul.md")),
|
||||
SkillsDir: defaultIfEmpty(os.Getenv("SKILLS_DIR"), filepath.Join(agentWorkspaceDir, "skills")),
|
||||
ReactMaxSteps: intFromEnv("REACT_MAX_STEPS", 0),
|
||||
ToolCallTimeoutSec: intFromEnv("TOOL_CALL_TIMEOUT_SEC", 15),
|
||||
ToolOutputMaxChars: intFromEnv("TOOL_OUTPUT_MAX_CHARS", 4000),
|
||||
EnableCapabilityGap: boolFromEnv("ENABLE_CAPABILITY_GAP", true),
|
||||
MessageChannel: defaultIfEmpty(os.Getenv("MESSAGE_CHANNEL"), "telegram"),
|
||||
LogLevel: defaultIfEmpty(os.Getenv("LOG_LEVEL"), "info"),
|
||||
SoulPath: defaultIfEmpty(os.Getenv("SOUL_PATH"), filepath.Join(agentWorkspaceDir, "bot_context", "soul.md")),
|
||||
SkillsDir: defaultIfEmpty(os.Getenv("SKILLS_DIR"), filepath.Join(agentWorkspaceDir, "skills")),
|
||||
ReactMaxSteps: intFromEnv("REACT_MAX_STEPS", 0),
|
||||
ToolCallTimeoutSec: intFromEnv("TOOL_CALL_TIMEOUT_SEC", 15),
|
||||
ToolOutputMaxChars: intFromEnv("TOOL_OUTPUT_MAX_CHARS", 4000),
|
||||
EnableCapabilityGap: boolFromEnv("ENABLE_CAPABILITY_GAP", true),
|
||||
AutoSkillDir: defaultIfEmpty(os.Getenv("AUTO_SKILL_DIR"), filepath.Join(agentWorkspaceDir, "skills")),
|
||||
GapDraftTriggerCount: intFromEnv("GAP_DRAFT_TRIGGER_COUNT", 3),
|
||||
GapClusterLookbackHours: intFromEnv("GAP_CLUSTER_LOOKBACK_HOURS", 168),
|
||||
@@ -93,6 +99,10 @@ func Load() (Config, error) {
|
||||
Model: defaultIfEmpty(os.Getenv("LLM_MODEL"), "gpt-4o-mini"),
|
||||
},
|
||||
SQLitePath: defaultIfEmpty(os.Getenv("SQLITE_PATH"), filepath.Join(defaultDataDir, "laodingbot.db")),
|
||||
WebSearch: WebSearchConfig{
|
||||
Engine: defaultIfEmpty(os.Getenv("WEB_SEARCH_ENGINE"), "duckduckgo"),
|
||||
APIKey: strings.TrimSpace(os.Getenv("WEB_SEARCH_API_KEY")),
|
||||
},
|
||||
Security: SecurityConfig{
|
||||
AllowedDirs: splitCSV(defaultIfEmpty(os.Getenv("ALLOWED_DIRS"), strings.Join([]string{agentWorkspaceDir, defaultDataDir, defaultWorkSubdir}, ","))),
|
||||
AllowedCommands: splitCSV(defaultIfEmpty(os.Getenv("ALLOWED_COMMANDS"), "pwd,ls,cat,echo,grep,find,head,tail,go")),
|
||||
|
||||
Reference in New Issue
Block a user