@openclaw/chutes-provider 0.0.0 → 2026.6.9

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 CHANGED
@@ -1,3 +1,12 @@
1
- # @openclaw/chutes-provider
1
+ # OpenClaw Chutes Provider
2
2
 
3
- Reserved placeholder for the official OpenClaw plugin package. Use a published release version instead.
3
+ Official OpenClaw provider plugin for Chutes.
4
+
5
+ Install from OpenClaw:
6
+
7
+ ```bash
8
+ openclaw plugins install @openclaw/chutes-provider
9
+ openclaw gateway restart
10
+ ```
11
+
12
+ See <https://docs.openclaw.ai/providers/chutes> for setup and configuration.
package/dist/api.js ADDED
@@ -0,0 +1,4 @@
1
+ import { CHUTES_BASE_URL, CHUTES_DEFAULT_MODEL_ID, CHUTES_DEFAULT_MODEL_REF, CHUTES_MODEL_CATALOG, buildChutesModelDefinition, discoverChutesModels } from "./models.js";
2
+ import { applyChutesApiKeyConfig, applyChutesConfig, applyChutesProviderConfig } from "./onboard.js";
3
+ import { buildChutesProvider } from "./provider-catalog.js";
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 ADDED
@@ -0,0 +1,149 @@
1
+ import { loginChutes } from "./oauth.js";
2
+ import { CHUTES_DEFAULT_MODEL_REF } from "./models.js";
3
+ import { applyChutesApiKeyConfig, applyChutesProviderConfig } from "./onboard.js";
4
+ import { buildChutesProvider, buildStaticChutesProvider } from "./provider-catalog.js";
5
+ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
6
+ import { buildOauthProviderAuthResult, resolveOAuthApiKeyMarker } from "openclaw/plugin-sdk/provider-auth";
7
+ import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
8
+ import { normalizeOptionalString, readStringValue } from "openclaw/plugin-sdk/string-coerce-runtime";
9
+ //#region extensions/chutes/index.ts
10
+ /**
11
+ * Chutes provider plugin entrypoint with OAuth and API-key auth methods.
12
+ */
13
+ const PROVIDER_ID = "chutes";
14
+ async function runChutesOAuth(ctx) {
15
+ const isRemote = ctx.isRemote;
16
+ const redirectUri = process.env.CHUTES_OAUTH_REDIRECT_URI?.trim() || "http://127.0.0.1:1456/oauth-callback";
17
+ const scopes = process.env.CHUTES_OAUTH_SCOPES?.trim() || "openid profile chutes:invoke";
18
+ const clientId = process.env.CHUTES_CLIENT_ID?.trim() || (await ctx.prompter.text({
19
+ message: "Enter Chutes OAuth client id",
20
+ placeholder: "cid_xxx",
21
+ validate: (value) => value?.trim() ? void 0 : "Required"
22
+ })).trim();
23
+ const clientSecret = normalizeOptionalString(process.env.CHUTES_CLIENT_SECRET);
24
+ await ctx.prompter.note(isRemote ? [
25
+ "You are running in a remote/VPS environment.",
26
+ "A URL will be shown for you to open in your LOCAL browser.",
27
+ "After signing in, paste the redirect URL back here.",
28
+ "",
29
+ `Redirect URI: ${redirectUri}`
30
+ ].join("\n") : [
31
+ "Browser will open for Chutes authentication.",
32
+ "If the callback doesn't auto-complete, paste the redirect URL.",
33
+ "",
34
+ `Redirect URI: ${redirectUri}`
35
+ ].join("\n"), "Chutes OAuth");
36
+ const progress = ctx.prompter.progress("Starting Chutes OAuth…");
37
+ try {
38
+ const { onAuth, onPrompt } = ctx.oauth.createVpsAwareHandlers({
39
+ isRemote,
40
+ prompter: ctx.prompter,
41
+ runtime: ctx.runtime,
42
+ spin: progress,
43
+ openUrl: ctx.openUrl,
44
+ localBrowserMessage: "Complete sign-in in browser…"
45
+ });
46
+ const creds = await loginChutes({
47
+ app: {
48
+ clientId,
49
+ clientSecret,
50
+ redirectUri,
51
+ scopes: scopes.split(/\s+/).filter(Boolean)
52
+ },
53
+ manual: isRemote,
54
+ onAuth,
55
+ onPrompt,
56
+ onProgress: (message) => progress.update(message)
57
+ });
58
+ progress.stop("Chutes OAuth complete");
59
+ return buildOauthProviderAuthResult({
60
+ providerId: PROVIDER_ID,
61
+ defaultModel: CHUTES_DEFAULT_MODEL_REF,
62
+ access: creds.access,
63
+ refresh: creds.refresh,
64
+ expires: creds.expires,
65
+ email: readStringValue(creds.email),
66
+ credentialExtra: {
67
+ clientId,
68
+ ..."accountId" in creds && typeof creds.accountId === "string" ? { accountId: creds.accountId } : {}
69
+ },
70
+ configPatch: applyChutesProviderConfig({}),
71
+ notes: ["Chutes OAuth tokens auto-refresh. Re-run login if refresh fails or access is revoked.", `Redirect URI: ${redirectUri}`]
72
+ });
73
+ } catch (err) {
74
+ progress.stop("Chutes OAuth failed");
75
+ await ctx.prompter.note([
76
+ "Trouble with OAuth?",
77
+ "Verify CHUTES_CLIENT_ID (and CHUTES_CLIENT_SECRET if required).",
78
+ `Verify the OAuth app redirect URI includes: ${redirectUri}`,
79
+ "Chutes docs: https://chutes.ai/docs/sign-in-with-chutes/overview"
80
+ ].join("\n"), "OAuth help");
81
+ throw err;
82
+ }
83
+ }
84
+ var chutes_default = definePluginEntry({
85
+ id: PROVIDER_ID,
86
+ name: "Chutes Provider",
87
+ description: "Bundled Chutes.ai provider plugin",
88
+ register(api) {
89
+ api.registerProvider({
90
+ id: PROVIDER_ID,
91
+ label: "Chutes",
92
+ docsPath: "/providers/chutes",
93
+ envVars: ["CHUTES_API_KEY", "CHUTES_OAUTH_TOKEN"],
94
+ auth: [{
95
+ id: "oauth",
96
+ label: "Chutes OAuth",
97
+ hint: "Browser sign-in",
98
+ kind: "oauth",
99
+ wizard: {
100
+ choiceId: "chutes",
101
+ choiceLabel: "Chutes (OAuth)",
102
+ choiceHint: "Browser sign-in",
103
+ groupId: "chutes",
104
+ groupLabel: "Chutes",
105
+ groupHint: "OAuth + API key"
106
+ },
107
+ run: async (ctx) => await runChutesOAuth(ctx)
108
+ }, createProviderApiKeyAuthMethod({
109
+ providerId: PROVIDER_ID,
110
+ methodId: "api-key",
111
+ label: "Chutes API key",
112
+ hint: "Open-source models including Llama, DeepSeek, and more",
113
+ optionKey: "chutesApiKey",
114
+ flagName: "--chutes-api-key",
115
+ envVar: "CHUTES_API_KEY",
116
+ promptMessage: "Enter Chutes API key",
117
+ noteTitle: "Chutes",
118
+ noteMessage: ["Chutes provides access to leading open-source models including Llama, DeepSeek, and more.", "Get your API key at: https://chutes.ai/settings/api-keys"].join("\n"),
119
+ defaultModel: CHUTES_DEFAULT_MODEL_REF,
120
+ expectedProviders: ["chutes"],
121
+ applyConfig: (cfg) => applyChutesApiKeyConfig(cfg),
122
+ wizard: {
123
+ choiceId: "chutes-api-key",
124
+ choiceLabel: "Chutes API key",
125
+ groupId: "chutes",
126
+ groupLabel: "Chutes",
127
+ groupHint: "OAuth + API key"
128
+ }
129
+ })],
130
+ catalog: {
131
+ order: "profile",
132
+ run: async (ctx) => {
133
+ const { apiKey, discoveryApiKey } = ctx.resolveProviderAuth(PROVIDER_ID, { oauthMarker: resolveOAuthApiKeyMarker(PROVIDER_ID) });
134
+ if (!apiKey) return null;
135
+ return { provider: {
136
+ ...await buildChutesProvider(discoveryApiKey),
137
+ apiKey
138
+ } };
139
+ }
140
+ },
141
+ staticCatalog: {
142
+ order: "profile",
143
+ run: async () => ({ provider: buildStaticChutesProvider() })
144
+ }
145
+ });
146
+ }
147
+ });
148
+ //#endregion
149
+ export { chutes_default as default };
@@ -0,0 +1,10 @@
1
+ //#region extensions/chutes/model-discovery-env.ts
2
+ /**
3
+ * Environment helper for Chutes model discovery behavior in tests.
4
+ */
5
+ /** Returns whether dynamic Chutes model discovery should use test behavior. */
6
+ function isChutesModelDiscoveryTestEnvironment(env = process.env) {
7
+ return env.NODE_ENV === "test" || env.VITEST === "true";
8
+ }
9
+ //#endregion
10
+ export { isChutesModelDiscoveryTestEnvironment };