mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
feat: channel gateway implementation and multi-bot refactor
- Refactor channel manager with support for Sender/Receiver interfaces and hot-swappable adapters. - Implement identity routing and pre-authentication logic for inbound messages. - Update database schema to support bot pre-auth keys and extended channel session metadata. - Add Telegram and Feishu channel configuration and adapter enhancements. - Update Swagger documentation and internal handlers for channel management. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -253,44 +253,44 @@ func toSubagent(row sqlc.Subagent) (Subagent, error) {
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func marshalMessages(messages []map[string]interface{}) ([]byte, error) {
|
||||
func marshalMessages(messages []map[string]any) ([]byte, error) {
|
||||
if messages == nil {
|
||||
messages = []map[string]interface{}{}
|
||||
messages = []map[string]any{}
|
||||
}
|
||||
return json.Marshal(messages)
|
||||
}
|
||||
|
||||
func unmarshalMessages(payload []byte) ([]map[string]interface{}, error) {
|
||||
func unmarshalMessages(payload []byte) ([]map[string]any, error) {
|
||||
if len(payload) == 0 {
|
||||
return []map[string]interface{}{}, nil
|
||||
return []map[string]any{}, nil
|
||||
}
|
||||
var messages []map[string]interface{}
|
||||
var messages []map[string]any
|
||||
if err := json.Unmarshal(payload, &messages); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if messages == nil {
|
||||
messages = []map[string]interface{}{}
|
||||
messages = []map[string]any{}
|
||||
}
|
||||
return messages, nil
|
||||
}
|
||||
|
||||
func marshalMetadata(metadata map[string]interface{}) ([]byte, error) {
|
||||
func marshalMetadata(metadata map[string]any) ([]byte, error) {
|
||||
if metadata == nil {
|
||||
metadata = map[string]interface{}{}
|
||||
metadata = map[string]any{}
|
||||
}
|
||||
return json.Marshal(metadata)
|
||||
}
|
||||
|
||||
func unmarshalMetadata(payload []byte) (map[string]interface{}, error) {
|
||||
func unmarshalMetadata(payload []byte) (map[string]any, error) {
|
||||
if len(payload) == 0 {
|
||||
return map[string]interface{}{}, nil
|
||||
return map[string]any{}, nil
|
||||
}
|
||||
var metadata map[string]interface{}
|
||||
var metadata map[string]any
|
||||
if err := json.Unmarshal(payload, &metadata); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if metadata == nil {
|
||||
metadata = map[string]interface{}{}
|
||||
metadata = map[string]any{}
|
||||
}
|
||||
return metadata, nil
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ type Subagent struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
BotID string `json:"bot_id"`
|
||||
Messages []map[string]interface{} `json:"messages"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
Messages []map[string]any `json:"messages"`
|
||||
Metadata map[string]any `json:"metadata"`
|
||||
Skills []string `json:"skills"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
@@ -19,19 +19,19 @@ type Subagent struct {
|
||||
type CreateRequest struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Messages []map[string]interface{} `json:"messages,omitempty"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
Messages []map[string]any `json:"messages,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
Skills []string `json:"skills,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateContextRequest struct {
|
||||
Messages []map[string]interface{} `json:"messages"`
|
||||
Messages []map[string]any `json:"messages"`
|
||||
}
|
||||
|
||||
type UpdateSkillsRequest struct {
|
||||
@@ -47,7 +47,7 @@ type ListResponse struct {
|
||||
}
|
||||
|
||||
type ContextResponse struct {
|
||||
Messages []map[string]interface{} `json:"messages"`
|
||||
Messages []map[string]any `json:"messages"`
|
||||
}
|
||||
|
||||
type SkillsResponse struct {
|
||||
|
||||
Reference in New Issue
Block a user