mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-17 18:30:50 +08:00
feat: add agent preset chat commands
This commit is contained in:
parent
2ad6f1a44e
commit
eea29fe296
33 changed files with 1519 additions and 234 deletions
|
|
@ -262,11 +262,20 @@ test('Weixin executes /compact for the bound Session without prompting the model
|
|||
assert.equal(fixture.seen.has('compact-weixin'), true);
|
||||
});
|
||||
|
||||
test('Weixin lists models without prompting and help advertises all four commands', async () => {
|
||||
test('Weixin lists models and presets without prompting and advertises fast commands', async () => {
|
||||
const fixture = stateFixture();
|
||||
const sent = [];
|
||||
const presetUpdates = [];
|
||||
let agentPreset = null;
|
||||
let asks = 0;
|
||||
let creates = 0;
|
||||
const agentPresetCatalog = {
|
||||
defaultId: 'preset-001',
|
||||
items: Array.from({ length: 70 }, (_, index) => ({
|
||||
id: `preset-${String(index + 1).padStart(3, '0')}`,
|
||||
label: `Weixin Preset ${index + 1} ${'x'.repeat(64)}`,
|
||||
})),
|
||||
};
|
||||
const bridge = new WeixinHarnessBridge({
|
||||
api: { sendText: async (request) => sent.push(request) },
|
||||
baseUrl: 'https://ilinkai.weixin.qq.com/',
|
||||
|
|
@ -281,6 +290,12 @@ test('Weixin lists models without prompting and help advertises all four command
|
|||
}],
|
||||
failures: [],
|
||||
}),
|
||||
agentPresetSettings: async () => ({ agentPreset, agentPresetCatalog }),
|
||||
updateAgentPreset: async (value) => {
|
||||
presetUpdates.push(value);
|
||||
agentPreset = value;
|
||||
return { agentPreset, agentPresetCatalog };
|
||||
},
|
||||
createSession: async () => { creates += 1; return 'weixin-session'; },
|
||||
ask: async () => { asks += 1; return 'unexpected model reply'; },
|
||||
},
|
||||
|
|
@ -293,12 +308,42 @@ test('Weixin lists models without prompting and help advertises all four command
|
|||
assert.equal(creates, 0);
|
||||
assert.equal(fixture.sessions.size, 0);
|
||||
|
||||
const presetReplyStart = sent.length;
|
||||
await bridge.accept(message('presets-weixin', '/presetlist'));
|
||||
const presetReplies = sent.slice(presetReplyStart).map((entry) => entry.text);
|
||||
assert.ok(presetReplies.length > 1);
|
||||
assert.match(presetReplies.join('\n'), /preset-070/);
|
||||
assert.equal(asks, 0);
|
||||
assert.equal(creates, 0);
|
||||
assert.equal(fixture.sessions.size, 0);
|
||||
|
||||
await bridge.accept(message('preset-current-weixin', '/preset'));
|
||||
assert.match(sent.at(-1).text, /跟随 Host 默认/);
|
||||
assert.equal(asks, 0);
|
||||
assert.equal(creates, 0);
|
||||
|
||||
const selectReplyStart = sent.length;
|
||||
await bridge.accept(message('preset-select-weixin', '/preset 2'));
|
||||
assert.deepEqual(presetUpdates, ['preset-002']);
|
||||
assert.equal(sent.length, selectReplyStart + 1);
|
||||
assert.match(sent.at(-1).text, /preset-002/);
|
||||
|
||||
const defaultReplyStart = sent.length;
|
||||
await bridge.accept(message('preset-default-weixin', '/preset --default'));
|
||||
assert.deepEqual(presetUpdates, ['preset-002', null]);
|
||||
assert.equal(sent.length, defaultReplyStart + 1);
|
||||
assert.match(sent.at(-1).text, /跟随 Host 默认/);
|
||||
assert.equal(asks, 0);
|
||||
assert.equal(creates, 0);
|
||||
assert.equal(fixture.sessions.size, 0);
|
||||
|
||||
await bridge.accept(message('help-models-weixin', '/help'));
|
||||
const help = sent.at(-1).text;
|
||||
for (const command of ['/models', '/model', '/stop', '/steer']) {
|
||||
for (const command of ['/models', '/model', '/presetlist', '/preset', '/preset --default', '/stop', '/steer']) {
|
||||
assert.equal(help.includes(command), true, command);
|
||||
}
|
||||
assert.match(help, /\/model 2/);
|
||||
assert.match(help, /\/preset id:<ID>/);
|
||||
});
|
||||
|
||||
test('bridge maps the scanning Weixin user to one persistent Harness session and echoes context_token', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue