chat-agent-toolkit 1.2.72 → 1.2.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connectors/index.d.ts +84 -0
- package/dist/connectors/server.d.ts +46 -0
- package/dist/connectors/smoke-test.d.ts +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/research-agent.cjs.js +1 -1
- package/dist/research-agent.cjs.js.map +1 -1
- package/dist/research-agent.es.js +1 -1
- package/dist/research-agent.es.js.map +1 -1
- package/package.json +13 -2
- package/src/connectors/README.md +374 -0
- package/src/connectors/catalog.json +1 -0
- package/src/connectors/index.ts +128 -0
- package/src/connectors/oomol-saas-server.js +125 -0
- package/src/connectors/package-lock.json +872 -0
- package/src/connectors/package.json +19 -0
- package/src/connectors/server.js +125 -0
- package/src/connectors/server.ts +220 -0
- package/src/connectors/smoke-test.js +14 -0
- package/src/connectors/smoke-test.ts +44 -0
- package/src/index.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chat-agent-toolkit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.74",
|
|
4
4
|
"description": "Multi-provider AI agent toolkit: generate language responses, search the web, extract content, and manage memory across 10+ LLM providers.",
|
|
5
5
|
"author": "vtempest <grokthiscontact@gmail.com>",
|
|
6
6
|
"license": "rights.institute/PROSPER",
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"import": "./dist/research-agent.es.js",
|
|
21
21
|
"require": "./dist/research-agent.cjs.js"
|
|
22
22
|
},
|
|
23
|
+
"./connectors": {
|
|
24
|
+
"types": "./src/connectors/index.ts",
|
|
25
|
+
"import": "./src/connectors/index.ts",
|
|
26
|
+
"require": "./src/connectors/index.ts"
|
|
27
|
+
},
|
|
23
28
|
"./*": {
|
|
24
29
|
"types": "./src/*.ts",
|
|
25
30
|
"react-server": "./src/*",
|
|
@@ -36,7 +41,9 @@
|
|
|
36
41
|
},
|
|
37
42
|
"files": [
|
|
38
43
|
"dist",
|
|
39
|
-
"src"
|
|
44
|
+
"src",
|
|
45
|
+
"src/connectors/*.json",
|
|
46
|
+
"src/connectors/server.ts"
|
|
40
47
|
],
|
|
41
48
|
"sideEffects": false,
|
|
42
49
|
"scripts": {
|
|
@@ -70,6 +77,10 @@
|
|
|
70
77
|
"vite-plugin-node-polyfills": "^0.28.0",
|
|
71
78
|
"vitest": "^4.0.18"
|
|
72
79
|
},
|
|
80
|
+
"optionalDependencies": {
|
|
81
|
+
"@oomol-lab/connector": "^1.0.0",
|
|
82
|
+
"express": "^5.2.1"
|
|
83
|
+
},
|
|
73
84
|
"dependencies": {
|
|
74
85
|
"@ai-sdk/anthropic": "^2.0.0",
|
|
75
86
|
"@ai-sdk/google": "^2.0.0",
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
# OpenConnector Integration
|
|
2
|
+
|
|
3
|
+
Multi-tenant OAuth & credential management for your agent toolkit. Securely link 900+ external services (Gmail, Slack, GitHub, Airtable, Stripe, etc.) on behalf of your users.
|
|
4
|
+
|
|
5
|
+
Built on [OOMOL Cloud](https://connector.oomol.com) — OAuth apps, token refresh, and credential vault managed by OOMOL, not your infrastructure.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
### As a Client (Importing from agent-toolkit)
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import {
|
|
13
|
+
ProjectConnector,
|
|
14
|
+
catalog,
|
|
15
|
+
searchCatalog,
|
|
16
|
+
getCatalogByAuthType,
|
|
17
|
+
} from "chat-agent-toolkit/connectors";
|
|
18
|
+
|
|
19
|
+
// Search available providers
|
|
20
|
+
const gmailProviders = searchCatalog("gmail");
|
|
21
|
+
const oauthProviders = getCatalogByAuthType("oauth2");
|
|
22
|
+
|
|
23
|
+
console.log(oauthProviders.slice(0, 5).map((p) => p.displayName));
|
|
24
|
+
// → ["Airtable", "Calendly", "Discord", "Dropbox", "Gmail"]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### As a Server Runtime (Running the connector server)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cd packages/agent-toolkit/src/connectors
|
|
31
|
+
|
|
32
|
+
# Install dependencies
|
|
33
|
+
npm install
|
|
34
|
+
|
|
35
|
+
# Start the server
|
|
36
|
+
OOMOL_PROJECT_API_KEY=oo_proj_... npm start
|
|
37
|
+
|
|
38
|
+
# Server runs on http://localhost:8787
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then make API calls from your frontend:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// POST /api/connections (start OAuth for Gmail)
|
|
45
|
+
const response = await fetch("http://localhost:8787/api/connections", {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: { "Content-Type": "application/json" },
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
service: "gmail",
|
|
50
|
+
connectionName: "My Work Email",
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const { authorizationUrl, requestId } = await response.json();
|
|
55
|
+
// Redirect user to authorizationUrl
|
|
56
|
+
// Then poll GET /api/connections/requests/{requestId} until connected
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Module Exports
|
|
60
|
+
|
|
61
|
+
### Utilities
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import {
|
|
65
|
+
// Re-exported from @oomol-lab/connector
|
|
66
|
+
ProjectConnector,
|
|
67
|
+
ConnectorError,
|
|
68
|
+
|
|
69
|
+
// Catalog data
|
|
70
|
+
catalog, // Basic provider info (900+ entries)
|
|
71
|
+
providerIndex, // Detailed provider info with action lists
|
|
72
|
+
|
|
73
|
+
// Search & filter functions
|
|
74
|
+
searchCatalog,
|
|
75
|
+
getCatalogProvider,
|
|
76
|
+
getProviderDetails,
|
|
77
|
+
getCatalogByAuthType,
|
|
78
|
+
getCatalogByCategory,
|
|
79
|
+
getCatalogCategories,
|
|
80
|
+
} from "chat-agent-toolkit/connectors";
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Server
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// Node.js runtime only — not for browser code
|
|
87
|
+
import { app, server } from "chat-agent-toolkit/connectors/server";
|
|
88
|
+
|
|
89
|
+
// Use express app in your own middleware stack
|
|
90
|
+
const myApp = express();
|
|
91
|
+
myApp.use("/oomol", app);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## API Endpoints (Server)
|
|
95
|
+
|
|
96
|
+
### GET /api/catalog
|
|
97
|
+
|
|
98
|
+
List or search providers.
|
|
99
|
+
|
|
100
|
+
**Query Parameters:**
|
|
101
|
+
- `q` (string, optional): Search term (case-insensitive)
|
|
102
|
+
- `limit` (number, default: 100): Max results
|
|
103
|
+
|
|
104
|
+
**Response:**
|
|
105
|
+
```json
|
|
106
|
+
[
|
|
107
|
+
{
|
|
108
|
+
"service": "gmail",
|
|
109
|
+
"displayName": "Gmail",
|
|
110
|
+
"categories": ["Productivity"],
|
|
111
|
+
"authTypes": ["oauth2"],
|
|
112
|
+
"actionCount": 46
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### POST /api/connections
|
|
118
|
+
|
|
119
|
+
Start a connection for the logged-in user.
|
|
120
|
+
|
|
121
|
+
**Request Body:**
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"service": "gmail",
|
|
125
|
+
"connectionName": "My Work Email",
|
|
126
|
+
"apiKey": "sk_...", // For API-key auth
|
|
127
|
+
"values": {...} // For custom credential auth
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**OAuth Response (pending):**
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"pending": true,
|
|
135
|
+
"requestId": "conn_req_abc123",
|
|
136
|
+
"authorizationUrl": "https://accounts.google.com/o/oauth2/auth?...",
|
|
137
|
+
"status": "initiated"
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**API-key Response (synchronous):**
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"pending": false,
|
|
145
|
+
"connectedAccountId": "conn_abc123",
|
|
146
|
+
"status": "connected",
|
|
147
|
+
"available": true
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### GET /api/connections/requests/:id
|
|
152
|
+
|
|
153
|
+
Poll OAuth connection status.
|
|
154
|
+
|
|
155
|
+
**Response:**
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"status": "connected", // initiated | connected | failed | expired
|
|
159
|
+
"connectedAccountId": "conn_...",
|
|
160
|
+
"available": true
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### POST /api/actions/:actionId
|
|
165
|
+
|
|
166
|
+
Execute a provider action (e.g., "gmail.search_threads").
|
|
167
|
+
|
|
168
|
+
**Request Body:**
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"input": {
|
|
172
|
+
"query": "from:boss subject:urgent",
|
|
173
|
+
"maxResults": 10
|
|
174
|
+
},
|
|
175
|
+
"connectionName": "My Work Email" // Optional, if user has multiple connections
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Response:**
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"data": [...],
|
|
183
|
+
"executionId": "exec_xyz",
|
|
184
|
+
"actionId": "gmail.search_threads",
|
|
185
|
+
"message": "Success"
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Architecture
|
|
190
|
+
|
|
191
|
+
### Client Side (Browser)
|
|
192
|
+
|
|
193
|
+
1. Import utilities from agent-toolkit
|
|
194
|
+
2. Search/display catalog to user
|
|
195
|
+
3. Call `/api/connections` to start auth flow
|
|
196
|
+
4. For OAuth: redirect user to `authorizationUrl`
|
|
197
|
+
5. After user authorizes, poll `/api/connections/requests/{requestId}`
|
|
198
|
+
6. Once connected, call `/api/actions/{actionId}` to execute actions
|
|
199
|
+
|
|
200
|
+
### Server Side (Node.js)
|
|
201
|
+
|
|
202
|
+
1. Express server handles OAuth callbacks
|
|
203
|
+
2. Credentials stored encrypted in OOMOL Cloud vault
|
|
204
|
+
3. Token refresh handled by OOMOL
|
|
205
|
+
4. Your app calls `/api/actions/...` on behalf of users
|
|
206
|
+
5. OOMOL makes the actual provider API calls
|
|
207
|
+
|
|
208
|
+
### OOMOL Cloud
|
|
209
|
+
|
|
210
|
+
- Hosts OAuth apps (client IDs, secrets)
|
|
211
|
+
- Stores encrypted credentials
|
|
212
|
+
- Refreshes OAuth tokens
|
|
213
|
+
- Rate-limits & retries provider calls
|
|
214
|
+
- Provides audit logs
|
|
215
|
+
|
|
216
|
+
## Security
|
|
217
|
+
|
|
218
|
+
### Session User ID
|
|
219
|
+
|
|
220
|
+
The server **trusts** `req.userId` to identify the logged-in user. It uses this to scope credentials and actions.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
// DEMO (insecure): dev-only, uses x-user-id header
|
|
224
|
+
app.use((req, _res, next) => {
|
|
225
|
+
req.userId = req.get("x-user-id") ?? "demo_user";
|
|
226
|
+
next();
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**In production**, derive `req.userId` from your auth system:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import passport from "passport";
|
|
234
|
+
|
|
235
|
+
app.use(passport.initialize());
|
|
236
|
+
app.use(passport.session());
|
|
237
|
+
|
|
238
|
+
// After passport middleware:
|
|
239
|
+
app.use((req, _res, next) => {
|
|
240
|
+
if (!req.user) return res.status(401).json({ error: "unauthorized" });
|
|
241
|
+
req.userId = req.user.id; // Your app's user ID
|
|
242
|
+
next();
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Never Trust Client
|
|
247
|
+
|
|
248
|
+
- Don't let clients pick their own user ID
|
|
249
|
+
- Don't pass user ID in request body or query params
|
|
250
|
+
- Always derive from authenticated session server-side
|
|
251
|
+
|
|
252
|
+
## Catalog Data
|
|
253
|
+
|
|
254
|
+
Two JSON files ship with the module:
|
|
255
|
+
|
|
256
|
+
1. **catalog.json** (~150 KB)
|
|
257
|
+
- Basic info: service ID, display name, auth types, action count
|
|
258
|
+
- Use for fast provider pickers
|
|
259
|
+
- Search/filter with `searchCatalog()`
|
|
260
|
+
|
|
261
|
+
2. **openconnector-providers-index.json** (~600 KB)
|
|
262
|
+
- Detailed: homepage URL, action list, categories
|
|
263
|
+
- Use for detailed provider pages
|
|
264
|
+
- Access with `getProviderDetails()`
|
|
265
|
+
|
|
266
|
+
Both are pre-filtered from OOMOL's master catalog (~900 providers).
|
|
267
|
+
|
|
268
|
+
## Environment Variables
|
|
269
|
+
|
|
270
|
+
When running the server:
|
|
271
|
+
|
|
272
|
+
| Variable | Default | Description |
|
|
273
|
+
| --- | --- | --- |
|
|
274
|
+
| `OOMOL_PROJECT_API_KEY` | N/A | Your OOMOL project API key (required) |
|
|
275
|
+
| `PORT` | `8787` | Server port |
|
|
276
|
+
| `APP_ORIGIN` | `http://localhost:8787` | Your app's origin (for OAuth redirect) |
|
|
277
|
+
|
|
278
|
+
## Error Handling
|
|
279
|
+
|
|
280
|
+
OOMOL returns structured error responses:
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"error": "provider_config_not_found",
|
|
285
|
+
"message": "The OAuth app for 'slack' is not configured in your OOMOL project."
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Common error codes:
|
|
290
|
+
- `provider_config_not_found` — OAuth app not set up in OOMOL console
|
|
291
|
+
- `connection_alias_conflict` — Connection name already used by this user
|
|
292
|
+
- `app_not_ready` — OOMOL project not fully set up
|
|
293
|
+
- `client_wait_timeout` — User didn't complete OAuth in time
|
|
294
|
+
- `invalid_action_id` — Action doesn't exist for this provider
|
|
295
|
+
|
|
296
|
+
## Example: Complete Flow
|
|
297
|
+
|
|
298
|
+
### Frontend
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
// 1. Search for Gmail
|
|
302
|
+
import { searchCatalog } from "chat-agent-toolkit/connectors";
|
|
303
|
+
const providers = searchCatalog("gmail");
|
|
304
|
+
|
|
305
|
+
// 2. Display to user, user clicks "Connect Gmail"
|
|
306
|
+
// 3. Call backend to start OAuth
|
|
307
|
+
const res = await fetch("/api/connections", {
|
|
308
|
+
method: "POST",
|
|
309
|
+
body: JSON.stringify({ service: "gmail", connectionName: "Gmail" }),
|
|
310
|
+
});
|
|
311
|
+
const { authorizationUrl, requestId } = await res.json();
|
|
312
|
+
|
|
313
|
+
// 4. Redirect user to Google's OAuth consent screen
|
|
314
|
+
window.location.href = authorizationUrl;
|
|
315
|
+
|
|
316
|
+
// 5. After user consents, they return to /connected
|
|
317
|
+
// 6. Poll backend to check if connection succeeded
|
|
318
|
+
while (true) {
|
|
319
|
+
const status = await fetch(`/api/connections/requests/${requestId}`);
|
|
320
|
+
const { status: connStatus } = await status.json();
|
|
321
|
+
if (connStatus === "connected") break;
|
|
322
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// 7. Now you can call actions
|
|
326
|
+
const messages = await fetch("/api/actions/gmail.search_threads", {
|
|
327
|
+
method: "POST",
|
|
328
|
+
body: JSON.stringify({
|
|
329
|
+
input: { query: "from:boss" },
|
|
330
|
+
connectionName: "Gmail",
|
|
331
|
+
}),
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Backend (Node.js)
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
import express from "express";
|
|
339
|
+
import { app as connectorApp } from "chat-agent-toolkit/connectors/server";
|
|
340
|
+
|
|
341
|
+
const app = express();
|
|
342
|
+
|
|
343
|
+
// Your auth middleware
|
|
344
|
+
app.use(authMiddleware);
|
|
345
|
+
|
|
346
|
+
// Mount connector server
|
|
347
|
+
app.use("/oomol", connectorApp);
|
|
348
|
+
|
|
349
|
+
// Your routes
|
|
350
|
+
app.post("/api/send-email", async (req, res) => {
|
|
351
|
+
const { to, subject, body } = req.body;
|
|
352
|
+
const result = await fetch("http://localhost:8787/api/actions/gmail.send", {
|
|
353
|
+
method: "POST",
|
|
354
|
+
body: JSON.stringify({
|
|
355
|
+
input: { to, subject, body },
|
|
356
|
+
connectionName: req.user.gmailConnection,
|
|
357
|
+
}),
|
|
358
|
+
});
|
|
359
|
+
res.json(await result.json());
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
app.listen(3000);
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Links
|
|
366
|
+
|
|
367
|
+
- [OOMOL Documentation](https://docs.oomol.com)
|
|
368
|
+
- [Connector SDK Reference](https://docs.oomol.com/connector-sdk)
|
|
369
|
+
- [Provider Catalog](https://connector.oomol.com/catalog)
|
|
370
|
+
|
|
371
|
+
## License
|
|
372
|
+
|
|
373
|
+
Part of [chat-agent-toolkit](https://github.com/opensourceagi/qwksearch-research-agent).
|
|
374
|
+
Licensed under PROSPER (rights.institute/PROSPER).
|