§01
Overview
- What it is: A small ops utility for sampled QA of call-center calls on Asterisk. The name
tg_invoice_listeneris misleading (likely a legacy ofbun initor a rename) — by the code this is a "call-recording QA sampler → Telegram". - Type / status / role: cli / ops script · prototype · solo (1 commit by the user).
- Activity period: 2026-04-18 (one day, 1 commit).
§02
Stack
- Bun + TypeScript, NO external dependencies — only Bun built-ins:
Bun.$(shell),Bun.file,Bun.env, nativefetch/FormData. Systemsshpassfor SSH/SCP over password. - Data source: Asterisk CDR (
asteriskcdrdbMySQL), recording files under/var/spool/asterisk/monitor/YYYY/MM/DD/. - Delivery: Telegram Bot API (
sendAudio, multipart FormData). - Config via env (SSH host/user/password, TG token/chat, lookback/sample parameters).
§03
What was shipped
- A single commit (2026-04-18): a complete working
index.tsscript (176 lines). - Logic:
fetchCandidates()(SQL over CDR: ANSWERED, billsec ≥ threshold, recording present,GROUP BY recordingfile,ORDER BY RAND() LIMIT),pickCount()(random 10–15), SCP download into a temp folder,sendAudio()with a formatted caption, tmp cleanup infinally, exit code based on result.
§04
Technical challenges
Confirmed by index.ts:
- SSH/SCP automation by password (
sshpass -e+ strict-ooptions: host-key check disabled, password-auth only, timeout): access to a remote PBX without keys. → practical ops integration. - Random sampling for QA (
ORDER BY RAND()+pickCount10–15): a representative sample of recordings instead of all of them. → thoughtful QA approach. - Zero-dependency on Bun built-ins (
Bun.$,Bun.file, native fetch/FormData): no node_modules dependencies, all I/O via the Bun runtime. → a modern, lightweight style. - Careful resources and errors: temp folder with PID+timestamp, guaranteed cleanup in
finally, per-file try/catch, meaningful exit code (fail if nothing was sent). → reliability for cron runs. - `requireEnv` with an explicit error on a missing variable. → fail-fast config.
§05
AI-assisted development
- Sessions found: 0. The repo has
.claude/(with a Bun guide in CLAUDE.md) and.cursor/— AI tooling was used, but no Claude Code transcripts. - What was done with AI: likely generated/refined with Cursor/Claude (CLAUDE.md is the standard Bun guide).
- AI-workflow patterns: minimal data.
§06
Achievements & metrics
- Working ops utility: Asterisk CDR → SCP → Telegram, ~176 lines, zero deps.
- Configurable sampling, safe cleanup, cron readiness.