openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
104 lines • 4.61 kB
TypeScript
import { r as OpenClawConfig } from "./types.openclaw-BdCLfP4c.js";
import { n as ChannelApprovalKind } from "./approval-types-ClyNB7BE.js";
import "./config-runtime-BcJv7C4y.js";
//#region src/plugin-sdk/approval-approvers.d.ts
type ApproverInput$1 = string | number;
/** Resolves explicit approvers first, then allow-from/default fallbacks with dedupe. */
declare function resolveApprovalApprovers(params: {
explicit?: readonly ApproverInput$1[] | null;
allowFrom?: readonly ApproverInput$1[] | null;
extraAllowFrom?: readonly ApproverInput$1[] | null;
defaultTo?: string | null;
normalizeApprover: (value: ApproverInput$1) => string | undefined;
normalizeDefaultTo?: (value: string) => string | undefined;
}): string[];
//#endregion
//#region src/plugin-sdk/approval-auth-helpers.d.ts
type ApproverInput = string | number;
type ApprovalApproverInputs = {
explicit?: readonly ApproverInput[] | null;
allowFrom?: readonly ApproverInput[] | null;
extraAllowFrom?: readonly ApproverInput[] | null;
defaultTo?: string | null;
};
type ApprovalContext = {
cfg: OpenClawConfig;
accountId?: string | null;
};
type ApprovalActorContext = ApprovalContext & {
senderId?: string | null;
};
type ChannelApprovalAuth = {
resolveApprovers: (context: ApprovalContext) => string[];
isAuthorizedSender: (context: ApprovalActorContext) => boolean;
approvalAuth: ReturnType<typeof createResolvedApproverActionAuthAdapter>;
};
type ApprovalAuthorizationResult = {
/** Whether the actor may perform the approval action. */
authorized: boolean;
/** User-facing denial reason when authorization fails. */
reason?: string;
};
/**
* Marks an authorization result as the implicit same-chat fallback used when a
* channel has no configured approver allowlist.
*/
declare function markImplicitSameChatApprovalAuthorization(
/** Authorization result to tag as the empty-approver same-chat fallback. */
result: ApprovalAuthorizationResult): ApprovalAuthorizationResult;
/**
* Checks whether an authorization result came from the implicit same-chat
* fallback instead of an explicitly configured approver allowlist.
*/
declare function isImplicitSameChatApprovalAuthorization(
/** Authorization result returned by approval auth helpers. */
result: ApprovalAuthorizationResult | null | undefined): boolean;
/**
* Builds the approval authorization adapter shared by channels that resolve
* approvers from account-scoped config.
*/
declare function createResolvedApproverActionAuthAdapter(params: {
/** Human-readable channel label used in denial messages. */
channelLabel: string;
/** Resolves normalized approver ids from config and optional account scope. */
resolveApprovers: (params: {
cfg: OpenClawConfig;
accountId?: string | null;
}) => string[];
/** Optional sender normalizer; defaults to trimmed string normalization. */
normalizeSenderId?: (value: string) => string | undefined;
}): {
authorizeActorAction({ cfg, accountId, senderId, approvalKind }: {
/** Full config used to resolve account-scoped approvers. */
cfg: OpenClawConfig;
/** Optional channel account id for account-scoped approver config. */
accountId?: string | null;
/** Actor attempting the approval action. */
senderId?: string | null;
/** Approval action being authorized. */
action: "approve";
/** Approval kind used in user-facing denial copy. */
approvalKind: ChannelApprovalKind;
}): ApprovalAuthorizationResult | {
readonly authorized: true;
readonly reason?: undefined;
} | {
readonly authorized: false;
readonly reason: `\u274C You are not authorized to approve exec requests on ${string}.` | `\u274C You are not authorized to approve plugin requests on ${string}.` | `\u274C You are not authorized to approve system-agent requests on ${string}.`;
};
};
declare function createChannelApprovalAuth(params: {
channelLabel: string;
resolveInputs: (params: ApprovalContext) => ApprovalApproverInputs;
normalizeApprover: (value: ApproverInput) => string | undefined;
normalizeDefaultTo?: (value: string) => string | undefined;
normalizeSenderId?: (value: string) => string | undefined;
isWildcardAuthorized?: (params: {
purpose: "sender" | "action";
senderId?: string;
inputs: ApprovalApproverInputs;
approvers: readonly string[];
}) => boolean;
}): ChannelApprovalAuth;
//#endregion
export { resolveApprovalApprovers as a, markImplicitSameChatApprovalAuthorization as i, createResolvedApproverActionAuthAdapter as n, isImplicitSameChatApprovalAuthorization as r, createChannelApprovalAuth as t };