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

Function verifyWriteTextFileInput

pkg/aiusechat/tools_writefile.go:104–131  ·  view source on GitHub ↗
(input any, toolUseData *uctypes.UIMessageDataToolUse)

Source from the content-addressed store, hash-verified

102}
103
104func verifyWriteTextFileInput(input any, toolUseData *uctypes.UIMessageDataToolUse) error {
105 params, err := parseWriteTextFileInput(input)
106 if err != nil {
107 return err
108 }
109
110 expandedPath, err := wavebase.ExpandHomeDir(params.Filename)
111 if err != nil {
112 return fmt.Errorf("failed to expand path: %w", err)
113 }
114
115 if !filepath.IsAbs(expandedPath) {
116 return fmt.Errorf("path must be absolute, got relative path: %s", params.Filename)
117 }
118
119 contentsBytes := []byte(params.Contents)
120 if utilfn.HasBinaryData(contentsBytes) {
121 return fmt.Errorf("contents appear to contain binary data")
122 }
123
124 _, err = validateTextFile(expandedPath, "write to", false)
125 if err != nil {
126 return err
127 }
128
129 toolUseData.InputFileName = params.Filename
130 return nil
131}
132
133func writeTextFileCallback(input any, toolUseData *uctypes.UIMessageDataToolUse) (any, error) {
134 params, err := parseWriteTextFileInput(input)

Callers

nothing calls this directly

Calls 4

ExpandHomeDirFunction · 0.92
HasBinaryDataFunction · 0.92
parseWriteTextFileInputFunction · 0.85
validateTextFileFunction · 0.85

Tested by

no test coverage detected