mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-26 16:06:16 +00:00
Plugin SDK: split setup and sandbox subpaths
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import {
|
||||
buildSglangProvider,
|
||||
configureOpenAICompatibleSelfHostedProviderNonInteractive,
|
||||
discoverOpenAICompatibleSelfHostedProvider,
|
||||
emptyPluginConfigSchema,
|
||||
promptAndConfigureOpenAICompatibleSelfHostedProviderAuth,
|
||||
type OpenClawPluginApi,
|
||||
type ProviderAuthMethodNonInteractiveContext,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
import {
|
||||
SGLANG_DEFAULT_API_KEY_ENV_VAR,
|
||||
SGLANG_DEFAULT_BASE_URL,
|
||||
SGLANG_MODEL_PLACEHOLDER,
|
||||
SGLANG_PROVIDER_LABEL,
|
||||
} from "../../src/agents/sglang-defaults.js";
|
||||
|
||||
const PROVIDER_ID = "sglang";
|
||||
const DEFAULT_BASE_URL = "http://127.0.0.1:30000/v1";
|
||||
|
||||
async function loadProviderSetup() {
|
||||
return await import("openclaw/plugin-sdk/provider-setup");
|
||||
}
|
||||
|
||||
const sglangPlugin = {
|
||||
id: "sglang",
|
||||
@@ -25,38 +30,44 @@ const sglangPlugin = {
|
||||
auth: [
|
||||
{
|
||||
id: "custom",
|
||||
label: "SGLang",
|
||||
label: SGLANG_PROVIDER_LABEL,
|
||||
hint: "Fast self-hosted OpenAI-compatible server",
|
||||
kind: "custom",
|
||||
run: async (ctx) =>
|
||||
promptAndConfigureOpenAICompatibleSelfHostedProviderAuth({
|
||||
run: async (ctx) => {
|
||||
const providerSetup = await loadProviderSetup();
|
||||
return await providerSetup.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({
|
||||
providerLabel: SGLANG_PROVIDER_LABEL,
|
||||
defaultBaseUrl: SGLANG_DEFAULT_BASE_URL,
|
||||
defaultApiKeyEnvVar: SGLANG_DEFAULT_API_KEY_ENV_VAR,
|
||||
modelPlaceholder: SGLANG_MODEL_PLACEHOLDER,
|
||||
});
|
||||
},
|
||||
runNonInteractive: async (ctx: ProviderAuthMethodNonInteractiveContext) => {
|
||||
const providerSetup = await loadProviderSetup();
|
||||
return await providerSetup.configureOpenAICompatibleSelfHostedProviderNonInteractive({
|
||||
ctx,
|
||||
providerId: PROVIDER_ID,
|
||||
providerLabel: "SGLang",
|
||||
defaultBaseUrl: DEFAULT_BASE_URL,
|
||||
defaultApiKeyEnvVar: "SGLANG_API_KEY",
|
||||
modelPlaceholder: "Qwen/Qwen3-8B",
|
||||
}),
|
||||
providerLabel: SGLANG_PROVIDER_LABEL,
|
||||
defaultBaseUrl: SGLANG_DEFAULT_BASE_URL,
|
||||
defaultApiKeyEnvVar: SGLANG_DEFAULT_API_KEY_ENV_VAR,
|
||||
modelPlaceholder: SGLANG_MODEL_PLACEHOLDER,
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
discovery: {
|
||||
order: "late",
|
||||
run: async (ctx) =>
|
||||
discoverOpenAICompatibleSelfHostedProvider({
|
||||
run: async (ctx) => {
|
||||
const providerSetup = await loadProviderSetup();
|
||||
return await providerSetup.discoverOpenAICompatibleSelfHostedProvider({
|
||||
ctx,
|
||||
providerId: PROVIDER_ID,
|
||||
buildProvider: buildSglangProvider,
|
||||
}),
|
||||
buildProvider: providerSetup.buildSglangProvider,
|
||||
});
|
||||
},
|
||||
},
|
||||
wizard: {
|
||||
setup: {
|
||||
|
||||
Reference in New Issue
Block a user