langmart-gateway-type3 3.0.44 → 3.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-tools.d.ts +46 -0
- package/dist/admin-tools.d.ts.map +1 -0
- package/dist/admin-tools.js +933 -0
- package/dist/admin-tools.js.map +1 -0
- package/dist/agent-tools.d.ts +38 -0
- package/dist/agent-tools.d.ts.map +1 -0
- package/dist/agent-tools.js +813 -0
- package/dist/agent-tools.js.map +1 -0
- package/dist/billing-tools.d.ts +25 -0
- package/dist/billing-tools.d.ts.map +1 -0
- package/dist/billing-tools.js +283 -0
- package/dist/billing-tools.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +792 -0
- package/dist/cli.js.map +1 -0
- package/dist/collection-tools.d.ts +26 -0
- package/dist/collection-tools.d.ts.map +1 -0
- package/dist/collection-tools.js +347 -0
- package/dist/collection-tools.js.map +1 -0
- package/dist/lib/tool-schema-validator.d.ts +35 -0
- package/dist/lib/tool-schema-validator.d.ts.map +1 -0
- package/dist/lib/tool-schema-validator.js +146 -0
- package/dist/lib/tool-schema-validator.js.map +1 -0
- package/dist/marketplace-tools.d.ts +116 -0
- package/dist/marketplace-tools.d.ts.map +1 -0
- package/dist/marketplace-tools.js +3089 -0
- package/dist/marketplace-tools.js.map +1 -0
- package/dist/organization-tools.d.ts +37 -0
- package/dist/organization-tools.d.ts.map +1 -0
- package/dist/organization-tools.js +609 -0
- package/dist/organization-tools.js.map +1 -0
- package/dist/seller-tools.d.ts +28 -0
- package/dist/seller-tools.d.ts.map +1 -0
- package/dist/seller-tools.js +437 -0
- package/dist/seller-tools.js.map +1 -0
- package/dist/src/mcp-tools/gateway-tools.d.ts +107 -0
- package/dist/src/mcp-tools/gateway-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/gateway-tools.js +398 -0
- package/dist/src/mcp-tools/gateway-tools.js.map +1 -0
- package/dist/src/types/mcp-types.d.ts +76 -0
- package/dist/src/types/mcp-types.d.ts.map +1 -0
- package/dist/src/types/mcp-types.js +54 -0
- package/dist/src/types/mcp-types.js.map +1 -0
- package/dist/support-tools.d.ts +23 -0
- package/dist/support-tools.d.ts.map +1 -0
- package/dist/support-tools.js +292 -0
- package/dist/support-tools.js.map +1 -0
- package/dist/test-key-redaction-integration.d.ts +7 -0
- package/dist/test-key-redaction-integration.d.ts.map +1 -0
- package/dist/test-key-redaction-integration.js +80 -0
- package/dist/test-key-redaction-integration.js.map +1 -0
- package/dist/test-key-redaction.d.ts +6 -0
- package/dist/test-key-redaction.d.ts.map +1 -0
- package/dist/test-key-redaction.js +115 -0
- package/dist/test-key-redaction.js.map +1 -0
- package/dist/test-vault-migration.d.ts +2 -0
- package/dist/test-vault-migration.d.ts.map +1 -0
- package/dist/test-vault-migration.js +130 -0
- package/dist/test-vault-migration.js.map +1 -0
- package/dist/user-tools.d.ts +40 -0
- package/dist/user-tools.d.ts.map +1 -0
- package/dist/user-tools.js +685 -0
- package/dist/user-tools.js.map +1 -0
- package/package.json +2 -69
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Support Tools - MCP Tools for Support Ticket Management
|
|
4
|
+
*
|
|
5
|
+
* Provides tools for:
|
|
6
|
+
* - Support tickets (list, create, get, reply, close)
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SupportTools = exports.supportToolDefinitions = void 0;
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
// ============= TOOL DEFINITIONS =============
|
|
15
|
+
exports.supportToolDefinitions = [
|
|
16
|
+
{
|
|
17
|
+
type: 'function',
|
|
18
|
+
function: {
|
|
19
|
+
name: 'support_tickets_list',
|
|
20
|
+
description: 'List all support tickets for the user. Response includes cross-referenced IDs: organization_id (use organizations_get for org details), user_id (reporter info), related_request_log_id (the inference request that triggered this ticket). The related_context field contains request details like model, provider, latency_ms, error_message.',
|
|
21
|
+
parameters: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
status: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Filter by ticket status',
|
|
27
|
+
enum: ['open', 'pending', 'resolved', 'closed', 'all'],
|
|
28
|
+
default: 'all'
|
|
29
|
+
},
|
|
30
|
+
limit: {
|
|
31
|
+
type: 'number',
|
|
32
|
+
description: 'Maximum number of tickets to return (default: 10). Use pagination for more results.',
|
|
33
|
+
default: 10
|
|
34
|
+
},
|
|
35
|
+
offset: {
|
|
36
|
+
type: 'number',
|
|
37
|
+
description: 'Number of tickets to skip',
|
|
38
|
+
default: 0
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
required: []
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
metadata: {
|
|
45
|
+
category: 'support',
|
|
46
|
+
defaultEnabled: true,
|
|
47
|
+
adminOnly: false,
|
|
48
|
+
destructive: false,
|
|
49
|
+
requiresConfirmation: false,
|
|
50
|
+
apiEndpoint: '/api/support/tickets',
|
|
51
|
+
apiMethod: 'GET',
|
|
52
|
+
tags: ['support', 'tickets', 'list']
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'function',
|
|
57
|
+
function: {
|
|
58
|
+
name: 'support_tickets_create',
|
|
59
|
+
description: 'Create a new support ticket.',
|
|
60
|
+
parameters: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
subject: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'Ticket subject line'
|
|
66
|
+
},
|
|
67
|
+
description: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Detailed description of the issue'
|
|
70
|
+
},
|
|
71
|
+
priority: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'Ticket priority',
|
|
74
|
+
enum: ['low', 'medium', 'high', 'urgent'],
|
|
75
|
+
default: 'medium'
|
|
76
|
+
},
|
|
77
|
+
category: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Issue category',
|
|
80
|
+
enum: ['billing', 'technical', 'account', 'feature_request', 'other'],
|
|
81
|
+
default: 'other'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
required: ['subject', 'description']
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
metadata: {
|
|
88
|
+
category: 'support',
|
|
89
|
+
defaultEnabled: true,
|
|
90
|
+
adminOnly: false,
|
|
91
|
+
destructive: false,
|
|
92
|
+
requiresConfirmation: false,
|
|
93
|
+
apiEndpoint: '/api/support/tickets',
|
|
94
|
+
apiMethod: 'POST',
|
|
95
|
+
tags: ['support', 'tickets', 'create']
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'function',
|
|
100
|
+
function: {
|
|
101
|
+
name: 'support_tickets_get',
|
|
102
|
+
description: 'Get details of a specific support ticket including messages.',
|
|
103
|
+
parameters: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
properties: {
|
|
106
|
+
ticket_id: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: 'Ticket ID. Use support_tickets_list first to find available ticket IDs.'
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
required: ['ticket_id']
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
metadata: {
|
|
115
|
+
category: 'support',
|
|
116
|
+
defaultEnabled: true,
|
|
117
|
+
adminOnly: false,
|
|
118
|
+
destructive: false,
|
|
119
|
+
requiresConfirmation: false,
|
|
120
|
+
apiEndpoint: '/api/support/tickets/:id',
|
|
121
|
+
apiMethod: 'GET',
|
|
122
|
+
tags: ['support', 'tickets', 'get']
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: 'function',
|
|
127
|
+
function: {
|
|
128
|
+
name: 'support_tickets_reply',
|
|
129
|
+
description: 'Reply to an existing support ticket.',
|
|
130
|
+
parameters: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
ticket_id: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'Ticket ID. Use support_tickets_list first to find available ticket IDs.'
|
|
136
|
+
},
|
|
137
|
+
message: {
|
|
138
|
+
type: 'string',
|
|
139
|
+
description: 'Reply message'
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
required: ['ticket_id', 'message']
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
metadata: {
|
|
146
|
+
category: 'support',
|
|
147
|
+
defaultEnabled: true,
|
|
148
|
+
adminOnly: false,
|
|
149
|
+
destructive: false,
|
|
150
|
+
requiresConfirmation: false,
|
|
151
|
+
apiEndpoint: '/api/support/tickets/:id/reply',
|
|
152
|
+
apiMethod: 'POST',
|
|
153
|
+
tags: ['support', 'tickets', 'reply']
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'function',
|
|
158
|
+
function: {
|
|
159
|
+
name: 'support_tickets_close',
|
|
160
|
+
description: 'Close an open support ticket.',
|
|
161
|
+
parameters: {
|
|
162
|
+
type: 'object',
|
|
163
|
+
properties: {
|
|
164
|
+
ticket_id: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Ticket ID to close. Use support_tickets_list first to find available ticket IDs.'
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
required: ['ticket_id']
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
metadata: {
|
|
173
|
+
category: 'support',
|
|
174
|
+
defaultEnabled: true,
|
|
175
|
+
adminOnly: false,
|
|
176
|
+
destructive: false,
|
|
177
|
+
requiresConfirmation: true,
|
|
178
|
+
apiEndpoint: '/api/support/tickets/:id/close',
|
|
179
|
+
apiMethod: 'POST',
|
|
180
|
+
tags: ['support', 'tickets', 'close']
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
// ============= TOOL EXECUTOR =============
|
|
185
|
+
class SupportTools {
|
|
186
|
+
constructor(registryUrl, apiKey) {
|
|
187
|
+
this.client = axios_1.default.create({
|
|
188
|
+
baseURL: registryUrl,
|
|
189
|
+
timeout: 30000,
|
|
190
|
+
headers: {
|
|
191
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
192
|
+
'Content-Type': 'application/json'
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
static getInstance(registryUrl, apiKey) {
|
|
197
|
+
if (!SupportTools.instance && registryUrl && apiKey) {
|
|
198
|
+
SupportTools.instance = new SupportTools(registryUrl, apiKey);
|
|
199
|
+
}
|
|
200
|
+
if (!SupportTools.instance) {
|
|
201
|
+
throw new Error('SupportTools not initialized.');
|
|
202
|
+
}
|
|
203
|
+
return SupportTools.instance;
|
|
204
|
+
}
|
|
205
|
+
getTools() {
|
|
206
|
+
return exports.supportToolDefinitions;
|
|
207
|
+
}
|
|
208
|
+
async executeTool(toolName, args) {
|
|
209
|
+
try {
|
|
210
|
+
switch (toolName) {
|
|
211
|
+
case 'support_tickets_list':
|
|
212
|
+
return await this.listTickets(args);
|
|
213
|
+
case 'support_tickets_create':
|
|
214
|
+
return await this.createTicket(args);
|
|
215
|
+
case 'support_tickets_get':
|
|
216
|
+
return await this.getTicket(args.ticket_id);
|
|
217
|
+
case 'support_tickets_reply':
|
|
218
|
+
return await this.replyToTicket(args);
|
|
219
|
+
case 'support_tickets_close':
|
|
220
|
+
return await this.closeTicket(args.ticket_id);
|
|
221
|
+
default:
|
|
222
|
+
return { success: false, error: `Unknown support tool: ${toolName}` };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
return { success: false, error: error.response?.data?.error?.message || error.message };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async listTickets(args) {
|
|
230
|
+
const params = {
|
|
231
|
+
...(args.status !== 'all' ? { status: args.status } : {}),
|
|
232
|
+
limit: args.limit || 10,
|
|
233
|
+
offset: args.offset || 0
|
|
234
|
+
};
|
|
235
|
+
const response = await this.client.get('/api/support/tickets', { params });
|
|
236
|
+
const data = response.data;
|
|
237
|
+
// Optimization: Filter output to reduce token usage
|
|
238
|
+
// Only return essential fields unless specifically requested otherwise in future
|
|
239
|
+
const simplifiedTickets = data.tickets.map((t) => ({
|
|
240
|
+
id: t.id,
|
|
241
|
+
ticket_number: t.ticket_number,
|
|
242
|
+
title: t.title,
|
|
243
|
+
status: t.status,
|
|
244
|
+
priority: t.priority,
|
|
245
|
+
created_at: t.created_at,
|
|
246
|
+
// Exclude description, related_context, etc. to save tokens
|
|
247
|
+
}));
|
|
248
|
+
return {
|
|
249
|
+
success: true,
|
|
250
|
+
output: JSON.stringify({
|
|
251
|
+
tickets: simplifiedTickets,
|
|
252
|
+
count: simplifiedTickets.length,
|
|
253
|
+
total_available: data.count,
|
|
254
|
+
pagination: {
|
|
255
|
+
limit: params.limit,
|
|
256
|
+
offset: params.offset
|
|
257
|
+
}
|
|
258
|
+
}, null, 2),
|
|
259
|
+
data: data // Keep full data in 'data' field for programmatic use if needed
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
async createTicket(args) {
|
|
263
|
+
const response = await this.client.post('/api/support/tickets', args);
|
|
264
|
+
return {
|
|
265
|
+
success: true,
|
|
266
|
+
output: JSON.stringify(response.data, null, 2),
|
|
267
|
+
data: response.data
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
async getTicket(ticketId) {
|
|
271
|
+
const response = await this.client.get(`/api/support/tickets/${ticketId}`);
|
|
272
|
+
return {
|
|
273
|
+
success: true,
|
|
274
|
+
output: JSON.stringify(response.data, null, 2),
|
|
275
|
+
data: response.data
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
async replyToTicket(args) {
|
|
279
|
+
await this.client.post(`/api/support/tickets/${args.ticket_id}/reply`, {
|
|
280
|
+
message: args.message
|
|
281
|
+
});
|
|
282
|
+
return { success: true, output: `✅ Reply sent to ticket ${args.ticket_id}` };
|
|
283
|
+
}
|
|
284
|
+
async closeTicket(ticketId) {
|
|
285
|
+
await this.client.post(`/api/support/tickets/${ticketId}/close`);
|
|
286
|
+
return { success: true, output: `✅ Ticket ${ticketId} closed.` };
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.SupportTools = SupportTools;
|
|
290
|
+
SupportTools.instance = null;
|
|
291
|
+
exports.default = SupportTools;
|
|
292
|
+
//# sourceMappingURL=support-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support-tools.js","sourceRoot":"","sources":["../support-tools.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,kDAA6C;AAG7C,+CAA+C;AAElC,QAAA,sBAAsB,GAAwB;IACvD;QACI,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACN,IAAI,EAAE,sBAAsB;YAC5B,WAAW,EAAE,iVAAiV;YAC9V,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,MAAM,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,yBAAyB;wBACtC,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC;wBACtD,OAAO,EAAE,KAAK;qBACjB;oBACD,KAAK,EAAE;wBACH,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,qFAAqF;wBAClG,OAAO,EAAE,EAAE;qBACd;oBACD,MAAM,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,2BAA2B;wBACxC,OAAO,EAAE,CAAC;qBACb;iBACJ;gBACD,QAAQ,EAAE,EAAE;aACf;SACJ;QACD,QAAQ,EAAE;YACN,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,I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AC,SAAS,CAAC,QAAgB;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;QAC3E,OAAO;YACH,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9C,IAAI,EAAE,QAAQ,CAAC,IAAI;SACtB,CAAC;IACN,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,IAAS;QACjC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,IAAI,CAAC,SAAS,QAAQ,EAAE;YACnE,OAAO,EAAE,IAAI,CAAC,OAAO;SACxB,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,0BAA0B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;IACjF,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,QAAgB;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,QAAQ,QAAQ,CAAC,CAAC;QACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,QAAQ,UAAU,EAAE,CAAC;IACrE,CAAC;;AAnHL,oCAoHC;AAnHkB,qBAAQ,GAAwB,IAAI,CAAC;AAqHxD,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-key-redaction-integration.d.ts","sourceRoot":"","sources":["../test-key-redaction-integration.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Integration test for KeyVault with marketplace tools
|
|
5
|
+
* Tests that API keys are redacted before being sent to LLM
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const key_vault_1 = require("./key-vault");
|
|
9
|
+
console.log('='.repeat(80));
|
|
10
|
+
console.log('KeyVault Integration Test - Message Flow Simulation');
|
|
11
|
+
console.log('='.repeat(80));
|
|
12
|
+
console.log();
|
|
13
|
+
const vault = new key_vault_1.KeyVault();
|
|
14
|
+
// Simulate user typing a message with API keys
|
|
15
|
+
const userMessage = `
|
|
16
|
+
I want to test my connections with these API keys:
|
|
17
|
+
- OpenAI: sk-1234567890abcdef1234567890abcdef1234567890abcd
|
|
18
|
+
- Groq: gsk_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJ
|
|
19
|
+
- Google Gemini: AIzaSyABCDEFGHIJKLMNOPQRSTUVWXYZ123456
|
|
20
|
+
`;
|
|
21
|
+
console.log('📝 User Input:');
|
|
22
|
+
console.log(userMessage);
|
|
23
|
+
console.log();
|
|
24
|
+
// Step 1: Redact keys before sending to LLM (this is what happens in cli-split-layout.tsx:1108)
|
|
25
|
+
console.log('🔐 Step 1: Redacting API keys before sending to LLM...');
|
|
26
|
+
const redactedMessage = vault.processOutgoingMessage(userMessage);
|
|
27
|
+
console.log();
|
|
28
|
+
console.log('📤 Message sent to LLM (REDACTED):');
|
|
29
|
+
console.log(redactedMessage);
|
|
30
|
+
console.log();
|
|
31
|
+
// Simulate LLM echoing back the keys in its response
|
|
32
|
+
const llmResponse = `
|
|
33
|
+
I can help you test your connections. I see you have:
|
|
34
|
+
- OpenAI key: ${redactedMessage.match(/sk-[a-f0-9]+/)?.[0] || 'sk-xxx'}
|
|
35
|
+
- Groq key: ${redactedMessage.match(/gsk_[A-Za-z0-9]+/)?.[0] || 'gsk_xxx'}
|
|
36
|
+
- Google Gemini key: ${redactedMessage.match(/AIza[A-Za-z0-9_\\-]+/)?.[0] || 'AIza_xxx'}
|
|
37
|
+
|
|
38
|
+
Let me test these connections for you.
|
|
39
|
+
`;
|
|
40
|
+
console.log('🤖 LLM Response (with redacted keys):');
|
|
41
|
+
console.log(llmResponse);
|
|
42
|
+
console.log();
|
|
43
|
+
// Step 2: Restore keys before showing to user (this is what happens in cli-split-layout.tsx:1201-1204)
|
|
44
|
+
console.log('🔓 Step 2: Restoring real API keys before displaying to user...');
|
|
45
|
+
const restoredResponse = vault.processIncomingMessage(llmResponse);
|
|
46
|
+
console.log();
|
|
47
|
+
console.log('📥 Response shown to user (RESTORED):');
|
|
48
|
+
console.log(restoredResponse);
|
|
49
|
+
console.log();
|
|
50
|
+
// Step 3: Show vault statistics
|
|
51
|
+
console.log('📊 Vault Statistics:');
|
|
52
|
+
const stats = vault.getStats();
|
|
53
|
+
console.log(`Total keys protected: ${stats.totalKeys}`);
|
|
54
|
+
console.log(`By provider:`, stats.byProvider);
|
|
55
|
+
console.log();
|
|
56
|
+
// Step 4: Show key details
|
|
57
|
+
console.log('🔍 Key Details:');
|
|
58
|
+
const allKeys = vault.getAllKeysInfo();
|
|
59
|
+
allKeys.forEach((key, index) => {
|
|
60
|
+
console.log(` ${index + 1}. ${key.provider} (${key.redactedPrefix})`);
|
|
61
|
+
console.log(` Age: ${key.ageMinutes.toFixed(2)} min, Used: ${key.useCount} times`);
|
|
62
|
+
});
|
|
63
|
+
console.log();
|
|
64
|
+
// Verify keys are different
|
|
65
|
+
console.log('✅ Verification:');
|
|
66
|
+
console.log(`Original contains real OpenAI key: ${userMessage.includes('sk-1234567890abcdef1234567890abcdef1234567890abcd')}`);
|
|
67
|
+
console.log(`Redacted does NOT contain real OpenAI key: ${!redactedMessage.includes('sk-1234567890abcdef1234567890abcdef1234567890abcd')}`);
|
|
68
|
+
console.log(`Restored contains real OpenAI key: ${restoredResponse.includes('sk-1234567890abcdef1234567890abcdef1234567890abcd')}`);
|
|
69
|
+
console.log();
|
|
70
|
+
console.log('='.repeat(80));
|
|
71
|
+
console.log('✅ Integration Test Complete!');
|
|
72
|
+
console.log('='.repeat(80));
|
|
73
|
+
console.log();
|
|
74
|
+
console.log('📝 IMPORTANT: This demonstrates that:');
|
|
75
|
+
console.log(' 1. Real keys are detected in user input');
|
|
76
|
+
console.log(' 2. Keys are replaced with random values before sending to LLM');
|
|
77
|
+
console.log(' 3. Real keys are restored in LLM responses before showing to user');
|
|
78
|
+
console.log(' 4. The LLM NEVER sees the real API keys');
|
|
79
|
+
console.log();
|
|
80
|
+
//# sourceMappingURL=test-key-redaction-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-key-redaction-integration.js","sourceRoot":"","sources":["../test-key-redaction-integration.ts"],"names":[],"mappings":";;AACA;;;GAGG;;AAEH,2CAAuC;AAEvC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5B,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;AACnE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5B,OAAO,CAAC,GAAG,EAAE,CAAC;AAEd,MAAM,KAAK,GAAG,IAAI,oBAAQ,EAAE,CAAC;AAE7B,+CAA+C;AAC/C,MAAM,WAAW,GAAG;;;;;CAKnB,CAAC;AAEF,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC9B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACzB,OAAO,CAAC,GAAG,EAAE,CAAC;AAEd,gGAAgG;AAChG,OAAO,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC;AACtE,MAAM,eAAe,GAAG,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;AAClE,OAAO,CAAC,GAAG,EAAE,CAAC;AAEd,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAClD,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC7B,OAAO,CAAC,GAAG,EAAE,CAAC;AAEd,qDAAqD;AACrD,MAAM,WAAW,GAAG;;gBAEJ,eAAe,CAAC,KAAK,CA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":3,"file":"test-key-redaction.d.ts","sourceRoot":"","sources":["../test-key-redaction.ts"],"names":[],"mappings":";AACA;;GAEG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Test script for KeyVault API key redaction
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const key_vault_1 = require("./key-vault");
|
|
8
|
+
const vault = new key_vault_1.KeyVault();
|
|
9
|
+
console.log('='.repeat(80));
|
|
10
|
+
console.log('API Key Redaction Test');
|
|
11
|
+
console.log('='.repeat(80));
|
|
12
|
+
console.log();
|
|
13
|
+
// Test 1: OpenAI legacy key
|
|
14
|
+
console.log('Test 1: OpenAI Legacy Key');
|
|
15
|
+
const openaiMessage = "My OpenAI key is sk-1234567890abcdef1234567890abcdef1234567890abcd";
|
|
16
|
+
console.log(`Original: ${openaiMessage}`);
|
|
17
|
+
const { redactedText: redacted1, detectedCount: count1 } = vault.redactKeys(openaiMessage);
|
|
18
|
+
console.log(`Redacted: ${redacted1}`);
|
|
19
|
+
console.log(`Detected: ${count1} key(s)`);
|
|
20
|
+
console.log();
|
|
21
|
+
// Test 2: Groq key
|
|
22
|
+
console.log('Test 2: Groq Key');
|
|
23
|
+
const groqMessage = "Here's my Groq API key: gsk_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJ";
|
|
24
|
+
console.log(`Original: ${groqMessage}`);
|
|
25
|
+
const { redactedText: redacted2, detectedCount: count2 } = vault.redactKeys(groqMessage);
|
|
26
|
+
console.log(`Redacted: ${redacted2}`);
|
|
27
|
+
console.log(`Detected: ${count2} key(s)`);
|
|
28
|
+
console.log();
|
|
29
|
+
// Test 3: Google Gemini key
|
|
30
|
+
console.log('Test 3: Google Gemini Key');
|
|
31
|
+
const geminiMessage = "Use this key: AIzaSyABCDEFGHIJKLMNOPQRSTUVWXYZ123456";
|
|
32
|
+
console.log(`Original: ${geminiMessage}`);
|
|
33
|
+
const { redactedText: redacted3, detectedCount: count3 } = vault.redactKeys(geminiMessage);
|
|
34
|
+
console.log(`Redacted: ${redacted3}`);
|
|
35
|
+
console.log(`Detected: ${count3} key(s)`);
|
|
36
|
+
console.log();
|
|
37
|
+
// Test 4: Anthropic key
|
|
38
|
+
console.log('Test 4: Anthropic Claude Key');
|
|
39
|
+
const anthropicMessage = "My Claude key is sk-ant-api03-R2D2C3P0ABCDEFGHIJKLMNOPQ-igAA";
|
|
40
|
+
console.log(`Original: ${anthropicMessage}`);
|
|
41
|
+
const { redactedText: redacted4, detectedCount: count4 } = vault.redactKeys(anthropicMessage);
|
|
42
|
+
console.log(`Redacted: ${redacted4}`);
|
|
43
|
+
console.log(`Detected: ${count4} key(s)`);
|
|
44
|
+
console.log();
|
|
45
|
+
// Test 5: OpenAI project key
|
|
46
|
+
console.log('Test 5: OpenAI Project Key');
|
|
47
|
+
const openaiProjMessage = "New key: sk-proj-1234567890abcdef1234567890abcdef1234567890abcd";
|
|
48
|
+
console.log(`Original: ${openaiProjMessage}`);
|
|
49
|
+
const { redactedText: redacted5, detectedCount: count5 } = vault.redactKeys(openaiProjMessage);
|
|
50
|
+
console.log(`Redacted: ${redacted5}`);
|
|
51
|
+
console.log(`Detected: ${count5} key(s)`);
|
|
52
|
+
console.log();
|
|
53
|
+
// Test 6: Multiple keys in one message
|
|
54
|
+
console.log('Test 6: Multiple Keys in One Message');
|
|
55
|
+
const multiMessage = `I have sk-1234567890abcdef1234567890abcdef1234567890abcd for OpenAI and gsk_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJ for Groq`;
|
|
56
|
+
console.log(`Original: ${multiMessage}`);
|
|
57
|
+
const { redactedText: redacted6, detectedCount: count6 } = vault.redactKeys(multiMessage);
|
|
58
|
+
console.log(`Redacted: ${redacted6}`);
|
|
59
|
+
console.log(`Detected: ${count6} key(s)`);
|
|
60
|
+
console.log();
|
|
61
|
+
// Test 7: Restore keys
|
|
62
|
+
console.log('Test 7: Key Restoration');
|
|
63
|
+
const llmResponse = `I see you have the API key: ${redacted1.match(/sk-[a-f0-9]+/)?.[0]}`;
|
|
64
|
+
console.log(`LLM Response (with redacted key): ${llmResponse}`);
|
|
65
|
+
const { restoredText: restored7, restoredCount: restoreCount7 } = vault.restoreKeys(llmResponse);
|
|
66
|
+
console.log(`Restored Response: ${restored7}`);
|
|
67
|
+
console.log(`Restored: ${restoreCount7} key(s)`);
|
|
68
|
+
console.log();
|
|
69
|
+
// Test 8: Statistics
|
|
70
|
+
console.log('Test 8: Vault Statistics');
|
|
71
|
+
const stats = vault.getStats();
|
|
72
|
+
console.log(`Total keys stored: ${stats.totalKeys}`);
|
|
73
|
+
console.log(`By provider:`, stats.byProvider);
|
|
74
|
+
console.log(`Average age: ${stats.averageAge.toFixed(2)} minutes`);
|
|
75
|
+
if (stats.oldestKey) {
|
|
76
|
+
console.log(`Oldest key: ${stats.oldestKey.provider} (${stats.oldestKey.ageMinutes.toFixed(2)} minutes old)`);
|
|
77
|
+
}
|
|
78
|
+
if (stats.newestKey) {
|
|
79
|
+
console.log(`Newest key: ${stats.newestKey.provider} (${stats.newestKey.ageMinutes.toFixed(2)} minutes old)`);
|
|
80
|
+
}
|
|
81
|
+
console.log();
|
|
82
|
+
// Test 9: Detailed key info
|
|
83
|
+
console.log('Test 9: Detailed Key Information');
|
|
84
|
+
const allKeys = vault.getAllKeysInfo();
|
|
85
|
+
console.log('All keys in vault:');
|
|
86
|
+
allKeys.forEach((key, index) => {
|
|
87
|
+
console.log(` ${index + 1}. ${key.provider} (${key.redactedPrefix})`);
|
|
88
|
+
console.log(` Age: ${key.ageMinutes.toFixed(2)} min, Last used: ${key.lastUsedMinutes.toFixed(2)} min ago, Used: ${key.useCount} times`);
|
|
89
|
+
});
|
|
90
|
+
console.log();
|
|
91
|
+
// Test 10: Cleanup old keys (simulate old keys by checking 0 minutes)
|
|
92
|
+
console.log('Test 10: Cleanup Old Keys');
|
|
93
|
+
const oldKeys = vault.getOldKeys(0); // Get all keys (they're all "old" at 0 minutes threshold)
|
|
94
|
+
console.log(`Keys older than 0 minutes: ${oldKeys.length}`);
|
|
95
|
+
oldKeys.forEach(key => {
|
|
96
|
+
console.log(` - ${key.provider}: ${key.ageMinutes.toFixed(2)} min old, used ${key.useCount} times`);
|
|
97
|
+
});
|
|
98
|
+
console.log();
|
|
99
|
+
// Actually clean up keys older than 5 minutes (should be 0)
|
|
100
|
+
const removedOld = vault.cleanupOldKeys(5);
|
|
101
|
+
console.log(`Removed ${removedOld} keys older than 5 minutes`);
|
|
102
|
+
console.log();
|
|
103
|
+
// Test 11: Cleanup unused keys
|
|
104
|
+
console.log('Test 11: Cleanup Unused Keys');
|
|
105
|
+
const removedUnused = vault.cleanupUnusedKeys(0); // Remove keys never used
|
|
106
|
+
console.log(`Removed ${removedUnused} unused keys`);
|
|
107
|
+
console.log();
|
|
108
|
+
// Check stats after cleanup
|
|
109
|
+
const finalStats = vault.getStats();
|
|
110
|
+
console.log(`Final vault size: ${finalStats.totalKeys} keys`);
|
|
111
|
+
console.log();
|
|
112
|
+
console.log('='.repeat(80));
|
|
113
|
+
console.log('All tests complete!');
|
|
114
|
+
console.log('='.repeat(80));
|
|
115
|
+
//# sourceMappingURL=test-key-redaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-key-redaction.js","sourceRoot":"","sources":["../test-key-redaction.ts"],"names":[],"mappings":";;AACA;;GAEG;;AAEH,2CAAuC;AAEvC,MAAM,KAAK,GAAG,IAAI,oBAAQ,EAAE,CAAC;AAE7B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5B,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AACtC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5B,OAAO,CAAC,GAAG,EAAE,CAAC;AAEd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