Skip to content

Commit 0517f3b

Browse files
committed
Pre-release 0.40.132
1 parent 9d1d42f commit 0517f3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1905
-607
lines changed

Copilot for Xcode.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 46 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Copilot for Xcode/Credits.rtf

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ SOFTWARE.\
163163
\
164164
\
165165
Dependency: github.com/apple/swift-syntax\
166-
Version: 509.0.2\
166+
Version: 510.0.3\
167167
License Content:\
168168
Apache License\
169169
Version 2.0, January 2004\
@@ -1761,7 +1761,7 @@ License Content:\
17611761
\
17621762
\
17631763
Dependency: github.com/ChimeHQ/JSONRPC\
1764-
Version: 0.6.0\
1764+
Version: 0.9.0\
17651765
License Content:\
17661766
BSD 3-Clause License\
17671767
\
@@ -1795,7 +1795,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\
17951795
\
17961796
\
17971797
Dependency: github.com/ChimeHQ/LanguageServerProtocol\
1798-
Version: 0.8.0\
1798+
Version: 0.13.3\
17991799
License Content:\
18001800
BSD 3-Clause License\
18011801
\
@@ -2611,7 +2611,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
26112611
\
26122612
\
26132613
Dependency: github.com/ChimeHQ/LanguageClient\
2614-
Version: 0.3.1\
2614+
Version: 0.8.2\
26152615
License Content:\
26162616
BSD 3-Clause License\
26172617
\
@@ -2645,7 +2645,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\
26452645
\
26462646
\
26472647
Dependency: github.com/ChimeHQ/ProcessEnv\
2648-
Version: 0.3.1\
2648+
Version: 1.0.1\
26492649
License Content:\
26502650
BSD 3-Clause License\
26512651
\
@@ -3322,4 +3322,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\
33223322
THE SOFTWARE.\
33233323
\
33243324
\
3325+
Dependency: https://github.com/scinfu/SwiftSoup\
3326+
Version: 2.9.6\
3327+
License Content:\
3328+
The MIT License\
3329+
\
3330+
Copyright (c) 2009-2025 Jonathan Hedley <https://jsoup.org/>\
3331+
Swift port copyright (c) 2016-2025 Nabil Chatbi\
3332+
\
3333+
Permission is hereby granted, free of charge, to any person obtaining a copy\
3334+
of this software and associated documentation files (the "Software"), to deal\
3335+
in the Software without restriction, including without limitation the rights\
3336+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\
3337+
copies of the Software, and to permit persons to whom the Software is\
3338+
furnished to do so, subject to the following conditions:\
3339+
\
3340+
The above copyright notice and this permission notice shall be included in all\
3341+
copies or substantial portions of the Software.\
3342+
\
3343+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\
3344+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\
3345+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\
3346+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\
3347+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\
3348+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\
3349+
SOFTWARE.\
3350+
\
3351+
\
33253352
}

Core/Package.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ let package = Package(
5353
.package(url: "https://github.com/devm33/KeyboardShortcuts", branch: "main"),
5454
.package(url: "https://github.com/devm33/CGEventOverride", branch: "devm33/fix-stale-AXIsProcessTrusted"),
5555
.package(url: "https://github.com/devm33/Highlightr", branch: "master"),
56-
.package(url: "https://github.com/globulus/swiftui-flow-layout",
57-
from: "1.0.5")
56+
.package(url: "https://github.com/globulus/swiftui-flow-layout", from: "1.0.5")
5857
],
5958
targets: [
6059
// MARK: - Main
@@ -182,7 +181,8 @@ let package = Package(
182181
.product(name: "Workspace", package: "Tool"),
183182
.product(name: "Terminal", package: "Tool"),
184183
.product(name: "SystemUtils", package: "Tool"),
185-
.product(name: "AppKitExtension", package: "Tool")
184+
.product(name: "AppKitExtension", package: "Tool"),
185+
.product(name: "WebContentExtractor", package: "Tool")
186186
]),
187187
.testTarget(
188188
name: "ChatServiceTests",
@@ -202,8 +202,7 @@ let package = Package(
202202
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
203203
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
204204
.product(name: "SwiftUIFlowLayout", package: "swiftui-flow-layout"),
205-
.product(name: "Persist", package: "Tool"),
206-
.product(name: "Terminal", package: "Tool")
205+
.product(name: "Persist", package: "Tool")
207206
]
208207
),
209208

Core/Sources/ChatService/ChatService.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ public final class ChatService: ChatServiceType, ObservableObject {
217217
}
218218
}
219219

220+
public func notifyChangeTextDocument(fileURL: URL, content: String, version: Int) async throws {
221+
try await conversationProvider?.notifyChangeTextDocument(fileURL: fileURL, content: content, version: version, workspaceURL: getWorkspaceURL())
222+
}
223+
220224
public static func service(for chatTabInfo: ChatTabInfo) -> ChatService {
221225
let provider = BuiltinExtensionConversationServiceProvider(
222226
extension: GitHubCopilotExtension.self

Core/Sources/ChatService/ToolCalls/CopilotToolRegistry.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class CopilotToolRegistry {
1010
tools[ToolName.getErrors.rawValue] = GetErrorsTool()
1111
tools[ToolName.insertEditIntoFile.rawValue] = InsertEditIntoFileTool()
1212
tools[ToolName.createFile.rawValue] = CreateFileTool()
13+
tools[ToolName.fetchWebPage.rawValue] = FetchWebPageTool()
1314
}
1415

1516
public func getTool(name: String) -> ICopilotTool? {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import AppKit
2+
import AXExtension
3+
import AXHelper
4+
import ConversationServiceProvider
5+
import Foundation
6+
import JSONRPC
7+
import Logger
8+
import WebKit
9+
import WebContentExtractor
10+
11+
public class FetchWebPageTool: ICopilotTool {
12+
public static let name = ToolName.fetchWebPage
13+
14+
public func invokeTool(
15+
_ request: InvokeClientToolRequest,
16+
completion: @escaping (AnyJSONRPCResponse) -> Void,
17+
chatHistoryUpdater: ChatHistoryUpdater?,
18+
contextProvider: (any ToolContextProvider)?
19+
) -> Bool {
20+
guard let params = request.params,
21+
let input = params.input,
22+
let urls = input["urls"]?.value as? [String]
23+
else {
24+
completeResponse(request, status: .error, response: "Invalid parameters", completion: completion)
25+
return true
26+
}
27+
28+
guard !urls.isEmpty else {
29+
completeResponse(request, status: .error, response: "No valid URLs provided", completion: completion)
30+
return true
31+
}
32+
33+
// Use the improved WebContentFetcher to fetch content from all URLs
34+
Task {
35+
let results = await WebContentFetcher.fetchMultipleContentAsync(from: urls)
36+
37+
completeResponses(
38+
request,
39+
responses: results,
40+
completion: completion
41+
)
42+
}
43+
44+
return true
45+
}
46+
}

Core/Sources/ChatService/ToolCalls/ICopilotTool.swift

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1+
import ChatTab
12
import ConversationServiceProvider
3+
import Foundation
24
import JSONRPC
3-
import ChatTab
4-
5-
enum ToolInvocationStatus: String {
6-
case success, error, cancelled
7-
}
85

96
public protocol ToolContextProvider {
107
// MARK: insert_edit_into_file
118
var chatTabInfo: ChatTabInfo { get }
129
func updateFileEdits(by fileEdit: FileEdit) -> Void
10+
func notifyChangeTextDocument(fileURL: URL, content: String, version: Int) async throws
1311
}
1412

1513
public typealias ChatHistoryUpdater = (String, [AgentRound]) -> Void
@@ -48,14 +46,42 @@ extension ICopilotTool {
4846
response: String = "",
4947
completion: @escaping (AnyJSONRPCResponse) -> Void
5048
) {
51-
let result: JSONValue = .array([
52-
.hash([
53-
"status": .string(status.rawValue),
54-
"content": .array([.hash(["value": .string(response)])])
55-
]),
56-
.null
57-
])
58-
completion(AnyJSONRPCResponse(id: request.id, result: result))
49+
completeResponses(
50+
request,
51+
status: status,
52+
responses: [response],
53+
completion: completion
54+
)
55+
}
56+
57+
///
58+
/// Completes a tool response with multiple data entries.
59+
/// - Parameters:
60+
/// - request: The original tool invocation request.
61+
/// - status: The completion status of the tool execution (success, error, or cancelled).
62+
/// - responses: Array of string values to include in the response content.
63+
/// - completion: The completion handler to call with the response.
64+
///
65+
func completeResponses(
66+
_ request: InvokeClientToolRequest,
67+
status: ToolInvocationStatus = .success,
68+
responses: [String],
69+
completion: @escaping (AnyJSONRPCResponse) -> Void
70+
) {
71+
let toolResult = LanguageModelToolResult(status: status, content: responses.map { response in
72+
LanguageModelToolResult.Content(value: response)
73+
})
74+
let jsonResult = try? JSONEncoder().encode(toolResult)
75+
let jsonValue = (try? JSONDecoder().decode(JSONValue.self, from: jsonResult ?? Data())) ?? JSONValue.null
76+
completion(
77+
AnyJSONRPCResponse(
78+
id: request.id,
79+
result: JSONValue.array([
80+
jsonValue,
81+
JSONValue.null,
82+
])
83+
)
84+
)
5985
}
6086
}
6187

0 commit comments

Comments
 (0)