1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! Convenience builder functions for test wire messages.
//!
//! Each function produces a `serde_json::Value` shaped exactly as the
//! production Gemini CLI would send it over the JSON-RPC 2.0 channel.
//! Use these together with [`ScenarioBuilder::exchange`] to set up test
//! scenarios without hand-writing JSON.
//!
//! [`ScenarioBuilder::exchange`]: super::ScenarioBuilder::exchange
use ;
/// Create a `session/update` notification carrying an `agent_message_chunk`.
///
/// This is the primary message type for streaming assistant text responses.
///
/// # Example
///
/// ```rust
/// use gemini_cli_sdk::testing::assistant_text;
///
/// let msg = assistant_text("Hello!");
/// assert_eq!(msg["params"]["sessionUpdate"], "agent_message_chunk");
/// assert_eq!(msg["params"]["content"]["text"], "Hello!");
/// ```
/// Create a `session/update` notification carrying an `agent_thought_chunk`.
///
/// Thought chunks represent the model's internal reasoning, streamed before
/// the final answer is emitted.
///
/// # Example
///
/// ```rust
/// use gemini_cli_sdk::testing::thought_text;
///
/// let msg = thought_text("Let me think about this…");
/// assert_eq!(msg["params"]["sessionUpdate"], "agent_thought_chunk");
/// ```
/// Create a `session/update` notification representing a pending tool call.
///
/// - `id` — unique identifier for this tool invocation (used to correlate with
/// the corresponding [`tool_result`]).
/// - `title` — human-readable name shown in the UI.
/// - `kind` — machine-readable tool category (e.g. `"file_read"`,
/// `"shell_exec"`).
///
/// # Example
///
/// ```rust
/// use gemini_cli_sdk::testing::tool_call;
///
/// let msg = tool_call("tc-1", "Read file", "file_read");
/// assert_eq!(msg["params"]["status"], "pending");
/// assert_eq!(msg["params"]["toolCallId"], "tc-1");
/// ```
/// Create a `session/update` notification representing a completed tool result.
///
/// - `id` — must match the `id` used in the corresponding [`tool_call`].
/// - `text` — the text content of the tool's output.
///
/// # Example
///
/// ```rust
/// use gemini_cli_sdk::testing::tool_result;
///
/// let msg = tool_result("tc-1", "file contents here");
/// assert_eq!(msg["params"]["status"], "completed");
/// assert_eq!(msg["params"]["content"][0]["text"], "file contents here");
/// ```
/// Create a `session/update` notification carrying a structured plan.
///
/// `entries` is a slice of `(content, status)` pairs where `status` is
/// typically `"pending"`, `"in_progress"`, or `"done"`.
///
/// # Example
///
/// ```rust
/// use gemini_cli_sdk::testing::plan;
///
/// let msg = plan(vec![
/// ("Read the source file", "done"),
/// ("Analyse the code", "in_progress"),
/// ("Write the summary", "pending"),
/// ]);
/// assert_eq!(msg["params"]["sessionUpdate"], "plan");
/// assert_eq!(msg["params"]["entries"][0]["status"], "done");
/// ```
/// Create a JSON-RPC success response representing the terminal result of a
/// `session/prompt` request.
///
/// `stop_reason` is typically `"end_turn"` or `"max_tokens"`.
///
/// # Example
///
/// ```rust
/// use gemini_cli_sdk::testing::prompt_result;
///
/// let msg = prompt_result("end_turn");
/// assert_eq!(msg["result"]["stopReason"], "end_turn");
/// assert!(msg["error"].is_null());
/// ```