MCPcopy Create free account
hub / github.com/compozy/agh / redactToolRawJSON

Function redactToolRawJSON

internal/cli/client_tools.go:231–251  ·  view source on GitHub ↗
(raw json.RawMessage)

Source from the content-addressed store, hash-verified

229}
230
231func redactToolRawJSON(raw json.RawMessage) json.RawMessage {
232 if len(raw) == 0 {
233 return raw
234 }
235 decoder := json.NewDecoder(strings.NewReader(string(raw)))
236 decoder.UseNumber()
237 var value any
238 if err := decoder.Decode(&value); err != nil || decoder.Decode(&struct{}{}) != io.EOF {
239 redacted := redactToolDiagnostic(string(raw))
240 if !json.Valid([]byte(redacted)) {
241 return raw
242 }
243 return json.RawMessage(redacted)
244 }
245 redacted := redactToolJSONValue(value)
246 payload, err := json.Marshal(redacted)
247 if err != nil {
248 return raw
249 }
250 return json.RawMessage(payload)
251}
252
253func redactToolJSONValue(value any) any {
254 switch typed := value.(type) {

Callers 3

redactToolMetadataFunction · 0.85

Calls 3

redactToolDiagnosticFunction · 0.85
redactToolJSONValueFunction · 0.85
ValidMethod · 0.45

Tested by 1