Skip to main content

hanzo_client/apis/
agents_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`delete_agents_by_ref`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteAgentsByRefError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`delete_agents_targets_by_id`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteAgentsTargetsByIdError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_agents`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetAgentsError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_agents_activity`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetAgentsActivityError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_agents_builds`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetAgentsBuildsError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_agents_builds_by_org_by_project`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetAgentsBuildsByOrgByProjectError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_agents_by_ref`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetAgentsByRefError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`get_agents_by_ref_runs`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetAgentsByRefRunsError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_agents_chat_conversations`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetAgentsChatConversationsError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`get_agents_chat_conversations_by_id`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum GetAgentsChatConversationsByIdError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`get_agents_chat_presets`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetAgentsChatPresetsError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`get_agents_metrics`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetAgentsMetricsError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`get_agents_runs`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum GetAgentsRunsError {
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`get_agents_sessions`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum GetAgentsSessionsError {
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`get_agents_sessions_by_id`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum GetAgentsSessionsByIdError {
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`get_agents_sessions_by_id_control`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum GetAgentsSessionsByIdControlError {
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`get_agents_sessions_by_id_progress`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum GetAgentsSessionsByIdProgressError {
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`get_agents_sessions_by_id_tree`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum GetAgentsSessionsByIdTreeError {
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`get_agents_sessions_stream`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum GetAgentsSessionsStreamError {
148    UnknownValue(serde_json::Value),
149}
150
151/// struct for typed errors of method [`get_agents_targets`]
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum GetAgentsTargetsError {
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`get_agents_targets_by_id`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum GetAgentsTargetsByIdError {
162    UnknownValue(serde_json::Value),
163}
164
165/// struct for typed errors of method [`patch_agents_by_ref`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum PatchAgentsByRefError {
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`patch_agents_sessions_by_id`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum PatchAgentsSessionsByIdError {
176    UnknownValue(serde_json::Value),
177}
178
179/// struct for typed errors of method [`patch_agents_targets_by_id`]
180#[derive(Debug, Clone, Serialize, Deserialize)]
181#[serde(untagged)]
182pub enum PatchAgentsTargetsByIdError {
183    UnknownValue(serde_json::Value),
184}
185
186/// struct for typed errors of method [`post_agents`]
187#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum PostAgentsError {
190    UnknownValue(serde_json::Value),
191}
192
193/// struct for typed errors of method [`post_agents_by_ref_run`]
194#[derive(Debug, Clone, Serialize, Deserialize)]
195#[serde(untagged)]
196pub enum PostAgentsByRefRunError {
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`post_agents_chat`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum PostAgentsChatError {
204    UnknownValue(serde_json::Value),
205}
206
207/// struct for typed errors of method [`post_agents_coding`]
208#[derive(Debug, Clone, Serialize, Deserialize)]
209#[serde(untagged)]
210pub enum PostAgentsCodingError {
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`post_agents_sessions`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum PostAgentsSessionsError {
218    UnknownValue(serde_json::Value),
219}
220
221/// struct for typed errors of method [`post_agents_sessions_by_id_events`]
222#[derive(Debug, Clone, Serialize, Deserialize)]
223#[serde(untagged)]
224pub enum PostAgentsSessionsByIdEventsError {
225    UnknownValue(serde_json::Value),
226}
227
228/// struct for typed errors of method [`post_agents_sessions_by_id_message`]
229#[derive(Debug, Clone, Serialize, Deserialize)]
230#[serde(untagged)]
231pub enum PostAgentsSessionsByIdMessageError {
232    UnknownValue(serde_json::Value),
233}
234
235/// struct for typed errors of method [`post_agents_sessions_by_id_pause`]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237#[serde(untagged)]
238pub enum PostAgentsSessionsByIdPauseError {
239    UnknownValue(serde_json::Value),
240}
241
242/// struct for typed errors of method [`post_agents_sessions_by_id_resume`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum PostAgentsSessionsByIdResumeError {
246    UnknownValue(serde_json::Value),
247}
248
249/// struct for typed errors of method [`post_agents_sessions_by_id_stop`]
250#[derive(Debug, Clone, Serialize, Deserialize)]
251#[serde(untagged)]
252pub enum PostAgentsSessionsByIdStopError {
253    UnknownValue(serde_json::Value),
254}
255
256/// struct for typed errors of method [`post_agents_targets`]
257#[derive(Debug, Clone, Serialize, Deserialize)]
258#[serde(untagged)]
259pub enum PostAgentsTargetsError {
260    UnknownValue(serde_json::Value),
261}
262
263/// struct for typed errors of method [`post_agents_targets_by_id_claim`]
264#[derive(Debug, Clone, Serialize, Deserialize)]
265#[serde(untagged)]
266pub enum PostAgentsTargetsByIdClaimError {
267    UnknownValue(serde_json::Value),
268}
269
270/// struct for typed errors of method [`post_agents_targets_by_id_key`]
271#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(untagged)]
273pub enum PostAgentsTargetsByIdKeyError {
274    UnknownValue(serde_json::Value),
275}
276
277/// struct for typed errors of method [`post_agents_targets_by_id_runs_by_runid_report`]
278#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum PostAgentsTargetsByIdRunsByRunidReportError {
281    UnknownValue(serde_json::Value),
282}
283
284
285/// Removes an agent and every run recorded against it. Answers 204.
286pub async fn delete_agents_by_ref(configuration: &configuration::Configuration, r#ref: &str) -> Result<(), Error<DeleteAgentsByRefError>> {
287    // add a prefix to parameters to efficiently prevent name collisions
288    let p_ref = r#ref;
289
290    let uri_str = format!("{}/v1/agents/{ref}", configuration.base_path, ref=crate::apis::urlencode(p_ref));
291    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
292
293    if let Some(ref user_agent) = configuration.user_agent {
294        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
295    }
296    if let Some(ref token) = configuration.bearer_access_token {
297        req_builder = req_builder.bearer_auth(token.to_owned());
298    };
299
300    let req = req_builder.build()?;
301    let resp = configuration.client.execute(req).await?;
302
303    let status = resp.status();
304
305    if !status.is_client_error() && !status.is_server_error() {
306        Ok(())
307    } else {
308        let content = resp.text().await?;
309        let entity: Option<DeleteAgentsByRefError> = serde_json::from_str(&content).ok();
310        Err(Error::ResponseError(ResponseContent { status, content, entity }))
311    }
312}
313
314/// Deregisters one machine. Only its owner, or an org admin, may remove it; an unknown id, a cross-org id and a machine owned by someone else all answer the same not-found, so a probe learns nothing about what exists.
315pub async fn delete_agents_targets_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::TargetDeleted, Error<DeleteAgentsTargetsByIdError>> {
316    // add a prefix to parameters to efficiently prevent name collisions
317    let p_id = id;
318
319    let uri_str = format!("{}/v1/agents/targets/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
320    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
321
322    if let Some(ref user_agent) = configuration.user_agent {
323        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324    }
325    if let Some(ref token) = configuration.bearer_access_token {
326        req_builder = req_builder.bearer_auth(token.to_owned());
327    };
328
329    let req = req_builder.build()?;
330    let resp = configuration.client.execute(req).await?;
331
332    let status = resp.status();
333    let content_type = resp
334        .headers()
335        .get("content-type")
336        .and_then(|v| v.to_str().ok())
337        .unwrap_or("application/octet-stream");
338    let content_type = super::ContentType::from(content_type);
339
340    if !status.is_client_error() && !status.is_server_error() {
341        let content = resp.text().await?;
342        match content_type {
343            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
344            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TargetDeleted`"))),
345            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TargetDeleted`")))),
346        }
347    } else {
348        let content = resp.text().await?;
349        let entity: Option<DeleteAgentsTargetsByIdError> = serde_json::from_str(&content).ok();
350        Err(Error::ResponseError(ResponseContent { status, content, entity }))
351    }
352}
353
354/// Returns every agent defined in the caller's org, each with the number of runs recorded against it.
355pub async fn get_agents(configuration: &configuration::Configuration, ) -> Result<models::AgentList, Error<GetAgentsError>> {
356
357    let uri_str = format!("{}/v1/agents", configuration.base_path);
358    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
359
360    if let Some(ref user_agent) = configuration.user_agent {
361        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
362    }
363    if let Some(ref token) = configuration.bearer_access_token {
364        req_builder = req_builder.bearer_auth(token.to_owned());
365    };
366
367    let req = req_builder.build()?;
368    let resp = configuration.client.execute(req).await?;
369
370    let status = resp.status();
371    let content_type = resp
372        .headers()
373        .get("content-type")
374        .and_then(|v| v.to_str().ok())
375        .unwrap_or("application/octet-stream");
376    let content_type = super::ContentType::from(content_type);
377
378    if !status.is_client_error() && !status.is_server_error() {
379        let content = resp.text().await?;
380        match content_type {
381            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
382            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentList`"))),
383            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AgentList`")))),
384        }
385    } else {
386        let content = resp.text().await?;
387        let entity: Option<GetAgentsError> = serde_json::from_str(&content).ok();
388        Err(Error::ResponseError(ResponseContent { status, content, entity }))
389    }
390}
391
392/// Serves the org-wide recent-activity feed. Events are REAL: each recorded run is an invoked (ok) or failed (error) event; each agent's own create/update timestamps are created/updated events. Merged, newest first, capped. Nothing is invented — an org with no agents and no runs gets [].
393pub async fn get_agents_activity(configuration: &configuration::Configuration, ) -> Result<models::ActivityFeed, Error<GetAgentsActivityError>> {
394
395    let uri_str = format!("{}/v1/agents/activity", configuration.base_path);
396    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
397
398    if let Some(ref user_agent) = configuration.user_agent {
399        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
400    }
401    if let Some(ref token) = configuration.bearer_access_token {
402        req_builder = req_builder.bearer_auth(token.to_owned());
403    };
404
405    let req = req_builder.build()?;
406    let resp = configuration.client.execute(req).await?;
407
408    let status = resp.status();
409    let content_type = resp
410        .headers()
411        .get("content-type")
412        .and_then(|v| v.to_str().ok())
413        .unwrap_or("application/octet-stream");
414    let content_type = super::ContentType::from(content_type);
415
416    if !status.is_client_error() && !status.is_server_error() {
417        let content = resp.text().await?;
418        match content_type {
419            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
420            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ActivityFeed`"))),
421            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ActivityFeed`")))),
422        }
423    } else {
424        let content = resp.text().await?;
425        let entity: Option<GetAgentsActivityError> = serde_json::from_str(&content).ok();
426        Err(Error::ResponseError(ResponseContent { status, content, entity }))
427    }
428}
429
430/// Returns the public index of every published build, most recently updated first, so a gallery can link straight to the story behind each product. PUBLIC, no tenancy: publishing is the author's act, and only published root sessions appear here.
431pub async fn get_agents_builds(configuration: &configuration::Configuration, limit: Option<i32>) -> Result<models::BuildList, Error<GetAgentsBuildsError>> {
432    // add a prefix to parameters to efficiently prevent name collisions
433    let p_limit = limit;
434
435    let uri_str = format!("{}/v1/agents/builds", configuration.base_path);
436    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
437
438    if let Some(ref param_value) = p_limit {
439        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
440    }
441    if let Some(ref user_agent) = configuration.user_agent {
442        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
443    }
444    if let Some(ref token) = configuration.bearer_access_token {
445        req_builder = req_builder.bearer_auth(token.to_owned());
446    };
447
448    let req = req_builder.build()?;
449    let resp = configuration.client.execute(req).await?;
450
451    let status = resp.status();
452    let content_type = resp
453        .headers()
454        .get("content-type")
455        .and_then(|v| v.to_str().ok())
456        .unwrap_or("application/octet-stream");
457    let content_type = super::ContentType::from(content_type);
458
459    if !status.is_client_error() && !status.is_server_error() {
460        let content = resp.text().await?;
461        match content_type {
462            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
463            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BuildList`"))),
464            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BuildList`")))),
465        }
466    } else {
467        let content = resp.text().await?;
468        let entity: Option<GetAgentsBuildsError> = serde_json::from_str(&content).ok();
469        Err(Error::ResponseError(ResponseContent { status, content, entity }))
470    }
471}
472
473/// Returns the readable build of one product: the agent session that produced it, turn by turn — the prompts, the reasoning, the commits each turn produced — plus the exact `git log` that re-derives every commit binding from git itself, so nothing here has to be taken on trust.  PUBLIC, no tenancy: it answers only for a session its author explicitly published, which is what makes it safe to be anonymous. An unpublished session is invisible here no matter who asks; its owner reads it through the org-scoped /v1/agents/sessions routes, which need a validated principal.
474pub async fn get_agents_builds_by_org_by_project(configuration: &configuration::Configuration, org: &str, project: &str) -> Result<models::BuildView, Error<GetAgentsBuildsByOrgByProjectError>> {
475    // add a prefix to parameters to efficiently prevent name collisions
476    let p_org = org;
477    let p_project = project;
478
479    let uri_str = format!("{}/v1/agents/builds/{org}/{project}", configuration.base_path, org=crate::apis::urlencode(p_org), project=crate::apis::urlencode(p_project));
480    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
481
482    if let Some(ref user_agent) = configuration.user_agent {
483        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
484    }
485    if let Some(ref token) = configuration.bearer_access_token {
486        req_builder = req_builder.bearer_auth(token.to_owned());
487    };
488
489    let req = req_builder.build()?;
490    let resp = configuration.client.execute(req).await?;
491
492    let status = resp.status();
493    let content_type = resp
494        .headers()
495        .get("content-type")
496        .and_then(|v| v.to_str().ok())
497        .unwrap_or("application/octet-stream");
498    let content_type = super::ContentType::from(content_type);
499
500    if !status.is_client_error() && !status.is_server_error() {
501        let content = resp.text().await?;
502        match content_type {
503            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
504            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BuildView`"))),
505            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BuildView`")))),
506        }
507    } else {
508        let content = resp.text().await?;
509        let entity: Option<GetAgentsBuildsByOrgByProjectError> = serde_json::from_str(&content).ok();
510        Err(Error::ResponseError(ResponseContent { status, content, entity }))
511    }
512}
513
514/// Returns one agent with its system prompt and its 20 most recent runs. The ref is the agent's public id or its org-unique name — a created agent is immediately gettable by whatever create handed back.
515pub async fn get_agents_by_ref(configuration: &configuration::Configuration, r#ref: &str) -> Result<models::AgentDetail, Error<GetAgentsByRefError>> {
516    // add a prefix to parameters to efficiently prevent name collisions
517    let p_ref = r#ref;
518
519    let uri_str = format!("{}/v1/agents/{ref}", configuration.base_path, ref=crate::apis::urlencode(p_ref));
520    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
521
522    if let Some(ref user_agent) = configuration.user_agent {
523        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
524    }
525    if let Some(ref token) = configuration.bearer_access_token {
526        req_builder = req_builder.bearer_auth(token.to_owned());
527    };
528
529    let req = req_builder.build()?;
530    let resp = configuration.client.execute(req).await?;
531
532    let status = resp.status();
533    let content_type = resp
534        .headers()
535        .get("content-type")
536        .and_then(|v| v.to_str().ok())
537        .unwrap_or("application/octet-stream");
538    let content_type = super::ContentType::from(content_type);
539
540    if !status.is_client_error() && !status.is_server_error() {
541        let content = resp.text().await?;
542        match content_type {
543            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
544            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentDetail`"))),
545            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AgentDetail`")))),
546        }
547    } else {
548        let content = resp.text().await?;
549        let entity: Option<GetAgentsByRefError> = serde_json::from_str(&content).ok();
550        Err(Error::ResponseError(ResponseContent { status, content, entity }))
551    }
552}
553
554/// Returns one agent's execution history, newest first — each run's input, its output or its error, and how long it took. Every row is a run that actually happened.
555pub async fn get_agents_by_ref_runs(configuration: &configuration::Configuration, r#ref: &str, limit: Option<i32>) -> Result<models::RunList, Error<GetAgentsByRefRunsError>> {
556    // add a prefix to parameters to efficiently prevent name collisions
557    let p_ref = r#ref;
558    let p_limit = limit;
559
560    let uri_str = format!("{}/v1/agents/{ref}/runs", configuration.base_path, ref=crate::apis::urlencode(p_ref));
561    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
562
563    if let Some(ref param_value) = p_limit {
564        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
565    }
566    if let Some(ref user_agent) = configuration.user_agent {
567        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
568    }
569    if let Some(ref token) = configuration.bearer_access_token {
570        req_builder = req_builder.bearer_auth(token.to_owned());
571    };
572
573    let req = req_builder.build()?;
574    let resp = configuration.client.execute(req).await?;
575
576    let status = resp.status();
577    let content_type = resp
578        .headers()
579        .get("content-type")
580        .and_then(|v| v.to_str().ok())
581        .unwrap_or("application/octet-stream");
582    let content_type = super::ContentType::from(content_type);
583
584    if !status.is_client_error() && !status.is_server_error() {
585        let content = resp.text().await?;
586        match content_type {
587            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
588            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RunList`"))),
589            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RunList`")))),
590        }
591    } else {
592        let content = resp.text().await?;
593        let entity: Option<GetAgentsByRefRunsError> = serde_json::from_str(&content).ok();
594        Err(Error::ResponseError(ResponseContent { status, content, entity }))
595    }
596}
597
598/// Returns a summary of every agent conversation in the caller's org — id, derived title, and when it was last appended to — for populating a thread list.  Scoped to the caller's org and nothing else, and that isolation is structural rather than a filter: conversations are persisted in a store opened PER ORG, so there is no query in which another tenant's threads could appear. A validated principal with a non-empty org is required; 403 without one.
599pub async fn get_agents_chat_conversations(configuration: &configuration::Configuration, ) -> Result<(), Error<GetAgentsChatConversationsError>> {
600
601    let uri_str = format!("{}/v1/agents/chat/conversations", configuration.base_path);
602    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
603
604    if let Some(ref user_agent) = configuration.user_agent {
605        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
606    }
607    if let Some(ref token) = configuration.bearer_access_token {
608        req_builder = req_builder.bearer_auth(token.to_owned());
609    };
610
611    let req = req_builder.build()?;
612    let resp = configuration.client.execute(req).await?;
613
614    let status = resp.status();
615
616    if !status.is_client_error() && !status.is_server_error() {
617        Ok(())
618    } else {
619        let content = resp.text().await?;
620        let entity: Option<GetAgentsChatConversationsError> = serde_json::from_str(&content).ok();
621        Err(Error::ResponseError(ResponseContent { status, content, entity }))
622    }
623}
624
625/// Returns every message of one conversation in order — role, content, the assistant's tool calls where it made any, and each message's creation time — which is the transcript a client replays to resume a thread.  The lookup happens inside the caller's OWN per-org store, so an id belonging to another tenant is not refused, it is simply absent: the answer is 200 with an empty message list. Read it as \"no such conversation for you\" rather than as an empty thread. A validated principal with a non-empty org is required; 403 without one.
626pub async fn get_agents_chat_conversations_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<GetAgentsChatConversationsByIdError>> {
627    // add a prefix to parameters to efficiently prevent name collisions
628    let p_id = id;
629
630    let uri_str = format!("{}/v1/agents/chat/conversations/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
631    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
632
633    if let Some(ref user_agent) = configuration.user_agent {
634        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
635    }
636    if let Some(ref token) = configuration.bearer_access_token {
637        req_builder = req_builder.bearer_auth(token.to_owned());
638    };
639
640    let req = req_builder.build()?;
641    let resp = configuration.client.execute(req).await?;
642
643    let status = resp.status();
644
645    if !status.is_client_error() && !status.is_server_error() {
646        Ok(())
647    } else {
648        let content = resp.text().await?;
649        let entity: Option<GetAgentsChatConversationsByIdError> = serde_json::from_str(&content).ok();
650        Err(Error::ResponseError(ResponseContent { status, content, entity }))
651    }
652}
653
654/// Returns the preset catalog: each entry's id, its description and whether it is server-executing — the flag that decides if a preset's tool calls run here or come back for the client to apply. The ids are what the round accepts in `preset`.  The catalog is compiled into the build, identical for every caller, and this is the one read in the group that needs no principal.
655pub async fn get_agents_chat_presets(configuration: &configuration::Configuration, ) -> Result<(), Error<GetAgentsChatPresetsError>> {
656
657    let uri_str = format!("{}/v1/agents/chat/presets", configuration.base_path);
658    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
659
660    if let Some(ref user_agent) = configuration.user_agent {
661        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
662    }
663    if let Some(ref token) = configuration.bearer_access_token {
664        req_builder = req_builder.bearer_auth(token.to_owned());
665    };
666
667    let req = req_builder.build()?;
668    let resp = configuration.client.execute(req).await?;
669
670    let status = resp.status();
671
672    if !status.is_client_error() && !status.is_server_error() {
673        Ok(())
674    } else {
675        let content = resp.text().await?;
676        let entity: Option<GetAgentsChatPresetsError> = serde_json::from_str(&content).ok();
677        Err(Error::ResponseError(ResponseContent { status, content, entity }))
678    }
679}
680
681/// Serves the invocations-over-time histogram for the org's Agents dashboard. Every point is a REAL count of recorded runs in that time bucket — one series line per agent that ran in the window. The Resource Usage rollup is all-null because this store meters no CPU/memory/storage/cost; the console renders those as \"—\" rather than a fabricated figure. No runs => empty series (an honest \"not connected / no activity yet\"), never a synthesized trend.
682pub async fn get_agents_metrics(configuration: &configuration::Configuration, range: Option<&str>) -> Result<models::MetricsView, Error<GetAgentsMetricsError>> {
683    // add a prefix to parameters to efficiently prevent name collisions
684    let p_range = range;
685
686    let uri_str = format!("{}/v1/agents/metrics", configuration.base_path);
687    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
688
689    if let Some(ref param_value) = p_range {
690        req_builder = req_builder.query(&[("range", &param_value.to_string())]);
691    }
692    if let Some(ref user_agent) = configuration.user_agent {
693        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
694    }
695    if let Some(ref token) = configuration.bearer_access_token {
696        req_builder = req_builder.bearer_auth(token.to_owned());
697    };
698
699    let req = req_builder.build()?;
700    let resp = configuration.client.execute(req).await?;
701
702    let status = resp.status();
703    let content_type = resp
704        .headers()
705        .get("content-type")
706        .and_then(|v| v.to_str().ok())
707        .unwrap_or("application/octet-stream");
708    let content_type = super::ContentType::from(content_type);
709
710    if !status.is_client_error() && !status.is_server_error() {
711        let content = resp.text().await?;
712        match content_type {
713            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
714            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MetricsView`"))),
715            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::MetricsView`")))),
716        }
717    } else {
718        let content = resp.text().await?;
719        let entity: Option<GetAgentsMetricsError> = serde_json::from_str(&content).ok();
720        Err(Error::ResponseError(ResponseContent { status, content, entity }))
721    }
722}
723
724/// Returns the org's agent runs across EVERY agent, newest first — what ran here, for whom, on which model, how long it took, and why it failed.  It is the feed the per-agent history could not be: an operator asking \"what is this tenant's agent plane doing\" does not start out knowing an agent ref, and answering by listing the agents and then paging each one's history is N+1 round trips to reconstruct one ordering the database already has (RunsSince, ordered by created_at over the org index).  The org is the CALLER's, resolved from identity by tenantStore — never a parameter. There is deliberately no org field on orgRunsQuery to forge: run history is the tenant's own record, and the only tenant this can answer for is the one asking.
725pub async fn get_agents_runs(configuration: &configuration::Configuration, limit: Option<i32>, status: Option<&str>) -> Result<models::RunList, Error<GetAgentsRunsError>> {
726    // add a prefix to parameters to efficiently prevent name collisions
727    let p_limit = limit;
728    let p_status = status;
729
730    let uri_str = format!("{}/v1/agents/runs", configuration.base_path);
731    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
732
733    if let Some(ref param_value) = p_limit {
734        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
735    }
736    if let Some(ref param_value) = p_status {
737        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
738    }
739    if let Some(ref user_agent) = configuration.user_agent {
740        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
741    }
742    if let Some(ref token) = configuration.bearer_access_token {
743        req_builder = req_builder.bearer_auth(token.to_owned());
744    };
745
746    let req = req_builder.build()?;
747    let resp = configuration.client.execute(req).await?;
748
749    let status = resp.status();
750    let content_type = resp
751        .headers()
752        .get("content-type")
753        .and_then(|v| v.to_str().ok())
754        .unwrap_or("application/octet-stream");
755    let content_type = super::ContentType::from(content_type);
756
757    if !status.is_client_error() && !status.is_server_error() {
758        let content = resp.text().await?;
759        match content_type {
760            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
761            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RunList`"))),
762            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RunList`")))),
763        }
764    } else {
765        let content = resp.text().await?;
766        let entity: Option<GetAgentsRunsError> = serde_json::from_str(&content).ok();
767        Err(Error::ResponseError(ResponseContent { status, content, entity }))
768    }
769}
770
771/// Returns the caller org's live sessions, newest first — each with its event count, its direct-child count and a one-line preview of its latest event. With no filter it returns ROOT sessions only, so a dashboard shows one row per flow rather than one per subagent; ?root= or ?parent= descends.
772pub async fn get_agents_sessions(configuration: &configuration::Configuration, root: Option<&str>, parent: Option<&str>, status: Option<&str>, project: Option<&str>, room: Option<&str>, limit: Option<i32>) -> Result<models::SessionList, Error<GetAgentsSessionsError>> {
773    // add a prefix to parameters to efficiently prevent name collisions
774    let p_root = root;
775    let p_parent = parent;
776    let p_status = status;
777    let p_project = project;
778    let p_room = room;
779    let p_limit = limit;
780
781    let uri_str = format!("{}/v1/agents/sessions", configuration.base_path);
782    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
783
784    if let Some(ref param_value) = p_root {
785        req_builder = req_builder.query(&[("root", &param_value.to_string())]);
786    }
787    if let Some(ref param_value) = p_parent {
788        req_builder = req_builder.query(&[("parent", &param_value.to_string())]);
789    }
790    if let Some(ref param_value) = p_status {
791        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
792    }
793    if let Some(ref param_value) = p_project {
794        req_builder = req_builder.query(&[("project", &param_value.to_string())]);
795    }
796    if let Some(ref param_value) = p_room {
797        req_builder = req_builder.query(&[("room", &param_value.to_string())]);
798    }
799    if let Some(ref param_value) = p_limit {
800        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
801    }
802    if let Some(ref user_agent) = configuration.user_agent {
803        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
804    }
805    if let Some(ref token) = configuration.bearer_access_token {
806        req_builder = req_builder.bearer_auth(token.to_owned());
807    };
808
809    let req = req_builder.build()?;
810    let resp = configuration.client.execute(req).await?;
811
812    let status = resp.status();
813    let content_type = resp
814        .headers()
815        .get("content-type")
816        .and_then(|v| v.to_str().ok())
817        .unwrap_or("application/octet-stream");
818    let content_type = super::ContentType::from(content_type);
819
820    if !status.is_client_error() && !status.is_server_error() {
821        let content = resp.text().await?;
822        match content_type {
823            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
824            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SessionList`"))),
825            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SessionList`")))),
826        }
827    } else {
828        let content = resp.text().await?;
829        let entity: Option<GetAgentsSessionsError> = serde_json::from_str(&content).ok();
830        Err(Error::ResponseError(ResponseContent { status, content, entity }))
831    }
832}
833
834/// Returns one session with its direct child sessions and its 50 most recent events, oldest of those first.
835pub async fn get_agents_sessions_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::SessionDetail, Error<GetAgentsSessionsByIdError>> {
836    // add a prefix to parameters to efficiently prevent name collisions
837    let p_id = id;
838
839    let uri_str = format!("{}/v1/agents/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
840    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
841
842    if let Some(ref user_agent) = configuration.user_agent {
843        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
844    }
845    if let Some(ref token) = configuration.bearer_access_token {
846        req_builder = req_builder.bearer_auth(token.to_owned());
847    };
848
849    let req = req_builder.build()?;
850    let resp = configuration.client.execute(req).await?;
851
852    let status = resp.status();
853    let content_type = resp
854        .headers()
855        .get("content-type")
856        .and_then(|v| v.to_str().ok())
857        .unwrap_or("application/octet-stream");
858    let content_type = super::ContentType::from(content_type);
859
860    if !status.is_client_error() && !status.is_server_error() {
861        let content = resp.text().await?;
862        match content_type {
863            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
864            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SessionDetail`"))),
865            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SessionDetail`")))),
866        }
867    } else {
868        let content = resp.text().await?;
869        let entity: Option<GetAgentsSessionsByIdError> = serde_json::from_str(&content).ok();
870        Err(Error::ResponseError(ResponseContent { status, content, entity }))
871    }
872}
873
874/// Returns the steering commands (pause/resume/stop/message) recorded against the caller's own session that are newer than the cursor, oldest first, with the cursor to poll from next. It is how a locally started `hanzo code` session — which is not task-backed, so nothing forwards its commands to an execution engine — consumes what the dashboard posted. Read-only and bounded at 200 per poll, so a steady poll is cheap and an applied command is never redelivered.
875pub async fn get_agents_sessions_by_id_control(configuration: &configuration::Configuration, id: &str, after: Option<i32>) -> Result<models::ControlDrain, Error<GetAgentsSessionsByIdControlError>> {
876    // add a prefix to parameters to efficiently prevent name collisions
877    let p_id = id;
878    let p_after = after;
879
880    let uri_str = format!("{}/v1/agents/sessions/{id}/control", configuration.base_path, id=crate::apis::urlencode(p_id));
881    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
882
883    if let Some(ref param_value) = p_after {
884        req_builder = req_builder.query(&[("after", &param_value.to_string())]);
885    }
886    if let Some(ref user_agent) = configuration.user_agent {
887        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
888    }
889    if let Some(ref token) = configuration.bearer_access_token {
890        req_builder = req_builder.bearer_auth(token.to_owned());
891    };
892
893    let req = req_builder.build()?;
894    let resp = configuration.client.execute(req).await?;
895
896    let status = resp.status();
897    let content_type = resp
898        .headers()
899        .get("content-type")
900        .and_then(|v| v.to_str().ok())
901        .unwrap_or("application/octet-stream");
902    let content_type = super::ContentType::from(content_type);
903
904    if !status.is_client_error() && !status.is_server_error() {
905        let content = resp.text().await?;
906        match content_type {
907            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
908            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ControlDrain`"))),
909            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ControlDrain`")))),
910        }
911    } else {
912        let content = resp.text().await?;
913        let entity: Option<GetAgentsSessionsByIdControlError> = serde_json::from_str(&content).ok();
914        Err(Error::ResponseError(ResponseContent { status, content, entity }))
915    }
916}
917
918/// Returns how far along one run is: the share of its goal that is done, whether it is running, blocked or finished, and a line saying what it is doing right now.  It is a MODEL ESTIMATE read off the run's own transcript, not a measurement — `estimated` says so on every answer, and a run whose progress cannot be told reports phase \"unknown\" with no percentage rather than a zero it does not mean. A session that has already finished answers from its own status instead, and is marked not estimated.  The list and detail reads carry the same value; this address is the one that WAITS. Where the stored estimate has gone stale it is remade before answering, so a human deciding whether to step into a run gets a current reading rather than the last poll's — which costs one small completion, charged to the same wallet the session already names, at most once every thirty seconds per run.
919pub async fn get_agents_sessions_by_id_progress(configuration: &configuration::Configuration, id: &str) -> Result<models::SessionProgress, Error<GetAgentsSessionsByIdProgressError>> {
920    // add a prefix to parameters to efficiently prevent name collisions
921    let p_id = id;
922
923    let uri_str = format!("{}/v1/agents/sessions/{id}/progress", configuration.base_path, id=crate::apis::urlencode(p_id));
924    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
925
926    if let Some(ref user_agent) = configuration.user_agent {
927        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
928    }
929    if let Some(ref token) = configuration.bearer_access_token {
930        req_builder = req_builder.bearer_auth(token.to_owned());
931    };
932
933    let req = req_builder.build()?;
934    let resp = configuration.client.execute(req).await?;
935
936    let status = resp.status();
937    let content_type = resp
938        .headers()
939        .get("content-type")
940        .and_then(|v| v.to_str().ok())
941        .unwrap_or("application/octet-stream");
942    let content_type = super::ContentType::from(content_type);
943
944    if !status.is_client_error() && !status.is_server_error() {
945        let content = resp.text().await?;
946        match content_type {
947            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
948            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SessionProgress`"))),
949            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SessionProgress`")))),
950        }
951    } else {
952        let content = resp.text().await?;
953        let entity: Option<GetAgentsSessionsByIdProgressError> = serde_json::from_str(&content).ok();
954        Err(Error::ResponseError(ResponseContent { status, content, entity }))
955    }
956}
957
958/// Returns the subagent-flow graph rooted at this session: the session, its children, their children, each node carrying its own event count. One indexed read pulls the whole flow (every node of a flow shares a root id), so the shape is assembled in memory rather than by walking the store per node.
959pub async fn get_agents_sessions_by_id_tree(configuration: &configuration::Configuration, id: &str) -> Result<models::TreeNode, Error<GetAgentsSessionsByIdTreeError>> {
960    // add a prefix to parameters to efficiently prevent name collisions
961    let p_id = id;
962
963    let uri_str = format!("{}/v1/agents/sessions/{id}/tree", configuration.base_path, id=crate::apis::urlencode(p_id));
964    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
965
966    if let Some(ref user_agent) = configuration.user_agent {
967        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
968    }
969    if let Some(ref token) = configuration.bearer_access_token {
970        req_builder = req_builder.bearer_auth(token.to_owned());
971    };
972
973    let req = req_builder.build()?;
974    let resp = configuration.client.execute(req).await?;
975
976    let status = resp.status();
977    let content_type = resp
978        .headers()
979        .get("content-type")
980        .and_then(|v| v.to_str().ok())
981        .unwrap_or("application/octet-stream");
982    let content_type = super::ContentType::from(content_type);
983
984    if !status.is_client_error() && !status.is_server_error() {
985        let content = resp.text().await?;
986        match content_type {
987            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
988            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TreeNode`"))),
989            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TreeNode`")))),
990        }
991    } else {
992        let content = resp.text().await?;
993        let entity: Option<GetAgentsSessionsByIdTreeError> = serde_json::from_str(&content).ok();
994        Err(Error::ResponseError(ResponseContent { status, content, entity }))
995    }
996}
997
998/// Holds the connection open as text/event-stream and pushes a frame each time the org's registry moves: an `event: session` frame carrying the same session shape the list and detail reads answer with (a registration, an update, or a login-manager revoke tearing a session down), and an `event: event` frame carrying one appended turn. Optional ?root=<session id> narrows the feed to a single subagent tree.  Requires a validated principal carrying an org; 403 without one. Org-scoped fail-closed: the bus filters on tenant before it fans out, so a subscriber only ever receives its own org's updates, and ?root= narrows that further but can never widen it.  Delivery is best-effort and the GET reads remain the source of truth. A subscriber that falls more than 256 frames behind is DROPPED — its channel is closed and the stream ends — so one stuck dashboard can never back-pressure a session write; the client reconnects and re-reads the session endpoints to resynchronise. A `: ping` comment every 25 seconds holds the connection open through proxies and is how a departed client is noticed.
999pub async fn get_agents_sessions_stream(configuration: &configuration::Configuration, ) -> Result<(), Error<GetAgentsSessionsStreamError>> {
1000
1001    let uri_str = format!("{}/v1/agents/sessions/stream", configuration.base_path);
1002    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1003
1004    if let Some(ref user_agent) = configuration.user_agent {
1005        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1006    }
1007    if let Some(ref token) = configuration.bearer_access_token {
1008        req_builder = req_builder.bearer_auth(token.to_owned());
1009    };
1010
1011    let req = req_builder.build()?;
1012    let resp = configuration.client.execute(req).await?;
1013
1014    let status = resp.status();
1015
1016    if !status.is_client_error() && !status.is_server_error() {
1017        Ok(())
1018    } else {
1019        let content = resp.text().await?;
1020        let entity: Option<GetAgentsSessionsStreamError> = serde_json::from_str(&content).ok();
1021        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1022    }
1023}
1024
1025/// Returns every machine registered to the caller's org, newest first, each with its live session load.
1026pub async fn get_agents_targets(configuration: &configuration::Configuration, ) -> Result<models::TargetList, Error<GetAgentsTargetsError>> {
1027
1028    let uri_str = format!("{}/v1/agents/targets", configuration.base_path);
1029    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1030
1031    if let Some(ref user_agent) = configuration.user_agent {
1032        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1033    }
1034    if let Some(ref token) = configuration.bearer_access_token {
1035        req_builder = req_builder.bearer_auth(token.to_owned());
1036    };
1037
1038    let req = req_builder.build()?;
1039    let resp = configuration.client.execute(req).await?;
1040
1041    let status = resp.status();
1042    let content_type = resp
1043        .headers()
1044        .get("content-type")
1045        .and_then(|v| v.to_str().ok())
1046        .unwrap_or("application/octet-stream");
1047    let content_type = super::ContentType::from(content_type);
1048
1049    if !status.is_client_error() && !status.is_server_error() {
1050        let content = resp.text().await?;
1051        match content_type {
1052            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1053            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TargetList`"))),
1054            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TargetList`")))),
1055        }
1056    } else {
1057        let content = resp.text().await?;
1058        let entity: Option<GetAgentsTargetsError> = serde_json::from_str(&content).ok();
1059        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1060    }
1061}
1062
1063/// Returns one registered machine, with its live session load.
1064pub async fn get_agents_targets_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::TargetView, Error<GetAgentsTargetsByIdError>> {
1065    // add a prefix to parameters to efficiently prevent name collisions
1066    let p_id = id;
1067
1068    let uri_str = format!("{}/v1/agents/targets/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1069    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1070
1071    if let Some(ref user_agent) = configuration.user_agent {
1072        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1073    }
1074    if let Some(ref token) = configuration.bearer_access_token {
1075        req_builder = req_builder.bearer_auth(token.to_owned());
1076    };
1077
1078    let req = req_builder.build()?;
1079    let resp = configuration.client.execute(req).await?;
1080
1081    let status = resp.status();
1082    let content_type = resp
1083        .headers()
1084        .get("content-type")
1085        .and_then(|v| v.to_str().ok())
1086        .unwrap_or("application/octet-stream");
1087    let content_type = super::ContentType::from(content_type);
1088
1089    if !status.is_client_error() && !status.is_server_error() {
1090        let content = resp.text().await?;
1091        match content_type {
1092            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1093            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TargetView`"))),
1094            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TargetView`")))),
1095        }
1096    } else {
1097        let content = resp.text().await?;
1098        let entity: Option<GetAgentsTargetsByIdError> = serde_json::from_str(&content).ok();
1099        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1100    }
1101}
1102
1103/// Changes an agent in place. Every field is optional; a field the request omits keeps its stored value. The resulting mode+schedule are re-validated together, so a partial update can never leave a long-running agent without the cron the scheduler needs to fire it, and a transition INTO long-running counts against the per-org cap on scheduled agents.
1104pub async fn patch_agents_by_ref(configuration: &configuration::Configuration, r#ref: &str, update_agent_in: models::UpdateAgentIn) -> Result<models::AgentView, Error<PatchAgentsByRefError>> {
1105    // add a prefix to parameters to efficiently prevent name collisions
1106    let p_ref = r#ref;
1107    let p_update_agent_in = update_agent_in;
1108
1109    let uri_str = format!("{}/v1/agents/{ref}", configuration.base_path, ref=crate::apis::urlencode(p_ref));
1110    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1111
1112    if let Some(ref user_agent) = configuration.user_agent {
1113        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1114    }
1115    if let Some(ref token) = configuration.bearer_access_token {
1116        req_builder = req_builder.bearer_auth(token.to_owned());
1117    };
1118    req_builder = req_builder.json(&p_update_agent_in);
1119
1120    let req = req_builder.build()?;
1121    let resp = configuration.client.execute(req).await?;
1122
1123    let status = resp.status();
1124    let content_type = resp
1125        .headers()
1126        .get("content-type")
1127        .and_then(|v| v.to_str().ok())
1128        .unwrap_or("application/octet-stream");
1129    let content_type = super::ContentType::from(content_type);
1130
1131    if !status.is_client_error() && !status.is_server_error() {
1132        let content = resp.text().await?;
1133        match content_type {
1134            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1135            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentView`"))),
1136            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AgentView`")))),
1137        }
1138    } else {
1139        let content = resp.text().await?;
1140        let entity: Option<PatchAgentsByRefError> = serde_json::from_str(&content).ok();
1141        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1142    }
1143}
1144
1145/// Updates a session's surface-owned truth: its status, its title, the run-target it is dispatched to, and the product it built plus whether that build's story is public. A FINISHED session stays finished — reopening a done/error run would fabricate liveness — and publishing is refused unless the session names the project it built, because the public build route is keyed on (org, project).
1146pub async fn patch_agents_sessions_by_id(configuration: &configuration::Configuration, id: &str, patch_session_in: models::PatchSessionIn) -> Result<models::SessionView, Error<PatchAgentsSessionsByIdError>> {
1147    // add a prefix to parameters to efficiently prevent name collisions
1148    let p_id = id;
1149    let p_patch_session_in = patch_session_in;
1150
1151    let uri_str = format!("{}/v1/agents/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1152    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1153
1154    if let Some(ref user_agent) = configuration.user_agent {
1155        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1156    }
1157    if let Some(ref token) = configuration.bearer_access_token {
1158        req_builder = req_builder.bearer_auth(token.to_owned());
1159    };
1160    req_builder = req_builder.json(&p_patch_session_in);
1161
1162    let req = req_builder.build()?;
1163    let resp = configuration.client.execute(req).await?;
1164
1165    let status = resp.status();
1166    let content_type = resp
1167        .headers()
1168        .get("content-type")
1169        .and_then(|v| v.to_str().ok())
1170        .unwrap_or("application/octet-stream");
1171    let content_type = super::ContentType::from(content_type);
1172
1173    if !status.is_client_error() && !status.is_server_error() {
1174        let content = resp.text().await?;
1175        match content_type {
1176            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1177            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SessionView`"))),
1178            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SessionView`")))),
1179        }
1180    } else {
1181        let content = resp.text().await?;
1182        let entity: Option<PatchAgentsSessionsByIdError> = serde_json::from_str(&content).ok();
1183        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1184    }
1185}
1186
1187/// Updates one machine in place. Every field is optional; a field the request omits is left alone. A metrics patch IS a heartbeat — the server stamps its own clock, so a client can neither forge nor backdate staleness.
1188pub async fn patch_agents_targets_by_id(configuration: &configuration::Configuration, id: &str, patch_target_in: models::PatchTargetIn) -> Result<models::TargetView, Error<PatchAgentsTargetsByIdError>> {
1189    // add a prefix to parameters to efficiently prevent name collisions
1190    let p_id = id;
1191    let p_patch_target_in = patch_target_in;
1192
1193    let uri_str = format!("{}/v1/agents/targets/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1194    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1195
1196    if let Some(ref user_agent) = configuration.user_agent {
1197        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1198    }
1199    if let Some(ref token) = configuration.bearer_access_token {
1200        req_builder = req_builder.bearer_auth(token.to_owned());
1201    };
1202    req_builder = req_builder.json(&p_patch_target_in);
1203
1204    let req = req_builder.build()?;
1205    let resp = configuration.client.execute(req).await?;
1206
1207    let status = resp.status();
1208    let content_type = resp
1209        .headers()
1210        .get("content-type")
1211        .and_then(|v| v.to_str().ok())
1212        .unwrap_or("application/octet-stream");
1213    let content_type = super::ContentType::from(content_type);
1214
1215    if !status.is_client_error() && !status.is_server_error() {
1216        let content = resp.text().await?;
1217        match content_type {
1218            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1219            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TargetView`"))),
1220            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TargetView`")))),
1221        }
1222    } else {
1223        let content = resp.text().await?;
1224        let entity: Option<PatchAgentsTargetsByIdError> = serde_json::from_str(&content).ok();
1225        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1226    }
1227}
1228
1229/// Defines an agent in the caller's org: a model, a system prompt (instructions) and a set of tool names. The name must be unique in the org and match ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$. An omitted model takes the deployment's configured default; a named one is checked against the gateway's served catalog, so a model this deployment never serves is refused here rather than failing at run time. A long-running agent must carry a 5-field cron schedule (the scheduler would otherwise never fire it) and counts against a per-org cap on scheduled agents.
1230pub async fn post_agents(configuration: &configuration::Configuration, create_agent_in: models::CreateAgentIn) -> Result<models::AgentView, Error<PostAgentsError>> {
1231    // add a prefix to parameters to efficiently prevent name collisions
1232    let p_create_agent_in = create_agent_in;
1233
1234    let uri_str = format!("{}/v1/agents", configuration.base_path);
1235    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1236
1237    if let Some(ref user_agent) = configuration.user_agent {
1238        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1239    }
1240    if let Some(ref token) = configuration.bearer_access_token {
1241        req_builder = req_builder.bearer_auth(token.to_owned());
1242    };
1243    req_builder = req_builder.json(&p_create_agent_in);
1244
1245    let req = req_builder.build()?;
1246    let resp = configuration.client.execute(req).await?;
1247
1248    let status = resp.status();
1249    let content_type = resp
1250        .headers()
1251        .get("content-type")
1252        .and_then(|v| v.to_str().ok())
1253        .unwrap_or("application/octet-stream");
1254    let content_type = super::ContentType::from(content_type);
1255
1256    if !status.is_client_error() && !status.is_server_error() {
1257        let content = resp.text().await?;
1258        match content_type {
1259            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1260            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentView`"))),
1261            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AgentView`")))),
1262        }
1263    } else {
1264        let content = resp.text().await?;
1265        let entity: Option<PostAgentsError> = serde_json::from_str(&content).ok();
1266        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1267    }
1268}
1269
1270/// Composes the agent's stored instructions with the caller's `input`, executes one real chat completion through the same in-process AI client the rest of the console uses, and answers with the run that was recorded: its id, status, model, output, duration and error. Every run this returns reflects an execution that actually happened — a model failure is recorded and reported, never hidden and never fabricated. A transient upstream failure (429, 5xx, empty choices) is retried up to three times with jittered backoff, and a configured failover model is tried before the run is called an error.  `ref` is the agent's public `agent_…` id or its org-unique name; either resolves the same agent, and it must belong to the caller's org, so an agent in another tenant is a 404 exactly like one that does not exist. A validated principal is required and the check is made twice on purpose: this route MOVES MONEY, so the debit's principal requirement is asserted where the money moves rather than inherited from the tenant lookup.  The org's balance is authorized BEFORE any inference, so an unfunded tenant gets 402 and no free compute, and a billing plane that cannot answer gets 503 rather than a free run. The flat per-run fee is an operator knob; setting it to zero makes runs free and removes the balance gate with them. Only a SUCCESSFUL run is billed, attributed to the model actually used — a failover run bills the model it fell over to, not the one it started on. A deployment with no inference wired answers 503 before any of this.  THE RULE A READER GETS WRONG: a failed run is a 502 whose body is the RUN, not an error envelope. The execution happened, the run was persisted to this agent's history, and its `error` field is the product — so a client that treats every non-2xx as an opaque failure throws away the only account of what went wrong. Each run also opens a root session in the live session registry, best-effort: a bookkeeping failure there never fails the run, because the run and its billing already happened.
1271pub async fn post_agents_by_ref_run(configuration: &configuration::Configuration, r#ref: &str) -> Result<(), Error<PostAgentsByRefRunError>> {
1272    // add a prefix to parameters to efficiently prevent name collisions
1273    let p_ref = r#ref;
1274
1275    let uri_str = format!("{}/v1/agents/{ref}/run", configuration.base_path, ref=crate::apis::urlencode(p_ref));
1276    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1277
1278    if let Some(ref user_agent) = configuration.user_agent {
1279        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1280    }
1281    if let Some(ref token) = configuration.bearer_access_token {
1282        req_builder = req_builder.bearer_auth(token.to_owned());
1283    };
1284
1285    let req = req_builder.build()?;
1286    let resp = configuration.client.execute(req).await?;
1287
1288    let status = resp.status();
1289
1290    if !status.is_client_error() && !status.is_server_error() {
1291        Ok(())
1292    } else {
1293        let content = resp.text().await?;
1294        let entity: Option<PostAgentsByRefRunError> = serde_json::from_str(&content).ok();
1295        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1296    }
1297}
1298
1299/// Answers one turn of a conversation with four things: the model's `reply`, the `actions` the server executed on the caller's behalf, the `ops` the client must apply itself, and the `conversationId` the turn was recorded under.  The split between actions and ops is the rule most easily got wrong. A tool call is executed HERE only when the chosen preset is server-executing AND the tool resolves in the caller's own scope; every other call is handed back as an op for the client to apply to its own graph or UI. A tool that fails still comes back as an action, carrying its error rather than failing the round.  `preset` selects the system prompt and the tool set (`capability` is a legacy alias for it); an unknown one is refused. `conversationId` continues an existing thread, and its absence starts one. A validated principal with a non-empty org is required — the org is the sole authority for both persistence and tool scope, and is NEVER read from the body.  A completion refused for the caller's own reason — 402 insufficient balance, 429, 403 — is relayed with its own status and body verbatim, so the real billing message reaches the client instead of an opaque gateway error. Only a genuine upstream fault becomes a 502.
1300pub async fn post_agents_chat(configuration: &configuration::Configuration, ) -> Result<(), Error<PostAgentsChatError>> {
1301
1302    let uri_str = format!("{}/v1/agents/chat", configuration.base_path);
1303    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1304
1305    if let Some(ref user_agent) = configuration.user_agent {
1306        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1307    }
1308    if let Some(ref token) = configuration.bearer_access_token {
1309        req_builder = req_builder.bearer_auth(token.to_owned());
1310    };
1311
1312    let req = req_builder.build()?;
1313    let resp = configuration.client.execute(req).await?;
1314
1315    let status = resp.status();
1316
1317    if !status.is_client_error() && !status.is_server_error() {
1318        Ok(())
1319    } else {
1320        let content = resp.text().await?;
1321        let entity: Option<PostAgentsChatError> = serde_json::from_str(&content).ok();
1322        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1323    }
1324}
1325
1326/// Runs a coding task on a repository: clones it into a sandbox, lets a model read and edit the code, run the tests, and push the work to a branch. Say the thing you want done — \"fix the failing auth test in hanzoai/cloud\" — and the run infers the repo, the branch and the plan. No prefix, no ceremony.  It answers 202 with the run's handle the moment the run is ADMITTED — not when it finishes. A coding run takes minutes; holding a request open for one would tie a connection to a model loop and give the caller nothing it cannot get better from the session stream.  The handle is a session id, and that is deliberate: the session is already the run's durable record and its live stream (/v1/agents/sessions/{id}/stream), so this op does not grow a progress endpoint, a status endpoint or a cancel endpoint of its own. One way to watch a run, whoever started it.  It is also how work CONTINUES. Pass an earlier run's session as `after` and this one starts from where that one stopped, so \"now add tests for it\" builds on the branch already pushed instead of a fresh clone. The follow-up still gets its own branch and its own session — one run, one branch, always reviewable on its own.
1327pub async fn post_agents_coding(configuration: &configuration::Configuration, coding_start_in: models::CodingStartIn) -> Result<models::CodingStarted, Error<PostAgentsCodingError>> {
1328    // add a prefix to parameters to efficiently prevent name collisions
1329    let p_coding_start_in = coding_start_in;
1330
1331    let uri_str = format!("{}/v1/agents/coding", configuration.base_path);
1332    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1333
1334    if let Some(ref user_agent) = configuration.user_agent {
1335        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1336    }
1337    if let Some(ref token) = configuration.bearer_access_token {
1338        req_builder = req_builder.bearer_auth(token.to_owned());
1339    };
1340    req_builder = req_builder.json(&p_coding_start_in);
1341
1342    let req = req_builder.build()?;
1343    let resp = configuration.client.execute(req).await?;
1344
1345    let status = resp.status();
1346    let content_type = resp
1347        .headers()
1348        .get("content-type")
1349        .and_then(|v| v.to_str().ok())
1350        .unwrap_or("application/octet-stream");
1351    let content_type = super::ContentType::from(content_type);
1352
1353    if !status.is_client_error() && !status.is_server_error() {
1354        let content = resp.text().await?;
1355        match content_type {
1356            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1357            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CodingStarted`"))),
1358            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CodingStarted`")))),
1359        }
1360    } else {
1361        let content = resp.text().await?;
1362        let entity: Option<PostAgentsCodingError> = serde_json::from_str(&content).ok();
1363        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1364    }
1365}
1366
1367/// Opens a live agent session in the caller's org — the row every surface (the CLI's outer agent, hanzo.bot, the console, chat) hangs its activity off. A session with a parentSessionId becomes a subagent of that session and inherits its root, so one flow is one tree; without one it is itself a root. Registering with a terminal status records a session that has already finished.
1368pub async fn post_agents_sessions(configuration: &configuration::Configuration, register_req: models::RegisterReq) -> Result<models::SessionView, Error<PostAgentsSessionsError>> {
1369    // add a prefix to parameters to efficiently prevent name collisions
1370    let p_register_req = register_req;
1371
1372    let uri_str = format!("{}/v1/agents/sessions", configuration.base_path);
1373    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1374
1375    if let Some(ref user_agent) = configuration.user_agent {
1376        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1377    }
1378    if let Some(ref token) = configuration.bearer_access_token {
1379        req_builder = req_builder.bearer_auth(token.to_owned());
1380    };
1381    req_builder = req_builder.json(&p_register_req);
1382
1383    let req = req_builder.build()?;
1384    let resp = configuration.client.execute(req).await?;
1385
1386    let status = resp.status();
1387    let content_type = resp
1388        .headers()
1389        .get("content-type")
1390        .and_then(|v| v.to_str().ok())
1391        .unwrap_or("application/octet-stream");
1392    let content_type = super::ContentType::from(content_type);
1393
1394    if !status.is_client_error() && !status.is_server_error() {
1395        let content = resp.text().await?;
1396        match content_type {
1397            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1398            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SessionView`"))),
1399            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SessionView`")))),
1400        }
1401    } else {
1402        let content = resp.text().await?;
1403        let entity: Option<PostAgentsSessionsError> = serde_json::from_str(&content).ok();
1404        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1405    }
1406}
1407
1408/// Records one turn of a session's transcript and answers 201 with it.  A `progress` turn additionally MOVES THE SESSION'S PROGRESS, marked as the run's own word rather than an estimate, and pushes the updated session onto the live stream — so a board's bar follows the run without polling and without a second write path. See progress.go.  THE TURN IS SCANNED BEFORE IT IS STORED. The same engine the code-security surface runs reads the payload at this boundary, and a credential in it refuses the append with 422 rather than redacting it — a redacted transcript is one that still had the secret in it once, and this way the author learns which value to rotate. The refusal carries every finding: the rule, the severity, the line, a MASKED preview and the fingerprint. The secret is never in the answer.
1409pub async fn post_agents_sessions_by_id_events(configuration: &configuration::Configuration, id: &str, event_in: models::EventIn) -> Result<models::EventView, Error<PostAgentsSessionsByIdEventsError>> {
1410    // add a prefix to parameters to efficiently prevent name collisions
1411    let p_id = id;
1412    let p_event_in = event_in;
1413
1414    let uri_str = format!("{}/v1/agents/sessions/{id}/events", configuration.base_path, id=crate::apis::urlencode(p_id));
1415    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1416
1417    if let Some(ref user_agent) = configuration.user_agent {
1418        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1419    }
1420    if let Some(ref token) = configuration.bearer_access_token {
1421        req_builder = req_builder.bearer_auth(token.to_owned());
1422    };
1423    req_builder = req_builder.json(&p_event_in);
1424
1425    let req = req_builder.build()?;
1426    let resp = configuration.client.execute(req).await?;
1427
1428    let status = resp.status();
1429    let content_type = resp
1430        .headers()
1431        .get("content-type")
1432        .and_then(|v| v.to_str().ok())
1433        .unwrap_or("application/octet-stream");
1434    let content_type = super::ContentType::from(content_type);
1435
1436    if !status.is_client_error() && !status.is_server_error() {
1437        let content = resp.text().await?;
1438        match content_type {
1439            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1440            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventView`"))),
1441            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventView`")))),
1442        }
1443    } else {
1444        let content = resp.text().await?;
1445        let entity: Option<PostAgentsSessionsByIdEventsError> = serde_json::from_str(&content).ok();
1446        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1447    }
1448}
1449
1450/// Sends a steering message to a running session — the endpoint a human or another agent interrupts through. It requires a `message` or a `payload`; the other three commands do not.
1451pub async fn post_agents_sessions_by_id_message(configuration: &configuration::Configuration, id: &str, control_in: models::ControlIn) -> Result<models::ControlResult, Error<PostAgentsSessionsByIdMessageError>> {
1452    // add a prefix to parameters to efficiently prevent name collisions
1453    let p_id = id;
1454    let p_control_in = control_in;
1455
1456    let uri_str = format!("{}/v1/agents/sessions/{id}/message", configuration.base_path, id=crate::apis::urlencode(p_id));
1457    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1458
1459    if let Some(ref user_agent) = configuration.user_agent {
1460        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1461    }
1462    if let Some(ref token) = configuration.bearer_access_token {
1463        req_builder = req_builder.bearer_auth(token.to_owned());
1464    };
1465    req_builder = req_builder.json(&p_control_in);
1466
1467    let req = req_builder.build()?;
1468    let resp = configuration.client.execute(req).await?;
1469
1470    let status = resp.status();
1471    let content_type = resp
1472        .headers()
1473        .get("content-type")
1474        .and_then(|v| v.to_str().ok())
1475        .unwrap_or("application/octet-stream");
1476    let content_type = super::ContentType::from(content_type);
1477
1478    if !status.is_client_error() && !status.is_server_error() {
1479        let content = resp.text().await?;
1480        match content_type {
1481            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1482            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ControlResult`"))),
1483            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ControlResult`")))),
1484        }
1485    } else {
1486        let content = resp.text().await?;
1487        let entity: Option<PostAgentsSessionsByIdMessageError> = serde_json::from_str(&content).ok();
1488        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1489    }
1490}
1491
1492/// Asks a running session to pause. Recorded durably, and forwarded to the durable-execution engine when the session is task-backed.
1493pub async fn post_agents_sessions_by_id_pause(configuration: &configuration::Configuration, id: &str, control_in: models::ControlIn) -> Result<models::ControlResult, Error<PostAgentsSessionsByIdPauseError>> {
1494    // add a prefix to parameters to efficiently prevent name collisions
1495    let p_id = id;
1496    let p_control_in = control_in;
1497
1498    let uri_str = format!("{}/v1/agents/sessions/{id}/pause", configuration.base_path, id=crate::apis::urlencode(p_id));
1499    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1500
1501    if let Some(ref user_agent) = configuration.user_agent {
1502        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1503    }
1504    if let Some(ref token) = configuration.bearer_access_token {
1505        req_builder = req_builder.bearer_auth(token.to_owned());
1506    };
1507    req_builder = req_builder.json(&p_control_in);
1508
1509    let req = req_builder.build()?;
1510    let resp = configuration.client.execute(req).await?;
1511
1512    let status = resp.status();
1513    let content_type = resp
1514        .headers()
1515        .get("content-type")
1516        .and_then(|v| v.to_str().ok())
1517        .unwrap_or("application/octet-stream");
1518    let content_type = super::ContentType::from(content_type);
1519
1520    if !status.is_client_error() && !status.is_server_error() {
1521        let content = resp.text().await?;
1522        match content_type {
1523            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1524            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ControlResult`"))),
1525            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ControlResult`")))),
1526        }
1527    } else {
1528        let content = resp.text().await?;
1529        let entity: Option<PostAgentsSessionsByIdPauseError> = serde_json::from_str(&content).ok();
1530        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1531    }
1532}
1533
1534/// Asks a paused session to continue, on the same terms as a pause.
1535pub async fn post_agents_sessions_by_id_resume(configuration: &configuration::Configuration, id: &str, control_in: models::ControlIn) -> Result<models::ControlResult, Error<PostAgentsSessionsByIdResumeError>> {
1536    // add a prefix to parameters to efficiently prevent name collisions
1537    let p_id = id;
1538    let p_control_in = control_in;
1539
1540    let uri_str = format!("{}/v1/agents/sessions/{id}/resume", configuration.base_path, id=crate::apis::urlencode(p_id));
1541    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1542
1543    if let Some(ref user_agent) = configuration.user_agent {
1544        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1545    }
1546    if let Some(ref token) = configuration.bearer_access_token {
1547        req_builder = req_builder.bearer_auth(token.to_owned());
1548    };
1549    req_builder = req_builder.json(&p_control_in);
1550
1551    let req = req_builder.build()?;
1552    let resp = configuration.client.execute(req).await?;
1553
1554    let status = resp.status();
1555    let content_type = resp
1556        .headers()
1557        .get("content-type")
1558        .and_then(|v| v.to_str().ok())
1559        .unwrap_or("application/octet-stream");
1560    let content_type = super::ContentType::from(content_type);
1561
1562    if !status.is_client_error() && !status.is_server_error() {
1563        let content = resp.text().await?;
1564        match content_type {
1565            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1566            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ControlResult`"))),
1567            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ControlResult`")))),
1568        }
1569    } else {
1570        let content = resp.text().await?;
1571        let entity: Option<PostAgentsSessionsByIdResumeError> = serde_json::from_str(&content).ok();
1572        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1573    }
1574}
1575
1576/// Ends a running session. `message` is recorded as the cancellation reason, which is what a later reader of the transcript sees.  STOPPING IS NOT DELETING: the session, its transcript and anything it produced stay readable. A session that has already finished is 409 rather than a second stop.
1577pub async fn post_agents_sessions_by_id_stop(configuration: &configuration::Configuration, id: &str, control_in: models::ControlIn) -> Result<models::ControlResult, Error<PostAgentsSessionsByIdStopError>> {
1578    // add a prefix to parameters to efficiently prevent name collisions
1579    let p_id = id;
1580    let p_control_in = control_in;
1581
1582    let uri_str = format!("{}/v1/agents/sessions/{id}/stop", configuration.base_path, id=crate::apis::urlencode(p_id));
1583    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1584
1585    if let Some(ref user_agent) = configuration.user_agent {
1586        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1587    }
1588    if let Some(ref token) = configuration.bearer_access_token {
1589        req_builder = req_builder.bearer_auth(token.to_owned());
1590    };
1591    req_builder = req_builder.json(&p_control_in);
1592
1593    let req = req_builder.build()?;
1594    let resp = configuration.client.execute(req).await?;
1595
1596    let status = resp.status();
1597    let content_type = resp
1598        .headers()
1599        .get("content-type")
1600        .and_then(|v| v.to_str().ok())
1601        .unwrap_or("application/octet-stream");
1602    let content_type = super::ContentType::from(content_type);
1603
1604    if !status.is_client_error() && !status.is_server_error() {
1605        let content = resp.text().await?;
1606        match content_type {
1607            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1608            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ControlResult`"))),
1609            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ControlResult`")))),
1610        }
1611    } else {
1612        let content = resp.text().await?;
1613        let entity: Option<PostAgentsSessionsByIdStopError> = serde_json::from_str(&content).ok();
1614        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1615    }
1616}
1617
1618/// Registers a machine as an agent target, or re-links one that is already registered. Re-linking is idempotent and keyed on org+host+owner, so a machine that reconnects refreshes its own row rather than piling up duplicates; it answers 200, while a first registration answers 201.
1619pub async fn post_agents_targets(configuration: &configuration::Configuration, target_req: models::TargetReq) -> Result<models::TargetView, Error<PostAgentsTargetsError>> {
1620    // add a prefix to parameters to efficiently prevent name collisions
1621    let p_target_req = target_req;
1622
1623    let uri_str = format!("{}/v1/agents/targets", configuration.base_path);
1624    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1625
1626    if let Some(ref user_agent) = configuration.user_agent {
1627        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1628    }
1629    if let Some(ref token) = configuration.bearer_access_token {
1630        req_builder = req_builder.bearer_auth(token.to_owned());
1631    };
1632    req_builder = req_builder.json(&p_target_req);
1633
1634    let req = req_builder.build()?;
1635    let resp = configuration.client.execute(req).await?;
1636
1637    let status = resp.status();
1638    let content_type = resp
1639        .headers()
1640        .get("content-type")
1641        .and_then(|v| v.to_str().ok())
1642        .unwrap_or("application/octet-stream");
1643    let content_type = super::ContentType::from(content_type);
1644
1645    if !status.is_client_error() && !status.is_server_error() {
1646        let content = resp.text().await?;
1647        match content_type {
1648            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1649            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TargetView`"))),
1650            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TargetView`")))),
1651        }
1652    } else {
1653        let content = resp.text().await?;
1654        let entity: Option<PostAgentsTargetsError> = serde_json::from_str(&content).ok();
1655        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1656    }
1657}
1658
1659/// ClaimRoutedRun is the machine's long poll for work: it authenticates the daemon, stamps the liveness the dispatch gate reads (the poll IS the proof a runner is listening), and waits up to 25 seconds for the next run addressed to THIS machine. It answers the run when one arrives and 204 with no body when the window elapses, on which the daemon re-polls immediately.  TWO independent proofs are required and both fail closed to the same 403: the caller must own this machine (or be an org admin) AND present its claim key in X-Target-Key. A run offered to one machine is unreachable from another's claim.
1660pub async fn post_agents_targets_by_id_claim(configuration: &configuration::Configuration, id: &str) -> Result<models::RoutedRunOut, Error<PostAgentsTargetsByIdClaimError>> {
1661    // add a prefix to parameters to efficiently prevent name collisions
1662    let p_id = id;
1663
1664    let uri_str = format!("{}/v1/agents/targets/{id}/claim", configuration.base_path, id=crate::apis::urlencode(p_id));
1665    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1666
1667    if let Some(ref user_agent) = configuration.user_agent {
1668        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1669    }
1670    if let Some(ref token) = configuration.bearer_access_token {
1671        req_builder = req_builder.bearer_auth(token.to_owned());
1672    };
1673
1674    let req = req_builder.build()?;
1675    let resp = configuration.client.execute(req).await?;
1676
1677    let status = resp.status();
1678    let content_type = resp
1679        .headers()
1680        .get("content-type")
1681        .and_then(|v| v.to_str().ok())
1682        .unwrap_or("application/octet-stream");
1683    let content_type = super::ContentType::from(content_type);
1684
1685    if !status.is_client_error() && !status.is_server_error() {
1686        let content = resp.text().await?;
1687        match content_type {
1688            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1689            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RoutedRunOut`"))),
1690            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RoutedRunOut`")))),
1691        }
1692    } else {
1693        let content = resp.text().await?;
1694        let entity: Option<PostAgentsTargetsByIdClaimError> = serde_json::from_str(&content).ok();
1695        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1696    }
1697}
1698
1699/// Mints (or rotates) the claim key a `hanzo code --serve` daemon presents to claim work for this machine, and returns it ONCE: only its SHA-256 hash is stored. Rotating supersedes any prior daemon, so only the machine's owner — or an org admin — may call it; every other caller gets the same not-found an unknown id gets, and learns nothing about what exists.
1700pub async fn post_agents_targets_by_id_key(configuration: &configuration::Configuration, id: &str) -> Result<models::ClaimKeyOut, Error<PostAgentsTargetsByIdKeyError>> {
1701    // add a prefix to parameters to efficiently prevent name collisions
1702    let p_id = id;
1703
1704    let uri_str = format!("{}/v1/agents/targets/{id}/key", configuration.base_path, id=crate::apis::urlencode(p_id));
1705    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1706
1707    if let Some(ref user_agent) = configuration.user_agent {
1708        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1709    }
1710    if let Some(ref token) = configuration.bearer_access_token {
1711        req_builder = req_builder.bearer_auth(token.to_owned());
1712    };
1713
1714    let req = req_builder.build()?;
1715    let resp = configuration.client.execute(req).await?;
1716
1717    let status = resp.status();
1718    let content_type = resp
1719        .headers()
1720        .get("content-type")
1721        .and_then(|v| v.to_str().ok())
1722        .unwrap_or("application/octet-stream");
1723    let content_type = super::ContentType::from(content_type);
1724
1725    if !status.is_client_error() && !status.is_server_error() {
1726        let content = resp.text().await?;
1727        match content_type {
1728            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1729            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClaimKeyOut`"))),
1730            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClaimKeyOut`")))),
1731        }
1732    } else {
1733        let content = resp.text().await?;
1734        let entity: Option<PostAgentsTargetsByIdKeyError> = serde_json::from_str(&content).ok();
1735        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1736    }
1737}
1738
1739/// Completes a claimed run: it delivers the terminal result to the run's durable owner, which is what lets that workflow finish. Scoped to (org, target, run) and claim-key authenticated, so a machine can only ever report a run it legitimately holds. Idempotent — a report for an unknown or already-finished run answers delivered:false rather than failing, because the session's terminal state was already set by the machine's own stream.
1740pub async fn post_agents_targets_by_id_runs_by_runid_report(configuration: &configuration::Configuration, id: &str, run_id: &str, report_run_in: models::ReportRunIn) -> Result<models::ReportOut, Error<PostAgentsTargetsByIdRunsByRunidReportError>> {
1741    // add a prefix to parameters to efficiently prevent name collisions
1742    let p_id = id;
1743    let p_run_id = run_id;
1744    let p_report_run_in = report_run_in;
1745
1746    let uri_str = format!("{}/v1/agents/targets/{id}/runs/{runId}/report", configuration.base_path, id=crate::apis::urlencode(p_id), runId=crate::apis::urlencode(p_run_id));
1747    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1748
1749    if let Some(ref user_agent) = configuration.user_agent {
1750        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1751    }
1752    if let Some(ref token) = configuration.bearer_access_token {
1753        req_builder = req_builder.bearer_auth(token.to_owned());
1754    };
1755    req_builder = req_builder.json(&p_report_run_in);
1756
1757    let req = req_builder.build()?;
1758    let resp = configuration.client.execute(req).await?;
1759
1760    let status = resp.status();
1761    let content_type = resp
1762        .headers()
1763        .get("content-type")
1764        .and_then(|v| v.to_str().ok())
1765        .unwrap_or("application/octet-stream");
1766    let content_type = super::ContentType::from(content_type);
1767
1768    if !status.is_client_error() && !status.is_server_error() {
1769        let content = resp.text().await?;
1770        match content_type {
1771            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1772            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReportOut`"))),
1773            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ReportOut`")))),
1774        }
1775    } else {
1776        let content = resp.text().await?;
1777        let entity: Option<PostAgentsTargetsByIdRunsByRunidReportError> = serde_json::from_str(&content).ok();
1778        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1779    }
1780}
1781