@letta-ai/letta-code 0.18.1 → 0.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,7 @@
38
38
  "highlight.js": "^11.11.1",
39
39
  "ink-link": "^5.0.0",
40
40
  "lowlight": "^3.3.0",
41
+ "node-pty": "^1.1.0",
41
42
  "open": "^10.2.0",
42
43
  "sharp": "^0.34.5",
43
44
  "ws": "^8.19.0"
@@ -67,7 +68,7 @@
67
68
  "fix": "bunx --bun @biomejs/biome@2.2.5 check --write src",
68
69
  "typecheck": "tsc --noEmit",
69
70
  "check": "bun run scripts/check.js",
70
- "dev": "bun --loader:.md=text --loader:.mdx=text --loader:.txt=text run src/index.ts",
71
+ "dev": "LETTA_DEBUG=1 bun --loader:.md=text --loader:.mdx=text --loader:.txt=text run src/index.ts",
71
72
  "build": "node scripts/postinstall-patches.js && bun run build.js",
72
73
  "test:update-chain:manual": "bun run src/tests/update-chain-smoke.ts --mode manual",
73
74
  "test:update-chain:startup": "bun run src/tests/update-chain-smoke.ts --mode startup",
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: dispatching-coding-agents
3
+ description: Dispatch tasks to Claude Code and Codex CLI agents via Bash. Use when you want a second opinion, need to parallelize research across models, or face a hard coding problem that benefits from a stateless agent with frontier reasoning. Covers non-interactive execution, model selection, session resumption, and the history-analyzer subagent for accessing their past sessions.
4
+ ---
5
+
6
+ # Dispatching Coding Agents
7
+
8
+ You can shell out to **Claude Code** (`claude`) and **Codex** (`codex`) as stateless sub-agents via Bash. They have full filesystem and tool access but **zero memory** — you must provide all necessary context in the prompt.
9
+
10
+ ## Philosophy
11
+
12
+ You are the experienced manager with persistent memory. Claude Code and Codex are high-intellect but stateless — reborn fresh every invocation. Your job:
13
+
14
+ 1. **Provide context** — include relevant file paths, architecture context, and constraints from your memory
15
+ 2. **Be specific** — tell them exactly what to investigate or implement, and what files to look at
16
+ 3. **Run async when possible** — use `run_in_background: true` on Bash calls to avoid blocking
17
+ 4. **Learn from results** — track which models/agents perform better on which tasks, and update memory
18
+ 5. **Mine their history** — use the `history-analyzer` subagent to access past Claude Code and Codex sessions
19
+
20
+ ## Non-Interactive Execution
21
+
22
+ ### Claude Code
23
+
24
+ ```bash
25
+ claude -p "YOUR PROMPT" --model MODEL --dangerously-skip-permissions
26
+ ```
27
+
28
+ - `-p` / `--print`: non-interactive mode, prints response and exits
29
+ - `--dangerously-skip-permissions`: use in trusted repos to skip approval prompts. Without this, killed/timed-out sessions can leave stale approval state that blocks future runs with "stale approval from interrupted session" errors.
30
+ - `--model MODEL`: alias (`sonnet`, `opus`) or full name (`claude-sonnet-4-6`)
31
+ - `--effort LEVEL`: `low`, `medium`, `high` — controls reasoning depth
32
+ - `--append-system-prompt "..."`: inject additional system instructions
33
+ - `--allowedTools "Bash Edit Read"`: restrict available tools
34
+ - `--max-budget-usd N`: cap spend for the invocation
35
+ - `-C DIR`: set working directory
36
+
37
+ Example — research task with Opus:
38
+ ```bash
39
+ claude -p "Trace the request flow from POST /agents/{id}/messages through to the LLM call. Cite files and line numbers." \
40
+ --model opus --dangerously-skip-permissions -C /path/to/repo
41
+ ```
42
+
43
+ ### Codex
44
+
45
+ ```bash
46
+ codex exec "YOUR PROMPT" -m codex-5.3 --full-auto
47
+ ```
48
+
49
+ - `exec`: non-interactive mode
50
+ - `-m MODEL`: prefer `codex-5.3` (frontier), also `gpt-5.2`, `o3`
51
+ - `--full-auto`: auto-approve commands in sandbox (equivalent to `-a on-request --sandbox workspace-write`)
52
+ - `-C DIR`: set working directory
53
+ - `--search`: enable web search tool
54
+
55
+ Example — research task:
56
+ ```bash
57
+ codex exec "Find all places where system prompt is recompiled. Cite files and line numbers." \
58
+ -m codex-5.3 --full-auto -C /path/to/repo
59
+ ```
60
+
61
+ ## Session Resumption
62
+
63
+ Both CLIs persist sessions to disk. Use resumption to continue a line of investigation.
64
+
65
+ ### Claude Code
66
+
67
+ ```bash
68
+ # Resume by session ID
69
+ claude -r SESSION_ID -p "Follow up: now check if..."
70
+
71
+ # Continue most recent session in current directory
72
+ claude -c -p "Also check..."
73
+
74
+ # Fork a session (new ID, keeps history)
75
+ claude -r SESSION_ID --fork-session -p "Try a different approach..."
76
+ ```
77
+
78
+ ### Codex
79
+
80
+ ```bash
81
+ # Resume by session ID (interactive)
82
+ codex resume SESSION_ID "Follow up prompt"
83
+
84
+ # Resume most recent session
85
+ codex resume --last "Follow up prompt"
86
+
87
+ # Fork a session (new ID, keeps history)
88
+ codex fork SESSION_ID "Try a different approach"
89
+ codex fork --last "Try a different approach"
90
+ ```
91
+
92
+ Note: Codex `resume` and `fork` launch interactive sessions, not non-interactive `exec`. For non-interactive follow-ups with Codex, start a fresh `exec` and include relevant context from the previous session in the prompt.
93
+
94
+ ## Capturing Session IDs
95
+
96
+ When you dispatch a task, capture the session ID so you can access the full session history later. The Bash output you get back is just the final summary — the full session (intermediate tool calls, files read, reasoning) is stored locally and contains much richer data.
97
+
98
+ ### Claude Code
99
+
100
+ Use `--output-format json` to get structured output including the session ID:
101
+ ```bash
102
+ claude -p "YOUR PROMPT" --model opus --dangerously-skip-permissions --output-format json 2>&1
103
+ ```
104
+ The JSON response includes `session_id`, `cost_usd`, `duration_ms`, `num_turns`, and `result`.
105
+
106
+ Session files are stored at:
107
+ ```
108
+ ~/.claude/projects/<encoded-path>/<session-id>.jsonl
109
+ ```
110
+ Where `<encoded-path>` is the working directory with `/` replaced by `-` (e.g. `/Users/foo/repos/bar` → `-Users-foo-repos-bar`).
111
+
112
+ ### Codex
113
+
114
+ Codex prints the session ID in its output header:
115
+ ```
116
+ session id: 019c9b76-fff4-7f40-a895-a58daa3c74c6
117
+ ```
118
+ Extract it with: `grep "^session id:" output | awk '{print $3}'`
119
+
120
+ Session files are stored at:
121
+ ```
122
+ ~/.codex/sessions/<year>/<month>/<day>/rollout-*.jsonl
123
+ ```
124
+
125
+ ## Session History
126
+
127
+ Both CLIs persist full session data (tool calls, reasoning, files read) locally. This is richer than the summarized output you get back in Bash.
128
+
129
+ ### Where sessions are stored
130
+
131
+ **Claude Code:**
132
+ ```
133
+ ~/.claude/projects/<encoded-path>/<session-id>.jsonl
134
+ ```
135
+ Where `<encoded-path>` is the working directory with `/` replaced by `-` (e.g. `/Users/foo/repos/bar` → `-Users-foo-repos-bar`). Use `--output-format json` to get the `session_id` in structured output.
136
+
137
+ **Codex:**
138
+ ```
139
+ ~/.codex/sessions/<year>/<month>/<day>/rollout-*-<session-id>.jsonl
140
+ ```
141
+ The session ID is printed in the output header: `session id: <uuid>`.
142
+
143
+ ### When to analyze sessions
144
+
145
+ **Don't** run history-analyzer after every dispatch — the reflection agent already captures insights from your conversation naturally, and single-session analysis tends to produce overly detailed memory that's better represented by the code itself.
146
+
147
+ **Do** use `history-analyzer` for its intended purpose: **bulk migration** when bootstrapping memory from months of accumulated Claude Code/Codex history (e.g. during `/init`). For that, see the `migrating-from-codex-and-claude-code` skill.
148
+
149
+ Session files are useful for:
150
+ - **Resuming** a line of investigation (see Session Resumption above)
151
+ - **Reviewing** what an agent actually did (read the JSONL directly)
152
+ - **Bulk migration** during `/init` when you have no existing memory
153
+
154
+ ## Dispatch Patterns
155
+
156
+ ### Parallel research — get multiple perspectives
157
+
158
+ Run Claude Code and Codex simultaneously on the same question via separate Bash calls in a single message. Compare results for higher confidence.
159
+
160
+ ### Deep investigation — use frontier models
161
+
162
+ For hard problems, use the strongest available models:
163
+ - Codex: `-m codex-5.3` (preferred — strong reasoning, good with large repos)
164
+ - Claude Code: `--model opus`
165
+
166
+ ### Code review — cross-agent validation
167
+
168
+ Have one agent write code, then dispatch the other to review it:
169
+ ```bash
170
+ claude -p "Review the changes in this diff for correctness and edge cases: $(git diff)" --model opus
171
+ ```
172
+
173
+ ### Scoped implementation — sandboxed changes
174
+
175
+ Use Codex with `--full-auto` or Claude Code with `--dangerously-skip-permissions` (in trusted repos only) for autonomous implementation tasks. Always review their changes via `git diff` before committing.
176
+
177
+ ## Timeouts
178
+
179
+ Set appropriate Bash timeouts for these calls — they can take a while:
180
+ - Research/analysis: `timeout: 300000` (5 min)
181
+ - Implementation: `timeout: 600000` (10 min)
182
+
183
+ ## Strengths & Weaknesses (update as you learn)
184
+
185
+ Track observations about model/agent performance in memory. Initial heuristics:
186
+
187
+ | Agent | Strengths | Weaknesses |
188
+ |-------|-----------|------------|
189
+ | Codex (Codex-5.3) | Frontier reasoning, handles large repos well, reliable with --full-auto | Most expensive |
190
+ | Codex (GPT-5.2) | Strong reasoning, good code search | Slightly less capable than 5.3 |
191
+ | Claude Code (Sonnet) | Fast, actionable output with concrete code samples | Less thorough on edge cases |
192
+ | Claude Code (Opus) | Deep analysis, nuanced reasoning | Can hang on large repos with tool use, needs --dangerously-skip-permissions |
@@ -218,7 +218,7 @@ const useInput = (inputHandler, options = {}) => {
218
218
  console.error(`[debug:ink-keypress] raw=${rawHex} name="${keypress.name}" seq="${keypress.sequence}" key={escape:${key.escape},tab:${key.tab},shift:${key.shift},ctrl:${key.ctrl},meta:${key.meta}}`);
219
219
  }
220
220
 
221
- let input = keypress.ctrl ? keypress.name : keypress.sequence;
221
+ let input = (keypress.ctrl ? keypress.name : keypress.sequence) ?? '';
222
222
  const seq = typeof keypress.sequence === 'string' ? keypress.sequence : '';
223
223
  // Filter xterm focus in/out sequences (ESC[I / ESC[O)
224
224
  if (seq === '\u001B[I' || seq === '\u001B[O' || input === '[I' || input === '[O' || /^(?:\[I|\[O)+$/.test(input || '')) {