@bxb1337/windsurf-fast-context 1.0.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/LICENSE +21 -0
- package/README.md +337 -0
- package/dist/auth/api-key.d.ts +2 -0
- package/dist/auth/api-key.test.d.ts +1 -0
- package/dist/auth/jwt-manager.d.ts +18 -0
- package/dist/auth/jwt-manager.test.d.ts +1 -0
- package/dist/cjs/auth/api-key.js +10 -0
- package/dist/cjs/auth/api-key.test.js +29 -0
- package/dist/cjs/auth/jwt-manager.js +94 -0
- package/dist/cjs/auth/jwt-manager.test.js +99 -0
- package/dist/cjs/conversion/prompt-converter.js +57 -0
- package/dist/cjs/conversion/prompt-converter.test.js +95 -0
- package/dist/cjs/conversion/response-converter.js +233 -0
- package/dist/cjs/conversion/response-converter.test.js +65 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/model/devstral-language-model.js +399 -0
- package/dist/cjs/model/devstral-language-model.test.js +410 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/protocol/connect-frame.js +40 -0
- package/dist/cjs/protocol/connect-frame.test.js +36 -0
- package/dist/cjs/protocol/protobuf.js +114 -0
- package/dist/cjs/protocol/protobuf.test.js +58 -0
- package/dist/cjs/provider.js +13 -0
- package/dist/cjs/provider.test.js +61 -0
- package/dist/cjs/transport/http.js +83 -0
- package/dist/cjs/transport/http.test.js +196 -0
- package/dist/cjs/types/index.js +2 -0
- package/dist/conversion/prompt-converter.d.ts +49 -0
- package/dist/conversion/prompt-converter.test.d.ts +1 -0
- package/dist/conversion/response-converter.d.ts +12 -0
- package/dist/conversion/response-converter.test.d.ts +1 -0
- package/dist/esm/auth/api-key.js +7 -0
- package/dist/esm/auth/api-key.test.js +27 -0
- package/dist/esm/auth/jwt-manager.js +90 -0
- package/dist/esm/auth/jwt-manager.test.js +97 -0
- package/dist/esm/conversion/prompt-converter.js +54 -0
- package/dist/esm/conversion/prompt-converter.test.js +93 -0
- package/dist/esm/conversion/response-converter.js +230 -0
- package/dist/esm/conversion/response-converter.test.js +63 -0
- package/dist/esm/dist/cjs/index.js +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/model/devstral-language-model.js +395 -0
- package/dist/esm/model/devstral-language-model.test.js +408 -0
- package/dist/esm/protocol/connect-frame.js +36 -0
- package/dist/esm/protocol/connect-frame.test.js +34 -0
- package/dist/esm/protocol/protobuf.js +108 -0
- package/dist/esm/protocol/protobuf.test.js +56 -0
- package/dist/esm/provider.js +9 -0
- package/dist/esm/provider.test.js +59 -0
- package/dist/esm/scripts/postbuild.js +10 -0
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/transport/http.js +78 -0
- package/dist/esm/transport/http.test.js +194 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/vitest.config.js +6 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/model/devstral-language-model.d.ts +118 -0
- package/dist/model/devstral-language-model.test.d.ts +1 -0
- package/dist/protocol/connect-frame.d.ts +10 -0
- package/dist/protocol/connect-frame.test.d.ts +1 -0
- package/dist/protocol/protobuf.d.ts +11 -0
- package/dist/protocol/protobuf.test.d.ts +1 -0
- package/dist/provider.d.ts +5 -0
- package/dist/provider.test.d.ts +1 -0
- package/dist/transport/http.d.ts +22 -0
- package/dist/transport/http.test.d.ts +1 -0
- package/dist/types/index.d.ts +37 -0
- package/package.json +51 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const prompt_converter_js_1 = require("./prompt-converter.js");
|
|
5
|
+
(0, vitest_1.describe)('convertPrompt', () => {
|
|
6
|
+
(0, vitest_1.it)('system maps to role 5', () => {
|
|
7
|
+
const prompt = [{ role: 'system', content: 'Keep answers concise.' }];
|
|
8
|
+
const result = (0, prompt_converter_js_1.convertPrompt)(prompt);
|
|
9
|
+
(0, vitest_1.expect)(result).toEqual([{ role: 5, content: 'Keep answers concise.' }]);
|
|
10
|
+
});
|
|
11
|
+
(0, vitest_1.it)('tool-call converts assistant tool calls and preserves id/name/args', () => {
|
|
12
|
+
const prompt = [
|
|
13
|
+
{
|
|
14
|
+
role: 'assistant',
|
|
15
|
+
content: [
|
|
16
|
+
{ type: 'text', text: 'Let me call a tool.' },
|
|
17
|
+
{
|
|
18
|
+
type: 'tool-call',
|
|
19
|
+
toolCallId: 'call_1',
|
|
20
|
+
toolName: 'searchDocs',
|
|
21
|
+
args: { query: 'prompt converter', topK: 3 },
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
const result = (0, prompt_converter_js_1.convertPrompt)(prompt);
|
|
27
|
+
(0, vitest_1.expect)(result).toHaveLength(2);
|
|
28
|
+
(0, vitest_1.expect)(result[0]).toEqual({ role: 2, content: 'Let me call a tool.' });
|
|
29
|
+
(0, vitest_1.expect)(result[1]).toEqual({
|
|
30
|
+
role: 2,
|
|
31
|
+
content: '',
|
|
32
|
+
metadata: {
|
|
33
|
+
toolCallId: 'call_1',
|
|
34
|
+
toolName: 'searchDocs',
|
|
35
|
+
toolArgsJson: '{"query":"prompt converter","topK":3}',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)('multi-turn preserves ordering across mixed roles', () => {
|
|
40
|
+
const prompt = [
|
|
41
|
+
{ role: 'system', content: 'System instruction' },
|
|
42
|
+
{
|
|
43
|
+
role: 'user',
|
|
44
|
+
content: [
|
|
45
|
+
{ type: 'text', text: 'Find usage examples.' },
|
|
46
|
+
{ type: 'file', data: 'ZmFrZQ==', mediaType: 'image/png' },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
role: 'assistant',
|
|
51
|
+
content: [
|
|
52
|
+
{ type: 'text', text: 'I will call a tool now.' },
|
|
53
|
+
{ type: 'tool-call', toolCallId: 'call_2', toolName: 'searchDocs', args: { q: 'usage examples' } },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
role: 'tool',
|
|
58
|
+
content: [
|
|
59
|
+
{
|
|
60
|
+
type: 'tool-result',
|
|
61
|
+
toolCallId: 'call_2',
|
|
62
|
+
toolName: 'searchDocs',
|
|
63
|
+
result: { hits: ['a.ts', 'b.ts'] },
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{ role: 'assistant', content: [{ type: 'text', text: 'Done.' }] },
|
|
68
|
+
];
|
|
69
|
+
const snapshot = JSON.parse(JSON.stringify(prompt));
|
|
70
|
+
const result = (0, prompt_converter_js_1.convertPrompt)(prompt);
|
|
71
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
72
|
+
{ role: 5, content: 'System instruction' },
|
|
73
|
+
{ role: 1, content: 'Find usage examples.' },
|
|
74
|
+
{ role: 2, content: 'I will call a tool now.' },
|
|
75
|
+
{
|
|
76
|
+
role: 2,
|
|
77
|
+
content: '',
|
|
78
|
+
metadata: {
|
|
79
|
+
toolCallId: 'call_2',
|
|
80
|
+
toolName: 'searchDocs',
|
|
81
|
+
toolArgsJson: '{"q":"usage examples"}',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
role: 4,
|
|
86
|
+
content: '{"hits":["a.ts","b.ts"]}',
|
|
87
|
+
metadata: {
|
|
88
|
+
refCallId: 'call_2',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{ role: 2, content: 'Done.' },
|
|
92
|
+
]);
|
|
93
|
+
(0, vitest_1.expect)(prompt).toEqual(snapshot);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertResponse = convertResponse;
|
|
4
|
+
const node_zlib_1 = require("node:zlib");
|
|
5
|
+
const protobuf_js_1 = require("../protocol/protobuf.js");
|
|
6
|
+
const TOOL_CALL_PREFIX = '[TOOL_CALLS]';
|
|
7
|
+
const ARGS_PREFIX = '[ARGS]';
|
|
8
|
+
function pushText(parts, text) {
|
|
9
|
+
if (text.length > 0) {
|
|
10
|
+
parts.push({ type: 'text', text });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function extractAnswerText(args) {
|
|
14
|
+
if (typeof args === 'string') {
|
|
15
|
+
return args;
|
|
16
|
+
}
|
|
17
|
+
if (args != null && typeof args === 'object') {
|
|
18
|
+
if ('answer' in args && typeof args.answer === 'string') {
|
|
19
|
+
return args.answer;
|
|
20
|
+
}
|
|
21
|
+
if ('text' in args && typeof args.text === 'string') {
|
|
22
|
+
return args.text;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return JSON.stringify(args);
|
|
26
|
+
}
|
|
27
|
+
function parseStringEnd(value, startIndex) {
|
|
28
|
+
let index = startIndex + 1;
|
|
29
|
+
let escaping = false;
|
|
30
|
+
while (index < value.length) {
|
|
31
|
+
const char = value[index];
|
|
32
|
+
if (escaping) {
|
|
33
|
+
escaping = false;
|
|
34
|
+
}
|
|
35
|
+
else if (char === '\\') {
|
|
36
|
+
escaping = true;
|
|
37
|
+
}
|
|
38
|
+
else if (char === '"') {
|
|
39
|
+
return index + 1;
|
|
40
|
+
}
|
|
41
|
+
index += 1;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function parseBalancedEnd(value, startIndex) {
|
|
46
|
+
const stack = [value[startIndex] === '{' ? '}' : ']'];
|
|
47
|
+
let index = startIndex + 1;
|
|
48
|
+
let inString = false;
|
|
49
|
+
let escaping = false;
|
|
50
|
+
while (index < value.length) {
|
|
51
|
+
const char = value[index];
|
|
52
|
+
if (inString) {
|
|
53
|
+
if (escaping) {
|
|
54
|
+
escaping = false;
|
|
55
|
+
}
|
|
56
|
+
else if (char === '\\') {
|
|
57
|
+
escaping = true;
|
|
58
|
+
}
|
|
59
|
+
else if (char === '"') {
|
|
60
|
+
inString = false;
|
|
61
|
+
}
|
|
62
|
+
index += 1;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (char === '"') {
|
|
66
|
+
inString = true;
|
|
67
|
+
index += 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (char === '{') {
|
|
71
|
+
stack.push('}');
|
|
72
|
+
index += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (char === '[') {
|
|
76
|
+
stack.push(']');
|
|
77
|
+
index += 1;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (char === '}' || char === ']') {
|
|
81
|
+
const expected = stack[stack.length - 1];
|
|
82
|
+
if (expected !== char) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
stack.pop();
|
|
86
|
+
index += 1;
|
|
87
|
+
if (stack.length === 0) {
|
|
88
|
+
return index;
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
index += 1;
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function parsePrimitiveEnd(value, startIndex) {
|
|
97
|
+
let index = startIndex;
|
|
98
|
+
while (index < value.length) {
|
|
99
|
+
const char = value[index];
|
|
100
|
+
if (char === ' ' || char === '\n' || char === '\r' || char === '\t') {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
index += 1;
|
|
104
|
+
}
|
|
105
|
+
return index;
|
|
106
|
+
}
|
|
107
|
+
function parseJsonValue(value, startIndex) {
|
|
108
|
+
let jsonStart = startIndex;
|
|
109
|
+
while (jsonStart < value.length) {
|
|
110
|
+
const char = value[jsonStart];
|
|
111
|
+
if (char !== ' ' && char !== '\n' && char !== '\r' && char !== '\t') {
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
jsonStart += 1;
|
|
115
|
+
}
|
|
116
|
+
if (jsonStart >= value.length) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const firstChar = value[jsonStart];
|
|
120
|
+
let endIndex;
|
|
121
|
+
if (firstChar === '{' || firstChar === '[') {
|
|
122
|
+
endIndex = parseBalancedEnd(value, jsonStart);
|
|
123
|
+
}
|
|
124
|
+
else if (firstChar === '"') {
|
|
125
|
+
endIndex = parseStringEnd(value, jsonStart);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
endIndex = parsePrimitiveEnd(value, jsonStart);
|
|
129
|
+
}
|
|
130
|
+
if (endIndex == null || endIndex <= jsonStart) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const rawJson = value.slice(jsonStart, endIndex);
|
|
134
|
+
try {
|
|
135
|
+
return {
|
|
136
|
+
parsed: JSON.parse(rawJson),
|
|
137
|
+
endIndex,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function hasControlChars(value) {
|
|
145
|
+
for (const char of value) {
|
|
146
|
+
const code = char.charCodeAt(0);
|
|
147
|
+
if (code <= 8 || code === 11 || code === 12 || (code >= 14 && code <= 31)) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
function maybeGunzip(buffer) {
|
|
154
|
+
if (buffer.length < 2) {
|
|
155
|
+
return buffer;
|
|
156
|
+
}
|
|
157
|
+
if (buffer.readUInt8(0) !== 0x1f || buffer.readUInt8(1) !== 0x8b) {
|
|
158
|
+
return buffer;
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
return (0, node_zlib_1.gunzipSync)(buffer);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return buffer;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function isLikelyMetadata(value) {
|
|
168
|
+
return /^[A-Za-z0-9._:-]{1,32}$/.test(value);
|
|
169
|
+
}
|
|
170
|
+
function pickBestExtractedText(values) {
|
|
171
|
+
const markerValues = values.filter((value) => value.includes(TOOL_CALL_PREFIX) || value.includes(ARGS_PREFIX));
|
|
172
|
+
if (markerValues.length > 0) {
|
|
173
|
+
return markerValues.join('');
|
|
174
|
+
}
|
|
175
|
+
const nonMetadata = values.filter((value) => !isLikelyMetadata(value));
|
|
176
|
+
const candidates = nonMetadata.length > 0 ? nonMetadata : values;
|
|
177
|
+
return candidates.reduce((best, current) => (current.length > best.length ? current : best), candidates[0] ?? '');
|
|
178
|
+
}
|
|
179
|
+
function decodeResponseText(buffer) {
|
|
180
|
+
const source = maybeGunzip(buffer);
|
|
181
|
+
const raw = source.toString('utf8');
|
|
182
|
+
if (!hasControlChars(raw) && !raw.includes('\ufffd')) {
|
|
183
|
+
return raw;
|
|
184
|
+
}
|
|
185
|
+
const extracted = (0, protobuf_js_1.extractStrings)(source).filter((value) => value.length > 0 && !hasControlChars(value));
|
|
186
|
+
if (extracted.length === 0) {
|
|
187
|
+
return raw;
|
|
188
|
+
}
|
|
189
|
+
return pickBestExtractedText(extracted);
|
|
190
|
+
}
|
|
191
|
+
function convertResponse(buffer) {
|
|
192
|
+
const responseText = decodeResponseText(buffer);
|
|
193
|
+
const parts = [];
|
|
194
|
+
let cursor = 0;
|
|
195
|
+
let toolCallCount = 0;
|
|
196
|
+
while (cursor < responseText.length) {
|
|
197
|
+
const markerStart = responseText.indexOf(TOOL_CALL_PREFIX, cursor);
|
|
198
|
+
if (markerStart === -1) {
|
|
199
|
+
pushText(parts, responseText.slice(cursor));
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
pushText(parts, responseText.slice(cursor, markerStart));
|
|
203
|
+
const toolNameStart = markerStart + TOOL_CALL_PREFIX.length;
|
|
204
|
+
const argsStart = responseText.indexOf(ARGS_PREFIX, toolNameStart);
|
|
205
|
+
if (argsStart === -1) {
|
|
206
|
+
pushText(parts, responseText.slice(markerStart));
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
const toolName = responseText.slice(toolNameStart, argsStart);
|
|
210
|
+
const parsedArgs = parseJsonValue(responseText, argsStart + ARGS_PREFIX.length);
|
|
211
|
+
if (parsedArgs == null) {
|
|
212
|
+
const nextMarker = responseText.indexOf(TOOL_CALL_PREFIX, markerStart + TOOL_CALL_PREFIX.length);
|
|
213
|
+
const malformedEnd = nextMarker === -1 ? responseText.length : nextMarker;
|
|
214
|
+
pushText(parts, responseText.slice(markerStart, malformedEnd));
|
|
215
|
+
cursor = malformedEnd;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (toolName === 'answer') {
|
|
219
|
+
pushText(parts, extractAnswerText(parsedArgs.parsed));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
toolCallCount += 1;
|
|
223
|
+
parts.push({
|
|
224
|
+
type: 'tool-call',
|
|
225
|
+
toolCallId: `toolcall_${toolCallCount}`,
|
|
226
|
+
toolName,
|
|
227
|
+
args: parsedArgs.parsed,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
cursor = parsedArgs.endIndex;
|
|
231
|
+
}
|
|
232
|
+
return parts;
|
|
233
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const node_zlib_1 = require("node:zlib");
|
|
5
|
+
const protobuf_js_1 = require("../protocol/protobuf.js");
|
|
6
|
+
const response_converter_js_1 = require("./response-converter.js");
|
|
7
|
+
(0, vitest_1.describe)('convertResponse', () => {
|
|
8
|
+
(0, vitest_1.it)('text - returns plain text part for plain response', () => {
|
|
9
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from('plain response text', 'utf8'));
|
|
10
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'plain response text' }]);
|
|
11
|
+
});
|
|
12
|
+
(0, vitest_1.it)('tool-call - parses tool markers and preserves surrounding text', () => {
|
|
13
|
+
const input = 'Before [TOOL_CALLS]searchDocs[ARGS]{"query":"prompt converter"} between [TOOL_CALLS]answer[ARGS]{"answer":"final answer"} after';
|
|
14
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'));
|
|
15
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
16
|
+
{ type: 'text', text: 'Before ' },
|
|
17
|
+
{
|
|
18
|
+
type: 'tool-call',
|
|
19
|
+
toolCallId: 'toolcall_1',
|
|
20
|
+
toolName: 'searchDocs',
|
|
21
|
+
args: { query: 'prompt converter' },
|
|
22
|
+
},
|
|
23
|
+
{ type: 'text', text: ' between ' },
|
|
24
|
+
{ type: 'text', text: 'final answer' },
|
|
25
|
+
{ type: 'text', text: ' after' },
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
(0, vitest_1.it)('malformed - invalid marker json remains text and does not throw', () => {
|
|
29
|
+
const input = 'prefix [TOOL_CALLS]searchDocs[ARGS]{"query": nope} suffix';
|
|
30
|
+
(0, vitest_1.expect)(() => (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'))).not.toThrow();
|
|
31
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'));
|
|
32
|
+
const combinedText = result
|
|
33
|
+
.filter((part) => part.type === 'text')
|
|
34
|
+
.map((part) => part.text)
|
|
35
|
+
.join('');
|
|
36
|
+
(0, vitest_1.expect)(result.every((part) => part.type === 'text')).toBe(true);
|
|
37
|
+
(0, vitest_1.expect)(combinedText).toBe(input);
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)('protobuf payload - extracts clean utf8 text without binary mojibake prefix', () => {
|
|
40
|
+
const payload = new protobuf_js_1.ProtobufEncoder();
|
|
41
|
+
payload.writeVarint(1, 150);
|
|
42
|
+
payload.writeString(2, '你好,TypeScript');
|
|
43
|
+
const result = (0, response_converter_js_1.convertResponse)(payload.toBuffer());
|
|
44
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: '你好,TypeScript' }]);
|
|
45
|
+
});
|
|
46
|
+
(0, vitest_1.it)('protobuf payload - still parses tool-call markers from extracted strings', () => {
|
|
47
|
+
const payload = new protobuf_js_1.ProtobufEncoder();
|
|
48
|
+
payload.writeVarint(1, 150);
|
|
49
|
+
payload.writeString(2, '[TOOL_CALLS]answer[ARGS]{"answer":"final answer"}');
|
|
50
|
+
const result = (0, response_converter_js_1.convertResponse)(payload.toBuffer());
|
|
51
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'final answer' }]);
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.it)('protobuf payload - ignores metadata strings and keeps main text field', () => {
|
|
54
|
+
const payload = new protobuf_js_1.ProtobufEncoder();
|
|
55
|
+
payload.writeString(1, 'meta');
|
|
56
|
+
payload.writeString(2, '你好,TypeScript');
|
|
57
|
+
const result = (0, response_converter_js_1.convertResponse)(payload.toBuffer());
|
|
58
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: '你好,TypeScript' }]);
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.it)('gzip payload - decompresses before decoding text', () => {
|
|
61
|
+
const compressed = (0, node_zlib_1.gzipSync)(Buffer.from('hello from gzip', 'utf8'));
|
|
62
|
+
const result = (0, response_converter_js_1.convertResponse)(compressed);
|
|
63
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'hello from gzip' }]);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = exports.windsurf = exports.createWindsurfProvider = void 0;
|
|
18
|
+
__exportStar(require("./types/index.js"), exports);
|
|
19
|
+
var provider_js_1 = require("./provider.js");
|
|
20
|
+
Object.defineProperty(exports, "createWindsurfProvider", { enumerable: true, get: function () { return provider_js_1.createWindsurfProvider; } });
|
|
21
|
+
Object.defineProperty(exports, "windsurf", { enumerable: true, get: function () { return provider_js_1.windsurf; } });
|
|
22
|
+
var provider_js_2 = require("./provider.js");
|
|
23
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return provider_js_2.default; } });
|