feat: add msglib message source metadata

This commit is contained in:
zhaoyilun
2026-07-10 08:36:34 +08:00
parent 1a21a01184
commit c8ecf5b36e
8 changed files with 380 additions and 15 deletions

View File

@@ -87,6 +87,16 @@ type DisplaySource struct {
PresentColumns []string `json:"present_columns"`
}
type MessageSource struct {
Source string `json:"source"`
Table string `json:"table"`
Role string `json:"role"`
Available bool `json:"available"`
RequiredColumns []string `json:"required_columns"`
PresentColumns []string `json:"present_columns"`
RowCount string `json:"row_count"`
}
type DisplayEntitiesOptions struct {
EntityType string
Query string
@@ -139,6 +149,19 @@ func (c *Client) DisplaySources(ctx context.Context) ([]DisplaySource, error) {
return out.DisplaySources, nil
}
func (c *Client) MessageSources(ctx context.Context) ([]MessageSource, error) {
args := map[string]any{
"sqlite_dll_path": c.config.SQLiteDLLPath,
"db_path": c.config.DBPath,
"password": c.config.Password,
}
var out messageSourcesData
if err := c.call(ctx, "message_sources", args, &out); err != nil {
return nil, err
}
return out.MessageSources, nil
}
func (c *Client) DisplayEntities(ctx context.Context, opts DisplayEntitiesOptions) ([]DisplayEntity, error) {
entityType := strings.TrimSpace(opts.EntityType)
if entityType != EntityTypeContacts && entityType != EntityTypeGroups {
@@ -174,6 +197,10 @@ type displaySourcesData struct {
DisplaySources []DisplaySource `json:"display_sources"`
}
type messageSourcesData struct {
MessageSources []MessageSource `json:"message_sources"`
}
type displayEntitiesData struct {
Entities []DisplayEntity `json:"entities"`
}