refactor: trim imessage helper exports

This commit is contained in:
Peter Steinberger
2026-05-01 18:23:45 +01:00
parent 1ff2d747dc
commit 235d06bff1
16 changed files with 24 additions and 36 deletions

View File

@@ -4,7 +4,6 @@ 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";

View File

@@ -1,19 +1,13 @@
import { formatTrimmedAllowFromEntries } from "openclaw/plugin-sdk/channel-config-helpers";
import type { ChannelStatusIssue } from "openclaw/plugin-sdk/channel-contract";
import { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
import {
DEFAULT_ACCOUNT_ID,
getChatChannelMeta,
type ChannelPlugin,
type OpenClawConfig,
} from "openclaw/plugin-sdk/core";
import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/media-runtime";
import { collectStatusIssuesFromLastError } from "openclaw/plugin-sdk/status-helpers";
import {
resolveIMessageConfigAllowFrom,
resolveIMessageConfigDefaultTo,
} from "./config-accessors.js";
import { looksLikeIMessageTargetId, normalizeIMessageMessagingTarget } from "./normalize.js";
import { normalizeIMessageMessagingTarget } from "./normalize.js";
export { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
export {
@@ -21,12 +15,9 @@ export {
DEFAULT_ACCOUNT_ID,
formatTrimmedAllowFromEntries,
getChatChannelMeta,
looksLikeIMessageTargetId,
normalizeIMessageMessagingTarget,
PAIRING_APPROVED_MESSAGE,
resolveChannelMediaMaxBytes,
resolveIMessageConfigAllowFrom,
resolveIMessageConfigDefaultTo,
};
export type { ChannelPlugin, ChannelStatusIssue, OpenClawConfig };
export type { ChannelPlugin };

View File

@@ -1,4 +1,4 @@
export type IMessageMonitorClient = {
type IMessageMonitorClient = {
request: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
stop: () => Promise<void>;
};

View File

@@ -1,4 +1,4 @@
export type SentMessageLookup = {
type SentMessageLookup = {
text?: string;
messageId?: string;
};

View File

@@ -111,7 +111,7 @@ function hasIMessageEchoMatch(params: {
);
}
export type IMessageInboundDispatchDecision = {
type IMessageInboundDispatchDecision = {
kind: "dispatch";
isGroup: boolean;
chatId?: number;
@@ -132,7 +132,7 @@ export type IMessageInboundDispatchDecision = {
effectiveGroupAllowFrom: string[];
};
export type IMessageInboundDecision =
type IMessageInboundDecision =
| { kind: "drop"; reason: string }
| { kind: "pairing"; senderId: string }
| IMessageInboundDispatchDecision;
@@ -653,7 +653,7 @@ export function buildIMessageInboundContext(params: {
return { ctxPayload, fromLabel, chatTarget, imessageTo, inboundHistory };
}
export function buildIMessageEchoScope(params: {
function buildIMessageEchoScope(params: {
accountId: string;
isGroup: boolean;
chatId?: number;

View File

@@ -11,7 +11,7 @@ type ConversationWindow = {
timestamps: number[];
};
export type LoopRateLimiter = {
type LoopRateLimiter = {
/** Returns true if this conversation has exceeded the rate limit. */
isRateLimited: (conversationKey: string) => boolean;
/** Record an inbound message for a conversation. */

View File

@@ -22,7 +22,7 @@ const REFLECTION_PATTERNS: Array<{ re: RegExp; label: string }> = [
{ re: FINAL_TAG_RE, label: "final-tag" },
];
export type ReflectionDetection = {
type ReflectionDetection = {
isReflection: boolean;
matchedLabels: string[];
};

View File

@@ -8,7 +8,7 @@ type SelfChatCacheKeyParts = {
chatId?: number;
};
export type SelfChatLookup = SelfChatCacheKeyParts & {
type SelfChatLookup = SelfChatCacheKeyParts & {
text?: string;
createdAt?: number;
};

View File

@@ -1,7 +1,7 @@
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
export type IMessageAttachment = {
type IMessageAttachment = {
original_path?: string | null;
mime_type?: string | null;
missing?: boolean | null;

View File

@@ -6,7 +6,7 @@ import {
const MAX_WATCH_ERROR_MESSAGE_CHARS = 200;
export type SanitizedIMessageWatchErrorPayload = {
type SanitizedIMessageWatchErrorPayload = {
code?: number;
message?: string;
};

View File

@@ -26,7 +26,7 @@ function looksLikeHandleOrPhoneTarget(params: {
return (params.phonePattern ?? /^\+?\d{3,}$/).test(trimmed);
}
export function normalizeIMessageHandle(raw: string): string {
function normalizeIMessageHandle(raw: string): string {
const trimmed = raw.trim();
if (!trimmed) {
return "";

View File

@@ -1,9 +1,8 @@
import type { PluginRuntime } from "openclaw/plugin-sdk/core";
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
const { setRuntime: setIMessageRuntime, getRuntime: getIMessageRuntime } =
createPluginRuntimeStore<PluginRuntime>({
pluginId: "imessage",
errorMessage: "iMessage runtime not initialized",
});
export { getIMessageRuntime, setIMessageRuntime };
const { setRuntime: setIMessageRuntime } = createPluginRuntimeStore<PluginRuntime>({
pluginId: "imessage",
errorMessage: "iMessage runtime not initialized",
});
export { setIMessageRuntime };

View File

@@ -9,7 +9,7 @@ import { resolveIMessageAccount, type ResolvedIMessageAccount } from "./accounts
import { createIMessageRpcClient, type IMessageRpcClient } from "./client.js";
import { formatIMessageChatTarget, type IMessageService, parseIMessageTarget } from "./targets.js";
export type IMessageSendOpts = {
type IMessageSendOpts = {
cliPath?: string;
dbPath?: string;
service?: IMessageService;
@@ -36,7 +36,7 @@ export type IMessageSendOpts = {
createClient?: (params: { cliPath: string; dbPath?: string }) => Promise<IMessageRpcClient>;
};
export type IMessageSendResult = {
type IMessageSendResult = {
messageId: string;
sentText: string;
};

View File

@@ -67,7 +67,7 @@ function buildIMessageSetupPatch(input: {
};
}
export async function promptIMessageAllowFrom(params: {
async function promptIMessageAllowFrom(params: {
cfg: OpenClawConfig;
prompter: WizardPrompter;
accountId?: string;

View File

@@ -9,7 +9,6 @@ import {
createIMessageCliPathTextInput,
imessageCompletionNote,
imessageDmPolicy,
imessageSetupAdapter,
imessageSetupStatusBase,
parseIMessageAllowFromEntries,
} from "./setup-core.js";
@@ -43,4 +42,4 @@ export const imessageSetupWizard: ChannelSetupWizard = {
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false),
};
export { imessageSetupAdapter, parseIMessageAllowFromEntries };
export { parseIMessageAllowFromEntries };

View File

@@ -20,7 +20,7 @@ import {
} from "./media-contract.js";
import { createIMessageSetupWizardProxy } from "./setup-core.js";
export const IMESSAGE_CHANNEL = "imessage" as const;
const IMESSAGE_CHANNEL = "imessage" as const;
async function loadIMessageChannelRuntime() {
return await import("./channel.runtime.js");
@@ -30,7 +30,7 @@ export const imessageSetupWizard = createIMessageSetupWizardProxy(
async () => (await loadIMessageChannelRuntime()).imessageSetupWizard,
);
export const imessageConfigAdapter = createScopedChannelConfigAdapter<ResolvedIMessageAccount>({
const imessageConfigAdapter = createScopedChannelConfigAdapter<ResolvedIMessageAccount>({
sectionKey: IMESSAGE_CHANNEL,
listAccountIds: listIMessageAccountIds,
resolveAccount: adaptScopedAccountAccessor(resolveIMessageAccount),