@nick3/copilot-api 1.9.15 → 1.10.7
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 +56 -7
- package/README.zh-CN.md +55 -6
- package/dist/{account-DjCbqJ2Q.js → account-COtMmvzU.js} +2 -2
- package/dist/{account-DjCbqJ2Q.js.map → account-COtMmvzU.js.map} +1 -1
- package/dist/admin/assets/{index-BRnD4-DB.js → index-DG4TRVMu.js} +36 -36
- package/dist/admin/index.html +1 -1
- package/dist/{auth--I1utaB6.js → auth-B0y-2njL.js} +3 -3
- package/dist/{auth--I1utaB6.js.map → auth-B0y-2njL.js.map} +1 -1
- package/dist/{check-usage-DHvjdha4.js → check-usage-DdevqHE5.js} +3 -3
- package/dist/{check-usage-DHvjdha4.js.map → check-usage-DdevqHE5.js.map} +1 -1
- package/dist/{get-copilot-token-ZbmbVF0I.js → get-copilot-token-8Rm-rVsp.js} +2 -2
- package/dist/{get-copilot-token-ZbmbVF0I.js.map → get-copilot-token-8Rm-rVsp.js.map} +1 -1
- package/dist/main.js +6 -4
- package/dist/main.js.map +1 -1
- package/dist/mcp-9Hgepkc5.js +37 -0
- package/dist/mcp-9Hgepkc5.js.map +1 -0
- package/dist/{poll-access-token-CIPDXrcm.js → poll-access-token-BAgM2-7k.js} +62 -6
- package/dist/poll-access-token-BAgM2-7k.js.map +1 -0
- package/dist/{quota-refresh-scheduler-runtime-XD2fDa2K.js → proxy-YVh74m0I.js} +67 -8
- package/dist/proxy-YVh74m0I.js.map +1 -0
- package/dist/{request-outbound-Cy6huWjK.js → request-outbound-BJjWS_jF.js} +1 -1
- package/dist/{request-outbound-CxvpSkOn.js → request-outbound-Pu1kp2x8.js} +3 -1
- package/dist/request-outbound-Pu1kp2x8.js.map +1 -0
- package/dist/{server-BDCnb3Ao.js → server-DmDAepfa.js} +667 -77
- package/dist/server-DmDAepfa.js.map +1 -0
- package/dist/{start-DkBnp9d8.js → start-D37Bi12h.js} +5 -52
- package/dist/start-D37Bi12h.js.map +1 -0
- package/dist/tool-search-BrN7M0Dd.js +110 -0
- package/dist/tool-search-BrN7M0Dd.js.map +1 -0
- package/package.json +3 -6
- package/dist/poll-access-token-CIPDXrcm.js.map +0 -1
- package/dist/quota-refresh-scheduler-runtime-XD2fDa2K.js.map +0 -1
- package/dist/request-outbound-CxvpSkOn.js.map +0 -1
- package/dist/server-BDCnb3Ao.js.map +0 -1
- package/dist/start-DkBnp9d8.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { M as
|
|
2
|
-
import { b as getCurrentIdentityEnvironment, c as isAccountEnabled, f as readLegacyToken, h as saveAccountToken, i as ensureAccountClientIdentity, l as listAccountsFromRegistry, o as hasLegacyToken, r as addAccountToRegistry, s as hasRegistry, u as loadAccountToken, v as buildIdentityKey, y as createAccountSessionId } from "./account-
|
|
1
|
+
import { M as consumeOutboundHeadersSnapshot, N as requestContext, _ as HTTPError, g as getCopilotUsage, k as accountFromState, m as getGitHubUser, x as copilotModelsHeaders, y as copilotBaseUrl } from "./poll-access-token-BAgM2-7k.js";
|
|
2
|
+
import { b as getCurrentIdentityEnvironment, c as isAccountEnabled, f as readLegacyToken, h as saveAccountToken, i as ensureAccountClientIdentity, l as listAccountsFromRegistry, o as hasLegacyToken, r as addAccountToRegistry, s as hasRegistry, u as loadAccountToken, v as buildIdentityKey, y as createAccountSessionId } from "./account-COtMmvzU.js";
|
|
3
3
|
import { t as PATHS } from "./paths-CclKwouX.js";
|
|
4
|
-
import { t as getCopilotToken } from "./get-copilot-token-
|
|
5
|
-
import { c as getAdminDbUserVersion, i as getRequestOutboundStore, o as getAdminDb, s as getAdminDbPath } from "./request-outbound-
|
|
4
|
+
import { t as getCopilotToken } from "./get-copilot-token-8Rm-rVsp.js";
|
|
5
|
+
import { c as getAdminDbUserVersion, i as getRequestOutboundStore, o as getAdminDb, s as getAdminDbPath } from "./request-outbound-Pu1kp2x8.js";
|
|
6
6
|
import consola, { consola as consola$1 } from "consola";
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
8
|
import fs$1 from "node:fs";
|
|
9
|
+
import { Agent, ProxyAgent, setGlobalDispatcher } from "undici";
|
|
10
|
+
import { getProxyForUrl } from "proxy-from-env";
|
|
9
11
|
//#region src/lib/config.ts
|
|
10
12
|
const PROVIDER_TYPE_ANTHROPIC = "anthropic";
|
|
11
13
|
const gpt5ExplorationPrompt = `## Exploration and reading files
|
|
@@ -69,6 +71,7 @@ const defaultConfig = {
|
|
|
69
71
|
modelRefreshIntervalHours: 24,
|
|
70
72
|
sessionAffinityRetentionDays: 7,
|
|
71
73
|
useMessagesApi: true,
|
|
74
|
+
useResponsesApiWebSocket: true,
|
|
72
75
|
useResponsesApiWebSearch: true,
|
|
73
76
|
logLevel: "info",
|
|
74
77
|
devMode: {
|
|
@@ -322,7 +325,7 @@ function mergeConfigWithDefaults() {
|
|
|
322
325
|
return mergedConfig;
|
|
323
326
|
}
|
|
324
327
|
function getConfig() {
|
|
325
|
-
cachedConfig ??= readConfigFromDisk();
|
|
328
|
+
cachedConfig ??= mergeDefaultConfig(readConfigFromDisk()).mergedConfig;
|
|
326
329
|
return cachedConfig;
|
|
327
330
|
}
|
|
328
331
|
function normalizeAliasKey(value) {
|
|
@@ -519,6 +522,9 @@ function getProviderConfig(name) {
|
|
|
519
522
|
function isMessagesApiEnabled() {
|
|
520
523
|
return getConfig().useMessagesApi ?? true;
|
|
521
524
|
}
|
|
525
|
+
function isResponsesApiWebSocketEnabled() {
|
|
526
|
+
return getConfig().useResponsesApiWebSocket ?? true;
|
|
527
|
+
}
|
|
522
528
|
function getAnthropicApiKey() {
|
|
523
529
|
return getConfig().anthropicApiKey ?? process.env.ANTHROPIC_API_KEY ?? void 0;
|
|
524
530
|
}
|
|
@@ -1624,7 +1630,7 @@ var RequestHistoryStore = class {
|
|
|
1624
1630
|
} catch (error) {
|
|
1625
1631
|
consola.debug("Failed to cleanup request_log retention", error);
|
|
1626
1632
|
}
|
|
1627
|
-
import("./request-outbound-
|
|
1633
|
+
import("./request-outbound-BJjWS_jF.js").then((m) => m.getRequestOutboundStore().cleanupOrphans()).catch(() => {});
|
|
1628
1634
|
}
|
|
1629
1635
|
meta() {
|
|
1630
1636
|
return {
|
|
@@ -3252,6 +3258,59 @@ function updateQuotaRefreshSchedulerFromConfig() {
|
|
|
3252
3258
|
quotaRefreshScheduler.updateConfig(getQuotaRefreshConfig());
|
|
3253
3259
|
}
|
|
3254
3260
|
//#endregion
|
|
3255
|
-
|
|
3261
|
+
//#region src/lib/proxy.ts
|
|
3262
|
+
let proxyEnvDispatcher;
|
|
3263
|
+
function getProxyEnvDispatcher() {
|
|
3264
|
+
return proxyEnvDispatcher;
|
|
3265
|
+
}
|
|
3266
|
+
function initProxyFromEnv() {
|
|
3267
|
+
try {
|
|
3268
|
+
const direct = new Agent();
|
|
3269
|
+
const proxies = /* @__PURE__ */ new Map();
|
|
3270
|
+
proxyEnvDispatcher = {
|
|
3271
|
+
dispatch(options, handler) {
|
|
3272
|
+
try {
|
|
3273
|
+
const origin = typeof options.origin === "string" ? new URL(options.origin) : options.origin;
|
|
3274
|
+
const raw = getProxyForUrl(origin.toString());
|
|
3275
|
+
const proxyUrl = raw && raw.length > 0 ? raw : void 0;
|
|
3276
|
+
if (!proxyUrl) {
|
|
3277
|
+
consola.debug(`HTTP proxy bypass: ${origin.hostname}`);
|
|
3278
|
+
return direct.dispatch(options, handler);
|
|
3279
|
+
}
|
|
3280
|
+
let agent = proxies.get(proxyUrl);
|
|
3281
|
+
if (!agent) {
|
|
3282
|
+
agent = new ProxyAgent(proxyUrl);
|
|
3283
|
+
proxies.set(proxyUrl, agent);
|
|
3284
|
+
}
|
|
3285
|
+
let label = proxyUrl;
|
|
3286
|
+
try {
|
|
3287
|
+
const u = new URL(proxyUrl);
|
|
3288
|
+
label = `${u.protocol}//${u.host}`;
|
|
3289
|
+
} catch {}
|
|
3290
|
+
consola.debug(`HTTP proxy route: ${origin.hostname} via ${label}`);
|
|
3291
|
+
return agent.dispatch(options, handler);
|
|
3292
|
+
} catch {
|
|
3293
|
+
return direct.dispatch(options, handler);
|
|
3294
|
+
}
|
|
3295
|
+
},
|
|
3296
|
+
close() {
|
|
3297
|
+
return direct.close();
|
|
3298
|
+
},
|
|
3299
|
+
destroy() {
|
|
3300
|
+
return direct.destroy();
|
|
3301
|
+
}
|
|
3302
|
+
};
|
|
3303
|
+
if (typeof Bun !== "undefined") {
|
|
3304
|
+
consola.debug("WebSocket proxy configured from environment (per-URL)");
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
setGlobalDispatcher(proxyEnvDispatcher);
|
|
3308
|
+
consola.debug("HTTP proxy configured from environment (per-URL)");
|
|
3309
|
+
} catch (err) {
|
|
3310
|
+
consola.debug("Proxy setup skipped:", err);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
//#endregion
|
|
3314
|
+
export { getModelRefreshIntervalMs as A, isResponsesApiWebSocketEnabled as B, getAnthropicApiKey as C, getLogLevel as D, getExtraPromptForModel as E, isForceAgentEnabled as F, resolveModelAlias as H, isMessageStartInputTokensFallbackEnabled as I, isMessagesApiEnabled as L, getReasoningEffortForModel as M, getSmallModel as N, getModelAliases as O, isAccountAffinityEnabled as P, isResponsesApiContextManagementModel as R, getAliasTargetSet as S, getConfig as T, shouldCompactUseSmallModel as U, mergeConfigWithDefaults as V, toLocalDateString as _, stopQuotaRefreshScheduler as a, isDevModeEnabled as b, applySharedSessionAffinityRetention as c, getClientIpInfo as d, getRequestHistoryStore as f, normalizeMessagesUsage as g, normalizeEmbeddingsUsage as h, startQuotaRefreshSchedulerFromConfig as i, getProviderConfig as j, getModelAliasesInfo as k, extractResponsesUsageFromResult as l, normalizeChatCompletionsUsage as m, initProxyFromEnv as n, updateQuotaRefreshSchedulerFromConfig as o, getStatsStore as p, registerQuotaRefreshSchedulerShutdownCleanup as r, accountsManager as s, getProxyEnvDispatcher as t, extractResponsesUsageFromStreamEvent as u, copilotFetch as v, getClaudeTokenMultiplier as w, PROVIDER_TYPE_ANTHROPIC as x, flushPendingCapture as y, isResponsesApiWebSearchEnabled as z };
|
|
3256
3315
|
|
|
3257
|
-
//# sourceMappingURL=
|
|
3316
|
+
//# sourceMappingURL=proxy-YVh74m0I.js.map
|