mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-20 05:31:30 +00:00
refactor(extensions): add channel-owned config schema seams
This commit is contained in:
4
extensions/discord/config-api.ts
Normal file
4
extensions/discord/config-api.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
buildChannelConfigSchema,
|
||||
DiscordConfigSchema,
|
||||
} from "openclaw/plugin-sdk/channel-config-schema";
|
||||
@@ -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, {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
4
extensions/imessage/config-api.ts
Normal file
4
extensions/imessage/config-api.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
buildChannelConfigSchema,
|
||||
IMessageConfigSchema,
|
||||
} from "openclaw/plugin-sdk/channel-config-schema";
|
||||
@@ -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,
|
||||
|
||||
@@ -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, {
|
||||
|
||||
@@ -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, {
|
||||
|
||||
4
extensions/signal/config-api.ts
Normal file
4
extensions/signal/config-api.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
buildChannelConfigSchema,
|
||||
SignalConfigSchema,
|
||||
} from "openclaw/plugin-sdk/channel-config-schema";
|
||||
@@ -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, {
|
||||
|
||||
@@ -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,
|
||||
|
||||
4
extensions/slack/config-api.ts
Normal file
4
extensions/slack/config-api.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
buildChannelConfigSchema,
|
||||
SlackConfigSchema,
|
||||
} from "openclaw/plugin-sdk/channel-config-schema";
|
||||
@@ -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, {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
4
extensions/telegram/config-api.ts
Normal file
4
extensions/telegram/config-api.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
buildChannelConfigSchema,
|
||||
TelegramConfigSchema,
|
||||
} from "openclaw/plugin-sdk/channel-config-schema";
|
||||
@@ -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,
|
||||
|
||||
@@ -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, {
|
||||
|
||||
4
extensions/whatsapp/config-api.ts
Normal file
4
extensions/whatsapp/config-api.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
buildChannelConfigSchema,
|
||||
WhatsAppConfigSchema,
|
||||
} from "openclaw/plugin-sdk/channel-config-schema";
|
||||
@@ -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, {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -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";',
|
||||
|
||||
Reference in New Issue
Block a user