mirror of https://github.com/openclaw/openclaw.git
refactor: split plugin runtime type contracts
This commit is contained in:
parent
30ab9b2068
commit
9702d94196
|
|
@ -0,0 +1,164 @@
|
|||
type ReadChannelAllowFromStore =
|
||||
typeof import("../../pairing/pairing-store.js").readChannelAllowFromStore;
|
||||
type UpsertChannelPairingRequest =
|
||||
typeof import("../../pairing/pairing-store.js").upsertChannelPairingRequest;
|
||||
|
||||
type ReadChannelAllowFromStoreForAccount = (params: {
|
||||
channel: Parameters<ReadChannelAllowFromStore>[0];
|
||||
accountId: string;
|
||||
env?: Parameters<ReadChannelAllowFromStore>[1];
|
||||
}) => ReturnType<ReadChannelAllowFromStore>;
|
||||
|
||||
type UpsertChannelPairingRequestForAccount = (
|
||||
params: Omit<Parameters<UpsertChannelPairingRequest>[0], "accountId"> & { accountId: string },
|
||||
) => ReturnType<UpsertChannelPairingRequest>;
|
||||
|
||||
export type PluginRuntimeChannel = {
|
||||
text: {
|
||||
chunkByNewline: typeof import("../../auto-reply/chunk.js").chunkByNewline;
|
||||
chunkMarkdownText: typeof import("../../auto-reply/chunk.js").chunkMarkdownText;
|
||||
chunkMarkdownTextWithMode: typeof import("../../auto-reply/chunk.js").chunkMarkdownTextWithMode;
|
||||
chunkText: typeof import("../../auto-reply/chunk.js").chunkText;
|
||||
chunkTextWithMode: typeof import("../../auto-reply/chunk.js").chunkTextWithMode;
|
||||
resolveChunkMode: typeof import("../../auto-reply/chunk.js").resolveChunkMode;
|
||||
resolveTextChunkLimit: typeof import("../../auto-reply/chunk.js").resolveTextChunkLimit;
|
||||
hasControlCommand: typeof import("../../auto-reply/command-detection.js").hasControlCommand;
|
||||
resolveMarkdownTableMode: typeof import("../../config/markdown-tables.js").resolveMarkdownTableMode;
|
||||
convertMarkdownTables: typeof import("../../markdown/tables.js").convertMarkdownTables;
|
||||
};
|
||||
reply: {
|
||||
dispatchReplyWithBufferedBlockDispatcher: typeof import("../../auto-reply/reply/provider-dispatcher.js").dispatchReplyWithBufferedBlockDispatcher;
|
||||
createReplyDispatcherWithTyping: typeof import("../../auto-reply/reply/reply-dispatcher.js").createReplyDispatcherWithTyping;
|
||||
resolveEffectiveMessagesConfig: typeof import("../../agents/identity.js").resolveEffectiveMessagesConfig;
|
||||
resolveHumanDelayConfig: typeof import("../../agents/identity.js").resolveHumanDelayConfig;
|
||||
dispatchReplyFromConfig: typeof import("../../auto-reply/reply/dispatch-from-config.js").dispatchReplyFromConfig;
|
||||
withReplyDispatcher: typeof import("../../auto-reply/dispatch.js").withReplyDispatcher;
|
||||
finalizeInboundContext: typeof import("../../auto-reply/reply/inbound-context.js").finalizeInboundContext;
|
||||
formatAgentEnvelope: typeof import("../../auto-reply/envelope.js").formatAgentEnvelope;
|
||||
/** @deprecated Prefer `BodyForAgent` + structured user-context blocks (do not build plaintext envelopes for prompts). */
|
||||
formatInboundEnvelope: typeof import("../../auto-reply/envelope.js").formatInboundEnvelope;
|
||||
resolveEnvelopeFormatOptions: typeof import("../../auto-reply/envelope.js").resolveEnvelopeFormatOptions;
|
||||
};
|
||||
routing: {
|
||||
resolveAgentRoute: typeof import("../../routing/resolve-route.js").resolveAgentRoute;
|
||||
};
|
||||
pairing: {
|
||||
buildPairingReply: typeof import("../../pairing/pairing-messages.js").buildPairingReply;
|
||||
readAllowFromStore: ReadChannelAllowFromStoreForAccount;
|
||||
upsertPairingRequest: UpsertChannelPairingRequestForAccount;
|
||||
};
|
||||
media: {
|
||||
fetchRemoteMedia: typeof import("../../media/fetch.js").fetchRemoteMedia;
|
||||
saveMediaBuffer: typeof import("../../media/store.js").saveMediaBuffer;
|
||||
};
|
||||
activity: {
|
||||
record: typeof import("../../infra/channel-activity.js").recordChannelActivity;
|
||||
get: typeof import("../../infra/channel-activity.js").getChannelActivity;
|
||||
};
|
||||
session: {
|
||||
resolveStorePath: typeof import("../../config/sessions.js").resolveStorePath;
|
||||
readSessionUpdatedAt: typeof import("../../config/sessions.js").readSessionUpdatedAt;
|
||||
recordSessionMetaFromInbound: typeof import("../../config/sessions.js").recordSessionMetaFromInbound;
|
||||
recordInboundSession: typeof import("../../channels/session.js").recordInboundSession;
|
||||
updateLastRoute: typeof import("../../config/sessions.js").updateLastRoute;
|
||||
};
|
||||
mentions: {
|
||||
buildMentionRegexes: typeof import("../../auto-reply/reply/mentions.js").buildMentionRegexes;
|
||||
matchesMentionPatterns: typeof import("../../auto-reply/reply/mentions.js").matchesMentionPatterns;
|
||||
matchesMentionWithExplicit: typeof import("../../auto-reply/reply/mentions.js").matchesMentionWithExplicit;
|
||||
};
|
||||
reactions: {
|
||||
shouldAckReaction: typeof import("../../channels/ack-reactions.js").shouldAckReaction;
|
||||
removeAckReactionAfterReply: typeof import("../../channels/ack-reactions.js").removeAckReactionAfterReply;
|
||||
};
|
||||
groups: {
|
||||
resolveGroupPolicy: typeof import("../../config/group-policy.js").resolveChannelGroupPolicy;
|
||||
resolveRequireMention: typeof import("../../config/group-policy.js").resolveChannelGroupRequireMention;
|
||||
};
|
||||
debounce: {
|
||||
createInboundDebouncer: typeof import("../../auto-reply/inbound-debounce.js").createInboundDebouncer;
|
||||
resolveInboundDebounceMs: typeof import("../../auto-reply/inbound-debounce.js").resolveInboundDebounceMs;
|
||||
};
|
||||
commands: {
|
||||
resolveCommandAuthorizedFromAuthorizers: typeof import("../../channels/command-gating.js").resolveCommandAuthorizedFromAuthorizers;
|
||||
isControlCommandMessage: typeof import("../../auto-reply/command-detection.js").isControlCommandMessage;
|
||||
shouldComputeCommandAuthorized: typeof import("../../auto-reply/command-detection.js").shouldComputeCommandAuthorized;
|
||||
shouldHandleTextCommands: typeof import("../../auto-reply/commands-registry.js").shouldHandleTextCommands;
|
||||
};
|
||||
discord: {
|
||||
messageActions: typeof import("../../channels/plugins/actions/discord.js").discordMessageActions;
|
||||
auditChannelPermissions: typeof import("../../discord/audit.js").auditDiscordChannelPermissions;
|
||||
listDirectoryGroupsLive: typeof import("../../discord/directory-live.js").listDiscordDirectoryGroupsLive;
|
||||
listDirectoryPeersLive: typeof import("../../discord/directory-live.js").listDiscordDirectoryPeersLive;
|
||||
probeDiscord: typeof import("../../discord/probe.js").probeDiscord;
|
||||
resolveChannelAllowlist: typeof import("../../discord/resolve-channels.js").resolveDiscordChannelAllowlist;
|
||||
resolveUserAllowlist: typeof import("../../discord/resolve-users.js").resolveDiscordUserAllowlist;
|
||||
sendMessageDiscord: typeof import("../../discord/send.js").sendMessageDiscord;
|
||||
sendPollDiscord: typeof import("../../discord/send.js").sendPollDiscord;
|
||||
monitorDiscordProvider: typeof import("../../discord/monitor.js").monitorDiscordProvider;
|
||||
};
|
||||
slack: {
|
||||
listDirectoryGroupsLive: typeof import("../../slack/directory-live.js").listSlackDirectoryGroupsLive;
|
||||
listDirectoryPeersLive: typeof import("../../slack/directory-live.js").listSlackDirectoryPeersLive;
|
||||
probeSlack: typeof import("../../slack/probe.js").probeSlack;
|
||||
resolveChannelAllowlist: typeof import("../../slack/resolve-channels.js").resolveSlackChannelAllowlist;
|
||||
resolveUserAllowlist: typeof import("../../slack/resolve-users.js").resolveSlackUserAllowlist;
|
||||
sendMessageSlack: typeof import("../../slack/send.js").sendMessageSlack;
|
||||
monitorSlackProvider: typeof import("../../slack/index.js").monitorSlackProvider;
|
||||
handleSlackAction: typeof import("../../agents/tools/slack-actions.js").handleSlackAction;
|
||||
};
|
||||
telegram: {
|
||||
auditGroupMembership: typeof import("../../telegram/audit.js").auditTelegramGroupMembership;
|
||||
collectUnmentionedGroupIds: typeof import("../../telegram/audit.js").collectTelegramUnmentionedGroupIds;
|
||||
probeTelegram: typeof import("../../telegram/probe.js").probeTelegram;
|
||||
resolveTelegramToken: typeof import("../../telegram/token.js").resolveTelegramToken;
|
||||
sendMessageTelegram: typeof import("../../telegram/send.js").sendMessageTelegram;
|
||||
sendPollTelegram: typeof import("../../telegram/send.js").sendPollTelegram;
|
||||
monitorTelegramProvider: typeof import("../../telegram/monitor.js").monitorTelegramProvider;
|
||||
messageActions: typeof import("../../channels/plugins/actions/telegram.js").telegramMessageActions;
|
||||
};
|
||||
signal: {
|
||||
probeSignal: typeof import("../../signal/probe.js").probeSignal;
|
||||
sendMessageSignal: typeof import("../../signal/send.js").sendMessageSignal;
|
||||
monitorSignalProvider: typeof import("../../signal/index.js").monitorSignalProvider;
|
||||
messageActions: typeof import("../../channels/plugins/actions/signal.js").signalMessageActions;
|
||||
};
|
||||
imessage: {
|
||||
monitorIMessageProvider: typeof import("../../imessage/monitor.js").monitorIMessageProvider;
|
||||
probeIMessage: typeof import("../../imessage/probe.js").probeIMessage;
|
||||
sendMessageIMessage: typeof import("../../imessage/send.js").sendMessageIMessage;
|
||||
};
|
||||
whatsapp: {
|
||||
getActiveWebListener: typeof import("../../web/active-listener.js").getActiveWebListener;
|
||||
getWebAuthAgeMs: typeof import("../../web/auth-store.js").getWebAuthAgeMs;
|
||||
logoutWeb: typeof import("../../web/auth-store.js").logoutWeb;
|
||||
logWebSelfId: typeof import("../../web/auth-store.js").logWebSelfId;
|
||||
readWebSelfId: typeof import("../../web/auth-store.js").readWebSelfId;
|
||||
webAuthExists: typeof import("../../web/auth-store.js").webAuthExists;
|
||||
sendMessageWhatsApp: typeof import("../../web/outbound.js").sendMessageWhatsApp;
|
||||
sendPollWhatsApp: typeof import("../../web/outbound.js").sendPollWhatsApp;
|
||||
loginWeb: typeof import("../../web/login.js").loginWeb;
|
||||
startWebLoginWithQr: typeof import("../../web/login-qr.js").startWebLoginWithQr;
|
||||
waitForWebLogin: typeof import("../../web/login-qr.js").waitForWebLogin;
|
||||
monitorWebChannel: typeof import("../../channels/web/index.js").monitorWebChannel;
|
||||
handleWhatsAppAction: typeof import("../../agents/tools/whatsapp-actions.js").handleWhatsAppAction;
|
||||
createLoginTool: typeof import("../../channels/plugins/agent-tools/whatsapp-login.js").createWhatsAppLoginTool;
|
||||
};
|
||||
line: {
|
||||
listLineAccountIds: typeof import("../../line/accounts.js").listLineAccountIds;
|
||||
resolveDefaultLineAccountId: typeof import("../../line/accounts.js").resolveDefaultLineAccountId;
|
||||
resolveLineAccount: typeof import("../../line/accounts.js").resolveLineAccount;
|
||||
normalizeAccountId: typeof import("../../line/accounts.js").normalizeAccountId;
|
||||
probeLineBot: typeof import("../../line/probe.js").probeLineBot;
|
||||
sendMessageLine: typeof import("../../line/send.js").sendMessageLine;
|
||||
pushMessageLine: typeof import("../../line/send.js").pushMessageLine;
|
||||
pushMessagesLine: typeof import("../../line/send.js").pushMessagesLine;
|
||||
pushFlexMessage: typeof import("../../line/send.js").pushFlexMessage;
|
||||
pushTemplateMessage: typeof import("../../line/send.js").pushTemplateMessage;
|
||||
pushLocationMessage: typeof import("../../line/send.js").pushLocationMessage;
|
||||
pushTextMessageWithQuickReplies: typeof import("../../line/send.js").pushTextMessageWithQuickReplies;
|
||||
createQuickReplyItems: typeof import("../../line/send.js").createQuickReplyItems;
|
||||
buildTemplateMessageFromPayload: typeof import("../../line/template-messages.js").buildTemplateMessageFromPayload;
|
||||
monitorLineProvider: typeof import("../../line/monitor.js").monitorLineProvider;
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import type { LogLevel } from "../../logging/levels.js";
|
||||
|
||||
export type RuntimeLogger = {
|
||||
debug?: (message: string, meta?: Record<string, unknown>) => void;
|
||||
info: (message: string, meta?: Record<string, unknown>) => void;
|
||||
warn: (message: string, meta?: Record<string, unknown>) => void;
|
||||
error: (message: string, meta?: Record<string, unknown>) => void;
|
||||
};
|
||||
|
||||
export type PluginRuntimeCore = {
|
||||
version: string;
|
||||
config: {
|
||||
loadConfig: typeof import("../../config/config.js").loadConfig;
|
||||
writeConfigFile: typeof import("../../config/config.js").writeConfigFile;
|
||||
};
|
||||
system: {
|
||||
enqueueSystemEvent: typeof import("../../infra/system-events.js").enqueueSystemEvent;
|
||||
requestHeartbeatNow: typeof import("../../infra/heartbeat-wake.js").requestHeartbeatNow;
|
||||
runCommandWithTimeout: typeof import("../../process/exec.js").runCommandWithTimeout;
|
||||
formatNativeDependencyHint: typeof import("./native-deps.js").formatNativeDependencyHint;
|
||||
};
|
||||
media: {
|
||||
loadWebMedia: typeof import("../../web/media.js").loadWebMedia;
|
||||
detectMime: typeof import("../../media/mime.js").detectMime;
|
||||
mediaKindFromMime: typeof import("../../media/constants.js").mediaKindFromMime;
|
||||
isVoiceCompatibleAudio: typeof import("../../media/audio.js").isVoiceCompatibleAudio;
|
||||
getImageMetadata: typeof import("../../media/image-ops.js").getImageMetadata;
|
||||
resizeToJpeg: typeof import("../../media/image-ops.js").resizeToJpeg;
|
||||
};
|
||||
tts: {
|
||||
textToSpeechTelephony: typeof import("../../tts/tts.js").textToSpeechTelephony;
|
||||
};
|
||||
stt: {
|
||||
transcribeAudioFile: typeof import("../../media-understanding/transcribe-audio.js").transcribeAudioFile;
|
||||
};
|
||||
tools: {
|
||||
createMemoryGetTool: typeof import("../../agents/tools/memory-tool.js").createMemoryGetTool;
|
||||
createMemorySearchTool: typeof import("../../agents/tools/memory-tool.js").createMemorySearchTool;
|
||||
registerMemoryCli: typeof import("../../cli/memory-cli.js").registerMemoryCli;
|
||||
};
|
||||
events: {
|
||||
onAgentEvent: typeof import("../../infra/agent-events.js").onAgentEvent;
|
||||
onSessionTranscriptUpdate: typeof import("../../sessions/transcript-events.js").onSessionTranscriptUpdate;
|
||||
};
|
||||
logging: {
|
||||
shouldLogVerbose: typeof import("../../globals.js").shouldLogVerbose;
|
||||
getChildLogger: (
|
||||
bindings?: Record<string, unknown>,
|
||||
opts?: { level?: LogLevel },
|
||||
) => RuntimeLogger;
|
||||
};
|
||||
state: {
|
||||
resolveStateDir: typeof import("../../config/paths.js").resolveStateDir;
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { describe, expectTypeOf, it } from "vitest";
|
||||
import { createPluginRuntime } from "./index.js";
|
||||
import type { PluginRuntime } from "./types.js";
|
||||
|
||||
describe("plugin runtime type contract", () => {
|
||||
it("createPluginRuntime returns the declared PluginRuntime shape", () => {
|
||||
const runtime = createPluginRuntime();
|
||||
expectTypeOf(runtime).toMatchTypeOf<PluginRuntime>();
|
||||
expectTypeOf<PluginRuntime>().toMatchTypeOf(runtime);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,388 +1,8 @@
|
|||
import type { LogLevel } from "../../logging/levels.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
import type { PluginRuntimeCore, RuntimeLogger } from "./types-core.js";
|
||||
|
||||
type ShouldLogVerbose = typeof import("../../globals.js").shouldLogVerbose;
|
||||
type DispatchReplyWithBufferedBlockDispatcher =
|
||||
typeof import("../../auto-reply/reply/provider-dispatcher.js").dispatchReplyWithBufferedBlockDispatcher;
|
||||
type CreateReplyDispatcherWithTyping =
|
||||
typeof import("../../auto-reply/reply/reply-dispatcher.js").createReplyDispatcherWithTyping;
|
||||
type ResolveEffectiveMessagesConfig =
|
||||
typeof import("../../agents/identity.js").resolveEffectiveMessagesConfig;
|
||||
type ResolveHumanDelayConfig = typeof import("../../agents/identity.js").resolveHumanDelayConfig;
|
||||
type ResolveAgentRoute = typeof import("../../routing/resolve-route.js").resolveAgentRoute;
|
||||
type BuildPairingReply = typeof import("../../pairing/pairing-messages.js").buildPairingReply;
|
||||
type ReadChannelAllowFromStore =
|
||||
typeof import("../../pairing/pairing-store.js").readChannelAllowFromStore;
|
||||
type UpsertChannelPairingRequest =
|
||||
typeof import("../../pairing/pairing-store.js").upsertChannelPairingRequest;
|
||||
type ReadChannelAllowFromStoreForAccount = (params: {
|
||||
channel: Parameters<ReadChannelAllowFromStore>[0];
|
||||
accountId: string;
|
||||
env?: Parameters<ReadChannelAllowFromStore>[1];
|
||||
}) => ReturnType<ReadChannelAllowFromStore>;
|
||||
type UpsertChannelPairingRequestForAccount = (
|
||||
params: Omit<Parameters<UpsertChannelPairingRequest>[0], "accountId"> & { accountId: string },
|
||||
) => ReturnType<UpsertChannelPairingRequest>;
|
||||
type FetchRemoteMedia = typeof import("../../media/fetch.js").fetchRemoteMedia;
|
||||
type SaveMediaBuffer = typeof import("../../media/store.js").saveMediaBuffer;
|
||||
type TextToSpeechTelephony = typeof import("../../tts/tts.js").textToSpeechTelephony;
|
||||
type TranscribeAudioFile =
|
||||
typeof import("../../media-understanding/transcribe-audio.js").transcribeAudioFile;
|
||||
type BuildMentionRegexes = typeof import("../../auto-reply/reply/mentions.js").buildMentionRegexes;
|
||||
type MatchesMentionPatterns =
|
||||
typeof import("../../auto-reply/reply/mentions.js").matchesMentionPatterns;
|
||||
type MatchesMentionWithExplicit =
|
||||
typeof import("../../auto-reply/reply/mentions.js").matchesMentionWithExplicit;
|
||||
type ShouldAckReaction = typeof import("../../channels/ack-reactions.js").shouldAckReaction;
|
||||
type RemoveAckReactionAfterReply =
|
||||
typeof import("../../channels/ack-reactions.js").removeAckReactionAfterReply;
|
||||
type ResolveChannelGroupPolicy =
|
||||
typeof import("../../config/group-policy.js").resolveChannelGroupPolicy;
|
||||
type ResolveChannelGroupRequireMention =
|
||||
typeof import("../../config/group-policy.js").resolveChannelGroupRequireMention;
|
||||
type CreateInboundDebouncer =
|
||||
typeof import("../../auto-reply/inbound-debounce.js").createInboundDebouncer;
|
||||
type ResolveInboundDebounceMs =
|
||||
typeof import("../../auto-reply/inbound-debounce.js").resolveInboundDebounceMs;
|
||||
type ResolveCommandAuthorizedFromAuthorizers =
|
||||
typeof import("../../channels/command-gating.js").resolveCommandAuthorizedFromAuthorizers;
|
||||
type ResolveTextChunkLimit = typeof import("../../auto-reply/chunk.js").resolveTextChunkLimit;
|
||||
type ResolveChunkMode = typeof import("../../auto-reply/chunk.js").resolveChunkMode;
|
||||
type ChunkMarkdownText = typeof import("../../auto-reply/chunk.js").chunkMarkdownText;
|
||||
type ChunkMarkdownTextWithMode =
|
||||
typeof import("../../auto-reply/chunk.js").chunkMarkdownTextWithMode;
|
||||
type ChunkText = typeof import("../../auto-reply/chunk.js").chunkText;
|
||||
type ChunkTextWithMode = typeof import("../../auto-reply/chunk.js").chunkTextWithMode;
|
||||
type ChunkByNewline = typeof import("../../auto-reply/chunk.js").chunkByNewline;
|
||||
type ResolveMarkdownTableMode =
|
||||
typeof import("../../config/markdown-tables.js").resolveMarkdownTableMode;
|
||||
type ConvertMarkdownTables = typeof import("../../markdown/tables.js").convertMarkdownTables;
|
||||
type HasControlCommand = typeof import("../../auto-reply/command-detection.js").hasControlCommand;
|
||||
type IsControlCommandMessage =
|
||||
typeof import("../../auto-reply/command-detection.js").isControlCommandMessage;
|
||||
type ShouldComputeCommandAuthorized =
|
||||
typeof import("../../auto-reply/command-detection.js").shouldComputeCommandAuthorized;
|
||||
type ShouldHandleTextCommands =
|
||||
typeof import("../../auto-reply/commands-registry.js").shouldHandleTextCommands;
|
||||
type DispatchReplyFromConfig =
|
||||
typeof import("../../auto-reply/reply/dispatch-from-config.js").dispatchReplyFromConfig;
|
||||
type WithReplyDispatcher = typeof import("../../auto-reply/dispatch.js").withReplyDispatcher;
|
||||
type FinalizeInboundContext =
|
||||
typeof import("../../auto-reply/reply/inbound-context.js").finalizeInboundContext;
|
||||
type FormatAgentEnvelope = typeof import("../../auto-reply/envelope.js").formatAgentEnvelope;
|
||||
type FormatInboundEnvelope = typeof import("../../auto-reply/envelope.js").formatInboundEnvelope;
|
||||
type ResolveEnvelopeFormatOptions =
|
||||
typeof import("../../auto-reply/envelope.js").resolveEnvelopeFormatOptions;
|
||||
type ResolveStateDir = typeof import("../../config/paths.js").resolveStateDir;
|
||||
type RecordInboundSession = typeof import("../../channels/session.js").recordInboundSession;
|
||||
type RecordSessionMetaFromInbound =
|
||||
typeof import("../../config/sessions.js").recordSessionMetaFromInbound;
|
||||
type ResolveStorePath = typeof import("../../config/sessions.js").resolveStorePath;
|
||||
type ReadSessionUpdatedAt = typeof import("../../config/sessions.js").readSessionUpdatedAt;
|
||||
type UpdateLastRoute = typeof import("../../config/sessions.js").updateLastRoute;
|
||||
type LoadConfig = typeof import("../../config/config.js").loadConfig;
|
||||
type WriteConfigFile = typeof import("../../config/config.js").writeConfigFile;
|
||||
type RecordChannelActivity = typeof import("../../infra/channel-activity.js").recordChannelActivity;
|
||||
type GetChannelActivity = typeof import("../../infra/channel-activity.js").getChannelActivity;
|
||||
type EnqueueSystemEvent = typeof import("../../infra/system-events.js").enqueueSystemEvent;
|
||||
type RequestHeartbeatNow = typeof import("../../infra/heartbeat-wake.js").requestHeartbeatNow;
|
||||
type RunCommandWithTimeout = typeof import("../../process/exec.js").runCommandWithTimeout;
|
||||
type FormatNativeDependencyHint = typeof import("./native-deps.js").formatNativeDependencyHint;
|
||||
type LoadWebMedia = typeof import("../../web/media.js").loadWebMedia;
|
||||
type DetectMime = typeof import("../../media/mime.js").detectMime;
|
||||
type MediaKindFromMime = typeof import("../../media/constants.js").mediaKindFromMime;
|
||||
type IsVoiceCompatibleAudio = typeof import("../../media/audio.js").isVoiceCompatibleAudio;
|
||||
type GetImageMetadata = typeof import("../../media/image-ops.js").getImageMetadata;
|
||||
type ResizeToJpeg = typeof import("../../media/image-ops.js").resizeToJpeg;
|
||||
type OnAgentEvent = typeof import("../../infra/agent-events.js").onAgentEvent;
|
||||
type OnSessionTranscriptUpdate =
|
||||
typeof import("../../sessions/transcript-events.js").onSessionTranscriptUpdate;
|
||||
type CreateMemoryGetTool = typeof import("../../agents/tools/memory-tool.js").createMemoryGetTool;
|
||||
type CreateMemorySearchTool =
|
||||
typeof import("../../agents/tools/memory-tool.js").createMemorySearchTool;
|
||||
type RegisterMemoryCli = typeof import("../../cli/memory-cli.js").registerMemoryCli;
|
||||
type DiscordMessageActions =
|
||||
typeof import("../../channels/plugins/actions/discord.js").discordMessageActions;
|
||||
type AuditDiscordChannelPermissions =
|
||||
typeof import("../../discord/audit.js").auditDiscordChannelPermissions;
|
||||
type ListDiscordDirectoryGroupsLive =
|
||||
typeof import("../../discord/directory-live.js").listDiscordDirectoryGroupsLive;
|
||||
type ListDiscordDirectoryPeersLive =
|
||||
typeof import("../../discord/directory-live.js").listDiscordDirectoryPeersLive;
|
||||
type ProbeDiscord = typeof import("../../discord/probe.js").probeDiscord;
|
||||
type ResolveDiscordChannelAllowlist =
|
||||
typeof import("../../discord/resolve-channels.js").resolveDiscordChannelAllowlist;
|
||||
type ResolveDiscordUserAllowlist =
|
||||
typeof import("../../discord/resolve-users.js").resolveDiscordUserAllowlist;
|
||||
type SendMessageDiscord = typeof import("../../discord/send.js").sendMessageDiscord;
|
||||
type SendPollDiscord = typeof import("../../discord/send.js").sendPollDiscord;
|
||||
type MonitorDiscordProvider = typeof import("../../discord/monitor.js").monitorDiscordProvider;
|
||||
type ListSlackDirectoryGroupsLive =
|
||||
typeof import("../../slack/directory-live.js").listSlackDirectoryGroupsLive;
|
||||
type ListSlackDirectoryPeersLive =
|
||||
typeof import("../../slack/directory-live.js").listSlackDirectoryPeersLive;
|
||||
type ProbeSlack = typeof import("../../slack/probe.js").probeSlack;
|
||||
type ResolveSlackChannelAllowlist =
|
||||
typeof import("../../slack/resolve-channels.js").resolveSlackChannelAllowlist;
|
||||
type ResolveSlackUserAllowlist =
|
||||
typeof import("../../slack/resolve-users.js").resolveSlackUserAllowlist;
|
||||
type SendMessageSlack = typeof import("../../slack/send.js").sendMessageSlack;
|
||||
type MonitorSlackProvider = typeof import("../../slack/index.js").monitorSlackProvider;
|
||||
type HandleSlackAction = typeof import("../../agents/tools/slack-actions.js").handleSlackAction;
|
||||
type AuditTelegramGroupMembership =
|
||||
typeof import("../../telegram/audit.js").auditTelegramGroupMembership;
|
||||
type CollectTelegramUnmentionedGroupIds =
|
||||
typeof import("../../telegram/audit.js").collectTelegramUnmentionedGroupIds;
|
||||
type ProbeTelegram = typeof import("../../telegram/probe.js").probeTelegram;
|
||||
type ResolveTelegramToken = typeof import("../../telegram/token.js").resolveTelegramToken;
|
||||
type SendMessageTelegram = typeof import("../../telegram/send.js").sendMessageTelegram;
|
||||
type SendPollTelegram = typeof import("../../telegram/send.js").sendPollTelegram;
|
||||
type MonitorTelegramProvider = typeof import("../../telegram/monitor.js").monitorTelegramProvider;
|
||||
type TelegramMessageActions =
|
||||
typeof import("../../channels/plugins/actions/telegram.js").telegramMessageActions;
|
||||
type ProbeSignal = typeof import("../../signal/probe.js").probeSignal;
|
||||
type SendMessageSignal = typeof import("../../signal/send.js").sendMessageSignal;
|
||||
type MonitorSignalProvider = typeof import("../../signal/index.js").monitorSignalProvider;
|
||||
type SignalMessageActions =
|
||||
typeof import("../../channels/plugins/actions/signal.js").signalMessageActions;
|
||||
type MonitorIMessageProvider = typeof import("../../imessage/monitor.js").monitorIMessageProvider;
|
||||
type ProbeIMessage = typeof import("../../imessage/probe.js").probeIMessage;
|
||||
type SendMessageIMessage = typeof import("../../imessage/send.js").sendMessageIMessage;
|
||||
type GetActiveWebListener = typeof import("../../web/active-listener.js").getActiveWebListener;
|
||||
type GetWebAuthAgeMs = typeof import("../../web/auth-store.js").getWebAuthAgeMs;
|
||||
type LogoutWeb = typeof import("../../web/auth-store.js").logoutWeb;
|
||||
type LogWebSelfId = typeof import("../../web/auth-store.js").logWebSelfId;
|
||||
type ReadWebSelfId = typeof import("../../web/auth-store.js").readWebSelfId;
|
||||
type WebAuthExists = typeof import("../../web/auth-store.js").webAuthExists;
|
||||
type SendMessageWhatsApp = typeof import("../../web/outbound.js").sendMessageWhatsApp;
|
||||
type SendPollWhatsApp = typeof import("../../web/outbound.js").sendPollWhatsApp;
|
||||
type LoginWeb = typeof import("../../web/login.js").loginWeb;
|
||||
type StartWebLoginWithQr = typeof import("../../web/login-qr.js").startWebLoginWithQr;
|
||||
type WaitForWebLogin = typeof import("../../web/login-qr.js").waitForWebLogin;
|
||||
type MonitorWebChannel = typeof import("../../channels/web/index.js").monitorWebChannel;
|
||||
type HandleWhatsAppAction =
|
||||
typeof import("../../agents/tools/whatsapp-actions.js").handleWhatsAppAction;
|
||||
type CreateWhatsAppLoginTool =
|
||||
typeof import("../../channels/plugins/agent-tools/whatsapp-login.js").createWhatsAppLoginTool;
|
||||
export type { RuntimeLogger };
|
||||
|
||||
// LINE channel types
|
||||
type ListLineAccountIds = typeof import("../../line/accounts.js").listLineAccountIds;
|
||||
type ResolveDefaultLineAccountId =
|
||||
typeof import("../../line/accounts.js").resolveDefaultLineAccountId;
|
||||
type ResolveLineAccount = typeof import("../../line/accounts.js").resolveLineAccount;
|
||||
type NormalizeLineAccountId = typeof import("../../line/accounts.js").normalizeAccountId;
|
||||
type ProbeLineBot = typeof import("../../line/probe.js").probeLineBot;
|
||||
type SendMessageLine = typeof import("../../line/send.js").sendMessageLine;
|
||||
type PushMessageLine = typeof import("../../line/send.js").pushMessageLine;
|
||||
type PushMessagesLine = typeof import("../../line/send.js").pushMessagesLine;
|
||||
type PushFlexMessage = typeof import("../../line/send.js").pushFlexMessage;
|
||||
type PushTemplateMessage = typeof import("../../line/send.js").pushTemplateMessage;
|
||||
type PushLocationMessage = typeof import("../../line/send.js").pushLocationMessage;
|
||||
type PushTextMessageWithQuickReplies =
|
||||
typeof import("../../line/send.js").pushTextMessageWithQuickReplies;
|
||||
type CreateQuickReplyItems = typeof import("../../line/send.js").createQuickReplyItems;
|
||||
type BuildTemplateMessageFromPayload =
|
||||
typeof import("../../line/template-messages.js").buildTemplateMessageFromPayload;
|
||||
type MonitorLineProvider = typeof import("../../line/monitor.js").monitorLineProvider;
|
||||
|
||||
export type RuntimeLogger = {
|
||||
debug?: (message: string, meta?: Record<string, unknown>) => void;
|
||||
info: (message: string, meta?: Record<string, unknown>) => void;
|
||||
warn: (message: string, meta?: Record<string, unknown>) => void;
|
||||
error: (message: string, meta?: Record<string, unknown>) => void;
|
||||
};
|
||||
|
||||
export type PluginRuntime = {
|
||||
version: string;
|
||||
config: {
|
||||
loadConfig: LoadConfig;
|
||||
writeConfigFile: WriteConfigFile;
|
||||
};
|
||||
system: {
|
||||
enqueueSystemEvent: EnqueueSystemEvent;
|
||||
requestHeartbeatNow: RequestHeartbeatNow;
|
||||
runCommandWithTimeout: RunCommandWithTimeout;
|
||||
formatNativeDependencyHint: FormatNativeDependencyHint;
|
||||
};
|
||||
media: {
|
||||
loadWebMedia: LoadWebMedia;
|
||||
detectMime: DetectMime;
|
||||
mediaKindFromMime: MediaKindFromMime;
|
||||
isVoiceCompatibleAudio: IsVoiceCompatibleAudio;
|
||||
getImageMetadata: GetImageMetadata;
|
||||
resizeToJpeg: ResizeToJpeg;
|
||||
};
|
||||
tts: {
|
||||
textToSpeechTelephony: TextToSpeechTelephony;
|
||||
};
|
||||
stt: {
|
||||
transcribeAudioFile: TranscribeAudioFile;
|
||||
};
|
||||
tools: {
|
||||
createMemoryGetTool: CreateMemoryGetTool;
|
||||
createMemorySearchTool: CreateMemorySearchTool;
|
||||
registerMemoryCli: RegisterMemoryCli;
|
||||
};
|
||||
channel: {
|
||||
text: {
|
||||
chunkByNewline: ChunkByNewline;
|
||||
chunkMarkdownText: ChunkMarkdownText;
|
||||
chunkMarkdownTextWithMode: ChunkMarkdownTextWithMode;
|
||||
chunkText: ChunkText;
|
||||
chunkTextWithMode: ChunkTextWithMode;
|
||||
resolveChunkMode: ResolveChunkMode;
|
||||
resolveTextChunkLimit: ResolveTextChunkLimit;
|
||||
hasControlCommand: HasControlCommand;
|
||||
resolveMarkdownTableMode: ResolveMarkdownTableMode;
|
||||
convertMarkdownTables: ConvertMarkdownTables;
|
||||
};
|
||||
reply: {
|
||||
dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcher;
|
||||
createReplyDispatcherWithTyping: CreateReplyDispatcherWithTyping;
|
||||
resolveEffectiveMessagesConfig: ResolveEffectiveMessagesConfig;
|
||||
resolveHumanDelayConfig: ResolveHumanDelayConfig;
|
||||
dispatchReplyFromConfig: DispatchReplyFromConfig;
|
||||
withReplyDispatcher: WithReplyDispatcher;
|
||||
finalizeInboundContext: FinalizeInboundContext;
|
||||
formatAgentEnvelope: FormatAgentEnvelope;
|
||||
/** @deprecated Prefer `BodyForAgent` + structured user-context blocks (do not build plaintext envelopes for prompts). */
|
||||
formatInboundEnvelope: FormatInboundEnvelope;
|
||||
resolveEnvelopeFormatOptions: ResolveEnvelopeFormatOptions;
|
||||
};
|
||||
routing: {
|
||||
resolveAgentRoute: ResolveAgentRoute;
|
||||
};
|
||||
pairing: {
|
||||
buildPairingReply: BuildPairingReply;
|
||||
readAllowFromStore: ReadChannelAllowFromStoreForAccount;
|
||||
upsertPairingRequest: UpsertChannelPairingRequestForAccount;
|
||||
};
|
||||
media: {
|
||||
fetchRemoteMedia: FetchRemoteMedia;
|
||||
saveMediaBuffer: SaveMediaBuffer;
|
||||
};
|
||||
activity: {
|
||||
record: RecordChannelActivity;
|
||||
get: GetChannelActivity;
|
||||
};
|
||||
session: {
|
||||
resolveStorePath: ResolveStorePath;
|
||||
readSessionUpdatedAt: ReadSessionUpdatedAt;
|
||||
recordSessionMetaFromInbound: RecordSessionMetaFromInbound;
|
||||
recordInboundSession: RecordInboundSession;
|
||||
updateLastRoute: UpdateLastRoute;
|
||||
};
|
||||
mentions: {
|
||||
buildMentionRegexes: BuildMentionRegexes;
|
||||
matchesMentionPatterns: MatchesMentionPatterns;
|
||||
matchesMentionWithExplicit: MatchesMentionWithExplicit;
|
||||
};
|
||||
reactions: {
|
||||
shouldAckReaction: ShouldAckReaction;
|
||||
removeAckReactionAfterReply: RemoveAckReactionAfterReply;
|
||||
};
|
||||
groups: {
|
||||
resolveGroupPolicy: ResolveChannelGroupPolicy;
|
||||
resolveRequireMention: ResolveChannelGroupRequireMention;
|
||||
};
|
||||
debounce: {
|
||||
createInboundDebouncer: CreateInboundDebouncer;
|
||||
resolveInboundDebounceMs: ResolveInboundDebounceMs;
|
||||
};
|
||||
commands: {
|
||||
resolveCommandAuthorizedFromAuthorizers: ResolveCommandAuthorizedFromAuthorizers;
|
||||
isControlCommandMessage: IsControlCommandMessage;
|
||||
shouldComputeCommandAuthorized: ShouldComputeCommandAuthorized;
|
||||
shouldHandleTextCommands: ShouldHandleTextCommands;
|
||||
};
|
||||
discord: {
|
||||
messageActions: DiscordMessageActions;
|
||||
auditChannelPermissions: AuditDiscordChannelPermissions;
|
||||
listDirectoryGroupsLive: ListDiscordDirectoryGroupsLive;
|
||||
listDirectoryPeersLive: ListDiscordDirectoryPeersLive;
|
||||
probeDiscord: ProbeDiscord;
|
||||
resolveChannelAllowlist: ResolveDiscordChannelAllowlist;
|
||||
resolveUserAllowlist: ResolveDiscordUserAllowlist;
|
||||
sendMessageDiscord: SendMessageDiscord;
|
||||
sendPollDiscord: SendPollDiscord;
|
||||
monitorDiscordProvider: MonitorDiscordProvider;
|
||||
};
|
||||
slack: {
|
||||
listDirectoryGroupsLive: ListSlackDirectoryGroupsLive;
|
||||
listDirectoryPeersLive: ListSlackDirectoryPeersLive;
|
||||
probeSlack: ProbeSlack;
|
||||
resolveChannelAllowlist: ResolveSlackChannelAllowlist;
|
||||
resolveUserAllowlist: ResolveSlackUserAllowlist;
|
||||
sendMessageSlack: SendMessageSlack;
|
||||
monitorSlackProvider: MonitorSlackProvider;
|
||||
handleSlackAction: HandleSlackAction;
|
||||
};
|
||||
telegram: {
|
||||
auditGroupMembership: AuditTelegramGroupMembership;
|
||||
collectUnmentionedGroupIds: CollectTelegramUnmentionedGroupIds;
|
||||
probeTelegram: ProbeTelegram;
|
||||
resolveTelegramToken: ResolveTelegramToken;
|
||||
sendMessageTelegram: SendMessageTelegram;
|
||||
sendPollTelegram: SendPollTelegram;
|
||||
monitorTelegramProvider: MonitorTelegramProvider;
|
||||
messageActions: TelegramMessageActions;
|
||||
};
|
||||
signal: {
|
||||
probeSignal: ProbeSignal;
|
||||
sendMessageSignal: SendMessageSignal;
|
||||
monitorSignalProvider: MonitorSignalProvider;
|
||||
messageActions: SignalMessageActions;
|
||||
};
|
||||
imessage: {
|
||||
monitorIMessageProvider: MonitorIMessageProvider;
|
||||
probeIMessage: ProbeIMessage;
|
||||
sendMessageIMessage: SendMessageIMessage;
|
||||
};
|
||||
whatsapp: {
|
||||
getActiveWebListener: GetActiveWebListener;
|
||||
getWebAuthAgeMs: GetWebAuthAgeMs;
|
||||
logoutWeb: LogoutWeb;
|
||||
logWebSelfId: LogWebSelfId;
|
||||
readWebSelfId: ReadWebSelfId;
|
||||
webAuthExists: WebAuthExists;
|
||||
sendMessageWhatsApp: SendMessageWhatsApp;
|
||||
sendPollWhatsApp: SendPollWhatsApp;
|
||||
loginWeb: LoginWeb;
|
||||
startWebLoginWithQr: StartWebLoginWithQr;
|
||||
waitForWebLogin: WaitForWebLogin;
|
||||
monitorWebChannel: MonitorWebChannel;
|
||||
handleWhatsAppAction: HandleWhatsAppAction;
|
||||
createLoginTool: CreateWhatsAppLoginTool;
|
||||
};
|
||||
line: {
|
||||
listLineAccountIds: ListLineAccountIds;
|
||||
resolveDefaultLineAccountId: ResolveDefaultLineAccountId;
|
||||
resolveLineAccount: ResolveLineAccount;
|
||||
normalizeAccountId: NormalizeLineAccountId;
|
||||
probeLineBot: ProbeLineBot;
|
||||
sendMessageLine: SendMessageLine;
|
||||
pushMessageLine: PushMessageLine;
|
||||
pushMessagesLine: PushMessagesLine;
|
||||
pushFlexMessage: PushFlexMessage;
|
||||
pushTemplateMessage: PushTemplateMessage;
|
||||
pushLocationMessage: PushLocationMessage;
|
||||
pushTextMessageWithQuickReplies: PushTextMessageWithQuickReplies;
|
||||
createQuickReplyItems: CreateQuickReplyItems;
|
||||
buildTemplateMessageFromPayload: BuildTemplateMessageFromPayload;
|
||||
monitorLineProvider: MonitorLineProvider;
|
||||
};
|
||||
};
|
||||
events: {
|
||||
onAgentEvent: OnAgentEvent;
|
||||
onSessionTranscriptUpdate: OnSessionTranscriptUpdate;
|
||||
};
|
||||
logging: {
|
||||
shouldLogVerbose: ShouldLogVerbose;
|
||||
getChildLogger: (
|
||||
bindings?: Record<string, unknown>,
|
||||
opts?: { level?: LogLevel },
|
||||
) => RuntimeLogger;
|
||||
};
|
||||
state: {
|
||||
resolveStateDir: ResolveStateDir;
|
||||
};
|
||||
export type PluginRuntime = PluginRuntimeCore & {
|
||||
channel: PluginRuntimeChannel;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue