@openclaw/moonshot-provider 2026.7.2-beta.7 → 2026.8.1-beta.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/index.js +21 -20
- package/dist/{kimi-web-search-provider-DGFWylD8.js → kimi-web-search-provider-CofLF1qp.js} +3 -3
- package/dist/{kimi-web-search-provider.runtime-B6y-kz4c.js → kimi-web-search-provider.runtime-_hv6i3xa.js} +12 -14
- package/dist/media-understanding-provider.js +8 -45
- package/dist/native-video.js +53 -0
- package/dist/onboard.js +3 -4
- package/dist/provider-catalog.js +2 -5
- package/dist/provider-contract-api.js +7 -13
- package/dist/provider-policy-api.js +24 -17
- package/dist/web-search-provider.js +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,35 +1,28 @@
|
|
|
1
|
+
import { t as openclaw_plugin_default } from "./openclaw.plugin-BLi5Z-ZR.js";
|
|
1
2
|
import { MOONSHOT_DEFAULT_MODEL_REF, applyMoonshotNativeStreamingUsageCompat, buildMoonshotProvider } from "./provider-catalog.js";
|
|
2
3
|
import "./api.js";
|
|
3
4
|
import { moonshotMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
5
|
+
import { isMoonshotAlwaysThinkingModelId, isMoonshotK3NativeVideoRoute, resolveThinkingProfile } from "./provider-policy-api.js";
|
|
6
|
+
import { wrapMoonshotStream } from "./native-video.js";
|
|
4
7
|
import { applyMoonshotConfig, applyMoonshotConfigCn } from "./onboard.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
8
|
+
import { t as createKimiWebSearchProvider } from "./kimi-web-search-provider-CofLF1qp.js";
|
|
9
|
+
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
|
7
10
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
8
11
|
import { buildOpenAICompatibleReplayPolicy } from "openclaw/plugin-sdk/provider-model-shared";
|
|
9
|
-
import { buildProviderStreamFamilyHooks } from "openclaw/plugin-sdk/provider-stream-family";
|
|
10
12
|
//#region extensions/moonshot/index.ts
|
|
11
13
|
const PROVIDER_ID = "moonshot";
|
|
12
|
-
const moonshotThinkingStreamHooks = buildProviderStreamFamilyHooks("moonshot-thinking");
|
|
13
14
|
var moonshot_default = defineSingleProviderPluginEntry({
|
|
14
15
|
id: PROVIDER_ID,
|
|
15
16
|
name: "Moonshot Provider",
|
|
16
17
|
description: "Bundled Moonshot provider plugin",
|
|
18
|
+
manifest: openclaw_plugin_default,
|
|
17
19
|
provider: {
|
|
18
20
|
label: "Moonshot",
|
|
19
21
|
docsPath: "/providers/moonshot",
|
|
20
22
|
aliases: ["moonshotai", "moonshot-ai"],
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
hint: "Kimi API models · https://platform.kimi.ai/docs/pricing/chat",
|
|
25
|
-
optionKey: "moonshotApiKey",
|
|
26
|
-
flagName: "--moonshot-api-key",
|
|
27
|
-
envVar: "MOONSHOT_API_KEY",
|
|
28
|
-
promptMessage: "Enter Moonshot API key",
|
|
29
|
-
defaultModel: MOONSHOT_DEFAULT_MODEL_REF,
|
|
30
|
-
applyConfig: (cfg) => applyMoonshotConfig(cfg),
|
|
31
|
-
wizard: { groupLabel: "Moonshot AI (Kimi)" }
|
|
32
|
-
}, {
|
|
23
|
+
manifestAuth: { applyConfig: applyMoonshotConfig },
|
|
24
|
+
extraAuth: [createProviderApiKeyAuthMethod({
|
|
25
|
+
providerId: PROVIDER_ID,
|
|
33
26
|
methodId: "api-key-cn",
|
|
34
27
|
label: "Kimi API key (.cn)",
|
|
35
28
|
hint: "Kimi API models · https://platform.kimi.ai/docs/pricing/chat",
|
|
@@ -38,9 +31,9 @@ var moonshot_default = defineSingleProviderPluginEntry({
|
|
|
38
31
|
envVar: "MOONSHOT_API_KEY",
|
|
39
32
|
promptMessage: "Enter Moonshot API key (.cn)",
|
|
40
33
|
defaultModel: MOONSHOT_DEFAULT_MODEL_REF,
|
|
41
|
-
applyConfig:
|
|
34
|
+
applyConfig: applyMoonshotConfigCn,
|
|
42
35
|
wizard: { groupLabel: "Moonshot AI (Kimi)" }
|
|
43
|
-
}],
|
|
36
|
+
})],
|
|
44
37
|
catalog: {
|
|
45
38
|
buildProvider: buildMoonshotProvider,
|
|
46
39
|
buildStaticProvider: buildMoonshotProvider,
|
|
@@ -48,14 +41,22 @@ var moonshot_default = defineSingleProviderPluginEntry({
|
|
|
48
41
|
liveModelDiscovery: true
|
|
49
42
|
},
|
|
50
43
|
applyNativeStreamingUsageCompat: ({ providerConfig }) => applyMoonshotNativeStreamingUsageCompat(providerConfig),
|
|
44
|
+
normalizeResolvedModel: (ctx) => ({
|
|
45
|
+
...ctx.model,
|
|
46
|
+
input: ctx.model.input.filter((type) => type !== "video").concat(isMoonshotK3NativeVideoRoute({
|
|
47
|
+
...ctx.model,
|
|
48
|
+
provider: ctx.provider,
|
|
49
|
+
modelId: ctx.modelId
|
|
50
|
+
}) ? "video" : [])
|
|
51
|
+
}),
|
|
51
52
|
buildReplayPolicy: ({ modelApi, modelId }) => buildOpenAICompatibleReplayPolicy(modelApi, {
|
|
52
53
|
modelId,
|
|
53
54
|
sanitizeToolCallIds: modelApi === "openai-completions",
|
|
54
55
|
duplicateToolCallIdStyle: "openai",
|
|
55
56
|
dropReasoningFromHistory: false
|
|
56
57
|
}),
|
|
57
|
-
|
|
58
|
-
wrapSimpleCompletionStreamFn: (ctx) =>
|
|
58
|
+
wrapStreamFn: (ctx) => wrapMoonshotStream(ctx),
|
|
59
|
+
wrapSimpleCompletionStreamFn: (ctx) => wrapMoonshotStream(ctx, true),
|
|
59
60
|
resolveThinkingProfile,
|
|
60
61
|
isModernModelRef: ({ modelId }) => isMoonshotAlwaysThinkingModelId(modelId)
|
|
61
62
|
},
|
|
@@ -2,7 +2,7 @@ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
|
2
2
|
import { createWebSearchProviderContractFields } from "openclaw/plugin-sdk/provider-web-search-config-contract";
|
|
3
3
|
//#region extensions/moonshot/src/kimi-web-search-provider.ts
|
|
4
4
|
const KIMI_CREDENTIAL_PATH = "plugins.entries.moonshot.config.webSearch.apiKey";
|
|
5
|
-
const loadKimiWebSearchProviderRuntime = createLazyRuntimeModule(() => import("./kimi-web-search-provider.runtime-
|
|
5
|
+
const loadKimiWebSearchProviderRuntime = createLazyRuntimeModule(() => import("./kimi-web-search-provider.runtime-_hv6i3xa.js"));
|
|
6
6
|
const KimiSearchSchema = {
|
|
7
7
|
type: "object",
|
|
8
8
|
properties: {
|
|
@@ -66,9 +66,9 @@ function createKimiWebSearchProvider() {
|
|
|
66
66
|
createTool: (ctx) => ({
|
|
67
67
|
description: "Search the web using Kimi by Moonshot. Returns AI-synthesized answers with citations from native $web_search.",
|
|
68
68
|
parameters: KimiSearchSchema,
|
|
69
|
-
execute: async (args) => {
|
|
69
|
+
execute: async (args, context) => {
|
|
70
70
|
const { executeKimiWebSearchProviderTool } = await loadKimiWebSearchProviderRuntime();
|
|
71
|
-
return await executeKimiWebSearchProviderTool(ctx, args);
|
|
71
|
+
return await executeKimiWebSearchProviderTool(ctx, args, { signal: context?.signal });
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL, isNativeMoonshotBaseUrl } from "./provider-catalog.js";
|
|
2
|
-
import { createProviderHttpError, readProviderJsonObjectResponse } from "openclaw/plugin-sdk/provider-http";
|
|
3
|
-
import { DEFAULT_SEARCH_COUNT, MAX_SEARCH_COUNT, buildSearchCacheKey, buildUnsupportedSearchFilterResponse, mergeScopedSearchConfig, readCachedSearchPayload, readConfiguredSecretString, readPositiveIntegerParam, readProviderEnvValue, readStringParam, resolveProviderWebSearchPluginConfig, resolveSearchCacheTtlMs, resolveSearchCount, resolveSearchTimeoutSeconds, setProviderWebSearchPluginConfigValue, withTrustedWebSearchEndpoint, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
4
2
|
import { isRecord, normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { createProviderHttpError, readProviderJsonObjectResponse } from "openclaw/plugin-sdk/provider-http";
|
|
4
|
+
import { MAX_SEARCH_COUNT, buildSearchCacheKey, buildUnsupportedSearchFilterResponse, mergeScopedSearchConfig, readCachedSearchPayload, readConfiguredSecretString, readPositiveIntegerParam, readProviderEnvValue, readStringParam, resolveProviderWebSearchPluginConfig, resolveSearchCacheTtlMs, resolveSearchTimeoutSeconds, setProviderWebSearchPluginConfigValue, withTrustedWebSearchEndpoint, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
5
5
|
//#region extensions/moonshot/src/kimi-web-search-provider.runtime.ts
|
|
6
6
|
const DEFAULT_KIMI_BASE_URL = MOONSHOT_BASE_URL;
|
|
7
7
|
const DEFAULT_KIMI_SEARCH_MODEL = "kimi-k2.6";
|
|
@@ -89,6 +89,7 @@ async function runKimiSearch(params) {
|
|
|
89
89
|
const next = await withTrustedWebSearchEndpoint({
|
|
90
90
|
url: endpoint,
|
|
91
91
|
timeoutSeconds: params.timeoutSeconds,
|
|
92
|
+
signal: params.signal,
|
|
92
93
|
init: {
|
|
93
94
|
method: "POST",
|
|
94
95
|
headers: {
|
|
@@ -160,13 +161,10 @@ async function runKimiSearch(params) {
|
|
|
160
161
|
grounded: hasGroundingEvidence
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
-
content: "Search completed but no final answer was produced.",
|
|
165
|
-
citations: [...collectedCitations],
|
|
166
|
-
grounded: hasGroundingEvidence
|
|
167
|
-
};
|
|
164
|
+
throw new Error("Kimi web search exhausted its tool-call rounds without producing a final answer. Retry the query or choose another search provider.");
|
|
168
165
|
}
|
|
169
|
-
async function executeKimiWebSearchProviderTool(ctx, args) {
|
|
166
|
+
async function executeKimiWebSearchProviderTool(ctx, args, opts) {
|
|
167
|
+
opts?.signal?.throwIfAborted();
|
|
170
168
|
const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "kimi", resolveProviderWebSearchPluginConfig(ctx.config, "moonshot"));
|
|
171
169
|
const unsupportedResponse = buildUnsupportedSearchFilterResponse(args, "kimi");
|
|
172
170
|
if (unsupportedResponse) return unsupportedResponse;
|
|
@@ -178,16 +176,15 @@ async function executeKimiWebSearchProviderTool(ctx, args) {
|
|
|
178
176
|
docs: "https://docs.openclaw.ai/tools/web"
|
|
179
177
|
};
|
|
180
178
|
const query = readStringParam(args, "query", { required: true });
|
|
181
|
-
|
|
179
|
+
readPositiveIntegerParam(args, "count", {
|
|
182
180
|
max: MAX_SEARCH_COUNT,
|
|
183
181
|
message: `count must be an integer from 1 to ${MAX_SEARCH_COUNT}.`
|
|
184
|
-
})
|
|
182
|
+
});
|
|
185
183
|
const model = resolveKimiModel(kimiConfig);
|
|
186
184
|
const baseUrl = resolveKimiBaseUrl(kimiConfig, ctx.config);
|
|
187
185
|
const cacheKey = buildSearchCacheKey([
|
|
188
186
|
"kimi",
|
|
189
187
|
query,
|
|
190
|
-
resolveSearchCount(count, DEFAULT_SEARCH_COUNT),
|
|
191
188
|
baseUrl,
|
|
192
189
|
model
|
|
193
190
|
]);
|
|
@@ -199,8 +196,10 @@ async function executeKimiWebSearchProviderTool(ctx, args) {
|
|
|
199
196
|
apiKey,
|
|
200
197
|
baseUrl,
|
|
201
198
|
model,
|
|
202
|
-
timeoutSeconds: resolveSearchTimeoutSeconds(searchConfig)
|
|
199
|
+
timeoutSeconds: resolveSearchTimeoutSeconds(searchConfig),
|
|
200
|
+
signal: opts?.signal
|
|
203
201
|
});
|
|
202
|
+
opts?.signal?.throwIfAborted();
|
|
204
203
|
if (!result.grounded) return {
|
|
205
204
|
error: "kimi_web_search_ungrounded",
|
|
206
205
|
message: "Kimi returned a chat completion without native web-search grounding. Retry the query, switch to a structured provider such as Brave, or use web_fetch/browser for a specific URL.",
|
|
@@ -289,8 +288,7 @@ const testing = {
|
|
|
289
288
|
resolveKimiModel,
|
|
290
289
|
resolveKimiBaseUrl,
|
|
291
290
|
extractKimiCitations,
|
|
292
|
-
hasKimiSearchResults,
|
|
293
291
|
extractKimiToolResultContent
|
|
294
292
|
};
|
|
295
293
|
//#endregion
|
|
296
|
-
export {
|
|
294
|
+
export { executeKimiWebSearchProviderTool, runKimiSearchProviderSetup, testing };
|
|
@@ -1,56 +1,19 @@
|
|
|
1
1
|
import { t as openclaw_plugin_default } from "./openclaw.plugin-BLi5Z-ZR.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MOONSHOT_BASE_URL } from "./provider-catalog.js";
|
|
3
|
+
import { describeImageWithModel, describeImagesWithModel, describeOpenAiCompatibleVideo } from "openclaw/plugin-sdk/media-understanding";
|
|
4
4
|
//#region extensions/moonshot/media-understanding-provider.ts
|
|
5
|
-
const DEFAULT_MOONSHOT_VIDEO_BASE_URL = "https://api.moonshot.ai/v1";
|
|
6
5
|
const DEFAULT_MOONSHOT_IMAGE_MODEL = openclaw_plugin_default.mediaUnderstandingProviderMetadata.moonshot.defaultModels.image;
|
|
7
6
|
const DEFAULT_MOONSHOT_VIDEO_MODEL = openclaw_plugin_default.mediaUnderstandingProviderMetadata.moonshot.defaultModels.video;
|
|
8
7
|
const DEFAULT_MOONSHOT_VIDEO_PROMPT = "Describe the video.";
|
|
9
8
|
async function describeMoonshotVideo(params) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
baseUrl: params.baseUrl,
|
|
16
|
-
defaultBaseUrl: DEFAULT_MOONSHOT_VIDEO_BASE_URL,
|
|
17
|
-
headers: params.headers,
|
|
18
|
-
request: params.request,
|
|
19
|
-
defaultHeaders: {
|
|
20
|
-
"content-type": "application/json",
|
|
21
|
-
authorization: `Bearer ${params.apiKey}`
|
|
22
|
-
},
|
|
9
|
+
return describeOpenAiCompatibleVideo({
|
|
10
|
+
...params,
|
|
11
|
+
defaultBaseUrl: MOONSHOT_BASE_URL,
|
|
12
|
+
defaultModel: DEFAULT_MOONSHOT_VIDEO_MODEL,
|
|
13
|
+
defaultPrompt: DEFAULT_MOONSHOT_VIDEO_PROMPT,
|
|
23
14
|
provider: "moonshot",
|
|
24
|
-
|
|
25
|
-
capability: "video",
|
|
26
|
-
transport: "media-understanding"
|
|
15
|
+
providerLabel: "Moonshot"
|
|
27
16
|
});
|
|
28
|
-
const { response: res, release } = await postJsonRequest({
|
|
29
|
-
url: `${baseUrl}/chat/completions`,
|
|
30
|
-
headers,
|
|
31
|
-
body: buildOpenAiCompatibleVideoRequestBody({
|
|
32
|
-
model,
|
|
33
|
-
prompt,
|
|
34
|
-
mime,
|
|
35
|
-
buffer: params.buffer
|
|
36
|
-
}),
|
|
37
|
-
timeoutMs: params.timeoutMs,
|
|
38
|
-
...params.signal ? { signal: params.signal } : {},
|
|
39
|
-
fetchFn,
|
|
40
|
-
allowPrivateNetwork,
|
|
41
|
-
dispatcherPolicy
|
|
42
|
-
});
|
|
43
|
-
try {
|
|
44
|
-
await assertOkOrThrowHttpError(res, "Moonshot video description failed");
|
|
45
|
-
const text = coerceOpenAiCompatibleVideoText(await readProviderJsonResponse(res, "Moonshot video description failed"));
|
|
46
|
-
if (!text) throw new Error("Moonshot video description response missing content");
|
|
47
|
-
return {
|
|
48
|
-
text,
|
|
49
|
-
model
|
|
50
|
-
};
|
|
51
|
-
} finally {
|
|
52
|
-
await release();
|
|
53
|
-
}
|
|
54
17
|
}
|
|
55
18
|
const moonshotMediaUnderstandingProvider = {
|
|
56
19
|
id: "moonshot",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isMoonshotAlwaysThinkingModelId, isMoonshotK3NativeVideoRoute } from "./provider-policy-api.js";
|
|
2
|
+
import { resolveProviderContext, streamSimple } from "openclaw/plugin-sdk/llm";
|
|
3
|
+
import { createMoonshotThinkingWrapper, resolveMoonshotThinkingKeep, resolveMoonshotThinkingType } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
4
|
+
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
//#region extensions/moonshot/native-video.ts
|
|
6
|
+
const VIDEO_PREFIX = "data:video/mp4;base64,";
|
|
7
|
+
const VIDEO_OMISSION = "(video omitted: untrusted or unsupported Moonshot video)";
|
|
8
|
+
const MOONSHOT_REQUEST_BYTES_EXCLUSIVE = 1e8;
|
|
9
|
+
function forEachUserContentPart(payload, visit) {
|
|
10
|
+
const messages = isRecord(payload) && Array.isArray(payload.messages) ? payload.messages : [];
|
|
11
|
+
for (const message of messages) {
|
|
12
|
+
if (!isRecord(message) || message.role !== "user" || !Array.isArray(message.content)) continue;
|
|
13
|
+
for (const part of message.content) if (isRecord(part)) visit(part);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function partUrl(part, field) {
|
|
17
|
+
const url = isRecord(part[field]) ? part[field].url : void 0;
|
|
18
|
+
return typeof url === "string" ? url : void 0;
|
|
19
|
+
}
|
|
20
|
+
function replacePart(part, text) {
|
|
21
|
+
Object.keys(part).forEach((key) => Reflect.deleteProperty(part, key));
|
|
22
|
+
Object.assign(part, {
|
|
23
|
+
type: "text",
|
|
24
|
+
text
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function finalizePayload(result, payload, requestBytesExclusive) {
|
|
28
|
+
const admitted = [];
|
|
29
|
+
forEachUserContentPart(payload, (part) => {
|
|
30
|
+
const videoUrl = partUrl(part, "video_url");
|
|
31
|
+
const imageUrl = partUrl(part, "image_url");
|
|
32
|
+
if (part.type === "video_url" && videoUrl?.startsWith(VIDEO_PREFIX)) admitted.push(part);
|
|
33
|
+
else if (part.type === "video_url" || imageUrl?.startsWith("data:video/")) replacePart(part, VIDEO_OMISSION);
|
|
34
|
+
});
|
|
35
|
+
const isOversized = () => Buffer.byteLength(JSON.stringify(payload), "utf8") >= requestBytesExclusive;
|
|
36
|
+
while (admitted.length > 0 && isOversized()) replacePart(admitted.pop(), "(video omitted: Moonshot request size limit)");
|
|
37
|
+
if (isOversized()) throw new Error(`Moonshot request body must be smaller than ${requestBytesExclusive} bytes`);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
function wrapMoonshotStream(ctx, simple = false, requestBytesExclusive = MOONSHOT_REQUEST_BYTES_EXCLUSIVE) {
|
|
41
|
+
const underlying = ctx.streamFn ?? streamSimple;
|
|
42
|
+
if (simple && !isMoonshotAlwaysThinkingModelId(ctx.modelId)) return underlying;
|
|
43
|
+
const withVideoContext = (model, context, options) => isMoonshotK3NativeVideoRoute({
|
|
44
|
+
...model,
|
|
45
|
+
modelId: model.id
|
|
46
|
+
}) ? resolveProviderContext(context, options).then((providerContext) => underlying(model, providerContext, options)) : underlying(model, context, options);
|
|
47
|
+
return createMoonshotThinkingWrapper(withVideoContext, resolveMoonshotThinkingType({
|
|
48
|
+
configuredThinking: ctx.extraParams?.thinking,
|
|
49
|
+
thinkingLevel: ctx.thinkingLevel
|
|
50
|
+
}), resolveMoonshotThinkingKeep({ configuredThinking: ctx.extraParams?.thinking }), (result, payload) => finalizePayload(result, payload, requestBytesExclusive));
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { wrapMoonshotStream };
|
package/dist/onboard.js
CHANGED
|
@@ -4,9 +4,8 @@ import { createDefaultModelPresetAppliers } from "openclaw/plugin-sdk/provider-o
|
|
|
4
4
|
const moonshotPresetAppliers = createDefaultModelPresetAppliers({
|
|
5
5
|
primaryModelRef: MOONSHOT_DEFAULT_MODEL_REF,
|
|
6
6
|
resolveParams: (_cfg, baseUrl) => {
|
|
7
|
-
const defaultModel = buildMoonshotProvider().models.find((
|
|
8
|
-
|
|
9
|
-
return {
|
|
7
|
+
const defaultModel = buildMoonshotProvider().models.find(({ id }) => id === MOONSHOT_DEFAULT_MODEL_ID);
|
|
8
|
+
return defaultModel ? {
|
|
10
9
|
providerId: "moonshot",
|
|
11
10
|
api: "openai-completions",
|
|
12
11
|
baseUrl,
|
|
@@ -16,7 +15,7 @@ const moonshotPresetAppliers = createDefaultModelPresetAppliers({
|
|
|
16
15
|
modelRef: MOONSHOT_DEFAULT_MODEL_REF,
|
|
17
16
|
alias: "Kimi"
|
|
18
17
|
}]
|
|
19
|
-
};
|
|
18
|
+
} : null;
|
|
20
19
|
}
|
|
21
20
|
});
|
|
22
21
|
function applyMoonshotConfig(cfg) {
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { t as openclaw_plugin_default } from "./openclaw.plugin-BLi5Z-ZR.js";
|
|
2
|
-
import { applyProviderNativeStreamingUsageCompat, buildManifestModelProviderConfig, readManifestProviderDefaultModelRef
|
|
2
|
+
import { applyProviderNativeStreamingUsageCompat, buildManifestModelProviderConfig, readManifestProviderDefaultModelRef } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
3
3
|
//#region extensions/moonshot/provider-catalog.ts
|
|
4
4
|
const MOONSHOT_BASE_URL = "https://api.moonshot.ai/v1";
|
|
5
5
|
const MOONSHOT_CN_BASE_URL = "https://api.moonshot.cn/v1";
|
|
6
6
|
const MOONSHOT_DEFAULT_MODEL_REF = readManifestProviderDefaultModelRef(openclaw_plugin_default, "moonshot");
|
|
7
7
|
const MOONSHOT_DEFAULT_MODEL_ID = MOONSHOT_DEFAULT_MODEL_REF.slice(9);
|
|
8
8
|
function isNativeMoonshotBaseUrl(baseUrl) {
|
|
9
|
-
return
|
|
10
|
-
providerId: "moonshot",
|
|
11
|
-
baseUrl
|
|
12
|
-
});
|
|
9
|
+
return [MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL].some((official) => baseUrl === official || baseUrl === `${official}/`);
|
|
13
10
|
}
|
|
14
11
|
function applyMoonshotNativeStreamingUsageCompat(provider) {
|
|
15
12
|
return applyProviderNativeStreamingUsageCompat({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as openclaw_plugin_default } from "./openclaw.plugin-BLi5Z-ZR.js";
|
|
1
2
|
//#region extensions/moonshot/provider-contract-api.ts
|
|
2
3
|
const noopAuth = async () => ({ profiles: [] });
|
|
3
4
|
function createMoonshotProvider() {
|
|
@@ -6,21 +7,14 @@ function createMoonshotProvider() {
|
|
|
6
7
|
label: "Moonshot",
|
|
7
8
|
docsPath: "/providers/moonshot",
|
|
8
9
|
aliases: ["moonshotai", "moonshot-ai"],
|
|
9
|
-
auth:
|
|
10
|
-
id:
|
|
10
|
+
auth: openclaw_plugin_default.providerAuthChoices.map((choice) => ({
|
|
11
|
+
id: choice.method,
|
|
11
12
|
kind: "api_key",
|
|
12
|
-
label:
|
|
13
|
-
hint:
|
|
13
|
+
label: choice.choiceLabel,
|
|
14
|
+
hint: choice.groupHint,
|
|
14
15
|
run: noopAuth,
|
|
15
|
-
wizard: { groupLabel:
|
|
16
|
-
}
|
|
17
|
-
id: "api-key-cn",
|
|
18
|
-
kind: "api_key",
|
|
19
|
-
label: "Kimi API key (.cn)",
|
|
20
|
-
hint: "Kimi API models · https://platform.kimi.ai/docs/pricing/chat",
|
|
21
|
-
run: noopAuth,
|
|
22
|
-
wizard: { groupLabel: "Moonshot AI (Kimi)" }
|
|
23
|
-
}]
|
|
16
|
+
wizard: { groupLabel: choice.groupLabel }
|
|
17
|
+
}))
|
|
24
18
|
};
|
|
25
19
|
}
|
|
26
20
|
//#endregion
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
+
import { isNativeMoonshotBaseUrl } from "./provider-catalog.js";
|
|
1
2
|
//#region extensions/moonshot/provider-policy-api.ts
|
|
2
3
|
const KIMI_K2_7_CODE_MODEL_ID = "kimi-k2.7-code";
|
|
3
4
|
const KIMI_K2_7_CODE_HIGHSPEED_MODEL_ID = "kimi-k2.7-code-highspeed";
|
|
4
5
|
const KIMI_K3_MODEL_ID = "kimi-k3";
|
|
6
|
+
const ALWAYS_THINKING_PROFILES = {
|
|
7
|
+
[KIMI_K3_MODEL_ID]: {
|
|
8
|
+
id: "max",
|
|
9
|
+
label: "max"
|
|
10
|
+
},
|
|
11
|
+
[KIMI_K2_7_CODE_MODEL_ID]: {
|
|
12
|
+
id: "low",
|
|
13
|
+
label: "on"
|
|
14
|
+
},
|
|
15
|
+
[KIMI_K2_7_CODE_HIGHSPEED_MODEL_ID]: {
|
|
16
|
+
id: "low",
|
|
17
|
+
label: "on"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function isMoonshotK3NativeVideoRoute(route) {
|
|
21
|
+
return route.provider === "moonshot" && route.modelId === "kimi-k3" && route.api === "openai-completions" && isNativeMoonshotBaseUrl(route.baseUrl);
|
|
22
|
+
}
|
|
5
23
|
function isMoonshotAlwaysThinkingModelId(modelId) {
|
|
6
|
-
|
|
7
|
-
return normalized === "kimi-k2.7-code" || normalized === "kimi-k2.7-code-highspeed" || normalized === "kimi-k3";
|
|
24
|
+
return modelId.trim().toLowerCase() in ALWAYS_THINKING_PROFILES;
|
|
8
25
|
}
|
|
9
26
|
function resolveThinkingProfile(context) {
|
|
10
27
|
const modelId = context.modelId.trim().toLowerCase();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}],
|
|
16
|
-
defaultLevel: "max",
|
|
17
|
-
preserveWhenCatalogReasoningFalse: true
|
|
18
|
-
};
|
|
19
|
-
if (modelId === "kimi-k2.7-code" || modelId === "kimi-k2.7-code-highspeed") return {
|
|
20
|
-
levels: [{
|
|
21
|
-
id: "low",
|
|
22
|
-
label: "on"
|
|
23
|
-
}],
|
|
24
|
-
defaultLevel: "low",
|
|
28
|
+
const profile = ALWAYS_THINKING_PROFILES[modelId];
|
|
29
|
+
if (profile) return {
|
|
30
|
+
levels: [profile],
|
|
31
|
+
defaultLevel: profile.id,
|
|
25
32
|
preserveWhenCatalogReasoningFalse: true
|
|
26
33
|
};
|
|
27
34
|
return {
|
|
@@ -36,4 +43,4 @@ function resolveThinkingProfile(context) {
|
|
|
36
43
|
};
|
|
37
44
|
}
|
|
38
45
|
//#endregion
|
|
39
|
-
export { KIMI_K2_7_CODE_HIGHSPEED_MODEL_ID, KIMI_K2_7_CODE_MODEL_ID, KIMI_K3_MODEL_ID, isMoonshotAlwaysThinkingModelId, resolveThinkingProfile };
|
|
46
|
+
export { KIMI_K2_7_CODE_HIGHSPEED_MODEL_ID, KIMI_K2_7_CODE_MODEL_ID, KIMI_K3_MODEL_ID, isMoonshotAlwaysThinkingModelId, isMoonshotK3NativeVideoRoute, resolveThinkingProfile };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createKimiWebSearchProvider } from "./kimi-web-search-provider-
|
|
1
|
+
import { t as createKimiWebSearchProvider } from "./kimi-web-search-provider-CofLF1qp.js";
|
|
2
2
|
export { createKimiWebSearchProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/moonshot-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.8.1-beta.3",
|
|
4
4
|
"description": "OpenClaw Moonshot provider plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"openclaw": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"minHostVersion": ">=2026.6.9"
|
|
15
15
|
},
|
|
16
16
|
"compat": {
|
|
17
|
-
"pluginApi": ">=2026.
|
|
17
|
+
"pluginApi": ">=2026.8.1-beta.3"
|
|
18
18
|
},
|
|
19
19
|
"build": {
|
|
20
|
-
"openclawVersion": "2026.
|
|
20
|
+
"openclawVersion": "2026.8.1-beta.3",
|
|
21
21
|
"bundledDist": false
|
|
22
22
|
},
|
|
23
23
|
"release": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"README.md"
|
|
39
39
|
],
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"openclaw": ">=2026.
|
|
41
|
+
"openclaw": ">=2026.8.1-beta.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|