@loopstack/github-module 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tools/actions/github-get-workflow-run.tool.d.ts +11 -9
- package/dist/tools/actions/github-get-workflow-run.tool.d.ts.map +1 -1
- package/dist/tools/actions/github-get-workflow-run.tool.js +13 -18
- package/dist/tools/actions/github-get-workflow-run.tool.js.map +1 -1
- package/dist/tools/actions/github-list-workflow-runs.tool.d.ts +29 -12
- package/dist/tools/actions/github-list-workflow-runs.tool.d.ts.map +1 -1
- package/dist/tools/actions/github-list-workflow-runs.tool.js +33 -38
- package/dist/tools/actions/github-list-workflow-runs.tool.js.map +1 -1
- package/dist/tools/actions/github-trigger-workflow.tool.d.ts +13 -11
- package/dist/tools/actions/github-trigger-workflow.tool.d.ts.map +1 -1
- package/dist/tools/actions/github-trigger-workflow.tool.js +15 -20
- package/dist/tools/actions/github-trigger-workflow.tool.js.map +1 -1
- package/dist/tools/content/github-create-or-update-file.tool.d.ts +15 -13
- package/dist/tools/content/github-create-or-update-file.tool.d.ts.map +1 -1
- package/dist/tools/content/github-create-or-update-file.tool.js +17 -22
- package/dist/tools/content/github-create-or-update-file.tool.js.map +1 -1
- package/dist/tools/content/github-get-commit.tool.d.ts +11 -9
- package/dist/tools/content/github-get-commit.tool.d.ts.map +1 -1
- package/dist/tools/content/github-get-commit.tool.js +13 -18
- package/dist/tools/content/github-get-commit.tool.js.map +1 -1
- package/dist/tools/content/github-get-file-content.tool.d.ts +12 -10
- package/dist/tools/content/github-get-file-content.tool.d.ts.map +1 -1
- package/dist/tools/content/github-get-file-content.tool.js +14 -19
- package/dist/tools/content/github-get-file-content.tool.js.map +1 -1
- package/dist/tools/content/github-list-directory.tool.d.ts +12 -10
- package/dist/tools/content/github-list-directory.tool.d.ts.map +1 -1
- package/dist/tools/content/github-list-directory.tool.js +14 -19
- package/dist/tools/content/github-list-directory.tool.js.map +1 -1
- package/dist/tools/issues/github-create-issue-comment.tool.d.ts +12 -10
- package/dist/tools/issues/github-create-issue-comment.tool.d.ts.map +1 -1
- package/dist/tools/issues/github-create-issue-comment.tool.js +14 -19
- package/dist/tools/issues/github-create-issue-comment.tool.js.map +1 -1
- package/dist/tools/issues/github-create-issue.tool.d.ts +14 -12
- package/dist/tools/issues/github-create-issue.tool.d.ts.map +1 -1
- package/dist/tools/issues/github-create-issue.tool.js +16 -21
- package/dist/tools/issues/github-create-issue.tool.js.map +1 -1
- package/dist/tools/issues/github-get-issue.tool.d.ts +11 -9
- package/dist/tools/issues/github-get-issue.tool.d.ts.map +1 -1
- package/dist/tools/issues/github-get-issue.tool.js +13 -18
- package/dist/tools/issues/github-get-issue.tool.js.map +1 -1
- package/dist/tools/issues/github-list-issues.tool.d.ts +19 -13
- package/dist/tools/issues/github-list-issues.tool.d.ts.map +1 -1
- package/dist/tools/issues/github-list-issues.tool.js +17 -22
- package/dist/tools/issues/github-list-issues.tool.js.map +1 -1
- package/dist/tools/pull-requests/github-create-pull-request.tool.d.ts +15 -13
- package/dist/tools/pull-requests/github-create-pull-request.tool.d.ts.map +1 -1
- package/dist/tools/pull-requests/github-create-pull-request.tool.js +17 -22
- package/dist/tools/pull-requests/github-create-pull-request.tool.js.map +1 -1
- package/dist/tools/pull-requests/github-get-pull-request.tool.d.ts +11 -9
- package/dist/tools/pull-requests/github-get-pull-request.tool.d.ts.map +1 -1
- package/dist/tools/pull-requests/github-get-pull-request.tool.js +13 -18
- package/dist/tools/pull-requests/github-get-pull-request.tool.js.map +1 -1
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.d.ts +11 -9
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.d.ts.map +1 -1
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.js +13 -18
- package/dist/tools/pull-requests/github-list-pr-reviews.tool.js.map +1 -1
- package/dist/tools/pull-requests/github-list-pull-requests.tool.d.ts +18 -12
- package/dist/tools/pull-requests/github-list-pull-requests.tool.d.ts.map +1 -1
- package/dist/tools/pull-requests/github-list-pull-requests.tool.js +16 -21
- package/dist/tools/pull-requests/github-list-pull-requests.tool.js.map +1 -1
- package/dist/tools/pull-requests/github-merge-pull-request.tool.d.ts +18 -12
- package/dist/tools/pull-requests/github-merge-pull-request.tool.d.ts.map +1 -1
- package/dist/tools/pull-requests/github-merge-pull-request.tool.js +16 -21
- package/dist/tools/pull-requests/github-merge-pull-request.tool.js.map +1 -1
- package/dist/tools/repos/github-create-repo.tool.d.ts +12 -10
- package/dist/tools/repos/github-create-repo.tool.d.ts.map +1 -1
- package/dist/tools/repos/github-create-repo.tool.js +14 -19
- package/dist/tools/repos/github-create-repo.tool.js.map +1 -1
- package/dist/tools/repos/github-get-repo.tool.d.ts +10 -8
- package/dist/tools/repos/github-get-repo.tool.d.ts.map +1 -1
- package/dist/tools/repos/github-get-repo.tool.js +12 -17
- package/dist/tools/repos/github-get-repo.tool.js.map +1 -1
- package/dist/tools/repos/github-list-branches.tool.d.ts +11 -9
- package/dist/tools/repos/github-list-branches.tool.d.ts.map +1 -1
- package/dist/tools/repos/github-list-branches.tool.js +13 -18
- package/dist/tools/repos/github-list-branches.tool.js.map +1 -1
- package/dist/tools/repos/github-list-repos.tool.d.ts +21 -10
- package/dist/tools/repos/github-list-repos.tool.d.ts.map +1 -1
- package/dist/tools/repos/github-list-repos.tool.js +14 -19
- package/dist/tools/repos/github-list-repos.tool.js.map +1 -1
- package/dist/tools/search/github-search-code.tool.d.ts +11 -9
- package/dist/tools/search/github-search-code.tool.d.ts.map +1 -1
- package/dist/tools/search/github-search-code.tool.js +13 -18
- package/dist/tools/search/github-search-code.tool.js.map +1 -1
- package/dist/tools/search/github-search-issues.tool.d.ts +20 -10
- package/dist/tools/search/github-search-issues.tool.d.ts.map +1 -1
- package/dist/tools/search/github-search-issues.tool.js +16 -21
- package/dist/tools/search/github-search-issues.tool.js.map +1 -1
- package/dist/tools/search/github-search-repos.tool.d.ts +17 -10
- package/dist/tools/search/github-search-repos.tool.d.ts.map +1 -1
- package/dist/tools/search/github-search-repos.tool.js +14 -19
- package/dist/tools/search/github-search-repos.tool.js.map +1 -1
- package/dist/tools/users/github-get-authenticated-user.tool.d.ts +7 -5
- package/dist/tools/users/github-get-authenticated-user.tool.d.ts.map +1 -1
- package/dist/tools/users/github-get-authenticated-user.tool.js +7 -12
- package/dist/tools/users/github-get-authenticated-user.tool.js.map +1 -1
- package/dist/tools/users/github-list-user-orgs.tool.d.ts +9 -7
- package/dist/tools/users/github-list-user-orgs.tool.d.ts.map +1 -1
- package/dist/tools/users/github-list-user-orgs.tool.js +11 -16
- package/dist/tools/users/github-list-user-orgs.tool.js.map +1 -1
- package/package.json +2 -2
- package/src/tools/actions/github-get-workflow-run.tool.ts +16 -22
- package/src/tools/actions/github-list-workflow-runs.tool.ts +36 -45
- package/src/tools/actions/github-trigger-workflow.tool.ts +18 -26
- package/src/tools/content/github-create-or-update-file.tool.ts +20 -30
- package/src/tools/content/github-get-commit.tool.ts +16 -22
- package/src/tools/content/github-get-file-content.tool.ts +17 -24
- package/src/tools/content/github-list-directory.tool.ts +17 -24
- package/src/tools/issues/github-create-issue-comment.tool.ts +17 -24
- package/src/tools/issues/github-create-issue.tool.ts +19 -28
- package/src/tools/issues/github-get-issue.tool.ts +16 -22
- package/src/tools/issues/github-list-issues.tool.ts +20 -30
- package/src/tools/pull-requests/github-create-pull-request.tool.ts +20 -30
- package/src/tools/pull-requests/github-get-pull-request.tool.ts +16 -22
- package/src/tools/pull-requests/github-list-pr-reviews.tool.ts +16 -22
- package/src/tools/pull-requests/github-list-pull-requests.tool.ts +19 -28
- package/src/tools/pull-requests/github-merge-pull-request.tool.ts +19 -28
- package/src/tools/repos/github-create-repo.tool.ts +17 -24
- package/src/tools/repos/github-get-repo.tool.ts +15 -20
- package/src/tools/repos/github-list-branches.tool.ts +16 -22
- package/src/tools/repos/github-list-repos.tool.ts +17 -24
- package/src/tools/search/github-search-code.tool.ts +16 -22
- package/src/tools/search/github-search-issues.tool.ts +19 -26
- package/src/tools/search/github-search-repos.tool.ts +17 -24
- package/src/tools/users/github-get-authenticated-user.tool.ts +10 -12
- package/src/tools/users/github-list-user-orgs.tool.ts +14 -18
|
@@ -1,47 +1,37 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
title: z.string(),
|
|
11
|
+
head: z.string(),
|
|
12
|
+
base: z.string(),
|
|
13
|
+
body: z.string().optional(),
|
|
14
|
+
draft: z.boolean().default(false),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
|
|
18
|
+
export type GitHubCreatePullRequestArgs = z.input<typeof inputSchema>;
|
|
15
19
|
|
|
16
20
|
@Tool({
|
|
17
|
-
|
|
21
|
+
uiConfig: {
|
|
18
22
|
description:
|
|
19
23
|
'Creates a new pull request in a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
20
24
|
},
|
|
25
|
+
schema: inputSchema,
|
|
21
26
|
})
|
|
22
|
-
export class GitHubCreatePullRequestTool
|
|
27
|
+
export class GitHubCreatePullRequestTool extends BaseTool {
|
|
23
28
|
private readonly logger = new Logger(GitHubCreatePullRequestTool.name);
|
|
24
29
|
|
|
25
30
|
@Inject()
|
|
26
31
|
private tokenStore: OAuthTokenStore;
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.object({
|
|
31
|
-
owner: z.string(),
|
|
32
|
-
repo: z.string(),
|
|
33
|
-
title: z.string(),
|
|
34
|
-
head: z.string(),
|
|
35
|
-
base: z.string(),
|
|
36
|
-
body: z.string().optional(),
|
|
37
|
-
draft: z.boolean().default(false),
|
|
38
|
-
})
|
|
39
|
-
.strict(),
|
|
40
|
-
})
|
|
41
|
-
args: GitHubCreatePullRequestArgs;
|
|
42
|
-
|
|
43
|
-
async execute(args: GitHubCreatePullRequestArgs, ctx: RunContext): Promise<ToolResult> {
|
|
44
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
33
|
+
async call(args: GitHubCreatePullRequestArgs): Promise<ToolResult> {
|
|
34
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
45
35
|
|
|
46
36
|
if (!accessToken) {
|
|
47
37
|
return {
|
|
@@ -74,7 +64,7 @@ export class GitHubCreatePullRequestTool implements ToolInterface {
|
|
|
74
64
|
});
|
|
75
65
|
|
|
76
66
|
if (response.status === 401 || response.status === 403) {
|
|
77
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
67
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
78
68
|
return {
|
|
79
69
|
data: {
|
|
80
70
|
error: '401',
|
|
@@ -1,39 +1,33 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
pullNumber: z.number(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
|
|
14
|
+
export type GitHubGetPullRequestArgs = z.infer<typeof inputSchema>;
|
|
11
15
|
|
|
12
16
|
@Tool({
|
|
13
|
-
|
|
17
|
+
uiConfig: {
|
|
14
18
|
description:
|
|
15
19
|
'Gets detailed information about a specific GitHub pull request. Returns { error: "unauthorized" } if no valid token is available.',
|
|
16
20
|
},
|
|
21
|
+
schema: inputSchema,
|
|
17
22
|
})
|
|
18
|
-
export class GitHubGetPullRequestTool
|
|
23
|
+
export class GitHubGetPullRequestTool extends BaseTool {
|
|
19
24
|
private readonly logger = new Logger(GitHubGetPullRequestTool.name);
|
|
20
25
|
|
|
21
26
|
@Inject()
|
|
22
27
|
private tokenStore: OAuthTokenStore;
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.object({
|
|
27
|
-
owner: z.string(),
|
|
28
|
-
repo: z.string(),
|
|
29
|
-
pullNumber: z.number(),
|
|
30
|
-
})
|
|
31
|
-
.strict(),
|
|
32
|
-
})
|
|
33
|
-
args: GitHubGetPullRequestArgs;
|
|
34
|
-
|
|
35
|
-
async execute(args: GitHubGetPullRequestArgs, ctx: RunContext): Promise<ToolResult> {
|
|
36
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
29
|
+
async call(args: GitHubGetPullRequestArgs): Promise<ToolResult> {
|
|
30
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
37
31
|
|
|
38
32
|
if (!accessToken) {
|
|
39
33
|
return {
|
|
@@ -54,7 +48,7 @@ export class GitHubGetPullRequestTool implements ToolInterface {
|
|
|
54
48
|
});
|
|
55
49
|
|
|
56
50
|
if (response.status === 401 || response.status === 403) {
|
|
57
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
51
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
58
52
|
return {
|
|
59
53
|
data: {
|
|
60
54
|
error: '401',
|
|
@@ -1,39 +1,33 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
pullNumber: z.number(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
|
|
14
|
+
export type GitHubListPrReviewsArgs = z.infer<typeof inputSchema>;
|
|
11
15
|
|
|
12
16
|
@Tool({
|
|
13
|
-
|
|
17
|
+
uiConfig: {
|
|
14
18
|
description:
|
|
15
19
|
'Lists reviews on a GitHub pull request. Returns { error: "unauthorized" } if no valid token is available.',
|
|
16
20
|
},
|
|
21
|
+
schema: inputSchema,
|
|
17
22
|
})
|
|
18
|
-
export class GitHubListPrReviewsTool
|
|
23
|
+
export class GitHubListPrReviewsTool extends BaseTool {
|
|
19
24
|
private readonly logger = new Logger(GitHubListPrReviewsTool.name);
|
|
20
25
|
|
|
21
26
|
@Inject()
|
|
22
27
|
private tokenStore: OAuthTokenStore;
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.object({
|
|
27
|
-
owner: z.string(),
|
|
28
|
-
repo: z.string(),
|
|
29
|
-
pullNumber: z.number(),
|
|
30
|
-
})
|
|
31
|
-
.strict(),
|
|
32
|
-
})
|
|
33
|
-
args: GitHubListPrReviewsArgs;
|
|
34
|
-
|
|
35
|
-
async execute(args: GitHubListPrReviewsArgs, ctx: RunContext): Promise<ToolResult> {
|
|
36
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
29
|
+
async call(args: GitHubListPrReviewsArgs): Promise<ToolResult> {
|
|
30
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
37
31
|
|
|
38
32
|
if (!accessToken) {
|
|
39
33
|
return {
|
|
@@ -54,7 +48,7 @@ export class GitHubListPrReviewsTool implements ToolInterface {
|
|
|
54
48
|
});
|
|
55
49
|
|
|
56
50
|
if (response.status === 401 || response.status === 403) {
|
|
57
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
51
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
58
52
|
return {
|
|
59
53
|
data: {
|
|
60
54
|
error: '401',
|
|
@@ -1,45 +1,36 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
state: z.enum(['open', 'closed', 'all']).default('open'),
|
|
11
|
+
base: z.string().optional(),
|
|
12
|
+
perPage: z.number().default(30),
|
|
13
|
+
page: z.number().default(1),
|
|
14
|
+
})
|
|
15
|
+
.strict();
|
|
16
|
+
|
|
17
|
+
export type GitHubListPullRequestsArgs = z.input<typeof inputSchema>;
|
|
14
18
|
|
|
15
19
|
@Tool({
|
|
16
|
-
|
|
20
|
+
uiConfig: {
|
|
17
21
|
description:
|
|
18
22
|
'Lists pull requests for a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
19
23
|
},
|
|
24
|
+
schema: inputSchema,
|
|
20
25
|
})
|
|
21
|
-
export class GitHubListPullRequestsTool
|
|
26
|
+
export class GitHubListPullRequestsTool extends BaseTool {
|
|
22
27
|
private readonly logger = new Logger(GitHubListPullRequestsTool.name);
|
|
23
28
|
|
|
24
29
|
@Inject()
|
|
25
30
|
private tokenStore: OAuthTokenStore;
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.object({
|
|
30
|
-
owner: z.string(),
|
|
31
|
-
repo: z.string(),
|
|
32
|
-
state: z.enum(['open', 'closed', 'all']).default('open'),
|
|
33
|
-
base: z.string().optional(),
|
|
34
|
-
perPage: z.number().default(30),
|
|
35
|
-
page: z.number().default(1),
|
|
36
|
-
})
|
|
37
|
-
.strict(),
|
|
38
|
-
})
|
|
39
|
-
args: GitHubListPullRequestsArgs;
|
|
40
|
-
|
|
41
|
-
async execute(args: GitHubListPullRequestsArgs, ctx: RunContext): Promise<ToolResult> {
|
|
42
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
32
|
+
async call(args: GitHubListPullRequestsArgs): Promise<ToolResult> {
|
|
33
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
43
34
|
|
|
44
35
|
if (!accessToken) {
|
|
45
36
|
return {
|
|
@@ -68,7 +59,7 @@ export class GitHubListPullRequestsTool implements ToolInterface {
|
|
|
68
59
|
});
|
|
69
60
|
|
|
70
61
|
if (response.status === 401 || response.status === 403) {
|
|
71
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
62
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
72
63
|
return {
|
|
73
64
|
data: {
|
|
74
65
|
error: '401',
|
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
pullNumber: z.number(),
|
|
11
|
+
mergeMethod: z.enum(['merge', 'squash', 'rebase']).default('merge'),
|
|
12
|
+
commitTitle: z.string().optional(),
|
|
13
|
+
commitMessage: z.string().optional(),
|
|
14
|
+
})
|
|
15
|
+
.strict();
|
|
16
|
+
|
|
17
|
+
export type GitHubMergePullRequestArgs = z.input<typeof inputSchema>;
|
|
14
18
|
|
|
15
19
|
@Tool({
|
|
16
|
-
|
|
20
|
+
uiConfig: {
|
|
17
21
|
description: 'Merges a GitHub pull request. Returns { error: "unauthorized" } if no valid token is available.',
|
|
18
22
|
},
|
|
23
|
+
schema: inputSchema,
|
|
19
24
|
})
|
|
20
|
-
export class GitHubMergePullRequestTool
|
|
25
|
+
export class GitHubMergePullRequestTool extends BaseTool {
|
|
21
26
|
private readonly logger = new Logger(GitHubMergePullRequestTool.name);
|
|
22
27
|
|
|
23
28
|
@Inject()
|
|
24
29
|
private tokenStore: OAuthTokenStore;
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.object({
|
|
29
|
-
owner: z.string(),
|
|
30
|
-
repo: z.string(),
|
|
31
|
-
pullNumber: z.number(),
|
|
32
|
-
mergeMethod: z.enum(['merge', 'squash', 'rebase']).default('merge'),
|
|
33
|
-
commitTitle: z.string().optional(),
|
|
34
|
-
commitMessage: z.string().optional(),
|
|
35
|
-
})
|
|
36
|
-
.strict(),
|
|
37
|
-
})
|
|
38
|
-
args: GitHubMergePullRequestArgs;
|
|
39
|
-
|
|
40
|
-
async execute(args: GitHubMergePullRequestArgs, ctx: RunContext): Promise<ToolResult> {
|
|
41
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
31
|
+
async call(args: GitHubMergePullRequestArgs): Promise<ToolResult> {
|
|
32
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
42
33
|
|
|
43
34
|
if (!accessToken) {
|
|
44
35
|
return {
|
|
@@ -69,7 +60,7 @@ export class GitHubMergePullRequestTool implements ToolInterface {
|
|
|
69
60
|
});
|
|
70
61
|
|
|
71
62
|
if (response.status === 401 || response.status === 403) {
|
|
72
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
63
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
73
64
|
return {
|
|
74
65
|
data: {
|
|
75
66
|
error: '401',
|
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
name: z.string(),
|
|
9
|
+
description: z.string().optional(),
|
|
10
|
+
private: z.boolean().default(false),
|
|
11
|
+
autoInit: z.boolean().default(false),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
|
|
15
|
+
export type GitHubCreateRepoArgs = z.input<typeof inputSchema>;
|
|
12
16
|
|
|
13
17
|
@Tool({
|
|
14
|
-
|
|
18
|
+
uiConfig: {
|
|
15
19
|
description:
|
|
16
20
|
'Creates a new GitHub repository for the authenticated user. Returns { error: "unauthorized" } if no valid token is available.',
|
|
17
21
|
},
|
|
22
|
+
schema: inputSchema,
|
|
18
23
|
})
|
|
19
|
-
export class GitHubCreateRepoTool
|
|
24
|
+
export class GitHubCreateRepoTool extends BaseTool {
|
|
20
25
|
private readonly logger = new Logger(GitHubCreateRepoTool.name);
|
|
21
26
|
|
|
22
27
|
@Inject()
|
|
23
28
|
private tokenStore: OAuthTokenStore;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.object({
|
|
28
|
-
name: z.string(),
|
|
29
|
-
description: z.string().optional(),
|
|
30
|
-
private: z.boolean().default(false),
|
|
31
|
-
autoInit: z.boolean().default(false),
|
|
32
|
-
})
|
|
33
|
-
.strict(),
|
|
34
|
-
})
|
|
35
|
-
args: GitHubCreateRepoArgs;
|
|
36
|
-
|
|
37
|
-
async execute(args: GitHubCreateRepoArgs, ctx: RunContext): Promise<ToolResult> {
|
|
38
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
30
|
+
async call(args: GitHubCreateRepoArgs): Promise<ToolResult> {
|
|
31
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
39
32
|
|
|
40
33
|
if (!accessToken) {
|
|
41
34
|
return {
|
|
@@ -66,7 +59,7 @@ export class GitHubCreateRepoTool implements ToolInterface {
|
|
|
66
59
|
});
|
|
67
60
|
|
|
68
61
|
if (response.status === 401 || response.status === 403) {
|
|
69
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
62
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
70
63
|
return {
|
|
71
64
|
data: {
|
|
72
65
|
error: '401',
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
|
+
|
|
13
|
+
export type GitHubGetRepoArgs = z.infer<typeof inputSchema>;
|
|
10
14
|
|
|
11
15
|
@Tool({
|
|
12
|
-
|
|
16
|
+
uiConfig: {
|
|
13
17
|
description:
|
|
14
18
|
'Gets detailed information about a specific GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
15
19
|
},
|
|
20
|
+
schema: inputSchema,
|
|
16
21
|
})
|
|
17
|
-
export class GitHubGetRepoTool
|
|
22
|
+
export class GitHubGetRepoTool extends BaseTool {
|
|
18
23
|
private readonly logger = new Logger(GitHubGetRepoTool.name);
|
|
19
24
|
|
|
20
25
|
@Inject()
|
|
21
26
|
private tokenStore: OAuthTokenStore;
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.object({
|
|
26
|
-
owner: z.string(),
|
|
27
|
-
repo: z.string(),
|
|
28
|
-
})
|
|
29
|
-
.strict(),
|
|
30
|
-
})
|
|
31
|
-
args: GitHubGetRepoArgs;
|
|
32
|
-
|
|
33
|
-
async execute(args: GitHubGetRepoArgs, ctx: RunContext): Promise<ToolResult> {
|
|
34
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
28
|
+
async call(args: GitHubGetRepoArgs): Promise<ToolResult> {
|
|
29
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
35
30
|
|
|
36
31
|
if (!accessToken) {
|
|
37
32
|
return {
|
|
@@ -54,7 +49,7 @@ export class GitHubGetRepoTool implements ToolInterface {
|
|
|
54
49
|
);
|
|
55
50
|
|
|
56
51
|
if (response.status === 401 || response.status === 403) {
|
|
57
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
52
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
58
53
|
return {
|
|
59
54
|
data: {
|
|
60
55
|
error: '401',
|
|
@@ -1,39 +1,33 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
perPage: z.number().default(30),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
|
|
14
|
+
export type GitHubListBranchesArgs = z.input<typeof inputSchema>;
|
|
11
15
|
|
|
12
16
|
@Tool({
|
|
13
|
-
|
|
17
|
+
uiConfig: {
|
|
14
18
|
description:
|
|
15
19
|
'Lists branches for a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
16
20
|
},
|
|
21
|
+
schema: inputSchema,
|
|
17
22
|
})
|
|
18
|
-
export class GitHubListBranchesTool
|
|
23
|
+
export class GitHubListBranchesTool extends BaseTool {
|
|
19
24
|
private readonly logger = new Logger(GitHubListBranchesTool.name);
|
|
20
25
|
|
|
21
26
|
@Inject()
|
|
22
27
|
private tokenStore: OAuthTokenStore;
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.object({
|
|
27
|
-
owner: z.string(),
|
|
28
|
-
repo: z.string(),
|
|
29
|
-
perPage: z.number().default(30),
|
|
30
|
-
})
|
|
31
|
-
.strict(),
|
|
32
|
-
})
|
|
33
|
-
args: GitHubListBranchesArgs;
|
|
34
|
-
|
|
35
|
-
async execute(args: GitHubListBranchesArgs, ctx: RunContext): Promise<ToolResult> {
|
|
36
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
29
|
+
async call(args: GitHubListBranchesArgs): Promise<ToolResult> {
|
|
30
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
37
31
|
|
|
38
32
|
if (!accessToken) {
|
|
39
33
|
return {
|
|
@@ -58,7 +52,7 @@ export class GitHubListBranchesTool implements ToolInterface {
|
|
|
58
52
|
});
|
|
59
53
|
|
|
60
54
|
if (response.status === 401 || response.status === 403) {
|
|
61
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
55
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
62
56
|
return {
|
|
63
57
|
data: {
|
|
64
58
|
error: '401',
|
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
visibility: z.enum(['all', 'public', 'private']).default('all'),
|
|
9
|
+
sort: z.enum(['created', 'updated', 'pushed', 'full_name']).default('updated'),
|
|
10
|
+
perPage: z.number().default(30),
|
|
11
|
+
page: z.number().default(1),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
|
|
15
|
+
export type GitHubListReposArgs = z.input<typeof inputSchema>;
|
|
12
16
|
|
|
13
17
|
@Tool({
|
|
14
|
-
|
|
18
|
+
uiConfig: {
|
|
15
19
|
description:
|
|
16
20
|
'Lists repositories for the authenticated GitHub user. Returns { error: "unauthorized" } if no valid token is available.',
|
|
17
21
|
},
|
|
22
|
+
schema: inputSchema,
|
|
18
23
|
})
|
|
19
|
-
export class GitHubListReposTool
|
|
24
|
+
export class GitHubListReposTool extends BaseTool {
|
|
20
25
|
private readonly logger = new Logger(GitHubListReposTool.name);
|
|
21
26
|
|
|
22
27
|
@Inject()
|
|
23
28
|
private tokenStore: OAuthTokenStore;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.object({
|
|
28
|
-
visibility: z.enum(['all', 'public', 'private']).default('all'),
|
|
29
|
-
sort: z.enum(['created', 'updated', 'pushed', 'full_name']).default('updated'),
|
|
30
|
-
perPage: z.number().default(30),
|
|
31
|
-
page: z.number().default(1),
|
|
32
|
-
})
|
|
33
|
-
.strict(),
|
|
34
|
-
})
|
|
35
|
-
args: GitHubListReposArgs;
|
|
36
|
-
|
|
37
|
-
async execute(args: GitHubListReposArgs, ctx: RunContext): Promise<ToolResult> {
|
|
38
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
30
|
+
async call(args: GitHubListReposArgs): Promise<ToolResult> {
|
|
31
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
39
32
|
|
|
40
33
|
if (!accessToken) {
|
|
41
34
|
return {
|
|
@@ -62,7 +55,7 @@ export class GitHubListReposTool implements ToolInterface {
|
|
|
62
55
|
});
|
|
63
56
|
|
|
64
57
|
if (response.status === 401 || response.status === 403) {
|
|
65
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
58
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
66
59
|
return {
|
|
67
60
|
data: {
|
|
68
61
|
error: '401',
|
|
@@ -1,39 +1,33 @@
|
|
|
1
1
|
import { Inject, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseTool, Tool, ToolResult } from '@loopstack/common';
|
|
4
4
|
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
query: z.string(),
|
|
9
|
+
perPage: z.number().default(30),
|
|
10
|
+
page: z.number().default(1),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
|
|
14
|
+
export type GitHubSearchCodeArgs = z.input<typeof inputSchema>;
|
|
11
15
|
|
|
12
16
|
@Tool({
|
|
13
|
-
|
|
17
|
+
uiConfig: {
|
|
14
18
|
description:
|
|
15
19
|
'Searches for code across GitHub repositories using the GitHub search syntax. Returns { error: "unauthorized" } if no valid token is available.',
|
|
16
20
|
},
|
|
21
|
+
schema: inputSchema,
|
|
17
22
|
})
|
|
18
|
-
export class GitHubSearchCodeTool
|
|
23
|
+
export class GitHubSearchCodeTool extends BaseTool {
|
|
19
24
|
private readonly logger = new Logger(GitHubSearchCodeTool.name);
|
|
20
25
|
|
|
21
26
|
@Inject()
|
|
22
27
|
private tokenStore: OAuthTokenStore;
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.object({
|
|
27
|
-
query: z.string(),
|
|
28
|
-
perPage: z.number().default(30),
|
|
29
|
-
page: z.number().default(1),
|
|
30
|
-
})
|
|
31
|
-
.strict(),
|
|
32
|
-
})
|
|
33
|
-
args: GitHubSearchCodeArgs;
|
|
34
|
-
|
|
35
|
-
async execute(args: GitHubSearchCodeArgs, ctx: RunContext): Promise<ToolResult> {
|
|
36
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
29
|
+
async call(args: GitHubSearchCodeArgs): Promise<ToolResult> {
|
|
30
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
37
31
|
|
|
38
32
|
if (!accessToken) {
|
|
39
33
|
return {
|
|
@@ -59,7 +53,7 @@ export class GitHubSearchCodeTool implements ToolInterface {
|
|
|
59
53
|
});
|
|
60
54
|
|
|
61
55
|
if (response.status === 401 || response.status === 403) {
|
|
62
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
56
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
63
57
|
return {
|
|
64
58
|
data: {
|
|
65
59
|
error: '401',
|