Skip to main content

agentmux_srv_core/backend/
jekt_held_summary.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! What srv says about the messages it holds for agents (`server::jekt_held_summary`): per agent, how many and why,
5//! as the `jekt.held.summary` answer, and the `jektheld` event that tells a window the answer changed. Counts and reasons
6//! only: no message body, no sender and no message id leave the hold table.
7
8use serde::Serialize;
9
10/// The event published when the held counts change. A signal, carrying only the totals: a window reads
11/// `jekt.held.summary` for who and why.
12pub const EVENT_JEKT_HELD: &str = "jektheld";
13
14/// Why an agent's messages are held, in the words the hold answer uses (`held_reason`).
15pub const REASON_NOT_RUNNING: &str = "not_running";
16pub const REASON_STARTING: &str = "starting";
17pub const REASON_NEEDS_LOGIN: &str = "needs_login";
18pub const REASON_USAGE_LIMIT: &str = "usage_limit";
19
20/// One agent's held messages for one reason.
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, ts_rs::TS)]
22#[ts(export, export_to = "../../../frontend/types/rpc/")]
23pub struct JektHeldAgent {
24    /// The agent's UID: `AgentRuntime.agent_id`.
25    pub agent_id: String,
26    pub agent_name: String,
27    /// `not_running`, `starting`, `needs_login`, `usage_limit`, `idle`, `quota` or `peer_offline`.
28    pub reason: String,
29    #[ts(type = "number")]
30    pub count: u32,
31    /// When the oldest of them was sent (unix ms).
32    #[ts(type = "number")]
33    pub since_ms: u64,
34}
35
36/// `jekt.held.summary`: the held messages, by agent and reason, the agent with the oldest message first.
37#[derive(Debug, Clone, PartialEq, Eq, Serialize, ts_rs::TS)]
38#[ts(export, export_to = "../../../frontend/types/rpc/")]
39pub struct JektHeldSummaryResult {
40    pub agents: Vec<JektHeldAgent>,
41}
42
43/// `jektheld`: the held counts changed.
44#[derive(Debug, Clone, PartialEq, Eq, Serialize, ts_rs::TS)]
45#[ts(export, export_to = "../../../frontend/types/rpc/")]
46pub struct JektHeldEvent {
47    /// Messages held in all.
48    #[ts(type = "number")]
49    pub messages: u32,
50    /// Agents that have any.
51    #[ts(type = "number")]
52    pub agents: u32,
53}