@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/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
3
|
import OpenAI from 'openai';
|
|
4
4
|
|
|
5
|
-
type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "sakana" | "palsu";
|
|
5
|
+
type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "sakana" | "xai" | "palsu";
|
|
6
6
|
type ThinkingLevel = "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
7
7
|
type CacheRetention = "none" | "short" | "long";
|
|
8
8
|
interface TextContent {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
3
|
import OpenAI from 'openai';
|
|
4
4
|
|
|
5
|
-
type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "sakana" | "palsu";
|
|
5
|
+
type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "sakana" | "xai" | "palsu";
|
|
6
6
|
type ThinkingLevel = "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
7
7
|
type CacheRetention = "none" | "short" | "long";
|
|
8
8
|
interface TextContent {
|
package/dist/index.js
CHANGED
|
@@ -58,12 +58,14 @@ var PROVIDER_DISPLAY = {
|
|
|
58
58
|
deepseek: "DeepSeek",
|
|
59
59
|
openrouter: "OpenRouter",
|
|
60
60
|
sakana: "Sakana",
|
|
61
|
+
xai: "xAI (Grok)",
|
|
61
62
|
xiaomi: "Xiaomi (MiMo)",
|
|
62
63
|
minimax: "MiniMax"
|
|
63
64
|
};
|
|
64
65
|
var PROVIDER_STATUS_URL = {
|
|
65
66
|
openai: "status.openai.com",
|
|
66
|
-
anthropic: "status.anthropic.com"
|
|
67
|
+
anthropic: "status.anthropic.com",
|
|
68
|
+
xai: "status.x.ai"
|
|
67
69
|
};
|
|
68
70
|
function providerDisplayName(provider) {
|
|
69
71
|
return PROVIDER_DISPLAY[provider] ?? provider;
|
|
@@ -1832,7 +1834,11 @@ async function* runStream2(options) {
|
|
|
1832
1834
|
const providerName = options.provider ?? "openai";
|
|
1833
1835
|
const useStreaming = options.streaming !== false;
|
|
1834
1836
|
const client = createClient2(options);
|
|
1835
|
-
const
|
|
1837
|
+
const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
|
|
1838
|
+
const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
|
|
1839
|
+
const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
|
|
1840
|
+
const hasFixedKimiSampling = isKimiK3 || isKimiK27;
|
|
1841
|
+
const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1836
1842
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
1837
1843
|
const downgradedMessages = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
|
|
1838
1844
|
if (options.provider === "moonshot") {
|
|
@@ -1844,7 +1850,9 @@ async function* runStream2(options) {
|
|
|
1844
1850
|
}
|
|
1845
1851
|
const messages = toOpenAIMessages(downgradedMessages, {
|
|
1846
1852
|
provider: options.provider,
|
|
1847
|
-
|
|
1853
|
+
// K3 and K2.7 preserve reasoning even when the user hides thinking in the
|
|
1854
|
+
// UI; keep assistant tool-call history wire-valid in that display mode.
|
|
1855
|
+
thinking: isKimiK3 || isKimiK27 || !!options.thinking,
|
|
1848
1856
|
supportsImages: options.supportsImages
|
|
1849
1857
|
});
|
|
1850
1858
|
const defaultTemp = options.provider === "glm" ? 0.6 : void 0;
|
|
@@ -1854,10 +1862,10 @@ async function* runStream2(options) {
|
|
|
1854
1862
|
messages,
|
|
1855
1863
|
stream: useStreaming,
|
|
1856
1864
|
...options.maxTokens ? { max_completion_tokens: options.maxTokens } : {},
|
|
1857
|
-
...effectiveTemp != null && !options.thinking ? { temperature: effectiveTemp } : {},
|
|
1858
|
-
...options.topP != null ? { top_p: options.topP } : {},
|
|
1865
|
+
...effectiveTemp != null && !options.thinking && !hasFixedKimiSampling ? { temperature: effectiveTemp } : {},
|
|
1866
|
+
...options.topP != null && !hasFixedKimiSampling ? { top_p: options.topP } : {},
|
|
1859
1867
|
...options.stop ? { stop: options.stop } : {},
|
|
1860
|
-
...options.thinking && !usesThinkingParam ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1868
|
+
...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1861
1869
|
...options.tools?.length ? { tools: toOpenAITools(options.tools) } : {},
|
|
1862
1870
|
...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
|
|
1863
1871
|
...useStreaming ? { stream_options: { include_usage: true } } : {}
|
|
@@ -1867,13 +1875,21 @@ async function* runStream2(options) {
|
|
|
1867
1875
|
paramsAny.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ggcoder");
|
|
1868
1876
|
if (options.provider === "openai" && options.model.startsWith("gpt-5.6")) {
|
|
1869
1877
|
paramsAny.prompt_cache_options = { mode: "implicit", ttl: "30m" };
|
|
1870
|
-
} else if ((options.cacheRetention ?? "short") === "long") {
|
|
1878
|
+
} else if (!isKimiK3 && (options.cacheRetention ?? "short") === "long") {
|
|
1871
1879
|
paramsAny.prompt_cache_retention = "24h";
|
|
1872
1880
|
}
|
|
1873
1881
|
}
|
|
1874
1882
|
if (options.provider === "openai" && options.serviceTier) {
|
|
1875
1883
|
params.service_tier = options.serviceTier;
|
|
1876
1884
|
}
|
|
1885
|
+
if (isKimiK3) {
|
|
1886
|
+
const paramsAny = params;
|
|
1887
|
+
if (isManagedKimiK3) {
|
|
1888
|
+
paramsAny.thinking = { type: "enabled", effort: "max", keep: "all" };
|
|
1889
|
+
} else {
|
|
1890
|
+
paramsAny.reasoning_effort = "max";
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1877
1893
|
if (usesThinkingParam) {
|
|
1878
1894
|
if (options.thinking) {
|
|
1879
1895
|
params.thinking = { type: "enabled" };
|
|
@@ -3337,6 +3353,18 @@ providerRegistry.register("sakana", {
|
|
|
3337
3353
|
baseUrl: options.baseUrl ?? "https://api.sakana.ai/v1"
|
|
3338
3354
|
})
|
|
3339
3355
|
});
|
|
3356
|
+
providerRegistry.register("xai", {
|
|
3357
|
+
// xAI's public API (console.x.ai key) is OpenAI-compatible — ride the Chat
|
|
3358
|
+
// Completions transport like Moonshot/DeepSeek. Grok reasoning models take
|
|
3359
|
+
// top-level `reasoning_effort` (low/medium/high), which the shared thinking
|
|
3360
|
+
// path already sends. xAI's OAuth path exists but only via the Grok CLI's
|
|
3361
|
+
// private Responses proxy (cli-chat-proxy.grok.com) with reverse-engineered
|
|
3362
|
+
// attribution headers and account-tier gating — intentionally not wired.
|
|
3363
|
+
stream: (options) => streamOpenAI({
|
|
3364
|
+
...options,
|
|
3365
|
+
baseUrl: options.baseUrl ?? "https://api.x.ai/v1"
|
|
3366
|
+
})
|
|
3367
|
+
});
|
|
3340
3368
|
providerRegistry.register("minimax", {
|
|
3341
3369
|
stream: (options) => streamAnthropic({
|
|
3342
3370
|
...options,
|