@carlonicora/nestjs-neo4jsonapi 1.97.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.
Files changed (137) hide show
  1. package/dist/agents/graph/tools/search-entities.tool.d.ts.map +1 -1
  2. package/dist/agents/graph/tools/search-entities.tool.js +14 -3
  3. package/dist/agents/graph/tools/search-entities.tool.js.map +1 -1
  4. package/dist/agents/graph/tools/tool.factory.d.ts.map +1 -1
  5. package/dist/agents/graph/tools/tool.factory.js +16 -2
  6. package/dist/agents/graph/tools/tool.factory.js.map +1 -1
  7. package/dist/agents/graph/tools/traverse.tool.d.ts.map +1 -1
  8. package/dist/agents/graph/tools/traverse.tool.js +14 -4
  9. package/dist/agents/graph/tools/traverse.tool.js.map +1 -1
  10. package/dist/agents/index.d.ts +15 -0
  11. package/dist/agents/index.d.ts.map +1 -1
  12. package/dist/agents/index.js +28 -1
  13. package/dist/agents/index.js.map +1 -1
  14. package/dist/agents/operator/contexts/operator.context.d.ts +54 -0
  15. package/dist/agents/operator/contexts/operator.context.d.ts.map +1 -0
  16. package/dist/agents/operator/contexts/operator.context.js +23 -0
  17. package/dist/agents/operator/contexts/operator.context.js.map +1 -0
  18. package/dist/agents/operator/controllers/operator.controller.d.ts +37 -0
  19. package/dist/agents/operator/controllers/operator.controller.d.ts.map +1 -0
  20. package/dist/agents/operator/controllers/operator.controller.js +142 -0
  21. package/dist/agents/operator/controllers/operator.controller.js.map +1 -0
  22. package/dist/agents/operator/entities/operator.meta.d.ts +8 -0
  23. package/dist/agents/operator/entities/operator.meta.d.ts.map +1 -0
  24. package/dist/agents/operator/entities/operator.meta.js +15 -0
  25. package/dist/agents/operator/entities/operator.meta.js.map +1 -0
  26. package/dist/agents/operator/interfaces/operator.tool.interface.d.ts +42 -0
  27. package/dist/agents/operator/interfaces/operator.tool.interface.d.ts.map +1 -0
  28. package/dist/agents/operator/interfaces/operator.tool.interface.js +6 -0
  29. package/dist/agents/operator/interfaces/operator.tool.interface.js.map +1 -0
  30. package/dist/agents/operator/operator.module.d.ts +3 -0
  31. package/dist/agents/operator/operator.module.d.ts.map +1 -0
  32. package/dist/agents/operator/operator.module.js +44 -0
  33. package/dist/agents/operator/operator.module.js.map +1 -0
  34. package/dist/agents/operator/prompts/operator.system.prompt.d.ts +2 -0
  35. package/dist/agents/operator/prompts/operator.system.prompt.d.ts.map +1 -0
  36. package/dist/agents/operator/prompts/operator.system.prompt.js +25 -0
  37. package/dist/agents/operator/prompts/operator.system.prompt.js.map +1 -0
  38. package/dist/agents/operator/services/operator.checkpointer.service.d.ts +57 -0
  39. package/dist/agents/operator/services/operator.checkpointer.service.d.ts.map +1 -0
  40. package/dist/agents/operator/services/operator.checkpointer.service.js +171 -0
  41. package/dist/agents/operator/services/operator.checkpointer.service.js.map +1 -0
  42. package/dist/agents/operator/services/operator.service.d.ts +81 -0
  43. package/dist/agents/operator/services/operator.service.d.ts.map +1 -0
  44. package/dist/agents/operator/services/operator.service.js +341 -0
  45. package/dist/agents/operator/services/operator.service.js.map +1 -0
  46. package/dist/agents/operator/tools/operator-test-action.tool.d.ts +12 -0
  47. package/dist/agents/operator/tools/operator-test-action.tool.d.ts.map +1 -0
  48. package/dist/agents/operator/tools/operator-test-action.tool.js +46 -0
  49. package/dist/agents/operator/tools/operator-test-action.tool.js.map +1 -0
  50. package/dist/agents/operator/tools/operator.tool.registry.d.ts +32 -0
  51. package/dist/agents/operator/tools/operator.tool.registry.d.ts.map +1 -0
  52. package/dist/agents/operator/tools/operator.tool.registry.js +95 -0
  53. package/dist/agents/operator/tools/operator.tool.registry.js.map +1 -0
  54. package/dist/agents/operator/tools/search-communities.tool.d.ts +16 -0
  55. package/dist/agents/operator/tools/search-communities.tool.d.ts.map +1 -0
  56. package/dist/agents/operator/tools/search-communities.tool.js +51 -0
  57. package/dist/agents/operator/tools/search-communities.tool.js.map +1 -0
  58. package/dist/agents/operator/tools/search-documents.tool.d.ts +17 -0
  59. package/dist/agents/operator/tools/search-documents.tool.d.ts.map +1 -0
  60. package/dist/agents/operator/tools/search-documents.tool.js +76 -0
  61. package/dist/agents/operator/tools/search-documents.tool.js.map +1 -0
  62. package/dist/config/base.config.d.ts +6 -0
  63. package/dist/config/base.config.d.ts.map +1 -1
  64. package/dist/config/base.config.js +1 -0
  65. package/dist/config/base.config.js.map +1 -1
  66. package/dist/config/interfaces/base.config.interface.d.ts +2 -0
  67. package/dist/config/interfaces/base.config.interface.d.ts.map +1 -1
  68. package/dist/config/interfaces/config.operator.interface.d.ts +9 -0
  69. package/dist/config/interfaces/config.operator.interface.d.ts.map +1 -0
  70. package/dist/config/interfaces/config.operator.interface.js +3 -0
  71. package/dist/config/interfaces/config.operator.interface.js.map +1 -0
  72. package/dist/config/interfaces/config.prompts.interface.d.ts +1 -0
  73. package/dist/config/interfaces/config.prompts.interface.d.ts.map +1 -1
  74. package/dist/config/interfaces/index.d.ts +1 -0
  75. package/dist/config/interfaces/index.d.ts.map +1 -1
  76. package/dist/config/interfaces/index.js +1 -0
  77. package/dist/config/interfaces/index.js.map +1 -1
  78. package/dist/core/llm/services/llm.service.d.ts +35 -0
  79. package/dist/core/llm/services/llm.service.d.ts.map +1 -1
  80. package/dist/core/llm/services/llm.service.js +92 -0
  81. package/dist/core/llm/services/llm.service.js.map +1 -1
  82. package/dist/foundations/assistant/assistant.module.d.ts.map +1 -1
  83. package/dist/foundations/assistant/assistant.module.js +14 -1
  84. package/dist/foundations/assistant/assistant.module.js.map +1 -1
  85. package/dist/foundations/assistant/entities/assistant.d.ts +1 -0
  86. package/dist/foundations/assistant/entities/assistant.d.ts.map +1 -1
  87. package/dist/foundations/assistant/entities/assistant.js +1 -0
  88. package/dist/foundations/assistant/entities/assistant.js.map +1 -1
  89. package/dist/foundations/assistant/services/assistant.service.d.ts +88 -1
  90. package/dist/foundations/assistant/services/assistant.service.d.ts.map +1 -1
  91. package/dist/foundations/assistant/services/assistant.service.js +365 -2
  92. package/dist/foundations/assistant/services/assistant.service.js.map +1 -1
  93. package/dist/foundations/assistant-action/assistant-action.module.d.ts +5 -0
  94. package/dist/foundations/assistant-action/assistant-action.module.d.ts.map +1 -0
  95. package/dist/foundations/assistant-action/assistant-action.module.js +43 -0
  96. package/dist/foundations/assistant-action/assistant-action.module.js.map +1 -0
  97. package/dist/foundations/assistant-action/controllers/assistant-action.controller.d.ts +30 -0
  98. package/dist/foundations/assistant-action/controllers/assistant-action.controller.d.ts.map +1 -0
  99. package/dist/foundations/assistant-action/controllers/assistant-action.controller.js +119 -0
  100. package/dist/foundations/assistant-action/controllers/assistant-action.controller.js.map +1 -0
  101. package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.d.ts +9 -0
  102. package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.d.ts.map +1 -0
  103. package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.js +46 -0
  104. package/dist/foundations/assistant-action/cron/assistant-action.expiry.cron.js.map +1 -0
  105. package/dist/foundations/assistant-action/entities/assistant-action.d.ts +49 -0
  106. package/dist/foundations/assistant-action/entities/assistant-action.d.ts.map +1 -0
  107. package/dist/foundations/assistant-action/entities/assistant-action.js +43 -0
  108. package/dist/foundations/assistant-action/entities/assistant-action.js.map +1 -0
  109. package/dist/foundations/assistant-action/entities/assistant-action.meta.d.ts +3 -0
  110. package/dist/foundations/assistant-action/entities/assistant-action.meta.d.ts.map +1 -0
  111. package/dist/foundations/assistant-action/entities/assistant-action.meta.js +10 -0
  112. package/dist/foundations/assistant-action/entities/assistant-action.meta.js.map +1 -0
  113. package/dist/foundations/assistant-action/index.d.ts +7 -0
  114. package/dist/foundations/assistant-action/index.d.ts.map +1 -0
  115. package/dist/foundations/assistant-action/index.js +23 -0
  116. package/dist/foundations/assistant-action/index.js.map +1 -0
  117. package/dist/foundations/assistant-action/repositories/assistant-action.repository.d.ts +81 -0
  118. package/dist/foundations/assistant-action/repositories/assistant-action.repository.d.ts.map +1 -0
  119. package/dist/foundations/assistant-action/repositories/assistant-action.repository.js +131 -0
  120. package/dist/foundations/assistant-action/repositories/assistant-action.repository.js.map +1 -0
  121. package/dist/foundations/assistant-action/services/assistant-action.service.d.ts +48 -0
  122. package/dist/foundations/assistant-action/services/assistant-action.service.d.ts.map +1 -0
  123. package/dist/foundations/assistant-action/services/assistant-action.service.js +67 -0
  124. package/dist/foundations/assistant-action/services/assistant-action.service.js.map +1 -0
  125. package/dist/foundations/assistant-message/entities/assistant-message.d.ts +12 -0
  126. package/dist/foundations/assistant-message/entities/assistant-message.d.ts.map +1 -1
  127. package/dist/foundations/assistant-message/entities/assistant-message.js +11 -0
  128. package/dist/foundations/assistant-message/entities/assistant-message.js.map +1 -1
  129. package/dist/foundations/assistant-message/repositories/assistant-message.repository.d.ts +9 -0
  130. package/dist/foundations/assistant-message/repositories/assistant-message.repository.d.ts.map +1 -1
  131. package/dist/foundations/assistant-message/services/assistant-message.service.d.ts +9 -0
  132. package/dist/foundations/assistant-message/services/assistant-message.service.d.ts.map +1 -1
  133. package/dist/foundations/index.d.ts +1 -0
  134. package/dist/foundations/index.d.ts.map +1 -1
  135. package/dist/foundations/index.js +1 -0
  136. package/dist/foundations/index.js.map +1 -1
  137. package/package.json +2 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.controller.js","sourceRoot":"","sources":["../../../../src/agents/operator/controllers/operator.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAuF;AACvF,0EAAqE;AAErE,oFAAgF;AAChF,sGAA4G;AAC5G,yGAA+G;AAC/G,mHAA8G;AAC9G,mGAA8F;AAC9F,+FAA0F;AAC1F,iFAAwF;AACxF,2FAAuF;AACvF,0GAAgG;AAChG,iGAA6F;AAC7F,6DAAyD;AAEzD;;;;;;;;GAQG;AAGI,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAG7B,YACmB,UAA4B,EAC5B,OAAuB;QADvB,eAAU,GAAV,UAAU,CAAkB;QAC5B,YAAO,GAAP,OAAO,CAAgB;QAJzB,WAAM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,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,4CAAyB,CAAC,KAAK,EAAE,MAAM,CAAC,CAGzF,CAAC;YACF,wDAAwD;YACxD,wEAAwE;YACxE,QAAQ,CAAC,QAAQ,GAAG,IAAA,oCAAa,EAAC,QAAQ,CAAC,QAAiC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC9F,IAAI,EAAE,8BAAa,CAAC,IAAI;gBACxB,EAAE,EAAE,WAAW;aAChB,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;QACxD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAjGY,gDAAkB;AAiBvB;IADL,IAAA,aAAI,EAAC,4BAAY,CAAC,QAAQ,CAAC;IACd,WAAA,IAAA,aAAI,GAAE,CAAA;IAA0B,WAAA,IAAA,YAAG,GAAE,CAAA;;qCAAxB,qCAAgB;;gDAoC1C;AASK;IADL,IAAA,aAAI,EAAC,GAAG,4BAAY,CAAC,QAAQ,iBAAiB,6CAAoB,CAAC,QAAQ,EAAE,CAAC;IAE5E,WAAA,IAAA,cAAK,EAAC,aAAa,CAAC,CAAA;IACpB,WAAA,IAAA,aAAI,GAAE,CAAA;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;;6CADQ,yCAAkB;;gDAgCjC;6BAhGU,kBAAkB;IAF9B,IAAA,kBAAS,EAAC,6BAAY,CAAC;IACvB,IAAA,mBAAU,GAAE;qCAKoB,oCAAgB;QACnB,gCAAc;GAL/B,kBAAkB,CAiG9B"}
