@selentar/analitoly 0.1.1

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 (186) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -0
  3. package/api/dist/dashboards/dash_1775220041958_v1r8io.json +829 -0
  4. package/api/dist/dashboards/dash_1775222037264_1rrsrd.json +309 -0
  5. package/api/dist/src/agent/agent.controller.d.ts +26 -0
  6. package/api/dist/src/agent/agent.controller.js +124 -0
  7. package/api/dist/src/agent/agent.controller.js.map +1 -0
  8. package/api/dist/src/agent/agent.module.d.ts +2 -0
  9. package/api/dist/src/agent/agent.module.js +23 -0
  10. package/api/dist/src/agent/agent.module.js.map +1 -0
  11. package/api/dist/src/agent/agent.service.d.ts +39 -0
  12. package/api/dist/src/agent/agent.service.js +389 -0
  13. package/api/dist/src/agent/agent.service.js.map +1 -0
  14. package/api/dist/src/agent/mcp-config.d.ts +9 -0
  15. package/api/dist/src/agent/mcp-config.js +51 -0
  16. package/api/dist/src/agent/mcp-config.js.map +1 -0
  17. package/api/dist/src/app.module.d.ts +2 -0
  18. package/api/dist/src/app.module.js +52 -0
  19. package/api/dist/src/app.module.js.map +1 -0
  20. package/api/dist/src/chart/chart.controller.d.ts +8 -0
  21. package/api/dist/src/chart/chart.controller.js +38 -0
  22. package/api/dist/src/chart/chart.controller.js.map +1 -0
  23. package/api/dist/src/chart/chart.module.d.ts +2 -0
  24. package/api/dist/src/chart/chart.module.js +24 -0
  25. package/api/dist/src/chart/chart.module.js.map +1 -0
  26. package/api/dist/src/chart/chart.service.d.ts +32 -0
  27. package/api/dist/src/chart/chart.service.js +106 -0
  28. package/api/dist/src/chart/chart.service.js.map +1 -0
  29. package/api/dist/src/chat/chat.controller.d.ts +14 -0
  30. package/api/dist/src/chat/chat.controller.js +73 -0
  31. package/api/dist/src/chat/chat.controller.js.map +1 -0
  32. package/api/dist/src/chat/chat.module.d.ts +2 -0
  33. package/api/dist/src/chat/chat.module.js +22 -0
  34. package/api/dist/src/chat/chat.module.js.map +1 -0
  35. package/api/dist/src/chat/chat.service.d.ts +25 -0
  36. package/api/dist/src/chat/chat.service.js +168 -0
  37. package/api/dist/src/chat/chat.service.js.map +1 -0
  38. package/api/dist/src/connection/connection.controller.d.ts +46 -0
  39. package/api/dist/src/connection/connection.controller.js +189 -0
  40. package/api/dist/src/connection/connection.controller.js.map +1 -0
  41. package/api/dist/src/connection/connection.model.d.ts +116 -0
  42. package/api/dist/src/connection/connection.model.js +23 -0
  43. package/api/dist/src/connection/connection.model.js.map +1 -0
  44. package/api/dist/src/connection/connection.module.d.ts +2 -0
  45. package/api/dist/src/connection/connection.module.js +31 -0
  46. package/api/dist/src/connection/connection.module.js.map +1 -0
  47. package/api/dist/src/connection/connection.repository.d.ts +16 -0
  48. package/api/dist/src/connection/connection.repository.js +195 -0
  49. package/api/dist/src/connection/connection.repository.js.map +1 -0
  50. package/api/dist/src/connection/connection.service.d.ts +50 -0
  51. package/api/dist/src/connection/connection.service.js +343 -0
  52. package/api/dist/src/connection/connection.service.js.map +1 -0
  53. package/api/dist/src/context/context.controller.d.ts +13 -0
  54. package/api/dist/src/context/context.controller.js +86 -0
  55. package/api/dist/src/context/context.controller.js.map +1 -0
  56. package/api/dist/src/context/context.module.d.ts +2 -0
  57. package/api/dist/src/context/context.module.js +39 -0
  58. package/api/dist/src/context/context.module.js.map +1 -0
  59. package/api/dist/src/context/context.service.d.ts +32 -0
  60. package/api/dist/src/context/context.service.js +177 -0
  61. package/api/dist/src/context/context.service.js.map +1 -0
  62. package/api/dist/src/dashboard/dashboard.controller.d.ts +21 -0
  63. package/api/dist/src/dashboard/dashboard.controller.js +109 -0
  64. package/api/dist/src/dashboard/dashboard.controller.js.map +1 -0
  65. package/api/dist/src/dashboard/dashboard.model.d.ts +15 -0
  66. package/api/dist/src/dashboard/dashboard.model.js +3 -0
  67. package/api/dist/src/dashboard/dashboard.model.js.map +1 -0
  68. package/api/dist/src/dashboard/dashboard.module.d.ts +2 -0
  69. package/api/dist/src/dashboard/dashboard.module.js +24 -0
  70. package/api/dist/src/dashboard/dashboard.module.js.map +1 -0
  71. package/api/dist/src/dashboard/dashboard.repository.d.ts +9 -0
  72. package/api/dist/src/dashboard/dashboard.repository.js +72 -0
  73. package/api/dist/src/dashboard/dashboard.repository.js.map +1 -0
  74. package/api/dist/src/dashboard/dashboard.service.d.ts +14 -0
  75. package/api/dist/src/dashboard/dashboard.service.js +87 -0
  76. package/api/dist/src/dashboard/dashboard.service.js.map +1 -0
  77. package/api/dist/src/datasource/connectors/connector.interface.d.ts +6 -0
  78. package/api/dist/src/datasource/connectors/connector.interface.js +3 -0
  79. package/api/dist/src/datasource/connectors/connector.interface.js.map +1 -0
  80. package/api/dist/src/datasource/connectors/mongo.connector.d.ts +30 -0
  81. package/api/dist/src/datasource/connectors/mongo.connector.js +167 -0
  82. package/api/dist/src/datasource/connectors/mongo.connector.js.map +1 -0
  83. package/api/dist/src/datasource/connectors/mongo.connector.test.d.ts +1 -0
  84. package/api/dist/src/datasource/connectors/mongo.connector.test.js +179 -0
  85. package/api/dist/src/datasource/connectors/mongo.connector.test.js.map +1 -0
  86. package/api/dist/src/datasource/connectors/postgres.connector.d.ts +50 -0
  87. package/api/dist/src/datasource/connectors/postgres.connector.js +213 -0
  88. package/api/dist/src/datasource/connectors/postgres.connector.js.map +1 -0
  89. package/api/dist/src/datasource/connectors/postgres.connector.test.d.ts +1 -0
  90. package/api/dist/src/datasource/connectors/postgres.connector.test.js +197 -0
  91. package/api/dist/src/datasource/connectors/postgres.connector.test.js.map +1 -0
  92. package/api/dist/src/datasource/datasource.controller.d.ts +16 -0
  93. package/api/dist/src/datasource/datasource.controller.js +79 -0
  94. package/api/dist/src/datasource/datasource.controller.js.map +1 -0
  95. package/api/dist/src/datasource/datasource.model.d.ts +26 -0
  96. package/api/dist/src/datasource/datasource.model.js +3 -0
  97. package/api/dist/src/datasource/datasource.model.js.map +1 -0
  98. package/api/dist/src/datasource/datasource.module.d.ts +2 -0
  99. package/api/dist/src/datasource/datasource.module.js +31 -0
  100. package/api/dist/src/datasource/datasource.module.js.map +1 -0
  101. package/api/dist/src/datasource/datasource.repository.d.ts +11 -0
  102. package/api/dist/src/datasource/datasource.repository.js +61 -0
  103. package/api/dist/src/datasource/datasource.repository.js.map +1 -0
  104. package/api/dist/src/datasource/datasource.service.d.ts +28 -0
  105. package/api/dist/src/datasource/datasource.service.js +95 -0
  106. package/api/dist/src/datasource/datasource.service.js.map +1 -0
  107. package/api/dist/src/example/example.controller.d.ts +10 -0
  108. package/api/dist/src/example/example.controller.js +43 -0
  109. package/api/dist/src/example/example.controller.js.map +1 -0
  110. package/api/dist/src/example/example.model.d.ts +6 -0
  111. package/api/dist/src/example/example.model.js +3 -0
  112. package/api/dist/src/example/example.model.js.map +1 -0
  113. package/api/dist/src/example/example.module.d.ts +2 -0
  114. package/api/dist/src/example/example.module.js +23 -0
  115. package/api/dist/src/example/example.module.js.map +1 -0
  116. package/api/dist/src/example/example.repository.d.ts +6 -0
  117. package/api/dist/src/example/example.repository.js +30 -0
  118. package/api/dist/src/example/example.repository.js.map +1 -0
  119. package/api/dist/src/example/example.service.d.ts +10 -0
  120. package/api/dist/src/example/example.service.js +31 -0
  121. package/api/dist/src/example/example.service.js.map +1 -0
  122. package/api/dist/src/integration/integration.controller.d.ts +15 -0
  123. package/api/dist/src/integration/integration.controller.js +69 -0
  124. package/api/dist/src/integration/integration.controller.js.map +1 -0
  125. package/api/dist/src/integration/integration.model.d.ts +17 -0
  126. package/api/dist/src/integration/integration.model.js +3 -0
  127. package/api/dist/src/integration/integration.model.js.map +1 -0
  128. package/api/dist/src/integration/integration.module.d.ts +2 -0
  129. package/api/dist/src/integration/integration.module.js +24 -0
  130. package/api/dist/src/integration/integration.module.js.map +1 -0
  131. package/api/dist/src/integration/integration.repository.d.ts +6 -0
  132. package/api/dist/src/integration/integration.repository.js +45 -0
  133. package/api/dist/src/integration/integration.repository.js.map +1 -0
  134. package/api/dist/src/integration/integration.service.d.ts +12 -0
  135. package/api/dist/src/integration/integration.service.js +78 -0
  136. package/api/dist/src/integration/integration.service.js.map +1 -0
  137. package/api/dist/src/main.d.ts +1 -0
  138. package/api/dist/src/main.js +19 -0
  139. package/api/dist/src/main.js.map +1 -0
  140. package/api/dist/src/mcp/grafana.mcp.d.ts +1 -0
  141. package/api/dist/src/mcp/grafana.mcp.js +95 -0
  142. package/api/dist/src/mcp/grafana.mcp.js.map +1 -0
  143. package/api/dist/src/mcp/graylog.mcp.d.ts +1 -0
  144. package/api/dist/src/mcp/graylog.mcp.js +241 -0
  145. package/api/dist/src/mcp/graylog.mcp.js.map +1 -0
  146. package/api/dist/src/mcp/mcp-server.d.ts +1 -0
  147. package/api/dist/src/mcp/mcp-server.js +336 -0
  148. package/api/dist/src/mcp/mcp-server.js.map +1 -0
  149. package/api/dist/src/paths.d.ts +8 -0
  150. package/api/dist/src/paths.js +50 -0
  151. package/api/dist/src/paths.js.map +1 -0
  152. package/api/dist/src/paths.test.d.ts +1 -0
  153. package/api/dist/src/paths.test.js +60 -0
  154. package/api/dist/src/paths.test.js.map +1 -0
  155. package/api/dist/src/project/project.controller.d.ts +44 -0
  156. package/api/dist/src/project/project.controller.js +79 -0
  157. package/api/dist/src/project/project.controller.js.map +1 -0
  158. package/api/dist/src/project/project.model.d.ts +19 -0
  159. package/api/dist/src/project/project.model.js +3 -0
  160. package/api/dist/src/project/project.model.js.map +1 -0
  161. package/api/dist/src/project/project.module.d.ts +2 -0
  162. package/api/dist/src/project/project.module.js +24 -0
  163. package/api/dist/src/project/project.module.js.map +1 -0
  164. package/api/dist/src/project/project.repository.d.ts +6 -0
  165. package/api/dist/src/project/project.repository.js +52 -0
  166. package/api/dist/src/project/project.repository.js.map +1 -0
  167. package/api/dist/src/project/project.service.d.ts +17 -0
  168. package/api/dist/src/project/project.service.js +163 -0
  169. package/api/dist/src/project/project.service.js.map +1 -0
  170. package/api/dist/tsconfig.tsbuildinfo +1 -0
  171. package/api/dist/vitest.config.d.ts +2 -0
  172. package/api/dist/vitest.config.js +10 -0
  173. package/api/dist/vitest.config.js.map +1 -0
  174. package/api/public/dist/Analitoly.png +0 -0
  175. package/api/public/dist/AnalitolyShort.png +0 -0
  176. package/api/public/dist/Gitlab.png +0 -0
  177. package/api/public/dist/Grafana.png +0 -0
  178. package/api/public/dist/Graylog.png +0 -0
  179. package/api/public/dist/Mongodb.png +0 -0
  180. package/api/public/dist/PostgreSQL.png +0 -0
  181. package/api/public/dist/assets/index-BPB3ckw4.js +222 -0
  182. package/api/public/dist/assets/index-CSAGa0SG.js +227 -0
  183. package/api/public/dist/index.html +12 -0
  184. package/bin/analitoly-mcp.js +18 -0
  185. package/bin/analitoly.js +38 -0
  186. package/package.json +54 -0
