internal/mcp: clean up handling of content
Add support for all content types, and formalize the conversion of content to and from the wire format (as a discriminated union). Change-Id: I93678ce98c02176a524d2c82425fb1267ad68bf0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/669135 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Auto-Submit: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
af4d138732
commit
bf608eeeae
1 changed files with 282 additions and 104 deletions
|
|
@ -91,7 +91,6 @@ var declarations = config{
|
|||
"Tools": {Name: "ToolCapabilities"},
|
||||
},
|
||||
},
|
||||
"TextContent": {Name: "TextContent"},
|
||||
"Tool": {
|
||||
Name: "Tool",
|
||||
Fields: config{"InputSchema": {Substitute: "*jsonschema.Schema"}},
|
||||
|
|
@ -249,8 +248,15 @@ func writeType(w io.Writer, config *typeConfig, def *jsonschema.Schema, named ma
|
|||
}
|
||||
|
||||
if def.Type == "" {
|
||||
// E.g. union types.
|
||||
fmt.Fprintf(w, "json.RawMessage")
|
||||
// special case: recognize Content
|
||||
if slices.ContainsFunc(def.AnyOf, func(s *jsonschema.Schema) bool {
|
||||
return s.Ref == "#/definitions/TextContent"
|
||||
}) {
|
||||
fmt.Fprintf(w, "Content")
|
||||
} else {
|
||||
// E.g. union types.
|
||||
fmt.Fprintf(w, "json.RawMessage")
|
||||
}
|
||||
} else {
|
||||
switch def.Type {
|
||||
case "array":
|
||||
|
|
|
|||
Loading…
Reference in a new issue