@gitlab/gitlab-ai-provider 3.3.0 → 3.4.0

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/dist/index.mjs CHANGED
@@ -181,11 +181,15 @@ var GitLabAnthropicLanguageModel = class {
181
181
  async getAnthropicClient(forceRefresh = false) {
182
182
  const tokenData = await this.directAccessClient.getDirectAccessToken(forceRefresh);
183
183
  const { "x-api-key": _removed, ...filteredHeaders } = tokenData.headers;
184
+ const mergedHeaders = {
185
+ ...filteredHeaders,
186
+ ...this.config.aiGatewayHeaders
187
+ };
184
188
  this.anthropicClient = new Anthropic({
185
189
  apiKey: null,
186
190
  authToken: tokenData.token,
187
191
  baseURL: this.directAccessClient.getAnthropicProxyUrl(),
188
- defaultHeaders: filteredHeaders
192
+ defaultHeaders: mergedHeaders
189
193
  });
190
194
  return this.anthropicClient;
191
195
  }
@@ -686,10 +690,14 @@ var GitLabOpenAILanguageModel = class {
686
690
  async getOpenAIClient(forceRefresh = false) {
687
691
  const tokenData = await this.directAccessClient.getDirectAccessToken(forceRefresh);
688
692
  const { "x-api-key": _removed, ...filteredHeaders } = tokenData.headers;
693
+ const mergedHeaders = {
694
+ ...filteredHeaders,
695
+ ...this.config.aiGatewayHeaders
696
+ };
689
697
  this.openaiClient = new OpenAI({
690
698
  apiKey: tokenData.token,
691
699
  baseURL: this.directAccessClient.getOpenAIProxyUrl(),
692
- defaultHeaders: filteredHeaders
700
+ defaultHeaders: mergedHeaders
693
701
  });
694
702
  return this.openaiClient;
695
703
  }
@@ -1502,11 +1510,13 @@ var GitLabOAuthManager = class {
1502
1510
  }
1503
1511
  };
1504
1512
 
1513
+ // src/version.ts
1514
+ var VERSION = true ? "3.3.1" : "0.0.0-dev";
1515
+
1505
1516
  // src/gitlab-provider.ts
1506
1517
  import * as fs from "fs";
1507
1518
  import * as path from "path";
1508
1519
  import * as os from "os";
1509
- var VERSION = "0.0.1";
1510
1520
  function getOpenCodeAuthPath() {
1511
1521
  const homeDir = os.homedir();
1512
1522
  const xdgDataHome = process.env.XDG_DATA_HOME;
@@ -1656,6 +1666,14 @@ function createGitLab(options = {}) {
1656
1666
  ...options.featureFlags,
1657
1667
  ...agenticOptions?.featureFlags
1658
1668
  };
1669
+ const defaultAiGatewayHeaders = {
1670
+ "User-Agent": `gitlab-ai-provider/${VERSION}`
1671
+ };
1672
+ const aiGatewayHeaders = {
1673
+ ...defaultAiGatewayHeaders,
1674
+ ...options.aiGatewayHeaders,
1675
+ ...agenticOptions?.aiGatewayHeaders
1676
+ };
1659
1677
  const baseConfig = {
1660
1678
  provider: `${providerName}.agentic`,
1661
1679
  instanceUrl,
@@ -1664,7 +1682,8 @@ function createGitLab(options = {}) {
1664
1682
  fetch: options.fetch,
1665
1683
  maxTokens: agenticOptions?.maxTokens,
1666
1684
  featureFlags,
1667
- aiGatewayUrl: options.aiGatewayUrl
1685
+ aiGatewayUrl: options.aiGatewayUrl,
1686
+ aiGatewayHeaders
1668
1687
  };
1669
1688
  if (mapping.provider === "openai") {
1670
1689
  return new GitLabOpenAILanguageModel(modelId, {
@@ -1984,6 +2003,7 @@ export {
1984
2003
  MODEL_MAPPINGS,
1985
2004
  OAUTH_SCOPES,
1986
2005
  TOKEN_EXPIRY_SKEW_MS,
2006
+ VERSION,
1987
2007
  createGitLab,
1988
2008
  getAnthropicModelForModelId,
1989
2009
  getModelMapping,