Some checks failed
CI / docs-scope (push) Has been cancelled
CI / secrets (push) Has been cancelled
CI / ios (push) Has been cancelled
Docker Release / validate_manual_backfill (push) Has been cancelled
Install Smoke / docs-scope (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / config-docs-drift (push) Has been cancelled
CI / changed-scope (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / release-check (push) Has been cancelled
CI / checks (pnpm canvas:a2ui:bundle && bunx vitest run --config vitest.unit.config.ts, bun, test) (push) Has been cancelled
CI / checks (pnpm canvas:a2ui:bundle && pnpm test, node, 2, 1, test) (push) Has been cancelled
CI / checks (pnpm canvas:a2ui:bundle && pnpm test, node, 2, 2, test) (push) Has been cancelled
CI / checks (pnpm protocol:check, node, protocol) (push) Has been cancelled
CI / checks (pnpm test:channels, node, channels) (push) Has been cancelled
CI / checks (pnpm test:extensions, node, extensions) (push) Has been cancelled
CI / check (push) Has been cancelled
CI / startup-memory (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / compat-node22 (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 1, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 2, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 3, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 4, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 5, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 6, test) (push) Has been cancelled
CI / macos (push) Has been cancelled
CI / android (./gradlew --no-daemon :app:assembleDebug, build) (push) Has been cancelled
CI / android (./gradlew --no-daemon :app:testDebugUnitTest, test) (push) Has been cancelled
Docker Release / approve_manual_backfill (push) Has been cancelled
Docker Release / build-amd64 (push) Has been cancelled
Docker Release / build-arm64 (push) Has been cancelled
Docker Release / create-manifest (push) Has been cancelled
Install Smoke / install-smoke (push) Has been cancelled
Stale / stale (push) Has been cancelled
Stale / lock-closed-issues (push) Has been cancelled
82 lines
2.5 KiB
TypeScript
82 lines
2.5 KiB
TypeScript
import {
|
|
buildSglangProvider,
|
|
configureOpenAICompatibleSelfHostedProviderNonInteractive,
|
|
discoverOpenAICompatibleSelfHostedProvider,
|
|
emptyPluginConfigSchema,
|
|
promptAndConfigureOpenAICompatibleSelfHostedProviderAuth,
|
|
type OpenClawPluginApi,
|
|
type ProviderAuthMethodNonInteractiveContext,
|
|
} from "openclaw/plugin-sdk/core";
|
|
|
|
const PROVIDER_ID = "sglang";
|
|
const DEFAULT_BASE_URL = "http://127.0.0.1:30000/v1";
|
|
|
|
const sglangPlugin = {
|
|
id: "sglang",
|
|
name: "SGLang Provider",
|
|
description: "Bundled SGLang provider plugin",
|
|
configSchema: emptyPluginConfigSchema(),
|
|
register(api: OpenClawPluginApi) {
|
|
api.registerProvider({
|
|
id: PROVIDER_ID,
|
|
label: "SGLang",
|
|
docsPath: "/providers/sglang",
|
|
envVars: ["SGLANG_API_KEY"],
|
|
auth: [
|
|
{
|
|
id: "custom",
|
|
label: "SGLang",
|
|
hint: "Fast self-hosted OpenAI-compatible server",
|
|
kind: "custom",
|
|
run: async (ctx) =>
|
|
promptAndConfigureOpenAICompatibleSelfHostedProviderAuth({
|
|
cfg: ctx.config,
|
|
prompter: ctx.prompter,
|
|
providerId: PROVIDER_ID,
|
|
providerLabel: "SGLang",
|
|
defaultBaseUrl: DEFAULT_BASE_URL,
|
|
defaultApiKeyEnvVar: "SGLANG_API_KEY",
|
|
modelPlaceholder: "Qwen/Qwen3-8B",
|
|
}),
|
|
runNonInteractive: async (ctx: ProviderAuthMethodNonInteractiveContext) =>
|
|
configureOpenAICompatibleSelfHostedProviderNonInteractive({
|
|
ctx,
|
|
providerId: PROVIDER_ID,
|
|
providerLabel: "SGLang",
|
|
defaultBaseUrl: DEFAULT_BASE_URL,
|
|
defaultApiKeyEnvVar: "SGLANG_API_KEY",
|
|
modelPlaceholder: "Qwen/Qwen3-8B",
|
|
}),
|
|
},
|
|
],
|
|
discovery: {
|
|
order: "late",
|
|
run: async (ctx) =>
|
|
discoverOpenAICompatibleSelfHostedProvider({
|
|
ctx,
|
|
providerId: PROVIDER_ID,
|
|
buildProvider: buildSglangProvider,
|
|
}),
|
|
},
|
|
wizard: {
|
|
setup: {
|
|
choiceId: "sglang",
|
|
choiceLabel: "SGLang",
|
|
choiceHint: "Fast self-hosted OpenAI-compatible server",
|
|
groupId: "sglang",
|
|
groupLabel: "SGLang",
|
|
groupHint: "Fast self-hosted server",
|
|
methodId: "custom",
|
|
},
|
|
modelPicker: {
|
|
label: "SGLang (custom)",
|
|
hint: "Enter SGLang URL + API key + model",
|
|
methodId: "custom",
|
|
},
|
|
},
|
|
});
|
|
},
|
|
};
|
|
|
|
export default sglangPlugin;
|