fix: align plugin runtime types
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import type { ClawdbotConfig } from "../../config/config.js";
|
import type { LogLevel } from "../../logging/levels.js";
|
||||||
|
|
||||||
export type RuntimeLogger = {
|
export type RuntimeLogger = {
|
||||||
debug?: (message: string) => void;
|
debug?: (message: string) => void;
|
||||||
@@ -11,109 +11,49 @@ export type PluginRuntime = {
|
|||||||
version: string;
|
version: string;
|
||||||
channel: {
|
channel: {
|
||||||
text: {
|
text: {
|
||||||
chunkMarkdownText: (text: string, limit: number) => string[];
|
chunkMarkdownText: typeof import("../../auto-reply/chunk.js").chunkMarkdownText;
|
||||||
resolveTextChunkLimit: (cfg: ClawdbotConfig, channel: string, accountId?: string) => number;
|
resolveTextChunkLimit: typeof import("../../auto-reply/chunk.js").resolveTextChunkLimit;
|
||||||
hasControlCommand: (text: string, cfg: ClawdbotConfig) => boolean;
|
hasControlCommand: typeof import("../../auto-reply/command-detection.js").hasControlCommand;
|
||||||
};
|
};
|
||||||
reply: {
|
reply: {
|
||||||
dispatchReplyWithBufferedBlockDispatcher: (params: {
|
dispatchReplyWithBufferedBlockDispatcher: typeof import("../../auto-reply/reply/provider-dispatcher.js").dispatchReplyWithBufferedBlockDispatcher;
|
||||||
ctx: unknown;
|
createReplyDispatcherWithTyping: typeof import("../../auto-reply/reply/reply-dispatcher.js").createReplyDispatcherWithTyping;
|
||||||
cfg: unknown;
|
resolveEffectiveMessagesConfig: typeof import("../../agents/identity.js").resolveEffectiveMessagesConfig;
|
||||||
dispatcherOptions: {
|
resolveHumanDelayConfig: typeof import("../../agents/identity.js").resolveHumanDelayConfig;
|
||||||
deliver: (payload: { text?: string; mediaUrls?: string[]; mediaUrl?: string }) => void | Promise<void>;
|
|
||||||
onError?: (err: unknown, info: { kind: string }) => void;
|
|
||||||
};
|
|
||||||
}) => Promise<void>;
|
|
||||||
createReplyDispatcherWithTyping: (...args: unknown[]) => unknown;
|
|
||||||
resolveEffectiveMessagesConfig: (
|
|
||||||
cfg: ClawdbotConfig,
|
|
||||||
agentId: string,
|
|
||||||
opts?: { hasAllowFrom?: boolean; fallbackMessagePrefix?: string },
|
|
||||||
) => { messagePrefix: string; responsePrefix?: string };
|
|
||||||
resolveHumanDelayConfig: (
|
|
||||||
cfg: ClawdbotConfig,
|
|
||||||
agentId: string,
|
|
||||||
) => { mode?: string; minMs?: number; maxMs?: number } | undefined;
|
|
||||||
};
|
};
|
||||||
routing: {
|
routing: {
|
||||||
resolveAgentRoute: (params: {
|
resolveAgentRoute: typeof import("../../routing/resolve-route.js").resolveAgentRoute;
|
||||||
cfg: unknown;
|
|
||||||
channel: string;
|
|
||||||
accountId: string;
|
|
||||||
peer: { kind: "dm" | "group" | "channel"; id: string };
|
|
||||||
}) => {
|
|
||||||
agentId: string;
|
|
||||||
channel: string;
|
|
||||||
accountId: string;
|
|
||||||
sessionKey: string;
|
|
||||||
mainSessionKey: string;
|
|
||||||
matchedBy: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
pairing: {
|
pairing: {
|
||||||
buildPairingReply: (params: { channel: string; idLine: string; code: string }) => string;
|
buildPairingReply: typeof import("../../pairing/pairing-messages.js").buildPairingReply;
|
||||||
readAllowFromStore: (channel: string) => Promise<string[]>;
|
readAllowFromStore: typeof import("../../pairing/pairing-store.js").readChannelAllowFromStore;
|
||||||
upsertPairingRequest: (params: {
|
upsertPairingRequest: typeof import("../../pairing/pairing-store.js").upsertChannelPairingRequest;
|
||||||
channel: string;
|
|
||||||
id: string;
|
|
||||||
meta?: { name?: string };
|
|
||||||
}) => Promise<{ code: string; created: boolean }>;
|
|
||||||
};
|
};
|
||||||
media: {
|
media: {
|
||||||
fetchRemoteMedia: (params: { url: string }) => Promise<{ buffer: Buffer; contentType?: string }>;
|
fetchRemoteMedia: typeof import("../../media/fetch.js").fetchRemoteMedia;
|
||||||
saveMediaBuffer: (
|
saveMediaBuffer: typeof import("../../media/store.js").saveMediaBuffer;
|
||||||
buffer: Uint8Array,
|
|
||||||
contentType: string | undefined,
|
|
||||||
direction: "inbound" | "outbound",
|
|
||||||
maxBytes: number,
|
|
||||||
) => Promise<{ path: string; contentType?: string }>;
|
|
||||||
};
|
};
|
||||||
mentions: {
|
mentions: {
|
||||||
buildMentionRegexes: (cfg: ClawdbotConfig, agentId?: string) => RegExp[];
|
buildMentionRegexes: typeof import("../../auto-reply/reply/mentions.js").buildMentionRegexes;
|
||||||
matchesMentionPatterns: (text: string, regexes: RegExp[]) => boolean;
|
matchesMentionPatterns: typeof import("../../auto-reply/reply/mentions.js").matchesMentionPatterns;
|
||||||
};
|
};
|
||||||
groups: {
|
groups: {
|
||||||
resolveGroupPolicy: (
|
resolveGroupPolicy: typeof import("../../config/group-policy.js").resolveChannelGroupPolicy;
|
||||||
cfg: ClawdbotConfig,
|
resolveRequireMention: typeof import("../../config/group-policy.js").resolveChannelGroupRequireMention;
|
||||||
channel: string,
|
|
||||||
accountId: string,
|
|
||||||
groupId: string,
|
|
||||||
) => {
|
|
||||||
allowlistEnabled: boolean;
|
|
||||||
allowed: boolean;
|
|
||||||
groupConfig?: unknown;
|
|
||||||
defaultConfig?: unknown;
|
|
||||||
};
|
|
||||||
resolveRequireMention: (
|
|
||||||
cfg: ClawdbotConfig,
|
|
||||||
channel: string,
|
|
||||||
accountId: string,
|
|
||||||
groupId: string,
|
|
||||||
override?: boolean,
|
|
||||||
) => boolean;
|
|
||||||
};
|
};
|
||||||
debounce: {
|
debounce: {
|
||||||
createInboundDebouncer: <T>(opts: {
|
createInboundDebouncer: typeof import("../../auto-reply/inbound-debounce.js").createInboundDebouncer;
|
||||||
debounceMs: number;
|
resolveInboundDebounceMs: typeof import("../../auto-reply/inbound-debounce.js").resolveInboundDebounceMs;
|
||||||
buildKey: (value: T) => string | null;
|
|
||||||
shouldDebounce: (value: T) => boolean;
|
|
||||||
onFlush: (entries: T[]) => Promise<void>;
|
|
||||||
onError?: (err: unknown) => void;
|
|
||||||
}) => { push: (value: T) => void; flush: () => Promise<void> };
|
|
||||||
resolveInboundDebounceMs: (cfg: ClawdbotConfig, channel: string) => number;
|
|
||||||
};
|
};
|
||||||
commands: {
|
commands: {
|
||||||
resolveCommandAuthorizedFromAuthorizers: (params: {
|
resolveCommandAuthorizedFromAuthorizers: typeof import("../../channels/command-gating.js").resolveCommandAuthorizedFromAuthorizers;
|
||||||
useAccessGroups: boolean;
|
|
||||||
authorizers: Array<{ configured: boolean; allowed: boolean }>;
|
|
||||||
}) => boolean;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
logging: {
|
logging: {
|
||||||
shouldLogVerbose: () => boolean;
|
shouldLogVerbose: typeof import("../../globals.js").shouldLogVerbose;
|
||||||
getChildLogger: (bindings?: Record<string, unknown>, opts?: { level?: string }) => RuntimeLogger;
|
getChildLogger: (bindings?: Record<string, unknown>, opts?: { level?: LogLevel }) => RuntimeLogger;
|
||||||
};
|
};
|
||||||
state: {
|
state: {
|
||||||
resolveStateDir: (cfg: ClawdbotConfig) => string;
|
resolveStateDir: typeof import("../../config/paths.js").resolveStateDir;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
|
const repoRoot = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"clawdbot/plugin-sdk": path.join(repoRoot, "src", "plugin-sdk", "index.ts"),
|
||||||
|
},
|
||||||
|
},
|
||||||
test: {
|
test: {
|
||||||
testTimeout: 20_000,
|
testTimeout: 20_000,
|
||||||
include: [
|
include: [
|
||||||
|
|||||||
Reference in New Issue
Block a user