mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-06-09 22:12:07 +00:00
7d744eb4f2
Replace file-based OAuth token storage with DB-backed storage using llm_providers (access token) + config_secrets (refresh token). - Store: Add Settings JSONB field, chatgpt_oauth provider type - OAuth: DBTokenSource backed by provider + secrets stores - HTTP: oauth.go uses DB stores + registers provider in-memory - Providers: chatgpt_oauth support in registerInMemory/registerProvidersFromDB - Config: Remove HasOAuthToken, revert envFallback→envStr - CLI: auth commands call HTTP API on running gateway - Split codex.go (478→189 LOC) into codex.go + codex_build.go + codex_types.go - Frontend: Remove fake OAUTH_PROVIDER_ID, use real DB-backed providers - Tests: Rewrite with mock stores, fix SSE mock servers
75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/nextlevelbuilder/goclaw/pkg/protocol"
|
|
)
|
|
|
|
// Version is set at build time via -ldflags "-X github.com/nextlevelbuilder/goclaw/cmd.Version=v1.0.0"
|
|
var Version = "dev"
|
|
|
|
var (
|
|
cfgFile string
|
|
verbose bool
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "goclaw",
|
|
Short: "GoClaw — AI agent gateway",
|
|
Long: "GoClaw: multi-agent AI platform with WebSocket RPC, tool execution, and channel integration. A Go port of OpenClaw with enhanced security and multi-tenant support.",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
runGateway()
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: config.json or $GOCLAW_CONFIG)")
|
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "enable debug logging")
|
|
|
|
rootCmd.AddCommand(onboardCmd())
|
|
rootCmd.AddCommand(versionCmd())
|
|
rootCmd.AddCommand(pairingCmd())
|
|
rootCmd.AddCommand(agentCmd())
|
|
rootCmd.AddCommand(doctorCmd())
|
|
rootCmd.AddCommand(configCmd())
|
|
rootCmd.AddCommand(modelsCmd())
|
|
rootCmd.AddCommand(channelsCmd())
|
|
rootCmd.AddCommand(cronCmd())
|
|
rootCmd.AddCommand(skillsCmd())
|
|
rootCmd.AddCommand(sessionsCmd())
|
|
rootCmd.AddCommand(migrateCmd())
|
|
rootCmd.AddCommand(upgradeCmd())
|
|
rootCmd.AddCommand(authCmd())
|
|
}
|
|
|
|
func versionCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "version",
|
|
Short: "Print version information",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
fmt.Printf("goclaw %s (protocol %d)\n", Version, protocol.ProtocolVersion)
|
|
},
|
|
}
|
|
}
|
|
|
|
func resolveConfigPath() string {
|
|
if cfgFile != "" {
|
|
return cfgFile
|
|
}
|
|
if v := os.Getenv("GOCLAW_CONFIG"); v != "" {
|
|
return v
|
|
}
|
|
return "config.json"
|
|
}
|
|
|
|
// Execute runs the root cobra command.
|
|
func Execute() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|