@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.cjs CHANGED
@@ -1846,6 +1846,17 @@ function getEnvironment() {
1846
1846
  }
1847
1847
 
1848
1848
  // src/providers/openai.ts
1849
+ function toKimiK3Effort(level) {
1850
+ switch (level) {
1851
+ case "low":
1852
+ return "low";
1853
+ case "medium":
1854
+ case "high":
1855
+ return "high";
1856
+ default:
1857
+ return "max";
1858
+ }
1859
+ }
1849
1860
  function extractOpenAIUsage(usage) {
1850
1861
  let cacheRead = 0;
1851
1862
  let cacheWrite = 0;
@@ -1902,6 +1913,7 @@ async function* runStream2(options) {
1902
1913
  const client = createClient2(options);
1903
1914
  const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
1904
1915
  const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
1916
+ const k3Effort = options.thinking ? toKimiK3Effort(options.thinking) : void 0;
1905
1917
  const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
1906
1918
  const hasFixedKimiSampling = isKimiK3 || isKimiK27;
1907
1919
  const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
@@ -1916,9 +1928,11 @@ async function* runStream2(options) {
1916
1928
  }
1917
1929
  const messages = toOpenAIMessages(downgradedMessages, {
1918
1930
  provider: options.provider,
1919
- // K3 and K2.7 preserve reasoning even when the user hides thinking in the
1920
- // UI; keep assistant tool-call history wire-valid in that display mode.
1921
- thinking: isKimiK3 || isKimiK27 || !!options.thinking,
1931
+ // K2.7 preserves reasoning even when the user hides thinking in the UI;
1932
+ // keep assistant tool-call history wire-valid in that display mode. A
1933
+ // disabled K3 must NOT carry placeholder reasoning_content (mirrors the
1934
+ // official CLI: reasoning is preserved only while thinking is enabled).
1935
+ thinking: isKimiK27 || !!options.thinking,
1922
1936
  supportsImages: options.supportsImages
1923
1937
  });
1924
1938
  const defaultTemp = options.provider === "glm" ? 0.6 : void 0;
@@ -1951,9 +1965,11 @@ async function* runStream2(options) {
1951
1965
  if (isKimiK3) {
1952
1966
  const paramsAny = params;
1953
1967
  if (isManagedKimiK3) {
1954
- paramsAny.thinking = { type: "enabled", effort: "max", keep: "all" };
1968
+ paramsAny.thinking = k3Effort ? { type: "enabled", effort: k3Effort, keep: "all" } : { type: "disabled" };
1969
+ } else if (k3Effort) {
1970
+ paramsAny.reasoning_effort = k3Effort;
1955
1971
  } else {
1956
- paramsAny.reasoning_effort = "max";
1972
+ paramsAny.thinking = { type: "disabled" };
1957
1973
  }
1958
1974
  }
1959
1975
  if (usesThinkingParam) {