@kaitranntt/ccs 7.31.1 → 7.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/cliproxy-executor.d.ts.map +1 -1
- package/dist/cliproxy/cliproxy-executor.js +60 -12
- package/dist/cliproxy/cliproxy-executor.js.map +1 -1
- package/dist/cliproxy/index.d.ts +6 -0
- package/dist/cliproxy/index.d.ts.map +1 -1
- package/dist/cliproxy/index.js +11 -1
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/tool-name-mapper.d.ts +103 -0
- package/dist/cliproxy/tool-name-mapper.d.ts.map +1 -0
- package/dist/cliproxy/tool-name-mapper.js +149 -0
- package/dist/cliproxy/tool-name-mapper.js.map +1 -0
- package/dist/cliproxy/tool-name-sanitizer.d.ts +65 -0
- package/dist/cliproxy/tool-name-sanitizer.d.ts.map +1 -0
- package/dist/cliproxy/tool-name-sanitizer.js +118 -0
- package/dist/cliproxy/tool-name-sanitizer.js.map +1 -0
- package/dist/cliproxy/tool-sanitization-proxy.d.ts +70 -0
- package/dist/cliproxy/tool-sanitization-proxy.d.ts.map +1 -0
- package/dist/cliproxy/tool-sanitization-proxy.js +453 -0
- package/dist/cliproxy/tool-sanitization-proxy.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Sanitization Proxy
|
|
4
|
+
*
|
|
5
|
+
* HTTP proxy that intercepts Claude CLI → CLIProxy requests to:
|
|
6
|
+
* 1. Sanitize MCP tool names exceeding Gemini's 64-char limit
|
|
7
|
+
* 2. Forward sanitized requests to upstream
|
|
8
|
+
* 3. Restore original names in responses
|
|
9
|
+
*
|
|
10
|
+
* Follows CodexReasoningProxy pattern for consistency.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ToolSanitizationProxy = void 0;
|
|
37
|
+
const http = __importStar(require("http"));
|
|
38
|
+
const https = __importStar(require("https"));
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
42
|
+
const url_1 = require("url");
|
|
43
|
+
const tool_name_mapper_1 = require("./tool-name-mapper");
|
|
44
|
+
const config_manager_1 = require("../utils/config-manager");
|
|
45
|
+
/**
|
|
46
|
+
* Type guard to check if a value is a plain object (Record).
|
|
47
|
+
* Used for safely accessing properties on unknown JSON values.
|
|
48
|
+
*/
|
|
49
|
+
function isRecord(value) {
|
|
50
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
class ToolSanitizationProxy {
|
|
53
|
+
constructor(config) {
|
|
54
|
+
this.server = null;
|
|
55
|
+
this.port = null;
|
|
56
|
+
this.config = {
|
|
57
|
+
upstreamBaseUrl: config.upstreamBaseUrl,
|
|
58
|
+
verbose: config.verbose ?? false,
|
|
59
|
+
warnOnSanitize: config.warnOnSanitize ?? true,
|
|
60
|
+
timeoutMs: config.timeoutMs ?? 120000,
|
|
61
|
+
};
|
|
62
|
+
this.debugMode = process.env.CCS_DEBUG === '1';
|
|
63
|
+
this.logFilePath = this.initLogFile();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Initialize log file path and ensure directory exists.
|
|
67
|
+
*/
|
|
68
|
+
initLogFile() {
|
|
69
|
+
const logsDir = path.join((0, config_manager_1.getCcsDir)(), 'logs');
|
|
70
|
+
try {
|
|
71
|
+
if (!fs.existsSync(logsDir)) {
|
|
72
|
+
fs.mkdirSync(logsDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
// Fallback to temp directory if logs dir creation fails
|
|
77
|
+
if (this.debugMode) {
|
|
78
|
+
console.error(`[tool-sanitization-proxy] Failed to create logs dir: ${err.message}`);
|
|
79
|
+
}
|
|
80
|
+
return path.join(os.tmpdir(), 'tool-sanitization-proxy.log');
|
|
81
|
+
}
|
|
82
|
+
return path.join(logsDir, 'tool-sanitization-proxy.log');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Write log entry to file (always) and console (if CCS_DEBUG=1).
|
|
86
|
+
*/
|
|
87
|
+
writeLog(level, message) {
|
|
88
|
+
const timestamp = new Date().toISOString();
|
|
89
|
+
const prefix = level === 'info' ? '[i]' : level === 'warn' ? '[!]' : '[X]';
|
|
90
|
+
const logLine = `${timestamp} ${prefix} ${message}\n`;
|
|
91
|
+
// Always write to file
|
|
92
|
+
try {
|
|
93
|
+
fs.appendFileSync(this.logFilePath, logLine);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Silently ignore file write errors
|
|
97
|
+
}
|
|
98
|
+
// Console output only in debug mode
|
|
99
|
+
if (this.debugMode) {
|
|
100
|
+
console.error(`${prefix} ${message}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
log(message) {
|
|
104
|
+
if (this.config.verbose) {
|
|
105
|
+
this.writeLog('info', `[tool-sanitization-proxy] ${message}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
warn(message) {
|
|
109
|
+
if (this.config.warnOnSanitize) {
|
|
110
|
+
this.writeLog('warn', `Tool name sanitized: ${message}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Start the proxy server on an ephemeral port.
|
|
115
|
+
* @returns The assigned port number
|
|
116
|
+
*/
|
|
117
|
+
async start() {
|
|
118
|
+
if (this.server)
|
|
119
|
+
return this.port ?? 0;
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
this.server = http.createServer((req, res) => {
|
|
122
|
+
void this.handleRequest(req, res);
|
|
123
|
+
});
|
|
124
|
+
this.server.listen(0, '127.0.0.1', () => {
|
|
125
|
+
const address = this.server?.address();
|
|
126
|
+
this.port = typeof address === 'object' && address ? address.port : 0;
|
|
127
|
+
this.writeLog('info', `Tool sanitization proxy active (port ${this.port})`);
|
|
128
|
+
resolve(this.port);
|
|
129
|
+
});
|
|
130
|
+
this.server.on('error', (err) => reject(err));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Stop the proxy server.
|
|
135
|
+
*/
|
|
136
|
+
stop() {
|
|
137
|
+
if (!this.server)
|
|
138
|
+
return;
|
|
139
|
+
this.server.close();
|
|
140
|
+
this.server = null;
|
|
141
|
+
this.port = null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get the port the proxy is listening on.
|
|
145
|
+
*/
|
|
146
|
+
getPort() {
|
|
147
|
+
return this.port;
|
|
148
|
+
}
|
|
149
|
+
readBody(req) {
|
|
150
|
+
return new Promise((resolve, reject) => {
|
|
151
|
+
const chunks = [];
|
|
152
|
+
const maxSize = 10 * 1024 * 1024; // 10MB
|
|
153
|
+
let total = 0;
|
|
154
|
+
req.on('data', (chunk) => {
|
|
155
|
+
total += chunk.length;
|
|
156
|
+
if (total > maxSize) {
|
|
157
|
+
req.destroy();
|
|
158
|
+
reject(new Error('Request body too large (max 10MB)'));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
chunks.push(chunk);
|
|
162
|
+
});
|
|
163
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
164
|
+
req.on('error', reject);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
async handleRequest(req, res) {
|
|
168
|
+
const method = req.method || 'GET';
|
|
169
|
+
const requestPath = req.url || '/';
|
|
170
|
+
const upstreamBase = new url_1.URL(this.config.upstreamBaseUrl);
|
|
171
|
+
const fullUpstreamUrl = new url_1.URL(requestPath, upstreamBase);
|
|
172
|
+
this.log(`${method} ${requestPath} → ${fullUpstreamUrl.href}`);
|
|
173
|
+
// Only buffer+rewrite JSON POST requests
|
|
174
|
+
const contentType = String(req.headers['content-type'] || '');
|
|
175
|
+
const isJson = contentType.includes('application/json');
|
|
176
|
+
const shouldRewrite = isJson && ['POST', 'PUT', 'PATCH'].includes(method.toUpperCase());
|
|
177
|
+
try {
|
|
178
|
+
if (!shouldRewrite) {
|
|
179
|
+
await this.forwardRaw(req, res, fullUpstreamUrl);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const rawBody = await this.readBody(req);
|
|
183
|
+
let parsed;
|
|
184
|
+
try {
|
|
185
|
+
parsed = rawBody.length ? JSON.parse(rawBody) : {};
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
189
|
+
res.end(JSON.stringify({ error: 'Invalid JSON in request body' }));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
// Create mapper for this request
|
|
193
|
+
const mapper = new tool_name_mapper_1.ToolNameMapper();
|
|
194
|
+
// Sanitize tools if present
|
|
195
|
+
let modifiedBody = parsed;
|
|
196
|
+
if (isRecord(parsed) && Array.isArray(parsed.tools)) {
|
|
197
|
+
const sanitizedTools = mapper.registerTools(parsed.tools);
|
|
198
|
+
modifiedBody = { ...parsed, tools: sanitizedTools };
|
|
199
|
+
// Log sanitization warnings
|
|
200
|
+
if (mapper.hasChanges()) {
|
|
201
|
+
const changes = mapper.getChanges();
|
|
202
|
+
for (const change of changes) {
|
|
203
|
+
this.warn(`"${change.original}" → "${change.sanitized}"`);
|
|
204
|
+
}
|
|
205
|
+
this.log(`Sanitized ${changes.length} tool name(s)`);
|
|
206
|
+
}
|
|
207
|
+
// Warn about hash collisions (multiple originals → same sanitized)
|
|
208
|
+
if (mapper.hasCollisions()) {
|
|
209
|
+
const collisions = mapper.getCollisions();
|
|
210
|
+
for (const collision of collisions) {
|
|
211
|
+
this.writeLog('warn', `[tool-sanitization-proxy] Hash collision detected: ${collision.originals.join(', ')} → "${collision.sanitized}"`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Check if streaming is requested
|
|
216
|
+
const isStreaming = isRecord(parsed) && parsed.stream === true;
|
|
217
|
+
if (isStreaming) {
|
|
218
|
+
await this.forwardJsonStreaming(req, res, fullUpstreamUrl, modifiedBody, mapper);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
await this.forwardJsonBuffered(req, res, fullUpstreamUrl, modifiedBody, mapper);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
const err = error;
|
|
226
|
+
this.log(`Error: ${err.message}`);
|
|
227
|
+
if (!res.headersSent) {
|
|
228
|
+
res.writeHead(502, { 'Content-Type': 'application/json' });
|
|
229
|
+
}
|
|
230
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
buildForwardHeaders(originalHeaders, bodyString) {
|
|
234
|
+
const headers = {};
|
|
235
|
+
// RFC 7230 hop-by-hop headers that should not be forwarded
|
|
236
|
+
const hopByHop = new Set([
|
|
237
|
+
'host',
|
|
238
|
+
'content-length',
|
|
239
|
+
'connection',
|
|
240
|
+
'transfer-encoding',
|
|
241
|
+
'keep-alive',
|
|
242
|
+
'proxy-authenticate',
|
|
243
|
+
'proxy-authorization',
|
|
244
|
+
'te',
|
|
245
|
+
'trailer',
|
|
246
|
+
'upgrade',
|
|
247
|
+
]);
|
|
248
|
+
for (const [key, value] of Object.entries(originalHeaders)) {
|
|
249
|
+
if (!value)
|
|
250
|
+
continue;
|
|
251
|
+
const lower = key.toLowerCase();
|
|
252
|
+
if (hopByHop.has(lower))
|
|
253
|
+
continue;
|
|
254
|
+
headers[key] = value;
|
|
255
|
+
}
|
|
256
|
+
if (bodyString !== undefined) {
|
|
257
|
+
headers['Content-Type'] = headers['Content-Type'] || 'application/json';
|
|
258
|
+
headers['Content-Length'] = Buffer.byteLength(bodyString);
|
|
259
|
+
}
|
|
260
|
+
return headers;
|
|
261
|
+
}
|
|
262
|
+
getRequestFn(url) {
|
|
263
|
+
return url.protocol === 'https:' ? https.request : http.request;
|
|
264
|
+
}
|
|
265
|
+
forwardRaw(originalReq, clientRes, upstreamUrl) {
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
267
|
+
const requestFn = this.getRequestFn(upstreamUrl);
|
|
268
|
+
const upstreamReq = requestFn({
|
|
269
|
+
protocol: upstreamUrl.protocol,
|
|
270
|
+
hostname: upstreamUrl.hostname,
|
|
271
|
+
port: upstreamUrl.port,
|
|
272
|
+
path: upstreamUrl.pathname + upstreamUrl.search,
|
|
273
|
+
method: originalReq.method,
|
|
274
|
+
timeout: this.config.timeoutMs,
|
|
275
|
+
headers: this.buildForwardHeaders(originalReq.headers),
|
|
276
|
+
}, (upstreamRes) => {
|
|
277
|
+
clientRes.writeHead(upstreamRes.statusCode || 200, upstreamRes.headers);
|
|
278
|
+
upstreamRes.pipe(clientRes);
|
|
279
|
+
upstreamRes.on('end', () => resolve());
|
|
280
|
+
upstreamRes.on('error', reject);
|
|
281
|
+
});
|
|
282
|
+
upstreamReq.on('timeout', () => upstreamReq.destroy(new Error('Upstream request timeout')));
|
|
283
|
+
upstreamReq.on('error', reject);
|
|
284
|
+
originalReq.pipe(upstreamReq);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Forward JSON request and buffer response for tool name restoration.
|
|
289
|
+
*/
|
|
290
|
+
forwardJsonBuffered(originalReq, clientRes, upstreamUrl, body, mapper) {
|
|
291
|
+
return new Promise((resolve, reject) => {
|
|
292
|
+
const bodyString = JSON.stringify(body);
|
|
293
|
+
const requestFn = this.getRequestFn(upstreamUrl);
|
|
294
|
+
const upstreamReq = requestFn({
|
|
295
|
+
protocol: upstreamUrl.protocol,
|
|
296
|
+
hostname: upstreamUrl.hostname,
|
|
297
|
+
port: upstreamUrl.port,
|
|
298
|
+
path: upstreamUrl.pathname + upstreamUrl.search,
|
|
299
|
+
method: originalReq.method,
|
|
300
|
+
timeout: this.config.timeoutMs,
|
|
301
|
+
headers: this.buildForwardHeaders(originalReq.headers, bodyString),
|
|
302
|
+
}, (upstreamRes) => {
|
|
303
|
+
const chunks = [];
|
|
304
|
+
upstreamRes.on('data', (chunk) => chunks.push(chunk));
|
|
305
|
+
upstreamRes.on('end', () => {
|
|
306
|
+
try {
|
|
307
|
+
const responseBody = Buffer.concat(chunks).toString('utf8');
|
|
308
|
+
const contentType = upstreamRes.headers['content-type'] || '';
|
|
309
|
+
// Only process JSON responses with tool_use blocks
|
|
310
|
+
if (contentType.includes('application/json') && mapper.hasChanges()) {
|
|
311
|
+
try {
|
|
312
|
+
const parsed = JSON.parse(responseBody);
|
|
313
|
+
if (isRecord(parsed) && Array.isArray(parsed.content)) {
|
|
314
|
+
parsed.content = mapper.restoreToolUse(parsed.content);
|
|
315
|
+
const modifiedResponse = JSON.stringify(parsed);
|
|
316
|
+
// Update content-length header
|
|
317
|
+
const headers = { ...upstreamRes.headers };
|
|
318
|
+
headers['content-length'] = String(Buffer.byteLength(modifiedResponse));
|
|
319
|
+
clientRes.writeHead(upstreamRes.statusCode || 200, headers);
|
|
320
|
+
clientRes.end(modifiedResponse);
|
|
321
|
+
resolve();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
// JSON parse failed, pass through unchanged
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// Pass through unchanged
|
|
330
|
+
clientRes.writeHead(upstreamRes.statusCode || 200, upstreamRes.headers);
|
|
331
|
+
clientRes.end(responseBody);
|
|
332
|
+
resolve();
|
|
333
|
+
}
|
|
334
|
+
catch (err) {
|
|
335
|
+
reject(err);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
upstreamRes.on('error', reject);
|
|
339
|
+
});
|
|
340
|
+
upstreamReq.on('timeout', () => upstreamReq.destroy(new Error('Upstream request timeout')));
|
|
341
|
+
upstreamReq.on('error', reject);
|
|
342
|
+
upstreamReq.write(bodyString);
|
|
343
|
+
upstreamReq.end();
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Forward JSON request and stream response with tool name restoration.
|
|
348
|
+
* Handles SSE (Server-Sent Events) format.
|
|
349
|
+
*/
|
|
350
|
+
forwardJsonStreaming(originalReq, clientRes, upstreamUrl, body, mapper) {
|
|
351
|
+
return new Promise((resolve, reject) => {
|
|
352
|
+
const bodyString = JSON.stringify(body);
|
|
353
|
+
const requestFn = this.getRequestFn(upstreamUrl);
|
|
354
|
+
const upstreamReq = requestFn({
|
|
355
|
+
protocol: upstreamUrl.protocol,
|
|
356
|
+
hostname: upstreamUrl.hostname,
|
|
357
|
+
port: upstreamUrl.port,
|
|
358
|
+
path: upstreamUrl.pathname + upstreamUrl.search,
|
|
359
|
+
method: originalReq.method,
|
|
360
|
+
timeout: this.config.timeoutMs,
|
|
361
|
+
headers: this.buildForwardHeaders(originalReq.headers, bodyString),
|
|
362
|
+
}, (upstreamRes) => {
|
|
363
|
+
clientRes.writeHead(upstreamRes.statusCode || 200, upstreamRes.headers);
|
|
364
|
+
// If no changes were made, just pipe through
|
|
365
|
+
if (!mapper.hasChanges()) {
|
|
366
|
+
upstreamRes.pipe(clientRes);
|
|
367
|
+
upstreamRes.on('end', () => resolve());
|
|
368
|
+
upstreamRes.on('error', reject);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
// Process SSE events for tool name restoration
|
|
372
|
+
let buffer = '';
|
|
373
|
+
upstreamRes.on('data', (chunk) => {
|
|
374
|
+
buffer += chunk.toString('utf8');
|
|
375
|
+
// Process complete SSE events
|
|
376
|
+
const events = buffer.split('\n\n');
|
|
377
|
+
buffer = events.pop() || ''; // Keep incomplete event in buffer
|
|
378
|
+
for (const event of events) {
|
|
379
|
+
if (!event.trim())
|
|
380
|
+
continue;
|
|
381
|
+
const processedEvent = this.processSSEEvent(event, mapper);
|
|
382
|
+
clientRes.write(processedEvent + '\n\n');
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
upstreamRes.on('end', () => {
|
|
386
|
+
// Process any remaining buffer
|
|
387
|
+
if (buffer.trim()) {
|
|
388
|
+
const processedEvent = this.processSSEEvent(buffer, mapper);
|
|
389
|
+
clientRes.write(processedEvent + '\n\n');
|
|
390
|
+
}
|
|
391
|
+
clientRes.end();
|
|
392
|
+
resolve();
|
|
393
|
+
});
|
|
394
|
+
upstreamRes.on('error', reject);
|
|
395
|
+
});
|
|
396
|
+
upstreamReq.on('timeout', () => upstreamReq.destroy(new Error('Upstream request timeout')));
|
|
397
|
+
upstreamReq.on('error', reject);
|
|
398
|
+
upstreamReq.write(bodyString);
|
|
399
|
+
upstreamReq.end();
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Process a single SSE event, restoring tool names if present.
|
|
404
|
+
*/
|
|
405
|
+
processSSEEvent(event, mapper) {
|
|
406
|
+
// Parse SSE format: data: {...}
|
|
407
|
+
const lines = event.split('\n');
|
|
408
|
+
const processedLines = [];
|
|
409
|
+
for (const line of lines) {
|
|
410
|
+
if (line.startsWith('data: ')) {
|
|
411
|
+
const jsonStr = line.slice(6); // Remove 'data: ' prefix
|
|
412
|
+
// Skip [DONE] marker
|
|
413
|
+
if (jsonStr.trim() === '[DONE]') {
|
|
414
|
+
processedLines.push(line);
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
const data = JSON.parse(jsonStr);
|
|
419
|
+
// Handle content_block_start with tool_use
|
|
420
|
+
if (isRecord(data) &&
|
|
421
|
+
data.type === 'content_block_start' &&
|
|
422
|
+
isRecord(data.content_block) &&
|
|
423
|
+
data.content_block.type === 'tool_use' &&
|
|
424
|
+
typeof data.content_block.name === 'string') {
|
|
425
|
+
const originalName = mapper.restoreName(data.content_block.name);
|
|
426
|
+
data.content_block.name = originalName;
|
|
427
|
+
processedLines.push('data: ' + JSON.stringify(data));
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
// Handle message with content array (final message)
|
|
431
|
+
if (isRecord(data) && Array.isArray(data.content)) {
|
|
432
|
+
data.content = mapper.restoreToolUse(data.content);
|
|
433
|
+
processedLines.push('data: ' + JSON.stringify(data));
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
// Pass through unchanged
|
|
437
|
+
processedLines.push(line);
|
|
438
|
+
}
|
|
439
|
+
catch {
|
|
440
|
+
// Not valid JSON, pass through unchanged
|
|
441
|
+
processedLines.push(line);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
// Non-data lines (event:, id:, etc.) pass through
|
|
446
|
+
processedLines.push(line);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return processedLines.join('\n');
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
exports.ToolSanitizationProxy = ToolSanitizationProxy;
|
|
453
|
+
//# sourceMappingURL=tool-sanitization-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-sanitization-proxy.js","sourceRoot":"","sources":["../../src/cliproxy/tool-sanitization-proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,6CAA+B;AAC/B,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,6BAA0B;AAC1B,yDAAkF;AAClF,4DAAoD;AAapD;;;GAGG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,MAAa,qBAAqB;IAOhC,YAAY,MAAmC;QANvC,WAAM,GAAuB,IAAI,CAAC;QAClC,SAAI,GAAkB,IAAI,CAAC;QAMjC,IAAI,CAAC,MAAM,GAAG;YACZ,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,IAAI;YAC7C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM;SACtC,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACK,WAAW;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,0BAAS,GAAE,EAAE,MAAM,CAAC,CAAC;QAE/C,IAAI,CAAC;YACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAA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