@bxb1337/windsurf-fast-context 1.0.2 → 1.0.4
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.
|
@@ -5,6 +5,8 @@ const node_zlib_1 = require("node:zlib");
|
|
|
5
5
|
const protobuf_js_1 = require("../protocol/protobuf.js");
|
|
6
6
|
const TOOL_CALL_PREFIX = '[TOOL_CALLS]';
|
|
7
7
|
const ARGS_PREFIX = '[ARGS]';
|
|
8
|
+
const STOP_TOKEN = '</s>';
|
|
9
|
+
const EMPTY_TOOL_CALLS_PATTERN = /TOOL_CALLS\d*(?:<\/s>)?\s*\{\s*\}/g;
|
|
8
10
|
function pushText(parts, text) {
|
|
9
11
|
if (text.length > 0) {
|
|
10
12
|
parts.push({ type: 'text', text });
|
|
@@ -189,7 +191,9 @@ function decodeResponseText(buffer) {
|
|
|
189
191
|
return pickBestExtractedText(extracted);
|
|
190
192
|
}
|
|
191
193
|
function convertResponse(buffer) {
|
|
192
|
-
|
|
194
|
+
let responseText = decodeResponseText(buffer);
|
|
195
|
+
responseText = responseText.replace(EMPTY_TOOL_CALLS_PATTERN, '');
|
|
196
|
+
responseText = responseText.replace(STOP_TOKEN, '');
|
|
193
197
|
const parts = [];
|
|
194
198
|
let cursor = 0;
|
|
195
199
|
let toolCallCount = 0;
|
|
@@ -62,4 +62,29 @@ const response_converter_js_1 = require("./response-converter.js");
|
|
|
62
62
|
const result = (0, response_converter_js_1.convertResponse)(compressed);
|
|
63
63
|
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'hello from gzip' }]);
|
|
64
64
|
});
|
|
65
|
+
(0, vitest_1.it)('strips empty TOOL_CALLS markers with stop token', () => {
|
|
66
|
+
const input = 'Hello world TOOL_CALLS0</s>{}';
|
|
67
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'));
|
|
68
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'Hello world ' }]);
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.it)('strips empty TOOL_CALLS markers without stop token', () => {
|
|
71
|
+
const input = 'Hello world TOOL_CALLS1{}';
|
|
72
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'));
|
|
73
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'Hello world ' }]);
|
|
74
|
+
});
|
|
75
|
+
(0, vitest_1.it)('strips empty TOOL_CALLS markers with whitespace', () => {
|
|
76
|
+
const input = 'Text TOOL_CALLS2{ } more text';
|
|
77
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'));
|
|
78
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'Text more text' }]);
|
|
79
|
+
});
|
|
80
|
+
(0, vitest_1.it)('strips standalone stop token', () => {
|
|
81
|
+
const input = 'Hello world</s>';
|
|
82
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'));
|
|
83
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'Hello world' }]);
|
|
84
|
+
});
|
|
85
|
+
(0, vitest_1.it)('handles TOOL_CALLS with number prefix before stop token', () => {
|
|
86
|
+
const input = 'Text before TOOL_CALLS1</s>{} text after';
|
|
87
|
+
const result = (0, response_converter_js_1.convertResponse)(Buffer.from(input, 'utf8'));
|
|
88
|
+
(0, vitest_1.expect)(result).toEqual([{ type: 'text', text: 'Text before text after' }]);
|
|
89
|
+
});
|
|
65
90
|
});
|
|
@@ -2,6 +2,8 @@ import { gunzipSync } from 'node:zlib';
|
|
|
2
2
|
import { extractStrings } from '../protocol/protobuf.js';
|
|
3
3
|
const TOOL_CALL_PREFIX = '[TOOL_CALLS]';
|
|
4
4
|
const ARGS_PREFIX = '[ARGS]';
|
|
5
|
+
const STOP_TOKEN = '</s>';
|
|
6
|
+
const EMPTY_TOOL_CALLS_PATTERN = /TOOL_CALLS\d*(?:<\/s>)?\s*\{\s*\}/g;
|
|
5
7
|
function pushText(parts, text) {
|
|
6
8
|
if (text.length > 0) {
|
|
7
9
|
parts.push({ type: 'text', text });
|
|
@@ -186,7 +188,9 @@ function decodeResponseText(buffer) {
|
|
|
186
188
|
return pickBestExtractedText(extracted);
|
|
187
189
|
}
|
|
188
190
|
export function convertResponse(buffer) {
|
|
189
|
-
|
|
191
|
+
let responseText = decodeResponseText(buffer);
|
|
192
|
+
responseText = responseText.replace(EMPTY_TOOL_CALLS_PATTERN, '');
|
|
193
|
+
responseText = responseText.replace(STOP_TOKEN, '');
|
|
190
194
|
const parts = [];
|
|
191
195
|
let cursor = 0;
|
|
192
196
|
let toolCallCount = 0;
|
|
@@ -60,4 +60,29 @@ describe('convertResponse', () => {
|
|
|
60
60
|
const result = convertResponse(compressed);
|
|
61
61
|
expect(result).toEqual([{ type: 'text', text: 'hello from gzip' }]);
|
|
62
62
|
});
|
|
63
|
+
it('strips empty TOOL_CALLS markers with stop token', () => {
|
|
64
|
+
const input = 'Hello world TOOL_CALLS0</s>{}';
|
|
65
|
+
const result = convertResponse(Buffer.from(input, 'utf8'));
|
|
66
|
+
expect(result).toEqual([{ type: 'text', text: 'Hello world ' }]);
|
|
67
|
+
});
|
|
68
|
+
it('strips empty TOOL_CALLS markers without stop token', () => {
|
|
69
|
+
const input = 'Hello world TOOL_CALLS1{}';
|
|
70
|
+
const result = convertResponse(Buffer.from(input, 'utf8'));
|
|
71
|
+
expect(result).toEqual([{ type: 'text', text: 'Hello world ' }]);
|
|
72
|
+
});
|
|
73
|
+
it('strips empty TOOL_CALLS markers with whitespace', () => {
|
|
74
|
+
const input = 'Text TOOL_CALLS2{ } more text';
|
|
75
|
+
const result = convertResponse(Buffer.from(input, 'utf8'));
|
|
76
|
+
expect(result).toEqual([{ type: 'text', text: 'Text more text' }]);
|
|
77
|
+
});
|
|
78
|
+
it('strips standalone stop token', () => {
|
|
79
|
+
const input = 'Hello world</s>';
|
|
80
|
+
const result = convertResponse(Buffer.from(input, 'utf8'));
|
|
81
|
+
expect(result).toEqual([{ type: 'text', text: 'Hello world' }]);
|
|
82
|
+
});
|
|
83
|
+
it('handles TOOL_CALLS with number prefix before stop token', () => {
|
|
84
|
+
const input = 'Text before TOOL_CALLS1</s>{} text after';
|
|
85
|
+
const result = convertResponse(Buffer.from(input, 'utf8'));
|
|
86
|
+
expect(result).toEqual([{ type: 'text', text: 'Text before text after' }]);
|
|
87
|
+
});
|
|
63
88
|
});
|
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bxb1337/windsurf-fast-context",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "AI SDK V3 provider for Windsurf's Devstral code search API",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "vitest --run",
|
|
8
|
-
"build:types": "tsc -p tsconfig.types.json",
|
|
9
|
-
"build:esm": "tsc -p tsconfig.json",
|
|
10
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
11
|
-
"build": "pnpm -s run build:types && pnpm -s run build:esm && pnpm -s run build:cjs && node ./scripts/postbuild.js",
|
|
12
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
13
|
-
},
|
|
14
6
|
"keywords": [
|
|
15
7
|
"windsurf",
|
|
16
8
|
"devstral",
|
|
@@ -47,5 +39,13 @@
|
|
|
47
39
|
"dist",
|
|
48
40
|
"README.md",
|
|
49
41
|
"LICENSE"
|
|
50
|
-
]
|
|
51
|
-
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "vitest --run",
|
|
45
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
46
|
+
"build:esm": "tsc -p tsconfig.json",
|
|
47
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
48
|
+
"build": "pnpm -s run build:types && pnpm -s run build:esm && pnpm -s run build:cjs && node ./scripts/postbuild.js",
|
|
49
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
50
|
+
}
|
|
51
|
+
}
|