feat: improve mode and peripheral orchestration

This commit is contained in:
Miayui
2026-09-21 00:13:47 +08:00
parent 89707a42e2
commit 448c8b31a0
39 changed files with 3068 additions and 277 deletions
+19 -1
View File
@@ -17,6 +17,8 @@ function createConversationId() {
return createOpaqueId("conv");
}
const HARDWARE_CLIENT_ID_PATTERN = /^hwc-[a-z0-9-]{8,80}$/;
function loadConversationId() {
const stored = sessionStorage.getItem("cognitive-agent.conversation-id");
// A browser runtime restart is a new virtual run. Do not reuse the old
@@ -33,12 +35,19 @@ function loadConversationId() {
function loadHardwareClientId() {
const key = "cognitive-agent.hardware-client-id";
const stored = localStorage.getItem(key);
if (/^hwc-[a-z0-9-]{8,80}$/.test(stored || "")) return stored;
if (HARDWARE_CLIENT_ID_PATTERN.test(stored || "")) return stored;
const clientId = createOpaqueId("hwc");
localStorage.setItem(key, clientId);
return clientId;
}
function validatedHardwareClientId() {
if (!HARDWARE_CLIENT_ID_PATTERN.test(state.hardwareClientId || "")) {
state.hardwareClientId = loadHardwareClientId();
}
return state.hardwareClientId;
}
function loadControlTransport() {
const stored = localStorage.getItem("cognitive-agent.control-transport");
return ["wired_can", "wireless_mqtt"].includes(stored) ? stored : "wired_can";
@@ -5131,6 +5140,7 @@ const MODE_DOMAIN_LABELS = {
window: "车窗",
front_light: "车灯",
vehicle_status: "车辆状态",
android: "车机媒体",
};
const MODE_TARGET_LABELS = {
@@ -5140,6 +5150,7 @@ const MODE_TARGET_LABELS = {
front_right: "右前 / 副驾",
rear_left: "左后",
rear_right: "右后",
headunit: "车机",
front_row: "前排",
rear_row: "后排",
vehicle: "全车",
@@ -8241,6 +8252,7 @@ const CONFIG_DOMAIN_META = {
window: { label: "车窗", icon: "panels-top-left", className: "generic" },
outlet: { label: "电动风口", icon: "wind", className: "climate" },
interior_light: { label: "车内灯", icon: "lightbulb", className: "ambient" },
android: { label: "车机媒体", icon: "clapperboard", className: "generic" },
};
const CONFIG_CAPABILITY_LABELS = {
@@ -8286,6 +8298,7 @@ const CONFIG_CAPABILITY_LABELS = {
"roof.set_shade_position": "设置遮阳帘位置",
"roof.set_shade_motion": "控制遮阳帘动作",
"roof.set_automatic_dimming": "设置自动调光",
"android.launch_app": "打开视频媒体",
};
const CONFIG_PARAMETER_LABELS = {
@@ -8309,6 +8322,8 @@ const CONFIG_PARAMETER_LABELS = {
outlet_mode: "出风模式",
mode: "工作模式",
mode_id: "固件模式编号",
package_name: "应用包名",
activity_name: "启动页面",
};
function makeConfigElement(tagName, className, textValue) {
@@ -9412,6 +9427,9 @@ window.CognitiveAgentConsole = {
getExecutionMode() {
return state.executionMode;
},
getHardwareClientId() {
return validatedHardwareClientId();
},
getConversationId() {
return state.conversationId;
},