@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,108 @@
|
|
|
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 GitHubMergePullRequestTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubMergePullRequestTool = 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 GitHubMergePullRequestTool = GitHubMergePullRequestTool_1 = class GitHubMergePullRequestTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubMergePullRequestTool_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
|
+
merge_method: args.mergeMethod ?? 'merge',
|
|
34
|
+
};
|
|
35
|
+
if (args.commitTitle)
|
|
36
|
+
requestBody.commit_title = args.commitTitle;
|
|
37
|
+
if (args.commitMessage)
|
|
38
|
+
requestBody.commit_message = args.commitMessage;
|
|
39
|
+
const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/${args.pullNumber}/merge`;
|
|
40
|
+
const response = await fetch(url, {
|
|
41
|
+
method: 'PUT',
|
|
42
|
+
headers: {
|
|
43
|
+
Authorization: `Bearer ${accessToken}`,
|
|
44
|
+
Accept: 'application/vnd.github+json',
|
|
45
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
body: JSON.stringify(requestBody),
|
|
49
|
+
});
|
|
50
|
+
if (response.status === 401 || response.status === 403) {
|
|
51
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
52
|
+
return {
|
|
53
|
+
data: {
|
|
54
|
+
error: '401',
|
|
55
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const errorBody = await response.text();
|
|
61
|
+
this.logger.error(`GitHub API error: ${response.status} ${errorBody}`);
|
|
62
|
+
return {
|
|
63
|
+
data: {
|
|
64
|
+
error: 'api_error',
|
|
65
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const result = (await response.json());
|
|
70
|
+
return {
|
|
71
|
+
data: {
|
|
72
|
+
merge: {
|
|
73
|
+
sha: result.sha,
|
|
74
|
+
merged: result.merged,
|
|
75
|
+
message: result.message,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.GitHubMergePullRequestTool = GitHubMergePullRequestTool;
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, common_1.Inject)(),
|
|
84
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
85
|
+
], GitHubMergePullRequestTool.prototype, "tokenStore", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, common_2.Input)({
|
|
88
|
+
schema: zod_1.z
|
|
89
|
+
.object({
|
|
90
|
+
owner: zod_1.z.string(),
|
|
91
|
+
repo: zod_1.z.string(),
|
|
92
|
+
pullNumber: zod_1.z.number(),
|
|
93
|
+
mergeMethod: zod_1.z.enum(['merge', 'squash', 'rebase']).default('merge'),
|
|
94
|
+
commitTitle: zod_1.z.string().optional(),
|
|
95
|
+
commitMessage: zod_1.z.string().optional(),
|
|
96
|
+
})
|
|
97
|
+
.strict(),
|
|
98
|
+
}),
|
|
99
|
+
__metadata("design:type", Object)
|
|
100
|
+
], GitHubMergePullRequestTool.prototype, "args", void 0);
|
|
101
|
+
exports.GitHubMergePullRequestTool = GitHubMergePullRequestTool = GitHubMergePullRequestTool_1 = __decorate([
|
|
102
|
+
(0, common_2.Tool)({
|
|
103
|
+
config: {
|
|
104
|
+
description: 'Merges a GitHub pull request. Returns { error: "unauthorized" } if no valid token is available.',
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
], GitHubMergePullRequestTool);
|
|
108
|
+
//# sourceMappingURL=github-merge-pull-request.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-merge-pull-request.tool.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/github-merge-pull-request.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0DAA0D;AAgBnD,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IACpB,MAAM,GAAG,IAAI,eAAM,CAAC,4BAA0B,CAAC,IAAI,CAAC,CAAC;IAG9D,UAAU,CAAkB;IAcpC,IAAI,CAA6B;IAEjC,KAAK,CAAC,OAAO,CAAC,IAAgC,EAAE,GAAe;QAC7D,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,YAAY,EAAE,IAAI,CAAC,WAAW,IAAI,OAAO;SAC1C,CAAC;QAEF,IAAI,IAAI,CAAC,WAAW;YAAE,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;QAClE,IAAI,IAAI,CAAC,aAAa;YAAE,WAAW,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;QAExE,MAAM,GAAG,GAAG,gCAAgC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,QAAQ,CAAC;QAC7I,MAAM,QAAQ,GAAG,MAAM,KA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AA,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,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;YACtB,WAAW,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;YACnE,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAClC,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACrC,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;;wDAC+B;qCAlBtB,0BAA0B;IALtC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,iGAAiG;SAC/G;KACF,CAAC;GACW,0BAA0B,CAwFtC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubCreateRepoArgs = {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
private?: boolean;
|
|
6
|
+
autoInit?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class GitHubCreateRepoTool implements ToolInterface {
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private tokenStore;
|
|
11
|
+
args: GitHubCreateRepoArgs;
|
|
12
|
+
execute(args: GitHubCreateRepoArgs, ctx: RunContext): Promise<ToolResult>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=github-create-repo.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-create-repo.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/repos/github-create-repo.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAMa,oBAAqB,YAAW,aAAa;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAGhE,OAAO,CAAC,UAAU,CAAkB;IAYpC,IAAI,EAAE,oBAAoB,CAAC;IAErB,OAAO,CAAC,IAAI,EAAE,oBAAoB,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CA0EhF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 GitHubCreateRepoTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubCreateRepoTool = 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 GitHubCreateRepoTool = GitHubCreateRepoTool_1 = class GitHubCreateRepoTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubCreateRepoTool_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 body = {
|
|
33
|
+
name: args.name,
|
|
34
|
+
private: args.private ?? false,
|
|
35
|
+
auto_init: args.autoInit ?? false,
|
|
36
|
+
};
|
|
37
|
+
if (args.description)
|
|
38
|
+
body.description = args.description;
|
|
39
|
+
const response = await fetch('https://api.github.com/user/repos', {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: `Bearer ${accessToken}`,
|
|
43
|
+
Accept: 'application/vnd.github+json',
|
|
44
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
},
|
|
47
|
+
body: JSON.stringify(body),
|
|
48
|
+
});
|
|
49
|
+
if (response.status === 401 || response.status === 403) {
|
|
50
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
51
|
+
return {
|
|
52
|
+
data: {
|
|
53
|
+
error: '401',
|
|
54
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
const errorBody = await response.text();
|
|
60
|
+
this.logger.error(`GitHub API error: ${response.status} ${errorBody}`);
|
|
61
|
+
return {
|
|
62
|
+
data: {
|
|
63
|
+
error: 'api_error',
|
|
64
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const repo = (await response.json());
|
|
69
|
+
return {
|
|
70
|
+
data: {
|
|
71
|
+
repo: {
|
|
72
|
+
id: repo.id,
|
|
73
|
+
fullName: repo.full_name,
|
|
74
|
+
name: repo.name,
|
|
75
|
+
htmlUrl: repo.html_url,
|
|
76
|
+
private: repo.private,
|
|
77
|
+
defaultBranch: repo.default_branch,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
exports.GitHubCreateRepoTool = GitHubCreateRepoTool;
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, common_1.Inject)(),
|
|
86
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
87
|
+
], GitHubCreateRepoTool.prototype, "tokenStore", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, common_2.Input)({
|
|
90
|
+
schema: zod_1.z
|
|
91
|
+
.object({
|
|
92
|
+
name: zod_1.z.string(),
|
|
93
|
+
description: zod_1.z.string().optional(),
|
|
94
|
+
private: zod_1.z.boolean().default(false),
|
|
95
|
+
autoInit: zod_1.z.boolean().default(false),
|
|
96
|
+
})
|
|
97
|
+
.strict(),
|
|
98
|
+
}),
|
|
99
|
+
__metadata("design:type", Object)
|
|
100
|
+
], GitHubCreateRepoTool.prototype, "args", void 0);
|
|
101
|
+
exports.GitHubCreateRepoTool = GitHubCreateRepoTool = GitHubCreateRepoTool_1 = __decorate([
|
|
102
|
+
(0, common_2.Tool)({
|
|
103
|
+
config: {
|
|
104
|
+
description: 'Creates a new GitHub repository for the authenticated user. Returns { error: "unauthorized" } if no valid token is available.',
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
], GitHubCreateRepoTool);
|
|
108
|
+
//# sourceMappingURL=github-create-repo.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-create-repo.tool.js","sourceRoot":"","sources":["../../../src/tools/repos/github-create-repo.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0DAA0D;AAenD,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IACd,MAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAGxD,UAAU,CAAkB;IAYpC,IAAI,CAAuB;IAE3B,KAAK,CAAC,OAAO,CAAC,IAA0B,EAAE,GAAe;QACvD,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,IAAI,GAA4B;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,KAAK;YAC9B,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;SAClC,CAAC;QAEF,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAE1D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,mCAAmC,EAAE;YAChE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;gBACtC,MAAM,EAAE,6BAA6B;gBACrC,sBAAsB,EAAE,YAAY;gBACpC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAA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AAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAClC,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;YACnC,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;SACrC,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;;kDACyB;+BAhBhB,oBAAoB;IANhC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,+HAA+H;SAClI;KACF,CAAC;GACW,oBAAoB,CA4FhC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubGetRepoArgs = {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class GitHubGetRepoTool implements ToolInterface {
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private tokenStore;
|
|
9
|
+
args: GitHubGetRepoArgs;
|
|
10
|
+
execute(args: GitHubGetRepoArgs, ctx: RunContext): Promise<ToolResult>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=github-get-repo.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-get-repo.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/repos/github-get-repo.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAMa,iBAAkB,YAAW,aAAa;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAG7D,OAAO,CAAC,UAAU,CAAkB;IAUpC,IAAI,EAAE,iBAAiB,CAAC;IAElB,OAAO,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAuF7E"}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 GitHubGetRepoTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubGetRepoTool = 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 GitHubGetRepoTool = GitHubGetRepoTool_1 = class GitHubGetRepoTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubGetRepoTool_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 response = await fetch(`https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}`, {
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${accessToken}`,
|
|
35
|
+
Accept: 'application/vnd.github+json',
|
|
36
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (response.status === 401 || response.status === 403) {
|
|
40
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
41
|
+
return {
|
|
42
|
+
data: {
|
|
43
|
+
error: '401',
|
|
44
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const body = await response.text();
|
|
50
|
+
this.logger.error(`GitHub API error: ${response.status} ${body}`);
|
|
51
|
+
return {
|
|
52
|
+
data: {
|
|
53
|
+
error: 'api_error',
|
|
54
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const repo = (await response.json());
|
|
59
|
+
return {
|
|
60
|
+
data: {
|
|
61
|
+
repo: {
|
|
62
|
+
id: repo.id,
|
|
63
|
+
fullName: repo.full_name,
|
|
64
|
+
name: repo.name,
|
|
65
|
+
owner: repo.owner.login,
|
|
66
|
+
ownerAvatar: repo.owner.avatar_url,
|
|
67
|
+
private: repo.private,
|
|
68
|
+
htmlUrl: repo.html_url,
|
|
69
|
+
description: repo.description,
|
|
70
|
+
language: repo.language,
|
|
71
|
+
defaultBranch: repo.default_branch,
|
|
72
|
+
stars: repo.stargazers_count,
|
|
73
|
+
forks: repo.forks_count,
|
|
74
|
+
openIssues: repo.open_issues_count,
|
|
75
|
+
createdAt: repo.created_at,
|
|
76
|
+
updatedAt: repo.updated_at,
|
|
77
|
+
topics: repo.topics,
|
|
78
|
+
license: repo.license?.spdx_id ?? null,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
exports.GitHubGetRepoTool = GitHubGetRepoTool;
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, common_1.Inject)(),
|
|
87
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
88
|
+
], GitHubGetRepoTool.prototype, "tokenStore", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, common_2.Input)({
|
|
91
|
+
schema: zod_1.z
|
|
92
|
+
.object({
|
|
93
|
+
owner: zod_1.z.string(),
|
|
94
|
+
repo: zod_1.z.string(),
|
|
95
|
+
})
|
|
96
|
+
.strict(),
|
|
97
|
+
}),
|
|
98
|
+
__metadata("design:type", Object)
|
|
99
|
+
], GitHubGetRepoTool.prototype, "args", void 0);
|
|
100
|
+
exports.GitHubGetRepoTool = GitHubGetRepoTool = GitHubGetRepoTool_1 = __decorate([
|
|
101
|
+
(0, common_2.Tool)({
|
|
102
|
+
config: {
|
|
103
|
+
description: 'Gets detailed information about a specific GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
], GitHubGetRepoTool);
|
|
107
|
+
//# sourceMappingURL=github-get-repo.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-get-repo.tool.js","sourceRoot":"","sources":["../../../src/tools/repos/github-get-repo.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0DAA0D;AAanD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IACX,MAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAGrD,UAAU,CAAkB;IAUpC,IAAI,CAAoB;IAExB,KAAK,CAAC,OAAO,CAAC,IAAuB,EAAE,GAAe;QACpD,MAAM,WAAW,G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
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubListBranchesArgs = {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
perPage?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class GitHubListBranchesTool implements ToolInterface {
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private tokenStore;
|
|
10
|
+
args: GitHubListBranchesArgs;
|
|
11
|
+
execute(args: GitHubListBranchesArgs, ctx: RunContext): Promise<ToolResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=github-list-branches.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-branches.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/repos/github-list-branches.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAMa,sBAAuB,YAAW,aAAa;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAGlE,OAAO,CAAC,UAAU,CAAkB;IAWpC,IAAI,EAAE,sBAAsB,CAAC;IAEvB,OAAO,CAAC,IAAI,EAAE,sBAAsB,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CA8DlF"}
|
|
@@ -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 GitHubListBranchesTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubListBranchesTool = 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 GitHubListBranchesTool = GitHubListBranchesTool_1 = class GitHubListBranchesTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubListBranchesTool_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
|
+
per_page: String(args.perPage ?? 30),
|
|
34
|
+
});
|
|
35
|
+
const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/branches?${params.toString()}`;
|
|
36
|
+
const response = await fetch(url, {
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${accessToken}`,
|
|
39
|
+
Accept: 'application/vnd.github+json',
|
|
40
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
if (response.status === 401 || response.status === 403) {
|
|
44
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
45
|
+
return {
|
|
46
|
+
data: {
|
|
47
|
+
error: '401',
|
|
48
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const body = await response.text();
|
|
54
|
+
this.logger.error(`GitHub API error: ${response.status} ${body}`);
|
|
55
|
+
return {
|
|
56
|
+
data: {
|
|
57
|
+
error: 'api_error',
|
|
58
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const data = (await response.json());
|
|
63
|
+
const branches = data.map((branch) => ({
|
|
64
|
+
name: branch.name,
|
|
65
|
+
commitSha: branch.commit.sha,
|
|
66
|
+
protected: branch['protected'],
|
|
67
|
+
}));
|
|
68
|
+
return {
|
|
69
|
+
data: { branches },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.GitHubListBranchesTool = GitHubListBranchesTool;
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, common_1.Inject)(),
|
|
76
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
77
|
+
], GitHubListBranchesTool.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
|
+
perPage: zod_1.z.number().default(30),
|
|
85
|
+
})
|
|
86
|
+
.strict(),
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], GitHubListBranchesTool.prototype, "args", void 0);
|
|
90
|
+
exports.GitHubListBranchesTool = GitHubListBranchesTool = GitHubListBranchesTool_1 = __decorate([
|
|
91
|
+
(0, common_2.Tool)({
|
|
92
|
+
config: {
|
|
93
|
+
description: 'Lists branches for a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
], GitHubListBranchesTool);
|
|
97
|
+
//# sourceMappingURL=github-list-branches.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-branches.tool.js","sourceRoot":"","sources":["../../../src/tools/repos/github-list-branches.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0DAA0D;AAcnD,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAChB,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAG1D,UAAU,CAAkB;IAWpC,IAAI,CAAyB;IAE7B,KAAK,CAAC,OAAO,CAAC,IAA4B,EAAE,GAAe;QACzD,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,MAAM,GAAG,IAAI,eAAe,CAAC;YACjC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;SACrC,CAAC,CAAC;QAEH,MAAM,GAAG,GAAG,gCAAgC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC5I,MAAM,QAAQ,GAAG,MAAM,KAA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AIzB;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;0DAAC;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,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;SAChC,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;;oDAC2B;iCAflB,sBAAsB;IANlC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,2GAA2G;SAC9G;KACF,CAAC;GACW,sBAAsB,CA+ElC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubListReposArgs = {
|
|
3
|
+
visibility?: string;
|
|
4
|
+
sort?: string;
|
|
5
|
+
perPage?: number;
|
|
6
|
+
page?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class GitHubListReposTool implements ToolInterface {
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private tokenStore;
|
|
11
|
+
args: GitHubListReposArgs;
|
|
12
|
+
execute(args: GitHubListReposArgs, ctx: RunContext): Promise<ToolResult>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=github-list-repos.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-repos.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/repos/github-list-repos.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAQ,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAMa,mBAAoB,YAAW,aAAa;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAG/D,OAAO,CAAC,UAAU,CAAkB;IAYpC,IAAI,EAAE,mBAAmB,CAAC;IAEpB,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CA8E/E"}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 GitHubListReposTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GitHubListReposTool = 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 GitHubListReposTool = GitHubListReposTool_1 = class GitHubListReposTool {
|
|
19
|
+
logger = new common_1.Logger(GitHubListReposTool_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
|
+
visibility: args.visibility ?? 'all',
|
|
34
|
+
sort: args.sort ?? 'updated',
|
|
35
|
+
per_page: String(args.perPage ?? 30),
|
|
36
|
+
page: String(args.page ?? 1),
|
|
37
|
+
});
|
|
38
|
+
const response = await fetch(`https://api.github.com/user/repos?${params.toString()}`, {
|
|
39
|
+
headers: {
|
|
40
|
+
Authorization: `Bearer ${accessToken}`,
|
|
41
|
+
Accept: 'application/vnd.github+json',
|
|
42
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
if (response.status === 401 || response.status === 403) {
|
|
46
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
47
|
+
return {
|
|
48
|
+
data: {
|
|
49
|
+
error: '401',
|
|
50
|
+
message: 'GitHub token was rejected. Please re-authenticate.',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
const body = await response.text();
|
|
56
|
+
this.logger.error(`GitHub API error: ${response.status} ${body}`);
|
|
57
|
+
return {
|
|
58
|
+
data: {
|
|
59
|
+
error: 'api_error',
|
|
60
|
+
message: `GitHub API error: ${response.statusText}`,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const data = (await response.json());
|
|
65
|
+
const repos = data.map((repo) => ({
|
|
66
|
+
id: repo.id,
|
|
67
|
+
fullName: repo.full_name,
|
|
68
|
+
name: repo.name,
|
|
69
|
+
owner: repo.owner.login,
|
|
70
|
+
private: repo.private,
|
|
71
|
+
htmlUrl: repo.html_url,
|
|
72
|
+
description: repo.description,
|
|
73
|
+
language: repo.language,
|
|
74
|
+
defaultBranch: repo.default_branch,
|
|
75
|
+
updatedAt: repo.updated_at,
|
|
76
|
+
}));
|
|
77
|
+
return {
|
|
78
|
+
data: { repos },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.GitHubListReposTool = GitHubListReposTool;
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, common_1.Inject)(),
|
|
85
|
+
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
86
|
+
], GitHubListReposTool.prototype, "tokenStore", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, common_2.Input)({
|
|
89
|
+
schema: zod_1.z
|
|
90
|
+
.object({
|
|
91
|
+
visibility: zod_1.z.enum(['all', 'public', 'private']).default('all'),
|
|
92
|
+
sort: zod_1.z.enum(['created', 'updated', 'pushed', 'full_name']).default('updated'),
|
|
93
|
+
perPage: zod_1.z.number().default(30),
|
|
94
|
+
page: zod_1.z.number().default(1),
|
|
95
|
+
})
|
|
96
|
+
.strict(),
|
|
97
|
+
}),
|
|
98
|
+
__metadata("design:type", Object)
|
|
99
|
+
], GitHubListReposTool.prototype, "args", void 0);
|
|
100
|
+
exports.GitHubListReposTool = GitHubListReposTool = GitHubListReposTool_1 = __decorate([
|
|
101
|
+
(0, common_2.Tool)({
|
|
102
|
+
config: {
|
|
103
|
+
description: 'Lists repositories for the authenticated GitHub user. Returns { error: "unauthorized" } if no valid token is available.',
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
], GitHubListReposTool);
|
|
107
|
+
//# sourceMappingURL=github-list-repos.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-list-repos.tool.js","sourceRoot":"","sources":["../../../src/tools/repos/github-list-repos.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAAuF;AACvF,0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CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;YAC/D,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;YAC9E,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;;iDACwB;8BAhBf,mBAAmB;IAN/B,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,yHAAyH;SAC5H;KACF,CAAC;GACW,mBAAmB,CAgG/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
2
|
+
export type GitHubSearchCodeArgs = {
|
|
3
|
+
query: string;
|
|
4
|
+
perPage?: number;
|
|
5
|
+
page?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class GitHubSearchCodeTool implements ToolInterface {
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private tokenStore;
|
|
10
|
+
args: GitHubSearchCodeArgs;
|
|
11
|
+
execute(args: GitHubSearchCodeArgs, ctx: RunContext): Promise<ToolResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=github-search-code.tool.d.ts.map
|