@openclaw/stepfun-provider 2026.9.5 → 2026.9.7

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/assets/icon.png CHANGED
Binary file
package/dist/index.js CHANGED
@@ -3,11 +3,42 @@ import { applyStepFunPlanConfig, applyStepFunPlanConfigCn, applyStepFunStandardC
3
3
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
4
4
  import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
5
5
  import { buildOpenAICompatibleLiveProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
6
- import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
6
+ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
7
  //#region extensions/stepfun/index.ts
8
+ const STEPFUN_SURFACES = {
9
+ standard: {
10
+ providerId: STEPFUN_PROVIDER_ID,
11
+ label: "StepFun",
12
+ authLabel: "StepFun Standard",
13
+ defaultModel: STEPFUN_DEFAULT_MODEL_REF,
14
+ baseUrls: {
15
+ cn: STEPFUN_STANDARD_CN_BASE_URL,
16
+ intl: STEPFUN_STANDARD_INTL_BASE_URL
17
+ },
18
+ buildProvider: buildStepFunProvider,
19
+ applyConfig: {
20
+ cn: applyStepFunStandardConfigCn,
21
+ intl: applyStepFunStandardConfig
22
+ }
23
+ },
24
+ plan: {
25
+ providerId: STEPFUN_PLAN_PROVIDER_ID,
26
+ label: "StepFun Step Plan",
27
+ authLabel: "StepFun Step Plan",
28
+ defaultModel: STEPFUN_PLAN_DEFAULT_MODEL_REF,
29
+ baseUrls: {
30
+ cn: STEPFUN_PLAN_CN_BASE_URL,
31
+ intl: STEPFUN_PLAN_INTL_BASE_URL
32
+ },
33
+ buildProvider: buildStepFunPlanProvider,
34
+ applyConfig: {
35
+ cn: applyStepFunPlanConfigCn,
36
+ intl: applyStepFunPlanConfig
37
+ }
38
+ }
39
+ };
8
40
  function trimExplicitBaseUrl(ctx, providerId) {
9
- const explicitProvider = ctx.config.models?.providers?.[providerId];
10
- return (typeof explicitProvider?.baseUrl === "string" ? explicitProvider.baseUrl.trim() : "") || void 0;
41
+ return normalizeOptionalString(ctx.config.models?.providers?.[providerId]?.baseUrl);
11
42
  }
12
43
  function inferRegionFromBaseUrl(baseUrl) {
13
44
  if (!baseUrl) return;
@@ -24,25 +55,16 @@ function inferRegionFromProfileId(profileId) {
24
55
  if (profileId.includes(":cn")) return "cn";
25
56
  if (profileId.includes(":intl")) return "intl";
26
57
  }
27
- function inferRegionFromEnv(env) {
28
- if (env.STEPFUN_API_KEY?.trim()) return "intl";
29
- }
30
- function inferRegionFromExplicitBaseUrls(ctx) {
31
- return inferRegionFromBaseUrl(trimExplicitBaseUrl(ctx, "stepfun")) ?? inferRegionFromBaseUrl(trimExplicitBaseUrl(ctx, "stepfun-plan"));
32
- }
33
- function resolveDefaultBaseUrl(surface, region) {
34
- if (surface === "plan") return region === "cn" ? STEPFUN_PLAN_CN_BASE_URL : STEPFUN_PLAN_INTL_BASE_URL;
35
- return region === "cn" ? STEPFUN_STANDARD_CN_BASE_URL : STEPFUN_STANDARD_INTL_BASE_URL;
36
- }
37
58
  async function resolveStepFunCatalog(ctx, params) {
38
59
  const profileAuth = ctx.resolveProviderAuth(params.providerId);
39
60
  const auth = profileAuth.apiKey ? profileAuth : ctx.resolveProviderApiKey(params.providerId);
40
61
  const apiKey = auth.apiKey;
41
62
  if (!apiKey) return null;
42
63
  const explicitBaseUrl = trimExplicitBaseUrl(ctx, params.providerId);
43
- const region = inferRegionFromBaseUrl(explicitBaseUrl) ?? inferRegionFromExplicitBaseUrls(ctx) ?? inferRegionFromProfileId(auth.profileId) ?? inferRegionFromEnv(ctx.env);
44
- const baseUrl = explicitBaseUrl ?? resolveDefaultBaseUrl(params.surface, region ?? "intl");
45
- const providerConfig = params.surface === "plan" ? buildStepFunPlanProvider(baseUrl) : buildStepFunProvider(baseUrl);
64
+ const region = inferRegionFromBaseUrl(explicitBaseUrl) ?? inferRegionFromBaseUrl(trimExplicitBaseUrl(ctx, "stepfun")) ?? inferRegionFromBaseUrl(trimExplicitBaseUrl(ctx, "stepfun-plan")) ?? inferRegionFromProfileId(auth.profileId);
65
+ const provider = STEPFUN_SURFACES[params.surface];
66
+ const baseUrl = explicitBaseUrl ?? provider.baseUrls[region ?? "intl"];
67
+ const providerConfig = provider.buildProvider(baseUrl);
46
68
  return await buildOpenAICompatibleLiveProviderCatalog({
47
69
  discoveryMode: "strict",
48
70
  providerId: params.providerId,
@@ -52,29 +74,30 @@ async function resolveStepFunCatalog(ctx, params) {
52
74
  profileId: auth.profileId
53
75
  });
54
76
  }
55
- function resolveProfileIds(region) {
56
- return region === "cn" ? ["stepfun:cn", "stepfun-plan:cn"] : ["stepfun:intl", "stepfun-plan:intl"];
57
- }
58
- function createStepFunApiKeyMethod(params) {
77
+ function createStepFunApiKeyMethod(surface, region) {
78
+ const provider = STEPFUN_SURFACES[surface];
79
+ const methodId = `${surface}-api-key-${region}`;
80
+ const label = `${provider.authLabel} API key (${region === "cn" ? "China" : "Global/Intl"})`;
81
+ const hint = `Endpoint: ${provider.baseUrls[region].replace(/^https:\/\//u, "")}`;
59
82
  return createProviderApiKeyAuthMethod({
60
- providerId: params.providerId,
61
- methodId: params.methodId,
62
- label: params.label,
63
- hint: params.hint,
83
+ providerId: provider.providerId,
84
+ methodId,
85
+ label,
86
+ hint,
64
87
  optionKey: "stepfunApiKey",
65
88
  flagName: "--stepfun-api-key",
66
89
  envVar: "STEPFUN_API_KEY",
67
- promptMessage: params.promptMessage,
68
- profileIds: resolveProfileIds(params.region),
90
+ promptMessage: `Enter StepFun API key for ${region === "cn" ? "China" : "global"} endpoints`,
91
+ profileIds: [`stepfun:${region}`, `stepfun-plan:${region}`],
69
92
  allowProfile: false,
70
- defaultModel: params.defaultModel,
93
+ defaultModel: provider.defaultModel,
71
94
  preserveExistingPrimary: true,
72
95
  expectedProviders: [STEPFUN_PROVIDER_ID, STEPFUN_PLAN_PROVIDER_ID],
73
- applyConfig: params.applyConfig,
96
+ applyConfig: provider.applyConfig[region],
74
97
  wizard: {
75
- choiceId: params.choiceId,
76
- choiceLabel: params.choiceLabel,
77
- choiceHint: params.choiceHint,
98
+ choiceId: `stepfun-${methodId}`,
99
+ choiceLabel: label,
100
+ choiceHint: hint,
78
101
  groupId: "stepfun",
79
102
  groupLabel: "StepFun",
80
103
  groupHint: "Standard / Step Plan (China / Global)"
@@ -86,90 +109,27 @@ var stepfun_default = definePluginEntry({
86
109
  name: "StepFun",
87
110
  description: "Bundled StepFun standard and Step Plan provider plugin",
88
111
  register(api) {
89
- api.registerProvider({
90
- id: STEPFUN_PROVIDER_ID,
91
- label: "StepFun",
92
- docsPath: "/providers/stepfun",
93
- envVars: ["STEPFUN_API_KEY"],
94
- auth: [createStepFunApiKeyMethod({
95
- providerId: STEPFUN_PROVIDER_ID,
96
- methodId: "standard-api-key-cn",
97
- label: "StepFun Standard API key (China)",
98
- hint: "Endpoint: api.stepfun.com/v1",
99
- region: "cn",
100
- promptMessage: "Enter StepFun API key for China endpoints",
101
- defaultModel: STEPFUN_DEFAULT_MODEL_REF,
102
- choiceId: "stepfun-standard-api-key-cn",
103
- choiceLabel: "StepFun Standard API key (China)",
104
- choiceHint: "Endpoint: api.stepfun.com/v1",
105
- applyConfig: applyStepFunStandardConfigCn
106
- }), createStepFunApiKeyMethod({
107
- providerId: STEPFUN_PROVIDER_ID,
108
- methodId: "standard-api-key-intl",
109
- label: "StepFun Standard API key (Global/Intl)",
110
- hint: "Endpoint: api.stepfun.ai/v1",
111
- region: "intl",
112
- promptMessage: "Enter StepFun API key for global endpoints",
113
- defaultModel: STEPFUN_DEFAULT_MODEL_REF,
114
- choiceId: "stepfun-standard-api-key-intl",
115
- choiceLabel: "StepFun Standard API key (Global/Intl)",
116
- choiceHint: "Endpoint: api.stepfun.ai/v1",
117
- applyConfig: applyStepFunStandardConfig
118
- })],
119
- catalog: {
120
- order: "paired",
121
- run: async (ctx) => resolveStepFunCatalog(ctx, {
122
- providerId: STEPFUN_PROVIDER_ID,
123
- surface: "standard"
124
- })
125
- },
126
- staticCatalog: {
127
- order: "paired",
128
- run: async () => ({ provider: buildStepFunProvider() })
129
- }
130
- });
131
- api.registerProvider({
132
- id: STEPFUN_PLAN_PROVIDER_ID,
133
- label: "StepFun Step Plan",
134
- docsPath: "/providers/stepfun",
135
- envVars: ["STEPFUN_API_KEY"],
136
- auth: [createStepFunApiKeyMethod({
137
- providerId: STEPFUN_PLAN_PROVIDER_ID,
138
- methodId: "plan-api-key-cn",
139
- label: "StepFun Step Plan API key (China)",
140
- hint: "Endpoint: api.stepfun.com/step_plan/v1",
141
- region: "cn",
142
- promptMessage: "Enter StepFun API key for China endpoints",
143
- defaultModel: STEPFUN_PLAN_DEFAULT_MODEL_REF,
144
- choiceId: "stepfun-plan-api-key-cn",
145
- choiceLabel: "StepFun Step Plan API key (China)",
146
- choiceHint: "Endpoint: api.stepfun.com/step_plan/v1",
147
- applyConfig: applyStepFunPlanConfigCn
148
- }), createStepFunApiKeyMethod({
149
- providerId: STEPFUN_PLAN_PROVIDER_ID,
150
- methodId: "plan-api-key-intl",
151
- label: "StepFun Step Plan API key (Global/Intl)",
152
- hint: "Endpoint: api.stepfun.ai/step_plan/v1",
153
- region: "intl",
154
- promptMessage: "Enter StepFun API key for global endpoints",
155
- defaultModel: STEPFUN_PLAN_DEFAULT_MODEL_REF,
156
- choiceId: "stepfun-plan-api-key-intl",
157
- choiceLabel: "StepFun Step Plan API key (Global/Intl)",
158
- choiceHint: "Endpoint: api.stepfun.ai/step_plan/v1",
159
- applyConfig: applyStepFunPlanConfig
160
- })],
161
- catalog: {
162
- order: "paired",
163
- run: async (ctx) => resolveStepFunCatalog(ctx, {
164
- providerId: STEPFUN_PLAN_PROVIDER_ID,
165
- surface: "plan"
166
- })
167
- },
168
- staticCatalog: {
169
- order: "paired",
170
- run: async () => ({ provider: buildStepFunPlanProvider() })
171
- }
172
- });
112
+ for (const surface of ["standard", "plan"]) {
113
+ const provider = STEPFUN_SURFACES[surface];
114
+ api.registerProvider({
115
+ id: provider.providerId,
116
+ label: provider.label,
117
+ docsPath: "/providers/stepfun",
118
+ envVars: ["STEPFUN_API_KEY"],
119
+ auth: ["cn", "intl"].map((region) => createStepFunApiKeyMethod(surface, region)),
120
+ catalog: {
121
+ order: "paired",
122
+ run: async (ctx) => resolveStepFunCatalog(ctx, {
123
+ providerId: provider.providerId,
124
+ surface
125
+ })
126
+ },
127
+ staticCatalog: {
128
+ order: "paired",
129
+ run: async () => ({ provider: provider.buildProvider() })
130
+ }
131
+ });
132
+ }
173
133
  }
174
134
  });
175
135
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/stepfun-provider",
3
- "version": "2026.9.5",
3
+ "version": "2026.9.7",
4
4
  "description": "OpenClaw StepFun provider plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.6.9"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.9.5"
21
+ "pluginApi": ">=2026.9.7"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.5",
24
+ "openclawVersion": "2026.9.7",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -40,7 +40,7 @@
40
40
  "assets/activity.svg"
41
41
  ],
42
42
  "peerDependencies": {
43
- "openclaw": ">=2026.9.5"
43
+ "openclaw": ">=2026.9.7"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {