refactor(extensions): add channel-owned config schema seams

This commit is contained in:
Peter Steinberger
2026-04-04 05:30:24 +01:00
parent c17985aa9f
commit b0e1551eb8
22 changed files with 93 additions and 55 deletions

View File

@@ -0,0 +1,52 @@
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const SRC_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
const REPO_ROOT = resolve(SRC_ROOT, "..");
const BUNDLED_EXTENSION_CONFIG_IMPORT_GUARDS = [
{
path: "extensions/telegram/src/config-schema.ts",
allowedSpecifier: "../config-api.js",
},
{
path: "extensions/discord/src/config-schema.ts",
allowedSpecifier: "../config-api.js",
},
{
path: "extensions/slack/src/config-schema.ts",
allowedSpecifier: "../config-api.js",
},
{
path: "extensions/signal/src/config-schema.ts",
allowedSpecifier: "../config-api.js",
},
{
path: "extensions/imessage/src/config-schema.ts",
allowedSpecifier: "../config-api.js",
},
{
path: "extensions/whatsapp/src/config-schema.ts",
allowedSpecifier: "../config-api.js",
},
{
path: "extensions/googlechat/src/config-schema.ts",
allowedSpecifier: "openclaw/plugin-sdk/googlechat",
},
{
path: "extensions/msteams/src/config-schema.ts",
allowedSpecifier: "openclaw/plugin-sdk/msteams",
},
] as const;
describe("bundled extension config api guardrails", () => {
for (const entry of BUNDLED_EXTENSION_CONFIG_IMPORT_GUARDS) {
it(`keeps ${entry.path} off the generic concrete-schema barrel`, () => {
const source = readFileSync(resolve(REPO_ROOT, entry.path), "utf8");
expect(source).toContain(entry.allowedSpecifier);
expect(source).not.toContain("openclaw/plugin-sdk/channel-config-schema");
});
}
});

View File

@@ -30,14 +30,14 @@ const RUNTIME_API_EXPORT_GUARDS: Record<string, readonly string[]> = {
'export * from "./src/send.components.js";',
],
[bundledPluginFile("imessage", "runtime-api.ts")]: [
'export { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, getChatChannelMeta, type ChannelPlugin, type OpenClawConfig } from "openclaw/plugin-sdk/core";',
'export { DEFAULT_ACCOUNT_ID, getChatChannelMeta, type ChannelPlugin, type OpenClawConfig } from "openclaw/plugin-sdk/core";',
'export { buildChannelConfigSchema, IMessageConfigSchema } from "./config-api.js";',
'export { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";',
'export { buildComputedAccountStatusSnapshot, collectStatusIssuesFromLastError } from "openclaw/plugin-sdk/status-helpers";',
'export { formatTrimmedAllowFromEntries } from "openclaw/plugin-sdk/channel-config-helpers";',
'export { resolveIMessageConfigAllowFrom, resolveIMessageConfigDefaultTo } from "./src/config-accessors.js";',
'export { looksLikeIMessageTargetId, normalizeIMessageMessagingTarget } from "./src/normalize.js";',
'export { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/media-runtime";',
'export { IMessageConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";',
'export { resolveIMessageGroupRequireMention, resolveIMessageGroupToolPolicy } from "./src/group-policy.js";',
'export { monitorIMessageProvider } from "./src/monitor.js";',
'export type { MonitorIMessageOpts } from "./src/monitor.js";',
@@ -83,7 +83,7 @@ const RUNTIME_API_EXPORT_GUARDS: Record<string, readonly string[]> = {
'export type { AcpRuntime, AcpRuntimeCapabilities, AcpRuntimeDoctorReport, AcpRuntimeEnsureInput, AcpRuntimeEvent, AcpRuntimeHandle, AcpRuntimeStatus, AcpRuntimeTurnInput, AcpRuntimeErrorCode, AcpSessionUpdateTag } from "openclaw/plugin-sdk/acp-runtime";',
'export { AcpRuntimeError } from "openclaw/plugin-sdk/acp-runtime";',
'export { clearAccountEntryFields, emptyPluginConfigSchema, formatPairingApproveHint, getChatChannelMeta } from "openclaw/plugin-sdk/core";',
'export { buildChannelConfigSchema, TelegramConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";',
'export { buildChannelConfigSchema, TelegramConfigSchema } from "./config-api.js";',
'export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";',
'export { PAIRING_APPROVED_MESSAGE, buildTokenChannelStatusSummary, projectCredentialSnapshotFields, resolveConfiguredFromCredentialStatuses } from "openclaw/plugin-sdk/channel-status";',
'export { jsonResult, readNumberParam, readReactionParams, readStringArrayParam, readStringOrNumberParam, readStringParam, resolvePollMaxSelections } from "openclaw/plugin-sdk/channel-actions";',