Skip to content

Releases

v0.17.0

Choose a tag to compare

@github-actions github-actions released this 27 Nov 05:32
fef8bf9

Added

  • tg messages search --forms also matches other forms of each plain word that occur in the
    cache: квартира finds квартиру and квартирой, meeting finds meetings, and еще
    finds ещё; a word with a digit (2ms) or a stem of one or two letters (ok) stays as
    typed. It works on the index's own words with light Russian and English stemmers, so the
    index and older versions are unchanged.
    Without the flag search stays exact. A query with FTS5 syntax or --phrase with --forms is
    INVALID_ARGS; while allowedChats is set, --forms matches words only as typed, since the
    forms come from the whole cache. Only visible transcripts of current attachments contribute
    word forms. The answer adds forms, the forms searched for (null
    without --forms or with allowedChats), and filters.forms. The cache gets the tables
    message_search_vocab and transcript_search_vocab, the words of the message and transcript
    indexes, which tg sql can read. See docs/search.md.
  • The GitHub Release has NOTICE, the licences of the ported stemmers, next to the binaries,
    and brew install neoromantic/tap/tg installs it in the formula's prefix.

v0.16.0

Choose a tag to compare

@github-actions github-actions released this 22 Nov 15:17
392c8d8

Added

  • tg messages list takes --type, --since and --until, so every voice note of a chat, or
    the chat since Monday, is one command instead of tg api messages.search with a hand-built
    peer and filter. --type takes one or more message types, comma-separated or repeated
    (voice, photo, video, document…), plus round and animation for the round video
    messages and GIFs that video also covers; --since and --until take the forms of
    tg messages search. A filtered page reads only the cache, needs no credentials for a chat
    the cache knows (a cached @username included, with allowedChats set too), explains a name
    the cache can't resolve, and pages with --before and --after as before. It adds complete, true only when one cached range covers the page up to the chat's
    newest known message and, with --type, every message in it has its type (a date window never
    guesses the date of a message the cache lacks); missing
    (history, types) says why it is false, missingBefore where the newest gap ends, and
    suggestion one sentence. next of an incomplete page has what fills it
    (tg messages list --fresh, tg db migrate), then the same page again, with --account
    kept; next carries --since and --until resolved to UTC seconds. Without the new flags the
    output is unchanged. tg messages search takes --type too, echoes it in filters.type and
    adds typesPending; its next then finishes a pending migration. Both commands suggest a
    one-time manual fetch for media whose type is unknown. When only the type is missing,
    list omits the automatic next page even if it has enough known matches to fill the limit.

  • tg media download takes several --id values and downloads the files of those messages of
    the chat in one run: up to 100 IDs per fetch, one private-chat protection check, up to 5 files at
    a time (2 of 20 MiB or more) and a flood wait that pauses the whole batch instead of failing
    files. A file fails on waits only after six in a row with no part downloaded between them,
    so a large download throttled by Telegram's speed limit completes. It prints one JSON line per file as each finishes, success or error, and exits 1 when
    any failed. Cached files need no network and partial files resume, as before. One --id
    prints what it printed before; a repeated --id still runs as a batch, downloading the ID once.

  • --out takes a name template such as ./media/{chat}/{date}_{id}_{name} (placeholders
    {chat}, {id}, {date}, {name}, {kind}); each filled part is made a safe file name,
    and one that exists as a symlink fails that file instead of being followed.
    With several --id, a directory --out names files {id}_{name}, so two photos no longer
    collide on photo.jpg. Repeating a batch accepts existing files with identical bytes. A
    collision between different files in one batch returns FILE_EXISTS even with --overwrite.
    Without --overwrite, a new file is published with a hard link; on a filesystem without
    hard links (exFAT, FAT, some network shares) it is copied instead, never over an existing
    file. If the copy is interrupted, use --overwrite to replace a partial export.

  • Transcribe voice and video notes with a local Whisper program using tg media transcribe. Search their transcripts with tg messages search, including snippets and counts.

