UNPKG

mcp-decisive

Version:

MCP server for WRAP decision-making framework with structured output

30 lines 1.34 kB
import { OptionSelectionAggregate } from '../../../domain/command/option-selection.js'; import { Values } from '../../../domain/term/option.js'; import { toStructuredCallToolResult, toCallToolResult } from '../util.js'; import { SUCCESS_MESSAGE_TEMPLATE, ERROR_MESSAGE_PREFIX, processTemplate } from './prompt.js'; export const registerOptionsHandler = async (args) => { const result = OptionSelectionAggregate.registerOptions({ options: args.options }); return result.match((event) => { const options = event.optionList.options.map(option => ({ id: Values.OptionId.toString(option.id), text: Values.OptionText.toString(option.text) })); const response = { options }; const optionsList = options .map((opt, idx) => `${idx + 1}. ${opt.text}`) .join('\n'); const successMessage = processTemplate(SUCCESS_MESSAGE_TEMPLATE, { count: options.length, optionsList: optionsList }); return toStructuredCallToolResult([successMessage], response, false); }, (error) => { const errorMessage = OptionSelectionAggregate.toErrorMessage(error); return toCallToolResult([`${ERROR_MESSAGE_PREFIX}${errorMessage}`], true); }); }; //# sourceMappingURL=handler.js.map