/** * Settings › Channels on the server: what each mounted channel needs, where * each credential comes from, and the owner/admin operations the page and the * agent both run through `list-messaging-channels` and * `manage-messaging-channel`. * * Credentials saved here are workspace-scoped secrets for the organization * (or `solo:` without one), which is where `resolveSecret` looks for * them both in Settings requests and in webhooks, which run as the admin who * turned the channel on. Nothing here depends on a template declaring the * keys, so every app can set up every channel it mounts. */ import { type ActionRunContext } from "../action.js"; import type { SecretScope } from "../secrets/register.js"; export declare const CHANNEL_MANAGE_DENIED = "Only organization owners and admins can set up channels."; export type ChannelState = "on" | "off" | "not-set-up" | "unavailable"; /** * `saved`: saved from Channels for this workspace. `environment`: the * deployment's environment. `elsewhere`: another saved key answers, such as * a personal key or an organization vault key. */ export type ChannelCredentialSource = "saved" | "environment" | "elsewhere" | "unreadable"; export interface ChannelCredentialStatus { key: string; label: string; required: boolean; helpText?: string; /** False when the adapter reads the key only from the deployment. */ saveable: boolean; /** Where the value comes from; null when unset. Always null for members. */ source: ChannelCredentialSource | null; /** Saved from Channels or exactly readable as a Channels-managed row. */ removable: boolean; /** Scope where the unreadable ciphertext was found. */ unreadableScope?: SecretScope; /** Scope where replacement will be written; `user` is the caller's own row. */ repairScope?: SecretScope; /** Exact scope of the credential offered for removal. */ removalScope?: SecretScope; } export interface MessagingChannelStatus { platform: string; label: string; /** On only when both enabled and configured. */ state: ChannelState; enabled: boolean; configured: boolean; /** True when stored credentials prevented the adapter from checking setup. */ configurationUnavailable?: boolean; /** Null when the app's public URL isn't known for this call. */ webhookUrl: string | null; details?: Record; error?: string; credentials: ChannelCredentialStatus[]; } export interface MessagingChannelsStatus { /** Owners and admins, or the only user of a workspace without an org. */ canManage: boolean; channels: MessagingChannelStatus[]; } export declare function listMessagingChannels(ctx: ActionRunContext | undefined): Promise; export interface ChannelCredentialRemovalCandidate { key: string; candidate: string; removalScope: SecretScope; } export interface ChannelCredentialRemovalConfirmation { key: string; removalConfirmation: string; } export declare function prepareMessagingChannelCredentialRemoval(ctx: ActionRunContext | undefined, platform: string, keys: readonly string[]): Promise<{ credentials: ChannelCredentialRemovalCandidate[]; }>; export declare function confirmMessagingChannelCredentialRemoval(ctx: ActionRunContext | undefined, platform: string, candidates: readonly Pick[]): Promise<{ credentials: ChannelCredentialRemovalConfirmation[]; }>; export interface ChannelChangeResult { channel: MessagingChannelStatus; message: string; } export declare function setMessagingChannelEnabled(ctx: ActionRunContext | undefined, platform: string, enabled: boolean): Promise; export declare function saveMessagingChannelCredentials(ctx: ActionRunContext | undefined, platform: string, values: Record): Promise; export declare function removeMessagingChannelCredentials(ctx: ActionRunContext | undefined, platform: string, confirmedCredentials: readonly { key: string; removalConfirmation: string; }[]): Promise; export declare function registerMessagingChannelWebhook(ctx: ActionRunContext | undefined, platform: string): Promise;