@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,341 @@
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 OperatorService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.OperatorService = void 0;
14
+ const messages_1 = require("@langchain/core/messages");
15
+ const langgraph_1 = require("@langchain/langgraph");
16
+ const common_1 = require("@nestjs/common");
17
+ const config_1 = require("@nestjs/config");
18
+ const zod_1 = require("zod");
19
+ const agentmessage_type_1 = require("../../../common/enums/agentmessage.type");
20
+ const llm_service_1 = require("../../../core/llm/services/llm.service");
21
+ const operator_context_1 = require("../contexts/operator.context");
22
+ const operator_system_prompt_1 = require("../prompts/operator.system.prompt");
23
+ const operator_tool_registry_1 = require("../tools/operator.tool.registry");
24
+ const operator_checkpointer_service_1 = require("./operator.checkpointer.service");
25
+ /** Max agent⇄tools iterations before the run is forced to finalise. */
26
+ const MAX_TOOL_ITERATIONS = 15;
27
+ /** Graph recursion limit sized for ~15 tool iterations (agent + tools per iteration). */
28
+ const RECURSION_LIMIT = 40;
29
+ const finalAnswerSchema = zod_1.z.object({
30
+ answer: zod_1.z.string(),
31
+ questions: zod_1.z.array(zod_1.z.string()),
32
+ });
33
+ /**
34
+ * OperatorService - the operator agent graph (START → agent ⇄ tools → finalise → END).
35
+ *
36
+ * - `agent` node: exactly one model invocation with all tools bound (LLMService.callStep).
37
+ * - `tools` node: executes the tool calls of the last AI message. Destructive
38
+ * calls are processed FIRST and freeze the run via `interrupt()` until the
39
+ * user approves or denies — at most ONE destructive call per pass (extra
40
+ * destructive calls get a "not executed" ToolMessage and must be re-issued);
41
+ * read-only tool errors become `Tool error: ...` ToolMessages so the model
42
+ * self-corrects (never thrown).
43
+ * - `finalise` node: one structured LLMService.call() producing the final
44
+ * answer + suggested questions. References and citations are collected
45
+ * deterministically from the tool-call recorder, never from the LLM.
46
+ *
47
+ * The graph is compiled per turn (tools are per-request closures) with the
48
+ * shared checkpoint saver; `resume()` recompiles identically and resumes the
49
+ * frozen thread with `new Command({ resume: { approved } })`.
50
+ */
51
+ let OperatorService = OperatorService_1 = class OperatorService {
52
+ constructor(llm, toolRegistry, checkpointer, configService) {
53
+ this.llm = llm;
54
+ this.toolRegistry = toolRegistry;
55
+ this.checkpointer = checkpointer;
56
+ this.configService = configService;
57
+ this.logger = new common_1.Logger(OperatorService_1.name);
58
+ const prompts = this.configService.get("prompts");
59
+ this.systemPrompt = prompts?.operator ?? operator_system_prompt_1.defaultOperatorSystemPrompt;
60
+ }
61
+ async run(params) {
62
+ const app = await this.compileGraph({
63
+ companyId: params.companyId,
64
+ userId: params.userId,
65
+ userModuleIds: params.userModuleIds,
66
+ contentId: params.contentId,
67
+ contentType: params.contentType,
68
+ dataLimits: {},
69
+ messages: params.messages,
70
+ });
71
+ const initialState = {
72
+ messages: this.buildInitialMessages(params.messages, params.question),
73
+ companyId: params.companyId,
74
+ userId: params.userId,
75
+ userModuleIds: params.userModuleIds,
76
+ contentId: params.contentId ?? null,
77
+ contentType: params.contentType ?? null,
78
+ question: params.question,
79
+ };
80
+ const finalState = (await app.invoke(initialState, {
81
+ configurable: { thread_id: params.threadId },
82
+ recursionLimit: RECURSION_LIMIT,
83
+ }));
84
+ return this.mapResult(finalState);
85
+ }
86
+ async resume(params) {
87
+ const app = await this.compileGraph({
88
+ companyId: params.companyId,
89
+ userId: params.userId,
90
+ userModuleIds: params.userModuleIds,
91
+ contentId: params.contentId,
92
+ contentType: params.contentType,
93
+ dataLimits: {},
94
+ messages: params.messages ?? [],
95
+ });
96
+ const finalState = (await app.invoke(new langgraph_1.Command({ resume: { approved: params.approved } }), {
97
+ configurable: { thread_id: params.threadId },
98
+ recursionLimit: RECURSION_LIMIT,
99
+ }));
100
+ return this.mapResult(finalState);
101
+ }
102
+ async compileGraph(ctx) {
103
+ const saver = await this.checkpointer.getSaver();
104
+ // Per-compile recorder: tool wrappers (registry-built closures) push
105
+ // ToolCallRecords here. It accumulates for the lifetime of the compiled
106
+ // graph — tools enforce cross-call contracts (e.g. describe-before-read)
107
+ // by inspecting it, so the tools node must NEVER drain it; it only copies
108
+ // the records new to each pass into checkpointed state. The array identity
109
+ // is shared with the tool closures: push into it, never reassign it.
110
+ const recorder = [];
111
+ const definitions = this.toolRegistry.build(ctx, recorder);
112
+ const toolMap = new Map(definitions.map((d) => [d.tool.name, d]));
113
+ const tools = definitions.map((d) => d.tool);
114
+ const workflow = new langgraph_1.StateGraph(operator_context_1.OperatorContext)
115
+ .addNode("agent", async (state) => {
116
+ const response = await this.llm.callStep({
117
+ systemPrompts: [this.systemPrompt],
118
+ messages: state.messages,
119
+ tools,
120
+ // Deterministic tool-following: at the config-default temperature the
121
+ // model intermittently relays recoverable tool errors to the user
122
+ // instead of retrying (observed live with gemini-2.5-flash-lite).
123
+ temperature: 0,
124
+ metadata: { agent: "operator", node: "agent", companyId: state.companyId },
125
+ });
126
+ return {
127
+ messages: [response.message],
128
+ iterations: state.iterations + 1,
129
+ tokens: response.tokenUsage,
130
+ };
131
+ })
132
+ .addNode("tools", async (state) => {
133
+ // Read the calls from the last AI message in checkpointed state so the
134
+ // node is deterministic on replay after an interrupt.
135
+ const last = state.messages[state.messages.length - 1];
136
+ const calls = last?.tool_calls ?? [];
137
+ const isDestructive = (name) => toolMap.get(name)?.destructive === true;
138
+ // Prime the recorder from checkpointed state. `resume()` recompiles the
139
+ // graph with a fresh (empty) recorder, but state.toolCalls is the
140
+ // durable superset of everything recorded so far — restoring the
141
+ // missing records keeps cross-pass tool contracts (describe-before-read)
142
+ // satisfied after an approval round-trip. Idempotent on node replays.
143
+ if (recorder.length < state.toolCalls.length) {
144
+ recorder.push(...state.toolCalls.slice(recorder.length));
145
+ }
146
+ // Everything pushed beyond this index during this pass is new and is
147
+ // what gets emitted into state (the toolCalls reducer concats).
148
+ const startIdx = recorder.length;
149
+ // Ordering rule: destructive calls are processed BEFORE read-only
150
+ // siblings, so no sibling effects are duplicated by node replay.
151
+ // Exactly-once rule: at most ONE destructive call is interrupted and
152
+ // executed per tools-node pass. LangGraph replays the whole node on
153
+ // every resume — a second `interrupt()` after a side effect would
154
+ // re-run that side effect on the next resume. Every destructive call
155
+ // after the first gets a "not executed" ToolMessage so the model can
156
+ // re-issue it on the next agent iteration.
157
+ const ordered = [...calls.filter((c) => isDestructive(c.name)), ...calls.filter((c) => !isDestructive(c.name))];
158
+ const toolMessages = [];
159
+ let destructiveHandled = false;
160
+ for (const [index, call] of ordered.entries()) {
161
+ const callId = call.id ?? `call_${index}`;
162
+ const definition = toolMap.get(call.name);
163
+ if (!definition) {
164
+ toolMessages.push(new messages_1.ToolMessage({ content: `Tool error: unknown tool "${call.name}".`, tool_call_id: callId }));
165
+ continue;
166
+ }
167
+ if (definition.destructive) {
168
+ if (destructiveHandled) {
169
+ toolMessages.push(new messages_1.ToolMessage({
170
+ content: "Not executed — one action per step. Re-issue this action after the current one resolves.",
171
+ tool_call_id: callId,
172
+ }));
173
+ continue;
174
+ }
175
+ destructiveHandled = true;
176
+ const payload = {
177
+ toolName: call.name,
178
+ toolArgs: (call.args ?? {}),
179
+ summary: definition.summarise?.(call.args ?? {}) ?? `${call.name}(${JSON.stringify(call.args ?? {})})`,
180
+ };
181
+ const decision = (0, langgraph_1.interrupt)(payload);
182
+ if (!decision?.approved) {
183
+ toolMessages.push(new messages_1.ToolMessage({ content: "Action denied by the user.", tool_call_id: callId }));
184
+ continue;
185
+ }
186
+ }
187
+ try {
188
+ const result = await definition.tool.invoke(call.args ?? {});
189
+ toolMessages.push(new messages_1.ToolMessage({
190
+ content: typeof result === "string" ? result : JSON.stringify(result),
191
+ tool_call_id: callId,
192
+ }));
193
+ }
194
+ catch (err) {
195
+ const message = err instanceof Error ? err.message : String(err);
196
+ this.logger.warn(`operator tool "${call.name}" failed: ${message}`);
197
+ toolMessages.push(new messages_1.ToolMessage({ content: `Tool error: ${message}`, tool_call_id: callId }));
198
+ }
199
+ }
200
+ // Only the records new to this pass go into state; re-deriving over
201
+ // primed records would duplicate toolCalls/references/citations
202
+ // because the state reducers concat.
203
+ const newRecords = recorder.slice(startIdx);
204
+ return {
205
+ messages: toolMessages,
206
+ toolCalls: newRecords,
207
+ references: this.collectReferences(newRecords),
208
+ citations: this.collectCitations(newRecords),
209
+ };
210
+ })
211
+ .addNode("finalise", async (state) => {
212
+ const transcript = state.messages
213
+ .map((m) => {
214
+ const content = typeof m.content === "string" ? m.content : JSON.stringify(m.content);
215
+ // AIMessages that only carry tool_calls stringify empty; surface the
216
+ // requested calls so cap-terminated runs expose the unfinished intent.
217
+ const toolCalls = m.tool_calls;
218
+ const requested = Array.isArray(toolCalls) && toolCalls.length > 0
219
+ ? `${content ? " " : ""}[requested tools: ${toolCalls
220
+ .map((c) => `${c.name}(${JSON.stringify(c.args ?? {})})`)
221
+ .join(", ")}]`
222
+ : "";
223
+ return `${m.getType()}: ${content}${requested}`;
224
+ })
225
+ .join("\n");
226
+ const result = await this.llm.call({
227
+ inputParams: { question: state.question, conversation: transcript },
228
+ outputSchema: finalAnswerSchema,
229
+ systemPrompts: [this.systemPrompt],
230
+ // LLMService.call() renders inputParams ONLY through {placeholder}
231
+ // substitution in this template — params without a matching
232
+ // placeholder are silently dropped and the model never sees them.
233
+ instructions: "The user asked:\n{question}\n\n" +
234
+ "This is the full conversation of the operator run that just finished (model turns, tool calls and tool results):\n\n{conversation}\n\n" +
235
+ "Produce the final reply: `answer` is the message for the user (built only from facts in the conversation above), `questions` is up to three short follow-up questions the user might ask next. " +
236
+ "If the conversation contains no tool results that answer the question, `answer` must say plainly that the information could not be found — do not guess and do not invent records. " +
237
+ "Never state that an action was performed (created, updated, deleted, executed) unless a tool result in the conversation confirms that exact action.",
238
+ metadata: { agent: "operator", node: "finalise", companyId: state.companyId },
239
+ });
240
+ return {
241
+ finalAnswer: { answer: result.answer ?? "", questions: result.questions ?? [] },
242
+ tokens: result.tokenUsage,
243
+ };
244
+ })
245
+ .addEdge(langgraph_1.START, "agent")
246
+ .addConditionalEdges("agent", (state) => {
247
+ const last = state.messages[state.messages.length - 1];
248
+ const hasToolCalls = Array.isArray(last?.tool_calls) && last.tool_calls.length > 0;
249
+ return hasToolCalls && state.iterations < MAX_TOOL_ITERATIONS ? "tools" : "finalise";
250
+ }, ["tools", "finalise"])
251
+ .addEdge("tools", "agent")
252
+ .addEdge("finalise", langgraph_1.END);
253
+ return workflow.compile({ checkpointer: saver });
254
+ }
255
+ /** Entity references derived deterministically from the tool-call recorder (never from the LLM). */
256
+ collectReferences(records) {
257
+ const references = [];
258
+ const seen = new Set();
259
+ const push = (type, id, reason) => {
260
+ if (typeof type !== "string" || typeof id !== "string" || !type || !id)
261
+ return;
262
+ const key = `${type}:${id}`;
263
+ if (seen.has(key))
264
+ return;
265
+ seen.add(key);
266
+ references.push({ type, id, relevance: 100, reason });
267
+ };
268
+ for (const record of records) {
269
+ if (record.error)
270
+ continue;
271
+ if (record.tool === "read_entity") {
272
+ push(record.input.type, record.input.id, "record read during the operator run");
273
+ }
274
+ else if (record.tool === "traverse") {
275
+ push(record.input.fromType, record.input.fromId, "record traversed during the operator run");
276
+ }
277
+ }
278
+ return references;
279
+ }
280
+ /** Chunk citations recorded by retrieval tool wrappers into the recorder. */
281
+ collectCitations(records) {
282
+ const citations = [];
283
+ for (const record of records) {
284
+ for (const citation of record.citations ?? []) {
285
+ citations.push({
286
+ chunkId: citation.chunkId,
287
+ relevance: citation.relevance,
288
+ reason: `retrieved by ${record.tool}`,
289
+ });
290
+ }
291
+ }
292
+ return citations;
293
+ }
294
+ buildInitialMessages(messages, question) {
295
+ const converted = messages.map((m) => {
296
+ switch (m.type) {
297
+ case agentmessage_type_1.AgentMessageType.System:
298
+ return new messages_1.SystemMessage(m.content);
299
+ case agentmessage_type_1.AgentMessageType.Assistant:
300
+ return new messages_1.AIMessage(m.content);
301
+ default:
302
+ return new messages_1.HumanMessage(m.content);
303
+ }
304
+ });
305
+ const last = converted[converted.length - 1];
306
+ if (!last || last.getType() !== "human" || last.content !== question) {
307
+ converted.push(new messages_1.HumanMessage(question));
308
+ }
309
+ return converted;
310
+ }
311
+ mapResult(finalState) {
312
+ const interrupts = finalState.__interrupt__;
313
+ if (interrupts && interrupts.length > 0) {
314
+ const payload = interrupts[0]?.value ?? {};
315
+ return {
316
+ kind: "pending_approval",
317
+ toolName: payload.toolName ?? "",
318
+ toolArgs: payload.toolArgs ?? {},
319
+ summary: payload.summary ?? "",
320
+ };
321
+ }
322
+ return {
323
+ kind: "completed",
324
+ answer: finalState.finalAnswer?.answer ?? "",
325
+ questions: finalState.finalAnswer?.questions ?? [],
326
+ references: finalState.references ?? [],
327
+ citations: finalState.citations ?? [],
328
+ toolCalls: finalState.toolCalls ?? [],
329
+ tokens: finalState.tokens ?? { input: 0, output: 0 },
330
+ };
331
+ }
332
+ };
333
+ exports.OperatorService = OperatorService;
334
+ exports.OperatorService = OperatorService = OperatorService_1 = __decorate([
335
+ (0, common_1.Injectable)(),
336
+ __metadata("design:paramtypes", [llm_service_1.LLMService,
337
+ operator_tool_registry_1.OperatorToolRegistry,
338
+ operator_checkpointer_service_1.OperatorCheckpointerService,
339
+ config_1.ConfigService])
340
+ ], OperatorService);
341
+ //# sourceMappingURL=operator.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.service.js","sourceRoot":"","sources":["../../../../src/agents/operator/services/operator.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uDAA4G;AAC5G,oDAAuG;AACvG,2CAAoD;AACpD,2CAA+C;AAC/C,6BAAwB;AACxB,+EAA2E;AAG3E,wEAAoE;AAGpE,mEAAuG;AAMvG,8EAAgF;AAChF,4EAAuE;AACvE,mFAA8E;AAE9E,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,yFAAyF;AACzF,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;CAC/B,CAAC,CAAC;AAqBH;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,eAAe,uBAArB,MAAM,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AAC,SAAS,IAAI,EAAE;YACrC,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,EAAE;YACrC,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;SACrD,CAAC;IACJ,CAAC;CACF,CAAA;AAlVY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAMa,wBAAU;QACD,6CAAoB;QACpB,2DAA2B;QAC1B,sBAAa;GARpC,eAAe,CAkV3B"}
@@ -0,0 +1,12 @@
1
+ import { ToolCallRecord, ToolFactory } from "../../graph/tools/tool.factory";
2
+ import { OperatorToolDefinition } from "../interfaces/operator.tool.interface";
3
+ /**
4
+ * Test-only destructive tool: echoes its note as "executed". Used to exercise
5
+ * the approval-gate flow end to end. Registered only when NODE_ENV !== "production".
6
+ */
7
+ export declare class OperatorTestActionTool {
8
+ private readonly factory;
9
+ constructor(factory: ToolFactory);
10
+ buildDefinition(recorder: ToolCallRecord[]): OperatorToolDefinition;
11
+ }
12
+ //# sourceMappingURL=operator-test-action.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator-test-action.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/tools/operator-test-action.tool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAM/E;;;GAGG;AACH,qBACa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW;IAEjD,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,sBAAsB;CAkBpE"}
@@ -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.OperatorTestActionTool = void 0;
13
+ const tools_1 = require("@langchain/core/tools");
14
+ const common_1 = require("@nestjs/common");
15
+ const zod_1 = require("zod");
16
+ const tool_factory_1 = require("../../graph/tools/tool.factory");
17
+ const inputSchema = zod_1.z.object({
18
+ note: zod_1.z.string().describe("A short note describing the test action to execute."),
19
+ });
20
+ /**
21
+ * Test-only destructive tool: echoes its note as "executed". Used to exercise
22
+ * the approval-gate flow end to end. Registered only when NODE_ENV !== "production".
23
+ */
24
+ let OperatorTestActionTool = class OperatorTestActionTool {
25
+ constructor(factory) {
26
+ this.factory = factory;
27
+ }
28
+ buildDefinition(recorder) {
29
+ return {
30
+ tool: new tools_1.DynamicStructuredTool({
31
+ name: "operator_test_action",
32
+ description: "Execute a test action (development/test environments only). This action requires user approval before it runs.",
33
+ schema: inputSchema,
34
+ func: async (input) => this.factory.capture({ tool: "operator_test_action", input }, async () => `Executed test action: ${input.note}`, recorder),
35
+ }),
36
+ destructive: true,
37
+ summarise: (args) => `Run test action: ${args.note}`,
38
+ };
39
+ }
40
+ };
41
+ exports.OperatorTestActionTool = OperatorTestActionTool;
42
+ exports.OperatorTestActionTool = OperatorTestActionTool = __decorate([
43
+ (0, common_1.Injectable)(),
44
+ __metadata("design:paramtypes", [tool_factory_1.ToolFactory])
45
+ ], OperatorTestActionTool);
46
+ //# sourceMappingURL=operator-test-action.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator-test-action.tool.js","sourceRoot":"","sources":["../../../../src/agents/operator/tools/operator-test-action.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA8D;AAC9D,2CAA4C;AAC5C,6BAAwB;AACxB,iEAA6E;AAG7E,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;CACjF,CAAC,CAAC;AAEH;;;GAGG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;IAErD,eAAe,CAAC,QAA0B;QACxC,OAAO;YACL,IAAI,EAAE,IAAI,6BAAqB,CAAC;gBAC9B,IAAI,EAAE,sBAAsB;gBAC5B,WAAW,EACT,gHAAgH;gBAClH,MAAM,EAAE,WAAW;gBACnB,IAAI,EAAE,KAAK,EAAE,KAAkC,EAAE,EAAE,CACjD,IAAI,CAAC,OAAO,CAAC,OAAO,CAClB,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,EACvC,KAAK,IAAI,EAAE,CAAC,yBAAyB,KAAK,CAAC,IAAI,EAAE,EACjD,QAAQ,CACT;aACJ,CAAC;YACF,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,CAAC,IAA6B,EAAE,EAAE,CAAC,oBAAoB,IAAI,CAAC,IAAI,EAAE;SAC9E,CAAC;IACJ,CAAC;CACF,CAAA;AArBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAE2B,0BAAW;GADtC,sBAAsB,CAqBlC"}
@@ -0,0 +1,32 @@
1
+ import { DescribeEntityTool } from "../../graph/tools/describe-entity.tool";
2
+ import { ReadEntityTool } from "../../graph/tools/read-entity.tool";
3
+ import { ResolveEntityTool } from "../../graph/tools/resolve-entity.tool";
4
+ import { SearchEntitiesTool } from "../../graph/tools/search-entities.tool";
5
+ import { ToolCallRecord } from "../../graph/tools/tool.factory";
6
+ import { TraverseTool } from "../../graph/tools/traverse.tool";
7
+ import { OperatorRetrievalContext, OperatorToolContribution, OperatorToolDefinition } from "../interfaces/operator.tool.interface";
8
+ import { OperatorTestActionTool } from "./operator-test-action.tool";
9
+ import { SearchCommunitiesTool } from "./search-communities.tool";
10
+ import { SearchDocumentsTool } from "./search-documents.tool";
11
+ /**
12
+ * Composes the operator's tool set for a single turn:
13
+ * - the five graph tools (read-only, built per request with ctx + recorder)
14
+ * - the two retrieval tools (search_documents, search_communities)
15
+ * - the test-only destructive tool (non-production environments only)
16
+ * - any app-contributed factories registered under the OPERATOR_TOOLS token,
17
+ * built per turn with the same ctx + recorder as the built-ins
18
+ */
19
+ export declare class OperatorToolRegistry {
20
+ private readonly resolveEntityTool;
21
+ private readonly describeEntityTool;
22
+ private readonly searchEntitiesTool;
23
+ private readonly readEntityTool;
24
+ private readonly traverseTool;
25
+ private readonly searchDocumentsTool;
26
+ private readonly searchCommunitiesTool;
27
+ private readonly operatorTestActionTool;
28
+ private readonly contributed?;
29
+ constructor(resolveEntityTool: ResolveEntityTool, describeEntityTool: DescribeEntityTool, searchEntitiesTool: SearchEntitiesTool, readEntityTool: ReadEntityTool, traverseTool: TraverseTool, searchDocumentsTool: SearchDocumentsTool, searchCommunitiesTool: SearchCommunitiesTool, operatorTestActionTool: OperatorTestActionTool, contributed?: OperatorToolContribution[]);
30
+ build(ctx: OperatorRetrievalContext, recorder: ToolCallRecord[]): OperatorToolDefinition[];
31
+ }
32
+ //# sourceMappingURL=operator.tool.registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.tool.registry.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/tools/operator.tool.registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO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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.OperatorToolRegistry = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const describe_entity_tool_1 = require("../../graph/tools/describe-entity.tool");
18
+ const read_entity_tool_1 = require("../../graph/tools/read-entity.tool");
19
+ const resolve_entity_tool_1 = require("../../graph/tools/resolve-entity.tool");
20
+ const search_entities_tool_1 = require("../../graph/tools/search-entities.tool");
21
+ const traverse_tool_1 = require("../../graph/tools/traverse.tool");
22
+ const operator_tool_interface_1 = require("../interfaces/operator.tool.interface");
23
+ const operator_test_action_tool_1 = require("./operator-test-action.tool");
24
+ const search_communities_tool_1 = require("./search-communities.tool");
25
+ const search_documents_tool_1 = require("./search-documents.tool");
26
+ /**
27
+ * Composes the operator's tool set for a single turn:
28
+ * - the five graph tools (read-only, built per request with ctx + recorder)
29
+ * - the two retrieval tools (search_documents, search_communities)
30
+ * - the test-only destructive tool (non-production environments only)
31
+ * - any app-contributed factories registered under the OPERATOR_TOOLS token,
32
+ * built per turn with the same ctx + recorder as the built-ins
33
+ */
34
+ let OperatorToolRegistry = class OperatorToolRegistry {
35
+ constructor(resolveEntityTool, describeEntityTool, searchEntitiesTool, readEntityTool, traverseTool, searchDocumentsTool, searchCommunitiesTool, operatorTestActionTool, contributed) {
36
+ this.resolveEntityTool = resolveEntityTool;
37
+ this.describeEntityTool = describeEntityTool;
38
+ this.searchEntitiesTool = searchEntitiesTool;
39
+ this.readEntityTool = readEntityTool;
40
+ this.traverseTool = traverseTool;
41
+ this.searchDocumentsTool = searchDocumentsTool;
42
+ this.searchCommunitiesTool = searchCommunitiesTool;
43
+ this.operatorTestActionTool = operatorTestActionTool;
44
+ this.contributed = contributed;
45
+ }
46
+ build(ctx, recorder) {
47
+ const userCtx = {
48
+ companyId: ctx.companyId,
49
+ userId: ctx.userId,
50
+ userModuleIds: ctx.userModuleIds,
51
+ };
52
+ const definitions = [
53
+ { tool: this.resolveEntityTool.build(userCtx, recorder), destructive: false },
54
+ { tool: this.describeEntityTool.build(userCtx, recorder), destructive: false },
55
+ { tool: this.searchEntitiesTool.build(userCtx, recorder), destructive: false },
56
+ { tool: this.readEntityTool.build(userCtx, recorder), destructive: false },
57
+ { tool: this.traverseTool.build(userCtx, recorder), destructive: false },
58
+ { tool: this.searchDocumentsTool.build(ctx, recorder), destructive: false },
59
+ { tool: this.searchCommunitiesTool.build(recorder), destructive: false },
60
+ ];
61
+ if (process.env.NODE_ENV !== "production") {
62
+ definitions.push(this.operatorTestActionTool.buildDefinition(recorder));
63
+ }
64
+ // Contributions are factories: build them per turn so they receive the
65
+ // request context (company scoping) and the shared tool-call recorder.
66
+ const all = [...definitions, ...(this.contributed ?? []).map((contribution) => contribution.build(ctx, recorder))];
67
+ // Guard against name collisions: a contributed tool named like a built-in
68
+ // would silently shadow it in the service's toolMap while both get bound to the model.
69
+ const seen = new Set();
70
+ for (const definition of all) {
71
+ const name = definition.tool.name;
72
+ if (seen.has(name)) {
73
+ throw new Error(`OperatorToolRegistry: duplicate tool name "${name}". ` +
74
+ `A contributed OPERATOR_TOOLS contribution must not reuse the name of a built-in or another contributed tool.`);
75
+ }
76
+ seen.add(name);
77
+ }
78
+ return all;
79
+ }
80
+ };
81
+ exports.OperatorToolRegistry = OperatorToolRegistry;
82
+ exports.OperatorToolRegistry = OperatorToolRegistry = __decorate([
83
+ (0, common_1.Injectable)(),
84
+ __param(8, (0, common_1.Optional)()),
85
+ __param(8, (0, common_1.Inject)(operator_tool_interface_1.OPERATOR_TOOLS)),
86
+ __metadata("design:paramtypes", [resolve_entity_tool_1.ResolveEntityTool,
87
+ describe_entity_tool_1.DescribeEntityTool,
88
+ search_entities_tool_1.SearchEntitiesTool,
89
+ read_entity_tool_1.ReadEntityTool,
90
+ traverse_tool_1.TraverseTool,
91
+ search_documents_tool_1.SearchDocumentsTool,
92
+ search_communities_tool_1.SearchCommunitiesTool,
93
+ operator_test_action_tool_1.OperatorTestActionTool, Array])
94
+ ], OperatorToolRegistry);
95
+ //# sourceMappingURL=operator.tool.registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.tool.registry.js","sourceRoot":"","sources":["../../../../src/agents/operator/tools/operator.tool.registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,iFAA4E;AAC5E,yEAAoE;AACpE,+EAA0E;AAC1E,iFAA4E;AAE5E,mEAA+D;AAC/D,mFAK+C;AAC/C,2EAAqE;AACrE,uEAAkE;AAClE,mEAA8D;AAE9D;;;;;;;GAOG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YACmB,iBAAoC,EACpC,kBAAsC,EACtC,kBAAsC,EACtC,cAA8B,EAC9B,YAA0B,EAC1B,mBAAwC,EACxC,qBAA4C,EAC5C,sBAA8C,EACV,WAAwC;QAR5E,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,wBAAmB,GAAnB,mBAAmB,CAAqB;QAC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WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1E,CAAC;QAED,uEAAuE;QACvE,uEAAuE;QACvE,MAAM,GAAG,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEnH,0EAA0E;QAC1E,uFAAuF;QACvF,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,KAAK,MAAM,UAAU,IAAI,GAAG,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CACb,8CAA8C,IAAI,KAAK;oBACrD,8GAA8G,CACjH,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAtDY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAWR,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,wCAAc,CAAC,CAAA;qCARC,uCAAiB;QAChB,yCAAkB;QAClB,yCAAkB;QACtB,iCAAc;QAChB,4BAAY;QACL,2CAAmB;QACjB,+CAAqB;QACpB,kDAAsB;GATtD,oBAAoB,CAsDhC"}
@@ -0,0 +1,16 @@
1
+ import { DynamicStructuredTool } from "@langchain/core/tools";
2
+ import { z } from "zod";
3
+ import { DriftSearchService } from "../../drift/services/drift.search.service";
4
+ import { ToolCallRecord, ToolFactory } from "../../graph/tools/tool.factory";
5
+ declare const inputSchema: z.ZodObject<{
6
+ question: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export declare class SearchCommunitiesTool {
9
+ private readonly factory;
10
+ private readonly driftSearchService;
11
+ constructor(factory: ToolFactory, driftSearchService: DriftSearchService);
12
+ build(recorder: ToolCallRecord[]): DynamicStructuredTool;
13
+ invoke(input: z.infer<typeof inputSchema>, recorder: ToolCallRecord[]): Promise<string>;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=search-communities.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-communities.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/operator/tools/search-communities.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7E,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAMH,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBADlB,OAAO,EAAE,WAAW,EACpB,kBAAkB,EAAE,kBAAkB;IAGzD,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,qBAAqB;IAUlD,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAW9F"}