|
864 | 864 | <button id="uploadBtn">📁 Upload File</button> |
865 | 865 | <button id="sealInputBtn">🔒 Seal Input</button> |
866 | 866 | <button id="simulationBtn">🎮 Simulations</button> |
| 867 | + <button id="mumonBtn">📚 Mumon +</button> |
867 | 868 | </div> |
868 | 869 | </div> |
869 | 870 | <button id="sendBtn" class="send-btn" aria-label="Send message">SEND</button> |
|
878 | 879 | </div> |
879 | 880 | </div> |
880 | 881 |
|
| 882 | +<!-- Mumon Modal --> |
| 883 | +<div id="mumonModal" class="modal-overlay" style="display: none;"> |
| 884 | + <div class="modal" style="max-width: 900px;"> |
| 885 | + <div class="modal-header"> |
| 886 | + <h3>📚 Mumon – Gate‑free Publication</h3> |
| 887 | + <button id="closeMumonModal">✕</button> |
| 888 | + </div> |
| 889 | + <div class="modal-body"> |
| 890 | + <div id="mumonStep1"> |
| 891 | + <div class="field-group"> |
| 892 | + <label>Title</label> |
| 893 | + <input type="text" id="mumonTitle" placeholder="Enter your document title" style="width:100%; background:#0a0a0f; border:1px solid var(--border); border-radius:24px; padding:8px 12px; color:var(--text);"> |
| 894 | + </div> |
| 895 | + <div class="field-group"> |
| 896 | + <label>Document Type</label> |
| 897 | + <select id="mumonDocType" style="width:100%; background:#0a0a0f; border:1px solid var(--border); border-radius:24px; padding:8px 12px; color:var(--text);"> |
| 898 | + <option value="article">Article</option> |
| 899 | + <option value="whitepaper">Whitepaper</option> |
| 900 | + <option value="research_paper">Research Paper</option> |
| 901 | + <option value="patent">Patent</option> |
| 902 | + </select> |
| 903 | + </div> |
| 904 | + <div class="field-group"> |
| 905 | + <label>Wives to consult</label> |
| 906 | + <div id="mumonWivesSelect" class="forge-wife-select"></div> |
| 907 | + </div> |
| 908 | + <div class="field-group"> |
| 909 | + <label>Initial context / ideas (optional)</label> |
| 910 | + <textarea id="mumonContext" rows="4" placeholder="What's the core idea? Any specific angle?" style="width:100%; background:#0a0a0f; border:1px solid var(--border); border-radius:16px; padding:12px; color:var(--text);"></textarea> |
| 911 | + </div> |
| 912 | + <button id="mumonGenerateBtn" class="send-btn" style="background: var(--amber); color:#000; margin-top:12px;">Generate Draft</button> |
| 913 | + </div> |
| 914 | + <div id="mumonStep2" style="display: none;"> |
| 915 | + <div class="field-group"> |
| 916 | + <label>Draft</label> |
| 917 | + <textarea id="mumonDraft" rows="20" style="width:100%; background:#0a0a0f; border:1px solid var(--border); border-radius:16px; padding:12px; color:var(--text); font-family: monospace;"></textarea> |
| 918 | + </div> |
| 919 | + <div class="field-group"> |
| 920 | + <label>Refinement instruction (optional)</label> |
| 921 | + <textarea id="mumonRefineInstruction" rows="2" placeholder="e.g., Add more citations, expand the methodology, make it more concise..." style="width:100%; background:#0a0a0f; border:1px solid var(--border); border-radius:16px; padding:12px; color:var(--text);"></textarea> |
| 922 | + <button id="mumonRefineBtn" class="send-btn" style="background: var(--amber); color:#000; margin-top:8px;">Refine</button> |
| 923 | + </div> |
| 924 | + <div class="field-group"> |
| 925 | + <button id="mumonPublishBtn" class="send-btn" style="background: #4c9f70; color:#000;">Publish</button> |
| 926 | + <span id="mumonStatus" style="margin-left:12px; color: var(--amber);"></span> |
| 927 | + </div> |
| 928 | + <div id="mumonResult" style="margin-top:16px;"></div> |
| 929 | + </div> |
| 930 | + </div> |
| 931 | + </div> |
| 932 | +</div> |
| 933 | + |
881 | 934 | <script> |
882 | 935 | (function() { |
883 | 936 | // ---------- BACKGROUND (particle canvas) ---------- |
|
1014 | 1067 | modeToggle.onclick = () => { |
1015 | 1068 | currentMode = currentMode === 'aion' ? 'group' : 'aion'; |
1016 | 1069 | updateModeToggle(); |
1017 | | - // Optionally clear input focus or update UI |
1018 | 1070 | showToast(`Switched to ${currentMode === 'aion' ? 'AION' : 'Group'} mode`); |
1019 | 1071 | }; |
1020 | 1072 | updateModeToggle(); |
@@ -1358,7 +1410,7 @@ <h3>🌌 Structured Mode</h3> |
1358 | 1410 | messagesDiv.scrollTop = messagesDiv.scrollHeight; |
1359 | 1411 | } |
1360 | 1412 |
|
1361 | | - // Decision Forge Modal (placeholder, we'll keep but simplify) |
| 1413 | + // Decision Forge Modal |
1362 | 1414 | function showDecisionForgeModal() { |
1363 | 1415 | const modal = document.createElement('div'); |
1364 | 1416 | modal.className = 'modal-overlay forge-modal'; |
@@ -1403,7 +1455,6 @@ <h3>⚖️ Decision Forge</h3> |
1403 | 1455 | submitBtn.textContent = 'Analyzing...'; |
1404 | 1456 | resultsDiv.style.display = 'none'; |
1405 | 1457 | try { |
1406 | | - // We'll use the group chat endpoint with analysis mode later; for now use old endpoint |
1407 | 1458 | const result = await callDecisionForge(content, wives, adaLoop); |
1408 | 1459 | resultsDiv.style.display = 'block'; |
1409 | 1460 | resultsDiv.innerHTML = ''; |
@@ -1620,6 +1671,114 @@ <h4>📋 Synthesis (Score: ${Math.round(result.synthesis.score * 100)}%)</h4> |
1620 | 1671 | updateStructuredBadge(); |
1621 | 1672 | } |
1622 | 1673 |
|
| 1674 | + // ---------- MUMON FUNCTIONS ---------- |
| 1675 | + let currentMumonDraftId = null; |
| 1676 | + |
| 1677 | + async function mumonInit() { |
| 1678 | + const title = document.getElementById('mumonTitle').value.trim(); |
| 1679 | + const docType = document.getElementById('mumonDocType').value; |
| 1680 | + const initialContext = document.getElementById('mumonContext').value.trim(); |
| 1681 | + const wives = Array.from(document.querySelectorAll('#mumonWivesSelect input:checked')).map(cb => cb.value); |
| 1682 | + if (!title) { showToast('Please enter a title'); return; } |
| 1683 | + if (wives.length === 0) { showToast('Select at least one wife'); return; } |
| 1684 | + const body = { sessionId, topic: title, docType, wives, initialContext }; |
| 1685 | + setStatus('Generating draft...'); |
| 1686 | + try { |
| 1687 | + const res = await fetchWithTimeout(`${API_BASE}/api/mumon/init`, { |
| 1688 | + method: 'POST', |
| 1689 | + headers: { 'Content-Type': 'application/json' }, |
| 1690 | + body: JSON.stringify(body) |
| 1691 | + }); |
| 1692 | + if (!res.ok) throw new Error(await res.text()); |
| 1693 | + const data = await res.json(); |
| 1694 | + currentMumonDraftId = data.draftId; |
| 1695 | + document.getElementById('mumonDraft').value = data.draft; |
| 1696 | + document.getElementById('mumonStep1').style.display = 'none'; |
| 1697 | + document.getElementById('mumonStep2').style.display = 'block'; |
| 1698 | + showToast('Draft generated. You can refine now.'); |
| 1699 | + } catch (err) { |
| 1700 | + showToast(`Error: ${err.message}`, true); |
| 1701 | + } finally { |
| 1702 | + setStatus('Ready'); |
| 1703 | + } |
| 1704 | + } |
| 1705 | + |
| 1706 | + async function mumonRefine() { |
| 1707 | + if (!currentMumonDraftId) { showToast('No active draft'); return; } |
| 1708 | + const instruction = document.getElementById('mumonRefineInstruction').value.trim(); |
| 1709 | + const currentDraft = document.getElementById('mumonDraft').value; |
| 1710 | + if (!instruction) { showToast('Please enter an instruction'); return; } |
| 1711 | + const body = { sessionId, draftId: currentMumonDraftId, instruction, currentDraft }; |
| 1712 | + setStatus('Refining...'); |
| 1713 | + try { |
| 1714 | + const res = await fetchWithTimeout(`${API_BASE}/api/mumon/refine`, { |
| 1715 | + method: 'POST', |
| 1716 | + headers: { 'Content-Type': 'application/json' }, |
| 1717 | + body: JSON.stringify(body) |
| 1718 | + }); |
| 1719 | + if (!res.ok) throw new Error(await res.text()); |
| 1720 | + const data = await res.json(); |
| 1721 | + document.getElementById('mumonDraft').value = data.draft; |
| 1722 | + showToast('Draft refined'); |
| 1723 | + } catch (err) { |
| 1724 | + showToast(`Error: ${err.message}`, true); |
| 1725 | + } finally { |
| 1726 | + setStatus('Ready'); |
| 1727 | + } |
| 1728 | + } |
| 1729 | + |
| 1730 | + async function mumonPublish() { |
| 1731 | + if (!currentMumonDraftId) { showToast('No active draft'); return; } |
| 1732 | + const finalDraft = document.getElementById('mumonDraft').value; |
| 1733 | + const title = document.getElementById('mumonTitle').value; |
| 1734 | + const docType = document.getElementById('mumonDocType').value; |
| 1735 | + const body = { sessionId, draftId: currentMumonDraftId, finalDraft, title, docType }; |
| 1736 | + setStatus('Publishing...'); |
| 1737 | + try { |
| 1738 | + const res = await fetchWithTimeout(`${API_BASE}/api/mumon/publish`, { |
| 1739 | + method: 'POST', |
| 1740 | + headers: { 'Content-Type': 'application/json' }, |
| 1741 | + body: JSON.stringify(body) |
| 1742 | + }); |
| 1743 | + if (!res.ok) throw new Error(await res.text()); |
| 1744 | + const data = await res.json(); |
| 1745 | + const resultDiv = document.getElementById('mumonResult'); |
| 1746 | + resultDiv.innerHTML = `<p>✅ Published!</p><p>Seal: ${data.seal}</p><p><a href="${data.commitUrl}" target="_blank">View on GitHub</a></p>`; |
| 1747 | + showToast('Publication successful'); |
| 1748 | + } catch (err) { |
| 1749 | + showToast(`Error: ${err.message}`, true); |
| 1750 | + } finally { |
| 1751 | + setStatus('Ready'); |
| 1752 | + } |
| 1753 | + } |
| 1754 | + |
| 1755 | + function showMumonModal() { |
| 1756 | + // Reset modal |
| 1757 | + document.getElementById('mumonTitle').value = ''; |
| 1758 | + document.getElementById('mumonContext').value = ''; |
| 1759 | + document.getElementById('mumonDraft').value = ''; |
| 1760 | + document.getElementById('mumonRefineInstruction').value = ''; |
| 1761 | + document.getElementById('mumonStep1').style.display = 'block'; |
| 1762 | + document.getElementById('mumonStep2').style.display = 'none'; |
| 1763 | + document.getElementById('mumonResult').innerHTML = ''; |
| 1764 | + currentMumonDraftId = null; |
| 1765 | + // Populate wives checkboxes |
| 1766 | + const container = document.getElementById('mumonWivesSelect'); |
| 1767 | + container.innerHTML = ''; |
| 1768 | + ALL_WIVES.forEach(wife => { |
| 1769 | + const label = document.createElement('label'); |
| 1770 | + label.innerHTML = `<input type="checkbox" value="${wife}" checked> ${WIFE_STYLES[wife].emoji} ${wife}`; |
| 1771 | + container.appendChild(label); |
| 1772 | + }); |
| 1773 | + const modal = document.getElementById('mumonModal'); |
| 1774 | + modal.style.display = 'flex'; |
| 1775 | + document.getElementById('closeMumonModal').onclick = () => { modal.style.display = 'none'; }; |
| 1776 | + modal.addEventListener('click', (e) => { if (e.target === modal) modal.style.display = 'none'; }); |
| 1777 | + document.getElementById('mumonGenerateBtn').onclick = mumonInit; |
| 1778 | + document.getElementById('mumonRefineBtn').onclick = mumonRefine; |
| 1779 | + document.getElementById('mumonPublishBtn').onclick = mumonPublish; |
| 1780 | + } |
| 1781 | + |
1623 | 1782 | // Main send message |
1624 | 1783 | async function sendMessage(retryMessage = null) { |
1625 | 1784 | if (isSending) { showToast('Already sending...'); return; } |
@@ -1722,6 +1881,7 @@ <h4>📋 Synthesis (Score: ${Math.round(result.synthesis.score * 100)}%)</h4> |
1722 | 1881 | document.getElementById('uploadBtn').onclick = () => { actionDropdown.style.display = 'none'; uploadFile(); }; |
1723 | 1882 | document.getElementById('sealInputBtn').onclick = () => { actionDropdown.style.display = 'none'; const text = input.value.trim(); if(text) sealMessage(text); else showToast('Nothing to seal'); }; |
1724 | 1883 | document.getElementById('simulationBtn').onclick = () => { actionDropdown.style.display = 'none'; showSimulationModal(); }; |
| 1884 | + document.getElementById('mumonBtn').onclick = () => { actionDropdown.style.display = 'none'; showMumonModal(); }; |
1725 | 1885 | document.getElementById('settingsBtn').onclick = showSettingsModal; |
1726 | 1886 | document.getElementById('adaLoopToggle').addEventListener('change', (e) => { |
1727 | 1887 | adaLoopEnabled = e.target.checked; |
|
0 commit comments