HandleRequest 处理 JSON-RPC 请求
(ctx context.Context, agentID string, req *JSONRPCRequest)
| 38 | |
| 39 | // HandleRequest 处理 JSON-RPC 请求 |
| 40 | func (s *Server) HandleRequest(ctx context.Context, agentID string, req *JSONRPCRequest) *JSONRPCResponse { |
| 41 | switch req.Method { |
| 42 | case "message/send": |
| 43 | return s.handleMessageSend(ctx, agentID, req) |
| 44 | case "message/stream": |
| 45 | return s.handleMessageStream(ctx, agentID, req) |
| 46 | case "tasks/get": |
| 47 | return s.handleTasksGet(ctx, agentID, req) |
| 48 | case "tasks/cancel": |
| 49 | return s.handleTasksCancel(ctx, agentID, req) |
| 50 | default: |
| 51 | return NewErrorResponse(req.ID, ErrorCodeMethodNotFound, |
| 52 | "method not found: "+req.Method, nil) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | // GetAgentCard 获取 Agent Card |
| 57 | func (s *Server) GetAgentCard(agentID string) (*AgentCard, error) { |