@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.
Files changed (35) hide show
  1. package/README.md +56 -7
  2. package/README.zh-CN.md +55 -6
  3. package/dist/{account-DjCbqJ2Q.js → account-COtMmvzU.js} +2 -2
  4. package/dist/{account-DjCbqJ2Q.js.map → account-COtMmvzU.js.map} +1 -1
  5. package/dist/admin/assets/{index-BRnD4-DB.js → index-DG4TRVMu.js} +36 -36
  6. package/dist/admin/index.html +1 -1
  7. package/dist/{auth--I1utaB6.js → auth-B0y-2njL.js} +3 -3
  8. package/dist/{auth--I1utaB6.js.map → auth-B0y-2njL.js.map} +1 -1
  9. package/dist/{check-usage-DHvjdha4.js → check-usage-DdevqHE5.js} +3 -3
  10. package/dist/{check-usage-DHvjdha4.js.map → check-usage-DdevqHE5.js.map} +1 -1
  11. package/dist/{get-copilot-token-ZbmbVF0I.js → get-copilot-token-8Rm-rVsp.js} +2 -2
  12. package/dist/{get-copilot-token-ZbmbVF0I.js.map → get-copilot-token-8Rm-rVsp.js.map} +1 -1
  13. package/dist/main.js +6 -4
  14. package/dist/main.js.map +1 -1
  15. package/dist/mcp-9Hgepkc5.js +37 -0
  16. package/dist/mcp-9Hgepkc5.js.map +1 -0
  17. package/dist/{poll-access-token-CIPDXrcm.js → poll-access-token-BAgM2-7k.js} +62 -6
  18. package/dist/poll-access-token-BAgM2-7k.js.map +1 -0
  19. package/dist/{quota-refresh-scheduler-runtime-XD2fDa2K.js → proxy-YVh74m0I.js} +67 -8
  20. package/dist/proxy-YVh74m0I.js.map +1 -0
  21. package/dist/{request-outbound-Cy6huWjK.js → request-outbound-BJjWS_jF.js} +1 -1
  22. package/dist/{request-outbound-CxvpSkOn.js → request-outbound-Pu1kp2x8.js} +3 -1
  23. package/dist/request-outbound-Pu1kp2x8.js.map +1 -0
  24. package/dist/{server-BDCnb3Ao.js → server-DmDAepfa.js} +667 -77
  25. package/dist/server-DmDAepfa.js.map +1 -0
  26. package/dist/{start-DkBnp9d8.js → start-D37Bi12h.js} +5 -52
  27. package/dist/start-D37Bi12h.js.map +1 -0
  28. package/dist/tool-search-BrN7M0Dd.js +110 -0
  29. package/dist/tool-search-BrN7M0Dd.js.map +1 -0
  30. package/package.json +3 -6
  31. package/dist/poll-access-token-CIPDXrcm.js.map +0 -1
  32. package/dist/quota-refresh-scheduler-runtime-XD2fDa2K.js.map +0 -1
  33. package/dist/request-outbound-CxvpSkOn.js.map +0 -1
  34. package/dist/server-BDCnb3Ao.js.map +0 -1
  35. package/dist/start-DkBnp9d8.js.map +0 -1
@@ -1,11 +1,13 @@
1
- import { M as requestContext, O as accountFromState, _ as HTTPError, g as getCopilotUsage, j as consumeOutboundHeadersSnapshot, m as getGitHubUser, x as copilotModelsHeaders, y as copilotBaseUrl } from "./poll-access-token-CIPDXrcm.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-DjCbqJ2Q.js";
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-ZbmbVF0I.js";
5
- import { c as getAdminDbUserVersion, i as getRequestOutboundStore, o as getAdminDb, s as getAdminDbPath } from "./request-outbound-CxvpSkOn.js";
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-Cy6huWjK.js").then((m) => m.getRequestOutboundStore().cleanupOrphans()).catch(() => {});
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
- export { getReasoningEffortForModel as A, shouldCompactUseSmallModel as B, getConfig as C, getModelAliasesInfo as D, getModelAliases as E, isMessagesApiEnabled as F, isResponsesApiContextManagementModel as I, isResponsesApiWebSearchEnabled as L, isAccountAffinityEnabled as M, isForceAgentEnabled as N, getModelRefreshIntervalMs as O, isMessageStartInputTokensFallbackEnabled as P, mergeConfigWithDefaults as R, getClaudeTokenMultiplier as S, getLogLevel as T, flushPendingCapture as _, accountsManager as a, getAliasTargetSet as b, extractResponsesUsageFromStreamEvent as c, getStatsStore as d, normalizeChatCompletionsUsage as f, copilotFetch as g, toLocalDateString as h, updateQuotaRefreshSchedulerFromConfig as i, getSmallModel as j, getProviderConfig as k, getClientIpInfo as l, normalizeMessagesUsage as m, startQuotaRefreshSchedulerFromConfig as n, applySharedSessionAffinityRetention as o, normalizeEmbeddingsUsage as p, stopQuotaRefreshScheduler as r, extractResponsesUsageFromResult as s, registerQuotaRefreshSchedulerShutdownCleanup as t, getRequestHistoryStore as u, isDevModeEnabled as v, getExtraPromptForModel as w, getAnthropicApiKey as x, PROVIDER_TYPE_ANTHROPIC as y, resolveModelAlias as z };
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=quota-refresh-scheduler-runtime-XD2fDa2K.js.map
3316
+ //# sourceMappingURL=proxy-YVh74m0I.js.map