Passer les reponses d'agents Mastra dans jq pour coloriser le raisonnement et les appels d'outils dans le terminal
L’API HTTP d’agents de Mastra retourne une structure JSON avec des steps, chacune contenant des elements content types comme reasoning, tool-call, tool-result et text. La sortie brute est dense. Commencez par l’explorer: # Appeler l'API et voir la structure brute http localhost:4111/api/agents/weather-agent/generate \ messages[0]="what's the weather in montreal?" | jq . # Obtenir uniquement la reponse finale http localhost:4111/api/agents/weather-agent/generate \ messages[0]="what's the weather in montreal?" | jq -r '.text' # Explorer ce qui se trouve dans les steps http localhost:4111/api/agents/weather-agent/generate \ messages[0]="what's the weather in montreal?" | jq '.steps[].content[] | .type' # "reasoning" # "tool-call" # "tool-result" # "text" # "reasoning" # "text" # Voir quels champs chaque type possede http localhost:4111/api/agents/weather-agent/generate \ messages[0]="what's the weather in montreal?" | jq '.steps[].content[] | select(.type == "tool-call")' Une fois la structure comprise, passez dans jq -r avec des sequences d’echappement ANSI en ligne pour coloriser chaque element: ...