import { M as ChannelSecurityDmPolicy } from "./types.core-CuC3Nb15.js"; import { i as OpenClawConfig } from "./types.openclaw-CpnoYlBx.js"; import { G as ConfigWriteScopeLike, K as ConfigWriteTargetLike, W as ConfigWriteAuthorizationResultLike, g as ChannelConfigAdapter } from "./types.adapters-BFws9krA.js"; import { t as buildAccountScopedDmSecurityPolicy } from "./helpers-Ri6kqUP5.js"; import { a as DmAccessRecord, c as normalizeLegacyDmAliases, d as resolveChannelDmPolicy, f as setCanonicalDmAllowFrom, l as resolveChannelDmAccess, n as ChannelDmAllowFromMode, o as ensureOpenDmPolicyAllowFromWildcard, r as ChannelDmPolicy, s as normalizeChannelDmPolicy, t as ChannelDmAccess, u as resolveChannelDmAllowFrom } from "./dm-access-BLdoaTNe.js"; //#region src/plugin-sdk/channel-config-helpers.d.ts /** Origin scope used when authorizing channel config writes. */ type ConfigWriteScope = ConfigWriteScopeLike; /** Target account/channel for a config write authorization check. */ type ConfigWriteTarget = ConfigWriteTargetLike; /** Decision returned by channel config write policy helpers. */ type ConfigWriteAuthorizationResult = ConfigWriteAuthorizationResultLike; type ChannelCrudConfigAdapter = Pick, "listAccountIds" | "resolveAccount" | "inspectAccount" | "defaultAccountId" | "setAccountEnabled" | "deleteAccount">; type ChannelConfigAdapterWithAccessors = Pick, "listAccountIds" | "resolveAccount" | "inspectAccount" | "defaultAccountId" | "setAccountEnabled" | "deleteAccount" | "resolveAllowFrom" | "formatAllowFrom" | "resolveDefaultTo">; /** Returns whether config writes are enabled for a channel/account target. */ declare function resolveChannelConfigWrites(params: { cfg: OpenClawConfig; channelId?: string | null; accountId?: string | null; }): boolean; /** Authorizes a channel config mutation against origin and target policy. */ declare function authorizeConfigWrite(params: { cfg: OpenClawConfig; origin?: ConfigWriteScope; target?: ConfigWriteTarget; allowBypass?: boolean; }): ConfigWriteAuthorizationResult; /** Returns true when trusted internal message scopes can bypass config write policy. */ declare function canBypassConfigWritePolicy(params: { channel?: string | null; gatewayClientScopes?: string[] | null; }): boolean; /** Formats the denial message shown when config write authorization fails. */ declare function formatConfigWriteDeniedMessage(params: { result: Exclude; fallbackChannelId?: string | null; }): string; type ChannelConfigAccessorParams = { cfg: Config; accountId?: string | null; }; type MultiAccountChannelConfigAdapterParams = { sectionKey: string; listAccountIds: (cfg: Config) => string[]; resolveAccount: (cfg: Config, accountId?: string | null) => ResolvedAccount; resolveAccessorAccount?: (params: ChannelConfigAccessorParams) => AccessorAccount; defaultAccountId: (cfg: Config) => string; inspectAccount?: (cfg: Config, accountId?: string | null) => unknown; clearBaseFields: string[]; resolveAllowFrom: (account: AccessorAccount) => Array | null | undefined; formatAllowFrom: (allowFrom: Array) => string[]; resolveDefaultTo?: (account: AccessorAccount) => string | number | null | undefined; }; type NamedAccountChannelConfigBaseParams = { sectionKey: string; listAccountIds: (cfg: Config) => string[]; resolveAccount: (cfg: Config, accountId?: string | null) => ResolvedAccount; defaultAccountId: (cfg: Config) => string; inspectAccount?: (cfg: Config, accountId?: string | null) => unknown; clearBaseFields: string[]; }; /** Coerce mixed allowlist config values into plain strings without trimming or deduping. */ declare function mapAllowFromEntries(allowFrom: Array | null | undefined): string[]; /** Normalize user-facing allowlist entries the same way config and doctor flows expect. */ declare function formatTrimmedAllowFromEntries(allowFrom: Array): string[]; /** Collapse nullable config scalars into a trimmed optional string. */ declare function resolveOptionalConfigString(value: string | number | null | undefined): string | undefined; /** Adapt `{ cfg, accountId }` accessors to callback sites that pass positional args. */ declare function adaptScopedAccountAccessor(accessor: (params: { cfg: Config; accountId?: string | null; }) => Result): (cfg: Config, accountId?: string | null) => Result; /** Build the shared allowlist/default target adapter surface for account-scoped channel configs. */ declare function createScopedAccountConfigAccessors(params: { /** Resolves the account used by read-only config accessors from `{ cfg, accountId }`. */resolveAccount: (params: { cfg: Config; accountId?: string | null; }) => ResolvedAccount; /** Reads raw allowlist entries from the resolved account. */ resolveAllowFrom: (account: ResolvedAccount) => Array | null | undefined; /** Formats allowlist entries for display or config inspection. */ formatAllowFrom: (allowFrom: Array) => string[]; /** Optional default destination selector; omitted when the channel has no default target. */ resolveDefaultTo?: (account: ResolvedAccount) => string | number | null | undefined; }): Pick, "resolveAllowFrom" | "formatAllowFrom" | "resolveDefaultTo">; /** Build the common CRUD/config helpers for channels that store multiple named accounts. */ declare function createScopedChannelConfigBase(params: NamedAccountChannelConfigBaseParams & { allowTopLevel?: boolean; }): ChannelCrudConfigAdapter; /** Build the full shared config adapter for account-scoped channels with allowlist/default target accessors. */ declare function createScopedChannelConfigAdapter(params: MultiAccountChannelConfigAdapterParams & { allowTopLevel?: boolean; }): ChannelConfigAdapterWithAccessors; /** Build CRUD/config helpers for top-level single-account channels. */ declare function createTopLevelChannelConfigBase(params: { sectionKey: string; resolveAccount: (cfg: Config) => ResolvedAccount; listAccountIds?: (cfg: Config) => string[]; defaultAccountId?: (cfg: Config) => string; inspectAccount?: (cfg: Config) => unknown; deleteMode?: "remove-section" | "clear-fields"; clearBaseFields?: string[]; }): Pick, "listAccountIds" | "resolveAccount" | "inspectAccount" | "defaultAccountId" | "setAccountEnabled" | "deleteAccount">; /** Build the full shared config adapter for top-level single-account channels with allowlist/default target accessors. */ declare function createTopLevelChannelConfigAdapter(params: { sectionKey: string; resolveAccount: (cfg: Config) => ResolvedAccount; resolveAccessorAccount?: (params: { cfg: Config; accountId?: string | null; }) => AccessorAccount; listAccountIds?: (cfg: Config) => string[]; defaultAccountId?: (cfg: Config) => string; inspectAccount?: (cfg: Config) => unknown; deleteMode?: "remove-section" | "clear-fields"; clearBaseFields?: string[]; resolveAllowFrom: (account: AccessorAccount) => Array | null | undefined; formatAllowFrom: (allowFrom: Array) => string[]; resolveDefaultTo?: (account: AccessorAccount) => string | number | null | undefined; }): ChannelConfigAdapterWithAccessors; /** Build CRUD/config helpers for channels where the default account lives at channel root and named accounts live under `accounts`. */ declare function createHybridChannelConfigBase(params: NamedAccountChannelConfigBaseParams & { preserveSectionOnDefaultDelete?: boolean; }): ChannelCrudConfigAdapter; /** Build the full shared config adapter for hybrid channels with allowlist/default target accessors. */ declare function createHybridChannelConfigAdapter(params: MultiAccountChannelConfigAdapterParams & { preserveSectionOnDefaultDelete?: boolean; }): ChannelConfigAdapterWithAccessors; /** Convert account-specific DM security fields into the shared runtime policy resolver shape. */ declare function createScopedDmSecurityResolver(params: { channelKey: string; resolvePolicy: (account: ResolvedAccount) => string | null | undefined; resolveAllowFrom: (account: ResolvedAccount) => Array | null | undefined; resolveAccess?: (params: { cfg: OpenClawConfig; accountId?: string | null; account: ResolvedAccount; }) => { dmPolicy?: string | null; allowFrom?: Array | null; }; resolveFallbackAccountId?: (account: ResolvedAccount) => string | null | undefined; defaultPolicy?: string; allowFromPathSuffix?: string; policyPathSuffix?: string; approveChannelId?: string; approveHint?: string; normalizeEntry?: (raw: string) => string; inheritSharedDefaultsFromDefaultAccount?: boolean; }): ({ cfg, accountId, account }: { cfg: OpenClawConfig; accountId?: string | null; account: ResolvedAccount; }) => ChannelSecurityDmPolicy; //#endregion export { type ChannelDmAccess, type ChannelDmAllowFromMode, type ChannelDmPolicy, ConfigWriteAuthorizationResult, ConfigWriteScope, ConfigWriteTarget, type DmAccessRecord, adaptScopedAccountAccessor, authorizeConfigWrite, buildAccountScopedDmSecurityPolicy, canBypassConfigWritePolicy, createHybridChannelConfigAdapter, createHybridChannelConfigBase, createScopedAccountConfigAccessors, createScopedChannelConfigAdapter, createScopedChannelConfigBase, createScopedDmSecurityResolver, createTopLevelChannelConfigAdapter, createTopLevelChannelConfigBase, ensureOpenDmPolicyAllowFromWildcard, formatConfigWriteDeniedMessage, formatTrimmedAllowFromEntries, mapAllowFromEntries, normalizeChannelDmPolicy, normalizeLegacyDmAliases, resolveChannelConfigWrites, resolveChannelDmAccess, resolveChannelDmAllowFrom, resolveChannelDmPolicy, resolveOptionalConfigString, setCanonicalDmAllowFrom };