Skip to content

Commit 7975432

Browse files
authored
fix(onboard): enable Runway and Alibaba video provider authentication (#126722)
* fix(onboard): enable Runway and Alibaba video provider authentication * perf(ui): load image lightbox only when opening images * perf(ui): defer onboarding memory import outside setup
1 parent e20a329 commit 7975432

5 files changed

Lines changed: 151 additions & 1 deletion

File tree

‎extensions/alibaba/index.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,39 @@
33
* generation provider.
44
*/
55
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
6+
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
67
import { alibabaVideoGenerationProvider } from "./video-generation-provider.js";
78

89
export default definePluginEntry({
910
id: "alibaba",
1011
name: "Alibaba Model Studio Plugin",
1112
description: "Bundled Alibaba Model Studio video provider plugin",
1213
register(api) {
14+
api.registerProvider({
15+
id: "alibaba",
16+
label: "Alibaba Model Studio",
17+
docsPath: "/providers/alibaba",
18+
envVars: ["MODELSTUDIO_API_KEY", "DASHSCOPE_API_KEY", "QWEN_API_KEY"],
19+
auth: [
20+
createProviderApiKeyAuthMethod({
21+
providerId: "alibaba",
22+
methodId: "api-key",
23+
label: "Alibaba Model Studio API key",
24+
optionKey: "alibabaModelStudioApiKey",
25+
flagName: "--alibaba-model-studio-api-key",
26+
envVar: "MODELSTUDIO_API_KEY",
27+
promptMessage: "Enter Alibaba Model Studio API key",
28+
wizard: {
29+
choiceId: "alibaba-model-studio-api-key",
30+
choiceLabel: "Alibaba Model Studio API key",
31+
groupId: "alibaba",
32+
groupLabel: "Alibaba Model Studio",
33+
groupHint: "DashScope / Model Studio API key",
34+
onboardingScopes: ["image-generation"],
35+
},
36+
}),
37+
],
38+
});
1339
api.registerVideoGenerationProvider(alibabaVideoGenerationProvider);
1440
},
1541
});

‎extensions/alibaba/video-generation-provider.test.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import {
55
clearRuntimeAuthProfileStoreSnapshots,
66
saveAuthProfileStore,
77
} from "openclaw/plugin-sdk/agent-runtime";
8+
import {
9+
capturePluginRegistration,
10+
createRuntimeEnv,
11+
resolveProviderPluginChoice,
12+
} from "openclaw/plugin-sdk/plugin-test-runtime";
813
import {
914
getProviderHttpMocks,
1015
installProviderHttpMockCleanup,
@@ -55,6 +60,49 @@ function clearAlibabaAuthEnvironment(): void {
5560
const requireRecord = createRequireRecord("record", "expected-label-record");
5661

5762
describe("alibaba video generation provider", () => {
63+
it("registers media-only API-key onboarding alongside video generation", async () => {
64+
const { default: plugin } = await import("./index.js");
65+
const captured = capturePluginRegistration(plugin);
66+
67+
expect(captured.videoGenerationProviders.map((provider) => provider.id)).toEqual(["alibaba"]);
68+
expect(captured.modelCatalogProviders).toEqual([]);
69+
expect(captured.providers).toHaveLength(1);
70+
expect(captured.providers[0]).toMatchObject({
71+
id: "alibaba",
72+
docsPath: "/providers/alibaba",
73+
envVars: ["MODELSTUDIO_API_KEY", "DASHSCOPE_API_KEY", "QWEN_API_KEY"],
74+
});
75+
76+
const choice = resolveProviderPluginChoice({
77+
providers: captured.providers,
78+
choice: "alibaba-model-studio-api-key",
79+
});
80+
expect(choice?.method.id).toBe("api-key");
81+
expect(choice?.method.starterModel).toBeUndefined();
82+
expect(choice?.wizard?.onboardingScopes).toEqual(["image-generation"]);
83+
if (!choice?.method.validateNonInteractive) {
84+
throw new Error("expected Alibaba non-interactive API-key validation");
85+
}
86+
87+
const resolveApiKey = vi.fn(async () => ({ key: "alibaba-test-key", source: "flag" as const }));
88+
expect(
89+
await choice.method.validateNonInteractive({
90+
authChoice: "alibaba-model-studio-api-key",
91+
config: {},
92+
baseConfig: {},
93+
opts: { alibabaModelStudioApiKey: "alibaba-test-key" },
94+
runtime: createRuntimeEnv(),
95+
resolveApiKey,
96+
}),
97+
).toBe(true);
98+
expect(resolveApiKey).toHaveBeenCalledWith({
99+
provider: "alibaba",
100+
flagValue: "alibaba-test-key",
101+
flagName: "--alibaba-model-studio-api-key",
102+
envVar: "MODELSTUDIO_API_KEY",
103+
});
104+
});
105+
58106
it("declares explicit mode capabilities", () => {
59107
expectExplicitVideoGenerationCapabilities(alibabaVideoGenerationProvider);
60108
expect(alibabaVideoGenerationProvider).toMatchObject({

‎extensions/runway/index.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
// Runway plugin entrypoint registers its OpenClaw integration.
22
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3+
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
34
import { buildRunwayVideoGenerationProvider } from "./video-generation-provider.js";
45

56
export default definePluginEntry({
67
id: "runway",
78
name: "Runway Provider",
89
description: "Bundled Runway video provider plugin",
910
register(api) {
11+
api.registerProvider({
12+
id: "runway",
13+
label: "Runway",
14+
docsPath: "/providers/runway",
15+
envVars: ["RUNWAYML_API_SECRET", "RUNWAY_API_KEY"],
16+
auth: [
17+
createProviderApiKeyAuthMethod({
18+
providerId: "runway",
19+
methodId: "api-key",
20+
label: "Runway API key",
21+
optionKey: "runwayApiKey",
22+
flagName: "--runway-api-key",
23+
envVar: "RUNWAYML_API_SECRET",
24+
promptMessage: "Enter Runway API key",
25+
wizard: {
26+
choiceId: "runway-api-key",
27+
choiceLabel: "Runway API key",
28+
groupId: "runway",
29+
groupLabel: "Runway",
30+
groupHint: "API key",
31+
onboardingScopes: ["image-generation"],
32+
},
33+
}),
34+
],
35+
});
1036
api.registerVideoGenerationProvider(buildRunwayVideoGenerationProvider());
1137
},
1238
});

‎extensions/runway/video-generation-provider.test.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// Runway tests cover video generation provider plugin behavior.
2+
import {
3+
capturePluginRegistration,
4+
createRuntimeEnv,
5+
resolveProviderPluginChoice,
6+
} from "openclaw/plugin-sdk/plugin-test-runtime";
27
import {
38
getProviderHttpMocks,
49
installProviderHttpMockCleanup,
@@ -82,6 +87,49 @@ function streamedRawResponse(text: string): Response {
8287
}
8388

8489
describe("runway video generation provider", () => {
90+
it("registers media-only API-key onboarding alongside video generation", async () => {
91+
const { default: plugin } = await import("./index.js");
92+
const captured = capturePluginRegistration(plugin);
93+
94+
expect(captured.videoGenerationProviders.map((provider) => provider.id)).toEqual(["runway"]);
95+
expect(captured.modelCatalogProviders).toEqual([]);
96+
expect(captured.providers).toHaveLength(1);
97+
expect(captured.providers[0]).toMatchObject({
98+
id: "runway",
99+
docsPath: "/providers/runway",
100+
envVars: ["RUNWAYML_API_SECRET", "RUNWAY_API_KEY"],
101+
});
102+
103+
const choice = resolveProviderPluginChoice({
104+
providers: captured.providers,
105+
choice: "runway-api-key",
106+
});
107+
expect(choice?.method.id).toBe("api-key");
108+
expect(choice?.method.starterModel).toBeUndefined();
109+
expect(choice?.wizard?.onboardingScopes).toEqual(["image-generation"]);
110+
if (!choice?.method.validateNonInteractive) {
111+
throw new Error("expected Runway non-interactive API-key validation");
112+
}
113+
114+
const resolveApiKey = vi.fn(async () => ({ key: "runway-test-key", source: "flag" as const }));
115+
expect(
116+
await choice.method.validateNonInteractive({
117+
authChoice: "runway-api-key",
118+
config: {},
119+
baseConfig: {},
120+
opts: { runwayApiKey: "runway-test-key" },
121+
runtime: createRuntimeEnv(),
122+
resolveApiKey,
123+
}),
124+
).toBe(true);
125+
expect(resolveApiKey).toHaveBeenCalledWith({
126+
provider: "runway",
127+
flagValue: "runway-test-key",
128+
flagName: "--runway-api-key",
129+
envVar: "RUNWAYML_API_SECRET",
130+
});
131+
});
132+
85133
it("declares explicit mode capabilities", () => {
86134
expectExplicitVideoGenerationCapabilities(buildRunwayVideoGenerationProvider());
87135
});

‎ui/src/app/app-host.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import "../components/app-topbar.ts";
44
import "../components/macos-titlebar-controls.ts";
55
import "../components/modal-dialog.ts";
66
import { formatDocumentTitle, titleForRoute } from "../app-navigation.ts";
7-
import "../components/onboarding-memory-import.ts";
87
import "../components/resizable-divider.ts";
98
import "../components/sidebar-update-card.ts";
109
import "../components/update-banner.ts";
@@ -722,6 +721,9 @@ class OpenClawShell
722721
}
723722

724723
override render() {
724+
if (this.onboardingMode && this.routeState.routeId !== "custodian") {
725+
void import("../components/onboarding-memory-import.ts");
726+
}
725727
return renderApplicationShell(this);
726728
}
727729
}

0 commit comments

Comments
 (0)