@appkit/llamacpp-cli 1.13.0 → 1.14.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/README.md +39 -1
- package/dist/cli.js +4 -13
- package/dist/cli.js.map +1 -1
- package/dist/commands/launch/claude.d.ts.map +1 -1
- package/dist/commands/launch/claude.js +5 -0
- package/dist/commands/launch/claude.js.map +1 -1
- package/dist/lib/anthropic-converter.d.ts +15 -0
- package/dist/lib/anthropic-converter.d.ts.map +1 -0
- package/dist/lib/anthropic-converter.js +306 -0
- package/dist/lib/anthropic-converter.js.map +1 -0
- package/dist/lib/anthropic-stream-converter.d.ts +35 -0
- package/dist/lib/anthropic-stream-converter.d.ts.map +1 -0
- package/dist/lib/anthropic-stream-converter.js +266 -0
- package/dist/lib/anthropic-stream-converter.js.map +1 -0
- package/dist/lib/router-server.d.ts +8 -0
- package/dist/lib/router-server.d.ts.map +1 -1
- package/dist/lib/router-server.js +213 -110
- package/dist/lib/router-server.js.map +1 -1
- package/dist/types/anthropic-types.d.ts +198 -0
- package/dist/types/anthropic-types.d.ts.map +1 -0
- package/dist/types/anthropic-types.js +5 -0
- package/dist/types/anthropic-types.js.map +1 -0
- package/dist/types/integration-config.d.ts +4 -0
- package/dist/types/integration-config.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnthropicStreamConverter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Recursively unescape strings in tool call parameters
|
|
6
|
+
* Fixes issue where llama.cpp doesn't properly unescape Qwen3's XML format
|
|
7
|
+
*/
|
|
8
|
+
function unescapeToolParameters(obj) {
|
|
9
|
+
if (typeof obj === 'string') {
|
|
10
|
+
// Unescape common escape sequences
|
|
11
|
+
return obj
|
|
12
|
+
.replace(/\\n/g, '\n')
|
|
13
|
+
.replace(/\\r/g, '\r')
|
|
14
|
+
.replace(/\\t/g, '\t')
|
|
15
|
+
.replace(/\\"/g, '"')
|
|
16
|
+
.replace(/\\'/g, "'")
|
|
17
|
+
.replace(/\\\\/g, '\\'); // Backslash must be last
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(obj)) {
|
|
20
|
+
return obj.map(unescapeToolParameters);
|
|
21
|
+
}
|
|
22
|
+
if (obj !== null && typeof obj === 'object') {
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
25
|
+
result[key] = unescapeToolParameters(value);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* StreamConverter manages state for converting OpenAI streaming responses to Anthropic format.
|
|
33
|
+
*
|
|
34
|
+
* It tracks the current state of content blocks and emits proper Anthropic SSE events.
|
|
35
|
+
*/
|
|
36
|
+
class AnthropicStreamConverter {
|
|
37
|
+
constructor(id, model, estimatedInputTokens) {
|
|
38
|
+
this.firstChunk = true;
|
|
39
|
+
this.contentIndex = 0;
|
|
40
|
+
this.outputTokens = 0;
|
|
41
|
+
// State tracking
|
|
42
|
+
this.textStarted = false;
|
|
43
|
+
this.currentTextContent = '';
|
|
44
|
+
this.toolCallsInProgress = new Map();
|
|
45
|
+
this.toolCallsSent = new Set();
|
|
46
|
+
this.id = id;
|
|
47
|
+
this.model = model;
|
|
48
|
+
this.estimatedInputTokens = estimatedInputTokens;
|
|
49
|
+
this.inputTokens = estimatedInputTokens;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Process an OpenAI streaming chunk and return Anthropic events.
|
|
53
|
+
*/
|
|
54
|
+
process(chunk) {
|
|
55
|
+
const events = [];
|
|
56
|
+
// First chunk: emit message_start
|
|
57
|
+
if (this.firstChunk) {
|
|
58
|
+
this.firstChunk = false;
|
|
59
|
+
events.push(this.createMessageStartEvent());
|
|
60
|
+
}
|
|
61
|
+
const choice = chunk.choices[0];
|
|
62
|
+
if (!choice) {
|
|
63
|
+
return events;
|
|
64
|
+
}
|
|
65
|
+
const delta = choice.delta;
|
|
66
|
+
// Handle text content
|
|
67
|
+
if (delta.content) {
|
|
68
|
+
if (!this.textStarted) {
|
|
69
|
+
this.textStarted = true;
|
|
70
|
+
events.push(this.createContentBlockStartEvent('text'));
|
|
71
|
+
}
|
|
72
|
+
this.currentTextContent += delta.content;
|
|
73
|
+
events.push(this.createTextDeltaEvent(delta.content));
|
|
74
|
+
}
|
|
75
|
+
// Handle tool calls
|
|
76
|
+
if (delta.tool_calls) {
|
|
77
|
+
for (const toolCallDelta of delta.tool_calls) {
|
|
78
|
+
const index = toolCallDelta.index;
|
|
79
|
+
const tcEvents = this.processToolCallDelta(toolCallDelta);
|
|
80
|
+
events.push(...tcEvents);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Handle completion
|
|
84
|
+
if (choice.finish_reason) {
|
|
85
|
+
// Close any open content blocks
|
|
86
|
+
if (this.textStarted) {
|
|
87
|
+
events.push(this.createContentBlockStopEvent(this.contentIndex));
|
|
88
|
+
this.contentIndex++;
|
|
89
|
+
}
|
|
90
|
+
// Close any open tool calls - send unescaped input before closing
|
|
91
|
+
for (const [index, state] of this.toolCallsInProgress.entries()) {
|
|
92
|
+
if (state.started && !state.completed) {
|
|
93
|
+
// Send unescaped tool input now that it's complete
|
|
94
|
+
if (state.arguments) {
|
|
95
|
+
try {
|
|
96
|
+
const parsedInput = JSON.parse(state.arguments);
|
|
97
|
+
const unescapedInput = unescapeToolParameters(parsedInput);
|
|
98
|
+
const correctedJson = JSON.stringify(unescapedInput);
|
|
99
|
+
events.push(this.createInputJsonDeltaEvent(state.blockIndex, correctedJson));
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// If parsing fails, send raw arguments
|
|
103
|
+
events.push(this.createInputJsonDeltaEvent(state.blockIndex, state.arguments));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
events.push(this.createContentBlockStopEvent(state.blockIndex));
|
|
107
|
+
state.completed = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Emit message_delta with stop reason
|
|
111
|
+
const stopReason = this.mapFinishReason(choice.finish_reason);
|
|
112
|
+
events.push(this.createMessageDeltaEvent(stopReason));
|
|
113
|
+
// Emit message_stop
|
|
114
|
+
events.push(this.createMessageStopEvent());
|
|
115
|
+
}
|
|
116
|
+
return events;
|
|
117
|
+
}
|
|
118
|
+
processToolCallDelta(toolCallDelta) {
|
|
119
|
+
const events = [];
|
|
120
|
+
const index = toolCallDelta.index;
|
|
121
|
+
// Get or create tool call state
|
|
122
|
+
let state = this.toolCallsInProgress.get(index);
|
|
123
|
+
if (!state) {
|
|
124
|
+
state = {
|
|
125
|
+
id: '',
|
|
126
|
+
name: '',
|
|
127
|
+
arguments: '',
|
|
128
|
+
started: false,
|
|
129
|
+
completed: false,
|
|
130
|
+
blockIndex: -1,
|
|
131
|
+
};
|
|
132
|
+
this.toolCallsInProgress.set(index, state);
|
|
133
|
+
}
|
|
134
|
+
// Accumulate tool call data
|
|
135
|
+
if (toolCallDelta.id) {
|
|
136
|
+
state.id = toolCallDelta.id;
|
|
137
|
+
}
|
|
138
|
+
if (toolCallDelta.function?.name) {
|
|
139
|
+
state.name = toolCallDelta.function.name;
|
|
140
|
+
}
|
|
141
|
+
if (toolCallDelta.function?.arguments) {
|
|
142
|
+
state.arguments += toolCallDelta.function.arguments;
|
|
143
|
+
}
|
|
144
|
+
// Start tool call block when we have id and name
|
|
145
|
+
if (!state.started && state.id && state.name) {
|
|
146
|
+
// Close text block if open
|
|
147
|
+
if (this.textStarted) {
|
|
148
|
+
events.push(this.createContentBlockStopEvent(this.contentIndex));
|
|
149
|
+
this.contentIndex++;
|
|
150
|
+
this.textStarted = false;
|
|
151
|
+
}
|
|
152
|
+
state.started = true;
|
|
153
|
+
state.blockIndex = this.contentIndex;
|
|
154
|
+
events.push(this.createToolUseStartEvent(state.id, state.name));
|
|
155
|
+
}
|
|
156
|
+
// NOTE: We don't send input_json_delta events incrementally anymore.
|
|
157
|
+
// Instead, we buffer the arguments and send them unescaped when the tool call completes.
|
|
158
|
+
// This fixes the issue where llama.cpp doesn't properly unescape Qwen3's XML format.
|
|
159
|
+
return events;
|
|
160
|
+
}
|
|
161
|
+
// ============================================================================
|
|
162
|
+
// Event Creation Methods
|
|
163
|
+
// ============================================================================
|
|
164
|
+
createMessageStartEvent() {
|
|
165
|
+
return {
|
|
166
|
+
type: 'message_start',
|
|
167
|
+
message: {
|
|
168
|
+
id: this.id,
|
|
169
|
+
type: 'message',
|
|
170
|
+
role: 'assistant',
|
|
171
|
+
model: this.model,
|
|
172
|
+
content: [],
|
|
173
|
+
usage: {
|
|
174
|
+
input_tokens: this.inputTokens,
|
|
175
|
+
output_tokens: 0,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
createContentBlockStartEvent(type) {
|
|
181
|
+
return {
|
|
182
|
+
type: 'content_block_start',
|
|
183
|
+
index: this.contentIndex,
|
|
184
|
+
content_block: {
|
|
185
|
+
type: 'text',
|
|
186
|
+
text: '',
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
createToolUseStartEvent(id, name) {
|
|
191
|
+
return {
|
|
192
|
+
type: 'content_block_start',
|
|
193
|
+
index: this.contentIndex,
|
|
194
|
+
content_block: {
|
|
195
|
+
type: 'tool_use',
|
|
196
|
+
id,
|
|
197
|
+
name,
|
|
198
|
+
input: {},
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
createTextDeltaEvent(text) {
|
|
203
|
+
return {
|
|
204
|
+
type: 'content_block_delta',
|
|
205
|
+
index: this.contentIndex,
|
|
206
|
+
delta: {
|
|
207
|
+
type: 'text_delta',
|
|
208
|
+
text,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
createInputJsonDeltaEvent(index, partialJson) {
|
|
213
|
+
return {
|
|
214
|
+
type: 'content_block_delta',
|
|
215
|
+
index,
|
|
216
|
+
delta: {
|
|
217
|
+
type: 'input_json_delta',
|
|
218
|
+
partial_json: partialJson,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
createContentBlockStopEvent(index) {
|
|
223
|
+
return {
|
|
224
|
+
type: 'content_block_stop',
|
|
225
|
+
index,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
createMessageDeltaEvent(stopReason) {
|
|
229
|
+
return {
|
|
230
|
+
type: 'message_delta',
|
|
231
|
+
delta: {
|
|
232
|
+
stop_reason: stopReason,
|
|
233
|
+
},
|
|
234
|
+
usage: {
|
|
235
|
+
input_tokens: this.inputTokens,
|
|
236
|
+
output_tokens: this.outputTokens,
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
createMessageStopEvent() {
|
|
241
|
+
return {
|
|
242
|
+
type: 'message_stop',
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
// ============================================================================
|
|
246
|
+
// Helper Methods
|
|
247
|
+
// ============================================================================
|
|
248
|
+
mapFinishReason(finishReason) {
|
|
249
|
+
const hasToolCalls = this.toolCallsInProgress.size > 0;
|
|
250
|
+
if (hasToolCalls) {
|
|
251
|
+
return 'tool_use';
|
|
252
|
+
}
|
|
253
|
+
switch (finishReason) {
|
|
254
|
+
case 'stop':
|
|
255
|
+
return 'end_turn';
|
|
256
|
+
case 'length':
|
|
257
|
+
return 'max_tokens';
|
|
258
|
+
case 'tool_calls':
|
|
259
|
+
return 'tool_use';
|
|
260
|
+
default:
|
|
261
|
+
return 'end_turn';
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.AnthropicStreamConverter = AnthropicStreamConverter;
|
|
266
|
+
//# sourceMappingURL=anthropic-stream-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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AAC,YAA2B;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,CAAC,CAAC;QAEvD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,QAAQ,YAAY,EAAE,CAAC;YACrB,KAAK,MAAM;gBACT,OAAO,UAAU,CAAC;YACpB,KAAK,QAAQ;gBACX,OAAO,YAAY,CAAC;YACtB,KAAK,YAAY;gBACf,OAAO,UAAU,CAAC;YACpB;gBACE,OAAO,UAAU,CAAC;QACtB,CAAC;IACH,CAAC;CACF;AA9QD,4DA8QC"}
|
|
@@ -33,6 +33,14 @@ declare class RouterServer {
|
|
|
33
33
|
* Anthropic Messages API endpoint - convert to OpenAI format and route
|
|
34
34
|
*/
|
|
35
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;
|
|
36
44
|
/**
|
|
37
45
|
* Chat completions endpoint - route to backend server
|
|
38
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-server.d.ts","sourceRoot":"","sources":["../../src/lib/router-server.ts"],"names":[],"mappings":";
|
|
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"}
|