graphrt_provider_api/invoke.rs
1//! Platform-native transport for gateway → agent requests.
2//!
3//! Most targets are reached over HTTP at an [`crate::EndpointAddress`]. Some
4//! are not (AWS Lambda: `InvokeWithResponseStream`, signed with SigV4, at an
5//! address like `lambda://<function>:<qualifier>`). Such providers implement
6//! [`crate::Provider::invoke`]; the gateway then sends the signed protocol
7//! request (`POST /internal/v1/runs`, ...) through it and reads the agent's
8//! response bytes (the SSE stream) from [`InvokeResponse::body`].
9
10use std::pin::Pin;
11
12use futures::Stream;
13
14use crate::error::ProviderError;
15
16/// A gateway → agent request, already signed (`Graphrt-Sig` among `headers`).
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct InvokeRequest {
19 /// `GET`, `POST`...
20 pub method: String,
21 /// Path with query, e.g. `/internal/v1/runs`.
22 pub path: String,
23 /// Headers (lowercase names).
24 pub headers: Vec<(String, String)>,
25 /// Body.
26 pub body: Vec<u8>,
27}
28
29/// Response body bytes as they arrive (never buffered whole: SSE).
30pub type ByteStream = Pin<Box<dyn Stream<Item = Result<Vec<u8>, ProviderError>> + Send>>;
31
32/// The agent's answer.
33pub struct InvokeResponse {
34 /// HTTP status the agent answered with.
35 pub status: u16,
36 /// Body bytes.
37 pub body: ByteStream,
38}
39
40impl std::fmt::Debug for InvokeResponse {
41 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 formatter.debug_struct("InvokeResponse").field("status", &self.status).finish_non_exhaustive()
43 }
44}