openloops 0.4.0 → 0.4.2

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +1 -0
  3. package/dist/common/repositories/mongo-db.repository.d.ts +6 -1
  4. package/dist/common/repositories/mongo-db.repository.js +13 -5
  5. package/dist/common/repositories/mongo-db.repository.mjs +13 -5
  6. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +1 -0
  7. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +6 -2
  8. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +6 -2
  9. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +1 -0
  10. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +6 -2
  11. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +6 -2
  12. package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +1 -0
  13. package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +6 -2
  14. package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +6 -2
  15. package/dist/services/chats/repositories/chat.repository.d.ts +4 -1
  16. package/dist/services/chats/repositories/chat.repository.js +1 -1
  17. package/dist/services/chats/repositories/chat.repository.mjs +1 -1
  18. package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +1 -0
  19. package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +1 -1
  20. package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +1 -1
  21. package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +1 -0
  22. package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +2 -2
  23. package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +2 -2
  24. package/dist/services/llmcalls/repositories/llmcall.repository.d.ts +4 -1
  25. package/dist/services/llmcalls/repositories/llmcall.repository.js +1 -1
  26. package/dist/services/llmcalls/repositories/llmcall.repository.mjs +1 -1
  27. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +1 -0
  28. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +1 -1
  29. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +1 -1
  30. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +1 -0
  31. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +1 -1
  32. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +1 -1
  33. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +1 -0
  34. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +2 -2
  35. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +2 -2
  36. package/dist/services/tasks/repositories/agent-action.repository.d.ts +4 -1
  37. package/dist/services/tasks/repositories/agent-action.repository.js +1 -1
  38. package/dist/services/tasks/repositories/agent-action.repository.mjs +1 -1
  39. package/dist/services/tasks/repositories/agent-task.repository.d.ts +4 -1
  40. package/dist/services/tasks/repositories/agent-task.repository.js +1 -1
  41. package/dist/services/tasks/repositories/agent-task.repository.mjs +1 -1
  42. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +1 -0
  43. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +2 -2
  44. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +2 -2
  45. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +1 -0
  46. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +2 -2
  47. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +2 -2
  48. package/dist/services/traces/repositories/agent-trace.repository.d.ts +4 -1
  49. package/dist/services/traces/repositories/agent-trace.repository.js +1 -1
  50. package/dist/services/traces/repositories/agent-trace.repository.mjs +1 -1
  51. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +1 -0
  52. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +2 -2
  53. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +2 -2
  54. package/dist/services/users/repositories/user.repository.d.ts +4 -1
  55. package/dist/services/users/repositories/user.repository.js +1 -1
  56. package/dist/services/users/repositories/user.repository.mjs +1 -1
  57. package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +1 -0
  58. package/dist/services/users/use-cases/list-users-by-props.use-case.js +1 -1
  59. package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +1 -1
  60. package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +4 -0
  61. package/dist/services/workspaces/repositories/workspace-item.repository.js +3 -0
  62. package/dist/services/workspaces/repositories/workspace-item.repository.mjs +3 -0
  63. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +1 -0
  64. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +2 -2
  65. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +2 -2
  66. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +1 -0
  67. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +2 -2
  68. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +2 -2
  69. package/docs/README.md +1 -1
  70. package/docs/automations.md +54 -7
  71. package/docs/chats.md +1 -1
  72. package/package.json +3 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,45 @@
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
+ ## 0.4.2
6
+
7
+ ### Added
8
+
9
+ - `hasMore` in the output of every list use case that did not have it: `listChatsByProps`, `listUsersByProps`, `listLLMCallsByProps`, `listAgentTasksByChat`, `listAgentActionsByTask`, `listAgentTracesByChat`, `listWorkspaceItems`, `searchWorkspaceItems` and `listAllMcpServersByUser`. The last one is never paginated, so it is always `false`.
10
+ - `WorkspaceItemRepository.findManyPaginated`, which returns `{ items, hasMore }`. `findMany` is unchanged.
11
+
12
+ ### Changed
13
+
14
+ - `findByProps` of the chat, LLM call, user, agent task, agent action and agent trace repositories now returns `{ items, hasMore }` instead of an array. Read `items` if you call them directly.
15
+
16
+ ## 0.4.1
17
+
18
+ ### Added
19
+
20
+ - `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.
21
+ - `MongoRepository.findManyPaginated`, which returns `{ items, hasMore }`. `findMany` is unchanged.
22
+
23
+ ## 0.4.0
24
+
25
+ This version breaks the API of the former agentic jobs. Follow the [migration steps](docs/automations.md#migrating-from-agentic-jobs) when you update.
26
+
27
+ ### Added
28
+
29
+ - 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).
30
+ - 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`).
31
+ - `receiveAutomationEvent`, with idempotency keys, a limit on the payload and a limit on the queue (`AUTOMATIONS_MAX_QUEUED_RUNS`).
32
+ - `runner.wake()` to make the runner check right away.
33
+ - `revokeToken` and `isTokenRevoked` in `openloops/authentication`, over the new generic collection `revoked_tokens`.
34
+ - `migrateAutomations` in `openloops/db` and `yarn migrate:automations` to move the data of the former agentic jobs.
35
+
36
+ ### Changed
37
+
38
+ - 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.
39
+ - `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.
40
+ - A run can now have the status `queued` and the trigger `event`, and keeps the `payload` and `idempotencyKey` of the event.
41
+ - `JWT_SECRET` is also needed to sign the tokens of event automations.
42
+
43
+ ### Removed
44
+
45
+ - 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({ where, select, options }: QueryParams<T>): Promise<T[]>;
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({ where, select, options }) {
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, limit = 10 } = options || {};
84
- const _limit = this.clampLimit(limit);
85
- const _skip = +page > 0 ? (+page - 1) * _limit : 0;
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({ where, select, options }) {
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, limit = 10 } = options || {};
61
- const _limit = this.clampLimit(limit);
62
- const _skip = +page > 0 ? (+page - 1) * _limit : 0;
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);
@@ -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 results = await this.automationRunRepository?.findByAutomation(automationId, { page, limit, sortBy });
47
- return { data: results ?? [] };
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 results = await this.automationRunRepository?.findByAutomation(automationId, { page, limit, sortBy });
19
- return { data: results ?? [] };
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 results = await this.automationRunRepository?.findByOwner(currentUser.userId, { page, limit, sortBy }, status);
47
- return { data: results ?? [] };
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 results = await this.automationRunRepository?.findByOwner(currentUser.userId, { page, limit, sortBy }, status);
19
- return { data: results ?? [] };
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 results = await this.automationRepository?.findByOwner(currentUser.userId, { page, limit, sortBy });
47
- return { data: results ?? [] };
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 results = await this.automationRepository?.findByOwner(currentUser.userId, { page, limit, sortBy });
19
- return { data: results ?? [] };
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([
@@ -6,5 +6,8 @@ export declare class ChatRepository {
6
6
  update(chat: Chat): Promise<ChatProps | null>;
7
7
  findById(id: string, select?: QueryParams<ChatProps>['select']): Promise<ChatProps | null>;
8
8
  deleteById(id: string): Promise<number>;
9
- findByProps(where: ChatProps, options: QueryOptions): Promise<ChatProps[]>;
9
+ findByProps(where: ChatProps, options: QueryOptions): Promise<{
10
+ items: ChatProps[];
11
+ hasMore: boolean;
12
+ }>;
10
13
  }
@@ -55,7 +55,7 @@ let ChatRepository = class {
55
55
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
56
56
  }
57
57
  async findByProps(where, options) {
58
- return await this._.findMany({ where, options });
58
+ return await this._.findManyPaginated({ where, options });
59
59
  }
60
60
  };
61
61
  ChatRepository = __decorateClass([
@@ -27,7 +27,7 @@ let ChatRepository = class {
27
27
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
28
28
  }
29
29
  async findByProps(where, options) {
30
- return await this._.findMany({ where, options });
30
+ return await this._.findManyPaginated({ where, options });
31
31
  }
32
32
  };
33
33
  ChatRepository = __decorateClass([
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
8
8
  }
9
9
  export interface Output extends BaseUseCaseOutput {
10
10
  data: ChatProps[] | null | undefined;
11
+ hasMore?: boolean;
11
12
  }
12
13
  export declare class ListChatsByPropsUseCase extends BaseUseCase<Params, Output> {
13
14
  private readonly chatRepository?;
@@ -42,7 +42,7 @@ let ListChatsByPropsUseCase = class extends import_base.BaseUseCase {
42
42
  async execute(params) {
43
43
  const { where, options } = params;
44
44
  const result = await this.chatRepository?.findByProps(where, options || {});
45
- return { data: result };
45
+ return { data: result?.items, hasMore: result?.hasMore };
46
46
  }
47
47
  };
48
48
  ListChatsByPropsUseCase = __decorateClass([
@@ -14,7 +14,7 @@ let ListChatsByPropsUseCase = class extends BaseUseCase {
14
14
  async execute(params) {
15
15
  const { where, options } = params;
16
16
  const result = await this.chatRepository?.findByProps(where, options || {});
17
- return { data: result };
17
+ return { data: result?.items, hasMore: result?.hasMore };
18
18
  }
19
19
  };
20
20
  ListChatsByPropsUseCase = __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 results = await this.chatRepository?._.findMany({
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: results };
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 results = await this.chatRepository?._.findMany({
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: results };
26
+ return { data: result?.items, hasMore: result?.hasMore };
27
27
  }
28
28
  };
29
29
  ListChatsByUserUseCase = __decorateClass([
@@ -6,5 +6,8 @@ export declare class LLMCallRepository {
6
6
  update(llmCall: LLMCall): Promise<LLMCallProps | null>;
7
7
  findById(id: string): Promise<LLMCallProps | null>;
8
8
  deleteById(id: string): Promise<number>;
9
- findByProps(where: LLMCallProps, options?: QueryOptions): Promise<LLMCallProps[]>;
9
+ findByProps(where: LLMCallProps, options?: QueryOptions): Promise<{
10
+ items: LLMCallProps[];
11
+ hasMore: boolean;
12
+ }>;
10
13
  }
@@ -55,7 +55,7 @@ let LLMCallRepository = class {
55
55
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
56
56
  }
57
57
  async findByProps(where, options) {
58
- return await this._.findMany({ where, options });
58
+ return await this._.findManyPaginated({ where, options });
59
59
  }
60
60
  };
61
61
  LLMCallRepository = __decorateClass([
@@ -27,7 +27,7 @@ let LLMCallRepository = class {
27
27
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
28
28
  }
29
29
  async findByProps(where, options) {
30
- return await this._.findMany({ where, options });
30
+ return await this._.findManyPaginated({ where, options });
31
31
  }
32
32
  };
33
33
  LLMCallRepository = __decorateClass([
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
8
8
  }
9
9
  export interface Output extends BaseUseCaseOutput {
10
10
  data: LLMCallProps[] | null | undefined;
11
+ hasMore?: boolean;
11
12
  }
12
13
  export declare class ListLLMCallsByPropsUseCase extends BaseUseCase<Params, Output> {
13
14
  private readonly llmCallRepository?;
@@ -42,7 +42,7 @@ let ListLLMCallsByPropsUseCase = class extends import_base.BaseUseCase {
42
42
  async execute(params) {
43
43
  const { where, options } = params;
44
44
  const result = await this.llmCallRepository?.findByProps(where, options);
45
- return { data: result };
45
+ return { data: result?.items, hasMore: result?.hasMore };
46
46
  }
47
47
  };
48
48
  ListLLMCallsByPropsUseCase = __decorateClass([
@@ -14,7 +14,7 @@ let ListLLMCallsByPropsUseCase = class extends BaseUseCase {
14
14
  async execute(params) {
15
15
  const { where, options } = params;
16
16
  const result = await this.llmCallRepository?.findByProps(where, options);
17
- return { data: result };
17
+ return { data: result?.items, hasMore: result?.hasMore };
18
18
  }
19
19
  };
20
20
  ListLLMCallsByPropsUseCase = __decorateClass([
@@ -5,6 +5,7 @@ export interface Params extends BaseUseCaseParams {
5
5
  }
6
6
  export interface Output extends BaseUseCaseOutput {
7
7
  data: McpServerProps[];
8
+ hasMore?: boolean;
8
9
  }
9
10
  export declare class ListAllMcpServersByUserUseCase extends BaseUseCase<Params, Output> {
10
11
  private readonly mcpServerRepository?;
@@ -43,7 +43,7 @@ let ListAllMcpServersByUserUseCase = class extends import_base.BaseUseCase {
43
43
  const { currentUser } = params;
44
44
  if (!currentUser?.userId) throw new Error("CurrentUser is required to list the Mcp Servers");
45
45
  const results = await this.mcpServerRepository?.findAllByOwner(currentUser.userId);
46
- return { data: results ?? [] };
46
+ return { data: results ?? [], hasMore: false };
47
47
  }
48
48
  };
49
49
  ListAllMcpServersByUserUseCase = __decorateClass([
@@ -15,7 +15,7 @@ let ListAllMcpServersByUserUseCase = class extends BaseUseCase {
15
15
  const { currentUser } = params;
16
16
  if (!currentUser?.userId) throw new Error("CurrentUser is required to list the Mcp Servers");
17
17
  const results = await this.mcpServerRepository?.findAllByOwner(currentUser.userId);
18
- return { data: results ?? [] };
18
+ return { data: results ?? [], hasMore: false };
19
19
  }
20
20
  };
21
21
  ListAllMcpServersByUserUseCase = __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 results = await this.mcpServerRepository?._.findMany({
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: results };
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 results = await this.mcpServerRepository?._.findMany({
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: results };
24
+ return { data: result?.items, hasMore: result?.hasMore };
25
25
  }
26
26
  };
27
27
  ListMcpServersByUserUseCase = __decorateClass([
@@ -4,5 +4,8 @@ export declare class AgentActionRepository {
4
4
  readonly _: MongoRepository<AgentActionProps>;
5
5
  create(action: AgentAction): Promise<AgentAction>;
6
6
  update(action: AgentAction): Promise<AgentActionProps | null>;
7
- findByProps(where: AgentActionProps, options: QueryOptions): Promise<AgentActionProps[]>;
7
+ findByProps(where: AgentActionProps, options: QueryOptions): Promise<{
8
+ items: AgentActionProps[];
9
+ hasMore: boolean;
10
+ }>;
8
11
  }
@@ -50,7 +50,7 @@ let AgentActionRepository = class {
50
50
  });
51
51
  }
52
52
  async findByProps(where, options) {
53
- return await this._.findMany({ where, options });
53
+ return await this._.findManyPaginated({ where, options });
54
54
  }
55
55
  };
56
56
  AgentActionRepository = __decorateClass([
@@ -22,7 +22,7 @@ let AgentActionRepository = class {
22
22
  });
23
23
  }
24
24
  async findByProps(where, options) {
25
- return await this._.findMany({ where, options });
25
+ return await this._.findManyPaginated({ where, options });
26
26
  }
27
27
  };
28
28
  AgentActionRepository = __decorateClass([
@@ -5,5 +5,8 @@ export declare class AgentTaskRepository {
5
5
  create(task: AgentTask): Promise<AgentTask>;
6
6
  update(task: AgentTask): Promise<AgentTaskProps | null>;
7
7
  findById(id: string, select?: QueryParams<AgentTaskProps>['select']): Promise<AgentTaskProps | null>;
8
- findByProps(where: AgentTaskProps, options: QueryOptions): Promise<AgentTaskProps[]>;
8
+ findByProps(where: AgentTaskProps, options: QueryOptions): Promise<{
9
+ items: AgentTaskProps[];
10
+ hasMore: boolean;
11
+ }>;
9
12
  }
@@ -53,7 +53,7 @@ let AgentTaskRepository = class {
53
53
  return await this._.findOne({ where: { _id: this._.parseId(id) }, select });
54
54
  }
55
55
  async findByProps(where, options) {
56
- return await this._.findMany({ where, options });
56
+ return await this._.findManyPaginated({ where, options });
57
57
  }
58
58
  };
59
59
  AgentTaskRepository = __decorateClass([
@@ -25,7 +25,7 @@ let AgentTaskRepository = class {
25
25
  return await this._.findOne({ where: { _id: this._.parseId(id) }, select });
26
26
  }
27
27
  async findByProps(where, options) {
28
- return await this._.findMany({ where, options });
28
+ return await this._.findManyPaginated({ where, options });
29
29
  }
30
30
  };
31
31
  AgentTaskRepository = __decorateClass([
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
8
8
  }
9
9
  export interface Output extends BaseUseCaseOutput {
10
10
  data: AgentActionProps[];
11
+ hasMore?: boolean;
11
12
  }
12
13
  export declare class ListAgentActionsByTaskUseCase extends BaseUseCase<Params, Output> {
13
14
  private readonly agentActionRepository?;
@@ -45,11 +45,11 @@ let ListAgentActionsByTaskUseCase = class extends import_base.BaseUseCase {
45
45
  const { taskId, options, currentUser } = params;
46
46
  if (!taskId) throw new Error("taskId is required");
47
47
  if (!currentUser) this.throwError403();
48
- const data = await this.agentActionRepository?.findByProps(
48
+ const result = await this.agentActionRepository?.findByProps(
49
49
  { ownerId: import_base2.BaseEntity.toObjectId(currentUser?.userId), taskId: import_base2.BaseEntity.toObjectId(taskId) },
50
50
  { limit: DEFAULT_LIMIT, sortBy: { _id: 1 }, ...options }
51
51
  );
52
- return { data: data ?? [] };
52
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
53
53
  }
54
54
  };
55
55
  ListAgentActionsByTaskUseCase = __decorateClass([
@@ -17,11 +17,11 @@ let ListAgentActionsByTaskUseCase = class extends BaseUseCase {
17
17
  const { taskId, options, currentUser } = params;
18
18
  if (!taskId) throw new Error("taskId is required");
19
19
  if (!currentUser) this.throwError403();
20
- const data = await this.agentActionRepository?.findByProps(
20
+ const result = await this.agentActionRepository?.findByProps(
21
21
  { ownerId: BaseEntity.toObjectId(currentUser?.userId), taskId: BaseEntity.toObjectId(taskId) },
22
22
  { limit: DEFAULT_LIMIT, sortBy: { _id: 1 }, ...options }
23
23
  );
24
- return { data: data ?? [] };
24
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
25
25
  }
26
26
  };
27
27
  ListAgentActionsByTaskUseCase = __decorateClass([
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
8
8
  }
9
9
  export interface Output extends BaseUseCaseOutput {
10
10
  data: AgentTaskProps[];
11
+ hasMore?: boolean;
11
12
  }
12
13
  export declare class ListAgentTasksByChatUseCase extends BaseUseCase<Params, Output> {
13
14
  private readonly agentTaskRepository?;
@@ -45,11 +45,11 @@ let ListAgentTasksByChatUseCase = class extends import_base.BaseUseCase {
45
45
  const { chatId, options, currentUser } = params;
46
46
  if (!chatId) throw new Error("chatId is required");
47
47
  if (!currentUser) this.throwError403();
48
- const data = await this.agentTaskRepository?.findByProps(
48
+ const result = await this.agentTaskRepository?.findByProps(
49
49
  { ownerId: import_base2.BaseEntity.toObjectId(currentUser?.userId), chatId: import_base2.BaseEntity.toObjectId(chatId) },
50
50
  { limit: DEFAULT_LIMIT, sortBy: { _id: -1 }, ...options }
51
51
  );
52
- return { data: data ?? [] };
52
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
53
53
  }
54
54
  };
55
55
  ListAgentTasksByChatUseCase = __decorateClass([
@@ -17,11 +17,11 @@ let ListAgentTasksByChatUseCase = class extends BaseUseCase {
17
17
  const { chatId, options, currentUser } = params;
18
18
  if (!chatId) throw new Error("chatId is required");
19
19
  if (!currentUser) this.throwError403();
20
- const data = await this.agentTaskRepository?.findByProps(
20
+ const result = await this.agentTaskRepository?.findByProps(
21
21
  { ownerId: BaseEntity.toObjectId(currentUser?.userId), chatId: BaseEntity.toObjectId(chatId) },
22
22
  { limit: DEFAULT_LIMIT, sortBy: { _id: -1 }, ...options }
23
23
  );
24
- return { data: data ?? [] };
24
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
25
25
  }
26
26
  };
27
27
  ListAgentTasksByChatUseCase = __decorateClass([
@@ -3,5 +3,8 @@ import { AgentTraceEntry, AgentTraceEntryProps } from '../entities';
3
3
  export declare class AgentTraceRepository {
4
4
  readonly _: MongoRepository<AgentTraceEntryProps>;
5
5
  createMany(entries: AgentTraceEntry[]): Promise<number>;
6
- findByProps(where: AgentTraceEntryProps, options: QueryOptions): Promise<AgentTraceEntryProps[]>;
6
+ findByProps(where: AgentTraceEntryProps, options: QueryOptions): Promise<{
7
+ items: AgentTraceEntryProps[];
8
+ hasMore: boolean;
9
+ }>;
7
10
  }
@@ -43,7 +43,7 @@ let AgentTraceRepository = class {
43
43
  return Object.keys(ids).length;
44
44
  }
45
45
  async findByProps(where, options) {
46
- return await this._.findMany({ where, options });
46
+ return await this._.findManyPaginated({ where, options });
47
47
  }
48
48
  };
49
49
  AgentTraceRepository = __decorateClass([
@@ -15,7 +15,7 @@ let AgentTraceRepository = class {
15
15
  return Object.keys(ids).length;
16
16
  }
17
17
  async findByProps(where, options) {
18
- return await this._.findMany({ where, options });
18
+ return await this._.findManyPaginated({ where, options });
19
19
  }
20
20
  };
21
21
  AgentTraceRepository = __decorateClass([
@@ -10,6 +10,7 @@ export interface Params extends BaseUseCaseParams {
10
10
  }
11
11
  export interface Output extends BaseUseCaseOutput {
12
12
  data: AgentTraceEntryProps[];
13
+ hasMore?: boolean;
13
14
  }
14
15
  export declare class ListAgentTracesByChatUseCase extends BaseUseCase<Params, Output> {
15
16
  private readonly agentTraceRepository?;
@@ -45,7 +45,7 @@ let ListAgentTracesByChatUseCase = class extends import_base.BaseUseCase {
45
45
  const { chatId, taskId, answerId, options, currentUser } = params;
46
46
  if (!chatId) throw new Error("chatId is required");
47
47
  if (!currentUser) this.throwError403();
48
- const data = await this.agentTraceRepository?.findByProps(
48
+ const result = await this.agentTraceRepository?.findByProps(
49
49
  {
50
50
  ownerId: import_base2.BaseEntity.toObjectId(currentUser?.userId),
51
51
  chatId: import_base2.BaseEntity.toObjectId(chatId),
@@ -54,7 +54,7 @@ let ListAgentTracesByChatUseCase = class extends import_base.BaseUseCase {
54
54
  },
55
55
  { limit: DEFAULT_LIMIT, sortBy: { _id: 1 }, ...options }
56
56
  );
57
- return { data: data ?? [] };
57
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
58
58
  }
59
59
  };
60
60
  ListAgentTracesByChatUseCase = __decorateClass([
@@ -17,7 +17,7 @@ let ListAgentTracesByChatUseCase = class extends BaseUseCase {
17
17
  const { chatId, taskId, answerId, options, currentUser } = params;
18
18
  if (!chatId) throw new Error("chatId is required");
19
19
  if (!currentUser) this.throwError403();
20
- const data = await this.agentTraceRepository?.findByProps(
20
+ const result = await this.agentTraceRepository?.findByProps(
21
21
  {
22
22
  ownerId: BaseEntity.toObjectId(currentUser?.userId),
23
23
  chatId: BaseEntity.toObjectId(chatId),
@@ -26,7 +26,7 @@ let ListAgentTracesByChatUseCase = class extends BaseUseCase {
26
26
  },
27
27
  { limit: DEFAULT_LIMIT, sortBy: { _id: 1 }, ...options }
28
28
  );
29
- return { data: data ?? [] };
29
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
30
30
  }
31
31
  };
32
32
  ListAgentTracesByChatUseCase = __decorateClass([
@@ -7,6 +7,9 @@ export declare class UserRepository {
7
7
  findById(id: string): Promise<UserProps | null>;
8
8
  findByExternalId(id: string): Promise<UserProps | null>;
9
9
  deleteById(id: string): Promise<number>;
10
- findByProps(where: Partial<UserProps>, options: QueryOptions): Promise<UserProps[]>;
10
+ findByProps(where: Partial<UserProps>, options: QueryOptions): Promise<{
11
+ items: UserProps[];
12
+ hasMore: boolean;
13
+ }>;
11
14
  findByEmailOrUsernameWithPassword(emailOrUsername: string): Promise<User | null>;
12
15
  }
@@ -63,7 +63,7 @@ let UserRepository = class {
63
63
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
64
64
  }
65
65
  async findByProps(where, options) {
66
- return await this._.findMany({ where, select: { password: 0 }, options });
66
+ return await this._.findManyPaginated({ where, select: { password: 0 }, options });
67
67
  }
68
68
  async findByEmailOrUsernameWithPassword(emailOrUsername) {
69
69
  const input = this._.cleanInput(emailOrUsername);
@@ -35,7 +35,7 @@ let UserRepository = class {
35
35
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
36
36
  }
37
37
  async findByProps(where, options) {
38
- return await this._.findMany({ where, select: { password: 0 }, options });
38
+ return await this._.findManyPaginated({ where, select: { password: 0 }, options });
39
39
  }
40
40
  async findByEmailOrUsernameWithPassword(emailOrUsername) {
41
41
  const input = this._.cleanInput(emailOrUsername);
@@ -8,6 +8,7 @@ export interface Params extends BaseUseCaseParams {
8
8
  }
9
9
  export interface Output extends BaseUseCaseOutput {
10
10
  data: UserProps[] | null | undefined;
11
+ hasMore?: boolean;
11
12
  }
12
13
  export declare class ListUsersByPropsUseCase extends BaseUseCase<Params, Output> {
13
14
  private readonly userRepository?;
@@ -42,7 +42,7 @@ let ListUsersByPropsUseCase = class extends import_base.BaseUseCase {
42
42
  async execute(params) {
43
43
  const { where, options } = params;
44
44
  const result = await this.userRepository?.findByProps(where, options || {});
45
- return { data: result };
45
+ return { data: result?.items, hasMore: result?.hasMore };
46
46
  }
47
47
  };
48
48
  ListUsersByPropsUseCase = __decorateClass([
@@ -14,7 +14,7 @@ let ListUsersByPropsUseCase = class extends BaseUseCase {
14
14
  async execute(params) {
15
15
  const { where, options } = params;
16
16
  const result = await this.userRepository?.findByProps(where, options || {});
17
- return { data: result };
17
+ return { data: result?.items, hasMore: result?.hasMore };
18
18
  }
19
19
  };
20
20
  ListUsersByPropsUseCase = __decorateClass([
@@ -14,5 +14,9 @@ export declare class WorkspaceItemRepository {
14
14
  findById(id: string, select?: QueryParams<WorkspaceItemProps>['select']): Promise<WorkspaceItemProps | null>;
15
15
  findByName(lookup: WorkspaceItemLookup, select?: QueryParams<WorkspaceItemProps>['select']): Promise<WorkspaceItemProps | null>;
16
16
  findMany(where: Record<string, unknown>, select?: QueryParams<WorkspaceItemProps>['select'], options?: QueryOptions): Promise<WorkspaceItemProps[]>;
17
+ findManyPaginated(where: Record<string, unknown>, select?: QueryParams<WorkspaceItemProps>['select'], options?: QueryOptions): Promise<{
18
+ items: WorkspaceItemProps[];
19
+ hasMore: boolean;
20
+ }>;
17
21
  deleteById(id: string): Promise<number>;
18
22
  }
@@ -61,6 +61,9 @@ let WorkspaceItemRepository = class {
61
61
  async findMany(where, select, options) {
62
62
  return await this._.findMany({ where, select, options });
63
63
  }
64
+ async findManyPaginated(where, select, options) {
65
+ return await this._.findManyPaginated({ where, select, options });
66
+ }
64
67
  async deleteById(id) {
65
68
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
66
69
  }
@@ -33,6 +33,9 @@ let WorkspaceItemRepository = class {
33
33
  async findMany(where, select, options) {
34
34
  return await this._.findMany({ where, select, options });
35
35
  }
36
+ async findManyPaginated(where, select, options) {
37
+ return await this._.findManyPaginated({ where, select, options });
38
+ }
36
39
  async deleteById(id) {
37
40
  return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
38
41
  }
@@ -10,6 +10,7 @@ export interface Params extends BaseUseCaseParams {
10
10
  }
11
11
  export interface Output extends BaseUseCaseOutput {
12
12
  data: WorkspaceItemProps[];
13
+ hasMore?: boolean;
13
14
  }
14
15
  export declare class ListWorkspaceItemsUseCase extends BaseUseCase<Params, Output> {
15
16
  private readonly workspaceItemRepository?;
@@ -51,12 +51,12 @@ let ListWorkspaceItemsUseCase = class extends import_base.BaseUseCase {
51
51
  ...taskId ? { taskId: import_base2.BaseEntity.toObjectId(taskId) } : {},
52
52
  ...kind ? { kind } : {}
53
53
  };
54
- const data = await this.workspaceItemRepository?.findMany(
54
+ const result = await this.workspaceItemRepository?.findManyPaginated(
55
55
  where,
56
56
  { content: 0 },
57
57
  { limit: DEFAULT_LIMIT, sortBy: { _id: -1 }, ...options }
58
58
  );
59
- return { data: data ?? [] };
59
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
60
60
  }
61
61
  };
62
62
  ListWorkspaceItemsUseCase = __decorateClass([
@@ -23,12 +23,12 @@ let ListWorkspaceItemsUseCase = class extends BaseUseCase {
23
23
  ...taskId ? { taskId: BaseEntity.toObjectId(taskId) } : {},
24
24
  ...kind ? { kind } : {}
25
25
  };
26
- const data = await this.workspaceItemRepository?.findMany(
26
+ const result = await this.workspaceItemRepository?.findManyPaginated(
27
27
  where,
28
28
  { content: 0 },
29
29
  { limit: DEFAULT_LIMIT, sortBy: { _id: -1 }, ...options }
30
30
  );
31
- return { data: data ?? [] };
31
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
32
32
  }
33
33
  };
34
34
  ListWorkspaceItemsUseCase = __decorateClass([
@@ -11,6 +11,7 @@ export interface Params extends BaseUseCaseParams {
11
11
  }
12
12
  export interface Output extends BaseUseCaseOutput {
13
13
  data: WorkspaceItemProps[];
14
+ hasMore?: boolean;
14
15
  }
15
16
  export declare class SearchWorkspaceItemsUseCase extends BaseUseCase<Params, Output> {
16
17
  private readonly workspaceItemRepository?;
@@ -55,12 +55,12 @@ let SearchWorkspaceItemsUseCase = class extends import_base.BaseUseCase {
55
55
  ...kind ? { kind } : {},
56
56
  $or: [{ name: pattern }, { description: pattern }]
57
57
  };
58
- const data = await this.workspaceItemRepository?.findMany(
58
+ const result = await this.workspaceItemRepository?.findManyPaginated(
59
59
  where,
60
60
  { content: 0 },
61
61
  { limit: DEFAULT_LIMIT, sortBy: { _id: -1 }, ...options }
62
62
  );
63
- return { data: data ?? [] };
63
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
64
64
  }
65
65
  };
66
66
  SearchWorkspaceItemsUseCase = __decorateClass([
@@ -27,12 +27,12 @@ let SearchWorkspaceItemsUseCase = class extends BaseUseCase {
27
27
  ...kind ? { kind } : {},
28
28
  $or: [{ name: pattern }, { description: pattern }]
29
29
  };
30
- const data = await this.workspaceItemRepository?.findMany(
30
+ const result = await this.workspaceItemRepository?.findManyPaginated(
31
31
  where,
32
32
  { content: 0 },
33
33
  { limit: DEFAULT_LIMIT, sortBy: { _id: -1 }, ...options }
34
34
  );
35
- return { data: data ?? [] };
35
+ return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
36
36
  }
37
37
  };
38
38
  SearchWorkspaceItemsUseCase = __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
@@ -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 import is now `openloops/automations`, the functions and types swap `AgenticJob` for `Automation`, the variables are `AUTOMATIONS_*`, the collections are `automations` and `automation_runs`, the runs point to their automation with `automationId`, and `recurrence` and `timezone` live inside `trigger`. The old names are not kept as aliases.
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 move the data, run this once per database after deploying the new version, or before it if you prefer. 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.
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`. Stop the runner of the old version first: a run that is in progress while the collection is renamed fails.
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.0",
3
+ "version": "0.4.2",
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",