attachments.py

A server module that handles uploaded chat files, including identifying their file type, storing them, serving image previews, and transcribing audio uploads. MIME type means the label that tells software whether a file is an image, document, audio file, or another format.

In plain words
What is it for?
Use it for multipart chat uploads, file-ID based retrieval, raw image-thumbnail responses, MIME detection, audio and video container handling, and automatic transcription of audio files.
Why use it?
It keeps chat uploads separate from general file storage and makes file classification consistent across different upload paths. It also ensures spoken content from audio uploads is made available to the agent.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/netmindai-open/narranexus/attachments.py
Clone the repo
git clone --depth 1 https://github.com/NetMindAI-Open/NarraNexus
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,380 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01380
Opus 5 $0.00000 $0.00690
Sonnet 5 $0.00000 $0.00276
Haiku 4.5 $0.00000 $0.00138

Measured 2d ago against content hash b80b611a08a4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

attachments.py scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.mindflow/mirror/backend/routes/agents/attachments.py.md · 124 lines

How it starts

The opening of the file, as written. The whole thing — 124 lines — stays where its author put it; the contents beside it link to each section on GitHub.

2026-07-22 — MIME sniffing moved to the shared utils helper

The local _sniff_mime_type + _audio_video_container_override pair moved to [[mime_sniff]] so all three upload/ingest paths (this route, IM channels, team-chat uploads) classify identically. One behavior delta: a libmagic application/octet-stream verdict now falls through to the extension guess instead of winning outright, so extension-typed text formats (.md, .csv) get their real MIME. The container override semantics are unchanged.

agents/attachments.py

Why it exists

HTTP boundary for the chat-attachment lifecycle: a multipart upload that returns a server-issued file_id, plus a raw-bytes endpoint the frontend uses to render image thumbnails inline. Kept separate from agents/files.py because chat attachments have a different storage shape (date-partitioned subdirs + sidecar index) and a different access pattern (referenced by file_id, not browsed by name).

Whisper transcription runs for every audio/* upload regardless of how the user produced it — the agent must always receive the spoken content via the system-prompt attachment marker, whether the clip came from in-browser dictation or from a file the user attached. The route's source query parameter is purely a frontend-render hint, normalised on the way out and echoed back so the persisted attachment dict carries it through chat history reload:

  • source=recording — the in-browser AudioRecorder produced a voice memo. Frontend renders VoiceTranscript (transcript text in place of the message bubble).
  • omitted / source=upload / anything else — Paperclip / drag-drop / paste. Frontend renders an ordinary file chip; the transcript still reaches the agent via the system prompt but is not surfaced in the UI (the user attached a file, they didn't dictate, so showing the transcript would be confusing).

Transcription routes through the same OpenAI-protocol provider system that powers chat (UserProviderServiceSystemProviderServicesettings.openai_api_key), so any user with a compatible provider gets transcription "for free". Failures never break the upload — they degrade to transcript=null and the response also exposes transcription_available so the frontend can surface a "voice unavailable" message specifically on the recording path.

Read the full file on GitHub · 124 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 124 lines · 0 tokens per session scan A b80b611a08a4

Subscribe to this mod's changes

attachments.py is an agent published in the GitHub repository NetMindAI-Open/NarraNexus (84 stars, last pushed 9d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,380 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

pixel-art-animation-reviewer

Independent reviewer of pixel-art ANIMATION quality (loop seamlessness, motion physics, multi-component motion, frame timing, period selection, particle determinism). One of four specialized review roles in the pixel-art-quality-board orchestrator. Use when the user asks to "check animation timing", "verify loop…

AnastasiyaW/codex-claude-code-config · 140 tokens

45-corporate-development

You are the Head of Corporate Development. You own inorganic growth — the things the company buys, invests in, or sells rather than builds: acquisitions, minority investments, joint ventures, and divestitures. Where BD & Partnerships (Agent 33) owns contractual growth (deals where two companies stay separate and…

ankitjha67/product-architect · 0 tokens

codex-second-opinion

Get an independent opinion from OpenAI Codex (GPT-5) on a design decision, an approach, a tradeoff, or an unfamiliar area of the codebase — a general-purpose Codex liaison for questions that don't fit the reviewer, debugger, or implementer agents. Use when the user asks to "ask Codex", wants Claude's work…

Sateezg/codex-bridge · 91 tokens

alchemist

Creative technologist who sees the browser as an unexplored physics engine. Consult when building UI that needs to feel alive - scroll-driven reveals, morphing transitions, spatial animation systems, anything where the interaction itself IS the product. Thinks in weight, tension, and breath before thinking in code.…

drobins25/craft · 355 tokens

designer

Ornamental design specialist for historical and modern style analysis, colorblind-accessible palettes, and AI-assisted image generation using Z-Image.

pjt222/agent-almanac · 29 tokens

AGENTS.motiscope

Agent "AGENTS.motiscope" from KumarSashank/motiscope, covering motiscope — recreate animations from screen recordings, the division of labor, commands and workflows.

KumarSashank/motiscope · 0 tokens