@nick3/copilot-api 1.4.4 → 1.4.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 +2 -2
- package/dist/{accounts-manager-BvbpPVp1.js → accounts-manager-BsGuQhKM.js} +3 -3
- package/dist/{accounts-manager-BvbpPVp1.js.map → accounts-manager-BsGuQhKM.js.map} +1 -1
- package/dist/{auth-C_MhaDzM.js → auth-BAEHgP-a.js} +3 -3
- package/dist/{auth-C_MhaDzM.js.map → auth-BAEHgP-a.js.map} +1 -1
- package/dist/{check-usage-Cw1fo31i.js → check-usage-Dbthad7V.js} +4 -4
- package/dist/{check-usage-Cw1fo31i.js.map → check-usage-Dbthad7V.js.map} +1 -1
- package/dist/{get-copilot-token-CbzXMTE5.js → get-copilot-token-BySQCue6.js} +2 -2
- package/dist/{get-copilot-token-CbzXMTE5.js.map → get-copilot-token-BySQCue6.js.map} +1 -1
- package/dist/main.js +3 -3
- package/dist/{poll-access-token-BMaaEFhO.js → poll-access-token-CKc0_m42.js} +2 -2
- package/dist/{poll-access-token-BMaaEFhO.js.map → poll-access-token-CKc0_m42.js.map} +1 -1
- package/dist/{server-BKsjCvqp.js → server-D_7gI9hx.js} +4 -4
- package/dist/{server-BKsjCvqp.js.map → server-D_7gI9hx.js.map} +1 -1
- package/dist/{start-cJXCnfYv.js → start-DItwCYda.js} +6 -6
- package/dist/{start-cJXCnfYv.js.map → start-DItwCYda.js.map} +1 -1
- package/dist/{utils-DkUv9TDj.js → utils-BIK3ym34.js} +5 -1
- package/dist/utils-BIK3ym34.js.map +1 -0
- package/package.json +1 -1
- package/dist/utils-DkUv9TDj.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTTPError, accountFromState, getGitHubApiBaseUrl, githubHeaders } from "./utils-
|
|
1
|
+
import { HTTPError, accountFromState, getGitHubApiBaseUrl, githubHeaders } from "./utils-BIK3ym34.js";
|
|
2
2
|
|
|
3
3
|
//#region src/services/github/get-copilot-token.ts
|
|
4
4
|
const getCopilotToken = async (account) => {
|
|
@@ -10,4 +10,4 @@ const getCopilotToken = async (account) => {
|
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
export { getCopilotToken };
|
|
13
|
-
//# sourceMappingURL=get-copilot-token-
|
|
13
|
+
//# sourceMappingURL=get-copilot-token-BySQCue6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-copilot-token-
|
|
1
|
+
{"version":3,"file":"get-copilot-token-BySQCue6.js","names":[],"sources":["../src/services/github/get-copilot-token.ts"],"sourcesContent":["import type { AccountContext } from \"~/lib/types/account\"\n\nimport { getGitHubApiBaseUrl, githubHeaders } from \"~/lib/api-config\"\nimport { HTTPError } from \"~/lib/error\"\nimport { accountFromState } from \"~/lib/state\"\n\nexport const getCopilotToken = async (account?: AccountContext) => {\n const ctx = account ?? accountFromState()\n const response = await fetch(\n `${getGitHubApiBaseUrl()}/copilot_internal/v2/token`,\n {\n headers: githubHeaders(ctx),\n },\n )\n\n if (!response.ok) throw new HTTPError(\"Failed to get Copilot token\", response)\n\n return (await response.json()) as GetCopilotTokenResponse\n}\n\n// Trimmed for the sake of simplicity\nexport interface GetCopilotTokenResponse {\n expires_at: number\n refresh_in: number\n token: string\n}\n"],"mappings":";;;AAMA,MAAa,kBAAkB,OAAO,YAA6B;CACjE,MAAM,MAAM,WAAW,kBAAkB;CACzC,MAAM,WAAW,MAAM,MACrB,GAAG,qBAAqB,CAAC,6BACzB,EACE,SAAS,cAAc,IAAI,EAC5B,CACF;AAED,KAAI,CAAC,SAAS,GAAI,OAAM,IAAI,UAAU,+BAA+B,SAAS;AAE9E,QAAQ,MAAM,SAAS,MAAM"}
|
package/dist/main.js
CHANGED
|
@@ -20,10 +20,10 @@ const args = parseArgs(process.argv, cliArgs);
|
|
|
20
20
|
if (typeof args["api-home"] === "string") process.env.COPILOT_API_HOME = args["api-home"];
|
|
21
21
|
if (typeof args["oauth-app"] === "string") process.env.COPILOT_API_OAUTH_APP = args["oauth-app"];
|
|
22
22
|
if (typeof args["enterprise-url"] === "string") process.env.COPILOT_API_ENTERPRISE_URL = args["enterprise-url"];
|
|
23
|
-
const { auth } = await import("./auth-
|
|
24
|
-
const { checkUsage } = await import("./check-usage-
|
|
23
|
+
const { auth } = await import("./auth-BAEHgP-a.js");
|
|
24
|
+
const { checkUsage } = await import("./check-usage-Dbthad7V.js");
|
|
25
25
|
const { debug } = await import("./debug-hQJWwXtC.js");
|
|
26
|
-
const { start } = await import("./start-
|
|
26
|
+
const { start } = await import("./start-DItwCYda.js");
|
|
27
27
|
const main = defineCommand({
|
|
28
28
|
meta: {
|
|
29
29
|
name: "copilot-api",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTTPError, getOauthAppConfig, getOauthUrls, sleep } from "./utils-
|
|
1
|
+
import { HTTPError, getOauthAppConfig, getOauthUrls, sleep } from "./utils-BIK3ym34.js";
|
|
2
2
|
import consola from "consola";
|
|
3
3
|
|
|
4
4
|
//#region src/services/github/get-device-code.ts
|
|
@@ -49,4 +49,4 @@ async function pollAccessToken(deviceCode) {
|
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { getDeviceCode, pollAccessToken };
|
|
52
|
-
//# sourceMappingURL=poll-access-token-
|
|
52
|
+
//# sourceMappingURL=poll-access-token-CKc0_m42.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-access-token-
|
|
1
|
+
{"version":3,"file":"poll-access-token-CKc0_m42.js","names":[],"sources":["../src/services/github/get-device-code.ts","../src/services/github/poll-access-token.ts"],"sourcesContent":["import { getOauthAppConfig, getOauthUrls } from \"~/lib/api-config\"\nimport { HTTPError } from \"~/lib/error\"\n\nexport async function getDeviceCode(): Promise<DeviceCodeResponse> {\n const { clientId, headers, scope } = getOauthAppConfig()\n const { deviceCodeUrl } = getOauthUrls()\n\n const response = await fetch(deviceCodeUrl, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n client_id: clientId,\n scope,\n }),\n })\n\n if (!response.ok) throw new HTTPError(\"Failed to get device code\", response)\n\n return (await response.json()) as DeviceCodeResponse\n}\n\nexport interface DeviceCodeResponse {\n device_code: string\n user_code: string\n verification_uri: string\n expires_in: number\n interval: number\n}\n","import consola from \"consola\"\n\nimport { getOauthAppConfig, getOauthUrls } from \"~/lib/api-config\"\nimport { sleep } from \"~/lib/utils\"\n\nimport type { DeviceCodeResponse } from \"./get-device-code\"\n\nexport async function pollAccessToken(\n deviceCode: DeviceCodeResponse,\n): Promise<string> {\n const { clientId, headers } = getOauthAppConfig()\n const { accessTokenUrl } = getOauthUrls()\n\n // Interval is in seconds, we need to multiply by 1000 to get milliseconds\n // I'm also adding another second, just to be safe\n const sleepDuration = (deviceCode.interval + 1) * 1000\n consola.debug(`Polling access token with interval of ${sleepDuration}ms`)\n\n while (true) {\n const response = await fetch(accessTokenUrl, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n client_id: clientId,\n device_code: deviceCode.device_code,\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n }),\n })\n\n if (!response.ok) {\n await sleep(sleepDuration)\n consola.error(\"Failed to poll access token:\", await response.text())\n\n continue\n }\n\n const json = await response.json()\n consola.debug(\"Polling access token response:\", json)\n\n const { access_token } = json as AccessTokenResponse\n\n if (access_token) {\n return access_token\n } else {\n await sleep(sleepDuration)\n }\n }\n}\n\ninterface AccessTokenResponse {\n access_token: string\n token_type: string\n scope: string\n}\n"],"mappings":";;;;AAGA,eAAsB,gBAA6C;CACjE,MAAM,EAAE,UAAU,SAAS,UAAU,mBAAmB;CACxD,MAAM,EAAE,kBAAkB,cAAc;CAExC,MAAM,WAAW,MAAM,MAAM,eAAe;EAC1C,QAAQ;EACR;EACA,MAAM,KAAK,UAAU;GACnB,WAAW;GACX;GACD,CAAC;EACH,CAAC;AAEF,KAAI,CAAC,SAAS,GAAI,OAAM,IAAI,UAAU,6BAA6B,SAAS;AAE5E,QAAQ,MAAM,SAAS,MAAM;;;;;ACX/B,eAAsB,gBACpB,YACiB;CACjB,MAAM,EAAE,UAAU,YAAY,mBAAmB;CACjD,MAAM,EAAE,mBAAmB,cAAc;CAIzC,MAAM,iBAAiB,WAAW,WAAW,KAAK;AAClD,SAAQ,MAAM,yCAAyC,cAAc,IAAI;AAEzE,QAAO,MAAM;EACX,MAAM,WAAW,MAAM,MAAM,gBAAgB;GAC3C,QAAQ;GACR;GACA,MAAM,KAAK,UAAU;IACnB,WAAW;IACX,aAAa,WAAW;IACxB,YAAY;IACb,CAAC;GACH,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;AAChB,SAAM,MAAM,cAAc;AAC1B,WAAQ,MAAM,gCAAgC,MAAM,SAAS,MAAM,CAAC;AAEpE;;EAGF,MAAM,OAAO,MAAM,SAAS,MAAM;AAClC,UAAQ,MAAM,kCAAkC,KAAK;EAErD,MAAM,EAAE,iBAAiB;AAEzB,MAAI,aACF,QAAO;MAEP,OAAM,MAAM,cAAc"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PATHS } from "./paths-DoT4SZ8f.js";
|
|
2
2
|
import { listAccountsFromRegistry } from "./accounts-registry-c7rs5Ed9.js";
|
|
3
|
-
import { HTTPError, accountFromState, cacheModels, copilotBaseUrl, copilotHeaders, forwardError, generateRequestIdFromPayload, getCopilotUsage, getRootSessionId, getUUID, isNullish, parseUserIdMetadata, prepareForCompact, prepareInteractionHeaders, sleep, state } from "./utils-
|
|
4
|
-
import "./get-copilot-token-
|
|
5
|
-
import { PROVIDER_TYPE_ANTHROPIC, accountsManager, getAliasTargetSet, getAnthropicApiKey, getConfig, getExtraPromptForModel, getModelAliases, getModelAliasesInfo, getModelRefreshIntervalMs, getProviderConfig, getReasoningEffortForModel, getSmallModel, isForceAgentEnabled, isFreeModelLoadBalancingEnabled, isMessageStartInputTokensFallbackEnabled, isMessagesApiEnabled, isResponsesApiContextManagementModel, mergeConfigWithDefaults, shouldCompactUseSmallModel } from "./accounts-manager-
|
|
3
|
+
import { HTTPError, accountFromState, cacheModels, copilotBaseUrl, copilotHeaders, forwardError, generateRequestIdFromPayload, getCopilotUsage, getRootSessionId, getUUID, isNullish, parseUserIdMetadata, prepareForCompact, prepareInteractionHeaders, sleep, state } from "./utils-BIK3ym34.js";
|
|
4
|
+
import "./get-copilot-token-BySQCue6.js";
|
|
5
|
+
import { PROVIDER_TYPE_ANTHROPIC, accountsManager, getAliasTargetSet, getAnthropicApiKey, getConfig, getExtraPromptForModel, getModelAliases, getModelAliasesInfo, getModelRefreshIntervalMs, getProviderConfig, getReasoningEffortForModel, getSmallModel, isForceAgentEnabled, isFreeModelLoadBalancingEnabled, isMessageStartInputTokensFallbackEnabled, isMessagesApiEnabled, isResponsesApiContextManagementModel, mergeConfigWithDefaults, shouldCompactUseSmallModel } from "./accounts-manager-BsGuQhKM.js";
|
|
6
6
|
import consola from "consola";
|
|
7
7
|
import fs, { readFile } from "node:fs/promises";
|
|
8
8
|
import * as path$1 from "node:path";
|
|
@@ -6434,4 +6434,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
6434
6434
|
|
|
6435
6435
|
//#endregion
|
|
6436
6436
|
export { server };
|
|
6437
|
-
//# sourceMappingURL=server-
|
|
6437
|
+
//# sourceMappingURL=server-D_7gI9hx.js.map
|