Skip to main content

acp_cli/bridge/
events.rs

1use tokio::sync::oneshot;
2
3#[derive(Debug, Clone)]
4pub struct PromptResult {
5    pub content: String,
6    pub stop_reason: String,
7}
8
9#[derive(Debug, Clone)]
10pub struct ToolCallInfo {
11    pub name: String,
12    pub description: Option<String>,
13}
14
15#[derive(Debug, Clone)]
16pub struct PermissionOption {
17    pub option_id: String,
18    pub name: String,
19    pub kind: PermissionKind,
20}
21
22#[derive(Debug, Clone, PartialEq)]
23pub enum PermissionKind {
24    Allow,
25    Deny,
26}
27
28#[derive(Debug)]
29pub enum PermissionOutcome {
30    Selected { option_id: String },
31    Cancelled,
32}
33
34pub enum BridgeEvent {
35    TextChunk {
36        text: String,
37    },
38    ToolUse {
39        name: String,
40    },
41    /// Emitted when a tool call completes and returns output.
42    /// `is_read` is true when the tool's kind is `ToolKind::Read` (file read).
43    ToolResult {
44        name: String,
45        output: String,
46        is_read: bool,
47    },
48    PermissionRequest {
49        tool: ToolCallInfo,
50        options: Vec<PermissionOption>,
51        reply: oneshot::Sender<PermissionOutcome>,
52    },
53    SessionCreated {
54        session_id: String,
55    },
56    PromptDone {
57        stop_reason: String,
58    },
59    Error {
60        message: String,
61    },
62    AgentExited {
63        code: Option<i32>,
64    },
65}