RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Go CLI: show hardware (#19991)
Jin Haic69960bc26a4
diff --git a/go.mod b/go.modindex 4840b931e4..56f5f7db1d 100644--- a/go.mod+++ b/go.mod@@ -62,6 +62,7 @@ require (github.com/pkoukk/tiktoken-go v0.1.8github.com/redis/go-redis/v9 v9.18.0github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d+ github.com/shirou/gopsutil/v3 v3.24.5github.com/signintech/gopdf v0.36.1github.com/siongui/gojianfan v0.0.0-20210926212422-2f175ac615degithub.com/spf13/viper v1.18.2@@ -151,6 +152,7 @@ require (github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // indirectgithub.com/go-logr/logr v1.4.3 // indirectgithub.com/go-logr/stdr v1.2.2 // indirect+ github.com/go-ole/go-ole v1.2.6 // indirectgithub.com/go-playground/locales v0.14.1 // indirectgithub.com/go-playground/universal-translator v0.18.1 // indirectgithub.com/go-playground/validator/v10 v10.30.2 // indirect@@ -178,6 +180,7 @@ require (github.com/klauspost/cpuid/v2 v2.3.0 // indirectgithub.com/klauspost/crc32 v1.3.0 // indirectgithub.com/leodido/go-urn v1.4.0 // indirect+ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirectgithub.com/magiconair/properties v1.8.10 // indirectgithub.com/mailru/easyjson v0.7.7 // indirectgithub.com/mattn/go-isatty v0.0.22 // indirect@@ -197,6 +200,7 @@ require (github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311 // indirectgithub.com/pierrec/lz4/v4 v4.1.18 // indirectgithub.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect+ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirectgithub.com/quic-go/qpack v0.6.0 // indirectgithub.com/quic-go/quic-go v0.59.1 // indirectgithub.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect@@ -207,6 +211,7 @@ require (github.com/sagikazarmark/slog-shim v0.1.0 // indirectgithub.com/segmentio/asm v1.1.3 // indirectgithub.com/segmentio/encoding v0.5.4 // indirect+ github.com/shoenig/go-m1cpu v0.1.6 // indirectgithub.com/sirupsen/logrus v1.9.3 // indirectgithub.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirectgithub.com/sourcegraph/conc v0.3.0 // indirect@@ -222,6 +227,8 @@ require (github.com/tiendc/go-deepcopy v1.7.2 // indirectgithub.com/tinylib/msgp v1.6.1 // indirectgithub.com/tjfoc/gmsm v1.4.1 // indirect+ github.com/tklauser/go-sysconf v0.3.12 // indirect+ github.com/tklauser/numcpus v0.6.1 // indirectgithub.com/twitchyliquid64/golang-asm v0.15.1 // indirectgithub.com/ugorji/go/codec v1.3.1 // indirectgithub.com/wk8/go-ordered-map/v2 v2.1.8 // indirect@@ -230,6 +237,7 @@ require (github.com/yargevad/filepathx v1.0.0 // indirectgithub.com/yosida95/uritemplate/v3 v3.0.2 // indirectgithub.com/yuin/gopher-lua v1.1.1 // indirect+ github.com/yusufpapurcu/wmi v1.2.4 // indirectgo.mongodb.org/mongo-driver/v2 v2.6.0 // indirectgo.opentelemetry.io/auto/sdk v1.2.1 // indirectgo.opentelemetry.io/contrib/detectors/gcp v1.44.0 // indirectdiff --git a/go.sum b/go.sumindex 6a94db47d7..0c21699a5c 100644--- a/go.sum+++ b/go.sum@@ -270,6 +270,8 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=+github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=+github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=@@ -314,6 +316,7 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5agithub.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=+github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=@@ -400,6 +403,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=+github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=+github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=@@ -476,6 +481,8 @@ github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=+github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=+github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=@@ -510,6 +517,12 @@ github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJngithub.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=+github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=+github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=+github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=+github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=+github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=+github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=github.com/signintech/gopdf v0.36.1 h1:cGpvEKvvqCV+ZXB9R2SQoWgouW91JpwsgoQEhLxIdp0=github.com/signintech/gopdf v0.36.1/go.mod h1:d23eO35GpEliSrF22eJ4bsM3wVeQJTjXTHq5x5qGKjA=github.com/siongui/gojianfan v0.0.0-20210926212422-2f175ac615de h1:1/P9CcR8iENN9ybbSRWohRd3rsPp9tEWlTS/7ygvjHE=@@ -575,6 +588,10 @@ github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77rogithub.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=+github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=+github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=+github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=+github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=github.com/ucloud/ucloud-sandbox-sdk-go v0.0.0-20260807065450-08464aef9ed5 h1:okVowRVpknqiBSurlOrG3YIqp5j4VxXtdS938XVAiWY=@@ -609,6 +626,8 @@ github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U=github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=+github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=+github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=@@ -738,10 +757,12 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hgolang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=+golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=+golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=@@ -751,6 +772,7 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBcgolang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=+golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=diff --git a/internal/admin/handler.go b/internal/admin/handler.goindex 08fb5814fd..ef81ecd76d 100644--- a/internal/admin/handler.go+++ b/internal/admin/handler.go@@ -1275,3 +1275,12 @@ func (h *Handler) PingEngine(c *gin.Context) {common.SuccessNoMessage(c, "SUCCESS")}++func (h *Handler) GetHardwareInfo(c *gin.Context) {+ hardwareInfo, err := utility.GetHardwareInfo()+ if err != nil {+ common.ErrorWithCode(c, common.CodeServerError, err.Error())+ return+ }+ common.SuccessWithData(c, hardwareInfo, "SUCCESS")+}diff --git a/internal/admin/router.go b/internal/admin/router.goindex e778bd01e7..b54b1c76ba 100644--- a/internal/admin/router.go+++ b/internal/admin/router.go@@ -93,6 +93,7 @@ func (r *Router) Setup(engine *gin.Engine) {// Environmentsprotected.GET("/environments", r.handler.ListEnvironments)+ protected.GET("/hardware", r.handler.GetHardwareInfo)// Versionprotected.GET("/version", r.handler.GetVersion)diff --git a/internal/cli/admin_parser.go b/internal/cli/admin_parser.goindex ca93a8c409..3ea4f462b3 100644--- a/internal/cli/admin_parser.go+++ b/internal/cli/admin_parser.go@@ -430,6 +430,8 @@ func (p *Parser) parseAdminShowCommands() (*Command, error) {return p.parseAdminShowTasks()case TokenLog:return p.parseAdminShowLogCommands()+ case TokenHardware:+ return p.parseAdminShowHardware()default:return nil, fmt.Errorf("unknown SHOW target: %s", p.curToken.Value)}@@ -3079,6 +3081,18 @@ func (p *Parser) parseAdminShowLogLevel() (*Command, error) {return cmd, nil}+func (p *Parser) parseAdminShowHardware() (*Command, error) {+ p.nextToken() // consume HARDWARE+ cmd := NewCommand("admin_show_hardware")++ // Semicolon is optional+ if p.curToken.Type == TokenSemicolon {+ p.nextToken()+ }++ return cmd, nil+}+// PURGE PREVIEW ORPHAN// PURGE ORPHANdiff --git a/internal/cli/cli_http.go b/internal/cli/cli_http.goindex bf6d17d29f..49c5b116ae 100644--- a/internal/cli/cli_http.go+++ b/internal/cli/cli_http.go@@ -293,6 +293,8 @@ func (c *CLI) ExecuteAdminCommand(commandCount int, cmd *Command) (ResponseIf, ereturn c.CommonShowAPIServerCommand(commandCount, cmd)case "admin_show_log_level":return c.AdminShowLogLevelCommand(commandCount, cmd)+ case "admin_show_hardware":+ return c.CommonShowHardwareCommand(commandCount, cmd)case "admin_list_api_servers":return c.CommonListAPIServersCommand(commandCount, cmd)case "api_add_api_server":@@ -496,6 +498,8 @@ func (c *CLI) ExecuteUserCommand(commandCount int, cmd *Command) (ResponseIf, erreturn c.CommonShowAPIServerCommand(commandCount, cmd)case "api_show_log_level":return c.APIShowLogLevelCommand(commandCount, cmd)+ case "api_show_hardware":+ return c.CommonShowHardwareCommand(commandCount, cmd)case "api_list_api_servers":return c.CommonListAPIServersCommand(commandCount, cmd)case "api_list_environments":diff --git a/internal/cli/common_command.go b/internal/cli/common_command.goindex 243eb32feb..6c869bc3d9 100644--- a/internal/cli/common_command.go+++ b/internal/cli/common_command.go@@ -950,6 +950,38 @@ func (c *CLI) CommonShowAPIServerCommand(commandCount int, cmd *Command) (Responreturn result, nil}+func (c *CLI) CommonShowHardwareCommand(commandCount int, cmd *Command) (ResponseIf, error) {+ var resp *Response+ var err error+ switch c.Config.CLIMode {+ case AdminMode:+ resp, err = c.AdminServerClient.Request(commandCount, "GET", "/admin/hardware", "web", nil, nil)+ case APIMode:+ resp, err = c.APIServerClientMap[c.Config.APIClientConfig.CurrentAPIServer].Request(commandCount, "GET", "/system/hardware", "web", nil, nil)+ default:+ return nil, fmt.Errorf("invalid server type")+ }++ if err != nil {+ return nil, fmt.Errorf("failed to show hardware: %w", err)+ }++ if resp.StatusCode != 200 {+ return nil, fmt.Errorf("failed to show hardware: HTTP %d, body: %s", resp.StatusCode, string(resp.Body))+ }++ var result CommonDataResponse+ if err = json.Unmarshal(resp.Body, &result); err != nil {+ return nil, fmt.Errorf("failed to show hardware: invalid JSON (%w)", err)+ }++ if result.Code != 0 {+ return nil, fmt.Errorf("%s", result.Message)+ }+ result.Duration = resp.Duration+ return &result, nil+}+func (c *CLI) CommonListAPIServersCommand(commandCount int, cmd *Command) (ResponseIf, error) {var result CommonResponsediff --git a/internal/cli/lexer.go b/internal/cli/lexer.goindex 46dfc6eeab..ea8eaa3061 100644--- a/internal/cli/lexer.go+++ b/internal/cli/lexer.go@@ -535,6 +535,8 @@ func (l *Lexer) lookupIdent(ident string) Token {return Token{Type: TokenWindow, Value: ident}case "ACTIVITY":return Token{Type: TokenActivity, Value: ident}+ case "HARDWARE":+ return Token{Type: TokenHardware, Value: ident}case "PURGE":return Token{Type: TokenPurge, Value: ident}case "PREVIEW":diff --git a/internal/cli/types.go b/internal/cli/types.goindex d525bb5ec9..e89ad2a8b7 100644--- a/internal/cli/types.go+++ b/internal/cli/types.go@@ -198,6 +198,7 @@ const (TokenDaysTokenWindowTokenActivity+ TokenHardwareTokenDataTokenPurgeTokenPlandiff --git a/internal/cli/user_parser.go b/internal/cli/user_parser.goindex ac74d1751b..f8df9dc3d5 100644--- a/internal/cli/user_parser.go+++ b/internal/cli/user_parser.go@@ -631,6 +631,8 @@ func (p *Parser) parseAPIShowCommands() (*Command, error) {return p.parseAPIShowAPI()case TokenLog:return p.parseAPIShowLogCommands()+ case TokenHardware:+ return p.parseAPIShowHardware()default:return nil, fmt.Errorf("unknown SHOW target: %s", p.curToken.Value)}@@ -892,6 +894,19 @@ func (p *Parser) parseShowLogLevel() (*Command, error) {return cmd, nil}+// SHOW HARDWARE+func (p *Parser) parseAPIShowHardware() (*Command, error) {+ p.nextToken() // consume HARDWARE+ cmd := NewCommand("api_show_hardware")++ // Semicolon is optional+ if p.curToken.Type == TokenSemicolon {+ p.nextToken()+ }++ return cmd, nil+}+// endregion SHOW commands// region CREATE commandsdiff --git a/internal/handler/system.go b/internal/handler/system.goindex e0756f58e0..9bf2e61013 100644--- a/internal/handler/system.go+++ b/internal/handler/system.go@@ -21,6 +21,7 @@ import ("ragflow/internal/common""ragflow/internal/server""ragflow/internal/service"+ "ragflow/internal/utility""github.com/gin-gonic/gin")@@ -273,3 +274,12 @@ func (h *SystemHandler) ListEnvironments(c *gin.Context) {func (h *SystemHandler) Language(c *gin.Context) {common.SuccessWithData(c, map[string]string{"language": "go"}, "success")}++func (h *SystemHandler) GetHardwareInfo(c *gin.Context) {+ hardwareInfo, err := utility.GetHardwareInfo()+ if err != nil {+ common.ErrorWithCode(c, common.CodeServerError, err.Error())+ return+ }+ common.SuccessWithData(c, hardwareInfo, "SUCCESS")+}diff --git a/internal/router/router.go b/internal/router/router.goindex 970aa1658b..a12eeae0c3 100644--- a/internal/router/router.go+++ b/internal/router/router.go@@ -689,6 +689,8 @@ func (r *Router) Setup(engine *gin.Engine) {// delete key /api/v1/system/keys/:key DELETEkeys.DELETE("/:key", r.systemHandler.DeleteKey)}++ system.GET("/hardware", r.systemHandler.GetHardwareInfo)}// Document routesdiff --git a/internal/utility/hardware.go b/internal/utility/hardware.gonew file mode 100644index 0000000000..76e0b9a6f9--- /dev/null+++ b/internal/utility/hardware.go@@ -0,0 +1,51 @@+//+// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.+//++package utility++import (+ "fmt"+ "runtime"++ "github.com/shirou/gopsutil/v3/cpu"+ "github.com/shirou/gopsutil/v3/mem"+)++type HardwareInfo struct {+ Arch string+ CPUCores int+ Memory uint64+ OS string+}++func GetHardwareInfo() (*HardwareInfo, error) {+ logicalCores, err := cpu.Counts(true)+ if err != nil {+ return nil, fmt.Errorf("fail to get logical cores count: %w", err)+ }++ vmStat, err := mem.VirtualMemory()+ if err != nil {+ return nil, fmt.Errorf("fail to get virtual memory info: %w", err)+ }++ return &HardwareInfo{+ Arch: runtime.GOARCH,+ CPUCores: logicalCores,+ Memory: vmStat.Total,+ OS: runtime.GOOS,+ }, nil+}