openloops 0.7.0 → 0.7.3
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/CHANGELOG.md +22 -0
- package/dist/db/indexes/mcp-servers.js +2 -1
- package/dist/db/indexes/mcp-servers.mjs +2 -1
- package/dist/harness/agent.d.ts +1 -2
- package/dist/harness/agent.js +15 -9
- package/dist/harness/agent.mjs +15 -9
- package/dist/services/automations/runner/automation-runner.js +1 -3
- package/dist/services/automations/runner/automation-runner.mjs +1 -3
- package/dist/services/mcp-servers/admin/index.d.ts +1 -0
- package/dist/services/mcp-servers/admin/index.js +22 -0
- package/dist/services/mcp-servers/admin/index.mjs +1 -0
- package/dist/services/mcp-servers/admin/module.d.ts +10 -0
- package/dist/services/mcp-servers/admin/module.js +55 -0
- package/dist/services/mcp-servers/admin/module.mjs +27 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +12 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +50 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +26 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +13 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +44 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +20 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +12 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +41 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +17 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +16 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +42 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +18 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +13 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +59 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +35 -0
- package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +8 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.js +23 -3
- package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +23 -3
- package/dist/services/mcp-servers/internal.d.ts +6 -0
- package/dist/services/mcp-servers/internal.js +32 -0
- package/dist/services/mcp-servers/internal.mjs +8 -0
- package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +8 -0
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +23 -3
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +24 -4
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +2 -0
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +2 -0
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +1 -1
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +1 -1
- package/docs/agent.md +1 -1
- package/docs/automations.md +24 -6
- package/docs/configuration.md +0 -1
- package/docs/mcp-servers.md +83 -1
- package/examples/authentication/login.ts +5 -0
- package/examples/automations/create-automation.ts +5 -0
- package/examples/automations/create-event-automation.ts +5 -0
- package/examples/automations/list-automation-runs.ts +6 -0
- package/examples/automations/list-automations.ts +3 -0
- package/examples/automations/preview-automation-runs.ts +3 -0
- package/examples/automations/receive-automation-event.ts +5 -0
- package/examples/automations/revoke-automation-event-token.ts +6 -0
- package/examples/automations/run-automation-now.ts +3 -0
- package/examples/automations/run-automation-worker.ts +15 -0
- package/examples/automations/update-automation.ts +6 -0
- package/examples/chats/delete-chat.ts +6 -0
- package/examples/chats/get-chat-by-id.ts +6 -0
- package/examples/chats/list-autonomous-chats.ts +3 -0
- package/examples/chats/list-chats.ts +3 -0
- package/examples/guardrails/custom-guard.ts +5 -0
- package/examples/loops/custom-loop.ts +8 -0
- package/examples/mcps/create-mcp.ts +6 -0
- package/examples/mcps/decide-mcp.ts +6 -0
- package/examples/mcps/delete-mcp.ts +6 -0
- package/examples/mcps/get-mcp-by-id.ts +3 -0
- package/examples/mcps/internal-mcp-admin.ts +66 -0
- package/examples/mcps/internal-mcp.ts +28 -3
- package/examples/mcps/list-all-mcps.ts +3 -0
- package/examples/mcps/list-user-mcps.ts +3 -0
- package/examples/mcps/update-mcp.ts +6 -1
- package/examples/mcps/verify-mcp.ts +3 -0
- package/examples/run-agent/interrupt-agent.ts +3 -0
- package/examples/run-agent/run-agent-autonomous.ts +3 -0
- package/examples/run-agent/run-agent-strict-mode.ts +3 -0
- package/examples/run-agent/run-agent-with-confirmation.ts +6 -0
- package/examples/run-agent/run-agent-with-fallback-model.ts +3 -0
- package/examples/run-agent/run-agent-with-guards.ts +3 -0
- package/examples/run-agent/run-agent-with-hooks.ts +6 -0
- package/examples/run-agent/run-agent-with-identity.ts +3 -0
- package/examples/run-agent/run-agent-with-model.ts +3 -0
- package/examples/run-agent/run-agent-with-slack.ts +3 -0
- package/examples/run-agent/run-agent-with-tools.ts +3 -0
- package/examples/tools/basic-tool.ts +3 -0
- package/examples/tools/destructive-tool.ts +3 -0
- package/examples/tools/web-search-tool.ts +3 -0
- package/examples/usage/get-chat-usage.ts +3 -0
- package/examples/usage/get-message-usage.ts +3 -0
- package/examples/usage/get-usage-stats-by-range.ts +3 -0
- package/examples/usage/get-usage-stats.ts +3 -0
- package/examples/users/create-user.ts +3 -0
- package/examples/users/delete-user.ts +6 -0
- package/examples/users/get-user-by-id.ts +3 -0
- package/examples/users/list-users.ts +3 -0
- package/examples/users/set-default-model.ts +6 -0
- package/examples/users/update-user.ts +3 -0
- package/package.json +5 -1
package/docs/configuration.md
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
| `JWT_SECRET` | for `login` and for event automations | Secret that signs the tokens of the sessions, of the reset of a password and of [event automations](automations.md#the-token). See [authentication](authentication.md). |
|
|
14
14
|
| `SERPER_API_KEY` | for `webSearchTool` | See [tools](tools.md#built-in-tools). |
|
|
15
15
|
| `SLACK_BOT_TOKEN` | for `sendSlackMessageTool` | See [tools](tools.md#built-in-tools). |
|
|
16
|
-
| `INTERNAL_MCP_TOKEN` | for internal MCP servers in automations | Token sent to the internal MCP servers when an automation runs without the session of its owner. See [automations](automations.md#internal-mcp-servers-in-a-automation). |
|
|
17
16
|
| `AUTOMATIONS_POLL_INTERVAL_MS` | no | How often the runner of [automations](automations.md) checks what is due, in milliseconds. Defaults to `60000`. |
|
|
18
17
|
| `AUTOMATIONS_LEASE_MS` | no | How long an automation stays locked while it runs, in milliseconds. Defaults to `600000`. |
|
|
19
18
|
| `AUTOMATIONS_MAX_QUEUED_RUNS` | no | How many events of one automation can wait to run. The next ones are recorded as skipped. Defaults to `10`. Read by the endpoint that receives the events. |
|
package/docs/mcp-servers.md
CHANGED
|
@@ -44,6 +44,7 @@ Creating a server connects to it once to read its manifest (tools and instructio
|
|
|
44
44
|
| Field | Meaning |
|
|
45
45
|
| --- | --- |
|
|
46
46
|
| `name`, `url`, `type`, `headers` | What you registered. |
|
|
47
|
+
| `environment` | Optional free text that says which environment the server belongs to (for example `staging` or `production`). It is only a label: the agent does not use it. A blank text removes it. |
|
|
47
48
|
| `trust` | `locked` (never approved, also the value of old records without one), `approved` or `blocked`. |
|
|
48
49
|
| `approvedHash` | Hash of the manifest the user approved. |
|
|
49
50
|
| `history` | The last 5 manifests the server has shown, newest first. The approved one is never dropped. |
|
|
@@ -158,6 +159,7 @@ const agent = new Agent({
|
|
|
158
159
|
Authorization: 'Bearer {{token}}',
|
|
159
160
|
'X-App': 'budget-agent',
|
|
160
161
|
},
|
|
162
|
+
autonomousToken: process.env.BUDGET_SERVICE_TOKEN,
|
|
161
163
|
},
|
|
162
164
|
],
|
|
163
165
|
})
|
|
@@ -173,13 +175,93 @@ await agent.run({
|
|
|
173
175
|
|
|
174
176
|
- `name` and `url` are required, and the name must be unique among the internal servers. `headers` is optional.
|
|
175
177
|
- `{{token}}` in a header value is replaced with `mcpTokens[name]` of the run. A header without the placeholder is sent as written, so the other headers are plain strings. If no header uses `{{token}}`, the server needs no token.
|
|
178
|
+
- `autonomousToken` is optional. It is the token of a service account, used instead of `mcpTokens[name]` only in an [autonomous run](agent.md#autonomous-mode) that brings no token for that server, and then the agent also sends the id of the user in `X-User-Id`. An interactive run never uses it. See [automations](automations.md#internal-mcp-servers-in-an-automation).
|
|
176
179
|
- The token lives only in memory during the run. Do not put it in `options`, which is saved in the chat. It is masked in the connection errors the agent logs.
|
|
177
180
|
- It is trusted: no approval is asked, the manifest is not reviewed or stored, and its tools are not marked as written by a third party. The tools still follow the rules of the tool pipeline, so a tool with `destructiveHint` asks the user before it runs.
|
|
178
181
|
- If the token of a server is missing for a run, or it cannot be reached, the agent leaves it out for that run, writes a trace and a log, and tells the model that the source is unavailable, so it says it could not access that information. The run does not fail. It does not tell the user the details, only that the source was not reachable.
|
|
179
182
|
- If a server of the user has the same name as an internal one, the one of the user is ignored for that run, so nobody can impersonate an internal server.
|
|
180
183
|
- The tools are named `<name>__<tool>`, like any other MCP tool.
|
|
181
184
|
|
|
182
|
-
In an automation there is no session of the user, so there is no token of theirs. See [automations](automations.md#internal-mcp-servers-in-
|
|
185
|
+
In an automation there is no session of the user, so there is no token of theirs. See [automations](automations.md#internal-mcp-servers-in-an-automation).
|
|
186
|
+
|
|
187
|
+
### Which token a server uses
|
|
188
|
+
|
|
189
|
+
There are three common setups. The difference is what the header says and whether the server has an `autonomousToken`.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const agent = new Agent({
|
|
193
|
+
loop: new AgiLoop(),
|
|
194
|
+
internalMcps: [
|
|
195
|
+
{
|
|
196
|
+
name: 'budget',
|
|
197
|
+
url: 'https://budget.example.com/mcp',
|
|
198
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'crm',
|
|
202
|
+
url: 'https://crm.example.com/mcp',
|
|
203
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
204
|
+
autonomousToken: process.env.CRM_SERVICE_TOKEN,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'catalog',
|
|
208
|
+
url: 'https://catalog.example.com/mcp',
|
|
209
|
+
headers: { Authorization: `Bearer ${process.env.CATALOG_SERVICE_TOKEN}` },
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
await agent.run({
|
|
215
|
+
input: { message: 'summarize my week' },
|
|
216
|
+
currentUser,
|
|
217
|
+
mcpTokens: { budget: sessionToken, crm: sessionToken },
|
|
218
|
+
})
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
| Server | Chat with `mcpTokens` | Automation (autonomous, no `mcpTokens`) |
|
|
222
|
+
| --- | --- | --- |
|
|
223
|
+
| `budget`: user token only | The token of the user. | Unavailable: there is no token and no `autonomousToken`. |
|
|
224
|
+
| `crm`: user token, and a service account for automations | The token of the user. | `CRM_SERVICE_TOKEN`, and the header `X-User-Id` with the owner of the automation. |
|
|
225
|
+
| `catalog`: always the service account | `CATALOG_SERVICE_TOKEN`, written in the header. | The same, without `X-User-Id`. |
|
|
226
|
+
|
|
227
|
+
- A chat never uses an `autonomousToken`. If `crm` is used in a chat and the request brings no token for it, the server is unavailable for that run.
|
|
228
|
+
- In `catalog` the credential is the same for every user and in every run. Use it only for data that is not specific to a user.
|
|
229
|
+
|
|
230
|
+
### Internal servers stored in the database
|
|
231
|
+
|
|
232
|
+
You can also manage the internal servers from a back office, without a deploy. They are stored in the same collection as the servers of the users, with `internal: true`, and the agent loads the enabled ones at the start of every run next to the ones declared in code. They behave the same way: trusted, no manifest review, no history, no notice of third party, destructive tools still ask.
|
|
233
|
+
|
|
234
|
+
They live in their own entry point, so the screens of the users never import them:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import {
|
|
238
|
+
createInternalMcp,
|
|
239
|
+
updateInternalMcp,
|
|
240
|
+
getInternalMcpById,
|
|
241
|
+
listInternalMcps,
|
|
242
|
+
deleteInternalMcp,
|
|
243
|
+
} from 'openloops/mcps/admin'
|
|
244
|
+
|
|
245
|
+
const mcp = await createInternalMcp({
|
|
246
|
+
payload: {
|
|
247
|
+
name: 'budget',
|
|
248
|
+
url: 'https://api.example.com/mcp',
|
|
249
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
250
|
+
},
|
|
251
|
+
currentUser: admin,
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
await updateInternalMcp({ id: mcp._id, payload: { enabled: false, __v: mcp.__v }, currentUser: admin })
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
- Every function needs an admin as `currentUser` and answers 403 otherwise. The sub-route separates the code, the permission is what protects it.
|
|
258
|
+
- `name` and `url` are required, `type` is always `http`, `environment` is optional and `enabled` defaults to `true`. A disabled server is not loaded. The name must be unique among the internal servers (409).
|
|
259
|
+
- A header with `{{token}}` uses `mcpTokens[name]` of the run. The stored servers have no `autonomousToken`, which exists only in the servers declared in code, so in an automation they are available only when the token is written in the header (for example `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U`), which is sent as it is in every run.
|
|
260
|
+
- Deleting is permanent. Internal servers have no owner, so they are not listed to any user.
|
|
261
|
+
- The normal functions (`getMcpServerById`, `updateMcpServer`, `deleteMcpServer`, `decideMcpServerTrust`, and the lists) never see them, not even for an admin, and `internal` and `enabled` in the payload of a user are ignored.
|
|
262
|
+
- If a server declared in code has the same name, the one in code wins. A server of a user with the same name as an internal one is ignored for that run.
|
|
263
|
+
- `headers` are stored as written, like the headers of the servers of the users. Mask them in your controller before sending a record to a client.
|
|
264
|
+
- Run `ensureIndexes` after updating: it adds the unique index of the names of the internal servers.
|
|
183
265
|
|
|
184
266
|
## Tools of MCP servers
|
|
185
267
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Logger } from 'openloops/common'
|
|
2
2
|
import { login } from 'openloops/authentication'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Logs in with an email or a username and a password.
|
|
6
|
+
*
|
|
7
|
+
* The result has a short access token, a refresh token and the user. Send the access token to your backend on every request and use the refresh token to get a new one when it expires.
|
|
8
|
+
*/
|
|
4
9
|
async function loginExample () {
|
|
5
10
|
const logger = new Logger()
|
|
6
11
|
|
|
@@ -2,6 +2,11 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { createAutomation } from 'openloops/automations'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Creates an automation that runs on a schedule: a weekly report at 08:00, Monday to Friday, in the timezone of the schedule.
|
|
7
|
+
*
|
|
8
|
+
* The run uses the model that you set here. The next run is calculated and returned in `triggers.schedule.nextRunAt`.
|
|
9
|
+
*/
|
|
5
10
|
async function createSchedule () {
|
|
6
11
|
const logger = new Logger()
|
|
7
12
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,11 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { createAutomation, issueAutomationEventToken } from 'openloops/automations'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Creates an automation that starts when another system sends it an event, and issues the token that system must use.
|
|
7
|
+
*
|
|
8
|
+
* The token is not stored: the owner can issue as many as they want. It expires in 90 days here, and without `expiresIn` it never expires.
|
|
9
|
+
*/
|
|
5
10
|
async function createEventAutomation () {
|
|
6
11
|
const logger = new Logger()
|
|
7
12
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { listAutomationRunsByAutomation, listAutomationRunsByUser } from 'openloops/automations'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Lists the history of runs of one automation, with its status and the chat where each run happened.
|
|
7
|
+
*/
|
|
5
8
|
async function listRunsOfAnAutomation () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -15,6 +18,9 @@ async function listRunsOfAnAutomation () {
|
|
|
15
18
|
logger.info(result.items.map(run => ({ status: run.status, startedAt: run.startedAt, chatId: run.chatId, error: run.error })), '[Demo] Runs of the automation')
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Counts the runs of the user that are paused (waiting for an answer in the chat) or failed, to show them in a screen of pending items.
|
|
23
|
+
*/
|
|
18
24
|
async function listRunsThatNeedAttention () {
|
|
19
25
|
const logger = new Logger()
|
|
20
26
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { listAutomationsByUser } from 'openloops/automations'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Lists the automations of the user with the state of their triggers and the result of the last run.
|
|
7
|
+
*/
|
|
5
8
|
async function listAutomations () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Logger } from 'openloops/common'
|
|
2
2
|
import { previewAutomationRuns } from 'openloops/automations'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Shows the next dates a recurrence would run, without creating anything. Use it in a form so the user sees what they are scheduling (here, the last day of every month at 18:00).
|
|
6
|
+
*/
|
|
4
7
|
async function previewRuns () {
|
|
5
8
|
const logger = new Logger()
|
|
6
9
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Logger } from 'openloops/common'
|
|
2
2
|
import { AutomationEventError, receiveAutomationEvent } from 'openloops/automations'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Receives an event from another system, for example in the endpoint of your backend that gets the call of an alarm.
|
|
6
|
+
*
|
|
7
|
+
* The token travels in the header `Authorization: Bearer ...`. The `idempotencyKey` is optional: with it, a repeated event does not start a second run. A refused event throws an `AutomationEventError` that carries the HTTP status to answer.
|
|
8
|
+
*/
|
|
4
9
|
async function receive (automationId: string, authorization: string, body: unknown, idempotencyKey?: string) {
|
|
5
10
|
const logger = new Logger()
|
|
6
11
|
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { revokeAutomationEventToken, rotateAutomationEventTokens } from 'openloops/automations'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Revokes one token of an automation, for example one that leaked, by presenting it. The other tokens keep working.
|
|
7
|
+
*/
|
|
5
8
|
async function revokeLeakedToken () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -11,6 +14,9 @@ async function revokeLeakedToken () {
|
|
|
11
14
|
logger.info({ jti: result.jti }, '[Demo] That token no longer works, the others still do')
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Invalidates every token issued for the automation at once. Issue a new one afterwards.
|
|
19
|
+
*/
|
|
14
20
|
async function rotateAll () {
|
|
15
21
|
const logger = new Logger()
|
|
16
22
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -3,6 +3,9 @@ import { CurrentUser } from 'openloops/base'
|
|
|
3
3
|
import { createAutomationRunner } from 'openloops/automations'
|
|
4
4
|
import { webSearchTool } from 'openloops/tools'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Starts a run of an automation by hand, outside its schedule, for example from a "run now" button. The run goes on in the background.
|
|
8
|
+
*/
|
|
6
9
|
async function runNow () {
|
|
7
10
|
const logger = new Logger()
|
|
8
11
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -8,9 +8,24 @@ async function notifyOwner (message: string) {
|
|
|
8
8
|
logger.info({ message }, '[Notification Service] Sending notification to the owner...')
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Worker that runs the automations. Start it in its own process: it looks for due schedules and queued events and runs each one in autonomous mode.
|
|
13
|
+
*
|
|
14
|
+
* The internal MCP `crm` uses the token of the user when there is one. An automation has no session of the user, so there it uses `autonomousToken`, the token of a service account, and the agent also sends the id of the owner in `X-User-Id`.
|
|
15
|
+
*
|
|
16
|
+
* `onRunFinished` is where you notify the owner when a run fails, is paused or is skipped.
|
|
17
|
+
*/
|
|
11
18
|
const runner = createAutomationRunner({
|
|
12
19
|
agent: {
|
|
13
20
|
tools: [webSearchTool],
|
|
21
|
+
internalMcps: [
|
|
22
|
+
{
|
|
23
|
+
name: 'crm',
|
|
24
|
+
url: 'https://crm.example.com/mcp',
|
|
25
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
26
|
+
autonomousToken: process.env.CRM_SERVICE_TOKEN,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
14
29
|
guards: [inputGuards.blockCard],
|
|
15
30
|
maxIterations: 30,
|
|
16
31
|
},
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { updateAutomation } from 'openloops/automations'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Turns off the schedule of an automation without deleting it. Triggers are merged key by key, so only `enabled` changes.
|
|
7
|
+
*/
|
|
5
8
|
async function pause () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -15,6 +18,9 @@ async function pause () {
|
|
|
15
18
|
logger.info({ enabled: result.triggers?.schedule?.enabled }, '[Demo] The automation is off')
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Turns the schedule on again and changes its recurrence at the same time. The next run is calculated again.
|
|
23
|
+
*/
|
|
18
24
|
async function resume () {
|
|
19
25
|
const logger = new Logger()
|
|
20
26
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { deleteChat } from 'openloops/chats'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Deletes a chat of the user without removing it from the database (soft delete).
|
|
7
|
+
*/
|
|
5
8
|
async function softDeleteChat () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -14,6 +17,9 @@ async function softDeleteChat () {
|
|
|
14
17
|
logger.info(result, '[Demo] Deleted chat')
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Removes a chat from the database for good. Only an admin can do it.
|
|
22
|
+
*/
|
|
17
23
|
async function hardDeleteChat () {
|
|
18
24
|
const logger = new Logger()
|
|
19
25
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { getChatById } from 'openloops/chats'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Gets a chat with its messages.
|
|
7
|
+
*/
|
|
5
8
|
async function getChat () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -14,6 +17,9 @@ async function getChat () {
|
|
|
14
17
|
logger.info(result?.messages, '[Demo] Messages')
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Gets only the state of a chat, with `select`, which is lighter. Use it to know if a run is still going or is waiting for the user.
|
|
22
|
+
*/
|
|
17
23
|
async function getChatStatus () {
|
|
18
24
|
const logger = new Logger()
|
|
19
25
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { listChatsByUser } from 'openloops/chats'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Lists the chats created by autonomous runs, and keeps the ones that need the user: waiting for a confirmation, waiting for an answer, or failed.
|
|
7
|
+
*/
|
|
5
8
|
async function listAutonomousChats () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { listChatsByUser } from 'openloops/chats'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Lists the chats of the user in pages.
|
|
7
|
+
*/
|
|
5
8
|
async function listChats () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Guard } from 'openloops/guardrails'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* An input guard of your own. The handler receives the message before the loop runs and returns `{ passed: true }` or `{ passed: false, reason }`. When it blocks, the user gets `reply` and the model never sees the message.
|
|
5
|
+
*
|
|
6
|
+
* Add it with `guards: [noSpam]` in the `Agent` or with `agent.addGuard(noSpam)`.
|
|
7
|
+
*/
|
|
3
8
|
export const noSpam = new Guard({
|
|
4
9
|
name: 'no_spam',
|
|
5
10
|
description: 'Blocks obvious spam phrases',
|
|
@@ -3,6 +3,11 @@ import { Logger } from 'openloops/common'
|
|
|
3
3
|
import { CurrentUser } from 'openloops/base'
|
|
4
4
|
import { fastResponder } from 'openloops/loops'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* A loop of your own. It has one node, `respond`, that answers with the fast responder and ends the turn. Add more nodes to build a flow with steps.
|
|
8
|
+
*
|
|
9
|
+
* Change the `version` every time the loop or its prompts change, it is saved with every turn.
|
|
10
|
+
*/
|
|
6
11
|
export class EchoLoop extends AgentLoop {
|
|
7
12
|
get initialNode () {
|
|
8
13
|
return this.nodes.respond
|
|
@@ -35,6 +40,9 @@ export class EchoLoop extends AgentLoop {
|
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Runs an agent with the loop above.
|
|
45
|
+
*/
|
|
38
46
|
async function runCustomLoop () {
|
|
39
47
|
const logger = new Logger()
|
|
40
48
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,11 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { createMcpServer } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Registers an MCP server of the user. It starts `locked`: the first time the agent needs it, the user must approve it.
|
|
7
|
+
*
|
|
8
|
+
* `environment` is only a label (for example `staging`), the agent does not use it. Creating the server connects once to read its manifest.
|
|
9
|
+
*/
|
|
5
10
|
async function createMcp () {
|
|
6
11
|
const logger = new Logger()
|
|
7
12
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -11,6 +16,7 @@ async function createMcp () {
|
|
|
11
16
|
name: 'gemini_demo_mcp',
|
|
12
17
|
type: 'http',
|
|
13
18
|
url: 'https://gemini-api-demos.uc.r.appspot.com/mcp',
|
|
19
|
+
environment: 'staging',
|
|
14
20
|
headers: {
|
|
15
21
|
'Accept': 'text/event-stream'
|
|
16
22
|
}
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { getMcpServerById, decideMcpServerTrust } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Approves a server with the hash of the manifest that the user reviewed. If the server changed since then, the call fails and the user has to review it again.
|
|
7
|
+
*/
|
|
5
8
|
async function approveMcp () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -22,6 +25,9 @@ async function approveMcp () {
|
|
|
22
25
|
logger.info({ trust: result.trust, approvedHash: result.approvedHash }, '[Demo] Approved mcp')
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Blocks a server. The agent will not list or call its tools until it is approved again.
|
|
30
|
+
*/
|
|
25
31
|
async function blockMcp () {
|
|
26
32
|
const logger = new Logger()
|
|
27
33
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { deleteMcpServer } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Deletes a server of the user without removing it from the database.
|
|
7
|
+
*/
|
|
5
8
|
async function softDeleteMcp () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -14,6 +17,9 @@ async function softDeleteMcp () {
|
|
|
14
17
|
logger.info(result, '[Demo] Deleted mcp result')
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Removes a server from the database for good. Only an admin can do it.
|
|
22
|
+
*/
|
|
17
23
|
async function hardDeleteMcp () {
|
|
18
24
|
const logger = new Logger()
|
|
19
25
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { getMcpServerById } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Gets one MCP server of the user, with its manifest history.
|
|
7
|
+
*/
|
|
5
8
|
async function getMcpById () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Logger } from 'openloops/common'
|
|
2
|
+
import { CurrentUser } from 'openloops/base'
|
|
3
|
+
import { createInternalMcp, updateInternalMcp, listInternalMcps, deleteInternalMcp } from 'openloops/mcps/admin'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Back office of the internal MCP servers. It needs an admin, anyone else gets 403.
|
|
7
|
+
*
|
|
8
|
+
* These servers are stored in the database, trusted (no manifest review) and loaded by the agent in every run. The users never see them.
|
|
9
|
+
*/
|
|
10
|
+
async function manageInternalMcps () {
|
|
11
|
+
const logger = new Logger()
|
|
12
|
+
const admin = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
13
|
+
|
|
14
|
+
if (!admin) throw new Error('[Demo] admin is not defined')
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An MCP with a template. `{{token}}` is replaced in each run with the token of the user, passed in `mcpTokens`, so the server acts on behalf of that user.
|
|
18
|
+
*
|
|
19
|
+
* If a run brings no token for it, the server is unavailable for that run and the agent continues without it. In an automation there is no token of the user, so it is unavailable there too.
|
|
20
|
+
*/
|
|
21
|
+
const crm = await createInternalMcp({
|
|
22
|
+
payload: {
|
|
23
|
+
name: 'crm',
|
|
24
|
+
url: 'https://crm.example.com/mcp',
|
|
25
|
+
environment: 'production',
|
|
26
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
27
|
+
},
|
|
28
|
+
currentUser: admin,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
logger.info(crm, '[Demo] Created internal mcp:')
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An MCP with a fixed token. The header has the token written in it, so it is sent as it is in every run, for every user and also in automations.
|
|
35
|
+
*
|
|
36
|
+
* Use it only for a service account that does not depend on the user. The token is stored as written, so do not return it to a client.
|
|
37
|
+
*/
|
|
38
|
+
const catalog = await createInternalMcp({
|
|
39
|
+
payload: {
|
|
40
|
+
name: 'catalog',
|
|
41
|
+
url: 'https://catalog.example.com/mcp',
|
|
42
|
+
environment: 'production',
|
|
43
|
+
headers: { Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U' },
|
|
44
|
+
},
|
|
45
|
+
currentUser: admin,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Disables the server without deleting it. A disabled server is not loaded by the agent.
|
|
50
|
+
*/
|
|
51
|
+
await updateInternalMcp({ id: String(catalog._id), payload: { enabled: false }, currentUser: admin })
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Lists the internal servers in pages.
|
|
55
|
+
*/
|
|
56
|
+
const page = await listInternalMcps({ options: { page: 1, limit: 10 }, currentUser: admin })
|
|
57
|
+
|
|
58
|
+
logger.info({ names: page.items.map(item => item.name) }, '[Demo] Internal mcps:')
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Deletes the server for good.
|
|
62
|
+
*/
|
|
63
|
+
await deleteInternalMcp({ id: String(catalog._id), currentUser: admin })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
manageInternalMcps()
|
|
@@ -3,6 +3,11 @@ import { Logger } from 'openloops/common'
|
|
|
3
3
|
import { CurrentUser } from 'openloops/base'
|
|
4
4
|
import { AgiLoop } from 'openloops/loops'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Declares internal MCP servers in code. They belong to your solution, not to the user, and they are trusted: no approval, no manifest review, no notice of third party. A destructive tool still asks the user.
|
|
8
|
+
*
|
|
9
|
+
* `mcpTokens` gives the token of the user to the servers that use `{{token}}`, by name. It is never saved.
|
|
10
|
+
*/
|
|
6
11
|
async function runAgentWithInternalMcp (sessionToken: string) {
|
|
7
12
|
const logger = new Logger()
|
|
8
13
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -12,11 +17,31 @@ async function runAgentWithInternalMcp (sessionToken: string) {
|
|
|
12
17
|
const agent = new Agent({
|
|
13
18
|
loop: new AgiLoop(),
|
|
14
19
|
internalMcps: [
|
|
20
|
+
/**
|
|
21
|
+
* An MCP with a template: it uses the token of the user from `mcpTokens`. In an automation there is no token, so it is unavailable there.
|
|
22
|
+
*/
|
|
15
23
|
{
|
|
16
24
|
name: 'budget',
|
|
17
|
-
url: 'https://
|
|
25
|
+
url: 'https://budget.example.com/mcp',
|
|
18
26
|
headers: { Authorization: 'Bearer {{token}}' },
|
|
19
27
|
},
|
|
28
|
+
/**
|
|
29
|
+
* An MCP with a template and a token for automations: in a chat it uses the token of the user. In an autonomous run, such as an automation, that brings no token for it, it uses `autonomousToken`, the token of a service account, and the agent sends the id of the owner in `X-User-Id`. A chat never uses `autonomousToken`.
|
|
30
|
+
*/
|
|
31
|
+
{
|
|
32
|
+
name: 'crm',
|
|
33
|
+
url: 'https://crm.example.com/mcp',
|
|
34
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
35
|
+
autonomousToken: process.env.CRM_SERVICE_TOKEN,
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* An MCP with a fixed token: always the service account, in chats and in automations, for every user. Use it only for data that does not depend on the user.
|
|
39
|
+
*/
|
|
40
|
+
{
|
|
41
|
+
name: 'catalog',
|
|
42
|
+
url: 'https://catalog.example.com/mcp',
|
|
43
|
+
headers: { Authorization: `Bearer ${process.env.CATALOG_SERVICE_TOKEN}` },
|
|
44
|
+
},
|
|
20
45
|
],
|
|
21
46
|
})
|
|
22
47
|
|
|
@@ -26,7 +51,7 @@ async function runAgentWithInternalMcp (sessionToken: string) {
|
|
|
26
51
|
message: 'how much did I spend on food this month?',
|
|
27
52
|
},
|
|
28
53
|
currentUser,
|
|
29
|
-
mcpTokens: { budget: sessionToken },
|
|
54
|
+
mcpTokens: { budget: sessionToken, crm: sessionToken },
|
|
30
55
|
})
|
|
31
56
|
|
|
32
57
|
logger.debug(result, '[Demo] Result')
|
|
@@ -35,4 +60,4 @@ async function runAgentWithInternalMcp (sessionToken: string) {
|
|
|
35
60
|
}
|
|
36
61
|
}
|
|
37
62
|
|
|
38
|
-
runAgentWithInternalMcp('
|
|
63
|
+
runAgentWithInternalMcp('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { listAllMcpServersByUser } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Lists every MCP server of the user, oldest first, without pages. It is what the agent uses. The internal servers never appear here.
|
|
7
|
+
*/
|
|
5
8
|
async function listAllMcps () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { listMcpServersByUser } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Lists the MCP servers of the user in pages, for a management screen. The internal servers never appear here.
|
|
7
|
+
*/
|
|
5
8
|
async function getMcpById () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -2,6 +2,11 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { updateMcpServer } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Updates a server of the user. Here the header carries a fixed token: the user wrote it, and it is sent as it is.
|
|
7
|
+
*
|
|
8
|
+
* Changing the headers checks the connection again and keeps the approval. Changing the `url` locks the server again.
|
|
9
|
+
*/
|
|
5
10
|
async function updateMcp () {
|
|
6
11
|
const logger = new Logger()
|
|
7
12
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
@@ -11,7 +16,7 @@ async function updateMcp () {
|
|
|
11
16
|
payload: {
|
|
12
17
|
name: 'test-mcp-updated',
|
|
13
18
|
headers: {
|
|
14
|
-
'Authorization': 'Bearer
|
|
19
|
+
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U'
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
currentUser,
|
|
@@ -2,6 +2,9 @@ import { Logger } from 'openloops/common'
|
|
|
2
2
|
import { CurrentUser } from 'openloops/base'
|
|
3
3
|
import { verifyMcpServerConnection } from 'openloops/mcps'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Checks the connection of a server: it reads the manifest and saves the status (`ok` or `error`). Use it in a "test connection" button, it also feeds a green or red dot.
|
|
7
|
+
*/
|
|
5
8
|
async function verifyMcp () {
|
|
6
9
|
const logger = new Logger()
|
|
7
10
|
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|