新增小红书、XMPP、元宝、Zalo 四个渠道扩展。 小红书渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, media, status, window XMPP 渠道扩展主要模块:plugin, config, gateway, outbound, streaming, pairing, security, dedupe, accounts, commands, muc, rate_limiter, stanza_utils, status, monitor 元宝渠道扩展主要模块:plugin, client, config_schema, gateway, outbound(chunk/queue/transport), inbound(dispatcher), streaming, pairing, security, accounts, actions, commands, codec(biz/conn), session, shared, utils Zalo 渠道扩展主要模块:api, config, gateway, webhook, outbound, pairing, security, session, polling, monitor, status
169 lines
6.3 KiB
Python
169 lines
6.3 KiB
Python
from enum import StrEnum
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class DmPolicy(StrEnum):
|
|
PAIRING = "pairing"
|
|
OPEN = "open"
|
|
ALLOWLIST = "allowlist"
|
|
DISABLED = "disabled"
|
|
|
|
|
|
class GroupPolicy(StrEnum):
|
|
OPEN = "open"
|
|
ALLOWLIST = "allowlist"
|
|
DISABLED = "disabled"
|
|
|
|
|
|
class XmppRoomConfig(BaseModel):
|
|
require_mention: bool = True
|
|
enabled: bool = True
|
|
allow_from: list[str] = Field(default_factory=list)
|
|
system_prompt: str | None = None
|
|
|
|
|
|
class XmppAccountConfig(BaseModel):
|
|
name: str = ""
|
|
enabled: bool = True
|
|
jid: str = ""
|
|
password: str = ""
|
|
host: str = ""
|
|
port: int = 5222
|
|
use_ssl: bool = False
|
|
resource: str = "ForcePilot"
|
|
nick: str = "Bot"
|
|
rooms: list[str] = Field(default_factory=list)
|
|
dm_policy: str = "open"
|
|
group_policy: str = "open"
|
|
allow_from: list[str] = Field(default_factory=list)
|
|
group_allow_from: list[str] = Field(default_factory=list)
|
|
room_configs: dict[str, XmppRoomConfig] = Field(default_factory=dict)
|
|
room_passwords: dict[str, str] = Field(default_factory=dict)
|
|
dm_session_scope: str = "per-user"
|
|
block_streaming: bool = True
|
|
text_chunk_limit: int = 2000
|
|
|
|
|
|
class XmppConfig(BaseModel):
|
|
enabled: bool = True
|
|
accounts: dict[str, XmppAccountConfig] = Field(default_factory=dict)
|
|
default_account: str = "default"
|
|
|
|
|
|
def build_config_schema() -> dict:
|
|
return {
|
|
"type": "object",
|
|
"properties": {
|
|
"enabled": {"type": "boolean", "default": True},
|
|
"jid": {
|
|
"type": "string",
|
|
"description": "XMPP Bot JID (e.g. bot@example.com)",
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"description": "XMPP Bot account password",
|
|
},
|
|
"host": {
|
|
"type": "string",
|
|
"description": "XMPP server hostname (leave empty for SRV DNS auto-discovery)",
|
|
},
|
|
"port": {
|
|
"type": "integer",
|
|
"default": 5222,
|
|
"description": "Server port (5222 STARTTLS / 5223 Direct TLS)",
|
|
},
|
|
"use_ssl": {
|
|
"type": "boolean",
|
|
"default": False,
|
|
"description": "Use Direct TLS (port 5223) instead of STARTTLS",
|
|
},
|
|
"resource": {
|
|
"type": "string",
|
|
"default": "ForcePilot",
|
|
"description": "XMPP resource identifier for this bot instance",
|
|
},
|
|
"nick": {
|
|
"type": "string",
|
|
"default": "Bot",
|
|
"description": "Default MUC room nickname",
|
|
},
|
|
"rooms": {
|
|
"type": "array",
|
|
"items": {"type": "string"},
|
|
"description": "MUC rooms to auto-join on connect (full JIDs like room@conference.example.com)",
|
|
},
|
|
"dm_policy": {
|
|
"type": "string",
|
|
"enum": ["open", "pairing", "allowlist", "disabled"],
|
|
"default": "open",
|
|
"description": "DM access policy",
|
|
},
|
|
"allow_from": {
|
|
"type": "array",
|
|
"items": {"type": "string"},
|
|
"description": "DM allowlist entries (Bare JIDs like user@example.com)",
|
|
},
|
|
"group_policy": {
|
|
"type": "string",
|
|
"enum": ["open", "allowlist", "disabled"],
|
|
"default": "open",
|
|
"description": "Group/MUC access policy",
|
|
},
|
|
"group_allow_from": {
|
|
"type": "array",
|
|
"items": {"type": "string"},
|
|
"description": "Group sender allowlist entries (Bare JIDs)",
|
|
},
|
|
"room_configs": {
|
|
"type": "object",
|
|
"description": "Per-room config (keyed by room JID)",
|
|
"additionalProperties": {
|
|
"type": "object",
|
|
"properties": {
|
|
"require_mention": {"type": "boolean", "default": True},
|
|
"enabled": {"type": "boolean", "default": True},
|
|
"allow_from": {"type": "array", "items": {"type": "string"}},
|
|
"system_prompt": {"type": "string"},
|
|
},
|
|
},
|
|
},
|
|
"dm_session_scope": {
|
|
"type": "string",
|
|
"enum": ["per-user", "per-user-room"],
|
|
"default": "per-user",
|
|
},
|
|
"room_passwords": {
|
|
"type": "object",
|
|
"description": "MUC room passwords (keyed by room JID)",
|
|
"additionalProperties": {"type": "string"},
|
|
},
|
|
"accounts": {
|
|
"type": "object",
|
|
"description": "Named accounts (keyed by account ID)",
|
|
"additionalProperties": {
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {"type": "string"},
|
|
"enabled": {"type": "boolean", "default": True},
|
|
"jid": {"type": "string"},
|
|
"password": {"type": "string"},
|
|
"host": {"type": "string"},
|
|
"port": {"type": "integer", "default": 5222},
|
|
"use_ssl": {"type": "boolean", "default": False},
|
|
"resource": {"type": "string", "default": "ForcePilot"},
|
|
"nick": {"type": "string", "default": "Bot"},
|
|
"rooms": {"type": "array", "items": {"type": "string"}},
|
|
"dm_policy": {"type": "string", "enum": ["open", "pairing", "allowlist", "disabled"]},
|
|
"allow_from": {"type": "array", "items": {"type": "string"}},
|
|
"group_policy": {"type": "string", "enum": ["open", "allowlist", "disabled"]},
|
|
"group_allow_from": {"type": "array", "items": {"type": "string"}},
|
|
"room_configs": {"type": "object", "additionalProperties": {"type": "object"}},
|
|
"dm_session_scope": {"type": "string", "enum": ["per-user", "per-user-room"]},
|
|
"room_passwords": {"type": "object", "additionalProperties": {"type": "string"}},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|