1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use crate::config::Provider;
use tokio::sync::mpsc;
/// Third-party persona pack (Justin, Nicole, Kaan, Tyler, Elliot, Bri) — not authored or hosted by
/// this project. Named here, rather than only where it's fetched, so the UI's confirmation prompt
/// and the agent task's download both show the same URL by construction.
pub const STELLAR_BUILD_INSTALL_URL: &str =
"https://raw.githubusercontent.com/kaankacar/stellar-build/main/install.sh";
#[derive(Debug)]
pub enum UserCommand {
SendPrompt(String),
Quit,
SetExplain(bool),
// Sent once project switching is wired to a command (Sprint 2.1).
#[allow(dead_code)]
ChangeProject(String),
SwitchModel {
provider: Provider,
model: String,
},
/// Runs the third-party Stellar Build installer after the user has explicitly confirmed it.
/// Routed through the agent task rather than handled in the UI thread: it downloads a script
/// and runs it, which can take a while and must not freeze rendering or key handling.
InstallStellarBuild,
}
#[derive(Debug, Clone)]
pub struct McpServerStatus {
pub name: String,
pub connected: bool,
pub detail: String,
}
#[derive(Debug, Clone)]
pub struct WorkspaceSnapshot {
pub project_name: String,
pub contract_name: Option<String>,
pub network: String,
pub account: String,
pub mcp_servers: Vec<McpServerStatus>,
}
#[allow(dead_code)]
#[derive(Debug)]
pub enum AgentUpdate {
ResponseChunk(String),
ResponseEnd,
Status(String),
/// A plain notice addressed to the user, with none of `Status`'s side effects — it does not
/// flip the app to Working or open an execution step. Boot-time announcements used `Status`
/// and so made a freshly launched, idle session render as a running turn.
Notice(String),
Error(String),
/// Which provider and model the agent actually holds, and whether a credential resolved for
/// them. The UI used to keep its own optimistic copy, which drifted from the agent the moment
/// a switch failed — or the moment the agent stopped existing.
Ready {
provider: String,
model: String,
credential: bool,
},
/// Structured workspace snapshot — lets the Context panel show Project/Contract/Network
/// without parsing free-form Status strings.
Workspace(WorkspaceSnapshot),
McpStatus(Vec<McpServerStatus>),
}
pub struct Channels {
pub user_tx: mpsc::UnboundedSender<UserCommand>,
pub user_rx: mpsc::UnboundedReceiver<UserCommand>,
pub agent_tx: mpsc::UnboundedSender<AgentUpdate>,
pub agent_rx: mpsc::UnboundedReceiver<AgentUpdate>,
}
impl Channels {
pub fn new() -> Self {
let (user_tx, user_rx) = mpsc::unbounded_channel();
let (agent_tx, agent_rx) = mpsc::unbounded_channel();
Self {
user_tx,
user_rx,
agent_tx,
agent_rx,
}
}
}