Add SILK voice fallback and WeChat polling diagnostics

This commit is contained in:
Coffee
2026-03-27 14:45:30 +08:00
parent 7284e05cd9
commit 6bc339f83c
8 changed files with 320 additions and 32 deletions
+49
View File
@@ -138,6 +138,16 @@ impl Guest for WechatChannel {
let mut context_tokens_changed = false;
for message in response.msgs {
log_channel(
channel_host::LogLevel::Info,
&format!(
"Received WeChat message: id={:?} from_user_id={:?} message_type={:?} item_types=[{}]",
message.message_id,
message.from_user_id,
message.message_type,
summarize_item_types(&message),
),
);
if let Some(from_user_id) = message.from_user_id.as_deref() {
if let Some(context_token) = message.context_token.as_deref() {
let changed = context_tokens
@@ -149,6 +159,15 @@ impl Guest for WechatChannel {
}
match incoming_bundle_from_message(&config, message) {
Ok(Some(bundle)) => {
log_channel(
channel_host::LogLevel::Info,
&format!(
"Mapped WeChat message into bundle: from_user_id={} text_len={} attachment_count={}",
bundle.from_user_id,
bundle.text.trim().chars().count(),
bundle.attachments.len(),
),
);
let emitted = process_incoming_bundle(
&mut pending_inbound,
bundle,
@@ -369,6 +388,15 @@ fn process_incoming_bundle(
}
fn emit_buffered_bundle(bundle: PendingInboundBundle) {
log_channel(
channel_host::LogLevel::Info,
&format!(
"Emitting WeChat bundle to agent: from_user_id={} text_len={} attachment_count={}",
bundle.from_user_id,
bundle.text.trim().chars().count(),
bundle.attachments.len(),
),
);
let metadata = json!({
"from_user_id": bundle.from_user_id,
"to_user_id": bundle.to_user_id,
@@ -413,6 +441,27 @@ fn merge_text(existing: &str, incoming: &str) -> String {
}
}
fn summarize_item_types(message: &WechatMessage) -> String {
let item_types = message
.item_list
.iter()
.map(|item| match item.r#type {
Some(MESSAGE_ITEM_TEXT) => "text".to_string(),
Some(crate::types::MESSAGE_ITEM_IMAGE) => "image".to_string(),
Some(crate::types::MESSAGE_ITEM_VOICE) => "voice".to_string(),
Some(crate::types::MESSAGE_ITEM_FILE) => "file".to_string(),
Some(other) => format!("unknown:{other}"),
None => "missing".to_string(),
})
.collect::<Vec<_>>();
if item_types.is_empty() {
"none".to_string()
} else {
item_types.join(",")
}
}
fn send_response(
config: &WechatConfig,
metadata: &OutboundMetadata,
+1 -1
View File
@@ -31,7 +31,7 @@ fn default_poll_interval_ms() -> u32 {
}
fn default_long_poll_timeout_ms() -> u32 {
35_000
15_000
}
impl Default for WechatConfig {
+1 -1
View File
@@ -45,6 +45,6 @@
"cdn_base_url": "https://novac2c.cdn.weixin.qq.com/c2c",
"bot_type": "3",
"poll_interval_ms": 30000,
"long_poll_timeout_ms": 35000
"long_poll_timeout_ms": 15000
}
}