feat(sdk): 插件 SDK(Tool/Skill/Channel 接口 + 注册辅助 + 配置 hook)

This commit is contained in:
Aska committed 2026-09-06 04:35:31 +08:00
1 parent c52ddfd9c7
commit 7b8cfc664a
5 files changed
+409

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
package sdk
import "context"
// Channel registers a chat platform adapter (QQ, WeChat, Telegram, ...).
//
// The SDK pins only the lifecycle shape. The authoritative contract for
// adapters lives in internal/channel/adapter (design authority
// DevDocs/design/08-渠道接入.md §1, the PlatformAdapter contract) and is
// implemented in milestone M6. This interface mirrors the lifecycle portion of
// that contract — Name/Connect/Disconnect/IsConnected/HealthCheck — without
// depending on the internal message model, so a platform plugin can register
// itself here while the message flow is provided by the channel layer.
//
// Implementations must be safe for concurrent use.
type Channel interface {
// Name returns the platform identifier (for example "qq", "telegram").
Name() string
// Connect establishes the platform connection using config. It may be
// called more than once and must be idempotent.
Connect(ctx context.Context, config any) error
// Disconnect tears the connection down gracefully. It returns nil when the
// adapter was already disconnected.
Disconnect(ctx context.Context) error
// IsConnected reports whether the connection is currently up.
IsConnected() bool
// HealthCheck probes the platform and returns an error when it is unhealthy.
HealthCheck(ctx context.Context) error
}