@kenkaiiii/gg-ai 5.17.0 → 5.19.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/README.md +1 -1
- package/dist/index.cjs +35 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Tool parameters are Zod schemas. Converted to JSON Schema at the provider bounda
|
|
|
43
43
|
| `anthropic` | Claude Opus 4.8, Sonnet 5, Haiku 4.5 | Extended thinking, prompt caching, server-side compaction |
|
|
44
44
|
| `openai` | GPT-4.1, o3, o4-mini | Supports OAuth (codex endpoint) and API keys |
|
|
45
45
|
| `glm` | GLM-5.1, GLM-4.7 | Z.AI platform, OpenAI-compatible |
|
|
46
|
-
| `moonshot` | Kimi K2.7 | Moonshot platform, OpenAI-compatible |
|
|
46
|
+
| `moonshot` | Kimi K3, Kimi K2.7 Code | Moonshot platform, OpenAI-compatible |
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
package/dist/index.cjs
CHANGED
|
@@ -118,12 +118,14 @@ var PROVIDER_DISPLAY = {
|
|
|
118
118
|
deepseek: "DeepSeek",
|
|
119
119
|
openrouter: "OpenRouter",
|
|
120
120
|
sakana: "Sakana",
|
|
121
|
+
xai: "xAI (Grok)",
|
|
121
122
|
xiaomi: "Xiaomi (MiMo)",
|
|
122
123
|
minimax: "MiniMax"
|
|
123
124
|
};
|
|
124
125
|
var PROVIDER_STATUS_URL = {
|
|
125
126
|
openai: "status.openai.com",
|
|
126
|
-
anthropic: "status.anthropic.com"
|
|
127
|
+
anthropic: "status.anthropic.com",
|
|
128
|
+
xai: "status.x.ai"
|
|
127
129
|
};
|
|
128
130
|
function providerDisplayName(provider) {
|
|
129
131
|
return PROVIDER_DISPLAY[provider] ?? provider;
|
|
@@ -1892,7 +1894,11 @@ async function* runStream2(options) {
|
|
|
1892
1894
|
const providerName = options.provider ?? "openai";
|
|
1893
1895
|
const useStreaming = options.streaming !== false;
|
|
1894
1896
|
const client = createClient2(options);
|
|
1895
|
-
const
|
|
1897
|
+
const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
|
|
1898
|
+
const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
|
|
1899
|
+
const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
|
|
1900
|
+
const hasFixedKimiSampling = isKimiK3 || isKimiK27;
|
|
1901
|
+
const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1896
1902
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
1897
1903
|
const downgradedMessages = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
|
|
1898
1904
|
if (options.provider === "moonshot") {
|
|
@@ -1904,7 +1910,9 @@ async function* runStream2(options) {
|
|
|
1904
1910
|
}
|
|
1905
1911
|
const messages = toOpenAIMessages(downgradedMessages, {
|
|
1906
1912
|
provider: options.provider,
|
|
1907
|
-
|
|
1913
|
+
// K3 and K2.7 preserve reasoning even when the user hides thinking in the
|
|
1914
|
+
// UI; keep assistant tool-call history wire-valid in that display mode.
|
|
1915
|
+
thinking: isKimiK3 || isKimiK27 || !!options.thinking,
|
|
1908
1916
|
supportsImages: options.supportsImages
|
|
1909
1917
|
});
|
|
1910
1918
|
const defaultTemp = options.provider === "glm" ? 0.6 : void 0;
|
|
@@ -1914,10 +1922,10 @@ async function* runStream2(options) {
|
|
|
1914
1922
|
messages,
|
|
1915
1923
|
stream: useStreaming,
|
|
1916
1924
|
...options.maxTokens ? { max_completion_tokens: options.maxTokens } : {},
|
|
1917
|
-
...effectiveTemp != null && !options.thinking ? { temperature: effectiveTemp } : {},
|
|
1918
|
-
...options.topP != null ? { top_p: options.topP } : {},
|
|
1925
|
+
...effectiveTemp != null && !options.thinking && !hasFixedKimiSampling ? { temperature: effectiveTemp } : {},
|
|
1926
|
+
...options.topP != null && !hasFixedKimiSampling ? { top_p: options.topP } : {},
|
|
1919
1927
|
...options.stop ? { stop: options.stop } : {},
|
|
1920
|
-
...options.thinking && !usesThinkingParam ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1928
|
+
...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1921
1929
|
...options.tools?.length ? { tools: toOpenAITools(options.tools) } : {},
|
|
1922
1930
|
...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
|
|
1923
1931
|
...useStreaming ? { stream_options: { include_usage: true } } : {}
|
|
@@ -1927,13 +1935,21 @@ async function* runStream2(options) {
|
|
|
1927
1935
|
paramsAny.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ggcoder");
|
|
1928
1936
|
if (options.provider === "openai" && options.model.startsWith("gpt-5.6")) {
|
|
1929
1937
|
paramsAny.prompt_cache_options = { mode: "implicit", ttl: "30m" };
|
|
1930
|
-
} else if ((options.cacheRetention ?? "short") === "long") {
|
|
1938
|
+
} else if (!isKimiK3 && (options.cacheRetention ?? "short") === "long") {
|
|
1931
1939
|
paramsAny.prompt_cache_retention = "24h";
|
|
1932
1940
|
}
|
|
1933
1941
|
}
|
|
1934
1942
|
if (options.provider === "openai" && options.serviceTier) {
|
|
1935
1943
|
params.service_tier = options.serviceTier;
|
|
1936
1944
|
}
|
|
1945
|
+
if (isKimiK3) {
|
|
1946
|
+
const paramsAny = params;
|
|
1947
|
+
if (isManagedKimiK3) {
|
|
1948
|
+
paramsAny.thinking = { type: "enabled", effort: "max", keep: "all" };
|
|
1949
|
+
} else {
|
|
1950
|
+
paramsAny.reasoning_effort = "max";
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1937
1953
|
if (usesThinkingParam) {
|
|
1938
1954
|
if (options.thinking) {
|
|
1939
1955
|
params.thinking = { type: "enabled" };
|
|
@@ -3397,6 +3413,18 @@ providerRegistry.register("sakana", {
|
|
|
3397
3413
|
baseUrl: options.baseUrl ?? "https://api.sakana.ai/v1"
|
|
3398
3414
|
})
|
|
3399
3415
|
});
|
|
3416
|
+
providerRegistry.register("xai", {
|
|
3417
|
+
// xAI's public API (console.x.ai key) is OpenAI-compatible — ride the Chat
|
|
3418
|
+
// Completions transport like Moonshot/DeepSeek. Grok reasoning models take
|
|
3419
|
+
// top-level `reasoning_effort` (low/medium/high), which the shared thinking
|
|
3420
|
+
// path already sends. xAI's OAuth path exists but only via the Grok CLI's
|
|
3421
|
+
// private Responses proxy (cli-chat-proxy.grok.com) with reverse-engineered
|
|
3422
|
+
// attribution headers and account-tier gating — intentionally not wired.
|
|
3423
|
+
stream: (options) => streamOpenAI({
|
|
3424
|
+
...options,
|
|
3425
|
+
baseUrl: options.baseUrl ?? "https://api.x.ai/v1"
|
|
3426
|
+
})
|
|
3427
|
+
});
|
|
3400
3428
|
providerRegistry.register("minimax", {
|
|
3401
3429
|
stream: (options) => streamAnthropic({
|
|
3402
3430
|
...options,
|