Commit Graph

161 Commits

Author SHA1 Message Date
Mohamed Boudra
899dafff35 Fix codex mcp default model 2025-12-24 18:58:49 +07:00
Mohamed Boudra
75c2a96068 Fix Codex MCP permission elicitation parity 2025-12-24 18:53:59 +07:00
Mohamed Boudra
5b971dba69 Fix permission gating fallback for Codex MCP 2025-12-24 18:49:29 +07:00
Mohamed Boudra
bcd117270e Handle Codex MCP model rejection fallback 2025-12-24 18:40:44 +07:00
Mohamed Boudra
16ccce4291 test: cover permission interrupt + read-only gating 2025-12-24 18:31:05 +07:00
Mohamed Boudra
f65a134ac0 test: add codex-mcp thread/item coverage 2025-12-24 18:25:12 +07:00
Mohamed Boudra
19aaee9c26 Add Codex MCP agent provider 2025-12-24 18:13:14 +07:00
Mohamed Boudra
d04fbb981c Add Codex MCP E2E test coverage 2025-12-24 17:57:49 +07:00
Mohamed Boudra
851c687b4f Add MCP persistence resume e2e test 2025-12-24 17:31:47 +07:00
Mohamed Boudra
4d75bd45e8 Add MCP event mapping parity e2e tests 2025-12-24 17:28:11 +07:00
Mohamed Boudra
797425c4e2 Merge origin/main 2025-12-24 17:21:26 +07:00
Mohamed Boudra
f5961fa044 refactor(server): extract test daemon setup into shared utility and switch mcp e2e test to codex provider 2025-12-24 17:18:31 +07:00
Mohamed Boudra
9318048f51 ensure mcp waits surface permissions 2025-12-24 09:05:24 +00:00
Mohamed Boudra
a24f578916 make mcp e2e test claude permissions 2025-12-24 08:55:16 +00:00
Mohamed Boudra
e37d50e938 make mcp agent e2e test provider-aware 2025-12-24 08:45:02 +00:00
Mohamed Boudra
e1f79c1d6f add mcp agent e2e smoke test 2025-12-24 08:38:25 +00:00
Mohamed Boudra
d787c5f1bc refactor daemon bootstrap and add smoke test 2025-12-24 08:25:17 +00:00
Mohamed Boudra
37da13a38b Fix markdown list text wrapping on Android
- Add custom list rendering rules in message.tsx for proper flex layout
- Remove flexWrap from list content styles (causes Android clipping)
- Use flex: 1 and flexShrink: 1 for natural text wrapping
- Add minWidth: 0 to content containers for proper shrinking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 04:41:37 +00:00
Mohamed Boudra
0526124fbd Fix type errors in server code
- Filter undefined values from env record for Codex SDK
- Add string type check for ParsedQs array element

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 23:11:48 +07:00
Mohamed Boudra
6a9b57ae0c Simplify agent list UI and add bearer token auth for Codex MCP
- Replace SectionList with FlatList in agent list, sorting attention items to top
- Persist server selection preference in create agent modal
- Add bearer token authentication support for agent-control MCP endpoint
- Pass bearer token through Codex wrapper script for MCP auth

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 22:11:51 +07:00
Mohamed Boudra
bf0ec80fb5 Move agent-control MCP config into AgentManager 2025-12-23 15:45:48 +07:00
Mohamed Boudra
dc90f57567 Inject agent-control MCP URL for codex session configs 2025-12-23 15:19:49 +07:00
Mohamed Boudra
077ecae607 Wire agent-control MCP URL into codex agents 2025-12-23 15:08:34 +07:00
Mohamed Boudra
e2ba6c8634 Add developer_instructions to Codex wrapper 2025-12-23 15:02:40 +07:00
Mohamed Boudra
4699297e4e Inject agent-control MCP via codex wrapper 2025-12-23 14:42:26 +07:00
Mohamed Boudra
702159fb75 Route agent MCP parent via query param 2025-12-23 13:49:18 +07:00
Mohamed Boudra
2e8444eaac fix: add parentAgentId to stored agent record schema
- Added `parentAgentId` field to `STORED_AGENT_SCHEMA` in agent-registry.ts
- Updated `toStoredAgentRecord()` in agent-projections.ts to include parentAgentId
- This ensures parentAgentId is persisted to agents.json for parent/child hierarchy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 17:47:31 +00:00
Mohamed Boudra
b2850aea23 feat: auto-inject parentAgentId in MCP create_agent tool
When an agent calls the MCP create_agent tool to spawn a child agent,
the parent-child relationship is now automatically established:

- Added setManagedAgentId() to AgentSession interface (optional method)
- ClaudeAgentSession stores its managed agent ID and includes it as
  X-Caller-Agent-Id header when connecting to the agent-control MCP
