@jeffreycao/copilot-api 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/dist/auth-PjO-EXxs.js +46 -0
- package/dist/auth-PjO-EXxs.js.map +1 -0
- package/dist/check-usage-C9abXGdq.js +45 -0
- package/dist/check-usage-C9abXGdq.js.map +1 -0
- package/dist/config-D3COstcJ.js +173 -0
- package/dist/config-D3COstcJ.js.map +1 -0
- package/dist/debug-Dx1S6uWG.js +82 -0
- package/dist/debug-Dx1S6uWG.js.map +1 -0
- package/dist/get-copilot-usage-xj7WA78o.js +12 -0
- package/dist/get-copilot-usage-xj7WA78o.js.map +1 -0
- package/dist/main.js +23 -551
- package/dist/main.js.map +1 -1
- package/dist/paths-Cla6y5eD.js +33 -0
- package/dist/paths-Cla6y5eD.js.map +1 -0
- package/dist/{server-C-LzaXzh.js → server-DJvut6rC.js} +6 -3
- package/dist/{server-C-LzaXzh.js.map → server-DJvut6rC.js.map} +1 -1
- package/dist/start-CiUssY8j.js +259 -0
- package/dist/start-CiUssY8j.js.map +1 -0
- package/dist/token-G21yvpKv.js +156 -0
- package/dist/token-G21yvpKv.js.map +1 -0
- package/dist/{config-DqFPDXKy.js → utils-artyYmCm.js} +3 -208
- package/dist/utils-artyYmCm.js.map +1 -0
- package/package.json +1 -1
- package/dist/config-DqFPDXKy.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/paths.ts
|
|
6
|
+
const AUTH_APP = process.env.COPILOT_API_OAUTH_APP?.trim() || "";
|
|
7
|
+
const ENTERPRISE_PREFIX = process.env.COPILOT_API_ENTERPRISE_URL ? "ent_" : "";
|
|
8
|
+
const DEFAULT_DIR = path.join(os.homedir(), ".local", "share", "copilot-api");
|
|
9
|
+
const APP_DIR = process.env.COPILOT_API_HOME || DEFAULT_DIR;
|
|
10
|
+
const GITHUB_TOKEN_PATH = path.join(APP_DIR, AUTH_APP, ENTERPRISE_PREFIX + "github_token");
|
|
11
|
+
const CONFIG_PATH = path.join(APP_DIR, "config.json");
|
|
12
|
+
const PATHS = {
|
|
13
|
+
APP_DIR,
|
|
14
|
+
GITHUB_TOKEN_PATH,
|
|
15
|
+
CONFIG_PATH
|
|
16
|
+
};
|
|
17
|
+
async function ensurePaths() {
|
|
18
|
+
await fs.mkdir(path.join(PATHS.APP_DIR, AUTH_APP), { recursive: true });
|
|
19
|
+
await ensureFile(PATHS.GITHUB_TOKEN_PATH);
|
|
20
|
+
await ensureFile(PATHS.CONFIG_PATH);
|
|
21
|
+
}
|
|
22
|
+
async function ensureFile(filePath) {
|
|
23
|
+
try {
|
|
24
|
+
await fs.access(filePath, fs.constants.W_OK);
|
|
25
|
+
} catch {
|
|
26
|
+
await fs.writeFile(filePath, "");
|
|
27
|
+
await fs.chmod(filePath, 384);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { PATHS, ensurePaths };
|
|
33
|
+
//# sourceMappingURL=paths-Cla6y5eD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths-Cla6y5eD.js","names":[],"sources":["../src/lib/paths.ts"],"sourcesContent":["import fs from \"node:fs/promises\"\nimport os from \"node:os\"\nimport path from \"node:path\"\n\nconst AUTH_APP = process.env.COPILOT_API_OAUTH_APP?.trim() || \"\"\nconst ENTERPRISE_PREFIX = process.env.COPILOT_API_ENTERPRISE_URL ? \"ent_\" : \"\"\n\nconst DEFAULT_DIR = path.join(os.homedir(), \".local\", \"share\", \"copilot-api\")\nconst APP_DIR = process.env.COPILOT_API_HOME || DEFAULT_DIR\n\nconst GITHUB_TOKEN_PATH = path.join(\n APP_DIR,\n AUTH_APP,\n ENTERPRISE_PREFIX + \"github_token\",\n)\nconst CONFIG_PATH = path.join(APP_DIR, \"config.json\")\n\nexport const PATHS = {\n APP_DIR,\n GITHUB_TOKEN_PATH,\n CONFIG_PATH,\n}\n\nexport async function ensurePaths(): Promise<void> {\n await fs.mkdir(path.join(PATHS.APP_DIR, AUTH_APP), { recursive: true })\n await ensureFile(PATHS.GITHUB_TOKEN_PATH)\n await ensureFile(PATHS.CONFIG_PATH)\n}\n\nasync function ensureFile(filePath: string): Promise<void> {\n try {\n await fs.access(filePath, fs.constants.W_OK)\n } catch {\n await fs.writeFile(filePath, \"\")\n await fs.chmod(filePath, 0o600)\n }\n}\n"],"mappings":";;;;;AAIA,MAAM,WAAW,QAAQ,IAAI,uBAAuB,MAAM,IAAI;AAC9D,MAAM,oBAAoB,QAAQ,IAAI,6BAA6B,SAAS;AAE5E,MAAM,cAAc,KAAK,KAAK,GAAG,SAAS,EAAE,UAAU,SAAS,cAAc;AAC7E,MAAM,UAAU,QAAQ,IAAI,oBAAoB;AAEhD,MAAM,oBAAoB,KAAK,KAC7B,SACA,UACA,oBAAoB,eACrB;AACD,MAAM,cAAc,KAAK,KAAK,SAAS,cAAc;AAErD,MAAa,QAAQ;CACnB;CACA;CACA;CACD;AAED,eAAsB,cAA6B;AACjD,OAAM,GAAG,MAAM,KAAK,KAAK,MAAM,SAAS,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACvE,OAAM,WAAW,MAAM,kBAAkB;AACzC,OAAM,WAAW,MAAM,YAAY;;AAGrC,eAAe,WAAW,UAAiC;AACzD,KAAI;AACF,QAAM,GAAG,OAAO,UAAU,GAAG,UAAU,KAAK;SACtC;AACN,QAAM,GAAG,UAAU,UAAU,GAAG;AAChC,QAAM,GAAG,MAAM,UAAU,IAAM"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PATHS } from "./paths-Cla6y5eD.js";
|
|
2
|
+
import { HTTPError, cacheModels, copilotBaseUrl, copilotHeaders, forwardError, generateRequestIdFromPayload, getRootSessionId, getUUID, isNullish, prepareInteractionHeaders, sleep, state } from "./utils-artyYmCm.js";
|
|
3
|
+
import { getCopilotUsage } from "./get-copilot-usage-xj7WA78o.js";
|
|
4
|
+
import { getConfig, getExtraPromptForModel, getProviderConfig, getReasoningEffortForModel, getSmallModel, isMessagesApiEnabled, isResponsesApiContextManagementModel, shouldCompactUseSmallModel } from "./config-D3COstcJ.js";
|
|
2
5
|
import consola from "consola";
|
|
3
6
|
import path from "node:path";
|
|
4
|
-
import fs, { readFileSync } from "node:fs";
|
|
5
7
|
import { Hono } from "hono";
|
|
6
8
|
import { cors } from "hono/cors";
|
|
7
9
|
import { logger } from "hono/logger";
|
|
10
|
+
import fs, { readFileSync } from "node:fs";
|
|
8
11
|
import { streamSSE } from "hono/streaming";
|
|
9
12
|
import util from "node:util";
|
|
10
13
|
import { events } from "fetch-event-stream";
|
|
@@ -2801,4 +2804,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
2801
2804
|
|
|
2802
2805
|
//#endregion
|
|
2803
2806
|
export { server };
|
|
2804
|
-
//# sourceMappingURL=server-
|
|
2807
|
+
//# sourceMappingURL=server-DJvut6rC.js.map
|