MCPcopy Create free account
hub / github.com/astercloud/aster / ListRunning

Method ListRunning

server/handlers/tool_runtime.go:55–87  ·  view source on GitHub ↗

ListRunning 返回运行中的工具调用

(c *gin.Context)

Source from the content-addressed store, hash-verified

53
54// ListRunning 返回运行中的工具调用
55func (h *ToolRuntimeHandler) ListRunning(c *gin.Context) {
56 agentID := c.Query("agent_id")
57 if agentID == "" {
58 c.JSON(http.StatusBadRequest, gin.H{"error": "agent_id is required"})
59 return
60 }
61
62 // 优先返回实时运行表
63 if h.reg != nil {
64 if ag := h.reg.Get(agentID); ag != nil {
65 c.JSON(http.StatusOK, gin.H{"running": ag.ListRunningToolSnapshots()})
66 return
67 }
68 }
69
70 records, err := (*h.store).LoadToolCallRecords(c.Request.Context(), agentID)
71 if err != nil {
72 c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
73 return
74 }
75
76 running := make([]types.ToolCallSnapshot, 0)
77 for _, rec := range records {
78 if rec.State == types.ToolCallStateExecuting || rec.State == types.ToolCallStateQueued || rec.State == types.ToolCallStatePending || rec.State == types.ToolCallStateCancelling {
79 snapshot := mapRecordToSnapshot(&rec)
80 running = append(running, snapshot)
81 }
82 }
83
84 c.JSON(http.StatusOK, gin.H{
85 "running": running,
86 })
87}
88
89// GetResult 导出工具执行结果
90func (h *ToolRuntimeHandler) GetResult(c *gin.Context) {

Callers

nothing calls this directly

Calls 8

mapRecordToSnapshotFunction · 0.85
JSONMethod · 0.80
QueryMethod · 0.65
GetMethod · 0.65
LoadToolCallRecordsMethod · 0.65
ContextMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected