@loopstack/oauth-examples 0.1.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 +111 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/oauth-examples.module.d.ts +3 -0
- package/dist/oauth-examples.module.d.ts.map +1 -0
- package/dist/oauth-examples.module.js +42 -0
- package/dist/oauth-examples.module.js.map +1 -0
- package/dist/shared/github/authenticate-github-task.tool.d.ts +26 -0
- package/dist/shared/github/authenticate-github-task.tool.d.ts.map +1 -0
- package/dist/shared/github/authenticate-github-task.tool.js +67 -0
- package/dist/shared/github/authenticate-github-task.tool.js.map +1 -0
- package/dist/shared/github/index.d.ts +2 -0
- package/dist/shared/github/index.d.ts.map +1 -0
- package/dist/shared/github/index.js +18 -0
- package/dist/shared/github/index.js.map +1 -0
- package/dist/shared/google/authenticate-google-task.tool.d.ts +26 -0
- package/dist/shared/google/authenticate-google-task.tool.d.ts.map +1 -0
- package/dist/shared/google/authenticate-google-task.tool.js +69 -0
- package/dist/shared/google/authenticate-google-task.tool.js.map +1 -0
- package/dist/shared/google/google-calendar-fetch-events.tool.d.ts +28 -0
- package/dist/shared/google/google-calendar-fetch-events.tool.d.ts.map +1 -0
- package/dist/shared/google/google-calendar-fetch-events.tool.js +96 -0
- package/dist/shared/google/google-calendar-fetch-events.tool.js.map +1 -0
- package/dist/shared/google/index.d.ts +3 -0
- package/dist/shared/google/index.d.ts.map +1 -0
- package/dist/shared/google/index.js +19 -0
- package/dist/shared/google/index.js.map +1 -0
- package/dist/workflows/github-agent/github-agent-example.ui.yaml +6 -0
- package/dist/workflows/github-agent/github-agent-example.workflow.d.ts +55 -0
- package/dist/workflows/github-agent/github-agent-example.workflow.d.ts.map +1 -0
- package/dist/workflows/github-agent/github-agent-example.workflow.js +243 -0
- package/dist/workflows/github-agent/github-agent-example.workflow.js.map +1 -0
- package/dist/workflows/github-agent/templates/systemMessage.md +23 -0
- package/dist/workflows/github-agent/templates/welcomeMessage.md +10 -0
- package/dist/workflows/github-overview/github-overview-example.workflow.d.ts +96 -0
- package/dist/workflows/github-overview/github-overview-example.workflow.d.ts.map +1 -0
- package/dist/workflows/github-overview/github-overview-example.workflow.js +216 -0
- package/dist/workflows/github-overview/github-overview-example.workflow.js.map +1 -0
- package/dist/workflows/github-overview/templates/repoOverview.md +81 -0
- package/dist/workflows/google-calendar-summary/google-calendar-summary-example.workflow.d.ts +32 -0
- package/dist/workflows/google-calendar-summary/google-calendar-summary-example.workflow.d.ts.map +1 -0
- package/dist/workflows/google-calendar-summary/google-calendar-summary-example.workflow.js +113 -0
- package/dist/workflows/google-calendar-summary/google-calendar-summary-example.workflow.js.map +1 -0
- package/dist/workflows/google-calendar-summary/templates/calendarSummary.md +10 -0
- package/dist/workflows/google-workspace-agent/google-workspace-agent-example.ui.yaml +6 -0
- package/dist/workflows/google-workspace-agent/google-workspace-agent-example.workflow.d.ts +41 -0
- package/dist/workflows/google-workspace-agent/google-workspace-agent-example.workflow.d.ts.map +1 -0
- package/dist/workflows/google-workspace-agent/google-workspace-agent-example.workflow.js +187 -0
- package/dist/workflows/google-workspace-agent/google-workspace-agent-example.workflow.js.map +1 -0
- package/dist/workflows/google-workspace-agent/templates/calendarSummary.md +10 -0
- package/dist/workflows/google-workspace-agent/templates/systemMessage.md +24 -0
- package/dist/workflows/google-workspace-agent/templates/welcomeMessage.md +7 -0
- package/package.json +52 -0
- package/src/index.ts +7 -0
- package/src/oauth-examples.module.ts +30 -0
- package/src/shared/github/authenticate-github-task.tool.ts +70 -0
- package/src/shared/github/index.ts +1 -0
- package/src/shared/google/authenticate-google-task.tool.ts +72 -0
- package/src/shared/google/google-calendar-fetch-events.tool.ts +117 -0
- package/src/shared/google/index.ts +2 -0
- package/src/workflows/github-agent/github-agent-example.ui.yaml +6 -0
- package/src/workflows/github-agent/github-agent-example.workflow.ts +193 -0
- package/src/workflows/github-agent/templates/systemMessage.md +23 -0
- package/src/workflows/github-agent/templates/welcomeMessage.md +10 -0
- package/src/workflows/github-overview/github-overview-example.workflow.ts +223 -0
- package/src/workflows/github-overview/templates/repoOverview.md +81 -0
- package/src/workflows/google-calendar-summary/google-calendar-summary-example.workflow.ts +102 -0
- package/src/workflows/google-calendar-summary/templates/calendarSummary.md +10 -0
- package/src/workflows/google-workspace-agent/google-workspace-agent-example.ui.yaml +6 -0
- package/src/workflows/google-workspace-agent/google-workspace-agent-example.workflow.ts +147 -0
- package/src/workflows/google-workspace-agent/templates/calendarSummary.md +10 -0
- package/src/workflows/google-workspace-agent/templates/systemMessage.md +24 -0
- package/src/workflows/google-workspace-agent/templates/welcomeMessage.md +7 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GithubOverviewExampleWorkflow = void 0;
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const common_1 = require("@loopstack/common");
|
|
16
|
+
const github_module_1 = require("@loopstack/github-module");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
const GitHubReposOverviewArgsSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
owner: zod_1.z.string().default('octocat'),
|
|
21
|
+
repo: zod_1.z.string().default('Hello-World'),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
let GithubOverviewExampleWorkflow = class GithubOverviewExampleWorkflow extends common_1.BaseWorkflow {
|
|
25
|
+
gitHubGetAuthenticatedUser;
|
|
26
|
+
gitHubListUserOrgs;
|
|
27
|
+
gitHubGetRepo;
|
|
28
|
+
gitHubListBranches;
|
|
29
|
+
gitHubListIssues;
|
|
30
|
+
gitHubListPullRequests;
|
|
31
|
+
gitHubListDirectory;
|
|
32
|
+
gitHubListWorkflowRuns;
|
|
33
|
+
gitHubSearchCode;
|
|
34
|
+
oAuthWorkflow;
|
|
35
|
+
constructor(gitHubGetAuthenticatedUser, gitHubListUserOrgs, gitHubGetRepo, gitHubListBranches, gitHubListIssues, gitHubListPullRequests, gitHubListDirectory, gitHubListWorkflowRuns, gitHubSearchCode, oAuthWorkflow) {
|
|
36
|
+
super();
|
|
37
|
+
this.gitHubGetAuthenticatedUser = gitHubGetAuthenticatedUser;
|
|
38
|
+
this.gitHubListUserOrgs = gitHubListUserOrgs;
|
|
39
|
+
this.gitHubGetRepo = gitHubGetRepo;
|
|
40
|
+
this.gitHubListBranches = gitHubListBranches;
|
|
41
|
+
this.gitHubListIssues = gitHubListIssues;
|
|
42
|
+
this.gitHubListPullRequests = gitHubListPullRequests;
|
|
43
|
+
this.gitHubListDirectory = gitHubListDirectory;
|
|
44
|
+
this.gitHubListWorkflowRuns = gitHubListWorkflowRuns;
|
|
45
|
+
this.gitHubSearchCode = gitHubSearchCode;
|
|
46
|
+
this.oAuthWorkflow = oAuthWorkflow;
|
|
47
|
+
}
|
|
48
|
+
async fetchUser(state, ctx) {
|
|
49
|
+
try {
|
|
50
|
+
const result = await this.gitHubGetAuthenticatedUser.call();
|
|
51
|
+
this.assignState({
|
|
52
|
+
owner: ctx.args.owner,
|
|
53
|
+
repo: ctx.args.repo,
|
|
54
|
+
requiresAuthentication: false,
|
|
55
|
+
user: result.data.user,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof Error && /authenticate/i.test(error.message)) {
|
|
60
|
+
this.assignState({ owner: ctx.args.owner, repo: ctx.args.repo, requiresAuthentication: true });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async authRequired(_state) {
|
|
67
|
+
await this.oAuthWorkflow.run({ provider: 'github', scopes: ['repo', 'read:org', 'workflow'] }, { callback: { transition: 'authCompleted' }, show: 'inline', label: 'GitHub authentication required' });
|
|
68
|
+
}
|
|
69
|
+
needsAuth(state) {
|
|
70
|
+
return !!state.requiresAuthentication;
|
|
71
|
+
}
|
|
72
|
+
authCompleted(_state, _input) { }
|
|
73
|
+
async fetchOrgs(_state) {
|
|
74
|
+
const result = await this.gitHubListUserOrgs.call({ perPage: 10 });
|
|
75
|
+
this.assignState({ orgs: result.data.orgs });
|
|
76
|
+
}
|
|
77
|
+
async fetchRepoDetails(state) {
|
|
78
|
+
const repoResult = await this.gitHubGetRepo.call({
|
|
79
|
+
owner: state.owner,
|
|
80
|
+
repo: state.repo,
|
|
81
|
+
});
|
|
82
|
+
const branchesResult = await this.gitHubListBranches.call({
|
|
83
|
+
owner: state.owner,
|
|
84
|
+
repo: state.repo,
|
|
85
|
+
});
|
|
86
|
+
this.assignState({ repoDetails: repoResult.data.repo, branches: branchesResult.data.branches });
|
|
87
|
+
}
|
|
88
|
+
async fetchIssuesPrs(state) {
|
|
89
|
+
const issuesResult = await this.gitHubListIssues.call({
|
|
90
|
+
owner: state.owner,
|
|
91
|
+
repo: state.repo,
|
|
92
|
+
state: 'open',
|
|
93
|
+
perPage: 10,
|
|
94
|
+
});
|
|
95
|
+
const prsResult = await this.gitHubListPullRequests.call({
|
|
96
|
+
owner: state.owner,
|
|
97
|
+
repo: state.repo,
|
|
98
|
+
state: 'open',
|
|
99
|
+
perPage: 10,
|
|
100
|
+
});
|
|
101
|
+
this.assignState({ issues: issuesResult.data.issues, pullRequests: prsResult.data.pullRequests });
|
|
102
|
+
}
|
|
103
|
+
async fetchContentActions(state) {
|
|
104
|
+
const dirResult = await this.gitHubListDirectory.call({
|
|
105
|
+
owner: state.owner,
|
|
106
|
+
repo: state.repo,
|
|
107
|
+
});
|
|
108
|
+
const runsResult = await this.gitHubListWorkflowRuns.call({
|
|
109
|
+
owner: state.owner,
|
|
110
|
+
repo: state.repo,
|
|
111
|
+
perPage: 5,
|
|
112
|
+
});
|
|
113
|
+
this.assignState({ directoryEntries: dirResult.data.entries, workflowRuns: runsResult.data.runs });
|
|
114
|
+
}
|
|
115
|
+
async fetchSearch(state) {
|
|
116
|
+
const result = await this.gitHubSearchCode.call({
|
|
117
|
+
query: `repo:${state.owner}/${state.repo}`,
|
|
118
|
+
perPage: 5,
|
|
119
|
+
});
|
|
120
|
+
this.assignState({ searchResults: result.data.results });
|
|
121
|
+
}
|
|
122
|
+
async displayResults(state) {
|
|
123
|
+
await this.documentStore.save(common_1.MarkdownDocument, {
|
|
124
|
+
markdown: this.render((0, node_path_1.join)(__dirname, 'templates', 'repoOverview.md'), {
|
|
125
|
+
user: state.user,
|
|
126
|
+
orgs: state.orgs,
|
|
127
|
+
repo: state.repoDetails,
|
|
128
|
+
branches: state.branches,
|
|
129
|
+
issues: state.issues,
|
|
130
|
+
pullRequests: state.pullRequests,
|
|
131
|
+
directoryEntries: state.directoryEntries,
|
|
132
|
+
workflowRuns: state.workflowRuns,
|
|
133
|
+
searchResults: state.searchResults,
|
|
134
|
+
}),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
exports.GithubOverviewExampleWorkflow = GithubOverviewExampleWorkflow;
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, common_1.Transition)({ to: 'user_fetched' }),
|
|
141
|
+
__metadata("design:type", Function),
|
|
142
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
143
|
+
__metadata("design:returntype", Promise)
|
|
144
|
+
], GithubOverviewExampleWorkflow.prototype, "fetchUser", null);
|
|
145
|
+
__decorate([
|
|
146
|
+
(0, common_1.Transition)({ from: 'user_fetched', to: 'awaiting_auth', priority: 10 }),
|
|
147
|
+
(0, common_1.Guard)('needsAuth'),
|
|
148
|
+
__metadata("design:type", Function),
|
|
149
|
+
__metadata("design:paramtypes", [Object]),
|
|
150
|
+
__metadata("design:returntype", Promise)
|
|
151
|
+
], GithubOverviewExampleWorkflow.prototype, "authRequired", null);
|
|
152
|
+
__decorate([
|
|
153
|
+
(0, common_1.Transition)({
|
|
154
|
+
from: 'awaiting_auth',
|
|
155
|
+
to: 'start',
|
|
156
|
+
wait: true,
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", Function),
|
|
159
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
160
|
+
__metadata("design:returntype", void 0)
|
|
161
|
+
], GithubOverviewExampleWorkflow.prototype, "authCompleted", null);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, common_1.Transition)({ from: 'user_fetched', to: 'orgs_fetched' }),
|
|
164
|
+
__metadata("design:type", Function),
|
|
165
|
+
__metadata("design:paramtypes", [Object]),
|
|
166
|
+
__metadata("design:returntype", Promise)
|
|
167
|
+
], GithubOverviewExampleWorkflow.prototype, "fetchOrgs", null);
|
|
168
|
+
__decorate([
|
|
169
|
+
(0, common_1.Transition)({ from: 'orgs_fetched', to: 'repo_fetched' }),
|
|
170
|
+
__metadata("design:type", Function),
|
|
171
|
+
__metadata("design:paramtypes", [Object]),
|
|
172
|
+
__metadata("design:returntype", Promise)
|
|
173
|
+
], GithubOverviewExampleWorkflow.prototype, "fetchRepoDetails", null);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, common_1.Transition)({ from: 'repo_fetched', to: 'issues_prs_fetched' }),
|
|
176
|
+
__metadata("design:type", Function),
|
|
177
|
+
__metadata("design:paramtypes", [Object]),
|
|
178
|
+
__metadata("design:returntype", Promise)
|
|
179
|
+
], GithubOverviewExampleWorkflow.prototype, "fetchIssuesPrs", null);
|
|
180
|
+
__decorate([
|
|
181
|
+
(0, common_1.Transition)({ from: 'issues_prs_fetched', to: 'content_actions_fetched' }),
|
|
182
|
+
__metadata("design:type", Function),
|
|
183
|
+
__metadata("design:paramtypes", [Object]),
|
|
184
|
+
__metadata("design:returntype", Promise)
|
|
185
|
+
], GithubOverviewExampleWorkflow.prototype, "fetchContentActions", null);
|
|
186
|
+
__decorate([
|
|
187
|
+
(0, common_1.Transition)({ from: 'content_actions_fetched', to: 'search_done' }),
|
|
188
|
+
__metadata("design:type", Function),
|
|
189
|
+
__metadata("design:paramtypes", [Object]),
|
|
190
|
+
__metadata("design:returntype", Promise)
|
|
191
|
+
], GithubOverviewExampleWorkflow.prototype, "fetchSearch", null);
|
|
192
|
+
__decorate([
|
|
193
|
+
(0, common_1.Transition)({ from: 'search_done', to: 'end' }),
|
|
194
|
+
__metadata("design:type", Function),
|
|
195
|
+
__metadata("design:paramtypes", [Object]),
|
|
196
|
+
__metadata("design:returntype", Promise)
|
|
197
|
+
], GithubOverviewExampleWorkflow.prototype, "displayResults", null);
|
|
198
|
+
exports.GithubOverviewExampleWorkflow = GithubOverviewExampleWorkflow = __decorate([
|
|
199
|
+
(0, common_1.Workflow)({
|
|
200
|
+
title: 'OAuth - GitHub Overview Example',
|
|
201
|
+
description: 'Comprehensive GitHub example that exercises every GitHub tool. Fetches user info, repository details, issues, pull requests, branches, directory contents, workflow runs, and search results. Launches the OAuth sub-workflow on unauthorized errors and retries.',
|
|
202
|
+
name: 'github_overview_example',
|
|
203
|
+
schema: GitHubReposOverviewArgsSchema,
|
|
204
|
+
}),
|
|
205
|
+
__metadata("design:paramtypes", [github_module_1.GitHubGetAuthenticatedUserTool,
|
|
206
|
+
github_module_1.GitHubListUserOrgsTool,
|
|
207
|
+
github_module_1.GitHubGetRepoTool,
|
|
208
|
+
github_module_1.GitHubListBranchesTool,
|
|
209
|
+
github_module_1.GitHubListIssuesTool,
|
|
210
|
+
github_module_1.GitHubListPullRequestsTool,
|
|
211
|
+
github_module_1.GitHubListDirectoryTool,
|
|
212
|
+
github_module_1.GitHubListWorkflowRunsTool,
|
|
213
|
+
github_module_1.GitHubSearchCodeTool,
|
|
214
|
+
oauth_module_1.OAuthWorkflow])
|
|
215
|
+
], GithubOverviewExampleWorkflow);
|
|
216
|
+
//# sourceMappingURL=github-overview-example.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-overview-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/github-overview/github-overview-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiC;AACjC,6BAAwB;AACxB,8CAAgG;AAEhG,4DAUkC;AAClC,0DAAwD;AAuCxD,MAAM,6BAA6B,GAAG,OAAC;KACpC,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;IACpC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;CACxC,CAAC;KACD,MAAM,EAAE,CAAC;AAWL,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,qBAAqC;IAEnE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVnB,YACmB,0BAA0D,EAC1D,kBAA0C,EAC1C,aAAgC,EAChC,kBAA0C,EAC1C,gBAAsC,EACtC,sBAAkD,EAClD,mBAA4C,EAC5C,sBAAkD,EAClD,gBAAsC,EACtC,aAA4B;QAE7C,KAAK,EAAE,CAAC;QAXS,+BAA0B,GAA1B,0BAA0B,CAAgC;QAC1D,uBAAkB,GAAlB,kBAAkB,CAAwB;QAC1C,kBAAa,GAAb,aAAa,CAAmB;QAChC,uBAAkB,GAAlB,kBAAkB,C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KK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,oBAAoB,EAAE,CAAC;;;;mEAgB9D;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,yBAAyB,EAAE,CAAC;;;;wEAazE;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC;;;;gEAOlE;AAKK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;;;;mEAe9C;wCAvJU,6BAA6B;IAPzC,IAAA,iBAAQ,EAAC;QACR,KAAK,EAAE,iCAAiC;QACxC,WAAW,EACT,mQAAmQ;QACrQ,IAAI,EAAE,yBAAyB;QAC/B,MAAM,EAAE,6BAA6B;KACtC,CAAC;qCAG+C,8CAA8B;QACtC,sCAAsB;QAC3B,iCAAiB;QACZ,sCAAsB;QACxB,oCAAoB;QACd,0CAA0B;QAC7B,uCAAuB;QACpB,0CAA0B;QAChC,oCAAoB;QACvB,4BAAa;GAXpC,6BAA6B,CAwJzC"}
|
|
@@ -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,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseWorkflow } from '@loopstack/common';
|
|
3
|
+
import type { RunContext, TransitionInput } from '@loopstack/common';
|
|
4
|
+
import { OAuthWorkflow } from '@loopstack/oauth-module';
|
|
5
|
+
import { GoogleCalendarFetchEventsTool } from '../../shared/google';
|
|
6
|
+
interface CalendarSummaryState {
|
|
7
|
+
events?: Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
summary: string;
|
|
10
|
+
start?: string;
|
|
11
|
+
end?: string;
|
|
12
|
+
}>;
|
|
13
|
+
requiresAuthentication?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const CalendarSummaryArgsSchema: z.ZodObject<{
|
|
16
|
+
calendarId: z.ZodDefault<z.ZodString>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
type CalendarSummaryArgs = z.infer<typeof CalendarSummaryArgsSchema>;
|
|
19
|
+
export declare class GoogleCalendarSummaryExampleWorkflow extends BaseWorkflow<CalendarSummaryArgs> {
|
|
20
|
+
private readonly googleCalendarFetchEvents;
|
|
21
|
+
private readonly oAuthWorkflow;
|
|
22
|
+
constructor(googleCalendarFetchEvents: GoogleCalendarFetchEventsTool, oAuthWorkflow: OAuthWorkflow);
|
|
23
|
+
fetchEvents(state: CalendarSummaryState, ctx: RunContext<CalendarSummaryArgs>): Promise<void>;
|
|
24
|
+
authRequired(_state: CalendarSummaryState): Promise<void>;
|
|
25
|
+
needsAuth(state: CalendarSummaryState): boolean;
|
|
26
|
+
authCompleted(_state: CalendarSummaryState, _input: TransitionInput): void;
|
|
27
|
+
displayResults(state: CalendarSummaryState): Promise<void>;
|
|
28
|
+
private now;
|
|
29
|
+
private endOfWeek;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=google-calendar-summary-example.workflow.d.ts.map
|
package/dist/workflows/google-calendar-summary/google-calendar-summary-example.workflow.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-calendar-summary-example.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/google-calendar-summary/google-calendar-summary-example.workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAiD,MAAM,mBAAmB,CAAC;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAEpE,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9E,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,QAAA,MAAM,yBAAyB;;kBAIpB,CAAC;AAEZ,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAErE,qBAOa,oCAAqC,SAAQ,YAAY,CAAC,mBAAmB,CAAC;IAEvF,OAAO,CAAC,QAAQ,CAAC,yBAAyB;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,yBAAyB,EAAE,6BAA6B,EACxD,aAAa,EAAE,aAAa;IAQzC,WAAW,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,UAAU,CAAC,mBAAmB,CAAC;IAuB7E,YAAY,CAAC,MAAM,EAAE,oBAAoB;IAO/C,SAAS,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAU/C,aAAa,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,eAAe;IAI7D,cAAc,CAAC,KAAK,EAAE,oBAAoB;IAMhD,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,SAAS;CASlB"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GoogleCalendarSummaryExampleWorkflow = void 0;
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const common_1 = require("@loopstack/common");
|
|
16
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
17
|
+
const google_1 = require("../../shared/google");
|
|
18
|
+
const CalendarSummaryArgsSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
calendarId: zod_1.z.string().default('primary'),
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
let GoogleCalendarSummaryExampleWorkflow = class GoogleCalendarSummaryExampleWorkflow extends common_1.BaseWorkflow {
|
|
24
|
+
googleCalendarFetchEvents;
|
|
25
|
+
oAuthWorkflow;
|
|
26
|
+
constructor(googleCalendarFetchEvents, oAuthWorkflow) {
|
|
27
|
+
super();
|
|
28
|
+
this.googleCalendarFetchEvents = googleCalendarFetchEvents;
|
|
29
|
+
this.oAuthWorkflow = oAuthWorkflow;
|
|
30
|
+
}
|
|
31
|
+
async fetchEvents(state, ctx) {
|
|
32
|
+
try {
|
|
33
|
+
const result = await this.googleCalendarFetchEvents.call({
|
|
34
|
+
calendarId: ctx.args.calendarId,
|
|
35
|
+
timeMin: this.now(),
|
|
36
|
+
timeMax: this.endOfWeek(),
|
|
37
|
+
});
|
|
38
|
+
this.assignState({ requiresAuthentication: false, events: result.data.events });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof Error && /authenticate/i.test(error.message)) {
|
|
42
|
+
this.assignState({ requiresAuthentication: true });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async authRequired(_state) {
|
|
49
|
+
await this.oAuthWorkflow.run({ provider: 'google', scopes: ['https://www.googleapis.com/auth/calendar.readonly'] }, { callback: { transition: 'authCompleted' }, show: 'inline', label: 'Google authentication required' });
|
|
50
|
+
}
|
|
51
|
+
needsAuth(state) {
|
|
52
|
+
return !!state.requiresAuthentication;
|
|
53
|
+
}
|
|
54
|
+
authCompleted(_state, _input) { }
|
|
55
|
+
async displayResults(state) {
|
|
56
|
+
await this.documentStore.save(common_1.MarkdownDocument, {
|
|
57
|
+
markdown: this.render((0, node_path_1.join)(__dirname, 'templates', 'calendarSummary.md'), { events: state.events }),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
now() {
|
|
61
|
+
return new Date().toISOString();
|
|
62
|
+
}
|
|
63
|
+
endOfWeek() {
|
|
64
|
+
const now = new Date();
|
|
65
|
+
const dayOfWeek = now.getDay();
|
|
66
|
+
const daysUntilSunday = dayOfWeek === 0 ? 7 : 7 - dayOfWeek;
|
|
67
|
+
const endOfWeek = new Date(now);
|
|
68
|
+
endOfWeek.setDate(now.getDate() + daysUntilSunday);
|
|
69
|
+
endOfWeek.setHours(23, 59, 59, 999);
|
|
70
|
+
return endOfWeek.toISOString();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.GoogleCalendarSummaryExampleWorkflow = GoogleCalendarSummaryExampleWorkflow;
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, common_1.Transition)({ to: 'calendar_fetched' }),
|
|
76
|
+
__metadata("design:type", Function),
|
|
77
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
78
|
+
__metadata("design:returntype", Promise)
|
|
79
|
+
], GoogleCalendarSummaryExampleWorkflow.prototype, "fetchEvents", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, common_1.Transition)({ from: 'calendar_fetched', to: 'awaiting_auth', priority: 10 }),
|
|
82
|
+
(0, common_1.Guard)('needsAuth'),
|
|
83
|
+
__metadata("design:type", Function),
|
|
84
|
+
__metadata("design:paramtypes", [Object]),
|
|
85
|
+
__metadata("design:returntype", Promise)
|
|
86
|
+
], GoogleCalendarSummaryExampleWorkflow.prototype, "authRequired", null);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, common_1.Transition)({
|
|
89
|
+
from: 'awaiting_auth',
|
|
90
|
+
to: 'start',
|
|
91
|
+
wait: true,
|
|
92
|
+
}),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
95
|
+
__metadata("design:returntype", void 0)
|
|
96
|
+
], GoogleCalendarSummaryExampleWorkflow.prototype, "authCompleted", null);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, common_1.Transition)({ from: 'calendar_fetched', to: 'end' }),
|
|
99
|
+
__metadata("design:type", Function),
|
|
100
|
+
__metadata("design:paramtypes", [Object]),
|
|
101
|
+
__metadata("design:returntype", Promise)
|
|
102
|
+
], GoogleCalendarSummaryExampleWorkflow.prototype, "displayResults", null);
|
|
103
|
+
exports.GoogleCalendarSummaryExampleWorkflow = GoogleCalendarSummaryExampleWorkflow = __decorate([
|
|
104
|
+
(0, common_1.Workflow)({
|
|
105
|
+
title: 'OAuth - Google Calendar Summary Example',
|
|
106
|
+
description: 'Fetches upcoming Google Calendar events and displays a summary. Launches the OAuth workflow as a sub-workflow on unauthorized errors and retries automatically.',
|
|
107
|
+
name: 'google_calendar_summary_example',
|
|
108
|
+
schema: CalendarSummaryArgsSchema,
|
|
109
|
+
}),
|
|
110
|
+
__metadata("design:paramtypes", [google_1.GoogleCalendarFetchEventsTool,
|
|
111
|
+
oauth_module_1.OAuthWorkflow])
|
|
112
|
+
], GoogleCalendarSummaryExampleWorkflow);
|
|
113
|
+
//# sourceMappingURL=google-calendar-summary-example.workflow.js.map
|
package/dist/workflows/google-calendar-summary/google-calendar-summary-example.workflow.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-calendar-summary-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/google-calendar-summary/google-calendar-summary-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiC;AACjC,6BAAwB;AACxB,8CAAgG;AAEhG,0DAAwD;AACxD,gDAAoE;AAOpE,MAAM,yBAAyB,GAAG,OAAC;KAChC,MAAM,CAAC;IACN,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;CAC1C,CAAC;KACD,MAAM,EAAE,CAAC;AAWL,IAAM,oCAAoC,GAA1C,MAAM,oCAAqC,SAAQ,qBAAiC;IAEtE;IACA;IAFnB,YACmB,yBAAwD,EACxD,aAA4B;QAE7C,KAAK,EAAE,CAAC;QAHS,8BAAyB,GAAzB,yBAAyB,CAA+B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E;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;;;;0EAKnD;+CA3DU,oCAAoC;IAPhD,IAAA,iBAAQ,EAAC;QACR,KAAK,EAAE,yCAAyC;QAChD,WAAW,EACT,iKAAiK;QACnK,IAAI,EAAE,iCAAiC;QACvC,MAAM,EAAE,yBAAyB;KAClC,CAAC;qCAG8C,sCAA6B;QACzC,4BAAa;GAHpC,oCAAoC,CA0EhD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BaseWorkflow } from '@loopstack/common';
|
|
2
|
+
import type { TransitionInput } from '@loopstack/common';
|
|
3
|
+
import { GmailGetMessageTool, GmailReplyToMessageTool, GmailSearchMessagesTool, GmailSendMessageTool, GoogleCalendarCreateEventTool, GoogleCalendarFetchEventsTool, GoogleCalendarListCalendarsTool, GoogleDriveDownloadFileTool, GoogleDriveGetFileMetadataTool, GoogleDriveListFilesTool, GoogleDriveUploadFileTool } from '@loopstack/google-workspace-module';
|
|
4
|
+
import type { LlmDelegateResult, LlmGenerateTextResult } from '@loopstack/llm-provider-module';
|
|
5
|
+
import { LlmDelegateToolCallsTool, LlmGenerateTextTool, LlmUpdateToolResultTool } from '@loopstack/llm-provider-module';
|
|
6
|
+
import { OAuthWorkflow } from '@loopstack/oauth-module';
|
|
7
|
+
import { AuthenticateGoogleTask } from '../../shared/google/authenticate-google-task.tool';
|
|
8
|
+
interface GoogleWorkspaceAgentState {
|
|
9
|
+
llmResult?: LlmGenerateTextResult;
|
|
10
|
+
delegateResult?: LlmDelegateResult;
|
|
11
|
+
}
|
|
12
|
+
export declare class GoogleWorkspaceAgentExampleWorkflow extends BaseWorkflow {
|
|
13
|
+
private readonly llmGenerateText;
|
|
14
|
+
private readonly llmDelegateToolCalls;
|
|
15
|
+
private readonly llmUpdateToolResult;
|
|
16
|
+
private readonly authenticateGoogle;
|
|
17
|
+
private readonly googleCalendarListCalendars;
|
|
18
|
+
private readonly googleCalendarFetchEvents;
|
|
19
|
+
private readonly googleCalendarCreateEvent;
|
|
20
|
+
private readonly gmailSearchMessages;
|
|
21
|
+
private readonly gmailGetMessage;
|
|
22
|
+
private readonly gmailSendMessage;
|
|
23
|
+
private readonly gmailReplyToMessage;
|
|
24
|
+
private readonly googleDriveListFiles;
|
|
25
|
+
private readonly googleDriveGetFileMetadata;
|
|
26
|
+
private readonly googleDriveDownloadFile;
|
|
27
|
+
private readonly googleDriveUploadFile;
|
|
28
|
+
private readonly oAuth;
|
|
29
|
+
constructor(llmGenerateText: LlmGenerateTextTool, llmDelegateToolCalls: LlmDelegateToolCallsTool, llmUpdateToolResult: LlmUpdateToolResultTool, authenticateGoogle: AuthenticateGoogleTask, googleCalendarListCalendars: GoogleCalendarListCalendarsTool, googleCalendarFetchEvents: GoogleCalendarFetchEventsTool, googleCalendarCreateEvent: GoogleCalendarCreateEventTool, gmailSearchMessages: GmailSearchMessagesTool, gmailGetMessage: GmailGetMessageTool, gmailSendMessage: GmailSendMessageTool, gmailReplyToMessage: GmailReplyToMessageTool, googleDriveListFiles: GoogleDriveListFilesTool, googleDriveGetFileMetadata: GoogleDriveGetFileMetadataTool, googleDriveDownloadFile: GoogleDriveDownloadFileTool, googleDriveUploadFile: GoogleDriveUploadFileTool, oAuth: OAuthWorkflow);
|
|
30
|
+
setup(_state: GoogleWorkspaceAgentState): Promise<void>;
|
|
31
|
+
userMessage(_state: GoogleWorkspaceAgentState, input: TransitionInput<string>): Promise<void>;
|
|
32
|
+
llmTurn(_state: GoogleWorkspaceAgentState): Promise<void>;
|
|
33
|
+
executeToolCalls(state: GoogleWorkspaceAgentState): Promise<void>;
|
|
34
|
+
hasToolCalls(state: GoogleWorkspaceAgentState): boolean;
|
|
35
|
+
toolResultReceived(state: GoogleWorkspaceAgentState, input: TransitionInput<Record<string, unknown>>): Promise<void>;
|
|
36
|
+
allToolsCompleteTransition(_state: GoogleWorkspaceAgentState): void;
|
|
37
|
+
allToolsComplete(state: GoogleWorkspaceAgentState): boolean;
|
|
38
|
+
respond(_state: GoogleWorkspaceAgentState): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=google-workspace-agent-example.workflow.d.ts.map
|
package/dist/workflows/google-workspace-agent/google-workspace-agent-example.workflow.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-workspace-agent-example.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/google-workspace-agent/google-workspace-agent-example.workflow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA+B,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,2BAA2B,EAC3B,8BAA8B,EAC9B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAEL,wBAAwB,EACxB,mBAAmB,EAEnB,uBAAuB,EACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAE3F,UAAU,yBAAyB;IACjC,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,cAAc,CAAC,EAAE,iBAAiB,CAAC;CACpC;AAED,qBAOa,mCAAoC,SAAQ,YAAY;IAEjE,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAEnC,OAA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