/** * Inbound file transport for Teams. A Teams message can carry uploaded files; * this turns them into AG-UI multimodal content the agent's model can read — * images and PDFs as their respective binary parts, and text/CSV/JSON as * decoded `text` parts. This is what makes the "upload a CSV → get a chart" * flow work: the CSV arrives as text the model can parse before it calls a * render tool. Mirrors `@copilotkit/channels-slack`'s `buildFileContentParts`. * * Teams delivers files two ways, and we handle both: * - Channel/chat file uploads arrive as an attachment of contentType * `application/vnd.microsoft.teams.file.download.info`, whose `content` * holds a pre-authenticated `downloadUrl` (no bearer token needed) plus a * `fileType`. We download from `downloadUrl`. * - Inline media (and the M365 Agents Playground) arrives as an attachment * whose `contentType` is the media MIME and `contentUrl` is either a * `data:` URI (decoded in-process) or an https URL (fetched directly). * * The bridge is transport-only: it delivers the bytes/text to the agent and * lets the app decide what to do with them. Anything it can't represent is * skipped with a short note so the agent knows a file was dropped and why. */ import type { AgentContentPart } from "@copilotkit/channels-ui"; /** The subset of a Teams `Attachment` we read (matches @microsoft/agents-activity). */ export interface TeamsAttachmentRef { contentType: string; contentUrl?: string; /** `file.download.info` attachments carry the real source here. */ content?: unknown; name?: string; } /** Tunables for inbound file handling (all optional; sane defaults). */ export interface FileDeliveryConfig { /** Skip a single file larger than this many bytes. Default 8 MiB. */ maxBytesPerFile?: number; /** Process at most this many files per message. Default 5. */ maxFiles?: number; /** Truncate decoded text files to this many bytes. Default 200 KiB. */ maxTextBytes?: number; } /** Best-effort MIME from a filename's extension, or undefined if unknown. */ export declare function mimeFromName(name: string | undefined): string | undefined; /** * Turn downloaded bytes into a single AG-UI content part, or a skip `note` when * the type is unsupported or the file exceeds the byte cap. Shared by the * attachment path (this module) and the Graph channel path (`graph-files.ts`) * so both classify and truncate identically. */ export declare function decodeFileBytes(label: string, mime: string, bytes: Buffer, config?: FileDeliveryConfig): { part: AgentContentPart; } | { note: string; }; /** * Download a message's attachments and turn them into AG-UI content parts. * Returns the parts plus human-readable `notes` for anything skipped (appended * to the message as a text part by the caller). */ export declare function buildFileContentParts(attachments: readonly TeamsAttachmentRef[], config?: FileDeliveryConfig): Promise<{ parts: AgentContentPart[]; notes: string[]; }>; //# sourceMappingURL=download-files.d.ts.map