@openclaw/chutes-provider 2026.7.2-beta.1 → 2026.7.2-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/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CHUTES_BASE_URL, CHUTES_DEFAULT_MODEL_ID, CHUTES_DEFAULT_MODEL_REF, CHUTES_MODEL_CATALOG, buildChutesModelDefinition, discoverChutesModels } from "./models.js";
1
+ import { a as buildChutesModelDefinition, i as CHUTES_MODEL_CATALOG, n as CHUTES_DEFAULT_MODEL_ID, o as discoverChutesModels, r as CHUTES_DEFAULT_MODEL_REF, t as CHUTES_BASE_URL } from "./models-C-YNyvwK.js";
2
2
  import { applyChutesApiKeyConfig, applyChutesConfig, applyChutesProviderConfig } from "./onboard.js";
3
3
  import { buildChutesProvider } from "./provider-catalog.js";
4
4
  export { CHUTES_BASE_URL, CHUTES_DEFAULT_MODEL_ID, CHUTES_DEFAULT_MODEL_REF, CHUTES_MODEL_CATALOG, applyChutesApiKeyConfig, applyChutesConfig, applyChutesProviderConfig, buildChutesModelDefinition, buildChutesProvider, discoverChutesModels };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { loginChutes } from "./oauth.js";
2
- import { CHUTES_DEFAULT_MODEL_REF } from "./models.js";
2
+ import { r as CHUTES_DEFAULT_MODEL_REF } from "./models-C-YNyvwK.js";
3
3
  import { applyChutesApiKeyConfig, applyChutesProviderConfig } from "./onboard.js";
4
4
  import { buildChutesProvider, buildStaticChutesProvider } from "./provider-catalog.js";
