| 5 | ) |
| 6 | |
| 7 | func TestRecord_Claude(t *testing.T) { |
| 8 | s := NewStore() |
| 9 | rawJSON := []byte(`{ |
| 10 | "model": "claude-3-opus", |
| 11 | "messages": [{"role": "user", "content": "hi"}], |
| 12 | "tools": [ |
| 13 | {"name": "Bash", "description": "Run bash", "input_schema": {"type": "object", "properties": {"command": {"type": "string"}}}}, |
| 14 | {"name": "Read", "description": "Read file", "input_schema": {"type": "object", "properties": {"path": {"type": "string"}}}} |
| 15 | ] |
| 16 | }`) |
| 17 | |
| 18 | s.Record(rawJSON, "claude") |
| 19 | tools := s.List() |
| 20 | |
| 21 | if len(tools) != 2 { |
| 22 | t.Fatalf("expected 2 tools, got %d", len(tools)) |
| 23 | } |
| 24 | |
| 25 | // Sorted by name |
| 26 | if tools[0].Name != "Bash" || tools[0].Format != "claude" { |
| 27 | t.Errorf("unexpected tool[0]: %+v", tools[0]) |
| 28 | } |
| 29 | if tools[1].Name != "Read" || tools[1].Format != "claude" { |
| 30 | t.Errorf("unexpected tool[1]: %+v", tools[1]) |
| 31 | } |
| 32 | if tools[0].Schema == nil { |
| 33 | t.Error("expected schema for Bash tool") |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func TestRecord_OpenAI(t *testing.T) { |
| 38 | s := NewStore() |