opencode-gitlab-plugin 3.2.0 → 3.2.1
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/CHANGELOG.md +7 -0
- package/dist/index.js +64 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +43 -12
- package/dist/mcp-server.cjs.map +1 -1
- package/package.json +1 -1
package/dist/mcp-server.cjs
CHANGED
|
@@ -31583,36 +31583,67 @@ applyMixins(UnifiedGitLabClient, [
|
|
|
31583
31583
|
]);
|
|
31584
31584
|
|
|
31585
31585
|
// src/utils.ts
|
|
31586
|
+
var integrationToken;
|
|
31587
|
+
function credentialToToken(value) {
|
|
31588
|
+
if (!value || typeof value !== "object") {
|
|
31589
|
+
return void 0;
|
|
31590
|
+
}
|
|
31591
|
+
const credential = value;
|
|
31592
|
+
if (credential["type"] === "oauth") {
|
|
31593
|
+
const access = credential["access"];
|
|
31594
|
+
if (typeof access !== "string" || !access) {
|
|
31595
|
+
return void 0;
|
|
31596
|
+
}
|
|
31597
|
+
return isExpired(credential["expires"]) ? void 0 : access;
|
|
31598
|
+
}
|
|
31599
|
+
if (typeof credential["key"] === "string" && credential["key"]) {
|
|
31600
|
+
return credential["key"];
|
|
31601
|
+
}
|
|
31602
|
+
if (typeof credential["token"] === "string" && credential["token"]) {
|
|
31603
|
+
return credential["token"];
|
|
31604
|
+
}
|
|
31605
|
+
return void 0;
|
|
31606
|
+
}
|
|
31607
|
+
function isExpired(expires) {
|
|
31608
|
+
return typeof expires === "number" && expires > 0 && expires <= Date.now();
|
|
31609
|
+
}
|
|
31586
31610
|
function readTokenFromAuthStorage() {
|
|
31587
31611
|
try {
|
|
31588
31612
|
const authPath = import_path.default.join(import_os.default.homedir(), ".local", "share", "opencode", "auth.json");
|
|
31589
31613
|
if (!import_fs.default.existsSync(authPath)) {
|
|
31590
|
-
return
|
|
31614
|
+
return {};
|
|
31591
31615
|
}
|
|
31592
31616
|
const authData = JSON.parse(import_fs.default.readFileSync(authPath, "utf-8"));
|
|
31593
31617
|
const gitlabAuth = authData?.gitlab;
|
|
31594
31618
|
if (!gitlabAuth) {
|
|
31595
|
-
return
|
|
31619
|
+
return {};
|
|
31596
31620
|
}
|
|
31597
|
-
|
|
31598
|
-
|
|
31621
|
+
const token = credentialToToken(gitlabAuth);
|
|
31622
|
+
if (token) {
|
|
31623
|
+
return { token };
|
|
31599
31624
|
}
|
|
31600
|
-
if (gitlabAuth.type === "
|
|
31601
|
-
return gitlabAuth.
|
|
31625
|
+
if (gitlabAuth.type === "oauth" && isExpired(gitlabAuth.expires)) {
|
|
31626
|
+
return { expired: new Date(gitlabAuth.expires) };
|
|
31602
31627
|
}
|
|
31603
|
-
return
|
|
31628
|
+
return {};
|
|
31604
31629
|
} catch (error45) {
|
|
31605
|
-
return
|
|
31630
|
+
return {};
|
|
31606
31631
|
}
|
|
31607
31632
|
}
|
|
31608
31633
|
function getGitLabClient() {
|
|
31609
|
-
let token = process.env["GITLAB_TOKEN"];
|
|
31634
|
+
let token = process.env["GITLAB_TOKEN"] || integrationToken;
|
|
31635
|
+
let expired;
|
|
31610
31636
|
if (!token) {
|
|
31611
|
-
token = readTokenFromAuthStorage();
|
|
31637
|
+
({ token, expired } = readTokenFromAuthStorage());
|
|
31612
31638
|
}
|
|
31613
31639
|
if (!token) {
|
|
31640
|
+
if (expired) {
|
|
31641
|
+
throw new Error(
|
|
31642
|
+
`GitLab OAuth token in ~/.local/share/opencode/auth.json expired on ${expired.toISOString()}. Re-authenticate GitLab in OpenCode or set the GITLAB_TOKEN environment variable.`
|
|
31643
|
+
);
|
|
31644
|
+
}
|
|
31614
31645
|
throw new Error(
|
|
31615
|
-
"GitLab API token not found. Set GITLAB_TOKEN environment variable or
|
|
31646
|
+
"GitLab API token not found. Set GITLAB_TOKEN environment variable or connect GitLab in OpenCode."
|
|
31616
31647
|
);
|
|
31617
31648
|
}
|
|
31618
31649
|
const instanceUrl = process.env["GITLAB_INSTANCE_URL"] || "https://gitlab.com";
|
|
@@ -34797,7 +34828,7 @@ async function main() {
|
|
|
34797
34828
|
`);
|
|
34798
34829
|
process.exit(1);
|
|
34799
34830
|
}
|
|
34800
|
-
const version2 = true ? "3.2.
|
|
34831
|
+
const version2 = true ? "3.2.1" : "0.0.0";
|
|
34801
34832
|
const server = new McpServer({ name: "gitlab", version: version2 });
|
|
34802
34833
|
adaptToolsToMcp(server, mcpTools);
|
|
34803
34834
|
const transport = new StdioServerTransport();
|