Add github_code_search tool + scanned key type field

- New tool: github_code_search (GitHub Code Search API with text-match fragments)
- Tool available when GitHubToken is configured in server settings
- Registered in AnthropicService + ChatService tool pipelines
- ToolService: SetHttpClientFactory() pattern for lazy DI resolution
- ScannedKeyRecord: type field (anthropic_oauth, anthropic_api, anthropic_unknown, unknown)
- DetectKeyType() based on key prefix
- DB migration: type column with default 'anthropic_oauth'
- Frontend: type label in scanned keys list
This commit is contained in:
Meleki committed 2026-03-13 08:12:55 +01:00
1 parent 04c7c2e13d
commit bca5e5145a
11 files changed
+145 -10

No files matched your search

+9
View File
@@ -185,6 +185,7 @@ public class KeyScannerService : BackgroundService
ApiKey = key,
Source = source,
SourceUrl = sourceUrl,
Type = DetectKeyType(key),
Status = "unchecked",
Plan = "Unknown",
ScannedAt = DateTime.UtcNow.ToString("o")
@@ -471,4 +472,12 @@ public class KeyScannerService : BackgroundService
await _db.UpdateScannedKeyStatus(sk.ScannedKeyId, "error", "Unknown", null, null);
}
}
private static string DetectKeyType(string key)
{
if (key.StartsWith("sk-ant-oat01-", StringComparison.Ordinal)) return "anthropic_oauth";
if (key.StartsWith("sk-ant-api03-", StringComparison.Ordinal)) return "anthropic_api";
if (key.StartsWith("sk-ant-", StringComparison.Ordinal)) return "anthropic_unknown";
return "unknown";
}
}