mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-14 19:20:50 +08:00
feat: add model and turn control commands
This commit is contained in:
parent
fc8f120e13
commit
99ce38e9a4
38 changed files with 3451 additions and 169 deletions
|
|
@ -321,6 +321,43 @@ test('DingTalk executes /compact for the bound Session without prompting the mod
|
|||
assert.equal(sent.at(-1).text, '暂无可压缩的历史记录。');
|
||||
});
|
||||
|
||||
test('DingTalk lists models without prompting and help advertises all four commands', async () => {
|
||||
const fixture = stateFixture();
|
||||
const sent = [];
|
||||
let asks = 0;
|
||||
let creates = 0;
|
||||
const bridge = new DingtalkHarnessBridge({
|
||||
api: { sendText: async (request) => sent.push(request) },
|
||||
clientId: 'ding-client',
|
||||
clientSecret: 'host-secret',
|
||||
harness: {
|
||||
listModels: async () => ({
|
||||
groups: [{
|
||||
id: 'dingtalk-provider',
|
||||
name: 'DingTalk Provider',
|
||||
models: [{ id: 'model-one', name: 'Model One' }],
|
||||
}],
|
||||
failures: [],
|
||||
}),
|
||||
createSession: async () => { creates += 1; return 'dingtalk-session'; },
|
||||
ask: async () => { asks += 1; return 'unexpected model reply'; },
|
||||
},
|
||||
state: fixture.state,
|
||||
});
|
||||
|
||||
await bridge.accept(message('models-dingtalk', '/models'));
|
||||
assert.match(sent.at(-1).text, /dingtalk-provider\/model-one/);
|
||||
assert.equal(asks, 0);
|
||||
assert.equal(creates, 0);
|
||||
assert.equal(fixture.sessions.size, 0);
|
||||
|
||||
await bridge.accept(message('help-models-dingtalk', '/help'));
|
||||
const help = sent.at(-1).text;
|
||||
for (const command of ['/models', '/model', '/stop', '/steer']) {
|
||||
assert.equal(help.includes(command), true, command);
|
||||
}
|
||||
});
|
||||
|
||||
test('bridge maps a DingTalk direct conversation to one persistent Harness session', async () => {
|
||||
const fixture = stateFixture();
|
||||
const sent = [];
|
||||
|
|
|
|||
|
|
@ -1047,7 +1047,7 @@ test('reconnect history restores a Code Mode sub-call before replaying its appro
|
|||
await Promise.allSettled([asking]);
|
||||
});
|
||||
|
||||
test('interaction callbacks preserve frame order and watcher shutdown drains them', async () => {
|
||||
test('interaction callbacks preserve frame order but watcher abort does not await a hanging callback', async () => {
|
||||
const opened = deferred();
|
||||
const releaseRequested = deferred();
|
||||
const order = [];
|
||||
|
|
@ -1102,10 +1102,10 @@ test('interaction callbacks preserve frame order and watcher shutdown drains the
|
|||
let settled = false;
|
||||
void watching.finally(() => { settled = true; });
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
assert.equal(settled, false);
|
||||
assert.equal(settled, true);
|
||||
|
||||
releaseRequested.resolve();
|
||||
await watching;
|
||||
await eventually(() => order.length === 3);
|
||||
assert.deepEqual(order, ['requested:start', 'requested:end', 'resolved']);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue