UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

63 lines • 3.51 kB
import { type ChannelFetch } from '../http.js'; import type { ChannelAdapter } from '../types.js'; export interface EvolutionApiOptions { /** * The Evolution API server — `https://evolution.example.com`. A compatible host that serves the * same routes under a prefix takes it here (`https://evolution.example.com/api`). */ url: string; /** The instance (the connected WhatsApp number) to send from and accept webhooks for. */ instance: string; /** The `apikey` header — the instance token or the global key. */ apiKey: string; /** * The secret a webhook must carry: as `?token=` in the webhook URL, a `:token` route param, an * `Authorization: Bearer` header or an `x-webhook-token` header. Evolution signs nothing, so this * token is the only thing standing between the route and anyone who wants to post as any phone * number. `false` turns the check off — only for a server that cannot be reached from outside. */ webhookToken: string | false; /** * Send proposals with reply buttons (`POST /message/sendButtons/{instance}`). Off by default: * Evolution (Baileys) sends them as a `nativeFlow` interactive message that WhatsApp did not show * at all in our test (2.3.7, Android recipient) — while Evolution still reported it sent. For * Whatsmiau, whose buttons render, use `whatsmiau()` (buttons on). The buttons message carries the * text instruction too ("Reply *yes* to confirm…"), for a phone that shows the text but not the * buttons; a 4xx from that endpoint falls back to the text-only message. */ buttons?: boolean; /** Answer messages in groups too (the sender is the participant). Default `false`. */ groups?: boolean; /** Longest message text. Default 4096. */ maxLength?: number; /** The adapter's name — the dedupe prefix and the decision's `via`. Default `'whatsapp'`. */ name?: string; /** Per-request timeout. Default 20 s. */ timeoutMs?: number; fetch?: ChannelFetch; } /** * WhatsApp through [Evolution API](https://doc.evolution-api.com) v2 (or a server with the same * routes). Point the instance's webhook — event `MESSAGES_UPSERT` — at the route, with the token: * `https://app.example.com/webhooks/whatsapp?token=<webhookToken>`. * * Reads `messages.upsert` (text, extended text, button and list replies, images, audio, video, * documents and stickers); ignores the instance's own messages (an item without `fromMe` counts as * incoming only with `status: 'received'`), broadcasts and (unless `groups`) groups. Sends with `POST {url}/message/sendText/{instance}`. Downloads media from the webhook's * inline `base64` (Evolution's "webhook base64" setting), else its `mediaUrl`, else * `POST {url}/chat/getBase64FromMediaMessage/{instance}`. */ export declare function evolutionApi(options: EvolutionApiOptions): ChannelAdapter; /** * The adapter for any server speaking Evolution's webhook and routes — `evolutionApi()` and * `whatsmiau()` differ only in their defaults. Internal. */ export declare function evolutionFormatAdapter(options: EvolutionApiOptions, defaults: { buttons: boolean; /** * Put the reply instruction in the buttons message too — for a server whose buttons may not * render (Evolution). Off where they render (Whatsmiau): the card shows the buttons alone. */ instructionWithButtons: boolean; }): ChannelAdapter; //# sourceMappingURL=evolution_api.d.ts.map