@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.
Files changed (126) hide show
  1. package/dist/tools/actions/github-get-workflow-run.tool.d.ts +11 -9
  2. package/dist/tools/actions/github-get-workflow-run.tool.d.ts.map +1 -1
  3. package/dist/tools/actions/github-get-workflow-run.tool.js +13 -18
  4. package/dist/tools/actions/github-get-workflow-run.tool.js.map +1 -1
  5. package/dist/tools/actions/github-list-workflow-runs.tool.d.ts +29 -12
  6. package/dist/tools/actions/github-list-workflow-runs.tool.d.ts.map +1 -1
  7. package/dist/tools/actions/github-list-workflow-runs.tool.js +33 -38
  8. package/dist/tools/actions/github-list-workflow-runs.tool.js.map +1 -1
  9. package/dist/tools/actions/github-trigger-workflow.tool.d.ts +13 -11
  10. package/dist/tools/actions/github-trigger-workflow.tool.d.ts.map +1 -1
  11. package/dist/tools/actions/github-trigger-workflow.tool.js +15 -20
  12. package/dist/tools/actions/github-trigger-workflow.tool.js.map +1 -1
  13. package/dist/tools/content/github-create-or-update-file.tool.d.ts +15 -13
  14. package/dist/tools/content/github-create-or-update-file.tool.d.ts.map +1 -1
  15. package/dist/tools/content/github-create-or-update-file.tool.js +17 -22
  16. package/dist/tools/content/github-create-or-update-file.tool.js.map +1 -1
  17. package/dist/tools/content/github-get-commit.tool.d.ts +11 -9
  18. package/dist/tools/content/github-get-commit.tool.d.ts.map +1 -1
  19. package/dist/tools/content/github-get-commit.tool.js +13 -18
  20. package/dist/tools/content/github-get-commit.tool.js.map +1 -1
  21. package/dist/tools/content/github-get-file-content.tool.d.ts +12 -10
  22. package/dist/tools/content/github-get-file-content.tool.d.ts.map +1 -1
  23. package/dist/tools/content/github-get-file-content.tool.js +14 -19
  24. package/dist/tools/content/github-get-file-content.tool.js.map +1 -1
  25. package/dist/tools/content/github-list-directory.tool.d.ts +12 -10
  26. package/dist/tools/content/github-list-directory.tool.d.ts.map +1 -1
  27. package/dist/tools/content/github-list-directory.tool.js +14 -19
  28. package/dist/tools/content/github-list-directory.tool.js.map +1 -1
  29. package/dist/tools/issues/github-create-issue-comment.tool.d.ts +12 -10
  30. package/dist/tools/issues/github-create-issue-comment.tool.d.ts.map +1 -1
  31. package/dist/tools/issues/github-create-issue-comment.tool.js +14 -19
  32. package/dist/tools/issues/github-create-issue-comment.tool.js.map +1 -1
  33. package/dist/tools/issues/github-create-issue.tool.d.ts +14 -12
  34. package/dist/tools/issues/github-create-issue.tool.d.ts.map +1 -1
  35. package/dist/tools/issues/github-create-issue.tool.js +16 -21
  36. package/dist/tools/issues/github-create-issue.tool.js.map +1 -1
  37. package/dist/tools/issues/github-get-issue.tool.d.ts +11 -9
  38. package/dist/tools/issues/github-get-issue.tool.d.ts.map +1 -1
  39. package/dist/tools/issues/github-get-issue.tool.js +13 -18
  40. package/dist/tools/issues/github-get-issue.tool.js.map +1 -1
  41. package/dist/tools/issues/github-list-issues.tool.d.ts +19 -13
  42. package/dist/tools/issues/github-list-issues.tool.d.ts.map +1 -1
  43. package/dist/tools/issues/github-list-issues.tool.js +17 -22
  44. package/dist/tools/issues/github-list-issues.tool.js.map +1 -1
  45. package/dist/tools/pull-requests/github-create-pull-request.tool.d.ts +15 -13
  46. package/dist/tools/pull-requests/github-create-pull-request.tool.d.ts.map +1 -1
  47. package/dist/tools/pull-requests/github-create-pull-request.tool.js +17 -22
  48. package/dist/tools/pull-requests/github-create-pull-request.tool.js.map +1 -1
  49. package/dist/tools/pull-requests/github-get-pull-request.tool.d.ts +11 -9
  50. package/dist/tools/pull-requests/github-get-pull-request.tool.d.ts.map +1 -1
  51. package/dist/tools/pull-requests/github-get-pull-request.tool.js +13 -18
  52. package/dist/tools/pull-requests/github-get-pull-request.tool.js.map +1 -1
  53. package/dist/tools/pull-requests/github-list-pr-reviews.tool.d.ts +11 -9
  54. package/dist/tools/pull-requests/github-list-pr-reviews.tool.d.ts.map +1 -1
  55. package/dist/tools/pull-requests/github-list-pr-reviews.tool.js +13 -18
  56. package/dist/tools/pull-requests/github-list-pr-reviews.tool.js.map +1 -1
  57. package/dist/tools/pull-requests/github-list-pull-requests.tool.d.ts +18 -12
  58. package/dist/tools/pull-requests/github-list-pull-requests.tool.d.ts.map +1 -1
  59. package/dist/tools/pull-requests/github-list-pull-requests.tool.js +16 -21
  60. package/dist/tools/pull-requests/github-list-pull-requests.tool.js.map +1 -1
  61. package/dist/tools/pull-requests/github-merge-pull-request.tool.d.ts +18 -12
  62. package/dist/tools/pull-requests/github-merge-pull-request.tool.d.ts.map +1 -1
  63. package/dist/tools/pull-requests/github-merge-pull-request.tool.js +16 -21
  64. package/dist/tools/pull-requests/github-merge-pull-request.tool.js.map +1 -1
  65. package/dist/tools/repos/github-create-repo.tool.d.ts +12 -10
  66. package/dist/tools/repos/github-create-repo.tool.d.ts.map +1 -1
  67. package/dist/tools/repos/github-create-repo.tool.js +14 -19
  68. package/dist/tools/repos/github-create-repo.tool.js.map +1 -1
  69. package/dist/tools/repos/github-get-repo.tool.d.ts +10 -8
  70. package/dist/tools/repos/github-get-repo.tool.d.ts.map +1 -1
  71. package/dist/tools/repos/github-get-repo.tool.js +12 -17
  72. package/dist/tools/repos/github-get-repo.tool.js.map +1 -1
  73. package/dist/tools/repos/github-list-branches.tool.d.ts +11 -9
  74. package/dist/tools/repos/github-list-branches.tool.d.ts.map +1 -1
  75. package/dist/tools/repos/github-list-branches.tool.js +13 -18
  76. package/dist/tools/repos/github-list-branches.tool.js.map +1 -1
  77. package/dist/tools/repos/github-list-repos.tool.d.ts +21 -10
  78. package/dist/tools/repos/github-list-repos.tool.d.ts.map +1 -1
  79. package/dist/tools/repos/github-list-repos.tool.js +14 -19
  80. package/dist/tools/repos/github-list-repos.tool.js.map +1 -1
  81. package/dist/tools/search/github-search-code.tool.d.ts +11 -9
  82. package/dist/tools/search/github-search-code.tool.d.ts.map +1 -1
  83. package/dist/tools/search/github-search-code.tool.js +13 -18
  84. package/dist/tools/search/github-search-code.tool.js.map +1 -1
  85. package/dist/tools/search/github-search-issues.tool.d.ts +20 -10
  86. package/dist/tools/search/github-search-issues.tool.d.ts.map +1 -1
  87. package/dist/tools/search/github-search-issues.tool.js +16 -21
  88. package/dist/tools/search/github-search-issues.tool.js.map +1 -1
  89. package/dist/tools/search/github-search-repos.tool.d.ts +17 -10
  90. package/dist/tools/search/github-search-repos.tool.d.ts.map +1 -1
  91. package/dist/tools/search/github-search-repos.tool.js +14 -19
  92. package/dist/tools/search/github-search-repos.tool.js.map +1 -1
  93. package/dist/tools/users/github-get-authenticated-user.tool.d.ts +7 -5
  94. package/dist/tools/users/github-get-authenticated-user.tool.d.ts.map +1 -1
  95. package/dist/tools/users/github-get-authenticated-user.tool.js +7 -12
  96. package/dist/tools/users/github-get-authenticated-user.tool.js.map +1 -1
  97. package/dist/tools/users/github-list-user-orgs.tool.d.ts +9 -7
  98. package/dist/tools/users/github-list-user-orgs.tool.d.ts.map +1 -1
  99. package/dist/tools/users/github-list-user-orgs.tool.js +11 -16
  100. package/dist/tools/users/github-list-user-orgs.tool.js.map +1 -1
  101. package/package.json +2 -2
  102. package/src/tools/actions/github-get-workflow-run.tool.ts +16 -22
  103. package/src/tools/actions/github-list-workflow-runs.tool.ts +36 -45
  104. package/src/tools/actions/github-trigger-workflow.tool.ts +18 -26
  105. package/src/tools/content/github-create-or-update-file.tool.ts +20 -30
  106. package/src/tools/content/github-get-commit.tool.ts +16 -22
  107. package/src/tools/content/github-get-file-content.tool.ts +17 -24
  108. package/src/tools/content/github-list-directory.tool.ts +17 -24
  109. package/src/tools/issues/github-create-issue-comment.tool.ts +17 -24
  110. package/src/tools/issues/github-create-issue.tool.ts +19 -28
  111. package/src/tools/issues/github-get-issue.tool.ts +16 -22
  112. package/src/tools/issues/github-list-issues.tool.ts +20 -30
  113. package/src/tools/pull-requests/github-create-pull-request.tool.ts +20 -30
  114. package/src/tools/pull-requests/github-get-pull-request.tool.ts +16 -22
  115. package/src/tools/pull-requests/github-list-pr-reviews.tool.ts +16 -22
  116. package/src/tools/pull-requests/github-list-pull-requests.tool.ts +19 -28
  117. package/src/tools/pull-requests/github-merge-pull-request.tool.ts +19 -28
  118. package/src/tools/repos/github-create-repo.tool.ts +17 -24
  119. package/src/tools/repos/github-get-repo.tool.ts +15 -20
  120. package/src/tools/repos/github-list-branches.tool.ts +16 -22
  121. package/src/tools/repos/github-list-repos.tool.ts +17 -24
  122. package/src/tools/search/github-search-code.tool.ts +16 -22
  123. package/src/tools/search/github-search-issues.tool.ts +19 -26
  124. package/src/tools/search/github-search-repos.tool.ts +17 -24
  125. package/src/tools/users/github-get-authenticated-user.tool.ts +10 -12
  126. package/src/tools/users/github-list-user-orgs.tool.ts +14 -18
