| 1 | package tool |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "encoding/json" |
| 6 | ) |
| 7 | |
| 8 | // ResolvedCall is the real target behind a proxy tool such as use_capability. |
| 9 | // Permission, hooks, read-only classification, and evidence use TargetName and |
| 10 | // Target; the provider transcript keeps the original proxy tool-call name. |
| 11 | type ResolvedCall struct { |
| 12 | // DisplayName is the proxy tool name shown in provider tool-call protocol |
| 13 | // matching (e.g. "use_capability"). |
| 14 | DisplayName string |
| 15 | // TargetName is the real tool name for permission/hooks/evidence |
| 16 | // (e.g. "mcp__github__search_issues"). |
| 17 | TargetName string |
| 18 | // Args are the arguments to pass to Target.Execute. |
| 19 | Args json.RawMessage |
| 20 | // Target is the concrete tool to execute. Nil means resolve-only metadata. |
| 21 | Target Tool |
| 22 | // ReadOnly is the effective read-only flag for the resolved target. |
| 23 | ReadOnly bool |
| 24 | // ProxyAction is inspect|call|decline for audit surfaces. |
| 25 | ProxyAction string |
| 26 | // CapabilityID is the capability catalog id being acted on. |
| 27 | CapabilityID string |
| 28 | // SkipExecute is set when resolution produced the final result without |
| 29 | // running a target tool (inspect, decline, unavailable, or an already- |
| 30 | // connected server directory call). |
| 31 | SkipExecute bool |
| 32 | // HostCompleted marks a call action whose final read-only result was produced |
| 33 | // and safety-checked by the host during resolution. Strict read-only agents |
| 34 | // use it to distinguish a validated connected-server directory from an |
| 35 | // unresolved dynamic call with a missing target. |
| 36 | HostCompleted bool |
| 37 | // Result is a precomputed result when SkipExecute is true. |
| 38 | Result string |
| 39 | // Unavailable marks a host-proven unavailable capability. |
| 40 | Unavailable bool |
| 41 | // UnavailableReason is the host-proven failure detail. |
| 42 | UnavailableReason string |
| 43 | // Commit applies a resolve-only state transition after the host has checked |
| 44 | // the resolved call. Proxy resolvers must not mutate host state before this |
| 45 | // callback runs: read-only agents may reject the action after resolution. |
| 46 | Commit func() error |
| 47 | } |
| 48 | |
| 49 | // CallResolver is implemented by proxy tools that map a model-visible call onto |
| 50 | // a real MCP (or other) target before permission, hooks, and evidence run. |
| 51 | type CallResolver interface { |
| 52 | ResolveCall(ctx context.Context, args json.RawMessage) (ResolvedCall, error) |
| 53 | } |
| 54 |