package main import ( "flag" "os" "devops.lty.name/luo/chatai/internal/config" "devops.lty.name/luo/chatai/internal/log" "devops.lty.name/luo/chatai/internal/server" "github.com/gin-gonic/gin" ) func main() { listen := flag.String("listen", config.FlagListen, "http listen address") agentsDir := flag.String("agents", config.FlagAgentsDir, "directory to store agent configurations") logLevel := flag.String("level", config.FlagLogLevel, "log level (dbg, inf, wrn, err)") msgLogPath := flag.String("msglog", config.FlagMsgLogPath, "audit log path") model := flag.String("model", config.DefaultGoogleAIModel, "Google AI model (gemini-1.5-flash, gemini-2.0-flash-exp)") flag.Parse() server.GoogleAIKey = os.Getenv("GOOGLE_AI_KEY") if server.GoogleAIKey == "" { log.T("main").Errf("GOOGLE_AI_KEY environment variable is not set") os.Exit(1) } server.GoogleAIModel = *model log.Setup(log.LogLevel(log.ParseLogLevel(*logLevel))) log.T("main").Inff("AI-Agent version %s, %s mode (build %s)", config.BuildVersion, config.BuildMode, config.BuildTime) log.T("main").Inff("%s", config.Copyright) log.SetupGin1() if config.BuildMode == "release" { gin.SetMode(gin.ReleaseMode) } engine := gin.New() engine.Use(gin.Recovery()) log.SetupGin2(engine) server.Setup(engine, *agentsDir, *msgLogPath) log.T("main").Inff("Starting server on %s", *listen) err := engine.Run(*listen) if err != nil { log.T("main").Errf("Server error: %v", err) os.Exit(1) } }