server

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractUserMessage

func ExtractUserMessage(msg *DingTalkMessage) string

ExtractUserMessage 提取用户消息

func IsValidTimestamp

func IsValidTimestamp(timestamp string) bool

IsValidTimestamp 检查时间戳有效性

Types

type DingTalkAtUser

type DingTalkAtUser struct {
	DingtalkID string `json:"dingtalkId"`
}

type DingTalkCrypto

type DingTalkCrypto struct {
	// contains filtered or unexported fields
}

DingTalkCrypto 回调加解密工具

func NewDingTalkCrypto

func NewDingTalkCrypto(token, encodingAESKey, suiteKey string) (*DingTalkCrypto, error)

NewDingTalkCrypto 创建回调加解密工具

func (*DingTalkCrypto) DecryptMessage

func (c *DingTalkCrypto) DecryptMessage(encryptedMsg string) (*DingTalkMessage, error)

DecryptMessage 解密消息

func (*DingTalkCrypto) VerifySignature

func (c *DingTalkCrypto) VerifySignature(timestamp, nonce, body, signature string) bool

VerifySignature 验证签名

type DingTalkIntent

type DingTalkIntent struct {
	MCPTool string
	Params  map[string]any
}

DingTalkIntent 用户意图

func ParseIntent

func ParseIntent(message string) (*DingTalkIntent, error)

ParseIntent 解析用户意图

type DingTalkMarkdownMsg

type DingTalkMarkdownMsg struct {
	Title string `json:"title"`
	Text  string `json:"text"`
}

type DingTalkMessage

type DingTalkMessage struct {
	MsgID            string           `json:"msgId"`
	MsgType          string           `json:"msgtype"`
	CreateAt         int64            `json:"createAt"`
	ConversationID   string           `json:"conversationId"`
	ConversationType string           `json:"conversationType"` // "1"=单聊, "2"=群聊
	SenderID         string           `json:"senderId"`
	SenderStaffID    string           `json:"senderStaffId"`
	SenderNick       string           `json:"senderNick"`
	ChatbotUserID    string           `json:"chatbotUserId"`
	Text             *DingTalkText    `json:"text,omitempty"`
	AtUsers          []DingTalkAtUser `json:"atUsers,omitempty"`
}

DingTalkMessage 钉钉消息

type DingTalkMessageHandler

type DingTalkMessageHandler struct {
	// contains filtered or unexported fields
}

DingTalkMessageHandler 消息处理器

func NewDingTalkMessageHandler

func NewDingTalkMessageHandler(cfg *config.Config, mcpServer *imcp.MCPServer) *DingTalkMessageHandler

NewDingTalkMessageHandler 创建消息处理器

func (*DingTalkMessageHandler) HandleMessage

HandleMessage 处理消息

type DingTalkResponse

type DingTalkResponse struct {
	MsgType  string               `json:"msgtype"`
	Text     *DingTalkTextMsg     `json:"text,omitempty"`
	Markdown *DingTalkMarkdownMsg `json:"markdown,omitempty"`
}

type DingTalkService

type DingTalkService struct {
	// contains filtered or unexported fields
}

DingTalkService 钉钉服务

func NewDingTalkService

func NewDingTalkService(cfg *config.Config, mcpServer *imcp.MCPServer) (*DingTalkService, error)

NewDingTalkService 创建钉钉服务

func (*DingTalkService) Start

func (s *DingTalkService) Start(ctx context.Context) error

Start 启动钉钉服务

func (*DingTalkService) Stop

func (s *DingTalkService) Stop(ctx context.Context) error

Stop 停止钉钉服务

type DingTalkStreamClient

type DingTalkStreamClient struct {
	// contains filtered or unexported fields
}

DingTalkStreamClient 钉钉流式客户端(使用官方SDK)

func NewDingTalkStreamClient

func NewDingTalkStreamClient(appKey, appSecret, templateID string) (*DingTalkStreamClient, error)

NewDingTalkStreamClient 创建钉钉流式客户端

func (*DingTalkStreamClient) CreateAndDeliverCard

func (c *DingTalkStreamClient) CreateAndDeliverCard(ctx context.Context, trackID, conversationID, conversationType, senderStaffID string) error

CreateAndDeliverCard 创建并投递 AI 卡片(实现CardClient接口)

func (*DingTalkStreamClient) GetAccessToken

func (c *DingTalkStreamClient) GetAccessToken() (string, error)

GetAccessToken 获取访问令牌(带缓存)

func (*DingTalkStreamClient) StreamError

func (c *DingTalkStreamClient) StreamError(trackID string, err error, question string) error

StreamError 发送错误信息

func (*DingTalkStreamClient) StreamInitial

func (c *DingTalkStreamClient) StreamInitial(trackID, question string) error

StreamInitial 发送初始提示信息

func (*DingTalkStreamClient) StreamResponse

func (c *DingTalkStreamClient) StreamResponse(ctx context.Context, trackID string, contentCh <-chan string, question string)

StreamResponse 流式响应(定时更新)

func (*DingTalkStreamClient) StreamingUpdate

func (c *DingTalkStreamClient) StreamingUpdate(trackID, content string, isFinalize bool) error

StreamingUpdate 流式更新卡片内容

type DingTalkStreamHandler

type DingTalkStreamHandler struct {
	// contains filtered or unexported fields
}

DingTalkStreamHandler Stream模式处理器

func NewDingTalkStreamHandler

func NewDingTalkStreamHandler(cfg *config.Config, cardClient *DingTalkStreamClient, mcpServer *imcp.MCPServer) *DingTalkStreamHandler

NewDingTalkStreamHandler 创建Stream处理器

func (*DingTalkStreamHandler) Start

Start 启动Stream客户端

func (*DingTalkStreamHandler) Stop

func (h *DingTalkStreamHandler) Stop() error

Stop 停止Stream客户端

type DingTalkText

type DingTalkText struct {
	Content string `json:"content"`
}

type DingTalkTextMsg

type DingTalkTextMsg struct {
	Content string `json:"content"`
}

type HTTPGinServer

type HTTPGinServer struct {
	// contains filtered or unexported fields
}

HTTPGinServer 基于 Gin 的 HTTP 服务器

func NewHTTPGinServer

func NewHTTPGinServer(cfg *config.Config) *HTTPGinServer

NewHTTPGinServer 创建基于 Gin 的 HTTP 服务器

func (*HTTPGinServer) SetMCPServer

func (s *HTTPGinServer) SetMCPServer(mcpServer *imcp.MCPServer)

SetMCPServer 设置 MCP Server

func (*HTTPGinServer) Start

func (s *HTTPGinServer) Start() error

Start 启动 HTTP 服务器

func (*HTTPGinServer) Stop

func (s *HTTPGinServer) Stop(ctx context.Context) error

Stop 停止 HTTP 服务器

type Intent

type Intent struct {
	Action   string            // list, get, search
	Provider string            // aliyun, tencent, jenkins
	Resource string            // ecs, cvm, rds, cdb, job, build
	Params   map[string]string // 参数
	MCPTool  string            // 对应的 MCP 工具名称
}

Intent 用户意图

type IntentParser

type IntentParser struct {
	// contains filtered or unexported fields
}

IntentParser 意图解析器

func (*IntentParser) Parse

func (p *IntentParser) Parse(message string) (*Intent, error)

Parse 解析用户消息

type Response

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

Response 统一响应结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL