Skip to main content

hanzo_client/models/
session_view.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
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct SessionView {
16    /// Account is which subscription or API account under that provider served it. Together with Provider it is what a login revoke matches on to stop the sessions a withdrawn account was paying for.
17    #[serde(rename = "account", skip_serializing_if = "Option::is_none")]
18    pub account: Option<String>,
19    /// Actor is WHO this session belongs to, as \"org/sub\" — the same identity a run is billed under. A register that names none takes the calling principal. It is what scopes a login revoke, so a session with the wrong actor is a session the right person cannot stop.
20    #[serde(rename = "actor", skip_serializing_if = "Option::is_none")]
21    pub actor: Option<String>,
22    /// Agent is the label the surface running this session calls itself by (\"hanzo-dev\"), up to 128 characters. Required at register. It is free text, not a reference: it need not name a defined agent, and nothing resolves it.
23    #[serde(rename = "agent", skip_serializing_if = "Option::is_none")]
24    pub agent: Option<String>,
25    /// Children is the DIRECT fan-out — how many sessions name this one as parent — and not the size of the subtree. Read the tree for that.
26    #[serde(rename = "children", skip_serializing_if = "Option::is_none")]
27    pub children: Option<i32>,
28    /// CreatedAt is when the row was written, same format. Every path that opens a session stamps it and StartedAt from one clock reading, so the two are equal on every session this surface has ever produced.
29    #[serde(rename = "createdAt", skip_serializing_if = "Option::is_none")]
30    pub created_at: Option<String>,
31    /// Cwd is the directory the session is working in NOW, not the one it started in: a linked shell moves around, and a card showing where `hanzo link` was run answers \"which work is this\" with something that was true once.
32    #[serde(rename = "cwd", skip_serializing_if = "Option::is_none")]
33    pub cwd: Option<String>,
34    /// EndedAt is when it reached done or error, same format. Empty while it is still running or paused, which is how absence reads here: not over yet.
35    #[serde(rename = "endedAt", skip_serializing_if = "Option::is_none")]
36    pub ended_at: Option<String>,
37    /// Events is how many turns the session's log holds, counted at read time. It is the whole log, however few of them RecentEvents carries.
38    #[serde(rename = "events", skip_serializing_if = "Option::is_none")]
39    pub events: Option<i32>,
40    /// Execution context (mission-control): the machine/repo/cwd a card shows and the run-target a session is dispatched to. Omitted when a surface didn't report it.
41    #[serde(rename = "host", skip_serializing_if = "Option::is_none")]
42    pub host: Option<String>,
43    /// ID is the session's handle, minted here as \"sess_\" + 32 hex characters. Every later read, patch, event append and control command is addressed with it, and a caller cannot choose it.
44    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
45    pub id: Option<String>,
46    /// LastEvent is the compact latest-activity line for the list projection (nil in register/patch/tree responses; set by list + detail). It lets a swipe card show a live one-line preview without fetching full detail.
47    #[serde(rename = "lastEvent", skip_serializing_if = "Option::is_none")]
48    pub last_event: Option<Box<models::LastEventView>>,
49    /// Org is the caller's OWN tenant, echoed so a client can build the public build URL (/builds/:org/:project) without a second call or a guess. It is never another tenant's — every read is org-scoped before it gets here.
50    #[serde(rename = "org", skip_serializing_if = "Option::is_none")]
51    pub org: Option<String>,
52    /// ParentSessionID is the session that spawned this one, making this a subagent of it. Empty means this session is a root — a flow of its own. A parent always belongs to the same org, so a tree never crosses a tenant.
53    #[serde(rename = "parentSessionId", skip_serializing_if = "Option::is_none")]
54    pub parent_session_id: Option<String>,
55    /// Progress is how far along this run is — a share of its goal, a phase, and a line saying what it is doing. Always present, so a board never branches on whether it is there; `phase` says \"unknown\" when nothing has estimated it. It is a MODEL ESTIMATE wherever `estimated` is true, and the row's own word where it is false. See progress.go.
56    #[serde(rename = "progress", skip_serializing_if = "Option::is_none")]
57    pub progress: Option<Box<models::SessionProgress>>,
58    /// The readable build: the product this session built and whether its story is public (provenance.go).
59    #[serde(rename = "project", skip_serializing_if = "Option::is_none")]
60    pub project: Option<String>,
61    /// Provider is the linked AI account's provider (claude | codex | hanzo | …) that served this run. Empty when the surface did not say.
62    #[serde(rename = "provider", skip_serializing_if = "Option::is_none")]
63    pub provider: Option<String>,
64    /// Published is the author's decision to let anyone read this session's story at the public build route. It only ever widens READ access to a session that already exists and grants nothing else; false, an unpublished session is invisible there no matter who asks. It cannot be true without a Project, because that route is keyed on (org, project).
65    #[serde(rename = "published", skip_serializing_if = "Option::is_none")]
66    pub published: Option<bool>,
67    /// Repo is the code the session is working on, as the surface reported it. It is truth the SURFACE states, so it is a label rather than something resolved here.
68    #[serde(rename = "repo", skip_serializing_if = "Option::is_none")]
69    pub repo: Option<String>,
70    /// Room is the collaborative room this run was started in (HIP-0523), empty when it came from anywhere else — a CLI, a schedule, an API call. It is what lets a workspace view show the runs of one room beside its messages.
71    #[serde(rename = "room", skip_serializing_if = "Option::is_none")]
72    pub room: Option<String>,
73    /// RootSessionID is the top of this session's tree, inherited from the parent and shared by every node in one flow. A root session's own id, when it has no parent. It is the key one indexed read pulls a whole flow by, and what ?root= narrows a list or a stream to.
74    #[serde(rename = "rootSessionId", skip_serializing_if = "Option::is_none")]
75    pub root_session_id: Option<String>,
76    /// StartedAt is when the session opened, RFC 3339 in UTC to the second.
77    #[serde(rename = "startedAt", skip_serializing_if = "Option::is_none")]
78    pub started_at: Option<String>,
79    /// Status is one of exactly four: running, paused, done, error. running and paused are LIVE; done and error are TERMINAL and monotonic — once a session reaches one it can never go back, because reopening a finished run would fabricate liveness. A control command never moves it: the surface running the agent reports the new status, and until it does the command is only recorded.
80    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
81    pub status: Option<String>,
82    /// Target is the registered run-target this session is dispatched to — a machine the org claimed, resolved same-org when it was set, so it can never point at another tenant's computer. Empty means the session names no machine.
83    #[serde(rename = "target", skip_serializing_if = "Option::is_none")]
84    pub target: Option<String>,
85    /// TaskRunID is that workflow's particular run. A workflow is the definition and a run is one execution of it, which is why both are carried.
86    #[serde(rename = "taskRunId", skip_serializing_if = "Option::is_none")]
87    pub task_run_id: Option<String>,
88    /// TaskWorkflowID is the hanzoai/tasks durable workflow that actually EXECUTES this session — this registry is the view, control and stream layer over it. Set, a control command is FORWARDED to that engine; empty, the running surface polls for commands instead, which is every session today.
89    #[serde(rename = "taskWorkflowId", skip_serializing_if = "Option::is_none")]
90    pub task_workflow_id: Option<String>,
91    /// Terminal is where this session can be WATCHED — the URL the machine published for its live terminal. Omitted when it publishes none.
92    #[serde(rename = "terminal", skip_serializing_if = "Option::is_none")]
93    pub terminal: Option<String>,
94    /// Title is the human line a card shows (\"ship the landing page\"), up to 512 characters. Free text, and the one field a surface may rewrite as the work turns out to be something else.
95    #[serde(rename = "title", skip_serializing_if = "Option::is_none")]
96    pub title: Option<String>,
97    /// UpdatedAt is the session's last-activity clock, same format. It moves on a write to the row — a status, a title, a re-dispatch — AND on every appended turn, because the append bumps it in the same transaction. The list is ordered on CreatedAt, so this is the field that says whether a session is still saying anything.
98    #[serde(rename = "updatedAt", skip_serializing_if = "Option::is_none")]
99    pub updated_at: Option<String>,
100}
101
102impl SessionView {
103    pub fn new() -> SessionView {
104        SessionView {
105            account: None,
106            actor: None,
107            agent: None,
108            children: None,
109            created_at: None,
110            cwd: None,
111            ended_at: None,
112            events: None,
113            host: None,
114            id: None,
115            last_event: None,
116            org: None,
117            parent_session_id: None,
118            progress: None,
119            project: None,
120            provider: None,
121            published: None,
122            repo: None,
123            room: None,
124            root_session_id: None,
125            started_at: None,
126            status: None,
127            target: None,
128            task_run_id: None,
129            task_workflow_id: None,
130            terminal: None,
131            title: None,
132            updated_at: None,
133        }
134    }
135}
136