Restructure src/ modules with consistent internal organization
Reorganize major src/ directories to follow a consistent pattern with
core/, menu/, submenu/, inputs/, logs/, layout/, feedback/ subdirectories.
Changes by module:
- stores/: Move 5 store files to stores/core/
- utils/: Create core/ (terminal, tools, etc.) and menu/ (progress-bar)
- api/: Create copilot/core/, copilot/auth/, ollama/core/
- providers/: Create core/, copilot/core/, copilot/auth/, ollama/core/, login/core/
- ui/: Create core/, banner/core/, banner/menu/, spinner/core/,
input-editor/core/, components/core/, components/menu/
- tools/: Create core/ for registry.ts and types.ts
- tui-solid/: Reorganize components/ into menu/, submenu/, inputs/,
logs/, modals/, panels/, layout/, feedback/
- commands/: Create core/ for runner.ts and handlers.ts
- services/: Create core/ for agent.ts, permissions.ts, session.ts,
executor.ts, config.ts
All imports updated to use new paths. TypeScript compilation verified.
This commit is contained in:
112
src/constants/multi-agent.ts
Normal file
112
src/constants/multi-agent.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* Multi-Agent Constants
|
||||
*
|
||||
* Configuration defaults, messages, and descriptions for multi-agent execution.
|
||||
*/
|
||||
|
||||
import type { AgentExecutionMode, ConflictStrategy } from "@/types/multi-agent";
|
||||
|
||||
/**
|
||||
* Default configuration values
|
||||
*/
|
||||
export const MULTI_AGENT_DEFAULTS = {
|
||||
maxConcurrent: 3,
|
||||
timeout: 300000, // 5 minutes
|
||||
executionMode: "adaptive" as AgentExecutionMode,
|
||||
conflictStrategy: "serialize" as ConflictStrategy,
|
||||
abortOnFirstError: false,
|
||||
conflictCheckInterval: 1000, // 1 second
|
||||
maxRetries: 2,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Resource limits
|
||||
*/
|
||||
export const MULTI_AGENT_LIMITS = {
|
||||
maxAgentsPerRequest: 10,
|
||||
maxConcurrentRequests: 3,
|
||||
maxQueuedAgents: 20,
|
||||
maxConflictsBeforeAbort: 5,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Execution mode descriptions
|
||||
*/
|
||||
export const EXECUTION_MODE_DESCRIPTIONS: Record<AgentExecutionMode, string> = {
|
||||
sequential: "Execute agents one after another, safest for file modifications",
|
||||
parallel: "Execute all agents concurrently, fastest but may cause conflicts",
|
||||
adaptive: "Start parallel, automatically serialize when conflicts detected",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Conflict strategy descriptions
|
||||
*/
|
||||
export const CONFLICT_STRATEGY_DESCRIPTIONS: Record<ConflictStrategy, string> = {
|
||||
serialize: "Wait for conflicting agent to complete before proceeding",
|
||||
"abort-newer": "Abort the agent that started later when conflict detected",
|
||||
"merge-results": "Attempt to merge changes from both agents",
|
||||
isolated: "Each agent works in isolated context, merge at end",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Error messages
|
||||
*/
|
||||
export const MULTI_AGENT_ERRORS = {
|
||||
MAX_AGENTS_EXCEEDED: (max: number) =>
|
||||
`Cannot spawn more than ${max} agents in a single request`,
|
||||
MAX_CONCURRENT_EXCEEDED: (max: number) =>
|
||||
`Maximum concurrent agents (${max}) reached`,
|
||||
AGENT_NOT_FOUND: (name: string) =>
|
||||
`Agent "${name}" not found in registry`,
|
||||
AGENT_ALREADY_RUNNING: (id: string) =>
|
||||
`Agent "${id}" is already running`,
|
||||
EXECUTION_TIMEOUT: (agentId: string, timeout: number) =>
|
||||
`Agent "${agentId}" timed out after ${timeout}ms`,
|
||||
CONFLICT_RESOLUTION_FAILED: (filePath: string) =>
|
||||
`Failed to resolve conflict for file: ${filePath}`,
|
||||
EXECUTION_ABORTED: "Execution aborted by user",
|
||||
INVALID_EXECUTION_MODE: (mode: string) =>
|
||||
`Invalid execution mode: ${mode}`,
|
||||
INVALID_CONFLICT_STRATEGY: (strategy: string) =>
|
||||
`Invalid conflict strategy: ${strategy}`,
|
||||
TOO_MANY_CONFLICTS: (count: number) =>
|
||||
`Too many conflicts detected (${count}), aborting execution`,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Status messages
|
||||
*/
|
||||
export const MULTI_AGENT_MESSAGES = {
|
||||
STARTING: "Starting multi-agent execution",
|
||||
AGENT_SPAWNED: (name: string) => `Spawned agent: ${name}`,
|
||||
AGENT_COMPLETED: (name: string) => `Agent completed: ${name}`,
|
||||
AGENT_FAILED: (name: string, error: string) =>
|
||||
`Agent failed: ${name} - ${error}`,
|
||||
CONFLICT_DETECTED: (file: string, agents: string[]) =>
|
||||
`Conflict detected on ${file} between agents: ${agents.join(", ")}`,
|
||||
CONFLICT_RESOLVED: (file: string, strategy: string) =>
|
||||
`Conflict resolved for ${file} using ${strategy}`,
|
||||
EXECUTION_COMPLETE: (success: number, failed: number) =>
|
||||
`Execution complete: ${success} succeeded, ${failed} failed`,
|
||||
WAITING_FOR_CONFLICT: (agentId: string) =>
|
||||
`Agent ${agentId} waiting for conflict resolution`,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Agent ID generation prefix
|
||||
*/
|
||||
export const AGENT_ID_PREFIX = "agent_";
|
||||
|
||||
/**
|
||||
* Request ID generation prefix
|
||||
*/
|
||||
export const REQUEST_ID_PREFIX = "req_";
|
||||
|
||||
/**
|
||||
* File lock constants
|
||||
*/
|
||||
export const FILE_LOCK = {
|
||||
acquireTimeout: 5000, // 5 seconds
|
||||
retryInterval: 100, // 100ms
|
||||
maxRetries: 50,
|
||||
} as const;
|
||||
Reference in New Issue
Block a user