bazel start + mcp start

This commit is contained in:
ari committed 2026-11-01 14:55:33 -05:00
1 parent a90653260a
commit 4c082aca7c
33 files changed
+1728 -79

No files matched your search

+28 -8
View File
@@ -27,6 +27,7 @@ import (
"slackerbot/internal/node"
"slackerbot/internal/state"
"slackerbot/internal/storage"
"slackerbot/internal/tools"
"slackerbot/internal/units"
"slackerbot/internal/util"
)
@@ -84,6 +85,7 @@ type incoming struct {
user, channel, ts, threadTS, text string
dm bool
heard bool
files []slack.File
}
func (m incoming) owner() (string, model.OwnerKind) {
@@ -152,17 +154,17 @@ func (b *Bot) onEvent(ctx context.Context, ev slackevents.EventsAPIEvent) {
if e.BotID != "" {
return
}
b.onMessage(ctx, incoming{e.User, e.Channel, e.TimeStamp, e.ThreadTimeStamp, b.stripMention(e.Text), false, false})
b.onMessage(ctx, incoming{e.User, e.Channel, e.TimeStamp, e.ThreadTimeStamp, b.stripMention(e.Text), false, false, eventFiles(ev)})
case *slackevents.MessageEvent:
if e.BotID != "" || e.SubType != "" || e.User == "" || e.User == b.botID {
if e.BotID != "" || (e.SubType != "" && e.SubType != "file_share") || e.User == "" || e.User == b.botID {
return
}
text := b.stripMention(e.Text)
switch {
case e.ChannelType == "im":
b.onMessage(ctx, incoming{e.User, e.Channel, e.TimeStamp, e.ThreadTimeStamp, text, true, false})
b.onMessage(ctx, incoming{e.User, e.Channel, e.TimeStamp, e.ThreadTimeStamp, text, true, false, eventFiles(ev)})
case b.listening(e.Channel, e.ThreadTimeStamp, e.Text):
b.onMessage(ctx, incoming{e.User, e.Channel, e.TimeStamp, e.ThreadTimeStamp, text, false, true})
b.onMessage(ctx, incoming{e.User, e.Channel, e.TimeStamp, e.ThreadTimeStamp, text, false, true, eventFiles(ev)})
}
case *slackevents.ReactionAddedEvent:
b.onReaction(e)
@@ -178,15 +180,17 @@ func (b *Bot) stripMention(text string) string {
}
func (b *Bot) onMessage(ctx context.Context, m incoming) {
if b.listenCommand(ctx, m) {
// A message with files always goes to the agent, so a file with no text isn't read as `help`.
commandable := len(m.files) == 0
if commandable && b.listenCommand(ctx, m) {
return
}
// Every assistant-pane chat is a DM thread, so its first message counts as new.
fresh := m.threadTS == "" || m.dm && b.store.Session(m.channel, m.threadTS) == nil
if fresh && b.command(ctx, m) {
if commandable && fresh && b.command(ctx, m) {
return
}
if m.threadTS != "" && !m.heard && b.moveCommand(ctx, m, m.threadTS) {
if commandable && m.threadTS != "" && !m.heard && b.moveCommand(ctx, m, m.threadTS) {
return
}
root := m.threadTS
@@ -297,6 +301,16 @@ func (b *Bot) onMessage(ctx context.Context, m incoming) {
if m.dm {
text = b.viewingNote(ctx, m.channel, root) + text
}
if len(m.files) > 0 {
edit(":paperclip: Copying the attachments into the container…")
note, problems := b.attach(ctx, u, m)
if note != "" {
text += "\n" + note
}
if len(problems) > 0 {
b.say(ctx, m.channel, root, ":warning: "+strings.Join(problems, "\n"))
}
}
edit("_working…_")
pctx, cancel := context.WithCancel(ctx)
@@ -311,11 +325,16 @@ func (b *Bot) onMessage(ctx context.Context, m incoming) {
defer b.setAssistantStatus(ctx, m.channel, root, "")
}
st := NewStreamer(b.api, m.channel, root, ph)
stop, err := acp.Prompt(pctx, id, text, st.Update)
var sends tools.Calls
stop, err := acp.Prompt(pctx, id, text, func(up acpUpdate) {
sends.Update(up)
st.Update(up)
})
if pctx.Err() != nil && ctx.Err() == nil {
stop, err = "cancelled", nil
}
st.Finish(stop, err)
b.upload(ctx, u, m.channel, root, sends.Files())
_ = b.store.Touch(u.ID)
switch {
case stop == "cancelled":
@@ -1043,6 +1062,7 @@ func (b *Bot) client(ctx context.Context, u *model.Owner) (*acp.ACP, error) {
if c, err = acp.New(initCtx, conn); err != nil {
return nil, err
}
c.Servers = b.mcpServers()
b.acpMu.Lock()
b.acps[key] = c
b.acpMu.Unlock()