UNPKG

mcp-casual-interview

Version:

MCP server for casual interview preparation workflow management

73 lines 3.69 kB
import { ok, err } from 'neverthrow'; import { WorkflowValues, WorkflowPolicies } from '../../term/interview-workflow/index.js'; // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Command Implementations // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ /** * Business logic: Check current progress and provide next action guidance */ const checkProgressCommand = (currentState) => { // Get next action prompt based on current state const nextActionPrompt = WorkflowValues.NextActionPrompts[currentState]; // Create progress checked event const event = { type: 'ProgressChecked', workflowState: currentState, nextActionPrompt, timestamp: new Date() }; return ok(event); }; /** * Business logic: Update workflow state with validation */ const updateWorkflowStateCommand = (currentState, newState) => { // Validate state transition using business rules if (!WorkflowPolicies.StateTransitions.canTransition(currentState, newState)) { return err({ type: 'InvalidStateTransition', message: `Cannot transition from '${currentState}' to '${newState}'` }); } // Create state updated event const event = { type: 'WorkflowStateUpdated', previousState: currentState, newState, timestamp: new Date() }; return ok(event); }; // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Higher-level workflows - Combining commands // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ /** * Check progress with optional state update */ const checkProgressWithUpdate = (request) => { const currentState = request.currentState ?? 'information_initially_registered'; // First check current progress const progressResult = checkProgressCommand(currentState); if (progressResult.isErr()) { return err(progressResult.error); } const events = [progressResult.value]; // Optionally update state if requested if (request.updateToState) { const updateResult = updateWorkflowStateCommand(currentState, request.updateToState); if (updateResult.isErr()) { return err(updateResult.error); } events.push(updateResult.value); } return ok(events); }; // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Public API - Progress Check Aggregate // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ export const ProgressCheckAggregate = { checkProgress: checkProgressCommand, updateState: updateWorkflowStateCommand, checkProgressWithUpdate }; //# sourceMappingURL=index.js.map