@loopstack/github-module 0.1.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/README.md +67 -0
- package/dist/github-oauth.provider.d.ts +19 -0
- package/dist/github-oauth.provider.d.ts.map +1 -0
- package/dist/github-oauth.provider.js +91 -0
- package/dist/github-oauth.provider.js.map +1 -0
- package/dist/github.module.d.ts +3 -0
- package/dist/github.module.d.ts.map +1 -0
- package/dist/github.module.js +75 -0
- package/dist/github.module.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/actions/github-get-workflow-run.tool.d.ts +13 -0
- package/dist/tools/actions/github-get-workflow-run.tool.d.ts.map +1 -0
- package/dist/tools/actions/github-get-workflow-run.tool.js +106 -0
- package/dist/tools/actions/github-get-workflow-run.tool.js.map +1 -0
- package/dist/tools/actions/github-list-workflow-runs.tool.d.ts +16 -0
- package/dist/tools/actions/github-list-workflow-runs.tool.d.ts.map +1 -0
- package/dist/tools/actions/github-list-workflow-runs.tool.js +129 -0
- package/dist/tools/actions/github-list-workflow-runs.tool.js.map +1 -0
- package/dist/tools/actions/github-trigger-workflow.tool.d.ts +15 -0
- package/dist/tools/actions/github-trigger-workflow.tool.d.ts.map +1 -0
- package/dist/tools/actions/github-trigger-workflow.tool.js +101 -0
- package/dist/tools/actions/github-trigger-workflow.tool.js.map +1 -0
- package/dist/tools/content/github-create-or-update-file.tool.d.ts +17 -0
- package/dist/tools/content/github-create-or-update-file.tool.d.ts.map +1 -0
- package/dist/tools/content/github-create-or-update-file.tool.js +115 -0
- package/dist/tools/content/github-create-or-update-file.tool.js.map +1 -0
- package/dist/tools/content/github-get-commit.tool.d.ts +13 -0
- package/dist/tools/content/github-get-commit.tool.d.ts.map +1 -0
- package/dist/tools/content/github-get-commit.tool.js +113 -0
- package/dist/tools/content/github-get-commit.tool.js.map +1 -0
- package/dist/tools/content/github-get-file-content.tool.d.ts +14 -0
- package/dist/tools/content/github-get-file-content.tool.d.ts.map +1 -0
- package/dist/tools/content/github-get-file-content.tool.js +107 -0
- package/dist/tools/content/github-get-file-content.tool.js.map +1 -0
- package/dist/tools/content/github-list-directory.tool.d.ts +14 -0
- package/dist/tools/content/github-list-directory.tool.d.ts.map +1 -0
- package/dist/tools/content/github-list-directory.tool.js +102 -0
- package/dist/tools/content/github-list-directory.tool.js.map +1 -0
- package/dist/tools/issues/github-create-issue-comment.tool.d.ts +14 -0
- package/dist/tools/issues/github-create-issue-comment.tool.d.ts.map +1 -0
- package/dist/tools/issues/github-create-issue-comment.tool.js +100 -0
- package/dist/tools/issues/github-create-issue-comment.tool.js.map +1 -0
- package/dist/tools/issues/github-create-issue.tool.d.ts +16 -0
- package/dist/tools/issues/github-create-issue.tool.d.ts.map +1 -0
- package/dist/tools/issues/github-create-issue.tool.js +112 -0
- package/dist/tools/issues/github-create-issue.tool.js.map +1 -0
- package/dist/tools/issues/github-get-issue.tool.d.ts +13 -0
- package/dist/tools/issues/github-get-issue.tool.d.ts.map +1 -0
- package/dist/tools/issues/github-get-issue.tool.js +106 -0
- package/dist/tools/issues/github-get-issue.tool.js.map +1 -0
- package/dist/tools/issues/github-list-issues.tool.d.ts +17 -0
- package/dist/tools/issues/github-list-issues.tool.d.ts.map +1 -0
- package/dist/tools/issues/github-list-issues.tool.js +115 -0
- package/dist/tools/issues/github-list-issues.tool.js.map +1 -0
- package/dist/tools/pull-requests/github-create-pull-request.tool.d.ts +17 -0
- package/dist/tools/pull-requests/github-create-pull-request.tool.d.ts.map +1 -0
- package/dist/tools/pull-requests/github-create-pull-request.tool.js +113 -0
- package/dist/tools/pull-requests/github-create-pull-request.tool.js.map +1 -0
- package/dist/tools/pull-requests/github-get-pull-request.tool.d.ts +13 -0
- package/dist/tools/pull-requests/github-get-pull-request.tool.d.ts.map +1 -0
- package/dist/tools/pull-requests/github-get-pull-request.tool.js +113 -0
- package/dist/tools/pull-requests/github-get-pull-request.tool.js.map +1 -0
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.d.ts +13 -0
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.d.ts.map +1 -0
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.js +97 -0
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.js.map +1 -0
- package/dist/tools/pull-requests/github-list-pull-requests.tool.d.ts +16 -0
- package/dist/tools/pull-requests/github-list-pull-requests.tool.d.ts.map +1 -0
- package/dist/tools/pull-requests/github-list-pull-requests.tool.js +113 -0
- package/dist/tools/pull-requests/github-list-pull-requests.tool.js.map +1 -0
- package/dist/tools/pull-requests/github-merge-pull-request.tool.d.ts +16 -0
- package/dist/tools/pull-requests/github-merge-pull-request.tool.d.ts.map +1 -0
- package/dist/tools/pull-requests/github-merge-pull-request.tool.js +108 -0
- package/dist/tools/pull-requests/github-merge-pull-request.tool.js.map +1 -0
- package/dist/tools/repos/github-create-repo.tool.d.ts +14 -0
- package/dist/tools/repos/github-create-repo.tool.d.ts.map +1 -0
- package/dist/tools/repos/github-create-repo.tool.js +108 -0
- package/dist/tools/repos/github-create-repo.tool.js.map +1 -0
- package/dist/tools/repos/github-get-repo.tool.d.ts +12 -0
- package/dist/tools/repos/github-get-repo.tool.d.ts.map +1 -0
- package/dist/tools/repos/github-get-repo.tool.js +107 -0
- package/dist/tools/repos/github-get-repo.tool.js.map +1 -0
- package/dist/tools/repos/github-list-branches.tool.d.ts +13 -0
- package/dist/tools/repos/github-list-branches.tool.d.ts.map +1 -0
- package/dist/tools/repos/github-list-branches.tool.js +97 -0
- package/dist/tools/repos/github-list-branches.tool.js.map +1 -0
- package/dist/tools/repos/github-list-repos.tool.d.ts +14 -0
- package/dist/tools/repos/github-list-repos.tool.d.ts.map +1 -0
- package/dist/tools/repos/github-list-repos.tool.js +107 -0
- package/dist/tools/repos/github-list-repos.tool.js.map +1 -0
- package/dist/tools/search/github-search-code.tool.d.ts +13 -0
- package/dist/tools/search/github-search-code.tool.d.ts.map +1 -0
- package/dist/tools/search/github-search-code.tool.js +100 -0
- package/dist/tools/search/github-search-code.tool.js.map +1 -0
- package/dist/tools/search/github-search-issues.tool.d.ts +14 -0
- package/dist/tools/search/github-search-issues.tool.d.ts.map +1 -0
- package/dist/tools/search/github-search-issues.tool.js +109 -0
- package/dist/tools/search/github-search-issues.tool.js.map +1 -0
- package/dist/tools/search/github-search-repos.tool.d.ts +14 -0
- package/dist/tools/search/github-search-repos.tool.d.ts.map +1 -0
- package/dist/tools/search/github-search-repos.tool.js +106 -0
- package/dist/tools/search/github-search-repos.tool.js.map +1 -0
- package/dist/tools/users/github-get-authenticated-user.tool.d.ts +9 -0
- package/dist/tools/users/github-get-authenticated-user.tool.d.ts.map +1 -0
- package/dist/tools/users/github-get-authenticated-user.tool.js +96 -0
- package/dist/tools/users/github-get-authenticated-user.tool.js.map +1 -0
- package/dist/tools/users/github-list-user-orgs.tool.d.ts +11 -0
- package/dist/tools/users/github-list-user-orgs.tool.d.ts.map +1 -0
- package/dist/tools/users/github-list-user-orgs.tool.js +95 -0
- package/dist/tools/users/github-list-user-orgs.tool.js.map +1 -0
- package/package.json +81 -0
- package/src/github-oauth.provider.ts +85 -0
- package/src/github.module.ts +63 -0
- package/src/index.ts +27 -0
- package/src/tools/actions/github-get-workflow-run.tool.ts +115 -0
- package/src/tools/actions/github-list-workflow-runs.tool.ts +141 -0
- package/src/tools/actions/github-trigger-workflow.tool.ts +97 -0
- package/src/tools/content/github-create-or-update-file.tool.ts +124 -0
- package/src/tools/content/github-get-commit.tool.ts +124 -0
- package/src/tools/content/github-get-file-content.tool.ts +112 -0
- package/src/tools/content/github-list-directory.tool.ts +105 -0
- package/src/tools/issues/github-create-issue-comment.tool.ts +100 -0
- package/src/tools/issues/github-create-issue.tool.ts +114 -0
- package/src/tools/issues/github-get-issue.tool.ts +115 -0
- package/src/tools/issues/github-list-issues.tool.ts +126 -0
- package/src/tools/pull-requests/github-create-pull-request.tool.ts +119 -0
- package/src/tools/pull-requests/github-get-pull-request.tool.ts +128 -0
- package/src/tools/pull-requests/github-list-pr-reviews.tool.ts +99 -0
- package/src/tools/pull-requests/github-list-pull-requests.tool.ts +124 -0
- package/src/tools/pull-requests/github-merge-pull-request.tool.ts +108 -0
- package/src/tools/repos/github-create-repo.tool.ts +111 -0
- package/src/tools/repos/github-get-repo.tool.ts +120 -0
- package/src/tools/repos/github-list-branches.tool.ts +97 -0
- package/src/tools/repos/github-list-repos.tool.ts +115 -0
- package/src/tools/search/github-search-code.tool.ts +105 -0
- package/src/tools/search/github-search-issues.tool.ts +120 -0
- package/src/tools/search/github-search-repos.tool.ts +115 -0
- package/src/tools/users/github-get-authenticated-user.tool.ts +98 -0
- package/src/tools/users/github-list-user-orgs.tool.ts +94 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubCreatePullRequestArgs = {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
title: string;
|
|
6
|
+
head: string;
|
|
7
|
+
base: string;
|
|
8
|
+
body?: string;
|
|
9
|
+
draft?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare class GitHubCreatePullRequestTool implements ToolInterface {
|
|
12
|
+
private readonly logger;
|
|
13
|
+
private tokenStore;
|
|
14
|
+
args: GitHubCreatePullRequestArgs;
|
|
15
|
+
execute(args: GitHubCreatePullRequestArgs, ctx: RunContext): Promise<ToolResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=github-create-pull-request.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-create-pull-request.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-create-pull-request.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,qBAMa,2BAA4B,YAAW,aAAa;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgD;IAGvE,OAAO,CAAC,UAAU,CAAkB;IAepC,IAAI,EAAE,2BAA2B,CAAC;IAE5B,OAAO,CAAC,IAAI,EAAE,2BAA2B,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CA4EvF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GitHubCreatePullRequestTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubCreatePullRequestTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
let GitHubCreatePullRequestTool = GitHubCreatePullRequestTool_1 = class GitHubCreatePullRequestTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubCreatePullRequestTool_1.name);
|
|
20
|
+
tokenStore;
|
|
21
|
+
args;
|
|
22
|
+
async execute(args, ctx) {
|
|
23
|
+
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
24
|
+
if (!accessToken) {
|
|
25
|
+
return {
|
|
26
|
+
data: {
|
|
27
|
+
error: 'unauthorized',
|
|
28
|
+
message: 'No valid GitHub token found. Please authenticate first.',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const requestBody = {
|
|
33
|
+
title: args.title,
|
|
34
|
+
head: args.head,
|
|
35
|
+
base: args.base,
|
|
36
|
+
draft: args.draft ?? false,
|
|
37
|
+
};
|
|
38
|
+
if (args.body)
|
|
39
|
+
requestBody.body = args.body;
|
|
40
|
+
const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls`;
|
|
41
|
+
const response = await fetch(url, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: `Bearer ${accessToken}`,
|
|
45
|
+
Accept: 'application/vnd.github+json',
|
|
46
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify(requestBody),
|
|
50
|
+
});
|
|
51
|
+
if (response.status === 401 || response.status === 403) {
|
|
52
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
53
|
+
return {
|
|
54
|
+
data: {
|
|
55
|
+
error: '401',
|
|
56
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
const errorBody = await response.text();
|
|
62
|
+
this.logger.error(`GitHub API error: ${response.status} ${errorBody}`);
|
|
63
|
+
return {
|
|
64
|
+
data: {
|
|
65
|
+
error: 'api_error',
|
|
66
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const pr = (await response.json());
|
|
71
|
+
return {
|
|
72
|
+
data: {
|
|
73
|
+
pullRequest: {
|
|
74
|
+
id: pr.id,
|
|
75
|
+
number: pr.number,
|
|
76
|
+
title: pr.title,
|
|
77
|
+
htmlUrl: pr.html_url,
|
|
78
|
+
state: pr.state,
|
|
79
|
+
draft: pr.draft,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.GitHubCreatePullRequestTool = GitHubCreatePullRequestTool;
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, common_1.Inject)(),
|
|
88
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
89
|
+
], GitHubCreatePullRequestTool.prototype, "tokenStore", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, common_2.Input)({
|
|
92
|
+
schema: zod_1.z
|
|
93
|
+
.object({
|
|
94
|
+
owner: zod_1.z.string(),
|
|
95
|
+
repo: zod_1.z.string(),
|
|
96
|
+
title: zod_1.z.string(),
|
|
97
|
+
head: zod_1.z.string(),
|
|
98
|
+
base: zod_1.z.string(),
|
|
99
|
+
body: zod_1.z.string().optional(),
|
|
100
|
+
draft: zod_1.z.boolean().default(false),
|
|
101
|
+
})
|
|
102
|
+
.strict(),
|
|
103
|
+
}),
|
|
104
|
+
__metadata("design:type", Object)
|
|
105
|
+
], GitHubCreatePullRequestTool.prototype, "args", void 0);
|
|
106
|
+
exports.GitHubCreatePullRequestTool = GitHubCreatePullRequestTool = GitHubCreatePullRequestTool_1 = __decorate([
|
|
107
|
+
(0, common_2.Tool)({
|
|
108
|
+
config: {
|
|
109
|
+
description: 'Creates a new pull request in a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
], GitHubCreatePullRequestTool);
|
|
113
|
+
//# sourceMappingURL=github-create-pull-request.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-create-pull-request.tool.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-create-pull-request.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0DAA0D;AAkBnD,IAAM,2BAA2B,mCAAjC,MAAM,2BAA2B;IACrB,MAAM,GAAG,IAAI,eAAM,CAAC,6BAA2B,CAAC,IAAI,CAAC,CAAC;IAG/D,UAAU,CAAkB;IAepC,IAAI,CAA8B;IAElC,KAAK,CAAC,OAAO,CAAC,IAAiC,EAAE,GAAe;QAC9D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEpF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,cAAc;oBACrB,OAAO,EAAE,yDAAyD;iBACnE;aACF,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAA4B;YAC3C,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK;SAC3B,CAAC;QAEF,IAAI,IAAI,CAAC,IAAI;YAAE,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAE5C,MAAM,GAAG,GAAG,gCAAgC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAA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ACpB,KAAK,EAAE,EAAE,CAAC,KAAK;oBACf,KAAK,EAAE,EAAE,CAAC,KAAK;iBAChB;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjGY,kEAA2B;AAI9B;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;+DAAC;AAepC;IAbC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,OAAC;aACN,MAAM,CAAC;YACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC3B,KAAK,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;SAClC,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;;yDACgC;sCAnBvB,2BAA2B;IANvC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,sHAAsH;SACzH;KACF,CAAC;GACW,2BAA2B,CAiGvC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubGetPullRequestArgs = {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
pullNumber: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class GitHubGetPullRequestTool implements ToolInterface {
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private tokenStore;
|
|
10
|
+
args: GitHubGetPullRequestArgs;
|
|
11
|
+
execute(args: GitHubGetPullRequestArgs, ctx: RunContext): Promise<ToolResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=github-get-pull-request.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-get-pull-request.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-get-pull-request.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAMa,wBAAyB,YAAW,aAAa;IAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;IAGpE,OAAO,CAAC,UAAU,CAAkB;IAWpC,IAAI,EAAE,wBAAwB,CAAC;IAEzB,OAAO,CAAC,IAAI,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CA6FpF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GitHubGetPullRequestTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubGetPullRequestTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
let GitHubGetPullRequestTool = GitHubGetPullRequestTool_1 = class GitHubGetPullRequestTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubGetPullRequestTool_1.name);
|
|
20
|
+
tokenStore;
|
|
21
|
+
args;
|
|
22
|
+
async execute(args, ctx) {
|
|
23
|
+
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
24
|
+
if (!accessToken) {
|
|
25
|
+
return {
|
|
26
|
+
data: {
|
|
27
|
+
error: 'unauthorized',
|
|
28
|
+
message: 'No valid GitHub token found. Please authenticate first.',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/${args.pullNumber}`;
|
|
33
|
+
const response = await fetch(url, {
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${accessToken}`,
|
|
36
|
+
Accept: 'application/vnd.github+json',
|
|
37
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (response.status === 401 || response.status === 403) {
|
|
41
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
42
|
+
return {
|
|
43
|
+
data: {
|
|
44
|
+
error: '401',
|
|
45
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
const body = await response.text();
|
|
51
|
+
this.logger.error(`GitHub API error: ${response.status} ${body}`);
|
|
52
|
+
return {
|
|
53
|
+
data: {
|
|
54
|
+
error: 'api_error',
|
|
55
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const pr = (await response.json());
|
|
60
|
+
return {
|
|
61
|
+
data: {
|
|
62
|
+
pullRequest: {
|
|
63
|
+
id: pr.id,
|
|
64
|
+
number: pr.number,
|
|
65
|
+
title: pr.title,
|
|
66
|
+
body: pr.body,
|
|
67
|
+
state: pr.state,
|
|
68
|
+
user: pr.user.login,
|
|
69
|
+
head: pr.head.ref,
|
|
70
|
+
headSha: pr.head.sha,
|
|
71
|
+
base: pr.base.ref,
|
|
72
|
+
merged: pr.merged,
|
|
73
|
+
mergeable: pr.mergeable,
|
|
74
|
+
draft: pr.draft,
|
|
75
|
+
additions: pr.additions,
|
|
76
|
+
deletions: pr.deletions,
|
|
77
|
+
changedFiles: pr.changed_files,
|
|
78
|
+
createdAt: pr.created_at,
|
|
79
|
+
updatedAt: pr.updated_at,
|
|
80
|
+
mergedAt: pr.merged_at,
|
|
81
|
+
htmlUrl: pr.html_url,
|
|
82
|
+
comments: pr.comments,
|
|
83
|
+
reviewComments: pr.review_comments,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
exports.GitHubGetPullRequestTool = GitHubGetPullRequestTool;
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, common_1.Inject)(),
|
|
92
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
93
|
+
], GitHubGetPullRequestTool.prototype, "tokenStore", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, common_2.Input)({
|
|
96
|
+
schema: zod_1.z
|
|
97
|
+
.object({
|
|
98
|
+
owner: zod_1.z.string(),
|
|
99
|
+
repo: zod_1.z.string(),
|
|
100
|
+
pullNumber: zod_1.z.number(),
|
|
101
|
+
})
|
|
102
|
+
.strict(),
|
|
103
|
+
}),
|
|
104
|
+
__metadata("design:type", Object)
|
|
105
|
+
], GitHubGetPullRequestTool.prototype, "args", void 0);
|
|
106
|
+
exports.GitHubGetPullRequestTool = GitHubGetPullRequestTool = GitHubGetPullRequestTool_1 = __decorate([
|
|
107
|
+
(0, common_2.Tool)({
|
|
108
|
+
config: {
|
|
109
|
+
description: 'Gets detailed information about a specific GitHub pull request. Returns { error: "unauthorized" } if no valid token is available.',
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
], GitHubGetPullRequestTool);
|
|
113
|
+
//# sourceMappingURL=github-get-pull-request.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-get-pull-request.tool.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-get-pull-request.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0DAA0D;AAcnD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAClB,MAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAG5D,UAAU,CAAkB;IAWpC,IAAI,CAA2B;IAE/B,KAAK,CAAC,OAAO,CAAC,IAA8B,EAAE,GAAe;QAC3D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEpF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,cAAc;oBACrB,OAAO,EAAE,yDAAyD;iBACnE;aACF,CAAC;QACJ,CAAC;QAED,MAAM,GAAG,GAAG,gCAAgC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;QACvI,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;gBACtC,MAAM,EAAE,6BAA6B;gBACrC,sBAA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AAC,MAAM;oBACjB,SAAS,EAAE,EAAE,CAAC,SAAS;oBACvB,KAAK,EAAE,EAAE,CAAC,KAAK;oBACf,SAAS,EAAE,EAAE,CAAC,SAAS;oBACvB,SAAS,EAAE,EAAE,CAAC,SAAS;oBACvB,YAAY,EAAE,EAAE,CAAC,aAAa;oBAC9B,SAAS,EAAE,EAAE,CAAC,UAAU;oBACxB,SAAS,EAAE,EAAE,CAAC,UAAU;oBACxB,QAAQ,EAAE,EAAE,CAAC,SAAS;oBACtB,OAAO,EAAE,EAAE,CAAC,QAAQ;oBACpB,QAAQ,EAAE,EAAE,CAAC,QAAQ;oBACrB,cAAc,EAAE,EAAE,CAAC,eAAe;iBACnC;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA9GY,4DAAwB;AAI3B;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;4DAAC;AAWpC;IATC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,OAAC;aACN,MAAM,CAAC;YACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;SACvB,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;;sDAC6B;mCAfpB,wBAAwB;IANpC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,mIAAmI;SACtI;KACF,CAAC;GACW,wBAAwB,CA8GpC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubListPrReviewsArgs = {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
pullNumber: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class GitHubListPrReviewsTool implements ToolInterface {
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private tokenStore;
|
|
10
|
+
args: GitHubListPrReviewsArgs;
|
|
11
|
+
execute(args: GitHubListPrReviewsArgs, ctx: RunContext): Promise<ToolResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=github-list-pr-reviews.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-pr-reviews.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-list-pr-reviews.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAMa,uBAAwB,YAAW,aAAa;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;IAGnE,OAAO,CAAC,UAAU,CAAkB;IAWpC,IAAI,EAAE,uBAAuB,CAAC;IAExB,OAAO,CAAC,IAAI,EAAE,uBAAuB,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAgEnF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GitHubListPrReviewsTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubListPrReviewsTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
let GitHubListPrReviewsTool = GitHubListPrReviewsTool_1 = class GitHubListPrReviewsTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubListPrReviewsTool_1.name);
|
|
20
|
+
tokenStore;
|
|
21
|
+
args;
|
|
22
|
+
async execute(args, ctx) {
|
|
23
|
+
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
24
|
+
if (!accessToken) {
|
|
25
|
+
return {
|
|
26
|
+
data: {
|
|
27
|
+
error: 'unauthorized',
|
|
28
|
+
message: 'No valid GitHub token found. Please authenticate first.',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/${args.pullNumber}/reviews`;
|
|
33
|
+
const response = await fetch(url, {
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${accessToken}`,
|
|
36
|
+
Accept: 'application/vnd.github+json',
|
|
37
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (response.status === 401 || response.status === 403) {
|
|
41
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
42
|
+
return {
|
|
43
|
+
data: {
|
|
44
|
+
error: '401',
|
|
45
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
const body = await response.text();
|
|
51
|
+
this.logger.error(`GitHub API error: ${response.status} ${body}`);
|
|
52
|
+
return {
|
|
53
|
+
data: {
|
|
54
|
+
error: 'api_error',
|
|
55
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const data = (await response.json());
|
|
60
|
+
const reviews = data.map((review) => ({
|
|
61
|
+
id: review.id,
|
|
62
|
+
user: review.user.login,
|
|
63
|
+
body: review.body,
|
|
64
|
+
state: review.state,
|
|
65
|
+
submittedAt: review.submitted_at,
|
|
66
|
+
htmlUrl: review.html_url,
|
|
67
|
+
}));
|
|
68
|
+
return {
|
|
69
|
+
data: { reviews },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.GitHubListPrReviewsTool = GitHubListPrReviewsTool;
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, common_1.Inject)(),
|
|
76
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
77
|
+
], GitHubListPrReviewsTool.prototype, "tokenStore", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, common_2.Input)({
|
|
80
|
+
schema: zod_1.z
|
|
81
|
+
.object({
|
|
82
|
+
owner: zod_1.z.string(),
|
|
83
|
+
repo: zod_1.z.string(),
|
|
84
|
+
pullNumber: zod_1.z.number(),
|
|
85
|
+
})
|
|
86
|
+
.strict(),
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], GitHubListPrReviewsTool.prototype, "args", void 0);
|
|
90
|
+
exports.GitHubListPrReviewsTool = GitHubListPrReviewsTool = GitHubListPrReviewsTool_1 = __decorate([
|
|
91
|
+
(0, common_2.Tool)({
|
|
92
|
+
config: {
|
|
93
|
+
description: 'Lists reviews on a GitHub pull request. Returns { error: "unauthorized" } if no valid token is available.',
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
], GitHubListPrReviewsTool);
|
|
97
|
+
//# sourceMappingURL=github-list-pr-reviews.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-pr-reviews.tool.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-list-pr-reviews.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0DAA0D;AAcnD,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IACjB,MAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IAG3D,UAAU,CAAkB;IAWpC,IAAI,CAA0B;IAE9B,KAAK,CAAC,OAAO,CAAC,IAA6B,EAAE,GAAe;QAC1D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEpF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,cAAc;oBACrB,OAAO,EAAE,yDAAyD;iBACnE;aACF,CAAC;QACJ,CAAC;QAED,MAAM,GAAG,GAAG,gCAAgC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,UAAU,CAAC;QAC/I,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;gBACtC,MAAM,EAAE,6BAA6B;gBACrC,sBAAsB,EAAE,YAAY;aACrC;SACF,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,QAAQ,CAAC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACl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AM,EAAE;KACZ,CAAC;;qDAC4B;kCAfnB,uBAAuB;IANnC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,2GAA2G;SAC9G;KACF,CAAC;GACW,uBAAuB,CAiFnC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubListPullRequestsArgs = {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
state?: string;
|
|
6
|
+
base?: string;
|
|
7
|
+
perPage?: number;
|
|
8
|
+
page?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class GitHubListPullRequestsTool implements ToolInterface {
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private tokenStore;
|
|
13
|
+
args: GitHubListPullRequestsArgs;
|
|
14
|
+
execute(args: GitHubListPullRequestsArgs, ctx: RunContext): Promise<ToolResult>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=github-list-pull-requests.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-pull-requests.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-list-pull-requests.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAMa,0BAA2B,YAAW,aAAa;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;IAGtE,OAAO,CAAC,UAAU,CAAkB;IAcpC,IAAI,EAAE,0BAA0B,CAAC;IAE3B,OAAO,CAAC,IAAI,EAAE,0BAA0B,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAmFtF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GitHubListPullRequestsTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubListPullRequestsTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
let GitHubListPullRequestsTool = GitHubListPullRequestsTool_1 = class GitHubListPullRequestsTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubListPullRequestsTool_1.name);
|
|
20
|
+
tokenStore;
|
|
21
|
+
args;
|
|
22
|
+
async execute(args, ctx) {
|
|
23
|
+
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
24
|
+
if (!accessToken) {
|
|
25
|
+
return {
|
|
26
|
+
data: {
|
|
27
|
+
error: 'unauthorized',
|
|
28
|
+
message: 'No valid GitHub token found. Please authenticate first.',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const params = new URLSearchParams({
|
|
33
|
+
state: args.state ?? 'open',
|
|
34
|
+
per_page: String(args.perPage ?? 30),
|
|
35
|
+
page: String(args.page ?? 1),
|
|
36
|
+
});
|
|
37
|
+
if (args.base)
|
|
38
|
+
params.set('base', args.base);
|
|
39
|
+
const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls?${params.toString()}`;
|
|
40
|
+
const response = await fetch(url, {
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: `Bearer ${accessToken}`,
|
|
43
|
+
Accept: 'application/vnd.github+json',
|
|
44
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if (response.status === 401 || response.status === 403) {
|
|
48
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
49
|
+
return {
|
|
50
|
+
data: {
|
|
51
|
+
error: '401',
|
|
52
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
const body = await response.text();
|
|
58
|
+
this.logger.error(`GitHub API error: ${response.status} ${body}`);
|
|
59
|
+
return {
|
|
60
|
+
data: {
|
|
61
|
+
error: 'api_error',
|
|
62
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const data = (await response.json());
|
|
67
|
+
const pullRequests = data.map((pr) => ({
|
|
68
|
+
id: pr.id,
|
|
69
|
+
number: pr.number,
|
|
70
|
+
title: pr.title,
|
|
71
|
+
state: pr.state,
|
|
72
|
+
user: pr.user.login,
|
|
73
|
+
head: pr.head.ref,
|
|
74
|
+
headSha: pr.head.sha,
|
|
75
|
+
base: pr.base.ref,
|
|
76
|
+
createdAt: pr.created_at,
|
|
77
|
+
updatedAt: pr.updated_at,
|
|
78
|
+
htmlUrl: pr.html_url,
|
|
79
|
+
draft: pr.draft,
|
|
80
|
+
}));
|
|
81
|
+
return {
|
|
82
|
+
data: { pullRequests },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
exports.GitHubListPullRequestsTool = GitHubListPullRequestsTool;
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, common_1.Inject)(),
|
|
89
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
90
|
+
], GitHubListPullRequestsTool.prototype, "tokenStore", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, common_2.Input)({
|
|
93
|
+
schema: zod_1.z
|
|
94
|
+
.object({
|
|
95
|
+
owner: zod_1.z.string(),
|
|
96
|
+
repo: zod_1.z.string(),
|
|
97
|
+
state: zod_1.z.enum(['open', 'closed', 'all']).default('open'),
|
|
98
|
+
base: zod_1.z.string().optional(),
|
|
99
|
+
perPage: zod_1.z.number().default(30),
|
|
100
|
+
page: zod_1.z.number().default(1),
|
|
101
|
+
})
|
|
102
|
+
.strict(),
|
|
103
|
+
}),
|
|
104
|
+
__metadata("design:type", Object)
|
|
105
|
+
], GitHubListPullRequestsTool.prototype, "args", void 0);
|
|
106
|
+
exports.GitHubListPullRequestsTool = GitHubListPullRequestsTool = GitHubListPullRequestsTool_1 = __decorate([
|
|
107
|
+
(0, common_2.Tool)({
|
|
108
|
+
config: {
|
|
109
|
+
description: 'Lists pull requests for a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
], GitHubListPullRequestsTool);
|
|
113
|
+
//# sourceMappingURL=github-list-pull-requests.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-pull-requests.tool.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-list-pull-requests.tool.ts"],"names":[],"mappings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U;YACxB,OAAO,EAAE,EAAE,CAAC,QAAQ;YACpB,KAAK,EAAE,EAAE,CAAC,KAAK;SAChB,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,IAAI,EAAE,EAAE,YAAY,EAAE;SACvB,CAAC;IACJ,CAAC;CACF,CAAA;AAvGY,gEAA0B;AAI7B;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;8DAAC;AAcpC;IAZC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,OAAC;aACN,MAAM,CAAC;YACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,KAAK,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;YACxD,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC3B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;SAC5B,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;;wDAC+B;qCAlBtB,0BAA0B;IANtC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,gHAAgH;SACnH;KACF,CAAC;GACW,0BAA0B,CAuGtC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubMergePullRequestArgs = {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
pullNumber: number;
|
|
6
|
+
mergeMethod?: string;
|
|
7
|
+
commitTitle?: string;
|
|
8
|
+
commitMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class GitHubMergePullRequestTool implements ToolInterface {
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private tokenStore;
|
|
13
|
+
args: GitHubMergePullRequestArgs;
|
|
14
|
+
execute(args: GitHubMergePullRequestArgs, ctx: RunContext): Promise<ToolResult>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=github-merge-pull-request.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-merge-pull-request.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-merge-pull-request.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,qBAKa,0BAA2B,YAAW,aAAa;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;IAGtE,OAAO,CAAC,UAAU,CAAkB;IAcpC,IAAI,EAAE,0BAA0B,CAAC;IAE3B,OAAO,CAAC,IAAI,EAAE,0BAA0B,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAoEtF"}
|