MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / buildAgentItem

Function buildAgentItem

agent/app/service/agents_utils.go:335–381  ·  view source on GitHub ↗
(agent *model.Agent, appInstall *model.AppInstall, envMap map[string]interface{})

Source from the content-addressed store, hash-verified

333}
334
335func buildAgentItem(agent *model.Agent, appInstall *model.AppInstall, envMap map[string]interface{}) dto.AgentItem {
336 agentType := agent.AgentType
337 item := dto.AgentItem{
338 ID: agent.ID,
339 Name: agent.Name,
340 Remark: agent.Remark,
341 AgentType: agentType,
342 Provider: agent.Provider,
343 ProviderName: providercatalog.DisplayName(agent.Provider),
344 Model: agent.Model,
345 APIType: agent.APIType,
346 MaxTokens: agent.MaxTokens,
347 ContextWindow: agent.ContextWindow,
348 BaseURL: agent.BaseURL,
349 APIKey: maskKey(agent.APIKey),
350 Token: agent.Token,
351 Status: agent.Status,
352 Message: agent.Message,
353 AppInstallID: agent.AppInstallID,
354 WebsiteID: agent.WebsiteID,
355 AccountID: agent.AccountID,
356 ConfigPath: agent.ConfigPath,
357 CreatedAt: agent.CreatedAt,
358 }
359 if appInstall != nil && appInstall.ID > 0 {
360 item.Container = appInstall.ContainerName
361 item.AppVersion = appInstall.Version
362 if agentType == constant.AppOpenclaw {
363 if isOpenclawHTTPSWindowVersion(appInstall.Version) {
364 item.WebUIPort = appInstall.HttpsPort
365 } else {
366 item.WebUIPort = appInstall.HttpPort
367 }
368 } else {
369 item.WebUIPort = appInstall.HttpPort
370 }
371 item.Path = appInstall.GetPath()
372 item.Status = appInstall.Status
373 item.Message = appInstall.Message
374 if envMap != nil {
375 if bridge, ok := envMap["PANEL_APP_PORT_BRIDGE"]; ok {
376 item.BridgePort = toInt(bridge)
377 }
378 }
379 }
380 return item
381}
382
383func isAgentAppKey(appKey string) bool {
384 return appKey == constant.AppOpenclaw || appKey == constant.AppCopaw || appKey == constant.AppHermesAgent

Callers 2

CreateMethod · 0.85
PageMethod · 0.85

Calls 4

maskKeyFunction · 0.85
toIntFunction · 0.85
GetPathMethod · 0.45

Tested by

no test coverage detected