MCPcopy Create free account
hub / github.com/diillson/chatcli / RunStructured

Function RunStructured

cli/plugins/capabilities.go:208–225  ·  view source on GitHub ↗

RunStructured executes the plugin and always returns a StructuredResult, preferring the structured executor when available and falling back to the legacy ExecuteWithStream pair otherwise. The infrastructure error (network timeout, ctx canceled, plugin binary not found) is returned separately so the

(ctx context.Context, p Plugin, args []string, onOutput func(string))

Source from the content-addressed store, hash-verified

206// timeout, ctx canceled, plugin binary not found) is returned separately so
207// the orchestrator can decide whether to abort the batch.
208func RunStructured(ctx context.Context, p Plugin, args []string, onOutput func(string)) (StructuredResult, error) {
209 if p == nil {
210 return StructuredResult{}, errNilPlugin
211 }
212 if se, ok := p.(StructuredExecutor); ok {
213 return se.ExecuteStructured(ctx, args, onOutput)
214 }
215 out, err := p.ExecuteWithStream(ctx, args, onOutput)
216 res := StructuredResult{Output: out}
217 if err != nil {
218 res.IsError = true
219 // ErrorCode classification lives in cli/agent — callers wrap this
220 // StructuredResult with agent.WrapStructuredResult to populate
221 // ErrorCode. Keeping the classifier out of this package avoids
222 // an import cycle (cli/plugins ↛ cli/agent).
223 }
224 return res, err
225}

Calls 2

ExecuteStructuredMethod · 0.80
ExecuteWithStreamMethod · 0.65