openloops 0.4.0 → 0.4.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/CHANGELOG.md +34 -0
- package/README.md +1 -0
- package/dist/common/repositories/mongo-db.repository.d.ts +6 -1
- package/dist/common/repositories/mongo-db.repository.js +13 -5
- package/dist/common/repositories/mongo-db.repository.mjs +13 -5
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +1 -0
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +6 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +6 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +1 -0
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +6 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +6 -2
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +1 -0
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +6 -2
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +6 -2
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +1 -0
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +2 -2
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +2 -2
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +1 -0
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +2 -2
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +2 -2
- package/docs/README.md +1 -1
- package/docs/automations.md +54 -7
- package/docs/chats.md +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `openloops` are written here, newest first. The format follows [Keep a Changelog](https://keepachangelog.com) and the versions follow [semantic versioning](https://semver.org), where a minor version can still break the API while the package is in beta. Changes before 0.4.0 are not recorded here, see the commits and the tags.
|
|
4
|
+
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `hasMore` in the output of `listChatsByUser`, `listMcpServersByUser`, `listAutomationsByUser`, `listAutomationRunsByUser` and `listAutomationRunsByAutomation`. It is `true` when there is a next page, so the client does not need to guess from the size of the last one. It is computed by reading one extra item, without a count query.
|
|
10
|
+
- `MongoRepository.findManyPaginated`, which returns `{ items, hasMore }`. `findMany` is unchanged.
|
|
11
|
+
|
|
12
|
+
## 0.4.0
|
|
13
|
+
|
|
14
|
+
This version breaks the API of the former agentic jobs. Follow the [migration steps](docs/automations.md#migrating-from-agentic-jobs) when you update.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Automations with an event trigger: another system sends an event, it becomes a queued run with its payload, and the runner executes the events of an automation one at a time and in order. See [automations](docs/automations.md#events).
|
|
19
|
+
- Tokens for those events, signed and not stored, that can be issued again, revoked one by one or rotated all at once (`issueAutomationEventToken`, `revokeAutomationEventToken`, `rotateAutomationEventTokens`).
|
|
20
|
+
- `receiveAutomationEvent`, with idempotency keys, a limit on the payload and a limit on the queue (`AUTOMATIONS_MAX_QUEUED_RUNS`).
|
|
21
|
+
- `runner.wake()` to make the runner check right away.
|
|
22
|
+
- `revokeToken` and `isTokenRevoked` in `openloops/authentication`, over the new generic collection `revoked_tokens`.
|
|
23
|
+
- `migrateAutomations` in `openloops/db` and `yarn migrate:automations` to move the data of the former agentic jobs.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Agentic jobs are now automations. The import is `openloops/automations`, the collections are `automations` and `automation_runs`, the runs use `automationId` and the variables are `AUTOMATIONS_POLL_INTERVAL_MS` and `AUTOMATIONS_LEASE_MS`. The old variables are not read anymore.
|
|
28
|
+
- `recurrence` and `timezone` of an automation now live inside its `trigger`, which is either a `schedule` or an `event`. The type of the trigger cannot be changed after the automation is created.
|
|
29
|
+
- A run can now have the status `queued` and the trigger `event`, and keeps the `payload` and `idempotencyKey` of the event.
|
|
30
|
+
- `JWT_SECRET` is also needed to sign the tokens of event automations.
|
|
31
|
+
|
|
32
|
+
### Removed
|
|
33
|
+
|
|
34
|
+
- The `openloops/agentic-jobs` export and every name that had `AgenticJob` in it. There are no aliases.
|
package/README.md
CHANGED
|
@@ -302,6 +302,7 @@ Every pattern above, and a lot more, lives as a runnable example in [`examples/`
|
|
|
302
302
|
- [Authentication](docs/authentication.md)
|
|
303
303
|
- [LLM usage tracking](docs/usage.md)
|
|
304
304
|
- [Configuration](docs/configuration.md)
|
|
305
|
+
- [Changelog](CHANGELOG.md)
|
|
305
306
|
|
|
306
307
|
## License
|
|
307
308
|
|
|
@@ -19,7 +19,12 @@ export declare class MongoRepository<T> {
|
|
|
19
19
|
cleanInput(value: string): string;
|
|
20
20
|
private clampLimit;
|
|
21
21
|
findOne({ where, select, options }: QueryParams<T>): Promise<T | null>;
|
|
22
|
-
findMany(
|
|
22
|
+
findMany(params: QueryParams<T>): Promise<T[]>;
|
|
23
|
+
findManyPaginated(params: QueryParams<T>): Promise<{
|
|
24
|
+
items: T[];
|
|
25
|
+
hasMore: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
private query;
|
|
23
28
|
findAll({ where, select, options }: QueryParams<T>): Promise<T[]>;
|
|
24
29
|
createOne({ payload }: CommandParams<T>): Promise<ObjectId>;
|
|
25
30
|
createMany({ payload }: CommandParams<T>): Promise<CreateManyResponse>;
|
|
@@ -76,14 +76,22 @@ class MongoRepository {
|
|
|
76
76
|
throw error;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
async findMany(
|
|
79
|
+
async findMany(params) {
|
|
80
|
+
const _limit = this.clampLimit(params.options?.limit);
|
|
81
|
+
return this.query(params, _limit, _limit);
|
|
82
|
+
}
|
|
83
|
+
async findManyPaginated(params) {
|
|
84
|
+
const _limit = this.clampLimit(params.options?.limit);
|
|
85
|
+
const results = await this.query(params, _limit, _limit + 1);
|
|
86
|
+
return { items: results.slice(0, _limit), hasMore: results.length > _limit };
|
|
87
|
+
}
|
|
88
|
+
async query({ where, select, options }, pageSize, fetchSize) {
|
|
80
89
|
try {
|
|
81
90
|
const db = await this.dbClient.db(this.database);
|
|
82
91
|
const collection = db.collection(this.collection);
|
|
83
|
-
const { page = 1
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const result = await collection.find({ ...where, ...this._where }, { projection: select }).sort(options?.sortBy || { _id: -1 }).skip(_skip).limit(_limit).toArray();
|
|
92
|
+
const { page = 1 } = options || {};
|
|
93
|
+
const _skip = +page > 0 ? (+page - 1) * pageSize : 0;
|
|
94
|
+
const result = await collection.find({ ...where, ...this._where }, { projection: select }).sort(options?.sortBy || { _id: -1 }).skip(_skip).limit(fetchSize).toArray();
|
|
87
95
|
return result;
|
|
88
96
|
} catch (error) {
|
|
89
97
|
await this.report(error);
|
|
@@ -53,14 +53,22 @@ class MongoRepository {
|
|
|
53
53
|
throw error;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
async findMany(
|
|
56
|
+
async findMany(params) {
|
|
57
|
+
const _limit = this.clampLimit(params.options?.limit);
|
|
58
|
+
return this.query(params, _limit, _limit);
|
|
59
|
+
}
|
|
60
|
+
async findManyPaginated(params) {
|
|
61
|
+
const _limit = this.clampLimit(params.options?.limit);
|
|
62
|
+
const results = await this.query(params, _limit, _limit + 1);
|
|
63
|
+
return { items: results.slice(0, _limit), hasMore: results.length > _limit };
|
|
64
|
+
}
|
|
65
|
+
async query({ where, select, options }, pageSize, fetchSize) {
|
|
57
66
|
try {
|
|
58
67
|
const db = await this.dbClient.db(this.database);
|
|
59
68
|
const collection = db.collection(this.collection);
|
|
60
|
-
const { page = 1
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const result = await collection.find({ ...where, ...this._where }, { projection: select }).sort(options?.sortBy || { _id: -1 }).skip(_skip).limit(_limit).toArray();
|
|
69
|
+
const { page = 1 } = options || {};
|
|
70
|
+
const _skip = +page > 0 ? (+page - 1) * pageSize : 0;
|
|
71
|
+
const result = await collection.find({ ...where, ...this._where }, { projection: select }).sort(options?.sortBy || { _id: -1 }).skip(_skip).limit(fetchSize).toArray();
|
|
64
72
|
return result;
|
|
65
73
|
} catch (error) {
|
|
66
74
|
await this.report(error);
|
package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
|
|
|
8
8
|
}
|
|
9
9
|
export interface Output extends BaseUseCaseOutput {
|
|
10
10
|
data: AutomationRunProps[];
|
|
11
|
+
hasMore?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare class ListAutomationRunsByAutomationUseCase extends BaseUseCase<Params, Output> {
|
|
13
14
|
private readonly automationRunRepository?;
|
|
@@ -31,6 +31,7 @@ __export(list_automation_runs_by_automation_use_case_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(list_automation_runs_by_automation_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
|
+
var import_mongodb = require("mongodb");
|
|
34
35
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
36
|
var import_repositories2 = require("../repositories");
|
|
36
37
|
let ListAutomationRunsByAutomationUseCase = class extends import_base.BaseUseCase {
|
|
@@ -43,8 +44,11 @@ let ListAutomationRunsByAutomationUseCase = class extends import_base.BaseUseCas
|
|
|
43
44
|
const { automationId, options } = params;
|
|
44
45
|
if (!automationId) throw new Error("Missing automationId");
|
|
45
46
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
46
|
-
const
|
|
47
|
-
|
|
47
|
+
const result = await this.automationRunRepository?._.findManyPaginated({
|
|
48
|
+
where: { automationId: new import_mongodb.ObjectId(automationId) },
|
|
49
|
+
options: { page, limit, sortBy }
|
|
50
|
+
});
|
|
51
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
48
52
|
}
|
|
49
53
|
};
|
|
50
54
|
ListAutomationRunsByAutomationUseCase = __decorateClass([
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
__decorateParam
|
|
4
4
|
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
5
|
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { ObjectId } from "mongodb";
|
|
6
7
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
8
|
import { AutomationRunRepository } from "../repositories";
|
|
8
9
|
let ListAutomationRunsByAutomationUseCase = class extends BaseUseCase {
|
|
@@ -15,8 +16,11 @@ let ListAutomationRunsByAutomationUseCase = class extends BaseUseCase {
|
|
|
15
16
|
const { automationId, options } = params;
|
|
16
17
|
if (!automationId) throw new Error("Missing automationId");
|
|
17
18
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const result = await this.automationRunRepository?._.findManyPaginated({
|
|
20
|
+
where: { automationId: new ObjectId(automationId) },
|
|
21
|
+
options: { page, limit, sortBy }
|
|
22
|
+
});
|
|
23
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
20
24
|
}
|
|
21
25
|
};
|
|
22
26
|
ListAutomationRunsByAutomationUseCase = __decorateClass([
|
|
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
|
|
|
8
8
|
}
|
|
9
9
|
export interface Output extends BaseUseCaseOutput {
|
|
10
10
|
data: AutomationRunProps[];
|
|
11
|
+
hasMore?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare class ListAutomationRunsByUserUseCase extends BaseUseCase<Params, Output> {
|
|
13
14
|
private readonly automationRunRepository?;
|
|
@@ -31,6 +31,7 @@ __export(list_automation_runs_by_user_use_case_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(list_automation_runs_by_user_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
|
+
var import_mongodb = require("mongodb");
|
|
34
35
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
36
|
var import_repositories2 = require("../repositories");
|
|
36
37
|
let ListAutomationRunsByUserUseCase = class extends import_base.BaseUseCase {
|
|
@@ -43,8 +44,11 @@ let ListAutomationRunsByUserUseCase = class extends import_base.BaseUseCase {
|
|
|
43
44
|
const { status, options, currentUser } = params;
|
|
44
45
|
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the runs of the automations");
|
|
45
46
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
46
|
-
const
|
|
47
|
-
|
|
47
|
+
const result = await this.automationRunRepository?._.findManyPaginated({
|
|
48
|
+
where: { ownerId: new import_mongodb.ObjectId(currentUser.userId), ...status ? { status } : {} },
|
|
49
|
+
options: { page, limit, sortBy }
|
|
50
|
+
});
|
|
51
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
48
52
|
}
|
|
49
53
|
};
|
|
50
54
|
ListAutomationRunsByUserUseCase = __decorateClass([
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
__decorateParam
|
|
4
4
|
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
5
|
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { ObjectId } from "mongodb";
|
|
6
7
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
8
|
import { AutomationRunRepository } from "../repositories";
|
|
8
9
|
let ListAutomationRunsByUserUseCase = class extends BaseUseCase {
|
|
@@ -15,8 +16,11 @@ let ListAutomationRunsByUserUseCase = class extends BaseUseCase {
|
|
|
15
16
|
const { status, options, currentUser } = params;
|
|
16
17
|
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the runs of the automations");
|
|
17
18
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const result = await this.automationRunRepository?._.findManyPaginated({
|
|
20
|
+
where: { ownerId: new ObjectId(currentUser.userId), ...status ? { status } : {} },
|
|
21
|
+
options: { page, limit, sortBy }
|
|
22
|
+
});
|
|
23
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
20
24
|
}
|
|
21
25
|
};
|
|
22
26
|
ListAutomationRunsByUserUseCase = __decorateClass([
|
|
@@ -7,6 +7,7 @@ export interface Params extends BaseUseCaseParams {
|
|
|
7
7
|
}
|
|
8
8
|
export interface Output extends BaseUseCaseOutput {
|
|
9
9
|
data: AutomationProps[];
|
|
10
|
+
hasMore?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare class ListAutomationsByUserUseCase extends BaseUseCase<Params, Output> {
|
|
12
13
|
private readonly automationRepository?;
|
|
@@ -31,6 +31,7 @@ __export(list_automations_by_user_use_case_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(list_automations_by_user_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
|
+
var import_mongodb = require("mongodb");
|
|
34
35
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
36
|
var import_repositories2 = require("../repositories");
|
|
36
37
|
let ListAutomationsByUserUseCase = class extends import_base.BaseUseCase {
|
|
@@ -43,8 +44,11 @@ let ListAutomationsByUserUseCase = class extends import_base.BaseUseCase {
|
|
|
43
44
|
const { options, currentUser } = params;
|
|
44
45
|
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the automations");
|
|
45
46
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
46
|
-
const
|
|
47
|
-
|
|
47
|
+
const result = await this.automationRepository?._.findManyPaginated({
|
|
48
|
+
where: { ownerId: new import_mongodb.ObjectId(currentUser.userId) },
|
|
49
|
+
options: { page, limit, sortBy }
|
|
50
|
+
});
|
|
51
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
48
52
|
}
|
|
49
53
|
};
|
|
50
54
|
ListAutomationsByUserUseCase = __decorateClass([
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
__decorateParam
|
|
4
4
|
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
5
|
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { ObjectId } from "mongodb";
|
|
6
7
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
8
|
import { AutomationRepository } from "../repositories";
|
|
8
9
|
let ListAutomationsByUserUseCase = class extends BaseUseCase {
|
|
@@ -15,8 +16,11 @@ let ListAutomationsByUserUseCase = class extends BaseUseCase {
|
|
|
15
16
|
const { options, currentUser } = params;
|
|
16
17
|
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the automations");
|
|
17
18
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const result = await this.automationRepository?._.findManyPaginated({
|
|
20
|
+
where: { ownerId: new ObjectId(currentUser.userId) },
|
|
21
|
+
options: { page, limit, sortBy }
|
|
22
|
+
});
|
|
23
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
20
24
|
}
|
|
21
25
|
};
|
|
22
26
|
ListAutomationsByUserUseCase = __decorateClass([
|
|
@@ -9,6 +9,7 @@ export interface Params extends BaseUseCaseParams {
|
|
|
9
9
|
}
|
|
10
10
|
export interface Output extends BaseUseCaseOutput {
|
|
11
11
|
data: ChatProps[] | null | undefined;
|
|
12
|
+
hasMore?: boolean;
|
|
12
13
|
}
|
|
13
14
|
export declare class ListChatsByUserUseCase extends BaseUseCase<Params, Output> {
|
|
14
15
|
private readonly chatRepository?;
|
|
@@ -43,7 +43,7 @@ let ListChatsByUserUseCase = class extends import_base.BaseUseCase {
|
|
|
43
43
|
async execute(params) {
|
|
44
44
|
const { options, executionMode, currentUser } = params;
|
|
45
45
|
const { page = 1, limit: pageSize = 10 } = options || {};
|
|
46
|
-
const
|
|
46
|
+
const result = await this.chatRepository?._.findManyPaginated({
|
|
47
47
|
where: {
|
|
48
48
|
ownerId: new import_mongodb.ObjectId(currentUser?.userId),
|
|
49
49
|
...executionMode === "autonomous" ? { "settings.executionMode": "autonomous" } : {},
|
|
@@ -51,7 +51,7 @@ let ListChatsByUserUseCase = class extends import_base.BaseUseCase {
|
|
|
51
51
|
},
|
|
52
52
|
options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
|
|
53
53
|
});
|
|
54
|
-
return { data:
|
|
54
|
+
return { data: result?.items, hasMore: result?.hasMore };
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
ListChatsByUserUseCase = __decorateClass([
|
|
@@ -15,7 +15,7 @@ let ListChatsByUserUseCase = class extends BaseUseCase {
|
|
|
15
15
|
async execute(params) {
|
|
16
16
|
const { options, executionMode, currentUser } = params;
|
|
17
17
|
const { page = 1, limit: pageSize = 10 } = options || {};
|
|
18
|
-
const
|
|
18
|
+
const result = await this.chatRepository?._.findManyPaginated({
|
|
19
19
|
where: {
|
|
20
20
|
ownerId: new ObjectId(currentUser?.userId),
|
|
21
21
|
...executionMode === "autonomous" ? { "settings.executionMode": "autonomous" } : {},
|
|
@@ -23,7 +23,7 @@ let ListChatsByUserUseCase = class extends BaseUseCase {
|
|
|
23
23
|
},
|
|
24
24
|
options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
|
|
25
25
|
});
|
|
26
|
-
return { data:
|
|
26
|
+
return { data: result?.items, hasMore: result?.hasMore };
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
ListChatsByUserUseCase = __decorateClass([
|
|
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
|
|
|
8
8
|
}
|
|
9
9
|
export interface Output extends BaseUseCaseOutput {
|
|
10
10
|
data: McpServerProps[] | null | undefined;
|
|
11
|
+
hasMore?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare class ListMcpServersByUserUseCase extends BaseUseCase<Params, Output> {
|
|
13
14
|
private readonly mcpServerRepository?;
|
|
@@ -43,13 +43,13 @@ let ListMcpServersByUserUseCase = class extends import_base.BaseUseCase {
|
|
|
43
43
|
async execute(params) {
|
|
44
44
|
const { options, currentUser } = params;
|
|
45
45
|
const { page = 1, limit: pageSize = 10 } = options || {};
|
|
46
|
-
const
|
|
46
|
+
const result = await this.mcpServerRepository?._.findManyPaginated({
|
|
47
47
|
where: {
|
|
48
48
|
ownerId: new import_mongodb.ObjectId(currentUser?.userId)
|
|
49
49
|
},
|
|
50
50
|
options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
|
|
51
51
|
});
|
|
52
|
-
return { data:
|
|
52
|
+
return { data: result?.items, hasMore: result?.hasMore };
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
ListMcpServersByUserUseCase = __decorateClass([
|
|
@@ -15,13 +15,13 @@ let ListMcpServersByUserUseCase = class extends BaseUseCase {
|
|
|
15
15
|
async execute(params) {
|
|
16
16
|
const { options, currentUser } = params;
|
|
17
17
|
const { page = 1, limit: pageSize = 10 } = options || {};
|
|
18
|
-
const
|
|
18
|
+
const result = await this.mcpServerRepository?._.findManyPaginated({
|
|
19
19
|
where: {
|
|
20
20
|
ownerId: new ObjectId(currentUser?.userId)
|
|
21
21
|
},
|
|
22
22
|
options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
|
|
23
23
|
});
|
|
24
|
-
return { data:
|
|
24
|
+
return { data: result?.items, hasMore: result?.hasMore };
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
ListMcpServersByUserUseCase = __decorateClass([
|
package/docs/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Start with the [README](../README.md) for what `openloops` is and how to run it.
|
|
|
14
14
|
| --- | --- |
|
|
15
15
|
| [The `Agent`](agent.md) | Options, running a turn, the result and its statuses, confirmations, autonomous mode, hooks and interruption. |
|
|
16
16
|
| [Configuration](configuration.md) | Environment variables, choosing the model and what is recorded. |
|
|
17
|
-
| [Automations](automations.md) | Tasks that the agent runs by itself, on a schedule or when an event arrives: triggers, tokens, the queue, the history of runs and the runner that executes them. |
|
|
17
|
+
| [Automations](automations.md) | Tasks that the agent runs by itself, on a schedule or when an event arrives: triggers, tokens, the queue, the history of runs and the runner that executes them. If you used `agentic-jobs`, read [the migration steps](automations.md#migrating-from-agentic-jobs). |
|
|
18
18
|
| [Chats](chats.md) | The chat record, its messages and their `source`, listing, reading and deleting chats. |
|
|
19
19
|
|
|
20
20
|
## Shape how the agent works
|
package/docs/automations.md
CHANGED
|
@@ -324,17 +324,64 @@ The collections are `automations` and `automation_runs`. `ensureIndexes` from `o
|
|
|
324
324
|
|
|
325
325
|
## Migrating from agentic jobs
|
|
326
326
|
|
|
327
|
-
Before 0.4.0 this module was called `agentic-jobs`. The
|
|
327
|
+
Before 0.4.0 this module was called `agentic-jobs`. The old names are not kept as aliases, so the update has to be done in your code, in your environment and in your data. Follow these steps in order.
|
|
328
|
+
|
|
329
|
+
1. **Stop the runner of the old version.** A run that is in progress while its collection is renamed fails.
|
|
330
|
+
2. **Change the names in your code.**
|
|
331
|
+
|
|
332
|
+
| Before | Now |
|
|
333
|
+
| --- | --- |
|
|
334
|
+
| `openloops/agentic-jobs` | `openloops/automations` |
|
|
335
|
+
| `AgenticJob`, `AgenticJobRun` and every `...AgenticJob...` function, such as `createAgenticJob` or `createAgenticJobRunner` | the same name with `Automation`, such as `createAutomation` or `createAutomationRunner` |
|
|
336
|
+
| `listAgenticJobRunsByJob({ jobId })` | `listAutomationRunsByAutomation({ automationId })` |
|
|
337
|
+
| `jobId` in the runs, in your queries and in your screens | `automationId` |
|
|
338
|
+
| `AGENTIC_JOBS_POLL_INTERVAL_MS`, `AGENTIC_JOBS_LEASE_MS` | `AUTOMATIONS_POLL_INTERVAL_MS`, `AUTOMATIONS_LEASE_MS` |
|
|
339
|
+
|
|
340
|
+
The old variables are **not read anymore and nothing warns you**: if you had set them, the runner now uses the default values until you rename them.
|
|
341
|
+
3. **Change the shape of what you send and read.** `recurrence` and `timezone` are no longer fields of the automation, they live inside `trigger`.
|
|
342
|
+
|
|
343
|
+
Before:
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
await createAutomation({
|
|
347
|
+
payload: {
|
|
348
|
+
name: 'Morning report',
|
|
349
|
+
instructions: 'Summarize my open tickets',
|
|
350
|
+
recurrence: { type: 'daily', time: '08:00' },
|
|
351
|
+
timezone: 'America/Lima',
|
|
352
|
+
},
|
|
353
|
+
currentUser,
|
|
354
|
+
})
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Now:
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
await createAutomation({
|
|
361
|
+
payload: {
|
|
362
|
+
name: 'Morning report',
|
|
363
|
+
instructions: 'Summarize my open tickets',
|
|
364
|
+
trigger: {
|
|
365
|
+
type: 'schedule',
|
|
366
|
+
recurrence: { type: 'daily', time: '08:00' },
|
|
367
|
+
timezone: 'America/Lima',
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
currentUser,
|
|
371
|
+
})
|
|
372
|
+
```
|
|
328
373
|
|
|
329
|
-
To
|
|
374
|
+
To change the recurrence or the timezone of an existing automation, send `trigger: { recurrence }` or `trigger: { timezone }`, only the one that changes. When you read an automation, its schedule is in `automation.trigger`.
|
|
375
|
+
4. **Migrate the data**, once per database. It renames the collections, moves `recurrence` and `timezone` into a `schedule` trigger, renames `jobId` to `automationId`, drops the old index and creates the new ones. It can be run again without changing anything, and it refuses to rename a collection if the new name already exists.
|
|
330
376
|
|
|
331
|
-
```typescript
|
|
332
|
-
import { migrateAutomations } from 'openloops/db'
|
|
377
|
+
```typescript
|
|
378
|
+
import { migrateAutomations } from 'openloops/db'
|
|
333
379
|
|
|
334
|
-
const report = await migrateAutomations(db, { dryRun: true })
|
|
335
|
-
```
|
|
380
|
+
const report = await migrateAutomations(db, { dryRun: true })
|
|
381
|
+
```
|
|
336
382
|
|
|
337
|
-
With `dryRun` it only counts what it would change. In a checkout of this repository you can run `yarn migrate:automations --dry-run` and `yarn migrate:automations`, which read `OPENLOOPS_DB_URI` and `OPENLOOPS_DB_NAME`.
|
|
383
|
+
With `dryRun` it only counts what it would change, so run it first. In a checkout of this repository you can run `yarn migrate:automations --dry-run` and `yarn migrate:automations`, which read `OPENLOOPS_DB_URI` and `OPENLOOPS_DB_NAME`.
|
|
384
|
+
5. **Start the runner of the new version.**
|
|
338
385
|
|
|
339
386
|
## Limits
|
|
340
387
|
|
package/docs/chats.md
CHANGED
|
@@ -43,7 +43,7 @@ const result = await listChatsByUser({
|
|
|
43
43
|
})
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Sorted by last update, newest first. Defaults to page 1 and 10 chats.
|
|
46
|
+
Sorted by last update, newest first. Defaults to page 1 and 10 chats. The result has `data` and `hasMore`, which is `true` when there is a next page.
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
49
|
const autonomous = await listChatsByUser({ executionMode: 'autonomous', currentUser })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Open source harness for AI agents: a TypeScript runtime with persistence, tools, MCP trust, approvals and autonomous automations, where the loop is pluggable",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jose Barcos",
|
|
@@ -79,7 +79,8 @@
|
|
|
79
79
|
"files": [
|
|
80
80
|
"dist",
|
|
81
81
|
"docs",
|
|
82
|
-
"examples"
|
|
82
|
+
"examples",
|
|
83
|
+
"CHANGELOG.md"
|
|
83
84
|
],
|
|
84
85
|
"scripts": {
|
|
85
86
|
"build": "tsup && tsc-alias",
|