From a00a1cc32c2f8d9c6b7f34b76d3479c2f1d554e4 Mon Sep 17 00:00:00 2001 From: jingrow Date: Mon, 3 Nov 2025 01:05:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0get=5Flocal=5Fagent=5Flist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/api/local_app.py | 114 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/jcloud/api/local_app.py b/jcloud/api/local_app.py index 612b86f..27ee490 100644 --- a/jcloud/api/local_app.py +++ b/jcloud/api/local_app.py @@ -107,6 +107,120 @@ def get_local_app_list(filters=None, order_by=None, limit_start=None, limit_page return result +@jingrow.whitelist(allow_guest=True) +def get_local_node_list(filters=None, order_by=None, limit_start=None, limit_page_length=None): + """获取本地节点列表""" + + # 构建查询条件 + query_filters = {"public": 1} + + if filters: + if isinstance(filters, str): + import json + filters = json.loads(filters) + query_filters.update(filters) + + # 默认排序 + if not order_by: + order_by = "node_type asc" + + # 获取节点列表 + nodes = jingrow.get_all( + "Local Node", + filters=query_filters, + fields=[ + "name", "node_type", "title", "subtitle", + "enabled", "public", "team", "status", "repository_url", + "file_url", "node_image", "creation", "modified" + ], + order_by=order_by, + limit_start=limit_start, + limit_page_length=limit_page_length + ) + + # 批量获取团队用户名称 + team_user_names = _get_team_user_names(nodes) + + # 格式化返回数据 + result = [] + for node in nodes: + node_data = { + "name": node.name, + "node_type": node.node_type, + "title": node.title, + "subtitle": node.subtitle, + "enabled": node.enabled, + "public": node.public, + "team": team_user_names.get(node.team), + "status": node.status, + "repository_url": node.repository_url, + "file_url": node.file_url, + "node_image": node.node_image, + "creation": node.creation, + "modified": node.modified + } + result.append(node_data) + + return result + + +@jingrow.whitelist(allow_guest=True) +def get_local_agent_list(filters=None, order_by=None, limit_start=None, limit_page_length=None): + """获取本地Agent列表""" + + # 构建查询条件 + query_filters = {"public": 1} + + if filters: + if isinstance(filters, str): + import json + filters = json.loads(filters) + query_filters.update(filters) + + # 默认排序 + if not order_by: + order_by = "agent_name asc" + + # 获取Agent列表 + agents = jingrow.get_all( + "Local Agent", + filters=query_filters, + fields=[ + "name", "agent_name", "title", "subtitle", + "enabled", "public", "team", "status", "repository_url", + "file_url", "agent_image", "creation", "modified" + ], + order_by=order_by, + limit_start=limit_start, + limit_page_length=limit_page_length + ) + + # 批量获取团队用户名称 + team_user_names = _get_team_user_names(agents) + + # 格式化返回数据 + result = [] + for agent in agents: + agent_data = { + "name": agent.name, + "agent_name": agent.agent_name, + "title": agent.title, + "subtitle": agent.subtitle, + "enabled": agent.enabled, + "public": agent.public, + "team": team_user_names.get(agent.team), + "status": agent.status, + "repository_url": agent.repository_url, + "file_url": agent.file_url, + "agent_image": agent.agent_image, + "creation": agent.creation, + "modified": agent.modified + } + result.append(agent_data) + + return result + + @jingrow.whitelist(allow_guest=True) def get_local_app(name): """获取本地应用详情"""