@jeffreycao/copilot-api 2.7.36 → 2.7.38

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.
@@ -1,12 +1,14 @@
1
- import { C as ensurePaths, D as state, E as isGitHubCopilotEnabled, _ as mergeConfigWithDefaults } from "./config-store-CYG9aCTL.js";
2
- import { b as startModelsDevCache, i as listEnabledProviders } from "./config-D8pUyhJp.js";
3
- import { A as initOpencodeVersion, G as GITHUB_TOKEN_ENV, K as readGitHubToken, R as getConfiguredApiKeys, q as readGitHubTokenFromEnv, z as getMissingApiKeysMessage } from "./token-BL6FigKp.js";
4
- import { o as runProviderSetup } from "./auth-BnQ_KOxT.js";
5
- import { t as setupCopilotRuntime } from "./copilot-runtime-RW0tbgv3.js";
1
+ import { C as ensurePaths, D as state, E as isGitHubCopilotEnabled, S as PATHS, _ as mergeConfigWithDefaults } from "./config-store-CYG9aCTL.js";
2
+ import { b as startModelsDevCache, i as listEnabledProviders } from "./config-BzhriV_y.js";
3
+ import { A as initOpencodeVersion, G as GITHUB_TOKEN_ENV, K as readGitHubToken, R as getConfiguredApiKeys, q as readGitHubTokenFromEnv, z as getMissingApiKeysMessage } from "./token-XNKmjmqH.js";
4
+ import { o as runProviderSetup } from "./auth-jHSWJs1b.js";
5
+ import { i as registerProcessCleanup, r as EventBus, t as setupCopilotRuntime } from "./copilot-runtime-8IpywGxw.js";
6
6
  import { defineCommand } from "citty";
7
7
  import consola from "consola";
8
+ import { resolve } from "node:path";
8
9
  import { getProxyForUrl } from "proxy-from-env";
9
10
  import { Agent, ProxyAgent, setGlobalDispatcher } from "undici";
11
+ import { pathToFileURL } from "node:url";
10
12
  import { serve } from "srvx";
11
13
  import { isIP } from "node:net";
12
14
  //#region src/lib/proxy.ts
@@ -118,6 +120,128 @@ function formatServerUrl(hostname, port) {
118
120
  return `http://${isIP(hostname) === 6 ? `[${hostname.replace("%", "%25")}]` : hostname}:${port}`;
119
121
  }
120
122
  //#endregion
123
+ //#region src/lib/gateway-plugins.ts
124
+ const MAX_PENDING_EVENTS = 1024;
125
+ var GatewayPlugins = class {
126
+ bus = new EventBus();
127
+ plugins = [];
128
+ subscriptions = 0;
129
+ closing;
130
+ port;
131
+ constructor(port) {
132
+ this.port = port;
133
+ }
134
+ get enabled() {
135
+ return this.subscriptions > 0;
136
+ }
137
+ async register(name, setup) {
138
+ if (this.closing) throw new Error("Gateway plugins are closing");
139
+ const plugin = {
140
+ name,
141
+ pending: 0,
142
+ overflowReported: false,
143
+ tail: Promise.resolve(),
144
+ unsubscribe: []
145
+ };
146
+ const api = Object.freeze({
147
+ version: 1,
148
+ server: Object.freeze({
149
+ pid: process.pid,
150
+ port: this.port
151
+ }),
152
+ on: (event, handler) => {
153
+ if (this.closing) throw new Error("Gateway plugins are closing");
154
+ const off = this.bus.subscribe(event, (value) => {
155
+ if (plugin.pending >= MAX_PENDING_EVENTS) {
156
+ if (!plugin.overflowReported) {
157
+ plugin.overflowReported = true;
158
+ consola.warn(`Plugin '${name}' event queue is full; dropping events`);
159
+ }
160
+ return;
161
+ }
162
+ plugin.pending++;
163
+ plugin.tail = plugin.tail.then(async () => {
164
+ try {
165
+ await handler(value);
166
+ } catch (error) {
167
+ consola.warn(`Plugin '${name}' hook failed`, error);
168
+ } finally {
169
+ plugin.pending--;
170
+ if (!plugin.pending) plugin.overflowReported = false;
171
+ }
172
+ });
173
+ });
174
+ this.subscriptions++;
175
+ let active = true;
176
+ const unsubscribe = () => {
177
+ if (!active) return;
178
+ active = false;
179
+ off();
180
+ this.subscriptions--;
181
+ };
182
+ plugin.unsubscribe.push(unsubscribe);
183
+ return unsubscribe;
184
+ },
185
+ log: (message) => consola.info(`[plugin:${name}] ${message}`)
186
+ });
187
+ try {
188
+ const cleanup = await setup(api);
189
+ if (typeof cleanup === "function") plugin.cleanup = cleanup;
190
+ this.plugins.push(plugin);
191
+ } catch (error) {
192
+ for (const off of plugin.unsubscribe) off();
193
+ throw error;
194
+ }
195
+ }
196
+ publish(name, event) {
197
+ if (this.enabled) {
198
+ const snapshot = { ...event };
199
+ Object.freeze(snapshot);
200
+ this.bus.publish(name, snapshot);
201
+ }
202
+ }
203
+ async flush() {
204
+ await Promise.all(this.plugins.map((plugin) => plugin.tail));
205
+ }
206
+ close(timeoutMs = 2e3) {
207
+ if (this.closing) return this.closing;
208
+ for (const plugin of this.plugins) for (const off of plugin.unsubscribe) off();
209
+ let timer;
210
+ const shutdown = Promise.all(this.plugins.map(async (plugin) => {
211
+ await plugin.tail;
212
+ try {
213
+ await plugin.cleanup?.();
214
+ } catch (error) {
215
+ consola.warn(`Plugin '${plugin.name}' cleanup failed`, error);
216
+ }
217
+ }));
218
+ const timeout = new Promise((resolveTimeout) => {
219
+ timer = setTimeout(resolveTimeout, timeoutMs);
220
+ });
221
+ this.closing = Promise.race([shutdown, timeout]).then(() => {
222
+ clearTimeout(timer);
223
+ });
224
+ return this.closing;
225
+ }
226
+ };
227
+ async function loadGatewayPlugins(setting, options) {
228
+ if (!setting?.trim()) return void 0;
229
+ const paths = JSON.parse(setting);
230
+ if (!Array.isArray(paths) || !paths.every((path) => typeof path === "string" && path.trim())) throw new Error("COPILOT_API_PLUGINS must be a JSON array of local module paths");
231
+ const plugins = new GatewayPlugins(options.port);
232
+ for (const path of new Set(paths)) {
233
+ const url = pathToFileURL(resolve(options.baseDir, path)).href;
234
+ try {
235
+ const module = await import(url);
236
+ if (!module || typeof module !== "object" || !("default" in module) || typeof module.default !== "function") throw new Error("Plugin must default-export a setup function");
237
+ await plugins.register(path, module.default);
238
+ } catch (error) {
239
+ consola.warn(`Failed to load gateway plugin '${path}'`, error);
240
+ }
241
+ }
242
+ return plugins;
243
+ }
244
+ //#endregion
121
245
  //#region src/start.ts
