override suspend fun send()

in a2a/a2a-server/src/commonMain/kotlin/ai/koog/a2a/server/notifications/SimplePushNotificationSender.kt [36:62]


    override suspend fun send(config: PushNotificationConfig, task: Task) {
        try {
            logger.debug { "Sending push notification configId='${config.id} for taskId='${task.id}'" }

            httpClient.post(config.url) {
                config.authentication?.let { auth ->
                    // Simple sender always takes the first scheme from the list
                    val schema = auth.schemes.firstOrNull()
                    val credentials = auth.credentials

                    if (schema != null && credentials != null) {
                        headers[HttpHeaders.Authorization] = "$schema $credentials"
                    }
                }

                config.token?.let { token ->
                    headers[PushNotificationSender.A2A_NOTIFICATION_TOKEN_HEADER] = token
                }

                setBody(task)
            }

            logger.debug { "Sent push notification successfully configId='${config.id} for taskId='${task.id}'" }
        } catch (e: Exception) {
            logger.warn(e) { "Failed to send push notification configId='${config.id} for taskId='${task.id}'" }
        }
    }