MCPcopy Index your code
hub / github.com/github/copilot-sdk / executeCommandAndRespond

Method executeCommandAndRespond

go/session.go:883–914  ·  view source on GitHub ↗

executeCommandAndRespond dispatches a command.execute event to the registered handler and sends the result (or error) back via the RPC layer.

(requestID, commandName, command, args string)

Source from the content-addressed store, hash-verified

881// executeCommandAndRespond dispatches a command.execute event to the registered handler
882// and sends the result (or error) back via the RPC layer.
883func (s *Session) executeCommandAndRespond(requestID, commandName, command, args string) {
884 ctx := context.Background()
885 handler, ok := s.getCommandHandler(commandName)
886 if !ok {
887 errMsg := fmt.Sprintf("Unknown command: %s", commandName)
888 s.RPC.Commands.HandlePendingCommand(ctx, &rpc.CommandsHandlePendingCommandRequest{
889 RequestID: requestID,
890 Error: &errMsg,
891 })
892 return
893 }
894
895 cmdCtx := CommandContext{
896 SessionID: s.SessionID,
897 Command: command,
898 CommandName: commandName,
899 Args: args,
900 }
901
902 if err := handler(cmdCtx); err != nil {
903 errMsg := err.Error()
904 s.RPC.Commands.HandlePendingCommand(ctx, &rpc.CommandsHandlePendingCommandRequest{
905 RequestID: requestID,
906 Error: &errMsg,
907 })
908 return
909 }
910
911 s.RPC.Commands.HandlePendingCommand(ctx, &rpc.CommandsHandlePendingCommandRequest{
912 RequestID: requestID,
913 })
914}
915
916// registerElicitationHandler registers an elicitation handler for this session.
917func (s *Session) registerElicitationHandler(handler ElicitationHandler) {

Callers 1

handleBroadcastEventMethod · 0.95

Calls 4

getCommandHandlerMethod · 0.95
handlerFunction · 0.85
HandlePendingCommandMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected