@@ -42,11 +42,14 @@ protocol GitHubCopilotLSP {
4242enum GitHubCopilotError : Error , LocalizedError {
4343 case languageServerNotInstalled
4444 case languageServerError( ServerError )
45+ case failedToInstallStartScript
4546
4647 var errorDescription : String ? {
4748 switch self {
4849 case . languageServerNotInstalled:
4950 return " Language server is not installed. "
51+ case . failedToInstallStartScript:
52+ return " Failed to install start script. "
5053 case let . languageServerError( error) :
5154 switch error {
5255 case let . handlerUnavailable( handler) :
@@ -109,12 +112,32 @@ public class GitHubCopilotBaseService {
109112 throw GitHubCopilotError . languageServerNotInstalled
110113 }
111114
115+ let indexJSURL : URL = try {
116+ if UserDefaults . shared. value ( for: \. gitHubCopilotLoadKeyChainCertificates) {
117+ let url = urls. executableURL. appendingPathComponent ( " load-self-signed-cert.js " )
118+ if !FileManager. default. fileExists ( atPath: url. path) {
119+ let file = Bundle . module. url (
120+ forResource: " load-self-signed-cert " ,
121+ withExtension: " js "
122+ ) !
123+ do {
124+ try FileManager . default. copyItem ( at: file, to: url)
125+ } catch {
126+ throw GitHubCopilotError . failedToInstallStartScript
127+ }
128+ }
129+ return url
130+ } else {
131+ return agentJSURL
132+ }
133+ } ( )
134+
112135 switch runner {
113136 case . bash:
114137 let nodePath = UserDefaults . shared. value ( for: \. nodePath)
115138 let command = [
116139 nodePath. isEmpty ? " node " : nodePath,
117- " \" \( agentJSURL . path) \" " ,
140+ " \" \( indexJSURL . path) \" " ,
118141 " --stdio " ,
119142 ] . joined ( separator: " " )
120143 executionParams = Process . ExecutionParameters (
@@ -128,7 +151,7 @@ public class GitHubCopilotBaseService {
128151 let nodePath = UserDefaults . shared. value ( for: \. nodePath)
129152 let command = [
130153 nodePath. isEmpty ? " node " : nodePath,
131- " \" \( agentJSURL . path) \" " ,
154+ " \" \( indexJSURL . path) \" " ,
132155 " --stdio " ,
133156 ] . joined ( separator: " " )
134157 executionParams = Process . ExecutionParameters (
@@ -146,7 +169,7 @@ public class GitHubCopilotBaseService {
146169 path: " /usr/bin/env " ,
147170 arguments: [
148171 nodePath. isEmpty ? " node " : nodePath,
149- agentJSURL . path,
172+ indexJSURL . path,
150173 " --stdio " ,
151174 ] ,
152175 environment: [
0 commit comments