Bump Go dependencies in both backend/ and backend/_example/memory_store.
Notable updates:
- github.com/go-pkgz/lgr v0.12.1 -> v0.12.3
- github.com/klauspost/compress v1.18.2 -> v1.18.5
- github.com/PuerkitoBio/goquery v1.11.0 -> v1.12.0
- github.com/montanaflynn/stats v0.7.1 -> v0.9.0
- github.com/redis/go-redis/v9 v9.17.2 -> v9.18.0
- github.com/slack-go/slack v0.17.3 -> v0.21.1
- go.mongodb.org/mongo-driver v1.17.6 -> v1.17.9
- golang.org/x/crypto v0.48.0 -> v0.50.0
- golang.org/x/net v0.49.0 -> v0.53.0
- golang.org/x/image v0.36.0 -> v0.39.0
- golang.org/x/sys v0.41.0 -> v0.43.0
- golang.org/x/{oauth2,sync,text} minor bumps
Key markdown/sanitisation libs (bluemonday v1.0.27,
alecthomas/chroma/v2 v2.23.1, russross/blackfriday/v2 v2.1.0,
Depado/bfchroma/v2 v2.0.0) are already at the latest available
versions and were not bumped.
Verified the Chroma span-class allowlist regex in
backend/app/store/comment.go:128-131 is still fully in sync with
chroma/v2 types.go StandardTypes map (86 classes, byte-equal after
sorting). The inline comment references commit c263f6f which is
stale (Chroma is at v2 now), but the class list content is current.
Ran `go mod tidy` + `go mod vendor` + full race test suite on both
modules. All green. Added a reminder in CLAUDE.md that updating
backend/ Go modules also requires `go mod tidy` in
backend/_example/memory_store since the example module uses a
local replace directive and inherits indirect deps from the main
module.
263 lines
7.8 KiB
Go
263 lines
7.8 KiB
Go
package slack
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
// AssistantThreadSetStatusParameters are the parameters for AssistantThreadSetStatus
|
|
type AssistantThreadsSetStatusParameters struct {
|
|
ChannelID string `json:"channel_id"`
|
|
Status string `json:"status"`
|
|
ThreadTS string `json:"thread_ts"`
|
|
LoadingMessages []string `json:"loading_messages,omitempty"`
|
|
}
|
|
|
|
// AssistantThreadSetTitleParameters are the parameters for AssistantThreadSetTitle
|
|
type AssistantThreadsSetTitleParameters struct {
|
|
ChannelID string `json:"channel_id"`
|
|
ThreadTS string `json:"thread_ts"`
|
|
Title string `json:"title"`
|
|
}
|
|
|
|
// AssistantThreadSetSuggestedPromptsParameters are the parameters for AssistantThreadSetSuggestedPrompts
|
|
type AssistantThreadsSetSuggestedPromptsParameters struct {
|
|
Title string `json:"title"`
|
|
ChannelID string `json:"channel_id"`
|
|
ThreadTS string `json:"thread_ts"`
|
|
Prompts []AssistantThreadsPrompt `json:"prompts"`
|
|
}
|
|
|
|
// AssistantThreadPrompt is a suggested prompt for a thread
|
|
type AssistantThreadsPrompt struct {
|
|
Title string `json:"title"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// AssistantSearchContextParameters are the parameters for AssistantSearchContext
|
|
type AssistantSearchContextParameters struct {
|
|
Query string `json:"query"`
|
|
ActionToken string `json:"action_token,omitempty"`
|
|
ChannelTypes []string `json:"channel_types,omitempty"`
|
|
ContentTypes []string `json:"content_types,omitempty"`
|
|
ContextChannelID string `json:"context_channel_id,omitempty"`
|
|
Cursor string `json:"cursor,omitempty"`
|
|
IncludeBots bool `json:"include_bots,omitempty"`
|
|
Limit int `json:"limit,omitempty"`
|
|
}
|
|
|
|
// AssistantSearchContextMessage represents a search result message
|
|
type AssistantSearchContextMessage struct {
|
|
AuthorUserID string `json:"author_user_id"`
|
|
TeamID string `json:"team_id"`
|
|
ChannelID string `json:"channel_id"`
|
|
MessageTS string `json:"message_ts"`
|
|
Content string `json:"content"`
|
|
IsAuthorBot bool `json:"is_author_bot"`
|
|
Permalink string `json:"permalink"`
|
|
}
|
|
|
|
// AssistantSearchContextResults contains the search results
|
|
type AssistantSearchContextResults struct {
|
|
Messages []AssistantSearchContextMessage `json:"messages"`
|
|
}
|
|
|
|
// AssistantSearchContextResponse is the response from assistant.search.context
|
|
type AssistantSearchContextResponse struct {
|
|
SlackResponse
|
|
Results AssistantSearchContextResults `json:"results"`
|
|
ResponseMetadata struct {
|
|
NextCursor string `json:"next_cursor"`
|
|
} `json:"response_metadata"`
|
|
}
|
|
|
|
// AssistantThreadSetSuggestedPrompts sets the suggested prompts for a thread
|
|
func (p *AssistantThreadsSetSuggestedPromptsParameters) AddPrompt(title, message string) {
|
|
p.Prompts = append(p.Prompts, AssistantThreadsPrompt{
|
|
Title: title,
|
|
Message: message,
|
|
})
|
|
}
|
|
|
|
// SetAssistantThreadsSugesstedPrompts sets the suggested prompts for a thread
|
|
// @see https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
|
|
func (api *Client) SetAssistantThreadsSuggestedPrompts(params AssistantThreadsSetSuggestedPromptsParameters) (err error) {
|
|
return api.SetAssistantThreadsSuggestedPromptsContext(context.Background(), params)
|
|
}
|
|
|
|
// SetAssistantThreadSuggestedPromptsContext sets the suggested prompts for a thread with a custom context
|
|
// @see https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
|
|
func (api *Client) SetAssistantThreadsSuggestedPromptsContext(ctx context.Context, params AssistantThreadsSetSuggestedPromptsParameters) (err error) {
|
|
|
|
values := url.Values{
|
|
"token": {api.token},
|
|
}
|
|
|
|
if params.ThreadTS != "" {
|
|
values.Add("thread_ts", params.ThreadTS)
|
|
}
|
|
|
|
values.Add("channel_id", params.ChannelID)
|
|
|
|
if params.Title != "" {
|
|
values.Add("title", params.Title)
|
|
}
|
|
|
|
// Send Prompts as JSON
|
|
prompts, err := json.Marshal(params.Prompts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
values.Add("prompts", string(prompts))
|
|
|
|
response := struct {
|
|
SlackResponse
|
|
}{}
|
|
|
|
err = api.postMethod(ctx, "assistant.threads.setSuggestedPrompts", values, &response)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
return response.Err()
|
|
}
|
|
|
|
// SetAssistantThreadStatus sets the status of a thread
|
|
// @see https://api.slack.com/methods/assistant.threads.setStatus
|
|
func (api *Client) SetAssistantThreadsStatus(params AssistantThreadsSetStatusParameters) (err error) {
|
|
return api.SetAssistantThreadsStatusContext(context.Background(), params)
|
|
}
|
|
|
|
// SetAssistantThreadStatusContext sets the status of a thread with a custom context
|
|
// @see https://api.slack.com/methods/assistant.threads.setStatus
|
|
func (api *Client) SetAssistantThreadsStatusContext(ctx context.Context, params AssistantThreadsSetStatusParameters) (err error) {
|
|
|
|
values := url.Values{
|
|
"token": {api.token},
|
|
}
|
|
|
|
if params.ThreadTS != "" {
|
|
values.Add("thread_ts", params.ThreadTS)
|
|
}
|
|
|
|
values.Add("channel_id", params.ChannelID)
|
|
|
|
// Always send the status parameter, if empty, it will clear any existing status
|
|
values.Add("status", params.Status)
|
|
|
|
if len(params.LoadingMessages) > 0 {
|
|
values.Add("loading_messages", strings.Join(params.LoadingMessages, ","))
|
|
}
|
|
|
|
response := struct {
|
|
SlackResponse
|
|
}{}
|
|
|
|
err = api.postMethod(ctx, "assistant.threads.setStatus", values, &response)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
return response.Err()
|
|
}
|
|
|
|
// SetAssistantThreadsTitle sets the title of a thread
|
|
// @see https://api.slack.com/methods/assistant.threads.setTitle
|
|
func (api *Client) SetAssistantThreadsTitle(params AssistantThreadsSetTitleParameters) (err error) {
|
|
return api.SetAssistantThreadsTitleContext(context.Background(), params)
|
|
}
|
|
|
|
// SetAssistantThreadsTitleContext sets the title of a thread with a custom context
|
|
// @see https://api.slack.com/methods/assistant.threads.setTitle
|
|
func (api *Client) SetAssistantThreadsTitleContext(ctx context.Context, params AssistantThreadsSetTitleParameters) (err error) {
|
|
|
|
values := url.Values{
|
|
"token": {api.token},
|
|
}
|
|
|
|
if params.ChannelID != "" {
|
|
values.Add("channel_id", params.ChannelID)
|
|
}
|
|
|
|
if params.ThreadTS != "" {
|
|
values.Add("thread_ts", params.ThreadTS)
|
|
}
|
|
|
|
if params.Title != "" {
|
|
values.Add("title", params.Title)
|
|
}
|
|
|
|
response := struct {
|
|
SlackResponse
|
|
}{}
|
|
|
|
err = api.postMethod(ctx, "assistant.threads.setTitle", values, &response)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
return response.Err()
|
|
|
|
}
|
|
|
|
// SearchAssistantContext searches messages across the Slack organization
|
|
// @see https://api.slack.com/methods/assistant.search.context
|
|
func (api *Client) SearchAssistantContext(params AssistantSearchContextParameters) (*AssistantSearchContextResponse, error) {
|
|
return api.SearchAssistantContextContext(context.Background(), params)
|
|
}
|
|
|
|
// SearchAssistantContextContext searches messages across the Slack organization with a custom context
|
|
// @see https://api.slack.com/methods/assistant.search.context
|
|
func (api *Client) SearchAssistantContextContext(ctx context.Context, params AssistantSearchContextParameters) (*AssistantSearchContextResponse, error) {
|
|
values := url.Values{
|
|
"token": {api.token},
|
|
}
|
|
|
|
values.Add("query", params.Query)
|
|
|
|
if params.ActionToken != "" {
|
|
values.Add("action_token", params.ActionToken)
|
|
}
|
|
|
|
if len(params.ChannelTypes) > 0 {
|
|
for _, channelType := range params.ChannelTypes {
|
|
values.Add("channel_types", channelType)
|
|
}
|
|
}
|
|
|
|
if len(params.ContentTypes) > 0 {
|
|
for _, contentType := range params.ContentTypes {
|
|
values.Add("content_types", contentType)
|
|
}
|
|
}
|
|
|
|
if params.ContextChannelID != "" {
|
|
values.Add("context_channel_id", params.ContextChannelID)
|
|
}
|
|
|
|
if params.Cursor != "" {
|
|
values.Add("cursor", params.Cursor)
|
|
}
|
|
|
|
if params.IncludeBots {
|
|
values.Add("include_bots", "true")
|
|
}
|
|
|
|
if params.Limit > 0 {
|
|
values.Add("limit", strconv.Itoa(params.Limit))
|
|
}
|
|
|
|
response := &AssistantSearchContextResponse{}
|
|
|
|
err := api.postMethod(ctx, "assistant.search.context", values, response)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return response, response.Err()
|
|
}
|