Merge paired WeChat binding and compound unbinding workflow

This commit is contained in:
鲨鱼辣椒 committed 2026-10-13 20:02:12 +08:00
commit 1bf831ef97
10 files changed
+2372 -769

No files matched your search

+14 -2
View File
@@ -55,6 +55,7 @@ const MESSAGES: Record<string, string> = {
download_failed: '文件保存失败,请重试',
channel_not_found: '微信渠道不存在或已解绑',
channel_operation_conflict: '微信渠道正在处理其他操作,请稍后查看状态',
channel_operation_unconfirmed: '微信绑定的变更尚未确认,请查看待确认操作后重试',
channel_request_invalid: '微信渠道请求无效,请刷新后重试',
channel_rate_limited: '微信渠道操作过于频繁,请稍后重试',
channel_conversation_not_found: '微信会话不存在或已关闭',
@@ -424,9 +425,20 @@ export class CloudAgentsModule {
let plan;
try { plan = operationPlan(value); }
catch { throw new CloudAgentsError(422, 'invalid_input'); }
const invoke = async () => plan.project(await this.request(plan.path, plan.method, plan.body, plan.cloud === 'ws'));
const invoke = async () => {
const result = plan.project(await this.request(plan.path, plan.method, plan.body, plan.cloud === 'ws'));
if (plan.operation === 'unbindChannelAccount') {
const value = record(result), channel = record(value.channel);
if (value.unbound !== true || value.disconnected !== true || channel.id !== plan.input.channel_account_id
|| channel.enabled !== false || channel.target_agent_slug !== null || channel.health !== 'login_required') {
// Keep the original operation in recovery until both routing and login are confirmed removed.
throw new CloudAgentsError(503, 'channel_operation_unconfirmed');
}
}
return result;
};
const recoverable = ['submit', 'preview', 'resume', 'publish', 'createApplication', 'createKey', 'createKnowledge', 'processKnowledge', 'createSchedule', 'runSchedule', 'importKnowledgeAttachment', 'createChild',
'createChannelAccount', 'routeChannelAccount', 'enableChannelAccount', 'pauseChannelAccount', 'disconnectChannelAccount',
'createChannelAccount', 'routeChannelAccount', 'enableChannelAccount', 'pauseChannelAccount', 'disconnectChannelAccount', 'unbindChannelAccount',
'channelAccountWechatBindStart', 'channelAccountWechatBindVerification', 'channelAccountWechatUnbind',
'createChannelBinding', 'switchChannelBindingAgent', 'enableChannelBinding', 'pauseChannelBinding', 'disconnectChannelBinding',
'wechatBindStart', 'wechatBindVerification', 'wechatUnbind',