feat: add stable proactive delivery

This commit is contained in:
xmanrui 2026-08-30 11:24:53 +08:00
parent 410cb822d7
commit 31792d7bc8
88 changed files with 6427 additions and 488 deletions

View file

@ -57,9 +57,11 @@ function configFixture(initial = [], events = []) {
function runtimeFactory({ events = [], pendingByClient = new Map(), failStart = false } = {}) {
const runtimes = [];
const connectionTests = [];
const proactiveSends = [];
return {
runtimes,
connectionTests,
proactiveSends,
createRuntime: async ({ botId, config, clientSecret }) => {
events.push(['create', botId]);
let ready = false;
@ -96,6 +98,10 @@ function runtimeFactory({ events = [], pendingByClient = new Map(), failStart =
async sendConnectionTest(text) {
connectionTests.push({ botId, text });
},
async sendProactiveText(...args) {
proactiveSends.push({ botId, args });
return { sent: true };
},
};
runtimes.push(runtime);
return runtime;
@ -154,6 +160,14 @@ test('successful QR poll stores secret then config then starts runtime without p
assert.equal(runtimes.connectionTests[0].botId, completed.botId);
assert.match(runtimes.connectionTests[0].text, /DeepSeek Harness 连接测试成功/);
assert.match(runtimes.connectionTests[0].text, /钉钉机器人(ding••••vate)/);
const target = { kind: 'user', route: { userId: 'staff-one' } };
assert.deepEqual(await controller.sendProactiveText(completed.botId, target, '主动投递'), {
sent: true,
});
assert.deepEqual(runtimes.proactiveSends, [{
botId: completed.botId,
args: [target, '主动投递', {}],
}]);
await controller.close();
});