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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! Event names and payloads emitted to the webview.
use EngineStatus;
use ;
/// Emitted whenever the engine's lifecycle status changes.
///
/// The name matches what the existing applications already emit, so adopting
/// Ed needs no frontend change.
pub const EVENT_CHAT_STATUS_CHANGED: &str = "chat_status_changed";
/// Emitted once an inference turn completes, successfully or not.
pub const EVENT_CHAT_REPLY: &str = "chat_reply";
/// Emitted with a [`ToolCall`](ed_agent::ToolCall) when the model asks for a
/// tool, before any approval or execution.
pub const EVENT_CHAT_TOOL_REQUESTED: &str = "chat_tool_requested";
/// Emitted with an [`ApprovalRequest`](ed_agent::ApprovalRequest) when a
/// mutating tool is waiting on the user.
///
/// This is a notification, not the approval itself. Ed asks the
/// [`ApprovalHandler`](ed_agent::ApprovalHandler) the host passed to
/// [`Ed::with_agent`](ed_agent::Ed::with_agent) for the decision; this event
/// exists so the webview can put a sheet on screen while that call is pending.
pub const EVENT_CHAT_APPROVAL_REQUESTED: &str = "chat_approval_requested";
/// Emitted with a [`ToolCall`](ed_agent::ToolCall) once a tool is approved and
/// about to run.
pub const EVENT_CHAT_TOOL_STARTED: &str = "chat_tool_started";
/// Emitted with a [`ToolExecutionResult`](ed_agent::ToolExecutionResult) when a
/// tool finishes, whether it succeeded or failed.
pub const EVENT_CHAT_TOOL_FINISHED: &str = "chat_tool_finished";
/// Emitted with an [`AgentReply`](ed_agent::AgentReply) when a full agent turn
/// completes.
///
/// Distinct from [`EVENT_CHAT_REPLY`], which covers the single-shot
/// [`Ed::send`](ed_agent::Ed::send) path. A turn reports one or the other,
/// never both.
pub const EVENT_CHAT_AGENT_REPLY: &str = "chat_agent_reply";
/// Emitted with a string when Ed has something the user should see but the turn
/// is still viable, such as an unverified model or a spent tool-round budget.
pub const EVENT_CHAT_WARNING: &str = "chat_warning";
/// Emitted with a [`TextDeltaPayload`] for each piece of a reply as it is
/// generated. Concatenate the deltas of one `id` to grow the assistant bubble;
/// [`EVENT_CHAT_REPLY`] still arrives at the end with the whole text.
pub const EVENT_CHAT_TEXT_DELTA: &str = "chat_text_delta";
/// Emitted with an [`ApprovalResolvedPayload`] once an approval request has
/// been answered, timed out, or cancelled, so the webview can close its sheet.
pub const EVENT_CHAT_APPROVAL_RESOLVED: &str = "chat_approval_resolved";
/// Payload for [`EVENT_CHAT_TEXT_DELTA`].
///
/// `session` and `id` are empty when the turn didn't come through a `submit`
/// call, which is the only thing that knows them.
/// Payload for [`EVENT_CHAT_REPLY`] when the turn came through `submit`.
///
/// A superset of [`ChatReply`](ed_agent::ChatReply), so a listener written for
/// the single-session event keeps working.
/// Payload for [`EVENT_CHAT_APPROVAL_REQUESTED`] when the approval handler is
/// [`TauriApprovals`](crate::TauriApprovals). Answer it with
/// `chat_respond_approval { request_id, decision }`.
/// Payload for [`EVENT_CHAT_APPROVAL_RESOLVED`].
/// Payload for [`EVENT_CHAT_STATUS_CHANGED`].
///
/// `status` serialises to `"unloaded"`, `"loading"`, `"ready"`, `"generating"`,
/// or `"error"` — [`EngineStatus`] is `#[serde(rename_all = "snake_case")]`,
/// which is the same set of strings applications were previously declaring as
/// their own constants.