mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:00:54 +00:00
perf: decouple plugin facades from extension types
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { resolveRelativeBundledPluginPublicModuleId } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
|
||||
type IMessageContractSurface = typeof import("@openclaw/imessage/contract-api.js");
|
||||
type IMessageContractSurface = {
|
||||
DEFAULT_IMESSAGE_ATTACHMENT_ROOTS: string[];
|
||||
resolveIMessageAttachmentRoots: (params: unknown) => string[];
|
||||
resolveIMessageRemoteAttachmentRoots: (params: unknown) => string[];
|
||||
};
|
||||
|
||||
const {
|
||||
DEFAULT_IMESSAGE_ATTACHMENT_ROOTS,
|
||||
|
||||
@@ -3,11 +3,14 @@ import {
|
||||
loadBundledPluginContractApiSync,
|
||||
} from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
|
||||
type TelegramContractSurface = typeof import("@openclaw/telegram/contract-api.js");
|
||||
type WhatsAppApiSurface = Pick<
|
||||
typeof import("@openclaw/whatsapp/api.js"),
|
||||
"isWhatsAppGroupJid" | "normalizeWhatsAppTarget" | "whatsappCommandPolicy"
|
||||
>;
|
||||
type TelegramContractSurface = {
|
||||
buildTelegramModelsProviderChannelData: (...args: unknown[]) => unknown;
|
||||
};
|
||||
type WhatsAppApiSurface = {
|
||||
isWhatsAppGroupJid: (...args: unknown[]) => boolean;
|
||||
normalizeWhatsAppTarget: (...args: unknown[]) => string | null;
|
||||
whatsappCommandPolicy: Record<string, unknown>;
|
||||
};
|
||||
|
||||
let telegramContractSurface: TelegramContractSurface | undefined;
|
||||
let whatsappApiSurface: WhatsAppApiSurface | undefined;
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import type { SignalSender } from "@openclaw/signal/contract-api.js";
|
||||
import { resolveRelativeBundledPluginPublicModuleId } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
|
||||
type SignalContractApiSurface = Pick<
|
||||
typeof import("@openclaw/signal/contract-api.js"),
|
||||
"isSignalSenderAllowed"
|
||||
>;
|
||||
export type SignalSender = {
|
||||
kind: string;
|
||||
raw: string;
|
||||
e164?: string;
|
||||
uuid?: string;
|
||||
username?: string;
|
||||
};
|
||||
|
||||
type SignalContractApiSurface = {
|
||||
isSignalSenderAllowed: (...args: unknown[]) => boolean;
|
||||
};
|
||||
|
||||
let signalContractSurface: Promise<SignalContractApiSurface> | undefined;
|
||||
|
||||
@@ -18,4 +24,3 @@ export function getSignalContractSurface(): Promise<SignalContractApiSurface> {
|
||||
) as Promise<SignalContractApiSurface>;
|
||||
return signalContractSurface;
|
||||
}
|
||||
export type { SignalSender };
|
||||
|
||||
@@ -5,7 +5,21 @@ import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import { resolveRelativeBundledPluginPublicModuleId } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
import { withTempHome } from "../temp-home.js";
|
||||
|
||||
type ResolvedSlackAccount = import("@openclaw/slack/api.js").ResolvedSlackAccount;
|
||||
type ResolvedSlackAccount = {
|
||||
accountId: string;
|
||||
enabled: boolean;
|
||||
botTokenSource: string;
|
||||
appTokenSource: string;
|
||||
userTokenSource: string;
|
||||
config: {
|
||||
replyToMode?: unknown;
|
||||
replyToModeByChatType?: unknown;
|
||||
dm?: unknown;
|
||||
};
|
||||
replyToMode?: unknown;
|
||||
replyToModeByChatType?: unknown;
|
||||
dm?: unknown;
|
||||
};
|
||||
|
||||
type SlackMessageEvent = {
|
||||
channel: string;
|
||||
|
||||
@@ -1,12 +1,78 @@
|
||||
export type {
|
||||
DiscordInteractiveHandlerContext,
|
||||
DiscordInteractiveHandlerRegistration,
|
||||
} from "@openclaw/discord/contract-api.js";
|
||||
export type {
|
||||
SlackInteractiveHandlerContext,
|
||||
SlackInteractiveHandlerRegistration,
|
||||
} from "@openclaw/slack/contract-api.js";
|
||||
export type {
|
||||
TelegramInteractiveHandlerContext,
|
||||
TelegramInteractiveHandlerRegistration,
|
||||
} from "@openclaw/telegram/contract-api.js";
|
||||
type ConversationBindingHelpers = {
|
||||
requestConversationBinding: (...args: unknown[]) => unknown;
|
||||
detachConversationBinding: (...args: unknown[]) => unknown;
|
||||
getCurrentConversationBinding: (...args: unknown[]) => unknown;
|
||||
};
|
||||
|
||||
type InteractiveHandlerRegistration<
|
||||
TChannel extends string,
|
||||
TContext,
|
||||
> = ConversationBindingHelpers & {
|
||||
channel: TChannel;
|
||||
namespace: string;
|
||||
handler: (ctx: TContext) => unknown;
|
||||
};
|
||||
|
||||
type BaseInteractiveContext<TChannel extends string> = ConversationBindingHelpers & {
|
||||
channel: TChannel;
|
||||
accountId: string;
|
||||
conversationId: string;
|
||||
parentConversationId?: string;
|
||||
senderId: string;
|
||||
senderUsername?: string;
|
||||
auth?: unknown;
|
||||
};
|
||||
|
||||
export type TelegramInteractiveHandlerContext = BaseInteractiveContext<"telegram"> & {
|
||||
callbackId: string;
|
||||
senderUsername?: string;
|
||||
threadId?: number;
|
||||
isGroup?: boolean;
|
||||
isForum?: boolean;
|
||||
callback: {
|
||||
data: string;
|
||||
namespace: string;
|
||||
payload: string;
|
||||
messageId: number;
|
||||
chatId: string;
|
||||
messageText?: string;
|
||||
};
|
||||
respond: Record<string, (...args: unknown[]) => unknown>;
|
||||
};
|
||||
|
||||
export type DiscordInteractiveHandlerContext = BaseInteractiveContext<"discord"> & {
|
||||
interactionId: string;
|
||||
guildId?: string;
|
||||
interaction: {
|
||||
data: string;
|
||||
namespace: string;
|
||||
payload: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
respond: Record<string, (...args: unknown[]) => unknown>;
|
||||
};
|
||||
|
||||
export type SlackInteractiveHandlerContext = BaseInteractiveContext<"slack"> & {
|
||||
interactionId: string;
|
||||
threadId?: string;
|
||||
interaction: {
|
||||
data: string;
|
||||
namespace: string;
|
||||
payload: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
respond: Record<string, (...args: unknown[]) => unknown>;
|
||||
};
|
||||
|
||||
export type TelegramInteractiveHandlerRegistration = InteractiveHandlerRegistration<
|
||||
"telegram",
|
||||
TelegramInteractiveHandlerContext
|
||||
>;
|
||||
export type DiscordInteractiveHandlerRegistration = InteractiveHandlerRegistration<
|
||||
"discord",
|
||||
DiscordInteractiveHandlerContext
|
||||
>;
|
||||
export type SlackInteractiveHandlerRegistration = InteractiveHandlerRegistration<
|
||||
"slack",
|
||||
SlackInteractiveHandlerContext
|
||||
>;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { loadBundledPluginContractApiSync } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
|
||||
type MatrixContractSurface = typeof import("@openclaw/matrix/contract-api.js");
|
||||
type MatrixContractSurface = {
|
||||
matrixSetupAdapter: Record<string, unknown>;
|
||||
matrixSetupWizard: Record<string, unknown>;
|
||||
};
|
||||
|
||||
let matrixContractSurface: MatrixContractSurface | undefined;
|
||||
|
||||
|
||||
@@ -9,29 +9,29 @@ import type { LineProbeResult } from "../../../src/plugin-sdk/line.js";
|
||||
import { resolveRelativeBundledPluginPublicModuleId } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
import { withEnvAsync } from "../../../src/test-utils/env.js";
|
||||
|
||||
type DiscordDirectoryContractApiSurface = Pick<
|
||||
typeof import("@openclaw/discord/directory-contract-api.js"),
|
||||
"listDiscordDirectoryPeersFromConfig" | "listDiscordDirectoryGroupsFromConfig"
|
||||
>;
|
||||
type DiscordProbe = import("@openclaw/discord/api.js").DiscordProbe;
|
||||
type DiscordTokenResolution = import("@openclaw/discord/api.js").DiscordTokenResolution;
|
||||
type IMessageProbe = import("@openclaw/imessage/runtime-api.js").IMessageProbe;
|
||||
type SignalProbe = import("@openclaw/signal/api.js").SignalProbe;
|
||||
type SlackDirectoryContractApiSurface = Pick<
|
||||
typeof import("@openclaw/slack/directory-contract-api.js"),
|
||||
"listSlackDirectoryPeersFromConfig" | "listSlackDirectoryGroupsFromConfig"
|
||||
>;
|
||||
type SlackProbe = import("@openclaw/slack/api.js").SlackProbe;
|
||||
type TelegramDirectoryContractApiSurface = Pick<
|
||||
typeof import("@openclaw/telegram/directory-contract-api.js"),
|
||||
"listTelegramDirectoryPeersFromConfig" | "listTelegramDirectoryGroupsFromConfig"
|
||||
>;
|
||||
type TelegramProbe = import("@openclaw/telegram/api.js").TelegramProbe;
|
||||
type TelegramTokenResolution = import("@openclaw/telegram/api.js").TelegramTokenResolution;
|
||||
type WhatsAppDirectoryContractApiSurface = Pick<
|
||||
typeof import("@openclaw/whatsapp/directory-contract-api.js"),
|
||||
"listWhatsAppDirectoryPeersFromConfig" | "listWhatsAppDirectoryGroupsFromConfig"
|
||||
>;
|
||||
type DiscordDirectoryContractApiSurface = {
|
||||
listDiscordDirectoryPeersFromConfig: DirectoryListFn;
|
||||
listDiscordDirectoryGroupsFromConfig: DirectoryListFn;
|
||||
};
|
||||
type DiscordProbe = BaseProbeResult;
|
||||
type DiscordTokenResolution = BaseTokenResolution;
|
||||
type IMessageProbe = BaseProbeResult;
|
||||
type SignalProbe = BaseProbeResult;
|
||||
type SlackDirectoryContractApiSurface = {
|
||||
listSlackDirectoryPeersFromConfig: DirectoryListFn;
|
||||
listSlackDirectoryGroupsFromConfig: DirectoryListFn;
|
||||
};
|
||||
type SlackProbe = BaseProbeResult;
|
||||
type TelegramDirectoryContractApiSurface = {
|
||||
listTelegramDirectoryPeersFromConfig: DirectoryListFn;
|
||||
listTelegramDirectoryGroupsFromConfig: DirectoryListFn;
|
||||
};
|
||||
type TelegramProbe = BaseProbeResult;
|
||||
type TelegramTokenResolution = BaseTokenResolution;
|
||||
type WhatsAppDirectoryContractApiSurface = {
|
||||
listWhatsAppDirectoryPeersFromConfig: DirectoryListFn;
|
||||
listWhatsAppDirectoryGroupsFromConfig: DirectoryListFn;
|
||||
};
|
||||
|
||||
let discordDirectoryContractApi: Promise<DiscordDirectoryContractApiSurface> | undefined;
|
||||
let slackDirectoryContractApi: Promise<SlackDirectoryContractApiSurface> | undefined;
|
||||
|
||||
@@ -1,15 +1,54 @@
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import type { SecurityAuditFinding } from "../../../src/security/audit.types.js";
|
||||
import {
|
||||
loadBundledPluginPublicSurfaceSync,
|
||||
resolveRelativeBundledPluginPublicModuleId,
|
||||
} from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
|
||||
type DiscordSecurityAuditSurface =
|
||||
typeof import("@openclaw/discord/security-audit-contract-api.js");
|
||||
type FeishuSecuritySurface = typeof import("@openclaw/feishu/security-contract-api.js");
|
||||
type SlackSecuritySurface = typeof import("@openclaw/slack/security-contract-api.js");
|
||||
type SynologyChatSecuritySurface = typeof import("@openclaw/synology-chat/contract-api.js");
|
||||
type TelegramSecuritySurface = typeof import("@openclaw/telegram/security-audit-contract-api.js");
|
||||
type ZalouserSecuritySurface = typeof import("@openclaw/zalouser/contract-api.js");
|
||||
type SecurityAuditAccount = {
|
||||
accountId: string;
|
||||
enabled?: boolean;
|
||||
token?: unknown;
|
||||
tokenSource?: string;
|
||||
config?: Record<string, unknown>;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type FlexibleSecurityAuditParams = {
|
||||
cfg?: OpenClawConfig;
|
||||
sourceConfig?: OpenClawConfig;
|
||||
account: SecurityAuditAccount;
|
||||
accountId?: string | null;
|
||||
orderedAccountIds?: string[];
|
||||
hasExplicitAccountPath?: boolean;
|
||||
};
|
||||
type ConfigSecurityAuditParams = {
|
||||
cfg: OpenClawConfig;
|
||||
};
|
||||
type AsyncChannelSecurityAuditCollector = (
|
||||
params: FlexibleSecurityAuditParams,
|
||||
) => Promise<SecurityAuditFinding[]>;
|
||||
type SyncChannelSecurityAuditCollector = (
|
||||
params: FlexibleSecurityAuditParams,
|
||||
) => SecurityAuditFinding[];
|
||||
type ConfigSecurityAuditCollector = (params: ConfigSecurityAuditParams) => SecurityAuditFinding[];
|
||||
type DiscordSecurityAuditSurface = {
|
||||
collectDiscordSecurityAuditFindings: AsyncChannelSecurityAuditCollector;
|
||||
};
|
||||
type FeishuSecuritySurface = {
|
||||
collectFeishuSecurityAuditFindings: ConfigSecurityAuditCollector;
|
||||
};
|
||||
type SlackSecuritySurface = {
|
||||
collectSlackSecurityAuditFindings: AsyncChannelSecurityAuditCollector;
|
||||
};
|
||||
type SynologyChatSecuritySurface = {
|
||||
collectSynologyChatSecurityAuditFindings: SyncChannelSecurityAuditCollector;
|
||||
};
|
||||
type TelegramSecuritySurface = {
|
||||
collectTelegramSecurityAuditFindings: AsyncChannelSecurityAuditCollector;
|
||||
};
|
||||
type ZalouserSecuritySurface = {
|
||||
collectZalouserSecurityAuditFindings: SyncChannelSecurityAuditCollector;
|
||||
};
|
||||
|
||||
const discordSecurityAuditModuleId = resolveRelativeBundledPluginPublicModuleId({
|
||||
fromModuleUrl: import.meta.url,
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { loadBundledPluginContractApiSync } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
|
||||
type AnthropicContractSurface = typeof import("@openclaw/anthropic/contract-api.js");
|
||||
type AnthropicContractSurface = {
|
||||
createAnthropicBetaHeadersWrapper: (...args: unknown[]) => unknown;
|
||||
createAnthropicFastModeWrapper: (...args: unknown[]) => unknown;
|
||||
createAnthropicServiceTierWrapper: (...args: unknown[]) => unknown;
|
||||
resolveAnthropicBetas: (...args: unknown[]) => unknown;
|
||||
resolveAnthropicFastMode: (...args: unknown[]) => unknown;
|
||||
resolveAnthropicServiceTier: (...args: unknown[]) => unknown;
|
||||
};
|
||||
|
||||
let anthropicContractSurface: AnthropicContractSurface | undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user