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:
duanshuwen
2026-04-23 20:27:54 +08:00
parent 979fb0a0f6
commit df600272d6
29 changed files with 2041 additions and 384 deletions

View File

@@ -120,6 +120,48 @@ describe('gateway event dispatch', () => {
]);
});
it('dispatches protocol tool lifecycle events onto the normalized tool status channel', () => {
const { emitter, events } = createEmitterRecorder();
dispatchProtocolEvent(emitter, GatewayEventType.TOOL_CALL_STARTED, {
sessionKey: 'agent:test:main',
runId: 'run-1',
toolName: 'browser.open_url',
});
dispatchProtocolEvent(emitter, GatewayEventType.TOOL_CALL_COMPLETED, {
sessionKey: 'agent:test:main',
runId: 'run-1',
toolName: 'browser.open_url',
durationMs: 42,
});
expect(events).toEqual([
{
event: 'tool:status',
payload: {
status: 'running',
payload: {
sessionKey: 'agent:test:main',
runId: 'run-1',
toolName: 'browser.open_url',
},
},
},
{
event: 'tool:status',
payload: {
status: 'completed',
payload: {
sessionKey: 'agent:test:main',
runId: 'run-1',
toolName: 'browser.open_url',
durationMs: 42,
},
},
},
]);
});
it('dispatches unknown protocol events to notification listeners', () => {
const { emitter, events } = createEmitterRecorder();
@@ -146,6 +188,11 @@ describe('gateway event dispatch', () => {
method: GatewayEventType.MESSAGE_RECEIVED,
params: { message: { text: 'hello' } },
});
dispatchJsonRpcNotification(emitter, {
jsonrpc: '2.0',
method: GatewayEventType.TOOL_CALL_STARTED,
params: { sessionKey: 'agent:test:main', runId: 'run-2', toolName: 'browser.open_url' },
});
dispatchJsonRpcNotification(emitter, {
jsonrpc: '2.0',
method: GatewayEventType.ERROR,
@@ -176,9 +223,24 @@ describe('gateway event dispatch', () => {
event: 'chat:message',
payload: { message: { text: 'hello' } },
});
expect(events[4].event).toBe('notification');
expect(events[5].event).toBe('error');
expect((events[5].payload as Error).message).toBe('gateway boom');
expect(events[4]).toEqual({
event: 'notification',
payload: {
jsonrpc: '2.0',
method: GatewayEventType.TOOL_CALL_STARTED,
params: { sessionKey: 'agent:test:main', runId: 'run-2', toolName: 'browser.open_url' },
},
});
expect(events[5]).toEqual({
event: 'tool:status',
payload: {
status: 'running',
payload: { sessionKey: 'agent:test:main', runId: 'run-2', toolName: 'browser.open_url' },
},
});
expect(events[6].event).toBe('notification');
expect(events[7].event).toBe('error');
expect((events[7].payload as Error).message).toBe('gateway boom');
});
});