@yzj01/llm-router 1.0.1 → 1.0.3

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/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as ProxyOptions, a as ProxyHandle } from './proxy-Co87mKak.js';
1
+ import { P as ProxyOptions, a as ProxyHandle } from './proxy-B7j2DcEK.js';
2
2
 
3
3
  type CliRuntime = {
4
4
  log: (msg: string) => void;
package/dist/cli.js CHANGED
@@ -1792,7 +1792,7 @@ function hashHex(value, length) {
1792
1792
  }
1793
1793
 
1794
1794
  // src/proxy.ts
1795
- var VERSION = "1.0.1";
1795
+ var VERSION = "1.0.3";
1796
1796
  var HOP_BY_HOP = /* @__PURE__ */ new Set([
1797
1797
  "connection",
1798
1798
  "keep-alive",
@@ -1889,15 +1889,16 @@ function readBody(req, limits) {
1889
1889
  }
1890
1890
  var OPENCLAW_CLI_TURN_PATTERN = /(?:^|\n)\[[^\]\n]+?\]\s+([\s\S]*?)(?=(?:\n\[[^\]\n]+?\]\s+)|$)/g;
1891
1891
  function extractRouteTextFromUserMessage(text) {
1892
- const matches = [...text.matchAll(OPENCLAW_CLI_TURN_PATTERN)];
1893
- const last = matches.at(-1)?.[1]?.trim();
1894
- return last || text;
1892
+ void OPENCLAW_CLI_TURN_PATTERN;
1893
+ return text;
1895
1894
  }
1896
1895
  function extractPrompt(messages) {
1897
1896
  const parts = [];
1898
1897
  let system;
1899
1898
  let openingText = "";
1900
- let lastUserText = "";
1899
+ let routeUserText = "";
1900
+ let previousRole;
1901
+ let previousUserText = "";
1901
1902
  for (const msg of messages) {
1902
1903
  if (!msg || typeof msg !== "object") continue;
1903
1904
  const role = msg.role;
@@ -1916,15 +1917,21 @@ ${text2}` : text2;
1916
1917
  } else {
1917
1918
  parts.push(text2);
1918
1919
  if (role === "user" && text2.trim()) {
1919
- lastUserText = extractRouteTextFromUserMessage(text2);
1920
+ if (previousRole === "user" && previousUserText.trim()) {
1921
+ routeUserText = previousUserText;
1922
+ } else {
1923
+ routeUserText = extractRouteTextFromUserMessage(text2);
1924
+ }
1920
1925
  }
1921
1926
  if (!openingText && text2.trim()) {
1922
1927
  openingText = text2;
1923
1928
  }
1924
1929
  }
1930
+ previousRole = role;
1931
+ previousUserText = role === "user" ? extractRouteTextFromUserMessage(text2) : "";
1925
1932
  }
1926
1933
  const text = parts.join(" ");
1927
- return { text, routeText: lastUserText || text, system, openingText };
1934
+ return { text, routeText: routeUserText || text, system, openingText };
1928
1935
  }
1929
1936
  function buildUpstreamHeaders(req, cfg) {
1930
1937
  const headers = {};