@loopstack/github-module 0.2.3 → 0.2.5

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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/tools/users/github-get-authenticated-user.tool.d.ts +1 -1
  3. package/dist/tools/users/github-get-authenticated-user.tool.d.ts.map +1 -1
  4. package/dist/tools/users/github-get-authenticated-user.tool.js.map +1 -1
  5. package/package.json +6 -8
  6. package/src/github-oauth.provider.ts +0 -85
  7. package/src/github.module.ts +0 -63
  8. package/src/index.ts +0 -27
  9. package/src/tools/actions/github-get-workflow-run.tool.ts +0 -109
  10. package/src/tools/actions/github-list-workflow-runs.tool.ts +0 -132
  11. package/src/tools/actions/github-trigger-workflow.tool.ts +0 -89
  12. package/src/tools/content/github-create-or-update-file.tool.ts +0 -114
  13. package/src/tools/content/github-get-commit.tool.ts +0 -118
  14. package/src/tools/content/github-get-file-content.tool.ts +0 -105
  15. package/src/tools/content/github-list-directory.tool.ts +0 -98
  16. package/src/tools/issues/github-create-issue-comment.tool.ts +0 -93
  17. package/src/tools/issues/github-create-issue.tool.ts +0 -105
  18. package/src/tools/issues/github-get-issue.tool.ts +0 -109
  19. package/src/tools/issues/github-list-issues.tool.ts +0 -116
  20. package/src/tools/pull-requests/github-create-pull-request.tool.ts +0 -109
  21. package/src/tools/pull-requests/github-get-pull-request.tool.ts +0 -122
  22. package/src/tools/pull-requests/github-list-pr-reviews.tool.ts +0 -93
  23. package/src/tools/pull-requests/github-list-pull-requests.tool.ts +0 -115
  24. package/src/tools/pull-requests/github-merge-pull-request.tool.ts +0 -99
  25. package/src/tools/repos/github-create-repo.tool.ts +0 -104
  26. package/src/tools/repos/github-get-repo.tool.ts +0 -115
  27. package/src/tools/repos/github-list-branches.tool.ts +0 -91
  28. package/src/tools/repos/github-list-repos.tool.ts +0 -108
  29. package/src/tools/search/github-search-code.tool.ts +0 -99
  30. package/src/tools/search/github-search-issues.tool.ts +0 -113
  31. package/src/tools/search/github-search-repos.tool.ts +0 -108
  32. package/src/tools/users/github-get-authenticated-user.tool.ts +0 -96
  33. package/src/tools/users/github-list-user-orgs.tool.ts +0 -90
package/README.md CHANGED
@@ -139,7 +139,7 @@ See `@loopstack/oauth-module` and `@loopstack/github-oauth-example` for complete
139
139
 
