chore(ui): Move some field definitions server side

This commit is contained in:
Richard Palethorpe
2025-03-26 15:56:14 +00:00
parent 7fb99ecf21
commit 319caf8e91
62 changed files with 1534 additions and 1574 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/bwmarrin/discordgo"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/core/types"
"github.com/mudler/LocalAgent/pkg/config"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/sashabaranov/go-openai"
)
@@ -34,6 +35,28 @@ func NewDiscord(config map[string]string) *Discord {
}
}
func DiscordConfigMeta() []config.Field {
return []config.Field{
{
Name: "token",
Label: "Discord Token",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "defaultChannel",
Label: "Default Channel",
Type: config.FieldTypeText,
},
{
Name: "lastMessageDuration",
Label: "Last Message Duration",
Type: config.FieldTypeText,
DefaultValue: "5m",
},
}
}
func (d *Discord) AgentResultCallback() func(state types.ActionState) {
return func(state types.ActionState) {
// Send the result to the bot

View File

@@ -8,6 +8,7 @@ import (
"github.com/google/go-github/v69/github"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/core/types"
"github.com/mudler/LocalAgent/pkg/config"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/sashabaranov/go-openai"
@@ -195,3 +196,39 @@ func (g *GithubIssues) issuesService() {
}
}
}
// GithubIssueConfigMeta returns the metadata for GitHub Issues connector configuration fields
func GithubIssueConfigMeta() []config.Field {
return []config.Field{
{
Name: "token",
Label: "GitHub Token",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "repository",
Label: "Repository",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "owner",
Label: "Owner",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "replyIfNoReplies",
Label: "Reply If No Replies",
Type: config.FieldTypeCheckbox,
},
{
Name: "pollInterval",
Label: "Poll Interval",
Type: config.FieldTypeText,
DefaultValue: "10m",
HelpText: "How often to check for new issues (e.g., 10m, 1h)",
},
}
}

View File

@@ -8,6 +8,7 @@ import (
"github.com/google/go-github/v69/github"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/core/types"
"github.com/mudler/LocalAgent/pkg/config"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/sashabaranov/go-openai"
@@ -195,3 +196,39 @@ func (g *GithubPRs) prService() {
}
}
}
// GithubPRConfigMeta returns the metadata for GitHub PR connector configuration fields
func GithubPRConfigMeta() []config.Field {
return []config.Field{
{
Name: "token",
Label: "GitHub Token",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "repository",
Label: "Repository",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "owner",
Label: "Owner",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "replyIfNoReplies",
Label: "Reply If No Replies",
Type: config.FieldTypeCheckbox,
},
{
Name: "pollInterval",
Label: "Poll Interval",
Type: config.FieldTypeText,
DefaultValue: "10m",
HelpText: "How often to check for new PRs (e.g., 10m, 1h)",
},
}
}

View File

@@ -7,6 +7,7 @@ import (
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/core/types"
"github.com/mudler/LocalAgent/pkg/config"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/mudler/LocalAgent/services/actions"
"github.com/sashabaranov/go-openai"
@@ -207,3 +208,44 @@ func (i *IRC) Start(a *agent.Agent) {
// Start the IRC client in a goroutine
go i.conn.Loop()
}
// IRCConfigMeta returns the metadata for IRC connector configuration fields
func IRCConfigMeta() []config.Field {
return []config.Field{
{
Name: "server",
Label: "IRC Server",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "port",
Label: "Port",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "nickname",
Label: "Nickname",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "channel",
Label: "Channel",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "alwaysReply",
Label: "Always Reply",
Type: config.FieldTypeCheckbox,
},
{
Name: "lastMessageDuration",
Label: "Last Message Duration",
Type: config.FieldTypeText,
DefaultValue: "5m",
},
}
}

View File

@@ -10,6 +10,7 @@ import (
"sync"
"time"
"github.com/mudler/LocalAgent/pkg/config"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/mudler/LocalAgent/pkg/xstrings"
"github.com/mudler/LocalAgent/services/actions"
@@ -784,3 +785,37 @@ func (t *Slack) Start(a *agent.Agent) {
client.RunContext(a.Context())
}
// SlackConfigMeta returns the metadata for Slack connector configuration fields
func SlackConfigMeta() []config.Field {
return []config.Field{
{
Name: "appToken",
Label: "App Token",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "botToken",
Label: "Bot Token",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "channelID",
Label: "Channel ID",
Type: config.FieldTypeText,
},
{
Name: "alwaysReply",
Label: "Always Reply",
Type: config.FieldTypeCheckbox,
},
{
Name: "lastMessageDuration",
Label: "Last Message Duration",
Type: config.FieldTypeText,
DefaultValue: "5m",
},
}
}

View File

@@ -14,6 +14,7 @@ import (
"github.com/go-telegram/bot/models"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/core/types"
"github.com/mudler/LocalAgent/pkg/config"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/mudler/LocalAgent/pkg/xstrings"
"github.com/mudler/LocalAgent/services/actions"
@@ -203,3 +204,27 @@ func NewTelegramConnector(config map[string]string) (*Telegram, error) {
conversationTracker: NewConversationTracker[int64](duration),
}, nil
}
// TelegramConfigMeta returns the metadata for Telegram connector configuration fields
func TelegramConfigMeta() []config.Field {
return []config.Field{
{
Name: "token",
Label: "Telegram Token",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "admins",
Label: "Admins",
Type: config.FieldTypeText,
HelpText: "Comma-separated list of Telegram usernames that are allowed to interact with the bot",
},
{
Name: "lastMessageDuration",
Label: "Last Message Duration",
Type: config.FieldTypeText,
DefaultValue: "5m",
},
}
}

View File

@@ -8,6 +8,7 @@ import (
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/core/types"
"github.com/mudler/LocalAgent/pkg/config"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/mudler/LocalAgent/services/connectors/twitter"
"github.com/sashabaranov/go-openai"
@@ -134,3 +135,26 @@ func (t *Twitter) run(a *agent.Agent) error {
return nil
}
// TwitterConfigMeta returns the metadata for Twitter connector configuration fields
func TwitterConfigMeta() []config.Field {
return []config.Field{
{
Name: "token",
Label: "Twitter API Token",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "botUsername",
Label: "Bot Username",
Type: config.FieldTypeText,
Required: true,
},
{
Name: "noCharacterLimit",
Label: "No Character Limit",
Type: config.FieldTypeCheckbox,
},
}
}