UNPKG

mcp-decisive

Version:

MCP server for WRAP decision-making framework with structured output

88 lines 3.25 kB
import { z } from 'zod'; /** * ワークフロー状態のコンストラクタ */ export const WorkflowState = { undefined: () => ({ type: 'undefined' }), issueDefined: () => ({ type: 'issue_defined' }), initialOptionsRegistered: () => ({ type: 'initial_options_registered' }), laddered: () => ({ type: 'laddered' }), analogicalResearchDone: () => ({ type: 'analogical_research_done' }), eliminationTested: () => ({ type: 'elimination_tested' }), optionsFixed: () => ({ type: 'options_fixed' }), }; /** * Zodスキーマ */ export const WorkflowStateSchema = z.discriminatedUnion('type', [ z.object({ type: z.literal('undefined') }), z.object({ type: z.literal('issue_defined') }), z.object({ type: z.literal('initial_options_registered') }), z.object({ type: z.literal('laddered') }), z.object({ type: z.literal('analogical_research_done') }), z.object({ type: z.literal('elimination_tested') }), z.object({ type: z.literal('options_fixed') }), ]); /** * 状態遷移ルールの定義 * 注意: issue_definedへの遷移は別途isValidTransitionで常に許可される */ const getValidTransitions = (state) => { switch (state.type) { case 'undefined': return ['issue_defined']; case 'issue_defined': return ['initial_options_registered']; case 'initial_options_registered': return ['laddered', 'analogical_research_done', 'elimination_tested']; case 'laddered': return ['analogical_research_done', 'elimination_tested', 'initial_options_registered']; case 'analogical_research_done': return ['elimination_tested', 'options_fixed', 'initial_options_registered']; case 'elimination_tested': return ['options_fixed', 'initial_options_registered', 'analogical_research_done']; case 'options_fixed': return []; } }; /** * 状態遷移が有効かどうかを判定する純粋関数 */ export const isValidTransition = (from, to) => { // define_issue: どの状態からも課題定義済みに遷移可能 if (to.type === 'issue_defined') { return true; } // 同じ状態への遷移は常に許可(上書き) if (from.type === to.type) { return true; } const validTransitions = getValidTransitions(from); return validTransitions.includes(to.type); }; /** * 状態の表示名を取得する純粋関数 */ export const getDisplayName = (state) => { switch (state.type) { case 'undefined': return '未定義状態'; case 'issue_defined': return '課題定義済み'; case 'initial_options_registered': return '初期選択肢登録済み'; case 'laddered': return 'ラダリング済み'; case 'analogical_research_done': return '類推による類似問題調査済み'; case 'elimination_tested': return '消去テスト済み'; case 'options_fixed': return '選択肢fixed'; } }; /** * 状態を比較する純粋関数 */ export const isState = (state, type) => state.type === type; //# sourceMappingURL=workflow-state.js.map