v0.9.2 49bea57

events.go RawHistoryFolder

1package core
2
3import (
4	"encoding/json"
5	"time"
6
7	"github.com/bnema/zut/packages/provider"
8)
9
10// AgentEvent is the superset of events emitted by an Agent run.
11// Consumers discriminate via a type switch. Each concrete type has a
12// Type() method for JSON serialization.
13type AgentEvent interface {
14	Type() string
15}
16
17type EvTurnStart struct {
18	Step int
19}
20
21func (EvTurnStart) Type() string { return "turn_start" }
22
23type EvUserMessage struct {
24	Message provider.Message
25}
26
27func (EvUserMessage) Type() string { return "user_message" }
28
29type EvAssistantStart struct{}
30
31func (EvAssistantStart) Type() string { return "assistant_start" }
32
33// RetryScope identifies the retry layer that issued an activity event.
34type RetryScope string
35
36const (
37	RetryScopeProvider RetryScope = "provider"
38	RetryScopeAgent    RetryScope = "agent"
39)
40
41// EvRequestStarted reports an outbound provider request attempt.
42type EvRequestStarted struct {
43	Provider    string
44	Model       string
45	Scope       RetryScope
46	Attempt     int
47	MaxAttempts int
48}
49
50func (EvRequestStarted) Type() string { return "request_started" }
51
52// EvRetryScheduled reports a retry delay before its upcoming attempt.
53type EvRetryScheduled struct {
54	Scope       RetryScope
55	Attempt     int
56	MaxAttempts int
57	Delay       time.Duration
58}
59
60func (EvRetryScheduled) Type() string { return "retry_scheduled" }
61
62type EvTextDelta struct {
63	Delta string
64}
65
66func (EvTextDelta) Type() string { return "text_delta" }
67
68type EvToolCall struct {
69	ID   string
70	Name string
71	Args json.RawMessage
72}
73
74func (EvToolCall) Type() string { return "tool_call" }
75
76// EvToolExecutionStarted fires after guards and confirmation allow a call,
77// immediately before the tool starts executing.
78type EvToolExecutionStarted struct {
79	ID   string
80	Name string
81}
82
83func (EvToolExecutionStarted) Type() string { return "tool_execution_started" }
84
85// EvToolUseStart fires the moment the provider announces a new
86// tool_use block during streaming, before any arg JSON has
87// arrived. Gives UIs a hook to pre-render a live "tool is being
88// composed" panel so the user sees the model typing the call in
89// real time. Name is already final at this point; Args is empty.
90type EvToolUseStart struct {
91	ID   string
92	Name string
93}
94
95func (EvToolUseStart) Type() string { return "tool_use_start" }
96
97// EvToolUseArgs fires for each delta fragment of the tool_use
98// block's argument JSON. Concatenating every delta for a given
99// ID produces the full JSON string; during streaming it's likely
100// truncated mid-value. UIs can extract partial string fields
101// (e.g. the `content` arg of `write`) with an escape-aware scan.
102type EvToolUseArgs struct {
103	ID    string
104	Delta string
105}
106
107func (EvToolUseArgs) Type() string { return "tool_use_args" }
108
109// EvToolUseEnd fires when the provider marks the tool_use block
110// complete. At this point the full args JSON is known; a separate
111// EvToolCall follows once the assistant message is assembled,
112// carrying the parsed block that actually runs.
113type EvToolUseEnd struct {
114	ID string
115}
116
117func (EvToolUseEnd) Type() string { return "tool_use_end" }
118
119type EvToolProgress struct {
120	ID   string
121	Text string
122}
123
124func (EvToolProgress) Type() string { return "tool_progress" }
125
126type EvToolResult struct {
127	ID     string
128	Result ToolResult
129}
130
131func (EvToolResult) Type() string { return "tool_result" }
132
133type EvUsage struct {
134	Usage      provider.Usage
135	Cumulative provider.Usage
136}
137
138func (EvUsage) Type() string { return "usage" }
139
140type EvAssistantMessage struct {
141	Message provider.Message
142}
143
144func (EvAssistantMessage) Type() string { return "assistant_message" }
145
146type EvTurnEnd struct {
147	Stop provider.StopReason
148	Err  error
149}
150
151func (EvTurnEnd) Type() string { return "turn_end" }
152
153type EvDone struct{}
154
155func (EvDone) Type() string { return "done" }
156
157type EvError struct {
158	Err error
159}
160
161func (EvError) Type() string { return "error" }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close