email-imap-fetch — скилл для Claude Code: что делает и как установить
Слушает ящики по IMAP через IDLE или опрос, забирает сниппеты непрочитанных писем и шлёт их в вебхуки OpenClaw.
npx skills add tiangong-ai/agent-skills --skill email-imap-fetch -a claude-codeЧто делает email-imap-fetch
Скрипт scripts/imap_idle_fetch.py отслеживает новые письма в одном или нескольких IMAP-аккаунтах. Он работает в режиме маршрутизации первого этапа: извлекает метаданные (uid, тему, отправителя, дату), текстовый сниппет и манифест вложений. Тело письма целиком и бинарные файлы вложений скилл не передаёт.
По умолчанию включён безопасный опрос poll, но через переменную окружения IMAP_IDLE_MODE=idle можно задействовать push-события сервера. Вывод пишется построчно в формате JSONL. Доставка событий в OpenClaw идёт через HTTP POST с фиксированными блоками <<<MAIL_REF_JSON>>> и <<<ATTACHMENT_MANIFEST_JSON>>>.
В интерактивной сессии терминала фоновый процесс останавливается сразу после закрытия консоли. Для непрерывной работы в продакшене скрипт нужно запускать через systemd, supervisor или launchd.
Какие задачи решает
- отслеживать появление писем в нескольких IMAP-ящиках
- передавать метаданные и сниппеты во входящие вебхуки OpenClaw
- маршрутизировать входящую почту без загрузки тяжёлых бинарных вложений
- настроить фоновый опрос или push-уведомления IMAP IDLE через переменные окружения
Примеры запросов агенту
- Проверь конфигурацию подключения к почтовым ящикам через
python3 scripts/imap_idle_fetch.py check-config - Запусти один тестовый цикл IDLE на 120 секунд с лимитом в 10 писем:
python3 scripts/imap_idle_fetch.py listen --cycles 1 --idle-seconds 120 --max-messages 10 - Запусти постоянный слушатель IMAP в фоновом режиме через
python3 scripts/imap_idle_fetch.py listen
Как установить email-imap-fetch
1Через Skills CLI (Vercel)
npx skills add tiangong-ai/agent-skills --skill email-imap-fetch -a claude-code2Вручную: положить файлы
~/.claude/skills/email-imap-fetch/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/email-imap-fetch/
1Через Skills CLI (Vercel)
npx skills add tiangong-ai/agent-skills --skill email-imap-fetch -a codex2Вручную: положить файлы
.agents/skills/email-imap-fetch/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add tiangong-ai/agent-skills --skill email-imap-fetch -a cursor2Вручную: положить файлы
.cursor/skills/email-imap-fetch/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install tiangong-ai/agent-skills email-imap-fetch2Вручную: положить файлы
.github/skills/email-imap-fetch/SKILL.md1Через Skills CLI (Vercel)
npx skills add tiangong-ai/agent-skills --skill email-imap-fetch -a gemini-cli2Командой платформы
gemini skills install https://github.com/tiangong-ai/agent-skills --path email-imap-fetchВручную: положить файлы
.devin/skills/email-imap-fetch/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add tiangong-ai/agent-skills --skill email-imap-fetch -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о email-imap-fetch
Как установить email-imap-fetch в Claude Code?
Выполните команду npx skills add tiangong-ai/agent-skills --skill email-imap-fetch -a claude-code. Спецификация скилла сохранится в ~/.claude/skills/email-imap-fetch/SKILL.md.
Передаёт ли скилл полные тексты писем и файлы вложений?
Нет, инструмент работает строго как маршрутизатор первого уровня. Он отправляет только тему, адресатов, краткий текстовый сниппет и манифест файлов без содержимого вложений.
Чем отличаются режимы idle и poll?
В режиме idle скрипт удерживает открытое IMAP-соединение и реагирует на входящие уведомления сервера. В режиме poll скрипт просыпается по таймеру IMAP_POLL_SECONDS, что подходит для серверов без поддержки команды IDLE.
Исходный текст
SKILL.md · MIT
--- name: email-imap-fetch description: Listen for one or more IMAP inboxes with the IDLE command, fetch unread email metadata plus text previews, and forward each message to OpenClaw webhooks. Use when tasks need near-real-time mailbox monitoring, multi-account inbox ingestion via environment variables, and automatic trigger delivery into OpenClaw automation. --- # Email IMAP Fetch ## Core Goal - Wait for new mail with IMAP IDLE. - Fetch unread messages after each wake-up. - Support multiple mailbox accounts configured with env. - Control IDLE support strictly with env mode (`idle` or `poll`) without runtime probing. - Forward each fetched email to OpenClaw webhooks. - Emit machine-readable JSON lines for downstream steps. - Keep this skill strictly in stage-1 routing mode: send snippet + structured refs only, never send full raw message body, and never send attachment binary/content. ## Workflow 1. Configure account env variables and OpenClaw webhook env variables (see `references/env.md` and `assets/config.example.env`). 2. Validate configuration: ```bash python3 scripts/imap_idle_fetch.py check-config ``` 3. Run one IDLE cycle per account (smoke test): ```bash python3 scripts/imap_idle_fetch.py listen --cycles 1 --idle-seconds 120 --max-messages 10 ``` 4. Run continuously (default resident mode): ```bash python3 scripts/imap_idle_fetch.py listen ``` ## Runtime Model - Skill files are installed locally, but the listener is not auto-started. - In `idle` mode, IMAP IDLE receives push events only while listener process and IMAP connection are alive. - In `poll` mode, listener sleeps for poll interval and then fetches unread messages. - If the process exits, push events are missed; next run can still fetch existing unread emails with `UNSEEN`. - Default runtime is resident mode (`IMAP_CYCLES=0` by default). - Default IDLE mode is `poll` (safe for servers without IDLE support). - In production, always-on deployment must run under `systemd`, `launchd`, `supervisor`, or an equivalent daemon manager. - Do not run the listener as a foreground process bound to an interactive exec session; once that session exits, the listener will stop. ## Output Contract - Output format is JSONL (one JSON object per line). - `type=status` for lifecycle events. - `type=message` for fetched emails with: - `account`, `mailbox`, `seq`, `uid` - `subject`, `from`, `to`, `date` - `message_id_raw`, `message_id_norm` (and compatibility field `message_id`) - `snippet` (plain-text preview only) - `attachment_count`, `attachment_manifest` (summary only, no attachment content) - `mail_ref` machine-readable object (`account`, `mailbox`, `uid`, `message_id_raw`, `message_id_norm`, `date`) - Webhook message includes two fixed machine-readable blocks for deterministic dispatch extraction: - `<<<MAIL_REF_JSON>>> ... <<<END_MAIL_REF_JSON>>>` - `<<<ATTACHMENT_MANIFEST_JSON>>> ... <<<END_ATTACHMENT_MANIFEST_JSON>>>` - `wait_mode` is `idle` or `poll` in cycle status output. - `wait_events` records the active wait strategy details. - `event=webhook_delivered` status events when OpenClaw webhook POST succeeds. - `type=error` for account-level failures. - `event=webhook_failed` error events when OpenClaw webhook POST fails. ## Parameters - `--cycles`: IDLE cycles per account (`0` means forever). - `--idle-seconds`: max wait time for each IDLE call. - `--poll-seconds`: interval used when polling mode is active. - `--idle-mode`: `idle` or `poll`. - `--max-messages`: max unread emails fetched each cycle. - `--mark-seen` / `--no-mark-seen`: control unread state updates. - `--snippet-chars`: preview length limit. - `--connect-timeout`: connection timeout seconds. - `--retry-seconds`: retry delay after failure. Environment defaults: - `IMAP_CYCLES` - `IMAP_IDLE_MODE` - `IMAP_IDLE_SECONDS` - `IMAP_POLL_SECONDS` - `IMAP_MAX_MESSAGES` - `IMAP_MARK_SEEN` - `IMAP_SNIPPET_CHARS` - `IMAP_CONNECT_TIMEOUT` - `IMAP_RETRY_SECONDS` OpenClaw webhooks forwarding: - `OPENCLAW_WEBHOOKS_ENABLED` - `OPENCLAW_WEBHOOKS_TOKEN` - `OPENCLAW_WEBHOOKS_BASE_URL` - `OPENCLAW_WEBHOOKS_MODE` (`agent` or `wake`) - `OPENCLAW_WEBHOOKS_ENDPOINT` (optional endpoint override) - `OPENCLAW_WEBHOOKS_PATH` - `OPENCLAW_WEBHOOKS_WAKE_MODE` - `OPENCLAW_WEBHOOKS_DELIVER` - `OPENCLAW_WEBHOOKS_TIMEOUT` - `OPENCLAW_WEBHOOKS_NAME` - `OPENCLAW_WEBHOOKS_AGENT_ID` - `OPENCLAW_WEBHOOKS_CHANNEL` - `OPENCLAW_WEBHOOKS_TO` - `OPENCLAW_WEBHOOKS_MODEL` - `OPENCLAW_WEBHOOKS_THINKING` - `OPENCLAW_WEBHOOKS_AGENT_TIMEOUT_SECONDS` - `OPENCLAW_WEBHOOKS_SESSION_KEY_PREFIX` ## Error Handling - Invalid env configuration exits with code `2`. - In `idle` mode, unsupported IDLE returns explicit error and suggests `IMAP_IDLE_MODE=poll`. - Runtime failures are emitted as `type=error`. - Command exits non-zero when account processing errors occur. ## References - `references/env.md` ## Assets - `assets/config.example.env` ## Scripts - `scripts/imap_idle_fetch.py`
© tiangong-ai · MIT · tiangong-ai/agent-skills