@@ -21,6 +21,7 @@ import (
2121"tailscale.com/tailcfg"
2222
2323"cdr.dev/slog"
24+ "github.com/coder/coder/v2/agent/proto"
2425"github.com/coder/coder/v2/codersdk"
2526drpcsdk"github.com/coder/coder/v2/codersdk/drpc"
2627"github.com/coder/retry"
@@ -281,18 +282,22 @@ func (c *Client) DERPMapUpdates(ctx context.Context) (<-chan DERPMapUpdate, io.C
281282},nil
282283}
283284
284- // Listen connects to the workspace agentcoordinate WebSocket
285+ // Listen connects to the workspace agentAPI WebSocket
285286// that handles connection negotiation.
286287func (c * Client )Listen (ctx context.Context ) (drpc.Conn ,error ) {
287- coordinateURL ,err := c .SDK .URL .Parse ("/api/v2/workspaceagents/me/rpc" )
288+ rpcURL ,err := c .SDK .URL .Parse ("/api/v2/workspaceagents/me/rpc" )
288289if err != nil {
289290return nil ,xerrors .Errorf ("parse url: %w" ,err )
290291}
292+ q := rpcURL .Query ()
293+ q .Add ("version" ,proto .CurrentVersion .String ())
294+ rpcURL .RawQuery = q .Encode ()
295+
291296jar ,err := cookiejar .New (nil )
292297if err != nil {
293298return nil ,xerrors .Errorf ("create cookie jar: %w" ,err )
294299}
295- jar .SetCookies (coordinateURL , []* http.Cookie {{
300+ jar .SetCookies (rpcURL , []* http.Cookie {{
296301Name :codersdk .SessionTokenCookie ,
297302Value :c .SDK .SessionToken (),
298303}})
@@ -301,7 +306,7 @@ func (c *Client) Listen(ctx context.Context) (drpc.Conn, error) {
301306Transport :c .SDK .HTTPClient .Transport ,
302307}
303308// nolint:bodyclose
304- conn ,res ,err := websocket .Dial (ctx ,coordinateURL .String (),& websocket.DialOptions {
309+ conn ,res ,err := websocket .Dial (ctx ,rpcURL .String (),& websocket.DialOptions {
305310HTTPClient :httpClient ,
306311})
307312if err != nil {