openloops 0.4.1 → 0.4.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 +19 -1
- package/dist/common/helpers/escape-regex.d.ts +1 -0
- package/dist/common/helpers/escape-regex.js +30 -0
- package/dist/common/helpers/escape-regex.mjs +7 -0
- package/dist/common/helpers/index.d.ts +1 -0
- package/dist/common/helpers/index.js +2 -0
- package/dist/common/helpers/index.mjs +1 -0
- package/dist/harness/utils/rank-tools-by-keywords.js +2 -4
- package/dist/harness/utils/rank-tools-by-keywords.mjs +2 -4
- package/dist/services/chats/repositories/chat.repository.d.ts +4 -1
- package/dist/services/chats/repositories/chat.repository.js +1 -1
- package/dist/services/chats/repositories/chat.repository.mjs +1 -1
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +1 -0
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +1 -1
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +1 -1
- 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 +5 -2
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -2
- package/dist/services/llmcalls/repositories/llmcall.repository.d.ts +4 -1
- package/dist/services/llmcalls/repositories/llmcall.repository.js +1 -1
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +1 -1
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +1 -0
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +1 -1
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +1 -1
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +1 -0
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +1 -1
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +1 -1
- package/dist/services/tasks/repositories/agent-action.repository.d.ts +4 -1
- package/dist/services/tasks/repositories/agent-action.repository.js +1 -1
- package/dist/services/tasks/repositories/agent-action.repository.mjs +1 -1
- package/dist/services/tasks/repositories/agent-task.repository.d.ts +4 -1
- package/dist/services/tasks/repositories/agent-task.repository.js +1 -1
- package/dist/services/tasks/repositories/agent-task.repository.mjs +1 -1
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +1 -0
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +2 -2
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +2 -2
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +1 -0
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +2 -2
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +2 -2
- package/dist/services/traces/repositories/agent-trace.repository.d.ts +4 -1
- package/dist/services/traces/repositories/agent-trace.repository.js +1 -1
- package/dist/services/traces/repositories/agent-trace.repository.mjs +1 -1
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +1 -0
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +2 -2
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +2 -2
- package/dist/services/users/repositories/user.repository.d.ts +4 -1
- package/dist/services/users/repositories/user.repository.js +1 -1
- package/dist/services/users/repositories/user.repository.mjs +1 -1
- package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +1 -0
- package/dist/services/users/use-cases/list-users-by-props.use-case.js +1 -1
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +1 -1
- package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +4 -0
- package/dist/services/workspaces/repositories/workspace-item.repository.js +3 -0
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +3 -0
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +1 -0
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +2 -2
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +2 -2
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +1 -0
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +4 -4
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +4 -4
- package/docs/chats.md +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,25 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
-
##
|
|
5
|
+
## 0.4.3
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `search` in `listChatsByUser`: returns only the chats with a message whose content contains the text, ignoring case. The text is escaped, so it is matched literally and not as a regular expression.
|
|
10
|
+
- `escapeRegex` helper in `src/common/helpers`, now used by `listChatsByUser`, `searchWorkspaceItems` and the tool ranking instead of three copies of the same escape.
|
|
11
|
+
|
|
12
|
+
## 0.4.2
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `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`.
|
|
17
|
+
- `WorkspaceItemRepository.findManyPaginated`, which returns `{ items, hasMore }`. `findMany` is unchanged.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- `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.
|
|
22
|
+
|
|
23
|
+
## 0.4.1
|
|
6
24
|
|
|
7
25
|
### Added
|
|
8
26
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeRegex(input?: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var escape_regex_exports = {};
|
|
20
|
+
__export(escape_regex_exports, {
|
|
21
|
+
escapeRegex: () => escapeRegex
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(escape_regex_exports);
|
|
24
|
+
function escapeRegex(input = "") {
|
|
25
|
+
return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
escapeRegex
|
|
30
|
+
});
|
|
@@ -15,10 +15,12 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var helpers_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(helpers_exports);
|
|
18
|
+
__reExport(helpers_exports, require("./escape-regex"), module.exports);
|
|
18
19
|
__reExport(helpers_exports, require("./extract-json-from-text"), module.exports);
|
|
19
20
|
__reExport(helpers_exports, require("./sanitize-string"), module.exports);
|
|
20
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
22
|
0 && (module.exports = {
|
|
23
|
+
...require("./escape-regex"),
|
|
22
24
|
...require("./extract-json-from-text"),
|
|
23
25
|
...require("./sanitize-string")
|
|
24
26
|
});
|
|
@@ -21,9 +21,7 @@ __export(rank_tools_by_keywords_exports, {
|
|
|
21
21
|
rankToolsByKeywords: () => rankToolsByKeywords
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(rank_tools_by_keywords_exports);
|
|
24
|
-
|
|
25
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
-
}
|
|
24
|
+
var import_helpers = require("../../common/helpers/index.js");
|
|
27
25
|
function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
|
|
28
26
|
const NAME_WEIGHT_MULTIPLIER = 2.5;
|
|
29
27
|
const DESCRIPTION_WEIGHT_MULTIPLIER = 1;
|
|
@@ -36,7 +34,7 @@ function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
|
|
|
36
34
|
for (const { keyword, weight } of keywords) {
|
|
37
35
|
if (!keyword || weight <= 0) continue;
|
|
38
36
|
const cleanKeyword = keyword.trim();
|
|
39
|
-
const escapedKeyword =
|
|
37
|
+
const escapedKeyword = (0, import_helpers.escapeRegex)(cleanKeyword);
|
|
40
38
|
const regex = new RegExp(`\\b${escapedKeyword}\\b`, "gi");
|
|
41
39
|
const nameMatches = (normalizedName.match(regex) || []).length;
|
|
42
40
|
const descMatches = (normalizedDescription.match(regex) || []).length;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import "../../chunk-CF3WOMB3.mjs";
|
|
2
|
-
|
|
3
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4
|
-
}
|
|
2
|
+
import { escapeRegex } from "../../common/helpers/index.js";
|
|
5
3
|
function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
|
|
6
4
|
const NAME_WEIGHT_MULTIPLIER = 2.5;
|
|
7
5
|
const DESCRIPTION_WEIGHT_MULTIPLIER = 1;
|
|
@@ -14,7 +12,7 @@ function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
|
|
|
14
12
|
for (const { keyword, weight } of keywords) {
|
|
15
13
|
if (!keyword || weight <= 0) continue;
|
|
16
14
|
const cleanKeyword = keyword.trim();
|
|
17
|
-
const escapedKeyword =
|
|
15
|
+
const escapedKeyword = escapeRegex(cleanKeyword);
|
|
18
16
|
const regex = new RegExp(`\\b${escapedKeyword}\\b`, "gi");
|
|
19
17
|
const nameMatches = (normalizedName.match(regex) || []).length;
|
|
20
18
|
const descMatches = (normalizedDescription.match(regex) || []).length;
|
|
@@ -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<
|
|
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._.
|
|
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._.
|
|
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([
|
|
@@ -5,6 +5,7 @@ import { ChatProps, ExecutionMode } from '../entities';
|
|
|
5
5
|
export interface Params extends BaseUseCaseParams {
|
|
6
6
|
filters?: Partial<ChatProps>;
|
|
7
7
|
executionMode?: ExecutionMode;
|
|
8
|
+
search?: string;
|
|
8
9
|
options?: QueryOptions;
|
|
9
10
|
}
|
|
10
11
|
export interface Output extends BaseUseCaseOutput {
|
|
@@ -32,6 +32,7 @@ __export(list_chats_by_user_use_case_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(list_chats_by_user_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
34
|
var import_mongodb = require("mongodb");
|
|
35
|
+
var import_helpers = require("../../../common/helpers/index.js");
|
|
35
36
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
36
37
|
var import_repositories2 = require("../repositories");
|
|
37
38
|
let ListChatsByUserUseCase = class extends import_base.BaseUseCase {
|
|
@@ -41,13 +42,15 @@ let ListChatsByUserUseCase = class extends import_base.BaseUseCase {
|
|
|
41
42
|
}
|
|
42
43
|
chatRepository;
|
|
43
44
|
async execute(params) {
|
|
44
|
-
const { options, executionMode, currentUser } = params;
|
|
45
|
+
const { options, executionMode, search, currentUser } = params;
|
|
45
46
|
const { page = 1, limit: pageSize = 10 } = options || {};
|
|
47
|
+
const term = (0, import_helpers.escapeRegex)(search?.trim());
|
|
46
48
|
const result = await this.chatRepository?._.findManyPaginated({
|
|
47
49
|
where: {
|
|
48
50
|
ownerId: new import_mongodb.ObjectId(currentUser?.userId),
|
|
49
51
|
...executionMode === "autonomous" ? { "settings.executionMode": "autonomous" } : {},
|
|
50
|
-
...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {}
|
|
52
|
+
...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {},
|
|
53
|
+
...term ? { "messages.content": { $regex: term, $options: "i" } } : {}
|
|
51
54
|
},
|
|
52
55
|
options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
|
|
53
56
|
});
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
5
|
import { autoInjectable, inject } from "tsyringe";
|
|
6
6
|
import { ObjectId } from "mongodb";
|
|
7
|
+
import { escapeRegex } from "../../../common/helpers/index.js";
|
|
7
8
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
8
9
|
import { ChatRepository } from "../repositories";
|
|
9
10
|
let ListChatsByUserUseCase = class extends BaseUseCase {
|
|
@@ -13,13 +14,15 @@ let ListChatsByUserUseCase = class extends BaseUseCase {
|
|
|
13
14
|
}
|
|
14
15
|
chatRepository;
|
|
15
16
|
async execute(params) {
|
|
16
|
-
const { options, executionMode, currentUser } = params;
|
|
17
|
+
const { options, executionMode, search, currentUser } = params;
|
|
17
18
|
const { page = 1, limit: pageSize = 10 } = options || {};
|
|
19
|
+
const term = escapeRegex(search?.trim());
|
|
18
20
|
const result = await this.chatRepository?._.findManyPaginated({
|
|
19
21
|
where: {
|
|
20
22
|
ownerId: new ObjectId(currentUser?.userId),
|
|
21
23
|
...executionMode === "autonomous" ? { "settings.executionMode": "autonomous" } : {},
|
|
22
|
-
...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {}
|
|
24
|
+
...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {},
|
|
25
|
+
...term ? { "messages.content": { $regex: term, $options: "i" } } : {}
|
|
23
26
|
},
|
|
24
27
|
options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
|
|
25
28
|
});
|
|
@@ -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<
|
|
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._.
|
|
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._.
|
|
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([
|
|
@@ -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<
|
|
7
|
+
findByProps(where: AgentActionProps, options: QueryOptions): Promise<{
|
|
8
|
+
items: AgentActionProps[];
|
|
9
|
+
hasMore: boolean;
|
|
10
|
+
}>;
|
|
8
11
|
}
|
|
@@ -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<
|
|
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._.
|
|
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._.
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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<
|
|
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._.
|
|
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._.
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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<
|
|
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._.
|
|
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._.
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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?;
|
|
@@ -31,6 +31,7 @@ __export(search_workspace_items_use_case_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(search_workspace_items_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
|
+
var import_helpers = require("../../../common/helpers/index.js");
|
|
34
35
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
36
|
var import_base2 = require("../../../common/base/base.entity.js");
|
|
36
37
|
var import_repositories2 = require("../repositories");
|
|
@@ -46,8 +47,7 @@ let SearchWorkspaceItemsUseCase = class extends import_base.BaseUseCase {
|
|
|
46
47
|
if (!chatId) throw new Error("chatId is required");
|
|
47
48
|
if (!query?.trim()) throw new Error("query is required");
|
|
48
49
|
if (!currentUser) this.throwError403();
|
|
49
|
-
const
|
|
50
|
-
const pattern = { $regex: escaped, $options: "i" };
|
|
50
|
+
const pattern = { $regex: (0, import_helpers.escapeRegex)(query.trim()), $options: "i" };
|
|
51
51
|
const where = {
|
|
52
52
|
ownerId: import_base2.BaseEntity.toObjectId(currentUser?.userId),
|
|
53
53
|
chatId: import_base2.BaseEntity.toObjectId(chatId),
|
|
@@ -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
|
|
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:
|
|
63
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
SearchWorkspaceItemsUseCase = __decorateClass([
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
__decorateParam
|
|
4
4
|
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
5
|
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { escapeRegex } from "../../../common/helpers/index.js";
|
|
6
7
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
8
|
import { BaseEntity } from "../../../common/base/base.entity.js";
|
|
8
9
|
import { WorkspaceItemRepository } from "../repositories";
|
|
@@ -18,8 +19,7 @@ let SearchWorkspaceItemsUseCase = class extends BaseUseCase {
|
|
|
18
19
|
if (!chatId) throw new Error("chatId is required");
|
|
19
20
|
if (!query?.trim()) throw new Error("query is required");
|
|
20
21
|
if (!currentUser) this.throwError403();
|
|
21
|
-
const
|
|
22
|
-
const pattern = { $regex: escaped, $options: "i" };
|
|
22
|
+
const pattern = { $regex: escapeRegex(query.trim()), $options: "i" };
|
|
23
23
|
const where = {
|
|
24
24
|
ownerId: BaseEntity.toObjectId(currentUser?.userId),
|
|
25
25
|
chatId: BaseEntity.toObjectId(chatId),
|
|
@@ -27,12 +27,12 @@ let SearchWorkspaceItemsUseCase = class extends BaseUseCase {
|
|
|
27
27
|
...kind ? { kind } : {},
|
|
28
28
|
$or: [{ name: pattern }, { description: pattern }]
|
|
29
29
|
};
|
|
30
|
-
const
|
|
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:
|
|
35
|
+
return { data: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
SearchWorkspaceItemsUseCase = __decorateClass([
|
package/docs/chats.md
CHANGED
|
@@ -53,6 +53,12 @@ const interactive = await listChatsByUser({ executionMode: 'interactive', curren
|
|
|
53
53
|
|
|
54
54
|
`executionMode` is optional. `autonomous` returns the chats that were created by an autonomous run and `interactive` returns the rest, including the chats saved before the mode existed. Combine it with `state.status` to show the autonomous runs that need attention: `awaiting_user_confirmation` or `awaiting_user_input` mean the run is paused until the user answers in the chat, and `failed` means it failed.
|
|
55
55
|
|
|
56
|
+
```typescript
|
|
57
|
+
const found = await listChatsByUser({ search: 'netflix', currentUser })
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`search` is optional. It returns the chats with at least one message whose content contains the text, ignoring case, in the same order and with the same pagination. The text is matched literally, so characters such as `(` or `.` have no special meaning. It reads the messages without an index, which is fine for the chats of one user. An empty text is ignored.
|
|
61
|
+
|
|
56
62
|
## Getting one chat
|
|
57
63
|
|
|
58
64
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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",
|