gitlab-ai-provider 6.9.1 → 6.9.2

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
@@ -2417,7 +2417,7 @@ import { AsyncResource } from "async_hooks";
2417
2417
  import WebSocket from "isomorphic-ws";
2418
2418
 
2419
2419
  // src/version.ts
2420
- var VERSION = true ? "6.9.0" : "0.0.0-dev";
2420
+ var VERSION = true ? "6.9.1" : "0.0.0-dev";
2421
2421
 
2422
2422
  // src/gitlab-workflow-client.ts
2423
2423
  var WS_CONNECT_TIMEOUT_MS = 3e4;
@@ -4969,12 +4969,15 @@ async function loadOpenCodeAuth(instanceUrl) {
4969
4969
  }
4970
4970
  const authData = JSON.parse(fs3.readFileSync(authPath, "utf-8"));
4971
4971
  const normalizedUrl = instanceUrl.replace(/\/$/, "");
4972
- if (authData.gitlab?.type === "oauth") {
4973
- const gitlabAuth = authData.gitlab;
4974
- const normalizedEnterpriseUrl = typeof gitlabAuth.enterpriseUrl === "string" ? gitlabAuth.enterpriseUrl.replace(/\/$/, "") : gitlabAuth.enterpriseUrl;
4975
- if (normalizedEnterpriseUrl === normalizedUrl) {
4972
+ const gitlabAuth = authData.gitlab;
4973
+ if (gitlabAuth?.type === "oauth") {
4974
+ const normalizedEnterpriseUrl = typeof gitlabAuth.enterpriseUrl === "string" ? gitlabAuth.enterpriseUrl.replace(/\/$/, "") : void 0;
4975
+ const matchesInstance = normalizedEnterpriseUrl === normalizedUrl || normalizedEnterpriseUrl === void 0 && normalizedUrl === GITLAB_COM_URL;
4976
+ if (matchesInstance) {
4976
4977
  return gitlabAuth;
4977
4978
  }
4979
+ } else if (gitlabAuth?.type === "api" && typeof gitlabAuth.key === "string") {
4980
+ return gitlabAuth;
4978
4981
  }
4979
4982
  const auth = authData[normalizedUrl] || authData[`${normalizedUrl}/`];
4980
4983
  return auth;
@@ -4987,6 +4990,9 @@ async function loadApiKey(options, instanceUrl, clientId) {
4987
4990
  return options.apiKey;
4988
4991
  }
4989
4992
  const auth = await loadOpenCodeAuth(instanceUrl);
4993
+ if (auth?.type === "api") {
4994
+ return auth.key;
4995
+ }
4990
4996
  if (auth?.type === "oauth") {
4991
4997
  const oauthManager = new GitLabOAuthManager();
4992
4998
  if (oauthManager.needsRefresh(auth.expires)) {