resume active sessions

This commit is contained in:
ari committed 2026-11-01 15:52:46 -05:00
1 parent 9e94c05fb6
commit 917a361370
19 files changed
+871 -42

No files matched your search

+27
View File
@@ -71,6 +71,33 @@ type Session struct {
Listen ListenMode `json:"listen,omitempty"`
}
// Turn is a reply the bot is still working on, kept so it can carry on after a restart.
type Turn struct {
Channel string `json:"channel"`
ThreadTS string `json:"thread_ts"`
MessageTS string `json:"message_ts"`
ReplyTS string `json:"reply_ts"`
User string `json:"user"`
OwnerID string `json:"owner_id"`
DM bool `json:"dm,omitempty"`
Heard bool `json:"heard,omitempty"`
Text string `json:"text"`
Files []TurnFile `json:"files,omitempty"`
// The agent got the prompt, so the session already holds part of the turn.
Prompted bool `json:"prompted,omitempty"`
Resumes int `json:"resumes,omitempty"`
StartedAt time.Time `json:"started_at"`
}
type TurnFile struct {
Name string `json:"name"`
Mode string `json:"mode,omitempty"`
URL string `json:"url"`
Size int `json:"size"`
}
// Whether the bot reads every reply in a channel thread, or only ones that
// @mention it. DMs always read everything.
type ListenMode string
+7
View File
@@ -124,6 +124,13 @@ func (p PermissionsConfig) Allowed(kind OwnerKind, channel, user string, a Actio
func (p PermissionsConfig) IsManager(user string) bool { return slices.Contains(p.Managers, user) }
// A super user is anyone on the list that applies to the channel, with any permission.
// DM channels have no list of their own, so the default list applies.
func (p PermissionsConfig) IsSuperUser(channel, user string) bool {
list, _ := p.SuperUsers(channel)
return p.IsManager(user) || len(list[user]) > 0
}
func (p PermissionsConfig) CanManage(channel, user string) bool {
return p.IsManager(user) || p.Allowed(OwnerChannel, channel, user, ActManage)
}