@wener/mcps 1.0.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.
- package/LICENSE +21 -0
- package/dist/index.mjs +15 -0
- package/dist/mcps-cli.mjs +174727 -0
- package/lib/chat/agent.js +187 -0
- package/lib/chat/agent.js.map +1 -0
- package/lib/chat/audit.js +238 -0
- package/lib/chat/audit.js.map +1 -0
- package/lib/chat/converters.js +467 -0
- package/lib/chat/converters.js.map +1 -0
- package/lib/chat/handler.js +1068 -0
- package/lib/chat/handler.js.map +1 -0
- package/lib/chat/index.js +12 -0
- package/lib/chat/index.js.map +1 -0
- package/lib/chat/types.js +35 -0
- package/lib/chat/types.js.map +1 -0
- package/lib/contracts/AuditContract.js +85 -0
- package/lib/contracts/AuditContract.js.map +1 -0
- package/lib/contracts/McpsContract.js +113 -0
- package/lib/contracts/McpsContract.js.map +1 -0
- package/lib/contracts/index.js +3 -0
- package/lib/contracts/index.js.map +1 -0
- package/lib/dev.server.js +7 -0
- package/lib/dev.server.js.map +1 -0
- package/lib/entities/ChatRequestEntity.js +318 -0
- package/lib/entities/ChatRequestEntity.js.map +1 -0
- package/lib/entities/McpRequestEntity.js +271 -0
- package/lib/entities/McpRequestEntity.js.map +1 -0
- package/lib/entities/RequestLogEntity.js +177 -0
- package/lib/entities/RequestLogEntity.js.map +1 -0
- package/lib/entities/ResponseEntity.js +150 -0
- package/lib/entities/ResponseEntity.js.map +1 -0
- package/lib/entities/index.js +11 -0
- package/lib/entities/index.js.map +1 -0
- package/lib/entities/types.js +11 -0
- package/lib/entities/types.js.map +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/mcps-cli.js +44 -0
- package/lib/mcps-cli.js.map +1 -0
- package/lib/providers/McpServerHandlerDef.js +40 -0
- package/lib/providers/McpServerHandlerDef.js.map +1 -0
- package/lib/providers/findMcpServerDef.js +26 -0
- package/lib/providers/findMcpServerDef.js.map +1 -0
- package/lib/providers/prometheus/def.js +24 -0
- package/lib/providers/prometheus/def.js.map +1 -0
- package/lib/providers/prometheus/index.js +2 -0
- package/lib/providers/prometheus/index.js.map +1 -0
- package/lib/providers/relay/def.js +32 -0
- package/lib/providers/relay/def.js.map +1 -0
- package/lib/providers/relay/index.js +2 -0
- package/lib/providers/relay/index.js.map +1 -0
- package/lib/providers/sql/def.js +31 -0
- package/lib/providers/sql/def.js.map +1 -0
- package/lib/providers/sql/index.js +2 -0
- package/lib/providers/sql/index.js.map +1 -0
- package/lib/providers/tencent-cls/def.js +44 -0
- package/lib/providers/tencent-cls/def.js.map +1 -0
- package/lib/providers/tencent-cls/index.js +2 -0
- package/lib/providers/tencent-cls/index.js.map +1 -0
- package/lib/scripts/bundle.js +90 -0
- package/lib/scripts/bundle.js.map +1 -0
- package/lib/server/api-routes.js +96 -0
- package/lib/server/api-routes.js.map +1 -0
- package/lib/server/audit.js +274 -0
- package/lib/server/audit.js.map +1 -0
- package/lib/server/chat-routes.js +82 -0
- package/lib/server/chat-routes.js.map +1 -0
- package/lib/server/config.js +223 -0
- package/lib/server/config.js.map +1 -0
- package/lib/server/db.js +97 -0
- package/lib/server/db.js.map +1 -0
- package/lib/server/index.js +2 -0
- package/lib/server/index.js.map +1 -0
- package/lib/server/mcp-handler.js +167 -0
- package/lib/server/mcp-handler.js.map +1 -0
- package/lib/server/mcp-routes.js +112 -0
- package/lib/server/mcp-routes.js.map +1 -0
- package/lib/server/mcps-router.js +119 -0
- package/lib/server/mcps-router.js.map +1 -0
- package/lib/server/schema.js +129 -0
- package/lib/server/schema.js.map +1 -0
- package/lib/server/server.js +166 -0
- package/lib/server/server.js.map +1 -0
- package/lib/web/ChatPage.js +827 -0
- package/lib/web/ChatPage.js.map +1 -0
- package/lib/web/McpInspectorPage.js +214 -0
- package/lib/web/McpInspectorPage.js.map +1 -0
- package/lib/web/ServersPage.js +93 -0
- package/lib/web/ServersPage.js.map +1 -0
- package/lib/web/main.js +541 -0
- package/lib/web/main.js.map +1 -0
- package/package.json +83 -0
- package/src/chat/agent.ts +240 -0
- package/src/chat/audit.ts +377 -0
- package/src/chat/converters.test.ts +325 -0
- package/src/chat/converters.ts +459 -0
- package/src/chat/handler.test.ts +137 -0
- package/src/chat/handler.ts +1233 -0
- package/src/chat/index.ts +16 -0
- package/src/chat/types.ts +72 -0
- package/src/contracts/AuditContract.ts +93 -0
- package/src/contracts/McpsContract.ts +141 -0
- package/src/contracts/index.ts +18 -0
- package/src/dev.server.ts +7 -0
- package/src/entities/ChatRequestEntity.ts +157 -0
- package/src/entities/McpRequestEntity.ts +149 -0
- package/src/entities/RequestLogEntity.ts +78 -0
- package/src/entities/ResponseEntity.ts +75 -0
- package/src/entities/index.ts +12 -0
- package/src/entities/types.ts +188 -0
- package/src/index.ts +1 -0
- package/src/mcps-cli.ts +59 -0
- package/src/providers/McpServerHandlerDef.ts +105 -0
- package/src/providers/findMcpServerDef.ts +31 -0
- package/src/providers/prometheus/def.ts +21 -0
- package/src/providers/prometheus/index.ts +1 -0
- package/src/providers/relay/def.ts +31 -0
- package/src/providers/relay/index.ts +1 -0
- package/src/providers/relay/relay.test.ts +47 -0
- package/src/providers/sql/def.ts +33 -0
- package/src/providers/sql/index.ts +1 -0
- package/src/providers/tencent-cls/def.ts +38 -0
- package/src/providers/tencent-cls/index.ts +1 -0
- package/src/scripts/bundle.ts +82 -0
- package/src/server/api-routes.ts +98 -0
- package/src/server/audit.ts +310 -0
- package/src/server/chat-routes.ts +95 -0
- package/src/server/config.test.ts +162 -0
- package/src/server/config.ts +198 -0
- package/src/server/db.ts +115 -0
- package/src/server/index.ts +1 -0
- package/src/server/mcp-handler.ts +209 -0
- package/src/server/mcp-routes.ts +133 -0
- package/src/server/mcps-router.ts +133 -0
- package/src/server/schema.ts +175 -0
- package/src/server/server.ts +163 -0
- package/src/web/ChatPage.tsx +1005 -0
- package/src/web/McpInspectorPage.tsx +254 -0
- package/src/web/ServersPage.tsx +139 -0
- package/src/web/main.tsx +600 -0
- package/src/web/styles.css +15 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { _ as _apply_decs_2203_r } from "@swc/helpers/_/_apply_decs_2203_r";
|
|
2
|
+
var _dec, _initClass, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _dec27, _dec28, _dec29, _dec30, _dec31, _dec32, _dec33, _init_id, /** Unique request ID for tracing */ _init_requestId, /** Request timestamp */ _init_requestedAt, /** Response timestamp */ _init_completedAt, /** Request status */ _init_status, /** HTTP method */ _init_method, /** Request path/endpoint */ _init_endpoint, /** Input protocol (client-facing) */ _init_inputProtocol, /** Output protocol (upstream provider) */ _init_outputProtocol, /** Model name requested */ _init_model, /** Resolved model name */ _init_resolvedModel, /** Provider name */ _init_provider, /** Upstream base URL */ _init_upstreamUrl, /** Whether request was streaming */ _init_streaming, /** Input token count */ _init_inputTokens, /** Output token count */ _init_outputTokens, /** Total token count */ _init_totalTokens, /** Request duration in ms */ _init_durationMs, /** Time to first token in ms */ _init_ttftMs, /** HTTP status code */ _init_httpStatus, /** Error message */ _init_errorMessage, /** Error code */ _init_errorCode, /** Client IP */ _init_clientIp, /** User agent */ _init_userAgent, /** User ID */ _init_userId, /** Organization ID */ _init_orgId, /** API key ID (not the actual key) */ _init_apiKeyId, /** Request metadata (JSON) */ _init_requestMeta, /** Response metadata (JSON) */ _init_responseMeta, /** Cost in credits (decimal string) */ _init_cost, /** Currency */ _init_currency, _init_createdAt, _init_updatedAt, _initProto;
|
|
3
|
+
import { Entity, Enum, PrimaryKey, Property } from '@mikro-orm/decorators/es';
|
|
4
|
+
/**
|
|
5
|
+
* Chat protocol type
|
|
6
|
+
*/ export const ChatProtocolType = Object.freeze({
|
|
7
|
+
OpenAI: 'openai',
|
|
8
|
+
Anthropic: 'anthropic',
|
|
9
|
+
Gemini: 'gemini'
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Request status
|
|
13
|
+
*/ export const RequestStatus = Object.freeze({
|
|
14
|
+
Pending: 'pending',
|
|
15
|
+
Success: 'success',
|
|
16
|
+
Error: 'error',
|
|
17
|
+
Timeout: 'timeout'
|
|
18
|
+
});
|
|
19
|
+
let _ChatRequestEntity;
|
|
20
|
+
_dec = Entity({
|
|
21
|
+
tableName: 'chat_request'
|
|
22
|
+
}), _dec1 = PrimaryKey({
|
|
23
|
+
type: 'integer'
|
|
24
|
+
}), _dec2 = Property({
|
|
25
|
+
type: 'string',
|
|
26
|
+
unique: true
|
|
27
|
+
}), _dec3 = Property({
|
|
28
|
+
type: 'datetime'
|
|
29
|
+
}), _dec4 = Property({
|
|
30
|
+
type: 'datetime',
|
|
31
|
+
nullable: true
|
|
32
|
+
}), _dec5 = Enum(()=>RequestStatus), _dec6 = Property({
|
|
33
|
+
type: 'string'
|
|
34
|
+
}), _dec7 = Property({
|
|
35
|
+
type: 'string'
|
|
36
|
+
}), _dec8 = Enum(()=>ChatProtocolType), _dec9 = Enum(()=>ChatProtocolType), _dec10 = Property({
|
|
37
|
+
type: 'string'
|
|
38
|
+
}), _dec11 = Property({
|
|
39
|
+
type: 'string',
|
|
40
|
+
nullable: true
|
|
41
|
+
}), _dec12 = Property({
|
|
42
|
+
type: 'string',
|
|
43
|
+
nullable: true
|
|
44
|
+
}), _dec13 = Property({
|
|
45
|
+
type: 'string',
|
|
46
|
+
nullable: true
|
|
47
|
+
}), _dec14 = Property({
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
default: false
|
|
50
|
+
}), _dec15 = Property({
|
|
51
|
+
type: 'integer',
|
|
52
|
+
nullable: true
|
|
53
|
+
}), _dec16 = Property({
|
|
54
|
+
type: 'integer',
|
|
55
|
+
nullable: true
|
|
56
|
+
}), _dec17 = Property({
|
|
57
|
+
type: 'integer',
|
|
58
|
+
nullable: true
|
|
59
|
+
}), _dec18 = Property({
|
|
60
|
+
type: 'integer',
|
|
61
|
+
nullable: true
|
|
62
|
+
}), _dec19 = Property({
|
|
63
|
+
type: 'integer',
|
|
64
|
+
nullable: true
|
|
65
|
+
}), _dec20 = Property({
|
|
66
|
+
type: 'integer',
|
|
67
|
+
nullable: true
|
|
68
|
+
}), _dec21 = Property({
|
|
69
|
+
type: 'text',
|
|
70
|
+
nullable: true
|
|
71
|
+
}), _dec22 = Property({
|
|
72
|
+
type: 'string',
|
|
73
|
+
nullable: true
|
|
74
|
+
}), _dec23 = Property({
|
|
75
|
+
type: 'string',
|
|
76
|
+
nullable: true
|
|
77
|
+
}), _dec24 = Property({
|
|
78
|
+
type: 'string',
|
|
79
|
+
nullable: true
|
|
80
|
+
}), _dec25 = Property({
|
|
81
|
+
type: 'string',
|
|
82
|
+
nullable: true
|
|
83
|
+
}), _dec26 = Property({
|
|
84
|
+
type: 'string',
|
|
85
|
+
nullable: true
|
|
86
|
+
}), _dec27 = Property({
|
|
87
|
+
type: 'string',
|
|
88
|
+
nullable: true
|
|
89
|
+
}), _dec28 = Property({
|
|
90
|
+
type: 'json',
|
|
91
|
+
nullable: true
|
|
92
|
+
}), _dec29 = Property({
|
|
93
|
+
type: 'json',
|
|
94
|
+
nullable: true
|
|
95
|
+
}), _dec30 = Property({
|
|
96
|
+
type: 'string',
|
|
97
|
+
nullable: true
|
|
98
|
+
}), _dec31 = Property({
|
|
99
|
+
type: 'string',
|
|
100
|
+
nullable: true
|
|
101
|
+
}), _dec32 = Property({
|
|
102
|
+
type: 'datetime'
|
|
103
|
+
}), _dec33 = Property({
|
|
104
|
+
type: 'datetime',
|
|
105
|
+
onUpdate: ()=>new Date()
|
|
106
|
+
});
|
|
107
|
+
let ChatRequestEntity = class ChatRequestEntity {
|
|
108
|
+
static{
|
|
109
|
+
({ e: [_init_id, _init_requestId, _init_requestedAt, _init_completedAt, _init_status, _init_method, _init_endpoint, _init_inputProtocol, _init_outputProtocol, _init_model, _init_resolvedModel, _init_provider, _init_upstreamUrl, _init_streaming, _init_inputTokens, _init_outputTokens, _init_totalTokens, _init_durationMs, _init_ttftMs, _init_httpStatus, _init_errorMessage, _init_errorCode, _init_clientIp, _init_userAgent, _init_userId, _init_orgId, _init_apiKeyId, _init_requestMeta, _init_responseMeta, _init_cost, _init_currency, _init_createdAt, _init_updatedAt, _initProto], c: [_ChatRequestEntity, _initClass] } = _apply_decs_2203_r(this, [
|
|
110
|
+
[
|
|
111
|
+
_dec1,
|
|
112
|
+
0,
|
|
113
|
+
"id"
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
_dec2,
|
|
117
|
+
0,
|
|
118
|
+
"requestId"
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
_dec3,
|
|
122
|
+
0,
|
|
123
|
+
"requestedAt"
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
_dec4,
|
|
127
|
+
0,
|
|
128
|
+
"completedAt"
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
_dec5,
|
|
132
|
+
0,
|
|
133
|
+
"status"
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
_dec6,
|
|
137
|
+
0,
|
|
138
|
+
"method"
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
_dec7,
|
|
142
|
+
0,
|
|
143
|
+
"endpoint"
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
_dec8,
|
|
147
|
+
0,
|
|
148
|
+
"inputProtocol"
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
_dec9,
|
|
152
|
+
0,
|
|
153
|
+
"outputProtocol"
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
_dec10,
|
|
157
|
+
0,
|
|
158
|
+
"model"
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
_dec11,
|
|
162
|
+
0,
|
|
163
|
+
"resolvedModel"
|
|
164
|
+
],
|
|
165
|
+
[
|
|
166
|
+
_dec12,
|
|
167
|
+
0,
|
|
168
|
+
"provider"
|
|
169
|
+
],
|
|
170
|
+
[
|
|
171
|
+
_dec13,
|
|
172
|
+
0,
|
|
173
|
+
"upstreamUrl"
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
_dec14,
|
|
177
|
+
0,
|
|
178
|
+
"streaming"
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
_dec15,
|
|
182
|
+
0,
|
|
183
|
+
"inputTokens"
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
_dec16,
|
|
187
|
+
0,
|
|
188
|
+
"outputTokens"
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
_dec17,
|
|
192
|
+
0,
|
|
193
|
+
"totalTokens"
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
_dec18,
|
|
197
|
+
0,
|
|
198
|
+
"durationMs"
|
|
199
|
+
],
|
|
200
|
+
[
|
|
201
|
+
_dec19,
|
|
202
|
+
0,
|
|
203
|
+
"ttftMs"
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
_dec20,
|
|
207
|
+
0,
|
|
208
|
+
"httpStatus"
|
|
209
|
+
],
|
|
210
|
+
[
|
|
211
|
+
_dec21,
|
|
212
|
+
0,
|
|
213
|
+
"errorMessage"
|
|
214
|
+
],
|
|
215
|
+
[
|
|
216
|
+
_dec22,
|
|
217
|
+
0,
|
|
218
|
+
"errorCode"
|
|
219
|
+
],
|
|
220
|
+
[
|
|
221
|
+
_dec23,
|
|
222
|
+
0,
|
|
223
|
+
"clientIp"
|
|
224
|
+
],
|
|
225
|
+
[
|
|
226
|
+
_dec24,
|
|
227
|
+
0,
|
|
228
|
+
"userAgent"
|
|
229
|
+
],
|
|
230
|
+
[
|
|
231
|
+
_dec25,
|
|
232
|
+
0,
|
|
233
|
+
"userId"
|
|
234
|
+
],
|
|
235
|
+
[
|
|
236
|
+
_dec26,
|
|
237
|
+
0,
|
|
238
|
+
"orgId"
|
|
239
|
+
],
|
|
240
|
+
[
|
|
241
|
+
_dec27,
|
|
242
|
+
0,
|
|
243
|
+
"apiKeyId"
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
_dec28,
|
|
247
|
+
0,
|
|
248
|
+
"requestMeta"
|
|
249
|
+
],
|
|
250
|
+
[
|
|
251
|
+
_dec29,
|
|
252
|
+
0,
|
|
253
|
+
"responseMeta"
|
|
254
|
+
],
|
|
255
|
+
[
|
|
256
|
+
_dec30,
|
|
257
|
+
0,
|
|
258
|
+
"cost"
|
|
259
|
+
],
|
|
260
|
+
[
|
|
261
|
+
_dec31,
|
|
262
|
+
0,
|
|
263
|
+
"currency"
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
_dec32,
|
|
267
|
+
0,
|
|
268
|
+
"createdAt"
|
|
269
|
+
],
|
|
270
|
+
[
|
|
271
|
+
_dec33,
|
|
272
|
+
0,
|
|
273
|
+
"updatedAt"
|
|
274
|
+
]
|
|
275
|
+
], [
|
|
276
|
+
_dec
|
|
277
|
+
]));
|
|
278
|
+
}
|
|
279
|
+
id = (_initProto(this), _init_id(this));
|
|
280
|
+
requestId = _init_requestId(this);
|
|
281
|
+
requestedAt = _init_requestedAt(this, new Date());
|
|
282
|
+
completedAt = _init_completedAt(this);
|
|
283
|
+
status = _init_status(this, RequestStatus.Pending);
|
|
284
|
+
method = _init_method(this);
|
|
285
|
+
endpoint = _init_endpoint(this);
|
|
286
|
+
inputProtocol = _init_inputProtocol(this);
|
|
287
|
+
outputProtocol = _init_outputProtocol(this);
|
|
288
|
+
model = _init_model(this);
|
|
289
|
+
resolvedModel = _init_resolvedModel(this);
|
|
290
|
+
provider = _init_provider(this);
|
|
291
|
+
upstreamUrl = _init_upstreamUrl(this);
|
|
292
|
+
streaming = _init_streaming(this, false);
|
|
293
|
+
inputTokens = _init_inputTokens(this);
|
|
294
|
+
outputTokens = _init_outputTokens(this);
|
|
295
|
+
totalTokens = _init_totalTokens(this);
|
|
296
|
+
durationMs = _init_durationMs(this);
|
|
297
|
+
ttftMs = _init_ttftMs(this);
|
|
298
|
+
httpStatus = _init_httpStatus(this);
|
|
299
|
+
errorMessage = _init_errorMessage(this);
|
|
300
|
+
errorCode = _init_errorCode(this);
|
|
301
|
+
clientIp = _init_clientIp(this);
|
|
302
|
+
userAgent = _init_userAgent(this);
|
|
303
|
+
userId = _init_userId(this);
|
|
304
|
+
orgId = _init_orgId(this);
|
|
305
|
+
apiKeyId = _init_apiKeyId(this);
|
|
306
|
+
requestMeta = _init_requestMeta(this);
|
|
307
|
+
responseMeta = _init_responseMeta(this);
|
|
308
|
+
cost = _init_cost(this);
|
|
309
|
+
currency = _init_currency(this);
|
|
310
|
+
createdAt = _init_createdAt(this, new Date());
|
|
311
|
+
updatedAt = _init_updatedAt(this, new Date());
|
|
312
|
+
static{
|
|
313
|
+
_initClass();
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
export { _ChatRequestEntity as ChatRequestEntity };
|
|
317
|
+
|
|
318
|
+
//# sourceMappingURL=ChatRequestEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/entities/ChatRequestEntity.ts"],"sourcesContent":["import { Entity, Enum, PrimaryKey, Property } from '@mikro-orm/decorators/es';\n\n/**\n * Chat protocol type\n */\nexport const ChatProtocolType = Object.freeze({\n\tOpenAI: 'openai',\n\tAnthropic: 'anthropic',\n\tGemini: 'gemini',\n} as const);\nexport type ChatProtocolType = (typeof ChatProtocolType)[keyof typeof ChatProtocolType];\n\n/**\n * Request status\n */\nexport const RequestStatus = Object.freeze({\n\tPending: 'pending',\n\tSuccess: 'success',\n\tError: 'error',\n\tTimeout: 'timeout',\n} as const);\nexport type RequestStatus = (typeof RequestStatus)[keyof typeof RequestStatus];\n\n/**\n * Chat Request Entity for auditing and metering\n */\n@Entity({ tableName: 'chat_request' })\nexport class ChatRequestEntity {\n\t@PrimaryKey({ type: 'integer' })\n\tid!: number;\n\n\t/** Unique request ID for tracing */\n\t@Property({ type: 'string', unique: true })\n\trequestId!: string;\n\n\t/** Request timestamp */\n\t@Property({ type: 'datetime' })\n\trequestedAt: Date = new Date();\n\n\t/** Response timestamp */\n\t@Property({ type: 'datetime', nullable: true })\n\tcompletedAt?: Date;\n\n\t/** Request status */\n\t@Enum(() => RequestStatus)\n\tstatus: RequestStatus = RequestStatus.Pending;\n\n\t/** HTTP method */\n\t@Property({ type: 'string' })\n\tmethod!: string;\n\n\t/** Request path/endpoint */\n\t@Property({ type: 'string' })\n\tendpoint!: string;\n\n\t/** Input protocol (client-facing) */\n\t@Enum(() => ChatProtocolType)\n\tinputProtocol!: ChatProtocolType;\n\n\t/** Output protocol (upstream provider) */\n\t@Enum(() => ChatProtocolType)\n\toutputProtocol!: ChatProtocolType;\n\n\t/** Model name requested */\n\t@Property({ type: 'string' })\n\tmodel!: string;\n\n\t/** Resolved model name */\n\t@Property({ type: 'string', nullable: true })\n\tresolvedModel?: string;\n\n\t/** Provider name */\n\t@Property({ type: 'string', nullable: true })\n\tprovider?: string;\n\n\t/** Upstream base URL */\n\t@Property({ type: 'string', nullable: true })\n\tupstreamUrl?: string;\n\n\t/** Whether request was streaming */\n\t@Property({ type: 'boolean', default: false })\n\tstreaming: boolean = false;\n\n\t/** Input token count */\n\t@Property({ type: 'integer', nullable: true })\n\tinputTokens?: number;\n\n\t/** Output token count */\n\t@Property({ type: 'integer', nullable: true })\n\toutputTokens?: number;\n\n\t/** Total token count */\n\t@Property({ type: 'integer', nullable: true })\n\ttotalTokens?: number;\n\n\t/** Request duration in ms */\n\t@Property({ type: 'integer', nullable: true })\n\tdurationMs?: number;\n\n\t/** Time to first token in ms */\n\t@Property({ type: 'integer', nullable: true })\n\tttftMs?: number;\n\n\t/** HTTP status code */\n\t@Property({ type: 'integer', nullable: true })\n\thttpStatus?: number;\n\n\t/** Error message */\n\t@Property({ type: 'text', nullable: true })\n\terrorMessage?: string;\n\n\t/** Error code */\n\t@Property({ type: 'string', nullable: true })\n\terrorCode?: string;\n\n\t/** Client IP */\n\t@Property({ type: 'string', nullable: true })\n\tclientIp?: string;\n\n\t/** User agent */\n\t@Property({ type: 'string', nullable: true })\n\tuserAgent?: string;\n\n\t/** User ID */\n\t@Property({ type: 'string', nullable: true })\n\tuserId?: string;\n\n\t/** Organization ID */\n\t@Property({ type: 'string', nullable: true })\n\torgId?: string;\n\n\t/** API key ID (not the actual key) */\n\t@Property({ type: 'string', nullable: true })\n\tapiKeyId?: string;\n\n\t/** Request metadata (JSON) */\n\t@Property({ type: 'json', nullable: true })\n\trequestMeta?: Record<string, unknown>;\n\n\t/** Response metadata (JSON) */\n\t@Property({ type: 'json', nullable: true })\n\tresponseMeta?: Record<string, unknown>;\n\n\t/** Cost in credits (decimal string) */\n\t@Property({ type: 'string', nullable: true })\n\tcost?: string;\n\n\t/** Currency */\n\t@Property({ type: 'string', nullable: true })\n\tcurrency?: string;\n\n\t@Property({ type: 'datetime' })\n\tcreatedAt: Date = new Date();\n\n\t@Property({ type: 'datetime', onUpdate: () => new Date() })\n\tupdatedAt: Date = new Date();\n}\n"],"names":["id","requestId","requestedAt","completedAt","status","method","endpoint","inputProtocol","outputProtocol","model","resolvedModel","provider","upstreamUrl","streaming","inputTokens","outputTokens","totalTokens","durationMs","ttftMs","httpStatus","errorMessage","errorCode","clientIp","userAgent","userId","orgId","apiKeyId","requestMeta","responseMeta","cost","currency","createdAt","updatedAt","Entity","Enum","PrimaryKey","Property","ChatProtocolType","Object","freeze","OpenAI","Anthropic","Gemini","RequestStatus","Pending","Success","Error","Timeout","tableName","type","unique","nullable","default","onUpdate","Date","ChatRequestEntity"],"mappings":";qRA4BC,AACAA,UAEA,kCAAkC,GAClC,AACAC,iBAEA,sBAAsB,GACtB,AACAC,mBAEA,uBAAuB,GACvB,AACAC,mBAEA,mBAAmB,GACnB,AACAC,cAEA,gBAAgB,GAChB,AACAC,cAEA,0BAA0B,GAC1B,AACAC,gBAEA,mCAAmC,GACnC,AACAC,qBAEA,wCAAwC,GACxC,AACAC,sBAEA,yBAAyB,GACzB,AACAC,aAEA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AAA,qBAAkB;IAIlBC,YAAAA,sBAAmB;IAInBC,SAAAA,mBAAgB;IAIhBC,QAAAA,kBAAe;IAIfC,WAAAA,qBAAkB;IAIlBC,cAAAA,wBAAsC;IAItCC,eAAAA,yBAAuC;IAIvCC,OAAAA,iBAAc;IAIdC,WAAAA,qBAAkB;IAGlBC,YAAAA,sBAAkB,IAAIuB,QAAO;IAG7BtB,YAAAA,sBAAkB,IAAIsB,QAAO;;;;AAC9B;SAjIA,AAAaC,sBAAAA,iBAiIZ"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { _ as _apply_decs_2203_r } from "@swc/helpers/_/_apply_decs_2203_r";
|
|
2
|
+
var _dec, _initClass, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _init_id, /** Unique request ID */ _init_requestId, /** MCP session ID */ _init_sessionId, /** Request timestamp */ _init_requestedAt, /** Response timestamp */ _init_completedAt, /** Request status */ _init_status, /** HTTP method */ _init_method, /** Request path */ _init_path, /** MCP server name */ _init_serverName, /** MCP server type */ _init_serverType, /** MCP request type (JSON-RPC method) */ _init_mcpMethod, /** Tool name (for tools/call) */ _init_toolName, /** Resource URI (for resources/read) */ _init_resourceUri, /** Prompt name (for prompts/get) */ _init_promptName, /** Request duration in ms */ _init_durationMs, /** HTTP status code */ _init_httpStatus, /** Error message */ _init_errorMessage, /** Error code */ _init_errorCode, /** Client IP */ _init_clientIp, /** User agent */ _init_userAgent, /** User ID */ _init_userId, /** Request headers (JSON) */ _init_requestHeaders, /** Request body (JSON) */ _init_requestBody, /** Response metadata (JSON) */ _init_responseMeta, _init_createdAt, _init_updatedAt, _initProto;
|
|
3
|
+
import { Entity, Enum, PrimaryKey, Property } from '@mikro-orm/decorators/es';
|
|
4
|
+
/**
|
|
5
|
+
* MCP server type
|
|
6
|
+
*/ export const McpServerType = Object.freeze({
|
|
7
|
+
TencentCls: 'tencent-cls',
|
|
8
|
+
Sql: 'sql',
|
|
9
|
+
Prometheus: 'prometheus',
|
|
10
|
+
Relay: 'relay',
|
|
11
|
+
Custom: 'custom'
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* MCP request type (JSON-RPC method)
|
|
15
|
+
*/ export const McpRequestType = Object.freeze({
|
|
16
|
+
Initialize: 'initialize',
|
|
17
|
+
ToolsList: 'tools/list',
|
|
18
|
+
ToolsCall: 'tools/call',
|
|
19
|
+
ResourcesList: 'resources/list',
|
|
20
|
+
ResourcesRead: 'resources/read',
|
|
21
|
+
PromptsList: 'prompts/list',
|
|
22
|
+
PromptsGet: 'prompts/get',
|
|
23
|
+
CompletionComplete: 'completion/complete',
|
|
24
|
+
LoggingSetLevel: 'logging/setLevel',
|
|
25
|
+
Ping: 'ping',
|
|
26
|
+
Other: 'other'
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Request status
|
|
30
|
+
*/ export const RequestStatus = Object.freeze({
|
|
31
|
+
Pending: 'pending',
|
|
32
|
+
Success: 'success',
|
|
33
|
+
Error: 'error',
|
|
34
|
+
Timeout: 'timeout'
|
|
35
|
+
});
|
|
36
|
+
let _McpRequestEntity;
|
|
37
|
+
_dec = Entity({
|
|
38
|
+
tableName: 'mcp_request'
|
|
39
|
+
}), _dec1 = PrimaryKey({
|
|
40
|
+
type: 'integer'
|
|
41
|
+
}), _dec2 = Property({
|
|
42
|
+
type: 'string'
|
|
43
|
+
}), _dec3 = Property({
|
|
44
|
+
type: 'string',
|
|
45
|
+
nullable: true
|
|
46
|
+
}), _dec4 = Property({
|
|
47
|
+
type: 'datetime'
|
|
48
|
+
}), _dec5 = Property({
|
|
49
|
+
type: 'datetime',
|
|
50
|
+
nullable: true
|
|
51
|
+
}), _dec6 = Enum(()=>RequestStatus), _dec7 = Property({
|
|
52
|
+
type: 'string'
|
|
53
|
+
}), _dec8 = Property({
|
|
54
|
+
type: 'string'
|
|
55
|
+
}), _dec9 = Property({
|
|
56
|
+
type: 'string'
|
|
57
|
+
}), _dec10 = Enum(()=>McpServerType), _dec11 = Enum(()=>McpRequestType), _dec12 = Property({
|
|
58
|
+
type: 'string',
|
|
59
|
+
nullable: true
|
|
60
|
+
}), _dec13 = Property({
|
|
61
|
+
type: 'string',
|
|
62
|
+
nullable: true
|
|
63
|
+
}), _dec14 = Property({
|
|
64
|
+
type: 'string',
|
|
65
|
+
nullable: true
|
|
66
|
+
}), _dec15 = Property({
|
|
67
|
+
type: 'integer',
|
|
68
|
+
nullable: true
|
|
69
|
+
}), _dec16 = Property({
|
|
70
|
+
type: 'integer',
|
|
71
|
+
nullable: true
|
|
72
|
+
}), _dec17 = Property({
|
|
73
|
+
type: 'text',
|
|
74
|
+
nullable: true
|
|
75
|
+
}), _dec18 = Property({
|
|
76
|
+
type: 'string',
|
|
77
|
+
nullable: true
|
|
78
|
+
}), _dec19 = Property({
|
|
79
|
+
type: 'string',
|
|
80
|
+
nullable: true
|
|
81
|
+
}), _dec20 = Property({
|
|
82
|
+
type: 'string',
|
|
83
|
+
nullable: true
|
|
84
|
+
}), _dec21 = Property({
|
|
85
|
+
type: 'string',
|
|
86
|
+
nullable: true
|
|
87
|
+
}), _dec22 = Property({
|
|
88
|
+
type: 'json',
|
|
89
|
+
nullable: true
|
|
90
|
+
}), _dec23 = Property({
|
|
91
|
+
type: 'json',
|
|
92
|
+
nullable: true
|
|
93
|
+
}), _dec24 = Property({
|
|
94
|
+
type: 'json',
|
|
95
|
+
nullable: true
|
|
96
|
+
}), _dec25 = Property({
|
|
97
|
+
type: 'datetime'
|
|
98
|
+
}), _dec26 = Property({
|
|
99
|
+
type: 'datetime',
|
|
100
|
+
onUpdate: ()=>new Date()
|
|
101
|
+
});
|
|
102
|
+
let McpRequestEntity = class McpRequestEntity {
|
|
103
|
+
static{
|
|
104
|
+
({ e: [_init_id, _init_requestId, _init_sessionId, _init_requestedAt, _init_completedAt, _init_status, _init_method, _init_path, _init_serverName, _init_serverType, _init_mcpMethod, _init_toolName, _init_resourceUri, _init_promptName, _init_durationMs, _init_httpStatus, _init_errorMessage, _init_errorCode, _init_clientIp, _init_userAgent, _init_userId, _init_requestHeaders, _init_requestBody, _init_responseMeta, _init_createdAt, _init_updatedAt, _initProto], c: [_McpRequestEntity, _initClass] } = _apply_decs_2203_r(this, [
|
|
105
|
+
[
|
|
106
|
+
_dec1,
|
|
107
|
+
0,
|
|
108
|
+
"id"
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
_dec2,
|
|
112
|
+
0,
|
|
113
|
+
"requestId"
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
_dec3,
|
|
117
|
+
0,
|
|
118
|
+
"sessionId"
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
_dec4,
|
|
122
|
+
0,
|
|
123
|
+
"requestedAt"
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
_dec5,
|
|
127
|
+
0,
|
|
128
|
+
"completedAt"
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
_dec6,
|
|
132
|
+
0,
|
|
133
|
+
"status"
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
_dec7,
|
|
137
|
+
0,
|
|
138
|
+
"method"
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
_dec8,
|
|
142
|
+
0,
|
|
143
|
+
"path"
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
_dec9,
|
|
147
|
+
0,
|
|
148
|
+
"serverName"
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
_dec10,
|
|
152
|
+
0,
|
|
153
|
+
"serverType"
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
_dec11,
|
|
157
|
+
0,
|
|
158
|
+
"mcpMethod"
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
_dec12,
|
|
162
|
+
0,
|
|
163
|
+
"toolName"
|
|
164
|
+
],
|
|
165
|
+
[
|
|
166
|
+
_dec13,
|
|
167
|
+
0,
|
|
168
|
+
"resourceUri"
|
|
169
|
+
],
|
|
170
|
+
[
|
|
171
|
+
_dec14,
|
|
172
|
+
0,
|
|
173
|
+
"promptName"
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
_dec15,
|
|
177
|
+
0,
|
|
178
|
+
"durationMs"
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
_dec16,
|
|
182
|
+
0,
|
|
183
|
+
"httpStatus"
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
_dec17,
|
|
187
|
+
0,
|
|
188
|
+
"errorMessage"
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
_dec18,
|
|
192
|
+
0,
|
|
193
|
+
"errorCode"
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
_dec19,
|
|
197
|
+
0,
|
|
198
|
+
"clientIp"
|
|
199
|
+
],
|
|
200
|
+
[
|
|
201
|
+
_dec20,
|
|
202
|
+
0,
|
|
203
|
+
"userAgent"
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
_dec21,
|
|
207
|
+
0,
|
|
208
|
+
"userId"
|
|
209
|
+
],
|
|
210
|
+
[
|
|
211
|
+
_dec22,
|
|
212
|
+
0,
|
|
213
|
+
"requestHeaders"
|
|
214
|
+
],
|
|
215
|
+
[
|
|
216
|
+
_dec23,
|
|
217
|
+
0,
|
|
218
|
+
"requestBody"
|
|
219
|
+
],
|
|
220
|
+
[
|
|
221
|
+
_dec24,
|
|
222
|
+
0,
|
|
223
|
+
"responseMeta"
|
|
224
|
+
],
|
|
225
|
+
[
|
|
226
|
+
_dec25,
|
|
227
|
+
0,
|
|
228
|
+
"createdAt"
|
|
229
|
+
],
|
|
230
|
+
[
|
|
231
|
+
_dec26,
|
|
232
|
+
0,
|
|
233
|
+
"updatedAt"
|
|
234
|
+
]
|
|
235
|
+
], [
|
|
236
|
+
_dec
|
|
237
|
+
]));
|
|
238
|
+
}
|
|
239
|
+
id = (_initProto(this), _init_id(this));
|
|
240
|
+
requestId = _init_requestId(this);
|
|
241
|
+
sessionId = _init_sessionId(this);
|
|
242
|
+
requestedAt = _init_requestedAt(this, new Date());
|
|
243
|
+
completedAt = _init_completedAt(this);
|
|
244
|
+
status = _init_status(this, RequestStatus.Pending);
|
|
245
|
+
method = _init_method(this);
|
|
246
|
+
path = _init_path(this);
|
|
247
|
+
serverName = _init_serverName(this);
|
|
248
|
+
serverType = _init_serverType(this, McpServerType.Custom);
|
|
249
|
+
mcpMethod = _init_mcpMethod(this, McpRequestType.Other);
|
|
250
|
+
toolName = _init_toolName(this);
|
|
251
|
+
resourceUri = _init_resourceUri(this);
|
|
252
|
+
promptName = _init_promptName(this);
|
|
253
|
+
durationMs = _init_durationMs(this);
|
|
254
|
+
httpStatus = _init_httpStatus(this);
|
|
255
|
+
errorMessage = _init_errorMessage(this);
|
|
256
|
+
errorCode = _init_errorCode(this);
|
|
257
|
+
clientIp = _init_clientIp(this);
|
|
258
|
+
userAgent = _init_userAgent(this);
|
|
259
|
+
userId = _init_userId(this);
|
|
260
|
+
requestHeaders = _init_requestHeaders(this);
|
|
261
|
+
requestBody = _init_requestBody(this);
|
|
262
|
+
responseMeta = _init_responseMeta(this);
|
|
263
|
+
createdAt = _init_createdAt(this, new Date());
|
|
264
|
+
updatedAt = _init_updatedAt(this, new Date());
|
|
265
|
+
static{
|
|
266
|
+
_initClass();
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
export { _McpRequestEntity as McpRequestEntity };
|
|
270
|
+
|
|
271
|
+
//# sourceMappingURL=McpRequestEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/entities/McpRequestEntity.ts"],"sourcesContent":["import { Entity, Enum, PrimaryKey, Property } from '@mikro-orm/decorators/es';\n\n/**\n * MCP server type\n */\nexport const McpServerType = Object.freeze({\n\tTencentCls: 'tencent-cls',\n\tSql: 'sql',\n\tPrometheus: 'prometheus',\n\tRelay: 'relay',\n\tCustom: 'custom',\n} as const);\nexport type McpServerType = (typeof McpServerType)[keyof typeof McpServerType];\n\n/**\n * MCP request type (JSON-RPC method)\n */\nexport const McpRequestType = Object.freeze({\n\tInitialize: 'initialize',\n\tToolsList: 'tools/list',\n\tToolsCall: 'tools/call',\n\tResourcesList: 'resources/list',\n\tResourcesRead: 'resources/read',\n\tPromptsList: 'prompts/list',\n\tPromptsGet: 'prompts/get',\n\tCompletionComplete: 'completion/complete',\n\tLoggingSetLevel: 'logging/setLevel',\n\tPing: 'ping',\n\tOther: 'other',\n} as const);\nexport type McpRequestType = (typeof McpRequestType)[keyof typeof McpRequestType];\n\n/**\n * Request status\n */\nexport const RequestStatus = Object.freeze({\n\tPending: 'pending',\n\tSuccess: 'success',\n\tError: 'error',\n\tTimeout: 'timeout',\n} as const);\nexport type RequestStatus = (typeof RequestStatus)[keyof typeof RequestStatus];\n\n/**\n * MCP Request Entity for auditing\n */\n@Entity({ tableName: 'mcp_request' })\nexport class McpRequestEntity {\n\t@PrimaryKey({ type: 'integer' })\n\tid!: number;\n\n\t/** Unique request ID */\n\t@Property({ type: 'string' })\n\trequestId!: string;\n\n\t/** MCP session ID */\n\t@Property({ type: 'string', nullable: true })\n\tsessionId?: string;\n\n\t/** Request timestamp */\n\t@Property({ type: 'datetime' })\n\trequestedAt: Date = new Date();\n\n\t/** Response timestamp */\n\t@Property({ type: 'datetime', nullable: true })\n\tcompletedAt?: Date;\n\n\t/** Request status */\n\t@Enum(() => RequestStatus)\n\tstatus: RequestStatus = RequestStatus.Pending;\n\n\t/** HTTP method */\n\t@Property({ type: 'string' })\n\tmethod!: string;\n\n\t/** Request path */\n\t@Property({ type: 'string' })\n\tpath!: string;\n\n\t/** MCP server name */\n\t@Property({ type: 'string' })\n\tserverName!: string;\n\n\t/** MCP server type */\n\t@Enum(() => McpServerType)\n\tserverType: McpServerType = McpServerType.Custom;\n\n\t/** MCP request type (JSON-RPC method) */\n\t@Enum(() => McpRequestType)\n\tmcpMethod: McpRequestType = McpRequestType.Other;\n\n\t/** Tool name (for tools/call) */\n\t@Property({ type: 'string', nullable: true })\n\ttoolName?: string;\n\n\t/** Resource URI (for resources/read) */\n\t@Property({ type: 'string', nullable: true })\n\tresourceUri?: string;\n\n\t/** Prompt name (for prompts/get) */\n\t@Property({ type: 'string', nullable: true })\n\tpromptName?: string;\n\n\t/** Request duration in ms */\n\t@Property({ type: 'integer', nullable: true })\n\tdurationMs?: number;\n\n\t/** HTTP status code */\n\t@Property({ type: 'integer', nullable: true })\n\thttpStatus?: number;\n\n\t/** Error message */\n\t@Property({ type: 'text', nullable: true })\n\terrorMessage?: string;\n\n\t/** Error code */\n\t@Property({ type: 'string', nullable: true })\n\terrorCode?: string;\n\n\t/** Client IP */\n\t@Property({ type: 'string', nullable: true })\n\tclientIp?: string;\n\n\t/** User agent */\n\t@Property({ type: 'string', nullable: true })\n\tuserAgent?: string;\n\n\t/** User ID */\n\t@Property({ type: 'string', nullable: true })\n\tuserId?: string;\n\n\t/** Request headers (JSON) */\n\t@Property({ type: 'json', nullable: true })\n\trequestHeaders?: Record<string, string>;\n\n\t/** Request body (JSON) */\n\t@Property({ type: 'json', nullable: true })\n\trequestBody?: Record<string, unknown>;\n\n\t/** Response metadata (JSON) */\n\t@Property({ type: 'json', nullable: true })\n\tresponseMeta?: Record<string, unknown>;\n\n\t@Property({ type: 'datetime' })\n\tcreatedAt: Date = new Date();\n\n\t@Property({ type: 'datetime', onUpdate: () => new Date() })\n\tupdatedAt: Date = new Date();\n}\n"],"names":["id","requestId","sessionId","requestedAt","completedAt","status","method","path","serverName","serverType","mcpMethod","toolName","resourceUri","promptName","durationMs","httpStatus","errorMessage","errorCode","clientIp","userAgent","userId","requestHeaders","requestBody","responseMeta","createdAt","updatedAt","Entity","Enum","PrimaryKey","Property","McpServerType","Object","freeze","TencentCls","Sql","Prometheus","Relay","Custom","McpRequestType","Initialize","ToolsList","ToolsCall","ResourcesList","ResourcesRead","PromptsList","PromptsGet","CompletionComplete","LoggingSetLevel","Ping","Other","RequestStatus","Pending","Success","Error","Timeout","tableName","type","nullable","onUpdate","Date","McpRequestEntity"],"mappings":";6NAgDC,AACAA,UAEA,sBAAsB,GACtB,AACAC,iBAEA,mBAAmB,GACnB,AACAC,iBAEA,sBAAsB,GACtB,AACAC,mBAEA,uBAAuB,GACvB,AACAC,mBAEA,mBAAmB,GACnB,AACAC,cAEA,gBAAgB,GAChB,AACAC,cAEA,iBAAiB,GACjB,AACAC,YAEA,oBAAoB,GACpB,AACAC,kBAEA,oBAAoB,GACpB,AACAC,kBAEA,uCAAuC,GACvC,AACAC,iBAEA,+BAA+B,GAC/B,AACAC,gBAEA,sCAAsC,GACtC,AACAC,mBAEA,kCAAkC,GAClC,AACAC,kBAEA,2BAA2B,GAC3B,AACAC,kBAEA,qBAAqB,GACrB,AACAC,kBAEA,kBAAkB,GAClB,AACAC,oBAEA,eAAe,GACf,AACAC,iBAEA,cAAc,GACd,AACAC,gBAEA,eAAe,GACf,AACAC,iBAEA,YAAY,GACZ,AACAC,cAEA,2BAA2B,GAC3B,AACAC,sBAEA,wBAAwB,GACxB,AACAC,mBAEA,6BAA6B,GAC7B,AACAC,oBAEA,AACAC,iBAEA,AACAC;AAnJD,SAASC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,2BAA2B;AAE9E;;CAEC,GACD,OAAO,MAAMC,gBAAgBC,OAAOC,MAAM,CAAC;IAC1CC,YAAY;IACZC,KAAK;IACLC,YAAY;IACZC,OAAO;IACPC,QAAQ;AACT,GAAY;AAGZ;;CAEC,GACD,OAAO,MAAMC,iBAAiBP,OAAOC,MAAM,CAAC;IAC3CO,YAAY;IACZC,WAAW;IACXC,WAAW;IACXC,eAAe;IACfC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,oBAAoB;IACpBC,iBAAiB;IACjBC,MAAM;IACNC,OAAO;AACR,GAAY;AAGZ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