Commit Graph

412 Commits

Author SHA1 Message Date
Tom Fehring
d12633b792 Convert standard markdown to Slack mrkdwn for Slack messages (#234)
* Slack: convert Markdown to mrkdwn

* Slack: avoid literal dynamic import for optional dep

* Slack formatter: cache optional dependency load state

* fix: remove slackify-markdown from lockfile dependencies

The lockfile had slackify-markdown in both `dependencies` (pinned) and
`optionalDependencies`, but package.json only lists it in
optionalDependencies. This caused npm ci to treat it as required,
defeating the optional dependency pattern.

Regenerated lockfile with clean npm install to fix.

Written by Cameron ◯ Letta Code

"The lockfile giveth, and the lockfile taketh away." - npm, probably

---------

Co-authored-by: Cameron <cameron@pfiffer.org>
2026-02-09 16:59:46 -08:00
Cameron
f2ec8f60c2 feat: support multiple Gmail accounts for polling (#244)
Add multi-account Gmail polling with per-account seen tracking, updated
onboarding flow, and config/env resolution.

Based on jasoncarreira's work in #214, rebased onto current main and
cleaned up:
- parseGmailAccounts() extracted to polling/service.ts with 10 unit tests
- Per-account seen email tracking (Map<string, Set<string>>) with legacy
  migration from single-account format
- Onboarding supports multi-select for existing accounts + add new
- Config resolution: polling.gmail.accounts > integrations.google.accounts
  (legacy) > GMAIL_ACCOUNT env (comma-separated)
- GoogleAccountConfig type for per-account service selection
- Updated docs/configuration.md

Closes #214.

Written by Cameron ◯ Letta Code

"Good artists copy, great artists steal." - Pablo Picasso
2026-02-09 16:58:34 -08:00
Cameron
deb1c4532a feat: add POST /api/v1/chat endpoint for agent messaging (#242)
* feat: add POST /api/v1/chat endpoint for sending messages to agents

Adds an HTTP endpoint that accepts a JSON message, sends it to the
lettabot agent via sendToAgent(), and returns the agent's response.
This enables external systems (e.g. server-side tools in other agents)
to communicate with lettabot programmatically.

- Add ChatRequest/ChatResponse types
- Add AgentRouter interface extending MessageDeliverer with sendToAgent()
- Implement AgentRouter on LettaGateway with agent-name routing
- Add POST /api/v1/chat route with auth, validation, and JSON body parsing

Written by Cameron ◯ Letta Code

"The most profound technologies are those that disappear." -- Mark Weiser

* feat: add SSE streaming support to /api/v1/chat endpoint

When the client sends Accept: text/event-stream, the chat endpoint
streams SDK messages as SSE events instead of waiting for the full
response. Each event is a JSON StreamMsg (assistant, tool_call,
tool_result, reasoning, result). The result event signals end-of-stream.

- Export StreamMsg type from bot.ts
- Add streamToAgent() to AgentSession interface and LettaBot
- Wire streamToAgent() through LettaGateway with agent-name routing
- Add SSE path in chat route (Accept header content negotiation)
- Handle client disconnect mid-stream gracefully

Written by Cameron ◯ Letta Code

"Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke

* test+docs: add chat endpoint tests and API documentation

- 10 tests for POST /api/v1/chat: auth, validation, sync response,
  agent routing, SSE streaming, stream error handling
- 6 tests for gateway sendToAgent/streamToAgent routing
- Fix timingSafeEqual crash on mismatched key lengths (return 401, not 500)
- Document chat endpoint in configuration.md with sync and SSE examples
- Add Chat API link to docs/README.md index

Written by Cameron ◯ Letta Code

"First, solve the problem. Then, write the code." -- John Johnson
2026-02-09 16:53:31 -08:00
Cameron
6f5a322840 fix: clear WhatsApp typing indicator after response (#243)
WhatsApp's "typing..." indicator lingers for 15-25 seconds after the bot
finishes responding because there was no way to clear it. This adds
stopTypingIndicator() which sends a "paused" presence update to
immediately dismiss it.

- stopTypingIndicator?() added to ChannelAdapter interface (optional)
- WhatsApp adapter implements it via sendPresenceUpdate("paused")
- bot.ts calls it in the finally block after stream processing

Written by Cameron ◯ Letta Code

"First, solve the problem. Then, write the code." - John Johnson
2026-02-09 16:25:52 -08:00
Cameron
5f7cdd3471 feat: XML response directives via <actions> wrapper block (#239)
Agents can now include an <actions> block at the start of their text
response to perform actions without tool calls. The block is stripped
before the message is delivered to the user.

Example:
  <actions>
    <react emoji="thumbsup" />
  </actions>
  Great idea!
  → Sends "Great idea!", reacts with thumbsup

- New directives parser (src/core/directives.ts) finds <actions> block
  at response start, parses self-closing child directives inside it
- addReaction() added to ChannelAdapter interface (Telegram, Slack,
  WhatsApp already implement it)
- Streaming holdback covers the full <actions> block duration (prefix
  check + incomplete block detection), preventing raw XML from flashing
- Directive execution extracted to executeDirectives() helper (no
  duplication between finalizeMessage and final send paths)
- Message envelope includes Response Directives section so all agents
  learn the feature regardless of system prompt
- System prompt documents the <actions> block syntax
- 19 unit tests for parser and stripping

Significantly cheaper than the Bash tool call approach (lettabot-react)
since no tool_call round trip is needed.

Relates to #19, #39, #240. Subsumes #210.

Written by Cameron ◯ Letta Code

"The best code is no code at all." - Jeff Atwood
2026-02-09 15:53:10 -08:00
Cameron
39fb657494 fix: exclude e2e tests from unit test run (#241)
Unit test job was discovering e2e/*.e2e.test.ts files and reporting
them as skipped, causing misleading "6 skipped" in PR checks.

Now test:run excludes e2e/ directory. E2E tests run separately via
test:e2e with secrets in CI.

Written by Cameron ◯ Letta Code

"Clean signals lead to confident decisions." -- unknown
2026-02-09 15:30:08 -08:00
Cameron
e3df025bd8 refactor: unify bot loop with runSession(), drop initialize/timeout (#238)
* refactor: unify bot loop with runSession(), drop initialize/timeout

Unify the duplicated session lifecycle in processMessage() and
sendToAgent() into shared helpers:

- baseSessionOptions: computed once, not duplicated
- getSession(): 3-way create/resume/fallback in one place
- persistSessionState(): save agentId/conversationId/skills
- runSession(): send with CONFLICT retry, deduplicated stream

Also:
- Drop session.initialize() -- SDK auto-initializes on send()
- Drop withTimeout() wrapper -- SDK should own timeouts
- sendToAgent() shrinks from 98 to 20 lines
- processMessage() shrinks from 437 to ~250 lines (delivery stays)
- Net -187 lines (1013 -> 825)

All recovery logic preserved: pre-send attemptRecovery(),
CONFLICT catch + retry, empty-result orphan recovery.

Fixes #197

Written by Cameron ◯ Letta Code

"Make it work, make it right, make it fast." -- Kent Beck

* fix: narrow conversation-not-found fallback to 404/missing errors

Codex review caught that runSession() was retrying with createSession()
on ANY send error when agentId exists, not just conversation-missing
cases. Auth/network/protocol errors would incorrectly fork conversations.

Now only retries on 404 or error messages containing "not found" /
"missing" / "does not exist". Other errors propagate immediately.

Written by Cameron ◯ Letta Code

"Be conservative in what you send, be liberal in what you accept." -- Postel's Law

* fix: persist agent ID eagerly on creation, not deferred to result

Codex review caught that agent/conversation IDs were only saved in the
stream result handler. If createAgent() succeeded but send/stream failed,
the ID was lost and the next message would create a duplicate agent.

Now: getSession() persists the agent ID + runs first-run setup (name,
skills) immediately after createAgent(). persistSessionState() only
updates conversation ID on result.

Written by Cameron ◯ Letta Code

"Fail fast, but don't forget what you learned." -- unknown

* fix: persist conversation ID after send, before streaming

Codex review caught that conversationId was only saved on stream result.
If streaming disconnected or aborted before result, the next turn would
fall back to resumeSession(agentId) (default conversation) instead of
resuming the actual conversation -- forking context.

Now saved immediately after successful send(), matching the pre-refactor
behavior where it was saved after initialize().

Written by Cameron ◯ Letta Code

"The best time to save state was before the failure. The second best time is now." -- adapted proverb
2026-02-09 15:19:13 -08:00
Cameron
a966315c92 fix: switch group batching from fixed timer to 5-second debounce (#237)
* fix: switch group batching from fixed timer to 5-second debounce

The old 10-minute fixed timer caused groups to feel unresponsive after
inactivity. Now uses debounce: timer resets on every new message, flushes
after 5 seconds of quiet. @mentions still flush immediately.

New config: groupDebounceSec (default 5). Old groupPollIntervalMin still
works (converted to ms) for backward compatibility.

Fixes #229

Written by Cameron ◯ Letta Code

"The user is always right. If there is a problem with the use of the system, it's the system that's wrong, not the user." -- Don Norman

* docs: add group debounce configuration reference

Document groupDebounceSec, instantGroups, and debounce behavior
in the channel configuration section.

Written by Cameron ◯ Letta Code

"Good documentation is like a good joke: if you have to explain it, it's not that good." -- Kelsey Hightower
2026-02-09 11:14:30 -08:00
Cameron
2c2ecbce9b fix: switch group batching from fixed timer to 5-second debounce (#237)
The old 10-minute fixed timer caused groups to feel unresponsive after
inactivity. Now uses debounce: timer resets on every new message, flushes
after 5 seconds of quiet. @mentions still flush immediately.

New config: groupDebounceSec (default 5). Old groupPollIntervalMin still
works (converted to ms) for backward compatibility.

Fixes #229

Written by Cameron ◯ Letta Code

"The user is always right. If there is a problem with the use of the system, it's the system that's wrong, not the user." -- Don Norman
2026-02-09 11:11:24 -08:00
Cameron
d98c0b27c3 Merge pull request #198 from letta-ai/letta/issue-169-20260206-2042
fix: remove model field from lettabot config, add `lettabot model` command
2026-02-09 11:04:56 -08:00
Cameron
32cf7169a6 fix: use Store class for v2 compat in model command, remove unused import
- Replace raw JSON parsing with Store class (v1+v2 format support)
- Remove unused listModels import from model.ts

Written by Cameron ◯ Letta Code

"Simplicity is the ultimate sophistication." -- Leonardo da Vinci
2026-02-09 10:55:21 -08:00
Cameron
4effadccb9 merge: resolve conflict with main (multi-agent architecture)
- Keep multi-agent normalizeAgents() flow from main
- Integrate deprecation warning for agent.model from PR
- Remove model from LettaBot constructor (server-side property)
- Remove Model: display from single-agent startup log

Written by Cameron ◯ Letta Code

"The best interface is no interface." -- Golden Krishna
2026-02-09 10:52:32 -08:00
Cameron
1a381757bb fix: Telegram messages truncated when MarkdownV2 edit fails (#236)
editMessage() had no fallback for MarkdownV2 failures (unlike sendMessage
which already falls back to plain text). When the agent generates markdown
tables or other complex formatting, the MarkdownV2 conversion can fail
mid-stream, silently leaving the user with whatever the last successful
streaming edit was -- a truncated message.

Three fixes:
- editMessage() now mirrors sendMessage's try/catch with plain-text fallback
- Final send retry no longer guarded by !messageId, so failed edits fall
  back to sending a new complete message
- Streaming edit errors are logged instead of silently swallowed

Written by Cameron ◯ Letta Code

"If you want to go fast, go alone. If you want to go far, go together." - African Proverb
2026-02-09 10:47:54 -08:00
Cameron
b8a248b0fb fix: CLI tools use Store class for v2 format compatibility (#235)
shared.ts was parsing lettabot-agent.json as v1 format directly,
returning null for v2 stores. Now uses the Store class which
handles v1/v2 transparently.

Affects lettabot-message, lettabot-react, and lettabot-history.

Written by Cameron ◯ Letta Code

"Simplicity is the ultimate sophistication." -- Leonardo da Vinci
2026-02-09 10:32:51 -08:00
Jason Carreira
16b5e5b7b7 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>
2026-02-09 10:16:10 -08:00
Cameron
673f247793 feat: custom heartbeat prompt via YAML config or file (#233)
* feat: custom heartbeat prompt via YAML config or file

Wire up the existing but unused HeartbeatConfig.prompt field so users
can customize what the agent sees during heartbeats. Adds three ways
to set it: inline YAML (prompt), file-based (promptFile, re-read each
tick for live editing), and env var (HEARTBEAT_PROMPT). Also documents
the <no-reply/> opt-out behavior.

Fixes #232

Written by Cameron ◯ Letta Code

"The only way to do great work is to love what you do." -- Steve Jobs

* test: add coverage for heartbeat prompt resolution

Tests buildCustomHeartbeatPrompt and HeartbeatService prompt resolution:
- default prompt fallback
- inline prompt usage
- promptFile loading
- inline > promptFile precedence
- live reload (file re-read each tick)
- graceful fallback on missing file
- empty file falls back to default

Written by Cameron ◯ Letta Code

"The only way to do great work is to love what you do." -- Steve Jobs
2026-02-09 10:01:15 -08:00
Cameron
999ee89cb0 feat: prepare package for npm publish (#227)
- Version 0.2.0 (was 1.0.0 -- too early for stable)
- Add files field: only ship dist/, .skills/, patches/
- Add engines: node >= 20
- Add repository, homepage, author metadata
- Add prepublishOnly: build + test gate
- Move patch-package from postinstall to prepare (don't run for end users)
- Add npm publish step to release workflow (requires NPM_TOKEN secret)
- Pre-releases publish with --tag next, stable with --tag latest
- Update release notes install instructions for npm

Closes #174 (once NPM_TOKEN is configured)

Written by Cameron ◯ Letta Code

"Shipping is a feature." -- Jez Humble
2026-02-09 09:52:48 -08:00
Cameron
abf3307e3d fix: include allowedUsers in env var channel fallback (#226)
normalizeAgents() env var fallback (added in #224) only mapped token
and dmPolicy, missing allowedUsers for all channels. This caused
dmPolicy=allowlist to reject everyone since the allowlist was empty.

Parses *_ALLOWED_USERS env vars (comma-separated) for all five
channels, matching the existing format used by onboard.ts and the
Railway env exporter.

Written by Cameron ◯ Letta Code

"We can only see a short distance ahead, but we can see plenty there that needs to be done." -- Alan Turing
2026-02-08 23:07:32 -08:00
Cameron
65cd82bc33 fix: restore env var channel config for container deploys (#224)
normalizeAgents() only read YAML config, breaking Railway/Docker
deploys where channels are configured via environment variables
(TELEGRAM_BOT_TOKEN, etc.). Add env var fallback in the legacy
single-agent path.

Multi-agent mode still requires YAML configuration.

Written by Cameron ◯ Letta Code

"The cheapest, fastest, and most reliable components are those that aren't there." -- Gordon Bell
2026-02-08 22:42:22 -08:00
Cameron
61a7450106 docs: multi-agent configuration reference (#223)
* docs: add multi-agent configuration reference

Document the agents[] YAML config, per-agent options, migration path
from single to multi-agent, and known limitations (#219, #220, #221).

Written by Cameron ◯ Letta Code

"Documentation is a love letter that you write to your future self." -- Damian Conway

* docs: fix channels required claim and soften isolation wording

- channels is not strictly required per-agent (validation is global)
- isolation has known exceptions, don't claim "fully isolated"

Written by Cameron ◯ Letta Code

"Clear is kind." -- Brene Brown
2026-02-08 22:36:25 -08:00
Cameron
5200a1e7e8 fix: false "no response" error after short streaming replies (#222)
When the agent sends a short single-chunk response (e.g. "Yep."), the
streaming edit path sends it to the channel immediately but never sets
sentAnyMessage. When finalizeMessage() then tries to edit the message
to identical content, Telegram rejects it ("message not modified"),
the catch swallows the error, and the post-loop fallback shows a
spurious "(No response)" error alongside the actual reply.

Fix: (1) set sentAnyMessage when the streaming path sends a new message,
(2) treat edit failures as success when messageId exists (the message
is already displayed to the user).

Written by Cameron ◯ Letta Code

"The stream carried everything -- we just forgot to look." - on debugging
2026-02-08 22:26:25 -08:00
Cameron
40586cdc9a fix: multi-agent state isolation and config.id wiring (#218)
Two bugs from the Phase 1 merge:

1. Store not scoped to agent name: LettaBot constructor passed no agent
   name to Store, so all agents in multi-agent mode shared the same
   agentId/conversationId state. Now passes config.agentName.

2. agentConfig.id ignored: Users could set `id: agent-abc123` in YAML
   but it was never applied. Now checked before store verification.

Written by Cameron ◯ Letta Code

"The best error message is the one that never shows up." -- Thomas Fuchs
2026-02-08 21:56:47 -08:00
Cameron
2f5242decd feat: wire up multi-agent in main.ts (Phase 1c) (#217)
Multi-agent configs now work end-to-end. Users can write `agents:` in
lettabot.yaml and each agent gets its own channels, cron, heartbeat,
and polling services.

- Rewrite main() to loop over normalizeAgents() output
- Extract createChannelsForAgent() and createGroupBatcher() helpers
- Replace env-var config parsing with YAML-direct for per-agent config
- LettaGateway manages all agents, API server uses gateway for delivery
- Per-agent services: cron, heartbeat, polling are agent-scoped
- Store v2 format handled at startup for LETTA_AGENT_ID loading
- Legacy single-agent configs work unchanged via normalizeAgents()

Part of #109

Written by Cameron ◯ Letta Code

"Make it work, make it right, make it fast." -- Kent Beck
2026-02-08 21:42:42 -08:00
Cameron
2fbd767c50 feat: add AgentSession interface and LettaGateway orchestrator (Phase 1b) (#216)
Interface-first multi-agent orchestration layer.

- Define AgentSession interface capturing the contract consumers depend on
- LettaBot implements AgentSession (already has all methods, now explicit)
- LettaGateway manages multiple named AgentSession instances
- Update heartbeat, cron, polling, API server to depend on interface, not concrete class
- 8 new gateway tests

No behavioral changes. Consumers that used LettaBot now use AgentSession interface,
enabling multi-agent without modifying consumer code.

Part of #109

Written by Cameron ◯ Letta Code

"First, solve the problem. Then, write the code." -- John Johnson
2026-02-08 21:41:45 -08:00
Cameron
3339a880f1 feat: multi-agent config types, normalizeAgents, and Store v2 (Phase 1a) (#215)
* feat: add multi-agent config types, normalizeAgents, and Store v2

Foundation for multi-agent support (Phase 1a). No behavioral changes.

- Add AgentConfig interface for per-agent configuration
- Add agents[] field to LettaBotConfig for docker-compose style multi-agent configs
- Add normalizeAgents() to convert legacy single-agent config to agents[] array
- Evolve Store to v2 format with per-agent state isolation
- Auto-migrate v1 store files to v2 transparently
- 18 new tests for normalization and store migration

Part of #109

Written by Cameron ◯ Letta Code

"The only way to do great work is to love what you do." -- Steve Jobs

* fix: harden multi-agent normalization and store isolation

* style: simplify redundant WhatsApp enabled check

WhatsApp has no credential to check (uses QR pairing), so the
`enabled !== false && enabled` condition simplifies to just `enabled`.

Written by Cameron ◯ Letta Code

"Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
2026-02-08 21:39:48 -08:00
Gabriele Sarti
110681e979 feat: pass images to the LLM via multimodal API (#184)
feat: pass images to the LLM via multimodal API

When users send images through any channel, the actual image content is now passed to the LLM via the SDK's multimodal API (imageFromFile/imageFromURL) instead of just text metadata.

- Graceful fallback for unsupported MIME types, missing files, and load errors
- Opt-out via features.inlineImages: false in config
- Warns when model doesn't support vision (detects [Image omitted] in response)
2026-02-08 20:22:32 -08:00
Cameron
528ef1f40e fix: add deprecation warning for agent.model + e2e model tests
- Warn at startup when agent.model is present in lettabot.yaml (deprecated, now ignored)
- Add e2e tests for model listing and agent model retrieval
- Remove stale model field from existing e2e test (BotConfig no longer has it)

Written by Cameron ◯ Letta Code

"The best way to predict the future is to invent it." -- Alan Kay
2026-02-08 20:09:39 -08:00
Cameron
64f12be6cd docs: add api.port config reference + Telegram message splitting note (#206)
- Document api.port/host/corsOrigin in configuration.md (example,
  reference table, and env var mapping)
- Add "Long Messages" section to telegram-setup.md noting the
  automatic 4096-char splitting behavior

Written by Cameron ◯ Letta Code

"The best time to plant a tree was 20 years ago. The second best time is now." - Chinese Proverb
2026-02-08 16:48:32 -08:00
Cameron
56e3df17d2 feat: persist voice message audio files to disk (#207)
Voice messages are now saved to the attachments directory regardless of
transcription outcome. The audio file path is included in the message
envelope so agents always have access to the original audio, even when
transcription fails or returns empty.

🐾 Generated with [Letta Code](https://letta.com)

Co-authored-by: Letta <noreply@letta.com>
2026-02-08 16:48:21 -08:00
Gabriele Sarti
66e8c462bf feat: group message batching + Telegram group gating + instantGroups (#187)
* feat: add group message batching, Telegram group gating, and instantGroups

Group Message Batcher:
- New GroupBatcher buffers group chat messages and flushes on timer or @mention
- Channel-agnostic: works with any ChannelAdapter
- Configurable per-channel via groupPollIntervalMin (default: 10min, 0 = immediate)
- formatGroupBatchEnvelope formats batched messages as chat logs for the agent
- Single-message batches unwrapped to use DM-style formatMessageEnvelope

Telegram Group Gating:
- my_chat_member handler: bot leaves groups when added by unpaired users
- Groups added by paired users are auto-approved via group-store
- Group messages bypass DM pairing (middleware skips group/supergroup chats)
- Mention detection for @bot in group messages

Channel Group Support:
- All adapters: getDmPolicy() interface method
- Discord: serverId (guildId), wasMentioned, pairing bypass for guilds
- Signal: group messages bypass pairing
- Slack: wasMentioned field on messages

instantGroups Config:
- Per-channel instantGroups config to bypass batching for specific groups
- For Discord, checked against both serverId and chatId
- YAML config → env vars → parsed in main.ts → Set passed to bot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: preserve large numeric IDs in instantGroups YAML config

Discord snowflake IDs exceed Number.MAX_SAFE_INTEGER, so YAML parses
unquoted IDs as lossy JavaScript numbers. Use the document AST to
extract the original string representation and avoid precision loss.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: Slack dmPolicy, Telegram group gating check

- Add dmPolicy to SlackConfig and wire through config/env/adapter
  (was hardcoded to 'open', now reads from config like other adapters)
- Check isGroupApproved() in Telegram middleware before processing
  group messages (approveGroup was called but never checked)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 14:47:22 -08:00
Cameron
c88621574a fix: remove StreamWatchdog that kills long-running agent operations (#204)
The watchdog aborted streams after idle timeouts, which breaks legitimate
subagent operations. The SDK stream should throw on connection failures.

Written by Cameron ◯ Letta Code

"The stream will end when it's ready." - a patient engineer
2026-02-07 14:43:01 -08:00
github-actions[bot]
2fe5ebe06d feat: expose polling configuration in lettabot.yaml (#202)
Add a top-level `polling` section to lettabot.yaml for configuring
background polling (Gmail, etc.) instead of relying solely on env vars.

- Add `PollingYamlConfig` type with `enabled`, `intervalMs`, and `gmail` subsection
- Update `configToEnv()` to map new polling config to env vars
- Update `main.ts` to read from YAML config with env var fallback
- Maintain backward compat with `integrations.google` legacy path
- Document polling config in docs/configuration.md

Fixes #201

Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com>
Co-authored-by: Cameron <cpfiffer@users.noreply.github.com>
2026-02-07 13:09:05 -08:00
Cameron
9a1fd68b7e fix: add api.port config + Telegram message splitting + error handling hardening (#200)
Addresses two community-reported issues:

1. Port configuration: The API server port was only readable from the
   PORT env var. Add api.port/host/corsOrigin to lettabot.yaml schema
   so users can configure it alongside other settings.

2. Telegram sending failures: Messages exceeding Telegram's 4096 char
   limit would fail with no splitting. Add splitMessageText() that
   splits at paragraph/line boundaries (~3800 chars to leave room for
   MarkdownV2 escaping), with a safety net re-split if formatting
   expands beyond 4096. Also wrap two unguarded adapter.sendMessage()
   calls in bot.ts error paths that could cascade into unhandled
   rejections crashing the process.

Written by Cameron ◯ Letta Code

"When you can't make them see the light, make them feel the heat." - Ronald Reagan
2026-02-07 11:20:07 -08:00
Cameron
9cb35228fd fix: deduplicate tool_call stream events by toolCallId (#199)
The Letta server streams tool_call_message events token-by-token as
the model generates tool arguments. A single tool call (e.g.
memory_rethink with a large new_memory arg) can produce hundreds of
wire events, all sharing the same toolCallId. Without dedup, the bot
miscounts these as separate tool calls -- logging "Calling tool: X"
hundreds of times and potentially triggering the tool-loop abort at
maxToolCalls (default 100) for what is actually a single call.

Track seen toolCallIds per stream and skip chunks already yielded.

Written by Cameron and Letta Code

"In the beginner's mind there are many possibilities, but in the
expert's mind there are few." -- Shunryu Suzuki
2026-02-06 16:52:33 -08:00
letta-code
7e82374865 fix: remove model field from lettabot config, add lettabot model command
The model field in lettabot.yaml was redundant and misleading -- the model
is configured on the Letta agent server-side, and lettabot shouldn't
override it. Users were confused seeing a model in their startup log that
didn't match the actual model being used.

Changes:
- Remove `model` from `LettaBotConfig.agent` (made optional for backward compat)
- Remove `model` from `BotConfig` interface and `bot.ts` createAgent() calls
- Remove `model` from `main.ts` config construction and startup log
- Stop saving `model` to lettabot.yaml during onboarding
- Stop mapping `agent.model` to `MODEL` env var in config/io.ts
- Add `getAgentModel()` and `updateAgentModel()` to letta-api.ts
- Add new `src/commands/model.ts` with three subcommands:
  - `lettabot model` - interactive model selector
  - `lettabot model show` - show current agent model
  - `lettabot model set <handle>` - set model directly
- Wire up model command in cli.ts with help text
- Update docs/configuration.md, lettabot.example.yaml, SKILL.md

Model selection during `lettabot onboard` is preserved for new agent
creation -- the selected model is passed to createAgent() but is NOT
saved to the config file.

Fixes #169

Co-authored-by: Cameron <cpfiffer@users.noreply.github.com>
2026-02-06 20:52:26 +00:00
jamesdanielwhitford
f413df8df7 feat: add OpenAI voice transcription setup to onboarding wizard (#191) 2026-02-06 12:09:33 -08:00
Cameron
b1d69965b5 feat: add <no-reply/> silent marker for agent opt-out (#196)
* feat: add {{NO_REPLY}} silent marker for agent opt-out

Allow the agent to respond with {{NO_REPLY}} to suppress message
delivery for messages that don't warrant a reply. The marker is
checked in three places: the streaming edit guard (prefix match to
prevent partial sends), finalizeMessage(), and the post-stream
response handler.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: use <no-reply/> XML marker instead of {{NO_REPLY}}

Switch to XML-style self-closing tag for consistency with the XML
envelope format used elsewhere, and because LLMs produce well-formed
XML tags more reliably than template syntax.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add no-reply hint to group chat envelopes

Agents created outside lettabot (via ADE, Letta Cloud) won't have the
system prompt telling them about <no-reply/>. Adding the hint to group
chat envelopes makes the opt-out mechanism self-documenting.

Written by Cameron ◯ Letta Code

"Silence is one of the great arts of conversation." -- Marcus Tullius Cicero

---------

Co-authored-by: Gabriele Sarti <gabriele.sarti996@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 11:08:56 -08:00
Ari Webb
04f58e72c8 feat: add ergonomic channel management CLI (#188)
* feat: add ergonomic channel management CLI

Add `lettabot channels` command for easier channel management:
- `lettabot channels` - Interactive menu
- `lettabot channels list` - Show status of all channels
- `lettabot channels add <channel>` - Add with focused setup
- `lettabot channels remove <channel>` - Remove/disable
- `lettabot channels enable/disable <channel>` - Quick toggle

This makes it much easier to add a single channel without going
through the full onboard wizard. For example, adding Discord
after already having Telegram configured now only requires
the Discord-specific prompts.

Also fixes test for /reset command (was added but test not updated).

🐙 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>

* refactor: remove enable/disable commands from channels CLI

Simplify the channels CLI to just add/remove. The enable/disable
commands were redundant - users can use `add` to reconfigure
and `remove` to disable.

🐙 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>

* clean up

---------

Co-authored-by: Letta <noreply@letta.com>
2026-02-06 10:58:09 -08:00
Gabriele Sarti
b1e1b5693c feat: make polling interval configurable via lettabot.yaml (#181)
Add `pollIntervalSec` to the Google integration config so the email
polling interval can be set in lettabot.yaml instead of requiring
the POLLING_INTERVAL_MS environment variable.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 10:50:22 -08:00
Gabriele Sarti
8cd48d9f54 fix: abort agent when stuck in tool-call loop (#185)
Add a configurable maxToolCalls safeguard (default: 100) that aborts the
session when the agent enters an infinite tool-calling loop. The stream
watchdog didn't catch this because the stream was active (sending
tool_call events), just not productive.

Configurable via lettabot.yaml:
  features:
    maxToolCalls: 100

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 10:43:37 -08:00
Cameron
0d32e05906 fix: orphaned approval recovery, empty-result retry, deploy stability (#183)
Fixes #180. See #194 for full analysis.
2026-02-06 10:42:41 -08:00
Cameron
5dea82acc5 fix: pin baileys to 6.7.21 and fix stale command count test (#193)
The ^6.7.21 caret range resolves to 6.17.16 on fresh npm install, which
ships incompatible TypeScript types (no call signatures on default export).
Pins exact version and adds explicit type annotation on getMessage key param.

Also updates commands.test.ts to expect 5 commands (reset was added but
test still expected 4).

Fixes #192

Written by Cameron ◯ Letta Code

"The caret giveth, and the caret taketh away."
2026-02-06 10:30:04 -08:00
Cameron
2373dbb3b1 fix: add npm overrides for keyv resolution (#162)
* fix: telegram ESM compatibility and improved diagnostics

- Replace telegram-markdown-v2 with telegramify-markdown (ESM compatible)
- Add raw text fallback when Telegram formatting fails, with error notice
- Improve empty response diagnostics: log agent ID, show conversation ID
- Add reset-conversation command hint to user messages
- Add telegram-format.test.ts with 7 tests

Fixes Railway deployment ERR_REQUIRE_ESM error with remark package.

Written by Cameron and Letta Code

"The best error message is the one that never shows up." - Thomas Fuchs

* fix: add npm overrides for keyv resolution

Users were still hitting ERR_MODULE_NOT_FOUND for keyv even after
PR #154 added it as a direct dependency. This happens because npm's
hoisting doesn't always resolve peer deps of optional deps properly.

npm overrides force the package manager to use our root keyv version
for all nested references, which is the idiomatic solution for
transitive peer dependency issues.

Also adds troubleshooting entry to README.

Written by Cameron ◯ Letta Code

"The best error message is the one that never shows up."
- Thomas Fuchs
2026-02-06 10:25:30 -08:00
dependabot[bot]
49db36f52f chore(deps): bump @letta-ai/letta-client from 1.7.7 to 1.7.8 (#186)
Bumps [@letta-ai/letta-client](https://github.com/letta-ai/letta-node) from 1.7.7 to 1.7.8.
- [Release notes](https://github.com/letta-ai/letta-node/releases)
- [Changelog](https://github.com/letta-ai/letta-node/blob/main/CHANGELOG.md)
- [Commits](https://github.com/letta-ai/letta-node/compare/v1.7.7...v1.7.8)

---
updated-dependencies:
- dependency-name: "@letta-ai/letta-client"
  dependency-version: 1.7.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-06 10:25:27 -08:00
Cameron
3ff33fee87 fix: client-side defensive recovery for orphaned approval_request_messages (#182)
When a conversation has an orphaned approval_request_message from a
cancelled/failed run, every subsequent message fails with 409 CONFLICT.
The existing attemptRecovery() can't find these because it checks
agent.pending_approval (null) and scans runs with stop_reason=requires_approval
(but the orphaned run is cancelled/failed).

Adds recoverOrphanedConversationApproval() which directly inspects conversation
messages, finds unresolved approval requests, verifies the originating run is
terminated, and sends denials to clear the stuck state. Both processMessage()
and sendToAgent() now catch CONFLICT errors and retry once after recovery.

Fixes #180

Written by Cameron ◯ Letta Code

"It is not the strongest of the species that survives, nor the most intelligent,
but the one most responsive to change." - Charles Darwin
2026-02-05 17:46:44 -08:00
Cameron
3b7150013c fix: approval detection missing include param + /reset command + startup check (#175)
getPendingApprovals() was calling agents.retrieve() without the
include: ['agent.pending_approval'] parameter, so the Letta API never
returned the pending_approval field. This caused stuck server-side tool
approvals (requires_approval=true) to go undetected, leaving the agent
permanently stuck with empty responses.

Also adds:
- Proactive ensureNoToolApprovals() on startup to disable requires_approval
- /reset slash command for deployed instances (clears conversation, keeps memory)
- Robust parsing for ToolCallDelta and deprecated tool_call field formats

Written by Cameron ◯ Letta Code

"The only way to do great work is to love what you do." - Steve Jobs
2026-02-05 17:38:48 -08:00
Cameron
0bed2cc166 fix: replace deprecated discord.js 'ready' event with 'clientReady' (#178)
The 'ready' event is deprecated in discord.js v14 and will break in v15.
Also switch from on() to once() since this event fires only once per login.

Reported-by: Aeo

Written by Cameron ◯ Letta Code

"The quietest fix is the one that prevents the loudest crash." -- a wise linter
2026-02-05 16:19:47 -08:00
Cameron
002fa48b2a docs: add releasing guide (#177)
Documents the automated release workflow:
- How to tag and push releases
- Pre-release detection (alpha/beta/rc)
- Versioning strategy (semver)
- Release checklist
- Links to npm publish tracking issue (#174)

Written by Cameron ◯ Letta Code

"Ship it." - GitHub
2026-02-05 15:13:19 -08:00
Cameron
610f2a64eb fix: remove broken letta-code notification step from release workflow (#176)
The `if: ${{ secrets.LETTA_API_KEY != '' }}` expression caused a
workflow parse error (secrets can't be used in `if` conditions).
Also `custom_prompt` may not be a valid input for letta-code-action.

Stripped the step for now -- will re-add once letta-code-action
supports release events.

Written by Cameron ◯ Letta Code

"Simplicity is the ultimate sophistication."
- Leonardo da Vinci
2026-02-05 15:07:40 -08:00
Cameron
9bd0134f72 feat: add automated GitHub Release workflow (#173)
Triggers on version tags (v*). Workflow:
1. Builds and runs tests (gate)
2. Generates release notes from merged PRs since last tag
3. Creates GitHub Release (with pre-release detection for alpha/beta/rc)
4. Optionally pings letta-code agent to write a friendly summary

Usage:
  git tag v0.1.0
  git push origin v0.1.0

Written by Cameron ◯ Letta Code

"Release early, release often."
- Eric S. Raymond
2026-02-05 14:58:01 -08:00