feat: add tool status management and localization for skill installation
- Updated chat message types to include tool statuses. - Enhanced localization files for English, Thai, and Chinese to support new tool status messages. - Modified HomePage and SkillsPage components to handle tool statuses in chat messages. - Implemented tool status merging and updating logic in the chat store. - Added handling for tool status events in the gateway event processing. - Created tests for chat message rendering with tool statuses and skill installation shortcuts. - Improved gateway event dispatching for tool lifecycle events.
This commit is contained in:
@@ -82,17 +82,50 @@ describe('gateway browser shortcut', () => {
|
||||
'http://www.baidu.com/',
|
||||
expect.objectContaining({ signal: expect.any(AbortSignal) }),
|
||||
);
|
||||
expect(broadcast).toHaveBeenNthCalledWith(1, expect.objectContaining({
|
||||
type: 'tool:status',
|
||||
sessionKey: 'agent:test:main',
|
||||
runId: 'run-1',
|
||||
toolName: 'browser.open_url',
|
||||
status: 'running',
|
||||
}));
|
||||
expect(broadcast).toHaveBeenNthCalledWith(2, expect.objectContaining({
|
||||
type: 'tool:status',
|
||||
sessionKey: 'agent:test:main',
|
||||
runId: 'run-1',
|
||||
toolName: 'browser.open_url',
|
||||
status: 'completed',
|
||||
}));
|
||||
expect(mocks.appendMessage).toHaveBeenCalledWith(
|
||||
'agent:test:main',
|
||||
expect.objectContaining({
|
||||
role: 'assistant',
|
||||
content: '已为你打开 http://www.baidu.com/(百度一下,你就知道)',
|
||||
_toolStatuses: [
|
||||
expect.objectContaining({
|
||||
name: 'browser.open_url',
|
||||
status: 'completed',
|
||||
input: { url: 'http://www.baidu.com/' },
|
||||
result: expect.objectContaining({
|
||||
pageUrl: 'http://www.baidu.com/',
|
||||
title: '百度一下,你就知道',
|
||||
}),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
);
|
||||
expect(broadcast).toHaveBeenCalledWith(expect.objectContaining({
|
||||
expect(broadcast).toHaveBeenNthCalledWith(3, expect.objectContaining({
|
||||
type: 'chat:final',
|
||||
sessionKey: 'agent:test:main',
|
||||
runId: 'run-1',
|
||||
message: expect.objectContaining({
|
||||
_toolStatuses: [
|
||||
expect.objectContaining({
|
||||
name: 'browser.open_url',
|
||||
status: 'completed',
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -113,16 +146,45 @@ describe('gateway browser shortcut', () => {
|
||||
|
||||
await flushAsyncTasks();
|
||||
|
||||
expect(broadcast).toHaveBeenNthCalledWith(1, expect.objectContaining({
|
||||
type: 'tool:status',
|
||||
runId: 'run-2',
|
||||
toolName: 'browser.open_url',
|
||||
status: 'running',
|
||||
}));
|
||||
expect(broadcast).toHaveBeenNthCalledWith(2, expect.objectContaining({
|
||||
type: 'tool:status',
|
||||
runId: 'run-2',
|
||||
toolName: 'browser.open_url',
|
||||
status: 'error',
|
||||
}));
|
||||
expect(mocks.appendMessage).toHaveBeenCalledWith(
|
||||
'agent:test:main',
|
||||
expect.objectContaining({
|
||||
role: 'assistant',
|
||||
content: '打开失败:No browser context available',
|
||||
_toolStatuses: [
|
||||
expect.objectContaining({
|
||||
name: 'browser.open_url',
|
||||
status: 'error',
|
||||
result: {
|
||||
error: 'No browser context available',
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
);
|
||||
expect(broadcast).toHaveBeenCalledWith(expect.objectContaining({
|
||||
expect(broadcast).toHaveBeenNthCalledWith(3, expect.objectContaining({
|
||||
type: 'chat:final',
|
||||
runId: 'run-2',
|
||||
message: expect.objectContaining({
|
||||
_toolStatuses: [
|
||||
expect.objectContaining({
|
||||
name: 'browser.open_url',
|
||||
status: 'error',
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user