@jiangxiaoxu/lm-tools-bridge-proxy 0.1.3 → 0.1.5

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 (2) hide show
  1. package/dist/index.js +20 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -190,6 +190,7 @@ function createStdioMessageHandler(targetGetter, targetRefresher) {
190
190
  path: targetUrl.pathname,
191
191
  method: "POST",
192
192
  headers: {
193
+ Accept: "application/json, text/event-stream",
193
194
  "Content-Type": "application/json",
194
195
  "Content-Length": Buffer.byteLength(payload)
195
196
  }
@@ -200,8 +201,26 @@ function createStdioMessageHandler(targetGetter, targetRefresher) {
200
201
  response.on("end", () => {
201
202
  const text = Buffer.concat(chunks).toString("utf8");
202
203
  if (text.length > 0) {
203
- import_node_process.default.stdout.write(`${text}
204
+ const contentType = Array.isArray(response.headers["content-type"]) ? response.headers["content-type"].join(";") : response.headers["content-type"] ?? "";
205
+ if (contentType.includes("text/event-stream")) {
206
+ const events = text.split(/\r?\n\r?\n/);
207
+ for (const eventBlock of events) {
208
+ const lines = eventBlock.split(/\r?\n/);
209
+ const dataLines = lines.filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart());
210
+ if (dataLines.length === 0) {
211
+ continue;
212
+ }
213
+ const dataText = dataLines.join("\n").trim();
214
+ if (dataText.length === 0 || dataText === "[DONE]") {
215
+ continue;
216
+ }
217
+ import_node_process.default.stdout.write(`${dataText}
204
218
  `);
219
+ }
220
+ } else {
221
+ import_node_process.default.stdout.write(`${text}
222
+ `);
223
+ }
205
224
  }
206
225
  resolve({ ok: true });
207
226
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiangxiaoxu/lm-tools-bridge-proxy",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Stdio MCP proxy for LM Tools Bridge (Windows Named Pipe resolve).",
5
5
  "license": "MIT",
6
6
  "bin": {