Skip to content

feat(account): connect, reconnect, pending, limits, pause, resume, unblock and delete - #39

Merged
ArtemKosolap merged 4 commits into
mainfrom
dev/REPLY-54131-account-verbs
Nov 12, 2026
Merged

ArtemKosolap merged 4 commits into
mainfrom
dev/REPLY-54131-account-verbs

Conversation

@ArtemKosolap

@ArtemKosolap ArtemKosolap commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

reply account gains eight verbs next to list, so an agent can have an email or LinkedIn account connected, limited, paused or removed without anyone opening Reply's web app:

Verb Email LinkedIn
connect --channel … [--provider gmail|office365] [--name N] [--allow-shared-page] POST /v3/email-accounts/connection-link {provider, name?} POST /v3/linkedin-accounts/connection-link {name}
reconnect <id> --channel … [--provider …] [--allow-shared-page] POST /v3/email-accounts/{id}/reconnect POST /v3/linkedin-accounts/{id}/reconnect
pending [--channel …] GET /v3/email-accounts/pending GET /v3/linkedin-accounts/pending, without connectionLink
limits <id> --channel … [--daily N] [--set <json>] GET / PATCH /v3/email-accounts/{id} safety PUT /v3/linkedin-accounts/{id}/limits, read back by GET /v3/linkedin-accounts/{id}
pause / resume <id> --channel linkedin refused (exit 2): Reply's API has no pause for a mailbox reads the status, then POST …/toggle-status only from enabled (pause) or disabled (resume)
unblock <id> POST /v3/email-accounts/{id}/resume-sending —
delete <id> --channel … --yes [--force] DELETE /v3/email-accounts/{id} DELETE /v3/linkedin-accounts/{id}[?force=true]

connect and reconnect print {channel, [id], link, expires_at, pending_id, kind, link_kind}. pending prints {items: [{channel, id, name, kind, account_id, expires_at, expired}], supported, unsupported_channels}.

Why

A person connects a mailbox or a LinkedIn profile on Google's, Microsoft's or LinkedIn's own page, so an agent only needs a link to hand them. Reply's v3 already issues those links for LinkedIn. For email, the one-mailbox link routes are new in Reply and not yet on every environment.

How it works

  • No silent fallback to the permanent address. When the email link route is missing (404 with no Reply code), connect/reconnect --channel email refuse with email_link.not_available, exit 1, and print nothing. Only --allow-shared-page makes them call GET /v1/SharedPageUrl and print the hosted mailbox page, with link_kind: "shared_page", expires_at: null and a warning. That address does not expire and lets its holder manage all of the user's mailboxes, deletion included. With --provider it is that provider's connect on the hosted page (ConnectWithGMail?uidToken=…, ConnectWithOffice?uidToken=…&isExchange=false, built from the v1 address's token in src/operations/shared-page.ts). For reconnect both provider forms carry &reconnect=true: the hosted controller checks !reconnect && WouldBuySeatAsync() before it redirects to the provider, so without the flag a user with no free mailbox slot, which the broken mailbox itself takes, would land on the NoFreeMailboxSlots error instead of reconnecting. Without --provider it is the hosted index, unchanged for reconnect: the person reconnects by opening the existing mailbox there, and the hosted page adds reconnect=true to the provider's connect itself whenever the mailbox it shows already exists, so the controller's free-slot check is skipped the same way. shared_page.not_enabled is the plan without hosted pages (v1 gives no code, so the CLI names it). The v1 answer is read as {url} or as a bare string, and its body is treated as a secret whatever its shape (below).
  • An email connection link needs a provider. Without --provider, connect --channel email is a usage error unless --allow-shared-page is given. With the flag, a read of GET /v3/email-accounts/pending tells the two kinds of Reply apart: one with the links answers email_link.provider_required, and one without gives the hosted index.
  • The link is a secret. The body of the shared-page call is a secret whatever its shape: the trace never shows it, and every address and single-value string in it is redacted wherever else it would appear, a refusal built from it included.
  • The link is printed once. It is printed once, in the stdout field link, and never on stderr, in errors or in logs. The global --verbose now traces the account commands' calls curl-style (request, status, headers, body). Every link Reply answers (connectionLink, url), and every token in it, is replaced there by <link redacted>. That covers headers too.
  • Errors. Exit codes follow the existing classes: 0 ok, 1 refusal or API error, 2 usage, nothing sent, and 3 when a write's outcome is unknown. Reply's refusals of the account routes come under the CLI's own codes, in the form the other work commands use, with Reply's code verbatim in reply_code: emailAccount.notFound (404) is email_account.not_found, emailAccount.limitReached (409) is email_account.limit_reached, emailAccount.noFreeMailboxSlots (409) is email_account.no_free_mailbox_slots, emailAccount.reconnectNotSupported (400) is email_account.reconnect_not_supported, linkedInAccount.notFound (404) is linkedin.account_not_found, linkedInAccount.limitReached (409) is linkedin.account_limit_reached, linkedInAccount.accountInUse (409) is linkedin.account_in_use, and linkedInAccount.cookieInvalid (400) is linkedin.invalid_cookie. Any other answer is read the way every other operation reads it (reply.refused, access.feature_unavailable, …).
  • delete has no prompt: without --yes it is a usage error and nothing is sent. --force with email is a usage error.
  • pause/resume: Reply's toggle turns enabled off and every other state on, so pause calls it only from enabled and resume only from disabled. An account already in the asked state is left alone (changed: false); at its daily limit an account is active, so resume leaves it alone and pause is refused before any write with account.pause_unavailable (details.reply_status carries Reply's word). They also refuse a disconnected account (linkedin.invalid_cookie), a state the CLI does not know or cannot read (account.status_unknown, also before any write), and a toggle that landed on the wrong state because someone changed it in between (account.status_changed).

