@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
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: OAuth Examples
|
|
3
|
+
description: Workflow examples for OAuth-protected integrations in Loopstack — GitHub repos overview and chat agent, Google Calendar summary and Google Workspace chat agent. Each pair demonstrates the same shape: scripted single-pass workflow + interactive agent with auto-OAuth retry.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @loopstack/oauth-examples
|
|
7
|
+
|
|
8
|
+
> OAuth integration workflow examples for the [Loopstack](https://loopstack.ai) automation framework.
|
|
9
|
+
|
|
10
|
+
Two integration patterns demonstrated for two providers. Each provider has:
|
|
11
|
+
|
|
12
|
+
- A **scripted overview/summary** workflow — single-pass, hand-rolled tool sequence
|
|
13
|
+
- An **interactive agent** workflow — Claude with the full tool set, OAuth auto-retry
|
|
14
|
+
|
|
15
|
+
Both shapes share the same OAuth retry pattern: on unauthorized error, launch the OAuth sub-workflow inline, then retry from start.
|
|
16
|
+
|
|
17
|
+
## Install as Source (Recommended)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx giget@latest gh:loopstack-ai/loopstack/registry/examples/oauth-examples src/oauth-examples
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then register the module:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Module } from '@nestjs/common';
|
|
27
|
+
import { LoopstackModule } from '@loopstack/loopstack-module';
|
|
28
|
+
import { OAuthExamplesModule } from './oauth-examples/oauth-examples.module';
|
|
29
|
+
|
|
30
|
+
@Module({
|
|
31
|
+
imports: [LoopstackModule.forRoot(), OAuthExamplesModule],
|
|
32
|
+
})
|
|
33
|
+
export class AppModule {}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Install as a Dependency
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install @loopstack/oauth-examples
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { OAuthExamplesModule } from '@loopstack/oauth-examples';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Environment
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
50
|
+
GITHUB_CLIENT_ID=...
|
|
51
|
+
GITHUB_CLIENT_SECRET=...
|
|
52
|
+
GOOGLE_CLIENT_ID=...
|
|
53
|
+
GOOGLE_CLIENT_SECRET=...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Refer to `@loopstack/github-module` and `@loopstack/google-workspace-module` for the full OAuth setup (redirect URLs, scopes).
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
| Example | Studio title | Description |
|
|
61
|
+
| --------------------------------------------------- | ----------------------------------------- | -------------------------------------------------------------- |
|
|
62
|
+
| [GitHub Overview](#github-overview) | `OAuth - GitHub Overview Example` | Scripted walk of GitHub read tools with markdown summary |
|
|
63
|
+
| [GitHub Agent](#github-agent) | `OAuth - GitHub Agent Example` | Interactive Claude agent with 25 GitHub tools |
|
|
64
|
+
| [Google Calendar Summary](#google-calendar-summary) | `OAuth - Google Calendar Summary Example` | Scripted calendar fetch + markdown summary |
|
|
65
|
+
| [Google Workspace Agent](#google-workspace-agent) | `OAuth - Google Workspace Agent Example` | Interactive Claude agent with Calendar, Gmail, and Drive tools |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## GitHub Overview
|
|
70
|
+
|
|
71
|
+
A scripted (non-agent) GitHub workflow that walks every major GitHub read tool: user info, orgs, repo details, branches, issues, PRs, directory contents, workflow runs, and code search. On any unauthorized error it pauses, launches the `OAuthWorkflow` sub-workflow inline, then retries from the start.
|
|
72
|
+
|
|
73
|
+
### Files
|
|
74
|
+
|
|
75
|
+
- `github-overview-example.workflow.ts` — workflow class
|
|
76
|
+
- `templates/repoOverview.md` — Handlebars markdown summary template
|
|
77
|
+
|
|
78
|
+
## GitHub Agent
|
|
79
|
+
|
|
80
|
+
An interactive Claude chat agent with 25 GitHub tools wired in: repos, issues, PRs, code, actions, and search. When a tool returns unauthorized, the agent calls `authenticateGitHub` to launch the OAuth sub-workflow and retries.
|
|
81
|
+
|
|
82
|
+
### Files
|
|
83
|
+
|
|
84
|
+
- `github-agent-example.workflow.ts` — workflow class
|
|
85
|
+
- `github-agent-example.ui.yaml` — chat prompt-input widget
|
|
86
|
+
- `templates/systemMessage.md` — system prompt
|
|
87
|
+
|
|
88
|
+
## Google Calendar Summary
|
|
89
|
+
|
|
90
|
+
Fetches the user's upcoming calendar events via `GoogleCalendarFetchEventsTool` and renders a markdown summary. On unauthorized it launches the `OAuthWorkflow` sub-workflow inline and retries.
|
|
91
|
+
|
|
92
|
+
### Files
|
|
93
|
+
|
|
94
|
+
- `google-calendar-summary-example.workflow.ts` — workflow class
|
|
95
|
+
- `templates/calendarSummary.md` — Handlebars markdown summary
|
|
96
|
+
|
|
97
|
+
## Google Workspace Agent
|
|
98
|
+
|
|
99
|
+
An interactive Claude chat agent with 11 Google Workspace tools (Calendar, Gmail, Drive). When a tool returns unauthorized, the agent calls `authenticateGoogle` to launch the OAuth sub-workflow and retries.
|
|
100
|
+
|
|
101
|
+
### Files
|
|
102
|
+
|
|
103
|
+
- `google-workspace-agent-example.workflow.ts` — workflow class
|
|
104
|
+
- `google-workspace-agent-example.ui.yaml` — chat prompt-input widget
|
|
105
|
+
- `templates/systemMessage.md` — system prompt
|
|
106
|
+
|
|
107
|
+
## About
|
|
108
|
+
|
|
109
|
+
Author: [Jakob Klippel](https://www.linkedin.com/in/jakob-klippel/)
|
|
110
|
+
|
|
111
|
+
License: MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './oauth-examples.module';
|
|
2
|
+
export * from './workflows/github-overview/github-overview-example.workflow';
|
|
3
|
+
export * from './workflows/github-agent/github-agent-example.workflow';
|
|
4
|
+
export * from './workflows/google-calendar-summary/google-calendar-summary-example.workflow';
|
|
5
|
+
export * from './workflows/google-workspace-agent/google-workspace-agent-example.workflow';
|
|
6
|
+
export * from './shared/github';
|
|
7
|
+
export * from './shared/google';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8DAA8D,CAAC;AAC7E,cAAc,wDAAwD,CAAC;AACvE,cAAc,8EAA8E,CAAC;AAC7F,cAAc,4EAA4E,CAAC;AAC3F,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./oauth-examples.module"), exports);
|
|
18
|
+
__exportStar(require("./workflows/github-overview/github-overview-example.workflow"), exports);
|
|
19
|
+
__exportStar(require("./workflows/github-agent/github-agent-example.workflow"), exports);
|
|
20
|
+
__exportStar(require("./workflows/google-calendar-summary/google-calendar-summary-example.workflow"), exports);
|
|
21
|
+
__exportStar(require("./workflows/google-workspace-agent/google-workspace-agent-example.workflow"), exports);
|
|
22
|
+
__exportStar(require("./shared/github"), exports);
|
|
23
|
+
__exportStar(require("./shared/google"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,+FAA6E;AAC7E,yFAAuE;AACvE,+GAA6F;AAC7F,6GAA2F;AAC3F,kDAAgC;AAChC,kDAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-examples.module.d.ts","sourceRoot":"","sources":["../src/oauth-examples.module.ts"],"names":[],"mappings":"AAoBA,qBASa,mBAAmB;CAAG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OAuthExamplesModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const claude_module_1 = require("@loopstack/claude-module");
|
|
12
|
+
const common_2 = require("@loopstack/common");
|
|
13
|
+
const github_module_1 = require("@loopstack/github-module");
|
|
14
|
+
const google_workspace_module_1 = require("@loopstack/google-workspace-module");
|
|
15
|
+
const authenticate_github_task_tool_1 = require("./shared/github/authenticate-github-task.tool");
|
|
16
|
+
const authenticate_google_task_tool_1 = require("./shared/google/authenticate-google-task.tool");
|
|
17
|
+
const google_calendar_fetch_events_tool_1 = require("./shared/google/google-calendar-fetch-events.tool");
|
|
18
|
+
const github_agent_example_workflow_1 = require("./workflows/github-agent/github-agent-example.workflow");
|
|
19
|
+
const github_overview_example_workflow_1 = require("./workflows/github-overview/github-overview-example.workflow");
|
|
20
|
+
const google_calendar_summary_example_workflow_1 = require("./workflows/google-calendar-summary/google-calendar-summary-example.workflow");
|
|
21
|
+
const google_workspace_agent_example_workflow_1 = require("./workflows/google-workspace-agent/google-workspace-agent-example.workflow");
|
|
22
|
+
const WORKFLOWS = [
|
|
23
|
+
github_overview_example_workflow_1.GithubOverviewExampleWorkflow,
|
|
24
|
+
github_agent_example_workflow_1.GithubAgentExampleWorkflow,
|
|
25
|
+
google_calendar_summary_example_workflow_1.GoogleCalendarSummaryExampleWorkflow,
|
|
26
|
+
google_workspace_agent_example_workflow_1.GoogleWorkspaceAgentExampleWorkflow,
|
|
27
|
+
];
|
|
28
|
+
let OAuthExamplesModule = class OAuthExamplesModule {
|
|
29
|
+
};
|
|
30
|
+
exports.OAuthExamplesModule = OAuthExamplesModule;
|
|
31
|
+
exports.OAuthExamplesModule = OAuthExamplesModule = __decorate([
|
|
32
|
+
(0, common_2.StudioApp)({
|
|
33
|
+
title: 'OAuth Examples',
|
|
34
|
+
workflows: WORKFLOWS,
|
|
35
|
+
}),
|
|
36
|
+
(0, common_1.Module)({
|
|
37
|
+
imports: [claude_module_1.ClaudeModule, github_module_1.GitHubModule, google_workspace_module_1.GoogleWorkspaceModule],
|
|
38
|
+
providers: [authenticate_github_task_tool_1.AuthenticateGitHubTask, authenticate_google_task_tool_1.AuthenticateGoogleTask, google_calendar_fetch_events_tool_1.GoogleCalendarFetchEventsTool, ...WORKFLOWS],
|
|
39
|
+
exports: [authenticate_github_task_tool_1.AuthenticateGitHubTask, authenticate_google_task_tool_1.AuthenticateGoogleTask, google_calendar_fetch_events_tool_1.GoogleCalendarFetchEventsTool, ...WORKFLOWS],
|
|
40
|
+
})
|
|
41
|
+
], OAuthExamplesModule);
|
|
42
|
+
//# sourceMappingURL=oauth-examples.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-examples.module.js","sourceRoot":"","sources":["../src/oauth-examples.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,4DAAwD;AACxD,8CAA8C;AAC9C,4DAAwD;AACxD,gFAA2E;AAC3E,iGAAuF;AACvF,iGAAuF;AACvF,yGAAkG;AAClG,0GAAoG;AACpG,mHAA6G;AAC7G,2IAAoI;AACpI,wIAAiI;AAEjI,MAAM,SAAS,GAAG;IAChB,gEAA6B;IAC7B,0DAA0B;IAC1B,+EAAoC;IACpC,6EAAmC;CACpC,CAAC;AAWK,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,kDAAmB;8BAAnB,mBAAmB;IAT/B,IAAA,kBAAS,EAAC;QACT,KAAK,EAAE,gBAAgB;QACvB,SAAS,EAAE,SAAS;KACrB,CAAC;IACD,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,EAAE,4BAAY,EAAE,+CAAqB,CAAC;QAC5D,SAAS,EAAE,CAAC,sDAAsB,EAAE,sDAAsB,EAAE,iEAA6B,EAAE,GAAG,SAAS,CAAC;QACxG,OAAO,EAAE,CAAC,sDAAsB,EAAE,sDAAsB,EAAE,iEAA6B,EAAE,GAAG,SAAS,CAAC;KACvG,CAAC;GACW,mBAAmB,CAAG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseTool, ToolCallOptions, ToolEnvelope } from '@loopstack/common';
|
|
3
|
+
import type { RunContext } from '@loopstack/common';
|
|
4
|
+
import { OAuthWorkflow } from '@loopstack/oauth-module';
|
|
5
|
+
declare const AuthenticateGitHubTaskInputSchema: z.ZodObject<{
|
|
6
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
7
|
+
callback: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
transition: z.ZodString;
|
|
9
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
type AuthenticateGitHubTaskInput = z.infer<typeof AuthenticateGitHubTaskInputSchema>;
|
|
13
|
+
export type AuthenticateGitHubTaskResult = {
|
|
14
|
+
workflowId: string;
|
|
15
|
+
mode: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
} | string;
|
|
18
|
+
export declare class AuthenticateGitHubTask extends BaseTool<AuthenticateGitHubTaskInput, object, AuthenticateGitHubTaskResult> {
|
|
19
|
+
private readonly oAuthWorkflow;
|
|
20
|
+
private readonly logger;
|
|
21
|
+
constructor(oAuthWorkflow: OAuthWorkflow);
|
|
22
|
+
protected handle(args: AuthenticateGitHubTaskInput, ctx: RunContext, options?: ToolCallOptions): Promise<ToolEnvelope<AuthenticateGitHubTaskResult>>;
|
|
23
|
+
complete(result: Record<string, unknown>): Promise<ToolEnvelope<AuthenticateGitHubTaskResult>>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=authenticate-github-task.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate-github-task.tool.d.ts","sourceRoot":"","sources":["../../../src/shared/github/authenticate-github-task.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAQ,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,QAAA,MAAM,iCAAiC;;;;;;kBAU5B,CAAC;AAEZ,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAErF,MAAM,MAAM,4BAA4B,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,MAAM,CAAC;AAEjH,qBASa,sBAAuB,SAAQ,QAAQ,CAClD,2BAA2B,EAC3B,MAAM,EACN,4BAA4B,CAC7B;IAGa,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;gBAErC,aAAa,EAAE,aAAa;cAIzC,MAAM,CACpB,IAAI,EAAE,2BAA2B,EACjC,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC;IAYhD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC;CAWrG"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
var AuthenticateGitHubTask_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AuthenticateGitHubTask = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
const AuthenticateGitHubTaskInputSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
scopes: zod_1.z.array(zod_1.z.string()).describe('The OAuth scopes to request (e.g. repo, user, workflow, read:org)'),
|
|
21
|
+
callback: zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
transition: zod_1.z.string(),
|
|
24
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
25
|
+
})
|
|
26
|
+
.optional(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
let AuthenticateGitHubTask = AuthenticateGitHubTask_1 = class AuthenticateGitHubTask extends common_2.BaseTool {
|
|
30
|
+
oAuthWorkflow;
|
|
31
|
+
logger = new common_1.Logger(AuthenticateGitHubTask_1.name);
|
|
32
|
+
constructor(oAuthWorkflow) {
|
|
33
|
+
super();
|
|
34
|
+
this.oAuthWorkflow = oAuthWorkflow;
|
|
35
|
+
}
|
|
36
|
+
async handle(args, ctx, options) {
|
|
37
|
+
const result = await this.oAuthWorkflow.run({ provider: 'github', scopes: args.scopes }, { callback: options?.callback ?? args.callback, show: 'inline', label: 'GitHub authentication required' });
|
|
38
|
+
return {
|
|
39
|
+
data: { ...result, mode: 'async' },
|
|
40
|
+
pending: { workflowId: result.workflowId },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async complete(result) {
|
|
44
|
+
const status = result.status;
|
|
45
|
+
if (status === 'failed' || status === 'canceled') {
|
|
46
|
+
const detail = result.errorMessage ?? `Sub-workflow ${status}`;
|
|
47
|
+
const message = `GitHub authentication ${status}: ${detail}`;
|
|
48
|
+
return { data: message, error: message };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
data: 'GitHub authentication completed successfully. You can now use GitHub tools.',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.AuthenticateGitHubTask = AuthenticateGitHubTask;
|
|
56
|
+
exports.AuthenticateGitHubTask = AuthenticateGitHubTask = AuthenticateGitHubTask_1 = __decorate([
|
|
57
|
+
(0, common_2.Tool)({
|
|
58
|
+
name: 'authenticate_github',
|
|
59
|
+
description: 'Launches GitHub OAuth authentication. Shows the user a sign-in prompt to authorize access to GitHub. ' +
|
|
60
|
+
'Use this when a GitHub tool returns an "unauthorized" error. ' +
|
|
61
|
+
'Pass the required OAuth scopes for the GitHub APIs you need access to. ' +
|
|
62
|
+
'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
|
|
63
|
+
schema: AuthenticateGitHubTaskInputSchema,
|
|
64
|
+
}),
|
|
65
|
+
__metadata("design:paramtypes", [oauth_module_1.OAuthWorkflow])
|
|
66
|
+
], AuthenticateGitHubTask);
|
|
67
|
+
//# sourceMappingURL=authenticate-github-task.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate-github-task.tool.js","sourceRoot":"","sources":["../../../src/shared/github/authenticate-github-task.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAkF;AAElF,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,iBAI3C;IAG8B;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAElE,YAA6B,aAA4B;QACvD,KAAK,EAAE,CAAC;QADmB,kBAAa,GAAb,aAAa,CAAe;IAEzD,CAAC;IAES,KAAK,CAAC,MAAM,CACpB,IAAiC,EACjC,GAAe,EACf,OAAyB;QAEzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CACzC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAC3C,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,gCAAgC,EAAE,CAC1G,CAAC;QAEF,OAAO;YACL,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;YAClC,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;SAC3C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAA+B;QAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAA4B,CAAC;QACnD,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;YACjD,MAAM,MAAM,GAAI,MAAM,CAAC,YAAmC,IAAI,gBAAgB,MAAM,EAAE,CAAC;YACvF,MAAM,OAAO,GAAG,yBAAyB,MAAM,KAAK,MAAM,EAAE,CAAC;YAC7D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO;YACL,IAAI,EAAE,6EAA6E;SACpF,CAAC;IACJ,CAAC;CACF,CAAA;AAtCY,wDAAsB;iCAAtB,sBAAsB;IATlC,IAAA,aAAI,EAAC;QACJ,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,uGAAuG;YACvG,+DAA+D;YAC/D,yEAAyE;YACzE,2HAA2H;QAC7H,MAAM,EAAE,iCAAiC;KAC1C,CAAC;qCAQ4C,4BAAa;GAP9C,sBAAsB,CAsClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/github/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./authenticate-github-task.tool"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/github/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseTool, ToolCallOptions, ToolEnvelope } from '@loopstack/common';
|
|
3
|
+
import type { RunContext } from '@loopstack/common';
|
|
4
|
+
import { OAuthWorkflow } from '@loopstack/oauth-module';
|
|
5
|
+
declare const AuthenticateGoogleTaskInputSchema: z.ZodObject<{
|
|
6
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
7
|
+
callback: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
transition: z.ZodString;
|
|
9
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
type AuthenticateGoogleTaskInput = z.infer<typeof AuthenticateGoogleTaskInputSchema>;
|
|
13
|
+
export type AuthenticateGoogleTaskResult = {
|
|
14
|
+
workflowId: string;
|
|
15
|
+
mode: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
} | string;
|
|
18
|
+
export declare class AuthenticateGoogleTask extends BaseTool<AuthenticateGoogleTaskInput, object, AuthenticateGoogleTaskResult> {
|
|
19
|
+
private readonly oAuthWorkflow;
|
|
20
|
+
private readonly logger;
|
|
21
|
+
constructor(oAuthWorkflow: OAuthWorkflow);
|
|
22
|
+
protected handle(args: AuthenticateGoogleTaskInput, ctx: RunContext, options?: ToolCallOptions): Promise<ToolEnvelope<AuthenticateGoogleTaskResult>>;
|
|
23
|
+
complete(result: Record<string, unknown>): Promise<ToolEnvelope<AuthenticateGoogleTaskResult>>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=authenticate-google-task.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate-google-task.tool.d.ts","sourceRoot":"","sources":["../../../src/shared/google/authenticate-google-task.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAQ,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,QAAA,MAAM,iCAAiC;;;;;;kBAY5B,CAAC;AAEZ,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAErF,MAAM,MAAM,4BAA4B,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,MAAM,CAAC;AAEjH,qBASa,sBAAuB,SAAQ,QAAQ,CAClD,2BAA2B,EAC3B,MAAM,EACN,4BAA4B,CAC7B;IAGa,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;gBAErC,aAAa,EAAE,aAAa;cAIzC,MAAM,CACpB,IAAI,EAAE,2BAA2B,EACjC,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC;IAYhD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC;CAWrG"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
var AuthenticateGoogleTask_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AuthenticateGoogleTask = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
const AuthenticateGoogleTaskInputSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
scopes: zod_1.z
|
|
21
|
+
.array(zod_1.z.string())
|
|
22
|
+
.describe('The OAuth scopes to request (e.g. https://www.googleapis.com/auth/calendar.events)'),
|
|
23
|
+
callback: zod_1.z
|
|
24
|
+
.object({
|
|
25
|
+
transition: zod_1.z.string(),
|
|
26
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
29
|
+
})
|
|
30
|
+
.strict();
|
|
31
|
+
let AuthenticateGoogleTask = AuthenticateGoogleTask_1 = class AuthenticateGoogleTask extends common_2.BaseTool {
|
|
32
|
+
oAuthWorkflow;
|
|
33
|
+
logger = new common_1.Logger(AuthenticateGoogleTask_1.name);
|
|
34
|
+
constructor(oAuthWorkflow) {
|
|
35
|
+
super();
|
|
36
|
+
this.oAuthWorkflow = oAuthWorkflow;
|
|
37
|
+
}
|
|
38
|
+
async handle(args, ctx, options) {
|
|
39
|
+
const result = await this.oAuthWorkflow.run({ provider: 'google', scopes: args.scopes }, { callback: options?.callback ?? args.callback, show: 'inline', label: 'Google authentication required' });
|
|
40
|
+
return {
|
|
41
|
+
data: { ...result, mode: 'async' },
|
|
42
|
+
pending: { workflowId: result.workflowId },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async complete(result) {
|
|
46
|
+
const status = result.status;
|
|
47
|
+
if (status === 'failed' || status === 'canceled') {
|
|
48
|
+
const detail = result.errorMessage ?? `Sub-workflow ${status}`;
|
|
49
|
+
const message = `Google authentication ${status}: ${detail}`;
|
|
50
|
+
return { data: message, error: message };
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
data: 'Google authentication completed successfully. You can now use Google Workspace tools.',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.AuthenticateGoogleTask = AuthenticateGoogleTask;
|
|
58
|
+
exports.AuthenticateGoogleTask = AuthenticateGoogleTask = AuthenticateGoogleTask_1 = __decorate([
|
|
59
|
+
(0, common_2.Tool)({
|
|
60
|
+
name: 'authenticate_google',
|
|
61
|
+
description: 'Launches Google OAuth authentication. Shows the user a sign-in prompt to authorize access to Google services. ' +
|
|
62
|
+
'Use this when a Google tool returns an "unauthorized" error. ' +
|
|
63
|
+
'Pass the required OAuth scopes for the Google APIs you need access to. ' +
|
|
64
|
+
'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
|
|
65
|
+
schema: AuthenticateGoogleTaskInputSchema,
|
|
66
|
+
}),
|
|
67
|
+
__metadata("design:paramtypes", [oauth_module_1.OAuthWorkflow])
|
|
68
|
+
], AuthenticateGoogleTask);
|
|
69
|
+
//# sourceMappingURL=authenticate-google-task.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate-google-task.tool.js","sourceRoot":"","sources":["../../../src/shared/google/authenticate-google-task.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAkF;AAElF,0DAAwD;AAExD,MAAM,iCAAiC,GAAG,OAAC;KACxC,MAAM,CAAC;IACN,MAAM,EAAE,OAAC;SACN,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,CAAC,oFAAoF,CAAC;IACjG,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,iBAI3C;IAG8B;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAElE,YAA6B,aAA4B;QACvD,KAAK,EAAE,CAAC;QADmB,kBAAa,GAAb,aAAa,CAAe;IAEzD,CAAC;IAES,KAAK,CAAC,MAAM,CACpB,IAAiC,EACjC,GAAe,EACf,OAAyB;QAEzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CACzC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAC3C,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,gCAAgC,EAAE,CAC1G,CAAC;QAEF,OAAO;YACL,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;YAClC,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;SAC3C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAA+B;QAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAA4B,CAAC;QACnD,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;YACjD,MAAM,MAAM,GAAI,MAAM,CAAC,YAAmC,IAAI,gBAAgB,MAAM,EAAE,CAAC;YACvF,MAAM,OAAO,GAAG,yBAAyB,MAAM,KAAK,MAAM,EAAE,CAAC;YAC7D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO;YACL,IAAI,EAAE,uFAAuF;SAC9F,CAAC;IACJ,CAAC;CACF,CAAA;AAtCY,wDAAsB;iCAAtB,sBAAsB;IATlC,IAAA,aAAI,EAAC;QACJ,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,gHAAgH;YAChH,+DAA+D;YAC/D,yEAAyE;YACzE,2HAA2H;QAC7H,MAAM,EAAE,iCAAiC;KAC1C,CAAC;qCAQ4C,4BAAa;GAP9C,sBAAsB,CAsClC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseTool, ToolEnvelope } from '@loopstack/common';
|
|
3
|
+
import type { RunContext } from '@loopstack/common';
|
|
4
|
+
import { OAuthTokenStore } from '@loopstack/oauth-module';
|
|
5
|
+
declare const GoogleCalendarFetchEventsSchema: z.ZodObject<{
|
|
6
|
+
timeMin: z.ZodString;
|
|
7
|
+
timeMax: z.ZodString;
|
|
8
|
+
calendarId: z.ZodDefault<z.ZodString>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
type GoogleCalendarFetchEventsArgs = z.infer<typeof GoogleCalendarFetchEventsSchema>;
|
|
11
|
+
export type GoogleCalendarFetchEventsResult = {
|
|
12
|
+
error?: string;
|
|
13
|
+
message?: string;
|
|
14
|
+
events?: {
|
|
15
|
+
id: string;
|
|
16
|
+
summary: string;
|
|
17
|
+
start: string | undefined;
|
|
18
|
+
end: string | undefined;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
export declare class GoogleCalendarFetchEventsTool extends BaseTool<GoogleCalendarFetchEventsArgs, object, GoogleCalendarFetchEventsResult> {
|
|
22
|
+
private readonly tokenStore;
|
|
23
|
+
private readonly logger;
|
|
24
|
+
constructor(tokenStore: OAuthTokenStore);
|
|
25
|
+
protected handle(args: GoogleCalendarFetchEventsArgs, ctx: RunContext): Promise<ToolEnvelope<GoogleCalendarFetchEventsResult>>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=google-calendar-fetch-events.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-calendar-fetch-events.tool.d.ts","sourceRoot":"","sources":["../../../src/shared/google/google-calendar-fetch-events.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAQ,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,QAAA,MAAM,+BAA+B;;;;kBAM1B,CAAC;AAEZ,KAAK,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAErF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,EAAE,CAAC;CAChG,CAAC;AAaF,qBAKa,6BAA8B,SAAQ,QAAQ,CACzD,6BAA6B,EAC7B,MAAM,EACN,+BAA+B,CAChC;IAGa,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkD;gBAE5C,UAAU,EAAE,eAAe;cAIxC,MAAM,CACpB,IAAI,EAAE,6BAA6B,EACnC,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,YAAY,CAAC,+BAA+B,CAAC,CAAC;CAgE1D"}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
var GoogleCalendarFetchEventsTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GoogleCalendarFetchEventsTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const oauth_module_1 = require("@loopstack/oauth-module");
|
|
18
|
+
const GoogleCalendarFetchEventsSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
timeMin: zod_1.z.string(),
|
|
21
|
+
timeMax: zod_1.z.string(),
|
|
22
|
+
calendarId: zod_1.z.string().default('primary'),
|
|
23
|
+
})
|
|
24
|
+
.strict();
|
|
25
|
+
let GoogleCalendarFetchEventsTool = GoogleCalendarFetchEventsTool_1 = class GoogleCalendarFetchEventsTool extends common_2.BaseTool {
|
|
26
|
+
tokenStore;
|
|
27
|
+
logger = new common_1.Logger(GoogleCalendarFetchEventsTool_1.name);
|
|
28
|
+
constructor(tokenStore) {
|
|
29
|
+
super();
|
|
30
|
+
this.tokenStore = tokenStore;
|
|
31
|
+
}
|
|
32
|
+
async handle(args, ctx) {
|
|
33
|
+
const accessToken = await this.tokenStore.getValidAccessToken(ctx.userId, 'google');
|
|
34
|
+
if (!accessToken) {
|
|
35
|
+
return {
|
|
36
|
+
data: {
|
|
37
|
+
error: 'unauthorized',
|
|
38
|
+
message: 'No valid Google token found. Please authenticate first.',
|
|
39
|
+
},
|
|
40
|
+
error: 'No valid Google token found. Please authenticate first.',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const calendarId = args.calendarId || 'primary';
|
|
44
|
+
const params = new URLSearchParams({
|
|
45
|
+
timeMin: args.timeMin,
|
|
46
|
+
timeMax: args.timeMax,
|
|
47
|
+
singleEvents: 'true',
|
|
48
|
+
orderBy: 'startTime',
|
|
49
|
+
});
|
|
50
|
+
const response = await fetch(`https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}/events?${params.toString()}`, {
|
|
51
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
52
|
+
});
|
|
53
|
+
if (response.status === 401 || response.status === 403) {
|
|
54
|
+
this.logger.warn(`Google Calendar API returned ${response.status} for user ${ctx.userId}`);
|
|
55
|
+
return {
|
|
56
|
+
data: {
|
|
57
|
+
error: '401',
|
|
58
|
+
message: 'Google token was rejected. Please re-authenticate.',
|
|
59
|
+
},
|
|
60
|
+
error: 'Google token was rejected. Please re-authenticate.',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
const body = await response.text();
|
|
65
|
+
this.logger.error(`Google Calendar API error: ${response.status} ${body}`);
|
|
66
|
+
console.log('api_error', response.statusText);
|
|
67
|
+
return {
|
|
68
|
+
data: {
|
|
69
|
+
error: 'api_error',
|
|
70
|
+
message: `Google Calendar API error: ${response.statusText}`,
|
|
71
|
+
},
|
|
72
|
+
error: `Google Calendar API error: ${response.statusText}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const data = (await response.json());
|
|
76
|
+
const events = data.items.map((event) => ({
|
|
77
|
+
id: event.id,
|
|
78
|
+
summary: event.summary,
|
|
79
|
+
start: event.start.dateTime || event.start.date,
|
|
80
|
+
end: event.end.dateTime || event.end.date,
|
|
81
|
+
}));
|
|
82
|
+
return {
|
|
83
|
+
data: { events },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.GoogleCalendarFetchEventsTool = GoogleCalendarFetchEventsTool;
|
|
88
|
+
exports.GoogleCalendarFetchEventsTool = GoogleCalendarFetchEventsTool = GoogleCalendarFetchEventsTool_1 = __decorate([
|
|
89
|
+
(0, common_2.Tool)({
|
|
90
|
+
name: 'google_calendar_fetch_events',
|
|
91
|
+
description: 'Fetches events from Google Calendar. Returns { error: "unauthorized" } if no valid token is available.',
|
|
92
|
+
schema: GoogleCalendarFetchEventsSchema,
|
|
93
|
+
}),
|
|
94
|
+
__metadata("design:paramtypes", [oauth_module_1.OAuthTokenStore])
|
|
95
|
+
], GoogleCalendarFetchEventsTool);
|
|
96
|
+
//# sourceMappingURL=google-calendar-fetch-events.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-calendar-fetch-events.tool.js","sourceRoot":"","sources":["../../../src/shared/google/google-calendar-fetch-events.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAiE;AAEjE,0DAA0D;AAE1D,MAAM,+BAA+B,GAAG,OAAC;KACtC,MAAM,CAAC;IACN,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;CAC1C,CAAC;KACD,MAAM,EAAE,CAAC;AA0BL,IAAM,6BAA6B,qCAAnC,MAAM,6BAA8B,SAAQ,iBAIlD;IAG8B;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,+BAA6B,CAAC,IAAI,CAAC,CAAC;IAEzE,YAA6B,UAA2B;QACtD,KAAK,EAAE,CAAC;QADmB,eAAU,GAAV,UAAU,CAAiB;IAExD,CAAC;IAES,KAAK,CAAC,MAAM,CACpB,IAAmC,EACnC,GAAe;QAEf,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEpF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,cAAc;oBACrB,OAAO,EAAE,yDAAyD;iBACnE;gBACD,KAAK,EAAE,yDAAyD;aACjE,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE,WAAW;SACrB,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,oDAAoD,kBAAkB,CAAC,UAAU,CAAC,WAAW,MAAM,CAAC,QAAQ,EAAE,EAAE,EAChH;YACE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE;SACpD,CACF,CAAC;QAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,QAAQ,CAAC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3F,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,KAAK;oBACZ,OAAO,EAAE,oDAAoD;iBAC9D;gBACD,KAAK,EAAE,oDAAoD;aAC5D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3E,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC9C,OAAO;gBACL,IAAI,EAAE;oBACJ,KAAK,EAAE,WAAW;oBAClB,OAAO,EAAE,8BAA8B,QAAQ,CAAC,UAAU,EAAE;iBAC7D;gBACD,KAAK,EAAE,8BAA8B,QAAQ,CAAC,UAAU,EAAE;aAC3D,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAA+B,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA+B,CAAC;QAC/F,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACxC,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI;YAC/C,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI;SAC1C,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,IAAI,EAAE,EAAE,MAAM,EAAE;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AA9EY,sEAA6B;wCAA7B,6BAA6B;IALzC,IAAA,aAAI,EAAC;QACJ,IAAI,EAAE,8BAA8B;QACpC,WAAW,EAAE,wGAAwG;QACrH,MAAM,EAAE,+BAA+B;KACxC,CAAC;qCAQyC,8BAAe;GAP7C,6BAA6B,CA8EzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/google/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./authenticate-google-task.tool"), exports);
|
|
18
|
+
__exportStar(require("./google-calendar-fetch-events.tool"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/google/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,sEAAoD"}
|