use loop_agent_sdk::lambda_runtime::{service_fn, Error, LambdaEvent};
use serde::{Deserialize, Serialize};
use tracing::info;
#[derive(Debug, Deserialize)]
struct WebhookRequest {
#[serde(default)]
body: String,
#[serde(default)]
headers: std::collections::HashMap<String, String>,
}
#[derive(Debug, Serialize)]
struct WebhookResponse {
status_code: u16,
body: String,
}
#[tokio::main]
async fn main() -> Result<(), Error> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.without_time()
.init();
info!("Loop Agent Lambda starting...");
loop_agent_sdk::lambda_runtime::run(service_fn(handler)).await
}
async fn handler(event: LambdaEvent<WebhookRequest>) -> Result<WebhookResponse, Error> {
let (request, _context) = event.into_parts();
info!("Received webhook: {} bytes", request.body.len());
Ok(WebhookResponse {
status_code: 200,
body: r#"{"success": true, "message": "Webhook received"}"#.to_string(),
})
}