-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathturn.go
More file actions
56 lines (45 loc) · 1.96 KB
/
turn.go
File metadata and controls
56 lines (45 loc) · 1.96 KB
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
package slagent
// Turn streams one agent response turn to a Slack thread.
type Turn interface {
// Thinking appends thinking/reasoning content.
Thinking(text string)
// Tool reports tool activity. Status: "running", "done", "error".
Tool(id, name, status, detail string)
// Text appends response text (markdown).
Text(text string)
// Status shows a transient status line.
Status(text string)
// MarkQuestion marks this turn as a question. The prefix is prepended
// and trailing "?" is replaced with " ❓" on finish.
MarkQuestion(prefix string)
// DeleteActivity deletes the activity message (thinking + tools).
DeleteActivity()
// SetPlainText toggles plain text mode. When on, text is posted as a code
// block instead of being converted to Slack mrkdwn (e.g. for plan output).
SetPlainText(on bool)
// Finish finalizes the turn. Must be called exactly once.
Finish() error
}
// turnWriter is the internal interface that backends implement.
type turnWriter interface {
writeText(text string)
writeThinking(text string)
writeTool(id, name, status, detail string)
writeStatus(text string)
markQuestion(prefix string)
deleteActivity()
setPlainText(on bool)
finish() error
}
// turnImpl wraps a turnWriter to implement Turn.
type turnImpl struct {
w turnWriter
}
func (t *turnImpl) Thinking(text string) { t.w.writeThinking(text) }
func (t *turnImpl) Tool(id, name, status, detail string) { t.w.writeTool(id, name, status, detail) }
func (t *turnImpl) Text(text string) { t.w.writeText(text) }
func (t *turnImpl) Status(text string) { t.w.writeStatus(text) }
func (t *turnImpl) MarkQuestion(prefix string) { t.w.markQuestion(prefix) }
func (t *turnImpl) DeleteActivity() { t.w.deleteActivity() }
func (t *turnImpl) SetPlainText(on bool) { t.w.setPlainText(on) }
func (t *turnImpl) Finish() error { return t.w.finish() }