feat: support compact command across IM channels

This commit is contained in:
xmanrui 2026-08-18 23:20:05 +08:00
parent 4545cfe9c5
commit 1cc7a26f30
40 changed files with 728 additions and 136 deletions

View file

@ -76,6 +76,31 @@ function stateFixture() {
};
}
test('DingTalk executes /compact for the bound Session without prompting the model', async () => {
const fixture = stateFixture();
fixture.sessions.set('p2p:staff-approved', 'session-compact');
const sent = [];
const executed = [];
const bridge = new DingtalkHarnessBridge({
api: { sendText: async (request) => sent.push(request) },
clientId: 'ding-client',
clientSecret: 'host-secret',
harness: {
executeCommand: async (sessionId, line) => {
executed.push({ sessionId, line });
return { commandId: 'compact-dingtalk', result: { kind: 'success', text: 'No compactable history yet.' } };
},
ask: async () => assert.fail('/compact must not be submitted to the model'),
},
state: fixture.state,
});
await bridge.accept(message('compact-dingtalk', '/compact'));
assert.deepEqual(executed, [{ sessionId: 'session-compact', line: '/compact' }]);
assert.equal(sent.at(-1).text, '暂无可压缩的历史记录。');
});
test('bridge maps a DingTalk direct conversation to one persistent Harness session', async () => {
const fixture = stateFixture();
const sent = [];

View file

@ -20,7 +20,7 @@ function controller() {
test('Host exports the DingTalk plugin identity and required services', () => {
const plugin = createDingtalkHostPlugin({ controller: controller() });
assert.equal(name, 'dsh-dingtalk-host');
assert.deepEqual(inject, ['connection', 'credentials', 'webServer']);
assert.deepEqual(inject, ['connection', 'credentials', 'webServer', 'typertGateway']);
assert.equal(plugin.name, name);
assert.deepEqual(plugin.inject, inject);
});