@@ -0,0 +1,8 @@
1
+ import { DataMeta } from "../../../common/interfaces/datamodel.interface";
2
+ /**
3
+ * Non-entity meta for the standalone operator endpoints (mirrors `authMeta`):
4
+ * the operator module exposes routes but has no Neo4j node of its own — the
5
+ * persisted resources are Assistants / AssistantMessages / AssistantActions.
6
+ */
7
+ export declare const operatorMeta: DataMeta;
8
+ //# sourceMappingURL=operator.meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.meta.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/entities/operator.meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,QAK1B,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.operatorMeta = void 0;
4
+ /**
5
+ * Non-entity meta for the standalone operator endpoints (mirrors `authMeta`):
6
+ * the operator module exposes routes but has no Neo4j node of its own — the
7
+ * persisted resources are Assistants / AssistantMessages / AssistantActions.
8
+ */
9
+ exports.operatorMeta = {
10
+ type: "operator",
11
+ endpoint: "operator",
12
+ nodeName: "operator",
13
+ labelName: "Operator",
14
+ };
15
+ //# sourceMappingURL=operator.meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.meta.js","sourceRoot":"","sources":["../../../../src/agents/operator/entities/operator.meta.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACU,QAAA,YAAY,GAAa;IACpC,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,UAAU;CACtB,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { DynamicStructuredTool } from "@langchain/core/tools";
2
+ import { MessageInterface } from "../../../common/interfaces/message.interface";
3
+ import { DataLimits } from "../../../common/types/data.limits";
4
+ import { ToolCallRecord, UserContext } from "../../graph/tools/tool.factory";
5
+ export interface OperatorToolDefinition {
6
+ tool: DynamicStructuredTool;
7
+ destructive: boolean;
8
+ /** Human-readable line shown in the approval card. Required when destructive. */
9
+ summarise?: (args: Record<string, unknown>) => string;
10
+ }
11
+ /** Chunk citation pushed into the per-turn recorder by retrieval tools. */
12
+ export interface OperatorChunkCitation {
13
+ chunkId: string;
14
+ relevance: number;
15
+ }
16
+ /**
17
+ * ToolCallRecord extended with the chunk citations a retrieval tool collected.
18
+ * Kept additive (operator-local) so the graph tools' recorder type is untouched.
19
+ */
20
+ export interface OperatorToolCallRecord extends ToolCallRecord {
21
+ citations?: OperatorChunkCitation[];
22
+ }
23
+ /** Per-turn context the operator retrieval tools are built with. */
24
+ export interface OperatorRetrievalContext extends UserContext {
25
+ contentId?: string;
26
+ contentType?: string;
27
+ dataLimits: DataLimits;
28
+ messages: MessageInterface[];
29
+ }
30
+ /**
31
+ * Factory contract for app-contributed operator tools.
32
+ * Built once per operator turn — like the built-ins — so contributed tools can
33
+ * apply company scoping from the request context and record their calls into
34
+ * the per-turn toolCalls audit trail.
35
+ */
36
+ export interface OperatorToolContribution {
37
+ /** Called once per operator turn with the request context and the per-turn tool-call recorder. */
38
+ build(ctx: OperatorRetrievalContext, recorder: ToolCallRecord[]): OperatorToolDefinition;
39
+ }
40
+ /** Multi-provider DI token: consuming apps contribute OperatorToolContribution factories. */
41
+ export declare const OPERATOR_TOOLS: unique symbol;
42
+ //# sourceMappingURL=operator.tool.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.tool.interface.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/interfaces/operator.tool.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7E,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,iFAAiF;IACjF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;CACvD;AAED,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,SAAS,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACrC;AAED,oEAAoE;AACpE,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,kGAAkG;IAClG,KAAK,CAAC,GAAG,EAAE,wBAAwB,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,sBAAsB,CAAC;CAC1F;AAED,6FAA6F;AAC7F,eAAO,MAAM,cAAc,eAA2B,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPERATOR_TOOLS = void 0;
4
+ /** Multi-provider DI token: consuming apps contribute OperatorToolContribution factories. */
5
+ exports.OPERATOR_TOOLS = Symbol("OPERATOR_TOOLS");
6
+ //# sourceMappingURL=operator.tool.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.tool.interface.js","sourceRoot":"","sources":["../../../../src/agents/operator/interfaces/operator.tool.interface.ts"],"names":[],"mappings":";;;AA6CA,6FAA6F;AAChF,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare class OperatorModule {
2
+ }
3
+ //# sourceMappingURL=operator.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.module.d.ts","sourceRoot":"","sources":["../../../src/agents/operator/operator.module.ts"],"names":[],"mappings":"AAcA,qBAgBa,cAAc;CAAG"}
@@ -0,0 +1,44 @@
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.OperatorModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const llm_module_1 = require("../../core/llm/llm.module");
12
+ const assistant_module_1 = require("../../foundations/assistant/assistant.module");
13
+ const contextualiser_module_1 = require("../contextualiser/contextualiser.module");
14
+ const drift_module_1 = require("../drift/drift.module");
15
+ const graph_module_1 = require("../graph/graph.module");
16
+ const operator_controller_1 = require("./controllers/operator.controller");
17
+ const operator_checkpointer_service_1 = require("./services/operator.checkpointer.service");
18
+ const operator_service_1 = require("./services/operator.service");
19
+ const operator_test_action_tool_1 = require("./tools/operator-test-action.tool");
20
+ const operator_tool_registry_1 = require("./tools/operator.tool.registry");
21
+ const search_communities_tool_1 = require("./tools/search-communities.tool");
22
+ const search_documents_tool_1 = require("./tools/search-documents.tool");
23
+ let OperatorModule = class OperatorModule {
24
+ };
25
+ exports.OperatorModule = OperatorModule;
26
+ exports.OperatorModule = OperatorModule = __decorate([
27
+ (0, common_1.Module)({
28
+ // forwardRef: OperatorController needs AssistantService (operator turn
29
+ // orchestration) while AssistantModule imports this module for
30
+ // OperatorService — the cycle requires forwardRef on both sides.
31
+ imports: [llm_module_1.LLMModule, graph_module_1.GraphModule, contextualiser_module_1.ContextualiserModule, drift_module_1.DriftModule, (0, common_1.forwardRef)(() => assistant_module_1.AssistantModule)],
32
+ controllers: [operator_controller_1.OperatorController],
33
+ providers: [
34
+ operator_service_1.OperatorService,
35
+ operator_tool_registry_1.OperatorToolRegistry,
36
+ operator_checkpointer_service_1.OperatorCheckpointerService,
37
+ search_documents_tool_1.SearchDocumentsTool,
38
+ search_communities_tool_1.SearchCommunitiesTool,
39
+ operator_test_action_tool_1.OperatorTestActionTool,
40
+ ],
41
+ exports: [operator_service_1.OperatorService, operator_tool_registry_1.OperatorToolRegistry, operator_checkpointer_service_1.OperatorCheckpointerService],
42
+ })
43
+ ], OperatorModule);
44
+ //# sourceMappingURL=operator.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.module.js","sourceRoot":"","sources":["../../../src/agents/operator/operator.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,0DAAsD;AACtD,mFAA+E;AAC/E,mFAA+E;AAC/E,wDAAoD;AACpD,wDAAoD;AACpD,2EAAuE;AACvE,4FAAuF;AACvF,kEAA8D;AAC9D,iFAA2E;AAC3E,2EAAsE;AACtE,6EAAwE;AACxE,yEAAoE;AAkB7D,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAhB1B,IAAA,eAAM,EAAC;QACN,uEAAuE;QACvE,+DAA+D;QAC/D,iEAAiE;QACjE,OAAO,EAAE,CAAC,sBAAS,EAAE,0BAAW,EAAE,4CAAoB,EAAE,0BAAW,EAAE,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kCAAe,CAAC,CAAC;QACvG,WAAW,EAAE,CAAC,wCAAkB,CAAC;QACjC,SAAS,EAAE;YACT,kCAAe;YACf,6CAAoB;YACpB,2DAA2B;YAC3B,2CAAmB;YACnB,+CAAqB;YACrB,kDAAsB;SACvB;QACD,OAAO,EAAE,CAAC,kCAAe,EAAE,6CAAoB,EAAE,2DAA2B,CAAC;KAC9E,CAAC;GACW,cAAc,CAAG"}
@@ -0,0 +1,2 @@
1
+ export declare const defaultOperatorSystemPrompt = "# Role\n\nYou are an operator agent for a company ERP. You answer the user's request by calling tools in a loop: inspect the data, walk relationships, and \u2014 when the user asks for it \u2014 perform actions.\n\nEvery fact in your final reply must come from a tool call that returned it. Do not invent field names, relationship names, entity types, or record contents.\n\n## How to work\n\n- Call tools step by step. A typical request needs several tool calls; keep going until you have what you need, then reply without calling further tools.\n- If a tool returns an error message (for example \"Tool error: ...\" or \"{ error: ... }\"), read it, correct your input, and try again. Never stop on the first error and never apologise to the user for a tool error.\n- When an error tells you how to recover, recover immediately in the same run: if it suggests a corrected value (a \"suggestion\" field, or \"Retry this call with ...\"), retry the same tool with that value; if it says another tool must be called first (for example describe_entity), call that tool and then retry the original call. Never relay a tool error to the user as a question, and never ask permission to continue \u2014 you already have it.\n- Some tools perform real actions (they create, change, or delete data). When you call one of these, the system pauses and asks the user to approve the action before it runs. If the user denies it, you will see \"Action denied by the user.\" \u2014 accept the decision, do not retry the action, and wrap up by telling the user what was and was not done.\n- Never ask the user a clarifying question mid-run; make the most reasonable assumption, state it in your reply, and proceed.\n\n## Output\n\nWhen you are done, reply in plain prose with the answer or a summary of the actions performed. Quote real field values from tool results.\n\n- If the tool results do not contain the information needed to answer, say so plainly (\"I could not find ...\") instead of guessing.\n- Never claim to have performed, created, updated, or deleted anything unless a tool result in this conversation confirms that exact action. You have no ability to act outside your tools.\n";
2
+ //# sourceMappingURL=operator.system.prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.system.prompt.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/prompts/operator.system.prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,yoEAoBvC,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultOperatorSystemPrompt = void 0;
4
+ exports.defaultOperatorSystemPrompt = `# Role
5
+
6
+ You are an operator agent for a company ERP. You answer the user's request by calling tools in a loop: inspect the data, walk relationships, and — when the user asks for it — perform actions.
7
+
8
+ Every fact in your final reply must come from a tool call that returned it. Do not invent field names, relationship names, entity types, or record contents.
9
+
10
+ ## How to work
11
+
12
+ - Call tools step by step. A typical request needs several tool calls; keep going until you have what you need, then reply without calling further tools.
13
+ - If a tool returns an error message (for example "Tool error: ..." or "{ error: ... }"), read it, correct your input, and try again. Never stop on the first error and never apologise to the user for a tool error.
14
+ - When an error tells you how to recover, recover immediately in the same run: if it suggests a corrected value (a "suggestion" field, or "Retry this call with ..."), retry the same tool with that value; if it says another tool must be called first (for example describe_entity), call that tool and then retry the original call. Never relay a tool error to the user as a question, and never ask permission to continue — you already have it.
15
+ - Some tools perform real actions (they create, change, or delete data). When you call one of these, the system pauses and asks the user to approve the action before it runs. If the user denies it, you will see "Action denied by the user." — accept the decision, do not retry the action, and wrap up by telling the user what was and was not done.
16
+ - Never ask the user a clarifying question mid-run; make the most reasonable assumption, state it in your reply, and proceed.
17
+
18
+ ## Output
19
+
20
+ When you are done, reply in plain prose with the answer or a summary of the actions performed. Quote real field values from tool results.
21
+
22
+ - If the tool results do not contain the information needed to answer, say so plainly ("I could not find ...") instead of guessing.
23
+ - Never claim to have performed, created, updated, or deleted anything unless a tool result in this conversation confirms that exact action. You have no ability to act outside your tools.
24
+ `;
25
+ //# sourceMappingURL=operator.system.prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.system.prompt.js","sourceRoot":"","sources":["../../../../src/agents/operator/prompts/operator.system.prompt.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;CAoB1C,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { BaseCheckpointSaver } from "@langchain/langgraph";
2
+ import { OnModuleDestroy } from "@nestjs/common";
3
+ import { ConfigService } from "@nestjs/config";
4
+ import { BaseConfigInterface } from "../../../config/interfaces/base.config.interface";
5
+ /** Default number of days an operator approval may stay pending. */
6
+ export declare const OPERATOR_DEFAULT_APPROVAL_TTL_DAYS = 7;
7
+ /**
8
+ * OperatorCheckpointerService - Durable checkpoint storage for the operator agent.
9
+ *
10
+ * Lazily constructs and caches a LangGraph checkpoint saver:
11
+ * - `RedisSaver` (from `@langchain/langgraph-checkpoint-redis`) when a Redis
12
+ * connection is configured, using the same `redis` config block the
13
+ * QueueModule reads from ConfigService.
14
+ * - `MemorySaver` fallback when no Redis config is present (tests).
15
+ *
16
+ * Checkpoints expire after `(operator.approvalTtlDays ?? 7) + 1` days, one day
17
+ * past the approval expiry so a pending approval never outlives its checkpoint.
18
+ */
19
+ export declare class OperatorCheckpointerService implements OnModuleDestroy {
20
+ private readonly configService;
21
+ private readonly logger;
22
+ private saverPromise?;
23
+ constructor(configService: ConfigService<BaseConfigInterface>);
24
+ /** Lazily constructs and caches the saver; MemorySaver fallback when redis config is absent (tests). */
25
+ getSaver(): Promise<BaseCheckpointSaver>;
26
+ /** Closes the Redis connection on shutdown; never throws. */
27
+ onModuleDestroy(): Promise<void>;
28
+ private createSaver;
29
+ /**
30
+ * Probes the Redis server for the module commands RedisSaver depends on,
31
+ * using a short-lived ioredis client (already a dependency of this package —
32
+ * the node-redis `redis` package used by the saver is not resolvable from
33
+ * here under pnpm's strict isolation).
34
+ *
35
+ * `COMMAND INFO <name>` replies with a single-element array whose element is
36
+ * nil (`[null]`) when the command is unknown, and a populated array when it
37
+ * exists. It is preferred over `MODULE LIST` because on Redis 8+ the JSON
38
+ * and search commands are built into core (no module entry), while
39
+ * COMMAND INFO reports them uniformly on redis-stack, module-loaded Redis,
40
+ * and Redis 8+.
41
+ *
42
+ * Connection failures reject and propagate to the caller, exactly like a
43
+ * `RedisSaver.fromUrl` failure: getSaver() clears the cached promise so the
44
+ * next call retries.
45
+ */
46
+ private probeMissingRedisCommands;
47
+ /**
48
+ * RedisSaver.fromUrl creates its node-redis client without an "error"
49
+ * listener, so a socket error after startup would crash the process. The
50
+ * client is a TypeScript-private but runtime-reachable field; attach a
51
+ * logging handler when it is reachable, and degrade silently when a future
52
+ * library version hides it.
53
+ */
54
+ private attachSaverErrorHandler;
55
+ private buildRedisUrl;
56
+ }
57
+ //# sourceMappingURL=operator.checkpointer.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.checkpointer.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/services/operator.checkpointer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAsB,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAIvF,oEAAoE;AACpE,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAQpD;;;;;;;;;;;GAWG;AACH,qBACa,2BAA4B,YAAW,eAAe;IAKrD,OAAO,CAAC,QAAQ,CAAC,aAAa;IAJ1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgD;IAEvE,OAAO,CAAC,YAAY,CAAC,CAA+B;gBAEvB,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAE9E,wGAAwG;IAClG,QAAQ,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAY9C,6DAA6D;IACvD,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;YAexB,WAAW;IAoCzB;;;;;;;;;;;;;;;;OAgBG;YACW,yBAAyB;IAgCvC;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,aAAa;CAWtB"}
@@ -0,0 +1,171 @@
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 OperatorCheckpointerService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.OperatorCheckpointerService = exports.OPERATOR_DEFAULT_APPROVAL_TTL_DAYS = void 0;
14
+ const langgraph_1 = require("@langchain/langgraph");
15
+ const langgraph_checkpoint_redis_1 = require("@langchain/langgraph-checkpoint-redis");
16
+ const common_1 = require("@nestjs/common");
17
+ const config_1 = require("@nestjs/config");
18
+ const ioredis_1 = require("ioredis");
19
+ /** Default number of days an operator approval may stay pending. */
20
+ exports.OPERATOR_DEFAULT_APPROVAL_TTL_DAYS = 7;
21
+ /**
22
+ * Commands RedisSaver depends on that only exist when the RedisJSON and
23
+ * RediSearch modules are loaded (redis-stack / Redis 8+ where they are core).
24
+ */
25
+ const OPERATOR_REQUIRED_REDIS_COMMANDS = ["JSON.SET", "FT.CREATE"];
26
+ /**
27
+ * OperatorCheckpointerService - Durable checkpoint storage for the operator agent.
28
+ *
29
+ * Lazily constructs and caches a LangGraph checkpoint saver:
30
+ * - `RedisSaver` (from `@langchain/langgraph-checkpoint-redis`) when a Redis
31
+ * connection is configured, using the same `redis` config block the
32
+ * QueueModule reads from ConfigService.
33
+ * - `MemorySaver` fallback when no Redis config is present (tests).
34
+ *
35
+ * Checkpoints expire after `(operator.approvalTtlDays ?? 7) + 1` days, one day
36
+ * past the approval expiry so a pending approval never outlives its checkpoint.
37
+ */
38
+ let OperatorCheckpointerService = OperatorCheckpointerService_1 = class OperatorCheckpointerService {
39
+ constructor(configService) {
40
+ this.configService = configService;
41
+ this.logger = new common_1.Logger(OperatorCheckpointerService_1.name);
42
+ }
43
+ /** Lazily constructs and caches the saver; MemorySaver fallback when redis config is absent (tests). */
44
+ async getSaver() {
45
+ if (!this.saverPromise) {
46
+ this.saverPromise = this.createSaver();
47
+ // A rejected saver (e.g. Redis briefly down) must not be cached forever:
48
+ // clear the cache so the next getSaver() call retries the connection.
49
+ // Callers awaiting the current promise still observe the rejection.
50
+ this.saverPromise.catch(() => (this.saverPromise = undefined));
51
+ }
52
+ return this.saverPromise;
53
+ }
54
+ /** Closes the Redis connection on shutdown; never throws. */
55
+ async onModuleDestroy() {
56
+ if (!this.saverPromise) {
57
+ return;
58
+ }
59
+ try {
60
+ const saver = (await this.saverPromise);
61
+ if (typeof saver.end === "function") {
62
+ await saver.end();
63
+ }
64
+ }
65
+ catch (error) {
66
+ this.logger.warn(`Failed to close operator checkpointer on shutdown: ${error}`);
67
+ }
68
+ }
69
+ async createSaver() {
70
+ const redis = this.configService.get("redis");
71
+ if (!redis?.host) {
72
+ this.logger.warn("Operator checkpointer falling back to MemorySaver — checkpoints will not survive restarts. Configure redis.host for durable checkpoints.");
73
+ return new langgraph_1.MemorySaver();
74
+ }
75
+ const url = this.buildRedisUrl(redis);
76
+ // RedisSaver.fromUrl SUCCEEDS against a Redis without RedisJSON/RediSearch
77
+ // (its ensureIndexes only logs the FT.CREATE failure); the first checkpoint
78
+ // write then dies on JSON.SET and the rejection crashes the process. Probe
79
+ // the server BEFORE adopting RedisSaver so plain Redis degrades gracefully.
80
+ const missingCommands = await this.probeMissingRedisCommands(url);
81
+ if (missingCommands.length > 0) {
82
+ this.logger.error(`Operator checkpointer: Redis at ${redis.host}:${redis.port} lacks the RedisJSON/RediSearch modules required for durable checkpoints (missing commands: ${missingCommands.join(", ")}; Redis 8+ or redis-stack needed). Falling back to MemorySaver — pending approvals will NOT survive restarts.`);
83
+ return new langgraph_1.MemorySaver();
84
+ }
85
+ const operator = this.configService.get("operator");
86
+ const approvalTtlDays = operator?.approvalTtlDays ?? exports.OPERATOR_DEFAULT_APPROVAL_TTL_DAYS;
87
+ // RedisSaver's `defaultTTL` option is expressed in MINUTES (the saver
88
+ // multiplies by 60 internally), so (approvalTtlDays + 1) days in seconds
89
+ // equals (approvalTtlDays + 1) * 24 * 60 minutes here.
90
+ const defaultTTL = (approvalTtlDays + 1) * 24 * 60;
91
+ const saver = await langgraph_checkpoint_redis_1.RedisSaver.fromUrl(url, { defaultTTL });
92
+ this.attachSaverErrorHandler(saver);
93
+ return saver;
94
+ }
95
+ /**
96
+ * Probes the Redis server for the module commands RedisSaver depends on,
97
+ * using a short-lived ioredis client (already a dependency of this package —
98
+ * the node-redis `redis` package used by the saver is not resolvable from
99
+ * here under pnpm's strict isolation).
100
+ *
101
+ * `COMMAND INFO <name>` replies with a single-element array whose element is
102
+ * nil (`[null]`) when the command is unknown, and a populated array when it
103
+ * exists. It is preferred over `MODULE LIST` because on Redis 8+ the JSON
104
+ * and search commands are built into core (no module entry), while
105
+ * COMMAND INFO reports them uniformly on redis-stack, module-loaded Redis,
106
+ * and Redis 8+.
107
+ *
108
+ * Connection failures reject and propagate to the caller, exactly like a
109
+ * `RedisSaver.fromUrl` failure: getSaver() clears the cached promise so the
110
+ * next call retries.
111
+ */
112
+ async probeMissingRedisCommands(url) {
113
+ const probe = new ioredis_1.Redis(url, {
114
+ lazyConnect: true,
115
+ maxRetriesPerRequest: 1,
116
+ retryStrategy: () => null,
117
+ });
118
+ // ioredis clients emit "error" events; without a listener an emitted error
119
+ // crashes the process. Connection failures are still surfaced through the
120
+ // rejected connect()/call() promises — the listener only absorbs the
121
+ // duplicate event emission.
122
+ probe.on("error", () => undefined);
123
+ try {
124
+ await probe.connect();
125
+ const missing = [];
126
+ for (const command of OPERATOR_REQUIRED_REDIS_COMMANDS) {
127
+ const reply = await probe.call("COMMAND", "INFO", command);
128
+ const supported = Array.isArray(reply) && reply.length > 0 && reply[0] !== null && reply[0] !== undefined;
129
+ if (!supported) {
130
+ missing.push(command);
131
+ }
132
+ }
133
+ return missing;
134
+ }
135
+ finally {
136
+ // disconnect() closes immediately and never throws (quit() can hang or
137
+ // reject on an already-broken connection).
138
+ probe.disconnect();
139
+ }
140
+ }
141
+ /**
142
+ * RedisSaver.fromUrl creates its node-redis client without an "error"
143
+ * listener, so a socket error after startup would crash the process. The
144
+ * client is a TypeScript-private but runtime-reachable field; attach a
145
+ * logging handler when it is reachable, and degrade silently when a future
146
+ * library version hides it.
147
+ */
148
+ attachSaverErrorHandler(saver) {
149
+ const client = saver.client;
150
+ if (client && typeof client.on === "function") {
151
+ client.on("error", (error) => this.logger.error(`Operator checkpointer Redis client error: ${error}`));
152
+ }
153
+ else {
154
+ this.logger.warn("Operator checkpointer: could not attach an error handler to the RedisSaver client (internal client not reachable).");
155
+ }
156
+ }
157
+ buildRedisUrl(redis) {
158
+ const credentials = redis.username || redis.password
159
+ ? `${encodeURIComponent(redis.username ?? "")}:${encodeURIComponent(redis.password ?? "")}@`
160
+ : "";
161
+ // IPv6 hosts must be bracketed to form a valid URL (e.g. redis://[::1]:6379).
162
+ const host = redis.host.includes(":") ? `[${redis.host}]` : redis.host;
163
+ return `redis://${credentials}${host}:${redis.port}`;
164
+ }
165
+ };
166
+ exports.OperatorCheckpointerService = OperatorCheckpointerService;
167
+ exports.OperatorCheckpointerService = OperatorCheckpointerService = OperatorCheckpointerService_1 = __decorate([
168
+ (0, common_1.Injectable)(),
169
+ __metadata("design:paramtypes", [config_1.ConfigService])
170
+ ], OperatorCheckpointerService);
171
+ //# sourceMappingURL=operator.checkpointer.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.checkpointer.service.js","sourceRoot":"","sources":["../../../../src/agents/operator/services/operator.checkpointer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAAwE;AACxE,sFAAmE;AACnE,2CAAqE;AACrE,2CAA+C;AAC/C,qCAAgC;AAKhC,oEAAoE;AACvD,QAAA,kCAAkC,GAAG,CAAC,CAAC;AAEpD;;;GAGG;AACH,MAAM,gCAAgC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QACJ,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,KAA2B;QAC/C,MAAM,WAAW,GACf,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ;YAC9B,CAAC,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,GAAG;YAC5F,CAAC,CAAC,EAAE,CAAC;QAET,8EAA8E;QAC9E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAEvE,OAAO,WAAW,WAAW,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;IACvD,CAAC;CACF,CAAA;AAzJY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;qCAMiC,sBAAa;GAL9C,2BAA2B,CAyJvC"}
@@ -0,0 +1,81 @@
1
+ import { ConfigService } from "@nestjs/config";
2
+ import { MessageInterface } from "../../../common/interfaces/message.interface";
3
+ import { BaseConfigInterface } from "../../../config/interfaces";
4
+ import { LLMService } from "../../../core/llm/services/llm.service";
5
+ import type { ToolCallRecord } from "../../graph/tools/tool.factory";
6
+ import type { EntityReference } from "../../responder/interfaces/entity.reference.interface";
7
+ import { OperatorCitation } from "../contexts/operator.context";
8
+ import { OperatorToolRegistry } from "../tools/operator.tool.registry";
9
+ import { OperatorCheckpointerService } from "./operator.checkpointer.service";
10
+ export type OperatorRunResult = {
11
+ kind: "completed";
12
+ answer: string;
13
+ questions: string[];
14
+ references: EntityReference[];
15
+ citations: OperatorCitation[];
16
+ toolCalls: ToolCallRecord[];
17
+ tokens: {
18
+ input: number;
19
+ output: number;
20
+ };
21
+ } | {
22
+ kind: "pending_approval";
23
+ toolName: string;
24
+ toolArgs: Record<string, unknown>;
25
+ summary: string;
26
+ };
27
+ /**
28
+ * OperatorService - the operator agent graph (START → agent ⇄ tools → finalise → END).
29
+ *
30
+ * - `agent` node: exactly one model invocation with all tools bound (LLMService.callStep).
31
+ * - `tools` node: executes the tool calls of the last AI message. Destructive
32
+ * calls are processed FIRST and freeze the run via `interrupt()` until the
33
+ * user approves or denies — at most ONE destructive call per pass (extra
34
+ * destructive calls get a "not executed" ToolMessage and must be re-issued);
35
+ * read-only tool errors become `Tool error: ...` ToolMessages so the model
36
+ * self-corrects (never thrown).
37
+ * - `finalise` node: one structured LLMService.call() producing the final
38
+ * answer + suggested questions. References and citations are collected
39
+ * deterministically from the tool-call recorder, never from the LLM.
40
+ *
41
+ * The graph is compiled per turn (tools are per-request closures) with the
42
+ * shared checkpoint saver; `resume()` recompiles identically and resumes the
43
+ * frozen thread with `new Command({ resume: { approved } })`.
44
+ */
45
+ export declare class OperatorService {
46
+ private readonly llm;
47
+ private readonly toolRegistry;
48
+ private readonly checkpointer;
49
+ private readonly configService;
50
+ private readonly logger;
51
+ private readonly systemPrompt;
52
+ constructor(llm: LLMService, toolRegistry: OperatorToolRegistry, checkpointer: OperatorCheckpointerService, configService: ConfigService<BaseConfigInterface>);
53
+ run(params: {
54
+ companyId: string;
55
+ userId: string;
56
+ userModuleIds: string[];
57
+ contentId?: string;
58
+ contentType?: string;
59
+ messages: MessageInterface[];
60
+ question: string;
61
+ threadId: string;
62
+ }): Promise<OperatorRunResult>;
63
+ resume(params: {
64
+ threadId: string;
65
+ approved: boolean;
66
+ companyId: string;
67
+ userId: string;
68
+ userModuleIds: string[];
69
+ contentId?: string;
70
+ contentType?: string;
71
+ messages?: MessageInterface[];
72
+ }): Promise<OperatorRunResult>;
73
+ private compileGraph;
74
+ /** Entity references derived deterministically from the tool-call recorder (never from the LLM). */
75
+ private collectReferences;
76
+ /** Chunk citations recorded by retrieval tool wrappers into the recorder. */
77
+ private collectCitations;
78
+ private buildInitialMessages;
79
+ private mapResult;
80
+ }
81
+ //# sourceMappingURL=operator.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/services/operator.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAyC,MAAM,8BAA8B,CAAC;AAOvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAmB9E,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,eAAe;IAKxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OA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