feat: add Letta Code detection and restore - #3107
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughHerdr adds Letta Code support across agent detection, session integration, native conversation restoration, CLI targets, configuration, tests, API schemas, and localized documentation. ChangesLetta Code support
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: 🟡 Moderate · up to The PR adds Letta session integration, but setup can persist a hook reference before the hook is ready, causing later sessions to invoke a broken hook; stale blocked-state detection and hook-setting compatibility concerns also remain. These bounded integration risks should be fixed or explicitly accepted before merging. Sequence Diagram(s)sequenceDiagram
participant User
participant HerdrCLI
participant LettaSettings
participant LettaHook
participant HerdrPane
User->>HerdrCLI: integration install letta
HerdrCLI->>LettaSettings: write SessionStart hook
HerdrCLI->>LettaHook: install managed script
LettaHook->>HerdrPane: report agent session metadata
User->>HerdrCLI: resume Letta conversation
HerdrCLI->>LettaHook: plan letta --conversation arguments
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
src/config/sound.rs (1)
47-47: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAdd an explicit regression assertion for omitted
letta.
#[serde(default)]already preservesAgentSoundOverrides::default(). Add an assertion that an absentlettafield producesAgentSoundSetting::Default.src/detect/mod.rs (1)
629-640: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueThe bare
letta-code/lettapath match is broad.The
windows(2)check matches any path that contains aletta-codedirectory followed by alettacomponent, outsidenode_modules. A local checkout path such as/home/user/src/letta-code/letta/build.jswould be classified as Letta. The scopedwindows(4)match above already covers the published package layout. Theis_interactive_letta_processgate limits the damage, so this is a small risk only.Consider anchoring the fallback to a
node_modulesor.bincontext, or to a trailing component.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: aa59483c-24ca-4cc4-8592-87c045048df4
📒 Files selected for processing (39)
docs/next/CHANGELOG.mddocs/next/api/herdr-api.schema.jsondocs/next/website/src/content/docs/agent-automation.mdxdocs/next/website/src/content/docs/agents.mdxdocs/next/website/src/content/docs/cli-reference.mdxdocs/next/website/src/content/docs/integrations.mdxdocs/next/website/src/content/docs/ja/agent-automation.mdxdocs/next/website/src/content/docs/ja/agents.mdxdocs/next/website/src/content/docs/ja/cli-reference.mdxdocs/next/website/src/content/docs/ja/integrations.mdxdocs/next/website/src/content/docs/ja/session-state.mdxdocs/next/website/src/content/docs/session-state.mdxdocs/next/website/src/content/docs/zh-cn/agent-automation.mdxdocs/next/website/src/content/docs/zh-cn/agents.mdxdocs/next/website/src/content/docs/zh-cn/cli-reference.mdxdocs/next/website/src/content/docs/zh-cn/integrations.mdxdocs/next/website/src/content/docs/zh-cn/session-state.mdxdocs/next/website/src/data/config-reference.jsonsrc/agent_resume.rssrc/api/schema/integrations.rssrc/cli/integration.rssrc/config/model.rssrc/config/sidebar.rssrc/config/sound.rssrc/detect/manifest.rssrc/detect/manifests/letta.tomlsrc/detect/mod.rssrc/integration/actions.rssrc/integration/assets/letta/herdr-agent-session.ps1src/integration/assets/letta/herdr-agent-session.shsrc/integration/env.rssrc/integration/mod.rssrc/integration/registry.rssrc/integration/targets.rssrc/integration/tests.rssrc/integration/types.rssrc/main.rswebsite/agent-detection/index.tomlwebsite/agent-detection/letta.toml
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
04c821e to
cfeed00
Compare
Greptile SummaryThe PR adds Letta Code as a supported agent with process and screen-state detection, optional session reporting, and native conversation restoration.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains within the eligible follow-up-review scope. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/detect/mod.rs | Adds Letta identity aliases, interactive-process filtering, executable selection, and screen-manifest registration. |
| src/detect/manifests/letta.toml | Defines prioritized OSC and screen fallbacks for Letta blocked, working, idle, and uncertain states. |
| src/integration/targets.rs | Adds transactional Letta hook installation and uninstall behavior while preserving unrelated settings and hooks. |
| src/integration/assets/letta/herdr-agent-session.sh | Reports named and agent-scoped default Letta conversations from SessionStart payloads on Unix. |
| src/integration/assets/letta/herdr-agent-session.ps1 | Implements the corresponding silent SessionStart session reporter for Windows. |
| src/agent_resume.rs | Maps persisted Letta conversation references to named or default-conversation restore commands. |
| src/api/schema/integrations.rs | Exposes Letta as an installable integration target through the typed API schema. |
Sequence Diagram
sequenceDiagram
participant User
participant Herdr
participant Letta as Letta Code
participant Hook as SessionStart Hook
participant Persist as Session Persistence
User->>Herdr: Start Letta agent
Herdr->>Letta: letta [arguments]
Letta-->>Herdr: OSC and screen output
Herdr->>Herdr: Detect idle, working, or blocked
Letta->>Hook: SessionStart payload
Hook->>Herdr: Report conversation reference
Herdr->>Persist: Save Letta session identity
Note over Herdr,Persist: After server restoration
Persist-->>Herdr: Restore session reference
alt Named conversation
Herdr->>Letta: "letta --conversation <id>"
else Default conversation
Herdr->>Letta: "letta --conversation default --agent <agent-id>"
end
Reviews (5): Last reviewed commit: "feat: add Letta Code detection and resto..." | Re-trigger Greptile
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/config/sound.rs (1)
226-226: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the Letta-specific lookup with a non-default test.
The current assertion verifies only the default value. It does not verify that a configured value reaches
AgentSoundOverrides::for_agentforAgent::Letta. Addletta = "on"to the fixture and assert both the parsed field and the lookup result.Suggested test extension
[ui.sound.agents] droid = "off" claude = "on" +letta = "on" ... - assert_eq!(config.ui.sound.agents.letta, AgentSoundSetting::Default); + assert_eq!(config.ui.sound.agents.letta, AgentSoundSetting::On); + assert_eq!( + config + .ui + .sound + .agents + .for_agent(Some(crate::detect::Agent::Letta)), + AgentSoundSetting::On + );src/detect/mod.rs (1)
692-735: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider normalizing the
--flag=valueform once.The list repeats each option twice: once as an exact match and once as a
--name=prefix. Splitting the argument at the first=and matching the name once removes the duplication and keeps both forms in sync when the option list changes.♻️ Possible simplification
- if cli_args.iter().any(|arg| { - matches!( - arg.as_str(), + if cli_args.iter().any(|arg| { + let name = arg.split_once('=').map_or(arg.as_str(), |(name, _)| name); + matches!( + name, "-p" | "--print"Then drop the
starts_with("--…=")chain.src/integration/targets.rs (1)
1209-1211: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReuse a single
letta_dir()result.
letta_dir()is called twice. Bind it once and derive both paths from it.♻️ Proposed change
- let hook_path = letta_dir()?.join("hooks").join(LETTA_HOOK_INSTALL_NAME); - let settings_path = letta_dir()?.join("settings.json"); + let dir = letta_dir()?; + let hook_path = dir.join("hooks").join(LETTA_HOOK_INSTALL_NAME); + let settings_path = dir.join("settings.json");
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a6b68c80-a89f-46f3-907b-3c80fcdc37c8
📒 Files selected for processing (6)
docs/next/website/src/data/config-reference.jsonsrc/config/sound.rssrc/detect/mod.rssrc/integration/assets/letta/herdr-agent-session.ps1src/integration/targets.rssrc/integration/tests.rs
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
0e6f70e to
6c0ff7b
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/integration/targets.rs (1)
1011-1018: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winUse a named millisecond timeout constant for the Letta hook. Letta Code v0.30.28 supports both
timeoutin milliseconds andquietas a boolean. Replace the unexplained10_000literal withLETTA_HOOK_TIMEOUT_MS.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0a396887-ed40-43ca-91ce-80b4fa6492ca
📒 Files selected for processing (3)
src/config/sound.rssrc/detect/mod.rssrc/integration/targets.rs
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
6c0ff7b to
e03e033
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 25b3509d-f279-4a69-94a2-22d181088986
📒 Files selected for processing (3)
src/integration/mod.rssrc/integration/targets.rssrc/integration/tests.rs
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
refs #3106 Co-authored-by: Cameron <cameron@pfiffer.org>
e03e033 to
f96c294
Compare
|
hey @just-cameron could you verify if this branch works great with letta? |
Summary
Builds on the initial integration work from @just-cameron in https://github.com/just-cameron/herdr/tree/letta-code-integration.
Validation
just checkRefs #3106