Add unit tests for skill capabilities, skill planner, and UV setup

- Implement tests for random ID generation, ensuring preference for crypto.randomUUID.
- Create tests for runtime context capabilities, validating the injection of enabled skill capabilities.
- Add tests for skill capability parsing, including classification and command example extraction.
- Introduce tests for the skill planner, verifying tool call planning based on user requests and attachment requirements.
- Establish tests for UV setup, ensuring proper handling of Python installation scenarios and environment checks.
This commit is contained in:
DEV_DSW
2026-04-24 17:02:59 +08:00
parent e11a2296cc
commit 4c61e93c3e
42 changed files with 12560 additions and 224 deletions

View File

@@ -1,7 +1,7 @@
import logManager from '@electron/service/logger';
import { extractBrowserOpenIntent, openUrlInBrowser } from '@electron/service/browser-open-service';
import { appendTranscriptLine } from '@electron/utils/token-usage-writer';
import type { RawMessage, ToolStatus } from '@runtime/shared/chat-model';
import type { RawMessage, ToolResultPayload, ToolStatus } from '@runtime/shared/chat-model';
import { sessionStore } from './session-store';
import type { GatewayEvent } from './types';
@@ -25,6 +25,7 @@ async function processBrowserOpen(
const toolCallId = `browser.open_url:${runId}`;
const startedAt = Date.now();
let finalToolStatus: ToolStatus | null = null;
let finalToolResult: ToolResultPayload | null = null;
broadcast({
type: 'tool:status',
@@ -44,6 +45,15 @@ async function processBrowserOpen(
return;
}
assistantText = buildBrowserOpenResponseText(result);
finalToolResult = {
ok: true,
summary: assistantText,
structuredData: result,
renderHints: {
card: 'browser-step',
},
raw: result,
};
finalToolStatus = {
id: toolCallId,
toolCallId,
@@ -73,6 +83,18 @@ async function processBrowserOpen(
return;
}
assistantText = buildBrowserOpenErrorText(error);
finalToolResult = {
ok: false,
summary: assistantText,
error: error instanceof Error ? error.message : String(error),
retryable: true,
renderHints: {
card: 'browser-step',
},
raw: {
error: error instanceof Error ? error.message : String(error),
},
};
finalToolStatus = {
id: toolCallId,
toolCallId,
@@ -107,6 +129,7 @@ async function processBrowserOpen(
role: 'assistant',
content: assistantText,
timestamp: Date.now(),
toolResult: finalToolResult,
_toolStatuses: finalToolStatus ? [finalToolStatus] : undefined,
};
sessionStore.appendMessage(sessionKey, finalMessage);