use serde_json::{Value, json};
pub const SUBTOPICS: [&str; 9] = [
"event sourcing",
"write-ahead logging",
"idempotency keys",
"crash recovery",
"replay determinism",
"suspension and approval",
"budget enforcement",
"side-effect classification",
"process supervision",
];
#[must_use]
pub fn finding_line(subtopic: &str) -> String {
format!("{subtopic}: noted for the report")
}
fn tool_use_response(
tool_use_id: &str,
tool: &str,
input: Value,
input_tokens: u64,
output_tokens: u64,
) -> Value {
json!({
"id": format!("msg_tool_{tool_use_id}"),
"model": "salvor-demo-model",
"role": "assistant",
"content": [{"type": "tool_use", "id": tool_use_id, "name": tool, "input": input}],
"stop_reason": "tool_use",
"usage": {"input_tokens": input_tokens, "output_tokens": output_tokens}
})
}
fn text_response(text: &str, input_tokens: u64, output_tokens: u64) -> Value {
json!({
"id": "msg_text",
"model": "salvor-demo-model",
"role": "assistant",
"content": [{"type": "text", "text": text}],
"stop_reason": "end_turn",
"usage": {"input_tokens": input_tokens, "output_tokens": output_tokens}
})
}
#[must_use]
pub fn script() -> Vec<(usize, Value)> {
let mut script = Vec::with_capacity(20);
for (index, subtopic) in SUBTOPICS.iter().enumerate() {
let search_turn = 2 * index + 1;
let save_turn = search_turn + 1;
script.push((
2 * search_turn - 1,
tool_use_response(
&format!("tu_search_{}", index + 1),
"search_notes",
json!({ "query": subtopic }),
200,
20,
),
));
script.push((
2 * save_turn - 1,
tool_use_response(
&format!("tu_save_{}", index + 1),
"save_finding",
json!({ "finding": finding_line(subtopic) }),
210,
21,
),
));
}
script.push((
2 * 19 - 1,
tool_use_response("tu_count", "get_finding_count", json!({}), 220, 22),
));
script.push((
2 * 20 - 1,
text_response("Research complete: 9 findings saved.", 230, 30),
));
script
}