Fixed

  • tg messages search --since and --until with milliseconds round up to the next second,
    since message dates are whole seconds: --until 00:01:40.500Z no longer leaves out a message
    sent at 00:01:40, and --since with milliseconds no longer takes one sent just before it.
    Its next carries the bounds resolved to UTC, so a relative bound (60s) keeps its window
    across pages.
  • With allowedChats set, tg messages search resolves its chat and the list from the cache
    alone, so a cached @username without an access hash needs no credentials again.
  • tg messages search --fresh is INVALID_ARGS that says search reads only the cache, instead
    of a generic unknown option.
  • A string flag's value that looks like a repeatable flag is no longer read as that flag: tg send --caption '--file=x' sends that caption.
  • A cached page of history vouches for the IDs above its newest message only up to the chat's
    newest message known before the request: a fetch that Telegram answers with nothing new now
    settles the gap (tg messages list --before 21 --fresh below a known message 30, a chat
    Telegram shows empty, or a chat whose newest messages were deleted), and a message cached while
    the request ran no longer vouches for a page that could miss a message sent meanwhile. The
    daemon's history pages follow the same rule.

v0.15.2

Choose a tag to compare

@github-actions github-actions released this 21 Nov 10:58
ac85803

Fixed

  • tg media download works on Windows. It failed with EPERM: operation not permitted, ftruncate before the first request, because it truncated the partial download through a file
    opened for appending. A resumed download keeps its whole parts as before (#233).

v0.15.1

Choose a tag to compare

@github-actions github-actions released this 19 Nov 16:48
79076cf

Fixed

  • A boolean flag with a value other than true or false (--silent=no and --silent=0,
    which ran as --silent) is INVALID_ARGS instead of being read as set (#217).
  • tg send, tg messages read and tg api write methods resolve an @username through
    Telegram, not the cache, so a username that moved never sends to its previous owner. The
    allowedChats check of a write resolves the list's @username entries the same way: an entry
    allows the chat that holds the username now, not its previous owner by ID. Reads take the
    latest fetched owner of a username (#217).
  • The daemon no longer deletes an account when two accounts sign in as the same Telegram user.
    It picked the one to keep by the kind of phone, so it could delete the account with the cache,
    label and active choice, or the one with the only working session. Now it leaves both and
    doesn't sync the second; its error says to log in again or remove it.

v0.15.0

Choose a tag to compare

@github-actions github-actions released this 19 Nov 16:38
cd69fad

Added

  • An agent skill, skills/telegram-sync-cli/SKILL.md: when to use tg, finding chats and
    messages, counting and reading whole chats with one tg sql query and checking that the
    cache covers the chat, confirming before tg send, the error schema and the exit codes.
    Install it with bunx skills add neoromantic/telegram-sync-cli or
    tg skill install --dir <skills dir>, which writes the same file from tg itself. A test
    runs every command in its examples against made-up data and checks the answers of its SQL.
  • tg skill validate reports the account record the next command uses without --account
    (account, accounts_total): activeAccount in config.json, else the active account,
    else the only one. It also reports whether a live process holds daemon.pid
    (daemon: { status, pid }). Neither checks that the session is authorized or online. No
    account, several and none active, or an invalid config.json is an issue. Each value is
    read on its own: one that can't be read is null (accounts_total) or unknown
    (daemon.status), with the reason, and the others stay accurate.
  • tg send --markdown and --html send rich messages such as headings and tables on
    supported accounts. The result includes format. File captions stay plain text.

Changed

  • tg starts about five times faster for every command that answers from the cache, and for
    --help and --version: it loads the Telegram client library only when a command calls
    Telegram (0.1 s of CPU instead of 0.5 s on a source install).

  • A group (basic group or supergroup) adds new messages to the cache only while you take part
    in it: you sent an ordinary message there in the last 90 days. Reading a group doesn't count.
    The rule holds in every tg chats sync mode and in tg messages list/get, --fresh
    included (which still return Telegram's page). Messages already cached stay; private chats
    and channels are unchanged. After each dialog pass the daemon asks Telegram once per group
    for your newest message of the last 90 days, at the lowest priority. Your next message in a
    group, from any device or with tg send, turns it back on; the messages of the pause aren't
    fetched later. tg chats list and tg chats sync show such a group with syncEnabled: false,
    the reason group_participation_required or group_participation_unknown and
    lastOwnMessageAt, and tg status leaves it out of the chats with sync on and of the history
    progress. See docs/sync-strategy.md.

  • Breaking: tg skill installs only the Markdown skill. tg 0.14.0 and older wrote
    <dataDir>/skill.json there and ignored --dir. Now:

    • tg skill manifest is removed;
    • tg skill install needs --dir, the agent's skills directory, and rejects an empty one;
    • it writes <dir>/telegram-sync-cli/SKILL.md instead of <dataDir>/skill.json,
      replacing a file already there, local edits included, and refusing a symbolic link for
      telegram-sync-cli or SKILL.md (the skills directory itself may be one);
    • its JSON drops data.manifest and keeps path, bytes and overwritten.

    Replace tg skill install with:

    tg skill install --dir ~/.claude/skills
  • Breaking: tg skill validate reports a missing account as an issue, so before
    tg auth login it prints valid: false, still with exit 0. tg 0.14.0 and older checked only
    the credentials and the data directory.

  • Breaking: src/db/index.ts no longer exports db, the open data.db connection. Code
    that imports it from the package source calls getDataDb(), which opens data.db on first
    use.

Fixed

  • tg skill install and tg skill validate work with a corrupt data.db, which stopped every
    command with a SQLite stack trace before it started: data.db now opens when a command first
    reads an account. Install writes the skill, and validate names the file as an issue.
  • A command acts on the chat and account it checked against
    allowedChats: the check pins the account and hands its resolved chat to the command, so a
    switch of the active account or a second lookup in between can't move it (#217).
  • A flag a command doesn't declare (--acount 2) and a value after a boolean flag
    (--silent false, which ran as --silent) are INVALID_ARGS instead of being ignored (#217).
  • A Telegram call that succeeded is no longer reported as failed when tg can't write it to its
    local api_activity log, so a retry doesn't repeat a send (#217).
  • The npm package declares long, which tg imports directly. Until now it only arrived
    through @mtcute/core, so an install that doesn't hoist transitive dependencies could fail
    to start.
  • tg auth login --phone works for a user who already has an account under another phone,
    such as the user:<id> account of a QR login or a number they have since changed (#213).
    The phone moves to that account, which keeps its cache. Until now the login failed with
    UNIQUE constraint failed: accounts.phone and left a second account behind.
  • A login of a user who already has an account under another phone or a QR login gives that
    account the new session. Until now the account kept its old session, so after the old
    session was ended in Telegram the login succeeded but the account stayed signed out.

v0.14.0

Choose a tag to compare

@github-actions github-actions released this 18 Nov 06:45
16dbd92

Added

  • Every error says whether running the same command again can work: error.retryable is
    true for RATE_LIMITED, NETWORK_ERROR, a media download that waited too long for
    another tg process and a tg api call Telegram failed on its side (500 or -503), false
    otherwise (#160). Nothing else in the error schema changes.
  • RATE_LIMITED carries the suggestion Wait <n>s, then run the same command again (for a
    media download, "… to resume the download"), with the wait in details.wait_seconds as
    before, from every command: tg api, tg send, tg chats, tg contacts, tg user,
    tg messages and tg media download.
  • ACCOUNT_NOT_FOUND suggests tg accounts list and the flag to pass the account to
    (--account, or --id for tg accounts switch, remove and info). tg send --to with a
    user ID Telegram refuses (PEER_ID_INVALID) suggests sending to the user's @username or
    +phone once, so tg caches the user.
  • next in success answers: a list of { command, why } beside data, where command is a
    complete tg command line that runs as written in a POSIX shell and why says what it does
    (#160). A paged read that has more suggests its next page with the account and every filter
    it was given: tg messages list (older pages, or newer ones after --after),
    tg messages search, tg chats list, tg contacts list, and tg messages wait --chat,
    which suggests waiting on from the last message it returned. tg chats search with no
    result suggests tg chats list --fresh, then the same search, where before the command was
    only in message. An answer with nothing to suggest has no next, and every existing field
    (message, nextBefore, nextAfter, hasMore, offset) is unchanged. --format pretty
    prints the suggestions on stderr, so stdout stays the data's JSON; --quiet prints nothing.

Changed

  • The data fields of tg chats list are declared once, in
    src/commands/chats/list-output.ts: the command's types come from it, the field table in
    docs/cli-commands.md is generated from it (bun run docs:outputs), and
    an e2e test fails when the command prints a field the declaration doesn't have (#160, a trial
    on one command). The output doesn't change. zod is a devDependency and doesn't ship.

Fixed

  • tg messages list, get, search, unread, wait and watch show the content of a rich
    message: one whose content is page blocks (headings, tables, lists, quotations, code,
    formulas, footnotes, media) instead of a text. It printed as text: null, so an agent saw an
    empty message where a table or a whole report was sent, and search could not find it. Its
    text is now the blocks in Telegram's rich Markdown (# headings, pipe tables, - [x] task
    lists, $$…$$ formulas, [^1] footnotes, HTML tags such as <details> where Markdown has
    none), with a placeholder for media, maps and buttons ([photo: caption]). messageType
    stays text. The text is cached, so search matches any word of it, a table cell's too.
    Messages cached by older versions print it from raw_json at once, and a background
    migration (messages_rich_text) makes them searchable.

v0.13.1

Choose a tag to compare

@github-actions github-actions released this 17 Nov 21:54

Fixed

  • tg messages search --chat me searches Saved Messages and --sender me finds your own
    messages: me (any case) is the account's own user ID, read from the account without a
    Telegram call. Before, both returned nothing and still succeeded. When the account doesn't
    know its user ID yet, me is INVALID_ARGS (exit 3) with a hint to run tg me once. A
    --chat or --sender value that is neither an ID, a username nor me (a typo such as
    12abc) is INVALID_ARGS naming the flag, instead of an empty success.
  • tg api types its arguments by the method's TL schema, so the documented examples work:
    tg api messages.getHistory --peer me --limit 1 and
    tg api messages.sendMessage --json '{"peer":"@user","message":"Hi"}' failed with
    Unknown object undefined. A chat given as a string or number where the method takes an
    InputPeer, InputUser or InputChannel (peer, id of users.getFullUser, channel…)
    resolves like tg send --to (me, @username, +phone, a marked ID; cache first); a long
    given as a number or decimal string becomes a Long (before, --hash 123 went out as 0); a
    required int or long left out is 0 (offsetId, maxId, hash…), a required randomId is
    random and a required offsetPeer is inputPeerEmpty. A chat of the wrong kind (a group as
    a user) is INVALID_ARGS. Full TL objects go as before.

v0.13.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 21:08

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).

v0.12.2

Choose a tag to compare

@github-actions github-actions released this 17 Nov 20:16
365507c

Fixed

  • tg sql "SELECT 1 AS one" -f json runs the query: the value of -f/--format after a positional
    query was added to the SQL (SELECT 1 AS one json, a syntax error), and after --query it was
    refused as an extra argument. tg sql -f json print-schema prints the schema.
  • tg messages list, get and search say what a service message did. A call, a pin or a
    group change used to print only messageType: "service" with no text, so an agent reading a
    chat could not tell a call had happened. Every item now has action, read from raw_json (so it
    works for messages cached by older versions too), null for other messages: a call gives
    video, duration and why it ended (missed, busy, hangup, disconnect), a pin the
    pinned message, a group change the new title or the users added or removed. Any other action
    gives its type name.
  • tg status no longer counts a sender whose every cached message is deleted as missing:
    nothing is left to ask Telegram for, and search doesn't show those messages by default. On a
    1.16M-message cache, 1,125 of the 1,376 senders still missing after the first fetch were such
    senders (#143).
  • Several commands can open a new cache together without failing to initialize its search index.

v0.12.1

Choose a tag to compare

@github-actions github-actions released this 13 Nov 16:20

Fixed

  • The daemon fetches the senders that cached messages name but the cache lacks, so
    sender:name finds their messages and tg messages shows their names. Caches synced before
    0.9.0 have many (about 3% of the messages of a 1.16M-message cache), and a live message still
    leaves one now and then. Once a day the daemon asks Telegram for one message of each such
    sender by ID, up to 100 per request, only when it has no other sync work: on a made-up cache of
    that shape, 349 requests for 2,960 senders. A sender Telegram doesn't return is asked again
    30 days later. tg status shows how many senders are still missing (#143).