Skip to content

Commit 32add9a

Browse files
committed
refactor(tool): migrate terminal tools to typed schemas
1 parent d5c4f48 commit 32add9a

2 files changed

Lines changed: 258 additions & 158 deletions

File tree

‎internal/tool/schema_batch_test.go‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,3 +1303,79 @@ func TestSmartCreateSchemaProvider(t *testing.T) {
13031303
t.Fatalf("required = %v, want [path]", (&SmartCreateTool{}).Parameters()["required"])
13041304
}
13051305
}
1306+
1307+
func TestTerminalCreateSchemaProvider(t *testing.T) {
1308+
var _ SchemaProvider = TerminalCreateTool{}
1309+
props := schemaProps(t, TerminalCreateTool{}.Parameters())
1310+
if props["command"].(map[string]interface{})["type"] != "string" {
1311+
t.Fatal("command type wrong")
1312+
}
1313+
if props["rows"].(map[string]interface{})["type"] != "integer" {
1314+
t.Fatal("rows type wrong")
1315+
}
1316+
if props["cols"].(map[string]interface{})["type"] != "integer" {
1317+
t.Fatal("cols type wrong")
1318+
}
1319+
}
1320+
1321+
func TestTerminalSendSchemaProvider(t *testing.T) {
1322+
var _ SchemaProvider = TerminalSendTool{}
1323+
props := schemaProps(t, TerminalSendTool{}.Parameters())
1324+
if props["terminal_id"].(map[string]interface{})["type"] != "string" {
1325+
t.Fatal("terminal_id type wrong")
1326+
}
1327+
if props["send_enter"].(map[string]interface{})["type"] != "boolean" {
1328+
t.Fatal("send_enter type wrong")
1329+
}
1330+
req, _ := TerminalSendTool{}.Parameters()["required"].([]string)
1331+
if len(req) != 2 || req[0] != "terminal_id" || req[1] != "input" {
1332+
t.Fatalf("required = %v, want [terminal_id input]", TerminalSendTool{}.Parameters()["required"])
1333+
}
1334+
}
1335+
1336+
func TestTerminalReadSchemaProvider(t *testing.T) {
1337+
var _ SchemaProvider = TerminalReadTool{}
1338+
props := schemaProps(t, TerminalReadTool{}.Parameters())
1339+
if props["max_bytes"].(map[string]interface{})["type"] != "integer" {
1340+
t.Fatal("max_bytes type wrong")
1341+
}
1342+
if props["timeout_ms"].(map[string]interface{})["type"] != "integer" {
1343+
t.Fatal("timeout_ms type wrong")
1344+
}
1345+
req, _ := TerminalReadTool{}.Parameters()["required"].([]string)
1346+
if len(req) != 1 || req[0] != "terminal_id" {
1347+
t.Fatalf("required = %v, want [terminal_id]", TerminalReadTool{}.Parameters()["required"])
1348+
}
1349+
}
1350+
1351+
func TestTerminalListSchemaProvider(t *testing.T) {
1352+
var _ SchemaProvider = TerminalListTool{}
1353+
props := schemaProps(t, TerminalListTool{}.Parameters())
1354+
if props["session_id"].(map[string]interface{})["type"] != "string" {
1355+
t.Fatal("session_id type wrong")
1356+
}
1357+
}
1358+
1359+
func TestTerminalResizeSchemaProvider(t *testing.T) {
1360+
var _ SchemaProvider = TerminalResizeTool{}
1361+
props := schemaProps(t, TerminalResizeTool{}.Parameters())
1362+
if props["rows"].(map[string]interface{})["type"] != "integer" {
1363+
t.Fatal("rows type wrong")
1364+
}
1365+
req, _ := TerminalResizeTool{}.Parameters()["required"].([]string)
1366+
if len(req) != 3 || req[0] != "terminal_id" || req[1] != "rows" || req[2] != "cols" {
1367+
t.Fatalf("required = %v, want [terminal_id rows cols]", TerminalResizeTool{}.Parameters()["required"])
1368+
}
1369+
}
1370+
1371+
func TestTerminalKillSchemaProvider(t *testing.T) {
1372+
var _ SchemaProvider = TerminalKillTool{}
1373+
props := schemaProps(t, TerminalKillTool{}.Parameters())
1374+
if props["terminal_id"].(map[string]interface{})["type"] != "string" {
1375+
t.Fatal("terminal_id type wrong")
1376+
}
1377+
req, _ := TerminalKillTool{}.Parameters()["required"].([]string)
1378+
if len(req) != 1 || req[0] != "terminal_id" {
1379+
t.Fatalf("required = %v, want [terminal_id]", TerminalKillTool{}.Parameters()["required"])
1380+
}
1381+
}

0 commit comments

Comments
 (0)