<commit_before>class KodingKite_KlientKite extends KodingKite

  @constructors['klient'] = this

  @createApiMapping

    exec               : 'exec'

    fsReadDirectory    : 'fs.readDirectory'
    fsGlob             : 'fs.glob'
    fsReadFile         : 'fs.readFile'
    fsGetInfo          : 'fs.getInfo'
    fsSetPermissions   : 'fs.setPermissions'
    fsRemove           : 'fs.remove'

    fsUniquePath       : 'fs.uniquePath'
    fsWriteFile        : 'fs.writeFile'
    fsRename           : 'fs.rename'
    fsMove             : 'fs.move'
    fsCreateDirectory  : 'fs.createDirectory'

    webtermGetSessions : 'webterm.getSessions'
    webtermConnect     : 'webterm.connect'
    webtermKillSession : 'webterm.killSession'
    webtermPing        : 'webterm.ping'

  init: ->
    @connect()
    Promise.resolve()

  # setTransport is used to override the setTransport method in KodingKite
  # prior to connection so we can have a custom URL. This is used so Klient
  # Kite can go over our internal userproxy
  setTransport: (@transport) ->
    # let's use DOM for parsing the url
    parser = document.createElement("a")
    parser.href = @transport.options.url

    # build our new url, example:
    # old: http://192.168.127.12:3000/kite
    # new: https://koding.com/-/userproxy/5172.16.17.321/kite
    #           or
    #      http://localhost:8090/-/userproxy/192.168.3.11/kite

    {hostname, protocol} = document.location

    changedUrl = "#{protocol}//#{hostname}/-/userproxy/#{parser.hostname}/kite"

    @transport.options.url = changedUrl

    # now call @connect in super, which will connect to our new URL
    super transport<commit_msg>klient: include the port in the changedUrl<commit_after>class KodingKite_KlientKite extends KodingKite

  @constructors['klient'] = this

  @createApiMapping

    exec               : 'exec'

    fsReadDirectory    : 'fs.readDirectory'
    fsGlob             : 'fs.glob'
    fsReadFile         : 'fs.readFile'
    fsGetInfo          : 'fs.getInfo'
    fsSetPermissions   : 'fs.setPermissions'
    fsRemove           : 'fs.remove'

    fsUniquePath       : 'fs.uniquePath'
    fsWriteFile        : 'fs.writeFile'
    fsRename           : 'fs.rename'
    fsMove             : 'fs.move'
    fsCreateDirectory  : 'fs.createDirectory'

    webtermGetSessions : 'webterm.getSessions'
    webtermConnect     : 'webterm.connect'
    webtermKillSession : 'webterm.killSession'
    webtermPing        : 'webterm.ping'

  init: ->
    @connect()
    Promise.resolve()

  # setTransport is used to override the setTransport method in KodingKite
  # prior to connection so we can have a custom URL. This is used so Klient
  # Kite can go over our internal userproxy
  setTransport: (@transport) ->
    # let's use DOM for parsing the url
    parser = document.createElement("a")
    parser.href = @transport.options.url

    # build our new url, example:
    # old: http://192.168.127.12:3000/kite
    # new: https://koding.com/-/userproxy/5172.16.31.10/kite
    #           or
    #      http://localhost:8090/-/userproxy/54.164.243.111/kite

    {hostname, protocol, port} = document.location

    changedUrl = "#{protocol}//#{hostname}#{if port then ":#{port}" else ""}/-/userproxy/#{parser.hostname}/kite"

    @transport.options.url = changedUrl

    # now call @connect in super, which will connect to our new URL
    super transport
{'fraction_non_alphanumeric': 0.1091070372560615, 'fraction_numerical': 0.023358959195742164, 'mean_word_length': 2.4485219164118246, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4134850', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1042, 'n_words': 249}