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,4 @@
export {
buildChannelConfigSchema,
DiscordConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";

View File

@@ -1,7 +1,4 @@
import {
buildChannelConfigSchema,
DiscordConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, DiscordConfigSchema } from "../config-api.js";
import { discordChannelConfigUiHints } from "./config-ui-hints.js";
export const DiscordChannelConfigSchema = buildChannelConfigSchema(DiscordConfigSchema, {

View File

@@ -5,10 +5,7 @@ export {
projectCredentialSnapshotFields,
resolveConfiguredFromCredentialStatuses,
} from "openclaw/plugin-sdk/channel-status";
export {
buildChannelConfigSchema,
DiscordConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
export { buildChannelConfigSchema, DiscordConfigSchema } from "../config-api.js";
export type {
ChannelMessageActionAdapter,
ChannelMessageActionContext,

View File

@@ -1,6 +1,3 @@
import {
buildChannelConfigSchema,
GoogleChatConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, GoogleChatConfigSchema } from "openclaw/plugin-sdk/googlechat";
export const GoogleChatChannelConfigSchema = buildChannelConfigSchema(GoogleChatConfigSchema);

View File

@@ -0,0 +1,4 @@
export {
buildChannelConfigSchema,
IMessageConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";

View File

@@ -2,11 +2,11 @@ import type { OpenClawConfig as RuntimeApiOpenClawConfig } from "openclaw/plugin
export {
DEFAULT_ACCOUNT_ID,
buildChannelConfigSchema,
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,
@@ -19,7 +19,6 @@ export {
} 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,

View File

@@ -1,7 +1,4 @@
import {
buildChannelConfigSchema,
IMessageConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, IMessageConfigSchema } from "../config-api.js";
import { iMessageChannelConfigUiHints } from "./config-ui-hints.js";
export const IMessageChannelConfigSchema = buildChannelConfigSchema(IMessageConfigSchema, {

View File

@@ -1,7 +1,4 @@
import {
buildChannelConfigSchema,
MSTeamsConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, MSTeamsConfigSchema } from "openclaw/plugin-sdk/msteams";
import { msTeamsChannelConfigUiHints } from "./config-ui-hints.js";
export const MSTeamsChannelConfigSchema = buildChannelConfigSchema(MSTeamsConfigSchema, {

View File

@@ -0,0 +1,4 @@
export {
buildChannelConfigSchema,
SignalConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";

View File

@@ -1,7 +1,4 @@
import {
buildChannelConfigSchema,
SignalConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, SignalConfigSchema } from "../config-api.js";
import { signalChannelConfigUiHints } from "./config-ui-hints.js";
export const SignalChannelConfigSchema = buildChannelConfigSchema(SignalConfigSchema, {

View File

@@ -2,7 +2,7 @@
// Prefer narrower SDK subpaths plus local extension seams over the legacy signal barrel.
export type { ChannelMessageActionAdapter } from "openclaw/plugin-sdk/channel-contract";
export { SignalConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
export { buildChannelConfigSchema, SignalConfigSchema } from "../config-api.js";
export { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
import type { OpenClawConfig as RuntimeOpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
export type { RuntimeOpenClawConfig as OpenClawConfig };
@@ -11,7 +11,6 @@ export type { ChannelPlugin } from "openclaw/plugin-sdk/core";
export {
DEFAULT_ACCOUNT_ID,
applyAccountNameToChannelSection,
buildChannelConfigSchema,
deleteAccountFromConfigSection,
emptyPluginConfigSchema,
formatPairingApproveHint,

View File

@@ -0,0 +1,4 @@
export {
buildChannelConfigSchema,
SlackConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";

View File

@@ -1,7 +1,4 @@
import {
buildChannelConfigSchema,
SlackConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, SlackConfigSchema } from "../config-api.js";
import { slackChannelConfigUiHints } from "./config-ui-hints.js";
export const SlackChannelConfigSchema = buildChannelConfigSchema(SlackConfigSchema, {

View File

@@ -4,10 +4,7 @@ export {
projectCredentialSnapshotFields,
resolveConfiguredFromRequiredCredentialStatuses,
} from "openclaw/plugin-sdk/channel-status";
export {
buildChannelConfigSchema,
SlackConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
export { buildChannelConfigSchema, SlackConfigSchema } from "../config-api.js";
export type { ChannelMessageActionContext } from "openclaw/plugin-sdk/channel-contract";
export { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
export type {

View File

@@ -0,0 +1,4 @@
export {
buildChannelConfigSchema,
TelegramConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";

View File

@@ -27,10 +27,7 @@ export {
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,

View File

@@ -1,7 +1,4 @@
import {
buildChannelConfigSchema,
TelegramConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, TelegramConfigSchema } from "../config-api.js";
import { telegramChannelConfigUiHints } from "./config-ui-hints.js";
export const TelegramChannelConfigSchema = buildChannelConfigSchema(TelegramConfigSchema, {

View File

@@ -0,0 +1,4 @@
export {
buildChannelConfigSchema,
WhatsAppConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";

View File

@@ -1,7 +1,4 @@
import {
buildChannelConfigSchema,
WhatsAppConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
import { buildChannelConfigSchema, WhatsAppConfigSchema } from "../config-api.js";
import { whatsAppChannelConfigUiHints } from "./config-ui-hints.js";
export const WhatsAppChannelConfigSchema = buildChannelConfigSchema(WhatsAppConfigSchema, {

View File

@@ -1,8 +1,5 @@
export { getChatChannelMeta, type ChannelPlugin } from "openclaw/plugin-sdk/core";
export {
buildChannelConfigSchema,
WhatsAppConfigSchema,
} from "openclaw/plugin-sdk/channel-config-schema";
export { buildChannelConfigSchema, WhatsAppConfigSchema } from "../config-api.js";
export { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
export {
formatWhatsAppConfigAllowFromEntries,

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";',