feat: split h5 direct chat from goosed tasks

This commit is contained in:
john
2026-07-04 14:01:00 +08:00
parent eb8d760dd9
commit 29d9a87d4f
18 changed files with 874 additions and 32 deletions
+46
View File
@@ -255,6 +255,52 @@ test('agent run starts a session and marks submitted reply as succeeded', async
assert.equal(pool.runs.get(run.id).attempts, 1);
});
test('agent run uses direct chat service for eligible chat messages', async () => {
const pool = createFakePool();
const directRuns = [];
const gateway = createAgentRunGateway({
pool,
userAuth: {},
tkmindProxy: {
async startSessionForUser() {
assert.fail('goose session should not start for direct chat');
},
async submitSessionReplyForUser() {
assert.fail('goose reply should not be submitted for direct chat');
},
},
directChatService: {
canHandle({ toolMode, userMessage }) {
return toolMode === 'chat' && userMessage?.content?.[0]?.text === 'hi';
},
async run(input) {
directRuns.push(input);
return {
sessionId: 'h5direct_session-1',
providerId: 'custom_deepseek',
model: 'deepseek-chat',
billing: { ok: true },
};
},
getStatus() {
return { enabled: true };
},
},
retryDelaysMs: [],
});
const run = await gateway.createRun('user-1', {
requestId: 'req-direct',
userMessage: { role: 'user', content: [{ type: 'text', text: 'hi' }] },
});
await waitFor(() => pool.runs.get(run.id)?.status === 'succeeded');
assert.equal(pool.runs.get(run.id).agent_session_id, 'h5direct_session-1');
assert.equal(directRuns.length, 1);
assert.equal(directRuns[0].requestId, 'req-direct');
assert.ok(pool.events.some((event) => event.eventType === 'direct_chat_completed'));
});
test('agent run with code tool mode starts and submits with code policy', async () => {
const pool = createFakePool();
const submitted = [];