- AgentManager.registerSession() calls setManagedAgentId() after
  registration so the session knows its ID before first prompt
- MCP server extracts X-Caller-Agent-Id header from init request and
  stores it as callerAgentId
- create_agent handler auto-injects callerAgentId as parentAgentId
  if not explicitly provided

This enables parent agents to spawn child agents that are correctly
associated, so they appear in the parent's Sub-Agents menu instead
of on the homepage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 17:36:58 +00:00
Mohamed Boudra
dd697defbb feat: add parentAgentId to MCP create_agent tool
Add parentAgentId optional parameter to the create_agent MCP tool input
schema so agents can create child agents with explicit parent references.
Also update registerSession() to copy parentAgentId from config to the
managed agent object.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 17:18:19 +00:00
Mohamed Boudra
a574429a7b feat: add parentAgentId field to server types
Add parentAgentId field to enable agent parent/child hierarchy:
- ManagedAgentBase in agent-manager.ts
- AgentSessionConfig in agent-sdk-types.ts
- AgentSnapshotPayloadSchema in messages.ts
- toAgentPayload() in agent-projections.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 17:15:29 +00:00
Mohamed Boudra
1bf4a1d478 fix: emit state after refreshing runtime info so clients get model updates
The Claude agent model was not showing in the UI ("Model: Unknown") because
refreshRuntimeInfo() updated agent.runtimeInfo but never called emitState()
to notify connected clients of the change.

Fixed by:
1. Adding change detection in refreshRuntimeInfo() to check if model, sessionId,
   or modeId changed
2. Calling emitState(agent) when changes are detected
3. Added debug logging in handleSystemMessage() to confirm model capture

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 16:47:42 +00:00
Mohamed Boudra
e1631fcab6 feat: capture actual model from Claude SDK init message
Update handleSystemMessage() in claude-agent.ts to read the actual model
from the SDK's init message (message.model) instead of just echoing back
the configured model. This gives us the real runtime model that the SDK
selected.

Also invalidates cached runtime info when the model is updated to ensure
getRuntimeInfo() returns the new value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 16:36:43 +00:00
Mohamed Boudra
abe3a42478 feat: add agent runtime info tracking with model detection from rollout files 2025-12-21 23:16:49 +07:00
Mohamed Boudra
a70842d9ef feat: auto-detect and use system-installed codex binary from PATH
Implements automatic detection and usage of system-installed Codex binary
with transparent fallback to embedded binary.

Changes:
- Add detectSystemCodexPath() to check for codex in PATH using `which`
- Update CodexAgentClient constructor to auto-detect system binary
- Log which binary is being used (system vs embedded) for debugging
- Preserve ability to explicitly override via codexPathOverride option

Benefits:
- No manual configuration required
- Uses latest system codex when available
- Seamless fallback to embedded binary
- Transparent to rest of codebase

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 13:30:49 +07:00
Mohamed Boudra
b8de55f31b Merge branch 'main' of github.com:boudra/voice-dev 2025-12-20 12:58:17 +07:00
Mohamed Boudra
fb30160cda feat: add batch clear attention and orchestrator mode instructions 2025-12-20 05:57:54 +00:00
Mohamed Boudra
5466ea1967 Merge branch 'main' of github.com:boudra/voice-dev 2025-12-20 12:57:33 +07:00
Mohamed Boudra
a6d2ea3153 fix: add input field to tool call data and simplify CLAUDE.md orchestrator docs 2025-12-20 12:56:59 +07:00
Mohamed Boudra
0f1758709d feat: add "Requires Attention" agent grouping feature
Implement a new UI section that surfaces agents requiring user attention at the top of the agent list. This includes agents that are running, have pending permissions, or have errors.

**Backend changes:**
- Add `requiresAttention` field to agent projections and SDK types
- Implement logic in AgentManager to detect attention states (running, pending permissions, errors)
- Add WebSocket message handler to notify clients of attention state changes
- Update session state to include attention tracking

**Frontend changes:**
- Add "REQUIRES ATTENTION" section in agent-list component with visual prominence
- Update useAggregatedAgents hook to expose `requiresAttention` agents
- Enhance session store to track and update attention states
- Add real-time updates via WebSocket for attention state changes
- Update type definitions across agent directory and stream types

Verified working via Playwright MCP testing on localhost:8081.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 11:27:08 +00:00
Mohamed Boudra
fd36c9b8e2 feat: add --isolated flag to Playwright MCP for Claude Code provider
Added the --isolated flag to the Playwright MCP configuration to ensure
browser instances run in isolated contexts, preventing state leakage
between different agent sessions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 23:03:45 +07:00
Mohamed Boudra
2a541d97c9 fix: capture input parameters for MCP and server tool calls
Previously, only standard tool_use blocks had their input parameters
captured in upsertToolUseEntry. MCP tools (mcp_tool_use) and server
tools (server_tool_use) were being handled for execution but their
inputs were never stored in the tool cache, resulting in missing input
data in the UI.

