ExecuteWithStream mirrors Execute — no incremental output.
(_ context.Context, args []string, _ func(string))
| 109 | |
| 110 | // ExecuteWithStream mirrors Execute — no incremental output. |
| 111 | func (p *BuiltinToolsPlugin) ExecuteWithStream(_ context.Context, args []string, _ func(string)) (string, error) { |
| 112 | adapter := currentToolCatalogAdapter() |
| 113 | if adapter == nil { |
| 114 | return "", errors.New("@tools: no tool-catalog adapter wired in this session") |
| 115 | } |
| 116 | if len(args) == 0 { |
| 117 | return "", errors.New(`@tools: empty args. Example: <tool_call name="@tools" args='{"cmd":"describe","args":{"name":"@diagram"}}' />`) |
| 118 | } |
| 119 | |
| 120 | cmd, inner, err := parseToolsInvocation(args) |
| 121 | if err != nil { |
| 122 | return "", fmt.Errorf("@tools: %w", err) |
| 123 | } |
| 124 | switch cmd { |
| 125 | case "describe": |
| 126 | var in struct { |
| 127 | Name string `json:"name"` |
| 128 | } |
| 129 | _ = json.Unmarshal([]byte(inner), &in) |
| 130 | if strings.TrimSpace(in.Name) == "" { |
| 131 | return "", errors.New(`@tools describe: "name" is required`) |
| 132 | } |
| 133 | return adapter.Describe(in.Name) |
| 134 | case "list": |
| 135 | return adapter.List() |
| 136 | default: |
| 137 | return "", fmt.Errorf("@tools: unknown cmd %q (valid: describe|list)", cmd) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | // parseToolsInvocation accepts the JSON envelope {cmd, args} or the argv form |
| 142 | // ("describe @diagram" / "list"). |
no test coverage detected