Skip to main content

objectiveai_sdk/http/viewer/
request.rs

1//! Wire shapes for events the viewer client POSTs to a remote viewer's
2//! HTTP server. The api server constructs these and pushes them through
3//! [`super::Client`]; standalone SDK consumers can do the same.
4
5use std::sync::Arc;
6
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9
10#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
11#[schemars(rename = "http.viewer.ResponseError")]
12pub struct ResponseError {
13    pub id: String,
14    #[serde(flatten)]
15    pub inner: crate::error::ResponseError,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
19#[schemars(rename = "http.viewer.AgentCompletionCreateParams")]
20pub struct AgentCompletionCreateParams {
21    pub id: String,
22    #[serde(flatten)]
23    pub inner:
24        Arc<crate::agent::completions::request::AgentCompletionCreateParams>,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
28#[schemars(rename = "http.viewer.AgentCompletionRequest")]
29#[serde(untagged)]
30pub enum AgentCompletionRequest {
31    #[schemars(title = "Begin")]
32    Begin(AgentCompletionCreateParams),
33    #[schemars(title = "Continue")]
34    Continue(
35        crate::agent::completions::response::streaming::AgentCompletionChunk,
36    ),
37    #[schemars(title = "Error")]
38    Error(ResponseError),
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
42#[schemars(rename = "http.viewer.FunctionExecutionCreateParams")]
43pub struct FunctionExecutionCreateParams {
44    pub id: String,
45    #[serde(flatten)]
46    pub inner: Arc<
47        crate::functions::executions::request::FunctionExecutionCreateParams,
48    >,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
52#[schemars(rename = "http.viewer.FunctionExecutionRequest")]
53#[serde(untagged)]
54pub enum FunctionExecutionRequest {
55    #[schemars(title = "Begin")]
56    Begin(FunctionExecutionCreateParams),
57    #[schemars(title = "Continue")]
58    Continue(crate::functions::executions::response::streaming::FunctionExecutionChunk),
59    #[schemars(title = "Error")]
60    Error(ResponseError),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
64#[schemars(rename = "http.viewer.Request")]
65#[serde(untagged)]
66pub enum Request {
67    #[schemars(title = "AgentCompletion")]
68    AgentCompletion(AgentCompletionRequest),
69    #[schemars(title = "FunctionExecution")]
70    FunctionExecution(FunctionExecutionRequest),
71}