Add lettabot-history CLI (#211)

* Add lettabot-history CLI

* Document and test lettabot-history

* Validate lettabot-history limit

* fix: address review feedback on history CLI

- Extract shared loadLastTarget into cli/shared.ts (was duplicated in message.ts, react.ts, history-core.ts)
- Clamp --limit to platform maximums (Discord: 100, Slack: 1000)
- Fix Discord author formatting: use globalName/username instead of deprecated discriminator
- Add Slack fetch test

Written by Cameron ◯ Letta Code

"You miss 100% of the shots you don't take." -- Wayne Gretzky -- Michael Scott

---------

Co-authored-by: Jason Carreira <jason@visotrust.com>
Co-authored-by: Cameron <cameron@pfiffer.org>
This commit is contained in:
Jason Carreira
2026-02-09 13:16:10 -05:00
committed by GitHub
parent 673f247793
commit 16b5e5b7b7
10 changed files with 467 additions and 56 deletions

36
docs/cli-tools.md Normal file
View File

@@ -0,0 +1,36 @@
# CLI Tools
LettaBot ships with a few small CLIs that the agent can invoke via Bash, or you can run manually.
They use the same config/credentials as the bot server.
## lettabot-message
Send a message to the most recent chat, or target a specific channel/chat.
```bash
lettabot-message send --text "Hello from a background task"
lettabot-message send --text "Hello" --channel slack --chat C123456
```
## lettabot-react
Add a reaction to a message (emoji can be unicode or :alias:).
```bash
lettabot-react add --emoji :eyes: --channel discord --chat 123 --message 456
lettabot-react add --emoji "👍"
```
## lettabot-history
Fetch recent messages from supported channels (Discord, Slack).
```bash
lettabot-history fetch --limit 25 --channel discord --chat 123456789
lettabot-history fetch --limit 10 --channel slack --chat C123456 --before 1712345678.000100
```
Notes:
- History fetch is not supported by the Telegram Bot API, Signal, or WhatsApp.
- If you omit `--channel` or `--chat`, the CLI falls back to the last message target stored in `lettabot-agent.json`.
- You need the channel-specific bot token set (`DISCORD_BOT_TOKEN` or `SLACK_BOT_TOKEN`).