/* ┌──────────────────────────────────────────────────────────────────────────────┐ │ @author: Davidson Gomes │ │ @file: /app/documentation/components/TechnicalDetailsSection.tsx │ │ Developed by: Davidson Gomes │ │ Creation date: May 13, 2025 │ │ Contact: contato@evolution-api.com │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @copyright © Evolution API 2025. All rights reserved. │ │ Licensed under the Apache License, Version 2.0 │ │ │ │ You may not use this file except in compliance with the License. │ │ You may obtain a copy of the License at │ │ │ │ http://www.apache.org/licenses/LICENSE-2.0 │ │ │ │ Unless required by applicable law or agreed to in writing, software │ │ distributed under the License is distributed on an "AS IS" BASIS, │ │ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @important │ │ For any future changes to the code in this file, it is recommended to │ │ include, together with the modification, the information of the developer │ │ who changed it and the date of modification. │ └──────────────────────────────────────────────────────────────────────────────┘ */ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { ClipboardCopy } from "lucide-react"; import { Separator } from "@/components/ui/separator"; import { CodeBlock } from "@/app/documentation/components/CodeBlock"; interface TechnicalDetailsSectionProps { copyToClipboard: (text: string) => void; } export function TechnicalDetailsSection({ copyToClipboard }: TechnicalDetailsSectionProps) { return ( Technical Details of the Methods

Method message/send

The message/send method performs a standard HTTP request and waits for the complete response.

Request:

Headers:

Response:

Method message/stream

The message/stream method uses Server-Sent Events (SSE) to receive real-time updates.

Request:

Headers:

SSE Event Format:

Each event follows the standard Server-Sent Events (SSE) format, with the "data:" prefix followed by the JSON content and terminated by two newlines ("\n\n"):

Event Types:

  • Status Updates: Contains the status field with information about the task status.
  • Artifact Updates: Contains the artifact field with the content generated by the agent.
  • Ping Events: Simple events with the format : ping to keep the connection active.

Client Consumption:

For a better experience, we recommend using the EventSource API to consume the events:

{ const data = JSON.parse(event.data); // Process different types of events if (data.result) { // 1. Process status updates if (data.result.status) { const state = data.result.status.state; // "working", "completed", etc. // Check if there is a text message if (data.result.status.message?.parts) { const textParts = data.result.status.message.parts .filter(part => part.type === "text") .map(part => part.text) .join(""); // Update UI with the text updateUI(textParts); } // Check if it is the final event if (data.result.final === true) { eventSource.close(); // Close connection } } // 2. Process the generated artifacts if (data.result.artifact) { const artifact = data.result.artifact; // Extract text from the artifact if (artifact.parts) { const artifactText = artifact.parts .filter(part => part.type === "text") .map(part => part.text) .join(""); // Update UI with the artifact updateArtifactUI(artifactText); } } } }; // Handle errors eventSource.onerror = (error) => { console.error("Error in SSE:", error); eventSource.close(); };`} language="javascript" />

Possible task states:

  • submitted: Task sent but not yet processed
  • working: Task being processed by the agent
  • completed: Task completed successfully
  • input-required: Agent waiting for additional user input
  • failed: Task failed during processing
  • canceled: Task was canceled

Possible task states:

  • submitted: Task sent
  • working: Task being processed
  • input-required: Agent waiting for additional user input
  • completed: Task completed successfully
  • canceled: Task canceled
  • failed: Task processing failed
); }