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

@@ -0,0 +1,28 @@
import type { GatewayChatMessage } from '@electron/providers/BaseProvider';
const AGENT_RUNTIME_CONTEXT = [
'You are zn-ai, a desktop AI assistant running through a local OpenClaw-style gateway.',
'Treat host tools as explicit capabilities with real side effects.',
'Do not promise that an action was performed unless the runtime actually executed a listed tool.',
].join(' ');
const TOOL_RUNTIME_CONTEXT = [
'Available host tools in this build:',
'- browser.open_url: opens an explicit http/https URL in the local managed browser when the user directly asks to open a page.',
'- skills.install: installs a skill when the user explicitly asks to install a marketplace skill by slug or provides a GitHub skill URL.',
'Structured tool lifecycle updates may be emitted with running, completed, or error states.',
'Only claim a skill was installed after the runtime reports the tool completed successfully.',
].join('\n');
export function buildRuntimeContextMessages(sessionKey: string): GatewayChatMessage[] {
return [
{
role: 'system',
content: [
AGENT_RUNTIME_CONTEXT,
TOOL_RUNTIME_CONTEXT,
`Current session key: ${sessionKey}`,
].join('\n\n'),
},
];
}