UNPKG

mcp-product-manager

Version:

MCP Orchestrator for task and project management with web interface

69 lines 3.51 kB
// bashApi.js - Wrapper for calling bash API functions import { exec } from 'child_process'; import { promisify } from 'util'; const execAsync = promisify(exec); // Base path for orchestrator scripts const ORCHESTRATOR_LIB = process.env.ORCHESTRATOR_LIB || './lib'; // Execute a bash function from the orchestrator API export const callBashFunction = async (scriptFile, functionName, ...args) => { const command = ` export DB_PATH="${process.env.DB_PATH || './product-manager.db'}" source "${ORCHESTRATOR_LIB}/db-core.sh" source "${ORCHESTRATOR_LIB}/${scriptFile}" ${functionName} ${args.map(arg => `"${arg}"`).join(' ')} `; try { const { stdout, stderr } = await execAsync(command, { shell: 'bash', env: { ...process.env } }); if (stderr) { console.error(`Bash API stderr: ${stderr}`); } // Try to parse as JSON if possible try { return JSON.parse(stdout.trim()); } catch { // Return raw output if not JSON return stdout.trim(); } } catch (error) { throw new Error(`Bash API error: ${error.message}`); } }; // Specific API function wrappers export const orchestratorApi = { // From orchestrator-api.sh getProjectStatus: (project) => callBashFunction('orchestrator-api.sh', 'get_project_status', project), getNextAction: (project, agent) => callBashFunction('orchestrator-api.sh', 'get_next_action', project, agent), claimWork: (workType, workId, agent) => callBashFunction('orchestrator-api.sh', 'claim_work', workType, workId, agent), quickStatus: (project = '') => callBashFunction('orchestrator-api.sh', 'quick_status', project), getIdleAgentRecommendations: (project) => callBashFunction('orchestrator-api.sh', 'get_idle_agent_recommendations', project), monitorHealth: (project) => callBashFunction('orchestrator-api.sh', 'monitor_health', project), }; export const taskOps = { // From task-ops.sh createTask: (project, description, priority = 'medium', category = 'general', estimatedHours = 2, model = 'sonnet') => callBashFunction('task-ops.sh', 'task_create', project, description, priority, category, estimatedHours, model), claimTask: (taskId, agent) => callBashFunction('task-ops.sh', 'task_claim', taskId, agent), updateTask: (taskId, field, value) => callBashFunction('task-ops.sh', 'task_update', taskId, field, value), completeTask: (taskId, result = '') => callBashFunction('task-ops.sh', 'task_complete', taskId, result), blockTask: (taskId, reason) => callBashFunction('task-ops.sh', 'task_block', taskId, reason), getTaskDetail: (taskId) => callBashFunction('task-ops.sh', 'task_detail', taskId), }; export const agentOps = { // From agent-ops.sh // agent_spawn expects: project, agent_type (default: basic), model (default: sonnet), task_id (optional) spawnAgent: (project, agentType = 'basic', model = 'sonnet', taskId = '') => callBashFunction('agent-ops.sh', 'agent_spawn', project, agentType, model, taskId), updateAgentStatus: (name, status) => callBashFunction('agent-ops.sh', 'agent_update_status', name, status), listAgents: (project = '') => callBashFunction('agent-ops.sh', 'agent_list', project), getAgentStatus: (name) => callBashFunction('agent-ops.sh', 'agent_status', name), }; export default { callBashFunction, orchestratorApi, taskOps, agentOps }; //# sourceMappingURL=bashApi.js.map