Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
208 lines
7.2 KiB
TypeScript
208 lines
7.2 KiB
TypeScript
// Openai tests cover openclaw.plugin plugin behavior.
|
|
import { readFileSync } from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
import { buildOpenAIProvider } from "./openai-provider.js";
|
|
import { buildOpenAISetupProvider } from "./setup-api.js";
|
|
|
|
const manifest = JSON.parse(
|
|
readFileSync(new URL("./openclaw.plugin.json", import.meta.url), "utf8"),
|
|
) as {
|
|
mediaUnderstandingProviderMetadata?: Record<
|
|
string,
|
|
{
|
|
capabilities?: string[];
|
|
defaultModels?: Record<string, string>;
|
|
autoPriority?: Record<string, number>;
|
|
}
|
|
>;
|
|
providerAuthChoices?: Array<{
|
|
provider?: string;
|
|
method?: string;
|
|
choiceLabel?: string;
|
|
choiceHint?: string;
|
|
choiceId?: string;
|
|
deprecatedChoiceIds?: string[];
|
|
assistantVisibility?: string;
|
|
groupId?: string;
|
|
groupLabel?: string;
|
|
groupHint?: string;
|
|
}>;
|
|
setup?: {
|
|
providers?: Array<{ id: string }>;
|
|
};
|
|
modelCatalog?: {
|
|
suppressions?: Array<{
|
|
provider?: string;
|
|
model?: string;
|
|
when?: {
|
|
baseUrlHosts?: string[];
|
|
providerConfigApiIn?: string[];
|
|
};
|
|
}>;
|
|
};
|
|
providerEndpoints?: Array<{
|
|
endpointClass?: string;
|
|
hosts?: string[];
|
|
hostSuffixes?: string[];
|
|
}>;
|
|
providerAuthAliases?: Record<string, string>;
|
|
legacyPluginIds?: string[];
|
|
};
|
|
|
|
const packageJson = JSON.parse(
|
|
readFileSync(new URL("./package.json", import.meta.url), "utf8"),
|
|
) as {
|
|
dependencies?: Record<string, string>;
|
|
devDependencies?: Record<string, string>;
|
|
};
|
|
|
|
function manifestComparableWizardFields(choice: {
|
|
choiceId?: string;
|
|
choiceLabel?: string;
|
|
choiceHint?: string;
|
|
assistantVisibility?: string;
|
|
groupId?: string;
|
|
groupLabel?: string;
|
|
groupHint?: string;
|
|
}) {
|
|
return Object.fromEntries(
|
|
Object.entries({
|
|
choiceId: choice.choiceId,
|
|
choiceLabel: choice.choiceLabel,
|
|
choiceHint: choice.choiceHint,
|
|
assistantVisibility: choice.assistantVisibility,
|
|
groupId: choice.groupId,
|
|
groupLabel: choice.groupLabel,
|
|
groupHint: choice.groupHint,
|
|
}).filter(([, value]) => value !== undefined),
|
|
);
|
|
}
|
|
|
|
function providerWizardByKey() {
|
|
const providers = [buildOpenAIProvider(), buildOpenAISetupProvider()];
|
|
const wizards = new Map<string, Record<string, unknown>>();
|
|
|
|
for (const provider of providers) {
|
|
for (const authMethod of provider.auth ?? []) {
|
|
if (authMethod.wizard) {
|
|
wizards.set(`${provider.id}:${authMethod.id}`, authMethod.wizard);
|
|
}
|
|
}
|
|
}
|
|
|
|
return wizards;
|
|
}
|
|
|
|
function expectWizardFields(
|
|
wizard: Record<string, unknown> | undefined,
|
|
choice: ReturnType<typeof manifestComparableWizardFields>,
|
|
key: string,
|
|
) {
|
|
if (!wizard) {
|
|
throw new Error(`Missing wizard for ${key}`);
|
|
}
|
|
for (const [field, value] of Object.entries(choice)) {
|
|
expect(wizard[field], `${key}.${field}`).toBe(value);
|
|
}
|
|
}
|
|
|
|
describe("OpenAI plugin manifest", () => {
|
|
it("keeps runtime dependencies in the package manifest", () => {
|
|
expect(packageJson.devDependencies?.["@openclaw/plugin-sdk"]).toBe("workspace:*");
|
|
expect(packageJson.dependencies?.ws).toBe("8.21.0");
|
|
});
|
|
|
|
it("exposes only current OpenAI login choices", () => {
|
|
const openAiLogin = manifest.providerAuthChoices?.find(
|
|
(choice) => choice.choiceId === "openai",
|
|
);
|
|
|
|
expect(openAiLogin?.deprecatedChoiceIds).toBeUndefined();
|
|
});
|
|
|
|
it("routes setup through the OpenAI setup runtime", () => {
|
|
expect(manifest.legacyPluginIds).toBeUndefined();
|
|
expect(manifest.setup?.providers?.map((provider) => provider.id)).toEqual(["openai"]);
|
|
expect(manifest.providerAuthAliases).toBeUndefined();
|
|
});
|
|
|
|
it("classifies ChatGPT backend traffic with the supported OpenAI endpoint class", () => {
|
|
const chatGptEndpoint = manifest.providerEndpoints?.find((endpoint) =>
|
|
endpoint.hosts?.includes("chatgpt.com"),
|
|
);
|
|
expect(chatGptEndpoint?.endpointClass).toBe("openai");
|
|
});
|
|
|
|
it("classifies regional API hosts as public OpenAI endpoints", () => {
|
|
const publicEndpoint = manifest.providerEndpoints?.find((endpoint) =>
|
|
endpoint.hosts?.includes("api.openai.com"),
|
|
);
|
|
expect(publicEndpoint?.endpointClass).toBe("openai-public");
|
|
expect(publicEndpoint?.hostSuffixes).toContain(".api.openai.com");
|
|
});
|
|
|
|
it("keeps OpenAI media-understanding manifest metadata aligned with runtime audio support", () => {
|
|
const metadata = manifest.mediaUnderstandingProviderMetadata?.openai;
|
|
expect(metadata?.capabilities).toEqual(["image", "audio"]);
|
|
expect(metadata?.defaultModels?.image).toBe("gpt-5.5");
|
|
expect(metadata?.defaultModels?.audio).toBe("gpt-4o-transcribe");
|
|
expect(metadata?.autoPriority?.image).toBe(20);
|
|
expect(metadata?.autoPriority?.audio).toBe(20);
|
|
});
|
|
|
|
it("labels OpenAI API key and Codex auth choices without stale mixed OAuth wording", () => {
|
|
const choices = manifest.providerAuthChoices ?? [];
|
|
const openAiLogin = choices.find((choice) => choice.choiceId === "openai");
|
|
const openAiDeviceCode = choices.find((choice) => choice.choiceId === "openai-device-code");
|
|
const apiKey = choices.find(
|
|
(choice) => choice.provider === "openai" && choice.method === "api-key",
|
|
);
|
|
|
|
expect(openAiLogin?.choiceLabel).toBe("ChatGPT Login");
|
|
expect(openAiLogin?.choiceHint).toBe("Sign in with your ChatGPT or Codex subscription");
|
|
expect(openAiLogin?.assistantVisibility).toBeUndefined();
|
|
expect(openAiLogin?.groupId).toBe("openai");
|
|
expect(openAiLogin?.groupLabel).toBe("OpenAI");
|
|
expect(openAiLogin?.groupHint).toBe("ChatGPT/Codex sign-in or API key");
|
|
expect(openAiDeviceCode?.choiceLabel).toBe("ChatGPT Device Pairing");
|
|
expect(openAiDeviceCode?.choiceHint).toBe(
|
|
"Pair your ChatGPT account in browser with a device code",
|
|
);
|
|
expect(openAiDeviceCode?.assistantVisibility).toBe("manual-only");
|
|
expect(openAiDeviceCode?.groupId).toBe("openai");
|
|
expect(openAiDeviceCode?.groupLabel).toBe("OpenAI");
|
|
expect(openAiDeviceCode?.groupHint).toBe("ChatGPT/Codex sign-in or API key");
|
|
expect(apiKey?.choiceLabel).toBe("OpenAI API Key");
|
|
expect(apiKey?.choiceHint).toBe("Use your OpenAI API key directly");
|
|
expect(apiKey?.groupId).toBe("openai");
|
|
expect(apiKey?.groupLabel).toBe("OpenAI");
|
|
expect(apiKey?.groupHint).toBe("ChatGPT/Codex sign-in or API key");
|
|
expect(choices.map((choice) => choice.choiceLabel)).not.toContain(
|
|
"OpenAI Codex (ChatGPT OAuth)",
|
|
);
|
|
expect(choices.map((choice) => choice.groupHint)).not.toContain("Codex OAuth + API key");
|
|
expect(choices.map((choice) => choice.groupHint)).not.toContain("API key or Codex sign-in");
|
|
});
|
|
|
|
it("keeps Spark suppression conditional on direct OpenAI API rows", () => {
|
|
const sparkSuppression = manifest.modelCatalog?.suppressions?.find(
|
|
(suppression) =>
|
|
suppression.provider === "openai" && suppression.model === "gpt-5.3-codex-spark",
|
|
);
|
|
|
|
expect(sparkSuppression?.when).toEqual({
|
|
baseUrlHosts: ["api.openai.com"],
|
|
});
|
|
});
|
|
|
|
it("keeps auth choice copy aligned with provider wizard metadata", () => {
|
|
const wizards = providerWizardByKey();
|
|
|
|
for (const choice of manifest.providerAuthChoices ?? []) {
|
|
const key = `${choice.provider}:${choice.method}`;
|
|
|
|
expectWizardFields(wizards.get(key), manifestComparableWizardFields(choice), key);
|
|
}
|
|
});
|
|
});
|