140
140
  Author: [Jakob Klippel](https://www.linkedin.com/in/jakob-klippel/)
141
141
 
142
- License: Apache-2.0
142
+ License: MIT
143
143
 
144
144
  ### Additional Resources
145
145
 
@@ -5,7 +5,7 @@ export type GitHubGetAuthenticatedUserArgs = z.infer<typeof inputSchema>;
5
5
  export declare class GitHubGetAuthenticatedUserTool extends BaseTool {
6
6
  private readonly logger;
7
7
  private tokenStore;
8
- call(_args: GitHubGetAuthenticatedUserArgs): Promise<ToolResult>;
8
+ call(_args?: GitHubGetAuthenticatedUserArgs): Promise<ToolResult>;
9
9
  }
10
10
  export {};
11
11
  //# sourceMappingURL=github-get-authenticated-user.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"github-get-authenticated-user.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/users/github-get-authenticated-user.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAQ,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/D,QAAA,MAAM,WAAW,iCAAwB,CAAC;AAE1C,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzE,qBAOa,8BAA+B,SAAQ,QAAQ;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;IAG1E,OAAO,CAAC,UAAU,CAAkB;IAE9B,IAAI,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,UAAU,CAAC;CAyEvE"}
1
+ {"version":3,"file":"github-get-authenticated-user.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/users/github-get-authenticated-user.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAQ,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/D,QAAA,MAAM,WAAW,iCAAwB,CAAC;AAE1C,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzE,qBAOa,8BAA+B,SAAQ,QAAQ;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;IAG1E,OAAO,CAAC,UAAU,CAAkB;IAE9B,IAAI,CAAC,KAAK,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC,UAAU,CAAC;CAyExE"}
@@ -1 +1 @@
1
- {"version":3,"file":"github-get-authenticated-user.tool.js","sourceRoot":"","sources":["../../../src/tools/users/github-get-authenticated-user.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAA+D;AAC/D,0DAA0D;AAE1D,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAWnC,IAAM,8BAA8B,sCAApC,MAAM,8BAA+B,SAAQ,iBAAQ;IACzC,MAAM,GAAG,IAAI,eAAM,CAAC,gCAA8B,CAAC,IAAI,CAAC,CAAC;IAGlE,UAAU,CAAkB;IAEpC,KAAK,CAAC,IAAI,CAAC,KAAqC;QAC9C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEjG,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,cAAc;oBACrB,OAAO,EAAE,yDAAyD;iBACnE;aACF,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MA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GAAG;oBACb,WAAW,EAAE,IAAI,CAAC,YAAY;oBAC9B,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,SAAS,EAAE,IAAI,CAAC,UAAU;iBAC3B;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/EY,wEAA8B;AAIjC;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;kEAAC;yCAJzB,8BAA8B;IAP1C,IAAA,aAAI,EAAC;QACJ,QAAQ,EAAE;YACR,WAAW,EACT,gIAAgI;SACnI;QACD,MAAM,EAAE,WAAW;KACpB,CAAC;GACW,8BAA8B,CA+E1C"}
1
+ {"version":3,"file":"github-get-authenticated-user.tool.js","sourceRoot":"","sources":["../../../src/tools/users/github-get-authenticated-user.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAA+D;AAC/D,0DAA0D;AAE1D,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAWnC,IAAM,8BAA8B,sCAApC,MAAM,8BAA+B,SAAQ,iBAAQ;IACzC,MAAM,GAAG,IAAI,eAAM,CAAC,gCAA8B,CAAC,IAAI,CAAC,CAAC;IAGlE,UAAU,CAAkB;IAEpC,KAAK,CAAC,IAAI,CAAC,KAAsC;QAC/C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEjG,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,cAAc;oBACrB,OAAO,EAAE,yDAAyD;iBACnE;aACF,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,6BAA6B,EAAE;YAC1D,OAAO,EAAE;gBACP,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,EAAE,IAAI,CAAC,SAAS;oBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,SAAS,EAAE,IAAI,CAAC,UAAU;iBAC3B;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/EY,wEAA8B;AAIjC;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;kEAAC;yCAJzB,8BAA8B;IAP1C,IAAA,aAAI,EAAC;QACJ,QAAQ,EAAE;YACR,WAAW,EACT,gIAAgI;SACnI;QACD,MAAM,EAAE,WAAW;KACpB,CAAC;GACW,8BAA8B,CA+E1C"}
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  "module",
10
10
  "oauth"
11
11
  ],
12
- "version": "0.2.3",
13
- "license": "Apache-2.0",
12
+ "version": "0.2.5",
13
+ "license": "MIT",
14
14
  "author": {
15
15
  "name": "Jakob Klippel",
16
16
  "url": "https://www.linkedin.com/in/jakob-klippel/"
@@ -18,8 +18,7 @@
18
18
  "main": "dist/index.js",
19
19
  "types": "dist/index.d.ts",
20
20
  "exports": {
21
- ".": "./dist/index.js",
22
- "./src/*": "./src/*"
21
+ ".": "./dist/index.js"
23
22
  },
24
23
  "scripts": {
25
24
  "build": "nest build",
@@ -30,12 +29,12 @@
30
29
  "watch": "nest build --watch"
31
30
  },
32
31
  "dependencies": {
33
- "@loopstack/oauth-module": "^0.2.3",
32
+ "@loopstack/common": "^0.29.0",
33
+ "@loopstack/oauth-module": "^0.2.7",
34
34
  "zod": "^4.3.6"
35
35
  },
36
36
  "files": [
37
- "dist",
38
- "src"
37
+ "dist"
39
38
  ],
40
39
  "jest": {
41
40
  "moduleFileExtensions": [
@@ -74,7 +73,6 @@
74
73
  }
75
74
  ],
76
75
  "installModes": [
77
- "add",
78
76
  "install"
79
77
  ]
80
78
  }
@@ -1,85 +0,0 @@
1
- import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
2
- import { ConfigService } from '@nestjs/config';
3
- import { OAuthProviderInterface, OAuthProviderRegistry, OAuthTokenSet } from '@loopstack/oauth-module';
4
-
5
- @Injectable()
6
- export class GitHubOAuthProvider implements OAuthProviderInterface, OnModuleInit {
7
- private readonly logger = new Logger(GitHubOAuthProvider.name);
8
-
9
- readonly providerId = 'github';
10
- readonly defaultScopes = ['repo', 'user', 'workflow', 'read:org'];
11
-
12
- constructor(
13
- private readonly configService: ConfigService,
14
- private readonly providerRegistry: OAuthProviderRegistry,
15
- ) {}
16
-
17
- onModuleInit(): void {
18
- this.providerRegistry.register(this);
19
- this.logger.log('GitHub OAuth provider registered');
20
- }
21
-
22
- private get clientId(): string {
23
- const id = this.configService.get<string>('GITHUB_CLIENT_ID');
24
- if (!id) throw new Error('GITHUB_CLIENT_ID is not configured');
25
- return id;
26
- }
27
-
28
- private get clientSecret(): string {
29
- const secret = this.configService.get<string>('GITHUB_CLIENT_SECRET');
30
- if (!secret) throw new Error('GITHUB_CLIENT_SECRET is not configured');
31
- return secret;
32
- }
33
-
34
- private get redirectUri(): string {
35
- return this.configService.get<string>('GITHUB_OAUTH_REDIRECT_URI', '/oauth/callback');
36
- }
37
-
38
- buildAuthUrl(scopes: string[], state: string): string {
39
- const params = new URLSearchParams({
40
- client_id: this.clientId,
41
- redirect_uri: this.redirectUri,
42
- scope: scopes.join(' '),
43
- state,
44
- });
45
- return `https://github.com/login/oauth/authorize?${params.toString()}`;
46
- }
47
-
48
- async exchangeCode(code: string): Promise<OAuthTokenSet> {
49
- const response = await fetch('https://github.com/login/oauth/access_token', {
50
- method: 'POST',
51
- headers: {
52
- 'Content-Type': 'application/x-www-form-urlencoded',
53
- Accept: 'application/json',
54
- },
55
- body: new URLSearchParams({
56
- code,
57
- client_id: this.clientId,
58
- client_secret: this.clientSecret,
59
- redirect_uri: this.redirectUri,
60
- }),
61
- });
62
-
63
- if (!response.ok) {
64
- const errorBody = await response.text();
65
- this.logger.error(`Token exchange failed: ${response.status} ${errorBody}`);
66
- throw new Error(`GitHub token exchange failed: ${response.statusText}`);
67
- }
68
-
69
- const tokens = (await response.json()) as {
70
- access_token: string;
71
- token_type: string;
72
- scope: string;
73
- };
74
-
75
- return {
76
- accessToken: tokens.access_token,
77
- expiresIn: 315360000,
78
- scope: tokens.scope,
79
- };
80
- }
81
-
82
- refreshToken(): Promise<OAuthTokenSet> {
83
- throw new Error('GitHub tokens do not expire and cannot be refreshed.');
84
- }
85
- }
@@ -1,63 +0,0 @@
1
- import { Module } from '@nestjs/common';
2
- import { OAuthModule } from '@loopstack/oauth-module';
3
- import { GitHubOAuthProvider } from './github-oauth.provider';
4
- import { GitHubGetWorkflowRunTool } from './tools/actions/github-get-workflow-run.tool';
5
- import { GitHubListWorkflowRunsTool } from './tools/actions/github-list-workflow-runs.tool';
6
- import { GitHubTriggerWorkflowTool } from './tools/actions/github-trigger-workflow.tool';
7
- import { GitHubCreateOrUpdateFileTool } from './tools/content/github-create-or-update-file.tool';
8
- import { GitHubGetCommitTool } from './tools/content/github-get-commit.tool';
9
- import { GitHubGetFileContentTool } from './tools/content/github-get-file-content.tool';
10
- import { GitHubListDirectoryTool } from './tools/content/github-list-directory.tool';
11
- import { GitHubCreateIssueCommentTool } from './tools/issues/github-create-issue-comment.tool';
12
- import { GitHubCreateIssueTool } from './tools/issues/github-create-issue.tool';
13
- import { GitHubGetIssueTool } from './tools/issues/github-get-issue.tool';
14
- import { GitHubListIssuesTool } from './tools/issues/github-list-issues.tool';
15
- import { GitHubCreatePullRequestTool } from './tools/pull-requests/github-create-pull-request.tool';
16
- import { GitHubGetPullRequestTool } from './tools/pull-requests/github-get-pull-request.tool';
17
- import { GitHubListPrReviewsTool } from './tools/pull-requests/github-list-pr-reviews.tool';
18
- import { GitHubListPullRequestsTool } from './tools/pull-requests/github-list-pull-requests.tool';
19
- import { GitHubMergePullRequestTool } from './tools/pull-requests/github-merge-pull-request.tool';
20
- import { GitHubCreateRepoTool } from './tools/repos/github-create-repo.tool';
21
- import { GitHubGetRepoTool } from './tools/repos/github-get-repo.tool';
22
- import { GitHubListBranchesTool } from './tools/repos/github-list-branches.tool';
23
- import { GitHubListReposTool } from './tools/repos/github-list-repos.tool';
24
- import { GitHubSearchCodeTool } from './tools/search/github-search-code.tool';
25
- import { GitHubSearchIssuesTool } from './tools/search/github-search-issues.tool';
26
- import { GitHubSearchReposTool } from './tools/search/github-search-repos.tool';
27
- import { GitHubGetAuthenticatedUserTool } from './tools/users/github-get-authenticated-user.tool';
28
- import { GitHubListUserOrgsTool } from './tools/users/github-list-user-orgs.tool';
29
-
30
- const tools = [
31
- GitHubListReposTool,
32
- GitHubGetRepoTool,
33
- GitHubCreateRepoTool,
34
- GitHubListBranchesTool,
35
- GitHubListIssuesTool,
36
- GitHubGetIssueTool,
37
- GitHubCreateIssueTool,
38
- GitHubCreateIssueCommentTool,
39
- GitHubListPullRequestsTool,
40
- GitHubGetPullRequestTool,
41
- GitHubCreatePullRequestTool,
42
- GitHubMergePullRequestTool,
43
- GitHubListPrReviewsTool,
44
- GitHubGetFileContentTool,
45
- GitHubCreateOrUpdateFileTool,
46
- GitHubListDirectoryTool,
47
- GitHubGetCommitTool,
48
- GitHubListWorkflowRunsTool,
49
- GitHubTriggerWorkflowTool,
50
- GitHubGetWorkflowRunTool,
51
- GitHubSearchCodeTool,
52
- GitHubSearchReposTool,
53
- GitHubSearchIssuesTool,
54
- GitHubGetAuthenticatedUserTool,
55
- GitHubListUserOrgsTool,
56
- ];
57
-
58
- @Module({
59
- imports: [OAuthModule],
60
- providers: [GitHubOAuthProvider, ...tools],
61
- exports: [GitHubOAuthProvider, ...tools],
62
- })
63
- export class GitHubModule {}
package/src/index.ts DELETED
@@ -1,27 +0,0 @@
1
- export * from './github.module';
2
- export * from './github-oauth.provider';
3
- export * from './tools/repos/github-list-repos.tool';
4
- export * from './tools/repos/github-get-repo.tool';
5
- export * from './tools/repos/github-create-repo.tool';
6
- export * from './tools/repos/github-list-branches.tool';
7
- export * from './tools/issues/github-list-issues.tool';
8
- export * from './tools/issues/github-get-issue.tool';
9
- export * from './tools/issues/github-create-issue.tool';
10
- export * from './tools/issues/github-create-issue-comment.tool';
11
- export * from './tools/pull-requests/github-list-pull-requests.tool';
12
- export * from './tools/pull-requests/github-get-pull-request.tool';
13
- export * from './tools/pull-requests/github-create-pull-request.tool';
14
- export * from './tools/pull-requests/github-merge-pull-request.tool';
15
- export * from './tools/pull-requests/github-list-pr-reviews.tool';
16
- export * from './tools/content/github-get-file-content.tool';
17
- export * from './tools/content/github-create-or-update-file.tool';
18
- export * from './tools/content/github-list-directory.tool';
19
- export * from './tools/content/github-get-commit.tool';
20
- export * from './tools/actions/github-list-workflow-runs.tool';
21
- export * from './tools/actions/github-trigger-workflow.tool';
22
- export * from './tools/actions/github-get-workflow-run.tool';
23
- export * from './tools/search/github-search-code.tool';
24
- export * from './tools/search/github-search-repos.tool';
25
- export * from './tools/search/github-search-issues.tool';
26
- export * from './tools/users/github-get-authenticated-user.tool';
27
- export * from './tools/users/github-list-user-orgs.tool';
@@ -1,109 +0,0 @@
1
- import { Inject, Logger } from '@nestjs/common';
2
- import { z } from 'zod';
3
- import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
- import { OAuthTokenStore } from '@loopstack/oauth-module';
5
-
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>;
15
-
16
- @Tool({
17
- uiConfig: {
18
- description:
19
- 'Gets detailed information about a specific GitHub Actions workflow run. Returns { error: "unauthorized" } if no valid token is available.',
20
- },
21
- schema: inputSchema,
22
- })
23
- export class GitHubGetWorkflowRunTool extends BaseTool {
24
- private readonly logger = new Logger(GitHubGetWorkflowRunTool.name);
25
-
26
- @Inject()
27
- private tokenStore: OAuthTokenStore;
28
-
29
- async call(args: GitHubGetWorkflowRunArgs): Promise<ToolResult> {
30
- const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
31
-
32
- if (!accessToken) {
33
- return {
34
- data: {
35
- error: 'unauthorized',
36
- message: 'No valid GitHub token found. Please authenticate first.',
37
- },
38
- };
39
- }
40
-
41
- const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/actions/runs/${args.runId}`;
42
- const response = await fetch(url, {
43
- headers: {
44
- Authorization: `Bearer ${accessToken}`,
45
- Accept: 'application/vnd.github+json',
46
- 'X-GitHub-Api-Version': '2022-11-28',
47
- },
48
- });
49
-
50
- if (response.status === 401 || response.status === 403) {
51
- this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
52
- return {
53
- data: {
54
- error: '401',
55
- message: 'GitHub token was rejected. Please re-authenticate.',
56
- },
57
- };
58
- }
59
-
60
- if (!response.ok) {
61
- const body = await response.text();
62
- this.logger.error(`GitHub API error: ${response.status} ${body}`);
63
- return {
64
- data: {
65
- error: 'api_error',
66
- message: `GitHub API error: ${response.statusText}`,
67
- },
68
- };
69
- }
70
-
71
- const run = (await response.json()) as {
72
- id: number;
73
- name: string;
74
- status: string;
75
- conclusion: string | null;
76
- head_branch: string;
77
- head_sha: string;
78
- event: string;
79
- workflow_id: number;
80
- run_number: number;
81
- run_attempt: number;
82
- created_at: string;
83
- updated_at: string;
84
- run_started_at: string;
85
- html_url: string;
86
- };
87
-
88
- return {
89
- data: {
90
- run: {
91
- id: run.id,
92
- name: run.name,
93
- status: run.status,
94
- conclusion: run.conclusion,
95
- headBranch: run.head_branch,
96
- headSha: run.head_sha,
97
- event: run.event,
98
- workflowId: run.workflow_id,
99
- runNumber: run.run_number,
100
- runAttempt: run.run_attempt,
101
- createdAt: run.created_at,
102
- updatedAt: run.updated_at,
103
- runStartedAt: run.run_started_at,
104
- htmlUrl: run.html_url,
105
- },
106
- },
107
- };
108
- }
109
- }
@@ -1,132 +0,0 @@
1
- import { Inject, Logger } from '@nestjs/common';
2
- import { z } from 'zod';
3
- import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
- import { OAuthTokenStore } from '@loopstack/oauth-module';
5
-
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>;
35
-
36
- @Tool({
37
- uiConfig: {
38
- description:
39
- 'Lists workflow runs for a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
40
- },
41
- schema: inputSchema,
42
- })
43
- export class GitHubListWorkflowRunsTool extends BaseTool {
44
- private readonly logger = new Logger(GitHubListWorkflowRunsTool.name);
45
-
46
- @Inject()
47
- private tokenStore: OAuthTokenStore;
48
-
49
- async call(args: GitHubListWorkflowRunsArgs): Promise<ToolResult> {
50
- const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
51
-
52
- if (!accessToken) {
53
- return {
54
- data: {
55
- error: 'unauthorized',
56
- message: 'No valid GitHub token found. Please authenticate first.',
57
- },
58
- };
59
- }
60
-
61
- const params = new URLSearchParams({
62
- per_page: String(args.perPage ?? 30),
63
- page: String(args.page ?? 1),
64
- });
65
-
66
- if (args.branch) params.set('branch', args.branch);
67
- if (args.status) params.set('status', args.status);
68
-
69
- const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/actions/runs?${params.toString()}`;
70
- const response = await fetch(url, {
71
- headers: {
72
- Authorization: `Bearer ${accessToken}`,
73
- Accept: 'application/vnd.github+json',
74
- 'X-GitHub-Api-Version': '2022-11-28',
75
- },
76
- });
77
-
78
- if (response.status === 401 || response.status === 403) {
79
- this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
80
- return {
81
- data: {
82
- error: '401',
83
- message: 'GitHub token was rejected. Please re-authenticate.',
84
- },
85
- };
86
- }
87
-
88
- if (!response.ok) {
89
- const body = await response.text();
90
- this.logger.error(`GitHub API error: ${response.status} ${body}`);
91
- return {
92
- data: {
93
- error: 'api_error',
94
- message: `GitHub API error: ${response.statusText}`,
95
- },
96
- };
97
- }
98
-
99
- const data = (await response.json()) as {
100
- total_count: number;
101
- workflow_runs: Array<{
102
- id: number;
103
- name: string;
104
- status: string;
105
- conclusion: string | null;
106
- head_branch: string;
107
- head_sha: string;
108
- event: string;
109
- created_at: string;
110
- updated_at: string;
111
- html_url: string;
112
- }>;
113
- };
114
-
115
- const runs = data.workflow_runs.map((run) => ({
116
- id: run.id,
117
- name: run.name,
118
- status: run.status,
119
- conclusion: run.conclusion,
120
- headBranch: run.head_branch,
121
- headSha: run.head_sha,
122
- event: run.event,
123
- createdAt: run.created_at,
124
- updatedAt: run.updated_at,
125
- htmlUrl: run.html_url,
126
- }));
127
-
128
- return {
129
- data: { totalCount: data.total_count, runs },
130
- };
131
- }
132
- }
@@ -1,89 +0,0 @@
1
- import { Inject, Logger } from '@nestjs/common';
2
- import { z } from 'zod';
3
- import { BaseTool, Tool, ToolResult } from '@loopstack/common';
4
- import { OAuthTokenStore } from '@loopstack/oauth-module';
5
-
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>;
17
-
18
- @Tool({
19
- uiConfig: {
20
- description:
21
- 'Triggers a GitHub Actions workflow dispatch event. Returns 204 No Content on success. Returns { error: "unauthorized" } if no valid token is available.',
22
- },
23
- schema: inputSchema,
24
- })
25
- export class GitHubTriggerWorkflowTool extends BaseTool {
26
- private readonly logger = new Logger(GitHubTriggerWorkflowTool.name);
27
-
28
- @Inject()
29
- private tokenStore: OAuthTokenStore;
30
-
31
- async call(args: GitHubTriggerWorkflowArgs): Promise<ToolResult> {
32
- const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
33
-
34
- if (!accessToken) {
35
- return {
36
- data: {
37
- error: 'unauthorized',
38
- message: 'No valid GitHub token found. Please authenticate first.',
39
- },
40
- };
41
- }
42
-
43
- const requestBody: Record<string, unknown> = {
44
- ref: args.ref,
45
- };
46
-
47
- if (args.inputs) requestBody.inputs = args.inputs;
48
-
49
- const url = `https://api.github.com/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/actions/workflows/${encodeURIComponent(args.workflowId)}/dispatches`;
50
- const response = await fetch(url, {
51
- method: 'POST',
52
- headers: {
53
- Authorization: `Bearer ${accessToken}`,
54
- Accept: 'application/vnd.github+json',
55
- 'X-GitHub-Api-Version': '2022-11-28',
56
- 'Content-Type': 'application/json',
57
- },
58
- body: JSON.stringify(requestBody),
59
- });
60
-
61
- if (response.status === 401 || response.status === 403) {
62
- this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
63
- return {
64
- data: {
65
- error: '401',
66
- message: 'GitHub token was rejected. Please re-authenticate.',
67
- },
68
- };
69
- }
70
-
71
- if (!response.ok && response.status !== 204) {
72
- const body = await response.text();
73
- this.logger.error(`GitHub API error: ${response.status} ${body}`);
74
- return {
75
- data: {
76
- error: 'api_error',
77
- message: `GitHub API error: ${response.statusText}`,
78
- },
79
- };
80
- }
81
-
82
- return {
83
- data: {
84
- triggered: true,
85
- message: 'Workflow dispatch event triggered successfully.',
86
- },
87
- };
88
- }
89
- }