@loopstack/github-oauth-example 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tools/authenticate-github-task.tool.d.ts +9 -8
- package/dist/tools/authenticate-github-task.tool.d.ts.map +1 -1
- package/dist/tools/authenticate-github-task.tool.js +30 -62
- package/dist/tools/authenticate-github-task.tool.js.map +1 -1
- package/dist/workflows/github-agent.ui.yaml +16 -0
- package/dist/workflows/github-agent.workflow.d.ts +14 -13
- package/dist/workflows/github-agent.workflow.d.ts.map +1 -1
- package/dist/workflows/github-agent.workflow.js +155 -71
- package/dist/workflows/github-agent.workflow.js.map +1 -1
- package/dist/workflows/github-repos-overview.ui.yaml +17 -0
- package/dist/workflows/github-repos-overview.workflow.d.ts +77 -87
- package/dist/workflows/github-repos-overview.workflow.d.ts.map +1 -1
- package/dist/workflows/github-repos-overview.workflow.js +177 -228
- package/dist/workflows/github-repos-overview.workflow.js.map +1 -1
- package/dist/workflows/templates/repoOverview.md +81 -0
- package/dist/workflows/templates/systemMessage.md +23 -0
- package/package.json +7 -7
- package/src/tools/authenticate-github-task.tool.ts +34 -82
- package/src/workflows/__tests__/github-repos-overview-workflow.spec.ts +105 -249
- package/src/workflows/github-agent.ui.yaml +16 -0
- package/src/workflows/github-agent.workflow.ts +109 -27
- package/src/workflows/github-repos-overview.ui.yaml +17 -0
- package/src/workflows/github-repos-overview.workflow.ts +257 -215
- package/src/workflows/templates/repoOverview.md +81 -0
- package/src/workflows/templates/systemMessage.md +23 -0
- package/dist/workflows/github-agent.workflow.yaml +0 -154
- package/dist/workflows/github-repos-overview.workflow.yaml +0 -249
- package/src/workflows/github-agent.workflow.yaml +0 -154
- package/src/workflows/github-repos-overview.workflow.yaml +0 -249
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-repos-overview.workflow.js","sourceRoot":"","sources":["../../src/workflows/github-repos-overview.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"github-repos-overview.workflow.js","sourceRoot":"","sources":["../../src/workflows/github-repos-overview.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,8CAW2B;AAC3B,0CAAiE;AACjE,4DAUkC;AAClC,0DAAwD;AAwEjD,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,qBAA6C;IAEtE,0BAA0B,CAAiC;IAC3D,kBAAkB,CAAyB;IAC3C,aAAa,CAAoB;IACjC,kBAAkB,CAAyB;IAC3C,gBAAgB,CAAuB;IACvC,sBAAsB,CAA6B;IACnD,mBAAmB,CAA0B;IAC7C,sBAAsB,CAA6B;IACnD,gBAAgB,CAAuB;IAE3C,KAAK,CAAgB;IAEvC,KAAK,CAAU;IACf,IAAI,CAAU;IACd,sBAAsB,CAAW;IACjC,IAAI,CAAgF;IACpF,IAAI,CAAwD;IAC5D,WAAW,CAST;IACF,QAAQ,CAA+C;IACvD,MAAM,CAA0F;IAChG,YAAY,CAOT;IACH,gBAAgB,CAAuD;IACvE,YAAY,CAMT;IACH,aAAa,CAA6D;IAIpE,AAAN,KAAK,CAAC,SAAS,CAAC,IAAqC;QACnD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,MAAM,MAAM,GAAiC,MAAM,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5F,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,IAAK,CAAC,KAAK,KAAK,cAAc,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAK,CAAC,IAAI,CAAC;IAChC,CAAC;IAKK,AAAN,KAAK,CAAC,YAAY;QAChB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CACjC,EAAE,QAAQ,EAAE,QAAQ,EAAE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,yBAAyB,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC;;;;8DAOlE;AAKK;IADL,IAAA,cAAK,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;;;;iEAe9B;sCArMU,2BAA2B;IATvC,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,gCAAgC;QACtD,MAAM,EAAE,OAAC;aACN,MAAM,CAAC;YACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;YACpC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;SACxC,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;GACW,2BAA2B,CAsMvC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
## Authenticated User
|
|
2
|
+
|
|
3
|
+
**{{ user.login }}** {{#if user.name}}({{ user.name }}){{/if}} — {{ user.publicRepos }} public repos
|
|
4
|
+
|
|
5
|
+
{{#if orgs}}
|
|
6
|
+
|
|
7
|
+
### Organizations
|
|
8
|
+
|
|
9
|
+
{{#each orgs}}
|
|
10
|
+
|
|
11
|
+
- **{{ this.login }}** {{#if this.description}}— {{ this.description }}{{/if}}
|
|
12
|
+
{{/each}}
|
|
13
|
+
{{/if}}
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Repository: [{{ repo.fullName }}]({{ repo.htmlUrl }})
|
|
18
|
+
|
|
19
|
+
{{ repo.description }}
|
|
20
|
+
|
|
21
|
+
| Language | Stars | Forks | Open Issues | Default Branch |
|
|
22
|
+
| ------------------- | ---------------- | ---------------- | --------------------- | ------------------------ |
|
|
23
|
+
| {{ repo.language }} | {{ repo.stars }} | {{ repo.forks }} | {{ repo.openIssues }} | {{ repo.defaultBranch }} |
|
|
24
|
+
|
|
25
|
+
### Branches
|
|
26
|
+
|
|
27
|
+
{{#each branches}}
|
|
28
|
+
|
|
29
|
+
- `{{ this.name }}` {{#if this.protected}}(protected){{/if}}
|
|
30
|
+
{{/each}}
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### Open Issues
|
|
35
|
+
|
|
36
|
+
{{#each issues}}
|
|
37
|
+
|
|
38
|
+
- [#{{ this.number }}]({{ this.htmlUrl }}) {{ this.title }} — @{{ this.user }}
|
|
39
|
+
{{/each}}
|
|
40
|
+
{{#unless issues}}
|
|
41
|
+
No open issues.
|
|
42
|
+
{{/unless}}
|
|
43
|
+
|
|
44
|
+
### Open Pull Requests
|
|
45
|
+
|
|
46
|
+
{{#each pullRequests}}
|
|
47
|
+
|
|
48
|
+
- [#{{ this.number }}]({{ this.htmlUrl }}) {{ this.title }} — @{{ this.user }} {{#if this.draft}}(draft){{/if}}
|
|
49
|
+
{{/each}}
|
|
50
|
+
{{#unless pullRequests}}
|
|
51
|
+
No open pull requests.
|
|
52
|
+
{{/unless}}
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### Root Directory
|
|
57
|
+
|
|
58
|
+
{{#each directoryEntries}}
|
|
59
|
+
|
|
60
|
+
- {{ this.type }} `{{ this.name }}`
|
|
61
|
+
{{/each}}
|
|
62
|
+
|
|
63
|
+
### Recent Workflow Runs
|
|
64
|
+
|
|
65
|
+
{{#each workflowRuns}}
|
|
66
|
+
|
|
67
|
+
- [{{ this.name }}]({{ this.htmlUrl }}) — {{ this.status }} {{#if this.conclusion}}({{ this.conclusion }}){{/if}}
|
|
68
|
+
{{/each}}
|
|
69
|
+
{{#unless workflowRuns}}
|
|
70
|
+
No workflow runs found.
|
|
71
|
+
{{/unless}}
|
|
72
|
+
|
|
73
|
+
### Code Search Results
|
|
74
|
+
|
|
75
|
+
{{#each searchResults}}
|
|
76
|
+
|
|
77
|
+
- `{{ this.path }}` in {{ this.repository }}
|
|
78
|
+
{{/each}}
|
|
79
|
+
{{#unless searchResults}}
|
|
80
|
+
No code search results.
|
|
81
|
+
{{/unless}}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
You are a helpful GitHub assistant. You have access to the user's
|
|
2
|
+
GitHub account through the tools provided to you.
|
|
3
|
+
|
|
4
|
+
You can help with:
|
|
5
|
+
|
|
6
|
+
- **Repositories**: List repos, get repo details, create repos, list branches
|
|
7
|
+
- **Issues**: List issues, get issue details, create issues, comment on issues
|
|
8
|
+
- **Pull Requests**: List PRs, get PR details, create PRs, merge PRs, list reviews
|
|
9
|
+
- **Code & Content**: Read files, create/update files, browse directories, view commits
|
|
10
|
+
- **Actions (CI/CD)**: List workflow runs, trigger workflows, check run status
|
|
11
|
+
- **Search**: Search code, repositories, and issues across GitHub
|
|
12
|
+
- **Users & Orgs**: Get user profile, list organizations
|
|
13
|
+
|
|
14
|
+
When a tool returns `{ error: "unauthorized" }` or `{ error: "401" }`, call the
|
|
15
|
+
`authenticateGitHub` tool with the required OAuth scopes to let the user sign in.
|
|
16
|
+
After authentication completes, retry the original request.
|
|
17
|
+
|
|
18
|
+
Common scopes: repo, user, workflow, read:org
|
|
19
|
+
|
|
20
|
+
IMPORTANT: When using authenticateGitHub, it must be the ONLY tool call in your response.
|
|
21
|
+
|
|
22
|
+
Be concise and helpful. Format results clearly using markdown.
|
|
23
|
+
When showing repository or issue information, include links where available.
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"loopstack",
|
|
9
9
|
"oauth"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.2.0",
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"author": {
|
|
14
14
|
"name": "Jakob Klippel",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"watch": "nest build --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@loopstack/claude-module": "^0.
|
|
33
|
-
"@loopstack/common": "^0.
|
|
34
|
-
"@loopstack/core": "^0.
|
|
35
|
-
"@loopstack/create-chat-message-tool": "^0.
|
|
36
|
-
"@loopstack/github-module": "^0.
|
|
37
|
-
"@loopstack/oauth-module": "^0.
|
|
32
|
+
"@loopstack/claude-module": "^0.22.0",
|
|
33
|
+
"@loopstack/common": "^0.25.0",
|
|
34
|
+
"@loopstack/core": "^0.25.0",
|
|
35
|
+
"@loopstack/create-chat-message-tool": "^0.21.0",
|
|
36
|
+
"@loopstack/github-module": "^0.2.0",
|
|
37
|
+
"@loopstack/oauth-module": "^0.2.0",
|
|
38
38
|
"@nestjs/common": "^11.1.14",
|
|
39
39
|
"zod": "^4.3.6"
|
|
40
40
|
},
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { Injectable, Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Input,
|
|
7
|
-
RunContext,
|
|
8
|
-
Tool,
|
|
9
|
-
ToolInterface,
|
|
10
|
-
ToolResult,
|
|
11
|
-
ToolSideEffects,
|
|
12
|
-
WorkflowInterface,
|
|
13
|
-
WorkflowMetadataInterface,
|
|
14
|
-
} from '@loopstack/common';
|
|
15
|
-
import { CreateDocument, LinkDocument, Task } from '@loopstack/core';
|
|
3
|
+
import { BaseTool, InjectWorkflow, Tool, ToolResult } from '@loopstack/common';
|
|
4
|
+
import { LinkDocument } from '@loopstack/core';
|
|
5
|
+
import { OAuthWorkflow } from '@loopstack/oauth-module';
|
|
16
6
|
|
|
17
7
|
const AuthenticateGitHubTaskInputSchema = z
|
|
18
8
|
.object({
|
|
19
9
|
scopes: z.array(z.string()).describe('The OAuth scopes to request (e.g. repo, user, workflow, read:org)'),
|
|
10
|
+
callback: z
|
|
11
|
+
.object({
|
|
12
|
+
transition: z.string(),
|
|
13
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
14
|
+
})
|
|
15
|
+
.optional(),
|
|
20
16
|
})
|
|
21
17
|
.strict();
|
|
22
18
|
|
|
@@ -24,102 +20,58 @@ type AuthenticateGitHubTaskInput = z.infer<typeof AuthenticateGitHubTaskInputSch
|
|
|
24
20
|
|
|
25
21
|
@Injectable()
|
|
26
22
|
@Tool({
|
|
27
|
-
|
|
23
|
+
uiConfig: {
|
|
28
24
|
description:
|
|
29
25
|
'Launches GitHub OAuth authentication. Shows the user a sign-in prompt to authorize access to GitHub. ' +
|
|
30
26
|
'Use this when a GitHub tool returns an "unauthorized" error. ' +
|
|
31
27
|
'Pass the required OAuth scopes for the GitHub APIs you need access to. ' +
|
|
32
28
|
'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
|
|
33
29
|
},
|
|
30
|
+
schema: AuthenticateGitHubTaskInputSchema,
|
|
34
31
|
})
|
|
35
|
-
export class AuthenticateGitHubTask
|
|
32
|
+
export class AuthenticateGitHubTask extends BaseTool {
|
|
36
33
|
private readonly logger = new Logger(AuthenticateGitHubTask.name);
|
|
37
34
|
|
|
38
|
-
@
|
|
39
|
-
@InjectTool() private createDocument: CreateDocument;
|
|
40
|
-
@InjectDocument() private linkDocument: LinkDocument;
|
|
35
|
+
@InjectWorkflow() private oAuth: OAuthWorkflow;
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
args: AuthenticateGitHubTaskInput,
|
|
47
|
-
ctx: RunContext,
|
|
48
|
-
parent: WorkflowInterface | ToolInterface,
|
|
49
|
-
metadata: WorkflowMetadataInterface,
|
|
50
|
-
): Promise<ToolResult> {
|
|
51
|
-
const taskResult = await this.task.execute(
|
|
52
|
-
{ workflow: 'oAuth', args: { provider: 'github', scopes: args.scopes } },
|
|
53
|
-
ctx,
|
|
54
|
-
parent,
|
|
37
|
+
async call(args: AuthenticateGitHubTaskInput): Promise<ToolResult> {
|
|
38
|
+
const result = await this.oAuth.run(
|
|
39
|
+
{ provider: 'github', scopes: args.scopes },
|
|
40
|
+
{ alias: 'oAuth', callback: args.callback },
|
|
55
41
|
);
|
|
56
42
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const linkResult = await this.createDocument.execute(
|
|
43
|
+
await this.repository.save(
|
|
44
|
+
LinkDocument,
|
|
60
45
|
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
icon: 'LockKeyhole',
|
|
67
|
-
label: 'GitHub authentication required',
|
|
68
|
-
caption: 'Complete sign-in to access GitHub',
|
|
69
|
-
href: `/pipelines/${String((taskResult.data as Record<string, unknown>).pipelineId)}`,
|
|
70
|
-
embed: true,
|
|
71
|
-
expanded: true,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
46
|
+
status: 'pending',
|
|
47
|
+
label: 'GitHub authentication required',
|
|
48
|
+
workflowId: result.workflowId,
|
|
49
|
+
embed: true,
|
|
50
|
+
expanded: true,
|
|
74
51
|
},
|
|
75
|
-
|
|
76
|
-
this,
|
|
77
|
-
metadata,
|
|
52
|
+
{ id: `link_${result.workflowId}` },
|
|
78
53
|
);
|
|
79
|
-
if (linkResult.effects) {
|
|
80
|
-
effects.push(...linkResult.effects);
|
|
81
|
-
}
|
|
82
54
|
|
|
83
55
|
return {
|
|
84
|
-
data:
|
|
85
|
-
effects,
|
|
56
|
+
data: { ...result, mode: 'async' },
|
|
86
57
|
};
|
|
87
58
|
}
|
|
88
59
|
|
|
89
|
-
async complete(
|
|
90
|
-
result
|
|
91
|
-
ctx: RunContext,
|
|
92
|
-
parent: WorkflowInterface | ToolInterface,
|
|
93
|
-
metadata: WorkflowMetadataInterface,
|
|
94
|
-
): Promise<ToolResult> {
|
|
95
|
-
const data = result as { pipelineId?: string };
|
|
96
|
-
|
|
97
|
-
const effects: ToolSideEffects[] = [];
|
|
60
|
+
async complete(result: Record<string, unknown>): Promise<ToolResult> {
|
|
61
|
+
const data = result as { workflowId?: string };
|
|
98
62
|
|
|
99
|
-
|
|
63
|
+
await this.repository.save(
|
|
64
|
+
LinkDocument,
|
|
100
65
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
update: {
|
|
105
|
-
content: {
|
|
106
|
-
icon: 'ShieldCheck',
|
|
107
|
-
label: 'GitHub authentication completed',
|
|
108
|
-
href: `/pipelines/${data.pipelineId}`,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
66
|
+
status: 'success',
|
|
67
|
+
label: 'GitHub authentication completed',
|
|
68
|
+
workflowId: data.workflowId,
|
|
111
69
|
},
|
|
112
|
-
|
|
113
|
-
this,
|
|
114
|
-
metadata,
|
|
70
|
+
{ id: `link_${data.workflowId}` },
|
|
115
71
|
);
|
|
116
|
-
if (linkResult.effects) {
|
|
117
|
-
effects.push(...linkResult.effects);
|
|
118
|
-
}
|
|
119
72
|
|
|
120
73
|
return {
|
|
121
74
|
data: 'GitHub authentication completed successfully. You can now use GitHub tools.',
|
|
122
|
-
effects,
|
|
123
75
|
};
|
|
124
76
|
}
|
|
125
77
|
}
|