What it does NOT do

  • No email pause: Reply's API has none.
  • No link is kept or re-read: pending never prints one.
  • LinkedIn connect and reconnect answers carry no expiry, so expires_at is null there. account pending reads the expiry of a LinkedIn connect.

Verification

  • npm run build (tsc, which is also the typecheck): clean. The repo has no separate lint or typecheck script.
  • npm test (vitest): 66 files, 1075 passed, 5 skipped. 63 of the tests are new: account-links.test.ts (25), account-manage.test.ts (17), account-secrets.test.ts (20), plus 1 in commands.test.ts. account-manage.test.ts runs pause and resume from each status Reply gives (one toggle from enabled for pause and from disabled for resume, none from any other), pause at the daily limit, and unrecognised or unreadable statuses for both verbs. account-links.test.ts checks the shared page's reconnect form for each provider and the index.
  • account-secrets.test.ts runs every link verb with --verbose against a stubbed Reply, using a token generated for each run. The cases are email and LinkedIn connect and reconnect, the shared page for each provider and the index on both connect and reconnect, the shared page answered as a bare string, pending, and six error paths: a shared page in an unreadable form, answered as a bare token, as text, as an object with no address, refused with the address in the refusal, and an answer without a usable link. One case goes through the real program entry point. Each case searches the whole of stderr, the trace and the thrown error for the token, its encoded form and the printed link, and fails on any hit. It also checks that the token is on stdout exactly once, in link. With the trace redaction disabled, all 13 original cases fail; with the shared-page body not treated as a secret, the four rows whose answer holds no readable address fail.
  • Fully offline: no live Reply call and no key.

…block and delete

`reply account` gains the verbs that manage the accounts a send goes from, so an agent can have an
email or LinkedIn account connected without opening Reply's web app:

- `connect` and `reconnect` print a link for the person who signs in to open. Email uses Reply's
  one-mailbox connection link (`POST /v3/email-accounts/connection-link`, `/{id}/reconnect`),
  LinkedIn its connection link and reconnect. A connection link connects one account, works once
  and expires.
- On a Reply without the email link routes (404, no code) the email verbs refuse with
  `email_link.not_available`. Only `--allow-shared-page` prints the hosted mailbox page from
  `GET /v1/SharedPageUrl` instead, the provider's connect with `--provider` and the index without,
  with `link_kind: "shared_page"`, `expires_at: null` and a warning: that address does not expire
  and lets its holder manage all of the user's mailboxes.
- `pending` lists the unused links of both channels without the links; email answers
  `supported: false` where Reply has no such list.
- `limits` reads or changes an email account's safety section or a LinkedIn account's limits.
- `pause` and `resume` read a LinkedIn account's state and toggle only when needed; email has no
  pause in Reply's API. `unblock` clears a provider's block on a mailbox.
- `delete` needs `--yes`; `--force` adds Reply's own force for LinkedIn.

A link and any token in it are printed once, in the stdout field `link`. `--verbose` now traces
the account commands' calls, with every link and token in them replaced by `<link redacted>`, and
no error or stderr line carries one; a test runs every link verb with `--verbose` against a stubbed
Reply and fails on any sight of the token. Reply's own refusal code is the error's code.
…e the CLI's error codes

The shared page's answer was read only as an object with a url field. A bare string was refused as
unreadable, and under --verbose the trace printed it whole, token included, since only link fields
of an object were redacted. A string body is now read as the address, and the body of the
shared-page call is a secret whatever its shape: the trace never shows it, every address and
single-value string in it is redacted wherever else it appears, and a refusal built from it has
them replaced too. The secret test gains rows for a bare-string answer, a bare token, text and an
object with no address, and a refusal quoting the address.

Reply's refusals of the account routes now come under the CLI's own codes, in the form the other
work commands use (email_account.not_found, linkedin.account_in_use, linkedin.invalid_cookie, …),
with Reply's code in reply_code; one with no code of its own reads as every refusal does, e.g.
reply.refused. sharedPage.notEnabled becomes shared_page.not_enabled. The help and README follow.
@ArtemKosolap
ArtemKosolap marked this pull request as ready for review November 12, 2026 05:52
Comment thread src/operations/account-manage.ts Resolved
Comment thread src/operations/shared-page.ts Resolved
…r states before any write

Reply's toggle turns an enabled account off and any other state on. A pause
from dailyLimitReached therefore turned the account on and then failed with
account.status_changed. Pause now flips only from enabled and resume only
from disabled. An account already in the asked state is left alone as
before; pause at the daily limit is refused with the new
account.pause_unavailable, and a state the CLI does not know with
account.status_unknown, both before any write.
Without reconnect=true the hosted page counts the sign-in as a new mailbox,
so a user with no free mailbox slot was sent to that error instead of
reconnecting. account reconnect --allow-shared-page --provider now adds the
flag to both the Gmail and the Office 365 connect. The index is printed as
before: the hosted page adds the flag itself when a mailbox already on it is
reconnected.
@ArtemKosolap
ArtemKosolap merged commit f8a6a28 into main Nov 12, 2026
6 checks passed
@ArtemKosolap
ArtemKosolap deleted the dev/REPLY-54131-account-verbs branch November 12, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants