@openclaw/moonshot-provider 2026.10.10-beta.5 → 2026.11.5-beta.1
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/.setup/{kimi-web-search-provider-DCbJoku0.mjs → kimi-web-search-provider-FmjLef0K.mjs} +4 -14
- package/dist/.setup/{kimi-web-search-provider.runtime-Je75Zave.mjs → kimi-web-search-provider.runtime-J65Xfgj0.mjs} +42 -63
- package/dist/.setup/{openclaw.plugin-ByEFwJ6V.mjs → openclaw.plugin-L9WEMtMR.mjs} +2 -2
- package/dist/.source-module-urls/98dadda93e14fddcb17e3f2bc9b40b6c0e2f113c184b0544049aa23f330f89aa.json +1 -0
- package/dist/index.js +45 -11
- package/dist/native-video.js +21 -23
- package/dist/provider-catalog.js +2 -3
- package/dist/provider-contract-api.js +2 -3
- package/dist/provider-discovery.js +1 -2
- package/dist/provider-policy-api.js +1 -2
- package/dist/web-search-contract-api.js +1 -1
- package/dist/web-search-provider.js +1 -1
- package/openclaw.plugin.json +1 -0
- package/package.json +4 -4
- package/dist/.source-module-urls/9b20209d0cfce68a5e811be58a0d9c4f3b090a0d73d30d30c6a951f86d0a3437.json +0 -1
- package/dist/media-understanding-provider.js +0 -29
- package/dist/onboard.js +0 -29
package/dist/.setup/{kimi-web-search-provider-DCbJoku0.mjs → kimi-web-search-provider-FmjLef0K.mjs}
RENAMED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import { createLazyRuntimeMethod, createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
2
|
-
import { createWebSearchProviderContractFields } from "openclaw/plugin-sdk/provider-web-search-config-contract";
|
|
3
|
-
|
|
2
|
+
import { WEB_SEARCH_QUERY_COUNT_PROPERTIES, createWebSearchProviderContractFields } from "openclaw/plugin-sdk/provider-web-search-config-contract";
|
|
3
|
+
// 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-J65Xfgj0.mjs"));
|
|
6
6
|
const KimiSearchSchema = {
|
|
7
7
|
type: "object",
|
|
8
8
|
properties: {
|
|
9
|
-
|
|
10
|
-
type: "string",
|
|
11
|
-
description: "Search query string."
|
|
12
|
-
},
|
|
13
|
-
count: {
|
|
14
|
-
type: "integer",
|
|
15
|
-
description: "Number of results to return (1-10).",
|
|
16
|
-
minimum: 1,
|
|
17
|
-
maximum: 10
|
|
18
|
-
},
|
|
9
|
+
...WEB_SEARCH_QUERY_COUNT_PROPERTIES,
|
|
19
10
|
country: {
|
|
20
11
|
type: "string",
|
|
21
12
|
description: "Not supported by Kimi."
|
|
@@ -70,5 +61,4 @@ function createKimiWebSearchProvider() {
|
|
|
70
61
|
})
|
|
71
62
|
};
|
|
72
63
|
}
|
|
73
|
-
//#endregion
|
|
74
64
|
export { createKimiWebSearchProvider as t };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL, isNativeMoonshotBaseUrl } from "../provider-policy-api.js";
|
|
2
2
|
import "../provider-catalog.js";
|
|
3
3
|
import { asNonArrayRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { sha256Hex } from "openclaw/plugin-sdk/node-crypto-runtime";
|
|
4
5
|
import { createProviderHttpError, normalizeBaseUrl, readProviderJsonObjectResponse } from "openclaw/plugin-sdk/provider-http";
|
|
5
|
-
import { DEFAULT_SEARCH_COUNT,
|
|
6
|
-
|
|
6
|
+
import { DEFAULT_SEARCH_COUNT, buildSearchCacheKey, buildUnsupportedSearchFilterResponse, externalContentStamp, mergeScopedSearchConfig, readCachedSearchPayload, readWebSearchApiKey, readWebSearchQueryAndCount, resolveProviderWebSearchPluginConfig, resolveSearchCacheTtlMs, resolveSearchCount, resolveSearchTimeoutSeconds, resolveSiteName, setProviderWebSearchPluginConfigValue, withTrustedWebSearchEndpoint, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
7
|
+
// extensions/moonshot/src/kimi-web-search-provider.runtime.ts
|
|
7
8
|
const DEFAULT_KIMI_BASE_URL = MOONSHOT_BASE_URL;
|
|
8
|
-
function resolveKimiApiKey(kimi) {
|
|
9
|
-
return readConfiguredSecretString(kimi?.apiKey, "plugins.entries.moonshot.config.webSearch.apiKey") ?? readProviderEnvValue(["KIMI_API_KEY", "MOONSHOT_API_KEY"]);
|
|
10
|
-
}
|
|
11
9
|
function resolveKimiBaseUrl(kimi, openClawConfig) {
|
|
12
10
|
const explicitBaseUrl = normalizeOptionalString(kimi?.baseUrl);
|
|
13
11
|
if (explicitBaseUrl) return normalizeBaseUrl(explicitBaseUrl) || DEFAULT_KIMI_BASE_URL;
|
|
@@ -18,93 +16,75 @@ function resolveKimiBaseUrl(kimi, openClawConfig) {
|
|
|
18
16
|
}
|
|
19
17
|
return DEFAULT_KIMI_BASE_URL;
|
|
20
18
|
}
|
|
21
|
-
async function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
async function executeKimiWebSearchProviderTool(ctx, args, opts) {
|
|
20
|
+
opts?.signal?.throwIfAborted();
|
|
21
|
+
const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "kimi", resolveProviderWebSearchPluginConfig(ctx.config, "moonshot"));
|
|
22
|
+
const unsupportedResponse = buildUnsupportedSearchFilterResponse(args, "kimi");
|
|
23
|
+
if (unsupportedResponse) return unsupportedResponse;
|
|
24
|
+
const kimiConfig = asNonArrayRecord(searchConfig?.kimi);
|
|
25
|
+
const apiKey = readWebSearchApiKey(kimiConfig.apiKey, "plugins.entries.moonshot.config.webSearch.apiKey", ["KIMI_API_KEY", "MOONSHOT_API_KEY"]);
|
|
26
|
+
if (!apiKey) return {
|
|
27
|
+
error: "missing_kimi_api_key",
|
|
28
|
+
message: "web_search (kimi) needs a Moonshot API key. Set KIMI_API_KEY or MOONSHOT_API_KEY in the Gateway environment, or configure plugins.entries.moonshot.config.webSearch.apiKey. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.",
|
|
29
|
+
docs: "https://docs.openclaw.ai/tools/web"
|
|
30
|
+
};
|
|
31
|
+
const { query, count: requestedCount } = readWebSearchQueryAndCount(args, searchConfig);
|
|
32
|
+
const count = resolveSearchCount(requestedCount, DEFAULT_SEARCH_COUNT);
|
|
33
|
+
const baseUrl = resolveKimiBaseUrl(kimiConfig, ctx.config);
|
|
34
|
+
const cacheKey = buildSearchCacheKey([
|
|
35
|
+
"kimi",
|
|
36
|
+
sha256Hex(apiKey),
|
|
37
|
+
query,
|
|
38
|
+
baseUrl,
|
|
39
|
+
count
|
|
40
|
+
]);
|
|
41
|
+
const cacheTtlMs = resolveSearchCacheTtlMs(searchConfig);
|
|
42
|
+
const cached = readCachedSearchPayload(cacheKey, cacheTtlMs);
|
|
43
|
+
if (cached) return cached;
|
|
44
|
+
const start = Date.now();
|
|
45
|
+
const timeoutSeconds = resolveSearchTimeoutSeconds(searchConfig);
|
|
46
|
+
const signal = opts?.signal;
|
|
47
|
+
const results = await withTrustedWebSearchEndpoint({
|
|
48
|
+
url: `${baseUrl}/tools/search`,
|
|
49
|
+
timeoutSeconds,
|
|
50
|
+
signal,
|
|
26
51
|
init: {
|
|
27
52
|
method: "POST",
|
|
28
53
|
headers: {
|
|
29
54
|
"Content-Type": "application/json",
|
|
30
|
-
Authorization: `Bearer ${
|
|
55
|
+
Authorization: `Bearer ${apiKey}`
|
|
31
56
|
},
|
|
32
57
|
body: JSON.stringify({
|
|
33
|
-
text_query:
|
|
34
|
-
limit:
|
|
58
|
+
text_query: query,
|
|
59
|
+
limit: count
|
|
35
60
|
})
|
|
36
61
|
}
|
|
37
62
|
}, async (res) => {
|
|
38
63
|
if (!res.ok) throw await createProviderHttpError(res, "Kimi API error");
|
|
39
64
|
const data = await readProviderJsonObjectResponse(res, "Kimi API error");
|
|
40
65
|
if (!Array.isArray(data.search_results)) throw new Error("Kimi API error: malformed JSON response");
|
|
41
|
-
return data.search_results.slice(0,
|
|
66
|
+
return data.search_results.slice(0, count).map((entry) => {
|
|
42
67
|
const result = asNonArrayRecord(entry);
|
|
43
68
|
const title = normalizeOptionalString(result.title);
|
|
44
69
|
const url = normalizeOptionalString(result.url) ?? "";
|
|
45
70
|
const description = normalizeOptionalString(result.snippet);
|
|
71
|
+
const date = normalizeOptionalString(result.date);
|
|
46
72
|
return {
|
|
47
73
|
title: title ? wrapWebContent(title, "web_search") : "",
|
|
48
74
|
url,
|
|
49
75
|
description: description ? wrapWebContent(description, "web_search") : "",
|
|
50
|
-
published:
|
|
76
|
+
published: date && /^\d{4}-\d{2}-\d{2}$/.test(date) ? date : void 0,
|
|
51
77
|
siteName: resolveSiteName(url) || void 0
|
|
52
78
|
};
|
|
53
79
|
});
|
|
54
80
|
});
|
|
55
|
-
}
|
|
56
|
-
function normalizeKimiResultDate(value) {
|
|
57
|
-
const date = normalizeOptionalString(value);
|
|
58
|
-
return date && /^\d{4}-\d{2}-\d{2}$/.test(date) ? date : void 0;
|
|
59
|
-
}
|
|
60
|
-
async function executeKimiWebSearchProviderTool(ctx, args, opts) {
|
|
61
|
-
opts?.signal?.throwIfAborted();
|
|
62
|
-
const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "kimi", resolveProviderWebSearchPluginConfig(ctx.config, "moonshot"));
|
|
63
|
-
const unsupportedResponse = buildUnsupportedSearchFilterResponse(args, "kimi");
|
|
64
|
-
if (unsupportedResponse) return unsupportedResponse;
|
|
65
|
-
const kimiConfig = asNonArrayRecord(searchConfig?.kimi);
|
|
66
|
-
const apiKey = resolveKimiApiKey(kimiConfig);
|
|
67
|
-
if (!apiKey) return {
|
|
68
|
-
error: "missing_kimi_api_key",
|
|
69
|
-
message: "web_search (kimi) needs a Moonshot API key. Set KIMI_API_KEY or MOONSHOT_API_KEY in the Gateway environment, or configure plugins.entries.moonshot.config.webSearch.apiKey. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.",
|
|
70
|
-
docs: "https://docs.openclaw.ai/tools/web"
|
|
71
|
-
};
|
|
72
|
-
const query = readStringParam(args, "query", { required: true });
|
|
73
|
-
const count = resolveSearchCount(readPositiveIntegerParam(args, "count", {
|
|
74
|
-
max: MAX_SEARCH_COUNT,
|
|
75
|
-
message: `count must be an integer from 1 to ${MAX_SEARCH_COUNT}.`
|
|
76
|
-
}) ?? searchConfig?.maxResults, DEFAULT_SEARCH_COUNT);
|
|
77
|
-
const baseUrl = resolveKimiBaseUrl(kimiConfig, ctx.config);
|
|
78
|
-
const cacheKey = buildSearchCacheKey([
|
|
79
|
-
"kimi",
|
|
80
|
-
query,
|
|
81
|
-
baseUrl,
|
|
82
|
-
count
|
|
83
|
-
]);
|
|
84
|
-
const cacheTtlMs = resolveSearchCacheTtlMs(searchConfig);
|
|
85
|
-
const cached = readCachedSearchPayload(cacheKey, cacheTtlMs);
|
|
86
|
-
if (cached) return cached;
|
|
87
|
-
const start = Date.now();
|
|
88
|
-
const results = await runKimiSearch({
|
|
89
|
-
query,
|
|
90
|
-
count,
|
|
91
|
-
apiKey,
|
|
92
|
-
baseUrl,
|
|
93
|
-
timeoutSeconds: resolveSearchTimeoutSeconds(searchConfig),
|
|
94
|
-
signal: opts?.signal
|
|
95
|
-
});
|
|
96
81
|
opts?.signal?.throwIfAborted();
|
|
97
82
|
const payload = {
|
|
98
83
|
query,
|
|
99
84
|
provider: "kimi",
|
|
100
85
|
count: results.length,
|
|
101
86
|
tookMs: Date.now() - start,
|
|
102
|
-
externalContent:
|
|
103
|
-
untrusted: true,
|
|
104
|
-
source: "web_search",
|
|
105
|
-
provider: "kimi",
|
|
106
|
-
wrapped: true
|
|
107
|
-
},
|
|
87
|
+
externalContent: externalContentStamp("kimi"),
|
|
108
88
|
results
|
|
109
89
|
};
|
|
110
90
|
writeCachedSearchPayload(cacheKey, payload, cacheTtlMs);
|
|
@@ -138,5 +118,4 @@ async function runKimiSearchProviderSetup(ctx) {
|
|
|
138
118
|
setProviderWebSearchPluginConfigValue(next, "moonshot", "baseUrl", baseUrl);
|
|
139
119
|
return next;
|
|
140
120
|
}
|
|
141
|
-
//#endregion
|
|
142
121
|
export { executeKimiWebSearchProviderTool, runKimiSearchProviderSetup };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// extensions/moonshot/openclaw.plugin.json
|
|
2
2
|
var openclaw_plugin_default = {
|
|
3
3
|
id: "moonshot",
|
|
4
4
|
categories: ["models"],
|
|
@@ -32,6 +32,7 @@ var openclaw_plugin_default = {
|
|
|
32
32
|
"baseUrl": "https://api.moonshot.ai/v1",
|
|
33
33
|
"api": "openai-completions",
|
|
34
34
|
"defaultModel": "kimi-k3",
|
|
35
|
+
"family": "moonshot",
|
|
35
36
|
"models": [
|
|
36
37
|
{
|
|
37
38
|
"id": "kimi-k3",
|
|
@@ -178,5 +179,4 @@ var openclaw_plugin_default = {
|
|
|
178
179
|
} }
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
|
-
//#endregion
|
|
182
182
|
export { openclaw_plugin_default as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"entries":[{"output":"api.js","source":"extensions/moonshot/api.ts"},{"output":"index.js","source":"extensions/moonshot/index.ts"},{"output":"native-video.js","source":"extensions/moonshot/native-video.ts"},{"output":"provider-catalog.js","source":"extensions/moonshot/provider-catalog.ts"},{"output":"provider-contract-api.js","source":"extensions/moonshot/provider-contract-api.ts"},{"output":"provider-discovery.js","source":"extensions/moonshot/provider-discovery.ts"},{"output":"provider-policy-api.js","source":"extensions/moonshot/provider-policy-api.ts"},{"output":"web-search-contract-api.js","source":"extensions/moonshot/web-search-contract-api.ts"},{"output":"web-search-provider.js","source":"extensions/moonshot/web-search-provider.ts"}],"chunks":[{"output":".setup/kimi-web-search-provider-FmjLef0K.mjs","sha256":"6d56bea96f4ba1f457f5357a3db954ca12661025763c8a1cbcd888cb8099ee72","facadeSource":null,"sources":["extensions/moonshot/src/kimi-web-search-provider.ts"]},{"output":".setup/kimi-web-search-provider.runtime-J65Xfgj0.mjs","sha256":"22a6ce47fecda46a6e2dec78b848164888d270e44814545311ef7d3497838c73","facadeSource":"extensions/moonshot/src/kimi-web-search-provider.runtime.ts","sources":["extensions/moonshot/src/kimi-web-search-provider.runtime.ts"]},{"output":".setup/openclaw.plugin-L9WEMtMR.mjs","sha256":"06115def4ad8231c2068267d841dd5a1191f9890aac4ef744b84eb895abcc9d6","facadeSource":null,"sources":["extensions/moonshot/openclaw.plugin.json"]},{"output":"api.js","sha256":"4bf3ecbf9a4470db6a310a700c704c9ae1f44b442c20bbbdb6e256a50fbdb7e7","facadeSource":"extensions/moonshot/api.ts","sources":[]},{"output":"index.js","sha256":"4370d5493578dfb7dd174b87eccdf34de97ccf7690c2ab986a9c569e312d3a96","facadeSource":"extensions/moonshot/index.ts","sources":["extensions/moonshot/index.ts"]},{"output":"native-video.js","sha256":"369e6822e4e87e8a3e09df26f25372ea78ccc269404d35afaeb81812d9a8aeec","facadeSource":"extensions/moonshot/native-video.ts","sources":["extensions/moonshot/native-video.ts"]},{"output":"provider-catalog.js","sha256":"61f1dd9b0da786088b0461ba79987ffe293748c73643d50de1bdc5daa35d2fbc","facadeSource":"extensions/moonshot/provider-catalog.ts","sources":["extensions/moonshot/provider-catalog.ts"]},{"output":"provider-contract-api.js","sha256":"2013a471a56f1ef15f030b4eb452e3369e0a4ed334a865b92925c00f75caee0f","facadeSource":"extensions/moonshot/provider-contract-api.ts","sources":["extensions/moonshot/provider-contract-api.ts"]},{"output":"provider-discovery.js","sha256":"ca2740f183c084de21982c490dff2ae5912815f7de5a7b8ed39a53b71dca159f","facadeSource":"extensions/moonshot/provider-discovery.ts","sources":["extensions/moonshot/provider-discovery.ts"]},{"output":"provider-policy-api.js","sha256":"bd0af18e6113cf4c560fcac020acfce3fd4177a9f2e84ce4a9e07acf37211b71","facadeSource":"extensions/moonshot/provider-policy-api.ts","sources":["extensions/moonshot/provider-policy-api.ts"]},{"output":"web-search-contract-api.js","sha256":"896f969da21536248650a385f01160a6ac552769359c422e1a44b297522811b8","facadeSource":"extensions/moonshot/web-search-contract-api.ts","sources":[]},{"output":"web-search-provider.js","sha256":"5109f39c798042edf6a239509db754c4f9f3717214cb1b2ba75dd53748fe5d1f","facadeSource":"extensions/moonshot/web-search-provider.ts","sources":[]}],"unrenderedSources":["extensions/moonshot/api.ts","extensions/moonshot/web-search-contract-api.ts","extensions/moonshot/web-search-provider.ts"]}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isMoonshotAlwaysThinkingModelId, isMoonshotK3NativeVideoRoute, resolveThinkingProfile } from "./provider-policy-api.js";
|
|
3
|
-
import { MOONSHOT_DEFAULT_MODEL_REF, buildMoonshotProvider } from "./provider-catalog.js";
|
|
4
|
-
import { moonshotMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
1
|
+
import { MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL, isMoonshotAlwaysThinkingModelId, isMoonshotK3NativeVideoRoute, resolveThinkingProfile } from "./provider-policy-api.js";
|
|
5
2
|
import { wrapMoonshotStream } from "./native-video.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { t as openclaw_plugin_default } from "./.setup/openclaw.plugin-L9WEMtMR.mjs";
|
|
4
|
+
import { MOONSHOT_DEFAULT_MODEL_ID, MOONSHOT_DEFAULT_MODEL_REF, buildMoonshotProvider } from "./provider-catalog.js";
|
|
5
|
+
import { t as createKimiWebSearchProvider } from "./.setup/kimi-web-search-provider-FmjLef0K.mjs";
|
|
6
|
+
import { describeOpenAiCompatibleVideo } from "openclaw/plugin-sdk/media-understanding";
|
|
8
7
|
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
|
9
8
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
10
9
|
import { buildOpenAICompatibleReplayPolicy } from "openclaw/plugin-sdk/provider-model-shared";
|
|
11
|
-
|
|
10
|
+
import { createDefaultModelsPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
|
|
11
|
+
// extensions/moonshot/index.ts
|
|
12
|
+
const moonshotPresetAppliers = createDefaultModelsPresetAppliers({
|
|
13
|
+
primaryModelRef: MOONSHOT_DEFAULT_MODEL_REF,
|
|
14
|
+
resolveParams: (cfg, baseUrl) => {
|
|
15
|
+
const defaultModel = buildMoonshotProvider().models.find(({ id }) => id === MOONSHOT_DEFAULT_MODEL_ID);
|
|
16
|
+
return defaultModel ? {
|
|
17
|
+
providerId: "moonshot",
|
|
18
|
+
api: "openai-completions",
|
|
19
|
+
baseUrl,
|
|
20
|
+
defaultModels: cfg.models?.mode === "replace" ? [defaultModel] : [],
|
|
21
|
+
defaultModelId: MOONSHOT_DEFAULT_MODEL_ID,
|
|
22
|
+
aliases: [{
|
|
23
|
+
modelRef: MOONSHOT_DEFAULT_MODEL_REF,
|
|
24
|
+
alias: "Kimi"
|
|
25
|
+
}]
|
|
26
|
+
} : null;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
12
29
|
const PROVIDER_ID = "moonshot";
|
|
13
30
|
var moonshot_default = defineSingleProviderPluginEntry({
|
|
14
31
|
id: PROVIDER_ID,
|
|
@@ -19,7 +36,7 @@ var moonshot_default = defineSingleProviderPluginEntry({
|
|
|
19
36
|
label: "Moonshot",
|
|
20
37
|
docsPath: "/providers/moonshot",
|
|
21
38
|
aliases: ["moonshotai", "moonshot-ai"],
|
|
22
|
-
manifestAuth: { applyConfig:
|
|
39
|
+
manifestAuth: { applyConfig: (cfg) => moonshotPresetAppliers.applyConfig(cfg, MOONSHOT_BASE_URL) },
|
|
23
40
|
extraAuth: [createProviderApiKeyAuthMethod({
|
|
24
41
|
providerId: PROVIDER_ID,
|
|
25
42
|
methodId: "api-key-cn",
|
|
@@ -30,7 +47,7 @@ var moonshot_default = defineSingleProviderPluginEntry({
|
|
|
30
47
|
envVar: "MOONSHOT_API_KEY",
|
|
31
48
|
promptMessage: "Enter Moonshot API key (.cn)",
|
|
32
49
|
defaultModel: MOONSHOT_DEFAULT_MODEL_REF,
|
|
33
|
-
applyConfig:
|
|
50
|
+
applyConfig: (cfg) => moonshotPresetAppliers.applyConfig(cfg, MOONSHOT_CN_BASE_URL),
|
|
34
51
|
wizard: { groupLabel: "Moonshot AI (Kimi)" }
|
|
35
52
|
})],
|
|
36
53
|
catalog: {
|
|
@@ -60,9 +77,26 @@ var moonshot_default = defineSingleProviderPluginEntry({
|
|
|
60
77
|
isModernModelRef: ({ modelId }) => isMoonshotAlwaysThinkingModelId(modelId)
|
|
61
78
|
},
|
|
62
79
|
register(api) {
|
|
63
|
-
api.registerMediaUnderstandingProvider(
|
|
80
|
+
api.registerMediaUnderstandingProvider({
|
|
81
|
+
id: "moonshot",
|
|
82
|
+
capabilities: ["image", "video"],
|
|
83
|
+
defaultModels: {
|
|
84
|
+
image: openclaw_plugin_default.mediaUnderstandingProviderMetadata.moonshot.defaultModels.image,
|
|
85
|
+
video: openclaw_plugin_default.mediaUnderstandingProviderMetadata.moonshot.defaultModels.video
|
|
86
|
+
},
|
|
87
|
+
autoPriority: { video: 20 },
|
|
88
|
+
describeImage: void 0,
|
|
89
|
+
describeImages: void 0,
|
|
90
|
+
describeVideo: async (params) => describeOpenAiCompatibleVideo({
|
|
91
|
+
...params,
|
|
92
|
+
defaultBaseUrl: MOONSHOT_BASE_URL,
|
|
93
|
+
defaultModel: openclaw_plugin_default.mediaUnderstandingProviderMetadata.moonshot.defaultModels.video,
|
|
94
|
+
defaultPrompt: "Describe the video.",
|
|
95
|
+
provider: "moonshot",
|
|
96
|
+
providerLabel: "Moonshot"
|
|
97
|
+
})
|
|
98
|
+
});
|
|
64
99
|
api.registerWebSearchProvider(createKimiWebSearchProvider());
|
|
65
100
|
}
|
|
66
101
|
});
|
|
67
|
-
//#endregion
|
|
68
102
|
export { moonshot_default as default };
|
package/dist/native-video.js
CHANGED
|
@@ -2,17 +2,10 @@ import { isMoonshotAlwaysThinkingModelId, isMoonshotK3NativeVideoRoute } from ".
|
|
|
2
2
|
import { resolveProviderContext, streamSimple } from "openclaw/plugin-sdk/llm";
|
|
3
3
|
import { createMoonshotThinkingWrapper, resolveMoonshotThinkingKeep, resolveMoonshotThinkingType } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
4
4
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
-
|
|
5
|
+
// extensions/moonshot/native-video.ts
|
|
6
6
|
const VIDEO_PREFIX = "data:video/mp4;base64,";
|
|
7
7
|
const VIDEO_OMISSION = "(video omitted: untrusted or unsupported Moonshot video)";
|
|
8
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
9
|
function partUrl(part, field) {
|
|
17
10
|
const url = isRecord(part[field]) ? part[field].url : void 0;
|
|
18
11
|
return typeof url === "string" ? url : void 0;
|
|
@@ -24,19 +17,6 @@ function replacePart(part, text) {
|
|
|
24
17
|
text
|
|
25
18
|
});
|
|
26
19
|
}
|
|
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
20
|
function wrapMoonshotStream(ctx, simple = false, requestBytesExclusive = MOONSHOT_REQUEST_BYTES_EXCLUSIVE) {
|
|
41
21
|
const underlying = ctx.streamFn ?? streamSimple;
|
|
42
22
|
if (simple && !isMoonshotAlwaysThinkingModelId(ctx.modelId)) return underlying;
|
|
@@ -47,7 +27,25 @@ function wrapMoonshotStream(ctx, simple = false, requestBytesExclusive = MOONSHO
|
|
|
47
27
|
return createMoonshotThinkingWrapper(withVideoContext, resolveMoonshotThinkingType({
|
|
48
28
|
configuredThinking: ctx.extraParams?.thinking,
|
|
49
29
|
thinkingLevel: ctx.thinkingLevel
|
|
50
|
-
}), resolveMoonshotThinkingKeep({ configuredThinking: ctx.extraParams?.thinking }), (result, payload) =>
|
|
30
|
+
}), resolveMoonshotThinkingKeep({ configuredThinking: ctx.extraParams?.thinking }), (result, payload) => {
|
|
31
|
+
const admitted = [];
|
|
32
|
+
const messages = isRecord(payload) && Array.isArray(payload.messages) ? payload.messages : [];
|
|
33
|
+
for (const message of messages) {
|
|
34
|
+
if (!isRecord(message) || message.role !== "user" || !Array.isArray(message.content)) continue;
|
|
35
|
+
for (const part of message.content) {
|
|
36
|
+
if (!isRecord(part)) continue;
|
|
37
|
+
const videoUrl = partUrl(part, "video_url");
|
|
38
|
+
const imageUrl = partUrl(part, "image_url");
|
|
39
|
+
if (part.type === "video_url" && videoUrl?.startsWith(VIDEO_PREFIX)) admitted.push(part);
|
|
40
|
+
else if (part.type === "video_url" || imageUrl?.startsWith("data:video/")) replacePart(part, VIDEO_OMISSION);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
while (Buffer.byteLength(JSON.stringify(payload), "utf8") >= requestBytesExclusive) {
|
|
44
|
+
const part = admitted.pop();
|
|
45
|
+
if (!part) throw new Error(`Moonshot request body must be smaller than ${requestBytesExclusive} bytes`);
|
|
46
|
+
replacePart(part, "(video omitted: Moonshot request size limit)");
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
});
|
|
51
50
|
}
|
|
52
|
-
//#endregion
|
|
53
51
|
export { wrapMoonshotStream };
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as openclaw_plugin_default } from "./.setup/openclaw.plugin-ByEFwJ6V.mjs";
|
|
2
1
|
import { MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL, isNativeMoonshotBaseUrl } from "./provider-policy-api.js";
|
|
2
|
+
import { t as openclaw_plugin_default } from "./.setup/openclaw.plugin-L9WEMtMR.mjs";
|
|
3
3
|
import { buildManifestModelProviderConfig, readManifestProviderDefaultModelRef } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
4
|
-
|
|
4
|
+
// extensions/moonshot/provider-catalog.ts
|
|
5
5
|
const MOONSHOT_DEFAULT_MODEL_REF = readManifestProviderDefaultModelRef(openclaw_plugin_default, "moonshot");
|
|
6
6
|
const MOONSHOT_DEFAULT_MODEL_ID = MOONSHOT_DEFAULT_MODEL_REF.slice(9);
|
|
7
7
|
function buildMoonshotProvider() {
|
|
@@ -10,5 +10,4 @@ function buildMoonshotProvider() {
|
|
|
10
10
|
catalog: openclaw_plugin_default.modelCatalog.providers.moonshot
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
//#endregion
|
|
14
13
|
export { MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL, MOONSHOT_DEFAULT_MODEL_ID, MOONSHOT_DEFAULT_MODEL_REF, buildMoonshotProvider, isNativeMoonshotBaseUrl };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as openclaw_plugin_default } from "./.setup/openclaw.plugin-
|
|
2
|
-
|
|
1
|
+
import { t as openclaw_plugin_default } from "./.setup/openclaw.plugin-L9WEMtMR.mjs";
|
|
2
|
+
// extensions/moonshot/provider-contract-api.ts
|
|
3
3
|
const noopAuth = async () => ({ profiles: [] });
|
|
4
4
|
function createMoonshotProvider() {
|
|
5
5
|
return {
|
|
@@ -17,5 +17,4 @@ function createMoonshotProvider() {
|
|
|
17
17
|
}))
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { createMoonshotProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildMoonshotProvider } from "./provider-catalog.js";
|
|
2
|
-
|
|
2
|
+
// extensions/moonshot/provider-discovery.ts
|
|
3
3
|
const moonshotProviderDiscovery = {
|
|
4
4
|
id: "moonshot",
|
|
5
5
|
label: "Moonshot",
|
|
@@ -11,5 +11,4 @@ const moonshotProviderDiscovery = {
|
|
|
11
11
|
run: async () => ({ provider: buildMoonshotProvider() })
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
14
|
export { moonshotProviderDiscovery as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// extensions/moonshot/provider-policy-api.ts
|
|
2
2
|
const MOONSHOT_BASE_URL = "https://api.moonshot.ai/v1";
|
|
3
3
|
const MOONSHOT_CN_BASE_URL = "https://api.moonshot.cn/v1";
|
|
4
4
|
const KIMI_K2_7_CODE_MODEL_ID = "kimi-k2.7-code";
|
|
@@ -50,5 +50,4 @@ function resolveThinkingProfile(context) {
|
|
|
50
50
|
defaultLevel: "off"
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { KIMI_K2_7_CODE_HIGHSPEED_MODEL_ID, KIMI_K2_7_CODE_MODEL_ID, MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL, isMoonshotAlwaysThinkingModelId, isMoonshotK3NativeVideoRoute, isNativeMoonshotBaseUrl, resolveThinkingProfile };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { t as createKimiWebSearchProvider } from "./.setup/kimi-web-search-provider-
|
|
1
|
+
export { t as createKimiWebSearchProvider } from "./.setup/kimi-web-search-provider-FmjLef0K.mjs";
|
|
2
2
|
import "./web-search-provider.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createKimiWebSearchProvider } from "./.setup/kimi-web-search-provider-
|
|
1
|
+
export { t as createKimiWebSearchProvider } from "./.setup/kimi-web-search-provider-FmjLef0K.mjs";
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/moonshot-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.11.5-beta.1",
|
|
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.11.5-beta.1"
|
|
18
18
|
},
|
|
19
19
|
"build": {
|
|
20
|
-
"openclawVersion": "2026.
|
|
20
|
+
"openclawVersion": "2026.11.5-beta.1",
|
|
21
21
|
"bundledDist": false
|
|
22
22
|
},
|
|
23
23
|
"release": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"assets/activity.svg"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"openclaw": ">=2026.
|
|
43
|
+
"openclaw": ">=2026.11.5-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"entries":[{"output":"api.js","source":"extensions/moonshot/api.ts"},{"output":"index.js","source":"extensions/moonshot/index.ts"},{"output":"media-understanding-provider.js","source":"extensions/moonshot/media-understanding-provider.ts"},{"output":"native-video.js","source":"extensions/moonshot/native-video.ts"},{"output":"onboard.js","source":"extensions/moonshot/onboard.ts"},{"output":"provider-catalog.js","source":"extensions/moonshot/provider-catalog.ts"},{"output":"provider-contract-api.js","source":"extensions/moonshot/provider-contract-api.ts"},{"output":"provider-discovery.js","source":"extensions/moonshot/provider-discovery.ts"},{"output":"provider-policy-api.js","source":"extensions/moonshot/provider-policy-api.ts"},{"output":"web-search-contract-api.js","source":"extensions/moonshot/web-search-contract-api.ts"},{"output":"web-search-provider.js","source":"extensions/moonshot/web-search-provider.ts"}],"chunks":[{"output":".setup/kimi-web-search-provider-DCbJoku0.mjs","sha256":"a07cb457beacf8b3d8353171f124cba657380ad7e7ab8bb7cf6dd9f851b9c9bb","facadeSource":null,"sources":["extensions/moonshot/src/kimi-web-search-provider.ts"]},{"output":".setup/kimi-web-search-provider.runtime-Je75Zave.mjs","sha256":"778cef37a12bc60785c71861a06dc75227f09d70ca9e58a6db54150caad4e3a1","facadeSource":"extensions/moonshot/src/kimi-web-search-provider.runtime.ts","sources":["extensions/moonshot/src/kimi-web-search-provider.runtime.ts"]},{"output":".setup/openclaw.plugin-ByEFwJ6V.mjs","sha256":"0703c43c5e19a27a7adb77b03ca87534cb8eef54d29f6ebb8c21bf86ad385386","facadeSource":null,"sources":["extensions/moonshot/openclaw.plugin.json"]},{"output":"api.js","sha256":"4bf3ecbf9a4470db6a310a700c704c9ae1f44b442c20bbbdb6e256a50fbdb7e7","facadeSource":"extensions/moonshot/api.ts","sources":[]},{"output":"index.js","sha256":"faad1b7b4c3f0732c65ea80829cbaa2e2246b8ea76959887f1ea1aff18c229b9","facadeSource":"extensions/moonshot/index.ts","sources":["extensions/moonshot/index.ts"]},{"output":"media-understanding-provider.js","sha256":"440a31b2a3908a3ff083d63714ca0e4220419e86a90ef927a884f598b27fd4ff","facadeSource":"extensions/moonshot/media-understanding-provider.ts","sources":["extensions/moonshot/media-understanding-provider.ts"]},{"output":"native-video.js","sha256":"a0aed6df1bccfb45987287353f89e79df75c15da339bc844a2046f3f3b6b5354","facadeSource":"extensions/moonshot/native-video.ts","sources":["extensions/moonshot/native-video.ts"]},{"output":"onboard.js","sha256":"b64d824d0b3e01af6bab454dbbfb7cb1c6f9704582a80b352e74cc6386e5a6c3","facadeSource":"extensions/moonshot/onboard.ts","sources":["extensions/moonshot/onboard.ts"]},{"output":"provider-catalog.js","sha256":"e5f808250991466001ad9eaa469dc2aa1060c53a3d4236420f06d0bb6ecf7e8e","facadeSource":"extensions/moonshot/provider-catalog.ts","sources":["extensions/moonshot/provider-catalog.ts"]},{"output":"provider-contract-api.js","sha256":"180fea6dccce810190f78c71e096f4bbdbca21d35869c2e5bc17053c6ab31ec4","facadeSource":"extensions/moonshot/provider-contract-api.ts","sources":["extensions/moonshot/provider-contract-api.ts"]},{"output":"provider-discovery.js","sha256":"e7cada03a31fba2c8fd7fd69a3f34810fffe2b516fbd0f390b5efb79264040f3","facadeSource":"extensions/moonshot/provider-discovery.ts","sources":["extensions/moonshot/provider-discovery.ts"]},{"output":"provider-policy-api.js","sha256":"5349b88cf07c99f547ac25108d8362672e7061e9ac0c1ea598ad001be9622fcb","facadeSource":"extensions/moonshot/provider-policy-api.ts","sources":["extensions/moonshot/provider-policy-api.ts"]},{"output":"web-search-contract-api.js","sha256":"0942cd0a8d266db0b3738c070e22d742067397f43aa63de5ee20657cbcdd8bba","facadeSource":"extensions/moonshot/web-search-contract-api.ts","sources":[]},{"output":"web-search-provider.js","sha256":"933c6768cd54c7eb6ce7fabde3ff017caa1908f18d3eb9644eeb8e99e9ae8e78","facadeSource":"extensions/moonshot/web-search-provider.ts","sources":[]}],"unrenderedSources":["extensions/moonshot/api.ts","extensions/moonshot/web-search-contract-api.ts","extensions/moonshot/web-search-provider.ts"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { t as openclaw_plugin_default } from "./.setup/openclaw.plugin-ByEFwJ6V.mjs";
|
|
2
|
-
import { MOONSHOT_BASE_URL } from "./provider-policy-api.js";
|
|
3
|
-
import "./provider-catalog.js";
|
|
4
|
-
import { describeOpenAiCompatibleVideo } from "openclaw/plugin-sdk/media-understanding";
|
|
5
|
-
//#region extensions/moonshot/media-understanding-provider.ts
|
|
6
|
-
const DEFAULT_MOONSHOT_IMAGE_MODEL = openclaw_plugin_default.mediaUnderstandingProviderMetadata.moonshot.defaultModels.image;
|
|
7
|
-
const DEFAULT_MOONSHOT_VIDEO_MODEL = openclaw_plugin_default.mediaUnderstandingProviderMetadata.moonshot.defaultModels.video;
|
|
8
|
-
const DEFAULT_MOONSHOT_VIDEO_PROMPT = "Describe the video.";
|
|
9
|
-
const moonshotMediaUnderstandingProvider = {
|
|
10
|
-
id: "moonshot",
|
|
11
|
-
capabilities: ["image", "video"],
|
|
12
|
-
defaultModels: {
|
|
13
|
-
image: DEFAULT_MOONSHOT_IMAGE_MODEL,
|
|
14
|
-
video: DEFAULT_MOONSHOT_VIDEO_MODEL
|
|
15
|
-
},
|
|
16
|
-
autoPriority: { video: 20 },
|
|
17
|
-
describeImage: void 0,
|
|
18
|
-
describeImages: void 0,
|
|
19
|
-
describeVideo: async (params) => describeOpenAiCompatibleVideo({
|
|
20
|
-
...params,
|
|
21
|
-
defaultBaseUrl: MOONSHOT_BASE_URL,
|
|
22
|
-
defaultModel: DEFAULT_MOONSHOT_VIDEO_MODEL,
|
|
23
|
-
defaultPrompt: DEFAULT_MOONSHOT_VIDEO_PROMPT,
|
|
24
|
-
provider: "moonshot",
|
|
25
|
-
providerLabel: "Moonshot"
|
|
26
|
-
})
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { moonshotMediaUnderstandingProvider };
|
package/dist/onboard.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { MOONSHOT_BASE_URL, MOONSHOT_CN_BASE_URL } from "./provider-policy-api.js";
|
|
2
|
-
import { MOONSHOT_DEFAULT_MODEL_ID, MOONSHOT_DEFAULT_MODEL_REF, buildMoonshotProvider } from "./provider-catalog.js";
|
|
3
|
-
import { createDefaultModelsPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
|
|
4
|
-
//#region extensions/moonshot/onboard.ts
|
|
5
|
-
const moonshotPresetAppliers = createDefaultModelsPresetAppliers({
|
|
6
|
-
primaryModelRef: MOONSHOT_DEFAULT_MODEL_REF,
|
|
7
|
-
resolveParams: (cfg, baseUrl) => {
|
|
8
|
-
const defaultModel = buildMoonshotProvider().models.find(({ id }) => id === MOONSHOT_DEFAULT_MODEL_ID);
|
|
9
|
-
return defaultModel ? {
|
|
10
|
-
providerId: "moonshot",
|
|
11
|
-
api: "openai-completions",
|
|
12
|
-
baseUrl,
|
|
13
|
-
defaultModels: cfg.models?.mode === "replace" ? [defaultModel] : [],
|
|
14
|
-
defaultModelId: MOONSHOT_DEFAULT_MODEL_ID,
|
|
15
|
-
aliases: [{
|
|
16
|
-
modelRef: MOONSHOT_DEFAULT_MODEL_REF,
|
|
17
|
-
alias: "Kimi"
|
|
18
|
-
}]
|
|
19
|
-
} : null;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
function applyMoonshotConfig(cfg) {
|
|
23
|
-
return moonshotPresetAppliers.applyConfig(cfg, MOONSHOT_BASE_URL);
|
|
24
|
-
}
|
|
25
|
-
function applyMoonshotConfigCn(cfg) {
|
|
26
|
-
return moonshotPresetAppliers.applyConfig(cfg, MOONSHOT_CN_BASE_URL);
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { applyMoonshotConfig, applyMoonshotConfigCn };
|