@@ -1,43 +1,35 @@
1
1
  import { Inject, Logger } from '@nestjs/common';
2
2
  import { z } from 'zod';
3
- import { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubTriggerWorkflowArgs = {
7
- owner: string;
8
- repo: string;
9
- workflowId: string;
10
- ref: string;
11
- inputs?: Record<string, string>;
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
- config: {
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 implements ToolInterface {
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
- @Input({
27
- schema: z
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 { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubCreateOrUpdateFileArgs = {
7
- owner: string;
8
- repo: string;
9
- path: string;
10
- content: string;
11
- message: string;
12
- sha?: string;
13
- branch?: string;
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
- config: {
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 implements ToolInterface {
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
- @Input({
29
- schema: z
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 { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubGetCommitArgs = {
7
- owner: string;
8
- repo: string;
9
- ref: string;
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
- config: {
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 implements ToolInterface {
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
- @Input({
25
- schema: z
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 { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubGetFileContentArgs = {
7
- owner: string;
8
- repo: string;
9
- path: string;
10
- ref?: string;
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
- config: {
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 implements ToolInterface {
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
- @Input({
26
- schema: z
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 { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubListDirectoryArgs = {
7
- owner: string;
8
- repo: string;
9
- path?: string;
10
- ref?: string;
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
- config: {
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 implements ToolInterface {
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
- @Input({
26
- schema: z
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 { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubCreateIssueCommentArgs = {
7
- owner: string;
8
- repo: string;
9
- issueNumber: number;
10
- body: string;
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
- config: {
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 implements ToolInterface {
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
- @Input({
26
- schema: z
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 { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubCreateIssueArgs = {
7
- owner: string;
8
- repo: string;
9
- title: string;
10
- body?: string;
11
- labels?: string[];
12
- assignees?: string[];
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
- config: {
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 implements ToolInterface {
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
- @Input({
28
- schema: z
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',
@@ -1,39 +1,33 @@
1
1
  import { Inject, Logger } from '@nestjs/common';
2
2
  import { z } from 'zod';
3
- import { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubGetIssueArgs = {
7
- owner: string;
8
- repo: string;
9
- issueNumber: number;
10
- };
6
+ const inputSchema = z
7
+ .object({
8
+ owner: z.string(),
9
+ repo: z.string(),
10
+ issueNumber: z.number(),
11
+ })
12
+ .strict();
13
+
14
+ export type GitHubGetIssueArgs = z.infer<typeof inputSchema>;
11
15
 
12
16
  @Tool({
13
- config: {
17
+ uiConfig: {
14
18
  description:
15
19
  'Gets detailed information about a specific GitHub issue. Returns { error: "unauthorized" } if no valid token is available.',
16
20
  },
21
+ schema: inputSchema,
17
22
  })
18
- export class GitHubGetIssueTool implements ToolInterface {
23
+ export class GitHubGetIssueTool extends BaseTool {
19
24
  private readonly logger = new Logger(GitHubGetIssueTool.name);
20
25
 
21
26
  @Inject()
22
27
  private tokenStore: OAuthTokenStore;
23
28
 
24
- @Input({
25
- schema: z
26
- .object({
27
- owner: z.string(),
28
- repo: z.string(),
29
- issueNumber: z.number(),
30
- })
31
- .strict(),
32
- })
33
- args: GitHubGetIssueArgs;
34
-
35
- async execute(args: GitHubGetIssueArgs, ctx: RunContext): Promise<ToolResult> {
36
- const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
29
+ async call(args: GitHubGetIssueArgs): 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 GitHubGetIssueTool 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,47 +1,37 @@
1
1
  import { Inject, Logger } from '@nestjs/common';
2
2
  import { z } from 'zod';
3
- import { Input, RunContext, Tool, ToolInterface, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
4
  import { OAuthTokenStore } from '@loopstack/oauth-module';
5
5
 
6
- export type GitHubListIssuesArgs = {
7
- owner: string;
8
- repo: string;
9
- state?: string;
10
- labels?: string;
11
- assignee?: string;
12
- perPage?: number;
13
- page?: number;
14
- };
6
+ const inputSchema = z
7
+ .object({
8
+ owner: z.string(),
9
+ repo: z.string(),
10
+ state: z.enum(['open', 'closed', 'all']).default('open'),
11
+ labels: z.string().optional(),
12
+ assignee: z.string().optional(),
13
+ perPage: z.number().default(30),
14
+ page: z.number().default(1),
15
+ })
16
+ .strict();
17
+
18
+ export type GitHubListIssuesArgs = z.input<typeof inputSchema>;
15
19
 
16
20
  @Tool({
17
- config: {
21
+ uiConfig: {
18
22
  description:
19
23
  'Lists issues for a GitHub repository. Note: the GitHub API returns both issues and pull requests; pull requests have a pull_request key. Returns { error: "unauthorized" } if no valid token is available.',
20
24
  },
25
+ schema: inputSchema,
21
26
  })
22
- export class GitHubListIssuesTool implements ToolInterface {
27
+ export class GitHubListIssuesTool extends BaseTool {
23
28
  private readonly logger = new Logger(GitHubListIssuesTool.name);
24
29
 
25
30
  @Inject()
26
31
  private tokenStore: OAuthTokenStore;
27
32
 
28
- @Input({
29
- schema: z
30
- .object({
31
- owner: z.string(),
32
- repo: z.string(),
33
- state: z.enum(['open', 'closed', 'all']).default('open'),
34
- labels: z.string().optional(),
35
- assignee: z.string().optional(),
36
- perPage: z.number().default(30),
37
- page: z.number().default(1),
38
- })
39
- .strict(),
40
- })
41
- args: GitHubListIssuesArgs;
42
-
43
- async execute(args: GitHubListIssuesArgs, ctx: RunContext): Promise<ToolResult> {
44
- const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
33
+ async call(args: GitHubListIssuesArgs): Promise<ToolResult> {
34
+ const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
45
35
 
46
36
  if (!accessToken) {
47
37
  return {
@@ -71,7 +61,7 @@ export class GitHubListIssuesTool implements ToolInterface {
71
61
  });
72
62
 
73
63
  if (response.status === 401 || response.status === 403) {
74
- this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
64
+ this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
75
65
  return {
76
66
  data: {
77
67
  error: '401',