Skip to main content

rightkit_agent_engine_protocol/
op.rs

1use serde::{Deserialize, Serialize};
2
3/// An input command from a thin driver (CLI or UI) into the runtime.
4///
5/// Drivers NEVER call the engine directly — they only submit Ops through
6/// `SessionConduit`. Discriminated union; forward-compatible — later gates add
7/// more Op kinds without changing this contract.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(tag = "$kind")]
10pub enum Op {
11    /// Send a new user turn into a session.
12    #[serde(rename = "submitUserMessage", rename_all = "camelCase")]
13    SubmitUserMessage {
14        op_id: String,
15        session_id: String,
16        text: String,
17    },
18
19    /// Interrupt the active run for a session (cancel the in-flight model/tool loop).
20    #[serde(rename = "interruptRun", rename_all = "camelCase")]
21    InterruptRun { op_id: String, session_id: String },
22
23    /// Manually compact the session's context now — summarize older turns behind a boundary.
24    #[serde(rename = "requestCompaction", rename_all = "camelCase")]
25    RequestCompaction { op_id: String, session_id: String },
26
27    /// Inject a human steering instruction to be applied at the next turn boundary.
28    #[serde(rename = "injectSteeringMessage", rename_all = "camelCase")]
29    InjectSteeringMessage {
30        op_id: String,
31        session_id: String,
32        content: String,
33        injected_at: String,
34        injected_by: String,
35    },
36
37    /// Resolve a pending tool-call approval (the P0.5 runtime pause).
38    #[serde(rename = "resolveToolApproval", rename_all = "camelCase")]
39    ResolveToolApproval {
40        op_id: String,
41        session_id: String,
42        tool_call_id: String,
43        approved: bool,
44        reason: Option<String>,
45    },
46}