ahp_types/notifications.rs
1// Generated from types/*.ts — do not edit.
2//
3// Regenerate with: npm run generate:rust
4
5#![allow(missing_docs)]
6
7#[allow(unused_imports)]
8use crate::common::{AnyValue, JsonObject, StringOrMarkdown, Uri};
9#[allow(unused_imports)]
10use serde::{Deserialize, Serialize};
11#[allow(unused_imports)]
12use serde_repr::{Deserialize_repr, Serialize_repr};
13
14#[allow(unused_imports)]
15use crate::state::{
16 AgentSelection, AnnotationsSummary, ChangesSummary, Changeset, FileEdit, ModelSelection,
17 ProjectInfo, SessionStatus, SessionSummary,
18};
19
20// ─── Enums ────────────────────────────────────────────────────────────
21
22/// Reason why authentication is required.
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
24pub enum AuthRequiredReason {
25 /// The client has not yet authenticated for the resource
26 #[serde(rename = "required")]
27 Required,
28 /// A previously valid token has expired or been revoked
29 #[serde(rename = "expired")]
30 Expired,
31}
32
33// ─── Notification Payloads ────────────────────────────────────────────
34
35/// Broadcast to all clients subscribed to the root channel when a new session
36/// is created.
37#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
38#[serde(rename_all = "camelCase")]
39pub struct SessionAddedParams {
40 /// Channel URI this notification belongs to (the root channel)
41 pub channel: Uri,
42 /// Summary of the new session
43 pub summary: SessionSummary,
44}
45
46/// Broadcast to all clients subscribed to the root channel when a session is
47/// disposed.
48#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
49#[serde(rename_all = "camelCase")]
50pub struct SessionRemovedParams {
51 /// Channel URI this notification belongs to (the root channel)
52 pub channel: Uri,
53 /// URI of the removed session
54 pub session: Uri,
55}
56
57/// Broadcast to all clients subscribed to the root channel when an existing
58/// session's summary changes (title, status, `modifiedAt`, model, working
59/// directory, read/done state, or diff statistics).
60///
61/// This notification lets clients that maintain a cached session list — for
62/// example, the result of a previous `listSessions()` call — stay in sync with
63/// in-flight sessions without having to subscribe to every session URI
64/// individually. It is complementary to, not a replacement for,
65/// `root/sessionAdded` and `root/sessionRemoved`: those signal lifecycle
66/// (creation/disposal), while this signals summary-level mutations on an
67/// already-known session.
68///
69/// Semantics:
70///
71/// - Only fields present in `changes` have new values; omitted fields are
72/// unchanged on the client's cached summary.
73/// - Identity fields (`resource`, `provider`, `createdAt`) never change and
74/// are not carried.
75/// - Like all protocol notifications, this is ephemeral: it is **not**
76/// replayed on reconnect. On reconnect, clients should re-fetch the full
77/// catalog via `listSessions()` as usual.
78/// - The server SHOULD emit this notification whenever any mutable field on
79/// {@link SessionSummary | `SessionSummary`} changes for a session the
80/// server has surfaced via `listSessions()` or `root/sessionAdded`.
81/// Servers MAY coalesce or debounce updates for noisy fields (for example,
82/// `modifiedAt` bumps while a turn is streaming) at their discretion.
83/// - Clients that have no cached entry for `session` MAY ignore the
84/// notification; it is not a substitute for `root/sessionAdded`.
85#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
86#[serde(rename_all = "camelCase")]
87pub struct SessionSummaryChangedParams {
88 /// Channel URI this notification belongs to (the root channel)
89 pub channel: Uri,
90 /// URI of the session whose summary changed
91 pub session: Uri,
92 /// Mutable summary fields that changed; omitted fields are unchanged.
93 ///
94 /// Identity fields (`resource`, `provider`, `createdAt`) never change and
95 /// MUST be omitted by senders; receivers SHOULD ignore them if present.
96 pub changes: PartialSessionSummary,
97}
98
99/// Generic progress notification for a long-running operation.
100///
101/// A client opts in to progress for a request by including a `progressToken` in
102/// that request (today: the `progressToken` field on `createSession`). If the
103/// server does long-running work to service the request — e.g. lazily
104/// downloading an agent's native SDK the first time a session of that provider
105/// is materialized — it emits `progress` notifications carrying the same token.
106///
107/// The notification is operation-agnostic: it says nothing about *what* is
108/// progressing. The client correlates `progressToken` back to the request it
109/// originated from (and thus the UI surface awaiting it) and renders its own
110/// localized indicator. The same channel serves any future long-running
111/// operation without a new method.
112///
113/// Semantics:
114///
115/// - `progress` is monotonically non-decreasing for a given `progressToken`.
116/// - `total` is present only when the server knows the magnitude up front
117/// (e.g. a `Content-Length`); when absent the client SHOULD show an
118/// indeterminate indicator.
119/// - The operation is complete when `progress === total`. The server MUST emit a
120/// final frame satisfying `progress === total`; when the total was never
121/// known, it sets `total` to the final `progress` on that frame. No further
122/// frames reference the token afterwards.
123/// - The server MAY emit no progress at all (e.g. the work was already done);
124/// the client then never shows an indicator.
125/// - Like all notifications this is ephemeral and is **not** replayed on
126/// reconnect. A client that never receives the terminal frame SHOULD expire
127/// the indicator after an idle timeout.
128#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
129#[serde(rename_all = "camelCase")]
130pub struct ProgressParams {
131 /// Channel URI this notification belongs to (the root channel).
132 pub channel: Uri,
133 /// Echoes the `progressToken` the client supplied on the originating request
134 /// (e.g. the `progressToken` field of `createSession`), correlating this frame
135 /// to that call. Unique across the client's active requests.
136 pub progress_token: String,
137 /// Progress so far, in operation-defined units (e.g. bytes received).
138 /// Monotonically non-decreasing for a given `progressToken`.
139 pub progress: i64,
140 /// Total when known up front (e.g. from a `Content-Length`); omitted ⇒
141 /// indeterminate. The operation is complete once `progress === total`.
142 #[serde(default, skip_serializing_if = "Option::is_none")]
143 pub total: Option<i64>,
144 /// Optional human-readable progress message. The client owns its own
145 /// (localized) presentation derived from the originating request; generic
146 /// clients that don't track the token MAY display this instead.
147 #[serde(default, skip_serializing_if = "Option::is_none")]
148 pub message: Option<String>,
149}
150
151/// Sent by the server when a protected resource requires (re-)authentication.
152///
153/// This notification MAY be associated with any channel — for example, an
154/// agent advertised on the root channel, or a per-session resource. The
155/// `channel` field identifies the subscription the auth requirement belongs
156/// to; the `resource` field carries the OAuth-protected resource identifier
157/// (per RFC 9728).
158///
159/// Clients should obtain a fresh token and push it via the `authenticate`
160/// command.
161#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
162#[serde(rename_all = "camelCase")]
163pub struct AuthRequiredParams {
164 /// Channel URI this notification belongs to
165 pub channel: Uri,
166 /// The protected resource identifier that requires authentication
167 pub resource: String,
168 /// Why authentication is required
169 #[serde(default, skip_serializing_if = "Option::is_none")]
170 pub reason: Option<AuthRequiredReason>,
171}
172
173/// Delivers a batch of OTLP log records to a client subscribed to the host's
174/// logs channel (advertised on `TelemetryCapabilities.logs`).
175///
176/// The `payload` field is an OTLP/JSON `ExportLogsServiceRequest` value
177/// verbatim — i.e. an object of shape `{ resourceLogs: ResourceLogs[] }` as
178/// defined by [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/logs/v1/logs_service.proto).
179/// AHP does not redeclare the OTLP type system; clients SHOULD use an
180/// OpenTelemetry SDK or schema to parse it.
181///
182/// Like all stateless-channel notifications, this is ephemeral: it is not
183/// replayed on reconnect. Subscribers receive only batches emitted after
184/// their `subscribe` succeeds.
185#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
186#[serde(rename_all = "camelCase")]
187pub struct OtlpExportLogsParams {
188 /// Channel URI this notification belongs to (an `ahp-otlp:` URI advertised on `TelemetryCapabilities.logs`).
189 pub channel: Uri,
190 /// OTLP/JSON `ExportLogsServiceRequest` value. The top-level field is
191 /// `resourceLogs: ResourceLogs[]`; nested shapes are defined by
192 /// opentelemetry-proto and are not redeclared here.
193 pub payload: JsonObject,
194}
195
196/// Delivers a batch of OTLP spans to a client subscribed to the host's
197/// traces channel (advertised on `TelemetryCapabilities.traces`).
198///
199/// The `payload` field is an OTLP/JSON `ExportTraceServiceRequest` value
200/// verbatim — i.e. an object of shape `{ resourceSpans: ResourceSpans[] }`
201/// as defined by [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/trace/v1/trace_service.proto).
202#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
203#[serde(rename_all = "camelCase")]
204pub struct OtlpExportTracesParams {
205 /// Channel URI this notification belongs to (an `ahp-otlp:` URI advertised on `TelemetryCapabilities.traces`).
206 pub channel: Uri,
207 /// OTLP/JSON `ExportTraceServiceRequest` value. The top-level field is
208 /// `resourceSpans: ResourceSpans[]`; nested shapes are defined by
209 /// opentelemetry-proto and are not redeclared here.
210 pub payload: JsonObject,
211}
212
213/// Delivers a batch of OTLP metric data points to a client subscribed to
214/// the host's metrics channel (advertised on `TelemetryCapabilities.metrics`).
215///
216/// The `payload` field is an OTLP/JSON `ExportMetricsServiceRequest` value
217/// verbatim — i.e. an object of shape `{ resourceMetrics: ResourceMetrics[] }`
218/// as defined by [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/metrics/v1/metrics_service.proto).
219#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
220#[serde(rename_all = "camelCase")]
221pub struct OtlpExportMetricsParams {
222 /// Channel URI this notification belongs to (an `ahp-otlp:` URI advertised on `TelemetryCapabilities.metrics`).
223 pub channel: Uri,
224 /// OTLP/JSON `ExportMetricsServiceRequest` value. The top-level field is
225 /// `resourceMetrics: ResourceMetrics[]`; nested shapes are defined by
226 /// opentelemetry-proto and are not redeclared here.
227 pub payload: JsonObject,
228}
229
230// ─── Partial Summaries ────────────────────────────────────────────────
231
232/// Partial equivalent of SessionSummary — every field is optional for delta updates.
233#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
234#[serde(rename_all = "camelCase")]
235pub struct PartialSessionSummary {
236 /// Agent provider ID
237 #[serde(default, skip_serializing_if = "Option::is_none")]
238 pub provider: Option<String>,
239 /// Session title
240 #[serde(default, skip_serializing_if = "Option::is_none")]
241 pub title: Option<String>,
242 /// Current session status
243 #[serde(default, skip_serializing_if = "Option::is_none")]
244 pub status: Option<u32>,
245 /// Human-readable description of what the session is currently doing
246 #[serde(default, skip_serializing_if = "Option::is_none")]
247 pub activity: Option<String>,
248 /// Server-owned project for this session
249 #[serde(default, skip_serializing_if = "Option::is_none")]
250 pub project: Option<ProjectInfo>,
251 /// The default working directory URI for this session. Individual chats
252 /// MAY override via {@link ChatSummary.workingDirectory | their own
253 /// `workingDirectory`}; this field acts as the fallback for any chat that
254 /// does not.
255 #[serde(default, skip_serializing_if = "Option::is_none")]
256 pub working_directory: Option<Uri>,
257 /// Lightweight summary of this session's inline annotations channel
258 /// (`ahp-session:/<uuid>/annotations`). Surfaced so badge UI can render
259 /// annotation / entry counts without subscribing. Absent when the session
260 /// does not expose an annotations channel.
261 #[serde(default, skip_serializing_if = "Option::is_none")]
262 pub annotations: Option<AnnotationsSummary>,
263 /// Session URI
264 #[serde(default, skip_serializing_if = "Option::is_none")]
265 pub resource: Option<Uri>,
266 /// Creation timestamp (ISO 8601, e.g. `"2025-03-10T18:42:03.123Z"`)
267 #[serde(default, skip_serializing_if = "Option::is_none")]
268 pub created_at: Option<String>,
269 /// Last modification timestamp (ISO 8601, e.g. `"2025-03-10T18:42:03.123Z"`)
270 #[serde(default, skip_serializing_if = "Option::is_none")]
271 pub modified_at: Option<String>,
272 /// Aggregate summary of file changes associated with this session. Servers
273 /// may populate this to give clients a quick at-a-glance view of the
274 /// session's footprint (e.g., for list rendering) without requiring the
275 /// client to subscribe to a changeset.
276 #[serde(default, skip_serializing_if = "Option::is_none")]
277 pub changes: Option<ChangesSummary>,
278 /// Lightweight server-defined metadata clients may use for the session
279 /// presentation. The protocol does not interpret these values; producers
280 /// SHOULD keep the payload small because summaries appear in session lists
281 /// and session notifications.
282 #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
283 pub meta: Option<JsonObject>,
284}