Now all three tool types have their inputs properly captured and
normalized, ensuring consistent tool call display across all tool types.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 22:55:14 +07:00
Mohamed Boudra
5cbeb97391 refactor: simplify AgentManager by removing over-engineered freeze/clone logic
Remove ReadonlyPendingPermissionsMap class and related deep cloning/freezing
methods that were causing "ManagedAgent views returned by AgentManager are
read-only" errors. The bug occurred because Map constructor internally calls
.set() which was overridden to throw.

Replace with simple shallow clones - sufficient because all consumers either
read 1-2 fields or immediately serialize via toAgentPayload() which already
creates safe copies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 21:54:55 +07:00
Mohamed Boudra
d3ad27e10a feat: improve Agent Control MCP activity endpoint with count headers
Enhance the get_agent_activity tool to provide better context about the activity list:
- Add activity count headers showing "X of Y activities"
- Remove raw format option, always use curated format for consistency
- Simplify implementation by removing unnecessary format branching
- Respect limit parameter to show most recent N activities

This makes it clearer to users when they're viewing a subset of activities versus the full list.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 21:03:48 +07:00
Mohamed Boudra
9aacc26eb6 feat: add 60-second timeout to Agent Control MCP wait operations
Implement hard-coded 60-second timeout for agent wait operations in three tools:
- create_agent (when background=false and initialPrompt provided)
- send_agent_prompt (when background=false)
- wait_for_agent (always)

When timeout occurs, returns gracefully with message "Awaiting the agent timed out, await again" instead of throwing an error. Agent continues running after timeout.

Added AGENT_WAIT_TIMEOUT_MS constant and waitForAgentWithTimeout helper function to handle timeout logic with proper cleanup and signal forwarding.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:53:01 +07:00
Mohamed Boudra
56e2af2308 refactor: move mode validation into AgentSession implementations
Move mode validation from AgentManager into the individual AgentSession
implementations (ClaudeAgentSession and CodexAgentSession) where it belongs.

Each session validates modes in:
- Constructor (when config.modeId is provided)
- setMode() method (when mode is changed)

This follows the principle that the AgentManager is a coordinator while
the AgentSession is the authority on what modes it supports.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:17:25 +07:00
Mohamed Boudra
7b649eb77f feat: add centralized mode validation for agent providers
Prevents server crashes when invalid modes are passed to agents by
validating mode IDs before attempting to set them on the SDK.

- Export VALID_CLAUDE_MODES and VALID_CODEX_MODES from provider files
- Add validateMode() function in agent-manager.ts
- Apply validation in createAgent(), resumeAgent(), and setAgentMode()
- Throws clear error listing valid modes when validation fails

This fixes the crash when 'read-only' (Codex mode) was passed to
a Claude agent.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:03:38 +07:00
Mohamed Boudra
b7eed8409b fix: handle promise rejections in claude-agent fire-and-forget patterns
Fixed two fire-and-forget promise patterns that could cause unhandled rejections:
- interruptActiveTurn() in requestCancel closure - now catches errors and logs warning
- forwardPromptEvents() in stream method - now catches errors and logs to console

Both now properly handle promise rejections to prevent Node.js process crashes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:02:51 +07:00
Mohamed Boudra
644c654274 perf: prevent HomeScreen rerenders during agent streaming
- Add top-level agentLastActivity Map to store (prevents cascade rerenders)
- Remove lastActivityAt updates from agent_stream handler (only status changes update timestamps)
- useAggregatedAgents now uses agent.lastActivityAt directly
- Remove investigation logging from previous debug session

The root cause was that every stream event updated agent.lastActivityAt,
causing useAggregatedAgents to recalculate, which caused HomeScreen to
rerender even when not visible. Now timestamps only update on meaningful
events (agent status changes), not individual stream tokens.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 17:34:07 +07:00
Mohamed Boudra
74c82a312e perf: move drafts to top-level store to prevent session rerenders
Previously, drafts were nested inside each session object, which caused
the entire session to be recreated on every keystroke. This triggered
rerenders in all components subscribed to the session.

Now drafts are stored at the top level of the Zustand store, keyed by
agentId (not serverId:agentId since agent IDs are globally unique).
This means draft updates only trigger rerenders in components that
subscribe to drafts specifically.

Changes:
- Move drafts from SessionState to SessionStoreState (top-level)
- Add createModalDraft for future use by the create agent modal
- Update getDraftInput/saveDraftInput to work with agentId only
- Update session-context to clear drafts using new API
- Remove investigation console.log statements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 15:46:45 +07:00
Mohamed Boudra
d5f8091d66 refactor: simplify modal mounting with lazy wrapper and add read-only git env 2025-12-03 14:09:56 +07:00