@loopstack/github-oauth-example 0.1.1 → 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.
Files changed (30) hide show
  1. package/README.md +116 -20
  2. package/dist/tools/authenticate-github-task.tool.d.ts +9 -8
  3. package/dist/tools/authenticate-github-task.tool.d.ts.map +1 -1
  4. package/dist/tools/authenticate-github-task.tool.js +30 -62
  5. package/dist/tools/authenticate-github-task.tool.js.map +1 -1
  6. package/dist/workflows/github-agent.ui.yaml +16 -0
  7. package/dist/workflows/github-agent.workflow.d.ts +14 -13
  8. package/dist/workflows/github-agent.workflow.d.ts.map +1 -1
  9. package/dist/workflows/github-agent.workflow.js +155 -71
  10. package/dist/workflows/github-agent.workflow.js.map +1 -1
  11. package/dist/workflows/github-repos-overview.ui.yaml +17 -0
  12. package/dist/workflows/github-repos-overview.workflow.d.ts +77 -87
  13. package/dist/workflows/github-repos-overview.workflow.d.ts.map +1 -1
  14. package/dist/workflows/github-repos-overview.workflow.js +177 -228
  15. package/dist/workflows/github-repos-overview.workflow.js.map +1 -1
  16. package/dist/workflows/templates/repoOverview.md +81 -0
  17. package/dist/workflows/templates/systemMessage.md +23 -0
  18. package/package.json +7 -7
  19. package/src/tools/authenticate-github-task.tool.ts +34 -82
  20. package/src/workflows/__tests__/github-repos-overview-workflow.spec.ts +105 -249
  21. package/src/workflows/github-agent.ui.yaml +16 -0
  22. package/src/workflows/github-agent.workflow.ts +109 -27
  23. package/src/workflows/github-repos-overview.ui.yaml +17 -0
  24. package/src/workflows/github-repos-overview.workflow.ts +257 -215
  25. package/src/workflows/templates/repoOverview.md +81 -0
  26. package/src/workflows/templates/systemMessage.md +23 -0
  27. package/dist/workflows/github-agent.workflow.yaml +0 -154
  28. package/dist/workflows/github-repos-overview.workflow.yaml +0 -249
  29. package/src/workflows/github-agent.workflow.yaml +0 -154
  30. package/src/workflows/github-repos-overview.workflow.yaml +0 -249
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > An example module for the [Loopstack AI](https://loopstack.ai) automation framework.
4
4
 
5
- This module demonstrates how to build workflows that interact with the GitHub API using OAuth authentication. It includes two workflows: a structured overview that fetches repository data, and an interactive chat agent powered by an LLM that can use all 25 GitHub tools.
5
+ This module demonstrates how to build workflows that interact with the GitHub API using OAuth authentication. It includes two workflows: a structured overview that fetches repository data, and an interactive chat agent powered by Claude that can use all 25 GitHub tools.
6
6
 
7
7
  ## Workflows
8
8
 
@@ -15,16 +15,70 @@ A multi-step workflow that fetches and displays a comprehensive overview of a Gi
15
15
  **Flow:**
16
16
 
17
17
  ```
18
- start -> fetch_user -> fetch_orgs -> fetch_repo_details -> fetch_issues_prs
19
- -> fetch_content_actions -> fetch_search -> display_results -> end
18
+ start -> user_fetched -> orgs_fetched -> repo_fetched -> issues_prs_fetched
19
+ -> content_actions_fetched -> search_done -> end
20
20
  ```
21
21
 
22
22
  With OAuth branching:
23
23
 
24
24
  ```
25
- fetch_user -> (unauthorized) -> auth_required -> awaiting_auth
26
- |
27
- auth_completed -> start (retry)
25
+ user_fetched -> (unauthorized via @Guard) -> awaiting_auth
26
+ |
27
+ auth_completed -> start (retry)
28
+ ```
29
+
30
+ **Key patterns:**
31
+
32
+ The workflow uses `@Guard` to check if authentication is needed and routes to the OAuth flow:
33
+
34
+ ```typescript
35
+ @Transition({ from: 'user_fetched', to: 'awaiting_auth', priority: 10 })
36
+ @Guard('needsAuth')
37
+ async authRequired() {
38
+ const result = await this.oAuth.run(
39
+ { provider: 'github', scopes: ['repo', 'read:org', 'workflow'] },
40
+ { alias: 'oAuth', callback: { transition: 'authCompleted' } },
41
+ );
42
+
43
+ await this.repository.save(
44
+ LinkDocument,
45
+ {
46
+ label: 'GitHub authentication required',
47
+ workflowId: result.workflowId,
48
+ embed: true,
49
+ expanded: true,
50
+ },
51
+ { id: `link_${result.workflowId}` },
52
+ );
53
+ }
54
+
55
+ needsAuth(): boolean {
56
+ return !!this.requiresAuthentication;
57
+ }
58
+ ```
59
+
60
+ The auth callback uses `wait: true` with `CallbackSchema` to receive the OAuth completion signal:
61
+
62
+ ```typescript
63
+ @Transition({
64
+ from: 'awaiting_auth',
65
+ to: 'start',
66
+ wait: true,
67
+ schema: CallbackSchema,
68
+ })
69
+ async authCompleted(payload: { workflowId: string }) {
70
+ await this.repository.save(
71
+ LinkDocument,
72
+ {
73
+ status: 'success',
74
+ label: 'GitHub authentication completed',
75
+ workflowId: payload.workflowId,
76
+ embed: true,
77
+ expanded: false,
78
+ },
79
+ { id: `link_${payload.workflowId}` },
80
+ );
81
+ }
28
82
  ```
29
83
 
30
84
  **Tools exercised in the workflow:**
@@ -61,18 +115,60 @@ All 25 tools are injected and available; 9 are called directly by the workflow t
61
115
 
62
116
  ### GitHub Agent (`gitHubAgent`)
63
117
 
64
- An interactive chat agent that gives an LLM access to all 25 GitHub tools. The agent can manage repositories, issues, pull requests, browse code, check CI/CD status, search across GitHub, and handle OAuth automatically.
118
+ An interactive chat agent that gives Claude access to all 25 GitHub tools. The agent can manage repositories, issues, pull requests, browse code, check CI/CD status, search across GitHub, and handle OAuth automatically via the `AuthenticateGitHubTask` custom tool.
65
119
 
66
120
  **How it works:**
67
121
 
68
- 1. Sets up a system prompt describing available GitHub capabilities
69
- 2. Waits for user input via a chat prompt
70
- 3. Sends the conversation to the LLM with all GitHub tools available
71
- 4. Executes any tool calls the LLM makes
72
- 5. If a tool returns an auth error, launches OAuth and resumes after authentication
122
+ 1. Sets up a hidden system message describing available GitHub capabilities
123
+ 2. Waits for user input via a `wait: true` transition
124
+ 3. Sends the conversation to Claude with all 25 GitHub tools plus `authenticateGitHub`
125
+ 4. If `stop_reason === 'tool_use'`, delegates tool calls via `DelegateToolCalls` and collects results with `UpdateToolResult`
126
+ 5. If a tool returns an auth error, the LLM calls `authenticateGitHub` which launches OAuth
73
127
  6. Loops back to wait for the next user message
74
128
 
75
- This is the easiest way to interactively test every GitHub tool — just ask the agent to perform any GitHub operation.
129
+ **Agent loop pattern:**
130
+
131
+ ```typescript
132
+ @Transition({ from: 'ready', to: 'prompt_executed' })
133
+ async llmTurn() {
134
+ const result: ToolResult<ClaudeGenerateTextResult> = await this.claudeGenerateText.call({
135
+ system: `You are a helpful GitHub assistant with access to repository, issue, PR, code, actions,
136
+ and search tools. When a tool returns an unauthorized error, use authenticateGitHub
137
+ to let the user sign in, then retry. Be concise and format results using markdown.`,
138
+ claude: { model: 'claude-sonnet-4-6' },
139
+ messagesSearchTag: 'message',
140
+ tools: [
141
+ 'gitHubListRepos', 'gitHubGetRepo', 'gitHubCreateRepo', 'gitHubListBranches',
142
+ 'gitHubListIssues', 'gitHubGetIssue', 'gitHubCreateIssue', 'gitHubCreateIssueComment',
143
+ 'gitHubListPullRequests', 'gitHubGetPullRequest', 'gitHubCreatePullRequest',
144
+ 'gitHubMergePullRequest', 'gitHubListPrReviews',
145
+ 'gitHubGetFileContent', 'gitHubCreateOrUpdateFile', 'gitHubListDirectory', 'gitHubGetCommit',
146
+ 'gitHubListWorkflowRuns', 'gitHubTriggerWorkflow', 'gitHubGetWorkflowRun',
147
+ 'gitHubSearchCode', 'gitHubSearchRepos', 'gitHubSearchIssues',
148
+ 'gitHubGetAuthenticatedUser', 'gitHubListUserOrgs',
149
+ 'authenticateGitHub',
150
+ ],
151
+ });
152
+ this.llmResult = result.data;
153
+ }
154
+
155
+ @Transition({ from: 'prompt_executed', to: 'awaiting_tools', priority: 10 })
156
+ @Guard('hasToolCalls')
157
+ async executeToolCalls() {
158
+ const result: ToolResult<DelegateToolCallsResult> = await this.delegateToolCalls.call({
159
+ message: this.llmResult!,
160
+ document: ClaudeMessageDocument,
161
+ callback: { transition: 'toolResultReceived' },
162
+ });
163
+ this.delegateResult = result.data;
164
+ }
165
+
166
+ hasToolCalls(): boolean {
167
+ return this.llmResult?.stop_reason === 'tool_use';
168
+ }
169
+ ```
170
+
171
+ This is the easiest way to interactively test every GitHub tool -- just ask the agent to perform any GitHub operation.
76
172
 
77
173
  ## Setup
78
174
 
@@ -89,17 +185,17 @@ GITHUB_OAUTH_REDIRECT_URI=http://localhost:5173/oauth/callback
89
185
  For the GitHub Agent workflow, you also need an LLM API key:
90
186
 
91
187
  ```bash
92
- OPENAI_API_KEY=your-openai-api-key
188
+ ANTHROPIC_API_KEY=your-anthropic-api-key
93
189
  ```
94
190
 
95
191
  ## Dependencies
96
192
 
97
- - `@loopstack/core` Core framework functionality including `ExecuteWorkflowAsync`
98
- - `@loopstack/ai-module` LLM integration (`AiGenerateText`, `DelegateToolCall`)
99
- - `@loopstack/oauth-module` OAuth infrastructure (`OAuthTokenStore`, `OAuthWorkflow`)
100
- - `@loopstack/github-module` All 25 GitHub tools and the GitHub OAuth provider
101
- - `@loopstack/core-ui-module` `CreateDocument`, `LinkDocument`, `MarkdownDocument`
102
- - `@loopstack/create-chat-message-tool` `CreateChatMessage`
193
+ - `@loopstack/common` - Core framework decorators (`BaseWorkflow`, `@Workflow`, `@Initial`, `@Transition`, `@Final`, `@Guard`, `@InjectTool`, `@InjectWorkflow`, `CallbackSchema`, `ToolResult`)
194
+ - `@loopstack/core` - Provides `LinkDocument` and `MarkdownDocument`
195
+ - `@loopstack/claude-module` - Claude integration (`ClaudeGenerateText`, `ClaudeMessageDocument`, `DelegateToolCalls`, `UpdateToolResult`)
196
+ - `@loopstack/oauth-module` - OAuth infrastructure (`OAuthWorkflow`)
197
+ - `@loopstack/github-module` - All 25 GitHub tools
198
+ - `@loopstack/create-chat-message-tool` - `CreateChatMessage` (used in agent workflow)
103
199
 
104
200
  ## About
105
201
 
@@ -1,17 +1,18 @@
1
1
  import { z } from 'zod';
2
- import { RunContext, ToolInterface, ToolResult, WorkflowInterface, WorkflowMetadataInterface } from '@loopstack/common';
2
+ import { BaseTool, ToolResult } from '@loopstack/common';
3
3
  declare const AuthenticateGitHubTaskInputSchema: z.ZodObject<{
4
4
  scopes: z.ZodArray<z.ZodString>;
5
+ callback: z.ZodOptional<z.ZodObject<{
6
+ transition: z.ZodString;
7
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
8
+ }, z.core.$strip>>;
5
9
  }, z.core.$strict>;
6
10
  type AuthenticateGitHubTaskInput = z.infer<typeof AuthenticateGitHubTaskInputSchema>;
7
- export declare class AuthenticateGitHubTask implements ToolInterface<AuthenticateGitHubTaskInput> {
11
+ export declare class AuthenticateGitHubTask extends BaseTool {
8
12
  private readonly logger;
9
- private task;
10
- private createDocument;
11
- private linkDocument;
12
- args: AuthenticateGitHubTaskInput;
13
- execute(args: AuthenticateGitHubTaskInput, ctx: RunContext, parent: WorkflowInterface | ToolInterface, metadata: WorkflowMetadataInterface): Promise<ToolResult>;
14
- complete(result: Record<string, unknown>, ctx: RunContext, parent: WorkflowInterface | ToolInterface, metadata: WorkflowMetadataInterface): Promise<ToolResult>;
13
+ private oAuth;
14
+ call(args: AuthenticateGitHubTaskInput): Promise<ToolResult>;
15
+ complete(result: Record<string, unknown>): Promise<ToolResult>;
15
16
  }
16
17
  export {};
17
18
  //# sourceMappingURL=authenticate-github-task.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate-github-task.tool.d.ts","sourceRoot":"","sources":["../../src/tools/authenticate-github-task.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,UAAU,EAEV,aAAa,EACb,UAAU,EAEV,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAG3B,QAAA,MAAM,iCAAiC;;kBAI5B,CAAC;AAEZ,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAErF,qBAUa,sBAAuB,YAAW,aAAa,CAAC,2BAA2B,CAAC;IACvF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAEpD,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,cAAc,CAAiB;IACnC,OAAO,CAAC,YAAY,CAAe;IAGrD,IAAI,EAAE,2BAA2B,CAAC;IAE5B,OAAO,CACX,IAAI,EAAE,2BAA2B,EACjC,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,iBAAiB,GAAG,aAAa,EACzC,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,UAAU,CAAC;IAuChB,QAAQ,CACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,iBAAiB,GAAG,aAAa,EACzC,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,UAAU,CAAC;CA+BvB"}
1
+ {"version":3,"file":"authenticate-github-task.tool.d.ts","sourceRoot":"","sources":["../../src/tools/authenticate-github-task.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAwB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/E,QAAA,MAAM,iCAAiC;;;;;;kBAU5B,CAAC;AAEZ,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAErF,qBAWa,sBAAuB,SAAQ,QAAQ;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAEhD,OAAO,CAAC,KAAK,CAAgB;IAEzC,IAAI,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,UAAU,CAAC;IAuB5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CAiBrE"}
@@ -15,93 +15,61 @@ const common_1 = require("@nestjs/common");
15
15
  const zod_1 = require("zod");
16
16
  const common_2 = require("@loopstack/common");
17
17
  const core_1 = require("@loopstack/core");
18
+ const oauth_module_1 = require("@loopstack/oauth-module");
18
19
  const AuthenticateGitHubTaskInputSchema = zod_1.z
19
20
  .object({
20
21
  scopes: zod_1.z.array(zod_1.z.string()).describe('The OAuth scopes to request (e.g. repo, user, workflow, read:org)'),
22
+ callback: zod_1.z
23
+ .object({
24
+ transition: zod_1.z.string(),
25
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
26
+ })
27
+ .optional(),
21
28
  })
22
29
  .strict();
23
- let AuthenticateGitHubTask = AuthenticateGitHubTask_1 = class AuthenticateGitHubTask {
30
+ let AuthenticateGitHubTask = AuthenticateGitHubTask_1 = class AuthenticateGitHubTask extends common_2.BaseTool {
24
31
  logger = new common_1.Logger(AuthenticateGitHubTask_1.name);
25
- task;
26
- createDocument;
27
- linkDocument;
28
- args;
29
- async execute(args, ctx, parent, metadata) {
30
- const taskResult = await this.task.execute({ workflow: 'oAuth', args: { provider: 'github', scopes: args.scopes } }, ctx, parent);
31
- const effects = [];
32
- const linkResult = await this.createDocument.execute({
33
- document: 'linkDocument',
34
- id: 'github_auth_link',
35
- validate: 'skip',
36
- update: {
37
- content: {
38
- icon: 'LockKeyhole',
39
- label: 'GitHub authentication required',
40
- caption: 'Complete sign-in to access GitHub',
41
- href: `/pipelines/${String(taskResult.data.pipelineId)}`,
42
- embed: true,
43
- expanded: true,
44
- },
45
- },
46
- }, ctx, this, metadata);
47
- if (linkResult.effects) {
48
- effects.push(...linkResult.effects);
49
- }
32
+ oAuth;
33
+ async call(args) {
34
+ const result = await this.oAuth.run({ provider: 'github', scopes: args.scopes }, { alias: 'oAuth', callback: args.callback });
35
+ await this.repository.save(core_1.LinkDocument, {
36
+ status: 'pending',
37
+ label: 'GitHub authentication required',
38
+ workflowId: result.workflowId,
39
+ embed: true,
40
+ expanded: true,
41
+ }, { id: `link_${result.workflowId}` });
50
42
  return {
51
- data: taskResult.data,
52
- effects,
43
+ data: { ...result, mode: 'async' },
53
44
  };
54
45
  }
55
- async complete(result, ctx, parent, metadata) {
46
+ async complete(result) {
56
47
  const data = result;
57
- const effects = [];
58
- const linkResult = await this.createDocument.execute({
59
- document: 'linkDocument',
60
- id: 'github_auth_link',
61
- validate: 'skip',
62
- update: {
63
- content: {
64
- icon: 'ShieldCheck',
65
- label: 'GitHub authentication completed',
66
- href: `/pipelines/${data.pipelineId}`,
67
- },
68
- },
69
- }, ctx, this, metadata);
70
- if (linkResult.effects) {
71
- effects.push(...linkResult.effects);
72
- }
48
+ await this.repository.save(core_1.LinkDocument, {
49
+ status: 'success',
50
+ label: 'GitHub authentication completed',
51
+ workflowId: data.workflowId,
52
+ }, { id: `link_${data.workflowId}` });
73
53
  return {
74
54
  data: 'GitHub authentication completed successfully. You can now use GitHub tools.',
75
- effects,
76
55
  };
77
56
  }
78
57
  };
79
58
  exports.AuthenticateGitHubTask = AuthenticateGitHubTask;
80
59
  __decorate([
81
- (0, common_2.InjectTool)(),
82
- __metadata("design:type", core_1.Task)
83
- ], AuthenticateGitHubTask.prototype, "task", void 0);
84
- __decorate([
85
- (0, common_2.InjectTool)(),
86
- __metadata("design:type", core_1.CreateDocument)
87
- ], AuthenticateGitHubTask.prototype, "createDocument", void 0);
88
- __decorate([
89
- (0, common_2.InjectDocument)(),
90
- __metadata("design:type", core_1.LinkDocument)
91
- ], AuthenticateGitHubTask.prototype, "linkDocument", void 0);
92
- __decorate([
93
- (0, common_2.Input)({ schema: AuthenticateGitHubTaskInputSchema }),
94
- __metadata("design:type", Object)
95
- ], AuthenticateGitHubTask.prototype, "args", void 0);
60
+ (0, common_2.InjectWorkflow)(),
61
+ __metadata("design:type", oauth_module_1.OAuthWorkflow)
62
+ ], AuthenticateGitHubTask.prototype, "oAuth", void 0);
96
63
  exports.AuthenticateGitHubTask = AuthenticateGitHubTask = AuthenticateGitHubTask_1 = __decorate([
97
64
  (0, common_1.Injectable)(),
98
65
  (0, common_2.Tool)({
99
- config: {
66
+ uiConfig: {
100
67
  description: 'Launches GitHub OAuth authentication. Shows the user a sign-in prompt to authorize access to GitHub. ' +
101
68
  'Use this when a GitHub tool returns an "unauthorized" error. ' +
102
69
  'Pass the required OAuth scopes for the GitHub APIs you need access to. ' +
103
70
  'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
104
71
  },
72
+ schema: AuthenticateGitHubTaskInputSchema,
105
73
  })
106
74
  ], AuthenticateGitHubTask);
107
75
  //# sourceMappingURL=authenticate-github-task.tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate-github-task.tool.js","sourceRoot":"","sources":["../../src/tools/authenticate-github-task.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAW2B;AAC3B,0CAAqE;AAErE,MAAM,iCAAiC,GAAG,OAAC;KACxC,MAAM,CAAC;IACN,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,mEAAmE,CAAC;CAC1G,CAAC;KACD,MAAM,EAAE,CAAC;AAcL,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAChB,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,CAAO;IACX,cAAc,CAAiB;IAC3B,YAAY,CAAe;IAGrD,IAAI,CAA8B;IAElC,KAAK,CAAC,OAAO,CACX,IAAiC,EACjC,GAAe,EACf,MAAyC,EACzC,QAAmC;QAEnC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CACxC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EACxE,GAAG,EACH,MAAM,CACP,CAAC;QAEF,MAAM,OAAO,GAAsB,EAAE,CAAC;QAEtC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAClD;YACE,QAAQ,EAAE,cAAc;YACxB,EAAE,EAAE,kBAAkB;YACtB,QAAQ,EAAE,MAAe;YACzB,MAAM,EAAE;gBAC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8BAAe,WAAI;oDAAC;AACX;IAArB,IAAA,mBAAU,GAAE;8BAAyB,qBAAc;8DAAC;AAC3B;IAAzB,IAAA,uBAAc,GAAE;8BAAuB,mBAAY;4DAAC;AAGrD;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,iCAAiC,EAAE,CAAC;;oDACnB;iCARvB,sBAAsB;IAVlC,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,uGAAuG;gBACvG,+DAA+D;gBAC/D,yEAAyE;gBACzE,2HAA2H;SAC9H;KACF,CAAC;GACW,sBAAsB,CA0FlC"}
1
+ {"version":3,"file":"authenticate-github-task.tool.js","sourceRoot":"","sources":["../../src/tools/authenticate-github-task.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAA+E;AAC/E,0CAA+C;AAC/C,0DAAwD;AAExD,MAAM,iCAAiC,GAAG,OAAC;KACxC,MAAM,CAAC;IACN,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,mEAAmE,CAAC;IACzG,QAAQ,EAAE,OAAC;SACR,MAAM,CAAC;QACN,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;QACtB,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;KACvD,CAAC;SACD,QAAQ,EAAE;CACd,CAAC;KACD,MAAM,EAAE,CAAC;AAeL,IAAM,sBAAsB,8BAA5B,MAAM,sBAAuB,SAAQ,iBAAQ;IACjC,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAExC,KAAK,CAAgB;IAE/C,KAAK,CAAC,IAAI,CAAC,IAAiC;QAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,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C"}
@@ -0,0 +1,16 @@
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,18 +1,13 @@
1
- import { ClaudeGenerateText, ClaudeMessageDocument, DelegateToolCalls, UpdateToolResult } from '@loopstack/claude-module';
2
- import { WorkflowInterface } from '@loopstack/common';
3
- import { CreateDocument, LinkDocument, Task } from '@loopstack/core';
1
+ import { ClaudeGenerateText, ClaudeGenerateTextResult, DelegateToolCalls, DelegateToolCallsResult, UpdateToolResult } from '@loopstack/claude-module';
2
+ import { BaseWorkflow } from '@loopstack/common';
4
3
  import { GitHubCreateIssueCommentTool, GitHubCreateIssueTool, GitHubCreateOrUpdateFileTool, GitHubCreatePullRequestTool, GitHubCreateRepoTool, GitHubGetAuthenticatedUserTool, GitHubGetCommitTool, GitHubGetFileContentTool, GitHubGetIssueTool, GitHubGetPullRequestTool, GitHubGetRepoTool, GitHubGetWorkflowRunTool, GitHubListBranchesTool, GitHubListDirectoryTool, GitHubListIssuesTool, GitHubListPrReviewsTool, GitHubListPullRequestsTool, GitHubListReposTool, GitHubListUserOrgsTool, GitHubListWorkflowRunsTool, GitHubMergePullRequestTool, GitHubSearchCodeTool, GitHubSearchIssuesTool, GitHubSearchReposTool, GitHubTriggerWorkflowTool } from '@loopstack/github-module';
5
4
  import { OAuthWorkflow } from '@loopstack/oauth-module';
6
5
  import { AuthenticateGitHubTask } from '../tools/authenticate-github-task.tool';
7
- export declare class GitHubAgentWorkflow implements WorkflowInterface {
8
- createDocument: CreateDocument;
6
+ export declare class GitHubAgentWorkflow extends BaseWorkflow {
9
7
  claudeGenerateText: ClaudeGenerateText;
10
8
  delegateToolCalls: DelegateToolCalls;
11
9
  updateToolResult: UpdateToolResult;
12
- task: Task;
13
10
  authenticateGitHub: AuthenticateGitHubTask;
14
- claudeMessageDocument: ClaudeMessageDocument;
15
- linkDocument: LinkDocument;
16
11
  gitHubListRepos: GitHubListReposTool;
17
12
  gitHubGetRepo: GitHubGetRepoTool;
18
13
  gitHubCreateRepo: GitHubCreateRepoTool;
@@ -39,10 +34,16 @@ export declare class GitHubAgentWorkflow implements WorkflowInterface {
39
34
  gitHubGetAuthenticatedUser: GitHubGetAuthenticatedUserTool;
40
35
  gitHubListUserOrgs: GitHubListUserOrgsTool;
41
36
  oAuth: OAuthWorkflow;
42
- state: {
43
- llmResult?: any;
44
- delegateResult?: any;
45
- };
46
- runtime: any;
37
+ llmResult?: ClaudeGenerateTextResult;
38
+ delegateResult?: DelegateToolCallsResult;
39
+ setup(): Promise<void>;
40
+ userMessage(payload: string): Promise<void>;
41
+ llmTurn(): Promise<void>;
42
+ executeToolCalls(): Promise<void>;
43
+ hasToolCalls(): boolean;
44
+ toolResultReceived(payload: Record<string, unknown>): Promise<void>;
45
+ allToolsCompleteTransition(): void;
46
+ allToolsComplete(): boolean;
47
+ respond(): Promise<void>;
47
48
  }
48
49
  //# sourceMappingURL=github-agent.workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"github-agent.workflow.d.ts","sourceRoot":"","sources":["../../src/workflows/github-agent.workflow.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAOL,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,8B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BAA4B,CAAC;IACvD,mBAAmB,EAAE,uBAAuB,CAAC;IAC7C,eAAe,EAAE,mBAAmB,CAAC;IAGrC,sBAAsB,EAAE,0BAA0B,CAAC;IACnD,qBAAqB,EAAE,yBAAyB,CAAC;IACjD,oBAAoB,EAAE,wBAAwB,CAAC;IAG/C,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,kBAAkB,EAAE,sBAAsB,CAAC;IAG3C,0BAA0B,EAAE,8BAA8B,CAAC;IAC3D,kBAAkB,EAAE,sBAAsB,CAAC;IAEvC,KAAK,EAAE,aAAa,CAAC;IAQvC,KAAK,EAAE;QACL,SAAS,CAAC,EAAE,GAAG,CAAC;QAChB,cAAc,CAAC,EAAE,GAAG,CAAC;KACtB,CAAC;IAGF,OAAO,EAAE,GAAG,CAAC;CACd"}
1
+ {"version":3,"file":"github-agent.workflow.d.ts","sourceRoot":"","sources":["../../src/workflows/github-agent.workflow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EAExB,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,YAAY,EAQb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAA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