fix: support legacy and current DSH hosts

This commit is contained in:
xmanrui 2026-08-29 20:22:07 +08:00
parent 72ffd7115c
commit 6b9118fe95
20 changed files with 1279 additions and 259 deletions

View file

@ -38,7 +38,6 @@ test('Host composes nine IM channels and the AI Office connector inside one plug
assert.deepEqual(inject, [
'connection',
'credentials',
'apiProxy',
'typertGateway',
]);
assert.deepEqual(calls, [
@ -55,6 +54,36 @@ test('Host composes nine IM channels and the AI Office connector inside one plug
]);
});
test('Host waits for apiProxy on legacy Harness and Controllers on modern Harness', async () => {
for (const [modern, expected] of [
[false, ['apiProxy']],
[true, ['sessionController', 'workspaceController']],
]) {
const injections = [];
const calls = [];
const plugin = createImHostPlugin(Object.fromEntries(CHANNELS.map(([channel, applyName]) => [
applyName,
async () => calls.push(channel),
])));
const ctx = {
credentials: {},
typertGateway: modern ? { stream() {} } : { invoke() {} },
inject(dependencies, callback) {
injections.push(dependencies);
if (dependencies.includes('tools')) return {};
return {
then(resolve, reject) {
Promise.resolve(callback(ctx)).then(resolve, reject);
},
};
},
};
await plugin.apply(ctx, {});
assert.deepEqual(injections[0], expected);
assert.deepEqual(calls, CHANNELS.map(([channel]) => channel));
}
});
const CHANNELS = [
['feishu', 'applyFeishu'],
['weixin', 'applyWeixin'],