chore: commit workspace updates

This commit is contained in:
ddCat
2026-09-14 01:11:56 +08:00
parent 01a2d171f5
commit 9727656b2b
491 changed files with 12826 additions and 72249 deletions

View File

@@ -0,0 +1,33 @@
package app
import (
"bytes"
"encoding/json"
"errors"
"io"
)
var errCloudAgentJSONSingleObject = errors.New("参数必须是单个 JSON 对象")
// decodeCloudAgentJSONObject is used for model tool arguments. Tool arguments
// are an untrusted protocol boundary: reject non-objects, unknown fields and
// trailing JSON instead of silently accepting an ambiguous payload.
func decodeCloudAgentJSONObject(raw string, target any) error {
data := bytes.TrimSpace([]byte(raw))
if len(data) == 0 || data[0] != '{' {
return errCloudAgentJSONSingleObject
}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
if err := decoder.Decode(target); err != nil {
return err
}
var extra any
if err := decoder.Decode(&extra); err != io.EOF {
if err == nil {
return errCloudAgentJSONSingleObject
}
return err
}
return nil
}