5
5
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
@@ -0,0 +1,182 @@
1
+ import { isChutesModelDiscoveryTestEnvironment } from "./model-discovery-env.js";
2
+ import { asPositiveSafeInteger, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { LiveModelCatalogHttpError, getCachedLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
4
+ import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
5
+ import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
6
+ import { ssrfPolicyFromHttpBaseUrlAllowedHostname } from "openclaw/plugin-sdk/ssrf-runtime";
7
+ //#region extensions/chutes/openclaw.plugin.json
8
+ var modelCatalog = {
9
+ "providers": { "chutes": {
10
+ "baseUrl": "https://llm.chutes.ai/v1",
11
+ "api": "openai-completions",
12
+ "models": [
13
+ {
14
+ "id": "deepseek-ai/DeepSeek-V3.2-TEE",
15
+ "name": "deepseek-ai/DeepSeek-V3.2-TEE",
16
+ "reasoning": true,
17
+ "input": ["text"],
18
+ "contextWindow": 131072,
19
+ "maxTokens": 65536,
20
+ "cost": {
21
+ "input": 1,
22
+ "output": 1,
23
+ "cacheRead": .5,
24
+ "cacheWrite": 0
25
+ }
26
+ },
27
+ {
28
+ "id": "moonshotai/Kimi-K2.5-TEE",
29
+ "name": "moonshotai/Kimi-K2.5-TEE",
30
+ "reasoning": true,
31
+ "input": ["text", "image"],
32
+ "contextWindow": 262144,
33
+ "maxTokens": 65535,
34
+ "cost": {
35
+ "input": .44,
36
+ "output": 2,
37
+ "cacheRead": .22,
38
+ "cacheWrite": 0
39
+ }
40
+ },
41
+ {
42
+ "id": "zai-org/GLM-5-TEE",
43
+ "name": "zai-org/GLM-5-TEE",
44
+ "reasoning": true,
45
+ "input": ["text"],
46
+ "contextWindow": 202752,
47
+ "maxTokens": 65535,
48
+ "cost": {
49
+ "input": .95,
50
+ "output": 2.55,
51
+ "cacheRead": .475,
52
+ "cacheWrite": 0
53
+ }
54
+ },
55
+ {
56
+ "id": "MiniMaxAI/MiniMax-M2.5-TEE",
57
+ "name": "MiniMaxAI/MiniMax-M2.5-TEE",
58
+ "reasoning": true,
59
+ "input": ["text"],
60
+ "contextWindow": 196608,
61
+ "maxTokens": 65536,
62
+ "cost": {
63
+ "input": .15,
64
+ "output": 1.2,
65
+ "cacheRead": .075,
66
+ "cacheWrite": 0
67
+ }
68
+ },
69
+ {
70
+ "id": "Qwen/Qwen3.5-397B-A17B-TEE",
71
+ "name": "Qwen/Qwen3.5-397B-A17B-TEE",
72
+ "reasoning": true,
73
+ "input": ["text", "image"],
74
+ "contextWindow": 262144,
75
+ "maxTokens": 65536,
76
+ "cost": {
77
+ "input": .45,
78
+ "output": 3,
79
+ "cacheRead": .225,
80
+ "cacheWrite": 0
81
+ }
82
+ }
83
+ ]
84
+ } },
85
+ "discovery": { "chutes": "refreshable" }
86
+ };
87
+ //#endregion
88
+ //#region extensions/chutes/models.ts
89
+ /**
90
+ * Chutes model catalog, static model definitions, and dynamic model discovery.
91
+ */
92
+ const log = createSubsystemLogger("chutes-models");
93
+ const CHUTES_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
94
+ providerId: "chutes",
95
+ catalog: modelCatalog.providers.chutes
96
+ });
97
+ /** Base URL for Chutes OpenAI-compatible inference. */
98
+ const CHUTES_BASE_URL = CHUTES_MANIFEST_PROVIDER.baseUrl;
99
+ /** Default Chutes model id used for onboarding. */
100
+ const CHUTES_DEFAULT_MODEL_ID = "zai-org/GLM-5-TEE";
101
+ /** Default Chutes model ref used for onboarding. */
102
+ const CHUTES_DEFAULT_MODEL_REF = `chutes/${CHUTES_DEFAULT_MODEL_ID}`;
103
+ const CHUTES_DEFAULT_CONTEXT_WINDOW = 128e3;
104
+ const CHUTES_DEFAULT_MAX_TOKENS = 4096;
105
+ /** Bundled fallback Chutes model catalog, normalized from the plugin manifest. */
106
+ const CHUTES_MODEL_CATALOG = CHUTES_MANIFEST_PROVIDER.models;
107
+ /** Adds Chutes provider compat metadata to one model catalog entry. */
108
+ function buildChutesModelDefinition(model) {
109
+ return {
110
+ ...model,
111
+ compat: {
112
+ ...model.compat,
113
+ supportsUsageInStreaming: false
114
+ }
115
+ };
116
+ }
117
+ const CACHE_TTL = 300 * 1e3;
118
+ async function fetchChutesModelRows(accessToken) {
119
+ return await getCachedLiveProviderModelRows({
120
+ providerId: "chutes",
121
+ endpoint: `${CHUTES_BASE_URL}/models`,
122
+ discoveryApiKey: accessToken,
123
+ timeoutMs: 1e4,
124
+ ttlMs: CACHE_TTL,
125
+ buildRequestHeaders: ({ discoveryApiKey }) => ({
126
+ Accept: "application/json",
127
+ ...discoveryApiKey ? { Authorization: `Bearer ${discoveryApiKey}` } : {}
128
+ }),
129
+ policy: ssrfPolicyFromHttpBaseUrlAllowedHostname(CHUTES_BASE_URL),
130
+ auditContext: "chutes-model-discovery"
131
+ });
132
+ }
133
+ /** Discovers Chutes models dynamically, falling back to the bundled static catalog. */
134
+ async function discoverChutesModels(accessToken) {
135
+ const trimmedKey = normalizeOptionalString(accessToken) ?? "";
136
+ if (isChutesModelDiscoveryTestEnvironment()) return CHUTES_MODEL_CATALOG.map(buildChutesModelDefinition);
137
+ const staticCatalog = () => CHUTES_MODEL_CATALOG.map(buildChutesModelDefinition);
138
+ try {
139
+ const data = await fetchChutesModelRows(trimmedKey || void 0);
140
+ if (data.length === 0) {
141
+ log.warn("No models in response, using static catalog");
142
+ return staticCatalog();
143
+ }
144
+ const seen = /* @__PURE__ */ new Set();
145
+ const models = [];
146
+ for (const entry of data) {
147
+ const id = normalizeOptionalString(entry?.id) ?? "";
148
+ if (!id || seen.has(id)) continue;
149
+ seen.add(id);
150
+ const lowerId = normalizeLowercaseStringOrEmpty(id);
151
+ const isReasoning = entry.supported_features?.includes("reasoning") || lowerId.includes("r1") || lowerId.includes("thinking") || lowerId.includes("reason") || lowerId.includes("tee");
152
+ const input = (entry.input_modalities || ["text"]).filter((i) => i === "text" || i === "image");
153
+ models.push({
154
+ id,
155
+ name: id,
156
+ reasoning: isReasoning,
157
+ input,
158
+ cost: {
159
+ input: entry.pricing?.prompt || 0,
160
+ output: entry.pricing?.completion || 0,
161
+ cacheRead: 0,
162
+ cacheWrite: 0
163
+ },
164
+ contextWindow: asPositiveSafeInteger(entry.context_length) ?? CHUTES_DEFAULT_CONTEXT_WINDOW,
165
+ maxTokens: asPositiveSafeInteger(entry.max_output_length) ?? CHUTES_DEFAULT_MAX_TOKENS,
166
+ compat: { supportsUsageInStreaming: false }
167
+ });
168
+ }
169
+ if (models.length === 0) return staticCatalog();
170
+ return models;
171
+ } catch (error) {
172
+ if (error instanceof LiveModelCatalogHttpError && error.status === 401 && trimmedKey) return await discoverChutesModels(void 0);
173
+ if (error instanceof LiveModelCatalogHttpError && error.status !== 401 && error.status !== 503) {
174
+ log.warn(`GET /v1/models failed: HTTP ${error.status}, using static catalog`);
175
+ return staticCatalog();
176
+ }
177
+ log.warn(`Discovery failed: ${String(error)}, using static catalog`);
178
+ return staticCatalog();
179
+ }
180
+ }
181
+ //#endregion
182
+ export { buildChutesModelDefinition as a, CHUTES_MODEL_CATALOG as i, CHUTES_DEFAULT_MODEL_ID as n, discoverChutesModels as o, CHUTES_DEFAULT_MODEL_REF as r, CHUTES_BASE_URL as t };