@appkit/llamacpp-cli 1.12.1 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +115 -0
  2. package/dist/cli.js +26 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/launch/claude.d.ts +6 -0
  5. package/dist/commands/launch/claude.d.ts.map +1 -0
  6. package/dist/commands/launch/claude.js +282 -0
  7. package/dist/commands/launch/claude.js.map +1 -0
  8. package/dist/lib/anthropic-converter.d.ts +15 -0
  9. package/dist/lib/anthropic-converter.d.ts.map +1 -0
  10. package/dist/lib/anthropic-converter.js +276 -0
  11. package/dist/lib/anthropic-converter.js.map +1 -0
  12. package/dist/lib/anthropic-stream-converter.d.ts +35 -0
  13. package/dist/lib/anthropic-stream-converter.d.ts.map +1 -0
  14. package/dist/lib/anthropic-stream-converter.js +227 -0
  15. package/dist/lib/anthropic-stream-converter.js.map +1 -0
  16. package/dist/lib/integration-checker.d.ts +26 -0
  17. package/dist/lib/integration-checker.d.ts.map +1 -0
  18. package/dist/lib/integration-checker.js +77 -0
  19. package/dist/lib/integration-checker.js.map +1 -0
  20. package/dist/lib/router-manager.d.ts +4 -0
  21. package/dist/lib/router-manager.d.ts.map +1 -1
  22. package/dist/lib/router-manager.js +10 -0
  23. package/dist/lib/router-manager.js.map +1 -1
  24. package/dist/lib/router-server.d.ts +21 -0
  25. package/dist/lib/router-server.d.ts.map +1 -1
  26. package/dist/lib/router-server.js +370 -7
  27. package/dist/lib/router-server.js.map +1 -1
  28. package/dist/types/anthropic-types.d.ts +198 -0
  29. package/dist/types/anthropic-types.d.ts.map +1 -0
  30. package/dist/types/anthropic-types.js +5 -0
  31. package/dist/types/anthropic-types.js.map +1 -0
  32. package/dist/types/integration-config.d.ts +32 -0
  33. package/dist/types/integration-config.d.ts.map +1 -0
  34. package/dist/types/integration-config.js +3 -0
  35. package/dist/types/integration-config.js.map +1 -0
  36. package/package.json +1 -1
@@ -98,6 +98,10 @@ export declare class RouterManager {
98
98
  config: RouterConfig;
99
99
  status: RouterServiceStatus;
100
100
  } | null>;
101
+ /**
102
+ * Get router URL
103
+ */
104
+ getRouterUrl(): Promise<string | null>;
101
105
  }
102
106
  export declare const routerManager: RouterManager;
103
107
  //# sourceMappingURL=router-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router-manager.d.ts","sourceRoot":"","sources":["../../src/lib/router-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAatD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,eAAe,CAAS;;IAShC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC;;OAEG;IACH,gBAAgB,IAAI,YAAY;IAiBhC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAOhD;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASjE;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM;IAkE3C;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD;;OAEG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CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAyCnE;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACG,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAY5E;;OAEG;IACG,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAY3E;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoD5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB3B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAA;KAAE,GAAG,IAAI,CAAC;IAUxF;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAO7C;AAGD,eAAO,MAAM,aAAa,eAAsB,CAAC"}
@@ -387,6 +387,16 @@ ${argsXml}
387
387
  const status = await this.getServiceStatus(config.label);
388
388
  return { config, status };
389
389
  }
390
+ /**
391
+ * Get router URL
392
+ */
393
+ async getRouterUrl() {
394
+ const config = await this.loadConfig();
395
+ if (!config) {
396
+ return null;
397
+ }
398
+ return `http://${config.host}:${config.port}`;
399
+ }
390
400
  }
391
401
  exports.RouterManager = RouterManager;
392
402
  // Export singleton instance
@@ -1 +1 @@
1
- {"version":3,"file":"router-manager.js","sourceRoot":"","sources":["../../src/lib/router-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,gDAAkC;AAElC,0DAAgE;AAChE,oDAS6B;AAS7B,MAAa,aAAa;IAMxB;QACE,IAAI,CAAC,SAAS,GAAG,IAAA,yBAAY,GAA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AAE,IAAI,CAAC,CAAC;QAElD,gBAAgB;QAChB,MAAM,IAAI,CAAC,YAAY,CAAC;YACtB,MAAM,EAAE,SAAS;YACjB,GAAG,EAAE,SAAS;YACd,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qBAAqB;QACvB,CAAC;QACD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,UAAU,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;IAChD,CAAC;CACF;AA/YD,sCA+YC;AAED,4BAA4B;AACf,QAAA,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
@@ -20,6 +20,27 @@ declare class RouterServer {
20
20
  * List models endpoint - aggregate from all running servers
21
21
  */
22
22
  private handleModels;
23
+ /**
24
+ * Retrieve specific model endpoint - OpenAI compatible
25
+ * Returns success for any model to allow Claude Code to work with both local and cloud models
26
+ */
27
+ private handleModelRetrieve;
28
+ /**
29
+ * Count tokens endpoint - Anthropic token counting API
30
+ */
31
+ private handleCountTokens;
32
+ /**
33
+ * Anthropic Messages API endpoint - convert to OpenAI format and route
34
+ */
35
+ private handleAnthropicMessages;
36
+ /**
37
+ * Handle non-streaming Anthropic Messages request
38
+ */
39
+ private handleAnthropicNonStreaming;
40
+ /**
41
+ * Handle streaming Anthropic Messages request
42
+ */
43
+ private handleAnthropicStreaming;
23
44
  /**
24
45
  * Chat completions endpoint - route to backend server
25
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"router-server.d.ts","sourceRoot":"","sources":["../../src/lib/router-server.ts"],"names":[],"mappings":";AA6BA;;GAEG;AACH,cAAM,YAAY;IAChB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAgB;IAExB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B;;OAEG;YACW,aAAa;IAgC3B;;OAEG;YACW,YAAY;IAS1B;;OAEG;YACW,YAAY;IAoB1B;;OAEG;YACW,qBAAqB;IAiEnC;;OAEG;YACW,gBAAgB;IA0E9B;;OAEG;YACW,YAAY;IA4D1B;;OAEG;YACW,QAAQ;IAStB;;OAEG;IACH,OAAO,CAAC,SAAS;IAUjB;;OAEG;YACW,aAAa;IAwB3B;;OAEG;YACW,UAAU;IAyBxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgC5B;;OAEG;YACW,kBAAkB;CAwCjC;AAkBD,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"router-server.d.ts","sourceRoot":"","sources":["../../src/lib/router-server.ts"],"names":[],"mappings":";AA2CA;;GAEG;AACH,cAAM,YAAY;IAChB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAgB;IAExB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B;;OAEG;YACW,aAAa;IA8C3B;;OAEG;YACW,YAAY;IAS1B;;OAEG;YACW,YAAY;IAoB1B;;;OAGG;YACW,mBAAmB;IAiBjC;;OAEG;YACW,iBAAiB;IAiC/B;;OAEG;YACW,uBAAuB;IAsIrC;;OAEG;YACW,2BAA2B;IAoHzC;;OAEG;YACW,wBAAwB;IAsGtC;;OAEG;YACW,qBAAqB;IAmEnC;;OAEG;YACW,gBAAgB;IA4E9B;;OAEG;YACW,YAAY;IA4D1B;;OAEG;YACW,QAAQ;IAStB;;OAEG;IACH,OAAO,CAAC,SAAS;IAUjB;;OAEG;YACW,aAAa;IAwB3B;;OAEG;YACW,UAAU;IAyBxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgC5B;;OAEG;YACW,kBAAkB;CAwCjC;AAkBD,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -42,6 +42,8 @@ const fs = __importStar(require("fs/promises"));
42
42
  const path = __importStar(require("path"));
43
43
  const file_utils_1 = require("../utils/file-utils");
44
44
  const router_logger_1 = require("./router-logger");
45
+ const anthropic_converter_1 = require("./anthropic-converter");
46
+ const anthropic_stream_converter_1 = require("./anthropic-stream-converter");
45
47
  /**
46
48
  * Router HTTP server - proxies requests to backend llama.cpp servers
47
49
  */
@@ -100,20 +102,37 @@ class RouterServer {
100
102
  }
101
103
  try {
102
104
  // Route based on path
103
- if (req.url === '/health' && req.method === 'GET') {
105
+ const url = req.url || '/';
106
+ const method = req.method || 'GET';
107
+ if (url === '/' && method === 'GET') {
108
+ // Root endpoint - return simple status
109
+ res.writeHead(200, { 'Content-Type': 'application/json' });
110
+ res.end(JSON.stringify({ status: 'ok', service: 'llamacpp-router' }));
111
+ }
112
+ else if (url === '/health' && method === 'GET') {
104
113
  await this.handleHealth(req, res);
105
114
  }
106
- else if (req.url === '/v1/models' && req.method === 'GET') {
115
+ else if (url === '/v1/models' && method === 'GET') {
107
116
  await this.handleModels(req, res);
108
117
  }
109
- else if (req.url === '/v1/chat/completions' && req.method === 'POST') {
118
+ else if (url.startsWith('/v1/models/') && method === 'GET') {
119
+ const modelId = url.slice('/v1/models/'.length).split('?')[0]; // Strip query params
120
+ await this.handleModelRetrieve(req, res, decodeURIComponent(modelId));
121
+ }
122
+ else if (url.startsWith('/v1/messages/count_tokens') && method === 'POST') {
123
+ await this.handleCountTokens(req, res);
124
+ }
125
+ else if (url.startsWith('/v1/messages') && method === 'POST') {
126
+ await this.handleAnthropicMessages(req, res);
127
+ }
128
+ else if (url.startsWith('/v1/chat/completions') && method === 'POST') {
110
129
  await this.handleChatCompletions(req, res);
111
130
  }
112
- else if (req.url === '/v1/embeddings' && req.method === 'POST') {
131
+ else if (url.startsWith('/v1/embeddings') && method === 'POST') {
113
132
  await this.handleEmbeddings(req, res);
114
133
  }
115
134
  else {
116
- this.sendError(res, 404, 'Not Found', `Unknown endpoint: ${req.url}`);
135
+ this.sendError(res, 404, 'Not Found', `Unknown endpoint: ${url}`);
117
136
  }
118
137
  }
119
138
  catch (error) {
@@ -151,6 +170,346 @@ class RouterServer {
151
170
  res.writeHead(200, { 'Content-Type': 'application/json' });
152
171
  res.end(JSON.stringify(response));
153
172
  }
173
+ /**
174
+ * Retrieve specific model endpoint - OpenAI compatible
175
+ * Returns success for any model to allow Claude Code to work with both local and cloud models
176
+ */
177
+ async handleModelRetrieve(req, res, modelId) {
178
+ const servers = await this.getAllServers();
179
+ const server = servers.find(s => s.modelName === modelId && s.status === 'running');
180
+ // Return model info for both local models and unknown models (like claude-haiku)
181
+ // This allows Claude Code to use both local and cloud model names
182
+ const modelInfo = {
183
+ id: modelId,
184
+ object: 'model',
185
+ created: server ? Math.floor(new Date(server.createdAt).getTime() / 1000) : Math.floor(Date.now() / 1000),
186
+ owned_by: server ? 'llamacpp' : 'anthropic',
187
+ };
188
+ res.writeHead(200, { 'Content-Type': 'application/json' });
189
+ res.end(JSON.stringify(modelInfo));
190
+ }
191
+ /**
192
+ * Count tokens endpoint - Anthropic token counting API
193
+ */
194
+ async handleCountTokens(req, res) {
195
+ try {
196
+ // Parse request body
197
+ const body = await this.readBody(req);
198
+ const request = JSON.parse(body);
199
+ // Estimate token count (rough approximation: ~4 chars per token)
200
+ let totalChars = 0;
201
+ if (request.system) {
202
+ totalChars += typeof request.system === 'string' ? request.system.length : JSON.stringify(request.system).length;
203
+ }
204
+ if (request.messages) {
205
+ for (const msg of request.messages) {
206
+ const content = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content);
207
+ totalChars += content.length;
208
+ }
209
+ }
210
+ const estimatedTokens = Math.ceil(totalChars / 4);
211
+ // Return Anthropic-compatible token count response
212
+ const response = {
213
+ input_tokens: estimatedTokens
214
+ };
215
+ res.writeHead(200, { 'Content-Type': 'application/json' });
216
+ res.end(JSON.stringify(response));
217
+ }
218
+ catch (error) {
219
+ console.error('[Router] Error counting tokens:', error);
220
+ this.sendError(res, 500, 'Internal Server Error', error.message);
221
+ }
222
+ }
223
+ /**
224
+ * Anthropic Messages API endpoint - convert to OpenAI format and route
225
+ */
226
+ async handleAnthropicMessages(req, res) {
227
+ const timer = new router_logger_1.RequestTimer();
228
+ let modelName = 'unknown';
229
+ let statusCode = 500;
230
+ let errorMsg;
231
+ let promptPreview;
232
+ try {
233
+ // Parse request body
234
+ const body = await this.readBody(req);
235
+ let anthropicRequest;
236
+ try {
237
+ anthropicRequest = JSON.parse(body);
238
+ }
239
+ catch (error) {
240
+ statusCode = 400;
241
+ errorMsg = 'Invalid JSON in request body';
242
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
243
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
244
+ res.end(JSON.stringify(anthropicError));
245
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg);
246
+ return;
247
+ }
248
+ // Extract model name and prompt preview
249
+ modelName = anthropicRequest.model || 'unknown';
250
+ if (anthropicRequest.messages && anthropicRequest.messages.length > 0) {
251
+ const userMsg = anthropicRequest.messages.find(m => m.role === 'user');
252
+ if (userMsg && typeof userMsg.content === 'string') {
253
+ promptPreview = userMsg.content.slice(0, 50);
254
+ }
255
+ }
256
+ // Validate required fields
257
+ if (!anthropicRequest.model) {
258
+ statusCode = 400;
259
+ errorMsg = 'Missing "model" field in request';
260
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
261
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
262
+ res.end(JSON.stringify(anthropicError));
263
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, undefined, promptPreview);
264
+ return;
265
+ }
266
+ if (!anthropicRequest.max_tokens || anthropicRequest.max_tokens <= 0) {
267
+ statusCode = 400;
268
+ errorMsg = 'max_tokens is required and must be positive';
269
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
270
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
271
+ res.end(JSON.stringify(anthropicError));
272
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, undefined, promptPreview);
273
+ return;
274
+ }
275
+ if (!anthropicRequest.messages || anthropicRequest.messages.length === 0) {
276
+ statusCode = 400;
277
+ errorMsg = 'messages is required and must be non-empty';
278
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
279
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
280
+ res.end(JSON.stringify(anthropicError));
281
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, undefined, promptPreview);
282
+ return;
283
+ }
284
+ // Find server for model
285
+ const server = await this.findServerForModel(modelName);
286
+ if (!server) {
287
+ statusCode = 404;
288
+ errorMsg = `No server found for model: ${modelName}`;
289
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
290
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
291
+ res.end(JSON.stringify(anthropicError));
292
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, undefined, promptPreview);
293
+ return;
294
+ }
295
+ // Check if server is running
296
+ if (server.status !== 'running') {
297
+ statusCode = 503;
298
+ errorMsg = `Server for model ${modelName} is not running (status: ${server.status})`;
299
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
300
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
301
+ res.end(JSON.stringify(anthropicError));
302
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, undefined, promptPreview);
303
+ return;
304
+ }
305
+ // Convert Anthropic request to OpenAI format
306
+ const openAIRequest = (0, anthropic_converter_1.fromMessagesRequest)(anthropicRequest);
307
+ // Generate message ID for response
308
+ const messageId = (0, anthropic_converter_1.generateMessageId)();
309
+ // Proxy request to backend
310
+ const backendHost = server.host === '0.0.0.0' ? '127.0.0.1' : server.host;
311
+ const backendUrl = `http://${backendHost}:${server.port}/v1/chat/completions`;
312
+ // Handle streaming vs non-streaming
313
+ if (anthropicRequest.stream) {
314
+ await this.handleAnthropicStreaming(anthropicRequest, openAIRequest, backendUrl, messageId, res, timer, modelName, promptPreview, server);
315
+ }
316
+ else {
317
+ await this.handleAnthropicNonStreaming(openAIRequest, backendUrl, messageId, res, timer, modelName, promptPreview, server);
318
+ }
319
+ }
320
+ catch (error) {
321
+ console.error('[Router] Error handling Anthropic messages request:', error);
322
+ statusCode = 500;
323
+ errorMsg = error.message;
324
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
325
+ if (!res.headersSent) {
326
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
327
+ res.end(JSON.stringify(anthropicError));
328
+ }
329
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, undefined, promptPreview);
330
+ }
331
+ }
332
+ /**
333
+ * Handle non-streaming Anthropic Messages request
334
+ */
335
+ async handleAnthropicNonStreaming(openAIRequest, backendUrl, messageId, res, timer, modelName, promptPreview, server) {
336
+ const url = new url_1.URL(backendUrl);
337
+ const options = {
338
+ hostname: url.hostname,
339
+ port: url.port,
340
+ path: url.pathname,
341
+ method: 'POST',
342
+ headers: {
343
+ 'Content-Type': 'application/json',
344
+ },
345
+ timeout: this.config.requestTimeout,
346
+ };
347
+ return new Promise((resolve, reject) => {
348
+ const backendReq = http.request(options, (backendRes) => {
349
+ let responseData = '';
350
+ backendRes.on('data', (chunk) => {
351
+ responseData += chunk.toString();
352
+ });
353
+ backendRes.on('end', async () => {
354
+ try {
355
+ const parsedResponse = JSON.parse(responseData);
356
+ // Check if backend returned an error
357
+ if (parsedResponse.error) {
358
+ const statusCode = backendRes.statusCode || 500;
359
+ const errorMsg = parsedResponse.error.message || 'Backend error';
360
+ console.error('[Router] Backend returned error:', errorMsg);
361
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
362
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
363
+ res.end(JSON.stringify(anthropicError));
364
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, `${server.host}:${server.port}`, promptPreview);
365
+ reject(new Error(errorMsg));
366
+ return;
367
+ }
368
+ // Check if response has required fields for a completion
369
+ if (!parsedResponse.choices || !Array.isArray(parsedResponse.choices) || parsedResponse.choices.length === 0) {
370
+ const statusCode = 502;
371
+ const errorMsg = 'Invalid backend response: missing choices array';
372
+ console.error('[Router] Backend response missing choices:', responseData.slice(0, 500));
373
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
374
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
375
+ res.end(JSON.stringify(anthropicError));
376
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, `${server.host}:${server.port}`, promptPreview);
377
+ reject(new Error(errorMsg));
378
+ return;
379
+ }
380
+ const openAIResponse = parsedResponse;
381
+ // Convert OpenAI response to Anthropic format
382
+ const anthropicResponse = (0, anthropic_converter_1.toMessagesResponse)(openAIResponse, messageId);
383
+ res.writeHead(200, { 'Content-Type': 'application/json' });
384
+ res.end(JSON.stringify(anthropicResponse));
385
+ await this.logRequest(modelName, '/v1/messages', 200, timer.elapsed(), undefined, `${server.host}:${server.port}`, promptPreview);
386
+ resolve();
387
+ }
388
+ catch (error) {
389
+ console.error('[Router] Error processing backend response:', error);
390
+ console.error('[Router] Raw response data:', responseData.slice(0, 1000));
391
+ const statusCode = 502;
392
+ const errorMsg = `Failed to process backend response: ${error.message}`;
393
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
394
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
395
+ res.end(JSON.stringify(anthropicError));
396
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, `${server.host}:${server.port}`, promptPreview);
397
+ reject(error);
398
+ }
399
+ });
400
+ });
401
+ backendReq.on('error', async (error) => {
402
+ console.error('[Router] Proxy request failed:', error);
403
+ const statusCode = 502;
404
+ const errorMsg = `Backend request failed: ${error.message}`;
405
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
406
+ if (!res.headersSent) {
407
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
408
+ res.end(JSON.stringify(anthropicError));
409
+ }
410
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, `${server.host}:${server.port}`, promptPreview);
411
+ reject(error);
412
+ });
413
+ backendReq.on('timeout', async () => {
414
+ console.error('[Router] Proxy request timed out');
415
+ backendReq.destroy();
416
+ const statusCode = 504;
417
+ const errorMsg = 'Request timeout';
418
+ const anthropicError = (0, anthropic_converter_1.createAnthropicError)(statusCode, errorMsg);
419
+ if (!res.headersSent) {
420
+ res.writeHead(statusCode, { 'Content-Type': 'application/json' });
421
+ res.end(JSON.stringify(anthropicError));
422
+ }
423
+ await this.logRequest(modelName, '/v1/messages', statusCode, timer.elapsed(), errorMsg, `${server.host}:${server.port}`, promptPreview);
424
+ reject(new Error('Request timeout'));
425
+ });
426
+ backendReq.write(JSON.stringify(openAIRequest));
427
+ backendReq.end();
428
+ });
429
+ }
430
+ /**
431
+ * Handle streaming Anthropic Messages request
432
+ */
433
+ async handleAnthropicStreaming(anthropicRequest, openAIRequest, backendUrl, messageId, res, timer, modelName, promptPreview, server) {
434
+ // Set SSE headers
435
+ res.writeHead(200, {
436
+ 'Content-Type': 'text/event-stream',
437
+ 'Cache-Control': 'no-cache',
438
+ 'Connection': 'keep-alive',
439
+ });
440
+ // Create stream converter
441
+ const estimatedTokens = (0, anthropic_converter_1.estimateInputTokens)(anthropicRequest);
442
+ const converter = new anthropic_stream_converter_1.AnthropicStreamConverter(messageId, anthropicRequest.model, estimatedTokens);
443
+ const url = new url_1.URL(backendUrl);
444
+ const options = {
445
+ hostname: url.hostname,
446
+ port: url.port,
447
+ path: url.pathname,
448
+ method: 'POST',
449
+ headers: {
450
+ 'Content-Type': 'application/json',
451
+ },
452
+ timeout: this.config.requestTimeout,
453
+ };
454
+ return new Promise((resolve, reject) => {
455
+ const backendReq = http.request(options, (backendRes) => {
456
+ let buffer = '';
457
+ backendRes.on('data', (chunk) => {
458
+ buffer += chunk.toString();
459
+ // Process complete SSE events
460
+ const lines = buffer.split('\n');
461
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
462
+ for (const line of lines) {
463
+ if (line.startsWith('data: ')) {
464
+ const data = line.slice(6);
465
+ if (data === '[DONE]') {
466
+ res.write('data: [DONE]\n\n');
467
+ continue;
468
+ }
469
+ try {
470
+ const chunk = JSON.parse(data);
471
+ const events = converter.process(chunk);
472
+ // Emit Anthropic SSE events
473
+ for (const event of events) {
474
+ res.write(`event: ${event.type}\n`);
475
+ res.write(`data: ${JSON.stringify(event)}\n\n`);
476
+ }
477
+ }
478
+ catch (error) {
479
+ console.error('[Router] Error parsing streaming chunk:', error);
480
+ }
481
+ }
482
+ }
483
+ });
484
+ backendRes.on('end', async () => {
485
+ res.end();
486
+ await this.logRequest(modelName, '/v1/messages', 200, timer.elapsed(), undefined, `${server.host}:${server.port}`, promptPreview);
487
+ resolve();
488
+ });
489
+ });
490
+ backendReq.on('error', async (error) => {
491
+ console.error('[Router] Streaming proxy request failed:', error);
492
+ const errorEvent = (0, anthropic_converter_1.createAnthropicError)(502, `Backend request failed: ${error.message}`);
493
+ res.write(`event: error\n`);
494
+ res.write(`data: ${JSON.stringify(errorEvent)}\n\n`);
495
+ res.end();
496
+ await this.logRequest(modelName, '/v1/messages', 502, timer.elapsed(), error.message, `${server.host}:${server.port}`, promptPreview);
497
+ reject(error);
498
+ });
499
+ backendReq.on('timeout', async () => {
500
+ console.error('[Router] Streaming proxy request timed out');
501
+ backendReq.destroy();
502
+ const errorEvent = (0, anthropic_converter_1.createAnthropicError)(504, 'Request timeout');
503
+ res.write(`event: error\n`);
504
+ res.write(`data: ${JSON.stringify(errorEvent)}\n\n`);
505
+ res.end();
506
+ await this.logRequest(modelName, '/v1/messages', 504, timer.elapsed(), 'Request timeout', `${server.host}:${server.port}`, promptPreview);
507
+ reject(new Error('Request timeout'));
508
+ });
509
+ backendReq.write(JSON.stringify(openAIRequest));
510
+ backendReq.end();
511
+ });
512
+ }
154
513
  /**
155
514
  * Chat completions endpoint - route to backend server
156
515
  */
