tirea_contract/io/input.rs
1use crate::io::ToolCallDecision;
2use crate::storage::RunOrigin;
3use crate::thread::Message;
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6
7/// Unified runtime request for all external protocols.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct RunRequest {
10 /// Target agent identifier.
11 pub agent_id: String,
12 /// Thread (conversation) ID. `None` -> auto-generate.
13 pub thread_id: Option<String>,
14 /// Run ID. `None` -> auto-generate.
15 pub run_id: Option<String>,
16 /// Parent run ID for nested/delegated execution.
17 pub parent_run_id: Option<String>,
18 /// Parent thread ID — set when a sub-agent is spawned by a parent agent.
19 pub parent_thread_id: Option<String>,
20 /// Resource this thread belongs to (for listing/querying).
21 pub resource_id: Option<String>,
22 /// Protocol origin for run index tracking.
23 #[serde(default)]
24 pub origin: RunOrigin,
25 /// Frontend state snapshot.
26 pub state: Option<Value>,
27 /// Messages to append before running.
28 pub messages: Vec<Message>,
29 /// Decisions to enqueue before loop start.
30 #[serde(default)]
31 pub initial_decisions: Vec<ToolCallDecision>,
32}
33
34/// Unified upstream message type for the runtime endpoint.
35#[derive(Debug, Clone)]
36pub enum RuntimeInput {
37 /// Start a new run with the given request.
38 Run(RunRequest),
39 /// A tool-call decision forwarded to the running loop.
40 Decision(ToolCallDecision),
41 /// Explicit application-level cancellation.
42 Cancel,
43}