mqtt切换为远程服务器部署,优化简单指令解析时长
This commit is contained in:
@@ -287,6 +287,59 @@ test("a completed NDJSON answer remains the authoritative visible response", asy
|
||||
assert.equal(harness.completed[0].error, null);
|
||||
});
|
||||
|
||||
test("assistant bridges request start and validated local controls to the console", async () => {
|
||||
const payload = {
|
||||
request_id: "req-local-mixed",
|
||||
utterance: "空调温度设置到23度,打开闪烁灯",
|
||||
execution_mode: "dry_run",
|
||||
provider_used: "local_rules+infrared_local_rules",
|
||||
validated_control_commands: [
|
||||
{
|
||||
operation: {
|
||||
id: "climate-temperature-1",
|
||||
capability: "climate.set_temperature",
|
||||
target: { zone: "driver" },
|
||||
parameters: { temperature_c: 23 },
|
||||
parse_source: "local_rule",
|
||||
},
|
||||
channel: "CAN1",
|
||||
actual_command: "ac temp driver 23",
|
||||
frames: [{
|
||||
label: "CAN1 帧",
|
||||
value: "0x1DE · 00 00 00 00 17 00 00 00",
|
||||
}],
|
||||
},
|
||||
],
|
||||
trace_events: [{ stage: "compile", duration_ms: 2 }],
|
||||
};
|
||||
const harness = createHarness([
|
||||
{ type: "validated_control_commands", payload },
|
||||
{ type: "answer.completed", route: "vehicle_control", answer: "模拟编排已完成。" },
|
||||
]);
|
||||
const starts = [];
|
||||
const validated = [];
|
||||
harness.sandbox.addEventListener("cognitive-agent:control-request-start", (event) => {
|
||||
starts.push(event.detail);
|
||||
});
|
||||
harness.sandbox.addEventListener("cognitive-agent:validated-can-commands", (event) => {
|
||||
validated.push(event.detail);
|
||||
});
|
||||
harness.input.value = payload.utterance;
|
||||
harness.input.dataset.speechUtteranceId = "speech-local-mixed";
|
||||
harness.input.dataset.speechValue = payload.utterance;
|
||||
|
||||
await harness.sandbox.CognitiveAgentAssistant.submit();
|
||||
|
||||
assert.deepEqual(JSON.parse(JSON.stringify(starts)), [{
|
||||
utterance: payload.utterance,
|
||||
speech_utterance_id: "speech-local-mixed",
|
||||
speech_value: payload.utterance,
|
||||
}]);
|
||||
assert.deepEqual(JSON.parse(JSON.stringify(validated)), [payload]);
|
||||
assert.equal(harness.requestCalls.length, 1);
|
||||
assert.equal(JSON.parse(harness.requestCalls[0].options.body).execution_mode, "dry_run");
|
||||
});
|
||||
|
||||
test("unsupported-control suggestions render once and click through as a new command", async () => {
|
||||
const suggestions = [
|
||||
{ id: "climate-on", label: "打开空调", command: "打开空调", domain: "climate" },
|
||||
|
||||
Reference in New Issue
Block a user