feat: add dynamic Robot configuration choices

This commit is contained in:
2026-08-16 00:55:06 +08:00
parent 7bef261fb8
commit fe55deed04
7 changed files with 524 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ import {
getAiHardwareAgentConfiguration,
getAiHardwareAssignment,
getAiHardwareOverview,
getAiHardwareConfigurationCatalog,
updateAiHardwareAgentConfiguration,
updateAiHardwareAssignment,
createAiHardwareOperationId,
@@ -56,6 +57,44 @@ describe('AI hardware renderer API', () => {
expect(hostApiFetchMock).toHaveBeenCalledWith('/api/works/ai-hardware', undefined);
});
it('strictly reads the safe configuration catalog and encodes the TTS dependency', async () => {
const catalog = {
schema_version: 1,
models: [{
model_type: 'TTS', model_id: 'TTS:model', model_name: '云端语音',
supports_function_call: null,
}],
voices: [{
tts_model_id: 'TTS:model', voice_id: 'voice-1', voice_name: '小夏',
languages: ['zh-CN'], is_clone: false,
}],
};
hostApiFetchMock.mockResolvedValue({ success: true, data: catalog });
await expect(getAiHardwareConfigurationCatalog('TTS:model')).resolves.toEqual(catalog);
expect(hostApiFetchMock).toHaveBeenCalledWith(
'/api/works/ai-hardware/catalog?tts_model_id=TTS%3Amodel',
undefined,
);
});
it('rejects unsafe or expanded catalog DTOs', async () => {
hostApiFetchMock.mockResolvedValue({ success: true, data: {
schema_version: 1,
models: [{
model_type: 'TTS', model_id: 'TTS_model', model_name: '语音',
supports_function_call: null, config_json: '{"api_key":"secret"}',
}],
voices: [],
} });
await expect(getAiHardwareConfigurationCatalog()).rejects.toMatchObject({
code: 'AI_HARDWARE_INVALID_RESPONSE',
});
expect(JSON.stringify(await getAiHardwareConfigurationCatalog().catch((error) => error)))
.not.toContain('secret');
});
it('sends create and bind business bodies without sensitive headers', async () => {
hostApiFetchMock
.mockResolvedValueOnce({ success: true, data: agent })