@carlonicora/nestjs-neo4jsonapi 1.96.0 → 1.98.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/tools/search-entities.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/search-entities.tool.js +14 -3
- package/dist/agents/graph/tools/search-entities.tool.js.map +1 -1
- package/dist/agents/graph/tools/tool.factory.d.ts.map +1 -1
- package/dist/agents/graph/tools/tool.factory.js +16 -2
- package/dist/agents/graph/tools/tool.factory.js.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.js +14 -4
- package/dist/agents/graph/tools/traverse.tool.js.map +1 -1
- package/dist/agents/index.d.ts +15 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +28 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/operator/contexts/operator.context.d.ts +54 -0
- package/dist/agents/operator/contexts/operator.context.d.ts.map +1 -0
- package/dist/agents/operator/contexts/operator.context.js +23 -0
- package/dist/agents/operator/contexts/operator.context.js.map +1 -0
- package/dist/agents/operator/controllers/operator.controller.d.ts +37 -0
- package/dist/agents/operator/controllers/operator.controller.d.ts.map +1 -0
- package/dist/agents/operator/controllers/operator.controller.js +142 -0
- package/dist/agents/operator/controllers/operator.controller.js.map +1 -0
- package/dist/agents/operator/entities/operator.meta.d.ts +8 -0
- package/dist/agents/operator/entities/operator.meta.d.ts.map +1 -0
- package/dist/agents/operator/entities/operator.meta.js +15 -0
- package/dist/agents/operator/entities/operator.meta.js.map +1 -0
- package/dist/agents/operator/interfaces/operator.tool.interface.d.ts +42 -0
- package/dist/agents/operator/interfaces/operator.tool.interface.d.ts.map +1 -0
- package/dist/agents/operator/interfaces/operator.tool.interface.js +6 -0
- package/dist/agents/operator/interfaces/operator.tool.interface.js.map +1 -0
- package/dist/agents/operator/operator.module.d.ts +3 -0
- package/dist/agents/operator/operator.module.d.ts.map +1 -0
- package/dist/agents/operator/operator.module.js +44 -0
- package/dist/agents/operator/operator.module.js.map +1 -0
- package/dist/agents/operator/prompts/operator.system.prompt.d.ts +2 -0
- package/dist/agents/operator/prompts/operator.system.prompt.d.ts.map +1 -0
- package/dist/agents/operator/prompts/operator.system.prompt.js +25 -0
- package/dist/agents/operator/prompts/operator.system.prompt.js.map +1 -0
- package/dist/agents/operator/services/operator.checkpointer.service.d.ts +57 -0
- package/dist/agents/operator/services/operator.checkpointer.service.d.ts.map +1 -0
- package/dist/agents/operator/services/operator.checkpointer.service.js +171 -0
- package/dist/agents/operator/services/operator.checkpointer.service.js.map +1 -0
- package/dist/agents/operator/services/operator.service.d.ts +81 -0
- package/dist/agents/operator/services/operator.service.d.ts.map +1 -0
- package/dist/agents/operator/services/operator.service.js +341 -0
- package/dist/agents/operator/services/operator.service.js.map +1 -0
- package/dist/agents/operator/tools/operator-test-action.tool.d.ts +12 -0
- package/dist/agents/operator/tools/operator-test-action.tool.d.ts.map +1 -0
- package/dist/agents/operator/tools/operator-test-action.tool.js +46 -0
- package/dist/agents/operator/tools/operator-test-action.tool.js.map +1 -0
- package/dist/agents/operator/tools/operator.tool.registry.d.ts +32 -0
- package/dist/agents/operator/tools/operator.tool.registry.d.ts.map +1 -0
- package/dist/agents/operator/tools/operator.tool.registry.js +95 -0
- package/dist/agents/operator/tools/operator.tool.registry.js.map +1 -0
- package/dist/agents/operator/tools/search-communities.tool.d.ts +16 -0
- package/dist/agents/operator/tools/search-communities.tool.d.ts.map +1 -0
- package/dist/agents/operator/tools/search-communities.tool.js +51 -0
- package/dist/agents/operator/tools/search-communities.tool.js.map +1 -0
- package/dist/agents/operator/tools/search-documents.tool.d.ts +17 -0
- package/dist/agents/operator/tools/search-documents.tool.d.ts.map +1 -0
- package/dist/agents/operator/tools/search-documents.tool.js +76 -0
- package/dist/agents/operator/tools/search-documents.tool.js.map +1 -0
- package/dist/common/interfaces/token.usage.interface.d.ts +2 -0
- package/dist/common/interfaces/token.usage.interface.d.ts.map +1 -1
- package/dist/config/base.config.d.ts +6 -0
- package/dist/config/base.config.d.ts.map +1 -1
- package/dist/config/base.config.js +19 -2
- package/dist/config/base.config.js.map +1 -1
- package/dist/config/interfaces/base.config.interface.d.ts +2 -0
- package/dist/config/interfaces/base.config.interface.d.ts.map +1 -1
- package/dist/config/interfaces/config.ai.interface.d.ts +6 -0
- package/dist/config/interfaces/config.ai.interface.d.ts.map +1 -1
- package/dist/config/interfaces/config.operator.interface.d.ts +9 -0
- package/dist/config/interfaces/config.operator.interface.d.ts.map +1 -0
- package/dist/config/interfaces/config.operator.interface.js +3 -0
- package/dist/config/interfaces/config.operator.interface.js.map +1 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts +1 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts.map +1 -1
- package/dist/config/interfaces/index.d.ts +1 -0
- package/dist/config/interfaces/index.d.ts.map +1 -1
- package/dist/config/interfaces/index.js +1 -0
- package/dist/config/interfaces/index.js.map +1 -1
- package/dist/core/llm/common/llm-raw-response.d.ts +4 -0
- package/dist/core/llm/common/llm-raw-response.d.ts.map +1 -1
- package/dist/core/llm/common/llm-raw-response.js.map +1 -1
- package/dist/core/llm/services/llm-call-dumper.service.d.ts +3 -0
- package/dist/core/llm/services/llm-call-dumper.service.d.ts.map +1 -1
- package/dist/core/llm/services/llm.service.d.ts +35 -0
- package/dist/core/llm/services/llm.service.d.ts.map +1 -1
- package/dist/core/llm/services/llm.service.js +118 -17
- package/dist/core/llm/services/llm.service.js.map +1 -1
- package/dist/foundations/assistant/assistant.module.d.ts.map +1 -1
- package/dist/foundations/assistant/assistant.module.js +14 -1
- package/dist/foundations/assistant/assistant.module.js.map +1 -1
- package/dist/foundations/assistant/entities/assistant.d.ts +1 -0
- package/dist/foundations/assistant/entities/assistant.d.ts.map +1 -1
- package/dist/foundations/assistant/entities/assistant.js +1 -0
- package/dist/foundations/assistant/entities/assistant.js.map +1 -1
- package/dist/foundations/assistant/services/assistant.service.d.ts +88 -1
- package/dist/foundations/assistant/services/assistant.service.d.ts.map +1 -1
- package/dist/foundations/assistant/services/assistant.service.js +365 -2
- package/dist/foundations/assistant/services/assistant.service.js.map +1 -1
- package/dist/foundations/assistant-action/assistant-action.module.d.ts +5 -0
- package/dist/foundations/assistant-action/assistant-action.module.d.ts.map +1 -0
- package/dist/foundations/assistant-action/assistant-action.module.js +43 -0
- package/dist/foundations/assistant-action/assistant-action.module.js.map +1 -0
- package/dist/foundations/assistant-action/controllers/assistant-action.controller.d.ts +30 -0
- package/dist/foundations/assistant-action/controllers/assistant-action.controller.d.ts.map +1 -0
- package/dist/foundations/assistant-action/controllers/assistant-action.controller.js +119 -0
- package/dist/foundations/assistant-action/controllers/assistant-action.controller.js.map +1 -0
- package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.d.ts +9 -0
- package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.d.ts.map +1 -0
- package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.js +46 -0
- package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.js.map +1 -0
- package/dist/foundations/assistant-action/entities/assistant-action.d.ts +49 -0
- package/dist/foundations/assistant-action/entities/assistant-action.d.ts.map +1 -0
- package/dist/foundations/assistant-action/entities/assistant-action.js +43 -0
- package/dist/foundations/assistant-action/entities/assistant-action.js.map +1 -0
- package/dist/foundations/assistant-action/entities/assistant-action.meta.d.ts +3 -0
- package/dist/foundations/assistant-action/entities/assistant-action.meta.d.ts.map +1 -0
- package/dist/foundations/assistant-action/entities/assistant-action.meta.js +10 -0
- package/dist/foundations/assistant-action/entities/assistant-action.meta.js.map +1 -0
- package/dist/foundations/assistant-action/index.d.ts +7 -0
- package/dist/foundations/assistant-action/index.d.ts.map +1 -0
- package/dist/foundations/assistant-action/index.js +23 -0
- package/dist/foundations/assistant-action/index.js.map +1 -0
- package/dist/foundations/assistant-action/repositories/assistant-action.repository.d.ts +81 -0
- package/dist/foundations/assistant-action/repositories/assistant-action.repository.d.ts.map +1 -0
- package/dist/foundations/assistant-action/repositories/assistant-action.repository.js +131 -0
- package/dist/foundations/assistant-action/repositories/assistant-action.repository.js.map +1 -0
- package/dist/foundations/assistant-action/services/assistant-action.service.d.ts +48 -0
- package/dist/foundations/assistant-action/services/assistant-action.service.d.ts.map +1 -0
- package/dist/foundations/assistant-action/services/assistant-action.service.js +67 -0
- package/dist/foundations/assistant-action/services/assistant-action.service.js.map +1 -0
- package/dist/foundations/assistant-message/entities/assistant-message.d.ts +12 -0
- package/dist/foundations/assistant-message/entities/assistant-message.d.ts.map +1 -1
- package/dist/foundations/assistant-message/entities/assistant-message.js +11 -0
- package/dist/foundations/assistant-message/entities/assistant-message.js.map +1 -1
- package/dist/foundations/assistant-message/repositories/assistant-message.repository.d.ts +9 -0
- package/dist/foundations/assistant-message/repositories/assistant-message.repository.d.ts.map +1 -1
- package/dist/foundations/assistant-message/services/assistant-message.service.d.ts +9 -0
- package/dist/foundations/assistant-message/services/assistant-message.service.d.ts.map +1 -1
- package/dist/foundations/index.d.ts +1 -0
- package/dist/foundations/index.d.ts.map +1 -1
- package/dist/foundations/index.js +1 -0
- package/dist/foundations/index.js.map +1 -1
- package/dist/foundations/tokenusage/entities/tokenusage.entity.d.ts +1 -0
- package/dist/foundations/tokenusage/entities/tokenusage.entity.d.ts.map +1 -1
- package/dist/foundations/tokenusage/entities/tokenusage.map.d.ts.map +1 -1
- package/dist/foundations/tokenusage/entities/tokenusage.map.js +1 -0
- package/dist/foundations/tokenusage/entities/tokenusage.map.js.map +1 -1
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.d.ts +1 -0
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.d.ts.map +1 -1
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.js +2 -0
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.js.map +1 -1
- package/dist/foundations/tokenusage/services/tokenusage.service.d.ts.map +1 -1
- package/dist/foundations/tokenusage/services/tokenusage.service.js +9 -3
- package/dist/foundations/tokenusage/services/tokenusage.service.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.module.d.ts","sourceRoot":"","sources":["../../../src/foundations/assistant-action/assistant-action.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAYlE,qBAca,qBAAsB,YAAW,YAAY;IACxD,YAAY;CAGb"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AssistantActionModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const conditional_service_decorator_1 = require("../../common/decorators/conditional-service.decorator");
|
|
12
|
+
const registry_1 = require("../../common/registries/registry");
|
|
13
|
+
const logging_module_1 = require("../../core/logging/logging.module");
|
|
14
|
+
const assistant_module_1 = require("../assistant/assistant.module");
|
|
15
|
+
const audit_module_1 = require("../audit/audit.module");
|
|
16
|
+
const assistant_action_controller_1 = require("./controllers/assistant-action.controller");
|
|
17
|
+
const assistant_action_expiry_cron_1 = require("./cron/assistant-action.expiry.cron");
|
|
18
|
+
const assistant_action_1 = require("./entities/assistant-action");
|
|
19
|
+
const assistant_action_repository_1 = require("./repositories/assistant-action.repository");
|
|
20
|
+
const assistant_action_service_1 = require("./services/assistant-action.service");
|
|
21
|
+
let AssistantActionModule = class AssistantActionModule {
|
|
22
|
+
onModuleInit() {
|
|
23
|
+
registry_1.modelRegistry.register(assistant_action_1.AssistantActionDescriptor.model);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.AssistantActionModule = AssistantActionModule;
|
|
27
|
+
exports.AssistantActionModule = AssistantActionModule = __decorate([
|
|
28
|
+
(0, common_1.Module)({
|
|
29
|
+
// forwardRef: the controller needs AssistantService (resolveAction), while
|
|
30
|
+
// the operator turn flow in AssistantModule needs this module's service /
|
|
31
|
+
// repository to create and resolve pending actions.
|
|
32
|
+
imports: [(0, common_1.forwardRef)(() => assistant_module_1.AssistantModule), audit_module_1.AuditModule, logging_module_1.LoggingModule],
|
|
33
|
+
controllers: [assistant_action_controller_1.AssistantActionController],
|
|
34
|
+
providers: [
|
|
35
|
+
assistant_action_1.AssistantActionDescriptor.model.serialiser,
|
|
36
|
+
assistant_action_repository_1.AssistantActionRepository,
|
|
37
|
+
assistant_action_service_1.AssistantActionService,
|
|
38
|
+
(0, conditional_service_decorator_1.createWorkerProvider)(assistant_action_expiry_cron_1.AssistantActionExpiryCron),
|
|
39
|
+
],
|
|
40
|
+
exports: [assistant_action_service_1.AssistantActionService, assistant_action_repository_1.AssistantActionRepository],
|
|
41
|
+
})
|
|
42
|
+
], AssistantActionModule);
|
|
43
|
+
//# sourceMappingURL=assistant-action.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.module.js","sourceRoot":"","sources":["../../../src/foundations/assistant-action/assistant-action.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkE;AAClE,yGAA6F;AAC7F,+DAAiE;AACjE,sEAAkE;AAClE,oEAAgE;AAChE,wDAAoD;AACpD,2FAAsF;AACtF,sFAAgF;AAChF,kEAAwE;AACxE,4FAAuF;AACvF,kFAA6E;AAgBtE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAAY;QACV,wBAAa,CAAC,QAAQ,CAAC,4CAAyB,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AAJY,sDAAqB;gCAArB,qBAAqB;IAdjC,IAAA,eAAM,EAAC;QACN,2EAA2E;QAC3E,0EAA0E;QAC1E,oDAAoD;QACpD,OAAO,EAAE,CAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kCAAe,CAAC,EAAE,0BAAW,EAAE,8BAAa,CAAC;QACxE,WAAW,EAAE,CAAC,uDAAyB,CAAC;QACxC,SAAS,EAAE;YACT,4CAAyB,CAAC,KAAK,CAAC,UAAU;YAC1C,uDAAyB;YACzB,iDAAsB;YACtB,IAAA,oDAAoB,EAAC,wDAAyB,CAAC;SAChD;QACD,OAAO,EAAE,CAAC,iDAAsB,EAAE,uDAAyB,CAAC;KAC7D,CAAC;GACW,qBAAqB,CAIjC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
+
import { CacheService } from "../../../core/cache/services/cache.service";
|
|
3
|
+
import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service";
|
|
4
|
+
import { AuditService } from "../../audit/services/audit.service";
|
|
5
|
+
import { AssistantService } from "../../assistant/services/assistant.service";
|
|
6
|
+
import { AssistantActionService } from "../services/assistant-action.service";
|
|
7
|
+
export declare class AssistantActionController {
|
|
8
|
+
private readonly assistantActions;
|
|
9
|
+
private readonly assistants;
|
|
10
|
+
private readonly jsonApi;
|
|
11
|
+
private readonly auditService;
|
|
12
|
+
private readonly cacheService;
|
|
13
|
+
private readonly crud;
|
|
14
|
+
constructor(assistantActions: AssistantActionService, assistants: AssistantService, jsonApi: JsonApiService, auditService: AuditService, cacheService: CacheService);
|
|
15
|
+
findById(request: FastifyRequest, reply: FastifyReply, actionId: string): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* POST /assistant-actions/:actionId/approve — resolve the pending action and
|
|
18
|
+
* resume the frozen operator run with approval. Synchronously returns the
|
|
19
|
+
* final assistant message (JSON:API) with the resolved action included.
|
|
20
|
+
*/
|
|
21
|
+
approve(request: FastifyRequest, reply: FastifyReply, actionId: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* POST /assistant-actions/:actionId/deny — resolve the pending action and
|
|
24
|
+
* resume with denial. Returns the wrap-up assistant message with the
|
|
25
|
+
* resolved action included.
|
|
26
|
+
*/
|
|
27
|
+
deny(request: FastifyRequest, reply: FastifyReply, actionId: string): Promise<void>;
|
|
28
|
+
private resolve;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=assistant-action.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.controller.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/controllers/assistant-action.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIvD,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAI9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E,qBAEa,yBAAyB;IAIlC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAP/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmD;gBAGrD,gBAAgB,EAAE,sBAAsB,EACxC,UAAU,EAAE,gBAAgB,EAC5B,OAAO,EAAE,cAAc,EACvB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY;IAMvC,QAAQ,CAAQ,OAAO,EAAE,cAAc,EAAS,KAAK,EAAE,YAAY,EAAqB,QAAQ,EAAE,MAAM;IAI9G;;;;OAIG;IAGG,OAAO,CAAQ,OAAO,EAAE,cAAc,EAAS,KAAK,EAAE,YAAY,EAAqB,QAAQ,EAAE,MAAM;IAI7G;;;;OAIG;IAGG,IAAI,CAAQ,OAAO,EAAE,cAAc,EAAS,KAAK,EAAE,YAAY,EAAqB,QAAQ,EAAE,MAAM;YAI5F,OAAO;CAqBtB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AssistantActionController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const decorators_1 = require("../../../common/decorators");
|
|
18
|
+
const jwt_auth_guard_1 = require("../../../common/guards/jwt.auth.guard");
|
|
19
|
+
const crud_handlers_1 = require("../../../common/handlers/crud.handlers");
|
|
20
|
+
const cache_service_1 = require("../../../core/cache/services/cache.service");
|
|
21
|
+
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
22
|
+
const audit_service_1 = require("../../audit/services/audit.service");
|
|
23
|
+
const assistant_service_1 = require("../../assistant/services/assistant.service");
|
|
24
|
+
const assistant_message_1 = require("../../assistant-message/entities/assistant-message");
|
|
25
|
+
const assistant_action_1 = require("../entities/assistant-action");
|
|
26
|
+
const assistant_action_meta_1 = require("../entities/assistant-action.meta");
|
|
27
|
+
const assistant_action_service_1 = require("../services/assistant-action.service");
|
|
28
|
+
let AssistantActionController = class AssistantActionController {
|
|
29
|
+
constructor(assistantActions, assistants, jsonApi, auditService, cacheService) {
|
|
30
|
+
this.assistantActions = assistantActions;
|
|
31
|
+
this.assistants = assistants;
|
|
32
|
+
this.jsonApi = jsonApi;
|
|
33
|
+
this.auditService = auditService;
|
|
34
|
+
this.cacheService = cacheService;
|
|
35
|
+
this.crud = (0, crud_handlers_1.createCrudHandlers)(() => this.assistantActions);
|
|
36
|
+
}
|
|
37
|
+
// GET /assistant-actions/:actionId
|
|
38
|
+
async findById(request, reply, actionId) {
|
|
39
|
+
return this.crud.findById(reply, actionId);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* POST /assistant-actions/:actionId/approve — resolve the pending action and
|
|
43
|
+
* resume the frozen operator run with approval. Synchronously returns the
|
|
44
|
+
* final assistant message (JSON:API) with the resolved action included.
|
|
45
|
+
*/
|
|
46
|
+
async approve(request, reply, actionId) {
|
|
47
|
+
return this.resolve(reply, actionId, true);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* POST /assistant-actions/:actionId/deny — resolve the pending action and
|
|
51
|
+
* resume with denial. Returns the wrap-up assistant message with the
|
|
52
|
+
* resolved action included.
|
|
53
|
+
*/
|
|
54
|
+
async deny(request, reply, actionId) {
|
|
55
|
+
return this.resolve(reply, actionId, false);
|
|
56
|
+
}
|
|
57
|
+
async resolve(reply, actionId, approved) {
|
|
58
|
+
const { assistantMessage, action } = await this.assistants.resolveAction({ actionId, approved });
|
|
59
|
+
const document = await this.jsonApi.buildSingle(assistant_message_1.AssistantMessageDescriptor.model, assistantMessage);
|
|
60
|
+
const actionDocument = await this.jsonApi.buildSingle(assistant_action_1.AssistantActionDescriptor.model, action);
|
|
61
|
+
// Merge the resolved action into `included`, deduping by (type,id) and
|
|
62
|
+
// never echoing the primary message resource back into `included`.
|
|
63
|
+
const merged = [...(document.included ?? []), actionDocument.data, ...(actionDocument.included ?? [])];
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
document.included = merged.filter((resource) => {
|
|
66
|
+
if (!resource)
|
|
67
|
+
return false;
|
|
68
|
+
if (resource.type === document.data?.type && resource.id === document.data?.id)
|
|
69
|
+
return false;
|
|
70
|
+
const key = `${resource.type}-${resource.id}`;
|
|
71
|
+
if (seen.has(key))
|
|
72
|
+
return false;
|
|
73
|
+
seen.add(key);
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
reply.send(document);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
exports.AssistantActionController = AssistantActionController;
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, common_1.Get)(`${assistant_action_meta_1.assistantActionMeta.endpoint}/:actionId`),
|
|
82
|
+
(0, decorators_1.Audit)(assistant_action_meta_1.assistantActionMeta, "actionId"),
|
|
83
|
+
__param(0, (0, common_1.Req)()),
|
|
84
|
+
__param(1, (0, common_1.Res)()),
|
|
85
|
+
__param(2, (0, common_1.Param)("actionId")),
|
|
86
|
+
__metadata("design:type", Function),
|
|
87
|
+
__metadata("design:paramtypes", [Object, Object, String]),
|
|
88
|
+
__metadata("design:returntype", Promise)
|
|
89
|
+
], AssistantActionController.prototype, "findById", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, common_1.Post)(`${assistant_action_meta_1.assistantActionMeta.endpoint}/:actionId/approve`),
|
|
92
|
+
(0, decorators_1.CacheInvalidate)(assistant_action_meta_1.assistantActionMeta, "actionId"),
|
|
93
|
+
__param(0, (0, common_1.Req)()),
|
|
94
|
+
__param(1, (0, common_1.Res)()),
|
|
95
|
+
__param(2, (0, common_1.Param)("actionId")),
|
|
96
|
+
__metadata("design:type", Function),
|
|
97
|
+
__metadata("design:paramtypes", [Object, Object, String]),
|
|
98
|
+
__metadata("design:returntype", Promise)
|
|
99
|
+
], AssistantActionController.prototype, "approve", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, common_1.Post)(`${assistant_action_meta_1.assistantActionMeta.endpoint}/:actionId/deny`),
|
|
102
|
+
(0, decorators_1.CacheInvalidate)(assistant_action_meta_1.assistantActionMeta, "actionId"),
|
|
103
|
+
__param(0, (0, common_1.Req)()),
|
|
104
|
+
__param(1, (0, common_1.Res)()),
|
|
105
|
+
__param(2, (0, common_1.Param)("actionId")),
|
|
106
|
+
__metadata("design:type", Function),
|
|
107
|
+
__metadata("design:paramtypes", [Object, Object, String]),
|
|
108
|
+
__metadata("design:returntype", Promise)
|
|
109
|
+
], AssistantActionController.prototype, "deny", null);
|
|
110
|
+
exports.AssistantActionController = AssistantActionController = __decorate([
|
|
111
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
112
|
+
(0, common_1.Controller)(),
|
|
113
|
+
__metadata("design:paramtypes", [assistant_action_service_1.AssistantActionService,
|
|
114
|
+
assistant_service_1.AssistantService,
|
|
115
|
+
jsonapi_service_1.JsonApiService,
|
|
116
|
+
audit_service_1.AuditService,
|
|
117
|
+
cache_service_1.CacheService])
|
|
118
|
+
], AssistantActionController);
|
|
119
|
+
//# sourceMappingURL=assistant-action.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.controller.js","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/controllers/assistant-action.controller.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppLoggingService } from "../../../core/logging/services/logging.service";
|
|
2
|
+
import { AssistantActionRepository } from "../repositories/assistant-action.repository";
|
|
3
|
+
export declare class AssistantActionExpiryCron {
|
|
4
|
+
private readonly assistantActionRepository;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(assistantActionRepository: AssistantActionRepository, logger: AppLoggingService);
|
|
7
|
+
handleOverdueActions(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=assistant-action.expiry.cron.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.expiry.cron.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/cron/assistant-action.expiry.cron.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAExF,qBACa,yBAAyB;IAElC,OAAO,CAAC,QAAQ,CAAC,yBAAyB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,iBAAiB;IAItC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAa5C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AssistantActionExpiryCron = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const schedule_1 = require("@nestjs/schedule");
|
|
15
|
+
const logging_service_1 = require("../../../core/logging/services/logging.service");
|
|
16
|
+
const assistant_action_repository_1 = require("../repositories/assistant-action.repository");
|
|
17
|
+
let AssistantActionExpiryCron = class AssistantActionExpiryCron {
|
|
18
|
+
constructor(assistantActionRepository, logger) {
|
|
19
|
+
this.assistantActionRepository = assistantActionRepository;
|
|
20
|
+
this.logger = logger;
|
|
21
|
+
}
|
|
22
|
+
async handleOverdueActions() {
|
|
23
|
+
const overdueActions = await this.assistantActionRepository.findAllOverduePendingActions();
|
|
24
|
+
for (const { assistantActionId, companyId } of overdueActions) {
|
|
25
|
+
try {
|
|
26
|
+
await this.assistantActionRepository.expireAction({ assistantActionId, companyId });
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
this.logger.error(`Failed to expire assistant action ${assistantActionId} for company ${companyId}: ${error.message}`, "AssistantActionExpiryCron");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.AssistantActionExpiryCron = AssistantActionExpiryCron;
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, schedule_1.Cron)(schedule_1.CronExpression.EVERY_HOUR),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", []),
|
|
39
|
+
__metadata("design:returntype", Promise)
|
|
40
|
+
], AssistantActionExpiryCron.prototype, "handleOverdueActions", null);
|
|
41
|
+
exports.AssistantActionExpiryCron = AssistantActionExpiryCron = __decorate([
|
|
42
|
+
(0, common_1.Injectable)(),
|
|
43
|
+
__metadata("design:paramtypes", [assistant_action_repository_1.AssistantActionRepository,
|
|
44
|
+
logging_service_1.AppLoggingService])
|
|
45
|
+
], AssistantActionExpiryCron);
|
|
46
|
+
//# sourceMappingURL=assistant-action.expiry.cron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.expiry.cron.js","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/cron/assistant-action.expiry.cron.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAwD;AACxD,oFAAmF;AACnF,6FAAwF;AAGjF,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC,YACmB,yBAAoD,EACpD,MAAyB;QADzB,8BAAyB,GAAzB,yBAAyB,CAA2B;QACpD,WAAM,GAAN,MAAM,CAAmB;IACzC,CAAC;IAGE,AAAN,KAAK,CAAC,oBAAoB;QACxB,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,4BAA4B,EAAE,CAAC;QAC3F,KAAK,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,cAAc,EAAE,CAAC;YAC9D,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,yBAAyB,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,CAAC;YACtF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,qCAAqC,iBAAiB,gBAAgB,SAAS,KAAM,KAAe,CAAC,OAAO,EAAE,EAC9G,2BAA2B,CAC5B,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AApBY,8DAAyB;AAO9B;IADL,IAAA,eAAI,EAAC,yBAAc,CAAC,UAAU,CAAC;;;;qEAa/B;oCAnBU,yBAAyB;IADrC,IAAA,mBAAU,GAAE;qCAGmC,uDAAyB;QAC5C,mCAAiB;GAHjC,yBAAyB,CAoBrC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Entity } from "../../../common";
|
|
2
|
+
import type { Company } from "../../company/entities/company";
|
|
3
|
+
import type { Assistant } from "../../assistant/entities/assistant";
|
|
4
|
+
import type { AssistantMessage } from "../../assistant-message/entities/assistant-message";
|
|
5
|
+
export type AssistantActionStatus = "pending" | "approved" | "denied" | "expired" | "executed" | "failed";
|
|
6
|
+
/**
|
|
7
|
+
* AssistantAction — a durable, first-class record of a destructive tool call
|
|
8
|
+
* awaiting (or having received) human approval. Survives Redis checkpoint loss
|
|
9
|
+
* and acts as the audit trail for operator approval gates.
|
|
10
|
+
*
|
|
11
|
+
* `requestedAt` is intentionally NOT a field — the framework's `createdAt`
|
|
12
|
+
* covers it.
|
|
13
|
+
*/
|
|
14
|
+
export type AssistantAction = Entity & {
|
|
15
|
+
status: AssistantActionStatus;
|
|
16
|
+
toolName: string;
|
|
17
|
+
toolArgs: string;
|
|
18
|
+
summary: string;
|
|
19
|
+
threadId: string;
|
|
20
|
+
userModuleIds: string;
|
|
21
|
+
contentScope?: string;
|
|
22
|
+
resolvedAt?: string;
|
|
23
|
+
expiresAt: string;
|
|
24
|
+
company: Company;
|
|
25
|
+
assistant: Assistant;
|
|
26
|
+
message?: AssistantMessage;
|
|
27
|
+
};
|
|
28
|
+
export declare const AssistantActionDescriptor: import("../../../common").EntityDescriptor<AssistantAction, {
|
|
29
|
+
assistant: {
|
|
30
|
+
model: import("../../../common").DataMeta;
|
|
31
|
+
direction: "in";
|
|
32
|
+
relationship: string;
|
|
33
|
+
cardinality: "one";
|
|
34
|
+
required: true;
|
|
35
|
+
dtoKey: string;
|
|
36
|
+
immutable: true;
|
|
37
|
+
};
|
|
38
|
+
message: {
|
|
39
|
+
model: import("../../../common").DataMeta;
|
|
40
|
+
direction: "in";
|
|
41
|
+
relationship: string;
|
|
42
|
+
cardinality: "one";
|
|
43
|
+
required: false;
|
|
44
|
+
dtoKey: string;
|
|
45
|
+
immutable: true;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
export type AssistantActionDescriptorType = typeof AssistantActionDescriptor;
|
|
49
|
+
//# sourceMappingURL=assistant-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/entities/assistant-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAI3F,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE1G;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IACrC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;EAkCpC,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,OAAO,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssistantActionDescriptor = void 0;
|
|
4
|
+
const common_1 = require("../../../common");
|
|
5
|
+
const assistant_meta_1 = require("../../assistant/entities/assistant.meta");
|
|
6
|
+
const assistant_message_meta_1 = require("../../assistant-message/entities/assistant-message.meta");
|
|
7
|
+
const assistant_action_meta_1 = require("./assistant-action.meta");
|
|
8
|
+
exports.AssistantActionDescriptor = (0, common_1.defineEntity)()({
|
|
9
|
+
...assistant_action_meta_1.assistantActionMeta,
|
|
10
|
+
isCompanyScoped: true,
|
|
11
|
+
fields: {
|
|
12
|
+
status: { type: "string" },
|
|
13
|
+
toolName: { type: "string" },
|
|
14
|
+
toolArgs: { type: "string" },
|
|
15
|
+
summary: { type: "string" },
|
|
16
|
+
threadId: { type: "string" },
|
|
17
|
+
userModuleIds: { type: "string" },
|
|
18
|
+
contentScope: { type: "string" },
|
|
19
|
+
resolvedAt: { type: "datetime" },
|
|
20
|
+
expiresAt: { type: "datetime", required: true },
|
|
21
|
+
},
|
|
22
|
+
relationships: {
|
|
23
|
+
assistant: {
|
|
24
|
+
model: assistant_meta_1.assistantMeta,
|
|
25
|
+
direction: "in", // the Assistant owns the action: (Assistant)-[:HAS_ACTION]->(AssistantAction)
|
|
26
|
+
relationship: "HAS_ACTION",
|
|
27
|
+
cardinality: "one",
|
|
28
|
+
required: true,
|
|
29
|
+
dtoKey: "assistant",
|
|
30
|
+
immutable: true,
|
|
31
|
+
},
|
|
32
|
+
message: {
|
|
33
|
+
model: assistant_message_meta_1.assistantMessageMeta,
|
|
34
|
+
direction: "in", // (AssistantMessage)-[:REQUESTED_IN]->(AssistantAction)
|
|
35
|
+
relationship: "REQUESTED_IN",
|
|
36
|
+
cardinality: "one",
|
|
37
|
+
required: false,
|
|
38
|
+
dtoKey: "message",
|
|
39
|
+
immutable: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=assistant-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.js","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/entities/assistant-action.ts"],"names":[],"mappings":";;;AAAA,4CAAuD;AAGvD,4EAAwE;AAExE,oGAA+F;AAC/F,mEAA8D;AA2BjD,QAAA,yBAAyB,GAAG,IAAA,qBAAY,GAAmB,CAAC;IACvE,GAAG,2CAAmB;IACtB,eAAe,EAAE,IAAI;IACrB,MAAM,EAAE;QACN,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACjC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAChC,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;QAChC,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;KAChD;IACD,aAAa,EAAE;QACb,SAAS,EAAE;YACT,KAAK,EAAE,8BAAa;YACpB,SAAS,EAAE,IAAI,EAAE,8EAA8E;YAC/F,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,IAAI;SAChB;QACD,OAAO,EAAE;YACP,KAAK,EAAE,6CAAoB;YAC3B,SAAS,EAAE,IAAI,EAAE,wDAAwD;YACzE,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,IAAI;SAChB;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.meta.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/entities/assistant-action.meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAE1E,eAAO,MAAM,mBAAmB,EAAE,QAKjC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assistantActionMeta = void 0;
|
|
4
|
+
exports.assistantActionMeta = {
|
|
5
|
+
type: "assistant-actions",
|
|
6
|
+
endpoint: "assistant-actions",
|
|
7
|
+
nodeName: "assistantAction",
|
|
8
|
+
labelName: "AssistantAction",
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=assistant-action.meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.meta.js","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/entities/assistant-action.meta.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAa;IAC3C,IAAI,EAAE,mBAAmB;IACzB,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,iBAAiB;IAC3B,SAAS,EAAE,iBAAiB;CAC7B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./entities/assistant-action.meta";
|
|
2
|
+
export * from "./entities/assistant-action";
|
|
3
|
+
export * from "./repositories/assistant-action.repository";
|
|
4
|
+
export * from "./services/assistant-action.service";
|
|
5
|
+
export * from "./controllers/assistant-action.controller";
|
|
6
|
+
export * from "./assistant-action.module";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/foundations/assistant-action/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AACpD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./entities/assistant-action.meta"), exports);
|
|
18
|
+
__exportStar(require("./entities/assistant-action"), exports);
|
|
19
|
+
__exportStar(require("./repositories/assistant-action.repository"), exports);
|
|
20
|
+
__exportStar(require("./services/assistant-action.service"), exports);
|
|
21
|
+
__exportStar(require("./controllers/assistant-action.controller"), exports);
|
|
22
|
+
__exportStar(require("./assistant-action.module"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/foundations/assistant-action/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,8DAA4C;AAC5C,6EAA2D;AAC3D,sEAAoD;AACpD,4EAA0D;AAC1D,4DAA0C"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ClsService } from "nestjs-cls";
|
|
2
|
+
import { AbstractRepository } from "../../../core/neo4j/abstracts/abstract.repository";
|
|
3
|
+
import { Neo4jService } from "../../../core/neo4j/services/neo4j.service";
|
|
4
|
+
import { SecurityService } from "../../../core/security/services/security.service";
|
|
5
|
+
import { AssistantAction, AssistantActionDescriptor, AssistantActionStatus } from "../entities/assistant-action";
|
|
6
|
+
/**
|
|
7
|
+
* AssistantActionRepository
|
|
8
|
+
*
|
|
9
|
+
* Owner-RBAC is inherited from the parent Assistant (a user may only see the
|
|
10
|
+
* actions that belong to their own assistants). Company scope is applied
|
|
11
|
+
* automatically via `buildDefaultMatch()` (`isCompanyScoped: true`).
|
|
12
|
+
*/
|
|
13
|
+
export declare class AssistantActionRepository extends AbstractRepository<AssistantAction, typeof AssistantActionDescriptor.relationships> {
|
|
14
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<AssistantAction, {
|
|
15
|
+
assistant: {
|
|
16
|
+
model: import("../../..").DataMeta;
|
|
17
|
+
direction: "in";
|
|
18
|
+
relationship: string;
|
|
19
|
+
cardinality: "one";
|
|
20
|
+
required: true;
|
|
21
|
+
dtoKey: string;
|
|
22
|
+
immutable: true;
|
|
23
|
+
};
|
|
24
|
+
message: {
|
|
25
|
+
model: import("../../..").DataMeta;
|
|
26
|
+
direction: "in";
|
|
27
|
+
relationship: string;
|
|
28
|
+
cardinality: "one";
|
|
29
|
+
required: false;
|
|
30
|
+
dtoKey: string;
|
|
31
|
+
immutable: true;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
constructor(neo4j: Neo4jService, securityService: SecurityService, clsService: ClsService);
|
|
35
|
+
protected buildUserHasAccess(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Atomically transition the action's status from `from` to `to`, guarded in
|
|
38
|
+
* Cypher so that only one of N concurrent attempts wins (`WHERE status =
|
|
39
|
+
* $from`). Also requires `expiresAt` to be in the future — expired actions
|
|
40
|
+
* can no longer be resolved.
|
|
41
|
+
*
|
|
42
|
+
* Under Neo4j's read-committed isolation a plain `MATCH … WHERE … SET` is
|
|
43
|
+
* check-then-set: the WHERE is evaluated before the write lock is acquired
|
|
44
|
+
* at SET and is NOT re-evaluated afterwards, so two concurrent approves
|
|
45
|
+
* could both pass the guard. The no-op `SET updatedAt = updatedAt` acquires
|
|
46
|
+
* the node's write lock BEFORE the guard (standard Neo4j CAS idiom), making
|
|
47
|
+
* the guard + transition atomic.
|
|
48
|
+
*
|
|
49
|
+
* Owner-RBAC (`buildUserHasAccess`) is injected via
|
|
50
|
+
* `securityService.userHasAccess()`, mirroring the framework's standard
|
|
51
|
+
* write path in AbstractRepository.
|
|
52
|
+
*
|
|
53
|
+
* Returns true when this call won the transition, false otherwise.
|
|
54
|
+
*/
|
|
55
|
+
resolveStatus(params: {
|
|
56
|
+
id: string;
|
|
57
|
+
from: AssistantActionStatus;
|
|
58
|
+
to: AssistantActionStatus;
|
|
59
|
+
}): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Cross-company sweep used by AssistantActionExpiryCron (runs outside any
|
|
62
|
+
* request, so there is no CLS company context). Mirrors
|
|
63
|
+
* CommunityRepository.findAllStaleCommunities(): the read returns
|
|
64
|
+
* id + companyId pairs so that every subsequent write stays company-scoped.
|
|
65
|
+
*/
|
|
66
|
+
findAllOverduePendingActions(): Promise<{
|
|
67
|
+
assistantActionId: string;
|
|
68
|
+
companyId: string;
|
|
69
|
+
}[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Company-scoped expiry write for a single overdue pending action, called by
|
|
72
|
+
* AssistantActionExpiryCron with the companyId resolved by the sweep above.
|
|
73
|
+
* Guarded on status AND expiresAt so a concurrent approval/denial between
|
|
74
|
+
* the sweep read and this write is never overwritten.
|
|
75
|
+
*/
|
|
76
|
+
expireAction(params: {
|
|
77
|
+
assistantActionId: string;
|
|
78
|
+
companyId: string;
|
|
79
|
+
}): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=assistant-action.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-action.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/assistant-action/repositories/assistant-action.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,eAAe,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGjH;;;;;;GAMG;AACH,qBACa,yBAA0B,SAAQ,kBAAkB,CAC/D,eAAe,EACf,OAAO,yBAAyB,CAAC,aAAa,CAC/C;IACC,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;;;;;;OAA6B;gBAE9C,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAIzF,SAAS,CAAC,kBAAkB,IAAI,MAAM;IAStC;;;;;;;;;;;;;;;;;;OAkBG;IACG,aAAa,CAAC,MAAM,EAAE;QAC1B,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,qBAAqB,CAAC;QAC5B,EAAE,EAAE,qBAAqB,CAAC;KAC3B,GAAG,OAAO,CAAC,OAAO,CAAC;IAsBpB;;;;;OAKG;IACG,4BAA4B,IAAI,OAAO,CAAC;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAgBjG;;;;;OAKG;IACG,YAAY,CAAC,MAAM,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB5F"}
|