mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-21 16:41:56 +00:00
Plugin SDK: split setup and sandbox subpaths
This commit is contained in:
1
src/agents/ollama-defaults.ts
Normal file
1
src/agents/ollama-defaults.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const OLLAMA_DEFAULT_BASE_URL = "http://127.0.0.1:11434";
|
||||
4
src/agents/sglang-defaults.ts
Normal file
4
src/agents/sglang-defaults.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const SGLANG_DEFAULT_BASE_URL = "http://127.0.0.1:30000/v1";
|
||||
export const SGLANG_PROVIDER_LABEL = "SGLang";
|
||||
export const SGLANG_DEFAULT_API_KEY_ENV_VAR = "SGLANG_API_KEY";
|
||||
export const SGLANG_MODEL_PLACEHOLDER = "Qwen/Qwen3-8B";
|
||||
4
src/agents/vllm-defaults.ts
Normal file
4
src/agents/vllm-defaults.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const VLLM_DEFAULT_BASE_URL = "http://127.0.0.1:8000/v1";
|
||||
export const VLLM_PROVIDER_LABEL = "vLLM";
|
||||
export const VLLM_DEFAULT_API_KEY_ENV_VAR = "VLLM_API_KEY";
|
||||
export const VLLM_MODEL_PLACEHOLDER = "meta-llama/Meta-Llama-3-8B-Instruct";
|
||||
@@ -30,27 +30,6 @@ export type {
|
||||
ProviderAuthMethod,
|
||||
ProviderAuthResult,
|
||||
} from "../plugins/types.js";
|
||||
export type {
|
||||
CreateSandboxBackendParams,
|
||||
RemoteShellSandboxHandle,
|
||||
RunSshSandboxCommandParams,
|
||||
SandboxBackendCommandParams,
|
||||
SandboxBackendCommandResult,
|
||||
SandboxBackendExecSpec,
|
||||
SandboxBackendFactory,
|
||||
SandboxFsBridge,
|
||||
SandboxFsStat,
|
||||
SandboxBackendHandle,
|
||||
SandboxBackendId,
|
||||
SandboxBackendManager,
|
||||
SandboxBackendRegistration,
|
||||
SandboxBackendRuntimeInfo,
|
||||
SandboxContext,
|
||||
SandboxResolvedPath,
|
||||
SandboxSshConfig,
|
||||
SshSandboxSession,
|
||||
SshSandboxSettings,
|
||||
} from "../agents/sandbox.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export type { GatewayRequestHandlerOptions } from "../gateway/server-methods/types.js";
|
||||
export type {
|
||||
@@ -66,58 +45,7 @@ export type {
|
||||
} from "./channel-plugin-common.js";
|
||||
|
||||
export { emptyPluginConfigSchema } from "./channel-plugin-common.js";
|
||||
export {
|
||||
buildExecRemoteCommand,
|
||||
buildRemoteCommand,
|
||||
buildSshSandboxArgv,
|
||||
createRemoteShellSandboxFsBridge,
|
||||
createSshSandboxSessionFromConfigText,
|
||||
createSshSandboxSessionFromSettings,
|
||||
disposeSshSandboxSession,
|
||||
getSandboxBackendFactory,
|
||||
getSandboxBackendManager,
|
||||
registerSandboxBackend,
|
||||
runSshSandboxCommand,
|
||||
shellEscape,
|
||||
uploadDirectoryToSshTarget,
|
||||
requireSandboxBackendFactory,
|
||||
} from "../agents/sandbox.js";
|
||||
export { buildOauthProviderAuthResult } from "./provider-auth-result.js";
|
||||
export {
|
||||
applyProviderDefaultModel,
|
||||
configureOpenAICompatibleSelfHostedProviderNonInteractive,
|
||||
discoverOpenAICompatibleSelfHostedProvider,
|
||||
promptAndConfigureOpenAICompatibleSelfHostedProvider,
|
||||
promptAndConfigureOpenAICompatibleSelfHostedProviderAuth,
|
||||
SELF_HOSTED_DEFAULT_CONTEXT_WINDOW,
|
||||
SELF_HOSTED_DEFAULT_COST,
|
||||
SELF_HOSTED_DEFAULT_MAX_TOKENS,
|
||||
} from "../commands/self-hosted-provider-setup.js";
|
||||
export {
|
||||
OLLAMA_DEFAULT_BASE_URL,
|
||||
OLLAMA_DEFAULT_MODEL,
|
||||
configureOllamaNonInteractive,
|
||||
ensureOllamaModelPulled,
|
||||
promptAndConfigureOllama,
|
||||
} from "../commands/ollama-setup.js";
|
||||
export {
|
||||
VLLM_DEFAULT_BASE_URL,
|
||||
VLLM_DEFAULT_CONTEXT_WINDOW,
|
||||
VLLM_DEFAULT_COST,
|
||||
VLLM_DEFAULT_MAX_TOKENS,
|
||||
promptAndConfigureVllm,
|
||||
} from "../commands/vllm-setup.js";
|
||||
export {
|
||||
buildOllamaProvider,
|
||||
buildSglangProvider,
|
||||
buildVllmProvider,
|
||||
} from "../agents/models-config.providers.discovery.js";
|
||||
|
||||
export {
|
||||
approveDevicePairing,
|
||||
listDevicePairing,
|
||||
rejectDevicePairing,
|
||||
} from "../infra/device-pairing.js";
|
||||
export {
|
||||
DEFAULT_SECRET_FILE_MAX_BYTES,
|
||||
loadSecretFileSync,
|
||||
@@ -126,13 +54,6 @@ export {
|
||||
} from "../infra/secret-file.js";
|
||||
export type { SecretFileReadOptions, SecretFileReadResult } from "../infra/secret-file.js";
|
||||
|
||||
export {
|
||||
runPluginCommandWithTimeout,
|
||||
type PluginCommandRunOptions,
|
||||
type PluginCommandRunResult,
|
||||
} from "./run-command.js";
|
||||
export { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
|
||||
|
||||
export { resolveGatewayBindUrl } from "../shared/gateway-bind-url.js";
|
||||
export type { GatewayBindUrlResult } from "../shared/gateway-bind-url.js";
|
||||
|
||||
|
||||
37
src/plugin-sdk/provider-setup.ts
Normal file
37
src/plugin-sdk/provider-setup.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
export type {
|
||||
OpenClawPluginApi,
|
||||
ProviderAuthContext,
|
||||
ProviderAuthMethodNonInteractiveContext,
|
||||
ProviderAuthResult,
|
||||
ProviderDiscoveryContext,
|
||||
} from "../plugins/types.js";
|
||||
|
||||
export {
|
||||
applyProviderDefaultModel,
|
||||
configureOpenAICompatibleSelfHostedProviderNonInteractive,
|
||||
discoverOpenAICompatibleSelfHostedProvider,
|
||||
promptAndConfigureOpenAICompatibleSelfHostedProvider,
|
||||
promptAndConfigureOpenAICompatibleSelfHostedProviderAuth,
|
||||
SELF_HOSTED_DEFAULT_CONTEXT_WINDOW,
|
||||
SELF_HOSTED_DEFAULT_COST,
|
||||
SELF_HOSTED_DEFAULT_MAX_TOKENS,
|
||||
} from "../commands/self-hosted-provider-setup.js";
|
||||
export {
|
||||
OLLAMA_DEFAULT_BASE_URL,
|
||||
OLLAMA_DEFAULT_MODEL,
|
||||
configureOllamaNonInteractive,
|
||||
ensureOllamaModelPulled,
|
||||
promptAndConfigureOllama,
|
||||
} from "../commands/ollama-setup.js";
|
||||
export {
|
||||
VLLM_DEFAULT_BASE_URL,
|
||||
VLLM_DEFAULT_CONTEXT_WINDOW,
|
||||
VLLM_DEFAULT_COST,
|
||||
VLLM_DEFAULT_MAX_TOKENS,
|
||||
promptAndConfigureVllm,
|
||||
} from "../commands/vllm-setup.js";
|
||||
export {
|
||||
buildOllamaProvider,
|
||||
buildSglangProvider,
|
||||
buildVllmProvider,
|
||||
} from "../agents/models-config.providers.discovery.js";
|
||||
45
src/plugin-sdk/sandbox.ts
Normal file
45
src/plugin-sdk/sandbox.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
export type {
|
||||
CreateSandboxBackendParams,
|
||||
RemoteShellSandboxHandle,
|
||||
RunSshSandboxCommandParams,
|
||||
SandboxBackendCommandParams,
|
||||
SandboxBackendCommandResult,
|
||||
SandboxBackendExecSpec,
|
||||
SandboxBackendFactory,
|
||||
SandboxFsBridge,
|
||||
SandboxFsStat,
|
||||
SandboxBackendHandle,
|
||||
SandboxBackendId,
|
||||
SandboxBackendManager,
|
||||
SandboxBackendRegistration,
|
||||
SandboxBackendRuntimeInfo,
|
||||
SandboxContext,
|
||||
SandboxResolvedPath,
|
||||
SandboxSshConfig,
|
||||
SshSandboxSession,
|
||||
SshSandboxSettings,
|
||||
} from "../agents/sandbox.js";
|
||||
|
||||
export {
|
||||
buildExecRemoteCommand,
|
||||
buildRemoteCommand,
|
||||
buildSshSandboxArgv,
|
||||
createRemoteShellSandboxFsBridge,
|
||||
createSshSandboxSessionFromConfigText,
|
||||
createSshSandboxSessionFromSettings,
|
||||
disposeSshSandboxSession,
|
||||
getSandboxBackendFactory,
|
||||
getSandboxBackendManager,
|
||||
registerSandboxBackend,
|
||||
requireSandboxBackendFactory,
|
||||
runSshSandboxCommand,
|
||||
shellEscape,
|
||||
uploadDirectoryToSshTarget,
|
||||
} from "../agents/sandbox.js";
|
||||
|
||||
export {
|
||||
runPluginCommandWithTimeout,
|
||||
type PluginCommandRunOptions,
|
||||
type PluginCommandRunResult,
|
||||
} from "./run-command.js";
|
||||
export { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
|
||||
@@ -11,6 +11,8 @@ import * as imessageSdk from "openclaw/plugin-sdk/imessage";
|
||||
import * as lineSdk from "openclaw/plugin-sdk/line";
|
||||
import * as msteamsSdk from "openclaw/plugin-sdk/msteams";
|
||||
import * as nostrSdk from "openclaw/plugin-sdk/nostr";
|
||||
import * as providerSetupSdk from "openclaw/plugin-sdk/provider-setup";
|
||||
import * as sandboxSdk from "openclaw/plugin-sdk/sandbox";
|
||||
import * as signalSdk from "openclaw/plugin-sdk/signal";
|
||||
import * as slackSdk from "openclaw/plugin-sdk/slack";
|
||||
import * as telegramSdk from "openclaw/plugin-sdk/telegram";
|
||||
@@ -46,6 +48,24 @@ describe("plugin-sdk subpath exports", () => {
|
||||
expect(typeof coreSdk.resolveThreadSessionKeys).toBe("function");
|
||||
expect(typeof coreSdk.runPassiveAccountLifecycle).toBe("function");
|
||||
expect(typeof coreSdk.createLoggerBackedRuntime).toBe("function");
|
||||
expect("registerSandboxBackend" in asExports(coreSdk)).toBe(false);
|
||||
expect("promptAndConfigureOpenAICompatibleSelfHostedProviderAuth" in asExports(coreSdk)).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("exports provider setup helpers from the dedicated subpath", () => {
|
||||
expect(typeof providerSetupSdk.buildVllmProvider).toBe("function");
|
||||
expect(typeof providerSetupSdk.discoverOpenAICompatibleSelfHostedProvider).toBe("function");
|
||||
expect(typeof providerSetupSdk.promptAndConfigureOpenAICompatibleSelfHostedProviderAuth).toBe(
|
||||
"function",
|
||||
);
|
||||
});
|
||||
|
||||
it("exports sandbox helpers from the dedicated subpath", () => {
|
||||
expect(typeof sandboxSdk.registerSandboxBackend).toBe("function");
|
||||
expect(typeof sandboxSdk.runPluginCommandWithTimeout).toBe("function");
|
||||
expect(typeof sandboxSdk.createRemoteShellSandboxFsBridge).toBe("function");
|
||||
});
|
||||
|
||||
it("exports shared core types used by bundled channels", () => {
|
||||
|
||||
@@ -22,8 +22,8 @@ vi.mock("../../../extensions/github-copilot/token.js", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/core", async () => {
|
||||
const actual = await vi.importActual<object>("openclaw/plugin-sdk/core");
|
||||
vi.mock("openclaw/plugin-sdk/provider-setup", async () => {
|
||||
const actual = await vi.importActual<object>("openclaw/plugin-sdk/provider-setup");
|
||||
return {
|
||||
...actual,
|
||||
buildOllamaProvider: (...args: unknown[]) => buildOllamaProviderMock(...args),
|
||||
|
||||
Reference in New Issue
Block a user