@loopstack/github-module 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -5
- 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,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
|
+
runId: z.number(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
|
|
14
|
+
export type GitHubGetWorkflowRunArgs = z.infer<typeof inputSchema>;
|
|
11
15
|
|
|
12
16
|
@Tool({
|
|
13
|
-
|
|
17
|
+
uiConfig: {
|
|
14
18
|
description:
|
|
15
19
|
'Gets detailed information about a specific GitHub Actions workflow run. Returns { error: "unauthorized" } if no valid token is available.',
|
|
16
20
|
},
|
|
21
|
+
schema: inputSchema,
|
|
17
22
|
})
|
|
18
|
-
export class GitHubGetWorkflowRunTool
|
|
23
|
+
export class GitHubGetWorkflowRunTool extends BaseTool {
|
|
19
24
|
private readonly logger = new Logger(GitHubGetWorkflowRunTool.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
|
-
runId: z.number(),
|
|
30
|
-
})
|
|
31
|
-
.strict(),
|
|
32
|
-
})
|
|
33
|
-
args: GitHubGetWorkflowRunArgs;
|
|
34
|
-
|
|
35
|
-
async execute(args: GitHubGetWorkflowRunArgs, ctx: RunContext): Promise<ToolResult> {
|
|
36
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
29
|
+
async call(args: GitHubGetWorkflowRunArgs): 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 GitHubGetWorkflowRunTool 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,62 +1,53 @@
|
|
|
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
|
+
branch: z.string().optional(),
|
|
11
|
+
status: z
|
|
12
|
+
.enum([
|
|
13
|
+
'completed',
|
|
14
|
+
'action_required',
|
|
15
|
+
'cancelled',
|
|
16
|
+
'failure',
|
|
17
|
+
'neutral',
|
|
18
|
+
'skipped',
|
|
19
|
+
'stale',
|
|
20
|
+
'success',
|
|
21
|
+
'timed_out',
|
|
22
|
+
'in_progress',
|
|
23
|
+
'queued',
|
|
24
|
+
'requested',
|
|
25
|
+
'waiting',
|
|
26
|
+
'pending',
|
|
27
|
+
])
|
|
28
|
+
.optional(),
|
|
29
|
+
perPage: z.number().default(30),
|
|
30
|
+
page: z.number().default(1),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
|
|
34
|
+
export type GitHubListWorkflowRunsArgs = z.input<typeof inputSchema>;
|
|
14
35
|
|
|
15
36
|
@Tool({
|
|
16
|
-
|
|
37
|
+
uiConfig: {
|
|
17
38
|
description:
|
|
18
39
|
'Lists workflow runs for a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
19
40
|
},
|
|
41
|
+
schema: inputSchema,
|
|
20
42
|
})
|
|
21
|
-
export class GitHubListWorkflowRunsTool
|
|
43
|
+
export class GitHubListWorkflowRunsTool extends BaseTool {
|
|
22
44
|
private readonly logger = new Logger(GitHubListWorkflowRunsTool.name);
|
|
23
45
|
|
|
24
46
|
@Inject()
|
|
25
47
|
private tokenStore: OAuthTokenStore;
|
|
26
48
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.object({
|
|
30
|
-
owner: z.string(),
|
|
31
|
-
repo: z.string(),
|
|
32
|
-
branch: z.string().optional(),
|
|
33
|
-
status: z
|
|
34
|
-
.enum([
|
|
35
|
-
'completed',
|
|
36
|
-
'action_required',
|
|
37
|
-
'cancelled',
|
|
38
|
-
'failure',
|
|
39
|
-
'neutral',
|
|
40
|
-
'skipped',
|
|
41
|
-
'stale',
|
|
42
|
-
'success',
|
|
43
|
-
'timed_out',
|
|
44
|
-
'in_progress',
|
|
45
|
-
'queued',
|
|
46
|
-
'requested',
|
|
47
|
-
'waiting',
|
|
48
|
-
'pending',
|
|
49
|
-
])
|
|
50
|
-
.optional(),
|
|
51
|
-
perPage: z.number().default(30),
|
|
52
|
-
page: z.number().default(1),
|
|
53
|
-
})
|
|
54
|
-
.strict(),
|
|
55
|
-
})
|
|
56
|
-
args: GitHubListWorkflowRunsArgs;
|
|
57
|
-
|
|
58
|
-
async execute(args: GitHubListWorkflowRunsArgs, ctx: RunContext): Promise<ToolResult> {
|
|
59
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
49
|
+
async call(args: GitHubListWorkflowRunsArgs): Promise<ToolResult> {
|
|
50
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
60
51
|
|
|
61
52
|
if (!accessToken) {
|
|
62
53
|
return {
|
|
@@ -85,7 +76,7 @@ export class GitHubListWorkflowRunsTool implements ToolInterface {
|
|
|
85
76
|
});
|
|
86
77
|
|
|
87
78
|
if (response.status === 401 || response.status === 403) {
|
|
88
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
79
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
89
80
|
return {
|
|
90
81
|
data: {
|
|
91
82
|
error: '401',
|
|
@@ -1,43 +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
|
-
|
|
6
|
+
const inputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
workflowId: z.string(),
|
|
11
|
+
ref: z.string(),
|
|
12
|
+
inputs: z.record(z.string(), z.string()).optional(),
|
|
13
|
+
})
|
|
14
|
+
.strict();
|
|
15
|
+
|
|
16
|
+
export type GitHubTriggerWorkflowArgs = z.infer<typeof inputSchema>;
|
|
13
17
|
|
|
14
18
|
@Tool({
|
|
15
|
-
|
|
19
|
+
uiConfig: {
|
|
16
20
|
description:
|
|
17
21
|
'Triggers a GitHub Actions workflow dispatch event. Returns 204 No Content on success. Returns { error: "unauthorized" } if no valid token is available.',
|
|
18
22
|
},
|
|
23
|
+
schema: inputSchema,
|
|
19
24
|
})
|
|
20
|
-
export class GitHubTriggerWorkflowTool
|
|
25
|
+
export class GitHubTriggerWorkflowTool extends BaseTool {
|
|
21
26
|
private readonly logger = new Logger(GitHubTriggerWorkflowTool.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
|
-
workflowId: z.string(),
|
|
32
|
-
ref: z.string(),
|
|
33
|
-
inputs: z.record(z.string(), z.string()).optional(),
|
|
34
|
-
})
|
|
35
|
-
.strict(),
|
|
36
|
-
})
|
|
37
|
-
args: GitHubTriggerWorkflowArgs;
|
|
38
|
-
|
|
39
|
-
async execute(args: GitHubTriggerWorkflowArgs, ctx: RunContext): Promise<ToolResult> {
|
|
40
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
31
|
+
async call(args: GitHubTriggerWorkflowArgs): Promise<ToolResult> {
|
|
32
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
41
33
|
|
|
42
34
|
if (!accessToken) {
|
|
43
35
|
return {
|
|
@@ -67,7 +59,7 @@ export class GitHubTriggerWorkflowTool implements ToolInterface {
|
|
|
67
59
|
});
|
|
68
60
|
|
|
69
61
|
if (response.status === 401 || response.status === 403) {
|
|
70
|
-
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}`);
|
|
71
63
|
return {
|
|
72
64
|
data: {
|
|
73
65
|
error: '401',
|
|
@@ -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
|
+
path: z.string(),
|
|
11
|
+
content: z.string(),
|
|
12
|
+
message: z.string(),
|
|
13
|
+
sha: z.string().optional(),
|
|
14
|
+
branch: z.string().optional(),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
|
|
18
|
+
export type GitHubCreateOrUpdateFileArgs = z.infer<typeof inputSchema>;
|
|
15
19
|
|
|
16
20
|
@Tool({
|
|
17
|
-
|
|
21
|
+
uiConfig: {
|
|
18
22
|
description:
|
|
19
23
|
'Creates or updates a file in a GitHub repository. Content is provided as plain text and encoded to base64 before sending. To update an existing file, provide the sha of the file being replaced. Returns { error: "unauthorized" } if no valid token is available.',
|
|
20
24
|
},
|
|
25
|
+
schema: inputSchema,
|
|
21
26
|
})
|
|
22
|
-
export class GitHubCreateOrUpdateFileTool
|
|
27
|
+
export class GitHubCreateOrUpdateFileTool extends BaseTool {
|
|
23
28
|
private readonly logger = new Logger(GitHubCreateOrUpdateFileTool.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
|
-
path: z.string(),
|
|
34
|
-
content: z.string(),
|
|
35
|
-
message: z.string(),
|
|
36
|
-
sha: z.string().optional(),
|
|
37
|
-
branch: z.string().optional(),
|
|
38
|
-
})
|
|
39
|
-
.strict(),
|
|
40
|
-
})
|
|
41
|
-
args: GitHubCreateOrUpdateFileArgs;
|
|
42
|
-
|
|
43
|
-
async execute(args: GitHubCreateOrUpdateFileArgs, ctx: RunContext): Promise<ToolResult> {
|
|
44
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
33
|
+
async call(args: GitHubCreateOrUpdateFileArgs): Promise<ToolResult> {
|
|
34
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
45
35
|
|
|
46
36
|
if (!accessToken) {
|
|
47
37
|
return {
|
|
@@ -73,7 +63,7 @@ export class GitHubCreateOrUpdateFileTool implements ToolInterface {
|
|
|
73
63
|
});
|
|
74
64
|
|
|
75
65
|
if (response.status === 401 || response.status === 403) {
|
|
76
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
66
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
77
67
|
return {
|
|
78
68
|
data: {
|
|
79
69
|
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
|
+
ref: z.string(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
|
|
14
|
+
export type GitHubGetCommitArgs = z.infer<typeof inputSchema>;
|
|
11
15
|
|
|
12
16
|
@Tool({
|
|
13
|
-
|
|
17
|
+
uiConfig: {
|
|
14
18
|
description:
|
|
15
19
|
'Gets detailed information about a specific commit in a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
16
20
|
},
|
|
21
|
+
schema: inputSchema,
|
|
17
22
|
})
|
|
18
|
-
export class GitHubGetCommitTool
|
|
23
|
+
export class GitHubGetCommitTool extends BaseTool {
|
|
19
24
|
private readonly logger = new Logger(GitHubGetCommitTool.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
|
-
ref: z.string(),
|
|
30
|
-
})
|
|
31
|
-
.strict(),
|
|
32
|
-
})
|
|
33
|
-
args: GitHubGetCommitArgs;
|
|
34
|
-
|
|
35
|
-
async execute(args: GitHubGetCommitArgs, ctx: RunContext): Promise<ToolResult> {
|
|
36
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
29
|
+
async call(args: GitHubGetCommitArgs): 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 GitHubGetCommitTool 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,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
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
path: z.string(),
|
|
11
|
+
ref: z.string().optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
|
|
15
|
+
export type GitHubGetFileContentArgs = z.infer<typeof inputSchema>;
|
|
12
16
|
|
|
13
17
|
@Tool({
|
|
14
|
-
|
|
18
|
+
uiConfig: {
|
|
15
19
|
description:
|
|
16
20
|
'Gets the content of a file from a GitHub repository. Decodes base64-encoded content from the API. Returns { error: "unauthorized" } if no valid token is available.',
|
|
17
21
|
},
|
|
22
|
+
schema: inputSchema,
|
|
18
23
|
})
|
|
19
|
-
export class GitHubGetFileContentTool
|
|
24
|
+
export class GitHubGetFileContentTool extends BaseTool {
|
|
20
25
|
private readonly logger = new Logger(GitHubGetFileContentTool.name);
|
|
21
26
|
|
|
22
27
|
@Inject()
|
|
23
28
|
private tokenStore: OAuthTokenStore;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.object({
|
|
28
|
-
owner: z.string(),
|
|
29
|
-
repo: z.string(),
|
|
30
|
-
path: z.string(),
|
|
31
|
-
ref: z.string().optional(),
|
|
32
|
-
})
|
|
33
|
-
.strict(),
|
|
34
|
-
})
|
|
35
|
-
args: GitHubGetFileContentArgs;
|
|
36
|
-
|
|
37
|
-
async execute(args: GitHubGetFileContentArgs, ctx: RunContext): Promise<ToolResult> {
|
|
38
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
30
|
+
async call(args: GitHubGetFileContentArgs): Promise<ToolResult> {
|
|
31
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
39
32
|
|
|
40
33
|
if (!accessToken) {
|
|
41
34
|
return {
|
|
@@ -59,7 +52,7 @@ export class GitHubGetFileContentTool implements ToolInterface {
|
|
|
59
52
|
});
|
|
60
53
|
|
|
61
54
|
if (response.status === 401 || response.status === 403) {
|
|
62
|
-
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}`);
|
|
63
56
|
return {
|
|
64
57
|
data: {
|
|
65
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
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
path: z.string().default(''),
|
|
11
|
+
ref: z.string().optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
|
|
15
|
+
export type GitHubListDirectoryArgs = z.input<typeof inputSchema>;
|
|
12
16
|
|
|
13
17
|
@Tool({
|
|
14
|
-
|
|
18
|
+
uiConfig: {
|
|
15
19
|
description:
|
|
16
20
|
'Lists the contents of a directory in a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
17
21
|
},
|
|
22
|
+
schema: inputSchema,
|
|
18
23
|
})
|
|
19
|
-
export class GitHubListDirectoryTool
|
|
24
|
+
export class GitHubListDirectoryTool extends BaseTool {
|
|
20
25
|
private readonly logger = new Logger(GitHubListDirectoryTool.name);
|
|
21
26
|
|
|
22
27
|
@Inject()
|
|
23
28
|
private tokenStore: OAuthTokenStore;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.object({
|
|
28
|
-
owner: z.string(),
|
|
29
|
-
repo: z.string(),
|
|
30
|
-
path: z.string().default(''),
|
|
31
|
-
ref: z.string().optional(),
|
|
32
|
-
})
|
|
33
|
-
.strict(),
|
|
34
|
-
})
|
|
35
|
-
args: GitHubListDirectoryArgs;
|
|
36
|
-
|
|
37
|
-
async execute(args: GitHubListDirectoryArgs, ctx: RunContext): Promise<ToolResult> {
|
|
38
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
30
|
+
async call(args: GitHubListDirectoryArgs): Promise<ToolResult> {
|
|
31
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
39
32
|
|
|
40
33
|
if (!accessToken) {
|
|
41
34
|
return {
|
|
@@ -60,7 +53,7 @@ export class GitHubListDirectoryTool implements ToolInterface {
|
|
|
60
53
|
});
|
|
61
54
|
|
|
62
55
|
if (response.status === 401 || response.status === 403) {
|
|
63
|
-
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}`);
|
|
64
57
|
return {
|
|
65
58
|
data: {
|
|
66
59
|
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
|
+
owner: z.string(),
|
|
9
|
+
repo: z.string(),
|
|
10
|
+
issueNumber: z.number(),
|
|
11
|
+
body: z.string(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
|
|
15
|
+
export type GitHubCreateIssueCommentArgs = z.infer<typeof inputSchema>;
|
|
12
16
|
|
|
13
17
|
@Tool({
|
|
14
|
-
|
|
18
|
+
uiConfig: {
|
|
15
19
|
description:
|
|
16
20
|
'Creates a comment on a GitHub issue or pull request. Returns { error: "unauthorized" } if no valid token is available.',
|
|
17
21
|
},
|
|
22
|
+
schema: inputSchema,
|
|
18
23
|
})
|
|
19
|
-
export class GitHubCreateIssueCommentTool
|
|
24
|
+
export class GitHubCreateIssueCommentTool extends BaseTool {
|
|
20
25
|
private readonly logger = new Logger(GitHubCreateIssueCommentTool.name);
|
|
21
26
|
|
|
22
27
|
@Inject()
|
|
23
28
|
private tokenStore: OAuthTokenStore;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.object({
|
|
28
|
-
owner: z.string(),
|
|
29
|
-
repo: z.string(),
|
|
30
|
-
issueNumber: z.number(),
|
|
31
|
-
body: z.string(),
|
|
32
|
-
})
|
|
33
|
-
.strict(),
|
|
34
|
-
})
|
|
35
|
-
args: GitHubCreateIssueCommentArgs;
|
|
36
|
-
|
|
37
|
-
async execute(args: GitHubCreateIssueCommentArgs, ctx: RunContext): Promise<ToolResult> {
|
|
38
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
30
|
+
async call(args: GitHubCreateIssueCommentArgs): Promise<ToolResult> {
|
|
31
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
39
32
|
|
|
40
33
|
if (!accessToken) {
|
|
41
34
|
return {
|
|
@@ -59,7 +52,7 @@ export class GitHubCreateIssueCommentTool implements ToolInterface {
|
|
|
59
52
|
});
|
|
60
53
|
|
|
61
54
|
if (response.status === 401 || response.status === 403) {
|
|
62
|
-
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}`);
|
|
63
56
|
return {
|
|
64
57
|
data: {
|
|
65
58
|
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
|
+
title: z.string(),
|
|
11
|
+
body: z.string().optional(),
|
|
12
|
+
labels: z.array(z.string()).optional(),
|
|
13
|
+
assignees: z.array(z.string()).optional(),
|
|
14
|
+
})
|
|
15
|
+
.strict();
|
|
16
|
+
|
|
17
|
+
export type GitHubCreateIssueArgs = z.infer<typeof inputSchema>;
|
|
14
18
|
|
|
15
19
|
@Tool({
|
|
16
|
-
|
|
20
|
+
uiConfig: {
|
|
17
21
|
description:
|
|
18
22
|
'Creates a new issue in a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
19
23
|
},
|
|
24
|
+
schema: inputSchema,
|
|
20
25
|
})
|
|
21
|
-
export class GitHubCreateIssueTool
|
|
26
|
+
export class GitHubCreateIssueTool extends BaseTool {
|
|
22
27
|
private readonly logger = new Logger(GitHubCreateIssueTool.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
|
-
title: z.string(),
|
|
33
|
-
body: z.string().optional(),
|
|
34
|
-
labels: z.array(z.string()).optional(),
|
|
35
|
-
assignees: z.array(z.string()).optional(),
|
|
36
|
-
})
|
|
37
|
-
.strict(),
|
|
38
|
-
})
|
|
39
|
-
args: GitHubCreateIssueArgs;
|
|
40
|
-
|
|
41
|
-
async execute(args: GitHubCreateIssueArgs, ctx: RunContext): Promise<ToolResult> {
|
|
42
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
32
|
+
async call(args: GitHubCreateIssueArgs): Promise<ToolResult> {
|
|
33
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
43
34
|
|
|
44
35
|
if (!accessToken) {
|
|
45
36
|
return {
|
|
@@ -71,7 +62,7 @@ export class GitHubCreateIssueTool implements ToolInterface {
|
|
|
71
62
|
});
|
|
72
63
|
|
|
73
64
|
if (response.status === 401 || response.status === 403) {
|
|
74
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
65
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
75
66
|
return {
|
|
76
67
|
data: {
|
|
77
68
|
error: '401',
|