agent_block_testkit/shapes/
anthropic.rs1use serde_json::{json, Value};
9use std::sync::atomic::{AtomicUsize, Ordering};
10
11static RESPONSE_SEQ: AtomicUsize = AtomicUsize::new(0);
12
13fn next_id(prefix: &str) -> String {
14 format!(
15 "{prefix}-{}",
16 RESPONSE_SEQ.fetch_add(1, Ordering::Relaxed) + 1
17 )
18}
19
20pub fn tool_use(id: &str, name: &str, input: Value) -> Value {
22 json!({ "type": "tool_use", "id": id, "name": name, "input": input })
23}
24
25pub fn text_response(text: &str) -> Value {
27 json!({
28 "id": next_id("msg-testkit"),
29 "type": "message",
30 "role": "assistant",
31 "content": [{ "type": "text", "text": text }],
32 "model": "claude-testkit-mock",
33 "stop_reason": "end_turn",
34 "usage": { "input_tokens": 10, "output_tokens": 10 }
35 })
36}
37
38pub fn tool_use_response(blocks: Vec<Value>) -> Value {
40 json!({
41 "id": next_id("msg-testkit"),
42 "type": "message",
43 "role": "assistant",
44 "content": blocks,
45 "model": "claude-testkit-mock",
46 "stop_reason": "tool_use",
47 "usage": { "input_tokens": 10, "output_tokens": 10 }
48 })
49}