MCPcopy
hub / github.com/wavetermdev/waveterm / parseReadDirInput

Function parseReadDirInput

pkg/aiusechat/tools_readdir.go:25–54  ·  view source on GitHub ↗
(input any)

Source from the content-addressed store, hash-verified

23}
24
25func parseReadDirInput(input any) (*readDirParams, error) {
26 result := &readDirParams{}
27
28 if input == nil {
29 return nil, fmt.Errorf("input is required")
30 }
31
32 if err := utilfn.ReUnmarshal(result, input); err != nil {
33 return nil, fmt.Errorf("invalid input format: %w", err)
34 }
35
36 if result.Path == "" {
37 return nil, fmt.Errorf("missing path parameter")
38 }
39
40 if result.MaxEntries == nil {
41 maxEntries := ReadDirDefaultMaxEntries
42 result.MaxEntries = &maxEntries
43 }
44
45 if *result.MaxEntries < 1 {
46 return nil, fmt.Errorf("max_entries must be at least 1, got %d", *result.MaxEntries)
47 }
48
49 if *result.MaxEntries > ReadDirHardMaxEntries {
50 return nil, fmt.Errorf("max_entries cannot exceed %d, got %d", ReadDirHardMaxEntries, *result.MaxEntries)
51 }
52
53 return result, nil
54}
55
56func verifyReadDirInput(input any, toolUseData *uctypes.UIMessageDataToolUse) error {
57 params, err := parseReadDirInput(input)

Callers 4

TestParseReadDirInputFunction · 0.85
verifyReadDirInputFunction · 0.85
readDirCallbackFunction · 0.85
GetReadDirToolDefinitionFunction · 0.85

Calls 1

ReUnmarshalFunction · 0.92

Tested by 1

TestParseReadDirInputFunction · 0.68