feat: integrate production cockpit AI assistant

This commit is contained in:
vee
2026-09-08 17:46:07 +08:00
parent 5e228e12ae
commit 93103c2579
66 changed files with 11046 additions and 374 deletions
+32 -2
View File
@@ -130,6 +130,8 @@ for raw_line in sys.stdin:
elif method == "thread/start":
thread_number += 1
thread_id = f"thread-{thread_number}"
if "DELAY_THREAD_START" in str(params.get("developerInstructions") or ""):
time.sleep(0.15)
emit(
{
"id": request_id,
@@ -145,6 +147,8 @@ for raw_line in sys.stdin:
turn_id = f"turn-{turn_number}"
thread_id = str(params.get("threadId"))
text = str((params.get("input") or [{}])[0].get("text") or "")
if "DELAY_TURN_START" in text:
time.sleep(0.15)
# Emit before the RPC response to exercise out-of-order event backlog.
emit(
{
@@ -182,6 +186,32 @@ for raw_line in sys.stdin:
}
)
continue
structured_answer = json.dumps(
{
"requests": [
{
"capability": "climate.set_temperature",
"target_scope": "vehicle",
"parameters": {"temperature_c": 24},
},
{
"capability": "roof.set_shade_position",
"target_scope": "vehicle",
"parameters": {"position_pct": 100},
},
],
"ambiguities": [],
"confidence": 0.94,
},
ensure_ascii=False,
separators=(",", ":"),
)
answer_text = structured_answer if params.get("outputSchema") else "协议正常"
answer_deltas = (
(answer_text[: len(answer_text) // 2], answer_text[len(answer_text) // 2 :])
if params.get("outputSchema")
else ("协议", "正常")
)
item_id = f"answer-{turn_number}"
emit(
{
@@ -199,7 +229,7 @@ for raw_line in sys.stdin:
},
}
)
for delta in ("协议", "正常"):
for delta in answer_deltas:
emit(
{
"method": "item/agentMessage/delta",
@@ -221,7 +251,7 @@ for raw_line in sys.stdin:
"item": {
"id": item_id,
"type": "agentMessage",
"text": "协议正常",
"text": answer_text,
"phase": "final_answer",
},
},