feat: 简化微信渠道账号连接

This commit is contained in:
2026-09-14 12:05:16 +08:00
parent a721b8fb7e
commit 21e707d9c4
21 changed files with 238 additions and 1078 deletions

View File

@@ -172,6 +172,27 @@ describe('Main cloud Agents boundary', () => {
expect(fetchImpl).not.toHaveBeenCalled();
});
it('does not expose removed channel policy, invitation, or caller-management operations', () => {
for (const operation of ['channelPolicy', 'createChannelPairing', 'channelCallers', 'revokeChannelCaller']) {
expect(() => operationPlan({ operation, input: { slug: draft.slug, channel_account_id: 'wechat-1' } })).toThrow('invalid_operation');
}
});
it('discards a legacy removed-operation journal entry without replaying its API', async () => {
const accountKey = 'a'.repeat(64);
journalRecords.set(accountKey, { recent: null, pending: [{
id: 'channelPolicy:legacy', operation: 'channelPolicy', created_at: '2026-09-13T00:00:00Z',
input: { slug: draft.slug, channel_account_id: 'wechat-1', operation_id: input.operation_id, access_mode: 'invited' },
}] });
const fetchImpl = vi.fn();
const module = moduleFor(fetchImpl);
await expect(module.resolvePending({ id: 'channelPolicy:legacy' })).resolves.toMatchObject({
operation: 'channelPolicy', discarded: true, retired: true,
});
expect((await module.recovery()).pending).toEqual([]);
expect(fetchImpl).not.toHaveBeenCalled();
});
it('uses the fixed self-only channel query and slug query aliases', () => {
const selfCallers = operationPlan({ operation: 'channelSelfCallers', input: { slug: draft.slug } });
expect(selfCallers.path).toBe(`/api/makelore/agents/${draft.slug}/channel-callers?access_mode=self_only`);
@@ -188,9 +209,9 @@ describe('Main cloud Agents boundary', () => {
it('projects channel output without provider credentials or arbitrary QR URLs', () => {
const plan = operationPlan({ operation: 'channelBindings', input: { slug: draft.slug } });
expect(plan.project({ items: [{ id: 'channel-1', display_name: '本人微信', account_key: 'private', health: 'connected', blockers: ['publish_required', { secret: true }] }],
expect(plan.project({ items: [{ id: 'channel-1', display_name: '个人微信', account_key: 'private', health: 'connected', blockers: ['publish_required', { secret: true }] }],
available_accounts: [{ id: 'channel-2', adoption_state: 'available', managed_agent_slug: null, access_token: 'private' }] })).toEqual({
items: [{ id: 'channel-1', display_name: '本人微信', health: 'connected', blockers: ['publish_required'] }],
items: [{ id: 'channel-1', display_name: '个人微信', health: 'connected', blockers: ['publish_required'] }],
available_accounts: [{ id: 'channel-2', adoption_state: 'available', managed_agent_slug: null }],
});
const qr = operationPlan({ operation: 'wechatBindStart', input: { slug: draft.slug, channel_account_id: 'channel-1', operation_id: input.operation_id, force: false } });