filterAllowedTools keeps only tools whose names match an entry in allowed (filepath.Match-style glob, falling back to an exact match). An empty allow-list imposes no restriction. Used by fork-mode skill sub-sessions that declare an allowed-tools list.
(agentTools []tools.Tool, allowed []string)
| 1227 | // allow-list imposes no restriction. Used by fork-mode skill sub-sessions |
| 1228 | // that declare an allowed-tools list. |
| 1229 | func filterAllowedTools(agentTools []tools.Tool, allowed []string) []tools.Tool { |
| 1230 | if len(allowed) == 0 { |
| 1231 | return agentTools |
| 1232 | } |
| 1233 | filtered := make([]tools.Tool, 0, len(agentTools)) |
| 1234 | for _, t := range agentTools { |
| 1235 | if toolNameMatchesAny(t.Name, allowed) { |
| 1236 | filtered = append(filtered, t) |
| 1237 | } |
| 1238 | } |
| 1239 | return filtered |
| 1240 | } |
| 1241 | |
| 1242 | // toolNameMatchesAny reports whether name matches any of the patterns. Each |
| 1243 | // pattern is tried as a filepath.Match glob; a malformed pattern falls back |