agentmux_srv_core/backend/
account_availability.rs1use std::sync::OnceLock;
10
11use serde::{Deserialize, Serialize};
12
13pub const EVENT_ACCOUNT_AVAILABILITY: &str = "accountavailability";
15
16#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ts_rs::TS)]
18#[ts(export, export_to = "../../../frontend/types/rpc/")]
19pub struct AccountEpisodeAgent {
20 pub block_id: String,
21 pub agent_id: String,
23 pub agent_name: String,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq, Serialize, ts_rs::TS)]
28#[ts(export, export_to = "../../../frontend/types/rpc/")]
29pub struct AccountEpisodeTask {
30 pub id: String,
31 #[ts(type = "number")]
32 pub number: i64,
33 pub task_ref: String,
35 pub title: String,
36}
37
38#[derive(Debug, Clone, PartialEq, Eq, Serialize, ts_rs::TS)]
43#[ts(export, export_to = "../../../frontend/types/rpc/")]
44pub struct AccountAvailabilityEvent {
45 pub account_id: String,
46 pub provider: String,
47 #[ts(type = r#""limited" | "signed_out" | "ok""#)]
48 pub state: String,
49 #[ts(type = "number | null")]
50 pub resets_at_ms: Option<u64>,
51 pub agents: Vec<AccountEpisodeAgent>,
52 pub tasks: Vec<AccountEpisodeTask>,
53}
54
55static COVERS_BLOCK: OnceLock<fn(&str) -> bool> = OnceLock::new();
56
57pub fn set_covers_block(f: fn(&str) -> bool) {
59 let _ = COVERS_BLOCK.set(f);
60}
61
62pub fn covers_block(block_id: &str) -> bool {
65 COVERS_BLOCK.get().is_some_and(|f| f(block_id))
66}