@@ -63,7 +63,7 @@ type SchemaPrimitive struct {
6363
6464func (s SchemaPrimitive ) Type () string { return s .Kind }
6565
66- type parser struct {
66+ type decoder struct {
6767 errors []error
6868}
6969
@@ -82,46 +82,46 @@ func LoadToolDefinitions(data []byte) (map[string]*ToolDef, error) {
8282 }
8383
8484 tools := map [string ]* ToolDef {}
85- parser := & parser {}
85+ decoder := & decoder {}
8686
8787 for _ , t := range defs .Tools {
8888 tools [t .Name ] = & ToolDef {
8989 Name : t .Name ,
9090 Description : t .Description ,
91- InputSchema : parser . parseRootSchema (t .InputSchema ),
92- OutputSchema : parser . parseRootSchema (t .OutputSchema ),
91+ InputSchema : decoder . decodeRootSchema (t .InputSchema ),
92+ OutputSchema : decoder . decodeRootSchema (t .OutputSchema ),
9393 }
9494 }
9595
96- if len (parser .errors ) > 0 {
97- return tools , errors .Append (nil , parser .errors ... )
96+ if len (decoder .errors ) > 0 {
97+ return tools , errors .Append (nil , decoder .errors ... )
9898 }
9999
100100 return tools , nil
101101}
102102
103- func (p * parser ) parseRootSchema (r RawSchema ) Schema {
103+ func (d * decoder ) decodeRootSchema (r RawSchema ) Schema {
104104 return Schema {
105105 Schema : r .SchemaVersion ,
106106 SchemaObject : SchemaObject {
107107 Kind : r .Type ,
108108 Description : r .Description ,
109109 Required : r .Required ,
110110 AdditionalProperties : r .AdditionalProperties ,
111- Properties : p . parseProperties (r .Properties ),
111+ Properties : d . decodeProperties (r .Properties ),
112112 },
113113 }
114114}
115115
116- func (p * parser ) parseSchema (r * RawSchema ) SchemaValue {
116+ func (p * decoder ) decodeSchema (r * RawSchema ) SchemaValue {
117117 switch r .Type {
118118 case "object" :
119119 return & SchemaObject {
120120 Kind : r .Type ,
121121 Description : r .Description ,
122122 Required : r .Required ,
123123 AdditionalProperties : r .AdditionalProperties ,
124- Properties : p .parseProperties (r .Properties ),
124+ Properties : p .decodeProperties (r .Properties ),
125125 }
126126 case "array" :
127127 var items SchemaValue
@@ -133,7 +133,7 @@ func (p *parser) parseSchema(r *RawSchema) SchemaValue {
133133 } else {
134134 var itemRaw RawSchema
135135 if err := json .Unmarshal (r .Items , & itemRaw ); err == nil {
136- items = p .parseSchema (& itemRaw )
136+ items = p .decodeSchema (& itemRaw )
137137 } else {
138138 p .errors = append (p .errors , errors .Errorf ("failed to unmarshal array items: %w" , err ))
139139 }
@@ -152,15 +152,15 @@ func (p *parser) parseSchema(r *RawSchema) SchemaValue {
152152 }
153153}
154154
155- func (p * parser ) parseProperties (props map [string ]json.RawMessage ) map [string ]SchemaValue {
155+ func (p * decoder ) decodeProperties (props map [string ]json.RawMessage ) map [string ]SchemaValue {
156156 res := make (map [string ]SchemaValue )
157157 for name , raw := range props {
158158 var r RawSchema
159159 if err := json .Unmarshal (raw , & r ); err != nil {
160160 p .errors = append (p .errors , fmt .Errorf ("failed to parse property %q: %w" , name , err ))
161161 continue
162162 }
163- res [name ] = p .parseSchema (& r )
163+ res [name ] = p .decodeSchema (& r )
164164 }
165165 return res
166166}
0 commit comments