@carlonicora/nestjs-neo4jsonapi 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/graph/graph.module.d.ts.map +1 -1
- package/dist/agents/graph/graph.module.js +3 -0
- package/dist/agents/graph/graph.module.js.map +1 -1
- package/dist/agents/graph/interfaces/graph.catalog.interface.d.ts +24 -0
- package/dist/agents/graph/interfaces/graph.catalog.interface.d.ts.map +1 -1
- package/dist/agents/graph/services/graph.catalog.service.d.ts +9 -0
- package/dist/agents/graph/services/graph.catalog.service.d.ts.map +1 -1
- package/dist/agents/graph/services/graph.catalog.service.js +61 -1
- package/dist/agents/graph/services/graph.catalog.service.js.map +1 -1
- package/dist/agents/graph/services/graph.search.service.d.ts +16 -1
- package/dist/agents/graph/services/graph.search.service.d.ts.map +1 -1
- package/dist/agents/graph/services/graph.search.service.js +51 -4
- package/dist/agents/graph/services/graph.search.service.js.map +1 -1
- package/dist/agents/graph/services/humanize-tool.d.ts +17 -2
- package/dist/agents/graph/services/humanize-tool.d.ts.map +1 -1
- package/dist/agents/graph/services/humanize-tool.js +71 -6
- package/dist/agents/graph/services/humanize-tool.js.map +1 -1
- package/dist/agents/graph/services/materialise-bridge.d.ts +6 -0
- package/dist/agents/graph/services/materialise-bridge.d.ts.map +1 -1
- package/dist/agents/graph/services/materialise-bridge.js +17 -1
- package/dist/agents/graph/services/materialise-bridge.js.map +1 -1
- package/dist/agents/graph/services/scope.guard.d.ts +43 -0
- package/dist/agents/graph/services/scope.guard.d.ts.map +1 -0
- package/dist/agents/graph/services/scope.guard.js +91 -0
- package/dist/agents/graph/services/scope.guard.js.map +1 -0
- package/dist/agents/graph/tools/read-entity.tool.d.ts +9 -1
- package/dist/agents/graph/tools/read-entity.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/read-entity.tool.js +30 -5
- package/dist/agents/graph/tools/read-entity.tool.js.map +1 -1
- package/dist/agents/graph/tools/resolve-entity.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/resolve-entity.tool.js +8 -1
- package/dist/agents/graph/tools/resolve-entity.tool.js.map +1 -1
- package/dist/agents/graph/tools/search-entities.tool.d.ts +9 -1
- package/dist/agents/graph/tools/search-entities.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/search-entities.tool.js +37 -8
- package/dist/agents/graph/tools/search-entities.tool.js.map +1 -1
- package/dist/agents/graph/tools/tool.factory.d.ts +4 -0
- package/dist/agents/graph/tools/tool.factory.d.ts.map +1 -1
- package/dist/agents/graph/tools/tool.factory.js.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.d.ts +9 -1
- package/dist/agents/graph/tools/traverse.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.js +21 -5
- package/dist/agents/graph/tools/traverse.tool.js.map +1 -1
- package/dist/agents/operator/contexts/operator.context.d.ts +4 -0
- package/dist/agents/operator/contexts/operator.context.d.ts.map +1 -1
- package/dist/agents/operator/contexts/operator.context.js +4 -0
- package/dist/agents/operator/contexts/operator.context.js.map +1 -1
- package/dist/agents/operator/operator.module.d.ts.map +1 -1
- package/dist/agents/operator/operator.module.js +4 -0
- package/dist/agents/operator/operator.module.js.map +1 -1
- package/dist/agents/operator/services/operator.service.d.ts +8 -0
- package/dist/agents/operator/services/operator.service.d.ts.map +1 -1
- package/dist/agents/operator/services/operator.service.js +8 -0
- package/dist/agents/operator/services/operator.service.js.map +1 -1
- package/dist/agents/operator/tools/entity-write.tools.d.ts +124 -0
- package/dist/agents/operator/tools/entity-write.tools.d.ts.map +1 -0
- package/dist/agents/operator/tools/entity-write.tools.js +471 -0
- package/dist/agents/operator/tools/entity-write.tools.js.map +1 -0
- package/dist/agents/operator/tools/operator.tool.registry.d.ts +5 -1
- package/dist/agents/operator/tools/operator.tool.registry.d.ts.map +1 -1
- package/dist/agents/operator/tools/operator.tool.registry.js +19 -2
- package/dist/agents/operator/tools/operator.tool.registry.js.map +1 -1
- package/dist/agents/operator/tools/search-documents.tool.d.ts +16 -1
- package/dist/agents/operator/tools/search-documents.tool.d.ts.map +1 -1
- package/dist/agents/operator/tools/search-documents.tool.js +59 -3
- package/dist/agents/operator/tools/search-documents.tool.js.map +1 -1
- package/dist/agents/prompts/index.d.ts +1 -0
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/prompts/index.js +7 -1
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/responder/contexts/responder.context.d.ts +12 -0
- package/dist/agents/responder/contexts/responder.context.d.ts.map +1 -1
- package/dist/agents/responder/contexts/responder.context.js +4 -0
- package/dist/agents/responder/contexts/responder.context.js.map +1 -1
- package/dist/agents/responder/factories/responder.context.factory.d.ts +4 -0
- package/dist/agents/responder/factories/responder.context.factory.d.ts.map +1 -1
- package/dist/agents/responder/factories/responder.context.factory.js +2 -0
- package/dist/agents/responder/factories/responder.context.factory.js.map +1 -1
- package/dist/agents/responder/nodes/graph.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/graph.node.service.js +18 -2
- package/dist/agents/responder/nodes/graph.node.service.js.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts +32 -0
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.js +31 -19
- package/dist/agents/responder/nodes/responder.answer.node.service.js.map +1 -1
- package/dist/agents/responder/services/responder.service.d.ts +4 -0
- package/dist/agents/responder/services/responder.service.d.ts.map +1 -1
- package/dist/agents/responder/services/responder.service.js +2 -0
- package/dist/agents/responder/services/responder.service.js.map +1 -1
- package/dist/common/interfaces/entity.schema.interface.d.ts +16 -0
- package/dist/common/interfaces/entity.schema.interface.d.ts.map +1 -1
- package/dist/config/interfaces/config.prompts.interface.d.ts +12 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts.map +1 -1
- package/dist/core/blocknote/services/blocknote.service.d.ts +23 -14
- package/dist/core/blocknote/services/blocknote.service.d.ts.map +1 -1
- package/dist/core/blocknote/services/blocknote.service.js +48 -32
- package/dist/core/blocknote/services/blocknote.service.js.map +1 -1
- package/dist/core/email/email.helpers.d.ts +18 -0
- package/dist/core/email/email.helpers.d.ts.map +1 -0
- package/dist/core/email/email.helpers.js +50 -0
- package/dist/core/email/email.helpers.js.map +1 -0
- package/dist/core/email/index.d.ts +1 -0
- package/dist/core/email/index.d.ts.map +1 -1
- package/dist/core/email/index.js +2 -0
- package/dist/core/email/index.js.map +1 -1
- package/dist/core/email/services/email.service.d.ts.map +1 -1
- package/dist/core/email/services/email.service.js +4 -4
- package/dist/core/email/services/email.service.js.map +1 -1
- package/dist/core/llm/services/llm.service.d.ts.map +1 -1
- package/dist/core/llm/services/llm.service.js +34 -2
- package/dist/core/llm/services/llm.service.js.map +1 -1
- package/dist/core/llm/services/tool-error-feedback.d.ts +40 -0
- package/dist/core/llm/services/tool-error-feedback.d.ts.map +1 -0
- package/dist/core/llm/services/tool-error-feedback.js +131 -0
- package/dist/core/llm/services/tool-error-feedback.js.map +1 -0
- package/dist/foundations/assistant/assistant.module.d.ts.map +1 -1
- package/dist/foundations/assistant/assistant.module.js +7 -1
- package/dist/foundations/assistant/assistant.module.js.map +1 -1
- package/dist/foundations/assistant/controllers/assistant.controller.d.ts +13 -1
- package/dist/foundations/assistant/controllers/assistant.controller.d.ts.map +1 -1
- package/dist/foundations/assistant/controllers/assistant.controller.js +37 -3
- package/dist/foundations/assistant/controllers/assistant.controller.js.map +1 -1
- package/dist/foundations/assistant/dtos/assistant-append.dto.d.ts +6 -0
- package/dist/foundations/assistant/dtos/assistant-append.dto.d.ts.map +1 -1
- package/dist/foundations/assistant/dtos/assistant-append.dto.js +1 -1
- package/dist/foundations/assistant/dtos/assistant-append.dto.js.map +1 -1
- package/dist/foundations/assistant/dtos/assistant-post.dto.d.ts +29 -0
- package/dist/foundations/assistant/dtos/assistant-post.dto.d.ts.map +1 -1
- package/dist/foundations/assistant/dtos/assistant-post.dto.js +47 -2
- package/dist/foundations/assistant/dtos/assistant-post.dto.js.map +1 -1
- package/dist/foundations/assistant/repositories/assistant.repository.d.ts +22 -0
- package/dist/foundations/assistant/repositories/assistant.repository.d.ts.map +1 -1
- package/dist/foundations/assistant/repositories/assistant.repository.js +28 -0
- package/dist/foundations/assistant/repositories/assistant.repository.js.map +1 -1
- package/dist/foundations/assistant/services/assistant-mention.extractor.d.ts +36 -0
- package/dist/foundations/assistant/services/assistant-mention.extractor.d.ts.map +1 -0
- package/dist/foundations/assistant/services/assistant-mention.extractor.js +99 -0
- package/dist/foundations/assistant/services/assistant-mention.extractor.js.map +1 -0
- package/dist/foundations/assistant/services/assistant.service.d.ts +84 -2
- package/dist/foundations/assistant/services/assistant.service.d.ts.map +1 -1
- package/dist/foundations/assistant/services/assistant.service.js +312 -60
- package/dist/foundations/assistant/services/assistant.service.js.map +1 -1
- package/dist/foundations/auth/services/auth.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.service.js +2 -0
- package/dist/foundations/auth/services/auth.service.js.map +1 -1
- package/dist/foundations/user/services/user.service.d.ts.map +1 -1
- package/dist/foundations/user/services/user.service.js +3 -0
- package/dist/foundations/user/services/user.service.js.map +1 -1
- package/dist/foundations/waitlist/services/waitlist.service.d.ts.map +1 -1
- package/dist/foundations/waitlist/services/waitlist.service.js +2 -0
- package/dist/foundations/waitlist/services/waitlist.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,11 +12,13 @@ const graph_module_1 = require("../../agents/graph/graph.module");
|
|
|
12
12
|
const operator_module_1 = require("../../agents/operator/operator.module");
|
|
13
13
|
const responder_module_1 = require("../../agents/responder/responder.module");
|
|
14
14
|
const registry_1 = require("../../common/registries/registry");
|
|
15
|
+
const blocknote_module_1 = require("../../core/blocknote/blocknote.module");
|
|
15
16
|
const assistant_action_module_1 = require("../assistant-action/assistant-action.module");
|
|
16
17
|
const assistant_message_module_1 = require("../assistant-message/assistant-message.module");
|
|
17
18
|
const assistant_controller_1 = require("./controllers/assistant.controller");
|
|
18
19
|
const assistant_1 = require("./entities/assistant");
|
|
19
20
|
const assistant_repository_1 = require("./repositories/assistant.repository");
|
|
21
|
+
const assistant_mention_extractor_1 = require("./services/assistant-mention.extractor");
|
|
20
22
|
const assistant_service_1 = require("./services/assistant.service");
|
|
21
23
|
let AssistantModule = class AssistantModule {
|
|
22
24
|
onModuleInit() {
|
|
@@ -31,15 +33,19 @@ exports.AssistantModule = AssistantModule = __decorate([
|
|
|
31
33
|
// service/repository to create and resolve pending actions.
|
|
32
34
|
// forwardRef on OperatorModule: its standalone OperatorController needs
|
|
33
35
|
// AssistantService while AssistantService needs OperatorService.
|
|
36
|
+
// GraphModule supplies GraphCatalogService and ScopeGuard (mention
|
|
37
|
+
// validation + hydration scope filtering); BlockNoteModule supplies the
|
|
38
|
+
// markdown conversion used to persist a rich composer payload.
|
|
34
39
|
imports: [
|
|
35
40
|
graph_module_1.GraphModule,
|
|
41
|
+
blocknote_module_1.BlockNoteModule,
|
|
36
42
|
responder_module_1.ResponderModule,
|
|
37
43
|
(0, common_1.forwardRef)(() => operator_module_1.OperatorModule),
|
|
38
44
|
assistant_message_module_1.AssistantMessageModule,
|
|
39
45
|
(0, common_1.forwardRef)(() => assistant_action_module_1.AssistantActionModule),
|
|
40
46
|
],
|
|
41
47
|
controllers: [assistant_controller_1.AssistantController],
|
|
42
|
-
providers: [assistant_1.AssistantDescriptor.model.serialiser, assistant_repository_1.AssistantRepository, assistant_service_1.AssistantService],
|
|
48
|
+
providers: [assistant_1.AssistantDescriptor.model.serialiser, assistant_repository_1.AssistantRepository, assistant_mention_extractor_1.AssistantMentionExtractor, assistant_service_1.AssistantService],
|
|
43
49
|
exports: [assistant_service_1.AssistantService, assistant_message_module_1.AssistantMessageModule],
|
|
44
50
|
})
|
|
45
51
|
], AssistantModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.module.js","sourceRoot":"","sources":["../../../src/foundations/assistant/assistant.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkE;AAClE,kEAA8D;AAC9D,2EAAuE;AACvE,8EAA0E;AAC1E,+DAAiE;AACjE,yFAAoF;AACpF,4FAAuF;AACvF,6EAAyE;AACzE,oDAA2D;AAC3D,8EAA0E;AAC1E,oEAAgE;
|
|
1
|
+
{"version":3,"file":"assistant.module.js","sourceRoot":"","sources":["../../../src/foundations/assistant/assistant.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkE;AAClE,kEAA8D;AAC9D,2EAAuE;AACvE,8EAA0E;AAC1E,+DAAiE;AACjE,4EAAwE;AACxE,yFAAoF;AACpF,4FAAuF;AACvF,6EAAyE;AACzE,oDAA2D;AAC3D,8EAA0E;AAC1E,wFAAmF;AACnF,oEAAgE;AAuBzD,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAAY;QACV,wBAAa,CAAC,QAAQ,CAAC,+BAAmB,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;CACF,CAAA;AAJY,0CAAe;0BAAf,eAAe;IArB3B,IAAA,eAAM,EAAC;QACN,wEAAwE;QACxE,wEAAwE;QACxE,4DAA4D;QAC5D,wEAAwE;QACxE,iEAAiE;QACjE,mEAAmE;QACnE,wEAAwE;QACxE,+DAA+D;QAC/D,OAAO,EAAE;YACP,0BAAW;YACX,kCAAe;YACf,kCAAe;YACf,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,gCAAc,CAAC;YAChC,iDAAsB;YACtB,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,+CAAqB,CAAC;SACxC;QACD,WAAW,EAAE,CAAC,0CAAmB,CAAC;QAClC,SAAS,EAAE,CAAC,+BAAmB,CAAC,KAAK,CAAC,UAAU,EAAE,0CAAmB,EAAE,uDAAyB,EAAE,oCAAgB,CAAC;QACnH,OAAO,EAAE,CAAC,oCAAgB,EAAE,iDAAsB,CAAC;KACpD,CAAC;GACW,eAAe,CAI3B"}
|
|
@@ -49,8 +49,20 @@ export declare class AssistantController {
|
|
|
49
49
|
/**
|
|
50
50
|
* GET /assistants — list the current user's assistant threads.
|
|
51
51
|
* RBAC (company + owner) is enforced by the repository's `buildUserHasAccess` override.
|
|
52
|
+
*
|
|
53
|
+
* `boundType` + `boundId` narrow the list to the threads bound to one
|
|
54
|
+
* resource (e.g. a campaign). Both are required together: a bound id with no
|
|
55
|
+
* type is ambiguous, and a type with no id names no resource. Supplying them
|
|
56
|
+
* is a custom filter, so it bypasses the CRUD handler and calls the service.
|
|
57
|
+
*/
|
|
58
|
+
findAll(reply: FastifyReply, query: any, search?: string, fetchAll?: boolean, orderBy?: string, boundType?: string, boundId?: string): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Validate the polymorphic `content` relationship reference against the model
|
|
61
|
+
* registry. The DTO can only assert that `type` is a non-empty string —
|
|
62
|
+
* BOUND_TO accepts any registered model, and the registry is the only place
|
|
63
|
+
* that knows the full set.
|
|
52
64
|
*/
|
|
53
|
-
|
|
65
|
+
private resolveBoundContent;
|
|
54
66
|
/**
|
|
55
67
|
* GET /assistants/:assistantId — read a single assistant thread.
|
|
56
68
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.controller.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/controllers/assistant.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assistant.controller.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/controllers/assistant.controller.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;AAElG,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAK9D,OAAO,EAAE,gBA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,MAAM,CAAQ,KAAK,EAAE,YAAY,EAAwB,WAAW,EAAE,MAAM;CAGnF"}
|
|
@@ -18,6 +18,7 @@ exports.mergeIncluded = mergeIncluded;
|
|
|
18
18
|
const common_1 = require("@nestjs/common");
|
|
19
19
|
const jwt_auth_guard_1 = require("../../../common/guards/jwt.auth.guard");
|
|
20
20
|
const crud_handlers_1 = require("../../../common/handlers/crud.handlers");
|
|
21
|
+
const registry_1 = require("../../../common/registries/registry");
|
|
21
22
|
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
22
23
|
const assistant_append_dto_1 = require("../dtos/assistant-append.dto");
|
|
23
24
|
const assistant_patch_dto_1 = require("../dtos/assistant-patch.dto");
|
|
@@ -87,7 +88,9 @@ let AssistantController = AssistantController_1 = class AssistantController {
|
|
|
87
88
|
*/
|
|
88
89
|
async create(body, req) {
|
|
89
90
|
const { content, title, howToMode, limitToHowToId } = body.data.attributes;
|
|
90
|
-
this.
|
|
91
|
+
const boundContent = this.resolveBoundContent(body.data.relationships?.content?.data);
|
|
92
|
+
this.logger.log(`create: userId=${req.user.userId} companyId=${req.user.companyId} firstMessageLen=${content.length}` +
|
|
93
|
+
(boundContent ? ` boundTo=${boundContent.type}/${boundContent.id}` : ""));
|
|
91
94
|
const { assistant, userMessage, assistantMessage, toolCalls } = await this.assistants.createWithFirstMessage({
|
|
92
95
|
companyId: req.user.companyId,
|
|
93
96
|
userId: req.user.userId,
|
|
@@ -95,6 +98,7 @@ let AssistantController = AssistantController_1 = class AssistantController {
|
|
|
95
98
|
title,
|
|
96
99
|
howToMode,
|
|
97
100
|
limitToHowToId,
|
|
101
|
+
boundContent,
|
|
98
102
|
});
|
|
99
103
|
const document = (await this.jsonApi.buildSingle(assistant_1.AssistantDescriptor.model, assistant));
|
|
100
104
|
const messagesDoc = (await this.jsonApi.buildList(assistant_message_1.AssistantMessageDescriptor.model, [
|
|
@@ -145,10 +149,38 @@ let AssistantController = AssistantController_1 = class AssistantController {
|
|
|
145
149
|
/**
|
|
146
150
|
* GET /assistants — list the current user's assistant threads.
|
|
147
151
|
* RBAC (company + owner) is enforced by the repository's `buildUserHasAccess` override.
|
|
152
|
+
*
|
|
153
|
+
* `boundType` + `boundId` narrow the list to the threads bound to one
|
|
154
|
+
* resource (e.g. a campaign). Both are required together: a bound id with no
|
|
155
|
+
* type is ambiguous, and a type with no id names no resource. Supplying them
|
|
156
|
+
* is a custom filter, so it bypasses the CRUD handler and calls the service.
|
|
148
157
|
*/
|
|
149
|
-
async findAll(reply, query, search, fetchAll, orderBy) {
|
|
158
|
+
async findAll(reply, query, search, fetchAll, orderBy, boundType, boundId) {
|
|
159
|
+
if (boundType && boundId) {
|
|
160
|
+
if (!registry_1.modelRegistry.getByType(boundType)) {
|
|
161
|
+
throw new common_1.BadRequestException(`Unknown resource type "${boundType}" for boundType.`);
|
|
162
|
+
}
|
|
163
|
+
const response = await this.assistants.findByBoundContent({ boundType, boundId, query });
|
|
164
|
+
reply.send(response);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
150
167
|
return this.crud.findAll(reply, { query, search, fetchAll, orderBy });
|
|
151
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Validate the polymorphic `content` relationship reference against the model
|
|
171
|
+
* registry. The DTO can only assert that `type` is a non-empty string —
|
|
172
|
+
* BOUND_TO accepts any registered model, and the registry is the only place
|
|
173
|
+
* that knows the full set.
|
|
174
|
+
*/
|
|
175
|
+
resolveBoundContent(reference) {
|
|
176
|
+
if (!reference)
|
|
177
|
+
return undefined;
|
|
178
|
+
const model = registry_1.modelRegistry.getByType(reference.type);
|
|
179
|
+
if (!model) {
|
|
180
|
+
throw new common_1.BadRequestException(`Unknown resource type "${reference.type}" for the assistant's bound content.`);
|
|
181
|
+
}
|
|
182
|
+
return { type: model.type, id: reference.id };
|
|
183
|
+
}
|
|
152
184
|
/**
|
|
153
185
|
* GET /assistants/:assistantId — read a single assistant thread.
|
|
154
186
|
*/
|
|
@@ -193,8 +225,10 @@ __decorate([
|
|
|
193
225
|
__param(2, (0, common_1.Query)("search")),
|
|
194
226
|
__param(3, (0, common_1.Query)("fetchAll")),
|
|
195
227
|
__param(4, (0, common_1.Query)("orderBy")),
|
|
228
|
+
__param(5, (0, common_1.Query)("boundType")),
|
|
229
|
+
__param(6, (0, common_1.Query)("boundId")),
|
|
196
230
|
__metadata("design:type", Function),
|
|
197
|
-
__metadata("design:paramtypes", [Object, Object, String, Boolean, String]),
|
|
231
|
+
__metadata("design:paramtypes", [Object, Object, String, Boolean, String, String, String]),
|
|
198
232
|
__metadata("design:returntype", Promise)
|
|
199
233
|
], AssistantController.prototype, "findAll", null);
|
|
200
234
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.controller.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/controllers/assistant.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"assistant.controller.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/controllers/assistant.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+CA,sCA8BC;AA7ED,2CAgBwB;AAExB,0EAAqE;AACrE,0EAA4E;AAE5E,kEAAoE;AACpE,oFAAgF;AAChF,uEAAkE;AAClE,qEAAgE;AAChE,mEAA8D;AAC9D,qDAA4D;AAC5D,+DAA2D;AAC3D,0FAAgG;AAChG,oGAA+F;AAC/F,qEAAiE;AAEjE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,aAAa,CAC3B,IAA2B,EAC3B,SAAgC,EAChC,eAAoD;IAEpD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAe,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;QACrC,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAU,EAAE,CAAC;YACzC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,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A;IAChB,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;IAClB,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;;;;kDAWlB;AAqBK;IADL,IAAA,YAAG,EAAC,GAAG,8BAAa,CAAC,QAAQ,eAAe,CAAC;IAC9B,WAAA,IAAA,YAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,cAAK,EAAC,aAAa,CAAC,CAAA;;;;mDAE/D;AAMK;IADL,IAAA,cAAK,EAAC,GAAG,8BAAa,CAAC,QAAQ,eAAe,CAAC;IACnC,WAAA,IAAA,YAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,uCAAiB;;gDAEtE;AAOK;IAFL,IAAA,eAAM,EAAC,GAAG,8BAAa,CAAC,QAAQ,eAAe,CAAC;IAChD,IAAA,iBAAQ,EAAC,mBAAU,CAAC,UAAU,CAAC;IAClB,WAAA,IAAA,YAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,cAAK,EAAC,aAAa,CAAC,CAAA;;;;iDAE7D;8BA5JU,mBAAmB;IAF/B,IAAA,kBAAS,EAAC,6BAAY,CAAC;IACvB,IAAA,mBAAU,GAAE;qCAMoB,oCAAgB;QACnB,gCAAc;GAN/B,mBAAmB,CA6J/B"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export declare class AssistantAppendAttributesDto {
|
|
2
|
+
/**
|
|
3
|
+
* This user message. Either plain text, or — following the host app's
|
|
4
|
+
* BlockNote convention — a JSON-serialised BlockNote document, which the
|
|
5
|
+
* server detects and converts. An append carries no binding; it inherits
|
|
6
|
+
* the thread's.
|
|
7
|
+
*/
|
|
2
8
|
content: string;
|
|
3
9
|
howToMode?: boolean;
|
|
4
10
|
limitToHowToId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-append.dto.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-append.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,4BAA4B;
|
|
1
|
+
{"version":3,"file":"assistant-append.dto.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-append.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,4BAA4B;IACvC;;;;;OAKG;IAIH,OAAO,EAAG,MAAM,CAAC;IAIjB,SAAS,CAAC,EAAE,OAAO,CAAC;IAIpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,sBAAsB;IAEjC,IAAI,EAAG,MAAM,CAAC;IAId,UAAU,EAAG,4BAA4B,CAAC;CAC3C;AAED,qBAAa,kBAAkB;IAG7B,IAAI,EAAG,sBAAsB,CAAC;CAC/B"}
|
|
@@ -18,7 +18,7 @@ exports.AssistantAppendAttributesDto = AssistantAppendAttributesDto;
|
|
|
18
18
|
__decorate([
|
|
19
19
|
(0, class_validator_1.IsString)(),
|
|
20
20
|
(0, class_validator_1.IsNotEmpty)(),
|
|
21
|
-
(0, class_validator_1.MaxLength)(
|
|
21
|
+
(0, class_validator_1.MaxLength)(200_000),
|
|
22
22
|
__metadata("design:type", String)
|
|
23
23
|
], AssistantAppendAttributesDto.prototype, "content", void 0);
|
|
24
24
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-append.dto.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-append.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAiH;AAEjH,MAAa,4BAA4B;
|
|
1
|
+
{"version":3,"file":"assistant-append.dto.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-append.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAiH;AAEjH,MAAa,4BAA4B;CAmBxC;AAnBD,oEAmBC;AATC;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,EAAC,OAAO,CAAC;;6DACF;AAIjB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;+DACQ;AAIpB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oEACa;AAG1B,MAAa,sBAAsB;CAOlC;AAPD,wDAOC;AALC;IADC,IAAA,wBAAM,EAAC,oBAAoB,CAAC;;oDACf;AAId;IAFC,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,4BAA4B,CAAC;8BAC5B,4BAA4B;0DAAC;AAG5C,MAAa,kBAAkB;CAI9B;AAJD,gDAIC;AADC;IAFC,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;8BAC5B,sBAAsB;gDAAC"}
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference to the resource a thread is bound to (the `content` relationship,
|
|
3
|
+
* materialised as `(Assistant)-[:BOUND_TO]->(target)`).
|
|
4
|
+
*
|
|
5
|
+
* `type` is a plain `@IsString()` — NOT `@Equals(...)` — because the
|
|
6
|
+
* relationship is polymorphic: any registered model may be the target. The
|
|
7
|
+
* controller resolves the string against the model registry and rejects
|
|
8
|
+
* unknown types there, which is the only place that knows the full set.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AssistantContentReferenceDto {
|
|
11
|
+
type: string;
|
|
12
|
+
id: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class AssistantContentRelationshipDto {
|
|
15
|
+
data: AssistantContentReferenceDto;
|
|
16
|
+
}
|
|
17
|
+
export declare class AssistantPostRelationshipsDto {
|
|
18
|
+
content?: AssistantContentRelationshipDto;
|
|
19
|
+
}
|
|
1
20
|
export declare class AssistantPostAttributesDto {
|
|
21
|
+
/**
|
|
22
|
+
* The first user message. Either plain text, or — following the host app's
|
|
23
|
+
* BlockNote convention — a JSON-serialised BlockNote document. The server
|
|
24
|
+
* detects the latter and derives the persisted markdown (and the pinned
|
|
25
|
+
* entity mentions) from it; see AssistantService.resolveUserTurnInput.
|
|
26
|
+
*
|
|
27
|
+
* The cap is generous because a serialised document carries block structure
|
|
28
|
+
* as well as prose.
|
|
29
|
+
*/
|
|
2
30
|
content: string;
|
|
3
31
|
title?: string;
|
|
4
32
|
howToMode?: boolean;
|
|
@@ -7,6 +35,7 @@ export declare class AssistantPostAttributesDto {
|
|
|
7
35
|
export declare class AssistantPostDataDto {
|
|
8
36
|
type: string;
|
|
9
37
|
attributes: AssistantPostAttributesDto;
|
|
38
|
+
relationships?: AssistantPostRelationshipsDto;
|
|
10
39
|
}
|
|
11
40
|
export declare class AssistantPostDto {
|
|
12
41
|
data: AssistantPostDataDto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-post.dto.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-post.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assistant-post.dto.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-post.dto.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,qBAAa,4BAA4B;IAGvC,IAAI,EAAG,MAAM,CAAC;IAGd,EAAE,EAAG,MAAM,CAAC;CACb;AAED,qBAAa,+BAA+B;IAI1C,IAAI,EAAG,4BAA4B,CAAC;CACrC;AAED,qBAAa,6BAA6B;IAIxC,OAAO,CAAC,EAAE,+BAA+B,CAAC;CAC3C;AAED,qBAAa,0BAA0B;IACrC;;;;;;;;OAQG;IAIH,OAAO,EAAG,MAAM,CAAC;IAKjB,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,SAAS,CAAC,EAAE,OAAO,CAAC;IAIpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,oBAAoB;IAE/B,IAAI,EAAG,MAAM,CAAC;IAId,UAAU,EAAG,0BAA0B,CAAC;IAKxC,aAAa,CAAC,EAAE,6BAA6B,CAAC;CAC/C;AAED,qBAAa,gBAAgB;IAG3B,IAAI,EAAG,oBAAoB,CAAC;CAC7B"}
|
|
@@ -9,17 +9,56 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AssistantPostDto = exports.AssistantPostDataDto = exports.AssistantPostAttributesDto = void 0;
|
|
12
|
+
exports.AssistantPostDto = exports.AssistantPostDataDto = exports.AssistantPostAttributesDto = exports.AssistantPostRelationshipsDto = exports.AssistantContentRelationshipDto = exports.AssistantContentReferenceDto = void 0;
|
|
13
13
|
const class_transformer_1 = require("class-transformer");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
15
|
const assistant_meta_1 = require("../entities/assistant.meta");
|
|
16
|
+
/**
|
|
17
|
+
* Reference to the resource a thread is bound to (the `content` relationship,
|
|
18
|
+
* materialised as `(Assistant)-[:BOUND_TO]->(target)`).
|
|
19
|
+
*
|
|
20
|
+
* `type` is a plain `@IsString()` — NOT `@Equals(...)` — because the
|
|
21
|
+
* relationship is polymorphic: any registered model may be the target. The
|
|
22
|
+
* controller resolves the string against the model registry and rejects
|
|
23
|
+
* unknown types there, which is the only place that knows the full set.
|
|
24
|
+
*/
|
|
25
|
+
class AssistantContentReferenceDto {
|
|
26
|
+
}
|
|
27
|
+
exports.AssistantContentReferenceDto = AssistantContentReferenceDto;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_validator_1.IsString)(),
|
|
30
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], AssistantContentReferenceDto.prototype, "type", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsUUID)(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], AssistantContentReferenceDto.prototype, "id", void 0);
|
|
37
|
+
class AssistantContentRelationshipDto {
|
|
38
|
+
}
|
|
39
|
+
exports.AssistantContentRelationshipDto = AssistantContentRelationshipDto;
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, class_validator_1.ValidateNested)(),
|
|
42
|
+
(0, class_validator_1.IsDefined)(),
|
|
43
|
+
(0, class_transformer_1.Type)(() => AssistantContentReferenceDto),
|
|
44
|
+
__metadata("design:type", AssistantContentReferenceDto)
|
|
45
|
+
], AssistantContentRelationshipDto.prototype, "data", void 0);
|
|
46
|
+
class AssistantPostRelationshipsDto {
|
|
47
|
+
}
|
|
48
|
+
exports.AssistantPostRelationshipsDto = AssistantPostRelationshipsDto;
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, class_validator_1.ValidateNested)(),
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
(0, class_transformer_1.Type)(() => AssistantContentRelationshipDto),
|
|
53
|
+
__metadata("design:type", AssistantContentRelationshipDto)
|
|
54
|
+
], AssistantPostRelationshipsDto.prototype, "content", void 0);
|
|
16
55
|
class AssistantPostAttributesDto {
|
|
17
56
|
}
|
|
18
57
|
exports.AssistantPostAttributesDto = AssistantPostAttributesDto;
|
|
19
58
|
__decorate([
|
|
20
59
|
(0, class_validator_1.IsString)(),
|
|
21
60
|
(0, class_validator_1.IsNotEmpty)(),
|
|
22
|
-
(0, class_validator_1.MaxLength)(
|
|
61
|
+
(0, class_validator_1.MaxLength)(200_000),
|
|
23
62
|
__metadata("design:type", String)
|
|
24
63
|
], AssistantPostAttributesDto.prototype, "content", void 0);
|
|
25
64
|
__decorate([
|
|
@@ -50,6 +89,12 @@ __decorate([
|
|
|
50
89
|
(0, class_transformer_1.Type)(() => AssistantPostAttributesDto),
|
|
51
90
|
__metadata("design:type", AssistantPostAttributesDto)
|
|
52
91
|
], AssistantPostDataDto.prototype, "attributes", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, class_validator_1.ValidateNested)(),
|
|
94
|
+
(0, class_validator_1.IsOptional)(),
|
|
95
|
+
(0, class_transformer_1.Type)(() => AssistantPostRelationshipsDto),
|
|
96
|
+
__metadata("design:type", AssistantPostRelationshipsDto)
|
|
97
|
+
], AssistantPostDataDto.prototype, "relationships", void 0);
|
|
53
98
|
class AssistantPostDto {
|
|
54
99
|
}
|
|
55
100
|
exports.AssistantPostDto = AssistantPostDto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-post.dto.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-post.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"assistant-post.dto.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/dtos/assistant-post.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAUyB;AACzB,+DAA2D;AAE3D;;;;;;;;GAQG;AACH,MAAa,4BAA4B;CAOxC;AAPD,oEAOC;AAJC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0DACC;AAGd;IADC,IAAA,wBAAM,GAAE;;wDACG;AAGd,MAAa,+BAA+B;CAK3C;AALD,0EAKC;AADC;IAHC,IAAA,gCAAc,GAAE;IAChB,IAAA,2BAAS,GAAE;IACX,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,4BAA4B,CAAC;8BAClC,4BAA4B;6DAAC;AAGtC,MAAa,6BAA6B;CAKzC;AALD,sEAKC;AADC;IAHC,IAAA,gCAAc,GAAE;IAChB,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,+BAA+B,CAAC;8BAClC,+BAA+B;8DAAC;AAG5C,MAAa,0BAA0B;CA2BtC;AA3BD,gEA2BC;AAdC;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,EAAC,OAAO,CAAC;;2DACF;AAKjB;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,EAAC,GAAG,CAAC;;yDACA;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;6DACQ;AAIpB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kEACa;AAG1B,MAAa,oBAAoB;CAYhC;AAZD,oDAYC;AAVC;IADC,IAAA,wBAAM,EAAC,8BAAa,CAAC,QAAQ,CAAC;;kDACjB;AAId;IAFC,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC;8BAC1B,0BAA0B;wDAAC;AAKxC;IAHC,IAAA,gCAAc,GAAE;IAChB,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,6BAA6B,CAAC;8BAC1B,6BAA6B;2DAAC;AAGhD,MAAa,gBAAgB;CAI5B;AAJD,4CAIC;AADC;IAFC,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;8BAC1B,oBAAoB;8CAAC"}
|
|
@@ -49,6 +49,28 @@ export declare class AssistantRepository extends AbstractRepository<Assistant, t
|
|
|
49
49
|
}>;
|
|
50
50
|
constructor(neo4j: Neo4jService, securityService: SecurityService, clsService: ClsService);
|
|
51
51
|
protected buildUserHasAccess(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Attach the thread to the resource it is scoped to:
|
|
54
|
+
* `(Assistant)-[:BOUND_TO]->(target)`.
|
|
55
|
+
*
|
|
56
|
+
* This cannot go through the generic create path. `BOUND_TO` is declared
|
|
57
|
+
* polymorphic on the descriptor (any registered model may be the target), so
|
|
58
|
+
* `relationships.content.model` is only a placeholder — `assistantMeta`.
|
|
59
|
+
* `AbstractRepository.create` reads `rel.model.labelName` both to validate the
|
|
60
|
+
* target exists (abstract.repository.ts:713) and to build the edge MATCH
|
|
61
|
+
* (:822), so routing a Campaign id through it looks for
|
|
62
|
+
* `(:Assistant { id: <campaign-uuid> })` and fails with "One or more related
|
|
63
|
+
* nodes do not exist."
|
|
64
|
+
*
|
|
65
|
+
* The caller resolves the real label from the model registry, so the label
|
|
66
|
+
* interpolated here is always a registered one and never user input. The id
|
|
67
|
+
* stays parameterised.
|
|
68
|
+
*/
|
|
69
|
+
bindContent(params: {
|
|
70
|
+
assistantId: string;
|
|
71
|
+
targetLabel: string;
|
|
72
|
+
targetId: string;
|
|
73
|
+
}): Promise<void>;
|
|
52
74
|
/**
|
|
53
75
|
* Override delete to cascade through HAS_MESSAGE children so that
|
|
54
76
|
* `AssistantMessage` nodes (and their REFERENCES edges) are removed with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/repositories/assistant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;;;;;;GASG;AACH,qBACa,mBAAoB,SAAQ,kBAAkB,CAAC,SAAS,EAAE,OAAO,mBAAmB,CAAC,aAAa,CAAC;IAC9G,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAuB;gBAExC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAIzF,SAAS,CAAC,kBAAkB,IAAI,MAAM;IAStC;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAUpD"}
|
|
1
|
+
{"version":3,"file":"assistant.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/repositories/assistant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;;;;;;GASG;AACH,qBACa,mBAAoB,SAAQ,kBAAkB,CAAC,SAAS,EAAE,OAAO,mBAAmB,CAAC,aAAa,CAAC;IAC9G,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAuB;gBAExC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAIzF,SAAS,CAAC,kBAAkB,IAAI,MAAM;IAStC;;;;;;;;;;;;;;;;OAgBG;IACG,WAAW,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxG;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAUpD"}
|
|
@@ -39,6 +39,34 @@ let AssistantRepository = class AssistantRepository extends abstract_repository_
|
|
|
39
39
|
}
|
|
40
40
|
WITH ${nodeName}`;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Attach the thread to the resource it is scoped to:
|
|
44
|
+
* `(Assistant)-[:BOUND_TO]->(target)`.
|
|
45
|
+
*
|
|
46
|
+
* This cannot go through the generic create path. `BOUND_TO` is declared
|
|
47
|
+
* polymorphic on the descriptor (any registered model may be the target), so
|
|
48
|
+
* `relationships.content.model` is only a placeholder — `assistantMeta`.
|
|
49
|
+
* `AbstractRepository.create` reads `rel.model.labelName` both to validate the
|
|
50
|
+
* target exists (abstract.repository.ts:713) and to build the edge MATCH
|
|
51
|
+
* (:822), so routing a Campaign id through it looks for
|
|
52
|
+
* `(:Assistant { id: <campaign-uuid> })` and fails with "One or more related
|
|
53
|
+
* nodes do not exist."
|
|
54
|
+
*
|
|
55
|
+
* The caller resolves the real label from the model registry, so the label
|
|
56
|
+
* interpolated here is always a registered one and never user input. The id
|
|
57
|
+
* stays parameterised.
|
|
58
|
+
*/
|
|
59
|
+
async bindContent(params) {
|
|
60
|
+
await this.neo4j.writeOne({
|
|
61
|
+
query: `
|
|
62
|
+
MATCH (assistant:Assistant {id: $assistantId})
|
|
63
|
+
MATCH (target:${params.targetLabel} {id: $targetId})
|
|
64
|
+
MERGE (assistant)-[rel:BOUND_TO]->(target)
|
|
65
|
+
SET rel.updatedAt = datetime()
|
|
66
|
+
`,
|
|
67
|
+
queryParams: { assistantId: params.assistantId, targetId: params.targetId },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
42
70
|
/**
|
|
43
71
|
* Override delete to cascade through HAS_MESSAGE children so that
|
|
44
72
|
* `AssistantMessage` nodes (and their REFERENCES edges) are removed with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.repository.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/repositories/assistant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,2FAAuF;AACvF,8EAA0E;AAC1E,uFAAmF;AACnF,qDAAuE;AAEvE;;;;;;;;;GASG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,wCAAuE;IAG9G,YAAY,KAAmB,EAAE,eAAgC,EAAE,UAAsB;QACvF,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAHzB,eAAU,GAAG,+BAAmB,CAAC;IAIpD,CAAC;IAES,kBAAkB;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAC3C,OAAO,QAAQ,QAAQ;;uBAEJ,QAAQ;;mBAEZ,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,MAAsB;QACjC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YACxB,KAAK,EAAE;;;;OAIN;YACD,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;SAC/B,CAAC,CAAC;IACL,CAAC;CACF,CAAA;
|
|
1
|
+
{"version":3,"file":"assistant.repository.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/repositories/assistant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,2FAAuF;AACvF,8EAA0E;AAC1E,uFAAmF;AACnF,qDAAuE;AAEvE;;;;;;;;;GASG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,wCAAuE;IAG9G,YAAY,KAAmB,EAAE,eAAgC,EAAE,UAAsB;QACvF,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAHzB,eAAU,GAAG,+BAAmB,CAAC;IAIpD,CAAC;IAES,kBAAkB;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAC3C,OAAO,QAAQ,QAAQ;;uBAEJ,QAAQ;;mBAEZ,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,WAAW,CAAC,MAAsE;QACtF,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YACxB,KAAK,EAAE;;wBAEW,MAAM,CAAC,WAAW;;;OAGnC;YACD,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAC5E,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,MAAsB;QACjC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YACxB,KAAK,EAAE;;;;OAIN;YACD,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;SAC/B,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA9DY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAIQ,4BAAY,EAAmB,kCAAe,EAAc,uBAAU;GAH9E,mBAAmB,CA8D/B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GraphCatalogService } from "../../../agents/graph/services/graph.catalog.service";
|
|
2
|
+
import { ScopeGuard } from "../../../agents/graph/services/scope.guard";
|
|
3
|
+
import { UserContext } from "../../../agents/graph/tools/tool.factory";
|
|
4
|
+
import { EntityServiceRegistry } from "../../../common/registries/entity.service.registry";
|
|
5
|
+
export interface ExtractedMention {
|
|
6
|
+
/** JSON:API type, e.g. "npcs". */
|
|
7
|
+
type: string;
|
|
8
|
+
id: string;
|
|
9
|
+
/** Display text the user saw. */
|
|
10
|
+
alias: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Turns a BlockNote document into the entity references a user message pins.
|
|
14
|
+
*
|
|
15
|
+
* A mention arrives from the browser, so it is INPUT, not a trusted pointer:
|
|
16
|
+
* validate() re-checks catalog membership, scope and existence before any of
|
|
17
|
+
* it reaches the LLM or becomes a REFERENCES edge.
|
|
18
|
+
*/
|
|
19
|
+
export declare class AssistantMentionExtractor {
|
|
20
|
+
private readonly catalog;
|
|
21
|
+
private readonly scopeGuard;
|
|
22
|
+
private readonly entityServices;
|
|
23
|
+
private readonly logger;
|
|
24
|
+
constructor(catalog: GraphCatalogService, scopeGuard: ScopeGuard, entityServices: EntityServiceRegistry);
|
|
25
|
+
/** Walks a BlockNote document for inline nodes of type "mention". Never throws. */
|
|
26
|
+
extract(blocks: unknown[]): ExtractedMention[];
|
|
27
|
+
/**
|
|
28
|
+
* Drops mentions that are not in the catalog for these modules, are outside
|
|
29
|
+
* the run's scope, or no longer resolve to a record.
|
|
30
|
+
*/
|
|
31
|
+
validate(params: {
|
|
32
|
+
mentions: ExtractedMention[];
|
|
33
|
+
ctx: UserContext;
|
|
34
|
+
}): Promise<ExtractedMention[]>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=assistant-mention.extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-mention.extractor.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant/services/assistant-mention.extractor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAE3F,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,qBACa,yBAAyB;IAIlC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IALjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;gBAGlD,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,qBAAqB;IAGxD,mFAAmF;IACnF,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,gBAAgB,EAAE;IAmC9C;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAoBxG"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var AssistantMentionExtractor_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AssistantMentionExtractor = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const graph_catalog_service_1 = require("../../../agents/graph/services/graph.catalog.service");
|
|
16
|
+
const scope_guard_1 = require("../../../agents/graph/services/scope.guard");
|
|
17
|
+
const entity_service_registry_1 = require("../../../common/registries/entity.service.registry");
|
|
18
|
+
/**
|
|
19
|
+
* Turns a BlockNote document into the entity references a user message pins.
|
|
20
|
+
*
|
|
21
|
+
* A mention arrives from the browser, so it is INPUT, not a trusted pointer:
|
|
22
|
+
* validate() re-checks catalog membership, scope and existence before any of
|
|
23
|
+
* it reaches the LLM or becomes a REFERENCES edge.
|
|
24
|
+
*/
|
|
25
|
+
let AssistantMentionExtractor = AssistantMentionExtractor_1 = class AssistantMentionExtractor {
|
|
26
|
+
constructor(catalog, scopeGuard, entityServices) {
|
|
27
|
+
this.catalog = catalog;
|
|
28
|
+
this.scopeGuard = scopeGuard;
|
|
29
|
+
this.entityServices = entityServices;
|
|
30
|
+
this.logger = new common_1.Logger(AssistantMentionExtractor_1.name);
|
|
31
|
+
}
|
|
32
|
+
/** Walks a BlockNote document for inline nodes of type "mention". Never throws. */
|
|
33
|
+
extract(blocks) {
|
|
34
|
+
const out = [];
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
const walk = (node) => {
|
|
37
|
+
if (!node || typeof node !== "object")
|
|
38
|
+
return;
|
|
39
|
+
if (Array.isArray(node)) {
|
|
40
|
+
node.forEach(walk);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (node.type === "mention") {
|
|
44
|
+
const id = node.props?.id;
|
|
45
|
+
const type = node.props?.entityType;
|
|
46
|
+
if (typeof id === "string" && typeof type === "string") {
|
|
47
|
+
const key = `${type}/${id}`;
|
|
48
|
+
if (!seen.has(key)) {
|
|
49
|
+
seen.add(key);
|
|
50
|
+
out.push({ type, id, alias: String(node.props?.alias ?? "") });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
walk(node.content);
|
|
56
|
+
walk(node.children);
|
|
57
|
+
};
|
|
58
|
+
try {
|
|
59
|
+
walk(blocks);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.logger.warn(`extract: malformed document — ${err instanceof Error ? err.message : String(err)}`);
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Drops mentions that are not in the catalog for these modules, are outside
|
|
69
|
+
* the run's scope, or no longer resolve to a record.
|
|
70
|
+
*/
|
|
71
|
+
async validate(params) {
|
|
72
|
+
const kept = [];
|
|
73
|
+
for (const mention of params.mentions) {
|
|
74
|
+
if (!this.catalog.getEntityDetail(mention.type, params.ctx.userModuleIds)) {
|
|
75
|
+
this.logger.warn(`validate: dropping mention of uncatalogued type "${mention.type}".`);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (!(await this.scopeGuard.isInScope({ type: mention.type, id: mention.id, ctx: params.ctx }))) {
|
|
79
|
+
this.logger.warn(`validate: dropping out-of-scope mention ${mention.type}/${mention.id}.`);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const service = this.entityServices.get(mention.type);
|
|
83
|
+
if (!service || !(await service.findRecordById({ id: mention.id }))) {
|
|
84
|
+
this.logger.warn(`validate: dropping unreadable mention ${mention.type}/${mention.id}.`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
kept.push(mention);
|
|
88
|
+
}
|
|
89
|
+
return kept;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.AssistantMentionExtractor = AssistantMentionExtractor;
|
|
93
|
+
exports.AssistantMentionExtractor = AssistantMentionExtractor = AssistantMentionExtractor_1 = __decorate([
|
|
94
|
+
(0, common_1.Injectable)(),
|
|
95
|
+
__metadata("design:paramtypes", [graph_catalog_service_1.GraphCatalogService,
|
|
96
|
+
scope_guard_1.ScopeGuard,
|
|
97
|
+
entity_service_registry_1.EntityServiceRegistry])
|
|
98
|
+
], AssistantMentionExtractor);
|
|
99
|
+
//# sourceMappingURL=assistant-mention.extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-mention.extractor.js","sourceRoot":"","sources":["../../../../src/foundations/assistant/services/assistant-mention.extractor.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,gGAA2F;AAC3F,4EAAwE;AAExE,gGAA2F;AAU3F;;;;;;GAMG;AAEI,IAAM,yBAAyB,iCAA/B,MAAM,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