@loopstack/github-oauth-example 0.3.1 → 0.4.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.
@@ -24,167 +24,132 @@ let GitHubReposOverviewWorkflow = class GitHubReposOverviewWorkflow extends comm
24
24
  gitHubListDirectory;
25
25
  gitHubListWorkflowRuns;
26
26
  gitHubSearchCode;
27
- oAuth;
28
- owner;
29
- repo;
30
- requiresAuthentication;
31
- user;
32
- orgs;
33
- repoDetails;
34
- branches;
35
- issues;
36
- pullRequests;
37
- directoryEntries;
38
- workflowRuns;
39
- searchResults;
40
- async fetchUser(args) {
41
- this.owner = args.owner;
42
- this.repo = args.repo;
27
+ oAuthWorkflow;
28
+ constructor(gitHubGetAuthenticatedUser, gitHubListUserOrgs, gitHubGetRepo, gitHubListBranches, gitHubListIssues, gitHubListPullRequests, gitHubListDirectory, gitHubListWorkflowRuns, gitHubSearchCode, oAuthWorkflow) {
29
+ super();
30
+ this.gitHubGetAuthenticatedUser = gitHubGetAuthenticatedUser;
31
+ this.gitHubListUserOrgs = gitHubListUserOrgs;
32
+ this.gitHubGetRepo = gitHubGetRepo;
33
+ this.gitHubListBranches = gitHubListBranches;
34
+ this.gitHubListIssues = gitHubListIssues;
35
+ this.gitHubListPullRequests = gitHubListPullRequests;
36
+ this.gitHubListDirectory = gitHubListDirectory;
37
+ this.gitHubListWorkflowRuns = gitHubListWorkflowRuns;
38
+ this.gitHubSearchCode = gitHubSearchCode;
39
+ this.oAuthWorkflow = oAuthWorkflow;
40
+ }
41
+ async fetchUser(state, ctx) {
42
+ const args = ctx.args;
43
43
  const result = await this.gitHubGetAuthenticatedUser.call();
44
- this.requiresAuthentication = result.data.error === 'unauthorized';
45
- this.user = result.data.user;
44
+ return {
45
+ ...state,
46
+ owner: args.owner,
47
+ repo: args.repo,
48
+ requiresAuthentication: result.data.error === 'unauthorized',
49
+ user: result.data.user,
50
+ };
46
51
  }
47
- async authRequired() {
48
- const result = await this.oAuth.run({ provider: 'github', scopes: ['repo', 'read:org', 'workflow'] }, { alias: 'oAuth', callback: { transition: 'authCompleted' } });
49
- await this.repository.save(common_1.LinkDocument, {
52
+ async authRequired(state) {
53
+ const result = await this.oAuthWorkflow.run({ provider: 'github', scopes: ['repo', 'read:org', 'workflow'] }, { callback: { transition: 'authCompleted' } });
54
+ await this.documentStore.save(common_1.LinkDocument, {
50
55
  label: 'GitHub authentication required',
51
56
  workflowId: result.workflowId,
52
57
  embed: true,
53
58
  expanded: true,
54
59
  }, { id: `link_${result.workflowId}` });
60
+ return state;
55
61
  }
56
- needsAuth() {
57
- return !!this.requiresAuthentication;
62
+ needsAuth(state) {
63
+ return !!state.requiresAuthentication;
58
64
  }
59
- async authCompleted(payload) {
60
- await this.repository.save(common_1.LinkDocument, {
65
+ async authCompleted(state, payload) {
66
+ await this.documentStore.save(common_1.LinkDocument, {
61
67
  status: 'success',
62
68
  label: 'GitHub authentication completed',
63
69
  workflowId: payload.workflowId,
64
70
  embed: true,
65
71
  expanded: false,
66
72
  }, { id: `link_${payload.workflowId}` });
73
+ return state;
67
74
  }
68
- async fetchOrgs() {
75
+ async fetchOrgs(state) {
69
76
  const result = await this.gitHubListUserOrgs.call({ perPage: 10 });
70
- this.orgs = result.data.orgs;
77
+ return { ...state, orgs: result.data.orgs };
71
78
  }
72
- async fetchRepoDetails() {
79
+ async fetchRepoDetails(state) {
73
80
  const repoResult = await this.gitHubGetRepo.call({
74
- owner: this.owner,
75
- repo: this.repo,
81
+ owner: state.owner,
82
+ repo: state.repo,
76
83
  });
77
- this.repoDetails = repoResult.data.repo;
78
84
  const branchesResult = await this.gitHubListBranches.call({
79
- owner: this.owner,
80
- repo: this.repo,
85
+ owner: state.owner,
86
+ repo: state.repo,
81
87
  });
82
- this.branches = branchesResult.data.branches;
88
+ return { ...state, repoDetails: repoResult.data.repo, branches: branchesResult.data.branches };
83
89
  }
84
- async fetchIssuesPrs() {
90
+ async fetchIssuesPrs(state) {
85
91
  const issuesResult = await this.gitHubListIssues.call({
86
- owner: this.owner,
87
- repo: this.repo,
92
+ owner: state.owner,
93
+ repo: state.repo,
88
94
  state: 'open',
89
95
  perPage: 10,
90
96
  });
91
- this.issues = issuesResult.data.issues;
92
97
  const prsResult = await this.gitHubListPullRequests.call({
93
- owner: this.owner,
94
- repo: this.repo,
98
+ owner: state.owner,
99
+ repo: state.repo,
95
100
  state: 'open',
96
101
  perPage: 10,
97
102
  });
98
- this.pullRequests = prsResult.data.pullRequests;
103
+ return { ...state, issues: issuesResult.data.issues, pullRequests: prsResult.data.pullRequests };
99
104
  }
100
- async fetchContentActions() {
105
+ async fetchContentActions(state) {
101
106
  const dirResult = await this.gitHubListDirectory.call({
102
- owner: this.owner,
103
- repo: this.repo,
107
+ owner: state.owner,
108
+ repo: state.repo,
104
109
  });
105
- this.directoryEntries = dirResult.data.entries;
106
110
  const runsResult = await this.gitHubListWorkflowRuns.call({
107
- owner: this.owner,
108
- repo: this.repo,
111
+ owner: state.owner,
112
+ repo: state.repo,
109
113
  perPage: 5,
110
114
  });
111
- this.workflowRuns = runsResult.data.runs;
115
+ return { ...state, directoryEntries: dirResult.data.entries, workflowRuns: runsResult.data.runs };
112
116
  }
113
- async fetchSearch() {
117
+ async fetchSearch(state) {
114
118
  const result = await this.gitHubSearchCode.call({
115
- query: `repo:${this.owner}/${this.repo}`,
119
+ query: `repo:${state.owner}/${state.repo}`,
116
120
  perPage: 5,
117
121
  });
118
- this.searchResults = result.data.results;
122
+ return { ...state, searchResults: result.data.results };
119
123
  }
120
- async displayResults() {
121
- await this.repository.save(common_1.MarkdownDocument, {
124
+ async displayResults(state) {
125
+ await this.documentStore.save(common_1.MarkdownDocument, {
122
126
  markdown: this.render(__dirname + '/templates/repoOverview.md', {
123
- user: this.user,
124
- orgs: this.orgs,
125
- repo: this.repoDetails,
126
- branches: this.branches,
127
- issues: this.issues,
128
- pullRequests: this.pullRequests,
129
- directoryEntries: this.directoryEntries,
130
- workflowRuns: this.workflowRuns,
131
- searchResults: this.searchResults,
127
+ user: state.user,
128
+ orgs: state.orgs,
129
+ repo: state.repoDetails,
130
+ branches: state.branches,
131
+ issues: state.issues,
132
+ pullRequests: state.pullRequests,
133
+ directoryEntries: state.directoryEntries,
134
+ workflowRuns: state.workflowRuns,
135
+ searchResults: state.searchResults,
132
136
  }),
133
137
  });
138
+ return {};
134
139
  }
135
140
  };
136
141
  exports.GitHubReposOverviewWorkflow = GitHubReposOverviewWorkflow;
137
142
  __decorate([
138
- (0, common_1.InjectTool)(),
139
- __metadata("design:type", github_module_1.GitHubGetAuthenticatedUserTool)
140
- ], GitHubReposOverviewWorkflow.prototype, "gitHubGetAuthenticatedUser", void 0);
141
- __decorate([
142
- (0, common_1.InjectTool)(),
143
- __metadata("design:type", github_module_1.GitHubListUserOrgsTool)
144
- ], GitHubReposOverviewWorkflow.prototype, "gitHubListUserOrgs", void 0);
145
- __decorate([
146
- (0, common_1.InjectTool)(),
147
- __metadata("design:type", github_module_1.GitHubGetRepoTool)
148
- ], GitHubReposOverviewWorkflow.prototype, "gitHubGetRepo", void 0);
149
- __decorate([
150
- (0, common_1.InjectTool)(),
151
- __metadata("design:type", github_module_1.GitHubListBranchesTool)
152
- ], GitHubReposOverviewWorkflow.prototype, "gitHubListBranches", void 0);
153
- __decorate([
154
- (0, common_1.InjectTool)(),
155
- __metadata("design:type", github_module_1.GitHubListIssuesTool)
156
- ], GitHubReposOverviewWorkflow.prototype, "gitHubListIssues", void 0);
157
- __decorate([
158
- (0, common_1.InjectTool)(),
159
- __metadata("design:type", github_module_1.GitHubListPullRequestsTool)
160
- ], GitHubReposOverviewWorkflow.prototype, "gitHubListPullRequests", void 0);
161
- __decorate([
162
- (0, common_1.InjectTool)(),
163
- __metadata("design:type", github_module_1.GitHubListDirectoryTool)
164
- ], GitHubReposOverviewWorkflow.prototype, "gitHubListDirectory", void 0);
165
- __decorate([
166
- (0, common_1.InjectTool)(),
167
- __metadata("design:type", github_module_1.GitHubListWorkflowRunsTool)
168
- ], GitHubReposOverviewWorkflow.prototype, "gitHubListWorkflowRuns", void 0);
169
- __decorate([
170
- (0, common_1.InjectTool)(),
171
- __metadata("design:type", github_module_1.GitHubSearchCodeTool)
172
- ], GitHubReposOverviewWorkflow.prototype, "gitHubSearchCode", void 0);
173
- __decorate([
174
- (0, common_1.InjectWorkflow)(),
175
- __metadata("design:type", oauth_module_1.OAuthWorkflow)
176
- ], GitHubReposOverviewWorkflow.prototype, "oAuth", void 0);
177
- __decorate([
178
- (0, common_1.Initial)({ to: 'user_fetched' }),
143
+ (0, common_1.Transition)({ to: 'user_fetched' }),
179
144
  __metadata("design:type", Function),
180
- __metadata("design:paramtypes", [Object]),
145
+ __metadata("design:paramtypes", [Object, Object]),
181
146
  __metadata("design:returntype", Promise)
182
147
  ], GitHubReposOverviewWorkflow.prototype, "fetchUser", null);
183
148
  __decorate([
184
149
  (0, common_1.Transition)({ from: 'user_fetched', to: 'awaiting_auth', priority: 10 }),
185
150
  (0, common_1.Guard)('needsAuth'),
186
151
  __metadata("design:type", Function),
187
- __metadata("design:paramtypes", []),
152
+ __metadata("design:paramtypes", [Object]),
188
153
  __metadata("design:returntype", Promise)
189
154
  ], GitHubReposOverviewWorkflow.prototype, "authRequired", null);
190
155
  __decorate([
@@ -195,54 +160,66 @@ __decorate([
195
160
  schema: common_1.CallbackSchema,
196
161
  }),
197
162
  __metadata("design:type", Function),
198
- __metadata("design:paramtypes", [Object]),
163
+ __metadata("design:paramtypes", [Object, Object]),
199
164
  __metadata("design:returntype", Promise)
200
165
  ], GitHubReposOverviewWorkflow.prototype, "authCompleted", null);
201
166
  __decorate([
202
167
  (0, common_1.Transition)({ from: 'user_fetched', to: 'orgs_fetched' }),
203
168
  __metadata("design:type", Function),
204
- __metadata("design:paramtypes", []),
169
+ __metadata("design:paramtypes", [Object]),
205
170
  __metadata("design:returntype", Promise)
206
171
  ], GitHubReposOverviewWorkflow.prototype, "fetchOrgs", null);
207
172
  __decorate([
208
173
  (0, common_1.Transition)({ from: 'orgs_fetched', to: 'repo_fetched' }),
209
174
  __metadata("design:type", Function),
210
- __metadata("design:paramtypes", []),
175
+ __metadata("design:paramtypes", [Object]),
211
176
  __metadata("design:returntype", Promise)
212
177
  ], GitHubReposOverviewWorkflow.prototype, "fetchRepoDetails", null);
213
178
  __decorate([
214
179
  (0, common_1.Transition)({ from: 'repo_fetched', to: 'issues_prs_fetched' }),
215
180
  __metadata("design:type", Function),
216
- __metadata("design:paramtypes", []),
181
+ __metadata("design:paramtypes", [Object]),
217
182
  __metadata("design:returntype", Promise)
218
183
  ], GitHubReposOverviewWorkflow.prototype, "fetchIssuesPrs", null);
219
184
  __decorate([
220
185
  (0, common_1.Transition)({ from: 'issues_prs_fetched', to: 'content_actions_fetched' }),
221
186
  __metadata("design:type", Function),
222
- __metadata("design:paramtypes", []),
187
+ __metadata("design:paramtypes", [Object]),
223
188
  __metadata("design:returntype", Promise)
224
189
  ], GitHubReposOverviewWorkflow.prototype, "fetchContentActions", null);
225
190
  __decorate([
226
191
  (0, common_1.Transition)({ from: 'content_actions_fetched', to: 'search_done' }),
227
192
  __metadata("design:type", Function),
228
- __metadata("design:paramtypes", []),
193
+ __metadata("design:paramtypes", [Object]),
229
194
  __metadata("design:returntype", Promise)
230
195
  ], GitHubReposOverviewWorkflow.prototype, "fetchSearch", null);
231
196
  __decorate([
232
- (0, common_1.Final)({ from: 'search_done' }),
197
+ (0, common_1.Transition)({ from: 'search_done', to: 'end' }),
233
198
  __metadata("design:type", Function),
234
- __metadata("design:paramtypes", []),
199
+ __metadata("design:paramtypes", [Object]),
235
200
  __metadata("design:returntype", Promise)
236
201
  ], GitHubReposOverviewWorkflow.prototype, "displayResults", null);
237
202
  exports.GitHubReposOverviewWorkflow = GitHubReposOverviewWorkflow = __decorate([
238
203
  (0, common_1.Workflow)({
239
- uiConfig: __dirname + '/github-repos-overview.ui.yaml',
204
+ title: 'GitHub Repository Overview',
205
+ description: 'Comprehensive GitHub example that exercises every GitHub tool.\nFetches user info, repository details, issues, pull requests, branches,\ndirectory contents, workflow runs, and search results for a given repository.\nIf not authenticated, launches the OAuth sub-workflow and retries.',
206
+ name: 'github_repos_overview',
240
207
  schema: zod_1.z
241
208
  .object({
242
209
  owner: zod_1.z.string().default('octocat'),
243
210
  repo: zod_1.z.string().default('Hello-World'),
244
211
  })
245
212
  .strict(),
246
- })
213
+ }),
214
+ __metadata("design:paramtypes", [github_module_1.GitHubGetAuthenticatedUserTool,
215
+ github_module_1.GitHubListUserOrgsTool,
216
+ github_module_1.GitHubGetRepoTool,
217
+ github_module_1.GitHubListBranchesTool,
218
+ github_module_1.GitHubListIssuesTool,
219
+ github_module_1.GitHubListPullRequestsTool,
220
+ github_module_1.GitHubListDirectoryTool,
221
+ github_module_1.GitHubListWorkflowRunsTool,
222
+ github_module_1.GitHubSearchCodeTool,
223
+ oauth_module_1.OAuthWorkflow])
247
224
  ], GitHubReposOverviewWorkflow);
248
225
  //# sourceMappingURL=github-repos-overview.workflow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"github-repos-overview.workflow.js","sourceRoot":"","sources":["../../src/workflows/github-repos-overview.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,8CAa2B;AAC3B,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,CA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,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,uBAAc;KACvB,CAAC;;;;gEAaD;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC;;;;4DAIxD;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC;;;;mEAaxD;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,oBAAoB,EAAE,CAAC;;;;iEAiB9D;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,yBAAyB,EAAE,CAAC;;;;sEAczE;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,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"}
1
+ {"version":3,"file":"github-repos-overview.workflow.js","sourceRoot":"","sources":["../../src/workflows/github-repos-overview.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,8CAQ2B;AAE3B,4DAUkC;AAClC,0DAAwD;AAmDjD,IAAM,2BAA2B,GAA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C,OAAO,CAAC,SAAS,CAAC;YACpC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;SACxC,CAAC;aACD,MAAM,EAAE;KACZ,CAAC;qCAM+C,8CAA8B;QACtC,sCAAsB;QAC3B,iCAAiB;QACZ,sCAAsB;QACxB,oCAAoB;QACd,0CAA0B;QAC7B,uCAAuB;QACpB,0CAA0B;QAChC,oCAAoB;QACvB,4BAAa;GAdpC,2BAA2B,CAgLvC"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "loopstack",
9
9
  "oauth"
10
10
  ],
11
- "version": "0.3.1",
11
+ "version": "0.4.1",
12
12
  "license": "MIT",
13
13
  "author": {
14
14
  "name": "Jakob Klippel",
@@ -29,12 +29,11 @@
29
29
  "watch": "nest build --watch"
30
30
  },
31
31
  "dependencies": {
32
- "@loopstack/claude-module": "^0.24.1",
33
- "@loopstack/llm-provider-module": "^0.3.1",
34
- "@loopstack/common": "^0.31.0",
35
- "@loopstack/core": "^0.31.0",
36
- "@loopstack/github-module": "^0.3.1",
37
- "@loopstack/oauth-module": "^0.3.1",
32
+ "@loopstack/claude-module": "^0.25.0",
33
+ "@loopstack/llm-provider-module": "^0.4.0",
34
+ "@loopstack/common": "^0.32.1",
35
+ "@loopstack/github-module": "^0.4.0",
36
+ "@loopstack/oauth-module": "^0.4.0",
38
37
  "@nestjs/common": "^11.1.19",
39
38
  "zod": "^4.3.6"
40
39
  },
@@ -1,6 +1,7 @@
1
- import { Injectable, Logger } from '@nestjs/common';
1
+ import { Logger } from '@nestjs/common';
2
2
  import { z } from 'zod';
3
- import { BaseTool, InjectWorkflow, LinkDocument, Tool, ToolResult } from '@loopstack/common';
3
+ import { BaseTool, LinkDocument, Tool, ToolCallOptions, ToolResult } from '@loopstack/common';
4
+ import type { LoopstackContext } from '@loopstack/common';
4
5
  import { OAuthWorkflow } from '@loopstack/oauth-module';
5
6
 
6
7
  const AuthenticateGitHubTaskInputSchema = z
@@ -17,29 +18,39 @@ const AuthenticateGitHubTaskInputSchema = z
17
18
 
18
19
  type AuthenticateGitHubTaskInput = z.infer<typeof AuthenticateGitHubTaskInputSchema>;
19
20
 
20
- @Injectable()
21
+ export type AuthenticateGitHubTaskResult = { workflowId: string; mode: string; [key: string]: unknown } | string;
22
+
21
23
  @Tool({
22
- uiConfig: {
23
- description:
24
- 'Launches GitHub OAuth authentication. Shows the user a sign-in prompt to authorize access to GitHub. ' +
25
- 'Use this when a GitHub tool returns an "unauthorized" error. ' +
26
- 'Pass the required OAuth scopes for the GitHub APIs you need access to. ' +
27
- 'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
28
- },
24
+ name: 'authenticate_github',
25
+ description:
26
+ 'Launches GitHub OAuth authentication. Shows the user a sign-in prompt to authorize access to GitHub. ' +
27
+ 'Use this when a GitHub tool returns an "unauthorized" error. ' +
28
+ 'Pass the required OAuth scopes for the GitHub APIs you need access to. ' +
29
+ 'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
29
30
  schema: AuthenticateGitHubTaskInputSchema,
30
31
  })
31
- export class AuthenticateGitHubTask extends BaseTool {
32
+ export class AuthenticateGitHubTask extends BaseTool<
33
+ AuthenticateGitHubTaskInput,
34
+ object,
35
+ AuthenticateGitHubTaskResult
36
+ > {
32
37
  private readonly logger = new Logger(AuthenticateGitHubTask.name);
33
38
 
34
- @InjectWorkflow() private oAuth: OAuthWorkflow;
39
+ constructor(private readonly oAuthWorkflow: OAuthWorkflow) {
40
+ super();
41
+ }
35
42
 
36
- async call(args: AuthenticateGitHubTaskInput): Promise<ToolResult> {
37
- const result = await this.oAuth.run(
43
+ protected async handle(
44
+ args: AuthenticateGitHubTaskInput,
45
+ ctx: LoopstackContext,
46
+ options?: ToolCallOptions,
47
+ ): Promise<ToolResult<AuthenticateGitHubTaskResult>> {
48
+ const result = await this.oAuthWorkflow.run(
38
49
  { provider: 'github', scopes: args.scopes },
39
- { alias: 'oAuth', callback: args.callback },
50
+ { callback: options?.callback ?? args.callback },
40
51
  );
41
52
 
42
- await this.repository.save(
53
+ await this.documentStore.save(
43
54
  LinkDocument,
44
55
  {
45
56
  status: 'pending',
@@ -53,13 +64,14 @@ export class AuthenticateGitHubTask extends BaseTool {
53
64
 
54
65
  return {
55
66
  data: { ...result, mode: 'async' },
67
+ pending: { workflowId: result.workflowId },
56
68
  };
57
69
  }
58
70
 
59
- async complete(result: Record<string, unknown>): Promise<ToolResult> {
71
+ async complete(result: Record<string, unknown>): Promise<ToolResult<AuthenticateGitHubTaskResult>> {
60
72
  const data = result as { workflowId?: string };
61
73
 
62
- await this.repository.save(
74
+ await this.documentStore.save(
63
75
  LinkDocument,
64
76
  {
65
77
  status: 'success',
@@ -1,7 +1,7 @@
1
1
  import { TestingModule } from '@nestjs/testing';
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { z } from 'zod';
4
- import { RunContext, WorkflowEntity, getBlockArgsSchema, getBlockConfig, getBlockTools } from '@loopstack/common';
4
+ import { RunContext, WorkflowEntity, getBlockArgsSchema, getBlockConfig } from '@loopstack/common';
5
5
  import { WorkflowProcessorService } from '@loopstack/core';
6
6
  import {
7
7
  GitHubCreateIssueCommentTool,
@@ -35,7 +35,7 @@ import { ToolMock, createStatelessContext, createWorkflowTest } from '@loopstack
35
35
  import { GitHubReposOverviewWorkflow } from '../github-repos-overview.workflow';
36
36
 
37
37
  const mockOAuthWorkflow = {
38
- run: vi.fn(),
38
+ run: vi.fn().mockResolvedValue({ workflowId: 'sub-1' }),
39
39
  };
40
40
 
41
41
  function applyAllGitHubToolMocks(builder: ReturnType<typeof createWorkflowTest>) {
@@ -72,7 +72,7 @@ function buildWorkflowTest() {
72
72
  createWorkflowTest()
73
73
  .forWorkflow(GitHubReposOverviewWorkflow)
74
74
  .withImports(OAuthModule)
75
- .withMock(OAuthWorkflow, mockOAuthWorkflow),
75
+ .withOverride(OAuthWorkflow, mockOAuthWorkflow),
76
76
  );
77
77
  }
78
78
 
@@ -130,20 +130,16 @@ describe('GitHubReposOverviewWorkflow', () => {
130
130
  expect(getBlockConfig(workflow)).toBeDefined();
131
131
  });
132
132
 
133
- it('should have GitHub tools available', () => {
134
- const tools = getBlockTools(workflow);
135
- expect(tools).toBeDefined();
136
-
137
- expect(tools).toContain('gitHubGetAuthenticatedUser');
138
- expect(tools).toContain('gitHubListUserOrgs');
139
- expect(tools).toContain('gitHubGetRepo');
140
-
141
- expect(tools).toContain('gitHubListBranches');
142
- expect(tools).toContain('gitHubListIssues');
143
- expect(tools).toContain('gitHubListPullRequests');
144
- expect(tools).toContain('gitHubListDirectory');
145
- expect(tools).toContain('gitHubListWorkflowRuns');
146
- expect(tools).toContain('gitHubSearchCode');
133
+ it('should have GitHub tools available via constructor injection', () => {
134
+ expect(mockGetAuthenticatedUser).toBeDefined();
135
+ expect(mockListUserOrgs).toBeDefined();
136
+ expect(mockGetRepo).toBeDefined();
137
+ expect(mockListBranches).toBeDefined();
138
+ expect(mockListIssues).toBeDefined();
139
+ expect(mockListPullRequests).toBeDefined();
140
+ expect(mockListDirectory).toBeDefined();
141
+ expect(mockListWorkflowRuns).toBeDefined();
142
+ expect(mockSearchCode).toBeDefined();
147
143
  });
148
144
  });
149
145
 
@@ -330,9 +326,7 @@ describe('GitHubReposOverviewWorkflow', () => {
330
326
  expect(result.place).toBe('end');
331
327
 
332
328
  // Verify markdown document was created
333
- expect(result.documents).toEqual(
334
- expect.arrayContaining([expect.objectContaining({ className: 'MarkdownDocument' })]),
335
- );
329
+ expect(result.documents).toEqual(expect.arrayContaining([expect.objectContaining({ documentName: 'markdown' })]));
336
330
 
337
331
  // Verify all read tools were called
338
332
  expect(mockGetAuthenticatedUser.call).toHaveBeenCalledTimes(1);
@@ -352,10 +346,7 @@ describe('GitHubReposOverviewWorkflow', () => {
352
346
 
353
347
  await processor.process(workflow, args, context);
354
348
 
355
- expect(mockGetRepo.call).toHaveBeenCalledWith(
356
- expect.objectContaining({ owner: 'octocat', repo: 'Hello-World' }),
357
- undefined,
358
- );
349
+ expect(mockGetRepo.call).toHaveBeenCalledWith(expect.objectContaining({ owner: 'octocat', repo: 'Hello-World' }));
359
350
  });
360
351
 
361
352
  it('should pass owner and repo to gitHubListBranches', async () => {
@@ -366,7 +357,6 @@ describe('GitHubReposOverviewWorkflow', () => {
366
357
 
367
358
  expect(mockListBranches.call).toHaveBeenCalledWith(
368
359
  expect.objectContaining({ owner: 'octocat', repo: 'Hello-World' }),
369
- undefined,
370
360
  );
371
361
  });
372
362
 
@@ -378,7 +368,6 @@ describe('GitHubReposOverviewWorkflow', () => {
378
368
 
379
369
  expect(mockListIssues.call).toHaveBeenCalledWith(
380
370
  expect.objectContaining({ owner: 'octocat', repo: 'Hello-World', state: 'open' }),
381
- undefined,
382
371
  );
383
372
  });
384
373
 
@@ -390,7 +379,6 @@ describe('GitHubReposOverviewWorkflow', () => {
390
379
 
391
380
  expect(mockListPullRequests.call).toHaveBeenCalledWith(
392
381
  expect.objectContaining({ owner: 'octocat', repo: 'Hello-World', state: 'open' }),
393
- undefined,
394
382
  );
395
383
  });
396
384
 
@@ -402,7 +390,6 @@ describe('GitHubReposOverviewWorkflow', () => {
402
390
 
403
391
  expect(mockListDirectory.call).toHaveBeenCalledWith(
404
392
  expect.objectContaining({ owner: 'octocat', repo: 'Hello-World' }),
405
- undefined,
406
393
  );
407
394
  });
408
395
 
@@ -414,7 +401,6 @@ describe('GitHubReposOverviewWorkflow', () => {
414
401
 
415
402
  expect(mockListWorkflowRuns.call).toHaveBeenCalledWith(
416
403
  expect.objectContaining({ owner: 'octocat', repo: 'Hello-World' }),
417
- undefined,
418
404
  );
419
405
  });
420
406
 
@@ -424,10 +410,7 @@ describe('GitHubReposOverviewWorkflow', () => {
424
410
 
425
411
  await processor.process(workflow, args, context);
426
412
 
427
- expect(mockSearchCode.call).toHaveBeenCalledWith(
428
- expect.objectContaining({ query: 'repo:octocat/Hello-World' }),
429
- undefined,
430
- );
413
+ expect(mockSearchCode.call).toHaveBeenCalledWith(expect.objectContaining({ query: 'repo:octocat/Hello-World' }));
431
414
  });
432
415
  });
433
416
 
@@ -442,10 +425,6 @@ describe('GitHubReposOverviewWorkflow', () => {
442
425
  },
443
426
  });
444
427
 
445
- mockOAuthWorkflow.run.mockResolvedValue({
446
- workflowId: 'test-workflow-id',
447
- });
448
-
449
428
  const result = await processor.process(workflow, { owner: 'octocat', repo: 'Hello-World' }, context);
450
429
 
451
430
  expect(result).toBeDefined();
@@ -457,10 +436,7 @@ describe('GitHubReposOverviewWorkflow', () => {
457
436
  expect(mockOAuthWorkflow.run).toHaveBeenCalledTimes(1);
458
437
  expect(mockOAuthWorkflow.run).toHaveBeenCalledWith(
459
438
  { provider: 'github', scopes: ['repo', 'read:org', 'workflow'] },
460
- expect.objectContaining({
461
- alias: 'oAuth',
462
- callback: { transition: 'authCompleted' },
463
- }),
439
+ { callback: { transition: 'authCompleted' } },
464
440
  );
465
441
 
466
442
  // Subsequent tools should NOT be called
@@ -570,9 +546,7 @@ describe('GitHubReposOverviewWorkflow with existing entity', () => {
570
546
  expect(result.place).toBe('end');
571
547
 
572
548
  // Verify markdown document was created after auth resume
573
- expect(result.documents).toEqual(
574
- expect.arrayContaining([expect.objectContaining({ className: 'MarkdownDocument' })]),
575
- );
549
+ expect(result.documents).toEqual(expect.arrayContaining([expect.objectContaining({ documentName: 'markdown' })]));
576
550
 
577
551
  expect(mockGetAuthenticatedUser.call).toHaveBeenCalledTimes(1);
578
552
  expect(mockGetRepo.call).toHaveBeenCalledTimes(1);
@@ -1,16 +1,6 @@
1
- title: 'GitHub Agent'
2
-
3
- description: |
4
- An interactive chat agent with access to GitHub.
5
- Ask it to manage repositories, issues, pull requests, browse code, check CI/CD status,
6
- search across GitHub, and more. Handles OAuth authentication automatically when needed —
7
- the agent detects unauthorized errors and launches authentication on its own.
8
-
9
- ui:
10
- widgets:
11
- - widget: prompt-input
12
- enabledWhen:
13
- - waiting_for_user
14
- options:
15
- transition: userMessage
16
- label: Send Message
1
+ widget: prompt-input
2
+ enabledWhen:
3
+ - waiting_for_user
4
+ options:
5
+ transition: userMessage
6
+ label: Send Message