diff --git a/src/__tests__/cosy.test.ts b/src/__tests__/cosy.test.ts index b1197c1..ddeaa7c 100644 --- a/src/__tests__/cosy.test.ts +++ b/src/__tests__/cosy.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "vitest"; import { + buildAuthHeaders, getQoderBaseUrl, getQoderCenterUrl, getQoderChatURL, @@ -178,3 +179,22 @@ describe("toQoderCNModelId", () => { expect(toQoderCNModelId("")).toBe("QoderCNModel"); }); }); + +describe("COSY client identity", () => { + it("sends Cosy-Version and cosyVersion as current qodercli 1.1.38", () => { + const headers = buildAuthHeaders(null, "https://api3.qoder.sh/algo/api/v2/model/list", { + userID: "user-1", + authToken: "token-1", + name: "Test", + email: "test@example.com", + machineID: "machine-1", + }); + expect(headers["Cosy-Version"]).toBe("1.1.38"); + + const auth = headers.Authorization; + expect(auth.startsWith("Bearer COSY.")).toBe(true); + const payloadB64 = auth.slice("Bearer COSY.".length).split(".")[0]; + const payload = JSON.parse(Buffer.from(payloadB64, "base64").toString("utf8")) as { cosyVersion: string }; + expect(payload.cosyVersion).toBe("1.1.38"); + }); +}); diff --git a/src/cosy.ts b/src/cosy.ts index 6bdd242..7f436ff 100644 --- a/src/cosy.ts +++ b/src/cosy.ts @@ -12,7 +12,7 @@ XcW+ML9FoCI6AOvOzwIDAQAB // Keep the COSY client identity aligned with the current Qoder CLI catalog // protocol. Older values cause the model endpoint to return a reduced list. -const QoderIDEVersion = "1.1.3"; +const QoderIDEVersion = "1.1.38"; const QoderClientType = "5"; const QoderDataPolicy = "disagree"; const QoderLoginVersion = "v2";