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 /// Mailbox entry that triggered this run (set by mailbox dispatcher).
33 #[serde(default, skip_serializing_if = "Option::is_none")]
34 pub source_mailbox_entry_id: Option<String>,
35}
36
37/// Unified upstream message type for the runtime endpoint.
38#[derive(Debug, Clone)]
39pub enum RuntimeInput {
40 /// Start a new run with the given request.
41 Run(RunRequest),
42 /// A tool-call decision forwarded to the running loop.
43 Decision(ToolCallDecision),
44 /// Explicit application-level cancellation.
45 Cancel,
46}