Add chitchat state machine routing

This commit is contained in:
Jacob Dubin
2026-05-06 16:01:15 -05:00
parent 0ccfa5db68
commit 7d31c3390c
6 changed files with 366 additions and 4 deletions

View File

@@ -3241,6 +3241,36 @@ public sealed class JiboWebSocketServiceTests
Assert.Equal("idle", stateValue?.ToString());
}
[Fact]
public async Task ClientAsrChitchatEmotionCommand_PersistsSplitRouteMetadata()
{
const string routeKey = "chitchatRoute";
const string emotionKey = "chitchatEmotion";
var token = _store.IssueRobotToken("chitchat-emotion-device-a");
var replies = await _service.HandleMessageAsync(new WebSocketMessageEnvelope
{
HostName = "neo-hub.jibo.com",
Path = "/listen",
Kind = "neo-hub-listen",
Token = token,
Text = """{"type":"CLIENT_ASR","transID":"trans-chitchat-emotion","data":{"text":"smile"}}"""
});
Assert.Equal(3, replies.Count);
using (var listenPayload = JsonDocument.Parse(replies[0].Text!))
{
Assert.Equal("emotion_command", listenPayload.RootElement.GetProperty("data").GetProperty("nlu").GetProperty("intent").GetString());
}
var session = _store.FindSessionByToken(token);
Assert.NotNull(session);
Assert.True(session.Metadata.TryGetValue(routeKey, out var routeValue));
Assert.Equal("EmotionCommand", routeValue?.ToString());
Assert.True(session.Metadata.TryGetValue(emotionKey, out var emotionValue));
Assert.Equal("happy", emotionValue?.ToString());
}
[Fact]
public async Task FollowUpTurn_UsesNewTurnStateWithoutLeakingBufferedAudio()
{