@@ -0,0 +1,309 @@
1
+ {
2
+ "id": "dash_1775222037264_1rrsrd",
3
+ "name": "Автосохранение",
4
+ "createdAt": "2026-04-03T13:13:57.264Z",
5
+ "updatedAt": "2026-04-03T13:22:11.187Z",
6
+ "charts": [
7
+ {
8
+ "chartId": "chart_1775222034922",
9
+ "echartsOption": {
10
+ "tooltip": {
11
+ "trigger": "item",
12
+ "formatter": "{b}: {c} ({d}%)"
13
+ },
14
+ "legend": {
15
+ "orient": "vertical",
16
+ "right": "5%",
17
+ "top": "center"
18
+ },
19
+ "series": [
20
+ {
21
+ "type": "pie",
22
+ "radius": [
23
+ "40%",
24
+ "70%"
25
+ ],
26
+ "center": [
27
+ "40%",
28
+ "50%"
29
+ ],
30
+ "data": [
31
+ {
32
+ "value": 769,
33
+ "name": "incomingCall"
34
+ },
35
+ {
36
+ "value": 30,
37
+ "name": "updateOfferStatus"
38
+ },
39
+ {
40
+ "value": 11,
41
+ "name": "updateChannelStatus"
42
+ },
43
+ {
44
+ "value": 4,
45
+ "name": "updateAccount"
46
+ },
47
+ {
48
+ "value": 1,
49
+ "name": "updateVoice"
50
+ }
51
+ ],
52
+ "emphasis": {
53
+ "itemStyle": {
54
+ "shadowBlur": 10,
55
+ "shadowOffsetX": 0,
56
+ "shadowColor": "rgba(0,0,0,0.5)"
57
+ }
58
+ },
59
+ "label": {
60
+ "show": true,
61
+ "formatter": "{b}\n{c}"
62
+ }
63
+ }
64
+ ]
65
+ },
66
+ "title": "Аналитические события (analyticsEvent)",
67
+ "description": "Распределение типов аналитических событий в MongoDB",
68
+ "sourceQuery": "{\"collection\": \"analyticsEvent\", \"pipeline\": [{\"$group\": {\"_id\": \"$name\", \"count\": {\"$sum\": 1}}}, {\"$sort\": {\"count\": -1}}]}",
69
+ "position": 0
70
+ },
71
+ {
72
+ "chartId": "chart_1775222038877",
73
+ "echartsOption": {
74
+ "tooltip": {
75
+ "trigger": "axis",
76
+ "axisPointer": {
77
+ "type": "shadow"
78
+ }
79
+ },
80
+ "grid": {
81
+ "left": "3%",
82
+ "right": "8%",
83
+ "bottom": "3%",
84
+ "containLabel": true
85
+ },
86
+ "xAxis": {
87
+ "type": "value"
88
+ },
89
+ "yAxis": {
90
+ "type": "category",
91
+ "data": [
92
+ "USER_AFTER_GREETING",
93
+ "TECH_ERROR",
94
+ "USER_ON_START",
95
+ "USER_AFTER_CANT_ANSWER",
96
+ "UNKNOWN"
97
+ ],
98
+ "axisLabel": {
99
+ "fontSize": 12
100
+ }
101
+ },
102
+ "series": [
103
+ {
104
+ "type": "bar",
105
+ "data": [
106
+ 1,
107
+ 3,
108
+ 5,
109
+ 26,
110
+ 31
111
+ ],
112
+ "itemStyle": {
113
+ "color": {
114
+ "type": "linear",
115
+ "x": 0,
116
+ "y": 0,
117
+ "x2": 1,
118
+ "y2": 0,
119
+ "colorStops": [
120
+ {
121
+ "offset": 0,
122
+ "color": "#83bff6"
123
+ },
124
+ {
125
+ "offset": 1,
126
+ "color": "#188df0"
127
+ }
128
+ ]
129
+ }
130
+ },
131
+ "label": {
132
+ "show": true,
133
+ "position": "right",
134
+ "fontSize": 13,
135
+ "fontWeight": "bold"
136
+ }
137
+ }
138
+ ]
139
+ },
140
+ "title": "Причины завершения звонков (hangUpType)",
141
+ "description": "Распределение типов завершения входящих звонков в MongoDB",
142
+ "sourceQuery": "{\"collection\": \"incomingCallEvent\", \"pipeline\": [{\"$group\": {\"_id\": \"$hangUpType\", \"count\": {\"$sum\": 1}}}, {\"$sort\": {\"count\": -1}}]}",
143
+ "position": 1
144
+ },
145
+ {
146
+ "chartId": "chart_1775222522454",
147
+ "echartsOption": {
148
+ "tooltip": {
149
+ "trigger": "axis",
150
+ "axisPointer": {
151
+ "type": "shadow"
152
+ }
153
+ },
154
+ "legend": {
155
+ "data": [
156
+ "Активные",
157
+ "Деактивированные"
158
+ ]
159
+ },
160
+ "grid": {
161
+ "left": "3%",
162
+ "right": "4%",
163
+ "bottom": "3%",
164
+ "containLabel": true
165
+ },
166
+ "xAxis": {
167
+ "type": "category",
168
+ "data": [
169
+ "PRO_MONTHLY_OFFER",
170
+ "ASSISTANT_OFFER",
171
+ "SERGEY_MP_OFFER",
172
+ "PRO_DAILY_OFFER"
173
+ ]
174
+ },
175
+ "yAxis": {
176
+ "type": "value"
177
+ },
178
+ "series": [
179
+ {
180
+ "name": "Активные",
181
+ "type": "bar",
182
+ "stack": "total",
183
+ "itemStyle": {
184
+ "color": "#5470c6"
185
+ },
186
+ "data": [
187
+ 6,
188
+ 6,
189
+ 0,
190
+ 0
191
+ ],
192
+ "label": {
193
+ "show": true,
194
+ "position": "inside"
195
+ }
196
+ },
197
+ {
198
+ "name": "Деактивированные",
199
+ "type": "bar",
200
+ "stack": "total",
201
+ "itemStyle": {
202
+ "color": "#ee6666"
203
+ },
204
+ "data": [
205
+ 12,
206
+ 7,
207
+ 3,
208
+ 1
209
+ ],
210
+ "label": {
211
+ "show": true,
212
+ "position": "inside"
213
+ }
214
+ }
215
+ ]
216
+ },
217
+ "title": "Активные vs деактивированные подписки по офферу",
218
+ "description": "Статус activated_offer по offer_id в QA01 acc",
219
+ "sourceQuery": "SELECT offer_id, active, deactivated FROM activated_offer GROUP BY offer_id",
220
+ "position": 2
221
+ },
222
+ {
223
+ "chartId": "chart_1775222527150",
224
+ "echartsOption": {
225
+ "tooltip": {
226
+ "trigger": "axis",
227
+ "axisPointer": {
228
+ "type": "cross"
229
+ }
230
+ },
231
+ "legend": {
232
+ "data": [
233
+ "Звонков",
234
+ "Средняя длительность (сек)"
235
+ ]
236
+ },
237
+ "grid": {
238
+ "left": "3%",
239
+ "right": "6%",
240
+ "bottom": "3%",
241
+ "containLabel": true
242
+ },
243
+ "xAxis": {
244
+ "type": "category",
245
+ "data": [
246
+ "Апр 2025",
247
+ "Май 2025",
248
+ "Июл 2025"
249
+ ]
250
+ },
251
+ "yAxis": [
252
+ {
253
+ "type": "value",
254
+ "name": "Звонков",
255
+ "position": "left"
256
+ },
257
+ {
258
+ "type": "value",
259
+ "name": "Сек",
260
+ "position": "right",
261
+ "min": 0,
262
+ "max": 35
263
+ }
264
+ ],
265
+ "series": [
266
+ {
267
+ "name": "Звонков",
268
+ "type": "bar",
269
+ "data": [
270
+ 57676,
271
+ 61285,
272
+ 303917
273
+ ],
274
+ "itemStyle": {
275
+ "color": "#91cc75"
276
+ },
277
+ "label": {
278
+ "show": true,
279
+ "position": "top",
280
+ "formatter": "{c}"
281
+ }
282
+ },
283
+ {
284
+ "name": "Средняя длительность (сек)",
285
+ "type": "line",
286
+ "yAxisIndex": 1,
287
+ "data": [
288
+ 21.9,
289
+ 26.1,
290
+ 16.6
291
+ ],
292
+ "itemStyle": {
293
+ "color": "#fac858"
294
+ },
295
+ "lineStyle": {
296
+ "width": 3
297
+ },
298
+ "symbol": "circle",
299
+ "symbolSize": 8
300
+ }
301
+ ]
302
+ },
303
+ "title": "Статистика звонков по месяцам (calls_bee_stat)",
304
+ "description": "Количество звонков и средняя длительность по месяцам",
305
+ "sourceQuery": "SELECT DATE_TRUNC('month', date), COUNT(*), AVG(duration) FROM calls_bee_stat GROUP BY 1",
306
+ "position": 3
307
+ }
308
+ ]
309
+ }
@@ -0,0 +1,26 @@
1
+ import { Response } from 'express';
2
+ import { AgentService } from './agent.service';
3
+ export declare class AgentController {
4
+ private readonly agentService;
5
+ constructor(agentService: AgentService);
6
+ getConfig(): {
7
+ hasServerKey: boolean;
8
+ };
9
+ connect(apiKey?: string): {
10
+ sessionId: string;
11
+ };
12
+ listSessions(): {
13
+ sessionId: string;
14
+ createdAt: string;
15
+ lastMessagePreview: string;
16
+ numTurns: number;
17
+ }[];
18
+ checkSession(sessionId: string): {
19
+ exists: boolean;
20
+ };
21
+ message(sessionId: string, message: string, res: Response): Promise<void>;
22
+ getUsage(sessionId: string): import("./agent.service").UsageStats;
23
+ disconnect(sessionId: string): {
24
+ ok: boolean;
25
+ };
26
+ }
@@ -0,0 +1,124 @@
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
+ var _a;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.AgentController = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const express_1 = require("express");
19
+ const agent_service_1 = require("./agent.service");
20
+ let AgentController = class AgentController {
21
+ constructor(agentService) {
22
+ this.agentService = agentService;
23
+ }
24
+ getConfig() {
25
+ return { hasServerKey: this.agentService.hasServerKey() };
26
+ }
27
+ connect(apiKey) {
28
+ const sessionId = this.agentService.connect(apiKey);
29
+ return { sessionId };
30
+ }
31
+ listSessions() {
32
+ return this.agentService.listSessions();
33
+ }
34
+ checkSession(sessionId) {
35
+ return { exists: this.agentService.hasSession(sessionId) };
36
+ }
37
+ async message(sessionId, message, res) {
38
+ res.writeHead(200, {
39
+ 'Content-Type': 'text/event-stream',
40
+ 'Cache-Control': 'no-cache',
41
+ Connection: 'keep-alive',
42
+ 'X-Accel-Buffering': 'no',
43
+ });
44
+ res.flushHeaders();
45
+ const heartbeat = setInterval(() => res.write(': heartbeat\n\n'), 5000);
46
+ res.on('close', () => clearInterval(heartbeat));
47
+ try {
48
+ for await (const event of this.agentService.sendMessage(sessionId, message)) {
49
+ res.write(`data: ${JSON.stringify(event)}\n\n`);
50
+ }
51
+ }
52
+ catch (err) {
53
+ const errorMsg = err instanceof Error ? err.message : String(err);
54
+ res.write(`data: ${JSON.stringify({ type: 'error', message: errorMsg })}\n\n`);
55
+ }
56
+ finally {
57
+ clearInterval(heartbeat);
58
+ res.write(`data: ${JSON.stringify({ type: 'close' })}\n\n`);
59
+ res.end();
60
+ }
61
+ }
62
+ getUsage(sessionId) {
63
+ return this.agentService.getUsage(sessionId);
64
+ }
65
+ disconnect(sessionId) {
66
+ this.agentService.disconnect(sessionId);
67
+ return { ok: true };
68
+ }
69
+ };
70
+ exports.AgentController = AgentController;
71
+ __decorate([
72
+ (0, common_1.Get)('config'),
73
+ __metadata("design:type", Function),
74
+ __metadata("design:paramtypes", []),
75
+ __metadata("design:returntype", void 0)
76
+ ], AgentController.prototype, "getConfig", null);
77
+ __decorate([
78
+ (0, common_1.Post)('connect'),
79
+ __param(0, (0, common_1.Body)('apiKey')),
80
+ __metadata("design:type", Function),
81
+ __metadata("design:paramtypes", [String]),
82
+ __metadata("design:returntype", void 0)
83
+ ], AgentController.prototype, "connect", null);
84
+ __decorate([
85
+ (0, common_1.Get)('sessions'),
86
+ __metadata("design:type", Function),
87
+ __metadata("design:paramtypes", []),
88
+ __metadata("design:returntype", void 0)
89
+ ], AgentController.prototype, "listSessions", null);
90
+ __decorate([
91
+ (0, common_1.Get)(':sessionId/exists'),
92
+ __param(0, (0, common_1.Param)('sessionId')),
93
+ __metadata("design:type", Function),
94
+ __metadata("design:paramtypes", [String]),
95
+ __metadata("design:returntype", void 0)
96
+ ], AgentController.prototype, "checkSession", null);
97
+ __decorate([
98
+ (0, common_1.Post)(':sessionId/message'),
99
+ __param(0, (0, common_1.Param)('sessionId')),
100
+ __param(1, (0, common_1.Body)('message')),
101
+ __param(2, (0, common_1.Res)()),
102
+ __metadata("design:type", Function),
103
+ __metadata("design:paramtypes", [String, String, typeof (_a = typeof express_1.Response !== "undefined" && express_1.Response) === "function" ? _a : Object]),
104
+ __metadata("design:returntype", Promise)
105
+ ], AgentController.prototype, "message", null);
106
+ __decorate([
107
+ (0, common_1.Get)(':sessionId/usage'),
108
+ __param(0, (0, common_1.Param)('sessionId')),
109
+ __metadata("design:type", Function),
110
+ __metadata("design:paramtypes", [String]),
111
+ __metadata("design:returntype", void 0)
112
+ ], AgentController.prototype, "getUsage", null);
113
+ __decorate([
114
+ (0, common_1.Delete)(':sessionId'),
115
+ __param(0, (0, common_1.Param)('sessionId')),
116
+ __metadata("design:type", Function),
117
+ __metadata("design:paramtypes", [String]),
118
+ __metadata("design:returntype", void 0)
119
+ ], AgentController.prototype, "disconnect", null);
120
+ exports.AgentController = AgentController = __decorate([
121
+ (0, common_1.Controller)('agent'),
122
+ __metadata("design:paramtypes", [agent_service_1.AgentService])
123
+ ], AgentController);
124
+ //# sourceMappingURL=agent.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.controller.js","sourceRoot":"","sources":["../../../src/agent/agent.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAiF;AACjF,qCAAmC;AACnC,mDAA+C;AAGxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAG3D,SAAS;QACP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,CAAA;;yEAAM,kBAAQ,oBAAR,kBAAQ;;8CA2BrB;AAGD;IADC,IAAA,YAAG,EAAC,kBAAkB,CAAC;IACd,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;;;;+CAE3B;AAGD;IADC,IAAA,eAAM,EAAC,YAAY,CAAC;IACT,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;;;;iDAG7B;0BAlEU,eAAe;IAD3B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAEyB,4BAAY;GAD5C,eAAe,CAmE3B"}
@@ -0,0 +1,2 @@
1
+ export declare class AgentModule {
2
+ }
@@ -0,0 +1,23 @@
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.AgentModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const agent_controller_1 = require("./agent.controller");
12
+ const agent_service_1 = require("./agent.service");
13
+ let AgentModule = class AgentModule {
14
+ };
15
+ exports.AgentModule = AgentModule;
16
+ exports.AgentModule = AgentModule = __decorate([
17
+ (0, common_1.Module)({
18
+ controllers: [agent_controller_1.AgentController],
19
+ providers: [agent_service_1.AgentService],
20
+ exports: [agent_service_1.AgentService],
21
+ })
22
+ ], AgentModule);
23
+ //# sourceMappingURL=agent.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.module.js","sourceRoot":"","sources":["../../../src/agent/agent.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,mDAA+C;AAOxC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
@@ -0,0 +1,39 @@
1
+ export interface SSEEvent {
2
+ type: 'init' | 'text' | 'tool_use' | 'tool_result' | 'done' | 'error';
3
+ [key: string]: unknown;
4
+ }
5
+ export interface UsageStats {
6
+ totalCostUsd: number;
7
+ inputTokens: number;
8
+ outputTokens: number;
9
+ cacheReadTokens: number;
10
+ cacheCreationTokens: number;
11
+ numTurns: number;
12
+ durationMs: number;
13
+ model: string;
14
+ modelUsage: Record<string, {
15
+ inputTokens: number;
16
+ outputTokens: number;
17
+ costUSD: number;
18
+ }>;
19
+ }
20
+ export declare class AgentService {
21
+ private sessions;
22
+ private projectRepository;
23
+ private connectionRepo;
24
+ private buildSystemPrompt;
25
+ private computeFingerprint;
26
+ connect(apiKey?: string): string;
27
+ hasServerKey(): boolean;
28
+ private hasClaudeCredentials;
29
+ sendMessage(sessionId: string, message: string): AsyncGenerator<SSEEvent>;
30
+ getUsage(sessionId: string): UsageStats;
31
+ listSessions(): {
32
+ sessionId: string;
33
+ createdAt: string;
34
+ lastMessagePreview: string;
35
+ numTurns: number;
36
+ }[];
37
+ hasSession(sessionId: string): boolean;
38
+ disconnect(sessionId: string): void;
39
+ }