swink_agent_memory/
interrupt.rs1use serde::{Deserialize, Serialize};
8use swink_agent::{LlmMessage, ModelSpec};
9
10#[non_exhaustive]
12#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
13pub struct PendingToolCall {
14 pub tool_call_id: String,
16 pub tool_name: String,
18 pub arguments: serde_json::Value,
20}
21
22impl PendingToolCall {
23 #[must_use]
25 pub fn new(
26 tool_call_id: impl Into<String>,
27 tool_name: impl Into<String>,
28 arguments: serde_json::Value,
29 ) -> Self {
30 Self {
31 tool_call_id: tool_call_id.into(),
32 tool_name: tool_name.into(),
33 arguments,
34 }
35 }
36}
37
38#[non_exhaustive]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct InterruptState {
46 pub interrupted_at: u64,
48 pub pending_tool_calls: Vec<PendingToolCall>,
50 pub context_snapshot: Vec<LlmMessage>,
52 pub system_prompt: String,
54 pub model: ModelSpec,
56}
57
58impl InterruptState {
59 #[must_use]
61 pub fn new(
62 interrupted_at: u64,
63 pending_tool_calls: Vec<PendingToolCall>,
64 context_snapshot: Vec<LlmMessage>,
65 system_prompt: impl Into<String>,
66 model: ModelSpec,
67 ) -> Self {
68 Self {
69 interrupted_at,
70 pending_tool_calls,
71 context_snapshot,
72 system_prompt: system_prompt.into(),
73 model,
74 }
75 }
76}
77
78const _: () = {
79 const fn assert_send_sync<T: Send + Sync>() {}
80 assert_send_sync::<InterruptState>();
81 assert_send_sync::<PendingToolCall>();
82};
83
84#[cfg(test)]
85#[path = "interrupt_tests.rs"]
86mod tests;