mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 05:50:47 +00:00
refactor: enforce plugin boundary seams
This commit is contained in:
@@ -6,8 +6,8 @@ import {
|
||||
readNumberParam,
|
||||
readStringArrayParam,
|
||||
readStringParam,
|
||||
} from "../../../../src/agents/tools/common.js";
|
||||
import type { DiscordActionConfig } from "../../../../src/config/types.discord.js";
|
||||
type DiscordActionConfig,
|
||||
} from "openclaw/plugin-sdk/discord-core";
|
||||
import { getPresence } from "../monitor/presence-cache.js";
|
||||
import {
|
||||
addRoleDiscord,
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
|
||||
import { withNormalizedTimestamp } from "../../../../src/agents/date-time.js";
|
||||
import { assertMediaNotDataUrl } from "../../../../src/agents/sandbox-paths.js";
|
||||
import {
|
||||
type ActionGate,
|
||||
assertMediaNotDataUrl,
|
||||
jsonResult,
|
||||
readNumberParam,
|
||||
readReactionParams,
|
||||
readStringArrayParam,
|
||||
readStringParam,
|
||||
} from "../../../../src/agents/tools/common.js";
|
||||
import type { OpenClawConfig } from "../../../../src/config/config.js";
|
||||
import type { DiscordActionConfig } from "../../../../src/config/types.discord.js";
|
||||
import { resolvePollMaxSelections } from "../../../../src/polls.js";
|
||||
resolvePollMaxSelections,
|
||||
type DiscordActionConfig,
|
||||
type OpenClawConfig,
|
||||
withNormalizedTimestamp,
|
||||
} from "openclaw/plugin-sdk/discord-core";
|
||||
import { readDiscordComponentSpec } from "../components.js";
|
||||
import {
|
||||
createThreadDiscord,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PermissionFlagsBits } from "discord-api-types/v10";
|
||||
import { readNumberParam, readStringParam } from "../../../../src/agents/tools/common.js";
|
||||
import { readNumberParam, readStringParam } from "openclaw/plugin-sdk/discord-core";
|
||||
|
||||
export type DiscordModerationAction = "timeout" | "kick" | "ban";
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
type ActionGate,
|
||||
jsonResult,
|
||||
readStringParam,
|
||||
} from "../../../../src/agents/tools/common.js";
|
||||
import type { DiscordActionConfig } from "../../../../src/config/types.discord.js";
|
||||
type DiscordActionConfig,
|
||||
} from "openclaw/plugin-sdk/discord-core";
|
||||
import {
|
||||
banMemberDiscord,
|
||||
hasAnyGuildPermissionDiscord,
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
type ActionGate,
|
||||
jsonResult,
|
||||
readStringParam,
|
||||
} from "../../../../src/agents/tools/common.js";
|
||||
import type { DiscordActionConfig } from "../../../../src/config/types.discord.js";
|
||||
type DiscordActionConfig,
|
||||
} from "openclaw/plugin-sdk/discord-core";
|
||||
import { getGateway } from "../monitor/gateway-registry.js";
|
||||
|
||||
const ACTIVITY_TYPE_MAP: Record<string, number> = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { readStringParam } from "../../../../src/agents/tools/common.js";
|
||||
import { readStringParam } from "openclaw/plugin-sdk/discord-core";
|
||||
|
||||
export function readDiscordParentIdParam(
|
||||
params: Record<string, unknown>,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { readStringParam } from "../../../../src/agents/tools/common.js";
|
||||
import type { OpenClawConfig } from "../../../../src/config/config.js";
|
||||
import { readStringParam, type OpenClawConfig } from "openclaw/plugin-sdk/discord-core";
|
||||
import { createDiscordActionGate } from "../accounts.js";
|
||||
import { handleDiscordGuildAction } from "./runtime.guild.js";
|
||||
import { handleDiscordMessagingAction } from "./runtime.messaging.js";
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from "openclaw/plugin-sdk/line";
|
||||
export * from "./src/setup-core.js";
|
||||
export * from "./src/setup-surface.js";
|
||||
export * from "./setup-api.js";
|
||||
|
||||
2
extensions/line/setup-api.ts
Normal file
2
extensions/line/setup-api.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { lineSetupAdapter } from "./src/setup-core.js";
|
||||
export { lineSetupWizard } from "./src/setup-surface.js";
|
||||
@@ -1,7 +1,11 @@
|
||||
import type { ChannelSetupAdapter, OpenClawConfig } from "openclaw/plugin-sdk/setup";
|
||||
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/setup";
|
||||
import { normalizeAccountId, resolveLineAccount } from "../../../src/line/accounts.js";
|
||||
import type { LineConfig } from "../../../src/line/types.js";
|
||||
import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
normalizeAccountId,
|
||||
resolveLineAccount,
|
||||
type ChannelSetupAdapter,
|
||||
type LineConfig,
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/line-core";
|
||||
|
||||
const channel = "line" as const;
|
||||
|
||||
@@ -154,4 +158,4 @@ export const lineSetupAdapter: ChannelSetupAdapter = {
|
||||
},
|
||||
};
|
||||
|
||||
export { listLineAccountIds } from "../../../src/line/accounts.js";
|
||||
export { listLineAccountIds } from "openclaw/plugin-sdk/line-core";
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
formatDocsLink,
|
||||
resolveLineAccount,
|
||||
setSetupChannelEnabled,
|
||||
setTopLevelChannelDmPolicyWithAllowFrom,
|
||||
splitSetupEntries,
|
||||
type ChannelSetupDmPolicy,
|
||||
type ChannelSetupWizard,
|
||||
} from "openclaw/plugin-sdk/setup";
|
||||
import { resolveLineAccount } from "../../../src/line/accounts.js";
|
||||
} from "openclaw/plugin-sdk/line-core";
|
||||
import {
|
||||
isLineConfigured,
|
||||
listLineAccountIds,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "openclaw/plugin-sdk/nostr";
|
||||
export * from "./src/setup-surface.js";
|
||||
export * from "./setup-api.js";
|
||||
|
||||
1
extensions/nostr/setup-api.ts
Normal file
1
extensions/nostr/setup-api.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { nostrSetupAdapter, nostrSetupWizard } from "./src/setup-surface.js";
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { withNormalizedTimestamp } from "../../../src/agents/date-time.js";
|
||||
import {
|
||||
createActionGate,
|
||||
imageResultFromFile,
|
||||
@@ -7,8 +6,9 @@ import {
|
||||
readNumberParam,
|
||||
readReactionParams,
|
||||
readStringParam,
|
||||
} from "../../../src/agents/tools/common.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
type OpenClawConfig,
|
||||
withNormalizedTimestamp,
|
||||
} from "openclaw/plugin-sdk/slack-core";
|
||||
import { resolveSlackAccount } from "./accounts.js";
|
||||
import {
|
||||
deleteSlackMessage,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "openclaw/plugin-sdk/synology-chat";
|
||||
export * from "./src/setup-surface.js";
|
||||
export * from "./setup-api.js";
|
||||
|
||||
1
extensions/synology-chat/setup-api.ts
Normal file
1
extensions/synology-chat/setup-api.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { synologyChatSetupAdapter, synologyChatSetupWizard } from "./src/setup-surface.js";
|
||||
@@ -7,10 +7,10 @@ import {
|
||||
readStringArrayParam,
|
||||
readStringOrNumberParam,
|
||||
readStringParam,
|
||||
} from "../../../src/agents/tools/common.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import type { TelegramActionConfig } from "../../../src/config/types.telegram.js";
|
||||
import { resolvePollMaxSelections } from "../../../src/polls.js";
|
||||
resolvePollMaxSelections,
|
||||
type OpenClawConfig,
|
||||
type TelegramActionConfig,
|
||||
} from "openclaw/plugin-sdk/telegram-core";
|
||||
import { createTelegramActionGate, resolveTelegramPollActionGateState } from "./accounts.js";
|
||||
import type { TelegramButtonStyle, TelegramInlineButtons } from "./button-types.js";
|
||||
import {
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from "openclaw/plugin-sdk/tlon";
|
||||
export * from "./src/setup-core.js";
|
||||
export * from "./src/setup-surface.js";
|
||||
export * from "./setup-api.js";
|
||||
|
||||
2
extensions/tlon/setup-api.ts
Normal file
2
extensions/tlon/setup-api.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { tlonSetupAdapter } from "./src/setup-core.js";
|
||||
export { tlonSetupWizard } from "./src/setup-surface.js";
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ToolAuthorizationError } from "../../../src/agents/tools/common.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import { resolveWhatsAppOutboundTarget } from "../../../src/whatsapp/resolve-outbound-target.js";
|
||||
import {
|
||||
ToolAuthorizationError,
|
||||
resolveWhatsAppOutboundTarget,
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/whatsapp-core";
|
||||
import { resolveWhatsAppAccount } from "./accounts.js";
|
||||
|
||||
export function resolveAuthorizedWhatsAppOutboundTarget(params: {
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
jsonResult,
|
||||
readReactionParams,
|
||||
readStringParam,
|
||||
} from "../../../src/agents/tools/common.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/whatsapp-core";
|
||||
import { resolveAuthorizedWhatsAppOutboundTarget } from "./action-runtime-target-auth.js";
|
||||
import { sendReactionWhatsApp } from "./send.js";
|
||||
|
||||
|
||||
@@ -210,6 +210,10 @@
|
||||
"types": "./dist/plugin-sdk/line.d.ts",
|
||||
"default": "./dist/plugin-sdk/line.js"
|
||||
},
|
||||
"./plugin-sdk/line-core": {
|
||||
"types": "./dist/plugin-sdk/line-core.d.ts",
|
||||
"default": "./dist/plugin-sdk/line-core.js"
|
||||
},
|
||||
"./plugin-sdk/msteams": {
|
||||
"types": "./dist/plugin-sdk/msteams.d.ts",
|
||||
"default": "./dist/plugin-sdk/msteams.js"
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
"whatsapp",
|
||||
"whatsapp-core",
|
||||
"line",
|
||||
"line-core",
|
||||
"msteams",
|
||||
"acpx",
|
||||
"bluebubbles",
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
createThreadBindingManager as createDiscordThreadBindingManager,
|
||||
} from "../../../../extensions/discord/runtime-api.js";
|
||||
import { createFeishuThreadBindingManager } from "../../../../extensions/feishu/api.js";
|
||||
import { setMatrixRuntime } from "../../../../extensions/matrix/src/runtime.js";
|
||||
import { setMatrixRuntime } from "../../../../extensions/matrix/index.js";
|
||||
import { createTelegramThreadBindingManager } from "../../../../extensions/telegram/runtime-api.js";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import {
|
||||
|
||||
@@ -5,10 +5,12 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
const ROOT_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const ALLOWED_EXTENSION_PUBLIC_SEAMS = new Set([
|
||||
"action-runtime.runtime.js",
|
||||
"api.js",
|
||||
"index.js",
|
||||
"login-qr-api.js",
|
||||
"runtime-api.js",
|
||||
"setup-api.js",
|
||||
"setup-entry.js",
|
||||
]);
|
||||
const GUARDED_CHANNEL_EXTENSIONS = new Set([
|
||||
@@ -328,6 +330,15 @@ describe("channel import guardrails", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps extension production files off direct core src imports", () => {
|
||||
for (const file of collectExtensionSourceFiles()) {
|
||||
const text = readFileSync(file, "utf8");
|
||||
expect(text, `${file} should not import ../../src/* core internals directly`).not.toMatch(
|
||||
/["'][^"']*(?:\.\.\/){2,}src\//,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps core production files off extension private src imports", () => {
|
||||
for (const file of collectCoreSourceFiles()) {
|
||||
const text = readFileSync(file, "utf8");
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
export type { ChannelPlugin } from "./channel-plugin-common.js";
|
||||
export { buildChannelConfigSchema, getChatChannelMeta } from "./channel-plugin-common.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export type { DiscordActionConfig } from "../config/types.js";
|
||||
export { withNormalizedTimestamp } from "../agents/date-time.js";
|
||||
export { assertMediaNotDataUrl } from "../agents/sandbox-paths.js";
|
||||
export {
|
||||
type ActionGate,
|
||||
jsonResult,
|
||||
parseAvailableTags,
|
||||
readNumberParam,
|
||||
readReactionParams,
|
||||
readStringArrayParam,
|
||||
readStringParam,
|
||||
} from "../agents/tools/common.js";
|
||||
export { DiscordConfigSchema } from "../config/zod-schema.providers-core.js";
|
||||
export { resolvePollMaxSelections } from "../polls.js";
|
||||
|
||||
16
src/plugin-sdk/line-core.ts
Normal file
16
src/plugin-sdk/line-core.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export type { LineConfig } from "../line/types.js";
|
||||
export {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
formatDocsLink,
|
||||
normalizeAccountId,
|
||||
setSetupChannelEnabled,
|
||||
setTopLevelChannelDmPolicyWithAllowFrom,
|
||||
splitSetupEntries,
|
||||
} from "./setup.js";
|
||||
export type { ChannelSetupAdapter, ChannelSetupDmPolicy, ChannelSetupWizard } from "./setup.js";
|
||||
export {
|
||||
listLineAccountIds,
|
||||
resolveDefaultLineAccountId,
|
||||
resolveLineAccount,
|
||||
} from "../line/accounts.js";
|
||||
@@ -32,8 +32,7 @@ export {
|
||||
resolveDefaultLineAccountId,
|
||||
resolveLineAccount,
|
||||
} from "../line/accounts.js";
|
||||
export { lineSetupAdapter } from "../../extensions/line/src/setup-core.js";
|
||||
export { lineSetupWizard } from "../../extensions/line/src/setup-surface.js";
|
||||
export { lineSetupAdapter, lineSetupWizard } from "../../extensions/line/setup-api.js";
|
||||
export { LineConfigSchema } from "../line/config-schema.js";
|
||||
export type { LineChannelData, LineConfig, ResolvedLineAccount } from "../line/types.js";
|
||||
export {
|
||||
|
||||
@@ -19,4 +19,4 @@ export {
|
||||
} from "./status-helpers.js";
|
||||
export { createFixedWindowRateLimiter } from "./webhook-memory-guards.js";
|
||||
export { mapAllowFromEntries } from "./channel-config-helpers.js";
|
||||
export { nostrSetupAdapter, nostrSetupWizard } from "../../extensions/nostr/src/setup-surface.js";
|
||||
export { nostrSetupAdapter, nostrSetupWizard } from "../../extensions/nostr/setup-api.js";
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export type { ChannelPlugin } from "./channel-plugin-common.js";
|
||||
export { buildChannelConfigSchema, getChatChannelMeta } from "./channel-plugin-common.js";
|
||||
export { withNormalizedTimestamp } from "../agents/date-time.js";
|
||||
export {
|
||||
createActionGate,
|
||||
imageResultFromFile,
|
||||
jsonResult,
|
||||
readNumberParam,
|
||||
readReactionParams,
|
||||
readStringParam,
|
||||
} from "../agents/tools/common.js";
|
||||
export { SlackConfigSchema } from "../config/zod-schema.providers-core.js";
|
||||
|
||||
@@ -20,4 +20,4 @@ export { createFixedWindowRateLimiter } from "./webhook-memory-guards.js";
|
||||
export {
|
||||
synologyChatSetupAdapter,
|
||||
synologyChatSetupWizard,
|
||||
} from "../../extensions/synology-chat/src/setup-surface.js";
|
||||
} from "../../extensions/synology-chat/setup-api.js";
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export type { TelegramActionConfig } from "../config/types.js";
|
||||
export type { ChannelPlugin } from "./channel-plugin-common.js";
|
||||
export { buildChannelConfigSchema, getChatChannelMeta } from "./channel-plugin-common.js";
|
||||
export { normalizeAccountId } from "../routing/session-key.js";
|
||||
export {
|
||||
jsonResult,
|
||||
readNumberParam,
|
||||
readReactionParams,
|
||||
readStringArrayParam,
|
||||
readStringOrNumberParam,
|
||||
readStringParam,
|
||||
} from "../agents/tools/common.js";
|
||||
export { TelegramConfigSchema } from "../config/zod-schema.providers-core.js";
|
||||
export { resolvePollMaxSelections } from "../polls.js";
|
||||
|
||||
@@ -27,5 +27,4 @@ export type { RuntimeEnv } from "../runtime.js";
|
||||
export { formatDocsLink } from "../terminal/links.js";
|
||||
export type { WizardPrompter } from "../wizard/prompts.js";
|
||||
export { createLoggerBackedRuntime } from "./runtime.js";
|
||||
export { tlonSetupAdapter } from "../../extensions/tlon/src/setup-core.js";
|
||||
export { tlonSetupWizard } from "../../extensions/tlon/src/setup-surface.js";
|
||||
export { tlonSetupAdapter, tlonSetupWizard } from "../../extensions/tlon/setup-api.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export type { ChannelPlugin } from "./channel-plugin-common.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
buildChannelConfigSchema,
|
||||
@@ -14,5 +15,13 @@ export {
|
||||
resolveWhatsAppGroupToolPolicy,
|
||||
} from "../channels/plugins/group-mentions.js";
|
||||
export { resolveWhatsAppGroupIntroHint } from "../channels/plugins/whatsapp-shared.js";
|
||||
export {
|
||||
ToolAuthorizationError,
|
||||
createActionGate,
|
||||
jsonResult,
|
||||
readReactionParams,
|
||||
readStringParam,
|
||||
} from "../agents/tools/common.js";
|
||||
export { WhatsAppConfigSchema } from "../config/zod-schema.providers-whatsapp.js";
|
||||
export { normalizeE164 } from "../utils.js";
|
||||
export { resolveWhatsAppOutboundTarget } from "../whatsapp/resolve-outbound-target.js";
|
||||
|
||||
Reference in New Issue
Block a user