Skip to content

v0.13.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 21:08
· 3 commits to main since this release

Commands for agents: wait for a reply, read and mark unread messages, and keep an agent
read-only or to a few chats.

Added

  • tg db vacuum checks the free disk before a full VACUUM (daemon stopped): it needs 2.2 times
    the cache file plus 64 MB, as the storage benchmark measured. When the disk is short it fails
    at once with GENERAL_ERROR, details.reason: "disk_full", the bytes needed and free, and
    changes nothing, instead of failing after minutes of work. tg status shows the same check
    next to its vacuum hint (#119).
  • tg messages wait blocks until the daemon stores a new message, then returns the new messages
    oldest first, in the same shape as tg messages list; tg messages watch prints each one as a
    JSON line as it is stored, until Ctrl-C or SIGTERM. Both read only the cache (no second
    Telegram session) and return within about a second of the daemon storing a message.
    --chat keeps one chat, --after <id> returns that chat's cached messages newer than it at
    once, --settle N keeps collecting until N quiet seconds, and after --timeout (default
    60 s) the result is { "messages": [], "timedOut": true } with exit 0. Without a running
    daemon they fail at once with DAEMON_NOT_RUNNING (#24).
  • Unread messages (#25). tg chats list --unread lists only chats with unread messages, and
    every chat item has unreadCount. tg messages unread [--chat <peer>] [--limit N] prints each
    chat's oldest unread messages from the cache with its unread count and missing, how many of
    them the cache lacks; --fresh reads the counts and those messages from Telegram.
    tg messages read --chat <peer> [--max-id <id>] marks a chat read on Telegram
    (messages.readHistory, or channels.readHistory for supergroups and channels) and caches
    its new count. chats_cache gets unread_count and read_inbox_max_id, which dialog lists
    set; the daemon raises the count for each new incoming message and takes reads on any device
    from Telegram's read updates, so the counts stay current between dialog passes. A cache from
    an older version has no counts until the daemon's next start or tg chats list --fresh.
  • Read-only mode and a chat allowlist for agents (#26). readOnly in config.json or
    TELEGRAM_SYNC_CLI_READ_ONLY=1 refuses, before connecting, every command that changes
    something on Telegram with the new code READ_ONLY (exit 1): tg send, tg messages read,
    tg api methods not named get…, search…, resolve… or check…, and tg auth login,
    login-qr and logout. allowedChats (or TELEGRAM_SYNC_CLI_ALLOWED_CHATS, which replaces
    it for one process) limits commands to those chats: one that names another chat fails with
    CHAT_NOT_ALLOWED (exit 1), tg chats list, tg chats search, tg messages search, wait,
    watch and unread show only allowed chats, and tg sql and tg api are off. tg status
    shows both under access. They guard against mistakes and are not a security boundary.

Changed

  • tg auth login-qr draws its QR code with uqr instead of
    qrcode-terminal, which has had no release since 2018. The code is black on white with the
    standard four-module quiet zone, so it scans in dark and light terminal themes, and it goes to
    stderr with its status lines, so they no longer mix with the JSON result on stdout (#10).
  • The daemon raises a chat's last_message_id and last_message_at with each live message, so
    tg chats list keeps the order of recent activity between dialog passes.

Fixed

  • tg db migrate with the daemon stopped no longer locks other tg commands out of the cache: it
    ran its batches back to back, and on a big cache a command that wrote meanwhile (tg messages list caching a page, tg send caching the sent message) could give up with database is locked after 5 s. It now pauses 150 ms after each second of work, so such a write gets in
    within about a second; the run takes up to 15% longer (#122).