Skip to main content

agentmux_srv_core/backend/
install_events.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! The `install_chunk` event an install publishes (`server/install_task.rs`,
5//! `server/system_install_handlers.rs`), kept below the server so `mps_events` can name it.
6
7use serde::Serialize;
8
9/// `install_chunk`: one line of an install's output, or its end. Scoped `install:<sessionId>`;
10/// `system.install` sends the same events.
11#[derive(Debug, Clone, Serialize, ts_rs::TS)]
12#[ts(export, export_to = "../../../frontend/types/rpc/")]
13#[serde(untagged)]
14pub enum InstallChunkEvent {
15    Line {
16        #[serde(rename = "sessionId")]
17        session_id: String,
18        line: String,
19        stream: InstallStream,
20    },
21    Done {
22        #[serde(rename = "sessionId")]
23        session_id: String,
24        op: InstallDoneOp,
25        ok: bool,
26        /// Why it failed: a message, or an `AgentMuxError` in its wire form. `null` when it didn't.
27        #[ts(type = "unknown")]
28        error: serde_json::Value,
29    },
30}
31
32impl InstallChunkEvent {
33    pub fn line(session_id: &str, line: String, stream: InstallStream) -> Self {
34        Self::Line { session_id: session_id.to_string(), line, stream }
35    }
36    pub fn done(session_id: &str, ok: bool, error: serde_json::Value) -> Self {
37        Self::Done { session_id: session_id.to_string(), op: InstallDoneOp::Done, ok, error }
38    }
39}
40
41#[derive(Debug, Clone, Copy, Serialize, ts_rs::TS)]
42#[ts(export, export_to = "../../../frontend/types/rpc/")]
43#[serde(rename_all = "lowercase")]
44pub enum InstallStream {
45    Stdout,
46    Stderr,
47}
48
49/// The `op` of the last event of an install.
50#[derive(Debug, Clone, Copy, Serialize, ts_rs::TS)]
51#[ts(export, export_to = "../../../frontend/types/rpc/")]
52#[serde(rename_all = "lowercase")]
53pub enum InstallDoneOp {
54    Done,
55}