refactor: migrate extensions to plugin sdk

This commit is contained in:
Peter Steinberger
2026-01-18 02:51:42 +00:00
parent 5b4651d9ed
commit 1420d113d8
95 changed files with 380 additions and 208 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+76 -1
View File
@@ -53,6 +53,76 @@ export type {
ChannelToolSend,
} from "../channels/plugins/types.js";
export type { ChannelConfigSchema, ChannelPlugin } from "../channels/plugins/types.plugin.js";
export type { ClawdbotPluginApi } from "../plugins/types.js";
export type { ClawdbotConfig } from "../config/config.js";
export type { ChannelDock } from "../channels/dock.js";
export type {
DmPolicy,
GroupPolicy,
MSTeamsChannelConfig,
MSTeamsConfig,
MSTeamsReplyStyle,
MSTeamsTeamConfig,
} from "../config/types.js";
export { MSTeamsConfigSchema } from "../config/zod-schema.providers-core.js";
export type { RuntimeEnv } from "../runtime.js";
export type { WizardPrompter } from "../wizard/prompts.js";
export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export type { ReplyPayload } from "../auto-reply/types.js";
export { SILENT_REPLY_TOKEN, isSilentReplyText } from "../auto-reply/tokens.js";
export { chunkMarkdownText, resolveTextChunkLimit } from "../auto-reply/chunk.js";
export {
hasControlCommand,
isControlCommandMessage,
shouldComputeCommandAuthorized,
} from "../auto-reply/command-detection.js";
export { shouldHandleTextCommands } from "../auto-reply/commands-registry.js";
export { formatAgentEnvelope } from "../auto-reply/envelope.js";
export {
createInboundDebouncer,
resolveInboundDebounceMs,
} from "../auto-reply/inbound-debounce.js";
export { dispatchReplyFromConfig } from "../auto-reply/reply/dispatch-from-config.js";
export { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js";
export {
buildPendingHistoryContextFromMap,
clearHistoryEntries,
DEFAULT_GROUP_HISTORY_LIMIT,
recordPendingHistoryEntry,
} from "../auto-reply/reply/history.js";
export type { HistoryEntry } from "../auto-reply/reply/history.js";
export { buildMentionRegexes, matchesMentionPatterns } from "../auto-reply/reply/mentions.js";
export { createReplyDispatcherWithTyping } from "../auto-reply/reply/reply-dispatcher.js";
export { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../agents/identity.js";
export { mergeAllowlist, summarizeMapping } from "../channels/allowlists/resolve-utils.js";
export { resolveCommandAuthorizedFromAuthorizers } from "../channels/command-gating.js";
export { resolveMentionGating } from "../channels/mention-gating.js";
export {
buildChannelKeyCandidates,
normalizeChannelSlug,
resolveChannelEntryMatch,
resolveChannelEntryMatchWithFallback,
resolveNestedAllowlistDecision,
} from "../channels/plugins/channel-config.js";
export type { AllowlistMatch } from "../channels/plugins/allowlist-match.js";
export { formatAllowlistMatchMeta } from "../channels/plugins/allowlist-match.js";
export { readChannelAllowFromStore, upsertChannelPairingRequest } from "../pairing/pairing-store.js";
export { resolveAgentRoute } from "../routing/resolve-route.js";
export { recordSessionMetaFromInbound, resolveStorePath, updateLastRoute } from "../config/sessions.js";
export { resolveStateDir } from "../config/paths.js";
export { loadConfig } from "../config/config.js";
export { danger } from "../globals.js";
export { logVerbose, shouldLogVerbose } from "../globals.js";
export { getChildLogger } from "../logging.js";
export { enqueueSystemEvent } from "../infra/system-events.js";
export { runCommandWithTimeout } from "../process/exec.js";
export { loadWebMedia } from "../web/media.js";
export { isVoiceCompatibleAudio } from "../media/audio.js";
export { mediaKindFromMime } from "../media/constants.js";
export { detectMime } from "../media/mime.js";
export { getImageMetadata, resizeToJpeg } from "../media/image-ops.js";
export { saveMediaBuffer } from "../media/store.js";
export type { PollInput } from "../polls.js";
export { buildChannelConfigSchema } from "../channels/plugins/config-schema.js";
export {
@@ -63,7 +133,10 @@ export { applyAccountNameToChannelSection } from "../channels/plugins/setup-help
export { formatPairingApproveHint } from "../channels/plugins/helpers.js";
export { PAIRING_APPROVED_MESSAGE } from "../channels/plugins/pairing-message.js";
export type { ChannelOnboardingAdapter } from "../channels/plugins/onboarding-types.js";
export type {
ChannelOnboardingAdapter,
ChannelOnboardingDmPolicy,
} from "../channels/plugins/onboarding-types.js";
export { addWildcardAllowFrom } from "../channels/plugins/onboarding/helpers.js";
export { promptChannelAccessConfig } from "../channels/plugins/onboarding/channel-access.js";
@@ -74,5 +147,7 @@ export {
readReactionParams,
readStringParam,
} from "../agents/tools/common.js";
export { createMemoryGetTool, createMemorySearchTool } from "../agents/tools/memory-tool.js";
export { registerMemoryCli } from "../cli/memory-cli.js";
export { formatDocsLink } from "../terminal/links.js";
+23
View File
@@ -1,3 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { createJiti } from "jiti";
import type { ClawdbotConfig } from "../config/config.js";
@@ -92,6 +95,24 @@ const normalizePluginsConfig = (config?: ClawdbotConfig["plugins"]): NormalizedP
};
};
const resolvePluginSdkAlias = (): string | null => {
try {
let cursor = path.dirname(fileURLToPath(import.meta.url));
for (let i = 0; i < 6; i += 1) {
const distCandidate = path.join(cursor, "dist", "plugin-sdk", "index.js");
if (fs.existsSync(distCandidate)) return distCandidate;
const srcCandidate = path.join(cursor, "src", "plugin-sdk", "index.ts");
if (fs.existsSync(srcCandidate)) return srcCandidate;
const parent = path.dirname(cursor);
if (parent === cursor) break;
cursor = parent;
}
} catch {
// ignore
}
return null;
};
function buildCacheKey(params: {
workspaceDir?: string;
plugins: NormalizedPluginsConfig;
@@ -289,8 +310,10 @@ export function loadClawdbotPlugins(options: PluginLoadOptions = {}): PluginRegi
});
pushDiagnostics(registry.diagnostics, discovery.diagnostics);
const pluginSdkAlias = resolvePluginSdkAlias();
const jiti = createJiti(import.meta.url, {
interopDefault: true,
...(pluginSdkAlias ? { alias: { "clawdbot/plugin-sdk": pluginSdkAlias } } : {}),
});
const seenIds = new Map<string, PluginRecord["origin"]>();
+3
View File
@@ -6,6 +6,7 @@ import { createInboundDebouncer, resolveInboundDebounceMs } from "../../auto-rep
import { buildMentionRegexes, matchesMentionPatterns } from "../../auto-reply/reply/mentions.js";
import { dispatchReplyWithBufferedBlockDispatcher } from "../../auto-reply/reply/provider-dispatcher.js";
import { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-dispatcher.js";
import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js";
import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js";
import { resolveChannelGroupPolicy, resolveChannelGroupRequireMention } from "../../config/group-policy.js";
import { resolveStateDir } from "../../config/paths.js";
@@ -46,6 +47,8 @@ export function createPluginRuntime(): PluginRuntime {
reply: {
dispatchReplyWithBufferedBlockDispatcher,
createReplyDispatcherWithTyping,
resolveEffectiveMessagesConfig,
resolveHumanDelayConfig,
},
routing: {
resolveAgentRoute,
+9
View File
@@ -25,6 +25,15 @@ export type PluginRuntime = {
};
}) => Promise<void>;
createReplyDispatcherWithTyping: (...args: unknown[]) => unknown;
resolveEffectiveMessagesConfig: (
cfg: ClawdbotConfig,
agentId: string,
opts?: { hasAllowFrom?: boolean; fallbackMessagePrefix?: string },
) => { messagePrefix: string; responsePrefix?: string };
resolveHumanDelayConfig: (
cfg: ClawdbotConfig,
agentId: string,
) => { mode?: string; minMs?: number; maxMs?: number } | undefined;
};
routing: {
resolveAgentRoute: (params: {
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.