@@ -201,7 +560,9 @@ class RouterServer {
201
560
  return;
202
561
  }
203
562
  // Proxy request to backend
204
- const backendUrl = `http://${server.host}:${server.port}/v1/chat/completions`;
563
+ // Always use 127.0.0.1 as destination (0.0.0.0 is only valid as bind address)
564
+ const backendHost = server.host === '0.0.0.0' ? '127.0.0.1' : server.host;
565
+ const backendUrl = `http://${backendHost}:${server.port}/v1/chat/completions`;
205
566
  await this.proxyRequest(backendUrl, requestData, req, res);
206
567
  // Log success
207
568
  statusCode = 200;
@@ -271,7 +632,9 @@ class RouterServer {
271
632
  return;
272
633
  }
273
634
  // Proxy request to backend
274
- const backendUrl = `http://${server.host}:${server.port}/v1/embeddings`;
635
+ // Always use 127.0.0.1 as destination (0.0.0.0 is only valid as bind address)
636
+ const backendHost = server.host === '0.0.0.0' ? '127.0.0.1' : server.host;
637
+ const backendUrl = `http://${backendHost}:${server.port}/v1/embeddings`;
275
638
  await this.proxyRequest(backendUrl, requestData, req, res);
276
639
  // Log success
277
640
  statusCode = 200;