kcode-k1-chat-chatend 0.7.0

Append-only open-format ChatBox state transitions for K1 chat
Documentation
use super::*;

#[test]
fn correlated_message_and_v2_result_recover() {
    let id = ToolCallId::new([1; 12], 1);
    let mut chat = Chatend::new();
    chat.start_round().unwrap();
    chat.append_stage(
        String::new(),
        vec![ProviderCall {
            tool_call_id: id,
            name: "WebSearch".into(),
            arguments: "{}".into(),
        }],
    )
    .unwrap();
    chat.accept_tool_message(id, "working".into()).unwrap();
    chat.accept_async_return_v2(
        id,
        Ok("done".into()),
        "k1.web-search-result/v1".into(),
        "{}".into(),
    )
    .unwrap();
    assert_eq!(chat.flush_active_arrivals().unwrap().len(), 2);
    assert_eq!(
        chat.accept_tool_message(id, "late".into()),
        Err(TransitionError::ToolMessageAfterResult)
    );
    Chatend::recover(chat.boxes().to_vec()).unwrap();
}