refactor: untangle remaining plugin sdk boundaries

This commit is contained in:
Peter Steinberger
2026-03-16 21:13:56 -07:00
parent afc0172cb1
commit 9ebe38b6e3
492 changed files with 5657 additions and 2877 deletions

View File

@@ -1,3 +1,16 @@
export type { OpenClawConfig } from "../config/config.js";
export { createAccountActionGate } from "../channels/plugins/account-action-gate.js";
export { createAccountListHelpers } from "../channels/plugins/account-helpers.js";
export { normalizeChatType } from "../channels/chat-type.js";
export { resolveAccountEntry } from "../routing/account-lookup.js";
export {
DEFAULT_ACCOUNT_ID,
normalizeAccountId,
normalizeOptionalAccountId,
} from "../routing/session-key.js";
export { normalizeE164, pathExists, resolveUserPath } from "../utils.js";
/** Resolve an account by id, then fall back to the default account when the primary lacks credentials. */
export function resolveAccountWithDefaultFallback<TAccount>(params: {
accountId?: string | null;

View File

@@ -0,0 +1,6 @@
// Public ACP runtime helpers for plugins that integrate with ACP control/session state.
export { getAcpSessionManager } from "../acp/control-plane/manager.js";
export { isAcpRuntimeError } from "../acp/runtime/errors.js";
export { readAcpSessionEntry } from "../acp/runtime/session-meta.js";
export type { AcpSessionStoreEntry } from "../acp/runtime/session-meta.js";

View File

@@ -0,0 +1,28 @@
// Public agent/model/runtime helpers for plugins that integrate with core agent flows.
export * from "../agents/agent-scope.js";
export * from "../agents/auth-profiles.js";
export * from "../agents/current-time.js";
export * from "../agents/defaults.js";
export * from "../agents/identity-avatar.js";
export * from "../agents/identity.js";
export * from "../agents/model-auth-markers.js";
export * from "../agents/model-auth.js";
export * from "../agents/model-catalog.js";
export * from "../agents/model-selection.js";
export * from "../agents/pi-embedded-block-chunker.js";
export * from "../agents/pi-embedded-utils.js";
export * from "../agents/provider-id.js";
export * from "../agents/schema/typebox.js";
export * from "../agents/sglang-defaults.js";
export * from "../agents/tools/common.js";
export * from "../agents/tools/discord-actions-shared.js";
export * from "../agents/tools/discord-actions.js";
export * from "../agents/tools/telegram-actions.js";
export * from "../agents/tools/web-guarded-fetch.js";
export * from "../agents/tools/web-shared.js";
export * from "../agents/tools/discord-actions-moderation-shared.js";
export * from "../agents/tools/web-fetch-utils.js";
export * from "../agents/vllm-defaults.js";
export * from "../commands/agent.js";
export * from "../tts/tts.js";

View File

@@ -2,6 +2,13 @@ import {
deleteAccountFromConfigSection,
setAccountEnabledInConfigSection,
} from "../channels/plugins/config-helpers.js";
import {
collectAllowlistProviderGroupPolicyWarnings,
collectAllowlistProviderRestrictSendersWarnings,
collectOpenGroupPolicyConfiguredRouteWarnings,
collectOpenGroupPolicyRouteAllowlistWarnings,
collectOpenProviderGroupPolicyWarnings,
} from "../channels/plugins/group-policy-warnings.js";
import { buildAccountScopedDmSecurityPolicy } from "../channels/plugins/helpers.js";
import { normalizeWhatsAppAllowFromEntries } from "../channels/plugins/normalize/whatsapp.js";
import { getChannelPlugin } from "../channels/plugins/registry.js";
@@ -149,6 +156,15 @@ export function createScopedDmSecurityResolver<
});
}
export { buildAccountScopedDmSecurityPolicy };
export {
collectAllowlistProviderGroupPolicyWarnings,
collectAllowlistProviderRestrictSendersWarnings,
collectOpenGroupPolicyConfiguredRouteWarnings,
collectOpenGroupPolicyRouteAllowlistWarnings,
collectOpenProviderGroupPolicyWarnings,
};
/** Read the effective WhatsApp allowlist through the active plugin contract. */
export function resolveWhatsAppConfigAllowFrom(params: {
cfg: OpenClawConfig;

View File

@@ -0,0 +1,53 @@
// Shared channel/runtime helpers for plugins. Channel plugins should use this
// surface instead of reaching into src/channels or adjacent infra modules.
export * from "../channels/ack-reactions.js";
export * from "../channels/allow-from.js";
export * from "../channels/allowlists/resolve-utils.js";
export * from "../channels/allowlist-match.js";
export * from "../channels/channel-config.js";
export * from "../channels/chat-type.js";
export * from "../channels/command-gating.js";
export * from "../channels/conversation-label.js";
export * from "../channels/draft-stream-controls.js";
export * from "../channels/draft-stream-loop.js";
export * from "../channels/inbound-debounce-policy.js";
export * from "../channels/location.js";
export * from "../channels/logging.js";
export * from "../channels/mention-gating.js";
export * from "../channels/native-command-session-targets.js";
export * from "../channels/reply-prefix.js";
export * from "../channels/run-state-machine.js";
export * from "../channels/session.js";
export * from "../channels/session-envelope.js";
export * from "../channels/session-meta.js";
export * from "../channels/status-reactions.js";
export * from "../channels/targets.js";
export * from "../channels/thread-binding-id.js";
export * from "../channels/thread-bindings-messages.js";
export * from "../channels/thread-bindings-policy.js";
export * from "../channels/transport/stall-watchdog.js";
export * from "../channels/typing.js";
export * from "../channels/plugins/actions/reaction-message-id.js";
export * from "../channels/plugins/actions/shared.js";
export type * from "../channels/plugins/types.js";
export * from "../channels/plugins/config-writes.js";
export * from "../channels/plugins/directory-config.js";
export * from "../channels/plugins/media-payload.js";
export * from "../channels/plugins/normalize/signal.js";
export * from "../channels/plugins/normalize/whatsapp.js";
export * from "../channels/plugins/outbound/direct-text-media.js";
export * from "../channels/plugins/outbound/interactive.js";
export * from "../channels/plugins/status-issues/shared.js";
export * from "../channels/plugins/whatsapp-heartbeat.js";
export * from "../infra/outbound/send-deps.js";
export * from "../utils/message-channel.js";
export type {
InteractiveButtonStyle,
InteractiveReplyButton,
InteractiveReply,
} from "../interactive/payload.js";
export {
normalizeInteractiveReply,
resolveInteractiveTextFallback,
} from "../interactive/payload.js";

View File

@@ -0,0 +1,6 @@
// Public CLI/output helpers for plugins that share terminal-facing command behavior.
export * from "../cli/command-format.js";
export * from "../cli/parse-duration.js";
export * from "../cli/wait.js";
export * from "../version.js";

View File

@@ -0,0 +1,42 @@
// Shared config/runtime boundary for plugins that need config loading,
// config writes, or session-store helpers without importing src internals.
export * from "../config/config.js";
export * from "../config/markdown-tables.js";
export * from "../config/group-policy.js";
export * from "../config/runtime-group-policy.js";
export * from "../config/commands.js";
export * from "../config/discord-preview-streaming.js";
export * from "../config/io.js";
export * from "../config/telegram-custom-commands.js";
export * from "../config/talk.js";
export * from "../config/agent-limits.js";
export * from "../cron/store.js";
export * from "../sessions/model-overrides.js";
export type * from "../config/types.slack.js";
export {
loadSessionStore,
readSessionUpdatedAt,
recordSessionMetaFromInbound,
resolveSessionKey,
resolveStorePath,
updateLastRoute,
updateSessionStore,
type SessionResetMode,
type SessionScope,
} from "../config/sessions.js";
export { resolveGroupSessionKey } from "../config/sessions/group.js";
export {
evaluateSessionFreshness,
resolveChannelResetConfig,
resolveSessionResetPolicy,
resolveSessionResetType,
resolveThreadFlag,
} from "../config/sessions/reset.js";
export { resolveSessionStoreEntry } from "../config/sessions/store.js";
export { isDangerousNameMatchingEnabled } from "../config/dangerous-name-matching.js";
export {
hasConfiguredSecretInput,
normalizeResolvedSecretInputString,
normalizeSecretInputString,
} from "../config/types.secrets.js";

View File

@@ -0,0 +1,41 @@
// Public pairing/session-binding helpers for plugins that manage conversation ownership.
export * from "../acp/persistent-bindings.route.js";
export {
type BindingStatus,
type BindingTargetKind,
type ConversationRef,
SessionBindingError,
type SessionBindingAdapter,
type SessionBindingAdapterCapabilities,
type SessionBindingBindInput,
type SessionBindingCapabilities,
type SessionBindingPlacement,
type SessionBindingRecord,
type SessionBindingService,
type SessionBindingUnbindInput,
getSessionBindingService,
isSessionBindingError,
registerSessionBindingAdapter,
unregisterSessionBindingAdapter,
} from "../infra/outbound/session-binding-service.js";
export * from "../pairing/pairing-challenge.js";
export * from "../pairing/pairing-messages.js";
export * from "../pairing/pairing-store.js";
export {
buildPluginBindingApprovalCustomId,
buildPluginBindingDeclinedText,
buildPluginBindingErrorText,
buildPluginBindingResolvedText,
buildPluginBindingUnavailableText,
detachPluginConversationBinding,
getCurrentPluginConversationBinding,
hasShownPluginBindingFallbackNotice,
isPluginOwnedBindingMetadata,
isPluginOwnedSessionBindingRecord,
markPluginBindingFallbackNoticeShown,
parsePluginBindingApprovalCustomId,
requestPluginConversationBinding,
resolvePluginConversationBindingApproval,
toPluginConversationBinding,
} from "../plugins/conversation-binding.js";

View File

@@ -1,6 +1,18 @@
export type { ChannelMessageActionAdapter } from "../channels/plugins/types.js";
export type { OpenClawConfig } from "../config/config.js";
export type { DiscordAccountConfig, DiscordActionConfig } from "../config/types.js";
export type { DiscordPluralKitConfig } from "../../extensions/discord/src/pluralkit.js";
export type { InspectedDiscordAccount } from "../../extensions/discord/src/account-inspect.js";
export type { ResolvedDiscordAccount } from "../../extensions/discord/src/accounts.js";
export type {
DiscordSendComponents,
DiscordSendEmbeds,
} from "../../extensions/discord/src/send.shared.js";
export type {
ThreadBindingManager,
ThreadBindingRecord,
ThreadBindingTargetKind,
} from "../../extensions/discord/src/monitor/thread-bindings.js";
export type {
ChannelMessageActionContext,
ChannelPlugin,
@@ -44,3 +56,77 @@ export {
buildComputedAccountStatusSnapshot,
buildTokenChannelStatusSummary,
} from "./status-helpers.js";
export {
createDiscordActionGate,
listDiscordAccountIds,
resolveDefaultDiscordAccountId,
resolveDiscordAccount,
} from "../../extensions/discord/src/accounts.js";
export { inspectDiscordAccount } from "../../extensions/discord/src/account-inspect.js";
export {
looksLikeDiscordTargetId,
normalizeDiscordMessagingTarget,
normalizeDiscordOutboundTarget,
} from "../../extensions/discord/src/normalize.js";
export { collectDiscordAuditChannelIds } from "../../extensions/discord/src/audit.js";
export { collectDiscordStatusIssues } from "../../extensions/discord/src/status-issues.js";
export {
DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS,
DISCORD_DEFAULT_LISTENER_TIMEOUT_MS,
} from "../../extensions/discord/src/monitor/timeouts.js";
export { normalizeExplicitDiscordSessionKey } from "../../extensions/discord/src/session-key-normalization.js";
export {
autoBindSpawnedDiscordSubagent,
listThreadBindingsBySessionKey,
unbindThreadBindingsBySessionKey,
} from "../../extensions/discord/src/monitor/thread-bindings.js";
export { getGateway } from "../../extensions/discord/src/monitor/gateway-registry.js";
export { getPresence } from "../../extensions/discord/src/monitor/presence-cache.js";
export { readDiscordComponentSpec } from "../../extensions/discord/src/components.js";
export { resolveDiscordChannelId } from "../../extensions/discord/src/targets.js";
export {
addRoleDiscord,
banMemberDiscord,
createChannelDiscord,
createScheduledEventDiscord,
createThreadDiscord,
deleteChannelDiscord,
deleteMessageDiscord,
editChannelDiscord,
editMessageDiscord,
fetchChannelInfoDiscord,
fetchChannelPermissionsDiscord,
fetchMemberInfoDiscord,
fetchMessageDiscord,
fetchReactionsDiscord,
fetchRoleInfoDiscord,
fetchVoiceStatusDiscord,
hasAnyGuildPermissionDiscord,
kickMemberDiscord,
listGuildChannelsDiscord,
listGuildEmojisDiscord,
listPinsDiscord,
listScheduledEventsDiscord,
listThreadsDiscord,
moveChannelDiscord,
pinMessageDiscord,
reactMessageDiscord,
readMessagesDiscord,
removeChannelPermissionDiscord,
removeOwnReactionsDiscord,
removeReactionDiscord,
removeRoleDiscord,
searchMessagesDiscord,
sendDiscordComponentMessage,
sendMessageDiscord,
sendPollDiscord,
sendStickerDiscord,
sendVoiceMessageDiscord,
setChannelPermissionDiscord,
timeoutMemberDiscord,
unpinMessageDiscord,
uploadEmojiDiscord,
uploadStickerDiscord,
} from "../../extensions/discord/src/send.js";
export { discordMessageActions } from "../../extensions/discord/src/channel-actions.js";

View File

@@ -0,0 +1,6 @@
// Public gateway/client helpers for plugins that talk to the host gateway surface.
export * from "../gateway/channel-status-patches.js";
export { GatewayClient } from "../gateway/client.js";
export { createOperatorApprovalsGatewayClient } from "../gateway/operator-approvals-client.js";
export type { EventFrame } from "../gateway/protocol/index.js";

View File

@@ -0,0 +1,5 @@
// Public hook helpers for plugins that need the shared internal/webhook hook pipeline.
export * from "../hooks/fire-and-forget.js";
export * from "../hooks/internal-hooks.js";
export * from "../hooks/message-hook-mappers.js";

View File

@@ -40,3 +40,4 @@ export { IMessageConfigSchema } from "../config/zod-schema.providers-core.js";
export { resolveChannelMediaMaxBytes } from "../channels/plugins/media-limits.js";
export { collectStatusIssuesFromLastError } from "./status-helpers.js";
export { sendMessageIMessage } from "../../extensions/imessage/src/send.js";

View File

@@ -0,0 +1,39 @@
// Public runtime/transport helpers for plugins that need shared infra behavior.
export * from "../infra/backoff.js";
export * from "../infra/channel-activity.js";
export * from "../infra/dedupe.js";
export * from "../infra/diagnostic-events.js";
export * from "../infra/diagnostic-flags.js";
export * from "../infra/env.js";
export * from "../infra/errors.js";
export * from "../infra/exec-approval-command-display.ts";
export * from "../infra/exec-approval-reply.ts";
export * from "../infra/exec-approval-session-target.ts";
export * from "../infra/exec-approvals.ts";
export * from "../infra/fetch.js";
export * from "../infra/file-lock.js";
export * from "../infra/format-time/format-duration.ts";
export * from "../infra/fs-safe.ts";
export * from "../infra/heartbeat-events.ts";
export * from "../infra/heartbeat-visibility.ts";
export * from "../infra/home-dir.js";
export * from "../infra/http-body.js";
export * from "../infra/json-files.js";
export * from "../infra/map-size.js";
export * from "../infra/net/hostname.ts";
export * from "../infra/net/fetch-guard.js";
export * from "../infra/net/proxy-env.js";
export * from "../infra/net/proxy-fetch.js";
export * from "../infra/net/ssrf.js";
export * from "../infra/outbound/identity.js";
export * from "../infra/retry.js";
export * from "../infra/retry-policy.js";
export * from "../infra/scp-host.ts";
export * from "../infra/secret-file.js";
export * from "../infra/secure-random.js";
export * from "../infra/system-events.js";
export * from "../infra/system-message.ts";
export * from "../infra/tmp-openclaw-dir.js";
export * from "../infra/transport-ready.js";
export * from "../infra/wsl.ts";

View File

@@ -1,7 +1,14 @@
import fs from "node:fs";
import { loadJsonFile, saveJsonFile } from "../infra/json-file.js";
import { writeJsonAtomic } from "../infra/json-files.js";
import { safeParseJson } from "../utils.js";
/** Read small JSON blobs synchronously for token/state caches. */
export { loadJsonFile };
/** Persist small JSON blobs synchronously with restrictive permissions. */
export { saveJsonFile };
/** Read JSON from disk and fall back cleanly when the file is missing or invalid. */
export async function readJsonFileWithFallback<T>(
filePath: string,

View File

@@ -0,0 +1,21 @@
// Public media/payload helpers for plugins that fetch, transform, or send attachments.
export * from "../media/audio.js";
export * from "../media/constants.js";
export * from "../media/fetch.js";
export * from "../media/ffmpeg-exec.js";
export * from "../media/ffmpeg-limits.js";
export * from "../media/image-ops.js";
export * from "../media/inbound-path-policy.js";
export * from "../media/load-options.js";
export * from "../media/local-roots.js";
export * from "../media/mime.js";
export * from "../media/outbound-attachment.js";
export * from "../media/png-encode.ts";
export * from "../media/store.js";
export * from "../media/temp-files.js";
export * from "../media-understanding/audio-preflight.ts";
export * from "../media-understanding/defaults.js";
export * from "../media-understanding/providers/image-runtime.ts";
export * from "../media-understanding/runner.js";
export * from "../polls.js";

View File

@@ -0,0 +1,6 @@
// Public plugin-command/hook helpers for plugins that extend shared command or hook flows.
export * from "../plugins/commands.js";
export * from "../plugins/hook-runner-global.js";
export * from "../plugins/interactive.js";
export * from "../plugins/types.js";

View File

@@ -0,0 +1,3 @@
// Public process helpers for plugins that spawn or probe local commands.
export * from "../process/exec.js";

View File

@@ -0,0 +1,43 @@
// Public auth/onboarding helpers for provider plugins.
export type { OpenClawConfig } from "../config/config.js";
export type { SecretInput } from "../config/types.secrets.js";
export type { ProviderAuthResult } from "../plugins/types.js";
export type { AuthProfileStore, OAuthCredential } from "../agents/auth-profiles/types.js";
export {
CLAUDE_CLI_PROFILE_ID,
CODEX_CLI_PROFILE_ID,
ensureAuthProfileStore,
listProfilesForProvider,
suggestOAuthProfileIdForLegacyDefault,
upsertAuthProfile,
} from "../agents/auth-profiles.js";
export {
MINIMAX_OAUTH_MARKER,
resolveNonEnvSecretRefApiKeyMarker,
} from "../agents/model-auth-markers.js";
export {
formatApiKeyPreview,
normalizeApiKeyInput,
validateApiKeyInput,
} from "../commands/auth-choice.api-key.js";
export {
ensureApiKeyFromOptionEnvOrPrompt,
normalizeSecretInputModeInput,
promptSecretRefForSetup,
resolveSecretInputModeForEnvSelection,
} from "../commands/auth-choice.apply-helpers.js";
export { buildTokenProfileId, validateAnthropicSetupToken } from "../commands/auth-token.js";
export { buildApiKeyCredential } from "../commands/onboard-auth.credentials.js";
export { applyAuthProfileConfig } from "../commands/onboard-auth.js";
export { githubCopilotLoginCommand } from "../providers/github-copilot-auth.js";
export { loginOpenAICodexOAuth } from "../commands/openai-codex-oauth.js";
export { createProviderApiKeyAuthMethod } from "../plugins/provider-api-key-auth.js";
export { coerceSecretRef } from "../config/types.secrets.js";
export { resolveDefaultSecretProviderAlias } from "../secrets/ref-contract.js";
export { resolveRequiredHomeDir } from "../infra/home-dir.js";
export {
normalizeOptionalSecretInput,
normalizeSecretInput,
} from "../utils/normalize-secret-input.js";

View File

@@ -0,0 +1,86 @@
// Public model/catalog helpers for provider plugins.
export type {
ModelApi,
ModelDefinitionConfig,
ModelProviderConfig,
} from "../config/types.models.js";
export type { ProviderPlugin } from "../plugins/types.js";
export { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js";
export { normalizeModelCompat } from "../agents/model-compat.js";
export { normalizeProviderId } from "../agents/provider-id.js";
export {
applyGoogleGeminiModelDefault,
GOOGLE_GEMINI_DEFAULT_MODEL,
} from "../commands/google-gemini-model-default.js";
export { applyOpenAIConfig, OPENAI_DEFAULT_MODEL } from "../commands/openai-model-default.js";
export { OPENCODE_GO_DEFAULT_MODEL_REF } from "../commands/opencode-go-model-default.js";
export { OPENCODE_ZEN_DEFAULT_MODEL } from "../commands/opencode-zen-model-default.js";
export { OPENCODE_ZEN_DEFAULT_MODEL_REF } from "../agents/opencode-zen-models.js";
export * from "../commands/onboard-auth.models.js";
export {
buildCloudflareAiGatewayModelDefinition,
CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF,
resolveCloudflareAiGatewayBaseUrl,
} from "../agents/cloudflare-ai-gateway.js";
export {
discoverHuggingfaceModels,
HUGGINGFACE_BASE_URL,
HUGGINGFACE_MODEL_CATALOG,
buildHuggingfaceModelDefinition,
} from "../agents/huggingface-models.js";
export { discoverKilocodeModels } from "../agents/kilocode-models.js";
export { resolveOllamaApiBase } from "../agents/ollama-models.js";
export {
buildSyntheticModelDefinition,
SYNTHETIC_BASE_URL,
SYNTHETIC_DEFAULT_MODEL_REF,
SYNTHETIC_MODEL_CATALOG,
} from "../agents/synthetic-models.js";
export {
buildTogetherModelDefinition,
TOGETHER_BASE_URL,
TOGETHER_MODEL_CATALOG,
} from "../agents/together-models.js";
export {
discoverVeniceModels,
VENICE_BASE_URL,
VENICE_DEFAULT_MODEL_REF,
VENICE_MODEL_CATALOG,
buildVeniceModelDefinition,
} from "../agents/venice-models.js";
export {
BYTEPLUS_BASE_URL,
BYTEPLUS_CODING_BASE_URL,
BYTEPLUS_CODING_MODEL_CATALOG,
BYTEPLUS_MODEL_CATALOG,
buildBytePlusModelDefinition,
} from "../agents/byteplus-models.js";
export {
DOUBAO_BASE_URL,
DOUBAO_CODING_BASE_URL,
DOUBAO_CODING_MODEL_CATALOG,
DOUBAO_MODEL_CATALOG,
buildDoubaoModelDefinition,
} from "../agents/doubao-models.js";
export { OLLAMA_DEFAULT_BASE_URL } from "../agents/ollama-defaults.js";
export { VLLM_DEFAULT_BASE_URL } from "../agents/vllm-defaults.js";
export { SGLANG_DEFAULT_BASE_URL } from "../agents/sglang-defaults.js";
export {
KILOCODE_BASE_URL,
KILOCODE_DEFAULT_CONTEXT_WINDOW,
KILOCODE_DEFAULT_COST,
KILOCODE_DEFAULT_MODEL_REF,
KILOCODE_DEFAULT_MAX_TOKENS,
KILOCODE_DEFAULT_MODEL_ID,
KILOCODE_DEFAULT_MODEL_NAME,
KILOCODE_MODEL_CATALOG,
} from "../providers/kilocode-shared.js";
export {
discoverVercelAiGatewayModels,
VERCEL_AI_GATEWAY_BASE_URL,
} from "../agents/vercel-ai-gateway.js";

View File

@@ -0,0 +1,16 @@
// Public config patch helpers for provider onboarding flows.
export type { OpenClawConfig } from "../config/config.js";
export type {
ModelApi,
ModelDefinitionConfig,
ModelProviderConfig,
} from "../config/types.models.js";
export {
applyAgentDefaultModelPrimary,
applyOnboardAuthAgentModelsAndProviders,
applyProviderConfigWithDefaultModel,
applyProviderConfigWithDefaultModels,
applyProviderConfigWithModelCatalog,
} from "../commands/onboard-auth.config-shared.js";
export { ensureModelAllowlistEntry } from "../commands/model-allowlist.js";

View File

@@ -0,0 +1,17 @@
// Public stream-wrapper helpers for provider plugins.
export {
createKilocodeWrapper,
createOpenRouterSystemCacheWrapper,
createOpenRouterWrapper,
isProxyReasoningUnsupported,
} from "../agents/pi-embedded-runner/proxy-stream-wrappers.js";
export {
createMoonshotThinkingWrapper,
resolveMoonshotThinkingType,
} from "../agents/pi-embedded-runner/moonshot-stream-wrappers.js";
export { createZaiToolStreamWrapper } from "../agents/pi-embedded-runner/zai-stream-wrappers.js";
export {
getOpenRouterModelCapabilities,
loadOpenRouterModelCapabilities,
} from "../agents/pi-embedded-runner/openrouter-model-capabilities.js";

View File

@@ -0,0 +1,21 @@
// Public usage fetch helpers for provider plugins.
export type {
ProviderUsageSnapshot,
UsageProviderId,
UsageWindow,
} from "../infra/provider-usage.types.js";
export {
fetchClaudeUsage,
fetchCodexUsage,
fetchGeminiUsage,
fetchMinimaxUsage,
fetchZaiUsage,
} from "../infra/provider-usage.fetch.js";
export { clampPercent, PROVIDER_LABELS } from "../infra/provider-usage.shared.js";
export {
buildUsageErrorSnapshot,
buildUsageHttpErrorSnapshot,
fetchJson,
} from "../infra/provider-usage.fetch.shared.js";

View File

@@ -0,0 +1,18 @@
// Public web-search registration helpers for provider plugins.
export {
createPluginBackedWebSearchProvider,
getScopedCredentialValue,
getTopLevelCredentialValue,
setScopedCredentialValue,
setTopLevelCredentialValue,
} from "../agents/tools/web-search-plugin-factory.js";
export { withTrustedWebToolsEndpoint } from "../agents/tools/web-guarded-fetch.js";
export {
DEFAULT_CACHE_TTL_MINUTES,
normalizeCacheKey,
readCache,
readResponseText,
resolveCacheTtlMs,
writeCache,
} from "../agents/tools/web-shared.js";

View File

@@ -8,4 +8,7 @@ export type {
ProviderAuthContext,
ProviderCatalogContext,
} from "../plugins/types.js";
export { ensureAuthProfileStore, listProfilesForProvider } from "../agents/auth-profiles.js";
export { QWEN_OAUTH_MARKER } from "../agents/model-auth-markers.js";
export { refreshQwenPortalCredentials } from "../providers/qwen-portal-oauth.js";
export { generatePkceVerifierChallenge, toFormUrlEncoded } from "./oauth-utils.js";

View File

@@ -0,0 +1,31 @@
// Shared agent/reply runtime helpers for channel plugins. Keep channel plugins
// off direct src/auto-reply imports by routing common reply primitives here.
export * from "../auto-reply/chunk.js";
export * from "../auto-reply/command-auth.js";
export * from "../auto-reply/command-detection.js";
export * from "../auto-reply/commands-registry.js";
export * from "../auto-reply/dispatch.js";
export * from "../auto-reply/group-activation.js";
export * from "../auto-reply/heartbeat.js";
export * from "../auto-reply/heartbeat-reply-payload.js";
export * from "../auto-reply/inbound-debounce.js";
export * from "../auto-reply/reply.js";
export * from "../auto-reply/tokens.js";
export * from "../auto-reply/envelope.js";
export * from "../auto-reply/reply/history.js";
export * from "../auto-reply/reply/abort.js";
export * from "../auto-reply/reply/btw-command.js";
export * from "../auto-reply/reply/commands-models.js";
export * from "../auto-reply/reply/inbound-dedupe.js";
export * from "../auto-reply/reply/inbound-context.js";
export * from "../auto-reply/reply/mentions.js";
export * from "../auto-reply/reply/reply-dispatcher.js";
export * from "../auto-reply/reply/reply-reference.js";
export * from "../auto-reply/reply/provider-dispatcher.js";
export * from "../auto-reply/reply/model-selection.js";
export * from "../auto-reply/reply/commands-info.js";
export * from "../auto-reply/skill-commands.js";
export * from "../auto-reply/status.js";
export type { ReplyPayload } from "../auto-reply/types.js";
export type { FinalizedMsgContext, MsgContext } from "../auto-reply/templating.js";

View File

@@ -1,6 +1,31 @@
export {
buildAgentSessionKey,
deriveLastRoutePolicy,
resolveAgentRoute,
resolveInboundLastRouteSessionKey,
type ResolvedAgentRoute,
type RoutePeer,
type RoutePeerKind,
} from "../routing/resolve-route.js";
export { resolveThreadSessionKeys } from "../routing/session-key.js";
export {
buildAgentMainSessionKey,
DEFAULT_ACCOUNT_ID,
DEFAULT_MAIN_KEY,
buildGroupHistoryKey,
isCronSessionKey,
isSubagentSessionKey,
normalizeAccountId,
normalizeAgentId,
normalizeMainKey,
normalizeOptionalAccountId,
parseAgentSessionKey,
resolveAgentIdFromSessionKey,
resolveThreadSessionKeys,
sanitizeAgentId,
} from "../routing/session-key.js";
export { resolveAccountEntry } from "../routing/account-lookup.js";
export { listBoundAccountIds, resolveDefaultAgentBoundAccountId } from "../routing/bindings.js";
export {
formatSetExplicitDefaultInstruction,
formatSetExplicitDefaultToConfiguredInstruction,
} from "../routing/default-account-warnings.js";

View File

@@ -0,0 +1,21 @@
// Shared process/runtime utilities for plugins. This is the public boundary for
// logger wiring, runtime env shims, and global verbose console helpers.
export type { RuntimeEnv } from "../runtime.js";
export { createNonExitingRuntime, defaultRuntime } from "../runtime.js";
export {
danger,
info,
isVerbose,
isYes,
logVerbose,
logVerboseConsole,
setVerbose,
setYes,
shouldLogVerbose,
success,
warn,
} from "../globals.js";
export * from "../logging.js";
export { waitForAbortSignal } from "../infra/abort-signal.js";
export { registerUnhandledRejectionHandler } from "../infra/unhandled-rejections.js";

View File

@@ -1,3 +1,5 @@
export type { PluginRuntime } from "../plugins/runtime/types.js";
/** Create a tiny mutable runtime slot with strict access when the runtime has not been initialized. */
export function createPluginRuntimeStore<T>(errorMessage: string): {
setRuntime: (next: T) => void;

View File

@@ -1,5 +1,23 @@
import { format } from "node:util";
import type { RuntimeEnv } from "../runtime.js";
export type { RuntimeEnv } from "../runtime.js";
export { createNonExitingRuntime, defaultRuntime } from "../runtime.js";
export {
danger,
info,
isVerbose,
isYes,
logVerbose,
logVerboseConsole,
setVerbose,
setYes,
shouldLogVerbose,
success,
warn,
} from "../globals.js";
export * from "../logging.js";
export { waitForAbortSignal } from "../infra/abort-signal.js";
export { registerUnhandledRejectionHandler } from "../infra/unhandled-rejections.js";
type LoggerLike = {
info: (message: string) => void;

View File

@@ -0,0 +1,6 @@
// Public security/policy helpers for plugins that need shared trust and DM gating logic.
export * from "../security/channel-metadata.js";
export * from "../security/dm-policy-shared.js";
export * from "../security/external-content.js";
export * from "../security/safe-regex.js";

View File

@@ -7,11 +7,16 @@ export type { WizardPrompter } from "../wizard/prompts.js";
export type { ChannelSetupAdapter } from "../channels/plugins/types.adapters.js";
export type { ChannelSetupInput } from "../channels/plugins/types.core.js";
export type { ChannelSetupDmPolicy } from "../channels/plugins/setup-wizard-types.js";
export type { ChannelSetupWizardAllowFromEntry } from "../channels/plugins/setup-wizard.js";
export type { ChannelSetupWizard } from "../channels/plugins/setup-wizard.js";
export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export { formatCliCommand } from "../cli/command-format.js";
export { detectBinary } from "../commands/onboard-helpers.js";
export { installSignalCli } from "../commands/signal-install.js";
export { formatDocsLink } from "../terminal/links.js";
export { hasConfiguredSecretInput, normalizeSecretInputString } from "../config/types.secrets.js";
export { normalizeE164, pathExists } from "../utils.js";
export {
applyAccountNameToChannelSection,
@@ -23,10 +28,22 @@ export {
addWildcardAllowFrom,
buildSingleChannelSecretPromptState,
mergeAllowFromEntries,
normalizeAllowFromEntries,
noteChannelLookupFailure,
noteChannelLookupSummary,
parseMentionOrPrefixedId,
parseSetupEntriesAllowingWildcard,
parseSetupEntriesWithParser,
patchChannelConfigForAccount,
promptLegacyChannelAllowFrom,
promptParsedAllowFromForScopedChannel,
promptSingleChannelSecretInput,
promptResolvedAllowFrom,
resolveSetupAccountId,
runSingleChannelSecretStep,
setAccountGroupPolicyForChannel,
setChannelDmPolicyWithAllowFrom,
setLegacyChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
setTopLevelChannelAllowFrom,
setTopLevelChannelDmPolicyWithAllowFrom,

View File

@@ -1,5 +1,7 @@
export type { ChannelMessageActionAdapter } from "../channels/plugins/types.js";
export type { OpenClawConfig } from "../config/config.js";
export type { SignalAccountConfig } from "../config/types.js";
export type { ResolvedSignalAccount } from "../../extensions/signal/src/accounts.js";
export type {
ChannelMessageActionContext,
ChannelPlugin,
@@ -40,3 +42,16 @@ export {
collectStatusIssuesFromLastError,
createDefaultChannelRuntimeState,
} from "./status-helpers.js";
export {
listEnabledSignalAccounts,
listSignalAccountIds,
resolveDefaultSignalAccountId,
resolveSignalAccount,
} from "../../extensions/signal/src/accounts.js";
export { resolveSignalReactionLevel } from "../../extensions/signal/src/reaction-level.js";
export {
removeReactionSignal,
sendReactionSignal,
} from "../../extensions/signal/src/send-reactions.js";
export { sendMessageSignal } from "../../extensions/signal/src/send.js";

View File

@@ -1,5 +1,7 @@
export type { OpenClawConfig } from "../config/config.js";
export type { SlackAccountConfig } from "../config/types.slack.js";
export type { InspectedSlackAccount } from "../../extensions/slack/src/account-inspect.js";
export type { ResolvedSlackAccount } from "../../extensions/slack/src/accounts.js";
export type {
ChannelMessageActionContext,
ChannelPlugin,
@@ -43,3 +45,40 @@ export {
} from "../channels/plugins/group-mentions.js";
export { SlackConfigSchema } from "../config/zod-schema.providers-core.js";
export { buildComputedAccountStatusSnapshot } from "./status-helpers.js";
export {
listEnabledSlackAccounts,
listSlackAccountIds,
resolveDefaultSlackAccountId,
resolveSlackAccount,
resolveSlackReplyToMode,
} from "../../extensions/slack/src/accounts.js";
export { isSlackInteractiveRepliesEnabled } from "../../extensions/slack/src/interactive-replies.js";
export { inspectSlackAccount } from "../../extensions/slack/src/account-inspect.js";
export { parseSlackTarget, resolveSlackChannelId } from "./slack-targets.js";
export {
extractSlackToolSend,
listSlackMessageActions,
} from "../../extensions/slack/src/message-actions.js";
export { buildSlackThreadingToolContext } from "../../extensions/slack/src/threading-tool-context.js";
export { parseSlackBlocksInput } from "../../extensions/slack/src/blocks-input.js";
export { handleSlackHttpRequest } from "../../extensions/slack/src/http/index.js";
export { sendMessageSlack } from "../../extensions/slack/src/send.js";
export {
deleteSlackMessage,
downloadSlackFile,
editSlackMessage,
getSlackMemberInfo,
listSlackEmojis,
listSlackPins,
listSlackReactions,
pinSlackMessage,
reactSlackMessage,
readSlackMessages,
removeOwnSlackReactions,
removeSlackReaction,
sendSlackMessage,
unpinSlackMessage,
} from "../../extensions/slack/src/actions.js";
export { recordSlackThreadParticipation } from "../../extensions/slack/src/sent-thread-cache.js";
export { handleSlackMessageAction } from "./slack-message-actions.js";

7
src/plugin-sdk/speech.ts Normal file
View File

@@ -0,0 +1,7 @@
// Public speech-provider builders for bundled or third-party plugins.
export { buildElevenLabsSpeechProvider } from "../tts/providers/elevenlabs.js";
export { buildMicrosoftSpeechProvider } from "../tts/providers/microsoft.js";
export { buildOpenAISpeechProvider } from "../tts/providers/openai.js";
export { parseTtsDirectives } from "../tts/tts-core.js";
export type { SpeechVoiceOption } from "../tts/provider-types.js";

View File

@@ -0,0 +1,3 @@
// Public state/config path helpers for plugins that persist small caches.
export { resolveOAuthDir, resolveStateDir, STATE_DIR } from "../config/paths.js";

View File

@@ -12,9 +12,18 @@ export type {
TelegramActionConfig,
TelegramNetworkConfig,
} from "../config/types.js";
export type { InspectedTelegramAccount } from "../../extensions/telegram/src/account-inspect.js";
export type { ResolvedTelegramAccount } from "../../extensions/telegram/src/accounts.js";
export type { TelegramProbe } from "../../extensions/telegram/src/probe.js";
export type {
TelegramButtonStyle,
TelegramInlineButtons,
} from "../../extensions/telegram/src/button-types.js";
export type { StickerMetadata } from "../../extensions/telegram/src/bot/types.js";
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export { parseTelegramTopicConversation } from "../acp/conversation-id.js";
export {
PAIRING_APPROVED_MESSAGE,
@@ -28,6 +37,7 @@ export {
} from "./channel-plugin-common.js";
export { clearAccountEntryFields } from "../channels/plugins/config-helpers.js";
export { resolveTelegramPollVisibility } from "../poll-params.js";
export {
projectCredentialSnapshotFields,
@@ -49,3 +59,57 @@ export {
export { TelegramConfigSchema } from "../config/zod-schema.providers-core.js";
export { buildTokenChannelStatusSummary } from "./status-helpers.js";
export {
createTelegramActionGate,
listTelegramAccountIds,
resolveDefaultTelegramAccountId,
resolveTelegramPollActionGateState,
resolveTelegramAccount,
} from "../../extensions/telegram/src/accounts.js";
export { inspectTelegramAccount } from "../../extensions/telegram/src/account-inspect.js";
export {
looksLikeTelegramTargetId,
normalizeTelegramMessagingTarget,
} from "../../extensions/telegram/src/normalize.js";
export {
parseTelegramReplyToMessageId,
parseTelegramThreadId,
} from "../../extensions/telegram/src/outbound-params.js";
export {
isNumericTelegramUserId,
normalizeTelegramAllowFromEntry,
} from "../../extensions/telegram/src/allow-from.js";
export { fetchTelegramChatId } from "../../extensions/telegram/src/api-fetch.js";
export {
resolveTelegramInlineButtonsScope,
resolveTelegramTargetChatType,
} from "../../extensions/telegram/src/inline-buttons.js";
export { resolveTelegramReactionLevel } from "../../extensions/telegram/src/reaction-level.js";
export {
createForumTopicTelegram,
deleteMessageTelegram,
editForumTopicTelegram,
editMessageTelegram,
reactMessageTelegram,
sendMessageTelegram,
sendPollTelegram,
sendStickerTelegram,
} from "../../extensions/telegram/src/send.js";
export { getCacheStats, searchStickers } from "../../extensions/telegram/src/sticker-cache.js";
export { resolveTelegramToken } from "../../extensions/telegram/src/token.js";
export { telegramMessageActions } from "../../extensions/telegram/src/channel-actions.js";
export { collectTelegramStatusIssues } from "../../extensions/telegram/src/status-issues.js";
export { sendTelegramPayloadMessages } from "../../extensions/telegram/src/outbound-adapter.js";
export {
buildBrowseProvidersButton,
buildModelsKeyboard,
buildProviderKeyboard,
calculateTotalPages,
getModelsPageSize,
type ProviderInfo,
} from "../../extensions/telegram/src/model-buttons.js";
export {
isTelegramExecApprovalApprover,
isTelegramExecApprovalClientEnabled,
} from "../../extensions/telegram/src/exec-approvals.js";

View File

@@ -6,3 +6,4 @@ export type { ChannelAccountSnapshot, ChannelGatewayContext } from "../channels/
export type { OpenClawConfig } from "../config/config.js";
export type { PluginRuntime } from "../plugins/runtime/types.js";
export type { RuntimeEnv } from "../runtime.js";
export type { MockFn } from "../test-utils/vitest-mock-fn.js";

View File

@@ -0,0 +1,23 @@
// Public shared text/formatting helpers for plugins that parse or rewrite message text.
export * from "../logger.js";
export * from "../logging/diagnostic.js";
export * from "../logging/logger.js";
export * from "../logging/redact.js";
export * from "../logging/redact-identifier.js";
export * from "../markdown/ir.js";
export * from "../markdown/render.js";
export * from "../markdown/tables.js";
export * from "../markdown/whatsapp.js";
export * from "../shared/global-singleton.js";
export * from "../shared/string-normalization.js";
export * from "../shared/string-sample.js";
export * from "../shared/text/assistant-visible-text.js";
export * from "../shared/text/code-regions.js";
export * from "../shared/text/reasoning-tags.js";
export * from "../terminal/safe-text.js";
export * from "../utils.js";
export * from "../utils/chunk-items.js";
export * from "../utils/fetch-timeout.js";
export * from "../utils/reaction-level.js";
export * from "../utils/with-timeout.js";

View File

@@ -1,6 +1,14 @@
export type { ChannelMessageActionName } from "../channels/plugins/types.js";
export type { OpenClawConfig } from "../config/config.js";
export type { DmPolicy, GroupPolicy, WhatsAppAccountConfig } from "../config/types.js";
export type {
WebChannelStatus,
WebMonitorTuning,
} from "../../extensions/whatsapp/src/auto-reply.js";
export type {
WebInboundMessage,
WebListenerCloseReason,
} from "../../extensions/whatsapp/src/inbound.js";
export type {
ChannelMessageActionContext,
ChannelPlugin,
@@ -36,6 +44,7 @@ export {
} from "../channels/plugins/group-policy-warnings.js";
export { buildAccountScopedDmSecurityPolicy } from "../channels/plugins/helpers.js";
export { resolveWhatsAppOutboundTarget } from "../whatsapp/resolve-outbound-target.js";
export { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "../whatsapp/normalize.js";
export {
resolveAllowlistProviderRuntimeGroupPolicy,
@@ -56,3 +65,48 @@ export { WhatsAppConfigSchema } from "../config/zod-schema.providers-whatsapp.js
export { createActionGate, readStringParam } from "../agents/tools/common.js";
export { createPluginRuntimeStore } from "./runtime-store.js";
export { normalizeE164 } from "../utils.js";
export {
hasAnyWhatsAppAuth,
listEnabledWhatsAppAccounts,
resolveWhatsAppAccount,
} from "../../extensions/whatsapp/src/accounts.js";
export {
WA_WEB_AUTH_DIR,
logWebSelfId,
logoutWeb,
pickWebChannel,
webAuthExists,
} from "../../extensions/whatsapp/src/auth-store.js";
export {
DEFAULT_WEB_MEDIA_BYTES,
HEARTBEAT_PROMPT,
HEARTBEAT_TOKEN,
monitorWebChannel,
resolveHeartbeatRecipients,
runWebHeartbeatOnce,
} from "../../extensions/whatsapp/src/auto-reply.js";
export {
extractMediaPlaceholder,
extractText,
monitorWebInbox,
} from "../../extensions/whatsapp/src/inbound.js";
export { loginWeb } from "../../extensions/whatsapp/src/login.js";
export {
getDefaultLocalRoots,
loadWebMedia,
loadWebMediaRaw,
optimizeImageToJpeg,
} from "../../extensions/whatsapp/src/media.js";
export {
sendMessageWhatsApp,
sendPollWhatsApp,
sendReactionWhatsApp,
} from "../../extensions/whatsapp/src/send.js";
export {
createWaSocket,
formatError,
getStatusCode,
waitForWaConnection,
} from "../../extensions/whatsapp/src/session.js";
export { createWhatsAppLoginTool } from "../../extensions/whatsapp/src/agent-tools-login.js";

7
src/plugin-sdk/zai.ts Normal file
View File

@@ -0,0 +1,7 @@
// Public Z.ai helpers for provider plugins that need endpoint detection.
export {
detectZaiEndpoint,
type ZaiDetectedEndpoint,
type ZaiEndpointId,
} from "../commands/zai-endpoint-detect.js";