@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
package/README.md
CHANGED
|
@@ -1,16 +1,54 @@
|
|
|
1
1
|
# @loopstack/github-module
|
|
2
2
|
|
|
3
|
-
GitHub integration for the Loopstack automation framework.
|
|
3
|
+
> GitHub integration for the [Loopstack AI](https://loopstack.ai) automation framework.
|
|
4
|
+
|
|
5
|
+
This module provides a GitHub OAuth 2.0 provider implementation and 25 tools across 7 domains for interacting with GitHub APIs. It registers a GitHub OAuth provider with `@loopstack/oauth-module`, enabling GitHub authentication in any Loopstack workflow, and provides tools for repositories, issues, pull requests, content/git ops, actions, search, and users/orgs.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The GitHub Module includes a **provider implementation** for `@loopstack/oauth-module`. It implements the `OAuthProviderInterface` and self-registers with the `OAuthProviderRegistry` on startup. Once registered, the generic OAuth workflow can handle `provider: 'github'` automatically.
|
|
10
|
+
|
|
11
|
+
By using this module, you'll be able to:
|
|
12
|
+
|
|
13
|
+
- Authenticate users with their GitHub account via OAuth 2.0
|
|
14
|
+
- Manage repositories, branches, issues, and pull requests programmatically
|
|
15
|
+
- Read and write file content, list directories, and inspect commits
|
|
16
|
+
- Trigger and monitor GitHub Actions workflow runs
|
|
17
|
+
- Search code, repositories, and issues across GitHub
|
|
18
|
+
- Access user profiles and organization memberships
|
|
4
19
|
|
|
5
20
|
## Installation
|
|
6
21
|
|
|
7
|
-
|
|
8
|
-
|
|
22
|
+
See [SETUP.md](./SETUP.md) for installation and setup instructions.
|
|
23
|
+
|
|
24
|
+
This module requires `@loopstack/oauth-module` as a peer dependency.
|
|
25
|
+
|
|
26
|
+
## How It Works
|
|
27
|
+
|
|
28
|
+
### Provider Registration
|
|
29
|
+
|
|
30
|
+
The `GitHubOAuthProvider` implements `OnModuleInit` and registers itself with the `OAuthProviderRegistry` at startup:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
onModuleInit(): void {
|
|
34
|
+
this.providerRegistry.register(this);
|
|
35
|
+
}
|
|
9
36
|
```
|
|
10
37
|
|
|
11
|
-
|
|
38
|
+
After registration, the generic `OAuthWorkflow` from `@loopstack/oauth-module` can handle authentication for `provider: 'github'`.
|
|
39
|
+
|
|
40
|
+
### Provider Details
|
|
41
|
+
|
|
42
|
+
| Property | Value |
|
|
43
|
+
| --------------- | --------------------------------------------- |
|
|
44
|
+
| `providerId` | `'github'` |
|
|
45
|
+
| `defaultScopes` | `repo`, `user`, `workflow`, `read:org` |
|
|
46
|
+
| Auth endpoint | `https://github.com/login/oauth/authorize` |
|
|
47
|
+
| Token endpoint | `https://github.com/login/oauth/access_token` |
|
|
12
48
|
|
|
13
|
-
|
|
49
|
+
> **Note:** GitHub OAuth tokens do not expire and do not support refresh. The `refreshToken()` method throws an error.
|
|
50
|
+
|
|
51
|
+
### Environment Variables
|
|
14
52
|
|
|
15
53
|
```env
|
|
16
54
|
GITHUB_CLIENT_ID=your_client_id
|
|
@@ -65,3 +103,46 @@ GITHUB_OAUTH_REDIRECT_URI=/oauth/callback
|
|
|
65
103
|
|
|
66
104
|
- **GitHubGetAuthenticatedUserTool** — Get authenticated user profile
|
|
67
105
|
- **GitHubListUserOrgsTool** — List user organizations
|
|
106
|
+
|
|
107
|
+
## Usage in Workflows
|
|
108
|
+
|
|
109
|
+
Once registered, any workflow can trigger GitHub authentication by launching the OAuth workflow with `provider: 'github'`:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
@InjectWorkflow() oAuth: OAuthWorkflow;
|
|
113
|
+
|
|
114
|
+
// In a transition method:
|
|
115
|
+
const result = await this.oAuth.run(
|
|
116
|
+
{ provider: 'github', scopes: ['repo', 'read:org', 'workflow'] },
|
|
117
|
+
{ alias: 'oAuth', callback: { transition: 'authCompleted' } },
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
await this.repository.save(
|
|
121
|
+
LinkDocument,
|
|
122
|
+
{
|
|
123
|
+
label: 'GitHub authentication required',
|
|
124
|
+
workflowId: result.workflowId,
|
|
125
|
+
embed: true,
|
|
126
|
+
expanded: true,
|
|
127
|
+
},
|
|
128
|
+
{ id: `link_${result.workflowId}` },
|
|
129
|
+
);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See `@loopstack/oauth-module` and `@loopstack/github-oauth-example` for complete usage examples.
|
|
133
|
+
|
|
134
|
+
## Dependencies
|
|
135
|
+
|
|
136
|
+
- `@loopstack/oauth-module` — Provides `OAuthProviderRegistry`, `OAuthProviderInterface`, and `OAuthTokenSet`
|
|
137
|
+
|
|
138
|
+
## About
|
|
139
|
+
|
|
140
|
+
Author: [Jakob Klippel](https://www.linkedin.com/in/jakob-klippel/)
|
|
141
|
+
|
|
142
|
+
License: Apache-2.0
|
|
143
|
+
|
|
144
|
+
### Additional Resources
|
|
145
|
+
|
|
146
|
+
- [Loopstack Documentation](https://loopstack.ai/docs)
|
|
147
|
+
- [Getting Started with Loopstack](https://loopstack.ai/docs/getting-started)
|
|
148
|
+
- For more examples see the [Loopstack Registry](https://loopstack.ai/registry)
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseTool, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
owner: z.ZodString;
|
|
5
|
+
repo: z.ZodString;
|
|
6
|
+
runId: z.ZodNumber;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export type GitHubGetWorkflowRunArgs = z.infer<typeof inputSchema>;
|
|
9
|
+
export declare class GitHubGetWorkflowRunTool extends BaseTool {
|
|
8
10
|
private readonly logger;
|
|
9
11
|
private tokenStore;
|
|
10
|
-
args: GitHubGetWorkflowRunArgs
|
|
11
|
-
execute(args: GitHubGetWorkflowRunArgs, ctx: RunContext): Promise<ToolResult>;
|
|
12
|
+
call(args: GitHubGetWorkflowRunArgs): Promise<ToolResult>;
|
|
12
13
|
}
|
|
14
|
+
export {};
|
|
13
15
|
//# sourceMappingURL=github-get-workflow-run.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-get-workflow-run.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/actions/github-get-workflow-run.tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github-get-workflow-run.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/actions/github-get-workflow-run.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;;;;kBAMN,CAAC;AAEZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnE,qBAOa,wBAAyB,SAAQ,QAAQ;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;IAGpE,OAAO,CAAC,UAAU,CAAkB;IAE9B,IAAI,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;CAgFhE"}
|
|
@@ -15,12 +15,18 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
-
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
owner: zod_1.z.string(),
|
|
21
|
+
repo: zod_1.z.string(),
|
|
22
|
+
runId: zod_1.z.number(),
|
|
23
|
+
})
|
|
24
|
+
.strict();
|
|
25
|
+
let GitHubGetWorkflowRunTool = GitHubGetWorkflowRunTool_1 = class GitHubGetWorkflowRunTool extends common_2.BaseTool {
|
|
19
26
|
logger = new common_1.Logger(GitHubGetWorkflowRunTool_1.name);
|
|
20
27
|
tokenStore;
|
|
21
|
-
args
|
|
22
|
-
|
|
23
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
28
|
+
async call(args) {
|
|
29
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
24
30
|
if (!accessToken) {
|
|
25
31
|
return {
|
|
26
32
|
data: {
|
|
@@ -38,7 +44,7 @@ let GitHubGetWorkflowRunTool = GitHubGetWorkflowRunTool_1 = class GitHubGetWorkf
|
|
|
38
44
|
},
|
|
39
45
|
});
|
|
40
46
|
if (response.status === 401 || response.status === 403) {
|
|
41
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
47
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
42
48
|
return {
|
|
43
49
|
data: {
|
|
44
50
|
error: '401',
|
|
@@ -84,23 +90,12 @@ __decorate([
|
|
|
84
90
|
(0, common_1.Inject)(),
|
|
85
91
|
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
86
92
|
], GitHubGetWorkflowRunTool.prototype, "tokenStore", void 0);
|
|
87
|
-
__decorate([
|
|
88
|
-
(0, common_2.Input)({
|
|
89
|
-
schema: zod_1.z
|
|
90
|
-
.object({
|
|
91
|
-
owner: zod_1.z.string(),
|
|
92
|
-
repo: zod_1.z.string(),
|
|
93
|
-
runId: zod_1.z.number(),
|
|
94
|
-
})
|
|
95
|
-
.strict(),
|
|
96
|
-
}),
|
|
97
|
-
__metadata("design:type", Object)
|
|
98
|
-
], GitHubGetWorkflowRunTool.prototype, "args", void 0);
|
|
99
93
|
exports.GitHubGetWorkflowRunTool = GitHubGetWorkflowRunTool = GitHubGetWorkflowRunTool_1 = __decorate([
|
|
100
94
|
(0, common_2.Tool)({
|
|
101
|
-
|
|
95
|
+
uiConfig: {
|
|
102
96
|
description: 'Gets detailed information about a specific GitHub Actions workflow run. Returns { error: "unauthorized" } if no valid token is available.',
|
|
103
97
|
},
|
|
98
|
+
schema: inputSchema,
|
|
104
99
|
})
|
|
105
100
|
], GitHubGetWorkflowRunTool);
|
|
106
101
|
//# sourceMappingURL=github-get-workflow-run.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-get-workflow-run.tool.js","sourceRoot":"","sources":["../../../src/tools/actions/github-get-workflow-run.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"github-get-workflow-run.tool.js","sourceRoot":"","sources":["../../../src/tools/actions/github-get-workflow-run.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAA+D;AAC/D,0DAA0D;AAE1D,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;CAClB,CAAC;KACD,MAAM,EAAE,CAAC;AAWL,IAAM,wBAAwB,gCAA9B,MAAM,wBAAyB,SAAQ,iBAAQ;IACnC,MAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAG5D,UAAU,CAAkB;IAEpC,KAAK,CAAC,IAAI,CAAC,IAA8B;QACvC,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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E;oBACV,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,MAAM,EAAE,GAAG,CAAC,MAAM;oBAClB,UAAU,EAAE,GAAG,CAAC,UAAU;oBAC1B,UAAU,EAAE,GAAG,CAAC,WAAW;oBAC3B,OAAO,EAAE,GAAG,CAAC,QAAQ;oBACrB,KAAK,EAAE,GAAG,CAAC,KAAK;oBAChB,UAAU,EAAE,GAAG,CAAC,WAAW;oBAC3B,SAAS,EAAE,GAAG,CAAC,UAAU;oBACzB,UAAU,EAAE,GAAG,CAAC,WAAW;oBAC3B,SAAS,EAAE,GAAG,CAAC,UAAU;oBACzB,SAAS,EAAE,GAAG,CAAC,UAAU;oBACzB,YAAY,EAAE,GAAG,CAAC,cAAc;oBAChC,OAAO,EAAE,GAAG,CAAC,QAAQ;iBACtB;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAtFY,4DAAwB;AAI3B;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;4DAAC;mCAJzB,wBAAwB;IAPpC,IAAA,aAAI,EAAC;QACJ,QAAQ,EAAE;YACR,WAAW,EACT,2IAA2I;SAC9I;QACD,MAAM,EAAE,WAAW;KACpB,CAAC;GACW,wBAAwB,CAsFpC"}
|
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseTool, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
owner: z.ZodString;
|
|
5
|
+
repo: z.ZodString;
|
|
6
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
7
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
success: "success";
|
|
9
|
+
pending: "pending";
|
|
10
|
+
completed: "completed";
|
|
11
|
+
action_required: "action_required";
|
|
12
|
+
cancelled: "cancelled";
|
|
13
|
+
failure: "failure";
|
|
14
|
+
neutral: "neutral";
|
|
15
|
+
skipped: "skipped";
|
|
16
|
+
stale: "stale";
|
|
17
|
+
timed_out: "timed_out";
|
|
18
|
+
in_progress: "in_progress";
|
|
19
|
+
queued: "queued";
|
|
20
|
+
requested: "requested";
|
|
21
|
+
waiting: "waiting";
|
|
22
|
+
}>>;
|
|
23
|
+
perPage: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type GitHubListWorkflowRunsArgs = z.input<typeof inputSchema>;
|
|
27
|
+
export declare class GitHubListWorkflowRunsTool extends BaseTool {
|
|
11
28
|
private readonly logger;
|
|
12
29
|
private tokenStore;
|
|
13
|
-
args: GitHubListWorkflowRunsArgs
|
|
14
|
-
execute(args: GitHubListWorkflowRunsArgs, ctx: RunContext): Promise<ToolResult>;
|
|
30
|
+
call(args: GitHubListWorkflowRunsArgs): Promise<ToolResult>;
|
|
15
31
|
}
|
|
32
|
+
export {};
|
|
16
33
|
//# sourceMappingURL=github-list-workflow-runs.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-list-workflow-runs.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/actions/github-list-workflow-runs.tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github-list-workflow-runs.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/actions/github-list-workflow-runs.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;;;;;;;;;;;;;;;;;;;;;;kBA0BN,CAAC;AAEZ,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAErE,qBAOa,0BAA2B,SAAQ,QAAQ;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;IAGtE,OAAO,CAAC,UAAU,CAAkB;IAE9B,IAAI,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,UAAU,CAAC;CAmFlE"}
|
|
@@ -15,12 +15,38 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
-
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
owner: zod_1.z.string(),
|
|
21
|
+
repo: zod_1.z.string(),
|
|
22
|
+
branch: zod_1.z.string().optional(),
|
|
23
|
+
status: zod_1.z
|
|
24
|
+
.enum([
|
|
25
|
+
'completed',
|
|
26
|
+
'action_required',
|
|
27
|
+
'cancelled',
|
|
28
|
+
'failure',
|
|
29
|
+
'neutral',
|
|
30
|
+
'skipped',
|
|
31
|
+
'stale',
|
|
32
|
+
'success',
|
|
33
|
+
'timed_out',
|
|
34
|
+
'in_progress',
|
|
35
|
+
'queued',
|
|
36
|
+
'requested',
|
|
37
|
+
'waiting',
|
|
38
|
+
'pending',
|
|
39
|
+
])
|
|
40
|
+
.optional(),
|
|
41
|
+
perPage: zod_1.z.number().default(30),
|
|
42
|
+
page: zod_1.z.number().default(1),
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
let GitHubListWorkflowRunsTool = GitHubListWorkflowRunsTool_1 = class GitHubListWorkflowRunsTool extends common_2.BaseTool {
|
|
19
46
|
logger = new common_1.Logger(GitHubListWorkflowRunsTool_1.name);
|
|
20
47
|
tokenStore;
|
|
21
|
-
args
|
|
22
|
-
|
|
23
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
48
|
+
async call(args) {
|
|
49
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
24
50
|
if (!accessToken) {
|
|
25
51
|
return {
|
|
26
52
|
data: {
|
|
@@ -46,7 +72,7 @@ let GitHubListWorkflowRunsTool = GitHubListWorkflowRunsTool_1 = class GitHubList
|
|
|
46
72
|
},
|
|
47
73
|
});
|
|
48
74
|
if (response.status === 401 || response.status === 403) {
|
|
49
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
75
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
50
76
|
return {
|
|
51
77
|
data: {
|
|
52
78
|
error: '401',
|
|
@@ -87,43 +113,12 @@ __decorate([
|
|
|
87
113
|
(0, common_1.Inject)(),
|
|
88
114
|
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
89
115
|
], GitHubListWorkflowRunsTool.prototype, "tokenStore", void 0);
|
|
90
|
-
__decorate([
|
|
91
|
-
(0, common_2.Input)({
|
|
92
|
-
schema: zod_1.z
|
|
93
|
-
.object({
|
|
94
|
-
owner: zod_1.z.string(),
|
|
95
|
-
repo: zod_1.z.string(),
|
|
96
|
-
branch: zod_1.z.string().optional(),
|
|
97
|
-
status: zod_1.z
|
|
98
|
-
.enum([
|
|
99
|
-
'completed',
|
|
100
|
-
'action_required',
|
|
101
|
-
'cancelled',
|
|
102
|
-
'failure',
|
|
103
|
-
'neutral',
|
|
104
|
-
'skipped',
|
|
105
|
-
'stale',
|
|
106
|
-
'success',
|
|
107
|
-
'timed_out',
|
|
108
|
-
'in_progress',
|
|
109
|
-
'queued',
|
|
110
|
-
'requested',
|
|
111
|
-
'waiting',
|
|
112
|
-
'pending',
|
|
113
|
-
])
|
|
114
|
-
.optional(),
|
|
115
|
-
perPage: zod_1.z.number().default(30),
|
|
116
|
-
page: zod_1.z.number().default(1),
|
|
117
|
-
})
|
|
118
|
-
.strict(),
|
|
119
|
-
}),
|
|
120
|
-
__metadata("design:type", Object)
|
|
121
|
-
], GitHubListWorkflowRunsTool.prototype, "args", void 0);
|
|
122
116
|
exports.GitHubListWorkflowRunsTool = GitHubListWorkflowRunsTool = GitHubListWorkflowRunsTool_1 = __decorate([
|
|
123
117
|
(0, common_2.Tool)({
|
|
124
|
-
|
|
118
|
+
uiConfig: {
|
|
125
119
|
description: 'Lists workflow runs for a GitHub repository. Returns { error: "unauthorized" } if no valid token is available.',
|
|
126
120
|
},
|
|
121
|
+
schema: inputSchema,
|
|
127
122
|
})
|
|
128
123
|
], GitHubListWorkflowRunsTool);
|
|
129
124
|
//# sourceMappingURL=github-list-workflow-runs.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-list-workflow-runs.tool.js","sourceRoot":"","sources":["../../../src/tools/actions/github-list-workflow-runs.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"github-list-workflow-runs.tool.js","sourceRoot":"","sources":["../../../src/tools/actions/github-list-workflow-runs.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAA+D;AAC/D,0DAA0D;AAE1D,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,MAAM,EAAE,OAAC;SACN,IAAI,CAAC;QACJ,WAAW;QACX,iBAAiB;QACjB,WAAW;QACX,SAAS;QACT,SAAS;QACT,SAAS;QACT,OAAO;QACP,SAAS;QACT,WAAW;QACX,aAAa;QACb,QAAQ;QACR,WAAW;QACX,SAAS;QACT,SAAS;KACV,CAAC;SACD,QAAQ,EAAE;IACb,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/B,IAAI,EAAE,O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;YACzB,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,OAAO,EAAE,GAAG,CAAC,QAAQ;SACtB,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE;SAC7C,CAAC;IACJ,CAAC;CACF,CAAA;AAzFY,gEAA0B;AAI7B;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;8DAAC;qCAJzB,0BAA0B;IAPtC,IAAA,aAAI,EAAC;QACJ,QAAQ,EAAE;YACR,WAAW,EACT,gHAAgH;SACnH;QACD,MAAM,EAAE,WAAW;KACpB,CAAC;GACW,0BAA0B,CAyFtC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseTool, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
owner: z.ZodString;
|
|
5
|
+
repo: z.ZodString;
|
|
6
|
+
workflowId: z.ZodString;
|
|
7
|
+
ref: z.ZodString;
|
|
8
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export type GitHubTriggerWorkflowArgs = z.infer<typeof inputSchema>;
|
|
11
|
+
export declare class GitHubTriggerWorkflowTool extends BaseTool {
|
|
10
12
|
private readonly logger;
|
|
11
13
|
private tokenStore;
|
|
12
|
-
args: GitHubTriggerWorkflowArgs
|
|
13
|
-
execute(args: GitHubTriggerWorkflowArgs, ctx: RunContext): Promise<ToolResult>;
|
|
14
|
+
call(args: GitHubTriggerWorkflowArgs): Promise<ToolResult>;
|
|
14
15
|
}
|
|
16
|
+
export {};
|
|
15
17
|
//# sourceMappingURL=github-trigger-workflow.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-trigger-workflow.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/actions/github-trigger-workflow.tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github-trigger-workflow.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/actions/github-trigger-workflow.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;;;;;;kBAQN,CAAC;AAEZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpE,qBAOa,yBAA0B,SAAQ,QAAQ;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;IAGrE,OAAO,CAAC,UAAU,CAAkB;IAE9B,IAAI,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;CA0DjE"}
|
|
@@ -15,12 +15,20 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
-
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
owner: zod_1.z.string(),
|
|
21
|
+
repo: zod_1.z.string(),
|
|
22
|
+
workflowId: zod_1.z.string(),
|
|
23
|
+
ref: zod_1.z.string(),
|
|
24
|
+
inputs: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
|
|
25
|
+
})
|
|
26
|
+
.strict();
|
|
27
|
+
let GitHubTriggerWorkflowTool = GitHubTriggerWorkflowTool_1 = class GitHubTriggerWorkflowTool extends common_2.BaseTool {
|
|
19
28
|
logger = new common_1.Logger(GitHubTriggerWorkflowTool_1.name);
|
|
20
29
|
tokenStore;
|
|
21
|
-
args
|
|
22
|
-
|
|
23
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
30
|
+
async call(args) {
|
|
31
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
24
32
|
if (!accessToken) {
|
|
25
33
|
return {
|
|
26
34
|
data: {
|
|
@@ -46,7 +54,7 @@ let GitHubTriggerWorkflowTool = GitHubTriggerWorkflowTool_1 = class GitHubTrigge
|
|
|
46
54
|
body: JSON.stringify(requestBody),
|
|
47
55
|
});
|
|
48
56
|
if (response.status === 401 || response.status === 403) {
|
|
49
|
-
this.logger.warn(`GitHub API returned ${response.status} for user ${ctx.userId}`);
|
|
57
|
+
this.logger.warn(`GitHub API returned ${response.status} for user ${this.ctx.context.userId}`);
|
|
50
58
|
return {
|
|
51
59
|
data: {
|
|
52
60
|
error: '401',
|
|
@@ -77,25 +85,12 @@ __decorate([
|
|
|
77
85
|
(0, common_1.Inject)(),
|
|
78
86
|
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
79
87
|
], GitHubTriggerWorkflowTool.prototype, "tokenStore", void 0);
|
|
80
|
-
__decorate([
|
|
81
|
-
(0, common_2.Input)({
|
|
82
|
-
schema: zod_1.z
|
|
83
|
-
.object({
|
|
84
|
-
owner: zod_1.z.string(),
|
|
85
|
-
repo: zod_1.z.string(),
|
|
86
|
-
workflowId: zod_1.z.string(),
|
|
87
|
-
ref: zod_1.z.string(),
|
|
88
|
-
inputs: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
|
|
89
|
-
})
|
|
90
|
-
.strict(),
|
|
91
|
-
}),
|
|
92
|
-
__metadata("design:type", Object)
|
|
93
|
-
], GitHubTriggerWorkflowTool.prototype, "args", void 0);
|
|
94
88
|
exports.GitHubTriggerWorkflowTool = GitHubTriggerWorkflowTool = GitHubTriggerWorkflowTool_1 = __decorate([
|
|
95
89
|
(0, common_2.Tool)({
|
|
96
|
-
|
|
90
|
+
uiConfig: {
|
|
97
91
|
description: 'Triggers a GitHub Actions workflow dispatch event. Returns 204 No Content on success. Returns { error: "unauthorized" } if no valid token is available.',
|
|
98
92
|
},
|
|
93
|
+
schema: inputSchema,
|
|
99
94
|
})
|
|
100
95
|
], GitHubTriggerWorkflowTool);
|
|
101
96
|
//# sourceMappingURL=github-trigger-workflow.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-trigger-workflow.tool.js","sourceRoot":"","sources":["../../../src/tools/actions/github-trigger-workflow.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"github-trigger-workflow.tool.js","sourceRoot":"","sources":["../../../src/tools/actions/github-trigger-workflow.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAA+D;AAC/D,0DAA0D;AAE1D,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;IACtB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACpD,CAAC;KACD,MAAM,EAAE,CAAC;AAWL,IAAM,yBAAyB,iCAA/B,MAAM,yBAA0B,SAAQ,iBAAQ;IACpC,MAAM,GAAG,IAAI,eAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;IAG7D,UAAU,CAAkB;IAEpC,KAAK,CAAC,IAAI,CAAC,IAA+B;QACxC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC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Q,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;YAClE,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,WAAW;oBAClB,OAAO,EAAE,qBAAqB,QAAQ,CAAC,UAAU,EAAE;iBACpD;aACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI,EAAE;gBACJ,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,iDAAiD;aAC3D;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhEY,8DAAyB;AAI5B;IADP,IAAA,eAAM,GAAE;8BACW,8BAAe;6DAAC;oCAJzB,yBAAyB;IAPrC,IAAA,aAAI,EAAC;QACJ,QAAQ,EAAE;YACR,WAAW,EACT,yJAAyJ;SAC5J;QACD,MAAM,EAAE,WAAW;KACpB,CAAC;GACW,yBAAyB,CAgErC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseTool, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
owner: z.ZodString;
|
|
5
|
+
repo: z.ZodString;
|
|
6
|
+
path: z.ZodString;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
sha: z.ZodOptional<z.ZodString>;
|
|
10
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type GitHubCreateOrUpdateFileArgs = z.infer<typeof inputSchema>;
|
|
13
|
+
export declare class GitHubCreateOrUpdateFileTool extends BaseTool {
|
|
12
14
|
private readonly logger;
|
|
13
15
|
private tokenStore;
|
|
14
|
-
args: GitHubCreateOrUpdateFileArgs
|
|
15
|
-
execute(args: GitHubCreateOrUpdateFileArgs, ctx: RunContext): Promise<ToolResult>;
|
|
16
|
+
call(args: GitHubCreateOrUpdateFileArgs): Promise<ToolResult>;
|
|
16
17
|
}
|
|
18
|
+
export {};
|
|
17
19
|
//# sourceMappingURL=github-create-or-update-file.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-create-or-update-file.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/content/github-create-or-update-file.tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github-create-or-update-file.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/content/github-create-or-update-file.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;;;;;;;;kBAUN,CAAC;AAEZ,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvE,qBAOa,4BAA6B,SAAQ,QAAQ;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiD;IAGxE,OAAO,CAAC,UAAU,CAAkB;IAE9B,IAAI,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,UAAU,CAAC;CAiFpE"}
|
|
@@ -15,12 +15,22 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
-
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
owner: zod_1.z.string(),
|
|
21
|
+
repo: zod_1.z.string(),
|
|
22
|
+
path: zod_1.z.string(),
|
|
23
|
+
content: zod_1.z.string(),
|
|
24
|
+
message: zod_1.z.string(),
|
|
25
|
+
sha: zod_1.z.string().optional(),
|
|
26
|
+
branch: zod_1.z.string().optional(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
let GitHubCreateOrUpdateFileTool = GitHubCreateOrUpdateFileTool_1 = class GitHubCreateOrUpdateFileTool extends common_2.BaseTool {
|
|
19
30
|
logger = new common_1.Logger(GitHubCreateOrUpdateFileTool_1.name);
|
|
20
31
|
tokenStore;
|
|
21
|
-
args
|
|
22
|
-
|
|
23
|
-
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'github');
|
|
32
|
+
async call(args) {
|
|
33
|
+
const accessToken = await this.tokenStore.getValidAccessToken(this.ctx.context.userId, 'github');
|
|
24
34
|
if (!accessToken) {
|
|
25
35
|
return {
|
|
26
36
|
data: {
|
|
@@ -49,7 +59,7 @@ let GitHubCreateOrUpdateFileTool = GitHubCreateOrUpdateFileTool_1 = class GitHub
|
|
|
49
59
|
body: JSON.stringify(requestBody),
|
|
50
60
|
});
|
|
51
61
|
if (response.status === 401 || response.status === 403) {
|
|
52
|
-
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}`);
|
|
53
63
|
return {
|
|
54
64
|
data: {
|
|
55
65
|
error: '401',
|
|
@@ -89,27 +99,12 @@ __decorate([
|
|
|
89
99
|
(0, common_1.Inject)(),
|
|
90
100
|
__metadata("design:type", oauth_module_1.OAuthTokenStore)
|
|
91
101
|
], GitHubCreateOrUpdateFileTool.prototype, "tokenStore", void 0);
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, common_2.Input)({
|
|
94
|
-
schema: zod_1.z
|
|
95
|
-
.object({
|
|
96
|
-
owner: zod_1.z.string(),
|
|
97
|
-
repo: zod_1.z.string(),
|
|
98
|
-
path: zod_1.z.string(),
|
|
99
|
-
content: zod_1.z.string(),
|
|
100
|
-
message: zod_1.z.string(),
|
|
101
|
-
sha: zod_1.z.string().optional(),
|
|
102
|
-
branch: zod_1.z.string().optional(),
|
|
103
|
-
})
|
|
104
|
-
.strict(),
|
|
105
|
-
}),
|
|
106
|
-
__metadata("design:type", Object)
|
|
107
|
-
], GitHubCreateOrUpdateFileTool.prototype, "args", void 0);
|
|
108
102
|
exports.GitHubCreateOrUpdateFileTool = GitHubCreateOrUpdateFileTool = GitHubCreateOrUpdateFileTool_1 = __decorate([
|
|
109
103
|
(0, common_2.Tool)({
|
|
110
|
-
|
|
104
|
+
uiConfig: {
|
|
111
105
|
description: '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.',
|
|
112
106
|
},
|
|
107
|
+
schema: inputSchema,
|
|
113
108
|
})
|
|
114
109
|
], GitHubCreateOrUpdateFileTool);
|
|
115
110
|
//# sourceMappingURL=github-create-or-update-file.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-create-or-update-file.tool.js","sourceRoot":"","sources":["../../../src/tools/content/github-create-or-update-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"github-create-or-update-file.tool.js","sourceRoot":"","sources":["../../../src/tools/content/github-create-or-update-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAgD;AAChD,6BAAwB;AACxB,8CAA+D;AAC/D,0DAA0D;AAE1D,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,OAAC,C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