Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions agent/prompt_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ def _strip_yaml_frontmatter(content: str) -> str:
"only — no markdown, no formatting. SMS messages are limited to ~1600 "
"characters, so be brief and direct."
),
"wechat": (
"You are on WeChat, a text messaging platform popular in China. "
"Use plain text only — no markdown, no formatting. Messages are limited "
"to 2048 characters. Keep responses concise and direct."
),
}

CONTEXT_FILE_MAX_CHARS = 20_000
Expand Down
1 change: 1 addition & 0 deletions cron/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def _deliver_result(job: dict, content: str) -> None:
"mattermost": Platform.MATTERMOST,
"homeassistant": Platform.HOMEASSISTANT,
"dingtalk": Platform.DINGTALK,
"wechat": Platform.WECHAT,
"email": Platform.EMAIL,
"sms": Platform.SMS,
}
Expand Down
27 changes: 27 additions & 0 deletions gateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Platform(Enum):
EMAIL = "email"
SMS = "sms"
DINGTALK = "dingtalk"
WECHAT = "wechat"
API_SERVER = "api_server"
WEBHOOK = "webhook"

Expand Down Expand Up @@ -547,6 +548,7 @@ def load_gateway_config() -> GatewayConfig:
Platform.SLACK: "SLACK_BOT_TOKEN",
Platform.MATTERMOST: "MATTERMOST_TOKEN",
Platform.MATRIX: "MATRIX_ACCESS_TOKEN",
Platform.WECHAT: "WECHAT_TOKEN",
}
for platform, pconfig in config.platforms.items():
if not pconfig.enabled:
Expand Down Expand Up @@ -775,6 +777,31 @@ def _apply_env_overrides(config: GatewayConfig) -> None:
if webhook_secret:
config.platforms[Platform.WEBHOOK].extra["secret"] = webhook_secret

# WeChat Official Account
wechat_token = os.getenv("WECHAT_TOKEN")
wechat_app_id = os.getenv("WECHAT_APP_ID")
wechat_app_secret = os.getenv("WECHAT_APP_SECRET")
if wechat_token and wechat_app_id and wechat_app_secret:
if Platform.WECHAT not in config.platforms:
config.platforms[Platform.WECHAT] = PlatformConfig()
config.platforms[Platform.WECHAT].enabled = True
config.platforms[Platform.WECHAT].token = wechat_token
config.platforms[Platform.WECHAT].extra["app_id"] = wechat_app_id
config.platforms[Platform.WECHAT].extra["app_secret"] = wechat_app_secret
wechat_port = os.getenv("WECHAT_PORT")
if wechat_port:
try:
config.platforms[Platform.WECHAT].extra["port"] = int(wechat_port)
except ValueError:
pass
wechat_home = os.getenv("WECHAT_HOME_CHANNEL")
if wechat_home:
config.platforms[Platform.WECHAT].home_channel = HomeChannel(
platform=Platform.WECHAT,
chat_id=wechat_home,
name=os.getenv("WECHAT_HOME_CHANNEL_NAME", "Home"),
)

# Session settings
idle_minutes = os.getenv("SESSION_IDLE_MINUTES")
if idle_minutes:
Expand Down
Loading
Loading