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>
This commit is contained in:
@@ -72,6 +72,10 @@ const DEFAULT_MODES: AgentMode[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const VALID_CLAUDE_MODES = new Set(
|
||||
DEFAULT_MODES.map((mode) => mode.id)
|
||||
);
|
||||
|
||||
type ClaudeAgentConfig = AgentSessionConfig & { provider: "claude" };
|
||||
|
||||
export type ClaudeContentChunk = { type: string; [key: string]: any };
|
||||
|
||||
Reference in New Issue
Block a user