import { n as Principal } from "./context-Ewez0LPe.js"; import { InboundEvent, ProactiveTrigger } from "./agent-runtime.js"; import { Channel, ChannelContext, DeliveryTarget } from "./agent-config.js"; //#region src/channels.d.ts declare function tryParseJson(body: string): T | undefined; declare function timestampFresh(ts: string, toleranceSec?: number): boolean; export declare function verifySlackSignature(signingSecret: string, timestamp: string, body: string, signature: string): Promise; export declare function verifyCrispSignature(signingSecret: string, timestamp: string, body: string, signature: string): Promise; export type ChannelObserver = (e: { raw: unknown; event?: InboundEvent; }, ctx: ChannelContext) => Promise | void; export type ChannelMode = "respond" | "observe"; export type KindObserver = (event: InboundEvent, ctx: ChannelContext) => Promise | void; export type ChannelRejection = { kind: "bad_signature" | "malformed_body" | "unrouted_interaction"; detail?: string; }; type ChannelExtensions = { mode?: ChannelMode; accept?: (raw: unknown) => boolean; onEvent?: ChannelObserver; onRejected?: (rejection: ChannelRejection, req: Request) => void; }; export type SlackDiagnosis = { auth: { ok: boolean; error?: string; team?: string; botUserId?: string; }; scopes: { granted: string[]; missing: { scope: string; neededFor: string; }[]; }; counters: { since: number; eventsReceived: Record; interactions: { claimed: number; appHandled: number; unrouted: number; }; rejections: Record; duplicates: number; }; hints: string[]; }; export declare function resetSlackCounters(path?: string): void; export declare function httpChannel(opts?: { path?: string; mcp?: (req: Request) => Promise; }): Channel; export type SlackEventKind = "message" | "app_mention" | "reaction_added" | "reaction_removed"; export type SlackChannelType = "channel" | "group" | "im" | "mpim" | "unknown"; export type SlackNormalizedEvent = InboundEvent & { /** From the event's `channel_type`. `app_mention` events don't carry one: `"unknown"`. Neither do reactions. Either reads `"im"` in a `D…` (DM) channel. */ channelType: SlackChannelType; }; export type SlackFeedback = { rating: "positive" | "negative"; turnId?: string; session?: string; user?: { id: string; }; channelId?: string; threadId?: string; messageTs?: string; }; export declare const feedbackBlocks: (turnId?: string, session?: string) => { type: string; elements: { type: string; action_id: string; positive_button: { text: { type: string; text: string; }; value: string; }; negative_button: { text: { type: string; text: string; }; value: string; }; }[]; }[]; export type SlackIdentity = { userId?: string; /** The ENVELOPE workspace (app installation) — NOT proof of the sender's membership. */ teamId?: string; /** The sender's home workspace, when Slack includes it on the event; absent ⇒ unproven. */ senderTeamId?: string; channelId: string; threadId?: string; kind: SlackEventKind; ts: string; }; export declare function slackChannel(opts: { signingSecret: string; botToken: string; path?: string; apiUrl?: string; events?: SlackEventKind[]; respondTo?: SlackEventKind[]; /** Per event: whether a kind listed in `respondTo` gets a turn. Observers still fire. Default: always. */ respondWhen?: (event: SlackNormalizedEvent, raw: unknown) => boolean; on?: Partial Promise | void>>; botUserId?: string; resolveIdentity?: (identity: SlackIdentity, ctx: ChannelContext) => Promise | Principal | null | undefined; stream?: boolean; status?: string; feedback?: boolean; onFeedback?: (feedback: SlackFeedback, ctx: ChannelContext) => void | Promise; approvalConfirm?: boolean; replaceInFlight?: boolean; onInteraction?: (payload: SlackInteraction, ctx: ChannelContext) => void | Promise; tasks?: (call: { id: string; name: string; input: unknown; }) => string | undefined; taskDisplayMode?: "timeline" | "plan" | "dense"; intermediateText?: "answer" | "status"; onError?: (err: unknown) => void; } & ChannelExtensions): Channel & { diagnose: () => Promise; }; export declare function receive(channel: Channel, ctx: ChannelContext, opts: { seed: string; target: DeliveryTarget; trigger: ProactiveTrigger; session: string; turnId?: string; }): Promise; type SlackEvent = { type?: string; bot_id?: string; subtype?: string; text?: string; channel?: string; ts?: string; thread_ts?: string; channel_type?: string; user?: string; reaction?: string; item?: { type?: string; channel?: string; ts?: string; }; }; type SlackInteraction = { type?: string; user?: { id?: string; }; channel?: { id?: string; }; message?: { ts?: string; thread_ts?: string; }; actions?: { action_id?: string; value?: string; }[]; response_url?: string; }; export declare function normalizeSlackEvent(e: SlackEvent, events: SlackEventKind[], botUserId?: string, teamId?: string): { event: SlackNormalizedEvent; session: string; userText: string; } | null; export type CrispWebhookAuth = { type: "signature"; secret: string; } | { type: "urlKey"; key: string; param?: string; }; export declare function verifyCrispUrlKey(expectedKey: string, url: string, param?: string): boolean; type CrispAuthOpts = { auth: CrispWebhookAuth; signingSecret?: never; } | { auth?: never; signingSecret: string; }; export type CrispMessageType = "text" | "file" | "animation" | "audio" | "picker" | "field" | "carousel" | "note" | "event"; export type CrispUser = { user_id?: string; nickname?: string; }; type CrispMessageData = { website_id?: string; session_id?: string; from?: "user" | "operator"; type?: CrispMessageType; content?: unknown; fingerprint?: number; user?: CrispUser; timestamp?: number; }; export type CrispEventPayloads = { "message:send": CrispMessageData; "message:received": CrispMessageData; "message:updated": { website_id?: string; session_id?: string; fingerprint?: number; content?: unknown; }; "message:removed": { website_id?: string; session_id?: string; fingerprint?: number; }; "session:set_state": { website_id?: string; session_id?: string; state?: "pending" | "unresolved" | "resolved"; }; "session:sync:rating": { website_id?: string; session_id?: string; rating?: { stars?: number; comment?: string; }; }; "session:removed": { website_id?: string; session_id?: string; }; }; export type CrispEventName = keyof CrispEventPayloads; export type CrispWebhookEnvelope = { website_id?: string; event?: string; data?: unknown; timestamp?: number; }; export declare function isCrispEvent(payload: unknown, event: E): payload is CrispWebhookEnvelope & { event: E; data: CrispEventPayloads[E]; timestamp?: number; }; export type CrispEventKind = "message" | "message_changed" | "state_changed" | "rating"; export declare function normalizeCrispEvent(payload: { event?: string; data?: unknown; }, events: CrispEventKind[]): { event: InboundEvent; session: string; userText: string; } | null; export type CrispVerification = { identity?: string; method?: string; annotation?: string; }; export type CrispIdentity = { websiteId: string; sessionId: string; fetched: boolean; verified: boolean; email?: string; method?: string; verifications: CrispVerification[]; meta: { nickname?: string; email?: string; data?: Record; }; }; export declare function deriveCrispIdentity(conversation: { verifications?: CrispVerification[] | null; meta?: CrispIdentity["meta"] | null; } | undefined, target: { websiteId: string; sessionId: string; fetched?: boolean; }): CrispIdentity; export declare function crispChannel(opts: CrispAuthOpts & { identifier: string; key: string; tier?: "plugin" | "website"; path?: string; apiUrl?: string; resolveIdentity?: (identity: CrispIdentity, ctx: ChannelContext) => Promise | Principal | null | undefined; events?: CrispEventKind[]; respondTo?: CrispEventKind[]; replyAs?: "message" | "note"; on?: Partial>; onError?: (err: unknown) => void; } & ChannelExtensions): Channel; //#endregion export { type DeliveryTarget, type InboundEvent, timestampFresh, tryParseJson };