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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
//! Auto-generated typed JSON-RPC namespace — do not edit manually.
//!
//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
//! protocol method through a typed namespace tree, so wire method names
//! and request/response shapes live in exactly one place — this file.
#![allow(missing_docs)]
#![allow(clippy::too_many_arguments)]
#![allow(deprecated)]
#![allow(dead_code)]
use super::cli_api_types::{rpc_methods, *};
use crate::session::Session;
use crate::{Client, Error};
/// Typed view over the [`Client`]'s server-level RPC namespace.
#[derive(Clone, Copy)]
pub struct ClientRpc<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpc<'a> {
/// `cafeMetrics.*` sub-namespace.
pub fn cafe_metrics(&self) -> ClientRpcCafeMetrics<'a> {
ClientRpcCafeMetrics {
client: self.client,
}
}
/// `session.*` sub-namespace.
pub fn session(&self) -> ClientRpcSession<'a> {
ClientRpcSession {
client: self.client,
}
}
}
/// `cafeMetrics.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcCafeMetrics<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcCafeMetrics<'a> {
/// Starts anonymous CAFE metrics for this process. The runtime selects the endpoint from COPILOT_CAFE_METRICS_URL or this connection's original auth owner. Offline and unsupported platforms refuse startup. Release eligibility must resolve before samples are sent. Requires the private trusted CLI host capability.
///
/// Wire method: `cafeMetrics.start`.
///
/// # Parameters
///
/// * `params` - Versions and provider configuration for CAFE.
///
/// # Returns
///
/// CAFE startup result.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn start(
&self,
params: CafeMetricsStartRequest,
) -> Result<CafeMetricsStartResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::CAFEMETRICS_START, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Resolves release eligibility once from the immutable release lookup shared with auto-update. Requires the private trusted CLI host capability.
///
/// Wire method: `cafeMetrics.resolveAdmission`.
///
/// # Parameters
///
/// * `params` - Immutable release lookup result.
///
/// # Returns
///
/// Admission result.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn resolve_admission(
&self,
params: CafeMetricsResolveAdmissionRequest,
) -> Result<CafeMetricsResolveAdmissionResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::CAFEMETRICS_RESOLVEADMISSION, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Records one terminal resume result. Does nothing before startup. Requires the private trusted CLI host capability.
///
/// Wire method: `cafeMetrics.recordResumeResult`.
///
/// # Parameters
///
/// * `params` - Terminal result of one resume attempt.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn record_resume_result(
&self,
params: CafeMetricsRecordResumeResultRequest,
) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(
rpc_methods::CAFEMETRICS_RECORDRESUMERESULT,
Some(wire_params),
)
.await?;
Ok(())
}
/// Stops recording and drains within one 1.5-second deadline. flushOnly sends at most one batch without stopping recording. Requires the private trusted CLI host capability.
///
/// Wire method: `cafeMetrics.shutdown`.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn shutdown(&self) -> Result<(), Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::CAFEMETRICS_SHUTDOWN, Some(wire_params))
.await?;
Ok(())
}
/// Stops recording and drains within one 1.5-second deadline. flushOnly sends at most one batch without stopping recording. Requires the private trusted CLI host capability.
///
/// Wire method: `cafeMetrics.shutdown`.
///
/// # Parameters
///
/// * `params` - Preliminary flush or final disposal.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn shutdown_with_params(
&self,
params: CafeMetricsShutdownRequest,
) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::CAFEMETRICS_SHUTDOWN, Some(wire_params))
.await?;
Ok(())
}
}
/// `session.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcSession<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcSession<'a> {
/// `session.cafeMetrics.*` sub-namespace.
pub fn cafe_metrics(&self) -> ClientRpcSessionCafeMetrics<'a> {
ClientRpcSessionCafeMetrics {
client: self.client,
}
}
}
/// `session.cafeMetrics.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcSessionCafeMetrics<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcSessionCafeMetrics<'a> {
/// Records live model-call events, including subagents, and root compaction events. Replaces any earlier recorder. Requires the private trusted CLI host capability.
///
/// Wire method: `session.cafeMetrics.attach`.
///
/// # Parameters
///
/// * `params` - Identifies the target session.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn attach(&self, params: SessionCafeMetricsAttachParams) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSION_CAFEMETRICS_ATTACH, Some(wire_params))
.await?;
Ok(())
}
/// Stops recording this session. Does nothing if it has no recorder. Requires the private trusted CLI host capability.
///
/// Wire method: `session.cafeMetrics.detach`.
///
/// # Parameters
///
/// * `params` - Identifies the target session.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn detach(&self, params: SessionCafeMetricsDetachParams) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSION_CAFEMETRICS_DETACH, Some(wire_params))
.await?;
Ok(())
}
}
/// Typed view over a [`Session`]'s RPC namespace.
#[derive(Clone, Copy)]
pub(crate) struct SessionRpc<'a> {
pub(crate) session: &'a Session,
}
impl<'a> SessionRpc<'a> {}