@kenkaiiii/gg-ai 5.20.5 → 5.22.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/dist/index.js CHANGED
@@ -1786,6 +1786,17 @@ function getEnvironment() {
1786
1786
  }
1787
1787
 
1788
1788
  // src/providers/openai.ts
1789
+ function toKimiK3Effort(level) {
1790
+ switch (level) {
1791
+ case "low":
1792
+ return "low";
1793
+ case "medium":
1794
+ case "high":
1795
+ return "high";
1796
+ default:
1797
+ return "max";
1798
+ }
1799
+ }
1789
1800
  function extractOpenAIUsage(usage) {
1790
1801
  let cacheRead = 0;
1791
1802
  let cacheWrite = 0;
@@ -1842,6 +1853,7 @@ async function* runStream2(options) {
1842
1853
  const client = createClient2(options);
1843
1854
  const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
1844
1855
  const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
1856
+ const k3Effort = options.thinking ? toKimiK3Effort(options.thinking) : void 0;
1845
1857
  const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
1846
1858
  const hasFixedKimiSampling = isKimiK3 || isKimiK27;
1847
1859
  const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
@@ -1856,9 +1868,11 @@ async function* runStream2(options) {
1856
1868
  }
1857
1869
  const messages = toOpenAIMessages(downgradedMessages, {
1858
1870
  provider: options.provider,
1859
- // K3 and K2.7 preserve reasoning even when the user hides thinking in the
1860
- // UI; keep assistant tool-call history wire-valid in that display mode.
1861
- thinking: isKimiK3 || isKimiK27 || !!options.thinking,
1871
+ // K2.7 preserves reasoning even when the user hides thinking in the UI;
1872
+ // keep assistant tool-call history wire-valid in that display mode. A
1873
+ // disabled K3 must NOT carry placeholder reasoning_content (mirrors the
1874
+ // official CLI: reasoning is preserved only while thinking is enabled).
1875
+ thinking: isKimiK27 || !!options.thinking,
1862
1876
  supportsImages: options.supportsImages
1863
1877
  });
1864
1878
  const defaultTemp = options.provider === "glm" ? 0.6 : void 0;
@@ -1891,9 +1905,11 @@ async function* runStream2(options) {
1891
1905
  if (isKimiK3) {
1892
1906
  const paramsAny = params;
1893
1907
  if (isManagedKimiK3) {
1894
- paramsAny.thinking = { type: "enabled", effort: "max", keep: "all" };
1908
+ paramsAny.thinking = k3Effort ? { type: "enabled", effort: k3Effort, keep: "all" } : { type: "disabled" };
1909
+ } else if (k3Effort) {
1910
+ paramsAny.reasoning_effort = k3Effort;
1895
1911
  } else {
1896
- paramsAny.reasoning_effort = "max";
1912
+ paramsAny.thinking = { type: "disabled" };
1897
1913
  }
1898
1914
  }
1899
1915
  if (usesThinkingParam) {