new features
This commit is contained in:
+16
-6
@@ -783,9 +783,10 @@ enum GiteaRepositoryLookup {
|
||||
|
||||
static func entries(client: any MCPToolClient) async throws -> [String] {
|
||||
let data = try await client.callTool("list_repositories", argumentsJSON: Data("{}".utf8))
|
||||
guard let result = try JSONSerialization.jsonObject(with: data) as? [String: Any],
|
||||
result["isError"] as? Bool != true else {
|
||||
throw StudioError("The connected Gitea server could not list its repositories.")
|
||||
try MCPToolResponse.check(data, tool: "list_repositories")
|
||||
let result = try JSONSerialization.jsonObject(with: data)
|
||||
guard result is [String: Any] || result is [Any] else {
|
||||
throw StudioError("Gitea returned an unexpected repository response.")
|
||||
}
|
||||
var entries: [String] = []
|
||||
var seen: Set<String> = []
|
||||
@@ -796,7 +797,7 @@ enum GiteaRepositoryLookup {
|
||||
let link = object["html_url"] as? String
|
||||
entries.append(link.map { "\(name) — \($0)" } ?? name)
|
||||
} else {
|
||||
for field in ["result", "structuredContent", "content", "text"] {
|
||||
for field in ["structuredContent", "result", "data", "repositories", "content", "text"] {
|
||||
if let nested = object[field] { collect(nested) }
|
||||
}
|
||||
}
|
||||
@@ -955,7 +956,16 @@ struct ChatFilePreview: Identifiable, Sendable {
|
||||
guard values.isRegularFile == true, let size = values.fileSize, size <= 20_000_000 else {
|
||||
throw StudioError("Choose an image file up to 20 MB.")
|
||||
}
|
||||
guard let source = CGImageSourceCreateWithURL(url as CFURL, nil),
|
||||
return try imagePreview(source: CGImageSourceCreateWithURL(url as CFURL, nil), name: url.lastPathComponent)
|
||||
}
|
||||
|
||||
static func pastedImage(_ data: Data) throws -> Self {
|
||||
guard data.count <= 20_000_000 else { throw StudioError("Choose an image up to 20 MB.") }
|
||||
return try imagePreview(source: CGImageSourceCreateWithData(data as CFData, nil), name: "Pasted Image.png")
|
||||
}
|
||||
|
||||
private static func imagePreview(source: CGImageSource?, name: String) throws -> Self {
|
||||
guard let source,
|
||||
let properties = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [CFString: Any],
|
||||
let width = properties[kCGImagePropertyPixelWidth] as? Int,
|
||||
let height = properties[kCGImagePropertyPixelHeight] as? Int, width > 0, height > 0 else {
|
||||
@@ -983,7 +993,7 @@ struct ChatFilePreview: Identifiable, Sendable {
|
||||
throw StudioError("The image exceeds 20 MB when converted to PNG.")
|
||||
}
|
||||
let text = (try? recognizeText(in: image)) ?? ""
|
||||
return Self(name: url.lastPathComponent, text: text, imagePNG: png as Data)
|
||||
return Self(name: name, text: text, imagePNG: png as Data)
|
||||
}
|
||||
|
||||
private static func pdfText(at url: URL) throws -> String {
|
||||
|
||||
Reference in New Issue
Block a user