@mindstone/mcp-server-google-workspace 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const COMPOSE_EMAIL_HTML = "\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>Compose Email</title>\n <style>\n :root {\n --bg: #ffffff;\n --panel: #ffffff;\n --border: #d9dde5;\n --text: #1f2937;\n --muted: #6b7280;\n --input-bg: #ffffff;\n --button-bg: #1f6feb;\n --button-text: #ffffff;\n --button-bg-hover: #1b63d3;\n --secondary-bg: #f3f4f6;\n --secondary-text: #1f2937;\n --secondary-border: #d1d5db;\n --error-bg: #fef2f2;\n --error-border: #fecaca;\n --error-text: #991b1b;\n --success-bg: #ecfdf5;\n --success-border: #bbf7d0;\n --success-text: #166534;\n }\n\n @media (prefers-color-scheme: dark) {\n :root {\n --bg: #0f172a;\n --panel: #111827;\n --border: #334155;\n --text: #e5e7eb;\n --muted: #9ca3af;\n --input-bg: #0b1220;\n --button-bg: #3b82f6;\n --button-text: #eff6ff;\n --button-bg-hover: #2563eb;\n --secondary-bg: #1f2937;\n --secondary-text: #e5e7eb;\n --secondary-border: #374151;\n --error-bg: #2b1011;\n --error-border: #7f1d1d;\n --error-text: #fca5a5;\n --success-bg: #052e1b;\n --success-border: #166534;\n --success-text: #86efac;\n }\n }\n\n html[data-theme=\"light\"] {\n color-scheme: light;\n }\n\n html[data-theme=\"dark\"] {\n color-scheme: dark;\n --bg: #0f172a;\n --panel: #111827;\n --border: #334155;\n --text: #e5e7eb;\n --muted: #9ca3af;\n --input-bg: #0b1220;\n --button-bg: #3b82f6;\n --button-text: #eff6ff;\n --button-bg-hover: #2563eb;\n --secondary-bg: #1f2937;\n --secondary-text: #e5e7eb;\n --secondary-border: #374151;\n --error-bg: #2b1011;\n --error-border: #7f1d1d;\n --error-text: #fca5a5;\n --success-bg: #052e1b;\n --success-border: #166534;\n --success-text: #86efac;\n }\n\n * {\n box-sizing: border-box;\n }\n\n body {\n margin: 0;\n padding: 16px;\n background: var(--bg);\n color: var(--text);\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n line-height: 1.4;\n }\n\n .wrapper {\n width: 100%;\n max-width: 720px;\n margin: 0 auto;\n }\n\n .card {\n background: var(--panel);\n border: 1px solid var(--border);\n border-radius: 12px;\n padding: 14px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n\n .field label {\n font-size: 12px;\n font-weight: 600;\n color: var(--muted);\n text-transform: uppercase;\n letter-spacing: 0.04em;\n }\n\n .input,\n .textarea {\n width: 100%;\n background: var(--input-bg);\n color: var(--text);\n border: 1px solid var(--border);\n border-radius: 8px;\n padding: 10px 12px;\n font-size: 14px;\n font-family: inherit;\n }\n\n .input:focus,\n .textarea:focus {\n outline: 2px solid rgba(59, 130, 246, 0.35);\n outline-offset: 1px;\n }\n\n .textarea {\n min-height: 180px;\n resize: vertical;\n white-space: pre-wrap;\n }\n\n .toggles {\n display: flex;\n gap: 12px;\n align-items: center;\n flex-wrap: wrap;\n }\n\n .link-button {\n border: none;\n padding: 0;\n background: none;\n color: var(--muted);\n text-decoration: underline;\n font-size: 12px;\n cursor: pointer;\n }\n\n .link-button:hover {\n color: var(--text);\n }\n\n .actions {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n margin-top: 2px;\n }\n\n .button {\n border-radius: 8px;\n border: 1px solid transparent;\n min-height: 36px;\n padding: 0 14px;\n font-size: 13px;\n font-weight: 600;\n font-family: inherit;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n transition: background 120ms ease, opacity 120ms ease, border-color 120ms ease;\n }\n\n .button:disabled {\n cursor: not-allowed;\n opacity: 0.75;\n }\n\n .button-primary {\n background: var(--button-bg);\n color: var(--button-text);\n }\n\n .button-primary:hover:enabled {\n background: var(--button-bg-hover);\n }\n\n .button-secondary {\n background: var(--secondary-bg);\n color: var(--secondary-text);\n border-color: var(--secondary-border);\n }\n\n .spinner {\n width: 14px;\n height: 14px;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n display: inline-block;\n animation: spin 700ms linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .status {\n border-radius: 8px;\n border: 1px solid transparent;\n padding: 8px 10px;\n font-size: 13px;\n }\n\n .error {\n background: var(--error-bg);\n border-color: var(--error-border);\n color: var(--error-text);\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n }\n\n .success {\n background: var(--success-bg);\n border-color: var(--success-border);\n color: var(--success-text);\n }\n\n .collapsed {\n border: 1px solid var(--border);\n border-radius: 10px;\n background: var(--panel);\n padding: 10px 12px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n font-size: 13px;\n }\n\n .hidden {\n display: none !important;\n }\n </style>\n</head>\n<body>\n <div class=\"wrapper\">\n <div id=\"collapsedState\" class=\"collapsed hidden\">\n <span id=\"collapsedMessage\">Draft collapsed.</span>\n <button id=\"reopenButton\" type=\"button\" class=\"button button-secondary\">Reopen</button>\n </div>\n\n <form id=\"composeForm\" class=\"card\" novalidate>\n <div class=\"field\">\n <label for=\"toInput\">To</label>\n <input id=\"toInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"name@example.com, team@example.com\">\n </div>\n\n <div class=\"toggles\">\n <button id=\"toggleCcButton\" type=\"button\" class=\"link-button\">Add CC</button>\n <button id=\"toggleBccButton\" type=\"button\" class=\"link-button\">Add BCC</button>\n </div>\n\n <div id=\"ccRow\" class=\"field hidden\">\n <label for=\"ccInput\">CC</label>\n <input id=\"ccInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"cc@example.com\">\n </div>\n\n <div id=\"bccRow\" class=\"field hidden\">\n <label for=\"bccInput\">BCC</label>\n <input id=\"bccInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"bcc@example.com\">\n </div>\n\n <div class=\"field\">\n <label for=\"subjectInput\">Subject</label>\n <input id=\"subjectInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"Email subject\">\n </div>\n\n <div class=\"field\">\n <label for=\"bodyInput\">Body</label>\n <textarea id=\"bodyInput\" class=\"textarea\" placeholder=\"Write your email\"></textarea>\n </div>\n\n <div id=\"errorBox\" class=\"status error hidden\">\n <span id=\"errorText\"></span>\n <button id=\"retryButton\" type=\"button\" class=\"link-button\">Retry</button>\n </div>\n\n <div id=\"successBox\" class=\"status success hidden\"></div>\n\n <div class=\"actions\">\n <button id=\"cancelButton\" type=\"button\" class=\"button button-secondary\">Cancel</button>\n <button id=\"sendButton\" type=\"submit\" class=\"button button-primary\">\n <span id=\"sendSpinner\" class=\"spinner hidden\" aria-hidden=\"true\"></span>\n <span id=\"sendLabel\">Send email</span>\n </button>\n </div>\n </form>\n </div>\n\n <script>\n (function () {\n 'use strict';\n\n var RESOURCE_URI = 'ui://google-workspace/compose-email';\n var currentEmail = '';\n var pendingRequestId = null;\n var pendingPayload = null;\n var sending = false;\n var collapsed = false;\n\n var composeForm = document.getElementById('composeForm');\n var collapsedState = document.getElementById('collapsedState');\n var collapsedMessage = document.getElementById('collapsedMessage');\n var reopenButton = document.getElementById('reopenButton');\n\n var toInput = document.getElementById('toInput');\n var ccInput = document.getElementById('ccInput');\n var bccInput = document.getElementById('bccInput');\n var subjectInput = document.getElementById('subjectInput');\n var bodyInput = document.getElementById('bodyInput');\n var ccRow = document.getElementById('ccRow');\n var bccRow = document.getElementById('bccRow');\n var toggleCcButton = document.getElementById('toggleCcButton');\n var toggleBccButton = document.getElementById('toggleBccButton');\n\n var sendButton = document.getElementById('sendButton');\n var sendLabel = document.getElementById('sendLabel');\n var sendSpinner = document.getElementById('sendSpinner');\n var cancelButton = document.getElementById('cancelButton');\n var retryButton = document.getElementById('retryButton');\n\n var errorBox = document.getElementById('errorBox');\n var errorText = document.getElementById('errorText');\n var successBox = document.getElementById('successBox');\n\n function applyThemeFromHostContext() {\n try {\n var context = window.__MCP_HOST_CONTEXT__;\n if (!context || (context.theme !== 'light' && context.theme !== 'dark')) {\n return;\n }\n document.documentElement.setAttribute('data-theme', context.theme);\n } catch (_) {\n // Ignore theme extraction errors\n }\n }\n\n function trimString(value) {\n return String(value || '').trim();\n }\n\n function formatAddressItem(item) {\n if (item && typeof item === 'object') {\n var email = trimString(item.email || item.address || item.value);\n var name = trimString(item.name || item.displayName);\n if (email && name) {\n return name + ' <' + email + '>';\n }\n return email;\n }\n return trimString(item);\n }\n\n function normalizeAddressList(value) {\n if (Array.isArray(value)) {\n return value.map(formatAddressItem).filter(Boolean);\n }\n if (typeof value === 'string') {\n return value\n .split(',')\n .map(function (item) { return trimString(item); })\n .filter(Boolean);\n }\n return [];\n }\n\n function listToInputValue(list) {\n return normalizeAddressList(list).join(', ');\n }\n\n var resizeQueued = false;\n function postResize() {\n if (resizeQueued) return;\n resizeQueued = true;\n requestAnimationFrame(function () {\n resizeQueued = false;\n var height = Math.max(\n document.documentElement.scrollHeight,\n document.body ? document.body.scrollHeight : 0\n );\n window.parent.postMessage(\n { jsonrpc: '2.0', method: 'ui/resize', params: { height: height } },\n '*'\n );\n });\n }\n\n function postReady() {\n window.parent.postMessage(\n {\n method: 'mcp-app:ready',\n params: { resourceUri: RESOURCE_URI }\n },\n '*'\n );\n }\n\n function setCollapsed(nextCollapsed, message) {\n collapsed = nextCollapsed;\n composeForm.classList.toggle('hidden', collapsed);\n collapsedState.classList.toggle('hidden', !collapsed);\n if (message) {\n collapsedMessage.textContent = message;\n } else {\n collapsedMessage.textContent = collapsed ? 'Draft collapsed.' : '';\n }\n postResize();\n }\n\n function setSending(nextSending) {\n sending = nextSending;\n sendButton.disabled = nextSending;\n cancelButton.disabled = nextSending;\n toInput.disabled = nextSending;\n ccInput.disabled = nextSending;\n bccInput.disabled = nextSending;\n subjectInput.disabled = nextSending;\n bodyInput.disabled = nextSending;\n sendSpinner.classList.toggle('hidden', !nextSending);\n sendLabel.textContent = nextSending ? 'Sending\u2026' : 'Send email';\n postResize();\n }\n\n function clearError() {\n errorText.textContent = '';\n errorBox.classList.add('hidden');\n }\n\n function showError(message) {\n errorText.textContent = message || 'Failed to send email.';\n errorBox.classList.remove('hidden');\n postResize();\n }\n\n function clearSuccess() {\n successBox.textContent = '';\n successBox.classList.add('hidden');\n }\n\n function showSuccess(message) {\n successBox.textContent = message;\n successBox.classList.remove('hidden');\n postResize();\n }\n\n function setCcVisible(visible) {\n ccRow.classList.toggle('hidden', !visible);\n toggleCcButton.textContent = visible ? 'Hide CC' : 'Add CC';\n }\n\n function setBccVisible(visible) {\n bccRow.classList.toggle('hidden', !visible);\n toggleBccButton.textContent = visible ? 'Hide BCC' : 'Add BCC';\n }\n\n function readFormPayload() {\n var payload = {\n to: normalizeAddressList(toInput.value),\n cc: normalizeAddressList(ccInput.value),\n bcc: normalizeAddressList(bccInput.value),\n subject: String(subjectInput.value || ''),\n body: String(bodyInput.value || '')\n };\n if (currentEmail) {\n payload.email = currentEmail;\n }\n return payload;\n }\n\n function validatePayload(payload) {\n if (!payload.to || payload.to.length === 0) {\n return 'Add at least one recipient in To.';\n }\n if (!trimString(payload.subject)) {\n return 'Add a subject before sending.';\n }\n if (!trimString(payload.body)) {\n return 'Add an email body before sending.';\n }\n return null;\n }\n\n function sendPayload(payload) {\n pendingPayload = payload;\n pendingRequestId = 'send-' + Date.now() + '-' + Math.random().toString(16).slice(2);\n setSending(true);\n clearError();\n clearSuccess();\n\n window.parent.postMessage(\n {\n jsonrpc: '2.0',\n method: 'tools/call',\n params: {\n name: 'send_workspace_email',\n arguments: payload\n },\n id: pendingRequestId\n },\n '*'\n );\n }\n\n function applyDraftData(rawDraft) {\n var draft = rawDraft && typeof rawDraft === 'object' ? rawDraft : {};\n toInput.value = listToInputValue(draft.to);\n ccInput.value = listToInputValue(draft.cc);\n bccInput.value = listToInputValue(draft.bcc);\n subjectInput.value = typeof draft.subject === 'string' ? draft.subject : '';\n bodyInput.value = typeof draft.body === 'string' ? draft.body : '';\n currentEmail = typeof draft.email === 'string' ? draft.email : '';\n setCcVisible(normalizeAddressList(draft.cc).length > 0);\n setBccVisible(normalizeAddressList(draft.bcc).length > 0);\n clearError();\n clearSuccess();\n postResize();\n }\n\n function getDraftFromToolResult(payload) {\n if (!payload || typeof payload !== 'object') {\n return null;\n }\n // CANONICAL: post-A0 super-mcp hoists structuredContent onto the\n // outer block; the host posts it through `params.structuredContent`.\n if (payload.structuredContent && typeof payload.structuredContent === 'object') {\n return payload.structuredContent;\n }\n // MIGRATION SHIM: pre-A0 stored sessions replayed through the\n // current iframe lack `params.structuredContent` because the outer\n // block had no hoist at capture time. Read inner envelope text \u2192\n // JSON.parse \u2192 result.structuredContent. NOT regex-based.\n //\n // Lifetime: PERMANENT defensive read-side helper. Pre-A0 sessions\n // are persisted on disk and may be replayed indefinitely; there is\n // no time-based sunset. Removing this fallback would silently break\n // pre-A0 conversation replay.\n var text = typeof payload.text === 'string' ? payload.text :\n (Array.isArray(payload.content)\n ? (payload.content.find(function (c) { return c && c.type === 'text' && typeof c.text === 'string'; }) || {}).text\n : null);\n if (typeof text !== 'string') return null;\n try {\n var parsed = JSON.parse(text);\n if (parsed && typeof parsed === 'object' && parsed.result && typeof parsed.result === 'object') {\n var inner = parsed.result;\n if (inner.structuredContent && typeof inner.structuredContent === 'object') {\n return inner.structuredContent;\n }\n }\n } catch (_) {\n // Likely-envelope heuristic: text starts with `{` and contains\n // `\"package_id\"` in the first 64 chars. If JSON.parse failed on a\n // likely-envelope, surface a warning so the developer chasing\n // \"compose form is empty on replay\" sees a signal. For non-envelope\n // text (the dominant case), no log fires.\n var prefix = text.length > 64 ? text.slice(0, 64) : text;\n var likelyEnvelope = prefix.charAt(0) === '{' && prefix.indexOf('\"package_id\"') !== -1;\n if (likelyEnvelope && typeof console !== 'undefined' && typeof console.warn === 'function') {\n console.warn('[compose-email] Migration shim: JSON.parse failed on likely super-mcp envelope; pre-fill skipped');\n }\n }\n return null;\n }\n\n composeForm.addEventListener('submit', function (event) {\n event.preventDefault();\n if (sending) return;\n\n var payload = readFormPayload();\n var validationError = validatePayload(payload);\n if (validationError) {\n showError(validationError);\n return;\n }\n\n sendPayload(payload);\n });\n\n retryButton.addEventListener('click', function () {\n if (sending) return;\n var payload = readFormPayload();\n var validationError = validatePayload(payload);\n if (validationError) {\n showError(validationError);\n return;\n }\n sendPayload(payload);\n });\n\n cancelButton.addEventListener('click', function () {\n if (sending) return;\n clearError();\n clearSuccess();\n setCollapsed(true, 'Draft collapsed. Nothing sent.');\n });\n\n reopenButton.addEventListener('click', function () {\n setCollapsed(false);\n });\n\n toggleCcButton.addEventListener('click', function () {\n setCcVisible(ccRow.classList.contains('hidden'));\n postResize();\n });\n\n toggleBccButton.addEventListener('click', function () {\n setBccVisible(bccRow.classList.contains('hidden'));\n postResize();\n });\n\n [toInput, ccInput, bccInput, subjectInput, bodyInput].forEach(function (element) {\n element.addEventListener('input', function () {\n clearError();\n clearSuccess();\n postResize();\n });\n });\n\n window.addEventListener('message', function (event) {\n var data = event.data;\n if (!data || typeof data !== 'object') {\n return;\n }\n\n if (data.method === 'ui/notifications/tool-result') {\n var draft = getDraftFromToolResult(data.params);\n if (draft) {\n applyDraftData(draft);\n }\n return;\n }\n\n if (data.jsonrpc !== '2.0' || !pendingRequestId || data.id !== pendingRequestId) {\n return;\n }\n\n pendingRequestId = null;\n setSending(false);\n\n if (data.error) {\n var errorMessage = data.error && typeof data.error.message === 'string'\n ? data.error.message\n : 'Failed to send email.';\n showError(errorMessage);\n return;\n }\n\n clearError();\n showSuccess('Email sent successfully.');\n setCollapsed(true, 'Email sent.');\n reopenButton.classList.add('hidden');\n });\n\n if (typeof ResizeObserver === 'function' && document.body) {\n var observer = new ResizeObserver(postResize);\n observer.observe(document.body);\n }\n\n applyThemeFromHostContext();\n setCcVisible(false);\n setBccVisible(false);\n setCollapsed(false);\n postResize();\n postReady();\n\n window.parent.postMessage(\n {\n jsonrpc: '2.0',\n method: 'ui/initialize',\n params: { resourceUri: RESOURCE_URI },\n id: 'compose-email-init'\n },\n '*'\n );\n })();\n </script>\n</body>\n</html>\n";
|
|
1
|
+
export declare const COMPOSE_EMAIL_HTML = "\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>Compose Email</title>\n <style>\n :root {\n --bg: #ffffff;\n --panel: #ffffff;\n --border: #d9dde5;\n --text: #1f2937;\n --muted: #6b7280;\n --input-bg: #ffffff;\n --button-bg: #1f6feb;\n --button-text: #ffffff;\n --button-bg-hover: #1b63d3;\n --secondary-bg: #f3f4f6;\n --secondary-text: #1f2937;\n --secondary-border: #d1d5db;\n --error-bg: #fef2f2;\n --error-border: #fecaca;\n --error-text: #991b1b;\n --success-bg: #ecfdf5;\n --success-border: #bbf7d0;\n --success-text: #166534;\n --warning-bg: #fffbeb;\n --warning-border: #fde68a;\n --warning-text: #92400e;\n }\n\n @media (prefers-color-scheme: dark) {\n :root {\n --bg: #0f172a;\n --panel: #111827;\n --border: #334155;\n --text: #e5e7eb;\n --muted: #9ca3af;\n --input-bg: #0b1220;\n --button-bg: #3b82f6;\n --button-text: #eff6ff;\n --button-bg-hover: #2563eb;\n --secondary-bg: #1f2937;\n --secondary-text: #e5e7eb;\n --secondary-border: #374151;\n --error-bg: #2b1011;\n --error-border: #7f1d1d;\n --error-text: #fca5a5;\n --success-bg: #052e1b;\n --success-border: #166534;\n --success-text: #86efac;\n --warning-bg: #2a2106;\n --warning-border: #854d0e;\n --warning-text: #fcd34d;\n }\n }\n\n html[data-theme=\"light\"] {\n color-scheme: light;\n }\n\n html[data-theme=\"dark\"] {\n color-scheme: dark;\n --bg: #0f172a;\n --panel: #111827;\n --border: #334155;\n --text: #e5e7eb;\n --muted: #9ca3af;\n --input-bg: #0b1220;\n --button-bg: #3b82f6;\n --button-text: #eff6ff;\n --button-bg-hover: #2563eb;\n --secondary-bg: #1f2937;\n --secondary-text: #e5e7eb;\n --secondary-border: #374151;\n --error-bg: #2b1011;\n --error-border: #7f1d1d;\n --error-text: #fca5a5;\n --success-bg: #052e1b;\n --success-border: #166534;\n --success-text: #86efac;\n --warning-bg: #2a2106;\n --warning-border: #854d0e;\n --warning-text: #fcd34d;\n }\n\n * {\n box-sizing: border-box;\n }\n\n body {\n margin: 0;\n padding: 16px;\n background: var(--bg);\n color: var(--text);\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n line-height: 1.4;\n }\n\n .wrapper {\n width: 100%;\n max-width: 720px;\n margin: 0 auto;\n }\n\n .card {\n background: var(--panel);\n border: 1px solid var(--border);\n border-radius: 12px;\n padding: 14px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n\n .field label {\n font-size: 12px;\n font-weight: 600;\n color: var(--muted);\n text-transform: uppercase;\n letter-spacing: 0.04em;\n }\n\n .input,\n .textarea {\n width: 100%;\n background: var(--input-bg);\n color: var(--text);\n border: 1px solid var(--border);\n border-radius: 8px;\n padding: 10px 12px;\n font-size: 14px;\n font-family: inherit;\n }\n\n .input:focus,\n .textarea:focus {\n outline: 2px solid rgba(59, 130, 246, 0.35);\n outline-offset: 1px;\n }\n\n .textarea {\n min-height: 180px;\n resize: vertical;\n white-space: pre-wrap;\n }\n\n .toggles {\n display: flex;\n gap: 12px;\n align-items: center;\n flex-wrap: wrap;\n }\n\n .link-button {\n border: none;\n padding: 0;\n background: none;\n color: var(--muted);\n text-decoration: underline;\n font-size: 12px;\n cursor: pointer;\n }\n\n .link-button:hover {\n color: var(--text);\n }\n\n .actions {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n margin-top: 2px;\n }\n\n .button {\n border-radius: 8px;\n border: 1px solid transparent;\n min-height: 36px;\n padding: 0 14px;\n font-size: 13px;\n font-weight: 600;\n font-family: inherit;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n transition: background 120ms ease, opacity 120ms ease, border-color 120ms ease;\n }\n\n .button:disabled {\n cursor: not-allowed;\n opacity: 0.75;\n }\n\n .button-primary {\n background: var(--button-bg);\n color: var(--button-text);\n }\n\n .button-primary:hover:enabled {\n background: var(--button-bg-hover);\n }\n\n .button-secondary {\n background: var(--secondary-bg);\n color: var(--secondary-text);\n border-color: var(--secondary-border);\n }\n\n .spinner {\n width: 14px;\n height: 14px;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n display: inline-block;\n animation: spin 700ms linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .status {\n border-radius: 8px;\n border: 1px solid transparent;\n padding: 8px 10px;\n font-size: 13px;\n }\n\n .error {\n background: var(--error-bg);\n border-color: var(--error-border);\n color: var(--error-text);\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n }\n\n .success {\n background: var(--success-bg);\n border-color: var(--success-border);\n color: var(--success-text);\n }\n\n .warning {\n background: var(--warning-bg);\n border-color: var(--warning-border);\n color: var(--warning-text);\n display: block;\n }\n\n .warning strong {\n display: block;\n margin-bottom: 2px;\n }\n\n .warning .warning-detail {\n opacity: 0.85;\n }\n\n .collapsed {\n border: 1px solid var(--border);\n border-radius: 10px;\n background: var(--panel);\n padding: 10px 12px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n font-size: 13px;\n }\n\n .hidden {\n display: none !important;\n }\n </style>\n</head>\n<body>\n <div class=\"wrapper\">\n <div id=\"collapsedState\" class=\"collapsed hidden\">\n <span id=\"collapsedMessage\">Draft collapsed.</span>\n <button id=\"reopenButton\" type=\"button\" class=\"button button-secondary\">Reopen</button>\n </div>\n\n <form id=\"composeForm\" class=\"card\" novalidate>\n <div class=\"field\">\n <label for=\"toInput\">To</label>\n <input id=\"toInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"name@example.com, team@example.com\">\n </div>\n\n <div class=\"toggles\">\n <button id=\"toggleCcButton\" type=\"button\" class=\"link-button\">Add CC</button>\n <button id=\"toggleBccButton\" type=\"button\" class=\"link-button\">Add BCC</button>\n </div>\n\n <div id=\"ccRow\" class=\"field hidden\">\n <label for=\"ccInput\">CC</label>\n <input id=\"ccInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"cc@example.com\">\n </div>\n\n <div id=\"bccRow\" class=\"field hidden\">\n <label for=\"bccInput\">BCC</label>\n <input id=\"bccInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"bcc@example.com\">\n </div>\n\n <div class=\"field\">\n <label for=\"subjectInput\">Subject</label>\n <input id=\"subjectInput\" class=\"input\" type=\"text\" autocomplete=\"off\" placeholder=\"Email subject\">\n </div>\n\n <div class=\"field\">\n <label for=\"bodyInput\">Body</label>\n <textarea id=\"bodyInput\" class=\"textarea\" placeholder=\"Write your email\"></textarea>\n </div>\n\n <div id=\"errorBox\" class=\"status error hidden\">\n <span id=\"errorText\"></span>\n <button id=\"retryButton\" type=\"button\" class=\"link-button\">Retry</button>\n </div>\n\n <div id=\"successBox\" class=\"status success hidden\"></div>\n\n <div id=\"unknownBox\" class=\"status warning hidden\" role=\"status\" aria-live=\"polite\">\n <strong id=\"unknownTitle\"></strong>\n <span id=\"unknownText\" class=\"warning-detail\"></span>\n </div>\n\n <div class=\"actions\">\n <button id=\"cancelButton\" type=\"button\" class=\"button button-secondary\">Cancel</button>\n <button id=\"sendButton\" type=\"submit\" class=\"button button-primary\">\n <span id=\"sendSpinner\" class=\"spinner hidden\" aria-hidden=\"true\"></span>\n <span id=\"sendLabel\">Send email</span>\n </button>\n </div>\n </form>\n </div>\n\n <script>\n (function () {\n 'use strict';\n\n var RESOURCE_URI = 'ui://google-workspace/compose-email';\n var currentEmail = '';\n var pendingRequestId = null;\n var pendingPayload = null;\n var sending = false;\n var collapsed = false;\n var outcomeUnknown = false;\n var sendTimeoutId = null;\n // Just beyond the host-side tool-call timeout (60s) so a legitimately slow\n // send resolves to its real result first; this only fires when the reply\n // is genuinely lost (REBEL-677), so the button can never stay stuck-silent.\n var SEND_TIMEOUT_MS = 75000;\n\n var composeForm = document.getElementById('composeForm');\n var collapsedState = document.getElementById('collapsedState');\n var collapsedMessage = document.getElementById('collapsedMessage');\n var reopenButton = document.getElementById('reopenButton');\n\n var toInput = document.getElementById('toInput');\n var ccInput = document.getElementById('ccInput');\n var bccInput = document.getElementById('bccInput');\n var subjectInput = document.getElementById('subjectInput');\n var bodyInput = document.getElementById('bodyInput');\n var ccRow = document.getElementById('ccRow');\n var bccRow = document.getElementById('bccRow');\n var toggleCcButton = document.getElementById('toggleCcButton');\n var toggleBccButton = document.getElementById('toggleBccButton');\n\n var sendButton = document.getElementById('sendButton');\n var sendLabel = document.getElementById('sendLabel');\n var sendSpinner = document.getElementById('sendSpinner');\n var cancelButton = document.getElementById('cancelButton');\n var retryButton = document.getElementById('retryButton');\n\n var errorBox = document.getElementById('errorBox');\n var errorText = document.getElementById('errorText');\n var successBox = document.getElementById('successBox');\n var unknownBox = document.getElementById('unknownBox');\n var unknownTitle = document.getElementById('unknownTitle');\n var unknownText = document.getElementById('unknownText');\n\n function applyThemeFromHostContext() {\n try {\n var context = window.__MCP_HOST_CONTEXT__;\n if (!context || (context.theme !== 'light' && context.theme !== 'dark')) {\n return;\n }\n document.documentElement.setAttribute('data-theme', context.theme);\n } catch (_) {\n // Ignore theme extraction errors\n }\n }\n\n function trimString(value) {\n return String(value || '').trim();\n }\n\n function formatAddressItem(item) {\n if (item && typeof item === 'object') {\n var email = trimString(item.email || item.address || item.value);\n var name = trimString(item.name || item.displayName);\n if (email && name) {\n return name + ' <' + email + '>';\n }\n return email;\n }\n return trimString(item);\n }\n\n function normalizeAddressList(value) {\n if (Array.isArray(value)) {\n return value.map(formatAddressItem).filter(Boolean);\n }\n if (typeof value === 'string') {\n return value\n .split(',')\n .map(function (item) { return trimString(item); })\n .filter(Boolean);\n }\n return [];\n }\n\n function listToInputValue(list) {\n return normalizeAddressList(list).join(', ');\n }\n\n var resizeQueued = false;\n function postResize() {\n if (resizeQueued) return;\n resizeQueued = true;\n requestAnimationFrame(function () {\n resizeQueued = false;\n var height = Math.max(\n document.documentElement.scrollHeight,\n document.body ? document.body.scrollHeight : 0\n );\n window.parent.postMessage(\n { jsonrpc: '2.0', method: 'ui/resize', params: { height: height } },\n '*'\n );\n });\n }\n\n function postReady() {\n window.parent.postMessage(\n {\n method: 'mcp-app:ready',\n params: { resourceUri: RESOURCE_URI }\n },\n '*'\n );\n }\n\n function setCollapsed(nextCollapsed, message) {\n collapsed = nextCollapsed;\n composeForm.classList.toggle('hidden', collapsed);\n collapsedState.classList.toggle('hidden', !collapsed);\n if (message) {\n collapsedMessage.textContent = message;\n } else {\n collapsedMessage.textContent = collapsed ? 'Draft collapsed.' : '';\n }\n postResize();\n }\n\n function setSending(nextSending) {\n sending = nextSending;\n sendButton.disabled = nextSending;\n cancelButton.disabled = nextSending;\n toInput.disabled = nextSending;\n ccInput.disabled = nextSending;\n bccInput.disabled = nextSending;\n subjectInput.disabled = nextSending;\n bodyInput.disabled = nextSending;\n sendSpinner.classList.toggle('hidden', !nextSending);\n sendLabel.textContent = nextSending ? 'Sending\u2026' : 'Send email';\n postResize();\n }\n\n function clearError() {\n errorText.textContent = '';\n errorBox.classList.add('hidden');\n }\n\n function showError(message) {\n errorText.textContent = message || 'Failed to send email.';\n errorBox.classList.remove('hidden');\n postResize();\n }\n\n function clearSuccess() {\n successBox.textContent = '';\n successBox.classList.add('hidden');\n }\n\n function showSuccess(message) {\n successBox.textContent = message;\n successBox.classList.remove('hidden');\n postResize();\n }\n\n function clearSendTimeout() {\n if (sendTimeoutId !== null) {\n clearTimeout(sendTimeoutId);\n sendTimeoutId = null;\n }\n }\n\n function clearUnknown() {\n outcomeUnknown = false;\n unknownTitle.textContent = '';\n unknownText.textContent = '';\n unknownBox.classList.add('hidden');\n }\n\n // No reply ever came back for the send (e.g. the host's response was lost\n // before reaching this iframe). We genuinely don't know whether the email\n // went out, so we must NOT claim success or failure: re-enable the form and\n // tell the user to verify before resending (the send is not idempotent, so\n // a blind retry could send a duplicate). REBEL-677 / FOX-3484.\n function showSendUnknown() {\n outcomeUnknown = true;\n clearError();\n clearSuccess();\n unknownTitle.textContent = 'Not sure if this sent.';\n unknownText.textContent = \"Rebel didn't hear back in time. Check your Sent folder before sending again, so it doesn't go out twice.\";\n unknownBox.classList.remove('hidden');\n postResize();\n }\n\n function handleSendTimeout() {\n sendTimeoutId = null;\n if (!pendingRequestId) {\n return;\n }\n pendingRequestId = null;\n setSending(false);\n showSendUnknown();\n }\n\n function setCcVisible(visible) {\n ccRow.classList.toggle('hidden', !visible);\n toggleCcButton.textContent = visible ? 'Hide CC' : 'Add CC';\n }\n\n function setBccVisible(visible) {\n bccRow.classList.toggle('hidden', !visible);\n toggleBccButton.textContent = visible ? 'Hide BCC' : 'Add BCC';\n }\n\n function readFormPayload() {\n var payload = {\n to: normalizeAddressList(toInput.value),\n cc: normalizeAddressList(ccInput.value),\n bcc: normalizeAddressList(bccInput.value),\n subject: String(subjectInput.value || ''),\n body: String(bodyInput.value || '')\n };\n if (currentEmail) {\n payload.email = currentEmail;\n }\n return payload;\n }\n\n function validatePayload(payload) {\n if (!payload.to || payload.to.length === 0) {\n return 'Add at least one recipient in To.';\n }\n if (!trimString(payload.subject)) {\n return 'Add a subject before sending.';\n }\n if (!trimString(payload.body)) {\n return 'Add an email body before sending.';\n }\n return null;\n }\n\n function sendPayload(payload) {\n pendingPayload = payload;\n pendingRequestId = 'send-' + Date.now() + '-' + Math.random().toString(16).slice(2);\n setSending(true);\n clearError();\n clearSuccess();\n clearUnknown();\n clearSendTimeout();\n sendTimeoutId = setTimeout(handleSendTimeout, SEND_TIMEOUT_MS);\n\n window.parent.postMessage(\n {\n jsonrpc: '2.0',\n method: 'tools/call',\n params: {\n name: 'send_workspace_email',\n arguments: payload\n },\n id: pendingRequestId\n },\n '*'\n );\n }\n\n function applyDraftData(rawDraft) {\n var draft = rawDraft && typeof rawDraft === 'object' ? rawDraft : {};\n toInput.value = listToInputValue(draft.to);\n ccInput.value = listToInputValue(draft.cc);\n bccInput.value = listToInputValue(draft.bcc);\n subjectInput.value = typeof draft.subject === 'string' ? draft.subject : '';\n bodyInput.value = typeof draft.body === 'string' ? draft.body : '';\n currentEmail = typeof draft.email === 'string' ? draft.email : '';\n setCcVisible(normalizeAddressList(draft.cc).length > 0);\n setBccVisible(normalizeAddressList(draft.bcc).length > 0);\n clearError();\n clearSuccess();\n postResize();\n }\n\n function getDraftFromToolResult(payload) {\n if (!payload || typeof payload !== 'object') {\n return null;\n }\n // CANONICAL: post-A0 super-mcp hoists structuredContent onto the\n // outer block; the host posts it through `params.structuredContent`.\n if (payload.structuredContent && typeof payload.structuredContent === 'object') {\n return payload.structuredContent;\n }\n // MIGRATION SHIM: pre-A0 stored sessions replayed through the\n // current iframe lack `params.structuredContent` because the outer\n // block had no hoist at capture time. Read inner envelope text \u2192\n // JSON.parse \u2192 result.structuredContent. NOT regex-based.\n //\n // Lifetime: PERMANENT defensive read-side helper. Pre-A0 sessions\n // are persisted on disk and may be replayed indefinitely; there is\n // no time-based sunset. Removing this fallback would silently break\n // pre-A0 conversation replay.\n var text = typeof payload.text === 'string' ? payload.text :\n (Array.isArray(payload.content)\n ? (payload.content.find(function (c) { return c && c.type === 'text' && typeof c.text === 'string'; }) || {}).text\n : null);\n if (typeof text !== 'string') return null;\n try {\n var parsed = JSON.parse(text);\n if (parsed && typeof parsed === 'object' && parsed.result && typeof parsed.result === 'object') {\n var inner = parsed.result;\n if (inner.structuredContent && typeof inner.structuredContent === 'object') {\n return inner.structuredContent;\n }\n }\n } catch (_) {\n // Likely-envelope heuristic: text starts with `{` and contains\n // `\"package_id\"` in the first 64 chars. If JSON.parse failed on a\n // likely-envelope, surface a warning so the developer chasing\n // \"compose form is empty on replay\" sees a signal. For non-envelope\n // text (the dominant case), no log fires.\n var prefix = text.length > 64 ? text.slice(0, 64) : text;\n var likelyEnvelope = prefix.charAt(0) === '{' && prefix.indexOf('\"package_id\"') !== -1;\n if (likelyEnvelope && typeof console !== 'undefined' && typeof console.warn === 'function') {\n console.warn('[compose-email] Migration shim: JSON.parse failed on likely super-mcp envelope; pre-fill skipped');\n }\n }\n return null;\n }\n\n composeForm.addEventListener('submit', function (event) {\n event.preventDefault();\n if (sending) return;\n\n var payload = readFormPayload();\n var validationError = validatePayload(payload);\n if (validationError) {\n showError(validationError);\n return;\n }\n\n sendPayload(payload);\n });\n\n retryButton.addEventListener('click', function () {\n if (sending) return;\n var payload = readFormPayload();\n var validationError = validatePayload(payload);\n if (validationError) {\n showError(validationError);\n return;\n }\n sendPayload(payload);\n });\n\n cancelButton.addEventListener('click', function () {\n if (sending) return;\n // After a lost-reply timeout we don't know if the email sent, so don't\n // claim \"Nothing sent.\" on collapse \u2014 point the user to verify instead.\n var collapseMessage = outcomeUnknown\n ? 'Collapsed. Check your Sent folder if you are not sure.'\n : 'Draft collapsed. Nothing sent.';\n clearError();\n clearSuccess();\n clearUnknown();\n setCollapsed(true, collapseMessage);\n });\n\n reopenButton.addEventListener('click', function () {\n setCollapsed(false);\n });\n\n toggleCcButton.addEventListener('click', function () {\n setCcVisible(ccRow.classList.contains('hidden'));\n postResize();\n });\n\n toggleBccButton.addEventListener('click', function () {\n setBccVisible(bccRow.classList.contains('hidden'));\n postResize();\n });\n\n [toInput, ccInput, bccInput, subjectInput, bodyInput].forEach(function (element) {\n element.addEventListener('input', function () {\n clearError();\n clearSuccess();\n clearUnknown();\n postResize();\n });\n });\n\n window.addEventListener('message', function (event) {\n var data = event.data;\n if (!data || typeof data !== 'object') {\n return;\n }\n\n if (data.method === 'ui/notifications/tool-result') {\n var draft = getDraftFromToolResult(data.params);\n if (draft) {\n applyDraftData(draft);\n }\n return;\n }\n\n if (data.jsonrpc !== '2.0' || !pendingRequestId || data.id !== pendingRequestId) {\n return;\n }\n\n pendingRequestId = null;\n clearSendTimeout();\n clearUnknown();\n setSending(false);\n\n if (data.error) {\n var errorMessage = data.error && typeof data.error.message === 'string'\n ? data.error.message\n : 'Failed to send email.';\n showError(errorMessage);\n return;\n }\n\n clearError();\n showSuccess('Email sent successfully.');\n setCollapsed(true, 'Email sent.');\n reopenButton.classList.add('hidden');\n });\n\n if (typeof ResizeObserver === 'function' && document.body) {\n var observer = new ResizeObserver(postResize);\n observer.observe(document.body);\n }\n\n applyThemeFromHostContext();\n setCcVisible(false);\n setBccVisible(false);\n setCollapsed(false);\n postResize();\n postReady();\n\n window.parent.postMessage(\n {\n jsonrpc: '2.0',\n method: 'ui/initialize',\n params: { resourceUri: RESOURCE_URI },\n id: 'compose-email-init'\n },\n '*'\n );\n })();\n </script>\n</body>\n</html>\n";
|
|
2
2
|
//# sourceMappingURL=compose-email-template.d.ts.map
|
|
@@ -26,6 +26,9 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
26
26
|
--success-bg: #ecfdf5;
|
|
27
27
|
--success-border: #bbf7d0;
|
|
28
28
|
--success-text: #166534;
|
|
29
|
+
--warning-bg: #fffbeb;
|
|
30
|
+
--warning-border: #fde68a;
|
|
31
|
+
--warning-text: #92400e;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
@media (prefers-color-scheme: dark) {
|
|
@@ -48,6 +51,9 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
48
51
|
--success-bg: #052e1b;
|
|
49
52
|
--success-border: #166534;
|
|
50
53
|
--success-text: #86efac;
|
|
54
|
+
--warning-bg: #2a2106;
|
|
55
|
+
--warning-border: #854d0e;
|
|
56
|
+
--warning-text: #fcd34d;
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -75,6 +81,9 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
75
81
|
--success-bg: #052e1b;
|
|
76
82
|
--success-border: #166534;
|
|
77
83
|
--success-text: #86efac;
|
|
84
|
+
--warning-bg: #2a2106;
|
|
85
|
+
--warning-border: #854d0e;
|
|
86
|
+
--warning-text: #fcd34d;
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
* {
|
|
@@ -246,6 +255,22 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
246
255
|
color: var(--success-text);
|
|
247
256
|
}
|
|
248
257
|
|
|
258
|
+
.warning {
|
|
259
|
+
background: var(--warning-bg);
|
|
260
|
+
border-color: var(--warning-border);
|
|
261
|
+
color: var(--warning-text);
|
|
262
|
+
display: block;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.warning strong {
|
|
266
|
+
display: block;
|
|
267
|
+
margin-bottom: 2px;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.warning .warning-detail {
|
|
271
|
+
opacity: 0.85;
|
|
272
|
+
}
|
|
273
|
+
|
|
249
274
|
.collapsed {
|
|
250
275
|
border: 1px solid var(--border);
|
|
251
276
|
border-radius: 10px;
|
|
@@ -308,6 +333,11 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
308
333
|
|
|
309
334
|
<div id="successBox" class="status success hidden"></div>
|
|
310
335
|
|
|
336
|
+
<div id="unknownBox" class="status warning hidden" role="status" aria-live="polite">
|
|
337
|
+
<strong id="unknownTitle"></strong>
|
|
338
|
+
<span id="unknownText" class="warning-detail"></span>
|
|
339
|
+
</div>
|
|
340
|
+
|
|
311
341
|
<div class="actions">
|
|
312
342
|
<button id="cancelButton" type="button" class="button button-secondary">Cancel</button>
|
|
313
343
|
<button id="sendButton" type="submit" class="button button-primary">
|
|
@@ -328,6 +358,12 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
328
358
|
var pendingPayload = null;
|
|
329
359
|
var sending = false;
|
|
330
360
|
var collapsed = false;
|
|
361
|
+
var outcomeUnknown = false;
|
|
362
|
+
var sendTimeoutId = null;
|
|
363
|
+
// Just beyond the host-side tool-call timeout (60s) so a legitimately slow
|
|
364
|
+
// send resolves to its real result first; this only fires when the reply
|
|
365
|
+
// is genuinely lost (REBEL-677), so the button can never stay stuck-silent.
|
|
366
|
+
var SEND_TIMEOUT_MS = 75000;
|
|
331
367
|
|
|
332
368
|
var composeForm = document.getElementById('composeForm');
|
|
333
369
|
var collapsedState = document.getElementById('collapsedState');
|
|
@@ -353,6 +389,9 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
353
389
|
var errorBox = document.getElementById('errorBox');
|
|
354
390
|
var errorText = document.getElementById('errorText');
|
|
355
391
|
var successBox = document.getElementById('successBox');
|
|
392
|
+
var unknownBox = document.getElementById('unknownBox');
|
|
393
|
+
var unknownTitle = document.getElementById('unknownTitle');
|
|
394
|
+
var unknownText = document.getElementById('unknownText');
|
|
356
395
|
|
|
357
396
|
function applyThemeFromHostContext() {
|
|
358
397
|
try {
|
|
@@ -474,6 +513,45 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
474
513
|
postResize();
|
|
475
514
|
}
|
|
476
515
|
|
|
516
|
+
function clearSendTimeout() {
|
|
517
|
+
if (sendTimeoutId !== null) {
|
|
518
|
+
clearTimeout(sendTimeoutId);
|
|
519
|
+
sendTimeoutId = null;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function clearUnknown() {
|
|
524
|
+
outcomeUnknown = false;
|
|
525
|
+
unknownTitle.textContent = '';
|
|
526
|
+
unknownText.textContent = '';
|
|
527
|
+
unknownBox.classList.add('hidden');
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// No reply ever came back for the send (e.g. the host's response was lost
|
|
531
|
+
// before reaching this iframe). We genuinely don't know whether the email
|
|
532
|
+
// went out, so we must NOT claim success or failure: re-enable the form and
|
|
533
|
+
// tell the user to verify before resending (the send is not idempotent, so
|
|
534
|
+
// a blind retry could send a duplicate). REBEL-677 / FOX-3484.
|
|
535
|
+
function showSendUnknown() {
|
|
536
|
+
outcomeUnknown = true;
|
|
537
|
+
clearError();
|
|
538
|
+
clearSuccess();
|
|
539
|
+
unknownTitle.textContent = 'Not sure if this sent.';
|
|
540
|
+
unknownText.textContent = "Rebel didn't hear back in time. Check your Sent folder before sending again, so it doesn't go out twice.";
|
|
541
|
+
unknownBox.classList.remove('hidden');
|
|
542
|
+
postResize();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function handleSendTimeout() {
|
|
546
|
+
sendTimeoutId = null;
|
|
547
|
+
if (!pendingRequestId) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
pendingRequestId = null;
|
|
551
|
+
setSending(false);
|
|
552
|
+
showSendUnknown();
|
|
553
|
+
}
|
|
554
|
+
|
|
477
555
|
function setCcVisible(visible) {
|
|
478
556
|
ccRow.classList.toggle('hidden', !visible);
|
|
479
557
|
toggleCcButton.textContent = visible ? 'Hide CC' : 'Add CC';
|
|
@@ -517,6 +595,9 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
517
595
|
setSending(true);
|
|
518
596
|
clearError();
|
|
519
597
|
clearSuccess();
|
|
598
|
+
clearUnknown();
|
|
599
|
+
clearSendTimeout();
|
|
600
|
+
sendTimeoutId = setTimeout(handleSendTimeout, SEND_TIMEOUT_MS);
|
|
520
601
|
|
|
521
602
|
window.parent.postMessage(
|
|
522
603
|
{
|
|
@@ -620,9 +701,15 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
620
701
|
|
|
621
702
|
cancelButton.addEventListener('click', function () {
|
|
622
703
|
if (sending) return;
|
|
704
|
+
// After a lost-reply timeout we don't know if the email sent, so don't
|
|
705
|
+
// claim "Nothing sent." on collapse — point the user to verify instead.
|
|
706
|
+
var collapseMessage = outcomeUnknown
|
|
707
|
+
? 'Collapsed. Check your Sent folder if you are not sure.'
|
|
708
|
+
: 'Draft collapsed. Nothing sent.';
|
|
623
709
|
clearError();
|
|
624
710
|
clearSuccess();
|
|
625
|
-
|
|
711
|
+
clearUnknown();
|
|
712
|
+
setCollapsed(true, collapseMessage);
|
|
626
713
|
});
|
|
627
714
|
|
|
628
715
|
reopenButton.addEventListener('click', function () {
|
|
@@ -643,6 +730,7 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
643
730
|
element.addEventListener('input', function () {
|
|
644
731
|
clearError();
|
|
645
732
|
clearSuccess();
|
|
733
|
+
clearUnknown();
|
|
646
734
|
postResize();
|
|
647
735
|
});
|
|
648
736
|
});
|
|
@@ -666,6 +754,8 @@ export const COMPOSE_EMAIL_HTML = `
|
|
|
666
754
|
}
|
|
667
755
|
|
|
668
756
|
pendingRequestId = null;
|
|
757
|
+
clearSendTimeout();
|
|
758
|
+
clearUnknown();
|
|
669
759
|
setSending(false);
|
|
670
760
|
|
|
671
761
|
if (data.error) {
|
|
@@ -364,7 +364,9 @@ Use get_workspace_email_thread with a thread_id from results to get full convers
|
|
|
364
364
|
category: 'Gmail/Messages',
|
|
365
365
|
description: `Open an inline editable email compose form before sending.
|
|
366
366
|
|
|
367
|
-
Use this when
|
|
367
|
+
Use this when the user wants an editable review form in Rebel before sending. The form lets the user edit To, CC, BCC, Subject, and Body, then explicitly click Send.
|
|
368
|
+
|
|
369
|
+
Do NOT use this when the user asks to save/create a Gmail draft, save to drafts, or save the already-drafted email without opening another review UI. Use create_workspace_draft for that.
|
|
368
370
|
|
|
369
371
|
This tool does not send the email directly. It prepares the draft and launches the inline form.`,
|
|
370
372
|
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
@@ -746,7 +748,7 @@ Attachments are NOT automatically carried over — you must explicitly download
|
|
|
746
748
|
{
|
|
747
749
|
name: 'create_workspace_draft',
|
|
748
750
|
category: 'Gmail/Drafts',
|
|
749
|
-
description: `Create a new Gmail draft. Supports plain text and HTML bodies, CC/BCC, reply threading, and attachments.`,
|
|
751
|
+
description: `Create a new Gmail draft. Use this when the user asks to save to drafts, save/create a Gmail draft, or save an already-drafted email without sending or opening another review UI. Supports plain text and HTML bodies, CC/BCC, reply threading, and attachments.`,
|
|
750
752
|
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
751
753
|
inputSchema: {
|
|
752
754
|
type: 'object',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function atomicCredentialWrite(filePath: string, data: string, opts?: {
|
|
1
|
+
export declare function atomicCredentialWrite(filePath: string, data: string | Buffer, opts?: {
|
|
2
2
|
mode?: number;
|
|
3
3
|
}): Promise<void>;
|
|
4
4
|
export declare function sweepStaleTemps(dir: string): Promise<void>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// vendored from upstream commit 4fcf6bcf2cc8170e656dc4e9a7f362116b9025c9
|
|
2
|
+
// keep byte-equivalent (modulo import path); see check-atomic-helper-equivalence.ts
|
|
1
3
|
import crypto from 'node:crypto';
|
|
2
4
|
import fs from 'node:fs';
|
|
3
5
|
import path from 'node:path';
|
|
@@ -6,12 +8,22 @@ const CREDENTIAL_FILE_MODE = 0o600;
|
|
|
6
8
|
const CREDENTIAL_DIR_MODE = 0o700;
|
|
7
9
|
const STALE_TEMP_MAX_AGE_MS = 5 * 60 * 1000;
|
|
8
10
|
function getSafeTempOpenFlags() {
|
|
11
|
+
// Use exclusive create (`wx`) so pre-existing temp paths fail closed.
|
|
12
|
+
// When available, add O_NOFOLLOW to refuse symlink traversal outright.
|
|
9
13
|
if (process.platform !== 'win32' && typeof fs.constants.O_NOFOLLOW === 'number') {
|
|
10
14
|
return fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_NOFOLLOW;
|
|
11
15
|
}
|
|
12
16
|
return 'wx';
|
|
13
17
|
}
|
|
14
18
|
function assertTargetIsNotSymlink(filePath) {
|
|
19
|
+
// Policy guard, NOT a race-free primitive: this lstat is TOCTOU-racy by design
|
|
20
|
+
// (an attacker who controls the parent directory can swap the entry between this
|
|
21
|
+
// check and the later rename). It exists to fail loud — and give a clear error —
|
|
22
|
+
// when a pre-existing credential path is already a symlink. The real write-through
|
|
23
|
+
// protection is the exclusive-create temp open (wx/O_EXCL + O_NOFOLLOW where
|
|
24
|
+
// available) plus rename(), which replaces the destination entry rather than
|
|
25
|
+
// following a symlink. See check-atomic-helper-equivalence.ts: this guard is part
|
|
26
|
+
// of the byte-equivalent contract across host + OSS copies.
|
|
15
27
|
try {
|
|
16
28
|
const stats = withSingleSyncRetryOnEmfile(() => fs.lstatSync(filePath));
|
|
17
29
|
if (stats.isSymbolicLink()) {
|
|
@@ -29,6 +41,7 @@ function assertTargetIsNotSymlink(filePath) {
|
|
|
29
41
|
}
|
|
30
42
|
function fsyncParentDirectory(dirPath) {
|
|
31
43
|
if (process.platform === 'win32') {
|
|
44
|
+
// Windows does not support fsync on directory file descriptors in a portable way.
|
|
32
45
|
return;
|
|
33
46
|
}
|
|
34
47
|
let dirFd;
|
|
@@ -64,10 +77,13 @@ export async function atomicCredentialWrite(filePath, data, opts) {
|
|
|
64
77
|
assertTargetIsNotSymlink(filePath);
|
|
65
78
|
const openedFileDescriptor = withSingleSyncRetryOnEmfile(() => fs.openSync(tempPath, getSafeTempOpenFlags(), fileMode));
|
|
66
79
|
fileDescriptor = openedFileDescriptor;
|
|
67
|
-
withSingleSyncRetryOnEmfile(() =>
|
|
80
|
+
withSingleSyncRetryOnEmfile(() => typeof data === 'string'
|
|
81
|
+
? fs.writeFileSync(openedFileDescriptor, data, { encoding: 'utf8' })
|
|
82
|
+
: fs.writeFileSync(openedFileDescriptor, data));
|
|
68
83
|
withSingleSyncRetryOnEmfile(() => fs.fsyncSync(openedFileDescriptor));
|
|
69
84
|
withSingleSyncRetryOnEmfile(() => fs.closeSync(openedFileDescriptor));
|
|
70
85
|
fileDescriptor = undefined;
|
|
86
|
+
withSingleSyncRetryOnEmfile(() => fs.chmodSync(tempPath, CREDENTIAL_FILE_MODE));
|
|
71
87
|
withSingleSyncRetryOnEmfile(() => fs.renameSync(tempPath, filePath));
|
|
72
88
|
withSingleSyncRetryOnEmfile(() => fs.chmodSync(filePath, CREDENTIAL_FILE_MODE));
|
|
73
89
|
fsyncParentDirectory(parentDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindstone/mcp-server-google-workspace",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"mcpName": "io.github.mindstone/mcp-server-google-workspace",
|
|
5
5
|
"description": "Google Workspace MCP server for Gmail, Calendar, Drive, Docs, Sheets, Slides, Contacts, Tasks, and Forms",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@types/node": "^22",
|
|
50
50
|
"@types/uuid": "^10.0.0",
|
|
51
51
|
"@vitest/coverage-v8": "^4.1.3",
|
|
52
|
+
"happy-dom": "^20.8.9",
|
|
52
53
|
"msw": "^2.13.2",
|
|
53
54
|
"shx": "^0.3.4",
|
|
54
55
|
"typescript": "^5.8.2",
|