122
246
  async function resolveGitHubToken(cliToken) {
123
247
  if (cliToken) return {
@@ -181,8 +305,17 @@ async function runServer(options) {
181
305
  if (resolvedGitHubToken && isGitHubCopilotEnabled()) await setupCopilotMode(resolvedGitHubToken.token, resolvedGitHubToken.source);
182
306
  else await setupProviderMode();
183
307
  consola.box(`🌐 Dashboard Viewer: ${serverUrl}/usage-viewer?endpoint=${serverUrl}/usage`);
184
- const { createServer } = await import("./server-BogSoFE5.js");
185
- const server = createServer({ networkExposed: binding.networkExposed });
308
+ const { createServer } = await import("./server-CEF4Sh-g.js");
309
+ const plugins = await loadGatewayPlugins(process.env.COPILOT_API_PLUGINS, {
310
+ port: options.port,
311
+ baseDir: PATHS.APP_DIR
312
+ });
313
+ if (plugins) registerProcessCleanup(() => plugins.close());
314
+ const server = createServer({
315
+ networkExposed: binding.networkExposed,
316
+ port: options.port,
317
+ plugins
318
+ });
186
319
  serve({
187
320
  fetch: server.fetch,
188
321
  hostname: binding.hostname,
@@ -243,4 +376,4 @@ const start = defineCommand({
243
376
  //#endregion
244
377
  export { start };
245
378
 
246
- //# sourceMappingURL=start-CH9AVcLK.js.map
379
+ //# sourceMappingURL=start-Bawh7LU_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-Bawh7LU_.js","names":["get"],"sources":["../src/lib/proxy.ts","../src/lib/server-host-shared.ts","../src/lib/server-host.ts","../src/lib/gateway-plugins.ts","../src/start.ts"],"sourcesContent":["import consola from \"consola\"\nimport { getProxyForUrl } from \"proxy-from-env\"\nimport { Agent, ProxyAgent, setGlobalDispatcher, type Dispatcher } from \"undici\"\n\nlet proxyEnvDispatcher: Dispatcher | undefined\n\nexport function getProxyEnvDispatcher(): Dispatcher | undefined {\n return proxyEnvDispatcher\n}\n\nexport function initProxyFromEnv(): void {\n try {\n const direct = new Agent()\n const proxies = new Map<string, ProxyAgent>()\n\n // We only need a minimal dispatcher that implements `dispatch` at runtime.\n // Typing the object as `Dispatcher` forces TypeScript to require many\n // additional methods. Instead, keep a plain object and cast when passing\n // to `setGlobalDispatcher`.\n const dispatcher = {\n dispatch(\n options: Dispatcher.DispatchOptions,\n handler: Dispatcher.DispatchHandler,\n ) {\n try {\n const origin =\n typeof options.origin === \"string\" ?\n new URL(options.origin)\n : (options.origin as URL)\n const get = getProxyForUrl as unknown as (\n u: string,\n ) => string | undefined\n const raw = get(origin.toString())\n const proxyUrl = raw && raw.length > 0 ? raw : undefined\n if (!proxyUrl) {\n consola.debug(`HTTP proxy bypass: ${origin.hostname}`)\n return (direct as unknown as Dispatcher).dispatch(options, handler)\n }\n let agent = proxies.get(proxyUrl)\n if (!agent) {\n agent = new ProxyAgent(proxyUrl)\n proxies.set(proxyUrl, agent)\n }\n let label = proxyUrl\n try {\n const u = new URL(proxyUrl)\n label = `${u.protocol}//${u.host}`\n } catch {\n /* noop */\n }\n consola.debug(`HTTP proxy route: ${origin.hostname} via ${label}`)\n return (agent as unknown as Dispatcher).dispatch(options, handler)\n } catch {\n return (direct as unknown as Dispatcher).dispatch(options, handler)\n }\n },\n close() {\n return direct.close()\n },\n destroy() {\n return direct.destroy()\n },\n }\n\n proxyEnvDispatcher = dispatcher as unknown as Dispatcher\n\n if (typeof Bun !== \"undefined\") {\n consola.debug(\"WebSocket proxy configured from environment (per-URL)\")\n return\n }\n\n setGlobalDispatcher(proxyEnvDispatcher)\n consola.debug(\"HTTP proxy configured from environment (per-URL)\")\n } catch (err) {\n consola.debug(\"Proxy setup skipped:\", err)\n }\n}\n","// Pure hostname helpers shared by the gateway server (Node) and the desktop\n// app (including the renderer bundle). This module must stay free of\n// `node:*` imports because the renderer cannot use `node:net`; all\n// address-family checks live in `server-host.ts`.\nexport const INVALID_HOST_CHARACTERS = /[\\s/?#]/\n\n// Bind hosts that listen on every interface, in normalized form (no\n// brackets, so \"[::]\" is covered via `stripIpv6Brackets`).\nexport const NORMALIZED_WILDCARD_HOSTS = new Set([\"0.0.0.0\", \"::\"])\n\nexport function stripIpv6Brackets(hostname: string): string {\n if (hostname.startsWith(\"[\") && hostname.endsWith(\"]\")) {\n return hostname.slice(1, -1)\n }\n return hostname\n}\n\nexport function normalizeHostnameBase(hostname: string): string {\n const normalized = stripIpv6Brackets(hostname.trim())\n if (!normalized || INVALID_HOST_CHARACTERS.test(normalized)) {\n throw new Error(`Invalid server host: ${JSON.stringify(hostname)}`)\n }\n return normalized\n}\n\nexport function isWildcardHostname(hostname: string): boolean {\n return NORMALIZED_WILDCARD_HOSTS.has(stripIpv6Brackets(hostname.trim()))\n}\n","import { isIP } from \"node:net\"\n\nimport { isWildcardHostname, normalizeHostnameBase } from \"./server-host-shared\"\n\nexport const DEFAULT_SERVER_HOST = \"127.0.0.1\"\n\n// Listen failures that mean the hostname itself cannot be bound, as opposed\n// to the port being occupied (EADDRINUSE) or forbidden (EACCES). ENOTFOUND\n// covers unresolvable names such as typos, EADDRNOTAVAIL covers valid IPs\n// that are not assigned to this machine.\nconst INVALID_BIND_ERROR_CODES = new Set([\n \"ENOTFOUND\",\n \"EADDRNOTAVAIL\",\n \"EINVAL\",\n \"EAFNOSUPPORT\",\n \"ENXIO\",\n])\n\nexport function isInvalidBindErrorCode(code?: string): boolean {\n return !!code && INVALID_BIND_ERROR_CODES.has(code)\n}\n\nexport interface ServerBinding {\n hostname: string\n clientHostname: string\n networkExposed: boolean\n}\n\nfunction isLoopbackIpv4(hostname: string): boolean {\n return isIP(hostname) === 4 && hostname.split(\".\", 1)[0] === \"127\"\n}\n\nfunction isLoopbackMappedIpv4(hostname: string): boolean {\n try {\n const canonicalHostname = new URL(`http://[${hostname}]/`).hostname.slice(\n 1,\n -1,\n )\n const mappedIpv4 = canonicalHostname.match(\n /^::ffff:([\\da-f]{1,4}):[\\da-f]{1,4}$/,\n )\n if (!mappedIpv4) {\n return false\n }\n\n return (Number.parseInt(mappedIpv4[1], 16) & 0xff00) === 0x7f00\n } catch {\n return false\n }\n}\n\nexport function normalizeServerHostname(hostname: string): string {\n return normalizeHostnameBase(hostname)\n}\n\nexport function isLoopbackHostname(hostname: string): boolean {\n const normalized = normalizeServerHostname(hostname).toLowerCase()\n if (normalized === \"localhost\" || normalized === \"localhost.\") {\n return true\n }\n if (isLoopbackIpv4(normalized)) {\n return true\n }\n if (isIP(normalized) !== 6) {\n return false\n }\n\n if (normalized === \"::1\" || normalized === \"0:0:0:0:0:0:0:1\") {\n return true\n }\n\n return isLoopbackMappedIpv4(normalized)\n}\n\nexport function resolveServerBinding(\n hostname: string,\n hasApiKeys: boolean,\n): ServerBinding {\n const normalizedHostname = normalizeServerHostname(hostname)\n const networkExposed = !isLoopbackHostname(normalizedHostname)\n\n if (networkExposed && !hasApiKeys) {\n throw new Error(\n `Refusing to listen on non-loopback host ${JSON.stringify(normalizedHostname)} without gateway API keys. Run \\`npx @jeffreycao/copilot-api@latest auth keys --add <key>\\` first, or use \\`--host ${DEFAULT_SERVER_HOST}\\`.`,\n )\n }\n\n return {\n hostname: normalizedHostname,\n clientHostname: resolveClientHostname(normalizedHostname),\n networkExposed,\n }\n}\n\nexport function resolveClientHostname(hostname: string): string {\n const normalizedHostname = normalizeServerHostname(hostname)\n // Wildcard binds listen on every interface, which clients cannot dial\n // directly (0.0.0.0 is not a routable destination).\n return isWildcardHostname(normalizedHostname) ? DEFAULT_SERVER_HOST : (\n normalizedHostname.toLowerCase()\n )\n}\n\nexport function resolveClientHostnameOrDefault(\n hostname: string | null | undefined,\n): string {\n const normalizedHostname = hostname?.trim()\n return normalizedHostname ?\n resolveClientHostname(normalizedHostname)\n : DEFAULT_SERVER_HOST\n}\n\nexport function formatServerUrl(hostname: string, port: number): string {\n const urlHostname =\n isIP(hostname) === 6 ? `[${hostname.replace(\"%\", \"%25\")}]` : hostname\n return `http://${urlHostname}:${port}`\n}\n","import consola from \"consola\"\nimport { resolve } from \"node:path\"\nimport { pathToFileURL } from \"node:url\"\n\nimport { EventBus } from \"./event-bus\"\nimport type {\n GatewayPluginApi,\n GatewayPluginEvents,\n GatewayPluginSetup,\n} from \"./types/gateway-plugins\"\nexport type {\n GatewayPluginApi,\n GatewayPluginEvents,\n GatewayPluginSetup,\n PluginRequest,\n} from \"./types/gateway-plugins\"\n\nconst MAX_PENDING_EVENTS = 1024\n\ninterface PluginState {\n name: string\n pending: number\n overflowReported: boolean\n tail: Promise<void>\n unsubscribe: Array<() => void>\n cleanup?: () => void | Promise<void>\n}\n\n// Each plugin has a bounded, ordered queue. Requests never await plugin I/O.\nexport class GatewayPlugins {\n private readonly bus = new EventBus<GatewayPluginEvents>()\n private readonly plugins: Array<PluginState> = []\n private subscriptions = 0\n private closing: Promise<void> | undefined\n\n private readonly port: number\n\n constructor(port: number) {\n this.port = port\n }\n\n get enabled(): boolean {\n return this.subscriptions > 0\n }\n\n async register(name: string, setup: GatewayPluginSetup): Promise<void> {\n if (this.closing) throw new Error(\"Gateway plugins are closing\")\n const plugin: PluginState = {\n name,\n pending: 0,\n overflowReported: false,\n tail: Promise.resolve(),\n unsubscribe: [],\n }\n const api: GatewayPluginApi = Object.freeze({\n version: 1 as const,\n server: Object.freeze({ pid: process.pid, port: this.port }),\n on: <Name extends keyof GatewayPluginEvents>(\n event: Name,\n handler: (\n value: Readonly<GatewayPluginEvents[Name]>,\n ) => void | Promise<void>,\n ) => {\n if (this.closing) throw new Error(\"Gateway plugins are closing\")\n const off = this.bus.subscribe(event, (value) => {\n if (plugin.pending >= MAX_PENDING_EVENTS) {\n if (!plugin.overflowReported) {\n plugin.overflowReported = true\n consola.warn(\n `Plugin '${name}' event queue is full; dropping events`,\n )\n }\n return\n }\n plugin.pending++\n plugin.tail = plugin.tail.then(async () => {\n try {\n await handler(value)\n } catch (error) {\n consola.warn(`Plugin '${name}' hook failed`, error)\n } finally {\n plugin.pending--\n if (!plugin.pending) plugin.overflowReported = false\n }\n })\n })\n this.subscriptions++\n let active = true\n const unsubscribe = () => {\n if (!active) return\n active = false\n off()\n this.subscriptions--\n }\n plugin.unsubscribe.push(unsubscribe)\n return unsubscribe\n },\n log: (message: string) => consola.info(`[plugin:${name}] ${message}`),\n })\n try {\n const cleanup = await setup(api)\n if (typeof cleanup === \"function\") plugin.cleanup = cleanup\n this.plugins.push(plugin)\n } catch (error) {\n for (const off of plugin.unsubscribe) off()\n throw error\n }\n }\n\n publish<Name extends keyof GatewayPluginEvents>(\n name: Name,\n event: GatewayPluginEvents[Name],\n ): void {\n if (this.enabled) {\n const snapshot = { ...event }\n Object.freeze(snapshot)\n this.bus.publish<Name>(name, snapshot)\n }\n }\n\n async flush(): Promise<void> {\n await Promise.all(this.plugins.map((plugin) => plugin.tail))\n }\n\n close(timeoutMs = 2000): Promise<void> {\n if (this.closing) return this.closing\n for (const plugin of this.plugins) {\n for (const off of plugin.unsubscribe) off()\n }\n let timer: ReturnType<typeof setTimeout>\n const shutdown = Promise.all(\n this.plugins.map(async (plugin) => {\n await plugin.tail\n try {\n await plugin.cleanup?.()\n } catch (error) {\n consola.warn(`Plugin '${plugin.name}' cleanup failed`, error)\n }\n }),\n )\n const timeout = new Promise<void>((resolveTimeout) => {\n timer = setTimeout(resolveTimeout, timeoutMs)\n })\n this.closing = Promise.race([shutdown, timeout]).then(() => {\n clearTimeout(timer)\n })\n return this.closing\n }\n}\n\nexport async function loadGatewayPlugins(\n setting: string | undefined,\n options: { port: number; baseDir: string },\n): Promise<GatewayPlugins | undefined> {\n if (!setting?.trim()) return undefined\n const paths: unknown = JSON.parse(setting)\n if (\n !Array.isArray(paths)\n || !paths.every((path: unknown) => typeof path === \"string\" && path.trim())\n ) {\n throw new Error(\n \"COPILOT_API_PLUGINS must be a JSON array of local module paths\",\n )\n }\n const plugins = new GatewayPlugins(options.port)\n for (const path of new Set(paths as Array<string>)) {\n const url = pathToFileURL(resolve(options.baseDir, path)).href\n try {\n const module: unknown = await import(url)\n if (\n !module\n || typeof module !== \"object\"\n || !(\"default\" in module)\n || typeof module.default !== \"function\"\n ) {\n throw new Error(\"Plugin must default-export a setup function\")\n }\n await plugins.register(path, module.default as GatewayPluginSetup)\n } catch (error) {\n consola.warn(`Failed to load gateway plugin '${path}'`, error)\n }\n }\n return plugins\n}\n","#!/usr/bin/env node\n\nimport { defineCommand } from \"citty\"\nimport consola from \"consola\"\nimport { serve, type ServerHandler } from \"srvx\"\n\nimport { runProviderSetup } from \"./auth\"\nimport { isGitHubCopilotEnabled } from \"./lib/github-copilot-provider\"\nimport { listEnabledProviders, mergeConfigWithDefaults } from \"./lib/config\"\nimport { setupCopilotRuntime } from \"~/lib/copilot-runtime\"\nimport {\n GITHUB_TOKEN_ENV,\n readGitHubToken,\n readGitHubTokenFromEnv,\n} from \"./lib/credential-store\"\nimport { startModelsDevCache } from \"./lib/models-dev-cache\"\nimport { initOpencodeVersion } from \"./lib/opencode\"\nimport { ensurePaths, PATHS } from \"./lib/paths\"\nimport { initProxyFromEnv } from \"./lib/proxy\"\nimport {\n getConfiguredApiKeys,\n getMissingApiKeysMessage,\n} from \"./lib/request-auth\"\nimport {\n DEFAULT_SERVER_HOST,\n formatServerUrl,\n resolveServerBinding,\n} from \"./lib/server-host\"\nimport { state } from \"./lib/state\"\nimport { loadGatewayPlugins } from \"./lib/gateway-plugins\"\nimport { registerProcessCleanup } from \"./lib/process-cleanup\"\n\ninterface RunServerOptions {\n host: string\n port: number\n verbose: boolean\n githubToken?: string\n showToken: boolean\n proxyEnv: boolean\n}\n\ntype GitHubTokenSource = \"cli\" | \"env\" | \"file\"\n\n// The environment is preferred over the token file so the token never has to\n// travel through the process list; --github-token stays first for callers that\n// opt in explicitly.\nasync function resolveGitHubToken(\n cliToken: string | undefined,\n): Promise<{ token: string; source: GitHubTokenSource } | null> {\n if (cliToken) return { token: cliToken, source: \"cli\" }\n\n const envToken = readGitHubTokenFromEnv()\n if (envToken) return { token: envToken, source: \"env\" }\n\n const fileToken = await readGitHubToken()\n if (fileToken) return { token: fileToken, source: \"file\" }\n\n return null\n}\n\nasync function setupCopilotMode(\n githubToken: string,\n source: GitHubTokenSource,\n): Promise<void> {\n state.githubTokenSource = source\n consola.info(\n source === \"cli\" ? \"Using provided GitHub token\"\n : source === \"env\" ?\n `Using GitHub token from the ${GITHUB_TOKEN_ENV} environment variable`\n : \"Using GitHub token from local file\",\n )\n\n await setupCopilotRuntime(githubToken)\n}\n\nasync function setupProviderMode(): Promise<void> {\n const enabledProviders = listEnabledProviders()\n\n if (enabledProviders.length > 0) {\n consola.info(`Using enabled providers: ${enabledProviders.join(\", \")}`)\n return\n }\n\n if (!isGitHubCopilotEnabled()) {\n throw new Error(\n \"No enabled providers found. Enable GitHub Copilot with `copilot-api provider enable github-copilot`, or enable another configured provider.\",\n )\n }\n\n consola.info(\"No enabled providers found. Setting one up...\")\n await runProviderSetup()\n\n if (state.githubToken && isGitHubCopilotEnabled()) {\n // The setup flow persisted the token with the credential store.\n await setupCopilotMode(state.githubToken, \"file\")\n return\n }\n\n const providersAfterSetup = listEnabledProviders()\n if (providersAfterSetup.length === 0) {\n throw new Error(\n \"Failed to configure any provider. Run `copilot-api auth login` to set one up.\",\n )\n }\n consola.info(`Configured providers: ${providersAfterSetup.join(\", \")}`)\n}\n\nexport async function runServer(options: RunServerOptions): Promise<void> {\n const tlsModule = await import(\"./lib/tls\")\n tlsModule.enableSystemCACompat()\n\n consola.options.throttle = 0\n\n mergeConfigWithDefaults()\n\n const configuredApiKeys = getConfiguredApiKeys()\n const binding = resolveServerBinding(\n options.host,\n configuredApiKeys.length > 0,\n )\n\n const missingApiKeysMessage = getMissingApiKeysMessage()\n if (missingApiKeysMessage) {\n consola.info(missingApiKeysMessage)\n }\n\n await initOpencodeVersion()\n\n if (options.proxyEnv) {\n initProxyFromEnv()\n }\n\n state.verbose = options.verbose\n if (options.verbose) {\n consola.level = 5\n consola.info(\"Verbose logging enabled\")\n }\n\n state.showToken = options.showToken\n\n await ensurePaths()\n await startModelsDevCache()\n\n const serverUrl = formatServerUrl(binding.clientHostname, options.port)\n\n const resolvedGitHubToken =\n isGitHubCopilotEnabled() ?\n await resolveGitHubToken(options.githubToken)\n : null\n if (resolvedGitHubToken && isGitHubCopilotEnabled()) {\n await setupCopilotMode(\n resolvedGitHubToken.token,\n resolvedGitHubToken.source,\n )\n } else {\n await setupProviderMode()\n }\n\n consola.box(\n `🌐 Dashboard Viewer: ${serverUrl}/usage-viewer?endpoint=${serverUrl}/usage`,\n )\n\n const { createServer } = await import(\"./server\")\n const plugins = await loadGatewayPlugins(process.env.COPILOT_API_PLUGINS, {\n port: options.port,\n baseDir: PATHS.APP_DIR,\n })\n if (plugins) registerProcessCleanup(() => plugins.close())\n const server = createServer({\n networkExposed: binding.networkExposed,\n port: options.port,\n plugins,\n })\n\n serve({\n fetch: server.fetch as ServerHandler,\n hostname: binding.hostname,\n port: options.port,\n bun: {\n idleTimeout: 0,\n },\n })\n}\n\nexport const start = defineCommand({\n meta: {\n name: \"start\",\n description: \"Start the Copilot API server\",\n },\n args: {\n host: {\n type: \"string\",\n default: process.env.HOST?.trim() || DEFAULT_SERVER_HOST,\n description: \"Host to listen on\",\n },\n port: {\n alias: \"p\",\n type: \"string\",\n default: \"4141\",\n description: \"Port to listen on\",\n },\n verbose: {\n alias: \"v\",\n type: \"boolean\",\n default: false,\n description: \"Enable verbose logging\",\n },\n \"github-token\": {\n alias: \"g\",\n type: \"string\",\n description:\n \"Provide GitHub token directly (must be generated using the `auth` subcommand)\",\n },\n \"show-token\": {\n type: \"boolean\",\n default: false,\n description: \"Show GitHub and Copilot tokens on fetch and refresh\",\n },\n \"proxy-env\": {\n type: \"boolean\",\n default: false,\n description: \"Initialize proxy from environment variables\",\n },\n },\n run({ args }) {\n return runServer({\n host: args.host,\n port: Number.parseInt(args.port, 10),\n verbose: args.verbose,\n githubToken: args[\"github-token\"],\n showToken: args[\"show-token\"],\n proxyEnv: args[\"proxy-env\"],\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;AAIA,IAAI;AAMJ,SAAgB,mBAAyB;CACvC,IAAI;EACF,MAAM,SAAS,IAAI,MAAM;EACzB,MAAM,0BAAU,IAAI,IAAwB;EAmD5C,qBAAqB;GA5CnB,SACE,SACA,SACA;IACA,IAAI;KACF,MAAM,SACJ,OAAO,QAAQ,WAAW,WACxB,IAAI,IAAI,QAAQ,MAAM,IACrB,QAAQ;KAIb,MAAM,MAAMA,eAAI,OAAO,SAAS,CAAC;KACjC,MAAM,WAAW,O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B,QAAQ,IAAI,qBAAqB;EACxE,MAAM,QAAQ;EACd,SAAS,MAAM;CACjB,CAAC;CACD,IAAI,SAAS,6BAA6B,QAAQ,MAAM,CAAC;CACzD,MAAM,SAAS,aAAa;EAC1B,gBAAgB,QAAQ;EACxB,MAAM,QAAQ;EACd;CACF,CAAC;CAED,MAAM;EACJ,OAAO,OAAO;EACd,UAAU,QAAQ;EAClB,MAAM,QAAQ;EACd,KAAK,EACH,aAAa,EACf;CACF,CAAC;AACH;AAEA,MAAa,QAAQ,cAAc;CACjC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,MAAM;GACJ,MAAM;GACN,SAAS,QAAQ,IAAI,MAAM,KAAK,KAAA;GAChC,aAAa;EACf;EACA,MAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,aAAa;EACf;EACA,SAAS;GACP,OAAO;GACP,MAAM;GACN,SAAS;GACT,aAAa;EACf;EACA,gBAAgB;GACd,OAAO;GACP,MAAM;GACN,aACE;EACJ;EACA,cAAc;GACZ,MAAM;GACN,SAAS;GACT,aAAa;EACf;EACA,aAAa;GACX,MAAM;GACN,SAAS;GACT,aAAa;EACf;CACF;CACA,IAAI,EAAE,QAAQ;EACZ,OAAO,UAAU;GACf,MAAM,KAAK;GACX,MAAM,OAAO,SAAS,KAAK,MAAM,EAAE;GACnC,SAAS,KAAK;GACd,aAAa,KAAK;GAClB,WAAW,KAAK;GAChB,UAAU,KAAK;EACjB,CAAC;CACH;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { A as UpstreamStreamInactivityTimeoutError, D as state, M as writeFileAtomically, O as HTTPError, S as PATHS, T as assertGitHubCopilotEnabled, c as getConfig, d as getUpstreamTransportConfig, g as isResponsesApiWebSocketEnabled, k as UpstreamHeadersTimeoutError, v as readEditableConfigFromDisk } from "./config-store-CYG9aCTL.js";
2
- import { c as setProviderConfig, n as getRawProviderConfig } from "./config-D8pUyhJp.js";
2
+ import { c as setProviderConfig, n as getRawProviderConfig } from "./config-BzhriV_y.js";
3
3
  import consola from "consola";
4
4
  import { createHash, randomBytes, randomUUID } from "node:crypto";
5
5
  import path from "node:path";
@@ -654,6 +654,9 @@ const requestContext = {
654
654
  getStore: () => asyncLocalStorage.getStore(),
655
655
  run: (context, callback) => asyncLocalStorage.run(context, callback)
656
656
  };
657
+ function setPluginRequestActualModel(model) {
658
+ requestContext.getStore()?.pluginRequest?.setActualModel(model);
659
+ }
657
660
  function generateTraceId() {
658
661
  return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
659
662
  }
@@ -801,6 +804,7 @@ function prepareCodexResponsesWebSocketRequest(payload, requestHeaders, baseUrl
801
804
  async function forwardCodexResponses(payload, requestHeaders, baseUrl = CODEX_API_BASE_URL, options = {}) {
802
805
  consola.log(`<-- model: ${payload.model}`);
803
806
  options.clientSignal?.throwIfAborted();
807
+ setPluginRequestActualModel(payload.model);
804
808
  const transport = resolveCodexResponsesTransport(options.transport);
805
809
  if (payload.stream && transport === "websocket") return forwardCodexResponsesOverWebSocket(payload, requestHeaders, baseUrl, options.clientSignal, options.onResponseHeaders);
806
810
  const normalizedPayload = normalizeCodexResponsesPayload(payload);
@@ -2757,6 +2761,6 @@ async function logUser(dependencies = defaultCopilotTokenDependencies) {
2757
2761
  state.tokenBasedBilling = copilotUser.token_based_billing;
2758
2762
  }
2759
2763
  //#endregion
2760
- export { forwardCodexResponses as $, initOpencodeVersion as A, getXaiAccessToken as B, copilotHeaders as C, prepareForCompact as D, isOpencodeOauthApp as E, compactTextOnlyGuard as F, GITHUB_TOKEN_ENV as G, persistXaiCredentials as H, createAuthMiddleware as I, XAI_API_BASE_URL as J, readGitHubToken as K, getConfiguredAdminApiKeys as L, compactMessageSections as M, compactSummaryPromptStart as N, prepareInteractionHeaders as O, compactSystemPromptStarts as P, buildCodexRequestHeaders as Q, getConfiguredApiKeys as R, copilotBaseUrl as S, copilotWebSocketHeaders as T, removeXaiAccount as U, getXaiAccounts as V, selectXaiAccount as W, loginCodex as X, loginXai as Y, CODEX_API_BASE_URL as Z, isAsyncIterable as _, removeCodexAccount as a, createResponsesSafeStream as at, parseUserIdMetadata as b, setupCopilotToken as c, createPooledWebSocketStream as ct, generateRequestIdFromPayload as d, stripInternalRequestHeaders as dt, generateTraceId as et, getPromptCacheKey as f, getUUID as g, getSessionAffinityFromHeaders as h, persistCodexCredentials as i, createResponsesHttpEventStream as it, compactAutoContinuePromptStarts as j, prepareMessageProxyHeaders as k, setupGitHubToken as l, createWebSocketUrl as lt, getRootSessionIdFromHeaders as m, invalidateCodexRuntime as n, resolveTraceId as nt, selectCodexAccount as o, encodePoolKeyPart as ot, getRootSessionId as p, readGitHubTokenFromEnv as q, logUser as r, fetchUpstreamWithLifecycle as rt, setupCodexToken as s, getResponsesStreamTerminalDisposition as st, getCodexAccounts as t, requestContext as tt, stopCopilotRefreshLoop as u, FULL_MODEL_CATALOG_HEADER as ut, isNullish as v, copilotModelsHeaders as w, getCopilotUsage as x, isResponsesStream as y, getMissingApiKeysMessage as z };
2764
+ export { forwardCodexResponses as $, initOpencodeVersion as A, getXaiAccessToken as B, copilotHeaders as C, prepareForCompact as D, isOpencodeOauthApp as E, compactTextOnlyGuard as F, GITHUB_TOKEN_ENV as G, persistXaiCredentials as H, createAuthMiddleware as I, XAI_API_BASE_URL as J, readGitHubToken as K, getConfiguredAdminApiKeys as L, compactMessageSections as M, compactSummaryPromptStart as N, prepareInteractionHeaders as O, compactSystemPromptStarts as P, buildCodexRequestHeaders as Q, getConfiguredApiKeys as R, copilotBaseUrl as S, copilotWebSocketHeaders as T, removeXaiAccount as U, getXaiAccounts as V, selectXaiAccount as W, loginCodex as X, loginXai as Y, CODEX_API_BASE_URL as Z, isAsyncIterable as _, removeCodexAccount as a, createResponsesHttpEventStream as at, parseUserIdMetadata as b, setupCopilotToken as c, getResponsesStreamTerminalDisposition as ct, generateRequestIdFromPayload as d, FULL_MODEL_CATALOG_HEADER as dt, generateTraceId as et, getPromptCacheKey as f, stripInternalRequestHeaders as ft, getUUID as g, getSessionAffinityFromHeaders as h, persistCodexCredentials as i, fetchUpstreamWithLifecycle as it, compactAutoContinuePromptStarts as j, prepareMessageProxyHeaders as k, setupGitHubToken as l, createPooledWebSocketStream as lt, getRootSessionIdFromHeaders as m, invalidateCodexRuntime as n, resolveTraceId as nt, selectCodexAccount as o, createResponsesSafeStream as ot, getRootSessionId as p, readGitHubTokenFromEnv as q, logUser as r, setPluginRequestActualModel as rt, setupCodexToken as s, encodePoolKeyPart as st, getCodexAccounts as t, requestContext as tt, stopCopilotRefreshLoop as u, createWebSocketUrl as ut, isNullish as v, copilotModelsHeaders as w, getCopilotUsage as x, isResponsesStream as y, getMissingApiKeysMessage as z };
2761
2765
 
2762
- //# sourceMappingURL=token-BL6FigKp.js.map
2766
+ //# sourceMappingURL=token-XNKmjmqH.js.map