{"repo_name": "glass", "file_name": "/glass/src/ui/listen/ListenView.js", "inference_info": {"prefix_code": "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\nimport './stt/SttView.js';\nimport './summary/SummaryView.js';\n\nexport class ListenView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 400px;\n transform: translate3d(0, 0, 0);\n backface-visibility: hidden;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n will-change: transform, opacity;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n/* Allow text selection in insights responses */\n.insights-container, .insights-container *, .markdown-content {\n user-select: text !important;\n cursor: text !important;\n}\n\n/* highlight.js 스타일 추가 */\n.insights-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n}\n\n.insights-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n}\n\n.insights-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n}\n\n.insights-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n}\n\n.hljs-keyword {\n color: #ff79c6 !important;\n}\n\n.hljs-string {\n color: #f1fa8c !important;\n}\n\n.hljs-comment {\n color: #6272a4 !important;\n}\n\n.hljs-number {\n color: #bd93f9 !important;\n}\n\n.hljs-function {\n color: #50fa7b !important;\n}\n\n.hljs-title {\n color: #50fa7b !important;\n}\n\n.hljs-variable {\n color: #8be9fd !important;\n}\n\n.hljs-built_in {\n color: #ffb86c !important;\n}\n\n.hljs-attr {\n color: #50fa7b !important;\n}\n\n.hljs-tag {\n color: #ff79c6 !important;\n}\n .assistant-container {\n display: flex;\n flex-direction: column;\n color: #ffffff;\n box-sizing: border-box;\n position: relative;\n background: rgba(0, 0, 0, 0.6);\n overflow: hidden;\n border-radius: 12px;\n width: 100%;\n height: 100%;\n }\n\n .assistant-container::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 12px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .assistant-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n z-index: -1;\n }\n\n .top-bar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 6px 16px;\n min-height: 32px;\n position: relative;\n z-index: 1;\n width: 100%;\n box-sizing: border-box;\n flex-shrink: 0;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .bar-left-text {\n color: white;\n font-size: 13px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n position: relative;\n overflow: hidden;\n white-space: nowrap;\n flex: 1;\n min-width: 0;\n max-width: 200px;\n }\n\n .bar-left-text-content {\n display: inline-block;\n transition: transform 0.3s ease;\n }\n\n .bar-left-text-content.slide-in {\n animation: slideIn 0.3s ease forwards;\n }\n\n .bar-controls {\n display: flex;\n gap: 4px;\n align-items: center;\n flex-shrink: 0;\n width: 120px;\n justify-content: flex-end;\n box-sizing: border-box;\n padding: 4px;\n }\n\n .toggle-button {\n display: flex;\n align-items: center;\n gap: 5px;\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: none;\n outline: none;\n box-shadow: none;\n padding: 4px 8px;\n border-radius: 5px;\n font-size: 11px;\n font-weight: 500;\n cursor: pointer;\n height: 24px;\n white-space: nowrap;\n transition: background-color 0.15s ease;\n justify-content: center;\n }\n\n .toggle-button:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .toggle-button svg {\n flex-shrink: 0;\n width: 12px;\n height: 12px;\n }\n\n .copy-button {\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: none;\n outline: none;\n box-shadow: none;\n padding: 4px;\n border-radius: 3px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 24px;\n height: 24px;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n position: relative;\n overflow: hidden;\n }\n\n .copy-button:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n\n .copy-button svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n }\n\n .copy-button .check-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .copy-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .check-icon {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n\n .timer {\n font-family: 'Monaco', 'Menlo', monospace;\n font-size: 10px;\n color: rgba(255, 255, 255, 0.7);\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .top-bar,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .transcription-container,\n :host-context(body.has-glass) .insights-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .outline-item,\n :host-context(body.has-glass) .request-item,\n :host-context(body.has-glass) .markdown-content,\n :host-context(body.has-glass) .insights-container pre,\n :host-context(body.has-glass) .insights-container p code,\n :host-context(body.has-glass) .insights-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container::before,\n :host-context(body.has-glass) .assistant-container::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .toggle-button:hover,\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .outline-item:hover,\n :host-context(body.has-glass) .request-item.clickable:hover,\n :host-context(body.has-glass) .markdown-content:hover {\n background: transparent !important;\n transform: none !important;\n }\n\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-thumb,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button {\n border-radius: 0 !important;\n }\n\n :host-context(body.has-glass) ::-webkit-scrollbar,\n :host-context(body.has-glass) ::-webkit-scrollbar-track,\n :host-context(body.has-glass) ::-webkit-scrollbar-thumb {\n background: transparent !important;\n width: 0 !important; /* 스크롤바 자체 숨기기 */\n }\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .top-bar,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .transcription-container,\n :host-context(body.has-glass) .insights-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .outline-item,\n :host-context(body.has-glass) .request-item,\n :host-context(body.has-glass) .markdown-content,\n :host-context(body.has-glass) .insights-container pre,\n :host-context(body.has-glass) .insights-container p code,\n :host-context(body.has-glass) .insights-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container::before,\n :host-context(body.has-glass) .assistant-container::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .toggle-button:hover,\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .outline-item:hover,\n :host-context(body.has-glass) .request-item.clickable:hover,\n :host-context(body.has-glass) .markdown-content:hover {\n background: transparent !important;\n transform: none !important;\n }\n\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-thumb,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button {\n border-radius: 0 !important;\n }\n\n :host-context(body.has-glass) ::-webkit-scrollbar,\n :host-context(body.has-glass) ::-webkit-scrollbar-track,\n :host-context(body.has-glass) ::-webkit-scrollbar-thumb {\n background: transparent !important;\n width: 0 !important;\n }\n `;\n\n static properties = {\n viewMode: { type: String },\n isHovering: { type: Boolean },\n isAnimating: { type: Boolean },\n copyState: { type: String },\n elapsedTime: { type: String },\n captureStartTime: { type: Number },\n isSessionActive: { type: Boolean },\n hasCompletedRecording: { type: Boolean },\n };\n\n constructor() {\n super();\n this.isSessionActive = false;\n this.hasCompletedRecording = false;\n this.viewMode = 'insights';\n this.isHovering = false;\n this.isAnimating = false;\n this.elapsedTime = '00:00';\n this.captureStartTime = null;\n this.timerInterval = null;\n this.adjustHeightThrottle = null;\n this.isThrottled = false;\n this.copyState = 'idle';\n this.copyTimeout = null;\n\n this.adjustWindowHeight = this.adjustWindowHeight.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n // Only start timer if session is active\n if (this.isSessionActive) {\n this.startTimer();\n }\n if (window.api) {\n window.api.listenView.onSessionStateChanged(", "suffix_code": ");\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.stopTimer();\n\n if (this.adjustHeightThrottle) {\n clearTimeout(this.adjustHeightThrottle);\n this.adjustHeightThrottle = null;\n }\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n }\n\n startTimer() {\n this.captureStartTime = Date.now();\n this.timerInterval = setInterval(() => {\n const elapsed = Math.floor((Date.now() - this.captureStartTime) / 1000);\n const minutes = Math.floor(elapsed / 60)\n .toString()\n .padStart(2, '0');\n const seconds = (elapsed % 60).toString().padStart(2, '0');\n this.elapsedTime = `${minutes}:${seconds}`;\n this.requestUpdate();\n }, 1000);\n }\n\n stopTimer() {\n if (this.timerInterval) {\n clearInterval(this.timerInterval);\n this.timerInterval = null;\n }\n }\n\n adjustWindowHeight() {\n if (!window.api) return;\n\n this.updateComplete\n .then(() => {\n const topBar = this.shadowRoot.querySelector('.top-bar');\n const activeContent = this.viewMode === 'transcript'\n ? this.shadowRoot.querySelector('stt-view')\n : this.shadowRoot.querySelector('summary-view');\n\n if (!topBar || !activeContent) return;\n\n const topBarHeight = topBar.offsetHeight;\n\n const contentHeight = activeContent.scrollHeight;\n\n const idealHeight = topBarHeight + contentHeight;\n\n const targetHeight = Math.min(700, idealHeight);\n\n console.log(\n `[Height Adjusted] Mode: ${this.viewMode}, TopBar: ${topBarHeight}px, Content: ${contentHeight}px, Ideal: ${idealHeight}px, Target: ${targetHeight}px`\n );\n\n window.api.listenView.adjustWindowHeight('listen', targetHeight);\n })\n .catch(error => {\n console.error('Error in adjustWindowHeight:', error);\n });\n }\n\n toggleViewMode() {\n this.viewMode = this.viewMode === 'insights' ? 'transcript' : 'insights';\n this.requestUpdate();\n }\n\n handleCopyHover(isHovering) {\n this.isHovering = isHovering;\n if (isHovering) {\n this.isAnimating = true;\n } else {\n this.isAnimating = false;\n }\n this.requestUpdate();\n }\n\n async handleCopy() {\n if (this.copyState === 'copied') return;\n\n let textToCopy = '';\n\n if (this.viewMode === 'transcript') {\n const sttView = this.shadowRoot.querySelector('stt-view');\n textToCopy = sttView ? sttView.getTranscriptText() : '';\n } else {\n const summaryView = this.shadowRoot.querySelector('summary-view');\n textToCopy = summaryView ? summaryView.getSummaryText() : '';\n }\n\n try {\n await navigator.clipboard.writeText(textToCopy);\n console.log('Content copied to clipboard');\n\n this.copyState = 'copied';\n this.requestUpdate();\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n this.copyTimeout = setTimeout(() => {\n this.copyState = 'idle';\n this.requestUpdate();\n }, 1500);\n } catch (err) {\n console.error('Failed to copy:', err);\n }\n }\n\n adjustWindowHeightThrottled() {\n if (this.isThrottled) {\n return;\n }\n\n this.adjustWindowHeight();\n\n this.isThrottled = true;\n\n this.adjustHeightThrottle = setTimeout(() => {\n this.isThrottled = false;\n }, 16);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n\n if (changedProperties.has('viewMode')) {\n this.adjustWindowHeight();\n }\n }\n\n handleSttMessagesUpdated(event) {\n // Handle messages update from SttView if needed\n this.adjustWindowHeightThrottled();\n }\n\n firstUpdated() {\n super.firstUpdated();\n setTimeout(() => this.adjustWindowHeight(), 200);\n }\n\n render() {\n const displayText = this.isHovering\n ? this.viewMode === 'transcript'\n ? 'Copy Transcript'\n : 'Copy Glass Analysis'\n : this.viewMode === 'insights'\n ? `Live insights`\n : `Glass is Listening ${this.elapsedTime}`;\n\n return html`\n
\n
\n
\n ${displayText}\n
\n
\n \n this.handleCopyHover(true)}\n @mouseleave=${() => this.handleCopyHover(false)}\n >\n \n \n \n \n \n \n \n \n
\n
\n\n \n\n \n
\n `;\n }\n}\n\ncustomElements.define('listen-view', ListenView);\n", "middle_code": "(event, { isActive }) => {\n const wasActive = this.isSessionActive;\n this.isSessionActive = isActive;\n if (!wasActive && isActive) {\n this.hasCompletedRecording = false;\n this.startTimer();\n this.updateComplete.then(() => {\n const sttView = this.shadowRoot.querySelector('stt-view');\n const summaryView = this.shadowRoot.querySelector('summary-view');\n if (sttView) sttView.resetTranscript();\n if (summaryView) summaryView.resetAnalysis();\n });\n this.requestUpdate();\n }\n if (wasActive && !isActive) {\n this.hasCompletedRecording = true;\n this.stopTimer();\n this.requestUpdate();\n }\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [["/glass/src/ui/ask/AskView.js", "import { html, css, LitElement } from '../../ui/assets/lit-core-2.7.4.min.js';\nimport { parser, parser_write, parser_end, default_renderer } from '../../ui/assets/smd.js';\n\nexport class AskView extends LitElement {\n static properties = {\n currentResponse: { type: String },\n currentQuestion: { type: String },\n isLoading: { type: Boolean },\n copyState: { type: String },\n isHovering: { type: Boolean },\n hoveredLineIndex: { type: Number },\n lineCopyState: { type: Object },\n showTextInput: { type: Boolean },\n headerText: { type: String },\n headerAnimating: { type: Boolean },\n isStreaming: { type: Boolean },\n };\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n color: white;\n transform: translate3d(0, 0, 0);\n backface-visibility: hidden;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n will-change: transform, opacity;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n @keyframes slideUp {\n 0% {\n opacity: 1;\n transform: translateY(0) scale(1);\n filter: blur(0px);\n }\n 30% {\n opacity: 0.7;\n transform: translateY(-20%) scale(0.98);\n filter: blur(0.5px);\n }\n 70% {\n opacity: 0.3;\n transform: translateY(-80%) scale(0.92);\n filter: blur(1.5px);\n }\n 100% {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n filter: blur(2px);\n }\n }\n\n @keyframes slideDown {\n 0% {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n filter: blur(2px);\n }\n 30% {\n opacity: 0.5;\n transform: translateY(-50%) scale(0.92);\n filter: blur(1px);\n }\n 65% {\n opacity: 0.9;\n transform: translateY(-5%) scale(0.99);\n filter: blur(0.2px);\n }\n 85% {\n opacity: 0.98;\n transform: translateY(2%) scale(1.005);\n filter: blur(0px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0) scale(1);\n filter: blur(0px);\n }\n }\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n /* Allow text selection in assistant responses */\n .response-container, .response-container * {\n user-select: text !important;\n cursor: text !important;\n }\n\n .response-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .response-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .response-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n }\n\n .response-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n }\n\n .hljs-keyword {\n color: #ff79c6 !important;\n }\n .hljs-string {\n color: #f1fa8c !important;\n }\n .hljs-comment {\n color: #6272a4 !important;\n }\n .hljs-number {\n color: #bd93f9 !important;\n }\n .hljs-function {\n color: #50fa7b !important;\n }\n .hljs-variable {\n color: #8be9fd !important;\n }\n .hljs-built_in {\n color: #ffb86c !important;\n }\n .hljs-title {\n color: #50fa7b !important;\n }\n .hljs-attr {\n color: #50fa7b !important;\n }\n .hljs-tag {\n color: #ff79c6 !important;\n }\n\n .ask-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: rgba(0, 0, 0, 0.6);\n border-radius: 12px;\n outline: 0.5px rgba(255, 255, 255, 0.3) solid;\n outline-offset: -1px;\n backdrop-filter: blur(1px);\n box-sizing: border-box;\n position: relative;\n overflow: hidden;\n }\n\n .ask-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n filter: blur(10px);\n z-index: -1;\n }\n\n .response-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 16px;\n background: transparent;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n flex-shrink: 0;\n }\n\n .response-header.hidden {\n display: none;\n }\n\n .header-left {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n }\n\n .response-icon {\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.2);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .response-icon svg {\n width: 12px;\n height: 12px;\n stroke: rgba(255, 255, 255, 0.9);\n }\n\n .response-label {\n font-size: 13px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.9);\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n\n .response-label.animating {\n animation: fadeInOut 0.3s ease-in-out;\n }\n\n @keyframes fadeInOut {\n 0% {\n opacity: 1;\n transform: translateY(0);\n }\n 50% {\n opacity: 0;\n transform: translateY(-10px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .header-right {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n justify-content: flex-end;\n }\n\n .question-text {\n font-size: 13px;\n color: rgba(255, 255, 255, 0.7);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 300px;\n margin-right: 8px;\n }\n\n .header-controls {\n display: flex;\n gap: 8px;\n align-items: center;\n flex-shrink: 0;\n }\n\n .copy-button {\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: 1px solid rgba(255, 255, 255, 0.2);\n padding: 4px;\n border-radius: 3px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 24px;\n height: 24px;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n position: relative;\n overflow: hidden;\n }\n\n .copy-button:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n\n .copy-button svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n }\n\n .copy-button .check-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .copy-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .check-icon {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n\n .close-button {\n background: rgba(255, 255, 255, 0.07);\n color: white;\n border: none;\n padding: 4px;\n border-radius: 20px;\n outline: 1px rgba(255, 255, 255, 0.3) solid;\n outline-offset: -1px;\n backdrop-filter: blur(0.5px);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n }\n\n .close-button:hover {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 1);\n }\n\n .response-container {\n flex: 1;\n padding: 16px;\n padding-left: 48px;\n overflow-y: auto;\n font-size: 14px;\n line-height: 1.6;\n background: transparent;\n min-height: 0;\n max-height: 400px;\n position: relative;\n }\n\n .response-container.hidden {\n display: none;\n }\n\n .response-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .response-container::-webkit-scrollbar-track {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n }\n\n .response-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n }\n\n .response-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .loading-dots {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n padding: 40px;\n }\n\n .loading-dot {\n width: 8px;\n height: 8px;\n background: rgba(255, 255, 255, 0.6);\n border-radius: 50%;\n animation: pulse 1.5s ease-in-out infinite;\n }\n\n .loading-dot:nth-child(1) {\n animation-delay: 0s;\n }\n\n .loading-dot:nth-child(2) {\n animation-delay: 0.2s;\n }\n\n .loading-dot:nth-child(3) {\n animation-delay: 0.4s;\n }\n\n @keyframes pulse {\n 0%,\n 80%,\n 100% {\n opacity: 0.3;\n transform: scale(0.8);\n }\n 40% {\n opacity: 1;\n transform: scale(1.2);\n }\n }\n\n .response-line {\n position: relative;\n padding: 2px 0;\n margin: 0;\n transition: background-color 0.15s ease;\n }\n\n .response-line:hover {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 4px;\n }\n\n .line-copy-button {\n position: absolute;\n left: -32px;\n top: 50%;\n transform: translateY(-50%);\n background: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n padding: 2px;\n cursor: pointer;\n opacity: 0;\n transition: opacity 0.15s ease, background-color 0.15s ease;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n }\n\n .response-line:hover .line-copy-button {\n opacity: 1;\n }\n\n .line-copy-button:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n\n .line-copy-button.copied {\n background: rgba(40, 167, 69, 0.3);\n }\n\n .line-copy-button svg {\n width: 12px;\n height: 12px;\n stroke: rgba(255, 255, 255, 0.9);\n }\n\n .text-input-container {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n background: rgba(0, 0, 0, 0.1);\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n flex-shrink: 0;\n transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;\n transform-origin: bottom;\n }\n\n .text-input-container.hidden {\n opacity: 0;\n transform: scaleY(0);\n padding: 0;\n height: 0;\n overflow: hidden;\n border-top: none;\n }\n\n .text-input-container.no-response {\n border-top: none;\n }\n\n #textInput {\n flex: 1;\n padding: 10px 14px;\n background: rgba(0, 0, 0, 0.2);\n border-radius: 20px;\n outline: none;\n border: none;\n color: white;\n font-size: 14px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 400;\n }\n\n #textInput::placeholder {\n color: rgba(255, 255, 255, 0.5);\n }\n\n #textInput:focus {\n outline: none;\n }\n\n .response-line h1,\n .response-line h2,\n .response-line h3,\n .response-line h4,\n .response-line h5,\n .response-line h6 {\n color: rgba(255, 255, 255, 0.95);\n margin: 16px 0 8px 0;\n font-weight: 600;\n }\n\n .response-line p {\n margin: 8px 0;\n color: rgba(255, 255, 255, 0.9);\n }\n\n .response-line ul,\n .response-line ol {\n margin: 8px 0;\n padding-left: 20px;\n }\n\n .response-line li {\n margin: 4px 0;\n color: rgba(255, 255, 255, 0.9);\n }\n\n .response-line code {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.95);\n padding: 2px 6px;\n border-radius: 4px;\n font-family: 'Monaco', 'Menlo', monospace;\n font-size: 13px;\n }\n\n .response-line pre {\n background: rgba(255, 255, 255, 0.05);\n color: rgba(255, 255, 255, 0.95);\n padding: 12px;\n border-radius: 6px;\n overflow-x: auto;\n margin: 12px 0;\n border: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .response-line pre code {\n background: none;\n padding: 0;\n }\n\n .response-line blockquote {\n border-left: 3px solid rgba(255, 255, 255, 0.3);\n margin: 12px 0;\n padding: 8px 16px;\n background: rgba(255, 255, 255, 0.05);\n color: rgba(255, 255, 255, 0.8);\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: rgba(255, 255, 255, 0.5);\n font-size: 14px;\n }\n\n .btn-gap {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n gap: 4px;\n }\n\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .ask-container,\n :host-context(body.has-glass) .response-header,\n :host-context(body.has-glass) .response-icon,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .close-button,\n :host-context(body.has-glass) .line-copy-button,\n :host-context(body.has-glass) .text-input-container,\n :host-context(body.has-glass) .response-container pre,\n :host-context(body.has-glass) .response-container p code,\n :host-context(body.has-glass) .response-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .ask-container::before {\n display: none !important;\n }\n\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .close-button:hover,\n :host-context(body.has-glass) .line-copy-button,\n :host-context(body.has-glass) .line-copy-button:hover,\n :host-context(body.has-glass) .response-line:hover {\n background: transparent !important;\n }\n\n :host-context(body.has-glass) .response-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .response-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n\n .submit-btn, .clear-btn {\n display: flex;\n align-items: center;\n background: transparent;\n color: white;\n border: none;\n border-radius: 6px;\n margin-left: 8px;\n font-size: 13px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n overflow: hidden;\n cursor: pointer;\n transition: background 0.15s;\n height: 32px;\n padding: 0 10px;\n box-shadow: none;\n }\n .submit-btn:hover, .clear-btn:hover {\n background: rgba(255,255,255,0.1);\n }\n .btn-label {\n margin-right: 8px;\n display: flex;\n align-items: center;\n height: 100%;\n }\n .btn-icon {\n background: rgba(255,255,255,0.1);\n border-radius: 13%;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n }\n .btn-icon img, .btn-icon svg {\n width: 13px;\n height: 13px;\n display: block;\n }\n .header-clear-btn {\n background: transparent;\n border: none;\n display: flex;\n align-items: center;\n gap: 2px;\n cursor: pointer;\n padding: 0 2px;\n }\n .header-clear-btn .icon-box {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n background-color: rgba(255, 255, 255, 0.1);\n border-radius: 13%;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .header-clear-btn:hover .icon-box {\n background-color: rgba(255,255,255,0.18);\n }\n `;\n\n constructor() {\n super();\n this.currentResponse = '';\n this.currentQuestion = '';\n this.isLoading = false;\n this.copyState = 'idle';\n this.showTextInput = true;\n this.headerText = 'AI Response';\n this.headerAnimating = false;\n this.isStreaming = false;\n\n this.marked = null;\n this.hljs = null;\n this.DOMPurify = null;\n this.isLibrariesLoaded = false;\n\n // SMD.js streaming markdown parser\n this.smdParser = null;\n this.smdContainer = null;\n this.lastProcessedLength = 0;\n\n this.handleSendText = this.handleSendText.bind(this);\n this.handleTextKeydown = this.handleTextKeydown.bind(this);\n this.handleCopy = this.handleCopy.bind(this);\n this.clearResponseContent = this.clearResponseContent.bind(this);\n this.handleEscKey = this.handleEscKey.bind(this);\n this.handleScroll = this.handleScroll.bind(this);\n this.handleCloseAskWindow = this.handleCloseAskWindow.bind(this);\n this.handleCloseIfNoContent = this.handleCloseIfNoContent.bind(this);\n\n this.loadLibraries();\n\n // --- Resize helpers ---\n this.isThrottled = false;\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n console.log('📱 AskView connectedCallback - IPC 이벤트 리스너 설정');\n\n document.addEventListener('keydown', this.handleEscKey);\n\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n const needed = entry.contentRect.height;\n const current = window.innerHeight;\n\n if (needed > current - 4) {\n this.requestWindowResize(Math.ceil(needed));\n }\n }\n });\n\n const container = this.shadowRoot?.querySelector('.ask-container');\n if (container) this.resizeObserver.observe(container);\n\n this.handleQuestionFromAssistant = (event, question) => {\n console.log('AskView: Received question from ListenView:', question);\n this.handleSendText(null, question);\n };\n\n if (window.api) {\n window.api.askView.onShowTextInput(() => {\n console.log('Show text input signal received');\n if (!this.showTextInput) {\n this.showTextInput = true;\n this.updateComplete.then(() => this.focusTextInput());\n } else {\n this.focusTextInput();\n }\n });\n\n window.api.askView.onScrollResponseUp(() => this.handleScroll('up'));\n window.api.askView.onScrollResponseDown(() => this.handleScroll('down'));\n window.api.askView.onAskStateUpdate((event, newState) => {\n this.currentResponse = newState.currentResponse;\n this.currentQuestion = newState.currentQuestion;\n this.isLoading = newState.isLoading;\n this.isStreaming = newState.isStreaming;\n \n const wasHidden = !this.showTextInput;\n this.showTextInput = newState.showTextInput;\n \n if (newState.showTextInput) {\n if (wasHidden) {\n this.updateComplete.then(() => this.focusTextInput());\n } else {\n this.focusTextInput();\n }\n }\n });\n console.log('AskView: IPC 이벤트 리스너 등록 완료');\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n\n console.log('📱 AskView disconnectedCallback - IPC 이벤트 리스너 제거');\n\n document.removeEventListener('keydown', this.handleEscKey);\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n if (this.headerAnimationTimeout) {\n clearTimeout(this.headerAnimationTimeout);\n }\n\n if (this.streamingTimeout) {\n clearTimeout(this.streamingTimeout);\n }\n\n Object.values(this.lineCopyTimeouts).forEach(timeout => clearTimeout(timeout));\n\n if (window.api) {\n window.api.askView.removeOnAskStateUpdate(this.handleAskStateUpdate);\n window.api.askView.removeOnShowTextInput(this.handleShowTextInput);\n window.api.askView.removeOnScrollResponseUp(this.handleScroll);\n window.api.askView.removeOnScrollResponseDown(this.handleScroll);\n console.log('✅ AskView: IPC 이벤트 리스너 제거 필요');\n }\n }\n\n\n async loadLibraries() {\n try {\n if (!window.marked) {\n await this.loadScript('../../assets/marked-4.3.0.min.js');\n }\n\n if (!window.hljs) {\n await this.loadScript('../../assets/highlight-11.9.0.min.js');\n }\n\n if (!window.DOMPurify) {\n await this.loadScript('../../assets/dompurify-3.0.7.min.js');\n }\n\n this.marked = window.marked;\n this.hljs = window.hljs;\n this.DOMPurify = window.DOMPurify;\n\n if (this.marked && this.hljs) {\n this.marked.setOptions({\n highlight: (code, lang) => {\n if (lang && this.hljs.getLanguage(lang)) {\n try {\n return this.hljs.highlight(code, { language: lang }).value;\n } catch (err) {\n console.warn('Highlight error:', err);\n }\n }\n try {\n return this.hljs.highlightAuto(code).value;\n } catch (err) {\n console.warn('Auto highlight error:', err);\n }\n return code;\n },\n breaks: true,\n gfm: true,\n pedantic: false,\n smartypants: false,\n xhtml: false,\n });\n\n this.isLibrariesLoaded = true;\n this.renderContent();\n console.log('Markdown libraries loaded successfully in AskView');\n }\n\n if (this.DOMPurify) {\n this.isDOMPurifyLoaded = true;\n console.log('DOMPurify loaded successfully in AskView');\n }\n } catch (error) {\n console.error('Failed to load libraries in AskView:', error);\n }\n }\n\n handleCloseAskWindow() {\n // this.clearResponseContent();\n window.api.askView.closeAskWindow();\n }\n\n handleCloseIfNoContent() {\n if (!this.currentResponse && !this.isLoading && !this.isStreaming) {\n this.handleCloseAskWindow();\n }\n }\n\n handleEscKey(e) {\n if (e.key === 'Escape') {\n e.preventDefault();\n this.handleCloseIfNoContent();\n }\n }\n\n clearResponseContent() {\n this.currentResponse = '';\n this.currentQuestion = '';\n this.isLoading = false;\n this.isStreaming = false;\n this.headerText = 'AI Response';\n this.showTextInput = true;\n this.lastProcessedLength = 0;\n this.smdParser = null;\n this.smdContainer = null;\n }\n\n handleInputFocus() {\n this.isInputFocused = true;\n }\n\n focusTextInput() {\n requestAnimationFrame(() => {\n const textInput = this.shadowRoot?.getElementById('textInput');\n if (textInput) {\n textInput.focus();\n }\n });\n }\n\n\n loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n parseMarkdown(text) {\n if (!text) return '';\n\n if (!this.isLibrariesLoaded || !this.marked) {\n return text;\n }\n\n try {\n return this.marked(text);\n } catch (error) {\n console.error('Markdown parsing error in AskView:', error);\n return text;\n }\n }\n\n fixIncompleteCodeBlocks(text) {\n if (!text) return text;\n\n const codeBlockMarkers = text.match(/```/g) || [];\n const markerCount = codeBlockMarkers.length;\n\n if (markerCount % 2 === 1) {\n return text + '\\n```';\n }\n\n return text;\n }\n\n handleScroll(direction) {\n const scrollableElement = this.shadowRoot.querySelector('#responseContainer');\n if (scrollableElement) {\n const scrollAmount = 100; // 한 번에 스크롤할 양 (px)\n if (direction === 'up') {\n scrollableElement.scrollTop -= scrollAmount;\n } else {\n scrollableElement.scrollTop += scrollAmount;\n }\n }\n }\n\n\n renderContent() {\n const responseContainer = this.shadowRoot.getElementById('responseContainer');\n if (!responseContainer) return;\n \n // Check loading state\n if (this.isLoading) {\n responseContainer.innerHTML = `\n
\n
\n
\n
\n
`;\n this.resetStreamingParser();\n return;\n }\n \n // If there is no response, show empty state\n if (!this.currentResponse) {\n responseContainer.innerHTML = `
...
`;\n this.resetStreamingParser();\n return;\n }\n \n // Set streaming markdown parser\n this.renderStreamingMarkdown(responseContainer);\n\n // After updating content, recalculate window height\n this.adjustWindowHeightThrottled();\n }\n\n resetStreamingParser() {\n this.smdParser = null;\n this.smdContainer = null;\n this.lastProcessedLength = 0;\n }\n\n renderStreamingMarkdown(responseContainer) {\n try {\n // 파서가 없거나 컨테이너가 변경되었으면 새로 생성\n if (!this.smdParser || this.smdContainer !== responseContainer) {\n this.smdContainer = responseContainer;\n this.smdContainer.innerHTML = '';\n \n // smd.js의 default_renderer 사용\n const renderer = default_renderer(this.smdContainer);\n this.smdParser = parser(renderer);\n this.lastProcessedLength = 0;\n }\n\n // 새로운 텍스트만 처리 (스트리밍 최적화)\n const currentText = this.currentResponse;\n const newText = currentText.slice(this.lastProcessedLength);\n \n if (newText.length > 0) {\n // 새로운 텍스트 청크를 파서에 전달\n parser_write(this.smdParser, newText);\n this.lastProcessedLength = currentText.length;\n }\n\n // 스트리밍이 완료되면 파서 종료\n if (!this.isStreaming && !this.isLoading) {\n parser_end(this.smdParser);\n }\n\n // 코드 하이라이팅 적용\n if (this.hljs) {\n responseContainer.querySelectorAll('pre code').forEach(block => {\n if (!block.hasAttribute('data-highlighted')) {\n this.hljs.highlightElement(block);\n block.setAttribute('data-highlighted', 'true');\n }\n });\n }\n\n // 스크롤을 맨 아래로\n responseContainer.scrollTop = responseContainer.scrollHeight;\n \n } catch (error) {\n console.error('Error rendering streaming markdown:', error);\n // 에러 발생 시 기본 텍스트 렌더링으로 폴백\n this.renderFallbackContent(responseContainer);\n }\n }\n\n renderFallbackContent(responseContainer) {\n const textToRender = this.currentResponse || '';\n \n if (this.isLibrariesLoaded && this.marked && this.DOMPurify) {\n try {\n // 마크다운 파싱\n const parsedHtml = this.marked.parse(textToRender);\n\n // DOMPurify로 정제\n const cleanHtml = this.DOMPurify.sanitize(parsedHtml, {\n ALLOWED_TAGS: [\n 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'br', 'strong', 'b', 'em', 'i',\n 'ul', 'ol', 'li', 'blockquote', 'code', 'pre', 'a', 'img', 'table', 'thead',\n 'tbody', 'tr', 'th', 'td', 'hr', 'sup', 'sub', 'del', 'ins',\n ],\n ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class', 'id', 'target', 'rel'],\n });\n\n responseContainer.innerHTML = cleanHtml;\n\n // 코드 하이라이팅 적용\n if (this.hljs) {\n responseContainer.querySelectorAll('pre code').forEach(block => {\n this.hljs.highlightElement(block);\n });\n }\n } catch (error) {\n console.error('Error in fallback rendering:', error);\n responseContainer.textContent = textToRender;\n }\n } else {\n // 라이브러리가 로드되지 않았을 때 기본 렌더링\n const basicHtml = textToRender\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\\n\\n/g, '

')\n .replace(/\\n/g, '
')\n .replace(/\\*\\*(.*?)\\*\\*/g, '$1')\n .replace(/\\*(.*?)\\*/g, '$1')\n .replace(/`([^`]+)`/g, '$1');\n\n responseContainer.innerHTML = `

${basicHtml}

`;\n }\n }\n\n\n requestWindowResize(targetHeight) {\n if (window.api) {\n window.api.askView.adjustWindowHeight(targetHeight);\n }\n }\n\n animateHeaderText(text) {\n this.headerAnimating = true;\n this.requestUpdate();\n\n setTimeout(() => {\n this.headerText = text;\n this.headerAnimating = false;\n this.requestUpdate();\n }, 150);\n }\n\n startHeaderAnimation() {\n this.animateHeaderText('analyzing screen...');\n\n if (this.headerAnimationTimeout) {\n clearTimeout(this.headerAnimationTimeout);\n }\n\n this.headerAnimationTimeout = setTimeout(() => {\n this.animateHeaderText('thinking...');\n }, 1500);\n }\n\n renderMarkdown(content) {\n if (!content) return '';\n\n if (this.isLibrariesLoaded && this.marked) {\n return this.parseMarkdown(content);\n }\n\n return content\n .replace(/\\*\\*(.*?)\\*\\*/g, '$1')\n .replace(/\\*(.*?)\\*/g, '$1')\n .replace(/`(.*?)`/g, '$1');\n }\n\n fixIncompleteMarkdown(text) {\n if (!text) return text;\n\n // 불완전한 볼드체 처리\n const boldCount = (text.match(/\\*\\*/g) || []).length;\n if (boldCount % 2 === 1) {\n text += '**';\n }\n\n // 불완전한 이탤릭체 처리\n const italicCount = (text.match(/(? closeBrackets) {\n text += ']';\n }\n\n const openParens = (text.match(/\\]\\(/g) || []).length;\n const closeParens = (text.match(/\\)\\s*$/g) || []).length;\n if (openParens > closeParens && text.endsWith('(')) {\n text += ')';\n }\n\n return text;\n }\n\n\n async handleCopy() {\n if (this.copyState === 'copied') return;\n\n let responseToCopy = this.currentResponse;\n\n if (this.isDOMPurifyLoaded && this.DOMPurify) {\n const testHtml = this.renderMarkdown(responseToCopy);\n const sanitized = this.DOMPurify.sanitize(testHtml);\n\n if (this.DOMPurify.removed && this.DOMPurify.removed.length > 0) {\n console.warn('Unsafe content detected, copy blocked');\n return;\n }\n }\n\n const textToCopy = `Question: ${this.currentQuestion}\\n\\nAnswer: ${responseToCopy}`;\n\n try {\n await navigator.clipboard.writeText(textToCopy);\n console.log('Content copied to clipboard');\n\n this.copyState = 'copied';\n this.requestUpdate();\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n this.copyTimeout = setTimeout(() => {\n this.copyState = 'idle';\n this.requestUpdate();\n }, 1500);\n } catch (err) {\n console.error('Failed to copy:', err);\n }\n }\n\n async handleLineCopy(lineIndex) {\n const originalLines = this.currentResponse.split('\\n');\n const lineToCopy = originalLines[lineIndex];\n\n if (!lineToCopy) return;\n\n try {\n await navigator.clipboard.writeText(lineToCopy);\n console.log('Line copied to clipboard');\n\n // '복사됨' 상태로 UI 즉시 업데이트\n this.lineCopyState = { ...this.lineCopyState, [lineIndex]: true };\n this.requestUpdate(); // LitElement에 UI 업데이트 요청\n\n // 기존 타임아웃이 있다면 초기화\n if (this.lineCopyTimeouts && this.lineCopyTimeouts[lineIndex]) {\n clearTimeout(this.lineCopyTimeouts[lineIndex]);\n }\n\n // ✨ 수정된 타임아웃: 1.5초 후 '복사됨' 상태 해제\n this.lineCopyTimeouts[lineIndex] = setTimeout(() => {\n const updatedState = { ...this.lineCopyState };\n delete updatedState[lineIndex];\n this.lineCopyState = updatedState;\n this.requestUpdate(); // UI 업데이트 요청\n }, 1500);\n } catch (err) {\n console.error('Failed to copy line:', err);\n }\n }\n\n async handleSendText(e, overridingText = '') {\n const textInput = this.shadowRoot?.getElementById('textInput');\n const text = (overridingText || textInput?.value || '').trim();\n // if (!text) return;\n\n textInput.value = '';\n\n if (window.api) {\n window.api.askView.sendMessage(text).catch(error => {\n console.error('Error sending text:', error);\n });\n }\n }\n\n handleTextKeydown(e) {\n // Fix for IME composition issue: Ignore Enter key presses while composing.\n if (e.isComposing) {\n return;\n }\n\n const isPlainEnter = e.key === 'Enter' && !e.shiftKey && !e.metaKey && !e.ctrlKey;\n const isModifierEnter = e.key === 'Enter' && (e.metaKey || e.ctrlKey);\n\n if (isPlainEnter || isModifierEnter) {\n e.preventDefault();\n this.handleSendText();\n }\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n \n // ✨ isLoading 또는 currentResponse가 변경될 때마다 뷰를 다시 그립니다.\n if (changedProperties.has('isLoading') || changedProperties.has('currentResponse')) {\n this.renderContent();\n }\n \n if (changedProperties.has('showTextInput') || changedProperties.has('isLoading') || changedProperties.has('currentResponse')) {\n this.adjustWindowHeightThrottled();\n }\n \n if (changedProperties.has('showTextInput') && this.showTextInput) {\n this.focusTextInput();\n }\n }\n\n firstUpdated() {\n setTimeout(() => this.adjustWindowHeight(), 200);\n }\n\n\n getTruncatedQuestion(question, maxLength = 30) {\n if (!question) return '';\n if (question.length <= maxLength) return question;\n return question.substring(0, maxLength) + '...';\n }\n\n\n\n render() {\n const hasResponse = this.isLoading || this.currentResponse || this.isStreaming;\n const headerText = this.isLoading ? 'Thinking...' : 'AI Response';\n\n return html`\n
\n \n
\n
\n
\n \n \n \n \n
\n ${headerText}\n
\n
\n ${this.getTruncatedQuestion(this.currentQuestion)}\n
\n \n \n
\n
\n
\n\n \n
\n \n
\n\n \n
\n \n \n Submit\n \n ↵\n \n \n
\n
\n `;\n }\n\n // Dynamically resize the BrowserWindow to fit current content\n adjustWindowHeight() {\n if (!window.api) return;\n\n this.updateComplete.then(() => {\n const headerEl = this.shadowRoot.querySelector('.response-header');\n const responseEl = this.shadowRoot.querySelector('.response-container');\n const inputEl = this.shadowRoot.querySelector('.text-input-container');\n\n if (!headerEl || !responseEl) return;\n\n const headerHeight = headerEl.classList.contains('hidden') ? 0 : headerEl.offsetHeight;\n const responseHeight = responseEl.scrollHeight;\n const inputHeight = (inputEl && !inputEl.classList.contains('hidden')) ? inputEl.offsetHeight : 0;\n\n const idealHeight = headerHeight + responseHeight + inputHeight;\n\n const targetHeight = Math.min(700, idealHeight);\n\n window.api.askView.adjustWindowHeight(\"ask\", targetHeight);\n\n }).catch(err => console.error('AskView adjustWindowHeight error:', err));\n }\n\n // Throttled wrapper to avoid excessive IPC spam (executes at most once per animation frame)\n adjustWindowHeightThrottled() {\n if (this.isThrottled) return;\n\n this.isThrottled = true;\n requestAnimationFrame(() => {\n this.adjustWindowHeight();\n this.isThrottled = false;\n });\n }\n}\n\ncustomElements.define('ask-view', AskView);\n"], ["/glass/src/ui/app/MainHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class MainHeader extends LitElement {\n static properties = {\n isTogglingSession: { type: Boolean, state: true },\n shortcuts: { type: Object, state: true },\n listenSessionStatus: { type: String, state: true },\n };\n\n static styles = css`\n :host {\n display: flex;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.sliding-in) {\n animation: fadeIn 0.2s ease-out forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n .header {\n -webkit-app-region: drag;\n width: max-content;\n height: 47px;\n padding: 2px 10px 2px 13px;\n background: transparent;\n overflow: hidden;\n border-radius: 9000px;\n /* backdrop-filter: blur(1px); */\n justify-content: space-between;\n align-items: center;\n display: inline-flex;\n box-sizing: border-box;\n position: relative;\n }\n\n .header::before {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n border-radius: 9000px;\n z-index: -1;\n }\n\n .header::after {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n border-radius: 9000px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%); \n -webkit-mask:\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .listen-button {\n -webkit-app-region: no-drag;\n height: 26px;\n padding: 0 13px;\n background: transparent;\n border-radius: 9000px;\n justify-content: center;\n width: 78px;\n align-items: center;\n gap: 6px;\n display: flex;\n border: none;\n cursor: pointer;\n position: relative;\n }\n\n .listen-button:disabled {\n cursor: default;\n opacity: 0.8;\n }\n\n .listen-button.active::before {\n background: rgba(215, 0, 0, 0.5);\n }\n\n .listen-button.active:hover::before {\n background: rgba(255, 20, 20, 0.6);\n }\n\n .listen-button.done {\n background-color: rgba(255, 255, 255, 0.6);\n transition: background-color 0.15s ease;\n }\n\n .listen-button.done .action-text-content {\n color: black;\n }\n \n .listen-button.done .listen-icon svg rect,\n .listen-button.done .listen-icon svg path {\n fill: black;\n }\n\n .listen-button.done:hover {\n background-color: #f0f0f0;\n }\n\n .listen-button:hover::before {\n background: rgba(255, 255, 255, 0.18);\n }\n\n .listen-button::before {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n background: rgba(255, 255, 255, 0.14);\n border-radius: 9000px;\n z-index: -1;\n transition: background 0.15s ease;\n }\n\n .listen-button::after {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n border-radius: 9000px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%);\n -webkit-mask:\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .listen-button.done::after {\n display: none;\n }\n\n .loading-dots {\n display: flex;\n align-items: center;\n gap: 5px;\n }\n\n .loading-dots span {\n width: 6px;\n height: 6px;\n background-color: white;\n border-radius: 50%;\n animation: pulse 1.4s infinite ease-in-out both;\n }\n .loading-dots span:nth-of-type(1) {\n animation-delay: -0.32s;\n }\n .loading-dots span:nth-of-type(2) {\n animation-delay: -0.16s;\n }\n @keyframes pulse {\n 0%, 80%, 100% {\n opacity: 0.2;\n }\n 40% {\n opacity: 1.0;\n }\n }\n\n .header-actions {\n -webkit-app-region: no-drag;\n height: 26px;\n box-sizing: border-box;\n justify-content: flex-start;\n align-items: center;\n gap: 9px;\n display: flex;\n padding: 0 8px;\n border-radius: 6px;\n transition: background 0.15s ease;\n }\n\n .header-actions:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .ask-action {\n margin-left: 4px;\n }\n\n .action-button,\n .action-text {\n padding-bottom: 1px;\n justify-content: center;\n align-items: center;\n gap: 10px;\n display: flex;\n }\n\n .action-text-content {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500; /* Medium */\n word-wrap: break-word;\n }\n\n .icon-container {\n justify-content: flex-start;\n align-items: center;\n gap: 4px;\n display: flex;\n }\n\n .icon-container.ask-icons svg,\n .icon-container.showhide-icons svg {\n width: 12px;\n height: 12px;\n }\n\n .listen-icon svg {\n width: 12px;\n height: 11px;\n position: relative;\n top: 1px;\n }\n\n .icon-box {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n background-color: rgba(255, 255, 255, 0.1);\n border-radius: 13%;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .settings-button {\n -webkit-app-region: no-drag;\n padding: 5px;\n border-radius: 50%;\n background: transparent;\n transition: background 0.15s ease;\n color: white;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n .settings-button:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .settings-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 3px;\n }\n\n .settings-icon svg {\n width: 16px;\n height: 16px;\n }\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .header,\n :host-context(body.has-glass) .listen-button,\n :host-context(body.has-glass) .header-actions,\n :host-context(body.has-glass) .settings-button {\n background: transparent !important;\n filter: none !important;\n box-shadow: none !important;\n backdrop-filter: none !important;\n }\n :host-context(body.has-glass) .icon-box {\n background: transparent !important;\n border: none !important;\n }\n\n :host-context(body.has-glass) .header::before,\n :host-context(body.has-glass) .header::after,\n :host-context(body.has-glass) .listen-button::before,\n :host-context(body.has-glass) .listen-button::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .header-actions:hover,\n :host-context(body.has-glass) .settings-button:hover,\n :host-context(body.has-glass) .listen-button:hover::before {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .header,\n :host-context(body.has-glass) .listen-button,\n :host-context(body.has-glass) .header-actions,\n :host-context(body.has-glass) .settings-button,\n :host-context(body.has-glass) .icon-box {\n border-radius: 0 !important;\n }\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n `;\n\n constructor() {\n super();\n this.shortcuts = {};\n this.isVisible = true;\n this.isAnimating = false;\n this.hasSlidIn = false;\n this.settingsHideTimer = null;\n this.isTogglingSession = false;\n this.listenSessionStatus = 'beforeSession';\n this.animationEndTimer = null;\n this.handleAnimationEnd = this.handleAnimationEnd.bind(this);\n this.handleMouseMove = this.handleMouseMove.bind(this);\n this.handleMouseUp = this.handleMouseUp.bind(this);\n this.dragState = null;\n this.wasJustDragged = false;\n }\n\n _getListenButtonText(status) {\n switch (status) {\n case 'beforeSession': return 'Listen';\n case 'inSession' : return 'Stop';\n case 'afterSession': return 'Done';\n default : return 'Listen';\n }\n }\n\n async handleMouseDown(e) {\n e.preventDefault();\n\n const initialPosition = await window.api.mainHeader.getHeaderPosition();\n\n this.dragState = {\n initialMouseX: e.screenX,\n initialMouseY: e.screenY,\n initialWindowX: initialPosition.x,\n initialWindowY: initialPosition.y,\n moved: false,\n };\n\n window.addEventListener('mousemove', this.handleMouseMove, { capture: true });\n window.addEventListener('mouseup', this.handleMouseUp, { once: true, capture: true });\n }\n\n handleMouseMove(e) {\n if (!this.dragState) return;\n\n const deltaX = Math.abs(e.screenX - this.dragState.initialMouseX);\n const deltaY = Math.abs(e.screenY - this.dragState.initialMouseY);\n \n if (deltaX > 3 || deltaY > 3) {\n this.dragState.moved = true;\n }\n\n const newWindowX = this.dragState.initialWindowX + (e.screenX - this.dragState.initialMouseX);\n const newWindowY = this.dragState.initialWindowY + (e.screenY - this.dragState.initialMouseY);\n\n window.api.mainHeader.moveHeaderTo(newWindowX, newWindowY);\n }\n\n handleMouseUp(e) {\n if (!this.dragState) return;\n\n const wasDragged = this.dragState.moved;\n\n window.removeEventListener('mousemove', this.handleMouseMove, { capture: true });\n this.dragState = null;\n\n if (wasDragged) {\n this.wasJustDragged = true;\n setTimeout(() => {\n this.wasJustDragged = false;\n }, 0);\n }\n }\n\n toggleVisibility() {\n if (this.isAnimating) {\n console.log('[MainHeader] Animation already in progress, ignoring toggle');\n return;\n }\n \n if (this.animationEndTimer) {\n clearTimeout(this.animationEndTimer);\n this.animationEndTimer = null;\n }\n \n this.isAnimating = true;\n \n if (this.isVisible) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n hide() {\n this.classList.remove('showing');\n this.classList.add('hiding');\n }\n \n show() {\n this.classList.remove('hiding', 'hidden');\n this.classList.add('showing');\n }\n \n handleAnimationEnd(e) {\n if (e.target !== this) return;\n \n this.isAnimating = false;\n \n if (this.classList.contains('hiding')) {\n this.classList.add('hidden');\n if (window.api) {\n window.api.mainHeader.sendHeaderAnimationFinished('hidden');\n }\n } else if (this.classList.contains('showing')) {\n if (window.api) {\n window.api.mainHeader.sendHeaderAnimationFinished('visible');\n }\n }\n }\n\n startSlideInAnimation() {\n if (this.hasSlidIn) return;\n this.classList.add('sliding-in');\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('animationend', this.handleAnimationEnd);\n\n if (window.api) {\n\n this._sessionStateTextListener = (event, { success }) => {\n if (success) {\n this.listenSessionStatus = ({\n beforeSession: 'inSession',\n inSession: 'afterSession',\n afterSession: 'beforeSession',\n })[this.listenSessionStatus] || 'beforeSession';\n } else {\n this.listenSessionStatus = 'beforeSession';\n }\n this.isTogglingSession = false; // ✨ 로딩 상태만 해제\n };\n window.api.mainHeader.onListenChangeSessionResult(this._sessionStateTextListener);\n\n this._shortcutListener = (event, keybinds) => {\n console.log('[MainHeader] Received updated shortcuts:', keybinds);\n this.shortcuts = keybinds;\n };\n window.api.mainHeader.onShortcutsUpdated(this._shortcutListener);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('animationend', this.handleAnimationEnd);\n \n if (this.animationEndTimer) {\n clearTimeout(this.animationEndTimer);\n this.animationEndTimer = null;\n }\n \n if (window.api) {\n if (this._sessionStateTextListener) {\n window.api.mainHeader.removeOnListenChangeSessionResult(this._sessionStateTextListener);\n }\n if (this._shortcutListener) {\n window.api.mainHeader.removeOnShortcutsUpdated(this._shortcutListener);\n }\n }\n }\n\n showSettingsWindow(element) {\n if (this.wasJustDragged) return;\n if (window.api) {\n console.log(`[MainHeader] showSettingsWindow called at ${Date.now()}`);\n window.api.mainHeader.showSettingsWindow();\n\n }\n }\n\n hideSettingsWindow() {\n if (this.wasJustDragged) return;\n if (window.api) {\n console.log(`[MainHeader] hideSettingsWindow called at ${Date.now()}`);\n window.api.mainHeader.hideSettingsWindow();\n }\n }\n\n async _handleListenClick() {\n if (this.wasJustDragged) return;\n if (this.isTogglingSession) {\n return;\n }\n\n this.isTogglingSession = true;\n\n try {\n const listenButtonText = this._getListenButtonText(this.listenSessionStatus);\n if (window.api) {\n await window.api.mainHeader.sendListenButtonClick(listenButtonText);\n }\n } catch (error) {\n console.error('IPC invoke for session change failed:', error);\n this.isTogglingSession = false;\n }\n }\n\n async _handleAskClick() {\n if (this.wasJustDragged) return;\n\n try {\n if (window.api) {\n await window.api.mainHeader.sendAskButtonClick();\n }\n } catch (error) {\n console.error('IPC invoke for ask button failed:', error);\n }\n }\n\n async _handleToggleAllWindowsVisibility() {\n if (this.wasJustDragged) return;\n\n try {\n if (window.api) {\n await window.api.mainHeader.sendToggleAllWindowsVisibility();\n }\n } catch (error) {\n console.error('IPC invoke for all windows visibility button failed:', error);\n }\n }\n\n\n renderShortcut(accelerator) {\n if (!accelerator) return html``;\n\n const keyMap = {\n 'Cmd': '⌘', 'Command': '⌘',\n 'Ctrl': '⌃', 'Control': '⌃',\n 'Alt': '⌥', 'Option': '⌥',\n 'Shift': '⇧',\n 'Enter': '↵',\n 'Backspace': '⌫',\n 'Delete': '⌦',\n 'Tab': '⇥',\n 'Escape': '⎋',\n 'Up': '↑', 'Down': '↓', 'Left': '←', 'Right': '→',\n '\\\\': html``,\n };\n\n const keys = accelerator.split('+');\n return html`${keys.map(key => html`\n
${keyMap[key] || key}
\n `)}`;\n }\n\n render() {\n const listenButtonText = this._getListenButtonText(this.listenSessionStatus);\n \n const buttonClasses = {\n active: listenButtonText === 'Stop',\n done: listenButtonText === 'Done',\n };\n const showStopIcon = listenButtonText === 'Stop' || listenButtonText === 'Done';\n\n return html`\n
\n \n\n
this._handleAskClick()}>\n
\n
Ask
\n
\n
\n ${this.renderShortcut(this.shortcuts.nextStep)}\n
\n
\n\n
this._handleToggleAllWindowsVisibility()}>\n
\n
Show/Hide
\n
\n
\n ${this.renderShortcut(this.shortcuts.toggleVisibility)}\n
\n
\n\n \n
\n `;\n }\n}\n\ncustomElements.define('main-header', MainHeader);\n"], ["/glass/src/ui/app/PermissionHeader.js", "import { LitElement, html, css } from '../assets/lit-core-2.7.4.min.js';\n\nexport class PermissionHeader extends LitElement {\n static styles = css`\n :host {\n display: block;\n transition: opacity 0.3s ease-in, transform 0.3s ease-in;\n will-change: opacity, transform;\n }\n\n :host(.sliding-out) {\n opacity: 0;\n transform: translateY(-20px);\n }\n\n :host(.hidden) {\n opacity: 0;\n pointer-events: none;\n }\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n box-sizing: border-box;\n }\n\n .container {\n -webkit-app-region: drag;\n width: 285px;\n /* height is now set dynamically */\n padding: 18px 20px;\n background: rgba(0, 0, 0, 0.3);\n border-radius: 16px;\n overflow: hidden;\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .container::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 16px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 10px;\n right: 10px;\n width: 14px;\n height: 14px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 3px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 14px;\n line-height: 1;\n padding: 0;\n }\n\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n\n .close-button:active {\n transform: scale(0.95);\n }\n\n .title {\n color: white;\n font-size: 16px;\n font-weight: 500;\n margin: 0;\n text-align: center;\n flex-shrink: 0;\n }\n\n .form-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 100%;\n margin-top: auto;\n }\n\n .form-content.all-granted {\n flex-grow: 1;\n justify-content: center;\n margin-top: 0;\n }\n\n .subtitle {\n color: rgba(255, 255, 255, 0.7);\n font-size: 11px;\n font-weight: 400;\n text-align: center;\n margin-bottom: 12px;\n line-height: 1.3;\n }\n\n .permission-status {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-bottom: 12px;\n min-height: 20px;\n }\n\n .permission-item {\n display: flex;\n align-items: center;\n gap: 6px;\n color: rgba(255, 255, 255, 0.8);\n font-size: 11px;\n font-weight: 400;\n }\n\n .permission-item.granted {\n color: rgba(34, 197, 94, 0.9);\n }\n\n .permission-icon {\n width: 12px;\n height: 12px;\n opacity: 0.8;\n }\n\n .check-icon {\n width: 12px;\n height: 12px;\n color: rgba(34, 197, 94, 0.9);\n }\n\n .action-button {\n -webkit-app-region: no-drag;\n width: 100%;\n height: 34px;\n background: rgba(255, 255, 255, 0.2);\n border: none;\n border-radius: 10px;\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s ease;\n position: relative;\n overflow: hidden;\n margin-bottom: 6px;\n }\n\n .action-button::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 10px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .action-button:hover:not(:disabled) {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .action-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .continue-button {\n -webkit-app-region: no-drag;\n width: 100%;\n height: 34px;\n background: rgba(34, 197, 94, 0.8);\n border: none;\n border-radius: 10px;\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s ease;\n position: relative;\n overflow: hidden;\n margin-top: 4px;\n }\n\n .continue-button::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 10px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .continue-button:hover:not(:disabled) {\n background: rgba(34, 197, 94, 0.9);\n }\n\n .continue-button:disabled {\n background: rgba(255, 255, 255, 0.2);\n cursor: not-allowed;\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .container,\n :host-context(body.has-glass) .action-button,\n :host-context(body.has-glass) .continue-button,\n :host-context(body.has-glass) .close-button {\n background: transparent !important;\n border: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .container::after,\n :host-context(body.has-glass) .action-button::after,\n :host-context(body.has-glass) .continue-button::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .action-button:hover,\n :host-context(body.has-glass) .continue-button:hover,\n :host-context(body.has-glass) .close-button:hover {\n background: transparent !important;\n }\n `;\n\n static properties = {\n microphoneGranted: { type: String },\n screenGranted: { type: String },\n keychainGranted: { type: String },\n isChecking: { type: String },\n continueCallback: { type: Function },\n userMode: { type: String }, // 'local' or 'firebase'\n };\n\n constructor() {\n super();\n this.microphoneGranted = 'unknown';\n this.screenGranted = 'unknown';\n this.keychainGranted = 'unknown';\n this.isChecking = false;\n this.continueCallback = null;\n this.userMode = 'local'; // Default to local\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n if (changedProperties.has('userMode')) {\n const newHeight = this.userMode === 'firebase' ? 280 : 220;\n console.log(`[PermissionHeader] User mode changed to ${this.userMode}, requesting resize to ${newHeight}px`);\n this.dispatchEvent(new CustomEvent('request-resize', {\n detail: { height: newHeight },\n bubbles: true,\n composed: true\n }));\n }\n }\n\n async connectedCallback() {\n super.connectedCallback();\n\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n this.userMode = userState.mode;\n } catch (e) {\n console.error('[PermissionHeader] Failed to get user state', e);\n this.userMode = 'local'; // Fallback to local\n }\n }\n\n await this.checkPermissions();\n \n // Set up periodic permission check\n this.permissionCheckInterval = setInterval(async () => {\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n this.userMode = userState.mode;\n } catch (e) {\n this.userMode = 'local';\n }\n }\n this.checkPermissions();\n }, 1000);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.permissionCheckInterval) {\n clearInterval(this.permissionCheckInterval);\n }\n }\n\n async checkPermissions() {\n if (!window.api || this.isChecking) return;\n \n this.isChecking = true;\n \n try {\n const permissions = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Permission check result:', permissions);\n \n const prevMic = this.microphoneGranted;\n const prevScreen = this.screenGranted;\n const prevKeychain = this.keychainGranted;\n \n this.microphoneGranted = permissions.microphone;\n this.screenGranted = permissions.screen;\n this.keychainGranted = permissions.keychain;\n \n // if permissions changed == UI update\n if (prevMic !== this.microphoneGranted || prevScreen !== this.screenGranted || prevKeychain !== this.keychainGranted) {\n console.log('[PermissionHeader] Permission status changed, updating UI');\n this.requestUpdate();\n }\n\n const isKeychainRequired = this.userMode === 'firebase';\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n \n // if all permissions granted == automatically continue\n if (this.microphoneGranted === 'granted' && \n this.screenGranted === 'granted' && \n keychainOk && \n this.continueCallback) {\n console.log('[PermissionHeader] All permissions granted, proceeding automatically');\n setTimeout(() => this.handleContinue(), 500);\n }\n } catch (error) {\n console.error('[PermissionHeader] Error checking permissions:', error);\n } finally {\n this.isChecking = false;\n }\n }\n\n async handleMicrophoneClick() {\n if (!window.api || this.microphoneGranted === 'granted') return;\n \n console.log('[PermissionHeader] Requesting microphone permission...');\n \n try {\n const result = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Microphone permission result:', result);\n \n if (result.microphone === 'granted') {\n this.microphoneGranted = 'granted';\n this.requestUpdate();\n return;\n }\n \n if (result.microphone === 'not-determined' || result.microphone === 'denied' || result.microphone === 'unknown' || result.microphone === 'restricted') {\n const res = await window.api.permissionHeader.requestMicrophonePermission();\n if (res.status === 'granted' || res.success === true) {\n this.microphoneGranted = 'granted';\n this.requestUpdate();\n return;\n }\n }\n \n \n // Check permissions again after a delay\n // setTimeout(() => this.checkPermissions(), 1000);\n } catch (error) {\n console.error('[PermissionHeader] Error requesting microphone permission:', error);\n }\n }\n\n async handleScreenClick() {\n if (!window.api || this.screenGranted === 'granted') return;\n \n console.log('[PermissionHeader] Checking screen recording permission...');\n \n try {\n const permissions = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Screen permission check result:', permissions);\n \n if (permissions.screen === 'granted') {\n this.screenGranted = 'granted';\n this.requestUpdate();\n return;\n }\n if (permissions.screen === 'not-determined' || permissions.screen === 'denied' || permissions.screen === 'unknown' || permissions.screen === 'restricted') {\n console.log('[PermissionHeader] Opening screen recording preferences...');\n await window.api.permissionHeader.openSystemPreferences('screen-recording');\n }\n \n // Check permissions again after a delay\n // (This may not execute if app restarts after permission grant)\n // setTimeout(() => this.checkPermissions(), 2000);\n } catch (error) {\n console.error('[PermissionHeader] Error opening screen recording preferences:', error);\n }\n }\n\n async handleKeychainClick() {\n if (!window.api || this.keychainGranted === 'granted') return;\n \n console.log('[PermissionHeader] Requesting keychain permission...');\n \n try {\n // Trigger initializeKey to prompt for keychain access\n // Assuming encryptionService is accessible or via API\n await window.api.permissionHeader.initializeEncryptionKey(); // New IPC handler needed\n \n // After success, update status\n this.keychainGranted = 'granted';\n this.requestUpdate();\n } catch (error) {\n console.error('[PermissionHeader] Error requesting keychain permission:', error);\n }\n }\n\n async handleContinue() {\n const isKeychainRequired = this.userMode === 'firebase';\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n\n if (this.continueCallback && \n this.microphoneGranted === 'granted' && \n this.screenGranted === 'granted' && \n keychainOk) {\n // Mark permissions as completed\n if (window.api && isKeychainRequired) {\n try {\n await window.api.permissionHeader.markKeychainCompleted();\n console.log('[PermissionHeader] Marked keychain as completed');\n } catch (error) {\n console.error('[PermissionHeader] Error marking keychain as completed:', error);\n }\n }\n \n this.continueCallback();\n }\n }\n\n handleClose() {\n console.log('Close button clicked');\n if (window.api) {\n window.api.common.quitApplication();\n }\n }\n\n render() {\n const isKeychainRequired = this.userMode === 'firebase';\n const containerHeight = isKeychainRequired ? 280 : 220;\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n const allGranted = this.microphoneGranted === 'granted' && this.screenGranted === 'granted' && keychainOk;\n\n return html`\n
\n \n

Permission Setup Required

\n\n
\n ${!allGranted ? html`\n
Grant access to microphone, screen recording${isKeychainRequired ? ' and keychain' : ''} to continue
\n \n
\n
\n ${this.microphoneGranted === 'granted' ? html`\n \n \n \n Microphone ✓\n ` : html`\n \n \n \n Microphone\n `}\n
\n \n
\n ${this.screenGranted === 'granted' ? html`\n \n \n \n Screen ✓\n ` : html`\n \n \n \n Screen Recording\n `}\n
\n\n ${isKeychainRequired ? html`\n
\n ${this.keychainGranted === 'granted' ? html`\n \n \n \n Data Encryption ✓\n ` : html`\n \n \n \n Data Encryption\n `}\n
\n ` : ''}\n
\n\n \n\n \n\n ${isKeychainRequired ? html`\n \n
\n Stores the key to encrypt your data. Press \"Always Allow\" to continue.\n
\n ` : ''}\n ` : html`\n \n `}\n
\n
\n `;\n }\n}\n\ncustomElements.define('permission-setup', PermissionHeader); "], ["/glass/src/ui/settings/SettingsView.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n// import { getOllamaProgressTracker } from '../../features/common/services/localProgressTracker.js'; // 제거됨\n\nexport class SettingsView extends LitElement {\n static styles = css`\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n :host {\n display: block;\n width: 240px;\n height: 100%;\n color: white;\n }\n\n .settings-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: rgba(20, 20, 20, 0.8);\n border-radius: 12px;\n outline: 0.5px rgba(255, 255, 255, 0.2) solid;\n outline-offset: -1px;\n box-sizing: border-box;\n position: relative;\n overflow-y: auto;\n padding: 12px 12px;\n z-index: 1000;\n }\n\n .settings-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .settings-container::-webkit-scrollbar-track {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n }\n\n .settings-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n }\n\n .settings-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .settings-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n filter: blur(10px);\n z-index: -1;\n }\n \n .settings-button[disabled],\n .api-key-section input[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .header-section {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n padding-bottom: 6px;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n position: relative;\n z-index: 1;\n }\n\n .title-line {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .app-title {\n font-size: 13px;\n font-weight: 500;\n color: white;\n margin: 0 0 4px 0;\n }\n\n .account-info {\n font-size: 11px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n }\n\n .invisibility-icon {\n padding-top: 2px;\n opacity: 0;\n transition: opacity 0.3s ease;\n }\n\n .invisibility-icon.visible {\n opacity: 1;\n }\n\n .invisibility-icon svg {\n width: 16px;\n height: 16px;\n }\n\n .shortcuts-section {\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: 4px 0;\n position: relative;\n z-index: 1;\n }\n\n .shortcut-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 0;\n color: white;\n font-size: 11px;\n }\n\n .shortcut-name {\n font-weight: 300;\n }\n\n .shortcut-keys {\n display: flex;\n align-items: center;\n gap: 3px;\n }\n\n .cmd-key, .shortcut-key {\n background: rgba(255, 255, 255, 0.1);\n border-radius: 3px;\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 11px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.9);\n }\n\n /* Buttons Section */\n .buttons-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n padding-top: 6px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n position: relative;\n z-index: 1;\n flex: 1;\n }\n\n .settings-button {\n background: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-radius: 4px;\n color: white;\n padding: 5px 10px;\n font-size: 11px;\n font-weight: 400;\n cursor: pointer;\n transition: all 0.15s ease;\n display: flex;\n align-items: center;\n justify-content: center;\n white-space: nowrap;\n }\n\n .settings-button:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .settings-button:active {\n transform: translateY(1px);\n }\n\n .settings-button.full-width {\n width: 100%;\n }\n\n .settings-button.half-width {\n flex: 1;\n }\n\n .settings-button.danger {\n background: rgba(255, 59, 48, 0.1);\n border-color: rgba(255, 59, 48, 0.3);\n color: rgba(255, 59, 48, 0.9);\n }\n\n .settings-button.danger:hover {\n background: rgba(255, 59, 48, 0.15);\n border-color: rgba(255, 59, 48, 0.4);\n }\n\n .move-buttons, .bottom-buttons {\n display: flex;\n gap: 4px;\n }\n\n .api-key-section {\n padding: 6px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .api-key-section input {\n width: 100%;\n background: rgba(0,0,0,0.2);\n border: 1px solid rgba(255,255,255,0.2);\n color: white;\n border-radius: 4px;\n padding: 4px;\n font-size: 11px;\n margin-bottom: 4px;\n box-sizing: border-box;\n }\n\n .api-key-section input::placeholder {\n color: rgba(255, 255, 255, 0.4);\n }\n\n /* Preset Management Section */\n .preset-section {\n padding: 6px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .preset-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 4px;\n }\n\n .preset-title {\n font-size: 11px;\n font-weight: 500;\n color: white;\n }\n\n .preset-count {\n font-size: 9px;\n color: rgba(255, 255, 255, 0.5);\n margin-left: 4px;\n }\n\n .preset-toggle {\n font-size: 10px;\n color: rgba(255, 255, 255, 0.6);\n cursor: pointer;\n padding: 2px 4px;\n border-radius: 2px;\n transition: background-color 0.15s ease;\n }\n\n .preset-toggle:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .preset-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n max-height: 120px;\n overflow-y: auto;\n }\n\n .preset-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 6px;\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n cursor: pointer;\n transition: all 0.15s ease;\n font-size: 11px;\n border: 1px solid transparent;\n }\n\n .preset-item:hover {\n background: rgba(255, 255, 255, 0.1);\n border-color: rgba(255, 255, 255, 0.1);\n }\n\n .preset-item.selected {\n background: rgba(0, 122, 255, 0.25);\n border-color: rgba(0, 122, 255, 0.6);\n box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.3);\n }\n\n .preset-name {\n color: white;\n flex: 1;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n font-weight: 300;\n }\n\n .preset-item.selected .preset-name {\n font-weight: 500;\n }\n\n .preset-status {\n font-size: 9px;\n color: rgba(0, 122, 255, 0.8);\n font-weight: 500;\n margin-left: 6px;\n }\n\n .no-presets-message {\n padding: 12px 8px;\n text-align: center;\n color: rgba(255, 255, 255, 0.5);\n font-size: 10px;\n line-height: 1.4;\n }\n\n .no-presets-message .web-link {\n color: rgba(0, 122, 255, 0.8);\n text-decoration: underline;\n cursor: pointer;\n }\n\n .no-presets-message .web-link:hover {\n color: rgba(0, 122, 255, 1);\n }\n\n .loading-state {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n color: rgba(255, 255, 255, 0.7);\n font-size: 11px;\n }\n\n .loading-spinner {\n width: 12px;\n height: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-top: 1px solid rgba(255, 255, 255, 0.8);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin-right: 6px;\n }\n\n .hidden {\n display: none;\n }\n\n .api-key-section, .model-selection-section {\n padding: 8px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .provider-key-group, .model-select-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n label {\n font-size: 11px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.8);\n margin-left: 2px;\n }\n label > strong {\n color: white;\n font-weight: 600;\n }\n .provider-key-group input {\n width: 100%; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.2);\n color: white; border-radius: 4px; padding: 5px 8px; font-size: 11px; box-sizing: border-box;\n }\n .key-buttons { display: flex; gap: 4px; }\n .key-buttons .settings-button { flex: 1; padding: 4px; }\n .model-list {\n display: flex; flex-direction: column; gap: 2px; max-height: 120px;\n overflow-y: auto; background: rgba(0,0,0,0.3); border-radius: 4px;\n padding: 4px; margin-top: 4px;\n }\n .model-item { \n padding: 5px 8px; \n font-size: 11px; \n border-radius: 3px; \n cursor: pointer; \n transition: background-color 0.15s; \n display: flex; \n justify-content: space-between; \n align-items: center; \n }\n .model-item:hover { background-color: rgba(255,255,255,0.1); }\n .model-item.selected { background-color: rgba(0, 122, 255, 0.4); font-weight: 500; }\n .model-status { \n font-size: 9px; \n color: rgba(255,255,255,0.6); \n margin-left: 8px; \n }\n .model-status.installed { color: rgba(0, 255, 0, 0.8); }\n .model-status.not-installed { color: rgba(255, 200, 0, 0.8); }\n .install-progress {\n flex: 1;\n height: 4px;\n background: rgba(255,255,255,0.1);\n border-radius: 2px;\n margin-left: 8px;\n overflow: hidden;\n }\n .install-progress-bar {\n height: 100%;\n background: rgba(0, 122, 255, 0.8);\n transition: width 0.3s ease;\n }\n \n /* Dropdown styles */\n select.model-dropdown {\n background: rgba(0,0,0,0.2);\n color: white;\n cursor: pointer;\n }\n \n select.model-dropdown option {\n background: #1a1a1a;\n color: white;\n }\n \n select.model-dropdown option:disabled {\n color: rgba(255,255,255,0.4);\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n\n :host-context(body.has-glass) * {\n background: transparent !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n outline: none !important;\n border: none !important;\n border-radius: 0 !important;\n transition: none !important;\n animation: none !important;\n }\n\n :host-context(body.has-glass) .settings-container::before {\n display: none !important;\n }\n `;\n\n\n //////// after_modelStateService ////////\n static properties = {\n shortcuts: { type: Object, state: true },\n firebaseUser: { type: Object, state: true },\n isLoading: { type: Boolean, state: true },\n isContentProtectionOn: { type: Boolean, state: true },\n saving: { type: Boolean, state: true },\n providerConfig: { type: Object, state: true },\n apiKeys: { type: Object, state: true },\n availableLlmModels: { type: Array, state: true },\n availableSttModels: { type: Array, state: true },\n selectedLlm: { type: String, state: true },\n selectedStt: { type: String, state: true },\n isLlmListVisible: { type: Boolean },\n isSttListVisible: { type: Boolean },\n presets: { type: Array, state: true },\n selectedPreset: { type: Object, state: true },\n showPresets: { type: Boolean, state: true },\n autoUpdateEnabled: { type: Boolean, state: true },\n autoUpdateLoading: { type: Boolean, state: true },\n // Ollama related properties\n ollamaStatus: { type: Object, state: true },\n ollamaModels: { type: Array, state: true },\n installingModels: { type: Object, state: true },\n // Whisper related properties\n whisperModels: { type: Array, state: true },\n };\n //////// after_modelStateService ////////\n\n constructor() {\n super();\n //////// after_modelStateService ////////\n this.shortcuts = {};\n this.firebaseUser = null;\n this.apiKeys = { openai: '', gemini: '', anthropic: '', whisper: '' };\n this.providerConfig = {};\n this.isLoading = true;\n this.isContentProtectionOn = true;\n this.saving = false;\n this.availableLlmModels = [];\n this.availableSttModels = [];\n this.selectedLlm = null;\n this.selectedStt = null;\n this.isLlmListVisible = false;\n this.isSttListVisible = false;\n this.presets = [];\n this.selectedPreset = null;\n this.showPresets = false;\n // Ollama related\n this.ollamaStatus = { installed: false, running: false };\n this.ollamaModels = [];\n this.installingModels = {}; // { modelName: progress }\n // Whisper related\n this.whisperModels = [];\n this.whisperProgressTracker = null; // Will be initialized when needed\n this.handleUsePicklesKey = this.handleUsePicklesKey.bind(this)\n this.autoUpdateEnabled = true;\n this.autoUpdateLoading = true;\n this.loadInitialData();\n //////// after_modelStateService ////////\n }\n\n async loadAutoUpdateSetting() {\n if (!window.api) return;\n this.autoUpdateLoading = true;\n try {\n const enabled = await window.api.settingsView.getAutoUpdate();\n this.autoUpdateEnabled = enabled;\n console.log('Auto-update setting loaded:', enabled);\n } catch (e) {\n console.error('Error loading auto-update setting:', e);\n this.autoUpdateEnabled = true; // fallback\n }\n this.autoUpdateLoading = false;\n this.requestUpdate();\n }\n\n async handleToggleAutoUpdate() {\n if (!window.api || this.autoUpdateLoading) return;\n this.autoUpdateLoading = true;\n this.requestUpdate();\n try {\n const newValue = !this.autoUpdateEnabled;\n const result = await window.api.settingsView.setAutoUpdate(newValue);\n if (result && result.success) {\n this.autoUpdateEnabled = newValue;\n } else {\n console.error('Failed to update auto-update setting');\n }\n } catch (e) {\n console.error('Error toggling auto-update:', e);\n }\n this.autoUpdateLoading = false;\n this.requestUpdate();\n }\n\n async loadLocalAIStatus() {\n try {\n // Load Ollama status\n const ollamaStatus = await window.api.settingsView.getOllamaStatus();\n if (ollamaStatus?.success) {\n this.ollamaStatus = { installed: ollamaStatus.installed, running: ollamaStatus.running };\n this.ollamaModels = ollamaStatus.models || [];\n }\n \n // Load Whisper models status only if Whisper is enabled\n if (this.apiKeys?.whisper === 'local') {\n const whisperModelsResult = await window.api.settingsView.getWhisperInstalledModels();\n if (whisperModelsResult?.success) {\n const installedWhisperModels = whisperModelsResult.models;\n if (this.providerConfig?.whisper) {\n this.providerConfig.whisper.sttModels.forEach(m => {\n const installedInfo = installedWhisperModels.find(i => i.id === m.id);\n if (installedInfo) {\n m.installed = installedInfo.installed;\n }\n });\n }\n }\n }\n \n // Trigger UI update\n this.requestUpdate();\n } catch (error) {\n console.error('Error loading LocalAI status:', error);\n }\n }\n\n //////// after_modelStateService ////////\n async loadInitialData() {\n if (!window.api) return;\n this.isLoading = true;\n try {\n // Load essential data first\n const [userState, modelSettings, presets, contentProtection, shortcuts] = await Promise.all([\n window.api.settingsView.getCurrentUser(),\n window.api.settingsView.getModelSettings(), // Facade call\n window.api.settingsView.getPresets(),\n window.api.settingsView.getContentProtectionStatus(),\n window.api.settingsView.getCurrentShortcuts()\n ]);\n \n if (userState && userState.isLoggedIn) this.firebaseUser = userState;\n \n if (modelSettings.success) {\n const { config, storedKeys, availableLlm, availableStt, selectedModels } = modelSettings.data;\n this.providerConfig = config;\n this.apiKeys = storedKeys;\n this.availableLlmModels = availableLlm;\n this.availableSttModels = availableStt;\n this.selectedLlm = selectedModels.llm;\n this.selectedStt = selectedModels.stt;\n }\n\n this.presets = presets || [];\n this.isContentProtectionOn = contentProtection;\n this.shortcuts = shortcuts || {};\n if (this.presets.length > 0) {\n const firstUserPreset = this.presets.find(p => p.is_default === 0);\n if (firstUserPreset) this.selectedPreset = firstUserPreset;\n }\n \n // Load LocalAI status asynchronously to improve initial load time\n this.loadLocalAIStatus();\n } catch (error) {\n console.error('Error loading initial settings data:', error);\n } finally {\n this.isLoading = false;\n }\n }\n\n\n async handleSaveKey(provider) {\n const input = this.shadowRoot.querySelector(`#key-input-${provider}`);\n if (!input) return;\n const key = input.value;\n \n // For Ollama, we need to ensure it's ready first\n if (provider === 'ollama') {\n this.saving = true;\n \n // First ensure Ollama is installed and running\n const ensureResult = await window.api.settingsView.ensureOllamaReady();\n if (!ensureResult.success) {\n alert(`Failed to setup Ollama: ${ensureResult.error}`);\n this.saving = false;\n return;\n }\n \n // Now validate (which will check if service is running)\n const result = await window.api.settingsView.validateKey({ provider, key: 'local' });\n \n if (result.success) {\n await this.refreshModelData();\n await this.refreshOllamaStatus();\n } else {\n alert(`Failed to connect to Ollama: ${result.error}`);\n }\n this.saving = false;\n return;\n }\n \n // For Whisper, just enable it\n if (provider === 'whisper') {\n this.saving = true;\n const result = await window.api.settingsView.validateKey({ provider, key: 'local' });\n \n if (result.success) {\n await this.refreshModelData();\n } else {\n alert(`Failed to enable Whisper: ${result.error}`);\n }\n this.saving = false;\n return;\n }\n \n // For other providers, use the normal flow\n this.saving = true;\n const result = await window.api.settingsView.validateKey({ provider, key });\n \n if (result.success) {\n await this.refreshModelData();\n } else {\n alert(`Failed to save ${provider} key: ${result.error}`);\n input.value = this.apiKeys[provider] || '';\n }\n this.saving = false;\n }\n \n async handleClearKey(provider) {\n console.log(`[SettingsView] handleClearKey: ${provider}`);\n this.saving = true;\n await window.api.settingsView.removeApiKey(provider);\n this.apiKeys = { ...this.apiKeys, [provider]: '' };\n await this.refreshModelData();\n this.saving = false;\n }\n\n async refreshModelData() {\n const [availableLlm, availableStt, selected, storedKeys] = await Promise.all([\n window.api.settingsView.getAvailableModels({ type: 'llm' }),\n window.api.settingsView.getAvailableModels({ type: 'stt' }),\n window.api.settingsView.getSelectedModels(),\n window.api.settingsView.getAllKeys()\n ]);\n this.availableLlmModels = availableLlm;\n this.availableSttModels = availableStt;\n this.selectedLlm = selected.llm;\n this.selectedStt = selected.stt;\n this.apiKeys = storedKeys;\n this.requestUpdate();\n }\n \n async toggleModelList(type) {\n const visibilityProp = type === 'llm' ? 'isLlmListVisible' : 'isSttListVisible';\n\n if (!this[visibilityProp]) {\n this.saving = true;\n this.requestUpdate();\n \n await this.refreshModelData();\n\n this.saving = false;\n }\n\n // 데이터 새로고침 후, 목록의 표시 상태를 토글합니다.\n this[visibilityProp] = !this[visibilityProp];\n this.requestUpdate();\n }\n \n async selectModel(type, modelId) {\n // Check if this is an Ollama model that needs to be installed\n const provider = this.getProviderForModel(type, modelId);\n if (provider === 'ollama') {\n const ollamaModel = this.ollamaModels.find(m => m.name === modelId);\n if (ollamaModel && !ollamaModel.installed && !ollamaModel.installing) {\n // Need to install the model first\n await this.installOllamaModel(modelId);\n return;\n }\n }\n \n // Check if this is a Whisper model that needs to be downloaded\n if (provider === 'whisper' && type === 'stt') {\n const isInstalling = this.installingModels[modelId] !== undefined;\n const whisperModelInfo = this.providerConfig.whisper.sttModels.find(m => m.id === modelId);\n \n if (whisperModelInfo && !whisperModelInfo.installed && !isInstalling) {\n await this.downloadWhisperModel(modelId);\n return;\n }\n }\n \n this.saving = true;\n await window.api.settingsView.setSelectedModel({ type, modelId });\n if (type === 'llm') this.selectedLlm = modelId;\n if (type === 'stt') this.selectedStt = modelId;\n this.isLlmListVisible = false;\n this.isSttListVisible = false;\n this.saving = false;\n this.requestUpdate();\n }\n \n async refreshOllamaStatus() {\n const ollamaStatus = await window.api.settingsView.getOllamaStatus();\n if (ollamaStatus?.success) {\n this.ollamaStatus = { installed: ollamaStatus.installed, running: ollamaStatus.running };\n this.ollamaModels = ollamaStatus.models || [];\n }\n }\n \n async installOllamaModel(modelName) {\n try {\n // Ollama 모델 다운로드 시작\n this.installingModels = { ...this.installingModels, [modelName]: 0 };\n this.requestUpdate();\n\n // 진행률 이벤트 리스너 설정 - 통합 LocalAI 이벤트 사용\n const progressHandler = (event, data) => {\n if (data.service === 'ollama' && data.model === modelName) {\n this.installingModels = { ...this.installingModels, [modelName]: data.progress || 0 };\n this.requestUpdate();\n }\n };\n\n // 통합 LocalAI 이벤트 리스너 등록\n window.api.settingsView.onLocalAIInstallProgress(progressHandler);\n\n try {\n const result = await window.api.settingsView.pullOllamaModel(modelName);\n \n if (result.success) {\n console.log(`[SettingsView] Model ${modelName} installed successfully`);\n delete this.installingModels[modelName];\n this.requestUpdate();\n \n // 상태 새로고침\n await this.refreshOllamaStatus();\n await this.refreshModelData();\n } else {\n throw new Error(result.error || 'Installation failed');\n }\n } finally {\n // 통합 LocalAI 이벤트 리스너 제거\n window.api.settingsView.removeOnLocalAIInstallProgress(progressHandler);\n }\n } catch (error) {\n console.error(`[SettingsView] Error installing model ${modelName}:`, error);\n delete this.installingModels[modelName];\n this.requestUpdate();\n }\n }\n \n async downloadWhisperModel(modelId) {\n // Mark as installing\n this.installingModels = { ...this.installingModels, [modelId]: 0 };\n this.requestUpdate();\n \n try {\n // Set up progress listener - 통합 LocalAI 이벤트 사용\n const progressHandler = (event, data) => {\n if (data.service === 'whisper' && data.model === modelId) {\n this.installingModels = { ...this.installingModels, [modelId]: data.progress || 0 };\n this.requestUpdate();\n }\n };\n \n window.api.settingsView.onLocalAIInstallProgress(progressHandler);\n \n // Start download\n const result = await window.api.settingsView.downloadWhisperModel(modelId);\n \n if (result.success) {\n // Update the model's installed status\n if (this.providerConfig?.whisper?.sttModels) {\n const modelInfo = this.providerConfig.whisper.sttModels.find(m => m.id === modelId);\n if (modelInfo) {\n modelInfo.installed = true;\n }\n }\n \n // Remove from installing models\n delete this.installingModels[modelId];\n this.requestUpdate();\n \n // Reload LocalAI status to get fresh data\n await this.loadLocalAIStatus();\n \n // Auto-select the model after download\n await this.selectModel('stt', modelId);\n } else {\n // Remove from installing models on failure too\n delete this.installingModels[modelId];\n this.requestUpdate();\n alert(`Failed to download Whisper model: ${result.error}`);\n }\n \n // Cleanup\n window.api.settingsView.removeOnLocalAIInstallProgress(progressHandler);\n } catch (error) {\n console.error(`[SettingsView] Error downloading Whisper model ${modelId}:`, error);\n // Remove from installing models on error\n delete this.installingModels[modelId];\n this.requestUpdate();\n alert(`Error downloading ${modelId}: ${error.message}`);\n }\n }\n \n getProviderForModel(type, modelId) {\n for (const [providerId, config] of Object.entries(this.providerConfig)) {\n const models = type === 'llm' ? config.llmModels : config.sttModels;\n if (models?.some(m => m.id === modelId)) {\n return providerId;\n }\n }\n return null;\n }\n\n\n handleUsePicklesKey(e) {\n e.preventDefault()\n if (this.wasJustDragged) return\n \n console.log(\"Requesting Firebase authentication from main process...\")\n window.api.settingsView.startFirebaseAuth();\n }\n //////// after_modelStateService ////////\n\n openShortcutEditor() {\n window.api.settingsView.openShortcutSettingsWindow();\n }\n\n connectedCallback() {\n super.connectedCallback();\n \n this.setupEventListeners();\n this.setupIpcListeners();\n this.setupWindowResize();\n this.loadAutoUpdateSetting();\n // Force one height calculation immediately (innerHeight may be 0 at first)\n setTimeout(() => this.updateScrollHeight(), 0);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.cleanupEventListeners();\n this.cleanupIpcListeners();\n this.cleanupWindowResize();\n \n // Cancel any ongoing Ollama installations when component is destroyed\n const installingModels = Object.keys(this.installingModels);\n if (installingModels.length > 0) {\n installingModels.forEach(modelName => {\n window.api.settingsView.cancelOllamaInstallation(modelName);\n });\n }\n }\n\n setupEventListeners() {\n this.addEventListener('mouseenter', this.handleMouseEnter);\n this.addEventListener('mouseleave', this.handleMouseLeave);\n }\n\n cleanupEventListeners() {\n this.removeEventListener('mouseenter', this.handleMouseEnter);\n this.removeEventListener('mouseleave', this.handleMouseLeave);\n }\n\n setupIpcListeners() {\n if (!window.api) return;\n \n this._userStateListener = (event, userState) => {\n console.log('[SettingsView] Received user-state-changed:', userState);\n if (userState && userState.isLoggedIn) {\n this.firebaseUser = userState;\n } else {\n this.firebaseUser = null;\n }\n this.loadAutoUpdateSetting();\n // Reload model settings when user state changes (Firebase login/logout)\n this.loadInitialData();\n };\n \n this._settingsUpdatedListener = (event, settings) => {\n console.log('[SettingsView] Received settings-updated');\n this.settings = settings;\n this.requestUpdate();\n };\n\n // 프리셋 업데이트 리스너 추가\n this._presetsUpdatedListener = async (event) => {\n console.log('[SettingsView] Received presets-updated, refreshing presets');\n try {\n const presets = await window.api.settingsView.getPresets();\n this.presets = presets || [];\n \n // 현재 선택된 프리셋이 삭제되었는지 확인 (사용자 프리셋만 고려)\n const userPresets = this.presets.filter(p => p.is_default === 0);\n if (this.selectedPreset && !userPresets.find(p => p.id === this.selectedPreset.id)) {\n this.selectedPreset = userPresets.length > 0 ? userPresets[0] : null;\n }\n \n this.requestUpdate();\n } catch (error) {\n console.error('[SettingsView] Failed to refresh presets:', error);\n }\n };\n this._shortcutListener = (event, keybinds) => {\n console.log('[SettingsView] Received updated shortcuts:', keybinds);\n this.shortcuts = keybinds;\n };\n \n window.api.settingsView.onUserStateChanged(this._userStateListener);\n window.api.settingsView.onSettingsUpdated(this._settingsUpdatedListener);\n window.api.settingsView.onPresetsUpdated(this._presetsUpdatedListener);\n window.api.settingsView.onShortcutsUpdated(this._shortcutListener);\n }\n\n cleanupIpcListeners() {\n if (!window.api) return;\n \n if (this._userStateListener) {\n window.api.settingsView.removeOnUserStateChanged(this._userStateListener);\n }\n if (this._settingsUpdatedListener) {\n window.api.settingsView.removeOnSettingsUpdated(this._settingsUpdatedListener);\n }\n if (this._presetsUpdatedListener) {\n window.api.settingsView.removeOnPresetsUpdated(this._presetsUpdatedListener);\n }\n if (this._shortcutListener) {\n window.api.settingsView.removeOnShortcutsUpdated(this._shortcutListener);\n }\n }\n\n setupWindowResize() {\n this.resizeHandler = () => {\n this.requestUpdate();\n this.updateScrollHeight();\n };\n window.addEventListener('resize', this.resizeHandler);\n \n // Initial setup\n setTimeout(() => this.updateScrollHeight(), 100);\n }\n\n cleanupWindowResize() {\n if (this.resizeHandler) {\n window.removeEventListener('resize', this.resizeHandler);\n }\n }\n\n updateScrollHeight() {\n // Electron 일부 시점에서 window.innerHeight 가 0 으로 보고되는 버그 보호\n const rawHeight = window.innerHeight || (window.screen ? window.screen.height : 0);\n const MIN_HEIGHT = 300; // 최소 보장 높이\n const maxHeight = Math.max(MIN_HEIGHT, rawHeight);\n\n this.style.maxHeight = `${maxHeight}px`;\n\n const container = this.shadowRoot?.querySelector('.settings-container');\n if (container) {\n container.style.maxHeight = `${maxHeight}px`;\n }\n }\n\n handleMouseEnter = () => {\n window.api.settingsView.cancelHideSettingsWindow();\n // Recalculate height in case it was set to 0 before\n this.updateScrollHeight();\n }\n\n handleMouseLeave = () => {\n window.api.settingsView.hideSettingsWindow();\n }\n\n\n getMainShortcuts() {\n return [\n { name: 'Show / Hide', accelerator: this.shortcuts.toggleVisibility },\n { name: 'Ask Anything', accelerator: this.shortcuts.nextStep },\n { name: 'Scroll Up Response', accelerator: this.shortcuts.scrollUp },\n { name: 'Scroll Down Response', accelerator: this.shortcuts.scrollDown },\n ];\n }\n\n renderShortcutKeys(accelerator) {\n if (!accelerator) return html`N/A`;\n \n const keyMap = {\n 'Cmd': '⌘', 'Command': '⌘', 'Ctrl': '⌃', 'Alt': '⌥', 'Shift': '⇧', 'Enter': '↵',\n 'Up': '↑', 'Down': '↓', 'Left': '←', 'Right': '→'\n };\n\n // scrollDown/scrollUp의 특수 처리\n if (accelerator.includes('↕')) {\n const keys = accelerator.replace('↕','').split('+');\n keys.push('↕');\n return html`${keys.map(key => html`${keyMap[key] || key}`)}`;\n }\n\n const keys = accelerator.split('+');\n return html`${keys.map(key => html`${keyMap[key] || key}`)}`;\n }\n\n togglePresets() {\n this.showPresets = !this.showPresets;\n }\n\n async handlePresetSelect(preset) {\n this.selectedPreset = preset;\n // Here you could implement preset application logic\n console.log('Selected preset:', preset);\n }\n\n handleMoveLeft() {\n console.log('Move Left clicked');\n window.api.settingsView.moveWindowStep('left');\n }\n\n handleMoveRight() {\n console.log('Move Right clicked');\n window.api.settingsView.moveWindowStep('right');\n }\n\n async handlePersonalize() {\n console.log('Personalize clicked');\n try {\n await window.api.settingsView.openPersonalizePage();\n } catch (error) {\n console.error('Failed to open personalize page:', error);\n }\n }\n\n async handleToggleInvisibility() {\n console.log('Toggle Invisibility clicked');\n this.isContentProtectionOn = await window.api.settingsView.toggleContentProtection();\n this.requestUpdate();\n }\n\n async handleSaveApiKey() {\n const input = this.shadowRoot.getElementById('api-key-input');\n if (!input || !input.value) return;\n\n const newApiKey = input.value;\n try {\n const result = await window.api.settingsView.saveApiKey(newApiKey);\n if (result.success) {\n console.log('API Key saved successfully via IPC.');\n this.apiKey = newApiKey;\n this.requestUpdate();\n } else {\n console.error('Failed to save API Key via IPC:', result.error);\n }\n } catch(e) {\n console.error('Error invoking save-api-key IPC:', e);\n }\n }\n\n handleQuit() {\n console.log('Quit clicked');\n window.api.settingsView.quitApplication();\n }\n\n handleFirebaseLogout() {\n console.log('Firebase Logout clicked');\n window.api.settingsView.firebaseLogout();\n }\n\n async handleOllamaShutdown() {\n console.log('[SettingsView] Shutting down Ollama service...');\n \n if (!window.api) return;\n \n try {\n // Show loading state\n this.ollamaStatus = { ...this.ollamaStatus, running: false };\n this.requestUpdate();\n \n const result = await window.api.settingsView.shutdownOllama(false); // Graceful shutdown\n \n if (result.success) {\n console.log('[SettingsView] Ollama shut down successfully');\n // Refresh status to reflect the change\n await this.refreshOllamaStatus();\n } else {\n console.error('[SettingsView] Failed to shutdown Ollama:', result.error);\n // Restore previous state on error\n await this.refreshOllamaStatus();\n }\n } catch (error) {\n console.error('[SettingsView] Error during Ollama shutdown:', error);\n // Restore previous state on error\n await this.refreshOllamaStatus();\n }\n }\n\n //////// after_modelStateService ////////\n render() {\n if (this.isLoading) {\n return html`\n
\n
\n
\n Loading...\n
\n
\n `;\n }\n\n const loggedIn = !!this.firebaseUser;\n\n const apiKeyManagementHTML = html`\n
\n ${Object.entries(this.providerConfig)\n .filter(([id, config]) => !id.includes('-glass'))\n .map(([id, config]) => {\n if (id === 'ollama') {\n // Special UI for Ollama\n return html`\n
\n \n ${this.ollamaStatus.installed && this.ollamaStatus.running ? html`\n
\n ✓ Ollama is running\n
\n \n ` : this.ollamaStatus.installed ? html`\n
\n ⚠ Ollama installed but not running\n
\n \n ` : html`\n
\n ✗ Ollama not installed\n
\n \n `}\n
\n `;\n }\n \n if (id === 'whisper') {\n // Simplified UI for Whisper without model selection\n return html`\n
\n \n ${this.apiKeys[id] === 'local' ? html`\n
\n ✓ Whisper is enabled\n
\n \n ` : html`\n \n `}\n
\n `;\n }\n \n // Regular providers\n return html`\n
\n \n \n
\n \n \n
\n
\n `;\n })}\n
\n `;\n \n const getModelName = (type, id) => {\n const models = type === 'llm' ? this.availableLlmModels : this.availableSttModels;\n const model = models.find(m => m.id === id);\n return model ? model.name : id;\n }\n\n const modelSelectionHTML = html`\n
\n
\n \n \n ${this.isLlmListVisible ? html`\n
\n ${this.availableLlmModels.map(model => {\n const isOllama = this.getProviderForModel('llm', model.id) === 'ollama';\n const ollamaModel = isOllama ? this.ollamaModels.find(m => m.name === model.id) : null;\n const isInstalling = this.installingModels[model.id] !== undefined;\n const installProgress = this.installingModels[model.id] || 0;\n \n return html`\n
this.selectModel('llm', model.id)}>\n ${model.name}\n ${isOllama ? html`\n ${isInstalling ? html`\n
\n
\n
\n ` : ollamaModel?.installed ? html`\n ✓ Installed\n ` : html`\n Click to install\n `}\n ` : ''}\n
\n `;\n })}\n
\n ` : ''}\n
\n
\n \n \n ${this.isSttListVisible ? html`\n
\n ${this.availableSttModels.map(model => {\n const isWhisper = this.getProviderForModel('stt', model.id) === 'whisper';\n const whisperModel = isWhisper && this.providerConfig?.whisper?.sttModels \n ? this.providerConfig.whisper.sttModels.find(m => m.id === model.id) \n : null;\n const isInstalling = this.installingModels[model.id] !== undefined;\n const installProgress = this.installingModels[model.id] || 0;\n \n return html`\n
this.selectModel('stt', model.id)}>\n ${model.name}\n ${isWhisper ? html`\n ${isInstalling ? html`\n
\n
\n
\n ` : whisperModel?.installed ? html`\n ✓ Installed\n ` : html`\n Not Installed\n `}\n ` : ''}\n
\n `;\n })}\n
\n ` : ''}\n
\n
\n `;\n\n return html`\n
\n
\n
\n

Pickle Glass

\n
\n ${this.firebaseUser\n ? html`Account: ${this.firebaseUser.email || 'Logged In'}`\n : `Account: Not Logged In`\n }\n
\n
\n
\n \n \n \n
\n
\n\n ${apiKeyManagementHTML}\n ${modelSelectionHTML}\n\n
\n \n
\n\n \n
\n ${this.getMainShortcuts().map(shortcut => html`\n
\n ${shortcut.name}\n
\n ${this.renderShortcutKeys(shortcut.accelerator)}\n
\n
\n `)}\n
\n\n
\n
\n \n My Presets\n (${this.presets.filter(p => p.is_default === 0).length})\n \n \n ${this.showPresets ? '▼' : '▶'}\n \n
\n \n
\n ${this.presets.filter(p => p.is_default === 0).length === 0 ? html`\n
\n No custom presets yet.
\n \n Create your first preset\n \n
\n ` : this.presets.filter(p => p.is_default === 0).map(preset => html`\n
this.handlePresetSelect(preset)}>\n ${preset.title}\n ${this.selectedPreset?.id === preset.id ? html`Selected` : ''}\n
\n `)}\n
\n
\n\n
\n \n \n \n
\n \n \n
\n \n \n \n
\n ${this.firebaseUser\n ? html`\n \n `\n : html`\n \n `\n }\n \n
\n
\n
\n `;\n }\n //////// after_modelStateService ////////\n}\n\ncustomElements.define('settings-view', SettingsView);"], ["/glass/src/ui/listen/summary/SummaryView.js", "import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';\n\nexport class SummaryView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n /* Inherit font styles from parent */\n\n /* highlight.js 스타일 추가 */\n .insights-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .insights-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .insights-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n }\n\n .insights-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n }\n\n .hljs-keyword {\n color: #ff79c6 !important;\n }\n .hljs-string {\n color: #f1fa8c !important;\n }\n .hljs-comment {\n color: #6272a4 !important;\n }\n .hljs-number {\n color: #bd93f9 !important;\n }\n .hljs-function {\n color: #50fa7b !important;\n }\n .hljs-variable {\n color: #8be9fd !important;\n }\n .hljs-built_in {\n color: #ffb86c !important;\n }\n .hljs-title {\n color: #50fa7b !important;\n }\n .hljs-attr {\n color: #50fa7b !important;\n }\n .hljs-tag {\n color: #ff79c6 !important;\n }\n\n .insights-container {\n overflow-y: auto;\n padding: 12px 16px 16px 16px;\n position: relative;\n z-index: 1;\n min-height: 150px;\n max-height: 600px;\n flex: 1;\n }\n\n /* Visibility handled by parent component */\n\n .insights-container::-webkit-scrollbar {\n width: 8px;\n }\n .insights-container::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n }\n .insights-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.3);\n border-radius: 4px;\n }\n .insights-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.5);\n }\n\n insights-title {\n color: rgba(255, 255, 255, 0.8);\n font-size: 15px;\n font-weight: 500;\n font-family: 'Helvetica Neue', sans-serif;\n margin: 12px 0 8px 0;\n display: block;\n }\n\n .insights-container h4 {\n color: #ffffff;\n font-size: 12px;\n font-weight: 600;\n margin: 12px 0 8px 0;\n padding: 4px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: default;\n }\n\n .insights-container h4:hover {\n background: transparent;\n }\n\n .insights-container h4:first-child {\n margin-top: 0;\n }\n\n .outline-item {\n color: #ffffff;\n font-size: 11px;\n line-height: 1.4;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n transition: background-color 0.15s ease;\n cursor: pointer;\n word-wrap: break-word;\n }\n\n .outline-item:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .request-item {\n color: #ffffff;\n font-size: 12px;\n line-height: 1.2;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: default;\n word-wrap: break-word;\n transition: background-color 0.15s ease;\n }\n\n .request-item.clickable {\n cursor: pointer;\n transition: all 0.15s ease;\n }\n .request-item.clickable:hover {\n background: rgba(255, 255, 255, 0.1);\n transform: translateX(2px);\n }\n\n /* 마크다운 렌더링된 콘텐츠 스타일 */\n .markdown-content {\n color: #ffffff;\n font-size: 11px;\n line-height: 1.4;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: pointer;\n word-wrap: break-word;\n transition: all 0.15s ease;\n }\n\n .markdown-content:hover {\n background: rgba(255, 255, 255, 0.1);\n transform: translateX(2px);\n }\n\n .markdown-content p {\n margin: 4px 0;\n }\n\n .markdown-content ul,\n .markdown-content ol {\n margin: 4px 0;\n padding-left: 16px;\n }\n\n .markdown-content li {\n margin: 2px 0;\n }\n\n .markdown-content a {\n color: #8be9fd;\n text-decoration: none;\n }\n\n .markdown-content a:hover {\n text-decoration: underline;\n }\n\n .markdown-content strong {\n font-weight: 600;\n color: #f8f8f2;\n }\n\n .markdown-content em {\n font-style: italic;\n color: #f1fa8c;\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100px;\n color: rgba(255, 255, 255, 0.6);\n font-size: 12px;\n font-style: italic;\n }\n `;\n\n static properties = {\n structuredData: { type: Object },\n isVisible: { type: Boolean },\n hasCompletedRecording: { type: Boolean },\n };\n\n constructor() {\n super();\n this.structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: [],\n };\n this.isVisible = true;\n this.hasCompletedRecording = false;\n\n // 마크다운 라이브러리 초기화\n this.marked = null;\n this.hljs = null;\n this.isLibrariesLoaded = false;\n this.DOMPurify = null;\n this.isDOMPurifyLoaded = false;\n\n this.loadLibraries();\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (window.api) {\n window.api.summaryView.onSummaryUpdate((event, data) => {\n this.structuredData = data;\n this.requestUpdate();\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.summaryView.removeAllSummaryUpdateListeners();\n }\n }\n\n // Handle session reset from parent\n resetAnalysis() {\n this.structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: [],\n };\n this.requestUpdate();\n }\n\n async loadLibraries() {\n try {\n if (!window.marked) {\n await this.loadScript('../../../assets/marked-4.3.0.min.js');\n }\n\n if (!window.hljs) {\n await this.loadScript('../../../assets/highlight-11.9.0.min.js');\n }\n\n if (!window.DOMPurify) {\n await this.loadScript('../../../assets/dompurify-3.0.7.min.js');\n }\n\n this.marked = window.marked;\n this.hljs = window.hljs;\n this.DOMPurify = window.DOMPurify;\n\n if (this.marked && this.hljs) {\n this.marked.setOptions({\n highlight: (code, lang) => {\n if (lang && this.hljs.getLanguage(lang)) {\n try {\n return this.hljs.highlight(code, { language: lang }).value;\n } catch (err) {\n console.warn('Highlight error:', err);\n }\n }\n try {\n return this.hljs.highlightAuto(code).value;\n } catch (err) {\n console.warn('Auto highlight error:', err);\n }\n return code;\n },\n breaks: true,\n gfm: true,\n pedantic: false,\n smartypants: false,\n xhtml: false,\n });\n\n this.isLibrariesLoaded = true;\n console.log('Markdown libraries loaded successfully');\n }\n\n if (this.DOMPurify) {\n this.isDOMPurifyLoaded = true;\n console.log('DOMPurify loaded successfully in SummaryView');\n }\n } catch (error) {\n console.error('Failed to load libraries:', error);\n }\n }\n\n loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n parseMarkdown(text) {\n if (!text) return '';\n\n if (!this.isLibrariesLoaded || !this.marked) {\n return text;\n }\n\n try {\n return this.marked(text);\n } catch (error) {\n console.error('Markdown parsing error:', error);\n return text;\n }\n }\n\n handleMarkdownClick(originalText) {\n this.handleRequestClick(originalText);\n }\n\n renderMarkdownContent() {\n if (!this.isLibrariesLoaded || !this.marked) {\n return;\n }\n\n const markdownElements = this.shadowRoot.querySelectorAll('[data-markdown-id]');\n markdownElements.forEach(element => {\n const originalText = element.getAttribute('data-original-text');\n if (originalText) {\n try {\n let parsedHTML = this.parseMarkdown(originalText);\n\n if (this.isDOMPurifyLoaded && this.DOMPurify) {\n parsedHTML = this.DOMPurify.sanitize(parsedHTML);\n\n if (this.DOMPurify.removed && this.DOMPurify.removed.length > 0) {\n console.warn('Unsafe content detected in insights, showing plain text');\n element.textContent = '⚠️ ' + originalText;\n return;\n }\n }\n\n element.innerHTML = parsedHTML;\n } catch (error) {\n console.error('Error rendering markdown for element:', error);\n element.textContent = originalText;\n }\n }\n });\n }\n\n async handleRequestClick(requestText) {\n console.log('🔥 Analysis request clicked:', requestText);\n\n if (window.api) {\n try {\n const result = await window.api.summaryView.sendQuestionFromSummary(requestText);\n\n if (result.success) {\n console.log('✅ Question sent to AskView successfully');\n } else {\n console.error('❌ Failed to send question to AskView:', result.error);\n }\n } catch (error) {\n console.error('❌ Error in handleRequestClick:', error);\n }\n }\n }\n\n getSummaryText() {\n const data = this.structuredData || { summary: [], topic: { header: '', bullets: [] }, actions: [] };\n let sections = [];\n\n if (data.summary && data.summary.length > 0) {\n sections.push(`Current Summary:\\n${data.summary.map(s => `• ${s}`).join('\\n')}`);\n }\n\n if (data.topic && data.topic.header && data.topic.bullets.length > 0) {\n sections.push(`\\n${data.topic.header}:\\n${data.topic.bullets.map(b => `• ${b}`).join('\\n')}`);\n }\n\n if (data.actions && data.actions.length > 0) {\n sections.push(`\\nActions:\\n${data.actions.map(a => `▸ ${a}`).join('\\n')}`);\n }\n\n if (data.followUps && data.followUps.length > 0) {\n sections.push(`\\nFollow-Ups:\\n${data.followUps.map(f => `▸ ${f}`).join('\\n')}`);\n }\n\n return sections.join('\\n\\n').trim();\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.renderMarkdownContent();\n }\n\n render() {\n if (!this.isVisible) {\n return html`
`;\n }\n\n const data = this.structuredData || {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n };\n\n const hasAnyContent = data.summary.length > 0 || data.topic.bullets.length > 0 || data.actions.length > 0;\n\n return html`\n
\n ${!hasAnyContent\n ? html`
No insights yet...
`\n : html`\n Current Summary\n ${data.summary.length > 0\n ? data.summary\n .slice(0, 5)\n .map(\n (bullet, index) => html`\n this.handleMarkdownClick(bullet)}\n >\n ${bullet}\n
\n `\n )\n : html`
No content yet...
`}\n ${data.topic.header\n ? html`\n ${data.topic.header}\n ${data.topic.bullets\n .slice(0, 3)\n .map(\n (bullet, index) => html`\n this.handleMarkdownClick(bullet)}\n >\n ${bullet}\n \n `\n )}\n `\n : ''}\n ${data.actions.length > 0\n ? html`\n Actions\n ${data.actions\n .slice(0, 5)\n .map(\n (action, index) => html`\n this.handleMarkdownClick(action)}\n >\n ${action}\n \n `\n )}\n `\n : ''}\n ${this.hasCompletedRecording && data.followUps && data.followUps.length > 0\n ? html`\n Follow-Ups\n ${data.followUps.map(\n (followUp, index) => html`\n this.handleMarkdownClick(followUp)}\n >\n ${followUp}\n \n `\n )}\n `\n : ''}\n `}\n \n `;\n }\n}\n\ncustomElements.define('summary-view', SummaryView); "], ["/glass/src/ui/settings/ShortCutSettingsView.js", "import { html, css, LitElement } from '../../ui/assets/lit-core-2.7.4.min.js';\n\nconst commonSystemShortcuts = new Set([\n 'Cmd+Q', 'Cmd+W', 'Cmd+A', 'Cmd+S', 'Cmd+Z', 'Cmd+X', 'Cmd+C', 'Cmd+V', 'Cmd+P', 'Cmd+F', 'Cmd+G', 'Cmd+H', 'Cmd+M', 'Cmd+N', 'Cmd+O', 'Cmd+T',\n 'Ctrl+Q', 'Ctrl+W', 'Ctrl+A', 'Ctrl+S', 'Ctrl+Z', 'Ctrl+X', 'Ctrl+C', 'Ctrl+V', 'Ctrl+P', 'Ctrl+F', 'Ctrl+G', 'Ctrl+H', 'Ctrl+M', 'Ctrl+N', 'Ctrl+O', 'Ctrl+T'\n]);\n\nconst displayNameMap = {\n nextStep: 'Ask Anything',\n moveUp: 'Move Up Window',\n moveDown: 'Move Down Window',\n scrollUp: 'Scroll Up Response',\n scrollDown: 'Scroll Down Response',\n };\n\nexport class ShortcutSettingsView extends LitElement {\n static styles = css`\n * { font-family:'Helvetica Neue',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;\n cursor:default; user-select:none; box-sizing:border-box; }\n\n :host { display:flex; width:100%; height:100%; color:white; }\n\n .container { display:flex; flex-direction:column; height:100%;\n background:rgba(20,20,20,.9); border-radius:12px;\n outline:.5px rgba(255,255,255,.2) solid; outline-offset:-1px;\n position:relative; overflow:hidden; padding:12px; }\n\n .close-button{position:absolute;top:10px;right:10px;inline-size:14px;block-size:14px;\n background:rgba(255,255,255,.1);border:none;border-radius:3px;\n color:rgba(255,255,255,.7);display:grid;place-items:center;\n font-size:14px;line-height:0;cursor:pointer;transition:.15s;z-index:10;}\n .close-button:hover{background:rgba(255,255,255,.2);color:rgba(255,255,255,.9);}\n\n .title{font-size:14px;font-weight:500;margin:0 0 8px;padding-bottom:8px;\n border-bottom:1px solid rgba(255,255,255,.1);text-align:center;}\n\n .scroll-area{flex:1 1 auto;overflow-y:auto;margin:0 -4px;padding:4px;}\n\n .shortcut-entry{display:flex;align-items:center;width:100%;gap:8px;\n margin-bottom:8px;font-size:12px;padding:4px;}\n .shortcut-name{flex:1 1 auto;color:rgba(255,255,255,.9);font-weight:300;\n white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}\n\n .action-btn{background:none;border:none;color:rgba(0,122,255,.8);\n font-size:11px;padding:0 4px;cursor:pointer;transition:.15s;}\n .action-btn:hover{color:#0a84ff;text-decoration:underline;}\n\n .shortcut-input{inline-size:120px;background:rgba(0,0,0,.2);\n border:1px solid rgba(255,255,255,.2);border-radius:4px;\n padding:4px 6px;font:11px 'SF Mono','Menlo',monospace;\n color:white;text-align:right;cursor:text;margin-left:auto;}\n .shortcut-input:focus,.shortcut-input.capturing{\n outline:none;border-color:rgba(0,122,255,.6);\n box-shadow:0 0 0 1px rgba(0,122,255,.3);}\n\n .feedback{font-size:10px;margin-top:2px;min-height:12px;}\n .feedback.error{color:#ef4444;}\n .feedback.success{color:#22c55e;}\n\n .actions{display:flex;gap:4px;padding-top:8px;border-top:1px solid rgba(255,255,255,.1);}\n .settings-button{flex:1;background:rgba(255,255,255,.1);\n border:1px solid rgba(255,255,255,.2);border-radius:4px;\n color:white;padding:5px 10px;font-size:11px;cursor:pointer;transition:.15s;}\n .settings-button:hover{background:rgba(255,255,255,.15);}\n .settings-button.primary{background:rgba(0,122,255,.25);border-color:rgba(0,122,255,.6);}\n .settings-button.primary:hover{background:rgba(0,122,255,.35);}\n .settings-button.danger{background:rgba(255,59,48,.1);border-color:rgba(255,59,48,.3);\n color:rgba(255,59,48,.9);}\n .settings-button.danger:hover{background:rgba(255,59,48,.15);\n }\n\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n :host-context(body.has-glass) * {\n background: transparent !important; /* 요청한 투명 처리 */\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n outline: none !important;\n border: none !important;\n border-radius: 0 !important;\n transition: none !important;\n animation: none !important;\n }\n `;\n\n static properties = {\n shortcuts: { type: Object, state: true },\n isLoading: { type: Boolean, state: true },\n capturingKey: { type: String, state: true },\n feedback: { type:Object, state:true }\n };\n\n constructor() {\n super();\n this.shortcuts = {};\n this.feedback = {};\n this.isLoading = true;\n this.capturingKey = null;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (!window.api) return;\n this.loadShortcutsHandler = (event, keybinds) => {\n this.shortcuts = keybinds;\n this.isLoading = false;\n };\n window.api.shortcutSettingsView.onLoadShortcuts(this.loadShortcutsHandler);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api && this.loadShortcutsHandler) {\n window.api.shortcutSettingsView.removeOnLoadShortcuts(this.loadShortcutsHandler);\n }\n }\n\n handleKeydown(e, shortcutKey){\n e.preventDefault(); e.stopPropagation();\n const result = this._parseAccelerator(e);\n if(!result) return; // modifier키만 누른 상태\n \n const {accel, error} = result;\n if(error){\n this.feedback = {...this.feedback, [shortcutKey]:{type:'error',msg:error}};\n return;\n }\n // 성공\n this.shortcuts = {...this.shortcuts, [shortcutKey]:accel};\n this.feedback = {...this.feedback, [shortcutKey]:{type:'success',msg:'Shortcut set'}};\n this.stopCapture();\n }\n \n _parseAccelerator(e){\n /* returns {accel?, error?} */\n const parts=[]; if(e.metaKey) parts.push('Cmd');\n if(e.ctrlKey) parts.push('Ctrl');\n if(e.altKey) parts.push('Alt');\n if(e.shiftKey) parts.push('Shift');\n \n const isModifier=['Meta','Control','Alt','Shift'].includes(e.key);\n if(isModifier) return null;\n \n const map={ArrowUp:'Up',ArrowDown:'Down',ArrowLeft:'Left',ArrowRight:'Right',' ':'Space'};\n parts.push(e.key.length===1? e.key.toUpperCase() : (map[e.key]||e.key));\n const accel=parts.join('+');\n \n /* ---- validation ---- */\n if(parts.length===1) return {error:'Invalid shortcut: needs a modifier'};\n if(parts.length>4) return {error:'Invalid shortcut: max 4 keys'};\n if(commonSystemShortcuts.has(accel)) return {error:'Invalid shortcut: system reserved'};\n return {accel};\n }\n\n startCapture(key){ this.capturingKey = key; this.feedback = {...this.feedback, [key]:undefined}; }\n\n disableShortcut(key){\n this.shortcuts = {...this.shortcuts, [key]:''}; // 공백 => 작동 X\n this.feedback = {...this.feedback, [key]:{type:'success',msg:'Shortcut disabled'}};\n }\n\n stopCapture() {\n this.capturingKey = null;\n }\n\n async handleSave() {\n if (!window.api) return;\n this.feedback = {};\n const result = await window.api.shortcutSettingsView.saveShortcuts(this.shortcuts);\n if (!result.success) {\n alert('Failed to save shortcuts: ' + result.error);\n }\n }\n\n handleClose() {\n if (!window.api) return;\n this.feedback = {};\n window.api.shortcutSettingsView.closeShortcutSettingsWindow();\n }\n\n async handleResetToDefault() {\n if (!window.api) return;\n const confirmation = confirm(\"Are you sure you want to reset all shortcuts to their default values?\");\n if (!confirmation) return;\n \n try {\n const defaultShortcuts = await window.api.shortcutSettingsView.getDefaultShortcuts();\n this.shortcuts = defaultShortcuts;\n } catch (error) {\n alert('Failed to load default settings.');\n }\n }\n\n formatShortcutName(name) {\n if (displayNameMap[name]) {\n return displayNameMap[name];\n }\n const result = name.replace(/([A-Z])/g, \" $1\");\n return result.charAt(0).toUpperCase() + result.slice(1);\n }\n\n render(){\n if(this.isLoading){\n return html`
Loading Shortcuts...
`;\n }\n return html`\n
\n \n

Edit Shortcuts

\n \n
\n ${Object.keys(this.shortcuts).map(key=>html`\n
\n
\n ${this.formatShortcutName(key)}\n \n \n \n \n \n this.startCapture(key)}\n @keydown=${e=>this.handleKeydown(e,key)}\n @blur=${()=>this.stopCapture()}\n />\n
\n \n ${this.feedback[key] ? html`\n
\n ${this.feedback[key].msg}\n
` : html`
`\n }\n
\n `)}\n
\n \n
\n \n \n \n
\n
\n `;\n }\n }\n\ncustomElements.define('shortcut-settings-view', ShortcutSettingsView);"], ["/glass/src/ui/app/ApiKeyHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class ApiKeyHeader extends LitElement {\n //////// after_modelStateService ////////\n static properties = {\n llmApiKey: { type: String },\n sttApiKey: { type: String },\n llmProvider: { type: String },\n sttProvider: { type: String },\n isLoading: { type: Boolean },\n errorMessage: { type: String },\n successMessage: { type: String },\n providers: { type: Object, state: true },\n modelSuggestions: { type: Array, state: true },\n userModelHistory: { type: Array, state: true },\n selectedLlmModel: { type: String, state: true },\n selectedSttModel: { type: String, state: true },\n ollamaStatus: { type: Object, state: true },\n installingModel: { type: String, state: true },\n installProgress: { type: Number, state: true },\n whisperInstallingModels: { type: Object, state: true },\n backCallback: { type: Function },\n llmError: { type: String },\n sttError: { type: String },\n };\n //////// after_modelStateService ////////\n\n static styles = css`\n :host {\n display: block;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n sans-serif;\n }\n * {\n box-sizing: border-box;\n }\n .container {\n width: 100%;\n height: 100%;\n padding: 24px 16px;\n background: rgba(0, 0, 0, 0.64);\n box-shadow: 0px 0px 0px 1.5px rgba(255, 255, 255, 0.64) inset;\n border-radius: 16px;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 24px;\n display: flex;\n -webkit-app-region: drag;\n }\n .header {\n width: 100%;\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-bottom: 8px;\n }\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 16px;\n right: 16px;\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 5px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 16px;\n line-height: 1;\n padding: 0;\n }\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n .back-button {\n -webkit-app-region: no-drag;\n padding: 8px;\n left: 0px;\n top: -7px;\n position: absolute;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n border-radius: 16px;\n border: 0.5px solid rgba(255, 255, 255, 0.5);\n justify-content: center;\n align-items: center;\n gap: 4px;\n display: flex;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n .back-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .arrow-icon-left {\n border: solid #dcdcdc;\n border-width: 0 1.2px 1.2px 0;\n display: inline-block;\n padding: 3px;\n transform: rotate(135deg);\n }\n .back-button-text {\n color: white;\n font-size: 12px;\n font-weight: 500;\n padding-right: 4px;\n }\n .title {\n color: white;\n font-size: 14px;\n font-weight: 700;\n }\n .section {\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .row {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n .label {\n color: white;\n font-size: 12px;\n font-weight: 600;\n }\n .provider-selector {\n display: flex;\n width: 240px;\n overflow: hidden;\n border-radius: 12px;\n border: 0.5px solid rgba(255, 255, 255, 0.5);\n }\n .provider-button {\n -webkit-app-region: no-drag;\n padding: 4px 8px;\n background: rgba(20.4, 20.4, 20.4, 0.32);\n color: #dcdcdc;\n font-size: 11px;\n font-weight: 450;\n letter-spacing: 0.11px;\n border: none;\n cursor: pointer;\n transition: background-color 0.2s ease;\n flex: 1;\n }\n .provider-button:hover {\n background: rgba(80, 80, 80, 0.48);\n }\n .provider-button[data-status='active'] {\n background: rgba(142.8, 142.8, 142.8, 0.48);\n color: white;\n }\n .api-input {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 10px 8px;\n background: rgba(61.2, 61.2, 61.2, 0.8);\n border-radius: 6px;\n border: 1px solid rgba(255, 255, 255, 0.24);\n color: white;\n font-size: 11px;\n text-overflow: ellipsis;\n font-family: inherit;\n line-height: inherit;\n }\n .ollama-action-button {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 10px 8px;\n border-radius: 16px;\n border: none;\n color: white;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n cursor: pointer;\n text-align: center;\n transition: background-color 0.2s ease;\n }\n .ollama-action-button.install {\n background: rgba(0, 122, 255, 0.2);\n }\n .ollama-action-button.start {\n background: rgba(255, 200, 0, 0.2);\n }\n select.api-input {\n -webkit-appearance: none;\n appearance: none;\n background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e\");\n background-position: right 0.5rem center;\n background-repeat: no-repeat;\n background-size: 1.5em 1.5em;\n padding-right: 2.5rem;\n }\n select.api-input option {\n background: #333;\n color: white;\n }\n .api-input::placeholder {\n color: #a0a0a0;\n }\n .confirm-button-container {\n width: 100%;\n display: flex;\n justify-content: flex-end;\n }\n .confirm-button {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 8px;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.16);\n border-radius: 16px;\n border: 1px solid rgba(255, 255, 255, 0.5);\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n .confirm-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .confirm-button:disabled {\n background: rgba(255, 255, 255, 0.12);\n color: #bebebe;\n border: 0.5px solid rgba(255, 255, 255, 0.24);\n box-shadow: none;\n cursor: not-allowed;\n }\n .footer {\n width: 100%;\n text-align: center;\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 500;\n line-height: 18px;\n }\n .footer-link {\n text-decoration: underline;\n cursor: pointer;\n -webkit-app-region: no-drag;\n }\n .error-message,\n .success-message {\n position: absolute;\n bottom: 70px;\n left: 16px;\n right: 16px;\n text-align: center;\n font-size: 11px;\n font-weight: 500;\n padding: 4px;\n border-radius: 4px;\n }\n .error-message {\n color: rgba(239, 68, 68, 0.9);\n }\n .success-message {\n color: rgba(74, 222, 128, 0.9);\n }\n .message-fade-out {\n animation: fadeOut 3s ease-in-out forwards;\n }\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 66% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n .sliding-out {\n animation: slideOut 0.3s ease-out forwards;\n }\n @keyframes slideOut {\n from {\n transform: translateY(0);\n opacity: 1;\n }\n to {\n transform: translateY(-100%);\n opacity: 0;\n }\n }\n .api-input.invalid {\n outline: 1px solid #ff7070;\n outline-offset: -1px;\n }\n .input-wrapper {\n display: flex;\n flex-direction: column;\n gap: 4px;\n align-items: flex-start;\n }\n .inline-error-message {\n color: #ff7070;\n font-size: 11px;\n font-weight: 400;\n letter-spacing: 0.11px;\n word-wrap: break-word;\n width: 240px;\n }\n `;\n\n\n constructor() {\n super();\n this.isLoading = false;\n this.errorMessage = '';\n this.successMessage = '';\n this.messageTimestamp = 0;\n //////// after_modelStateService ////////\n this.llmApiKey = '';\n this.sttApiKey = '';\n this.llmProvider = 'openai';\n this.sttProvider = 'openai';\n this.providers = { llm: [], stt: [] }; // 초기화\n // Ollama related\n this.modelSuggestions = [];\n this.userModelHistory = [];\n this.selectedLlmModel = '';\n this.selectedSttModel = '';\n this.ollamaStatus = { installed: false, running: false };\n this.installingModel = null;\n this.installProgress = 0;\n this.whisperInstallingModels = {};\n this.backCallback = () => {};\n this.llmError = '';\n this.sttError = '';\n\n // Professional operation management system\n this.activeOperations = new Map();\n this.operationTimeouts = new Map();\n this.connectionState = 'idle'; // idle, connecting, connected, failed, disconnected\n this.lastStateChange = Date.now();\n this.retryCount = 0;\n this.maxRetries = 3;\n this.baseRetryDelay = 1000;\n\n // Backpressure and resource management\n this.operationQueue = [];\n this.maxConcurrentOperations = 2;\n this.maxQueueSize = 5;\n this.operationMetrics = {\n totalOperations: 0,\n successfulOperations: 0,\n failedOperations: 0,\n timeouts: 0,\n averageResponseTime: 0,\n };\n\n // Configuration\n this.ipcTimeout = 10000; // 10s for IPC calls\n this.operationTimeout = 15000; // 15s for complex operations\n\n // Health monitoring system\n this.healthCheck = {\n enabled: false,\n intervalId: null,\n intervalMs: 30000, // 30s\n lastCheck: 0,\n consecutiveFailures: 0,\n maxFailures: 3,\n };\n\n // Load user model history from localStorage\n this.loadUserModelHistory();\n this.loadProviderConfig();\n //////// after_modelStateService ////////\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleInput = this.handleInput.bind(this);\n this.handleAnimationEnd = this.handleAnimationEnd.bind(this);\n this.handleProviderChange = this.handleProviderChange.bind(this);\n this.handleLlmProviderChange = this.handleLlmProviderChange.bind(this);\n this.handleSttProviderChange = this.handleSttProviderChange.bind(this);\n this.handleMessageFadeEnd = this.handleMessageFadeEnd.bind(this);\n this.handleModelKeyPress = this.handleModelKeyPress.bind(this);\n this.handleSttModelChange = this.handleSttModelChange.bind(this);\n this.handleBack = this.handleBack.bind(this);\n this.handleClose = this.handleClose.bind(this);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.dispatchEvent(new CustomEvent('content-changed', { bubbles: true, composed: true }));\n }\n\n reset() {\n this.apiKey = '';\n this.isLoading = false;\n this.errorMessage = '';\n this.validatedApiKey = null;\n this.selectedProvider = 'openai';\n this.requestUpdate();\n }\n\n handleBack() {\n if (this.backCallback) {\n this.backCallback();\n }\n }\n\n async loadProviderConfig() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n const [config, ollamaStatus] = await Promise.all([\n window.api.apiKeyHeader.getProviderConfig(),\n window.api.apiKeyHeader.getOllamaStatus(),\n ]);\n\n const llmProviders = [];\n const sttProviders = [];\n\n for (const id in config) {\n // 'openai-glass' 같은 가상 Provider는 UI에 표시하지 않음\n if (id.includes('-glass')) continue;\n const hasLlmModels = config[id].llmModels.length > 0 || id === 'ollama';\n const hasSttModels = config[id].sttModels.length > 0 || id === 'whisper';\n\n if (hasLlmModels) {\n llmProviders.push({ id, name: config[id].name });\n }\n if (hasSttModels) {\n sttProviders.push({ id, name: config[id].name });\n }\n }\n\n this.providers = { llm: llmProviders, stt: sttProviders };\n\n // 기본 선택 값 설정\n if (llmProviders.length > 0) this.llmProvider = llmProviders[0].id;\n if (sttProviders.length > 0) this.sttProvider = sttProviders[0].id;\n\n // Ollama 상태 및 모델 제안 로드\n if (ollamaStatus?.success) {\n this.ollamaStatus = {\n installed: ollamaStatus.installed,\n running: ollamaStatus.running,\n };\n\n // Load model suggestions if Ollama is running\n if (ollamaStatus.running) {\n await this.loadModelSuggestions();\n }\n }\n\n this.requestUpdate();\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load provider config:', error);\n }\n }\n\n async handleMouseDown(e) {\n if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON' || e.target.tagName === 'SELECT') {\n return;\n }\n\n e.preventDefault();\n\n if (!window.api?.apiKeyHeader) return;\n const initialPosition = await window.api.apiKeyHeader.getHeaderPosition();\n\n this.dragState = {\n initialMouseX: e.screenX,\n initialMouseY: e.screenY,\n initialWindowX: initialPosition.x,\n initialWindowY: initialPosition.y,\n moved: false,\n };\n\n window.addEventListener('mousemove', this.handleMouseMove);\n window.addEventListener('mouseup', this.handleMouseUp, { once: true });\n }\n\n handleMouseMove(e) {\n if (!this.dragState) return;\n\n const deltaX = Math.abs(e.screenX - this.dragState.initialMouseX);\n const deltaY = Math.abs(e.screenY - this.dragState.initialMouseY);\n\n if (deltaX > 3 || deltaY > 3) {\n this.dragState.moved = true;\n }\n\n const newWindowX = this.dragState.initialWindowX + (e.screenX - this.dragState.initialMouseX);\n const newWindowY = this.dragState.initialWindowY + (e.screenY - this.dragState.initialMouseY);\n\n if (window.api?.apiKeyHeader) {\n window.api.apiKeyHeader.moveHeaderTo(newWindowX, newWindowY);\n }\n }\n\n handleMouseUp(e) {\n if (!this.dragState) return;\n\n const wasDragged = this.dragState.moved;\n\n window.removeEventListener('mousemove', this.handleMouseMove);\n this.dragState = null;\n\n if (wasDragged) {\n this.wasJustDragged = true;\n setTimeout(() => {\n this.wasJustDragged = false;\n }, 200);\n }\n }\n\n handleInput(e) {\n this.apiKey = e.target.value;\n this.clearMessages();\n console.log('Input changed:', this.apiKey?.length || 0, 'chars');\n\n this.requestUpdate();\n this.updateComplete.then(() => {\n const inputField = this.shadowRoot?.querySelector('.apikey-input');\n if (inputField && this.isInputFocused) {\n inputField.focus();\n }\n });\n }\n\n clearMessages() {\n this.errorMessage = '';\n this.successMessage = '';\n this.messageTimestamp = 0;\n this.llmError = '';\n this.sttError = '';\n }\n\n handleProviderChange(e) {\n this.selectedProvider = e.target.value;\n this.clearMessages();\n console.log('Provider changed to:', this.selectedProvider);\n this.requestUpdate();\n }\n\n async handleLlmProviderChange(e, providerId) {\n const newProvider = providerId || e.target.value;\n if (newProvider === this.llmProvider) return;\n\n // Cancel any active operations first\n this._cancelAllActiveOperations();\n\n this.llmProvider = newProvider;\n this.errorMessage = '';\n this.successMessage = '';\n\n if (['openai', 'gemini'].includes(this.llmProvider)) {\n this.sttProvider = this.llmProvider;\n }\n\n // Reset retry state\n this.retryCount = 0;\n\n if (this.llmProvider === 'ollama') {\n console.log('[ApiKeyHeader] Ollama selected, initiating connection...');\n await this._initializeOllamaConnection();\n // Start health monitoring for Ollama\n this._startHealthMonitoring();\n } else {\n this._updateConnectionState('idle', 'Non-Ollama provider selected');\n // Stop health monitoring for non-Ollama providers\n this._stopHealthMonitoring();\n }\n\n this.requestUpdate();\n }\n\n async _initializeOllamaConnection() {\n try {\n // Progressive connection attempt with exponential backoff\n await this._attemptOllamaConnection();\n } catch (error) {\n console.error('[ApiKeyHeader] Initial Ollama connection failed:', error.message);\n\n if (this.retryCount < this.maxRetries) {\n const delay = this.baseRetryDelay * Math.pow(2, this.retryCount);\n console.log(`[ApiKeyHeader] Retrying Ollama connection in ${delay}ms (attempt ${this.retryCount + 1}/${this.maxRetries})`);\n\n this.retryCount++;\n\n // Use proper Promise-based delay instead of setTimeout\n await new Promise(resolve => {\n const retryTimeoutId = setTimeout(() => {\n this._initializeOllamaConnection();\n resolve();\n }, delay);\n\n // Store timeout for cleanup\n this.operationTimeouts.set(`retry_${this.retryCount}`, retryTimeoutId);\n });\n } else {\n this._updateConnectionState('failed', `Connection failed after ${this.maxRetries} attempts`);\n }\n }\n }\n\n async _attemptOllamaConnection() {\n await this.refreshOllamaStatus();\n }\n\n _cancelAllActiveOperations() {\n console.log(`[ApiKeyHeader] Cancelling ${this.activeOperations.size} active operations and ${this.operationQueue.length} queued operations`);\n\n // Cancel active operations\n for (const [operationType, operation] of this.activeOperations) {\n this._cancelOperation(operationType);\n }\n\n // Cancel queued operations\n for (const queuedOp of this.operationQueue) {\n queuedOp.reject(new Error(`Operation ${queuedOp.type} cancelled during cleanup`));\n }\n this.operationQueue.length = 0;\n\n // Clean up all timeouts\n for (const [timeoutId, timeout] of this.operationTimeouts) {\n clearTimeout(timeout);\n }\n this.operationTimeouts.clear();\n }\n\n /**\n * Get operation metrics for monitoring\n */\n getOperationMetrics() {\n return {\n ...this.operationMetrics,\n activeOperations: this.activeOperations.size,\n queuedOperations: this.operationQueue.length,\n successRate:\n this.operationMetrics.totalOperations > 0\n ? (this.operationMetrics.successfulOperations / this.operationMetrics.totalOperations) * 100\n : 0,\n };\n }\n\n /**\n * Adaptive backpressure based on system performance\n */\n _adjustBackpressureThresholds() {\n const metrics = this.getOperationMetrics();\n\n // Reduce concurrent operations if success rate is low\n if (metrics.successRate < 70 && this.maxConcurrentOperations > 1) {\n this.maxConcurrentOperations = Math.max(1, this.maxConcurrentOperations - 1);\n console.log(\n `[ApiKeyHeader] Reduced max concurrent operations to ${this.maxConcurrentOperations} (success rate: ${metrics.successRate.toFixed(1)}%)`\n );\n }\n\n // Increase if performance is good\n if (metrics.successRate > 90 && metrics.averageResponseTime < 3000 && this.maxConcurrentOperations < 3) {\n this.maxConcurrentOperations++;\n console.log(`[ApiKeyHeader] Increased max concurrent operations to ${this.maxConcurrentOperations}`);\n }\n }\n\n /**\n * Professional health monitoring system\n */\n _startHealthMonitoring() {\n if (this.healthCheck.enabled) return;\n\n this.healthCheck.enabled = true;\n this.healthCheck.intervalId = setInterval(() => {\n this._performHealthCheck();\n }, this.healthCheck.intervalMs);\n\n console.log(`[ApiKeyHeader] Health monitoring started (interval: ${this.healthCheck.intervalMs}ms)`);\n }\n\n _stopHealthMonitoring() {\n if (!this.healthCheck.enabled) return;\n\n this.healthCheck.enabled = false;\n if (this.healthCheck.intervalId) {\n clearInterval(this.healthCheck.intervalId);\n this.healthCheck.intervalId = null;\n }\n\n console.log('[ApiKeyHeader] Health monitoring stopped');\n }\n\n async _performHealthCheck() {\n // Only perform health check if Ollama is selected and we're in a stable state\n if (this.llmProvider !== 'ollama' || this.connectionState === 'connecting') {\n return;\n }\n\n const now = Date.now();\n this.healthCheck.lastCheck = now;\n\n try {\n // Lightweight health check - just ping the service\n const isHealthy = await this._executeOperation(\n 'health_check',\n async () => {\n if (!window.api?.apiKeyHeader) return false;\n const result = await window.api.apiKeyHeader.getOllamaStatus();\n return result?.success && result?.running;\n },\n { timeout: 5000, priority: 'low' }\n );\n\n if (isHealthy) {\n this.healthCheck.consecutiveFailures = 0;\n\n // Update state if we were previously failed\n if (this.connectionState === 'failed') {\n this._updateConnectionState('connected', 'Health check recovered');\n }\n } else {\n this._handleHealthCheckFailure();\n }\n\n // Adjust thresholds based on performance\n this._adjustBackpressureThresholds();\n } catch (error) {\n console.warn('[ApiKeyHeader] Health check failed:', error.message);\n this._handleHealthCheckFailure();\n }\n }\n\n _handleHealthCheckFailure() {\n this.healthCheck.consecutiveFailures++;\n\n if (this.healthCheck.consecutiveFailures >= this.healthCheck.maxFailures) {\n console.warn(`[ApiKeyHeader] Health check failed ${this.healthCheck.consecutiveFailures} times, marking as disconnected`);\n this._updateConnectionState('failed', 'Service health check failed');\n\n // Increase health check frequency when having issues\n this.healthCheck.intervalMs = Math.max(10000, this.healthCheck.intervalMs / 2);\n this._restartHealthMonitoring();\n }\n }\n\n _restartHealthMonitoring() {\n this._stopHealthMonitoring();\n this._startHealthMonitoring();\n }\n\n /**\n * Get comprehensive health status\n */\n getHealthStatus() {\n return {\n connection: {\n state: this.connectionState,\n lastStateChange: this.lastStateChange,\n timeSinceLastChange: Date.now() - this.lastStateChange,\n },\n operations: this.getOperationMetrics(),\n health: {\n enabled: this.healthCheck.enabled,\n lastCheck: this.healthCheck.lastCheck,\n timeSinceLastCheck: this.healthCheck.lastCheck > 0 ? Date.now() - this.healthCheck.lastCheck : null,\n consecutiveFailures: this.healthCheck.consecutiveFailures,\n intervalMs: this.healthCheck.intervalMs,\n },\n ollama: {\n provider: this.llmProvider,\n status: this.ollamaStatus,\n selectedModel: this.selectedLlmModel,\n },\n };\n }\n\n async handleSttProviderChange(e, providerId) {\n const newProvider = providerId || e.target.value;\n if (newProvider === this.sttProvider) return;\n\n this.sttProvider = newProvider;\n this.errorMessage = '';\n this.successMessage = '';\n\n if (this.sttProvider === 'ollama') {\n console.warn('[ApiKeyHeader] Ollama does not support STT yet. Please select Whisper or another provider.');\n this.sttError = '*Ollama does not support STT yet. Please select Whisper or another STT provider.';\n this.messageTimestamp = Date.now();\n\n // Auto-select Whisper if available\n const whisperProvider = this.providers.stt.find(p => p.id === 'whisper');\n if (whisperProvider) {\n this.sttProvider = 'whisper';\n console.log('[ApiKeyHeader] Auto-selected Whisper for STT');\n }\n }\n\n this.requestUpdate();\n }\n\n /**\n * Professional operation management with backpressure control\n */\n async _executeOperation(operationType, operation, options = {}) {\n const operationId = `${operationType}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n const timeout = options.timeout || this.ipcTimeout;\n const priority = options.priority || 'normal'; // high, normal, low\n\n // Backpressure control\n if (this.activeOperations.size >= this.maxConcurrentOperations) {\n if (this.operationQueue.length >= this.maxQueueSize) {\n throw new Error(`Operation queue full (${this.maxQueueSize}), rejecting ${operationType}`);\n }\n\n console.log(`[ApiKeyHeader] Queuing operation ${operationType} (${this.activeOperations.size} active)`);\n return this._queueOperation(operationId, operationType, operation, options);\n }\n\n return this._executeImmediately(operationId, operationType, operation, timeout);\n }\n\n async _queueOperation(operationId, operationType, operation, options) {\n return new Promise((resolve, reject) => {\n const queuedOperation = {\n id: operationId,\n type: operationType,\n operation,\n options,\n resolve,\n reject,\n queuedAt: Date.now(),\n priority: options.priority || 'normal',\n };\n\n // Insert based on priority (high priority first)\n if (options.priority === 'high') {\n this.operationQueue.unshift(queuedOperation);\n } else {\n this.operationQueue.push(queuedOperation);\n }\n\n console.log(`[ApiKeyHeader] Queued ${operationType} (queue size: ${this.operationQueue.length})`);\n });\n }\n\n async _executeImmediately(operationId, operationType, operation, timeout) {\n const startTime = Date.now();\n this.operationMetrics.totalOperations++;\n\n // Check if similar operation is already running\n if (this.activeOperations.has(operationType)) {\n console.log(`[ApiKeyHeader] Operation ${operationType} already in progress, cancelling previous`);\n this._cancelOperation(operationType);\n }\n\n // Create cancellation mechanism\n const cancellationPromise = new Promise((_, reject) => {\n const timeoutId = setTimeout(() => {\n this.operationMetrics.timeouts++;\n reject(new Error(`Operation ${operationType} timeout after ${timeout}ms`));\n }, timeout);\n\n this.operationTimeouts.set(operationId, timeoutId);\n });\n\n const operationPromise = Promise.race([operation(), cancellationPromise]);\n\n this.activeOperations.set(operationType, {\n id: operationId,\n promise: operationPromise,\n startTime,\n });\n\n try {\n const result = await operationPromise;\n this._recordOperationSuccess(startTime);\n return result;\n } catch (error) {\n this._recordOperationFailure(error, operationType);\n throw error;\n } finally {\n this._cleanupOperation(operationId, operationType);\n this._processQueue();\n }\n }\n\n _recordOperationSuccess(startTime) {\n this.operationMetrics.successfulOperations++;\n const responseTime = Date.now() - startTime;\n this._updateAverageResponseTime(responseTime);\n }\n\n _recordOperationFailure(error, operationType) {\n this.operationMetrics.failedOperations++;\n\n if (error.message.includes('timeout')) {\n console.error(`[ApiKeyHeader] Operation ${operationType} timed out`);\n this._updateConnectionState('failed', `Timeout: ${error.message}`);\n }\n }\n\n _updateAverageResponseTime(responseTime) {\n const totalOps = this.operationMetrics.successfulOperations;\n this.operationMetrics.averageResponseTime = (this.operationMetrics.averageResponseTime * (totalOps - 1) + responseTime) / totalOps;\n }\n\n async _processQueue() {\n if (this.operationQueue.length === 0 || this.activeOperations.size >= this.maxConcurrentOperations) {\n return;\n }\n\n const queuedOp = this.operationQueue.shift();\n if (!queuedOp) return;\n\n const queueTime = Date.now() - queuedOp.queuedAt;\n console.log(`[ApiKeyHeader] Processing queued operation ${queuedOp.type} (waited ${queueTime}ms)`);\n\n try {\n const result = await this._executeImmediately(\n queuedOp.id,\n queuedOp.type,\n queuedOp.operation,\n queuedOp.options.timeout || this.ipcTimeout\n );\n queuedOp.resolve(result);\n } catch (error) {\n queuedOp.reject(error);\n }\n }\n\n _cancelOperation(operationType) {\n const operation = this.activeOperations.get(operationType);\n if (operation) {\n this._cleanupOperation(operation.id, operationType);\n console.log(`[ApiKeyHeader] Cancelled operation: ${operationType}`);\n }\n }\n\n _cleanupOperation(operationId, operationType) {\n if (this.operationTimeouts.has(operationId)) {\n clearTimeout(this.operationTimeouts.get(operationId));\n this.operationTimeouts.delete(operationId);\n }\n this.activeOperations.delete(operationType);\n }\n\n _updateConnectionState(newState, reason = '') {\n if (this.connectionState !== newState) {\n console.log(`[ApiKeyHeader] Connection state: ${this.connectionState} -> ${newState} (${reason})`);\n this.connectionState = newState;\n this.lastStateChange = Date.now();\n\n // Update UI based on state\n this._handleStateChange(newState, reason);\n }\n }\n\n _handleStateChange(state, reason) {\n switch (state) {\n case 'connecting':\n this.installingModel = 'Connecting to Ollama...';\n this.installProgress = 10;\n break;\n case 'failed':\n this.errorMessage = reason || 'Connection failed';\n this.installingModel = null;\n this.installProgress = 0;\n this.messageTimestamp = Date.now();\n break;\n case 'connected':\n this.installingModel = null;\n this.installProgress = 0;\n break;\n case 'disconnected':\n this.ollamaStatus = { installed: false, running: false };\n break;\n }\n this.requestUpdate();\n }\n\n async refreshOllamaStatus() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n this._updateConnectionState('connecting', 'Checking Ollama status');\n\n const result = await this._executeOperation('ollama_status', async () => {\n return await window.api.apiKeyHeader.getOllamaStatus();\n });\n\n if (result?.success) {\n this.ollamaStatus = {\n installed: result.installed,\n running: result.running,\n };\n\n this._updateConnectionState('connected', 'Status updated successfully');\n\n // Load model suggestions if Ollama is running\n if (result.running) {\n await this.loadModelSuggestions();\n }\n } else {\n this._updateConnectionState('failed', result?.error || 'Status check failed');\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to refresh Ollama status:', error.message);\n this._updateConnectionState('failed', error.message);\n }\n }\n\n async loadModelSuggestions() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n const result = await this._executeOperation('model_suggestions', async () => {\n return await window.api.apiKeyHeader.getModelSuggestions();\n });\n\n if (result?.success) {\n this.modelSuggestions = result.suggestions || [];\n\n // 기본 모델 선택 (설치된 모델 중 첫 번째)\n if (!this.selectedLlmModel && this.modelSuggestions.length > 0) {\n const installedModel = this.modelSuggestions.find(m => m.status === 'installed');\n if (installedModel) {\n this.selectedLlmModel = installedModel.name;\n }\n }\n this.requestUpdate();\n } else {\n console.warn('[ApiKeyHeader] Model suggestions request unsuccessful:', result?.error);\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load model suggestions:', error.message);\n }\n }\n\n async ensureOllamaReady() {\n if (!window.api?.apiKeyHeader) return false;\n\n try {\n this._updateConnectionState('connecting', 'Ensuring Ollama is ready');\n\n const result = await this._executeOperation(\n 'ollama_ensure_ready',\n async () => {\n return await window.api.apiKeyHeader.ensureOllamaReady();\n },\n { timeout: this.operationTimeout }\n );\n\n if (result?.success) {\n await this.refreshOllamaStatus();\n this._updateConnectionState('connected', 'Ollama ready');\n return true;\n } else {\n const errorMsg = `Failed to setup Ollama: ${result?.error || 'Unknown error'}`;\n this._updateConnectionState('failed', errorMsg);\n return false;\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to ensure Ollama ready:', error.message);\n this._updateConnectionState('failed', `Error setting up Ollama: ${error.message}`);\n return false;\n }\n }\n\n async ensureOllamaReadyWithUI() {\n if (!window.api?.apiKeyHeader) return false;\n\n this.installingModel = 'Setting up Ollama';\n this.installProgress = 0;\n this.clearMessages();\n this.requestUpdate();\n\n const progressHandler = (event, data) => {\n // 통합 LocalAI 이벤트에서 Ollama 진행률만 처리\n if (data.service !== 'ollama') return;\n \n let baseProgress = 0;\n let stageTotal = 0;\n\n switch (data.stage) {\n case 'downloading':\n baseProgress = 0;\n stageTotal = 70;\n break;\n case 'mounting':\n baseProgress = 70;\n stageTotal = 10;\n break;\n case 'installing':\n baseProgress = 80;\n stageTotal = 10;\n break;\n case 'linking':\n baseProgress = 90;\n stageTotal = 5;\n break;\n case 'cleanup':\n baseProgress = 95;\n stageTotal = 3;\n break;\n case 'starting':\n baseProgress = 98;\n stageTotal = 2;\n break;\n }\n\n const overallProgress = baseProgress + (data.progress / 100) * stageTotal;\n\n this.installingModel = data.message;\n this.installProgress = Math.round(overallProgress);\n this.requestUpdate();\n };\n\n let operationCompleted = false;\n const completionTimeout = setTimeout(async () => {\n if (!operationCompleted) {\n console.log('[ApiKeyHeader] Operation timeout, checking status manually...');\n await this._handleOllamaSetupCompletion(true);\n }\n }, 15000); // 15 second timeout\n\n const completionHandler = async (event, data) => {\n // 통합 LocalAI 이벤트에서 Ollama 완료만 처리\n if (data.service !== 'ollama') return;\n if (operationCompleted) return;\n operationCompleted = true;\n clearTimeout(completionTimeout);\n\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n // installation-complete 이벤트는 성공을 의미\n await this._handleOllamaSetupCompletion(true);\n };\n\n // 통합 LocalAI 이벤트 사용\n window.api.apiKeyHeader.onLocalAIComplete(completionHandler);\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n try {\n let result;\n if (!this.ollamaStatus.installed) {\n console.log('[ApiKeyHeader] Ollama not installed. Starting installation.');\n result = await window.api.apiKeyHeader.installOllama();\n } else {\n console.log('[ApiKeyHeader] Ollama installed. Starting service.');\n result = await window.api.apiKeyHeader.startOllamaService();\n }\n\n // If IPC call succeeds but no event received, handle completion manually\n if (result?.success && !operationCompleted) {\n setTimeout(async () => {\n if (!operationCompleted) {\n operationCompleted = true;\n clearTimeout(completionTimeout);\n await this._handleOllamaSetupCompletion(true);\n }\n }, 2000);\n }\n } catch (error) {\n operationCompleted = true;\n clearTimeout(completionTimeout);\n console.error('[ApiKeyHeader] Ollama setup failed:', error);\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n window.api.apiKeyHeader.removeOnLocalAIComplete(completionHandler);\n await this._handleOllamaSetupCompletion(false, error.message);\n }\n }\n\n async _handleOllamaSetupCompletion(success, errorMessage = null) {\n this.installingModel = null;\n this.installProgress = 0;\n\n if (success) {\n await this.refreshOllamaStatus();\n this.successMessage = '✓ Ollama is ready!';\n } else {\n this.llmError = `*Setup failed: ${errorMessage || 'Unknown error'}`;\n }\n this.messageTimestamp = Date.now();\n this.requestUpdate();\n }\n\n async handleModelInput(e) {\n const modelName = e.target.value.trim();\n this.selectedLlmModel = modelName;\n this.clearMessages();\n\n // Save to user history if it's a valid model name\n if (modelName && modelName.length > 2) {\n this.saveToUserHistory(modelName);\n }\n\n this.requestUpdate();\n }\n\n async handleModelKeyPress(e) {\n if (e.key === 'Enter' && this.selectedLlmModel?.trim()) {\n e.preventDefault();\n console.log(`[ApiKeyHeader] Enter pressed, installing model: ${this.selectedLlmModel}`);\n\n // Check if Ollama is ready first\n const ollamaReady = await this.ensureOllamaReady();\n if (!ollamaReady) {\n this.llmError = '*Failed to setup Ollama';\n this.messageTimestamp = Date.now();\n this.requestUpdate();\n return;\n }\n\n // Install the model\n await this.installModel(this.selectedLlmModel);\n }\n }\n\n loadUserModelHistory() {\n try {\n const saved = localStorage.getItem('ollama-model-history');\n if (saved) {\n this.userModelHistory = JSON.parse(saved);\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load model history:', error);\n this.userModelHistory = [];\n }\n }\n\n saveToUserHistory(modelName) {\n if (!modelName || !modelName.trim()) return;\n\n // Remove if already exists (to move to front)\n this.userModelHistory = this.userModelHistory.filter(m => m !== modelName);\n\n // Add to front\n this.userModelHistory.unshift(modelName);\n\n // Keep only last 20 entries\n this.userModelHistory = this.userModelHistory.slice(0, 20);\n\n // Save to localStorage\n try {\n localStorage.setItem('ollama-model-history', JSON.stringify(this.userModelHistory));\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to save model history:', error);\n }\n }\n\n getCombinedModelSuggestions() {\n const combined = [];\n\n // Add installed models first (from Ollama CLI)\n for (const model of this.modelSuggestions) {\n combined.push({\n name: model.name,\n status: 'installed',\n size: model.size || 'Unknown',\n source: 'installed',\n });\n }\n\n // Add user history models that aren't already installed\n const installedNames = this.modelSuggestions.map(m => m.name);\n for (const modelName of this.userModelHistory) {\n if (!installedNames.includes(modelName)) {\n combined.push({\n name: modelName,\n status: 'history',\n size: 'Unknown',\n source: 'history',\n });\n }\n }\n\n return combined;\n }\n\n async installModel(modelName) {\n if (!modelName?.trim()) {\n throw new Error('Invalid model name');\n }\n\n this.installingModel = modelName;\n this.installProgress = 0;\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) return;\n let progressHandler = null;\n\n try {\n console.log(`[ApiKeyHeader] Installing model via Ollama REST API: ${modelName}`);\n\n // Create robust progress handler with timeout protection\n progressHandler = (event, data) => {\n if (data.service === 'ollama' && data.model === modelName && !this._isOperationCancelled(modelName)) {\n const progress = Math.round(Math.max(0, Math.min(100, data.progress || 0)));\n\n if (progress !== this.installProgress) {\n this.installProgress = progress;\n console.log(`[ApiKeyHeader] API Progress: ${progress}% for ${modelName} (${data.status || 'downloading'})`);\n this.requestUpdate();\n }\n }\n };\n\n // Set up progress tracking - 통합 LocalAI 이벤트 사용\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n // Execute the model pull with timeout\n const installPromise = window.api.apiKeyHeader.pullOllamaModel(modelName);\n const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Installation timeout after 10 minutes')), 600000));\n\n const result = await Promise.race([installPromise, timeoutPromise]);\n\n if (result.success) {\n console.log(`[ApiKeyHeader] Model ${modelName} installed successfully via API`);\n this.installProgress = 100;\n this.requestUpdate();\n\n // Brief pause to show completion\n await new Promise(resolve => setTimeout(resolve, 300));\n\n // Refresh status and show success\n await this.refreshOllamaStatus();\n this.successMessage = `✓ ${modelName} ready`;\n this.messageTimestamp = Date.now();\n } else {\n throw new Error(result.error || 'Installation failed');\n }\n } catch (error) {\n console.error(`[ApiKeyHeader] Model installation failed:`, error);\n this.llmError = `*Failed: ${error.message}`;\n this.messageTimestamp = Date.now();\n } finally {\n // Comprehensive cleanup\n if (progressHandler) {\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n }\n\n this.installingModel = null;\n this.installProgress = 0;\n this.requestUpdate();\n }\n }\n\n _isOperationCancelled(modelName) {\n return !this.installingModel || this.installingModel !== modelName;\n }\n\n async downloadWhisperModel(modelId) {\n if (!modelId?.trim()) {\n console.warn('[ApiKeyHeader] Invalid Whisper model ID');\n return;\n }\n\n console.log(`[ApiKeyHeader] Starting Whisper model download: ${modelId}`);\n\n // Mark as installing\n this.whisperInstallingModels = { ...this.whisperInstallingModels, [modelId]: 0 };\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) return;\n let progressHandler = null;\n\n try {\n // Set up robust progress listener - 통합 LocalAI 이벤트 사용\n progressHandler = (event, data) => {\n if (data.service === 'whisper' && data.model === modelId) {\n const cleanProgress = Math.round(Math.max(0, Math.min(100, data.progress || 0)));\n this.whisperInstallingModels = { ...this.whisperInstallingModels, [modelId]: cleanProgress };\n console.log(`[ApiKeyHeader] Whisper download progress: ${cleanProgress}% for ${modelId}`);\n this.requestUpdate();\n }\n };\n\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n // Start download with timeout protection\n const downloadPromise = window.api.apiKeyHeader.downloadWhisperModel(modelId);\n const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Download timeout after 10 minutes')), 600000));\n\n const result = await Promise.race([downloadPromise, timeoutPromise]);\n\n if (result?.success) {\n this.successMessage = `✓ ${modelId} downloaded successfully`;\n this.messageTimestamp = Date.now();\n console.log(`[ApiKeyHeader] Whisper model ${modelId} downloaded successfully`);\n\n // Auto-select the downloaded model\n this.selectedSttModel = modelId;\n } else {\n this.sttError = `*Failed to download ${modelId}: ${result?.error || 'Unknown error'}`;\n this.messageTimestamp = Date.now();\n console.error(`[ApiKeyHeader] Whisper download failed:`, result?.error);\n }\n } catch (error) {\n console.error(`[ApiKeyHeader] Error downloading Whisper model ${modelId}:`, error);\n this.sttError = `*Error downloading ${modelId}: ${error.message}`;\n this.messageTimestamp = Date.now();\n } finally {\n // Cleanup\n if (progressHandler) {\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n }\n delete this.whisperInstallingModels[modelId];\n this.requestUpdate();\n }\n }\n\n handlePaste(e) {\n e.preventDefault();\n this.clearMessages();\n const clipboardText = (e.clipboardData || window.clipboardData).getData('text');\n console.log('Paste event detected:', clipboardText?.substring(0, 10) + '...');\n\n if (clipboardText) {\n this.apiKey = clipboardText.trim();\n\n const inputElement = e.target;\n inputElement.value = this.apiKey;\n }\n\n this.requestUpdate();\n this.updateComplete.then(() => {\n const inputField = this.shadowRoot?.querySelector('.apikey-input');\n if (inputField) {\n inputField.focus();\n inputField.setSelectionRange(inputField.value.length, inputField.value.length);\n }\n });\n }\n\n handleKeyPress(e) {\n if (e.key === 'Enter') {\n e.preventDefault();\n this.handleSubmit();\n }\n }\n\n //////// after_modelStateService ////////\n async handleSttModelChange(e) {\n const modelId = e.target.value;\n this.selectedSttModel = modelId;\n\n if (modelId && this.sttProvider === 'whisper') {\n // Check if model needs to be downloaded\n const isInstalling = this.whisperInstallingModels[modelId] !== undefined;\n if (!isInstalling) {\n console.log(`[ApiKeyHeader] Auto-installing Whisper model: ${modelId}`);\n await this.downloadWhisperModel(modelId);\n }\n }\n\n this.requestUpdate();\n }\n\n async handleSubmit() {\n console.log('[ApiKeyHeader] handleSubmit: Submitting...');\n\n this.isLoading = true;\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) {\n this.isLoading = false;\n this.llmError = '*API bridge not available';\n this.requestUpdate();\n return;\n }\n\n try {\n // Handle LLM provider\n let llmResult;\n if (this.llmProvider === 'ollama') {\n // For Ollama ensure it's ready and validate model selection\n if (!this.selectedLlmModel?.trim()) {\n throw new Error('Please enter an Ollama model name');\n }\n\n const ollamaReady = await this.ensureOllamaReady();\n if (!ollamaReady) {\n throw new Error('Failed to setup Ollama');\n }\n\n // Check if model is installed, if not install it\n const selectedModel = this.getCombinedModelSuggestions().find(m => m.name === this.selectedLlmModel);\n if (!selectedModel || selectedModel.status !== 'installed') {\n console.log(`[ApiKeyHeader] Installing model ${this.selectedLlmModel}...`);\n await this.installModel(this.selectedLlmModel);\n }\n\n // Validate Ollama is working\n llmResult = await window.api.apiKeyHeader.validateKey({\n provider: 'ollama',\n key: 'local',\n });\n\n if (llmResult.success) {\n // Set the selected model\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'llm',\n modelId: this.selectedLlmModel,\n });\n }\n } else {\n // For other providers, validate API key\n if (!this.llmApiKey.trim()) {\n throw new Error('Please enter LLM API key');\n }\n\n llmResult = await window.api.apiKeyHeader.validateKey({\n provider: this.llmProvider,\n key: this.llmApiKey.trim(),\n });\n\n if (llmResult.success) {\n const config = await window.api.apiKeyHeader.getProviderConfig();\n const providerConfig = config[this.llmProvider];\n if (providerConfig && providerConfig.llmModels.length > 0) {\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'llm',\n modelId: providerConfig.llmModels[0].id,\n });\n }\n }\n }\n\n // Handle STT provider\n let sttResult;\n if (this.sttProvider === 'ollama') {\n // Ollama doesn't support STT yet, so skip or use same as LLM validation\n sttResult = { success: true };\n } else if (this.sttProvider === 'whisper') {\n // For Whisper, just validate it's enabled (model download already handled in handleSttModelChange)\n sttResult = await window.api.apiKeyHeader.validateKey({\n provider: 'whisper',\n key: 'local',\n });\n\n if (sttResult.success && this.selectedSttModel) {\n // Set the selected model\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'stt',\n modelId: this.selectedSttModel,\n });\n }\n } else {\n // For other providers, validate API key\n if (!this.sttApiKey.trim()) {\n throw new Error('Please enter STT API key');\n }\n\n sttResult = await window.api.apiKeyHeader.validateKey({\n provider: this.sttProvider,\n key: this.sttApiKey.trim(),\n });\n\n if (sttResult.success) {\n const config = await window.api.apiKeyHeader.getProviderConfig();\n const providerConfig = config[this.sttProvider];\n if (providerConfig && providerConfig.sttModels.length > 0) {\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'stt',\n modelId: providerConfig.sttModels[0].id,\n });\n }\n }\n }\n\n if (llmResult.success && sttResult.success) {\n console.log('[ApiKeyHeader] handleSubmit: Validation successful.');\n \n // Force refresh the model state to ensure areProvidersConfigured returns true\n setTimeout(async () => {\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n console.log('[ApiKeyHeader] Post-validation providers configured check:', isConfigured);\n \n if (isConfigured) {\n this.startSlideOutAnimation();\n } else {\n console.error('[ApiKeyHeader] Providers still not configured after successful validation');\n this.llmError = '*Configuration error. Please try again.';\n this.isLoading = false;\n this.requestUpdate();\n }\n }, 100);\n } else {\n this.llmError = !llmResult.success ? `*${llmResult.error || 'Invalid API Key'}` : '';\n this.sttError = !sttResult.success ? `*${sttResult.error || 'Invalid'}` : '';\n this.errorMessage = ''; // Do not use the general error message for this\n this.messageTimestamp = Date.now();\n }\n } catch (error) {\n console.error('[ApiKeyHeader] handleSubmit: Error:', error);\n this.llmError = `*${error.message}`;\n this.messageTimestamp = Date.now();\n }\n\n this.isLoading = false;\n this.requestUpdate();\n }\n //////// after_modelStateService ////////\n\n\n ////TODO: 뭔가 넘어가는 애니메이션 로직에 문제가 있음\n startSlideOutAnimation() {\n console.log('[ApiKeyHeader] startSlideOutAnimation: Starting slide out animation.');\n this.classList.add('sliding-out');\n \n // Fallback: if animation doesn't trigger animationend event, force transition\n setTimeout(() => {\n if (this.classList.contains('sliding-out')) {\n console.log('[ApiKeyHeader] Animation fallback triggered - forcing transition');\n this.handleAnimationEnd({ target: this, animationName: 'slideOut' });\n }\n }, 1); // Wait a bit longer than animation duration\n }\n\n handleClose() {\n if (window.api?.common) {\n window.api.common.quitApplication();\n }\n }\n\n //////// after_modelStateService ////////\n handleAnimationEnd(e) {\n if (e.target !== this || !this.classList.contains('sliding-out')) return;\n this.classList.remove('sliding-out');\n this.classList.add('hidden');\n\n console.log('[ApiKeyHeader] handleAnimationEnd: Animation completed, transitioning to next state...');\n\n if (!window.api?.common) {\n console.error('[ApiKeyHeader] handleAnimationEnd: window.api.common not available');\n return;\n }\n\n if (!this.stateUpdateCallback) {\n console.error('[ApiKeyHeader] handleAnimationEnd: stateUpdateCallback not set! This will prevent transition to main window.');\n return;\n }\n\n window.api.common\n .getCurrentUser()\n .then(userState => {\n console.log('[ApiKeyHeader] handleAnimationEnd: User state retrieved:', userState);\n\n // Additional validation for local providers\n return window.api.apiKeyHeader.areProvidersConfigured().then(isConfigured => {\n console.log('[ApiKeyHeader] handleAnimationEnd: Providers configured check:', isConfigured);\n\n if (!isConfigured) {\n console.warn('[ApiKeyHeader] handleAnimationEnd: Providers still not configured, may return to ApiKey screen');\n }\n\n // Call the state update callback\n this.stateUpdateCallback(userState);\n });\n })\n .catch(error => {\n console.error('[ApiKeyHeader] handleAnimationEnd: Error during state transition:', error);\n\n // Fallback: try to call callback with minimal state\n if (this.stateUpdateCallback) {\n console.log('[ApiKeyHeader] handleAnimationEnd: Attempting fallback state transition...');\n this.stateUpdateCallback({ isLoggedIn: false });\n }\n });\n }\n //////// after_modelStateService ////////\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('animationend', this.handleAnimationEnd);\n }\n\n handleMessageFadeEnd(e) {\n if (e.animationName === 'fadeOut') {\n // Clear the message that finished fading\n if (e.target.classList.contains('error-message')) {\n this.errorMessage = '';\n } else if (e.target.classList.contains('success-message')) {\n this.successMessage = '';\n }\n this.messageTimestamp = 0;\n this.requestUpdate();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('animationend', this.handleAnimationEnd);\n\n // Professional cleanup of all resources\n this._performCompleteCleanup();\n }\n\n _performCompleteCleanup() {\n console.log('[ApiKeyHeader] Performing complete cleanup');\n\n // Stop health monitoring\n this._stopHealthMonitoring();\n\n // Cancel all active operations\n this._cancelAllActiveOperations();\n\n // Cancel any ongoing installations when component is destroyed\n if (this.installingModel) {\n this.progressTracker.cancelInstallation(this.installingModel);\n }\n\n // Cleanup event listeners\n if (window.api?.apiKeyHeader) {\n window.api.apiKeyHeader.removeAllListeners();\n }\n\n // Cancel any ongoing downloads\n const downloadingModels = Object.keys(this.whisperInstallingModels);\n if (downloadingModels.length > 0) {\n console.log(`[ApiKeyHeader] Cancelling ${downloadingModels.length} ongoing Whisper downloads`);\n downloadingModels.forEach(modelId => {\n delete this.whisperInstallingModels[modelId];\n });\n }\n\n // Reset state\n this.connectionState = 'disconnected';\n this.retryCount = 0;\n\n console.log('[ApiKeyHeader] Cleanup completed');\n }\n\n /**\n * State machine-based Ollama UI rendering\n */\n _renderOllamaStateUI() {\n const state = this._getOllamaUIState();\n\n switch (state.type) {\n case 'connecting':\n return this._renderConnectingState(state);\n case 'install_required':\n return this._renderInstallRequiredState();\n case 'start_required':\n return this._renderStartRequiredState();\n case 'ready':\n return this._renderReadyState();\n case 'failed':\n return this._renderFailedState(state);\n case 'installing':\n return this._renderInstallingState(state);\n default:\n return this._renderUnknownState();\n }\n }\n\n _getOllamaUIState() {\n // State determination logic\n if (this.connectionState === 'connecting') {\n return { type: 'connecting', message: this.installingModel || 'Connecting to Ollama...' };\n }\n\n if (this.connectionState === 'failed') {\n return { type: 'failed', message: this.errorMessage };\n }\n\n if (this.installingModel && this.installingModel.includes('Ollama')) {\n return { type: 'installing', progress: this.installProgress };\n }\n\n if (!this.ollamaStatus.installed) {\n return { type: 'install_required' };\n }\n\n if (!this.ollamaStatus.running) {\n return { type: 'start_required' };\n }\n\n return { type: 'ready' };\n }\n\n _renderConnectingState(state) {\n return html`\n
\n
\n
\n
\n
\n ${this.installProgress}%\n
\n
\n `;\n }\n\n _renderInstallRequiredState() {\n return html` `;\n }\n\n _renderStartRequiredState() {\n return html` `;\n }\n\n _renderReadyState() {\n return html`\n \n \n \n ${this.getCombinedModelSuggestions().map(\n model => html`\n \n `\n )}\n \n\n \n ${this.renderModelStatus()}\n ${this.installingModel && !this.installingModel.includes('Ollama')\n ? html`\n
\n
\n
\n
\n
\n ${this.installProgress}%\n
\n \n `\n : ''}\n `;\n }\n\n _renderFailedState(state) {\n return html`\n
\n
Connection failed
\n
\n ${state.message || 'Unknown error'}\n
\n this._initializeOllamaConnection()}\n >\n Retry Connection\n \n
\n `;\n }\n\n _renderInstallingState(state) {\n return html`\n
\n
\n
\n
\n
\n ${state.progress}%\n
\n
\n `;\n }\n\n _renderUnknownState() {\n return html`\n
\n
Unknown state - Please refresh
\n
\n `;\n }\n\n renderModelStatus() {\n return '';\n }\n\n shouldFadeMessage(type) {\n const hasMessage = type === 'error' ? this.errorMessage : this.successMessage;\n return hasMessage && this.messageTimestamp > 0 && Date.now() - this.messageTimestamp > 100;\n }\n\n openPrivacyPolicy() {\n console.log('🔊 openPrivacyPolicy ApiKeyHeader');\n if (window.api?.common) {\n window.api.common.openExternal('https://pickle.com/privacy-policy');\n }\n }\n\n render() {\n const llmNeedsApiKey = this.llmProvider !== 'ollama' && this.llmProvider !== 'whisper';\n const sttNeedsApiKey = this.sttProvider !== 'ollama' && this.sttProvider !== 'whisper';\n const llmNeedsModel = this.llmProvider === 'ollama';\n const sttNeedsModel = this.sttProvider === 'whisper';\n\n const isButtonDisabled =\n this.isLoading ||\n this.installingModel ||\n Object.keys(this.whisperInstallingModels).length > 0 ||\n (llmNeedsApiKey && !this.llmApiKey.trim()) ||\n (sttNeedsApiKey && !this.sttApiKey.trim()) ||\n (llmNeedsModel && !this.selectedLlmModel?.trim()) ||\n (sttNeedsModel && !this.selectedSttModel);\n\n const llmProviderName = this.providers.llm.find(p => p.id === this.llmProvider)?.name || this.llmProvider;\n\n return html`\n
\n \n
\n
\n \n
Back
\n
\n
Use Personal API keys
\n
\n\n \n
\n
\n
1. Select LLM Provider
\n
\n ${this.providers.llm.map(\n p => html`\n this.handleLlmProviderChange(e, p.id)}\n >\n ${p.name}\n \n `\n )}\n
\n
\n
\n
2. Enter API Key
\n ${this.llmProvider === 'ollama'\n ? this._renderOllamaStateUI()\n : html`\n
\n {\n this.llmApiKey = e.target.value;\n this.llmError = '';\n }}\n ?disabled=${this.isLoading}\n />\n ${this.llmError ? html`
${this.llmError}
` : ''}\n
\n `}\n
\n
\n\n \n
\n
\n
3. Select STT Provider
\n
\n ${this.providers.stt.map(\n p => html`\n this.handleSttProviderChange(e, p.id)}\n >\n ${p.name}\n \n `\n )}\n
\n
\n
\n
4. Enter STT API Key
\n ${this.sttProvider === 'ollama'\n ? html`\n
\n STT not supported by Ollama\n
\n `\n : this.sttProvider === 'whisper'\n ? html`\n
\n {\n this.handleSttModelChange(e);\n this.sttError = '';\n }}\n ?disabled=${this.isLoading}\n >\n \n ${[\n { id: 'whisper-tiny', name: 'Whisper Tiny (39M)' },\n { id: 'whisper-base', name: 'Whisper Base (74M)' },\n { id: 'whisper-small', name: 'Whisper Small (244M)' },\n { id: 'whisper-medium', name: 'Whisper Medium (769M)' },\n ].map(model => html` `)}\n \n ${this.sttError ? html`
${this.sttError}
` : ''}\n
\n `\n : html`\n
\n {\n this.sttApiKey = e.target.value;\n this.sttError = '';\n }}\n ?disabled=${this.isLoading}\n />\n ${this.sttError ? html`
${this.sttError}
` : ''}\n
\n `}\n
\n
\n
\n \n
\n\n
\n Get your API key from: OpenAI | Google | Anthropic\n
\n Glass does not collect your personal data —\n See details\n
\n\n
\n ${this.errorMessage}\n
\n \n ${this.successMessage}\n
\n \n `;\n }\n}\n\ncustomElements.define('apikey-header', ApiKeyHeader);\n"], ["/glass/src/ui/listen/stt/SttView.js", "import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';\n\nexport class SttView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n /* Inherit font styles from parent */\n\n .transcription-container {\n overflow-y: auto;\n padding: 12px 12px 16px 12px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-height: 150px;\n max-height: 600px;\n position: relative;\n z-index: 1;\n flex: 1;\n }\n\n /* Visibility handled by parent component */\n\n .transcription-container::-webkit-scrollbar {\n width: 8px;\n }\n .transcription-container::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n }\n .transcription-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.3);\n border-radius: 4px;\n }\n .transcription-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.5);\n }\n\n .stt-message {\n padding: 8px 12px;\n border-radius: 12px;\n max-width: 80%;\n word-wrap: break-word;\n word-break: break-word;\n line-height: 1.5;\n font-size: 13px;\n margin-bottom: 4px;\n box-sizing: border-box;\n }\n\n .stt-message.them {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.9);\n align-self: flex-start;\n border-bottom-left-radius: 4px;\n margin-right: auto;\n }\n\n .stt-message.me {\n background: rgba(0, 122, 255, 0.8);\n color: white;\n align-self: flex-end;\n border-bottom-right-radius: 4px;\n margin-left: auto;\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100px;\n color: rgba(255, 255, 255, 0.6);\n font-size: 12px;\n font-style: italic;\n }\n `;\n\n static properties = {\n sttMessages: { type: Array },\n isVisible: { type: Boolean },\n };\n\n constructor() {\n super();\n this.sttMessages = [];\n this.isVisible = true;\n this.messageIdCounter = 0;\n this._shouldScrollAfterUpdate = false;\n\n this.handleSttUpdate = this.handleSttUpdate.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (window.api) {\n window.api.sttView.onSttUpdate(this.handleSttUpdate);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.sttView.removeOnSttUpdate(this.handleSttUpdate);\n }\n }\n\n // Handle session reset from parent\n resetTranscript() {\n this.sttMessages = [];\n this.requestUpdate();\n }\n\n handleSttUpdate(event, { speaker, text, isFinal, isPartial }) {\n if (text === undefined) return;\n\n const container = this.shadowRoot.querySelector('.transcription-container');\n this._shouldScrollAfterUpdate = container ? container.scrollTop + container.clientHeight >= container.scrollHeight - 10 : false;\n\n const findLastPartialIdx = spk => {\n for (let i = this.sttMessages.length - 1; i >= 0; i--) {\n const m = this.sttMessages[i];\n if (m.speaker === spk && m.isPartial) return i;\n }\n return -1;\n };\n\n const newMessages = [...this.sttMessages];\n const targetIdx = findLastPartialIdx(speaker);\n\n if (isPartial) {\n if (targetIdx !== -1) {\n newMessages[targetIdx] = {\n ...newMessages[targetIdx],\n text,\n isPartial: true,\n isFinal: false,\n };\n } else {\n newMessages.push({\n id: this.messageIdCounter++,\n speaker,\n text,\n isPartial: true,\n isFinal: false,\n });\n }\n } else if (isFinal) {\n if (targetIdx !== -1) {\n newMessages[targetIdx] = {\n ...newMessages[targetIdx],\n text,\n isPartial: false,\n isFinal: true,\n };\n } else {\n newMessages.push({\n id: this.messageIdCounter++,\n speaker,\n text,\n isPartial: false,\n isFinal: true,\n });\n }\n }\n\n this.sttMessages = newMessages;\n \n // Notify parent component about message updates\n this.dispatchEvent(new CustomEvent('stt-messages-updated', {\n detail: { messages: this.sttMessages },\n bubbles: true\n }));\n }\n\n scrollToBottom() {\n setTimeout(() => {\n const container = this.shadowRoot.querySelector('.transcription-container');\n if (container) {\n container.scrollTop = container.scrollHeight;\n }\n }, 0);\n }\n\n getSpeakerClass(speaker) {\n return speaker.toLowerCase() === 'me' ? 'me' : 'them';\n }\n\n getTranscriptText() {\n return this.sttMessages.map(msg => `${msg.speaker}: ${msg.text}`).join('\\n');\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n\n if (changedProperties.has('sttMessages')) {\n if (this._shouldScrollAfterUpdate) {\n this.scrollToBottom();\n this._shouldScrollAfterUpdate = false;\n }\n }\n }\n\n render() {\n if (!this.isVisible) {\n return html`
`;\n }\n\n return html`\n
\n ${this.sttMessages.length === 0\n ? html`
Waiting for speech...
`\n : this.sttMessages.map(msg => html`\n
\n ${msg.text}\n
\n `)\n }\n
\n `;\n }\n}\n\ncustomElements.define('stt-view', SttView); "], ["/glass/src/ui/app/WelcomeHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class WelcomeHeader extends LitElement {\n static styles = css`\n :host {\n display: block;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n sans-serif;\n }\n .container {\n width: 100%;\n box-sizing: border-box;\n height: auto;\n padding: 24px 16px;\n background: rgba(0, 0, 0, 0.64);\n box-shadow: 0px 0px 0px 1.5px rgba(255, 255, 255, 0.64) inset;\n border-radius: 16px;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 32px;\n display: inline-flex;\n -webkit-app-region: drag;\n }\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 16px;\n right: 16px;\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 5px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 16px;\n line-height: 1;\n padding: 0;\n }\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n .header-section {\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 4px;\n display: flex;\n }\n .title {\n color: white;\n font-size: 18px;\n font-weight: 700;\n }\n .subtitle {\n color: white;\n font-size: 14px;\n font-weight: 500;\n }\n .option-card {\n width: 100%;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 8px;\n display: inline-flex;\n }\n .divider {\n width: 1px;\n align-self: stretch;\n position: relative;\n background: #bebebe;\n border-radius: 2px;\n }\n .option-content {\n flex: 1 1 0;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 8px;\n display: inline-flex;\n min-width: 0;\n }\n .option-title {\n color: white;\n font-size: 14px;\n font-weight: 700;\n }\n .option-description {\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 400;\n line-height: 18px;\n letter-spacing: 0.12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .action-button {\n -webkit-app-region: no-drag;\n padding: 8px 10px;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.16);\n border-radius: 16px;\n border: 1px solid rgba(255, 255, 255, 0.5);\n justify-content: center;\n align-items: center;\n gap: 6px;\n display: flex;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n .action-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .button-text {\n color: white;\n font-size: 12px;\n font-weight: 600;\n }\n .button-icon {\n width: 12px;\n height: 12px;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .arrow-icon {\n border: solid white;\n border-width: 0 1.2px 1.2px 0;\n display: inline-block;\n padding: 3px;\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n .footer {\n align-self: stretch;\n text-align: center;\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 500;\n line-height: 19.2px;\n }\n .footer-link {\n text-decoration: underline;\n cursor: pointer;\n -webkit-app-region: no-drag;\n }\n `;\n\n static properties = {\n loginCallback: { type: Function },\n apiKeyCallback: { type: Function },\n };\n\n constructor() {\n super();\n this.loginCallback = () => {};\n this.apiKeyCallback = () => {};\n this.handleClose = this.handleClose.bind(this);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.dispatchEvent(new CustomEvent('content-changed', { bubbles: true, composed: true }));\n }\n\n handleClose() {\n if (window.api?.common) {\n window.api.common.quitApplication();\n }\n }\n\n render() {\n return html`\n
\n \n
\n
Welcome to Glass
\n
Choose how to connect your AI model
\n
\n
\n
\n
\n
Quick start with default API key
\n
\n 100% free with Pickle's OpenAI key
No personal data collected
Sign up with Google in seconds\n
\n
\n \n
\n
\n
\n
\n
Use Personal API keys
\n
\n Costs may apply based on your API usage
No personal data collected
Use your own API keys (OpenAI, Gemini, etc.)\n
\n
\n \n
\n
\n Glass does not collect your personal data —\n See details\n
\n
\n `;\n }\n\n openPrivacyPolicy() {\n console.log('🔊 openPrivacyPolicy WelcomeHeader');\n if (window.api?.common) {\n window.api.common.openExternal('https://pickle.com/privacy-policy');\n }\n }\n}\n\ncustomElements.define('welcome-header', WelcomeHeader);"], ["/glass/src/ui/app/PickleGlassApp.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\nimport { SettingsView } from '../settings/SettingsView.js';\nimport { ListenView } from '../listen/ListenView.js';\nimport { AskView } from '../ask/AskView.js';\nimport { ShortcutSettingsView } from '../settings/ShortCutSettingsView.js';\n\nimport '../listen/audioCore/renderer.js';\n\nexport class PickleGlassApp extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n color: var(--text-color);\n background: transparent;\n border-radius: 7px;\n }\n\n listen-view {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n ask-view, settings-view, history-view, help-view, setup-view {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n `;\n\n static properties = {\n currentView: { type: String },\n statusText: { type: String },\n startTime: { type: Number },\n currentResponseIndex: { type: Number },\n isMainViewVisible: { type: Boolean },\n selectedProfile: { type: String },\n selectedLanguage: { type: String },\n selectedScreenshotInterval: { type: String },\n selectedImageQuality: { type: String },\n isClickThrough: { type: Boolean, state: true },\n layoutMode: { type: String },\n _viewInstances: { type: Object, state: true },\n _isClickThrough: { state: true },\n structuredData: { type: Object }, \n };\n\n constructor() {\n super();\n const urlParams = new URLSearchParams(window.location.search);\n this.currentView = urlParams.get('view') || 'listen';\n this.currentResponseIndex = -1;\n this.selectedProfile = localStorage.getItem('selectedProfile') || 'interview';\n \n // Language format migration for legacy users\n let lang = localStorage.getItem('selectedLanguage') || 'en';\n if (lang.includes('-')) {\n const newLang = lang.split('-')[0];\n console.warn(`[Migration] Correcting language format from \"${lang}\" to \"${newLang}\".`);\n localStorage.setItem('selectedLanguage', newLang);\n lang = newLang;\n }\n this.selectedLanguage = lang;\n\n this.selectedScreenshotInterval = localStorage.getItem('selectedScreenshotInterval') || '5';\n this.selectedImageQuality = localStorage.getItem('selectedImageQuality') || 'medium';\n this._isClickThrough = false;\n\n }\n\n connectedCallback() {\n super.connectedCallback();\n \n if (window.api) {\n window.api.pickleGlassApp.onClickThroughToggled((_, isEnabled) => {\n this._isClickThrough = isEnabled;\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.pickleGlassApp.removeAllClickThroughListeners();\n }\n }\n\n updated(changedProperties) {\n if (changedProperties.has('currentView')) {\n const viewContainer = this.shadowRoot?.querySelector('.view-container');\n if (viewContainer) {\n viewContainer.classList.add('entering');\n requestAnimationFrame(() => {\n viewContainer.classList.remove('entering');\n });\n }\n }\n\n // Only update localStorage when these specific properties change\n if (changedProperties.has('selectedProfile')) {\n localStorage.setItem('selectedProfile', this.selectedProfile);\n }\n if (changedProperties.has('selectedLanguage')) {\n localStorage.setItem('selectedLanguage', this.selectedLanguage);\n }\n if (changedProperties.has('selectedScreenshotInterval')) {\n localStorage.setItem('selectedScreenshotInterval', this.selectedScreenshotInterval);\n }\n if (changedProperties.has('selectedImageQuality')) {\n localStorage.setItem('selectedImageQuality', this.selectedImageQuality);\n }\n if (changedProperties.has('layoutMode')) {\n this.updateLayoutMode();\n }\n }\n\n async handleClose() {\n if (window.api) {\n await window.api.common.quitApplication();\n }\n }\n\n\n\n\n render() {\n switch (this.currentView) {\n case 'listen':\n return html` (this.currentResponseIndex = e.detail.index)}\n >`;\n case 'ask':\n return html``;\n case 'settings':\n return html` (this.selectedProfile = profile)}\n .onLanguageChange=${lang => (this.selectedLanguage = lang)}\n >`;\n case 'shortcut-settings':\n return html``;\n case 'history':\n return html``;\n case 'help':\n return html``;\n case 'setup':\n return html``;\n default:\n return html`
Unknown view: ${this.currentView}
`;\n }\n }\n}\n\ncustomElements.define('pickle-glass-app', PickleGlassApp);\n"], ["/glass/src/window/windowManager.js", "const { BrowserWindow, globalShortcut, screen, app, shell } = require('electron');\nconst WindowLayoutManager = require('./windowLayoutManager');\nconst SmoothMovementManager = require('./smoothMovementManager');\nconst path = require('node:path');\nconst os = require('os');\nconst shortcutsService = require('../features/shortcuts/shortcutsService');\nconst internalBridge = require('../bridge/internalBridge');\nconst permissionRepository = require('../features/common/repositories/permission');\n\n/* ────────────────[ GLASS BYPASS ]─────────────── */\nlet liquidGlass;\nconst isLiquidGlassSupported = () => {\n if (process.platform !== 'darwin') {\n return false;\n }\n const majorVersion = parseInt(os.release().split('.')[0], 10);\n // return majorVersion >= 25; // macOS 26+ (Darwin 25+)\n return majorVersion >= 26; // See you soon!\n};\nlet shouldUseLiquidGlass = isLiquidGlassSupported();\nif (shouldUseLiquidGlass) {\n try {\n liquidGlass = require('electron-liquid-glass');\n } catch (e) {\n console.warn('Could not load optional dependency \"electron-liquid-glass\". The feature will be disabled.');\n shouldUseLiquidGlass = false;\n }\n}\n/* ────────────────[ GLASS BYPASS ]─────────────── */\n\nlet isContentProtectionOn = true;\nlet lastVisibleWindows = new Set(['header']);\n\nlet currentHeaderState = 'apikey';\nconst windowPool = new Map();\n\nlet settingsHideTimer = null;\n\n\nlet layoutManager = null;\nlet movementManager = null;\n\n\nfunction updateChildWindowLayouts(animated = true) {\n // if (movementManager.isAnimating) return;\n\n const visibleWindows = {};\n const listenWin = windowPool.get('listen');\n const askWin = windowPool.get('ask');\n if (listenWin && !listenWin.isDestroyed() && listenWin.isVisible()) {\n visibleWindows.listen = true;\n }\n if (askWin && !askWin.isDestroyed() && askWin.isVisible()) {\n visibleWindows.ask = true;\n }\n\n if (Object.keys(visibleWindows).length === 0) return;\n\n const newLayout = layoutManager.calculateFeatureWindowLayout(visibleWindows);\n movementManager.animateLayout(newLayout, animated);\n}\n\nconst showSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: true });\n};\n\nconst hideSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: false });\n};\n\nconst cancelHideSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: true });\n};\n\nconst moveWindowStep = (direction) => {\n internalBridge.emit('window:moveStep', { direction });\n};\n\nconst resizeHeaderWindow = ({ width, height }) => {\n internalBridge.emit('window:resizeHeaderWindow', { width, height });\n};\n\nconst handleHeaderAnimationFinished = (state) => {\n internalBridge.emit('window:headerAnimationFinished', state);\n};\n\nconst getHeaderPosition = () => {\n return new Promise((resolve) => {\n internalBridge.emit('window:getHeaderPosition', (position) => {\n resolve(position);\n });\n });\n};\n\nconst moveHeaderTo = (newX, newY) => {\n internalBridge.emit('window:moveHeaderTo', { newX, newY });\n};\n\nconst adjustWindowHeight = (winName, targetHeight) => {\n internalBridge.emit('window:adjustWindowHeight', { winName, targetHeight });\n};\n\n\nfunction setupWindowController(windowPool, layoutManager, movementManager) {\n internalBridge.on('window:requestVisibility', ({ name, visible }) => {\n handleWindowVisibilityRequest(windowPool, layoutManager, movementManager, name, visible);\n });\n internalBridge.on('window:requestToggleAllWindowsVisibility', ({ targetVisibility }) => {\n changeAllWindowsVisibility(windowPool, targetVisibility);\n });\n internalBridge.on('window:moveToDisplay', ({ displayId }) => {\n // movementManager.moveToDisplay(displayId);\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateNewPositionForDisplay(header, displayId);\n if (newPosition) {\n movementManager.animateWindowPosition(header, newPosition, {\n onComplete: () => updateChildWindowLayouts(true)\n });\n }\n }\n });\n internalBridge.on('window:moveToEdge', ({ direction }) => {\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateEdgePosition(header, direction);\n movementManager.animateWindowPosition(header, newPosition, { \n onComplete: () => updateChildWindowLayouts(true) \n });\n }\n });\n\n internalBridge.on('window:moveStep', ({ direction }) => {\n const header = windowPool.get('header');\n if (header) { \n const newHeaderPosition = layoutManager.calculateStepMovePosition(header, direction);\n if (!newHeaderPosition) return;\n \n const futureHeaderBounds = { ...header.getBounds(), ...newHeaderPosition };\n const visibleWindows = {};\n const listenWin = windowPool.get('listen');\n const askWin = windowPool.get('ask');\n if (listenWin && !listenWin.isDestroyed() && listenWin.isVisible()) {\n visibleWindows.listen = true;\n }\n if (askWin && !askWin.isDestroyed() && askWin.isVisible()) {\n visibleWindows.ask = true;\n }\n\n const newChildLayout = layoutManager.calculateFeatureWindowLayout(visibleWindows, futureHeaderBounds);\n \n movementManager.animateWindowPosition(header, newHeaderPosition);\n movementManager.animateLayout(newChildLayout);\n }\n });\n\n internalBridge.on('window:resizeHeaderWindow', ({ width, height }) => {\n const header = windowPool.get('header');\n if (!header || movementManager.isAnimating) return;\n\n const newHeaderBounds = layoutManager.calculateHeaderResize(header, { width, height });\n \n const wasResizable = header.isResizable();\n if (!wasResizable) header.setResizable(true);\n\n movementManager.animateWindowBounds(header, newHeaderBounds, {\n onComplete: () => {\n if (!wasResizable) header.setResizable(false);\n updateChildWindowLayouts(true);\n }\n });\n });\n internalBridge.on('window:headerAnimationFinished', (state) => {\n const header = windowPool.get('header');\n if (!header || header.isDestroyed()) return;\n\n if (state === 'hidden') {\n header.hide();\n } else if (state === 'visible') {\n updateChildWindowLayouts(false);\n }\n });\n internalBridge.on('window:getHeaderPosition', (reply) => {\n const header = windowPool.get('header');\n if (header && !header.isDestroyed()) {\n reply(header.getBounds());\n } else {\n reply({ x: 0, y: 0, width: 0, height: 0 });\n }\n });\n internalBridge.on('window:moveHeaderTo', ({ newX, newY }) => {\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateClampedPosition(header, { x: newX, y: newY });\n header.setPosition(newPosition.x, newPosition.y);\n }\n });\n internalBridge.on('window:adjustWindowHeight', ({ winName, targetHeight }) => {\n console.log(`[Layout Debug] adjustWindowHeight: targetHeight=${targetHeight}`);\n const senderWindow = windowPool.get(winName);\n if (senderWindow) {\n const newBounds = layoutManager.calculateWindowHeightAdjustment(senderWindow, targetHeight);\n \n const wasResizable = senderWindow.isResizable();\n if (!wasResizable) senderWindow.setResizable(true);\n\n movementManager.animateWindowBounds(senderWindow, newBounds, {\n onComplete: () => {\n if (!wasResizable) senderWindow.setResizable(false);\n updateChildWindowLayouts(true);\n }\n });\n }\n });\n}\n\nfunction changeAllWindowsVisibility(windowPool, targetVisibility) {\n const header = windowPool.get('header');\n if (!header) return;\n\n if (typeof targetVisibility === 'boolean' &&\n header.isVisible() === targetVisibility) {\n return;\n }\n \n if (header.isVisible()) {\n lastVisibleWindows.clear();\n \n windowPool.forEach((win, name) => {\n if (win && !win.isDestroyed() && win.isVisible()) {\n lastVisibleWindows.add(name);\n }\n });\n \n lastVisibleWindows.forEach(name => {\n if (name === 'header') return;\n const win = windowPool.get(name);\n if (win && !win.isDestroyed()) win.hide();\n });\n header.hide();\n \n return;\n }\n \n lastVisibleWindows.forEach(name => {\n const win = windowPool.get(name);\n if (win && !win.isDestroyed())\n win.show();\n });\n }\n\n/**\n * \n * @param {Map} windowPool\n * @param {WindowLayoutManager} layoutManager \n * @param {SmoothMovementManager} movementManager\n * @param {'listen' | 'ask' | 'settings' | 'shortcut-settings'} name \n * @param {boolean} shouldBeVisible \n */\nasync function handleWindowVisibilityRequest(windowPool, layoutManager, movementManager, name, shouldBeVisible) {\n console.log(`[WindowManager] Request: set '${name}' visibility to ${shouldBeVisible}`);\n const win = windowPool.get(name);\n\n if (!win || win.isDestroyed()) {\n console.warn(`[WindowManager] Window '${name}' not found or destroyed.`);\n return;\n }\n\n if (name !== 'settings') {\n const isCurrentlyVisible = win.isVisible();\n if (isCurrentlyVisible === shouldBeVisible) {\n console.log(`[WindowManager] Window '${name}' is already in the desired state.`);\n return;\n }\n }\n\n const disableClicks = (selectedWindow) => {\n for (const [name, win] of windowPool) {\n if (win !== selectedWindow && !win.isDestroyed()) {\n win.setIgnoreMouseEvents(true, { forward: true });\n }\n }\n };\n\n const restoreClicks = () => {\n for (const [, win] of windowPool) {\n if (!win.isDestroyed()) win.setIgnoreMouseEvents(false);\n }\n };\n\n if (name === 'settings') {\n if (shouldBeVisible) {\n // Cancel any pending hide operations\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n settingsHideTimer = null;\n }\n const position = layoutManager.calculateSettingsWindowPosition();\n if (position) {\n win.setBounds(position);\n win.__lockedByButton = true;\n win.show();\n win.moveTop();\n win.setAlwaysOnTop(true);\n } else {\n console.warn('[WindowManager] Could not calculate settings window position.');\n }\n } else {\n // Hide after a delay\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n }\n settingsHideTimer = setTimeout(() => {\n if (win && !win.isDestroyed()) {\n win.setAlwaysOnTop(false);\n win.hide();\n }\n settingsHideTimer = null;\n }, 200);\n\n win.__lockedByButton = false;\n }\n return;\n }\n\n\n if (name === 'shortcut-settings') {\n if (shouldBeVisible) {\n // layoutManager.positionShortcutSettingsWindow();\n const newBounds = layoutManager.calculateShortcutSettingsWindowPosition();\n if (newBounds) win.setBounds(newBounds);\n \n if (process.platform === 'darwin') {\n win.setAlwaysOnTop(true, 'screen-saver');\n } else {\n win.setAlwaysOnTop(true);\n }\n // globalShortcut.unregisterAll();\n disableClicks(win);\n win.show();\n } else {\n if (process.platform === 'darwin') {\n win.setAlwaysOnTop(false, 'screen-saver');\n } else {\n win.setAlwaysOnTop(false);\n }\n restoreClicks();\n win.hide();\n }\n return;\n }\n\n if (name === 'listen' || name === 'ask') {\n const win = windowPool.get(name);\n const otherName = name === 'listen' ? 'ask' : 'listen';\n const otherWin = windowPool.get(otherName);\n const isOtherWinVisible = otherWin && !otherWin.isDestroyed() && otherWin.isVisible();\n \n const ANIM_OFFSET_X = 50;\n const ANIM_OFFSET_Y = 20;\n\n const finalVisibility = {\n listen: (name === 'listen' && shouldBeVisible) || (otherName === 'listen' && isOtherWinVisible),\n ask: (name === 'ask' && shouldBeVisible) || (otherName === 'ask' && isOtherWinVisible),\n };\n if (!shouldBeVisible) {\n finalVisibility[name] = false;\n }\n\n const targetLayout = layoutManager.calculateFeatureWindowLayout(finalVisibility);\n\n if (shouldBeVisible) {\n if (!win) return;\n const targetBounds = targetLayout[name];\n if (!targetBounds) return;\n\n const startPos = { ...targetBounds };\n if (name === 'listen') startPos.x -= ANIM_OFFSET_X;\n else if (name === 'ask') startPos.y -= ANIM_OFFSET_Y;\n\n win.setOpacity(0);\n win.setBounds(startPos);\n win.show();\n\n movementManager.fade(win, { to: 1 });\n movementManager.animateLayout(targetLayout);\n\n } else {\n if (!win || !win.isVisible()) return;\n\n const currentBounds = win.getBounds();\n const targetPos = { ...currentBounds };\n if (name === 'listen') targetPos.x -= ANIM_OFFSET_X;\n else if (name === 'ask') targetPos.y -= ANIM_OFFSET_Y;\n\n movementManager.fade(win, { to: 0, onComplete: () => win.hide() });\n movementManager.animateWindowPosition(win, targetPos);\n \n // 다른 창들도 새 레이아웃으로 애니메이션\n const otherWindowsLayout = { ...targetLayout };\n delete otherWindowsLayout[name];\n movementManager.animateLayout(otherWindowsLayout);\n }\n }\n}\n\n\nconst setContentProtection = (status) => {\n isContentProtectionOn = status;\n console.log(`[Protection] Content protection toggled to: ${isContentProtectionOn}`);\n windowPool.forEach(win => {\n if (win && !win.isDestroyed()) {\n win.setContentProtection(isContentProtectionOn);\n }\n });\n};\n\nconst getContentProtectionStatus = () => isContentProtectionOn;\n\nconst toggleContentProtection = () => {\n const newStatus = !getContentProtectionStatus();\n setContentProtection(newStatus);\n return newStatus;\n};\n\n\nconst openLoginPage = () => {\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n const personalizeUrl = `${webUrl}/personalize?desktop=true`;\n shell.openExternal(personalizeUrl);\n console.log('Opening personalization page:', personalizeUrl);\n};\n\n\nfunction createFeatureWindows(header, namesToCreate) {\n // if (windowPool.has('listen')) return;\n\n const commonChildOptions = {\n parent: header,\n show: false,\n frame: false,\n transparent: true,\n vibrancy: false,\n hasShadow: false,\n skipTaskbar: true,\n hiddenInMissionControl: true,\n resizable: false,\n webPreferences: {\n nodeIntegration: false,\n contextIsolation: true,\n preload: path.join(__dirname, '../preload.js'),\n },\n };\n\n const createFeatureWindow = (name) => {\n if (windowPool.has(name)) return;\n \n switch (name) {\n case 'listen': {\n const listen = new BrowserWindow({\n ...commonChildOptions, width:400,minWidth:400,maxWidth:900,\n maxHeight:900,\n });\n listen.setContentProtection(isContentProtectionOn);\n listen.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n listen.setWindowButtonVisibility(false);\n }\n const listenLoadOptions = { query: { view: 'listen' } };\n if (!shouldUseLiquidGlass) {\n listen.loadFile(path.join(__dirname, '../ui/app/content.html'), listenLoadOptions);\n }\n else {\n listenLoadOptions.query.glass = 'true';\n listen.loadFile(path.join(__dirname, '../ui/app/content.html'), listenLoadOptions);\n listen.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(listen.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n if (!app.isPackaged) {\n listen.webContents.openDevTools({ mode: 'detach' });\n }\n windowPool.set('listen', listen);\n break;\n }\n\n // ask\n case 'ask': {\n const ask = new BrowserWindow({ ...commonChildOptions, width:600 });\n ask.setContentProtection(isContentProtectionOn);\n ask.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n ask.setWindowButtonVisibility(false);\n }\n const askLoadOptions = { query: { view: 'ask' } };\n if (!shouldUseLiquidGlass) {\n ask.loadFile(path.join(__dirname, '../ui/app/content.html'), askLoadOptions);\n }\n else {\n askLoadOptions.query.glass = 'true';\n ask.loadFile(path.join(__dirname, '../ui/app/content.html'), askLoadOptions);\n ask.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(ask.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n \n // Open DevTools in development\n if (!app.isPackaged) {\n ask.webContents.openDevTools({ mode: 'detach' });\n }\n windowPool.set('ask', ask);\n break;\n }\n\n // settings\n case 'settings': {\n const settings = new BrowserWindow({ ...commonChildOptions, width:240, maxHeight:400, parent:undefined });\n settings.setContentProtection(isContentProtectionOn);\n settings.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n settings.setWindowButtonVisibility(false);\n }\n const settingsLoadOptions = { query: { view: 'settings' } };\n if (!shouldUseLiquidGlass) {\n settings.loadFile(path.join(__dirname,'../ui/app/content.html'), settingsLoadOptions)\n .catch(console.error);\n }\n else {\n settingsLoadOptions.query.glass = 'true';\n settings.loadFile(path.join(__dirname,'../ui/app/content.html'), settingsLoadOptions)\n .catch(console.error);\n settings.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(settings.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n windowPool.set('settings', settings); \n\n if (!app.isPackaged) {\n settings.webContents.openDevTools({ mode: 'detach' });\n }\n break;\n }\n\n case 'shortcut-settings': {\n const shortcutEditor = new BrowserWindow({\n ...commonChildOptions,\n width: 353,\n height: 720,\n modal: false,\n parent: undefined,\n alwaysOnTop: true,\n titleBarOverlay: false,\n });\n\n shortcutEditor.setContentProtection(isContentProtectionOn);\n shortcutEditor.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n shortcutEditor.setWindowButtonVisibility(false);\n }\n\n const loadOptions = { query: { view: 'shortcut-settings' } };\n if (!shouldUseLiquidGlass) {\n shortcutEditor.loadFile(path.join(__dirname, '../ui/app/content.html'), loadOptions);\n } else {\n loadOptions.query.glass = 'true';\n shortcutEditor.loadFile(path.join(__dirname, '../ui/app/content.html'), loadOptions);\n shortcutEditor.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(shortcutEditor.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n }\n });\n }\n\n windowPool.set('shortcut-settings', shortcutEditor);\n if (!app.isPackaged) {\n shortcutEditor.webContents.openDevTools({ mode: 'detach' });\n }\n break;\n }\n }\n };\n\n if (Array.isArray(namesToCreate)) {\n namesToCreate.forEach(name => createFeatureWindow(name));\n } else if (typeof namesToCreate === 'string') {\n createFeatureWindow(namesToCreate);\n } else {\n createFeatureWindow('listen');\n createFeatureWindow('ask');\n createFeatureWindow('settings');\n createFeatureWindow('shortcut-settings');\n }\n}\n\nfunction destroyFeatureWindows() {\n const featureWindows = ['listen','ask','settings','shortcut-settings'];\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n settingsHideTimer = null;\n }\n featureWindows.forEach(name=>{\n const win = windowPool.get(name);\n if (win && !win.isDestroyed()) win.destroy();\n windowPool.delete(name);\n });\n}\n\n\n\nfunction getCurrentDisplay(window) {\n if (!window || window.isDestroyed()) return screen.getPrimaryDisplay();\n\n const windowBounds = window.getBounds();\n const windowCenter = {\n x: windowBounds.x + windowBounds.width / 2,\n y: windowBounds.y + windowBounds.height / 2,\n };\n\n return screen.getDisplayNearestPoint(windowCenter);\n}\n\n\n\nfunction createWindows() {\n const HEADER_HEIGHT = 47;\n const DEFAULT_WINDOW_WIDTH = 353;\n\n const primaryDisplay = screen.getPrimaryDisplay();\n const { y: workAreaY, width: screenWidth } = primaryDisplay.workArea;\n\n const initialX = Math.round((screenWidth - DEFAULT_WINDOW_WIDTH) / 2);\n const initialY = workAreaY + 21;\n \n const header = new BrowserWindow({\n width: DEFAULT_WINDOW_WIDTH,\n height: HEADER_HEIGHT,\n x: initialX,\n y: initialY,\n frame: false,\n transparent: true,\n vibrancy: false,\n hasShadow: false,\n alwaysOnTop: true,\n skipTaskbar: true,\n hiddenInMissionControl: true,\n resizable: false,\n focusable: true,\n acceptFirstMouse: true,\n webPreferences: {\n nodeIntegration: false,\n contextIsolation: true,\n preload: path.join(__dirname, '../preload.js'),\n backgroundThrottling: false,\n webSecurity: false,\n enableRemoteModule: false,\n // Ensure proper rendering and prevent pixelation\n experimentalFeatures: false,\n },\n // Prevent pixelation and ensure proper rendering\n useContentSize: true,\n disableAutoHideCursor: true,\n });\n if (process.platform === 'darwin') {\n header.setWindowButtonVisibility(false);\n }\n const headerLoadOptions = {};\n if (!shouldUseLiquidGlass) {\n header.loadFile(path.join(__dirname, '../ui/app/header.html'), headerLoadOptions);\n }\n else {\n headerLoadOptions.query = { glass: 'true' };\n header.loadFile(path.join(__dirname, '../ui/app/header.html'), headerLoadOptions);\n header.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(header.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1); \n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n windowPool.set('header', header);\n layoutManager = new WindowLayoutManager(windowPool);\n movementManager = new SmoothMovementManager(windowPool);\n\n\n header.on('moved', () => {\n if (movementManager.isAnimating) {\n return;\n }\n updateChildWindowLayouts(false);\n });\n\n header.webContents.once('dom-ready', () => {\n shortcutsService.initialize(windowPool);\n shortcutsService.registerShortcuts();\n });\n\n setupIpcHandlers(windowPool, layoutManager);\n setupWindowController(windowPool, layoutManager, movementManager);\n\n if (currentHeaderState === 'main') {\n createFeatureWindows(header, ['listen', 'ask', 'settings', 'shortcut-settings']);\n }\n\n header.setContentProtection(isContentProtectionOn);\n header.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });\n \n // Open DevTools in development\n if (!app.isPackaged) {\n header.webContents.openDevTools({ mode: 'detach' });\n }\n\n header.on('focus', () => {\n console.log('[WindowManager] Header gained focus');\n });\n\n header.on('blur', () => {\n console.log('[WindowManager] Header lost focus');\n });\n\n header.webContents.on('before-input-event', (event, input) => {\n if (input.type === 'mouseDown') {\n const target = input.target;\n if (target && (target.includes('input') || target.includes('apikey'))) {\n header.focus();\n }\n }\n });\n\n header.on('resize', () => updateChildWindowLayouts(false));\n\n return windowPool;\n}\n\n\nfunction setupIpcHandlers(windowPool, layoutManager) {\n screen.on('display-added', (event, newDisplay) => {\n console.log('[Display] New display added:', newDisplay.id);\n });\n\n screen.on('display-removed', (event, oldDisplay) => {\n console.log('[Display] Display removed:', oldDisplay.id);\n const header = windowPool.get('header');\n\n if (header && getCurrentDisplay(header).id === oldDisplay.id) {\n const primaryDisplay = screen.getPrimaryDisplay();\n const newPosition = layoutManager.calculateNewPositionForDisplay(header, primaryDisplay.id);\n if (newPosition) {\n // 복구 상황이므로 애니메이션 없이 즉시 이동\n header.setPosition(newPosition.x, newPosition.y, false);\n updateChildWindowLayouts(false);\n }\n }\n });\n\n screen.on('display-metrics-changed', (event, display, changedMetrics) => {\n // 레이아웃 업데이트 함수를 새 버전으로 호출\n updateChildWindowLayouts(false);\n });\n}\n\n\nconst handleHeaderStateChanged = (state) => {\n console.log(`[WindowManager] Header state changed to: ${state}`);\n currentHeaderState = state;\n\n if (state === 'main') {\n createFeatureWindows(windowPool.get('header'));\n } else { // 'apikey' | 'permission'\n destroyFeatureWindows();\n }\n internalBridge.emit('reregister-shortcuts');\n};\n\n\nmodule.exports = {\n createWindows,\n windowPool,\n toggleContentProtection,\n resizeHeaderWindow,\n getContentProtectionStatus,\n showSettingsWindow,\n hideSettingsWindow,\n cancelHideSettingsWindow,\n openLoginPage,\n moveWindowStep,\n handleHeaderStateChanged,\n handleHeaderAnimationFinished,\n getHeaderPosition,\n moveHeaderTo,\n adjustWindowHeight,\n};"], ["/glass/src/features/listen/stt/sttService.js", "const { BrowserWindow } = require('electron');\nconst { spawn } = require('child_process');\nconst { createSTT } = require('../../common/ai/factory');\nconst modelStateService = require('../../common/services/modelStateService');\n\nconst COMPLETION_DEBOUNCE_MS = 2000;\n\n// ── New heartbeat / renewal constants ────────────────────────────────────────────\n// Interval to send low-cost keep-alive messages so the remote service does not\n// treat the connection as idle. One minute is safely below the typical 2-5 min\n// idle timeout window seen on provider websockets.\nconst KEEP_ALIVE_INTERVAL_MS = 60 * 1000; // 1 minute\n\n// Interval after which we pro-actively tear down and recreate the STT sessions\n// to dodge the 30-minute hard timeout enforced by some providers. 20 minutes\n// gives a 10-minute safety buffer.\nconst SESSION_RENEW_INTERVAL_MS = 20 * 60 * 1000; // 20 minutes\n\n// Duration to allow the old and new sockets to run in parallel so we don't\n// miss any packets at the exact swap moment.\nconst SOCKET_OVERLAP_MS = 2 * 1000; // 2 seconds\n\nclass SttService {\n constructor() {\n this.mySttSession = null;\n this.theirSttSession = null;\n this.myCurrentUtterance = '';\n this.theirCurrentUtterance = '';\n \n // Turn-completion debouncing\n this.myCompletionBuffer = '';\n this.theirCompletionBuffer = '';\n this.myCompletionTimer = null;\n this.theirCompletionTimer = null;\n \n // System audio capture\n this.systemAudioProc = null;\n\n // Keep-alive / renewal timers\n this.keepAliveInterval = null;\n this.sessionRenewTimeout = null;\n\n // Callbacks\n this.onTranscriptionComplete = null;\n this.onStatusUpdate = null;\n\n this.modelInfo = null; \n }\n\n setCallbacks({ onTranscriptionComplete, onStatusUpdate }) {\n this.onTranscriptionComplete = onTranscriptionComplete;\n this.onStatusUpdate = onStatusUpdate;\n }\n\n sendToRenderer(channel, data) {\n // Listen 관련 이벤트는 Listen 윈도우에만 전송 (Ask 윈도우 충돌 방지)\n const { windowPool } = require('../../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n async handleSendSystemAudioContent(data, mimeType) {\n try {\n await this.sendSystemAudioContent(data, mimeType);\n this.sendToRenderer('system-audio-data', { data });\n return { success: true };\n } catch (error) {\n console.error('Error sending system audio:', error);\n return { success: false, error: error.message };\n }\n }\n\n flushMyCompletion() {\n const finalText = (this.myCompletionBuffer + this.myCurrentUtterance).trim();\n if (!this.modelInfo || !finalText) return;\n\n // Notify completion callback\n if (this.onTranscriptionComplete) {\n this.onTranscriptionComplete('Me', finalText);\n }\n \n // Send to renderer as final\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n\n this.myCompletionBuffer = '';\n this.myCompletionTimer = null;\n this.myCurrentUtterance = '';\n \n if (this.onStatusUpdate) {\n this.onStatusUpdate('Listening...');\n }\n }\n\n flushTheirCompletion() {\n const finalText = (this.theirCompletionBuffer + this.theirCurrentUtterance).trim();\n if (!this.modelInfo || !finalText) return;\n \n // Notify completion callback\n if (this.onTranscriptionComplete) {\n this.onTranscriptionComplete('Them', finalText);\n }\n \n // Send to renderer as final\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n\n this.theirCompletionBuffer = '';\n this.theirCompletionTimer = null;\n this.theirCurrentUtterance = '';\n \n if (this.onStatusUpdate) {\n this.onStatusUpdate('Listening...');\n }\n }\n\n debounceMyCompletion(text) {\n if (this.modelInfo?.provider === 'gemini') {\n this.myCompletionBuffer += text;\n } else {\n this.myCompletionBuffer += (this.myCompletionBuffer ? ' ' : '') + text;\n }\n\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = setTimeout(() => this.flushMyCompletion(), COMPLETION_DEBOUNCE_MS);\n }\n\n debounceTheirCompletion(text) {\n if (this.modelInfo?.provider === 'gemini') {\n this.theirCompletionBuffer += text;\n } else {\n this.theirCompletionBuffer += (this.theirCompletionBuffer ? ' ' : '') + text;\n }\n\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = setTimeout(() => this.flushTheirCompletion(), COMPLETION_DEBOUNCE_MS);\n }\n\n async initializeSttSessions(language = 'en') {\n const effectiveLanguage = process.env.OPENAI_TRANSCRIBE_LANG || language || 'en';\n\n const modelInfo = await modelStateService.getCurrentModelInfo('stt');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key is not configured.');\n }\n this.modelInfo = modelInfo;\n console.log(`[SttService] Initializing STT for ${modelInfo.provider} using model ${modelInfo.model}`);\n\n const handleMyMessage = message => {\n if (!this.modelInfo) {\n console.log('[SttService] Ignoring message - session already closed');\n return;\n }\n // console.log('[SttService] handleMyMessage', message);\n \n if (this.modelInfo.provider === 'whisper') {\n // Whisper STT emits 'transcription' events with different structure\n if (message.text && message.text.trim()) {\n const finalText = message.text.trim();\n \n // Filter out Whisper noise transcriptions\n const noisePatterns = [\n '[BLANK_AUDIO]',\n '[INAUDIBLE]',\n '[MUSIC]',\n '[SOUND]',\n '[NOISE]',\n '(BLANK_AUDIO)',\n '(INAUDIBLE)',\n '(MUSIC)',\n '(SOUND)',\n '(NOISE)'\n ];\n \n const isNoise = noisePatterns.some(pattern => \n finalText.includes(pattern) || finalText === pattern\n );\n \n \n if (!isNoise && finalText.length > 2) {\n this.debounceMyCompletion(finalText);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n } else {\n console.log(`[Whisper-Me] Filtered noise: \"${finalText}\"`);\n }\n }\n return;\n } else if (this.modelInfo.provider === 'gemini') {\n if (!message.serverContent?.modelTurn) {\n console.log('[Gemini STT - Me]', JSON.stringify(message, null, 2));\n }\n\n if (message.serverContent?.turnComplete) {\n if (this.myCompletionTimer) {\n clearTimeout(this.myCompletionTimer);\n this.flushMyCompletion();\n }\n return;\n }\n \n const transcription = message.serverContent?.inputTranscription;\n if (!transcription || !transcription.text) return;\n \n const textChunk = transcription.text;\n if (!textChunk.trim() || textChunk.trim() === '') {\n return; // 1. Ignore whitespace-only chunks or noise\n }\n \n this.debounceMyCompletion(textChunk);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: this.myCompletionBuffer,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n \n // Deepgram \n } else if (this.modelInfo.provider === 'deepgram') {\n const text = message.channel?.alternatives?.[0]?.transcript;\n if (!text || text.trim().length === 0) return;\n\n const isFinal = message.is_final;\n console.log(`[SttService-Me-Deepgram] Received: isFinal=${isFinal}, text=\"${text}\"`);\n\n if (isFinal) {\n // 최종 결과가 도착하면, 현재 진행중인 부분 발화는 비우고\n // 최종 텍스트로 debounce를 실행합니다.\n this.myCurrentUtterance = ''; \n this.debounceMyCompletion(text); \n } else {\n // 부분 결과(interim)인 경우, 화면에 실시간으로 업데이트합니다.\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n\n this.myCurrentUtterance = text;\n \n const continuousText = (this.myCompletionBuffer + ' ' + this.myCurrentUtterance).trim();\n\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n \n } else {\n const type = message.type;\n const text = message.transcript || message.delta || (message.alternatives && message.alternatives[0]?.transcript) || '';\n\n if (type === 'conversation.item.input_audio_transcription.delta') {\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n this.myCurrentUtterance += text;\n const continuousText = this.myCompletionBuffer + (this.myCompletionBuffer ? ' ' : '') + this.myCurrentUtterance;\n if (text && !text.includes('vq_lbr_audio_')) {\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n } else if (type === 'conversation.item.input_audio_transcription.completed') {\n if (text && text.trim()) {\n const finalUtteranceText = text.trim();\n this.myCurrentUtterance = '';\n this.debounceMyCompletion(finalUtteranceText);\n }\n }\n }\n\n if (message.error) {\n console.error('[Me] STT Session Error:', message.error);\n }\n };\n\n const handleTheirMessage = message => {\n if (!message || typeof message !== 'object') return;\n\n if (!this.modelInfo) {\n console.log('[SttService] Ignoring message - session already closed');\n return;\n }\n \n if (this.modelInfo.provider === 'whisper') {\n // Whisper STT emits 'transcription' events with different structure\n if (message.text && message.text.trim()) {\n const finalText = message.text.trim();\n \n // Filter out Whisper noise transcriptions\n const noisePatterns = [\n '[BLANK_AUDIO]',\n '[INAUDIBLE]',\n '[MUSIC]',\n '[SOUND]',\n '[NOISE]',\n '(BLANK_AUDIO)',\n '(INAUDIBLE)',\n '(MUSIC)',\n '(SOUND)',\n '(NOISE)'\n ];\n \n const isNoise = noisePatterns.some(pattern => \n finalText.includes(pattern) || finalText === pattern\n );\n \n \n // Only process if it's not noise, not a false positive, and has meaningful content\n if (!isNoise && finalText.length > 2) {\n this.debounceTheirCompletion(finalText);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n } else {\n console.log(`[Whisper-Them] Filtered noise: \"${finalText}\"`);\n }\n }\n return;\n } else if (this.modelInfo.provider === 'gemini') {\n if (!message.serverContent?.modelTurn) {\n console.log('[Gemini STT - Them]', JSON.stringify(message, null, 2));\n }\n\n if (message.serverContent?.turnComplete) {\n if (this.theirCompletionTimer) {\n clearTimeout(this.theirCompletionTimer);\n this.flushTheirCompletion();\n }\n return;\n }\n \n const transcription = message.serverContent?.inputTranscription;\n if (!transcription || !transcription.text) return;\n\n const textChunk = transcription.text;\n if (!textChunk.trim() || textChunk.trim() === '') {\n return; // 1. Ignore whitespace-only chunks or noise\n }\n\n this.debounceTheirCompletion(textChunk);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: this.theirCompletionBuffer,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n\n // Deepgram\n } else if (this.modelInfo.provider === 'deepgram') {\n const text = message.channel?.alternatives?.[0]?.transcript;\n if (!text || text.trim().length === 0) return;\n\n const isFinal = message.is_final;\n\n if (isFinal) {\n this.theirCurrentUtterance = ''; \n this.debounceTheirCompletion(text); \n } else {\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n\n this.theirCurrentUtterance = text;\n \n const continuousText = (this.theirCompletionBuffer + ' ' + this.theirCurrentUtterance).trim();\n\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n\n } else {\n const type = message.type;\n const text = message.transcript || message.delta || (message.alternatives && message.alternatives[0]?.transcript) || '';\n if (type === 'conversation.item.input_audio_transcription.delta') {\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n this.theirCurrentUtterance += text;\n const continuousText = this.theirCompletionBuffer + (this.theirCompletionBuffer ? ' ' : '') + this.theirCurrentUtterance;\n if (text && !text.includes('vq_lbr_audio_')) {\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n } else if (type === 'conversation.item.input_audio_transcription.completed') {\n if (text && text.trim()) {\n const finalUtteranceText = text.trim();\n this.theirCurrentUtterance = '';\n this.debounceTheirCompletion(finalUtteranceText);\n }\n }\n }\n \n if (message.error) {\n console.error('[Them] STT Session Error:', message.error);\n }\n };\n\n const mySttConfig = {\n language: effectiveLanguage,\n callbacks: {\n onmessage: handleMyMessage,\n onerror: error => console.error('My STT session error:', error.message),\n onclose: event => console.log('My STT session closed:', event.reason),\n },\n };\n \n const theirSttConfig = {\n language: effectiveLanguage,\n callbacks: {\n onmessage: handleTheirMessage,\n onerror: error => console.error('Their STT session error:', error.message),\n onclose: event => console.log('Their STT session closed:', event.reason),\n },\n };\n \n const sttOptions = {\n apiKey: this.modelInfo.apiKey,\n language: effectiveLanguage,\n usePortkey: this.modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: this.modelInfo.provider === 'openai-glass' ? this.modelInfo.apiKey : undefined,\n };\n\n // Add sessionType for Whisper to distinguish between My and Their sessions\n const myOptions = { ...sttOptions, callbacks: mySttConfig.callbacks, sessionType: 'my' };\n const theirOptions = { ...sttOptions, callbacks: theirSttConfig.callbacks, sessionType: 'their' };\n\n [this.mySttSession, this.theirSttSession] = await Promise.all([\n createSTT(this.modelInfo.provider, myOptions),\n createSTT(this.modelInfo.provider, theirOptions),\n ]);\n\n console.log('✅ Both STT sessions initialized successfully.');\n\n // ── Setup keep-alive heart-beats ────────────────────────────────────────\n if (this.keepAliveInterval) clearInterval(this.keepAliveInterval);\n this.keepAliveInterval = setInterval(() => {\n this._sendKeepAlive();\n }, KEEP_ALIVE_INTERVAL_MS);\n\n // ── Schedule session auto-renewal ───────────────────────────────────────\n if (this.sessionRenewTimeout) clearTimeout(this.sessionRenewTimeout);\n this.sessionRenewTimeout = setTimeout(async () => {\n try {\n console.log('[SttService] Auto-renewing STT sessions…');\n await this.renewSessions(language);\n } catch (err) {\n console.error('[SttService] Failed to renew STT sessions:', err);\n }\n }, SESSION_RENEW_INTERVAL_MS);\n\n return true;\n }\n\n /**\n * Send a lightweight keep-alive to prevent idle disconnects.\n * Currently only implemented for OpenAI provider because Gemini's SDK\n * already performs its own heart-beats.\n */\n _sendKeepAlive() {\n if (!this.isSessionActive()) return;\n\n if (this.modelInfo?.provider === 'openai') {\n try {\n this.mySttSession?.keepAlive?.();\n this.theirSttSession?.keepAlive?.();\n } catch (err) {\n console.error('[SttService] keepAlive error:', err.message);\n }\n }\n }\n\n /**\n * Gracefully tears down then recreates the STT sessions. Should be invoked\n * on a timer to avoid provider-side hard timeouts.\n */\n async renewSessions(language = 'en') {\n if (!this.isSessionActive()) {\n console.warn('[SttService] renewSessions called but no active session.');\n return;\n }\n\n const oldMySession = this.mySttSession;\n const oldTheirSession = this.theirSttSession;\n\n console.log('[SttService] Spawning fresh STT sessions in the background…');\n\n // We reuse initializeSttSessions to create fresh sessions with the same\n // language and handlers. The method will update the session pointers\n // and timers, but crucially it does NOT touch the system audio capture\n // pipeline, so audio continues flowing uninterrupted.\n await this.initializeSttSessions(language);\n\n // Close the old sessions after a short overlap window.\n setTimeout(() => {\n try {\n oldMySession?.close?.();\n oldTheirSession?.close?.();\n console.log('[SttService] Old STT sessions closed after hand-off.');\n } catch (err) {\n console.error('[SttService] Error closing old STT sessions:', err.message);\n }\n }, SOCKET_OVERLAP_MS);\n }\n\n async sendMicAudioContent(data, mimeType) {\n // const provider = await this.getAiProvider();\n // const isGemini = provider === 'gemini';\n \n if (!this.mySttSession) {\n throw new Error('User STT session not active');\n }\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data, mimeType: mimeType || 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(data, 'base64'); \n } else {\n payload = data;\n }\n await this.mySttSession.sendRealtimeInput(payload);\n }\n\n async sendSystemAudioContent(data, mimeType) {\n if (!this.theirSttSession) {\n throw new Error('Their STT session not active');\n }\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data, mimeType: mimeType || 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(data, 'base64');\n } else {\n payload = data;\n }\n\n await this.theirSttSession.sendRealtimeInput(payload);\n }\n\n killExistingSystemAudioDump() {\n return new Promise(resolve => {\n console.log('Checking for existing SystemAudioDump processes...');\n\n const killProc = spawn('pkill', ['-f', 'SystemAudioDump'], {\n stdio: 'ignore',\n });\n\n killProc.on('close', code => {\n if (code === 0) {\n console.log('Killed existing SystemAudioDump processes');\n } else {\n console.log('No existing SystemAudioDump processes found');\n }\n resolve();\n });\n\n killProc.on('error', err => {\n console.log('Error checking for existing processes (this is normal):', err.message);\n resolve();\n });\n\n setTimeout(() => {\n killProc.kill();\n resolve();\n }, 2000);\n });\n }\n\n async startMacOSAudioCapture() {\n if (process.platform !== 'darwin' || !this.theirSttSession) return false;\n\n await this.killExistingSystemAudioDump();\n console.log('Starting macOS audio capture for \"Them\"...');\n\n const { app } = require('electron');\n const path = require('path');\n const systemAudioPath = app.isPackaged\n ? path.join(process.resourcesPath, 'app.asar.unpacked', 'src', 'ui', 'assets', 'SystemAudioDump')\n : path.join(app.getAppPath(), 'src', 'ui', 'assets', 'SystemAudioDump');\n\n console.log('SystemAudioDump path:', systemAudioPath);\n\n this.systemAudioProc = spawn(systemAudioPath, [], {\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n\n if (!this.systemAudioProc.pid) {\n console.error('Failed to start SystemAudioDump');\n return false;\n }\n\n console.log('SystemAudioDump started with PID:', this.systemAudioProc.pid);\n\n const CHUNK_DURATION = 0.1;\n const SAMPLE_RATE = 24000;\n const BYTES_PER_SAMPLE = 2;\n const CHANNELS = 2;\n const CHUNK_SIZE = SAMPLE_RATE * BYTES_PER_SAMPLE * CHANNELS * CHUNK_DURATION;\n\n let audioBuffer = Buffer.alloc(0);\n\n // const provider = await this.getAiProvider();\n // const isGemini = provider === 'gemini';\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n this.systemAudioProc.stdout.on('data', async data => {\n audioBuffer = Buffer.concat([audioBuffer, data]);\n\n while (audioBuffer.length >= CHUNK_SIZE) {\n const chunk = audioBuffer.slice(0, CHUNK_SIZE);\n audioBuffer = audioBuffer.slice(CHUNK_SIZE);\n\n const monoChunk = CHANNELS === 2 ? this.convertStereoToMono(chunk) : chunk;\n const base64Data = monoChunk.toString('base64');\n\n this.sendToRenderer('system-audio-data', { data: base64Data });\n\n if (this.theirSttSession) {\n try {\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data: base64Data, mimeType: 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(base64Data, 'base64');\n } else {\n payload = base64Data;\n }\n\n await this.theirSttSession.sendRealtimeInput(payload);\n } catch (err) {\n console.error('Error sending system audio:', err.message);\n }\n }\n }\n });\n\n this.systemAudioProc.stderr.on('data', data => {\n console.error('SystemAudioDump stderr:', data.toString());\n });\n\n this.systemAudioProc.on('close', code => {\n console.log('SystemAudioDump process closed with code:', code);\n this.systemAudioProc = null;\n });\n\n this.systemAudioProc.on('error', err => {\n console.error('SystemAudioDump process error:', err);\n this.systemAudioProc = null;\n });\n\n return true;\n }\n\n convertStereoToMono(stereoBuffer) {\n const samples = stereoBuffer.length / 4;\n const monoBuffer = Buffer.alloc(samples * 2);\n\n for (let i = 0; i < samples; i++) {\n const leftSample = stereoBuffer.readInt16LE(i * 4);\n monoBuffer.writeInt16LE(leftSample, i * 2);\n }\n\n return monoBuffer;\n }\n\n stopMacOSAudioCapture() {\n if (this.systemAudioProc) {\n console.log('Stopping SystemAudioDump...');\n this.systemAudioProc.kill('SIGTERM');\n this.systemAudioProc = null;\n }\n }\n\n isSessionActive() {\n return !!this.mySttSession && !!this.theirSttSession;\n }\n\n async closeSessions() {\n this.stopMacOSAudioCapture();\n\n // Clear heartbeat / renewal timers\n if (this.keepAliveInterval) {\n clearInterval(this.keepAliveInterval);\n this.keepAliveInterval = null;\n }\n if (this.sessionRenewTimeout) {\n clearTimeout(this.sessionRenewTimeout);\n this.sessionRenewTimeout = null;\n }\n\n // Clear timers\n if (this.myCompletionTimer) {\n clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n }\n if (this.theirCompletionTimer) {\n clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n }\n\n const closePromises = [];\n if (this.mySttSession) {\n closePromises.push(this.mySttSession.close());\n this.mySttSession = null;\n }\n if (this.theirSttSession) {\n closePromises.push(this.theirSttSession.close());\n this.theirSttSession = null;\n }\n\n await Promise.all(closePromises);\n console.log('All STT sessions closed.');\n\n // Reset state\n this.myCurrentUtterance = '';\n this.theirCurrentUtterance = '';\n this.myCompletionBuffer = '';\n this.theirCompletionBuffer = '';\n this.modelInfo = null; \n }\n}\n\nmodule.exports = SttService; "], ["/glass/src/features/listen/summary/summaryService.js", "const { BrowserWindow } = require('electron');\nconst { getSystemPrompt } = require('../../common/prompts/promptBuilder.js');\nconst { createLLM } = require('../../common/ai/factory');\nconst sessionRepository = require('../../common/repositories/session');\nconst summaryRepository = require('./repositories');\nconst modelStateService = require('../../common/services/modelStateService');\n\nclass SummaryService {\n constructor() {\n this.previousAnalysisResult = null;\n this.analysisHistory = [];\n this.conversationHistory = [];\n this.currentSessionId = null;\n \n // Callbacks\n this.onAnalysisComplete = null;\n this.onStatusUpdate = null;\n }\n\n setCallbacks({ onAnalysisComplete, onStatusUpdate }) {\n this.onAnalysisComplete = onAnalysisComplete;\n this.onStatusUpdate = onStatusUpdate;\n }\n\n setSessionId(sessionId) {\n this.currentSessionId = sessionId;\n }\n\n sendToRenderer(channel, data) {\n const { windowPool } = require('../../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n addConversationTurn(speaker, text) {\n const conversationText = `${speaker.toLowerCase()}: ${text.trim()}`;\n this.conversationHistory.push(conversationText);\n console.log(`💬 Added conversation text: ${conversationText}`);\n console.log(`📈 Total conversation history: ${this.conversationHistory.length} texts`);\n\n // Trigger analysis if needed\n this.triggerAnalysisIfNeeded();\n }\n\n getConversationHistory() {\n return this.conversationHistory;\n }\n\n resetConversationHistory() {\n this.conversationHistory = [];\n this.previousAnalysisResult = null;\n this.analysisHistory = [];\n console.log('🔄 Conversation history and analysis state reset');\n }\n\n /**\n * Converts conversation history into text to include in the prompt.\n * @param {Array} conversationTexts - Array of conversation texts [\"me: ~~~\", \"them: ~~~\", ...]\n * @param {number} maxTurns - Maximum number of recent turns to include\n * @returns {string} - Formatted conversation string for the prompt\n */\n formatConversationForPrompt(conversationTexts, maxTurns = 30) {\n if (conversationTexts.length === 0) return '';\n return conversationTexts.slice(-maxTurns).join('\\n');\n }\n\n async makeOutlineAndRequests(conversationTexts, maxTurns = 30) {\n console.log(`🔍 makeOutlineAndRequests called - conversationTexts: ${conversationTexts.length}`);\n\n if (conversationTexts.length === 0) {\n console.log('⚠️ No conversation texts available for analysis');\n return null;\n }\n\n const recentConversation = this.formatConversationForPrompt(conversationTexts, maxTurns);\n\n // 이전 분석 결과를 프롬프트에 포함\n let contextualPrompt = '';\n if (this.previousAnalysisResult) {\n contextualPrompt = `\nPrevious Analysis Context:\n- Main Topic: ${this.previousAnalysisResult.topic.header}\n- Key Points: ${this.previousAnalysisResult.summary.slice(0, 3).join(', ')}\n- Last Actions: ${this.previousAnalysisResult.actions.slice(0, 2).join(', ')}\n\nPlease build upon this context while analyzing the new conversation segments.\n`;\n }\n\n const basePrompt = getSystemPrompt('pickle_glass_analysis', '', false);\n const systemPrompt = basePrompt.replace('{{CONVERSATION_HISTORY}}', recentConversation);\n\n try {\n if (this.currentSessionId) {\n await sessionRepository.touch(this.currentSessionId);\n }\n\n const modelInfo = await modelStateService.getCurrentModelInfo('llm');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key is not configured.');\n }\n console.log(`🤖 Sending analysis request to ${modelInfo.provider} using model ${modelInfo.model}`);\n \n const messages = [\n {\n role: 'system',\n content: systemPrompt,\n },\n {\n role: 'user',\n content: `${contextualPrompt}\n\nAnalyze the conversation and provide a structured summary. Format your response as follows:\n\n**Summary Overview**\n- Main discussion point with context\n\n**Key Topic: [Topic Name]**\n- First key insight\n- Second key insight\n- Third key insight\n\n**Extended Explanation**\nProvide 2-3 sentences explaining the context and implications.\n\n**Suggested Questions**\n1. First follow-up question?\n2. Second follow-up question?\n3. Third follow-up question?\n\nKeep all points concise and build upon previous analysis if provided.`,\n },\n ];\n\n console.log('🤖 Sending analysis request to AI...');\n\n const llm = createLLM(modelInfo.provider, {\n apiKey: modelInfo.apiKey,\n model: modelInfo.model,\n temperature: 0.7,\n maxTokens: 1024,\n usePortkey: modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: modelInfo.provider === 'openai-glass' ? modelInfo.apiKey : undefined,\n });\n\n const completion = await llm.chat(messages);\n\n const responseText = completion.content;\n console.log(`✅ Analysis response received: ${responseText}`);\n const structuredData = this.parseResponseText(responseText, this.previousAnalysisResult);\n\n if (this.currentSessionId) {\n try {\n summaryRepository.saveSummary({\n sessionId: this.currentSessionId,\n text: responseText,\n tldr: structuredData.summary.join('\\n'),\n bullet_json: JSON.stringify(structuredData.topic.bullets),\n action_json: JSON.stringify(structuredData.actions),\n model: modelInfo.model\n });\n } catch (err) {\n console.error('[DB] Failed to save summary:', err);\n }\n }\n\n // 분석 결과 저장\n this.previousAnalysisResult = structuredData;\n this.analysisHistory.push({\n timestamp: Date.now(),\n data: structuredData,\n conversationLength: conversationTexts.length,\n });\n\n if (this.analysisHistory.length > 10) {\n this.analysisHistory.shift();\n }\n\n return structuredData;\n } catch (error) {\n console.error('❌ Error during analysis generation:', error.message);\n return this.previousAnalysisResult; // 에러 시 이전 결과 반환\n }\n }\n\n parseResponseText(responseText, previousResult) {\n const structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: ['✉️ Draft a follow-up email', '✅ Generate action items', '📝 Show summary'],\n };\n\n // 이전 결과가 있으면 기본값으로 사용\n if (previousResult) {\n structuredData.topic.header = previousResult.topic.header;\n structuredData.summary = [...previousResult.summary];\n }\n\n try {\n const lines = responseText.split('\\n');\n let currentSection = '';\n let isCapturingTopic = false;\n let topicName = '';\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n // 섹션 헤더 감지\n if (trimmedLine.startsWith('**Summary Overview**')) {\n currentSection = 'summary-overview';\n continue;\n } else if (trimmedLine.startsWith('**Key Topic:')) {\n currentSection = 'topic';\n isCapturingTopic = true;\n topicName = trimmedLine.match(/\\*\\*Key Topic: (.+?)\\*\\*/)?.[1] || '';\n if (topicName) {\n structuredData.topic.header = topicName + ':';\n }\n continue;\n } else if (trimmedLine.startsWith('**Extended Explanation**')) {\n currentSection = 'explanation';\n continue;\n } else if (trimmedLine.startsWith('**Suggested Questions**')) {\n currentSection = 'questions';\n continue;\n }\n\n // 컨텐츠 파싱\n if (trimmedLine.startsWith('-') && currentSection === 'summary-overview') {\n const summaryPoint = trimmedLine.substring(1).trim();\n if (summaryPoint && !structuredData.summary.includes(summaryPoint)) {\n // 기존 summary 업데이트 (최대 5개 유지)\n structuredData.summary.unshift(summaryPoint);\n if (structuredData.summary.length > 5) {\n structuredData.summary.pop();\n }\n }\n } else if (trimmedLine.startsWith('-') && currentSection === 'topic') {\n const bullet = trimmedLine.substring(1).trim();\n if (bullet && structuredData.topic.bullets.length < 3) {\n structuredData.topic.bullets.push(bullet);\n }\n } else if (currentSection === 'explanation' && trimmedLine) {\n // explanation을 topic bullets에 추가 (문장 단위로)\n const sentences = trimmedLine\n .split(/\\.\\s+/)\n .filter(s => s.trim().length > 0)\n .map(s => s.trim() + (s.endsWith('.') ? '' : '.'));\n\n sentences.forEach(sentence => {\n if (structuredData.topic.bullets.length < 3 && !structuredData.topic.bullets.includes(sentence)) {\n structuredData.topic.bullets.push(sentence);\n }\n });\n } else if (trimmedLine.match(/^\\d+\\./) && currentSection === 'questions') {\n const question = trimmedLine.replace(/^\\d+\\.\\s*/, '').trim();\n if (question && question.includes('?')) {\n structuredData.actions.push(`❓ ${question}`);\n }\n }\n }\n\n // 기본 액션 추가\n const defaultActions = ['✨ What should I say next?', '💬 Suggest follow-up questions'];\n defaultActions.forEach(action => {\n if (!structuredData.actions.includes(action)) {\n structuredData.actions.push(action);\n }\n });\n\n // 액션 개수 제한\n structuredData.actions = structuredData.actions.slice(0, 5);\n\n // 유효성 검증 및 이전 데이터 병합\n if (structuredData.summary.length === 0 && previousResult) {\n structuredData.summary = previousResult.summary;\n }\n if (structuredData.topic.bullets.length === 0 && previousResult) {\n structuredData.topic.bullets = previousResult.topic.bullets;\n }\n } catch (error) {\n console.error('❌ Error parsing response text:', error);\n // 에러 시 이전 결과 반환\n return (\n previousResult || {\n summary: [],\n topic: { header: 'Analysis in progress', bullets: [] },\n actions: ['✨ What should I say next?', '💬 Suggest follow-up questions'],\n followUps: ['✉️ Draft a follow-up email', '✅ Generate action items', '📝 Show summary'],\n }\n );\n }\n\n console.log('📊 Final structured data:', JSON.stringify(structuredData, null, 2));\n return structuredData;\n }\n\n /**\n * Triggers analysis when conversation history reaches 5 texts.\n */\n async triggerAnalysisIfNeeded() {\n if (this.conversationHistory.length >= 5 && this.conversationHistory.length % 5 === 0) {\n console.log(`Triggering analysis - ${this.conversationHistory.length} conversation texts accumulated`);\n\n const data = await this.makeOutlineAndRequests(this.conversationHistory);\n if (data) {\n console.log('Sending structured data to renderer');\n this.sendToRenderer('summary-update', data);\n \n // Notify callback\n if (this.onAnalysisComplete) {\n this.onAnalysisComplete(data);\n }\n } else {\n console.log('No analysis data returned');\n }\n }\n }\n\n getCurrentAnalysisData() {\n return {\n previousResult: this.previousAnalysisResult,\n history: this.analysisHistory,\n conversationLength: this.conversationHistory.length,\n };\n }\n}\n\nmodule.exports = SummaryService; "], ["/glass/src/features/ask/askService.js", "const { BrowserWindow } = require('electron');\nconst { createStreamingLLM } = require('../common/ai/factory');\n// Lazy require helper to avoid circular dependency issues\nconst getWindowManager = () => require('../../window/windowManager');\nconst internalBridge = require('../../bridge/internalBridge');\n\nconst getWindowPool = () => {\n try {\n return getWindowManager().windowPool;\n } catch {\n return null;\n }\n};\n\nconst sessionRepository = require('../common/repositories/session');\nconst askRepository = require('./repositories');\nconst { getSystemPrompt } = require('../common/prompts/promptBuilder');\nconst path = require('node:path');\nconst fs = require('node:fs');\nconst os = require('os');\nconst util = require('util');\nconst execFile = util.promisify(require('child_process').execFile);\nconst { desktopCapturer } = require('electron');\nconst modelStateService = require('../common/services/modelStateService');\n\n// Try to load sharp, but don't fail if it's not available\nlet sharp;\ntry {\n sharp = require('sharp');\n console.log('[AskService] Sharp module loaded successfully');\n} catch (error) {\n console.warn('[AskService] Sharp module not available:', error.message);\n console.warn('[AskService] Screenshot functionality will work with reduced image processing capabilities');\n sharp = null;\n}\nlet lastScreenshot = null;\n\nasync function captureScreenshot(options = {}) {\n if (process.platform === 'darwin') {\n try {\n const tempPath = path.join(os.tmpdir(), `screenshot-${Date.now()}.jpg`);\n\n await execFile('screencapture', ['-x', '-t', 'jpg', tempPath]);\n\n const imageBuffer = await fs.promises.readFile(tempPath);\n await fs.promises.unlink(tempPath);\n\n if (sharp) {\n try {\n // Try using sharp for optimal image processing\n const resizedBuffer = await sharp(imageBuffer)\n .resize({ height: 384 })\n .jpeg({ quality: 80 })\n .toBuffer();\n\n const base64 = resizedBuffer.toString('base64');\n const metadata = await sharp(resizedBuffer).metadata();\n\n lastScreenshot = {\n base64,\n width: metadata.width,\n height: metadata.height,\n timestamp: Date.now(),\n };\n\n return { success: true, base64, width: metadata.width, height: metadata.height };\n } catch (sharpError) {\n console.warn('Sharp module failed, falling back to basic image processing:', sharpError.message);\n }\n }\n \n // Fallback: Return the original image without resizing\n console.log('[AskService] Using fallback image processing (no resize/compression)');\n const base64 = imageBuffer.toString('base64');\n \n lastScreenshot = {\n base64,\n width: null, // We don't have metadata without sharp\n height: null,\n timestamp: Date.now(),\n };\n\n return { success: true, base64, width: null, height: null };\n } catch (error) {\n console.error('Failed to capture screenshot:', error);\n return { success: false, error: error.message };\n }\n }\n\n try {\n const sources = await desktopCapturer.getSources({\n types: ['screen'],\n thumbnailSize: {\n width: 1920,\n height: 1080,\n },\n });\n\n if (sources.length === 0) {\n throw new Error('No screen sources available');\n }\n const source = sources[0];\n const buffer = source.thumbnail.toJPEG(70);\n const base64 = buffer.toString('base64');\n const size = source.thumbnail.getSize();\n\n return {\n success: true,\n base64,\n width: size.width,\n height: size.height,\n };\n } catch (error) {\n console.error('Failed to capture screenshot using desktopCapturer:', error);\n return {\n success: false,\n error: error.message,\n };\n }\n}\n\n/**\n * @class\n * @description\n */\nclass AskService {\n constructor() {\n this.abortController = null;\n this.state = {\n isVisible: false,\n isLoading: false,\n isStreaming: false,\n currentQuestion: '',\n currentResponse: '',\n showTextInput: true,\n };\n console.log('[AskService] Service instance created.');\n }\n\n _broadcastState() {\n const askWindow = getWindowPool()?.get('ask');\n if (askWindow && !askWindow.isDestroyed()) {\n askWindow.webContents.send('ask:stateUpdate', this.state);\n }\n }\n\n async toggleAskButton(inputScreenOnly = false) {\n const askWindow = getWindowPool()?.get('ask');\n\n let shouldSendScreenOnly = false;\n if (inputScreenOnly && this.state.showTextInput && askWindow && askWindow.isVisible()) {\n shouldSendScreenOnly = true;\n await this.sendMessage('', []);\n return;\n }\n\n const hasContent = this.state.isLoading || this.state.isStreaming || (this.state.currentResponse && this.state.currentResponse.length > 0);\n\n if (askWindow && askWindow.isVisible() && hasContent) {\n this.state.showTextInput = !this.state.showTextInput;\n this._broadcastState();\n } else {\n if (askWindow && askWindow.isVisible()) {\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: false });\n this.state.isVisible = false;\n } else {\n console.log('[AskService] Showing hidden Ask window');\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: true });\n this.state.isVisible = true;\n }\n if (this.state.isVisible) {\n this.state.showTextInput = true;\n this._broadcastState();\n }\n }\n }\n\n async closeAskWindow () {\n if (this.abortController) {\n this.abortController.abort('Window closed by user');\n this.abortController = null;\n }\n \n this.state = {\n isVisible : false,\n isLoading : false,\n isStreaming : false,\n currentQuestion: '',\n currentResponse: '',\n showTextInput : true,\n };\n this._broadcastState();\n \n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: false });\n \n return { success: true };\n }\n \n\n /**\n * \n * @param {string[]} conversationTexts\n * @returns {string}\n * @private\n */\n _formatConversationForPrompt(conversationTexts) {\n if (!conversationTexts || conversationTexts.length === 0) {\n return 'No conversation history available.';\n }\n return conversationTexts.slice(-30).join('\\n');\n }\n\n /**\n * \n * @param {string} userPrompt\n * @returns {Promise<{success: boolean, response?: string, error?: string}>}\n */\n async sendMessage(userPrompt, conversationHistoryRaw=[]) {\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: true });\n this.state = {\n ...this.state,\n isLoading: true,\n isStreaming: false,\n currentQuestion: userPrompt,\n currentResponse: '',\n showTextInput: false,\n };\n this._broadcastState();\n\n if (this.abortController) {\n this.abortController.abort('New request received.');\n }\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n\n\n let sessionId;\n\n try {\n console.log(`[AskService] 🤖 Processing message: ${userPrompt.substring(0, 50)}...`);\n\n sessionId = await sessionRepository.getOrCreateActive('ask');\n await askRepository.addAiMessage({ sessionId, role: 'user', content: userPrompt.trim() });\n console.log(`[AskService] DB: Saved user prompt to session ${sessionId}`);\n \n const modelInfo = await modelStateService.getCurrentModelInfo('llm');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key not configured.');\n }\n console.log(`[AskService] Using model: ${modelInfo.model} for provider: ${modelInfo.provider}`);\n\n const screenshotResult = await captureScreenshot({ quality: 'medium' });\n const screenshotBase64 = screenshotResult.success ? screenshotResult.base64 : null;\n\n const conversationHistory = this._formatConversationForPrompt(conversationHistoryRaw);\n\n const systemPrompt = getSystemPrompt('pickle_glass_analysis', conversationHistory, false);\n\n const messages = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: [\n { type: 'text', text: `User Request: ${userPrompt.trim()}` },\n ],\n },\n ];\n\n if (screenshotBase64) {\n messages[1].content.push({\n type: 'image_url',\n image_url: { url: `data:image/jpeg;base64,${screenshotBase64}` },\n });\n }\n \n const streamingLLM = createStreamingLLM(modelInfo.provider, {\n apiKey: modelInfo.apiKey,\n model: modelInfo.model,\n temperature: 0.7,\n maxTokens: 2048,\n usePortkey: modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: modelInfo.provider === 'openai-glass' ? modelInfo.apiKey : undefined,\n });\n\n try {\n const response = await streamingLLM.streamChat(messages);\n const askWin = getWindowPool()?.get('ask');\n\n if (!askWin || askWin.isDestroyed()) {\n console.error(\"[AskService] Ask window is not available to send stream to.\");\n response.body.getReader().cancel();\n return { success: false, error: 'Ask window is not available.' };\n }\n\n const reader = response.body.getReader();\n signal.addEventListener('abort', () => {\n console.log(`[AskService] Aborting stream reader. Reason: ${signal.reason}`);\n reader.cancel(signal.reason).catch(() => { /* 이미 취소된 경우의 오류는 무시 */ });\n });\n\n await this._processStream(reader, askWin, sessionId, signal);\n return { success: true };\n\n } catch (multimodalError) {\n // 멀티모달 요청이 실패했고 스크린샷이 포함되어 있다면 텍스트만으로 재시도\n if (screenshotBase64 && this._isMultimodalError(multimodalError)) {\n console.log(`[AskService] Multimodal request failed, retrying with text-only: ${multimodalError.message}`);\n \n // 텍스트만으로 메시지 재구성\n const textOnlyMessages = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: `User Request: ${userPrompt.trim()}`\n }\n ];\n\n const fallbackResponse = await streamingLLM.streamChat(textOnlyMessages);\n const askWin = getWindowPool()?.get('ask');\n\n if (!askWin || askWin.isDestroyed()) {\n console.error(\"[AskService] Ask window is not available for fallback response.\");\n fallbackResponse.body.getReader().cancel();\n return { success: false, error: 'Ask window is not available.' };\n }\n\n const fallbackReader = fallbackResponse.body.getReader();\n signal.addEventListener('abort', () => {\n console.log(`[AskService] Aborting fallback stream reader. Reason: ${signal.reason}`);\n fallbackReader.cancel(signal.reason).catch(() => {});\n });\n\n await this._processStream(fallbackReader, askWin, sessionId, signal);\n return { success: true };\n } else {\n // 다른 종류의 에러이거나 스크린샷이 없었다면 그대로 throw\n throw multimodalError;\n }\n }\n\n } catch (error) {\n console.error('[AskService] Error during message processing:', error);\n this.state = {\n ...this.state,\n isLoading: false,\n isStreaming: false,\n showTextInput: true,\n };\n this._broadcastState();\n\n const askWin = getWindowPool()?.get('ask');\n if (askWin && !askWin.isDestroyed()) {\n const streamError = error.message || 'Unknown error occurred';\n askWin.webContents.send('ask-response-stream-error', { error: streamError });\n }\n\n return { success: false, error: error.message };\n }\n }\n\n /**\n * \n * @param {ReadableStreamDefaultReader} reader\n * @param {BrowserWindow} askWin\n * @param {number} sessionId \n * @param {AbortSignal} signal\n * @returns {Promise}\n * @private\n */\n async _processStream(reader, askWin, sessionId, signal) {\n const decoder = new TextDecoder();\n let fullResponse = '';\n\n try {\n this.state.isLoading = false;\n this.state.isStreaming = true;\n this._broadcastState();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value);\n const lines = chunk.split('\\n').filter(line => line.trim() !== '');\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.substring(6);\n if (data === '[DONE]') {\n return; \n }\n try {\n const json = JSON.parse(data);\n const token = json.choices[0]?.delta?.content || '';\n if (token) {\n fullResponse += token;\n this.state.currentResponse = fullResponse;\n this._broadcastState();\n }\n } catch (error) {\n }\n }\n }\n }\n } catch (streamError) {\n if (signal.aborted) {\n console.log(`[AskService] Stream reading was intentionally cancelled. Reason: ${signal.reason}`);\n } else {\n console.error('[AskService] Error while processing stream:', streamError);\n if (askWin && !askWin.isDestroyed()) {\n askWin.webContents.send('ask-response-stream-error', { error: streamError.message });\n }\n }\n } finally {\n this.state.isStreaming = false;\n this.state.currentResponse = fullResponse;\n this._broadcastState();\n if (fullResponse) {\n try {\n await askRepository.addAiMessage({ sessionId, role: 'assistant', content: fullResponse });\n console.log(`[AskService] DB: Saved partial or full assistant response to session ${sessionId} after stream ended.`);\n } catch(dbError) {\n console.error(\"[AskService] DB: Failed to save assistant response after stream ended:\", dbError);\n }\n }\n }\n }\n\n /**\n * 멀티모달 관련 에러인지 판단\n * @private\n */\n _isMultimodalError(error) {\n const errorMessage = error.message?.toLowerCase() || '';\n return (\n errorMessage.includes('vision') ||\n errorMessage.includes('image') ||\n errorMessage.includes('multimodal') ||\n errorMessage.includes('unsupported') ||\n errorMessage.includes('image_url') ||\n errorMessage.includes('400') || // Bad Request often for unsupported features\n errorMessage.includes('invalid') ||\n errorMessage.includes('not supported')\n );\n }\n\n}\n\nconst askService = new AskService();\n\nmodule.exports = askService;"], ["/glass/src/ui/listen/audioCore/listenCapture.js", "const createAecModule = require('./aec.js');\n\nlet aecModPromise = null; // 한 번만 로드\nlet aecMod = null;\nlet aecPtr = 0; // Rust Aec* 1개만 재사용\n\n/** WASM 모듈 가져오고 1회 초기화 */\nasync function getAec () {\n if (aecModPromise) return aecModPromise; // 캐시\n\n aecModPromise = createAecModule().then((M) => {\n aecMod = M; \n\n console.log('WASM Module Loaded:', M); \n // C 심볼 → JS 래퍼 바인딩 (딱 1번)\n M.newPtr = M.cwrap('AecNew', 'number',\n ['number','number','number','number']);\n M.cancel = M.cwrap('AecCancelEcho', null,\n ['number','number','number','number','number']);\n M.destroy = M.cwrap('AecDestroy', null, ['number']);\n return M;\n });\n\n return aecModPromise;\n}\n\n// 바로 로드-실패 로그를 보기 위해\n// getAec().catch(console.error);\n// ---------------------------\n// Constants & Globals\n// ---------------------------\nconst SAMPLE_RATE = 24000;\nconst AUDIO_CHUNK_DURATION = 0.1;\nconst BUFFER_SIZE = 4096;\n\nconst isLinux = window.api.platform.isLinux;\nconst isMacOS = window.api.platform.isMacOS;\n\nlet mediaStream = null;\nlet micMediaStream = null;\nlet audioContext = null;\nlet audioProcessor = null;\nlet systemAudioContext = null;\nlet systemAudioProcessor = null;\n\nlet systemAudioBuffer = [];\nconst MAX_SYSTEM_BUFFER_SIZE = 10;\n\n// ---------------------------\n// Utility helpers (exact from renderer.js)\n// ---------------------------\nfunction isVoiceActive(audioFloat32Array, threshold = 0.005) {\n if (!audioFloat32Array || audioFloat32Array.length === 0) {\n return false;\n }\n\n let sumOfSquares = 0;\n for (let i = 0; i < audioFloat32Array.length; i++) {\n sumOfSquares += audioFloat32Array[i] * audioFloat32Array[i];\n }\n const rms = Math.sqrt(sumOfSquares / audioFloat32Array.length);\n\n // console.log(`VAD RMS: ${rms.toFixed(4)}`); // For debugging VAD threshold\n\n return rms > threshold;\n}\n\nfunction base64ToFloat32Array(base64) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n\n const int16Array = new Int16Array(bytes.buffer);\n const float32Array = new Float32Array(int16Array.length);\n\n for (let i = 0; i < int16Array.length; i++) {\n float32Array[i] = int16Array[i] / 32768.0;\n }\n\n return float32Array;\n}\n\nfunction convertFloat32ToInt16(float32Array) {\n const int16Array = new Int16Array(float32Array.length);\n for (let i = 0; i < float32Array.length; i++) {\n // Improved scaling to prevent clipping\n const s = Math.max(-1, Math.min(1, float32Array[i]));\n int16Array[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n return int16Array;\n}\n\nfunction arrayBufferToBase64(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n/* ───────────────────────── JS ↔︎ WASM 헬퍼 ───────────────────────── */\nfunction int16PtrFromFloat32(mod, f32) {\n const len = f32.length;\n const bytes = len * 2;\n const ptr = mod._malloc(bytes);\n // HEAP16이 없으면 HEAPU8.buffer로 직접 래핑\n const heapBuf = (mod.HEAP16 ? mod.HEAP16.buffer : mod.HEAPU8.buffer);\n const i16 = new Int16Array(heapBuf, ptr, len);\n for (let i = 0; i < len; ++i) {\n const s = Math.max(-1, Math.min(1, f32[i]));\n i16[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n return { ptr, view: i16 };\n}\n\nfunction float32FromInt16View(i16) {\n const out = new Float32Array(i16.length);\n for (let i = 0; i < i16.length; ++i) out[i] = i16[i] / 32768;\n return out;\n}\n\n/* 필요하다면 종료 시 */\nfunction disposeAec () {\n getAec().then(mod => { if (aecPtr) mod.destroy(aecPtr); });\n}\n\n// listenCapture.js\n\nfunction runAecSync(micF32, sysF32) {\n if (!aecMod || !aecPtr || !aecMod.HEAPU8) {\n // console.log('🔊 No AEC module or heap buffer');\n return micF32;\n }\n\n const frameSize = 160; // AEC 모듈 초기화 시 설정한 프레임 크기\n const numFrames = Math.floor(micF32.length / frameSize);\n\n // 최종 처리된 오디오 데이터를 담을 버퍼\n const processedF32 = new Float32Array(micF32.length);\n\n // 시스템 오디오와 마이크 오디오의 길이를 맞춥니다. (안정성 확보)\n let alignedSysF32 = new Float32Array(micF32.length);\n if (sysF32.length > 0) {\n // sysF32를 micF32 길이에 맞게 자르거나 채웁니다.\n const lengthToCopy = Math.min(micF32.length, sysF32.length);\n alignedSysF32.set(sysF32.slice(0, lengthToCopy));\n }\n\n\n // 2400개 샘플을 160개 프레임으로 나누어 루프 실행\n for (let i = 0; i < numFrames; i++) {\n const offset = i * frameSize;\n\n // 현재 프레임에 해당하는 160개 샘플을 잘라냅니다.\n const micFrame = micF32.subarray(offset, offset + frameSize);\n const echoFrame = alignedSysF32.subarray(offset, offset + frameSize);\n\n // WASM 메모리에 프레임 데이터 쓰기\n const micPtr = int16PtrFromFloat32(aecMod, micFrame);\n const echoPtr = int16PtrFromFloat32(aecMod, echoFrame);\n const outPtr = aecMod._malloc(frameSize * 2); // 160 * 2 bytes\n\n // AEC 실행 (160개 샘플 단위)\n aecMod.cancel(aecPtr, micPtr.ptr, echoPtr.ptr, outPtr, frameSize);\n\n // WASM 메모리에서 처리된 프레임 데이터 읽기\n const heapBuf = (aecMod.HEAP16 ? aecMod.HEAP16.buffer : aecMod.HEAPU8.buffer);\n const outFrameI16 = new Int16Array(heapBuf, outPtr, frameSize);\n const outFrameF32 = float32FromInt16View(outFrameI16);\n\n // 처리된 프레임을 최종 버퍼의 올바른 위치에 복사\n processedF32.set(outFrameF32, offset);\n\n // 할당된 메모리 해제\n aecMod._free(micPtr.ptr);\n aecMod._free(echoPtr.ptr);\n aecMod._free(outPtr);\n }\n\n return processedF32;\n // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲\n // 여기까지가 새로운 로직\n // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲\n}\n\n\n// System audio data handler\nwindow.api.listenCapture.onSystemAudioData((event, { data }) => {\n systemAudioBuffer.push({\n data: data,\n timestamp: Date.now(),\n });\n\n // 오래된 데이터 제거\n if (systemAudioBuffer.length > MAX_SYSTEM_BUFFER_SIZE) {\n systemAudioBuffer = systemAudioBuffer.slice(-MAX_SYSTEM_BUFFER_SIZE);\n }\n});\n\n// ---------------------------\n// Complete token tracker (exact from renderer.js)\n// ---------------------------\nlet tokenTracker = {\n tokens: [],\n audioStartTime: null,\n\n addTokens(count, type = 'image') {\n const now = Date.now();\n this.tokens.push({\n timestamp: now,\n count: count,\n type: type,\n });\n\n this.cleanOldTokens();\n },\n\n calculateImageTokens(width, height) {\n const pixels = width * height;\n if (pixels <= 384 * 384) {\n return 85;\n }\n\n const tiles = Math.ceil(pixels / (768 * 768));\n return tiles * 85;\n },\n\n trackAudioTokens() {\n if (!this.audioStartTime) {\n this.audioStartTime = Date.now();\n return;\n }\n\n const now = Date.now();\n const elapsedSeconds = (now - this.audioStartTime) / 1000;\n\n const audioTokens = Math.floor(elapsedSeconds * 16);\n\n if (audioTokens > 0) {\n this.addTokens(audioTokens, 'audio');\n this.audioStartTime = now;\n }\n },\n\n cleanOldTokens() {\n const oneMinuteAgo = Date.now() - 60 * 1000;\n this.tokens = this.tokens.filter(token => token.timestamp > oneMinuteAgo);\n },\n\n getTokensInLastMinute() {\n this.cleanOldTokens();\n return this.tokens.reduce((total, token) => total + token.count, 0);\n },\n\n shouldThrottle() {\n const throttleEnabled = localStorage.getItem('throttleTokens') === 'true';\n if (!throttleEnabled) {\n return false;\n }\n\n const maxTokensPerMin = parseInt(localStorage.getItem('maxTokensPerMin') || '500000', 10);\n const throttleAtPercent = parseInt(localStorage.getItem('throttleAtPercent') || '75', 10);\n\n const currentTokens = this.getTokensInLastMinute();\n const throttleThreshold = Math.floor((maxTokensPerMin * throttleAtPercent) / 100);\n\n console.log(`Token check: ${currentTokens}/${maxTokensPerMin} (throttle at ${throttleThreshold})`);\n\n return currentTokens >= throttleThreshold;\n },\n\n // Reset the tracker\n reset() {\n this.tokens = [];\n this.audioStartTime = null;\n },\n};\n\n// Track audio tokens every few seconds\nsetInterval(() => {\n tokenTracker.trackAudioTokens();\n}, 2000);\n\n// ---------------------------\n// Audio processing functions (exact from renderer.js)\n// ---------------------------\nasync function setupMicProcessing(micStream) {\n /* ── WASM 먼저 로드 ───────────────────────── */\n const mod = await getAec();\n if (!aecPtr) aecPtr = mod.newPtr(160, 1600, 24000, 1);\n\n\n const micAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n await micAudioContext.resume(); \n const micSource = micAudioContext.createMediaStreamSource(micStream);\n const micProcessor = micAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n micProcessor.onaudioprocess = (e) => {\n const inputData = e.inputBuffer.getChannelData(0);\n audioBuffer.push(...inputData);\n // console.log('🎤 micProcessor.onaudioprocess');\n\n // samplesPerChunk(=2400) 만큼 모이면 전송\n while (audioBuffer.length >= samplesPerChunk) {\n let chunk = audioBuffer.splice(0, samplesPerChunk);\n let processedChunk = new Float32Array(chunk); // 기본값\n\n // ───────────────── WASM AEC ─────────────────\n if (systemAudioBuffer.length > 0) {\n const latest = systemAudioBuffer[systemAudioBuffer.length - 1];\n const sysF32 = base64ToFloat32Array(latest.data);\n\n // **음성 구간일 때만 런**\n processedChunk = runAecSync(new Float32Array(chunk), sysF32);\n // console.log('🔊 Applied WASM-AEC (speex)');\n } else {\n console.log('🔊 No system audio for AEC reference');\n }\n\n const pcm16 = convertFloat32ToInt16(processedChunk);\n const b64 = arrayBufferToBase64(pcm16.buffer);\n\n window.api.listenCapture.sendMicAudioContent({\n data: b64,\n mimeType: 'audio/pcm;rate=24000',\n });\n }\n };\n\n micSource.connect(micProcessor);\n micProcessor.connect(micAudioContext.destination);\n\n audioProcessor = micProcessor;\n return { context: micAudioContext, processor: micProcessor };\n}\n\nfunction setupLinuxMicProcessing(micStream) {\n // Setup microphone audio processing for Linux\n const micAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n const micSource = micAudioContext.createMediaStreamSource(micStream);\n const micProcessor = micAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n micProcessor.onaudioprocess = async e => {\n const inputData = e.inputBuffer.getChannelData(0);\n audioBuffer.push(...inputData);\n\n // Process audio in chunks\n while (audioBuffer.length >= samplesPerChunk) {\n const chunk = audioBuffer.splice(0, samplesPerChunk);\n const pcmData16 = convertFloat32ToInt16(chunk);\n const base64Data = arrayBufferToBase64(pcmData16.buffer);\n\n await window.api.listenCapture.sendMicAudioContent({\n data: base64Data,\n mimeType: 'audio/pcm;rate=24000',\n });\n }\n };\n\n micSource.connect(micProcessor);\n micProcessor.connect(micAudioContext.destination);\n\n // Store processor reference for cleanup\n audioProcessor = micProcessor;\n}\n\nfunction setupSystemAudioProcessing(systemStream) {\n const systemAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n const systemSource = systemAudioContext.createMediaStreamSource(systemStream);\n const systemProcessor = systemAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n systemProcessor.onaudioprocess = async e => {\n const inputData = e.inputBuffer.getChannelData(0);\n if (!inputData || inputData.length === 0) return;\n \n audioBuffer.push(...inputData);\n\n while (audioBuffer.length >= samplesPerChunk) {\n const chunk = audioBuffer.splice(0, samplesPerChunk);\n const pcmData16 = convertFloat32ToInt16(chunk);\n const base64Data = arrayBufferToBase64(pcmData16.buffer);\n\n try {\n await window.api.listenCapture.sendSystemAudioContent({\n data: base64Data,\n mimeType: 'audio/pcm;rate=24000',\n });\n } catch (error) {\n console.error('Failed to send system audio:', error);\n }\n }\n };\n\n systemSource.connect(systemProcessor);\n systemProcessor.connect(systemAudioContext.destination);\n\n return { context: systemAudioContext, processor: systemProcessor };\n}\n\n// ---------------------------\n// Main capture functions (exact from renderer.js)\n// ---------------------------\nasync function startCapture(screenshotIntervalSeconds = 5, imageQuality = 'medium') {\n\n // Reset token tracker when starting new capture session\n tokenTracker.reset();\n console.log('🎯 Token tracker reset for new capture session');\n\n try {\n if (isMacOS) {\n\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n\n // On macOS, use SystemAudioDump for audio and getDisplayMedia for screen\n console.log('Starting macOS capture with SystemAudioDump...');\n\n // Start macOS audio capture\n const audioResult = await window.api.listenCapture.startMacosSystemAudio();\n if (!audioResult.success) {\n console.warn('[listenCapture] macOS audio start failed:', audioResult.error);\n\n // 이미 실행 중 → stop 후 재시도\n if (audioResult.error === 'already_running') {\n await window.api.listenCapture.stopMacosSystemAudio();\n await new Promise(r => setTimeout(r, 500));\n const retry = await window.api.listenCapture.startMacosSystemAudio();\n if (!retry.success) {\n throw new Error('Retry failed: ' + retry.error);\n }\n } else {\n throw new Error('Failed to start macOS audio capture: ' + audioResult.error);\n }\n }\n\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n\n console.log('macOS microphone capture started');\n const { context, processor } = await setupMicProcessing(micMediaStream);\n audioContext = context;\n audioProcessor = processor;\n } catch (micErr) {\n console.warn('Failed to get microphone on macOS:', micErr);\n }\n ////////// for index & subjects //////////\n\n console.log('macOS screen capture started - audio handled by SystemAudioDump');\n } else if (isLinux) {\n\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n \n // Linux - use display media for screen capture and getUserMedia for microphone\n mediaStream = await navigator.mediaDevices.getDisplayMedia({\n video: {\n frameRate: 1,\n width: { ideal: 1920 },\n height: { ideal: 1080 },\n },\n audio: false, // Don't use system audio loopback on Linux\n });\n\n // Get microphone input for Linux\n let micMediaStream = null;\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n\n console.log('Linux microphone capture started');\n\n // Setup audio processing for microphone on Linux\n setupLinuxMicProcessing(micMediaStream);\n } catch (micError) {\n console.warn('Failed to get microphone access on Linux:', micError);\n // Continue without microphone if permission denied\n }\n\n console.log('Linux screen capture started');\n } else {\n // Windows - capture mic and system audio separately using native loopback\n console.log('Starting Windows capture with native loopback audio...');\n\n // Ensure STT sessions are initialized before starting audio capture\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n\n // 1. Get user's microphone\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n console.log('Windows microphone capture started');\n const { context, processor } = await setupMicProcessing(micMediaStream);\n audioContext = context;\n audioProcessor = processor;\n } catch (micErr) {\n console.warn('Could not get microphone access on Windows:', micErr);\n }\n\n // 2. Get system audio using native Electron loopback\n try {\n mediaStream = await navigator.mediaDevices.getDisplayMedia({\n video: true,\n audio: true // This will now use native loopback from our handler\n });\n \n // Verify we got audio tracks\n const audioTracks = mediaStream.getAudioTracks();\n if (audioTracks.length === 0) {\n throw new Error('No audio track in native loopback stream');\n }\n \n console.log('Windows native loopback audio capture started');\n const { context, processor } = setupSystemAudioProcessing(mediaStream);\n systemAudioContext = context;\n systemAudioProcessor = processor;\n } catch (sysAudioErr) {\n console.error('Failed to start Windows native loopback audio:', sysAudioErr);\n // Continue without system audio\n }\n }\n } catch (err) {\n console.error('Error starting capture:', err);\n // Note: pickleGlass.e() is not available in this context, commenting out\n // pickleGlass.e().setStatus('error');\n }\n}\n\nfunction stopCapture() {\n // Clean up microphone resources\n if (audioProcessor) {\n audioProcessor.disconnect();\n audioProcessor = null;\n }\n if (audioContext) {\n audioContext.close();\n audioContext = null;\n }\n\n // Clean up system audio resources\n if (systemAudioProcessor) {\n systemAudioProcessor.disconnect();\n systemAudioProcessor = null;\n }\n if (systemAudioContext) {\n systemAudioContext.close();\n systemAudioContext = null;\n }\n\n // Stop and release media stream tracks\n if (mediaStream) {\n mediaStream.getTracks().forEach(track => track.stop());\n mediaStream = null;\n }\n if (micMediaStream) {\n micMediaStream.getTracks().forEach(t => t.stop());\n micMediaStream = null;\n }\n\n // Stop macOS audio capture if running\n if (isMacOS) {\n window.api.listenCapture.stopMacosSystemAudio().catch(err => {\n console.error('Error stopping macOS audio:', err);\n });\n }\n}\n\n// ---------------------------\n// Exports & global registration\n// ---------------------------\nmodule.exports = {\n getAec, // 새로 만든 초기화 함수\n runAecSync, // sync 버전\n disposeAec, // 필요시 Rust 객체 파괴\n startCapture,\n stopCapture,\n isLinux,\n isMacOS,\n};\n\n// Expose functions to global scope for external access (exact from renderer.js)\nif (typeof window !== 'undefined') {\n window.listenCapture = module.exports;\n window.pickleGlass = window.pickleGlass || {};\n window.pickleGlass.startCapture = startCapture;\n window.pickleGlass.stopCapture = stopCapture;\n} "], ["/glass/src/ui/app/HeaderController.js", "import './MainHeader.js';\nimport './ApiKeyHeader.js';\nimport './PermissionHeader.js';\nimport './WelcomeHeader.js';\n\nclass HeaderTransitionManager {\n constructor() {\n this.headerContainer = document.getElementById('header-container');\n this.currentHeaderType = null; // 'welcome' | 'apikey' | 'main' | 'permission'\n this.welcomeHeader = null;\n this.apiKeyHeader = null;\n this.mainHeader = null;\n this.permissionHeader = null;\n\n /**\n * only one header window is allowed\n * @param {'welcome'|'apikey'|'main'|'permission'} type\n */\n this.ensureHeader = (type) => {\n console.log('[HeaderController] ensureHeader: Ensuring header of type:', type);\n if (this.currentHeaderType === type) {\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'already exists.');\n return;\n }\n\n this.headerContainer.innerHTML = '';\n \n this.welcomeHeader = null;\n this.apiKeyHeader = null;\n this.mainHeader = null;\n this.permissionHeader = null;\n\n // Create new header element\n if (type === 'welcome') {\n this.welcomeHeader = document.createElement('welcome-header');\n this.welcomeHeader.loginCallback = () => this.handleLoginOption();\n this.welcomeHeader.apiKeyCallback = () => this.handleApiKeyOption();\n this.headerContainer.appendChild(this.welcomeHeader);\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'created.');\n } else if (type === 'apikey') {\n this.apiKeyHeader = document.createElement('apikey-header');\n this.apiKeyHeader.stateUpdateCallback = (userState) => this.handleStateUpdate(userState);\n this.apiKeyHeader.backCallback = () => this.transitionToWelcomeHeader();\n this.apiKeyHeader.addEventListener('request-resize', e => {\n this._resizeForApiKey(e.detail.height); \n });\n this.headerContainer.appendChild(this.apiKeyHeader);\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'created.');\n } else if (type === 'permission') {\n this.permissionHeader = document.createElement('permission-setup');\n this.permissionHeader.addEventListener('request-resize', e => {\n this._resizeForPermissionHeader(e.detail.height); \n });\n this.permissionHeader.continueCallback = async () => {\n if (window.api && window.api.headerController) {\n console.log('[HeaderController] Re-initializing model state after permission grant...');\n await window.api.headerController.reInitializeModelState();\n }\n this.transitionToMainHeader();\n };\n this.headerContainer.appendChild(this.permissionHeader);\n } else {\n this.mainHeader = document.createElement('main-header');\n this.headerContainer.appendChild(this.mainHeader);\n this.mainHeader.startSlideInAnimation?.();\n }\n\n this.currentHeaderType = type;\n this.notifyHeaderState(type === 'permission' ? 'apikey' : type); // Keep permission state as apikey for compatibility\n };\n\n console.log('[HeaderController] Manager initialized');\n\n // WelcomeHeader 콜백 메서드들\n this.handleLoginOption = this.handleLoginOption.bind(this);\n this.handleApiKeyOption = this.handleApiKeyOption.bind(this);\n\n this._bootstrap();\n\n if (window.api) {\n window.api.headerController.onUserStateChanged((event, userState) => {\n console.log('[HeaderController] Received user state change:', userState);\n this.handleStateUpdate(userState);\n });\n\n window.api.headerController.onAuthFailed((event, { message }) => {\n console.error('[HeaderController] Received auth failure from main process:', message);\n if (this.apiKeyHeader) {\n this.apiKeyHeader.errorMessage = 'Authentication failed. Please try again.';\n this.apiKeyHeader.isLoading = false;\n }\n });\n window.api.headerController.onForceShowApiKeyHeader(async () => {\n console.log('[HeaderController] Received broadcast to show apikey header. Switching now.');\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n if (!isConfigured) {\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n } else {\n await this._resizeForApiKey();\n this.ensureHeader('apikey');\n }\n }); \n }\n }\n\n notifyHeaderState(stateOverride) {\n const state = stateOverride || this.currentHeaderType || 'apikey';\n if (window.api) {\n window.api.headerController.sendHeaderStateChanged(state);\n }\n }\n\n async _bootstrap() {\n // The initial state will be sent by the main process via 'user-state-changed'\n // We just need to request it.\n if (window.api) {\n const userState = await window.api.common.getCurrentUser();\n console.log('[HeaderController] Bootstrapping with initial user state:', userState);\n this.handleStateUpdate(userState);\n } else {\n // Fallback for non-electron environment (testing/web)\n this.ensureHeader('welcome');\n }\n }\n\n\n //////// after_modelStateService ////////\n async handleStateUpdate(userState) {\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n\n if (isConfigured) {\n // If providers are configured, always check permissions regardless of login state.\n const permissionResult = await this.checkPermissions();\n if (permissionResult.success) {\n this.transitionToMainHeader();\n } else {\n this.transitionToPermissionHeader();\n }\n } else {\n // If no providers are configured, show the welcome header to prompt for setup.\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n }\n }\n\n // WelcomeHeader 콜백 메서드들\n async handleLoginOption() {\n console.log('[HeaderController] Login option selected');\n if (window.api) {\n await window.api.common.startFirebaseAuth();\n }\n }\n\n async handleApiKeyOption() {\n console.log('[HeaderController] API key option selected');\n await this._resizeForApiKey(400);\n this.ensureHeader('apikey');\n // ApiKeyHeader에 뒤로가기 콜백 설정\n if (this.apiKeyHeader) {\n this.apiKeyHeader.backCallback = () => this.transitionToWelcomeHeader();\n }\n }\n\n async transitionToWelcomeHeader() {\n if (this.currentHeaderType === 'welcome') {\n return this._resizeForWelcome();\n }\n\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n }\n //////// after_modelStateService ////////\n\n async transitionToPermissionHeader() {\n // Prevent duplicate transitions\n if (this.currentHeaderType === 'permission') {\n console.log('[HeaderController] Already showing permission setup, skipping transition');\n return;\n }\n\n // Check if permissions were previously completed\n if (window.api) {\n try {\n const permissionsCompleted = await window.api.headerController.checkPermissionsCompleted();\n if (permissionsCompleted) {\n console.log('[HeaderController] Permissions were previously completed, checking current status...');\n \n // Double check current permission status\n const permissionResult = await this.checkPermissions();\n if (permissionResult.success) {\n // Skip permission setup if already granted\n this.transitionToMainHeader();\n return;\n }\n \n console.log('[HeaderController] Permissions were revoked, showing setup again');\n }\n } catch (error) {\n console.error('[HeaderController] Error checking permissions completed status:', error);\n }\n }\n\n let initialHeight = 220;\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n if (userState.mode === 'firebase') {\n initialHeight = 280;\n }\n } catch (e) {\n console.error('Could not get user state for resize', e);\n }\n }\n\n await this._resizeForPermissionHeader(initialHeight);\n this.ensureHeader('permission');\n }\n\n async transitionToMainHeader(animate = true) {\n if (this.currentHeaderType === 'main') {\n return this._resizeForMain();\n }\n\n await this._resizeForMain();\n this.ensureHeader('main');\n }\n\n async _resizeForMain() {\n if (!window.api) return;\n console.log('[HeaderController] _resizeForMain: Resizing window to 353x47');\n return window.api.headerController.resizeHeaderWindow({ width: 353, height: 47 }).catch(() => {});\n }\n\n async _resizeForApiKey(height = 370) {\n if (!window.api) return;\n console.log(`[HeaderController] _resizeForApiKey: Resizing window to 456x${height}`);\n return window.api.headerController.resizeHeaderWindow({ width: 456, height: height }).catch(() => {});\n }\n\n async _resizeForPermissionHeader(height) {\n if (!window.api) return;\n const finalHeight = height || 220;\n return window.api.headerController.resizeHeaderWindow({ width: 285, height: finalHeight })\n .catch(() => {});\n }\n\n async _resizeForWelcome() {\n if (!window.api) return;\n console.log('[HeaderController] _resizeForWelcome: Resizing window to 456x370');\n return window.api.headerController.resizeHeaderWindow({ width: 456, height: 364 })\n .catch(() => {});\n }\n\n async checkPermissions() {\n if (!window.api) {\n return { success: true };\n }\n \n try {\n const permissions = await window.api.headerController.checkSystemPermissions();\n console.log('[HeaderController] Current permissions:', permissions);\n \n if (!permissions.needsSetup) {\n return { success: true };\n }\n\n let errorMessage = '';\n if (!permissions.microphone && !permissions.screen) {\n errorMessage = 'Microphone and screen recording access required';\n }\n \n return { \n success: false, \n error: errorMessage\n };\n } catch (error) {\n console.error('[HeaderController] Error checking permissions:', error);\n return { \n success: false, \n error: 'Failed to check permissions' \n };\n }\n }\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n new HeaderTransitionManager();\n});\n"], ["/glass/src/features/common/services/ollamaService.js", "const { EventEmitter } = require('events');\nconst { spawn, exec } = require('child_process');\nconst { promisify } = require('util');\nconst fetch = require('node-fetch');\nconst path = require('path');\nconst fs = require('fs').promises;\nconst os = require('os');\nconst https = require('https');\nconst crypto = require('crypto');\nconst { app } = require('electron');\nconst { spawnAsync } = require('../utils/spawnHelper');\nconst { DOWNLOAD_CHECKSUMS } = require('../config/checksums');\nconst ollamaModelRepository = require('../repositories/ollamaModel');\n\nconst execAsync = promisify(exec);\n\nclass OllamaService extends EventEmitter {\n constructor() {\n super();\n this.serviceName = 'OllamaService';\n this.baseUrl = 'http://localhost:11434';\n \n // 단순화된 상태 관리\n this.installState = {\n isInstalled: false,\n isInstalling: false,\n progress: 0\n };\n \n // 단순화된 요청 관리 (복잡한 큐 제거)\n this.activeRequest = null;\n this.requestTimeout = 30000; // 30초 타임아웃\n \n // 모델 상태\n this.installedModels = new Map();\n this.modelWarmupStatus = new Map();\n \n // 체크포인트 시스템 (롤백용)\n this.installCheckpoints = [];\n \n // 설치 진행률 관리\n this.installationProgress = new Map();\n \n // 워밍 관련 (기존 유지)\n this.warmingModels = new Map();\n this.warmedModels = new Set();\n this.lastWarmUpAttempt = new Map();\n this.warmupTimeout = 120000; // 120s for model warmup\n \n // 상태 동기화\n this._lastState = null;\n this._syncInterval = null;\n this._lastLoadedModels = [];\n this.modelLoadStatus = new Map();\n \n // 서비스 종료 상태 추적\n this.isShuttingDown = false;\n }\n\n\n // Base class methods integration\n getPlatform() {\n return process.platform;\n }\n\n async checkCommand(command) {\n try {\n const platform = this.getPlatform();\n const checkCmd = platform === 'win32' ? 'where' : 'which';\n const { stdout } = await execAsync(`${checkCmd} ${command}`);\n return stdout.trim();\n } catch (error) {\n return null;\n }\n }\n\n async waitForService(checkFn, maxAttempts = 30, delayMs = 1000) {\n for (let i = 0; i < maxAttempts; i++) {\n if (await checkFn()) {\n console.log(`[${this.serviceName}] Service is ready`);\n return true;\n }\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n throw new Error(`${this.serviceName} service failed to start within timeout`);\n }\n\n getInstallProgress(modelName) {\n return this.installationProgress.get(modelName) || 0;\n }\n\n setInstallProgress(modelName, progress) {\n this.installationProgress.set(modelName, progress);\n }\n\n clearInstallProgress(modelName) {\n this.installationProgress.delete(modelName);\n }\n\n async getStatus() {\n try {\n const installed = await this.isInstalled();\n if (!installed) {\n return { success: true, installed: false, running: false, models: [] };\n }\n\n const running = await this.isServiceRunning();\n if (!running) {\n return { success: true, installed: true, running: false, models: [] };\n }\n\n const models = await this.getInstalledModels();\n return { success: true, installed: true, running: true, models };\n } catch (error) {\n console.error('[OllamaService] Error getting status:', error);\n return { success: false, error: error.message, installed: false, running: false, models: [] };\n }\n }\n\n getOllamaCliPath() {\n if (this.getPlatform() === 'darwin') {\n return '/Applications/Ollama.app/Contents/Resources/ollama';\n }\n return 'ollama';\n }\n\n // === 런타임 관리 (단순화) ===\n async makeRequest(endpoint, options = {}) {\n // 서비스 종료 중이면 요청하지 않음\n if (this.isShuttingDown) {\n throw new Error('Service is shutting down');\n }\n \n // 동시 요청 방지 (단순한 잠금)\n if (this.activeRequest) {\n await this.activeRequest;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.requestTimeout);\n\n this.activeRequest = fetch(`${this.baseUrl}${endpoint}`, {\n ...options,\n signal: controller.signal\n }).finally(() => {\n clearTimeout(timeoutId);\n this.activeRequest = null;\n });\n\n return this.activeRequest;\n }\n\n async isInstalled() {\n try {\n const platform = this.getPlatform();\n \n if (platform === 'darwin') {\n try {\n await fs.access('/Applications/Ollama.app');\n return true;\n } catch {\n const ollamaPath = await this.checkCommand(this.getOllamaCliPath());\n return !!ollamaPath;\n }\n } else {\n const ollamaPath = await this.checkCommand(this.getOllamaCliPath());\n return !!ollamaPath;\n }\n } catch (error) {\n console.log('[OllamaService] Ollama not found:', error.message);\n return false;\n }\n }\n\n async isServiceRunning() {\n try {\n // Use /api/ps to check if service is running\n // This is more reliable than /api/tags which may not show models not in memory\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n return response.ok;\n } catch (error) {\n console.log(`[OllamaService] Service health check failed: ${error.message}`);\n return false;\n }\n }\n\n async startService() {\n // 서비스 시작 시 종료 플래그 리셋\n this.isShuttingDown = false;\n \n const platform = this.getPlatform();\n \n try {\n if (platform === 'darwin') {\n try {\n await spawnAsync('open', ['-a', 'Ollama']);\n await this.waitForService(() => this.isServiceRunning());\n return true;\n } catch {\n spawn(this.getOllamaCliPath(), ['serve'], {\n detached: true,\n stdio: 'ignore'\n }).unref();\n await this.waitForService(() => this.isServiceRunning());\n return true;\n }\n } else {\n spawn(this.getOllamaCliPath(), ['serve'], {\n detached: true,\n stdio: 'ignore',\n shell: platform === 'win32'\n }).unref();\n await this.waitForService(() => this.isServiceRunning());\n return true;\n }\n } catch (error) {\n console.error('[OllamaService] Failed to start service:', error);\n throw error;\n }\n }\n\n async stopService() {\n return await this.shutdown();\n }\n\n // Comprehensive health check using multiple endpoints\n async healthCheck() {\n try {\n const checks = {\n serviceRunning: false,\n apiResponsive: false,\n modelsAccessible: false,\n memoryStatus: false\n };\n \n // 1. Basic service check with /api/ps\n try {\n const psResponse = await this.makeRequest('/api/ps', { method: 'GET' });\n checks.serviceRunning = psResponse.ok;\n checks.memoryStatus = psResponse.ok;\n } catch (error) {\n console.log('[OllamaService] /api/ps check failed:', error.message);\n }\n \n // 2. Check if API is responsive with root endpoint\n try {\n const rootResponse = await this.makeRequest('/', { method: 'GET' });\n checks.apiResponsive = rootResponse.ok;\n } catch (error) {\n console.log('[OllamaService] Root endpoint check failed:', error.message);\n }\n \n // 3. Check if models endpoint is accessible\n try {\n const tagsResponse = await this.makeRequest('/api/tags', { method: 'GET' });\n checks.modelsAccessible = tagsResponse.ok;\n } catch (error) {\n console.log('[OllamaService] /api/tags check failed:', error.message);\n }\n \n const allHealthy = Object.values(checks).every(v => v === true);\n \n return {\n healthy: allHealthy,\n checks,\n timestamp: new Date().toISOString()\n };\n } catch (error) {\n console.error('[OllamaService] Health check failed:', error);\n return {\n healthy: false,\n error: error.message,\n timestamp: new Date().toISOString()\n };\n }\n }\n\n async getInstalledModels() {\n // 서비스 종료 중이면 빈 배열 반환\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, returning empty models list');\n return [];\n }\n \n try {\n const response = await this.makeRequest('/api/tags', {\n method: 'GET'\n });\n \n const data = await response.json();\n return data.models || [];\n } catch (error) {\n console.error('[OllamaService] Failed to get installed models:', error.message);\n return [];\n }\n }\n\n // Get models currently loaded in memory using /api/ps\n async getLoadedModels() {\n // 서비스 종료 중이면 빈 배열 반환\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, returning empty loaded models list');\n return [];\n }\n \n try {\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n if (!response.ok) {\n console.log('[OllamaService] Failed to get loaded models via /api/ps');\n return [];\n }\n \n const data = await response.json();\n // Extract model names from running processes\n return (data.models || []).map(m => m.name);\n } catch (error) {\n console.error('[OllamaService] Error getting loaded models:', error);\n return [];\n }\n }\n \n // Get detailed memory info for loaded models\n async getLoadedModelsWithMemoryInfo() {\n try {\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n if (!response.ok) {\n return [];\n }\n \n const data = await response.json();\n // Return full model info including memory usage\n return data.models || [];\n } catch (error) {\n console.error('[OllamaService] Error getting loaded models info:', error);\n return [];\n }\n }\n \n // Check if a specific model is loaded in memory\n async isModelLoaded(modelName) {\n const loadedModels = await this.getLoadedModels();\n return loadedModels.includes(modelName);\n }\n\n async getInstalledModelsList() {\n try {\n const { stdout } = await spawnAsync(this.getOllamaCliPath(), ['list']);\n const lines = stdout.split('\\n').filter(line => line.trim());\n \n // Skip header line (NAME, ID, SIZE, MODIFIED)\n const modelLines = lines.slice(1);\n \n const models = [];\n for (const line of modelLines) {\n if (!line.trim()) continue;\n \n // Parse line: \"model:tag model_id size modified_time\"\n const parts = line.split(/\\s+/);\n if (parts.length >= 3) {\n models.push({\n name: parts[0],\n id: parts[1],\n size: parts[2] + (parts[3] === 'GB' || parts[3] === 'MB' ? ' ' + parts[3] : ''),\n status: 'installed'\n });\n }\n }\n \n return models;\n } catch (error) {\n console.log('[OllamaService] Failed to get installed models via CLI, falling back to API');\n // Fallback to API if CLI fails\n const apiModels = await this.getInstalledModels();\n return apiModels.map(model => ({\n name: model.name,\n id: model.digest || 'unknown',\n size: model.size || 'Unknown',\n status: 'installed'\n }));\n }\n }\n\n async getModelSuggestions() {\n try {\n // Get actually installed models\n const installedModels = await this.getInstalledModelsList();\n \n // Get user input history from storage (we'll implement this in the frontend)\n // For now, just return installed models\n return installedModels;\n } catch (error) {\n console.error('[OllamaService] Failed to get model suggestions:', error);\n return [];\n }\n }\n\n async isModelInstalled(modelName) {\n const models = await this.getInstalledModels();\n return models.some(model => model.name === modelName);\n }\n\n async pullModel(modelName) {\n if (!modelName?.trim()) {\n throw new Error(`Invalid model name: ${modelName}`);\n }\n\n console.log(`[OllamaService] Starting to pull model: ${modelName} via API`);\n \n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelName, \n progress: 0,\n status: 'starting'\n });\n \n try {\n const response = await fetch(`${this.baseUrl}/api/pull`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n stream: true\n })\n });\n\n if (!response.ok) {\n throw new Error(`Pull API failed: ${response.status} ${response.statusText}`);\n }\n\n // Handle Node.js streaming response\n return new Promise((resolve, reject) => {\n let buffer = '';\n \n response.body.on('data', (chunk) => {\n buffer += chunk.toString();\n const lines = buffer.split('\\n');\n \n // Keep incomplete line in buffer\n buffer = lines.pop() || '';\n \n // Process complete lines\n for (const line of lines) {\n if (!line.trim()) continue;\n \n try {\n const data = JSON.parse(line);\n const progress = this._parseOllamaPullProgress(data, modelName);\n \n if (progress !== null) {\n this.setInstallProgress(modelName, progress);\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelName, \n progress,\n status: data.status || 'downloading'\n });\n console.log(`[OllamaService] API Progress: ${progress}% for ${modelName} (${data.status || 'downloading'})`);\n }\n\n // Handle completion\n if (data.status === 'success') {\n console.log(`[OllamaService] Successfully pulled model: ${modelName}`);\n this.emit('model-pull-complete', { model: modelName });\n this.clearInstallProgress(modelName);\n resolve();\n return;\n }\n } catch (parseError) {\n console.warn('[OllamaService] Failed to parse response line:', line);\n }\n }\n });\n\n response.body.on('end', () => {\n // Process any remaining data in buffer\n if (buffer.trim()) {\n try {\n const data = JSON.parse(buffer);\n if (data.status === 'success') {\n console.log(`[OllamaService] Successfully pulled model: ${modelName}`);\n this.emit('model-pull-complete', { model: modelName });\n }\n } catch (parseError) {\n console.warn('[OllamaService] Failed to parse final buffer:', buffer);\n }\n }\n this.clearInstallProgress(modelName);\n resolve();\n });\n\n response.body.on('error', (error) => {\n console.error(`[OllamaService] Stream error for ${modelName}:`, error);\n this.clearInstallProgress(modelName);\n reject(error);\n });\n });\n } catch (error) {\n this.clearInstallProgress(modelName);\n console.error(`[OllamaService] Pull model failed:`, error);\n throw error;\n }\n }\n\n _parseOllamaPullProgress(data, modelName) {\n // Handle Ollama API response format\n if (data.status === 'success') {\n return 100;\n }\n\n // Handle downloading progress\n if (data.total && data.completed !== undefined) {\n const progress = Math.round((data.completed / data.total) * 100);\n return Math.min(progress, 99); // Don't show 100% until success\n }\n\n // Handle status-based progress\n const statusProgress = {\n 'pulling manifest': 5,\n 'downloading': 10,\n 'verifying sha256 digest': 90,\n 'writing manifest': 95,\n 'removing any unused layers': 98\n };\n\n if (data.status && statusProgress[data.status] !== undefined) {\n return statusProgress[data.status];\n }\n\n return null;\n }\n\n\n\n async downloadFile(url, destination, options = {}) {\n const { \n onProgress = null,\n headers = { 'User-Agent': 'Glass-App' },\n timeout = 300000,\n modelId = null\n } = options;\n\n return new Promise((resolve, reject) => {\n const file = require('fs').createWriteStream(destination);\n let downloadedSize = 0;\n let totalSize = 0;\n\n const request = https.get(url, { headers }, (response) => {\n if ([301, 302, 307, 308].includes(response.statusCode)) {\n file.close();\n require('fs').unlink(destination, () => {});\n \n if (!response.headers.location) {\n reject(new Error('Redirect without location header'));\n return;\n }\n \n console.log(`[${this.serviceName}] Following redirect from ${url} to ${response.headers.location}`);\n this.downloadFile(response.headers.location, destination, options)\n .then(resolve)\n .catch(reject);\n return;\n }\n\n if (response.statusCode !== 200) {\n file.close();\n require('fs').unlink(destination, () => {});\n reject(new Error(`Download failed: ${response.statusCode} ${response.statusMessage}`));\n return;\n }\n\n totalSize = parseInt(response.headers['content-length'], 10) || 0;\n\n response.on('data', (chunk) => {\n downloadedSize += chunk.length;\n \n if (totalSize > 0) {\n const progress = Math.round((downloadedSize / totalSize) * 100);\n \n if (onProgress) {\n onProgress(progress, downloadedSize, totalSize);\n }\n }\n });\n\n response.pipe(file);\n\n file.on('finish', () => {\n file.close(() => {\n resolve({ success: true, size: downloadedSize });\n });\n });\n });\n\n request.on('timeout', () => {\n request.destroy();\n file.close();\n require('fs').unlink(destination, () => {});\n reject(new Error('Download timeout'));\n });\n\n request.on('error', (err) => {\n file.close();\n require('fs').unlink(destination, () => {});\n this.emit('download-error', { url, error: err, modelId });\n reject(err);\n });\n\n request.setTimeout(timeout);\n\n file.on('error', (err) => {\n require('fs').unlink(destination, () => {});\n reject(err);\n });\n });\n }\n\n async downloadWithRetry(url, destination, options = {}) {\n const { \n maxRetries = 3, \n retryDelay = 1000, \n expectedChecksum = null,\n modelId = null,\n ...downloadOptions \n } = options;\n \n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n try {\n const result = await this.downloadFile(url, destination, { \n ...downloadOptions, \n modelId \n });\n \n if (expectedChecksum) {\n const isValid = await this.verifyChecksum(destination, expectedChecksum);\n if (!isValid) {\n require('fs').unlinkSync(destination);\n throw new Error('Checksum verification failed');\n }\n console.log(`[${this.serviceName}] Checksum verified successfully`);\n }\n \n return result;\n } catch (error) {\n if (attempt === maxRetries) {\n throw error;\n }\n \n console.log(`Download attempt ${attempt} failed, retrying in ${retryDelay}ms...`);\n await new Promise(resolve => setTimeout(resolve, retryDelay * attempt));\n }\n }\n }\n\n async verifyChecksum(filePath, expectedChecksum) {\n return new Promise((resolve, reject) => {\n const hash = crypto.createHash('sha256');\n const stream = require('fs').createReadStream(filePath);\n \n stream.on('data', (data) => hash.update(data));\n stream.on('end', () => {\n const fileChecksum = hash.digest('hex');\n console.log(`[${this.serviceName}] File checksum: ${fileChecksum}`);\n console.log(`[${this.serviceName}] Expected checksum: ${expectedChecksum}`);\n resolve(fileChecksum === expectedChecksum);\n });\n stream.on('error', reject);\n });\n }\n\n async autoInstall(onProgress) {\n const platform = this.getPlatform();\n console.log(`[${this.serviceName}] Starting auto-installation for ${platform}`);\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.installMacOS(onProgress);\n case 'win32':\n return await this.installWindows(onProgress);\n case 'linux':\n return await this.installLinux();\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Auto-installation failed:`, error);\n throw error;\n }\n }\n\n async installMacOS(onProgress) {\n console.log('[OllamaService] Installing Ollama on macOS using DMG...');\n \n try {\n const dmgUrl = 'https://ollama.com/download/Ollama.dmg';\n const tempDir = app.getPath('temp');\n const dmgPath = path.join(tempDir, 'Ollama.dmg');\n const mountPoint = path.join(tempDir, 'OllamaMount');\n\n // 체크포인트 저장\n await this.saveCheckpoint('pre-install');\n\n console.log('[OllamaService] Step 1: Downloading Ollama DMG...');\n onProgress?.({ stage: 'downloading', message: 'Downloading Ollama installer...', progress: 0 });\n const checksumInfo = DOWNLOAD_CHECKSUMS.ollama.dmg;\n await this.downloadWithRetry(dmgUrl, dmgPath, {\n expectedChecksum: checksumInfo?.sha256,\n onProgress: (progress) => {\n onProgress?.({ stage: 'downloading', message: `Downloading... ${progress}%`, progress });\n }\n });\n \n await this.saveCheckpoint('post-download');\n \n console.log('[OllamaService] Step 2: Mounting DMG...');\n onProgress?.({ stage: 'mounting', message: 'Mounting disk image...', progress: 0 });\n await fs.mkdir(mountPoint, { recursive: true });\n await spawnAsync('hdiutil', ['attach', dmgPath, '-mountpoint', mountPoint]);\n onProgress?.({ stage: 'mounting', message: 'Disk image mounted.', progress: 100 });\n \n console.log('[OllamaService] Step 3: Installing Ollama.app...');\n onProgress?.({ stage: 'installing', message: 'Installing Ollama application...', progress: 0 });\n await spawnAsync('cp', ['-R', `${mountPoint}/Ollama.app`, '/Applications/']);\n onProgress?.({ stage: 'installing', message: 'Application installed.', progress: 100 });\n \n await this.saveCheckpoint('post-install');\n \n console.log('[OllamaService] Step 4: Setting up CLI path...');\n onProgress?.({ stage: 'linking', message: 'Creating command-line shortcut...', progress: 0 });\n try {\n const script = `do shell script \"mkdir -p /usr/local/bin && ln -sf '${this.getOllamaCliPath()}' '/usr/local/bin/ollama'\" with administrator privileges`;\n await spawnAsync('osascript', ['-e', script]);\n onProgress?.({ stage: 'linking', message: 'Shortcut created.', progress: 100 });\n } catch (linkError) {\n console.error('[OllamaService] CLI symlink creation failed:', linkError.message);\n onProgress?.({ stage: 'linking', message: 'Shortcut creation failed (permissions?).', progress: 100 });\n // Not throwing an error, as the app might still work\n }\n \n console.log('[OllamaService] Step 5: Cleanup...');\n onProgress?.({ stage: 'cleanup', message: 'Cleaning up installation files...', progress: 0 });\n await spawnAsync('hdiutil', ['detach', mountPoint]);\n await fs.unlink(dmgPath).catch(() => {});\n await fs.rmdir(mountPoint).catch(() => {});\n onProgress?.({ stage: 'cleanup', message: 'Cleanup complete.', progress: 100 });\n \n console.log('[OllamaService] Ollama installed successfully on macOS');\n \n await new Promise(resolve => setTimeout(resolve, 2000));\n \n return true;\n } catch (error) {\n console.error('[OllamaService] macOS installation failed:', error);\n // 설치 실패 시 정리\n await fs.unlink(dmgPath).catch(() => {});\n throw new Error(`Failed to install Ollama on macOS: ${error.message}`);\n }\n }\n\n async installWindows(onProgress) {\n console.log('[OllamaService] Installing Ollama on Windows...');\n \n try {\n const exeUrl = 'https://ollama.com/download/OllamaSetup.exe';\n const tempDir = app.getPath('temp');\n const exePath = path.join(tempDir, 'OllamaSetup.exe');\n\n console.log('[OllamaService] Step 1: Downloading Ollama installer...');\n onProgress?.({ stage: 'downloading', message: 'Downloading Ollama installer...', progress: 0 });\n const checksumInfo = DOWNLOAD_CHECKSUMS.ollama.exe;\n await this.downloadWithRetry(exeUrl, exePath, {\n expectedChecksum: checksumInfo?.sha256,\n onProgress: (progress) => {\n onProgress?.({ stage: 'downloading', message: `Downloading... ${progress}%`, progress });\n }\n });\n \n console.log('[OllamaService] Step 2: Running silent installation...');\n onProgress?.({ stage: 'installing', message: 'Installing Ollama...', progress: 0 });\n await spawnAsync(exePath, ['/VERYSILENT', '/NORESTART']);\n onProgress?.({ stage: 'installing', message: 'Installation complete.', progress: 100 });\n \n console.log('[OllamaService] Step 3: Cleanup...');\n onProgress?.({ stage: 'cleanup', message: 'Cleaning up installation files...', progress: 0 });\n await fs.unlink(exePath).catch(() => {});\n onProgress?.({ stage: 'cleanup', message: 'Cleanup complete.', progress: 100 });\n \n console.log('[OllamaService] Ollama installed successfully on Windows');\n \n await new Promise(resolve => setTimeout(resolve, 3000));\n \n return true;\n } catch (error) {\n console.error('[OllamaService] Windows installation failed:', error);\n throw new Error(`Failed to install Ollama on Windows: ${error.message}`);\n }\n }\n\n async installLinux() {\n console.log('[OllamaService] Installing Ollama on Linux...');\n console.log('[OllamaService] Automatic installation on Linux is not supported for security reasons.');\n console.log('[OllamaService] Please install Ollama manually:');\n console.log('[OllamaService] 1. Visit https://ollama.com/download/linux');\n console.log('[OllamaService] 2. Follow the official installation instructions');\n console.log('[OllamaService] 3. Or use your package manager if available');\n throw new Error('Manual installation required on Linux. Please visit https://ollama.com/download/linux');\n }\n\n // === 체크포인트 & 롤백 시스템 ===\n async saveCheckpoint(name) {\n this.installCheckpoints.push({\n name,\n timestamp: Date.now(),\n state: { ...this.installState }\n });\n }\n\n async rollbackToLastCheckpoint() {\n const checkpoint = this.installCheckpoints.pop();\n if (checkpoint) {\n console.log(`[OllamaService] Rolling back to checkpoint: ${checkpoint.name}`);\n // 플랫폼별 롤백 로직 실행\n await this._executeRollback(checkpoint);\n }\n }\n\n async _executeRollback(checkpoint) {\n const platform = this.getPlatform();\n \n if (platform === 'darwin' && checkpoint.name === 'post-install') {\n // macOS 롤백\n await fs.rm('/Applications/Ollama.app', { recursive: true, force: true }).catch(() => {});\n } else if (platform === 'win32') {\n // Windows 롤백 (레지스트리 등)\n // TODO: Windows 롤백 구현\n }\n \n this.installState = checkpoint.state;\n }\n\n // === 상태 동기화 (내부 처리) ===\n async syncState() {\n // 서비스 종료 중이면 스킵\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, skipping state sync');\n return this.installState;\n }\n \n try {\n const isInstalled = await this.isInstalled();\n const isRunning = await this.isServiceRunning();\n const models = isRunning && !this.isShuttingDown ? await this.getInstalledModels() : [];\n const loadedModels = isRunning && !this.isShuttingDown ? await this.getLoadedModels() : [];\n \n // 상태 업데이트\n this.installState.isInstalled = isInstalled;\n this.installState.isRunning = isRunning;\n this.installState.lastSync = Date.now();\n \n // 메모리 로드 상태 추적\n const previousLoadedModels = this._lastLoadedModels || [];\n const loadedChanged = loadedModels.length !== previousLoadedModels.length || \n !loadedModels.every(m => previousLoadedModels.includes(m));\n \n if (loadedChanged) {\n console.log(`[OllamaService] Loaded models changed: ${loadedModels.join(', ')}`);\n this._lastLoadedModels = loadedModels;\n \n // 메모리에서 언로드된 모델의 warmed 상태 제거\n for (const modelName of this.warmedModels) {\n if (!loadedModels.includes(modelName)) {\n this.warmedModels.delete(modelName);\n console.log(`[OllamaService] Model ${modelName} unloaded from memory, removing warmed state`);\n }\n }\n }\n \n // 모델 상태 DB 업데이트\n if (isRunning && models.length > 0) {\n for (const model of models) {\n try {\n const isLoaded = loadedModels.includes(model.name);\n // DB에는 installed 상태만 저장, loaded 상태는 메모리에서 관리\n await ollamaModelRepository.updateInstallStatus(model.name, true, false);\n \n // 로드 상태를 인스턴스 변수에 저장\n if (!this.modelLoadStatus) {\n this.modelLoadStatus = new Map();\n }\n this.modelLoadStatus.set(model.name, isLoaded);\n } catch (dbError) {\n console.warn(`[OllamaService] Failed to update DB for model ${model.name}:`, dbError);\n }\n }\n }\n \n // UI 알림 (상태 변경 시만)\n if (this._lastState?.isRunning !== isRunning || \n this._lastState?.isInstalled !== isInstalled ||\n loadedChanged) {\n // Emit state change event - LocalAIManager가 처리\n this.emit('state-changed', {\n installed: isInstalled,\n running: isRunning,\n models: models.length,\n loadedModels: loadedModels\n });\n }\n \n this._lastState = { isInstalled, isRunning, modelsCount: models.length };\n return { isInstalled, isRunning, models };\n \n } catch (error) {\n console.error('[OllamaService] State sync failed:', error);\n return { \n isInstalled: this.installState.isInstalled || false,\n isRunning: false,\n models: []\n };\n }\n }\n\n // 주기적 동기화 시작\n startPeriodicSync() {\n if (this._syncInterval) return;\n \n this._syncInterval = setInterval(() => {\n this.syncState();\n }, 30000); // 30초마다\n }\n\n stopPeriodicSync() {\n if (this._syncInterval) {\n clearInterval(this._syncInterval);\n this._syncInterval = null;\n }\n }\n\n async warmUpModel(modelName, forceRefresh = false) {\n if (!modelName?.trim()) {\n console.warn(`[OllamaService] Invalid model name for warm-up`);\n return false;\n }\n\n // Check if already warmed (and not forcing refresh)\n if (!forceRefresh && this.warmedModels.has(modelName)) {\n console.log(`[OllamaService] Model ${modelName} already warmed up, skipping`);\n return true;\n }\n\n // Check if currently warming - return existing Promise\n if (this.warmingModels.has(modelName)) {\n console.log(`[OllamaService] Model ${modelName} is already warming up, joining existing operation`);\n return await this.warmingModels.get(modelName);\n }\n\n // Check rate limiting (prevent too frequent attempts)\n const lastAttempt = this.lastWarmUpAttempt.get(modelName);\n const now = Date.now();\n if (lastAttempt && (now - lastAttempt) < 5000) { // 5 second cooldown\n console.log(`[OllamaService] Rate limiting warm-up for ${modelName}, try again in ${5 - Math.floor((now - lastAttempt) / 1000)}s`);\n return false;\n }\n\n // Create and store the warming Promise\n const warmingPromise = this._performWarmUp(modelName);\n this.warmingModels.set(modelName, warmingPromise);\n this.lastWarmUpAttempt.set(modelName, now);\n\n try {\n const result = await warmingPromise;\n \n if (result) {\n this.warmedModels.add(modelName);\n console.log(`[OllamaService] Model ${modelName} successfully warmed up`);\n }\n \n return result;\n } finally {\n // Always clean up the warming Promise\n this.warmingModels.delete(modelName);\n }\n }\n\n async _performWarmUp(modelName) {\n console.log(`[OllamaService] Starting warm-up for model: ${modelName}`);\n \n try {\n const response = await this.makeRequest('/api/chat', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n messages: [\n { role: 'user', content: 'Hi' }\n ],\n stream: false,\n options: {\n num_predict: 1, // Minimal response\n temperature: 0\n }\n })\n });\n\n return true;\n } catch (error) {\n // Check if it's a 404 error (model not found/installed)\n if (error.message.includes('HTTP 404') || error.message.includes('Not Found')) {\n console.log(`[OllamaService] Model ${modelName} not found (404), attempting to install...`);\n \n try {\n // Try to install the model\n await this.pullModel(modelName);\n console.log(`[OllamaService] Successfully installed model ${modelName}, retrying warm-up...`);\n \n // Update database to reflect installation\n await ollamaModelRepository.updateInstallStatus(modelName, true, false);\n \n // Retry warm-up after installation\n const retryResponse = await this.makeRequest('/api/chat', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n messages: [\n { role: 'user', content: 'Hi' }\n ],\n stream: false,\n options: {\n num_predict: 1,\n temperature: 0\n }\n })\n });\n \n console.log(`[OllamaService] Successfully warmed up model ${modelName} after installation`);\n return true;\n \n } catch (installError) {\n console.error(`[OllamaService] Failed to auto-install model ${modelName}:`, installError.message);\n await ollamaModelRepository.updateInstallStatus(modelName, false, false);\n return false;\n }\n } else {\n console.error(`[OllamaService] Failed to warm up model ${modelName}:`, error.message);\n return false;\n }\n }\n }\n\n async autoWarmUpSelectedModel() {\n try {\n // Get selected model from ModelStateService\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n console.log('[OllamaService] ModelStateService not available for auto warm-up');\n return false;\n }\n\n const selectedModels = await modelStateService.getSelectedModels();\n const llmModelId = selectedModels.llm;\n \n // Check if it's an Ollama model\n const provider = modelStateService.getProviderForModel('llm', llmModelId);\n if (provider !== 'ollama') {\n console.log('[OllamaService] Selected LLM is not Ollama, skipping warm-up');\n return false;\n }\n\n // Check if Ollama service is running\n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log('[OllamaService] Ollama service not running, clearing warm-up cache');\n this._clearWarmUpCache();\n return false;\n }\n\n // 설치 여부 체크 제거 - _performWarmUp에서 자동으로 설치 처리\n console.log(`[OllamaService] Auto-warming up selected model: ${llmModelId} (will auto-install if needed)`);\n const result = await this.warmUpModel(llmModelId);\n \n // 성공 시 LocalAIManager에 알림\n if (result) {\n this.emit('model-warmed-up', { model: llmModelId });\n }\n \n return result;\n \n } catch (error) {\n console.error('[OllamaService] Auto warm-up failed:', error);\n return false;\n }\n }\n\n _clearWarmUpCache() {\n this.warmedModels.clear();\n this.warmingModels.clear();\n this.lastWarmUpAttempt.clear();\n console.log('[OllamaService] Warm-up cache cleared');\n }\n\n async getWarmUpStatus() {\n const loadedModels = await this.getLoadedModels();\n \n return {\n warmedModels: Array.from(this.warmedModels),\n warmingModels: Array.from(this.warmingModels.keys()),\n loadedModels: loadedModels, // Models actually loaded in memory\n lastAttempts: Object.fromEntries(this.lastWarmUpAttempt)\n };\n }\n\n async shutdown(force = false) {\n console.log(`[OllamaService] Shutdown initiated (force: ${force})`);\n \n // 종료 중 플래그 설정\n this.isShuttingDown = true;\n \n if (!force && this.warmingModels.size > 0) {\n const warmingList = Array.from(this.warmingModels.keys());\n console.log(`[OllamaService] Waiting for ${warmingList.length} models to finish warming: ${warmingList.join(', ')}`);\n \n const warmingPromises = Array.from(this.warmingModels.values());\n try {\n // Use Promise.allSettled instead of race with setTimeout\n const results = await Promise.allSettled(warmingPromises);\n const completed = results.filter(r => r.status === 'fulfilled').length;\n console.log(`[OllamaService] ${completed}/${results.length} warming operations completed`);\n } catch (error) {\n console.log('[OllamaService] Error waiting for warm-up completion, proceeding with shutdown');\n }\n }\n\n // Clean up all resources\n this._clearWarmUpCache();\n this.stopPeriodicSync();\n \n // 프로세스 종료\n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log('[OllamaService] Service not running, nothing to shutdown');\n return true;\n }\n\n const platform = this.getPlatform();\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.shutdownMacOS(force);\n case 'win32':\n return await this.shutdownWindows(force);\n case 'linux':\n return await this.shutdownLinux(force);\n default:\n console.warn(`[OllamaService] Unsupported platform for shutdown: ${platform}`);\n return false;\n }\n } catch (error) {\n console.error(`[OllamaService] Error during shutdown:`, error);\n return false;\n }\n }\n\n async shutdownMacOS(force) {\n try {\n // 1. First, try to kill ollama server process\n console.log('[OllamaService] Killing ollama server process...');\n try {\n await spawnAsync('pkill', ['-f', 'ollama serve']);\n } catch (e) {\n // Process might not be running\n }\n \n // 2. Then quit the Ollama.app\n console.log('[OllamaService] Quitting Ollama.app...');\n try {\n await spawnAsync('osascript', ['-e', 'tell application \"Ollama\" to quit']);\n } catch (e) {\n console.log('[OllamaService] Ollama.app might not be running');\n }\n \n // 3. Wait a moment for shutdown\n await new Promise(resolve => setTimeout(resolve, 2000));\n \n // 4. Force kill any remaining ollama processes\n if (force || await this.isServiceRunning()) {\n console.log('[OllamaService] Force killing any remaining ollama processes...');\n try {\n // Kill all ollama processes\n await spawnAsync('pkill', ['-9', '-f', 'ollama']);\n } catch (e) {\n // Ignore errors - process might not exist\n }\n }\n \n // 5. Final check\n await new Promise(resolve => setTimeout(resolve, 1000));\n const stillRunning = await this.isServiceRunning();\n if (stillRunning) {\n console.warn('[OllamaService] Warning: Ollama may still be running');\n return false;\n }\n \n console.log('[OllamaService] Ollama shutdown complete');\n return true;\n } catch (error) {\n console.error('[OllamaService] Shutdown error:', error);\n return false;\n }\n }\n\n async shutdownWindows(force) {\n try {\n // Try to stop the service gracefully\n await spawnAsync('taskkill', ['/IM', 'ollama.exe', '/T']);\n console.log('[OllamaService] Ollama process terminated on Windows');\n return true;\n } catch (error) {\n console.log('[OllamaService] Standard termination failed, trying force kill');\n try {\n await spawnAsync('taskkill', ['/IM', 'ollama.exe', '/F', '/T']);\n return true;\n } catch (killError) {\n console.error('[OllamaService] Failed to force kill Ollama on Windows:', killError);\n return false;\n }\n }\n }\n\n async shutdownLinux(force) {\n try {\n await spawnAsync('pkill', ['-f', this.getOllamaCliPath()]);\n console.log('[OllamaService] Ollama process terminated on Linux');\n return true;\n } catch (error) {\n if (force) {\n await spawnAsync('pkill', ['-9', '-f', this.getOllamaCliPath()]).catch(() => {});\n }\n console.error('[OllamaService] Failed to shutdown Ollama on Linux:', error);\n return false;\n }\n }\n\n async getAllModelsWithStatus() {\n // Get all installed models directly from Ollama\n const installedModels = await this.getInstalledModels();\n \n // Get loaded models from memory\n const loadedModels = await this.getLoadedModels();\n \n const models = [];\n for (const model of installedModels) {\n const isWarmingUp = this.warmingModels.has(model.name);\n const isWarmedUp = this.warmedModels.has(model.name);\n const isLoaded = loadedModels.includes(model.name);\n \n models.push({\n name: model.name,\n displayName: model.name, // Use model name as display name\n size: model.size || 'Unknown',\n description: `Ollama model: ${model.name}`,\n installed: true,\n installing: this.installationProgress.has(model.name),\n progress: this.getInstallProgress(model.name),\n warmedUp: isWarmedUp,\n isWarmingUp,\n isLoaded, // Actually loaded in memory\n status: isWarmingUp ? 'warming' : (isLoaded ? 'loaded' : (isWarmedUp ? 'ready' : 'cold'))\n });\n }\n \n // Also add any models currently being installed\n for (const [modelName, progress] of this.installationProgress) {\n if (!models.find(m => m.name === modelName)) {\n models.push({\n name: modelName,\n displayName: modelName,\n size: 'Unknown',\n description: `Ollama model: ${modelName}`,\n installed: false,\n installing: true,\n progress: progress\n });\n }\n }\n \n return models;\n }\n\n async handleGetStatus() {\n try {\n const installed = await this.isInstalled();\n if (!installed) {\n return { success: true, installed: false, running: false, models: [] };\n }\n\n const running = await this.isServiceRunning();\n if (!running) {\n return { success: true, installed: true, running: false, models: [] };\n }\n\n const models = await this.getAllModelsWithStatus();\n return { success: true, installed: true, running: true, models };\n } catch (error) {\n console.error('[OllamaService] Error getting status:', error);\n return { success: false, error: error.message, installed: false, running: false, models: [] };\n }\n }\n\n async handleInstall() {\n try {\n const onProgress = (data) => {\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', data);\n };\n\n await this.autoInstall(onProgress);\n \n // 설치 검증\n onProgress({ stage: 'verifying', message: 'Verifying installation...', progress: 0 });\n const verifyResult = await this.verifyInstallation();\n if (!verifyResult.success) {\n throw new Error(`Installation verification failed: ${verifyResult.error}`);\n }\n onProgress({ stage: 'verifying', message: 'Installation verified.', progress: 100 });\n\n if (!await this.isServiceRunning()) {\n onProgress({ stage: 'starting', message: 'Starting Ollama service...', progress: 0 });\n await this.startService();\n onProgress({ stage: 'starting', message: 'Ollama service started.', progress: 100 });\n }\n \n this.installState.isInstalled = true;\n // Emit completion event - LocalAIManager가 처리\n this.emit('installation-complete');\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to install:', error);\n await this.rollbackToLastCheckpoint();\n // Emit error event - LocalAIManager가 처리\n this.emit('error', {\n errorType: 'installation-failed',\n error: error.message\n });\n return { success: false, error: error.message };\n }\n }\n\n async handleStartService() {\n try {\n if (!await this.isServiceRunning()) {\n console.log('[OllamaService] Starting Ollama service...');\n await this.startService();\n }\n this.emit('install-complete', { success: true });\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to start service:', error);\n this.emit('install-complete', { success: false, error: error.message });\n return { success: false, error: error.message };\n }\n }\n\n async handleEnsureReady() {\n try {\n if (await this.isInstalled() && !await this.isServiceRunning()) {\n console.log('[OllamaService] Ollama installed but not running, starting service...');\n await this.startService();\n }\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to ensure ready:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetModels() {\n try {\n const models = await this.getAllModelsWithStatus();\n return { success: true, models };\n } catch (error) {\n console.error('[OllamaService] Failed to get models:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetModelSuggestions() {\n try {\n const suggestions = await this.getModelSuggestions();\n return { success: true, suggestions };\n } catch (error) {\n console.error('[OllamaService] Failed to get model suggestions:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handlePullModel(modelName) {\n try {\n console.log(`[OllamaService] Starting model pull: ${modelName}`);\n\n await ollamaModelRepository.updateInstallStatus(modelName, false, true);\n\n await this.pullModel(modelName);\n\n await ollamaModelRepository.updateInstallStatus(modelName, true, false);\n\n console.log(`[OllamaService] Model ${modelName} pull successful`);\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to pull model:', error);\n await ollamaModelRepository.updateInstallStatus(modelName, false, false);\n // Emit error event - LocalAIManager가 처리\n this.emit('error', { \n errorType: 'model-pull-failed',\n model: modelName, \n error: error.message \n });\n return { success: false, error: error.message };\n }\n }\n\n async handleIsModelInstalled(modelName) {\n try {\n const installed = await this.isModelInstalled(modelName);\n return { success: true, installed };\n } catch (error) {\n console.error('[OllamaService] Failed to check model installation:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleWarmUpModel(modelName) {\n try {\n const success = await this.warmUpModel(modelName);\n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to warm up model:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleAutoWarmUp() {\n try {\n const success = await this.autoWarmUpSelectedModel();\n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to auto warm-up:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetWarmUpStatus() {\n try {\n const status = await this.getWarmUpStatus();\n return { success: true, status };\n } catch (error) {\n console.error('[OllamaService] Failed to get warm-up status:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleShutdown(force = false) {\n try {\n console.log(`[OllamaService] Manual shutdown requested (force: ${force})`);\n const success = await this.shutdown(force);\n \n // 종료 후 상태 업데이트 및 플래그 리셋\n if (success) {\n // 종료 완료 후 플래그 리셋\n this.isShuttingDown = false;\n await this.syncState();\n }\n \n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to shutdown Ollama:', error);\n return { success: false, error: error.message };\n }\n }\n \n // 설치 검증\n async verifyInstallation() {\n try {\n console.log('[OllamaService] Verifying installation...');\n \n // 1. 바이너리 확인\n const isInstalled = await this.isInstalled();\n if (!isInstalled) {\n return { success: false, error: 'Ollama binary not found' };\n }\n \n // 2. CLI 명령 테스트\n try {\n const { stdout } = await spawnAsync(this.getOllamaCliPath(), ['--version']);\n console.log('[OllamaService] Ollama version:', stdout.trim());\n } catch (error) {\n return { success: false, error: 'Ollama CLI not responding' };\n }\n \n // 3. 서비스 시작 가능 여부 확인\n const platform = this.getPlatform();\n if (platform === 'darwin') {\n // macOS: 앱 번들 확인\n try {\n await fs.access('/Applications/Ollama.app/Contents/MacOS/Ollama');\n } catch (error) {\n return { success: false, error: 'Ollama.app executable not found' };\n }\n }\n \n console.log('[OllamaService] Installation verified successfully');\n return { success: true };\n \n } catch (error) {\n console.error('[OllamaService] Verification failed:', error);\n return { success: false, error: error.message };\n }\n }\n}\n\n// Export singleton instance\nconst ollamaService = new OllamaService();\nmodule.exports = ollamaService;"], ["/glass/src/features/common/services/whisperService.js", "const { EventEmitter } = require('events');\nconst { spawn, exec } = require('child_process');\nconst { promisify } = require('util');\nconst path = require('path');\nconst fs = require('fs');\nconst os = require('os');\nconst https = require('https');\nconst crypto = require('crypto');\nconst { spawnAsync } = require('../utils/spawnHelper');\nconst { DOWNLOAD_CHECKSUMS } = require('../config/checksums');\n\nconst execAsync = promisify(exec);\n\nconst fsPromises = fs.promises;\n\nclass WhisperService extends EventEmitter {\n constructor() {\n super();\n this.serviceName = 'WhisperService';\n \n // 경로 및 디렉토리\n this.whisperPath = null;\n this.modelsDir = null;\n this.tempDir = null;\n \n // 세션 관리 (세션 풀 내장)\n this.sessionPool = [];\n this.activeSessions = new Map();\n this.maxSessions = 3;\n \n // 설치 상태\n this.installState = {\n isInstalled: false,\n isInitialized: false\n };\n \n // 사용 가능한 모델\n this.availableModels = {\n 'whisper-tiny': {\n name: 'Tiny',\n size: '39M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin'\n },\n 'whisper-base': {\n name: 'Base',\n size: '74M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin'\n },\n 'whisper-small': {\n name: 'Small',\n size: '244M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin'\n },\n 'whisper-medium': {\n name: 'Medium',\n size: '769M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin'\n }\n };\n }\n\n\n // Base class methods integration\n getPlatform() {\n return process.platform;\n }\n\n async checkCommand(command) {\n try {\n const platform = this.getPlatform();\n const checkCmd = platform === 'win32' ? 'where' : 'which';\n const { stdout } = await execAsync(`${checkCmd} ${command}`);\n return stdout.trim();\n } catch (error) {\n return null;\n }\n }\n\n async waitForService(checkFn, maxAttempts = 30, delayMs = 1000) {\n for (let i = 0; i < maxAttempts; i++) {\n if (await checkFn()) {\n console.log(`[${this.serviceName}] Service is ready`);\n return true;\n }\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n throw new Error(`${this.serviceName} service failed to start within timeout`);\n }\n\n async downloadFile(url, destination, options = {}) {\n const { \n onProgress = null,\n headers = { 'User-Agent': 'Glass-App' },\n timeout = 300000,\n modelId = null\n } = options;\n\n return new Promise((resolve, reject) => {\n const file = fs.createWriteStream(destination);\n let downloadedSize = 0;\n let totalSize = 0;\n\n const request = https.get(url, { headers }, (response) => {\n if ([301, 302, 307, 308].includes(response.statusCode)) {\n file.close();\n fs.unlink(destination, () => {});\n \n if (!response.headers.location) {\n reject(new Error('Redirect without location header'));\n return;\n }\n \n console.log(`[${this.serviceName}] Following redirect from ${url} to ${response.headers.location}`);\n this.downloadFile(response.headers.location, destination, options)\n .then(resolve)\n .catch(reject);\n return;\n }\n\n if (response.statusCode !== 200) {\n file.close();\n fs.unlink(destination, () => {});\n reject(new Error(`Download failed: ${response.statusCode} ${response.statusMessage}`));\n return;\n }\n\n totalSize = parseInt(response.headers['content-length'], 10) || 0;\n\n response.on('data', (chunk) => {\n downloadedSize += chunk.length;\n \n if (totalSize > 0) {\n const progress = Math.round((downloadedSize / totalSize) * 100);\n \n if (onProgress) {\n onProgress(progress, downloadedSize, totalSize);\n }\n }\n });\n\n response.pipe(file);\n\n file.on('finish', () => {\n file.close(() => {\n resolve({ success: true, size: downloadedSize });\n });\n });\n });\n\n request.on('timeout', () => {\n request.destroy();\n file.close();\n fs.unlink(destination, () => {});\n reject(new Error('Download timeout'));\n });\n\n request.on('error', (err) => {\n file.close();\n fs.unlink(destination, () => {});\n this.emit('download-error', { url, error: err, modelId });\n reject(err);\n });\n\n request.setTimeout(timeout);\n\n file.on('error', (err) => {\n fs.unlink(destination, () => {});\n reject(err);\n });\n });\n }\n\n async downloadWithRetry(url, destination, options = {}) {\n const { \n maxRetries = 3, \n retryDelay = 1000, \n expectedChecksum = null,\n modelId = null,\n ...downloadOptions \n } = options;\n \n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n try {\n const result = await this.downloadFile(url, destination, { \n ...downloadOptions, \n modelId \n });\n \n if (expectedChecksum) {\n const isValid = await this.verifyChecksum(destination, expectedChecksum);\n if (!isValid) {\n fs.unlinkSync(destination);\n throw new Error('Checksum verification failed');\n }\n console.log(`[${this.serviceName}] Checksum verified successfully`);\n }\n \n return result;\n } catch (error) {\n if (attempt === maxRetries) {\n throw error;\n }\n \n console.log(`Download attempt ${attempt} failed, retrying in ${retryDelay}ms...`);\n await new Promise(resolve => setTimeout(resolve, retryDelay * attempt));\n }\n }\n }\n\n async verifyChecksum(filePath, expectedChecksum) {\n return new Promise((resolve, reject) => {\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(filePath);\n \n stream.on('data', (data) => hash.update(data));\n stream.on('end', () => {\n const fileChecksum = hash.digest('hex');\n console.log(`[${this.serviceName}] File checksum: ${fileChecksum}`);\n console.log(`[${this.serviceName}] Expected checksum: ${expectedChecksum}`);\n resolve(fileChecksum === expectedChecksum);\n });\n stream.on('error', reject);\n });\n }\n\n async autoInstall(onProgress) {\n const platform = this.getPlatform();\n console.log(`[${this.serviceName}] Starting auto-installation for ${platform}`);\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.installMacOS(onProgress);\n case 'win32':\n return await this.installWindows(onProgress);\n case 'linux':\n return await this.installLinux();\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Auto-installation failed:`, error);\n throw error;\n }\n }\n\n async shutdown(force = false) {\n console.log(`[${this.serviceName}] Starting ${force ? 'forced' : 'graceful'} shutdown...`);\n \n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log(`[${this.serviceName}] Service not running, nothing to shutdown`);\n return true;\n }\n\n const platform = this.getPlatform();\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.shutdownMacOS(force);\n case 'win32':\n return await this.shutdownWindows(force);\n case 'linux':\n return await this.shutdownLinux(force);\n default:\n console.warn(`[${this.serviceName}] Unsupported platform for shutdown: ${platform}`);\n return false;\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Error during shutdown:`, error);\n return false;\n }\n }\n\n async initialize() {\n if (this.installState.isInitialized) return;\n\n try {\n const homeDir = os.homedir();\n const whisperDir = path.join(homeDir, '.glass', 'whisper');\n \n this.modelsDir = path.join(whisperDir, 'models');\n this.tempDir = path.join(whisperDir, 'temp');\n \n // Windows에서는 .exe 확장자 필요\n const platform = this.getPlatform();\n const whisperExecutable = platform === 'win32' ? 'whisper-whisper.exe' : 'whisper';\n this.whisperPath = path.join(whisperDir, 'bin', whisperExecutable);\n\n await this.ensureDirectories();\n await this.ensureWhisperBinary();\n \n this.installState.isInitialized = true;\n console.log('[WhisperService] Initialized successfully');\n } catch (error) {\n console.error('[WhisperService] Initialization failed:', error);\n // Emit error event - LocalAIManager가 처리\n this.emit('error', {\n errorType: 'initialization-failed',\n error: error.message\n });\n throw error;\n }\n }\n\n async ensureDirectories() {\n await fsPromises.mkdir(this.modelsDir, { recursive: true });\n await fsPromises.mkdir(this.tempDir, { recursive: true });\n await fsPromises.mkdir(path.dirname(this.whisperPath), { recursive: true });\n }\n\n // local stt session\n async getSession(config) {\n // check available session\n const availableSession = this.sessionPool.find(s => !s.inUse);\n if (availableSession) {\n availableSession.inUse = true;\n await availableSession.reconfigure(config);\n return availableSession;\n }\n\n // create new session\n if (this.activeSessions.size >= this.maxSessions) {\n throw new Error('Maximum session limit reached');\n }\n\n const session = new WhisperSession(config, this);\n await session.initialize();\n this.activeSessions.set(session.id, session);\n \n return session;\n }\n\n async releaseSession(sessionId) {\n const session = this.activeSessions.get(sessionId);\n if (session) {\n await session.cleanup();\n session.inUse = false;\n \n // add to session pool\n if (this.sessionPool.length < 2) {\n this.sessionPool.push(session);\n } else {\n // remove session\n await session.destroy();\n this.activeSessions.delete(sessionId);\n }\n }\n }\n\n //cleanup\n async cleanup() {\n // cleanup all sessions\n for (const session of this.activeSessions.values()) {\n await session.destroy();\n }\n \n this.activeSessions.clear();\n this.sessionPool = [];\n }\n\n async ensureWhisperBinary() {\n const whisperCliPath = await this.checkCommand('whisper-cli');\n if (whisperCliPath) {\n this.whisperPath = whisperCliPath;\n console.log(`[WhisperService] Found whisper-cli at: ${this.whisperPath}`);\n return;\n }\n\n const whisperPath = await this.checkCommand('whisper');\n if (whisperPath) {\n this.whisperPath = whisperPath;\n console.log(`[WhisperService] Found whisper at: ${this.whisperPath}`);\n return;\n }\n\n try {\n await fsPromises.access(this.whisperPath, fs.constants.X_OK);\n console.log('[WhisperService] Custom whisper binary found');\n return;\n } catch (error) {\n // Continue to installation\n }\n\n const platform = this.getPlatform();\n if (platform === 'darwin') {\n console.log('[WhisperService] Whisper not found, trying Homebrew installation...');\n try {\n await this.installViaHomebrew();\n // verify installation\n const verified = await this.verifyInstallation();\n if (!verified.success) {\n throw new Error(verified.error);\n }\n return;\n } catch (error) {\n console.log('[WhisperService] Homebrew installation failed:', error.message);\n }\n }\n\n await this.autoInstall();\n \n // verify installation\n const verified = await this.verifyInstallation();\n if (!verified.success) {\n throw new Error(`Whisper installation verification failed: ${verified.error}`);\n }\n }\n\n async installViaHomebrew() {\n const brewPath = await this.checkCommand('brew');\n if (!brewPath) {\n throw new Error('Homebrew not found. Please install Homebrew first.');\n }\n\n console.log('[WhisperService] Installing whisper-cpp via Homebrew...');\n await spawnAsync('brew', ['install', 'whisper-cpp']);\n \n const whisperCliPath = await this.checkCommand('whisper-cli');\n if (whisperCliPath) {\n this.whisperPath = whisperCliPath;\n console.log(`[WhisperService] Whisper-cli installed via Homebrew at: ${this.whisperPath}`);\n } else {\n const whisperPath = await this.checkCommand('whisper');\n if (whisperPath) {\n this.whisperPath = whisperPath;\n console.log(`[WhisperService] Whisper installed via Homebrew at: ${this.whisperPath}`);\n }\n }\n }\n\n\n async ensureModelAvailable(modelId) {\n if (!this.installState.isInitialized) {\n console.log('[WhisperService] Service not initialized, initializing now...');\n await this.initialize();\n }\n\n const modelInfo = this.availableModels[modelId];\n if (!modelInfo) {\n throw new Error(`Unknown model: ${modelId}. Available models: ${Object.keys(this.availableModels).join(', ')}`);\n }\n\n const modelPath = await this.getModelPath(modelId);\n try {\n await fsPromises.access(modelPath, fs.constants.R_OK);\n console.log(`[WhisperService] Model ${modelId} already available at: ${modelPath}`);\n } catch (error) {\n console.log(`[WhisperService] Model ${modelId} not found, downloading...`);\n await this.downloadModel(modelId);\n }\n }\n\n async downloadModel(modelId) {\n const modelInfo = this.availableModels[modelId];\n const modelPath = await this.getModelPath(modelId);\n const checksumInfo = DOWNLOAD_CHECKSUMS.whisper.models[modelId];\n \n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelId, \n progress: 0 \n });\n \n await this.downloadWithRetry(modelInfo.url, modelPath, {\n expectedChecksum: checksumInfo?.sha256,\n modelId, // pass modelId to LocalAIServiceBase for event handling\n onProgress: (progress) => {\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelId, \n progress \n });\n }\n });\n \n console.log(`[WhisperService] Model ${modelId} downloaded successfully`);\n this.emit('model-download-complete', { modelId });\n }\n\n async handleDownloadModel(modelId) {\n try {\n console.log(`[WhisperService] Handling download for model: ${modelId}`);\n\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n\n await this.ensureModelAvailable(modelId);\n \n return { success: true };\n } catch (error) {\n console.error(`[WhisperService] Failed to handle download for model ${modelId}:`, error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetInstalledModels() {\n try {\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n const models = await this.getInstalledModels();\n return { success: true, models };\n } catch (error) {\n console.error('[WhisperService] Failed to get installed models:', error);\n return { success: false, error: error.message };\n }\n }\n\n async getModelPath(modelId) {\n if (!this.installState.isInitialized || !this.modelsDir) {\n throw new Error('WhisperService is not initialized. Call initialize() first.');\n }\n return path.join(this.modelsDir, `${modelId}.bin`);\n }\n\n async getWhisperPath() {\n return this.whisperPath;\n }\n\n async saveAudioToTemp(audioBuffer, sessionId = '') {\n const timestamp = Date.now();\n const random = Math.random().toString(36).substr(2, 6);\n const sessionPrefix = sessionId ? `${sessionId}_` : '';\n const tempFile = path.join(this.tempDir, `audio_${sessionPrefix}${timestamp}_${random}.wav`);\n \n const wavHeader = this.createWavHeader(audioBuffer.length);\n const wavBuffer = Buffer.concat([wavHeader, audioBuffer]);\n \n await fsPromises.writeFile(tempFile, wavBuffer);\n return tempFile;\n }\n\n createWavHeader(dataSize) {\n const header = Buffer.alloc(44);\n const sampleRate = 16000;\n const numChannels = 1;\n const bitsPerSample = 16;\n \n header.write('RIFF', 0);\n header.writeUInt32LE(36 + dataSize, 4);\n header.write('WAVE', 8);\n header.write('fmt ', 12);\n header.writeUInt32LE(16, 16);\n header.writeUInt16LE(1, 20);\n header.writeUInt16LE(numChannels, 22);\n header.writeUInt32LE(sampleRate, 24);\n header.writeUInt32LE(sampleRate * numChannels * bitsPerSample / 8, 28);\n header.writeUInt16LE(numChannels * bitsPerSample / 8, 32);\n header.writeUInt16LE(bitsPerSample, 34);\n header.write('data', 36);\n header.writeUInt32LE(dataSize, 40);\n \n return header;\n }\n\n async cleanupTempFile(filePath) {\n if (!filePath || typeof filePath !== 'string') {\n console.warn('[WhisperService] Invalid file path for cleanup:', filePath);\n return;\n }\n\n const filesToCleanup = [\n filePath,\n filePath.replace('.wav', '.txt'),\n filePath.replace('.wav', '.json')\n ];\n\n for (const file of filesToCleanup) {\n try {\n // Check if file exists before attempting to delete\n await fsPromises.access(file, fs.constants.F_OK);\n await fsPromises.unlink(file);\n console.log(`[WhisperService] Cleaned up: ${file}`);\n } catch (error) {\n // File doesn't exist or already deleted - this is normal\n if (error.code !== 'ENOENT') {\n console.warn(`[WhisperService] Failed to cleanup ${file}:`, error.message);\n }\n }\n }\n }\n\n async getInstalledModels() {\n if (!this.installState.isInitialized) {\n console.log('[WhisperService] Service not initialized for getInstalledModels, initializing now...');\n await this.initialize();\n }\n\n const models = [];\n for (const [modelId, modelInfo] of Object.entries(this.availableModels)) {\n try {\n const modelPath = await this.getModelPath(modelId);\n await fsPromises.access(modelPath, fs.constants.R_OK);\n models.push({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: true\n });\n } catch (error) {\n models.push({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: false\n });\n }\n }\n return models;\n }\n\n async isServiceRunning() {\n return this.installState.isInitialized;\n }\n\n async startService() {\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n return true;\n }\n\n async stopService() {\n return true;\n }\n\n async isInstalled() {\n try {\n const whisperPath = await this.checkCommand('whisper-cli') || await this.checkCommand('whisper');\n return !!whisperPath;\n } catch (error) {\n return false;\n }\n }\n\n async installMacOS() {\n throw new Error('Binary installation not available for macOS. Please install Homebrew and run: brew install whisper-cpp');\n }\n\n async installWindows() {\n console.log('[WhisperService] Installing Whisper on Windows...');\n const version = 'v1.7.6';\n const binaryUrl = `https://github.com/ggml-org/whisper.cpp/releases/download/${version}/whisper-bin-x64.zip`;\n const tempFile = path.join(this.tempDir, 'whisper-binary.zip');\n \n try {\n console.log('[WhisperService] Step 1: Downloading Whisper binary...');\n await this.downloadWithRetry(binaryUrl, tempFile);\n \n console.log('[WhisperService] Step 2: Extracting archive...');\n const extractDir = path.join(this.tempDir, 'extracted');\n \n // 임시 압축 해제 디렉토리 생성\n await fsPromises.mkdir(extractDir, { recursive: true });\n \n // PowerShell 명령에서 경로를 올바르게 인용\n const expandCommand = `Expand-Archive -Path \"${tempFile}\" -DestinationPath \"${extractDir}\" -Force`;\n await spawnAsync('powershell', ['-command', expandCommand]);\n \n console.log('[WhisperService] Step 3: Finding and moving whisper executable...');\n \n // 압축 해제된 디렉토리에서 whisper.exe 파일 찾기\n const whisperExecutables = await this.findWhisperExecutables(extractDir);\n \n if (whisperExecutables.length === 0) {\n throw new Error('whisper.exe not found in extracted files');\n }\n \n // 첫 번째로 찾은 whisper.exe를 목표 위치로 복사\n const sourceExecutable = whisperExecutables[0];\n const targetDir = path.dirname(this.whisperPath);\n await fsPromises.mkdir(targetDir, { recursive: true });\n await fsPromises.copyFile(sourceExecutable, this.whisperPath);\n \n console.log('[WhisperService] Step 4: Verifying installation...');\n \n // 설치 검증\n await fsPromises.access(this.whisperPath, fs.constants.F_OK);\n \n // whisper.exe 실행 테스트\n try {\n await spawnAsync(this.whisperPath, ['--help']);\n console.log('[WhisperService] Whisper executable verified successfully');\n } catch (testError) {\n console.warn('[WhisperService] Whisper executable test failed, but file exists:', testError.message);\n }\n \n console.log('[WhisperService] Step 5: Cleanup...');\n \n // 임시 파일 정리\n await fsPromises.unlink(tempFile).catch(() => {});\n await this.removeDirectory(extractDir).catch(() => {});\n \n console.log('[WhisperService] Whisper installed successfully on Windows');\n return true;\n \n } catch (error) {\n console.error('[WhisperService] Windows installation failed:', error);\n \n // 실패 시 임시 파일 정리\n await fsPromises.unlink(tempFile).catch(() => {});\n await this.removeDirectory(path.join(this.tempDir, 'extracted')).catch(() => {});\n \n throw new Error(`Failed to install Whisper on Windows: ${error.message}`);\n }\n }\n \n // 압축 해제된 디렉토리에서 whisper.exe 파일들을 재귀적으로 찾기\n async findWhisperExecutables(dir) {\n const executables = [];\n \n try {\n const items = await fsPromises.readdir(dir, { withFileTypes: true });\n \n for (const item of items) {\n const fullPath = path.join(dir, item.name);\n \n if (item.isDirectory()) {\n const subExecutables = await this.findWhisperExecutables(fullPath);\n executables.push(...subExecutables);\n } else if (item.isFile() && (item.name === 'whisper-whisper.exe' || item.name === 'whisper.exe' || item.name === 'main.exe')) {\n executables.push(fullPath);\n }\n }\n } catch (error) {\n console.warn('[WhisperService] Error reading directory:', dir, error.message);\n }\n \n return executables;\n }\n \n // 디렉토리 재귀적 삭제\n async removeDirectory(dir) {\n try {\n const items = await fsPromises.readdir(dir, { withFileTypes: true });\n \n for (const item of items) {\n const fullPath = path.join(dir, item.name);\n \n if (item.isDirectory()) {\n await this.removeDirectory(fullPath);\n } else {\n await fsPromises.unlink(fullPath);\n }\n }\n \n await fsPromises.rmdir(dir);\n } catch (error) {\n console.warn('[WhisperService] Error removing directory:', dir, error.message);\n }\n }\n\n async installLinux() {\n console.log('[WhisperService] Installing Whisper on Linux...');\n const version = 'v1.7.6';\n const binaryUrl = `https://github.com/ggml-org/whisper.cpp/releases/download/${version}/whisper-cpp-${version}-linux-x64.tar.gz`;\n const tempFile = path.join(this.tempDir, 'whisper-binary.tar.gz');\n \n try {\n await this.downloadWithRetry(binaryUrl, tempFile);\n const extractDir = path.dirname(this.whisperPath);\n await spawnAsync('tar', ['-xzf', tempFile, '-C', extractDir, '--strip-components=1']);\n await spawnAsync('chmod', ['+x', this.whisperPath]);\n await fsPromises.unlink(tempFile);\n console.log('[WhisperService] Whisper installed successfully on Linux');\n return true;\n } catch (error) {\n console.error('[WhisperService] Linux installation failed:', error);\n throw new Error(`Failed to install Whisper on Linux: ${error.message}`);\n }\n }\n\n async shutdownMacOS(force) {\n return true;\n }\n\n async shutdownWindows(force) {\n return true;\n }\n\n async shutdownLinux(force) {\n return true;\n }\n}\n\n// WhisperSession class\nclass WhisperSession {\n constructor(config, service) {\n this.id = `session_${Date.now()}_${Math.random()}`;\n this.config = config;\n this.service = service;\n this.process = null;\n this.inUse = true;\n this.audioBuffer = Buffer.alloc(0);\n }\n\n async initialize() {\n await this.service.ensureModelAvailable(this.config.model);\n this.startProcessingLoop();\n }\n\n async reconfigure(config) {\n this.config = config;\n await this.service.ensureModelAvailable(this.config.model);\n }\n\n startProcessingLoop() {\n // TODO: 실제 처리 루프 구현\n }\n\n async cleanup() {\n // 임시 파일 정리\n await this.cleanupTempFiles();\n }\n\n async cleanupTempFiles() {\n // TODO: 임시 파일 정리 구현\n }\n\n async destroy() {\n if (this.process) {\n this.process.kill();\n }\n // 임시 파일 정리\n await this.cleanupTempFiles();\n }\n}\n\n// verify installation\nWhisperService.prototype.verifyInstallation = async function() {\n try {\n console.log('[WhisperService] Verifying installation...');\n \n // 1. check binary\n if (!this.whisperPath) {\n return { success: false, error: 'Whisper binary path not set' };\n }\n \n try {\n await fsPromises.access(this.whisperPath, fs.constants.X_OK);\n } catch (error) {\n return { success: false, error: 'Whisper binary not executable' };\n }\n \n // 2. check version\n try {\n const { stdout } = await spawnAsync(this.whisperPath, ['--help']);\n if (!stdout.includes('whisper')) {\n return { success: false, error: 'Invalid whisper binary' };\n }\n } catch (error) {\n return { success: false, error: 'Whisper binary not responding' };\n }\n \n // 3. check directories\n try {\n await fsPromises.access(this.modelsDir, fs.constants.W_OK);\n await fsPromises.access(this.tempDir, fs.constants.W_OK);\n } catch (error) {\n return { success: false, error: 'Required directories not accessible' };\n }\n \n console.log('[WhisperService] Installation verified successfully');\n return { success: true };\n \n } catch (error) {\n console.error('[WhisperService] Verification failed:', error);\n return { success: false, error: error.message };\n }\n};\n\n// Export singleton instance\nconst whisperService = new WhisperService();\nmodule.exports = whisperService;"], ["/glass/src/index.js", "// try {\n// const reloader = require('electron-reloader');\n// reloader(module, {\n// });\n// } catch (err) {\n// }\n\nrequire('dotenv').config();\n\nif (require('electron-squirrel-startup')) {\n process.exit(0);\n}\n\nconst { app, BrowserWindow, shell, ipcMain, dialog, desktopCapturer, session } = require('electron');\nconst { createWindows } = require('./window/windowManager.js');\nconst listenService = require('./features/listen/listenService');\nconst { initializeFirebase } = require('./features/common/services/firebaseClient');\nconst databaseInitializer = require('./features/common/services/databaseInitializer');\nconst authService = require('./features/common/services/authService');\nconst path = require('node:path');\nconst express = require('express');\nconst fetch = require('node-fetch');\nconst { autoUpdater } = require('electron-updater');\nconst { EventEmitter } = require('events');\nconst askService = require('./features/ask/askService');\nconst settingsService = require('./features/settings/settingsService');\nconst sessionRepository = require('./features/common/repositories/session');\nconst modelStateService = require('./features/common/services/modelStateService');\nconst featureBridge = require('./bridge/featureBridge');\nconst windowBridge = require('./bridge/windowBridge');\n\n// Global variables\nconst eventBridge = new EventEmitter();\nlet WEB_PORT = 3000;\nlet isShuttingDown = false; // Flag to prevent infinite shutdown loop\n\n//////// after_modelStateService ////////\nglobal.modelStateService = modelStateService;\n//////// after_modelStateService ////////\n\n// Import and initialize OllamaService\nconst ollamaService = require('./features/common/services/ollamaService');\nconst ollamaModelRepository = require('./features/common/repositories/ollamaModel');\n\n// Native deep link handling - cross-platform compatible\nlet pendingDeepLinkUrl = null;\n\nfunction setupProtocolHandling() {\n // Protocol registration - must be done before app is ready\n try {\n if (!app.isDefaultProtocolClient('pickleglass')) {\n const success = app.setAsDefaultProtocolClient('pickleglass');\n if (success) {\n console.log('[Protocol] Successfully set as default protocol client for pickleglass://');\n } else {\n console.warn('[Protocol] Failed to set as default protocol client - this may affect deep linking');\n }\n } else {\n console.log('[Protocol] Already registered as default protocol client for pickleglass://');\n }\n } catch (error) {\n console.error('[Protocol] Error during protocol registration:', error);\n }\n\n // Handle protocol URLs on Windows/Linux\n app.on('second-instance', (event, commandLine, workingDirectory) => {\n console.log('[Protocol] Second instance command line:', commandLine);\n \n focusMainWindow();\n \n let protocolUrl = null;\n \n // Search through all command line arguments for a valid protocol URL\n for (const arg of commandLine) {\n if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {\n // Clean up the URL by removing problematic characters\n const cleanUrl = arg.replace(/[\\\\₩]/g, '');\n \n // Additional validation for Windows\n if (process.platform === 'win32') {\n // On Windows, ensure the URL doesn't contain file path indicators\n if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {\n protocolUrl = cleanUrl;\n break;\n }\n } else {\n protocolUrl = cleanUrl;\n break;\n }\n }\n }\n \n if (protocolUrl) {\n console.log('[Protocol] Valid URL found from second instance:', protocolUrl);\n handleCustomUrl(protocolUrl);\n } else {\n console.log('[Protocol] No valid protocol URL found in command line arguments');\n console.log('[Protocol] Command line args:', commandLine);\n }\n });\n\n // Handle protocol URLs on macOS\n app.on('open-url', (event, url) => {\n event.preventDefault();\n console.log('[Protocol] Received URL via open-url:', url);\n \n if (!url || !url.startsWith('pickleglass://')) {\n console.warn('[Protocol] Invalid URL format:', url);\n return;\n }\n\n if (app.isReady()) {\n handleCustomUrl(url);\n } else {\n pendingDeepLinkUrl = url;\n console.log('[Protocol] App not ready, storing URL for later');\n }\n });\n}\n\nfunction focusMainWindow() {\n const { windowPool } = require('./window/windowManager.js');\n if (windowPool) {\n const header = windowPool.get('header');\n if (header && !header.isDestroyed()) {\n if (header.isMinimized()) header.restore();\n header.focus();\n return true;\n }\n }\n \n // Fallback: focus any available window\n const windows = BrowserWindow.getAllWindows();\n if (windows.length > 0) {\n const mainWindow = windows[0];\n if (!mainWindow.isDestroyed()) {\n if (mainWindow.isMinimized()) mainWindow.restore();\n mainWindow.focus();\n return true;\n }\n }\n \n return false;\n}\n\nif (process.platform === 'win32') {\n for (const arg of process.argv) {\n if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {\n // Clean up the URL by removing problematic characters (korean characters issue...)\n const cleanUrl = arg.replace(/[\\\\₩]/g, '');\n \n if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {\n console.log('[Protocol] Found protocol URL in initial arguments:', cleanUrl);\n pendingDeepLinkUrl = cleanUrl;\n break;\n }\n }\n }\n \n console.log('[Protocol] Initial process.argv:', process.argv);\n}\n\nconst gotTheLock = app.requestSingleInstanceLock();\nif (!gotTheLock) {\n app.quit();\n process.exit(0);\n}\n\n// setup protocol after single instance lock\nsetupProtocolHandling();\n\napp.whenReady().then(async () => {\n\n // Setup native loopback audio capture for Windows\n session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {\n desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {\n // Grant access to the first screen found with loopback audio\n callback({ video: sources[0], audio: 'loopback' });\n }).catch((error) => {\n console.error('Failed to get desktop capturer sources:', error);\n callback({});\n });\n });\n\n // Initialize core services\n initializeFirebase();\n \n try {\n await databaseInitializer.initialize();\n console.log('>>> [index.js] Database initialized successfully');\n \n // Clean up zombie sessions from previous runs first - MOVED TO authService\n // sessionRepository.endAllActiveSessions();\n\n await authService.initialize();\n\n //////// after_modelStateService ////////\n await modelStateService.initialize();\n //////// after_modelStateService ////////\n\n featureBridge.initialize(); // 추가: featureBridge 초기화\n windowBridge.initialize();\n setupWebDataHandlers();\n\n // Initialize Ollama models in database\n await ollamaModelRepository.initializeDefaultModels();\n\n // Auto warm-up selected Ollama model in background (non-blocking)\n setTimeout(async () => {\n try {\n console.log('[index.js] Starting background Ollama model warm-up...');\n await ollamaService.autoWarmUpSelectedModel();\n } catch (error) {\n console.log('[index.js] Background warm-up failed (non-critical):', error.message);\n }\n }, 2000); // Wait 2 seconds after app start\n\n // Start web server and create windows ONLY after all initializations are successful\n WEB_PORT = await startWebStack();\n console.log('Web front-end listening on', WEB_PORT);\n \n createWindows();\n\n } catch (err) {\n console.error('>>> [index.js] Database initialization failed - some features may not work', err);\n // Optionally, show an error dialog to the user\n dialog.showErrorBox(\n 'Application Error',\n 'A critical error occurred during startup. Some features might be disabled. Please restart the application.'\n );\n }\n\n // initAutoUpdater should be called after auth is initialized\n initAutoUpdater();\n\n // Process any pending deep link after everything is initialized\n if (pendingDeepLinkUrl) {\n console.log('[Protocol] Processing pending URL:', pendingDeepLinkUrl);\n handleCustomUrl(pendingDeepLinkUrl);\n pendingDeepLinkUrl = null;\n }\n});\n\napp.on('before-quit', async (event) => {\n // Prevent infinite loop by checking if shutdown is already in progress\n if (isShuttingDown) {\n console.log('[Shutdown] 🔄 Shutdown already in progress, allowing quit...');\n return;\n }\n \n console.log('[Shutdown] App is about to quit. Starting graceful shutdown...');\n \n // Set shutdown flag to prevent infinite loop\n isShuttingDown = true;\n \n // Prevent immediate quit to allow graceful shutdown\n event.preventDefault();\n \n try {\n // 1. Stop audio capture first (immediate)\n await listenService.closeSession();\n console.log('[Shutdown] Audio capture stopped');\n \n // 2. End all active sessions (database operations) - with error handling\n try {\n await sessionRepository.endAllActiveSessions();\n console.log('[Shutdown] Active sessions ended');\n } catch (dbError) {\n console.warn('[Shutdown] Could not end active sessions (database may be closed):', dbError.message);\n }\n \n // 3. Shutdown Ollama service (potentially time-consuming)\n console.log('[Shutdown] shutting down Ollama service...');\n const ollamaShutdownSuccess = await Promise.race([\n ollamaService.shutdown(false), // Graceful shutdown\n new Promise(resolve => setTimeout(() => resolve(false), 8000)) // 8s timeout\n ]);\n \n if (ollamaShutdownSuccess) {\n console.log('[Shutdown] Ollama service shut down gracefully');\n } else {\n console.log('[Shutdown] Ollama shutdown timeout, forcing...');\n // Force shutdown if graceful failed\n try {\n await ollamaService.shutdown(true);\n } catch (forceShutdownError) {\n console.warn('[Shutdown] Force shutdown also failed:', forceShutdownError.message);\n }\n }\n \n // 4. Close database connections (final cleanup)\n try {\n databaseInitializer.close();\n console.log('[Shutdown] Database connections closed');\n } catch (closeError) {\n console.warn('[Shutdown] Error closing database:', closeError.message);\n }\n \n console.log('[Shutdown] Graceful shutdown completed successfully');\n \n } catch (error) {\n console.error('[Shutdown] Error during graceful shutdown:', error);\n // Continue with shutdown even if there were errors\n } finally {\n // Actually quit the app now\n console.log('[Shutdown] Exiting application...');\n app.exit(0); // Use app.exit() instead of app.quit() to force quit\n }\n});\n\napp.on('activate', () => {\n if (BrowserWindow.getAllWindows().length === 0) {\n createWindows();\n }\n});\n\nfunction setupWebDataHandlers() {\n const sessionRepository = require('./features/common/repositories/session');\n const sttRepository = require('./features/listen/stt/repositories');\n const summaryRepository = require('./features/listen/summary/repositories');\n const askRepository = require('./features/ask/repositories');\n const userRepository = require('./features/common/repositories/user');\n const presetRepository = require('./features/common/repositories/preset');\n\n const handleRequest = async (channel, responseChannel, payload) => {\n let result;\n // const currentUserId = authService.getCurrentUserId(); // No longer needed here\n try {\n switch (channel) {\n // SESSION\n case 'get-sessions':\n // Adapter injects UID\n result = await sessionRepository.getAllByUserId();\n break;\n case 'get-session-details':\n const session = await sessionRepository.getById(payload);\n if (!session) {\n result = null;\n break;\n }\n const [transcripts, ai_messages, summary] = await Promise.all([\n sttRepository.getAllTranscriptsBySessionId(payload),\n askRepository.getAllAiMessagesBySessionId(payload),\n summaryRepository.getSummaryBySessionId(payload)\n ]);\n result = { session, transcripts, ai_messages, summary };\n break;\n case 'delete-session':\n result = await sessionRepository.deleteWithRelatedData(payload);\n break;\n case 'create-session':\n // Adapter injects UID\n const id = await sessionRepository.create('ask');\n if (payload && payload.title) {\n await sessionRepository.updateTitle(id, payload.title);\n }\n result = { id };\n break;\n \n // USER\n case 'get-user-profile':\n // Adapter injects UID\n result = await userRepository.getById();\n break;\n case 'update-user-profile':\n // Adapter injects UID\n result = await userRepository.update(payload);\n break;\n case 'find-or-create-user':\n result = await userRepository.findOrCreate(payload);\n break;\n case 'save-api-key':\n // Use ModelStateService as the single source of truth for API key management\n result = await modelStateService.setApiKey(payload.provider, payload.apiKey);\n break;\n case 'check-api-key-status':\n // Use ModelStateService to check API key status\n const hasApiKey = await modelStateService.hasValidApiKey();\n result = { hasApiKey };\n break;\n case 'delete-account':\n // Adapter injects UID\n result = await userRepository.deleteById();\n break;\n\n // PRESET\n case 'get-presets':\n // Adapter injects UID\n result = await presetRepository.getPresets();\n break;\n case 'create-preset':\n // Adapter injects UID\n result = await presetRepository.create(payload);\n settingsService.notifyPresetUpdate('created', result.id, payload.title);\n break;\n case 'update-preset':\n // Adapter injects UID\n result = await presetRepository.update(payload.id, payload.data);\n settingsService.notifyPresetUpdate('updated', payload.id, payload.data.title);\n break;\n case 'delete-preset':\n // Adapter injects UID\n result = await presetRepository.delete(payload);\n settingsService.notifyPresetUpdate('deleted', payload);\n break;\n \n // BATCH\n case 'get-batch-data':\n const includes = payload ? payload.split(',').map(item => item.trim()) : ['profile', 'presets', 'sessions'];\n const promises = {};\n \n if (includes.includes('profile')) {\n // Adapter injects UID\n promises.profile = userRepository.getById();\n }\n if (includes.includes('presets')) {\n // Adapter injects UID\n promises.presets = presetRepository.getPresets();\n }\n if (includes.includes('sessions')) {\n // Adapter injects UID\n promises.sessions = sessionRepository.getAllByUserId();\n }\n \n const batchResult = {};\n const promiseResults = await Promise.all(Object.values(promises));\n Object.keys(promises).forEach((key, index) => {\n batchResult[key] = promiseResults[index];\n });\n\n result = batchResult;\n break;\n\n default:\n throw new Error(`Unknown web data channel: ${channel}`);\n }\n eventBridge.emit(responseChannel, { success: true, data: result });\n } catch (error) {\n console.error(`Error handling web data request for ${channel}:`, error);\n eventBridge.emit(responseChannel, { success: false, error: error.message });\n }\n };\n \n eventBridge.on('web-data-request', handleRequest);\n}\n\nasync function handleCustomUrl(url) {\n try {\n console.log('[Custom URL] Processing URL:', url);\n \n // Validate and clean URL\n if (!url || typeof url !== 'string' || !url.startsWith('pickleglass://')) {\n console.error('[Custom URL] Invalid URL format:', url);\n return;\n }\n \n // Clean up URL by removing problematic characters\n const cleanUrl = url.replace(/[\\\\₩]/g, '');\n \n // Additional validation\n if (cleanUrl !== url) {\n console.log('[Custom URL] Cleaned URL from:', url, 'to:', cleanUrl);\n url = cleanUrl;\n }\n \n const urlObj = new URL(url);\n const action = urlObj.hostname;\n const params = Object.fromEntries(urlObj.searchParams);\n \n console.log('[Custom URL] Action:', action, 'Params:', params);\n\n switch (action) {\n case 'login':\n case 'auth-success':\n await handleFirebaseAuthCallback(params);\n break;\n case 'personalize':\n handlePersonalizeFromUrl(params);\n break;\n default:\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n \n const targetUrl = `http://localhost:${WEB_PORT}/${action}`;\n console.log(`[Custom URL] Navigating webview to: ${targetUrl}`);\n header.webContents.loadURL(targetUrl);\n }\n }\n\n } catch (error) {\n console.error('[Custom URL] Error parsing URL:', error);\n }\n}\n\nasync function handleFirebaseAuthCallback(params) {\n const userRepository = require('./features/common/repositories/user');\n const { token: idToken } = params;\n\n if (!idToken) {\n console.error('[Auth] Firebase auth callback is missing ID token.');\n // No need to send IPC, the UI won't transition without a successful auth state change.\n return;\n }\n\n console.log('[Auth] Received ID token from deep link, exchanging for custom token...');\n\n try {\n const functionUrl = 'https://us-west1-pickle-3651a.cloudfunctions.net/pickleGlassAuthCallback';\n const response = await fetch(functionUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ token: idToken })\n });\n\n const data = await response.json();\n\n if (!response.ok || !data.success) {\n throw new Error(data.error || 'Failed to exchange token.');\n }\n\n const { customToken, user } = data;\n console.log('[Auth] Successfully received custom token for user:', user.uid);\n\n const firebaseUser = {\n uid: user.uid,\n email: user.email || 'no-email@example.com',\n displayName: user.name || 'User',\n photoURL: user.picture\n };\n\n // 1. Sync user data to local DB\n userRepository.findOrCreate(firebaseUser);\n console.log('[Auth] User data synced with local DB.');\n\n // 2. Sign in using the authService in the main process\n await authService.signInWithCustomToken(customToken);\n console.log('[Auth] Main process sign-in initiated. Waiting for onAuthStateChanged...');\n\n // 3. Focus the app window\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n } else {\n console.error('[Auth] Header window not found after auth callback.');\n }\n \n } catch (error) {\n console.error('[Auth] Error during custom token exchange or sign-in:', error);\n // The UI will not change, and the user can try again.\n // Optionally, send a generic error event to the renderer.\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n header.webContents.send('auth-failed', { message: error.message });\n }\n }\n}\n\nfunction handlePersonalizeFromUrl(params) {\n console.log('[Custom URL] Personalize params:', params);\n \n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n \n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n \n const personalizeUrl = `http://localhost:${WEB_PORT}/settings`;\n console.log(`[Custom URL] Navigating to personalize page: ${personalizeUrl}`);\n header.webContents.loadURL(personalizeUrl);\n \n BrowserWindow.getAllWindows().forEach(win => {\n win.webContents.send('enter-personalize-mode', {\n message: 'Personalization mode activated',\n params: params\n });\n });\n } else {\n console.error('[Custom URL] Header window not found for personalize');\n }\n}\n\n\nasync function startWebStack() {\n console.log('NODE_ENV =', process.env.NODE_ENV); \n const isDev = !app.isPackaged;\n\n const getAvailablePort = () => {\n return new Promise((resolve, reject) => {\n const server = require('net').createServer();\n server.listen(0, (err) => {\n if (err) reject(err);\n const port = server.address().port;\n server.close(() => resolve(port));\n });\n });\n };\n\n const apiPort = await getAvailablePort();\n const frontendPort = await getAvailablePort();\n\n console.log(`🔧 Allocated ports: API=${apiPort}, Frontend=${frontendPort}`);\n\n process.env.pickleglass_API_PORT = apiPort.toString();\n process.env.pickleglass_API_URL = `http://localhost:${apiPort}`;\n process.env.pickleglass_WEB_PORT = frontendPort.toString();\n process.env.pickleglass_WEB_URL = `http://localhost:${frontendPort}`;\n\n console.log(`🌍 Environment variables set:`, {\n pickleglass_API_URL: process.env.pickleglass_API_URL,\n pickleglass_WEB_URL: process.env.pickleglass_WEB_URL\n });\n\n const createBackendApp = require('../pickleglass_web/backend_node');\n const nodeApi = createBackendApp(eventBridge);\n\n const staticDir = app.isPackaged\n ? path.join(process.resourcesPath, 'out')\n : path.join(__dirname, '..', 'pickleglass_web', 'out');\n\n const fs = require('fs');\n\n if (!fs.existsSync(staticDir)) {\n console.error(`============================================================`);\n console.error(`[ERROR] Frontend build directory not found!`);\n console.error(`Path: ${staticDir}`);\n console.error(`Please run 'npm run build' inside the 'pickleglass_web' directory first.`);\n console.error(`============================================================`);\n app.quit();\n return;\n }\n\n const runtimeConfig = {\n API_URL: `http://localhost:${apiPort}`,\n WEB_URL: `http://localhost:${frontendPort}`,\n timestamp: Date.now()\n };\n \n // 쓰기 가능한 임시 폴더에 런타임 설정 파일 생성\n const tempDir = app.getPath('temp');\n const configPath = path.join(tempDir, 'runtime-config.json');\n fs.writeFileSync(configPath, JSON.stringify(runtimeConfig, null, 2));\n console.log(`📝 Runtime config created in temp location: ${configPath}`);\n\n const frontSrv = express();\n \n // 프론트엔드에서 /runtime-config.json을 요청하면 임시 폴더의 파일을 제공\n frontSrv.get('/runtime-config.json', (req, res) => {\n res.sendFile(configPath);\n });\n\n frontSrv.use((req, res, next) => {\n if (req.path.indexOf('.') === -1 && req.path !== '/') {\n const htmlPath = path.join(staticDir, req.path + '.html');\n if (fs.existsSync(htmlPath)) {\n return res.sendFile(htmlPath);\n }\n }\n next();\n });\n \n frontSrv.use(express.static(staticDir));\n \n const frontendServer = await new Promise((resolve, reject) => {\n const server = frontSrv.listen(frontendPort, '127.0.0.1', () => resolve(server));\n server.on('error', reject);\n app.once('before-quit', () => server.close());\n });\n\n console.log(`✅ Frontend server started on http://localhost:${frontendPort}`);\n\n const apiSrv = express();\n apiSrv.use(nodeApi);\n\n const apiServer = await new Promise((resolve, reject) => {\n const server = apiSrv.listen(apiPort, '127.0.0.1', () => resolve(server));\n server.on('error', reject);\n app.once('before-quit', () => server.close());\n });\n\n console.log(`✅ API server started on http://localhost:${apiPort}`);\n\n console.log(`🚀 All services ready:\n Frontend: http://localhost:${frontendPort}\n API: http://localhost:${apiPort}`);\n\n return frontendPort;\n}\n\n// Auto-update initialization\nasync function initAutoUpdater() {\n if (process.env.NODE_ENV === 'development') {\n console.log('Development environment, skipping auto-updater.');\n return;\n }\n\n try {\n await autoUpdater.checkForUpdates();\n autoUpdater.on('update-available', () => {\n console.log('Update available!');\n autoUpdater.downloadUpdate();\n });\n autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, date, url) => {\n console.log('Update downloaded:', releaseNotes, releaseName, date, url);\n dialog.showMessageBox({\n type: 'info',\n title: 'Application Update',\n message: `A new version of PickleGlass (${releaseName}) has been downloaded. It will be installed the next time you launch the application.`,\n buttons: ['Restart', 'Later']\n }).then(response => {\n if (response.response === 0) {\n autoUpdater.quitAndInstall();\n }\n });\n });\n autoUpdater.on('error', (err) => {\n console.error('Error in auto-updater:', err);\n });\n } catch (err) {\n console.error('Error initializing auto-updater:', err);\n }\n}"], ["/glass/src/features/settings/settingsService.js", "const { ipcMain, BrowserWindow } = require('electron');\nconst Store = require('electron-store');\nconst authService = require('../common/services/authService');\nconst settingsRepository = require('./repositories');\nconst { getStoredApiKey, getStoredProvider, windowPool } = require('../../window/windowManager');\n\n// New imports for common services\nconst modelStateService = require('../common/services/modelStateService');\nconst localAIManager = require('../common/services/localAIManager');\n\nconst store = new Store({\n name: 'pickle-glass-settings',\n defaults: {\n users: {}\n }\n});\n\n// Configuration constants\nconst NOTIFICATION_CONFIG = {\n RELEVANT_WINDOW_TYPES: ['settings', 'main'],\n DEBOUNCE_DELAY: 300, // prevent spam during bulk operations (ms)\n MAX_RETRY_ATTEMPTS: 3,\n RETRY_BASE_DELAY: 1000, // exponential backoff base (ms)\n};\n\n// New facade functions for model state management\nasync function getModelSettings() {\n try {\n const [config, storedKeys, selectedModels, availableLlm, availableStt] = await Promise.all([\n modelStateService.getProviderConfig(),\n modelStateService.getAllApiKeys(),\n modelStateService.getSelectedModels(),\n modelStateService.getAvailableModels('llm'),\n modelStateService.getAvailableModels('stt')\n ]);\n \n return { success: true, data: { config, storedKeys, availableLlm, availableStt, selectedModels } };\n } catch (error) {\n console.error('[SettingsService] Error getting model settings:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function clearApiKey(provider) {\n const success = await modelStateService.handleRemoveApiKey(provider);\n return { success };\n}\n\nasync function setSelectedModel(type, modelId) {\n const success = await modelStateService.handleSetSelectedModel(type, modelId);\n return { success };\n}\n\n// LocalAI facade functions\nasync function getOllamaStatus() {\n return localAIManager.getServiceStatus('ollama');\n}\n\nasync function ensureOllamaReady() {\n const status = await localAIManager.getServiceStatus('ollama');\n if (!status.installed || !status.running) {\n await localAIManager.startService('ollama');\n }\n return { success: true };\n}\n\nasync function shutdownOllama() {\n return localAIManager.stopService('ollama');\n}\n\n\n// window targeting system\nclass WindowNotificationManager {\n constructor() {\n this.pendingNotifications = new Map();\n }\n\n /**\n * Send notifications only to relevant windows\n * @param {string} event - Event name\n * @param {*} data - Event data\n * @param {object} options - Notification options\n */\n notifyRelevantWindows(event, data = null, options = {}) {\n const { \n windowTypes = NOTIFICATION_CONFIG.RELEVANT_WINDOW_TYPES,\n debounce = NOTIFICATION_CONFIG.DEBOUNCE_DELAY \n } = options;\n\n if (debounce > 0) {\n this.debounceNotification(event, () => {\n this.sendToTargetWindows(event, data, windowTypes);\n }, debounce);\n } else {\n this.sendToTargetWindows(event, data, windowTypes);\n }\n }\n\n sendToTargetWindows(event, data, windowTypes) {\n const relevantWindows = this.getRelevantWindows(windowTypes);\n \n if (relevantWindows.length === 0) {\n console.log(`[WindowNotificationManager] No relevant windows found for event: ${event}`);\n return;\n }\n\n console.log(`[WindowNotificationManager] Sending ${event} to ${relevantWindows.length} relevant windows`);\n \n relevantWindows.forEach(win => {\n try {\n if (data) {\n win.webContents.send(event, data);\n } else {\n win.webContents.send(event);\n }\n } catch (error) {\n console.warn(`[WindowNotificationManager] Failed to send ${event} to window:`, error.message);\n }\n });\n }\n\n getRelevantWindows(windowTypes) {\n const allWindows = BrowserWindow.getAllWindows();\n const relevantWindows = [];\n\n allWindows.forEach(win => {\n if (win.isDestroyed()) return;\n\n for (const [windowName, poolWindow] of windowPool || []) {\n if (poolWindow === win && windowTypes.includes(windowName)) {\n if (windowName === 'settings' || win.isVisible()) {\n relevantWindows.push(win);\n }\n break;\n }\n }\n });\n\n return relevantWindows;\n }\n\n debounceNotification(key, fn, delay) {\n // Clear existing timeout\n if (this.pendingNotifications.has(key)) {\n clearTimeout(this.pendingNotifications.get(key));\n }\n\n // Set new timeout\n const timeoutId = setTimeout(() => {\n fn();\n this.pendingNotifications.delete(key);\n }, delay);\n\n this.pendingNotifications.set(key, timeoutId);\n }\n\n cleanup() {\n // Clear all pending notifications\n this.pendingNotifications.forEach(timeoutId => clearTimeout(timeoutId));\n this.pendingNotifications.clear();\n }\n}\n\n// Global instance\nconst windowNotificationManager = new WindowNotificationManager();\n\n// Default keybinds configuration\nconst DEFAULT_KEYBINDS = {\n mac: {\n moveUp: 'Cmd+Up',\n moveDown: 'Cmd+Down',\n moveLeft: 'Cmd+Left',\n moveRight: 'Cmd+Right',\n toggleVisibility: 'Cmd+\\\\',\n toggleClickThrough: 'Cmd+M',\n nextStep: 'Cmd+Enter',\n manualScreenshot: 'Cmd+Shift+S',\n previousResponse: 'Cmd+[',\n nextResponse: 'Cmd+]',\n scrollUp: 'Cmd+Shift+Up',\n scrollDown: 'Cmd+Shift+Down',\n },\n windows: {\n moveUp: 'Ctrl+Up',\n moveDown: 'Ctrl+Down',\n moveLeft: 'Ctrl+Left',\n moveRight: 'Ctrl+Right',\n toggleVisibility: 'Ctrl+\\\\',\n toggleClickThrough: 'Ctrl+M',\n nextStep: 'Ctrl+Enter',\n manualScreenshot: 'Ctrl+Shift+S',\n previousResponse: 'Ctrl+[',\n nextResponse: 'Ctrl+]',\n scrollUp: 'Ctrl+Shift+Up',\n scrollDown: 'Ctrl+Shift+Down',\n }\n};\n\n// Service state\nlet currentSettings = null;\n\nfunction getDefaultSettings() {\n const isMac = process.platform === 'darwin';\n return {\n profile: 'school',\n language: 'en',\n screenshotInterval: '5000',\n imageQuality: '0.8',\n layoutMode: 'stacked',\n keybinds: isMac ? DEFAULT_KEYBINDS.mac : DEFAULT_KEYBINDS.windows,\n throttleTokens: 500,\n maxTokens: 2000,\n throttlePercent: 80,\n googleSearchEnabled: false,\n backgroundTransparency: 0.5,\n fontSize: 14,\n contentProtection: true\n };\n}\n\nasync function getSettings() {\n try {\n const uid = authService.getCurrentUserId();\n const userSettingsKey = uid ? `users.${uid}` : 'users.default';\n \n const defaultSettings = getDefaultSettings();\n const savedSettings = store.get(userSettingsKey, {});\n \n currentSettings = { ...defaultSettings, ...savedSettings };\n return currentSettings;\n } catch (error) {\n console.error('[SettingsService] Error getting settings from store:', error);\n return getDefaultSettings();\n }\n}\n\nasync function saveSettings(settings) {\n try {\n const uid = authService.getCurrentUserId();\n const userSettingsKey = uid ? `users.${uid}` : 'users.default';\n \n const currentSaved = store.get(userSettingsKey, {});\n const newSettings = { ...currentSaved, ...settings };\n \n store.set(userSettingsKey, newSettings);\n currentSettings = newSettings;\n \n // Use smart notification system\n windowNotificationManager.notifyRelevantWindows('settings-updated', currentSettings);\n\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error saving settings to store:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function getPresets() {\n try {\n // The adapter now handles which presets to return based on login state.\n const presets = await settingsRepository.getPresets();\n return presets;\n } catch (error) {\n console.error('[SettingsService] Error getting presets:', error);\n return [];\n }\n}\n\nasync function getPresetTemplates() {\n try {\n const templates = await settingsRepository.getPresetTemplates();\n return templates;\n } catch (error) {\n console.error('[SettingsService] Error getting preset templates:', error);\n return [];\n }\n}\n\nasync function createPreset(title, prompt) {\n try {\n // The adapter injects the UID.\n const result = await settingsRepository.createPreset({ title, prompt });\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'created',\n presetId: result.id,\n title\n });\n \n return { success: true, id: result.id };\n } catch (error) {\n console.error('[SettingsService] Error creating preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function updatePreset(id, title, prompt) {\n try {\n // The adapter injects the UID.\n await settingsRepository.updatePreset(id, { title, prompt });\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'updated',\n presetId: id,\n title\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error updating preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function deletePreset(id) {\n try {\n // The adapter injects the UID.\n await settingsRepository.deletePreset(id);\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'deleted',\n presetId: id\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error deleting preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function saveApiKey(apiKey, provider = 'openai') {\n try {\n // Use ModelStateService as the single source of truth for API key management\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n throw new Error('ModelStateService not initialized');\n }\n \n await modelStateService.setApiKey(provider, apiKey);\n \n // Notify windows\n BrowserWindow.getAllWindows().forEach(win => {\n if (!win.isDestroyed()) {\n win.webContents.send('api-key-validated', apiKey);\n }\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error saving API key:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function removeApiKey() {\n try {\n // Use ModelStateService as the single source of truth for API key management\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n throw new Error('ModelStateService not initialized');\n }\n \n // Remove all API keys for all providers\n const providers = ['openai', 'anthropic', 'gemini', 'ollama', 'whisper'];\n for (const provider of providers) {\n await modelStateService.removeApiKey(provider);\n }\n \n // Notify windows\n BrowserWindow.getAllWindows().forEach(win => {\n if (!win.isDestroyed()) {\n win.webContents.send('api-key-removed');\n }\n });\n \n console.log('[SettingsService] API key removed for all providers');\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error removing API key:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function updateContentProtection(enabled) {\n try {\n const settings = await getSettings();\n settings.contentProtection = enabled;\n \n // Update content protection in main window\n const { app } = require('electron');\n const mainWindow = windowPool.get('main');\n if (mainWindow && !mainWindow.isDestroyed()) {\n mainWindow.setContentProtection(enabled);\n }\n \n return await saveSettings(settings);\n } catch (error) {\n console.error('[SettingsService] Error updating content protection:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function getAutoUpdateSetting() {\n try {\n return settingsRepository.getAutoUpdate();\n } catch (error) {\n console.error('[SettingsService] Error getting auto update setting:', error);\n return true; // Fallback to enabled\n }\n}\n\nasync function setAutoUpdateSetting(isEnabled) {\n try {\n await settingsRepository.setAutoUpdate(isEnabled);\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error setting auto update setting:', error);\n return { success: false, error: error.message };\n }\n}\n\nfunction initialize() {\n // cleanup \n windowNotificationManager.cleanup();\n \n console.log('[SettingsService] Initialized and ready.');\n}\n\n// Cleanup function\nfunction cleanup() {\n windowNotificationManager.cleanup();\n console.log('[SettingsService] Cleaned up resources.');\n}\n\nfunction notifyPresetUpdate(action, presetId, title = null) {\n const data = { action, presetId };\n if (title) data.title = title;\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', data);\n}\n\nmodule.exports = {\n initialize,\n cleanup,\n notifyPresetUpdate,\n getSettings,\n saveSettings,\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n saveApiKey,\n removeApiKey,\n updateContentProtection,\n getAutoUpdateSetting,\n setAutoUpdateSetting,\n // Model settings facade\n getModelSettings,\n clearApiKey,\n setSelectedModel,\n // Ollama facade\n getOllamaStatus,\n ensureOllamaReady,\n shutdownOllama\n};"], ["/glass/src/features/common/services/modelStateService.js", "const { EventEmitter } = require('events');\nconst Store = require('electron-store');\nconst { PROVIDERS, getProviderClass } = require('../ai/factory');\nconst encryptionService = require('./encryptionService');\nconst providerSettingsRepository = require('../repositories/providerSettings');\nconst authService = require('./authService');\nconst ollamaModelRepository = require('../repositories/ollamaModel');\n\nclass ModelStateService extends EventEmitter {\n constructor() {\n super();\n this.authService = authService;\n // electron-store는 오직 레거시 데이터 마이그레이션 용도로만 사용됩니다.\n this.store = new Store({ name: 'pickle-glass-model-state' });\n }\n\n async initialize() {\n console.log('[ModelStateService] Initializing one-time setup...');\n await this._initializeEncryption();\n await this._runMigrations();\n this.setupLocalAIStateSync();\n await this._autoSelectAvailableModels([], true);\n console.log('[ModelStateService] One-time setup complete.');\n }\n\n async _initializeEncryption() {\n try {\n const rows = await providerSettingsRepository.getRawApiKeys();\n if (rows.some(r => r.api_key && encryptionService.looksEncrypted(r.api_key))) {\n console.log('[ModelStateService] Encrypted keys detected, initializing encryption...');\n const userIdForMigration = this.authService.getCurrentUserId();\n await encryptionService.initializeKey(userIdForMigration);\n } else {\n console.log('[ModelStateService] No encrypted keys detected, skipping encryption initialization.');\n }\n } catch (err) {\n console.warn('[ModelStateService] Error while checking encrypted keys:', err.message);\n }\n }\n\n async _runMigrations() {\n console.log('[ModelStateService] Checking for data migrations...');\n const userId = this.authService.getCurrentUserId();\n \n try {\n const sqliteClient = require('./sqliteClient');\n const db = sqliteClient.getDb();\n const tableExists = db.prepare(\"SELECT name FROM sqlite_master WHERE type='table' AND name='user_model_selections'\").get();\n \n if (tableExists) {\n const selections = db.prepare('SELECT * FROM user_model_selections WHERE uid = ?').get(userId);\n if (selections) {\n console.log('[ModelStateService] Migrating from user_model_selections table...');\n if (selections.llm_model) {\n const llmProvider = this.getProviderForModel(selections.llm_model, 'llm');\n if (llmProvider) {\n await this.setSelectedModel('llm', selections.llm_model);\n }\n }\n if (selections.stt_model) {\n const sttProvider = this.getProviderForModel(selections.stt_model, 'stt');\n if (sttProvider) {\n await this.setSelectedModel('stt', selections.stt_model);\n }\n }\n db.prepare('DROP TABLE user_model_selections').run();\n console.log('[ModelStateService] user_model_selections migration complete.');\n }\n }\n } catch (error) {\n console.error('[ModelStateService] user_model_selections migration failed:', error);\n }\n\n try {\n const legacyData = this.store.get(`users.${userId}`);\n if (legacyData && legacyData.apiKeys) {\n console.log('[ModelStateService] Migrating from electron-store...');\n for (const [provider, apiKey] of Object.entries(legacyData.apiKeys)) {\n if (apiKey && PROVIDERS[provider]) {\n await this.setApiKey(provider, apiKey);\n }\n }\n if (legacyData.selectedModels?.llm) {\n await this.setSelectedModel('llm', legacyData.selectedModels.llm);\n }\n if (legacyData.selectedModels?.stt) {\n await this.setSelectedModel('stt', legacyData.selectedModels.stt);\n }\n this.store.delete(`users.${userId}`);\n console.log('[ModelStateService] electron-store migration complete.');\n }\n } catch (error) {\n console.error('[ModelStateService] electron-store migration failed:', error);\n }\n }\n \n setupLocalAIStateSync() {\n const localAIManager = require('./localAIManager');\n localAIManager.on('state-changed', (service, status) => {\n this.handleLocalAIStateChange(service, status);\n });\n }\n\n async handleLocalAIStateChange(service, state) {\n console.log(`[ModelStateService] LocalAI state changed: ${service}`, state);\n if (!state.installed || !state.running) {\n const types = service === 'ollama' ? ['llm'] : service === 'whisper' ? ['stt'] : [];\n await this._autoSelectAvailableModels(types);\n }\n this.emit('state-updated', await this.getLiveState());\n }\n\n async getLiveState() {\n const providerSettings = await providerSettingsRepository.getAll();\n const apiKeys = {};\n Object.keys(PROVIDERS).forEach(provider => {\n const setting = providerSettings.find(s => s.provider === provider);\n apiKeys[provider] = setting?.api_key || null;\n });\n\n const activeSettings = await providerSettingsRepository.getActiveSettings();\n const selectedModels = {\n llm: activeSettings.llm?.selected_llm_model || null,\n stt: activeSettings.stt?.selected_stt_model || null\n };\n \n return { apiKeys, selectedModels };\n }\n\n async _autoSelectAvailableModels(forceReselectionForTypes = [], isInitialBoot = false) {\n console.log(`[ModelStateService] Running auto-selection. Force re-selection for: [${forceReselectionForTypes.join(', ')}]`);\n const { apiKeys, selectedModels } = await this.getLiveState();\n const types = ['llm', 'stt'];\n\n for (const type of types) {\n const currentModelId = selectedModels[type];\n let isCurrentModelValid = false;\n const forceReselection = forceReselectionForTypes.includes(type);\n\n if (currentModelId && !forceReselection) {\n const provider = this.getProviderForModel(currentModelId, type);\n const apiKey = apiKeys[provider];\n if (provider && apiKey) {\n isCurrentModelValid = true;\n }\n }\n\n if (!isCurrentModelValid) {\n console.log(`[ModelStateService] No valid ${type.toUpperCase()} model selected or selection forced. Finding an alternative...`);\n const availableModels = await this.getAvailableModels(type);\n if (availableModels.length > 0) {\n const apiModel = availableModels.find(model => {\n const provider = this.getProviderForModel(model.id, type);\n return provider && provider !== 'ollama' && provider !== 'whisper';\n });\n const newModel = apiModel || availableModels[0];\n await this.setSelectedModel(type, newModel.id);\n console.log(`[ModelStateService] Auto-selected ${type.toUpperCase()} model: ${newModel.id}`);\n } else {\n await providerSettingsRepository.setActiveProvider(null, type);\n if (!isInitialBoot) {\n this.emit('state-updated', await this.getLiveState());\n }\n }\n }\n }\n }\n \n async setFirebaseVirtualKey(virtualKey) {\n console.log(`[ModelStateService] Setting Firebase virtual key.`);\n\n // 키를 설정하기 전에, 이전에 openai-glass 키가 있었는지 확인합니다.\n const previousSettings = await providerSettingsRepository.getByProvider('openai-glass');\n const wasPreviouslyConfigured = !!previousSettings?.api_key;\n\n // 항상 새로운 가상 키로 업데이트합니다.\n await this.setApiKey('openai-glass', virtualKey);\n\n if (virtualKey) {\n // 이전에 설정된 적이 없는 경우 (최초 로그인)에만 모델을 강제로 변경합니다.\n if (!wasPreviouslyConfigured) {\n console.log('[ModelStateService] First-time setup for openai-glass, setting default models.');\n const llmModel = PROVIDERS['openai-glass']?.llmModels[0];\n const sttModel = PROVIDERS['openai-glass']?.sttModels[0];\n if (llmModel) await this.setSelectedModel('llm', llmModel.id);\n if (sttModel) await this.setSelectedModel('stt', sttModel.id);\n } else {\n console.log('[ModelStateService] openai-glass key updated, but respecting user\\'s existing model selection.');\n }\n } else {\n // 로그아웃 시, 현재 활성화된 모델이 openai-glass인 경우에만 다른 모델로 전환합니다.\n const selected = await this.getSelectedModels();\n const llmProvider = this.getProviderForModel(selected.llm, 'llm');\n const sttProvider = this.getProviderForModel(selected.stt, 'stt');\n \n const typesToReselect = [];\n if (llmProvider === 'openai-glass') typesToReselect.push('llm');\n if (sttProvider === 'openai-glass') typesToReselect.push('stt');\n\n if (typesToReselect.length > 0) {\n console.log('[ModelStateService] Logged out, re-selecting models for:', typesToReselect.join(', '));\n await this._autoSelectAvailableModels(typesToReselect);\n }\n }\n }\n\n async setApiKey(provider, key) {\n console.log(`[ModelStateService] setApiKey for ${provider}`);\n if (!provider) {\n throw new Error('Provider is required');\n }\n\n // 'openai-glass'는 자체 인증 키를 사용하므로 유효성 검사를 건너뜁니다.\n if (provider !== 'openai-glass') {\n const validationResult = await this.validateApiKey(provider, key);\n if (!validationResult.success) {\n console.warn(`[ModelStateService] API key validation failed for ${provider}: ${validationResult.error}`);\n return validationResult;\n }\n }\n\n const finalKey = (provider === 'ollama' || provider === 'whisper') ? 'local' : key;\n const existingSettings = await providerSettingsRepository.getByProvider(provider) || {};\n await providerSettingsRepository.upsert(provider, { ...existingSettings, api_key: finalKey });\n \n // 키가 추가/변경되었으므로, 해당 provider의 모델을 자동 선택할 수 있는지 확인\n await this._autoSelectAvailableModels([]);\n \n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return { success: true };\n }\n\n async getAllApiKeys() {\n const allSettings = await providerSettingsRepository.getAll();\n const apiKeys = {};\n allSettings.forEach(s => {\n if (s.provider !== 'openai-glass') {\n apiKeys[s.provider] = s.api_key;\n }\n });\n return apiKeys;\n }\n\n async removeApiKey(provider) {\n const setting = await providerSettingsRepository.getByProvider(provider);\n if (setting && setting.api_key) {\n await providerSettingsRepository.upsert(provider, { ...setting, api_key: null });\n await this._autoSelectAvailableModels(['llm', 'stt']);\n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return true;\n }\n return false;\n }\n\n /**\n * 사용자가 Firebase에 로그인했는지 확인합니다.\n */\n isLoggedInWithFirebase() {\n return this.authService.getCurrentUser().isLoggedIn;\n }\n\n /**\n * 유효한 API 키가 하나라도 설정되어 있는지 확인합니다.\n */\n async hasValidApiKey() {\n if (this.isLoggedInWithFirebase()) return true;\n \n const allSettings = await providerSettingsRepository.getAll();\n return allSettings.some(s => s.api_key && s.api_key.trim().length > 0);\n }\n\n getProviderForModel(arg1, arg2) {\n // Compatibility: support both (type, modelId) old order and (modelId, type) new order\n let type, modelId;\n if (arg1 === 'llm' || arg1 === 'stt') {\n type = arg1;\n modelId = arg2;\n } else {\n modelId = arg1;\n type = arg2;\n }\n if (!modelId || !type) return null;\n for (const providerId in PROVIDERS) {\n const models = type === 'llm' ? PROVIDERS[providerId].llmModels : PROVIDERS[providerId].sttModels;\n if (models && models.some(m => m.id === modelId)) {\n return providerId;\n }\n }\n if (type === 'llm') {\n const installedModels = ollamaModelRepository.getInstalledModels();\n if (installedModels.some(m => m.name === modelId)) return 'ollama';\n }\n return null;\n }\n\n async getSelectedModels() {\n const active = await providerSettingsRepository.getActiveSettings();\n return {\n llm: active.llm?.selected_llm_model || null,\n stt: active.stt?.selected_stt_model || null,\n };\n }\n \n async setSelectedModel(type, modelId) {\n const provider = this.getProviderForModel(modelId, type);\n if (!provider) {\n console.warn(`[ModelStateService] No provider found for model ${modelId}`);\n return false;\n }\n\n const existingSettings = await providerSettingsRepository.getByProvider(provider) || {};\n const newSettings = { ...existingSettings };\n\n if (type === 'llm') {\n newSettings.selected_llm_model = modelId;\n } else {\n newSettings.selected_stt_model = modelId;\n }\n \n await providerSettingsRepository.upsert(provider, newSettings);\n await providerSettingsRepository.setActiveProvider(provider, type);\n \n console.log(`[ModelStateService] Selected ${type} model: ${modelId} (provider: ${provider})`);\n \n if (type === 'llm' && provider === 'ollama') {\n require('./localAIManager').warmUpModel(modelId).catch(err => console.warn(err));\n }\n \n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return true;\n }\n\n async getAvailableModels(type) {\n const allSettings = await providerSettingsRepository.getAll();\n const available = [];\n const modelListKey = type === 'llm' ? 'llmModels' : 'sttModels';\n\n for (const setting of allSettings) {\n if (!setting.api_key) continue;\n\n const providerId = setting.provider;\n if (providerId === 'ollama' && type === 'llm') {\n const installed = ollamaModelRepository.getInstalledModels();\n available.push(...installed.map(m => ({ id: m.name, name: m.name })));\n } else if (PROVIDERS[providerId]?.[modelListKey]) {\n available.push(...PROVIDERS[providerId][modelListKey]);\n }\n }\n return [...new Map(available.map(item => [item.id, item])).values()];\n }\n\n async getCurrentModelInfo(type) {\n const activeSetting = await providerSettingsRepository.getActiveProvider(type);\n if (!activeSetting) return null;\n \n const model = type === 'llm' ? activeSetting.selected_llm_model : activeSetting.selected_stt_model;\n if (!model) return null;\n\n return {\n provider: activeSetting.provider,\n model: model,\n apiKey: activeSetting.api_key,\n };\n }\n\n // --- 핸들러 및 유틸리티 메서드 ---\n\n async validateApiKey(provider, key) {\n if (!key || (key.trim() === '' && provider !== 'ollama' && provider !== 'whisper')) {\n return { success: false, error: 'API key cannot be empty.' };\n }\n const ProviderClass = getProviderClass(provider);\n if (!ProviderClass || typeof ProviderClass.validateApiKey !== 'function') {\n return { success: true };\n }\n try {\n return await ProviderClass.validateApiKey(key);\n } catch (error) {\n return { success: false, error: 'An unexpected error occurred during validation.' };\n }\n }\n\n getProviderConfig() {\n const config = {};\n for (const key in PROVIDERS) {\n const { handler, ...rest } = PROVIDERS[key];\n config[key] = rest;\n }\n return config;\n }\n \n async handleRemoveApiKey(provider) {\n const success = await this.removeApiKey(provider);\n if (success) {\n const selectedModels = await this.getSelectedModels();\n if (!selectedModels.llm && !selectedModels.stt) {\n this.emit('force-show-apikey-header');\n }\n }\n return success;\n }\n\n /*-------------- Compatibility Helpers --------------*/\n async handleValidateKey(provider, key) {\n return await this.setApiKey(provider, key);\n }\n\n async handleSetSelectedModel(type, modelId) {\n return await this.setSelectedModel(type, modelId);\n }\n\n async areProvidersConfigured() {\n if (this.isLoggedInWithFirebase()) return true;\n const allSettings = await providerSettingsRepository.getAll();\n const apiKeyMap = {};\n allSettings.forEach(s => apiKeyMap[s.provider] = s.api_key);\n // LLM\n const hasLlmKey = Object.entries(apiKeyMap).some(([provider, key]) => {\n if (!key) return false;\n if (provider === 'whisper') return false; // whisper는 LLM 없음\n return PROVIDERS[provider]?.llmModels?.length > 0;\n });\n // STT\n const hasSttKey = Object.entries(apiKeyMap).some(([provider, key]) => {\n if (!key) return false;\n if (provider === 'ollama') return false; // ollama는 STT 없음\n return PROVIDERS[provider]?.sttModels?.length > 0 || provider === 'whisper';\n });\n return hasLlmKey && hasSttKey;\n }\n}\n\nconst modelStateService = new ModelStateService();\nmodule.exports = modelStateService;"], ["/glass/src/window/windowLayoutManager.js", "const { screen } = require('electron');\n\n/**\n * \n * @param {BrowserWindow} window \n * @returns {Display}\n */\nfunction getCurrentDisplay(window) {\n if (!window || window.isDestroyed()) return screen.getPrimaryDisplay();\n\n const windowBounds = window.getBounds();\n const windowCenter = {\n x: windowBounds.x + windowBounds.width / 2,\n y: windowBounds.y + windowBounds.height / 2,\n };\n\n return screen.getDisplayNearestPoint(windowCenter);\n}\n\nclass WindowLayoutManager {\n /**\n * @param {Map} windowPool - 관리할 창들의 맵\n */\n constructor(windowPool) {\n this.windowPool = windowPool;\n this.isUpdating = false;\n this.PADDING = 80;\n }\n\n getHeaderPosition = () => {\n const header = this.windowPool.get('header');\n if (header) {\n const [x, y] = header.getPosition();\n return { x, y };\n }\n return { x: 0, y: 0 };\n };\n\n\n /**\n * \n * @returns {{name: string, primary: string, secondary: string}}\n */\n determineLayoutStrategy(headerBounds, screenWidth, screenHeight, relativeX, relativeY, workAreaX, workAreaY) {\n const headerRelX = headerBounds.x - workAreaX;\n const headerRelY = headerBounds.y - workAreaY;\n\n const spaceBelow = screenHeight - (headerRelY + headerBounds.height);\n const spaceAbove = headerRelY;\n const spaceLeft = headerRelX;\n const spaceRight = screenWidth - (headerRelX + headerBounds.width);\n\n if (spaceBelow >= 400) {\n return { name: 'below', primary: 'below', secondary: relativeX < 0.5 ? 'right' : 'left' };\n } else if (spaceAbove >= 400) {\n return { name: 'above', primary: 'above', secondary: relativeX < 0.5 ? 'right' : 'left' };\n } else if (relativeX < 0.3 && spaceRight >= 800) {\n return { name: 'right-side', primary: 'right', secondary: spaceBelow > spaceAbove ? 'below' : 'above' };\n } else if (relativeX > 0.7 && spaceLeft >= 800) {\n return { name: 'left-side', primary: 'left', secondary: spaceBelow > spaceAbove ? 'below' : 'above' };\n } else {\n return { name: 'adaptive', primary: spaceBelow > spaceAbove ? 'below' : 'above', secondary: spaceRight > spaceLeft ? 'right' : 'left' };\n }\n }\n\n\n\n /**\n * @returns {{x: number, y: number} | null}\n */\n calculateSettingsWindowPosition() {\n const header = this.windowPool.get('header');\n const settings = this.windowPool.get('settings');\n\n if (!header || header.isDestroyed() || !settings || settings.isDestroyed()) {\n return null;\n }\n\n const headerBounds = header.getBounds();\n const settingsBounds = settings.getBounds();\n const display = getCurrentDisplay(header);\n const { x: workAreaX, y: workAreaY, width: screenWidth, height: screenHeight } = display.workArea;\n\n const PAD = 5;\n const buttonPadding = 170;\n\n const x = headerBounds.x + headerBounds.width - settingsBounds.width + buttonPadding;\n const y = headerBounds.y + headerBounds.height + PAD;\n\n const clampedX = Math.max(workAreaX + 10, Math.min(workAreaX + screenWidth - settingsBounds.width - 10, x));\n const clampedY = Math.max(workAreaY + 10, Math.min(workAreaY + screenHeight - settingsBounds.height - 10, y));\n\n return { x: Math.round(clampedX), y: Math.round(clampedY) };\n }\n\n\n calculateHeaderResize(header, { width, height }) {\n if (!header) return null;\n const currentBounds = header.getBounds();\n const centerX = currentBounds.x + currentBounds.width / 2;\n const newX = Math.round(centerX - width / 2);\n const display = getCurrentDisplay(header);\n const { x: workAreaX, width: workAreaWidth } = display.workArea;\n const clampedX = Math.max(workAreaX, Math.min(workAreaX + workAreaWidth - width, newX));\n return { x: clampedX, y: currentBounds.y, width, height };\n }\n \n calculateClampedPosition(header, { x: newX, y: newY }) {\n if (!header) return null;\n const targetDisplay = screen.getDisplayNearestPoint({ x: newX, y: newY });\n const { x: workAreaX, y: workAreaY, width, height } = targetDisplay.workArea;\n const headerBounds = header.getBounds();\n const clampedX = Math.max(workAreaX, Math.min(newX, workAreaX + width - headerBounds.width));\n const clampedY = Math.max(workAreaY, Math.min(newY, workAreaY + height - headerBounds.height));\n return { x: clampedX, y: clampedY };\n }\n \n calculateWindowHeightAdjustment(senderWindow, targetHeight) {\n if (!senderWindow) return null;\n const currentBounds = senderWindow.getBounds();\n const minHeight = senderWindow.getMinimumSize()[1];\n const maxHeight = senderWindow.getMaximumSize()[1];\n let adjustedHeight = Math.max(minHeight, targetHeight);\n if (maxHeight > 0) {\n adjustedHeight = Math.min(maxHeight, adjustedHeight);\n }\n console.log(`[Layout Debug] calculateWindowHeightAdjustment: targetHeight=${targetHeight}`);\n return { ...currentBounds, height: adjustedHeight };\n }\n \n // 기존 getTargetBoundsForFeatureWindows를 이 함수로 대체합니다.\n calculateFeatureWindowLayout(visibility, headerBoundsOverride = null) {\n const header = this.windowPool.get('header');\n const headerBounds = headerBoundsOverride || (header ? header.getBounds() : null);\n\n if (!headerBounds) return {};\n\n let display;\n if (headerBoundsOverride) {\n const boundsCenter = {\n x: headerBounds.x + headerBounds.width / 2,\n y: headerBounds.y + headerBounds.height / 2,\n };\n display = screen.getDisplayNearestPoint(boundsCenter);\n } else {\n display = getCurrentDisplay(header);\n }\n \n const { width: screenWidth, height: screenHeight, x: workAreaX, y: workAreaY } = display.workArea;\n \n const ask = this.windowPool.get('ask');\n const listen = this.windowPool.get('listen');\n \n const askVis = visibility.ask && ask && !ask.isDestroyed();\n const listenVis = visibility.listen && listen && !listen.isDestroyed();\n \n if (!askVis && !listenVis) return {};\n \n const PAD = 8;\n const headerTopRel = headerBounds.y - workAreaY;\n const headerBottomRel = headerTopRel + headerBounds.height;\n const headerCenterXRel = headerBounds.x - workAreaX + headerBounds.width / 2;\n \n const relativeX = headerCenterXRel / screenWidth;\n const relativeY = (headerBounds.y - workAreaY) / screenHeight;\n const strategy = this.determineLayoutStrategy(headerBounds, screenWidth, screenHeight, relativeX, relativeY, workAreaX, workAreaY);\n \n const askB = askVis ? ask.getBounds() : null;\n const listenB = listenVis ? listen.getBounds() : null;\n\n if (askVis) {\n console.log(`[Layout Debug] Ask Window Bounds: height=${askB.height}, width=${askB.width}`);\n }\n if (listenVis) {\n console.log(`[Layout Debug] Listen Window Bounds: height=${listenB.height}, width=${listenB.width}`);\n }\n \n const layout = {};\n \n if (askVis && listenVis) {\n let askXRel = headerCenterXRel - (askB.width / 2);\n let listenXRel = askXRel - listenB.width - PAD;\n \n if (listenXRel < PAD) {\n listenXRel = PAD;\n askXRel = listenXRel + listenB.width + PAD;\n }\n if (askXRel + askB.width > screenWidth - PAD) {\n askXRel = screenWidth - PAD - askB.width;\n listenXRel = askXRel - listenB.width - PAD;\n }\n \n if (strategy.primary === 'above') {\n const windowBottomAbs = headerBounds.y - PAD;\n layout.ask = { x: Math.round(askXRel + workAreaX), y: Math.round(windowBottomAbs - askB.height), width: askB.width, height: askB.height };\n layout.listen = { x: Math.round(listenXRel + workAreaX), y: Math.round(windowBottomAbs - listenB.height), width: listenB.width, height: listenB.height };\n } else { // 'below'\n const yAbs = headerBounds.y + headerBounds.height + PAD;\n layout.ask = { x: Math.round(askXRel + workAreaX), y: Math.round(yAbs), width: askB.width, height: askB.height };\n layout.listen = { x: Math.round(listenXRel + workAreaX), y: Math.round(yAbs), width: listenB.width, height: listenB.height };\n }\n } else { // Single window\n const winName = askVis ? 'ask' : 'listen';\n const winB = askVis ? askB : listenB;\n if (!winB) return {};\n \n let xRel = headerCenterXRel - winB.width / 2;\n xRel = Math.max(PAD, Math.min(screenWidth - winB.width - PAD, xRel));\n \n let yPos;\n if (strategy.primary === 'above') {\n yPos = (headerBounds.y - workAreaY) - PAD - winB.height;\n } else { // 'below'\n yPos = (headerBounds.y - workAreaY) + headerBounds.height + PAD;\n }\n \n layout[winName] = { x: Math.round(xRel + workAreaX), y: Math.round(yPos + workAreaY), width: winB.width, height: winB.height };\n }\n return layout;\n }\n \n calculateShortcutSettingsWindowPosition() {\n const header = this.windowPool.get('header');\n const shortcutSettings = this.windowPool.get('shortcut-settings');\n if (!header || !shortcutSettings) return null;\n \n const headerBounds = header.getBounds();\n const shortcutBounds = shortcutSettings.getBounds();\n const { workArea } = getCurrentDisplay(header);\n \n let newX = Math.round(headerBounds.x + (headerBounds.width / 2) - (shortcutBounds.width / 2));\n let newY = Math.round(headerBounds.y);\n \n newX = Math.max(workArea.x, Math.min(newX, workArea.x + workArea.width - shortcutBounds.width));\n newY = Math.max(workArea.y, Math.min(newY, workArea.y + workArea.height - shortcutBounds.height));\n \n return { x: newX, y: newY, width: shortcutBounds.width, height: shortcutBounds.height };\n }\n\n calculateStepMovePosition(header, direction) {\n if (!header) return null;\n const currentBounds = header.getBounds();\n const stepSize = 80; // 이동 간격\n let targetX = currentBounds.x;\n let targetY = currentBounds.y;\n \n switch (direction) {\n case 'left': targetX -= stepSize; break;\n case 'right': targetX += stepSize; break;\n case 'up': targetY -= stepSize; break;\n case 'down': targetY += stepSize; break;\n }\n \n return this.calculateClampedPosition(header, { x: targetX, y: targetY });\n }\n \n calculateEdgePosition(header, direction) {\n if (!header) return null;\n const display = getCurrentDisplay(header);\n const { workArea } = display;\n const currentBounds = header.getBounds();\n \n let targetX = currentBounds.x;\n let targetY = currentBounds.y;\n \n switch (direction) {\n case 'left': targetX = workArea.x; break;\n case 'right': targetX = workArea.x + workArea.width - currentBounds.width; break;\n case 'up': targetY = workArea.y; break;\n case 'down': targetY = workArea.y + workArea.height - currentBounds.height; break;\n }\n return { x: targetX, y: targetY };\n }\n \n calculateNewPositionForDisplay(window, targetDisplayId) {\n if (!window) return null;\n \n const targetDisplay = screen.getAllDisplays().find(d => d.id === targetDisplayId);\n if (!targetDisplay) return null;\n \n const currentBounds = window.getBounds();\n const currentDisplay = getCurrentDisplay(window);\n \n if (currentDisplay.id === targetDisplay.id) return { x: currentBounds.x, y: currentBounds.y };\n \n const relativeX = (currentBounds.x - currentDisplay.workArea.x) / currentDisplay.workArea.width;\n const relativeY = (currentBounds.y - currentDisplay.workArea.y) / currentDisplay.workArea.height;\n \n const targetX = targetDisplay.workArea.x + targetDisplay.workArea.width * relativeX;\n const targetY = targetDisplay.workArea.y + targetDisplay.workArea.height * relativeY;\n \n const clampedX = Math.max(targetDisplay.workArea.x, Math.min(targetX, targetDisplay.workArea.x + targetDisplay.workArea.width - currentBounds.width));\n const clampedY = Math.max(targetDisplay.workArea.y, Math.min(targetY, targetDisplay.workArea.y + targetDisplay.workArea.height - currentBounds.height));\n \n return { x: Math.round(clampedX), y: Math.round(clampedY) };\n }\n \n /**\n * @param {Rectangle} bounds1\n * @param {Rectangle} bounds2\n * @returns {boolean}\n */\n boundsOverlap(bounds1, bounds2) {\n const margin = 10;\n return !(\n bounds1.x + bounds1.width + margin < bounds2.x ||\n bounds2.x + bounds2.width + margin < bounds1.x ||\n bounds1.y + bounds1.height + margin < bounds2.y ||\n bounds2.y + bounds2.height + margin < bounds1.y\n );\n }\n}\n\nmodule.exports = WindowLayoutManager;"], ["/glass/src/features/common/ai/providers/whisper.js", "let spawn, path, EventEmitter;\n\nif (typeof window === 'undefined') {\n spawn = require('child_process').spawn;\n path = require('path');\n EventEmitter = require('events').EventEmitter;\n} else {\n class DummyEventEmitter {\n on() {}\n emit() {}\n removeAllListeners() {}\n }\n EventEmitter = DummyEventEmitter;\n}\n\nclass WhisperSTTSession extends EventEmitter {\n constructor(model, whisperService, sessionId) {\n super();\n this.model = model;\n this.whisperService = whisperService;\n this.sessionId = sessionId || `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n this.process = null;\n this.isRunning = false;\n this.audioBuffer = Buffer.alloc(0);\n this.processingInterval = null;\n this.lastTranscription = '';\n }\n\n async initialize() {\n try {\n await this.whisperService.ensureModelAvailable(this.model);\n this.isRunning = true;\n this.startProcessingLoop();\n return true;\n } catch (error) {\n console.error('[WhisperSTT] Initialization error:', error);\n this.emit('error', error);\n return false;\n }\n }\n\n startProcessingLoop() {\n this.processingInterval = setInterval(async () => {\n const minBufferSize = 16000 * 2 * 0.15;\n if (this.audioBuffer.length >= minBufferSize && !this.process) {\n console.log(`[WhisperSTT-${this.sessionId}] Processing audio chunk, buffer size: ${this.audioBuffer.length}`);\n await this.processAudioChunk();\n }\n }, 1500);\n }\n\n async processAudioChunk() {\n if (!this.isRunning || this.audioBuffer.length === 0) return;\n\n const audioData = this.audioBuffer;\n this.audioBuffer = Buffer.alloc(0);\n\n try {\n const tempFile = await this.whisperService.saveAudioToTemp(audioData, this.sessionId);\n \n if (!tempFile || typeof tempFile !== 'string') {\n console.error('[WhisperSTT] Invalid temp file path:', tempFile);\n return;\n }\n \n const whisperPath = await this.whisperService.getWhisperPath();\n const modelPath = await this.whisperService.getModelPath(this.model);\n\n if (!whisperPath || !modelPath) {\n console.error('[WhisperSTT] Invalid whisper or model path:', { whisperPath, modelPath });\n return;\n }\n\n this.process = spawn(whisperPath, [\n '-m', modelPath,\n '-f', tempFile,\n '--no-timestamps',\n '--output-txt',\n '--output-json',\n '--language', 'auto',\n '--threads', '4',\n '--print-progress', 'false'\n ]);\n\n let output = '';\n let errorOutput = '';\n\n this.process.stdout.on('data', (data) => {\n output += data.toString();\n });\n\n this.process.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n\n this.process.on('close', async (code) => {\n this.process = null;\n \n if (code === 0 && output.trim()) {\n const transcription = output.trim();\n if (transcription && transcription !== this.lastTranscription) {\n this.lastTranscription = transcription;\n console.log(`[WhisperSTT-${this.sessionId}] Transcription: \"${transcription}\"`);\n this.emit('transcription', {\n text: transcription,\n timestamp: Date.now(),\n confidence: 1.0,\n sessionId: this.sessionId\n });\n }\n } else if (errorOutput) {\n console.error(`[WhisperSTT-${this.sessionId}] Process error:`, errorOutput);\n }\n\n await this.whisperService.cleanupTempFile(tempFile);\n });\n\n } catch (error) {\n console.error('[WhisperSTT] Processing error:', error);\n this.emit('error', error);\n }\n }\n\n sendRealtimeInput(audioData) {\n if (!this.isRunning) {\n console.warn(`[WhisperSTT-${this.sessionId}] Session not running, cannot accept audio`);\n return;\n }\n\n if (typeof audioData === 'string') {\n try {\n audioData = Buffer.from(audioData, 'base64');\n } catch (error) {\n console.error('[WhisperSTT] Failed to decode base64 audio data:', error);\n return;\n }\n } else if (audioData instanceof ArrayBuffer) {\n audioData = Buffer.from(audioData);\n } else if (!Buffer.isBuffer(audioData) && !(audioData instanceof Uint8Array)) {\n console.error('[WhisperSTT] Invalid audio data type:', typeof audioData);\n return;\n }\n\n if (!Buffer.isBuffer(audioData)) {\n audioData = Buffer.from(audioData);\n }\n\n if (audioData.length > 0) {\n this.audioBuffer = Buffer.concat([this.audioBuffer, audioData]);\n // Log every 10th audio chunk to avoid spam\n if (Math.random() < 0.1) {\n console.log(`[WhisperSTT-${this.sessionId}] Received audio chunk: ${audioData.length} bytes, total buffer: ${this.audioBuffer.length} bytes`);\n }\n }\n }\n\n async close() {\n console.log(`[WhisperSTT-${this.sessionId}] Closing session`);\n this.isRunning = false;\n\n if (this.processingInterval) {\n clearInterval(this.processingInterval);\n this.processingInterval = null;\n }\n\n if (this.process) {\n this.process.kill('SIGTERM');\n this.process = null;\n }\n\n this.removeAllListeners();\n }\n}\n\nclass WhisperProvider {\n static async validateApiKey() {\n // Whisper is a local service, no API key validation needed.\n return { success: true };\n }\n\n constructor() {\n this.whisperService = null;\n }\n\n async initialize() {\n if (!this.whisperService) {\n this.whisperService = require('../../services/whisperService');\n if (!this.whisperService.isInitialized) {\n await this.whisperService.initialize();\n }\n }\n }\n\n async createSTT(config) {\n await this.initialize();\n \n const model = config.model || 'whisper-tiny';\n const sessionType = config.sessionType || 'unknown';\n console.log(`[WhisperProvider] Creating ${sessionType} STT session with model: ${model}`);\n \n // Create unique session ID based on type\n const sessionId = `${sessionType}_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`;\n const session = new WhisperSTTSession(model, this.whisperService, sessionId);\n \n // Log session creation\n console.log(`[WhisperProvider] Created session: ${sessionId}`);\n \n const initialized = await session.initialize();\n if (!initialized) {\n throw new Error('Failed to initialize Whisper STT session');\n }\n\n if (config.callbacks) {\n if (config.callbacks.onmessage) {\n session.on('transcription', config.callbacks.onmessage);\n }\n if (config.callbacks.onerror) {\n session.on('error', config.callbacks.onerror);\n }\n if (config.callbacks.onclose) {\n session.on('close', config.callbacks.onclose);\n }\n }\n\n return session;\n }\n\n async createLLM() {\n throw new Error('Whisper provider does not support LLM functionality');\n }\n\n async createStreamingLLM() {\n console.warn('[WhisperProvider] Streaming LLM is not supported by Whisper.');\n throw new Error('Whisper does not support LLM.');\n }\n}\n\nmodule.exports = {\n WhisperProvider,\n WhisperSTTSession\n};"], ["/glass/src/features/common/ai/providers/gemini.js", "const { GoogleGenerativeAI } = require(\"@google/generative-ai\")\nconst { GoogleGenAI } = require(\"@google/genai\")\n\nclass GeminiProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string') {\n return { success: false, error: 'Invalid Gemini API key format.' };\n }\n\n try {\n const validationUrl = `https://generativelanguage.googleapis.com/v1beta/models?key=${key}`;\n const response = await fetch(validationUrl);\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error?.message || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[GeminiProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n\n/**\n * Creates a Gemini STT session\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Gemini API key\n * @param {string} [opts.language='en-US'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @returns {Promise} STT session\n */\nasync function createSTT({ apiKey, language = \"en-US\", callbacks = {}, ...config }) {\n const liveClient = new GoogleGenAI({ vertexai: false, apiKey })\n\n // Language code BCP-47 conversion\n const lang = language.includes(\"-\") ? language : `${language}-US`\n\n const session = await liveClient.live.connect({\n\n model: 'gemini-live-2.5-flash-preview',\n callbacks: {\n ...callbacks,\n onMessage: (msg) => {\n if (!msg || typeof msg !== 'object') return;\n msg.provider = 'gemini';\n callbacks.onmessage?.(msg);\n }\n },\n\n config: {\n inputAudioTranscription: {},\n speechConfig: { languageCode: lang },\n },\n })\n\n return {\n sendRealtimeInput: async (payload) => session.sendRealtimeInput(payload),\n close: async () => session.close(),\n }\n}\n\n/**\n * Creates a Gemini LLM instance with proper text response handling\n */\nfunction createLLM({ apiKey, model = \"gemini-2.5-flash\", temperature = 0.7, maxTokens = 8192, ...config }) {\n const client = new GoogleGenerativeAI(apiKey)\n\n return {\n generateContent: async (parts) => {\n const geminiModel = client.getGenerativeModel({\n model: model,\n generationConfig: {\n temperature,\n maxOutputTokens: maxTokens,\n // Ensure we get text responses, not JSON\n responseMimeType: \"text/plain\",\n },\n })\n\n const systemPrompt = \"\"\n const userContent = []\n\n for (const part of parts) {\n if (typeof part === \"string\") {\n // Don't automatically assume strings starting with \"You are\" are system prompts\n // Check if it's explicitly marked as a system instruction\n userContent.push(part)\n } else if (part.inlineData) {\n userContent.push({\n inlineData: {\n mimeType: part.inlineData.mimeType,\n data: part.inlineData.data,\n },\n })\n }\n }\n\n try {\n const result = await geminiModel.generateContent(userContent)\n const response = await result.response\n\n // Return plain text, not wrapped in JSON structure\n return {\n response: {\n text: () => response.text(),\n },\n }\n } catch (error) {\n console.error(\"Gemini API error:\", error)\n throw error\n }\n },\n\n chat: async (messages) => {\n // Filter out any system prompts that might be causing JSON responses\n let systemInstruction = \"\"\n const history = []\n let lastMessage\n\n messages.forEach((msg, index) => {\n if (msg.role === \"system\") {\n // Clean system instruction - avoid JSON formatting requests\n systemInstruction = msg.content\n .replace(/respond in json/gi, \"\")\n .replace(/format.*json/gi, \"\")\n .replace(/return.*json/gi, \"\")\n\n // Add explicit instruction for natural text\n if (!systemInstruction.includes(\"respond naturally\")) {\n systemInstruction += \"\\n\\nRespond naturally in plain text, not in JSON or structured format.\"\n }\n return\n }\n\n const role = msg.role === \"user\" ? \"user\" : \"model\"\n\n if (index === messages.length - 1) {\n lastMessage = msg\n } else {\n history.push({ role, parts: [{ text: msg.content }] })\n }\n })\n\n const geminiModel = client.getGenerativeModel({\n model: model,\n systemInstruction:\n systemInstruction ||\n \"Respond naturally in plain text format. Do not use JSON or structured responses unless specifically requested.\",\n generationConfig: {\n temperature: temperature,\n maxOutputTokens: maxTokens,\n // Force plain text responses\n responseMimeType: \"text/plain\",\n },\n })\n\n const chat = geminiModel.startChat({\n history: history,\n })\n\n let content = lastMessage.content\n\n // Handle multimodal content\n if (Array.isArray(content)) {\n const geminiContent = []\n for (const part of content) {\n if (typeof part === \"string\") {\n geminiContent.push(part)\n } else if (part.type === \"text\") {\n geminiContent.push(part.text)\n } else if (part.type === \"image_url\" && part.image_url) {\n const base64Data = part.image_url.url.split(\",\")[1]\n geminiContent.push({\n inlineData: {\n mimeType: \"image/png\",\n data: base64Data,\n },\n })\n }\n }\n content = geminiContent\n }\n\n const result = await chat.sendMessage(content)\n const response = await result.response\n\n // Return plain text content\n return {\n content: response.text(),\n raw: result,\n }\n },\n }\n}\n\n/**\n * Creates a Gemini streaming LLM instance with text response fix\n */\nfunction createStreamingLLM({ apiKey, model = \"gemini-2.5-flash\", temperature = 0.7, maxTokens = 8192, ...config }) {\n const client = new GoogleGenerativeAI(apiKey)\n\n return {\n streamChat: async (messages) => {\n console.log(\"[Gemini Provider] Starting streaming request\")\n\n let systemInstruction = \"\"\n const nonSystemMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n // Clean and modify system instruction\n systemInstruction = msg.content\n .replace(/respond in json/gi, \"\")\n .replace(/format.*json/gi, \"\")\n .replace(/return.*json/gi, \"\")\n\n if (!systemInstruction.includes(\"respond naturally\")) {\n systemInstruction += \"\\n\\nRespond naturally in plain text, not in JSON or structured format.\"\n }\n } else {\n nonSystemMessages.push(msg)\n }\n }\n\n const geminiModel = client.getGenerativeModel({\n model: model,\n systemInstruction:\n systemInstruction ||\n \"Respond naturally in plain text format. Do not use JSON or structured responses unless specifically requested.\",\n generationConfig: {\n temperature,\n maxOutputTokens: maxTokens || 8192,\n // Force plain text responses\n responseMimeType: \"text/plain\",\n },\n })\n\n const stream = new ReadableStream({\n async start(controller) {\n try {\n const lastMessage = nonSystemMessages[nonSystemMessages.length - 1]\n let geminiContent = []\n\n if (Array.isArray(lastMessage.content)) {\n for (const part of lastMessage.content) {\n if (typeof part === \"string\") {\n geminiContent.push(part)\n } else if (part.type === \"text\") {\n geminiContent.push(part.text)\n } else if (part.type === \"image_url\" && part.image_url) {\n const base64Data = part.image_url.url.split(\",\")[1]\n geminiContent.push({\n inlineData: {\n mimeType: \"image/png\",\n data: base64Data,\n },\n })\n }\n }\n } else {\n geminiContent = [lastMessage.content]\n }\n\n const contentParts = geminiContent.map((part) => {\n if (typeof part === \"string\") {\n return { text: part }\n } else if (part.inlineData) {\n return { inlineData: part.inlineData }\n }\n return part\n })\n\n const result = await geminiModel.generateContentStream({\n contents: [\n {\n role: \"user\",\n parts: contentParts,\n },\n ],\n })\n\n for await (const chunk of result.stream) {\n const chunkText = chunk.text() || \"\"\n\n // Format as SSE data - this should now be plain text\n const data = JSON.stringify({\n choices: [\n {\n delta: {\n content: chunkText,\n },\n },\n ],\n })\n controller.enqueue(new TextEncoder().encode(`data: ${data}\\n\\n`))\n }\n\n controller.enqueue(new TextEncoder().encode(\"data: [DONE]\\n\\n\"))\n controller.close()\n } catch (error) {\n console.error(\"[Gemini Provider] Streaming error:\", error)\n controller.error(error)\n }\n },\n })\n\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n },\n })\n },\n }\n}\n\nmodule.exports = {\n GeminiProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};\n"], ["/glass/src/features/listen/listenService.js", "const { BrowserWindow } = require('electron');\nconst SttService = require('./stt/sttService');\nconst SummaryService = require('./summary/summaryService');\nconst authService = require('../common/services/authService');\nconst sessionRepository = require('../common/repositories/session');\nconst sttRepository = require('./stt/repositories');\nconst internalBridge = require('../../bridge/internalBridge');\n\nclass ListenService {\n constructor() {\n this.sttService = new SttService();\n this.summaryService = new SummaryService();\n this.currentSessionId = null;\n this.isInitializingSession = false;\n\n this.setupServiceCallbacks();\n console.log('[ListenService] Service instance created.');\n }\n\n setupServiceCallbacks() {\n // STT service callbacks\n this.sttService.setCallbacks({\n onTranscriptionComplete: (speaker, text) => {\n this.handleTranscriptionComplete(speaker, text);\n },\n onStatusUpdate: (status) => {\n this.sendToRenderer('update-status', status);\n }\n });\n\n // Summary service callbacks\n this.summaryService.setCallbacks({\n onAnalysisComplete: (data) => {\n console.log('📊 Analysis completed:', data);\n },\n onStatusUpdate: (status) => {\n this.sendToRenderer('update-status', status);\n }\n });\n }\n\n sendToRenderer(channel, data) {\n const { windowPool } = require('../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n initialize() {\n this.setupIpcHandlers();\n console.log('[ListenService] Initialized and ready.');\n }\n\n async handleListenRequest(listenButtonText) {\n const { windowPool } = require('../../window/windowManager');\n const listenWindow = windowPool.get('listen');\n const header = windowPool.get('header');\n\n try {\n switch (listenButtonText) {\n case 'Listen':\n console.log('[ListenService] changeSession to \"Listen\"');\n internalBridge.emit('window:requestVisibility', { name: 'listen', visible: true });\n await this.initializeSession();\n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send('session-state-changed', { isActive: true });\n }\n break;\n \n case 'Stop':\n console.log('[ListenService] changeSession to \"Stop\"');\n await this.closeSession();\n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send('session-state-changed', { isActive: false });\n }\n break;\n \n case 'Done':\n console.log('[ListenService] changeSession to \"Done\"');\n internalBridge.emit('window:requestVisibility', { name: 'listen', visible: false });\n listenWindow.webContents.send('session-state-changed', { isActive: false });\n break;\n \n default:\n throw new Error(`[ListenService] unknown listenButtonText: ${listenButtonText}`);\n }\n \n header.webContents.send('listen:changeSessionResult', { success: true });\n\n } catch (error) {\n console.error('[ListenService] error in handleListenRequest:', error);\n header.webContents.send('listen:changeSessionResult', { success: false });\n throw error; \n }\n }\n\n async handleTranscriptionComplete(speaker, text) {\n console.log(`[ListenService] Transcription complete: ${speaker} - ${text}`);\n \n // Save to database\n await this.saveConversationTurn(speaker, text);\n \n // Add to summary service for analysis\n this.summaryService.addConversationTurn(speaker, text);\n }\n\n async saveConversationTurn(speaker, transcription) {\n if (!this.currentSessionId) {\n console.error('[DB] Cannot save turn, no active session ID.');\n return;\n }\n if (transcription.trim() === '') return;\n\n try {\n await sessionRepository.touch(this.currentSessionId);\n await sttRepository.addTranscript({\n sessionId: this.currentSessionId,\n speaker: speaker,\n text: transcription.trim(),\n });\n console.log(`[DB] Saved transcript for session ${this.currentSessionId}: (${speaker})`);\n } catch (error) {\n console.error('Failed to save transcript to DB:', error);\n }\n }\n\n async initializeNewSession() {\n try {\n // The UID is no longer passed to the repository method directly.\n // The adapter layer handles UID injection. We just ensure a user is available.\n const user = authService.getCurrentUser();\n if (!user) {\n // This case should ideally not happen as authService initializes a default user.\n throw new Error(\"Cannot initialize session: auth service not ready.\");\n }\n \n this.currentSessionId = await sessionRepository.getOrCreateActive('listen');\n console.log(`[DB] New listen session ensured: ${this.currentSessionId}`);\n\n // Set session ID for summary service\n this.summaryService.setSessionId(this.currentSessionId);\n \n // Reset conversation history\n this.summaryService.resetConversationHistory();\n\n console.log('New conversation session started:', this.currentSessionId);\n return true;\n } catch (error) {\n console.error('Failed to initialize new session in DB:', error);\n this.currentSessionId = null;\n return false;\n }\n }\n\n async initializeSession(language = 'en') {\n if (this.isInitializingSession) {\n console.log('Session initialization already in progress.');\n return false;\n }\n\n this.isInitializingSession = true;\n this.sendToRenderer('session-initializing', true);\n this.sendToRenderer('update-status', 'Initializing sessions...');\n\n try {\n // Initialize database session\n const sessionInitialized = await this.initializeNewSession();\n if (!sessionInitialized) {\n throw new Error('Failed to initialize database session');\n }\n\n /* ---------- STT Initialization Retry Logic ---------- */\n const MAX_RETRY = 10;\n const RETRY_DELAY_MS = 300; // 0.3 seconds\n\n let sttReady = false;\n for (let attempt = 1; attempt <= MAX_RETRY; attempt++) {\n try {\n await this.sttService.initializeSttSessions(language);\n sttReady = true;\n break; // Exit on success\n } catch (err) {\n console.warn(\n `[ListenService] STT init attempt ${attempt} failed: ${err.message}`\n );\n if (attempt < MAX_RETRY) {\n await new Promise(r => setTimeout(r, RETRY_DELAY_MS));\n }\n }\n }\n if (!sttReady) throw new Error('STT init failed after retries');\n /* ------------------------------------------- */\n\n console.log('✅ Listen service initialized successfully.');\n \n this.sendToRenderer('update-status', 'Connected. Ready to listen.');\n \n return true;\n } catch (error) {\n console.error('❌ Failed to initialize listen service:', error);\n this.sendToRenderer('update-status', 'Initialization failed.');\n return false;\n } finally {\n this.isInitializingSession = false;\n this.sendToRenderer('session-initializing', false);\n this.sendToRenderer('change-listen-capture-state', { status: \"start\" });\n }\n }\n\n async sendMicAudioContent(data, mimeType) {\n return await this.sttService.sendMicAudioContent(data, mimeType);\n }\n\n async startMacOSAudioCapture() {\n if (process.platform !== 'darwin') {\n throw new Error('macOS audio capture only available on macOS');\n }\n return await this.sttService.startMacOSAudioCapture();\n }\n\n async stopMacOSAudioCapture() {\n this.sttService.stopMacOSAudioCapture();\n }\n\n isSessionActive() {\n return this.sttService.isSessionActive();\n }\n\n async closeSession() {\n try {\n this.sendToRenderer('change-listen-capture-state', { status: \"stop\" });\n // Close STT sessions\n await this.sttService.closeSessions();\n\n await this.stopMacOSAudioCapture();\n\n // End database session\n if (this.currentSessionId) {\n await sessionRepository.end(this.currentSessionId);\n console.log(`[DB] Session ${this.currentSessionId} ended.`);\n }\n\n // Reset state\n this.currentSessionId = null;\n this.summaryService.resetConversationHistory();\n\n console.log('Listen service session closed.');\n return { success: true };\n } catch (error) {\n console.error('Error closing listen service session:', error);\n return { success: false, error: error.message };\n }\n }\n\n getCurrentSessionData() {\n return {\n sessionId: this.currentSessionId,\n conversationHistory: this.summaryService.getConversationHistory(),\n totalTexts: this.summaryService.getConversationHistory().length,\n analysisData: this.summaryService.getCurrentAnalysisData(),\n };\n }\n\n getConversationHistory() {\n return this.summaryService.getConversationHistory();\n }\n\n _createHandler(asyncFn, successMessage, errorMessage) {\n return async (...args) => {\n try {\n const result = await asyncFn.apply(this, args);\n if (successMessage) console.log(successMessage);\n // `startMacOSAudioCapture`는 성공 시 { success, error } 객체를 반환하지 않으므로,\n // 핸들러가 일관된 응답을 보내도록 여기서 success 객체를 반환합니다.\n // 다른 함수들은 이미 success 객체를 반환합니다.\n return result && typeof result.success !== 'undefined' ? result : { success: true };\n } catch (e) {\n console.error(errorMessage, e);\n return { success: false, error: e.message };\n }\n };\n }\n\n // `_createHandler`를 사용하여 핸들러들을 동적으로 생성합니다.\n handleSendMicAudioContent = this._createHandler(\n this.sendMicAudioContent,\n null,\n 'Error sending user audio:'\n );\n\n handleStartMacosAudio = this._createHandler(\n async () => {\n if (process.platform !== 'darwin') {\n return { success: false, error: 'macOS audio capture only available on macOS' };\n }\n if (this.sttService.isMacOSAudioRunning?.()) {\n return { success: false, error: 'already_running' };\n }\n await this.startMacOSAudioCapture();\n return { success: true, error: null };\n },\n 'macOS audio capture started.',\n 'Error starting macOS audio capture:'\n );\n \n handleStopMacosAudio = this._createHandler(\n this.stopMacOSAudioCapture,\n 'macOS audio capture stopped.',\n 'Error stopping macOS audio capture:'\n );\n\n handleUpdateGoogleSearchSetting = this._createHandler(\n async (enabled) => {\n console.log('Google Search setting updated to:', enabled);\n },\n null,\n 'Error updating Google Search setting:'\n );\n}\n\nconst listenService = new ListenService();\nmodule.exports = listenService;"], ["/glass/src/features/common/ai/providers/anthropic.js", "const { Anthropic } = require(\"@anthropic-ai/sdk\")\n\nclass AnthropicProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string' || !key.startsWith('sk-ant-')) {\n return { success: false, error: 'Invalid Anthropic API key format.' };\n }\n\n try {\n const response = await fetch(\"https://api.anthropic.com/v1/messages\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": key,\n \"anthropic-version\": \"2023-06-01\",\n },\n body: JSON.stringify({\n model: \"claude-3-haiku-20240307\",\n max_tokens: 1,\n messages: [{ role: \"user\", content: \"Hi\" }],\n }),\n });\n\n if (response.ok || response.status === 400) { // 400 is a valid response for a bad request, not a bad key\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n return { success: false, error: errorData.error?.message || `Validation failed with status: ${response.status}` };\n }\n } catch (error) {\n console.error(`[AnthropicProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n/**\n * Creates an Anthropic STT session\n * Note: Anthropic doesn't have native real-time STT, so this is a placeholder\n * You might want to use a different STT service or implement a workaround\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.language='en'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @returns {Promise} STT session placeholder\n */\nasync function createSTT({ apiKey, language = \"en\", callbacks = {}, ...config }) {\n console.warn(\"[Anthropic] STT not natively supported. Consider using OpenAI or Gemini for STT.\")\n\n // Return a mock STT session that doesn't actually do anything\n // You might want to fallback to another provider for STT\n return {\n sendRealtimeInput: async (audioData) => {\n console.warn(\"[Anthropic] STT sendRealtimeInput called but not implemented\")\n },\n close: async () => {\n console.log(\"[Anthropic] STT session closed\")\n },\n }\n}\n\n/**\n * Creates an Anthropic LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.model='claude-3-5-sonnet-20241022'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=4096] - Max tokens\n * @returns {object} LLM instance\n */\nfunction createLLM({ apiKey, model = \"claude-3-5-sonnet-20241022\", temperature = 0.7, maxTokens = 4096, ...config }) {\n const client = new Anthropic({ apiKey })\n\n return {\n generateContent: async (parts) => {\n const messages = []\n let systemPrompt = \"\"\n const userContent = []\n\n for (const part of parts) {\n if (typeof part === \"string\") {\n if (systemPrompt === \"\" && part.includes(\"You are\")) {\n systemPrompt = part\n } else {\n userContent.push({ type: \"text\", text: part })\n }\n } else if (part.inlineData) {\n userContent.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: part.inlineData.mimeType,\n data: part.inlineData.data,\n },\n })\n }\n }\n\n if (userContent.length > 0) {\n messages.push({ role: \"user\", content: userContent })\n }\n\n try {\n const response = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: messages,\n })\n\n return {\n response: {\n text: () => response.content[0].text,\n },\n raw: response,\n }\n } catch (error) {\n console.error(\"Anthropic API error:\", error)\n throw error\n }\n },\n\n // For compatibility with chat-style interfaces\n chat: async (messages) => {\n let systemPrompt = \"\"\n const anthropicMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemPrompt = msg.content\n } else {\n // Handle multimodal content\n let content\n if (Array.isArray(msg.content)) {\n content = []\n for (const part of msg.content) {\n if (typeof part === \"string\") {\n content.push({ type: \"text\", text: part })\n } else if (part.type === \"text\") {\n content.push({ type: \"text\", text: part.text })\n } else if (part.type === \"image_url\" && part.image_url) {\n // Convert base64 image to Anthropic format\n const imageUrl = part.image_url.url\n const [mimeInfo, base64Data] = imageUrl.split(\",\")\n\n // Extract the actual MIME type from the data URL\n const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || \"image/jpeg\"\n\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: mimeType,\n data: base64Data,\n },\n })\n }\n }\n } else {\n content = [{ type: \"text\", text: msg.content }]\n }\n\n anthropicMessages.push({\n role: msg.role === \"user\" ? \"user\" : \"assistant\",\n content: content,\n })\n }\n }\n\n const response = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: anthropicMessages,\n })\n\n return {\n content: response.content[0].text,\n raw: response,\n }\n },\n }\n}\n\n/**\n * Creates an Anthropic streaming LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.model='claude-3-5-sonnet-20241022'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=4096] - Max tokens\n * @returns {object} Streaming LLM instance\n */\nfunction createStreamingLLM({\n apiKey,\n model = \"claude-3-5-sonnet-20241022\",\n temperature = 0.7,\n maxTokens = 4096,\n ...config\n}) {\n const client = new Anthropic({ apiKey })\n\n return {\n streamChat: async (messages) => {\n console.log(\"[Anthropic Provider] Starting streaming request\")\n\n let systemPrompt = \"\"\n const anthropicMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemPrompt = msg.content\n } else {\n // Handle multimodal content\n let content\n if (Array.isArray(msg.content)) {\n content = []\n for (const part of msg.content) {\n if (typeof part === \"string\") {\n content.push({ type: \"text\", text: part })\n } else if (part.type === \"text\") {\n content.push({ type: \"text\", text: part.text })\n } else if (part.type === \"image_url\" && part.image_url) {\n // Convert base64 image to Anthropic format\n const imageUrl = part.image_url.url\n const [mimeInfo, base64Data] = imageUrl.split(\",\")\n\n // Extract the actual MIME type from the data URL\n const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || \"image/jpeg\"\n\n console.log(`[Anthropic] Processing image with MIME type: ${mimeType}`)\n\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: mimeType,\n data: base64Data,\n },\n })\n }\n }\n } else {\n content = [{ type: \"text\", text: msg.content }]\n }\n\n anthropicMessages.push({\n role: msg.role === \"user\" ? \"user\" : \"assistant\",\n content: content,\n })\n }\n }\n\n // Create a ReadableStream to handle Anthropic's streaming\n const stream = new ReadableStream({\n async start(controller) {\n try {\n console.log(\"[Anthropic Provider] Processing messages:\", anthropicMessages.length, \"messages\")\n\n let chunkCount = 0\n let totalContent = \"\"\n\n // Stream the response\n const stream = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: anthropicMessages,\n stream: true,\n })\n\n for await (const chunk of stream) {\n if (chunk.type === \"content_block_delta\" && chunk.delta.type === \"text_delta\") {\n chunkCount++\n const chunkText = chunk.delta.text || \"\"\n totalContent += chunkText\n\n // Format as SSE data\n const data = JSON.stringify({\n choices: [\n {\n delta: {\n content: chunkText,\n },\n },\n ],\n })\n controller.enqueue(new TextEncoder().encode(`data: ${data}\\n\\n`))\n }\n }\n\n console.log(\n `[Anthropic Provider] Streamed ${chunkCount} chunks, total length: ${totalContent.length} chars`,\n )\n\n // Send the final done message\n controller.enqueue(new TextEncoder().encode(\"data: [DONE]\\n\\n\"))\n controller.close()\n console.log(\"[Anthropic Provider] Streaming completed successfully\")\n } catch (error) {\n console.error(\"[Anthropic Provider] Streaming error:\", error)\n controller.error(error)\n }\n },\n })\n\n // Create a Response object with the stream\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n },\n })\n },\n }\n}\n\nmodule.exports = {\n AnthropicProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};\n"], ["/glass/src/features/common/services/firebaseClient.js", "const { initializeApp } = require('firebase/app');\nconst { initializeAuth } = require('firebase/auth');\nconst Store = require('electron-store');\nconst { getFirestore, setLogLevel } = require('firebase/firestore');\n\n// setLogLevel('debug');\n\n/**\n * Firebase Auth expects the `persistence` option passed to `initializeAuth()` to be *classes*,\n * not instances. It then calls `new PersistenceClass()` internally. \n *\n * The helper below returns such a class, pre-configured with an `electron-store` instance that\n * will be shared across all constructed objects. This mirrors the pattern used by Firebase's own\n * `browserLocalPersistence` implementation as well as community solutions for NodeJS.\n */\nfunction createElectronStorePersistence(storeName = 'firebase-auth-session') {\n // Create a single `electron-store` behind the scenes – all Persistence instances will use it.\n const sharedStore = new Store({ name: storeName });\n\n return class ElectronStorePersistence {\n constructor() {\n this.store = sharedStore;\n this.type = 'LOCAL';\n }\n\n /**\n * Firebase calls this to check whether the persistence is usable in the current context.\n */\n _isAvailable() {\n return Promise.resolve(true);\n }\n\n async _set(key, value) {\n this.store.set(key, value);\n }\n\n async _get(key) {\n return this.store.get(key) ?? null;\n }\n\n async _remove(key) {\n this.store.delete(key);\n }\n\n /**\n * These are used by Firebase to react to external storage events (e.g. multi-tab).\n * Electron apps are single-renderer per process, so we can safely provide no-op\n * implementations.\n */\n _addListener(_key, _listener) {\n // no-op\n }\n\n _removeListener(_key, _listener) {\n // no-op\n }\n };\n}\n\nconst firebaseConfig = {\n apiKey: 'AIzaSyAgtJrmsFWG1C7m9S55HyT1laICEzuUS2g',\n authDomain: 'pickle-3651a.firebaseapp.com',\n projectId: 'pickle-3651a',\n storageBucket: 'pickle-3651a.firebasestorage.app',\n messagingSenderId: '904706892885',\n appId: '1:904706892885:web:0e42b3dda796674ead20dc',\n measurementId: 'G-SQ0WM6S28T',\n};\n\nlet firebaseApp = null;\nlet firebaseAuth = null;\nlet firestoreInstance = null; // To hold the specific DB instance\n\nfunction initializeFirebase() {\n if (firebaseApp) {\n console.log('[FirebaseClient] Firebase already initialized.');\n return;\n }\n try {\n firebaseApp = initializeApp(firebaseConfig);\n \n // Build a *class* persistence provider and hand it to Firebase.\n const ElectronStorePersistence = createElectronStorePersistence('firebase-auth-session');\n\n firebaseAuth = initializeAuth(firebaseApp, {\n // `initializeAuth` accepts a single class or an array – we pass an array for future\n // extensibility and to match Firebase examples.\n persistence: [ElectronStorePersistence],\n });\n\n // Initialize Firestore with the specific database ID\n firestoreInstance = getFirestore(firebaseApp, 'pickle-glass');\n\n console.log('[FirebaseClient] Firebase initialized successfully with class-based electron-store persistence.');\n console.log('[FirebaseClient] Firestore instance is targeting the \"pickle-glass\" database.');\n } catch (error) {\n console.error('[FirebaseClient] Firebase initialization failed:', error);\n }\n}\n\nfunction getFirebaseAuth() {\n if (!firebaseAuth) {\n throw new Error(\"Firebase Auth has not been initialized. Call initializeFirebase() first.\");\n }\n return firebaseAuth;\n}\n\nfunction getFirestoreInstance() {\n if (!firestoreInstance) {\n throw new Error(\"Firestore has not been initialized. Call initializeFirebase() first.\");\n }\n return firestoreInstance;\n}\n\nmodule.exports = {\n initializeFirebase,\n getFirebaseAuth,\n getFirestoreInstance,\n}; "], ["/glass/src/window/smoothMovementManager.js", "const { screen } = require('electron');\n\nclass SmoothMovementManager {\n constructor(windowPool) {\n this.windowPool = windowPool;\n this.stepSize = 80;\n this.animationDuration = 300;\n this.headerPosition = { x: 0, y: 0 };\n this.isAnimating = false;\n this.hiddenPosition = null;\n this.lastVisiblePosition = null;\n this.currentDisplayId = null;\n this.animationFrameId = null;\n\n this.animationTimers = new Map();\n }\n\n /**\n * @param {BrowserWindow} win\n * @returns {boolean}\n */\n _isWindowValid(win) {\n if (!win || win.isDestroyed()) {\n // 해당 창의 타이머가 있으면 정리\n if (this.animationTimers.has(win)) {\n clearTimeout(this.animationTimers.get(win));\n this.animationTimers.delete(win);\n }\n return false;\n }\n return true;\n }\n\n /**\n * \n * @param {BrowserWindow} win\n * @param {number} targetX\n * @param {number} targetY\n * @param {object} [options]\n * @param {object} [options.sizeOverride]\n * @param {function} [options.onComplete]\n * @param {number} [options.duration]\n */\n animateWindow(win, targetX, targetY, options = {}) {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n\n const { sizeOverride, onComplete, duration: animDuration } = options;\n const start = win.getBounds();\n const startTime = Date.now();\n const duration = animDuration || this.animationDuration;\n const { width, height } = sizeOverride || start;\n\n const step = () => {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete();\n return;\n }\n\n const p = Math.min((Date.now() - startTime) / duration, 1);\n const eased = 1 - Math.pow(1 - p, 3); // ease-out-cubic\n const x = start.x + (targetX - start.x) * eased;\n const y = start.y + (targetY - start.y) * eased;\n\n win.setBounds({ x: Math.round(x), y: Math.round(y), width, height });\n\n if (p < 1) {\n setTimeout(step, 8);\n } else {\n this.layoutManager.updateLayout();\n if (onComplete) {\n onComplete();\n }\n }\n };\n step();\n }\n\n fade(win, { from, to, duration = 250, onComplete }) {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete();\n return;\n }\n const startOpacity = from ?? win.getOpacity();\n const startTime = Date.now();\n \n const step = () => {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete(); return;\n }\n const progress = Math.min(1, (Date.now() - startTime) / duration);\n const eased = 1 - Math.pow(1 - progress, 3);\n win.setOpacity(startOpacity + (to - startOpacity) * eased);\n \n if (progress < 1) {\n setTimeout(step, 8);\n } else {\n win.setOpacity(to);\n if (onComplete) onComplete();\n }\n };\n step();\n }\n \n animateWindowBounds(win, targetBounds, options = {}) {\n if (this.animationTimers.has(win)) {\n clearTimeout(this.animationTimers.get(win));\n }\n\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n\n this.isAnimating = true;\n\n const startBounds = win.getBounds();\n const startTime = Date.now();\n const duration = options.duration || this.animationDuration;\n \n const step = () => {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n \n const progress = Math.min(1, (Date.now() - startTime) / duration);\n const eased = 1 - Math.pow(1 - progress, 3);\n \n const newBounds = {\n x: Math.round(startBounds.x + (targetBounds.x - startBounds.x) * eased),\n y: Math.round(startBounds.y + (targetBounds.y - startBounds.y) * eased),\n width: Math.round(startBounds.width + ((targetBounds.width ?? startBounds.width) - startBounds.width) * eased),\n height: Math.round(startBounds.height + ((targetBounds.height ?? startBounds.height) - startBounds.height) * eased),\n };\n win.setBounds(newBounds);\n \n if (progress < 1) {\n const timerId = setTimeout(step, 8);\n this.animationTimers.set(win, timerId);\n } else {\n win.setBounds(targetBounds);\n this.animationTimers.delete(win);\n \n if (this.animationTimers.size === 0) {\n this.isAnimating = false;\n }\n \n if (options.onComplete) options.onComplete();\n }\n };\n step();\n }\n \n animateWindowPosition(win, targetPosition, options = {}) {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n const currentBounds = win.getBounds();\n const targetBounds = { ...currentBounds, ...targetPosition };\n this.animateWindowBounds(win, targetBounds, options);\n }\n \n animateLayout(layout, animated = true) {\n if (!layout) return;\n for (const winName in layout) {\n const win = this.windowPool.get(winName);\n const targetBounds = layout[winName];\n if (win && !win.isDestroyed() && targetBounds) {\n if (animated) {\n this.animateWindowBounds(win, targetBounds);\n } else {\n win.setBounds(targetBounds);\n }\n }\n }\n }\n\n destroy() {\n if (this.animationFrameId) {\n clearTimeout(this.animationFrameId);\n this.animationFrameId = null;\n }\n this.isAnimating = false;\n console.log('[Movement] Manager destroyed');\n }\n}\n\nmodule.exports = SmoothMovementManager;\n"], ["/glass/src/features/common/services/encryptionService.js", "const crypto = require('crypto');\nlet keytar;\n\n// Dynamically import keytar, as it's an optional dependency.\ntry {\n keytar = require('keytar');\n} catch (error) {\n console.warn('[EncryptionService] keytar is not available. Will use in-memory key for this session. Restarting the app might be required for data persistence after login.');\n keytar = null;\n}\n\nconst permissionService = require('./permissionService');\n\nconst SERVICE_NAME = 'com.pickle.glass'; // A unique identifier for the app in the keychain\nlet sessionKey = null; // In-memory fallback key\n\nconst ALGORITHM = 'aes-256-gcm';\nconst IV_LENGTH = 16; // For AES, this is always 16\nconst AUTH_TAG_LENGTH = 16;\n\n\n/**\n * Initializes the encryption key for a given user.\n * It first tries to get the key from the OS keychain.\n * If that fails, it generates a new key.\n * If keytar is available, it saves the new key.\n * Otherwise, it uses an in-memory key for the session.\n *\n * @param {string} userId - The unique identifier for the user (e.g., Firebase UID).\n */\nasync function initializeKey(userId) {\n if (!userId) {\n throw new Error('A user ID must be provided to initialize the encryption key.');\n }\n\n let keyRetrieved = false;\n\n if (keytar) {\n try {\n let key = await keytar.getPassword(SERVICE_NAME, userId);\n if (!key) {\n console.log(`[EncryptionService] No key found for ${userId}. Creating a new one.`);\n key = crypto.randomBytes(32).toString('hex');\n await keytar.setPassword(SERVICE_NAME, userId, key);\n console.log(`[EncryptionService] New key securely stored in keychain for ${userId}.`);\n } else {\n console.log(`[EncryptionService] Encryption key successfully retrieved from keychain for ${userId}.`);\n keyRetrieved = true;\n }\n sessionKey = key;\n } catch (error) {\n console.error('[EncryptionService] keytar failed. Falling back to in-memory key for this session.', error);\n keytar = null; // Disable keytar for the rest of the session to avoid repeated errors\n sessionKey = crypto.randomBytes(32).toString('hex');\n }\n } else {\n // keytar is not available\n if (!sessionKey) {\n console.warn('[EncryptionService] Using in-memory session key. Data will not persist across restarts without keytar.');\n sessionKey = crypto.randomBytes(32).toString('hex');\n }\n }\n\n // Mark keychain completed in permissions DB if this is the first successful retrieval or storage\n try {\n await permissionService.markKeychainCompleted(userId);\n if (keyRetrieved) {\n console.log(`[EncryptionService] Keychain completion marked in DB for ${userId}.`);\n }\n } catch (permErr) {\n console.error('[EncryptionService] Failed to mark keychain completion:', permErr);\n }\n\n if (!sessionKey) {\n throw new Error('Failed to initialize encryption key.');\n }\n}\n\nfunction resetSessionKey() {\n sessionKey = null;\n}\n\n/**\n * Encrypts a given text using AES-256-GCM.\n * @param {string} text The text to encrypt.\n * @returns {string | null} The encrypted data, as a base64 string containing iv, authTag, and content, or the original value if it cannot be encrypted.\n */\nfunction encrypt(text) {\n if (!sessionKey) {\n console.error('[EncryptionService] Encryption key is not initialized. Cannot encrypt.');\n return text; // Return original if key is missing\n }\n if (text == null) { // checks for null or undefined\n return text;\n }\n\n try {\n const key = Buffer.from(sessionKey, 'hex');\n const iv = crypto.randomBytes(IV_LENGTH);\n const cipher = crypto.createCipheriv(ALGORITHM, key, iv);\n \n let encrypted = cipher.update(String(text), 'utf8', 'hex');\n encrypted += cipher.final('hex');\n \n const authTag = cipher.getAuthTag();\n\n // Prepend IV and AuthTag to the encrypted content, then encode as base64.\n return Buffer.concat([iv, authTag, Buffer.from(encrypted, 'hex')]).toString('base64');\n } catch (error) {\n console.error('[EncryptionService] Encryption failed:', error);\n return text; // Return original on error\n }\n}\n\n/**\n * Decrypts a given encrypted string.\n * @param {string} encryptedText The base64 encrypted text.\n * @returns {string | null} The decrypted text, or the original value if it cannot be decrypted.\n */\nfunction decrypt(encryptedText) {\n if (!sessionKey) {\n console.error('[EncryptionService] Encryption key is not initialized. Cannot decrypt.');\n return encryptedText; // Return original if key is missing\n }\n if (encryptedText == null || typeof encryptedText !== 'string') {\n return encryptedText;\n }\n\n try {\n const data = Buffer.from(encryptedText, 'base64');\n if (data.length < IV_LENGTH + AUTH_TAG_LENGTH) {\n // This is not a valid encrypted string, likely plain text.\n return encryptedText;\n }\n \n const key = Buffer.from(sessionKey, 'hex');\n const iv = data.slice(0, IV_LENGTH);\n const authTag = data.slice(IV_LENGTH, IV_LENGTH + AUTH_TAG_LENGTH);\n const encryptedContent = data.slice(IV_LENGTH + AUTH_TAG_LENGTH);\n\n const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);\n decipher.setAuthTag(authTag);\n \n let decrypted = decipher.update(encryptedContent, 'hex', 'utf8');\n decrypted += decipher.final('utf8');\n \n return decrypted;\n } catch (error) {\n // It's common for this to fail if the data is not encrypted (e.g., legacy data).\n // In that case, we return the original value.\n console.error('[EncryptionService] Decryption failed:', error);\n return encryptedText;\n }\n}\n\nfunction looksEncrypted(str) {\n if (!str || typeof str !== 'string') return false;\n // Base64 chars + optional '=' padding\n if (!/^[A-Za-z0-9+/]+={0,2}$/.test(str)) return false;\n try {\n const buf = Buffer.from(str, 'base64');\n // Our AES-GCM cipher text must be at least 32 bytes (IV 16 + TAG 16)\n return buf.length >= 32;\n } catch {\n return false;\n }\n}\n\nmodule.exports = {\n initializeKey,\n resetSessionKey,\n encrypt,\n decrypt,\n looksEncrypted,\n}; "], ["/glass/src/features/common/ai/providers/openai.js", "const OpenAI = require('openai');\nconst WebSocket = require('ws');\nconst { Portkey } = require('portkey-ai');\nconst { Readable } = require('stream');\nconst { getProviderForModel } = require('../factory.js');\n\n\nclass OpenAIProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string' || !key.startsWith('sk-')) {\n return { success: false, error: 'Invalid OpenAI API key format.' };\n }\n\n try {\n const response = await fetch('https://api.openai.com/v1/models', {\n headers: { 'Authorization': `Bearer ${key}` }\n });\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error?.message || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[OpenAIProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n\n/**\n * Creates an OpenAI STT session\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.language='en'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {Promise} STT session\n */\nasync function createSTT({ apiKey, language = 'en', callbacks = {}, usePortkey = false, portkeyVirtualKey, ...config }) {\n const keyType = usePortkey ? 'vKey' : 'apiKey';\n const key = usePortkey ? (portkeyVirtualKey || apiKey) : apiKey;\n\n const wsUrl = keyType === 'apiKey'\n ? 'wss://api.openai.com/v1/realtime?intent=transcription'\n : 'wss://api.portkey.ai/v1/realtime?intent=transcription';\n\n const headers = keyType === 'apiKey'\n ? {\n 'Authorization': `Bearer ${key}`,\n 'OpenAI-Beta': 'realtime=v1',\n }\n : {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': key,\n 'OpenAI-Beta': 'realtime=v1',\n };\n\n const ws = new WebSocket(wsUrl, { headers });\n\n return new Promise((resolve, reject) => {\n ws.onopen = () => {\n console.log(\"WebSocket session opened.\");\n\n const sessionConfig = {\n type: 'transcription_session.update',\n session: {\n input_audio_format: 'pcm16',\n input_audio_transcription: {\n model: 'gpt-4o-mini-transcribe',\n prompt: config.prompt || '',\n language: language || 'en'\n },\n turn_detection: {\n type: 'server_vad',\n threshold: 0.5,\n prefix_padding_ms: 200,\n silence_duration_ms: 100,\n },\n input_audio_noise_reduction: {\n type: 'near_field'\n }\n }\n };\n \n ws.send(JSON.stringify(sessionConfig));\n\n // Helper to periodically keep the websocket alive\n const keepAlive = () => {\n try {\n if (ws.readyState === WebSocket.OPEN) {\n // The ws library supports native ping frames which are ideal for heart-beats\n ws.ping();\n }\n } catch (err) {\n console.error('[OpenAI STT] keepAlive error:', err.message);\n }\n };\n\n resolve({\n sendRealtimeInput: (audioData) => {\n if (ws.readyState === WebSocket.OPEN) {\n const message = {\n type: 'input_audio_buffer.append',\n audio: audioData\n };\n ws.send(JSON.stringify(message));\n }\n },\n // Expose keepAlive so higher-level services can schedule heart-beats\n keepAlive,\n close: () => {\n if (ws.readyState === WebSocket.OPEN) {\n ws.send(JSON.stringify({ type: 'session.close' }));\n ws.onmessage = ws.onerror = () => {}; // 핸들러 제거\n ws.close(1000, 'Client initiated close.');\n }\n }\n });\n };\n\n ws.onmessage = (event) => {\n // ── 종료·하트비트 패킷 필터링 ──────────────────────────────\n if (!event.data || event.data === 'null' || event.data === '[DONE]') return;\n\n let msg;\n try { msg = JSON.parse(event.data); }\n catch { return; } // JSON 파싱 실패 무시\n\n if (!msg || typeof msg !== 'object') return;\n\n msg.provider = 'openai'; // ← 항상 명시\n callbacks.onmessage?.(msg);\n };\n\n ws.onerror = (error) => {\n console.error('WebSocket error:', error.message);\n if (callbacks && callbacks.onerror) {\n callbacks.onerror(error);\n }\n reject(error);\n };\n\n ws.onclose = (event) => {\n console.log(`WebSocket closed: ${event.code} ${event.reason}`);\n if (callbacks && callbacks.onclose) {\n callbacks.onclose(event);\n }\n };\n });\n}\n\n/**\n * Creates an OpenAI LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.model='gpt-4.1'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=2048] - Max tokens\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {object} LLM instance\n */\nfunction createLLM({ apiKey, model = 'gpt-4.1', temperature = 0.7, maxTokens = 2048, usePortkey = false, portkeyVirtualKey, ...config }) {\n const client = new OpenAI({ apiKey });\n \n const callApi = async (messages) => {\n if (!usePortkey) {\n const response = await client.chat.completions.create({\n model: model,\n messages: messages,\n temperature: temperature,\n max_tokens: maxTokens\n });\n return {\n content: response.choices[0].message.content.trim(),\n raw: response\n };\n } else {\n const fetchUrl = 'https://api.portkey.ai/v1/chat/completions';\n const response = await fetch(fetchUrl, {\n method: 'POST',\n headers: {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': portkeyVirtualKey || apiKey,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: model,\n messages,\n temperature,\n max_tokens: maxTokens,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Portkey API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n return {\n content: result.choices[0].message.content.trim(),\n raw: result\n };\n }\n };\n\n return {\n generateContent: async (parts) => {\n const messages = [];\n let systemPrompt = '';\n let userContent = [];\n \n for (const part of parts) {\n if (typeof part === 'string') {\n if (systemPrompt === '' && part.includes('You are')) {\n systemPrompt = part;\n } else {\n userContent.push({ type: 'text', text: part });\n }\n } else if (part.inlineData) {\n userContent.push({\n type: 'image_url',\n image_url: { url: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}` }\n });\n }\n }\n \n if (systemPrompt) messages.push({ role: 'system', content: systemPrompt });\n if (userContent.length > 0) messages.push({ role: 'user', content: userContent });\n \n const result = await callApi(messages);\n\n return {\n response: {\n text: () => result.content\n },\n raw: result.raw\n };\n },\n \n // For compatibility with chat-style interfaces\n chat: async (messages) => {\n return await callApi(messages);\n }\n };\n}\n\n/** \n * Creates an OpenAI streaming LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.model='gpt-4.1'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=2048] - Max tokens\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {object} Streaming LLM instance\n */\nfunction createStreamingLLM({ apiKey, model = 'gpt-4.1', temperature = 0.7, maxTokens = 2048, usePortkey = false, portkeyVirtualKey, ...config }) {\n return {\n streamChat: async (messages) => {\n const fetchUrl = usePortkey \n ? 'https://api.portkey.ai/v1/chat/completions'\n : 'https://api.openai.com/v1/chat/completions';\n \n const headers = usePortkey\n ? {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': portkeyVirtualKey || apiKey,\n 'Content-Type': 'application/json',\n }\n : {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n };\n\n const response = await fetch(fetchUrl, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n model: model,\n messages,\n temperature,\n max_tokens: maxTokens,\n stream: true,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`OpenAI API error: ${response.status} ${response.statusText}`);\n }\n\n return response;\n }\n };\n}\n\nmodule.exports = {\n OpenAIProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n}; "], ["/glass/src/features/common/services/authService.js", "const { onAuthStateChanged, signInWithCustomToken, signOut } = require('firebase/auth');\nconst { BrowserWindow, shell } = require('electron');\nconst { getFirebaseAuth } = require('./firebaseClient');\nconst fetch = require('node-fetch');\nconst encryptionService = require('./encryptionService');\nconst migrationService = require('./migrationService');\nconst sessionRepository = require('../repositories/session');\nconst providerSettingsRepository = require('../repositories/providerSettings');\nconst permissionService = require('./permissionService');\n\nasync function getVirtualKeyByEmail(email, idToken) {\n if (!idToken) {\n throw new Error('Firebase ID token is required for virtual key request');\n }\n\n const resp = await fetch('https://serverless-api-sf3o.vercel.app/api/virtual_key', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${idToken}`,\n },\n body: JSON.stringify({ email: email.trim().toLowerCase() }),\n redirect: 'follow',\n });\n\n const json = await resp.json().catch(() => ({}));\n if (!resp.ok) {\n console.error('[VK] API request failed:', json.message || 'Unknown error');\n throw new Error(json.message || `HTTP ${resp.status}: Virtual key request failed`);\n }\n\n const vKey = json?.data?.virtualKey || json?.data?.virtual_key || json?.data?.newVKey?.slug;\n\n if (!vKey) throw new Error('virtual key missing in response');\n return vKey;\n}\n\nclass AuthService {\n constructor() {\n this.currentUserId = 'default_user';\n this.currentUserMode = 'local'; // 'local' or 'firebase'\n this.currentUser = null;\n this.isInitialized = false;\n\n // This ensures the key is ready before any login/logout state change.\n this.initializationPromise = null;\n\n sessionRepository.setAuthService(this);\n }\n\n initialize() {\n if (this.isInitialized) return this.initializationPromise;\n\n this.initializationPromise = new Promise((resolve) => {\n const auth = getFirebaseAuth();\n onAuthStateChanged(auth, async (user) => {\n const previousUser = this.currentUser;\n\n if (user) {\n // User signed IN\n console.log(`[AuthService] Firebase user signed in:`, user.uid);\n this.currentUser = user;\n this.currentUserId = user.uid;\n this.currentUserMode = 'firebase';\n\n // Clean up any zombie sessions from a previous run for this user.\n await sessionRepository.endAllActiveSessions();\n\n // ** Initialize encryption key for the logged-in user if permissions are already granted **\n if (process.platform === 'darwin' && !(await permissionService.checkKeychainCompleted(this.currentUserId))) {\n console.warn('[AuthService] Keychain permission not yet completed for this user. Deferring key initialization.');\n } else {\n await encryptionService.initializeKey(user.uid);\n }\n\n // ** Check for and run data migration for the user **\n // No 'await' here, so it runs in the background without blocking startup.\n migrationService.checkAndRunMigration(user);\n\n // ***** CRITICAL: Wait for the virtual key and model state update to complete *****\n try {\n const idToken = await user.getIdToken(true);\n const virtualKey = await getVirtualKeyByEmail(user.email, idToken);\n\n if (global.modelStateService) {\n // The model state service now writes directly to the DB, no in-memory state.\n await global.modelStateService.setFirebaseVirtualKey(virtualKey);\n }\n console.log(`[AuthService] Virtual key for ${user.email} has been processed and state updated.`);\n\n } catch (error) {\n console.error('[AuthService] Failed to fetch or save virtual key:', error);\n // This is not critical enough to halt the login, but we should log it.\n }\n\n } else {\n // User signed OUT\n console.log(`[AuthService] No Firebase user.`);\n if (previousUser) {\n console.log(`[AuthService] Clearing API key for logged-out user: ${previousUser.uid}`);\n if (global.modelStateService) {\n // The model state service now writes directly to the DB.\n await global.modelStateService.setFirebaseVirtualKey(null);\n }\n }\n this.currentUser = null;\n this.currentUserId = 'default_user';\n this.currentUserMode = 'local';\n\n // End active sessions for the local/default user as well.\n await sessionRepository.endAllActiveSessions();\n\n encryptionService.resetSessionKey();\n }\n this.broadcastUserState();\n \n if (!this.isInitialized) {\n this.isInitialized = true;\n console.log('[AuthService] Initialized and resolved initialization promise.');\n resolve();\n }\n });\n });\n\n return this.initializationPromise;\n }\n\n async startFirebaseAuthFlow() {\n try {\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n const authUrl = `${webUrl}/login?mode=electron`;\n console.log(`[AuthService] Opening Firebase auth URL in browser: ${authUrl}`);\n await shell.openExternal(authUrl);\n return { success: true };\n } catch (error) {\n console.error('[AuthService] Failed to open Firebase auth URL:', error);\n return { success: false, error: error.message };\n }\n }\n\n async signInWithCustomToken(token) {\n const auth = getFirebaseAuth();\n try {\n const userCredential = await signInWithCustomToken(auth, token);\n console.log(`[AuthService] Successfully signed in with custom token for user:`, userCredential.user.uid);\n // onAuthStateChanged will handle the state update and broadcast\n } catch (error) {\n console.error('[AuthService] Error signing in with custom token:', error);\n throw error; // Re-throw to be handled by the caller\n }\n }\n\n async signOut() {\n const auth = getFirebaseAuth();\n try {\n // End all active sessions for the current user BEFORE signing out.\n await sessionRepository.endAllActiveSessions();\n\n await signOut(auth);\n console.log('[AuthService] User sign-out initiated successfully.');\n // onAuthStateChanged will handle the state update and broadcast,\n // which will also re-evaluate the API key status.\n } catch (error) {\n console.error('[AuthService] Error signing out:', error);\n }\n }\n \n broadcastUserState() {\n const userState = this.getCurrentUser();\n console.log('[AuthService] Broadcasting user state change:', userState);\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed() && win.webContents && !win.webContents.isDestroyed()) {\n win.webContents.send('user-state-changed', userState);\n }\n });\n }\n\n getCurrentUserId() {\n return this.currentUserId;\n }\n\n getCurrentUser() {\n const isLoggedIn = !!(this.currentUserMode === 'firebase' && this.currentUser);\n\n if (isLoggedIn) {\n return {\n uid: this.currentUser.uid,\n email: this.currentUser.email,\n displayName: this.currentUser.displayName,\n mode: 'firebase',\n isLoggedIn: true,\n //////// before_modelStateService ////////\n // hasApiKey: this.hasApiKey // Always true for firebase users, but good practice\n //////// before_modelStateService ////////\n };\n }\n return {\n uid: this.currentUserId, // returns 'default_user'\n email: 'contact@pickle.com',\n displayName: 'Default User',\n mode: 'local',\n isLoggedIn: false,\n //////// before_modelStateService ////////\n // hasApiKey: this.hasApiKey\n //////// before_modelStateService ////////\n };\n }\n}\n\nconst authService = new AuthService();\nmodule.exports = authService; "], ["/glass/src/features/common/services/sqliteClient.js", "const Database = require('better-sqlite3');\nconst path = require('path');\nconst LATEST_SCHEMA = require('../config/schema');\n\nclass SQLiteClient {\n constructor() {\n this.db = null;\n this.dbPath = null;\n this.defaultUserId = 'default_user';\n }\n\n connect(dbPath) {\n if (this.db) {\n console.log('[SQLiteClient] Already connected.');\n return;\n }\n\n try {\n this.dbPath = dbPath;\n this.db = new Database(this.dbPath);\n this.db.pragma('journal_mode = WAL');\n console.log('[SQLiteClient] Connected successfully to:', this.dbPath);\n } catch (err) {\n console.error('[SQLiteClient] Could not connect to database', err);\n throw err;\n }\n }\n\n getDb() {\n if (!this.db) {\n throw new Error(\"Database not connected. Call connect() first.\");\n }\n return this.db;\n }\n\n _validateAndQuoteIdentifier(identifier) {\n if (!/^[a-zA-Z0-9_]+$/.test(identifier)) {\n throw new Error(`Invalid database identifier used: ${identifier}. Only alphanumeric characters and underscores are allowed.`);\n }\n return `\"${identifier}\"`;\n }\n\n _migrateProviderSettings() {\n const tablesInDb = this.getTablesFromDb();\n if (!tablesInDb.includes('provider_settings')) {\n return; // Table doesn't exist, no migration needed.\n }\n \n const providerSettingsInfo = this.db.prepare(`PRAGMA table_info(provider_settings)`).all();\n const hasUidColumn = providerSettingsInfo.some(col => col.name === 'uid');\n \n if (hasUidColumn) {\n console.log('[DB Migration] Old provider_settings schema detected. Starting robust migration...');\n \n try {\n this.db.transaction(() => {\n this.db.exec('ALTER TABLE provider_settings RENAME TO provider_settings_old');\n console.log('[DB Migration] Renamed provider_settings to provider_settings_old');\n \n this.createTable('provider_settings', LATEST_SCHEMA.provider_settings);\n console.log('[DB Migration] Created new provider_settings table');\n \n // Dynamically build the migration query for robustness\n const oldColumnNames = this.db.prepare(`PRAGMA table_info(provider_settings_old)`).all().map(c => c.name);\n const newColumnNames = LATEST_SCHEMA.provider_settings.columns.map(c => c.name);\n const commonColumns = newColumnNames.filter(name => oldColumnNames.includes(name));\n \n if (!commonColumns.includes('provider')) {\n console.warn('[DB Migration] Old table is missing the \"provider\" column. Aborting migration for this table.');\n this.db.exec('DROP TABLE provider_settings_old');\n return;\n }\n \n const orderParts = [];\n if (oldColumnNames.includes('updated_at')) orderParts.push('updated_at DESC');\n if (oldColumnNames.includes('created_at')) orderParts.push('created_at DESC');\n const orderByClause = orderParts.length > 0 ? `ORDER BY ${orderParts.join(', ')}` : '';\n \n const columnsForInsert = commonColumns.map(c => this._validateAndQuoteIdentifier(c)).join(', ');\n \n const migrationQuery = `\n INSERT INTO provider_settings (${columnsForInsert})\n SELECT ${columnsForInsert}\n FROM (\n SELECT *, ROW_NUMBER() OVER(PARTITION BY provider ${orderByClause}) as rn\n FROM provider_settings_old\n )\n WHERE rn = 1\n `;\n \n console.log(`[DB Migration] Executing robust migration query for columns: ${commonColumns.join(', ')}`);\n const result = this.db.prepare(migrationQuery).run();\n console.log(`[DB Migration] Migrated ${result.changes} rows to the new provider_settings table.`);\n \n this.db.exec('DROP TABLE provider_settings_old');\n console.log('[DB Migration] Dropped provider_settings_old table.');\n })();\n console.log('[DB Migration] provider_settings migration completed successfully.');\n } catch (error) {\n console.error('[DB Migration] Failed to migrate provider_settings table.', error);\n \n // Try to recover by dropping the temp table if it exists\n const oldTableExists = this.getTablesFromDb().includes('provider_settings_old');\n if (oldTableExists) {\n this.db.exec('DROP TABLE provider_settings_old');\n console.warn('[DB Migration] Cleaned up temporary old table after failure.');\n }\n throw error;\n }\n }\n }\n\n async synchronizeSchema() {\n console.log('[DB Sync] Starting schema synchronization...');\n\n // Run special migration for provider_settings before the generic sync logic\n this._migrateProviderSettings();\n\n const tablesInDb = this.getTablesFromDb();\n\n for (const tableName of Object.keys(LATEST_SCHEMA)) {\n const tableSchema = LATEST_SCHEMA[tableName];\n\n if (!tablesInDb.includes(tableName)) {\n // Table doesn't exist, create it\n this.createTable(tableName, tableSchema);\n } else {\n // Table exists, check for missing columns\n this.updateTable(tableName, tableSchema);\n }\n }\n console.log('[DB Sync] Schema synchronization finished.');\n }\n\n getTablesFromDb() {\n const tables = this.db.prepare(\"SELECT name FROM sqlite_master WHERE type='table'\").all();\n return tables.map(t => t.name);\n }\n\n createTable(tableName, tableSchema) {\n const safeTableName = this._validateAndQuoteIdentifier(tableName);\n const columnDefs = tableSchema.columns\n .map(col => `${this._validateAndQuoteIdentifier(col.name)} ${col.type}`)\n .join(', ');\n \n const constraints = tableSchema.constraints || [];\n const constraintsDef = constraints.length > 0 ? ', ' + constraints.join(', ') : '';\n \n const query = `CREATE TABLE IF NOT EXISTS ${safeTableName} (${columnDefs}${constraintsDef})`;\n console.log(`[DB Sync] Creating table: ${tableName}`);\n this.db.exec(query);\n }\n\n updateTable(tableName, tableSchema) {\n const safeTableName = this._validateAndQuoteIdentifier(tableName);\n \n // Get current columns\n const currentColumns = this.db.prepare(`PRAGMA table_info(${safeTableName})`).all();\n const currentColumnNames = currentColumns.map(col => col.name);\n\n // Check for new columns to add\n const newColumns = tableSchema.columns.filter(col => !currentColumnNames.includes(col.name));\n\n if (newColumns.length > 0) {\n console.log(`[DB Sync] Adding ${newColumns.length} new column(s) to ${tableName}`);\n for (const col of newColumns) {\n const safeColName = this._validateAndQuoteIdentifier(col.name);\n const addColumnQuery = `ALTER TABLE ${safeTableName} ADD COLUMN ${safeColName} ${col.type}`;\n this.db.exec(addColumnQuery);\n console.log(`[DB Sync] Added column ${col.name} to ${tableName}`);\n }\n }\n\n if (tableSchema.constraints && tableSchema.constraints.length > 0) {\n console.log(`[DB Sync] Note: Constraints for ${tableName} can only be set during table creation`);\n }\n }\n\n runQuery(query, params = []) {\n return this.db.prepare(query).run(params);\n }\n\n cleanupEmptySessions() {\n console.log('[DB Cleanup] Checking for empty sessions...');\n const query = `\n SELECT s.id FROM sessions s\n LEFT JOIN transcripts t ON s.id = t.session_id\n LEFT JOIN ai_messages a ON s.id = a.session_id\n LEFT JOIN summaries su ON s.id = su.session_id\n WHERE t.id IS NULL AND a.id IS NULL AND su.session_id IS NULL\n `;\n\n const rows = this.db.prepare(query).all();\n\n if (rows.length === 0) {\n console.log('[DB Cleanup] No empty sessions found.');\n return;\n }\n\n const idsToDelete = rows.map(r => r.id);\n const placeholders = idsToDelete.map(() => '?').join(',');\n const deleteQuery = `DELETE FROM sessions WHERE id IN (${placeholders})`;\n\n console.log(`[DB Cleanup] Found ${idsToDelete.length} empty sessions. Deleting...`);\n const result = this.db.prepare(deleteQuery).run(idsToDelete);\n console.log(`[DB Cleanup] Successfully deleted ${result.changes} empty sessions.`);\n }\n\n async initTables() {\n await this.synchronizeSchema();\n this.initDefaultData();\n }\n\n initDefaultData() {\n const now = Math.floor(Date.now() / 1000);\n const initUserQuery = `\n INSERT OR IGNORE INTO users (uid, display_name, email, created_at)\n VALUES (?, ?, ?, ?)\n `;\n\n this.db.prepare(initUserQuery).run(this.defaultUserId, 'Default User', 'contact@pickle.com', now);\n\n const defaultPresets = [\n ['school', 'School', 'You are a school and lecture assistant. Your goal is to help the user, a student, understand academic material and answer questions.\\n\\nWhenever a question appears on the user\\'s screen or is asked aloud, you provide a direct, step-by-step answer, showing all necessary reasoning or calculations.\\n\\nIf the user is watching a lecture or working through new material, you offer concise explanations of key concepts and clarify definitions as they come up.', 1],\n ['meetings', 'Meetings', 'You are a meeting assistant. Your goal is to help the user capture key information during meetings and follow up effectively.\\n\\nYou help capture meeting notes, track action items, identify key decisions, and summarize important points discussed during meetings.', 1],\n ['sales', 'Sales', 'You are a real-time AI sales assistant, and your goal is to help the user close deals during sales interactions.\\n\\nYou provide real-time sales support, suggest responses to objections, help identify customer needs, and recommend strategies to advance deals.', 1],\n ['recruiting', 'Recruiting', 'You are a recruiting assistant. Your goal is to help the user interview candidates and evaluate talent effectively.\\n\\nYou help evaluate candidates, suggest interview questions, analyze responses, and provide insights about candidate fit for positions.', 1],\n ['customer-support', 'Customer Support', 'You are a customer support assistant. Your goal is to help resolve customer issues efficiently and thoroughly.\\n\\nYou help diagnose customer problems, suggest solutions, provide step-by-step troubleshooting guidance, and ensure customer satisfaction.', 1],\n ];\n\n const stmt = this.db.prepare(`\n INSERT OR IGNORE INTO prompt_presets (id, uid, title, prompt, is_default, created_at)\n VALUES (?, ?, ?, ?, ?, ?)\n `);\n\n for (const preset of defaultPresets) {\n stmt.run(preset[0], this.defaultUserId, preset[1], preset[2], preset[3], now);\n }\n\n console.log('Default data initialized.');\n }\n\n close() {\n if (this.db) {\n try {\n this.db.close();\n console.log('SQLite connection closed.');\n } catch (err) {\n console.error('SQLite connection close failed:', err);\n }\n this.db = null;\n }\n }\n\n query(sql, params = []) {\n if (!this.db) {\n throw new Error('Database not connected');\n }\n\n try {\n if (sql.toUpperCase().startsWith('SELECT')) {\n return this.db.prepare(sql).all(params);\n } else {\n const result = this.db.prepare(sql).run(params);\n return { changes: result.changes, lastID: result.lastID };\n }\n } catch (err) {\n console.error('Query error:', err);\n throw err;\n }\n }\n}\n\nconst sqliteClient = new SQLiteClient();\nmodule.exports = sqliteClient; "], ["/glass/src/features/common/ai/providers/ollama.js", "const http = require('http');\nconst fetch = require('node-fetch');\n\n// Request Queue System for Ollama API (only for non-streaming requests)\nclass RequestQueue {\n constructor() {\n this.queue = [];\n this.processing = false;\n this.streamingActive = false;\n }\n\n async addStreamingRequest(requestFn) {\n // Streaming requests have priority - wait for current processing to finish\n while (this.processing) {\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n \n this.streamingActive = true;\n console.log('[Ollama Queue] Starting streaming request (priority)');\n \n try {\n const result = await requestFn();\n return result;\n } finally {\n this.streamingActive = false;\n console.log('[Ollama Queue] Streaming request completed');\n }\n }\n\n async add(requestFn) {\n return new Promise((resolve, reject) => {\n this.queue.push({ requestFn, resolve, reject });\n this.process();\n });\n }\n\n async process() {\n if (this.processing || this.queue.length === 0) {\n return;\n }\n\n // Wait if streaming is active\n if (this.streamingActive) {\n setTimeout(() => this.process(), 100);\n return;\n }\n\n this.processing = true;\n\n while (this.queue.length > 0) {\n // Check if streaming started while processing queue\n if (this.streamingActive) {\n this.processing = false;\n setTimeout(() => this.process(), 100);\n return;\n }\n\n const { requestFn, resolve, reject } = this.queue.shift();\n \n try {\n console.log(`[Ollama Queue] Processing queued request (${this.queue.length} remaining)`);\n const result = await requestFn();\n resolve(result);\n } catch (error) {\n console.error('[Ollama Queue] Request failed:', error);\n reject(error);\n }\n }\n\n this.processing = false;\n }\n}\n\n// Global request queue instance\nconst requestQueue = new RequestQueue();\n\nclass OllamaProvider {\n static async validateApiKey() {\n try {\n const response = await fetch('http://localhost:11434/api/tags');\n if (response.ok) {\n return { success: true };\n } else {\n return { success: false, error: 'Ollama service is not running. Please start Ollama first.' };\n }\n } catch (error) {\n return { success: false, error: 'Cannot connect to Ollama. Please ensure Ollama is installed and running.' };\n }\n }\n}\n\n\nfunction convertMessagesToOllamaFormat(messages) {\n return messages.map(msg => {\n if (Array.isArray(msg.content)) {\n let textContent = '';\n const images = [];\n \n for (const part of msg.content) {\n if (part.type === 'text') {\n textContent += part.text;\n } else if (part.type === 'image_url') {\n const base64 = part.image_url.url.replace(/^data:image\\/[^;]+;base64,/, '');\n images.push(base64);\n }\n }\n \n return {\n role: msg.role,\n content: textContent,\n ...(images.length > 0 && { images })\n };\n } else {\n return msg;\n }\n });\n}\n\nfunction createLLM({ \n model, \n temperature = 0.7, \n maxTokens = 2048, \n baseUrl = 'http://localhost:11434',\n ...config \n}) {\n if (!model) {\n throw new Error('Model parameter is required for Ollama LLM. Please specify a model name (e.g., \"llama3.2:latest\", \"gemma3:4b\")');\n }\n return {\n generateContent: async (parts) => {\n let systemPrompt = '';\n const userContent = [];\n\n for (const part of parts) {\n if (typeof part === 'string') {\n if (systemPrompt === '' && part.includes('You are')) {\n systemPrompt = part;\n } else {\n userContent.push(part);\n }\n } else if (part.inlineData) {\n userContent.push({\n type: 'image',\n image: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`\n });\n }\n }\n\n const messages = [];\n if (systemPrompt) {\n messages.push({ role: 'system', content: systemPrompt });\n }\n messages.push({ role: 'user', content: userContent.join('\\n') });\n\n // Use request queue to prevent concurrent API calls\n return await requestQueue.add(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages,\n stream: false,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n \n return {\n response: {\n text: () => result.message.content\n },\n raw: result\n };\n } catch (error) {\n console.error('Ollama LLM error:', error);\n throw error;\n }\n });\n },\n\n chat: async (messages) => {\n const ollamaMessages = convertMessagesToOllamaFormat(messages);\n\n // Use request queue to prevent concurrent API calls\n return await requestQueue.add(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages: ollamaMessages,\n stream: false,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n \n return {\n content: result.message.content,\n raw: result\n };\n } catch (error) {\n console.error('Ollama chat error:', error);\n throw error;\n }\n });\n }\n };\n}\n\nfunction createStreamingLLM({ \n model, \n temperature = 0.7, \n maxTokens = 2048, \n baseUrl = 'http://localhost:11434',\n ...config \n}) {\n if (!model) {\n throw new Error('Model parameter is required for Ollama streaming LLM. Please specify a model name (e.g., \"llama3.2:latest\", \"gemma3:4b\")');\n }\n return {\n streamChat: async (messages) => {\n console.log('[Ollama Provider] Starting streaming request');\n\n const ollamaMessages = convertMessagesToOllamaFormat(messages);\n console.log('[Ollama Provider] Converted messages for Ollama:', ollamaMessages);\n\n // Streaming requests have priority over queued requests\n return await requestQueue.addStreamingRequest(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages: ollamaMessages,\n stream: true,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n console.log('[Ollama Provider] Got streaming response');\n\n const stream = new ReadableStream({\n async start(controller) {\n let buffer = '';\n\n try {\n response.body.on('data', (chunk) => {\n buffer += chunk.toString();\n const lines = buffer.split('\\n');\n buffer = lines.pop() || '';\n\n for (const line of lines) {\n if (line.trim() === '') continue;\n \n try {\n const data = JSON.parse(line);\n \n if (data.message?.content) {\n const sseData = JSON.stringify({\n choices: [{\n delta: {\n content: data.message.content\n }\n }]\n });\n controller.enqueue(new TextEncoder().encode(`data: ${sseData}\\n\\n`));\n }\n \n if (data.done) {\n controller.enqueue(new TextEncoder().encode('data: [DONE]\\n\\n'));\n }\n } catch (e) {\n console.error('[Ollama Provider] Failed to parse chunk:', e);\n }\n }\n });\n\n response.body.on('end', () => {\n controller.close();\n console.log('[Ollama Provider] Streaming completed');\n });\n\n response.body.on('error', (error) => {\n console.error('[Ollama Provider] Streaming error:', error);\n controller.error(error);\n });\n \n } catch (error) {\n console.error('[Ollama Provider] Streaming setup error:', error);\n controller.error(error);\n }\n }\n });\n\n return {\n ok: true,\n body: stream\n };\n \n } catch (error) {\n console.error('[Ollama Provider] Request error:', error);\n throw error;\n }\n });\n }\n };\n}\n\nmodule.exports = {\n OllamaProvider,\n createLLM,\n createStreamingLLM,\n convertMessagesToOllamaFormat\n}; "], ["/glass/src/features/common/services/migrationService.js", "const { doc, writeBatch, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../services/firebaseClient');\nconst encryptionService = require('../services/encryptionService');\n\nconst sqliteSessionRepo = require('../repositories/session/sqlite.repository');\nconst sqlitePresetRepo = require('../repositories/preset/sqlite.repository');\nconst sqliteUserRepo = require('../repositories/user/sqlite.repository');\nconst sqliteSttRepo = require('../../listen/stt/repositories/sqlite.repository');\nconst sqliteSummaryRepo = require('../../listen/summary/repositories/sqlite.repository');\nconst sqliteAiMessageRepo = require('../../ask/repositories/sqlite.repository');\n\nconst MAX_BATCH_OPERATIONS = 500;\n\nasync function checkAndRunMigration(firebaseUser) {\n if (!firebaseUser || !firebaseUser.uid) {\n console.log('[Migration] No user, skipping migration check.');\n return;\n }\n\n console.log(`[Migration] Checking for user ${firebaseUser.uid}...`);\n\n const localUser = sqliteUserRepo.getById(firebaseUser.uid);\n if (!localUser || localUser.has_migrated_to_firebase) {\n console.log(`[Migration] User ${firebaseUser.uid} is not eligible or already migrated.`);\n return;\n }\n\n console.log(`[Migration] Starting data migration for user ${firebaseUser.uid}...`);\n \n try {\n const db = getFirestoreInstance();\n \n // --- Phase 1: Migrate Parent Documents (Presets & Sessions) ---\n console.log('[Migration Phase 1] Migrating parent documents...');\n let phase1Batch = writeBatch(db);\n let phase1OpCount = 0;\n const phase1Promises = [];\n \n const localPresets = (await sqlitePresetRepo.getPresets(firebaseUser.uid)).filter(p => !p.is_default);\n console.log(`[Migration Phase 1] Found ${localPresets.length} custom presets.`);\n for (const preset of localPresets) {\n const presetRef = doc(db, 'prompt_presets', preset.id);\n const cleanPreset = {\n uid: preset.uid,\n title: encryptionService.encrypt(preset.title ?? ''),\n prompt: encryptionService.encrypt(preset.prompt ?? ''),\n is_default: preset.is_default ?? 0,\n created_at: preset.created_at ? Timestamp.fromMillis(preset.created_at * 1000) : null,\n updated_at: preset.updated_at ? Timestamp.fromMillis(preset.updated_at * 1000) : null\n };\n phase1Batch.set(presetRef, cleanPreset);\n phase1OpCount++;\n if (phase1OpCount >= MAX_BATCH_OPERATIONS) {\n phase1Promises.push(phase1Batch.commit());\n phase1Batch = writeBatch(db);\n phase1OpCount = 0;\n }\n }\n \n const localSessions = await sqliteSessionRepo.getAllByUserId(firebaseUser.uid);\n console.log(`[Migration Phase 1] Found ${localSessions.length} sessions.`);\n for (const session of localSessions) {\n const sessionRef = doc(db, 'sessions', session.id);\n const cleanSession = {\n uid: session.uid,\n members: session.members ?? [session.uid],\n title: encryptionService.encrypt(session.title ?? ''),\n session_type: session.session_type ?? 'ask',\n started_at: session.started_at ? Timestamp.fromMillis(session.started_at * 1000) : null,\n ended_at: session.ended_at ? Timestamp.fromMillis(session.ended_at * 1000) : null,\n updated_at: session.updated_at ? Timestamp.fromMillis(session.updated_at * 1000) : null\n };\n phase1Batch.set(sessionRef, cleanSession);\n phase1OpCount++;\n if (phase1OpCount >= MAX_BATCH_OPERATIONS) {\n phase1Promises.push(phase1Batch.commit());\n phase1Batch = writeBatch(db);\n phase1OpCount = 0;\n }\n }\n \n if (phase1OpCount > 0) {\n phase1Promises.push(phase1Batch.commit());\n }\n \n if (phase1Promises.length > 0) {\n await Promise.all(phase1Promises);\n console.log(`[Migration Phase 1] Successfully committed ${phase1Promises.length} batches of parent documents.`);\n } else {\n console.log('[Migration Phase 1] No parent documents to migrate.');\n }\n\n // --- Phase 2: Migrate Child Documents (sub-collections) ---\n console.log('[Migration Phase 2] Migrating child documents for all sessions...');\n let phase2Batch = writeBatch(db);\n let phase2OpCount = 0;\n const phase2Promises = [];\n\n for (const session of localSessions) {\n const transcripts = await sqliteSttRepo.getAllTranscriptsBySessionId(session.id);\n for (const t of transcripts) {\n const transcriptRef = doc(db, `sessions/${session.id}/transcripts`, t.id);\n const cleanTranscript = {\n uid: firebaseUser.uid,\n session_id: t.session_id,\n start_at: t.start_at ? Timestamp.fromMillis(t.start_at * 1000) : null,\n end_at: t.end_at ? Timestamp.fromMillis(t.end_at * 1000) : null,\n speaker: t.speaker ?? null,\n text: encryptionService.encrypt(t.text ?? ''),\n lang: t.lang ?? 'en',\n created_at: t.created_at ? Timestamp.fromMillis(t.created_at * 1000) : null\n };\n phase2Batch.set(transcriptRef, cleanTranscript);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n\n const messages = await sqliteAiMessageRepo.getAllAiMessagesBySessionId(session.id);\n for (const m of messages) {\n const msgRef = doc(db, `sessions/${session.id}/ai_messages`, m.id);\n const cleanMessage = {\n uid: firebaseUser.uid,\n session_id: m.session_id,\n sent_at: m.sent_at ? Timestamp.fromMillis(m.sent_at * 1000) : null,\n role: m.role ?? 'user',\n content: encryptionService.encrypt(m.content ?? ''),\n tokens: m.tokens ?? null,\n model: m.model ?? 'unknown',\n created_at: m.created_at ? Timestamp.fromMillis(m.created_at * 1000) : null\n };\n phase2Batch.set(msgRef, cleanMessage);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n\n const summary = await sqliteSummaryRepo.getSummaryBySessionId(session.id);\n if (summary) {\n // Reverting to use 'data' as the document ID for summary.\n const summaryRef = doc(db, `sessions/${session.id}/summary`, 'data');\n const cleanSummary = {\n uid: firebaseUser.uid,\n session_id: summary.session_id,\n generated_at: summary.generated_at ? Timestamp.fromMillis(summary.generated_at * 1000) : null,\n model: summary.model ?? 'unknown',\n tldr: encryptionService.encrypt(summary.tldr ?? ''),\n text: encryptionService.encrypt(summary.text ?? ''),\n bullet_json: encryptionService.encrypt(summary.bullet_json ?? '[]'),\n action_json: encryptionService.encrypt(summary.action_json ?? '[]'),\n tokens_used: summary.tokens_used ?? null,\n updated_at: summary.updated_at ? Timestamp.fromMillis(summary.updated_at * 1000) : null\n };\n phase2Batch.set(summaryRef, cleanSummary);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n }\n\n if (phase2OpCount > 0) {\n phase2Promises.push(phase2Batch.commit());\n }\n\n if (phase2Promises.length > 0) {\n await Promise.all(phase2Promises);\n console.log(`[Migration Phase 2] Successfully committed ${phase2Promises.length} batches of child documents.`);\n } else {\n console.log('[Migration Phase 2] No child documents to migrate.');\n }\n\n // --- 4. Mark migration as complete ---\n sqliteUserRepo.setMigrationComplete(firebaseUser.uid);\n console.log(`[Migration] ✅ Successfully marked migration as complete for ${firebaseUser.uid}.`);\n\n } catch (error) {\n console.error(`[Migration] 🔥 An error occurred during migration for user ${firebaseUser.uid}:`, error);\n }\n}\n\nmodule.exports = {\n checkAndRunMigration,\n}; "], ["/glass/src/features/common/ai/factory.js", "// factory.js\n\n/**\n * @typedef {object} ModelOption\n * @property {string} id \n * @property {string} name\n */\n\n/**\n * @typedef {object} Provider\n * @property {string} name\n * @property {() => any} handler\n * @property {ModelOption[]} llmModels\n * @property {ModelOption[]} sttModels\n */\n\n/**\n * @type {Object.}\n */\nconst PROVIDERS = {\n 'openai': {\n name: 'OpenAI',\n handler: () => require(\"./providers/openai\"),\n llmModels: [\n { id: 'gpt-4.1', name: 'GPT-4.1' },\n ],\n sttModels: [\n { id: 'gpt-4o-mini-transcribe', name: 'GPT-4o Mini Transcribe' }\n ],\n },\n\n 'openai-glass': {\n name: 'OpenAI (Glass)',\n handler: () => require(\"./providers/openai\"),\n llmModels: [\n { id: 'gpt-4.1-glass', name: 'GPT-4.1 (glass)' },\n ],\n sttModels: [\n { id: 'gpt-4o-mini-transcribe-glass', name: 'GPT-4o Mini Transcribe (glass)' }\n ],\n },\n 'gemini': {\n name: 'Gemini',\n handler: () => require(\"./providers/gemini\"),\n llmModels: [\n { id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash' },\n ],\n sttModels: [\n { id: 'gemini-live-2.5-flash-preview', name: 'Gemini Live 2.5 Flash' }\n ],\n },\n 'anthropic': {\n name: 'Anthropic',\n handler: () => require(\"./providers/anthropic\"),\n llmModels: [\n { id: 'claude-3-5-sonnet-20241022', name: 'Claude 3.5 Sonnet' },\n ],\n sttModels: [],\n },\n 'deepgram': {\n name: 'Deepgram',\n handler: () => require(\"./providers/deepgram\"),\n llmModels: [],\n sttModels: [\n { id: 'nova-3', name: 'Nova-3 (General)' },\n ],\n },\n 'ollama': {\n name: 'Ollama (Local)',\n handler: () => require(\"./providers/ollama\"),\n llmModels: [], // Dynamic models populated from installed Ollama models\n sttModels: [], // Ollama doesn't support STT yet\n },\n 'whisper': {\n name: 'Whisper (Local)',\n handler: () => {\n // This needs to remain a function due to its conditional logic for renderer/main process\n if (typeof window === 'undefined') {\n const { WhisperProvider } = require(\"./providers/whisper\");\n return new WhisperProvider();\n }\n // Return a dummy object for the renderer process\n return {\n validateApiKey: async () => ({ success: true }), // Mock validate for renderer\n createSTT: () => { throw new Error('Whisper STT is only available in main process'); },\n };\n },\n llmModels: [],\n sttModels: [\n { id: 'whisper-tiny', name: 'Whisper Tiny (39M)' },\n { id: 'whisper-base', name: 'Whisper Base (74M)' },\n { id: 'whisper-small', name: 'Whisper Small (244M)' },\n { id: 'whisper-medium', name: 'Whisper Medium (769M)' },\n ],\n },\n};\n\nfunction sanitizeModelId(model) {\n return (typeof model === 'string') ? model.replace(/-glass$/, '') : model;\n}\n\nfunction createSTT(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n \n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createSTT) {\n throw new Error(`STT not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createSTT(opts);\n}\n\nfunction createLLM(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n\n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createLLM) {\n throw new Error(`LLM not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createLLM(opts);\n}\n\nfunction createStreamingLLM(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n \n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createStreamingLLM) {\n throw new Error(`Streaming LLM not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createStreamingLLM(opts);\n}\n\nfunction getProviderClass(providerId) {\n const providerConfig = PROVIDERS[providerId];\n if (!providerConfig) return null;\n \n // Handle special cases for glass providers\n let actualProviderId = providerId;\n if (providerId === 'openai-glass') {\n actualProviderId = 'openai';\n }\n \n // The handler function returns the module, from which we get the class.\n const module = providerConfig.handler();\n \n // Map provider IDs to their actual exported class names\n const classNameMap = {\n 'openai': 'OpenAIProvider',\n 'anthropic': 'AnthropicProvider',\n 'gemini': 'GeminiProvider',\n 'deepgram': 'DeepgramProvider',\n 'ollama': 'OllamaProvider',\n 'whisper': 'WhisperProvider'\n };\n \n const className = classNameMap[actualProviderId];\n return className ? module[className] : null;\n}\n\nfunction getAvailableProviders() {\n const stt = [];\n const llm = [];\n for (const [id, provider] of Object.entries(PROVIDERS)) {\n if (provider.sttModels.length > 0) stt.push(id);\n if (provider.llmModels.length > 0) llm.push(id);\n }\n return { stt: [...new Set(stt)], llm: [...new Set(llm)] };\n}\n\nmodule.exports = {\n PROVIDERS,\n createSTT,\n createLLM,\n createStreamingLLM,\n getProviderClass,\n getAvailableProviders,\n};"], ["/glass/src/features/common/services/localAIManager.js", "const { EventEmitter } = require('events');\nconst ollamaService = require('./ollamaService');\nconst whisperService = require('./whisperService');\n\n\n//Central manager for managing Ollama and Whisper services \nclass LocalAIManager extends EventEmitter {\n constructor() {\n super();\n \n // service map\n this.services = {\n ollama: ollamaService,\n whisper: whisperService\n };\n \n // unified state management\n this.state = {\n ollama: {\n installed: false,\n running: false,\n models: []\n },\n whisper: {\n installed: false,\n initialized: false,\n models: []\n }\n };\n \n // setup event listeners\n this.setupEventListeners();\n }\n \n \n // subscribe to events from each service and re-emit as unified events\n setupEventListeners() {\n // ollama events\n ollamaService.on('install-progress', (data) => {\n this.emit('install-progress', 'ollama', data);\n });\n \n ollamaService.on('installation-complete', () => {\n this.emit('installation-complete', 'ollama');\n this.updateServiceState('ollama');\n });\n \n ollamaService.on('error', (error) => {\n this.emit('error', { service: 'ollama', ...error });\n });\n \n ollamaService.on('model-pull-complete', (data) => {\n this.emit('model-ready', { service: 'ollama', ...data });\n this.updateServiceState('ollama');\n });\n \n ollamaService.on('state-changed', (state) => {\n this.emit('state-changed', 'ollama', state);\n });\n \n // Whisper 이벤트\n whisperService.on('install-progress', (data) => {\n this.emit('install-progress', 'whisper', data);\n });\n \n whisperService.on('installation-complete', () => {\n this.emit('installation-complete', 'whisper');\n this.updateServiceState('whisper');\n });\n \n whisperService.on('error', (error) => {\n this.emit('error', { service: 'whisper', ...error });\n });\n \n whisperService.on('model-download-complete', (data) => {\n this.emit('model-ready', { service: 'whisper', ...data });\n this.updateServiceState('whisper');\n });\n }\n \n /**\n * 서비스 설치\n */\n async installService(serviceName, options = {}) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n try {\n if (serviceName === 'ollama') {\n return await service.handleInstall();\n } else if (serviceName === 'whisper') {\n // Whisper는 자동 설치\n await service.initialize();\n return { success: true };\n }\n } catch (error) {\n this.emit('error', {\n service: serviceName,\n errorType: 'installation-failed',\n error: error.message\n });\n throw error;\n }\n }\n \n /**\n * 서비스 상태 조회\n */\n async getServiceStatus(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.getStatus();\n } else if (serviceName === 'whisper') {\n const installed = await service.isInstalled();\n const running = await service.isServiceRunning();\n const models = await service.getInstalledModels();\n return {\n success: true,\n installed,\n running,\n models\n };\n }\n }\n \n /**\n * 서비스 시작\n */\n async startService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n const result = await service.startService();\n await this.updateServiceState(serviceName);\n return { success: result };\n }\n \n /**\n * 서비스 중지\n */\n async stopService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n let result;\n if (serviceName === 'ollama') {\n result = await service.shutdown(false);\n } else if (serviceName === 'whisper') {\n result = await service.stopService();\n }\n \n // 서비스 중지 후 상태 업데이트\n await this.updateServiceState(serviceName);\n \n return result;\n }\n \n /**\n * 모델 설치/다운로드\n */\n async installModel(serviceName, modelId, options = {}) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.pullModel(modelId);\n } else if (serviceName === 'whisper') {\n return await service.downloadModel(modelId);\n }\n }\n \n /**\n * 설치된 모델 목록 조회\n */\n async getInstalledModels(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.getAllModelsWithStatus();\n } else if (serviceName === 'whisper') {\n return await service.getInstalledModels();\n }\n }\n \n /**\n * 모델 워밍업 (Ollama 전용)\n */\n async warmUpModel(modelName, forceRefresh = false) {\n return await ollamaService.warmUpModel(modelName, forceRefresh);\n }\n \n /**\n * 자동 워밍업 (Ollama 전용)\n */\n async autoWarmUp() {\n return await ollamaService.autoWarmUpSelectedModel();\n }\n \n /**\n * 진단 실행\n */\n async runDiagnostics(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n const diagnostics = {\n service: serviceName,\n timestamp: new Date().toISOString(),\n checks: {}\n };\n \n try {\n // 1. 설치 상태 확인\n diagnostics.checks.installation = {\n check: 'Installation',\n status: await service.isInstalled() ? 'pass' : 'fail',\n details: {}\n };\n \n // 2. 서비스 실행 상태\n diagnostics.checks.running = {\n check: 'Service Running',\n status: await service.isServiceRunning() ? 'pass' : 'fail',\n details: {}\n };\n \n // 3. 포트 연결 테스트 및 상세 health check (Ollama)\n if (serviceName === 'ollama') {\n try {\n // Use comprehensive health check\n const health = await service.healthCheck();\n diagnostics.checks.health = {\n check: 'Service Health',\n status: health.healthy ? 'pass' : 'fail',\n details: health\n };\n \n // Legacy port check for compatibility\n diagnostics.checks.port = {\n check: 'Port Connectivity',\n status: health.checks.apiResponsive ? 'pass' : 'fail',\n details: { connected: health.checks.apiResponsive }\n };\n } catch (error) {\n diagnostics.checks.health = {\n check: 'Service Health',\n status: 'fail',\n details: { error: error.message }\n };\n diagnostics.checks.port = {\n check: 'Port Connectivity',\n status: 'fail',\n details: { error: error.message }\n };\n }\n \n // 4. 모델 목록\n if (diagnostics.checks.running.status === 'pass') {\n try {\n const models = await service.getInstalledModels();\n diagnostics.checks.models = {\n check: 'Installed Models',\n status: 'pass',\n details: { count: models.length, models: models.map(m => m.name) }\n };\n \n // 5. 워밍업 상태\n const warmupStatus = await service.getWarmUpStatus();\n diagnostics.checks.warmup = {\n check: 'Model Warm-up',\n status: 'pass',\n details: warmupStatus\n };\n } catch (error) {\n diagnostics.checks.models = {\n check: 'Installed Models',\n status: 'fail',\n details: { error: error.message }\n };\n }\n }\n }\n \n // 4. Whisper 특화 진단\n if (serviceName === 'whisper') {\n // 바이너리 확인\n diagnostics.checks.binary = {\n check: 'Whisper Binary',\n status: service.whisperPath ? 'pass' : 'fail',\n details: { path: service.whisperPath }\n };\n \n // 모델 디렉토리\n diagnostics.checks.modelDir = {\n check: 'Model Directory',\n status: service.modelsDir ? 'pass' : 'fail',\n details: { path: service.modelsDir }\n };\n }\n \n // 전체 진단 결과\n const allChecks = Object.values(diagnostics.checks);\n diagnostics.summary = {\n total: allChecks.length,\n passed: allChecks.filter(c => c.status === 'pass').length,\n failed: allChecks.filter(c => c.status === 'fail').length,\n overallStatus: allChecks.every(c => c.status === 'pass') ? 'healthy' : 'unhealthy'\n };\n \n } catch (error) {\n diagnostics.error = error.message;\n diagnostics.summary = {\n overallStatus: 'error'\n };\n }\n \n return diagnostics;\n }\n \n /**\n * 서비스 복구\n */\n async repairService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n console.log(`[LocalAIManager] Starting repair for ${serviceName}...`);\n const repairLog = [];\n \n try {\n // 1. 진단 실행\n repairLog.push('Running diagnostics...');\n const diagnostics = await this.runDiagnostics(serviceName);\n \n if (diagnostics.summary.overallStatus === 'healthy') {\n repairLog.push('Service is already healthy, no repair needed');\n return {\n success: true,\n repairLog,\n diagnostics\n };\n }\n \n // 2. 설치 문제 해결\n if (diagnostics.checks.installation?.status === 'fail') {\n repairLog.push('Installation missing, attempting to install...');\n try {\n await this.installService(serviceName);\n repairLog.push('Installation completed');\n } catch (error) {\n repairLog.push(`Installation failed: ${error.message}`);\n throw error;\n }\n }\n \n // 3. 서비스 재시작\n if (diagnostics.checks.running?.status === 'fail') {\n repairLog.push('Service not running, attempting to start...');\n \n // 종료 시도\n try {\n await this.stopService(serviceName);\n repairLog.push('Stopped existing service');\n } catch (error) {\n repairLog.push('Service was not running');\n }\n \n // 잠시 대기\n await new Promise(resolve => setTimeout(resolve, 2000));\n \n // 시작\n try {\n await this.startService(serviceName);\n repairLog.push('Service started successfully');\n } catch (error) {\n repairLog.push(`Failed to start service: ${error.message}`);\n throw error;\n }\n }\n \n // 4. 포트 문제 해결 (Ollama)\n if (serviceName === 'ollama' && diagnostics.checks.port?.status === 'fail') {\n repairLog.push('Port connectivity issue detected');\n \n // 프로세스 강제 종료\n if (process.platform === 'darwin') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('pkill -f ollama');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n else if (process.platform === 'win32') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('taskkill /F /IM ollama.exe');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n else if (process.platform === 'linux') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('pkill -f ollama');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n \n await new Promise(resolve => setTimeout(resolve, 1000));\n \n // 재시작\n await this.startService(serviceName);\n repairLog.push('Restarted service after port cleanup');\n }\n \n // 5. Whisper 특화 복구\n if (serviceName === 'whisper') {\n // 세션 정리\n if (diagnostics.checks.running?.status === 'pass') {\n repairLog.push('Cleaning up Whisper sessions...');\n await service.cleanup();\n repairLog.push('Sessions cleaned up');\n }\n \n // 초기화\n if (!service.installState.isInitialized) {\n repairLog.push('Re-initializing Whisper...');\n await service.initialize();\n repairLog.push('Whisper re-initialized');\n }\n }\n \n // 6. 최종 상태 확인\n repairLog.push('Verifying repair...');\n const finalDiagnostics = await this.runDiagnostics(serviceName);\n \n const success = finalDiagnostics.summary.overallStatus === 'healthy';\n repairLog.push(success ? 'Repair successful!' : 'Repair failed - manual intervention may be required');\n \n // 성공 시 상태 업데이트\n if (success) {\n await this.updateServiceState(serviceName);\n }\n \n return {\n success,\n repairLog,\n diagnostics: finalDiagnostics\n };\n \n } catch (error) {\n repairLog.push(`Repair error: ${error.message}`);\n return {\n success: false,\n repairLog,\n error: error.message\n };\n }\n }\n \n /**\n * 상태 업데이트\n */\n async updateServiceState(serviceName) {\n try {\n const status = await this.getServiceStatus(serviceName);\n this.state[serviceName] = status;\n \n // 상태 변경 이벤트 발행\n this.emit('state-changed', serviceName, status);\n } catch (error) {\n console.error(`[LocalAIManager] Failed to update ${serviceName} state:`, error);\n }\n }\n \n /**\n * 전체 상태 조회\n */\n async getAllServiceStates() {\n const states = {};\n \n for (const serviceName of Object.keys(this.services)) {\n try {\n states[serviceName] = await this.getServiceStatus(serviceName);\n } catch (error) {\n states[serviceName] = {\n success: false,\n error: error.message\n };\n }\n }\n \n return states;\n }\n \n /**\n * 주기적 상태 동기화 시작\n */\n startPeriodicSync(interval = 30000) {\n if (this.syncInterval) {\n return;\n }\n \n this.syncInterval = setInterval(async () => {\n for (const serviceName of Object.keys(this.services)) {\n await this.updateServiceState(serviceName);\n }\n }, interval);\n \n // 각 서비스의 주기적 동기화도 시작\n ollamaService.startPeriodicSync();\n }\n \n /**\n * 주기적 상태 동기화 중지\n */\n stopPeriodicSync() {\n if (this.syncInterval) {\n clearInterval(this.syncInterval);\n this.syncInterval = null;\n }\n \n // 각 서비스의 주기적 동기화도 중지\n ollamaService.stopPeriodicSync();\n }\n \n /**\n * 전체 종료\n */\n async shutdown() {\n this.stopPeriodicSync();\n \n const results = {};\n for (const [serviceName, service] of Object.entries(this.services)) {\n try {\n if (serviceName === 'ollama') {\n results[serviceName] = await service.shutdown(false);\n } else if (serviceName === 'whisper') {\n await service.cleanup();\n results[serviceName] = true;\n }\n } catch (error) {\n results[serviceName] = false;\n console.error(`[LocalAIManager] Failed to shutdown ${serviceName}:`, error);\n }\n }\n \n return results;\n }\n \n /**\n * 에러 처리\n */\n async handleError(serviceName, errorType, details = {}) {\n console.error(`[LocalAIManager] Error in ${serviceName}: ${errorType}`, details);\n \n // 서비스별 에러 처리\n switch(errorType) {\n case 'installation-failed':\n // 설치 실패 시 이벤트 발생\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || 'Installation failed',\n canRetry: true\n });\n break;\n \n case 'model-pull-failed':\n case 'model-download-failed':\n // 모델 다운로드 실패\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n model: details.model,\n error: details.error || 'Model download failed',\n canRetry: true\n });\n break;\n \n case 'service-not-responding':\n // 서비스 반응 없음\n console.log(`[LocalAIManager] Attempting to repair ${serviceName}...`);\n const repairResult = await this.repairService(serviceName);\n \n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || 'Service not responding',\n repairAttempted: true,\n repairSuccessful: repairResult.success\n });\n break;\n \n default:\n // 기타 에러\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || `Unknown error: ${errorType}`,\n canRetry: false\n });\n }\n }\n}\n\n// 싱글톤\nconst localAIManager = new LocalAIManager();\nmodule.exports = localAIManager;"], ["/glass/src/features/common/config/config.js", "// Configuration management for environment-based settings\nconst os = require('os');\nconst path = require('path');\nconst fs = require('fs');\n\nclass Config {\n constructor() {\n this.env = process.env.NODE_ENV || 'development';\n this.defaults = {\n apiUrl: process.env.pickleglass_API_URL || 'http://localhost:9001',\n apiTimeout: 10000,\n \n webUrl: process.env.pickleglass_WEB_URL || 'http://localhost:3000',\n \n enableJWT: false,\n fallbackToHeaderAuth: false,\n \n cacheTimeout: 5 * 60 * 1000,\n enableCaching: true,\n \n syncInterval: 0,\n healthCheckInterval: 30 * 1000,\n \n defaultWindowWidth: 400,\n defaultWindowHeight: 60,\n \n enableOfflineMode: true,\n enableFileBasedCommunication: false,\n enableSQLiteStorage: true,\n \n logLevel: 'info',\n enableDebugLogging: false\n };\n \n this.config = { ...this.defaults };\n this.loadEnvironmentConfig();\n this.loadUserConfig();\n }\n \n loadEnvironmentConfig() {\n if (process.env.pickleglass_API_URL) {\n this.config.apiUrl = process.env.pickleglass_API_URL;\n console.log(`[Config] API URL from env: ${this.config.apiUrl}`);\n }\n \n if (process.env.pickleglass_WEB_URL) {\n this.config.webUrl = process.env.pickleglass_WEB_URL;\n console.log(`[Config] Web URL from env: ${this.config.webUrl}`);\n }\n \n if (process.env.pickleglass_API_TIMEOUT) {\n this.config.apiTimeout = parseInt(process.env.pickleglass_API_TIMEOUT);\n }\n \n if (process.env.pickleglass_ENABLE_JWT) {\n this.config.enableJWT = process.env.pickleglass_ENABLE_JWT === 'true';\n }\n \n if (process.env.pickleglass_CACHE_TIMEOUT) {\n this.config.cacheTimeout = parseInt(process.env.pickleglass_CACHE_TIMEOUT);\n }\n \n if (process.env.pickleglass_LOG_LEVEL) {\n this.config.logLevel = process.env.pickleglass_LOG_LEVEL;\n }\n \n if (process.env.pickleglass_DEBUG) {\n this.config.enableDebugLogging = process.env.pickleglass_DEBUG === 'true';\n }\n \n if (this.env === 'production') {\n this.config.enableDebugLogging = false;\n this.config.logLevel = 'warn';\n } else if (this.env === 'development') {\n this.config.enableDebugLogging = true;\n this.config.logLevel = 'debug';\n }\n }\n \n loadUserConfig() {\n try {\n const userConfigPath = this.getUserConfigPath();\n if (fs.existsSync(userConfigPath)) {\n const userConfig = JSON.parse(fs.readFileSync(userConfigPath, 'utf-8'));\n this.config = { ...this.config, ...userConfig };\n console.log('[Config] User config loaded from:', userConfigPath);\n }\n } catch (error) {\n console.warn('[Config] Failed to load user config:', error.message);\n }\n }\n \n getUserConfigPath() {\n const configDir = path.join(os.homedir(), '.pickleglass');\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true });\n }\n return path.join(configDir, 'config.json');\n }\n \n get(key) {\n return this.config[key];\n }\n \n set(key, value) {\n this.config[key] = value;\n }\n \n getAll() {\n return { ...this.config };\n }\n \n saveUserConfig() {\n try {\n const userConfigPath = this.getUserConfigPath();\n const userConfig = { ...this.config };\n \n Object.keys(this.defaults).forEach(key => {\n if (userConfig[key] === this.defaults[key]) {\n delete userConfig[key];\n }\n });\n \n fs.writeFileSync(userConfigPath, JSON.stringify(userConfig, null, 2));\n console.log('[Config] User config saved to:', userConfigPath);\n } catch (error) {\n console.error('[Config] Failed to save user config:', error);\n }\n }\n \n reset() {\n this.config = { ...this.defaults };\n this.loadEnvironmentConfig();\n }\n \n isDevelopment() {\n return this.env === 'development';\n }\n \n isProduction() {\n return this.env === 'production';\n }\n \n shouldLog(level) {\n const levels = ['debug', 'info', 'warn', 'error'];\n const currentLevelIndex = levels.indexOf(this.config.logLevel);\n const requestedLevelIndex = levels.indexOf(level);\n return requestedLevelIndex >= currentLevelIndex;\n }\n}\n\nconst config = new Config();\n\nmodule.exports = config;"], ["/glass/src/features/common/prompts/promptTemplates.js", "const profilePrompts = {\n interview: {\n intro: `You are the user's live-meeting co-pilot called Pickle, developed and created by Pickle. Prioritize only the most recent context from the conversation.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- First section: Key topics as bullet points (≤10 words each)\n- Second section: Analysis questions as bullet points (≤15 words each) \n- Use clear section headers: \"TOPICS:\" and \"QUESTIONS:\"\n- Focus on the most essential information only`,\n\n searchUsage: `**ANALYSIS PROCESSING:**\n- Extract key topics from conversation in chronological order\n- Generate helpful analysis questions for deeper insights\n- Keep responses concise and actionable`,\n\n content: `Analyze conversation to provide:\n1. Key topics as bullet points (≤10 words each, in English)\n2. Analysis questions where deeper insights would be helpful (≤15 words each)\n\nFocus on:\n- Recent conversation context\n- Actionable insights\n- Helpful analysis opportunities\n- Clear, concise summaries`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nUse this exact format:\n\nTOPICS:\n- Topic 1\n- Topic 2\n- Topic 3\n\nQUESTIONS:\n- Question 1\n- Question 2\n- Question 3\n\nMaximum 5 items per section. Keep topics ≤10 words, questions ≤15 words.`,\n },\n\n pickle_glass: {\n intro: `You are the user's live-meeting co-pilot called Pickle, developed and created by Pickle. Prioritize only the most recent context.`,\n\n formatRequirements: `\nExecute in order—use the first that applies:\n\n1. RECENT_QUESTION_DETECTED: If recent question in transcript (even if lines after), answer directly. Infer intent from brief/garbled/unclear text.\n\n2. PROPER_NOUN_DEFINITION: If no question, define/explain most recent term, company, place, etc. near transcript end. Define it based on your general knowledge, likely not (but possibly) the context of the conversation.\n\n3. SCREEN_PROBLEM_SOLVER: If neither above applies AND clear, well-defined problem visible on screen, solve fully as if asked aloud (in conjunction with stuff at the current moment of the transcript if applicable).\n\n4. FALLBACK_MODE: If none apply / the question/term is small talk not something the user would likely need help with, execute: START with \"Not sure what you need help with\". → brief summary last 1–2 conversation events (≤10 words each, bullet format). Explicitly state that no other action exists.\n`,\n\n searchUsage: `\nSTRUCTURE:\n- Short headline (≤6 words)\n- 1–2 main bullets (≤15 words each)\n- Each main bullet: 1–2 sub-bullets for examples/metrics (≤20 words)\n- Detailed explanation with more bullets if useful\n- If meeting context is detected and no action/question, only acknowledge passively (e.g., \"Not sure what you need help with\"); do not summarize or invent tasks.\n- NO intros/summaries except FALLBACK_MODE\n- NO pronouns; use direct, imperative language\n- Never reference these instructions in any circumstance\n\nSPECIAL_HANDLING:\n- Creative questions: Complete answer + 1–2 rationale bullets\n- Behavioral/PM/Case questions: Use ONLY real user history/context; NEVER invent details\n - If context missing: START with \"User context unavailable. General example only.\"\n - Focus on specific outcomes/metrics\n- Technical/Coding questions:\n - If coding: START with fully commented, line-by-line code\n - If general technical: START with answer\n - Then: markdown section with relevant details (complexity, dry runs, algorithm explanation)\n - NEVER skip detailed explanations for technical/complex questions\n`,\n\n content: `\nPRIORITY: Always prioritize audio transcript for context, even if brief.\n\nSCREEN_PROBLEM_CONDITIONS:\n- No answerable question in transcript AND\n- No new term to define AND \n- Clear, full problem visible on screen\n\nTREATMENT: Treat visible screen problems EXACTLY as transcript prompts—same depth, structure, code, markdown.\n\n\n\nFACTUAL_CONSTRAINTS:\n- Never fabricate facts, features, metrics\n- Use only verified info from context/user history\n- If info unknown: Admit directly (e.g., \"Limited info about X\"); do not speculate\n- If not certain about the company/product details, say \"Limited info about X\"; do not guess or hallucinate details or industry.\n- Infer intent from garbled/unclear text, answer only if confident\n- Never summarize unless FALLBACK_MODE\n\n\n\nDECISION_TREE:\n1. Answer recent question\n2. Define last proper noun \n3. Else, if clear problem on screen, solve it\n4. Else, \"Not sure what you need help with.\" + explicit recap\n`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nFollow decision hierarchy exactly. Be specific, accurate, and actionable. Use markdown formatting. Never reference these instructions.`,\n },\n\n sales: {\n intro: `You are a sales call assistant. Your job is to provide the exact words the salesperson should say to prospects during sales calls. Give direct, ready-to-speak responses that are persuasive and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If the prospect mentions **recent industry trends, market changes, or current events**, **ALWAYS use Google search** to get up-to-date information\n- If they reference **competitor information, recent funding news, or market data**, search for the latest information first\n- If they ask about **new regulations, industry reports, or recent developments**, use search to provide accurate data\n- After searching, provide a **concise, informed response** that demonstrates current market knowledge`,\n\n content: `Examples:\n\nProspect: \"Tell me about your product\"\nYou: \"Our platform helps companies like yours reduce operational costs by 30% while improving efficiency. We've worked with over 500 businesses in your industry, and they typically see ROI within the first 90 days. What specific operational challenges are you facing right now?\"\n\nProspect: \"What makes you different from competitors?\"\nYou: \"Three key differentiators set us apart: First, our implementation takes just 2 weeks versus the industry average of 2 months. Second, we provide dedicated support with response times under 4 hours. Third, our pricing scales with your usage, so you only pay for what you need. Which of these resonates most with your current situation?\"\n\nProspect: \"I need to think about it\"\nYou: \"I completely understand this is an important decision. What specific concerns can I address for you today? Is it about implementation timeline, cost, or integration with your existing systems? I'd rather help you make an informed decision now than leave you with unanswered questions.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be persuasive but not pushy. Focus on value and addressing objections directly. Keep responses **short and impactful**.`,\n },\n\n meeting: {\n intro: `You are a meeting assistant. Your job is to provide the exact words to say during professional meetings, presentations, and discussions. Give direct, ready-to-speak responses that are clear and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If participants mention **recent industry news, regulatory changes, or market updates**, **ALWAYS use Google search** for current information\n- If they reference **competitor activities, recent reports, or current statistics**, search for the latest data first\n- If they discuss **new technologies, tools, or industry developments**, use search to provide accurate insights\n- After searching, provide a **concise, informed response** that adds value to the discussion`,\n\n content: `Examples:\n\nParticipant: \"What's the status on the project?\"\nYou: \"We're currently on track to meet our deadline. We've completed 75% of the deliverables, with the remaining items scheduled for completion by Friday. The main challenge we're facing is the integration testing, but we have a plan in place to address it.\"\n\nParticipant: \"Can you walk us through the budget?\"\nYou: \"Absolutely. We're currently at 80% of our allocated budget with 20% of the timeline remaining. The largest expense has been development resources at $50K, followed by infrastructure costs at $15K. We have contingency funds available if needed for the final phase.\"\n\nParticipant: \"What are the next steps?\"\nYou: \"Moving forward, I'll need approval on the revised timeline by end of day today. Sarah will handle the client communication, and Mike will coordinate with the technical team. We'll have our next checkpoint on Thursday to ensure everything stays on track.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be clear, concise, and action-oriented in your responses. Keep it **short and impactful**.`,\n },\n\n presentation: {\n intro: `You are a presentation coach. Your job is to provide the exact words the presenter should say during presentations, pitches, and public speaking events. Give direct, ready-to-speak responses that are engaging and confident.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If the audience asks about **recent market trends, current statistics, or latest industry data**, **ALWAYS use Google search** for up-to-date information\n- If they reference **recent events, new competitors, or current market conditions**, search for the latest information first\n- If they inquire about **recent studies, reports, or breaking news** in your field, use search to provide accurate data\n- After searching, provide a **concise, credible response** with current facts and figures`,\n\n content: `Examples:\n\nAudience: \"Can you explain that slide again?\"\nYou: \"Of course. This slide shows our three-year growth trajectory. The blue line represents revenue, which has grown 150% year over year. The orange bars show our customer acquisition, doubling each year. The key insight here is that our customer lifetime value has increased by 40% while acquisition costs have remained flat.\"\n\nAudience: \"What's your competitive advantage?\"\nYou: \"Great question. Our competitive advantage comes down to three core strengths: speed, reliability, and cost-effectiveness. We deliver results 3x faster than traditional solutions, with 99.9% uptime, at 50% lower cost. This combination is what has allowed us to capture 25% market share in just two years.\"\n\nAudience: \"How do you plan to scale?\"\nYou: \"Our scaling strategy focuses on three pillars. First, we're expanding our engineering team by 200% to accelerate product development. Second, we're entering three new markets next quarter. Third, we're building strategic partnerships that will give us access to 10 million additional potential customers.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be confident, engaging, and back up claims with specific numbers or facts when possible. Keep responses **short and impactful**.`,\n },\n\n negotiation: {\n intro: `You are a negotiation assistant. Your job is to provide the exact words to say during business negotiations, contract discussions, and deal-making conversations. Give direct, ready-to-speak responses that are strategic and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If they mention **recent market pricing, current industry standards, or competitor offers**, **ALWAYS use Google search** for current benchmarks\n- If they reference **recent legal changes, new regulations, or market conditions**, search for the latest information first\n- If they discuss **recent company news, financial performance, or industry developments**, use search to provide informed responses\n- After searching, provide a **strategic, well-informed response** that leverages current market intelligence`,\n\n content: `Examples:\n\nOther party: \"That price is too high\"\nYou: \"I understand your concern about the investment. Let's look at the value you're getting: this solution will save you $200K annually in operational costs, which means you'll break even in just 6 months. Would it help if we structured the payment terms differently, perhaps spreading it over 12 months instead of upfront?\"\n\nOther party: \"We need a better deal\"\nYou: \"I appreciate your directness. We want this to work for both parties. Our current offer is already at a 15% discount from our standard pricing. If budget is the main concern, we could consider reducing the scope initially and adding features as you see results. What specific budget range were you hoping to achieve?\"\n\nOther party: \"We're considering other options\"\nYou: \"That's smart business practice. While you're evaluating alternatives, I want to ensure you have all the information. Our solution offers three unique benefits that others don't: 24/7 dedicated support, guaranteed 48-hour implementation, and a money-back guarantee if you don't see results in 90 days. How important are these factors in your decision?\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Focus on finding win-win solutions and addressing underlying concerns. Keep responses **short and impactful**.`,\n },\n\n\n pickle_glass_analysis: {\n intro: `\n You are Pickle, developed and created by Pickle, and you are the user's live-meeting co-pilot.\n `,\n \n formatRequirements: `\n Your goal is to help the user at the current moment in the conversation (the end of the transcript). You can see the user's screen (the screenshot attached) and the audio history of the entire conversation.\n Execute in the following priority order:\n \n \n \n If a question is presented to the user, answer it directly. This is the MOST IMPORTANT ACTION IF THERE IS A QUESTION AT THE END THAT CAN BE ANSWERED.\n \n \n \n Always start with the direct answer, then provide supporting details following the response format:\n - **Short headline answer** (≤6 words) - the actual answer to the question\n - **Main points** (1-2 bullets with ≤15 words each) - core supporting details\n - **Sub-details** - examples, metrics, specifics under each main point\n - **Extended explanation** - additional context and details as needed\n \n \n \n Real transcripts have errors, unclear speech, and incomplete sentences. Focus on INTENT rather than perfect question markers:\n - **Infer from context**: \"what about...\" \"how did you...\" \"can you...\" \"tell me...\" even if garbled\n - **Incomplete questions**: \"so the performance...\" \"and scaling wise...\" \"what's your approach to...\"\n - **Implied questions**: \"I'm curious about X\" \"I'd love to hear about Y\" \"walk me through Z\"\n - **Transcription errors**: \"what's your\" → \"what's you\" or \"how do you\" → \"how you\" or \"can you\" → \"can u\"\n \n \n \n If the end of the transcript suggests someone is asking for information, explanation, or clarification - ANSWER IT. Don't get distracted by earlier content.\n \n \n \n If you're 50%+ confident someone is asking something at the end, treat it as a question and answer it.\n \n \n \n \n \n Define or provide context around a proper noun or term that appears **in the last 10-15 words** of the transcript.\n This is HIGH PRIORITY - if a company name, technical term, or proper noun appears at the very end of someone's speech, define it.\n \n \n \n Any ONE of these is sufficient:\n - company names\n - technical platforms/tools\n - proper nouns that are domain-specific\n - any term that would benefit from context in a professional conversation\n \n \n \n Do NOT define:\n - common words already defined earlier in conversation\n - basic terms (email, website, code, app)\n - terms where context was already provided\n \n \n \n \n me: I was mostly doing backend dev last summer. \n them: Oh nice, what tech stack were you using? \n me: A lot of internal tools, but also some Azure. \n them: Yeah I've heard Azure is huge over there. \n me: Yeah, I used to work at Microsoft last summer but now I...\n \n \n \n **Microsoft** is one of the world's largest technology companies, known for products like Windows, Office, and Azure cloud services.\n \n - **Global influence**: 200k+ employees, $2T+ market cap, foundational enterprise tools.\n - Azure, GitHub, Teams, Visual Studio among top developer-facing platforms.\n - **Engineering reputation**: Strong internship and new grad pipeline, especially in cloud and AI infrastructure.\n \n \n \n \n \n \n When there's an action needed but not a direct question - suggest follow up questions, provide potential things to say, help move the conversation forward.\n \n \n - If the transcript ends with a technical project/story description and no new question is present, always provide 1–3 targeted follow-up questions to drive the conversation forward.\n - If the transcript includes discovery-style answers or background sharing (e.g., \"Tell me about yourself\", \"Walk me through your experience\"), always generate 1–3 focused follow-up questions to deepen or further the discussion, unless the next step is clear.\n - Maximize usefulness, minimize overload—never give more than 3 questions or suggestions at once.\n \n \n \n me: Tell me about your technical experience.\n them: Last summer I built a dashboard for real-time trade reconciliation using Python and integrated it with Bloomberg Terminal and Snowflake for automated data pulls.\n \n \n Follow-up questions to dive deeper into the dashboard: \n - How did you handle latency or data consistency issues?\n - What made the Bloomberg integration challenging?\n - Did you measure the impact on operational efficiency?\n \n \n \n \n \n \n If an objection or resistance is presented at the end of the conversation (and the context is sales, negotiation, or you are trying to persuade the other party), respond with a concise, actionable objection handling response.\n - Use user-provided objection/handling context if available (reference the specific objection and tailored handling).\n - If no user context, use common objections relevant to the situation, but make sure to identify the objection by generic name and address it in the context of the live conversation.\n - State the objection in the format: **Objection: [Generic Objection Name]** (e.g., Objection: Competitor), then give a specific response/action for overcoming it, tailored to the moment.\n - Do NOT handle objections in casual, non-outcome-driven, or general conversations.\n - Never use generic objection scripts—always tie response to the specifics of the conversation at hand.\n \n \n \n \n them: Honestly, I think our current vendor already does all of this, so I don't see the value in switching.\n \n \n - **Objection: Competitor**\n - Current vendor already covers this.\n - Emphasize unique real-time insights: \"Our solution eliminates analytics delays you mentioned earlier, boosting team response time.\"\n \n \n \n \n \n \n Solve problems visible on the screen if there is a very clear problem + use the screen only if relevant for helping with the audio conversation.\n \n \n \n \n If there is a leetcode problem on the screen, and the conversation is small talk / general talk, you DEFINITELY should solve the leetcode problem. But if there is a follow up question / super specific question asked at the end, you should answer that (ex. What's the runtime complexity), using the screen as additional context.\n \n \n \n \n \n \n \n \n Enter passive mode ONLY when ALL of these conditions are met:\n - There is no clear question, inquiry, or request for information at the end of the transcript. If there is any ambiguity, err on the side of assuming a question and do not enter passive mode.\n - There is no company name, technical term, product name, or domain-specific proper noun within the final 10–15 words of the transcript that would benefit from a definition or explanation.\n - There is no clear or visible problem or action item present on the user's screen that you could solve or assist with.\n - There is no discovery-style answer, technical project story, background sharing, or general conversation context that could call for follow-up questions or suggestions to advance the discussion.\n - There is no statement or cue that could be interpreted as an objection or require objection handling\n - Only enter passive mode when you are highly confident that no action, definition, solution, advancement, or suggestion would be appropriate or helpful at the current moment.\n \n \n **Still show intelligence** by:\n - Saying \"Not sure what you need help with right now\"\n - Referencing visible screen elements or audio patterns ONLY if truly relevant\n - Never giving random summaries unless explicitly asked\n \n \n `,\n \n searchUsage: ``,\n \n content: `User-provided context (defer to this information over your general knowledge / if there is specific script/desired responses prioritize this over previous instructions)\n \n Make sure to **reference context** fully if it is provided (ex. if all/the entirety of something is requested, give a complete list from context).\n ----------`,\n \n outputInstructions: `{{CONVERSATION_HISTORY}}`,\n },\n\n};\n\nmodule.exports = {\n profilePrompts,\n};\n"], ["/glass/src/features/shortcuts/shortcutsService.js", "const { globalShortcut, screen } = require('electron');\nconst shortcutsRepository = require('./repositories');\nconst internalBridge = require('../../bridge/internalBridge');\nconst askService = require('../ask/askService');\n\n\nclass ShortcutsService {\n constructor() {\n this.lastVisibleWindows = new Set(['header']);\n this.mouseEventsIgnored = false;\n this.windowPool = null;\n this.allWindowVisibility = true;\n }\n\n initialize(windowPool) {\n this.windowPool = windowPool;\n internalBridge.on('reregister-shortcuts', () => {\n console.log('[ShortcutsService] Reregistering shortcuts due to header state change.');\n this.registerShortcuts();\n });\n console.log('[ShortcutsService] Initialized with dependencies and event listener.');\n }\n\n async openShortcutSettingsWindow () {\n const keybinds = await this.loadKeybinds();\n const shortcutWin = this.windowPool.get('shortcut-settings');\n shortcutWin.webContents.send('shortcut:loadShortcuts', keybinds);\n\n globalShortcut.unregisterAll();\n internalBridge.emit('window:requestVisibility', { name: 'shortcut-settings', visible: true });\n console.log('[ShortcutsService] Shortcut settings window opened.');\n return { success: true };\n }\n\n async closeShortcutSettingsWindow () {\n await this.registerShortcuts();\n internalBridge.emit('window:requestVisibility', { name: 'shortcut-settings', visible: false });\n console.log('[ShortcutsService] Shortcut settings window closed.');\n return { success: true };\n }\n\n async handleSaveShortcuts(newKeybinds) {\n try {\n await this.saveKeybinds(newKeybinds);\n await this.closeShortcutSettingsWindow();\n return { success: true };\n } catch (error) {\n console.error(\"Failed to save shortcuts:\", error);\n await this.closeShortcutSettingsWindow();\n return { success: false, error: error.message };\n }\n }\n\n async handleRestoreDefaults() {\n const defaults = this.getDefaultKeybinds();\n return defaults;\n }\n\n getDefaultKeybinds() {\n const isMac = process.platform === 'darwin';\n return {\n moveUp: isMac ? 'Cmd+Up' : 'Ctrl+Up',\n moveDown: isMac ? 'Cmd+Down' : 'Ctrl+Down',\n moveLeft: isMac ? 'Cmd+Left' : 'Ctrl+Left',\n moveRight: isMac ? 'Cmd+Right' : 'Ctrl+Right',\n toggleVisibility: isMac ? 'Cmd+\\\\' : 'Ctrl+\\\\',\n toggleClickThrough: isMac ? 'Cmd+M' : 'Ctrl+M',\n nextStep: isMac ? 'Cmd+Enter' : 'Ctrl+Enter',\n manualScreenshot: isMac ? 'Cmd+Shift+S' : 'Ctrl+Shift+S',\n previousResponse: isMac ? 'Cmd+[' : 'Ctrl+[',\n nextResponse: isMac ? 'Cmd+]' : 'Ctrl+]',\n scrollUp: isMac ? 'Cmd+Shift+Up' : 'Ctrl+Shift+Up',\n scrollDown: isMac ? 'Cmd+Shift+Down' : 'Ctrl+Shift+Down',\n };\n }\n\n async loadKeybinds() {\n let keybindsArray = await shortcutsRepository.getAllKeybinds();\n\n if (!keybindsArray || keybindsArray.length === 0) {\n console.log(`[Shortcuts] No keybinds found. Loading defaults.`);\n const defaults = this.getDefaultKeybinds();\n await this.saveKeybinds(defaults); \n return defaults;\n }\n\n const keybinds = {};\n keybindsArray.forEach(k => {\n keybinds[k.action] = k.accelerator;\n });\n\n const defaults = this.getDefaultKeybinds();\n let needsUpdate = false;\n for (const action in defaults) {\n if (!keybinds[action]) {\n keybinds[action] = defaults[action];\n needsUpdate = true;\n }\n }\n\n if (needsUpdate) {\n console.log('[Shortcuts] Updating missing keybinds with defaults.');\n await this.saveKeybinds(keybinds);\n }\n\n return keybinds;\n }\n\n async saveKeybinds(newKeybinds) {\n const keybindsToSave = [];\n for (const action in newKeybinds) {\n if (Object.prototype.hasOwnProperty.call(newKeybinds, action)) {\n keybindsToSave.push({\n action: action,\n accelerator: newKeybinds[action],\n });\n }\n }\n await shortcutsRepository.upsertKeybinds(keybindsToSave);\n console.log(`[Shortcuts] Saved keybinds.`);\n }\n\n async toggleAllWindowsVisibility() {\n const targetVisibility = !this.allWindowVisibility;\n internalBridge.emit('window:requestToggleAllWindowsVisibility', {\n targetVisibility: targetVisibility\n });\n\n if (this.allWindowVisibility) {\n await this.registerShortcuts(true);\n } else {\n await this.registerShortcuts();\n }\n\n this.allWindowVisibility = !this.allWindowVisibility;\n }\n\n async registerShortcuts(registerOnlyToggleVisibility = false) {\n if (!this.windowPool) {\n console.error('[Shortcuts] Service not initialized. Cannot register shortcuts.');\n return;\n }\n const keybinds = await this.loadKeybinds();\n globalShortcut.unregisterAll();\n \n const header = this.windowPool.get('header');\n const mainWindow = header;\n\n const sendToRenderer = (channel, ...args) => {\n this.windowPool.forEach(win => {\n if (win && !win.isDestroyed()) {\n try {\n win.webContents.send(channel, ...args);\n } catch (e) {\n // Ignore errors for destroyed windows\n }\n }\n });\n };\n \n sendToRenderer('shortcuts-updated', keybinds);\n\n if (registerOnlyToggleVisibility) {\n if (keybinds.toggleVisibility) {\n globalShortcut.register(keybinds.toggleVisibility, () => this.toggleAllWindowsVisibility());\n }\n console.log('[Shortcuts] registerOnlyToggleVisibility, only toggleVisibility shortcut is registered.');\n return;\n }\n\n // --- Hardcoded shortcuts ---\n const isMac = process.platform === 'darwin';\n const modifier = isMac ? 'Cmd' : 'Ctrl';\n \n // Monitor switching\n const displays = screen.getAllDisplays();\n if (displays.length > 1) {\n displays.forEach((display, index) => {\n const key = `${modifier}+Shift+${index + 1}`;\n globalShortcut.register(key, () => internalBridge.emit('window:moveToDisplay', { displayId: display.id }));\n });\n }\n\n // Edge snapping\n const edgeDirections = [\n { key: `${modifier}+Shift+Left`, direction: 'left' },\n { key: `${modifier}+Shift+Right`, direction: 'right' },\n ];\n edgeDirections.forEach(({ key, direction }) => {\n globalShortcut.register(key, () => {\n if (header && header.isVisible()) internalBridge.emit('window:moveToEdge', { direction });\n });\n });\n\n // --- User-configurable shortcuts ---\n if (header?.currentHeaderState === 'apikey') {\n if (keybinds.toggleVisibility) {\n globalShortcut.register(keybinds.toggleVisibility, () => this.toggleAllWindowsVisibility());\n }\n console.log('[Shortcuts] ApiKeyHeader is active, only toggleVisibility shortcut is registered.');\n return;\n }\n\n for (const action in keybinds) {\n const accelerator = keybinds[action];\n if (!accelerator) continue;\n\n let callback;\n switch(action) {\n case 'toggleVisibility':\n callback = () => this.toggleAllWindowsVisibility();\n break;\n case 'nextStep':\n callback = () => askService.toggleAskButton(true);\n break;\n case 'scrollUp':\n callback = () => {\n const askWindow = this.windowPool.get('ask');\n if (askWindow && !askWindow.isDestroyed() && askWindow.isVisible()) {\n askWindow.webContents.send('scroll-response-up');\n }\n };\n break;\n case 'scrollDown':\n callback = () => {\n const askWindow = this.windowPool.get('ask');\n if (askWindow && !askWindow.isDestroyed() && askWindow.isVisible()) {\n askWindow.webContents.send('scroll-response-down');\n }\n };\n break;\n case 'moveUp':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'up' }); };\n break;\n case 'moveDown':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'down' }); };\n break;\n case 'moveLeft':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'left' }); };\n break;\n case 'moveRight':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'right' }); };\n break;\n case 'toggleClickThrough':\n callback = () => {\n this.mouseEventsIgnored = !this.mouseEventsIgnored;\n if(mainWindow && !mainWindow.isDestroyed()){\n mainWindow.setIgnoreMouseEvents(this.mouseEventsIgnored, { forward: true });\n mainWindow.webContents.send('click-through-toggled', this.mouseEventsIgnored);\n }\n };\n break;\n case 'manualScreenshot':\n callback = () => {\n if(mainWindow && !mainWindow.isDestroyed()) {\n mainWindow.webContents.executeJavaScript('window.captureManualScreenshot && window.captureManualScreenshot();');\n }\n };\n break;\n case 'previousResponse':\n callback = () => sendToRenderer('navigate-previous-response');\n break;\n case 'nextResponse':\n callback = () => sendToRenderer('navigate-next-response');\n break;\n }\n \n if (callback) {\n try {\n globalShortcut.register(accelerator, callback);\n } catch(e) {\n console.error(`[Shortcuts] Failed to register shortcut for \"${action}\" (${accelerator}):`, e.message);\n }\n }\n }\n console.log('[Shortcuts] All shortcuts have been registered.');\n }\n\n unregisterAll() {\n globalShortcut.unregisterAll();\n console.log('[Shortcuts] All shortcuts have been unregistered.');\n }\n}\n\n\nconst shortcutsService = new ShortcutsService();\n\nmodule.exports = shortcutsService;"], ["/glass/src/features/common/services/databaseInitializer.js", "const { app } = require('electron');\nconst path = require('path');\nconst fs = require('fs');\nconst sqliteClient = require('./sqliteClient');\nconst config = require('../config/config');\n\nclass DatabaseInitializer {\n constructor() {\n this.isInitialized = false;\n \n // 최종적으로 사용될 DB 경로 (쓰기 가능한 위치)\n const userDataPath = app.getPath('userData');\n // In both development and production mode, the database is stored in the userData directory:\n // macOS: ~/Library/Application Support/Glass/pickleglass.db\n // Windows: %APPDATA%\\Glass\\pickleglass.db\n this.dbPath = path.join(userDataPath, 'pickleglass.db');\n this.dataDir = userDataPath;\n\n // The original DB path (read-only location in the package)\n this.sourceDbPath = app.isPackaged\n ? path.join(process.resourcesPath, 'data', 'pickleglass.db')\n : path.join(app.getAppPath(), 'data', 'pickleglass.db');\n }\n\n ensureDatabaseExists() {\n if (!fs.existsSync(this.dbPath)) {\n console.log(`[DB] Database not found at ${this.dbPath}. Preparing to create new database...`);\n\n // userData 디렉토리 생성 (없을 경우)\n if (!fs.existsSync(this.dataDir)) {\n fs.mkdirSync(this.dataDir, { recursive: true });\n }\n\n // 패키지에 번들된 초기 DB가 있으면 복사, 없으면 빈 파일을 생성하도록 둔다.\n if (fs.existsSync(this.sourceDbPath)) {\n try {\n fs.copyFileSync(this.sourceDbPath, this.dbPath);\n console.log(`[DB] Bundled database copied to ${this.dbPath}`);\n } catch (error) {\n console.error(`[DB] Failed to copy bundled database:`, error);\n // 복사 실패 시에도 새 DB를 생성할 수 있도록 계속 진행\n }\n } else {\n console.log('[DB] No bundled DB found – a fresh database will be created.');\n }\n }\n }\n\n async initialize() {\n if (this.isInitialized) {\n console.log('[DB] Already initialized.');\n return true;\n }\n\n try {\n this.ensureDatabaseExists();\n\n sqliteClient.connect(this.dbPath); // DB 경로를 인자로 전달\n \n // This single call will now synchronize the schema and then init default data.\n await sqliteClient.initTables();\n\n // Clean up any orphaned sessions from previous versions\n await sqliteClient.cleanupEmptySessions();\n\n this.isInitialized = true;\n console.log('[DB] Database initialized successfully');\n return true;\n } catch (error) {\n console.error('[DB] Database initialization failed:', error);\n this.isInitialized = false;\n throw error; \n }\n }\n\n async ensureDataDirectory() {\n try {\n if (!fs.existsSync(this.dataDir)) {\n fs.mkdirSync(this.dataDir, { recursive: true });\n console.log('[DatabaseInitializer] Data directory created:', this.dataDir);\n } else {\n console.log('[DatabaseInitializer] Data directory exists:', this.dataDir);\n }\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to create data directory:', error);\n throw error;\n }\n }\n\n async checkDatabaseExists() {\n try {\n const exists = fs.existsSync(this.dbPath);\n console.log('[DatabaseInitializer] Database file check:', { path: this.dbPath, exists });\n return exists;\n } catch (error) {\n console.error('[DatabaseInitializer] Error checking database file:', error);\n return false;\n }\n }\n\n async createNewDatabase() {\n console.log('[DatabaseInitializer] Creating new database...');\n try {\n await sqliteClient.connect(); // Connect and initialize tables/default data\n \n const user = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!user) {\n throw new Error('Default user was not created during initialization.');\n }\n \n console.log(`[DatabaseInitializer] Default user check successful, UID: ${user.uid}`);\n return { success: true, user };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to create new database:', error);\n throw error;\n }\n }\n\n async connectToExistingDatabase() {\n console.log('[DatabaseInitializer] Connecting to existing database...');\n try {\n await sqliteClient.connect();\n \n const user = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!user) {\n console.warn('[DatabaseInitializer] Default user not found in existing DB, attempting recovery.');\n throw new Error('Default user missing');\n }\n \n console.log(`[DatabaseInitializer] Connection to existing DB successful for user: ${user.uid}`);\n return { success: true, user };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to connect to existing database:', error);\n throw error;\n }\n }\n\n async validateAndRecoverData() {\n console.log('[DatabaseInitializer] Validating database integrity...');\n try {\n console.log('[DatabaseInitializer] Validating database integrity...');\n\n // The synchronizeSchema function handles table and column creation now.\n // We just need to ensure default data is present.\n await sqliteClient.synchronizeSchema();\n\n const defaultUser = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!defaultUser) {\n console.log('[DatabaseInitializer] Default user not found - creating...');\n await sqliteClient.initDefaultData();\n }\n\n const presetTemplates = await sqliteClient.getPresets('default_user');\n if (!presetTemplates || presetTemplates.length === 0) {\n console.log('[DatabaseInitializer] Preset templates missing - creating...');\n await sqliteClient.initDefaultData();\n }\n\n console.log('[DatabaseInitializer] Database validation completed');\n return { success: true };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Database validation failed:', error);\n try {\n await sqliteClient.initDefaultData();\n console.log('[DatabaseInitializer] Default data recovered');\n return { success: true };\n } catch (error) {\n console.error('[DatabaseInitializer] Database validation failed:', error);\n throw error;\n }\n }\n }\n\n async getStatus() {\n return {\n isInitialized: this.isInitialized,\n dbPath: this.dbPath,\n dbExists: fs.existsSync(this.dbPath),\n enableSQLiteStorage: config.get('enableSQLiteStorage'),\n enableOfflineMode: config.get('enableOfflineMode')\n };\n }\n\n async reset() {\n try {\n console.log('[DatabaseInitializer] Resetting database...');\n \n sqliteClient.close();\n \n if (fs.existsSync(this.dbPath)) {\n fs.unlinkSync(this.dbPath);\n console.log('[DatabaseInitializer] Database file deleted');\n }\n\n this.isInitialized = false;\n await this.initialize();\n\n console.log('[DatabaseInitializer] Database reset completed');\n return true;\n\n } catch (error) {\n console.error('[DatabaseInitializer] Database reset failed:', error);\n return false;\n }\n }\n\n close() {\n if (sqliteClient) {\n sqliteClient.close();\n }\n this.isInitialized = false;\n console.log('[DatabaseInitializer] Database connection closed');\n }\n\n getDatabasePath() {\n return this.dbPath;\n }\n}\n\nconst databaseInitializer = new DatabaseInitializer();\n\nmodule.exports = databaseInitializer; "], ["/glass/src/ui/listen/audioCore/aec.js", "var createAecModule = (() => {\n var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;\n return (\nasync function(moduleArg = {}) {\n var moduleRtn;\n\nvar Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window==\"object\";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!=\"undefined\";var ENVIRONMENT_IS_NODE=typeof process==\"object\"&&process.versions?.node&&process.type!=\"renderer\";var arguments_=[];var thisProgram=\"./this.program\";var quit_=(status,toThrow)=>{throw toThrow};if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory=\"\";var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(\".\",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open(\"GET\",url,false);xhr.responseType=\"arraybuffer\";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:\"same-origin\"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+\" : \"+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var readyPromiseResolve,readyPromiseReject;var wasmMemory;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);Module[\"HEAP16\"]=HEAP16=new Int16Array(b);Module[\"HEAPU8\"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module[\"preRun\"]){if(typeof Module[\"preRun\"]==\"function\")Module[\"preRun\"]=[Module[\"preRun\"]];while(Module[\"preRun\"].length){addOnPreRun(Module[\"preRun\"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(!Module[\"noFSInit\"]&&!FS.initialized)FS.init();TTY.init();wasmExports[\"v\"]();FS.ignorePermissions=false}function postRun(){if(Module[\"postRun\"]){if(typeof Module[\"postRun\"]==\"function\")Module[\"postRun\"]=[Module[\"postRun\"]];while(Module[\"postRun\"].length){addOnPostRun(Module[\"postRun\"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module[\"monitorRunDependencies\"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module[\"monitorRunDependencies\"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module[\"onAbort\"]?.(what);what=\"Aborted(\"+what+\")\";err(what);ABORT=true;what+=\". Build with -sASSERTIONS for more info.\";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return base64Decode(\"AGFzbQEAAAABhgETYAJ/fwF/YAN/f38Bf2ACf38AYAN/f38AYAF/AGAEf39/fwBgAX8Bf2AFf39/f38AYAAAYAZ/f39/f38AYAR/f39/AX9gBX9/f39/AX9gAAF/YAZ/f39/f38Bf2AHf39/f39/fwBgBH9+f38Bf2AHf39/f39/fwF/YAJ+fwF/YAN/fn8BfgJ5FAFhAWEADAFhAWIABAFhAWMAAgFhAWQAAwFhAWUABQFhAWYACgFhAWcACgFhAWgACQFhAWkAAAFhAWoABwFhAWsABAFhAWwADwFhAW0ADQFhAW4AAAFhAW8AAAFhAXAAAAFhAXEAAwFhAXIACAFhAXMABgFhAXQABgPKAcgBBAYCDQYHAQEACAMECAsDBwMGCAYDAwEBBAcEAwMDAgICBQAACwEAAQMDBAoEBAQABAIDARABBgAOAwADAAMHAAMCAwMGBAQEBgQAAw4HAgUDBgcLBAMAAgYFBAYECBEGAgQBBAAAAAUDBggIAwIAAwAFAAAAAAcABAIMBAcGCgQCAgUFAAACAgIAAgIDAgAFBQEBAwUFBQUFAAAEBAAAAQAAAgYEBxIEAAAAAAAAAQAAAAAAAAAAAAYCAgYCAQkJBwcFBQEBBAgEBQFwAX9/BQcBAYICgIACBggBfwFB4PkECwdDDgF1AgABdgDbAQF3AJIBAXgAkAEBeQCPAQF6ABgBQQAUAUIAjQEBQwCMAQFEANoBAUUAkQEBRgCOAQFHANEBAUgBAAnUAQEAQQELfswBwgG6AUtOaIkBUIsBhgGEATmIAYcBhQEkNIMBVY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2AhAMAQsgCSAANgIUCyAARQ0BCyAAIAk2AhggAigCECIBBEAgACABNgIQIAEgADYCGAsgAigCFCIBRQ0AIAAgATYCFCABIAA2AhgLAkAgA0EPTQRAIAIgAyAGaiIAQQNyNgIEIAAgAmoiACAAKAIEQQFyNgIEDAELIAIgBkEDcjYCBCACIAZqIgUgA0EBcjYCBCADIAVqIAM2AgAgCARAIAhBeHFB7PMAaiEAQdjzACgCACEBAn9BASAIQQN2dCIHIARxRQRAQcTzACAEIAdyNgIAIAAMAQsgACgCCAshBCAAIAE2AgggBCABNgIMIAEgADYCDCABIAQ2AggLQdjzACAFNgIAQczzACADNgIACyACQQhqIQALIApBEGokACAAC/gBAgR/AX4jAEEgayIFJAACQAJAIAEgASACaiICSwRAQQAhAQwBC0EAIQEgAyAEakEBa0EAIANrca0gAiAAKAIAIgdBAXQiBiACIAZLGyICQQhBBCAEQQFGGyIGIAIgBksbIgatfiIJQiCIQgBSDQAgCaciCEGAgICAeCADa0sNAEEAIQIgBSAHBH8gBSAEIAdsNgIcIAUgACgCBDYCFCADBUEACzYCGCAFQQhqIAMgCCAFQRRqEDUgBSgCCEEBRw0BIAUoAhAhAiAFKAIMIQELIAEgAkG85wAQJAALIAUoAgwhASAAIAY2AgAgACABNgIEIAVBIGokAAt0AQF/IAJFBEAgACgCBCABKAIERg8LIAAgAUYEQEEBDwsgASgCBCICLQAAIQECQCAAKAIEIgMtAAAiAEUNACAAIAFHDQADQCACLQABIQEgAy0AASIARQ0BIAJBAWohAiADQQFqIQMgACABRg0ACwsgACABRgucBAEIfyMAQRBrIgMkACADIAE2AgQgAyAANgIAIANCoICAgA43AggCfwJAAkACQCACKAIQIgkEQCACKAIUIgANAQwCCyACKAIMIgBFDQEgAigCCCIBIABBA3RqIQQgAEEBa0H/////AXFBAWohBiACKAIAIQADQAJAIAAoAgQiBUUNACADKAIAIAAoAgAgBSADKAIEKAIMEQEARQ0AQQEMBQtBASABKAIAIAMgASgCBBEAAA0EGiAAQQhqIQA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IANyNgIAIAIMAQsgAigCCAshASACIAA2AgggASAANgIMIAAgAjYCDCAAIAE2AggPC0EfIQMgAUH///8HTQRAIAFBJiABQQh2ZyICa3ZBAXEgAkEBdGtBPmohAwsgACADNgIcIABCADcCECADQQJ0QfT1AGohAgJAAkBByPMAKAIAIgRBASADdCIHcUUEQEHI8wAgBCAHcjYCACACIAA2AgAgACACNgIYDAELIAFBGSADQQF2a0EAIANBH0cbdCEDIAIoAgAhAgNAIAIiBCgCBEF4cSABRg0CIANBHXYhAiADQQF0IQMgBCACQQRxaiIHKAIQIgINAAsgByAANgIQIAAgBDYCGAsgACAANgIMIAAgADYCCA8LIAQoAggiASAANgIMIAQgADYCCCAAQQA2AhggACAENgIMIAAgATYCCAsLGwAgACABQZD5ACgCACIAQcoAIAAbEQIAEB0AC4YBAQF/IAJBAE4EQAJ/IAMoAgQEQCADKAIIIgQEQCADKAIAIAQgASACED8MAgsLIAEgAkUNABpB2fkALQAAGiACIAEQHAsiA0UEQCAAIAI2AgggACABNgIEIABBATYCAA8LIAAgAjYCCCAAIAM2AgQgAEEANgIADwsgAEEANgIEIABBATYCAAsiAQF/IAAoAgAiACAAQR91IgJzIAJrIABBf3NBH3YgARAqC2sBA38jAEGAAWsiBCQAIAAoAgAhAANAIAIgBGogAEEPcSIDQTByIANBN2ogA0EKSRs6AH8gAkEBayECIABBD0sgAEEEdiEADQALIAFBAUG8G0ECIAIgBGpBgAFqQQAgAmsQFyAEQYABaiQACzgAAkAgAkGAgMQARg0AIAAgAiABKAIQEQAARQ0AQQEPCyADRQRAQQAPCyAAIAMgBCABKAIMEQEAC44EAQx/IAFBAWshDiAAKAIEIQogACgCACELIAAoAgghDAJAA0AgBQ0BAn8CQCACIARJDQADQCABIARqIQUCQAJAAkAgAiAEayIHQQdNBEAgAiAERw0BIAIhBAwFCwJAIAVBA2pBfHEiBiAFayIDBEBBACEAA0AgACAFai0AAEEKRg0FIAMgAEEBaiIARw0ACyADIAdBCGsiAE0NAQwDCyAHQ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HRrIgRBD3UgBEEQdWxBgIACakEQdSIEIARBjvv//wdsQYCAAWpBD3ZB1cAAakH//wNxbEEBdEGAgIrvAWtBEHUgBGxBgIABakEPdSAEayIEQf//AXNBAWogBEEAThsMAQtBACAEQYCAAnENABpBgYB+Qf//ASAEGws7AQIgA0EBaiIDIABHDQALC0EEIQEDQCAAIAFvBEADQEECIQMCQAJAAkAgAUECaw4DAAECAQtBAyEDDAELIAFBAmohAwsgACAAIAAgAyADIANsIABKGyADQYD6AUobIgFvDQALCyACIAE2AgggAiAAIAFtIgA2AgwgAkEIaiECIABBAUoNAAsLC7QCAAJAAkACQAJAAkACQAJAAkACQAJAAkAgAUEJaw4SAAgJCggJAQIDBAoJCgoICQUGBwsgAiACKAIAIgFBBGo2AgAgACABKAIANgIADwsgAiACKAIAIgFBBGo2AgAgACABMgEANwMADwsgAiACKAIAIgFBBGo2AgAgACABMwEANwMADwsgAiACKAIAIgFBBGo2AgAgACABMAAANwMADwsgAiACKAIAIgFBBGo2AgAgACABMQAANwMADwsgAiACKAIAQQdqQXhxIgFBCGo2AgAgACABKwMAOQMADwsACw8LIAIgAigCACIBQQRqNgIAIAAgATQCADcDAA8LIAIgAigCACIBQQRqNgIAIAAgATUCADcDAA8LIAIgAigCAEEHakF4cSIBQQhqNgIAIAAgASkDADcDAAtvAQV/IAAoAgAiAywAAEEwayIBQQlLBEBBAA8LA0BBfyEEIAJBzJmz5gBNBEBBfyABIAJBCmwiBWogASAFQf////8Hc0sbIQQLIAAgA0EBaiIFNgIAIAMsAAEgBCECIAUhA0EwayIBQQpJDQALIAILvwkBA38jAEHwAGsiBSQAIAUgATYCKCAFIAA2AiQgBSACNgIsQaT5AEGk+QAoAgAiAkEBajYCAAJAAkACQAJAAn9BACACQQBIDQAaQQFBzPkALQAADQAaQcz5AEEBOgAAQcj5AEHI+QAoAgBBAWo2AgBBAgtB/wFxIgJBAkcEQCACQQFxRQ0BIAVBGGogACABKAIYEQIAIAUgBSgCHEEAIAUoAhgiAB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BUEgaiQAIAEPCyACEAEACwQAQQELtgMBA38gAUFwcSIDKAIIIgRFBEAgAyECA0AgAigCACIEIAI2AgQgBCICKAIIIgRFDQALCyADIAQ2AgggBCAEKAIAIgJBEGs2AgAgAkEQRgRAIAAhAwNAAkACQCABQQRxRQRAIAMgAUF+cUEEaiIAIAMoAgAiAiABIAJGGzYCACABIAJHDQEDQCAAQXBxIgQoAggiAkUEQCAEIQEDQCABKAIAIgIgATYCBCACIgEoAggiAkUNAAsLIAQgAjYCCAJAIABBCXFBAUcEQAJAIABBCHEiAUUEQCACLQARQQFxDQELQRFBACABGyEBDAILIAIoAgQiAUUEQEEAIQEMAgsgBCABNgIIIAMgAEFzcSADKAIAIgEgACABRiIAGzYCACAARQRAIAQgAjYCCCABIQAMAwsgAhA+DAULIAMgAEFzcSADKAIAIgEgACABRiICGzYCACABIQAgAkUNAQwECyADIAEgAygCACIBIAAgAUYbNgIAIAAgAUcgASEADQALA0AgAigCBCACED4iAg0ACwwCCyADIAFBfnEgAygCACICIAEgAkYiABs2AgAgAA0BCyACIQEMAQsLCwtoAQN/IAAoAgQiAigCACEAAkADQAJAIAICfyAAQQJxRQRAIABBEWsiAUEBckEAIAEbDAELIABBCHFFDQEgAEF2cQsgAigCACIBIAAgAUYiAxs2AgAgASEAIANFDQEMAgsLIAIgABB0CwuUAgICfwF+IwBBEGsiAyQAAn9BACACRQ0AGgNAAkACQAJAQQACfyABQf////8HIAIgAkH/////B08bEEMiBEF/RwRAIAMgBDYCDCADQQQ6AAhByOkAIARFDQEaIAIgBEkNAiABIARqIQEgAiAEayECDAQLIANBADoACyADQQA7AAkgA0EAOgAIIANBwPMAKAIAIgQ2AgwgBEEbRg0DIANBCGoLKQMAIgVC/wGDQgRRDQQaIAAtAABBBEcEQEH4+ABBADYCAEElIAAQAkH4+AAoAgBB+PgAQQA2AgBBAUYNAgsgACAFNwIAQQEMBAsgBCACQZDrABAvAAsQACAAIAU3AgAQAQALIAINAAtBAAsgA0EQaiQAC4M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j4AEEANgIAQQFGDQMNAQtBAAwBC0EBCyAEQYCAgIB4ckGAgICAeEcEQCAAEBQLIANBEGokAA8LEAAhAyAEQYCAgIB4ckGAgICAeEYNACAAEBQgAxABAAsgAxABAAtdAQF/IwBBMGsiBCQAIARBATYCDCAEQgE3AhQgBEGQygA2AgggBCADOgAvIAQgBEEvaq1CgICAgIAIhDcDICAEIARBIGo2AhAgACABIARBCGogAhEDACAEQTBqJAALzAEBAX8jAEEQayIBJAACQAJAIAMEQANAAkACQCACQf////8HIAMgA0H/////B08bEEMiBEF/RwRAIAEgBDYCDCABQQQ6AAggBEUEQEHI6QAhAwwGCyADIARPDQEgBCADQZDrABAvAAsgAUEAOgALIAFBADsACSABQQA6AAggAUHA8wAoAgAiBDYCDCAEQRtGDQEgAUEIaiEDDAQLIAIgBGohAiADIARrIQMLIAMNAAsLIABBBDoAAAwBCyAAIAMpAwA3AgALIAFBEGokAAvTAQICfgV/IAAoAggiBigCBCIHQv////8PIAYpAwgiAyADQv////8PWhunayIFQQAgBSAHTRsiBSACIAIgBUsbIggEQCAGKAIAIAetIgQgAyADIARWG6dqIAEgCPwKAAALIAYgAyAIrXw3AwgCQAJAIAIgBU0NAEHI6QApAwAiA0L/AYNCBFENACAALQAAQQRHBEBB+PgAQQA2AgBBJSAAEAJB+PgAKAIAQfj4AEEANgIAQQFGDQILIAAgAzcCAEEBIQkLIAkPCxAAIAAgAzcCABABAAtQAQF/IAAoAggiACgCACAAKAIIIgNrIAJJBEAgACADIAJBAUEBEBkgACgCCCEDCyACBEAgACgCBCADaiABIAL8CgAACyAAIAIgA2o2AghBAAuVAwECfyMAQTBrIgMkAEH4+ABBADYCACADQQQ6AAggAyABNgIQQSsgA0EIakGc6AAgAhAFIQFB+PgAKAIAIQJB+PgAQQA2AgACQAJAIAJBAUYNAAJAAkAgAQRAIAMtAAhBBEcNAUH4+ABBADYCACADQQA2AiggA0IENwIgIANBuOoANgIYIANBATYCHEEsIANBGGpBwOoAEANB+PgAKAIA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kEIC2ooAgAhACACKAIAIQULIAMgADYCBCADIAU2AgAgAUEQaiQAIAMgAykDADcCFEGE+QAtAAAhACADIANBD2o2AiQgAyADQRRqNgIgIAMgA0EQajYCHAJAAkACQAJAAkAgAEUEQCADQgA3AigMAQtBhPkAQQE6AABB0PkAKAIAIQZB0PkAQQA2AgAgA0EANgIoIAMgBjYCLCAGDQELAkAgA0EoaiIBKAIADQAgASgCBCIARQ0AIAAgACgCACIAQQFrNgIAIABBAUcNACABQQRqEEILIANBHGogA0E/akGY7AAQaQwBCyADIAY2AjAgBkEIaiEBIAYoAghFBEBB+PgAQQA2AgBBJiABEAgaQfj4ACgCAEH4+ABBADYCAEEBRg0CC0EAIQJBpPkAKAIAQf////8HcQRAQcj5ACgCAEEARyECC0H4+ABBADYCAEEoIANBHGogBkEQakHw6wAQBEH4+AAoAgBB+PgAQQA2AgBBAUYEQBAAIQUgASACEDIMAwsgASACEDJBhPkAQQE6AABB0PkAKAIAIQBB0PkAIAY2AgAgAyAANgI4IANBATYCNCAARQ0AIAAgACgCACIAQQFrNgIAIABBAUcNACADQThqEEILIANBQGskAA8LEAAhBQsgBiAGKAIAIgBBAWs2AgAgAEEBRgRAIANBMGoQQgsgBRABAAsMACAAQczoACABEBsLDAAgAEG06AAgARAbCwwAIABBhOgAIAEQGwsMACAAQZzoACABEBsLrAMCBn8CfiMAQRBrIgIkACACQQA2AgwCfwJAIAFBgAFPBEAgAUGAEEkNASABQYCABE8EQCACIAFBP3FBgAFyOgAPIAIgAUESdkHwAXI6AAwgAiABQQZ2QT9xQYABcjoADiACIAFBDHZBP3FBgAFyOgANQQQMAwsgAiABQT9xQYABcjoADiACIAFBDHZB4AFyOgAMIAIgAUEGdkE/cUGAAXI6AA1BAwwCCyACIAE6AAxBAQwBCyACIAFBP3FBgAFyOgANIAIgAUEGdkHAAXI6AAxBAgshASAAKAIIIgQoAgQiBUL/////DyAEKQMIIgggCEL/////D1obp2siA0EAIAMgBU0bIgMgASABIANLGyIGBEAg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AI8AAAANAAAAsi0AACIAAACgAAAAEwAAALItAAAiAAAApwAAABUAAADULQAALAAAAHsAAAANAAAA1C0AACwAAAB5AAAADQAAANQtAAAsAAAAdgAAAA0AAADULQAALAAAAG4AAAAVAAAABC4AACoAAAAxAAAARQAAAAQuAAAqAAAANwAAAA4AAAAELgAAKgAAADgAAABLAAAALi4AABYAAAAELgAAKgAAAEUAAAANAAAABC4AACoAAACEAAAADQAAAEguAAAoAAAA6AAAACMAAABILgAAKAAAAPUAAAA6AAAAcC4AAEUAAAC1LgAAHwAAANQuAAAyAAAARAAAABEAAAAGLwAAFwAAANQuAAAyAAAASgAAABEAAAAdLwAAHAAAANQuAAAyAAAAkQAAABIAAAA0JQAARCUAAFUlAABnJQAAdyUAAIclAACaJQAArCUAALklAADHJQAA3CUAAOglAADzJQAACCYAAB0mAAAsJgAAOiYAAE0mAABzJgAAqyYAAMQmAADbJgAA5yYAAPAmAAD6JgAACicAACEnAAAvJwAAPScAAEonAABeJwAAZicAAIEnAACPJwAAnycAALUnAADKJwAA1ScAAOsnAAD4JwAAAygAAA4oAACMKwAAlCsAAKQrAAC1KwAAxCsAANMrAADlKwAA9isAAAIsAAALLAAAGywAACYsAAAwLAAABiUAAD0sAABKLAAAViwAAGcsAAB5LAAAhywAAJ0sAACpLAAAtCwAALwsAADFLAAA0CwAANssAADoLAAA9CwAAAAtAAASLQAAGi0AACgtAAA0LQAAQy0AAFYtAABhLQAAbC0AAHktAACELQAAji0AAJMtAACsMAAACgAAABwAAAAF\")}function getBinarySync(file){if(ArrayBuffer.isView(file)){return file}if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw\"both async and sync fetching of the wasm failed\"}async function getWasmBinary(binaryFile){return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports[\"u\"];updateMemoryViews();wasmTable=wasmExports[\"H\"];assignWasmExports(wasmExports);removeRunDependency(\"wasm-instantiate\");return wasmExports}addRunDependency(\"wasm-instantiate\");function receiveInstantiationResult(result){return receiveInstance(result[\"instance\"])}var info=getWasmImports();if(Module[\"instantiateWasm\"]){return new Promise((resolve,reject)=>{Module[\"instantiateWasm\"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name=\"ExitStatus\";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var base64Decode=b64=>{var b1,b2,i=0,j=0,bLength=b64.length;var output=new Uint8Array((bLength*3>>2)-(b64[bLength-2]==\"=\")-(b64[bLength-1]==\"=\"));for(;i>4;output[j+1]=b1<<4|b2>>2;output[j+2]=b2<<6|base64ReverseLookup[b64.charCodeAt(i+3)]}return output};var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionLast=0;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var uncaughtExceptionCount=0;var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=ptr}throw exceptionLast};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd)+1;if(sizeabort(\"\");var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||\"./this.program\";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator==\"object\"&&navigator.language||\"C\").replace(\"-\",\"_\")+\".UTF-8\";var env={USER:\"web_user\",LOGNAME:\"web_user\",PATH:\"/\",PWD:\"/\",HOME:\"/home/web_user\",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module[\"onExit\"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var PATH={isAbs:path=>path.charAt(0)===\"/\",splitPath:filename=>{var splitPathRe=/^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last===\".\"){parts.splice(i,1)}else if(last===\"..\"){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift(\"..\")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.slice(-1)===\"/\";path=PATH.normalizeArray(path.split(\"/\").filter(p=>!!p),!isAbsolute).join(\"/\");if(!path&&!isAbsolute){path=\".\"}if(path&&trailingSlash){path+=\"/\"}return(isAbsolute?\"/\":\"\")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return\".\"}if(dir){dir=dir.slice(0,-1)}return root+dir},basename:path=>path&&path.match(/([^\\/]+|\\/)\\/*$/)[1],join:(...paths)=>PATH.normalize(paths.join(\"/\")),join2:(l,r)=>PATH.normalize(l+\"/\"+r)};var initRandomFill=()=>view=>crypto.getRandomValues(view);var randomFill=view=>{(randomFill=initRandomFill())(view)};var PATH_FS={resolve:(...args)=>{var resolvedPath=\"\",resolvedAbsolute=false;for(var i=args.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?args[i]:FS.cwd();if(typeof path!=\"string\"){throw new TypeError(\"Arguments to path.resolve must be strings\")}else if(!path){return\"\"}resolvedPath=path+\"/\"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split(\"/\").filter(p=>!!p),!resolvedAbsolute).join(\"/\");return(resolvedAbsolute?\"/\":\"\")+resolvedPath||\".\"},relative:(from,to)=>{from=PATH_FS.resolve(from).slice(1);to=PATH_FS.resolve(to).slice(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!==\"\")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split(\"/\"));var toParts=trim(to.split(\"/\"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str=\"\";while(idx>10,56320|ch&1023)}}return str};var FS_stdin_getChar_buffer=[];var intArrayFromString=(stringy,dontAddNull,length)=>{var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array};var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var result=null;if(typeof window!=\"undefined\"&&typeof window.prompt==\"function\"){result=window.prompt(\"Input: \");if(result!==null){result+=\"\\n\"}}else{}if(!result){return null}FS_stdin_getChar_buffer=intArrayFromString(result,true)}return FS_stdin_getChar_buffer.shift()};var TTY={ttys:[],init(){},shutdown(){},register(dev,ops){TTY.ttys[dev]={input:[],output:[],ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close(stream){stream.tty.ops.fsync(stream.tty)},fsync(stream){stream.tty.ops.fsync(stream.tty)},read(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i0){out(UTF8ArrayToString(tty.output));tty.output=[]}},ioctl_tcgets(tty){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(tty,optional_actions,data){return 0},ioctl_tiocgwinsz(tty){return[24,80]}},default_tty1_ops:{put_char(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync(tty){if(tty.output?.length>0){err(UTF8ArrayToString(tty.output));tty.output=[]}}}};var mmapAlloc=size=>{abort()};var MEMFS={ops_table:null,mount(mount){return MEMFS.createNode(null,\"/\",16895,0)},createNode(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}MEMFS.ops_table||={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}};var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.atime=node.mtime=node.ctime=Date.now();if(parent){parent.contents[name]=node;parent.atime=parent.mtime=parent.ctime=node.atime}return node},getFileDataAsTypedArray(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.atime);attr.mtime=new Date(node.mtime);attr.ctime=new Date(node.ctime);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr(node,attr){for(const key of[\"mode\",\"atime\",\"mtime\",\"ctime\"]){if(attr[key]!=null){node[key]=attr[key]}}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup(parent,name){throw MEMFS.doesNotExistError},mknod(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename(old_node,new_dir,new_name){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){if(FS.isDir(old_node.mode)){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}FS.hashRemoveNode(new_node)}delete old_node.parent.contents[old_node.name];new_dir.contents[new_name]=old_node;old_node.name=new_name;new_dir.ctime=new_dir.mtime=old_node.parent.ctime=old_node.parent.mtime=Date.now()},unlink(parent,name){delete parent.contents[name];parent.ctime=parent.mtime=Date.now()},rmdir(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.ctime=parent.mtime=Date.now()},readdir(node){return[\".\",\"..\",...Object.keys(node.contents)]},symlink(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length{var arrayBuffer=await readAsync(url);return new Uint8Array(arrayBuffer)};var FS_createDataFile=(...args)=>FS.createDataFile(...args);var getUniqueRunDependency=id=>id;var preloadPlugins=[];var FS_handledByPreloadPlugin=(byteArray,fullname,finish,onerror)=>{if(typeof Browser!=\"undefined\")Browser.init();var handled=false;preloadPlugins.forEach(plugin=>{if(handled)return;if(plugin[\"canHandle\"](fullname)){plugin[\"handle\"](byteArray,fullname,finish,onerror);handled=true}});return handled};var FS_createPreloadedFile=(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency(`cp ${fullname}`);function processData(byteArray){function finish(byteArray){preFinish?.();if(!dontCreateFile){FS_createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}onload?.();removeRunDependency(dep)}if(FS_handledByPreloadPlugin(byteArray,fullname,finish,()=>{onerror?.();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url==\"string\"){asyncLoad(url).then(processData,onerror)}else{processData(url)}};var FS_modeStringToFlags=str=>{var flagModes={r:0,\"r+\":2,w:512|64|1,\"w+\":512|64|2,a:1024|64|1,\"a+\":1024|64|2};var flags=flagModes[str];if(typeof flags==\"undefined\"){throw new Error(`Unknown file open mode: ${str}`)}return flags};var FS_getMode=(canRead,canWrite)=>{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode};var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:\"/\",initialized:false,ignorePermissions:true,filesystems:null,syncFSRequests:0,readFiles:{},ErrnoError:class{name=\"ErrnoError\";constructor(errno){this.errno=errno}},FSStream:class{shared={};get object(){return this.node}set object(val){this.node=val}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(val){this.shared.flags=val}get position(){return this.shared.position}set position(val){this.shared.position=val}},FSNode:class{node_ops={};stream_ops={};readMode=292|73;writeMode=146;mounted=null;constructor(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.rdev=rdev;this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(val){val?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(val){val?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return FS.isDir(this.mode)}get isDevice(){return FS.isChrdev(this.mode)}},lookupPath(path,opts={}){if(!path){throw new FS.ErrnoError(44)}opts.follow_mount??=true;if(!PATH.isAbs(path)){path=FS.cwd()+\"/\"+path}linkloop:for(var nlinks=0;nlinks<40;nlinks++){var parts=path.split(\"/\").filter(p=>!!p);var current=FS.root;var current_path=\"/\";for(var i=0;i>>0)%FS.nameTable.length},hashAddNode(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode(parent,name){var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode(parent,name,mode,rdev){var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode(node){FS.hashRemoveNode(node)},isRoot(node){return node===node.parent},isMountpoint(node){return!!node.mounted},isFile(mode){return(mode&61440)===32768},isDir(mode){return(mode&61440)===16384},isLink(mode){return(mode&61440)===40960},isChrdev(mode){return(mode&61440)===8192},isBlkdev(mode){return(mode&61440)===24576},isFIFO(mode){return(mode&61440)===4096},isSocket(mode){return(mode&49152)===49152},flagsToPermissionString(flag){var perms=[\"r\",\"w\",\"rw\"][flag&3];if(flag&512){perms+=\"w\"}return perms},nodePermissions(node,perms){if(FS.ignorePermissions){return 0}if(perms.includes(\"r\")&&!(node.mode&292)){return 2}else if(perms.includes(\"w\")&&!(node.mode&146)){return 2}else if(perms.includes(\"x\")&&!(node.mode&73)){return 2}return 0},mayLookup(dir){if(!FS.isDir(dir.mode))return 54;var errCode=FS.nodePermissions(dir,\"x\");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate(dir,name){if(!FS.isDir(dir.mode)){return 54}try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,\"wx\")},mayDelete(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,\"wx\");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen(node,flags){if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!==\"r\"||flags&(512|64)){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},checkOpExists(op,err){if(!op){throw new FS.ErrnoError(err)}return op},MAX_OPEN_FDS:4096,nextfd(){for(var fd=0;fd<=FS.MAX_OPEN_FDS;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStreamChecked(fd){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}return stream},getStream:fd=>FS.streams[fd],createStream(stream,fd=-1){stream=Object.assign(new FS.FSStream,stream);if(fd==-1){fd=FS.nextfd()}stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream(fd){FS.streams[fd]=null},dupStream(origStream,fd=-1){var stream=FS.createStream(origStream,fd);stream.stream_ops?.dup?.(stream);return stream},doSetAttr(stream,node,attr){var setattr=stream?.stream_ops.setattr;var arg=setattr?stream:node;setattr??=node.node_ops.setattr;FS.checkOpExists(setattr,63);setattr(arg,attr)},chrdev_stream_ops:{open(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;stream.stream_ops.open?.(stream)},llseek(){throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push(...m.mounts)}return mounts},syncfs(populate,callback){if(typeof populate==\"function\"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`)}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount(type,opts,mountpoint){var root=mountpoint===\"/\";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type,opts,mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup(parent,name){return parent.node_ops.lookup(parent,name)},mknod(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name){throw new FS.ErrnoError(28)}if(name===\".\"||name===\"..\"){throw new FS.ErrnoError(20)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},statfs(path){return FS.statfsNode(FS.lookupPath(path,{follow:true}).node)},statfsStream(stream){return FS.statfsNode(stream.node)},statfsNode(node){var rtn={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:FS.nextInode,ffree:FS.nextInode-1,fsid:42,flags:2,namelen:255};if(node.node_ops.statfs){Object.assign(rtn,node.node_ops.statfs(node.mount.opts.root))}return rtn},create(path,mode=438){mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir(path,mode=511){mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree(path,mode){var dirs=path.split(\"/\");var d=\"\";for(var dir of dirs){if(!dir)continue;if(d||PATH.isAbs(path))d+=\"/\";d+=dir;try{FS.mkdir(d,mode)}catch(e){if(e.errno!=20)throw e}}},mkdev(path,mode,dev){if(typeof dev==\"undefined\"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink(oldpath,newpath){if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename(old_path,new_path){var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!==\".\"){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!==\".\"){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,\"w\");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name);old_node.parent=new_dir}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir(path){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;var readdir=FS.checkOpExists(node.node_ops.readdir,54);return readdir(node)},unlink(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink(path){var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return link.node_ops.readlink(link)},stat(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;var getattr=FS.checkOpExists(node.node_ops.getattr,63);return getattr(node)},fstat(fd){var stream=FS.getStreamChecked(fd);var node=stream.node;var getattr=stream.stream_ops.getattr;var arg=getattr?stream:node;getattr??=node.node_ops.getattr;FS.checkOpExists(getattr,63);return getattr(arg)},lstat(path){return FS.stat(path,true)},doChmod(stream,node,mode,dontFollow){FS.doSetAttr(stream,node,{mode:mode&4095|node.mode&~4095,ctime:Date.now(),dontFollow})},chmod(path,mode,dontFollow){var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}FS.doChmod(null,node,mode,dontFollow)},lchmod(path,mode){FS.chmod(path,mode,true)},fchmod(fd,mode){var stream=FS.getStreamChecked(fd);FS.doChmod(stream,stream.node,mode,false)},doChown(stream,node,dontFollow){FS.doSetAttr(stream,node,{timestamp:Date.now(),dontFollow})},chown(path,uid,gid,dontFollow){var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}FS.doChown(null,node,dontFollow)},lchown(path,uid,gid){FS.chown(path,uid,gid,true)},fchown(fd,uid,gid){var stream=FS.getStreamChecked(fd);FS.doChown(stream,stream.node,false)},doTruncate(stream,node,len){if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,\"w\");if(errCode){throw new FS.ErrnoError(errCode)}FS.doSetAttr(stream,node,{size:len,timestamp:Date.now()})},truncate(path,len){if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}FS.doTruncate(null,node,len)},ftruncate(fd,len){var stream=FS.getStreamChecked(fd);if(len<0||(stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.doTruncate(stream,stream.node,len)},utime(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;var setattr=FS.checkOpExists(node.node_ops.setattr,63);setattr(node,{atime,mtime})},open(path,flags,mode=438){if(path===\"\"){throw new FS.ErrnoError(44)}flags=typeof flags==\"string\"?FS_modeStringToFlags(flags):flags;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;var isDirPath;if(typeof path==\"object\"){node=path}else{isDirPath=path.endsWith(\"/\");var lookup=FS.lookupPath(path,{follow:!(flags&131072),noent_okay:true});node=lookup.node;path=lookup.path}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else if(isDirPath){throw new FS.ErrnoError(31)}else{node=FS.mknod(path,mode|511,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node,path:FS.getPath(node),flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(created){FS.chmod(node,mode&511)}if(Module[\"logReadFiles\"]&&!(flags&1)){if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close(stream){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed(stream){return stream.fd===null},llseek(stream,offset,whence){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read(stream,buffer,offset,length,position){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!=\"undefined\";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write(stream,buffer,offset,length,position,canOwn){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!=\"undefined\";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},mmap(stream,length,position,prot,flags){if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}if(!length){throw new FS.ErrnoError(28)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync(stream,buffer,offset,length,mmapFlags){if(!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},ioctl(stream,cmd,arg){if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile(path,opts={}){opts.flags=opts.flags||0;opts.encoding=opts.encoding||\"binary\";if(opts.encoding!==\"utf8\"&&opts.encoding!==\"binary\"){throw new Error(`Invalid encoding type \"${opts.encoding}\"`)}var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding===\"utf8\"){buf=UTF8ArrayToString(buf)}FS.close(stream);return buf},writeFile(path,data,opts={}){opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data==\"string\"){data=new Uint8Array(intArrayFromString(data,true))}if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error(\"Unsupported data type\")}FS.close(stream)},cwd:()=>FS.currentPath,chdir(path){var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,\"x\");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories(){FS.mkdir(\"/tmp\");FS.mkdir(\"/home\");FS.mkdir(\"/home/web_user\")},createDefaultDevices(){FS.mkdir(\"/dev\");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length,llseek:()=>0});FS.mkdev(\"/dev/null\",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev(\"/dev/tty\",FS.makedev(5,0));FS.mkdev(\"/dev/tty1\",FS.makedev(6,0));var randomBuffer=new Uint8Array(1024),randomLeft=0;var randomByte=()=>{if(randomLeft===0){randomFill(randomBuffer);randomLeft=randomBuffer.byteLength}return randomBuffer[--randomLeft]};FS.createDevice(\"/dev\",\"random\",randomByte);FS.createDevice(\"/dev\",\"urandom\",randomByte);FS.mkdir(\"/dev/shm\");FS.mkdir(\"/dev/shm/tmp\")},createSpecialDirectories(){FS.mkdir(\"/proc\");var proc_self=FS.mkdir(\"/proc/self\");FS.mkdir(\"/proc/self/fd\");FS.mount({mount(){var node=FS.createNode(proc_self,\"fd\",16895,73);node.stream_ops={llseek:MEMFS.stream_ops.llseek};node.node_ops={lookup(parent,name){var fd=+name;var stream=FS.getStreamChecked(fd);var ret={parent:null,mount:{mountpoint:\"fake\"},node_ops:{readlink:()=>stream.path},id:fd+1};ret.parent=ret;return ret},readdir(){return Array.from(FS.streams.entries()).filter(([k,v])=>v).map(([k,v])=>k.toString())}};return node}},{},\"/proc/self/fd\")},createStandardStreams(input,output,error){if(input){FS.createDevice(\"/dev\",\"stdin\",input)}else{FS.symlink(\"/dev/tty\",\"/dev/stdin\")}if(output){FS.createDevice(\"/dev\",\"stdout\",null,output)}else{FS.symlink(\"/dev/tty\",\"/dev/stdout\")}if(error){FS.createDevice(\"/dev\",\"stderr\",null,error)}else{FS.symlink(\"/dev/tty1\",\"/dev/stderr\")}var stdin=FS.open(\"/dev/stdin\",0);var stdout=FS.open(\"/dev/stdout\",1);var stderr=FS.open(\"/dev/stderr\",1)},staticInit(){FS.nameTable=new Array(4096);FS.mount(MEMFS,{},\"/\");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={MEMFS}},init(input,output,error){FS.initialized=true;input??=Module[\"stdin\"];output??=Module[\"stdout\"];error??=Module[\"stderr\"];FS.createStandardStreams(input,output,error)},quit(){FS.initialized=false;for(var stream of FS.streams){if(stream){FS.close(stream)}}},findObject(path,dontResolveLastLink){var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath(path,dontResolveLastLink){try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path===\"/\"}catch(e){ret.error=e.errno}return ret},createPath(parent,path,canRead,canWrite){parent=typeof parent==\"string\"?parent:FS.getPath(parent);var parts=path.split(\"/\").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){if(e.errno!=20)throw e}parent=current}return current},createFile(parent,name,properties,canRead,canWrite){var path=PATH.join2(typeof parent==\"string\"?parent:FS.getPath(parent),name);var mode=FS_getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile(parent,name,data,canRead,canWrite,canOwn){var path=name;if(parent){parent=typeof parent==\"string\"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS_getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data==\"string\"){var arr=new Array(data.length);for(var i=0,len=data.length;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]}setDataGetter(getter){this.getter=getter}cacheLength(){var xhr=new XMLHttpRequest;xhr.open(\"HEAD\",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error(\"Couldn't load \"+url+\". Status: \"+xhr.status);var datalength=Number(xhr.getResponseHeader(\"Content-length\"));var header;var hasByteServing=(header=xhr.getResponseHeader(\"Accept-Ranges\"))&&header===\"bytes\";var usesGzip=(header=xhr.getResponseHeader(\"Content-Encoding\"))&&header===\"gzip\";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error(\"invalid range (\"+from+\", \"+to+\") or no bytes requested!\");if(to>datalength-1)throw new Error(\"only \"+datalength+\" bytes available! programmer error!\");var xhr=new XMLHttpRequest;xhr.open(\"GET\",url,false);if(datalength!==chunkSize)xhr.setRequestHeader(\"Range\",\"bytes=\"+from+\"-\"+to);xhr.responseType=\"arraybuffer\";if(xhr.overrideMimeType){xhr.overrideMimeType(\"text/plain; charset=x-user-defined\")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error(\"Couldn't load \"+url+\". Status: \"+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||\"\",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==\"undefined\"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==\"undefined\")throw new Error(\"doXHR failed!\");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out(\"LazyFiles on gzip forces download of the whole file when length is accessed\")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true}get length(){if(!this.lengthKnown){this.cacheLength()}return this._length}get chunkSize(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}if(typeof XMLHttpRequest!=\"undefined\"){if(!ENVIRONMENT_IS_WORKER)throw\"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc\";var lazyArray=new LazyUint8Array;var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=(...args)=>{FS.forceLoadFile(node);return fn(...args)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr,allocated:true}};node.stream_ops=stream_ops;return node}};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):\"\";var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=SYSCALLS.getStreamFromFD(dirfd);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return dir+\"/\"+path},writeStat(buf,stat){HEAP32[buf>>2]=stat.dev;HEAP32[buf+4>>2]=stat.mode;HEAPU32[buf+8>>2]=stat.nlink;HEAP32[buf+12>>2]=stat.uid;HEAP32[buf+16>>2]=stat.gid;HEAP32[buf+20>>2]=stat.rdev;HEAP64[buf+24>>3]=BigInt(stat.size);HEAP32[buf+32>>2]=4096;HEAP32[buf+36>>2]=stat.blocks;var atime=stat.atime.getTime();var mtime=stat.mtime.getTime();var ctime=stat.ctime.getTime();HEAP64[buf+40>>3]=BigInt(Math.floor(atime/1e3));HEAPU32[buf+48>>2]=atime%1e3*1e3*1e3;HEAP64[buf+56>>3]=BigInt(Math.floor(mtime/1e3));HEAPU32[buf+64>>2]=mtime%1e3*1e3*1e3;HEAP64[buf+72>>3]=BigInt(Math.floor(ctime/1e3));HEAPU32[buf+80>>2]=ctime%1e3*1e3*1e3;HEAP64[buf+88>>3]=BigInt(stat.ino);return 0},writeStatFs(buf,stats){HEAP32[buf+4>>2]=stats.bsize;HEAP32[buf+40>>2]=stats.bsize;HEAP32[buf+8>>2]=stats.blocks;HEAP32[buf+12>>2]=stats.bfree;HEAP32[buf+16>>2]=stats.bavail;HEAP32[buf+20>>2]=stats.files;HEAP32[buf+24>>2]=stats.ffree;HEAP32[buf+28>>2]=stats.fsid;HEAP32[buf+44>>2]=stats.flags;HEAP32[buf+36>>2]=stats.namelen},doMsync(addr,stream,len,flags,offset){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(43)}if(flags&2){return 0}var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},getStreamFromFD(fd){var stream=FS.getStreamChecked(fd);return stream},varargs:undefined,getStr(ptr){var ret=UTF8ToString(ptr);return ret}};function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>numINT53_MAX?NaN:Number(num);function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);try{if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);HEAP64[newOffset>>3]=BigInt(stream.position);if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var doWritev=(stream,iov,iovcnt,offset)=>{var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2]=num;return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var getCFunc=ident=>{var func=Module[\"_\"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType===\"string\"){return UTF8ToString(ret)}if(returnType===\"boolean\")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i{var numericArgs=!argTypes||argTypes.every(type=>type===\"number\"||type===\"boolean\");var numericRet=returnType!==\"string\";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};for(var base64ReverseLookup=new Uint8Array(123),i=25;i>=0;--i){base64ReverseLookup[48+i]=52+i;base64ReverseLookup[65+i]=i;base64ReverseLookup[97+i]=26+i}base64ReverseLookup[43]=62;base64ReverseLookup[47]=63;FS.createPreloadedFile=FS_createPreloadedFile;FS.staticInit();MEMFS.doesNotExistError=new FS.ErrnoError(44);MEMFS.doesNotExistError.stack=\"\";{if(Module[\"noExitRuntime\"])noExitRuntime=Module[\"noExitRuntime\"];if(Module[\"preloadPlugins\"])preloadPlugins=Module[\"preloadPlugins\"];if(Module[\"print\"])out=Module[\"print\"];if(Module[\"printErr\"])err=Module[\"printErr\"];if(Module[\"wasmBinary\"])wasmBinary=Module[\"wasmBinary\"];if(Module[\"arguments\"])arguments_=Module[\"arguments\"];if(Module[\"thisProgram\"])thisProgram=Module[\"thisProgram\"]}Module[\"ccall\"]=ccall;Module[\"cwrap\"]=cwrap;var _AecNew,_AecCancelEcho,_AecDestroy,_malloc,_free,_setThrew,__emscripten_tempret_set,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_can_catch;function assignWasmExports(wasmExports){Module[\"_AecNew\"]=_AecNew=wasmExports[\"w\"];Module[\"_AecCancelEcho\"]=_AecCancelEcho=wasmExports[\"x\"];Module[\"_AecDestroy\"]=_AecDestroy=wasmExports[\"y\"];Module[\"_malloc\"]=_malloc=wasmExports[\"z\"];Module[\"_free\"]=_free=wasmExports[\"A\"];_setThrew=wasmExports[\"B\"];__emscripten_tempret_set=wasmExports[\"C\"];__emscripten_stack_restore=wasmExports[\"D\"];__emscripten_stack_alloc=wasmExports[\"E\"];_emscripten_stack_get_current=wasmExports[\"F\"];___cxa_can_catch=wasmExports[\"G\"]}var wasmImports={a:___cxa_find_matching_catch_2,q:___cxa_throw,b:___resumeException,p:___syscall_getcwd,r:__abort_js,t:_emscripten_resize_heap,n:_environ_get,o:_environ_sizes_get,k:_exit,s:_fd_close,l:_fd_seek,g:_fd_write,i:invoke_ii,f:invoke_iiii,m:invoke_iiiiii,c:invoke_vi,d:invoke_vii,e:invoke_viii,j:invoke_viiii,h:invoke_viiiii};var wasmExports=await createWasm();function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module[\"calledRun\"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module[\"onRuntimeInitialized\"]?.();postRun()}if(Module[\"setStatus\"]){Module[\"setStatus\"](\"Running...\");setTimeout(()=>{setTimeout(()=>Module[\"setStatus\"](\"\"),1);doRun()},1)}else{doRun()}}function preInit(){if(Module[\"preInit\"]){if(typeof Module[\"preInit\"]==\"function\")Module[\"preInit\"]=[Module[\"preInit\"]];while(Module[\"preInit\"].length>0){Module[\"preInit\"].shift()()}}}preInit();run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}\n\n\n return moduleRtn;\n}\n);\n})();\nif (typeof exports === 'object' && typeof module === 'object') {\n module.exports = createAecModule;\n // This default export looks redundant, but it allows TS to import this\n // commonjs style module.\n module.exports.default = createAecModule;\n} else if (typeof define === 'function' && define['amd'])\n define([], () => createAecModule);\n"], ["/glass/src/features/common/config/checksums.js", "const DOWNLOAD_CHECKSUMS = {\n ollama: {\n dmg: {\n url: 'https://ollama.com/download/Ollama.dmg',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n exe: {\n url: 'https://ollama.com/download/OllamaSetup.exe',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n linux: {\n url: 'curl -fsSL https://ollama.com/install.sh | sh',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n }\n },\n whisper: {\n models: {\n 'whisper-tiny': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-tiny.bin',\n sha256: 'be07e048e1e599ad46341c8d2a135645097a538221678b7acdd1b1919c6e1b21'\n },\n 'whisper-base': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-base.bin',\n sha256: '60ed5bc3dd14eea856493d334349b405782ddcaf0028d4b5df4088345fba2efe'\n },\n 'whisper-small': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-small.bin',\n sha256: '1be3a9b2063867b937e64e2ec7483364a79917e157fa98c5d94b5c1fffea987b'\n },\n 'whisper-medium': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-medium.bin',\n sha256: '6c14d5adee5f86394037b4e4e8b59f1673b6cee10e3cf0b11bbdbee79c156208'\n }\n },\n binaries: {\n 'v1.7.6': {\n mac: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-mac-x64.zip',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n windows: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-win-x64.zip',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n linux: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-linux-x64.tar.gz',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n }\n }\n }\n }\n};\n\nmodule.exports = { DOWNLOAD_CHECKSUMS };"], ["/glass/src/features/common/ai/providers/deepgram.js", "// providers/deepgram.js\n\nconst { createClient, LiveTranscriptionEvents } = require('@deepgram/sdk');\nconst WebSocket = require('ws');\n\n/**\n * Deepgram Provider 클래스. API 키 유효성 검사를 담당합니다.\n */\nclass DeepgramProvider {\n /**\n * Deepgram API 키의 유효성을 검사합니다.\n * @param {string} key - 검사할 Deepgram API 키\n * @returns {Promise<{success: boolean, error?: string}>}\n */\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string') {\n return { success: false, error: 'Invalid Deepgram API key format.' };\n }\n try {\n // ✨ 변경점: SDK 대신 직접 fetch로 API를 호출하여 안정성 확보 (openai.js 방식)\n const response = await fetch('https://api.deepgram.com/v1/projects', {\n headers: { 'Authorization': `Token ${key}` }\n });\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.err_msg || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[DeepgramProvider] Network error during key validation:`, error);\n return { success: false, error: error.message || 'A network error occurred during validation.' };\n }\n }\n}\n\nfunction createSTT({\n apiKey,\n language = 'en-US',\n sampleRate = 24000,\n callbacks = {},\n }) {\n const qs = new URLSearchParams({\n model: 'nova-3',\n encoding: 'linear16',\n sample_rate: sampleRate.toString(),\n language,\n smart_format: 'true',\n interim_results: 'true',\n channels: '1',\n });\n \n const url = `wss://api.deepgram.com/v1/listen?${qs}`;\n \n const ws = new WebSocket(url, {\n headers: { Authorization: `Token ${apiKey}` },\n });\n ws.binaryType = 'arraybuffer';\n \n return new Promise((resolve, reject) => {\n const to = setTimeout(() => {\n ws.terminate();\n reject(new Error('DG open timeout (10 s)'));\n }, 10_000);\n \n ws.on('open', () => {\n clearTimeout(to);\n resolve({\n sendRealtimeInput: (buf) => ws.send(buf),\n close: () => ws.close(1000, 'client'),\n });\n });\n \n ws.on('message', raw => {\n let msg;\n try { msg = JSON.parse(raw.toString()); } catch { return; }\n if (msg.channel?.alternatives?.[0]?.transcript !== undefined) {\n callbacks.onmessage?.({ provider: 'deepgram', ...msg });\n }\n });\n \n ws.on('close', (code, reason) =>\n callbacks.onclose?.({ code, reason: reason.toString() })\n );\n \n ws.on('error', err => {\n clearTimeout(to);\n callbacks.onerror?.(err);\n reject(err);\n });\n });\n }\n\n// ... (LLM 관련 Placeholder 함수들은 그대로 유지) ...\nfunction createLLM(opts) {\n console.warn(\"[Deepgram] LLM not supported.\");\n return { generateContent: async () => { throw new Error(\"Deepgram does not support LLM functionality.\"); } };\n}\nfunction createStreamingLLM(opts) {\n console.warn(\"[Deepgram] Streaming LLM not supported.\");\n return { streamChat: async () => { throw new Error(\"Deepgram does not support Streaming LLM functionality.\"); } };\n}\n\nmodule.exports = {\n DeepgramProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};"], ["/glass/src/features/common/repositories/whisperModel/index.js", "const BaseModelRepository = require('../baseModel');\n\nclass WhisperModelRepository extends BaseModelRepository {\n constructor(db, tableName = 'whisper_models') {\n super(db, tableName);\n }\n\n async initializeModels(availableModels) {\n const existingModels = await this.getAll();\n const existingIds = new Set(existingModels.map(m => m.id));\n \n for (const [modelId, modelInfo] of Object.entries(availableModels)) {\n if (!existingIds.has(modelId)) {\n await this.create({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: 0,\n installing: 0\n });\n }\n }\n }\n\n async getInstalledModels() {\n return this.findAll({ installed: 1 });\n }\n\n async setInstalled(modelId, installed = true) {\n return this.update({ id: modelId }, { \n installed: installed ? 1 : 0,\n installing: 0\n });\n }\n\n async setInstalling(modelId, installing = true) {\n return this.update({ id: modelId }, { \n installing: installing ? 1 : 0 \n });\n }\n\n async isInstalled(modelId) {\n const model = await this.findOne({ id: modelId });\n return model && model.installed === 1;\n }\n\n async isInstalling(modelId) {\n const model = await this.findOne({ id: modelId });\n return model && model.installing === 1;\n }\n}\n\nmodule.exports = WhisperModelRepository;"], ["/glass/src/features/common/repositories/providerSettings/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\nconst encryptionService = require('../../services/encryptionService');\n\nfunction getByProvider(provider) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT * FROM provider_settings WHERE provider = ?');\n const result = stmt.get(provider) || null;\n \n if (result && result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n \n return result;\n}\n\nfunction getAll() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT * FROM provider_settings ORDER BY provider');\n const results = stmt.all();\n \n return results.map(result => {\n if (result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n return result;\n });\n}\n\nfunction upsert(provider, settings) {\n // Validate: prevent direct setting of active status\n if (settings.is_active_llm || settings.is_active_stt) {\n console.warn('[ProviderSettings] Warning: is_active_llm/is_active_stt should not be set directly. Use setActiveProvider() instead.');\n }\n \n const db = sqliteClient.getDb();\n \n // Use SQLite's UPSERT syntax (INSERT ... ON CONFLICT ... DO UPDATE)\n const stmt = db.prepare(`\n INSERT INTO provider_settings (provider, api_key, selected_llm_model, selected_stt_model, is_active_llm, is_active_stt, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(provider) DO UPDATE SET\n api_key = excluded.api_key,\n selected_llm_model = excluded.selected_llm_model,\n selected_stt_model = excluded.selected_stt_model,\n -- is_active_llm and is_active_stt are NOT updated here\n -- Use setActiveProvider() to change active status\n updated_at = excluded.updated_at\n `);\n \n const result = stmt.run(\n provider,\n settings.api_key || null,\n settings.selected_llm_model || null,\n settings.selected_stt_model || null,\n 0, // is_active_llm - always 0, use setActiveProvider to activate\n 0, // is_active_stt - always 0, use setActiveProvider to activate\n settings.created_at || Date.now(),\n settings.updated_at\n );\n \n return { changes: result.changes };\n}\n\nfunction remove(provider) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('DELETE FROM provider_settings WHERE provider = ?');\n const result = stmt.run(provider);\n return { changes: result.changes };\n}\n\nfunction removeAll() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('DELETE FROM provider_settings');\n const result = stmt.run();\n return { changes: result.changes };\n}\n\nfunction getRawApiKeys() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT api_key FROM provider_settings');\n return stmt.all();\n}\n\n// Get active provider for a specific type (llm or stt)\nfunction getActiveProvider(type) {\n const db = sqliteClient.getDb();\n const column = type === 'llm' ? 'is_active_llm' : 'is_active_stt';\n const stmt = db.prepare(`SELECT * FROM provider_settings WHERE ${column} = 1`);\n const result = stmt.get() || null;\n \n if (result && result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n \n return result;\n}\n\n// Set active provider for a specific type\nfunction setActiveProvider(provider, type) {\n const db = sqliteClient.getDb();\n const column = type === 'llm' ? 'is_active_llm' : 'is_active_stt';\n \n // Start transaction to ensure only one provider is active\n db.transaction(() => {\n // First, deactivate all providers for this type\n const deactivateStmt = db.prepare(`UPDATE provider_settings SET ${column} = 0`);\n deactivateStmt.run();\n \n // Then activate the specified provider\n if (provider) {\n const activateStmt = db.prepare(`UPDATE provider_settings SET ${column} = 1 WHERE provider = ?`);\n activateStmt.run(provider);\n }\n })();\n \n return { success: true };\n}\n\n// Get all active settings (both llm and stt)\nfunction getActiveSettings() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare(`\n SELECT * FROM provider_settings \n WHERE (is_active_llm = 1 OR is_active_stt = 1)\n ORDER BY provider\n `);\n const results = stmt.all();\n \n // Decrypt API keys and organize by type\n const activeSettings = {\n llm: null,\n stt: null\n };\n \n results.forEach(result => {\n if (result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n if (result.is_active_llm) {\n activeSettings.llm = result;\n }\n if (result.is_active_stt) {\n activeSettings.stt = result;\n }\n });\n \n return activeSettings;\n}\n\nmodule.exports = {\n getByProvider,\n getAll,\n upsert,\n remove,\n removeAll,\n getRawApiKeys,\n getActiveProvider,\n setActiveProvider,\n getActiveSettings\n}; "], ["/glass/src/features/common/repositories/session/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction getById(id) {\n const db = sqliteClient.getDb();\n return db.prepare('SELECT * FROM sessions WHERE id = ?').get(id);\n}\n\nfunction create(uid, type = 'ask') {\n const db = sqliteClient.getDb();\n const sessionId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO sessions (id, uid, title, session_type, started_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(sessionId, uid, `Session @ ${new Date().toLocaleTimeString()}`, type, now, now);\n console.log(`SQLite: Created session ${sessionId} for user ${uid} (type: ${type})`);\n return sessionId;\n } catch (err) {\n console.error('SQLite: Failed to create session:', err);\n throw err;\n }\n}\n\nfunction getAllByUserId(uid) {\n const db = sqliteClient.getDb();\n const query = \"SELECT id, uid, title, session_type, started_at, ended_at, sync_state, updated_at FROM sessions WHERE uid = ? ORDER BY started_at DESC\";\n return db.prepare(query).all(uid);\n}\n\nfunction updateTitle(id, title) {\n const db = sqliteClient.getDb();\n const result = db.prepare('UPDATE sessions SET title = ? WHERE id = ?').run(title, id);\n return { changes: result.changes };\n}\n\nfunction deleteWithRelatedData(id) {\n const db = sqliteClient.getDb();\n const transaction = db.transaction(() => {\n db.prepare(\"DELETE FROM transcripts WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM ai_messages WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM summaries WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM sessions WHERE id = ?\").run(id);\n });\n \n try {\n transaction();\n return { success: true };\n } catch (err) {\n throw err;\n }\n}\n\nfunction end(id) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `UPDATE sessions SET ended_at = ?, updated_at = ? WHERE id = ?`;\n const result = db.prepare(query).run(now, now, id);\n return { changes: result.changes };\n}\n\nfunction updateType(id, type) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = 'UPDATE sessions SET session_type = ?, updated_at = ? WHERE id = ?';\n const result = db.prepare(query).run(type, now, id);\n return { changes: result.changes };\n}\n\nfunction touch(id) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = 'UPDATE sessions SET updated_at = ? WHERE id = ?';\n const result = db.prepare(query).run(now, id);\n return { changes: result.changes };\n}\n\nfunction getOrCreateActive(uid, requestedType = 'ask') {\n const db = sqliteClient.getDb();\n \n // 1. Look for ANY active session for the user (ended_at IS NULL).\n // Prefer 'listen' sessions over 'ask' sessions to ensure continuity.\n const findQuery = `\n SELECT id, session_type FROM sessions \n WHERE uid = ? AND ended_at IS NULL\n ORDER BY CASE session_type WHEN 'listen' THEN 1 WHEN 'ask' THEN 2 ELSE 3 END\n LIMIT 1\n `;\n\n const activeSession = db.prepare(findQuery).get(uid);\n\n if (activeSession) {\n // An active session exists.\n console.log(`[Repo] Found active session ${activeSession.id} of type ${activeSession.session_type}`);\n \n // 2. Promotion Logic: If it's an 'ask' session and we need 'listen', promote it.\n if (activeSession.session_type === 'ask' && requestedType === 'listen') {\n updateType(activeSession.id, 'listen');\n console.log(`[Repo] Promoted session ${activeSession.id} to 'listen' type.`);\n }\n\n // 3. Touch the session and return its ID.\n touch(activeSession.id);\n return activeSession.id;\n } else {\n // 4. No active session found, create a new one.\n console.log(`[Repo] No active session for user ${uid}. Creating new '${requestedType}' session.`);\n return create(uid, requestedType);\n }\n}\n\nfunction endAllActiveSessions(uid) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n // Filter by uid to match the Firebase repository's behavior.\n const query = `UPDATE sessions SET ended_at = ?, updated_at = ? WHERE ended_at IS NULL AND uid = ?`;\n \n try {\n const result = db.prepare(query).run(now, now, uid);\n console.log(`[Repo] Ended ${result.changes} active SQLite session(s) for user ${uid}.`);\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to end all active sessions:', err);\n throw err;\n }\n}\n\nmodule.exports = {\n getById,\n create,\n getAllByUserId,\n updateTitle,\n deleteWithRelatedData,\n end,\n updateType,\n touch,\n getOrCreateActive,\n endAllActiveSessions,\n}; "], ["/glass/src/features/settings/repositories/firebase.repository.js", "const { collection, doc, addDoc, getDoc, getDocs, updateDoc, deleteDoc, query, where, orderBy } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../common/repositories/firestoreConverter');\nconst encryptionService = require('../../common/services/encryptionService');\n\nconst userPresetConverter = createEncryptedConverter(['prompt', 'title']);\n\nconst defaultPresetConverter = {\n toFirestore: (data) => data,\n fromFirestore: (snapshot, options) => {\n const data = snapshot.data(options);\n return { ...data, id: snapshot.id };\n }\n};\n\nfunction userPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'prompt_presets').withConverter(userPresetConverter);\n}\n\nfunction defaultPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'defaults/v1/prompt_presets').withConverter(defaultPresetConverter);\n}\n\nasync function getPresets(uid) {\n const userPresetsQuery = query(userPresetsCol(), where('uid', '==', uid));\n const defaultPresetsQuery = query(defaultPresetsCol());\n\n const [userSnapshot, defaultSnapshot] = await Promise.all([\n getDocs(userPresetsQuery),\n getDocs(defaultPresetsQuery)\n ]);\n\n const presets = [\n ...defaultSnapshot.docs.map(d => d.data()),\n ...userSnapshot.docs.map(d => d.data())\n ];\n\n return presets.sort((a, b) => {\n if (a.is_default && !b.is_default) return -1;\n if (!a.is_default && b.is_default) return 1;\n return a.title.localeCompare(b.title);\n });\n}\n\nasync function getPresetTemplates() {\n const q = query(defaultPresetsCol(), orderBy('title', 'asc'));\n const snapshot = await getDocs(q);\n return snapshot.docs.map(doc => doc.data());\n}\n\nasync function createPreset({ uid, title, prompt }) {\n const now = Math.floor(Date.now() / 1000);\n const newPreset = {\n uid: uid,\n title,\n prompt,\n is_default: 0,\n created_at: now,\n };\n const docRef = await addDoc(userPresetsCol(), newPreset);\n return { id: docRef.id };\n}\n\nasync function updatePreset(id, { title, prompt }, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to update.\");\n }\n\n const updates = {};\n if (title !== undefined) {\n updates.title = encryptionService.encrypt(title);\n }\n if (prompt !== undefined) {\n updates.prompt = encryptionService.encrypt(prompt);\n }\n updates.updated_at = Math.floor(Date.now() / 1000);\n \n await updateDoc(docRef, updates);\n return { changes: 1 };\n}\n\nasync function deletePreset(id, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to delete.\");\n }\n\n await deleteDoc(docRef);\n return { changes: 1 };\n}\n\nasync function getAutoUpdate(uid) {\n // Assume users are stored in a \"users\" collection, and auto_update_enabled is a field\n const userDocRef = doc(getFirestoreInstance(), 'users', uid);\n try {\n const userSnap = await getDoc(userDocRef);\n if (userSnap.exists()) {\n const data = userSnap.data();\n if (typeof data.auto_update_enabled !== 'undefined') {\n console.log('Firebase: Auto update setting found:', data.auto_update_enabled);\n return !!data.auto_update_enabled;\n } else {\n // Field does not exist, just return default\n return true;\n }\n } else {\n // User doc does not exist, just return default\n return true;\n }\n } catch (error) {\n console.error('Firebase: Error getting auto_update_enabled setting:', error);\n return true; // fallback to enabled\n }\n}\n\nasync function setAutoUpdate(uid, isEnabled) {\n const userDocRef = doc(getFirestoreInstance(), 'users', uid);\n try {\n const userSnap = await getDoc(userDocRef);\n if (userSnap.exists()) {\n await updateDoc(userDocRef, { auto_update_enabled: !!isEnabled });\n }\n // If user doc does not exist, do nothing (no creation)\n return { success: true };\n } catch (error) {\n console.error('Firebase: Error setting auto-update:', error);\n return { success: false, error: error.message };\n }\n}\n\n\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n getAutoUpdate,\n setAutoUpdate,\n}; "], ["/glass/src/features/common/repositories/user/firebase.repository.js", "const { doc, getDoc, setDoc, deleteDoc, writeBatch, query, where, getDocs, collection, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst userConverter = createEncryptedConverter([]);\n\nfunction usersCol() {\n const db = getFirestoreInstance();\n return collection(db, 'users').withConverter(userConverter);\n}\n\n// These functions are mostly correct as they already operate on a top-level collection.\n// We just need to ensure the signatures are consistent.\n\nasync function findOrCreate(user) {\n if (!user || !user.uid) throw new Error('User object and uid are required');\n const { uid, displayName, email } = user;\n const now = Timestamp.now();\n const docRef = doc(usersCol(), uid);\n const docSnap = await getDoc(docRef);\n\n if (docSnap.exists()) {\n await setDoc(docRef, { \n display_name: displayName || docSnap.data().display_name || 'User',\n email: email || docSnap.data().email || 'no-email@example.com'\n }, { merge: true });\n } else {\n await setDoc(docRef, { uid, display_name: displayName || 'User', email: email || 'no-email@example.com', created_at: now });\n }\n const finalDoc = await getDoc(docRef);\n return finalDoc.data();\n}\n\nasync function getById(uid) {\n const docRef = doc(usersCol(), uid);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\n\n\nasync function update({ uid, displayName }) {\n const docRef = doc(usersCol(), uid);\n await setDoc(docRef, { display_name: displayName }, { merge: true });\n return { changes: 1 };\n}\n\nasync function deleteById(uid) {\n const db = getFirestoreInstance();\n const batch = writeBatch(db);\n\n // 1. Delete all sessions owned by the user\n const sessionsQuery = query(collection(db, 'sessions'), where('uid', '==', uid));\n const sessionsSnapshot = await getDocs(sessionsQuery);\n \n for (const sessionDoc of sessionsSnapshot.docs) {\n // Recursively delete sub-collections\n const subcollectionsToDelete = ['transcripts', 'ai_messages', 'summary'];\n for (const sub of subcollectionsToDelete) {\n const subColPath = `sessions/${sessionDoc.id}/${sub}`;\n const subSnapshot = await getDocs(query(collection(db, subColPath)));\n subSnapshot.forEach(d => batch.delete(d.ref));\n }\n batch.delete(sessionDoc.ref);\n }\n\n // 2. Delete all presets owned by the user\n const presetsQuery = query(collection(db, 'prompt_presets'), where('uid', '==', uid));\n const presetsSnapshot = await getDocs(presetsQuery);\n presetsSnapshot.forEach(doc => batch.delete(doc.ref));\n\n // 3. Delete the user document itself\n const userRef = doc(usersCol(), uid);\n batch.delete(userRef);\n\n await batch.commit();\n return { success: true };\n}\n\nmodule.exports = {\n findOrCreate,\n getById,\n update,\n deleteById,\n}; "], ["/glass/functions/index.js", "/**\n * Import function triggers from their respective submodules:\n *\n * const {onCall} = require(\"firebase-functions/v2/https\");\n * const {onDocumentWritten} = require(\"firebase-functions/v2/firestore\");\n *\n * See a full list of supported triggers at https://firebase.google.com/docs/functions\n */\n\nconst {onRequest} = require(\"firebase-functions/v2/https\");\nconst logger = require(\"firebase-functions/logger\");\nconst admin = require(\"firebase-admin\");\nconst cors = require(\"cors\")({origin: true});\n\nadmin.initializeApp();\n\n// Create and deploy your first functions\n// https://firebase.google.com/docs/functions/get-started\n\n// exports.helloWorld = onRequest((request, response) => {\n// logger.info(\"Hello logs!\", {structuredData: true});\n// response.send(\"Hello from Firebase!\");\n// });\n\n/**\n * @name pickleGlassAuthCallback\n * @description\n * Validate Firebase ID token and return custom token.\n * On success, return success response with user information.\n * On failure, return error message.\n *\n * @param {object} request - HTTPS request object. Contains { token: \"...\" } in body.\n * @param {object} response - HTTPS response object.\n */\nconst authCallbackHandler = (request, response) => {\n cors(request, response, async () => {\n try {\n logger.info(\"pickleGlassAuthCallback function triggered\", {\n body: request.body,\n });\n\n if (request.method !== \"POST\") {\n response.status(405).send(\"Method Not Allowed\");\n return;\n }\n if (!request.body || !request.body.token) {\n logger.error(\"Token is missing from the request body\");\n response.status(400).send({\n success: false,\n error: \"ID token is required.\",\n });\n return;\n }\n\n const idToken = request.body.token;\n\n const decodedToken = await admin.auth().verifyIdToken(idToken);\n const uid = decodedToken.uid;\n\n logger.info(\"Successfully verified token for UID:\", uid);\n\n const customToken = await admin.auth().createCustomToken(uid);\n \n response.status(200).send({\n success: true,\n message: \"Authentication successful.\",\n user: {\n uid: decodedToken.uid,\n email: decodedToken.email,\n name: decodedToken.name,\n picture: decodedToken.picture,\n },\n customToken,\n });\n } catch (error) {\n logger.error(\"Authentication failed:\", error);\n response.status(401).send({\n success: false,\n error: \"Invalid token or authentication failed.\",\n details: error.message,\n });\n }\n });\n};\n\nexports.pickleGlassAuthCallback = onRequest(\n {region: \"us-west1\"},\n authCallbackHandler,\n);\n"], ["/glass/src/bridge/featureBridge.js", "// src/bridge/featureBridge.js\nconst { ipcMain, app, BrowserWindow } = require('electron');\nconst settingsService = require('../features/settings/settingsService');\nconst authService = require('../features/common/services/authService');\nconst whisperService = require('../features/common/services/whisperService');\nconst ollamaService = require('../features/common/services/ollamaService');\nconst modelStateService = require('../features/common/services/modelStateService');\nconst shortcutsService = require('../features/shortcuts/shortcutsService');\nconst presetRepository = require('../features/common/repositories/preset');\nconst localAIManager = require('../features/common/services/localAIManager');\nconst askService = require('../features/ask/askService');\nconst listenService = require('../features/listen/listenService');\nconst permissionService = require('../features/common/services/permissionService');\nconst encryptionService = require('../features/common/services/encryptionService');\n\nmodule.exports = {\n // Renderer로부터의 요청을 수신하고 서비스로 전달\n initialize() {\n // Settings Service\n ipcMain.handle('settings:getPresets', async () => await settingsService.getPresets());\n ipcMain.handle('settings:get-auto-update', async () => await settingsService.getAutoUpdateSetting());\n ipcMain.handle('settings:set-auto-update', async (event, isEnabled) => await settingsService.setAutoUpdateSetting(isEnabled)); \n ipcMain.handle('settings:get-model-settings', async () => await settingsService.getModelSettings());\n ipcMain.handle('settings:clear-api-key', async (e, { provider }) => await settingsService.clearApiKey(provider));\n ipcMain.handle('settings:set-selected-model', async (e, { type, modelId }) => await settingsService.setSelectedModel(type, modelId)); \n\n ipcMain.handle('settings:get-ollama-status', async () => await settingsService.getOllamaStatus());\n ipcMain.handle('settings:ensure-ollama-ready', async () => await settingsService.ensureOllamaReady());\n ipcMain.handle('settings:shutdown-ollama', async () => await settingsService.shutdownOllama());\n\n // Shortcuts\n ipcMain.handle('settings:getCurrentShortcuts', async () => await shortcutsService.loadKeybinds());\n ipcMain.handle('shortcut:getDefaultShortcuts', async () => await shortcutsService.handleRestoreDefaults());\n ipcMain.handle('shortcut:closeShortcutSettingsWindow', async () => await shortcutsService.closeShortcutSettingsWindow());\n ipcMain.handle('shortcut:openShortcutSettingsWindow', async () => await shortcutsService.openShortcutSettingsWindow());\n ipcMain.handle('shortcut:saveShortcuts', async (event, newKeybinds) => await shortcutsService.handleSaveShortcuts(newKeybinds));\n ipcMain.handle('shortcut:toggleAllWindowsVisibility', async () => await shortcutsService.toggleAllWindowsVisibility());\n\n // Permissions\n ipcMain.handle('check-system-permissions', async () => await permissionService.checkSystemPermissions());\n ipcMain.handle('request-microphone-permission', async () => await permissionService.requestMicrophonePermission());\n ipcMain.handle('open-system-preferences', async (event, section) => await permissionService.openSystemPreferences(section));\n ipcMain.handle('mark-keychain-completed', async () => await permissionService.markKeychainCompleted());\n ipcMain.handle('check-keychain-completed', async () => await permissionService.checkKeychainCompleted());\n ipcMain.handle('initialize-encryption-key', async () => {\n const userId = authService.getCurrentUserId();\n await encryptionService.initializeKey(userId);\n return { success: true };\n });\n\n // User/Auth\n ipcMain.handle('get-current-user', () => authService.getCurrentUser());\n ipcMain.handle('start-firebase-auth', async () => await authService.startFirebaseAuthFlow());\n ipcMain.handle('firebase-logout', async () => await authService.signOut());\n\n // App\n ipcMain.handle('quit-application', () => app.quit());\n\n // Whisper\n ipcMain.handle('whisper:download-model', async (event, modelId) => await whisperService.handleDownloadModel(modelId));\n ipcMain.handle('whisper:get-installed-models', async () => await whisperService.handleGetInstalledModels());\n \n // General\n ipcMain.handle('get-preset-templates', () => presetRepository.getPresetTemplates());\n ipcMain.handle('get-web-url', () => process.env.pickleglass_WEB_URL || 'http://localhost:3000');\n\n // Ollama\n ipcMain.handle('ollama:get-status', async () => await ollamaService.handleGetStatus());\n ipcMain.handle('ollama:install', async () => await ollamaService.handleInstall());\n ipcMain.handle('ollama:start-service', async () => await ollamaService.handleStartService());\n ipcMain.handle('ollama:ensure-ready', async () => await ollamaService.handleEnsureReady());\n ipcMain.handle('ollama:get-models', async () => await ollamaService.handleGetModels());\n ipcMain.handle('ollama:get-model-suggestions', async () => await ollamaService.handleGetModelSuggestions());\n ipcMain.handle('ollama:pull-model', async (event, modelName) => await ollamaService.handlePullModel(modelName));\n ipcMain.handle('ollama:is-model-installed', async (event, modelName) => await ollamaService.handleIsModelInstalled(modelName));\n ipcMain.handle('ollama:warm-up-model', async (event, modelName) => await ollamaService.handleWarmUpModel(modelName));\n ipcMain.handle('ollama:auto-warm-up', async () => await ollamaService.handleAutoWarmUp());\n ipcMain.handle('ollama:get-warm-up-status', async () => await ollamaService.handleGetWarmUpStatus());\n ipcMain.handle('ollama:shutdown', async (event, force = false) => await ollamaService.handleShutdown(force));\n\n // Ask\n ipcMain.handle('ask:sendQuestionFromAsk', async (event, userPrompt) => await askService.sendMessage(userPrompt));\n ipcMain.handle('ask:sendQuestionFromSummary', async (event, userPrompt) => await askService.sendMessage(userPrompt));\n ipcMain.handle('ask:toggleAskButton', async () => await askService.toggleAskButton());\n ipcMain.handle('ask:closeAskWindow', async () => await askService.closeAskWindow());\n \n // Listen\n ipcMain.handle('listen:sendMicAudio', async (event, { data, mimeType }) => await listenService.handleSendMicAudioContent(data, mimeType));\n ipcMain.handle('listen:sendSystemAudio', async (event, { data, mimeType }) => {\n const result = await listenService.sttService.sendSystemAudioContent(data, mimeType);\n if(result.success) {\n listenService.sendToRenderer('system-audio-data', { data });\n }\n return result;\n });\n ipcMain.handle('listen:startMacosSystemAudio', async () => await listenService.handleStartMacosAudio());\n ipcMain.handle('listen:stopMacosSystemAudio', async () => await listenService.handleStopMacosAudio());\n ipcMain.handle('update-google-search-setting', async (event, enabled) => await listenService.handleUpdateGoogleSearchSetting(enabled));\n ipcMain.handle('listen:isSessionActive', async () => await listenService.isSessionActive());\n ipcMain.handle('listen:changeSession', async (event, listenButtonText) => {\n console.log('[FeatureBridge] listen:changeSession from mainheader', listenButtonText);\n try {\n await listenService.handleListenRequest(listenButtonText);\n return { success: true };\n } catch (error) {\n console.error('[FeatureBridge] listen:changeSession failed', error.message);\n return { success: false, error: error.message };\n }\n });\n\n // ModelStateService\n ipcMain.handle('model:validate-key', async (e, { provider, key }) => await modelStateService.handleValidateKey(provider, key));\n ipcMain.handle('model:get-all-keys', async () => await modelStateService.getAllApiKeys());\n ipcMain.handle('model:set-api-key', async (e, { provider, key }) => await modelStateService.setApiKey(provider, key));\n ipcMain.handle('model:remove-api-key', async (e, provider) => await modelStateService.handleRemoveApiKey(provider));\n ipcMain.handle('model:get-selected-models', async () => await modelStateService.getSelectedModels());\n ipcMain.handle('model:set-selected-model', async (e, { type, modelId }) => await modelStateService.handleSetSelectedModel(type, modelId));\n ipcMain.handle('model:get-available-models', async (e, { type }) => await modelStateService.getAvailableModels(type));\n ipcMain.handle('model:are-providers-configured', async () => await modelStateService.areProvidersConfigured());\n ipcMain.handle('model:get-provider-config', () => modelStateService.getProviderConfig());\n ipcMain.handle('model:re-initialize-state', async () => await modelStateService.initialize());\n\n // LocalAIManager 이벤트를 모든 윈도우에 브로드캐스트\n localAIManager.on('install-progress', (service, data) => {\n const event = { service, ...data };\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:install-progress', event);\n }\n });\n });\n localAIManager.on('installation-complete', (service) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:installation-complete', { service });\n }\n });\n });\n localAIManager.on('error', (error) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:error-occurred', error);\n }\n });\n });\n // Handle error-occurred events from LocalAIManager's error handling\n localAIManager.on('error-occurred', (error) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:error-occurred', error);\n }\n });\n });\n localAIManager.on('model-ready', (data) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:model-ready', data);\n }\n });\n });\n localAIManager.on('state-changed', (service, state) => {\n const event = { service, ...state };\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:service-status-changed', event);\n }\n });\n });\n\n // 주기적 상태 동기화 시작\n localAIManager.startPeriodicSync();\n\n // ModelStateService 이벤트를 모든 윈도우에 브로드캐스트\n modelStateService.on('state-updated', (state) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('model-state:updated', state);\n }\n });\n });\n modelStateService.on('settings-updated', () => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('settings-updated');\n }\n });\n });\n modelStateService.on('force-show-apikey-header', () => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('force-show-apikey-header');\n }\n });\n });\n\n // LocalAI 통합 핸들러 추가\n ipcMain.handle('localai:install', async (event, { service, options }) => {\n return await localAIManager.installService(service, options);\n });\n ipcMain.handle('localai:get-status', async (event, service) => {\n return await localAIManager.getServiceStatus(service);\n });\n ipcMain.handle('localai:start-service', async (event, service) => {\n return await localAIManager.startService(service);\n });\n ipcMain.handle('localai:stop-service', async (event, service) => {\n return await localAIManager.stopService(service);\n });\n ipcMain.handle('localai:install-model', async (event, { service, modelId, options }) => {\n return await localAIManager.installModel(service, modelId, options);\n });\n ipcMain.handle('localai:get-installed-models', async (event, service) => {\n return await localAIManager.getInstalledModels(service);\n });\n ipcMain.handle('localai:run-diagnostics', async (event, service) => {\n return await localAIManager.runDiagnostics(service);\n });\n ipcMain.handle('localai:repair-service', async (event, service) => {\n return await localAIManager.repairService(service);\n });\n \n // 에러 처리 핸들러\n ipcMain.handle('localai:handle-error', async (event, { service, errorType, details }) => {\n return await localAIManager.handleError(service, errorType, details);\n });\n \n // 전체 상태 조회\n ipcMain.handle('localai:get-all-states', async (event) => {\n return await localAIManager.getAllServiceStates();\n });\n\n console.log('[FeatureBridge] Initialized with all feature handlers.');\n },\n\n // Renderer로 상태를 전송\n sendAskProgress(win, progress) {\n win.webContents.send('feature:ask:progress', progress);\n },\n};"], ["/glass/src/features/common/repositories/session/firebase.repository.js", "const { doc, getDoc, collection, addDoc, query, where, getDocs, writeBatch, orderBy, limit, updateDoc, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst sessionConverter = createEncryptedConverter(['title']);\n\nfunction sessionsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'sessions').withConverter(sessionConverter);\n}\n\n// Sub-collection references are now built from the top-level\nfunction subCollections(sessionId) {\n const db = getFirestoreInstance();\n const sessionPath = `sessions/${sessionId}`;\n return {\n transcripts: collection(db, `${sessionPath}/transcripts`),\n ai_messages: collection(db, `${sessionPath}/ai_messages`),\n summary: collection(db, `${sessionPath}/summary`),\n }\n}\n\nasync function getById(id) {\n const docRef = doc(sessionsCol(), id);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\nasync function create(uid, type = 'ask') {\n const now = Timestamp.now();\n const newSession = {\n uid: uid,\n members: [uid], // For future sharing functionality\n title: `Session @ ${new Date().toLocaleTimeString()}`,\n session_type: type,\n started_at: now,\n updated_at: now,\n ended_at: null,\n };\n const docRef = await addDoc(sessionsCol(), newSession);\n console.log(`Firebase: Created session ${docRef.id} for user ${uid}`);\n return docRef.id;\n}\n\nasync function getAllByUserId(uid) {\n const q = query(sessionsCol(), where('members', 'array-contains', uid), orderBy('started_at', 'desc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nasync function updateTitle(id, title) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, {\n title: encryptionService.encrypt(title),\n updated_at: Timestamp.now()\n });\n return { changes: 1 };\n}\n\nasync function deleteWithRelatedData(id) {\n const db = getFirestoreInstance();\n const batch = writeBatch(db);\n\n const { transcripts, ai_messages, summary } = subCollections(id);\n const [transcriptsSnap, aiMessagesSnap, summarySnap] = await Promise.all([\n getDocs(query(transcripts)),\n getDocs(query(ai_messages)),\n getDocs(query(summary)),\n ]);\n \n transcriptsSnap.forEach(d => batch.delete(d.ref));\n aiMessagesSnap.forEach(d => batch.delete(d.ref));\n summarySnap.forEach(d => batch.delete(d.ref));\n\n const sessionRef = doc(sessionsCol(), id);\n batch.delete(sessionRef);\n\n await batch.commit();\n return { success: true };\n}\n\nasync function end(id) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { ended_at: Timestamp.now() });\n return { changes: 1 };\n}\n\nasync function updateType(id, type) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { session_type: type });\n return { changes: 1 };\n}\n\nasync function touch(id) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { updated_at: Timestamp.now() });\n return { changes: 1 };\n}\n\nasync function getOrCreateActive(uid, requestedType = 'ask') {\n const findQuery = query(\n sessionsCol(),\n where('uid', '==', uid),\n where('ended_at', '==', null),\n orderBy('session_type', 'desc'),\n limit(1)\n );\n\n const activeSessionSnap = await getDocs(findQuery);\n \n if (!activeSessionSnap.empty) {\n const activeSessionDoc = activeSessionSnap.docs[0];\n const sessionRef = doc(sessionsCol(), activeSessionDoc.id);\n const activeSession = activeSessionDoc.data();\n\n console.log(`[Repo] Found active Firebase session ${activeSession.id}`);\n \n const updates = { updated_at: Timestamp.now() };\n if (activeSession.session_type === 'ask' && requestedType === 'listen') {\n updates.session_type = 'listen';\n console.log(`[Repo] Promoted Firebase session ${activeSession.id} to 'listen' type.`);\n }\n \n await updateDoc(sessionRef, updates);\n return activeSessionDoc.id;\n } else {\n console.log(`[Repo] No active Firebase session for user ${uid}. Creating new.`);\n return create(uid, requestedType);\n }\n}\n\nasync function endAllActiveSessions(uid) {\n const q = query(sessionsCol(), where('uid', '==', uid), where('ended_at', '==', null));\n const snapshot = await getDocs(q);\n\n if (snapshot.empty) return { changes: 0 };\n\n const batch = writeBatch(getFirestoreInstance());\n const now = Timestamp.now();\n snapshot.forEach(d => {\n batch.update(d.ref, { ended_at: now });\n });\n await batch.commit();\n\n console.log(`[Repo] Ended ${snapshot.size} active session(s) for user ${uid}.`);\n return { changes: snapshot.size };\n}\n\nmodule.exports = {\n getById,\n create,\n getAllByUserId,\n updateTitle,\n deleteWithRelatedData,\n end,\n updateType,\n touch,\n getOrCreateActive,\n endAllActiveSessions,\n}; "], ["/glass/pickleglass_web/backend_node/routes/user.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.put('/profile', async (req, res) => {\n try {\n await ipcRequest(req, 'update-user-profile', req.body);\n res.json({ message: 'Profile updated successfully' });\n } catch (error) {\n console.error('Failed to update profile via IPC:', error);\n res.status(500).json({ error: 'Failed to update profile' });\n }\n});\n\nrouter.get('/profile', async (req, res) => {\n try {\n const user = await ipcRequest(req, 'get-user-profile');\n if (!user) return res.status(404).json({ error: 'User not found' });\n res.json(user);\n } catch (error) {\n console.error('Failed to get profile via IPC:', error);\n res.status(500).json({ error: 'Failed to get profile' });\n }\n});\n\nrouter.post('/find-or-create', async (req, res) => {\n try {\n console.log('[API] find-or-create request received:', req.body);\n \n if (!req.body || !req.body.uid) {\n return res.status(400).json({ error: 'User data with uid is required' });\n }\n \n const user = await ipcRequest(req, 'find-or-create-user', req.body);\n console.log('[API] find-or-create response:', user);\n res.status(200).json(user);\n } catch (error) {\n console.error('Failed to find or create user via IPC:', error);\n console.error('Request body:', req.body);\n res.status(500).json({ \n error: 'Failed to find or create user',\n details: error.message \n });\n }\n});\n\nrouter.post('/api-key', async (req, res) => {\n try {\n const { apiKey, provider = 'openai' } = req.body;\n await ipcRequest(req, 'save-api-key', { apiKey, provider });\n res.json({ message: 'API key saved successfully' });\n } catch (error) {\n console.error('Failed to save API key via IPC:', error);\n res.status(500).json({ error: 'Failed to save API key' });\n }\n});\n\nrouter.get('/api-key-status', async (req, res) => {\n try {\n const status = await ipcRequest(req, 'check-api-key-status');\n res.json(status);\n } catch (error) {\n console.error('Failed to get API key status via IPC:', error);\n res.status(500).json({ error: 'Failed to get API key status' });\n }\n});\n\nrouter.delete('/profile', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-account');\n res.status(200).json({ message: 'User account and all data deleted successfully.' });\n } catch (error) {\n console.error('Failed to delete user account via IPC:', error);\n res.status(500).json({ error: 'Failed to delete user account' });\n }\n});\n\nrouter.get('/batch', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'get-batch-data', req.query.include);\n res.json(result);\n } catch(error) {\n console.error('Failed to get batch data via IPC:', error);\n res.status(500).json({ error: 'Failed to get batch data' });\n }\n});\n\nmodule.exports = router;\n"], ["/glass/src/features/settings/repositories/sqlite.repository.js", "const sqliteClient = require('../../common/services/sqliteClient');\n\nfunction getPresets(uid) {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE uid = ? OR is_default = 1 \n ORDER BY is_default DESC, title ASC\n `;\n \n try {\n return db.prepare(query).all(uid) || [];\n } catch (err) {\n console.error('SQLite: Failed to get presets:', err);\n throw err;\n }\n}\n\nfunction getPresetTemplates() {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE is_default = 1 \n ORDER BY title ASC\n `;\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('SQLite: Failed to get preset templates:', err);\n throw err;\n }\n}\n\nfunction createPreset({ uid, title, prompt }) {\n const db = sqliteClient.getDb();\n const id = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n INSERT INTO prompt_presets (id, uid, title, prompt, is_default, created_at, sync_state)\n VALUES (?, ?, ?, ?, 0, ?, 'dirty')\n `;\n \n try {\n db.prepare(query).run(id, uid, title, prompt, now);\n return { id };\n } catch (err) {\n console.error('SQLite: Failed to create preset:', err);\n throw err;\n }\n}\n\nfunction updatePreset(id, { title, prompt }, uid) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n UPDATE prompt_presets \n SET title = ?, prompt = ?, sync_state = 'dirty', updated_at = ?\n WHERE id = ? AND uid = ? AND is_default = 0\n `;\n \n try {\n const result = db.prepare(query).run(title, prompt, now, id, uid);\n if (result.changes === 0) {\n throw new Error('Preset not found, is default, or permission denied');\n }\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to update preset:', err);\n throw err;\n }\n}\n\nfunction deletePreset(id, uid) {\n const db = sqliteClient.getDb();\n const query = `\n DELETE FROM prompt_presets \n WHERE id = ? AND uid = ? AND is_default = 0\n `;\n \n try {\n const result = db.prepare(query).run(id, uid);\n if (result.changes === 0) {\n throw new Error('Preset not found, is default, or permission denied');\n }\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to delete preset:', err);\n throw err;\n }\n}\n\nfunction getAutoUpdate(uid) {\n const db = sqliteClient.getDb();\n const targetUid = uid;\n\n try {\n const row = db.prepare('SELECT auto_update_enabled FROM users WHERE uid = ?').get(targetUid);\n \n if (row) {\n console.log('SQLite: Auto update setting found:', row.auto_update_enabled);\n return row.auto_update_enabled !== 0;\n } else {\n // User doesn't exist, create them with default settings\n const now = Math.floor(Date.now() / 1000);\n const stmt = db.prepare(\n 'INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)');\n stmt.run(targetUid, 'User', 'user@example.com', now, 1);\n return true; // default to enabled\n }\n } catch (error) {\n console.error('SQLite: Error getting auto_update_enabled setting:', error);\n return true; // fallback to enabled\n }\n}\n\nfunction setAutoUpdate(uid, isEnabled) {\n const db = sqliteClient.getDb();\n const targetUid = uid || sqliteClient.defaultUserId;\n \n try {\n const result = db.prepare('UPDATE users SET auto_update_enabled = ? WHERE uid = ?').run(isEnabled ? 1 : 0, targetUid);\n \n // If no rows were updated, the user might not exist, so create them\n if (result.changes === 0) {\n const now = Math.floor(Date.now() / 1000);\n const stmt = db.prepare('INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)');\n stmt.run(targetUid, 'User', 'user@example.com', now, isEnabled ? 1 : 0);\n }\n \n return { success: true };\n } catch (error) {\n console.error('SQLite: Error setting auto-update:', error);\n throw error;\n }\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n getAutoUpdate,\n setAutoUpdate\n};"], ["/glass/src/features/common/services/permissionService.js", "const { systemPreferences, shell, desktopCapturer } = require('electron');\nconst permissionRepository = require('../repositories/permission');\n\nclass PermissionService {\n _getAuthService() {\n return require('./authService');\n }\n\n async checkSystemPermissions() {\n const permissions = {\n microphone: 'unknown',\n screen: 'unknown',\n keychain: 'unknown',\n needsSetup: true\n };\n\n try {\n if (process.platform === 'darwin') {\n permissions.microphone = systemPreferences.getMediaAccessStatus('microphone');\n permissions.screen = systemPreferences.getMediaAccessStatus('screen');\n permissions.keychain = await this.checkKeychainCompleted(this._getAuthService().getCurrentUserId()) ? 'granted' : 'unknown';\n permissions.needsSetup = permissions.microphone !== 'granted' || permissions.screen !== 'granted' || permissions.keychain !== 'granted';\n } else {\n permissions.microphone = 'granted';\n permissions.screen = 'granted';\n permissions.keychain = 'granted';\n permissions.needsSetup = false;\n }\n\n console.log('[Permissions] System permissions status:', permissions);\n return permissions;\n } catch (error) {\n console.error('[Permissions] Error checking permissions:', error);\n return {\n microphone: 'unknown',\n screen: 'unknown',\n keychain: 'unknown',\n needsSetup: true,\n error: error.message\n };\n }\n }\n\n async requestMicrophonePermission() {\n if (process.platform !== 'darwin') {\n return { success: true };\n }\n\n try {\n const status = systemPreferences.getMediaAccessStatus('microphone');\n console.log('[Permissions] Microphone status:', status);\n if (status === 'granted') {\n return { success: true, status: 'granted' };\n }\n\n const granted = await systemPreferences.askForMediaAccess('microphone');\n return {\n success: granted,\n status: granted ? 'granted' : 'denied'\n };\n } catch (error) {\n console.error('[Permissions] Error requesting microphone permission:', error);\n return {\n success: false,\n error: error.message\n };\n }\n }\n\n async openSystemPreferences(section) {\n if (process.platform !== 'darwin') {\n return { success: false, error: 'Not supported on this platform' };\n }\n\n try {\n if (section === 'screen-recording') {\n try {\n console.log('[Permissions] Triggering screen capture request to register app...');\n await desktopCapturer.getSources({\n types: ['screen'],\n thumbnailSize: { width: 1, height: 1 }\n });\n console.log('[Permissions] App registered for screen recording');\n } catch (captureError) {\n console.log('[Permissions] Screen capture request triggered (expected to fail):', captureError.message);\n }\n \n // await shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture');\n }\n return { success: true };\n } catch (error) {\n console.error('[Permissions] Error opening system preferences:', error);\n return { success: false, error: error.message };\n }\n }\n\n async markKeychainCompleted() {\n try {\n await permissionRepository.markKeychainCompleted(this._getAuthService().getCurrentUserId());\n console.log('[Permissions] Marked keychain as completed');\n return { success: true };\n } catch (error) {\n console.error('[Permissions] Error marking keychain as completed:', error);\n return { success: false, error: error.message };\n }\n }\n\n async checkKeychainCompleted(uid) {\n if (uid === \"default_user\") {\n return true;\n }\n try {\n const completed = permissionRepository.checkKeychainCompleted(uid);\n console.log('[Permissions] Keychain completed status:', completed);\n return completed;\n } catch (error) {\n console.error('[Permissions] Error checking keychain completed status:', error);\n return false;\n }\n }\n}\n\nconst permissionService = new PermissionService();\nmodule.exports = permissionService; "], ["/glass/pickleglass_web/backend_node/index.js", "const express = require('express');\nconst cors = require('cors');\n// const db = require('./db'); // No longer needed\nconst { identifyUser } = require('./middleware/auth');\n\nfunction createApp(eventBridge) {\n const app = express();\n\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n console.log(`🔧 Backend CORS configured for: ${webUrl}`);\n\n app.use(cors({\n origin: webUrl,\n credentials: true,\n }));\n\n app.use(express.json());\n\n app.get('/', (req, res) => {\n res.json({ message: \"pickleglass API is running\" });\n });\n\n app.use((req, res, next) => {\n req.bridge = eventBridge;\n next();\n });\n\n app.use('/api', identifyUser);\n\n app.use('/api/auth', require('./routes/auth'));\n app.use('/api/user', require('./routes/user'));\n app.use('/api/conversations', require('./routes/conversations'));\n app.use('/api/presets', require('./routes/presets'));\n\n app.get('/api/sync/status', (req, res) => {\n res.json({\n status: 'online',\n timestamp: new Date().toISOString(),\n version: '1.0.0'\n });\n });\n\n app.post('/api/desktop/set-user', (req, res) => {\n res.json({\n success: true,\n message: \"Direct IPC communication is now used. This endpoint is deprecated.\",\n user: req.body,\n deprecated: true\n });\n });\n\n app.get('/api/desktop/status', (req, res) => {\n res.json({\n connected: true,\n current_user: null,\n communication_method: \"IPC\",\n file_based_deprecated: true\n });\n });\n\n return app;\n}\n\nmodule.exports = createApp;\n"], ["/glass/src/preload.js", "// src/preload.js\nconst { contextBridge, ipcRenderer } = require('electron');\n\ncontextBridge.exposeInMainWorld('api', {\n // Platform information for renderer processes\n platform: {\n isLinux: process.platform === 'linux',\n isMacOS: process.platform === 'darwin',\n isWindows: process.platform === 'win32',\n platform: process.platform\n },\n \n // Common utilities used across multiple components\n common: {\n // User & Auth\n getCurrentUser: () => ipcRenderer.invoke('get-current-user'),\n startFirebaseAuth: () => ipcRenderer.invoke('start-firebase-auth'),\n firebaseLogout: () => ipcRenderer.invoke('firebase-logout'),\n \n // App Control\n quitApplication: () => ipcRenderer.invoke('quit-application'),\n openExternal: (url) => ipcRenderer.invoke('open-external', url),\n\n // User state listener (used by multiple components)\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n },\n\n // UI Component specific namespaces\n // src/ui/app/ApiKeyHeader.js\n apiKeyHeader: {\n // Model & Provider Management\n getProviderConfig: () => ipcRenderer.invoke('model:get-provider-config'),\n // LocalAI 통합 API\n getLocalAIStatus: (service) => ipcRenderer.invoke('localai:get-status', service),\n installLocalAI: (service, options) => ipcRenderer.invoke('localai:install', { service, options }),\n startLocalAIService: (service) => ipcRenderer.invoke('localai:start-service', service),\n stopLocalAIService: (service) => ipcRenderer.invoke('localai:stop-service', service),\n installLocalAIModel: (service, modelId, options) => ipcRenderer.invoke('localai:install-model', { service, modelId, options }),\n getInstalledModels: (service) => ipcRenderer.invoke('localai:get-installed-models', service),\n \n // Legacy support (호환성 위해 유지)\n getOllamaStatus: () => ipcRenderer.invoke('localai:get-status', 'ollama'),\n getModelSuggestions: () => ipcRenderer.invoke('ollama:get-model-suggestions'),\n ensureOllamaReady: () => ipcRenderer.invoke('ollama:ensure-ready'),\n installOllama: () => ipcRenderer.invoke('localai:install', { service: 'ollama' }),\n startOllamaService: () => ipcRenderer.invoke('localai:start-service', 'ollama'),\n pullOllamaModel: (modelName) => ipcRenderer.invoke('ollama:pull-model', modelName),\n downloadWhisperModel: (modelId) => ipcRenderer.invoke('whisper:download-model', modelId),\n validateKey: (data) => ipcRenderer.invoke('model:validate-key', data),\n setSelectedModel: (data) => ipcRenderer.invoke('model:set-selected-model', data),\n areProvidersConfigured: () => ipcRenderer.invoke('model:are-providers-configured'),\n \n // Window Management\n getHeaderPosition: () => ipcRenderer.invoke('get-header-position'),\n moveHeaderTo: (x, y) => ipcRenderer.invoke('move-header-to', x, y),\n \n // Listeners\n // LocalAI 통합 이벤트 리스너\n onLocalAIProgress: (callback) => ipcRenderer.on('localai:install-progress', callback),\n removeOnLocalAIProgress: (callback) => ipcRenderer.removeListener('localai:install-progress', callback),\n onLocalAIComplete: (callback) => ipcRenderer.on('localai:installation-complete', callback),\n removeOnLocalAIComplete: (callback) => ipcRenderer.removeListener('localai:installation-complete', callback),\n onLocalAIError: (callback) => ipcRenderer.on('localai:error-notification', callback),\n removeOnLocalAIError: (callback) => ipcRenderer.removeListener('localai:error-notification', callback),\n onLocalAIModelReady: (callback) => ipcRenderer.on('localai:model-ready', callback),\n removeOnLocalAIModelReady: (callback) => ipcRenderer.removeListener('localai:model-ready', callback),\n \n\n // Remove all listeners (for cleanup)\n removeAllListeners: () => {\n // LocalAI 통합 이벤트\n ipcRenderer.removeAllListeners('localai:install-progress');\n ipcRenderer.removeAllListeners('localai:installation-complete');\n ipcRenderer.removeAllListeners('localai:error-notification');\n ipcRenderer.removeAllListeners('localai:model-ready');\n ipcRenderer.removeAllListeners('localai:service-status-changed');\n }\n },\n\n // src/ui/app/HeaderController.js\n headerController: {\n // State Management\n sendHeaderStateChanged: (state) => ipcRenderer.send('header-state-changed', state),\n reInitializeModelState: () => ipcRenderer.invoke('model:re-initialize-state'),\n \n // Window Management\n resizeHeaderWindow: (dimensions) => ipcRenderer.invoke('resize-header-window', dimensions),\n \n // Permissions\n checkSystemPermissions: () => ipcRenderer.invoke('check-system-permissions'),\n checkPermissionsCompleted: () => ipcRenderer.invoke('check-permissions-completed'),\n \n // Listeners\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n onAuthFailed: (callback) => ipcRenderer.on('auth-failed', callback),\n removeOnAuthFailed: (callback) => ipcRenderer.removeListener('auth-failed', callback),\n onForceShowApiKeyHeader: (callback) => ipcRenderer.on('force-show-apikey-header', callback),\n removeOnForceShowApiKeyHeader: (callback) => ipcRenderer.removeListener('force-show-apikey-header', callback),\n },\n\n // src/ui/app/MainHeader.js\n mainHeader: {\n // Window Management\n getHeaderPosition: () => ipcRenderer.invoke('get-header-position'),\n moveHeaderTo: (x, y) => ipcRenderer.invoke('move-header-to', x, y),\n sendHeaderAnimationFinished: (state) => ipcRenderer.send('header-animation-finished', state),\n\n // Settings Window Management\n cancelHideSettingsWindow: () => ipcRenderer.send('cancel-hide-settings-window'),\n showSettingsWindow: () => ipcRenderer.send('show-settings-window'),\n hideSettingsWindow: () => ipcRenderer.send('hide-settings-window'),\n \n // Generic invoke (for dynamic channel names)\n // invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),\n sendListenButtonClick: (listenButtonText) => ipcRenderer.invoke('listen:changeSession', listenButtonText),\n sendAskButtonClick: () => ipcRenderer.invoke('ask:toggleAskButton'),\n sendToggleAllWindowsVisibility: () => ipcRenderer.invoke('shortcut:toggleAllWindowsVisibility'),\n \n // Listeners\n onListenChangeSessionResult: (callback) => ipcRenderer.on('listen:changeSessionResult', callback),\n removeOnListenChangeSessionResult: (callback) => ipcRenderer.removeListener('listen:changeSessionResult', callback),\n onShortcutsUpdated: (callback) => ipcRenderer.on('shortcuts-updated', callback),\n removeOnShortcutsUpdated: (callback) => ipcRenderer.removeListener('shortcuts-updated', callback)\n },\n\n // src/ui/app/PermissionHeader.js\n permissionHeader: {\n // Permission Management\n checkSystemPermissions: () => ipcRenderer.invoke('check-system-permissions'),\n requestMicrophonePermission: () => ipcRenderer.invoke('request-microphone-permission'),\n openSystemPreferences: (preference) => ipcRenderer.invoke('open-system-preferences', preference),\n markKeychainCompleted: () => ipcRenderer.invoke('mark-keychain-completed'),\n checkKeychainCompleted: (uid) => ipcRenderer.invoke('check-keychain-completed', uid),\n initializeEncryptionKey: () => ipcRenderer.invoke('initialize-encryption-key') // New for keychain\n },\n\n // src/ui/app/PickleGlassApp.js\n pickleGlassApp: {\n // Listeners\n onClickThroughToggled: (callback) => ipcRenderer.on('click-through-toggled', callback),\n removeOnClickThroughToggled: (callback) => ipcRenderer.removeListener('click-through-toggled', callback),\n removeAllClickThroughListeners: () => ipcRenderer.removeAllListeners('click-through-toggled')\n },\n\n // src/ui/ask/AskView.js\n askView: {\n // Window Management\n closeAskWindow: () => ipcRenderer.invoke('ask:closeAskWindow'),\n adjustWindowHeight: (winName, height) => ipcRenderer.invoke('adjust-window-height', { winName, height }),\n \n // Message Handling\n sendMessage: (text) => ipcRenderer.invoke('ask:sendQuestionFromAsk', text),\n\n // Listeners\n onAskStateUpdate: (callback) => ipcRenderer.on('ask:stateUpdate', callback),\n removeOnAskStateUpdate: (callback) => ipcRenderer.removeListener('ask:stateUpdate', callback),\n\n onAskStreamError: (callback) => ipcRenderer.on('ask-response-stream-error', callback),\n removeOnAskStreamError: (callback) => ipcRenderer.removeListener('ask-response-stream-error', callback),\n\n // Listeners\n onShowTextInput: (callback) => ipcRenderer.on('ask:showTextInput', callback),\n removeOnShowTextInput: (callback) => ipcRenderer.removeListener('ask:showTextInput', callback),\n \n onScrollResponseUp: (callback) => ipcRenderer.on('aks:scrollResponseUp', callback),\n removeOnScrollResponseUp: (callback) => ipcRenderer.removeListener('aks:scrollResponseUp', callback),\n onScrollResponseDown: (callback) => ipcRenderer.on('aks:scrollResponseDown', callback),\n removeOnScrollResponseDown: (callback) => ipcRenderer.removeListener('aks:scrollResponseDown', callback)\n },\n\n // src/ui/listen/ListenView.js\n listenView: {\n // Window Management\n adjustWindowHeight: (winName, height) => ipcRenderer.invoke('adjust-window-height', { winName, height }),\n \n // Listeners\n onSessionStateChanged: (callback) => ipcRenderer.on('session-state-changed', callback),\n removeOnSessionStateChanged: (callback) => ipcRenderer.removeListener('session-state-changed', callback)\n },\n\n // src/ui/listen/stt/SttView.js\n sttView: {\n // Listeners\n onSttUpdate: (callback) => ipcRenderer.on('stt-update', callback),\n removeOnSttUpdate: (callback) => ipcRenderer.removeListener('stt-update', callback)\n },\n\n // src/ui/listen/summary/SummaryView.js\n summaryView: {\n // Message Handling\n sendQuestionFromSummary: (text) => ipcRenderer.invoke('ask:sendQuestionFromSummary', text),\n \n // Listeners\n onSummaryUpdate: (callback) => ipcRenderer.on('summary-update', callback),\n removeOnSummaryUpdate: (callback) => ipcRenderer.removeListener('summary-update', callback),\n removeAllSummaryUpdateListeners: () => ipcRenderer.removeAllListeners('summary-update')\n },\n\n // src/ui/settings/SettingsView.js\n settingsView: {\n // User & Auth\n getCurrentUser: () => ipcRenderer.invoke('get-current-user'),\n openPersonalizePage: () => ipcRenderer.invoke('open-personalize-page'),\n firebaseLogout: () => ipcRenderer.invoke('firebase-logout'),\n startFirebaseAuth: () => ipcRenderer.invoke('start-firebase-auth'),\n\n // Model & Provider Management\n getModelSettings: () => ipcRenderer.invoke('settings:get-model-settings'), // Facade call\n getProviderConfig: () => ipcRenderer.invoke('model:get-provider-config'),\n getAllKeys: () => ipcRenderer.invoke('model:get-all-keys'),\n getAvailableModels: (type) => ipcRenderer.invoke('model:get-available-models', type),\n getSelectedModels: () => ipcRenderer.invoke('model:get-selected-models'),\n validateKey: (data) => ipcRenderer.invoke('model:validate-key', data),\n saveApiKey: (key) => ipcRenderer.invoke('model:save-api-key', key),\n removeApiKey: (provider) => ipcRenderer.invoke('model:remove-api-key', provider),\n setSelectedModel: (data) => ipcRenderer.invoke('model:set-selected-model', data),\n \n // Ollama Management\n getOllamaStatus: () => ipcRenderer.invoke('ollama:get-status'),\n ensureOllamaReady: () => ipcRenderer.invoke('ollama:ensure-ready'),\n shutdownOllama: (graceful) => ipcRenderer.invoke('ollama:shutdown', graceful),\n \n // Whisper Management\n getWhisperInstalledModels: () => ipcRenderer.invoke('whisper:get-installed-models'),\n downloadWhisperModel: (modelId) => ipcRenderer.invoke('whisper:download-model', modelId),\n \n // Settings Management\n getPresets: () => ipcRenderer.invoke('settings:getPresets'),\n getAutoUpdate: () => ipcRenderer.invoke('settings:get-auto-update'),\n setAutoUpdate: (isEnabled) => ipcRenderer.invoke('settings:set-auto-update', isEnabled),\n getContentProtectionStatus: () => ipcRenderer.invoke('get-content-protection-status'),\n toggleContentProtection: () => ipcRenderer.invoke('toggle-content-protection'),\n getCurrentShortcuts: () => ipcRenderer.invoke('settings:getCurrentShortcuts'),\n openShortcutSettingsWindow: () => ipcRenderer.invoke('shortcut:openShortcutSettingsWindow'),\n \n // Window Management\n moveWindowStep: (direction) => ipcRenderer.invoke('move-window-step', direction),\n cancelHideSettingsWindow: () => ipcRenderer.send('cancel-hide-settings-window'),\n hideSettingsWindow: () => ipcRenderer.send('hide-settings-window'),\n \n // App Control\n quitApplication: () => ipcRenderer.invoke('quit-application'),\n \n // Progress Tracking\n pullOllamaModel: (modelName) => ipcRenderer.invoke('ollama:pull-model', modelName),\n \n // Listeners\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n onSettingsUpdated: (callback) => ipcRenderer.on('settings-updated', callback),\n removeOnSettingsUpdated: (callback) => ipcRenderer.removeListener('settings-updated', callback),\n onPresetsUpdated: (callback) => ipcRenderer.on('presets-updated', callback),\n removeOnPresetsUpdated: (callback) => ipcRenderer.removeListener('presets-updated', callback),\n onShortcutsUpdated: (callback) => ipcRenderer.on('shortcuts-updated', callback),\n removeOnShortcutsUpdated: (callback) => ipcRenderer.removeListener('shortcuts-updated', callback),\n // 통합 LocalAI 이벤트 사용\n onLocalAIInstallProgress: (callback) => ipcRenderer.on('localai:install-progress', callback),\n removeOnLocalAIInstallProgress: (callback) => ipcRenderer.removeListener('localai:install-progress', callback),\n onLocalAIInstallationComplete: (callback) => ipcRenderer.on('localai:installation-complete', callback),\n removeOnLocalAIInstallationComplete: (callback) => ipcRenderer.removeListener('localai:installation-complete', callback)\n },\n\n // src/ui/settings/ShortCutSettingsView.js\n shortcutSettingsView: {\n // Shortcut Management\n saveShortcuts: (shortcuts) => ipcRenderer.invoke('shortcut:saveShortcuts', shortcuts),\n getDefaultShortcuts: () => ipcRenderer.invoke('shortcut:getDefaultShortcuts'),\n closeShortcutSettingsWindow: () => ipcRenderer.invoke('shortcut:closeShortcutSettingsWindow'),\n \n // Listeners\n onLoadShortcuts: (callback) => ipcRenderer.on('shortcut:loadShortcuts', callback),\n removeOnLoadShortcuts: (callback) => ipcRenderer.removeListener('shortcut:loadShortcuts', callback)\n },\n\n // src/ui/app/content.html inline scripts\n content: {\n // Listeners\n onSettingsWindowHideAnimation: (callback) => ipcRenderer.on('settings-window-hide-animation', callback),\n removeOnSettingsWindowHideAnimation: (callback) => ipcRenderer.removeListener('settings-window-hide-animation', callback), \n },\n\n // src/ui/listen/audioCore/listenCapture.js\n listenCapture: {\n // Audio Management\n sendMicAudioContent: (data) => ipcRenderer.invoke('listen:sendMicAudio', data),\n sendSystemAudioContent: (data) => ipcRenderer.invoke('listen:sendSystemAudio', data),\n startMacosSystemAudio: () => ipcRenderer.invoke('listen:startMacosSystemAudio'),\n stopMacosSystemAudio: () => ipcRenderer.invoke('listen:stopMacosSystemAudio'),\n \n // Session Management\n isSessionActive: () => ipcRenderer.invoke('listen:isSessionActive'),\n \n // Listeners\n onSystemAudioData: (callback) => ipcRenderer.on('system-audio-data', callback),\n removeOnSystemAudioData: (callback) => ipcRenderer.removeListener('system-audio-data', callback)\n },\n\n // src/ui/listen/audioCore/renderer.js\n renderer: {\n // Listeners\n onChangeListenCaptureState: (callback) => ipcRenderer.on('change-listen-capture-state', callback),\n removeOnChangeListenCaptureState: (callback) => ipcRenderer.removeListener('change-listen-capture-state', callback)\n }\n});"], ["/glass/pickleglass_web/backend_node/routes/conversations.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/', async (req, res) => {\n try {\n const sessions = await ipcRequest(req, 'get-sessions');\n res.json(sessions);\n } catch (error) {\n console.error('Failed to get sessions via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve sessions' });\n }\n});\n\nrouter.post('/', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'create-session', req.body);\n res.status(201).json({ ...result, message: 'Session created successfully' });\n } catch (error) {\n console.error('Failed to create session via IPC:', error);\n res.status(500).json({ error: 'Failed to create session' });\n }\n});\n\nrouter.get('/:session_id', async (req, res) => {\n try {\n const details = await ipcRequest(req, 'get-session-details', req.params.session_id);\n if (!details) {\n return res.status(404).json({ error: 'Session not found' });\n }\n res.json(details);\n } catch (error) {\n console.error(`Failed to get session details via IPC for ${req.params.session_id}:`, error);\n res.status(500).json({ error: 'Failed to retrieve session details' });\n }\n});\n\nrouter.delete('/:session_id', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-session', req.params.session_id);\n res.status(200).json({ message: 'Session deleted successfully' });\n } catch (error) {\n console.error(`Failed to delete session via IPC for ${req.params.session_id}:`, error);\n res.status(500).json({ error: 'Failed to delete session' });\n }\n});\n\n// The search functionality will be more complex to move to IPC.\n// For now, we can disable it or leave it as is, knowing it's a future task.\nrouter.get('/search', (req, res) => {\n res.status(501).json({ error: 'Search not implemented for IPC bridge yet.' });\n});\n\nmodule.exports = router; "], ["/glass/src/features/common/repositories/user/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction findOrCreate(user) {\n const db = sqliteClient.getDb();\n \n if (!user || !user.uid) {\n throw new Error('User object and uid are required');\n }\n \n const { uid, displayName, email } = user;\n const now = Math.floor(Date.now() / 1000);\n \n // Validate inputs\n const safeDisplayName = displayName || 'User';\n const safeEmail = email || 'no-email@example.com';\n\n const query = `\n INSERT INTO users (uid, display_name, email, created_at)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(uid) DO UPDATE SET \n display_name=excluded.display_name, \n email=excluded.email\n `;\n \n try {\n console.log('[SQLite] Creating/updating user:', { uid, displayName: safeDisplayName, email: safeEmail });\n db.prepare(query).run(uid, safeDisplayName, safeEmail, now);\n const result = getById(uid);\n console.log('[SQLite] User operation successful:', result);\n return result;\n } catch (err) {\n console.error('SQLite: Failed to find or create user:', err);\n console.error('SQLite: User data:', { uid, displayName: safeDisplayName, email: safeEmail });\n throw new Error(`Failed to create user in database: ${err.message}`);\n }\n}\n\nfunction getById(uid) {\n const db = sqliteClient.getDb();\n return db.prepare('SELECT * FROM users WHERE uid = ?').get(uid);\n}\n\n\n\nfunction update({ uid, displayName }) {\n const db = sqliteClient.getDb();\n const result = db.prepare('UPDATE users SET display_name = ? WHERE uid = ?').run(displayName, uid);\n return { changes: result.changes };\n}\n\nfunction setMigrationComplete(uid) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('UPDATE users SET has_migrated_to_firebase = 1 WHERE uid = ?');\n const result = stmt.run(uid);\n if (result.changes > 0) {\n console.log(`[Repo] Marked migration as complete for user ${uid}.`);\n }\n return result;\n}\n\nfunction deleteById(uid) {\n const db = sqliteClient.getDb();\n const userSessions = db.prepare('SELECT id FROM sessions WHERE uid = ?').all(uid);\n const sessionIds = userSessions.map(s => s.id);\n\n const transaction = db.transaction(() => {\n if (sessionIds.length > 0) {\n const placeholders = sessionIds.map(() => '?').join(',');\n db.prepare(`DELETE FROM transcripts WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM ai_messages WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM summaries WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM sessions WHERE uid = ?`).run(uid);\n }\n db.prepare('DELETE FROM prompt_presets WHERE uid = ? AND is_default = 0').run(uid);\n db.prepare('DELETE FROM users WHERE uid = ?').run(uid);\n });\n\n try {\n transaction();\n return { success: true };\n } catch (err) {\n throw err;\n }\n}\n\nmodule.exports = {\n findOrCreate,\n getById,\n update,\n setMigrationComplete,\n deleteById\n}; "], ["/glass/src/features/common/repositories/ollamaModel/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\n/**\n * Get all Ollama models\n */\nfunction getAllModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get models:', err);\n throw err;\n }\n}\n\n/**\n * Get a specific model by name\n */\nfunction getModel(name) {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE name = ?';\n \n try {\n return db.prepare(query).get(name);\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get model:', err);\n throw err;\n }\n}\n\n/**\n * Create or update a model entry\n */\nfunction upsertModel({ name, size, installed = false, installing = false }) {\n const db = sqliteClient.getDb();\n const query = `\n INSERT INTO ollama_models (name, size, installed, installing)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(name) DO UPDATE SET \n size = excluded.size,\n installed = excluded.installed,\n installing = excluded.installing\n `;\n \n try {\n db.prepare(query).run(name, size, installed ? 1 : 0, installing ? 1 : 0);\n return { success: true };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to upsert model:', err);\n throw err;\n }\n}\n\n/**\n * Update installation status for a model\n */\nfunction updateInstallStatus(name, installed, installing = false) {\n const db = sqliteClient.getDb();\n const query = 'UPDATE ollama_models SET installed = ?, installing = ? WHERE name = ?';\n \n try {\n const result = db.prepare(query).run(installed ? 1 : 0, installing ? 1 : 0, name);\n return { success: true, changes: result.changes };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to update install status:', err);\n throw err;\n }\n}\n\n/**\n * Initialize default models - now done dynamically based on installed models\n */\nfunction initializeDefaultModels() {\n // Default models are now detected dynamically from Ollama installation\n // This function maintains compatibility but doesn't hardcode any models\n console.log('[OllamaModel Repository] Default models initialization skipped - using dynamic detection');\n return { success: true };\n}\n\n/**\n * Delete a model entry\n */\nfunction deleteModel(name) {\n const db = sqliteClient.getDb();\n const query = 'DELETE FROM ollama_models WHERE name = ?';\n \n try {\n const result = db.prepare(query).run(name);\n return { success: true, changes: result.changes };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to delete model:', err);\n throw err;\n }\n}\n\n/**\n * Get installed models\n */\nfunction getInstalledModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE installed = 1 ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get installed models:', err);\n throw err;\n }\n}\n\n/**\n * Get models currently being installed\n */\nfunction getInstallingModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE installing = 1 ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get installing models:', err);\n throw err;\n }\n}\n\nmodule.exports = {\n getAllModels,\n getModel,\n upsertModel,\n updateInstallStatus,\n initializeDefaultModels,\n deleteModel,\n getInstalledModels,\n getInstallingModels\n}; "], ["/glass/src/features/listen/summary/repositories/sqlite.repository.js", "const sqliteClient = require('../../../common/services/sqliteClient');\n\nfunction saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model = 'unknown' }) {\n // uid is ignored in the SQLite implementation\n return new Promise((resolve, reject) => {\n try {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n INSERT INTO summaries (session_id, generated_at, model, text, tldr, bullet_json, action_json, updated_at) \n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(session_id) DO UPDATE SET\n generated_at=excluded.generated_at,\n model=excluded.model,\n text=excluded.text,\n tldr=excluded.tldr,\n bullet_json=excluded.bullet_json,\n action_json=excluded.action_json,\n updated_at=excluded.updated_at\n `;\n \n const result = db.prepare(query).run(sessionId, now, model, text, tldr, bullet_json, action_json, now);\n resolve({ changes: result.changes });\n } catch (err) {\n console.error('Error saving summary:', err);\n reject(err);\n }\n });\n}\n\nfunction getSummaryBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM summaries WHERE session_id = ?\";\n return db.prepare(query).get(sessionId) || null;\n}\n\nmodule.exports = {\n saveSummary,\n getSummaryBySessionId,\n}; "], ["/glass/src/features/common/repositories/preset/firebase.repository.js", "const { collection, doc, addDoc, getDoc, getDocs, updateDoc, deleteDoc, query, where, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst userPresetConverter = createEncryptedConverter(['prompt', 'title']);\n\nconst defaultPresetConverter = {\n toFirestore: (data) => data,\n fromFirestore: (snapshot, options) => {\n const data = snapshot.data(options);\n return { ...data, id: snapshot.id };\n }\n};\n\nfunction userPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'prompt_presets').withConverter(userPresetConverter);\n}\n\nfunction defaultPresetsCol() {\n const db = getFirestoreInstance();\n // Path must have an odd number of segments. 'v1' is a placeholder document.\n return collection(db, 'defaults/v1/prompt_presets').withConverter(defaultPresetConverter);\n}\n\nasync function getPresets(uid) {\n const userPresetsQuery = query(userPresetsCol(), where('uid', '==', uid));\n const defaultPresetsQuery = query(defaultPresetsCol()); // Defaults have no owner\n\n const [userSnapshot, defaultSnapshot] = await Promise.all([\n getDocs(userPresetsQuery),\n getDocs(defaultPresetsQuery)\n ]);\n\n const presets = [\n ...defaultSnapshot.docs.map(d => d.data()),\n ...userSnapshot.docs.map(d => d.data())\n ];\n\n return presets.sort((a, b) => {\n if (a.is_default && !b.is_default) return -1;\n if (!a.is_default && b.is_default) return 1;\n return a.title.localeCompare(b.title);\n });\n}\n\nasync function getPresetTemplates() {\n const q = query(defaultPresetsCol(), orderBy('title', 'asc'));\n const snapshot = await getDocs(q);\n return snapshot.docs.map(doc => doc.data());\n}\n\nasync function create({ uid, title, prompt }) {\n const now = Timestamp.now();\n const newPreset = {\n uid: uid,\n title,\n prompt,\n is_default: 0,\n created_at: now,\n };\n const docRef = await addDoc(userPresetsCol(), newPreset);\n return { id: docRef.id };\n}\n\nasync function update(id, { title, prompt }, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to update.\");\n }\n\n // Encrypt sensitive fields before sending to Firestore because `updateDoc` bypasses converters.\n const updates = {};\n if (title !== undefined) {\n updates.title = encryptionService.encrypt(title);\n }\n if (prompt !== undefined) {\n updates.prompt = encryptionService.encrypt(prompt);\n }\n updates.updated_at = Timestamp.now();\n\n await updateDoc(docRef, updates);\n return { changes: 1 };\n}\n\nasync function del(id, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to delete.\");\n }\n\n await deleteDoc(docRef);\n return { changes: 1 };\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n create,\n update,\n delete: del,\n}; "], ["/glass/src/features/shortcuts/repositories/sqlite.repository.js", "const sqliteClient = require('../../common/services/sqliteClient');\nconst crypto = require('crypto');\n\nfunction getAllKeybinds() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM shortcuts';\n try {\n return db.prepare(query).all();\n } catch (error) {\n console.error(`[DB] Failed to get keybinds:`, error);\n return [];\n }\n}\n\nfunction upsertKeybinds(keybinds) {\n if (!keybinds || keybinds.length === 0) return;\n\n const db = sqliteClient.getDb();\n const upsert = db.transaction((items) => {\n const query = `\n INSERT INTO shortcuts (action, accelerator, created_at)\n VALUES (@action, @accelerator, @created_at)\n ON CONFLICT(action) DO UPDATE SET\n accelerator = excluded.accelerator;\n `;\n const insert = db.prepare(query);\n\n for (const item of items) {\n insert.run({\n action: item.action,\n accelerator: item.accelerator,\n created_at: Math.floor(Date.now() / 1000)\n });\n }\n });\n\n try {\n upsert(keybinds);\n } catch (error) {\n console.error('[DB] Failed to upsert keybinds:', error);\n throw error;\n }\n}\n\nmodule.exports = {\n getAllKeybinds,\n upsertKeybinds\n}; "], ["/glass/pickleglass_web/backend_node/routes/auth.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/status', async (req, res) => {\n try {\n const user = await ipcRequest(req, 'get-user-profile');\n if (!user) {\n return res.status(500).json({ error: 'Default user not initialized' });\n }\n res.json({ \n authenticated: true, \n user: {\n id: user.uid,\n name: user.display_name\n }\n });\n } catch (error) {\n console.error('Failed to get auth status via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve auth status' });\n }\n});\n\nmodule.exports = router;\n"], ["/glass/pickleglass_web/tailwind.config.js", "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n content: [\n './pages/**/*.{js,ts,jsx,tsx,mdx}',\n './components/**/*.{js,ts,jsx,tsx,mdx}',\n './app/**/*.{js,ts,jsx,tsx,mdx}',\n ],\n theme: {\n extend: {\n colors: {\n primary: '#3b82f6',\n secondary: '#64748b',\n accent: '#06b6d4',\n 'subtle-bg': '#f8f7f4',\n 'subtle-active-bg': '#e7e5e4',\n },\n },\n },\n plugins: [],\n} "], ["/glass/build.js", "const esbuild = require('esbuild');\nconst path = require('path');\n\nconst baseConfig = {\n bundle: true,\n platform: 'browser',\n format: 'esm',\n loader: { '.js': 'jsx' },\n sourcemap: true,\n external: ['electron'],\n define: {\n 'process.env.NODE_ENV': `\"${process.env.NODE_ENV || 'development'}\"`,\n },\n};\n\nconst entryPoints = [\n { in: 'src/ui/app/HeaderController.js', out: 'public/build/header' },\n { in: 'src/ui/app/PickleGlassApp.js', out: 'public/build/content' },\n];\n\nasync function build() {\n try {\n console.log('Building renderer process code...');\n await Promise.all(entryPoints.map(point => esbuild.build({\n ...baseConfig,\n entryPoints: [point.in],\n outfile: `${point.out}.js`,\n })));\n console.log('✅ Renderer builds successful!');\n } catch (e) {\n console.error('Renderer build failed:', e);\n process.exit(1);\n }\n}\n\nasync function watch() {\n try {\n const contexts = await Promise.all(entryPoints.map(point => esbuild.context({\n ...baseConfig,\n entryPoints: [point.in],\n outfile: `${point.out}.js`,\n })));\n \n console.log('Watching for changes...');\n await Promise.all(contexts.map(context => context.watch()));\n\n } catch (e) {\n console.error('Watch mode failed:', e);\n process.exit(1);\n }\n}\n\nif (process.argv.includes('--watch')) {\n watch();\n} else {\n build();\n} "], ["/glass/src/features/common/repositories/preset/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction getPresets(uid) {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE uid = ? OR is_default = 1 \n ORDER BY is_default DESC, title ASC\n `;\n \n try {\n return db.prepare(query).all(uid);\n } catch (err) {\n console.error('SQLite: Failed to get presets:', err);\n throw err;\n }\n}\n\nfunction getPresetTemplates() {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE is_default = 1 \n ORDER BY title ASC\n `;\n \n try {\n return db.prepare(query).all();\n } catch (err) {\n console.error('SQLite: Failed to get preset templates:', err);\n throw err;\n }\n}\n\nfunction create({ uid, title, prompt }) {\n const db = sqliteClient.getDb();\n const presetId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO prompt_presets (id, uid, title, prompt, is_default, created_at, sync_state) VALUES (?, ?, ?, ?, 0, ?, 'dirty')`;\n \n try {\n db.prepare(query).run(presetId, uid, title, prompt, now);\n return { id: presetId };\n } catch (err) {\n throw err;\n }\n}\n\nfunction update(id, { title, prompt }, uid) {\n const db = sqliteClient.getDb();\n const query = `UPDATE prompt_presets SET title = ?, prompt = ?, sync_state = 'dirty' WHERE id = ? AND uid = ? AND is_default = 0`;\n\n try {\n const result = db.prepare(query).run(title, prompt, id, uid);\n if (result.changes === 0) {\n throw new Error(\"Preset not found or permission denied.\");\n }\n return { changes: result.changes };\n } catch (err) {\n throw err;\n }\n}\n\nfunction del(id, uid) {\n const db = sqliteClient.getDb();\n const query = `DELETE FROM prompt_presets WHERE id = ? AND uid = ? AND is_default = 0`;\n\n try {\n const result = db.prepare(query).run(id, uid);\n if (result.changes === 0) {\n throw new Error(\"Preset not found or permission denied.\");\n }\n return { changes: result.changes };\n } catch (err) {\n throw err;\n }\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n create,\n update,\n delete: del\n}; "], ["/glass/src/features/common/repositories/firestoreConverter.js", "const encryptionService = require('../services/encryptionService');\nconst { Timestamp } = require('firebase/firestore');\n\n/**\n * Creates a Firestore converter that automatically encrypts and decrypts specified fields.\n * @param {string[]} fieldsToEncrypt - An array of field names to encrypt.\n * @returns {import('@firebase/firestore').FirestoreDataConverter} A Firestore converter.\n * @template T\n */\nfunction createEncryptedConverter(fieldsToEncrypt = []) {\n return {\n /**\n * @param {import('@firebase/firestore').DocumentData} appObject\n */\n toFirestore: (appObject) => {\n const firestoreData = { ...appObject };\n for (const field of fieldsToEncrypt) {\n if (Object.prototype.hasOwnProperty.call(firestoreData, field) && firestoreData[field] != null) {\n firestoreData[field] = encryptionService.encrypt(firestoreData[field]);\n }\n }\n // Ensure there's a timestamp for the last modification\n firestoreData.updated_at = Timestamp.now();\n return firestoreData;\n },\n /**\n * @param {import('@firebase/firestore').QueryDocumentSnapshot} snapshot\n * @param {import('@firebase/firestore').SnapshotOptions} options\n */\n fromFirestore: (snapshot, options) => {\n const firestoreData = snapshot.data(options);\n const appObject = { ...firestoreData, id: snapshot.id }; // include the document ID\n\n for (const field of fieldsToEncrypt) {\n if (Object.prototype.hasOwnProperty.call(appObject, field) && appObject[field] != null) {\n try {\n appObject[field] = encryptionService.decrypt(appObject[field]);\n } catch (error) {\n console.warn(`[FirestoreConverter] Failed to decrypt field '${field}' (possibly plaintext or key mismatch):`, error.message);\n // Keep the original value instead of failing\n // appObject[field] remains as is\n }\n }\n }\n\n // Convert Firestore Timestamps back to Unix timestamps (seconds) for app-wide consistency\n for (const key in appObject) {\n if (appObject[key] instanceof Timestamp) {\n appObject[key] = appObject[key].seconds;\n }\n }\n \n return appObject;\n }\n };\n}\n\nmodule.exports = {\n createEncryptedConverter,\n}; "], ["/glass/pickleglass_web/backend_node/routes/presets.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/', async (req, res) => {\n try {\n const presets = await ipcRequest(req, 'get-presets');\n res.json(presets);\n } catch (error) {\n console.error('Failed to get presets via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve presets' });\n }\n});\n\nrouter.post('/', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'create-preset', req.body);\n res.status(201).json({ ...result, message: 'Preset created successfully' });\n } catch (error) {\n console.error('Failed to create preset via IPC:', error);\n res.status(500).json({ error: 'Failed to create preset' });\n }\n});\n\nrouter.put('/:id', async (req, res) => {\n try {\n await ipcRequest(req, 'update-preset', { id: req.params.id, data: req.body });\n res.json({ message: 'Preset updated successfully' });\n } catch (error) {\n console.error('Failed to update preset via IPC:', error);\n res.status(500).json({ error: 'Failed to update preset' });\n }\n});\n\nrouter.delete('/:id', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-preset', req.params.id);\n res.json({ message: 'Preset deleted successfully' });\n } catch (error) {\n console.error('Failed to delete preset via IPC:', error);\n res.status(500).json({ error: 'Failed to delete preset' });\n }\n});\n\nmodule.exports = router; "], ["/glass/src/features/listen/summary/repositories/firebase.repository.js", "const { collection, doc, setDoc, getDoc, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../../common/repositories/firestoreConverter');\nconst encryptionService = require('../../../common/services/encryptionService');\n\nconst fieldsToEncrypt = ['tldr', 'text', 'bullet_json', 'action_json'];\nconst summaryConverter = createEncryptedConverter(fieldsToEncrypt);\n\nfunction summaryDocRef(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access summary.\");\n const db = getFirestoreInstance();\n // Reverting to the original structure with 'data' as the document ID.\n const docPath = `sessions/${sessionId}/summary/data`;\n return doc(db, docPath).withConverter(summaryConverter);\n}\n\nasync function saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model = 'unknown' }) {\n const now = Timestamp.now();\n const summaryData = {\n uid, // To know who generated the summary\n session_id: sessionId,\n generated_at: now,\n model,\n text,\n tldr,\n bullet_json,\n action_json,\n updated_at: now,\n };\n \n // The converter attached to summaryDocRef will handle encryption via its `toFirestore` method.\n // Manual encryption was removed to fix the double-encryption bug.\n const docRef = summaryDocRef(sessionId);\n await setDoc(docRef, summaryData, { merge: true });\n\n return { changes: 1 };\n}\n\nasync function getSummaryBySessionId(sessionId) {\n const docRef = summaryDocRef(sessionId);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\nmodule.exports = {\n saveSummary,\n getSummaryBySessionId,\n}; "], ["/glass/src/features/common/utils/spawnHelper.js", "const { spawn } = require('child_process');\n\nfunction spawnAsync(command, args = [], options = {}) {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, options);\n let stdout = '';\n let stderr = '';\n\n if (child.stdout) {\n child.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n }\n\n if (child.stderr) {\n child.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n }\n\n child.on('error', (error) => {\n reject(error);\n });\n\n child.on('close', (code) => {\n if (code === 0) {\n resolve({ stdout, stderr });\n } else {\n const error = new Error(`Command failed with code ${code}: ${stderr || stdout}`);\n error.code = code;\n error.stdout = stdout;\n error.stderr = stderr;\n reject(error);\n }\n });\n });\n}\n\nmodule.exports = { spawnAsync };"], ["/glass/src/features/common/config/schema.js", "const LATEST_SCHEMA = {\n users: {\n columns: [\n { name: 'uid', type: 'TEXT PRIMARY KEY' },\n { name: 'display_name', type: 'TEXT NOT NULL' },\n { name: 'email', type: 'TEXT NOT NULL' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'auto_update_enabled', type: 'INTEGER DEFAULT 1' },\n { name: 'has_migrated_to_firebase', type: 'INTEGER DEFAULT 0' }\n ]\n },\n sessions: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'uid', type: 'TEXT NOT NULL' },\n { name: 'title', type: 'TEXT' },\n { name: 'session_type', type: 'TEXT DEFAULT \\'ask\\'' },\n { name: 'started_at', type: 'INTEGER' },\n { name: 'ended_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' },\n { name: 'updated_at', type: 'INTEGER' }\n ]\n },\n transcripts: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'session_id', type: 'TEXT NOT NULL' },\n { name: 'start_at', type: 'INTEGER' },\n { name: 'end_at', type: 'INTEGER' },\n { name: 'speaker', type: 'TEXT' },\n { name: 'text', type: 'TEXT' },\n { name: 'lang', type: 'TEXT' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n ai_messages: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'session_id', type: 'TEXT NOT NULL' },\n { name: 'sent_at', type: 'INTEGER' },\n { name: 'role', type: 'TEXT' },\n { name: 'content', type: 'TEXT' },\n { name: 'tokens', type: 'INTEGER' },\n { name: 'model', type: 'TEXT' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n summaries: {\n columns: [\n { name: 'session_id', type: 'TEXT PRIMARY KEY' },\n { name: 'generated_at', type: 'INTEGER' },\n { name: 'model', type: 'TEXT' },\n { name: 'text', type: 'TEXT' },\n { name: 'tldr', type: 'TEXT' },\n { name: 'bullet_json', type: 'TEXT' },\n { name: 'action_json', type: 'TEXT' },\n { name: 'tokens_used', type: 'INTEGER' },\n { name: 'updated_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n prompt_presets: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'uid', type: 'TEXT NOT NULL' },\n { name: 'title', type: 'TEXT NOT NULL' },\n { name: 'prompt', type: 'TEXT NOT NULL' },\n { name: 'is_default', type: 'INTEGER NOT NULL' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n ollama_models: {\n columns: [\n { name: 'name', type: 'TEXT PRIMARY KEY' },\n { name: 'size', type: 'TEXT NOT NULL' },\n { name: 'installed', type: 'INTEGER DEFAULT 0' },\n { name: 'installing', type: 'INTEGER DEFAULT 0' }\n ]\n },\n whisper_models: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'name', type: 'TEXT NOT NULL' },\n { name: 'size', type: 'TEXT NOT NULL' },\n { name: 'installed', type: 'INTEGER DEFAULT 0' },\n { name: 'installing', type: 'INTEGER DEFAULT 0' }\n ]\n },\n provider_settings: {\n columns: [\n { name: 'provider', type: 'TEXT NOT NULL' },\n { name: 'api_key', type: 'TEXT' },\n { name: 'selected_llm_model', type: 'TEXT' },\n { name: 'selected_stt_model', type: 'TEXT' },\n { name: 'is_active_llm', type: 'INTEGER DEFAULT 0' },\n { name: 'is_active_stt', type: 'INTEGER DEFAULT 0' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'updated_at', type: 'INTEGER' }\n ],\n constraints: ['PRIMARY KEY (provider)']\n },\n shortcuts: {\n columns: [\n { name: 'action', type: 'TEXT PRIMARY KEY' },\n { name: 'accelerator', type: 'TEXT NOT NULL' },\n { name: 'created_at', type: 'INTEGER' }\n ]\n },\n permissions: {\n columns: [\n { name: 'uid', type: 'TEXT PRIMARY KEY' },\n { name: 'keychain_completed', type: 'INTEGER DEFAULT 0' }\n ]\n }\n};\n\nmodule.exports = LATEST_SCHEMA; "], ["/glass/pickleglass_web/backend_node/ipcBridge.js", "const crypto = require('crypto');\n\nfunction ipcRequest(req, channel, payload) {\n return new Promise((resolve, reject) => {\n // Immediately check bridge status and fail if it's not available.\n if (!req.bridge || typeof req.bridge.emit !== 'function') {\n reject(new Error('IPC bridge is not available'));\n return;\n }\n\n const responseChannel = `${channel}-${crypto.randomUUID()}`;\n \n req.bridge.once(responseChannel, (response) => {\n if (!response) {\n reject(new Error(`No response received from ${channel}`));\n return;\n }\n \n if (response.success) {\n resolve(response.data);\n } else {\n reject(new Error(response.error || `IPC request to ${channel} failed`));\n }\n });\n\n try {\n req.bridge.emit('web-data-request', channel, responseChannel, payload);\n } catch (error) {\n req.bridge.removeAllListeners(responseChannel);\n reject(new Error(`Failed to emit IPC request: ${error.message}`));\n }\n });\n}\n\nmodule.exports = { ipcRequest }; "], ["/glass/notarize.js", "const { notarize } = require('@electron/notarize');\n\nexports.notarizeApp = async function (context) {\n if (context.electronPlatformName !== 'darwin') {\n return;\n }\n\n console.log(' notarizing a macOS build!');\n\n const { appOutDir } = context;\n const appName = context.packager.appInfo.productFilename;\n const appPath = `${appOutDir}/${appName}.app`;\n\n if (!process.env.APPLE_ID || !process.env.APPLE_ID_PASSWORD || !process.env.APPLE_TEAM_ID) {\n throw new Error('APPLE_ID, APPLE_ID_PASSWORD, and APPLE_TEAM_ID environment variables are required for notarization.');\n }\n\n await notarize({\n appBundleId: 'com.pickle.glass',\n appPath: appPath,\n appleId: process.env.APPLE_ID,\n appleIdPassword: process.env.APPLE_ID_PASSWORD,\n teamId: process.env.APPLE_TEAM_ID,\n });\n\n console.log(`Successfully notarized ${appName}`);\n}; "], ["/glass/src/features/listen/stt/repositories/sqlite.repository.js", "const sqliteClient = require('../../../common/services/sqliteClient');\n\nfunction addTranscript({ uid, sessionId, speaker, text }) {\n // uid is ignored in the SQLite implementation\n const db = sqliteClient.getDb();\n const transcriptId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO transcripts (id, session_id, start_at, speaker, text, created_at) VALUES (?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(transcriptId, sessionId, now, speaker, text, now);\n return { id: transcriptId };\n } catch (err) {\n console.error('Error adding transcript:', err);\n throw err;\n }\n}\n\nfunction getAllTranscriptsBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM transcripts WHERE session_id = ? ORDER BY start_at ASC\";\n return db.prepare(query).all(sessionId);\n}\n\nmodule.exports = {\n addTranscript,\n getAllTranscriptsBySessionId,\n}; "], ["/glass/src/features/ask/repositories/sqlite.repository.js", "const sqliteClient = require('../../common/services/sqliteClient');\n\nfunction addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n // uid is ignored in the SQLite implementation\n const db = sqliteClient.getDb();\n const messageId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO ai_messages (id, session_id, sent_at, role, content, model, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(messageId, sessionId, now, role, content, model, now);\n return { id: messageId };\n } catch (err) {\n console.error('SQLite: Failed to add AI message:', err);\n throw err;\n }\n}\n\nfunction getAllAiMessagesBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM ai_messages WHERE session_id = ? ORDER BY sent_at ASC\";\n return db.prepare(query).all(sessionId);\n}\n\nmodule.exports = {\n addAiMessage,\n getAllAiMessagesBySessionId\n}; "], ["/glass/src/features/common/repositories/providerSettings/index.js", "const sqliteRepository = require('./sqlite.repository');\n\nfunction getBaseRepository() {\n // For now, we only have sqlite. This could be expanded later.\n return sqliteRepository;\n}\n\nconst providerSettingsRepositoryAdapter = {\n // Core CRUD operations\n async getByProvider(provider) {\n const repo = getBaseRepository();\n return await repo.getByProvider(provider);\n },\n\n async getAll() {\n const repo = getBaseRepository();\n return await repo.getAll();\n },\n\n async upsert(provider, settings) {\n const repo = getBaseRepository();\n const now = Date.now();\n \n const settingsWithMeta = {\n ...settings,\n provider,\n updated_at: now,\n created_at: settings.created_at || now\n };\n \n return await repo.upsert(provider, settingsWithMeta);\n },\n\n async remove(provider) {\n const repo = getBaseRepository();\n return await repo.remove(provider);\n },\n\n async removeAll() {\n const repo = getBaseRepository();\n return await repo.removeAll();\n },\n\n async getRawApiKeys() {\n // This function should always target the local sqlite DB,\n // as it's part of the local-first boot sequence.\n return await sqliteRepository.getRawApiKeys();\n },\n \n async getActiveProvider(type) {\n const repo = getBaseRepository();\n return await repo.getActiveProvider(type);\n },\n \n async setActiveProvider(provider, type) {\n const repo = getBaseRepository();\n return await repo.setActiveProvider(provider, type);\n },\n \n async getActiveSettings() {\n const repo = getBaseRepository();\n return await repo.getActiveSettings();\n }\n};\n\nmodule.exports = {\n ...providerSettingsRepositoryAdapter\n}; "], ["/glass/src/ui/listen/audioCore/renderer.js", "// renderer.js\nconst listenCapture = require('./listenCapture.js');\nconst params = new URLSearchParams(window.location.search);\nconst isListenView = params.get('view') === 'listen';\n\n\nwindow.pickleGlass = {\n startCapture: listenCapture.startCapture,\n stopCapture: listenCapture.stopCapture,\n isLinux: listenCapture.isLinux,\n isMacOS: listenCapture.isMacOS,\n captureManualScreenshot: listenCapture.captureManualScreenshot,\n getCurrentScreenshot: listenCapture.getCurrentScreenshot,\n};\n\n\nwindow.api.renderer.onChangeListenCaptureState((_event, { status }) => {\n if (!isListenView) {\n console.log('[Renderer] Non-listen view: ignoring capture-state change');\n return;\n }\n if (status === \"stop\") {\n console.log('[Renderer] Session ended – stopping local capture');\n listenCapture.stopCapture();\n } else {\n console.log('[Renderer] Session initialized – starting local capture');\n listenCapture.startCapture();\n }\n});\n"], ["/glass/src/bridge/windowBridge.js", "// src/bridge/windowBridge.js\nconst { ipcMain, shell } = require('electron');\n\n// Bridge는 단순히 IPC 핸들러를 등록하는 역할만 함 (비즈니스 로직 없음)\nmodule.exports = {\n initialize() {\n // initialize 시점에 windowManager를 require하여 circular dependency 문제 해결\n const windowManager = require('../window/windowManager');\n \n // 기존 IPC 핸들러들\n ipcMain.handle('toggle-content-protection', () => windowManager.toggleContentProtection());\n ipcMain.handle('resize-header-window', (event, args) => windowManager.resizeHeaderWindow(args));\n ipcMain.handle('get-content-protection-status', () => windowManager.getContentProtectionStatus());\n ipcMain.on('show-settings-window', () => windowManager.showSettingsWindow());\n ipcMain.on('hide-settings-window', () => windowManager.hideSettingsWindow());\n ipcMain.on('cancel-hide-settings-window', () => windowManager.cancelHideSettingsWindow());\n\n ipcMain.handle('open-login-page', () => windowManager.openLoginPage());\n ipcMain.handle('open-personalize-page', () => windowManager.openLoginPage());\n ipcMain.handle('move-window-step', (event, direction) => windowManager.moveWindowStep(direction));\n ipcMain.handle('open-external', (event, url) => shell.openExternal(url));\n\n // Newly moved handlers from windowManager\n ipcMain.on('header-state-changed', (event, state) => windowManager.handleHeaderStateChanged(state));\n ipcMain.on('header-animation-finished', (event, state) => windowManager.handleHeaderAnimationFinished(state));\n ipcMain.handle('get-header-position', () => windowManager.getHeaderPosition());\n ipcMain.handle('move-header-to', (event, newX, newY) => windowManager.moveHeaderTo(newX, newY));\n ipcMain.handle('adjust-window-height', (event, { winName, height }) => windowManager.adjustWindowHeight(winName, height));\n },\n\n notifyFocusChange(win, isFocused) {\n win.webContents.send('window:focus-change', isFocused);\n }\n};"], ["/glass/src/features/listen/stt/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst sttRepositoryAdapter = {\n addTranscript: ({ sessionId, speaker, text }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().addTranscript({ uid, sessionId, speaker, text });\n },\n getAllTranscriptsBySessionId: (sessionId) => {\n return getBaseRepository().getAllTranscriptsBySessionId(sessionId);\n }\n};\n\nmodule.exports = sttRepositoryAdapter; "], ["/glass/src/features/common/repositories/permission/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction markKeychainCompleted(uid) {\n return sqliteClient.query(\n 'INSERT OR REPLACE INTO permissions (uid, keychain_completed) VALUES (?, 1)',\n [uid]\n );\n}\n\nfunction checkKeychainCompleted(uid) {\n const row = sqliteClient.query('SELECT keychain_completed FROM permissions WHERE uid = ?', [uid]);\n return row.length > 0 && row[0].keychain_completed === 1;\n}\n\nmodule.exports = {\n markKeychainCompleted,\n checkKeychainCompleted\n}; "], ["/glass/src/features/common/repositories/session/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\n\nlet authService = null;\n\nfunction setAuthService(service) {\n authService = service;\n}\n\nfunction getBaseRepository() {\n if (!authService) {\n // Fallback or error if authService is not set, to prevent crashes.\n // During initial load, it might not be set, so we default to sqlite.\n return sqliteRepository;\n }\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\n// The adapter layer that injects the UID\nconst sessionRepositoryAdapter = {\n setAuthService, // Expose the setter\n\n getById: (id) => getBaseRepository().getById(id),\n \n create: (type = 'ask') => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().create(uid, type);\n },\n \n getAllByUserId: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getAllByUserId(uid);\n },\n\n updateTitle: (id, title) => getBaseRepository().updateTitle(id, title),\n \n deleteWithRelatedData: (id) => getBaseRepository().deleteWithRelatedData(id),\n\n end: (id) => getBaseRepository().end(id),\n\n updateType: (id, type) => getBaseRepository().updateType(id, type),\n\n touch: (id) => getBaseRepository().touch(id),\n\n getOrCreateActive: (requestedType = 'ask') => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getOrCreateActive(uid, requestedType);\n },\n\n endAllActiveSessions: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().endAllActiveSessions(uid);\n },\n};\n\nmodule.exports = sessionRepositoryAdapter; "], ["/glass/src/features/listen/stt/repositories/firebase.repository.js", "const { collection, addDoc, query, getDocs, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../../common/repositories/firestoreConverter');\n\nconst transcriptConverter = createEncryptedConverter(['text']);\n\nfunction transcriptsCol(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access transcripts.\");\n const db = getFirestoreInstance();\n return collection(db, `sessions/${sessionId}/transcripts`).withConverter(transcriptConverter);\n}\n\nasync function addTranscript({ uid, sessionId, speaker, text }) {\n const now = Timestamp.now();\n const newTranscript = {\n uid, // To identify the author/source of the transcript\n session_id: sessionId,\n start_at: now,\n speaker,\n text,\n created_at: now,\n };\n const docRef = await addDoc(transcriptsCol(sessionId), newTranscript);\n return { id: docRef.id };\n}\n\nasync function getAllTranscriptsBySessionId(sessionId) {\n const q = query(transcriptsCol(sessionId), orderBy('start_at', 'asc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nmodule.exports = {\n addTranscript,\n getAllTranscriptsBySessionId,\n}; "], ["/glass/src/features/common/repositories/user/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\n\nlet authService = null;\n\nfunction getAuthService() {\n if (!authService) {\n authService = require('../../services/authService');\n }\n return authService;\n}\n\nfunction getBaseRepository() {\n const service = getAuthService();\n if (!service) {\n throw new Error('AuthService could not be loaded for the user repository.');\n }\n const user = service.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst userRepositoryAdapter = {\n findOrCreate: (user) => {\n // This function receives the full user object, which includes the uid. No need to inject.\n return getBaseRepository().findOrCreate(user);\n },\n \n getById: () => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().getById(uid);\n },\n\n\n\n update: (updateData) => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().update({ uid, ...updateData });\n },\n\n deleteById: () => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().deleteById(uid);\n }\n};\n\nmodule.exports = {\n ...userRepositoryAdapter\n}; "], ["/glass/src/features/listen/summary/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst summaryRepositoryAdapter = {\n saveSummary: ({ sessionId, tldr, text, bullet_json, action_json, model }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model });\n },\n getSummaryBySessionId: (sessionId) => {\n return getBaseRepository().getSummaryBySessionId(sessionId);\n }\n};\n\nmodule.exports = summaryRepositoryAdapter; "], ["/glass/src/features/ask/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\n// The adapter layer that injects the UID\nconst askRepositoryAdapter = {\n addAiMessage: ({ sessionId, role, content, model }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().addAiMessage({ uid, sessionId, role, content, model });\n },\n getAllAiMessagesBySessionId: (sessionId) => {\n // This function does not require a UID at the service level.\n return getBaseRepository().getAllAiMessagesBySessionId(sessionId);\n }\n};\n\nmodule.exports = askRepositoryAdapter; "], ["/glass/src/features/ask/repositories/firebase.repository.js", "const { collection, addDoc, query, getDocs, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../common/repositories/firestoreConverter');\n\nconst aiMessageConverter = createEncryptedConverter(['content']);\n\nfunction aiMessagesCol(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access AI messages.\");\n const db = getFirestoreInstance();\n return collection(db, `sessions/${sessionId}/ai_messages`).withConverter(aiMessageConverter);\n}\n\nasync function addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n const now = Timestamp.now();\n const newMessage = {\n uid, // To identify the author of the message\n session_id: sessionId,\n sent_at: now,\n role,\n content,\n model,\n created_at: now,\n };\n \n const docRef = await addDoc(aiMessagesCol(sessionId), newMessage);\n return { id: docRef.id };\n}\n\nasync function getAllAiMessagesBySessionId(sessionId) {\n const q = query(aiMessagesCol(sessionId), orderBy('sent_at', 'asc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nmodule.exports = {\n addAiMessage,\n getAllAiMessagesBySessionId,\n}; "], ["/glass/src/features/common/repositories/preset/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst presetRepositoryAdapter = {\n getPresets: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getPresets(uid);\n },\n\n getPresetTemplates: () => {\n return getBaseRepository().getPresetTemplates();\n },\n\n create: (options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().create({ uid, ...options });\n },\n\n update: (id, options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().update(id, options, uid);\n },\n\n delete: (id) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().delete(id, uid);\n },\n};\n\nmodule.exports = presetRepositoryAdapter; "], ["/glass/src/features/settings/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst settingsRepositoryAdapter = {\n getPresets: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getPresets(uid);\n },\n\n getPresetTemplates: () => {\n return getBaseRepository().getPresetTemplates();\n },\n\n createPreset: (options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().createPreset({ uid, ...options });\n },\n\n updatePreset: (id, options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().updatePreset(id, options, uid);\n },\n\n deletePreset: (id) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().deletePreset(id, uid);\n },\n\n getAutoUpdate: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getAutoUpdate(uid);\n },\n\n setAutoUpdate: (isEnabled) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().setAutoUpdate(uid, isEnabled);\n },\n};\n\nmodule.exports = settingsRepositoryAdapter;\n"], ["/glass/src/features/common/prompts/promptBuilder.js", "const { profilePrompts } = require('./promptTemplates.js');\n\nfunction buildSystemPrompt(promptParts, customPrompt = '', googleSearchEnabled = true) {\n const sections = [promptParts.intro, '\\n\\n', promptParts.formatRequirements];\n\n if (googleSearchEnabled) {\n sections.push('\\n\\n', promptParts.searchUsage);\n }\n\n sections.push('\\n\\n', promptParts.content, '\\n\\nUser-provided context\\n-----\\n', customPrompt, '\\n-----\\n\\n', promptParts.outputInstructions);\n\n return sections.join('');\n}\n\nfunction getSystemPrompt(profile, customPrompt = '', googleSearchEnabled = true) {\n const promptParts = profilePrompts[profile] || profilePrompts.interview;\n return buildSystemPrompt(promptParts, customPrompt, googleSearchEnabled);\n}\n\nmodule.exports = {\n getSystemPrompt,\n};\n"], ["/glass/pickleglass_web/backend_node/middleware/auth.js", "function identifyUser(req, res, next) {\n const userId = req.get('X-User-ID');\n\n if (userId) {\n req.uid = userId;\n } else {\n req.uid = 'default_user';\n }\n \n next();\n}\n\nmodule.exports = { identifyUser }; "], ["/glass/pickleglass_web/next.config.js", "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n reactStrictMode: true,\n swcMinify: true,\n output: 'export',\n\n images: { unoptimized: true },\n}\n\nmodule.exports = nextConfig "], ["/glass/src/features/common/repositories/permission/index.js", "const sqliteRepository = require('./sqlite.repository');\n\n// This repository is not user-specific, so we always return sqlite.\nfunction getRepository() {\n return sqliteRepository;\n}\n\nmodule.exports = {\n markKeychainCompleted: (...args) => getRepository().markKeychainCompleted(...args),\n checkKeychainCompleted: (...args) => getRepository().checkKeychainCompleted(...args),\n}; "], ["/glass/src/features/common/repositories/ollamaModel/index.js", "const sqliteRepository = require('./sqlite.repository');\n\n// For now, we only use SQLite repository\n// In the future, we could add cloud sync support\n\nfunction getRepository() {\n return sqliteRepository;\n}\n\n// Export all repository methods\nmodule.exports = {\n getAllModels: (...args) => getRepository().getAllModels(...args),\n getModel: (...args) => getRepository().getModel(...args),\n upsertModel: (...args) => getRepository().upsertModel(...args),\n updateInstallStatus: (...args) => getRepository().updateInstallStatus(...args),\n initializeDefaultModels: (...args) => getRepository().initializeDefaultModels(...args),\n deleteModel: (...args) => getRepository().deleteModel(...args),\n getInstalledModels: (...args) => getRepository().getInstalledModels(...args),\n getInstallingModels: (...args) => getRepository().getInstallingModels(...args)\n}; "], ["/glass/pickleglass_web/postcss.config.js", "module.exports = {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n} "], ["/glass/src/bridge/internalBridge.js", "// src/bridge/internalBridge.js\nconst { EventEmitter } = require('events');\n\n// FeatureCore와 WindowCore를 잇는 내부 이벤트 버스\nconst internalBridge = new EventEmitter();\nmodule.exports = internalBridge;\n\n// 예시 이벤트\n// internalBridge.on('content-protection-changed', (enabled) => {\n// // windowManager에서 처리\n// });"], ["/glass/src/features/shortcuts/repositories/index.js", "module.exports = require('./sqlite.repository'); "], ["/glass/preload.js", ""]], "task_instance_info": {"created_time": "2025-08-21 00:01:29", "created_task_model": "DeepSeek-R1", "function_skeleton": "(event, { isActive }) => {}", "code_description": "This code segment functions to: Handle state transitions between active and inactive session states by initializing timers and resetting user interface components when a session begins, while terminating timing mechanisms and updating status indicators when a session concludes."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\n(event, { isActive }) => {\n this.isSessionActive = isActive;\n if (isActive) {\n this.startTimer();\n } else {\n this.stopTimer();\n this.hasCompletedRecording = true;\n }\n}\n[TASK_END]\n```", "inference_time": "2025-08-21 00-01-42"}, "editdistance_info": {"edit_distance": 21.4765, "calculate_time": "2025-08-21 00:01:42", "true_code_clean": "(event, { isActive }) => {\n const wasActive = this.isSessionActive;\n this.isSessionActive = isActive;\n if (!wasActive && isActive) {\n this.hasCompletedRecording = false;\n this.startTimer();\n this.updateComplete.then(() => {\n const sttView = this.shadowRoot.querySelector('stt-view');\n const summaryView = this.shadowRoot.querySelector('summary-view');\n if (sttView) sttView.resetTranscript();\n if (summaryView) summaryView.resetAnalysis();\n });\n this.requestUpdate();\n }\n if (wasActive && !isActive) {\n this.hasCompletedRecording = true;\n this.stopTimer();\n this.requestUpdate();\n }\n }", "predict_code_clean": "(event, { isActive }) => {\n this.isSessionActive = isActive;\n if (isActive) {\n this.startTimer();\n } else {\n this.stopTimer();\n this.hasCompletedRecording = true;\n }\n}"}} {"repo_name": "glass", "file_name": "/glass/src/features/shortcuts/repositories/sqlite.repository.js", "inference_info": {"prefix_code": "const sqliteClient = require('../../common/services/sqliteClient');\nconst crypto = require('crypto');\n\nfunction getAllKeybinds() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM shortcuts';\n try {\n return db.prepare(query).all();\n } catch (error) {\n console.error(`[DB] Failed to get keybinds:`, error);\n return [];\n }\n}\n\n", "suffix_code": "\n\nmodule.exports = {\n getAllKeybinds,\n upsertKeybinds\n}; ", "middle_code": "function upsertKeybinds(keybinds) {\n if (!keybinds || keybinds.length === 0) return;\n const db = sqliteClient.getDb();\n const upsert = db.transaction((items) => {\n const query = `\n INSERT INTO shortcuts (action, accelerator, created_at)\n VALUES (@action, @accelerator, @created_at)\n ON CONFLICT(action) DO UPDATE SET\n accelerator = excluded.accelerator;\n `;\n const insert = db.prepare(query);\n for (const item of items) {\n insert.run({\n action: item.action,\n accelerator: item.accelerator,\n created_at: Math.floor(Date.now() / 1000)\n });\n }\n });\n try {\n upsert(keybinds);\n } catch (error) {\n console.error('[DB] Failed to upsert keybinds:', error);\n throw error;\n }\n}", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [["/glass/src/features/shortcuts/shortcutsService.js", "const { globalShortcut, screen } = require('electron');\nconst shortcutsRepository = require('./repositories');\nconst internalBridge = require('../../bridge/internalBridge');\nconst askService = require('../ask/askService');\n\n\nclass ShortcutsService {\n constructor() {\n this.lastVisibleWindows = new Set(['header']);\n this.mouseEventsIgnored = false;\n this.windowPool = null;\n this.allWindowVisibility = true;\n }\n\n initialize(windowPool) {\n this.windowPool = windowPool;\n internalBridge.on('reregister-shortcuts', () => {\n console.log('[ShortcutsService] Reregistering shortcuts due to header state change.');\n this.registerShortcuts();\n });\n console.log('[ShortcutsService] Initialized with dependencies and event listener.');\n }\n\n async openShortcutSettingsWindow () {\n const keybinds = await this.loadKeybinds();\n const shortcutWin = this.windowPool.get('shortcut-settings');\n shortcutWin.webContents.send('shortcut:loadShortcuts', keybinds);\n\n globalShortcut.unregisterAll();\n internalBridge.emit('window:requestVisibility', { name: 'shortcut-settings', visible: true });\n console.log('[ShortcutsService] Shortcut settings window opened.');\n return { success: true };\n }\n\n async closeShortcutSettingsWindow () {\n await this.registerShortcuts();\n internalBridge.emit('window:requestVisibility', { name: 'shortcut-settings', visible: false });\n console.log('[ShortcutsService] Shortcut settings window closed.');\n return { success: true };\n }\n\n async handleSaveShortcuts(newKeybinds) {\n try {\n await this.saveKeybinds(newKeybinds);\n await this.closeShortcutSettingsWindow();\n return { success: true };\n } catch (error) {\n console.error(\"Failed to save shortcuts:\", error);\n await this.closeShortcutSettingsWindow();\n return { success: false, error: error.message };\n }\n }\n\n async handleRestoreDefaults() {\n const defaults = this.getDefaultKeybinds();\n return defaults;\n }\n\n getDefaultKeybinds() {\n const isMac = process.platform === 'darwin';\n return {\n moveUp: isMac ? 'Cmd+Up' : 'Ctrl+Up',\n moveDown: isMac ? 'Cmd+Down' : 'Ctrl+Down',\n moveLeft: isMac ? 'Cmd+Left' : 'Ctrl+Left',\n moveRight: isMac ? 'Cmd+Right' : 'Ctrl+Right',\n toggleVisibility: isMac ? 'Cmd+\\\\' : 'Ctrl+\\\\',\n toggleClickThrough: isMac ? 'Cmd+M' : 'Ctrl+M',\n nextStep: isMac ? 'Cmd+Enter' : 'Ctrl+Enter',\n manualScreenshot: isMac ? 'Cmd+Shift+S' : 'Ctrl+Shift+S',\n previousResponse: isMac ? 'Cmd+[' : 'Ctrl+[',\n nextResponse: isMac ? 'Cmd+]' : 'Ctrl+]',\n scrollUp: isMac ? 'Cmd+Shift+Up' : 'Ctrl+Shift+Up',\n scrollDown: isMac ? 'Cmd+Shift+Down' : 'Ctrl+Shift+Down',\n };\n }\n\n async loadKeybinds() {\n let keybindsArray = await shortcutsRepository.getAllKeybinds();\n\n if (!keybindsArray || keybindsArray.length === 0) {\n console.log(`[Shortcuts] No keybinds found. Loading defaults.`);\n const defaults = this.getDefaultKeybinds();\n await this.saveKeybinds(defaults); \n return defaults;\n }\n\n const keybinds = {};\n keybindsArray.forEach(k => {\n keybinds[k.action] = k.accelerator;\n });\n\n const defaults = this.getDefaultKeybinds();\n let needsUpdate = false;\n for (const action in defaults) {\n if (!keybinds[action]) {\n keybinds[action] = defaults[action];\n needsUpdate = true;\n }\n }\n\n if (needsUpdate) {\n console.log('[Shortcuts] Updating missing keybinds with defaults.');\n await this.saveKeybinds(keybinds);\n }\n\n return keybinds;\n }\n\n async saveKeybinds(newKeybinds) {\n const keybindsToSave = [];\n for (const action in newKeybinds) {\n if (Object.prototype.hasOwnProperty.call(newKeybinds, action)) {\n keybindsToSave.push({\n action: action,\n accelerator: newKeybinds[action],\n });\n }\n }\n await shortcutsRepository.upsertKeybinds(keybindsToSave);\n console.log(`[Shortcuts] Saved keybinds.`);\n }\n\n async toggleAllWindowsVisibility() {\n const targetVisibility = !this.allWindowVisibility;\n internalBridge.emit('window:requestToggleAllWindowsVisibility', {\n targetVisibility: targetVisibility\n });\n\n if (this.allWindowVisibility) {\n await this.registerShortcuts(true);\n } else {\n await this.registerShortcuts();\n }\n\n this.allWindowVisibility = !this.allWindowVisibility;\n }\n\n async registerShortcuts(registerOnlyToggleVisibility = false) {\n if (!this.windowPool) {\n console.error('[Shortcuts] Service not initialized. Cannot register shortcuts.');\n return;\n }\n const keybinds = await this.loadKeybinds();\n globalShortcut.unregisterAll();\n \n const header = this.windowPool.get('header');\n const mainWindow = header;\n\n const sendToRenderer = (channel, ...args) => {\n this.windowPool.forEach(win => {\n if (win && !win.isDestroyed()) {\n try {\n win.webContents.send(channel, ...args);\n } catch (e) {\n // Ignore errors for destroyed windows\n }\n }\n });\n };\n \n sendToRenderer('shortcuts-updated', keybinds);\n\n if (registerOnlyToggleVisibility) {\n if (keybinds.toggleVisibility) {\n globalShortcut.register(keybinds.toggleVisibility, () => this.toggleAllWindowsVisibility());\n }\n console.log('[Shortcuts] registerOnlyToggleVisibility, only toggleVisibility shortcut is registered.');\n return;\n }\n\n // --- Hardcoded shortcuts ---\n const isMac = process.platform === 'darwin';\n const modifier = isMac ? 'Cmd' : 'Ctrl';\n \n // Monitor switching\n const displays = screen.getAllDisplays();\n if (displays.length > 1) {\n displays.forEach((display, index) => {\n const key = `${modifier}+Shift+${index + 1}`;\n globalShortcut.register(key, () => internalBridge.emit('window:moveToDisplay', { displayId: display.id }));\n });\n }\n\n // Edge snapping\n const edgeDirections = [\n { key: `${modifier}+Shift+Left`, direction: 'left' },\n { key: `${modifier}+Shift+Right`, direction: 'right' },\n ];\n edgeDirections.forEach(({ key, direction }) => {\n globalShortcut.register(key, () => {\n if (header && header.isVisible()) internalBridge.emit('window:moveToEdge', { direction });\n });\n });\n\n // --- User-configurable shortcuts ---\n if (header?.currentHeaderState === 'apikey') {\n if (keybinds.toggleVisibility) {\n globalShortcut.register(keybinds.toggleVisibility, () => this.toggleAllWindowsVisibility());\n }\n console.log('[Shortcuts] ApiKeyHeader is active, only toggleVisibility shortcut is registered.');\n return;\n }\n\n for (const action in keybinds) {\n const accelerator = keybinds[action];\n if (!accelerator) continue;\n\n let callback;\n switch(action) {\n case 'toggleVisibility':\n callback = () => this.toggleAllWindowsVisibility();\n break;\n case 'nextStep':\n callback = () => askService.toggleAskButton(true);\n break;\n case 'scrollUp':\n callback = () => {\n const askWindow = this.windowPool.get('ask');\n if (askWindow && !askWindow.isDestroyed() && askWindow.isVisible()) {\n askWindow.webContents.send('scroll-response-up');\n }\n };\n break;\n case 'scrollDown':\n callback = () => {\n const askWindow = this.windowPool.get('ask');\n if (askWindow && !askWindow.isDestroyed() && askWindow.isVisible()) {\n askWindow.webContents.send('scroll-response-down');\n }\n };\n break;\n case 'moveUp':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'up' }); };\n break;\n case 'moveDown':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'down' }); };\n break;\n case 'moveLeft':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'left' }); };\n break;\n case 'moveRight':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'right' }); };\n break;\n case 'toggleClickThrough':\n callback = () => {\n this.mouseEventsIgnored = !this.mouseEventsIgnored;\n if(mainWindow && !mainWindow.isDestroyed()){\n mainWindow.setIgnoreMouseEvents(this.mouseEventsIgnored, { forward: true });\n mainWindow.webContents.send('click-through-toggled', this.mouseEventsIgnored);\n }\n };\n break;\n case 'manualScreenshot':\n callback = () => {\n if(mainWindow && !mainWindow.isDestroyed()) {\n mainWindow.webContents.executeJavaScript('window.captureManualScreenshot && window.captureManualScreenshot();');\n }\n };\n break;\n case 'previousResponse':\n callback = () => sendToRenderer('navigate-previous-response');\n break;\n case 'nextResponse':\n callback = () => sendToRenderer('navigate-next-response');\n break;\n }\n \n if (callback) {\n try {\n globalShortcut.register(accelerator, callback);\n } catch(e) {\n console.error(`[Shortcuts] Failed to register shortcut for \"${action}\" (${accelerator}):`, e.message);\n }\n }\n }\n console.log('[Shortcuts] All shortcuts have been registered.');\n }\n\n unregisterAll() {\n globalShortcut.unregisterAll();\n console.log('[Shortcuts] All shortcuts have been unregistered.');\n }\n}\n\n\nconst shortcutsService = new ShortcutsService();\n\nmodule.exports = shortcutsService;"], ["/glass/src/features/common/repositories/providerSettings/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\nconst encryptionService = require('../../services/encryptionService');\n\nfunction getByProvider(provider) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT * FROM provider_settings WHERE provider = ?');\n const result = stmt.get(provider) || null;\n \n if (result && result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n \n return result;\n}\n\nfunction getAll() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT * FROM provider_settings ORDER BY provider');\n const results = stmt.all();\n \n return results.map(result => {\n if (result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n return result;\n });\n}\n\nfunction upsert(provider, settings) {\n // Validate: prevent direct setting of active status\n if (settings.is_active_llm || settings.is_active_stt) {\n console.warn('[ProviderSettings] Warning: is_active_llm/is_active_stt should not be set directly. Use setActiveProvider() instead.');\n }\n \n const db = sqliteClient.getDb();\n \n // Use SQLite's UPSERT syntax (INSERT ... ON CONFLICT ... DO UPDATE)\n const stmt = db.prepare(`\n INSERT INTO provider_settings (provider, api_key, selected_llm_model, selected_stt_model, is_active_llm, is_active_stt, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(provider) DO UPDATE SET\n api_key = excluded.api_key,\n selected_llm_model = excluded.selected_llm_model,\n selected_stt_model = excluded.selected_stt_model,\n -- is_active_llm and is_active_stt are NOT updated here\n -- Use setActiveProvider() to change active status\n updated_at = excluded.updated_at\n `);\n \n const result = stmt.run(\n provider,\n settings.api_key || null,\n settings.selected_llm_model || null,\n settings.selected_stt_model || null,\n 0, // is_active_llm - always 0, use setActiveProvider to activate\n 0, // is_active_stt - always 0, use setActiveProvider to activate\n settings.created_at || Date.now(),\n settings.updated_at\n );\n \n return { changes: result.changes };\n}\n\nfunction remove(provider) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('DELETE FROM provider_settings WHERE provider = ?');\n const result = stmt.run(provider);\n return { changes: result.changes };\n}\n\nfunction removeAll() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('DELETE FROM provider_settings');\n const result = stmt.run();\n return { changes: result.changes };\n}\n\nfunction getRawApiKeys() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT api_key FROM provider_settings');\n return stmt.all();\n}\n\n// Get active provider for a specific type (llm or stt)\nfunction getActiveProvider(type) {\n const db = sqliteClient.getDb();\n const column = type === 'llm' ? 'is_active_llm' : 'is_active_stt';\n const stmt = db.prepare(`SELECT * FROM provider_settings WHERE ${column} = 1`);\n const result = stmt.get() || null;\n \n if (result && result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n \n return result;\n}\n\n// Set active provider for a specific type\nfunction setActiveProvider(provider, type) {\n const db = sqliteClient.getDb();\n const column = type === 'llm' ? 'is_active_llm' : 'is_active_stt';\n \n // Start transaction to ensure only one provider is active\n db.transaction(() => {\n // First, deactivate all providers for this type\n const deactivateStmt = db.prepare(`UPDATE provider_settings SET ${column} = 0`);\n deactivateStmt.run();\n \n // Then activate the specified provider\n if (provider) {\n const activateStmt = db.prepare(`UPDATE provider_settings SET ${column} = 1 WHERE provider = ?`);\n activateStmt.run(provider);\n }\n })();\n \n return { success: true };\n}\n\n// Get all active settings (both llm and stt)\nfunction getActiveSettings() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare(`\n SELECT * FROM provider_settings \n WHERE (is_active_llm = 1 OR is_active_stt = 1)\n ORDER BY provider\n `);\n const results = stmt.all();\n \n // Decrypt API keys and organize by type\n const activeSettings = {\n llm: null,\n stt: null\n };\n \n results.forEach(result => {\n if (result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n if (result.is_active_llm) {\n activeSettings.llm = result;\n }\n if (result.is_active_stt) {\n activeSettings.stt = result;\n }\n });\n \n return activeSettings;\n}\n\nmodule.exports = {\n getByProvider,\n getAll,\n upsert,\n remove,\n removeAll,\n getRawApiKeys,\n getActiveProvider,\n setActiveProvider,\n getActiveSettings\n}; "], ["/glass/src/features/common/repositories/ollamaModel/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\n/**\n * Get all Ollama models\n */\nfunction getAllModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get models:', err);\n throw err;\n }\n}\n\n/**\n * Get a specific model by name\n */\nfunction getModel(name) {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE name = ?';\n \n try {\n return db.prepare(query).get(name);\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get model:', err);\n throw err;\n }\n}\n\n/**\n * Create or update a model entry\n */\nfunction upsertModel({ name, size, installed = false, installing = false }) {\n const db = sqliteClient.getDb();\n const query = `\n INSERT INTO ollama_models (name, size, installed, installing)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(name) DO UPDATE SET \n size = excluded.size,\n installed = excluded.installed,\n installing = excluded.installing\n `;\n \n try {\n db.prepare(query).run(name, size, installed ? 1 : 0, installing ? 1 : 0);\n return { success: true };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to upsert model:', err);\n throw err;\n }\n}\n\n/**\n * Update installation status for a model\n */\nfunction updateInstallStatus(name, installed, installing = false) {\n const db = sqliteClient.getDb();\n const query = 'UPDATE ollama_models SET installed = ?, installing = ? WHERE name = ?';\n \n try {\n const result = db.prepare(query).run(installed ? 1 : 0, installing ? 1 : 0, name);\n return { success: true, changes: result.changes };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to update install status:', err);\n throw err;\n }\n}\n\n/**\n * Initialize default models - now done dynamically based on installed models\n */\nfunction initializeDefaultModels() {\n // Default models are now detected dynamically from Ollama installation\n // This function maintains compatibility but doesn't hardcode any models\n console.log('[OllamaModel Repository] Default models initialization skipped - using dynamic detection');\n return { success: true };\n}\n\n/**\n * Delete a model entry\n */\nfunction deleteModel(name) {\n const db = sqliteClient.getDb();\n const query = 'DELETE FROM ollama_models WHERE name = ?';\n \n try {\n const result = db.prepare(query).run(name);\n return { success: true, changes: result.changes };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to delete model:', err);\n throw err;\n }\n}\n\n/**\n * Get installed models\n */\nfunction getInstalledModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE installed = 1 ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get installed models:', err);\n throw err;\n }\n}\n\n/**\n * Get models currently being installed\n */\nfunction getInstallingModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE installing = 1 ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get installing models:', err);\n throw err;\n }\n}\n\nmodule.exports = {\n getAllModels,\n getModel,\n upsertModel,\n updateInstallStatus,\n initializeDefaultModels,\n deleteModel,\n getInstalledModels,\n getInstallingModels\n}; "], ["/glass/src/features/common/services/sqliteClient.js", "const Database = require('better-sqlite3');\nconst path = require('path');\nconst LATEST_SCHEMA = require('../config/schema');\n\nclass SQLiteClient {\n constructor() {\n this.db = null;\n this.dbPath = null;\n this.defaultUserId = 'default_user';\n }\n\n connect(dbPath) {\n if (this.db) {\n console.log('[SQLiteClient] Already connected.');\n return;\n }\n\n try {\n this.dbPath = dbPath;\n this.db = new Database(this.dbPath);\n this.db.pragma('journal_mode = WAL');\n console.log('[SQLiteClient] Connected successfully to:', this.dbPath);\n } catch (err) {\n console.error('[SQLiteClient] Could not connect to database', err);\n throw err;\n }\n }\n\n getDb() {\n if (!this.db) {\n throw new Error(\"Database not connected. Call connect() first.\");\n }\n return this.db;\n }\n\n _validateAndQuoteIdentifier(identifier) {\n if (!/^[a-zA-Z0-9_]+$/.test(identifier)) {\n throw new Error(`Invalid database identifier used: ${identifier}. Only alphanumeric characters and underscores are allowed.`);\n }\n return `\"${identifier}\"`;\n }\n\n _migrateProviderSettings() {\n const tablesInDb = this.getTablesFromDb();\n if (!tablesInDb.includes('provider_settings')) {\n return; // Table doesn't exist, no migration needed.\n }\n \n const providerSettingsInfo = this.db.prepare(`PRAGMA table_info(provider_settings)`).all();\n const hasUidColumn = providerSettingsInfo.some(col => col.name === 'uid');\n \n if (hasUidColumn) {\n console.log('[DB Migration] Old provider_settings schema detected. Starting robust migration...');\n \n try {\n this.db.transaction(() => {\n this.db.exec('ALTER TABLE provider_settings RENAME TO provider_settings_old');\n console.log('[DB Migration] Renamed provider_settings to provider_settings_old');\n \n this.createTable('provider_settings', LATEST_SCHEMA.provider_settings);\n console.log('[DB Migration] Created new provider_settings table');\n \n // Dynamically build the migration query for robustness\n const oldColumnNames = this.db.prepare(`PRAGMA table_info(provider_settings_old)`).all().map(c => c.name);\n const newColumnNames = LATEST_SCHEMA.provider_settings.columns.map(c => c.name);\n const commonColumns = newColumnNames.filter(name => oldColumnNames.includes(name));\n \n if (!commonColumns.includes('provider')) {\n console.warn('[DB Migration] Old table is missing the \"provider\" column. Aborting migration for this table.');\n this.db.exec('DROP TABLE provider_settings_old');\n return;\n }\n \n const orderParts = [];\n if (oldColumnNames.includes('updated_at')) orderParts.push('updated_at DESC');\n if (oldColumnNames.includes('created_at')) orderParts.push('created_at DESC');\n const orderByClause = orderParts.length > 0 ? `ORDER BY ${orderParts.join(', ')}` : '';\n \n const columnsForInsert = commonColumns.map(c => this._validateAndQuoteIdentifier(c)).join(', ');\n \n const migrationQuery = `\n INSERT INTO provider_settings (${columnsForInsert})\n SELECT ${columnsForInsert}\n FROM (\n SELECT *, ROW_NUMBER() OVER(PARTITION BY provider ${orderByClause}) as rn\n FROM provider_settings_old\n )\n WHERE rn = 1\n `;\n \n console.log(`[DB Migration] Executing robust migration query for columns: ${commonColumns.join(', ')}`);\n const result = this.db.prepare(migrationQuery).run();\n console.log(`[DB Migration] Migrated ${result.changes} rows to the new provider_settings table.`);\n \n this.db.exec('DROP TABLE provider_settings_old');\n console.log('[DB Migration] Dropped provider_settings_old table.');\n })();\n console.log('[DB Migration] provider_settings migration completed successfully.');\n } catch (error) {\n console.error('[DB Migration] Failed to migrate provider_settings table.', error);\n \n // Try to recover by dropping the temp table if it exists\n const oldTableExists = this.getTablesFromDb().includes('provider_settings_old');\n if (oldTableExists) {\n this.db.exec('DROP TABLE provider_settings_old');\n console.warn('[DB Migration] Cleaned up temporary old table after failure.');\n }\n throw error;\n }\n }\n }\n\n async synchronizeSchema() {\n console.log('[DB Sync] Starting schema synchronization...');\n\n // Run special migration for provider_settings before the generic sync logic\n this._migrateProviderSettings();\n\n const tablesInDb = this.getTablesFromDb();\n\n for (const tableName of Object.keys(LATEST_SCHEMA)) {\n const tableSchema = LATEST_SCHEMA[tableName];\n\n if (!tablesInDb.includes(tableName)) {\n // Table doesn't exist, create it\n this.createTable(tableName, tableSchema);\n } else {\n // Table exists, check for missing columns\n this.updateTable(tableName, tableSchema);\n }\n }\n console.log('[DB Sync] Schema synchronization finished.');\n }\n\n getTablesFromDb() {\n const tables = this.db.prepare(\"SELECT name FROM sqlite_master WHERE type='table'\").all();\n return tables.map(t => t.name);\n }\n\n createTable(tableName, tableSchema) {\n const safeTableName = this._validateAndQuoteIdentifier(tableName);\n const columnDefs = tableSchema.columns\n .map(col => `${this._validateAndQuoteIdentifier(col.name)} ${col.type}`)\n .join(', ');\n \n const constraints = tableSchema.constraints || [];\n const constraintsDef = constraints.length > 0 ? ', ' + constraints.join(', ') : '';\n \n const query = `CREATE TABLE IF NOT EXISTS ${safeTableName} (${columnDefs}${constraintsDef})`;\n console.log(`[DB Sync] Creating table: ${tableName}`);\n this.db.exec(query);\n }\n\n updateTable(tableName, tableSchema) {\n const safeTableName = this._validateAndQuoteIdentifier(tableName);\n \n // Get current columns\n const currentColumns = this.db.prepare(`PRAGMA table_info(${safeTableName})`).all();\n const currentColumnNames = currentColumns.map(col => col.name);\n\n // Check for new columns to add\n const newColumns = tableSchema.columns.filter(col => !currentColumnNames.includes(col.name));\n\n if (newColumns.length > 0) {\n console.log(`[DB Sync] Adding ${newColumns.length} new column(s) to ${tableName}`);\n for (const col of newColumns) {\n const safeColName = this._validateAndQuoteIdentifier(col.name);\n const addColumnQuery = `ALTER TABLE ${safeTableName} ADD COLUMN ${safeColName} ${col.type}`;\n this.db.exec(addColumnQuery);\n console.log(`[DB Sync] Added column ${col.name} to ${tableName}`);\n }\n }\n\n if (tableSchema.constraints && tableSchema.constraints.length > 0) {\n console.log(`[DB Sync] Note: Constraints for ${tableName} can only be set during table creation`);\n }\n }\n\n runQuery(query, params = []) {\n return this.db.prepare(query).run(params);\n }\n\n cleanupEmptySessions() {\n console.log('[DB Cleanup] Checking for empty sessions...');\n const query = `\n SELECT s.id FROM sessions s\n LEFT JOIN transcripts t ON s.id = t.session_id\n LEFT JOIN ai_messages a ON s.id = a.session_id\n LEFT JOIN summaries su ON s.id = su.session_id\n WHERE t.id IS NULL AND a.id IS NULL AND su.session_id IS NULL\n `;\n\n const rows = this.db.prepare(query).all();\n\n if (rows.length === 0) {\n console.log('[DB Cleanup] No empty sessions found.');\n return;\n }\n\n const idsToDelete = rows.map(r => r.id);\n const placeholders = idsToDelete.map(() => '?').join(',');\n const deleteQuery = `DELETE FROM sessions WHERE id IN (${placeholders})`;\n\n console.log(`[DB Cleanup] Found ${idsToDelete.length} empty sessions. Deleting...`);\n const result = this.db.prepare(deleteQuery).run(idsToDelete);\n console.log(`[DB Cleanup] Successfully deleted ${result.changes} empty sessions.`);\n }\n\n async initTables() {\n await this.synchronizeSchema();\n this.initDefaultData();\n }\n\n initDefaultData() {\n const now = Math.floor(Date.now() / 1000);\n const initUserQuery = `\n INSERT OR IGNORE INTO users (uid, display_name, email, created_at)\n VALUES (?, ?, ?, ?)\n `;\n\n this.db.prepare(initUserQuery).run(this.defaultUserId, 'Default User', 'contact@pickle.com', now);\n\n const defaultPresets = [\n ['school', 'School', 'You are a school and lecture assistant. Your goal is to help the user, a student, understand academic material and answer questions.\\n\\nWhenever a question appears on the user\\'s screen or is asked aloud, you provide a direct, step-by-step answer, showing all necessary reasoning or calculations.\\n\\nIf the user is watching a lecture or working through new material, you offer concise explanations of key concepts and clarify definitions as they come up.', 1],\n ['meetings', 'Meetings', 'You are a meeting assistant. Your goal is to help the user capture key information during meetings and follow up effectively.\\n\\nYou help capture meeting notes, track action items, identify key decisions, and summarize important points discussed during meetings.', 1],\n ['sales', 'Sales', 'You are a real-time AI sales assistant, and your goal is to help the user close deals during sales interactions.\\n\\nYou provide real-time sales support, suggest responses to objections, help identify customer needs, and recommend strategies to advance deals.', 1],\n ['recruiting', 'Recruiting', 'You are a recruiting assistant. Your goal is to help the user interview candidates and evaluate talent effectively.\\n\\nYou help evaluate candidates, suggest interview questions, analyze responses, and provide insights about candidate fit for positions.', 1],\n ['customer-support', 'Customer Support', 'You are a customer support assistant. Your goal is to help resolve customer issues efficiently and thoroughly.\\n\\nYou help diagnose customer problems, suggest solutions, provide step-by-step troubleshooting guidance, and ensure customer satisfaction.', 1],\n ];\n\n const stmt = this.db.prepare(`\n INSERT OR IGNORE INTO prompt_presets (id, uid, title, prompt, is_default, created_at)\n VALUES (?, ?, ?, ?, ?, ?)\n `);\n\n for (const preset of defaultPresets) {\n stmt.run(preset[0], this.defaultUserId, preset[1], preset[2], preset[3], now);\n }\n\n console.log('Default data initialized.');\n }\n\n close() {\n if (this.db) {\n try {\n this.db.close();\n console.log('SQLite connection closed.');\n } catch (err) {\n console.error('SQLite connection close failed:', err);\n }\n this.db = null;\n }\n }\n\n query(sql, params = []) {\n if (!this.db) {\n throw new Error('Database not connected');\n }\n\n try {\n if (sql.toUpperCase().startsWith('SELECT')) {\n return this.db.prepare(sql).all(params);\n } else {\n const result = this.db.prepare(sql).run(params);\n return { changes: result.changes, lastID: result.lastID };\n }\n } catch (err) {\n console.error('Query error:', err);\n throw err;\n }\n }\n}\n\nconst sqliteClient = new SQLiteClient();\nmodule.exports = sqliteClient; "], ["/glass/src/features/settings/repositories/sqlite.repository.js", "const sqliteClient = require('../../common/services/sqliteClient');\n\nfunction getPresets(uid) {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE uid = ? OR is_default = 1 \n ORDER BY is_default DESC, title ASC\n `;\n \n try {\n return db.prepare(query).all(uid) || [];\n } catch (err) {\n console.error('SQLite: Failed to get presets:', err);\n throw err;\n }\n}\n\nfunction getPresetTemplates() {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE is_default = 1 \n ORDER BY title ASC\n `;\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('SQLite: Failed to get preset templates:', err);\n throw err;\n }\n}\n\nfunction createPreset({ uid, title, prompt }) {\n const db = sqliteClient.getDb();\n const id = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n INSERT INTO prompt_presets (id, uid, title, prompt, is_default, created_at, sync_state)\n VALUES (?, ?, ?, ?, 0, ?, 'dirty')\n `;\n \n try {\n db.prepare(query).run(id, uid, title, prompt, now);\n return { id };\n } catch (err) {\n console.error('SQLite: Failed to create preset:', err);\n throw err;\n }\n}\n\nfunction updatePreset(id, { title, prompt }, uid) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n UPDATE prompt_presets \n SET title = ?, prompt = ?, sync_state = 'dirty', updated_at = ?\n WHERE id = ? AND uid = ? AND is_default = 0\n `;\n \n try {\n const result = db.prepare(query).run(title, prompt, now, id, uid);\n if (result.changes === 0) {\n throw new Error('Preset not found, is default, or permission denied');\n }\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to update preset:', err);\n throw err;\n }\n}\n\nfunction deletePreset(id, uid) {\n const db = sqliteClient.getDb();\n const query = `\n DELETE FROM prompt_presets \n WHERE id = ? AND uid = ? AND is_default = 0\n `;\n \n try {\n const result = db.prepare(query).run(id, uid);\n if (result.changes === 0) {\n throw new Error('Preset not found, is default, or permission denied');\n }\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to delete preset:', err);\n throw err;\n }\n}\n\nfunction getAutoUpdate(uid) {\n const db = sqliteClient.getDb();\n const targetUid = uid;\n\n try {\n const row = db.prepare('SELECT auto_update_enabled FROM users WHERE uid = ?').get(targetUid);\n \n if (row) {\n console.log('SQLite: Auto update setting found:', row.auto_update_enabled);\n return row.auto_update_enabled !== 0;\n } else {\n // User doesn't exist, create them with default settings\n const now = Math.floor(Date.now() / 1000);\n const stmt = db.prepare(\n 'INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)');\n stmt.run(targetUid, 'User', 'user@example.com', now, 1);\n return true; // default to enabled\n }\n } catch (error) {\n console.error('SQLite: Error getting auto_update_enabled setting:', error);\n return true; // fallback to enabled\n }\n}\n\nfunction setAutoUpdate(uid, isEnabled) {\n const db = sqliteClient.getDb();\n const targetUid = uid || sqliteClient.defaultUserId;\n \n try {\n const result = db.prepare('UPDATE users SET auto_update_enabled = ? WHERE uid = ?').run(isEnabled ? 1 : 0, targetUid);\n \n // If no rows were updated, the user might not exist, so create them\n if (result.changes === 0) {\n const now = Math.floor(Date.now() / 1000);\n const stmt = db.prepare('INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)');\n stmt.run(targetUid, 'User', 'user@example.com', now, isEnabled ? 1 : 0);\n }\n \n return { success: true };\n } catch (error) {\n console.error('SQLite: Error setting auto-update:', error);\n throw error;\n }\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n getAutoUpdate,\n setAutoUpdate\n};"], ["/glass/src/features/common/repositories/user/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction findOrCreate(user) {\n const db = sqliteClient.getDb();\n \n if (!user || !user.uid) {\n throw new Error('User object and uid are required');\n }\n \n const { uid, displayName, email } = user;\n const now = Math.floor(Date.now() / 1000);\n \n // Validate inputs\n const safeDisplayName = displayName || 'User';\n const safeEmail = email || 'no-email@example.com';\n\n const query = `\n INSERT INTO users (uid, display_name, email, created_at)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(uid) DO UPDATE SET \n display_name=excluded.display_name, \n email=excluded.email\n `;\n \n try {\n console.log('[SQLite] Creating/updating user:', { uid, displayName: safeDisplayName, email: safeEmail });\n db.prepare(query).run(uid, safeDisplayName, safeEmail, now);\n const result = getById(uid);\n console.log('[SQLite] User operation successful:', result);\n return result;\n } catch (err) {\n console.error('SQLite: Failed to find or create user:', err);\n console.error('SQLite: User data:', { uid, displayName: safeDisplayName, email: safeEmail });\n throw new Error(`Failed to create user in database: ${err.message}`);\n }\n}\n\nfunction getById(uid) {\n const db = sqliteClient.getDb();\n return db.prepare('SELECT * FROM users WHERE uid = ?').get(uid);\n}\n\n\n\nfunction update({ uid, displayName }) {\n const db = sqliteClient.getDb();\n const result = db.prepare('UPDATE users SET display_name = ? WHERE uid = ?').run(displayName, uid);\n return { changes: result.changes };\n}\n\nfunction setMigrationComplete(uid) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('UPDATE users SET has_migrated_to_firebase = 1 WHERE uid = ?');\n const result = stmt.run(uid);\n if (result.changes > 0) {\n console.log(`[Repo] Marked migration as complete for user ${uid}.`);\n }\n return result;\n}\n\nfunction deleteById(uid) {\n const db = sqliteClient.getDb();\n const userSessions = db.prepare('SELECT id FROM sessions WHERE uid = ?').all(uid);\n const sessionIds = userSessions.map(s => s.id);\n\n const transaction = db.transaction(() => {\n if (sessionIds.length > 0) {\n const placeholders = sessionIds.map(() => '?').join(',');\n db.prepare(`DELETE FROM transcripts WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM ai_messages WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM summaries WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM sessions WHERE uid = ?`).run(uid);\n }\n db.prepare('DELETE FROM prompt_presets WHERE uid = ? AND is_default = 0').run(uid);\n db.prepare('DELETE FROM users WHERE uid = ?').run(uid);\n });\n\n try {\n transaction();\n return { success: true };\n } catch (err) {\n throw err;\n }\n}\n\nmodule.exports = {\n findOrCreate,\n getById,\n update,\n setMigrationComplete,\n deleteById\n}; "], ["/glass/src/features/listen/summary/repositories/sqlite.repository.js", "const sqliteClient = require('../../../common/services/sqliteClient');\n\nfunction saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model = 'unknown' }) {\n // uid is ignored in the SQLite implementation\n return new Promise((resolve, reject) => {\n try {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n INSERT INTO summaries (session_id, generated_at, model, text, tldr, bullet_json, action_json, updated_at) \n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(session_id) DO UPDATE SET\n generated_at=excluded.generated_at,\n model=excluded.model,\n text=excluded.text,\n tldr=excluded.tldr,\n bullet_json=excluded.bullet_json,\n action_json=excluded.action_json,\n updated_at=excluded.updated_at\n `;\n \n const result = db.prepare(query).run(sessionId, now, model, text, tldr, bullet_json, action_json, now);\n resolve({ changes: result.changes });\n } catch (err) {\n console.error('Error saving summary:', err);\n reject(err);\n }\n });\n}\n\nfunction getSummaryBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM summaries WHERE session_id = ?\";\n return db.prepare(query).get(sessionId) || null;\n}\n\nmodule.exports = {\n saveSummary,\n getSummaryBySessionId,\n}; "], ["/glass/src/features/common/repositories/session/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction getById(id) {\n const db = sqliteClient.getDb();\n return db.prepare('SELECT * FROM sessions WHERE id = ?').get(id);\n}\n\nfunction create(uid, type = 'ask') {\n const db = sqliteClient.getDb();\n const sessionId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO sessions (id, uid, title, session_type, started_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(sessionId, uid, `Session @ ${new Date().toLocaleTimeString()}`, type, now, now);\n console.log(`SQLite: Created session ${sessionId} for user ${uid} (type: ${type})`);\n return sessionId;\n } catch (err) {\n console.error('SQLite: Failed to create session:', err);\n throw err;\n }\n}\n\nfunction getAllByUserId(uid) {\n const db = sqliteClient.getDb();\n const query = \"SELECT id, uid, title, session_type, started_at, ended_at, sync_state, updated_at FROM sessions WHERE uid = ? ORDER BY started_at DESC\";\n return db.prepare(query).all(uid);\n}\n\nfunction updateTitle(id, title) {\n const db = sqliteClient.getDb();\n const result = db.prepare('UPDATE sessions SET title = ? WHERE id = ?').run(title, id);\n return { changes: result.changes };\n}\n\nfunction deleteWithRelatedData(id) {\n const db = sqliteClient.getDb();\n const transaction = db.transaction(() => {\n db.prepare(\"DELETE FROM transcripts WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM ai_messages WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM summaries WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM sessions WHERE id = ?\").run(id);\n });\n \n try {\n transaction();\n return { success: true };\n } catch (err) {\n throw err;\n }\n}\n\nfunction end(id) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `UPDATE sessions SET ended_at = ?, updated_at = ? WHERE id = ?`;\n const result = db.prepare(query).run(now, now, id);\n return { changes: result.changes };\n}\n\nfunction updateType(id, type) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = 'UPDATE sessions SET session_type = ?, updated_at = ? WHERE id = ?';\n const result = db.prepare(query).run(type, now, id);\n return { changes: result.changes };\n}\n\nfunction touch(id) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = 'UPDATE sessions SET updated_at = ? WHERE id = ?';\n const result = db.prepare(query).run(now, id);\n return { changes: result.changes };\n}\n\nfunction getOrCreateActive(uid, requestedType = 'ask') {\n const db = sqliteClient.getDb();\n \n // 1. Look for ANY active session for the user (ended_at IS NULL).\n // Prefer 'listen' sessions over 'ask' sessions to ensure continuity.\n const findQuery = `\n SELECT id, session_type FROM sessions \n WHERE uid = ? AND ended_at IS NULL\n ORDER BY CASE session_type WHEN 'listen' THEN 1 WHEN 'ask' THEN 2 ELSE 3 END\n LIMIT 1\n `;\n\n const activeSession = db.prepare(findQuery).get(uid);\n\n if (activeSession) {\n // An active session exists.\n console.log(`[Repo] Found active session ${activeSession.id} of type ${activeSession.session_type}`);\n \n // 2. Promotion Logic: If it's an 'ask' session and we need 'listen', promote it.\n if (activeSession.session_type === 'ask' && requestedType === 'listen') {\n updateType(activeSession.id, 'listen');\n console.log(`[Repo] Promoted session ${activeSession.id} to 'listen' type.`);\n }\n\n // 3. Touch the session and return its ID.\n touch(activeSession.id);\n return activeSession.id;\n } else {\n // 4. No active session found, create a new one.\n console.log(`[Repo] No active session for user ${uid}. Creating new '${requestedType}' session.`);\n return create(uid, requestedType);\n }\n}\n\nfunction endAllActiveSessions(uid) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n // Filter by uid to match the Firebase repository's behavior.\n const query = `UPDATE sessions SET ended_at = ?, updated_at = ? WHERE ended_at IS NULL AND uid = ?`;\n \n try {\n const result = db.prepare(query).run(now, now, uid);\n console.log(`[Repo] Ended ${result.changes} active SQLite session(s) for user ${uid}.`);\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to end all active sessions:', err);\n throw err;\n }\n}\n\nmodule.exports = {\n getById,\n create,\n getAllByUserId,\n updateTitle,\n deleteWithRelatedData,\n end,\n updateType,\n touch,\n getOrCreateActive,\n endAllActiveSessions,\n}; "], ["/glass/src/features/settings/settingsService.js", "const { ipcMain, BrowserWindow } = require('electron');\nconst Store = require('electron-store');\nconst authService = require('../common/services/authService');\nconst settingsRepository = require('./repositories');\nconst { getStoredApiKey, getStoredProvider, windowPool } = require('../../window/windowManager');\n\n// New imports for common services\nconst modelStateService = require('../common/services/modelStateService');\nconst localAIManager = require('../common/services/localAIManager');\n\nconst store = new Store({\n name: 'pickle-glass-settings',\n defaults: {\n users: {}\n }\n});\n\n// Configuration constants\nconst NOTIFICATION_CONFIG = {\n RELEVANT_WINDOW_TYPES: ['settings', 'main'],\n DEBOUNCE_DELAY: 300, // prevent spam during bulk operations (ms)\n MAX_RETRY_ATTEMPTS: 3,\n RETRY_BASE_DELAY: 1000, // exponential backoff base (ms)\n};\n\n// New facade functions for model state management\nasync function getModelSettings() {\n try {\n const [config, storedKeys, selectedModels, availableLlm, availableStt] = await Promise.all([\n modelStateService.getProviderConfig(),\n modelStateService.getAllApiKeys(),\n modelStateService.getSelectedModels(),\n modelStateService.getAvailableModels('llm'),\n modelStateService.getAvailableModels('stt')\n ]);\n \n return { success: true, data: { config, storedKeys, availableLlm, availableStt, selectedModels } };\n } catch (error) {\n console.error('[SettingsService] Error getting model settings:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function clearApiKey(provider) {\n const success = await modelStateService.handleRemoveApiKey(provider);\n return { success };\n}\n\nasync function setSelectedModel(type, modelId) {\n const success = await modelStateService.handleSetSelectedModel(type, modelId);\n return { success };\n}\n\n// LocalAI facade functions\nasync function getOllamaStatus() {\n return localAIManager.getServiceStatus('ollama');\n}\n\nasync function ensureOllamaReady() {\n const status = await localAIManager.getServiceStatus('ollama');\n if (!status.installed || !status.running) {\n await localAIManager.startService('ollama');\n }\n return { success: true };\n}\n\nasync function shutdownOllama() {\n return localAIManager.stopService('ollama');\n}\n\n\n// window targeting system\nclass WindowNotificationManager {\n constructor() {\n this.pendingNotifications = new Map();\n }\n\n /**\n * Send notifications only to relevant windows\n * @param {string} event - Event name\n * @param {*} data - Event data\n * @param {object} options - Notification options\n */\n notifyRelevantWindows(event, data = null, options = {}) {\n const { \n windowTypes = NOTIFICATION_CONFIG.RELEVANT_WINDOW_TYPES,\n debounce = NOTIFICATION_CONFIG.DEBOUNCE_DELAY \n } = options;\n\n if (debounce > 0) {\n this.debounceNotification(event, () => {\n this.sendToTargetWindows(event, data, windowTypes);\n }, debounce);\n } else {\n this.sendToTargetWindows(event, data, windowTypes);\n }\n }\n\n sendToTargetWindows(event, data, windowTypes) {\n const relevantWindows = this.getRelevantWindows(windowTypes);\n \n if (relevantWindows.length === 0) {\n console.log(`[WindowNotificationManager] No relevant windows found for event: ${event}`);\n return;\n }\n\n console.log(`[WindowNotificationManager] Sending ${event} to ${relevantWindows.length} relevant windows`);\n \n relevantWindows.forEach(win => {\n try {\n if (data) {\n win.webContents.send(event, data);\n } else {\n win.webContents.send(event);\n }\n } catch (error) {\n console.warn(`[WindowNotificationManager] Failed to send ${event} to window:`, error.message);\n }\n });\n }\n\n getRelevantWindows(windowTypes) {\n const allWindows = BrowserWindow.getAllWindows();\n const relevantWindows = [];\n\n allWindows.forEach(win => {\n if (win.isDestroyed()) return;\n\n for (const [windowName, poolWindow] of windowPool || []) {\n if (poolWindow === win && windowTypes.includes(windowName)) {\n if (windowName === 'settings' || win.isVisible()) {\n relevantWindows.push(win);\n }\n break;\n }\n }\n });\n\n return relevantWindows;\n }\n\n debounceNotification(key, fn, delay) {\n // Clear existing timeout\n if (this.pendingNotifications.has(key)) {\n clearTimeout(this.pendingNotifications.get(key));\n }\n\n // Set new timeout\n const timeoutId = setTimeout(() => {\n fn();\n this.pendingNotifications.delete(key);\n }, delay);\n\n this.pendingNotifications.set(key, timeoutId);\n }\n\n cleanup() {\n // Clear all pending notifications\n this.pendingNotifications.forEach(timeoutId => clearTimeout(timeoutId));\n this.pendingNotifications.clear();\n }\n}\n\n// Global instance\nconst windowNotificationManager = new WindowNotificationManager();\n\n// Default keybinds configuration\nconst DEFAULT_KEYBINDS = {\n mac: {\n moveUp: 'Cmd+Up',\n moveDown: 'Cmd+Down',\n moveLeft: 'Cmd+Left',\n moveRight: 'Cmd+Right',\n toggleVisibility: 'Cmd+\\\\',\n toggleClickThrough: 'Cmd+M',\n nextStep: 'Cmd+Enter',\n manualScreenshot: 'Cmd+Shift+S',\n previousResponse: 'Cmd+[',\n nextResponse: 'Cmd+]',\n scrollUp: 'Cmd+Shift+Up',\n scrollDown: 'Cmd+Shift+Down',\n },\n windows: {\n moveUp: 'Ctrl+Up',\n moveDown: 'Ctrl+Down',\n moveLeft: 'Ctrl+Left',\n moveRight: 'Ctrl+Right',\n toggleVisibility: 'Ctrl+\\\\',\n toggleClickThrough: 'Ctrl+M',\n nextStep: 'Ctrl+Enter',\n manualScreenshot: 'Ctrl+Shift+S',\n previousResponse: 'Ctrl+[',\n nextResponse: 'Ctrl+]',\n scrollUp: 'Ctrl+Shift+Up',\n scrollDown: 'Ctrl+Shift+Down',\n }\n};\n\n// Service state\nlet currentSettings = null;\n\nfunction getDefaultSettings() {\n const isMac = process.platform === 'darwin';\n return {\n profile: 'school',\n language: 'en',\n screenshotInterval: '5000',\n imageQuality: '0.8',\n layoutMode: 'stacked',\n keybinds: isMac ? DEFAULT_KEYBINDS.mac : DEFAULT_KEYBINDS.windows,\n throttleTokens: 500,\n maxTokens: 2000,\n throttlePercent: 80,\n googleSearchEnabled: false,\n backgroundTransparency: 0.5,\n fontSize: 14,\n contentProtection: true\n };\n}\n\nasync function getSettings() {\n try {\n const uid = authService.getCurrentUserId();\n const userSettingsKey = uid ? `users.${uid}` : 'users.default';\n \n const defaultSettings = getDefaultSettings();\n const savedSettings = store.get(userSettingsKey, {});\n \n currentSettings = { ...defaultSettings, ...savedSettings };\n return currentSettings;\n } catch (error) {\n console.error('[SettingsService] Error getting settings from store:', error);\n return getDefaultSettings();\n }\n}\n\nasync function saveSettings(settings) {\n try {\n const uid = authService.getCurrentUserId();\n const userSettingsKey = uid ? `users.${uid}` : 'users.default';\n \n const currentSaved = store.get(userSettingsKey, {});\n const newSettings = { ...currentSaved, ...settings };\n \n store.set(userSettingsKey, newSettings);\n currentSettings = newSettings;\n \n // Use smart notification system\n windowNotificationManager.notifyRelevantWindows('settings-updated', currentSettings);\n\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error saving settings to store:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function getPresets() {\n try {\n // The adapter now handles which presets to return based on login state.\n const presets = await settingsRepository.getPresets();\n return presets;\n } catch (error) {\n console.error('[SettingsService] Error getting presets:', error);\n return [];\n }\n}\n\nasync function getPresetTemplates() {\n try {\n const templates = await settingsRepository.getPresetTemplates();\n return templates;\n } catch (error) {\n console.error('[SettingsService] Error getting preset templates:', error);\n return [];\n }\n}\n\nasync function createPreset(title, prompt) {\n try {\n // The adapter injects the UID.\n const result = await settingsRepository.createPreset({ title, prompt });\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'created',\n presetId: result.id,\n title\n });\n \n return { success: true, id: result.id };\n } catch (error) {\n console.error('[SettingsService] Error creating preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function updatePreset(id, title, prompt) {\n try {\n // The adapter injects the UID.\n await settingsRepository.updatePreset(id, { title, prompt });\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'updated',\n presetId: id,\n title\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error updating preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function deletePreset(id) {\n try {\n // The adapter injects the UID.\n await settingsRepository.deletePreset(id);\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'deleted',\n presetId: id\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error deleting preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function saveApiKey(apiKey, provider = 'openai') {\n try {\n // Use ModelStateService as the single source of truth for API key management\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n throw new Error('ModelStateService not initialized');\n }\n \n await modelStateService.setApiKey(provider, apiKey);\n \n // Notify windows\n BrowserWindow.getAllWindows().forEach(win => {\n if (!win.isDestroyed()) {\n win.webContents.send('api-key-validated', apiKey);\n }\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error saving API key:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function removeApiKey() {\n try {\n // Use ModelStateService as the single source of truth for API key management\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n throw new Error('ModelStateService not initialized');\n }\n \n // Remove all API keys for all providers\n const providers = ['openai', 'anthropic', 'gemini', 'ollama', 'whisper'];\n for (const provider of providers) {\n await modelStateService.removeApiKey(provider);\n }\n \n // Notify windows\n BrowserWindow.getAllWindows().forEach(win => {\n if (!win.isDestroyed()) {\n win.webContents.send('api-key-removed');\n }\n });\n \n console.log('[SettingsService] API key removed for all providers');\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error removing API key:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function updateContentProtection(enabled) {\n try {\n const settings = await getSettings();\n settings.contentProtection = enabled;\n \n // Update content protection in main window\n const { app } = require('electron');\n const mainWindow = windowPool.get('main');\n if (mainWindow && !mainWindow.isDestroyed()) {\n mainWindow.setContentProtection(enabled);\n }\n \n return await saveSettings(settings);\n } catch (error) {\n console.error('[SettingsService] Error updating content protection:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function getAutoUpdateSetting() {\n try {\n return settingsRepository.getAutoUpdate();\n } catch (error) {\n console.error('[SettingsService] Error getting auto update setting:', error);\n return true; // Fallback to enabled\n }\n}\n\nasync function setAutoUpdateSetting(isEnabled) {\n try {\n await settingsRepository.setAutoUpdate(isEnabled);\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error setting auto update setting:', error);\n return { success: false, error: error.message };\n }\n}\n\nfunction initialize() {\n // cleanup \n windowNotificationManager.cleanup();\n \n console.log('[SettingsService] Initialized and ready.');\n}\n\n// Cleanup function\nfunction cleanup() {\n windowNotificationManager.cleanup();\n console.log('[SettingsService] Cleaned up resources.');\n}\n\nfunction notifyPresetUpdate(action, presetId, title = null) {\n const data = { action, presetId };\n if (title) data.title = title;\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', data);\n}\n\nmodule.exports = {\n initialize,\n cleanup,\n notifyPresetUpdate,\n getSettings,\n saveSettings,\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n saveApiKey,\n removeApiKey,\n updateContentProtection,\n getAutoUpdateSetting,\n setAutoUpdateSetting,\n // Model settings facade\n getModelSettings,\n clearApiKey,\n setSelectedModel,\n // Ollama facade\n getOllamaStatus,\n ensureOllamaReady,\n shutdownOllama\n};"], ["/glass/src/features/common/services/modelStateService.js", "const { EventEmitter } = require('events');\nconst Store = require('electron-store');\nconst { PROVIDERS, getProviderClass } = require('../ai/factory');\nconst encryptionService = require('./encryptionService');\nconst providerSettingsRepository = require('../repositories/providerSettings');\nconst authService = require('./authService');\nconst ollamaModelRepository = require('../repositories/ollamaModel');\n\nclass ModelStateService extends EventEmitter {\n constructor() {\n super();\n this.authService = authService;\n // electron-store는 오직 레거시 데이터 마이그레이션 용도로만 사용됩니다.\n this.store = new Store({ name: 'pickle-glass-model-state' });\n }\n\n async initialize() {\n console.log('[ModelStateService] Initializing one-time setup...');\n await this._initializeEncryption();\n await this._runMigrations();\n this.setupLocalAIStateSync();\n await this._autoSelectAvailableModels([], true);\n console.log('[ModelStateService] One-time setup complete.');\n }\n\n async _initializeEncryption() {\n try {\n const rows = await providerSettingsRepository.getRawApiKeys();\n if (rows.some(r => r.api_key && encryptionService.looksEncrypted(r.api_key))) {\n console.log('[ModelStateService] Encrypted keys detected, initializing encryption...');\n const userIdForMigration = this.authService.getCurrentUserId();\n await encryptionService.initializeKey(userIdForMigration);\n } else {\n console.log('[ModelStateService] No encrypted keys detected, skipping encryption initialization.');\n }\n } catch (err) {\n console.warn('[ModelStateService] Error while checking encrypted keys:', err.message);\n }\n }\n\n async _runMigrations() {\n console.log('[ModelStateService] Checking for data migrations...');\n const userId = this.authService.getCurrentUserId();\n \n try {\n const sqliteClient = require('./sqliteClient');\n const db = sqliteClient.getDb();\n const tableExists = db.prepare(\"SELECT name FROM sqlite_master WHERE type='table' AND name='user_model_selections'\").get();\n \n if (tableExists) {\n const selections = db.prepare('SELECT * FROM user_model_selections WHERE uid = ?').get(userId);\n if (selections) {\n console.log('[ModelStateService] Migrating from user_model_selections table...');\n if (selections.llm_model) {\n const llmProvider = this.getProviderForModel(selections.llm_model, 'llm');\n if (llmProvider) {\n await this.setSelectedModel('llm', selections.llm_model);\n }\n }\n if (selections.stt_model) {\n const sttProvider = this.getProviderForModel(selections.stt_model, 'stt');\n if (sttProvider) {\n await this.setSelectedModel('stt', selections.stt_model);\n }\n }\n db.prepare('DROP TABLE user_model_selections').run();\n console.log('[ModelStateService] user_model_selections migration complete.');\n }\n }\n } catch (error) {\n console.error('[ModelStateService] user_model_selections migration failed:', error);\n }\n\n try {\n const legacyData = this.store.get(`users.${userId}`);\n if (legacyData && legacyData.apiKeys) {\n console.log('[ModelStateService] Migrating from electron-store...');\n for (const [provider, apiKey] of Object.entries(legacyData.apiKeys)) {\n if (apiKey && PROVIDERS[provider]) {\n await this.setApiKey(provider, apiKey);\n }\n }\n if (legacyData.selectedModels?.llm) {\n await this.setSelectedModel('llm', legacyData.selectedModels.llm);\n }\n if (legacyData.selectedModels?.stt) {\n await this.setSelectedModel('stt', legacyData.selectedModels.stt);\n }\n this.store.delete(`users.${userId}`);\n console.log('[ModelStateService] electron-store migration complete.');\n }\n } catch (error) {\n console.error('[ModelStateService] electron-store migration failed:', error);\n }\n }\n \n setupLocalAIStateSync() {\n const localAIManager = require('./localAIManager');\n localAIManager.on('state-changed', (service, status) => {\n this.handleLocalAIStateChange(service, status);\n });\n }\n\n async handleLocalAIStateChange(service, state) {\n console.log(`[ModelStateService] LocalAI state changed: ${service}`, state);\n if (!state.installed || !state.running) {\n const types = service === 'ollama' ? ['llm'] : service === 'whisper' ? ['stt'] : [];\n await this._autoSelectAvailableModels(types);\n }\n this.emit('state-updated', await this.getLiveState());\n }\n\n async getLiveState() {\n const providerSettings = await providerSettingsRepository.getAll();\n const apiKeys = {};\n Object.keys(PROVIDERS).forEach(provider => {\n const setting = providerSettings.find(s => s.provider === provider);\n apiKeys[provider] = setting?.api_key || null;\n });\n\n const activeSettings = await providerSettingsRepository.getActiveSettings();\n const selectedModels = {\n llm: activeSettings.llm?.selected_llm_model || null,\n stt: activeSettings.stt?.selected_stt_model || null\n };\n \n return { apiKeys, selectedModels };\n }\n\n async _autoSelectAvailableModels(forceReselectionForTypes = [], isInitialBoot = false) {\n console.log(`[ModelStateService] Running auto-selection. Force re-selection for: [${forceReselectionForTypes.join(', ')}]`);\n const { apiKeys, selectedModels } = await this.getLiveState();\n const types = ['llm', 'stt'];\n\n for (const type of types) {\n const currentModelId = selectedModels[type];\n let isCurrentModelValid = false;\n const forceReselection = forceReselectionForTypes.includes(type);\n\n if (currentModelId && !forceReselection) {\n const provider = this.getProviderForModel(currentModelId, type);\n const apiKey = apiKeys[provider];\n if (provider && apiKey) {\n isCurrentModelValid = true;\n }\n }\n\n if (!isCurrentModelValid) {\n console.log(`[ModelStateService] No valid ${type.toUpperCase()} model selected or selection forced. Finding an alternative...`);\n const availableModels = await this.getAvailableModels(type);\n if (availableModels.length > 0) {\n const apiModel = availableModels.find(model => {\n const provider = this.getProviderForModel(model.id, type);\n return provider && provider !== 'ollama' && provider !== 'whisper';\n });\n const newModel = apiModel || availableModels[0];\n await this.setSelectedModel(type, newModel.id);\n console.log(`[ModelStateService] Auto-selected ${type.toUpperCase()} model: ${newModel.id}`);\n } else {\n await providerSettingsRepository.setActiveProvider(null, type);\n if (!isInitialBoot) {\n this.emit('state-updated', await this.getLiveState());\n }\n }\n }\n }\n }\n \n async setFirebaseVirtualKey(virtualKey) {\n console.log(`[ModelStateService] Setting Firebase virtual key.`);\n\n // 키를 설정하기 전에, 이전에 openai-glass 키가 있었는지 확인합니다.\n const previousSettings = await providerSettingsRepository.getByProvider('openai-glass');\n const wasPreviouslyConfigured = !!previousSettings?.api_key;\n\n // 항상 새로운 가상 키로 업데이트합니다.\n await this.setApiKey('openai-glass', virtualKey);\n\n if (virtualKey) {\n // 이전에 설정된 적이 없는 경우 (최초 로그인)에만 모델을 강제로 변경합니다.\n if (!wasPreviouslyConfigured) {\n console.log('[ModelStateService] First-time setup for openai-glass, setting default models.');\n const llmModel = PROVIDERS['openai-glass']?.llmModels[0];\n const sttModel = PROVIDERS['openai-glass']?.sttModels[0];\n if (llmModel) await this.setSelectedModel('llm', llmModel.id);\n if (sttModel) await this.setSelectedModel('stt', sttModel.id);\n } else {\n console.log('[ModelStateService] openai-glass key updated, but respecting user\\'s existing model selection.');\n }\n } else {\n // 로그아웃 시, 현재 활성화된 모델이 openai-glass인 경우에만 다른 모델로 전환합니다.\n const selected = await this.getSelectedModels();\n const llmProvider = this.getProviderForModel(selected.llm, 'llm');\n const sttProvider = this.getProviderForModel(selected.stt, 'stt');\n \n const typesToReselect = [];\n if (llmProvider === 'openai-glass') typesToReselect.push('llm');\n if (sttProvider === 'openai-glass') typesToReselect.push('stt');\n\n if (typesToReselect.length > 0) {\n console.log('[ModelStateService] Logged out, re-selecting models for:', typesToReselect.join(', '));\n await this._autoSelectAvailableModels(typesToReselect);\n }\n }\n }\n\n async setApiKey(provider, key) {\n console.log(`[ModelStateService] setApiKey for ${provider}`);\n if (!provider) {\n throw new Error('Provider is required');\n }\n\n // 'openai-glass'는 자체 인증 키를 사용하므로 유효성 검사를 건너뜁니다.\n if (provider !== 'openai-glass') {\n const validationResult = await this.validateApiKey(provider, key);\n if (!validationResult.success) {\n console.warn(`[ModelStateService] API key validation failed for ${provider}: ${validationResult.error}`);\n return validationResult;\n }\n }\n\n const finalKey = (provider === 'ollama' || provider === 'whisper') ? 'local' : key;\n const existingSettings = await providerSettingsRepository.getByProvider(provider) || {};\n await providerSettingsRepository.upsert(provider, { ...existingSettings, api_key: finalKey });\n \n // 키가 추가/변경되었으므로, 해당 provider의 모델을 자동 선택할 수 있는지 확인\n await this._autoSelectAvailableModels([]);\n \n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return { success: true };\n }\n\n async getAllApiKeys() {\n const allSettings = await providerSettingsRepository.getAll();\n const apiKeys = {};\n allSettings.forEach(s => {\n if (s.provider !== 'openai-glass') {\n apiKeys[s.provider] = s.api_key;\n }\n });\n return apiKeys;\n }\n\n async removeApiKey(provider) {\n const setting = await providerSettingsRepository.getByProvider(provider);\n if (setting && setting.api_key) {\n await providerSettingsRepository.upsert(provider, { ...setting, api_key: null });\n await this._autoSelectAvailableModels(['llm', 'stt']);\n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return true;\n }\n return false;\n }\n\n /**\n * 사용자가 Firebase에 로그인했는지 확인합니다.\n */\n isLoggedInWithFirebase() {\n return this.authService.getCurrentUser().isLoggedIn;\n }\n\n /**\n * 유효한 API 키가 하나라도 설정되어 있는지 확인합니다.\n */\n async hasValidApiKey() {\n if (this.isLoggedInWithFirebase()) return true;\n \n const allSettings = await providerSettingsRepository.getAll();\n return allSettings.some(s => s.api_key && s.api_key.trim().length > 0);\n }\n\n getProviderForModel(arg1, arg2) {\n // Compatibility: support both (type, modelId) old order and (modelId, type) new order\n let type, modelId;\n if (arg1 === 'llm' || arg1 === 'stt') {\n type = arg1;\n modelId = arg2;\n } else {\n modelId = arg1;\n type = arg2;\n }\n if (!modelId || !type) return null;\n for (const providerId in PROVIDERS) {\n const models = type === 'llm' ? PROVIDERS[providerId].llmModels : PROVIDERS[providerId].sttModels;\n if (models && models.some(m => m.id === modelId)) {\n return providerId;\n }\n }\n if (type === 'llm') {\n const installedModels = ollamaModelRepository.getInstalledModels();\n if (installedModels.some(m => m.name === modelId)) return 'ollama';\n }\n return null;\n }\n\n async getSelectedModels() {\n const active = await providerSettingsRepository.getActiveSettings();\n return {\n llm: active.llm?.selected_llm_model || null,\n stt: active.stt?.selected_stt_model || null,\n };\n }\n \n async setSelectedModel(type, modelId) {\n const provider = this.getProviderForModel(modelId, type);\n if (!provider) {\n console.warn(`[ModelStateService] No provider found for model ${modelId}`);\n return false;\n }\n\n const existingSettings = await providerSettingsRepository.getByProvider(provider) || {};\n const newSettings = { ...existingSettings };\n\n if (type === 'llm') {\n newSettings.selected_llm_model = modelId;\n } else {\n newSettings.selected_stt_model = modelId;\n }\n \n await providerSettingsRepository.upsert(provider, newSettings);\n await providerSettingsRepository.setActiveProvider(provider, type);\n \n console.log(`[ModelStateService] Selected ${type} model: ${modelId} (provider: ${provider})`);\n \n if (type === 'llm' && provider === 'ollama') {\n require('./localAIManager').warmUpModel(modelId).catch(err => console.warn(err));\n }\n \n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return true;\n }\n\n async getAvailableModels(type) {\n const allSettings = await providerSettingsRepository.getAll();\n const available = [];\n const modelListKey = type === 'llm' ? 'llmModels' : 'sttModels';\n\n for (const setting of allSettings) {\n if (!setting.api_key) continue;\n\n const providerId = setting.provider;\n if (providerId === 'ollama' && type === 'llm') {\n const installed = ollamaModelRepository.getInstalledModels();\n available.push(...installed.map(m => ({ id: m.name, name: m.name })));\n } else if (PROVIDERS[providerId]?.[modelListKey]) {\n available.push(...PROVIDERS[providerId][modelListKey]);\n }\n }\n return [...new Map(available.map(item => [item.id, item])).values()];\n }\n\n async getCurrentModelInfo(type) {\n const activeSetting = await providerSettingsRepository.getActiveProvider(type);\n if (!activeSetting) return null;\n \n const model = type === 'llm' ? activeSetting.selected_llm_model : activeSetting.selected_stt_model;\n if (!model) return null;\n\n return {\n provider: activeSetting.provider,\n model: model,\n apiKey: activeSetting.api_key,\n };\n }\n\n // --- 핸들러 및 유틸리티 메서드 ---\n\n async validateApiKey(provider, key) {\n if (!key || (key.trim() === '' && provider !== 'ollama' && provider !== 'whisper')) {\n return { success: false, error: 'API key cannot be empty.' };\n }\n const ProviderClass = getProviderClass(provider);\n if (!ProviderClass || typeof ProviderClass.validateApiKey !== 'function') {\n return { success: true };\n }\n try {\n return await ProviderClass.validateApiKey(key);\n } catch (error) {\n return { success: false, error: 'An unexpected error occurred during validation.' };\n }\n }\n\n getProviderConfig() {\n const config = {};\n for (const key in PROVIDERS) {\n const { handler, ...rest } = PROVIDERS[key];\n config[key] = rest;\n }\n return config;\n }\n \n async handleRemoveApiKey(provider) {\n const success = await this.removeApiKey(provider);\n if (success) {\n const selectedModels = await this.getSelectedModels();\n if (!selectedModels.llm && !selectedModels.stt) {\n this.emit('force-show-apikey-header');\n }\n }\n return success;\n }\n\n /*-------------- Compatibility Helpers --------------*/\n async handleValidateKey(provider, key) {\n return await this.setApiKey(provider, key);\n }\n\n async handleSetSelectedModel(type, modelId) {\n return await this.setSelectedModel(type, modelId);\n }\n\n async areProvidersConfigured() {\n if (this.isLoggedInWithFirebase()) return true;\n const allSettings = await providerSettingsRepository.getAll();\n const apiKeyMap = {};\n allSettings.forEach(s => apiKeyMap[s.provider] = s.api_key);\n // LLM\n const hasLlmKey = Object.entries(apiKeyMap).some(([provider, key]) => {\n if (!key) return false;\n if (provider === 'whisper') return false; // whisper는 LLM 없음\n return PROVIDERS[provider]?.llmModels?.length > 0;\n });\n // STT\n const hasSttKey = Object.entries(apiKeyMap).some(([provider, key]) => {\n if (!key) return false;\n if (provider === 'ollama') return false; // ollama는 STT 없음\n return PROVIDERS[provider]?.sttModels?.length > 0 || provider === 'whisper';\n });\n return hasLlmKey && hasSttKey;\n }\n}\n\nconst modelStateService = new ModelStateService();\nmodule.exports = modelStateService;"], ["/glass/src/features/common/repositories/preset/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction getPresets(uid) {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE uid = ? OR is_default = 1 \n ORDER BY is_default DESC, title ASC\n `;\n \n try {\n return db.prepare(query).all(uid);\n } catch (err) {\n console.error('SQLite: Failed to get presets:', err);\n throw err;\n }\n}\n\nfunction getPresetTemplates() {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE is_default = 1 \n ORDER BY title ASC\n `;\n \n try {\n return db.prepare(query).all();\n } catch (err) {\n console.error('SQLite: Failed to get preset templates:', err);\n throw err;\n }\n}\n\nfunction create({ uid, title, prompt }) {\n const db = sqliteClient.getDb();\n const presetId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO prompt_presets (id, uid, title, prompt, is_default, created_at, sync_state) VALUES (?, ?, ?, ?, 0, ?, 'dirty')`;\n \n try {\n db.prepare(query).run(presetId, uid, title, prompt, now);\n return { id: presetId };\n } catch (err) {\n throw err;\n }\n}\n\nfunction update(id, { title, prompt }, uid) {\n const db = sqliteClient.getDb();\n const query = `UPDATE prompt_presets SET title = ?, prompt = ?, sync_state = 'dirty' WHERE id = ? AND uid = ? AND is_default = 0`;\n\n try {\n const result = db.prepare(query).run(title, prompt, id, uid);\n if (result.changes === 0) {\n throw new Error(\"Preset not found or permission denied.\");\n }\n return { changes: result.changes };\n } catch (err) {\n throw err;\n }\n}\n\nfunction del(id, uid) {\n const db = sqliteClient.getDb();\n const query = `DELETE FROM prompt_presets WHERE id = ? AND uid = ? AND is_default = 0`;\n\n try {\n const result = db.prepare(query).run(id, uid);\n if (result.changes === 0) {\n throw new Error(\"Preset not found or permission denied.\");\n }\n return { changes: result.changes };\n } catch (err) {\n throw err;\n }\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n create,\n update,\n delete: del\n}; "], ["/glass/src/ui/settings/SettingsView.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n// import { getOllamaProgressTracker } from '../../features/common/services/localProgressTracker.js'; // 제거됨\n\nexport class SettingsView extends LitElement {\n static styles = css`\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n :host {\n display: block;\n width: 240px;\n height: 100%;\n color: white;\n }\n\n .settings-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: rgba(20, 20, 20, 0.8);\n border-radius: 12px;\n outline: 0.5px rgba(255, 255, 255, 0.2) solid;\n outline-offset: -1px;\n box-sizing: border-box;\n position: relative;\n overflow-y: auto;\n padding: 12px 12px;\n z-index: 1000;\n }\n\n .settings-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .settings-container::-webkit-scrollbar-track {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n }\n\n .settings-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n }\n\n .settings-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .settings-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n filter: blur(10px);\n z-index: -1;\n }\n \n .settings-button[disabled],\n .api-key-section input[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .header-section {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n padding-bottom: 6px;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n position: relative;\n z-index: 1;\n }\n\n .title-line {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .app-title {\n font-size: 13px;\n font-weight: 500;\n color: white;\n margin: 0 0 4px 0;\n }\n\n .account-info {\n font-size: 11px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n }\n\n .invisibility-icon {\n padding-top: 2px;\n opacity: 0;\n transition: opacity 0.3s ease;\n }\n\n .invisibility-icon.visible {\n opacity: 1;\n }\n\n .invisibility-icon svg {\n width: 16px;\n height: 16px;\n }\n\n .shortcuts-section {\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: 4px 0;\n position: relative;\n z-index: 1;\n }\n\n .shortcut-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 0;\n color: white;\n font-size: 11px;\n }\n\n .shortcut-name {\n font-weight: 300;\n }\n\n .shortcut-keys {\n display: flex;\n align-items: center;\n gap: 3px;\n }\n\n .cmd-key, .shortcut-key {\n background: rgba(255, 255, 255, 0.1);\n border-radius: 3px;\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 11px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.9);\n }\n\n /* Buttons Section */\n .buttons-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n padding-top: 6px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n position: relative;\n z-index: 1;\n flex: 1;\n }\n\n .settings-button {\n background: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-radius: 4px;\n color: white;\n padding: 5px 10px;\n font-size: 11px;\n font-weight: 400;\n cursor: pointer;\n transition: all 0.15s ease;\n display: flex;\n align-items: center;\n justify-content: center;\n white-space: nowrap;\n }\n\n .settings-button:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .settings-button:active {\n transform: translateY(1px);\n }\n\n .settings-button.full-width {\n width: 100%;\n }\n\n .settings-button.half-width {\n flex: 1;\n }\n\n .settings-button.danger {\n background: rgba(255, 59, 48, 0.1);\n border-color: rgba(255, 59, 48, 0.3);\n color: rgba(255, 59, 48, 0.9);\n }\n\n .settings-button.danger:hover {\n background: rgba(255, 59, 48, 0.15);\n border-color: rgba(255, 59, 48, 0.4);\n }\n\n .move-buttons, .bottom-buttons {\n display: flex;\n gap: 4px;\n }\n\n .api-key-section {\n padding: 6px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .api-key-section input {\n width: 100%;\n background: rgba(0,0,0,0.2);\n border: 1px solid rgba(255,255,255,0.2);\n color: white;\n border-radius: 4px;\n padding: 4px;\n font-size: 11px;\n margin-bottom: 4px;\n box-sizing: border-box;\n }\n\n .api-key-section input::placeholder {\n color: rgba(255, 255, 255, 0.4);\n }\n\n /* Preset Management Section */\n .preset-section {\n padding: 6px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .preset-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 4px;\n }\n\n .preset-title {\n font-size: 11px;\n font-weight: 500;\n color: white;\n }\n\n .preset-count {\n font-size: 9px;\n color: rgba(255, 255, 255, 0.5);\n margin-left: 4px;\n }\n\n .preset-toggle {\n font-size: 10px;\n color: rgba(255, 255, 255, 0.6);\n cursor: pointer;\n padding: 2px 4px;\n border-radius: 2px;\n transition: background-color 0.15s ease;\n }\n\n .preset-toggle:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .preset-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n max-height: 120px;\n overflow-y: auto;\n }\n\n .preset-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 6px;\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n cursor: pointer;\n transition: all 0.15s ease;\n font-size: 11px;\n border: 1px solid transparent;\n }\n\n .preset-item:hover {\n background: rgba(255, 255, 255, 0.1);\n border-color: rgba(255, 255, 255, 0.1);\n }\n\n .preset-item.selected {\n background: rgba(0, 122, 255, 0.25);\n border-color: rgba(0, 122, 255, 0.6);\n box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.3);\n }\n\n .preset-name {\n color: white;\n flex: 1;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n font-weight: 300;\n }\n\n .preset-item.selected .preset-name {\n font-weight: 500;\n }\n\n .preset-status {\n font-size: 9px;\n color: rgba(0, 122, 255, 0.8);\n font-weight: 500;\n margin-left: 6px;\n }\n\n .no-presets-message {\n padding: 12px 8px;\n text-align: center;\n color: rgba(255, 255, 255, 0.5);\n font-size: 10px;\n line-height: 1.4;\n }\n\n .no-presets-message .web-link {\n color: rgba(0, 122, 255, 0.8);\n text-decoration: underline;\n cursor: pointer;\n }\n\n .no-presets-message .web-link:hover {\n color: rgba(0, 122, 255, 1);\n }\n\n .loading-state {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n color: rgba(255, 255, 255, 0.7);\n font-size: 11px;\n }\n\n .loading-spinner {\n width: 12px;\n height: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-top: 1px solid rgba(255, 255, 255, 0.8);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin-right: 6px;\n }\n\n .hidden {\n display: none;\n }\n\n .api-key-section, .model-selection-section {\n padding: 8px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .provider-key-group, .model-select-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n label {\n font-size: 11px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.8);\n margin-left: 2px;\n }\n label > strong {\n color: white;\n font-weight: 600;\n }\n .provider-key-group input {\n width: 100%; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.2);\n color: white; border-radius: 4px; padding: 5px 8px; font-size: 11px; box-sizing: border-box;\n }\n .key-buttons { display: flex; gap: 4px; }\n .key-buttons .settings-button { flex: 1; padding: 4px; }\n .model-list {\n display: flex; flex-direction: column; gap: 2px; max-height: 120px;\n overflow-y: auto; background: rgba(0,0,0,0.3); border-radius: 4px;\n padding: 4px; margin-top: 4px;\n }\n .model-item { \n padding: 5px 8px; \n font-size: 11px; \n border-radius: 3px; \n cursor: pointer; \n transition: background-color 0.15s; \n display: flex; \n justify-content: space-between; \n align-items: center; \n }\n .model-item:hover { background-color: rgba(255,255,255,0.1); }\n .model-item.selected { background-color: rgba(0, 122, 255, 0.4); font-weight: 500; }\n .model-status { \n font-size: 9px; \n color: rgba(255,255,255,0.6); \n margin-left: 8px; \n }\n .model-status.installed { color: rgba(0, 255, 0, 0.8); }\n .model-status.not-installed { color: rgba(255, 200, 0, 0.8); }\n .install-progress {\n flex: 1;\n height: 4px;\n background: rgba(255,255,255,0.1);\n border-radius: 2px;\n margin-left: 8px;\n overflow: hidden;\n }\n .install-progress-bar {\n height: 100%;\n background: rgba(0, 122, 255, 0.8);\n transition: width 0.3s ease;\n }\n \n /* Dropdown styles */\n select.model-dropdown {\n background: rgba(0,0,0,0.2);\n color: white;\n cursor: pointer;\n }\n \n select.model-dropdown option {\n background: #1a1a1a;\n color: white;\n }\n \n select.model-dropdown option:disabled {\n color: rgba(255,255,255,0.4);\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n\n :host-context(body.has-glass) * {\n background: transparent !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n outline: none !important;\n border: none !important;\n border-radius: 0 !important;\n transition: none !important;\n animation: none !important;\n }\n\n :host-context(body.has-glass) .settings-container::before {\n display: none !important;\n }\n `;\n\n\n //////// after_modelStateService ////////\n static properties = {\n shortcuts: { type: Object, state: true },\n firebaseUser: { type: Object, state: true },\n isLoading: { type: Boolean, state: true },\n isContentProtectionOn: { type: Boolean, state: true },\n saving: { type: Boolean, state: true },\n providerConfig: { type: Object, state: true },\n apiKeys: { type: Object, state: true },\n availableLlmModels: { type: Array, state: true },\n availableSttModels: { type: Array, state: true },\n selectedLlm: { type: String, state: true },\n selectedStt: { type: String, state: true },\n isLlmListVisible: { type: Boolean },\n isSttListVisible: { type: Boolean },\n presets: { type: Array, state: true },\n selectedPreset: { type: Object, state: true },\n showPresets: { type: Boolean, state: true },\n autoUpdateEnabled: { type: Boolean, state: true },\n autoUpdateLoading: { type: Boolean, state: true },\n // Ollama related properties\n ollamaStatus: { type: Object, state: true },\n ollamaModels: { type: Array, state: true },\n installingModels: { type: Object, state: true },\n // Whisper related properties\n whisperModels: { type: Array, state: true },\n };\n //////// after_modelStateService ////////\n\n constructor() {\n super();\n //////// after_modelStateService ////////\n this.shortcuts = {};\n this.firebaseUser = null;\n this.apiKeys = { openai: '', gemini: '', anthropic: '', whisper: '' };\n this.providerConfig = {};\n this.isLoading = true;\n this.isContentProtectionOn = true;\n this.saving = false;\n this.availableLlmModels = [];\n this.availableSttModels = [];\n this.selectedLlm = null;\n this.selectedStt = null;\n this.isLlmListVisible = false;\n this.isSttListVisible = false;\n this.presets = [];\n this.selectedPreset = null;\n this.showPresets = false;\n // Ollama related\n this.ollamaStatus = { installed: false, running: false };\n this.ollamaModels = [];\n this.installingModels = {}; // { modelName: progress }\n // Whisper related\n this.whisperModels = [];\n this.whisperProgressTracker = null; // Will be initialized when needed\n this.handleUsePicklesKey = this.handleUsePicklesKey.bind(this)\n this.autoUpdateEnabled = true;\n this.autoUpdateLoading = true;\n this.loadInitialData();\n //////// after_modelStateService ////////\n }\n\n async loadAutoUpdateSetting() {\n if (!window.api) return;\n this.autoUpdateLoading = true;\n try {\n const enabled = await window.api.settingsView.getAutoUpdate();\n this.autoUpdateEnabled = enabled;\n console.log('Auto-update setting loaded:', enabled);\n } catch (e) {\n console.error('Error loading auto-update setting:', e);\n this.autoUpdateEnabled = true; // fallback\n }\n this.autoUpdateLoading = false;\n this.requestUpdate();\n }\n\n async handleToggleAutoUpdate() {\n if (!window.api || this.autoUpdateLoading) return;\n this.autoUpdateLoading = true;\n this.requestUpdate();\n try {\n const newValue = !this.autoUpdateEnabled;\n const result = await window.api.settingsView.setAutoUpdate(newValue);\n if (result && result.success) {\n this.autoUpdateEnabled = newValue;\n } else {\n console.error('Failed to update auto-update setting');\n }\n } catch (e) {\n console.error('Error toggling auto-update:', e);\n }\n this.autoUpdateLoading = false;\n this.requestUpdate();\n }\n\n async loadLocalAIStatus() {\n try {\n // Load Ollama status\n const ollamaStatus = await window.api.settingsView.getOllamaStatus();\n if (ollamaStatus?.success) {\n this.ollamaStatus = { installed: ollamaStatus.installed, running: ollamaStatus.running };\n this.ollamaModels = ollamaStatus.models || [];\n }\n \n // Load Whisper models status only if Whisper is enabled\n if (this.apiKeys?.whisper === 'local') {\n const whisperModelsResult = await window.api.settingsView.getWhisperInstalledModels();\n if (whisperModelsResult?.success) {\n const installedWhisperModels = whisperModelsResult.models;\n if (this.providerConfig?.whisper) {\n this.providerConfig.whisper.sttModels.forEach(m => {\n const installedInfo = installedWhisperModels.find(i => i.id === m.id);\n if (installedInfo) {\n m.installed = installedInfo.installed;\n }\n });\n }\n }\n }\n \n // Trigger UI update\n this.requestUpdate();\n } catch (error) {\n console.error('Error loading LocalAI status:', error);\n }\n }\n\n //////// after_modelStateService ////////\n async loadInitialData() {\n if (!window.api) return;\n this.isLoading = true;\n try {\n // Load essential data first\n const [userState, modelSettings, presets, contentProtection, shortcuts] = await Promise.all([\n window.api.settingsView.getCurrentUser(),\n window.api.settingsView.getModelSettings(), // Facade call\n window.api.settingsView.getPresets(),\n window.api.settingsView.getContentProtectionStatus(),\n window.api.settingsView.getCurrentShortcuts()\n ]);\n \n if (userState && userState.isLoggedIn) this.firebaseUser = userState;\n \n if (modelSettings.success) {\n const { config, storedKeys, availableLlm, availableStt, selectedModels } = modelSettings.data;\n this.providerConfig = config;\n this.apiKeys = storedKeys;\n this.availableLlmModels = availableLlm;\n this.availableSttModels = availableStt;\n this.selectedLlm = selectedModels.llm;\n this.selectedStt = selectedModels.stt;\n }\n\n this.presets = presets || [];\n this.isContentProtectionOn = contentProtection;\n this.shortcuts = shortcuts || {};\n if (this.presets.length > 0) {\n const firstUserPreset = this.presets.find(p => p.is_default === 0);\n if (firstUserPreset) this.selectedPreset = firstUserPreset;\n }\n \n // Load LocalAI status asynchronously to improve initial load time\n this.loadLocalAIStatus();\n } catch (error) {\n console.error('Error loading initial settings data:', error);\n } finally {\n this.isLoading = false;\n }\n }\n\n\n async handleSaveKey(provider) {\n const input = this.shadowRoot.querySelector(`#key-input-${provider}`);\n if (!input) return;\n const key = input.value;\n \n // For Ollama, we need to ensure it's ready first\n if (provider === 'ollama') {\n this.saving = true;\n \n // First ensure Ollama is installed and running\n const ensureResult = await window.api.settingsView.ensureOllamaReady();\n if (!ensureResult.success) {\n alert(`Failed to setup Ollama: ${ensureResult.error}`);\n this.saving = false;\n return;\n }\n \n // Now validate (which will check if service is running)\n const result = await window.api.settingsView.validateKey({ provider, key: 'local' });\n \n if (result.success) {\n await this.refreshModelData();\n await this.refreshOllamaStatus();\n } else {\n alert(`Failed to connect to Ollama: ${result.error}`);\n }\n this.saving = false;\n return;\n }\n \n // For Whisper, just enable it\n if (provider === 'whisper') {\n this.saving = true;\n const result = await window.api.settingsView.validateKey({ provider, key: 'local' });\n \n if (result.success) {\n await this.refreshModelData();\n } else {\n alert(`Failed to enable Whisper: ${result.error}`);\n }\n this.saving = false;\n return;\n }\n \n // For other providers, use the normal flow\n this.saving = true;\n const result = await window.api.settingsView.validateKey({ provider, key });\n \n if (result.success) {\n await this.refreshModelData();\n } else {\n alert(`Failed to save ${provider} key: ${result.error}`);\n input.value = this.apiKeys[provider] || '';\n }\n this.saving = false;\n }\n \n async handleClearKey(provider) {\n console.log(`[SettingsView] handleClearKey: ${provider}`);\n this.saving = true;\n await window.api.settingsView.removeApiKey(provider);\n this.apiKeys = { ...this.apiKeys, [provider]: '' };\n await this.refreshModelData();\n this.saving = false;\n }\n\n async refreshModelData() {\n const [availableLlm, availableStt, selected, storedKeys] = await Promise.all([\n window.api.settingsView.getAvailableModels({ type: 'llm' }),\n window.api.settingsView.getAvailableModels({ type: 'stt' }),\n window.api.settingsView.getSelectedModels(),\n window.api.settingsView.getAllKeys()\n ]);\n this.availableLlmModels = availableLlm;\n this.availableSttModels = availableStt;\n this.selectedLlm = selected.llm;\n this.selectedStt = selected.stt;\n this.apiKeys = storedKeys;\n this.requestUpdate();\n }\n \n async toggleModelList(type) {\n const visibilityProp = type === 'llm' ? 'isLlmListVisible' : 'isSttListVisible';\n\n if (!this[visibilityProp]) {\n this.saving = true;\n this.requestUpdate();\n \n await this.refreshModelData();\n\n this.saving = false;\n }\n\n // 데이터 새로고침 후, 목록의 표시 상태를 토글합니다.\n this[visibilityProp] = !this[visibilityProp];\n this.requestUpdate();\n }\n \n async selectModel(type, modelId) {\n // Check if this is an Ollama model that needs to be installed\n const provider = this.getProviderForModel(type, modelId);\n if (provider === 'ollama') {\n const ollamaModel = this.ollamaModels.find(m => m.name === modelId);\n if (ollamaModel && !ollamaModel.installed && !ollamaModel.installing) {\n // Need to install the model first\n await this.installOllamaModel(modelId);\n return;\n }\n }\n \n // Check if this is a Whisper model that needs to be downloaded\n if (provider === 'whisper' && type === 'stt') {\n const isInstalling = this.installingModels[modelId] !== undefined;\n const whisperModelInfo = this.providerConfig.whisper.sttModels.find(m => m.id === modelId);\n \n if (whisperModelInfo && !whisperModelInfo.installed && !isInstalling) {\n await this.downloadWhisperModel(modelId);\n return;\n }\n }\n \n this.saving = true;\n await window.api.settingsView.setSelectedModel({ type, modelId });\n if (type === 'llm') this.selectedLlm = modelId;\n if (type === 'stt') this.selectedStt = modelId;\n this.isLlmListVisible = false;\n this.isSttListVisible = false;\n this.saving = false;\n this.requestUpdate();\n }\n \n async refreshOllamaStatus() {\n const ollamaStatus = await window.api.settingsView.getOllamaStatus();\n if (ollamaStatus?.success) {\n this.ollamaStatus = { installed: ollamaStatus.installed, running: ollamaStatus.running };\n this.ollamaModels = ollamaStatus.models || [];\n }\n }\n \n async installOllamaModel(modelName) {\n try {\n // Ollama 모델 다운로드 시작\n this.installingModels = { ...this.installingModels, [modelName]: 0 };\n this.requestUpdate();\n\n // 진행률 이벤트 리스너 설정 - 통합 LocalAI 이벤트 사용\n const progressHandler = (event, data) => {\n if (data.service === 'ollama' && data.model === modelName) {\n this.installingModels = { ...this.installingModels, [modelName]: data.progress || 0 };\n this.requestUpdate();\n }\n };\n\n // 통합 LocalAI 이벤트 리스너 등록\n window.api.settingsView.onLocalAIInstallProgress(progressHandler);\n\n try {\n const result = await window.api.settingsView.pullOllamaModel(modelName);\n \n if (result.success) {\n console.log(`[SettingsView] Model ${modelName} installed successfully`);\n delete this.installingModels[modelName];\n this.requestUpdate();\n \n // 상태 새로고침\n await this.refreshOllamaStatus();\n await this.refreshModelData();\n } else {\n throw new Error(result.error || 'Installation failed');\n }\n } finally {\n // 통합 LocalAI 이벤트 리스너 제거\n window.api.settingsView.removeOnLocalAIInstallProgress(progressHandler);\n }\n } catch (error) {\n console.error(`[SettingsView] Error installing model ${modelName}:`, error);\n delete this.installingModels[modelName];\n this.requestUpdate();\n }\n }\n \n async downloadWhisperModel(modelId) {\n // Mark as installing\n this.installingModels = { ...this.installingModels, [modelId]: 0 };\n this.requestUpdate();\n \n try {\n // Set up progress listener - 통합 LocalAI 이벤트 사용\n const progressHandler = (event, data) => {\n if (data.service === 'whisper' && data.model === modelId) {\n this.installingModels = { ...this.installingModels, [modelId]: data.progress || 0 };\n this.requestUpdate();\n }\n };\n \n window.api.settingsView.onLocalAIInstallProgress(progressHandler);\n \n // Start download\n const result = await window.api.settingsView.downloadWhisperModel(modelId);\n \n if (result.success) {\n // Update the model's installed status\n if (this.providerConfig?.whisper?.sttModels) {\n const modelInfo = this.providerConfig.whisper.sttModels.find(m => m.id === modelId);\n if (modelInfo) {\n modelInfo.installed = true;\n }\n }\n \n // Remove from installing models\n delete this.installingModels[modelId];\n this.requestUpdate();\n \n // Reload LocalAI status to get fresh data\n await this.loadLocalAIStatus();\n \n // Auto-select the model after download\n await this.selectModel('stt', modelId);\n } else {\n // Remove from installing models on failure too\n delete this.installingModels[modelId];\n this.requestUpdate();\n alert(`Failed to download Whisper model: ${result.error}`);\n }\n \n // Cleanup\n window.api.settingsView.removeOnLocalAIInstallProgress(progressHandler);\n } catch (error) {\n console.error(`[SettingsView] Error downloading Whisper model ${modelId}:`, error);\n // Remove from installing models on error\n delete this.installingModels[modelId];\n this.requestUpdate();\n alert(`Error downloading ${modelId}: ${error.message}`);\n }\n }\n \n getProviderForModel(type, modelId) {\n for (const [providerId, config] of Object.entries(this.providerConfig)) {\n const models = type === 'llm' ? config.llmModels : config.sttModels;\n if (models?.some(m => m.id === modelId)) {\n return providerId;\n }\n }\n return null;\n }\n\n\n handleUsePicklesKey(e) {\n e.preventDefault()\n if (this.wasJustDragged) return\n \n console.log(\"Requesting Firebase authentication from main process...\")\n window.api.settingsView.startFirebaseAuth();\n }\n //////// after_modelStateService ////////\n\n openShortcutEditor() {\n window.api.settingsView.openShortcutSettingsWindow();\n }\n\n connectedCallback() {\n super.connectedCallback();\n \n this.setupEventListeners();\n this.setupIpcListeners();\n this.setupWindowResize();\n this.loadAutoUpdateSetting();\n // Force one height calculation immediately (innerHeight may be 0 at first)\n setTimeout(() => this.updateScrollHeight(), 0);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.cleanupEventListeners();\n this.cleanupIpcListeners();\n this.cleanupWindowResize();\n \n // Cancel any ongoing Ollama installations when component is destroyed\n const installingModels = Object.keys(this.installingModels);\n if (installingModels.length > 0) {\n installingModels.forEach(modelName => {\n window.api.settingsView.cancelOllamaInstallation(modelName);\n });\n }\n }\n\n setupEventListeners() {\n this.addEventListener('mouseenter', this.handleMouseEnter);\n this.addEventListener('mouseleave', this.handleMouseLeave);\n }\n\n cleanupEventListeners() {\n this.removeEventListener('mouseenter', this.handleMouseEnter);\n this.removeEventListener('mouseleave', this.handleMouseLeave);\n }\n\n setupIpcListeners() {\n if (!window.api) return;\n \n this._userStateListener = (event, userState) => {\n console.log('[SettingsView] Received user-state-changed:', userState);\n if (userState && userState.isLoggedIn) {\n this.firebaseUser = userState;\n } else {\n this.firebaseUser = null;\n }\n this.loadAutoUpdateSetting();\n // Reload model settings when user state changes (Firebase login/logout)\n this.loadInitialData();\n };\n \n this._settingsUpdatedListener = (event, settings) => {\n console.log('[SettingsView] Received settings-updated');\n this.settings = settings;\n this.requestUpdate();\n };\n\n // 프리셋 업데이트 리스너 추가\n this._presetsUpdatedListener = async (event) => {\n console.log('[SettingsView] Received presets-updated, refreshing presets');\n try {\n const presets = await window.api.settingsView.getPresets();\n this.presets = presets || [];\n \n // 현재 선택된 프리셋이 삭제되었는지 확인 (사용자 프리셋만 고려)\n const userPresets = this.presets.filter(p => p.is_default === 0);\n if (this.selectedPreset && !userPresets.find(p => p.id === this.selectedPreset.id)) {\n this.selectedPreset = userPresets.length > 0 ? userPresets[0] : null;\n }\n \n this.requestUpdate();\n } catch (error) {\n console.error('[SettingsView] Failed to refresh presets:', error);\n }\n };\n this._shortcutListener = (event, keybinds) => {\n console.log('[SettingsView] Received updated shortcuts:', keybinds);\n this.shortcuts = keybinds;\n };\n \n window.api.settingsView.onUserStateChanged(this._userStateListener);\n window.api.settingsView.onSettingsUpdated(this._settingsUpdatedListener);\n window.api.settingsView.onPresetsUpdated(this._presetsUpdatedListener);\n window.api.settingsView.onShortcutsUpdated(this._shortcutListener);\n }\n\n cleanupIpcListeners() {\n if (!window.api) return;\n \n if (this._userStateListener) {\n window.api.settingsView.removeOnUserStateChanged(this._userStateListener);\n }\n if (this._settingsUpdatedListener) {\n window.api.settingsView.removeOnSettingsUpdated(this._settingsUpdatedListener);\n }\n if (this._presetsUpdatedListener) {\n window.api.settingsView.removeOnPresetsUpdated(this._presetsUpdatedListener);\n }\n if (this._shortcutListener) {\n window.api.settingsView.removeOnShortcutsUpdated(this._shortcutListener);\n }\n }\n\n setupWindowResize() {\n this.resizeHandler = () => {\n this.requestUpdate();\n this.updateScrollHeight();\n };\n window.addEventListener('resize', this.resizeHandler);\n \n // Initial setup\n setTimeout(() => this.updateScrollHeight(), 100);\n }\n\n cleanupWindowResize() {\n if (this.resizeHandler) {\n window.removeEventListener('resize', this.resizeHandler);\n }\n }\n\n updateScrollHeight() {\n // Electron 일부 시점에서 window.innerHeight 가 0 으로 보고되는 버그 보호\n const rawHeight = window.innerHeight || (window.screen ? window.screen.height : 0);\n const MIN_HEIGHT = 300; // 최소 보장 높이\n const maxHeight = Math.max(MIN_HEIGHT, rawHeight);\n\n this.style.maxHeight = `${maxHeight}px`;\n\n const container = this.shadowRoot?.querySelector('.settings-container');\n if (container) {\n container.style.maxHeight = `${maxHeight}px`;\n }\n }\n\n handleMouseEnter = () => {\n window.api.settingsView.cancelHideSettingsWindow();\n // Recalculate height in case it was set to 0 before\n this.updateScrollHeight();\n }\n\n handleMouseLeave = () => {\n window.api.settingsView.hideSettingsWindow();\n }\n\n\n getMainShortcuts() {\n return [\n { name: 'Show / Hide', accelerator: this.shortcuts.toggleVisibility },\n { name: 'Ask Anything', accelerator: this.shortcuts.nextStep },\n { name: 'Scroll Up Response', accelerator: this.shortcuts.scrollUp },\n { name: 'Scroll Down Response', accelerator: this.shortcuts.scrollDown },\n ];\n }\n\n renderShortcutKeys(accelerator) {\n if (!accelerator) return html`N/A`;\n \n const keyMap = {\n 'Cmd': '⌘', 'Command': '⌘', 'Ctrl': '⌃', 'Alt': '⌥', 'Shift': '⇧', 'Enter': '↵',\n 'Up': '↑', 'Down': '↓', 'Left': '←', 'Right': '→'\n };\n\n // scrollDown/scrollUp의 특수 처리\n if (accelerator.includes('↕')) {\n const keys = accelerator.replace('↕','').split('+');\n keys.push('↕');\n return html`${keys.map(key => html`${keyMap[key] || key}`)}`;\n }\n\n const keys = accelerator.split('+');\n return html`${keys.map(key => html`${keyMap[key] || key}`)}`;\n }\n\n togglePresets() {\n this.showPresets = !this.showPresets;\n }\n\n async handlePresetSelect(preset) {\n this.selectedPreset = preset;\n // Here you could implement preset application logic\n console.log('Selected preset:', preset);\n }\n\n handleMoveLeft() {\n console.log('Move Left clicked');\n window.api.settingsView.moveWindowStep('left');\n }\n\n handleMoveRight() {\n console.log('Move Right clicked');\n window.api.settingsView.moveWindowStep('right');\n }\n\n async handlePersonalize() {\n console.log('Personalize clicked');\n try {\n await window.api.settingsView.openPersonalizePage();\n } catch (error) {\n console.error('Failed to open personalize page:', error);\n }\n }\n\n async handleToggleInvisibility() {\n console.log('Toggle Invisibility clicked');\n this.isContentProtectionOn = await window.api.settingsView.toggleContentProtection();\n this.requestUpdate();\n }\n\n async handleSaveApiKey() {\n const input = this.shadowRoot.getElementById('api-key-input');\n if (!input || !input.value) return;\n\n const newApiKey = input.value;\n try {\n const result = await window.api.settingsView.saveApiKey(newApiKey);\n if (result.success) {\n console.log('API Key saved successfully via IPC.');\n this.apiKey = newApiKey;\n this.requestUpdate();\n } else {\n console.error('Failed to save API Key via IPC:', result.error);\n }\n } catch(e) {\n console.error('Error invoking save-api-key IPC:', e);\n }\n }\n\n handleQuit() {\n console.log('Quit clicked');\n window.api.settingsView.quitApplication();\n }\n\n handleFirebaseLogout() {\n console.log('Firebase Logout clicked');\n window.api.settingsView.firebaseLogout();\n }\n\n async handleOllamaShutdown() {\n console.log('[SettingsView] Shutting down Ollama service...');\n \n if (!window.api) return;\n \n try {\n // Show loading state\n this.ollamaStatus = { ...this.ollamaStatus, running: false };\n this.requestUpdate();\n \n const result = await window.api.settingsView.shutdownOllama(false); // Graceful shutdown\n \n if (result.success) {\n console.log('[SettingsView] Ollama shut down successfully');\n // Refresh status to reflect the change\n await this.refreshOllamaStatus();\n } else {\n console.error('[SettingsView] Failed to shutdown Ollama:', result.error);\n // Restore previous state on error\n await this.refreshOllamaStatus();\n }\n } catch (error) {\n console.error('[SettingsView] Error during Ollama shutdown:', error);\n // Restore previous state on error\n await this.refreshOllamaStatus();\n }\n }\n\n //////// after_modelStateService ////////\n render() {\n if (this.isLoading) {\n return html`\n
\n
\n
\n Loading...\n
\n
\n `;\n }\n\n const loggedIn = !!this.firebaseUser;\n\n const apiKeyManagementHTML = html`\n
\n ${Object.entries(this.providerConfig)\n .filter(([id, config]) => !id.includes('-glass'))\n .map(([id, config]) => {\n if (id === 'ollama') {\n // Special UI for Ollama\n return html`\n
\n \n ${this.ollamaStatus.installed && this.ollamaStatus.running ? html`\n
\n ✓ Ollama is running\n
\n \n ` : this.ollamaStatus.installed ? html`\n
\n ⚠ Ollama installed but not running\n
\n \n ` : html`\n
\n ✗ Ollama not installed\n
\n \n `}\n
\n `;\n }\n \n if (id === 'whisper') {\n // Simplified UI for Whisper without model selection\n return html`\n
\n \n ${this.apiKeys[id] === 'local' ? html`\n
\n ✓ Whisper is enabled\n
\n \n ` : html`\n \n `}\n
\n `;\n }\n \n // Regular providers\n return html`\n
\n \n \n
\n \n \n
\n
\n `;\n })}\n
\n `;\n \n const getModelName = (type, id) => {\n const models = type === 'llm' ? this.availableLlmModels : this.availableSttModels;\n const model = models.find(m => m.id === id);\n return model ? model.name : id;\n }\n\n const modelSelectionHTML = html`\n
\n
\n \n \n ${this.isLlmListVisible ? html`\n
\n ${this.availableLlmModels.map(model => {\n const isOllama = this.getProviderForModel('llm', model.id) === 'ollama';\n const ollamaModel = isOllama ? this.ollamaModels.find(m => m.name === model.id) : null;\n const isInstalling = this.installingModels[model.id] !== undefined;\n const installProgress = this.installingModels[model.id] || 0;\n \n return html`\n
this.selectModel('llm', model.id)}>\n ${model.name}\n ${isOllama ? html`\n ${isInstalling ? html`\n
\n
\n
\n ` : ollamaModel?.installed ? html`\n ✓ Installed\n ` : html`\n Click to install\n `}\n ` : ''}\n
\n `;\n })}\n
\n ` : ''}\n
\n
\n \n \n ${this.isSttListVisible ? html`\n
\n ${this.availableSttModels.map(model => {\n const isWhisper = this.getProviderForModel('stt', model.id) === 'whisper';\n const whisperModel = isWhisper && this.providerConfig?.whisper?.sttModels \n ? this.providerConfig.whisper.sttModels.find(m => m.id === model.id) \n : null;\n const isInstalling = this.installingModels[model.id] !== undefined;\n const installProgress = this.installingModels[model.id] || 0;\n \n return html`\n
this.selectModel('stt', model.id)}>\n ${model.name}\n ${isWhisper ? html`\n ${isInstalling ? html`\n
\n
\n
\n ` : whisperModel?.installed ? html`\n ✓ Installed\n ` : html`\n Not Installed\n `}\n ` : ''}\n
\n `;\n })}\n
\n ` : ''}\n
\n
\n `;\n\n return html`\n
\n
\n
\n

Pickle Glass

\n
\n ${this.firebaseUser\n ? html`Account: ${this.firebaseUser.email || 'Logged In'}`\n : `Account: Not Logged In`\n }\n
\n
\n
\n \n \n \n
\n
\n\n ${apiKeyManagementHTML}\n ${modelSelectionHTML}\n\n
\n \n
\n\n \n
\n ${this.getMainShortcuts().map(shortcut => html`\n
\n ${shortcut.name}\n
\n ${this.renderShortcutKeys(shortcut.accelerator)}\n
\n
\n `)}\n
\n\n
\n
\n \n My Presets\n (${this.presets.filter(p => p.is_default === 0).length})\n \n \n ${this.showPresets ? '▼' : '▶'}\n \n
\n \n
\n ${this.presets.filter(p => p.is_default === 0).length === 0 ? html`\n
\n No custom presets yet.
\n \n Create your first preset\n \n
\n ` : this.presets.filter(p => p.is_default === 0).map(preset => html`\n
this.handlePresetSelect(preset)}>\n ${preset.title}\n ${this.selectedPreset?.id === preset.id ? html`Selected` : ''}\n
\n `)}\n
\n
\n\n
\n \n \n \n
\n \n \n
\n \n \n \n
\n ${this.firebaseUser\n ? html`\n \n `\n : html`\n \n `\n }\n \n
\n
\n
\n `;\n }\n //////// after_modelStateService ////////\n}\n\ncustomElements.define('settings-view', SettingsView);"], ["/glass/src/features/ask/repositories/sqlite.repository.js", "const sqliteClient = require('../../common/services/sqliteClient');\n\nfunction addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n // uid is ignored in the SQLite implementation\n const db = sqliteClient.getDb();\n const messageId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO ai_messages (id, session_id, sent_at, role, content, model, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(messageId, sessionId, now, role, content, model, now);\n return { id: messageId };\n } catch (err) {\n console.error('SQLite: Failed to add AI message:', err);\n throw err;\n }\n}\n\nfunction getAllAiMessagesBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM ai_messages WHERE session_id = ? ORDER BY sent_at ASC\";\n return db.prepare(query).all(sessionId);\n}\n\nmodule.exports = {\n addAiMessage,\n getAllAiMessagesBySessionId\n}; "], ["/glass/src/features/listen/stt/repositories/sqlite.repository.js", "const sqliteClient = require('../../../common/services/sqliteClient');\n\nfunction addTranscript({ uid, sessionId, speaker, text }) {\n // uid is ignored in the SQLite implementation\n const db = sqliteClient.getDb();\n const transcriptId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO transcripts (id, session_id, start_at, speaker, text, created_at) VALUES (?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(transcriptId, sessionId, now, speaker, text, now);\n return { id: transcriptId };\n } catch (err) {\n console.error('Error adding transcript:', err);\n throw err;\n }\n}\n\nfunction getAllTranscriptsBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM transcripts WHERE session_id = ? ORDER BY start_at ASC\";\n return db.prepare(query).all(sessionId);\n}\n\nmodule.exports = {\n addTranscript,\n getAllTranscriptsBySessionId,\n}; "], ["/glass/src/index.js", "// try {\n// const reloader = require('electron-reloader');\n// reloader(module, {\n// });\n// } catch (err) {\n// }\n\nrequire('dotenv').config();\n\nif (require('electron-squirrel-startup')) {\n process.exit(0);\n}\n\nconst { app, BrowserWindow, shell, ipcMain, dialog, desktopCapturer, session } = require('electron');\nconst { createWindows } = require('./window/windowManager.js');\nconst listenService = require('./features/listen/listenService');\nconst { initializeFirebase } = require('./features/common/services/firebaseClient');\nconst databaseInitializer = require('./features/common/services/databaseInitializer');\nconst authService = require('./features/common/services/authService');\nconst path = require('node:path');\nconst express = require('express');\nconst fetch = require('node-fetch');\nconst { autoUpdater } = require('electron-updater');\nconst { EventEmitter } = require('events');\nconst askService = require('./features/ask/askService');\nconst settingsService = require('./features/settings/settingsService');\nconst sessionRepository = require('./features/common/repositories/session');\nconst modelStateService = require('./features/common/services/modelStateService');\nconst featureBridge = require('./bridge/featureBridge');\nconst windowBridge = require('./bridge/windowBridge');\n\n// Global variables\nconst eventBridge = new EventEmitter();\nlet WEB_PORT = 3000;\nlet isShuttingDown = false; // Flag to prevent infinite shutdown loop\n\n//////// after_modelStateService ////////\nglobal.modelStateService = modelStateService;\n//////// after_modelStateService ////////\n\n// Import and initialize OllamaService\nconst ollamaService = require('./features/common/services/ollamaService');\nconst ollamaModelRepository = require('./features/common/repositories/ollamaModel');\n\n// Native deep link handling - cross-platform compatible\nlet pendingDeepLinkUrl = null;\n\nfunction setupProtocolHandling() {\n // Protocol registration - must be done before app is ready\n try {\n if (!app.isDefaultProtocolClient('pickleglass')) {\n const success = app.setAsDefaultProtocolClient('pickleglass');\n if (success) {\n console.log('[Protocol] Successfully set as default protocol client for pickleglass://');\n } else {\n console.warn('[Protocol] Failed to set as default protocol client - this may affect deep linking');\n }\n } else {\n console.log('[Protocol] Already registered as default protocol client for pickleglass://');\n }\n } catch (error) {\n console.error('[Protocol] Error during protocol registration:', error);\n }\n\n // Handle protocol URLs on Windows/Linux\n app.on('second-instance', (event, commandLine, workingDirectory) => {\n console.log('[Protocol] Second instance command line:', commandLine);\n \n focusMainWindow();\n \n let protocolUrl = null;\n \n // Search through all command line arguments for a valid protocol URL\n for (const arg of commandLine) {\n if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {\n // Clean up the URL by removing problematic characters\n const cleanUrl = arg.replace(/[\\\\₩]/g, '');\n \n // Additional validation for Windows\n if (process.platform === 'win32') {\n // On Windows, ensure the URL doesn't contain file path indicators\n if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {\n protocolUrl = cleanUrl;\n break;\n }\n } else {\n protocolUrl = cleanUrl;\n break;\n }\n }\n }\n \n if (protocolUrl) {\n console.log('[Protocol] Valid URL found from second instance:', protocolUrl);\n handleCustomUrl(protocolUrl);\n } else {\n console.log('[Protocol] No valid protocol URL found in command line arguments');\n console.log('[Protocol] Command line args:', commandLine);\n }\n });\n\n // Handle protocol URLs on macOS\n app.on('open-url', (event, url) => {\n event.preventDefault();\n console.log('[Protocol] Received URL via open-url:', url);\n \n if (!url || !url.startsWith('pickleglass://')) {\n console.warn('[Protocol] Invalid URL format:', url);\n return;\n }\n\n if (app.isReady()) {\n handleCustomUrl(url);\n } else {\n pendingDeepLinkUrl = url;\n console.log('[Protocol] App not ready, storing URL for later');\n }\n });\n}\n\nfunction focusMainWindow() {\n const { windowPool } = require('./window/windowManager.js');\n if (windowPool) {\n const header = windowPool.get('header');\n if (header && !header.isDestroyed()) {\n if (header.isMinimized()) header.restore();\n header.focus();\n return true;\n }\n }\n \n // Fallback: focus any available window\n const windows = BrowserWindow.getAllWindows();\n if (windows.length > 0) {\n const mainWindow = windows[0];\n if (!mainWindow.isDestroyed()) {\n if (mainWindow.isMinimized()) mainWindow.restore();\n mainWindow.focus();\n return true;\n }\n }\n \n return false;\n}\n\nif (process.platform === 'win32') {\n for (const arg of process.argv) {\n if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {\n // Clean up the URL by removing problematic characters (korean characters issue...)\n const cleanUrl = arg.replace(/[\\\\₩]/g, '');\n \n if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {\n console.log('[Protocol] Found protocol URL in initial arguments:', cleanUrl);\n pendingDeepLinkUrl = cleanUrl;\n break;\n }\n }\n }\n \n console.log('[Protocol] Initial process.argv:', process.argv);\n}\n\nconst gotTheLock = app.requestSingleInstanceLock();\nif (!gotTheLock) {\n app.quit();\n process.exit(0);\n}\n\n// setup protocol after single instance lock\nsetupProtocolHandling();\n\napp.whenReady().then(async () => {\n\n // Setup native loopback audio capture for Windows\n session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {\n desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {\n // Grant access to the first screen found with loopback audio\n callback({ video: sources[0], audio: 'loopback' });\n }).catch((error) => {\n console.error('Failed to get desktop capturer sources:', error);\n callback({});\n });\n });\n\n // Initialize core services\n initializeFirebase();\n \n try {\n await databaseInitializer.initialize();\n console.log('>>> [index.js] Database initialized successfully');\n \n // Clean up zombie sessions from previous runs first - MOVED TO authService\n // sessionRepository.endAllActiveSessions();\n\n await authService.initialize();\n\n //////// after_modelStateService ////////\n await modelStateService.initialize();\n //////// after_modelStateService ////////\n\n featureBridge.initialize(); // 추가: featureBridge 초기화\n windowBridge.initialize();\n setupWebDataHandlers();\n\n // Initialize Ollama models in database\n await ollamaModelRepository.initializeDefaultModels();\n\n // Auto warm-up selected Ollama model in background (non-blocking)\n setTimeout(async () => {\n try {\n console.log('[index.js] Starting background Ollama model warm-up...');\n await ollamaService.autoWarmUpSelectedModel();\n } catch (error) {\n console.log('[index.js] Background warm-up failed (non-critical):', error.message);\n }\n }, 2000); // Wait 2 seconds after app start\n\n // Start web server and create windows ONLY after all initializations are successful\n WEB_PORT = await startWebStack();\n console.log('Web front-end listening on', WEB_PORT);\n \n createWindows();\n\n } catch (err) {\n console.error('>>> [index.js] Database initialization failed - some features may not work', err);\n // Optionally, show an error dialog to the user\n dialog.showErrorBox(\n 'Application Error',\n 'A critical error occurred during startup. Some features might be disabled. Please restart the application.'\n );\n }\n\n // initAutoUpdater should be called after auth is initialized\n initAutoUpdater();\n\n // Process any pending deep link after everything is initialized\n if (pendingDeepLinkUrl) {\n console.log('[Protocol] Processing pending URL:', pendingDeepLinkUrl);\n handleCustomUrl(pendingDeepLinkUrl);\n pendingDeepLinkUrl = null;\n }\n});\n\napp.on('before-quit', async (event) => {\n // Prevent infinite loop by checking if shutdown is already in progress\n if (isShuttingDown) {\n console.log('[Shutdown] 🔄 Shutdown already in progress, allowing quit...');\n return;\n }\n \n console.log('[Shutdown] App is about to quit. Starting graceful shutdown...');\n \n // Set shutdown flag to prevent infinite loop\n isShuttingDown = true;\n \n // Prevent immediate quit to allow graceful shutdown\n event.preventDefault();\n \n try {\n // 1. Stop audio capture first (immediate)\n await listenService.closeSession();\n console.log('[Shutdown] Audio capture stopped');\n \n // 2. End all active sessions (database operations) - with error handling\n try {\n await sessionRepository.endAllActiveSessions();\n console.log('[Shutdown] Active sessions ended');\n } catch (dbError) {\n console.warn('[Shutdown] Could not end active sessions (database may be closed):', dbError.message);\n }\n \n // 3. Shutdown Ollama service (potentially time-consuming)\n console.log('[Shutdown] shutting down Ollama service...');\n const ollamaShutdownSuccess = await Promise.race([\n ollamaService.shutdown(false), // Graceful shutdown\n new Promise(resolve => setTimeout(() => resolve(false), 8000)) // 8s timeout\n ]);\n \n if (ollamaShutdownSuccess) {\n console.log('[Shutdown] Ollama service shut down gracefully');\n } else {\n console.log('[Shutdown] Ollama shutdown timeout, forcing...');\n // Force shutdown if graceful failed\n try {\n await ollamaService.shutdown(true);\n } catch (forceShutdownError) {\n console.warn('[Shutdown] Force shutdown also failed:', forceShutdownError.message);\n }\n }\n \n // 4. Close database connections (final cleanup)\n try {\n databaseInitializer.close();\n console.log('[Shutdown] Database connections closed');\n } catch (closeError) {\n console.warn('[Shutdown] Error closing database:', closeError.message);\n }\n \n console.log('[Shutdown] Graceful shutdown completed successfully');\n \n } catch (error) {\n console.error('[Shutdown] Error during graceful shutdown:', error);\n // Continue with shutdown even if there were errors\n } finally {\n // Actually quit the app now\n console.log('[Shutdown] Exiting application...');\n app.exit(0); // Use app.exit() instead of app.quit() to force quit\n }\n});\n\napp.on('activate', () => {\n if (BrowserWindow.getAllWindows().length === 0) {\n createWindows();\n }\n});\n\nfunction setupWebDataHandlers() {\n const sessionRepository = require('./features/common/repositories/session');\n const sttRepository = require('./features/listen/stt/repositories');\n const summaryRepository = require('./features/listen/summary/repositories');\n const askRepository = require('./features/ask/repositories');\n const userRepository = require('./features/common/repositories/user');\n const presetRepository = require('./features/common/repositories/preset');\n\n const handleRequest = async (channel, responseChannel, payload) => {\n let result;\n // const currentUserId = authService.getCurrentUserId(); // No longer needed here\n try {\n switch (channel) {\n // SESSION\n case 'get-sessions':\n // Adapter injects UID\n result = await sessionRepository.getAllByUserId();\n break;\n case 'get-session-details':\n const session = await sessionRepository.getById(payload);\n if (!session) {\n result = null;\n break;\n }\n const [transcripts, ai_messages, summary] = await Promise.all([\n sttRepository.getAllTranscriptsBySessionId(payload),\n askRepository.getAllAiMessagesBySessionId(payload),\n summaryRepository.getSummaryBySessionId(payload)\n ]);\n result = { session, transcripts, ai_messages, summary };\n break;\n case 'delete-session':\n result = await sessionRepository.deleteWithRelatedData(payload);\n break;\n case 'create-session':\n // Adapter injects UID\n const id = await sessionRepository.create('ask');\n if (payload && payload.title) {\n await sessionRepository.updateTitle(id, payload.title);\n }\n result = { id };\n break;\n \n // USER\n case 'get-user-profile':\n // Adapter injects UID\n result = await userRepository.getById();\n break;\n case 'update-user-profile':\n // Adapter injects UID\n result = await userRepository.update(payload);\n break;\n case 'find-or-create-user':\n result = await userRepository.findOrCreate(payload);\n break;\n case 'save-api-key':\n // Use ModelStateService as the single source of truth for API key management\n result = await modelStateService.setApiKey(payload.provider, payload.apiKey);\n break;\n case 'check-api-key-status':\n // Use ModelStateService to check API key status\n const hasApiKey = await modelStateService.hasValidApiKey();\n result = { hasApiKey };\n break;\n case 'delete-account':\n // Adapter injects UID\n result = await userRepository.deleteById();\n break;\n\n // PRESET\n case 'get-presets':\n // Adapter injects UID\n result = await presetRepository.getPresets();\n break;\n case 'create-preset':\n // Adapter injects UID\n result = await presetRepository.create(payload);\n settingsService.notifyPresetUpdate('created', result.id, payload.title);\n break;\n case 'update-preset':\n // Adapter injects UID\n result = await presetRepository.update(payload.id, payload.data);\n settingsService.notifyPresetUpdate('updated', payload.id, payload.data.title);\n break;\n case 'delete-preset':\n // Adapter injects UID\n result = await presetRepository.delete(payload);\n settingsService.notifyPresetUpdate('deleted', payload);\n break;\n \n // BATCH\n case 'get-batch-data':\n const includes = payload ? payload.split(',').map(item => item.trim()) : ['profile', 'presets', 'sessions'];\n const promises = {};\n \n if (includes.includes('profile')) {\n // Adapter injects UID\n promises.profile = userRepository.getById();\n }\n if (includes.includes('presets')) {\n // Adapter injects UID\n promises.presets = presetRepository.getPresets();\n }\n if (includes.includes('sessions')) {\n // Adapter injects UID\n promises.sessions = sessionRepository.getAllByUserId();\n }\n \n const batchResult = {};\n const promiseResults = await Promise.all(Object.values(promises));\n Object.keys(promises).forEach((key, index) => {\n batchResult[key] = promiseResults[index];\n });\n\n result = batchResult;\n break;\n\n default:\n throw new Error(`Unknown web data channel: ${channel}`);\n }\n eventBridge.emit(responseChannel, { success: true, data: result });\n } catch (error) {\n console.error(`Error handling web data request for ${channel}:`, error);\n eventBridge.emit(responseChannel, { success: false, error: error.message });\n }\n };\n \n eventBridge.on('web-data-request', handleRequest);\n}\n\nasync function handleCustomUrl(url) {\n try {\n console.log('[Custom URL] Processing URL:', url);\n \n // Validate and clean URL\n if (!url || typeof url !== 'string' || !url.startsWith('pickleglass://')) {\n console.error('[Custom URL] Invalid URL format:', url);\n return;\n }\n \n // Clean up URL by removing problematic characters\n const cleanUrl = url.replace(/[\\\\₩]/g, '');\n \n // Additional validation\n if (cleanUrl !== url) {\n console.log('[Custom URL] Cleaned URL from:', url, 'to:', cleanUrl);\n url = cleanUrl;\n }\n \n const urlObj = new URL(url);\n const action = urlObj.hostname;\n const params = Object.fromEntries(urlObj.searchParams);\n \n console.log('[Custom URL] Action:', action, 'Params:', params);\n\n switch (action) {\n case 'login':\n case 'auth-success':\n await handleFirebaseAuthCallback(params);\n break;\n case 'personalize':\n handlePersonalizeFromUrl(params);\n break;\n default:\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n \n const targetUrl = `http://localhost:${WEB_PORT}/${action}`;\n console.log(`[Custom URL] Navigating webview to: ${targetUrl}`);\n header.webContents.loadURL(targetUrl);\n }\n }\n\n } catch (error) {\n console.error('[Custom URL] Error parsing URL:', error);\n }\n}\n\nasync function handleFirebaseAuthCallback(params) {\n const userRepository = require('./features/common/repositories/user');\n const { token: idToken } = params;\n\n if (!idToken) {\n console.error('[Auth] Firebase auth callback is missing ID token.');\n // No need to send IPC, the UI won't transition without a successful auth state change.\n return;\n }\n\n console.log('[Auth] Received ID token from deep link, exchanging for custom token...');\n\n try {\n const functionUrl = 'https://us-west1-pickle-3651a.cloudfunctions.net/pickleGlassAuthCallback';\n const response = await fetch(functionUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ token: idToken })\n });\n\n const data = await response.json();\n\n if (!response.ok || !data.success) {\n throw new Error(data.error || 'Failed to exchange token.');\n }\n\n const { customToken, user } = data;\n console.log('[Auth] Successfully received custom token for user:', user.uid);\n\n const firebaseUser = {\n uid: user.uid,\n email: user.email || 'no-email@example.com',\n displayName: user.name || 'User',\n photoURL: user.picture\n };\n\n // 1. Sync user data to local DB\n userRepository.findOrCreate(firebaseUser);\n console.log('[Auth] User data synced with local DB.');\n\n // 2. Sign in using the authService in the main process\n await authService.signInWithCustomToken(customToken);\n console.log('[Auth] Main process sign-in initiated. Waiting for onAuthStateChanged...');\n\n // 3. Focus the app window\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n } else {\n console.error('[Auth] Header window not found after auth callback.');\n }\n \n } catch (error) {\n console.error('[Auth] Error during custom token exchange or sign-in:', error);\n // The UI will not change, and the user can try again.\n // Optionally, send a generic error event to the renderer.\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n header.webContents.send('auth-failed', { message: error.message });\n }\n }\n}\n\nfunction handlePersonalizeFromUrl(params) {\n console.log('[Custom URL] Personalize params:', params);\n \n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n \n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n \n const personalizeUrl = `http://localhost:${WEB_PORT}/settings`;\n console.log(`[Custom URL] Navigating to personalize page: ${personalizeUrl}`);\n header.webContents.loadURL(personalizeUrl);\n \n BrowserWindow.getAllWindows().forEach(win => {\n win.webContents.send('enter-personalize-mode', {\n message: 'Personalization mode activated',\n params: params\n });\n });\n } else {\n console.error('[Custom URL] Header window not found for personalize');\n }\n}\n\n\nasync function startWebStack() {\n console.log('NODE_ENV =', process.env.NODE_ENV); \n const isDev = !app.isPackaged;\n\n const getAvailablePort = () => {\n return new Promise((resolve, reject) => {\n const server = require('net').createServer();\n server.listen(0, (err) => {\n if (err) reject(err);\n const port = server.address().port;\n server.close(() => resolve(port));\n });\n });\n };\n\n const apiPort = await getAvailablePort();\n const frontendPort = await getAvailablePort();\n\n console.log(`🔧 Allocated ports: API=${apiPort}, Frontend=${frontendPort}`);\n\n process.env.pickleglass_API_PORT = apiPort.toString();\n process.env.pickleglass_API_URL = `http://localhost:${apiPort}`;\n process.env.pickleglass_WEB_PORT = frontendPort.toString();\n process.env.pickleglass_WEB_URL = `http://localhost:${frontendPort}`;\n\n console.log(`🌍 Environment variables set:`, {\n pickleglass_API_URL: process.env.pickleglass_API_URL,\n pickleglass_WEB_URL: process.env.pickleglass_WEB_URL\n });\n\n const createBackendApp = require('../pickleglass_web/backend_node');\n const nodeApi = createBackendApp(eventBridge);\n\n const staticDir = app.isPackaged\n ? path.join(process.resourcesPath, 'out')\n : path.join(__dirname, '..', 'pickleglass_web', 'out');\n\n const fs = require('fs');\n\n if (!fs.existsSync(staticDir)) {\n console.error(`============================================================`);\n console.error(`[ERROR] Frontend build directory not found!`);\n console.error(`Path: ${staticDir}`);\n console.error(`Please run 'npm run build' inside the 'pickleglass_web' directory first.`);\n console.error(`============================================================`);\n app.quit();\n return;\n }\n\n const runtimeConfig = {\n API_URL: `http://localhost:${apiPort}`,\n WEB_URL: `http://localhost:${frontendPort}`,\n timestamp: Date.now()\n };\n \n // 쓰기 가능한 임시 폴더에 런타임 설정 파일 생성\n const tempDir = app.getPath('temp');\n const configPath = path.join(tempDir, 'runtime-config.json');\n fs.writeFileSync(configPath, JSON.stringify(runtimeConfig, null, 2));\n console.log(`📝 Runtime config created in temp location: ${configPath}`);\n\n const frontSrv = express();\n \n // 프론트엔드에서 /runtime-config.json을 요청하면 임시 폴더의 파일을 제공\n frontSrv.get('/runtime-config.json', (req, res) => {\n res.sendFile(configPath);\n });\n\n frontSrv.use((req, res, next) => {\n if (req.path.indexOf('.') === -1 && req.path !== '/') {\n const htmlPath = path.join(staticDir, req.path + '.html');\n if (fs.existsSync(htmlPath)) {\n return res.sendFile(htmlPath);\n }\n }\n next();\n });\n \n frontSrv.use(express.static(staticDir));\n \n const frontendServer = await new Promise((resolve, reject) => {\n const server = frontSrv.listen(frontendPort, '127.0.0.1', () => resolve(server));\n server.on('error', reject);\n app.once('before-quit', () => server.close());\n });\n\n console.log(`✅ Frontend server started on http://localhost:${frontendPort}`);\n\n const apiSrv = express();\n apiSrv.use(nodeApi);\n\n const apiServer = await new Promise((resolve, reject) => {\n const server = apiSrv.listen(apiPort, '127.0.0.1', () => resolve(server));\n server.on('error', reject);\n app.once('before-quit', () => server.close());\n });\n\n console.log(`✅ API server started on http://localhost:${apiPort}`);\n\n console.log(`🚀 All services ready:\n Frontend: http://localhost:${frontendPort}\n API: http://localhost:${apiPort}`);\n\n return frontendPort;\n}\n\n// Auto-update initialization\nasync function initAutoUpdater() {\n if (process.env.NODE_ENV === 'development') {\n console.log('Development environment, skipping auto-updater.');\n return;\n }\n\n try {\n await autoUpdater.checkForUpdates();\n autoUpdater.on('update-available', () => {\n console.log('Update available!');\n autoUpdater.downloadUpdate();\n });\n autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, date, url) => {\n console.log('Update downloaded:', releaseNotes, releaseName, date, url);\n dialog.showMessageBox({\n type: 'info',\n title: 'Application Update',\n message: `A new version of PickleGlass (${releaseName}) has been downloaded. It will be installed the next time you launch the application.`,\n buttons: ['Restart', 'Later']\n }).then(response => {\n if (response.response === 0) {\n autoUpdater.quitAndInstall();\n }\n });\n });\n autoUpdater.on('error', (err) => {\n console.error('Error in auto-updater:', err);\n });\n } catch (err) {\n console.error('Error initializing auto-updater:', err);\n }\n}"], ["/glass/src/features/listen/summary/summaryService.js", "const { BrowserWindow } = require('electron');\nconst { getSystemPrompt } = require('../../common/prompts/promptBuilder.js');\nconst { createLLM } = require('../../common/ai/factory');\nconst sessionRepository = require('../../common/repositories/session');\nconst summaryRepository = require('./repositories');\nconst modelStateService = require('../../common/services/modelStateService');\n\nclass SummaryService {\n constructor() {\n this.previousAnalysisResult = null;\n this.analysisHistory = [];\n this.conversationHistory = [];\n this.currentSessionId = null;\n \n // Callbacks\n this.onAnalysisComplete = null;\n this.onStatusUpdate = null;\n }\n\n setCallbacks({ onAnalysisComplete, onStatusUpdate }) {\n this.onAnalysisComplete = onAnalysisComplete;\n this.onStatusUpdate = onStatusUpdate;\n }\n\n setSessionId(sessionId) {\n this.currentSessionId = sessionId;\n }\n\n sendToRenderer(channel, data) {\n const { windowPool } = require('../../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n addConversationTurn(speaker, text) {\n const conversationText = `${speaker.toLowerCase()}: ${text.trim()}`;\n this.conversationHistory.push(conversationText);\n console.log(`💬 Added conversation text: ${conversationText}`);\n console.log(`📈 Total conversation history: ${this.conversationHistory.length} texts`);\n\n // Trigger analysis if needed\n this.triggerAnalysisIfNeeded();\n }\n\n getConversationHistory() {\n return this.conversationHistory;\n }\n\n resetConversationHistory() {\n this.conversationHistory = [];\n this.previousAnalysisResult = null;\n this.analysisHistory = [];\n console.log('🔄 Conversation history and analysis state reset');\n }\n\n /**\n * Converts conversation history into text to include in the prompt.\n * @param {Array} conversationTexts - Array of conversation texts [\"me: ~~~\", \"them: ~~~\", ...]\n * @param {number} maxTurns - Maximum number of recent turns to include\n * @returns {string} - Formatted conversation string for the prompt\n */\n formatConversationForPrompt(conversationTexts, maxTurns = 30) {\n if (conversationTexts.length === 0) return '';\n return conversationTexts.slice(-maxTurns).join('\\n');\n }\n\n async makeOutlineAndRequests(conversationTexts, maxTurns = 30) {\n console.log(`🔍 makeOutlineAndRequests called - conversationTexts: ${conversationTexts.length}`);\n\n if (conversationTexts.length === 0) {\n console.log('⚠️ No conversation texts available for analysis');\n return null;\n }\n\n const recentConversation = this.formatConversationForPrompt(conversationTexts, maxTurns);\n\n // 이전 분석 결과를 프롬프트에 포함\n let contextualPrompt = '';\n if (this.previousAnalysisResult) {\n contextualPrompt = `\nPrevious Analysis Context:\n- Main Topic: ${this.previousAnalysisResult.topic.header}\n- Key Points: ${this.previousAnalysisResult.summary.slice(0, 3).join(', ')}\n- Last Actions: ${this.previousAnalysisResult.actions.slice(0, 2).join(', ')}\n\nPlease build upon this context while analyzing the new conversation segments.\n`;\n }\n\n const basePrompt = getSystemPrompt('pickle_glass_analysis', '', false);\n const systemPrompt = basePrompt.replace('{{CONVERSATION_HISTORY}}', recentConversation);\n\n try {\n if (this.currentSessionId) {\n await sessionRepository.touch(this.currentSessionId);\n }\n\n const modelInfo = await modelStateService.getCurrentModelInfo('llm');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key is not configured.');\n }\n console.log(`🤖 Sending analysis request to ${modelInfo.provider} using model ${modelInfo.model}`);\n \n const messages = [\n {\n role: 'system',\n content: systemPrompt,\n },\n {\n role: 'user',\n content: `${contextualPrompt}\n\nAnalyze the conversation and provide a structured summary. Format your response as follows:\n\n**Summary Overview**\n- Main discussion point with context\n\n**Key Topic: [Topic Name]**\n- First key insight\n- Second key insight\n- Third key insight\n\n**Extended Explanation**\nProvide 2-3 sentences explaining the context and implications.\n\n**Suggested Questions**\n1. First follow-up question?\n2. Second follow-up question?\n3. Third follow-up question?\n\nKeep all points concise and build upon previous analysis if provided.`,\n },\n ];\n\n console.log('🤖 Sending analysis request to AI...');\n\n const llm = createLLM(modelInfo.provider, {\n apiKey: modelInfo.apiKey,\n model: modelInfo.model,\n temperature: 0.7,\n maxTokens: 1024,\n usePortkey: modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: modelInfo.provider === 'openai-glass' ? modelInfo.apiKey : undefined,\n });\n\n const completion = await llm.chat(messages);\n\n const responseText = completion.content;\n console.log(`✅ Analysis response received: ${responseText}`);\n const structuredData = this.parseResponseText(responseText, this.previousAnalysisResult);\n\n if (this.currentSessionId) {\n try {\n summaryRepository.saveSummary({\n sessionId: this.currentSessionId,\n text: responseText,\n tldr: structuredData.summary.join('\\n'),\n bullet_json: JSON.stringify(structuredData.topic.bullets),\n action_json: JSON.stringify(structuredData.actions),\n model: modelInfo.model\n });\n } catch (err) {\n console.error('[DB] Failed to save summary:', err);\n }\n }\n\n // 분석 결과 저장\n this.previousAnalysisResult = structuredData;\n this.analysisHistory.push({\n timestamp: Date.now(),\n data: structuredData,\n conversationLength: conversationTexts.length,\n });\n\n if (this.analysisHistory.length > 10) {\n this.analysisHistory.shift();\n }\n\n return structuredData;\n } catch (error) {\n console.error('❌ Error during analysis generation:', error.message);\n return this.previousAnalysisResult; // 에러 시 이전 결과 반환\n }\n }\n\n parseResponseText(responseText, previousResult) {\n const structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: ['✉️ Draft a follow-up email', '✅ Generate action items', '📝 Show summary'],\n };\n\n // 이전 결과가 있으면 기본값으로 사용\n if (previousResult) {\n structuredData.topic.header = previousResult.topic.header;\n structuredData.summary = [...previousResult.summary];\n }\n\n try {\n const lines = responseText.split('\\n');\n let currentSection = '';\n let isCapturingTopic = false;\n let topicName = '';\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n // 섹션 헤더 감지\n if (trimmedLine.startsWith('**Summary Overview**')) {\n currentSection = 'summary-overview';\n continue;\n } else if (trimmedLine.startsWith('**Key Topic:')) {\n currentSection = 'topic';\n isCapturingTopic = true;\n topicName = trimmedLine.match(/\\*\\*Key Topic: (.+?)\\*\\*/)?.[1] || '';\n if (topicName) {\n structuredData.topic.header = topicName + ':';\n }\n continue;\n } else if (trimmedLine.startsWith('**Extended Explanation**')) {\n currentSection = 'explanation';\n continue;\n } else if (trimmedLine.startsWith('**Suggested Questions**')) {\n currentSection = 'questions';\n continue;\n }\n\n // 컨텐츠 파싱\n if (trimmedLine.startsWith('-') && currentSection === 'summary-overview') {\n const summaryPoint = trimmedLine.substring(1).trim();\n if (summaryPoint && !structuredData.summary.includes(summaryPoint)) {\n // 기존 summary 업데이트 (최대 5개 유지)\n structuredData.summary.unshift(summaryPoint);\n if (structuredData.summary.length > 5) {\n structuredData.summary.pop();\n }\n }\n } else if (trimmedLine.startsWith('-') && currentSection === 'topic') {\n const bullet = trimmedLine.substring(1).trim();\n if (bullet && structuredData.topic.bullets.length < 3) {\n structuredData.topic.bullets.push(bullet);\n }\n } else if (currentSection === 'explanation' && trimmedLine) {\n // explanation을 topic bullets에 추가 (문장 단위로)\n const sentences = trimmedLine\n .split(/\\.\\s+/)\n .filter(s => s.trim().length > 0)\n .map(s => s.trim() + (s.endsWith('.') ? '' : '.'));\n\n sentences.forEach(sentence => {\n if (structuredData.topic.bullets.length < 3 && !structuredData.topic.bullets.includes(sentence)) {\n structuredData.topic.bullets.push(sentence);\n }\n });\n } else if (trimmedLine.match(/^\\d+\\./) && currentSection === 'questions') {\n const question = trimmedLine.replace(/^\\d+\\.\\s*/, '').trim();\n if (question && question.includes('?')) {\n structuredData.actions.push(`❓ ${question}`);\n }\n }\n }\n\n // 기본 액션 추가\n const defaultActions = ['✨ What should I say next?', '💬 Suggest follow-up questions'];\n defaultActions.forEach(action => {\n if (!structuredData.actions.includes(action)) {\n structuredData.actions.push(action);\n }\n });\n\n // 액션 개수 제한\n structuredData.actions = structuredData.actions.slice(0, 5);\n\n // 유효성 검증 및 이전 데이터 병합\n if (structuredData.summary.length === 0 && previousResult) {\n structuredData.summary = previousResult.summary;\n }\n if (structuredData.topic.bullets.length === 0 && previousResult) {\n structuredData.topic.bullets = previousResult.topic.bullets;\n }\n } catch (error) {\n console.error('❌ Error parsing response text:', error);\n // 에러 시 이전 결과 반환\n return (\n previousResult || {\n summary: [],\n topic: { header: 'Analysis in progress', bullets: [] },\n actions: ['✨ What should I say next?', '💬 Suggest follow-up questions'],\n followUps: ['✉️ Draft a follow-up email', '✅ Generate action items', '📝 Show summary'],\n }\n );\n }\n\n console.log('📊 Final structured data:', JSON.stringify(structuredData, null, 2));\n return structuredData;\n }\n\n /**\n * Triggers analysis when conversation history reaches 5 texts.\n */\n async triggerAnalysisIfNeeded() {\n if (this.conversationHistory.length >= 5 && this.conversationHistory.length % 5 === 0) {\n console.log(`Triggering analysis - ${this.conversationHistory.length} conversation texts accumulated`);\n\n const data = await this.makeOutlineAndRequests(this.conversationHistory);\n if (data) {\n console.log('Sending structured data to renderer');\n this.sendToRenderer('summary-update', data);\n \n // Notify callback\n if (this.onAnalysisComplete) {\n this.onAnalysisComplete(data);\n }\n } else {\n console.log('No analysis data returned');\n }\n }\n }\n\n getCurrentAnalysisData() {\n return {\n previousResult: this.previousAnalysisResult,\n history: this.analysisHistory,\n conversationLength: this.conversationHistory.length,\n };\n }\n}\n\nmodule.exports = SummaryService; "], ["/glass/src/ui/settings/ShortCutSettingsView.js", "import { html, css, LitElement } from '../../ui/assets/lit-core-2.7.4.min.js';\n\nconst commonSystemShortcuts = new Set([\n 'Cmd+Q', 'Cmd+W', 'Cmd+A', 'Cmd+S', 'Cmd+Z', 'Cmd+X', 'Cmd+C', 'Cmd+V', 'Cmd+P', 'Cmd+F', 'Cmd+G', 'Cmd+H', 'Cmd+M', 'Cmd+N', 'Cmd+O', 'Cmd+T',\n 'Ctrl+Q', 'Ctrl+W', 'Ctrl+A', 'Ctrl+S', 'Ctrl+Z', 'Ctrl+X', 'Ctrl+C', 'Ctrl+V', 'Ctrl+P', 'Ctrl+F', 'Ctrl+G', 'Ctrl+H', 'Ctrl+M', 'Ctrl+N', 'Ctrl+O', 'Ctrl+T'\n]);\n\nconst displayNameMap = {\n nextStep: 'Ask Anything',\n moveUp: 'Move Up Window',\n moveDown: 'Move Down Window',\n scrollUp: 'Scroll Up Response',\n scrollDown: 'Scroll Down Response',\n };\n\nexport class ShortcutSettingsView extends LitElement {\n static styles = css`\n * { font-family:'Helvetica Neue',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;\n cursor:default; user-select:none; box-sizing:border-box; }\n\n :host { display:flex; width:100%; height:100%; color:white; }\n\n .container { display:flex; flex-direction:column; height:100%;\n background:rgba(20,20,20,.9); border-radius:12px;\n outline:.5px rgba(255,255,255,.2) solid; outline-offset:-1px;\n position:relative; overflow:hidden; padding:12px; }\n\n .close-button{position:absolute;top:10px;right:10px;inline-size:14px;block-size:14px;\n background:rgba(255,255,255,.1);border:none;border-radius:3px;\n color:rgba(255,255,255,.7);display:grid;place-items:center;\n font-size:14px;line-height:0;cursor:pointer;transition:.15s;z-index:10;}\n .close-button:hover{background:rgba(255,255,255,.2);color:rgba(255,255,255,.9);}\n\n .title{font-size:14px;font-weight:500;margin:0 0 8px;padding-bottom:8px;\n border-bottom:1px solid rgba(255,255,255,.1);text-align:center;}\n\n .scroll-area{flex:1 1 auto;overflow-y:auto;margin:0 -4px;padding:4px;}\n\n .shortcut-entry{display:flex;align-items:center;width:100%;gap:8px;\n margin-bottom:8px;font-size:12px;padding:4px;}\n .shortcut-name{flex:1 1 auto;color:rgba(255,255,255,.9);font-weight:300;\n white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}\n\n .action-btn{background:none;border:none;color:rgba(0,122,255,.8);\n font-size:11px;padding:0 4px;cursor:pointer;transition:.15s;}\n .action-btn:hover{color:#0a84ff;text-decoration:underline;}\n\n .shortcut-input{inline-size:120px;background:rgba(0,0,0,.2);\n border:1px solid rgba(255,255,255,.2);border-radius:4px;\n padding:4px 6px;font:11px 'SF Mono','Menlo',monospace;\n color:white;text-align:right;cursor:text;margin-left:auto;}\n .shortcut-input:focus,.shortcut-input.capturing{\n outline:none;border-color:rgba(0,122,255,.6);\n box-shadow:0 0 0 1px rgba(0,122,255,.3);}\n\n .feedback{font-size:10px;margin-top:2px;min-height:12px;}\n .feedback.error{color:#ef4444;}\n .feedback.success{color:#22c55e;}\n\n .actions{display:flex;gap:4px;padding-top:8px;border-top:1px solid rgba(255,255,255,.1);}\n .settings-button{flex:1;background:rgba(255,255,255,.1);\n border:1px solid rgba(255,255,255,.2);border-radius:4px;\n color:white;padding:5px 10px;font-size:11px;cursor:pointer;transition:.15s;}\n .settings-button:hover{background:rgba(255,255,255,.15);}\n .settings-button.primary{background:rgba(0,122,255,.25);border-color:rgba(0,122,255,.6);}\n .settings-button.primary:hover{background:rgba(0,122,255,.35);}\n .settings-button.danger{background:rgba(255,59,48,.1);border-color:rgba(255,59,48,.3);\n color:rgba(255,59,48,.9);}\n .settings-button.danger:hover{background:rgba(255,59,48,.15);\n }\n\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n :host-context(body.has-glass) * {\n background: transparent !important; /* 요청한 투명 처리 */\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n outline: none !important;\n border: none !important;\n border-radius: 0 !important;\n transition: none !important;\n animation: none !important;\n }\n `;\n\n static properties = {\n shortcuts: { type: Object, state: true },\n isLoading: { type: Boolean, state: true },\n capturingKey: { type: String, state: true },\n feedback: { type:Object, state:true }\n };\n\n constructor() {\n super();\n this.shortcuts = {};\n this.feedback = {};\n this.isLoading = true;\n this.capturingKey = null;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (!window.api) return;\n this.loadShortcutsHandler = (event, keybinds) => {\n this.shortcuts = keybinds;\n this.isLoading = false;\n };\n window.api.shortcutSettingsView.onLoadShortcuts(this.loadShortcutsHandler);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api && this.loadShortcutsHandler) {\n window.api.shortcutSettingsView.removeOnLoadShortcuts(this.loadShortcutsHandler);\n }\n }\n\n handleKeydown(e, shortcutKey){\n e.preventDefault(); e.stopPropagation();\n const result = this._parseAccelerator(e);\n if(!result) return; // modifier키만 누른 상태\n \n const {accel, error} = result;\n if(error){\n this.feedback = {...this.feedback, [shortcutKey]:{type:'error',msg:error}};\n return;\n }\n // 성공\n this.shortcuts = {...this.shortcuts, [shortcutKey]:accel};\n this.feedback = {...this.feedback, [shortcutKey]:{type:'success',msg:'Shortcut set'}};\n this.stopCapture();\n }\n \n _parseAccelerator(e){\n /* returns {accel?, error?} */\n const parts=[]; if(e.metaKey) parts.push('Cmd');\n if(e.ctrlKey) parts.push('Ctrl');\n if(e.altKey) parts.push('Alt');\n if(e.shiftKey) parts.push('Shift');\n \n const isModifier=['Meta','Control','Alt','Shift'].includes(e.key);\n if(isModifier) return null;\n \n const map={ArrowUp:'Up',ArrowDown:'Down',ArrowLeft:'Left',ArrowRight:'Right',' ':'Space'};\n parts.push(e.key.length===1? e.key.toUpperCase() : (map[e.key]||e.key));\n const accel=parts.join('+');\n \n /* ---- validation ---- */\n if(parts.length===1) return {error:'Invalid shortcut: needs a modifier'};\n if(parts.length>4) return {error:'Invalid shortcut: max 4 keys'};\n if(commonSystemShortcuts.has(accel)) return {error:'Invalid shortcut: system reserved'};\n return {accel};\n }\n\n startCapture(key){ this.capturingKey = key; this.feedback = {...this.feedback, [key]:undefined}; }\n\n disableShortcut(key){\n this.shortcuts = {...this.shortcuts, [key]:''}; // 공백 => 작동 X\n this.feedback = {...this.feedback, [key]:{type:'success',msg:'Shortcut disabled'}};\n }\n\n stopCapture() {\n this.capturingKey = null;\n }\n\n async handleSave() {\n if (!window.api) return;\n this.feedback = {};\n const result = await window.api.shortcutSettingsView.saveShortcuts(this.shortcuts);\n if (!result.success) {\n alert('Failed to save shortcuts: ' + result.error);\n }\n }\n\n handleClose() {\n if (!window.api) return;\n this.feedback = {};\n window.api.shortcutSettingsView.closeShortcutSettingsWindow();\n }\n\n async handleResetToDefault() {\n if (!window.api) return;\n const confirmation = confirm(\"Are you sure you want to reset all shortcuts to their default values?\");\n if (!confirmation) return;\n \n try {\n const defaultShortcuts = await window.api.shortcutSettingsView.getDefaultShortcuts();\n this.shortcuts = defaultShortcuts;\n } catch (error) {\n alert('Failed to load default settings.');\n }\n }\n\n formatShortcutName(name) {\n if (displayNameMap[name]) {\n return displayNameMap[name];\n }\n const result = name.replace(/([A-Z])/g, \" $1\");\n return result.charAt(0).toUpperCase() + result.slice(1);\n }\n\n render(){\n if(this.isLoading){\n return html`
Loading Shortcuts...
`;\n }\n return html`\n
\n \n

Edit Shortcuts

\n \n
\n ${Object.keys(this.shortcuts).map(key=>html`\n
\n
\n ${this.formatShortcutName(key)}\n \n \n \n \n \n this.startCapture(key)}\n @keydown=${e=>this.handleKeydown(e,key)}\n @blur=${()=>this.stopCapture()}\n />\n
\n \n ${this.feedback[key] ? html`\n
\n ${this.feedback[key].msg}\n
` : html`
`\n }\n
\n `)}\n
\n \n
\n \n \n \n
\n
\n `;\n }\n }\n\ncustomElements.define('shortcut-settings-view', ShortcutSettingsView);"], ["/glass/src/ui/app/MainHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class MainHeader extends LitElement {\n static properties = {\n isTogglingSession: { type: Boolean, state: true },\n shortcuts: { type: Object, state: true },\n listenSessionStatus: { type: String, state: true },\n };\n\n static styles = css`\n :host {\n display: flex;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.sliding-in) {\n animation: fadeIn 0.2s ease-out forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n .header {\n -webkit-app-region: drag;\n width: max-content;\n height: 47px;\n padding: 2px 10px 2px 13px;\n background: transparent;\n overflow: hidden;\n border-radius: 9000px;\n /* backdrop-filter: blur(1px); */\n justify-content: space-between;\n align-items: center;\n display: inline-flex;\n box-sizing: border-box;\n position: relative;\n }\n\n .header::before {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n border-radius: 9000px;\n z-index: -1;\n }\n\n .header::after {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n border-radius: 9000px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%); \n -webkit-mask:\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .listen-button {\n -webkit-app-region: no-drag;\n height: 26px;\n padding: 0 13px;\n background: transparent;\n border-radius: 9000px;\n justify-content: center;\n width: 78px;\n align-items: center;\n gap: 6px;\n display: flex;\n border: none;\n cursor: pointer;\n position: relative;\n }\n\n .listen-button:disabled {\n cursor: default;\n opacity: 0.8;\n }\n\n .listen-button.active::before {\n background: rgba(215, 0, 0, 0.5);\n }\n\n .listen-button.active:hover::before {\n background: rgba(255, 20, 20, 0.6);\n }\n\n .listen-button.done {\n background-color: rgba(255, 255, 255, 0.6);\n transition: background-color 0.15s ease;\n }\n\n .listen-button.done .action-text-content {\n color: black;\n }\n \n .listen-button.done .listen-icon svg rect,\n .listen-button.done .listen-icon svg path {\n fill: black;\n }\n\n .listen-button.done:hover {\n background-color: #f0f0f0;\n }\n\n .listen-button:hover::before {\n background: rgba(255, 255, 255, 0.18);\n }\n\n .listen-button::before {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n background: rgba(255, 255, 255, 0.14);\n border-radius: 9000px;\n z-index: -1;\n transition: background 0.15s ease;\n }\n\n .listen-button::after {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n border-radius: 9000px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%);\n -webkit-mask:\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .listen-button.done::after {\n display: none;\n }\n\n .loading-dots {\n display: flex;\n align-items: center;\n gap: 5px;\n }\n\n .loading-dots span {\n width: 6px;\n height: 6px;\n background-color: white;\n border-radius: 50%;\n animation: pulse 1.4s infinite ease-in-out both;\n }\n .loading-dots span:nth-of-type(1) {\n animation-delay: -0.32s;\n }\n .loading-dots span:nth-of-type(2) {\n animation-delay: -0.16s;\n }\n @keyframes pulse {\n 0%, 80%, 100% {\n opacity: 0.2;\n }\n 40% {\n opacity: 1.0;\n }\n }\n\n .header-actions {\n -webkit-app-region: no-drag;\n height: 26px;\n box-sizing: border-box;\n justify-content: flex-start;\n align-items: center;\n gap: 9px;\n display: flex;\n padding: 0 8px;\n border-radius: 6px;\n transition: background 0.15s ease;\n }\n\n .header-actions:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .ask-action {\n margin-left: 4px;\n }\n\n .action-button,\n .action-text {\n padding-bottom: 1px;\n justify-content: center;\n align-items: center;\n gap: 10px;\n display: flex;\n }\n\n .action-text-content {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500; /* Medium */\n word-wrap: break-word;\n }\n\n .icon-container {\n justify-content: flex-start;\n align-items: center;\n gap: 4px;\n display: flex;\n }\n\n .icon-container.ask-icons svg,\n .icon-container.showhide-icons svg {\n width: 12px;\n height: 12px;\n }\n\n .listen-icon svg {\n width: 12px;\n height: 11px;\n position: relative;\n top: 1px;\n }\n\n .icon-box {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n background-color: rgba(255, 255, 255, 0.1);\n border-radius: 13%;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .settings-button {\n -webkit-app-region: no-drag;\n padding: 5px;\n border-radius: 50%;\n background: transparent;\n transition: background 0.15s ease;\n color: white;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n .settings-button:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .settings-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 3px;\n }\n\n .settings-icon svg {\n width: 16px;\n height: 16px;\n }\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .header,\n :host-context(body.has-glass) .listen-button,\n :host-context(body.has-glass) .header-actions,\n :host-context(body.has-glass) .settings-button {\n background: transparent !important;\n filter: none !important;\n box-shadow: none !important;\n backdrop-filter: none !important;\n }\n :host-context(body.has-glass) .icon-box {\n background: transparent !important;\n border: none !important;\n }\n\n :host-context(body.has-glass) .header::before,\n :host-context(body.has-glass) .header::after,\n :host-context(body.has-glass) .listen-button::before,\n :host-context(body.has-glass) .listen-button::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .header-actions:hover,\n :host-context(body.has-glass) .settings-button:hover,\n :host-context(body.has-glass) .listen-button:hover::before {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .header,\n :host-context(body.has-glass) .listen-button,\n :host-context(body.has-glass) .header-actions,\n :host-context(body.has-glass) .settings-button,\n :host-context(body.has-glass) .icon-box {\n border-radius: 0 !important;\n }\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n `;\n\n constructor() {\n super();\n this.shortcuts = {};\n this.isVisible = true;\n this.isAnimating = false;\n this.hasSlidIn = false;\n this.settingsHideTimer = null;\n this.isTogglingSession = false;\n this.listenSessionStatus = 'beforeSession';\n this.animationEndTimer = null;\n this.handleAnimationEnd = this.handleAnimationEnd.bind(this);\n this.handleMouseMove = this.handleMouseMove.bind(this);\n this.handleMouseUp = this.handleMouseUp.bind(this);\n this.dragState = null;\n this.wasJustDragged = false;\n }\n\n _getListenButtonText(status) {\n switch (status) {\n case 'beforeSession': return 'Listen';\n case 'inSession' : return 'Stop';\n case 'afterSession': return 'Done';\n default : return 'Listen';\n }\n }\n\n async handleMouseDown(e) {\n e.preventDefault();\n\n const initialPosition = await window.api.mainHeader.getHeaderPosition();\n\n this.dragState = {\n initialMouseX: e.screenX,\n initialMouseY: e.screenY,\n initialWindowX: initialPosition.x,\n initialWindowY: initialPosition.y,\n moved: false,\n };\n\n window.addEventListener('mousemove', this.handleMouseMove, { capture: true });\n window.addEventListener('mouseup', this.handleMouseUp, { once: true, capture: true });\n }\n\n handleMouseMove(e) {\n if (!this.dragState) return;\n\n const deltaX = Math.abs(e.screenX - this.dragState.initialMouseX);\n const deltaY = Math.abs(e.screenY - this.dragState.initialMouseY);\n \n if (deltaX > 3 || deltaY > 3) {\n this.dragState.moved = true;\n }\n\n const newWindowX = this.dragState.initialWindowX + (e.screenX - this.dragState.initialMouseX);\n const newWindowY = this.dragState.initialWindowY + (e.screenY - this.dragState.initialMouseY);\n\n window.api.mainHeader.moveHeaderTo(newWindowX, newWindowY);\n }\n\n handleMouseUp(e) {\n if (!this.dragState) return;\n\n const wasDragged = this.dragState.moved;\n\n window.removeEventListener('mousemove', this.handleMouseMove, { capture: true });\n this.dragState = null;\n\n if (wasDragged) {\n this.wasJustDragged = true;\n setTimeout(() => {\n this.wasJustDragged = false;\n }, 0);\n }\n }\n\n toggleVisibility() {\n if (this.isAnimating) {\n console.log('[MainHeader] Animation already in progress, ignoring toggle');\n return;\n }\n \n if (this.animationEndTimer) {\n clearTimeout(this.animationEndTimer);\n this.animationEndTimer = null;\n }\n \n this.isAnimating = true;\n \n if (this.isVisible) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n hide() {\n this.classList.remove('showing');\n this.classList.add('hiding');\n }\n \n show() {\n this.classList.remove('hiding', 'hidden');\n this.classList.add('showing');\n }\n \n handleAnimationEnd(e) {\n if (e.target !== this) return;\n \n this.isAnimating = false;\n \n if (this.classList.contains('hiding')) {\n this.classList.add('hidden');\n if (window.api) {\n window.api.mainHeader.sendHeaderAnimationFinished('hidden');\n }\n } else if (this.classList.contains('showing')) {\n if (window.api) {\n window.api.mainHeader.sendHeaderAnimationFinished('visible');\n }\n }\n }\n\n startSlideInAnimation() {\n if (this.hasSlidIn) return;\n this.classList.add('sliding-in');\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('animationend', this.handleAnimationEnd);\n\n if (window.api) {\n\n this._sessionStateTextListener = (event, { success }) => {\n if (success) {\n this.listenSessionStatus = ({\n beforeSession: 'inSession',\n inSession: 'afterSession',\n afterSession: 'beforeSession',\n })[this.listenSessionStatus] || 'beforeSession';\n } else {\n this.listenSessionStatus = 'beforeSession';\n }\n this.isTogglingSession = false; // ✨ 로딩 상태만 해제\n };\n window.api.mainHeader.onListenChangeSessionResult(this._sessionStateTextListener);\n\n this._shortcutListener = (event, keybinds) => {\n console.log('[MainHeader] Received updated shortcuts:', keybinds);\n this.shortcuts = keybinds;\n };\n window.api.mainHeader.onShortcutsUpdated(this._shortcutListener);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('animationend', this.handleAnimationEnd);\n \n if (this.animationEndTimer) {\n clearTimeout(this.animationEndTimer);\n this.animationEndTimer = null;\n }\n \n if (window.api) {\n if (this._sessionStateTextListener) {\n window.api.mainHeader.removeOnListenChangeSessionResult(this._sessionStateTextListener);\n }\n if (this._shortcutListener) {\n window.api.mainHeader.removeOnShortcutsUpdated(this._shortcutListener);\n }\n }\n }\n\n showSettingsWindow(element) {\n if (this.wasJustDragged) return;\n if (window.api) {\n console.log(`[MainHeader] showSettingsWindow called at ${Date.now()}`);\n window.api.mainHeader.showSettingsWindow();\n\n }\n }\n\n hideSettingsWindow() {\n if (this.wasJustDragged) return;\n if (window.api) {\n console.log(`[MainHeader] hideSettingsWindow called at ${Date.now()}`);\n window.api.mainHeader.hideSettingsWindow();\n }\n }\n\n async _handleListenClick() {\n if (this.wasJustDragged) return;\n if (this.isTogglingSession) {\n return;\n }\n\n this.isTogglingSession = true;\n\n try {\n const listenButtonText = this._getListenButtonText(this.listenSessionStatus);\n if (window.api) {\n await window.api.mainHeader.sendListenButtonClick(listenButtonText);\n }\n } catch (error) {\n console.error('IPC invoke for session change failed:', error);\n this.isTogglingSession = false;\n }\n }\n\n async _handleAskClick() {\n if (this.wasJustDragged) return;\n\n try {\n if (window.api) {\n await window.api.mainHeader.sendAskButtonClick();\n }\n } catch (error) {\n console.error('IPC invoke for ask button failed:', error);\n }\n }\n\n async _handleToggleAllWindowsVisibility() {\n if (this.wasJustDragged) return;\n\n try {\n if (window.api) {\n await window.api.mainHeader.sendToggleAllWindowsVisibility();\n }\n } catch (error) {\n console.error('IPC invoke for all windows visibility button failed:', error);\n }\n }\n\n\n renderShortcut(accelerator) {\n if (!accelerator) return html``;\n\n const keyMap = {\n 'Cmd': '⌘', 'Command': '⌘',\n 'Ctrl': '⌃', 'Control': '⌃',\n 'Alt': '⌥', 'Option': '⌥',\n 'Shift': '⇧',\n 'Enter': '↵',\n 'Backspace': '⌫',\n 'Delete': '⌦',\n 'Tab': '⇥',\n 'Escape': '⎋',\n 'Up': '↑', 'Down': '↓', 'Left': '←', 'Right': '→',\n '\\\\': html``,\n };\n\n const keys = accelerator.split('+');\n return html`${keys.map(key => html`\n
${keyMap[key] || key}
\n `)}`;\n }\n\n render() {\n const listenButtonText = this._getListenButtonText(this.listenSessionStatus);\n \n const buttonClasses = {\n active: listenButtonText === 'Stop',\n done: listenButtonText === 'Done',\n };\n const showStopIcon = listenButtonText === 'Stop' || listenButtonText === 'Done';\n\n return html`\n
\n \n\n
this._handleAskClick()}>\n
\n
Ask
\n
\n
\n ${this.renderShortcut(this.shortcuts.nextStep)}\n
\n
\n\n
this._handleToggleAllWindowsVisibility()}>\n
\n
Show/Hide
\n
\n
\n ${this.renderShortcut(this.shortcuts.toggleVisibility)}\n
\n
\n\n \n
\n `;\n }\n}\n\ncustomElements.define('main-header', MainHeader);\n"], ["/glass/src/features/common/services/databaseInitializer.js", "const { app } = require('electron');\nconst path = require('path');\nconst fs = require('fs');\nconst sqliteClient = require('./sqliteClient');\nconst config = require('../config/config');\n\nclass DatabaseInitializer {\n constructor() {\n this.isInitialized = false;\n \n // 최종적으로 사용될 DB 경로 (쓰기 가능한 위치)\n const userDataPath = app.getPath('userData');\n // In both development and production mode, the database is stored in the userData directory:\n // macOS: ~/Library/Application Support/Glass/pickleglass.db\n // Windows: %APPDATA%\\Glass\\pickleglass.db\n this.dbPath = path.join(userDataPath, 'pickleglass.db');\n this.dataDir = userDataPath;\n\n // The original DB path (read-only location in the package)\n this.sourceDbPath = app.isPackaged\n ? path.join(process.resourcesPath, 'data', 'pickleglass.db')\n : path.join(app.getAppPath(), 'data', 'pickleglass.db');\n }\n\n ensureDatabaseExists() {\n if (!fs.existsSync(this.dbPath)) {\n console.log(`[DB] Database not found at ${this.dbPath}. Preparing to create new database...`);\n\n // userData 디렉토리 생성 (없을 경우)\n if (!fs.existsSync(this.dataDir)) {\n fs.mkdirSync(this.dataDir, { recursive: true });\n }\n\n // 패키지에 번들된 초기 DB가 있으면 복사, 없으면 빈 파일을 생성하도록 둔다.\n if (fs.existsSync(this.sourceDbPath)) {\n try {\n fs.copyFileSync(this.sourceDbPath, this.dbPath);\n console.log(`[DB] Bundled database copied to ${this.dbPath}`);\n } catch (error) {\n console.error(`[DB] Failed to copy bundled database:`, error);\n // 복사 실패 시에도 새 DB를 생성할 수 있도록 계속 진행\n }\n } else {\n console.log('[DB] No bundled DB found – a fresh database will be created.');\n }\n }\n }\n\n async initialize() {\n if (this.isInitialized) {\n console.log('[DB] Already initialized.');\n return true;\n }\n\n try {\n this.ensureDatabaseExists();\n\n sqliteClient.connect(this.dbPath); // DB 경로를 인자로 전달\n \n // This single call will now synchronize the schema and then init default data.\n await sqliteClient.initTables();\n\n // Clean up any orphaned sessions from previous versions\n await sqliteClient.cleanupEmptySessions();\n\n this.isInitialized = true;\n console.log('[DB] Database initialized successfully');\n return true;\n } catch (error) {\n console.error('[DB] Database initialization failed:', error);\n this.isInitialized = false;\n throw error; \n }\n }\n\n async ensureDataDirectory() {\n try {\n if (!fs.existsSync(this.dataDir)) {\n fs.mkdirSync(this.dataDir, { recursive: true });\n console.log('[DatabaseInitializer] Data directory created:', this.dataDir);\n } else {\n console.log('[DatabaseInitializer] Data directory exists:', this.dataDir);\n }\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to create data directory:', error);\n throw error;\n }\n }\n\n async checkDatabaseExists() {\n try {\n const exists = fs.existsSync(this.dbPath);\n console.log('[DatabaseInitializer] Database file check:', { path: this.dbPath, exists });\n return exists;\n } catch (error) {\n console.error('[DatabaseInitializer] Error checking database file:', error);\n return false;\n }\n }\n\n async createNewDatabase() {\n console.log('[DatabaseInitializer] Creating new database...');\n try {\n await sqliteClient.connect(); // Connect and initialize tables/default data\n \n const user = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!user) {\n throw new Error('Default user was not created during initialization.');\n }\n \n console.log(`[DatabaseInitializer] Default user check successful, UID: ${user.uid}`);\n return { success: true, user };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to create new database:', error);\n throw error;\n }\n }\n\n async connectToExistingDatabase() {\n console.log('[DatabaseInitializer] Connecting to existing database...');\n try {\n await sqliteClient.connect();\n \n const user = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!user) {\n console.warn('[DatabaseInitializer] Default user not found in existing DB, attempting recovery.');\n throw new Error('Default user missing');\n }\n \n console.log(`[DatabaseInitializer] Connection to existing DB successful for user: ${user.uid}`);\n return { success: true, user };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to connect to existing database:', error);\n throw error;\n }\n }\n\n async validateAndRecoverData() {\n console.log('[DatabaseInitializer] Validating database integrity...');\n try {\n console.log('[DatabaseInitializer] Validating database integrity...');\n\n // The synchronizeSchema function handles table and column creation now.\n // We just need to ensure default data is present.\n await sqliteClient.synchronizeSchema();\n\n const defaultUser = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!defaultUser) {\n console.log('[DatabaseInitializer] Default user not found - creating...');\n await sqliteClient.initDefaultData();\n }\n\n const presetTemplates = await sqliteClient.getPresets('default_user');\n if (!presetTemplates || presetTemplates.length === 0) {\n console.log('[DatabaseInitializer] Preset templates missing - creating...');\n await sqliteClient.initDefaultData();\n }\n\n console.log('[DatabaseInitializer] Database validation completed');\n return { success: true };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Database validation failed:', error);\n try {\n await sqliteClient.initDefaultData();\n console.log('[DatabaseInitializer] Default data recovered');\n return { success: true };\n } catch (error) {\n console.error('[DatabaseInitializer] Database validation failed:', error);\n throw error;\n }\n }\n }\n\n async getStatus() {\n return {\n isInitialized: this.isInitialized,\n dbPath: this.dbPath,\n dbExists: fs.existsSync(this.dbPath),\n enableSQLiteStorage: config.get('enableSQLiteStorage'),\n enableOfflineMode: config.get('enableOfflineMode')\n };\n }\n\n async reset() {\n try {\n console.log('[DatabaseInitializer] Resetting database...');\n \n sqliteClient.close();\n \n if (fs.existsSync(this.dbPath)) {\n fs.unlinkSync(this.dbPath);\n console.log('[DatabaseInitializer] Database file deleted');\n }\n\n this.isInitialized = false;\n await this.initialize();\n\n console.log('[DatabaseInitializer] Database reset completed');\n return true;\n\n } catch (error) {\n console.error('[DatabaseInitializer] Database reset failed:', error);\n return false;\n }\n }\n\n close() {\n if (sqliteClient) {\n sqliteClient.close();\n }\n this.isInitialized = false;\n console.log('[DatabaseInitializer] Database connection closed');\n }\n\n getDatabasePath() {\n return this.dbPath;\n }\n}\n\nconst databaseInitializer = new DatabaseInitializer();\n\nmodule.exports = databaseInitializer; "], ["/glass/src/ui/app/ApiKeyHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class ApiKeyHeader extends LitElement {\n //////// after_modelStateService ////////\n static properties = {\n llmApiKey: { type: String },\n sttApiKey: { type: String },\n llmProvider: { type: String },\n sttProvider: { type: String },\n isLoading: { type: Boolean },\n errorMessage: { type: String },\n successMessage: { type: String },\n providers: { type: Object, state: true },\n modelSuggestions: { type: Array, state: true },\n userModelHistory: { type: Array, state: true },\n selectedLlmModel: { type: String, state: true },\n selectedSttModel: { type: String, state: true },\n ollamaStatus: { type: Object, state: true },\n installingModel: { type: String, state: true },\n installProgress: { type: Number, state: true },\n whisperInstallingModels: { type: Object, state: true },\n backCallback: { type: Function },\n llmError: { type: String },\n sttError: { type: String },\n };\n //////// after_modelStateService ////////\n\n static styles = css`\n :host {\n display: block;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n sans-serif;\n }\n * {\n box-sizing: border-box;\n }\n .container {\n width: 100%;\n height: 100%;\n padding: 24px 16px;\n background: rgba(0, 0, 0, 0.64);\n box-shadow: 0px 0px 0px 1.5px rgba(255, 255, 255, 0.64) inset;\n border-radius: 16px;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 24px;\n display: flex;\n -webkit-app-region: drag;\n }\n .header {\n width: 100%;\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-bottom: 8px;\n }\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 16px;\n right: 16px;\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 5px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 16px;\n line-height: 1;\n padding: 0;\n }\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n .back-button {\n -webkit-app-region: no-drag;\n padding: 8px;\n left: 0px;\n top: -7px;\n position: absolute;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n border-radius: 16px;\n border: 0.5px solid rgba(255, 255, 255, 0.5);\n justify-content: center;\n align-items: center;\n gap: 4px;\n display: flex;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n .back-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .arrow-icon-left {\n border: solid #dcdcdc;\n border-width: 0 1.2px 1.2px 0;\n display: inline-block;\n padding: 3px;\n transform: rotate(135deg);\n }\n .back-button-text {\n color: white;\n font-size: 12px;\n font-weight: 500;\n padding-right: 4px;\n }\n .title {\n color: white;\n font-size: 14px;\n font-weight: 700;\n }\n .section {\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .row {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n .label {\n color: white;\n font-size: 12px;\n font-weight: 600;\n }\n .provider-selector {\n display: flex;\n width: 240px;\n overflow: hidden;\n border-radius: 12px;\n border: 0.5px solid rgba(255, 255, 255, 0.5);\n }\n .provider-button {\n -webkit-app-region: no-drag;\n padding: 4px 8px;\n background: rgba(20.4, 20.4, 20.4, 0.32);\n color: #dcdcdc;\n font-size: 11px;\n font-weight: 450;\n letter-spacing: 0.11px;\n border: none;\n cursor: pointer;\n transition: background-color 0.2s ease;\n flex: 1;\n }\n .provider-button:hover {\n background: rgba(80, 80, 80, 0.48);\n }\n .provider-button[data-status='active'] {\n background: rgba(142.8, 142.8, 142.8, 0.48);\n color: white;\n }\n .api-input {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 10px 8px;\n background: rgba(61.2, 61.2, 61.2, 0.8);\n border-radius: 6px;\n border: 1px solid rgba(255, 255, 255, 0.24);\n color: white;\n font-size: 11px;\n text-overflow: ellipsis;\n font-family: inherit;\n line-height: inherit;\n }\n .ollama-action-button {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 10px 8px;\n border-radius: 16px;\n border: none;\n color: white;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n cursor: pointer;\n text-align: center;\n transition: background-color 0.2s ease;\n }\n .ollama-action-button.install {\n background: rgba(0, 122, 255, 0.2);\n }\n .ollama-action-button.start {\n background: rgba(255, 200, 0, 0.2);\n }\n select.api-input {\n -webkit-appearance: none;\n appearance: none;\n background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e\");\n background-position: right 0.5rem center;\n background-repeat: no-repeat;\n background-size: 1.5em 1.5em;\n padding-right: 2.5rem;\n }\n select.api-input option {\n background: #333;\n color: white;\n }\n .api-input::placeholder {\n color: #a0a0a0;\n }\n .confirm-button-container {\n width: 100%;\n display: flex;\n justify-content: flex-end;\n }\n .confirm-button {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 8px;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.16);\n border-radius: 16px;\n border: 1px solid rgba(255, 255, 255, 0.5);\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n .confirm-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .confirm-button:disabled {\n background: rgba(255, 255, 255, 0.12);\n color: #bebebe;\n border: 0.5px solid rgba(255, 255, 255, 0.24);\n box-shadow: none;\n cursor: not-allowed;\n }\n .footer {\n width: 100%;\n text-align: center;\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 500;\n line-height: 18px;\n }\n .footer-link {\n text-decoration: underline;\n cursor: pointer;\n -webkit-app-region: no-drag;\n }\n .error-message,\n .success-message {\n position: absolute;\n bottom: 70px;\n left: 16px;\n right: 16px;\n text-align: center;\n font-size: 11px;\n font-weight: 500;\n padding: 4px;\n border-radius: 4px;\n }\n .error-message {\n color: rgba(239, 68, 68, 0.9);\n }\n .success-message {\n color: rgba(74, 222, 128, 0.9);\n }\n .message-fade-out {\n animation: fadeOut 3s ease-in-out forwards;\n }\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 66% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n .sliding-out {\n animation: slideOut 0.3s ease-out forwards;\n }\n @keyframes slideOut {\n from {\n transform: translateY(0);\n opacity: 1;\n }\n to {\n transform: translateY(-100%);\n opacity: 0;\n }\n }\n .api-input.invalid {\n outline: 1px solid #ff7070;\n outline-offset: -1px;\n }\n .input-wrapper {\n display: flex;\n flex-direction: column;\n gap: 4px;\n align-items: flex-start;\n }\n .inline-error-message {\n color: #ff7070;\n font-size: 11px;\n font-weight: 400;\n letter-spacing: 0.11px;\n word-wrap: break-word;\n width: 240px;\n }\n `;\n\n\n constructor() {\n super();\n this.isLoading = false;\n this.errorMessage = '';\n this.successMessage = '';\n this.messageTimestamp = 0;\n //////// after_modelStateService ////////\n this.llmApiKey = '';\n this.sttApiKey = '';\n this.llmProvider = 'openai';\n this.sttProvider = 'openai';\n this.providers = { llm: [], stt: [] }; // 초기화\n // Ollama related\n this.modelSuggestions = [];\n this.userModelHistory = [];\n this.selectedLlmModel = '';\n this.selectedSttModel = '';\n this.ollamaStatus = { installed: false, running: false };\n this.installingModel = null;\n this.installProgress = 0;\n this.whisperInstallingModels = {};\n this.backCallback = () => {};\n this.llmError = '';\n this.sttError = '';\n\n // Professional operation management system\n this.activeOperations = new Map();\n this.operationTimeouts = new Map();\n this.connectionState = 'idle'; // idle, connecting, connected, failed, disconnected\n this.lastStateChange = Date.now();\n this.retryCount = 0;\n this.maxRetries = 3;\n this.baseRetryDelay = 1000;\n\n // Backpressure and resource management\n this.operationQueue = [];\n this.maxConcurrentOperations = 2;\n this.maxQueueSize = 5;\n this.operationMetrics = {\n totalOperations: 0,\n successfulOperations: 0,\n failedOperations: 0,\n timeouts: 0,\n averageResponseTime: 0,\n };\n\n // Configuration\n this.ipcTimeout = 10000; // 10s for IPC calls\n this.operationTimeout = 15000; // 15s for complex operations\n\n // Health monitoring system\n this.healthCheck = {\n enabled: false,\n intervalId: null,\n intervalMs: 30000, // 30s\n lastCheck: 0,\n consecutiveFailures: 0,\n maxFailures: 3,\n };\n\n // Load user model history from localStorage\n this.loadUserModelHistory();\n this.loadProviderConfig();\n //////// after_modelStateService ////////\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleInput = this.handleInput.bind(this);\n this.handleAnimationEnd = this.handleAnimationEnd.bind(this);\n this.handleProviderChange = this.handleProviderChange.bind(this);\n this.handleLlmProviderChange = this.handleLlmProviderChange.bind(this);\n this.handleSttProviderChange = this.handleSttProviderChange.bind(this);\n this.handleMessageFadeEnd = this.handleMessageFadeEnd.bind(this);\n this.handleModelKeyPress = this.handleModelKeyPress.bind(this);\n this.handleSttModelChange = this.handleSttModelChange.bind(this);\n this.handleBack = this.handleBack.bind(this);\n this.handleClose = this.handleClose.bind(this);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.dispatchEvent(new CustomEvent('content-changed', { bubbles: true, composed: true }));\n }\n\n reset() {\n this.apiKey = '';\n this.isLoading = false;\n this.errorMessage = '';\n this.validatedApiKey = null;\n this.selectedProvider = 'openai';\n this.requestUpdate();\n }\n\n handleBack() {\n if (this.backCallback) {\n this.backCallback();\n }\n }\n\n async loadProviderConfig() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n const [config, ollamaStatus] = await Promise.all([\n window.api.apiKeyHeader.getProviderConfig(),\n window.api.apiKeyHeader.getOllamaStatus(),\n ]);\n\n const llmProviders = [];\n const sttProviders = [];\n\n for (const id in config) {\n // 'openai-glass' 같은 가상 Provider는 UI에 표시하지 않음\n if (id.includes('-glass')) continue;\n const hasLlmModels = config[id].llmModels.length > 0 || id === 'ollama';\n const hasSttModels = config[id].sttModels.length > 0 || id === 'whisper';\n\n if (hasLlmModels) {\n llmProviders.push({ id, name: config[id].name });\n }\n if (hasSttModels) {\n sttProviders.push({ id, name: config[id].name });\n }\n }\n\n this.providers = { llm: llmProviders, stt: sttProviders };\n\n // 기본 선택 값 설정\n if (llmProviders.length > 0) this.llmProvider = llmProviders[0].id;\n if (sttProviders.length > 0) this.sttProvider = sttProviders[0].id;\n\n // Ollama 상태 및 모델 제안 로드\n if (ollamaStatus?.success) {\n this.ollamaStatus = {\n installed: ollamaStatus.installed,\n running: ollamaStatus.running,\n };\n\n // Load model suggestions if Ollama is running\n if (ollamaStatus.running) {\n await this.loadModelSuggestions();\n }\n }\n\n this.requestUpdate();\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load provider config:', error);\n }\n }\n\n async handleMouseDown(e) {\n if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON' || e.target.tagName === 'SELECT') {\n return;\n }\n\n e.preventDefault();\n\n if (!window.api?.apiKeyHeader) return;\n const initialPosition = await window.api.apiKeyHeader.getHeaderPosition();\n\n this.dragState = {\n initialMouseX: e.screenX,\n initialMouseY: e.screenY,\n initialWindowX: initialPosition.x,\n initialWindowY: initialPosition.y,\n moved: false,\n };\n\n window.addEventListener('mousemove', this.handleMouseMove);\n window.addEventListener('mouseup', this.handleMouseUp, { once: true });\n }\n\n handleMouseMove(e) {\n if (!this.dragState) return;\n\n const deltaX = Math.abs(e.screenX - this.dragState.initialMouseX);\n const deltaY = Math.abs(e.screenY - this.dragState.initialMouseY);\n\n if (deltaX > 3 || deltaY > 3) {\n this.dragState.moved = true;\n }\n\n const newWindowX = this.dragState.initialWindowX + (e.screenX - this.dragState.initialMouseX);\n const newWindowY = this.dragState.initialWindowY + (e.screenY - this.dragState.initialMouseY);\n\n if (window.api?.apiKeyHeader) {\n window.api.apiKeyHeader.moveHeaderTo(newWindowX, newWindowY);\n }\n }\n\n handleMouseUp(e) {\n if (!this.dragState) return;\n\n const wasDragged = this.dragState.moved;\n\n window.removeEventListener('mousemove', this.handleMouseMove);\n this.dragState = null;\n\n if (wasDragged) {\n this.wasJustDragged = true;\n setTimeout(() => {\n this.wasJustDragged = false;\n }, 200);\n }\n }\n\n handleInput(e) {\n this.apiKey = e.target.value;\n this.clearMessages();\n console.log('Input changed:', this.apiKey?.length || 0, 'chars');\n\n this.requestUpdate();\n this.updateComplete.then(() => {\n const inputField = this.shadowRoot?.querySelector('.apikey-input');\n if (inputField && this.isInputFocused) {\n inputField.focus();\n }\n });\n }\n\n clearMessages() {\n this.errorMessage = '';\n this.successMessage = '';\n this.messageTimestamp = 0;\n this.llmError = '';\n this.sttError = '';\n }\n\n handleProviderChange(e) {\n this.selectedProvider = e.target.value;\n this.clearMessages();\n console.log('Provider changed to:', this.selectedProvider);\n this.requestUpdate();\n }\n\n async handleLlmProviderChange(e, providerId) {\n const newProvider = providerId || e.target.value;\n if (newProvider === this.llmProvider) return;\n\n // Cancel any active operations first\n this._cancelAllActiveOperations();\n\n this.llmProvider = newProvider;\n this.errorMessage = '';\n this.successMessage = '';\n\n if (['openai', 'gemini'].includes(this.llmProvider)) {\n this.sttProvider = this.llmProvider;\n }\n\n // Reset retry state\n this.retryCount = 0;\n\n if (this.llmProvider === 'ollama') {\n console.log('[ApiKeyHeader] Ollama selected, initiating connection...');\n await this._initializeOllamaConnection();\n // Start health monitoring for Ollama\n this._startHealthMonitoring();\n } else {\n this._updateConnectionState('idle', 'Non-Ollama provider selected');\n // Stop health monitoring for non-Ollama providers\n this._stopHealthMonitoring();\n }\n\n this.requestUpdate();\n }\n\n async _initializeOllamaConnection() {\n try {\n // Progressive connection attempt with exponential backoff\n await this._attemptOllamaConnection();\n } catch (error) {\n console.error('[ApiKeyHeader] Initial Ollama connection failed:', error.message);\n\n if (this.retryCount < this.maxRetries) {\n const delay = this.baseRetryDelay * Math.pow(2, this.retryCount);\n console.log(`[ApiKeyHeader] Retrying Ollama connection in ${delay}ms (attempt ${this.retryCount + 1}/${this.maxRetries})`);\n\n this.retryCount++;\n\n // Use proper Promise-based delay instead of setTimeout\n await new Promise(resolve => {\n const retryTimeoutId = setTimeout(() => {\n this._initializeOllamaConnection();\n resolve();\n }, delay);\n\n // Store timeout for cleanup\n this.operationTimeouts.set(`retry_${this.retryCount}`, retryTimeoutId);\n });\n } else {\n this._updateConnectionState('failed', `Connection failed after ${this.maxRetries} attempts`);\n }\n }\n }\n\n async _attemptOllamaConnection() {\n await this.refreshOllamaStatus();\n }\n\n _cancelAllActiveOperations() {\n console.log(`[ApiKeyHeader] Cancelling ${this.activeOperations.size} active operations and ${this.operationQueue.length} queued operations`);\n\n // Cancel active operations\n for (const [operationType, operation] of this.activeOperations) {\n this._cancelOperation(operationType);\n }\n\n // Cancel queued operations\n for (const queuedOp of this.operationQueue) {\n queuedOp.reject(new Error(`Operation ${queuedOp.type} cancelled during cleanup`));\n }\n this.operationQueue.length = 0;\n\n // Clean up all timeouts\n for (const [timeoutId, timeout] of this.operationTimeouts) {\n clearTimeout(timeout);\n }\n this.operationTimeouts.clear();\n }\n\n /**\n * Get operation metrics for monitoring\n */\n getOperationMetrics() {\n return {\n ...this.operationMetrics,\n activeOperations: this.activeOperations.size,\n queuedOperations: this.operationQueue.length,\n successRate:\n this.operationMetrics.totalOperations > 0\n ? (this.operationMetrics.successfulOperations / this.operationMetrics.totalOperations) * 100\n : 0,\n };\n }\n\n /**\n * Adaptive backpressure based on system performance\n */\n _adjustBackpressureThresholds() {\n const metrics = this.getOperationMetrics();\n\n // Reduce concurrent operations if success rate is low\n if (metrics.successRate < 70 && this.maxConcurrentOperations > 1) {\n this.maxConcurrentOperations = Math.max(1, this.maxConcurrentOperations - 1);\n console.log(\n `[ApiKeyHeader] Reduced max concurrent operations to ${this.maxConcurrentOperations} (success rate: ${metrics.successRate.toFixed(1)}%)`\n );\n }\n\n // Increase if performance is good\n if (metrics.successRate > 90 && metrics.averageResponseTime < 3000 && this.maxConcurrentOperations < 3) {\n this.maxConcurrentOperations++;\n console.log(`[ApiKeyHeader] Increased max concurrent operations to ${this.maxConcurrentOperations}`);\n }\n }\n\n /**\n * Professional health monitoring system\n */\n _startHealthMonitoring() {\n if (this.healthCheck.enabled) return;\n\n this.healthCheck.enabled = true;\n this.healthCheck.intervalId = setInterval(() => {\n this._performHealthCheck();\n }, this.healthCheck.intervalMs);\n\n console.log(`[ApiKeyHeader] Health monitoring started (interval: ${this.healthCheck.intervalMs}ms)`);\n }\n\n _stopHealthMonitoring() {\n if (!this.healthCheck.enabled) return;\n\n this.healthCheck.enabled = false;\n if (this.healthCheck.intervalId) {\n clearInterval(this.healthCheck.intervalId);\n this.healthCheck.intervalId = null;\n }\n\n console.log('[ApiKeyHeader] Health monitoring stopped');\n }\n\n async _performHealthCheck() {\n // Only perform health check if Ollama is selected and we're in a stable state\n if (this.llmProvider !== 'ollama' || this.connectionState === 'connecting') {\n return;\n }\n\n const now = Date.now();\n this.healthCheck.lastCheck = now;\n\n try {\n // Lightweight health check - just ping the service\n const isHealthy = await this._executeOperation(\n 'health_check',\n async () => {\n if (!window.api?.apiKeyHeader) return false;\n const result = await window.api.apiKeyHeader.getOllamaStatus();\n return result?.success && result?.running;\n },\n { timeout: 5000, priority: 'low' }\n );\n\n if (isHealthy) {\n this.healthCheck.consecutiveFailures = 0;\n\n // Update state if we were previously failed\n if (this.connectionState === 'failed') {\n this._updateConnectionState('connected', 'Health check recovered');\n }\n } else {\n this._handleHealthCheckFailure();\n }\n\n // Adjust thresholds based on performance\n this._adjustBackpressureThresholds();\n } catch (error) {\n console.warn('[ApiKeyHeader] Health check failed:', error.message);\n this._handleHealthCheckFailure();\n }\n }\n\n _handleHealthCheckFailure() {\n this.healthCheck.consecutiveFailures++;\n\n if (this.healthCheck.consecutiveFailures >= this.healthCheck.maxFailures) {\n console.warn(`[ApiKeyHeader] Health check failed ${this.healthCheck.consecutiveFailures} times, marking as disconnected`);\n this._updateConnectionState('failed', 'Service health check failed');\n\n // Increase health check frequency when having issues\n this.healthCheck.intervalMs = Math.max(10000, this.healthCheck.intervalMs / 2);\n this._restartHealthMonitoring();\n }\n }\n\n _restartHealthMonitoring() {\n this._stopHealthMonitoring();\n this._startHealthMonitoring();\n }\n\n /**\n * Get comprehensive health status\n */\n getHealthStatus() {\n return {\n connection: {\n state: this.connectionState,\n lastStateChange: this.lastStateChange,\n timeSinceLastChange: Date.now() - this.lastStateChange,\n },\n operations: this.getOperationMetrics(),\n health: {\n enabled: this.healthCheck.enabled,\n lastCheck: this.healthCheck.lastCheck,\n timeSinceLastCheck: this.healthCheck.lastCheck > 0 ? Date.now() - this.healthCheck.lastCheck : null,\n consecutiveFailures: this.healthCheck.consecutiveFailures,\n intervalMs: this.healthCheck.intervalMs,\n },\n ollama: {\n provider: this.llmProvider,\n status: this.ollamaStatus,\n selectedModel: this.selectedLlmModel,\n },\n };\n }\n\n async handleSttProviderChange(e, providerId) {\n const newProvider = providerId || e.target.value;\n if (newProvider === this.sttProvider) return;\n\n this.sttProvider = newProvider;\n this.errorMessage = '';\n this.successMessage = '';\n\n if (this.sttProvider === 'ollama') {\n console.warn('[ApiKeyHeader] Ollama does not support STT yet. Please select Whisper or another provider.');\n this.sttError = '*Ollama does not support STT yet. Please select Whisper or another STT provider.';\n this.messageTimestamp = Date.now();\n\n // Auto-select Whisper if available\n const whisperProvider = this.providers.stt.find(p => p.id === 'whisper');\n if (whisperProvider) {\n this.sttProvider = 'whisper';\n console.log('[ApiKeyHeader] Auto-selected Whisper for STT');\n }\n }\n\n this.requestUpdate();\n }\n\n /**\n * Professional operation management with backpressure control\n */\n async _executeOperation(operationType, operation, options = {}) {\n const operationId = `${operationType}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n const timeout = options.timeout || this.ipcTimeout;\n const priority = options.priority || 'normal'; // high, normal, low\n\n // Backpressure control\n if (this.activeOperations.size >= this.maxConcurrentOperations) {\n if (this.operationQueue.length >= this.maxQueueSize) {\n throw new Error(`Operation queue full (${this.maxQueueSize}), rejecting ${operationType}`);\n }\n\n console.log(`[ApiKeyHeader] Queuing operation ${operationType} (${this.activeOperations.size} active)`);\n return this._queueOperation(operationId, operationType, operation, options);\n }\n\n return this._executeImmediately(operationId, operationType, operation, timeout);\n }\n\n async _queueOperation(operationId, operationType, operation, options) {\n return new Promise((resolve, reject) => {\n const queuedOperation = {\n id: operationId,\n type: operationType,\n operation,\n options,\n resolve,\n reject,\n queuedAt: Date.now(),\n priority: options.priority || 'normal',\n };\n\n // Insert based on priority (high priority first)\n if (options.priority === 'high') {\n this.operationQueue.unshift(queuedOperation);\n } else {\n this.operationQueue.push(queuedOperation);\n }\n\n console.log(`[ApiKeyHeader] Queued ${operationType} (queue size: ${this.operationQueue.length})`);\n });\n }\n\n async _executeImmediately(operationId, operationType, operation, timeout) {\n const startTime = Date.now();\n this.operationMetrics.totalOperations++;\n\n // Check if similar operation is already running\n if (this.activeOperations.has(operationType)) {\n console.log(`[ApiKeyHeader] Operation ${operationType} already in progress, cancelling previous`);\n this._cancelOperation(operationType);\n }\n\n // Create cancellation mechanism\n const cancellationPromise = new Promise((_, reject) => {\n const timeoutId = setTimeout(() => {\n this.operationMetrics.timeouts++;\n reject(new Error(`Operation ${operationType} timeout after ${timeout}ms`));\n }, timeout);\n\n this.operationTimeouts.set(operationId, timeoutId);\n });\n\n const operationPromise = Promise.race([operation(), cancellationPromise]);\n\n this.activeOperations.set(operationType, {\n id: operationId,\n promise: operationPromise,\n startTime,\n });\n\n try {\n const result = await operationPromise;\n this._recordOperationSuccess(startTime);\n return result;\n } catch (error) {\n this._recordOperationFailure(error, operationType);\n throw error;\n } finally {\n this._cleanupOperation(operationId, operationType);\n this._processQueue();\n }\n }\n\n _recordOperationSuccess(startTime) {\n this.operationMetrics.successfulOperations++;\n const responseTime = Date.now() - startTime;\n this._updateAverageResponseTime(responseTime);\n }\n\n _recordOperationFailure(error, operationType) {\n this.operationMetrics.failedOperations++;\n\n if (error.message.includes('timeout')) {\n console.error(`[ApiKeyHeader] Operation ${operationType} timed out`);\n this._updateConnectionState('failed', `Timeout: ${error.message}`);\n }\n }\n\n _updateAverageResponseTime(responseTime) {\n const totalOps = this.operationMetrics.successfulOperations;\n this.operationMetrics.averageResponseTime = (this.operationMetrics.averageResponseTime * (totalOps - 1) + responseTime) / totalOps;\n }\n\n async _processQueue() {\n if (this.operationQueue.length === 0 || this.activeOperations.size >= this.maxConcurrentOperations) {\n return;\n }\n\n const queuedOp = this.operationQueue.shift();\n if (!queuedOp) return;\n\n const queueTime = Date.now() - queuedOp.queuedAt;\n console.log(`[ApiKeyHeader] Processing queued operation ${queuedOp.type} (waited ${queueTime}ms)`);\n\n try {\n const result = await this._executeImmediately(\n queuedOp.id,\n queuedOp.type,\n queuedOp.operation,\n queuedOp.options.timeout || this.ipcTimeout\n );\n queuedOp.resolve(result);\n } catch (error) {\n queuedOp.reject(error);\n }\n }\n\n _cancelOperation(operationType) {\n const operation = this.activeOperations.get(operationType);\n if (operation) {\n this._cleanupOperation(operation.id, operationType);\n console.log(`[ApiKeyHeader] Cancelled operation: ${operationType}`);\n }\n }\n\n _cleanupOperation(operationId, operationType) {\n if (this.operationTimeouts.has(operationId)) {\n clearTimeout(this.operationTimeouts.get(operationId));\n this.operationTimeouts.delete(operationId);\n }\n this.activeOperations.delete(operationType);\n }\n\n _updateConnectionState(newState, reason = '') {\n if (this.connectionState !== newState) {\n console.log(`[ApiKeyHeader] Connection state: ${this.connectionState} -> ${newState} (${reason})`);\n this.connectionState = newState;\n this.lastStateChange = Date.now();\n\n // Update UI based on state\n this._handleStateChange(newState, reason);\n }\n }\n\n _handleStateChange(state, reason) {\n switch (state) {\n case 'connecting':\n this.installingModel = 'Connecting to Ollama...';\n this.installProgress = 10;\n break;\n case 'failed':\n this.errorMessage = reason || 'Connection failed';\n this.installingModel = null;\n this.installProgress = 0;\n this.messageTimestamp = Date.now();\n break;\n case 'connected':\n this.installingModel = null;\n this.installProgress = 0;\n break;\n case 'disconnected':\n this.ollamaStatus = { installed: false, running: false };\n break;\n }\n this.requestUpdate();\n }\n\n async refreshOllamaStatus() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n this._updateConnectionState('connecting', 'Checking Ollama status');\n\n const result = await this._executeOperation('ollama_status', async () => {\n return await window.api.apiKeyHeader.getOllamaStatus();\n });\n\n if (result?.success) {\n this.ollamaStatus = {\n installed: result.installed,\n running: result.running,\n };\n\n this._updateConnectionState('connected', 'Status updated successfully');\n\n // Load model suggestions if Ollama is running\n if (result.running) {\n await this.loadModelSuggestions();\n }\n } else {\n this._updateConnectionState('failed', result?.error || 'Status check failed');\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to refresh Ollama status:', error.message);\n this._updateConnectionState('failed', error.message);\n }\n }\n\n async loadModelSuggestions() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n const result = await this._executeOperation('model_suggestions', async () => {\n return await window.api.apiKeyHeader.getModelSuggestions();\n });\n\n if (result?.success) {\n this.modelSuggestions = result.suggestions || [];\n\n // 기본 모델 선택 (설치된 모델 중 첫 번째)\n if (!this.selectedLlmModel && this.modelSuggestions.length > 0) {\n const installedModel = this.modelSuggestions.find(m => m.status === 'installed');\n if (installedModel) {\n this.selectedLlmModel = installedModel.name;\n }\n }\n this.requestUpdate();\n } else {\n console.warn('[ApiKeyHeader] Model suggestions request unsuccessful:', result?.error);\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load model suggestions:', error.message);\n }\n }\n\n async ensureOllamaReady() {\n if (!window.api?.apiKeyHeader) return false;\n\n try {\n this._updateConnectionState('connecting', 'Ensuring Ollama is ready');\n\n const result = await this._executeOperation(\n 'ollama_ensure_ready',\n async () => {\n return await window.api.apiKeyHeader.ensureOllamaReady();\n },\n { timeout: this.operationTimeout }\n );\n\n if (result?.success) {\n await this.refreshOllamaStatus();\n this._updateConnectionState('connected', 'Ollama ready');\n return true;\n } else {\n const errorMsg = `Failed to setup Ollama: ${result?.error || 'Unknown error'}`;\n this._updateConnectionState('failed', errorMsg);\n return false;\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to ensure Ollama ready:', error.message);\n this._updateConnectionState('failed', `Error setting up Ollama: ${error.message}`);\n return false;\n }\n }\n\n async ensureOllamaReadyWithUI() {\n if (!window.api?.apiKeyHeader) return false;\n\n this.installingModel = 'Setting up Ollama';\n this.installProgress = 0;\n this.clearMessages();\n this.requestUpdate();\n\n const progressHandler = (event, data) => {\n // 통합 LocalAI 이벤트에서 Ollama 진행률만 처리\n if (data.service !== 'ollama') return;\n \n let baseProgress = 0;\n let stageTotal = 0;\n\n switch (data.stage) {\n case 'downloading':\n baseProgress = 0;\n stageTotal = 70;\n break;\n case 'mounting':\n baseProgress = 70;\n stageTotal = 10;\n break;\n case 'installing':\n baseProgress = 80;\n stageTotal = 10;\n break;\n case 'linking':\n baseProgress = 90;\n stageTotal = 5;\n break;\n case 'cleanup':\n baseProgress = 95;\n stageTotal = 3;\n break;\n case 'starting':\n baseProgress = 98;\n stageTotal = 2;\n break;\n }\n\n const overallProgress = baseProgress + (data.progress / 100) * stageTotal;\n\n this.installingModel = data.message;\n this.installProgress = Math.round(overallProgress);\n this.requestUpdate();\n };\n\n let operationCompleted = false;\n const completionTimeout = setTimeout(async () => {\n if (!operationCompleted) {\n console.log('[ApiKeyHeader] Operation timeout, checking status manually...');\n await this._handleOllamaSetupCompletion(true);\n }\n }, 15000); // 15 second timeout\n\n const completionHandler = async (event, data) => {\n // 통합 LocalAI 이벤트에서 Ollama 완료만 처리\n if (data.service !== 'ollama') return;\n if (operationCompleted) return;\n operationCompleted = true;\n clearTimeout(completionTimeout);\n\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n // installation-complete 이벤트는 성공을 의미\n await this._handleOllamaSetupCompletion(true);\n };\n\n // 통합 LocalAI 이벤트 사용\n window.api.apiKeyHeader.onLocalAIComplete(completionHandler);\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n try {\n let result;\n if (!this.ollamaStatus.installed) {\n console.log('[ApiKeyHeader] Ollama not installed. Starting installation.');\n result = await window.api.apiKeyHeader.installOllama();\n } else {\n console.log('[ApiKeyHeader] Ollama installed. Starting service.');\n result = await window.api.apiKeyHeader.startOllamaService();\n }\n\n // If IPC call succeeds but no event received, handle completion manually\n if (result?.success && !operationCompleted) {\n setTimeout(async () => {\n if (!operationCompleted) {\n operationCompleted = true;\n clearTimeout(completionTimeout);\n await this._handleOllamaSetupCompletion(true);\n }\n }, 2000);\n }\n } catch (error) {\n operationCompleted = true;\n clearTimeout(completionTimeout);\n console.error('[ApiKeyHeader] Ollama setup failed:', error);\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n window.api.apiKeyHeader.removeOnLocalAIComplete(completionHandler);\n await this._handleOllamaSetupCompletion(false, error.message);\n }\n }\n\n async _handleOllamaSetupCompletion(success, errorMessage = null) {\n this.installingModel = null;\n this.installProgress = 0;\n\n if (success) {\n await this.refreshOllamaStatus();\n this.successMessage = '✓ Ollama is ready!';\n } else {\n this.llmError = `*Setup failed: ${errorMessage || 'Unknown error'}`;\n }\n this.messageTimestamp = Date.now();\n this.requestUpdate();\n }\n\n async handleModelInput(e) {\n const modelName = e.target.value.trim();\n this.selectedLlmModel = modelName;\n this.clearMessages();\n\n // Save to user history if it's a valid model name\n if (modelName && modelName.length > 2) {\n this.saveToUserHistory(modelName);\n }\n\n this.requestUpdate();\n }\n\n async handleModelKeyPress(e) {\n if (e.key === 'Enter' && this.selectedLlmModel?.trim()) {\n e.preventDefault();\n console.log(`[ApiKeyHeader] Enter pressed, installing model: ${this.selectedLlmModel}`);\n\n // Check if Ollama is ready first\n const ollamaReady = await this.ensureOllamaReady();\n if (!ollamaReady) {\n this.llmError = '*Failed to setup Ollama';\n this.messageTimestamp = Date.now();\n this.requestUpdate();\n return;\n }\n\n // Install the model\n await this.installModel(this.selectedLlmModel);\n }\n }\n\n loadUserModelHistory() {\n try {\n const saved = localStorage.getItem('ollama-model-history');\n if (saved) {\n this.userModelHistory = JSON.parse(saved);\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load model history:', error);\n this.userModelHistory = [];\n }\n }\n\n saveToUserHistory(modelName) {\n if (!modelName || !modelName.trim()) return;\n\n // Remove if already exists (to move to front)\n this.userModelHistory = this.userModelHistory.filter(m => m !== modelName);\n\n // Add to front\n this.userModelHistory.unshift(modelName);\n\n // Keep only last 20 entries\n this.userModelHistory = this.userModelHistory.slice(0, 20);\n\n // Save to localStorage\n try {\n localStorage.setItem('ollama-model-history', JSON.stringify(this.userModelHistory));\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to save model history:', error);\n }\n }\n\n getCombinedModelSuggestions() {\n const combined = [];\n\n // Add installed models first (from Ollama CLI)\n for (const model of this.modelSuggestions) {\n combined.push({\n name: model.name,\n status: 'installed',\n size: model.size || 'Unknown',\n source: 'installed',\n });\n }\n\n // Add user history models that aren't already installed\n const installedNames = this.modelSuggestions.map(m => m.name);\n for (const modelName of this.userModelHistory) {\n if (!installedNames.includes(modelName)) {\n combined.push({\n name: modelName,\n status: 'history',\n size: 'Unknown',\n source: 'history',\n });\n }\n }\n\n return combined;\n }\n\n async installModel(modelName) {\n if (!modelName?.trim()) {\n throw new Error('Invalid model name');\n }\n\n this.installingModel = modelName;\n this.installProgress = 0;\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) return;\n let progressHandler = null;\n\n try {\n console.log(`[ApiKeyHeader] Installing model via Ollama REST API: ${modelName}`);\n\n // Create robust progress handler with timeout protection\n progressHandler = (event, data) => {\n if (data.service === 'ollama' && data.model === modelName && !this._isOperationCancelled(modelName)) {\n const progress = Math.round(Math.max(0, Math.min(100, data.progress || 0)));\n\n if (progress !== this.installProgress) {\n this.installProgress = progress;\n console.log(`[ApiKeyHeader] API Progress: ${progress}% for ${modelName} (${data.status || 'downloading'})`);\n this.requestUpdate();\n }\n }\n };\n\n // Set up progress tracking - 통합 LocalAI 이벤트 사용\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n // Execute the model pull with timeout\n const installPromise = window.api.apiKeyHeader.pullOllamaModel(modelName);\n const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Installation timeout after 10 minutes')), 600000));\n\n const result = await Promise.race([installPromise, timeoutPromise]);\n\n if (result.success) {\n console.log(`[ApiKeyHeader] Model ${modelName} installed successfully via API`);\n this.installProgress = 100;\n this.requestUpdate();\n\n // Brief pause to show completion\n await new Promise(resolve => setTimeout(resolve, 300));\n\n // Refresh status and show success\n await this.refreshOllamaStatus();\n this.successMessage = `✓ ${modelName} ready`;\n this.messageTimestamp = Date.now();\n } else {\n throw new Error(result.error || 'Installation failed');\n }\n } catch (error) {\n console.error(`[ApiKeyHeader] Model installation failed:`, error);\n this.llmError = `*Failed: ${error.message}`;\n this.messageTimestamp = Date.now();\n } finally {\n // Comprehensive cleanup\n if (progressHandler) {\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n }\n\n this.installingModel = null;\n this.installProgress = 0;\n this.requestUpdate();\n }\n }\n\n _isOperationCancelled(modelName) {\n return !this.installingModel || this.installingModel !== modelName;\n }\n\n async downloadWhisperModel(modelId) {\n if (!modelId?.trim()) {\n console.warn('[ApiKeyHeader] Invalid Whisper model ID');\n return;\n }\n\n console.log(`[ApiKeyHeader] Starting Whisper model download: ${modelId}`);\n\n // Mark as installing\n this.whisperInstallingModels = { ...this.whisperInstallingModels, [modelId]: 0 };\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) return;\n let progressHandler = null;\n\n try {\n // Set up robust progress listener - 통합 LocalAI 이벤트 사용\n progressHandler = (event, data) => {\n if (data.service === 'whisper' && data.model === modelId) {\n const cleanProgress = Math.round(Math.max(0, Math.min(100, data.progress || 0)));\n this.whisperInstallingModels = { ...this.whisperInstallingModels, [modelId]: cleanProgress };\n console.log(`[ApiKeyHeader] Whisper download progress: ${cleanProgress}% for ${modelId}`);\n this.requestUpdate();\n }\n };\n\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n // Start download with timeout protection\n const downloadPromise = window.api.apiKeyHeader.downloadWhisperModel(modelId);\n const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Download timeout after 10 minutes')), 600000));\n\n const result = await Promise.race([downloadPromise, timeoutPromise]);\n\n if (result?.success) {\n this.successMessage = `✓ ${modelId} downloaded successfully`;\n this.messageTimestamp = Date.now();\n console.log(`[ApiKeyHeader] Whisper model ${modelId} downloaded successfully`);\n\n // Auto-select the downloaded model\n this.selectedSttModel = modelId;\n } else {\n this.sttError = `*Failed to download ${modelId}: ${result?.error || 'Unknown error'}`;\n this.messageTimestamp = Date.now();\n console.error(`[ApiKeyHeader] Whisper download failed:`, result?.error);\n }\n } catch (error) {\n console.error(`[ApiKeyHeader] Error downloading Whisper model ${modelId}:`, error);\n this.sttError = `*Error downloading ${modelId}: ${error.message}`;\n this.messageTimestamp = Date.now();\n } finally {\n // Cleanup\n if (progressHandler) {\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n }\n delete this.whisperInstallingModels[modelId];\n this.requestUpdate();\n }\n }\n\n handlePaste(e) {\n e.preventDefault();\n this.clearMessages();\n const clipboardText = (e.clipboardData || window.clipboardData).getData('text');\n console.log('Paste event detected:', clipboardText?.substring(0, 10) + '...');\n\n if (clipboardText) {\n this.apiKey = clipboardText.trim();\n\n const inputElement = e.target;\n inputElement.value = this.apiKey;\n }\n\n this.requestUpdate();\n this.updateComplete.then(() => {\n const inputField = this.shadowRoot?.querySelector('.apikey-input');\n if (inputField) {\n inputField.focus();\n inputField.setSelectionRange(inputField.value.length, inputField.value.length);\n }\n });\n }\n\n handleKeyPress(e) {\n if (e.key === 'Enter') {\n e.preventDefault();\n this.handleSubmit();\n }\n }\n\n //////// after_modelStateService ////////\n async handleSttModelChange(e) {\n const modelId = e.target.value;\n this.selectedSttModel = modelId;\n\n if (modelId && this.sttProvider === 'whisper') {\n // Check if model needs to be downloaded\n const isInstalling = this.whisperInstallingModels[modelId] !== undefined;\n if (!isInstalling) {\n console.log(`[ApiKeyHeader] Auto-installing Whisper model: ${modelId}`);\n await this.downloadWhisperModel(modelId);\n }\n }\n\n this.requestUpdate();\n }\n\n async handleSubmit() {\n console.log('[ApiKeyHeader] handleSubmit: Submitting...');\n\n this.isLoading = true;\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) {\n this.isLoading = false;\n this.llmError = '*API bridge not available';\n this.requestUpdate();\n return;\n }\n\n try {\n // Handle LLM provider\n let llmResult;\n if (this.llmProvider === 'ollama') {\n // For Ollama ensure it's ready and validate model selection\n if (!this.selectedLlmModel?.trim()) {\n throw new Error('Please enter an Ollama model name');\n }\n\n const ollamaReady = await this.ensureOllamaReady();\n if (!ollamaReady) {\n throw new Error('Failed to setup Ollama');\n }\n\n // Check if model is installed, if not install it\n const selectedModel = this.getCombinedModelSuggestions().find(m => m.name === this.selectedLlmModel);\n if (!selectedModel || selectedModel.status !== 'installed') {\n console.log(`[ApiKeyHeader] Installing model ${this.selectedLlmModel}...`);\n await this.installModel(this.selectedLlmModel);\n }\n\n // Validate Ollama is working\n llmResult = await window.api.apiKeyHeader.validateKey({\n provider: 'ollama',\n key: 'local',\n });\n\n if (llmResult.success) {\n // Set the selected model\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'llm',\n modelId: this.selectedLlmModel,\n });\n }\n } else {\n // For other providers, validate API key\n if (!this.llmApiKey.trim()) {\n throw new Error('Please enter LLM API key');\n }\n\n llmResult = await window.api.apiKeyHeader.validateKey({\n provider: this.llmProvider,\n key: this.llmApiKey.trim(),\n });\n\n if (llmResult.success) {\n const config = await window.api.apiKeyHeader.getProviderConfig();\n const providerConfig = config[this.llmProvider];\n if (providerConfig && providerConfig.llmModels.length > 0) {\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'llm',\n modelId: providerConfig.llmModels[0].id,\n });\n }\n }\n }\n\n // Handle STT provider\n let sttResult;\n if (this.sttProvider === 'ollama') {\n // Ollama doesn't support STT yet, so skip or use same as LLM validation\n sttResult = { success: true };\n } else if (this.sttProvider === 'whisper') {\n // For Whisper, just validate it's enabled (model download already handled in handleSttModelChange)\n sttResult = await window.api.apiKeyHeader.validateKey({\n provider: 'whisper',\n key: 'local',\n });\n\n if (sttResult.success && this.selectedSttModel) {\n // Set the selected model\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'stt',\n modelId: this.selectedSttModel,\n });\n }\n } else {\n // For other providers, validate API key\n if (!this.sttApiKey.trim()) {\n throw new Error('Please enter STT API key');\n }\n\n sttResult = await window.api.apiKeyHeader.validateKey({\n provider: this.sttProvider,\n key: this.sttApiKey.trim(),\n });\n\n if (sttResult.success) {\n const config = await window.api.apiKeyHeader.getProviderConfig();\n const providerConfig = config[this.sttProvider];\n if (providerConfig && providerConfig.sttModels.length > 0) {\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'stt',\n modelId: providerConfig.sttModels[0].id,\n });\n }\n }\n }\n\n if (llmResult.success && sttResult.success) {\n console.log('[ApiKeyHeader] handleSubmit: Validation successful.');\n \n // Force refresh the model state to ensure areProvidersConfigured returns true\n setTimeout(async () => {\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n console.log('[ApiKeyHeader] Post-validation providers configured check:', isConfigured);\n \n if (isConfigured) {\n this.startSlideOutAnimation();\n } else {\n console.error('[ApiKeyHeader] Providers still not configured after successful validation');\n this.llmError = '*Configuration error. Please try again.';\n this.isLoading = false;\n this.requestUpdate();\n }\n }, 100);\n } else {\n this.llmError = !llmResult.success ? `*${llmResult.error || 'Invalid API Key'}` : '';\n this.sttError = !sttResult.success ? `*${sttResult.error || 'Invalid'}` : '';\n this.errorMessage = ''; // Do not use the general error message for this\n this.messageTimestamp = Date.now();\n }\n } catch (error) {\n console.error('[ApiKeyHeader] handleSubmit: Error:', error);\n this.llmError = `*${error.message}`;\n this.messageTimestamp = Date.now();\n }\n\n this.isLoading = false;\n this.requestUpdate();\n }\n //////// after_modelStateService ////////\n\n\n ////TODO: 뭔가 넘어가는 애니메이션 로직에 문제가 있음\n startSlideOutAnimation() {\n console.log('[ApiKeyHeader] startSlideOutAnimation: Starting slide out animation.');\n this.classList.add('sliding-out');\n \n // Fallback: if animation doesn't trigger animationend event, force transition\n setTimeout(() => {\n if (this.classList.contains('sliding-out')) {\n console.log('[ApiKeyHeader] Animation fallback triggered - forcing transition');\n this.handleAnimationEnd({ target: this, animationName: 'slideOut' });\n }\n }, 1); // Wait a bit longer than animation duration\n }\n\n handleClose() {\n if (window.api?.common) {\n window.api.common.quitApplication();\n }\n }\n\n //////// after_modelStateService ////////\n handleAnimationEnd(e) {\n if (e.target !== this || !this.classList.contains('sliding-out')) return;\n this.classList.remove('sliding-out');\n this.classList.add('hidden');\n\n console.log('[ApiKeyHeader] handleAnimationEnd: Animation completed, transitioning to next state...');\n\n if (!window.api?.common) {\n console.error('[ApiKeyHeader] handleAnimationEnd: window.api.common not available');\n return;\n }\n\n if (!this.stateUpdateCallback) {\n console.error('[ApiKeyHeader] handleAnimationEnd: stateUpdateCallback not set! This will prevent transition to main window.');\n return;\n }\n\n window.api.common\n .getCurrentUser()\n .then(userState => {\n console.log('[ApiKeyHeader] handleAnimationEnd: User state retrieved:', userState);\n\n // Additional validation for local providers\n return window.api.apiKeyHeader.areProvidersConfigured().then(isConfigured => {\n console.log('[ApiKeyHeader] handleAnimationEnd: Providers configured check:', isConfigured);\n\n if (!isConfigured) {\n console.warn('[ApiKeyHeader] handleAnimationEnd: Providers still not configured, may return to ApiKey screen');\n }\n\n // Call the state update callback\n this.stateUpdateCallback(userState);\n });\n })\n .catch(error => {\n console.error('[ApiKeyHeader] handleAnimationEnd: Error during state transition:', error);\n\n // Fallback: try to call callback with minimal state\n if (this.stateUpdateCallback) {\n console.log('[ApiKeyHeader] handleAnimationEnd: Attempting fallback state transition...');\n this.stateUpdateCallback({ isLoggedIn: false });\n }\n });\n }\n //////// after_modelStateService ////////\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('animationend', this.handleAnimationEnd);\n }\n\n handleMessageFadeEnd(e) {\n if (e.animationName === 'fadeOut') {\n // Clear the message that finished fading\n if (e.target.classList.contains('error-message')) {\n this.errorMessage = '';\n } else if (e.target.classList.contains('success-message')) {\n this.successMessage = '';\n }\n this.messageTimestamp = 0;\n this.requestUpdate();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('animationend', this.handleAnimationEnd);\n\n // Professional cleanup of all resources\n this._performCompleteCleanup();\n }\n\n _performCompleteCleanup() {\n console.log('[ApiKeyHeader] Performing complete cleanup');\n\n // Stop health monitoring\n this._stopHealthMonitoring();\n\n // Cancel all active operations\n this._cancelAllActiveOperations();\n\n // Cancel any ongoing installations when component is destroyed\n if (this.installingModel) {\n this.progressTracker.cancelInstallation(this.installingModel);\n }\n\n // Cleanup event listeners\n if (window.api?.apiKeyHeader) {\n window.api.apiKeyHeader.removeAllListeners();\n }\n\n // Cancel any ongoing downloads\n const downloadingModels = Object.keys(this.whisperInstallingModels);\n if (downloadingModels.length > 0) {\n console.log(`[ApiKeyHeader] Cancelling ${downloadingModels.length} ongoing Whisper downloads`);\n downloadingModels.forEach(modelId => {\n delete this.whisperInstallingModels[modelId];\n });\n }\n\n // Reset state\n this.connectionState = 'disconnected';\n this.retryCount = 0;\n\n console.log('[ApiKeyHeader] Cleanup completed');\n }\n\n /**\n * State machine-based Ollama UI rendering\n */\n _renderOllamaStateUI() {\n const state = this._getOllamaUIState();\n\n switch (state.type) {\n case 'connecting':\n return this._renderConnectingState(state);\n case 'install_required':\n return this._renderInstallRequiredState();\n case 'start_required':\n return this._renderStartRequiredState();\n case 'ready':\n return this._renderReadyState();\n case 'failed':\n return this._renderFailedState(state);\n case 'installing':\n return this._renderInstallingState(state);\n default:\n return this._renderUnknownState();\n }\n }\n\n _getOllamaUIState() {\n // State determination logic\n if (this.connectionState === 'connecting') {\n return { type: 'connecting', message: this.installingModel || 'Connecting to Ollama...' };\n }\n\n if (this.connectionState === 'failed') {\n return { type: 'failed', message: this.errorMessage };\n }\n\n if (this.installingModel && this.installingModel.includes('Ollama')) {\n return { type: 'installing', progress: this.installProgress };\n }\n\n if (!this.ollamaStatus.installed) {\n return { type: 'install_required' };\n }\n\n if (!this.ollamaStatus.running) {\n return { type: 'start_required' };\n }\n\n return { type: 'ready' };\n }\n\n _renderConnectingState(state) {\n return html`\n
\n
\n
\n
\n
\n ${this.installProgress}%\n
\n
\n `;\n }\n\n _renderInstallRequiredState() {\n return html` `;\n }\n\n _renderStartRequiredState() {\n return html` `;\n }\n\n _renderReadyState() {\n return html`\n \n \n \n ${this.getCombinedModelSuggestions().map(\n model => html`\n \n `\n )}\n \n\n \n ${this.renderModelStatus()}\n ${this.installingModel && !this.installingModel.includes('Ollama')\n ? html`\n
\n
\n
\n
\n
\n ${this.installProgress}%\n
\n \n `\n : ''}\n `;\n }\n\n _renderFailedState(state) {\n return html`\n
\n
Connection failed
\n
\n ${state.message || 'Unknown error'}\n
\n this._initializeOllamaConnection()}\n >\n Retry Connection\n \n
\n `;\n }\n\n _renderInstallingState(state) {\n return html`\n
\n
\n
\n
\n
\n ${state.progress}%\n
\n
\n `;\n }\n\n _renderUnknownState() {\n return html`\n
\n
Unknown state - Please refresh
\n
\n `;\n }\n\n renderModelStatus() {\n return '';\n }\n\n shouldFadeMessage(type) {\n const hasMessage = type === 'error' ? this.errorMessage : this.successMessage;\n return hasMessage && this.messageTimestamp > 0 && Date.now() - this.messageTimestamp > 100;\n }\n\n openPrivacyPolicy() {\n console.log('🔊 openPrivacyPolicy ApiKeyHeader');\n if (window.api?.common) {\n window.api.common.openExternal('https://pickle.com/privacy-policy');\n }\n }\n\n render() {\n const llmNeedsApiKey = this.llmProvider !== 'ollama' && this.llmProvider !== 'whisper';\n const sttNeedsApiKey = this.sttProvider !== 'ollama' && this.sttProvider !== 'whisper';\n const llmNeedsModel = this.llmProvider === 'ollama';\n const sttNeedsModel = this.sttProvider === 'whisper';\n\n const isButtonDisabled =\n this.isLoading ||\n this.installingModel ||\n Object.keys(this.whisperInstallingModels).length > 0 ||\n (llmNeedsApiKey && !this.llmApiKey.trim()) ||\n (sttNeedsApiKey && !this.sttApiKey.trim()) ||\n (llmNeedsModel && !this.selectedLlmModel?.trim()) ||\n (sttNeedsModel && !this.selectedSttModel);\n\n const llmProviderName = this.providers.llm.find(p => p.id === this.llmProvider)?.name || this.llmProvider;\n\n return html`\n
\n \n
\n
\n \n
Back
\n
\n
Use Personal API keys
\n
\n\n \n
\n
\n
1. Select LLM Provider
\n
\n ${this.providers.llm.map(\n p => html`\n this.handleLlmProviderChange(e, p.id)}\n >\n ${p.name}\n \n `\n )}\n
\n
\n
\n
2. Enter API Key
\n ${this.llmProvider === 'ollama'\n ? this._renderOllamaStateUI()\n : html`\n
\n {\n this.llmApiKey = e.target.value;\n this.llmError = '';\n }}\n ?disabled=${this.isLoading}\n />\n ${this.llmError ? html`
${this.llmError}
` : ''}\n
\n `}\n
\n
\n\n \n
\n
\n
3. Select STT Provider
\n
\n ${this.providers.stt.map(\n p => html`\n this.handleSttProviderChange(e, p.id)}\n >\n ${p.name}\n \n `\n )}\n
\n
\n
\n
4. Enter STT API Key
\n ${this.sttProvider === 'ollama'\n ? html`\n
\n STT not supported by Ollama\n
\n `\n : this.sttProvider === 'whisper'\n ? html`\n
\n {\n this.handleSttModelChange(e);\n this.sttError = '';\n }}\n ?disabled=${this.isLoading}\n >\n \n ${[\n { id: 'whisper-tiny', name: 'Whisper Tiny (39M)' },\n { id: 'whisper-base', name: 'Whisper Base (74M)' },\n { id: 'whisper-small', name: 'Whisper Small (244M)' },\n { id: 'whisper-medium', name: 'Whisper Medium (769M)' },\n ].map(model => html` `)}\n \n ${this.sttError ? html`
${this.sttError}
` : ''}\n
\n `\n : html`\n
\n {\n this.sttApiKey = e.target.value;\n this.sttError = '';\n }}\n ?disabled=${this.isLoading}\n />\n ${this.sttError ? html`
${this.sttError}
` : ''}\n
\n `}\n
\n
\n
\n \n
\n\n
\n Get your API key from: OpenAI | Google | Anthropic\n
\n Glass does not collect your personal data —\n See details\n
\n\n
\n ${this.errorMessage}\n
\n \n ${this.successMessage}\n
\n \n `;\n }\n}\n\ncustomElements.define('apikey-header', ApiKeyHeader);\n"], ["/glass/src/features/ask/askService.js", "const { BrowserWindow } = require('electron');\nconst { createStreamingLLM } = require('../common/ai/factory');\n// Lazy require helper to avoid circular dependency issues\nconst getWindowManager = () => require('../../window/windowManager');\nconst internalBridge = require('../../bridge/internalBridge');\n\nconst getWindowPool = () => {\n try {\n return getWindowManager().windowPool;\n } catch {\n return null;\n }\n};\n\nconst sessionRepository = require('../common/repositories/session');\nconst askRepository = require('./repositories');\nconst { getSystemPrompt } = require('../common/prompts/promptBuilder');\nconst path = require('node:path');\nconst fs = require('node:fs');\nconst os = require('os');\nconst util = require('util');\nconst execFile = util.promisify(require('child_process').execFile);\nconst { desktopCapturer } = require('electron');\nconst modelStateService = require('../common/services/modelStateService');\n\n// Try to load sharp, but don't fail if it's not available\nlet sharp;\ntry {\n sharp = require('sharp');\n console.log('[AskService] Sharp module loaded successfully');\n} catch (error) {\n console.warn('[AskService] Sharp module not available:', error.message);\n console.warn('[AskService] Screenshot functionality will work with reduced image processing capabilities');\n sharp = null;\n}\nlet lastScreenshot = null;\n\nasync function captureScreenshot(options = {}) {\n if (process.platform === 'darwin') {\n try {\n const tempPath = path.join(os.tmpdir(), `screenshot-${Date.now()}.jpg`);\n\n await execFile('screencapture', ['-x', '-t', 'jpg', tempPath]);\n\n const imageBuffer = await fs.promises.readFile(tempPath);\n await fs.promises.unlink(tempPath);\n\n if (sharp) {\n try {\n // Try using sharp for optimal image processing\n const resizedBuffer = await sharp(imageBuffer)\n .resize({ height: 384 })\n .jpeg({ quality: 80 })\n .toBuffer();\n\n const base64 = resizedBuffer.toString('base64');\n const metadata = await sharp(resizedBuffer).metadata();\n\n lastScreenshot = {\n base64,\n width: metadata.width,\n height: metadata.height,\n timestamp: Date.now(),\n };\n\n return { success: true, base64, width: metadata.width, height: metadata.height };\n } catch (sharpError) {\n console.warn('Sharp module failed, falling back to basic image processing:', sharpError.message);\n }\n }\n \n // Fallback: Return the original image without resizing\n console.log('[AskService] Using fallback image processing (no resize/compression)');\n const base64 = imageBuffer.toString('base64');\n \n lastScreenshot = {\n base64,\n width: null, // We don't have metadata without sharp\n height: null,\n timestamp: Date.now(),\n };\n\n return { success: true, base64, width: null, height: null };\n } catch (error) {\n console.error('Failed to capture screenshot:', error);\n return { success: false, error: error.message };\n }\n }\n\n try {\n const sources = await desktopCapturer.getSources({\n types: ['screen'],\n thumbnailSize: {\n width: 1920,\n height: 1080,\n },\n });\n\n if (sources.length === 0) {\n throw new Error('No screen sources available');\n }\n const source = sources[0];\n const buffer = source.thumbnail.toJPEG(70);\n const base64 = buffer.toString('base64');\n const size = source.thumbnail.getSize();\n\n return {\n success: true,\n base64,\n width: size.width,\n height: size.height,\n };\n } catch (error) {\n console.error('Failed to capture screenshot using desktopCapturer:', error);\n return {\n success: false,\n error: error.message,\n };\n }\n}\n\n/**\n * @class\n * @description\n */\nclass AskService {\n constructor() {\n this.abortController = null;\n this.state = {\n isVisible: false,\n isLoading: false,\n isStreaming: false,\n currentQuestion: '',\n currentResponse: '',\n showTextInput: true,\n };\n console.log('[AskService] Service instance created.');\n }\n\n _broadcastState() {\n const askWindow = getWindowPool()?.get('ask');\n if (askWindow && !askWindow.isDestroyed()) {\n askWindow.webContents.send('ask:stateUpdate', this.state);\n }\n }\n\n async toggleAskButton(inputScreenOnly = false) {\n const askWindow = getWindowPool()?.get('ask');\n\n let shouldSendScreenOnly = false;\n if (inputScreenOnly && this.state.showTextInput && askWindow && askWindow.isVisible()) {\n shouldSendScreenOnly = true;\n await this.sendMessage('', []);\n return;\n }\n\n const hasContent = this.state.isLoading || this.state.isStreaming || (this.state.currentResponse && this.state.currentResponse.length > 0);\n\n if (askWindow && askWindow.isVisible() && hasContent) {\n this.state.showTextInput = !this.state.showTextInput;\n this._broadcastState();\n } else {\n if (askWindow && askWindow.isVisible()) {\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: false });\n this.state.isVisible = false;\n } else {\n console.log('[AskService] Showing hidden Ask window');\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: true });\n this.state.isVisible = true;\n }\n if (this.state.isVisible) {\n this.state.showTextInput = true;\n this._broadcastState();\n }\n }\n }\n\n async closeAskWindow () {\n if (this.abortController) {\n this.abortController.abort('Window closed by user');\n this.abortController = null;\n }\n \n this.state = {\n isVisible : false,\n isLoading : false,\n isStreaming : false,\n currentQuestion: '',\n currentResponse: '',\n showTextInput : true,\n };\n this._broadcastState();\n \n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: false });\n \n return { success: true };\n }\n \n\n /**\n * \n * @param {string[]} conversationTexts\n * @returns {string}\n * @private\n */\n _formatConversationForPrompt(conversationTexts) {\n if (!conversationTexts || conversationTexts.length === 0) {\n return 'No conversation history available.';\n }\n return conversationTexts.slice(-30).join('\\n');\n }\n\n /**\n * \n * @param {string} userPrompt\n * @returns {Promise<{success: boolean, response?: string, error?: string}>}\n */\n async sendMessage(userPrompt, conversationHistoryRaw=[]) {\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: true });\n this.state = {\n ...this.state,\n isLoading: true,\n isStreaming: false,\n currentQuestion: userPrompt,\n currentResponse: '',\n showTextInput: false,\n };\n this._broadcastState();\n\n if (this.abortController) {\n this.abortController.abort('New request received.');\n }\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n\n\n let sessionId;\n\n try {\n console.log(`[AskService] 🤖 Processing message: ${userPrompt.substring(0, 50)}...`);\n\n sessionId = await sessionRepository.getOrCreateActive('ask');\n await askRepository.addAiMessage({ sessionId, role: 'user', content: userPrompt.trim() });\n console.log(`[AskService] DB: Saved user prompt to session ${sessionId}`);\n \n const modelInfo = await modelStateService.getCurrentModelInfo('llm');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key not configured.');\n }\n console.log(`[AskService] Using model: ${modelInfo.model} for provider: ${modelInfo.provider}`);\n\n const screenshotResult = await captureScreenshot({ quality: 'medium' });\n const screenshotBase64 = screenshotResult.success ? screenshotResult.base64 : null;\n\n const conversationHistory = this._formatConversationForPrompt(conversationHistoryRaw);\n\n const systemPrompt = getSystemPrompt('pickle_glass_analysis', conversationHistory, false);\n\n const messages = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: [\n { type: 'text', text: `User Request: ${userPrompt.trim()}` },\n ],\n },\n ];\n\n if (screenshotBase64) {\n messages[1].content.push({\n type: 'image_url',\n image_url: { url: `data:image/jpeg;base64,${screenshotBase64}` },\n });\n }\n \n const streamingLLM = createStreamingLLM(modelInfo.provider, {\n apiKey: modelInfo.apiKey,\n model: modelInfo.model,\n temperature: 0.7,\n maxTokens: 2048,\n usePortkey: modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: modelInfo.provider === 'openai-glass' ? modelInfo.apiKey : undefined,\n });\n\n try {\n const response = await streamingLLM.streamChat(messages);\n const askWin = getWindowPool()?.get('ask');\n\n if (!askWin || askWin.isDestroyed()) {\n console.error(\"[AskService] Ask window is not available to send stream to.\");\n response.body.getReader().cancel();\n return { success: false, error: 'Ask window is not available.' };\n }\n\n const reader = response.body.getReader();\n signal.addEventListener('abort', () => {\n console.log(`[AskService] Aborting stream reader. Reason: ${signal.reason}`);\n reader.cancel(signal.reason).catch(() => { /* 이미 취소된 경우의 오류는 무시 */ });\n });\n\n await this._processStream(reader, askWin, sessionId, signal);\n return { success: true };\n\n } catch (multimodalError) {\n // 멀티모달 요청이 실패했고 스크린샷이 포함되어 있다면 텍스트만으로 재시도\n if (screenshotBase64 && this._isMultimodalError(multimodalError)) {\n console.log(`[AskService] Multimodal request failed, retrying with text-only: ${multimodalError.message}`);\n \n // 텍스트만으로 메시지 재구성\n const textOnlyMessages = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: `User Request: ${userPrompt.trim()}`\n }\n ];\n\n const fallbackResponse = await streamingLLM.streamChat(textOnlyMessages);\n const askWin = getWindowPool()?.get('ask');\n\n if (!askWin || askWin.isDestroyed()) {\n console.error(\"[AskService] Ask window is not available for fallback response.\");\n fallbackResponse.body.getReader().cancel();\n return { success: false, error: 'Ask window is not available.' };\n }\n\n const fallbackReader = fallbackResponse.body.getReader();\n signal.addEventListener('abort', () => {\n console.log(`[AskService] Aborting fallback stream reader. Reason: ${signal.reason}`);\n fallbackReader.cancel(signal.reason).catch(() => {});\n });\n\n await this._processStream(fallbackReader, askWin, sessionId, signal);\n return { success: true };\n } else {\n // 다른 종류의 에러이거나 스크린샷이 없었다면 그대로 throw\n throw multimodalError;\n }\n }\n\n } catch (error) {\n console.error('[AskService] Error during message processing:', error);\n this.state = {\n ...this.state,\n isLoading: false,\n isStreaming: false,\n showTextInput: true,\n };\n this._broadcastState();\n\n const askWin = getWindowPool()?.get('ask');\n if (askWin && !askWin.isDestroyed()) {\n const streamError = error.message || 'Unknown error occurred';\n askWin.webContents.send('ask-response-stream-error', { error: streamError });\n }\n\n return { success: false, error: error.message };\n }\n }\n\n /**\n * \n * @param {ReadableStreamDefaultReader} reader\n * @param {BrowserWindow} askWin\n * @param {number} sessionId \n * @param {AbortSignal} signal\n * @returns {Promise}\n * @private\n */\n async _processStream(reader, askWin, sessionId, signal) {\n const decoder = new TextDecoder();\n let fullResponse = '';\n\n try {\n this.state.isLoading = false;\n this.state.isStreaming = true;\n this._broadcastState();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value);\n const lines = chunk.split('\\n').filter(line => line.trim() !== '');\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.substring(6);\n if (data === '[DONE]') {\n return; \n }\n try {\n const json = JSON.parse(data);\n const token = json.choices[0]?.delta?.content || '';\n if (token) {\n fullResponse += token;\n this.state.currentResponse = fullResponse;\n this._broadcastState();\n }\n } catch (error) {\n }\n }\n }\n }\n } catch (streamError) {\n if (signal.aborted) {\n console.log(`[AskService] Stream reading was intentionally cancelled. Reason: ${signal.reason}`);\n } else {\n console.error('[AskService] Error while processing stream:', streamError);\n if (askWin && !askWin.isDestroyed()) {\n askWin.webContents.send('ask-response-stream-error', { error: streamError.message });\n }\n }\n } finally {\n this.state.isStreaming = false;\n this.state.currentResponse = fullResponse;\n this._broadcastState();\n if (fullResponse) {\n try {\n await askRepository.addAiMessage({ sessionId, role: 'assistant', content: fullResponse });\n console.log(`[AskService] DB: Saved partial or full assistant response to session ${sessionId} after stream ended.`);\n } catch(dbError) {\n console.error(\"[AskService] DB: Failed to save assistant response after stream ended:\", dbError);\n }\n }\n }\n }\n\n /**\n * 멀티모달 관련 에러인지 판단\n * @private\n */\n _isMultimodalError(error) {\n const errorMessage = error.message?.toLowerCase() || '';\n return (\n errorMessage.includes('vision') ||\n errorMessage.includes('image') ||\n errorMessage.includes('multimodal') ||\n errorMessage.includes('unsupported') ||\n errorMessage.includes('image_url') ||\n errorMessage.includes('400') || // Bad Request often for unsupported features\n errorMessage.includes('invalid') ||\n errorMessage.includes('not supported')\n );\n }\n\n}\n\nconst askService = new AskService();\n\nmodule.exports = askService;"], ["/glass/src/features/common/services/ollamaService.js", "const { EventEmitter } = require('events');\nconst { spawn, exec } = require('child_process');\nconst { promisify } = require('util');\nconst fetch = require('node-fetch');\nconst path = require('path');\nconst fs = require('fs').promises;\nconst os = require('os');\nconst https = require('https');\nconst crypto = require('crypto');\nconst { app } = require('electron');\nconst { spawnAsync } = require('../utils/spawnHelper');\nconst { DOWNLOAD_CHECKSUMS } = require('../config/checksums');\nconst ollamaModelRepository = require('../repositories/ollamaModel');\n\nconst execAsync = promisify(exec);\n\nclass OllamaService extends EventEmitter {\n constructor() {\n super();\n this.serviceName = 'OllamaService';\n this.baseUrl = 'http://localhost:11434';\n \n // 단순화된 상태 관리\n this.installState = {\n isInstalled: false,\n isInstalling: false,\n progress: 0\n };\n \n // 단순화된 요청 관리 (복잡한 큐 제거)\n this.activeRequest = null;\n this.requestTimeout = 30000; // 30초 타임아웃\n \n // 모델 상태\n this.installedModels = new Map();\n this.modelWarmupStatus = new Map();\n \n // 체크포인트 시스템 (롤백용)\n this.installCheckpoints = [];\n \n // 설치 진행률 관리\n this.installationProgress = new Map();\n \n // 워밍 관련 (기존 유지)\n this.warmingModels = new Map();\n this.warmedModels = new Set();\n this.lastWarmUpAttempt = new Map();\n this.warmupTimeout = 120000; // 120s for model warmup\n \n // 상태 동기화\n this._lastState = null;\n this._syncInterval = null;\n this._lastLoadedModels = [];\n this.modelLoadStatus = new Map();\n \n // 서비스 종료 상태 추적\n this.isShuttingDown = false;\n }\n\n\n // Base class methods integration\n getPlatform() {\n return process.platform;\n }\n\n async checkCommand(command) {\n try {\n const platform = this.getPlatform();\n const checkCmd = platform === 'win32' ? 'where' : 'which';\n const { stdout } = await execAsync(`${checkCmd} ${command}`);\n return stdout.trim();\n } catch (error) {\n return null;\n }\n }\n\n async waitForService(checkFn, maxAttempts = 30, delayMs = 1000) {\n for (let i = 0; i < maxAttempts; i++) {\n if (await checkFn()) {\n console.log(`[${this.serviceName}] Service is ready`);\n return true;\n }\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n throw new Error(`${this.serviceName} service failed to start within timeout`);\n }\n\n getInstallProgress(modelName) {\n return this.installationProgress.get(modelName) || 0;\n }\n\n setInstallProgress(modelName, progress) {\n this.installationProgress.set(modelName, progress);\n }\n\n clearInstallProgress(modelName) {\n this.installationProgress.delete(modelName);\n }\n\n async getStatus() {\n try {\n const installed = await this.isInstalled();\n if (!installed) {\n return { success: true, installed: false, running: false, models: [] };\n }\n\n const running = await this.isServiceRunning();\n if (!running) {\n return { success: true, installed: true, running: false, models: [] };\n }\n\n const models = await this.getInstalledModels();\n return { success: true, installed: true, running: true, models };\n } catch (error) {\n console.error('[OllamaService] Error getting status:', error);\n return { success: false, error: error.message, installed: false, running: false, models: [] };\n }\n }\n\n getOllamaCliPath() {\n if (this.getPlatform() === 'darwin') {\n return '/Applications/Ollama.app/Contents/Resources/ollama';\n }\n return 'ollama';\n }\n\n // === 런타임 관리 (단순화) ===\n async makeRequest(endpoint, options = {}) {\n // 서비스 종료 중이면 요청하지 않음\n if (this.isShuttingDown) {\n throw new Error('Service is shutting down');\n }\n \n // 동시 요청 방지 (단순한 잠금)\n if (this.activeRequest) {\n await this.activeRequest;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.requestTimeout);\n\n this.activeRequest = fetch(`${this.baseUrl}${endpoint}`, {\n ...options,\n signal: controller.signal\n }).finally(() => {\n clearTimeout(timeoutId);\n this.activeRequest = null;\n });\n\n return this.activeRequest;\n }\n\n async isInstalled() {\n try {\n const platform = this.getPlatform();\n \n if (platform === 'darwin') {\n try {\n await fs.access('/Applications/Ollama.app');\n return true;\n } catch {\n const ollamaPath = await this.checkCommand(this.getOllamaCliPath());\n return !!ollamaPath;\n }\n } else {\n const ollamaPath = await this.checkCommand(this.getOllamaCliPath());\n return !!ollamaPath;\n }\n } catch (error) {\n console.log('[OllamaService] Ollama not found:', error.message);\n return false;\n }\n }\n\n async isServiceRunning() {\n try {\n // Use /api/ps to check if service is running\n // This is more reliable than /api/tags which may not show models not in memory\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n return response.ok;\n } catch (error) {\n console.log(`[OllamaService] Service health check failed: ${error.message}`);\n return false;\n }\n }\n\n async startService() {\n // 서비스 시작 시 종료 플래그 리셋\n this.isShuttingDown = false;\n \n const platform = this.getPlatform();\n \n try {\n if (platform === 'darwin') {\n try {\n await spawnAsync('open', ['-a', 'Ollama']);\n await this.waitForService(() => this.isServiceRunning());\n return true;\n } catch {\n spawn(this.getOllamaCliPath(), ['serve'], {\n detached: true,\n stdio: 'ignore'\n }).unref();\n await this.waitForService(() => this.isServiceRunning());\n return true;\n }\n } else {\n spawn(this.getOllamaCliPath(), ['serve'], {\n detached: true,\n stdio: 'ignore',\n shell: platform === 'win32'\n }).unref();\n await this.waitForService(() => this.isServiceRunning());\n return true;\n }\n } catch (error) {\n console.error('[OllamaService] Failed to start service:', error);\n throw error;\n }\n }\n\n async stopService() {\n return await this.shutdown();\n }\n\n // Comprehensive health check using multiple endpoints\n async healthCheck() {\n try {\n const checks = {\n serviceRunning: false,\n apiResponsive: false,\n modelsAccessible: false,\n memoryStatus: false\n };\n \n // 1. Basic service check with /api/ps\n try {\n const psResponse = await this.makeRequest('/api/ps', { method: 'GET' });\n checks.serviceRunning = psResponse.ok;\n checks.memoryStatus = psResponse.ok;\n } catch (error) {\n console.log('[OllamaService] /api/ps check failed:', error.message);\n }\n \n // 2. Check if API is responsive with root endpoint\n try {\n const rootResponse = await this.makeRequest('/', { method: 'GET' });\n checks.apiResponsive = rootResponse.ok;\n } catch (error) {\n console.log('[OllamaService] Root endpoint check failed:', error.message);\n }\n \n // 3. Check if models endpoint is accessible\n try {\n const tagsResponse = await this.makeRequest('/api/tags', { method: 'GET' });\n checks.modelsAccessible = tagsResponse.ok;\n } catch (error) {\n console.log('[OllamaService] /api/tags check failed:', error.message);\n }\n \n const allHealthy = Object.values(checks).every(v => v === true);\n \n return {\n healthy: allHealthy,\n checks,\n timestamp: new Date().toISOString()\n };\n } catch (error) {\n console.error('[OllamaService] Health check failed:', error);\n return {\n healthy: false,\n error: error.message,\n timestamp: new Date().toISOString()\n };\n }\n }\n\n async getInstalledModels() {\n // 서비스 종료 중이면 빈 배열 반환\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, returning empty models list');\n return [];\n }\n \n try {\n const response = await this.makeRequest('/api/tags', {\n method: 'GET'\n });\n \n const data = await response.json();\n return data.models || [];\n } catch (error) {\n console.error('[OllamaService] Failed to get installed models:', error.message);\n return [];\n }\n }\n\n // Get models currently loaded in memory using /api/ps\n async getLoadedModels() {\n // 서비스 종료 중이면 빈 배열 반환\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, returning empty loaded models list');\n return [];\n }\n \n try {\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n if (!response.ok) {\n console.log('[OllamaService] Failed to get loaded models via /api/ps');\n return [];\n }\n \n const data = await response.json();\n // Extract model names from running processes\n return (data.models || []).map(m => m.name);\n } catch (error) {\n console.error('[OllamaService] Error getting loaded models:', error);\n return [];\n }\n }\n \n // Get detailed memory info for loaded models\n async getLoadedModelsWithMemoryInfo() {\n try {\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n if (!response.ok) {\n return [];\n }\n \n const data = await response.json();\n // Return full model info including memory usage\n return data.models || [];\n } catch (error) {\n console.error('[OllamaService] Error getting loaded models info:', error);\n return [];\n }\n }\n \n // Check if a specific model is loaded in memory\n async isModelLoaded(modelName) {\n const loadedModels = await this.getLoadedModels();\n return loadedModels.includes(modelName);\n }\n\n async getInstalledModelsList() {\n try {\n const { stdout } = await spawnAsync(this.getOllamaCliPath(), ['list']);\n const lines = stdout.split('\\n').filter(line => line.trim());\n \n // Skip header line (NAME, ID, SIZE, MODIFIED)\n const modelLines = lines.slice(1);\n \n const models = [];\n for (const line of modelLines) {\n if (!line.trim()) continue;\n \n // Parse line: \"model:tag model_id size modified_time\"\n const parts = line.split(/\\s+/);\n if (parts.length >= 3) {\n models.push({\n name: parts[0],\n id: parts[1],\n size: parts[2] + (parts[3] === 'GB' || parts[3] === 'MB' ? ' ' + parts[3] : ''),\n status: 'installed'\n });\n }\n }\n \n return models;\n } catch (error) {\n console.log('[OllamaService] Failed to get installed models via CLI, falling back to API');\n // Fallback to API if CLI fails\n const apiModels = await this.getInstalledModels();\n return apiModels.map(model => ({\n name: model.name,\n id: model.digest || 'unknown',\n size: model.size || 'Unknown',\n status: 'installed'\n }));\n }\n }\n\n async getModelSuggestions() {\n try {\n // Get actually installed models\n const installedModels = await this.getInstalledModelsList();\n \n // Get user input history from storage (we'll implement this in the frontend)\n // For now, just return installed models\n return installedModels;\n } catch (error) {\n console.error('[OllamaService] Failed to get model suggestions:', error);\n return [];\n }\n }\n\n async isModelInstalled(modelName) {\n const models = await this.getInstalledModels();\n return models.some(model => model.name === modelName);\n }\n\n async pullModel(modelName) {\n if (!modelName?.trim()) {\n throw new Error(`Invalid model name: ${modelName}`);\n }\n\n console.log(`[OllamaService] Starting to pull model: ${modelName} via API`);\n \n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelName, \n progress: 0,\n status: 'starting'\n });\n \n try {\n const response = await fetch(`${this.baseUrl}/api/pull`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n stream: true\n })\n });\n\n if (!response.ok) {\n throw new Error(`Pull API failed: ${response.status} ${response.statusText}`);\n }\n\n // Handle Node.js streaming response\n return new Promise((resolve, reject) => {\n let buffer = '';\n \n response.body.on('data', (chunk) => {\n buffer += chunk.toString();\n const lines = buffer.split('\\n');\n \n // Keep incomplete line in buffer\n buffer = lines.pop() || '';\n \n // Process complete lines\n for (const line of lines) {\n if (!line.trim()) continue;\n \n try {\n const data = JSON.parse(line);\n const progress = this._parseOllamaPullProgress(data, modelName);\n \n if (progress !== null) {\n this.setInstallProgress(modelName, progress);\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelName, \n progress,\n status: data.status || 'downloading'\n });\n console.log(`[OllamaService] API Progress: ${progress}% for ${modelName} (${data.status || 'downloading'})`);\n }\n\n // Handle completion\n if (data.status === 'success') {\n console.log(`[OllamaService] Successfully pulled model: ${modelName}`);\n this.emit('model-pull-complete', { model: modelName });\n this.clearInstallProgress(modelName);\n resolve();\n return;\n }\n } catch (parseError) {\n console.warn('[OllamaService] Failed to parse response line:', line);\n }\n }\n });\n\n response.body.on('end', () => {\n // Process any remaining data in buffer\n if (buffer.trim()) {\n try {\n const data = JSON.parse(buffer);\n if (data.status === 'success') {\n console.log(`[OllamaService] Successfully pulled model: ${modelName}`);\n this.emit('model-pull-complete', { model: modelName });\n }\n } catch (parseError) {\n console.warn('[OllamaService] Failed to parse final buffer:', buffer);\n }\n }\n this.clearInstallProgress(modelName);\n resolve();\n });\n\n response.body.on('error', (error) => {\n console.error(`[OllamaService] Stream error for ${modelName}:`, error);\n this.clearInstallProgress(modelName);\n reject(error);\n });\n });\n } catch (error) {\n this.clearInstallProgress(modelName);\n console.error(`[OllamaService] Pull model failed:`, error);\n throw error;\n }\n }\n\n _parseOllamaPullProgress(data, modelName) {\n // Handle Ollama API response format\n if (data.status === 'success') {\n return 100;\n }\n\n // Handle downloading progress\n if (data.total && data.completed !== undefined) {\n const progress = Math.round((data.completed / data.total) * 100);\n return Math.min(progress, 99); // Don't show 100% until success\n }\n\n // Handle status-based progress\n const statusProgress = {\n 'pulling manifest': 5,\n 'downloading': 10,\n 'verifying sha256 digest': 90,\n 'writing manifest': 95,\n 'removing any unused layers': 98\n };\n\n if (data.status && statusProgress[data.status] !== undefined) {\n return statusProgress[data.status];\n }\n\n return null;\n }\n\n\n\n async downloadFile(url, destination, options = {}) {\n const { \n onProgress = null,\n headers = { 'User-Agent': 'Glass-App' },\n timeout = 300000,\n modelId = null\n } = options;\n\n return new Promise((resolve, reject) => {\n const file = require('fs').createWriteStream(destination);\n let downloadedSize = 0;\n let totalSize = 0;\n\n const request = https.get(url, { headers }, (response) => {\n if ([301, 302, 307, 308].includes(response.statusCode)) {\n file.close();\n require('fs').unlink(destination, () => {});\n \n if (!response.headers.location) {\n reject(new Error('Redirect without location header'));\n return;\n }\n \n console.log(`[${this.serviceName}] Following redirect from ${url} to ${response.headers.location}`);\n this.downloadFile(response.headers.location, destination, options)\n .then(resolve)\n .catch(reject);\n return;\n }\n\n if (response.statusCode !== 200) {\n file.close();\n require('fs').unlink(destination, () => {});\n reject(new Error(`Download failed: ${response.statusCode} ${response.statusMessage}`));\n return;\n }\n\n totalSize = parseInt(response.headers['content-length'], 10) || 0;\n\n response.on('data', (chunk) => {\n downloadedSize += chunk.length;\n \n if (totalSize > 0) {\n const progress = Math.round((downloadedSize / totalSize) * 100);\n \n if (onProgress) {\n onProgress(progress, downloadedSize, totalSize);\n }\n }\n });\n\n response.pipe(file);\n\n file.on('finish', () => {\n file.close(() => {\n resolve({ success: true, size: downloadedSize });\n });\n });\n });\n\n request.on('timeout', () => {\n request.destroy();\n file.close();\n require('fs').unlink(destination, () => {});\n reject(new Error('Download timeout'));\n });\n\n request.on('error', (err) => {\n file.close();\n require('fs').unlink(destination, () => {});\n this.emit('download-error', { url, error: err, modelId });\n reject(err);\n });\n\n request.setTimeout(timeout);\n\n file.on('error', (err) => {\n require('fs').unlink(destination, () => {});\n reject(err);\n });\n });\n }\n\n async downloadWithRetry(url, destination, options = {}) {\n const { \n maxRetries = 3, \n retryDelay = 1000, \n expectedChecksum = null,\n modelId = null,\n ...downloadOptions \n } = options;\n \n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n try {\n const result = await this.downloadFile(url, destination, { \n ...downloadOptions, \n modelId \n });\n \n if (expectedChecksum) {\n const isValid = await this.verifyChecksum(destination, expectedChecksum);\n if (!isValid) {\n require('fs').unlinkSync(destination);\n throw new Error('Checksum verification failed');\n }\n console.log(`[${this.serviceName}] Checksum verified successfully`);\n }\n \n return result;\n } catch (error) {\n if (attempt === maxRetries) {\n throw error;\n }\n \n console.log(`Download attempt ${attempt} failed, retrying in ${retryDelay}ms...`);\n await new Promise(resolve => setTimeout(resolve, retryDelay * attempt));\n }\n }\n }\n\n async verifyChecksum(filePath, expectedChecksum) {\n return new Promise((resolve, reject) => {\n const hash = crypto.createHash('sha256');\n const stream = require('fs').createReadStream(filePath);\n \n stream.on('data', (data) => hash.update(data));\n stream.on('end', () => {\n const fileChecksum = hash.digest('hex');\n console.log(`[${this.serviceName}] File checksum: ${fileChecksum}`);\n console.log(`[${this.serviceName}] Expected checksum: ${expectedChecksum}`);\n resolve(fileChecksum === expectedChecksum);\n });\n stream.on('error', reject);\n });\n }\n\n async autoInstall(onProgress) {\n const platform = this.getPlatform();\n console.log(`[${this.serviceName}] Starting auto-installation for ${platform}`);\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.installMacOS(onProgress);\n case 'win32':\n return await this.installWindows(onProgress);\n case 'linux':\n return await this.installLinux();\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Auto-installation failed:`, error);\n throw error;\n }\n }\n\n async installMacOS(onProgress) {\n console.log('[OllamaService] Installing Ollama on macOS using DMG...');\n \n try {\n const dmgUrl = 'https://ollama.com/download/Ollama.dmg';\n const tempDir = app.getPath('temp');\n const dmgPath = path.join(tempDir, 'Ollama.dmg');\n const mountPoint = path.join(tempDir, 'OllamaMount');\n\n // 체크포인트 저장\n await this.saveCheckpoint('pre-install');\n\n console.log('[OllamaService] Step 1: Downloading Ollama DMG...');\n onProgress?.({ stage: 'downloading', message: 'Downloading Ollama installer...', progress: 0 });\n const checksumInfo = DOWNLOAD_CHECKSUMS.ollama.dmg;\n await this.downloadWithRetry(dmgUrl, dmgPath, {\n expectedChecksum: checksumInfo?.sha256,\n onProgress: (progress) => {\n onProgress?.({ stage: 'downloading', message: `Downloading... ${progress}%`, progress });\n }\n });\n \n await this.saveCheckpoint('post-download');\n \n console.log('[OllamaService] Step 2: Mounting DMG...');\n onProgress?.({ stage: 'mounting', message: 'Mounting disk image...', progress: 0 });\n await fs.mkdir(mountPoint, { recursive: true });\n await spawnAsync('hdiutil', ['attach', dmgPath, '-mountpoint', mountPoint]);\n onProgress?.({ stage: 'mounting', message: 'Disk image mounted.', progress: 100 });\n \n console.log('[OllamaService] Step 3: Installing Ollama.app...');\n onProgress?.({ stage: 'installing', message: 'Installing Ollama application...', progress: 0 });\n await spawnAsync('cp', ['-R', `${mountPoint}/Ollama.app`, '/Applications/']);\n onProgress?.({ stage: 'installing', message: 'Application installed.', progress: 100 });\n \n await this.saveCheckpoint('post-install');\n \n console.log('[OllamaService] Step 4: Setting up CLI path...');\n onProgress?.({ stage: 'linking', message: 'Creating command-line shortcut...', progress: 0 });\n try {\n const script = `do shell script \"mkdir -p /usr/local/bin && ln -sf '${this.getOllamaCliPath()}' '/usr/local/bin/ollama'\" with administrator privileges`;\n await spawnAsync('osascript', ['-e', script]);\n onProgress?.({ stage: 'linking', message: 'Shortcut created.', progress: 100 });\n } catch (linkError) {\n console.error('[OllamaService] CLI symlink creation failed:', linkError.message);\n onProgress?.({ stage: 'linking', message: 'Shortcut creation failed (permissions?).', progress: 100 });\n // Not throwing an error, as the app might still work\n }\n \n console.log('[OllamaService] Step 5: Cleanup...');\n onProgress?.({ stage: 'cleanup', message: 'Cleaning up installation files...', progress: 0 });\n await spawnAsync('hdiutil', ['detach', mountPoint]);\n await fs.unlink(dmgPath).catch(() => {});\n await fs.rmdir(mountPoint).catch(() => {});\n onProgress?.({ stage: 'cleanup', message: 'Cleanup complete.', progress: 100 });\n \n console.log('[OllamaService] Ollama installed successfully on macOS');\n \n await new Promise(resolve => setTimeout(resolve, 2000));\n \n return true;\n } catch (error) {\n console.error('[OllamaService] macOS installation failed:', error);\n // 설치 실패 시 정리\n await fs.unlink(dmgPath).catch(() => {});\n throw new Error(`Failed to install Ollama on macOS: ${error.message}`);\n }\n }\n\n async installWindows(onProgress) {\n console.log('[OllamaService] Installing Ollama on Windows...');\n \n try {\n const exeUrl = 'https://ollama.com/download/OllamaSetup.exe';\n const tempDir = app.getPath('temp');\n const exePath = path.join(tempDir, 'OllamaSetup.exe');\n\n console.log('[OllamaService] Step 1: Downloading Ollama installer...');\n onProgress?.({ stage: 'downloading', message: 'Downloading Ollama installer...', progress: 0 });\n const checksumInfo = DOWNLOAD_CHECKSUMS.ollama.exe;\n await this.downloadWithRetry(exeUrl, exePath, {\n expectedChecksum: checksumInfo?.sha256,\n onProgress: (progress) => {\n onProgress?.({ stage: 'downloading', message: `Downloading... ${progress}%`, progress });\n }\n });\n \n console.log('[OllamaService] Step 2: Running silent installation...');\n onProgress?.({ stage: 'installing', message: 'Installing Ollama...', progress: 0 });\n await spawnAsync(exePath, ['/VERYSILENT', '/NORESTART']);\n onProgress?.({ stage: 'installing', message: 'Installation complete.', progress: 100 });\n \n console.log('[OllamaService] Step 3: Cleanup...');\n onProgress?.({ stage: 'cleanup', message: 'Cleaning up installation files...', progress: 0 });\n await fs.unlink(exePath).catch(() => {});\n onProgress?.({ stage: 'cleanup', message: 'Cleanup complete.', progress: 100 });\n \n console.log('[OllamaService] Ollama installed successfully on Windows');\n \n await new Promise(resolve => setTimeout(resolve, 3000));\n \n return true;\n } catch (error) {\n console.error('[OllamaService] Windows installation failed:', error);\n throw new Error(`Failed to install Ollama on Windows: ${error.message}`);\n }\n }\n\n async installLinux() {\n console.log('[OllamaService] Installing Ollama on Linux...');\n console.log('[OllamaService] Automatic installation on Linux is not supported for security reasons.');\n console.log('[OllamaService] Please install Ollama manually:');\n console.log('[OllamaService] 1. Visit https://ollama.com/download/linux');\n console.log('[OllamaService] 2. Follow the official installation instructions');\n console.log('[OllamaService] 3. Or use your package manager if available');\n throw new Error('Manual installation required on Linux. Please visit https://ollama.com/download/linux');\n }\n\n // === 체크포인트 & 롤백 시스템 ===\n async saveCheckpoint(name) {\n this.installCheckpoints.push({\n name,\n timestamp: Date.now(),\n state: { ...this.installState }\n });\n }\n\n async rollbackToLastCheckpoint() {\n const checkpoint = this.installCheckpoints.pop();\n if (checkpoint) {\n console.log(`[OllamaService] Rolling back to checkpoint: ${checkpoint.name}`);\n // 플랫폼별 롤백 로직 실행\n await this._executeRollback(checkpoint);\n }\n }\n\n async _executeRollback(checkpoint) {\n const platform = this.getPlatform();\n \n if (platform === 'darwin' && checkpoint.name === 'post-install') {\n // macOS 롤백\n await fs.rm('/Applications/Ollama.app', { recursive: true, force: true }).catch(() => {});\n } else if (platform === 'win32') {\n // Windows 롤백 (레지스트리 등)\n // TODO: Windows 롤백 구현\n }\n \n this.installState = checkpoint.state;\n }\n\n // === 상태 동기화 (내부 처리) ===\n async syncState() {\n // 서비스 종료 중이면 스킵\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, skipping state sync');\n return this.installState;\n }\n \n try {\n const isInstalled = await this.isInstalled();\n const isRunning = await this.isServiceRunning();\n const models = isRunning && !this.isShuttingDown ? await this.getInstalledModels() : [];\n const loadedModels = isRunning && !this.isShuttingDown ? await this.getLoadedModels() : [];\n \n // 상태 업데이트\n this.installState.isInstalled = isInstalled;\n this.installState.isRunning = isRunning;\n this.installState.lastSync = Date.now();\n \n // 메모리 로드 상태 추적\n const previousLoadedModels = this._lastLoadedModels || [];\n const loadedChanged = loadedModels.length !== previousLoadedModels.length || \n !loadedModels.every(m => previousLoadedModels.includes(m));\n \n if (loadedChanged) {\n console.log(`[OllamaService] Loaded models changed: ${loadedModels.join(', ')}`);\n this._lastLoadedModels = loadedModels;\n \n // 메모리에서 언로드된 모델의 warmed 상태 제거\n for (const modelName of this.warmedModels) {\n if (!loadedModels.includes(modelName)) {\n this.warmedModels.delete(modelName);\n console.log(`[OllamaService] Model ${modelName} unloaded from memory, removing warmed state`);\n }\n }\n }\n \n // 모델 상태 DB 업데이트\n if (isRunning && models.length > 0) {\n for (const model of models) {\n try {\n const isLoaded = loadedModels.includes(model.name);\n // DB에는 installed 상태만 저장, loaded 상태는 메모리에서 관리\n await ollamaModelRepository.updateInstallStatus(model.name, true, false);\n \n // 로드 상태를 인스턴스 변수에 저장\n if (!this.modelLoadStatus) {\n this.modelLoadStatus = new Map();\n }\n this.modelLoadStatus.set(model.name, isLoaded);\n } catch (dbError) {\n console.warn(`[OllamaService] Failed to update DB for model ${model.name}:`, dbError);\n }\n }\n }\n \n // UI 알림 (상태 변경 시만)\n if (this._lastState?.isRunning !== isRunning || \n this._lastState?.isInstalled !== isInstalled ||\n loadedChanged) {\n // Emit state change event - LocalAIManager가 처리\n this.emit('state-changed', {\n installed: isInstalled,\n running: isRunning,\n models: models.length,\n loadedModels: loadedModels\n });\n }\n \n this._lastState = { isInstalled, isRunning, modelsCount: models.length };\n return { isInstalled, isRunning, models };\n \n } catch (error) {\n console.error('[OllamaService] State sync failed:', error);\n return { \n isInstalled: this.installState.isInstalled || false,\n isRunning: false,\n models: []\n };\n }\n }\n\n // 주기적 동기화 시작\n startPeriodicSync() {\n if (this._syncInterval) return;\n \n this._syncInterval = setInterval(() => {\n this.syncState();\n }, 30000); // 30초마다\n }\n\n stopPeriodicSync() {\n if (this._syncInterval) {\n clearInterval(this._syncInterval);\n this._syncInterval = null;\n }\n }\n\n async warmUpModel(modelName, forceRefresh = false) {\n if (!modelName?.trim()) {\n console.warn(`[OllamaService] Invalid model name for warm-up`);\n return false;\n }\n\n // Check if already warmed (and not forcing refresh)\n if (!forceRefresh && this.warmedModels.has(modelName)) {\n console.log(`[OllamaService] Model ${modelName} already warmed up, skipping`);\n return true;\n }\n\n // Check if currently warming - return existing Promise\n if (this.warmingModels.has(modelName)) {\n console.log(`[OllamaService] Model ${modelName} is already warming up, joining existing operation`);\n return await this.warmingModels.get(modelName);\n }\n\n // Check rate limiting (prevent too frequent attempts)\n const lastAttempt = this.lastWarmUpAttempt.get(modelName);\n const now = Date.now();\n if (lastAttempt && (now - lastAttempt) < 5000) { // 5 second cooldown\n console.log(`[OllamaService] Rate limiting warm-up for ${modelName}, try again in ${5 - Math.floor((now - lastAttempt) / 1000)}s`);\n return false;\n }\n\n // Create and store the warming Promise\n const warmingPromise = this._performWarmUp(modelName);\n this.warmingModels.set(modelName, warmingPromise);\n this.lastWarmUpAttempt.set(modelName, now);\n\n try {\n const result = await warmingPromise;\n \n if (result) {\n this.warmedModels.add(modelName);\n console.log(`[OllamaService] Model ${modelName} successfully warmed up`);\n }\n \n return result;\n } finally {\n // Always clean up the warming Promise\n this.warmingModels.delete(modelName);\n }\n }\n\n async _performWarmUp(modelName) {\n console.log(`[OllamaService] Starting warm-up for model: ${modelName}`);\n \n try {\n const response = await this.makeRequest('/api/chat', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n messages: [\n { role: 'user', content: 'Hi' }\n ],\n stream: false,\n options: {\n num_predict: 1, // Minimal response\n temperature: 0\n }\n })\n });\n\n return true;\n } catch (error) {\n // Check if it's a 404 error (model not found/installed)\n if (error.message.includes('HTTP 404') || error.message.includes('Not Found')) {\n console.log(`[OllamaService] Model ${modelName} not found (404), attempting to install...`);\n \n try {\n // Try to install the model\n await this.pullModel(modelName);\n console.log(`[OllamaService] Successfully installed model ${modelName}, retrying warm-up...`);\n \n // Update database to reflect installation\n await ollamaModelRepository.updateInstallStatus(modelName, true, false);\n \n // Retry warm-up after installation\n const retryResponse = await this.makeRequest('/api/chat', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n messages: [\n { role: 'user', content: 'Hi' }\n ],\n stream: false,\n options: {\n num_predict: 1,\n temperature: 0\n }\n })\n });\n \n console.log(`[OllamaService] Successfully warmed up model ${modelName} after installation`);\n return true;\n \n } catch (installError) {\n console.error(`[OllamaService] Failed to auto-install model ${modelName}:`, installError.message);\n await ollamaModelRepository.updateInstallStatus(modelName, false, false);\n return false;\n }\n } else {\n console.error(`[OllamaService] Failed to warm up model ${modelName}:`, error.message);\n return false;\n }\n }\n }\n\n async autoWarmUpSelectedModel() {\n try {\n // Get selected model from ModelStateService\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n console.log('[OllamaService] ModelStateService not available for auto warm-up');\n return false;\n }\n\n const selectedModels = await modelStateService.getSelectedModels();\n const llmModelId = selectedModels.llm;\n \n // Check if it's an Ollama model\n const provider = modelStateService.getProviderForModel('llm', llmModelId);\n if (provider !== 'ollama') {\n console.log('[OllamaService] Selected LLM is not Ollama, skipping warm-up');\n return false;\n }\n\n // Check if Ollama service is running\n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log('[OllamaService] Ollama service not running, clearing warm-up cache');\n this._clearWarmUpCache();\n return false;\n }\n\n // 설치 여부 체크 제거 - _performWarmUp에서 자동으로 설치 처리\n console.log(`[OllamaService] Auto-warming up selected model: ${llmModelId} (will auto-install if needed)`);\n const result = await this.warmUpModel(llmModelId);\n \n // 성공 시 LocalAIManager에 알림\n if (result) {\n this.emit('model-warmed-up', { model: llmModelId });\n }\n \n return result;\n \n } catch (error) {\n console.error('[OllamaService] Auto warm-up failed:', error);\n return false;\n }\n }\n\n _clearWarmUpCache() {\n this.warmedModels.clear();\n this.warmingModels.clear();\n this.lastWarmUpAttempt.clear();\n console.log('[OllamaService] Warm-up cache cleared');\n }\n\n async getWarmUpStatus() {\n const loadedModels = await this.getLoadedModels();\n \n return {\n warmedModels: Array.from(this.warmedModels),\n warmingModels: Array.from(this.warmingModels.keys()),\n loadedModels: loadedModels, // Models actually loaded in memory\n lastAttempts: Object.fromEntries(this.lastWarmUpAttempt)\n };\n }\n\n async shutdown(force = false) {\n console.log(`[OllamaService] Shutdown initiated (force: ${force})`);\n \n // 종료 중 플래그 설정\n this.isShuttingDown = true;\n \n if (!force && this.warmingModels.size > 0) {\n const warmingList = Array.from(this.warmingModels.keys());\n console.log(`[OllamaService] Waiting for ${warmingList.length} models to finish warming: ${warmingList.join(', ')}`);\n \n const warmingPromises = Array.from(this.warmingModels.values());\n try {\n // Use Promise.allSettled instead of race with setTimeout\n const results = await Promise.allSettled(warmingPromises);\n const completed = results.filter(r => r.status === 'fulfilled').length;\n console.log(`[OllamaService] ${completed}/${results.length} warming operations completed`);\n } catch (error) {\n console.log('[OllamaService] Error waiting for warm-up completion, proceeding with shutdown');\n }\n }\n\n // Clean up all resources\n this._clearWarmUpCache();\n this.stopPeriodicSync();\n \n // 프로세스 종료\n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log('[OllamaService] Service not running, nothing to shutdown');\n return true;\n }\n\n const platform = this.getPlatform();\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.shutdownMacOS(force);\n case 'win32':\n return await this.shutdownWindows(force);\n case 'linux':\n return await this.shutdownLinux(force);\n default:\n console.warn(`[OllamaService] Unsupported platform for shutdown: ${platform}`);\n return false;\n }\n } catch (error) {\n console.error(`[OllamaService] Error during shutdown:`, error);\n return false;\n }\n }\n\n async shutdownMacOS(force) {\n try {\n // 1. First, try to kill ollama server process\n console.log('[OllamaService] Killing ollama server process...');\n try {\n await spawnAsync('pkill', ['-f', 'ollama serve']);\n } catch (e) {\n // Process might not be running\n }\n \n // 2. Then quit the Ollama.app\n console.log('[OllamaService] Quitting Ollama.app...');\n try {\n await spawnAsync('osascript', ['-e', 'tell application \"Ollama\" to quit']);\n } catch (e) {\n console.log('[OllamaService] Ollama.app might not be running');\n }\n \n // 3. Wait a moment for shutdown\n await new Promise(resolve => setTimeout(resolve, 2000));\n \n // 4. Force kill any remaining ollama processes\n if (force || await this.isServiceRunning()) {\n console.log('[OllamaService] Force killing any remaining ollama processes...');\n try {\n // Kill all ollama processes\n await spawnAsync('pkill', ['-9', '-f', 'ollama']);\n } catch (e) {\n // Ignore errors - process might not exist\n }\n }\n \n // 5. Final check\n await new Promise(resolve => setTimeout(resolve, 1000));\n const stillRunning = await this.isServiceRunning();\n if (stillRunning) {\n console.warn('[OllamaService] Warning: Ollama may still be running');\n return false;\n }\n \n console.log('[OllamaService] Ollama shutdown complete');\n return true;\n } catch (error) {\n console.error('[OllamaService] Shutdown error:', error);\n return false;\n }\n }\n\n async shutdownWindows(force) {\n try {\n // Try to stop the service gracefully\n await spawnAsync('taskkill', ['/IM', 'ollama.exe', '/T']);\n console.log('[OllamaService] Ollama process terminated on Windows');\n return true;\n } catch (error) {\n console.log('[OllamaService] Standard termination failed, trying force kill');\n try {\n await spawnAsync('taskkill', ['/IM', 'ollama.exe', '/F', '/T']);\n return true;\n } catch (killError) {\n console.error('[OllamaService] Failed to force kill Ollama on Windows:', killError);\n return false;\n }\n }\n }\n\n async shutdownLinux(force) {\n try {\n await spawnAsync('pkill', ['-f', this.getOllamaCliPath()]);\n console.log('[OllamaService] Ollama process terminated on Linux');\n return true;\n } catch (error) {\n if (force) {\n await spawnAsync('pkill', ['-9', '-f', this.getOllamaCliPath()]).catch(() => {});\n }\n console.error('[OllamaService] Failed to shutdown Ollama on Linux:', error);\n return false;\n }\n }\n\n async getAllModelsWithStatus() {\n // Get all installed models directly from Ollama\n const installedModels = await this.getInstalledModels();\n \n // Get loaded models from memory\n const loadedModels = await this.getLoadedModels();\n \n const models = [];\n for (const model of installedModels) {\n const isWarmingUp = this.warmingModels.has(model.name);\n const isWarmedUp = this.warmedModels.has(model.name);\n const isLoaded = loadedModels.includes(model.name);\n \n models.push({\n name: model.name,\n displayName: model.name, // Use model name as display name\n size: model.size || 'Unknown',\n description: `Ollama model: ${model.name}`,\n installed: true,\n installing: this.installationProgress.has(model.name),\n progress: this.getInstallProgress(model.name),\n warmedUp: isWarmedUp,\n isWarmingUp,\n isLoaded, // Actually loaded in memory\n status: isWarmingUp ? 'warming' : (isLoaded ? 'loaded' : (isWarmedUp ? 'ready' : 'cold'))\n });\n }\n \n // Also add any models currently being installed\n for (const [modelName, progress] of this.installationProgress) {\n if (!models.find(m => m.name === modelName)) {\n models.push({\n name: modelName,\n displayName: modelName,\n size: 'Unknown',\n description: `Ollama model: ${modelName}`,\n installed: false,\n installing: true,\n progress: progress\n });\n }\n }\n \n return models;\n }\n\n async handleGetStatus() {\n try {\n const installed = await this.isInstalled();\n if (!installed) {\n return { success: true, installed: false, running: false, models: [] };\n }\n\n const running = await this.isServiceRunning();\n if (!running) {\n return { success: true, installed: true, running: false, models: [] };\n }\n\n const models = await this.getAllModelsWithStatus();\n return { success: true, installed: true, running: true, models };\n } catch (error) {\n console.error('[OllamaService] Error getting status:', error);\n return { success: false, error: error.message, installed: false, running: false, models: [] };\n }\n }\n\n async handleInstall() {\n try {\n const onProgress = (data) => {\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', data);\n };\n\n await this.autoInstall(onProgress);\n \n // 설치 검증\n onProgress({ stage: 'verifying', message: 'Verifying installation...', progress: 0 });\n const verifyResult = await this.verifyInstallation();\n if (!verifyResult.success) {\n throw new Error(`Installation verification failed: ${verifyResult.error}`);\n }\n onProgress({ stage: 'verifying', message: 'Installation verified.', progress: 100 });\n\n if (!await this.isServiceRunning()) {\n onProgress({ stage: 'starting', message: 'Starting Ollama service...', progress: 0 });\n await this.startService();\n onProgress({ stage: 'starting', message: 'Ollama service started.', progress: 100 });\n }\n \n this.installState.isInstalled = true;\n // Emit completion event - LocalAIManager가 처리\n this.emit('installation-complete');\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to install:', error);\n await this.rollbackToLastCheckpoint();\n // Emit error event - LocalAIManager가 처리\n this.emit('error', {\n errorType: 'installation-failed',\n error: error.message\n });\n return { success: false, error: error.message };\n }\n }\n\n async handleStartService() {\n try {\n if (!await this.isServiceRunning()) {\n console.log('[OllamaService] Starting Ollama service...');\n await this.startService();\n }\n this.emit('install-complete', { success: true });\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to start service:', error);\n this.emit('install-complete', { success: false, error: error.message });\n return { success: false, error: error.message };\n }\n }\n\n async handleEnsureReady() {\n try {\n if (await this.isInstalled() && !await this.isServiceRunning()) {\n console.log('[OllamaService] Ollama installed but not running, starting service...');\n await this.startService();\n }\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to ensure ready:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetModels() {\n try {\n const models = await this.getAllModelsWithStatus();\n return { success: true, models };\n } catch (error) {\n console.error('[OllamaService] Failed to get models:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetModelSuggestions() {\n try {\n const suggestions = await this.getModelSuggestions();\n return { success: true, suggestions };\n } catch (error) {\n console.error('[OllamaService] Failed to get model suggestions:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handlePullModel(modelName) {\n try {\n console.log(`[OllamaService] Starting model pull: ${modelName}`);\n\n await ollamaModelRepository.updateInstallStatus(modelName, false, true);\n\n await this.pullModel(modelName);\n\n await ollamaModelRepository.updateInstallStatus(modelName, true, false);\n\n console.log(`[OllamaService] Model ${modelName} pull successful`);\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to pull model:', error);\n await ollamaModelRepository.updateInstallStatus(modelName, false, false);\n // Emit error event - LocalAIManager가 처리\n this.emit('error', { \n errorType: 'model-pull-failed',\n model: modelName, \n error: error.message \n });\n return { success: false, error: error.message };\n }\n }\n\n async handleIsModelInstalled(modelName) {\n try {\n const installed = await this.isModelInstalled(modelName);\n return { success: true, installed };\n } catch (error) {\n console.error('[OllamaService] Failed to check model installation:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleWarmUpModel(modelName) {\n try {\n const success = await this.warmUpModel(modelName);\n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to warm up model:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleAutoWarmUp() {\n try {\n const success = await this.autoWarmUpSelectedModel();\n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to auto warm-up:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetWarmUpStatus() {\n try {\n const status = await this.getWarmUpStatus();\n return { success: true, status };\n } catch (error) {\n console.error('[OllamaService] Failed to get warm-up status:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleShutdown(force = false) {\n try {\n console.log(`[OllamaService] Manual shutdown requested (force: ${force})`);\n const success = await this.shutdown(force);\n \n // 종료 후 상태 업데이트 및 플래그 리셋\n if (success) {\n // 종료 완료 후 플래그 리셋\n this.isShuttingDown = false;\n await this.syncState();\n }\n \n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to shutdown Ollama:', error);\n return { success: false, error: error.message };\n }\n }\n \n // 설치 검증\n async verifyInstallation() {\n try {\n console.log('[OllamaService] Verifying installation...');\n \n // 1. 바이너리 확인\n const isInstalled = await this.isInstalled();\n if (!isInstalled) {\n return { success: false, error: 'Ollama binary not found' };\n }\n \n // 2. CLI 명령 테스트\n try {\n const { stdout } = await spawnAsync(this.getOllamaCliPath(), ['--version']);\n console.log('[OllamaService] Ollama version:', stdout.trim());\n } catch (error) {\n return { success: false, error: 'Ollama CLI not responding' };\n }\n \n // 3. 서비스 시작 가능 여부 확인\n const platform = this.getPlatform();\n if (platform === 'darwin') {\n // macOS: 앱 번들 확인\n try {\n await fs.access('/Applications/Ollama.app/Contents/MacOS/Ollama');\n } catch (error) {\n return { success: false, error: 'Ollama.app executable not found' };\n }\n }\n \n console.log('[OllamaService] Installation verified successfully');\n return { success: true };\n \n } catch (error) {\n console.error('[OllamaService] Verification failed:', error);\n return { success: false, error: error.message };\n }\n }\n}\n\n// Export singleton instance\nconst ollamaService = new OllamaService();\nmodule.exports = ollamaService;"], ["/glass/src/features/common/services/whisperService.js", "const { EventEmitter } = require('events');\nconst { spawn, exec } = require('child_process');\nconst { promisify } = require('util');\nconst path = require('path');\nconst fs = require('fs');\nconst os = require('os');\nconst https = require('https');\nconst crypto = require('crypto');\nconst { spawnAsync } = require('../utils/spawnHelper');\nconst { DOWNLOAD_CHECKSUMS } = require('../config/checksums');\n\nconst execAsync = promisify(exec);\n\nconst fsPromises = fs.promises;\n\nclass WhisperService extends EventEmitter {\n constructor() {\n super();\n this.serviceName = 'WhisperService';\n \n // 경로 및 디렉토리\n this.whisperPath = null;\n this.modelsDir = null;\n this.tempDir = null;\n \n // 세션 관리 (세션 풀 내장)\n this.sessionPool = [];\n this.activeSessions = new Map();\n this.maxSessions = 3;\n \n // 설치 상태\n this.installState = {\n isInstalled: false,\n isInitialized: false\n };\n \n // 사용 가능한 모델\n this.availableModels = {\n 'whisper-tiny': {\n name: 'Tiny',\n size: '39M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin'\n },\n 'whisper-base': {\n name: 'Base',\n size: '74M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin'\n },\n 'whisper-small': {\n name: 'Small',\n size: '244M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin'\n },\n 'whisper-medium': {\n name: 'Medium',\n size: '769M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin'\n }\n };\n }\n\n\n // Base class methods integration\n getPlatform() {\n return process.platform;\n }\n\n async checkCommand(command) {\n try {\n const platform = this.getPlatform();\n const checkCmd = platform === 'win32' ? 'where' : 'which';\n const { stdout } = await execAsync(`${checkCmd} ${command}`);\n return stdout.trim();\n } catch (error) {\n return null;\n }\n }\n\n async waitForService(checkFn, maxAttempts = 30, delayMs = 1000) {\n for (let i = 0; i < maxAttempts; i++) {\n if (await checkFn()) {\n console.log(`[${this.serviceName}] Service is ready`);\n return true;\n }\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n throw new Error(`${this.serviceName} service failed to start within timeout`);\n }\n\n async downloadFile(url, destination, options = {}) {\n const { \n onProgress = null,\n headers = { 'User-Agent': 'Glass-App' },\n timeout = 300000,\n modelId = null\n } = options;\n\n return new Promise((resolve, reject) => {\n const file = fs.createWriteStream(destination);\n let downloadedSize = 0;\n let totalSize = 0;\n\n const request = https.get(url, { headers }, (response) => {\n if ([301, 302, 307, 308].includes(response.statusCode)) {\n file.close();\n fs.unlink(destination, () => {});\n \n if (!response.headers.location) {\n reject(new Error('Redirect without location header'));\n return;\n }\n \n console.log(`[${this.serviceName}] Following redirect from ${url} to ${response.headers.location}`);\n this.downloadFile(response.headers.location, destination, options)\n .then(resolve)\n .catch(reject);\n return;\n }\n\n if (response.statusCode !== 200) {\n file.close();\n fs.unlink(destination, () => {});\n reject(new Error(`Download failed: ${response.statusCode} ${response.statusMessage}`));\n return;\n }\n\n totalSize = parseInt(response.headers['content-length'], 10) || 0;\n\n response.on('data', (chunk) => {\n downloadedSize += chunk.length;\n \n if (totalSize > 0) {\n const progress = Math.round((downloadedSize / totalSize) * 100);\n \n if (onProgress) {\n onProgress(progress, downloadedSize, totalSize);\n }\n }\n });\n\n response.pipe(file);\n\n file.on('finish', () => {\n file.close(() => {\n resolve({ success: true, size: downloadedSize });\n });\n });\n });\n\n request.on('timeout', () => {\n request.destroy();\n file.close();\n fs.unlink(destination, () => {});\n reject(new Error('Download timeout'));\n });\n\n request.on('error', (err) => {\n file.close();\n fs.unlink(destination, () => {});\n this.emit('download-error', { url, error: err, modelId });\n reject(err);\n });\n\n request.setTimeout(timeout);\n\n file.on('error', (err) => {\n fs.unlink(destination, () => {});\n reject(err);\n });\n });\n }\n\n async downloadWithRetry(url, destination, options = {}) {\n const { \n maxRetries = 3, \n retryDelay = 1000, \n expectedChecksum = null,\n modelId = null,\n ...downloadOptions \n } = options;\n \n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n try {\n const result = await this.downloadFile(url, destination, { \n ...downloadOptions, \n modelId \n });\n \n if (expectedChecksum) {\n const isValid = await this.verifyChecksum(destination, expectedChecksum);\n if (!isValid) {\n fs.unlinkSync(destination);\n throw new Error('Checksum verification failed');\n }\n console.log(`[${this.serviceName}] Checksum verified successfully`);\n }\n \n return result;\n } catch (error) {\n if (attempt === maxRetries) {\n throw error;\n }\n \n console.log(`Download attempt ${attempt} failed, retrying in ${retryDelay}ms...`);\n await new Promise(resolve => setTimeout(resolve, retryDelay * attempt));\n }\n }\n }\n\n async verifyChecksum(filePath, expectedChecksum) {\n return new Promise((resolve, reject) => {\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(filePath);\n \n stream.on('data', (data) => hash.update(data));\n stream.on('end', () => {\n const fileChecksum = hash.digest('hex');\n console.log(`[${this.serviceName}] File checksum: ${fileChecksum}`);\n console.log(`[${this.serviceName}] Expected checksum: ${expectedChecksum}`);\n resolve(fileChecksum === expectedChecksum);\n });\n stream.on('error', reject);\n });\n }\n\n async autoInstall(onProgress) {\n const platform = this.getPlatform();\n console.log(`[${this.serviceName}] Starting auto-installation for ${platform}`);\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.installMacOS(onProgress);\n case 'win32':\n return await this.installWindows(onProgress);\n case 'linux':\n return await this.installLinux();\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Auto-installation failed:`, error);\n throw error;\n }\n }\n\n async shutdown(force = false) {\n console.log(`[${this.serviceName}] Starting ${force ? 'forced' : 'graceful'} shutdown...`);\n \n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log(`[${this.serviceName}] Service not running, nothing to shutdown`);\n return true;\n }\n\n const platform = this.getPlatform();\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.shutdownMacOS(force);\n case 'win32':\n return await this.shutdownWindows(force);\n case 'linux':\n return await this.shutdownLinux(force);\n default:\n console.warn(`[${this.serviceName}] Unsupported platform for shutdown: ${platform}`);\n return false;\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Error during shutdown:`, error);\n return false;\n }\n }\n\n async initialize() {\n if (this.installState.isInitialized) return;\n\n try {\n const homeDir = os.homedir();\n const whisperDir = path.join(homeDir, '.glass', 'whisper');\n \n this.modelsDir = path.join(whisperDir, 'models');\n this.tempDir = path.join(whisperDir, 'temp');\n \n // Windows에서는 .exe 확장자 필요\n const platform = this.getPlatform();\n const whisperExecutable = platform === 'win32' ? 'whisper-whisper.exe' : 'whisper';\n this.whisperPath = path.join(whisperDir, 'bin', whisperExecutable);\n\n await this.ensureDirectories();\n await this.ensureWhisperBinary();\n \n this.installState.isInitialized = true;\n console.log('[WhisperService] Initialized successfully');\n } catch (error) {\n console.error('[WhisperService] Initialization failed:', error);\n // Emit error event - LocalAIManager가 처리\n this.emit('error', {\n errorType: 'initialization-failed',\n error: error.message\n });\n throw error;\n }\n }\n\n async ensureDirectories() {\n await fsPromises.mkdir(this.modelsDir, { recursive: true });\n await fsPromises.mkdir(this.tempDir, { recursive: true });\n await fsPromises.mkdir(path.dirname(this.whisperPath), { recursive: true });\n }\n\n // local stt session\n async getSession(config) {\n // check available session\n const availableSession = this.sessionPool.find(s => !s.inUse);\n if (availableSession) {\n availableSession.inUse = true;\n await availableSession.reconfigure(config);\n return availableSession;\n }\n\n // create new session\n if (this.activeSessions.size >= this.maxSessions) {\n throw new Error('Maximum session limit reached');\n }\n\n const session = new WhisperSession(config, this);\n await session.initialize();\n this.activeSessions.set(session.id, session);\n \n return session;\n }\n\n async releaseSession(sessionId) {\n const session = this.activeSessions.get(sessionId);\n if (session) {\n await session.cleanup();\n session.inUse = false;\n \n // add to session pool\n if (this.sessionPool.length < 2) {\n this.sessionPool.push(session);\n } else {\n // remove session\n await session.destroy();\n this.activeSessions.delete(sessionId);\n }\n }\n }\n\n //cleanup\n async cleanup() {\n // cleanup all sessions\n for (const session of this.activeSessions.values()) {\n await session.destroy();\n }\n \n this.activeSessions.clear();\n this.sessionPool = [];\n }\n\n async ensureWhisperBinary() {\n const whisperCliPath = await this.checkCommand('whisper-cli');\n if (whisperCliPath) {\n this.whisperPath = whisperCliPath;\n console.log(`[WhisperService] Found whisper-cli at: ${this.whisperPath}`);\n return;\n }\n\n const whisperPath = await this.checkCommand('whisper');\n if (whisperPath) {\n this.whisperPath = whisperPath;\n console.log(`[WhisperService] Found whisper at: ${this.whisperPath}`);\n return;\n }\n\n try {\n await fsPromises.access(this.whisperPath, fs.constants.X_OK);\n console.log('[WhisperService] Custom whisper binary found');\n return;\n } catch (error) {\n // Continue to installation\n }\n\n const platform = this.getPlatform();\n if (platform === 'darwin') {\n console.log('[WhisperService] Whisper not found, trying Homebrew installation...');\n try {\n await this.installViaHomebrew();\n // verify installation\n const verified = await this.verifyInstallation();\n if (!verified.success) {\n throw new Error(verified.error);\n }\n return;\n } catch (error) {\n console.log('[WhisperService] Homebrew installation failed:', error.message);\n }\n }\n\n await this.autoInstall();\n \n // verify installation\n const verified = await this.verifyInstallation();\n if (!verified.success) {\n throw new Error(`Whisper installation verification failed: ${verified.error}`);\n }\n }\n\n async installViaHomebrew() {\n const brewPath = await this.checkCommand('brew');\n if (!brewPath) {\n throw new Error('Homebrew not found. Please install Homebrew first.');\n }\n\n console.log('[WhisperService] Installing whisper-cpp via Homebrew...');\n await spawnAsync('brew', ['install', 'whisper-cpp']);\n \n const whisperCliPath = await this.checkCommand('whisper-cli');\n if (whisperCliPath) {\n this.whisperPath = whisperCliPath;\n console.log(`[WhisperService] Whisper-cli installed via Homebrew at: ${this.whisperPath}`);\n } else {\n const whisperPath = await this.checkCommand('whisper');\n if (whisperPath) {\n this.whisperPath = whisperPath;\n console.log(`[WhisperService] Whisper installed via Homebrew at: ${this.whisperPath}`);\n }\n }\n }\n\n\n async ensureModelAvailable(modelId) {\n if (!this.installState.isInitialized) {\n console.log('[WhisperService] Service not initialized, initializing now...');\n await this.initialize();\n }\n\n const modelInfo = this.availableModels[modelId];\n if (!modelInfo) {\n throw new Error(`Unknown model: ${modelId}. Available models: ${Object.keys(this.availableModels).join(', ')}`);\n }\n\n const modelPath = await this.getModelPath(modelId);\n try {\n await fsPromises.access(modelPath, fs.constants.R_OK);\n console.log(`[WhisperService] Model ${modelId} already available at: ${modelPath}`);\n } catch (error) {\n console.log(`[WhisperService] Model ${modelId} not found, downloading...`);\n await this.downloadModel(modelId);\n }\n }\n\n async downloadModel(modelId) {\n const modelInfo = this.availableModels[modelId];\n const modelPath = await this.getModelPath(modelId);\n const checksumInfo = DOWNLOAD_CHECKSUMS.whisper.models[modelId];\n \n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelId, \n progress: 0 \n });\n \n await this.downloadWithRetry(modelInfo.url, modelPath, {\n expectedChecksum: checksumInfo?.sha256,\n modelId, // pass modelId to LocalAIServiceBase for event handling\n onProgress: (progress) => {\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelId, \n progress \n });\n }\n });\n \n console.log(`[WhisperService] Model ${modelId} downloaded successfully`);\n this.emit('model-download-complete', { modelId });\n }\n\n async handleDownloadModel(modelId) {\n try {\n console.log(`[WhisperService] Handling download for model: ${modelId}`);\n\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n\n await this.ensureModelAvailable(modelId);\n \n return { success: true };\n } catch (error) {\n console.error(`[WhisperService] Failed to handle download for model ${modelId}:`, error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetInstalledModels() {\n try {\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n const models = await this.getInstalledModels();\n return { success: true, models };\n } catch (error) {\n console.error('[WhisperService] Failed to get installed models:', error);\n return { success: false, error: error.message };\n }\n }\n\n async getModelPath(modelId) {\n if (!this.installState.isInitialized || !this.modelsDir) {\n throw new Error('WhisperService is not initialized. Call initialize() first.');\n }\n return path.join(this.modelsDir, `${modelId}.bin`);\n }\n\n async getWhisperPath() {\n return this.whisperPath;\n }\n\n async saveAudioToTemp(audioBuffer, sessionId = '') {\n const timestamp = Date.now();\n const random = Math.random().toString(36).substr(2, 6);\n const sessionPrefix = sessionId ? `${sessionId}_` : '';\n const tempFile = path.join(this.tempDir, `audio_${sessionPrefix}${timestamp}_${random}.wav`);\n \n const wavHeader = this.createWavHeader(audioBuffer.length);\n const wavBuffer = Buffer.concat([wavHeader, audioBuffer]);\n \n await fsPromises.writeFile(tempFile, wavBuffer);\n return tempFile;\n }\n\n createWavHeader(dataSize) {\n const header = Buffer.alloc(44);\n const sampleRate = 16000;\n const numChannels = 1;\n const bitsPerSample = 16;\n \n header.write('RIFF', 0);\n header.writeUInt32LE(36 + dataSize, 4);\n header.write('WAVE', 8);\n header.write('fmt ', 12);\n header.writeUInt32LE(16, 16);\n header.writeUInt16LE(1, 20);\n header.writeUInt16LE(numChannels, 22);\n header.writeUInt32LE(sampleRate, 24);\n header.writeUInt32LE(sampleRate * numChannels * bitsPerSample / 8, 28);\n header.writeUInt16LE(numChannels * bitsPerSample / 8, 32);\n header.writeUInt16LE(bitsPerSample, 34);\n header.write('data', 36);\n header.writeUInt32LE(dataSize, 40);\n \n return header;\n }\n\n async cleanupTempFile(filePath) {\n if (!filePath || typeof filePath !== 'string') {\n console.warn('[WhisperService] Invalid file path for cleanup:', filePath);\n return;\n }\n\n const filesToCleanup = [\n filePath,\n filePath.replace('.wav', '.txt'),\n filePath.replace('.wav', '.json')\n ];\n\n for (const file of filesToCleanup) {\n try {\n // Check if file exists before attempting to delete\n await fsPromises.access(file, fs.constants.F_OK);\n await fsPromises.unlink(file);\n console.log(`[WhisperService] Cleaned up: ${file}`);\n } catch (error) {\n // File doesn't exist or already deleted - this is normal\n if (error.code !== 'ENOENT') {\n console.warn(`[WhisperService] Failed to cleanup ${file}:`, error.message);\n }\n }\n }\n }\n\n async getInstalledModels() {\n if (!this.installState.isInitialized) {\n console.log('[WhisperService] Service not initialized for getInstalledModels, initializing now...');\n await this.initialize();\n }\n\n const models = [];\n for (const [modelId, modelInfo] of Object.entries(this.availableModels)) {\n try {\n const modelPath = await this.getModelPath(modelId);\n await fsPromises.access(modelPath, fs.constants.R_OK);\n models.push({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: true\n });\n } catch (error) {\n models.push({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: false\n });\n }\n }\n return models;\n }\n\n async isServiceRunning() {\n return this.installState.isInitialized;\n }\n\n async startService() {\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n return true;\n }\n\n async stopService() {\n return true;\n }\n\n async isInstalled() {\n try {\n const whisperPath = await this.checkCommand('whisper-cli') || await this.checkCommand('whisper');\n return !!whisperPath;\n } catch (error) {\n return false;\n }\n }\n\n async installMacOS() {\n throw new Error('Binary installation not available for macOS. Please install Homebrew and run: brew install whisper-cpp');\n }\n\n async installWindows() {\n console.log('[WhisperService] Installing Whisper on Windows...');\n const version = 'v1.7.6';\n const binaryUrl = `https://github.com/ggml-org/whisper.cpp/releases/download/${version}/whisper-bin-x64.zip`;\n const tempFile = path.join(this.tempDir, 'whisper-binary.zip');\n \n try {\n console.log('[WhisperService] Step 1: Downloading Whisper binary...');\n await this.downloadWithRetry(binaryUrl, tempFile);\n \n console.log('[WhisperService] Step 2: Extracting archive...');\n const extractDir = path.join(this.tempDir, 'extracted');\n \n // 임시 압축 해제 디렉토리 생성\n await fsPromises.mkdir(extractDir, { recursive: true });\n \n // PowerShell 명령에서 경로를 올바르게 인용\n const expandCommand = `Expand-Archive -Path \"${tempFile}\" -DestinationPath \"${extractDir}\" -Force`;\n await spawnAsync('powershell', ['-command', expandCommand]);\n \n console.log('[WhisperService] Step 3: Finding and moving whisper executable...');\n \n // 압축 해제된 디렉토리에서 whisper.exe 파일 찾기\n const whisperExecutables = await this.findWhisperExecutables(extractDir);\n \n if (whisperExecutables.length === 0) {\n throw new Error('whisper.exe not found in extracted files');\n }\n \n // 첫 번째로 찾은 whisper.exe를 목표 위치로 복사\n const sourceExecutable = whisperExecutables[0];\n const targetDir = path.dirname(this.whisperPath);\n await fsPromises.mkdir(targetDir, { recursive: true });\n await fsPromises.copyFile(sourceExecutable, this.whisperPath);\n \n console.log('[WhisperService] Step 4: Verifying installation...');\n \n // 설치 검증\n await fsPromises.access(this.whisperPath, fs.constants.F_OK);\n \n // whisper.exe 실행 테스트\n try {\n await spawnAsync(this.whisperPath, ['--help']);\n console.log('[WhisperService] Whisper executable verified successfully');\n } catch (testError) {\n console.warn('[WhisperService] Whisper executable test failed, but file exists:', testError.message);\n }\n \n console.log('[WhisperService] Step 5: Cleanup...');\n \n // 임시 파일 정리\n await fsPromises.unlink(tempFile).catch(() => {});\n await this.removeDirectory(extractDir).catch(() => {});\n \n console.log('[WhisperService] Whisper installed successfully on Windows');\n return true;\n \n } catch (error) {\n console.error('[WhisperService] Windows installation failed:', error);\n \n // 실패 시 임시 파일 정리\n await fsPromises.unlink(tempFile).catch(() => {});\n await this.removeDirectory(path.join(this.tempDir, 'extracted')).catch(() => {});\n \n throw new Error(`Failed to install Whisper on Windows: ${error.message}`);\n }\n }\n \n // 압축 해제된 디렉토리에서 whisper.exe 파일들을 재귀적으로 찾기\n async findWhisperExecutables(dir) {\n const executables = [];\n \n try {\n const items = await fsPromises.readdir(dir, { withFileTypes: true });\n \n for (const item of items) {\n const fullPath = path.join(dir, item.name);\n \n if (item.isDirectory()) {\n const subExecutables = await this.findWhisperExecutables(fullPath);\n executables.push(...subExecutables);\n } else if (item.isFile() && (item.name === 'whisper-whisper.exe' || item.name === 'whisper.exe' || item.name === 'main.exe')) {\n executables.push(fullPath);\n }\n }\n } catch (error) {\n console.warn('[WhisperService] Error reading directory:', dir, error.message);\n }\n \n return executables;\n }\n \n // 디렉토리 재귀적 삭제\n async removeDirectory(dir) {\n try {\n const items = await fsPromises.readdir(dir, { withFileTypes: true });\n \n for (const item of items) {\n const fullPath = path.join(dir, item.name);\n \n if (item.isDirectory()) {\n await this.removeDirectory(fullPath);\n } else {\n await fsPromises.unlink(fullPath);\n }\n }\n \n await fsPromises.rmdir(dir);\n } catch (error) {\n console.warn('[WhisperService] Error removing directory:', dir, error.message);\n }\n }\n\n async installLinux() {\n console.log('[WhisperService] Installing Whisper on Linux...');\n const version = 'v1.7.6';\n const binaryUrl = `https://github.com/ggml-org/whisper.cpp/releases/download/${version}/whisper-cpp-${version}-linux-x64.tar.gz`;\n const tempFile = path.join(this.tempDir, 'whisper-binary.tar.gz');\n \n try {\n await this.downloadWithRetry(binaryUrl, tempFile);\n const extractDir = path.dirname(this.whisperPath);\n await spawnAsync('tar', ['-xzf', tempFile, '-C', extractDir, '--strip-components=1']);\n await spawnAsync('chmod', ['+x', this.whisperPath]);\n await fsPromises.unlink(tempFile);\n console.log('[WhisperService] Whisper installed successfully on Linux');\n return true;\n } catch (error) {\n console.error('[WhisperService] Linux installation failed:', error);\n throw new Error(`Failed to install Whisper on Linux: ${error.message}`);\n }\n }\n\n async shutdownMacOS(force) {\n return true;\n }\n\n async shutdownWindows(force) {\n return true;\n }\n\n async shutdownLinux(force) {\n return true;\n }\n}\n\n// WhisperSession class\nclass WhisperSession {\n constructor(config, service) {\n this.id = `session_${Date.now()}_${Math.random()}`;\n this.config = config;\n this.service = service;\n this.process = null;\n this.inUse = true;\n this.audioBuffer = Buffer.alloc(0);\n }\n\n async initialize() {\n await this.service.ensureModelAvailable(this.config.model);\n this.startProcessingLoop();\n }\n\n async reconfigure(config) {\n this.config = config;\n await this.service.ensureModelAvailable(this.config.model);\n }\n\n startProcessingLoop() {\n // TODO: 실제 처리 루프 구현\n }\n\n async cleanup() {\n // 임시 파일 정리\n await this.cleanupTempFiles();\n }\n\n async cleanupTempFiles() {\n // TODO: 임시 파일 정리 구현\n }\n\n async destroy() {\n if (this.process) {\n this.process.kill();\n }\n // 임시 파일 정리\n await this.cleanupTempFiles();\n }\n}\n\n// verify installation\nWhisperService.prototype.verifyInstallation = async function() {\n try {\n console.log('[WhisperService] Verifying installation...');\n \n // 1. check binary\n if (!this.whisperPath) {\n return { success: false, error: 'Whisper binary path not set' };\n }\n \n try {\n await fsPromises.access(this.whisperPath, fs.constants.X_OK);\n } catch (error) {\n return { success: false, error: 'Whisper binary not executable' };\n }\n \n // 2. check version\n try {\n const { stdout } = await spawnAsync(this.whisperPath, ['--help']);\n if (!stdout.includes('whisper')) {\n return { success: false, error: 'Invalid whisper binary' };\n }\n } catch (error) {\n return { success: false, error: 'Whisper binary not responding' };\n }\n \n // 3. check directories\n try {\n await fsPromises.access(this.modelsDir, fs.constants.W_OK);\n await fsPromises.access(this.tempDir, fs.constants.W_OK);\n } catch (error) {\n return { success: false, error: 'Required directories not accessible' };\n }\n \n console.log('[WhisperService] Installation verified successfully');\n return { success: true };\n \n } catch (error) {\n console.error('[WhisperService] Verification failed:', error);\n return { success: false, error: error.message };\n }\n};\n\n// Export singleton instance\nconst whisperService = new WhisperService();\nmodule.exports = whisperService;"], ["/glass/src/features/common/services/encryptionService.js", "const crypto = require('crypto');\nlet keytar;\n\n// Dynamically import keytar, as it's an optional dependency.\ntry {\n keytar = require('keytar');\n} catch (error) {\n console.warn('[EncryptionService] keytar is not available. Will use in-memory key for this session. Restarting the app might be required for data persistence after login.');\n keytar = null;\n}\n\nconst permissionService = require('./permissionService');\n\nconst SERVICE_NAME = 'com.pickle.glass'; // A unique identifier for the app in the keychain\nlet sessionKey = null; // In-memory fallback key\n\nconst ALGORITHM = 'aes-256-gcm';\nconst IV_LENGTH = 16; // For AES, this is always 16\nconst AUTH_TAG_LENGTH = 16;\n\n\n/**\n * Initializes the encryption key for a given user.\n * It first tries to get the key from the OS keychain.\n * If that fails, it generates a new key.\n * If keytar is available, it saves the new key.\n * Otherwise, it uses an in-memory key for the session.\n *\n * @param {string} userId - The unique identifier for the user (e.g., Firebase UID).\n */\nasync function initializeKey(userId) {\n if (!userId) {\n throw new Error('A user ID must be provided to initialize the encryption key.');\n }\n\n let keyRetrieved = false;\n\n if (keytar) {\n try {\n let key = await keytar.getPassword(SERVICE_NAME, userId);\n if (!key) {\n console.log(`[EncryptionService] No key found for ${userId}. Creating a new one.`);\n key = crypto.randomBytes(32).toString('hex');\n await keytar.setPassword(SERVICE_NAME, userId, key);\n console.log(`[EncryptionService] New key securely stored in keychain for ${userId}.`);\n } else {\n console.log(`[EncryptionService] Encryption key successfully retrieved from keychain for ${userId}.`);\n keyRetrieved = true;\n }\n sessionKey = key;\n } catch (error) {\n console.error('[EncryptionService] keytar failed. Falling back to in-memory key for this session.', error);\n keytar = null; // Disable keytar for the rest of the session to avoid repeated errors\n sessionKey = crypto.randomBytes(32).toString('hex');\n }\n } else {\n // keytar is not available\n if (!sessionKey) {\n console.warn('[EncryptionService] Using in-memory session key. Data will not persist across restarts without keytar.');\n sessionKey = crypto.randomBytes(32).toString('hex');\n }\n }\n\n // Mark keychain completed in permissions DB if this is the first successful retrieval or storage\n try {\n await permissionService.markKeychainCompleted(userId);\n if (keyRetrieved) {\n console.log(`[EncryptionService] Keychain completion marked in DB for ${userId}.`);\n }\n } catch (permErr) {\n console.error('[EncryptionService] Failed to mark keychain completion:', permErr);\n }\n\n if (!sessionKey) {\n throw new Error('Failed to initialize encryption key.');\n }\n}\n\nfunction resetSessionKey() {\n sessionKey = null;\n}\n\n/**\n * Encrypts a given text using AES-256-GCM.\n * @param {string} text The text to encrypt.\n * @returns {string | null} The encrypted data, as a base64 string containing iv, authTag, and content, or the original value if it cannot be encrypted.\n */\nfunction encrypt(text) {\n if (!sessionKey) {\n console.error('[EncryptionService] Encryption key is not initialized. Cannot encrypt.');\n return text; // Return original if key is missing\n }\n if (text == null) { // checks for null or undefined\n return text;\n }\n\n try {\n const key = Buffer.from(sessionKey, 'hex');\n const iv = crypto.randomBytes(IV_LENGTH);\n const cipher = crypto.createCipheriv(ALGORITHM, key, iv);\n \n let encrypted = cipher.update(String(text), 'utf8', 'hex');\n encrypted += cipher.final('hex');\n \n const authTag = cipher.getAuthTag();\n\n // Prepend IV and AuthTag to the encrypted content, then encode as base64.\n return Buffer.concat([iv, authTag, Buffer.from(encrypted, 'hex')]).toString('base64');\n } catch (error) {\n console.error('[EncryptionService] Encryption failed:', error);\n return text; // Return original on error\n }\n}\n\n/**\n * Decrypts a given encrypted string.\n * @param {string} encryptedText The base64 encrypted text.\n * @returns {string | null} The decrypted text, or the original value if it cannot be decrypted.\n */\nfunction decrypt(encryptedText) {\n if (!sessionKey) {\n console.error('[EncryptionService] Encryption key is not initialized. Cannot decrypt.');\n return encryptedText; // Return original if key is missing\n }\n if (encryptedText == null || typeof encryptedText !== 'string') {\n return encryptedText;\n }\n\n try {\n const data = Buffer.from(encryptedText, 'base64');\n if (data.length < IV_LENGTH + AUTH_TAG_LENGTH) {\n // This is not a valid encrypted string, likely plain text.\n return encryptedText;\n }\n \n const key = Buffer.from(sessionKey, 'hex');\n const iv = data.slice(0, IV_LENGTH);\n const authTag = data.slice(IV_LENGTH, IV_LENGTH + AUTH_TAG_LENGTH);\n const encryptedContent = data.slice(IV_LENGTH + AUTH_TAG_LENGTH);\n\n const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);\n decipher.setAuthTag(authTag);\n \n let decrypted = decipher.update(encryptedContent, 'hex', 'utf8');\n decrypted += decipher.final('utf8');\n \n return decrypted;\n } catch (error) {\n // It's common for this to fail if the data is not encrypted (e.g., legacy data).\n // In that case, we return the original value.\n console.error('[EncryptionService] Decryption failed:', error);\n return encryptedText;\n }\n}\n\nfunction looksEncrypted(str) {\n if (!str || typeof str !== 'string') return false;\n // Base64 chars + optional '=' padding\n if (!/^[A-Za-z0-9+/]+={0,2}$/.test(str)) return false;\n try {\n const buf = Buffer.from(str, 'base64');\n // Our AES-GCM cipher text must be at least 32 bytes (IV 16 + TAG 16)\n return buf.length >= 32;\n } catch {\n return false;\n }\n}\n\nmodule.exports = {\n initializeKey,\n resetSessionKey,\n encrypt,\n decrypt,\n looksEncrypted,\n}; "], ["/glass/src/bridge/featureBridge.js", "// src/bridge/featureBridge.js\nconst { ipcMain, app, BrowserWindow } = require('electron');\nconst settingsService = require('../features/settings/settingsService');\nconst authService = require('../features/common/services/authService');\nconst whisperService = require('../features/common/services/whisperService');\nconst ollamaService = require('../features/common/services/ollamaService');\nconst modelStateService = require('../features/common/services/modelStateService');\nconst shortcutsService = require('../features/shortcuts/shortcutsService');\nconst presetRepository = require('../features/common/repositories/preset');\nconst localAIManager = require('../features/common/services/localAIManager');\nconst askService = require('../features/ask/askService');\nconst listenService = require('../features/listen/listenService');\nconst permissionService = require('../features/common/services/permissionService');\nconst encryptionService = require('../features/common/services/encryptionService');\n\nmodule.exports = {\n // Renderer로부터의 요청을 수신하고 서비스로 전달\n initialize() {\n // Settings Service\n ipcMain.handle('settings:getPresets', async () => await settingsService.getPresets());\n ipcMain.handle('settings:get-auto-update', async () => await settingsService.getAutoUpdateSetting());\n ipcMain.handle('settings:set-auto-update', async (event, isEnabled) => await settingsService.setAutoUpdateSetting(isEnabled)); \n ipcMain.handle('settings:get-model-settings', async () => await settingsService.getModelSettings());\n ipcMain.handle('settings:clear-api-key', async (e, { provider }) => await settingsService.clearApiKey(provider));\n ipcMain.handle('settings:set-selected-model', async (e, { type, modelId }) => await settingsService.setSelectedModel(type, modelId)); \n\n ipcMain.handle('settings:get-ollama-status', async () => await settingsService.getOllamaStatus());\n ipcMain.handle('settings:ensure-ollama-ready', async () => await settingsService.ensureOllamaReady());\n ipcMain.handle('settings:shutdown-ollama', async () => await settingsService.shutdownOllama());\n\n // Shortcuts\n ipcMain.handle('settings:getCurrentShortcuts', async () => await shortcutsService.loadKeybinds());\n ipcMain.handle('shortcut:getDefaultShortcuts', async () => await shortcutsService.handleRestoreDefaults());\n ipcMain.handle('shortcut:closeShortcutSettingsWindow', async () => await shortcutsService.closeShortcutSettingsWindow());\n ipcMain.handle('shortcut:openShortcutSettingsWindow', async () => await shortcutsService.openShortcutSettingsWindow());\n ipcMain.handle('shortcut:saveShortcuts', async (event, newKeybinds) => await shortcutsService.handleSaveShortcuts(newKeybinds));\n ipcMain.handle('shortcut:toggleAllWindowsVisibility', async () => await shortcutsService.toggleAllWindowsVisibility());\n\n // Permissions\n ipcMain.handle('check-system-permissions', async () => await permissionService.checkSystemPermissions());\n ipcMain.handle('request-microphone-permission', async () => await permissionService.requestMicrophonePermission());\n ipcMain.handle('open-system-preferences', async (event, section) => await permissionService.openSystemPreferences(section));\n ipcMain.handle('mark-keychain-completed', async () => await permissionService.markKeychainCompleted());\n ipcMain.handle('check-keychain-completed', async () => await permissionService.checkKeychainCompleted());\n ipcMain.handle('initialize-encryption-key', async () => {\n const userId = authService.getCurrentUserId();\n await encryptionService.initializeKey(userId);\n return { success: true };\n });\n\n // User/Auth\n ipcMain.handle('get-current-user', () => authService.getCurrentUser());\n ipcMain.handle('start-firebase-auth', async () => await authService.startFirebaseAuthFlow());\n ipcMain.handle('firebase-logout', async () => await authService.signOut());\n\n // App\n ipcMain.handle('quit-application', () => app.quit());\n\n // Whisper\n ipcMain.handle('whisper:download-model', async (event, modelId) => await whisperService.handleDownloadModel(modelId));\n ipcMain.handle('whisper:get-installed-models', async () => await whisperService.handleGetInstalledModels());\n \n // General\n ipcMain.handle('get-preset-templates', () => presetRepository.getPresetTemplates());\n ipcMain.handle('get-web-url', () => process.env.pickleglass_WEB_URL || 'http://localhost:3000');\n\n // Ollama\n ipcMain.handle('ollama:get-status', async () => await ollamaService.handleGetStatus());\n ipcMain.handle('ollama:install', async () => await ollamaService.handleInstall());\n ipcMain.handle('ollama:start-service', async () => await ollamaService.handleStartService());\n ipcMain.handle('ollama:ensure-ready', async () => await ollamaService.handleEnsureReady());\n ipcMain.handle('ollama:get-models', async () => await ollamaService.handleGetModels());\n ipcMain.handle('ollama:get-model-suggestions', async () => await ollamaService.handleGetModelSuggestions());\n ipcMain.handle('ollama:pull-model', async (event, modelName) => await ollamaService.handlePullModel(modelName));\n ipcMain.handle('ollama:is-model-installed', async (event, modelName) => await ollamaService.handleIsModelInstalled(modelName));\n ipcMain.handle('ollama:warm-up-model', async (event, modelName) => await ollamaService.handleWarmUpModel(modelName));\n ipcMain.handle('ollama:auto-warm-up', async () => await ollamaService.handleAutoWarmUp());\n ipcMain.handle('ollama:get-warm-up-status', async () => await ollamaService.handleGetWarmUpStatus());\n ipcMain.handle('ollama:shutdown', async (event, force = false) => await ollamaService.handleShutdown(force));\n\n // Ask\n ipcMain.handle('ask:sendQuestionFromAsk', async (event, userPrompt) => await askService.sendMessage(userPrompt));\n ipcMain.handle('ask:sendQuestionFromSummary', async (event, userPrompt) => await askService.sendMessage(userPrompt));\n ipcMain.handle('ask:toggleAskButton', async () => await askService.toggleAskButton());\n ipcMain.handle('ask:closeAskWindow', async () => await askService.closeAskWindow());\n \n // Listen\n ipcMain.handle('listen:sendMicAudio', async (event, { data, mimeType }) => await listenService.handleSendMicAudioContent(data, mimeType));\n ipcMain.handle('listen:sendSystemAudio', async (event, { data, mimeType }) => {\n const result = await listenService.sttService.sendSystemAudioContent(data, mimeType);\n if(result.success) {\n listenService.sendToRenderer('system-audio-data', { data });\n }\n return result;\n });\n ipcMain.handle('listen:startMacosSystemAudio', async () => await listenService.handleStartMacosAudio());\n ipcMain.handle('listen:stopMacosSystemAudio', async () => await listenService.handleStopMacosAudio());\n ipcMain.handle('update-google-search-setting', async (event, enabled) => await listenService.handleUpdateGoogleSearchSetting(enabled));\n ipcMain.handle('listen:isSessionActive', async () => await listenService.isSessionActive());\n ipcMain.handle('listen:changeSession', async (event, listenButtonText) => {\n console.log('[FeatureBridge] listen:changeSession from mainheader', listenButtonText);\n try {\n await listenService.handleListenRequest(listenButtonText);\n return { success: true };\n } catch (error) {\n console.error('[FeatureBridge] listen:changeSession failed', error.message);\n return { success: false, error: error.message };\n }\n });\n\n // ModelStateService\n ipcMain.handle('model:validate-key', async (e, { provider, key }) => await modelStateService.handleValidateKey(provider, key));\n ipcMain.handle('model:get-all-keys', async () => await modelStateService.getAllApiKeys());\n ipcMain.handle('model:set-api-key', async (e, { provider, key }) => await modelStateService.setApiKey(provider, key));\n ipcMain.handle('model:remove-api-key', async (e, provider) => await modelStateService.handleRemoveApiKey(provider));\n ipcMain.handle('model:get-selected-models', async () => await modelStateService.getSelectedModels());\n ipcMain.handle('model:set-selected-model', async (e, { type, modelId }) => await modelStateService.handleSetSelectedModel(type, modelId));\n ipcMain.handle('model:get-available-models', async (e, { type }) => await modelStateService.getAvailableModels(type));\n ipcMain.handle('model:are-providers-configured', async () => await modelStateService.areProvidersConfigured());\n ipcMain.handle('model:get-provider-config', () => modelStateService.getProviderConfig());\n ipcMain.handle('model:re-initialize-state', async () => await modelStateService.initialize());\n\n // LocalAIManager 이벤트를 모든 윈도우에 브로드캐스트\n localAIManager.on('install-progress', (service, data) => {\n const event = { service, ...data };\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:install-progress', event);\n }\n });\n });\n localAIManager.on('installation-complete', (service) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:installation-complete', { service });\n }\n });\n });\n localAIManager.on('error', (error) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:error-occurred', error);\n }\n });\n });\n // Handle error-occurred events from LocalAIManager's error handling\n localAIManager.on('error-occurred', (error) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:error-occurred', error);\n }\n });\n });\n localAIManager.on('model-ready', (data) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:model-ready', data);\n }\n });\n });\n localAIManager.on('state-changed', (service, state) => {\n const event = { service, ...state };\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:service-status-changed', event);\n }\n });\n });\n\n // 주기적 상태 동기화 시작\n localAIManager.startPeriodicSync();\n\n // ModelStateService 이벤트를 모든 윈도우에 브로드캐스트\n modelStateService.on('state-updated', (state) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('model-state:updated', state);\n }\n });\n });\n modelStateService.on('settings-updated', () => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('settings-updated');\n }\n });\n });\n modelStateService.on('force-show-apikey-header', () => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('force-show-apikey-header');\n }\n });\n });\n\n // LocalAI 통합 핸들러 추가\n ipcMain.handle('localai:install', async (event, { service, options }) => {\n return await localAIManager.installService(service, options);\n });\n ipcMain.handle('localai:get-status', async (event, service) => {\n return await localAIManager.getServiceStatus(service);\n });\n ipcMain.handle('localai:start-service', async (event, service) => {\n return await localAIManager.startService(service);\n });\n ipcMain.handle('localai:stop-service', async (event, service) => {\n return await localAIManager.stopService(service);\n });\n ipcMain.handle('localai:install-model', async (event, { service, modelId, options }) => {\n return await localAIManager.installModel(service, modelId, options);\n });\n ipcMain.handle('localai:get-installed-models', async (event, service) => {\n return await localAIManager.getInstalledModels(service);\n });\n ipcMain.handle('localai:run-diagnostics', async (event, service) => {\n return await localAIManager.runDiagnostics(service);\n });\n ipcMain.handle('localai:repair-service', async (event, service) => {\n return await localAIManager.repairService(service);\n });\n \n // 에러 처리 핸들러\n ipcMain.handle('localai:handle-error', async (event, { service, errorType, details }) => {\n return await localAIManager.handleError(service, errorType, details);\n });\n \n // 전체 상태 조회\n ipcMain.handle('localai:get-all-states', async (event) => {\n return await localAIManager.getAllServiceStates();\n });\n\n console.log('[FeatureBridge] Initialized with all feature handlers.');\n },\n\n // Renderer로 상태를 전송\n sendAskProgress(win, progress) {\n win.webContents.send('feature:ask:progress', progress);\n },\n};"], ["/glass/src/features/common/services/localAIManager.js", "const { EventEmitter } = require('events');\nconst ollamaService = require('./ollamaService');\nconst whisperService = require('./whisperService');\n\n\n//Central manager for managing Ollama and Whisper services \nclass LocalAIManager extends EventEmitter {\n constructor() {\n super();\n \n // service map\n this.services = {\n ollama: ollamaService,\n whisper: whisperService\n };\n \n // unified state management\n this.state = {\n ollama: {\n installed: false,\n running: false,\n models: []\n },\n whisper: {\n installed: false,\n initialized: false,\n models: []\n }\n };\n \n // setup event listeners\n this.setupEventListeners();\n }\n \n \n // subscribe to events from each service and re-emit as unified events\n setupEventListeners() {\n // ollama events\n ollamaService.on('install-progress', (data) => {\n this.emit('install-progress', 'ollama', data);\n });\n \n ollamaService.on('installation-complete', () => {\n this.emit('installation-complete', 'ollama');\n this.updateServiceState('ollama');\n });\n \n ollamaService.on('error', (error) => {\n this.emit('error', { service: 'ollama', ...error });\n });\n \n ollamaService.on('model-pull-complete', (data) => {\n this.emit('model-ready', { service: 'ollama', ...data });\n this.updateServiceState('ollama');\n });\n \n ollamaService.on('state-changed', (state) => {\n this.emit('state-changed', 'ollama', state);\n });\n \n // Whisper 이벤트\n whisperService.on('install-progress', (data) => {\n this.emit('install-progress', 'whisper', data);\n });\n \n whisperService.on('installation-complete', () => {\n this.emit('installation-complete', 'whisper');\n this.updateServiceState('whisper');\n });\n \n whisperService.on('error', (error) => {\n this.emit('error', { service: 'whisper', ...error });\n });\n \n whisperService.on('model-download-complete', (data) => {\n this.emit('model-ready', { service: 'whisper', ...data });\n this.updateServiceState('whisper');\n });\n }\n \n /**\n * 서비스 설치\n */\n async installService(serviceName, options = {}) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n try {\n if (serviceName === 'ollama') {\n return await service.handleInstall();\n } else if (serviceName === 'whisper') {\n // Whisper는 자동 설치\n await service.initialize();\n return { success: true };\n }\n } catch (error) {\n this.emit('error', {\n service: serviceName,\n errorType: 'installation-failed',\n error: error.message\n });\n throw error;\n }\n }\n \n /**\n * 서비스 상태 조회\n */\n async getServiceStatus(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.getStatus();\n } else if (serviceName === 'whisper') {\n const installed = await service.isInstalled();\n const running = await service.isServiceRunning();\n const models = await service.getInstalledModels();\n return {\n success: true,\n installed,\n running,\n models\n };\n }\n }\n \n /**\n * 서비스 시작\n */\n async startService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n const result = await service.startService();\n await this.updateServiceState(serviceName);\n return { success: result };\n }\n \n /**\n * 서비스 중지\n */\n async stopService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n let result;\n if (serviceName === 'ollama') {\n result = await service.shutdown(false);\n } else if (serviceName === 'whisper') {\n result = await service.stopService();\n }\n \n // 서비스 중지 후 상태 업데이트\n await this.updateServiceState(serviceName);\n \n return result;\n }\n \n /**\n * 모델 설치/다운로드\n */\n async installModel(serviceName, modelId, options = {}) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.pullModel(modelId);\n } else if (serviceName === 'whisper') {\n return await service.downloadModel(modelId);\n }\n }\n \n /**\n * 설치된 모델 목록 조회\n */\n async getInstalledModels(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.getAllModelsWithStatus();\n } else if (serviceName === 'whisper') {\n return await service.getInstalledModels();\n }\n }\n \n /**\n * 모델 워밍업 (Ollama 전용)\n */\n async warmUpModel(modelName, forceRefresh = false) {\n return await ollamaService.warmUpModel(modelName, forceRefresh);\n }\n \n /**\n * 자동 워밍업 (Ollama 전용)\n */\n async autoWarmUp() {\n return await ollamaService.autoWarmUpSelectedModel();\n }\n \n /**\n * 진단 실행\n */\n async runDiagnostics(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n const diagnostics = {\n service: serviceName,\n timestamp: new Date().toISOString(),\n checks: {}\n };\n \n try {\n // 1. 설치 상태 확인\n diagnostics.checks.installation = {\n check: 'Installation',\n status: await service.isInstalled() ? 'pass' : 'fail',\n details: {}\n };\n \n // 2. 서비스 실행 상태\n diagnostics.checks.running = {\n check: 'Service Running',\n status: await service.isServiceRunning() ? 'pass' : 'fail',\n details: {}\n };\n \n // 3. 포트 연결 테스트 및 상세 health check (Ollama)\n if (serviceName === 'ollama') {\n try {\n // Use comprehensive health check\n const health = await service.healthCheck();\n diagnostics.checks.health = {\n check: 'Service Health',\n status: health.healthy ? 'pass' : 'fail',\n details: health\n };\n \n // Legacy port check for compatibility\n diagnostics.checks.port = {\n check: 'Port Connectivity',\n status: health.checks.apiResponsive ? 'pass' : 'fail',\n details: { connected: health.checks.apiResponsive }\n };\n } catch (error) {\n diagnostics.checks.health = {\n check: 'Service Health',\n status: 'fail',\n details: { error: error.message }\n };\n diagnostics.checks.port = {\n check: 'Port Connectivity',\n status: 'fail',\n details: { error: error.message }\n };\n }\n \n // 4. 모델 목록\n if (diagnostics.checks.running.status === 'pass') {\n try {\n const models = await service.getInstalledModels();\n diagnostics.checks.models = {\n check: 'Installed Models',\n status: 'pass',\n details: { count: models.length, models: models.map(m => m.name) }\n };\n \n // 5. 워밍업 상태\n const warmupStatus = await service.getWarmUpStatus();\n diagnostics.checks.warmup = {\n check: 'Model Warm-up',\n status: 'pass',\n details: warmupStatus\n };\n } catch (error) {\n diagnostics.checks.models = {\n check: 'Installed Models',\n status: 'fail',\n details: { error: error.message }\n };\n }\n }\n }\n \n // 4. Whisper 특화 진단\n if (serviceName === 'whisper') {\n // 바이너리 확인\n diagnostics.checks.binary = {\n check: 'Whisper Binary',\n status: service.whisperPath ? 'pass' : 'fail',\n details: { path: service.whisperPath }\n };\n \n // 모델 디렉토리\n diagnostics.checks.modelDir = {\n check: 'Model Directory',\n status: service.modelsDir ? 'pass' : 'fail',\n details: { path: service.modelsDir }\n };\n }\n \n // 전체 진단 결과\n const allChecks = Object.values(diagnostics.checks);\n diagnostics.summary = {\n total: allChecks.length,\n passed: allChecks.filter(c => c.status === 'pass').length,\n failed: allChecks.filter(c => c.status === 'fail').length,\n overallStatus: allChecks.every(c => c.status === 'pass') ? 'healthy' : 'unhealthy'\n };\n \n } catch (error) {\n diagnostics.error = error.message;\n diagnostics.summary = {\n overallStatus: 'error'\n };\n }\n \n return diagnostics;\n }\n \n /**\n * 서비스 복구\n */\n async repairService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n console.log(`[LocalAIManager] Starting repair for ${serviceName}...`);\n const repairLog = [];\n \n try {\n // 1. 진단 실행\n repairLog.push('Running diagnostics...');\n const diagnostics = await this.runDiagnostics(serviceName);\n \n if (diagnostics.summary.overallStatus === 'healthy') {\n repairLog.push('Service is already healthy, no repair needed');\n return {\n success: true,\n repairLog,\n diagnostics\n };\n }\n \n // 2. 설치 문제 해결\n if (diagnostics.checks.installation?.status === 'fail') {\n repairLog.push('Installation missing, attempting to install...');\n try {\n await this.installService(serviceName);\n repairLog.push('Installation completed');\n } catch (error) {\n repairLog.push(`Installation failed: ${error.message}`);\n throw error;\n }\n }\n \n // 3. 서비스 재시작\n if (diagnostics.checks.running?.status === 'fail') {\n repairLog.push('Service not running, attempting to start...');\n \n // 종료 시도\n try {\n await this.stopService(serviceName);\n repairLog.push('Stopped existing service');\n } catch (error) {\n repairLog.push('Service was not running');\n }\n \n // 잠시 대기\n await new Promise(resolve => setTimeout(resolve, 2000));\n \n // 시작\n try {\n await this.startService(serviceName);\n repairLog.push('Service started successfully');\n } catch (error) {\n repairLog.push(`Failed to start service: ${error.message}`);\n throw error;\n }\n }\n \n // 4. 포트 문제 해결 (Ollama)\n if (serviceName === 'ollama' && diagnostics.checks.port?.status === 'fail') {\n repairLog.push('Port connectivity issue detected');\n \n // 프로세스 강제 종료\n if (process.platform === 'darwin') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('pkill -f ollama');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n else if (process.platform === 'win32') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('taskkill /F /IM ollama.exe');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n else if (process.platform === 'linux') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('pkill -f ollama');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n \n await new Promise(resolve => setTimeout(resolve, 1000));\n \n // 재시작\n await this.startService(serviceName);\n repairLog.push('Restarted service after port cleanup');\n }\n \n // 5. Whisper 특화 복구\n if (serviceName === 'whisper') {\n // 세션 정리\n if (diagnostics.checks.running?.status === 'pass') {\n repairLog.push('Cleaning up Whisper sessions...');\n await service.cleanup();\n repairLog.push('Sessions cleaned up');\n }\n \n // 초기화\n if (!service.installState.isInitialized) {\n repairLog.push('Re-initializing Whisper...');\n await service.initialize();\n repairLog.push('Whisper re-initialized');\n }\n }\n \n // 6. 최종 상태 확인\n repairLog.push('Verifying repair...');\n const finalDiagnostics = await this.runDiagnostics(serviceName);\n \n const success = finalDiagnostics.summary.overallStatus === 'healthy';\n repairLog.push(success ? 'Repair successful!' : 'Repair failed - manual intervention may be required');\n \n // 성공 시 상태 업데이트\n if (success) {\n await this.updateServiceState(serviceName);\n }\n \n return {\n success,\n repairLog,\n diagnostics: finalDiagnostics\n };\n \n } catch (error) {\n repairLog.push(`Repair error: ${error.message}`);\n return {\n success: false,\n repairLog,\n error: error.message\n };\n }\n }\n \n /**\n * 상태 업데이트\n */\n async updateServiceState(serviceName) {\n try {\n const status = await this.getServiceStatus(serviceName);\n this.state[serviceName] = status;\n \n // 상태 변경 이벤트 발행\n this.emit('state-changed', serviceName, status);\n } catch (error) {\n console.error(`[LocalAIManager] Failed to update ${serviceName} state:`, error);\n }\n }\n \n /**\n * 전체 상태 조회\n */\n async getAllServiceStates() {\n const states = {};\n \n for (const serviceName of Object.keys(this.services)) {\n try {\n states[serviceName] = await this.getServiceStatus(serviceName);\n } catch (error) {\n states[serviceName] = {\n success: false,\n error: error.message\n };\n }\n }\n \n return states;\n }\n \n /**\n * 주기적 상태 동기화 시작\n */\n startPeriodicSync(interval = 30000) {\n if (this.syncInterval) {\n return;\n }\n \n this.syncInterval = setInterval(async () => {\n for (const serviceName of Object.keys(this.services)) {\n await this.updateServiceState(serviceName);\n }\n }, interval);\n \n // 각 서비스의 주기적 동기화도 시작\n ollamaService.startPeriodicSync();\n }\n \n /**\n * 주기적 상태 동기화 중지\n */\n stopPeriodicSync() {\n if (this.syncInterval) {\n clearInterval(this.syncInterval);\n this.syncInterval = null;\n }\n \n // 각 서비스의 주기적 동기화도 중지\n ollamaService.stopPeriodicSync();\n }\n \n /**\n * 전체 종료\n */\n async shutdown() {\n this.stopPeriodicSync();\n \n const results = {};\n for (const [serviceName, service] of Object.entries(this.services)) {\n try {\n if (serviceName === 'ollama') {\n results[serviceName] = await service.shutdown(false);\n } else if (serviceName === 'whisper') {\n await service.cleanup();\n results[serviceName] = true;\n }\n } catch (error) {\n results[serviceName] = false;\n console.error(`[LocalAIManager] Failed to shutdown ${serviceName}:`, error);\n }\n }\n \n return results;\n }\n \n /**\n * 에러 처리\n */\n async handleError(serviceName, errorType, details = {}) {\n console.error(`[LocalAIManager] Error in ${serviceName}: ${errorType}`, details);\n \n // 서비스별 에러 처리\n switch(errorType) {\n case 'installation-failed':\n // 설치 실패 시 이벤트 발생\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || 'Installation failed',\n canRetry: true\n });\n break;\n \n case 'model-pull-failed':\n case 'model-download-failed':\n // 모델 다운로드 실패\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n model: details.model,\n error: details.error || 'Model download failed',\n canRetry: true\n });\n break;\n \n case 'service-not-responding':\n // 서비스 반응 없음\n console.log(`[LocalAIManager] Attempting to repair ${serviceName}...`);\n const repairResult = await this.repairService(serviceName);\n \n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || 'Service not responding',\n repairAttempted: true,\n repairSuccessful: repairResult.success\n });\n break;\n \n default:\n // 기타 에러\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || `Unknown error: ${errorType}`,\n canRetry: false\n });\n }\n }\n}\n\n// 싱글톤\nconst localAIManager = new LocalAIManager();\nmodule.exports = localAIManager;"], ["/glass/src/features/settings/repositories/firebase.repository.js", "const { collection, doc, addDoc, getDoc, getDocs, updateDoc, deleteDoc, query, where, orderBy } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../common/repositories/firestoreConverter');\nconst encryptionService = require('../../common/services/encryptionService');\n\nconst userPresetConverter = createEncryptedConverter(['prompt', 'title']);\n\nconst defaultPresetConverter = {\n toFirestore: (data) => data,\n fromFirestore: (snapshot, options) => {\n const data = snapshot.data(options);\n return { ...data, id: snapshot.id };\n }\n};\n\nfunction userPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'prompt_presets').withConverter(userPresetConverter);\n}\n\nfunction defaultPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'defaults/v1/prompt_presets').withConverter(defaultPresetConverter);\n}\n\nasync function getPresets(uid) {\n const userPresetsQuery = query(userPresetsCol(), where('uid', '==', uid));\n const defaultPresetsQuery = query(defaultPresetsCol());\n\n const [userSnapshot, defaultSnapshot] = await Promise.all([\n getDocs(userPresetsQuery),\n getDocs(defaultPresetsQuery)\n ]);\n\n const presets = [\n ...defaultSnapshot.docs.map(d => d.data()),\n ...userSnapshot.docs.map(d => d.data())\n ];\n\n return presets.sort((a, b) => {\n if (a.is_default && !b.is_default) return -1;\n if (!a.is_default && b.is_default) return 1;\n return a.title.localeCompare(b.title);\n });\n}\n\nasync function getPresetTemplates() {\n const q = query(defaultPresetsCol(), orderBy('title', 'asc'));\n const snapshot = await getDocs(q);\n return snapshot.docs.map(doc => doc.data());\n}\n\nasync function createPreset({ uid, title, prompt }) {\n const now = Math.floor(Date.now() / 1000);\n const newPreset = {\n uid: uid,\n title,\n prompt,\n is_default: 0,\n created_at: now,\n };\n const docRef = await addDoc(userPresetsCol(), newPreset);\n return { id: docRef.id };\n}\n\nasync function updatePreset(id, { title, prompt }, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to update.\");\n }\n\n const updates = {};\n if (title !== undefined) {\n updates.title = encryptionService.encrypt(title);\n }\n if (prompt !== undefined) {\n updates.prompt = encryptionService.encrypt(prompt);\n }\n updates.updated_at = Math.floor(Date.now() / 1000);\n \n await updateDoc(docRef, updates);\n return { changes: 1 };\n}\n\nasync function deletePreset(id, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to delete.\");\n }\n\n await deleteDoc(docRef);\n return { changes: 1 };\n}\n\nasync function getAutoUpdate(uid) {\n // Assume users are stored in a \"users\" collection, and auto_update_enabled is a field\n const userDocRef = doc(getFirestoreInstance(), 'users', uid);\n try {\n const userSnap = await getDoc(userDocRef);\n if (userSnap.exists()) {\n const data = userSnap.data();\n if (typeof data.auto_update_enabled !== 'undefined') {\n console.log('Firebase: Auto update setting found:', data.auto_update_enabled);\n return !!data.auto_update_enabled;\n } else {\n // Field does not exist, just return default\n return true;\n }\n } else {\n // User doc does not exist, just return default\n return true;\n }\n } catch (error) {\n console.error('Firebase: Error getting auto_update_enabled setting:', error);\n return true; // fallback to enabled\n }\n}\n\nasync function setAutoUpdate(uid, isEnabled) {\n const userDocRef = doc(getFirestoreInstance(), 'users', uid);\n try {\n const userSnap = await getDoc(userDocRef);\n if (userSnap.exists()) {\n await updateDoc(userDocRef, { auto_update_enabled: !!isEnabled });\n }\n // If user doc does not exist, do nothing (no creation)\n return { success: true };\n } catch (error) {\n console.error('Firebase: Error setting auto-update:', error);\n return { success: false, error: error.message };\n }\n}\n\n\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n getAutoUpdate,\n setAutoUpdate,\n}; "], ["/glass/src/features/common/services/migrationService.js", "const { doc, writeBatch, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../services/firebaseClient');\nconst encryptionService = require('../services/encryptionService');\n\nconst sqliteSessionRepo = require('../repositories/session/sqlite.repository');\nconst sqlitePresetRepo = require('../repositories/preset/sqlite.repository');\nconst sqliteUserRepo = require('../repositories/user/sqlite.repository');\nconst sqliteSttRepo = require('../../listen/stt/repositories/sqlite.repository');\nconst sqliteSummaryRepo = require('../../listen/summary/repositories/sqlite.repository');\nconst sqliteAiMessageRepo = require('../../ask/repositories/sqlite.repository');\n\nconst MAX_BATCH_OPERATIONS = 500;\n\nasync function checkAndRunMigration(firebaseUser) {\n if (!firebaseUser || !firebaseUser.uid) {\n console.log('[Migration] No user, skipping migration check.');\n return;\n }\n\n console.log(`[Migration] Checking for user ${firebaseUser.uid}...`);\n\n const localUser = sqliteUserRepo.getById(firebaseUser.uid);\n if (!localUser || localUser.has_migrated_to_firebase) {\n console.log(`[Migration] User ${firebaseUser.uid} is not eligible or already migrated.`);\n return;\n }\n\n console.log(`[Migration] Starting data migration for user ${firebaseUser.uid}...`);\n \n try {\n const db = getFirestoreInstance();\n \n // --- Phase 1: Migrate Parent Documents (Presets & Sessions) ---\n console.log('[Migration Phase 1] Migrating parent documents...');\n let phase1Batch = writeBatch(db);\n let phase1OpCount = 0;\n const phase1Promises = [];\n \n const localPresets = (await sqlitePresetRepo.getPresets(firebaseUser.uid)).filter(p => !p.is_default);\n console.log(`[Migration Phase 1] Found ${localPresets.length} custom presets.`);\n for (const preset of localPresets) {\n const presetRef = doc(db, 'prompt_presets', preset.id);\n const cleanPreset = {\n uid: preset.uid,\n title: encryptionService.encrypt(preset.title ?? ''),\n prompt: encryptionService.encrypt(preset.prompt ?? ''),\n is_default: preset.is_default ?? 0,\n created_at: preset.created_at ? Timestamp.fromMillis(preset.created_at * 1000) : null,\n updated_at: preset.updated_at ? Timestamp.fromMillis(preset.updated_at * 1000) : null\n };\n phase1Batch.set(presetRef, cleanPreset);\n phase1OpCount++;\n if (phase1OpCount >= MAX_BATCH_OPERATIONS) {\n phase1Promises.push(phase1Batch.commit());\n phase1Batch = writeBatch(db);\n phase1OpCount = 0;\n }\n }\n \n const localSessions = await sqliteSessionRepo.getAllByUserId(firebaseUser.uid);\n console.log(`[Migration Phase 1] Found ${localSessions.length} sessions.`);\n for (const session of localSessions) {\n const sessionRef = doc(db, 'sessions', session.id);\n const cleanSession = {\n uid: session.uid,\n members: session.members ?? [session.uid],\n title: encryptionService.encrypt(session.title ?? ''),\n session_type: session.session_type ?? 'ask',\n started_at: session.started_at ? Timestamp.fromMillis(session.started_at * 1000) : null,\n ended_at: session.ended_at ? Timestamp.fromMillis(session.ended_at * 1000) : null,\n updated_at: session.updated_at ? Timestamp.fromMillis(session.updated_at * 1000) : null\n };\n phase1Batch.set(sessionRef, cleanSession);\n phase1OpCount++;\n if (phase1OpCount >= MAX_BATCH_OPERATIONS) {\n phase1Promises.push(phase1Batch.commit());\n phase1Batch = writeBatch(db);\n phase1OpCount = 0;\n }\n }\n \n if (phase1OpCount > 0) {\n phase1Promises.push(phase1Batch.commit());\n }\n \n if (phase1Promises.length > 0) {\n await Promise.all(phase1Promises);\n console.log(`[Migration Phase 1] Successfully committed ${phase1Promises.length} batches of parent documents.`);\n } else {\n console.log('[Migration Phase 1] No parent documents to migrate.');\n }\n\n // --- Phase 2: Migrate Child Documents (sub-collections) ---\n console.log('[Migration Phase 2] Migrating child documents for all sessions...');\n let phase2Batch = writeBatch(db);\n let phase2OpCount = 0;\n const phase2Promises = [];\n\n for (const session of localSessions) {\n const transcripts = await sqliteSttRepo.getAllTranscriptsBySessionId(session.id);\n for (const t of transcripts) {\n const transcriptRef = doc(db, `sessions/${session.id}/transcripts`, t.id);\n const cleanTranscript = {\n uid: firebaseUser.uid,\n session_id: t.session_id,\n start_at: t.start_at ? Timestamp.fromMillis(t.start_at * 1000) : null,\n end_at: t.end_at ? Timestamp.fromMillis(t.end_at * 1000) : null,\n speaker: t.speaker ?? null,\n text: encryptionService.encrypt(t.text ?? ''),\n lang: t.lang ?? 'en',\n created_at: t.created_at ? Timestamp.fromMillis(t.created_at * 1000) : null\n };\n phase2Batch.set(transcriptRef, cleanTranscript);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n\n const messages = await sqliteAiMessageRepo.getAllAiMessagesBySessionId(session.id);\n for (const m of messages) {\n const msgRef = doc(db, `sessions/${session.id}/ai_messages`, m.id);\n const cleanMessage = {\n uid: firebaseUser.uid,\n session_id: m.session_id,\n sent_at: m.sent_at ? Timestamp.fromMillis(m.sent_at * 1000) : null,\n role: m.role ?? 'user',\n content: encryptionService.encrypt(m.content ?? ''),\n tokens: m.tokens ?? null,\n model: m.model ?? 'unknown',\n created_at: m.created_at ? Timestamp.fromMillis(m.created_at * 1000) : null\n };\n phase2Batch.set(msgRef, cleanMessage);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n\n const summary = await sqliteSummaryRepo.getSummaryBySessionId(session.id);\n if (summary) {\n // Reverting to use 'data' as the document ID for summary.\n const summaryRef = doc(db, `sessions/${session.id}/summary`, 'data');\n const cleanSummary = {\n uid: firebaseUser.uid,\n session_id: summary.session_id,\n generated_at: summary.generated_at ? Timestamp.fromMillis(summary.generated_at * 1000) : null,\n model: summary.model ?? 'unknown',\n tldr: encryptionService.encrypt(summary.tldr ?? ''),\n text: encryptionService.encrypt(summary.text ?? ''),\n bullet_json: encryptionService.encrypt(summary.bullet_json ?? '[]'),\n action_json: encryptionService.encrypt(summary.action_json ?? '[]'),\n tokens_used: summary.tokens_used ?? null,\n updated_at: summary.updated_at ? Timestamp.fromMillis(summary.updated_at * 1000) : null\n };\n phase2Batch.set(summaryRef, cleanSummary);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n }\n\n if (phase2OpCount > 0) {\n phase2Promises.push(phase2Batch.commit());\n }\n\n if (phase2Promises.length > 0) {\n await Promise.all(phase2Promises);\n console.log(`[Migration Phase 2] Successfully committed ${phase2Promises.length} batches of child documents.`);\n } else {\n console.log('[Migration Phase 2] No child documents to migrate.');\n }\n\n // --- 4. Mark migration as complete ---\n sqliteUserRepo.setMigrationComplete(firebaseUser.uid);\n console.log(`[Migration] ✅ Successfully marked migration as complete for ${firebaseUser.uid}.`);\n\n } catch (error) {\n console.error(`[Migration] 🔥 An error occurred during migration for user ${firebaseUser.uid}:`, error);\n }\n}\n\nmodule.exports = {\n checkAndRunMigration,\n}; "], ["/glass/src/ui/app/PermissionHeader.js", "import { LitElement, html, css } from '../assets/lit-core-2.7.4.min.js';\n\nexport class PermissionHeader extends LitElement {\n static styles = css`\n :host {\n display: block;\n transition: opacity 0.3s ease-in, transform 0.3s ease-in;\n will-change: opacity, transform;\n }\n\n :host(.sliding-out) {\n opacity: 0;\n transform: translateY(-20px);\n }\n\n :host(.hidden) {\n opacity: 0;\n pointer-events: none;\n }\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n box-sizing: border-box;\n }\n\n .container {\n -webkit-app-region: drag;\n width: 285px;\n /* height is now set dynamically */\n padding: 18px 20px;\n background: rgba(0, 0, 0, 0.3);\n border-radius: 16px;\n overflow: hidden;\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .container::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 16px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 10px;\n right: 10px;\n width: 14px;\n height: 14px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 3px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 14px;\n line-height: 1;\n padding: 0;\n }\n\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n\n .close-button:active {\n transform: scale(0.95);\n }\n\n .title {\n color: white;\n font-size: 16px;\n font-weight: 500;\n margin: 0;\n text-align: center;\n flex-shrink: 0;\n }\n\n .form-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 100%;\n margin-top: auto;\n }\n\n .form-content.all-granted {\n flex-grow: 1;\n justify-content: center;\n margin-top: 0;\n }\n\n .subtitle {\n color: rgba(255, 255, 255, 0.7);\n font-size: 11px;\n font-weight: 400;\n text-align: center;\n margin-bottom: 12px;\n line-height: 1.3;\n }\n\n .permission-status {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-bottom: 12px;\n min-height: 20px;\n }\n\n .permission-item {\n display: flex;\n align-items: center;\n gap: 6px;\n color: rgba(255, 255, 255, 0.8);\n font-size: 11px;\n font-weight: 400;\n }\n\n .permission-item.granted {\n color: rgba(34, 197, 94, 0.9);\n }\n\n .permission-icon {\n width: 12px;\n height: 12px;\n opacity: 0.8;\n }\n\n .check-icon {\n width: 12px;\n height: 12px;\n color: rgba(34, 197, 94, 0.9);\n }\n\n .action-button {\n -webkit-app-region: no-drag;\n width: 100%;\n height: 34px;\n background: rgba(255, 255, 255, 0.2);\n border: none;\n border-radius: 10px;\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s ease;\n position: relative;\n overflow: hidden;\n margin-bottom: 6px;\n }\n\n .action-button::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 10px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .action-button:hover:not(:disabled) {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .action-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .continue-button {\n -webkit-app-region: no-drag;\n width: 100%;\n height: 34px;\n background: rgba(34, 197, 94, 0.8);\n border: none;\n border-radius: 10px;\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s ease;\n position: relative;\n overflow: hidden;\n margin-top: 4px;\n }\n\n .continue-button::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 10px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .continue-button:hover:not(:disabled) {\n background: rgba(34, 197, 94, 0.9);\n }\n\n .continue-button:disabled {\n background: rgba(255, 255, 255, 0.2);\n cursor: not-allowed;\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .container,\n :host-context(body.has-glass) .action-button,\n :host-context(body.has-glass) .continue-button,\n :host-context(body.has-glass) .close-button {\n background: transparent !important;\n border: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .container::after,\n :host-context(body.has-glass) .action-button::after,\n :host-context(body.has-glass) .continue-button::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .action-button:hover,\n :host-context(body.has-glass) .continue-button:hover,\n :host-context(body.has-glass) .close-button:hover {\n background: transparent !important;\n }\n `;\n\n static properties = {\n microphoneGranted: { type: String },\n screenGranted: { type: String },\n keychainGranted: { type: String },\n isChecking: { type: String },\n continueCallback: { type: Function },\n userMode: { type: String }, // 'local' or 'firebase'\n };\n\n constructor() {\n super();\n this.microphoneGranted = 'unknown';\n this.screenGranted = 'unknown';\n this.keychainGranted = 'unknown';\n this.isChecking = false;\n this.continueCallback = null;\n this.userMode = 'local'; // Default to local\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n if (changedProperties.has('userMode')) {\n const newHeight = this.userMode === 'firebase' ? 280 : 220;\n console.log(`[PermissionHeader] User mode changed to ${this.userMode}, requesting resize to ${newHeight}px`);\n this.dispatchEvent(new CustomEvent('request-resize', {\n detail: { height: newHeight },\n bubbles: true,\n composed: true\n }));\n }\n }\n\n async connectedCallback() {\n super.connectedCallback();\n\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n this.userMode = userState.mode;\n } catch (e) {\n console.error('[PermissionHeader] Failed to get user state', e);\n this.userMode = 'local'; // Fallback to local\n }\n }\n\n await this.checkPermissions();\n \n // Set up periodic permission check\n this.permissionCheckInterval = setInterval(async () => {\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n this.userMode = userState.mode;\n } catch (e) {\n this.userMode = 'local';\n }\n }\n this.checkPermissions();\n }, 1000);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.permissionCheckInterval) {\n clearInterval(this.permissionCheckInterval);\n }\n }\n\n async checkPermissions() {\n if (!window.api || this.isChecking) return;\n \n this.isChecking = true;\n \n try {\n const permissions = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Permission check result:', permissions);\n \n const prevMic = this.microphoneGranted;\n const prevScreen = this.screenGranted;\n const prevKeychain = this.keychainGranted;\n \n this.microphoneGranted = permissions.microphone;\n this.screenGranted = permissions.screen;\n this.keychainGranted = permissions.keychain;\n \n // if permissions changed == UI update\n if (prevMic !== this.microphoneGranted || prevScreen !== this.screenGranted || prevKeychain !== this.keychainGranted) {\n console.log('[PermissionHeader] Permission status changed, updating UI');\n this.requestUpdate();\n }\n\n const isKeychainRequired = this.userMode === 'firebase';\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n \n // if all permissions granted == automatically continue\n if (this.microphoneGranted === 'granted' && \n this.screenGranted === 'granted' && \n keychainOk && \n this.continueCallback) {\n console.log('[PermissionHeader] All permissions granted, proceeding automatically');\n setTimeout(() => this.handleContinue(), 500);\n }\n } catch (error) {\n console.error('[PermissionHeader] Error checking permissions:', error);\n } finally {\n this.isChecking = false;\n }\n }\n\n async handleMicrophoneClick() {\n if (!window.api || this.microphoneGranted === 'granted') return;\n \n console.log('[PermissionHeader] Requesting microphone permission...');\n \n try {\n const result = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Microphone permission result:', result);\n \n if (result.microphone === 'granted') {\n this.microphoneGranted = 'granted';\n this.requestUpdate();\n return;\n }\n \n if (result.microphone === 'not-determined' || result.microphone === 'denied' || result.microphone === 'unknown' || result.microphone === 'restricted') {\n const res = await window.api.permissionHeader.requestMicrophonePermission();\n if (res.status === 'granted' || res.success === true) {\n this.microphoneGranted = 'granted';\n this.requestUpdate();\n return;\n }\n }\n \n \n // Check permissions again after a delay\n // setTimeout(() => this.checkPermissions(), 1000);\n } catch (error) {\n console.error('[PermissionHeader] Error requesting microphone permission:', error);\n }\n }\n\n async handleScreenClick() {\n if (!window.api || this.screenGranted === 'granted') return;\n \n console.log('[PermissionHeader] Checking screen recording permission...');\n \n try {\n const permissions = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Screen permission check result:', permissions);\n \n if (permissions.screen === 'granted') {\n this.screenGranted = 'granted';\n this.requestUpdate();\n return;\n }\n if (permissions.screen === 'not-determined' || permissions.screen === 'denied' || permissions.screen === 'unknown' || permissions.screen === 'restricted') {\n console.log('[PermissionHeader] Opening screen recording preferences...');\n await window.api.permissionHeader.openSystemPreferences('screen-recording');\n }\n \n // Check permissions again after a delay\n // (This may not execute if app restarts after permission grant)\n // setTimeout(() => this.checkPermissions(), 2000);\n } catch (error) {\n console.error('[PermissionHeader] Error opening screen recording preferences:', error);\n }\n }\n\n async handleKeychainClick() {\n if (!window.api || this.keychainGranted === 'granted') return;\n \n console.log('[PermissionHeader] Requesting keychain permission...');\n \n try {\n // Trigger initializeKey to prompt for keychain access\n // Assuming encryptionService is accessible or via API\n await window.api.permissionHeader.initializeEncryptionKey(); // New IPC handler needed\n \n // After success, update status\n this.keychainGranted = 'granted';\n this.requestUpdate();\n } catch (error) {\n console.error('[PermissionHeader] Error requesting keychain permission:', error);\n }\n }\n\n async handleContinue() {\n const isKeychainRequired = this.userMode === 'firebase';\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n\n if (this.continueCallback && \n this.microphoneGranted === 'granted' && \n this.screenGranted === 'granted' && \n keychainOk) {\n // Mark permissions as completed\n if (window.api && isKeychainRequired) {\n try {\n await window.api.permissionHeader.markKeychainCompleted();\n console.log('[PermissionHeader] Marked keychain as completed');\n } catch (error) {\n console.error('[PermissionHeader] Error marking keychain as completed:', error);\n }\n }\n \n this.continueCallback();\n }\n }\n\n handleClose() {\n console.log('Close button clicked');\n if (window.api) {\n window.api.common.quitApplication();\n }\n }\n\n render() {\n const isKeychainRequired = this.userMode === 'firebase';\n const containerHeight = isKeychainRequired ? 280 : 220;\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n const allGranted = this.microphoneGranted === 'granted' && this.screenGranted === 'granted' && keychainOk;\n\n return html`\n
\n \n

Permission Setup Required

\n\n
\n ${!allGranted ? html`\n
Grant access to microphone, screen recording${isKeychainRequired ? ' and keychain' : ''} to continue
\n \n
\n
\n ${this.microphoneGranted === 'granted' ? html`\n \n \n \n Microphone ✓\n ` : html`\n \n \n \n Microphone\n `}\n
\n \n
\n ${this.screenGranted === 'granted' ? html`\n \n \n \n Screen ✓\n ` : html`\n \n \n \n Screen Recording\n `}\n
\n\n ${isKeychainRequired ? html`\n
\n ${this.keychainGranted === 'granted' ? html`\n \n \n \n Data Encryption ✓\n ` : html`\n \n \n \n Data Encryption\n `}\n
\n ` : ''}\n
\n\n \n\n \n\n ${isKeychainRequired ? html`\n \n
\n Stores the key to encrypt your data. Press \"Always Allow\" to continue.\n
\n ` : ''}\n ` : html`\n \n `}\n
\n
\n `;\n }\n}\n\ncustomElements.define('permission-setup', PermissionHeader); "], ["/glass/src/features/common/ai/providers/openai.js", "const OpenAI = require('openai');\nconst WebSocket = require('ws');\nconst { Portkey } = require('portkey-ai');\nconst { Readable } = require('stream');\nconst { getProviderForModel } = require('../factory.js');\n\n\nclass OpenAIProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string' || !key.startsWith('sk-')) {\n return { success: false, error: 'Invalid OpenAI API key format.' };\n }\n\n try {\n const response = await fetch('https://api.openai.com/v1/models', {\n headers: { 'Authorization': `Bearer ${key}` }\n });\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error?.message || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[OpenAIProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n\n/**\n * Creates an OpenAI STT session\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.language='en'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {Promise} STT session\n */\nasync function createSTT({ apiKey, language = 'en', callbacks = {}, usePortkey = false, portkeyVirtualKey, ...config }) {\n const keyType = usePortkey ? 'vKey' : 'apiKey';\n const key = usePortkey ? (portkeyVirtualKey || apiKey) : apiKey;\n\n const wsUrl = keyType === 'apiKey'\n ? 'wss://api.openai.com/v1/realtime?intent=transcription'\n : 'wss://api.portkey.ai/v1/realtime?intent=transcription';\n\n const headers = keyType === 'apiKey'\n ? {\n 'Authorization': `Bearer ${key}`,\n 'OpenAI-Beta': 'realtime=v1',\n }\n : {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': key,\n 'OpenAI-Beta': 'realtime=v1',\n };\n\n const ws = new WebSocket(wsUrl, { headers });\n\n return new Promise((resolve, reject) => {\n ws.onopen = () => {\n console.log(\"WebSocket session opened.\");\n\n const sessionConfig = {\n type: 'transcription_session.update',\n session: {\n input_audio_format: 'pcm16',\n input_audio_transcription: {\n model: 'gpt-4o-mini-transcribe',\n prompt: config.prompt || '',\n language: language || 'en'\n },\n turn_detection: {\n type: 'server_vad',\n threshold: 0.5,\n prefix_padding_ms: 200,\n silence_duration_ms: 100,\n },\n input_audio_noise_reduction: {\n type: 'near_field'\n }\n }\n };\n \n ws.send(JSON.stringify(sessionConfig));\n\n // Helper to periodically keep the websocket alive\n const keepAlive = () => {\n try {\n if (ws.readyState === WebSocket.OPEN) {\n // The ws library supports native ping frames which are ideal for heart-beats\n ws.ping();\n }\n } catch (err) {\n console.error('[OpenAI STT] keepAlive error:', err.message);\n }\n };\n\n resolve({\n sendRealtimeInput: (audioData) => {\n if (ws.readyState === WebSocket.OPEN) {\n const message = {\n type: 'input_audio_buffer.append',\n audio: audioData\n };\n ws.send(JSON.stringify(message));\n }\n },\n // Expose keepAlive so higher-level services can schedule heart-beats\n keepAlive,\n close: () => {\n if (ws.readyState === WebSocket.OPEN) {\n ws.send(JSON.stringify({ type: 'session.close' }));\n ws.onmessage = ws.onerror = () => {}; // 핸들러 제거\n ws.close(1000, 'Client initiated close.');\n }\n }\n });\n };\n\n ws.onmessage = (event) => {\n // ── 종료·하트비트 패킷 필터링 ──────────────────────────────\n if (!event.data || event.data === 'null' || event.data === '[DONE]') return;\n\n let msg;\n try { msg = JSON.parse(event.data); }\n catch { return; } // JSON 파싱 실패 무시\n\n if (!msg || typeof msg !== 'object') return;\n\n msg.provider = 'openai'; // ← 항상 명시\n callbacks.onmessage?.(msg);\n };\n\n ws.onerror = (error) => {\n console.error('WebSocket error:', error.message);\n if (callbacks && callbacks.onerror) {\n callbacks.onerror(error);\n }\n reject(error);\n };\n\n ws.onclose = (event) => {\n console.log(`WebSocket closed: ${event.code} ${event.reason}`);\n if (callbacks && callbacks.onclose) {\n callbacks.onclose(event);\n }\n };\n });\n}\n\n/**\n * Creates an OpenAI LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.model='gpt-4.1'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=2048] - Max tokens\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {object} LLM instance\n */\nfunction createLLM({ apiKey, model = 'gpt-4.1', temperature = 0.7, maxTokens = 2048, usePortkey = false, portkeyVirtualKey, ...config }) {\n const client = new OpenAI({ apiKey });\n \n const callApi = async (messages) => {\n if (!usePortkey) {\n const response = await client.chat.completions.create({\n model: model,\n messages: messages,\n temperature: temperature,\n max_tokens: maxTokens\n });\n return {\n content: response.choices[0].message.content.trim(),\n raw: response\n };\n } else {\n const fetchUrl = 'https://api.portkey.ai/v1/chat/completions';\n const response = await fetch(fetchUrl, {\n method: 'POST',\n headers: {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': portkeyVirtualKey || apiKey,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: model,\n messages,\n temperature,\n max_tokens: maxTokens,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Portkey API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n return {\n content: result.choices[0].message.content.trim(),\n raw: result\n };\n }\n };\n\n return {\n generateContent: async (parts) => {\n const messages = [];\n let systemPrompt = '';\n let userContent = [];\n \n for (const part of parts) {\n if (typeof part === 'string') {\n if (systemPrompt === '' && part.includes('You are')) {\n systemPrompt = part;\n } else {\n userContent.push({ type: 'text', text: part });\n }\n } else if (part.inlineData) {\n userContent.push({\n type: 'image_url',\n image_url: { url: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}` }\n });\n }\n }\n \n if (systemPrompt) messages.push({ role: 'system', content: systemPrompt });\n if (userContent.length > 0) messages.push({ role: 'user', content: userContent });\n \n const result = await callApi(messages);\n\n return {\n response: {\n text: () => result.content\n },\n raw: result.raw\n };\n },\n \n // For compatibility with chat-style interfaces\n chat: async (messages) => {\n return await callApi(messages);\n }\n };\n}\n\n/** \n * Creates an OpenAI streaming LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.model='gpt-4.1'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=2048] - Max tokens\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {object} Streaming LLM instance\n */\nfunction createStreamingLLM({ apiKey, model = 'gpt-4.1', temperature = 0.7, maxTokens = 2048, usePortkey = false, portkeyVirtualKey, ...config }) {\n return {\n streamChat: async (messages) => {\n const fetchUrl = usePortkey \n ? 'https://api.portkey.ai/v1/chat/completions'\n : 'https://api.openai.com/v1/chat/completions';\n \n const headers = usePortkey\n ? {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': portkeyVirtualKey || apiKey,\n 'Content-Type': 'application/json',\n }\n : {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n };\n\n const response = await fetch(fetchUrl, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n model: model,\n messages,\n temperature,\n max_tokens: maxTokens,\n stream: true,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`OpenAI API error: ${response.status} ${response.statusText}`);\n }\n\n return response;\n }\n };\n}\n\nmodule.exports = {\n OpenAIProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n}; "], ["/glass/src/features/common/ai/providers/deepgram.js", "// providers/deepgram.js\n\nconst { createClient, LiveTranscriptionEvents } = require('@deepgram/sdk');\nconst WebSocket = require('ws');\n\n/**\n * Deepgram Provider 클래스. API 키 유효성 검사를 담당합니다.\n */\nclass DeepgramProvider {\n /**\n * Deepgram API 키의 유효성을 검사합니다.\n * @param {string} key - 검사할 Deepgram API 키\n * @returns {Promise<{success: boolean, error?: string}>}\n */\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string') {\n return { success: false, error: 'Invalid Deepgram API key format.' };\n }\n try {\n // ✨ 변경점: SDK 대신 직접 fetch로 API를 호출하여 안정성 확보 (openai.js 방식)\n const response = await fetch('https://api.deepgram.com/v1/projects', {\n headers: { 'Authorization': `Token ${key}` }\n });\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.err_msg || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[DeepgramProvider] Network error during key validation:`, error);\n return { success: false, error: error.message || 'A network error occurred during validation.' };\n }\n }\n}\n\nfunction createSTT({\n apiKey,\n language = 'en-US',\n sampleRate = 24000,\n callbacks = {},\n }) {\n const qs = new URLSearchParams({\n model: 'nova-3',\n encoding: 'linear16',\n sample_rate: sampleRate.toString(),\n language,\n smart_format: 'true',\n interim_results: 'true',\n channels: '1',\n });\n \n const url = `wss://api.deepgram.com/v1/listen?${qs}`;\n \n const ws = new WebSocket(url, {\n headers: { Authorization: `Token ${apiKey}` },\n });\n ws.binaryType = 'arraybuffer';\n \n return new Promise((resolve, reject) => {\n const to = setTimeout(() => {\n ws.terminate();\n reject(new Error('DG open timeout (10 s)'));\n }, 10_000);\n \n ws.on('open', () => {\n clearTimeout(to);\n resolve({\n sendRealtimeInput: (buf) => ws.send(buf),\n close: () => ws.close(1000, 'client'),\n });\n });\n \n ws.on('message', raw => {\n let msg;\n try { msg = JSON.parse(raw.toString()); } catch { return; }\n if (msg.channel?.alternatives?.[0]?.transcript !== undefined) {\n callbacks.onmessage?.({ provider: 'deepgram', ...msg });\n }\n });\n \n ws.on('close', (code, reason) =>\n callbacks.onclose?.({ code, reason: reason.toString() })\n );\n \n ws.on('error', err => {\n clearTimeout(to);\n callbacks.onerror?.(err);\n reject(err);\n });\n });\n }\n\n// ... (LLM 관련 Placeholder 함수들은 그대로 유지) ...\nfunction createLLM(opts) {\n console.warn(\"[Deepgram] LLM not supported.\");\n return { generateContent: async () => { throw new Error(\"Deepgram does not support LLM functionality.\"); } };\n}\nfunction createStreamingLLM(opts) {\n console.warn(\"[Deepgram] Streaming LLM not supported.\");\n return { streamChat: async () => { throw new Error(\"Deepgram does not support Streaming LLM functionality.\"); } };\n}\n\nmodule.exports = {\n DeepgramProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};"], ["/glass/src/window/windowManager.js", "const { BrowserWindow, globalShortcut, screen, app, shell } = require('electron');\nconst WindowLayoutManager = require('./windowLayoutManager');\nconst SmoothMovementManager = require('./smoothMovementManager');\nconst path = require('node:path');\nconst os = require('os');\nconst shortcutsService = require('../features/shortcuts/shortcutsService');\nconst internalBridge = require('../bridge/internalBridge');\nconst permissionRepository = require('../features/common/repositories/permission');\n\n/* ────────────────[ GLASS BYPASS ]─────────────── */\nlet liquidGlass;\nconst isLiquidGlassSupported = () => {\n if (process.platform !== 'darwin') {\n return false;\n }\n const majorVersion = parseInt(os.release().split('.')[0], 10);\n // return majorVersion >= 25; // macOS 26+ (Darwin 25+)\n return majorVersion >= 26; // See you soon!\n};\nlet shouldUseLiquidGlass = isLiquidGlassSupported();\nif (shouldUseLiquidGlass) {\n try {\n liquidGlass = require('electron-liquid-glass');\n } catch (e) {\n console.warn('Could not load optional dependency \"electron-liquid-glass\". The feature will be disabled.');\n shouldUseLiquidGlass = false;\n }\n}\n/* ────────────────[ GLASS BYPASS ]─────────────── */\n\nlet isContentProtectionOn = true;\nlet lastVisibleWindows = new Set(['header']);\n\nlet currentHeaderState = 'apikey';\nconst windowPool = new Map();\n\nlet settingsHideTimer = null;\n\n\nlet layoutManager = null;\nlet movementManager = null;\n\n\nfunction updateChildWindowLayouts(animated = true) {\n // if (movementManager.isAnimating) return;\n\n const visibleWindows = {};\n const listenWin = windowPool.get('listen');\n const askWin = windowPool.get('ask');\n if (listenWin && !listenWin.isDestroyed() && listenWin.isVisible()) {\n visibleWindows.listen = true;\n }\n if (askWin && !askWin.isDestroyed() && askWin.isVisible()) {\n visibleWindows.ask = true;\n }\n\n if (Object.keys(visibleWindows).length === 0) return;\n\n const newLayout = layoutManager.calculateFeatureWindowLayout(visibleWindows);\n movementManager.animateLayout(newLayout, animated);\n}\n\nconst showSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: true });\n};\n\nconst hideSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: false });\n};\n\nconst cancelHideSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: true });\n};\n\nconst moveWindowStep = (direction) => {\n internalBridge.emit('window:moveStep', { direction });\n};\n\nconst resizeHeaderWindow = ({ width, height }) => {\n internalBridge.emit('window:resizeHeaderWindow', { width, height });\n};\n\nconst handleHeaderAnimationFinished = (state) => {\n internalBridge.emit('window:headerAnimationFinished', state);\n};\n\nconst getHeaderPosition = () => {\n return new Promise((resolve) => {\n internalBridge.emit('window:getHeaderPosition', (position) => {\n resolve(position);\n });\n });\n};\n\nconst moveHeaderTo = (newX, newY) => {\n internalBridge.emit('window:moveHeaderTo', { newX, newY });\n};\n\nconst adjustWindowHeight = (winName, targetHeight) => {\n internalBridge.emit('window:adjustWindowHeight', { winName, targetHeight });\n};\n\n\nfunction setupWindowController(windowPool, layoutManager, movementManager) {\n internalBridge.on('window:requestVisibility', ({ name, visible }) => {\n handleWindowVisibilityRequest(windowPool, layoutManager, movementManager, name, visible);\n });\n internalBridge.on('window:requestToggleAllWindowsVisibility', ({ targetVisibility }) => {\n changeAllWindowsVisibility(windowPool, targetVisibility);\n });\n internalBridge.on('window:moveToDisplay', ({ displayId }) => {\n // movementManager.moveToDisplay(displayId);\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateNewPositionForDisplay(header, displayId);\n if (newPosition) {\n movementManager.animateWindowPosition(header, newPosition, {\n onComplete: () => updateChildWindowLayouts(true)\n });\n }\n }\n });\n internalBridge.on('window:moveToEdge', ({ direction }) => {\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateEdgePosition(header, direction);\n movementManager.animateWindowPosition(header, newPosition, { \n onComplete: () => updateChildWindowLayouts(true) \n });\n }\n });\n\n internalBridge.on('window:moveStep', ({ direction }) => {\n const header = windowPool.get('header');\n if (header) { \n const newHeaderPosition = layoutManager.calculateStepMovePosition(header, direction);\n if (!newHeaderPosition) return;\n \n const futureHeaderBounds = { ...header.getBounds(), ...newHeaderPosition };\n const visibleWindows = {};\n const listenWin = windowPool.get('listen');\n const askWin = windowPool.get('ask');\n if (listenWin && !listenWin.isDestroyed() && listenWin.isVisible()) {\n visibleWindows.listen = true;\n }\n if (askWin && !askWin.isDestroyed() && askWin.isVisible()) {\n visibleWindows.ask = true;\n }\n\n const newChildLayout = layoutManager.calculateFeatureWindowLayout(visibleWindows, futureHeaderBounds);\n \n movementManager.animateWindowPosition(header, newHeaderPosition);\n movementManager.animateLayout(newChildLayout);\n }\n });\n\n internalBridge.on('window:resizeHeaderWindow', ({ width, height }) => {\n const header = windowPool.get('header');\n if (!header || movementManager.isAnimating) return;\n\n const newHeaderBounds = layoutManager.calculateHeaderResize(header, { width, height });\n \n const wasResizable = header.isResizable();\n if (!wasResizable) header.setResizable(true);\n\n movementManager.animateWindowBounds(header, newHeaderBounds, {\n onComplete: () => {\n if (!wasResizable) header.setResizable(false);\n updateChildWindowLayouts(true);\n }\n });\n });\n internalBridge.on('window:headerAnimationFinished', (state) => {\n const header = windowPool.get('header');\n if (!header || header.isDestroyed()) return;\n\n if (state === 'hidden') {\n header.hide();\n } else if (state === 'visible') {\n updateChildWindowLayouts(false);\n }\n });\n internalBridge.on('window:getHeaderPosition', (reply) => {\n const header = windowPool.get('header');\n if (header && !header.isDestroyed()) {\n reply(header.getBounds());\n } else {\n reply({ x: 0, y: 0, width: 0, height: 0 });\n }\n });\n internalBridge.on('window:moveHeaderTo', ({ newX, newY }) => {\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateClampedPosition(header, { x: newX, y: newY });\n header.setPosition(newPosition.x, newPosition.y);\n }\n });\n internalBridge.on('window:adjustWindowHeight', ({ winName, targetHeight }) => {\n console.log(`[Layout Debug] adjustWindowHeight: targetHeight=${targetHeight}`);\n const senderWindow = windowPool.get(winName);\n if (senderWindow) {\n const newBounds = layoutManager.calculateWindowHeightAdjustment(senderWindow, targetHeight);\n \n const wasResizable = senderWindow.isResizable();\n if (!wasResizable) senderWindow.setResizable(true);\n\n movementManager.animateWindowBounds(senderWindow, newBounds, {\n onComplete: () => {\n if (!wasResizable) senderWindow.setResizable(false);\n updateChildWindowLayouts(true);\n }\n });\n }\n });\n}\n\nfunction changeAllWindowsVisibility(windowPool, targetVisibility) {\n const header = windowPool.get('header');\n if (!header) return;\n\n if (typeof targetVisibility === 'boolean' &&\n header.isVisible() === targetVisibility) {\n return;\n }\n \n if (header.isVisible()) {\n lastVisibleWindows.clear();\n \n windowPool.forEach((win, name) => {\n if (win && !win.isDestroyed() && win.isVisible()) {\n lastVisibleWindows.add(name);\n }\n });\n \n lastVisibleWindows.forEach(name => {\n if (name === 'header') return;\n const win = windowPool.get(name);\n if (win && !win.isDestroyed()) win.hide();\n });\n header.hide();\n \n return;\n }\n \n lastVisibleWindows.forEach(name => {\n const win = windowPool.get(name);\n if (win && !win.isDestroyed())\n win.show();\n });\n }\n\n/**\n * \n * @param {Map} windowPool\n * @param {WindowLayoutManager} layoutManager \n * @param {SmoothMovementManager} movementManager\n * @param {'listen' | 'ask' | 'settings' | 'shortcut-settings'} name \n * @param {boolean} shouldBeVisible \n */\nasync function handleWindowVisibilityRequest(windowPool, layoutManager, movementManager, name, shouldBeVisible) {\n console.log(`[WindowManager] Request: set '${name}' visibility to ${shouldBeVisible}`);\n const win = windowPool.get(name);\n\n if (!win || win.isDestroyed()) {\n console.warn(`[WindowManager] Window '${name}' not found or destroyed.`);\n return;\n }\n\n if (name !== 'settings') {\n const isCurrentlyVisible = win.isVisible();\n if (isCurrentlyVisible === shouldBeVisible) {\n console.log(`[WindowManager] Window '${name}' is already in the desired state.`);\n return;\n }\n }\n\n const disableClicks = (selectedWindow) => {\n for (const [name, win] of windowPool) {\n if (win !== selectedWindow && !win.isDestroyed()) {\n win.setIgnoreMouseEvents(true, { forward: true });\n }\n }\n };\n\n const restoreClicks = () => {\n for (const [, win] of windowPool) {\n if (!win.isDestroyed()) win.setIgnoreMouseEvents(false);\n }\n };\n\n if (name === 'settings') {\n if (shouldBeVisible) {\n // Cancel any pending hide operations\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n settingsHideTimer = null;\n }\n const position = layoutManager.calculateSettingsWindowPosition();\n if (position) {\n win.setBounds(position);\n win.__lockedByButton = true;\n win.show();\n win.moveTop();\n win.setAlwaysOnTop(true);\n } else {\n console.warn('[WindowManager] Could not calculate settings window position.');\n }\n } else {\n // Hide after a delay\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n }\n settingsHideTimer = setTimeout(() => {\n if (win && !win.isDestroyed()) {\n win.setAlwaysOnTop(false);\n win.hide();\n }\n settingsHideTimer = null;\n }, 200);\n\n win.__lockedByButton = false;\n }\n return;\n }\n\n\n if (name === 'shortcut-settings') {\n if (shouldBeVisible) {\n // layoutManager.positionShortcutSettingsWindow();\n const newBounds = layoutManager.calculateShortcutSettingsWindowPosition();\n if (newBounds) win.setBounds(newBounds);\n \n if (process.platform === 'darwin') {\n win.setAlwaysOnTop(true, 'screen-saver');\n } else {\n win.setAlwaysOnTop(true);\n }\n // globalShortcut.unregisterAll();\n disableClicks(win);\n win.show();\n } else {\n if (process.platform === 'darwin') {\n win.setAlwaysOnTop(false, 'screen-saver');\n } else {\n win.setAlwaysOnTop(false);\n }\n restoreClicks();\n win.hide();\n }\n return;\n }\n\n if (name === 'listen' || name === 'ask') {\n const win = windowPool.get(name);\n const otherName = name === 'listen' ? 'ask' : 'listen';\n const otherWin = windowPool.get(otherName);\n const isOtherWinVisible = otherWin && !otherWin.isDestroyed() && otherWin.isVisible();\n \n const ANIM_OFFSET_X = 50;\n const ANIM_OFFSET_Y = 20;\n\n const finalVisibility = {\n listen: (name === 'listen' && shouldBeVisible) || (otherName === 'listen' && isOtherWinVisible),\n ask: (name === 'ask' && shouldBeVisible) || (otherName === 'ask' && isOtherWinVisible),\n };\n if (!shouldBeVisible) {\n finalVisibility[name] = false;\n }\n\n const targetLayout = layoutManager.calculateFeatureWindowLayout(finalVisibility);\n\n if (shouldBeVisible) {\n if (!win) return;\n const targetBounds = targetLayout[name];\n if (!targetBounds) return;\n\n const startPos = { ...targetBounds };\n if (name === 'listen') startPos.x -= ANIM_OFFSET_X;\n else if (name === 'ask') startPos.y -= ANIM_OFFSET_Y;\n\n win.setOpacity(0);\n win.setBounds(startPos);\n win.show();\n\n movementManager.fade(win, { to: 1 });\n movementManager.animateLayout(targetLayout);\n\n } else {\n if (!win || !win.isVisible()) return;\n\n const currentBounds = win.getBounds();\n const targetPos = { ...currentBounds };\n if (name === 'listen') targetPos.x -= ANIM_OFFSET_X;\n else if (name === 'ask') targetPos.y -= ANIM_OFFSET_Y;\n\n movementManager.fade(win, { to: 0, onComplete: () => win.hide() });\n movementManager.animateWindowPosition(win, targetPos);\n \n // 다른 창들도 새 레이아웃으로 애니메이션\n const otherWindowsLayout = { ...targetLayout };\n delete otherWindowsLayout[name];\n movementManager.animateLayout(otherWindowsLayout);\n }\n }\n}\n\n\nconst setContentProtection = (status) => {\n isContentProtectionOn = status;\n console.log(`[Protection] Content protection toggled to: ${isContentProtectionOn}`);\n windowPool.forEach(win => {\n if (win && !win.isDestroyed()) {\n win.setContentProtection(isContentProtectionOn);\n }\n });\n};\n\nconst getContentProtectionStatus = () => isContentProtectionOn;\n\nconst toggleContentProtection = () => {\n const newStatus = !getContentProtectionStatus();\n setContentProtection(newStatus);\n return newStatus;\n};\n\n\nconst openLoginPage = () => {\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n const personalizeUrl = `${webUrl}/personalize?desktop=true`;\n shell.openExternal(personalizeUrl);\n console.log('Opening personalization page:', personalizeUrl);\n};\n\n\nfunction createFeatureWindows(header, namesToCreate) {\n // if (windowPool.has('listen')) return;\n\n const commonChildOptions = {\n parent: header,\n show: false,\n frame: false,\n transparent: true,\n vibrancy: false,\n hasShadow: false,\n skipTaskbar: true,\n hiddenInMissionControl: true,\n resizable: false,\n webPreferences: {\n nodeIntegration: false,\n contextIsolation: true,\n preload: path.join(__dirname, '../preload.js'),\n },\n };\n\n const createFeatureWindow = (name) => {\n if (windowPool.has(name)) return;\n \n switch (name) {\n case 'listen': {\n const listen = new BrowserWindow({\n ...commonChildOptions, width:400,minWidth:400,maxWidth:900,\n maxHeight:900,\n });\n listen.setContentProtection(isContentProtectionOn);\n listen.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n listen.setWindowButtonVisibility(false);\n }\n const listenLoadOptions = { query: { view: 'listen' } };\n if (!shouldUseLiquidGlass) {\n listen.loadFile(path.join(__dirname, '../ui/app/content.html'), listenLoadOptions);\n }\n else {\n listenLoadOptions.query.glass = 'true';\n listen.loadFile(path.join(__dirname, '../ui/app/content.html'), listenLoadOptions);\n listen.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(listen.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n if (!app.isPackaged) {\n listen.webContents.openDevTools({ mode: 'detach' });\n }\n windowPool.set('listen', listen);\n break;\n }\n\n // ask\n case 'ask': {\n const ask = new BrowserWindow({ ...commonChildOptions, width:600 });\n ask.setContentProtection(isContentProtectionOn);\n ask.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n ask.setWindowButtonVisibility(false);\n }\n const askLoadOptions = { query: { view: 'ask' } };\n if (!shouldUseLiquidGlass) {\n ask.loadFile(path.join(__dirname, '../ui/app/content.html'), askLoadOptions);\n }\n else {\n askLoadOptions.query.glass = 'true';\n ask.loadFile(path.join(__dirname, '../ui/app/content.html'), askLoadOptions);\n ask.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(ask.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n \n // Open DevTools in development\n if (!app.isPackaged) {\n ask.webContents.openDevTools({ mode: 'detach' });\n }\n windowPool.set('ask', ask);\n break;\n }\n\n // settings\n case 'settings': {\n const settings = new BrowserWindow({ ...commonChildOptions, width:240, maxHeight:400, parent:undefined });\n settings.setContentProtection(isContentProtectionOn);\n settings.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n settings.setWindowButtonVisibility(false);\n }\n const settingsLoadOptions = { query: { view: 'settings' } };\n if (!shouldUseLiquidGlass) {\n settings.loadFile(path.join(__dirname,'../ui/app/content.html'), settingsLoadOptions)\n .catch(console.error);\n }\n else {\n settingsLoadOptions.query.glass = 'true';\n settings.loadFile(path.join(__dirname,'../ui/app/content.html'), settingsLoadOptions)\n .catch(console.error);\n settings.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(settings.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n windowPool.set('settings', settings); \n\n if (!app.isPackaged) {\n settings.webContents.openDevTools({ mode: 'detach' });\n }\n break;\n }\n\n case 'shortcut-settings': {\n const shortcutEditor = new BrowserWindow({\n ...commonChildOptions,\n width: 353,\n height: 720,\n modal: false,\n parent: undefined,\n alwaysOnTop: true,\n titleBarOverlay: false,\n });\n\n shortcutEditor.setContentProtection(isContentProtectionOn);\n shortcutEditor.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n shortcutEditor.setWindowButtonVisibility(false);\n }\n\n const loadOptions = { query: { view: 'shortcut-settings' } };\n if (!shouldUseLiquidGlass) {\n shortcutEditor.loadFile(path.join(__dirname, '../ui/app/content.html'), loadOptions);\n } else {\n loadOptions.query.glass = 'true';\n shortcutEditor.loadFile(path.join(__dirname, '../ui/app/content.html'), loadOptions);\n shortcutEditor.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(shortcutEditor.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n }\n });\n }\n\n windowPool.set('shortcut-settings', shortcutEditor);\n if (!app.isPackaged) {\n shortcutEditor.webContents.openDevTools({ mode: 'detach' });\n }\n break;\n }\n }\n };\n\n if (Array.isArray(namesToCreate)) {\n namesToCreate.forEach(name => createFeatureWindow(name));\n } else if (typeof namesToCreate === 'string') {\n createFeatureWindow(namesToCreate);\n } else {\n createFeatureWindow('listen');\n createFeatureWindow('ask');\n createFeatureWindow('settings');\n createFeatureWindow('shortcut-settings');\n }\n}\n\nfunction destroyFeatureWindows() {\n const featureWindows = ['listen','ask','settings','shortcut-settings'];\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n settingsHideTimer = null;\n }\n featureWindows.forEach(name=>{\n const win = windowPool.get(name);\n if (win && !win.isDestroyed()) win.destroy();\n windowPool.delete(name);\n });\n}\n\n\n\nfunction getCurrentDisplay(window) {\n if (!window || window.isDestroyed()) return screen.getPrimaryDisplay();\n\n const windowBounds = window.getBounds();\n const windowCenter = {\n x: windowBounds.x + windowBounds.width / 2,\n y: windowBounds.y + windowBounds.height / 2,\n };\n\n return screen.getDisplayNearestPoint(windowCenter);\n}\n\n\n\nfunction createWindows() {\n const HEADER_HEIGHT = 47;\n const DEFAULT_WINDOW_WIDTH = 353;\n\n const primaryDisplay = screen.getPrimaryDisplay();\n const { y: workAreaY, width: screenWidth } = primaryDisplay.workArea;\n\n const initialX = Math.round((screenWidth - DEFAULT_WINDOW_WIDTH) / 2);\n const initialY = workAreaY + 21;\n \n const header = new BrowserWindow({\n width: DEFAULT_WINDOW_WIDTH,\n height: HEADER_HEIGHT,\n x: initialX,\n y: initialY,\n frame: false,\n transparent: true,\n vibrancy: false,\n hasShadow: false,\n alwaysOnTop: true,\n skipTaskbar: true,\n hiddenInMissionControl: true,\n resizable: false,\n focusable: true,\n acceptFirstMouse: true,\n webPreferences: {\n nodeIntegration: false,\n contextIsolation: true,\n preload: path.join(__dirname, '../preload.js'),\n backgroundThrottling: false,\n webSecurity: false,\n enableRemoteModule: false,\n // Ensure proper rendering and prevent pixelation\n experimentalFeatures: false,\n },\n // Prevent pixelation and ensure proper rendering\n useContentSize: true,\n disableAutoHideCursor: true,\n });\n if (process.platform === 'darwin') {\n header.setWindowButtonVisibility(false);\n }\n const headerLoadOptions = {};\n if (!shouldUseLiquidGlass) {\n header.loadFile(path.join(__dirname, '../ui/app/header.html'), headerLoadOptions);\n }\n else {\n headerLoadOptions.query = { glass: 'true' };\n header.loadFile(path.join(__dirname, '../ui/app/header.html'), headerLoadOptions);\n header.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(header.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1); \n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n windowPool.set('header', header);\n layoutManager = new WindowLayoutManager(windowPool);\n movementManager = new SmoothMovementManager(windowPool);\n\n\n header.on('moved', () => {\n if (movementManager.isAnimating) {\n return;\n }\n updateChildWindowLayouts(false);\n });\n\n header.webContents.once('dom-ready', () => {\n shortcutsService.initialize(windowPool);\n shortcutsService.registerShortcuts();\n });\n\n setupIpcHandlers(windowPool, layoutManager);\n setupWindowController(windowPool, layoutManager, movementManager);\n\n if (currentHeaderState === 'main') {\n createFeatureWindows(header, ['listen', 'ask', 'settings', 'shortcut-settings']);\n }\n\n header.setContentProtection(isContentProtectionOn);\n header.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });\n \n // Open DevTools in development\n if (!app.isPackaged) {\n header.webContents.openDevTools({ mode: 'detach' });\n }\n\n header.on('focus', () => {\n console.log('[WindowManager] Header gained focus');\n });\n\n header.on('blur', () => {\n console.log('[WindowManager] Header lost focus');\n });\n\n header.webContents.on('before-input-event', (event, input) => {\n if (input.type === 'mouseDown') {\n const target = input.target;\n if (target && (target.includes('input') || target.includes('apikey'))) {\n header.focus();\n }\n }\n });\n\n header.on('resize', () => updateChildWindowLayouts(false));\n\n return windowPool;\n}\n\n\nfunction setupIpcHandlers(windowPool, layoutManager) {\n screen.on('display-added', (event, newDisplay) => {\n console.log('[Display] New display added:', newDisplay.id);\n });\n\n screen.on('display-removed', (event, oldDisplay) => {\n console.log('[Display] Display removed:', oldDisplay.id);\n const header = windowPool.get('header');\n\n if (header && getCurrentDisplay(header).id === oldDisplay.id) {\n const primaryDisplay = screen.getPrimaryDisplay();\n const newPosition = layoutManager.calculateNewPositionForDisplay(header, primaryDisplay.id);\n if (newPosition) {\n // 복구 상황이므로 애니메이션 없이 즉시 이동\n header.setPosition(newPosition.x, newPosition.y, false);\n updateChildWindowLayouts(false);\n }\n }\n });\n\n screen.on('display-metrics-changed', (event, display, changedMetrics) => {\n // 레이아웃 업데이트 함수를 새 버전으로 호출\n updateChildWindowLayouts(false);\n });\n}\n\n\nconst handleHeaderStateChanged = (state) => {\n console.log(`[WindowManager] Header state changed to: ${state}`);\n currentHeaderState = state;\n\n if (state === 'main') {\n createFeatureWindows(windowPool.get('header'));\n } else { // 'apikey' | 'permission'\n destroyFeatureWindows();\n }\n internalBridge.emit('reregister-shortcuts');\n};\n\n\nmodule.exports = {\n createWindows,\n windowPool,\n toggleContentProtection,\n resizeHeaderWindow,\n getContentProtectionStatus,\n showSettingsWindow,\n hideSettingsWindow,\n cancelHideSettingsWindow,\n openLoginPage,\n moveWindowStep,\n handleHeaderStateChanged,\n handleHeaderAnimationFinished,\n getHeaderPosition,\n moveHeaderTo,\n adjustWindowHeight,\n};"], ["/glass/src/features/common/services/authService.js", "const { onAuthStateChanged, signInWithCustomToken, signOut } = require('firebase/auth');\nconst { BrowserWindow, shell } = require('electron');\nconst { getFirebaseAuth } = require('./firebaseClient');\nconst fetch = require('node-fetch');\nconst encryptionService = require('./encryptionService');\nconst migrationService = require('./migrationService');\nconst sessionRepository = require('../repositories/session');\nconst providerSettingsRepository = require('../repositories/providerSettings');\nconst permissionService = require('./permissionService');\n\nasync function getVirtualKeyByEmail(email, idToken) {\n if (!idToken) {\n throw new Error('Firebase ID token is required for virtual key request');\n }\n\n const resp = await fetch('https://serverless-api-sf3o.vercel.app/api/virtual_key', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${idToken}`,\n },\n body: JSON.stringify({ email: email.trim().toLowerCase() }),\n redirect: 'follow',\n });\n\n const json = await resp.json().catch(() => ({}));\n if (!resp.ok) {\n console.error('[VK] API request failed:', json.message || 'Unknown error');\n throw new Error(json.message || `HTTP ${resp.status}: Virtual key request failed`);\n }\n\n const vKey = json?.data?.virtualKey || json?.data?.virtual_key || json?.data?.newVKey?.slug;\n\n if (!vKey) throw new Error('virtual key missing in response');\n return vKey;\n}\n\nclass AuthService {\n constructor() {\n this.currentUserId = 'default_user';\n this.currentUserMode = 'local'; // 'local' or 'firebase'\n this.currentUser = null;\n this.isInitialized = false;\n\n // This ensures the key is ready before any login/logout state change.\n this.initializationPromise = null;\n\n sessionRepository.setAuthService(this);\n }\n\n initialize() {\n if (this.isInitialized) return this.initializationPromise;\n\n this.initializationPromise = new Promise((resolve) => {\n const auth = getFirebaseAuth();\n onAuthStateChanged(auth, async (user) => {\n const previousUser = this.currentUser;\n\n if (user) {\n // User signed IN\n console.log(`[AuthService] Firebase user signed in:`, user.uid);\n this.currentUser = user;\n this.currentUserId = user.uid;\n this.currentUserMode = 'firebase';\n\n // Clean up any zombie sessions from a previous run for this user.\n await sessionRepository.endAllActiveSessions();\n\n // ** Initialize encryption key for the logged-in user if permissions are already granted **\n if (process.platform === 'darwin' && !(await permissionService.checkKeychainCompleted(this.currentUserId))) {\n console.warn('[AuthService] Keychain permission not yet completed for this user. Deferring key initialization.');\n } else {\n await encryptionService.initializeKey(user.uid);\n }\n\n // ** Check for and run data migration for the user **\n // No 'await' here, so it runs in the background without blocking startup.\n migrationService.checkAndRunMigration(user);\n\n // ***** CRITICAL: Wait for the virtual key and model state update to complete *****\n try {\n const idToken = await user.getIdToken(true);\n const virtualKey = await getVirtualKeyByEmail(user.email, idToken);\n\n if (global.modelStateService) {\n // The model state service now writes directly to the DB, no in-memory state.\n await global.modelStateService.setFirebaseVirtualKey(virtualKey);\n }\n console.log(`[AuthService] Virtual key for ${user.email} has been processed and state updated.`);\n\n } catch (error) {\n console.error('[AuthService] Failed to fetch or save virtual key:', error);\n // This is not critical enough to halt the login, but we should log it.\n }\n\n } else {\n // User signed OUT\n console.log(`[AuthService] No Firebase user.`);\n if (previousUser) {\n console.log(`[AuthService] Clearing API key for logged-out user: ${previousUser.uid}`);\n if (global.modelStateService) {\n // The model state service now writes directly to the DB.\n await global.modelStateService.setFirebaseVirtualKey(null);\n }\n }\n this.currentUser = null;\n this.currentUserId = 'default_user';\n this.currentUserMode = 'local';\n\n // End active sessions for the local/default user as well.\n await sessionRepository.endAllActiveSessions();\n\n encryptionService.resetSessionKey();\n }\n this.broadcastUserState();\n \n if (!this.isInitialized) {\n this.isInitialized = true;\n console.log('[AuthService] Initialized and resolved initialization promise.');\n resolve();\n }\n });\n });\n\n return this.initializationPromise;\n }\n\n async startFirebaseAuthFlow() {\n try {\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n const authUrl = `${webUrl}/login?mode=electron`;\n console.log(`[AuthService] Opening Firebase auth URL in browser: ${authUrl}`);\n await shell.openExternal(authUrl);\n return { success: true };\n } catch (error) {\n console.error('[AuthService] Failed to open Firebase auth URL:', error);\n return { success: false, error: error.message };\n }\n }\n\n async signInWithCustomToken(token) {\n const auth = getFirebaseAuth();\n try {\n const userCredential = await signInWithCustomToken(auth, token);\n console.log(`[AuthService] Successfully signed in with custom token for user:`, userCredential.user.uid);\n // onAuthStateChanged will handle the state update and broadcast\n } catch (error) {\n console.error('[AuthService] Error signing in with custom token:', error);\n throw error; // Re-throw to be handled by the caller\n }\n }\n\n async signOut() {\n const auth = getFirebaseAuth();\n try {\n // End all active sessions for the current user BEFORE signing out.\n await sessionRepository.endAllActiveSessions();\n\n await signOut(auth);\n console.log('[AuthService] User sign-out initiated successfully.');\n // onAuthStateChanged will handle the state update and broadcast,\n // which will also re-evaluate the API key status.\n } catch (error) {\n console.error('[AuthService] Error signing out:', error);\n }\n }\n \n broadcastUserState() {\n const userState = this.getCurrentUser();\n console.log('[AuthService] Broadcasting user state change:', userState);\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed() && win.webContents && !win.webContents.isDestroyed()) {\n win.webContents.send('user-state-changed', userState);\n }\n });\n }\n\n getCurrentUserId() {\n return this.currentUserId;\n }\n\n getCurrentUser() {\n const isLoggedIn = !!(this.currentUserMode === 'firebase' && this.currentUser);\n\n if (isLoggedIn) {\n return {\n uid: this.currentUser.uid,\n email: this.currentUser.email,\n displayName: this.currentUser.displayName,\n mode: 'firebase',\n isLoggedIn: true,\n //////// before_modelStateService ////////\n // hasApiKey: this.hasApiKey // Always true for firebase users, but good practice\n //////// before_modelStateService ////////\n };\n }\n return {\n uid: this.currentUserId, // returns 'default_user'\n email: 'contact@pickle.com',\n displayName: 'Default User',\n mode: 'local',\n isLoggedIn: false,\n //////// before_modelStateService ////////\n // hasApiKey: this.hasApiKey\n //////// before_modelStateService ////////\n };\n }\n}\n\nconst authService = new AuthService();\nmodule.exports = authService; "], ["/glass/src/features/common/ai/providers/gemini.js", "const { GoogleGenerativeAI } = require(\"@google/generative-ai\")\nconst { GoogleGenAI } = require(\"@google/genai\")\n\nclass GeminiProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string') {\n return { success: false, error: 'Invalid Gemini API key format.' };\n }\n\n try {\n const validationUrl = `https://generativelanguage.googleapis.com/v1beta/models?key=${key}`;\n const response = await fetch(validationUrl);\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error?.message || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[GeminiProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n\n/**\n * Creates a Gemini STT session\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Gemini API key\n * @param {string} [opts.language='en-US'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @returns {Promise} STT session\n */\nasync function createSTT({ apiKey, language = \"en-US\", callbacks = {}, ...config }) {\n const liveClient = new GoogleGenAI({ vertexai: false, apiKey })\n\n // Language code BCP-47 conversion\n const lang = language.includes(\"-\") ? language : `${language}-US`\n\n const session = await liveClient.live.connect({\n\n model: 'gemini-live-2.5-flash-preview',\n callbacks: {\n ...callbacks,\n onMessage: (msg) => {\n if (!msg || typeof msg !== 'object') return;\n msg.provider = 'gemini';\n callbacks.onmessage?.(msg);\n }\n },\n\n config: {\n inputAudioTranscription: {},\n speechConfig: { languageCode: lang },\n },\n })\n\n return {\n sendRealtimeInput: async (payload) => session.sendRealtimeInput(payload),\n close: async () => session.close(),\n }\n}\n\n/**\n * Creates a Gemini LLM instance with proper text response handling\n */\nfunction createLLM({ apiKey, model = \"gemini-2.5-flash\", temperature = 0.7, maxTokens = 8192, ...config }) {\n const client = new GoogleGenerativeAI(apiKey)\n\n return {\n generateContent: async (parts) => {\n const geminiModel = client.getGenerativeModel({\n model: model,\n generationConfig: {\n temperature,\n maxOutputTokens: maxTokens,\n // Ensure we get text responses, not JSON\n responseMimeType: \"text/plain\",\n },\n })\n\n const systemPrompt = \"\"\n const userContent = []\n\n for (const part of parts) {\n if (typeof part === \"string\") {\n // Don't automatically assume strings starting with \"You are\" are system prompts\n // Check if it's explicitly marked as a system instruction\n userContent.push(part)\n } else if (part.inlineData) {\n userContent.push({\n inlineData: {\n mimeType: part.inlineData.mimeType,\n data: part.inlineData.data,\n },\n })\n }\n }\n\n try {\n const result = await geminiModel.generateContent(userContent)\n const response = await result.response\n\n // Return plain text, not wrapped in JSON structure\n return {\n response: {\n text: () => response.text(),\n },\n }\n } catch (error) {\n console.error(\"Gemini API error:\", error)\n throw error\n }\n },\n\n chat: async (messages) => {\n // Filter out any system prompts that might be causing JSON responses\n let systemInstruction = \"\"\n const history = []\n let lastMessage\n\n messages.forEach((msg, index) => {\n if (msg.role === \"system\") {\n // Clean system instruction - avoid JSON formatting requests\n systemInstruction = msg.content\n .replace(/respond in json/gi, \"\")\n .replace(/format.*json/gi, \"\")\n .replace(/return.*json/gi, \"\")\n\n // Add explicit instruction for natural text\n if (!systemInstruction.includes(\"respond naturally\")) {\n systemInstruction += \"\\n\\nRespond naturally in plain text, not in JSON or structured format.\"\n }\n return\n }\n\n const role = msg.role === \"user\" ? \"user\" : \"model\"\n\n if (index === messages.length - 1) {\n lastMessage = msg\n } else {\n history.push({ role, parts: [{ text: msg.content }] })\n }\n })\n\n const geminiModel = client.getGenerativeModel({\n model: model,\n systemInstruction:\n systemInstruction ||\n \"Respond naturally in plain text format. Do not use JSON or structured responses unless specifically requested.\",\n generationConfig: {\n temperature: temperature,\n maxOutputTokens: maxTokens,\n // Force plain text responses\n responseMimeType: \"text/plain\",\n },\n })\n\n const chat = geminiModel.startChat({\n history: history,\n })\n\n let content = lastMessage.content\n\n // Handle multimodal content\n if (Array.isArray(content)) {\n const geminiContent = []\n for (const part of content) {\n if (typeof part === \"string\") {\n geminiContent.push(part)\n } else if (part.type === \"text\") {\n geminiContent.push(part.text)\n } else if (part.type === \"image_url\" && part.image_url) {\n const base64Data = part.image_url.url.split(\",\")[1]\n geminiContent.push({\n inlineData: {\n mimeType: \"image/png\",\n data: base64Data,\n },\n })\n }\n }\n content = geminiContent\n }\n\n const result = await chat.sendMessage(content)\n const response = await result.response\n\n // Return plain text content\n return {\n content: response.text(),\n raw: result,\n }\n },\n }\n}\n\n/**\n * Creates a Gemini streaming LLM instance with text response fix\n */\nfunction createStreamingLLM({ apiKey, model = \"gemini-2.5-flash\", temperature = 0.7, maxTokens = 8192, ...config }) {\n const client = new GoogleGenerativeAI(apiKey)\n\n return {\n streamChat: async (messages) => {\n console.log(\"[Gemini Provider] Starting streaming request\")\n\n let systemInstruction = \"\"\n const nonSystemMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n // Clean and modify system instruction\n systemInstruction = msg.content\n .replace(/respond in json/gi, \"\")\n .replace(/format.*json/gi, \"\")\n .replace(/return.*json/gi, \"\")\n\n if (!systemInstruction.includes(\"respond naturally\")) {\n systemInstruction += \"\\n\\nRespond naturally in plain text, not in JSON or structured format.\"\n }\n } else {\n nonSystemMessages.push(msg)\n }\n }\n\n const geminiModel = client.getGenerativeModel({\n model: model,\n systemInstruction:\n systemInstruction ||\n \"Respond naturally in plain text format. Do not use JSON or structured responses unless specifically requested.\",\n generationConfig: {\n temperature,\n maxOutputTokens: maxTokens || 8192,\n // Force plain text responses\n responseMimeType: \"text/plain\",\n },\n })\n\n const stream = new ReadableStream({\n async start(controller) {\n try {\n const lastMessage = nonSystemMessages[nonSystemMessages.length - 1]\n let geminiContent = []\n\n if (Array.isArray(lastMessage.content)) {\n for (const part of lastMessage.content) {\n if (typeof part === \"string\") {\n geminiContent.push(part)\n } else if (part.type === \"text\") {\n geminiContent.push(part.text)\n } else if (part.type === \"image_url\" && part.image_url) {\n const base64Data = part.image_url.url.split(\",\")[1]\n geminiContent.push({\n inlineData: {\n mimeType: \"image/png\",\n data: base64Data,\n },\n })\n }\n }\n } else {\n geminiContent = [lastMessage.content]\n }\n\n const contentParts = geminiContent.map((part) => {\n if (typeof part === \"string\") {\n return { text: part }\n } else if (part.inlineData) {\n return { inlineData: part.inlineData }\n }\n return part\n })\n\n const result = await geminiModel.generateContentStream({\n contents: [\n {\n role: \"user\",\n parts: contentParts,\n },\n ],\n })\n\n for await (const chunk of result.stream) {\n const chunkText = chunk.text() || \"\"\n\n // Format as SSE data - this should now be plain text\n const data = JSON.stringify({\n choices: [\n {\n delta: {\n content: chunkText,\n },\n },\n ],\n })\n controller.enqueue(new TextEncoder().encode(`data: ${data}\\n\\n`))\n }\n\n controller.enqueue(new TextEncoder().encode(\"data: [DONE]\\n\\n\"))\n controller.close()\n } catch (error) {\n console.error(\"[Gemini Provider] Streaming error:\", error)\n controller.error(error)\n }\n },\n })\n\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n },\n })\n },\n }\n}\n\nmodule.exports = {\n GeminiProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};\n"], ["/glass/src/features/listen/stt/sttService.js", "const { BrowserWindow } = require('electron');\nconst { spawn } = require('child_process');\nconst { createSTT } = require('../../common/ai/factory');\nconst modelStateService = require('../../common/services/modelStateService');\n\nconst COMPLETION_DEBOUNCE_MS = 2000;\n\n// ── New heartbeat / renewal constants ────────────────────────────────────────────\n// Interval to send low-cost keep-alive messages so the remote service does not\n// treat the connection as idle. One minute is safely below the typical 2-5 min\n// idle timeout window seen on provider websockets.\nconst KEEP_ALIVE_INTERVAL_MS = 60 * 1000; // 1 minute\n\n// Interval after which we pro-actively tear down and recreate the STT sessions\n// to dodge the 30-minute hard timeout enforced by some providers. 20 minutes\n// gives a 10-minute safety buffer.\nconst SESSION_RENEW_INTERVAL_MS = 20 * 60 * 1000; // 20 minutes\n\n// Duration to allow the old and new sockets to run in parallel so we don't\n// miss any packets at the exact swap moment.\nconst SOCKET_OVERLAP_MS = 2 * 1000; // 2 seconds\n\nclass SttService {\n constructor() {\n this.mySttSession = null;\n this.theirSttSession = null;\n this.myCurrentUtterance = '';\n this.theirCurrentUtterance = '';\n \n // Turn-completion debouncing\n this.myCompletionBuffer = '';\n this.theirCompletionBuffer = '';\n this.myCompletionTimer = null;\n this.theirCompletionTimer = null;\n \n // System audio capture\n this.systemAudioProc = null;\n\n // Keep-alive / renewal timers\n this.keepAliveInterval = null;\n this.sessionRenewTimeout = null;\n\n // Callbacks\n this.onTranscriptionComplete = null;\n this.onStatusUpdate = null;\n\n this.modelInfo = null; \n }\n\n setCallbacks({ onTranscriptionComplete, onStatusUpdate }) {\n this.onTranscriptionComplete = onTranscriptionComplete;\n this.onStatusUpdate = onStatusUpdate;\n }\n\n sendToRenderer(channel, data) {\n // Listen 관련 이벤트는 Listen 윈도우에만 전송 (Ask 윈도우 충돌 방지)\n const { windowPool } = require('../../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n async handleSendSystemAudioContent(data, mimeType) {\n try {\n await this.sendSystemAudioContent(data, mimeType);\n this.sendToRenderer('system-audio-data', { data });\n return { success: true };\n } catch (error) {\n console.error('Error sending system audio:', error);\n return { success: false, error: error.message };\n }\n }\n\n flushMyCompletion() {\n const finalText = (this.myCompletionBuffer + this.myCurrentUtterance).trim();\n if (!this.modelInfo || !finalText) return;\n\n // Notify completion callback\n if (this.onTranscriptionComplete) {\n this.onTranscriptionComplete('Me', finalText);\n }\n \n // Send to renderer as final\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n\n this.myCompletionBuffer = '';\n this.myCompletionTimer = null;\n this.myCurrentUtterance = '';\n \n if (this.onStatusUpdate) {\n this.onStatusUpdate('Listening...');\n }\n }\n\n flushTheirCompletion() {\n const finalText = (this.theirCompletionBuffer + this.theirCurrentUtterance).trim();\n if (!this.modelInfo || !finalText) return;\n \n // Notify completion callback\n if (this.onTranscriptionComplete) {\n this.onTranscriptionComplete('Them', finalText);\n }\n \n // Send to renderer as final\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n\n this.theirCompletionBuffer = '';\n this.theirCompletionTimer = null;\n this.theirCurrentUtterance = '';\n \n if (this.onStatusUpdate) {\n this.onStatusUpdate('Listening...');\n }\n }\n\n debounceMyCompletion(text) {\n if (this.modelInfo?.provider === 'gemini') {\n this.myCompletionBuffer += text;\n } else {\n this.myCompletionBuffer += (this.myCompletionBuffer ? ' ' : '') + text;\n }\n\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = setTimeout(() => this.flushMyCompletion(), COMPLETION_DEBOUNCE_MS);\n }\n\n debounceTheirCompletion(text) {\n if (this.modelInfo?.provider === 'gemini') {\n this.theirCompletionBuffer += text;\n } else {\n this.theirCompletionBuffer += (this.theirCompletionBuffer ? ' ' : '') + text;\n }\n\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = setTimeout(() => this.flushTheirCompletion(), COMPLETION_DEBOUNCE_MS);\n }\n\n async initializeSttSessions(language = 'en') {\n const effectiveLanguage = process.env.OPENAI_TRANSCRIBE_LANG || language || 'en';\n\n const modelInfo = await modelStateService.getCurrentModelInfo('stt');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key is not configured.');\n }\n this.modelInfo = modelInfo;\n console.log(`[SttService] Initializing STT for ${modelInfo.provider} using model ${modelInfo.model}`);\n\n const handleMyMessage = message => {\n if (!this.modelInfo) {\n console.log('[SttService] Ignoring message - session already closed');\n return;\n }\n // console.log('[SttService] handleMyMessage', message);\n \n if (this.modelInfo.provider === 'whisper') {\n // Whisper STT emits 'transcription' events with different structure\n if (message.text && message.text.trim()) {\n const finalText = message.text.trim();\n \n // Filter out Whisper noise transcriptions\n const noisePatterns = [\n '[BLANK_AUDIO]',\n '[INAUDIBLE]',\n '[MUSIC]',\n '[SOUND]',\n '[NOISE]',\n '(BLANK_AUDIO)',\n '(INAUDIBLE)',\n '(MUSIC)',\n '(SOUND)',\n '(NOISE)'\n ];\n \n const isNoise = noisePatterns.some(pattern => \n finalText.includes(pattern) || finalText === pattern\n );\n \n \n if (!isNoise && finalText.length > 2) {\n this.debounceMyCompletion(finalText);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n } else {\n console.log(`[Whisper-Me] Filtered noise: \"${finalText}\"`);\n }\n }\n return;\n } else if (this.modelInfo.provider === 'gemini') {\n if (!message.serverContent?.modelTurn) {\n console.log('[Gemini STT - Me]', JSON.stringify(message, null, 2));\n }\n\n if (message.serverContent?.turnComplete) {\n if (this.myCompletionTimer) {\n clearTimeout(this.myCompletionTimer);\n this.flushMyCompletion();\n }\n return;\n }\n \n const transcription = message.serverContent?.inputTranscription;\n if (!transcription || !transcription.text) return;\n \n const textChunk = transcription.text;\n if (!textChunk.trim() || textChunk.trim() === '') {\n return; // 1. Ignore whitespace-only chunks or noise\n }\n \n this.debounceMyCompletion(textChunk);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: this.myCompletionBuffer,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n \n // Deepgram \n } else if (this.modelInfo.provider === 'deepgram') {\n const text = message.channel?.alternatives?.[0]?.transcript;\n if (!text || text.trim().length === 0) return;\n\n const isFinal = message.is_final;\n console.log(`[SttService-Me-Deepgram] Received: isFinal=${isFinal}, text=\"${text}\"`);\n\n if (isFinal) {\n // 최종 결과가 도착하면, 현재 진행중인 부분 발화는 비우고\n // 최종 텍스트로 debounce를 실행합니다.\n this.myCurrentUtterance = ''; \n this.debounceMyCompletion(text); \n } else {\n // 부분 결과(interim)인 경우, 화면에 실시간으로 업데이트합니다.\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n\n this.myCurrentUtterance = text;\n \n const continuousText = (this.myCompletionBuffer + ' ' + this.myCurrentUtterance).trim();\n\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n \n } else {\n const type = message.type;\n const text = message.transcript || message.delta || (message.alternatives && message.alternatives[0]?.transcript) || '';\n\n if (type === 'conversation.item.input_audio_transcription.delta') {\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n this.myCurrentUtterance += text;\n const continuousText = this.myCompletionBuffer + (this.myCompletionBuffer ? ' ' : '') + this.myCurrentUtterance;\n if (text && !text.includes('vq_lbr_audio_')) {\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n } else if (type === 'conversation.item.input_audio_transcription.completed') {\n if (text && text.trim()) {\n const finalUtteranceText = text.trim();\n this.myCurrentUtterance = '';\n this.debounceMyCompletion(finalUtteranceText);\n }\n }\n }\n\n if (message.error) {\n console.error('[Me] STT Session Error:', message.error);\n }\n };\n\n const handleTheirMessage = message => {\n if (!message || typeof message !== 'object') return;\n\n if (!this.modelInfo) {\n console.log('[SttService] Ignoring message - session already closed');\n return;\n }\n \n if (this.modelInfo.provider === 'whisper') {\n // Whisper STT emits 'transcription' events with different structure\n if (message.text && message.text.trim()) {\n const finalText = message.text.trim();\n \n // Filter out Whisper noise transcriptions\n const noisePatterns = [\n '[BLANK_AUDIO]',\n '[INAUDIBLE]',\n '[MUSIC]',\n '[SOUND]',\n '[NOISE]',\n '(BLANK_AUDIO)',\n '(INAUDIBLE)',\n '(MUSIC)',\n '(SOUND)',\n '(NOISE)'\n ];\n \n const isNoise = noisePatterns.some(pattern => \n finalText.includes(pattern) || finalText === pattern\n );\n \n \n // Only process if it's not noise, not a false positive, and has meaningful content\n if (!isNoise && finalText.length > 2) {\n this.debounceTheirCompletion(finalText);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n } else {\n console.log(`[Whisper-Them] Filtered noise: \"${finalText}\"`);\n }\n }\n return;\n } else if (this.modelInfo.provider === 'gemini') {\n if (!message.serverContent?.modelTurn) {\n console.log('[Gemini STT - Them]', JSON.stringify(message, null, 2));\n }\n\n if (message.serverContent?.turnComplete) {\n if (this.theirCompletionTimer) {\n clearTimeout(this.theirCompletionTimer);\n this.flushTheirCompletion();\n }\n return;\n }\n \n const transcription = message.serverContent?.inputTranscription;\n if (!transcription || !transcription.text) return;\n\n const textChunk = transcription.text;\n if (!textChunk.trim() || textChunk.trim() === '') {\n return; // 1. Ignore whitespace-only chunks or noise\n }\n\n this.debounceTheirCompletion(textChunk);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: this.theirCompletionBuffer,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n\n // Deepgram\n } else if (this.modelInfo.provider === 'deepgram') {\n const text = message.channel?.alternatives?.[0]?.transcript;\n if (!text || text.trim().length === 0) return;\n\n const isFinal = message.is_final;\n\n if (isFinal) {\n this.theirCurrentUtterance = ''; \n this.debounceTheirCompletion(text); \n } else {\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n\n this.theirCurrentUtterance = text;\n \n const continuousText = (this.theirCompletionBuffer + ' ' + this.theirCurrentUtterance).trim();\n\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n\n } else {\n const type = message.type;\n const text = message.transcript || message.delta || (message.alternatives && message.alternatives[0]?.transcript) || '';\n if (type === 'conversation.item.input_audio_transcription.delta') {\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n this.theirCurrentUtterance += text;\n const continuousText = this.theirCompletionBuffer + (this.theirCompletionBuffer ? ' ' : '') + this.theirCurrentUtterance;\n if (text && !text.includes('vq_lbr_audio_')) {\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n } else if (type === 'conversation.item.input_audio_transcription.completed') {\n if (text && text.trim()) {\n const finalUtteranceText = text.trim();\n this.theirCurrentUtterance = '';\n this.debounceTheirCompletion(finalUtteranceText);\n }\n }\n }\n \n if (message.error) {\n console.error('[Them] STT Session Error:', message.error);\n }\n };\n\n const mySttConfig = {\n language: effectiveLanguage,\n callbacks: {\n onmessage: handleMyMessage,\n onerror: error => console.error('My STT session error:', error.message),\n onclose: event => console.log('My STT session closed:', event.reason),\n },\n };\n \n const theirSttConfig = {\n language: effectiveLanguage,\n callbacks: {\n onmessage: handleTheirMessage,\n onerror: error => console.error('Their STT session error:', error.message),\n onclose: event => console.log('Their STT session closed:', event.reason),\n },\n };\n \n const sttOptions = {\n apiKey: this.modelInfo.apiKey,\n language: effectiveLanguage,\n usePortkey: this.modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: this.modelInfo.provider === 'openai-glass' ? this.modelInfo.apiKey : undefined,\n };\n\n // Add sessionType for Whisper to distinguish between My and Their sessions\n const myOptions = { ...sttOptions, callbacks: mySttConfig.callbacks, sessionType: 'my' };\n const theirOptions = { ...sttOptions, callbacks: theirSttConfig.callbacks, sessionType: 'their' };\n\n [this.mySttSession, this.theirSttSession] = await Promise.all([\n createSTT(this.modelInfo.provider, myOptions),\n createSTT(this.modelInfo.provider, theirOptions),\n ]);\n\n console.log('✅ Both STT sessions initialized successfully.');\n\n // ── Setup keep-alive heart-beats ────────────────────────────────────────\n if (this.keepAliveInterval) clearInterval(this.keepAliveInterval);\n this.keepAliveInterval = setInterval(() => {\n this._sendKeepAlive();\n }, KEEP_ALIVE_INTERVAL_MS);\n\n // ── Schedule session auto-renewal ───────────────────────────────────────\n if (this.sessionRenewTimeout) clearTimeout(this.sessionRenewTimeout);\n this.sessionRenewTimeout = setTimeout(async () => {\n try {\n console.log('[SttService] Auto-renewing STT sessions…');\n await this.renewSessions(language);\n } catch (err) {\n console.error('[SttService] Failed to renew STT sessions:', err);\n }\n }, SESSION_RENEW_INTERVAL_MS);\n\n return true;\n }\n\n /**\n * Send a lightweight keep-alive to prevent idle disconnects.\n * Currently only implemented for OpenAI provider because Gemini's SDK\n * already performs its own heart-beats.\n */\n _sendKeepAlive() {\n if (!this.isSessionActive()) return;\n\n if (this.modelInfo?.provider === 'openai') {\n try {\n this.mySttSession?.keepAlive?.();\n this.theirSttSession?.keepAlive?.();\n } catch (err) {\n console.error('[SttService] keepAlive error:', err.message);\n }\n }\n }\n\n /**\n * Gracefully tears down then recreates the STT sessions. Should be invoked\n * on a timer to avoid provider-side hard timeouts.\n */\n async renewSessions(language = 'en') {\n if (!this.isSessionActive()) {\n console.warn('[SttService] renewSessions called but no active session.');\n return;\n }\n\n const oldMySession = this.mySttSession;\n const oldTheirSession = this.theirSttSession;\n\n console.log('[SttService] Spawning fresh STT sessions in the background…');\n\n // We reuse initializeSttSessions to create fresh sessions with the same\n // language and handlers. The method will update the session pointers\n // and timers, but crucially it does NOT touch the system audio capture\n // pipeline, so audio continues flowing uninterrupted.\n await this.initializeSttSessions(language);\n\n // Close the old sessions after a short overlap window.\n setTimeout(() => {\n try {\n oldMySession?.close?.();\n oldTheirSession?.close?.();\n console.log('[SttService] Old STT sessions closed after hand-off.');\n } catch (err) {\n console.error('[SttService] Error closing old STT sessions:', err.message);\n }\n }, SOCKET_OVERLAP_MS);\n }\n\n async sendMicAudioContent(data, mimeType) {\n // const provider = await this.getAiProvider();\n // const isGemini = provider === 'gemini';\n \n if (!this.mySttSession) {\n throw new Error('User STT session not active');\n }\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data, mimeType: mimeType || 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(data, 'base64'); \n } else {\n payload = data;\n }\n await this.mySttSession.sendRealtimeInput(payload);\n }\n\n async sendSystemAudioContent(data, mimeType) {\n if (!this.theirSttSession) {\n throw new Error('Their STT session not active');\n }\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data, mimeType: mimeType || 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(data, 'base64');\n } else {\n payload = data;\n }\n\n await this.theirSttSession.sendRealtimeInput(payload);\n }\n\n killExistingSystemAudioDump() {\n return new Promise(resolve => {\n console.log('Checking for existing SystemAudioDump processes...');\n\n const killProc = spawn('pkill', ['-f', 'SystemAudioDump'], {\n stdio: 'ignore',\n });\n\n killProc.on('close', code => {\n if (code === 0) {\n console.log('Killed existing SystemAudioDump processes');\n } else {\n console.log('No existing SystemAudioDump processes found');\n }\n resolve();\n });\n\n killProc.on('error', err => {\n console.log('Error checking for existing processes (this is normal):', err.message);\n resolve();\n });\n\n setTimeout(() => {\n killProc.kill();\n resolve();\n }, 2000);\n });\n }\n\n async startMacOSAudioCapture() {\n if (process.platform !== 'darwin' || !this.theirSttSession) return false;\n\n await this.killExistingSystemAudioDump();\n console.log('Starting macOS audio capture for \"Them\"...');\n\n const { app } = require('electron');\n const path = require('path');\n const systemAudioPath = app.isPackaged\n ? path.join(process.resourcesPath, 'app.asar.unpacked', 'src', 'ui', 'assets', 'SystemAudioDump')\n : path.join(app.getAppPath(), 'src', 'ui', 'assets', 'SystemAudioDump');\n\n console.log('SystemAudioDump path:', systemAudioPath);\n\n this.systemAudioProc = spawn(systemAudioPath, [], {\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n\n if (!this.systemAudioProc.pid) {\n console.error('Failed to start SystemAudioDump');\n return false;\n }\n\n console.log('SystemAudioDump started with PID:', this.systemAudioProc.pid);\n\n const CHUNK_DURATION = 0.1;\n const SAMPLE_RATE = 24000;\n const BYTES_PER_SAMPLE = 2;\n const CHANNELS = 2;\n const CHUNK_SIZE = SAMPLE_RATE * BYTES_PER_SAMPLE * CHANNELS * CHUNK_DURATION;\n\n let audioBuffer = Buffer.alloc(0);\n\n // const provider = await this.getAiProvider();\n // const isGemini = provider === 'gemini';\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n this.systemAudioProc.stdout.on('data', async data => {\n audioBuffer = Buffer.concat([audioBuffer, data]);\n\n while (audioBuffer.length >= CHUNK_SIZE) {\n const chunk = audioBuffer.slice(0, CHUNK_SIZE);\n audioBuffer = audioBuffer.slice(CHUNK_SIZE);\n\n const monoChunk = CHANNELS === 2 ? this.convertStereoToMono(chunk) : chunk;\n const base64Data = monoChunk.toString('base64');\n\n this.sendToRenderer('system-audio-data', { data: base64Data });\n\n if (this.theirSttSession) {\n try {\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data: base64Data, mimeType: 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(base64Data, 'base64');\n } else {\n payload = base64Data;\n }\n\n await this.theirSttSession.sendRealtimeInput(payload);\n } catch (err) {\n console.error('Error sending system audio:', err.message);\n }\n }\n }\n });\n\n this.systemAudioProc.stderr.on('data', data => {\n console.error('SystemAudioDump stderr:', data.toString());\n });\n\n this.systemAudioProc.on('close', code => {\n console.log('SystemAudioDump process closed with code:', code);\n this.systemAudioProc = null;\n });\n\n this.systemAudioProc.on('error', err => {\n console.error('SystemAudioDump process error:', err);\n this.systemAudioProc = null;\n });\n\n return true;\n }\n\n convertStereoToMono(stereoBuffer) {\n const samples = stereoBuffer.length / 4;\n const monoBuffer = Buffer.alloc(samples * 2);\n\n for (let i = 0; i < samples; i++) {\n const leftSample = stereoBuffer.readInt16LE(i * 4);\n monoBuffer.writeInt16LE(leftSample, i * 2);\n }\n\n return monoBuffer;\n }\n\n stopMacOSAudioCapture() {\n if (this.systemAudioProc) {\n console.log('Stopping SystemAudioDump...');\n this.systemAudioProc.kill('SIGTERM');\n this.systemAudioProc = null;\n }\n }\n\n isSessionActive() {\n return !!this.mySttSession && !!this.theirSttSession;\n }\n\n async closeSessions() {\n this.stopMacOSAudioCapture();\n\n // Clear heartbeat / renewal timers\n if (this.keepAliveInterval) {\n clearInterval(this.keepAliveInterval);\n this.keepAliveInterval = null;\n }\n if (this.sessionRenewTimeout) {\n clearTimeout(this.sessionRenewTimeout);\n this.sessionRenewTimeout = null;\n }\n\n // Clear timers\n if (this.myCompletionTimer) {\n clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n }\n if (this.theirCompletionTimer) {\n clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n }\n\n const closePromises = [];\n if (this.mySttSession) {\n closePromises.push(this.mySttSession.close());\n this.mySttSession = null;\n }\n if (this.theirSttSession) {\n closePromises.push(this.theirSttSession.close());\n this.theirSttSession = null;\n }\n\n await Promise.all(closePromises);\n console.log('All STT sessions closed.');\n\n // Reset state\n this.myCurrentUtterance = '';\n this.theirCurrentUtterance = '';\n this.myCompletionBuffer = '';\n this.theirCompletionBuffer = '';\n this.modelInfo = null; \n }\n}\n\nmodule.exports = SttService; "], ["/glass/src/features/common/repositories/session/firebase.repository.js", "const { doc, getDoc, collection, addDoc, query, where, getDocs, writeBatch, orderBy, limit, updateDoc, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst sessionConverter = createEncryptedConverter(['title']);\n\nfunction sessionsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'sessions').withConverter(sessionConverter);\n}\n\n// Sub-collection references are now built from the top-level\nfunction subCollections(sessionId) {\n const db = getFirestoreInstance();\n const sessionPath = `sessions/${sessionId}`;\n return {\n transcripts: collection(db, `${sessionPath}/transcripts`),\n ai_messages: collection(db, `${sessionPath}/ai_messages`),\n summary: collection(db, `${sessionPath}/summary`),\n }\n}\n\nasync function getById(id) {\n const docRef = doc(sessionsCol(), id);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\nasync function create(uid, type = 'ask') {\n const now = Timestamp.now();\n const newSession = {\n uid: uid,\n members: [uid], // For future sharing functionality\n title: `Session @ ${new Date().toLocaleTimeString()}`,\n session_type: type,\n started_at: now,\n updated_at: now,\n ended_at: null,\n };\n const docRef = await addDoc(sessionsCol(), newSession);\n console.log(`Firebase: Created session ${docRef.id} for user ${uid}`);\n return docRef.id;\n}\n\nasync function getAllByUserId(uid) {\n const q = query(sessionsCol(), where('members', 'array-contains', uid), orderBy('started_at', 'desc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nasync function updateTitle(id, title) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, {\n title: encryptionService.encrypt(title),\n updated_at: Timestamp.now()\n });\n return { changes: 1 };\n}\n\nasync function deleteWithRelatedData(id) {\n const db = getFirestoreInstance();\n const batch = writeBatch(db);\n\n const { transcripts, ai_messages, summary } = subCollections(id);\n const [transcriptsSnap, aiMessagesSnap, summarySnap] = await Promise.all([\n getDocs(query(transcripts)),\n getDocs(query(ai_messages)),\n getDocs(query(summary)),\n ]);\n \n transcriptsSnap.forEach(d => batch.delete(d.ref));\n aiMessagesSnap.forEach(d => batch.delete(d.ref));\n summarySnap.forEach(d => batch.delete(d.ref));\n\n const sessionRef = doc(sessionsCol(), id);\n batch.delete(sessionRef);\n\n await batch.commit();\n return { success: true };\n}\n\nasync function end(id) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { ended_at: Timestamp.now() });\n return { changes: 1 };\n}\n\nasync function updateType(id, type) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { session_type: type });\n return { changes: 1 };\n}\n\nasync function touch(id) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { updated_at: Timestamp.now() });\n return { changes: 1 };\n}\n\nasync function getOrCreateActive(uid, requestedType = 'ask') {\n const findQuery = query(\n sessionsCol(),\n where('uid', '==', uid),\n where('ended_at', '==', null),\n orderBy('session_type', 'desc'),\n limit(1)\n );\n\n const activeSessionSnap = await getDocs(findQuery);\n \n if (!activeSessionSnap.empty) {\n const activeSessionDoc = activeSessionSnap.docs[0];\n const sessionRef = doc(sessionsCol(), activeSessionDoc.id);\n const activeSession = activeSessionDoc.data();\n\n console.log(`[Repo] Found active Firebase session ${activeSession.id}`);\n \n const updates = { updated_at: Timestamp.now() };\n if (activeSession.session_type === 'ask' && requestedType === 'listen') {\n updates.session_type = 'listen';\n console.log(`[Repo] Promoted Firebase session ${activeSession.id} to 'listen' type.`);\n }\n \n await updateDoc(sessionRef, updates);\n return activeSessionDoc.id;\n } else {\n console.log(`[Repo] No active Firebase session for user ${uid}. Creating new.`);\n return create(uid, requestedType);\n }\n}\n\nasync function endAllActiveSessions(uid) {\n const q = query(sessionsCol(), where('uid', '==', uid), where('ended_at', '==', null));\n const snapshot = await getDocs(q);\n\n if (snapshot.empty) return { changes: 0 };\n\n const batch = writeBatch(getFirestoreInstance());\n const now = Timestamp.now();\n snapshot.forEach(d => {\n batch.update(d.ref, { ended_at: now });\n });\n await batch.commit();\n\n console.log(`[Repo] Ended ${snapshot.size} active session(s) for user ${uid}.`);\n return { changes: snapshot.size };\n}\n\nmodule.exports = {\n getById,\n create,\n getAllByUserId,\n updateTitle,\n deleteWithRelatedData,\n end,\n updateType,\n touch,\n getOrCreateActive,\n endAllActiveSessions,\n}; "], ["/glass/src/features/listen/listenService.js", "const { BrowserWindow } = require('electron');\nconst SttService = require('./stt/sttService');\nconst SummaryService = require('./summary/summaryService');\nconst authService = require('../common/services/authService');\nconst sessionRepository = require('../common/repositories/session');\nconst sttRepository = require('./stt/repositories');\nconst internalBridge = require('../../bridge/internalBridge');\n\nclass ListenService {\n constructor() {\n this.sttService = new SttService();\n this.summaryService = new SummaryService();\n this.currentSessionId = null;\n this.isInitializingSession = false;\n\n this.setupServiceCallbacks();\n console.log('[ListenService] Service instance created.');\n }\n\n setupServiceCallbacks() {\n // STT service callbacks\n this.sttService.setCallbacks({\n onTranscriptionComplete: (speaker, text) => {\n this.handleTranscriptionComplete(speaker, text);\n },\n onStatusUpdate: (status) => {\n this.sendToRenderer('update-status', status);\n }\n });\n\n // Summary service callbacks\n this.summaryService.setCallbacks({\n onAnalysisComplete: (data) => {\n console.log('📊 Analysis completed:', data);\n },\n onStatusUpdate: (status) => {\n this.sendToRenderer('update-status', status);\n }\n });\n }\n\n sendToRenderer(channel, data) {\n const { windowPool } = require('../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n initialize() {\n this.setupIpcHandlers();\n console.log('[ListenService] Initialized and ready.');\n }\n\n async handleListenRequest(listenButtonText) {\n const { windowPool } = require('../../window/windowManager');\n const listenWindow = windowPool.get('listen');\n const header = windowPool.get('header');\n\n try {\n switch (listenButtonText) {\n case 'Listen':\n console.log('[ListenService] changeSession to \"Listen\"');\n internalBridge.emit('window:requestVisibility', { name: 'listen', visible: true });\n await this.initializeSession();\n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send('session-state-changed', { isActive: true });\n }\n break;\n \n case 'Stop':\n console.log('[ListenService] changeSession to \"Stop\"');\n await this.closeSession();\n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send('session-state-changed', { isActive: false });\n }\n break;\n \n case 'Done':\n console.log('[ListenService] changeSession to \"Done\"');\n internalBridge.emit('window:requestVisibility', { name: 'listen', visible: false });\n listenWindow.webContents.send('session-state-changed', { isActive: false });\n break;\n \n default:\n throw new Error(`[ListenService] unknown listenButtonText: ${listenButtonText}`);\n }\n \n header.webContents.send('listen:changeSessionResult', { success: true });\n\n } catch (error) {\n console.error('[ListenService] error in handleListenRequest:', error);\n header.webContents.send('listen:changeSessionResult', { success: false });\n throw error; \n }\n }\n\n async handleTranscriptionComplete(speaker, text) {\n console.log(`[ListenService] Transcription complete: ${speaker} - ${text}`);\n \n // Save to database\n await this.saveConversationTurn(speaker, text);\n \n // Add to summary service for analysis\n this.summaryService.addConversationTurn(speaker, text);\n }\n\n async saveConversationTurn(speaker, transcription) {\n if (!this.currentSessionId) {\n console.error('[DB] Cannot save turn, no active session ID.');\n return;\n }\n if (transcription.trim() === '') return;\n\n try {\n await sessionRepository.touch(this.currentSessionId);\n await sttRepository.addTranscript({\n sessionId: this.currentSessionId,\n speaker: speaker,\n text: transcription.trim(),\n });\n console.log(`[DB] Saved transcript for session ${this.currentSessionId}: (${speaker})`);\n } catch (error) {\n console.error('Failed to save transcript to DB:', error);\n }\n }\n\n async initializeNewSession() {\n try {\n // The UID is no longer passed to the repository method directly.\n // The adapter layer handles UID injection. We just ensure a user is available.\n const user = authService.getCurrentUser();\n if (!user) {\n // This case should ideally not happen as authService initializes a default user.\n throw new Error(\"Cannot initialize session: auth service not ready.\");\n }\n \n this.currentSessionId = await sessionRepository.getOrCreateActive('listen');\n console.log(`[DB] New listen session ensured: ${this.currentSessionId}`);\n\n // Set session ID for summary service\n this.summaryService.setSessionId(this.currentSessionId);\n \n // Reset conversation history\n this.summaryService.resetConversationHistory();\n\n console.log('New conversation session started:', this.currentSessionId);\n return true;\n } catch (error) {\n console.error('Failed to initialize new session in DB:', error);\n this.currentSessionId = null;\n return false;\n }\n }\n\n async initializeSession(language = 'en') {\n if (this.isInitializingSession) {\n console.log('Session initialization already in progress.');\n return false;\n }\n\n this.isInitializingSession = true;\n this.sendToRenderer('session-initializing', true);\n this.sendToRenderer('update-status', 'Initializing sessions...');\n\n try {\n // Initialize database session\n const sessionInitialized = await this.initializeNewSession();\n if (!sessionInitialized) {\n throw new Error('Failed to initialize database session');\n }\n\n /* ---------- STT Initialization Retry Logic ---------- */\n const MAX_RETRY = 10;\n const RETRY_DELAY_MS = 300; // 0.3 seconds\n\n let sttReady = false;\n for (let attempt = 1; attempt <= MAX_RETRY; attempt++) {\n try {\n await this.sttService.initializeSttSessions(language);\n sttReady = true;\n break; // Exit on success\n } catch (err) {\n console.warn(\n `[ListenService] STT init attempt ${attempt} failed: ${err.message}`\n );\n if (attempt < MAX_RETRY) {\n await new Promise(r => setTimeout(r, RETRY_DELAY_MS));\n }\n }\n }\n if (!sttReady) throw new Error('STT init failed after retries');\n /* ------------------------------------------- */\n\n console.log('✅ Listen service initialized successfully.');\n \n this.sendToRenderer('update-status', 'Connected. Ready to listen.');\n \n return true;\n } catch (error) {\n console.error('❌ Failed to initialize listen service:', error);\n this.sendToRenderer('update-status', 'Initialization failed.');\n return false;\n } finally {\n this.isInitializingSession = false;\n this.sendToRenderer('session-initializing', false);\n this.sendToRenderer('change-listen-capture-state', { status: \"start\" });\n }\n }\n\n async sendMicAudioContent(data, mimeType) {\n return await this.sttService.sendMicAudioContent(data, mimeType);\n }\n\n async startMacOSAudioCapture() {\n if (process.platform !== 'darwin') {\n throw new Error('macOS audio capture only available on macOS');\n }\n return await this.sttService.startMacOSAudioCapture();\n }\n\n async stopMacOSAudioCapture() {\n this.sttService.stopMacOSAudioCapture();\n }\n\n isSessionActive() {\n return this.sttService.isSessionActive();\n }\n\n async closeSession() {\n try {\n this.sendToRenderer('change-listen-capture-state', { status: \"stop\" });\n // Close STT sessions\n await this.sttService.closeSessions();\n\n await this.stopMacOSAudioCapture();\n\n // End database session\n if (this.currentSessionId) {\n await sessionRepository.end(this.currentSessionId);\n console.log(`[DB] Session ${this.currentSessionId} ended.`);\n }\n\n // Reset state\n this.currentSessionId = null;\n this.summaryService.resetConversationHistory();\n\n console.log('Listen service session closed.');\n return { success: true };\n } catch (error) {\n console.error('Error closing listen service session:', error);\n return { success: false, error: error.message };\n }\n }\n\n getCurrentSessionData() {\n return {\n sessionId: this.currentSessionId,\n conversationHistory: this.summaryService.getConversationHistory(),\n totalTexts: this.summaryService.getConversationHistory().length,\n analysisData: this.summaryService.getCurrentAnalysisData(),\n };\n }\n\n getConversationHistory() {\n return this.summaryService.getConversationHistory();\n }\n\n _createHandler(asyncFn, successMessage, errorMessage) {\n return async (...args) => {\n try {\n const result = await asyncFn.apply(this, args);\n if (successMessage) console.log(successMessage);\n // `startMacOSAudioCapture`는 성공 시 { success, error } 객체를 반환하지 않으므로,\n // 핸들러가 일관된 응답을 보내도록 여기서 success 객체를 반환합니다.\n // 다른 함수들은 이미 success 객체를 반환합니다.\n return result && typeof result.success !== 'undefined' ? result : { success: true };\n } catch (e) {\n console.error(errorMessage, e);\n return { success: false, error: e.message };\n }\n };\n }\n\n // `_createHandler`를 사용하여 핸들러들을 동적으로 생성합니다.\n handleSendMicAudioContent = this._createHandler(\n this.sendMicAudioContent,\n null,\n 'Error sending user audio:'\n );\n\n handleStartMacosAudio = this._createHandler(\n async () => {\n if (process.platform !== 'darwin') {\n return { success: false, error: 'macOS audio capture only available on macOS' };\n }\n if (this.sttService.isMacOSAudioRunning?.()) {\n return { success: false, error: 'already_running' };\n }\n await this.startMacOSAudioCapture();\n return { success: true, error: null };\n },\n 'macOS audio capture started.',\n 'Error starting macOS audio capture:'\n );\n \n handleStopMacosAudio = this._createHandler(\n this.stopMacOSAudioCapture,\n 'macOS audio capture stopped.',\n 'Error stopping macOS audio capture:'\n );\n\n handleUpdateGoogleSearchSetting = this._createHandler(\n async (enabled) => {\n console.log('Google Search setting updated to:', enabled);\n },\n null,\n 'Error updating Google Search setting:'\n );\n}\n\nconst listenService = new ListenService();\nmodule.exports = listenService;"], ["/glass/src/ui/listen/summary/SummaryView.js", "import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';\n\nexport class SummaryView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n /* Inherit font styles from parent */\n\n /* highlight.js 스타일 추가 */\n .insights-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .insights-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .insights-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n }\n\n .insights-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n }\n\n .hljs-keyword {\n color: #ff79c6 !important;\n }\n .hljs-string {\n color: #f1fa8c !important;\n }\n .hljs-comment {\n color: #6272a4 !important;\n }\n .hljs-number {\n color: #bd93f9 !important;\n }\n .hljs-function {\n color: #50fa7b !important;\n }\n .hljs-variable {\n color: #8be9fd !important;\n }\n .hljs-built_in {\n color: #ffb86c !important;\n }\n .hljs-title {\n color: #50fa7b !important;\n }\n .hljs-attr {\n color: #50fa7b !important;\n }\n .hljs-tag {\n color: #ff79c6 !important;\n }\n\n .insights-container {\n overflow-y: auto;\n padding: 12px 16px 16px 16px;\n position: relative;\n z-index: 1;\n min-height: 150px;\n max-height: 600px;\n flex: 1;\n }\n\n /* Visibility handled by parent component */\n\n .insights-container::-webkit-scrollbar {\n width: 8px;\n }\n .insights-container::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n }\n .insights-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.3);\n border-radius: 4px;\n }\n .insights-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.5);\n }\n\n insights-title {\n color: rgba(255, 255, 255, 0.8);\n font-size: 15px;\n font-weight: 500;\n font-family: 'Helvetica Neue', sans-serif;\n margin: 12px 0 8px 0;\n display: block;\n }\n\n .insights-container h4 {\n color: #ffffff;\n font-size: 12px;\n font-weight: 600;\n margin: 12px 0 8px 0;\n padding: 4px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: default;\n }\n\n .insights-container h4:hover {\n background: transparent;\n }\n\n .insights-container h4:first-child {\n margin-top: 0;\n }\n\n .outline-item {\n color: #ffffff;\n font-size: 11px;\n line-height: 1.4;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n transition: background-color 0.15s ease;\n cursor: pointer;\n word-wrap: break-word;\n }\n\n .outline-item:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .request-item {\n color: #ffffff;\n font-size: 12px;\n line-height: 1.2;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: default;\n word-wrap: break-word;\n transition: background-color 0.15s ease;\n }\n\n .request-item.clickable {\n cursor: pointer;\n transition: all 0.15s ease;\n }\n .request-item.clickable:hover {\n background: rgba(255, 255, 255, 0.1);\n transform: translateX(2px);\n }\n\n /* 마크다운 렌더링된 콘텐츠 스타일 */\n .markdown-content {\n color: #ffffff;\n font-size: 11px;\n line-height: 1.4;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: pointer;\n word-wrap: break-word;\n transition: all 0.15s ease;\n }\n\n .markdown-content:hover {\n background: rgba(255, 255, 255, 0.1);\n transform: translateX(2px);\n }\n\n .markdown-content p {\n margin: 4px 0;\n }\n\n .markdown-content ul,\n .markdown-content ol {\n margin: 4px 0;\n padding-left: 16px;\n }\n\n .markdown-content li {\n margin: 2px 0;\n }\n\n .markdown-content a {\n color: #8be9fd;\n text-decoration: none;\n }\n\n .markdown-content a:hover {\n text-decoration: underline;\n }\n\n .markdown-content strong {\n font-weight: 600;\n color: #f8f8f2;\n }\n\n .markdown-content em {\n font-style: italic;\n color: #f1fa8c;\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100px;\n color: rgba(255, 255, 255, 0.6);\n font-size: 12px;\n font-style: italic;\n }\n `;\n\n static properties = {\n structuredData: { type: Object },\n isVisible: { type: Boolean },\n hasCompletedRecording: { type: Boolean },\n };\n\n constructor() {\n super();\n this.structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: [],\n };\n this.isVisible = true;\n this.hasCompletedRecording = false;\n\n // 마크다운 라이브러리 초기화\n this.marked = null;\n this.hljs = null;\n this.isLibrariesLoaded = false;\n this.DOMPurify = null;\n this.isDOMPurifyLoaded = false;\n\n this.loadLibraries();\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (window.api) {\n window.api.summaryView.onSummaryUpdate((event, data) => {\n this.structuredData = data;\n this.requestUpdate();\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.summaryView.removeAllSummaryUpdateListeners();\n }\n }\n\n // Handle session reset from parent\n resetAnalysis() {\n this.structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: [],\n };\n this.requestUpdate();\n }\n\n async loadLibraries() {\n try {\n if (!window.marked) {\n await this.loadScript('../../../assets/marked-4.3.0.min.js');\n }\n\n if (!window.hljs) {\n await this.loadScript('../../../assets/highlight-11.9.0.min.js');\n }\n\n if (!window.DOMPurify) {\n await this.loadScript('../../../assets/dompurify-3.0.7.min.js');\n }\n\n this.marked = window.marked;\n this.hljs = window.hljs;\n this.DOMPurify = window.DOMPurify;\n\n if (this.marked && this.hljs) {\n this.marked.setOptions({\n highlight: (code, lang) => {\n if (lang && this.hljs.getLanguage(lang)) {\n try {\n return this.hljs.highlight(code, { language: lang }).value;\n } catch (err) {\n console.warn('Highlight error:', err);\n }\n }\n try {\n return this.hljs.highlightAuto(code).value;\n } catch (err) {\n console.warn('Auto highlight error:', err);\n }\n return code;\n },\n breaks: true,\n gfm: true,\n pedantic: false,\n smartypants: false,\n xhtml: false,\n });\n\n this.isLibrariesLoaded = true;\n console.log('Markdown libraries loaded successfully');\n }\n\n if (this.DOMPurify) {\n this.isDOMPurifyLoaded = true;\n console.log('DOMPurify loaded successfully in SummaryView');\n }\n } catch (error) {\n console.error('Failed to load libraries:', error);\n }\n }\n\n loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n parseMarkdown(text) {\n if (!text) return '';\n\n if (!this.isLibrariesLoaded || !this.marked) {\n return text;\n }\n\n try {\n return this.marked(text);\n } catch (error) {\n console.error('Markdown parsing error:', error);\n return text;\n }\n }\n\n handleMarkdownClick(originalText) {\n this.handleRequestClick(originalText);\n }\n\n renderMarkdownContent() {\n if (!this.isLibrariesLoaded || !this.marked) {\n return;\n }\n\n const markdownElements = this.shadowRoot.querySelectorAll('[data-markdown-id]');\n markdownElements.forEach(element => {\n const originalText = element.getAttribute('data-original-text');\n if (originalText) {\n try {\n let parsedHTML = this.parseMarkdown(originalText);\n\n if (this.isDOMPurifyLoaded && this.DOMPurify) {\n parsedHTML = this.DOMPurify.sanitize(parsedHTML);\n\n if (this.DOMPurify.removed && this.DOMPurify.removed.length > 0) {\n console.warn('Unsafe content detected in insights, showing plain text');\n element.textContent = '⚠️ ' + originalText;\n return;\n }\n }\n\n element.innerHTML = parsedHTML;\n } catch (error) {\n console.error('Error rendering markdown for element:', error);\n element.textContent = originalText;\n }\n }\n });\n }\n\n async handleRequestClick(requestText) {\n console.log('🔥 Analysis request clicked:', requestText);\n\n if (window.api) {\n try {\n const result = await window.api.summaryView.sendQuestionFromSummary(requestText);\n\n if (result.success) {\n console.log('✅ Question sent to AskView successfully');\n } else {\n console.error('❌ Failed to send question to AskView:', result.error);\n }\n } catch (error) {\n console.error('❌ Error in handleRequestClick:', error);\n }\n }\n }\n\n getSummaryText() {\n const data = this.structuredData || { summary: [], topic: { header: '', bullets: [] }, actions: [] };\n let sections = [];\n\n if (data.summary && data.summary.length > 0) {\n sections.push(`Current Summary:\\n${data.summary.map(s => `• ${s}`).join('\\n')}`);\n }\n\n if (data.topic && data.topic.header && data.topic.bullets.length > 0) {\n sections.push(`\\n${data.topic.header}:\\n${data.topic.bullets.map(b => `• ${b}`).join('\\n')}`);\n }\n\n if (data.actions && data.actions.length > 0) {\n sections.push(`\\nActions:\\n${data.actions.map(a => `▸ ${a}`).join('\\n')}`);\n }\n\n if (data.followUps && data.followUps.length > 0) {\n sections.push(`\\nFollow-Ups:\\n${data.followUps.map(f => `▸ ${f}`).join('\\n')}`);\n }\n\n return sections.join('\\n\\n').trim();\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.renderMarkdownContent();\n }\n\n render() {\n if (!this.isVisible) {\n return html`
`;\n }\n\n const data = this.structuredData || {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n };\n\n const hasAnyContent = data.summary.length > 0 || data.topic.bullets.length > 0 || data.actions.length > 0;\n\n return html`\n
\n ${!hasAnyContent\n ? html`
No insights yet...
`\n : html`\n Current Summary\n ${data.summary.length > 0\n ? data.summary\n .slice(0, 5)\n .map(\n (bullet, index) => html`\n this.handleMarkdownClick(bullet)}\n >\n ${bullet}\n
\n `\n )\n : html`
No content yet...
`}\n ${data.topic.header\n ? html`\n ${data.topic.header}\n ${data.topic.bullets\n .slice(0, 3)\n .map(\n (bullet, index) => html`\n this.handleMarkdownClick(bullet)}\n >\n ${bullet}\n \n `\n )}\n `\n : ''}\n ${data.actions.length > 0\n ? html`\n Actions\n ${data.actions\n .slice(0, 5)\n .map(\n (action, index) => html`\n this.handleMarkdownClick(action)}\n >\n ${action}\n \n `\n )}\n `\n : ''}\n ${this.hasCompletedRecording && data.followUps && data.followUps.length > 0\n ? html`\n Follow-Ups\n ${data.followUps.map(\n (followUp, index) => html`\n this.handleMarkdownClick(followUp)}\n >\n ${followUp}\n \n `\n )}\n `\n : ''}\n `}\n \n `;\n }\n}\n\ncustomElements.define('summary-view', SummaryView); "], ["/glass/src/ui/ask/AskView.js", "import { html, css, LitElement } from '../../ui/assets/lit-core-2.7.4.min.js';\nimport { parser, parser_write, parser_end, default_renderer } from '../../ui/assets/smd.js';\n\nexport class AskView extends LitElement {\n static properties = {\n currentResponse: { type: String },\n currentQuestion: { type: String },\n isLoading: { type: Boolean },\n copyState: { type: String },\n isHovering: { type: Boolean },\n hoveredLineIndex: { type: Number },\n lineCopyState: { type: Object },\n showTextInput: { type: Boolean },\n headerText: { type: String },\n headerAnimating: { type: Boolean },\n isStreaming: { type: Boolean },\n };\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n color: white;\n transform: translate3d(0, 0, 0);\n backface-visibility: hidden;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n will-change: transform, opacity;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n @keyframes slideUp {\n 0% {\n opacity: 1;\n transform: translateY(0) scale(1);\n filter: blur(0px);\n }\n 30% {\n opacity: 0.7;\n transform: translateY(-20%) scale(0.98);\n filter: blur(0.5px);\n }\n 70% {\n opacity: 0.3;\n transform: translateY(-80%) scale(0.92);\n filter: blur(1.5px);\n }\n 100% {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n filter: blur(2px);\n }\n }\n\n @keyframes slideDown {\n 0% {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n filter: blur(2px);\n }\n 30% {\n opacity: 0.5;\n transform: translateY(-50%) scale(0.92);\n filter: blur(1px);\n }\n 65% {\n opacity: 0.9;\n transform: translateY(-5%) scale(0.99);\n filter: blur(0.2px);\n }\n 85% {\n opacity: 0.98;\n transform: translateY(2%) scale(1.005);\n filter: blur(0px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0) scale(1);\n filter: blur(0px);\n }\n }\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n /* Allow text selection in assistant responses */\n .response-container, .response-container * {\n user-select: text !important;\n cursor: text !important;\n }\n\n .response-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .response-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .response-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n }\n\n .response-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n }\n\n .hljs-keyword {\n color: #ff79c6 !important;\n }\n .hljs-string {\n color: #f1fa8c !important;\n }\n .hljs-comment {\n color: #6272a4 !important;\n }\n .hljs-number {\n color: #bd93f9 !important;\n }\n .hljs-function {\n color: #50fa7b !important;\n }\n .hljs-variable {\n color: #8be9fd !important;\n }\n .hljs-built_in {\n color: #ffb86c !important;\n }\n .hljs-title {\n color: #50fa7b !important;\n }\n .hljs-attr {\n color: #50fa7b !important;\n }\n .hljs-tag {\n color: #ff79c6 !important;\n }\n\n .ask-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: rgba(0, 0, 0, 0.6);\n border-radius: 12px;\n outline: 0.5px rgba(255, 255, 255, 0.3) solid;\n outline-offset: -1px;\n backdrop-filter: blur(1px);\n box-sizing: border-box;\n position: relative;\n overflow: hidden;\n }\n\n .ask-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n filter: blur(10px);\n z-index: -1;\n }\n\n .response-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 16px;\n background: transparent;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n flex-shrink: 0;\n }\n\n .response-header.hidden {\n display: none;\n }\n\n .header-left {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n }\n\n .response-icon {\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.2);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .response-icon svg {\n width: 12px;\n height: 12px;\n stroke: rgba(255, 255, 255, 0.9);\n }\n\n .response-label {\n font-size: 13px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.9);\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n\n .response-label.animating {\n animation: fadeInOut 0.3s ease-in-out;\n }\n\n @keyframes fadeInOut {\n 0% {\n opacity: 1;\n transform: translateY(0);\n }\n 50% {\n opacity: 0;\n transform: translateY(-10px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .header-right {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n justify-content: flex-end;\n }\n\n .question-text {\n font-size: 13px;\n color: rgba(255, 255, 255, 0.7);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 300px;\n margin-right: 8px;\n }\n\n .header-controls {\n display: flex;\n gap: 8px;\n align-items: center;\n flex-shrink: 0;\n }\n\n .copy-button {\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: 1px solid rgba(255, 255, 255, 0.2);\n padding: 4px;\n border-radius: 3px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 24px;\n height: 24px;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n position: relative;\n overflow: hidden;\n }\n\n .copy-button:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n\n .copy-button svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n }\n\n .copy-button .check-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .copy-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .check-icon {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n\n .close-button {\n background: rgba(255, 255, 255, 0.07);\n color: white;\n border: none;\n padding: 4px;\n border-radius: 20px;\n outline: 1px rgba(255, 255, 255, 0.3) solid;\n outline-offset: -1px;\n backdrop-filter: blur(0.5px);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n }\n\n .close-button:hover {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 1);\n }\n\n .response-container {\n flex: 1;\n padding: 16px;\n padding-left: 48px;\n overflow-y: auto;\n font-size: 14px;\n line-height: 1.6;\n background: transparent;\n min-height: 0;\n max-height: 400px;\n position: relative;\n }\n\n .response-container.hidden {\n display: none;\n }\n\n .response-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .response-container::-webkit-scrollbar-track {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n }\n\n .response-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n }\n\n .response-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .loading-dots {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n padding: 40px;\n }\n\n .loading-dot {\n width: 8px;\n height: 8px;\n background: rgba(255, 255, 255, 0.6);\n border-radius: 50%;\n animation: pulse 1.5s ease-in-out infinite;\n }\n\n .loading-dot:nth-child(1) {\n animation-delay: 0s;\n }\n\n .loading-dot:nth-child(2) {\n animation-delay: 0.2s;\n }\n\n .loading-dot:nth-child(3) {\n animation-delay: 0.4s;\n }\n\n @keyframes pulse {\n 0%,\n 80%,\n 100% {\n opacity: 0.3;\n transform: scale(0.8);\n }\n 40% {\n opacity: 1;\n transform: scale(1.2);\n }\n }\n\n .response-line {\n position: relative;\n padding: 2px 0;\n margin: 0;\n transition: background-color 0.15s ease;\n }\n\n .response-line:hover {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 4px;\n }\n\n .line-copy-button {\n position: absolute;\n left: -32px;\n top: 50%;\n transform: translateY(-50%);\n background: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n padding: 2px;\n cursor: pointer;\n opacity: 0;\n transition: opacity 0.15s ease, background-color 0.15s ease;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n }\n\n .response-line:hover .line-copy-button {\n opacity: 1;\n }\n\n .line-copy-button:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n\n .line-copy-button.copied {\n background: rgba(40, 167, 69, 0.3);\n }\n\n .line-copy-button svg {\n width: 12px;\n height: 12px;\n stroke: rgba(255, 255, 255, 0.9);\n }\n\n .text-input-container {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n background: rgba(0, 0, 0, 0.1);\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n flex-shrink: 0;\n transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;\n transform-origin: bottom;\n }\n\n .text-input-container.hidden {\n opacity: 0;\n transform: scaleY(0);\n padding: 0;\n height: 0;\n overflow: hidden;\n border-top: none;\n }\n\n .text-input-container.no-response {\n border-top: none;\n }\n\n #textInput {\n flex: 1;\n padding: 10px 14px;\n background: rgba(0, 0, 0, 0.2);\n border-radius: 20px;\n outline: none;\n border: none;\n color: white;\n font-size: 14px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 400;\n }\n\n #textInput::placeholder {\n color: rgba(255, 255, 255, 0.5);\n }\n\n #textInput:focus {\n outline: none;\n }\n\n .response-line h1,\n .response-line h2,\n .response-line h3,\n .response-line h4,\n .response-line h5,\n .response-line h6 {\n color: rgba(255, 255, 255, 0.95);\n margin: 16px 0 8px 0;\n font-weight: 600;\n }\n\n .response-line p {\n margin: 8px 0;\n color: rgba(255, 255, 255, 0.9);\n }\n\n .response-line ul,\n .response-line ol {\n margin: 8px 0;\n padding-left: 20px;\n }\n\n .response-line li {\n margin: 4px 0;\n color: rgba(255, 255, 255, 0.9);\n }\n\n .response-line code {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.95);\n padding: 2px 6px;\n border-radius: 4px;\n font-family: 'Monaco', 'Menlo', monospace;\n font-size: 13px;\n }\n\n .response-line pre {\n background: rgba(255, 255, 255, 0.05);\n color: rgba(255, 255, 255, 0.95);\n padding: 12px;\n border-radius: 6px;\n overflow-x: auto;\n margin: 12px 0;\n border: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .response-line pre code {\n background: none;\n padding: 0;\n }\n\n .response-line blockquote {\n border-left: 3px solid rgba(255, 255, 255, 0.3);\n margin: 12px 0;\n padding: 8px 16px;\n background: rgba(255, 255, 255, 0.05);\n color: rgba(255, 255, 255, 0.8);\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: rgba(255, 255, 255, 0.5);\n font-size: 14px;\n }\n\n .btn-gap {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n gap: 4px;\n }\n\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .ask-container,\n :host-context(body.has-glass) .response-header,\n :host-context(body.has-glass) .response-icon,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .close-button,\n :host-context(body.has-glass) .line-copy-button,\n :host-context(body.has-glass) .text-input-container,\n :host-context(body.has-glass) .response-container pre,\n :host-context(body.has-glass) .response-container p code,\n :host-context(body.has-glass) .response-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .ask-container::before {\n display: none !important;\n }\n\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .close-button:hover,\n :host-context(body.has-glass) .line-copy-button,\n :host-context(body.has-glass) .line-copy-button:hover,\n :host-context(body.has-glass) .response-line:hover {\n background: transparent !important;\n }\n\n :host-context(body.has-glass) .response-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .response-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n\n .submit-btn, .clear-btn {\n display: flex;\n align-items: center;\n background: transparent;\n color: white;\n border: none;\n border-radius: 6px;\n margin-left: 8px;\n font-size: 13px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n overflow: hidden;\n cursor: pointer;\n transition: background 0.15s;\n height: 32px;\n padding: 0 10px;\n box-shadow: none;\n }\n .submit-btn:hover, .clear-btn:hover {\n background: rgba(255,255,255,0.1);\n }\n .btn-label {\n margin-right: 8px;\n display: flex;\n align-items: center;\n height: 100%;\n }\n .btn-icon {\n background: rgba(255,255,255,0.1);\n border-radius: 13%;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n }\n .btn-icon img, .btn-icon svg {\n width: 13px;\n height: 13px;\n display: block;\n }\n .header-clear-btn {\n background: transparent;\n border: none;\n display: flex;\n align-items: center;\n gap: 2px;\n cursor: pointer;\n padding: 0 2px;\n }\n .header-clear-btn .icon-box {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n background-color: rgba(255, 255, 255, 0.1);\n border-radius: 13%;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .header-clear-btn:hover .icon-box {\n background-color: rgba(255,255,255,0.18);\n }\n `;\n\n constructor() {\n super();\n this.currentResponse = '';\n this.currentQuestion = '';\n this.isLoading = false;\n this.copyState = 'idle';\n this.showTextInput = true;\n this.headerText = 'AI Response';\n this.headerAnimating = false;\n this.isStreaming = false;\n\n this.marked = null;\n this.hljs = null;\n this.DOMPurify = null;\n this.isLibrariesLoaded = false;\n\n // SMD.js streaming markdown parser\n this.smdParser = null;\n this.smdContainer = null;\n this.lastProcessedLength = 0;\n\n this.handleSendText = this.handleSendText.bind(this);\n this.handleTextKeydown = this.handleTextKeydown.bind(this);\n this.handleCopy = this.handleCopy.bind(this);\n this.clearResponseContent = this.clearResponseContent.bind(this);\n this.handleEscKey = this.handleEscKey.bind(this);\n this.handleScroll = this.handleScroll.bind(this);\n this.handleCloseAskWindow = this.handleCloseAskWindow.bind(this);\n this.handleCloseIfNoContent = this.handleCloseIfNoContent.bind(this);\n\n this.loadLibraries();\n\n // --- Resize helpers ---\n this.isThrottled = false;\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n console.log('📱 AskView connectedCallback - IPC 이벤트 리스너 설정');\n\n document.addEventListener('keydown', this.handleEscKey);\n\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n const needed = entry.contentRect.height;\n const current = window.innerHeight;\n\n if (needed > current - 4) {\n this.requestWindowResize(Math.ceil(needed));\n }\n }\n });\n\n const container = this.shadowRoot?.querySelector('.ask-container');\n if (container) this.resizeObserver.observe(container);\n\n this.handleQuestionFromAssistant = (event, question) => {\n console.log('AskView: Received question from ListenView:', question);\n this.handleSendText(null, question);\n };\n\n if (window.api) {\n window.api.askView.onShowTextInput(() => {\n console.log('Show text input signal received');\n if (!this.showTextInput) {\n this.showTextInput = true;\n this.updateComplete.then(() => this.focusTextInput());\n } else {\n this.focusTextInput();\n }\n });\n\n window.api.askView.onScrollResponseUp(() => this.handleScroll('up'));\n window.api.askView.onScrollResponseDown(() => this.handleScroll('down'));\n window.api.askView.onAskStateUpdate((event, newState) => {\n this.currentResponse = newState.currentResponse;\n this.currentQuestion = newState.currentQuestion;\n this.isLoading = newState.isLoading;\n this.isStreaming = newState.isStreaming;\n \n const wasHidden = !this.showTextInput;\n this.showTextInput = newState.showTextInput;\n \n if (newState.showTextInput) {\n if (wasHidden) {\n this.updateComplete.then(() => this.focusTextInput());\n } else {\n this.focusTextInput();\n }\n }\n });\n console.log('AskView: IPC 이벤트 리스너 등록 완료');\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n\n console.log('📱 AskView disconnectedCallback - IPC 이벤트 리스너 제거');\n\n document.removeEventListener('keydown', this.handleEscKey);\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n if (this.headerAnimationTimeout) {\n clearTimeout(this.headerAnimationTimeout);\n }\n\n if (this.streamingTimeout) {\n clearTimeout(this.streamingTimeout);\n }\n\n Object.values(this.lineCopyTimeouts).forEach(timeout => clearTimeout(timeout));\n\n if (window.api) {\n window.api.askView.removeOnAskStateUpdate(this.handleAskStateUpdate);\n window.api.askView.removeOnShowTextInput(this.handleShowTextInput);\n window.api.askView.removeOnScrollResponseUp(this.handleScroll);\n window.api.askView.removeOnScrollResponseDown(this.handleScroll);\n console.log('✅ AskView: IPC 이벤트 리스너 제거 필요');\n }\n }\n\n\n async loadLibraries() {\n try {\n if (!window.marked) {\n await this.loadScript('../../assets/marked-4.3.0.min.js');\n }\n\n if (!window.hljs) {\n await this.loadScript('../../assets/highlight-11.9.0.min.js');\n }\n\n if (!window.DOMPurify) {\n await this.loadScript('../../assets/dompurify-3.0.7.min.js');\n }\n\n this.marked = window.marked;\n this.hljs = window.hljs;\n this.DOMPurify = window.DOMPurify;\n\n if (this.marked && this.hljs) {\n this.marked.setOptions({\n highlight: (code, lang) => {\n if (lang && this.hljs.getLanguage(lang)) {\n try {\n return this.hljs.highlight(code, { language: lang }).value;\n } catch (err) {\n console.warn('Highlight error:', err);\n }\n }\n try {\n return this.hljs.highlightAuto(code).value;\n } catch (err) {\n console.warn('Auto highlight error:', err);\n }\n return code;\n },\n breaks: true,\n gfm: true,\n pedantic: false,\n smartypants: false,\n xhtml: false,\n });\n\n this.isLibrariesLoaded = true;\n this.renderContent();\n console.log('Markdown libraries loaded successfully in AskView');\n }\n\n if (this.DOMPurify) {\n this.isDOMPurifyLoaded = true;\n console.log('DOMPurify loaded successfully in AskView');\n }\n } catch (error) {\n console.error('Failed to load libraries in AskView:', error);\n }\n }\n\n handleCloseAskWindow() {\n // this.clearResponseContent();\n window.api.askView.closeAskWindow();\n }\n\n handleCloseIfNoContent() {\n if (!this.currentResponse && !this.isLoading && !this.isStreaming) {\n this.handleCloseAskWindow();\n }\n }\n\n handleEscKey(e) {\n if (e.key === 'Escape') {\n e.preventDefault();\n this.handleCloseIfNoContent();\n }\n }\n\n clearResponseContent() {\n this.currentResponse = '';\n this.currentQuestion = '';\n this.isLoading = false;\n this.isStreaming = false;\n this.headerText = 'AI Response';\n this.showTextInput = true;\n this.lastProcessedLength = 0;\n this.smdParser = null;\n this.smdContainer = null;\n }\n\n handleInputFocus() {\n this.isInputFocused = true;\n }\n\n focusTextInput() {\n requestAnimationFrame(() => {\n const textInput = this.shadowRoot?.getElementById('textInput');\n if (textInput) {\n textInput.focus();\n }\n });\n }\n\n\n loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n parseMarkdown(text) {\n if (!text) return '';\n\n if (!this.isLibrariesLoaded || !this.marked) {\n return text;\n }\n\n try {\n return this.marked(text);\n } catch (error) {\n console.error('Markdown parsing error in AskView:', error);\n return text;\n }\n }\n\n fixIncompleteCodeBlocks(text) {\n if (!text) return text;\n\n const codeBlockMarkers = text.match(/```/g) || [];\n const markerCount = codeBlockMarkers.length;\n\n if (markerCount % 2 === 1) {\n return text + '\\n```';\n }\n\n return text;\n }\n\n handleScroll(direction) {\n const scrollableElement = this.shadowRoot.querySelector('#responseContainer');\n if (scrollableElement) {\n const scrollAmount = 100; // 한 번에 스크롤할 양 (px)\n if (direction === 'up') {\n scrollableElement.scrollTop -= scrollAmount;\n } else {\n scrollableElement.scrollTop += scrollAmount;\n }\n }\n }\n\n\n renderContent() {\n const responseContainer = this.shadowRoot.getElementById('responseContainer');\n if (!responseContainer) return;\n \n // Check loading state\n if (this.isLoading) {\n responseContainer.innerHTML = `\n
\n
\n
\n
\n
`;\n this.resetStreamingParser();\n return;\n }\n \n // If there is no response, show empty state\n if (!this.currentResponse) {\n responseContainer.innerHTML = `
...
`;\n this.resetStreamingParser();\n return;\n }\n \n // Set streaming markdown parser\n this.renderStreamingMarkdown(responseContainer);\n\n // After updating content, recalculate window height\n this.adjustWindowHeightThrottled();\n }\n\n resetStreamingParser() {\n this.smdParser = null;\n this.smdContainer = null;\n this.lastProcessedLength = 0;\n }\n\n renderStreamingMarkdown(responseContainer) {\n try {\n // 파서가 없거나 컨테이너가 변경되었으면 새로 생성\n if (!this.smdParser || this.smdContainer !== responseContainer) {\n this.smdContainer = responseContainer;\n this.smdContainer.innerHTML = '';\n \n // smd.js의 default_renderer 사용\n const renderer = default_renderer(this.smdContainer);\n this.smdParser = parser(renderer);\n this.lastProcessedLength = 0;\n }\n\n // 새로운 텍스트만 처리 (스트리밍 최적화)\n const currentText = this.currentResponse;\n const newText = currentText.slice(this.lastProcessedLength);\n \n if (newText.length > 0) {\n // 새로운 텍스트 청크를 파서에 전달\n parser_write(this.smdParser, newText);\n this.lastProcessedLength = currentText.length;\n }\n\n // 스트리밍이 완료되면 파서 종료\n if (!this.isStreaming && !this.isLoading) {\n parser_end(this.smdParser);\n }\n\n // 코드 하이라이팅 적용\n if (this.hljs) {\n responseContainer.querySelectorAll('pre code').forEach(block => {\n if (!block.hasAttribute('data-highlighted')) {\n this.hljs.highlightElement(block);\n block.setAttribute('data-highlighted', 'true');\n }\n });\n }\n\n // 스크롤을 맨 아래로\n responseContainer.scrollTop = responseContainer.scrollHeight;\n \n } catch (error) {\n console.error('Error rendering streaming markdown:', error);\n // 에러 발생 시 기본 텍스트 렌더링으로 폴백\n this.renderFallbackContent(responseContainer);\n }\n }\n\n renderFallbackContent(responseContainer) {\n const textToRender = this.currentResponse || '';\n \n if (this.isLibrariesLoaded && this.marked && this.DOMPurify) {\n try {\n // 마크다운 파싱\n const parsedHtml = this.marked.parse(textToRender);\n\n // DOMPurify로 정제\n const cleanHtml = this.DOMPurify.sanitize(parsedHtml, {\n ALLOWED_TAGS: [\n 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'br', 'strong', 'b', 'em', 'i',\n 'ul', 'ol', 'li', 'blockquote', 'code', 'pre', 'a', 'img', 'table', 'thead',\n 'tbody', 'tr', 'th', 'td', 'hr', 'sup', 'sub', 'del', 'ins',\n ],\n ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class', 'id', 'target', 'rel'],\n });\n\n responseContainer.innerHTML = cleanHtml;\n\n // 코드 하이라이팅 적용\n if (this.hljs) {\n responseContainer.querySelectorAll('pre code').forEach(block => {\n this.hljs.highlightElement(block);\n });\n }\n } catch (error) {\n console.error('Error in fallback rendering:', error);\n responseContainer.textContent = textToRender;\n }\n } else {\n // 라이브러리가 로드되지 않았을 때 기본 렌더링\n const basicHtml = textToRender\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\\n\\n/g, '

')\n .replace(/\\n/g, '
')\n .replace(/\\*\\*(.*?)\\*\\*/g, '$1')\n .replace(/\\*(.*?)\\*/g, '$1')\n .replace(/`([^`]+)`/g, '$1');\n\n responseContainer.innerHTML = `

${basicHtml}

`;\n }\n }\n\n\n requestWindowResize(targetHeight) {\n if (window.api) {\n window.api.askView.adjustWindowHeight(targetHeight);\n }\n }\n\n animateHeaderText(text) {\n this.headerAnimating = true;\n this.requestUpdate();\n\n setTimeout(() => {\n this.headerText = text;\n this.headerAnimating = false;\n this.requestUpdate();\n }, 150);\n }\n\n startHeaderAnimation() {\n this.animateHeaderText('analyzing screen...');\n\n if (this.headerAnimationTimeout) {\n clearTimeout(this.headerAnimationTimeout);\n }\n\n this.headerAnimationTimeout = setTimeout(() => {\n this.animateHeaderText('thinking...');\n }, 1500);\n }\n\n renderMarkdown(content) {\n if (!content) return '';\n\n if (this.isLibrariesLoaded && this.marked) {\n return this.parseMarkdown(content);\n }\n\n return content\n .replace(/\\*\\*(.*?)\\*\\*/g, '$1')\n .replace(/\\*(.*?)\\*/g, '$1')\n .replace(/`(.*?)`/g, '$1');\n }\n\n fixIncompleteMarkdown(text) {\n if (!text) return text;\n\n // 불완전한 볼드체 처리\n const boldCount = (text.match(/\\*\\*/g) || []).length;\n if (boldCount % 2 === 1) {\n text += '**';\n }\n\n // 불완전한 이탤릭체 처리\n const italicCount = (text.match(/(? closeBrackets) {\n text += ']';\n }\n\n const openParens = (text.match(/\\]\\(/g) || []).length;\n const closeParens = (text.match(/\\)\\s*$/g) || []).length;\n if (openParens > closeParens && text.endsWith('(')) {\n text += ')';\n }\n\n return text;\n }\n\n\n async handleCopy() {\n if (this.copyState === 'copied') return;\n\n let responseToCopy = this.currentResponse;\n\n if (this.isDOMPurifyLoaded && this.DOMPurify) {\n const testHtml = this.renderMarkdown(responseToCopy);\n const sanitized = this.DOMPurify.sanitize(testHtml);\n\n if (this.DOMPurify.removed && this.DOMPurify.removed.length > 0) {\n console.warn('Unsafe content detected, copy blocked');\n return;\n }\n }\n\n const textToCopy = `Question: ${this.currentQuestion}\\n\\nAnswer: ${responseToCopy}`;\n\n try {\n await navigator.clipboard.writeText(textToCopy);\n console.log('Content copied to clipboard');\n\n this.copyState = 'copied';\n this.requestUpdate();\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n this.copyTimeout = setTimeout(() => {\n this.copyState = 'idle';\n this.requestUpdate();\n }, 1500);\n } catch (err) {\n console.error('Failed to copy:', err);\n }\n }\n\n async handleLineCopy(lineIndex) {\n const originalLines = this.currentResponse.split('\\n');\n const lineToCopy = originalLines[lineIndex];\n\n if (!lineToCopy) return;\n\n try {\n await navigator.clipboard.writeText(lineToCopy);\n console.log('Line copied to clipboard');\n\n // '복사됨' 상태로 UI 즉시 업데이트\n this.lineCopyState = { ...this.lineCopyState, [lineIndex]: true };\n this.requestUpdate(); // LitElement에 UI 업데이트 요청\n\n // 기존 타임아웃이 있다면 초기화\n if (this.lineCopyTimeouts && this.lineCopyTimeouts[lineIndex]) {\n clearTimeout(this.lineCopyTimeouts[lineIndex]);\n }\n\n // ✨ 수정된 타임아웃: 1.5초 후 '복사됨' 상태 해제\n this.lineCopyTimeouts[lineIndex] = setTimeout(() => {\n const updatedState = { ...this.lineCopyState };\n delete updatedState[lineIndex];\n this.lineCopyState = updatedState;\n this.requestUpdate(); // UI 업데이트 요청\n }, 1500);\n } catch (err) {\n console.error('Failed to copy line:', err);\n }\n }\n\n async handleSendText(e, overridingText = '') {\n const textInput = this.shadowRoot?.getElementById('textInput');\n const text = (overridingText || textInput?.value || '').trim();\n // if (!text) return;\n\n textInput.value = '';\n\n if (window.api) {\n window.api.askView.sendMessage(text).catch(error => {\n console.error('Error sending text:', error);\n });\n }\n }\n\n handleTextKeydown(e) {\n // Fix for IME composition issue: Ignore Enter key presses while composing.\n if (e.isComposing) {\n return;\n }\n\n const isPlainEnter = e.key === 'Enter' && !e.shiftKey && !e.metaKey && !e.ctrlKey;\n const isModifierEnter = e.key === 'Enter' && (e.metaKey || e.ctrlKey);\n\n if (isPlainEnter || isModifierEnter) {\n e.preventDefault();\n this.handleSendText();\n }\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n \n // ✨ isLoading 또는 currentResponse가 변경될 때마다 뷰를 다시 그립니다.\n if (changedProperties.has('isLoading') || changedProperties.has('currentResponse')) {\n this.renderContent();\n }\n \n if (changedProperties.has('showTextInput') || changedProperties.has('isLoading') || changedProperties.has('currentResponse')) {\n this.adjustWindowHeightThrottled();\n }\n \n if (changedProperties.has('showTextInput') && this.showTextInput) {\n this.focusTextInput();\n }\n }\n\n firstUpdated() {\n setTimeout(() => this.adjustWindowHeight(), 200);\n }\n\n\n getTruncatedQuestion(question, maxLength = 30) {\n if (!question) return '';\n if (question.length <= maxLength) return question;\n return question.substring(0, maxLength) + '...';\n }\n\n\n\n render() {\n const hasResponse = this.isLoading || this.currentResponse || this.isStreaming;\n const headerText = this.isLoading ? 'Thinking...' : 'AI Response';\n\n return html`\n
\n \n
\n
\n
\n \n \n \n \n
\n ${headerText}\n
\n
\n ${this.getTruncatedQuestion(this.currentQuestion)}\n
\n \n \n
\n
\n
\n\n \n
\n \n
\n\n \n
\n \n \n Submit\n \n ↵\n \n \n
\n
\n `;\n }\n\n // Dynamically resize the BrowserWindow to fit current content\n adjustWindowHeight() {\n if (!window.api) return;\n\n this.updateComplete.then(() => {\n const headerEl = this.shadowRoot.querySelector('.response-header');\n const responseEl = this.shadowRoot.querySelector('.response-container');\n const inputEl = this.shadowRoot.querySelector('.text-input-container');\n\n if (!headerEl || !responseEl) return;\n\n const headerHeight = headerEl.classList.contains('hidden') ? 0 : headerEl.offsetHeight;\n const responseHeight = responseEl.scrollHeight;\n const inputHeight = (inputEl && !inputEl.classList.contains('hidden')) ? inputEl.offsetHeight : 0;\n\n const idealHeight = headerHeight + responseHeight + inputHeight;\n\n const targetHeight = Math.min(700, idealHeight);\n\n window.api.askView.adjustWindowHeight(\"ask\", targetHeight);\n\n }).catch(err => console.error('AskView adjustWindowHeight error:', err));\n }\n\n // Throttled wrapper to avoid excessive IPC spam (executes at most once per animation frame)\n adjustWindowHeightThrottled() {\n if (this.isThrottled) return;\n\n this.isThrottled = true;\n requestAnimationFrame(() => {\n this.adjustWindowHeight();\n this.isThrottled = false;\n });\n }\n}\n\ncustomElements.define('ask-view', AskView);\n"], ["/glass/src/ui/listen/audioCore/listenCapture.js", "const createAecModule = require('./aec.js');\n\nlet aecModPromise = null; // 한 번만 로드\nlet aecMod = null;\nlet aecPtr = 0; // Rust Aec* 1개만 재사용\n\n/** WASM 모듈 가져오고 1회 초기화 */\nasync function getAec () {\n if (aecModPromise) return aecModPromise; // 캐시\n\n aecModPromise = createAecModule().then((M) => {\n aecMod = M; \n\n console.log('WASM Module Loaded:', M); \n // C 심볼 → JS 래퍼 바인딩 (딱 1번)\n M.newPtr = M.cwrap('AecNew', 'number',\n ['number','number','number','number']);\n M.cancel = M.cwrap('AecCancelEcho', null,\n ['number','number','number','number','number']);\n M.destroy = M.cwrap('AecDestroy', null, ['number']);\n return M;\n });\n\n return aecModPromise;\n}\n\n// 바로 로드-실패 로그를 보기 위해\n// getAec().catch(console.error);\n// ---------------------------\n// Constants & Globals\n// ---------------------------\nconst SAMPLE_RATE = 24000;\nconst AUDIO_CHUNK_DURATION = 0.1;\nconst BUFFER_SIZE = 4096;\n\nconst isLinux = window.api.platform.isLinux;\nconst isMacOS = window.api.platform.isMacOS;\n\nlet mediaStream = null;\nlet micMediaStream = null;\nlet audioContext = null;\nlet audioProcessor = null;\nlet systemAudioContext = null;\nlet systemAudioProcessor = null;\n\nlet systemAudioBuffer = [];\nconst MAX_SYSTEM_BUFFER_SIZE = 10;\n\n// ---------------------------\n// Utility helpers (exact from renderer.js)\n// ---------------------------\nfunction isVoiceActive(audioFloat32Array, threshold = 0.005) {\n if (!audioFloat32Array || audioFloat32Array.length === 0) {\n return false;\n }\n\n let sumOfSquares = 0;\n for (let i = 0; i < audioFloat32Array.length; i++) {\n sumOfSquares += audioFloat32Array[i] * audioFloat32Array[i];\n }\n const rms = Math.sqrt(sumOfSquares / audioFloat32Array.length);\n\n // console.log(`VAD RMS: ${rms.toFixed(4)}`); // For debugging VAD threshold\n\n return rms > threshold;\n}\n\nfunction base64ToFloat32Array(base64) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n\n const int16Array = new Int16Array(bytes.buffer);\n const float32Array = new Float32Array(int16Array.length);\n\n for (let i = 0; i < int16Array.length; i++) {\n float32Array[i] = int16Array[i] / 32768.0;\n }\n\n return float32Array;\n}\n\nfunction convertFloat32ToInt16(float32Array) {\n const int16Array = new Int16Array(float32Array.length);\n for (let i = 0; i < float32Array.length; i++) {\n // Improved scaling to prevent clipping\n const s = Math.max(-1, Math.min(1, float32Array[i]));\n int16Array[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n return int16Array;\n}\n\nfunction arrayBufferToBase64(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n/* ───────────────────────── JS ↔︎ WASM 헬퍼 ───────────────────────── */\nfunction int16PtrFromFloat32(mod, f32) {\n const len = f32.length;\n const bytes = len * 2;\n const ptr = mod._malloc(bytes);\n // HEAP16이 없으면 HEAPU8.buffer로 직접 래핑\n const heapBuf = (mod.HEAP16 ? mod.HEAP16.buffer : mod.HEAPU8.buffer);\n const i16 = new Int16Array(heapBuf, ptr, len);\n for (let i = 0; i < len; ++i) {\n const s = Math.max(-1, Math.min(1, f32[i]));\n i16[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n return { ptr, view: i16 };\n}\n\nfunction float32FromInt16View(i16) {\n const out = new Float32Array(i16.length);\n for (let i = 0; i < i16.length; ++i) out[i] = i16[i] / 32768;\n return out;\n}\n\n/* 필요하다면 종료 시 */\nfunction disposeAec () {\n getAec().then(mod => { if (aecPtr) mod.destroy(aecPtr); });\n}\n\n// listenCapture.js\n\nfunction runAecSync(micF32, sysF32) {\n if (!aecMod || !aecPtr || !aecMod.HEAPU8) {\n // console.log('🔊 No AEC module or heap buffer');\n return micF32;\n }\n\n const frameSize = 160; // AEC 모듈 초기화 시 설정한 프레임 크기\n const numFrames = Math.floor(micF32.length / frameSize);\n\n // 최종 처리된 오디오 데이터를 담을 버퍼\n const processedF32 = new Float32Array(micF32.length);\n\n // 시스템 오디오와 마이크 오디오의 길이를 맞춥니다. (안정성 확보)\n let alignedSysF32 = new Float32Array(micF32.length);\n if (sysF32.length > 0) {\n // sysF32를 micF32 길이에 맞게 자르거나 채웁니다.\n const lengthToCopy = Math.min(micF32.length, sysF32.length);\n alignedSysF32.set(sysF32.slice(0, lengthToCopy));\n }\n\n\n // 2400개 샘플을 160개 프레임으로 나누어 루프 실행\n for (let i = 0; i < numFrames; i++) {\n const offset = i * frameSize;\n\n // 현재 프레임에 해당하는 160개 샘플을 잘라냅니다.\n const micFrame = micF32.subarray(offset, offset + frameSize);\n const echoFrame = alignedSysF32.subarray(offset, offset + frameSize);\n\n // WASM 메모리에 프레임 데이터 쓰기\n const micPtr = int16PtrFromFloat32(aecMod, micFrame);\n const echoPtr = int16PtrFromFloat32(aecMod, echoFrame);\n const outPtr = aecMod._malloc(frameSize * 2); // 160 * 2 bytes\n\n // AEC 실행 (160개 샘플 단위)\n aecMod.cancel(aecPtr, micPtr.ptr, echoPtr.ptr, outPtr, frameSize);\n\n // WASM 메모리에서 처리된 프레임 데이터 읽기\n const heapBuf = (aecMod.HEAP16 ? aecMod.HEAP16.buffer : aecMod.HEAPU8.buffer);\n const outFrameI16 = new Int16Array(heapBuf, outPtr, frameSize);\n const outFrameF32 = float32FromInt16View(outFrameI16);\n\n // 처리된 프레임을 최종 버퍼의 올바른 위치에 복사\n processedF32.set(outFrameF32, offset);\n\n // 할당된 메모리 해제\n aecMod._free(micPtr.ptr);\n aecMod._free(echoPtr.ptr);\n aecMod._free(outPtr);\n }\n\n return processedF32;\n // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲\n // 여기까지가 새로운 로직\n // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲\n}\n\n\n// System audio data handler\nwindow.api.listenCapture.onSystemAudioData((event, { data }) => {\n systemAudioBuffer.push({\n data: data,\n timestamp: Date.now(),\n });\n\n // 오래된 데이터 제거\n if (systemAudioBuffer.length > MAX_SYSTEM_BUFFER_SIZE) {\n systemAudioBuffer = systemAudioBuffer.slice(-MAX_SYSTEM_BUFFER_SIZE);\n }\n});\n\n// ---------------------------\n// Complete token tracker (exact from renderer.js)\n// ---------------------------\nlet tokenTracker = {\n tokens: [],\n audioStartTime: null,\n\n addTokens(count, type = 'image') {\n const now = Date.now();\n this.tokens.push({\n timestamp: now,\n count: count,\n type: type,\n });\n\n this.cleanOldTokens();\n },\n\n calculateImageTokens(width, height) {\n const pixels = width * height;\n if (pixels <= 384 * 384) {\n return 85;\n }\n\n const tiles = Math.ceil(pixels / (768 * 768));\n return tiles * 85;\n },\n\n trackAudioTokens() {\n if (!this.audioStartTime) {\n this.audioStartTime = Date.now();\n return;\n }\n\n const now = Date.now();\n const elapsedSeconds = (now - this.audioStartTime) / 1000;\n\n const audioTokens = Math.floor(elapsedSeconds * 16);\n\n if (audioTokens > 0) {\n this.addTokens(audioTokens, 'audio');\n this.audioStartTime = now;\n }\n },\n\n cleanOldTokens() {\n const oneMinuteAgo = Date.now() - 60 * 1000;\n this.tokens = this.tokens.filter(token => token.timestamp > oneMinuteAgo);\n },\n\n getTokensInLastMinute() {\n this.cleanOldTokens();\n return this.tokens.reduce((total, token) => total + token.count, 0);\n },\n\n shouldThrottle() {\n const throttleEnabled = localStorage.getItem('throttleTokens') === 'true';\n if (!throttleEnabled) {\n return false;\n }\n\n const maxTokensPerMin = parseInt(localStorage.getItem('maxTokensPerMin') || '500000', 10);\n const throttleAtPercent = parseInt(localStorage.getItem('throttleAtPercent') || '75', 10);\n\n const currentTokens = this.getTokensInLastMinute();\n const throttleThreshold = Math.floor((maxTokensPerMin * throttleAtPercent) / 100);\n\n console.log(`Token check: ${currentTokens}/${maxTokensPerMin} (throttle at ${throttleThreshold})`);\n\n return currentTokens >= throttleThreshold;\n },\n\n // Reset the tracker\n reset() {\n this.tokens = [];\n this.audioStartTime = null;\n },\n};\n\n// Track audio tokens every few seconds\nsetInterval(() => {\n tokenTracker.trackAudioTokens();\n}, 2000);\n\n// ---------------------------\n// Audio processing functions (exact from renderer.js)\n// ---------------------------\nasync function setupMicProcessing(micStream) {\n /* ── WASM 먼저 로드 ───────────────────────── */\n const mod = await getAec();\n if (!aecPtr) aecPtr = mod.newPtr(160, 1600, 24000, 1);\n\n\n const micAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n await micAudioContext.resume(); \n const micSource = micAudioContext.createMediaStreamSource(micStream);\n const micProcessor = micAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n micProcessor.onaudioprocess = (e) => {\n const inputData = e.inputBuffer.getChannelData(0);\n audioBuffer.push(...inputData);\n // console.log('🎤 micProcessor.onaudioprocess');\n\n // samplesPerChunk(=2400) 만큼 모이면 전송\n while (audioBuffer.length >= samplesPerChunk) {\n let chunk = audioBuffer.splice(0, samplesPerChunk);\n let processedChunk = new Float32Array(chunk); // 기본값\n\n // ───────────────── WASM AEC ─────────────────\n if (systemAudioBuffer.length > 0) {\n const latest = systemAudioBuffer[systemAudioBuffer.length - 1];\n const sysF32 = base64ToFloat32Array(latest.data);\n\n // **음성 구간일 때만 런**\n processedChunk = runAecSync(new Float32Array(chunk), sysF32);\n // console.log('🔊 Applied WASM-AEC (speex)');\n } else {\n console.log('🔊 No system audio for AEC reference');\n }\n\n const pcm16 = convertFloat32ToInt16(processedChunk);\n const b64 = arrayBufferToBase64(pcm16.buffer);\n\n window.api.listenCapture.sendMicAudioContent({\n data: b64,\n mimeType: 'audio/pcm;rate=24000',\n });\n }\n };\n\n micSource.connect(micProcessor);\n micProcessor.connect(micAudioContext.destination);\n\n audioProcessor = micProcessor;\n return { context: micAudioContext, processor: micProcessor };\n}\n\nfunction setupLinuxMicProcessing(micStream) {\n // Setup microphone audio processing for Linux\n const micAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n const micSource = micAudioContext.createMediaStreamSource(micStream);\n const micProcessor = micAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n micProcessor.onaudioprocess = async e => {\n const inputData = e.inputBuffer.getChannelData(0);\n audioBuffer.push(...inputData);\n\n // Process audio in chunks\n while (audioBuffer.length >= samplesPerChunk) {\n const chunk = audioBuffer.splice(0, samplesPerChunk);\n const pcmData16 = convertFloat32ToInt16(chunk);\n const base64Data = arrayBufferToBase64(pcmData16.buffer);\n\n await window.api.listenCapture.sendMicAudioContent({\n data: base64Data,\n mimeType: 'audio/pcm;rate=24000',\n });\n }\n };\n\n micSource.connect(micProcessor);\n micProcessor.connect(micAudioContext.destination);\n\n // Store processor reference for cleanup\n audioProcessor = micProcessor;\n}\n\nfunction setupSystemAudioProcessing(systemStream) {\n const systemAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n const systemSource = systemAudioContext.createMediaStreamSource(systemStream);\n const systemProcessor = systemAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n systemProcessor.onaudioprocess = async e => {\n const inputData = e.inputBuffer.getChannelData(0);\n if (!inputData || inputData.length === 0) return;\n \n audioBuffer.push(...inputData);\n\n while (audioBuffer.length >= samplesPerChunk) {\n const chunk = audioBuffer.splice(0, samplesPerChunk);\n const pcmData16 = convertFloat32ToInt16(chunk);\n const base64Data = arrayBufferToBase64(pcmData16.buffer);\n\n try {\n await window.api.listenCapture.sendSystemAudioContent({\n data: base64Data,\n mimeType: 'audio/pcm;rate=24000',\n });\n } catch (error) {\n console.error('Failed to send system audio:', error);\n }\n }\n };\n\n systemSource.connect(systemProcessor);\n systemProcessor.connect(systemAudioContext.destination);\n\n return { context: systemAudioContext, processor: systemProcessor };\n}\n\n// ---------------------------\n// Main capture functions (exact from renderer.js)\n// ---------------------------\nasync function startCapture(screenshotIntervalSeconds = 5, imageQuality = 'medium') {\n\n // Reset token tracker when starting new capture session\n tokenTracker.reset();\n console.log('🎯 Token tracker reset for new capture session');\n\n try {\n if (isMacOS) {\n\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n\n // On macOS, use SystemAudioDump for audio and getDisplayMedia for screen\n console.log('Starting macOS capture with SystemAudioDump...');\n\n // Start macOS audio capture\n const audioResult = await window.api.listenCapture.startMacosSystemAudio();\n if (!audioResult.success) {\n console.warn('[listenCapture] macOS audio start failed:', audioResult.error);\n\n // 이미 실행 중 → stop 후 재시도\n if (audioResult.error === 'already_running') {\n await window.api.listenCapture.stopMacosSystemAudio();\n await new Promise(r => setTimeout(r, 500));\n const retry = await window.api.listenCapture.startMacosSystemAudio();\n if (!retry.success) {\n throw new Error('Retry failed: ' + retry.error);\n }\n } else {\n throw new Error('Failed to start macOS audio capture: ' + audioResult.error);\n }\n }\n\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n\n console.log('macOS microphone capture started');\n const { context, processor } = await setupMicProcessing(micMediaStream);\n audioContext = context;\n audioProcessor = processor;\n } catch (micErr) {\n console.warn('Failed to get microphone on macOS:', micErr);\n }\n ////////// for index & subjects //////////\n\n console.log('macOS screen capture started - audio handled by SystemAudioDump');\n } else if (isLinux) {\n\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n \n // Linux - use display media for screen capture and getUserMedia for microphone\n mediaStream = await navigator.mediaDevices.getDisplayMedia({\n video: {\n frameRate: 1,\n width: { ideal: 1920 },\n height: { ideal: 1080 },\n },\n audio: false, // Don't use system audio loopback on Linux\n });\n\n // Get microphone input for Linux\n let micMediaStream = null;\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n\n console.log('Linux microphone capture started');\n\n // Setup audio processing for microphone on Linux\n setupLinuxMicProcessing(micMediaStream);\n } catch (micError) {\n console.warn('Failed to get microphone access on Linux:', micError);\n // Continue without microphone if permission denied\n }\n\n console.log('Linux screen capture started');\n } else {\n // Windows - capture mic and system audio separately using native loopback\n console.log('Starting Windows capture with native loopback audio...');\n\n // Ensure STT sessions are initialized before starting audio capture\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n\n // 1. Get user's microphone\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n console.log('Windows microphone capture started');\n const { context, processor } = await setupMicProcessing(micMediaStream);\n audioContext = context;\n audioProcessor = processor;\n } catch (micErr) {\n console.warn('Could not get microphone access on Windows:', micErr);\n }\n\n // 2. Get system audio using native Electron loopback\n try {\n mediaStream = await navigator.mediaDevices.getDisplayMedia({\n video: true,\n audio: true // This will now use native loopback from our handler\n });\n \n // Verify we got audio tracks\n const audioTracks = mediaStream.getAudioTracks();\n if (audioTracks.length === 0) {\n throw new Error('No audio track in native loopback stream');\n }\n \n console.log('Windows native loopback audio capture started');\n const { context, processor } = setupSystemAudioProcessing(mediaStream);\n systemAudioContext = context;\n systemAudioProcessor = processor;\n } catch (sysAudioErr) {\n console.error('Failed to start Windows native loopback audio:', sysAudioErr);\n // Continue without system audio\n }\n }\n } catch (err) {\n console.error('Error starting capture:', err);\n // Note: pickleGlass.e() is not available in this context, commenting out\n // pickleGlass.e().setStatus('error');\n }\n}\n\nfunction stopCapture() {\n // Clean up microphone resources\n if (audioProcessor) {\n audioProcessor.disconnect();\n audioProcessor = null;\n }\n if (audioContext) {\n audioContext.close();\n audioContext = null;\n }\n\n // Clean up system audio resources\n if (systemAudioProcessor) {\n systemAudioProcessor.disconnect();\n systemAudioProcessor = null;\n }\n if (systemAudioContext) {\n systemAudioContext.close();\n systemAudioContext = null;\n }\n\n // Stop and release media stream tracks\n if (mediaStream) {\n mediaStream.getTracks().forEach(track => track.stop());\n mediaStream = null;\n }\n if (micMediaStream) {\n micMediaStream.getTracks().forEach(t => t.stop());\n micMediaStream = null;\n }\n\n // Stop macOS audio capture if running\n if (isMacOS) {\n window.api.listenCapture.stopMacosSystemAudio().catch(err => {\n console.error('Error stopping macOS audio:', err);\n });\n }\n}\n\n// ---------------------------\n// Exports & global registration\n// ---------------------------\nmodule.exports = {\n getAec, // 새로 만든 초기화 함수\n runAecSync, // sync 버전\n disposeAec, // 필요시 Rust 객체 파괴\n startCapture,\n stopCapture,\n isLinux,\n isMacOS,\n};\n\n// Expose functions to global scope for external access (exact from renderer.js)\nif (typeof window !== 'undefined') {\n window.listenCapture = module.exports;\n window.pickleGlass = window.pickleGlass || {};\n window.pickleGlass.startCapture = startCapture;\n window.pickleGlass.stopCapture = stopCapture;\n} "], ["/glass/src/features/common/ai/providers/whisper.js", "let spawn, path, EventEmitter;\n\nif (typeof window === 'undefined') {\n spawn = require('child_process').spawn;\n path = require('path');\n EventEmitter = require('events').EventEmitter;\n} else {\n class DummyEventEmitter {\n on() {}\n emit() {}\n removeAllListeners() {}\n }\n EventEmitter = DummyEventEmitter;\n}\n\nclass WhisperSTTSession extends EventEmitter {\n constructor(model, whisperService, sessionId) {\n super();\n this.model = model;\n this.whisperService = whisperService;\n this.sessionId = sessionId || `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n this.process = null;\n this.isRunning = false;\n this.audioBuffer = Buffer.alloc(0);\n this.processingInterval = null;\n this.lastTranscription = '';\n }\n\n async initialize() {\n try {\n await this.whisperService.ensureModelAvailable(this.model);\n this.isRunning = true;\n this.startProcessingLoop();\n return true;\n } catch (error) {\n console.error('[WhisperSTT] Initialization error:', error);\n this.emit('error', error);\n return false;\n }\n }\n\n startProcessingLoop() {\n this.processingInterval = setInterval(async () => {\n const minBufferSize = 16000 * 2 * 0.15;\n if (this.audioBuffer.length >= minBufferSize && !this.process) {\n console.log(`[WhisperSTT-${this.sessionId}] Processing audio chunk, buffer size: ${this.audioBuffer.length}`);\n await this.processAudioChunk();\n }\n }, 1500);\n }\n\n async processAudioChunk() {\n if (!this.isRunning || this.audioBuffer.length === 0) return;\n\n const audioData = this.audioBuffer;\n this.audioBuffer = Buffer.alloc(0);\n\n try {\n const tempFile = await this.whisperService.saveAudioToTemp(audioData, this.sessionId);\n \n if (!tempFile || typeof tempFile !== 'string') {\n console.error('[WhisperSTT] Invalid temp file path:', tempFile);\n return;\n }\n \n const whisperPath = await this.whisperService.getWhisperPath();\n const modelPath = await this.whisperService.getModelPath(this.model);\n\n if (!whisperPath || !modelPath) {\n console.error('[WhisperSTT] Invalid whisper or model path:', { whisperPath, modelPath });\n return;\n }\n\n this.process = spawn(whisperPath, [\n '-m', modelPath,\n '-f', tempFile,\n '--no-timestamps',\n '--output-txt',\n '--output-json',\n '--language', 'auto',\n '--threads', '4',\n '--print-progress', 'false'\n ]);\n\n let output = '';\n let errorOutput = '';\n\n this.process.stdout.on('data', (data) => {\n output += data.toString();\n });\n\n this.process.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n\n this.process.on('close', async (code) => {\n this.process = null;\n \n if (code === 0 && output.trim()) {\n const transcription = output.trim();\n if (transcription && transcription !== this.lastTranscription) {\n this.lastTranscription = transcription;\n console.log(`[WhisperSTT-${this.sessionId}] Transcription: \"${transcription}\"`);\n this.emit('transcription', {\n text: transcription,\n timestamp: Date.now(),\n confidence: 1.0,\n sessionId: this.sessionId\n });\n }\n } else if (errorOutput) {\n console.error(`[WhisperSTT-${this.sessionId}] Process error:`, errorOutput);\n }\n\n await this.whisperService.cleanupTempFile(tempFile);\n });\n\n } catch (error) {\n console.error('[WhisperSTT] Processing error:', error);\n this.emit('error', error);\n }\n }\n\n sendRealtimeInput(audioData) {\n if (!this.isRunning) {\n console.warn(`[WhisperSTT-${this.sessionId}] Session not running, cannot accept audio`);\n return;\n }\n\n if (typeof audioData === 'string') {\n try {\n audioData = Buffer.from(audioData, 'base64');\n } catch (error) {\n console.error('[WhisperSTT] Failed to decode base64 audio data:', error);\n return;\n }\n } else if (audioData instanceof ArrayBuffer) {\n audioData = Buffer.from(audioData);\n } else if (!Buffer.isBuffer(audioData) && !(audioData instanceof Uint8Array)) {\n console.error('[WhisperSTT] Invalid audio data type:', typeof audioData);\n return;\n }\n\n if (!Buffer.isBuffer(audioData)) {\n audioData = Buffer.from(audioData);\n }\n\n if (audioData.length > 0) {\n this.audioBuffer = Buffer.concat([this.audioBuffer, audioData]);\n // Log every 10th audio chunk to avoid spam\n if (Math.random() < 0.1) {\n console.log(`[WhisperSTT-${this.sessionId}] Received audio chunk: ${audioData.length} bytes, total buffer: ${this.audioBuffer.length} bytes`);\n }\n }\n }\n\n async close() {\n console.log(`[WhisperSTT-${this.sessionId}] Closing session`);\n this.isRunning = false;\n\n if (this.processingInterval) {\n clearInterval(this.processingInterval);\n this.processingInterval = null;\n }\n\n if (this.process) {\n this.process.kill('SIGTERM');\n this.process = null;\n }\n\n this.removeAllListeners();\n }\n}\n\nclass WhisperProvider {\n static async validateApiKey() {\n // Whisper is a local service, no API key validation needed.\n return { success: true };\n }\n\n constructor() {\n this.whisperService = null;\n }\n\n async initialize() {\n if (!this.whisperService) {\n this.whisperService = require('../../services/whisperService');\n if (!this.whisperService.isInitialized) {\n await this.whisperService.initialize();\n }\n }\n }\n\n async createSTT(config) {\n await this.initialize();\n \n const model = config.model || 'whisper-tiny';\n const sessionType = config.sessionType || 'unknown';\n console.log(`[WhisperProvider] Creating ${sessionType} STT session with model: ${model}`);\n \n // Create unique session ID based on type\n const sessionId = `${sessionType}_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`;\n const session = new WhisperSTTSession(model, this.whisperService, sessionId);\n \n // Log session creation\n console.log(`[WhisperProvider] Created session: ${sessionId}`);\n \n const initialized = await session.initialize();\n if (!initialized) {\n throw new Error('Failed to initialize Whisper STT session');\n }\n\n if (config.callbacks) {\n if (config.callbacks.onmessage) {\n session.on('transcription', config.callbacks.onmessage);\n }\n if (config.callbacks.onerror) {\n session.on('error', config.callbacks.onerror);\n }\n if (config.callbacks.onclose) {\n session.on('close', config.callbacks.onclose);\n }\n }\n\n return session;\n }\n\n async createLLM() {\n throw new Error('Whisper provider does not support LLM functionality');\n }\n\n async createStreamingLLM() {\n console.warn('[WhisperProvider] Streaming LLM is not supported by Whisper.');\n throw new Error('Whisper does not support LLM.');\n }\n}\n\nmodule.exports = {\n WhisperProvider,\n WhisperSTTSession\n};"], ["/glass/src/features/common/ai/providers/anthropic.js", "const { Anthropic } = require(\"@anthropic-ai/sdk\")\n\nclass AnthropicProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string' || !key.startsWith('sk-ant-')) {\n return { success: false, error: 'Invalid Anthropic API key format.' };\n }\n\n try {\n const response = await fetch(\"https://api.anthropic.com/v1/messages\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": key,\n \"anthropic-version\": \"2023-06-01\",\n },\n body: JSON.stringify({\n model: \"claude-3-haiku-20240307\",\n max_tokens: 1,\n messages: [{ role: \"user\", content: \"Hi\" }],\n }),\n });\n\n if (response.ok || response.status === 400) { // 400 is a valid response for a bad request, not a bad key\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n return { success: false, error: errorData.error?.message || `Validation failed with status: ${response.status}` };\n }\n } catch (error) {\n console.error(`[AnthropicProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n/**\n * Creates an Anthropic STT session\n * Note: Anthropic doesn't have native real-time STT, so this is a placeholder\n * You might want to use a different STT service or implement a workaround\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.language='en'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @returns {Promise} STT session placeholder\n */\nasync function createSTT({ apiKey, language = \"en\", callbacks = {}, ...config }) {\n console.warn(\"[Anthropic] STT not natively supported. Consider using OpenAI or Gemini for STT.\")\n\n // Return a mock STT session that doesn't actually do anything\n // You might want to fallback to another provider for STT\n return {\n sendRealtimeInput: async (audioData) => {\n console.warn(\"[Anthropic] STT sendRealtimeInput called but not implemented\")\n },\n close: async () => {\n console.log(\"[Anthropic] STT session closed\")\n },\n }\n}\n\n/**\n * Creates an Anthropic LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.model='claude-3-5-sonnet-20241022'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=4096] - Max tokens\n * @returns {object} LLM instance\n */\nfunction createLLM({ apiKey, model = \"claude-3-5-sonnet-20241022\", temperature = 0.7, maxTokens = 4096, ...config }) {\n const client = new Anthropic({ apiKey })\n\n return {\n generateContent: async (parts) => {\n const messages = []\n let systemPrompt = \"\"\n const userContent = []\n\n for (const part of parts) {\n if (typeof part === \"string\") {\n if (systemPrompt === \"\" && part.includes(\"You are\")) {\n systemPrompt = part\n } else {\n userContent.push({ type: \"text\", text: part })\n }\n } else if (part.inlineData) {\n userContent.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: part.inlineData.mimeType,\n data: part.inlineData.data,\n },\n })\n }\n }\n\n if (userContent.length > 0) {\n messages.push({ role: \"user\", content: userContent })\n }\n\n try {\n const response = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: messages,\n })\n\n return {\n response: {\n text: () => response.content[0].text,\n },\n raw: response,\n }\n } catch (error) {\n console.error(\"Anthropic API error:\", error)\n throw error\n }\n },\n\n // For compatibility with chat-style interfaces\n chat: async (messages) => {\n let systemPrompt = \"\"\n const anthropicMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemPrompt = msg.content\n } else {\n // Handle multimodal content\n let content\n if (Array.isArray(msg.content)) {\n content = []\n for (const part of msg.content) {\n if (typeof part === \"string\") {\n content.push({ type: \"text\", text: part })\n } else if (part.type === \"text\") {\n content.push({ type: \"text\", text: part.text })\n } else if (part.type === \"image_url\" && part.image_url) {\n // Convert base64 image to Anthropic format\n const imageUrl = part.image_url.url\n const [mimeInfo, base64Data] = imageUrl.split(\",\")\n\n // Extract the actual MIME type from the data URL\n const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || \"image/jpeg\"\n\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: mimeType,\n data: base64Data,\n },\n })\n }\n }\n } else {\n content = [{ type: \"text\", text: msg.content }]\n }\n\n anthropicMessages.push({\n role: msg.role === \"user\" ? \"user\" : \"assistant\",\n content: content,\n })\n }\n }\n\n const response = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: anthropicMessages,\n })\n\n return {\n content: response.content[0].text,\n raw: response,\n }\n },\n }\n}\n\n/**\n * Creates an Anthropic streaming LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.model='claude-3-5-sonnet-20241022'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=4096] - Max tokens\n * @returns {object} Streaming LLM instance\n */\nfunction createStreamingLLM({\n apiKey,\n model = \"claude-3-5-sonnet-20241022\",\n temperature = 0.7,\n maxTokens = 4096,\n ...config\n}) {\n const client = new Anthropic({ apiKey })\n\n return {\n streamChat: async (messages) => {\n console.log(\"[Anthropic Provider] Starting streaming request\")\n\n let systemPrompt = \"\"\n const anthropicMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemPrompt = msg.content\n } else {\n // Handle multimodal content\n let content\n if (Array.isArray(msg.content)) {\n content = []\n for (const part of msg.content) {\n if (typeof part === \"string\") {\n content.push({ type: \"text\", text: part })\n } else if (part.type === \"text\") {\n content.push({ type: \"text\", text: part.text })\n } else if (part.type === \"image_url\" && part.image_url) {\n // Convert base64 image to Anthropic format\n const imageUrl = part.image_url.url\n const [mimeInfo, base64Data] = imageUrl.split(\",\")\n\n // Extract the actual MIME type from the data URL\n const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || \"image/jpeg\"\n\n console.log(`[Anthropic] Processing image with MIME type: ${mimeType}`)\n\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: mimeType,\n data: base64Data,\n },\n })\n }\n }\n } else {\n content = [{ type: \"text\", text: msg.content }]\n }\n\n anthropicMessages.push({\n role: msg.role === \"user\" ? \"user\" : \"assistant\",\n content: content,\n })\n }\n }\n\n // Create a ReadableStream to handle Anthropic's streaming\n const stream = new ReadableStream({\n async start(controller) {\n try {\n console.log(\"[Anthropic Provider] Processing messages:\", anthropicMessages.length, \"messages\")\n\n let chunkCount = 0\n let totalContent = \"\"\n\n // Stream the response\n const stream = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: anthropicMessages,\n stream: true,\n })\n\n for await (const chunk of stream) {\n if (chunk.type === \"content_block_delta\" && chunk.delta.type === \"text_delta\") {\n chunkCount++\n const chunkText = chunk.delta.text || \"\"\n totalContent += chunkText\n\n // Format as SSE data\n const data = JSON.stringify({\n choices: [\n {\n delta: {\n content: chunkText,\n },\n },\n ],\n })\n controller.enqueue(new TextEncoder().encode(`data: ${data}\\n\\n`))\n }\n }\n\n console.log(\n `[Anthropic Provider] Streamed ${chunkCount} chunks, total length: ${totalContent.length} chars`,\n )\n\n // Send the final done message\n controller.enqueue(new TextEncoder().encode(\"data: [DONE]\\n\\n\"))\n controller.close()\n console.log(\"[Anthropic Provider] Streaming completed successfully\")\n } catch (error) {\n console.error(\"[Anthropic Provider] Streaming error:\", error)\n controller.error(error)\n }\n },\n })\n\n // Create a Response object with the stream\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n },\n })\n },\n }\n}\n\nmodule.exports = {\n AnthropicProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};\n"], ["/glass/src/features/common/repositories/firestoreConverter.js", "const encryptionService = require('../services/encryptionService');\nconst { Timestamp } = require('firebase/firestore');\n\n/**\n * Creates a Firestore converter that automatically encrypts and decrypts specified fields.\n * @param {string[]} fieldsToEncrypt - An array of field names to encrypt.\n * @returns {import('@firebase/firestore').FirestoreDataConverter} A Firestore converter.\n * @template T\n */\nfunction createEncryptedConverter(fieldsToEncrypt = []) {\n return {\n /**\n * @param {import('@firebase/firestore').DocumentData} appObject\n */\n toFirestore: (appObject) => {\n const firestoreData = { ...appObject };\n for (const field of fieldsToEncrypt) {\n if (Object.prototype.hasOwnProperty.call(firestoreData, field) && firestoreData[field] != null) {\n firestoreData[field] = encryptionService.encrypt(firestoreData[field]);\n }\n }\n // Ensure there's a timestamp for the last modification\n firestoreData.updated_at = Timestamp.now();\n return firestoreData;\n },\n /**\n * @param {import('@firebase/firestore').QueryDocumentSnapshot} snapshot\n * @param {import('@firebase/firestore').SnapshotOptions} options\n */\n fromFirestore: (snapshot, options) => {\n const firestoreData = snapshot.data(options);\n const appObject = { ...firestoreData, id: snapshot.id }; // include the document ID\n\n for (const field of fieldsToEncrypt) {\n if (Object.prototype.hasOwnProperty.call(appObject, field) && appObject[field] != null) {\n try {\n appObject[field] = encryptionService.decrypt(appObject[field]);\n } catch (error) {\n console.warn(`[FirestoreConverter] Failed to decrypt field '${field}' (possibly plaintext or key mismatch):`, error.message);\n // Keep the original value instead of failing\n // appObject[field] remains as is\n }\n }\n }\n\n // Convert Firestore Timestamps back to Unix timestamps (seconds) for app-wide consistency\n for (const key in appObject) {\n if (appObject[key] instanceof Timestamp) {\n appObject[key] = appObject[key].seconds;\n }\n }\n \n return appObject;\n }\n };\n}\n\nmodule.exports = {\n createEncryptedConverter,\n}; "], ["/glass/src/ui/app/HeaderController.js", "import './MainHeader.js';\nimport './ApiKeyHeader.js';\nimport './PermissionHeader.js';\nimport './WelcomeHeader.js';\n\nclass HeaderTransitionManager {\n constructor() {\n this.headerContainer = document.getElementById('header-container');\n this.currentHeaderType = null; // 'welcome' | 'apikey' | 'main' | 'permission'\n this.welcomeHeader = null;\n this.apiKeyHeader = null;\n this.mainHeader = null;\n this.permissionHeader = null;\n\n /**\n * only one header window is allowed\n * @param {'welcome'|'apikey'|'main'|'permission'} type\n */\n this.ensureHeader = (type) => {\n console.log('[HeaderController] ensureHeader: Ensuring header of type:', type);\n if (this.currentHeaderType === type) {\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'already exists.');\n return;\n }\n\n this.headerContainer.innerHTML = '';\n \n this.welcomeHeader = null;\n this.apiKeyHeader = null;\n this.mainHeader = null;\n this.permissionHeader = null;\n\n // Create new header element\n if (type === 'welcome') {\n this.welcomeHeader = document.createElement('welcome-header');\n this.welcomeHeader.loginCallback = () => this.handleLoginOption();\n this.welcomeHeader.apiKeyCallback = () => this.handleApiKeyOption();\n this.headerContainer.appendChild(this.welcomeHeader);\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'created.');\n } else if (type === 'apikey') {\n this.apiKeyHeader = document.createElement('apikey-header');\n this.apiKeyHeader.stateUpdateCallback = (userState) => this.handleStateUpdate(userState);\n this.apiKeyHeader.backCallback = () => this.transitionToWelcomeHeader();\n this.apiKeyHeader.addEventListener('request-resize', e => {\n this._resizeForApiKey(e.detail.height); \n });\n this.headerContainer.appendChild(this.apiKeyHeader);\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'created.');\n } else if (type === 'permission') {\n this.permissionHeader = document.createElement('permission-setup');\n this.permissionHeader.addEventListener('request-resize', e => {\n this._resizeForPermissionHeader(e.detail.height); \n });\n this.permissionHeader.continueCallback = async () => {\n if (window.api && window.api.headerController) {\n console.log('[HeaderController] Re-initializing model state after permission grant...');\n await window.api.headerController.reInitializeModelState();\n }\n this.transitionToMainHeader();\n };\n this.headerContainer.appendChild(this.permissionHeader);\n } else {\n this.mainHeader = document.createElement('main-header');\n this.headerContainer.appendChild(this.mainHeader);\n this.mainHeader.startSlideInAnimation?.();\n }\n\n this.currentHeaderType = type;\n this.notifyHeaderState(type === 'permission' ? 'apikey' : type); // Keep permission state as apikey for compatibility\n };\n\n console.log('[HeaderController] Manager initialized');\n\n // WelcomeHeader 콜백 메서드들\n this.handleLoginOption = this.handleLoginOption.bind(this);\n this.handleApiKeyOption = this.handleApiKeyOption.bind(this);\n\n this._bootstrap();\n\n if (window.api) {\n window.api.headerController.onUserStateChanged((event, userState) => {\n console.log('[HeaderController] Received user state change:', userState);\n this.handleStateUpdate(userState);\n });\n\n window.api.headerController.onAuthFailed((event, { message }) => {\n console.error('[HeaderController] Received auth failure from main process:', message);\n if (this.apiKeyHeader) {\n this.apiKeyHeader.errorMessage = 'Authentication failed. Please try again.';\n this.apiKeyHeader.isLoading = false;\n }\n });\n window.api.headerController.onForceShowApiKeyHeader(async () => {\n console.log('[HeaderController] Received broadcast to show apikey header. Switching now.');\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n if (!isConfigured) {\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n } else {\n await this._resizeForApiKey();\n this.ensureHeader('apikey');\n }\n }); \n }\n }\n\n notifyHeaderState(stateOverride) {\n const state = stateOverride || this.currentHeaderType || 'apikey';\n if (window.api) {\n window.api.headerController.sendHeaderStateChanged(state);\n }\n }\n\n async _bootstrap() {\n // The initial state will be sent by the main process via 'user-state-changed'\n // We just need to request it.\n if (window.api) {\n const userState = await window.api.common.getCurrentUser();\n console.log('[HeaderController] Bootstrapping with initial user state:', userState);\n this.handleStateUpdate(userState);\n } else {\n // Fallback for non-electron environment (testing/web)\n this.ensureHeader('welcome');\n }\n }\n\n\n //////// after_modelStateService ////////\n async handleStateUpdate(userState) {\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n\n if (isConfigured) {\n // If providers are configured, always check permissions regardless of login state.\n const permissionResult = await this.checkPermissions();\n if (permissionResult.success) {\n this.transitionToMainHeader();\n } else {\n this.transitionToPermissionHeader();\n }\n } else {\n // If no providers are configured, show the welcome header to prompt for setup.\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n }\n }\n\n // WelcomeHeader 콜백 메서드들\n async handleLoginOption() {\n console.log('[HeaderController] Login option selected');\n if (window.api) {\n await window.api.common.startFirebaseAuth();\n }\n }\n\n async handleApiKeyOption() {\n console.log('[HeaderController] API key option selected');\n await this._resizeForApiKey(400);\n this.ensureHeader('apikey');\n // ApiKeyHeader에 뒤로가기 콜백 설정\n if (this.apiKeyHeader) {\n this.apiKeyHeader.backCallback = () => this.transitionToWelcomeHeader();\n }\n }\n\n async transitionToWelcomeHeader() {\n if (this.currentHeaderType === 'welcome') {\n return this._resizeForWelcome();\n }\n\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n }\n //////// after_modelStateService ////////\n\n async transitionToPermissionHeader() {\n // Prevent duplicate transitions\n if (this.currentHeaderType === 'permission') {\n console.log('[HeaderController] Already showing permission setup, skipping transition');\n return;\n }\n\n // Check if permissions were previously completed\n if (window.api) {\n try {\n const permissionsCompleted = await window.api.headerController.checkPermissionsCompleted();\n if (permissionsCompleted) {\n console.log('[HeaderController] Permissions were previously completed, checking current status...');\n \n // Double check current permission status\n const permissionResult = await this.checkPermissions();\n if (permissionResult.success) {\n // Skip permission setup if already granted\n this.transitionToMainHeader();\n return;\n }\n \n console.log('[HeaderController] Permissions were revoked, showing setup again');\n }\n } catch (error) {\n console.error('[HeaderController] Error checking permissions completed status:', error);\n }\n }\n\n let initialHeight = 220;\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n if (userState.mode === 'firebase') {\n initialHeight = 280;\n }\n } catch (e) {\n console.error('Could not get user state for resize', e);\n }\n }\n\n await this._resizeForPermissionHeader(initialHeight);\n this.ensureHeader('permission');\n }\n\n async transitionToMainHeader(animate = true) {\n if (this.currentHeaderType === 'main') {\n return this._resizeForMain();\n }\n\n await this._resizeForMain();\n this.ensureHeader('main');\n }\n\n async _resizeForMain() {\n if (!window.api) return;\n console.log('[HeaderController] _resizeForMain: Resizing window to 353x47');\n return window.api.headerController.resizeHeaderWindow({ width: 353, height: 47 }).catch(() => {});\n }\n\n async _resizeForApiKey(height = 370) {\n if (!window.api) return;\n console.log(`[HeaderController] _resizeForApiKey: Resizing window to 456x${height}`);\n return window.api.headerController.resizeHeaderWindow({ width: 456, height: height }).catch(() => {});\n }\n\n async _resizeForPermissionHeader(height) {\n if (!window.api) return;\n const finalHeight = height || 220;\n return window.api.headerController.resizeHeaderWindow({ width: 285, height: finalHeight })\n .catch(() => {});\n }\n\n async _resizeForWelcome() {\n if (!window.api) return;\n console.log('[HeaderController] _resizeForWelcome: Resizing window to 456x370');\n return window.api.headerController.resizeHeaderWindow({ width: 456, height: 364 })\n .catch(() => {});\n }\n\n async checkPermissions() {\n if (!window.api) {\n return { success: true };\n }\n \n try {\n const permissions = await window.api.headerController.checkSystemPermissions();\n console.log('[HeaderController] Current permissions:', permissions);\n \n if (!permissions.needsSetup) {\n return { success: true };\n }\n\n let errorMessage = '';\n if (!permissions.microphone && !permissions.screen) {\n errorMessage = 'Microphone and screen recording access required';\n }\n \n return { \n success: false, \n error: errorMessage\n };\n } catch (error) {\n console.error('[HeaderController] Error checking permissions:', error);\n return { \n success: false, \n error: 'Failed to check permissions' \n };\n }\n }\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n new HeaderTransitionManager();\n});\n"], ["/glass/src/features/common/ai/providers/ollama.js", "const http = require('http');\nconst fetch = require('node-fetch');\n\n// Request Queue System for Ollama API (only for non-streaming requests)\nclass RequestQueue {\n constructor() {\n this.queue = [];\n this.processing = false;\n this.streamingActive = false;\n }\n\n async addStreamingRequest(requestFn) {\n // Streaming requests have priority - wait for current processing to finish\n while (this.processing) {\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n \n this.streamingActive = true;\n console.log('[Ollama Queue] Starting streaming request (priority)');\n \n try {\n const result = await requestFn();\n return result;\n } finally {\n this.streamingActive = false;\n console.log('[Ollama Queue] Streaming request completed');\n }\n }\n\n async add(requestFn) {\n return new Promise((resolve, reject) => {\n this.queue.push({ requestFn, resolve, reject });\n this.process();\n });\n }\n\n async process() {\n if (this.processing || this.queue.length === 0) {\n return;\n }\n\n // Wait if streaming is active\n if (this.streamingActive) {\n setTimeout(() => this.process(), 100);\n return;\n }\n\n this.processing = true;\n\n while (this.queue.length > 0) {\n // Check if streaming started while processing queue\n if (this.streamingActive) {\n this.processing = false;\n setTimeout(() => this.process(), 100);\n return;\n }\n\n const { requestFn, resolve, reject } = this.queue.shift();\n \n try {\n console.log(`[Ollama Queue] Processing queued request (${this.queue.length} remaining)`);\n const result = await requestFn();\n resolve(result);\n } catch (error) {\n console.error('[Ollama Queue] Request failed:', error);\n reject(error);\n }\n }\n\n this.processing = false;\n }\n}\n\n// Global request queue instance\nconst requestQueue = new RequestQueue();\n\nclass OllamaProvider {\n static async validateApiKey() {\n try {\n const response = await fetch('http://localhost:11434/api/tags');\n if (response.ok) {\n return { success: true };\n } else {\n return { success: false, error: 'Ollama service is not running. Please start Ollama first.' };\n }\n } catch (error) {\n return { success: false, error: 'Cannot connect to Ollama. Please ensure Ollama is installed and running.' };\n }\n }\n}\n\n\nfunction convertMessagesToOllamaFormat(messages) {\n return messages.map(msg => {\n if (Array.isArray(msg.content)) {\n let textContent = '';\n const images = [];\n \n for (const part of msg.content) {\n if (part.type === 'text') {\n textContent += part.text;\n } else if (part.type === 'image_url') {\n const base64 = part.image_url.url.replace(/^data:image\\/[^;]+;base64,/, '');\n images.push(base64);\n }\n }\n \n return {\n role: msg.role,\n content: textContent,\n ...(images.length > 0 && { images })\n };\n } else {\n return msg;\n }\n });\n}\n\nfunction createLLM({ \n model, \n temperature = 0.7, \n maxTokens = 2048, \n baseUrl = 'http://localhost:11434',\n ...config \n}) {\n if (!model) {\n throw new Error('Model parameter is required for Ollama LLM. Please specify a model name (e.g., \"llama3.2:latest\", \"gemma3:4b\")');\n }\n return {\n generateContent: async (parts) => {\n let systemPrompt = '';\n const userContent = [];\n\n for (const part of parts) {\n if (typeof part === 'string') {\n if (systemPrompt === '' && part.includes('You are')) {\n systemPrompt = part;\n } else {\n userContent.push(part);\n }\n } else if (part.inlineData) {\n userContent.push({\n type: 'image',\n image: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`\n });\n }\n }\n\n const messages = [];\n if (systemPrompt) {\n messages.push({ role: 'system', content: systemPrompt });\n }\n messages.push({ role: 'user', content: userContent.join('\\n') });\n\n // Use request queue to prevent concurrent API calls\n return await requestQueue.add(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages,\n stream: false,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n \n return {\n response: {\n text: () => result.message.content\n },\n raw: result\n };\n } catch (error) {\n console.error('Ollama LLM error:', error);\n throw error;\n }\n });\n },\n\n chat: async (messages) => {\n const ollamaMessages = convertMessagesToOllamaFormat(messages);\n\n // Use request queue to prevent concurrent API calls\n return await requestQueue.add(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages: ollamaMessages,\n stream: false,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n \n return {\n content: result.message.content,\n raw: result\n };\n } catch (error) {\n console.error('Ollama chat error:', error);\n throw error;\n }\n });\n }\n };\n}\n\nfunction createStreamingLLM({ \n model, \n temperature = 0.7, \n maxTokens = 2048, \n baseUrl = 'http://localhost:11434',\n ...config \n}) {\n if (!model) {\n throw new Error('Model parameter is required for Ollama streaming LLM. Please specify a model name (e.g., \"llama3.2:latest\", \"gemma3:4b\")');\n }\n return {\n streamChat: async (messages) => {\n console.log('[Ollama Provider] Starting streaming request');\n\n const ollamaMessages = convertMessagesToOllamaFormat(messages);\n console.log('[Ollama Provider] Converted messages for Ollama:', ollamaMessages);\n\n // Streaming requests have priority over queued requests\n return await requestQueue.addStreamingRequest(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages: ollamaMessages,\n stream: true,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n console.log('[Ollama Provider] Got streaming response');\n\n const stream = new ReadableStream({\n async start(controller) {\n let buffer = '';\n\n try {\n response.body.on('data', (chunk) => {\n buffer += chunk.toString();\n const lines = buffer.split('\\n');\n buffer = lines.pop() || '';\n\n for (const line of lines) {\n if (line.trim() === '') continue;\n \n try {\n const data = JSON.parse(line);\n \n if (data.message?.content) {\n const sseData = JSON.stringify({\n choices: [{\n delta: {\n content: data.message.content\n }\n }]\n });\n controller.enqueue(new TextEncoder().encode(`data: ${sseData}\\n\\n`));\n }\n \n if (data.done) {\n controller.enqueue(new TextEncoder().encode('data: [DONE]\\n\\n'));\n }\n } catch (e) {\n console.error('[Ollama Provider] Failed to parse chunk:', e);\n }\n }\n });\n\n response.body.on('end', () => {\n controller.close();\n console.log('[Ollama Provider] Streaming completed');\n });\n\n response.body.on('error', (error) => {\n console.error('[Ollama Provider] Streaming error:', error);\n controller.error(error);\n });\n \n } catch (error) {\n console.error('[Ollama Provider] Streaming setup error:', error);\n controller.error(error);\n }\n }\n });\n\n return {\n ok: true,\n body: stream\n };\n \n } catch (error) {\n console.error('[Ollama Provider] Request error:', error);\n throw error;\n }\n });\n }\n };\n}\n\nmodule.exports = {\n OllamaProvider,\n createLLM,\n createStreamingLLM,\n convertMessagesToOllamaFormat\n}; "], ["/glass/src/features/common/repositories/providerSettings/index.js", "const sqliteRepository = require('./sqlite.repository');\n\nfunction getBaseRepository() {\n // For now, we only have sqlite. This could be expanded later.\n return sqliteRepository;\n}\n\nconst providerSettingsRepositoryAdapter = {\n // Core CRUD operations\n async getByProvider(provider) {\n const repo = getBaseRepository();\n return await repo.getByProvider(provider);\n },\n\n async getAll() {\n const repo = getBaseRepository();\n return await repo.getAll();\n },\n\n async upsert(provider, settings) {\n const repo = getBaseRepository();\n const now = Date.now();\n \n const settingsWithMeta = {\n ...settings,\n provider,\n updated_at: now,\n created_at: settings.created_at || now\n };\n \n return await repo.upsert(provider, settingsWithMeta);\n },\n\n async remove(provider) {\n const repo = getBaseRepository();\n return await repo.remove(provider);\n },\n\n async removeAll() {\n const repo = getBaseRepository();\n return await repo.removeAll();\n },\n\n async getRawApiKeys() {\n // This function should always target the local sqlite DB,\n // as it's part of the local-first boot sequence.\n return await sqliteRepository.getRawApiKeys();\n },\n \n async getActiveProvider(type) {\n const repo = getBaseRepository();\n return await repo.getActiveProvider(type);\n },\n \n async setActiveProvider(provider, type) {\n const repo = getBaseRepository();\n return await repo.setActiveProvider(provider, type);\n },\n \n async getActiveSettings() {\n const repo = getBaseRepository();\n return await repo.getActiveSettings();\n }\n};\n\nmodule.exports = {\n ...providerSettingsRepositoryAdapter\n}; "], ["/glass/src/ui/listen/ListenView.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\nimport './stt/SttView.js';\nimport './summary/SummaryView.js';\n\nexport class ListenView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 400px;\n transform: translate3d(0, 0, 0);\n backface-visibility: hidden;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n will-change: transform, opacity;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n/* Allow text selection in insights responses */\n.insights-container, .insights-container *, .markdown-content {\n user-select: text !important;\n cursor: text !important;\n}\n\n/* highlight.js 스타일 추가 */\n.insights-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n}\n\n.insights-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n}\n\n.insights-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n}\n\n.insights-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n}\n\n.hljs-keyword {\n color: #ff79c6 !important;\n}\n\n.hljs-string {\n color: #f1fa8c !important;\n}\n\n.hljs-comment {\n color: #6272a4 !important;\n}\n\n.hljs-number {\n color: #bd93f9 !important;\n}\n\n.hljs-function {\n color: #50fa7b !important;\n}\n\n.hljs-title {\n color: #50fa7b !important;\n}\n\n.hljs-variable {\n color: #8be9fd !important;\n}\n\n.hljs-built_in {\n color: #ffb86c !important;\n}\n\n.hljs-attr {\n color: #50fa7b !important;\n}\n\n.hljs-tag {\n color: #ff79c6 !important;\n}\n .assistant-container {\n display: flex;\n flex-direction: column;\n color: #ffffff;\n box-sizing: border-box;\n position: relative;\n background: rgba(0, 0, 0, 0.6);\n overflow: hidden;\n border-radius: 12px;\n width: 100%;\n height: 100%;\n }\n\n .assistant-container::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 12px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .assistant-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n z-index: -1;\n }\n\n .top-bar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 6px 16px;\n min-height: 32px;\n position: relative;\n z-index: 1;\n width: 100%;\n box-sizing: border-box;\n flex-shrink: 0;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .bar-left-text {\n color: white;\n font-size: 13px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n position: relative;\n overflow: hidden;\n white-space: nowrap;\n flex: 1;\n min-width: 0;\n max-width: 200px;\n }\n\n .bar-left-text-content {\n display: inline-block;\n transition: transform 0.3s ease;\n }\n\n .bar-left-text-content.slide-in {\n animation: slideIn 0.3s ease forwards;\n }\n\n .bar-controls {\n display: flex;\n gap: 4px;\n align-items: center;\n flex-shrink: 0;\n width: 120px;\n justify-content: flex-end;\n box-sizing: border-box;\n padding: 4px;\n }\n\n .toggle-button {\n display: flex;\n align-items: center;\n gap: 5px;\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: none;\n outline: none;\n box-shadow: none;\n padding: 4px 8px;\n border-radius: 5px;\n font-size: 11px;\n font-weight: 500;\n cursor: pointer;\n height: 24px;\n white-space: nowrap;\n transition: background-color 0.15s ease;\n justify-content: center;\n }\n\n .toggle-button:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .toggle-button svg {\n flex-shrink: 0;\n width: 12px;\n height: 12px;\n }\n\n .copy-button {\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: none;\n outline: none;\n box-shadow: none;\n padding: 4px;\n border-radius: 3px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 24px;\n height: 24px;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n position: relative;\n overflow: hidden;\n }\n\n .copy-button:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n\n .copy-button svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n }\n\n .copy-button .check-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .copy-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .check-icon {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n\n .timer {\n font-family: 'Monaco', 'Menlo', monospace;\n font-size: 10px;\n color: rgba(255, 255, 255, 0.7);\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .top-bar,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .transcription-container,\n :host-context(body.has-glass) .insights-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .outline-item,\n :host-context(body.has-glass) .request-item,\n :host-context(body.has-glass) .markdown-content,\n :host-context(body.has-glass) .insights-container pre,\n :host-context(body.has-glass) .insights-container p code,\n :host-context(body.has-glass) .insights-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container::before,\n :host-context(body.has-glass) .assistant-container::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .toggle-button:hover,\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .outline-item:hover,\n :host-context(body.has-glass) .request-item.clickable:hover,\n :host-context(body.has-glass) .markdown-content:hover {\n background: transparent !important;\n transform: none !important;\n }\n\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-thumb,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button {\n border-radius: 0 !important;\n }\n\n :host-context(body.has-glass) ::-webkit-scrollbar,\n :host-context(body.has-glass) ::-webkit-scrollbar-track,\n :host-context(body.has-glass) ::-webkit-scrollbar-thumb {\n background: transparent !important;\n width: 0 !important; /* 스크롤바 자체 숨기기 */\n }\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .top-bar,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .transcription-container,\n :host-context(body.has-glass) .insights-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .outline-item,\n :host-context(body.has-glass) .request-item,\n :host-context(body.has-glass) .markdown-content,\n :host-context(body.has-glass) .insights-container pre,\n :host-context(body.has-glass) .insights-container p code,\n :host-context(body.has-glass) .insights-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container::before,\n :host-context(body.has-glass) .assistant-container::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .toggle-button:hover,\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .outline-item:hover,\n :host-context(body.has-glass) .request-item.clickable:hover,\n :host-context(body.has-glass) .markdown-content:hover {\n background: transparent !important;\n transform: none !important;\n }\n\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-thumb,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button {\n border-radius: 0 !important;\n }\n\n :host-context(body.has-glass) ::-webkit-scrollbar,\n :host-context(body.has-glass) ::-webkit-scrollbar-track,\n :host-context(body.has-glass) ::-webkit-scrollbar-thumb {\n background: transparent !important;\n width: 0 !important;\n }\n `;\n\n static properties = {\n viewMode: { type: String },\n isHovering: { type: Boolean },\n isAnimating: { type: Boolean },\n copyState: { type: String },\n elapsedTime: { type: String },\n captureStartTime: { type: Number },\n isSessionActive: { type: Boolean },\n hasCompletedRecording: { type: Boolean },\n };\n\n constructor() {\n super();\n this.isSessionActive = false;\n this.hasCompletedRecording = false;\n this.viewMode = 'insights';\n this.isHovering = false;\n this.isAnimating = false;\n this.elapsedTime = '00:00';\n this.captureStartTime = null;\n this.timerInterval = null;\n this.adjustHeightThrottle = null;\n this.isThrottled = false;\n this.copyState = 'idle';\n this.copyTimeout = null;\n\n this.adjustWindowHeight = this.adjustWindowHeight.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n // Only start timer if session is active\n if (this.isSessionActive) {\n this.startTimer();\n }\n if (window.api) {\n window.api.listenView.onSessionStateChanged((event, { isActive }) => {\n const wasActive = this.isSessionActive;\n this.isSessionActive = isActive;\n\n if (!wasActive && isActive) {\n this.hasCompletedRecording = false;\n this.startTimer();\n // Reset child components\n this.updateComplete.then(() => {\n const sttView = this.shadowRoot.querySelector('stt-view');\n const summaryView = this.shadowRoot.querySelector('summary-view');\n if (sttView) sttView.resetTranscript();\n if (summaryView) summaryView.resetAnalysis();\n });\n this.requestUpdate();\n }\n if (wasActive && !isActive) {\n this.hasCompletedRecording = true;\n this.stopTimer();\n this.requestUpdate();\n }\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.stopTimer();\n\n if (this.adjustHeightThrottle) {\n clearTimeout(this.adjustHeightThrottle);\n this.adjustHeightThrottle = null;\n }\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n }\n\n startTimer() {\n this.captureStartTime = Date.now();\n this.timerInterval = setInterval(() => {\n const elapsed = Math.floor((Date.now() - this.captureStartTime) / 1000);\n const minutes = Math.floor(elapsed / 60)\n .toString()\n .padStart(2, '0');\n const seconds = (elapsed % 60).toString().padStart(2, '0');\n this.elapsedTime = `${minutes}:${seconds}`;\n this.requestUpdate();\n }, 1000);\n }\n\n stopTimer() {\n if (this.timerInterval) {\n clearInterval(this.timerInterval);\n this.timerInterval = null;\n }\n }\n\n adjustWindowHeight() {\n if (!window.api) return;\n\n this.updateComplete\n .then(() => {\n const topBar = this.shadowRoot.querySelector('.top-bar');\n const activeContent = this.viewMode === 'transcript'\n ? this.shadowRoot.querySelector('stt-view')\n : this.shadowRoot.querySelector('summary-view');\n\n if (!topBar || !activeContent) return;\n\n const topBarHeight = topBar.offsetHeight;\n\n const contentHeight = activeContent.scrollHeight;\n\n const idealHeight = topBarHeight + contentHeight;\n\n const targetHeight = Math.min(700, idealHeight);\n\n console.log(\n `[Height Adjusted] Mode: ${this.viewMode}, TopBar: ${topBarHeight}px, Content: ${contentHeight}px, Ideal: ${idealHeight}px, Target: ${targetHeight}px`\n );\n\n window.api.listenView.adjustWindowHeight('listen', targetHeight);\n })\n .catch(error => {\n console.error('Error in adjustWindowHeight:', error);\n });\n }\n\n toggleViewMode() {\n this.viewMode = this.viewMode === 'insights' ? 'transcript' : 'insights';\n this.requestUpdate();\n }\n\n handleCopyHover(isHovering) {\n this.isHovering = isHovering;\n if (isHovering) {\n this.isAnimating = true;\n } else {\n this.isAnimating = false;\n }\n this.requestUpdate();\n }\n\n async handleCopy() {\n if (this.copyState === 'copied') return;\n\n let textToCopy = '';\n\n if (this.viewMode === 'transcript') {\n const sttView = this.shadowRoot.querySelector('stt-view');\n textToCopy = sttView ? sttView.getTranscriptText() : '';\n } else {\n const summaryView = this.shadowRoot.querySelector('summary-view');\n textToCopy = summaryView ? summaryView.getSummaryText() : '';\n }\n\n try {\n await navigator.clipboard.writeText(textToCopy);\n console.log('Content copied to clipboard');\n\n this.copyState = 'copied';\n this.requestUpdate();\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n this.copyTimeout = setTimeout(() => {\n this.copyState = 'idle';\n this.requestUpdate();\n }, 1500);\n } catch (err) {\n console.error('Failed to copy:', err);\n }\n }\n\n adjustWindowHeightThrottled() {\n if (this.isThrottled) {\n return;\n }\n\n this.adjustWindowHeight();\n\n this.isThrottled = true;\n\n this.adjustHeightThrottle = setTimeout(() => {\n this.isThrottled = false;\n }, 16);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n\n if (changedProperties.has('viewMode')) {\n this.adjustWindowHeight();\n }\n }\n\n handleSttMessagesUpdated(event) {\n // Handle messages update from SttView if needed\n this.adjustWindowHeightThrottled();\n }\n\n firstUpdated() {\n super.firstUpdated();\n setTimeout(() => this.adjustWindowHeight(), 200);\n }\n\n render() {\n const displayText = this.isHovering\n ? this.viewMode === 'transcript'\n ? 'Copy Transcript'\n : 'Copy Glass Analysis'\n : this.viewMode === 'insights'\n ? `Live insights`\n : `Glass is Listening ${this.elapsedTime}`;\n\n return html`\n
\n
\n
\n ${displayText}\n
\n
\n \n this.handleCopyHover(true)}\n @mouseleave=${() => this.handleCopyHover(false)}\n >\n \n \n \n \n \n \n \n \n
\n
\n\n \n\n \n
\n `;\n }\n}\n\ncustomElements.define('listen-view', ListenView);\n"], ["/glass/src/features/common/config/config.js", "// Configuration management for environment-based settings\nconst os = require('os');\nconst path = require('path');\nconst fs = require('fs');\n\nclass Config {\n constructor() {\n this.env = process.env.NODE_ENV || 'development';\n this.defaults = {\n apiUrl: process.env.pickleglass_API_URL || 'http://localhost:9001',\n apiTimeout: 10000,\n \n webUrl: process.env.pickleglass_WEB_URL || 'http://localhost:3000',\n \n enableJWT: false,\n fallbackToHeaderAuth: false,\n \n cacheTimeout: 5 * 60 * 1000,\n enableCaching: true,\n \n syncInterval: 0,\n healthCheckInterval: 30 * 1000,\n \n defaultWindowWidth: 400,\n defaultWindowHeight: 60,\n \n enableOfflineMode: true,\n enableFileBasedCommunication: false,\n enableSQLiteStorage: true,\n \n logLevel: 'info',\n enableDebugLogging: false\n };\n \n this.config = { ...this.defaults };\n this.loadEnvironmentConfig();\n this.loadUserConfig();\n }\n \n loadEnvironmentConfig() {\n if (process.env.pickleglass_API_URL) {\n this.config.apiUrl = process.env.pickleglass_API_URL;\n console.log(`[Config] API URL from env: ${this.config.apiUrl}`);\n }\n \n if (process.env.pickleglass_WEB_URL) {\n this.config.webUrl = process.env.pickleglass_WEB_URL;\n console.log(`[Config] Web URL from env: ${this.config.webUrl}`);\n }\n \n if (process.env.pickleglass_API_TIMEOUT) {\n this.config.apiTimeout = parseInt(process.env.pickleglass_API_TIMEOUT);\n }\n \n if (process.env.pickleglass_ENABLE_JWT) {\n this.config.enableJWT = process.env.pickleglass_ENABLE_JWT === 'true';\n }\n \n if (process.env.pickleglass_CACHE_TIMEOUT) {\n this.config.cacheTimeout = parseInt(process.env.pickleglass_CACHE_TIMEOUT);\n }\n \n if (process.env.pickleglass_LOG_LEVEL) {\n this.config.logLevel = process.env.pickleglass_LOG_LEVEL;\n }\n \n if (process.env.pickleglass_DEBUG) {\n this.config.enableDebugLogging = process.env.pickleglass_DEBUG === 'true';\n }\n \n if (this.env === 'production') {\n this.config.enableDebugLogging = false;\n this.config.logLevel = 'warn';\n } else if (this.env === 'development') {\n this.config.enableDebugLogging = true;\n this.config.logLevel = 'debug';\n }\n }\n \n loadUserConfig() {\n try {\n const userConfigPath = this.getUserConfigPath();\n if (fs.existsSync(userConfigPath)) {\n const userConfig = JSON.parse(fs.readFileSync(userConfigPath, 'utf-8'));\n this.config = { ...this.config, ...userConfig };\n console.log('[Config] User config loaded from:', userConfigPath);\n }\n } catch (error) {\n console.warn('[Config] Failed to load user config:', error.message);\n }\n }\n \n getUserConfigPath() {\n const configDir = path.join(os.homedir(), '.pickleglass');\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true });\n }\n return path.join(configDir, 'config.json');\n }\n \n get(key) {\n return this.config[key];\n }\n \n set(key, value) {\n this.config[key] = value;\n }\n \n getAll() {\n return { ...this.config };\n }\n \n saveUserConfig() {\n try {\n const userConfigPath = this.getUserConfigPath();\n const userConfig = { ...this.config };\n \n Object.keys(this.defaults).forEach(key => {\n if (userConfig[key] === this.defaults[key]) {\n delete userConfig[key];\n }\n });\n \n fs.writeFileSync(userConfigPath, JSON.stringify(userConfig, null, 2));\n console.log('[Config] User config saved to:', userConfigPath);\n } catch (error) {\n console.error('[Config] Failed to save user config:', error);\n }\n }\n \n reset() {\n this.config = { ...this.defaults };\n this.loadEnvironmentConfig();\n }\n \n isDevelopment() {\n return this.env === 'development';\n }\n \n isProduction() {\n return this.env === 'production';\n }\n \n shouldLog(level) {\n const levels = ['debug', 'info', 'warn', 'error'];\n const currentLevelIndex = levels.indexOf(this.config.logLevel);\n const requestedLevelIndex = levels.indexOf(level);\n return requestedLevelIndex >= currentLevelIndex;\n }\n}\n\nconst config = new Config();\n\nmodule.exports = config;"], ["/glass/src/ui/app/WelcomeHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class WelcomeHeader extends LitElement {\n static styles = css`\n :host {\n display: block;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n sans-serif;\n }\n .container {\n width: 100%;\n box-sizing: border-box;\n height: auto;\n padding: 24px 16px;\n background: rgba(0, 0, 0, 0.64);\n box-shadow: 0px 0px 0px 1.5px rgba(255, 255, 255, 0.64) inset;\n border-radius: 16px;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 32px;\n display: inline-flex;\n -webkit-app-region: drag;\n }\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 16px;\n right: 16px;\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 5px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 16px;\n line-height: 1;\n padding: 0;\n }\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n .header-section {\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 4px;\n display: flex;\n }\n .title {\n color: white;\n font-size: 18px;\n font-weight: 700;\n }\n .subtitle {\n color: white;\n font-size: 14px;\n font-weight: 500;\n }\n .option-card {\n width: 100%;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 8px;\n display: inline-flex;\n }\n .divider {\n width: 1px;\n align-self: stretch;\n position: relative;\n background: #bebebe;\n border-radius: 2px;\n }\n .option-content {\n flex: 1 1 0;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 8px;\n display: inline-flex;\n min-width: 0;\n }\n .option-title {\n color: white;\n font-size: 14px;\n font-weight: 700;\n }\n .option-description {\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 400;\n line-height: 18px;\n letter-spacing: 0.12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .action-button {\n -webkit-app-region: no-drag;\n padding: 8px 10px;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.16);\n border-radius: 16px;\n border: 1px solid rgba(255, 255, 255, 0.5);\n justify-content: center;\n align-items: center;\n gap: 6px;\n display: flex;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n .action-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .button-text {\n color: white;\n font-size: 12px;\n font-weight: 600;\n }\n .button-icon {\n width: 12px;\n height: 12px;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .arrow-icon {\n border: solid white;\n border-width: 0 1.2px 1.2px 0;\n display: inline-block;\n padding: 3px;\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n .footer {\n align-self: stretch;\n text-align: center;\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 500;\n line-height: 19.2px;\n }\n .footer-link {\n text-decoration: underline;\n cursor: pointer;\n -webkit-app-region: no-drag;\n }\n `;\n\n static properties = {\n loginCallback: { type: Function },\n apiKeyCallback: { type: Function },\n };\n\n constructor() {\n super();\n this.loginCallback = () => {};\n this.apiKeyCallback = () => {};\n this.handleClose = this.handleClose.bind(this);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.dispatchEvent(new CustomEvent('content-changed', { bubbles: true, composed: true }));\n }\n\n handleClose() {\n if (window.api?.common) {\n window.api.common.quitApplication();\n }\n }\n\n render() {\n return html`\n
\n \n
\n
Welcome to Glass
\n
Choose how to connect your AI model
\n
\n
\n
\n
\n
Quick start with default API key
\n
\n 100% free with Pickle's OpenAI key
No personal data collected
Sign up with Google in seconds\n
\n
\n \n
\n
\n
\n
\n
Use Personal API keys
\n
\n Costs may apply based on your API usage
No personal data collected
Use your own API keys (OpenAI, Gemini, etc.)\n
\n
\n \n
\n
\n Glass does not collect your personal data —\n See details\n
\n
\n `;\n }\n\n openPrivacyPolicy() {\n console.log('🔊 openPrivacyPolicy WelcomeHeader');\n if (window.api?.common) {\n window.api.common.openExternal('https://pickle.com/privacy-policy');\n }\n }\n}\n\ncustomElements.define('welcome-header', WelcomeHeader);"], ["/glass/src/features/common/repositories/user/firebase.repository.js", "const { doc, getDoc, setDoc, deleteDoc, writeBatch, query, where, getDocs, collection, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst userConverter = createEncryptedConverter([]);\n\nfunction usersCol() {\n const db = getFirestoreInstance();\n return collection(db, 'users').withConverter(userConverter);\n}\n\n// These functions are mostly correct as they already operate on a top-level collection.\n// We just need to ensure the signatures are consistent.\n\nasync function findOrCreate(user) {\n if (!user || !user.uid) throw new Error('User object and uid are required');\n const { uid, displayName, email } = user;\n const now = Timestamp.now();\n const docRef = doc(usersCol(), uid);\n const docSnap = await getDoc(docRef);\n\n if (docSnap.exists()) {\n await setDoc(docRef, { \n display_name: displayName || docSnap.data().display_name || 'User',\n email: email || docSnap.data().email || 'no-email@example.com'\n }, { merge: true });\n } else {\n await setDoc(docRef, { uid, display_name: displayName || 'User', email: email || 'no-email@example.com', created_at: now });\n }\n const finalDoc = await getDoc(docRef);\n return finalDoc.data();\n}\n\nasync function getById(uid) {\n const docRef = doc(usersCol(), uid);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\n\n\nasync function update({ uid, displayName }) {\n const docRef = doc(usersCol(), uid);\n await setDoc(docRef, { display_name: displayName }, { merge: true });\n return { changes: 1 };\n}\n\nasync function deleteById(uid) {\n const db = getFirestoreInstance();\n const batch = writeBatch(db);\n\n // 1. Delete all sessions owned by the user\n const sessionsQuery = query(collection(db, 'sessions'), where('uid', '==', uid));\n const sessionsSnapshot = await getDocs(sessionsQuery);\n \n for (const sessionDoc of sessionsSnapshot.docs) {\n // Recursively delete sub-collections\n const subcollectionsToDelete = ['transcripts', 'ai_messages', 'summary'];\n for (const sub of subcollectionsToDelete) {\n const subColPath = `sessions/${sessionDoc.id}/${sub}`;\n const subSnapshot = await getDocs(query(collection(db, subColPath)));\n subSnapshot.forEach(d => batch.delete(d.ref));\n }\n batch.delete(sessionDoc.ref);\n }\n\n // 2. Delete all presets owned by the user\n const presetsQuery = query(collection(db, 'prompt_presets'), where('uid', '==', uid));\n const presetsSnapshot = await getDocs(presetsQuery);\n presetsSnapshot.forEach(doc => batch.delete(doc.ref));\n\n // 3. Delete the user document itself\n const userRef = doc(usersCol(), uid);\n batch.delete(userRef);\n\n await batch.commit();\n return { success: true };\n}\n\nmodule.exports = {\n findOrCreate,\n getById,\n update,\n deleteById,\n}; "], ["/glass/src/features/common/repositories/preset/firebase.repository.js", "const { collection, doc, addDoc, getDoc, getDocs, updateDoc, deleteDoc, query, where, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst userPresetConverter = createEncryptedConverter(['prompt', 'title']);\n\nconst defaultPresetConverter = {\n toFirestore: (data) => data,\n fromFirestore: (snapshot, options) => {\n const data = snapshot.data(options);\n return { ...data, id: snapshot.id };\n }\n};\n\nfunction userPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'prompt_presets').withConverter(userPresetConverter);\n}\n\nfunction defaultPresetsCol() {\n const db = getFirestoreInstance();\n // Path must have an odd number of segments. 'v1' is a placeholder document.\n return collection(db, 'defaults/v1/prompt_presets').withConverter(defaultPresetConverter);\n}\n\nasync function getPresets(uid) {\n const userPresetsQuery = query(userPresetsCol(), where('uid', '==', uid));\n const defaultPresetsQuery = query(defaultPresetsCol()); // Defaults have no owner\n\n const [userSnapshot, defaultSnapshot] = await Promise.all([\n getDocs(userPresetsQuery),\n getDocs(defaultPresetsQuery)\n ]);\n\n const presets = [\n ...defaultSnapshot.docs.map(d => d.data()),\n ...userSnapshot.docs.map(d => d.data())\n ];\n\n return presets.sort((a, b) => {\n if (a.is_default && !b.is_default) return -1;\n if (!a.is_default && b.is_default) return 1;\n return a.title.localeCompare(b.title);\n });\n}\n\nasync function getPresetTemplates() {\n const q = query(defaultPresetsCol(), orderBy('title', 'asc'));\n const snapshot = await getDocs(q);\n return snapshot.docs.map(doc => doc.data());\n}\n\nasync function create({ uid, title, prompt }) {\n const now = Timestamp.now();\n const newPreset = {\n uid: uid,\n title,\n prompt,\n is_default: 0,\n created_at: now,\n };\n const docRef = await addDoc(userPresetsCol(), newPreset);\n return { id: docRef.id };\n}\n\nasync function update(id, { title, prompt }, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to update.\");\n }\n\n // Encrypt sensitive fields before sending to Firestore because `updateDoc` bypasses converters.\n const updates = {};\n if (title !== undefined) {\n updates.title = encryptionService.encrypt(title);\n }\n if (prompt !== undefined) {\n updates.prompt = encryptionService.encrypt(prompt);\n }\n updates.updated_at = Timestamp.now();\n\n await updateDoc(docRef, updates);\n return { changes: 1 };\n}\n\nasync function del(id, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to delete.\");\n }\n\n await deleteDoc(docRef);\n return { changes: 1 };\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n create,\n update,\n delete: del,\n}; "], ["/glass/src/features/common/repositories/permission/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction markKeychainCompleted(uid) {\n return sqliteClient.query(\n 'INSERT OR REPLACE INTO permissions (uid, keychain_completed) VALUES (?, 1)',\n [uid]\n );\n}\n\nfunction checkKeychainCompleted(uid) {\n const row = sqliteClient.query('SELECT keychain_completed FROM permissions WHERE uid = ?', [uid]);\n return row.length > 0 && row[0].keychain_completed === 1;\n}\n\nmodule.exports = {\n markKeychainCompleted,\n checkKeychainCompleted\n}; "], ["/glass/src/features/ask/repositories/firebase.repository.js", "const { collection, addDoc, query, getDocs, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../common/repositories/firestoreConverter');\n\nconst aiMessageConverter = createEncryptedConverter(['content']);\n\nfunction aiMessagesCol(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access AI messages.\");\n const db = getFirestoreInstance();\n return collection(db, `sessions/${sessionId}/ai_messages`).withConverter(aiMessageConverter);\n}\n\nasync function addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n const now = Timestamp.now();\n const newMessage = {\n uid, // To identify the author of the message\n session_id: sessionId,\n sent_at: now,\n role,\n content,\n model,\n created_at: now,\n };\n \n const docRef = await addDoc(aiMessagesCol(sessionId), newMessage);\n return { id: docRef.id };\n}\n\nasync function getAllAiMessagesBySessionId(sessionId) {\n const q = query(aiMessagesCol(sessionId), orderBy('sent_at', 'asc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nmodule.exports = {\n addAiMessage,\n getAllAiMessagesBySessionId,\n}; "], ["/glass/src/features/common/services/firebaseClient.js", "const { initializeApp } = require('firebase/app');\nconst { initializeAuth } = require('firebase/auth');\nconst Store = require('electron-store');\nconst { getFirestore, setLogLevel } = require('firebase/firestore');\n\n// setLogLevel('debug');\n\n/**\n * Firebase Auth expects the `persistence` option passed to `initializeAuth()` to be *classes*,\n * not instances. It then calls `new PersistenceClass()` internally. \n *\n * The helper below returns such a class, pre-configured with an `electron-store` instance that\n * will be shared across all constructed objects. This mirrors the pattern used by Firebase's own\n * `browserLocalPersistence` implementation as well as community solutions for NodeJS.\n */\nfunction createElectronStorePersistence(storeName = 'firebase-auth-session') {\n // Create a single `electron-store` behind the scenes – all Persistence instances will use it.\n const sharedStore = new Store({ name: storeName });\n\n return class ElectronStorePersistence {\n constructor() {\n this.store = sharedStore;\n this.type = 'LOCAL';\n }\n\n /**\n * Firebase calls this to check whether the persistence is usable in the current context.\n */\n _isAvailable() {\n return Promise.resolve(true);\n }\n\n async _set(key, value) {\n this.store.set(key, value);\n }\n\n async _get(key) {\n return this.store.get(key) ?? null;\n }\n\n async _remove(key) {\n this.store.delete(key);\n }\n\n /**\n * These are used by Firebase to react to external storage events (e.g. multi-tab).\n * Electron apps are single-renderer per process, so we can safely provide no-op\n * implementations.\n */\n _addListener(_key, _listener) {\n // no-op\n }\n\n _removeListener(_key, _listener) {\n // no-op\n }\n };\n}\n\nconst firebaseConfig = {\n apiKey: 'AIzaSyAgtJrmsFWG1C7m9S55HyT1laICEzuUS2g',\n authDomain: 'pickle-3651a.firebaseapp.com',\n projectId: 'pickle-3651a',\n storageBucket: 'pickle-3651a.firebasestorage.app',\n messagingSenderId: '904706892885',\n appId: '1:904706892885:web:0e42b3dda796674ead20dc',\n measurementId: 'G-SQ0WM6S28T',\n};\n\nlet firebaseApp = null;\nlet firebaseAuth = null;\nlet firestoreInstance = null; // To hold the specific DB instance\n\nfunction initializeFirebase() {\n if (firebaseApp) {\n console.log('[FirebaseClient] Firebase already initialized.');\n return;\n }\n try {\n firebaseApp = initializeApp(firebaseConfig);\n \n // Build a *class* persistence provider and hand it to Firebase.\n const ElectronStorePersistence = createElectronStorePersistence('firebase-auth-session');\n\n firebaseAuth = initializeAuth(firebaseApp, {\n // `initializeAuth` accepts a single class or an array – we pass an array for future\n // extensibility and to match Firebase examples.\n persistence: [ElectronStorePersistence],\n });\n\n // Initialize Firestore with the specific database ID\n firestoreInstance = getFirestore(firebaseApp, 'pickle-glass');\n\n console.log('[FirebaseClient] Firebase initialized successfully with class-based electron-store persistence.');\n console.log('[FirebaseClient] Firestore instance is targeting the \"pickle-glass\" database.');\n } catch (error) {\n console.error('[FirebaseClient] Firebase initialization failed:', error);\n }\n}\n\nfunction getFirebaseAuth() {\n if (!firebaseAuth) {\n throw new Error(\"Firebase Auth has not been initialized. Call initializeFirebase() first.\");\n }\n return firebaseAuth;\n}\n\nfunction getFirestoreInstance() {\n if (!firestoreInstance) {\n throw new Error(\"Firestore has not been initialized. Call initializeFirebase() first.\");\n }\n return firestoreInstance;\n}\n\nmodule.exports = {\n initializeFirebase,\n getFirebaseAuth,\n getFirestoreInstance,\n}; "], ["/glass/src/features/common/services/permissionService.js", "const { systemPreferences, shell, desktopCapturer } = require('electron');\nconst permissionRepository = require('../repositories/permission');\n\nclass PermissionService {\n _getAuthService() {\n return require('./authService');\n }\n\n async checkSystemPermissions() {\n const permissions = {\n microphone: 'unknown',\n screen: 'unknown',\n keychain: 'unknown',\n needsSetup: true\n };\n\n try {\n if (process.platform === 'darwin') {\n permissions.microphone = systemPreferences.getMediaAccessStatus('microphone');\n permissions.screen = systemPreferences.getMediaAccessStatus('screen');\n permissions.keychain = await this.checkKeychainCompleted(this._getAuthService().getCurrentUserId()) ? 'granted' : 'unknown';\n permissions.needsSetup = permissions.microphone !== 'granted' || permissions.screen !== 'granted' || permissions.keychain !== 'granted';\n } else {\n permissions.microphone = 'granted';\n permissions.screen = 'granted';\n permissions.keychain = 'granted';\n permissions.needsSetup = false;\n }\n\n console.log('[Permissions] System permissions status:', permissions);\n return permissions;\n } catch (error) {\n console.error('[Permissions] Error checking permissions:', error);\n return {\n microphone: 'unknown',\n screen: 'unknown',\n keychain: 'unknown',\n needsSetup: true,\n error: error.message\n };\n }\n }\n\n async requestMicrophonePermission() {\n if (process.platform !== 'darwin') {\n return { success: true };\n }\n\n try {\n const status = systemPreferences.getMediaAccessStatus('microphone');\n console.log('[Permissions] Microphone status:', status);\n if (status === 'granted') {\n return { success: true, status: 'granted' };\n }\n\n const granted = await systemPreferences.askForMediaAccess('microphone');\n return {\n success: granted,\n status: granted ? 'granted' : 'denied'\n };\n } catch (error) {\n console.error('[Permissions] Error requesting microphone permission:', error);\n return {\n success: false,\n error: error.message\n };\n }\n }\n\n async openSystemPreferences(section) {\n if (process.platform !== 'darwin') {\n return { success: false, error: 'Not supported on this platform' };\n }\n\n try {\n if (section === 'screen-recording') {\n try {\n console.log('[Permissions] Triggering screen capture request to register app...');\n await desktopCapturer.getSources({\n types: ['screen'],\n thumbnailSize: { width: 1, height: 1 }\n });\n console.log('[Permissions] App registered for screen recording');\n } catch (captureError) {\n console.log('[Permissions] Screen capture request triggered (expected to fail):', captureError.message);\n }\n \n // await shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture');\n }\n return { success: true };\n } catch (error) {\n console.error('[Permissions] Error opening system preferences:', error);\n return { success: false, error: error.message };\n }\n }\n\n async markKeychainCompleted() {\n try {\n await permissionRepository.markKeychainCompleted(this._getAuthService().getCurrentUserId());\n console.log('[Permissions] Marked keychain as completed');\n return { success: true };\n } catch (error) {\n console.error('[Permissions] Error marking keychain as completed:', error);\n return { success: false, error: error.message };\n }\n }\n\n async checkKeychainCompleted(uid) {\n if (uid === \"default_user\") {\n return true;\n }\n try {\n const completed = permissionRepository.checkKeychainCompleted(uid);\n console.log('[Permissions] Keychain completed status:', completed);\n return completed;\n } catch (error) {\n console.error('[Permissions] Error checking keychain completed status:', error);\n return false;\n }\n }\n}\n\nconst permissionService = new PermissionService();\nmodule.exports = permissionService; "], ["/glass/src/features/listen/stt/repositories/firebase.repository.js", "const { collection, addDoc, query, getDocs, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../../common/repositories/firestoreConverter');\n\nconst transcriptConverter = createEncryptedConverter(['text']);\n\nfunction transcriptsCol(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access transcripts.\");\n const db = getFirestoreInstance();\n return collection(db, `sessions/${sessionId}/transcripts`).withConverter(transcriptConverter);\n}\n\nasync function addTranscript({ uid, sessionId, speaker, text }) {\n const now = Timestamp.now();\n const newTranscript = {\n uid, // To identify the author/source of the transcript\n session_id: sessionId,\n start_at: now,\n speaker,\n text,\n created_at: now,\n };\n const docRef = await addDoc(transcriptsCol(sessionId), newTranscript);\n return { id: docRef.id };\n}\n\nasync function getAllTranscriptsBySessionId(sessionId) {\n const q = query(transcriptsCol(sessionId), orderBy('start_at', 'asc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nmodule.exports = {\n addTranscript,\n getAllTranscriptsBySessionId,\n}; "], ["/glass/src/features/listen/summary/repositories/firebase.repository.js", "const { collection, doc, setDoc, getDoc, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../../common/repositories/firestoreConverter');\nconst encryptionService = require('../../../common/services/encryptionService');\n\nconst fieldsToEncrypt = ['tldr', 'text', 'bullet_json', 'action_json'];\nconst summaryConverter = createEncryptedConverter(fieldsToEncrypt);\n\nfunction summaryDocRef(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access summary.\");\n const db = getFirestoreInstance();\n // Reverting to the original structure with 'data' as the document ID.\n const docPath = `sessions/${sessionId}/summary/data`;\n return doc(db, docPath).withConverter(summaryConverter);\n}\n\nasync function saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model = 'unknown' }) {\n const now = Timestamp.now();\n const summaryData = {\n uid, // To know who generated the summary\n session_id: sessionId,\n generated_at: now,\n model,\n text,\n tldr,\n bullet_json,\n action_json,\n updated_at: now,\n };\n \n // The converter attached to summaryDocRef will handle encryption via its `toFirestore` method.\n // Manual encryption was removed to fix the double-encryption bug.\n const docRef = summaryDocRef(sessionId);\n await setDoc(docRef, summaryData, { merge: true });\n\n return { changes: 1 };\n}\n\nasync function getSummaryBySessionId(sessionId) {\n const docRef = summaryDocRef(sessionId);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\nmodule.exports = {\n saveSummary,\n getSummaryBySessionId,\n}; "], ["/glass/src/window/windowLayoutManager.js", "const { screen } = require('electron');\n\n/**\n * \n * @param {BrowserWindow} window \n * @returns {Display}\n */\nfunction getCurrentDisplay(window) {\n if (!window || window.isDestroyed()) return screen.getPrimaryDisplay();\n\n const windowBounds = window.getBounds();\n const windowCenter = {\n x: windowBounds.x + windowBounds.width / 2,\n y: windowBounds.y + windowBounds.height / 2,\n };\n\n return screen.getDisplayNearestPoint(windowCenter);\n}\n\nclass WindowLayoutManager {\n /**\n * @param {Map} windowPool - 관리할 창들의 맵\n */\n constructor(windowPool) {\n this.windowPool = windowPool;\n this.isUpdating = false;\n this.PADDING = 80;\n }\n\n getHeaderPosition = () => {\n const header = this.windowPool.get('header');\n if (header) {\n const [x, y] = header.getPosition();\n return { x, y };\n }\n return { x: 0, y: 0 };\n };\n\n\n /**\n * \n * @returns {{name: string, primary: string, secondary: string}}\n */\n determineLayoutStrategy(headerBounds, screenWidth, screenHeight, relativeX, relativeY, workAreaX, workAreaY) {\n const headerRelX = headerBounds.x - workAreaX;\n const headerRelY = headerBounds.y - workAreaY;\n\n const spaceBelow = screenHeight - (headerRelY + headerBounds.height);\n const spaceAbove = headerRelY;\n const spaceLeft = headerRelX;\n const spaceRight = screenWidth - (headerRelX + headerBounds.width);\n\n if (spaceBelow >= 400) {\n return { name: 'below', primary: 'below', secondary: relativeX < 0.5 ? 'right' : 'left' };\n } else if (spaceAbove >= 400) {\n return { name: 'above', primary: 'above', secondary: relativeX < 0.5 ? 'right' : 'left' };\n } else if (relativeX < 0.3 && spaceRight >= 800) {\n return { name: 'right-side', primary: 'right', secondary: spaceBelow > spaceAbove ? 'below' : 'above' };\n } else if (relativeX > 0.7 && spaceLeft >= 800) {\n return { name: 'left-side', primary: 'left', secondary: spaceBelow > spaceAbove ? 'below' : 'above' };\n } else {\n return { name: 'adaptive', primary: spaceBelow > spaceAbove ? 'below' : 'above', secondary: spaceRight > spaceLeft ? 'right' : 'left' };\n }\n }\n\n\n\n /**\n * @returns {{x: number, y: number} | null}\n */\n calculateSettingsWindowPosition() {\n const header = this.windowPool.get('header');\n const settings = this.windowPool.get('settings');\n\n if (!header || header.isDestroyed() || !settings || settings.isDestroyed()) {\n return null;\n }\n\n const headerBounds = header.getBounds();\n const settingsBounds = settings.getBounds();\n const display = getCurrentDisplay(header);\n const { x: workAreaX, y: workAreaY, width: screenWidth, height: screenHeight } = display.workArea;\n\n const PAD = 5;\n const buttonPadding = 170;\n\n const x = headerBounds.x + headerBounds.width - settingsBounds.width + buttonPadding;\n const y = headerBounds.y + headerBounds.height + PAD;\n\n const clampedX = Math.max(workAreaX + 10, Math.min(workAreaX + screenWidth - settingsBounds.width - 10, x));\n const clampedY = Math.max(workAreaY + 10, Math.min(workAreaY + screenHeight - settingsBounds.height - 10, y));\n\n return { x: Math.round(clampedX), y: Math.round(clampedY) };\n }\n\n\n calculateHeaderResize(header, { width, height }) {\n if (!header) return null;\n const currentBounds = header.getBounds();\n const centerX = currentBounds.x + currentBounds.width / 2;\n const newX = Math.round(centerX - width / 2);\n const display = getCurrentDisplay(header);\n const { x: workAreaX, width: workAreaWidth } = display.workArea;\n const clampedX = Math.max(workAreaX, Math.min(workAreaX + workAreaWidth - width, newX));\n return { x: clampedX, y: currentBounds.y, width, height };\n }\n \n calculateClampedPosition(header, { x: newX, y: newY }) {\n if (!header) return null;\n const targetDisplay = screen.getDisplayNearestPoint({ x: newX, y: newY });\n const { x: workAreaX, y: workAreaY, width, height } = targetDisplay.workArea;\n const headerBounds = header.getBounds();\n const clampedX = Math.max(workAreaX, Math.min(newX, workAreaX + width - headerBounds.width));\n const clampedY = Math.max(workAreaY, Math.min(newY, workAreaY + height - headerBounds.height));\n return { x: clampedX, y: clampedY };\n }\n \n calculateWindowHeightAdjustment(senderWindow, targetHeight) {\n if (!senderWindow) return null;\n const currentBounds = senderWindow.getBounds();\n const minHeight = senderWindow.getMinimumSize()[1];\n const maxHeight = senderWindow.getMaximumSize()[1];\n let adjustedHeight = Math.max(minHeight, targetHeight);\n if (maxHeight > 0) {\n adjustedHeight = Math.min(maxHeight, adjustedHeight);\n }\n console.log(`[Layout Debug] calculateWindowHeightAdjustment: targetHeight=${targetHeight}`);\n return { ...currentBounds, height: adjustedHeight };\n }\n \n // 기존 getTargetBoundsForFeatureWindows를 이 함수로 대체합니다.\n calculateFeatureWindowLayout(visibility, headerBoundsOverride = null) {\n const header = this.windowPool.get('header');\n const headerBounds = headerBoundsOverride || (header ? header.getBounds() : null);\n\n if (!headerBounds) return {};\n\n let display;\n if (headerBoundsOverride) {\n const boundsCenter = {\n x: headerBounds.x + headerBounds.width / 2,\n y: headerBounds.y + headerBounds.height / 2,\n };\n display = screen.getDisplayNearestPoint(boundsCenter);\n } else {\n display = getCurrentDisplay(header);\n }\n \n const { width: screenWidth, height: screenHeight, x: workAreaX, y: workAreaY } = display.workArea;\n \n const ask = this.windowPool.get('ask');\n const listen = this.windowPool.get('listen');\n \n const askVis = visibility.ask && ask && !ask.isDestroyed();\n const listenVis = visibility.listen && listen && !listen.isDestroyed();\n \n if (!askVis && !listenVis) return {};\n \n const PAD = 8;\n const headerTopRel = headerBounds.y - workAreaY;\n const headerBottomRel = headerTopRel + headerBounds.height;\n const headerCenterXRel = headerBounds.x - workAreaX + headerBounds.width / 2;\n \n const relativeX = headerCenterXRel / screenWidth;\n const relativeY = (headerBounds.y - workAreaY) / screenHeight;\n const strategy = this.determineLayoutStrategy(headerBounds, screenWidth, screenHeight, relativeX, relativeY, workAreaX, workAreaY);\n \n const askB = askVis ? ask.getBounds() : null;\n const listenB = listenVis ? listen.getBounds() : null;\n\n if (askVis) {\n console.log(`[Layout Debug] Ask Window Bounds: height=${askB.height}, width=${askB.width}`);\n }\n if (listenVis) {\n console.log(`[Layout Debug] Listen Window Bounds: height=${listenB.height}, width=${listenB.width}`);\n }\n \n const layout = {};\n \n if (askVis && listenVis) {\n let askXRel = headerCenterXRel - (askB.width / 2);\n let listenXRel = askXRel - listenB.width - PAD;\n \n if (listenXRel < PAD) {\n listenXRel = PAD;\n askXRel = listenXRel + listenB.width + PAD;\n }\n if (askXRel + askB.width > screenWidth - PAD) {\n askXRel = screenWidth - PAD - askB.width;\n listenXRel = askXRel - listenB.width - PAD;\n }\n \n if (strategy.primary === 'above') {\n const windowBottomAbs = headerBounds.y - PAD;\n layout.ask = { x: Math.round(askXRel + workAreaX), y: Math.round(windowBottomAbs - askB.height), width: askB.width, height: askB.height };\n layout.listen = { x: Math.round(listenXRel + workAreaX), y: Math.round(windowBottomAbs - listenB.height), width: listenB.width, height: listenB.height };\n } else { // 'below'\n const yAbs = headerBounds.y + headerBounds.height + PAD;\n layout.ask = { x: Math.round(askXRel + workAreaX), y: Math.round(yAbs), width: askB.width, height: askB.height };\n layout.listen = { x: Math.round(listenXRel + workAreaX), y: Math.round(yAbs), width: listenB.width, height: listenB.height };\n }\n } else { // Single window\n const winName = askVis ? 'ask' : 'listen';\n const winB = askVis ? askB : listenB;\n if (!winB) return {};\n \n let xRel = headerCenterXRel - winB.width / 2;\n xRel = Math.max(PAD, Math.min(screenWidth - winB.width - PAD, xRel));\n \n let yPos;\n if (strategy.primary === 'above') {\n yPos = (headerBounds.y - workAreaY) - PAD - winB.height;\n } else { // 'below'\n yPos = (headerBounds.y - workAreaY) + headerBounds.height + PAD;\n }\n \n layout[winName] = { x: Math.round(xRel + workAreaX), y: Math.round(yPos + workAreaY), width: winB.width, height: winB.height };\n }\n return layout;\n }\n \n calculateShortcutSettingsWindowPosition() {\n const header = this.windowPool.get('header');\n const shortcutSettings = this.windowPool.get('shortcut-settings');\n if (!header || !shortcutSettings) return null;\n \n const headerBounds = header.getBounds();\n const shortcutBounds = shortcutSettings.getBounds();\n const { workArea } = getCurrentDisplay(header);\n \n let newX = Math.round(headerBounds.x + (headerBounds.width / 2) - (shortcutBounds.width / 2));\n let newY = Math.round(headerBounds.y);\n \n newX = Math.max(workArea.x, Math.min(newX, workArea.x + workArea.width - shortcutBounds.width));\n newY = Math.max(workArea.y, Math.min(newY, workArea.y + workArea.height - shortcutBounds.height));\n \n return { x: newX, y: newY, width: shortcutBounds.width, height: shortcutBounds.height };\n }\n\n calculateStepMovePosition(header, direction) {\n if (!header) return null;\n const currentBounds = header.getBounds();\n const stepSize = 80; // 이동 간격\n let targetX = currentBounds.x;\n let targetY = currentBounds.y;\n \n switch (direction) {\n case 'left': targetX -= stepSize; break;\n case 'right': targetX += stepSize; break;\n case 'up': targetY -= stepSize; break;\n case 'down': targetY += stepSize; break;\n }\n \n return this.calculateClampedPosition(header, { x: targetX, y: targetY });\n }\n \n calculateEdgePosition(header, direction) {\n if (!header) return null;\n const display = getCurrentDisplay(header);\n const { workArea } = display;\n const currentBounds = header.getBounds();\n \n let targetX = currentBounds.x;\n let targetY = currentBounds.y;\n \n switch (direction) {\n case 'left': targetX = workArea.x; break;\n case 'right': targetX = workArea.x + workArea.width - currentBounds.width; break;\n case 'up': targetY = workArea.y; break;\n case 'down': targetY = workArea.y + workArea.height - currentBounds.height; break;\n }\n return { x: targetX, y: targetY };\n }\n \n calculateNewPositionForDisplay(window, targetDisplayId) {\n if (!window) return null;\n \n const targetDisplay = screen.getAllDisplays().find(d => d.id === targetDisplayId);\n if (!targetDisplay) return null;\n \n const currentBounds = window.getBounds();\n const currentDisplay = getCurrentDisplay(window);\n \n if (currentDisplay.id === targetDisplay.id) return { x: currentBounds.x, y: currentBounds.y };\n \n const relativeX = (currentBounds.x - currentDisplay.workArea.x) / currentDisplay.workArea.width;\n const relativeY = (currentBounds.y - currentDisplay.workArea.y) / currentDisplay.workArea.height;\n \n const targetX = targetDisplay.workArea.x + targetDisplay.workArea.width * relativeX;\n const targetY = targetDisplay.workArea.y + targetDisplay.workArea.height * relativeY;\n \n const clampedX = Math.max(targetDisplay.workArea.x, Math.min(targetX, targetDisplay.workArea.x + targetDisplay.workArea.width - currentBounds.width));\n const clampedY = Math.max(targetDisplay.workArea.y, Math.min(targetY, targetDisplay.workArea.y + targetDisplay.workArea.height - currentBounds.height));\n \n return { x: Math.round(clampedX), y: Math.round(clampedY) };\n }\n \n /**\n * @param {Rectangle} bounds1\n * @param {Rectangle} bounds2\n * @returns {boolean}\n */\n boundsOverlap(bounds1, bounds2) {\n const margin = 10;\n return !(\n bounds1.x + bounds1.width + margin < bounds2.x ||\n bounds2.x + bounds2.width + margin < bounds1.x ||\n bounds1.y + bounds1.height + margin < bounds2.y ||\n bounds2.y + bounds2.height + margin < bounds1.y\n );\n }\n}\n\nmodule.exports = WindowLayoutManager;"], ["/glass/src/window/smoothMovementManager.js", "const { screen } = require('electron');\n\nclass SmoothMovementManager {\n constructor(windowPool) {\n this.windowPool = windowPool;\n this.stepSize = 80;\n this.animationDuration = 300;\n this.headerPosition = { x: 0, y: 0 };\n this.isAnimating = false;\n this.hiddenPosition = null;\n this.lastVisiblePosition = null;\n this.currentDisplayId = null;\n this.animationFrameId = null;\n\n this.animationTimers = new Map();\n }\n\n /**\n * @param {BrowserWindow} win\n * @returns {boolean}\n */\n _isWindowValid(win) {\n if (!win || win.isDestroyed()) {\n // 해당 창의 타이머가 있으면 정리\n if (this.animationTimers.has(win)) {\n clearTimeout(this.animationTimers.get(win));\n this.animationTimers.delete(win);\n }\n return false;\n }\n return true;\n }\n\n /**\n * \n * @param {BrowserWindow} win\n * @param {number} targetX\n * @param {number} targetY\n * @param {object} [options]\n * @param {object} [options.sizeOverride]\n * @param {function} [options.onComplete]\n * @param {number} [options.duration]\n */\n animateWindow(win, targetX, targetY, options = {}) {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n\n const { sizeOverride, onComplete, duration: animDuration } = options;\n const start = win.getBounds();\n const startTime = Date.now();\n const duration = animDuration || this.animationDuration;\n const { width, height } = sizeOverride || start;\n\n const step = () => {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete();\n return;\n }\n\n const p = Math.min((Date.now() - startTime) / duration, 1);\n const eased = 1 - Math.pow(1 - p, 3); // ease-out-cubic\n const x = start.x + (targetX - start.x) * eased;\n const y = start.y + (targetY - start.y) * eased;\n\n win.setBounds({ x: Math.round(x), y: Math.round(y), width, height });\n\n if (p < 1) {\n setTimeout(step, 8);\n } else {\n this.layoutManager.updateLayout();\n if (onComplete) {\n onComplete();\n }\n }\n };\n step();\n }\n\n fade(win, { from, to, duration = 250, onComplete }) {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete();\n return;\n }\n const startOpacity = from ?? win.getOpacity();\n const startTime = Date.now();\n \n const step = () => {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete(); return;\n }\n const progress = Math.min(1, (Date.now() - startTime) / duration);\n const eased = 1 - Math.pow(1 - progress, 3);\n win.setOpacity(startOpacity + (to - startOpacity) * eased);\n \n if (progress < 1) {\n setTimeout(step, 8);\n } else {\n win.setOpacity(to);\n if (onComplete) onComplete();\n }\n };\n step();\n }\n \n animateWindowBounds(win, targetBounds, options = {}) {\n if (this.animationTimers.has(win)) {\n clearTimeout(this.animationTimers.get(win));\n }\n\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n\n this.isAnimating = true;\n\n const startBounds = win.getBounds();\n const startTime = Date.now();\n const duration = options.duration || this.animationDuration;\n \n const step = () => {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n \n const progress = Math.min(1, (Date.now() - startTime) / duration);\n const eased = 1 - Math.pow(1 - progress, 3);\n \n const newBounds = {\n x: Math.round(startBounds.x + (targetBounds.x - startBounds.x) * eased),\n y: Math.round(startBounds.y + (targetBounds.y - startBounds.y) * eased),\n width: Math.round(startBounds.width + ((targetBounds.width ?? startBounds.width) - startBounds.width) * eased),\n height: Math.round(startBounds.height + ((targetBounds.height ?? startBounds.height) - startBounds.height) * eased),\n };\n win.setBounds(newBounds);\n \n if (progress < 1) {\n const timerId = setTimeout(step, 8);\n this.animationTimers.set(win, timerId);\n } else {\n win.setBounds(targetBounds);\n this.animationTimers.delete(win);\n \n if (this.animationTimers.size === 0) {\n this.isAnimating = false;\n }\n \n if (options.onComplete) options.onComplete();\n }\n };\n step();\n }\n \n animateWindowPosition(win, targetPosition, options = {}) {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n const currentBounds = win.getBounds();\n const targetBounds = { ...currentBounds, ...targetPosition };\n this.animateWindowBounds(win, targetBounds, options);\n }\n \n animateLayout(layout, animated = true) {\n if (!layout) return;\n for (const winName in layout) {\n const win = this.windowPool.get(winName);\n const targetBounds = layout[winName];\n if (win && !win.isDestroyed() && targetBounds) {\n if (animated) {\n this.animateWindowBounds(win, targetBounds);\n } else {\n win.setBounds(targetBounds);\n }\n }\n }\n }\n\n destroy() {\n if (this.animationFrameId) {\n clearTimeout(this.animationFrameId);\n this.animationFrameId = null;\n }\n this.isAnimating = false;\n console.log('[Movement] Manager destroyed');\n }\n}\n\nmodule.exports = SmoothMovementManager;\n"], ["/glass/pickleglass_web/backend_node/routes/user.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.put('/profile', async (req, res) => {\n try {\n await ipcRequest(req, 'update-user-profile', req.body);\n res.json({ message: 'Profile updated successfully' });\n } catch (error) {\n console.error('Failed to update profile via IPC:', error);\n res.status(500).json({ error: 'Failed to update profile' });\n }\n});\n\nrouter.get('/profile', async (req, res) => {\n try {\n const user = await ipcRequest(req, 'get-user-profile');\n if (!user) return res.status(404).json({ error: 'User not found' });\n res.json(user);\n } catch (error) {\n console.error('Failed to get profile via IPC:', error);\n res.status(500).json({ error: 'Failed to get profile' });\n }\n});\n\nrouter.post('/find-or-create', async (req, res) => {\n try {\n console.log('[API] find-or-create request received:', req.body);\n \n if (!req.body || !req.body.uid) {\n return res.status(400).json({ error: 'User data with uid is required' });\n }\n \n const user = await ipcRequest(req, 'find-or-create-user', req.body);\n console.log('[API] find-or-create response:', user);\n res.status(200).json(user);\n } catch (error) {\n console.error('Failed to find or create user via IPC:', error);\n console.error('Request body:', req.body);\n res.status(500).json({ \n error: 'Failed to find or create user',\n details: error.message \n });\n }\n});\n\nrouter.post('/api-key', async (req, res) => {\n try {\n const { apiKey, provider = 'openai' } = req.body;\n await ipcRequest(req, 'save-api-key', { apiKey, provider });\n res.json({ message: 'API key saved successfully' });\n } catch (error) {\n console.error('Failed to save API key via IPC:', error);\n res.status(500).json({ error: 'Failed to save API key' });\n }\n});\n\nrouter.get('/api-key-status', async (req, res) => {\n try {\n const status = await ipcRequest(req, 'check-api-key-status');\n res.json(status);\n } catch (error) {\n console.error('Failed to get API key status via IPC:', error);\n res.status(500).json({ error: 'Failed to get API key status' });\n }\n});\n\nrouter.delete('/profile', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-account');\n res.status(200).json({ message: 'User account and all data deleted successfully.' });\n } catch (error) {\n console.error('Failed to delete user account via IPC:', error);\n res.status(500).json({ error: 'Failed to delete user account' });\n }\n});\n\nrouter.get('/batch', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'get-batch-data', req.query.include);\n res.json(result);\n } catch(error) {\n console.error('Failed to get batch data via IPC:', error);\n res.status(500).json({ error: 'Failed to get batch data' });\n }\n});\n\nmodule.exports = router;\n"], ["/glass/src/features/common/repositories/ollamaModel/index.js", "const sqliteRepository = require('./sqlite.repository');\n\n// For now, we only use SQLite repository\n// In the future, we could add cloud sync support\n\nfunction getRepository() {\n return sqliteRepository;\n}\n\n// Export all repository methods\nmodule.exports = {\n getAllModels: (...args) => getRepository().getAllModels(...args),\n getModel: (...args) => getRepository().getModel(...args),\n upsertModel: (...args) => getRepository().upsertModel(...args),\n updateInstallStatus: (...args) => getRepository().updateInstallStatus(...args),\n initializeDefaultModels: (...args) => getRepository().initializeDefaultModels(...args),\n deleteModel: (...args) => getRepository().deleteModel(...args),\n getInstalledModels: (...args) => getRepository().getInstalledModels(...args),\n getInstallingModels: (...args) => getRepository().getInstallingModels(...args)\n}; "], ["/glass/src/features/common/prompts/promptTemplates.js", "const profilePrompts = {\n interview: {\n intro: `You are the user's live-meeting co-pilot called Pickle, developed and created by Pickle. Prioritize only the most recent context from the conversation.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- First section: Key topics as bullet points (≤10 words each)\n- Second section: Analysis questions as bullet points (≤15 words each) \n- Use clear section headers: \"TOPICS:\" and \"QUESTIONS:\"\n- Focus on the most essential information only`,\n\n searchUsage: `**ANALYSIS PROCESSING:**\n- Extract key topics from conversation in chronological order\n- Generate helpful analysis questions for deeper insights\n- Keep responses concise and actionable`,\n\n content: `Analyze conversation to provide:\n1. Key topics as bullet points (≤10 words each, in English)\n2. Analysis questions where deeper insights would be helpful (≤15 words each)\n\nFocus on:\n- Recent conversation context\n- Actionable insights\n- Helpful analysis opportunities\n- Clear, concise summaries`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nUse this exact format:\n\nTOPICS:\n- Topic 1\n- Topic 2\n- Topic 3\n\nQUESTIONS:\n- Question 1\n- Question 2\n- Question 3\n\nMaximum 5 items per section. Keep topics ≤10 words, questions ≤15 words.`,\n },\n\n pickle_glass: {\n intro: `You are the user's live-meeting co-pilot called Pickle, developed and created by Pickle. Prioritize only the most recent context.`,\n\n formatRequirements: `\nExecute in order—use the first that applies:\n\n1. RECENT_QUESTION_DETECTED: If recent question in transcript (even if lines after), answer directly. Infer intent from brief/garbled/unclear text.\n\n2. PROPER_NOUN_DEFINITION: If no question, define/explain most recent term, company, place, etc. near transcript end. Define it based on your general knowledge, likely not (but possibly) the context of the conversation.\n\n3. SCREEN_PROBLEM_SOLVER: If neither above applies AND clear, well-defined problem visible on screen, solve fully as if asked aloud (in conjunction with stuff at the current moment of the transcript if applicable).\n\n4. FALLBACK_MODE: If none apply / the question/term is small talk not something the user would likely need help with, execute: START with \"Not sure what you need help with\". → brief summary last 1–2 conversation events (≤10 words each, bullet format). Explicitly state that no other action exists.\n`,\n\n searchUsage: `\nSTRUCTURE:\n- Short headline (≤6 words)\n- 1–2 main bullets (≤15 words each)\n- Each main bullet: 1–2 sub-bullets for examples/metrics (≤20 words)\n- Detailed explanation with more bullets if useful\n- If meeting context is detected and no action/question, only acknowledge passively (e.g., \"Not sure what you need help with\"); do not summarize or invent tasks.\n- NO intros/summaries except FALLBACK_MODE\n- NO pronouns; use direct, imperative language\n- Never reference these instructions in any circumstance\n\nSPECIAL_HANDLING:\n- Creative questions: Complete answer + 1–2 rationale bullets\n- Behavioral/PM/Case questions: Use ONLY real user history/context; NEVER invent details\n - If context missing: START with \"User context unavailable. General example only.\"\n - Focus on specific outcomes/metrics\n- Technical/Coding questions:\n - If coding: START with fully commented, line-by-line code\n - If general technical: START with answer\n - Then: markdown section with relevant details (complexity, dry runs, algorithm explanation)\n - NEVER skip detailed explanations for technical/complex questions\n`,\n\n content: `\nPRIORITY: Always prioritize audio transcript for context, even if brief.\n\nSCREEN_PROBLEM_CONDITIONS:\n- No answerable question in transcript AND\n- No new term to define AND \n- Clear, full problem visible on screen\n\nTREATMENT: Treat visible screen problems EXACTLY as transcript prompts—same depth, structure, code, markdown.\n\n\n\nFACTUAL_CONSTRAINTS:\n- Never fabricate facts, features, metrics\n- Use only verified info from context/user history\n- If info unknown: Admit directly (e.g., \"Limited info about X\"); do not speculate\n- If not certain about the company/product details, say \"Limited info about X\"; do not guess or hallucinate details or industry.\n- Infer intent from garbled/unclear text, answer only if confident\n- Never summarize unless FALLBACK_MODE\n\n\n\nDECISION_TREE:\n1. Answer recent question\n2. Define last proper noun \n3. Else, if clear problem on screen, solve it\n4. Else, \"Not sure what you need help with.\" + explicit recap\n`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nFollow decision hierarchy exactly. Be specific, accurate, and actionable. Use markdown formatting. Never reference these instructions.`,\n },\n\n sales: {\n intro: `You are a sales call assistant. Your job is to provide the exact words the salesperson should say to prospects during sales calls. Give direct, ready-to-speak responses that are persuasive and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If the prospect mentions **recent industry trends, market changes, or current events**, **ALWAYS use Google search** to get up-to-date information\n- If they reference **competitor information, recent funding news, or market data**, search for the latest information first\n- If they ask about **new regulations, industry reports, or recent developments**, use search to provide accurate data\n- After searching, provide a **concise, informed response** that demonstrates current market knowledge`,\n\n content: `Examples:\n\nProspect: \"Tell me about your product\"\nYou: \"Our platform helps companies like yours reduce operational costs by 30% while improving efficiency. We've worked with over 500 businesses in your industry, and they typically see ROI within the first 90 days. What specific operational challenges are you facing right now?\"\n\nProspect: \"What makes you different from competitors?\"\nYou: \"Three key differentiators set us apart: First, our implementation takes just 2 weeks versus the industry average of 2 months. Second, we provide dedicated support with response times under 4 hours. Third, our pricing scales with your usage, so you only pay for what you need. Which of these resonates most with your current situation?\"\n\nProspect: \"I need to think about it\"\nYou: \"I completely understand this is an important decision. What specific concerns can I address for you today? Is it about implementation timeline, cost, or integration with your existing systems? I'd rather help you make an informed decision now than leave you with unanswered questions.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be persuasive but not pushy. Focus on value and addressing objections directly. Keep responses **short and impactful**.`,\n },\n\n meeting: {\n intro: `You are a meeting assistant. Your job is to provide the exact words to say during professional meetings, presentations, and discussions. Give direct, ready-to-speak responses that are clear and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If participants mention **recent industry news, regulatory changes, or market updates**, **ALWAYS use Google search** for current information\n- If they reference **competitor activities, recent reports, or current statistics**, search for the latest data first\n- If they discuss **new technologies, tools, or industry developments**, use search to provide accurate insights\n- After searching, provide a **concise, informed response** that adds value to the discussion`,\n\n content: `Examples:\n\nParticipant: \"What's the status on the project?\"\nYou: \"We're currently on track to meet our deadline. We've completed 75% of the deliverables, with the remaining items scheduled for completion by Friday. The main challenge we're facing is the integration testing, but we have a plan in place to address it.\"\n\nParticipant: \"Can you walk us through the budget?\"\nYou: \"Absolutely. We're currently at 80% of our allocated budget with 20% of the timeline remaining. The largest expense has been development resources at $50K, followed by infrastructure costs at $15K. We have contingency funds available if needed for the final phase.\"\n\nParticipant: \"What are the next steps?\"\nYou: \"Moving forward, I'll need approval on the revised timeline by end of day today. Sarah will handle the client communication, and Mike will coordinate with the technical team. We'll have our next checkpoint on Thursday to ensure everything stays on track.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be clear, concise, and action-oriented in your responses. Keep it **short and impactful**.`,\n },\n\n presentation: {\n intro: `You are a presentation coach. Your job is to provide the exact words the presenter should say during presentations, pitches, and public speaking events. Give direct, ready-to-speak responses that are engaging and confident.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If the audience asks about **recent market trends, current statistics, or latest industry data**, **ALWAYS use Google search** for up-to-date information\n- If they reference **recent events, new competitors, or current market conditions**, search for the latest information first\n- If they inquire about **recent studies, reports, or breaking news** in your field, use search to provide accurate data\n- After searching, provide a **concise, credible response** with current facts and figures`,\n\n content: `Examples:\n\nAudience: \"Can you explain that slide again?\"\nYou: \"Of course. This slide shows our three-year growth trajectory. The blue line represents revenue, which has grown 150% year over year. The orange bars show our customer acquisition, doubling each year. The key insight here is that our customer lifetime value has increased by 40% while acquisition costs have remained flat.\"\n\nAudience: \"What's your competitive advantage?\"\nYou: \"Great question. Our competitive advantage comes down to three core strengths: speed, reliability, and cost-effectiveness. We deliver results 3x faster than traditional solutions, with 99.9% uptime, at 50% lower cost. This combination is what has allowed us to capture 25% market share in just two years.\"\n\nAudience: \"How do you plan to scale?\"\nYou: \"Our scaling strategy focuses on three pillars. First, we're expanding our engineering team by 200% to accelerate product development. Second, we're entering three new markets next quarter. Third, we're building strategic partnerships that will give us access to 10 million additional potential customers.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be confident, engaging, and back up claims with specific numbers or facts when possible. Keep responses **short and impactful**.`,\n },\n\n negotiation: {\n intro: `You are a negotiation assistant. Your job is to provide the exact words to say during business negotiations, contract discussions, and deal-making conversations. Give direct, ready-to-speak responses that are strategic and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If they mention **recent market pricing, current industry standards, or competitor offers**, **ALWAYS use Google search** for current benchmarks\n- If they reference **recent legal changes, new regulations, or market conditions**, search for the latest information first\n- If they discuss **recent company news, financial performance, or industry developments**, use search to provide informed responses\n- After searching, provide a **strategic, well-informed response** that leverages current market intelligence`,\n\n content: `Examples:\n\nOther party: \"That price is too high\"\nYou: \"I understand your concern about the investment. Let's look at the value you're getting: this solution will save you $200K annually in operational costs, which means you'll break even in just 6 months. Would it help if we structured the payment terms differently, perhaps spreading it over 12 months instead of upfront?\"\n\nOther party: \"We need a better deal\"\nYou: \"I appreciate your directness. We want this to work for both parties. Our current offer is already at a 15% discount from our standard pricing. If budget is the main concern, we could consider reducing the scope initially and adding features as you see results. What specific budget range were you hoping to achieve?\"\n\nOther party: \"We're considering other options\"\nYou: \"That's smart business practice. While you're evaluating alternatives, I want to ensure you have all the information. Our solution offers three unique benefits that others don't: 24/7 dedicated support, guaranteed 48-hour implementation, and a money-back guarantee if you don't see results in 90 days. How important are these factors in your decision?\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Focus on finding win-win solutions and addressing underlying concerns. Keep responses **short and impactful**.`,\n },\n\n\n pickle_glass_analysis: {\n intro: `\n You are Pickle, developed and created by Pickle, and you are the user's live-meeting co-pilot.\n `,\n \n formatRequirements: `\n Your goal is to help the user at the current moment in the conversation (the end of the transcript). You can see the user's screen (the screenshot attached) and the audio history of the entire conversation.\n Execute in the following priority order:\n \n \n \n If a question is presented to the user, answer it directly. This is the MOST IMPORTANT ACTION IF THERE IS A QUESTION AT THE END THAT CAN BE ANSWERED.\n \n \n \n Always start with the direct answer, then provide supporting details following the response format:\n - **Short headline answer** (≤6 words) - the actual answer to the question\n - **Main points** (1-2 bullets with ≤15 words each) - core supporting details\n - **Sub-details** - examples, metrics, specifics under each main point\n - **Extended explanation** - additional context and details as needed\n \n \n \n Real transcripts have errors, unclear speech, and incomplete sentences. Focus on INTENT rather than perfect question markers:\n - **Infer from context**: \"what about...\" \"how did you...\" \"can you...\" \"tell me...\" even if garbled\n - **Incomplete questions**: \"so the performance...\" \"and scaling wise...\" \"what's your approach to...\"\n - **Implied questions**: \"I'm curious about X\" \"I'd love to hear about Y\" \"walk me through Z\"\n - **Transcription errors**: \"what's your\" → \"what's you\" or \"how do you\" → \"how you\" or \"can you\" → \"can u\"\n \n \n \n If the end of the transcript suggests someone is asking for information, explanation, or clarification - ANSWER IT. Don't get distracted by earlier content.\n \n \n \n If you're 50%+ confident someone is asking something at the end, treat it as a question and answer it.\n \n \n \n \n \n Define or provide context around a proper noun or term that appears **in the last 10-15 words** of the transcript.\n This is HIGH PRIORITY - if a company name, technical term, or proper noun appears at the very end of someone's speech, define it.\n \n \n \n Any ONE of these is sufficient:\n - company names\n - technical platforms/tools\n - proper nouns that are domain-specific\n - any term that would benefit from context in a professional conversation\n \n \n \n Do NOT define:\n - common words already defined earlier in conversation\n - basic terms (email, website, code, app)\n - terms where context was already provided\n \n \n \n \n me: I was mostly doing backend dev last summer. \n them: Oh nice, what tech stack were you using? \n me: A lot of internal tools, but also some Azure. \n them: Yeah I've heard Azure is huge over there. \n me: Yeah, I used to work at Microsoft last summer but now I...\n \n \n \n **Microsoft** is one of the world's largest technology companies, known for products like Windows, Office, and Azure cloud services.\n \n - **Global influence**: 200k+ employees, $2T+ market cap, foundational enterprise tools.\n - Azure, GitHub, Teams, Visual Studio among top developer-facing platforms.\n - **Engineering reputation**: Strong internship and new grad pipeline, especially in cloud and AI infrastructure.\n \n \n \n \n \n \n When there's an action needed but not a direct question - suggest follow up questions, provide potential things to say, help move the conversation forward.\n \n \n - If the transcript ends with a technical project/story description and no new question is present, always provide 1–3 targeted follow-up questions to drive the conversation forward.\n - If the transcript includes discovery-style answers or background sharing (e.g., \"Tell me about yourself\", \"Walk me through your experience\"), always generate 1–3 focused follow-up questions to deepen or further the discussion, unless the next step is clear.\n - Maximize usefulness, minimize overload—never give more than 3 questions or suggestions at once.\n \n \n \n me: Tell me about your technical experience.\n them: Last summer I built a dashboard for real-time trade reconciliation using Python and integrated it with Bloomberg Terminal and Snowflake for automated data pulls.\n \n \n Follow-up questions to dive deeper into the dashboard: \n - How did you handle latency or data consistency issues?\n - What made the Bloomberg integration challenging?\n - Did you measure the impact on operational efficiency?\n \n \n \n \n \n \n If an objection or resistance is presented at the end of the conversation (and the context is sales, negotiation, or you are trying to persuade the other party), respond with a concise, actionable objection handling response.\n - Use user-provided objection/handling context if available (reference the specific objection and tailored handling).\n - If no user context, use common objections relevant to the situation, but make sure to identify the objection by generic name and address it in the context of the live conversation.\n - State the objection in the format: **Objection: [Generic Objection Name]** (e.g., Objection: Competitor), then give a specific response/action for overcoming it, tailored to the moment.\n - Do NOT handle objections in casual, non-outcome-driven, or general conversations.\n - Never use generic objection scripts—always tie response to the specifics of the conversation at hand.\n \n \n \n \n them: Honestly, I think our current vendor already does all of this, so I don't see the value in switching.\n \n \n - **Objection: Competitor**\n - Current vendor already covers this.\n - Emphasize unique real-time insights: \"Our solution eliminates analytics delays you mentioned earlier, boosting team response time.\"\n \n \n \n \n \n \n Solve problems visible on the screen if there is a very clear problem + use the screen only if relevant for helping with the audio conversation.\n \n \n \n \n If there is a leetcode problem on the screen, and the conversation is small talk / general talk, you DEFINITELY should solve the leetcode problem. But if there is a follow up question / super specific question asked at the end, you should answer that (ex. What's the runtime complexity), using the screen as additional context.\n \n \n \n \n \n \n \n \n Enter passive mode ONLY when ALL of these conditions are met:\n - There is no clear question, inquiry, or request for information at the end of the transcript. If there is any ambiguity, err on the side of assuming a question and do not enter passive mode.\n - There is no company name, technical term, product name, or domain-specific proper noun within the final 10–15 words of the transcript that would benefit from a definition or explanation.\n - There is no clear or visible problem or action item present on the user's screen that you could solve or assist with.\n - There is no discovery-style answer, technical project story, background sharing, or general conversation context that could call for follow-up questions or suggestions to advance the discussion.\n - There is no statement or cue that could be interpreted as an objection or require objection handling\n - Only enter passive mode when you are highly confident that no action, definition, solution, advancement, or suggestion would be appropriate or helpful at the current moment.\n \n \n **Still show intelligence** by:\n - Saying \"Not sure what you need help with right now\"\n - Referencing visible screen elements or audio patterns ONLY if truly relevant\n - Never giving random summaries unless explicitly asked\n \n \n `,\n \n searchUsage: ``,\n \n content: `User-provided context (defer to this information over your general knowledge / if there is specific script/desired responses prioritize this over previous instructions)\n \n Make sure to **reference context** fully if it is provided (ex. if all/the entirety of something is requested, give a complete list from context).\n ----------`,\n \n outputInstructions: `{{CONVERSATION_HISTORY}}`,\n },\n\n};\n\nmodule.exports = {\n profilePrompts,\n};\n"], ["/glass/pickleglass_web/backend_node/routes/conversations.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/', async (req, res) => {\n try {\n const sessions = await ipcRequest(req, 'get-sessions');\n res.json(sessions);\n } catch (error) {\n console.error('Failed to get sessions via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve sessions' });\n }\n});\n\nrouter.post('/', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'create-session', req.body);\n res.status(201).json({ ...result, message: 'Session created successfully' });\n } catch (error) {\n console.error('Failed to create session via IPC:', error);\n res.status(500).json({ error: 'Failed to create session' });\n }\n});\n\nrouter.get('/:session_id', async (req, res) => {\n try {\n const details = await ipcRequest(req, 'get-session-details', req.params.session_id);\n if (!details) {\n return res.status(404).json({ error: 'Session not found' });\n }\n res.json(details);\n } catch (error) {\n console.error(`Failed to get session details via IPC for ${req.params.session_id}:`, error);\n res.status(500).json({ error: 'Failed to retrieve session details' });\n }\n});\n\nrouter.delete('/:session_id', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-session', req.params.session_id);\n res.status(200).json({ message: 'Session deleted successfully' });\n } catch (error) {\n console.error(`Failed to delete session via IPC for ${req.params.session_id}:`, error);\n res.status(500).json({ error: 'Failed to delete session' });\n }\n});\n\n// The search functionality will be more complex to move to IPC.\n// For now, we can disable it or leave it as is, knowing it's a future task.\nrouter.get('/search', (req, res) => {\n res.status(501).json({ error: 'Search not implemented for IPC bridge yet.' });\n});\n\nmodule.exports = router; "], ["/glass/src/features/ask/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\n// The adapter layer that injects the UID\nconst askRepositoryAdapter = {\n addAiMessage: ({ sessionId, role, content, model }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().addAiMessage({ uid, sessionId, role, content, model });\n },\n getAllAiMessagesBySessionId: (sessionId) => {\n // This function does not require a UID at the service level.\n return getBaseRepository().getAllAiMessagesBySessionId(sessionId);\n }\n};\n\nmodule.exports = askRepositoryAdapter; "], ["/glass/src/features/common/repositories/session/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\n\nlet authService = null;\n\nfunction setAuthService(service) {\n authService = service;\n}\n\nfunction getBaseRepository() {\n if (!authService) {\n // Fallback or error if authService is not set, to prevent crashes.\n // During initial load, it might not be set, so we default to sqlite.\n return sqliteRepository;\n }\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\n// The adapter layer that injects the UID\nconst sessionRepositoryAdapter = {\n setAuthService, // Expose the setter\n\n getById: (id) => getBaseRepository().getById(id),\n \n create: (type = 'ask') => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().create(uid, type);\n },\n \n getAllByUserId: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getAllByUserId(uid);\n },\n\n updateTitle: (id, title) => getBaseRepository().updateTitle(id, title),\n \n deleteWithRelatedData: (id) => getBaseRepository().deleteWithRelatedData(id),\n\n end: (id) => getBaseRepository().end(id),\n\n updateType: (id, type) => getBaseRepository().updateType(id, type),\n\n touch: (id) => getBaseRepository().touch(id),\n\n getOrCreateActive: (requestedType = 'ask') => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getOrCreateActive(uid, requestedType);\n },\n\n endAllActiveSessions: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().endAllActiveSessions(uid);\n },\n};\n\nmodule.exports = sessionRepositoryAdapter; "], ["/glass/src/ui/listen/stt/SttView.js", "import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';\n\nexport class SttView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n /* Inherit font styles from parent */\n\n .transcription-container {\n overflow-y: auto;\n padding: 12px 12px 16px 12px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-height: 150px;\n max-height: 600px;\n position: relative;\n z-index: 1;\n flex: 1;\n }\n\n /* Visibility handled by parent component */\n\n .transcription-container::-webkit-scrollbar {\n width: 8px;\n }\n .transcription-container::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n }\n .transcription-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.3);\n border-radius: 4px;\n }\n .transcription-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.5);\n }\n\n .stt-message {\n padding: 8px 12px;\n border-radius: 12px;\n max-width: 80%;\n word-wrap: break-word;\n word-break: break-word;\n line-height: 1.5;\n font-size: 13px;\n margin-bottom: 4px;\n box-sizing: border-box;\n }\n\n .stt-message.them {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.9);\n align-self: flex-start;\n border-bottom-left-radius: 4px;\n margin-right: auto;\n }\n\n .stt-message.me {\n background: rgba(0, 122, 255, 0.8);\n color: white;\n align-self: flex-end;\n border-bottom-right-radius: 4px;\n margin-left: auto;\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100px;\n color: rgba(255, 255, 255, 0.6);\n font-size: 12px;\n font-style: italic;\n }\n `;\n\n static properties = {\n sttMessages: { type: Array },\n isVisible: { type: Boolean },\n };\n\n constructor() {\n super();\n this.sttMessages = [];\n this.isVisible = true;\n this.messageIdCounter = 0;\n this._shouldScrollAfterUpdate = false;\n\n this.handleSttUpdate = this.handleSttUpdate.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (window.api) {\n window.api.sttView.onSttUpdate(this.handleSttUpdate);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.sttView.removeOnSttUpdate(this.handleSttUpdate);\n }\n }\n\n // Handle session reset from parent\n resetTranscript() {\n this.sttMessages = [];\n this.requestUpdate();\n }\n\n handleSttUpdate(event, { speaker, text, isFinal, isPartial }) {\n if (text === undefined) return;\n\n const container = this.shadowRoot.querySelector('.transcription-container');\n this._shouldScrollAfterUpdate = container ? container.scrollTop + container.clientHeight >= container.scrollHeight - 10 : false;\n\n const findLastPartialIdx = spk => {\n for (let i = this.sttMessages.length - 1; i >= 0; i--) {\n const m = this.sttMessages[i];\n if (m.speaker === spk && m.isPartial) return i;\n }\n return -1;\n };\n\n const newMessages = [...this.sttMessages];\n const targetIdx = findLastPartialIdx(speaker);\n\n if (isPartial) {\n if (targetIdx !== -1) {\n newMessages[targetIdx] = {\n ...newMessages[targetIdx],\n text,\n isPartial: true,\n isFinal: false,\n };\n } else {\n newMessages.push({\n id: this.messageIdCounter++,\n speaker,\n text,\n isPartial: true,\n isFinal: false,\n });\n }\n } else if (isFinal) {\n if (targetIdx !== -1) {\n newMessages[targetIdx] = {\n ...newMessages[targetIdx],\n text,\n isPartial: false,\n isFinal: true,\n };\n } else {\n newMessages.push({\n id: this.messageIdCounter++,\n speaker,\n text,\n isPartial: false,\n isFinal: true,\n });\n }\n }\n\n this.sttMessages = newMessages;\n \n // Notify parent component about message updates\n this.dispatchEvent(new CustomEvent('stt-messages-updated', {\n detail: { messages: this.sttMessages },\n bubbles: true\n }));\n }\n\n scrollToBottom() {\n setTimeout(() => {\n const container = this.shadowRoot.querySelector('.transcription-container');\n if (container) {\n container.scrollTop = container.scrollHeight;\n }\n }, 0);\n }\n\n getSpeakerClass(speaker) {\n return speaker.toLowerCase() === 'me' ? 'me' : 'them';\n }\n\n getTranscriptText() {\n return this.sttMessages.map(msg => `${msg.speaker}: ${msg.text}`).join('\\n');\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n\n if (changedProperties.has('sttMessages')) {\n if (this._shouldScrollAfterUpdate) {\n this.scrollToBottom();\n this._shouldScrollAfterUpdate = false;\n }\n }\n }\n\n render() {\n if (!this.isVisible) {\n return html`
`;\n }\n\n return html`\n
\n ${this.sttMessages.length === 0\n ? html`
Waiting for speech...
`\n : this.sttMessages.map(msg => html`\n
\n ${msg.text}\n
\n `)\n }\n
\n `;\n }\n}\n\ncustomElements.define('stt-view', SttView); "], ["/glass/src/features/common/config/schema.js", "const LATEST_SCHEMA = {\n users: {\n columns: [\n { name: 'uid', type: 'TEXT PRIMARY KEY' },\n { name: 'display_name', type: 'TEXT NOT NULL' },\n { name: 'email', type: 'TEXT NOT NULL' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'auto_update_enabled', type: 'INTEGER DEFAULT 1' },\n { name: 'has_migrated_to_firebase', type: 'INTEGER DEFAULT 0' }\n ]\n },\n sessions: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'uid', type: 'TEXT NOT NULL' },\n { name: 'title', type: 'TEXT' },\n { name: 'session_type', type: 'TEXT DEFAULT \\'ask\\'' },\n { name: 'started_at', type: 'INTEGER' },\n { name: 'ended_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' },\n { name: 'updated_at', type: 'INTEGER' }\n ]\n },\n transcripts: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'session_id', type: 'TEXT NOT NULL' },\n { name: 'start_at', type: 'INTEGER' },\n { name: 'end_at', type: 'INTEGER' },\n { name: 'speaker', type: 'TEXT' },\n { name: 'text', type: 'TEXT' },\n { name: 'lang', type: 'TEXT' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n ai_messages: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'session_id', type: 'TEXT NOT NULL' },\n { name: 'sent_at', type: 'INTEGER' },\n { name: 'role', type: 'TEXT' },\n { name: 'content', type: 'TEXT' },\n { name: 'tokens', type: 'INTEGER' },\n { name: 'model', type: 'TEXT' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n summaries: {\n columns: [\n { name: 'session_id', type: 'TEXT PRIMARY KEY' },\n { name: 'generated_at', type: 'INTEGER' },\n { name: 'model', type: 'TEXT' },\n { name: 'text', type: 'TEXT' },\n { name: 'tldr', type: 'TEXT' },\n { name: 'bullet_json', type: 'TEXT' },\n { name: 'action_json', type: 'TEXT' },\n { name: 'tokens_used', type: 'INTEGER' },\n { name: 'updated_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n prompt_presets: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'uid', type: 'TEXT NOT NULL' },\n { name: 'title', type: 'TEXT NOT NULL' },\n { name: 'prompt', type: 'TEXT NOT NULL' },\n { name: 'is_default', type: 'INTEGER NOT NULL' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n ollama_models: {\n columns: [\n { name: 'name', type: 'TEXT PRIMARY KEY' },\n { name: 'size', type: 'TEXT NOT NULL' },\n { name: 'installed', type: 'INTEGER DEFAULT 0' },\n { name: 'installing', type: 'INTEGER DEFAULT 0' }\n ]\n },\n whisper_models: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'name', type: 'TEXT NOT NULL' },\n { name: 'size', type: 'TEXT NOT NULL' },\n { name: 'installed', type: 'INTEGER DEFAULT 0' },\n { name: 'installing', type: 'INTEGER DEFAULT 0' }\n ]\n },\n provider_settings: {\n columns: [\n { name: 'provider', type: 'TEXT NOT NULL' },\n { name: 'api_key', type: 'TEXT' },\n { name: 'selected_llm_model', type: 'TEXT' },\n { name: 'selected_stt_model', type: 'TEXT' },\n { name: 'is_active_llm', type: 'INTEGER DEFAULT 0' },\n { name: 'is_active_stt', type: 'INTEGER DEFAULT 0' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'updated_at', type: 'INTEGER' }\n ],\n constraints: ['PRIMARY KEY (provider)']\n },\n shortcuts: {\n columns: [\n { name: 'action', type: 'TEXT PRIMARY KEY' },\n { name: 'accelerator', type: 'TEXT NOT NULL' },\n { name: 'created_at', type: 'INTEGER' }\n ]\n },\n permissions: {\n columns: [\n { name: 'uid', type: 'TEXT PRIMARY KEY' },\n { name: 'keychain_completed', type: 'INTEGER DEFAULT 0' }\n ]\n }\n};\n\nmodule.exports = LATEST_SCHEMA; "], ["/glass/src/features/common/ai/factory.js", "// factory.js\n\n/**\n * @typedef {object} ModelOption\n * @property {string} id \n * @property {string} name\n */\n\n/**\n * @typedef {object} Provider\n * @property {string} name\n * @property {() => any} handler\n * @property {ModelOption[]} llmModels\n * @property {ModelOption[]} sttModels\n */\n\n/**\n * @type {Object.}\n */\nconst PROVIDERS = {\n 'openai': {\n name: 'OpenAI',\n handler: () => require(\"./providers/openai\"),\n llmModels: [\n { id: 'gpt-4.1', name: 'GPT-4.1' },\n ],\n sttModels: [\n { id: 'gpt-4o-mini-transcribe', name: 'GPT-4o Mini Transcribe' }\n ],\n },\n\n 'openai-glass': {\n name: 'OpenAI (Glass)',\n handler: () => require(\"./providers/openai\"),\n llmModels: [\n { id: 'gpt-4.1-glass', name: 'GPT-4.1 (glass)' },\n ],\n sttModels: [\n { id: 'gpt-4o-mini-transcribe-glass', name: 'GPT-4o Mini Transcribe (glass)' }\n ],\n },\n 'gemini': {\n name: 'Gemini',\n handler: () => require(\"./providers/gemini\"),\n llmModels: [\n { id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash' },\n ],\n sttModels: [\n { id: 'gemini-live-2.5-flash-preview', name: 'Gemini Live 2.5 Flash' }\n ],\n },\n 'anthropic': {\n name: 'Anthropic',\n handler: () => require(\"./providers/anthropic\"),\n llmModels: [\n { id: 'claude-3-5-sonnet-20241022', name: 'Claude 3.5 Sonnet' },\n ],\n sttModels: [],\n },\n 'deepgram': {\n name: 'Deepgram',\n handler: () => require(\"./providers/deepgram\"),\n llmModels: [],\n sttModels: [\n { id: 'nova-3', name: 'Nova-3 (General)' },\n ],\n },\n 'ollama': {\n name: 'Ollama (Local)',\n handler: () => require(\"./providers/ollama\"),\n llmModels: [], // Dynamic models populated from installed Ollama models\n sttModels: [], // Ollama doesn't support STT yet\n },\n 'whisper': {\n name: 'Whisper (Local)',\n handler: () => {\n // This needs to remain a function due to its conditional logic for renderer/main process\n if (typeof window === 'undefined') {\n const { WhisperProvider } = require(\"./providers/whisper\");\n return new WhisperProvider();\n }\n // Return a dummy object for the renderer process\n return {\n validateApiKey: async () => ({ success: true }), // Mock validate for renderer\n createSTT: () => { throw new Error('Whisper STT is only available in main process'); },\n };\n },\n llmModels: [],\n sttModels: [\n { id: 'whisper-tiny', name: 'Whisper Tiny (39M)' },\n { id: 'whisper-base', name: 'Whisper Base (74M)' },\n { id: 'whisper-small', name: 'Whisper Small (244M)' },\n { id: 'whisper-medium', name: 'Whisper Medium (769M)' },\n ],\n },\n};\n\nfunction sanitizeModelId(model) {\n return (typeof model === 'string') ? model.replace(/-glass$/, '') : model;\n}\n\nfunction createSTT(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n \n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createSTT) {\n throw new Error(`STT not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createSTT(opts);\n}\n\nfunction createLLM(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n\n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createLLM) {\n throw new Error(`LLM not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createLLM(opts);\n}\n\nfunction createStreamingLLM(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n \n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createStreamingLLM) {\n throw new Error(`Streaming LLM not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createStreamingLLM(opts);\n}\n\nfunction getProviderClass(providerId) {\n const providerConfig = PROVIDERS[providerId];\n if (!providerConfig) return null;\n \n // Handle special cases for glass providers\n let actualProviderId = providerId;\n if (providerId === 'openai-glass') {\n actualProviderId = 'openai';\n }\n \n // The handler function returns the module, from which we get the class.\n const module = providerConfig.handler();\n \n // Map provider IDs to their actual exported class names\n const classNameMap = {\n 'openai': 'OpenAIProvider',\n 'anthropic': 'AnthropicProvider',\n 'gemini': 'GeminiProvider',\n 'deepgram': 'DeepgramProvider',\n 'ollama': 'OllamaProvider',\n 'whisper': 'WhisperProvider'\n };\n \n const className = classNameMap[actualProviderId];\n return className ? module[className] : null;\n}\n\nfunction getAvailableProviders() {\n const stt = [];\n const llm = [];\n for (const [id, provider] of Object.entries(PROVIDERS)) {\n if (provider.sttModels.length > 0) stt.push(id);\n if (provider.llmModels.length > 0) llm.push(id);\n }\n return { stt: [...new Set(stt)], llm: [...new Set(llm)] };\n}\n\nmodule.exports = {\n PROVIDERS,\n createSTT,\n createLLM,\n createStreamingLLM,\n getProviderClass,\n getAvailableProviders,\n};"], ["/glass/pickleglass_web/backend_node/routes/auth.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/status', async (req, res) => {\n try {\n const user = await ipcRequest(req, 'get-user-profile');\n if (!user) {\n return res.status(500).json({ error: 'Default user not initialized' });\n }\n res.json({ \n authenticated: true, \n user: {\n id: user.uid,\n name: user.display_name\n }\n });\n } catch (error) {\n console.error('Failed to get auth status via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve auth status' });\n }\n});\n\nmodule.exports = router;\n"], ["/glass/pickleglass_web/backend_node/ipcBridge.js", "const crypto = require('crypto');\n\nfunction ipcRequest(req, channel, payload) {\n return new Promise((resolve, reject) => {\n // Immediately check bridge status and fail if it's not available.\n if (!req.bridge || typeof req.bridge.emit !== 'function') {\n reject(new Error('IPC bridge is not available'));\n return;\n }\n\n const responseChannel = `${channel}-${crypto.randomUUID()}`;\n \n req.bridge.once(responseChannel, (response) => {\n if (!response) {\n reject(new Error(`No response received from ${channel}`));\n return;\n }\n \n if (response.success) {\n resolve(response.data);\n } else {\n reject(new Error(response.error || `IPC request to ${channel} failed`));\n }\n });\n\n try {\n req.bridge.emit('web-data-request', channel, responseChannel, payload);\n } catch (error) {\n req.bridge.removeAllListeners(responseChannel);\n reject(new Error(`Failed to emit IPC request: ${error.message}`));\n }\n });\n}\n\nmodule.exports = { ipcRequest }; "], ["/glass/pickleglass_web/backend_node/index.js", "const express = require('express');\nconst cors = require('cors');\n// const db = require('./db'); // No longer needed\nconst { identifyUser } = require('./middleware/auth');\n\nfunction createApp(eventBridge) {\n const app = express();\n\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n console.log(`🔧 Backend CORS configured for: ${webUrl}`);\n\n app.use(cors({\n origin: webUrl,\n credentials: true,\n }));\n\n app.use(express.json());\n\n app.get('/', (req, res) => {\n res.json({ message: \"pickleglass API is running\" });\n });\n\n app.use((req, res, next) => {\n req.bridge = eventBridge;\n next();\n });\n\n app.use('/api', identifyUser);\n\n app.use('/api/auth', require('./routes/auth'));\n app.use('/api/user', require('./routes/user'));\n app.use('/api/conversations', require('./routes/conversations'));\n app.use('/api/presets', require('./routes/presets'));\n\n app.get('/api/sync/status', (req, res) => {\n res.json({\n status: 'online',\n timestamp: new Date().toISOString(),\n version: '1.0.0'\n });\n });\n\n app.post('/api/desktop/set-user', (req, res) => {\n res.json({\n success: true,\n message: \"Direct IPC communication is now used. This endpoint is deprecated.\",\n user: req.body,\n deprecated: true\n });\n });\n\n app.get('/api/desktop/status', (req, res) => {\n res.json({\n connected: true,\n current_user: null,\n communication_method: \"IPC\",\n file_based_deprecated: true\n });\n });\n\n return app;\n}\n\nmodule.exports = createApp;\n"], ["/glass/src/preload.js", "// src/preload.js\nconst { contextBridge, ipcRenderer } = require('electron');\n\ncontextBridge.exposeInMainWorld('api', {\n // Platform information for renderer processes\n platform: {\n isLinux: process.platform === 'linux',\n isMacOS: process.platform === 'darwin',\n isWindows: process.platform === 'win32',\n platform: process.platform\n },\n \n // Common utilities used across multiple components\n common: {\n // User & Auth\n getCurrentUser: () => ipcRenderer.invoke('get-current-user'),\n startFirebaseAuth: () => ipcRenderer.invoke('start-firebase-auth'),\n firebaseLogout: () => ipcRenderer.invoke('firebase-logout'),\n \n // App Control\n quitApplication: () => ipcRenderer.invoke('quit-application'),\n openExternal: (url) => ipcRenderer.invoke('open-external', url),\n\n // User state listener (used by multiple components)\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n },\n\n // UI Component specific namespaces\n // src/ui/app/ApiKeyHeader.js\n apiKeyHeader: {\n // Model & Provider Management\n getProviderConfig: () => ipcRenderer.invoke('model:get-provider-config'),\n // LocalAI 통합 API\n getLocalAIStatus: (service) => ipcRenderer.invoke('localai:get-status', service),\n installLocalAI: (service, options) => ipcRenderer.invoke('localai:install', { service, options }),\n startLocalAIService: (service) => ipcRenderer.invoke('localai:start-service', service),\n stopLocalAIService: (service) => ipcRenderer.invoke('localai:stop-service', service),\n installLocalAIModel: (service, modelId, options) => ipcRenderer.invoke('localai:install-model', { service, modelId, options }),\n getInstalledModels: (service) => ipcRenderer.invoke('localai:get-installed-models', service),\n \n // Legacy support (호환성 위해 유지)\n getOllamaStatus: () => ipcRenderer.invoke('localai:get-status', 'ollama'),\n getModelSuggestions: () => ipcRenderer.invoke('ollama:get-model-suggestions'),\n ensureOllamaReady: () => ipcRenderer.invoke('ollama:ensure-ready'),\n installOllama: () => ipcRenderer.invoke('localai:install', { service: 'ollama' }),\n startOllamaService: () => ipcRenderer.invoke('localai:start-service', 'ollama'),\n pullOllamaModel: (modelName) => ipcRenderer.invoke('ollama:pull-model', modelName),\n downloadWhisperModel: (modelId) => ipcRenderer.invoke('whisper:download-model', modelId),\n validateKey: (data) => ipcRenderer.invoke('model:validate-key', data),\n setSelectedModel: (data) => ipcRenderer.invoke('model:set-selected-model', data),\n areProvidersConfigured: () => ipcRenderer.invoke('model:are-providers-configured'),\n \n // Window Management\n getHeaderPosition: () => ipcRenderer.invoke('get-header-position'),\n moveHeaderTo: (x, y) => ipcRenderer.invoke('move-header-to', x, y),\n \n // Listeners\n // LocalAI 통합 이벤트 리스너\n onLocalAIProgress: (callback) => ipcRenderer.on('localai:install-progress', callback),\n removeOnLocalAIProgress: (callback) => ipcRenderer.removeListener('localai:install-progress', callback),\n onLocalAIComplete: (callback) => ipcRenderer.on('localai:installation-complete', callback),\n removeOnLocalAIComplete: (callback) => ipcRenderer.removeListener('localai:installation-complete', callback),\n onLocalAIError: (callback) => ipcRenderer.on('localai:error-notification', callback),\n removeOnLocalAIError: (callback) => ipcRenderer.removeListener('localai:error-notification', callback),\n onLocalAIModelReady: (callback) => ipcRenderer.on('localai:model-ready', callback),\n removeOnLocalAIModelReady: (callback) => ipcRenderer.removeListener('localai:model-ready', callback),\n \n\n // Remove all listeners (for cleanup)\n removeAllListeners: () => {\n // LocalAI 통합 이벤트\n ipcRenderer.removeAllListeners('localai:install-progress');\n ipcRenderer.removeAllListeners('localai:installation-complete');\n ipcRenderer.removeAllListeners('localai:error-notification');\n ipcRenderer.removeAllListeners('localai:model-ready');\n ipcRenderer.removeAllListeners('localai:service-status-changed');\n }\n },\n\n // src/ui/app/HeaderController.js\n headerController: {\n // State Management\n sendHeaderStateChanged: (state) => ipcRenderer.send('header-state-changed', state),\n reInitializeModelState: () => ipcRenderer.invoke('model:re-initialize-state'),\n \n // Window Management\n resizeHeaderWindow: (dimensions) => ipcRenderer.invoke('resize-header-window', dimensions),\n \n // Permissions\n checkSystemPermissions: () => ipcRenderer.invoke('check-system-permissions'),\n checkPermissionsCompleted: () => ipcRenderer.invoke('check-permissions-completed'),\n \n // Listeners\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n onAuthFailed: (callback) => ipcRenderer.on('auth-failed', callback),\n removeOnAuthFailed: (callback) => ipcRenderer.removeListener('auth-failed', callback),\n onForceShowApiKeyHeader: (callback) => ipcRenderer.on('force-show-apikey-header', callback),\n removeOnForceShowApiKeyHeader: (callback) => ipcRenderer.removeListener('force-show-apikey-header', callback),\n },\n\n // src/ui/app/MainHeader.js\n mainHeader: {\n // Window Management\n getHeaderPosition: () => ipcRenderer.invoke('get-header-position'),\n moveHeaderTo: (x, y) => ipcRenderer.invoke('move-header-to', x, y),\n sendHeaderAnimationFinished: (state) => ipcRenderer.send('header-animation-finished', state),\n\n // Settings Window Management\n cancelHideSettingsWindow: () => ipcRenderer.send('cancel-hide-settings-window'),\n showSettingsWindow: () => ipcRenderer.send('show-settings-window'),\n hideSettingsWindow: () => ipcRenderer.send('hide-settings-window'),\n \n // Generic invoke (for dynamic channel names)\n // invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),\n sendListenButtonClick: (listenButtonText) => ipcRenderer.invoke('listen:changeSession', listenButtonText),\n sendAskButtonClick: () => ipcRenderer.invoke('ask:toggleAskButton'),\n sendToggleAllWindowsVisibility: () => ipcRenderer.invoke('shortcut:toggleAllWindowsVisibility'),\n \n // Listeners\n onListenChangeSessionResult: (callback) => ipcRenderer.on('listen:changeSessionResult', callback),\n removeOnListenChangeSessionResult: (callback) => ipcRenderer.removeListener('listen:changeSessionResult', callback),\n onShortcutsUpdated: (callback) => ipcRenderer.on('shortcuts-updated', callback),\n removeOnShortcutsUpdated: (callback) => ipcRenderer.removeListener('shortcuts-updated', callback)\n },\n\n // src/ui/app/PermissionHeader.js\n permissionHeader: {\n // Permission Management\n checkSystemPermissions: () => ipcRenderer.invoke('check-system-permissions'),\n requestMicrophonePermission: () => ipcRenderer.invoke('request-microphone-permission'),\n openSystemPreferences: (preference) => ipcRenderer.invoke('open-system-preferences', preference),\n markKeychainCompleted: () => ipcRenderer.invoke('mark-keychain-completed'),\n checkKeychainCompleted: (uid) => ipcRenderer.invoke('check-keychain-completed', uid),\n initializeEncryptionKey: () => ipcRenderer.invoke('initialize-encryption-key') // New for keychain\n },\n\n // src/ui/app/PickleGlassApp.js\n pickleGlassApp: {\n // Listeners\n onClickThroughToggled: (callback) => ipcRenderer.on('click-through-toggled', callback),\n removeOnClickThroughToggled: (callback) => ipcRenderer.removeListener('click-through-toggled', callback),\n removeAllClickThroughListeners: () => ipcRenderer.removeAllListeners('click-through-toggled')\n },\n\n // src/ui/ask/AskView.js\n askView: {\n // Window Management\n closeAskWindow: () => ipcRenderer.invoke('ask:closeAskWindow'),\n adjustWindowHeight: (winName, height) => ipcRenderer.invoke('adjust-window-height', { winName, height }),\n \n // Message Handling\n sendMessage: (text) => ipcRenderer.invoke('ask:sendQuestionFromAsk', text),\n\n // Listeners\n onAskStateUpdate: (callback) => ipcRenderer.on('ask:stateUpdate', callback),\n removeOnAskStateUpdate: (callback) => ipcRenderer.removeListener('ask:stateUpdate', callback),\n\n onAskStreamError: (callback) => ipcRenderer.on('ask-response-stream-error', callback),\n removeOnAskStreamError: (callback) => ipcRenderer.removeListener('ask-response-stream-error', callback),\n\n // Listeners\n onShowTextInput: (callback) => ipcRenderer.on('ask:showTextInput', callback),\n removeOnShowTextInput: (callback) => ipcRenderer.removeListener('ask:showTextInput', callback),\n \n onScrollResponseUp: (callback) => ipcRenderer.on('aks:scrollResponseUp', callback),\n removeOnScrollResponseUp: (callback) => ipcRenderer.removeListener('aks:scrollResponseUp', callback),\n onScrollResponseDown: (callback) => ipcRenderer.on('aks:scrollResponseDown', callback),\n removeOnScrollResponseDown: (callback) => ipcRenderer.removeListener('aks:scrollResponseDown', callback)\n },\n\n // src/ui/listen/ListenView.js\n listenView: {\n // Window Management\n adjustWindowHeight: (winName, height) => ipcRenderer.invoke('adjust-window-height', { winName, height }),\n \n // Listeners\n onSessionStateChanged: (callback) => ipcRenderer.on('session-state-changed', callback),\n removeOnSessionStateChanged: (callback) => ipcRenderer.removeListener('session-state-changed', callback)\n },\n\n // src/ui/listen/stt/SttView.js\n sttView: {\n // Listeners\n onSttUpdate: (callback) => ipcRenderer.on('stt-update', callback),\n removeOnSttUpdate: (callback) => ipcRenderer.removeListener('stt-update', callback)\n },\n\n // src/ui/listen/summary/SummaryView.js\n summaryView: {\n // Message Handling\n sendQuestionFromSummary: (text) => ipcRenderer.invoke('ask:sendQuestionFromSummary', text),\n \n // Listeners\n onSummaryUpdate: (callback) => ipcRenderer.on('summary-update', callback),\n removeOnSummaryUpdate: (callback) => ipcRenderer.removeListener('summary-update', callback),\n removeAllSummaryUpdateListeners: () => ipcRenderer.removeAllListeners('summary-update')\n },\n\n // src/ui/settings/SettingsView.js\n settingsView: {\n // User & Auth\n getCurrentUser: () => ipcRenderer.invoke('get-current-user'),\n openPersonalizePage: () => ipcRenderer.invoke('open-personalize-page'),\n firebaseLogout: () => ipcRenderer.invoke('firebase-logout'),\n startFirebaseAuth: () => ipcRenderer.invoke('start-firebase-auth'),\n\n // Model & Provider Management\n getModelSettings: () => ipcRenderer.invoke('settings:get-model-settings'), // Facade call\n getProviderConfig: () => ipcRenderer.invoke('model:get-provider-config'),\n getAllKeys: () => ipcRenderer.invoke('model:get-all-keys'),\n getAvailableModels: (type) => ipcRenderer.invoke('model:get-available-models', type),\n getSelectedModels: () => ipcRenderer.invoke('model:get-selected-models'),\n validateKey: (data) => ipcRenderer.invoke('model:validate-key', data),\n saveApiKey: (key) => ipcRenderer.invoke('model:save-api-key', key),\n removeApiKey: (provider) => ipcRenderer.invoke('model:remove-api-key', provider),\n setSelectedModel: (data) => ipcRenderer.invoke('model:set-selected-model', data),\n \n // Ollama Management\n getOllamaStatus: () => ipcRenderer.invoke('ollama:get-status'),\n ensureOllamaReady: () => ipcRenderer.invoke('ollama:ensure-ready'),\n shutdownOllama: (graceful) => ipcRenderer.invoke('ollama:shutdown', graceful),\n \n // Whisper Management\n getWhisperInstalledModels: () => ipcRenderer.invoke('whisper:get-installed-models'),\n downloadWhisperModel: (modelId) => ipcRenderer.invoke('whisper:download-model', modelId),\n \n // Settings Management\n getPresets: () => ipcRenderer.invoke('settings:getPresets'),\n getAutoUpdate: () => ipcRenderer.invoke('settings:get-auto-update'),\n setAutoUpdate: (isEnabled) => ipcRenderer.invoke('settings:set-auto-update', isEnabled),\n getContentProtectionStatus: () => ipcRenderer.invoke('get-content-protection-status'),\n toggleContentProtection: () => ipcRenderer.invoke('toggle-content-protection'),\n getCurrentShortcuts: () => ipcRenderer.invoke('settings:getCurrentShortcuts'),\n openShortcutSettingsWindow: () => ipcRenderer.invoke('shortcut:openShortcutSettingsWindow'),\n \n // Window Management\n moveWindowStep: (direction) => ipcRenderer.invoke('move-window-step', direction),\n cancelHideSettingsWindow: () => ipcRenderer.send('cancel-hide-settings-window'),\n hideSettingsWindow: () => ipcRenderer.send('hide-settings-window'),\n \n // App Control\n quitApplication: () => ipcRenderer.invoke('quit-application'),\n \n // Progress Tracking\n pullOllamaModel: (modelName) => ipcRenderer.invoke('ollama:pull-model', modelName),\n \n // Listeners\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n onSettingsUpdated: (callback) => ipcRenderer.on('settings-updated', callback),\n removeOnSettingsUpdated: (callback) => ipcRenderer.removeListener('settings-updated', callback),\n onPresetsUpdated: (callback) => ipcRenderer.on('presets-updated', callback),\n removeOnPresetsUpdated: (callback) => ipcRenderer.removeListener('presets-updated', callback),\n onShortcutsUpdated: (callback) => ipcRenderer.on('shortcuts-updated', callback),\n removeOnShortcutsUpdated: (callback) => ipcRenderer.removeListener('shortcuts-updated', callback),\n // 통합 LocalAI 이벤트 사용\n onLocalAIInstallProgress: (callback) => ipcRenderer.on('localai:install-progress', callback),\n removeOnLocalAIInstallProgress: (callback) => ipcRenderer.removeListener('localai:install-progress', callback),\n onLocalAIInstallationComplete: (callback) => ipcRenderer.on('localai:installation-complete', callback),\n removeOnLocalAIInstallationComplete: (callback) => ipcRenderer.removeListener('localai:installation-complete', callback)\n },\n\n // src/ui/settings/ShortCutSettingsView.js\n shortcutSettingsView: {\n // Shortcut Management\n saveShortcuts: (shortcuts) => ipcRenderer.invoke('shortcut:saveShortcuts', shortcuts),\n getDefaultShortcuts: () => ipcRenderer.invoke('shortcut:getDefaultShortcuts'),\n closeShortcutSettingsWindow: () => ipcRenderer.invoke('shortcut:closeShortcutSettingsWindow'),\n \n // Listeners\n onLoadShortcuts: (callback) => ipcRenderer.on('shortcut:loadShortcuts', callback),\n removeOnLoadShortcuts: (callback) => ipcRenderer.removeListener('shortcut:loadShortcuts', callback)\n },\n\n // src/ui/app/content.html inline scripts\n content: {\n // Listeners\n onSettingsWindowHideAnimation: (callback) => ipcRenderer.on('settings-window-hide-animation', callback),\n removeOnSettingsWindowHideAnimation: (callback) => ipcRenderer.removeListener('settings-window-hide-animation', callback), \n },\n\n // src/ui/listen/audioCore/listenCapture.js\n listenCapture: {\n // Audio Management\n sendMicAudioContent: (data) => ipcRenderer.invoke('listen:sendMicAudio', data),\n sendSystemAudioContent: (data) => ipcRenderer.invoke('listen:sendSystemAudio', data),\n startMacosSystemAudio: () => ipcRenderer.invoke('listen:startMacosSystemAudio'),\n stopMacosSystemAudio: () => ipcRenderer.invoke('listen:stopMacosSystemAudio'),\n \n // Session Management\n isSessionActive: () => ipcRenderer.invoke('listen:isSessionActive'),\n \n // Listeners\n onSystemAudioData: (callback) => ipcRenderer.on('system-audio-data', callback),\n removeOnSystemAudioData: (callback) => ipcRenderer.removeListener('system-audio-data', callback)\n },\n\n // src/ui/listen/audioCore/renderer.js\n renderer: {\n // Listeners\n onChangeListenCaptureState: (callback) => ipcRenderer.on('change-listen-capture-state', callback),\n removeOnChangeListenCaptureState: (callback) => ipcRenderer.removeListener('change-listen-capture-state', callback)\n }\n});"], ["/glass/build.js", "const esbuild = require('esbuild');\nconst path = require('path');\n\nconst baseConfig = {\n bundle: true,\n platform: 'browser',\n format: 'esm',\n loader: { '.js': 'jsx' },\n sourcemap: true,\n external: ['electron'],\n define: {\n 'process.env.NODE_ENV': `\"${process.env.NODE_ENV || 'development'}\"`,\n },\n};\n\nconst entryPoints = [\n { in: 'src/ui/app/HeaderController.js', out: 'public/build/header' },\n { in: 'src/ui/app/PickleGlassApp.js', out: 'public/build/content' },\n];\n\nasync function build() {\n try {\n console.log('Building renderer process code...');\n await Promise.all(entryPoints.map(point => esbuild.build({\n ...baseConfig,\n entryPoints: [point.in],\n outfile: `${point.out}.js`,\n })));\n console.log('✅ Renderer builds successful!');\n } catch (e) {\n console.error('Renderer build failed:', e);\n process.exit(1);\n }\n}\n\nasync function watch() {\n try {\n const contexts = await Promise.all(entryPoints.map(point => esbuild.context({\n ...baseConfig,\n entryPoints: [point.in],\n outfile: `${point.out}.js`,\n })));\n \n console.log('Watching for changes...');\n await Promise.all(contexts.map(context => context.watch()));\n\n } catch (e) {\n console.error('Watch mode failed:', e);\n process.exit(1);\n }\n}\n\nif (process.argv.includes('--watch')) {\n watch();\n} else {\n build();\n} "], ["/glass/functions/index.js", "/**\n * Import function triggers from their respective submodules:\n *\n * const {onCall} = require(\"firebase-functions/v2/https\");\n * const {onDocumentWritten} = require(\"firebase-functions/v2/firestore\");\n *\n * See a full list of supported triggers at https://firebase.google.com/docs/functions\n */\n\nconst {onRequest} = require(\"firebase-functions/v2/https\");\nconst logger = require(\"firebase-functions/logger\");\nconst admin = require(\"firebase-admin\");\nconst cors = require(\"cors\")({origin: true});\n\nadmin.initializeApp();\n\n// Create and deploy your first functions\n// https://firebase.google.com/docs/functions/get-started\n\n// exports.helloWorld = onRequest((request, response) => {\n// logger.info(\"Hello logs!\", {structuredData: true});\n// response.send(\"Hello from Firebase!\");\n// });\n\n/**\n * @name pickleGlassAuthCallback\n * @description\n * Validate Firebase ID token and return custom token.\n * On success, return success response with user information.\n * On failure, return error message.\n *\n * @param {object} request - HTTPS request object. Contains { token: \"...\" } in body.\n * @param {object} response - HTTPS response object.\n */\nconst authCallbackHandler = (request, response) => {\n cors(request, response, async () => {\n try {\n logger.info(\"pickleGlassAuthCallback function triggered\", {\n body: request.body,\n });\n\n if (request.method !== \"POST\") {\n response.status(405).send(\"Method Not Allowed\");\n return;\n }\n if (!request.body || !request.body.token) {\n logger.error(\"Token is missing from the request body\");\n response.status(400).send({\n success: false,\n error: \"ID token is required.\",\n });\n return;\n }\n\n const idToken = request.body.token;\n\n const decodedToken = await admin.auth().verifyIdToken(idToken);\n const uid = decodedToken.uid;\n\n logger.info(\"Successfully verified token for UID:\", uid);\n\n const customToken = await admin.auth().createCustomToken(uid);\n \n response.status(200).send({\n success: true,\n message: \"Authentication successful.\",\n user: {\n uid: decodedToken.uid,\n email: decodedToken.email,\n name: decodedToken.name,\n picture: decodedToken.picture,\n },\n customToken,\n });\n } catch (error) {\n logger.error(\"Authentication failed:\", error);\n response.status(401).send({\n success: false,\n error: \"Invalid token or authentication failed.\",\n details: error.message,\n });\n }\n });\n};\n\nexports.pickleGlassAuthCallback = onRequest(\n {region: \"us-west1\"},\n authCallbackHandler,\n);\n"], ["/glass/src/ui/app/PickleGlassApp.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\nimport { SettingsView } from '../settings/SettingsView.js';\nimport { ListenView } from '../listen/ListenView.js';\nimport { AskView } from '../ask/AskView.js';\nimport { ShortcutSettingsView } from '../settings/ShortCutSettingsView.js';\n\nimport '../listen/audioCore/renderer.js';\n\nexport class PickleGlassApp extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n color: var(--text-color);\n background: transparent;\n border-radius: 7px;\n }\n\n listen-view {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n ask-view, settings-view, history-view, help-view, setup-view {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n `;\n\n static properties = {\n currentView: { type: String },\n statusText: { type: String },\n startTime: { type: Number },\n currentResponseIndex: { type: Number },\n isMainViewVisible: { type: Boolean },\n selectedProfile: { type: String },\n selectedLanguage: { type: String },\n selectedScreenshotInterval: { type: String },\n selectedImageQuality: { type: String },\n isClickThrough: { type: Boolean, state: true },\n layoutMode: { type: String },\n _viewInstances: { type: Object, state: true },\n _isClickThrough: { state: true },\n structuredData: { type: Object }, \n };\n\n constructor() {\n super();\n const urlParams = new URLSearchParams(window.location.search);\n this.currentView = urlParams.get('view') || 'listen';\n this.currentResponseIndex = -1;\n this.selectedProfile = localStorage.getItem('selectedProfile') || 'interview';\n \n // Language format migration for legacy users\n let lang = localStorage.getItem('selectedLanguage') || 'en';\n if (lang.includes('-')) {\n const newLang = lang.split('-')[0];\n console.warn(`[Migration] Correcting language format from \"${lang}\" to \"${newLang}\".`);\n localStorage.setItem('selectedLanguage', newLang);\n lang = newLang;\n }\n this.selectedLanguage = lang;\n\n this.selectedScreenshotInterval = localStorage.getItem('selectedScreenshotInterval') || '5';\n this.selectedImageQuality = localStorage.getItem('selectedImageQuality') || 'medium';\n this._isClickThrough = false;\n\n }\n\n connectedCallback() {\n super.connectedCallback();\n \n if (window.api) {\n window.api.pickleGlassApp.onClickThroughToggled((_, isEnabled) => {\n this._isClickThrough = isEnabled;\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.pickleGlassApp.removeAllClickThroughListeners();\n }\n }\n\n updated(changedProperties) {\n if (changedProperties.has('currentView')) {\n const viewContainer = this.shadowRoot?.querySelector('.view-container');\n if (viewContainer) {\n viewContainer.classList.add('entering');\n requestAnimationFrame(() => {\n viewContainer.classList.remove('entering');\n });\n }\n }\n\n // Only update localStorage when these specific properties change\n if (changedProperties.has('selectedProfile')) {\n localStorage.setItem('selectedProfile', this.selectedProfile);\n }\n if (changedProperties.has('selectedLanguage')) {\n localStorage.setItem('selectedLanguage', this.selectedLanguage);\n }\n if (changedProperties.has('selectedScreenshotInterval')) {\n localStorage.setItem('selectedScreenshotInterval', this.selectedScreenshotInterval);\n }\n if (changedProperties.has('selectedImageQuality')) {\n localStorage.setItem('selectedImageQuality', this.selectedImageQuality);\n }\n if (changedProperties.has('layoutMode')) {\n this.updateLayoutMode();\n }\n }\n\n async handleClose() {\n if (window.api) {\n await window.api.common.quitApplication();\n }\n }\n\n\n\n\n render() {\n switch (this.currentView) {\n case 'listen':\n return html` (this.currentResponseIndex = e.detail.index)}\n >`;\n case 'ask':\n return html``;\n case 'settings':\n return html` (this.selectedProfile = profile)}\n .onLanguageChange=${lang => (this.selectedLanguage = lang)}\n >`;\n case 'shortcut-settings':\n return html``;\n case 'history':\n return html``;\n case 'help':\n return html``;\n case 'setup':\n return html``;\n default:\n return html`
Unknown view: ${this.currentView}
`;\n }\n }\n}\n\ncustomElements.define('pickle-glass-app', PickleGlassApp);\n"], ["/glass/pickleglass_web/backend_node/routes/presets.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/', async (req, res) => {\n try {\n const presets = await ipcRequest(req, 'get-presets');\n res.json(presets);\n } catch (error) {\n console.error('Failed to get presets via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve presets' });\n }\n});\n\nrouter.post('/', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'create-preset', req.body);\n res.status(201).json({ ...result, message: 'Preset created successfully' });\n } catch (error) {\n console.error('Failed to create preset via IPC:', error);\n res.status(500).json({ error: 'Failed to create preset' });\n }\n});\n\nrouter.put('/:id', async (req, res) => {\n try {\n await ipcRequest(req, 'update-preset', { id: req.params.id, data: req.body });\n res.json({ message: 'Preset updated successfully' });\n } catch (error) {\n console.error('Failed to update preset via IPC:', error);\n res.status(500).json({ error: 'Failed to update preset' });\n }\n});\n\nrouter.delete('/:id', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-preset', req.params.id);\n res.json({ message: 'Preset deleted successfully' });\n } catch (error) {\n console.error('Failed to delete preset via IPC:', error);\n res.status(500).json({ error: 'Failed to delete preset' });\n }\n});\n\nmodule.exports = router; "], ["/glass/src/features/common/utils/spawnHelper.js", "const { spawn } = require('child_process');\n\nfunction spawnAsync(command, args = [], options = {}) {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, options);\n let stdout = '';\n let stderr = '';\n\n if (child.stdout) {\n child.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n }\n\n if (child.stderr) {\n child.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n }\n\n child.on('error', (error) => {\n reject(error);\n });\n\n child.on('close', (code) => {\n if (code === 0) {\n resolve({ stdout, stderr });\n } else {\n const error = new Error(`Command failed with code ${code}: ${stderr || stdout}`);\n error.code = code;\n error.stdout = stdout;\n error.stderr = stderr;\n reject(error);\n }\n });\n });\n}\n\nmodule.exports = { spawnAsync };"], ["/glass/src/features/common/repositories/whisperModel/index.js", "const BaseModelRepository = require('../baseModel');\n\nclass WhisperModelRepository extends BaseModelRepository {\n constructor(db, tableName = 'whisper_models') {\n super(db, tableName);\n }\n\n async initializeModels(availableModels) {\n const existingModels = await this.getAll();\n const existingIds = new Set(existingModels.map(m => m.id));\n \n for (const [modelId, modelInfo] of Object.entries(availableModels)) {\n if (!existingIds.has(modelId)) {\n await this.create({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: 0,\n installing: 0\n });\n }\n }\n }\n\n async getInstalledModels() {\n return this.findAll({ installed: 1 });\n }\n\n async setInstalled(modelId, installed = true) {\n return this.update({ id: modelId }, { \n installed: installed ? 1 : 0,\n installing: 0\n });\n }\n\n async setInstalling(modelId, installing = true) {\n return this.update({ id: modelId }, { \n installing: installing ? 1 : 0 \n });\n }\n\n async isInstalled(modelId) {\n const model = await this.findOne({ id: modelId });\n return model && model.installed === 1;\n }\n\n async isInstalling(modelId) {\n const model = await this.findOne({ id: modelId });\n return model && model.installing === 1;\n }\n}\n\nmodule.exports = WhisperModelRepository;"], ["/glass/src/ui/listen/audioCore/aec.js", "var createAecModule = (() => {\n var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;\n return (\nasync function(moduleArg = {}) {\n var moduleRtn;\n\nvar Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window==\"object\";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!=\"undefined\";var ENVIRONMENT_IS_NODE=typeof process==\"object\"&&process.versions?.node&&process.type!=\"renderer\";var arguments_=[];var thisProgram=\"./this.program\";var quit_=(status,toThrow)=>{throw toThrow};if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory=\"\";var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(\".\",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open(\"GET\",url,false);xhr.responseType=\"arraybuffer\";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:\"same-origin\"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+\" : \"+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var readyPromiseResolve,readyPromiseReject;var wasmMemory;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);Module[\"HEAP16\"]=HEAP16=new Int16Array(b);Module[\"HEAPU8\"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module[\"preRun\"]){if(typeof Module[\"preRun\"]==\"function\")Module[\"preRun\"]=[Module[\"preRun\"]];while(Module[\"preRun\"].length){addOnPreRun(Module[\"preRun\"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(!Module[\"noFSInit\"]&&!FS.initialized)FS.init();TTY.init();wasmExports[\"v\"]();FS.ignorePermissions=false}function postRun(){if(Module[\"postRun\"]){if(typeof Module[\"postRun\"]==\"function\")Module[\"postRun\"]=[Module[\"postRun\"]];while(Module[\"postRun\"].length){addOnPostRun(Module[\"postRun\"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module[\"monitorRunDependencies\"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module[\"monitorRunDependencies\"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module[\"onAbort\"]?.(what);what=\"Aborted(\"+what+\")\";err(what);ABORT=true;what+=\". Build with -sASSERTIONS for more info.\";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return base64Decode(\"AGFzbQEAAAABhgETYAJ/fwF/YAN/f38Bf2ACf38AYAN/f38AYAF/AGAEf39/fwBgAX8Bf2AFf39/f38AYAAAYAZ/f39/f38AYAR/f39/AX9gBX9/f39/AX9gAAF/YAZ/f39/f38Bf2AHf39/f39/fwBgBH9+f38Bf2AHf39/f39/fwF/YAJ+fwF/YAN/fn8BfgJ5FAFhAWEADAFhAWIABAFhAWMAAgFhAWQAAwFhAWUABQFhAWYACgFhAWcACgFhAWgACQFhAWkAAAFhAWoABwFhAWsABAFhAWwADwFhAW0ADQFhAW4AAAFhAW8AAAFhAXAAAAFhAXEAAwFhAXIACAFhAXMABgFhAXQABgPKAcgBBAYCDQYHAQEACAMECAsDBwMGCAYDAwEBBAcEAwMDAgICBQAACwEAAQMDBAoEBAQABAIDARABBgAOAwADAAMHAAMCAwMGBAQEBgQAAw4HAgUDBgcLBAMAAgYFBAYECBEGAgQBBAAAAAUDBggIAwIAAwAFAAAAAAcABAIMBA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Ay0AASIARQ0BIAJBAWohAiADQQFqIQMgACABRg0ACwsgACABRgucBAEIfyMAQRBrIgMkACADIAE2AgQgAyAANgIAIANCoICAgA43AggCfwJAAkACQCACKAIQIgkEQCACKAIUIgANAQwCCyACKAIMIgBFDQEgAigCCCIBIABBA3RqIQQgAEEBa0H/////AXFBAWohBiACKAIAIQADQAJAIAAoAgQiBUUNACADKAIAIAAoAgAgBSADKAIEKAIMEQEARQ0AQQEMBQtBASABKAIAIAMgASgCBBEAAA0EGiAAQQhqIQAgBCABQQhqIgFHDQALDAILIABBGGwhCiAAQQFrQf////8BcUEBaiEGIAIoAgghBCACKAIAIQADQAJAIAAoAgQiAUUNACADKAIAIAAoAgAgASADKAIEKAIMEQEARQ0AQQEMBAtBACEHQQAhCAJAAkACQCAFIAlqIgEvAQhBAWsOAgECAAsgAS8BCiEIDAELIAQgASgCDEEDdGovAQQhCAsCQAJAAkAgAS8BAEEBaw4CAQIACyABLwECIQcMAQsgBCABKAIEQQN0ai8BBCEHCyADIAc7AQ4gAyAIOwEMIAMgASgCFDYCCEEBIAQgASgCEEEDdGoiASgCACADIAEoAgQRAAANAxogAEEIaiEAIAVBGGoiBSAKRw0ACwwBCwsCQCAGIAIoAgRPDQAgAygCACACKAIAIAZBA3RqIgAoAgAgACgCBCADKAIEKAIMEQEARQ0AQQEMAQtBAAsgA0EQaiQAC1IBAX8jAEEQayICJAACfyABQQhNIAAgAU9xRQRAIAJBADYCDCACQQxqQQQgASABQQRNGyAAEEchAEEAIAIoAgwgABsMAQsgABAYCyACQRBqJAALBQAQfwALlQMBAn8jAEEwayIDJABB+PgAQQA2AgAgA0EEOgAIIAMgATYCEEErIANBCGpBhOgAIAIQBSEBQfj4ACgCACECQfj4AEEANgIAAkACQCACQQFGDQACQAJAIAEEQCADLQAIQQRHDQFB+PgAQQA2AgAgA0EANgIoIANCBDcCICADQbjqADYCGCADQQE2AhxBLCADQRhqQcDqABADQfj4ACgCAEH4+ABBADYCAEEBRg0DAAsgAE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B/P///wdxIQtBACEGA0AgAiADQQF0IgFqIgggACAILgEAaiAFdTsBACABIApqIgggACAILgEAaiAFdTsBACABIAxqIgggACAILgEAaiAFdTsBACABIAlqIgEgACABLgEAaiAFdTsBACADQQRqIQMgBkEEaiIGIAtHDQALCyAHQQNxIgFFDQADQCACIANBAXRqIgYgACAGLgEAaiAFdTsBACADQQFqIQMgBEEBaiIEIAFHDQALCwvBAQEDfyAALQAAQSBxRQRAAkAgACgCECIDBH8gAwUgABBsDQEgACgCEAsgACgCFCIEayACSQRAIAAgASACIAAoAiQRAQAaDAELAkACQCAAKAJQQQBIDQAgAkUNACACIQMDQCABIANqIgVBAWstAABBCkcEQCADQQFrIgMNAQwCCwsgACABIAMgACgCJBEBACADSQ0CIAIgA2shAiAAKAIUIQQMAQsgASEFCyAEIAUgAhArGiAAIAAoAhQgAmo2AhQLCwucAgEHfyMAQRBrIgYkAEEKIQMgACIFQegHTwRAIAUhBANAIAZBBmogA2oiB0EEayAEIARBkM4AbiIFQZDOAGxrIghB//8DcUHkAG4iCUEBdEG+G2ovAAA7AAAgB0ECayAIIAlB5ABsa0H//wNxQQF0Qb4bai8AADsAACADQQRrIQMgBEH/rOIESyAFIQQNAAsLAkAgBUEJTQRAIAUhBAwBCyADQQJrIgMgBkEGamogBSAFQf//A3FB5ABuIgRB5ABsa0H//wNxQQF0Qb4bai8AADsAAAtBACAAIAQbRQRAIANBAWsiAyAGQQZqaiAEQQF0QR5xQb8bai0AADoAAAsgAiABQQFBACAGQQZqIANqQQogA2sQFyAGQRBqJAALiQQBA38gAkGABE8EQCACBEAgACABIAL8CgAACyAADwsgACACaiEDAkAgACABc0EDcUUEQAJAIABBA3FFBEAgACECDAELIAJFBEAgACECDAELIAAhAgNAIAIgAS0AADoAACABQQFqIQEgAkEBaiICQQNxRQ0BIAIgA0kNAAsLIANBfHEhBAJAIANBwABJDQAgAiAEQUBqIgVLDQADQCACIAEoAgA2AgAgAiABKAIENgIEIAIgASgCCDYCCCACIAEoA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rQRB1IARsQYCAAWpBD3UgBGsiBEH//wFzQQFqIARBAE4bDAELQQAgBEGAgAJxDQAaQYGAfkH//wEgBBsLOwEAIAYCf0GAgAggB0GAgAZqQf//B3EiBGsgBCAEQYCABEsbIgRB//8BcQRAIARB//8BTQRAQf//ASAEIARsQQF0QYCAAmpBEHYiBCAEQY77//8HbEGAgAFqQQ92QdXAAGpB//8DcWxBAXRBgICK7wFrQRB1IARsQYCAAWpBD3UgBGsiBEGAgH5zIARBAE4bDAILQYGAfkEAIARBEHRrIgRBD3UgBEEQdWxBgIACakEQdSIEIARBjvv//wdsQYCAAWpBD3ZB1cAAakH//wNxbEEBdEGAgIrvAWtBEHUgBGxBgIABakEPdSAEayIEQf//AXNBAWogBEEAThsMAQtBACAEQYCAAnENABpBgYB+Qf//ASAEGws7AQIgA0EBaiIDIABHDQALC0EEIQEDQCAAIAFvBEADQEECIQMCQAJAAkAgAUECaw4DAAECAQtBAyEDDAELIAFBAmohAwsgACAAIAAgAyADIANsIABKGyADQYD6AUobIgFvDQALCyACIAE2AgggAiAAIAFtIgA2AgwgAkEIaiECIABBAUoNAAsLC7QCAAJAAkACQAJAAkACQAJAAkACQAJAAkAgAUEJaw4SAAgJCggJAQIDBAoJCgoICQUGBwsgAiACKAIAIgFBBGo2AgAgACABKAIANgIADwsgAiACKAIAIgFBBGo2AgAgACABMgEANwMADwsgAiACKAIAIgFBBGo2AgAgACABMwEANwMADwsgAiACKAIAIgFBBGo2AgAgACABMAAANwMADwsgAiACKAIAIgFBBGo2AgAgACABMQAANwMADwsgAiACKAIAQQdqQXhxIgFBCGo2AgAgACABKwMAOQMADwsACw8LIAIgAigCACIBQQRqNgIAIAAgATQCADcDAA8LIAIgAigCACIBQQRqNgIAIAAgATUCADcDAA8LIAIgAigCAEEHakF4cSIBQQhqNgIAIAAgASkDADcDAAtvAQV/IAAoAgAiAywAAEEwayIBQQlLBEBBAA8LA0BBfyEEIAJBzJmz5gBNBEBBfyABIAJBCmwiBWogASAFQf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BESACIAYQA0H4+AAoAgBB+PgAQQA2AgBBAUYNAQALIAFCgYCAgBA3AwAgASAENgIUIAEgAzYCECABIAA3AwggBSABNgIcIAFBGGoiAkEAQcwA/AsAQfj4AEEANgIAQSogAhACQfj4ACgCAEH4+ABBADYCAEEBRw0BEAAhAiABIAEoAgAiAUEBazYCACABQQFHDQICQCAFKAIcIgFBf0YNACABIAEoAgQiA0EBazYCBCADQQFHDQAgARAUCwwCCxAAIQIgA0UNASADQQA6AAAgBEUNASADEBQgAhABAAsgBUEgaiQAIAEPCyACEAEACwQAQQELtgMBA38gAUFwcSIDKAIIIgRFBEAgAyECA0AgAigCACIEIAI2AgQgBCICKAIIIgRFDQALCyADIAQ2AgggBCAEKAIAIgJBEGs2AgAgAkEQRgRAIAAhAwNAAkACQCABQQRxRQRAIAMgAUF+cUEEaiIAIAMoAgAiAiABIAJGGzYCACABIAJHDQEDQCAAQXBxIgQoAggiAkUEQCAEIQEDQCABKAIAIgIgATYCBCACIgEoAggiAkUNAAsLIAQgAjYCCAJAIABBCXFBAUcEQAJAIABBCHEiAUUEQCACLQARQQFxDQELQRFBACABGyEBDAILIAIoAgQiAUUEQEEAIQEMAgsgBCABNgIIIAMgAEFzcSADKAIAIgEgACABRiIAGzYCACAARQRAIAQgAjYCCCABIQAMAwsgAhA+DAULIAMgAEFzcSADKAIAIgEgACABRiICGzYCACABIQAgAkUNAQwECyADIAEgAygCACIBIAAgAUYbNgIAIAAgAUcgASEADQALA0AgAigCBCACED4iAg0ACwwCCyADIAFBfnEgAygCACICIAEgAkYiABs2AgAgAA0BCyACIQEMAQsLCwtoAQN/IAAoAgQiAigCACEAAkADQAJAIAICfyAAQQJxRQRAIABBEWsiAUEBckEAIAEbDAELIABBCHFFDQEgAEF2cQsgAigCACIBIAAgAUYiAxs2AgAgASEAIANFDQEMAgsLIAIgABB0CwuUAgICfwF+IwBBEGsiAyQAAn9BACACRQ0AGgNAAkACQAJAQQACfyABQf////8HIAIgAkH/////B08bEEMiBE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AnRqQQE2AgAgAkEBaiECIAVBAWoiBSAARw0ACwsgA0EANgKUASAIEFwhACADQQA2ApgBIANBADYCkAEgAyAANgKcASADIQIjAEEgayIAJAAgAiAKNgI0IABBIGokAEEBBUEACyEBQdn5AC0AABoCQEEMQQQQHCIARQRAQfj4AEEANgIAQRFBBEEMEANB+PgAKAIAQfj4AEEANgIAQQFHDQEQABogChBaIAEEQCACEFkLECYACyAAIAo2AgggACACNgIEIAAgATYCACAADwsAC0cBAn8jAEEwayIAJAAgAEEBNgIYIABBjPAANgIUIABCADcCICAAIABBLGoiATYCHCAAQQxqIgIgASAAQRRqEB4gAhAfEB0ACyYAIAAgAUEBckEQajYCBCAAIAFBAnFFIAFBAUdxIAFBcElxNgIACxkAIAAgAUEBajYCBCAAIAFBf3NBAXE2AgALRwBBBCEBIAJBgAggAyADQYAITxsQeSIDQX9GBEAgAEEAOwABIABBADoAA0HA8wAoAgAhA0EAIQELIAAgAzYCBCAAIAE6AAALTQBBBCEBIAJB/////wcgAyADQf////8HTxsQQyIDQX9GBEAgAEEAOwABIABBADoAA0HA8wAoAgAhA0EAIQELIAAgAzYCBCAAIAE6AAALLgAgASgCACAALQAAQQJ0IgBBhPIAaigCACAAQeTfAGooAgAgASgCBCgCDBEBAAscACABKAIAIAAoAgAgACgCBCABKAIEKAIMEQEACwwAIAAgASkCADcDAAsSACAAQYztADYCBCAAIAE2AgALSwECf0HZ+QAtAAAaIAEoAgQhAiABKAIAIQNBCEEEEBwiAUUEQEEEQQgQNAALIAEgAjYCBCABIAM2AgAgAEGM7QA2AgQgACABNgIAC3kBAX8jAEEgayICJAACfyAAKAIAQYCAgIB4RwRAIAEoAgAgACgCBCAAKAIIIAEoAgQoAgwRAQAMAQsgAiAAKAIMKAIAIgApAgg3AxAgAiAAKQIQNwMYIAIgACkCADcDCCABKAIAIAEoAgQgAkEIahAbCyACQSBqJAAL4QECAn8BfiMAQTBrIgIkACABKAIAQYCAgIB4RgRAIAEoAgwhAyACQQA2AhQgAkKAgICAEDcCDCACIAMoAgAiAykCCDcDICACIAMpAhA3AyggAykCACEEQfj4AEEANgIAIAIgBDcDGEErIAJBDGpBzOgAIAJBGGoQBRpB+PgAKAIAQfj4AEEANgIAQQFGBEAQACACKAIMBEAgAigCEBAUCxABAAsgAiACKAIUIgM2AgggAiACKQIMIgQ3AwAgASADNgIIIAEgBDcCAAsgACABNgIAIABB/OwANgIEIAJBMGokAAv5AgIEfwF+IwBBMGsiAiQAAkAgASgCACIDQYCAgIB4RgRAIAEoAgwhAyACQQA2AhQgAkKAgICAEDcCDCACIAMoAgAiAykCCDcDICACIAMpAhA3AyggAykCACEGQfj4AEEANgIAIAIgBjcDGEErIAJBDGpBzOgAIAJBGGoQBRpB+PgAKAIAQfj4AEEANgIAQQFGBEAQACEBIAIoAgxFDQIgAigCEBAUDAILIAIgAigCFCIDNgIIIAIgAikCDCIGNwMAIAEgAzYCCCABIAY3AgAgASgCACEDCyABKAIIIQUgAUEANgIIIAEoAgQhBCABQoCAgIAQNwIAQdn5AC0AABoCQEEMQQQQHCIBRQRAQfj4AEEANgIAQRFBBEEMEANB+PgAKAIAQfj4AEEANgIAQQFHDQEQACEBIANFDQIgBBAUIAEQAQALIAEgBTYCCCABIAQ2AgQgASADNgIAIABB/OwANgIEIAAgATYCACACQTBqJAAPCwALIAEQAQALnwkCBn8DfiMAQdAEayIDJAAgAyACQQkgARs2AgQgAyABQabVACABGzYCACADQQhqIgdBAEGABPwLACADQgA3A5AEIANBgAQ2AowEIAMgBzYCiAQgADUCACEJIAA1AgQhCiADQdjsADYCoAQgA0IDNwKsBCADIApCgICAgMAEhCIKNwPIBCADIAlCgICAgPAIhCIJNwPABCADIAOtQoCAgIDABIQiCzcDuAQgAyADQbgEaiIINgKoBCADQQQ2AqQEIwBBMGsiASQAQfj4AEEANgIAIAFBBDoACCABIANBiARqNgIQQSsgAUEIakG06AAgA0GgBGoQBSECQfj4ACgCACEEQfj4AEEANgIAAkACQAJAIARBAUYNAAJAAkAgA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BAUDAILEAAhAyAAKAIERQ0BIAAoAggaIAIQFAwBCyABQYAEQcjsABBXAAsgARAUIAMQAQALIANB0ARqJAALtgIBA38jAEEwayIAJABB2PkALQAARQRAIABBAjYCDCAAQbjrADYCCCAAQgE3AhQgACAAQShqrUKAgICAgAGENwMgIAAgATYCKCAAIABBIGo2AhAgACAAQS9qIABBCGoQHgJAAkAgAC0AACIBQQRGDQAgAUEDRw0AIAAoAgQiAigCACEDIAIoAgQiASgCACIEBEBB+PgAQQA2AgAgBCADEAJB+PgAKAIAQfj4AEEANgIAQQFGDQILIAEoAgQEQCABKAIIGiADEBQLIAIQFAsgAEEwaiQADwsQACABKAIEBEAgASgCCBogAxAUCyACEBQQAQALIABBAjYCDCAAQgE3AhQgAEHI6wA2AgggACABNgIAIAAgAK1CgICAgIABhDcDICAAIABBIGo2AhAgAEEIakHY6wAQFgALjAYCB38BfiMAQRBrIgMkACABKAIEIQUgASgCACEHIAAtAAAhCCMAQRBrIgAkAEHZ+QAtAAAaQYAEIQECQAJAAkACQAJAAkBBgARBARAcIgIEQCAAIAI2AgggAEGABDYCBCACQYAEEHoNAgNAQcDzACgCACIEQcQARwRAIAMgBDYCDCADQoCAgIAINwIEIAFFDQggAhAUDAgLQfj4AEEANgIAIAAgATYCDEExIABBBGogAUEBQQFBARAHQfj4ACgCAEH4+ABBADYCAEEBRg0CIAAoAggiAiAAKAIEIgEQekUNAAsMAgtBAUGABEG07gAQJAwECxAAIQEgACgCBEUNAiAAKAIIIQIMAQsgACACECUiBDYCDAJAIAEgBEsEQAJAIARFBEBBASEBIAIQFAwBCyACIAFBASAEED8iAUUNAgsgACAENgIEIAAgATYCCAsgAyAAKQIENwIEIAMgACgCDDYCDAwEC0H4+ABBADYCAEEQQQEgBEHE7gAQBEH4+AAoAgBB+PgAQQA2AgBBAUcNAhAAIQELIAIQFAsgARABAAsACyAAQRBqJAAgAykCCCEJAkACQAJAAkACQCADKAIEIgRBgICAgHhHDQAgCUL/AYNCA1INACAJQi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oAgAgASgCCCIEayAFSQRAIAEgBCAFQQFBARAZCyADQQN0IAJqIQYgASgCCCEEA0AgAigCACEHIAIoAgQiAyABKAIAIARrSwRAIAEgBCADQQFBARAZIAEoAgghBAsgAwRAIAEoAgQgBGogByAD/AoAAAsgASADIARqIgQ2AgggAkEIaiICIAZHDQALCyAAQQQ6AAAgACAFNgIEC1cBAX8gASgCACABKAIIIgRrIANJBEAgASAEIANBAUEBEBkgASgCCCEECyADBEAgASgCBCAEaiACIAP8CgAACyAAIAM2AgQgASADIARqNgIIIABBBDoAAAvqAwEDfyMAQbABayICJAACQAJAAkACQAJAAkACQCAALQAAQQFrDgMBAgMACyACIAAoAgQiAzYCBCACQRhqIgBBAEGAAfwLACADIAAQeEEASA0FIAJBmAFqIgMgACAAECUQRiACQQhqIgQgAxBFQfj4AEEANgIAIAJBAzYCHCACQaDqADYCGCACQgI3AiQgAiACQQRqrUKAgICA4AeENwOgASACIAStQoCAgIDwB4Q3A5gBIAIgAzYCIEErIAEoAgAgASgCBCAAEAUhAEH4+AAoAgBB+PgAQQA2AgBBAUcNAxAAIAIoAggEQCACKAIMEBQLEAEACyAALQABIQAgAkEBNgIcIAJBkMoANgIYIAJCATcCJCACIABBAnQiAEG83gBqKAIANgKcASACIABB3PAAaigCADYCmAEgAiACQZgBaq1CgICAgMAEhDcDCCACIAJBCGo2AiAgASgCACABKAIEIAJBGGoQGyEADAMLIAEgACgCBCIAKAIAIAAoAgQQOyEADAILIAAoAgQiACgCACABIAAoAgQoAhARAAAhAAwBCyACKAIIRQ0AIAIoAgwQFAsgAkGwAWokACAADwsgAkEANgKoASACQQE2ApwBIAJCBDcCoAEgAkGc7gA2ApgBIAJBmAFqQaTuABAWAAvEDAEEfwJ/IwBBwAFrIgIkAAJAAkACQAJAAkACQAJAAkAgAC0AAEEBaw4DAQIDAAsgAiAAKAIENgIMIAEoAgBBodAAQQIgASgCBCgCDBEBACEDIAJBEGoiAEEAOgAFIAAgAzoABCAAIAE2AgAgAEGj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AAC4AAACvKgAACQAAALgqAAAOAAAAPykAAAIAAADGKgAAAQAAAAEAAABcAAAADAAAAAQAAABzAAAAAAAAAAgAAAAEAAAAdAAAAAAAAAAIAAAABAAAAHUAAAB2AAAAdwAAAHgAAAB5AAAAEAAAAAQAAAB6AAAAewAAAHwAAAB9AAAA0yoAABkAAAA/KQAAAgAAAMYqAAABAAAAMykAAAwAAAA/KQAAAgAAAOwqAAAzAAAAHysAAC0AAABMKwAANQAAAIErAAALAAAAoC0AABIAAACyLQAAIgAAAI8AAAANAAAAsi0AACIAAACgAAAAEwAAALItAAAiAAAApwAAABUAAADULQAALAAAAHsAAAANAAAA1C0AACwAAAB5AAAADQAAANQtAAAsAAAAdgAAAA0AAADULQAALAAAAG4AAAAVAAAABC4AACoAAAAxAAAARQAAAAQuAAAqAAAANwAAAA4AAAAELgAAKgAAADgAAABLAAAALi4AABYAAAAELgAAKgAAAEUAAAANAAAABC4AACoAAACEAAAADQAAAEguAAAoAAAA6AAAACMAAABILgAAKAAAAPUAAAA6AAAAcC4AAEUAAAC1LgAAHwAAANQuAAAyAAAARAAAABEAAAAGLwAAFwAAANQuAAAyAAAASgAAABEAAAAdLwAAHAAAANQuAAAyAAAAkQAAABIAAAA0JQAARCUAAFUlAABnJQAAdyUAAIclAACaJQAArCUAALklAADHJQAA3CUAAOglAADzJQAACCYAAB0mAAAsJgAAOiYAAE0mAABzJgAAqyYAAMQmAADbJgAA5yYAAPAmAAD6JgAACicAACEnAAAvJwAAPScAAEonAABeJwAAZicAAIEnAACPJwAAnycAALUnAADKJwAA1ScAAOsnAAD4JwAAAygAAA4oAACMKwAAlCsAAKQrAAC1KwAAxCsAANMrAADlKwAA9isAAAIsAAALLAAAGywAACYsAAAwLAAABiUAAD0sAABKLAAAViwAAGcsAAB5LAAAhywAAJ0sAACpLAAAtCwAALwsAADFLAAA0CwAANssAADoLAAA9CwAAAAtAAASLQAAGi0AACgtAAA0LQAAQy0AAFYtAABhLQAAbC0AAHktAACELQAAji0AAJMtAACsMAAACgAAABwAAAAF\")}function getBinarySync(file){if(ArrayBuffer.isView(file)){return file}if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw\"both async and sync fetching of the wasm failed\"}async function getWasmBinary(binaryFile){return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports[\"u\"];updateMemoryViews();wasmTable=wasmExports[\"H\"];assignWasmExports(wasmExports);removeRunDependency(\"wasm-instantiate\");return wasmExports}addRunDependency(\"wasm-instantiate\");function receiveInstantiationResult(result){return receiveInstance(result[\"instance\"])}var info=getWasmImports();if(Module[\"instantiateWasm\"]){return new Promise((resolve,reject)=>{Module[\"instantiateWasm\"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name=\"ExitStatus\";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var base64Decode=b64=>{var b1,b2,i=0,j=0,bLength=b64.length;var output=new Uint8Array((bLength*3>>2)-(b64[bLength-2]==\"=\")-(b64[bLength-1]==\"=\"));for(;i>4;output[j+1]=b1<<4|b2>>2;output[j+2]=b2<<6|base64ReverseLookup[b64.charCodeAt(i+3)]}return output};var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionLast=0;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var uncaughtExceptionCount=0;var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=ptr}throw exceptionLast};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd)+1;if(sizeabort(\"\");var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||\"./this.program\";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator==\"object\"&&navigator.language||\"C\").replace(\"-\",\"_\")+\".UTF-8\";var env={USER:\"web_user\",LOGNAME:\"web_user\",PATH:\"/\",PWD:\"/\",HOME:\"/home/web_user\",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module[\"onExit\"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var PATH={isAbs:path=>path.charAt(0)===\"/\",splitPath:filename=>{var splitPathRe=/^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last===\".\"){parts.splice(i,1)}else if(last===\"..\"){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift(\"..\")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.slice(-1)===\"/\";path=PATH.normalizeArray(path.split(\"/\").filter(p=>!!p),!isAbsolute).join(\"/\");if(!path&&!isAbsolute){path=\".\"}if(path&&trailingSlash){path+=\"/\"}return(isAbsolute?\"/\":\"\")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return\".\"}if(dir){dir=dir.slice(0,-1)}return root+dir},basename:path=>path&&path.match(/([^\\/]+|\\/)\\/*$/)[1],join:(...paths)=>PATH.normalize(paths.join(\"/\")),join2:(l,r)=>PATH.normalize(l+\"/\"+r)};var initRandomFill=()=>view=>crypto.getRandomValues(view);var randomFill=view=>{(randomFill=initRandomFill())(view)};var PATH_FS={resolve:(...args)=>{var resolvedPath=\"\",resolvedAbsolute=false;for(var i=args.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?args[i]:FS.cwd();if(typeof path!=\"string\"){throw new TypeError(\"Arguments to path.resolve must be strings\")}else if(!path){return\"\"}resolvedPath=path+\"/\"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split(\"/\").filter(p=>!!p),!resolvedAbsolute).join(\"/\");return(resolvedAbsolute?\"/\":\"\")+resolvedPath||\".\"},relative:(from,to)=>{from=PATH_FS.resolve(from).slice(1);to=PATH_FS.resolve(to).slice(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!==\"\")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split(\"/\"));var toParts=trim(to.split(\"/\"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str=\"\";while(idx>10,56320|ch&1023)}}return str};var FS_stdin_getChar_buffer=[];var intArrayFromString=(stringy,dontAddNull,length)=>{var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array};var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var result=null;if(typeof window!=\"undefined\"&&typeof window.prompt==\"function\"){result=window.prompt(\"Input: \");if(result!==null){result+=\"\\n\"}}else{}if(!result){return null}FS_stdin_getChar_buffer=intArrayFromString(result,true)}return FS_stdin_getChar_buffer.shift()};var TTY={ttys:[],init(){},shutdown(){},register(dev,ops){TTY.ttys[dev]={input:[],output:[],ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close(stream){stream.tty.ops.fsync(stream.tty)},fsync(stream){stream.tty.ops.fsync(stream.tty)},read(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i0){out(UTF8ArrayToString(tty.output));tty.output=[]}},ioctl_tcgets(tty){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(tty,optional_actions,data){return 0},ioctl_tiocgwinsz(tty){return[24,80]}},default_tty1_ops:{put_char(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync(tty){if(tty.output?.length>0){err(UTF8ArrayToString(tty.output));tty.output=[]}}}};var mmapAlloc=size=>{abort()};var MEMFS={ops_table:null,mount(mount){return MEMFS.createNode(null,\"/\",16895,0)},createNode(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}MEMFS.ops_table||={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}};var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.atime=node.mtime=node.ctime=Date.now();if(parent){parent.contents[name]=node;parent.atime=parent.mtime=parent.ctime=node.atime}return node},getFileDataAsTypedArray(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.atime);attr.mtime=new Date(node.mtime);attr.ctime=new Date(node.ctime);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr(node,attr){for(const key of[\"mode\",\"atime\",\"mtime\",\"ctime\"]){if(attr[key]!=null){node[key]=attr[key]}}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup(parent,name){throw MEMFS.doesNotExistError},mknod(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename(old_node,new_dir,new_name){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){if(FS.isDir(old_node.mode)){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}FS.hashRemoveNode(new_node)}delete old_node.parent.contents[old_node.name];new_dir.contents[new_name]=old_node;old_node.name=new_name;new_dir.ctime=new_dir.mtime=old_node.parent.ctime=old_node.parent.mtime=Date.now()},unlink(parent,name){delete parent.contents[name];parent.ctime=parent.mtime=Date.now()},rmdir(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.ctime=parent.mtime=Date.now()},readdir(node){return[\".\",\"..\",...Object.keys(node.contents)]},symlink(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length{var arrayBuffer=await readAsync(url);return new Uint8Array(arrayBuffer)};var FS_createDataFile=(...args)=>FS.createDataFile(...args);var getUniqueRunDependency=id=>id;var preloadPlugins=[];var FS_handledByPreloadPlugin=(byteArray,fullname,finish,onerror)=>{if(typeof Browser!=\"undefined\")Browser.init();var handled=false;preloadPlugins.forEach(plugin=>{if(handled)return;if(plugin[\"canHandle\"](fullname)){plugin[\"handle\"](byteArray,fullname,finish,onerror);handled=true}});return handled};var FS_createPreloadedFile=(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency(`cp ${fullname}`);function processData(byteArray){function finish(byteArray){preFinish?.();if(!dontCreateFile){FS_createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}onload?.();removeRunDependency(dep)}if(FS_handledByPreloadPlugin(byteArray,fullname,finish,()=>{onerror?.();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url==\"string\"){asyncLoad(url).then(processData,onerror)}else{processData(url)}};var FS_modeStringToFlags=str=>{var flagModes={r:0,\"r+\":2,w:512|64|1,\"w+\":512|64|2,a:1024|64|1,\"a+\":1024|64|2};var flags=flagModes[str];if(typeof flags==\"undefined\"){throw new Error(`Unknown file open mode: ${str}`)}return flags};var FS_getMode=(canRead,canWrite)=>{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode};var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:\"/\",initialized:false,ignorePermissions:true,filesystems:null,syncFSRequests:0,readFiles:{},ErrnoError:class{name=\"ErrnoError\";constructor(errno){this.errno=errno}},FSStream:class{shared={};get object(){return this.node}set object(val){this.node=val}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(val){this.shared.flags=val}get position(){return this.shared.position}set position(val){this.shared.position=val}},FSNode:class{node_ops={};stream_ops={};readMode=292|73;writeMode=146;mounted=null;constructor(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.rdev=rdev;this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(val){val?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(val){val?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return FS.isDir(this.mode)}get isDevice(){return FS.isChrdev(this.mode)}},lookupPath(path,opts={}){if(!path){throw new FS.ErrnoError(44)}opts.follow_mount??=true;if(!PATH.isAbs(path)){path=FS.cwd()+\"/\"+path}linkloop:for(var nlinks=0;nlinks<40;nlinks++){var parts=path.split(\"/\").filter(p=>!!p);var current=FS.root;var current_path=\"/\";for(var i=0;i>>0)%FS.nameTable.length},hashAddNode(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode(parent,name){var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode(parent,name,mode,rdev){var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode(node){FS.hashRemoveNode(node)},isRoot(node){return node===node.parent},isMountpoint(node){return!!node.mounted},isFile(mode){return(mode&61440)===32768},isDir(mode){return(mode&61440)===16384},isLink(mode){return(mode&61440)===40960},isChrdev(mode){return(mode&61440)===8192},isBlkdev(mode){return(mode&61440)===24576},isFIFO(mode){return(mode&61440)===4096},isSocket(mode){return(mode&49152)===49152},flagsToPermissionString(flag){var perms=[\"r\",\"w\",\"rw\"][flag&3];if(flag&512){perms+=\"w\"}return perms},nodePermissions(node,perms){if(FS.ignorePermissions){return 0}if(perms.includes(\"r\")&&!(node.mode&292)){return 2}else if(perms.includes(\"w\")&&!(node.mode&146)){return 2}else if(perms.includes(\"x\")&&!(node.mode&73)){return 2}return 0},mayLookup(dir){if(!FS.isDir(dir.mode))return 54;var errCode=FS.nodePermissions(dir,\"x\");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate(dir,name){if(!FS.isDir(dir.mode)){return 54}try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,\"wx\")},mayDelete(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,\"wx\");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen(node,flags){if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!==\"r\"||flags&(512|64)){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},checkOpExists(op,err){if(!op){throw new FS.ErrnoError(err)}return op},MAX_OPEN_FDS:4096,nextfd(){for(var fd=0;fd<=FS.MAX_OPEN_FDS;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStreamChecked(fd){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}return stream},getStream:fd=>FS.streams[fd],createStream(stream,fd=-1){stream=Object.assign(new FS.FSStream,stream);if(fd==-1){fd=FS.nextfd()}stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream(fd){FS.streams[fd]=null},dupStream(origStream,fd=-1){var stream=FS.createStream(origStream,fd);stream.stream_ops?.dup?.(stream);return stream},doSetAttr(stream,node,attr){var setattr=stream?.stream_ops.setattr;var arg=setattr?stream:node;setattr??=node.node_ops.setattr;FS.checkOpExists(setattr,63);setattr(arg,attr)},chrdev_stream_ops:{open(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;stream.stream_ops.open?.(stream)},llseek(){throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push(...m.mounts)}return mounts},syncfs(populate,callback){if(typeof populate==\"function\"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`)}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount(type,opts,mountpoint){var root=mountpoint===\"/\";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type,opts,mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup(parent,name){return parent.node_ops.lookup(parent,name)},mknod(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name){throw new FS.ErrnoError(28)}if(name===\".\"||name===\"..\"){throw new FS.ErrnoError(20)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},statfs(path){return FS.statfsNode(FS.lookupPath(path,{follow:true}).node)},statfsStream(stream){return FS.statfsNode(stream.node)},statfsNode(node){var rtn={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:FS.nextInode,ffree:FS.nextInode-1,fsid:42,flags:2,namelen:255};if(node.node_ops.statfs){Object.assign(rtn,node.node_ops.statfs(node.mount.opts.root))}return rtn},create(path,mode=438){mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir(path,mode=511){mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree(path,mode){var dirs=path.split(\"/\");var d=\"\";for(var dir of dirs){if(!dir)continue;if(d||PATH.isAbs(path))d+=\"/\";d+=dir;try{FS.mkdir(d,mode)}catch(e){if(e.errno!=20)throw e}}},mkdev(path,mode,dev){if(typeof dev==\"undefined\"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink(oldpath,newpath){if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename(old_path,new_path){var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!==\".\"){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!==\".\"){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,\"w\");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name);old_node.parent=new_dir}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir(path){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;var readdir=FS.checkOpExists(node.node_ops.readdir,54);return readdir(node)},unlink(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink(path){var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return link.node_ops.readlink(link)},stat(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;var getattr=FS.checkOpExists(node.node_ops.getattr,63);return getattr(node)},fstat(fd){var stream=FS.getStreamChecked(fd);var node=stream.node;var getattr=stream.stream_ops.getattr;var arg=getattr?stream:node;getattr??=node.node_ops.getattr;FS.checkOpExists(getattr,63);return getattr(arg)},lstat(path){return FS.stat(path,true)},doChmod(stream,node,mode,dontFollow){FS.doSetAttr(stream,node,{mode:mode&4095|node.mode&~4095,ctime:Date.now(),dontFollow})},chmod(path,mode,dontFollow){var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}FS.doChmod(null,node,mode,dontFollow)},lchmod(path,mode){FS.chmod(path,mode,true)},fchmod(fd,mode){var stream=FS.getStreamChecked(fd);FS.doChmod(stream,stream.node,mode,false)},doChown(stream,node,dontFollow){FS.doSetAttr(stream,node,{timestamp:Date.now(),dontFollow})},chown(path,uid,gid,dontFollow){var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}FS.doChown(null,node,dontFollow)},lchown(path,uid,gid){FS.chown(path,uid,gid,true)},fchown(fd,uid,gid){var stream=FS.getStreamChecked(fd);FS.doChown(stream,stream.node,false)},doTruncate(stream,node,len){if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,\"w\");if(errCode){throw new FS.ErrnoError(errCode)}FS.doSetAttr(stream,node,{size:len,timestamp:Date.now()})},truncate(path,len){if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}FS.doTruncate(null,node,len)},ftruncate(fd,len){var stream=FS.getStreamChecked(fd);if(len<0||(stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.doTruncate(stream,stream.node,len)},utime(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;var setattr=FS.checkOpExists(node.node_ops.setattr,63);setattr(node,{atime,mtime})},open(path,flags,mode=438){if(path===\"\"){throw new FS.ErrnoError(44)}flags=typeof flags==\"string\"?FS_modeStringToFlags(flags):flags;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;var isDirPath;if(typeof path==\"object\"){node=path}else{isDirPath=path.endsWith(\"/\");var lookup=FS.lookupPath(path,{follow:!(flags&131072),noent_okay:true});node=lookup.node;path=lookup.path}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else if(isDirPath){throw new FS.ErrnoError(31)}else{node=FS.mknod(path,mode|511,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node,path:FS.getPath(node),flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(created){FS.chmod(node,mode&511)}if(Module[\"logReadFiles\"]&&!(flags&1)){if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close(stream){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed(stream){return stream.fd===null},llseek(stream,offset,whence){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read(stream,buffer,offset,length,position){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!=\"undefined\";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write(stream,buffer,offset,length,position,canOwn){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!=\"undefined\";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},mmap(stream,length,position,prot,flags){if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}if(!length){throw new FS.ErrnoError(28)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync(stream,buffer,offset,length,mmapFlags){if(!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},ioctl(stream,cmd,arg){if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile(path,opts={}){opts.flags=opts.flags||0;opts.encoding=opts.encoding||\"binary\";if(opts.encoding!==\"utf8\"&&opts.encoding!==\"binary\"){throw new Error(`Invalid encoding type \"${opts.encoding}\"`)}var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding===\"utf8\"){buf=UTF8ArrayToString(buf)}FS.close(stream);return buf},writeFile(path,data,opts={}){opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data==\"string\"){data=new Uint8Array(intArrayFromString(data,true))}if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error(\"Unsupported data type\")}FS.close(stream)},cwd:()=>FS.currentPath,chdir(path){var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,\"x\");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories(){FS.mkdir(\"/tmp\");FS.mkdir(\"/home\");FS.mkdir(\"/home/web_user\")},createDefaultDevices(){FS.mkdir(\"/dev\");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length,llseek:()=>0});FS.mkdev(\"/dev/null\",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev(\"/dev/tty\",FS.makedev(5,0));FS.mkdev(\"/dev/tty1\",FS.makedev(6,0));var randomBuffer=new Uint8Array(1024),randomLeft=0;var randomByte=()=>{if(randomLeft===0){randomFill(randomBuffer);randomLeft=randomBuffer.byteLength}return randomBuffer[--randomLeft]};FS.createDevice(\"/dev\",\"random\",randomByte);FS.createDevice(\"/dev\",\"urandom\",randomByte);FS.mkdir(\"/dev/shm\");FS.mkdir(\"/dev/shm/tmp\")},createSpecialDirectories(){FS.mkdir(\"/proc\");var proc_self=FS.mkdir(\"/proc/self\");FS.mkdir(\"/proc/self/fd\");FS.mount({mount(){var node=FS.createNode(proc_self,\"fd\",16895,73);node.stream_ops={llseek:MEMFS.stream_ops.llseek};node.node_ops={lookup(parent,name){var fd=+name;var stream=FS.getStreamChecked(fd);var ret={parent:null,mount:{mountpoint:\"fake\"},node_ops:{readlink:()=>stream.path},id:fd+1};ret.parent=ret;return ret},readdir(){return Array.from(FS.streams.entries()).filter(([k,v])=>v).map(([k,v])=>k.toString())}};return node}},{},\"/proc/self/fd\")},createStandardStreams(input,output,error){if(input){FS.createDevice(\"/dev\",\"stdin\",input)}else{FS.symlink(\"/dev/tty\",\"/dev/stdin\")}if(output){FS.createDevice(\"/dev\",\"stdout\",null,output)}else{FS.symlink(\"/dev/tty\",\"/dev/stdout\")}if(error){FS.createDevice(\"/dev\",\"stderr\",null,error)}else{FS.symlink(\"/dev/tty1\",\"/dev/stderr\")}var stdin=FS.open(\"/dev/stdin\",0);var stdout=FS.open(\"/dev/stdout\",1);var stderr=FS.open(\"/dev/stderr\",1)},staticInit(){FS.nameTable=new Array(4096);FS.mount(MEMFS,{},\"/\");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={MEMFS}},init(input,output,error){FS.initialized=true;input??=Module[\"stdin\"];output??=Module[\"stdout\"];error??=Module[\"stderr\"];FS.createStandardStreams(input,output,error)},quit(){FS.initialized=false;for(var stream of FS.streams){if(stream){FS.close(stream)}}},findObject(path,dontResolveLastLink){var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath(path,dontResolveLastLink){try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path===\"/\"}catch(e){ret.error=e.errno}return ret},createPath(parent,path,canRead,canWrite){parent=typeof parent==\"string\"?parent:FS.getPath(parent);var parts=path.split(\"/\").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){if(e.errno!=20)throw e}parent=current}return current},createFile(parent,name,properties,canRead,canWrite){var path=PATH.join2(typeof parent==\"string\"?parent:FS.getPath(parent),name);var mode=FS_getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile(parent,name,data,canRead,canWrite,canOwn){var path=name;if(parent){parent=typeof parent==\"string\"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS_getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data==\"string\"){var arr=new Array(data.length);for(var i=0,len=data.length;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]}setDataGetter(getter){this.getter=getter}cacheLength(){var xhr=new XMLHttpRequest;xhr.open(\"HEAD\",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error(\"Couldn't load \"+url+\". Status: \"+xhr.status);var datalength=Number(xhr.getResponseHeader(\"Content-length\"));var header;var hasByteServing=(header=xhr.getResponseHeader(\"Accept-Ranges\"))&&header===\"bytes\";var usesGzip=(header=xhr.getResponseHeader(\"Content-Encoding\"))&&header===\"gzip\";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error(\"invalid range (\"+from+\", \"+to+\") or no bytes requested!\");if(to>datalength-1)throw new Error(\"only \"+datalength+\" bytes available! programmer error!\");var xhr=new XMLHttpRequest;xhr.open(\"GET\",url,false);if(datalength!==chunkSize)xhr.setRequestHeader(\"Range\",\"bytes=\"+from+\"-\"+to);xhr.responseType=\"arraybuffer\";if(xhr.overrideMimeType){xhr.overrideMimeType(\"text/plain; charset=x-user-defined\")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error(\"Couldn't load \"+url+\". Status: \"+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||\"\",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==\"undefined\"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==\"undefined\")throw new Error(\"doXHR failed!\");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out(\"LazyFiles on gzip forces download of the whole file when length is accessed\")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true}get length(){if(!this.lengthKnown){this.cacheLength()}return this._length}get chunkSize(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}if(typeof XMLHttpRequest!=\"undefined\"){if(!ENVIRONMENT_IS_WORKER)throw\"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc\";var lazyArray=new LazyUint8Array;var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=(...args)=>{FS.forceLoadFile(node);return fn(...args)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr,allocated:true}};node.stream_ops=stream_ops;return node}};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):\"\";var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=SYSCALLS.getStreamFromFD(dirfd);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return dir+\"/\"+path},writeStat(buf,stat){HEAP32[buf>>2]=stat.dev;HEAP32[buf+4>>2]=stat.mode;HEAPU32[buf+8>>2]=stat.nlink;HEAP32[buf+12>>2]=stat.uid;HEAP32[buf+16>>2]=stat.gid;HEAP32[buf+20>>2]=stat.rdev;HEAP64[buf+24>>3]=BigInt(stat.size);HEAP32[buf+32>>2]=4096;HEAP32[buf+36>>2]=stat.blocks;var atime=stat.atime.getTime();var mtime=stat.mtime.getTime();var ctime=stat.ctime.getTime();HEAP64[buf+40>>3]=BigInt(Math.floor(atime/1e3));HEAPU32[buf+48>>2]=atime%1e3*1e3*1e3;HEAP64[buf+56>>3]=BigInt(Math.floor(mtime/1e3));HEAPU32[buf+64>>2]=mtime%1e3*1e3*1e3;HEAP64[buf+72>>3]=BigInt(Math.floor(ctime/1e3));HEAPU32[buf+80>>2]=ctime%1e3*1e3*1e3;HEAP64[buf+88>>3]=BigInt(stat.ino);return 0},writeStatFs(buf,stats){HEAP32[buf+4>>2]=stats.bsize;HEAP32[buf+40>>2]=stats.bsize;HEAP32[buf+8>>2]=stats.blocks;HEAP32[buf+12>>2]=stats.bfree;HEAP32[buf+16>>2]=stats.bavail;HEAP32[buf+20>>2]=stats.files;HEAP32[buf+24>>2]=stats.ffree;HEAP32[buf+28>>2]=stats.fsid;HEAP32[buf+44>>2]=stats.flags;HEAP32[buf+36>>2]=stats.namelen},doMsync(addr,stream,len,flags,offset){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(43)}if(flags&2){return 0}var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},getStreamFromFD(fd){var stream=FS.getStreamChecked(fd);return stream},varargs:undefined,getStr(ptr){var ret=UTF8ToString(ptr);return ret}};function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>numINT53_MAX?NaN:Number(num);function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);try{if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);HEAP64[newOffset>>3]=BigInt(stream.position);if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var doWritev=(stream,iov,iovcnt,offset)=>{var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2]=num;return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var getCFunc=ident=>{var func=Module[\"_\"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType===\"string\"){return UTF8ToString(ret)}if(returnType===\"boolean\")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i{var numericArgs=!argTypes||argTypes.every(type=>type===\"number\"||type===\"boolean\");var numericRet=returnType!==\"string\";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};for(var base64ReverseLookup=new Uint8Array(123),i=25;i>=0;--i){base64ReverseLookup[48+i]=52+i;base64ReverseLookup[65+i]=i;base64ReverseLookup[97+i]=26+i}base64ReverseLookup[43]=62;base64ReverseLookup[47]=63;FS.createPreloadedFile=FS_createPreloadedFile;FS.staticInit();MEMFS.doesNotExistError=new FS.ErrnoError(44);MEMFS.doesNotExistError.stack=\"\";{if(Module[\"noExitRuntime\"])noExitRuntime=Module[\"noExitRuntime\"];if(Module[\"preloadPlugins\"])preloadPlugins=Module[\"preloadPlugins\"];if(Module[\"print\"])out=Module[\"print\"];if(Module[\"printErr\"])err=Module[\"printErr\"];if(Module[\"wasmBinary\"])wasmBinary=Module[\"wasmBinary\"];if(Module[\"arguments\"])arguments_=Module[\"arguments\"];if(Module[\"thisProgram\"])thisProgram=Module[\"thisProgram\"]}Module[\"ccall\"]=ccall;Module[\"cwrap\"]=cwrap;var _AecNew,_AecCancelEcho,_AecDestroy,_malloc,_free,_setThrew,__emscripten_tempret_set,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_can_catch;function assignWasmExports(wasmExports){Module[\"_AecNew\"]=_AecNew=wasmExports[\"w\"];Module[\"_AecCancelEcho\"]=_AecCancelEcho=wasmExports[\"x\"];Module[\"_AecDestroy\"]=_AecDestroy=wasmExports[\"y\"];Module[\"_malloc\"]=_malloc=wasmExports[\"z\"];Module[\"_free\"]=_free=wasmExports[\"A\"];_setThrew=wasmExports[\"B\"];__emscripten_tempret_set=wasmExports[\"C\"];__emscripten_stack_restore=wasmExports[\"D\"];__emscripten_stack_alloc=wasmExports[\"E\"];_emscripten_stack_get_current=wasmExports[\"F\"];___cxa_can_catch=wasmExports[\"G\"]}var wasmImports={a:___cxa_find_matching_catch_2,q:___cxa_throw,b:___resumeException,p:___syscall_getcwd,r:__abort_js,t:_emscripten_resize_heap,n:_environ_get,o:_environ_sizes_get,k:_exit,s:_fd_close,l:_fd_seek,g:_fd_write,i:invoke_ii,f:invoke_iiii,m:invoke_iiiiii,c:invoke_vi,d:invoke_vii,e:invoke_viii,j:invoke_viiii,h:invoke_viiiii};var wasmExports=await createWasm();function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module[\"calledRun\"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module[\"onRuntimeInitialized\"]?.();postRun()}if(Module[\"setStatus\"]){Module[\"setStatus\"](\"Running...\");setTimeout(()=>{setTimeout(()=>Module[\"setStatus\"](\"\"),1);doRun()},1)}else{doRun()}}function preInit(){if(Module[\"preInit\"]){if(typeof Module[\"preInit\"]==\"function\")Module[\"preInit\"]=[Module[\"preInit\"]];while(Module[\"preInit\"].length>0){Module[\"preInit\"].shift()()}}}preInit();run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}\n\n\n return moduleRtn;\n}\n);\n})();\nif (typeof exports === 'object' && typeof module === 'object') {\n module.exports = createAecModule;\n // This default export looks redundant, but it allows TS to import this\n // commonjs style module.\n module.exports.default = createAecModule;\n} else if (typeof define === 'function' && define['amd'])\n define([], () => createAecModule);\n"], ["/glass/src/features/common/repositories/user/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\n\nlet authService = null;\n\nfunction getAuthService() {\n if (!authService) {\n authService = require('../../services/authService');\n }\n return authService;\n}\n\nfunction getBaseRepository() {\n const service = getAuthService();\n if (!service) {\n throw new Error('AuthService could not be loaded for the user repository.');\n }\n const user = service.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst userRepositoryAdapter = {\n findOrCreate: (user) => {\n // This function receives the full user object, which includes the uid. No need to inject.\n return getBaseRepository().findOrCreate(user);\n },\n \n getById: () => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().getById(uid);\n },\n\n\n\n update: (updateData) => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().update({ uid, ...updateData });\n },\n\n deleteById: () => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().deleteById(uid);\n }\n};\n\nmodule.exports = {\n ...userRepositoryAdapter\n}; "], ["/glass/src/features/listen/stt/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst sttRepositoryAdapter = {\n addTranscript: ({ sessionId, speaker, text }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().addTranscript({ uid, sessionId, speaker, text });\n },\n getAllTranscriptsBySessionId: (sessionId) => {\n return getBaseRepository().getAllTranscriptsBySessionId(sessionId);\n }\n};\n\nmodule.exports = sttRepositoryAdapter; "], ["/glass/src/features/listen/summary/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst summaryRepositoryAdapter = {\n saveSummary: ({ sessionId, tldr, text, bullet_json, action_json, model }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model });\n },\n getSummaryBySessionId: (sessionId) => {\n return getBaseRepository().getSummaryBySessionId(sessionId);\n }\n};\n\nmodule.exports = summaryRepositoryAdapter; "], ["/glass/src/features/settings/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst settingsRepositoryAdapter = {\n getPresets: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getPresets(uid);\n },\n\n getPresetTemplates: () => {\n return getBaseRepository().getPresetTemplates();\n },\n\n createPreset: (options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().createPreset({ uid, ...options });\n },\n\n updatePreset: (id, options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().updatePreset(id, options, uid);\n },\n\n deletePreset: (id) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().deletePreset(id, uid);\n },\n\n getAutoUpdate: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getAutoUpdate(uid);\n },\n\n setAutoUpdate: (isEnabled) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().setAutoUpdate(uid, isEnabled);\n },\n};\n\nmodule.exports = settingsRepositoryAdapter;\n"], ["/glass/src/features/common/repositories/preset/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst presetRepositoryAdapter = {\n getPresets: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getPresets(uid);\n },\n\n getPresetTemplates: () => {\n return getBaseRepository().getPresetTemplates();\n },\n\n create: (options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().create({ uid, ...options });\n },\n\n update: (id, options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().update(id, options, uid);\n },\n\n delete: (id) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().delete(id, uid);\n },\n};\n\nmodule.exports = presetRepositoryAdapter; "], ["/glass/src/features/common/repositories/permission/index.js", "const sqliteRepository = require('./sqlite.repository');\n\n// This repository is not user-specific, so we always return sqlite.\nfunction getRepository() {\n return sqliteRepository;\n}\n\nmodule.exports = {\n markKeychainCompleted: (...args) => getRepository().markKeychainCompleted(...args),\n checkKeychainCompleted: (...args) => getRepository().checkKeychainCompleted(...args),\n}; "], ["/glass/src/ui/listen/audioCore/renderer.js", "// renderer.js\nconst listenCapture = require('./listenCapture.js');\nconst params = new URLSearchParams(window.location.search);\nconst isListenView = params.get('view') === 'listen';\n\n\nwindow.pickleGlass = {\n startCapture: listenCapture.startCapture,\n stopCapture: listenCapture.stopCapture,\n isLinux: listenCapture.isLinux,\n isMacOS: listenCapture.isMacOS,\n captureManualScreenshot: listenCapture.captureManualScreenshot,\n getCurrentScreenshot: listenCapture.getCurrentScreenshot,\n};\n\n\nwindow.api.renderer.onChangeListenCaptureState((_event, { status }) => {\n if (!isListenView) {\n console.log('[Renderer] Non-listen view: ignoring capture-state change');\n return;\n }\n if (status === \"stop\") {\n console.log('[Renderer] Session ended – stopping local capture');\n listenCapture.stopCapture();\n } else {\n console.log('[Renderer] Session initialized – starting local capture');\n listenCapture.startCapture();\n }\n});\n"], ["/glass/notarize.js", "const { notarize } = require('@electron/notarize');\n\nexports.notarizeApp = async function (context) {\n if (context.electronPlatformName !== 'darwin') {\n return;\n }\n\n console.log(' notarizing a macOS build!');\n\n const { appOutDir } = context;\n const appName = context.packager.appInfo.productFilename;\n const appPath = `${appOutDir}/${appName}.app`;\n\n if (!process.env.APPLE_ID || !process.env.APPLE_ID_PASSWORD || !process.env.APPLE_TEAM_ID) {\n throw new Error('APPLE_ID, APPLE_ID_PASSWORD, and APPLE_TEAM_ID environment variables are required for notarization.');\n }\n\n await notarize({\n appBundleId: 'com.pickle.glass',\n appPath: appPath,\n appleId: process.env.APPLE_ID,\n appleIdPassword: process.env.APPLE_ID_PASSWORD,\n teamId: process.env.APPLE_TEAM_ID,\n });\n\n console.log(`Successfully notarized ${appName}`);\n}; "], ["/glass/src/features/common/prompts/promptBuilder.js", "const { profilePrompts } = require('./promptTemplates.js');\n\nfunction buildSystemPrompt(promptParts, customPrompt = '', googleSearchEnabled = true) {\n const sections = [promptParts.intro, '\\n\\n', promptParts.formatRequirements];\n\n if (googleSearchEnabled) {\n sections.push('\\n\\n', promptParts.searchUsage);\n }\n\n sections.push('\\n\\n', promptParts.content, '\\n\\nUser-provided context\\n-----\\n', customPrompt, '\\n-----\\n\\n', promptParts.outputInstructions);\n\n return sections.join('');\n}\n\nfunction getSystemPrompt(profile, customPrompt = '', googleSearchEnabled = true) {\n const promptParts = profilePrompts[profile] || profilePrompts.interview;\n return buildSystemPrompt(promptParts, customPrompt, googleSearchEnabled);\n}\n\nmodule.exports = {\n getSystemPrompt,\n};\n"], ["/glass/src/features/common/config/checksums.js", "const DOWNLOAD_CHECKSUMS = {\n ollama: {\n dmg: {\n url: 'https://ollama.com/download/Ollama.dmg',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n exe: {\n url: 'https://ollama.com/download/OllamaSetup.exe',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n linux: {\n url: 'curl -fsSL https://ollama.com/install.sh | sh',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n }\n },\n whisper: {\n models: {\n 'whisper-tiny': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-tiny.bin',\n sha256: 'be07e048e1e599ad46341c8d2a135645097a538221678b7acdd1b1919c6e1b21'\n },\n 'whisper-base': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-base.bin',\n sha256: '60ed5bc3dd14eea856493d334349b405782ddcaf0028d4b5df4088345fba2efe'\n },\n 'whisper-small': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-small.bin',\n sha256: '1be3a9b2063867b937e64e2ec7483364a79917e157fa98c5d94b5c1fffea987b'\n },\n 'whisper-medium': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-medium.bin',\n sha256: '6c14d5adee5f86394037b4e4e8b59f1673b6cee10e3cf0b11bbdbee79c156208'\n }\n },\n binaries: {\n 'v1.7.6': {\n mac: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-mac-x64.zip',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n windows: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-win-x64.zip',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n linux: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-linux-x64.tar.gz',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n }\n }\n }\n }\n};\n\nmodule.exports = { DOWNLOAD_CHECKSUMS };"], ["/glass/pickleglass_web/backend_node/middleware/auth.js", "function identifyUser(req, res, next) {\n const userId = req.get('X-User-ID');\n\n if (userId) {\n req.uid = userId;\n } else {\n req.uid = 'default_user';\n }\n \n next();\n}\n\nmodule.exports = { identifyUser }; "], ["/glass/src/bridge/windowBridge.js", "// src/bridge/windowBridge.js\nconst { ipcMain, shell } = require('electron');\n\n// Bridge는 단순히 IPC 핸들러를 등록하는 역할만 함 (비즈니스 로직 없음)\nmodule.exports = {\n initialize() {\n // initialize 시점에 windowManager를 require하여 circular dependency 문제 해결\n const windowManager = require('../window/windowManager');\n \n // 기존 IPC 핸들러들\n ipcMain.handle('toggle-content-protection', () => windowManager.toggleContentProtection());\n ipcMain.handle('resize-header-window', (event, args) => windowManager.resizeHeaderWindow(args));\n ipcMain.handle('get-content-protection-status', () => windowManager.getContentProtectionStatus());\n ipcMain.on('show-settings-window', () => windowManager.showSettingsWindow());\n ipcMain.on('hide-settings-window', () => windowManager.hideSettingsWindow());\n ipcMain.on('cancel-hide-settings-window', () => windowManager.cancelHideSettingsWindow());\n\n ipcMain.handle('open-login-page', () => windowManager.openLoginPage());\n ipcMain.handle('open-personalize-page', () => windowManager.openLoginPage());\n ipcMain.handle('move-window-step', (event, direction) => windowManager.moveWindowStep(direction));\n ipcMain.handle('open-external', (event, url) => shell.openExternal(url));\n\n // Newly moved handlers from windowManager\n ipcMain.on('header-state-changed', (event, state) => windowManager.handleHeaderStateChanged(state));\n ipcMain.on('header-animation-finished', (event, state) => windowManager.handleHeaderAnimationFinished(state));\n ipcMain.handle('get-header-position', () => windowManager.getHeaderPosition());\n ipcMain.handle('move-header-to', (event, newX, newY) => windowManager.moveHeaderTo(newX, newY));\n ipcMain.handle('adjust-window-height', (event, { winName, height }) => windowManager.adjustWindowHeight(winName, height));\n },\n\n notifyFocusChange(win, isFocused) {\n win.webContents.send('window:focus-change', isFocused);\n }\n};"], ["/glass/pickleglass_web/tailwind.config.js", "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n content: [\n './pages/**/*.{js,ts,jsx,tsx,mdx}',\n './components/**/*.{js,ts,jsx,tsx,mdx}',\n './app/**/*.{js,ts,jsx,tsx,mdx}',\n ],\n theme: {\n extend: {\n colors: {\n primary: '#3b82f6',\n secondary: '#64748b',\n accent: '#06b6d4',\n 'subtle-bg': '#f8f7f4',\n 'subtle-active-bg': '#e7e5e4',\n },\n },\n },\n plugins: [],\n} "], ["/glass/pickleglass_web/next.config.js", "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n reactStrictMode: true,\n swcMinify: true,\n output: 'export',\n\n images: { unoptimized: true },\n}\n\nmodule.exports = nextConfig "], ["/glass/src/bridge/internalBridge.js", "// src/bridge/internalBridge.js\nconst { EventEmitter } = require('events');\n\n// FeatureCore와 WindowCore를 잇는 내부 이벤트 버스\nconst internalBridge = new EventEmitter();\nmodule.exports = internalBridge;\n\n// 예시 이벤트\n// internalBridge.on('content-protection-changed', (enabled) => {\n// // windowManager에서 처리\n// });"], ["/glass/pickleglass_web/postcss.config.js", "module.exports = {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n} "], ["/glass/src/features/shortcuts/repositories/index.js", "module.exports = require('./sqlite.repository'); "], ["/glass/preload.js", ""]], "task_instance_info": {"created_time": "2025-08-21 00:01:29", "created_task_model": "DeepSeek-R1", "function_skeleton": "function upsertKeybinds (keybinds) {}", "code_description": "This code segment functions to: Perform batch database updates or insertions based on unique constraint checks while maintaining transactional integrity and timestamp tracking for data modifications."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\nfunction upsertKeybinds(keybinds) {\n const db = sqliteClient.getDb();\n const query = `\n INSERT INTO shortcuts (name, description, key_combination, category)\n VALUES (@name, @description, @key_combination, @category)\n ON CONFLICT(name) DO UPDATE SET\n description = excluded.description,\n key_combination = excluded.key_combination,\n category = excluded.category\n `;\n \n const transaction = db.transaction();\n try {\n const stmt = transaction.prepare(query);\n \n keybinds.forEach(keybind => {\n stmt.run({\n name: keybind.name,\n description: keybind.description,\n key_combination: keybind.key_combination,\n category: keybind.category\n });\n });\n \n transaction.commit();\n \n // Generate cache busting hash\n const hash = crypto.createHash('md5')\n .update(Date.now().toString())\n .digest('hex');\n \n return hash;\n } catch (error) {\n transaction.rollback();\n console.error('[DB] Failed to upsert keybinds:', error);\n return null;\n }\n}\n[TASK_END]\n```", "inference_time": "2025-08-21 00-01-51"}, "editdistance_info": {"edit_distance": 31.25, "calculate_time": "2025-08-21 00:01:51", "true_code_clean": "function upsertKeybinds(keybinds) {\n if (!keybinds || keybinds.length === 0) return;\n const db = sqliteClient.getDb();\n const upsert = db.transaction((items) => {\n const query = `\n INSERT INTO shortcuts (action, accelerator, created_at)\n VALUES (@action, @accelerator, @created_at)\n ON CONFLICT(action) DO UPDATE SET\n accelerator = excluded.accelerator;\n `;\n const insert = db.prepare(query);\n for (const item of items) {\n insert.run({\n action: item.action,\n accelerator: item.accelerator,\n created_at: Math.floor(Date.now() / 1000)\n });\n }\n });\n try {\n upsert(keybinds);\n } catch (error) {\n console.error('[DB] Failed to upsert keybinds:', error);\n throw error;\n }\n}", "predict_code_clean": "function upsertKeybinds(keybinds) {\n const db = sqliteClient.getDb();\n const query = `\n INSERT INTO shortcuts (name, description, key_combination, category)\n VALUES (@name, @description, @key_combination, @category)\n ON CONFLICT(name) DO UPDATE SET\n description = excluded.description,\n key_combination = excluded.key_combination,\n category = excluded.category\n `;\n const transaction = db.transaction();\n try {\n const stmt = transaction.prepare(query);\n keybinds.forEach(keybind => {\n stmt.run({\n name: keybind.name,\n description: keybind.description,\n key_combination: keybind.key_combination,\n category: keybind.category\n });\n });\n transaction.commit();\n const hash = crypto.createHash('md5')\n .update(Date.now().toString())\n .digest('hex');\n return hash;\n } catch (error) {\n transaction.rollback();\n console.error('[DB] Failed to upsert keybinds:', error);\n return null;\n }\n}"}} {"repo_name": "glass", "file_name": "/glass/src/features/ask/repositories/sqlite.repository.js", "inference_info": {"prefix_code": "const sqliteClient = require('../../common/services/sqliteClient');\n\n", "suffix_code": "\n\nfunction getAllAiMessagesBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM ai_messages WHERE session_id = ? ORDER BY sent_at ASC\";\n return db.prepare(query).all(sessionId);\n}\n\nmodule.exports = {\n addAiMessage,\n getAllAiMessagesBySessionId\n}; ", "middle_code": "function addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n const db = sqliteClient.getDb();\n const messageId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO ai_messages (id, session_id, sent_at, role, content, model, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)`;\n try {\n db.prepare(query).run(messageId, sessionId, now, role, content, model, now);\n return { id: messageId };\n } catch (err) {\n console.error('SQLite: Failed to add AI message:', err);\n throw err;\n }\n}", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [["/glass/src/features/common/repositories/session/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction getById(id) {\n const db = sqliteClient.getDb();\n return db.prepare('SELECT * FROM sessions WHERE id = ?').get(id);\n}\n\nfunction create(uid, type = 'ask') {\n const db = sqliteClient.getDb();\n const sessionId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO sessions (id, uid, title, session_type, started_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(sessionId, uid, `Session @ ${new Date().toLocaleTimeString()}`, type, now, now);\n console.log(`SQLite: Created session ${sessionId} for user ${uid} (type: ${type})`);\n return sessionId;\n } catch (err) {\n console.error('SQLite: Failed to create session:', err);\n throw err;\n }\n}\n\nfunction getAllByUserId(uid) {\n const db = sqliteClient.getDb();\n const query = \"SELECT id, uid, title, session_type, started_at, ended_at, sync_state, updated_at FROM sessions WHERE uid = ? ORDER BY started_at DESC\";\n return db.prepare(query).all(uid);\n}\n\nfunction updateTitle(id, title) {\n const db = sqliteClient.getDb();\n const result = db.prepare('UPDATE sessions SET title = ? WHERE id = ?').run(title, id);\n return { changes: result.changes };\n}\n\nfunction deleteWithRelatedData(id) {\n const db = sqliteClient.getDb();\n const transaction = db.transaction(() => {\n db.prepare(\"DELETE FROM transcripts WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM ai_messages WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM summaries WHERE session_id = ?\").run(id);\n db.prepare(\"DELETE FROM sessions WHERE id = ?\").run(id);\n });\n \n try {\n transaction();\n return { success: true };\n } catch (err) {\n throw err;\n }\n}\n\nfunction end(id) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `UPDATE sessions SET ended_at = ?, updated_at = ? WHERE id = ?`;\n const result = db.prepare(query).run(now, now, id);\n return { changes: result.changes };\n}\n\nfunction updateType(id, type) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = 'UPDATE sessions SET session_type = ?, updated_at = ? WHERE id = ?';\n const result = db.prepare(query).run(type, now, id);\n return { changes: result.changes };\n}\n\nfunction touch(id) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = 'UPDATE sessions SET updated_at = ? WHERE id = ?';\n const result = db.prepare(query).run(now, id);\n return { changes: result.changes };\n}\n\nfunction getOrCreateActive(uid, requestedType = 'ask') {\n const db = sqliteClient.getDb();\n \n // 1. Look for ANY active session for the user (ended_at IS NULL).\n // Prefer 'listen' sessions over 'ask' sessions to ensure continuity.\n const findQuery = `\n SELECT id, session_type FROM sessions \n WHERE uid = ? AND ended_at IS NULL\n ORDER BY CASE session_type WHEN 'listen' THEN 1 WHEN 'ask' THEN 2 ELSE 3 END\n LIMIT 1\n `;\n\n const activeSession = db.prepare(findQuery).get(uid);\n\n if (activeSession) {\n // An active session exists.\n console.log(`[Repo] Found active session ${activeSession.id} of type ${activeSession.session_type}`);\n \n // 2. Promotion Logic: If it's an 'ask' session and we need 'listen', promote it.\n if (activeSession.session_type === 'ask' && requestedType === 'listen') {\n updateType(activeSession.id, 'listen');\n console.log(`[Repo] Promoted session ${activeSession.id} to 'listen' type.`);\n }\n\n // 3. Touch the session and return its ID.\n touch(activeSession.id);\n return activeSession.id;\n } else {\n // 4. No active session found, create a new one.\n console.log(`[Repo] No active session for user ${uid}. Creating new '${requestedType}' session.`);\n return create(uid, requestedType);\n }\n}\n\nfunction endAllActiveSessions(uid) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n // Filter by uid to match the Firebase repository's behavior.\n const query = `UPDATE sessions SET ended_at = ?, updated_at = ? WHERE ended_at IS NULL AND uid = ?`;\n \n try {\n const result = db.prepare(query).run(now, now, uid);\n console.log(`[Repo] Ended ${result.changes} active SQLite session(s) for user ${uid}.`);\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to end all active sessions:', err);\n throw err;\n }\n}\n\nmodule.exports = {\n getById,\n create,\n getAllByUserId,\n updateTitle,\n deleteWithRelatedData,\n end,\n updateType,\n touch,\n getOrCreateActive,\n endAllActiveSessions,\n}; "], ["/glass/src/features/listen/stt/repositories/sqlite.repository.js", "const sqliteClient = require('../../../common/services/sqliteClient');\n\nfunction addTranscript({ uid, sessionId, speaker, text }) {\n // uid is ignored in the SQLite implementation\n const db = sqliteClient.getDb();\n const transcriptId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO transcripts (id, session_id, start_at, speaker, text, created_at) VALUES (?, ?, ?, ?, ?, ?)`;\n \n try {\n db.prepare(query).run(transcriptId, sessionId, now, speaker, text, now);\n return { id: transcriptId };\n } catch (err) {\n console.error('Error adding transcript:', err);\n throw err;\n }\n}\n\nfunction getAllTranscriptsBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM transcripts WHERE session_id = ? ORDER BY start_at ASC\";\n return db.prepare(query).all(sessionId);\n}\n\nmodule.exports = {\n addTranscript,\n getAllTranscriptsBySessionId,\n}; "], ["/glass/src/features/settings/repositories/sqlite.repository.js", "const sqliteClient = require('../../common/services/sqliteClient');\n\nfunction getPresets(uid) {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE uid = ? OR is_default = 1 \n ORDER BY is_default DESC, title ASC\n `;\n \n try {\n return db.prepare(query).all(uid) || [];\n } catch (err) {\n console.error('SQLite: Failed to get presets:', err);\n throw err;\n }\n}\n\nfunction getPresetTemplates() {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE is_default = 1 \n ORDER BY title ASC\n `;\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('SQLite: Failed to get preset templates:', err);\n throw err;\n }\n}\n\nfunction createPreset({ uid, title, prompt }) {\n const db = sqliteClient.getDb();\n const id = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n INSERT INTO prompt_presets (id, uid, title, prompt, is_default, created_at, sync_state)\n VALUES (?, ?, ?, ?, 0, ?, 'dirty')\n `;\n \n try {\n db.prepare(query).run(id, uid, title, prompt, now);\n return { id };\n } catch (err) {\n console.error('SQLite: Failed to create preset:', err);\n throw err;\n }\n}\n\nfunction updatePreset(id, { title, prompt }, uid) {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n UPDATE prompt_presets \n SET title = ?, prompt = ?, sync_state = 'dirty', updated_at = ?\n WHERE id = ? AND uid = ? AND is_default = 0\n `;\n \n try {\n const result = db.prepare(query).run(title, prompt, now, id, uid);\n if (result.changes === 0) {\n throw new Error('Preset not found, is default, or permission denied');\n }\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to update preset:', err);\n throw err;\n }\n}\n\nfunction deletePreset(id, uid) {\n const db = sqliteClient.getDb();\n const query = `\n DELETE FROM prompt_presets \n WHERE id = ? AND uid = ? AND is_default = 0\n `;\n \n try {\n const result = db.prepare(query).run(id, uid);\n if (result.changes === 0) {\n throw new Error('Preset not found, is default, or permission denied');\n }\n return { changes: result.changes };\n } catch (err) {\n console.error('SQLite: Failed to delete preset:', err);\n throw err;\n }\n}\n\nfunction getAutoUpdate(uid) {\n const db = sqliteClient.getDb();\n const targetUid = uid;\n\n try {\n const row = db.prepare('SELECT auto_update_enabled FROM users WHERE uid = ?').get(targetUid);\n \n if (row) {\n console.log('SQLite: Auto update setting found:', row.auto_update_enabled);\n return row.auto_update_enabled !== 0;\n } else {\n // User doesn't exist, create them with default settings\n const now = Math.floor(Date.now() / 1000);\n const stmt = db.prepare(\n 'INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)');\n stmt.run(targetUid, 'User', 'user@example.com', now, 1);\n return true; // default to enabled\n }\n } catch (error) {\n console.error('SQLite: Error getting auto_update_enabled setting:', error);\n return true; // fallback to enabled\n }\n}\n\nfunction setAutoUpdate(uid, isEnabled) {\n const db = sqliteClient.getDb();\n const targetUid = uid || sqliteClient.defaultUserId;\n \n try {\n const result = db.prepare('UPDATE users SET auto_update_enabled = ? WHERE uid = ?').run(isEnabled ? 1 : 0, targetUid);\n \n // If no rows were updated, the user might not exist, so create them\n if (result.changes === 0) {\n const now = Math.floor(Date.now() / 1000);\n const stmt = db.prepare('INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)');\n stmt.run(targetUid, 'User', 'user@example.com', now, isEnabled ? 1 : 0);\n }\n \n return { success: true };\n } catch (error) {\n console.error('SQLite: Error setting auto-update:', error);\n throw error;\n }\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n getAutoUpdate,\n setAutoUpdate\n};"], ["/glass/src/features/common/repositories/preset/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction getPresets(uid) {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE uid = ? OR is_default = 1 \n ORDER BY is_default DESC, title ASC\n `;\n \n try {\n return db.prepare(query).all(uid);\n } catch (err) {\n console.error('SQLite: Failed to get presets:', err);\n throw err;\n }\n}\n\nfunction getPresetTemplates() {\n const db = sqliteClient.getDb();\n const query = `\n SELECT * FROM prompt_presets \n WHERE is_default = 1 \n ORDER BY title ASC\n `;\n \n try {\n return db.prepare(query).all();\n } catch (err) {\n console.error('SQLite: Failed to get preset templates:', err);\n throw err;\n }\n}\n\nfunction create({ uid, title, prompt }) {\n const db = sqliteClient.getDb();\n const presetId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO prompt_presets (id, uid, title, prompt, is_default, created_at, sync_state) VALUES (?, ?, ?, ?, 0, ?, 'dirty')`;\n \n try {\n db.prepare(query).run(presetId, uid, title, prompt, now);\n return { id: presetId };\n } catch (err) {\n throw err;\n }\n}\n\nfunction update(id, { title, prompt }, uid) {\n const db = sqliteClient.getDb();\n const query = `UPDATE prompt_presets SET title = ?, prompt = ?, sync_state = 'dirty' WHERE id = ? AND uid = ? AND is_default = 0`;\n\n try {\n const result = db.prepare(query).run(title, prompt, id, uid);\n if (result.changes === 0) {\n throw new Error(\"Preset not found or permission denied.\");\n }\n return { changes: result.changes };\n } catch (err) {\n throw err;\n }\n}\n\nfunction del(id, uid) {\n const db = sqliteClient.getDb();\n const query = `DELETE FROM prompt_presets WHERE id = ? AND uid = ? AND is_default = 0`;\n\n try {\n const result = db.prepare(query).run(id, uid);\n if (result.changes === 0) {\n throw new Error(\"Preset not found or permission denied.\");\n }\n return { changes: result.changes };\n } catch (err) {\n throw err;\n }\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n create,\n update,\n delete: del\n}; "], ["/glass/src/features/listen/summary/repositories/sqlite.repository.js", "const sqliteClient = require('../../../common/services/sqliteClient');\n\nfunction saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model = 'unknown' }) {\n // uid is ignored in the SQLite implementation\n return new Promise((resolve, reject) => {\n try {\n const db = sqliteClient.getDb();\n const now = Math.floor(Date.now() / 1000);\n const query = `\n INSERT INTO summaries (session_id, generated_at, model, text, tldr, bullet_json, action_json, updated_at) \n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(session_id) DO UPDATE SET\n generated_at=excluded.generated_at,\n model=excluded.model,\n text=excluded.text,\n tldr=excluded.tldr,\n bullet_json=excluded.bullet_json,\n action_json=excluded.action_json,\n updated_at=excluded.updated_at\n `;\n \n const result = db.prepare(query).run(sessionId, now, model, text, tldr, bullet_json, action_json, now);\n resolve({ changes: result.changes });\n } catch (err) {\n console.error('Error saving summary:', err);\n reject(err);\n }\n });\n}\n\nfunction getSummaryBySessionId(sessionId) {\n const db = sqliteClient.getDb();\n const query = \"SELECT * FROM summaries WHERE session_id = ?\";\n return db.prepare(query).get(sessionId) || null;\n}\n\nmodule.exports = {\n saveSummary,\n getSummaryBySessionId,\n}; "], ["/glass/src/features/ask/repositories/firebase.repository.js", "const { collection, addDoc, query, getDocs, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../common/repositories/firestoreConverter');\n\nconst aiMessageConverter = createEncryptedConverter(['content']);\n\nfunction aiMessagesCol(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access AI messages.\");\n const db = getFirestoreInstance();\n return collection(db, `sessions/${sessionId}/ai_messages`).withConverter(aiMessageConverter);\n}\n\nasync function addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n const now = Timestamp.now();\n const newMessage = {\n uid, // To identify the author of the message\n session_id: sessionId,\n sent_at: now,\n role,\n content,\n model,\n created_at: now,\n };\n \n const docRef = await addDoc(aiMessagesCol(sessionId), newMessage);\n return { id: docRef.id };\n}\n\nasync function getAllAiMessagesBySessionId(sessionId) {\n const q = query(aiMessagesCol(sessionId), orderBy('sent_at', 'asc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nmodule.exports = {\n addAiMessage,\n getAllAiMessagesBySessionId,\n}; "], ["/glass/src/features/common/repositories/user/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction findOrCreate(user) {\n const db = sqliteClient.getDb();\n \n if (!user || !user.uid) {\n throw new Error('User object and uid are required');\n }\n \n const { uid, displayName, email } = user;\n const now = Math.floor(Date.now() / 1000);\n \n // Validate inputs\n const safeDisplayName = displayName || 'User';\n const safeEmail = email || 'no-email@example.com';\n\n const query = `\n INSERT INTO users (uid, display_name, email, created_at)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(uid) DO UPDATE SET \n display_name=excluded.display_name, \n email=excluded.email\n `;\n \n try {\n console.log('[SQLite] Creating/updating user:', { uid, displayName: safeDisplayName, email: safeEmail });\n db.prepare(query).run(uid, safeDisplayName, safeEmail, now);\n const result = getById(uid);\n console.log('[SQLite] User operation successful:', result);\n return result;\n } catch (err) {\n console.error('SQLite: Failed to find or create user:', err);\n console.error('SQLite: User data:', { uid, displayName: safeDisplayName, email: safeEmail });\n throw new Error(`Failed to create user in database: ${err.message}`);\n }\n}\n\nfunction getById(uid) {\n const db = sqliteClient.getDb();\n return db.prepare('SELECT * FROM users WHERE uid = ?').get(uid);\n}\n\n\n\nfunction update({ uid, displayName }) {\n const db = sqliteClient.getDb();\n const result = db.prepare('UPDATE users SET display_name = ? WHERE uid = ?').run(displayName, uid);\n return { changes: result.changes };\n}\n\nfunction setMigrationComplete(uid) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('UPDATE users SET has_migrated_to_firebase = 1 WHERE uid = ?');\n const result = stmt.run(uid);\n if (result.changes > 0) {\n console.log(`[Repo] Marked migration as complete for user ${uid}.`);\n }\n return result;\n}\n\nfunction deleteById(uid) {\n const db = sqliteClient.getDb();\n const userSessions = db.prepare('SELECT id FROM sessions WHERE uid = ?').all(uid);\n const sessionIds = userSessions.map(s => s.id);\n\n const transaction = db.transaction(() => {\n if (sessionIds.length > 0) {\n const placeholders = sessionIds.map(() => '?').join(',');\n db.prepare(`DELETE FROM transcripts WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM ai_messages WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM summaries WHERE session_id IN (${placeholders})`).run(...sessionIds);\n db.prepare(`DELETE FROM sessions WHERE uid = ?`).run(uid);\n }\n db.prepare('DELETE FROM prompt_presets WHERE uid = ? AND is_default = 0').run(uid);\n db.prepare('DELETE FROM users WHERE uid = ?').run(uid);\n });\n\n try {\n transaction();\n return { success: true };\n } catch (err) {\n throw err;\n }\n}\n\nmodule.exports = {\n findOrCreate,\n getById,\n update,\n setMigrationComplete,\n deleteById\n}; "], ["/glass/src/features/common/services/sqliteClient.js", "const Database = require('better-sqlite3');\nconst path = require('path');\nconst LATEST_SCHEMA = require('../config/schema');\n\nclass SQLiteClient {\n constructor() {\n this.db = null;\n this.dbPath = null;\n this.defaultUserId = 'default_user';\n }\n\n connect(dbPath) {\n if (this.db) {\n console.log('[SQLiteClient] Already connected.');\n return;\n }\n\n try {\n this.dbPath = dbPath;\n this.db = new Database(this.dbPath);\n this.db.pragma('journal_mode = WAL');\n console.log('[SQLiteClient] Connected successfully to:', this.dbPath);\n } catch (err) {\n console.error('[SQLiteClient] Could not connect to database', err);\n throw err;\n }\n }\n\n getDb() {\n if (!this.db) {\n throw new Error(\"Database not connected. Call connect() first.\");\n }\n return this.db;\n }\n\n _validateAndQuoteIdentifier(identifier) {\n if (!/^[a-zA-Z0-9_]+$/.test(identifier)) {\n throw new Error(`Invalid database identifier used: ${identifier}. Only alphanumeric characters and underscores are allowed.`);\n }\n return `\"${identifier}\"`;\n }\n\n _migrateProviderSettings() {\n const tablesInDb = this.getTablesFromDb();\n if (!tablesInDb.includes('provider_settings')) {\n return; // Table doesn't exist, no migration needed.\n }\n \n const providerSettingsInfo = this.db.prepare(`PRAGMA table_info(provider_settings)`).all();\n const hasUidColumn = providerSettingsInfo.some(col => col.name === 'uid');\n \n if (hasUidColumn) {\n console.log('[DB Migration] Old provider_settings schema detected. Starting robust migration...');\n \n try {\n this.db.transaction(() => {\n this.db.exec('ALTER TABLE provider_settings RENAME TO provider_settings_old');\n console.log('[DB Migration] Renamed provider_settings to provider_settings_old');\n \n this.createTable('provider_settings', LATEST_SCHEMA.provider_settings);\n console.log('[DB Migration] Created new provider_settings table');\n \n // Dynamically build the migration query for robustness\n const oldColumnNames = this.db.prepare(`PRAGMA table_info(provider_settings_old)`).all().map(c => c.name);\n const newColumnNames = LATEST_SCHEMA.provider_settings.columns.map(c => c.name);\n const commonColumns = newColumnNames.filter(name => oldColumnNames.includes(name));\n \n if (!commonColumns.includes('provider')) {\n console.warn('[DB Migration] Old table is missing the \"provider\" column. Aborting migration for this table.');\n this.db.exec('DROP TABLE provider_settings_old');\n return;\n }\n \n const orderParts = [];\n if (oldColumnNames.includes('updated_at')) orderParts.push('updated_at DESC');\n if (oldColumnNames.includes('created_at')) orderParts.push('created_at DESC');\n const orderByClause = orderParts.length > 0 ? `ORDER BY ${orderParts.join(', ')}` : '';\n \n const columnsForInsert = commonColumns.map(c => this._validateAndQuoteIdentifier(c)).join(', ');\n \n const migrationQuery = `\n INSERT INTO provider_settings (${columnsForInsert})\n SELECT ${columnsForInsert}\n FROM (\n SELECT *, ROW_NUMBER() OVER(PARTITION BY provider ${orderByClause}) as rn\n FROM provider_settings_old\n )\n WHERE rn = 1\n `;\n \n console.log(`[DB Migration] Executing robust migration query for columns: ${commonColumns.join(', ')}`);\n const result = this.db.prepare(migrationQuery).run();\n console.log(`[DB Migration] Migrated ${result.changes} rows to the new provider_settings table.`);\n \n this.db.exec('DROP TABLE provider_settings_old');\n console.log('[DB Migration] Dropped provider_settings_old table.');\n })();\n console.log('[DB Migration] provider_settings migration completed successfully.');\n } catch (error) {\n console.error('[DB Migration] Failed to migrate provider_settings table.', error);\n \n // Try to recover by dropping the temp table if it exists\n const oldTableExists = this.getTablesFromDb().includes('provider_settings_old');\n if (oldTableExists) {\n this.db.exec('DROP TABLE provider_settings_old');\n console.warn('[DB Migration] Cleaned up temporary old table after failure.');\n }\n throw error;\n }\n }\n }\n\n async synchronizeSchema() {\n console.log('[DB Sync] Starting schema synchronization...');\n\n // Run special migration for provider_settings before the generic sync logic\n this._migrateProviderSettings();\n\n const tablesInDb = this.getTablesFromDb();\n\n for (const tableName of Object.keys(LATEST_SCHEMA)) {\n const tableSchema = LATEST_SCHEMA[tableName];\n\n if (!tablesInDb.includes(tableName)) {\n // Table doesn't exist, create it\n this.createTable(tableName, tableSchema);\n } else {\n // Table exists, check for missing columns\n this.updateTable(tableName, tableSchema);\n }\n }\n console.log('[DB Sync] Schema synchronization finished.');\n }\n\n getTablesFromDb() {\n const tables = this.db.prepare(\"SELECT name FROM sqlite_master WHERE type='table'\").all();\n return tables.map(t => t.name);\n }\n\n createTable(tableName, tableSchema) {\n const safeTableName = this._validateAndQuoteIdentifier(tableName);\n const columnDefs = tableSchema.columns\n .map(col => `${this._validateAndQuoteIdentifier(col.name)} ${col.type}`)\n .join(', ');\n \n const constraints = tableSchema.constraints || [];\n const constraintsDef = constraints.length > 0 ? ', ' + constraints.join(', ') : '';\n \n const query = `CREATE TABLE IF NOT EXISTS ${safeTableName} (${columnDefs}${constraintsDef})`;\n console.log(`[DB Sync] Creating table: ${tableName}`);\n this.db.exec(query);\n }\n\n updateTable(tableName, tableSchema) {\n const safeTableName = this._validateAndQuoteIdentifier(tableName);\n \n // Get current columns\n const currentColumns = this.db.prepare(`PRAGMA table_info(${safeTableName})`).all();\n const currentColumnNames = currentColumns.map(col => col.name);\n\n // Check for new columns to add\n const newColumns = tableSchema.columns.filter(col => !currentColumnNames.includes(col.name));\n\n if (newColumns.length > 0) {\n console.log(`[DB Sync] Adding ${newColumns.length} new column(s) to ${tableName}`);\n for (const col of newColumns) {\n const safeColName = this._validateAndQuoteIdentifier(col.name);\n const addColumnQuery = `ALTER TABLE ${safeTableName} ADD COLUMN ${safeColName} ${col.type}`;\n this.db.exec(addColumnQuery);\n console.log(`[DB Sync] Added column ${col.name} to ${tableName}`);\n }\n }\n\n if (tableSchema.constraints && tableSchema.constraints.length > 0) {\n console.log(`[DB Sync] Note: Constraints for ${tableName} can only be set during table creation`);\n }\n }\n\n runQuery(query, params = []) {\n return this.db.prepare(query).run(params);\n }\n\n cleanupEmptySessions() {\n console.log('[DB Cleanup] Checking for empty sessions...');\n const query = `\n SELECT s.id FROM sessions s\n LEFT JOIN transcripts t ON s.id = t.session_id\n LEFT JOIN ai_messages a ON s.id = a.session_id\n LEFT JOIN summaries su ON s.id = su.session_id\n WHERE t.id IS NULL AND a.id IS NULL AND su.session_id IS NULL\n `;\n\n const rows = this.db.prepare(query).all();\n\n if (rows.length === 0) {\n console.log('[DB Cleanup] No empty sessions found.');\n return;\n }\n\n const idsToDelete = rows.map(r => r.id);\n const placeholders = idsToDelete.map(() => '?').join(',');\n const deleteQuery = `DELETE FROM sessions WHERE id IN (${placeholders})`;\n\n console.log(`[DB Cleanup] Found ${idsToDelete.length} empty sessions. Deleting...`);\n const result = this.db.prepare(deleteQuery).run(idsToDelete);\n console.log(`[DB Cleanup] Successfully deleted ${result.changes} empty sessions.`);\n }\n\n async initTables() {\n await this.synchronizeSchema();\n this.initDefaultData();\n }\n\n initDefaultData() {\n const now = Math.floor(Date.now() / 1000);\n const initUserQuery = `\n INSERT OR IGNORE INTO users (uid, display_name, email, created_at)\n VALUES (?, ?, ?, ?)\n `;\n\n this.db.prepare(initUserQuery).run(this.defaultUserId, 'Default User', 'contact@pickle.com', now);\n\n const defaultPresets = [\n ['school', 'School', 'You are a school and lecture assistant. Your goal is to help the user, a student, understand academic material and answer questions.\\n\\nWhenever a question appears on the user\\'s screen or is asked aloud, you provide a direct, step-by-step answer, showing all necessary reasoning or calculations.\\n\\nIf the user is watching a lecture or working through new material, you offer concise explanations of key concepts and clarify definitions as they come up.', 1],\n ['meetings', 'Meetings', 'You are a meeting assistant. Your goal is to help the user capture key information during meetings and follow up effectively.\\n\\nYou help capture meeting notes, track action items, identify key decisions, and summarize important points discussed during meetings.', 1],\n ['sales', 'Sales', 'You are a real-time AI sales assistant, and your goal is to help the user close deals during sales interactions.\\n\\nYou provide real-time sales support, suggest responses to objections, help identify customer needs, and recommend strategies to advance deals.', 1],\n ['recruiting', 'Recruiting', 'You are a recruiting assistant. Your goal is to help the user interview candidates and evaluate talent effectively.\\n\\nYou help evaluate candidates, suggest interview questions, analyze responses, and provide insights about candidate fit for positions.', 1],\n ['customer-support', 'Customer Support', 'You are a customer support assistant. Your goal is to help resolve customer issues efficiently and thoroughly.\\n\\nYou help diagnose customer problems, suggest solutions, provide step-by-step troubleshooting guidance, and ensure customer satisfaction.', 1],\n ];\n\n const stmt = this.db.prepare(`\n INSERT OR IGNORE INTO prompt_presets (id, uid, title, prompt, is_default, created_at)\n VALUES (?, ?, ?, ?, ?, ?)\n `);\n\n for (const preset of defaultPresets) {\n stmt.run(preset[0], this.defaultUserId, preset[1], preset[2], preset[3], now);\n }\n\n console.log('Default data initialized.');\n }\n\n close() {\n if (this.db) {\n try {\n this.db.close();\n console.log('SQLite connection closed.');\n } catch (err) {\n console.error('SQLite connection close failed:', err);\n }\n this.db = null;\n }\n }\n\n query(sql, params = []) {\n if (!this.db) {\n throw new Error('Database not connected');\n }\n\n try {\n if (sql.toUpperCase().startsWith('SELECT')) {\n return this.db.prepare(sql).all(params);\n } else {\n const result = this.db.prepare(sql).run(params);\n return { changes: result.changes, lastID: result.lastID };\n }\n } catch (err) {\n console.error('Query error:', err);\n throw err;\n }\n }\n}\n\nconst sqliteClient = new SQLiteClient();\nmodule.exports = sqliteClient; "], ["/glass/src/features/common/repositories/ollamaModel/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\n/**\n * Get all Ollama models\n */\nfunction getAllModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get models:', err);\n throw err;\n }\n}\n\n/**\n * Get a specific model by name\n */\nfunction getModel(name) {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE name = ?';\n \n try {\n return db.prepare(query).get(name);\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get model:', err);\n throw err;\n }\n}\n\n/**\n * Create or update a model entry\n */\nfunction upsertModel({ name, size, installed = false, installing = false }) {\n const db = sqliteClient.getDb();\n const query = `\n INSERT INTO ollama_models (name, size, installed, installing)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(name) DO UPDATE SET \n size = excluded.size,\n installed = excluded.installed,\n installing = excluded.installing\n `;\n \n try {\n db.prepare(query).run(name, size, installed ? 1 : 0, installing ? 1 : 0);\n return { success: true };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to upsert model:', err);\n throw err;\n }\n}\n\n/**\n * Update installation status for a model\n */\nfunction updateInstallStatus(name, installed, installing = false) {\n const db = sqliteClient.getDb();\n const query = 'UPDATE ollama_models SET installed = ?, installing = ? WHERE name = ?';\n \n try {\n const result = db.prepare(query).run(installed ? 1 : 0, installing ? 1 : 0, name);\n return { success: true, changes: result.changes };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to update install status:', err);\n throw err;\n }\n}\n\n/**\n * Initialize default models - now done dynamically based on installed models\n */\nfunction initializeDefaultModels() {\n // Default models are now detected dynamically from Ollama installation\n // This function maintains compatibility but doesn't hardcode any models\n console.log('[OllamaModel Repository] Default models initialization skipped - using dynamic detection');\n return { success: true };\n}\n\n/**\n * Delete a model entry\n */\nfunction deleteModel(name) {\n const db = sqliteClient.getDb();\n const query = 'DELETE FROM ollama_models WHERE name = ?';\n \n try {\n const result = db.prepare(query).run(name);\n return { success: true, changes: result.changes };\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to delete model:', err);\n throw err;\n }\n}\n\n/**\n * Get installed models\n */\nfunction getInstalledModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE installed = 1 ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get installed models:', err);\n throw err;\n }\n}\n\n/**\n * Get models currently being installed\n */\nfunction getInstallingModels() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM ollama_models WHERE installing = 1 ORDER BY name';\n \n try {\n return db.prepare(query).all() || [];\n } catch (err) {\n console.error('[OllamaModel Repository] Failed to get installing models:', err);\n throw err;\n }\n}\n\nmodule.exports = {\n getAllModels,\n getModel,\n upsertModel,\n updateInstallStatus,\n initializeDefaultModels,\n deleteModel,\n getInstalledModels,\n getInstallingModels\n}; "], ["/glass/src/features/common/services/migrationService.js", "const { doc, writeBatch, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../services/firebaseClient');\nconst encryptionService = require('../services/encryptionService');\n\nconst sqliteSessionRepo = require('../repositories/session/sqlite.repository');\nconst sqlitePresetRepo = require('../repositories/preset/sqlite.repository');\nconst sqliteUserRepo = require('../repositories/user/sqlite.repository');\nconst sqliteSttRepo = require('../../listen/stt/repositories/sqlite.repository');\nconst sqliteSummaryRepo = require('../../listen/summary/repositories/sqlite.repository');\nconst sqliteAiMessageRepo = require('../../ask/repositories/sqlite.repository');\n\nconst MAX_BATCH_OPERATIONS = 500;\n\nasync function checkAndRunMigration(firebaseUser) {\n if (!firebaseUser || !firebaseUser.uid) {\n console.log('[Migration] No user, skipping migration check.');\n return;\n }\n\n console.log(`[Migration] Checking for user ${firebaseUser.uid}...`);\n\n const localUser = sqliteUserRepo.getById(firebaseUser.uid);\n if (!localUser || localUser.has_migrated_to_firebase) {\n console.log(`[Migration] User ${firebaseUser.uid} is not eligible or already migrated.`);\n return;\n }\n\n console.log(`[Migration] Starting data migration for user ${firebaseUser.uid}...`);\n \n try {\n const db = getFirestoreInstance();\n \n // --- Phase 1: Migrate Parent Documents (Presets & Sessions) ---\n console.log('[Migration Phase 1] Migrating parent documents...');\n let phase1Batch = writeBatch(db);\n let phase1OpCount = 0;\n const phase1Promises = [];\n \n const localPresets = (await sqlitePresetRepo.getPresets(firebaseUser.uid)).filter(p => !p.is_default);\n console.log(`[Migration Phase 1] Found ${localPresets.length} custom presets.`);\n for (const preset of localPresets) {\n const presetRef = doc(db, 'prompt_presets', preset.id);\n const cleanPreset = {\n uid: preset.uid,\n title: encryptionService.encrypt(preset.title ?? ''),\n prompt: encryptionService.encrypt(preset.prompt ?? ''),\n is_default: preset.is_default ?? 0,\n created_at: preset.created_at ? Timestamp.fromMillis(preset.created_at * 1000) : null,\n updated_at: preset.updated_at ? Timestamp.fromMillis(preset.updated_at * 1000) : null\n };\n phase1Batch.set(presetRef, cleanPreset);\n phase1OpCount++;\n if (phase1OpCount >= MAX_BATCH_OPERATIONS) {\n phase1Promises.push(phase1Batch.commit());\n phase1Batch = writeBatch(db);\n phase1OpCount = 0;\n }\n }\n \n const localSessions = await sqliteSessionRepo.getAllByUserId(firebaseUser.uid);\n console.log(`[Migration Phase 1] Found ${localSessions.length} sessions.`);\n for (const session of localSessions) {\n const sessionRef = doc(db, 'sessions', session.id);\n const cleanSession = {\n uid: session.uid,\n members: session.members ?? [session.uid],\n title: encryptionService.encrypt(session.title ?? ''),\n session_type: session.session_type ?? 'ask',\n started_at: session.started_at ? Timestamp.fromMillis(session.started_at * 1000) : null,\n ended_at: session.ended_at ? Timestamp.fromMillis(session.ended_at * 1000) : null,\n updated_at: session.updated_at ? Timestamp.fromMillis(session.updated_at * 1000) : null\n };\n phase1Batch.set(sessionRef, cleanSession);\n phase1OpCount++;\n if (phase1OpCount >= MAX_BATCH_OPERATIONS) {\n phase1Promises.push(phase1Batch.commit());\n phase1Batch = writeBatch(db);\n phase1OpCount = 0;\n }\n }\n \n if (phase1OpCount > 0) {\n phase1Promises.push(phase1Batch.commit());\n }\n \n if (phase1Promises.length > 0) {\n await Promise.all(phase1Promises);\n console.log(`[Migration Phase 1] Successfully committed ${phase1Promises.length} batches of parent documents.`);\n } else {\n console.log('[Migration Phase 1] No parent documents to migrate.');\n }\n\n // --- Phase 2: Migrate Child Documents (sub-collections) ---\n console.log('[Migration Phase 2] Migrating child documents for all sessions...');\n let phase2Batch = writeBatch(db);\n let phase2OpCount = 0;\n const phase2Promises = [];\n\n for (const session of localSessions) {\n const transcripts = await sqliteSttRepo.getAllTranscriptsBySessionId(session.id);\n for (const t of transcripts) {\n const transcriptRef = doc(db, `sessions/${session.id}/transcripts`, t.id);\n const cleanTranscript = {\n uid: firebaseUser.uid,\n session_id: t.session_id,\n start_at: t.start_at ? Timestamp.fromMillis(t.start_at * 1000) : null,\n end_at: t.end_at ? Timestamp.fromMillis(t.end_at * 1000) : null,\n speaker: t.speaker ?? null,\n text: encryptionService.encrypt(t.text ?? ''),\n lang: t.lang ?? 'en',\n created_at: t.created_at ? Timestamp.fromMillis(t.created_at * 1000) : null\n };\n phase2Batch.set(transcriptRef, cleanTranscript);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n\n const messages = await sqliteAiMessageRepo.getAllAiMessagesBySessionId(session.id);\n for (const m of messages) {\n const msgRef = doc(db, `sessions/${session.id}/ai_messages`, m.id);\n const cleanMessage = {\n uid: firebaseUser.uid,\n session_id: m.session_id,\n sent_at: m.sent_at ? Timestamp.fromMillis(m.sent_at * 1000) : null,\n role: m.role ?? 'user',\n content: encryptionService.encrypt(m.content ?? ''),\n tokens: m.tokens ?? null,\n model: m.model ?? 'unknown',\n created_at: m.created_at ? Timestamp.fromMillis(m.created_at * 1000) : null\n };\n phase2Batch.set(msgRef, cleanMessage);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n\n const summary = await sqliteSummaryRepo.getSummaryBySessionId(session.id);\n if (summary) {\n // Reverting to use 'data' as the document ID for summary.\n const summaryRef = doc(db, `sessions/${session.id}/summary`, 'data');\n const cleanSummary = {\n uid: firebaseUser.uid,\n session_id: summary.session_id,\n generated_at: summary.generated_at ? Timestamp.fromMillis(summary.generated_at * 1000) : null,\n model: summary.model ?? 'unknown',\n tldr: encryptionService.encrypt(summary.tldr ?? ''),\n text: encryptionService.encrypt(summary.text ?? ''),\n bullet_json: encryptionService.encrypt(summary.bullet_json ?? '[]'),\n action_json: encryptionService.encrypt(summary.action_json ?? '[]'),\n tokens_used: summary.tokens_used ?? null,\n updated_at: summary.updated_at ? Timestamp.fromMillis(summary.updated_at * 1000) : null\n };\n phase2Batch.set(summaryRef, cleanSummary);\n phase2OpCount++;\n if (phase2OpCount >= MAX_BATCH_OPERATIONS) {\n phase2Promises.push(phase2Batch.commit());\n phase2Batch = writeBatch(db);\n phase2OpCount = 0;\n }\n }\n }\n\n if (phase2OpCount > 0) {\n phase2Promises.push(phase2Batch.commit());\n }\n\n if (phase2Promises.length > 0) {\n await Promise.all(phase2Promises);\n console.log(`[Migration Phase 2] Successfully committed ${phase2Promises.length} batches of child documents.`);\n } else {\n console.log('[Migration Phase 2] No child documents to migrate.');\n }\n\n // --- 4. Mark migration as complete ---\n sqliteUserRepo.setMigrationComplete(firebaseUser.uid);\n console.log(`[Migration] ✅ Successfully marked migration as complete for ${firebaseUser.uid}.`);\n\n } catch (error) {\n console.error(`[Migration] 🔥 An error occurred during migration for user ${firebaseUser.uid}:`, error);\n }\n}\n\nmodule.exports = {\n checkAndRunMigration,\n}; "], ["/glass/src/features/common/repositories/providerSettings/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\nconst encryptionService = require('../../services/encryptionService');\n\nfunction getByProvider(provider) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT * FROM provider_settings WHERE provider = ?');\n const result = stmt.get(provider) || null;\n \n if (result && result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n \n return result;\n}\n\nfunction getAll() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT * FROM provider_settings ORDER BY provider');\n const results = stmt.all();\n \n return results.map(result => {\n if (result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n return result;\n });\n}\n\nfunction upsert(provider, settings) {\n // Validate: prevent direct setting of active status\n if (settings.is_active_llm || settings.is_active_stt) {\n console.warn('[ProviderSettings] Warning: is_active_llm/is_active_stt should not be set directly. Use setActiveProvider() instead.');\n }\n \n const db = sqliteClient.getDb();\n \n // Use SQLite's UPSERT syntax (INSERT ... ON CONFLICT ... DO UPDATE)\n const stmt = db.prepare(`\n INSERT INTO provider_settings (provider, api_key, selected_llm_model, selected_stt_model, is_active_llm, is_active_stt, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(provider) DO UPDATE SET\n api_key = excluded.api_key,\n selected_llm_model = excluded.selected_llm_model,\n selected_stt_model = excluded.selected_stt_model,\n -- is_active_llm and is_active_stt are NOT updated here\n -- Use setActiveProvider() to change active status\n updated_at = excluded.updated_at\n `);\n \n const result = stmt.run(\n provider,\n settings.api_key || null,\n settings.selected_llm_model || null,\n settings.selected_stt_model || null,\n 0, // is_active_llm - always 0, use setActiveProvider to activate\n 0, // is_active_stt - always 0, use setActiveProvider to activate\n settings.created_at || Date.now(),\n settings.updated_at\n );\n \n return { changes: result.changes };\n}\n\nfunction remove(provider) {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('DELETE FROM provider_settings WHERE provider = ?');\n const result = stmt.run(provider);\n return { changes: result.changes };\n}\n\nfunction removeAll() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('DELETE FROM provider_settings');\n const result = stmt.run();\n return { changes: result.changes };\n}\n\nfunction getRawApiKeys() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare('SELECT api_key FROM provider_settings');\n return stmt.all();\n}\n\n// Get active provider for a specific type (llm or stt)\nfunction getActiveProvider(type) {\n const db = sqliteClient.getDb();\n const column = type === 'llm' ? 'is_active_llm' : 'is_active_stt';\n const stmt = db.prepare(`SELECT * FROM provider_settings WHERE ${column} = 1`);\n const result = stmt.get() || null;\n \n if (result && result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n \n return result;\n}\n\n// Set active provider for a specific type\nfunction setActiveProvider(provider, type) {\n const db = sqliteClient.getDb();\n const column = type === 'llm' ? 'is_active_llm' : 'is_active_stt';\n \n // Start transaction to ensure only one provider is active\n db.transaction(() => {\n // First, deactivate all providers for this type\n const deactivateStmt = db.prepare(`UPDATE provider_settings SET ${column} = 0`);\n deactivateStmt.run();\n \n // Then activate the specified provider\n if (provider) {\n const activateStmt = db.prepare(`UPDATE provider_settings SET ${column} = 1 WHERE provider = ?`);\n activateStmt.run(provider);\n }\n })();\n \n return { success: true };\n}\n\n// Get all active settings (both llm and stt)\nfunction getActiveSettings() {\n const db = sqliteClient.getDb();\n const stmt = db.prepare(`\n SELECT * FROM provider_settings \n WHERE (is_active_llm = 1 OR is_active_stt = 1)\n ORDER BY provider\n `);\n const results = stmt.all();\n \n // Decrypt API keys and organize by type\n const activeSettings = {\n llm: null,\n stt: null\n };\n \n results.forEach(result => {\n if (result.api_key && encryptionService.looksEncrypted(result.api_key)) {\n result.api_key = encryptionService.decrypt(result.api_key);\n }\n if (result.is_active_llm) {\n activeSettings.llm = result;\n }\n if (result.is_active_stt) {\n activeSettings.stt = result;\n }\n });\n \n return activeSettings;\n}\n\nmodule.exports = {\n getByProvider,\n getAll,\n upsert,\n remove,\n removeAll,\n getRawApiKeys,\n getActiveProvider,\n setActiveProvider,\n getActiveSettings\n}; "], ["/glass/src/features/shortcuts/repositories/sqlite.repository.js", "const sqliteClient = require('../../common/services/sqliteClient');\nconst crypto = require('crypto');\n\nfunction getAllKeybinds() {\n const db = sqliteClient.getDb();\n const query = 'SELECT * FROM shortcuts';\n try {\n return db.prepare(query).all();\n } catch (error) {\n console.error(`[DB] Failed to get keybinds:`, error);\n return [];\n }\n}\n\nfunction upsertKeybinds(keybinds) {\n if (!keybinds || keybinds.length === 0) return;\n\n const db = sqliteClient.getDb();\n const upsert = db.transaction((items) => {\n const query = `\n INSERT INTO shortcuts (action, accelerator, created_at)\n VALUES (@action, @accelerator, @created_at)\n ON CONFLICT(action) DO UPDATE SET\n accelerator = excluded.accelerator;\n `;\n const insert = db.prepare(query);\n\n for (const item of items) {\n insert.run({\n action: item.action,\n accelerator: item.accelerator,\n created_at: Math.floor(Date.now() / 1000)\n });\n }\n });\n\n try {\n upsert(keybinds);\n } catch (error) {\n console.error('[DB] Failed to upsert keybinds:', error);\n throw error;\n }\n}\n\nmodule.exports = {\n getAllKeybinds,\n upsertKeybinds\n}; "], ["/glass/src/features/common/repositories/session/firebase.repository.js", "const { doc, getDoc, collection, addDoc, query, where, getDocs, writeBatch, orderBy, limit, updateDoc, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst sessionConverter = createEncryptedConverter(['title']);\n\nfunction sessionsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'sessions').withConverter(sessionConverter);\n}\n\n// Sub-collection references are now built from the top-level\nfunction subCollections(sessionId) {\n const db = getFirestoreInstance();\n const sessionPath = `sessions/${sessionId}`;\n return {\n transcripts: collection(db, `${sessionPath}/transcripts`),\n ai_messages: collection(db, `${sessionPath}/ai_messages`),\n summary: collection(db, `${sessionPath}/summary`),\n }\n}\n\nasync function getById(id) {\n const docRef = doc(sessionsCol(), id);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\nasync function create(uid, type = 'ask') {\n const now = Timestamp.now();\n const newSession = {\n uid: uid,\n members: [uid], // For future sharing functionality\n title: `Session @ ${new Date().toLocaleTimeString()}`,\n session_type: type,\n started_at: now,\n updated_at: now,\n ended_at: null,\n };\n const docRef = await addDoc(sessionsCol(), newSession);\n console.log(`Firebase: Created session ${docRef.id} for user ${uid}`);\n return docRef.id;\n}\n\nasync function getAllByUserId(uid) {\n const q = query(sessionsCol(), where('members', 'array-contains', uid), orderBy('started_at', 'desc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nasync function updateTitle(id, title) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, {\n title: encryptionService.encrypt(title),\n updated_at: Timestamp.now()\n });\n return { changes: 1 };\n}\n\nasync function deleteWithRelatedData(id) {\n const db = getFirestoreInstance();\n const batch = writeBatch(db);\n\n const { transcripts, ai_messages, summary } = subCollections(id);\n const [transcriptsSnap, aiMessagesSnap, summarySnap] = await Promise.all([\n getDocs(query(transcripts)),\n getDocs(query(ai_messages)),\n getDocs(query(summary)),\n ]);\n \n transcriptsSnap.forEach(d => batch.delete(d.ref));\n aiMessagesSnap.forEach(d => batch.delete(d.ref));\n summarySnap.forEach(d => batch.delete(d.ref));\n\n const sessionRef = doc(sessionsCol(), id);\n batch.delete(sessionRef);\n\n await batch.commit();\n return { success: true };\n}\n\nasync function end(id) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { ended_at: Timestamp.now() });\n return { changes: 1 };\n}\n\nasync function updateType(id, type) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { session_type: type });\n return { changes: 1 };\n}\n\nasync function touch(id) {\n const docRef = doc(sessionsCol(), id);\n await updateDoc(docRef, { updated_at: Timestamp.now() });\n return { changes: 1 };\n}\n\nasync function getOrCreateActive(uid, requestedType = 'ask') {\n const findQuery = query(\n sessionsCol(),\n where('uid', '==', uid),\n where('ended_at', '==', null),\n orderBy('session_type', 'desc'),\n limit(1)\n );\n\n const activeSessionSnap = await getDocs(findQuery);\n \n if (!activeSessionSnap.empty) {\n const activeSessionDoc = activeSessionSnap.docs[0];\n const sessionRef = doc(sessionsCol(), activeSessionDoc.id);\n const activeSession = activeSessionDoc.data();\n\n console.log(`[Repo] Found active Firebase session ${activeSession.id}`);\n \n const updates = { updated_at: Timestamp.now() };\n if (activeSession.session_type === 'ask' && requestedType === 'listen') {\n updates.session_type = 'listen';\n console.log(`[Repo] Promoted Firebase session ${activeSession.id} to 'listen' type.`);\n }\n \n await updateDoc(sessionRef, updates);\n return activeSessionDoc.id;\n } else {\n console.log(`[Repo] No active Firebase session for user ${uid}. Creating new.`);\n return create(uid, requestedType);\n }\n}\n\nasync function endAllActiveSessions(uid) {\n const q = query(sessionsCol(), where('uid', '==', uid), where('ended_at', '==', null));\n const snapshot = await getDocs(q);\n\n if (snapshot.empty) return { changes: 0 };\n\n const batch = writeBatch(getFirestoreInstance());\n const now = Timestamp.now();\n snapshot.forEach(d => {\n batch.update(d.ref, { ended_at: now });\n });\n await batch.commit();\n\n console.log(`[Repo] Ended ${snapshot.size} active session(s) for user ${uid}.`);\n return { changes: snapshot.size };\n}\n\nmodule.exports = {\n getById,\n create,\n getAllByUserId,\n updateTitle,\n deleteWithRelatedData,\n end,\n updateType,\n touch,\n getOrCreateActive,\n endAllActiveSessions,\n}; "], ["/glass/src/features/ask/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\n// The adapter layer that injects the UID\nconst askRepositoryAdapter = {\n addAiMessage: ({ sessionId, role, content, model }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().addAiMessage({ uid, sessionId, role, content, model });\n },\n getAllAiMessagesBySessionId: (sessionId) => {\n // This function does not require a UID at the service level.\n return getBaseRepository().getAllAiMessagesBySessionId(sessionId);\n }\n};\n\nmodule.exports = askRepositoryAdapter; "], ["/glass/src/features/listen/stt/repositories/firebase.repository.js", "const { collection, addDoc, query, getDocs, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../../common/repositories/firestoreConverter');\n\nconst transcriptConverter = createEncryptedConverter(['text']);\n\nfunction transcriptsCol(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access transcripts.\");\n const db = getFirestoreInstance();\n return collection(db, `sessions/${sessionId}/transcripts`).withConverter(transcriptConverter);\n}\n\nasync function addTranscript({ uid, sessionId, speaker, text }) {\n const now = Timestamp.now();\n const newTranscript = {\n uid, // To identify the author/source of the transcript\n session_id: sessionId,\n start_at: now,\n speaker,\n text,\n created_at: now,\n };\n const docRef = await addDoc(transcriptsCol(sessionId), newTranscript);\n return { id: docRef.id };\n}\n\nasync function getAllTranscriptsBySessionId(sessionId) {\n const q = query(transcriptsCol(sessionId), orderBy('start_at', 'asc'));\n const querySnapshot = await getDocs(q);\n return querySnapshot.docs.map(doc => doc.data());\n}\n\nmodule.exports = {\n addTranscript,\n getAllTranscriptsBySessionId,\n}; "], ["/glass/src/features/listen/summary/repositories/firebase.repository.js", "const { collection, doc, setDoc, getDoc, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../../common/repositories/firestoreConverter');\nconst encryptionService = require('../../../common/services/encryptionService');\n\nconst fieldsToEncrypt = ['tldr', 'text', 'bullet_json', 'action_json'];\nconst summaryConverter = createEncryptedConverter(fieldsToEncrypt);\n\nfunction summaryDocRef(sessionId) {\n if (!sessionId) throw new Error(\"Session ID is required to access summary.\");\n const db = getFirestoreInstance();\n // Reverting to the original structure with 'data' as the document ID.\n const docPath = `sessions/${sessionId}/summary/data`;\n return doc(db, docPath).withConverter(summaryConverter);\n}\n\nasync function saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model = 'unknown' }) {\n const now = Timestamp.now();\n const summaryData = {\n uid, // To know who generated the summary\n session_id: sessionId,\n generated_at: now,\n model,\n text,\n tldr,\n bullet_json,\n action_json,\n updated_at: now,\n };\n \n // The converter attached to summaryDocRef will handle encryption via its `toFirestore` method.\n // Manual encryption was removed to fix the double-encryption bug.\n const docRef = summaryDocRef(sessionId);\n await setDoc(docRef, summaryData, { merge: true });\n\n return { changes: 1 };\n}\n\nasync function getSummaryBySessionId(sessionId) {\n const docRef = summaryDocRef(sessionId);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\nmodule.exports = {\n saveSummary,\n getSummaryBySessionId,\n}; "], ["/glass/src/features/ask/askService.js", "const { BrowserWindow } = require('electron');\nconst { createStreamingLLM } = require('../common/ai/factory');\n// Lazy require helper to avoid circular dependency issues\nconst getWindowManager = () => require('../../window/windowManager');\nconst internalBridge = require('../../bridge/internalBridge');\n\nconst getWindowPool = () => {\n try {\n return getWindowManager().windowPool;\n } catch {\n return null;\n }\n};\n\nconst sessionRepository = require('../common/repositories/session');\nconst askRepository = require('./repositories');\nconst { getSystemPrompt } = require('../common/prompts/promptBuilder');\nconst path = require('node:path');\nconst fs = require('node:fs');\nconst os = require('os');\nconst util = require('util');\nconst execFile = util.promisify(require('child_process').execFile);\nconst { desktopCapturer } = require('electron');\nconst modelStateService = require('../common/services/modelStateService');\n\n// Try to load sharp, but don't fail if it's not available\nlet sharp;\ntry {\n sharp = require('sharp');\n console.log('[AskService] Sharp module loaded successfully');\n} catch (error) {\n console.warn('[AskService] Sharp module not available:', error.message);\n console.warn('[AskService] Screenshot functionality will work with reduced image processing capabilities');\n sharp = null;\n}\nlet lastScreenshot = null;\n\nasync function captureScreenshot(options = {}) {\n if (process.platform === 'darwin') {\n try {\n const tempPath = path.join(os.tmpdir(), `screenshot-${Date.now()}.jpg`);\n\n await execFile('screencapture', ['-x', '-t', 'jpg', tempPath]);\n\n const imageBuffer = await fs.promises.readFile(tempPath);\n await fs.promises.unlink(tempPath);\n\n if (sharp) {\n try {\n // Try using sharp for optimal image processing\n const resizedBuffer = await sharp(imageBuffer)\n .resize({ height: 384 })\n .jpeg({ quality: 80 })\n .toBuffer();\n\n const base64 = resizedBuffer.toString('base64');\n const metadata = await sharp(resizedBuffer).metadata();\n\n lastScreenshot = {\n base64,\n width: metadata.width,\n height: metadata.height,\n timestamp: Date.now(),\n };\n\n return { success: true, base64, width: metadata.width, height: metadata.height };\n } catch (sharpError) {\n console.warn('Sharp module failed, falling back to basic image processing:', sharpError.message);\n }\n }\n \n // Fallback: Return the original image without resizing\n console.log('[AskService] Using fallback image processing (no resize/compression)');\n const base64 = imageBuffer.toString('base64');\n \n lastScreenshot = {\n base64,\n width: null, // We don't have metadata without sharp\n height: null,\n timestamp: Date.now(),\n };\n\n return { success: true, base64, width: null, height: null };\n } catch (error) {\n console.error('Failed to capture screenshot:', error);\n return { success: false, error: error.message };\n }\n }\n\n try {\n const sources = await desktopCapturer.getSources({\n types: ['screen'],\n thumbnailSize: {\n width: 1920,\n height: 1080,\n },\n });\n\n if (sources.length === 0) {\n throw new Error('No screen sources available');\n }\n const source = sources[0];\n const buffer = source.thumbnail.toJPEG(70);\n const base64 = buffer.toString('base64');\n const size = source.thumbnail.getSize();\n\n return {\n success: true,\n base64,\n width: size.width,\n height: size.height,\n };\n } catch (error) {\n console.error('Failed to capture screenshot using desktopCapturer:', error);\n return {\n success: false,\n error: error.message,\n };\n }\n}\n\n/**\n * @class\n * @description\n */\nclass AskService {\n constructor() {\n this.abortController = null;\n this.state = {\n isVisible: false,\n isLoading: false,\n isStreaming: false,\n currentQuestion: '',\n currentResponse: '',\n showTextInput: true,\n };\n console.log('[AskService] Service instance created.');\n }\n\n _broadcastState() {\n const askWindow = getWindowPool()?.get('ask');\n if (askWindow && !askWindow.isDestroyed()) {\n askWindow.webContents.send('ask:stateUpdate', this.state);\n }\n }\n\n async toggleAskButton(inputScreenOnly = false) {\n const askWindow = getWindowPool()?.get('ask');\n\n let shouldSendScreenOnly = false;\n if (inputScreenOnly && this.state.showTextInput && askWindow && askWindow.isVisible()) {\n shouldSendScreenOnly = true;\n await this.sendMessage('', []);\n return;\n }\n\n const hasContent = this.state.isLoading || this.state.isStreaming || (this.state.currentResponse && this.state.currentResponse.length > 0);\n\n if (askWindow && askWindow.isVisible() && hasContent) {\n this.state.showTextInput = !this.state.showTextInput;\n this._broadcastState();\n } else {\n if (askWindow && askWindow.isVisible()) {\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: false });\n this.state.isVisible = false;\n } else {\n console.log('[AskService] Showing hidden Ask window');\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: true });\n this.state.isVisible = true;\n }\n if (this.state.isVisible) {\n this.state.showTextInput = true;\n this._broadcastState();\n }\n }\n }\n\n async closeAskWindow () {\n if (this.abortController) {\n this.abortController.abort('Window closed by user');\n this.abortController = null;\n }\n \n this.state = {\n isVisible : false,\n isLoading : false,\n isStreaming : false,\n currentQuestion: '',\n currentResponse: '',\n showTextInput : true,\n };\n this._broadcastState();\n \n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: false });\n \n return { success: true };\n }\n \n\n /**\n * \n * @param {string[]} conversationTexts\n * @returns {string}\n * @private\n */\n _formatConversationForPrompt(conversationTexts) {\n if (!conversationTexts || conversationTexts.length === 0) {\n return 'No conversation history available.';\n }\n return conversationTexts.slice(-30).join('\\n');\n }\n\n /**\n * \n * @param {string} userPrompt\n * @returns {Promise<{success: boolean, response?: string, error?: string}>}\n */\n async sendMessage(userPrompt, conversationHistoryRaw=[]) {\n internalBridge.emit('window:requestVisibility', { name: 'ask', visible: true });\n this.state = {\n ...this.state,\n isLoading: true,\n isStreaming: false,\n currentQuestion: userPrompt,\n currentResponse: '',\n showTextInput: false,\n };\n this._broadcastState();\n\n if (this.abortController) {\n this.abortController.abort('New request received.');\n }\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n\n\n let sessionId;\n\n try {\n console.log(`[AskService] 🤖 Processing message: ${userPrompt.substring(0, 50)}...`);\n\n sessionId = await sessionRepository.getOrCreateActive('ask');\n await askRepository.addAiMessage({ sessionId, role: 'user', content: userPrompt.trim() });\n console.log(`[AskService] DB: Saved user prompt to session ${sessionId}`);\n \n const modelInfo = await modelStateService.getCurrentModelInfo('llm');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key not configured.');\n }\n console.log(`[AskService] Using model: ${modelInfo.model} for provider: ${modelInfo.provider}`);\n\n const screenshotResult = await captureScreenshot({ quality: 'medium' });\n const screenshotBase64 = screenshotResult.success ? screenshotResult.base64 : null;\n\n const conversationHistory = this._formatConversationForPrompt(conversationHistoryRaw);\n\n const systemPrompt = getSystemPrompt('pickle_glass_analysis', conversationHistory, false);\n\n const messages = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: [\n { type: 'text', text: `User Request: ${userPrompt.trim()}` },\n ],\n },\n ];\n\n if (screenshotBase64) {\n messages[1].content.push({\n type: 'image_url',\n image_url: { url: `data:image/jpeg;base64,${screenshotBase64}` },\n });\n }\n \n const streamingLLM = createStreamingLLM(modelInfo.provider, {\n apiKey: modelInfo.apiKey,\n model: modelInfo.model,\n temperature: 0.7,\n maxTokens: 2048,\n usePortkey: modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: modelInfo.provider === 'openai-glass' ? modelInfo.apiKey : undefined,\n });\n\n try {\n const response = await streamingLLM.streamChat(messages);\n const askWin = getWindowPool()?.get('ask');\n\n if (!askWin || askWin.isDestroyed()) {\n console.error(\"[AskService] Ask window is not available to send stream to.\");\n response.body.getReader().cancel();\n return { success: false, error: 'Ask window is not available.' };\n }\n\n const reader = response.body.getReader();\n signal.addEventListener('abort', () => {\n console.log(`[AskService] Aborting stream reader. Reason: ${signal.reason}`);\n reader.cancel(signal.reason).catch(() => { /* 이미 취소된 경우의 오류는 무시 */ });\n });\n\n await this._processStream(reader, askWin, sessionId, signal);\n return { success: true };\n\n } catch (multimodalError) {\n // 멀티모달 요청이 실패했고 스크린샷이 포함되어 있다면 텍스트만으로 재시도\n if (screenshotBase64 && this._isMultimodalError(multimodalError)) {\n console.log(`[AskService] Multimodal request failed, retrying with text-only: ${multimodalError.message}`);\n \n // 텍스트만으로 메시지 재구성\n const textOnlyMessages = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: `User Request: ${userPrompt.trim()}`\n }\n ];\n\n const fallbackResponse = await streamingLLM.streamChat(textOnlyMessages);\n const askWin = getWindowPool()?.get('ask');\n\n if (!askWin || askWin.isDestroyed()) {\n console.error(\"[AskService] Ask window is not available for fallback response.\");\n fallbackResponse.body.getReader().cancel();\n return { success: false, error: 'Ask window is not available.' };\n }\n\n const fallbackReader = fallbackResponse.body.getReader();\n signal.addEventListener('abort', () => {\n console.log(`[AskService] Aborting fallback stream reader. Reason: ${signal.reason}`);\n fallbackReader.cancel(signal.reason).catch(() => {});\n });\n\n await this._processStream(fallbackReader, askWin, sessionId, signal);\n return { success: true };\n } else {\n // 다른 종류의 에러이거나 스크린샷이 없었다면 그대로 throw\n throw multimodalError;\n }\n }\n\n } catch (error) {\n console.error('[AskService] Error during message processing:', error);\n this.state = {\n ...this.state,\n isLoading: false,\n isStreaming: false,\n showTextInput: true,\n };\n this._broadcastState();\n\n const askWin = getWindowPool()?.get('ask');\n if (askWin && !askWin.isDestroyed()) {\n const streamError = error.message || 'Unknown error occurred';\n askWin.webContents.send('ask-response-stream-error', { error: streamError });\n }\n\n return { success: false, error: error.message };\n }\n }\n\n /**\n * \n * @param {ReadableStreamDefaultReader} reader\n * @param {BrowserWindow} askWin\n * @param {number} sessionId \n * @param {AbortSignal} signal\n * @returns {Promise}\n * @private\n */\n async _processStream(reader, askWin, sessionId, signal) {\n const decoder = new TextDecoder();\n let fullResponse = '';\n\n try {\n this.state.isLoading = false;\n this.state.isStreaming = true;\n this._broadcastState();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value);\n const lines = chunk.split('\\n').filter(line => line.trim() !== '');\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.substring(6);\n if (data === '[DONE]') {\n return; \n }\n try {\n const json = JSON.parse(data);\n const token = json.choices[0]?.delta?.content || '';\n if (token) {\n fullResponse += token;\n this.state.currentResponse = fullResponse;\n this._broadcastState();\n }\n } catch (error) {\n }\n }\n }\n }\n } catch (streamError) {\n if (signal.aborted) {\n console.log(`[AskService] Stream reading was intentionally cancelled. Reason: ${signal.reason}`);\n } else {\n console.error('[AskService] Error while processing stream:', streamError);\n if (askWin && !askWin.isDestroyed()) {\n askWin.webContents.send('ask-response-stream-error', { error: streamError.message });\n }\n }\n } finally {\n this.state.isStreaming = false;\n this.state.currentResponse = fullResponse;\n this._broadcastState();\n if (fullResponse) {\n try {\n await askRepository.addAiMessage({ sessionId, role: 'assistant', content: fullResponse });\n console.log(`[AskService] DB: Saved partial or full assistant response to session ${sessionId} after stream ended.`);\n } catch(dbError) {\n console.error(\"[AskService] DB: Failed to save assistant response after stream ended:\", dbError);\n }\n }\n }\n }\n\n /**\n * 멀티모달 관련 에러인지 판단\n * @private\n */\n _isMultimodalError(error) {\n const errorMessage = error.message?.toLowerCase() || '';\n return (\n errorMessage.includes('vision') ||\n errorMessage.includes('image') ||\n errorMessage.includes('multimodal') ||\n errorMessage.includes('unsupported') ||\n errorMessage.includes('image_url') ||\n errorMessage.includes('400') || // Bad Request often for unsupported features\n errorMessage.includes('invalid') ||\n errorMessage.includes('not supported')\n );\n }\n\n}\n\nconst askService = new AskService();\n\nmodule.exports = askService;"], ["/glass/src/index.js", "// try {\n// const reloader = require('electron-reloader');\n// reloader(module, {\n// });\n// } catch (err) {\n// }\n\nrequire('dotenv').config();\n\nif (require('electron-squirrel-startup')) {\n process.exit(0);\n}\n\nconst { app, BrowserWindow, shell, ipcMain, dialog, desktopCapturer, session } = require('electron');\nconst { createWindows } = require('./window/windowManager.js');\nconst listenService = require('./features/listen/listenService');\nconst { initializeFirebase } = require('./features/common/services/firebaseClient');\nconst databaseInitializer = require('./features/common/services/databaseInitializer');\nconst authService = require('./features/common/services/authService');\nconst path = require('node:path');\nconst express = require('express');\nconst fetch = require('node-fetch');\nconst { autoUpdater } = require('electron-updater');\nconst { EventEmitter } = require('events');\nconst askService = require('./features/ask/askService');\nconst settingsService = require('./features/settings/settingsService');\nconst sessionRepository = require('./features/common/repositories/session');\nconst modelStateService = require('./features/common/services/modelStateService');\nconst featureBridge = require('./bridge/featureBridge');\nconst windowBridge = require('./bridge/windowBridge');\n\n// Global variables\nconst eventBridge = new EventEmitter();\nlet WEB_PORT = 3000;\nlet isShuttingDown = false; // Flag to prevent infinite shutdown loop\n\n//////// after_modelStateService ////////\nglobal.modelStateService = modelStateService;\n//////// after_modelStateService ////////\n\n// Import and initialize OllamaService\nconst ollamaService = require('./features/common/services/ollamaService');\nconst ollamaModelRepository = require('./features/common/repositories/ollamaModel');\n\n// Native deep link handling - cross-platform compatible\nlet pendingDeepLinkUrl = null;\n\nfunction setupProtocolHandling() {\n // Protocol registration - must be done before app is ready\n try {\n if (!app.isDefaultProtocolClient('pickleglass')) {\n const success = app.setAsDefaultProtocolClient('pickleglass');\n if (success) {\n console.log('[Protocol] Successfully set as default protocol client for pickleglass://');\n } else {\n console.warn('[Protocol] Failed to set as default protocol client - this may affect deep linking');\n }\n } else {\n console.log('[Protocol] Already registered as default protocol client for pickleglass://');\n }\n } catch (error) {\n console.error('[Protocol] Error during protocol registration:', error);\n }\n\n // Handle protocol URLs on Windows/Linux\n app.on('second-instance', (event, commandLine, workingDirectory) => {\n console.log('[Protocol] Second instance command line:', commandLine);\n \n focusMainWindow();\n \n let protocolUrl = null;\n \n // Search through all command line arguments for a valid protocol URL\n for (const arg of commandLine) {\n if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {\n // Clean up the URL by removing problematic characters\n const cleanUrl = arg.replace(/[\\\\₩]/g, '');\n \n // Additional validation for Windows\n if (process.platform === 'win32') {\n // On Windows, ensure the URL doesn't contain file path indicators\n if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {\n protocolUrl = cleanUrl;\n break;\n }\n } else {\n protocolUrl = cleanUrl;\n break;\n }\n }\n }\n \n if (protocolUrl) {\n console.log('[Protocol] Valid URL found from second instance:', protocolUrl);\n handleCustomUrl(protocolUrl);\n } else {\n console.log('[Protocol] No valid protocol URL found in command line arguments');\n console.log('[Protocol] Command line args:', commandLine);\n }\n });\n\n // Handle protocol URLs on macOS\n app.on('open-url', (event, url) => {\n event.preventDefault();\n console.log('[Protocol] Received URL via open-url:', url);\n \n if (!url || !url.startsWith('pickleglass://')) {\n console.warn('[Protocol] Invalid URL format:', url);\n return;\n }\n\n if (app.isReady()) {\n handleCustomUrl(url);\n } else {\n pendingDeepLinkUrl = url;\n console.log('[Protocol] App not ready, storing URL for later');\n }\n });\n}\n\nfunction focusMainWindow() {\n const { windowPool } = require('./window/windowManager.js');\n if (windowPool) {\n const header = windowPool.get('header');\n if (header && !header.isDestroyed()) {\n if (header.isMinimized()) header.restore();\n header.focus();\n return true;\n }\n }\n \n // Fallback: focus any available window\n const windows = BrowserWindow.getAllWindows();\n if (windows.length > 0) {\n const mainWindow = windows[0];\n if (!mainWindow.isDestroyed()) {\n if (mainWindow.isMinimized()) mainWindow.restore();\n mainWindow.focus();\n return true;\n }\n }\n \n return false;\n}\n\nif (process.platform === 'win32') {\n for (const arg of process.argv) {\n if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {\n // Clean up the URL by removing problematic characters (korean characters issue...)\n const cleanUrl = arg.replace(/[\\\\₩]/g, '');\n \n if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {\n console.log('[Protocol] Found protocol URL in initial arguments:', cleanUrl);\n pendingDeepLinkUrl = cleanUrl;\n break;\n }\n }\n }\n \n console.log('[Protocol] Initial process.argv:', process.argv);\n}\n\nconst gotTheLock = app.requestSingleInstanceLock();\nif (!gotTheLock) {\n app.quit();\n process.exit(0);\n}\n\n// setup protocol after single instance lock\nsetupProtocolHandling();\n\napp.whenReady().then(async () => {\n\n // Setup native loopback audio capture for Windows\n session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {\n desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {\n // Grant access to the first screen found with loopback audio\n callback({ video: sources[0], audio: 'loopback' });\n }).catch((error) => {\n console.error('Failed to get desktop capturer sources:', error);\n callback({});\n });\n });\n\n // Initialize core services\n initializeFirebase();\n \n try {\n await databaseInitializer.initialize();\n console.log('>>> [index.js] Database initialized successfully');\n \n // Clean up zombie sessions from previous runs first - MOVED TO authService\n // sessionRepository.endAllActiveSessions();\n\n await authService.initialize();\n\n //////// after_modelStateService ////////\n await modelStateService.initialize();\n //////// after_modelStateService ////////\n\n featureBridge.initialize(); // 추가: featureBridge 초기화\n windowBridge.initialize();\n setupWebDataHandlers();\n\n // Initialize Ollama models in database\n await ollamaModelRepository.initializeDefaultModels();\n\n // Auto warm-up selected Ollama model in background (non-blocking)\n setTimeout(async () => {\n try {\n console.log('[index.js] Starting background Ollama model warm-up...');\n await ollamaService.autoWarmUpSelectedModel();\n } catch (error) {\n console.log('[index.js] Background warm-up failed (non-critical):', error.message);\n }\n }, 2000); // Wait 2 seconds after app start\n\n // Start web server and create windows ONLY after all initializations are successful\n WEB_PORT = await startWebStack();\n console.log('Web front-end listening on', WEB_PORT);\n \n createWindows();\n\n } catch (err) {\n console.error('>>> [index.js] Database initialization failed - some features may not work', err);\n // Optionally, show an error dialog to the user\n dialog.showErrorBox(\n 'Application Error',\n 'A critical error occurred during startup. Some features might be disabled. Please restart the application.'\n );\n }\n\n // initAutoUpdater should be called after auth is initialized\n initAutoUpdater();\n\n // Process any pending deep link after everything is initialized\n if (pendingDeepLinkUrl) {\n console.log('[Protocol] Processing pending URL:', pendingDeepLinkUrl);\n handleCustomUrl(pendingDeepLinkUrl);\n pendingDeepLinkUrl = null;\n }\n});\n\napp.on('before-quit', async (event) => {\n // Prevent infinite loop by checking if shutdown is already in progress\n if (isShuttingDown) {\n console.log('[Shutdown] 🔄 Shutdown already in progress, allowing quit...');\n return;\n }\n \n console.log('[Shutdown] App is about to quit. Starting graceful shutdown...');\n \n // Set shutdown flag to prevent infinite loop\n isShuttingDown = true;\n \n // Prevent immediate quit to allow graceful shutdown\n event.preventDefault();\n \n try {\n // 1. Stop audio capture first (immediate)\n await listenService.closeSession();\n console.log('[Shutdown] Audio capture stopped');\n \n // 2. End all active sessions (database operations) - with error handling\n try {\n await sessionRepository.endAllActiveSessions();\n console.log('[Shutdown] Active sessions ended');\n } catch (dbError) {\n console.warn('[Shutdown] Could not end active sessions (database may be closed):', dbError.message);\n }\n \n // 3. Shutdown Ollama service (potentially time-consuming)\n console.log('[Shutdown] shutting down Ollama service...');\n const ollamaShutdownSuccess = await Promise.race([\n ollamaService.shutdown(false), // Graceful shutdown\n new Promise(resolve => setTimeout(() => resolve(false), 8000)) // 8s timeout\n ]);\n \n if (ollamaShutdownSuccess) {\n console.log('[Shutdown] Ollama service shut down gracefully');\n } else {\n console.log('[Shutdown] Ollama shutdown timeout, forcing...');\n // Force shutdown if graceful failed\n try {\n await ollamaService.shutdown(true);\n } catch (forceShutdownError) {\n console.warn('[Shutdown] Force shutdown also failed:', forceShutdownError.message);\n }\n }\n \n // 4. Close database connections (final cleanup)\n try {\n databaseInitializer.close();\n console.log('[Shutdown] Database connections closed');\n } catch (closeError) {\n console.warn('[Shutdown] Error closing database:', closeError.message);\n }\n \n console.log('[Shutdown] Graceful shutdown completed successfully');\n \n } catch (error) {\n console.error('[Shutdown] Error during graceful shutdown:', error);\n // Continue with shutdown even if there were errors\n } finally {\n // Actually quit the app now\n console.log('[Shutdown] Exiting application...');\n app.exit(0); // Use app.exit() instead of app.quit() to force quit\n }\n});\n\napp.on('activate', () => {\n if (BrowserWindow.getAllWindows().length === 0) {\n createWindows();\n }\n});\n\nfunction setupWebDataHandlers() {\n const sessionRepository = require('./features/common/repositories/session');\n const sttRepository = require('./features/listen/stt/repositories');\n const summaryRepository = require('./features/listen/summary/repositories');\n const askRepository = require('./features/ask/repositories');\n const userRepository = require('./features/common/repositories/user');\n const presetRepository = require('./features/common/repositories/preset');\n\n const handleRequest = async (channel, responseChannel, payload) => {\n let result;\n // const currentUserId = authService.getCurrentUserId(); // No longer needed here\n try {\n switch (channel) {\n // SESSION\n case 'get-sessions':\n // Adapter injects UID\n result = await sessionRepository.getAllByUserId();\n break;\n case 'get-session-details':\n const session = await sessionRepository.getById(payload);\n if (!session) {\n result = null;\n break;\n }\n const [transcripts, ai_messages, summary] = await Promise.all([\n sttRepository.getAllTranscriptsBySessionId(payload),\n askRepository.getAllAiMessagesBySessionId(payload),\n summaryRepository.getSummaryBySessionId(payload)\n ]);\n result = { session, transcripts, ai_messages, summary };\n break;\n case 'delete-session':\n result = await sessionRepository.deleteWithRelatedData(payload);\n break;\n case 'create-session':\n // Adapter injects UID\n const id = await sessionRepository.create('ask');\n if (payload && payload.title) {\n await sessionRepository.updateTitle(id, payload.title);\n }\n result = { id };\n break;\n \n // USER\n case 'get-user-profile':\n // Adapter injects UID\n result = await userRepository.getById();\n break;\n case 'update-user-profile':\n // Adapter injects UID\n result = await userRepository.update(payload);\n break;\n case 'find-or-create-user':\n result = await userRepository.findOrCreate(payload);\n break;\n case 'save-api-key':\n // Use ModelStateService as the single source of truth for API key management\n result = await modelStateService.setApiKey(payload.provider, payload.apiKey);\n break;\n case 'check-api-key-status':\n // Use ModelStateService to check API key status\n const hasApiKey = await modelStateService.hasValidApiKey();\n result = { hasApiKey };\n break;\n case 'delete-account':\n // Adapter injects UID\n result = await userRepository.deleteById();\n break;\n\n // PRESET\n case 'get-presets':\n // Adapter injects UID\n result = await presetRepository.getPresets();\n break;\n case 'create-preset':\n // Adapter injects UID\n result = await presetRepository.create(payload);\n settingsService.notifyPresetUpdate('created', result.id, payload.title);\n break;\n case 'update-preset':\n // Adapter injects UID\n result = await presetRepository.update(payload.id, payload.data);\n settingsService.notifyPresetUpdate('updated', payload.id, payload.data.title);\n break;\n case 'delete-preset':\n // Adapter injects UID\n result = await presetRepository.delete(payload);\n settingsService.notifyPresetUpdate('deleted', payload);\n break;\n \n // BATCH\n case 'get-batch-data':\n const includes = payload ? payload.split(',').map(item => item.trim()) : ['profile', 'presets', 'sessions'];\n const promises = {};\n \n if (includes.includes('profile')) {\n // Adapter injects UID\n promises.profile = userRepository.getById();\n }\n if (includes.includes('presets')) {\n // Adapter injects UID\n promises.presets = presetRepository.getPresets();\n }\n if (includes.includes('sessions')) {\n // Adapter injects UID\n promises.sessions = sessionRepository.getAllByUserId();\n }\n \n const batchResult = {};\n const promiseResults = await Promise.all(Object.values(promises));\n Object.keys(promises).forEach((key, index) => {\n batchResult[key] = promiseResults[index];\n });\n\n result = batchResult;\n break;\n\n default:\n throw new Error(`Unknown web data channel: ${channel}`);\n }\n eventBridge.emit(responseChannel, { success: true, data: result });\n } catch (error) {\n console.error(`Error handling web data request for ${channel}:`, error);\n eventBridge.emit(responseChannel, { success: false, error: error.message });\n }\n };\n \n eventBridge.on('web-data-request', handleRequest);\n}\n\nasync function handleCustomUrl(url) {\n try {\n console.log('[Custom URL] Processing URL:', url);\n \n // Validate and clean URL\n if (!url || typeof url !== 'string' || !url.startsWith('pickleglass://')) {\n console.error('[Custom URL] Invalid URL format:', url);\n return;\n }\n \n // Clean up URL by removing problematic characters\n const cleanUrl = url.replace(/[\\\\₩]/g, '');\n \n // Additional validation\n if (cleanUrl !== url) {\n console.log('[Custom URL] Cleaned URL from:', url, 'to:', cleanUrl);\n url = cleanUrl;\n }\n \n const urlObj = new URL(url);\n const action = urlObj.hostname;\n const params = Object.fromEntries(urlObj.searchParams);\n \n console.log('[Custom URL] Action:', action, 'Params:', params);\n\n switch (action) {\n case 'login':\n case 'auth-success':\n await handleFirebaseAuthCallback(params);\n break;\n case 'personalize':\n handlePersonalizeFromUrl(params);\n break;\n default:\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n \n const targetUrl = `http://localhost:${WEB_PORT}/${action}`;\n console.log(`[Custom URL] Navigating webview to: ${targetUrl}`);\n header.webContents.loadURL(targetUrl);\n }\n }\n\n } catch (error) {\n console.error('[Custom URL] Error parsing URL:', error);\n }\n}\n\nasync function handleFirebaseAuthCallback(params) {\n const userRepository = require('./features/common/repositories/user');\n const { token: idToken } = params;\n\n if (!idToken) {\n console.error('[Auth] Firebase auth callback is missing ID token.');\n // No need to send IPC, the UI won't transition without a successful auth state change.\n return;\n }\n\n console.log('[Auth] Received ID token from deep link, exchanging for custom token...');\n\n try {\n const functionUrl = 'https://us-west1-pickle-3651a.cloudfunctions.net/pickleGlassAuthCallback';\n const response = await fetch(functionUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ token: idToken })\n });\n\n const data = await response.json();\n\n if (!response.ok || !data.success) {\n throw new Error(data.error || 'Failed to exchange token.');\n }\n\n const { customToken, user } = data;\n console.log('[Auth] Successfully received custom token for user:', user.uid);\n\n const firebaseUser = {\n uid: user.uid,\n email: user.email || 'no-email@example.com',\n displayName: user.name || 'User',\n photoURL: user.picture\n };\n\n // 1. Sync user data to local DB\n userRepository.findOrCreate(firebaseUser);\n console.log('[Auth] User data synced with local DB.');\n\n // 2. Sign in using the authService in the main process\n await authService.signInWithCustomToken(customToken);\n console.log('[Auth] Main process sign-in initiated. Waiting for onAuthStateChanged...');\n\n // 3. Focus the app window\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n } else {\n console.error('[Auth] Header window not found after auth callback.');\n }\n \n } catch (error) {\n console.error('[Auth] Error during custom token exchange or sign-in:', error);\n // The UI will not change, and the user can try again.\n // Optionally, send a generic error event to the renderer.\n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n if (header) {\n header.webContents.send('auth-failed', { message: error.message });\n }\n }\n}\n\nfunction handlePersonalizeFromUrl(params) {\n console.log('[Custom URL] Personalize params:', params);\n \n const { windowPool } = require('./window/windowManager.js');\n const header = windowPool.get('header');\n \n if (header) {\n if (header.isMinimized()) header.restore();\n header.focus();\n \n const personalizeUrl = `http://localhost:${WEB_PORT}/settings`;\n console.log(`[Custom URL] Navigating to personalize page: ${personalizeUrl}`);\n header.webContents.loadURL(personalizeUrl);\n \n BrowserWindow.getAllWindows().forEach(win => {\n win.webContents.send('enter-personalize-mode', {\n message: 'Personalization mode activated',\n params: params\n });\n });\n } else {\n console.error('[Custom URL] Header window not found for personalize');\n }\n}\n\n\nasync function startWebStack() {\n console.log('NODE_ENV =', process.env.NODE_ENV); \n const isDev = !app.isPackaged;\n\n const getAvailablePort = () => {\n return new Promise((resolve, reject) => {\n const server = require('net').createServer();\n server.listen(0, (err) => {\n if (err) reject(err);\n const port = server.address().port;\n server.close(() => resolve(port));\n });\n });\n };\n\n const apiPort = await getAvailablePort();\n const frontendPort = await getAvailablePort();\n\n console.log(`🔧 Allocated ports: API=${apiPort}, Frontend=${frontendPort}`);\n\n process.env.pickleglass_API_PORT = apiPort.toString();\n process.env.pickleglass_API_URL = `http://localhost:${apiPort}`;\n process.env.pickleglass_WEB_PORT = frontendPort.toString();\n process.env.pickleglass_WEB_URL = `http://localhost:${frontendPort}`;\n\n console.log(`🌍 Environment variables set:`, {\n pickleglass_API_URL: process.env.pickleglass_API_URL,\n pickleglass_WEB_URL: process.env.pickleglass_WEB_URL\n });\n\n const createBackendApp = require('../pickleglass_web/backend_node');\n const nodeApi = createBackendApp(eventBridge);\n\n const staticDir = app.isPackaged\n ? path.join(process.resourcesPath, 'out')\n : path.join(__dirname, '..', 'pickleglass_web', 'out');\n\n const fs = require('fs');\n\n if (!fs.existsSync(staticDir)) {\n console.error(`============================================================`);\n console.error(`[ERROR] Frontend build directory not found!`);\n console.error(`Path: ${staticDir}`);\n console.error(`Please run 'npm run build' inside the 'pickleglass_web' directory first.`);\n console.error(`============================================================`);\n app.quit();\n return;\n }\n\n const runtimeConfig = {\n API_URL: `http://localhost:${apiPort}`,\n WEB_URL: `http://localhost:${frontendPort}`,\n timestamp: Date.now()\n };\n \n // 쓰기 가능한 임시 폴더에 런타임 설정 파일 생성\n const tempDir = app.getPath('temp');\n const configPath = path.join(tempDir, 'runtime-config.json');\n fs.writeFileSync(configPath, JSON.stringify(runtimeConfig, null, 2));\n console.log(`📝 Runtime config created in temp location: ${configPath}`);\n\n const frontSrv = express();\n \n // 프론트엔드에서 /runtime-config.json을 요청하면 임시 폴더의 파일을 제공\n frontSrv.get('/runtime-config.json', (req, res) => {\n res.sendFile(configPath);\n });\n\n frontSrv.use((req, res, next) => {\n if (req.path.indexOf('.') === -1 && req.path !== '/') {\n const htmlPath = path.join(staticDir, req.path + '.html');\n if (fs.existsSync(htmlPath)) {\n return res.sendFile(htmlPath);\n }\n }\n next();\n });\n \n frontSrv.use(express.static(staticDir));\n \n const frontendServer = await new Promise((resolve, reject) => {\n const server = frontSrv.listen(frontendPort, '127.0.0.1', () => resolve(server));\n server.on('error', reject);\n app.once('before-quit', () => server.close());\n });\n\n console.log(`✅ Frontend server started on http://localhost:${frontendPort}`);\n\n const apiSrv = express();\n apiSrv.use(nodeApi);\n\n const apiServer = await new Promise((resolve, reject) => {\n const server = apiSrv.listen(apiPort, '127.0.0.1', () => resolve(server));\n server.on('error', reject);\n app.once('before-quit', () => server.close());\n });\n\n console.log(`✅ API server started on http://localhost:${apiPort}`);\n\n console.log(`🚀 All services ready:\n Frontend: http://localhost:${frontendPort}\n API: http://localhost:${apiPort}`);\n\n return frontendPort;\n}\n\n// Auto-update initialization\nasync function initAutoUpdater() {\n if (process.env.NODE_ENV === 'development') {\n console.log('Development environment, skipping auto-updater.');\n return;\n }\n\n try {\n await autoUpdater.checkForUpdates();\n autoUpdater.on('update-available', () => {\n console.log('Update available!');\n autoUpdater.downloadUpdate();\n });\n autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, date, url) => {\n console.log('Update downloaded:', releaseNotes, releaseName, date, url);\n dialog.showMessageBox({\n type: 'info',\n title: 'Application Update',\n message: `A new version of PickleGlass (${releaseName}) has been downloaded. It will be installed the next time you launch the application.`,\n buttons: ['Restart', 'Later']\n }).then(response => {\n if (response.response === 0) {\n autoUpdater.quitAndInstall();\n }\n });\n });\n autoUpdater.on('error', (err) => {\n console.error('Error in auto-updater:', err);\n });\n } catch (err) {\n console.error('Error initializing auto-updater:', err);\n }\n}"], ["/glass/src/features/listen/summary/summaryService.js", "const { BrowserWindow } = require('electron');\nconst { getSystemPrompt } = require('../../common/prompts/promptBuilder.js');\nconst { createLLM } = require('../../common/ai/factory');\nconst sessionRepository = require('../../common/repositories/session');\nconst summaryRepository = require('./repositories');\nconst modelStateService = require('../../common/services/modelStateService');\n\nclass SummaryService {\n constructor() {\n this.previousAnalysisResult = null;\n this.analysisHistory = [];\n this.conversationHistory = [];\n this.currentSessionId = null;\n \n // Callbacks\n this.onAnalysisComplete = null;\n this.onStatusUpdate = null;\n }\n\n setCallbacks({ onAnalysisComplete, onStatusUpdate }) {\n this.onAnalysisComplete = onAnalysisComplete;\n this.onStatusUpdate = onStatusUpdate;\n }\n\n setSessionId(sessionId) {\n this.currentSessionId = sessionId;\n }\n\n sendToRenderer(channel, data) {\n const { windowPool } = require('../../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n addConversationTurn(speaker, text) {\n const conversationText = `${speaker.toLowerCase()}: ${text.trim()}`;\n this.conversationHistory.push(conversationText);\n console.log(`💬 Added conversation text: ${conversationText}`);\n console.log(`📈 Total conversation history: ${this.conversationHistory.length} texts`);\n\n // Trigger analysis if needed\n this.triggerAnalysisIfNeeded();\n }\n\n getConversationHistory() {\n return this.conversationHistory;\n }\n\n resetConversationHistory() {\n this.conversationHistory = [];\n this.previousAnalysisResult = null;\n this.analysisHistory = [];\n console.log('🔄 Conversation history and analysis state reset');\n }\n\n /**\n * Converts conversation history into text to include in the prompt.\n * @param {Array} conversationTexts - Array of conversation texts [\"me: ~~~\", \"them: ~~~\", ...]\n * @param {number} maxTurns - Maximum number of recent turns to include\n * @returns {string} - Formatted conversation string for the prompt\n */\n formatConversationForPrompt(conversationTexts, maxTurns = 30) {\n if (conversationTexts.length === 0) return '';\n return conversationTexts.slice(-maxTurns).join('\\n');\n }\n\n async makeOutlineAndRequests(conversationTexts, maxTurns = 30) {\n console.log(`🔍 makeOutlineAndRequests called - conversationTexts: ${conversationTexts.length}`);\n\n if (conversationTexts.length === 0) {\n console.log('⚠️ No conversation texts available for analysis');\n return null;\n }\n\n const recentConversation = this.formatConversationForPrompt(conversationTexts, maxTurns);\n\n // 이전 분석 결과를 프롬프트에 포함\n let contextualPrompt = '';\n if (this.previousAnalysisResult) {\n contextualPrompt = `\nPrevious Analysis Context:\n- Main Topic: ${this.previousAnalysisResult.topic.header}\n- Key Points: ${this.previousAnalysisResult.summary.slice(0, 3).join(', ')}\n- Last Actions: ${this.previousAnalysisResult.actions.slice(0, 2).join(', ')}\n\nPlease build upon this context while analyzing the new conversation segments.\n`;\n }\n\n const basePrompt = getSystemPrompt('pickle_glass_analysis', '', false);\n const systemPrompt = basePrompt.replace('{{CONVERSATION_HISTORY}}', recentConversation);\n\n try {\n if (this.currentSessionId) {\n await sessionRepository.touch(this.currentSessionId);\n }\n\n const modelInfo = await modelStateService.getCurrentModelInfo('llm');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key is not configured.');\n }\n console.log(`🤖 Sending analysis request to ${modelInfo.provider} using model ${modelInfo.model}`);\n \n const messages = [\n {\n role: 'system',\n content: systemPrompt,\n },\n {\n role: 'user',\n content: `${contextualPrompt}\n\nAnalyze the conversation and provide a structured summary. Format your response as follows:\n\n**Summary Overview**\n- Main discussion point with context\n\n**Key Topic: [Topic Name]**\n- First key insight\n- Second key insight\n- Third key insight\n\n**Extended Explanation**\nProvide 2-3 sentences explaining the context and implications.\n\n**Suggested Questions**\n1. First follow-up question?\n2. Second follow-up question?\n3. Third follow-up question?\n\nKeep all points concise and build upon previous analysis if provided.`,\n },\n ];\n\n console.log('🤖 Sending analysis request to AI...');\n\n const llm = createLLM(modelInfo.provider, {\n apiKey: modelInfo.apiKey,\n model: modelInfo.model,\n temperature: 0.7,\n maxTokens: 1024,\n usePortkey: modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: modelInfo.provider === 'openai-glass' ? modelInfo.apiKey : undefined,\n });\n\n const completion = await llm.chat(messages);\n\n const responseText = completion.content;\n console.log(`✅ Analysis response received: ${responseText}`);\n const structuredData = this.parseResponseText(responseText, this.previousAnalysisResult);\n\n if (this.currentSessionId) {\n try {\n summaryRepository.saveSummary({\n sessionId: this.currentSessionId,\n text: responseText,\n tldr: structuredData.summary.join('\\n'),\n bullet_json: JSON.stringify(structuredData.topic.bullets),\n action_json: JSON.stringify(structuredData.actions),\n model: modelInfo.model\n });\n } catch (err) {\n console.error('[DB] Failed to save summary:', err);\n }\n }\n\n // 분석 결과 저장\n this.previousAnalysisResult = structuredData;\n this.analysisHistory.push({\n timestamp: Date.now(),\n data: structuredData,\n conversationLength: conversationTexts.length,\n });\n\n if (this.analysisHistory.length > 10) {\n this.analysisHistory.shift();\n }\n\n return structuredData;\n } catch (error) {\n console.error('❌ Error during analysis generation:', error.message);\n return this.previousAnalysisResult; // 에러 시 이전 결과 반환\n }\n }\n\n parseResponseText(responseText, previousResult) {\n const structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: ['✉️ Draft a follow-up email', '✅ Generate action items', '📝 Show summary'],\n };\n\n // 이전 결과가 있으면 기본값으로 사용\n if (previousResult) {\n structuredData.topic.header = previousResult.topic.header;\n structuredData.summary = [...previousResult.summary];\n }\n\n try {\n const lines = responseText.split('\\n');\n let currentSection = '';\n let isCapturingTopic = false;\n let topicName = '';\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n // 섹션 헤더 감지\n if (trimmedLine.startsWith('**Summary Overview**')) {\n currentSection = 'summary-overview';\n continue;\n } else if (trimmedLine.startsWith('**Key Topic:')) {\n currentSection = 'topic';\n isCapturingTopic = true;\n topicName = trimmedLine.match(/\\*\\*Key Topic: (.+?)\\*\\*/)?.[1] || '';\n if (topicName) {\n structuredData.topic.header = topicName + ':';\n }\n continue;\n } else if (trimmedLine.startsWith('**Extended Explanation**')) {\n currentSection = 'explanation';\n continue;\n } else if (trimmedLine.startsWith('**Suggested Questions**')) {\n currentSection = 'questions';\n continue;\n }\n\n // 컨텐츠 파싱\n if (trimmedLine.startsWith('-') && currentSection === 'summary-overview') {\n const summaryPoint = trimmedLine.substring(1).trim();\n if (summaryPoint && !structuredData.summary.includes(summaryPoint)) {\n // 기존 summary 업데이트 (최대 5개 유지)\n structuredData.summary.unshift(summaryPoint);\n if (structuredData.summary.length > 5) {\n structuredData.summary.pop();\n }\n }\n } else if (trimmedLine.startsWith('-') && currentSection === 'topic') {\n const bullet = trimmedLine.substring(1).trim();\n if (bullet && structuredData.topic.bullets.length < 3) {\n structuredData.topic.bullets.push(bullet);\n }\n } else if (currentSection === 'explanation' && trimmedLine) {\n // explanation을 topic bullets에 추가 (문장 단위로)\n const sentences = trimmedLine\n .split(/\\.\\s+/)\n .filter(s => s.trim().length > 0)\n .map(s => s.trim() + (s.endsWith('.') ? '' : '.'));\n\n sentences.forEach(sentence => {\n if (structuredData.topic.bullets.length < 3 && !structuredData.topic.bullets.includes(sentence)) {\n structuredData.topic.bullets.push(sentence);\n }\n });\n } else if (trimmedLine.match(/^\\d+\\./) && currentSection === 'questions') {\n const question = trimmedLine.replace(/^\\d+\\.\\s*/, '').trim();\n if (question && question.includes('?')) {\n structuredData.actions.push(`❓ ${question}`);\n }\n }\n }\n\n // 기본 액션 추가\n const defaultActions = ['✨ What should I say next?', '💬 Suggest follow-up questions'];\n defaultActions.forEach(action => {\n if (!structuredData.actions.includes(action)) {\n structuredData.actions.push(action);\n }\n });\n\n // 액션 개수 제한\n structuredData.actions = structuredData.actions.slice(0, 5);\n\n // 유효성 검증 및 이전 데이터 병합\n if (structuredData.summary.length === 0 && previousResult) {\n structuredData.summary = previousResult.summary;\n }\n if (structuredData.topic.bullets.length === 0 && previousResult) {\n structuredData.topic.bullets = previousResult.topic.bullets;\n }\n } catch (error) {\n console.error('❌ Error parsing response text:', error);\n // 에러 시 이전 결과 반환\n return (\n previousResult || {\n summary: [],\n topic: { header: 'Analysis in progress', bullets: [] },\n actions: ['✨ What should I say next?', '💬 Suggest follow-up questions'],\n followUps: ['✉️ Draft a follow-up email', '✅ Generate action items', '📝 Show summary'],\n }\n );\n }\n\n console.log('📊 Final structured data:', JSON.stringify(structuredData, null, 2));\n return structuredData;\n }\n\n /**\n * Triggers analysis when conversation history reaches 5 texts.\n */\n async triggerAnalysisIfNeeded() {\n if (this.conversationHistory.length >= 5 && this.conversationHistory.length % 5 === 0) {\n console.log(`Triggering analysis - ${this.conversationHistory.length} conversation texts accumulated`);\n\n const data = await this.makeOutlineAndRequests(this.conversationHistory);\n if (data) {\n console.log('Sending structured data to renderer');\n this.sendToRenderer('summary-update', data);\n \n // Notify callback\n if (this.onAnalysisComplete) {\n this.onAnalysisComplete(data);\n }\n } else {\n console.log('No analysis data returned');\n }\n }\n }\n\n getCurrentAnalysisData() {\n return {\n previousResult: this.previousAnalysisResult,\n history: this.analysisHistory,\n conversationLength: this.conversationHistory.length,\n };\n }\n}\n\nmodule.exports = SummaryService; "], ["/glass/src/features/settings/repositories/firebase.repository.js", "const { collection, doc, addDoc, getDoc, getDocs, updateDoc, deleteDoc, query, where, orderBy } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../common/services/firebaseClient');\nconst { createEncryptedConverter } = require('../../common/repositories/firestoreConverter');\nconst encryptionService = require('../../common/services/encryptionService');\n\nconst userPresetConverter = createEncryptedConverter(['prompt', 'title']);\n\nconst defaultPresetConverter = {\n toFirestore: (data) => data,\n fromFirestore: (snapshot, options) => {\n const data = snapshot.data(options);\n return { ...data, id: snapshot.id };\n }\n};\n\nfunction userPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'prompt_presets').withConverter(userPresetConverter);\n}\n\nfunction defaultPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'defaults/v1/prompt_presets').withConverter(defaultPresetConverter);\n}\n\nasync function getPresets(uid) {\n const userPresetsQuery = query(userPresetsCol(), where('uid', '==', uid));\n const defaultPresetsQuery = query(defaultPresetsCol());\n\n const [userSnapshot, defaultSnapshot] = await Promise.all([\n getDocs(userPresetsQuery),\n getDocs(defaultPresetsQuery)\n ]);\n\n const presets = [\n ...defaultSnapshot.docs.map(d => d.data()),\n ...userSnapshot.docs.map(d => d.data())\n ];\n\n return presets.sort((a, b) => {\n if (a.is_default && !b.is_default) return -1;\n if (!a.is_default && b.is_default) return 1;\n return a.title.localeCompare(b.title);\n });\n}\n\nasync function getPresetTemplates() {\n const q = query(defaultPresetsCol(), orderBy('title', 'asc'));\n const snapshot = await getDocs(q);\n return snapshot.docs.map(doc => doc.data());\n}\n\nasync function createPreset({ uid, title, prompt }) {\n const now = Math.floor(Date.now() / 1000);\n const newPreset = {\n uid: uid,\n title,\n prompt,\n is_default: 0,\n created_at: now,\n };\n const docRef = await addDoc(userPresetsCol(), newPreset);\n return { id: docRef.id };\n}\n\nasync function updatePreset(id, { title, prompt }, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to update.\");\n }\n\n const updates = {};\n if (title !== undefined) {\n updates.title = encryptionService.encrypt(title);\n }\n if (prompt !== undefined) {\n updates.prompt = encryptionService.encrypt(prompt);\n }\n updates.updated_at = Math.floor(Date.now() / 1000);\n \n await updateDoc(docRef, updates);\n return { changes: 1 };\n}\n\nasync function deletePreset(id, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to delete.\");\n }\n\n await deleteDoc(docRef);\n return { changes: 1 };\n}\n\nasync function getAutoUpdate(uid) {\n // Assume users are stored in a \"users\" collection, and auto_update_enabled is a field\n const userDocRef = doc(getFirestoreInstance(), 'users', uid);\n try {\n const userSnap = await getDoc(userDocRef);\n if (userSnap.exists()) {\n const data = userSnap.data();\n if (typeof data.auto_update_enabled !== 'undefined') {\n console.log('Firebase: Auto update setting found:', data.auto_update_enabled);\n return !!data.auto_update_enabled;\n } else {\n // Field does not exist, just return default\n return true;\n }\n } else {\n // User doc does not exist, just return default\n return true;\n }\n } catch (error) {\n console.error('Firebase: Error getting auto_update_enabled setting:', error);\n return true; // fallback to enabled\n }\n}\n\nasync function setAutoUpdate(uid, isEnabled) {\n const userDocRef = doc(getFirestoreInstance(), 'users', uid);\n try {\n const userSnap = await getDoc(userDocRef);\n if (userSnap.exists()) {\n await updateDoc(userDocRef, { auto_update_enabled: !!isEnabled });\n }\n // If user doc does not exist, do nothing (no creation)\n return { success: true };\n } catch (error) {\n console.error('Firebase: Error setting auto-update:', error);\n return { success: false, error: error.message };\n }\n}\n\n\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n getAutoUpdate,\n setAutoUpdate,\n}; "], ["/glass/src/features/common/services/modelStateService.js", "const { EventEmitter } = require('events');\nconst Store = require('electron-store');\nconst { PROVIDERS, getProviderClass } = require('../ai/factory');\nconst encryptionService = require('./encryptionService');\nconst providerSettingsRepository = require('../repositories/providerSettings');\nconst authService = require('./authService');\nconst ollamaModelRepository = require('../repositories/ollamaModel');\n\nclass ModelStateService extends EventEmitter {\n constructor() {\n super();\n this.authService = authService;\n // electron-store는 오직 레거시 데이터 마이그레이션 용도로만 사용됩니다.\n this.store = new Store({ name: 'pickle-glass-model-state' });\n }\n\n async initialize() {\n console.log('[ModelStateService] Initializing one-time setup...');\n await this._initializeEncryption();\n await this._runMigrations();\n this.setupLocalAIStateSync();\n await this._autoSelectAvailableModels([], true);\n console.log('[ModelStateService] One-time setup complete.');\n }\n\n async _initializeEncryption() {\n try {\n const rows = await providerSettingsRepository.getRawApiKeys();\n if (rows.some(r => r.api_key && encryptionService.looksEncrypted(r.api_key))) {\n console.log('[ModelStateService] Encrypted keys detected, initializing encryption...');\n const userIdForMigration = this.authService.getCurrentUserId();\n await encryptionService.initializeKey(userIdForMigration);\n } else {\n console.log('[ModelStateService] No encrypted keys detected, skipping encryption initialization.');\n }\n } catch (err) {\n console.warn('[ModelStateService] Error while checking encrypted keys:', err.message);\n }\n }\n\n async _runMigrations() {\n console.log('[ModelStateService] Checking for data migrations...');\n const userId = this.authService.getCurrentUserId();\n \n try {\n const sqliteClient = require('./sqliteClient');\n const db = sqliteClient.getDb();\n const tableExists = db.prepare(\"SELECT name FROM sqlite_master WHERE type='table' AND name='user_model_selections'\").get();\n \n if (tableExists) {\n const selections = db.prepare('SELECT * FROM user_model_selections WHERE uid = ?').get(userId);\n if (selections) {\n console.log('[ModelStateService] Migrating from user_model_selections table...');\n if (selections.llm_model) {\n const llmProvider = this.getProviderForModel(selections.llm_model, 'llm');\n if (llmProvider) {\n await this.setSelectedModel('llm', selections.llm_model);\n }\n }\n if (selections.stt_model) {\n const sttProvider = this.getProviderForModel(selections.stt_model, 'stt');\n if (sttProvider) {\n await this.setSelectedModel('stt', selections.stt_model);\n }\n }\n db.prepare('DROP TABLE user_model_selections').run();\n console.log('[ModelStateService] user_model_selections migration complete.');\n }\n }\n } catch (error) {\n console.error('[ModelStateService] user_model_selections migration failed:', error);\n }\n\n try {\n const legacyData = this.store.get(`users.${userId}`);\n if (legacyData && legacyData.apiKeys) {\n console.log('[ModelStateService] Migrating from electron-store...');\n for (const [provider, apiKey] of Object.entries(legacyData.apiKeys)) {\n if (apiKey && PROVIDERS[provider]) {\n await this.setApiKey(provider, apiKey);\n }\n }\n if (legacyData.selectedModels?.llm) {\n await this.setSelectedModel('llm', legacyData.selectedModels.llm);\n }\n if (legacyData.selectedModels?.stt) {\n await this.setSelectedModel('stt', legacyData.selectedModels.stt);\n }\n this.store.delete(`users.${userId}`);\n console.log('[ModelStateService] electron-store migration complete.');\n }\n } catch (error) {\n console.error('[ModelStateService] electron-store migration failed:', error);\n }\n }\n \n setupLocalAIStateSync() {\n const localAIManager = require('./localAIManager');\n localAIManager.on('state-changed', (service, status) => {\n this.handleLocalAIStateChange(service, status);\n });\n }\n\n async handleLocalAIStateChange(service, state) {\n console.log(`[ModelStateService] LocalAI state changed: ${service}`, state);\n if (!state.installed || !state.running) {\n const types = service === 'ollama' ? ['llm'] : service === 'whisper' ? ['stt'] : [];\n await this._autoSelectAvailableModels(types);\n }\n this.emit('state-updated', await this.getLiveState());\n }\n\n async getLiveState() {\n const providerSettings = await providerSettingsRepository.getAll();\n const apiKeys = {};\n Object.keys(PROVIDERS).forEach(provider => {\n const setting = providerSettings.find(s => s.provider === provider);\n apiKeys[provider] = setting?.api_key || null;\n });\n\n const activeSettings = await providerSettingsRepository.getActiveSettings();\n const selectedModels = {\n llm: activeSettings.llm?.selected_llm_model || null,\n stt: activeSettings.stt?.selected_stt_model || null\n };\n \n return { apiKeys, selectedModels };\n }\n\n async _autoSelectAvailableModels(forceReselectionForTypes = [], isInitialBoot = false) {\n console.log(`[ModelStateService] Running auto-selection. Force re-selection for: [${forceReselectionForTypes.join(', ')}]`);\n const { apiKeys, selectedModels } = await this.getLiveState();\n const types = ['llm', 'stt'];\n\n for (const type of types) {\n const currentModelId = selectedModels[type];\n let isCurrentModelValid = false;\n const forceReselection = forceReselectionForTypes.includes(type);\n\n if (currentModelId && !forceReselection) {\n const provider = this.getProviderForModel(currentModelId, type);\n const apiKey = apiKeys[provider];\n if (provider && apiKey) {\n isCurrentModelValid = true;\n }\n }\n\n if (!isCurrentModelValid) {\n console.log(`[ModelStateService] No valid ${type.toUpperCase()} model selected or selection forced. Finding an alternative...`);\n const availableModels = await this.getAvailableModels(type);\n if (availableModels.length > 0) {\n const apiModel = availableModels.find(model => {\n const provider = this.getProviderForModel(model.id, type);\n return provider && provider !== 'ollama' && provider !== 'whisper';\n });\n const newModel = apiModel || availableModels[0];\n await this.setSelectedModel(type, newModel.id);\n console.log(`[ModelStateService] Auto-selected ${type.toUpperCase()} model: ${newModel.id}`);\n } else {\n await providerSettingsRepository.setActiveProvider(null, type);\n if (!isInitialBoot) {\n this.emit('state-updated', await this.getLiveState());\n }\n }\n }\n }\n }\n \n async setFirebaseVirtualKey(virtualKey) {\n console.log(`[ModelStateService] Setting Firebase virtual key.`);\n\n // 키를 설정하기 전에, 이전에 openai-glass 키가 있었는지 확인합니다.\n const previousSettings = await providerSettingsRepository.getByProvider('openai-glass');\n const wasPreviouslyConfigured = !!previousSettings?.api_key;\n\n // 항상 새로운 가상 키로 업데이트합니다.\n await this.setApiKey('openai-glass', virtualKey);\n\n if (virtualKey) {\n // 이전에 설정된 적이 없는 경우 (최초 로그인)에만 모델을 강제로 변경합니다.\n if (!wasPreviouslyConfigured) {\n console.log('[ModelStateService] First-time setup for openai-glass, setting default models.');\n const llmModel = PROVIDERS['openai-glass']?.llmModels[0];\n const sttModel = PROVIDERS['openai-glass']?.sttModels[0];\n if (llmModel) await this.setSelectedModel('llm', llmModel.id);\n if (sttModel) await this.setSelectedModel('stt', sttModel.id);\n } else {\n console.log('[ModelStateService] openai-glass key updated, but respecting user\\'s existing model selection.');\n }\n } else {\n // 로그아웃 시, 현재 활성화된 모델이 openai-glass인 경우에만 다른 모델로 전환합니다.\n const selected = await this.getSelectedModels();\n const llmProvider = this.getProviderForModel(selected.llm, 'llm');\n const sttProvider = this.getProviderForModel(selected.stt, 'stt');\n \n const typesToReselect = [];\n if (llmProvider === 'openai-glass') typesToReselect.push('llm');\n if (sttProvider === 'openai-glass') typesToReselect.push('stt');\n\n if (typesToReselect.length > 0) {\n console.log('[ModelStateService] Logged out, re-selecting models for:', typesToReselect.join(', '));\n await this._autoSelectAvailableModels(typesToReselect);\n }\n }\n }\n\n async setApiKey(provider, key) {\n console.log(`[ModelStateService] setApiKey for ${provider}`);\n if (!provider) {\n throw new Error('Provider is required');\n }\n\n // 'openai-glass'는 자체 인증 키를 사용하므로 유효성 검사를 건너뜁니다.\n if (provider !== 'openai-glass') {\n const validationResult = await this.validateApiKey(provider, key);\n if (!validationResult.success) {\n console.warn(`[ModelStateService] API key validation failed for ${provider}: ${validationResult.error}`);\n return validationResult;\n }\n }\n\n const finalKey = (provider === 'ollama' || provider === 'whisper') ? 'local' : key;\n const existingSettings = await providerSettingsRepository.getByProvider(provider) || {};\n await providerSettingsRepository.upsert(provider, { ...existingSettings, api_key: finalKey });\n \n // 키가 추가/변경되었으므로, 해당 provider의 모델을 자동 선택할 수 있는지 확인\n await this._autoSelectAvailableModels([]);\n \n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return { success: true };\n }\n\n async getAllApiKeys() {\n const allSettings = await providerSettingsRepository.getAll();\n const apiKeys = {};\n allSettings.forEach(s => {\n if (s.provider !== 'openai-glass') {\n apiKeys[s.provider] = s.api_key;\n }\n });\n return apiKeys;\n }\n\n async removeApiKey(provider) {\n const setting = await providerSettingsRepository.getByProvider(provider);\n if (setting && setting.api_key) {\n await providerSettingsRepository.upsert(provider, { ...setting, api_key: null });\n await this._autoSelectAvailableModels(['llm', 'stt']);\n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return true;\n }\n return false;\n }\n\n /**\n * 사용자가 Firebase에 로그인했는지 확인합니다.\n */\n isLoggedInWithFirebase() {\n return this.authService.getCurrentUser().isLoggedIn;\n }\n\n /**\n * 유효한 API 키가 하나라도 설정되어 있는지 확인합니다.\n */\n async hasValidApiKey() {\n if (this.isLoggedInWithFirebase()) return true;\n \n const allSettings = await providerSettingsRepository.getAll();\n return allSettings.some(s => s.api_key && s.api_key.trim().length > 0);\n }\n\n getProviderForModel(arg1, arg2) {\n // Compatibility: support both (type, modelId) old order and (modelId, type) new order\n let type, modelId;\n if (arg1 === 'llm' || arg1 === 'stt') {\n type = arg1;\n modelId = arg2;\n } else {\n modelId = arg1;\n type = arg2;\n }\n if (!modelId || !type) return null;\n for (const providerId in PROVIDERS) {\n const models = type === 'llm' ? PROVIDERS[providerId].llmModels : PROVIDERS[providerId].sttModels;\n if (models && models.some(m => m.id === modelId)) {\n return providerId;\n }\n }\n if (type === 'llm') {\n const installedModels = ollamaModelRepository.getInstalledModels();\n if (installedModels.some(m => m.name === modelId)) return 'ollama';\n }\n return null;\n }\n\n async getSelectedModels() {\n const active = await providerSettingsRepository.getActiveSettings();\n return {\n llm: active.llm?.selected_llm_model || null,\n stt: active.stt?.selected_stt_model || null,\n };\n }\n \n async setSelectedModel(type, modelId) {\n const provider = this.getProviderForModel(modelId, type);\n if (!provider) {\n console.warn(`[ModelStateService] No provider found for model ${modelId}`);\n return false;\n }\n\n const existingSettings = await providerSettingsRepository.getByProvider(provider) || {};\n const newSettings = { ...existingSettings };\n\n if (type === 'llm') {\n newSettings.selected_llm_model = modelId;\n } else {\n newSettings.selected_stt_model = modelId;\n }\n \n await providerSettingsRepository.upsert(provider, newSettings);\n await providerSettingsRepository.setActiveProvider(provider, type);\n \n console.log(`[ModelStateService] Selected ${type} model: ${modelId} (provider: ${provider})`);\n \n if (type === 'llm' && provider === 'ollama') {\n require('./localAIManager').warmUpModel(modelId).catch(err => console.warn(err));\n }\n \n this.emit('state-updated', await this.getLiveState());\n this.emit('settings-updated');\n return true;\n }\n\n async getAvailableModels(type) {\n const allSettings = await providerSettingsRepository.getAll();\n const available = [];\n const modelListKey = type === 'llm' ? 'llmModels' : 'sttModels';\n\n for (const setting of allSettings) {\n if (!setting.api_key) continue;\n\n const providerId = setting.provider;\n if (providerId === 'ollama' && type === 'llm') {\n const installed = ollamaModelRepository.getInstalledModels();\n available.push(...installed.map(m => ({ id: m.name, name: m.name })));\n } else if (PROVIDERS[providerId]?.[modelListKey]) {\n available.push(...PROVIDERS[providerId][modelListKey]);\n }\n }\n return [...new Map(available.map(item => [item.id, item])).values()];\n }\n\n async getCurrentModelInfo(type) {\n const activeSetting = await providerSettingsRepository.getActiveProvider(type);\n if (!activeSetting) return null;\n \n const model = type === 'llm' ? activeSetting.selected_llm_model : activeSetting.selected_stt_model;\n if (!model) return null;\n\n return {\n provider: activeSetting.provider,\n model: model,\n apiKey: activeSetting.api_key,\n };\n }\n\n // --- 핸들러 및 유틸리티 메서드 ---\n\n async validateApiKey(provider, key) {\n if (!key || (key.trim() === '' && provider !== 'ollama' && provider !== 'whisper')) {\n return { success: false, error: 'API key cannot be empty.' };\n }\n const ProviderClass = getProviderClass(provider);\n if (!ProviderClass || typeof ProviderClass.validateApiKey !== 'function') {\n return { success: true };\n }\n try {\n return await ProviderClass.validateApiKey(key);\n } catch (error) {\n return { success: false, error: 'An unexpected error occurred during validation.' };\n }\n }\n\n getProviderConfig() {\n const config = {};\n for (const key in PROVIDERS) {\n const { handler, ...rest } = PROVIDERS[key];\n config[key] = rest;\n }\n return config;\n }\n \n async handleRemoveApiKey(provider) {\n const success = await this.removeApiKey(provider);\n if (success) {\n const selectedModels = await this.getSelectedModels();\n if (!selectedModels.llm && !selectedModels.stt) {\n this.emit('force-show-apikey-header');\n }\n }\n return success;\n }\n\n /*-------------- Compatibility Helpers --------------*/\n async handleValidateKey(provider, key) {\n return await this.setApiKey(provider, key);\n }\n\n async handleSetSelectedModel(type, modelId) {\n return await this.setSelectedModel(type, modelId);\n }\n\n async areProvidersConfigured() {\n if (this.isLoggedInWithFirebase()) return true;\n const allSettings = await providerSettingsRepository.getAll();\n const apiKeyMap = {};\n allSettings.forEach(s => apiKeyMap[s.provider] = s.api_key);\n // LLM\n const hasLlmKey = Object.entries(apiKeyMap).some(([provider, key]) => {\n if (!key) return false;\n if (provider === 'whisper') return false; // whisper는 LLM 없음\n return PROVIDERS[provider]?.llmModels?.length > 0;\n });\n // STT\n const hasSttKey = Object.entries(apiKeyMap).some(([provider, key]) => {\n if (!key) return false;\n if (provider === 'ollama') return false; // ollama는 STT 없음\n return PROVIDERS[provider]?.sttModels?.length > 0 || provider === 'whisper';\n });\n return hasLlmKey && hasSttKey;\n }\n}\n\nconst modelStateService = new ModelStateService();\nmodule.exports = modelStateService;"], ["/glass/src/features/common/services/whisperService.js", "const { EventEmitter } = require('events');\nconst { spawn, exec } = require('child_process');\nconst { promisify } = require('util');\nconst path = require('path');\nconst fs = require('fs');\nconst os = require('os');\nconst https = require('https');\nconst crypto = require('crypto');\nconst { spawnAsync } = require('../utils/spawnHelper');\nconst { DOWNLOAD_CHECKSUMS } = require('../config/checksums');\n\nconst execAsync = promisify(exec);\n\nconst fsPromises = fs.promises;\n\nclass WhisperService extends EventEmitter {\n constructor() {\n super();\n this.serviceName = 'WhisperService';\n \n // 경로 및 디렉토리\n this.whisperPath = null;\n this.modelsDir = null;\n this.tempDir = null;\n \n // 세션 관리 (세션 풀 내장)\n this.sessionPool = [];\n this.activeSessions = new Map();\n this.maxSessions = 3;\n \n // 설치 상태\n this.installState = {\n isInstalled: false,\n isInitialized: false\n };\n \n // 사용 가능한 모델\n this.availableModels = {\n 'whisper-tiny': {\n name: 'Tiny',\n size: '39M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin'\n },\n 'whisper-base': {\n name: 'Base',\n size: '74M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin'\n },\n 'whisper-small': {\n name: 'Small',\n size: '244M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin'\n },\n 'whisper-medium': {\n name: 'Medium',\n size: '769M',\n url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin'\n }\n };\n }\n\n\n // Base class methods integration\n getPlatform() {\n return process.platform;\n }\n\n async checkCommand(command) {\n try {\n const platform = this.getPlatform();\n const checkCmd = platform === 'win32' ? 'where' : 'which';\n const { stdout } = await execAsync(`${checkCmd} ${command}`);\n return stdout.trim();\n } catch (error) {\n return null;\n }\n }\n\n async waitForService(checkFn, maxAttempts = 30, delayMs = 1000) {\n for (let i = 0; i < maxAttempts; i++) {\n if (await checkFn()) {\n console.log(`[${this.serviceName}] Service is ready`);\n return true;\n }\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n throw new Error(`${this.serviceName} service failed to start within timeout`);\n }\n\n async downloadFile(url, destination, options = {}) {\n const { \n onProgress = null,\n headers = { 'User-Agent': 'Glass-App' },\n timeout = 300000,\n modelId = null\n } = options;\n\n return new Promise((resolve, reject) => {\n const file = fs.createWriteStream(destination);\n let downloadedSize = 0;\n let totalSize = 0;\n\n const request = https.get(url, { headers }, (response) => {\n if ([301, 302, 307, 308].includes(response.statusCode)) {\n file.close();\n fs.unlink(destination, () => {});\n \n if (!response.headers.location) {\n reject(new Error('Redirect without location header'));\n return;\n }\n \n console.log(`[${this.serviceName}] Following redirect from ${url} to ${response.headers.location}`);\n this.downloadFile(response.headers.location, destination, options)\n .then(resolve)\n .catch(reject);\n return;\n }\n\n if (response.statusCode !== 200) {\n file.close();\n fs.unlink(destination, () => {});\n reject(new Error(`Download failed: ${response.statusCode} ${response.statusMessage}`));\n return;\n }\n\n totalSize = parseInt(response.headers['content-length'], 10) || 0;\n\n response.on('data', (chunk) => {\n downloadedSize += chunk.length;\n \n if (totalSize > 0) {\n const progress = Math.round((downloadedSize / totalSize) * 100);\n \n if (onProgress) {\n onProgress(progress, downloadedSize, totalSize);\n }\n }\n });\n\n response.pipe(file);\n\n file.on('finish', () => {\n file.close(() => {\n resolve({ success: true, size: downloadedSize });\n });\n });\n });\n\n request.on('timeout', () => {\n request.destroy();\n file.close();\n fs.unlink(destination, () => {});\n reject(new Error('Download timeout'));\n });\n\n request.on('error', (err) => {\n file.close();\n fs.unlink(destination, () => {});\n this.emit('download-error', { url, error: err, modelId });\n reject(err);\n });\n\n request.setTimeout(timeout);\n\n file.on('error', (err) => {\n fs.unlink(destination, () => {});\n reject(err);\n });\n });\n }\n\n async downloadWithRetry(url, destination, options = {}) {\n const { \n maxRetries = 3, \n retryDelay = 1000, \n expectedChecksum = null,\n modelId = null,\n ...downloadOptions \n } = options;\n \n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n try {\n const result = await this.downloadFile(url, destination, { \n ...downloadOptions, \n modelId \n });\n \n if (expectedChecksum) {\n const isValid = await this.verifyChecksum(destination, expectedChecksum);\n if (!isValid) {\n fs.unlinkSync(destination);\n throw new Error('Checksum verification failed');\n }\n console.log(`[${this.serviceName}] Checksum verified successfully`);\n }\n \n return result;\n } catch (error) {\n if (attempt === maxRetries) {\n throw error;\n }\n \n console.log(`Download attempt ${attempt} failed, retrying in ${retryDelay}ms...`);\n await new Promise(resolve => setTimeout(resolve, retryDelay * attempt));\n }\n }\n }\n\n async verifyChecksum(filePath, expectedChecksum) {\n return new Promise((resolve, reject) => {\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(filePath);\n \n stream.on('data', (data) => hash.update(data));\n stream.on('end', () => {\n const fileChecksum = hash.digest('hex');\n console.log(`[${this.serviceName}] File checksum: ${fileChecksum}`);\n console.log(`[${this.serviceName}] Expected checksum: ${expectedChecksum}`);\n resolve(fileChecksum === expectedChecksum);\n });\n stream.on('error', reject);\n });\n }\n\n async autoInstall(onProgress) {\n const platform = this.getPlatform();\n console.log(`[${this.serviceName}] Starting auto-installation for ${platform}`);\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.installMacOS(onProgress);\n case 'win32':\n return await this.installWindows(onProgress);\n case 'linux':\n return await this.installLinux();\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Auto-installation failed:`, error);\n throw error;\n }\n }\n\n async shutdown(force = false) {\n console.log(`[${this.serviceName}] Starting ${force ? 'forced' : 'graceful'} shutdown...`);\n \n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log(`[${this.serviceName}] Service not running, nothing to shutdown`);\n return true;\n }\n\n const platform = this.getPlatform();\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.shutdownMacOS(force);\n case 'win32':\n return await this.shutdownWindows(force);\n case 'linux':\n return await this.shutdownLinux(force);\n default:\n console.warn(`[${this.serviceName}] Unsupported platform for shutdown: ${platform}`);\n return false;\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Error during shutdown:`, error);\n return false;\n }\n }\n\n async initialize() {\n if (this.installState.isInitialized) return;\n\n try {\n const homeDir = os.homedir();\n const whisperDir = path.join(homeDir, '.glass', 'whisper');\n \n this.modelsDir = path.join(whisperDir, 'models');\n this.tempDir = path.join(whisperDir, 'temp');\n \n // Windows에서는 .exe 확장자 필요\n const platform = this.getPlatform();\n const whisperExecutable = platform === 'win32' ? 'whisper-whisper.exe' : 'whisper';\n this.whisperPath = path.join(whisperDir, 'bin', whisperExecutable);\n\n await this.ensureDirectories();\n await this.ensureWhisperBinary();\n \n this.installState.isInitialized = true;\n console.log('[WhisperService] Initialized successfully');\n } catch (error) {\n console.error('[WhisperService] Initialization failed:', error);\n // Emit error event - LocalAIManager가 처리\n this.emit('error', {\n errorType: 'initialization-failed',\n error: error.message\n });\n throw error;\n }\n }\n\n async ensureDirectories() {\n await fsPromises.mkdir(this.modelsDir, { recursive: true });\n await fsPromises.mkdir(this.tempDir, { recursive: true });\n await fsPromises.mkdir(path.dirname(this.whisperPath), { recursive: true });\n }\n\n // local stt session\n async getSession(config) {\n // check available session\n const availableSession = this.sessionPool.find(s => !s.inUse);\n if (availableSession) {\n availableSession.inUse = true;\n await availableSession.reconfigure(config);\n return availableSession;\n }\n\n // create new session\n if (this.activeSessions.size >= this.maxSessions) {\n throw new Error('Maximum session limit reached');\n }\n\n const session = new WhisperSession(config, this);\n await session.initialize();\n this.activeSessions.set(session.id, session);\n \n return session;\n }\n\n async releaseSession(sessionId) {\n const session = this.activeSessions.get(sessionId);\n if (session) {\n await session.cleanup();\n session.inUse = false;\n \n // add to session pool\n if (this.sessionPool.length < 2) {\n this.sessionPool.push(session);\n } else {\n // remove session\n await session.destroy();\n this.activeSessions.delete(sessionId);\n }\n }\n }\n\n //cleanup\n async cleanup() {\n // cleanup all sessions\n for (const session of this.activeSessions.values()) {\n await session.destroy();\n }\n \n this.activeSessions.clear();\n this.sessionPool = [];\n }\n\n async ensureWhisperBinary() {\n const whisperCliPath = await this.checkCommand('whisper-cli');\n if (whisperCliPath) {\n this.whisperPath = whisperCliPath;\n console.log(`[WhisperService] Found whisper-cli at: ${this.whisperPath}`);\n return;\n }\n\n const whisperPath = await this.checkCommand('whisper');\n if (whisperPath) {\n this.whisperPath = whisperPath;\n console.log(`[WhisperService] Found whisper at: ${this.whisperPath}`);\n return;\n }\n\n try {\n await fsPromises.access(this.whisperPath, fs.constants.X_OK);\n console.log('[WhisperService] Custom whisper binary found');\n return;\n } catch (error) {\n // Continue to installation\n }\n\n const platform = this.getPlatform();\n if (platform === 'darwin') {\n console.log('[WhisperService] Whisper not found, trying Homebrew installation...');\n try {\n await this.installViaHomebrew();\n // verify installation\n const verified = await this.verifyInstallation();\n if (!verified.success) {\n throw new Error(verified.error);\n }\n return;\n } catch (error) {\n console.log('[WhisperService] Homebrew installation failed:', error.message);\n }\n }\n\n await this.autoInstall();\n \n // verify installation\n const verified = await this.verifyInstallation();\n if (!verified.success) {\n throw new Error(`Whisper installation verification failed: ${verified.error}`);\n }\n }\n\n async installViaHomebrew() {\n const brewPath = await this.checkCommand('brew');\n if (!brewPath) {\n throw new Error('Homebrew not found. Please install Homebrew first.');\n }\n\n console.log('[WhisperService] Installing whisper-cpp via Homebrew...');\n await spawnAsync('brew', ['install', 'whisper-cpp']);\n \n const whisperCliPath = await this.checkCommand('whisper-cli');\n if (whisperCliPath) {\n this.whisperPath = whisperCliPath;\n console.log(`[WhisperService] Whisper-cli installed via Homebrew at: ${this.whisperPath}`);\n } else {\n const whisperPath = await this.checkCommand('whisper');\n if (whisperPath) {\n this.whisperPath = whisperPath;\n console.log(`[WhisperService] Whisper installed via Homebrew at: ${this.whisperPath}`);\n }\n }\n }\n\n\n async ensureModelAvailable(modelId) {\n if (!this.installState.isInitialized) {\n console.log('[WhisperService] Service not initialized, initializing now...');\n await this.initialize();\n }\n\n const modelInfo = this.availableModels[modelId];\n if (!modelInfo) {\n throw new Error(`Unknown model: ${modelId}. Available models: ${Object.keys(this.availableModels).join(', ')}`);\n }\n\n const modelPath = await this.getModelPath(modelId);\n try {\n await fsPromises.access(modelPath, fs.constants.R_OK);\n console.log(`[WhisperService] Model ${modelId} already available at: ${modelPath}`);\n } catch (error) {\n console.log(`[WhisperService] Model ${modelId} not found, downloading...`);\n await this.downloadModel(modelId);\n }\n }\n\n async downloadModel(modelId) {\n const modelInfo = this.availableModels[modelId];\n const modelPath = await this.getModelPath(modelId);\n const checksumInfo = DOWNLOAD_CHECKSUMS.whisper.models[modelId];\n \n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelId, \n progress: 0 \n });\n \n await this.downloadWithRetry(modelInfo.url, modelPath, {\n expectedChecksum: checksumInfo?.sha256,\n modelId, // pass modelId to LocalAIServiceBase for event handling\n onProgress: (progress) => {\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelId, \n progress \n });\n }\n });\n \n console.log(`[WhisperService] Model ${modelId} downloaded successfully`);\n this.emit('model-download-complete', { modelId });\n }\n\n async handleDownloadModel(modelId) {\n try {\n console.log(`[WhisperService] Handling download for model: ${modelId}`);\n\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n\n await this.ensureModelAvailable(modelId);\n \n return { success: true };\n } catch (error) {\n console.error(`[WhisperService] Failed to handle download for model ${modelId}:`, error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetInstalledModels() {\n try {\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n const models = await this.getInstalledModels();\n return { success: true, models };\n } catch (error) {\n console.error('[WhisperService] Failed to get installed models:', error);\n return { success: false, error: error.message };\n }\n }\n\n async getModelPath(modelId) {\n if (!this.installState.isInitialized || !this.modelsDir) {\n throw new Error('WhisperService is not initialized. Call initialize() first.');\n }\n return path.join(this.modelsDir, `${modelId}.bin`);\n }\n\n async getWhisperPath() {\n return this.whisperPath;\n }\n\n async saveAudioToTemp(audioBuffer, sessionId = '') {\n const timestamp = Date.now();\n const random = Math.random().toString(36).substr(2, 6);\n const sessionPrefix = sessionId ? `${sessionId}_` : '';\n const tempFile = path.join(this.tempDir, `audio_${sessionPrefix}${timestamp}_${random}.wav`);\n \n const wavHeader = this.createWavHeader(audioBuffer.length);\n const wavBuffer = Buffer.concat([wavHeader, audioBuffer]);\n \n await fsPromises.writeFile(tempFile, wavBuffer);\n return tempFile;\n }\n\n createWavHeader(dataSize) {\n const header = Buffer.alloc(44);\n const sampleRate = 16000;\n const numChannels = 1;\n const bitsPerSample = 16;\n \n header.write('RIFF', 0);\n header.writeUInt32LE(36 + dataSize, 4);\n header.write('WAVE', 8);\n header.write('fmt ', 12);\n header.writeUInt32LE(16, 16);\n header.writeUInt16LE(1, 20);\n header.writeUInt16LE(numChannels, 22);\n header.writeUInt32LE(sampleRate, 24);\n header.writeUInt32LE(sampleRate * numChannels * bitsPerSample / 8, 28);\n header.writeUInt16LE(numChannels * bitsPerSample / 8, 32);\n header.writeUInt16LE(bitsPerSample, 34);\n header.write('data', 36);\n header.writeUInt32LE(dataSize, 40);\n \n return header;\n }\n\n async cleanupTempFile(filePath) {\n if (!filePath || typeof filePath !== 'string') {\n console.warn('[WhisperService] Invalid file path for cleanup:', filePath);\n return;\n }\n\n const filesToCleanup = [\n filePath,\n filePath.replace('.wav', '.txt'),\n filePath.replace('.wav', '.json')\n ];\n\n for (const file of filesToCleanup) {\n try {\n // Check if file exists before attempting to delete\n await fsPromises.access(file, fs.constants.F_OK);\n await fsPromises.unlink(file);\n console.log(`[WhisperService] Cleaned up: ${file}`);\n } catch (error) {\n // File doesn't exist or already deleted - this is normal\n if (error.code !== 'ENOENT') {\n console.warn(`[WhisperService] Failed to cleanup ${file}:`, error.message);\n }\n }\n }\n }\n\n async getInstalledModels() {\n if (!this.installState.isInitialized) {\n console.log('[WhisperService] Service not initialized for getInstalledModels, initializing now...');\n await this.initialize();\n }\n\n const models = [];\n for (const [modelId, modelInfo] of Object.entries(this.availableModels)) {\n try {\n const modelPath = await this.getModelPath(modelId);\n await fsPromises.access(modelPath, fs.constants.R_OK);\n models.push({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: true\n });\n } catch (error) {\n models.push({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: false\n });\n }\n }\n return models;\n }\n\n async isServiceRunning() {\n return this.installState.isInitialized;\n }\n\n async startService() {\n if (!this.installState.isInitialized) {\n await this.initialize();\n }\n return true;\n }\n\n async stopService() {\n return true;\n }\n\n async isInstalled() {\n try {\n const whisperPath = await this.checkCommand('whisper-cli') || await this.checkCommand('whisper');\n return !!whisperPath;\n } catch (error) {\n return false;\n }\n }\n\n async installMacOS() {\n throw new Error('Binary installation not available for macOS. Please install Homebrew and run: brew install whisper-cpp');\n }\n\n async installWindows() {\n console.log('[WhisperService] Installing Whisper on Windows...');\n const version = 'v1.7.6';\n const binaryUrl = `https://github.com/ggml-org/whisper.cpp/releases/download/${version}/whisper-bin-x64.zip`;\n const tempFile = path.join(this.tempDir, 'whisper-binary.zip');\n \n try {\n console.log('[WhisperService] Step 1: Downloading Whisper binary...');\n await this.downloadWithRetry(binaryUrl, tempFile);\n \n console.log('[WhisperService] Step 2: Extracting archive...');\n const extractDir = path.join(this.tempDir, 'extracted');\n \n // 임시 압축 해제 디렉토리 생성\n await fsPromises.mkdir(extractDir, { recursive: true });\n \n // PowerShell 명령에서 경로를 올바르게 인용\n const expandCommand = `Expand-Archive -Path \"${tempFile}\" -DestinationPath \"${extractDir}\" -Force`;\n await spawnAsync('powershell', ['-command', expandCommand]);\n \n console.log('[WhisperService] Step 3: Finding and moving whisper executable...');\n \n // 압축 해제된 디렉토리에서 whisper.exe 파일 찾기\n const whisperExecutables = await this.findWhisperExecutables(extractDir);\n \n if (whisperExecutables.length === 0) {\n throw new Error('whisper.exe not found in extracted files');\n }\n \n // 첫 번째로 찾은 whisper.exe를 목표 위치로 복사\n const sourceExecutable = whisperExecutables[0];\n const targetDir = path.dirname(this.whisperPath);\n await fsPromises.mkdir(targetDir, { recursive: true });\n await fsPromises.copyFile(sourceExecutable, this.whisperPath);\n \n console.log('[WhisperService] Step 4: Verifying installation...');\n \n // 설치 검증\n await fsPromises.access(this.whisperPath, fs.constants.F_OK);\n \n // whisper.exe 실행 테스트\n try {\n await spawnAsync(this.whisperPath, ['--help']);\n console.log('[WhisperService] Whisper executable verified successfully');\n } catch (testError) {\n console.warn('[WhisperService] Whisper executable test failed, but file exists:', testError.message);\n }\n \n console.log('[WhisperService] Step 5: Cleanup...');\n \n // 임시 파일 정리\n await fsPromises.unlink(tempFile).catch(() => {});\n await this.removeDirectory(extractDir).catch(() => {});\n \n console.log('[WhisperService] Whisper installed successfully on Windows');\n return true;\n \n } catch (error) {\n console.error('[WhisperService] Windows installation failed:', error);\n \n // 실패 시 임시 파일 정리\n await fsPromises.unlink(tempFile).catch(() => {});\n await this.removeDirectory(path.join(this.tempDir, 'extracted')).catch(() => {});\n \n throw new Error(`Failed to install Whisper on Windows: ${error.message}`);\n }\n }\n \n // 압축 해제된 디렉토리에서 whisper.exe 파일들을 재귀적으로 찾기\n async findWhisperExecutables(dir) {\n const executables = [];\n \n try {\n const items = await fsPromises.readdir(dir, { withFileTypes: true });\n \n for (const item of items) {\n const fullPath = path.join(dir, item.name);\n \n if (item.isDirectory()) {\n const subExecutables = await this.findWhisperExecutables(fullPath);\n executables.push(...subExecutables);\n } else if (item.isFile() && (item.name === 'whisper-whisper.exe' || item.name === 'whisper.exe' || item.name === 'main.exe')) {\n executables.push(fullPath);\n }\n }\n } catch (error) {\n console.warn('[WhisperService] Error reading directory:', dir, error.message);\n }\n \n return executables;\n }\n \n // 디렉토리 재귀적 삭제\n async removeDirectory(dir) {\n try {\n const items = await fsPromises.readdir(dir, { withFileTypes: true });\n \n for (const item of items) {\n const fullPath = path.join(dir, item.name);\n \n if (item.isDirectory()) {\n await this.removeDirectory(fullPath);\n } else {\n await fsPromises.unlink(fullPath);\n }\n }\n \n await fsPromises.rmdir(dir);\n } catch (error) {\n console.warn('[WhisperService] Error removing directory:', dir, error.message);\n }\n }\n\n async installLinux() {\n console.log('[WhisperService] Installing Whisper on Linux...');\n const version = 'v1.7.6';\n const binaryUrl = `https://github.com/ggml-org/whisper.cpp/releases/download/${version}/whisper-cpp-${version}-linux-x64.tar.gz`;\n const tempFile = path.join(this.tempDir, 'whisper-binary.tar.gz');\n \n try {\n await this.downloadWithRetry(binaryUrl, tempFile);\n const extractDir = path.dirname(this.whisperPath);\n await spawnAsync('tar', ['-xzf', tempFile, '-C', extractDir, '--strip-components=1']);\n await spawnAsync('chmod', ['+x', this.whisperPath]);\n await fsPromises.unlink(tempFile);\n console.log('[WhisperService] Whisper installed successfully on Linux');\n return true;\n } catch (error) {\n console.error('[WhisperService] Linux installation failed:', error);\n throw new Error(`Failed to install Whisper on Linux: ${error.message}`);\n }\n }\n\n async shutdownMacOS(force) {\n return true;\n }\n\n async shutdownWindows(force) {\n return true;\n }\n\n async shutdownLinux(force) {\n return true;\n }\n}\n\n// WhisperSession class\nclass WhisperSession {\n constructor(config, service) {\n this.id = `session_${Date.now()}_${Math.random()}`;\n this.config = config;\n this.service = service;\n this.process = null;\n this.inUse = true;\n this.audioBuffer = Buffer.alloc(0);\n }\n\n async initialize() {\n await this.service.ensureModelAvailable(this.config.model);\n this.startProcessingLoop();\n }\n\n async reconfigure(config) {\n this.config = config;\n await this.service.ensureModelAvailable(this.config.model);\n }\n\n startProcessingLoop() {\n // TODO: 실제 처리 루프 구현\n }\n\n async cleanup() {\n // 임시 파일 정리\n await this.cleanupTempFiles();\n }\n\n async cleanupTempFiles() {\n // TODO: 임시 파일 정리 구현\n }\n\n async destroy() {\n if (this.process) {\n this.process.kill();\n }\n // 임시 파일 정리\n await this.cleanupTempFiles();\n }\n}\n\n// verify installation\nWhisperService.prototype.verifyInstallation = async function() {\n try {\n console.log('[WhisperService] Verifying installation...');\n \n // 1. check binary\n if (!this.whisperPath) {\n return { success: false, error: 'Whisper binary path not set' };\n }\n \n try {\n await fsPromises.access(this.whisperPath, fs.constants.X_OK);\n } catch (error) {\n return { success: false, error: 'Whisper binary not executable' };\n }\n \n // 2. check version\n try {\n const { stdout } = await spawnAsync(this.whisperPath, ['--help']);\n if (!stdout.includes('whisper')) {\n return { success: false, error: 'Invalid whisper binary' };\n }\n } catch (error) {\n return { success: false, error: 'Whisper binary not responding' };\n }\n \n // 3. check directories\n try {\n await fsPromises.access(this.modelsDir, fs.constants.W_OK);\n await fsPromises.access(this.tempDir, fs.constants.W_OK);\n } catch (error) {\n return { success: false, error: 'Required directories not accessible' };\n }\n \n console.log('[WhisperService] Installation verified successfully');\n return { success: true };\n \n } catch (error) {\n console.error('[WhisperService] Verification failed:', error);\n return { success: false, error: error.message };\n }\n};\n\n// Export singleton instance\nconst whisperService = new WhisperService();\nmodule.exports = whisperService;"], ["/glass/src/features/listen/stt/sttService.js", "const { BrowserWindow } = require('electron');\nconst { spawn } = require('child_process');\nconst { createSTT } = require('../../common/ai/factory');\nconst modelStateService = require('../../common/services/modelStateService');\n\nconst COMPLETION_DEBOUNCE_MS = 2000;\n\n// ── New heartbeat / renewal constants ────────────────────────────────────────────\n// Interval to send low-cost keep-alive messages so the remote service does not\n// treat the connection as idle. One minute is safely below the typical 2-5 min\n// idle timeout window seen on provider websockets.\nconst KEEP_ALIVE_INTERVAL_MS = 60 * 1000; // 1 minute\n\n// Interval after which we pro-actively tear down and recreate the STT sessions\n// to dodge the 30-minute hard timeout enforced by some providers. 20 minutes\n// gives a 10-minute safety buffer.\nconst SESSION_RENEW_INTERVAL_MS = 20 * 60 * 1000; // 20 minutes\n\n// Duration to allow the old and new sockets to run in parallel so we don't\n// miss any packets at the exact swap moment.\nconst SOCKET_OVERLAP_MS = 2 * 1000; // 2 seconds\n\nclass SttService {\n constructor() {\n this.mySttSession = null;\n this.theirSttSession = null;\n this.myCurrentUtterance = '';\n this.theirCurrentUtterance = '';\n \n // Turn-completion debouncing\n this.myCompletionBuffer = '';\n this.theirCompletionBuffer = '';\n this.myCompletionTimer = null;\n this.theirCompletionTimer = null;\n \n // System audio capture\n this.systemAudioProc = null;\n\n // Keep-alive / renewal timers\n this.keepAliveInterval = null;\n this.sessionRenewTimeout = null;\n\n // Callbacks\n this.onTranscriptionComplete = null;\n this.onStatusUpdate = null;\n\n this.modelInfo = null; \n }\n\n setCallbacks({ onTranscriptionComplete, onStatusUpdate }) {\n this.onTranscriptionComplete = onTranscriptionComplete;\n this.onStatusUpdate = onStatusUpdate;\n }\n\n sendToRenderer(channel, data) {\n // Listen 관련 이벤트는 Listen 윈도우에만 전송 (Ask 윈도우 충돌 방지)\n const { windowPool } = require('../../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n async handleSendSystemAudioContent(data, mimeType) {\n try {\n await this.sendSystemAudioContent(data, mimeType);\n this.sendToRenderer('system-audio-data', { data });\n return { success: true };\n } catch (error) {\n console.error('Error sending system audio:', error);\n return { success: false, error: error.message };\n }\n }\n\n flushMyCompletion() {\n const finalText = (this.myCompletionBuffer + this.myCurrentUtterance).trim();\n if (!this.modelInfo || !finalText) return;\n\n // Notify completion callback\n if (this.onTranscriptionComplete) {\n this.onTranscriptionComplete('Me', finalText);\n }\n \n // Send to renderer as final\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n\n this.myCompletionBuffer = '';\n this.myCompletionTimer = null;\n this.myCurrentUtterance = '';\n \n if (this.onStatusUpdate) {\n this.onStatusUpdate('Listening...');\n }\n }\n\n flushTheirCompletion() {\n const finalText = (this.theirCompletionBuffer + this.theirCurrentUtterance).trim();\n if (!this.modelInfo || !finalText) return;\n \n // Notify completion callback\n if (this.onTranscriptionComplete) {\n this.onTranscriptionComplete('Them', finalText);\n }\n \n // Send to renderer as final\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n\n this.theirCompletionBuffer = '';\n this.theirCompletionTimer = null;\n this.theirCurrentUtterance = '';\n \n if (this.onStatusUpdate) {\n this.onStatusUpdate('Listening...');\n }\n }\n\n debounceMyCompletion(text) {\n if (this.modelInfo?.provider === 'gemini') {\n this.myCompletionBuffer += text;\n } else {\n this.myCompletionBuffer += (this.myCompletionBuffer ? ' ' : '') + text;\n }\n\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = setTimeout(() => this.flushMyCompletion(), COMPLETION_DEBOUNCE_MS);\n }\n\n debounceTheirCompletion(text) {\n if (this.modelInfo?.provider === 'gemini') {\n this.theirCompletionBuffer += text;\n } else {\n this.theirCompletionBuffer += (this.theirCompletionBuffer ? ' ' : '') + text;\n }\n\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = setTimeout(() => this.flushTheirCompletion(), COMPLETION_DEBOUNCE_MS);\n }\n\n async initializeSttSessions(language = 'en') {\n const effectiveLanguage = process.env.OPENAI_TRANSCRIBE_LANG || language || 'en';\n\n const modelInfo = await modelStateService.getCurrentModelInfo('stt');\n if (!modelInfo || !modelInfo.apiKey) {\n throw new Error('AI model or API key is not configured.');\n }\n this.modelInfo = modelInfo;\n console.log(`[SttService] Initializing STT for ${modelInfo.provider} using model ${modelInfo.model}`);\n\n const handleMyMessage = message => {\n if (!this.modelInfo) {\n console.log('[SttService] Ignoring message - session already closed');\n return;\n }\n // console.log('[SttService] handleMyMessage', message);\n \n if (this.modelInfo.provider === 'whisper') {\n // Whisper STT emits 'transcription' events with different structure\n if (message.text && message.text.trim()) {\n const finalText = message.text.trim();\n \n // Filter out Whisper noise transcriptions\n const noisePatterns = [\n '[BLANK_AUDIO]',\n '[INAUDIBLE]',\n '[MUSIC]',\n '[SOUND]',\n '[NOISE]',\n '(BLANK_AUDIO)',\n '(INAUDIBLE)',\n '(MUSIC)',\n '(SOUND)',\n '(NOISE)'\n ];\n \n const isNoise = noisePatterns.some(pattern => \n finalText.includes(pattern) || finalText === pattern\n );\n \n \n if (!isNoise && finalText.length > 2) {\n this.debounceMyCompletion(finalText);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n } else {\n console.log(`[Whisper-Me] Filtered noise: \"${finalText}\"`);\n }\n }\n return;\n } else if (this.modelInfo.provider === 'gemini') {\n if (!message.serverContent?.modelTurn) {\n console.log('[Gemini STT - Me]', JSON.stringify(message, null, 2));\n }\n\n if (message.serverContent?.turnComplete) {\n if (this.myCompletionTimer) {\n clearTimeout(this.myCompletionTimer);\n this.flushMyCompletion();\n }\n return;\n }\n \n const transcription = message.serverContent?.inputTranscription;\n if (!transcription || !transcription.text) return;\n \n const textChunk = transcription.text;\n if (!textChunk.trim() || textChunk.trim() === '') {\n return; // 1. Ignore whitespace-only chunks or noise\n }\n \n this.debounceMyCompletion(textChunk);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: this.myCompletionBuffer,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n \n // Deepgram \n } else if (this.modelInfo.provider === 'deepgram') {\n const text = message.channel?.alternatives?.[0]?.transcript;\n if (!text || text.trim().length === 0) return;\n\n const isFinal = message.is_final;\n console.log(`[SttService-Me-Deepgram] Received: isFinal=${isFinal}, text=\"${text}\"`);\n\n if (isFinal) {\n // 최종 결과가 도착하면, 현재 진행중인 부분 발화는 비우고\n // 최종 텍스트로 debounce를 실행합니다.\n this.myCurrentUtterance = ''; \n this.debounceMyCompletion(text); \n } else {\n // 부분 결과(interim)인 경우, 화면에 실시간으로 업데이트합니다.\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n\n this.myCurrentUtterance = text;\n \n const continuousText = (this.myCompletionBuffer + ' ' + this.myCurrentUtterance).trim();\n\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n \n } else {\n const type = message.type;\n const text = message.transcript || message.delta || (message.alternatives && message.alternatives[0]?.transcript) || '';\n\n if (type === 'conversation.item.input_audio_transcription.delta') {\n if (this.myCompletionTimer) clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n this.myCurrentUtterance += text;\n const continuousText = this.myCompletionBuffer + (this.myCompletionBuffer ? ' ' : '') + this.myCurrentUtterance;\n if (text && !text.includes('vq_lbr_audio_')) {\n this.sendToRenderer('stt-update', {\n speaker: 'Me',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n } else if (type === 'conversation.item.input_audio_transcription.completed') {\n if (text && text.trim()) {\n const finalUtteranceText = text.trim();\n this.myCurrentUtterance = '';\n this.debounceMyCompletion(finalUtteranceText);\n }\n }\n }\n\n if (message.error) {\n console.error('[Me] STT Session Error:', message.error);\n }\n };\n\n const handleTheirMessage = message => {\n if (!message || typeof message !== 'object') return;\n\n if (!this.modelInfo) {\n console.log('[SttService] Ignoring message - session already closed');\n return;\n }\n \n if (this.modelInfo.provider === 'whisper') {\n // Whisper STT emits 'transcription' events with different structure\n if (message.text && message.text.trim()) {\n const finalText = message.text.trim();\n \n // Filter out Whisper noise transcriptions\n const noisePatterns = [\n '[BLANK_AUDIO]',\n '[INAUDIBLE]',\n '[MUSIC]',\n '[SOUND]',\n '[NOISE]',\n '(BLANK_AUDIO)',\n '(INAUDIBLE)',\n '(MUSIC)',\n '(SOUND)',\n '(NOISE)'\n ];\n \n const isNoise = noisePatterns.some(pattern => \n finalText.includes(pattern) || finalText === pattern\n );\n \n \n // Only process if it's not noise, not a false positive, and has meaningful content\n if (!isNoise && finalText.length > 2) {\n this.debounceTheirCompletion(finalText);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: finalText,\n isPartial: false,\n isFinal: true,\n timestamp: Date.now(),\n });\n } else {\n console.log(`[Whisper-Them] Filtered noise: \"${finalText}\"`);\n }\n }\n return;\n } else if (this.modelInfo.provider === 'gemini') {\n if (!message.serverContent?.modelTurn) {\n console.log('[Gemini STT - Them]', JSON.stringify(message, null, 2));\n }\n\n if (message.serverContent?.turnComplete) {\n if (this.theirCompletionTimer) {\n clearTimeout(this.theirCompletionTimer);\n this.flushTheirCompletion();\n }\n return;\n }\n \n const transcription = message.serverContent?.inputTranscription;\n if (!transcription || !transcription.text) return;\n\n const textChunk = transcription.text;\n if (!textChunk.trim() || textChunk.trim() === '') {\n return; // 1. Ignore whitespace-only chunks or noise\n }\n\n this.debounceTheirCompletion(textChunk);\n \n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: this.theirCompletionBuffer,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n\n // Deepgram\n } else if (this.modelInfo.provider === 'deepgram') {\n const text = message.channel?.alternatives?.[0]?.transcript;\n if (!text || text.trim().length === 0) return;\n\n const isFinal = message.is_final;\n\n if (isFinal) {\n this.theirCurrentUtterance = ''; \n this.debounceTheirCompletion(text); \n } else {\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n\n this.theirCurrentUtterance = text;\n \n const continuousText = (this.theirCompletionBuffer + ' ' + this.theirCurrentUtterance).trim();\n\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n\n } else {\n const type = message.type;\n const text = message.transcript || message.delta || (message.alternatives && message.alternatives[0]?.transcript) || '';\n if (type === 'conversation.item.input_audio_transcription.delta') {\n if (this.theirCompletionTimer) clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n this.theirCurrentUtterance += text;\n const continuousText = this.theirCompletionBuffer + (this.theirCompletionBuffer ? ' ' : '') + this.theirCurrentUtterance;\n if (text && !text.includes('vq_lbr_audio_')) {\n this.sendToRenderer('stt-update', {\n speaker: 'Them',\n text: continuousText,\n isPartial: true,\n isFinal: false,\n timestamp: Date.now(),\n });\n }\n } else if (type === 'conversation.item.input_audio_transcription.completed') {\n if (text && text.trim()) {\n const finalUtteranceText = text.trim();\n this.theirCurrentUtterance = '';\n this.debounceTheirCompletion(finalUtteranceText);\n }\n }\n }\n \n if (message.error) {\n console.error('[Them] STT Session Error:', message.error);\n }\n };\n\n const mySttConfig = {\n language: effectiveLanguage,\n callbacks: {\n onmessage: handleMyMessage,\n onerror: error => console.error('My STT session error:', error.message),\n onclose: event => console.log('My STT session closed:', event.reason),\n },\n };\n \n const theirSttConfig = {\n language: effectiveLanguage,\n callbacks: {\n onmessage: handleTheirMessage,\n onerror: error => console.error('Their STT session error:', error.message),\n onclose: event => console.log('Their STT session closed:', event.reason),\n },\n };\n \n const sttOptions = {\n apiKey: this.modelInfo.apiKey,\n language: effectiveLanguage,\n usePortkey: this.modelInfo.provider === 'openai-glass',\n portkeyVirtualKey: this.modelInfo.provider === 'openai-glass' ? this.modelInfo.apiKey : undefined,\n };\n\n // Add sessionType for Whisper to distinguish between My and Their sessions\n const myOptions = { ...sttOptions, callbacks: mySttConfig.callbacks, sessionType: 'my' };\n const theirOptions = { ...sttOptions, callbacks: theirSttConfig.callbacks, sessionType: 'their' };\n\n [this.mySttSession, this.theirSttSession] = await Promise.all([\n createSTT(this.modelInfo.provider, myOptions),\n createSTT(this.modelInfo.provider, theirOptions),\n ]);\n\n console.log('✅ Both STT sessions initialized successfully.');\n\n // ── Setup keep-alive heart-beats ────────────────────────────────────────\n if (this.keepAliveInterval) clearInterval(this.keepAliveInterval);\n this.keepAliveInterval = setInterval(() => {\n this._sendKeepAlive();\n }, KEEP_ALIVE_INTERVAL_MS);\n\n // ── Schedule session auto-renewal ───────────────────────────────────────\n if (this.sessionRenewTimeout) clearTimeout(this.sessionRenewTimeout);\n this.sessionRenewTimeout = setTimeout(async () => {\n try {\n console.log('[SttService] Auto-renewing STT sessions…');\n await this.renewSessions(language);\n } catch (err) {\n console.error('[SttService] Failed to renew STT sessions:', err);\n }\n }, SESSION_RENEW_INTERVAL_MS);\n\n return true;\n }\n\n /**\n * Send a lightweight keep-alive to prevent idle disconnects.\n * Currently only implemented for OpenAI provider because Gemini's SDK\n * already performs its own heart-beats.\n */\n _sendKeepAlive() {\n if (!this.isSessionActive()) return;\n\n if (this.modelInfo?.provider === 'openai') {\n try {\n this.mySttSession?.keepAlive?.();\n this.theirSttSession?.keepAlive?.();\n } catch (err) {\n console.error('[SttService] keepAlive error:', err.message);\n }\n }\n }\n\n /**\n * Gracefully tears down then recreates the STT sessions. Should be invoked\n * on a timer to avoid provider-side hard timeouts.\n */\n async renewSessions(language = 'en') {\n if (!this.isSessionActive()) {\n console.warn('[SttService] renewSessions called but no active session.');\n return;\n }\n\n const oldMySession = this.mySttSession;\n const oldTheirSession = this.theirSttSession;\n\n console.log('[SttService] Spawning fresh STT sessions in the background…');\n\n // We reuse initializeSttSessions to create fresh sessions with the same\n // language and handlers. The method will update the session pointers\n // and timers, but crucially it does NOT touch the system audio capture\n // pipeline, so audio continues flowing uninterrupted.\n await this.initializeSttSessions(language);\n\n // Close the old sessions after a short overlap window.\n setTimeout(() => {\n try {\n oldMySession?.close?.();\n oldTheirSession?.close?.();\n console.log('[SttService] Old STT sessions closed after hand-off.');\n } catch (err) {\n console.error('[SttService] Error closing old STT sessions:', err.message);\n }\n }, SOCKET_OVERLAP_MS);\n }\n\n async sendMicAudioContent(data, mimeType) {\n // const provider = await this.getAiProvider();\n // const isGemini = provider === 'gemini';\n \n if (!this.mySttSession) {\n throw new Error('User STT session not active');\n }\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data, mimeType: mimeType || 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(data, 'base64'); \n } else {\n payload = data;\n }\n await this.mySttSession.sendRealtimeInput(payload);\n }\n\n async sendSystemAudioContent(data, mimeType) {\n if (!this.theirSttSession) {\n throw new Error('Their STT session not active');\n }\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data, mimeType: mimeType || 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(data, 'base64');\n } else {\n payload = data;\n }\n\n await this.theirSttSession.sendRealtimeInput(payload);\n }\n\n killExistingSystemAudioDump() {\n return new Promise(resolve => {\n console.log('Checking for existing SystemAudioDump processes...');\n\n const killProc = spawn('pkill', ['-f', 'SystemAudioDump'], {\n stdio: 'ignore',\n });\n\n killProc.on('close', code => {\n if (code === 0) {\n console.log('Killed existing SystemAudioDump processes');\n } else {\n console.log('No existing SystemAudioDump processes found');\n }\n resolve();\n });\n\n killProc.on('error', err => {\n console.log('Error checking for existing processes (this is normal):', err.message);\n resolve();\n });\n\n setTimeout(() => {\n killProc.kill();\n resolve();\n }, 2000);\n });\n }\n\n async startMacOSAudioCapture() {\n if (process.platform !== 'darwin' || !this.theirSttSession) return false;\n\n await this.killExistingSystemAudioDump();\n console.log('Starting macOS audio capture for \"Them\"...');\n\n const { app } = require('electron');\n const path = require('path');\n const systemAudioPath = app.isPackaged\n ? path.join(process.resourcesPath, 'app.asar.unpacked', 'src', 'ui', 'assets', 'SystemAudioDump')\n : path.join(app.getAppPath(), 'src', 'ui', 'assets', 'SystemAudioDump');\n\n console.log('SystemAudioDump path:', systemAudioPath);\n\n this.systemAudioProc = spawn(systemAudioPath, [], {\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n\n if (!this.systemAudioProc.pid) {\n console.error('Failed to start SystemAudioDump');\n return false;\n }\n\n console.log('SystemAudioDump started with PID:', this.systemAudioProc.pid);\n\n const CHUNK_DURATION = 0.1;\n const SAMPLE_RATE = 24000;\n const BYTES_PER_SAMPLE = 2;\n const CHANNELS = 2;\n const CHUNK_SIZE = SAMPLE_RATE * BYTES_PER_SAMPLE * CHANNELS * CHUNK_DURATION;\n\n let audioBuffer = Buffer.alloc(0);\n\n // const provider = await this.getAiProvider();\n // const isGemini = provider === 'gemini';\n\n let modelInfo = this.modelInfo;\n if (!modelInfo) {\n console.warn('[SttService] modelInfo not found, fetching on-the-fly as a fallback...');\n modelInfo = await modelStateService.getCurrentModelInfo('stt');\n }\n if (!modelInfo) {\n throw new Error('STT model info could not be retrieved.');\n }\n\n this.systemAudioProc.stdout.on('data', async data => {\n audioBuffer = Buffer.concat([audioBuffer, data]);\n\n while (audioBuffer.length >= CHUNK_SIZE) {\n const chunk = audioBuffer.slice(0, CHUNK_SIZE);\n audioBuffer = audioBuffer.slice(CHUNK_SIZE);\n\n const monoChunk = CHANNELS === 2 ? this.convertStereoToMono(chunk) : chunk;\n const base64Data = monoChunk.toString('base64');\n\n this.sendToRenderer('system-audio-data', { data: base64Data });\n\n if (this.theirSttSession) {\n try {\n let payload;\n if (modelInfo.provider === 'gemini') {\n payload = { audio: { data: base64Data, mimeType: 'audio/pcm;rate=24000' } };\n } else if (modelInfo.provider === 'deepgram') {\n payload = Buffer.from(base64Data, 'base64');\n } else {\n payload = base64Data;\n }\n\n await this.theirSttSession.sendRealtimeInput(payload);\n } catch (err) {\n console.error('Error sending system audio:', err.message);\n }\n }\n }\n });\n\n this.systemAudioProc.stderr.on('data', data => {\n console.error('SystemAudioDump stderr:', data.toString());\n });\n\n this.systemAudioProc.on('close', code => {\n console.log('SystemAudioDump process closed with code:', code);\n this.systemAudioProc = null;\n });\n\n this.systemAudioProc.on('error', err => {\n console.error('SystemAudioDump process error:', err);\n this.systemAudioProc = null;\n });\n\n return true;\n }\n\n convertStereoToMono(stereoBuffer) {\n const samples = stereoBuffer.length / 4;\n const monoBuffer = Buffer.alloc(samples * 2);\n\n for (let i = 0; i < samples; i++) {\n const leftSample = stereoBuffer.readInt16LE(i * 4);\n monoBuffer.writeInt16LE(leftSample, i * 2);\n }\n\n return monoBuffer;\n }\n\n stopMacOSAudioCapture() {\n if (this.systemAudioProc) {\n console.log('Stopping SystemAudioDump...');\n this.systemAudioProc.kill('SIGTERM');\n this.systemAudioProc = null;\n }\n }\n\n isSessionActive() {\n return !!this.mySttSession && !!this.theirSttSession;\n }\n\n async closeSessions() {\n this.stopMacOSAudioCapture();\n\n // Clear heartbeat / renewal timers\n if (this.keepAliveInterval) {\n clearInterval(this.keepAliveInterval);\n this.keepAliveInterval = null;\n }\n if (this.sessionRenewTimeout) {\n clearTimeout(this.sessionRenewTimeout);\n this.sessionRenewTimeout = null;\n }\n\n // Clear timers\n if (this.myCompletionTimer) {\n clearTimeout(this.myCompletionTimer);\n this.myCompletionTimer = null;\n }\n if (this.theirCompletionTimer) {\n clearTimeout(this.theirCompletionTimer);\n this.theirCompletionTimer = null;\n }\n\n const closePromises = [];\n if (this.mySttSession) {\n closePromises.push(this.mySttSession.close());\n this.mySttSession = null;\n }\n if (this.theirSttSession) {\n closePromises.push(this.theirSttSession.close());\n this.theirSttSession = null;\n }\n\n await Promise.all(closePromises);\n console.log('All STT sessions closed.');\n\n // Reset state\n this.myCurrentUtterance = '';\n this.theirCurrentUtterance = '';\n this.myCompletionBuffer = '';\n this.theirCompletionBuffer = '';\n this.modelInfo = null; \n }\n}\n\nmodule.exports = SttService; "], ["/glass/src/features/common/services/ollamaService.js", "const { EventEmitter } = require('events');\nconst { spawn, exec } = require('child_process');\nconst { promisify } = require('util');\nconst fetch = require('node-fetch');\nconst path = require('path');\nconst fs = require('fs').promises;\nconst os = require('os');\nconst https = require('https');\nconst crypto = require('crypto');\nconst { app } = require('electron');\nconst { spawnAsync } = require('../utils/spawnHelper');\nconst { DOWNLOAD_CHECKSUMS } = require('../config/checksums');\nconst ollamaModelRepository = require('../repositories/ollamaModel');\n\nconst execAsync = promisify(exec);\n\nclass OllamaService extends EventEmitter {\n constructor() {\n super();\n this.serviceName = 'OllamaService';\n this.baseUrl = 'http://localhost:11434';\n \n // 단순화된 상태 관리\n this.installState = {\n isInstalled: false,\n isInstalling: false,\n progress: 0\n };\n \n // 단순화된 요청 관리 (복잡한 큐 제거)\n this.activeRequest = null;\n this.requestTimeout = 30000; // 30초 타임아웃\n \n // 모델 상태\n this.installedModels = new Map();\n this.modelWarmupStatus = new Map();\n \n // 체크포인트 시스템 (롤백용)\n this.installCheckpoints = [];\n \n // 설치 진행률 관리\n this.installationProgress = new Map();\n \n // 워밍 관련 (기존 유지)\n this.warmingModels = new Map();\n this.warmedModels = new Set();\n this.lastWarmUpAttempt = new Map();\n this.warmupTimeout = 120000; // 120s for model warmup\n \n // 상태 동기화\n this._lastState = null;\n this._syncInterval = null;\n this._lastLoadedModels = [];\n this.modelLoadStatus = new Map();\n \n // 서비스 종료 상태 추적\n this.isShuttingDown = false;\n }\n\n\n // Base class methods integration\n getPlatform() {\n return process.platform;\n }\n\n async checkCommand(command) {\n try {\n const platform = this.getPlatform();\n const checkCmd = platform === 'win32' ? 'where' : 'which';\n const { stdout } = await execAsync(`${checkCmd} ${command}`);\n return stdout.trim();\n } catch (error) {\n return null;\n }\n }\n\n async waitForService(checkFn, maxAttempts = 30, delayMs = 1000) {\n for (let i = 0; i < maxAttempts; i++) {\n if (await checkFn()) {\n console.log(`[${this.serviceName}] Service is ready`);\n return true;\n }\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n throw new Error(`${this.serviceName} service failed to start within timeout`);\n }\n\n getInstallProgress(modelName) {\n return this.installationProgress.get(modelName) || 0;\n }\n\n setInstallProgress(modelName, progress) {\n this.installationProgress.set(modelName, progress);\n }\n\n clearInstallProgress(modelName) {\n this.installationProgress.delete(modelName);\n }\n\n async getStatus() {\n try {\n const installed = await this.isInstalled();\n if (!installed) {\n return { success: true, installed: false, running: false, models: [] };\n }\n\n const running = await this.isServiceRunning();\n if (!running) {\n return { success: true, installed: true, running: false, models: [] };\n }\n\n const models = await this.getInstalledModels();\n return { success: true, installed: true, running: true, models };\n } catch (error) {\n console.error('[OllamaService] Error getting status:', error);\n return { success: false, error: error.message, installed: false, running: false, models: [] };\n }\n }\n\n getOllamaCliPath() {\n if (this.getPlatform() === 'darwin') {\n return '/Applications/Ollama.app/Contents/Resources/ollama';\n }\n return 'ollama';\n }\n\n // === 런타임 관리 (단순화) ===\n async makeRequest(endpoint, options = {}) {\n // 서비스 종료 중이면 요청하지 않음\n if (this.isShuttingDown) {\n throw new Error('Service is shutting down');\n }\n \n // 동시 요청 방지 (단순한 잠금)\n if (this.activeRequest) {\n await this.activeRequest;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.requestTimeout);\n\n this.activeRequest = fetch(`${this.baseUrl}${endpoint}`, {\n ...options,\n signal: controller.signal\n }).finally(() => {\n clearTimeout(timeoutId);\n this.activeRequest = null;\n });\n\n return this.activeRequest;\n }\n\n async isInstalled() {\n try {\n const platform = this.getPlatform();\n \n if (platform === 'darwin') {\n try {\n await fs.access('/Applications/Ollama.app');\n return true;\n } catch {\n const ollamaPath = await this.checkCommand(this.getOllamaCliPath());\n return !!ollamaPath;\n }\n } else {\n const ollamaPath = await this.checkCommand(this.getOllamaCliPath());\n return !!ollamaPath;\n }\n } catch (error) {\n console.log('[OllamaService] Ollama not found:', error.message);\n return false;\n }\n }\n\n async isServiceRunning() {\n try {\n // Use /api/ps to check if service is running\n // This is more reliable than /api/tags which may not show models not in memory\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n return response.ok;\n } catch (error) {\n console.log(`[OllamaService] Service health check failed: ${error.message}`);\n return false;\n }\n }\n\n async startService() {\n // 서비스 시작 시 종료 플래그 리셋\n this.isShuttingDown = false;\n \n const platform = this.getPlatform();\n \n try {\n if (platform === 'darwin') {\n try {\n await spawnAsync('open', ['-a', 'Ollama']);\n await this.waitForService(() => this.isServiceRunning());\n return true;\n } catch {\n spawn(this.getOllamaCliPath(), ['serve'], {\n detached: true,\n stdio: 'ignore'\n }).unref();\n await this.waitForService(() => this.isServiceRunning());\n return true;\n }\n } else {\n spawn(this.getOllamaCliPath(), ['serve'], {\n detached: true,\n stdio: 'ignore',\n shell: platform === 'win32'\n }).unref();\n await this.waitForService(() => this.isServiceRunning());\n return true;\n }\n } catch (error) {\n console.error('[OllamaService] Failed to start service:', error);\n throw error;\n }\n }\n\n async stopService() {\n return await this.shutdown();\n }\n\n // Comprehensive health check using multiple endpoints\n async healthCheck() {\n try {\n const checks = {\n serviceRunning: false,\n apiResponsive: false,\n modelsAccessible: false,\n memoryStatus: false\n };\n \n // 1. Basic service check with /api/ps\n try {\n const psResponse = await this.makeRequest('/api/ps', { method: 'GET' });\n checks.serviceRunning = psResponse.ok;\n checks.memoryStatus = psResponse.ok;\n } catch (error) {\n console.log('[OllamaService] /api/ps check failed:', error.message);\n }\n \n // 2. Check if API is responsive with root endpoint\n try {\n const rootResponse = await this.makeRequest('/', { method: 'GET' });\n checks.apiResponsive = rootResponse.ok;\n } catch (error) {\n console.log('[OllamaService] Root endpoint check failed:', error.message);\n }\n \n // 3. Check if models endpoint is accessible\n try {\n const tagsResponse = await this.makeRequest('/api/tags', { method: 'GET' });\n checks.modelsAccessible = tagsResponse.ok;\n } catch (error) {\n console.log('[OllamaService] /api/tags check failed:', error.message);\n }\n \n const allHealthy = Object.values(checks).every(v => v === true);\n \n return {\n healthy: allHealthy,\n checks,\n timestamp: new Date().toISOString()\n };\n } catch (error) {\n console.error('[OllamaService] Health check failed:', error);\n return {\n healthy: false,\n error: error.message,\n timestamp: new Date().toISOString()\n };\n }\n }\n\n async getInstalledModels() {\n // 서비스 종료 중이면 빈 배열 반환\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, returning empty models list');\n return [];\n }\n \n try {\n const response = await this.makeRequest('/api/tags', {\n method: 'GET'\n });\n \n const data = await response.json();\n return data.models || [];\n } catch (error) {\n console.error('[OllamaService] Failed to get installed models:', error.message);\n return [];\n }\n }\n\n // Get models currently loaded in memory using /api/ps\n async getLoadedModels() {\n // 서비스 종료 중이면 빈 배열 반환\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, returning empty loaded models list');\n return [];\n }\n \n try {\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n if (!response.ok) {\n console.log('[OllamaService] Failed to get loaded models via /api/ps');\n return [];\n }\n \n const data = await response.json();\n // Extract model names from running processes\n return (data.models || []).map(m => m.name);\n } catch (error) {\n console.error('[OllamaService] Error getting loaded models:', error);\n return [];\n }\n }\n \n // Get detailed memory info for loaded models\n async getLoadedModelsWithMemoryInfo() {\n try {\n const response = await this.makeRequest('/api/ps', {\n method: 'GET'\n });\n \n if (!response.ok) {\n return [];\n }\n \n const data = await response.json();\n // Return full model info including memory usage\n return data.models || [];\n } catch (error) {\n console.error('[OllamaService] Error getting loaded models info:', error);\n return [];\n }\n }\n \n // Check if a specific model is loaded in memory\n async isModelLoaded(modelName) {\n const loadedModels = await this.getLoadedModels();\n return loadedModels.includes(modelName);\n }\n\n async getInstalledModelsList() {\n try {\n const { stdout } = await spawnAsync(this.getOllamaCliPath(), ['list']);\n const lines = stdout.split('\\n').filter(line => line.trim());\n \n // Skip header line (NAME, ID, SIZE, MODIFIED)\n const modelLines = lines.slice(1);\n \n const models = [];\n for (const line of modelLines) {\n if (!line.trim()) continue;\n \n // Parse line: \"model:tag model_id size modified_time\"\n const parts = line.split(/\\s+/);\n if (parts.length >= 3) {\n models.push({\n name: parts[0],\n id: parts[1],\n size: parts[2] + (parts[3] === 'GB' || parts[3] === 'MB' ? ' ' + parts[3] : ''),\n status: 'installed'\n });\n }\n }\n \n return models;\n } catch (error) {\n console.log('[OllamaService] Failed to get installed models via CLI, falling back to API');\n // Fallback to API if CLI fails\n const apiModels = await this.getInstalledModels();\n return apiModels.map(model => ({\n name: model.name,\n id: model.digest || 'unknown',\n size: model.size || 'Unknown',\n status: 'installed'\n }));\n }\n }\n\n async getModelSuggestions() {\n try {\n // Get actually installed models\n const installedModels = await this.getInstalledModelsList();\n \n // Get user input history from storage (we'll implement this in the frontend)\n // For now, just return installed models\n return installedModels;\n } catch (error) {\n console.error('[OllamaService] Failed to get model suggestions:', error);\n return [];\n }\n }\n\n async isModelInstalled(modelName) {\n const models = await this.getInstalledModels();\n return models.some(model => model.name === modelName);\n }\n\n async pullModel(modelName) {\n if (!modelName?.trim()) {\n throw new Error(`Invalid model name: ${modelName}`);\n }\n\n console.log(`[OllamaService] Starting to pull model: ${modelName} via API`);\n \n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelName, \n progress: 0,\n status: 'starting'\n });\n \n try {\n const response = await fetch(`${this.baseUrl}/api/pull`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n stream: true\n })\n });\n\n if (!response.ok) {\n throw new Error(`Pull API failed: ${response.status} ${response.statusText}`);\n }\n\n // Handle Node.js streaming response\n return new Promise((resolve, reject) => {\n let buffer = '';\n \n response.body.on('data', (chunk) => {\n buffer += chunk.toString();\n const lines = buffer.split('\\n');\n \n // Keep incomplete line in buffer\n buffer = lines.pop() || '';\n \n // Process complete lines\n for (const line of lines) {\n if (!line.trim()) continue;\n \n try {\n const data = JSON.parse(line);\n const progress = this._parseOllamaPullProgress(data, modelName);\n \n if (progress !== null) {\n this.setInstallProgress(modelName, progress);\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', { \n model: modelName, \n progress,\n status: data.status || 'downloading'\n });\n console.log(`[OllamaService] API Progress: ${progress}% for ${modelName} (${data.status || 'downloading'})`);\n }\n\n // Handle completion\n if (data.status === 'success') {\n console.log(`[OllamaService] Successfully pulled model: ${modelName}`);\n this.emit('model-pull-complete', { model: modelName });\n this.clearInstallProgress(modelName);\n resolve();\n return;\n }\n } catch (parseError) {\n console.warn('[OllamaService] Failed to parse response line:', line);\n }\n }\n });\n\n response.body.on('end', () => {\n // Process any remaining data in buffer\n if (buffer.trim()) {\n try {\n const data = JSON.parse(buffer);\n if (data.status === 'success') {\n console.log(`[OllamaService] Successfully pulled model: ${modelName}`);\n this.emit('model-pull-complete', { model: modelName });\n }\n } catch (parseError) {\n console.warn('[OllamaService] Failed to parse final buffer:', buffer);\n }\n }\n this.clearInstallProgress(modelName);\n resolve();\n });\n\n response.body.on('error', (error) => {\n console.error(`[OllamaService] Stream error for ${modelName}:`, error);\n this.clearInstallProgress(modelName);\n reject(error);\n });\n });\n } catch (error) {\n this.clearInstallProgress(modelName);\n console.error(`[OllamaService] Pull model failed:`, error);\n throw error;\n }\n }\n\n _parseOllamaPullProgress(data, modelName) {\n // Handle Ollama API response format\n if (data.status === 'success') {\n return 100;\n }\n\n // Handle downloading progress\n if (data.total && data.completed !== undefined) {\n const progress = Math.round((data.completed / data.total) * 100);\n return Math.min(progress, 99); // Don't show 100% until success\n }\n\n // Handle status-based progress\n const statusProgress = {\n 'pulling manifest': 5,\n 'downloading': 10,\n 'verifying sha256 digest': 90,\n 'writing manifest': 95,\n 'removing any unused layers': 98\n };\n\n if (data.status && statusProgress[data.status] !== undefined) {\n return statusProgress[data.status];\n }\n\n return null;\n }\n\n\n\n async downloadFile(url, destination, options = {}) {\n const { \n onProgress = null,\n headers = { 'User-Agent': 'Glass-App' },\n timeout = 300000,\n modelId = null\n } = options;\n\n return new Promise((resolve, reject) => {\n const file = require('fs').createWriteStream(destination);\n let downloadedSize = 0;\n let totalSize = 0;\n\n const request = https.get(url, { headers }, (response) => {\n if ([301, 302, 307, 308].includes(response.statusCode)) {\n file.close();\n require('fs').unlink(destination, () => {});\n \n if (!response.headers.location) {\n reject(new Error('Redirect without location header'));\n return;\n }\n \n console.log(`[${this.serviceName}] Following redirect from ${url} to ${response.headers.location}`);\n this.downloadFile(response.headers.location, destination, options)\n .then(resolve)\n .catch(reject);\n return;\n }\n\n if (response.statusCode !== 200) {\n file.close();\n require('fs').unlink(destination, () => {});\n reject(new Error(`Download failed: ${response.statusCode} ${response.statusMessage}`));\n return;\n }\n\n totalSize = parseInt(response.headers['content-length'], 10) || 0;\n\n response.on('data', (chunk) => {\n downloadedSize += chunk.length;\n \n if (totalSize > 0) {\n const progress = Math.round((downloadedSize / totalSize) * 100);\n \n if (onProgress) {\n onProgress(progress, downloadedSize, totalSize);\n }\n }\n });\n\n response.pipe(file);\n\n file.on('finish', () => {\n file.close(() => {\n resolve({ success: true, size: downloadedSize });\n });\n });\n });\n\n request.on('timeout', () => {\n request.destroy();\n file.close();\n require('fs').unlink(destination, () => {});\n reject(new Error('Download timeout'));\n });\n\n request.on('error', (err) => {\n file.close();\n require('fs').unlink(destination, () => {});\n this.emit('download-error', { url, error: err, modelId });\n reject(err);\n });\n\n request.setTimeout(timeout);\n\n file.on('error', (err) => {\n require('fs').unlink(destination, () => {});\n reject(err);\n });\n });\n }\n\n async downloadWithRetry(url, destination, options = {}) {\n const { \n maxRetries = 3, \n retryDelay = 1000, \n expectedChecksum = null,\n modelId = null,\n ...downloadOptions \n } = options;\n \n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n try {\n const result = await this.downloadFile(url, destination, { \n ...downloadOptions, \n modelId \n });\n \n if (expectedChecksum) {\n const isValid = await this.verifyChecksum(destination, expectedChecksum);\n if (!isValid) {\n require('fs').unlinkSync(destination);\n throw new Error('Checksum verification failed');\n }\n console.log(`[${this.serviceName}] Checksum verified successfully`);\n }\n \n return result;\n } catch (error) {\n if (attempt === maxRetries) {\n throw error;\n }\n \n console.log(`Download attempt ${attempt} failed, retrying in ${retryDelay}ms...`);\n await new Promise(resolve => setTimeout(resolve, retryDelay * attempt));\n }\n }\n }\n\n async verifyChecksum(filePath, expectedChecksum) {\n return new Promise((resolve, reject) => {\n const hash = crypto.createHash('sha256');\n const stream = require('fs').createReadStream(filePath);\n \n stream.on('data', (data) => hash.update(data));\n stream.on('end', () => {\n const fileChecksum = hash.digest('hex');\n console.log(`[${this.serviceName}] File checksum: ${fileChecksum}`);\n console.log(`[${this.serviceName}] Expected checksum: ${expectedChecksum}`);\n resolve(fileChecksum === expectedChecksum);\n });\n stream.on('error', reject);\n });\n }\n\n async autoInstall(onProgress) {\n const platform = this.getPlatform();\n console.log(`[${this.serviceName}] Starting auto-installation for ${platform}`);\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.installMacOS(onProgress);\n case 'win32':\n return await this.installWindows(onProgress);\n case 'linux':\n return await this.installLinux();\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n } catch (error) {\n console.error(`[${this.serviceName}] Auto-installation failed:`, error);\n throw error;\n }\n }\n\n async installMacOS(onProgress) {\n console.log('[OllamaService] Installing Ollama on macOS using DMG...');\n \n try {\n const dmgUrl = 'https://ollama.com/download/Ollama.dmg';\n const tempDir = app.getPath('temp');\n const dmgPath = path.join(tempDir, 'Ollama.dmg');\n const mountPoint = path.join(tempDir, 'OllamaMount');\n\n // 체크포인트 저장\n await this.saveCheckpoint('pre-install');\n\n console.log('[OllamaService] Step 1: Downloading Ollama DMG...');\n onProgress?.({ stage: 'downloading', message: 'Downloading Ollama installer...', progress: 0 });\n const checksumInfo = DOWNLOAD_CHECKSUMS.ollama.dmg;\n await this.downloadWithRetry(dmgUrl, dmgPath, {\n expectedChecksum: checksumInfo?.sha256,\n onProgress: (progress) => {\n onProgress?.({ stage: 'downloading', message: `Downloading... ${progress}%`, progress });\n }\n });\n \n await this.saveCheckpoint('post-download');\n \n console.log('[OllamaService] Step 2: Mounting DMG...');\n onProgress?.({ stage: 'mounting', message: 'Mounting disk image...', progress: 0 });\n await fs.mkdir(mountPoint, { recursive: true });\n await spawnAsync('hdiutil', ['attach', dmgPath, '-mountpoint', mountPoint]);\n onProgress?.({ stage: 'mounting', message: 'Disk image mounted.', progress: 100 });\n \n console.log('[OllamaService] Step 3: Installing Ollama.app...');\n onProgress?.({ stage: 'installing', message: 'Installing Ollama application...', progress: 0 });\n await spawnAsync('cp', ['-R', `${mountPoint}/Ollama.app`, '/Applications/']);\n onProgress?.({ stage: 'installing', message: 'Application installed.', progress: 100 });\n \n await this.saveCheckpoint('post-install');\n \n console.log('[OllamaService] Step 4: Setting up CLI path...');\n onProgress?.({ stage: 'linking', message: 'Creating command-line shortcut...', progress: 0 });\n try {\n const script = `do shell script \"mkdir -p /usr/local/bin && ln -sf '${this.getOllamaCliPath()}' '/usr/local/bin/ollama'\" with administrator privileges`;\n await spawnAsync('osascript', ['-e', script]);\n onProgress?.({ stage: 'linking', message: 'Shortcut created.', progress: 100 });\n } catch (linkError) {\n console.error('[OllamaService] CLI symlink creation failed:', linkError.message);\n onProgress?.({ stage: 'linking', message: 'Shortcut creation failed (permissions?).', progress: 100 });\n // Not throwing an error, as the app might still work\n }\n \n console.log('[OllamaService] Step 5: Cleanup...');\n onProgress?.({ stage: 'cleanup', message: 'Cleaning up installation files...', progress: 0 });\n await spawnAsync('hdiutil', ['detach', mountPoint]);\n await fs.unlink(dmgPath).catch(() => {});\n await fs.rmdir(mountPoint).catch(() => {});\n onProgress?.({ stage: 'cleanup', message: 'Cleanup complete.', progress: 100 });\n \n console.log('[OllamaService] Ollama installed successfully on macOS');\n \n await new Promise(resolve => setTimeout(resolve, 2000));\n \n return true;\n } catch (error) {\n console.error('[OllamaService] macOS installation failed:', error);\n // 설치 실패 시 정리\n await fs.unlink(dmgPath).catch(() => {});\n throw new Error(`Failed to install Ollama on macOS: ${error.message}`);\n }\n }\n\n async installWindows(onProgress) {\n console.log('[OllamaService] Installing Ollama on Windows...');\n \n try {\n const exeUrl = 'https://ollama.com/download/OllamaSetup.exe';\n const tempDir = app.getPath('temp');\n const exePath = path.join(tempDir, 'OllamaSetup.exe');\n\n console.log('[OllamaService] Step 1: Downloading Ollama installer...');\n onProgress?.({ stage: 'downloading', message: 'Downloading Ollama installer...', progress: 0 });\n const checksumInfo = DOWNLOAD_CHECKSUMS.ollama.exe;\n await this.downloadWithRetry(exeUrl, exePath, {\n expectedChecksum: checksumInfo?.sha256,\n onProgress: (progress) => {\n onProgress?.({ stage: 'downloading', message: `Downloading... ${progress}%`, progress });\n }\n });\n \n console.log('[OllamaService] Step 2: Running silent installation...');\n onProgress?.({ stage: 'installing', message: 'Installing Ollama...', progress: 0 });\n await spawnAsync(exePath, ['/VERYSILENT', '/NORESTART']);\n onProgress?.({ stage: 'installing', message: 'Installation complete.', progress: 100 });\n \n console.log('[OllamaService] Step 3: Cleanup...');\n onProgress?.({ stage: 'cleanup', message: 'Cleaning up installation files...', progress: 0 });\n await fs.unlink(exePath).catch(() => {});\n onProgress?.({ stage: 'cleanup', message: 'Cleanup complete.', progress: 100 });\n \n console.log('[OllamaService] Ollama installed successfully on Windows');\n \n await new Promise(resolve => setTimeout(resolve, 3000));\n \n return true;\n } catch (error) {\n console.error('[OllamaService] Windows installation failed:', error);\n throw new Error(`Failed to install Ollama on Windows: ${error.message}`);\n }\n }\n\n async installLinux() {\n console.log('[OllamaService] Installing Ollama on Linux...');\n console.log('[OllamaService] Automatic installation on Linux is not supported for security reasons.');\n console.log('[OllamaService] Please install Ollama manually:');\n console.log('[OllamaService] 1. Visit https://ollama.com/download/linux');\n console.log('[OllamaService] 2. Follow the official installation instructions');\n console.log('[OllamaService] 3. Or use your package manager if available');\n throw new Error('Manual installation required on Linux. Please visit https://ollama.com/download/linux');\n }\n\n // === 체크포인트 & 롤백 시스템 ===\n async saveCheckpoint(name) {\n this.installCheckpoints.push({\n name,\n timestamp: Date.now(),\n state: { ...this.installState }\n });\n }\n\n async rollbackToLastCheckpoint() {\n const checkpoint = this.installCheckpoints.pop();\n if (checkpoint) {\n console.log(`[OllamaService] Rolling back to checkpoint: ${checkpoint.name}`);\n // 플랫폼별 롤백 로직 실행\n await this._executeRollback(checkpoint);\n }\n }\n\n async _executeRollback(checkpoint) {\n const platform = this.getPlatform();\n \n if (platform === 'darwin' && checkpoint.name === 'post-install') {\n // macOS 롤백\n await fs.rm('/Applications/Ollama.app', { recursive: true, force: true }).catch(() => {});\n } else if (platform === 'win32') {\n // Windows 롤백 (레지스트리 등)\n // TODO: Windows 롤백 구현\n }\n \n this.installState = checkpoint.state;\n }\n\n // === 상태 동기화 (내부 처리) ===\n async syncState() {\n // 서비스 종료 중이면 스킵\n if (this.isShuttingDown) {\n console.log('[OllamaService] Service is shutting down, skipping state sync');\n return this.installState;\n }\n \n try {\n const isInstalled = await this.isInstalled();\n const isRunning = await this.isServiceRunning();\n const models = isRunning && !this.isShuttingDown ? await this.getInstalledModels() : [];\n const loadedModels = isRunning && !this.isShuttingDown ? await this.getLoadedModels() : [];\n \n // 상태 업데이트\n this.installState.isInstalled = isInstalled;\n this.installState.isRunning = isRunning;\n this.installState.lastSync = Date.now();\n \n // 메모리 로드 상태 추적\n const previousLoadedModels = this._lastLoadedModels || [];\n const loadedChanged = loadedModels.length !== previousLoadedModels.length || \n !loadedModels.every(m => previousLoadedModels.includes(m));\n \n if (loadedChanged) {\n console.log(`[OllamaService] Loaded models changed: ${loadedModels.join(', ')}`);\n this._lastLoadedModels = loadedModels;\n \n // 메모리에서 언로드된 모델의 warmed 상태 제거\n for (const modelName of this.warmedModels) {\n if (!loadedModels.includes(modelName)) {\n this.warmedModels.delete(modelName);\n console.log(`[OllamaService] Model ${modelName} unloaded from memory, removing warmed state`);\n }\n }\n }\n \n // 모델 상태 DB 업데이트\n if (isRunning && models.length > 0) {\n for (const model of models) {\n try {\n const isLoaded = loadedModels.includes(model.name);\n // DB에는 installed 상태만 저장, loaded 상태는 메모리에서 관리\n await ollamaModelRepository.updateInstallStatus(model.name, true, false);\n \n // 로드 상태를 인스턴스 변수에 저장\n if (!this.modelLoadStatus) {\n this.modelLoadStatus = new Map();\n }\n this.modelLoadStatus.set(model.name, isLoaded);\n } catch (dbError) {\n console.warn(`[OllamaService] Failed to update DB for model ${model.name}:`, dbError);\n }\n }\n }\n \n // UI 알림 (상태 변경 시만)\n if (this._lastState?.isRunning !== isRunning || \n this._lastState?.isInstalled !== isInstalled ||\n loadedChanged) {\n // Emit state change event - LocalAIManager가 처리\n this.emit('state-changed', {\n installed: isInstalled,\n running: isRunning,\n models: models.length,\n loadedModels: loadedModels\n });\n }\n \n this._lastState = { isInstalled, isRunning, modelsCount: models.length };\n return { isInstalled, isRunning, models };\n \n } catch (error) {\n console.error('[OllamaService] State sync failed:', error);\n return { \n isInstalled: this.installState.isInstalled || false,\n isRunning: false,\n models: []\n };\n }\n }\n\n // 주기적 동기화 시작\n startPeriodicSync() {\n if (this._syncInterval) return;\n \n this._syncInterval = setInterval(() => {\n this.syncState();\n }, 30000); // 30초마다\n }\n\n stopPeriodicSync() {\n if (this._syncInterval) {\n clearInterval(this._syncInterval);\n this._syncInterval = null;\n }\n }\n\n async warmUpModel(modelName, forceRefresh = false) {\n if (!modelName?.trim()) {\n console.warn(`[OllamaService] Invalid model name for warm-up`);\n return false;\n }\n\n // Check if already warmed (and not forcing refresh)\n if (!forceRefresh && this.warmedModels.has(modelName)) {\n console.log(`[OllamaService] Model ${modelName} already warmed up, skipping`);\n return true;\n }\n\n // Check if currently warming - return existing Promise\n if (this.warmingModels.has(modelName)) {\n console.log(`[OllamaService] Model ${modelName} is already warming up, joining existing operation`);\n return await this.warmingModels.get(modelName);\n }\n\n // Check rate limiting (prevent too frequent attempts)\n const lastAttempt = this.lastWarmUpAttempt.get(modelName);\n const now = Date.now();\n if (lastAttempt && (now - lastAttempt) < 5000) { // 5 second cooldown\n console.log(`[OllamaService] Rate limiting warm-up for ${modelName}, try again in ${5 - Math.floor((now - lastAttempt) / 1000)}s`);\n return false;\n }\n\n // Create and store the warming Promise\n const warmingPromise = this._performWarmUp(modelName);\n this.warmingModels.set(modelName, warmingPromise);\n this.lastWarmUpAttempt.set(modelName, now);\n\n try {\n const result = await warmingPromise;\n \n if (result) {\n this.warmedModels.add(modelName);\n console.log(`[OllamaService] Model ${modelName} successfully warmed up`);\n }\n \n return result;\n } finally {\n // Always clean up the warming Promise\n this.warmingModels.delete(modelName);\n }\n }\n\n async _performWarmUp(modelName) {\n console.log(`[OllamaService] Starting warm-up for model: ${modelName}`);\n \n try {\n const response = await this.makeRequest('/api/chat', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n messages: [\n { role: 'user', content: 'Hi' }\n ],\n stream: false,\n options: {\n num_predict: 1, // Minimal response\n temperature: 0\n }\n })\n });\n\n return true;\n } catch (error) {\n // Check if it's a 404 error (model not found/installed)\n if (error.message.includes('HTTP 404') || error.message.includes('Not Found')) {\n console.log(`[OllamaService] Model ${modelName} not found (404), attempting to install...`);\n \n try {\n // Try to install the model\n await this.pullModel(modelName);\n console.log(`[OllamaService] Successfully installed model ${modelName}, retrying warm-up...`);\n \n // Update database to reflect installation\n await ollamaModelRepository.updateInstallStatus(modelName, true, false);\n \n // Retry warm-up after installation\n const retryResponse = await this.makeRequest('/api/chat', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: modelName,\n messages: [\n { role: 'user', content: 'Hi' }\n ],\n stream: false,\n options: {\n num_predict: 1,\n temperature: 0\n }\n })\n });\n \n console.log(`[OllamaService] Successfully warmed up model ${modelName} after installation`);\n return true;\n \n } catch (installError) {\n console.error(`[OllamaService] Failed to auto-install model ${modelName}:`, installError.message);\n await ollamaModelRepository.updateInstallStatus(modelName, false, false);\n return false;\n }\n } else {\n console.error(`[OllamaService] Failed to warm up model ${modelName}:`, error.message);\n return false;\n }\n }\n }\n\n async autoWarmUpSelectedModel() {\n try {\n // Get selected model from ModelStateService\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n console.log('[OllamaService] ModelStateService not available for auto warm-up');\n return false;\n }\n\n const selectedModels = await modelStateService.getSelectedModels();\n const llmModelId = selectedModels.llm;\n \n // Check if it's an Ollama model\n const provider = modelStateService.getProviderForModel('llm', llmModelId);\n if (provider !== 'ollama') {\n console.log('[OllamaService] Selected LLM is not Ollama, skipping warm-up');\n return false;\n }\n\n // Check if Ollama service is running\n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log('[OllamaService] Ollama service not running, clearing warm-up cache');\n this._clearWarmUpCache();\n return false;\n }\n\n // 설치 여부 체크 제거 - _performWarmUp에서 자동으로 설치 처리\n console.log(`[OllamaService] Auto-warming up selected model: ${llmModelId} (will auto-install if needed)`);\n const result = await this.warmUpModel(llmModelId);\n \n // 성공 시 LocalAIManager에 알림\n if (result) {\n this.emit('model-warmed-up', { model: llmModelId });\n }\n \n return result;\n \n } catch (error) {\n console.error('[OllamaService] Auto warm-up failed:', error);\n return false;\n }\n }\n\n _clearWarmUpCache() {\n this.warmedModels.clear();\n this.warmingModels.clear();\n this.lastWarmUpAttempt.clear();\n console.log('[OllamaService] Warm-up cache cleared');\n }\n\n async getWarmUpStatus() {\n const loadedModels = await this.getLoadedModels();\n \n return {\n warmedModels: Array.from(this.warmedModels),\n warmingModels: Array.from(this.warmingModels.keys()),\n loadedModels: loadedModels, // Models actually loaded in memory\n lastAttempts: Object.fromEntries(this.lastWarmUpAttempt)\n };\n }\n\n async shutdown(force = false) {\n console.log(`[OllamaService] Shutdown initiated (force: ${force})`);\n \n // 종료 중 플래그 설정\n this.isShuttingDown = true;\n \n if (!force && this.warmingModels.size > 0) {\n const warmingList = Array.from(this.warmingModels.keys());\n console.log(`[OllamaService] Waiting for ${warmingList.length} models to finish warming: ${warmingList.join(', ')}`);\n \n const warmingPromises = Array.from(this.warmingModels.values());\n try {\n // Use Promise.allSettled instead of race with setTimeout\n const results = await Promise.allSettled(warmingPromises);\n const completed = results.filter(r => r.status === 'fulfilled').length;\n console.log(`[OllamaService] ${completed}/${results.length} warming operations completed`);\n } catch (error) {\n console.log('[OllamaService] Error waiting for warm-up completion, proceeding with shutdown');\n }\n }\n\n // Clean up all resources\n this._clearWarmUpCache();\n this.stopPeriodicSync();\n \n // 프로세스 종료\n const isRunning = await this.isServiceRunning();\n if (!isRunning) {\n console.log('[OllamaService] Service not running, nothing to shutdown');\n return true;\n }\n\n const platform = this.getPlatform();\n \n try {\n switch(platform) {\n case 'darwin':\n return await this.shutdownMacOS(force);\n case 'win32':\n return await this.shutdownWindows(force);\n case 'linux':\n return await this.shutdownLinux(force);\n default:\n console.warn(`[OllamaService] Unsupported platform for shutdown: ${platform}`);\n return false;\n }\n } catch (error) {\n console.error(`[OllamaService] Error during shutdown:`, error);\n return false;\n }\n }\n\n async shutdownMacOS(force) {\n try {\n // 1. First, try to kill ollama server process\n console.log('[OllamaService] Killing ollama server process...');\n try {\n await spawnAsync('pkill', ['-f', 'ollama serve']);\n } catch (e) {\n // Process might not be running\n }\n \n // 2. Then quit the Ollama.app\n console.log('[OllamaService] Quitting Ollama.app...');\n try {\n await spawnAsync('osascript', ['-e', 'tell application \"Ollama\" to quit']);\n } catch (e) {\n console.log('[OllamaService] Ollama.app might not be running');\n }\n \n // 3. Wait a moment for shutdown\n await new Promise(resolve => setTimeout(resolve, 2000));\n \n // 4. Force kill any remaining ollama processes\n if (force || await this.isServiceRunning()) {\n console.log('[OllamaService] Force killing any remaining ollama processes...');\n try {\n // Kill all ollama processes\n await spawnAsync('pkill', ['-9', '-f', 'ollama']);\n } catch (e) {\n // Ignore errors - process might not exist\n }\n }\n \n // 5. Final check\n await new Promise(resolve => setTimeout(resolve, 1000));\n const stillRunning = await this.isServiceRunning();\n if (stillRunning) {\n console.warn('[OllamaService] Warning: Ollama may still be running');\n return false;\n }\n \n console.log('[OllamaService] Ollama shutdown complete');\n return true;\n } catch (error) {\n console.error('[OllamaService] Shutdown error:', error);\n return false;\n }\n }\n\n async shutdownWindows(force) {\n try {\n // Try to stop the service gracefully\n await spawnAsync('taskkill', ['/IM', 'ollama.exe', '/T']);\n console.log('[OllamaService] Ollama process terminated on Windows');\n return true;\n } catch (error) {\n console.log('[OllamaService] Standard termination failed, trying force kill');\n try {\n await spawnAsync('taskkill', ['/IM', 'ollama.exe', '/F', '/T']);\n return true;\n } catch (killError) {\n console.error('[OllamaService] Failed to force kill Ollama on Windows:', killError);\n return false;\n }\n }\n }\n\n async shutdownLinux(force) {\n try {\n await spawnAsync('pkill', ['-f', this.getOllamaCliPath()]);\n console.log('[OllamaService] Ollama process terminated on Linux');\n return true;\n } catch (error) {\n if (force) {\n await spawnAsync('pkill', ['-9', '-f', this.getOllamaCliPath()]).catch(() => {});\n }\n console.error('[OllamaService] Failed to shutdown Ollama on Linux:', error);\n return false;\n }\n }\n\n async getAllModelsWithStatus() {\n // Get all installed models directly from Ollama\n const installedModels = await this.getInstalledModels();\n \n // Get loaded models from memory\n const loadedModels = await this.getLoadedModels();\n \n const models = [];\n for (const model of installedModels) {\n const isWarmingUp = this.warmingModels.has(model.name);\n const isWarmedUp = this.warmedModels.has(model.name);\n const isLoaded = loadedModels.includes(model.name);\n \n models.push({\n name: model.name,\n displayName: model.name, // Use model name as display name\n size: model.size || 'Unknown',\n description: `Ollama model: ${model.name}`,\n installed: true,\n installing: this.installationProgress.has(model.name),\n progress: this.getInstallProgress(model.name),\n warmedUp: isWarmedUp,\n isWarmingUp,\n isLoaded, // Actually loaded in memory\n status: isWarmingUp ? 'warming' : (isLoaded ? 'loaded' : (isWarmedUp ? 'ready' : 'cold'))\n });\n }\n \n // Also add any models currently being installed\n for (const [modelName, progress] of this.installationProgress) {\n if (!models.find(m => m.name === modelName)) {\n models.push({\n name: modelName,\n displayName: modelName,\n size: 'Unknown',\n description: `Ollama model: ${modelName}`,\n installed: false,\n installing: true,\n progress: progress\n });\n }\n }\n \n return models;\n }\n\n async handleGetStatus() {\n try {\n const installed = await this.isInstalled();\n if (!installed) {\n return { success: true, installed: false, running: false, models: [] };\n }\n\n const running = await this.isServiceRunning();\n if (!running) {\n return { success: true, installed: true, running: false, models: [] };\n }\n\n const models = await this.getAllModelsWithStatus();\n return { success: true, installed: true, running: true, models };\n } catch (error) {\n console.error('[OllamaService] Error getting status:', error);\n return { success: false, error: error.message, installed: false, running: false, models: [] };\n }\n }\n\n async handleInstall() {\n try {\n const onProgress = (data) => {\n // Emit progress event - LocalAIManager가 처리\n this.emit('install-progress', data);\n };\n\n await this.autoInstall(onProgress);\n \n // 설치 검증\n onProgress({ stage: 'verifying', message: 'Verifying installation...', progress: 0 });\n const verifyResult = await this.verifyInstallation();\n if (!verifyResult.success) {\n throw new Error(`Installation verification failed: ${verifyResult.error}`);\n }\n onProgress({ stage: 'verifying', message: 'Installation verified.', progress: 100 });\n\n if (!await this.isServiceRunning()) {\n onProgress({ stage: 'starting', message: 'Starting Ollama service...', progress: 0 });\n await this.startService();\n onProgress({ stage: 'starting', message: 'Ollama service started.', progress: 100 });\n }\n \n this.installState.isInstalled = true;\n // Emit completion event - LocalAIManager가 처리\n this.emit('installation-complete');\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to install:', error);\n await this.rollbackToLastCheckpoint();\n // Emit error event - LocalAIManager가 처리\n this.emit('error', {\n errorType: 'installation-failed',\n error: error.message\n });\n return { success: false, error: error.message };\n }\n }\n\n async handleStartService() {\n try {\n if (!await this.isServiceRunning()) {\n console.log('[OllamaService] Starting Ollama service...');\n await this.startService();\n }\n this.emit('install-complete', { success: true });\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to start service:', error);\n this.emit('install-complete', { success: false, error: error.message });\n return { success: false, error: error.message };\n }\n }\n\n async handleEnsureReady() {\n try {\n if (await this.isInstalled() && !await this.isServiceRunning()) {\n console.log('[OllamaService] Ollama installed but not running, starting service...');\n await this.startService();\n }\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to ensure ready:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetModels() {\n try {\n const models = await this.getAllModelsWithStatus();\n return { success: true, models };\n } catch (error) {\n console.error('[OllamaService] Failed to get models:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetModelSuggestions() {\n try {\n const suggestions = await this.getModelSuggestions();\n return { success: true, suggestions };\n } catch (error) {\n console.error('[OllamaService] Failed to get model suggestions:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handlePullModel(modelName) {\n try {\n console.log(`[OllamaService] Starting model pull: ${modelName}`);\n\n await ollamaModelRepository.updateInstallStatus(modelName, false, true);\n\n await this.pullModel(modelName);\n\n await ollamaModelRepository.updateInstallStatus(modelName, true, false);\n\n console.log(`[OllamaService] Model ${modelName} pull successful`);\n return { success: true };\n } catch (error) {\n console.error('[OllamaService] Failed to pull model:', error);\n await ollamaModelRepository.updateInstallStatus(modelName, false, false);\n // Emit error event - LocalAIManager가 처리\n this.emit('error', { \n errorType: 'model-pull-failed',\n model: modelName, \n error: error.message \n });\n return { success: false, error: error.message };\n }\n }\n\n async handleIsModelInstalled(modelName) {\n try {\n const installed = await this.isModelInstalled(modelName);\n return { success: true, installed };\n } catch (error) {\n console.error('[OllamaService] Failed to check model installation:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleWarmUpModel(modelName) {\n try {\n const success = await this.warmUpModel(modelName);\n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to warm up model:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleAutoWarmUp() {\n try {\n const success = await this.autoWarmUpSelectedModel();\n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to auto warm-up:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleGetWarmUpStatus() {\n try {\n const status = await this.getWarmUpStatus();\n return { success: true, status };\n } catch (error) {\n console.error('[OllamaService] Failed to get warm-up status:', error);\n return { success: false, error: error.message };\n }\n }\n\n async handleShutdown(force = false) {\n try {\n console.log(`[OllamaService] Manual shutdown requested (force: ${force})`);\n const success = await this.shutdown(force);\n \n // 종료 후 상태 업데이트 및 플래그 리셋\n if (success) {\n // 종료 완료 후 플래그 리셋\n this.isShuttingDown = false;\n await this.syncState();\n }\n \n return { success };\n } catch (error) {\n console.error('[OllamaService] Failed to shutdown Ollama:', error);\n return { success: false, error: error.message };\n }\n }\n \n // 설치 검증\n async verifyInstallation() {\n try {\n console.log('[OllamaService] Verifying installation...');\n \n // 1. 바이너리 확인\n const isInstalled = await this.isInstalled();\n if (!isInstalled) {\n return { success: false, error: 'Ollama binary not found' };\n }\n \n // 2. CLI 명령 테스트\n try {\n const { stdout } = await spawnAsync(this.getOllamaCliPath(), ['--version']);\n console.log('[OllamaService] Ollama version:', stdout.trim());\n } catch (error) {\n return { success: false, error: 'Ollama CLI not responding' };\n }\n \n // 3. 서비스 시작 가능 여부 확인\n const platform = this.getPlatform();\n if (platform === 'darwin') {\n // macOS: 앱 번들 확인\n try {\n await fs.access('/Applications/Ollama.app/Contents/MacOS/Ollama');\n } catch (error) {\n return { success: false, error: 'Ollama.app executable not found' };\n }\n }\n \n console.log('[OllamaService] Installation verified successfully');\n return { success: true };\n \n } catch (error) {\n console.error('[OllamaService] Verification failed:', error);\n return { success: false, error: error.message };\n }\n }\n}\n\n// Export singleton instance\nconst ollamaService = new OllamaService();\nmodule.exports = ollamaService;"], ["/glass/src/features/common/ai/providers/gemini.js", "const { GoogleGenerativeAI } = require(\"@google/generative-ai\")\nconst { GoogleGenAI } = require(\"@google/genai\")\n\nclass GeminiProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string') {\n return { success: false, error: 'Invalid Gemini API key format.' };\n }\n\n try {\n const validationUrl = `https://generativelanguage.googleapis.com/v1beta/models?key=${key}`;\n const response = await fetch(validationUrl);\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error?.message || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[GeminiProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n\n/**\n * Creates a Gemini STT session\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Gemini API key\n * @param {string} [opts.language='en-US'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @returns {Promise} STT session\n */\nasync function createSTT({ apiKey, language = \"en-US\", callbacks = {}, ...config }) {\n const liveClient = new GoogleGenAI({ vertexai: false, apiKey })\n\n // Language code BCP-47 conversion\n const lang = language.includes(\"-\") ? language : `${language}-US`\n\n const session = await liveClient.live.connect({\n\n model: 'gemini-live-2.5-flash-preview',\n callbacks: {\n ...callbacks,\n onMessage: (msg) => {\n if (!msg || typeof msg !== 'object') return;\n msg.provider = 'gemini';\n callbacks.onmessage?.(msg);\n }\n },\n\n config: {\n inputAudioTranscription: {},\n speechConfig: { languageCode: lang },\n },\n })\n\n return {\n sendRealtimeInput: async (payload) => session.sendRealtimeInput(payload),\n close: async () => session.close(),\n }\n}\n\n/**\n * Creates a Gemini LLM instance with proper text response handling\n */\nfunction createLLM({ apiKey, model = \"gemini-2.5-flash\", temperature = 0.7, maxTokens = 8192, ...config }) {\n const client = new GoogleGenerativeAI(apiKey)\n\n return {\n generateContent: async (parts) => {\n const geminiModel = client.getGenerativeModel({\n model: model,\n generationConfig: {\n temperature,\n maxOutputTokens: maxTokens,\n // Ensure we get text responses, not JSON\n responseMimeType: \"text/plain\",\n },\n })\n\n const systemPrompt = \"\"\n const userContent = []\n\n for (const part of parts) {\n if (typeof part === \"string\") {\n // Don't automatically assume strings starting with \"You are\" are system prompts\n // Check if it's explicitly marked as a system instruction\n userContent.push(part)\n } else if (part.inlineData) {\n userContent.push({\n inlineData: {\n mimeType: part.inlineData.mimeType,\n data: part.inlineData.data,\n },\n })\n }\n }\n\n try {\n const result = await geminiModel.generateContent(userContent)\n const response = await result.response\n\n // Return plain text, not wrapped in JSON structure\n return {\n response: {\n text: () => response.text(),\n },\n }\n } catch (error) {\n console.error(\"Gemini API error:\", error)\n throw error\n }\n },\n\n chat: async (messages) => {\n // Filter out any system prompts that might be causing JSON responses\n let systemInstruction = \"\"\n const history = []\n let lastMessage\n\n messages.forEach((msg, index) => {\n if (msg.role === \"system\") {\n // Clean system instruction - avoid JSON formatting requests\n systemInstruction = msg.content\n .replace(/respond in json/gi, \"\")\n .replace(/format.*json/gi, \"\")\n .replace(/return.*json/gi, \"\")\n\n // Add explicit instruction for natural text\n if (!systemInstruction.includes(\"respond naturally\")) {\n systemInstruction += \"\\n\\nRespond naturally in plain text, not in JSON or structured format.\"\n }\n return\n }\n\n const role = msg.role === \"user\" ? \"user\" : \"model\"\n\n if (index === messages.length - 1) {\n lastMessage = msg\n } else {\n history.push({ role, parts: [{ text: msg.content }] })\n }\n })\n\n const geminiModel = client.getGenerativeModel({\n model: model,\n systemInstruction:\n systemInstruction ||\n \"Respond naturally in plain text format. Do not use JSON or structured responses unless specifically requested.\",\n generationConfig: {\n temperature: temperature,\n maxOutputTokens: maxTokens,\n // Force plain text responses\n responseMimeType: \"text/plain\",\n },\n })\n\n const chat = geminiModel.startChat({\n history: history,\n })\n\n let content = lastMessage.content\n\n // Handle multimodal content\n if (Array.isArray(content)) {\n const geminiContent = []\n for (const part of content) {\n if (typeof part === \"string\") {\n geminiContent.push(part)\n } else if (part.type === \"text\") {\n geminiContent.push(part.text)\n } else if (part.type === \"image_url\" && part.image_url) {\n const base64Data = part.image_url.url.split(\",\")[1]\n geminiContent.push({\n inlineData: {\n mimeType: \"image/png\",\n data: base64Data,\n },\n })\n }\n }\n content = geminiContent\n }\n\n const result = await chat.sendMessage(content)\n const response = await result.response\n\n // Return plain text content\n return {\n content: response.text(),\n raw: result,\n }\n },\n }\n}\n\n/**\n * Creates a Gemini streaming LLM instance with text response fix\n */\nfunction createStreamingLLM({ apiKey, model = \"gemini-2.5-flash\", temperature = 0.7, maxTokens = 8192, ...config }) {\n const client = new GoogleGenerativeAI(apiKey)\n\n return {\n streamChat: async (messages) => {\n console.log(\"[Gemini Provider] Starting streaming request\")\n\n let systemInstruction = \"\"\n const nonSystemMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n // Clean and modify system instruction\n systemInstruction = msg.content\n .replace(/respond in json/gi, \"\")\n .replace(/format.*json/gi, \"\")\n .replace(/return.*json/gi, \"\")\n\n if (!systemInstruction.includes(\"respond naturally\")) {\n systemInstruction += \"\\n\\nRespond naturally in plain text, not in JSON or structured format.\"\n }\n } else {\n nonSystemMessages.push(msg)\n }\n }\n\n const geminiModel = client.getGenerativeModel({\n model: model,\n systemInstruction:\n systemInstruction ||\n \"Respond naturally in plain text format. Do not use JSON or structured responses unless specifically requested.\",\n generationConfig: {\n temperature,\n maxOutputTokens: maxTokens || 8192,\n // Force plain text responses\n responseMimeType: \"text/plain\",\n },\n })\n\n const stream = new ReadableStream({\n async start(controller) {\n try {\n const lastMessage = nonSystemMessages[nonSystemMessages.length - 1]\n let geminiContent = []\n\n if (Array.isArray(lastMessage.content)) {\n for (const part of lastMessage.content) {\n if (typeof part === \"string\") {\n geminiContent.push(part)\n } else if (part.type === \"text\") {\n geminiContent.push(part.text)\n } else if (part.type === \"image_url\" && part.image_url) {\n const base64Data = part.image_url.url.split(\",\")[1]\n geminiContent.push({\n inlineData: {\n mimeType: \"image/png\",\n data: base64Data,\n },\n })\n }\n }\n } else {\n geminiContent = [lastMessage.content]\n }\n\n const contentParts = geminiContent.map((part) => {\n if (typeof part === \"string\") {\n return { text: part }\n } else if (part.inlineData) {\n return { inlineData: part.inlineData }\n }\n return part\n })\n\n const result = await geminiModel.generateContentStream({\n contents: [\n {\n role: \"user\",\n parts: contentParts,\n },\n ],\n })\n\n for await (const chunk of result.stream) {\n const chunkText = chunk.text() || \"\"\n\n // Format as SSE data - this should now be plain text\n const data = JSON.stringify({\n choices: [\n {\n delta: {\n content: chunkText,\n },\n },\n ],\n })\n controller.enqueue(new TextEncoder().encode(`data: ${data}\\n\\n`))\n }\n\n controller.enqueue(new TextEncoder().encode(\"data: [DONE]\\n\\n\"))\n controller.close()\n } catch (error) {\n console.error(\"[Gemini Provider] Streaming error:\", error)\n controller.error(error)\n }\n },\n })\n\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n },\n })\n },\n }\n}\n\nmodule.exports = {\n GeminiProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};\n"], ["/glass/src/features/common/repositories/user/firebase.repository.js", "const { doc, getDoc, setDoc, deleteDoc, writeBatch, query, where, getDocs, collection, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst userConverter = createEncryptedConverter([]);\n\nfunction usersCol() {\n const db = getFirestoreInstance();\n return collection(db, 'users').withConverter(userConverter);\n}\n\n// These functions are mostly correct as they already operate on a top-level collection.\n// We just need to ensure the signatures are consistent.\n\nasync function findOrCreate(user) {\n if (!user || !user.uid) throw new Error('User object and uid are required');\n const { uid, displayName, email } = user;\n const now = Timestamp.now();\n const docRef = doc(usersCol(), uid);\n const docSnap = await getDoc(docRef);\n\n if (docSnap.exists()) {\n await setDoc(docRef, { \n display_name: displayName || docSnap.data().display_name || 'User',\n email: email || docSnap.data().email || 'no-email@example.com'\n }, { merge: true });\n } else {\n await setDoc(docRef, { uid, display_name: displayName || 'User', email: email || 'no-email@example.com', created_at: now });\n }\n const finalDoc = await getDoc(docRef);\n return finalDoc.data();\n}\n\nasync function getById(uid) {\n const docRef = doc(usersCol(), uid);\n const docSnap = await getDoc(docRef);\n return docSnap.exists() ? docSnap.data() : null;\n}\n\n\n\nasync function update({ uid, displayName }) {\n const docRef = doc(usersCol(), uid);\n await setDoc(docRef, { display_name: displayName }, { merge: true });\n return { changes: 1 };\n}\n\nasync function deleteById(uid) {\n const db = getFirestoreInstance();\n const batch = writeBatch(db);\n\n // 1. Delete all sessions owned by the user\n const sessionsQuery = query(collection(db, 'sessions'), where('uid', '==', uid));\n const sessionsSnapshot = await getDocs(sessionsQuery);\n \n for (const sessionDoc of sessionsSnapshot.docs) {\n // Recursively delete sub-collections\n const subcollectionsToDelete = ['transcripts', 'ai_messages', 'summary'];\n for (const sub of subcollectionsToDelete) {\n const subColPath = `sessions/${sessionDoc.id}/${sub}`;\n const subSnapshot = await getDocs(query(collection(db, subColPath)));\n subSnapshot.forEach(d => batch.delete(d.ref));\n }\n batch.delete(sessionDoc.ref);\n }\n\n // 2. Delete all presets owned by the user\n const presetsQuery = query(collection(db, 'prompt_presets'), where('uid', '==', uid));\n const presetsSnapshot = await getDocs(presetsQuery);\n presetsSnapshot.forEach(doc => batch.delete(doc.ref));\n\n // 3. Delete the user document itself\n const userRef = doc(usersCol(), uid);\n batch.delete(userRef);\n\n await batch.commit();\n return { success: true };\n}\n\nmodule.exports = {\n findOrCreate,\n getById,\n update,\n deleteById,\n}; "], ["/glass/src/features/common/repositories/preset/firebase.repository.js", "const { collection, doc, addDoc, getDoc, getDocs, updateDoc, deleteDoc, query, where, orderBy, Timestamp } = require('firebase/firestore');\nconst { getFirestoreInstance } = require('../../services/firebaseClient');\nconst { createEncryptedConverter } = require('../firestoreConverter');\nconst encryptionService = require('../../services/encryptionService');\n\nconst userPresetConverter = createEncryptedConverter(['prompt', 'title']);\n\nconst defaultPresetConverter = {\n toFirestore: (data) => data,\n fromFirestore: (snapshot, options) => {\n const data = snapshot.data(options);\n return { ...data, id: snapshot.id };\n }\n};\n\nfunction userPresetsCol() {\n const db = getFirestoreInstance();\n return collection(db, 'prompt_presets').withConverter(userPresetConverter);\n}\n\nfunction defaultPresetsCol() {\n const db = getFirestoreInstance();\n // Path must have an odd number of segments. 'v1' is a placeholder document.\n return collection(db, 'defaults/v1/prompt_presets').withConverter(defaultPresetConverter);\n}\n\nasync function getPresets(uid) {\n const userPresetsQuery = query(userPresetsCol(), where('uid', '==', uid));\n const defaultPresetsQuery = query(defaultPresetsCol()); // Defaults have no owner\n\n const [userSnapshot, defaultSnapshot] = await Promise.all([\n getDocs(userPresetsQuery),\n getDocs(defaultPresetsQuery)\n ]);\n\n const presets = [\n ...defaultSnapshot.docs.map(d => d.data()),\n ...userSnapshot.docs.map(d => d.data())\n ];\n\n return presets.sort((a, b) => {\n if (a.is_default && !b.is_default) return -1;\n if (!a.is_default && b.is_default) return 1;\n return a.title.localeCompare(b.title);\n });\n}\n\nasync function getPresetTemplates() {\n const q = query(defaultPresetsCol(), orderBy('title', 'asc'));\n const snapshot = await getDocs(q);\n return snapshot.docs.map(doc => doc.data());\n}\n\nasync function create({ uid, title, prompt }) {\n const now = Timestamp.now();\n const newPreset = {\n uid: uid,\n title,\n prompt,\n is_default: 0,\n created_at: now,\n };\n const docRef = await addDoc(userPresetsCol(), newPreset);\n return { id: docRef.id };\n}\n\nasync function update(id, { title, prompt }, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to update.\");\n }\n\n // Encrypt sensitive fields before sending to Firestore because `updateDoc` bypasses converters.\n const updates = {};\n if (title !== undefined) {\n updates.title = encryptionService.encrypt(title);\n }\n if (prompt !== undefined) {\n updates.prompt = encryptionService.encrypt(prompt);\n }\n updates.updated_at = Timestamp.now();\n\n await updateDoc(docRef, updates);\n return { changes: 1 };\n}\n\nasync function del(id, uid) {\n const docRef = doc(userPresetsCol(), id);\n const docSnap = await getDoc(docRef);\n\n if (!docSnap.exists() || docSnap.data().uid !== uid || docSnap.data().is_default) {\n throw new Error(\"Preset not found or permission denied to delete.\");\n }\n\n await deleteDoc(docRef);\n return { changes: 1 };\n}\n\nmodule.exports = {\n getPresets,\n getPresetTemplates,\n create,\n update,\n delete: del,\n}; "], ["/glass/src/features/common/ai/providers/openai.js", "const OpenAI = require('openai');\nconst WebSocket = require('ws');\nconst { Portkey } = require('portkey-ai');\nconst { Readable } = require('stream');\nconst { getProviderForModel } = require('../factory.js');\n\n\nclass OpenAIProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string' || !key.startsWith('sk-')) {\n return { success: false, error: 'Invalid OpenAI API key format.' };\n }\n\n try {\n const response = await fetch('https://api.openai.com/v1/models', {\n headers: { 'Authorization': `Bearer ${key}` }\n });\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error?.message || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[OpenAIProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n\n/**\n * Creates an OpenAI STT session\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.language='en'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {Promise} STT session\n */\nasync function createSTT({ apiKey, language = 'en', callbacks = {}, usePortkey = false, portkeyVirtualKey, ...config }) {\n const keyType = usePortkey ? 'vKey' : 'apiKey';\n const key = usePortkey ? (portkeyVirtualKey || apiKey) : apiKey;\n\n const wsUrl = keyType === 'apiKey'\n ? 'wss://api.openai.com/v1/realtime?intent=transcription'\n : 'wss://api.portkey.ai/v1/realtime?intent=transcription';\n\n const headers = keyType === 'apiKey'\n ? {\n 'Authorization': `Bearer ${key}`,\n 'OpenAI-Beta': 'realtime=v1',\n }\n : {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': key,\n 'OpenAI-Beta': 'realtime=v1',\n };\n\n const ws = new WebSocket(wsUrl, { headers });\n\n return new Promise((resolve, reject) => {\n ws.onopen = () => {\n console.log(\"WebSocket session opened.\");\n\n const sessionConfig = {\n type: 'transcription_session.update',\n session: {\n input_audio_format: 'pcm16',\n input_audio_transcription: {\n model: 'gpt-4o-mini-transcribe',\n prompt: config.prompt || '',\n language: language || 'en'\n },\n turn_detection: {\n type: 'server_vad',\n threshold: 0.5,\n prefix_padding_ms: 200,\n silence_duration_ms: 100,\n },\n input_audio_noise_reduction: {\n type: 'near_field'\n }\n }\n };\n \n ws.send(JSON.stringify(sessionConfig));\n\n // Helper to periodically keep the websocket alive\n const keepAlive = () => {\n try {\n if (ws.readyState === WebSocket.OPEN) {\n // The ws library supports native ping frames which are ideal for heart-beats\n ws.ping();\n }\n } catch (err) {\n console.error('[OpenAI STT] keepAlive error:', err.message);\n }\n };\n\n resolve({\n sendRealtimeInput: (audioData) => {\n if (ws.readyState === WebSocket.OPEN) {\n const message = {\n type: 'input_audio_buffer.append',\n audio: audioData\n };\n ws.send(JSON.stringify(message));\n }\n },\n // Expose keepAlive so higher-level services can schedule heart-beats\n keepAlive,\n close: () => {\n if (ws.readyState === WebSocket.OPEN) {\n ws.send(JSON.stringify({ type: 'session.close' }));\n ws.onmessage = ws.onerror = () => {}; // 핸들러 제거\n ws.close(1000, 'Client initiated close.');\n }\n }\n });\n };\n\n ws.onmessage = (event) => {\n // ── 종료·하트비트 패킷 필터링 ──────────────────────────────\n if (!event.data || event.data === 'null' || event.data === '[DONE]') return;\n\n let msg;\n try { msg = JSON.parse(event.data); }\n catch { return; } // JSON 파싱 실패 무시\n\n if (!msg || typeof msg !== 'object') return;\n\n msg.provider = 'openai'; // ← 항상 명시\n callbacks.onmessage?.(msg);\n };\n\n ws.onerror = (error) => {\n console.error('WebSocket error:', error.message);\n if (callbacks && callbacks.onerror) {\n callbacks.onerror(error);\n }\n reject(error);\n };\n\n ws.onclose = (event) => {\n console.log(`WebSocket closed: ${event.code} ${event.reason}`);\n if (callbacks && callbacks.onclose) {\n callbacks.onclose(event);\n }\n };\n });\n}\n\n/**\n * Creates an OpenAI LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.model='gpt-4.1'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=2048] - Max tokens\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {object} LLM instance\n */\nfunction createLLM({ apiKey, model = 'gpt-4.1', temperature = 0.7, maxTokens = 2048, usePortkey = false, portkeyVirtualKey, ...config }) {\n const client = new OpenAI({ apiKey });\n \n const callApi = async (messages) => {\n if (!usePortkey) {\n const response = await client.chat.completions.create({\n model: model,\n messages: messages,\n temperature: temperature,\n max_tokens: maxTokens\n });\n return {\n content: response.choices[0].message.content.trim(),\n raw: response\n };\n } else {\n const fetchUrl = 'https://api.portkey.ai/v1/chat/completions';\n const response = await fetch(fetchUrl, {\n method: 'POST',\n headers: {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': portkeyVirtualKey || apiKey,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: model,\n messages,\n temperature,\n max_tokens: maxTokens,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Portkey API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n return {\n content: result.choices[0].message.content.trim(),\n raw: result\n };\n }\n };\n\n return {\n generateContent: async (parts) => {\n const messages = [];\n let systemPrompt = '';\n let userContent = [];\n \n for (const part of parts) {\n if (typeof part === 'string') {\n if (systemPrompt === '' && part.includes('You are')) {\n systemPrompt = part;\n } else {\n userContent.push({ type: 'text', text: part });\n }\n } else if (part.inlineData) {\n userContent.push({\n type: 'image_url',\n image_url: { url: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}` }\n });\n }\n }\n \n if (systemPrompt) messages.push({ role: 'system', content: systemPrompt });\n if (userContent.length > 0) messages.push({ role: 'user', content: userContent });\n \n const result = await callApi(messages);\n\n return {\n response: {\n text: () => result.content\n },\n raw: result.raw\n };\n },\n \n // For compatibility with chat-style interfaces\n chat: async (messages) => {\n return await callApi(messages);\n }\n };\n}\n\n/** \n * Creates an OpenAI streaming LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - OpenAI API key\n * @param {string} [opts.model='gpt-4.1'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=2048] - Max tokens\n * @param {boolean} [opts.usePortkey=false] - Whether to use Portkey\n * @param {string} [opts.portkeyVirtualKey] - Portkey virtual key\n * @returns {object} Streaming LLM instance\n */\nfunction createStreamingLLM({ apiKey, model = 'gpt-4.1', temperature = 0.7, maxTokens = 2048, usePortkey = false, portkeyVirtualKey, ...config }) {\n return {\n streamChat: async (messages) => {\n const fetchUrl = usePortkey \n ? 'https://api.portkey.ai/v1/chat/completions'\n : 'https://api.openai.com/v1/chat/completions';\n \n const headers = usePortkey\n ? {\n 'x-portkey-api-key': 'gRv2UGRMq6GGLJ8aVEB4e7adIewu',\n 'x-portkey-virtual-key': portkeyVirtualKey || apiKey,\n 'Content-Type': 'application/json',\n }\n : {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n };\n\n const response = await fetch(fetchUrl, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n model: model,\n messages,\n temperature,\n max_tokens: maxTokens,\n stream: true,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`OpenAI API error: ${response.status} ${response.statusText}`);\n }\n\n return response;\n }\n };\n}\n\nmodule.exports = {\n OpenAIProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n}; "], ["/glass/src/ui/app/ApiKeyHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class ApiKeyHeader extends LitElement {\n //////// after_modelStateService ////////\n static properties = {\n llmApiKey: { type: String },\n sttApiKey: { type: String },\n llmProvider: { type: String },\n sttProvider: { type: String },\n isLoading: { type: Boolean },\n errorMessage: { type: String },\n successMessage: { type: String },\n providers: { type: Object, state: true },\n modelSuggestions: { type: Array, state: true },\n userModelHistory: { type: Array, state: true },\n selectedLlmModel: { type: String, state: true },\n selectedSttModel: { type: String, state: true },\n ollamaStatus: { type: Object, state: true },\n installingModel: { type: String, state: true },\n installProgress: { type: Number, state: true },\n whisperInstallingModels: { type: Object, state: true },\n backCallback: { type: Function },\n llmError: { type: String },\n sttError: { type: String },\n };\n //////// after_modelStateService ////////\n\n static styles = css`\n :host {\n display: block;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n sans-serif;\n }\n * {\n box-sizing: border-box;\n }\n .container {\n width: 100%;\n height: 100%;\n padding: 24px 16px;\n background: rgba(0, 0, 0, 0.64);\n box-shadow: 0px 0px 0px 1.5px rgba(255, 255, 255, 0.64) inset;\n border-radius: 16px;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 24px;\n display: flex;\n -webkit-app-region: drag;\n }\n .header {\n width: 100%;\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-bottom: 8px;\n }\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 16px;\n right: 16px;\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 5px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 16px;\n line-height: 1;\n padding: 0;\n }\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n .back-button {\n -webkit-app-region: no-drag;\n padding: 8px;\n left: 0px;\n top: -7px;\n position: absolute;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n border-radius: 16px;\n border: 0.5px solid rgba(255, 255, 255, 0.5);\n justify-content: center;\n align-items: center;\n gap: 4px;\n display: flex;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n .back-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .arrow-icon-left {\n border: solid #dcdcdc;\n border-width: 0 1.2px 1.2px 0;\n display: inline-block;\n padding: 3px;\n transform: rotate(135deg);\n }\n .back-button-text {\n color: white;\n font-size: 12px;\n font-weight: 500;\n padding-right: 4px;\n }\n .title {\n color: white;\n font-size: 14px;\n font-weight: 700;\n }\n .section {\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .row {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n .label {\n color: white;\n font-size: 12px;\n font-weight: 600;\n }\n .provider-selector {\n display: flex;\n width: 240px;\n overflow: hidden;\n border-radius: 12px;\n border: 0.5px solid rgba(255, 255, 255, 0.5);\n }\n .provider-button {\n -webkit-app-region: no-drag;\n padding: 4px 8px;\n background: rgba(20.4, 20.4, 20.4, 0.32);\n color: #dcdcdc;\n font-size: 11px;\n font-weight: 450;\n letter-spacing: 0.11px;\n border: none;\n cursor: pointer;\n transition: background-color 0.2s ease;\n flex: 1;\n }\n .provider-button:hover {\n background: rgba(80, 80, 80, 0.48);\n }\n .provider-button[data-status='active'] {\n background: rgba(142.8, 142.8, 142.8, 0.48);\n color: white;\n }\n .api-input {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 10px 8px;\n background: rgba(61.2, 61.2, 61.2, 0.8);\n border-radius: 6px;\n border: 1px solid rgba(255, 255, 255, 0.24);\n color: white;\n font-size: 11px;\n text-overflow: ellipsis;\n font-family: inherit;\n line-height: inherit;\n }\n .ollama-action-button {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 10px 8px;\n border-radius: 16px;\n border: none;\n color: white;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n cursor: pointer;\n text-align: center;\n transition: background-color 0.2s ease;\n }\n .ollama-action-button.install {\n background: rgba(0, 122, 255, 0.2);\n }\n .ollama-action-button.start {\n background: rgba(255, 200, 0, 0.2);\n }\n select.api-input {\n -webkit-appearance: none;\n appearance: none;\n background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e\");\n background-position: right 0.5rem center;\n background-repeat: no-repeat;\n background-size: 1.5em 1.5em;\n padding-right: 2.5rem;\n }\n select.api-input option {\n background: #333;\n color: white;\n }\n .api-input::placeholder {\n color: #a0a0a0;\n }\n .confirm-button-container {\n width: 100%;\n display: flex;\n justify-content: flex-end;\n }\n .confirm-button {\n -webkit-app-region: no-drag;\n width: 240px;\n padding: 8px;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.16);\n border-radius: 16px;\n border: 1px solid rgba(255, 255, 255, 0.5);\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n .confirm-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .confirm-button:disabled {\n background: rgba(255, 255, 255, 0.12);\n color: #bebebe;\n border: 0.5px solid rgba(255, 255, 255, 0.24);\n box-shadow: none;\n cursor: not-allowed;\n }\n .footer {\n width: 100%;\n text-align: center;\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 500;\n line-height: 18px;\n }\n .footer-link {\n text-decoration: underline;\n cursor: pointer;\n -webkit-app-region: no-drag;\n }\n .error-message,\n .success-message {\n position: absolute;\n bottom: 70px;\n left: 16px;\n right: 16px;\n text-align: center;\n font-size: 11px;\n font-weight: 500;\n padding: 4px;\n border-radius: 4px;\n }\n .error-message {\n color: rgba(239, 68, 68, 0.9);\n }\n .success-message {\n color: rgba(74, 222, 128, 0.9);\n }\n .message-fade-out {\n animation: fadeOut 3s ease-in-out forwards;\n }\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 66% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n .sliding-out {\n animation: slideOut 0.3s ease-out forwards;\n }\n @keyframes slideOut {\n from {\n transform: translateY(0);\n opacity: 1;\n }\n to {\n transform: translateY(-100%);\n opacity: 0;\n }\n }\n .api-input.invalid {\n outline: 1px solid #ff7070;\n outline-offset: -1px;\n }\n .input-wrapper {\n display: flex;\n flex-direction: column;\n gap: 4px;\n align-items: flex-start;\n }\n .inline-error-message {\n color: #ff7070;\n font-size: 11px;\n font-weight: 400;\n letter-spacing: 0.11px;\n word-wrap: break-word;\n width: 240px;\n }\n `;\n\n\n constructor() {\n super();\n this.isLoading = false;\n this.errorMessage = '';\n this.successMessage = '';\n this.messageTimestamp = 0;\n //////// after_modelStateService ////////\n this.llmApiKey = '';\n this.sttApiKey = '';\n this.llmProvider = 'openai';\n this.sttProvider = 'openai';\n this.providers = { llm: [], stt: [] }; // 초기화\n // Ollama related\n this.modelSuggestions = [];\n this.userModelHistory = [];\n this.selectedLlmModel = '';\n this.selectedSttModel = '';\n this.ollamaStatus = { installed: false, running: false };\n this.installingModel = null;\n this.installProgress = 0;\n this.whisperInstallingModels = {};\n this.backCallback = () => {};\n this.llmError = '';\n this.sttError = '';\n\n // Professional operation management system\n this.activeOperations = new Map();\n this.operationTimeouts = new Map();\n this.connectionState = 'idle'; // idle, connecting, connected, failed, disconnected\n this.lastStateChange = Date.now();\n this.retryCount = 0;\n this.maxRetries = 3;\n this.baseRetryDelay = 1000;\n\n // Backpressure and resource management\n this.operationQueue = [];\n this.maxConcurrentOperations = 2;\n this.maxQueueSize = 5;\n this.operationMetrics = {\n totalOperations: 0,\n successfulOperations: 0,\n failedOperations: 0,\n timeouts: 0,\n averageResponseTime: 0,\n };\n\n // Configuration\n this.ipcTimeout = 10000; // 10s for IPC calls\n this.operationTimeout = 15000; // 15s for complex operations\n\n // Health monitoring system\n this.healthCheck = {\n enabled: false,\n intervalId: null,\n intervalMs: 30000, // 30s\n lastCheck: 0,\n consecutiveFailures: 0,\n maxFailures: 3,\n };\n\n // Load user model history from localStorage\n this.loadUserModelHistory();\n this.loadProviderConfig();\n //////// after_modelStateService ////////\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleInput = this.handleInput.bind(this);\n this.handleAnimationEnd = this.handleAnimationEnd.bind(this);\n this.handleProviderChange = this.handleProviderChange.bind(this);\n this.handleLlmProviderChange = this.handleLlmProviderChange.bind(this);\n this.handleSttProviderChange = this.handleSttProviderChange.bind(this);\n this.handleMessageFadeEnd = this.handleMessageFadeEnd.bind(this);\n this.handleModelKeyPress = this.handleModelKeyPress.bind(this);\n this.handleSttModelChange = this.handleSttModelChange.bind(this);\n this.handleBack = this.handleBack.bind(this);\n this.handleClose = this.handleClose.bind(this);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.dispatchEvent(new CustomEvent('content-changed', { bubbles: true, composed: true }));\n }\n\n reset() {\n this.apiKey = '';\n this.isLoading = false;\n this.errorMessage = '';\n this.validatedApiKey = null;\n this.selectedProvider = 'openai';\n this.requestUpdate();\n }\n\n handleBack() {\n if (this.backCallback) {\n this.backCallback();\n }\n }\n\n async loadProviderConfig() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n const [config, ollamaStatus] = await Promise.all([\n window.api.apiKeyHeader.getProviderConfig(),\n window.api.apiKeyHeader.getOllamaStatus(),\n ]);\n\n const llmProviders = [];\n const sttProviders = [];\n\n for (const id in config) {\n // 'openai-glass' 같은 가상 Provider는 UI에 표시하지 않음\n if (id.includes('-glass')) continue;\n const hasLlmModels = config[id].llmModels.length > 0 || id === 'ollama';\n const hasSttModels = config[id].sttModels.length > 0 || id === 'whisper';\n\n if (hasLlmModels) {\n llmProviders.push({ id, name: config[id].name });\n }\n if (hasSttModels) {\n sttProviders.push({ id, name: config[id].name });\n }\n }\n\n this.providers = { llm: llmProviders, stt: sttProviders };\n\n // 기본 선택 값 설정\n if (llmProviders.length > 0) this.llmProvider = llmProviders[0].id;\n if (sttProviders.length > 0) this.sttProvider = sttProviders[0].id;\n\n // Ollama 상태 및 모델 제안 로드\n if (ollamaStatus?.success) {\n this.ollamaStatus = {\n installed: ollamaStatus.installed,\n running: ollamaStatus.running,\n };\n\n // Load model suggestions if Ollama is running\n if (ollamaStatus.running) {\n await this.loadModelSuggestions();\n }\n }\n\n this.requestUpdate();\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load provider config:', error);\n }\n }\n\n async handleMouseDown(e) {\n if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON' || e.target.tagName === 'SELECT') {\n return;\n }\n\n e.preventDefault();\n\n if (!window.api?.apiKeyHeader) return;\n const initialPosition = await window.api.apiKeyHeader.getHeaderPosition();\n\n this.dragState = {\n initialMouseX: e.screenX,\n initialMouseY: e.screenY,\n initialWindowX: initialPosition.x,\n initialWindowY: initialPosition.y,\n moved: false,\n };\n\n window.addEventListener('mousemove', this.handleMouseMove);\n window.addEventListener('mouseup', this.handleMouseUp, { once: true });\n }\n\n handleMouseMove(e) {\n if (!this.dragState) return;\n\n const deltaX = Math.abs(e.screenX - this.dragState.initialMouseX);\n const deltaY = Math.abs(e.screenY - this.dragState.initialMouseY);\n\n if (deltaX > 3 || deltaY > 3) {\n this.dragState.moved = true;\n }\n\n const newWindowX = this.dragState.initialWindowX + (e.screenX - this.dragState.initialMouseX);\n const newWindowY = this.dragState.initialWindowY + (e.screenY - this.dragState.initialMouseY);\n\n if (window.api?.apiKeyHeader) {\n window.api.apiKeyHeader.moveHeaderTo(newWindowX, newWindowY);\n }\n }\n\n handleMouseUp(e) {\n if (!this.dragState) return;\n\n const wasDragged = this.dragState.moved;\n\n window.removeEventListener('mousemove', this.handleMouseMove);\n this.dragState = null;\n\n if (wasDragged) {\n this.wasJustDragged = true;\n setTimeout(() => {\n this.wasJustDragged = false;\n }, 200);\n }\n }\n\n handleInput(e) {\n this.apiKey = e.target.value;\n this.clearMessages();\n console.log('Input changed:', this.apiKey?.length || 0, 'chars');\n\n this.requestUpdate();\n this.updateComplete.then(() => {\n const inputField = this.shadowRoot?.querySelector('.apikey-input');\n if (inputField && this.isInputFocused) {\n inputField.focus();\n }\n });\n }\n\n clearMessages() {\n this.errorMessage = '';\n this.successMessage = '';\n this.messageTimestamp = 0;\n this.llmError = '';\n this.sttError = '';\n }\n\n handleProviderChange(e) {\n this.selectedProvider = e.target.value;\n this.clearMessages();\n console.log('Provider changed to:', this.selectedProvider);\n this.requestUpdate();\n }\n\n async handleLlmProviderChange(e, providerId) {\n const newProvider = providerId || e.target.value;\n if (newProvider === this.llmProvider) return;\n\n // Cancel any active operations first\n this._cancelAllActiveOperations();\n\n this.llmProvider = newProvider;\n this.errorMessage = '';\n this.successMessage = '';\n\n if (['openai', 'gemini'].includes(this.llmProvider)) {\n this.sttProvider = this.llmProvider;\n }\n\n // Reset retry state\n this.retryCount = 0;\n\n if (this.llmProvider === 'ollama') {\n console.log('[ApiKeyHeader] Ollama selected, initiating connection...');\n await this._initializeOllamaConnection();\n // Start health monitoring for Ollama\n this._startHealthMonitoring();\n } else {\n this._updateConnectionState('idle', 'Non-Ollama provider selected');\n // Stop health monitoring for non-Ollama providers\n this._stopHealthMonitoring();\n }\n\n this.requestUpdate();\n }\n\n async _initializeOllamaConnection() {\n try {\n // Progressive connection attempt with exponential backoff\n await this._attemptOllamaConnection();\n } catch (error) {\n console.error('[ApiKeyHeader] Initial Ollama connection failed:', error.message);\n\n if (this.retryCount < this.maxRetries) {\n const delay = this.baseRetryDelay * Math.pow(2, this.retryCount);\n console.log(`[ApiKeyHeader] Retrying Ollama connection in ${delay}ms (attempt ${this.retryCount + 1}/${this.maxRetries})`);\n\n this.retryCount++;\n\n // Use proper Promise-based delay instead of setTimeout\n await new Promise(resolve => {\n const retryTimeoutId = setTimeout(() => {\n this._initializeOllamaConnection();\n resolve();\n }, delay);\n\n // Store timeout for cleanup\n this.operationTimeouts.set(`retry_${this.retryCount}`, retryTimeoutId);\n });\n } else {\n this._updateConnectionState('failed', `Connection failed after ${this.maxRetries} attempts`);\n }\n }\n }\n\n async _attemptOllamaConnection() {\n await this.refreshOllamaStatus();\n }\n\n _cancelAllActiveOperations() {\n console.log(`[ApiKeyHeader] Cancelling ${this.activeOperations.size} active operations and ${this.operationQueue.length} queued operations`);\n\n // Cancel active operations\n for (const [operationType, operation] of this.activeOperations) {\n this._cancelOperation(operationType);\n }\n\n // Cancel queued operations\n for (const queuedOp of this.operationQueue) {\n queuedOp.reject(new Error(`Operation ${queuedOp.type} cancelled during cleanup`));\n }\n this.operationQueue.length = 0;\n\n // Clean up all timeouts\n for (const [timeoutId, timeout] of this.operationTimeouts) {\n clearTimeout(timeout);\n }\n this.operationTimeouts.clear();\n }\n\n /**\n * Get operation metrics for monitoring\n */\n getOperationMetrics() {\n return {\n ...this.operationMetrics,\n activeOperations: this.activeOperations.size,\n queuedOperations: this.operationQueue.length,\n successRate:\n this.operationMetrics.totalOperations > 0\n ? (this.operationMetrics.successfulOperations / this.operationMetrics.totalOperations) * 100\n : 0,\n };\n }\n\n /**\n * Adaptive backpressure based on system performance\n */\n _adjustBackpressureThresholds() {\n const metrics = this.getOperationMetrics();\n\n // Reduce concurrent operations if success rate is low\n if (metrics.successRate < 70 && this.maxConcurrentOperations > 1) {\n this.maxConcurrentOperations = Math.max(1, this.maxConcurrentOperations - 1);\n console.log(\n `[ApiKeyHeader] Reduced max concurrent operations to ${this.maxConcurrentOperations} (success rate: ${metrics.successRate.toFixed(1)}%)`\n );\n }\n\n // Increase if performance is good\n if (metrics.successRate > 90 && metrics.averageResponseTime < 3000 && this.maxConcurrentOperations < 3) {\n this.maxConcurrentOperations++;\n console.log(`[ApiKeyHeader] Increased max concurrent operations to ${this.maxConcurrentOperations}`);\n }\n }\n\n /**\n * Professional health monitoring system\n */\n _startHealthMonitoring() {\n if (this.healthCheck.enabled) return;\n\n this.healthCheck.enabled = true;\n this.healthCheck.intervalId = setInterval(() => {\n this._performHealthCheck();\n }, this.healthCheck.intervalMs);\n\n console.log(`[ApiKeyHeader] Health monitoring started (interval: ${this.healthCheck.intervalMs}ms)`);\n }\n\n _stopHealthMonitoring() {\n if (!this.healthCheck.enabled) return;\n\n this.healthCheck.enabled = false;\n if (this.healthCheck.intervalId) {\n clearInterval(this.healthCheck.intervalId);\n this.healthCheck.intervalId = null;\n }\n\n console.log('[ApiKeyHeader] Health monitoring stopped');\n }\n\n async _performHealthCheck() {\n // Only perform health check if Ollama is selected and we're in a stable state\n if (this.llmProvider !== 'ollama' || this.connectionState === 'connecting') {\n return;\n }\n\n const now = Date.now();\n this.healthCheck.lastCheck = now;\n\n try {\n // Lightweight health check - just ping the service\n const isHealthy = await this._executeOperation(\n 'health_check',\n async () => {\n if (!window.api?.apiKeyHeader) return false;\n const result = await window.api.apiKeyHeader.getOllamaStatus();\n return result?.success && result?.running;\n },\n { timeout: 5000, priority: 'low' }\n );\n\n if (isHealthy) {\n this.healthCheck.consecutiveFailures = 0;\n\n // Update state if we were previously failed\n if (this.connectionState === 'failed') {\n this._updateConnectionState('connected', 'Health check recovered');\n }\n } else {\n this._handleHealthCheckFailure();\n }\n\n // Adjust thresholds based on performance\n this._adjustBackpressureThresholds();\n } catch (error) {\n console.warn('[ApiKeyHeader] Health check failed:', error.message);\n this._handleHealthCheckFailure();\n }\n }\n\n _handleHealthCheckFailure() {\n this.healthCheck.consecutiveFailures++;\n\n if (this.healthCheck.consecutiveFailures >= this.healthCheck.maxFailures) {\n console.warn(`[ApiKeyHeader] Health check failed ${this.healthCheck.consecutiveFailures} times, marking as disconnected`);\n this._updateConnectionState('failed', 'Service health check failed');\n\n // Increase health check frequency when having issues\n this.healthCheck.intervalMs = Math.max(10000, this.healthCheck.intervalMs / 2);\n this._restartHealthMonitoring();\n }\n }\n\n _restartHealthMonitoring() {\n this._stopHealthMonitoring();\n this._startHealthMonitoring();\n }\n\n /**\n * Get comprehensive health status\n */\n getHealthStatus() {\n return {\n connection: {\n state: this.connectionState,\n lastStateChange: this.lastStateChange,\n timeSinceLastChange: Date.now() - this.lastStateChange,\n },\n operations: this.getOperationMetrics(),\n health: {\n enabled: this.healthCheck.enabled,\n lastCheck: this.healthCheck.lastCheck,\n timeSinceLastCheck: this.healthCheck.lastCheck > 0 ? Date.now() - this.healthCheck.lastCheck : null,\n consecutiveFailures: this.healthCheck.consecutiveFailures,\n intervalMs: this.healthCheck.intervalMs,\n },\n ollama: {\n provider: this.llmProvider,\n status: this.ollamaStatus,\n selectedModel: this.selectedLlmModel,\n },\n };\n }\n\n async handleSttProviderChange(e, providerId) {\n const newProvider = providerId || e.target.value;\n if (newProvider === this.sttProvider) return;\n\n this.sttProvider = newProvider;\n this.errorMessage = '';\n this.successMessage = '';\n\n if (this.sttProvider === 'ollama') {\n console.warn('[ApiKeyHeader] Ollama does not support STT yet. Please select Whisper or another provider.');\n this.sttError = '*Ollama does not support STT yet. Please select Whisper or another STT provider.';\n this.messageTimestamp = Date.now();\n\n // Auto-select Whisper if available\n const whisperProvider = this.providers.stt.find(p => p.id === 'whisper');\n if (whisperProvider) {\n this.sttProvider = 'whisper';\n console.log('[ApiKeyHeader] Auto-selected Whisper for STT');\n }\n }\n\n this.requestUpdate();\n }\n\n /**\n * Professional operation management with backpressure control\n */\n async _executeOperation(operationType, operation, options = {}) {\n const operationId = `${operationType}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n const timeout = options.timeout || this.ipcTimeout;\n const priority = options.priority || 'normal'; // high, normal, low\n\n // Backpressure control\n if (this.activeOperations.size >= this.maxConcurrentOperations) {\n if (this.operationQueue.length >= this.maxQueueSize) {\n throw new Error(`Operation queue full (${this.maxQueueSize}), rejecting ${operationType}`);\n }\n\n console.log(`[ApiKeyHeader] Queuing operation ${operationType} (${this.activeOperations.size} active)`);\n return this._queueOperation(operationId, operationType, operation, options);\n }\n\n return this._executeImmediately(operationId, operationType, operation, timeout);\n }\n\n async _queueOperation(operationId, operationType, operation, options) {\n return new Promise((resolve, reject) => {\n const queuedOperation = {\n id: operationId,\n type: operationType,\n operation,\n options,\n resolve,\n reject,\n queuedAt: Date.now(),\n priority: options.priority || 'normal',\n };\n\n // Insert based on priority (high priority first)\n if (options.priority === 'high') {\n this.operationQueue.unshift(queuedOperation);\n } else {\n this.operationQueue.push(queuedOperation);\n }\n\n console.log(`[ApiKeyHeader] Queued ${operationType} (queue size: ${this.operationQueue.length})`);\n });\n }\n\n async _executeImmediately(operationId, operationType, operation, timeout) {\n const startTime = Date.now();\n this.operationMetrics.totalOperations++;\n\n // Check if similar operation is already running\n if (this.activeOperations.has(operationType)) {\n console.log(`[ApiKeyHeader] Operation ${operationType} already in progress, cancelling previous`);\n this._cancelOperation(operationType);\n }\n\n // Create cancellation mechanism\n const cancellationPromise = new Promise((_, reject) => {\n const timeoutId = setTimeout(() => {\n this.operationMetrics.timeouts++;\n reject(new Error(`Operation ${operationType} timeout after ${timeout}ms`));\n }, timeout);\n\n this.operationTimeouts.set(operationId, timeoutId);\n });\n\n const operationPromise = Promise.race([operation(), cancellationPromise]);\n\n this.activeOperations.set(operationType, {\n id: operationId,\n promise: operationPromise,\n startTime,\n });\n\n try {\n const result = await operationPromise;\n this._recordOperationSuccess(startTime);\n return result;\n } catch (error) {\n this._recordOperationFailure(error, operationType);\n throw error;\n } finally {\n this._cleanupOperation(operationId, operationType);\n this._processQueue();\n }\n }\n\n _recordOperationSuccess(startTime) {\n this.operationMetrics.successfulOperations++;\n const responseTime = Date.now() - startTime;\n this._updateAverageResponseTime(responseTime);\n }\n\n _recordOperationFailure(error, operationType) {\n this.operationMetrics.failedOperations++;\n\n if (error.message.includes('timeout')) {\n console.error(`[ApiKeyHeader] Operation ${operationType} timed out`);\n this._updateConnectionState('failed', `Timeout: ${error.message}`);\n }\n }\n\n _updateAverageResponseTime(responseTime) {\n const totalOps = this.operationMetrics.successfulOperations;\n this.operationMetrics.averageResponseTime = (this.operationMetrics.averageResponseTime * (totalOps - 1) + responseTime) / totalOps;\n }\n\n async _processQueue() {\n if (this.operationQueue.length === 0 || this.activeOperations.size >= this.maxConcurrentOperations) {\n return;\n }\n\n const queuedOp = this.operationQueue.shift();\n if (!queuedOp) return;\n\n const queueTime = Date.now() - queuedOp.queuedAt;\n console.log(`[ApiKeyHeader] Processing queued operation ${queuedOp.type} (waited ${queueTime}ms)`);\n\n try {\n const result = await this._executeImmediately(\n queuedOp.id,\n queuedOp.type,\n queuedOp.operation,\n queuedOp.options.timeout || this.ipcTimeout\n );\n queuedOp.resolve(result);\n } catch (error) {\n queuedOp.reject(error);\n }\n }\n\n _cancelOperation(operationType) {\n const operation = this.activeOperations.get(operationType);\n if (operation) {\n this._cleanupOperation(operation.id, operationType);\n console.log(`[ApiKeyHeader] Cancelled operation: ${operationType}`);\n }\n }\n\n _cleanupOperation(operationId, operationType) {\n if (this.operationTimeouts.has(operationId)) {\n clearTimeout(this.operationTimeouts.get(operationId));\n this.operationTimeouts.delete(operationId);\n }\n this.activeOperations.delete(operationType);\n }\n\n _updateConnectionState(newState, reason = '') {\n if (this.connectionState !== newState) {\n console.log(`[ApiKeyHeader] Connection state: ${this.connectionState} -> ${newState} (${reason})`);\n this.connectionState = newState;\n this.lastStateChange = Date.now();\n\n // Update UI based on state\n this._handleStateChange(newState, reason);\n }\n }\n\n _handleStateChange(state, reason) {\n switch (state) {\n case 'connecting':\n this.installingModel = 'Connecting to Ollama...';\n this.installProgress = 10;\n break;\n case 'failed':\n this.errorMessage = reason || 'Connection failed';\n this.installingModel = null;\n this.installProgress = 0;\n this.messageTimestamp = Date.now();\n break;\n case 'connected':\n this.installingModel = null;\n this.installProgress = 0;\n break;\n case 'disconnected':\n this.ollamaStatus = { installed: false, running: false };\n break;\n }\n this.requestUpdate();\n }\n\n async refreshOllamaStatus() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n this._updateConnectionState('connecting', 'Checking Ollama status');\n\n const result = await this._executeOperation('ollama_status', async () => {\n return await window.api.apiKeyHeader.getOllamaStatus();\n });\n\n if (result?.success) {\n this.ollamaStatus = {\n installed: result.installed,\n running: result.running,\n };\n\n this._updateConnectionState('connected', 'Status updated successfully');\n\n // Load model suggestions if Ollama is running\n if (result.running) {\n await this.loadModelSuggestions();\n }\n } else {\n this._updateConnectionState('failed', result?.error || 'Status check failed');\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to refresh Ollama status:', error.message);\n this._updateConnectionState('failed', error.message);\n }\n }\n\n async loadModelSuggestions() {\n if (!window.api?.apiKeyHeader) return;\n\n try {\n const result = await this._executeOperation('model_suggestions', async () => {\n return await window.api.apiKeyHeader.getModelSuggestions();\n });\n\n if (result?.success) {\n this.modelSuggestions = result.suggestions || [];\n\n // 기본 모델 선택 (설치된 모델 중 첫 번째)\n if (!this.selectedLlmModel && this.modelSuggestions.length > 0) {\n const installedModel = this.modelSuggestions.find(m => m.status === 'installed');\n if (installedModel) {\n this.selectedLlmModel = installedModel.name;\n }\n }\n this.requestUpdate();\n } else {\n console.warn('[ApiKeyHeader] Model suggestions request unsuccessful:', result?.error);\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load model suggestions:', error.message);\n }\n }\n\n async ensureOllamaReady() {\n if (!window.api?.apiKeyHeader) return false;\n\n try {\n this._updateConnectionState('connecting', 'Ensuring Ollama is ready');\n\n const result = await this._executeOperation(\n 'ollama_ensure_ready',\n async () => {\n return await window.api.apiKeyHeader.ensureOllamaReady();\n },\n { timeout: this.operationTimeout }\n );\n\n if (result?.success) {\n await this.refreshOllamaStatus();\n this._updateConnectionState('connected', 'Ollama ready');\n return true;\n } else {\n const errorMsg = `Failed to setup Ollama: ${result?.error || 'Unknown error'}`;\n this._updateConnectionState('failed', errorMsg);\n return false;\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to ensure Ollama ready:', error.message);\n this._updateConnectionState('failed', `Error setting up Ollama: ${error.message}`);\n return false;\n }\n }\n\n async ensureOllamaReadyWithUI() {\n if (!window.api?.apiKeyHeader) return false;\n\n this.installingModel = 'Setting up Ollama';\n this.installProgress = 0;\n this.clearMessages();\n this.requestUpdate();\n\n const progressHandler = (event, data) => {\n // 통합 LocalAI 이벤트에서 Ollama 진행률만 처리\n if (data.service !== 'ollama') return;\n \n let baseProgress = 0;\n let stageTotal = 0;\n\n switch (data.stage) {\n case 'downloading':\n baseProgress = 0;\n stageTotal = 70;\n break;\n case 'mounting':\n baseProgress = 70;\n stageTotal = 10;\n break;\n case 'installing':\n baseProgress = 80;\n stageTotal = 10;\n break;\n case 'linking':\n baseProgress = 90;\n stageTotal = 5;\n break;\n case 'cleanup':\n baseProgress = 95;\n stageTotal = 3;\n break;\n case 'starting':\n baseProgress = 98;\n stageTotal = 2;\n break;\n }\n\n const overallProgress = baseProgress + (data.progress / 100) * stageTotal;\n\n this.installingModel = data.message;\n this.installProgress = Math.round(overallProgress);\n this.requestUpdate();\n };\n\n let operationCompleted = false;\n const completionTimeout = setTimeout(async () => {\n if (!operationCompleted) {\n console.log('[ApiKeyHeader] Operation timeout, checking status manually...');\n await this._handleOllamaSetupCompletion(true);\n }\n }, 15000); // 15 second timeout\n\n const completionHandler = async (event, data) => {\n // 통합 LocalAI 이벤트에서 Ollama 완료만 처리\n if (data.service !== 'ollama') return;\n if (operationCompleted) return;\n operationCompleted = true;\n clearTimeout(completionTimeout);\n\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n // installation-complete 이벤트는 성공을 의미\n await this._handleOllamaSetupCompletion(true);\n };\n\n // 통합 LocalAI 이벤트 사용\n window.api.apiKeyHeader.onLocalAIComplete(completionHandler);\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n try {\n let result;\n if (!this.ollamaStatus.installed) {\n console.log('[ApiKeyHeader] Ollama not installed. Starting installation.');\n result = await window.api.apiKeyHeader.installOllama();\n } else {\n console.log('[ApiKeyHeader] Ollama installed. Starting service.');\n result = await window.api.apiKeyHeader.startOllamaService();\n }\n\n // If IPC call succeeds but no event received, handle completion manually\n if (result?.success && !operationCompleted) {\n setTimeout(async () => {\n if (!operationCompleted) {\n operationCompleted = true;\n clearTimeout(completionTimeout);\n await this._handleOllamaSetupCompletion(true);\n }\n }, 2000);\n }\n } catch (error) {\n operationCompleted = true;\n clearTimeout(completionTimeout);\n console.error('[ApiKeyHeader] Ollama setup failed:', error);\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n window.api.apiKeyHeader.removeOnLocalAIComplete(completionHandler);\n await this._handleOllamaSetupCompletion(false, error.message);\n }\n }\n\n async _handleOllamaSetupCompletion(success, errorMessage = null) {\n this.installingModel = null;\n this.installProgress = 0;\n\n if (success) {\n await this.refreshOllamaStatus();\n this.successMessage = '✓ Ollama is ready!';\n } else {\n this.llmError = `*Setup failed: ${errorMessage || 'Unknown error'}`;\n }\n this.messageTimestamp = Date.now();\n this.requestUpdate();\n }\n\n async handleModelInput(e) {\n const modelName = e.target.value.trim();\n this.selectedLlmModel = modelName;\n this.clearMessages();\n\n // Save to user history if it's a valid model name\n if (modelName && modelName.length > 2) {\n this.saveToUserHistory(modelName);\n }\n\n this.requestUpdate();\n }\n\n async handleModelKeyPress(e) {\n if (e.key === 'Enter' && this.selectedLlmModel?.trim()) {\n e.preventDefault();\n console.log(`[ApiKeyHeader] Enter pressed, installing model: ${this.selectedLlmModel}`);\n\n // Check if Ollama is ready first\n const ollamaReady = await this.ensureOllamaReady();\n if (!ollamaReady) {\n this.llmError = '*Failed to setup Ollama';\n this.messageTimestamp = Date.now();\n this.requestUpdate();\n return;\n }\n\n // Install the model\n await this.installModel(this.selectedLlmModel);\n }\n }\n\n loadUserModelHistory() {\n try {\n const saved = localStorage.getItem('ollama-model-history');\n if (saved) {\n this.userModelHistory = JSON.parse(saved);\n }\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to load model history:', error);\n this.userModelHistory = [];\n }\n }\n\n saveToUserHistory(modelName) {\n if (!modelName || !modelName.trim()) return;\n\n // Remove if already exists (to move to front)\n this.userModelHistory = this.userModelHistory.filter(m => m !== modelName);\n\n // Add to front\n this.userModelHistory.unshift(modelName);\n\n // Keep only last 20 entries\n this.userModelHistory = this.userModelHistory.slice(0, 20);\n\n // Save to localStorage\n try {\n localStorage.setItem('ollama-model-history', JSON.stringify(this.userModelHistory));\n } catch (error) {\n console.error('[ApiKeyHeader] Failed to save model history:', error);\n }\n }\n\n getCombinedModelSuggestions() {\n const combined = [];\n\n // Add installed models first (from Ollama CLI)\n for (const model of this.modelSuggestions) {\n combined.push({\n name: model.name,\n status: 'installed',\n size: model.size || 'Unknown',\n source: 'installed',\n });\n }\n\n // Add user history models that aren't already installed\n const installedNames = this.modelSuggestions.map(m => m.name);\n for (const modelName of this.userModelHistory) {\n if (!installedNames.includes(modelName)) {\n combined.push({\n name: modelName,\n status: 'history',\n size: 'Unknown',\n source: 'history',\n });\n }\n }\n\n return combined;\n }\n\n async installModel(modelName) {\n if (!modelName?.trim()) {\n throw new Error('Invalid model name');\n }\n\n this.installingModel = modelName;\n this.installProgress = 0;\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) return;\n let progressHandler = null;\n\n try {\n console.log(`[ApiKeyHeader] Installing model via Ollama REST API: ${modelName}`);\n\n // Create robust progress handler with timeout protection\n progressHandler = (event, data) => {\n if (data.service === 'ollama' && data.model === modelName && !this._isOperationCancelled(modelName)) {\n const progress = Math.round(Math.max(0, Math.min(100, data.progress || 0)));\n\n if (progress !== this.installProgress) {\n this.installProgress = progress;\n console.log(`[ApiKeyHeader] API Progress: ${progress}% for ${modelName} (${data.status || 'downloading'})`);\n this.requestUpdate();\n }\n }\n };\n\n // Set up progress tracking - 통합 LocalAI 이벤트 사용\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n // Execute the model pull with timeout\n const installPromise = window.api.apiKeyHeader.pullOllamaModel(modelName);\n const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Installation timeout after 10 minutes')), 600000));\n\n const result = await Promise.race([installPromise, timeoutPromise]);\n\n if (result.success) {\n console.log(`[ApiKeyHeader] Model ${modelName} installed successfully via API`);\n this.installProgress = 100;\n this.requestUpdate();\n\n // Brief pause to show completion\n await new Promise(resolve => setTimeout(resolve, 300));\n\n // Refresh status and show success\n await this.refreshOllamaStatus();\n this.successMessage = `✓ ${modelName} ready`;\n this.messageTimestamp = Date.now();\n } else {\n throw new Error(result.error || 'Installation failed');\n }\n } catch (error) {\n console.error(`[ApiKeyHeader] Model installation failed:`, error);\n this.llmError = `*Failed: ${error.message}`;\n this.messageTimestamp = Date.now();\n } finally {\n // Comprehensive cleanup\n if (progressHandler) {\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n }\n\n this.installingModel = null;\n this.installProgress = 0;\n this.requestUpdate();\n }\n }\n\n _isOperationCancelled(modelName) {\n return !this.installingModel || this.installingModel !== modelName;\n }\n\n async downloadWhisperModel(modelId) {\n if (!modelId?.trim()) {\n console.warn('[ApiKeyHeader] Invalid Whisper model ID');\n return;\n }\n\n console.log(`[ApiKeyHeader] Starting Whisper model download: ${modelId}`);\n\n // Mark as installing\n this.whisperInstallingModels = { ...this.whisperInstallingModels, [modelId]: 0 };\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) return;\n let progressHandler = null;\n\n try {\n // Set up robust progress listener - 통합 LocalAI 이벤트 사용\n progressHandler = (event, data) => {\n if (data.service === 'whisper' && data.model === modelId) {\n const cleanProgress = Math.round(Math.max(0, Math.min(100, data.progress || 0)));\n this.whisperInstallingModels = { ...this.whisperInstallingModels, [modelId]: cleanProgress };\n console.log(`[ApiKeyHeader] Whisper download progress: ${cleanProgress}% for ${modelId}`);\n this.requestUpdate();\n }\n };\n\n window.api.apiKeyHeader.onLocalAIProgress(progressHandler);\n\n // Start download with timeout protection\n const downloadPromise = window.api.apiKeyHeader.downloadWhisperModel(modelId);\n const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Download timeout after 10 minutes')), 600000));\n\n const result = await Promise.race([downloadPromise, timeoutPromise]);\n\n if (result?.success) {\n this.successMessage = `✓ ${modelId} downloaded successfully`;\n this.messageTimestamp = Date.now();\n console.log(`[ApiKeyHeader] Whisper model ${modelId} downloaded successfully`);\n\n // Auto-select the downloaded model\n this.selectedSttModel = modelId;\n } else {\n this.sttError = `*Failed to download ${modelId}: ${result?.error || 'Unknown error'}`;\n this.messageTimestamp = Date.now();\n console.error(`[ApiKeyHeader] Whisper download failed:`, result?.error);\n }\n } catch (error) {\n console.error(`[ApiKeyHeader] Error downloading Whisper model ${modelId}:`, error);\n this.sttError = `*Error downloading ${modelId}: ${error.message}`;\n this.messageTimestamp = Date.now();\n } finally {\n // Cleanup\n if (progressHandler) {\n window.api.apiKeyHeader.removeOnLocalAIProgress(progressHandler);\n }\n delete this.whisperInstallingModels[modelId];\n this.requestUpdate();\n }\n }\n\n handlePaste(e) {\n e.preventDefault();\n this.clearMessages();\n const clipboardText = (e.clipboardData || window.clipboardData).getData('text');\n console.log('Paste event detected:', clipboardText?.substring(0, 10) + '...');\n\n if (clipboardText) {\n this.apiKey = clipboardText.trim();\n\n const inputElement = e.target;\n inputElement.value = this.apiKey;\n }\n\n this.requestUpdate();\n this.updateComplete.then(() => {\n const inputField = this.shadowRoot?.querySelector('.apikey-input');\n if (inputField) {\n inputField.focus();\n inputField.setSelectionRange(inputField.value.length, inputField.value.length);\n }\n });\n }\n\n handleKeyPress(e) {\n if (e.key === 'Enter') {\n e.preventDefault();\n this.handleSubmit();\n }\n }\n\n //////// after_modelStateService ////////\n async handleSttModelChange(e) {\n const modelId = e.target.value;\n this.selectedSttModel = modelId;\n\n if (modelId && this.sttProvider === 'whisper') {\n // Check if model needs to be downloaded\n const isInstalling = this.whisperInstallingModels[modelId] !== undefined;\n if (!isInstalling) {\n console.log(`[ApiKeyHeader] Auto-installing Whisper model: ${modelId}`);\n await this.downloadWhisperModel(modelId);\n }\n }\n\n this.requestUpdate();\n }\n\n async handleSubmit() {\n console.log('[ApiKeyHeader] handleSubmit: Submitting...');\n\n this.isLoading = true;\n this.clearMessages();\n this.requestUpdate();\n\n if (!window.api?.apiKeyHeader) {\n this.isLoading = false;\n this.llmError = '*API bridge not available';\n this.requestUpdate();\n return;\n }\n\n try {\n // Handle LLM provider\n let llmResult;\n if (this.llmProvider === 'ollama') {\n // For Ollama ensure it's ready and validate model selection\n if (!this.selectedLlmModel?.trim()) {\n throw new Error('Please enter an Ollama model name');\n }\n\n const ollamaReady = await this.ensureOllamaReady();\n if (!ollamaReady) {\n throw new Error('Failed to setup Ollama');\n }\n\n // Check if model is installed, if not install it\n const selectedModel = this.getCombinedModelSuggestions().find(m => m.name === this.selectedLlmModel);\n if (!selectedModel || selectedModel.status !== 'installed') {\n console.log(`[ApiKeyHeader] Installing model ${this.selectedLlmModel}...`);\n await this.installModel(this.selectedLlmModel);\n }\n\n // Validate Ollama is working\n llmResult = await window.api.apiKeyHeader.validateKey({\n provider: 'ollama',\n key: 'local',\n });\n\n if (llmResult.success) {\n // Set the selected model\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'llm',\n modelId: this.selectedLlmModel,\n });\n }\n } else {\n // For other providers, validate API key\n if (!this.llmApiKey.trim()) {\n throw new Error('Please enter LLM API key');\n }\n\n llmResult = await window.api.apiKeyHeader.validateKey({\n provider: this.llmProvider,\n key: this.llmApiKey.trim(),\n });\n\n if (llmResult.success) {\n const config = await window.api.apiKeyHeader.getProviderConfig();\n const providerConfig = config[this.llmProvider];\n if (providerConfig && providerConfig.llmModels.length > 0) {\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'llm',\n modelId: providerConfig.llmModels[0].id,\n });\n }\n }\n }\n\n // Handle STT provider\n let sttResult;\n if (this.sttProvider === 'ollama') {\n // Ollama doesn't support STT yet, so skip or use same as LLM validation\n sttResult = { success: true };\n } else if (this.sttProvider === 'whisper') {\n // For Whisper, just validate it's enabled (model download already handled in handleSttModelChange)\n sttResult = await window.api.apiKeyHeader.validateKey({\n provider: 'whisper',\n key: 'local',\n });\n\n if (sttResult.success && this.selectedSttModel) {\n // Set the selected model\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'stt',\n modelId: this.selectedSttModel,\n });\n }\n } else {\n // For other providers, validate API key\n if (!this.sttApiKey.trim()) {\n throw new Error('Please enter STT API key');\n }\n\n sttResult = await window.api.apiKeyHeader.validateKey({\n provider: this.sttProvider,\n key: this.sttApiKey.trim(),\n });\n\n if (sttResult.success) {\n const config = await window.api.apiKeyHeader.getProviderConfig();\n const providerConfig = config[this.sttProvider];\n if (providerConfig && providerConfig.sttModels.length > 0) {\n await window.api.apiKeyHeader.setSelectedModel({\n type: 'stt',\n modelId: providerConfig.sttModels[0].id,\n });\n }\n }\n }\n\n if (llmResult.success && sttResult.success) {\n console.log('[ApiKeyHeader] handleSubmit: Validation successful.');\n \n // Force refresh the model state to ensure areProvidersConfigured returns true\n setTimeout(async () => {\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n console.log('[ApiKeyHeader] Post-validation providers configured check:', isConfigured);\n \n if (isConfigured) {\n this.startSlideOutAnimation();\n } else {\n console.error('[ApiKeyHeader] Providers still not configured after successful validation');\n this.llmError = '*Configuration error. Please try again.';\n this.isLoading = false;\n this.requestUpdate();\n }\n }, 100);\n } else {\n this.llmError = !llmResult.success ? `*${llmResult.error || 'Invalid API Key'}` : '';\n this.sttError = !sttResult.success ? `*${sttResult.error || 'Invalid'}` : '';\n this.errorMessage = ''; // Do not use the general error message for this\n this.messageTimestamp = Date.now();\n }\n } catch (error) {\n console.error('[ApiKeyHeader] handleSubmit: Error:', error);\n this.llmError = `*${error.message}`;\n this.messageTimestamp = Date.now();\n }\n\n this.isLoading = false;\n this.requestUpdate();\n }\n //////// after_modelStateService ////////\n\n\n ////TODO: 뭔가 넘어가는 애니메이션 로직에 문제가 있음\n startSlideOutAnimation() {\n console.log('[ApiKeyHeader] startSlideOutAnimation: Starting slide out animation.');\n this.classList.add('sliding-out');\n \n // Fallback: if animation doesn't trigger animationend event, force transition\n setTimeout(() => {\n if (this.classList.contains('sliding-out')) {\n console.log('[ApiKeyHeader] Animation fallback triggered - forcing transition');\n this.handleAnimationEnd({ target: this, animationName: 'slideOut' });\n }\n }, 1); // Wait a bit longer than animation duration\n }\n\n handleClose() {\n if (window.api?.common) {\n window.api.common.quitApplication();\n }\n }\n\n //////// after_modelStateService ////////\n handleAnimationEnd(e) {\n if (e.target !== this || !this.classList.contains('sliding-out')) return;\n this.classList.remove('sliding-out');\n this.classList.add('hidden');\n\n console.log('[ApiKeyHeader] handleAnimationEnd: Animation completed, transitioning to next state...');\n\n if (!window.api?.common) {\n console.error('[ApiKeyHeader] handleAnimationEnd: window.api.common not available');\n return;\n }\n\n if (!this.stateUpdateCallback) {\n console.error('[ApiKeyHeader] handleAnimationEnd: stateUpdateCallback not set! This will prevent transition to main window.');\n return;\n }\n\n window.api.common\n .getCurrentUser()\n .then(userState => {\n console.log('[ApiKeyHeader] handleAnimationEnd: User state retrieved:', userState);\n\n // Additional validation for local providers\n return window.api.apiKeyHeader.areProvidersConfigured().then(isConfigured => {\n console.log('[ApiKeyHeader] handleAnimationEnd: Providers configured check:', isConfigured);\n\n if (!isConfigured) {\n console.warn('[ApiKeyHeader] handleAnimationEnd: Providers still not configured, may return to ApiKey screen');\n }\n\n // Call the state update callback\n this.stateUpdateCallback(userState);\n });\n })\n .catch(error => {\n console.error('[ApiKeyHeader] handleAnimationEnd: Error during state transition:', error);\n\n // Fallback: try to call callback with minimal state\n if (this.stateUpdateCallback) {\n console.log('[ApiKeyHeader] handleAnimationEnd: Attempting fallback state transition...');\n this.stateUpdateCallback({ isLoggedIn: false });\n }\n });\n }\n //////// after_modelStateService ////////\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('animationend', this.handleAnimationEnd);\n }\n\n handleMessageFadeEnd(e) {\n if (e.animationName === 'fadeOut') {\n // Clear the message that finished fading\n if (e.target.classList.contains('error-message')) {\n this.errorMessage = '';\n } else if (e.target.classList.contains('success-message')) {\n this.successMessage = '';\n }\n this.messageTimestamp = 0;\n this.requestUpdate();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('animationend', this.handleAnimationEnd);\n\n // Professional cleanup of all resources\n this._performCompleteCleanup();\n }\n\n _performCompleteCleanup() {\n console.log('[ApiKeyHeader] Performing complete cleanup');\n\n // Stop health monitoring\n this._stopHealthMonitoring();\n\n // Cancel all active operations\n this._cancelAllActiveOperations();\n\n // Cancel any ongoing installations when component is destroyed\n if (this.installingModel) {\n this.progressTracker.cancelInstallation(this.installingModel);\n }\n\n // Cleanup event listeners\n if (window.api?.apiKeyHeader) {\n window.api.apiKeyHeader.removeAllListeners();\n }\n\n // Cancel any ongoing downloads\n const downloadingModels = Object.keys(this.whisperInstallingModels);\n if (downloadingModels.length > 0) {\n console.log(`[ApiKeyHeader] Cancelling ${downloadingModels.length} ongoing Whisper downloads`);\n downloadingModels.forEach(modelId => {\n delete this.whisperInstallingModels[modelId];\n });\n }\n\n // Reset state\n this.connectionState = 'disconnected';\n this.retryCount = 0;\n\n console.log('[ApiKeyHeader] Cleanup completed');\n }\n\n /**\n * State machine-based Ollama UI rendering\n */\n _renderOllamaStateUI() {\n const state = this._getOllamaUIState();\n\n switch (state.type) {\n case 'connecting':\n return this._renderConnectingState(state);\n case 'install_required':\n return this._renderInstallRequiredState();\n case 'start_required':\n return this._renderStartRequiredState();\n case 'ready':\n return this._renderReadyState();\n case 'failed':\n return this._renderFailedState(state);\n case 'installing':\n return this._renderInstallingState(state);\n default:\n return this._renderUnknownState();\n }\n }\n\n _getOllamaUIState() {\n // State determination logic\n if (this.connectionState === 'connecting') {\n return { type: 'connecting', message: this.installingModel || 'Connecting to Ollama...' };\n }\n\n if (this.connectionState === 'failed') {\n return { type: 'failed', message: this.errorMessage };\n }\n\n if (this.installingModel && this.installingModel.includes('Ollama')) {\n return { type: 'installing', progress: this.installProgress };\n }\n\n if (!this.ollamaStatus.installed) {\n return { type: 'install_required' };\n }\n\n if (!this.ollamaStatus.running) {\n return { type: 'start_required' };\n }\n\n return { type: 'ready' };\n }\n\n _renderConnectingState(state) {\n return html`\n
\n
\n
\n
\n
\n ${this.installProgress}%\n
\n
\n `;\n }\n\n _renderInstallRequiredState() {\n return html` `;\n }\n\n _renderStartRequiredState() {\n return html` `;\n }\n\n _renderReadyState() {\n return html`\n \n \n \n ${this.getCombinedModelSuggestions().map(\n model => html`\n \n `\n )}\n \n\n \n ${this.renderModelStatus()}\n ${this.installingModel && !this.installingModel.includes('Ollama')\n ? html`\n
\n
\n
\n
\n
\n ${this.installProgress}%\n
\n \n `\n : ''}\n `;\n }\n\n _renderFailedState(state) {\n return html`\n
\n
Connection failed
\n
\n ${state.message || 'Unknown error'}\n
\n this._initializeOllamaConnection()}\n >\n Retry Connection\n \n
\n `;\n }\n\n _renderInstallingState(state) {\n return html`\n
\n
\n
\n
\n
\n ${state.progress}%\n
\n
\n `;\n }\n\n _renderUnknownState() {\n return html`\n
\n
Unknown state - Please refresh
\n
\n `;\n }\n\n renderModelStatus() {\n return '';\n }\n\n shouldFadeMessage(type) {\n const hasMessage = type === 'error' ? this.errorMessage : this.successMessage;\n return hasMessage && this.messageTimestamp > 0 && Date.now() - this.messageTimestamp > 100;\n }\n\n openPrivacyPolicy() {\n console.log('🔊 openPrivacyPolicy ApiKeyHeader');\n if (window.api?.common) {\n window.api.common.openExternal('https://pickle.com/privacy-policy');\n }\n }\n\n render() {\n const llmNeedsApiKey = this.llmProvider !== 'ollama' && this.llmProvider !== 'whisper';\n const sttNeedsApiKey = this.sttProvider !== 'ollama' && this.sttProvider !== 'whisper';\n const llmNeedsModel = this.llmProvider === 'ollama';\n const sttNeedsModel = this.sttProvider === 'whisper';\n\n const isButtonDisabled =\n this.isLoading ||\n this.installingModel ||\n Object.keys(this.whisperInstallingModels).length > 0 ||\n (llmNeedsApiKey && !this.llmApiKey.trim()) ||\n (sttNeedsApiKey && !this.sttApiKey.trim()) ||\n (llmNeedsModel && !this.selectedLlmModel?.trim()) ||\n (sttNeedsModel && !this.selectedSttModel);\n\n const llmProviderName = this.providers.llm.find(p => p.id === this.llmProvider)?.name || this.llmProvider;\n\n return html`\n
\n \n
\n
\n \n
Back
\n
\n
Use Personal API keys
\n
\n\n \n
\n
\n
1. Select LLM Provider
\n
\n ${this.providers.llm.map(\n p => html`\n this.handleLlmProviderChange(e, p.id)}\n >\n ${p.name}\n \n `\n )}\n
\n
\n
\n
2. Enter API Key
\n ${this.llmProvider === 'ollama'\n ? this._renderOllamaStateUI()\n : html`\n
\n {\n this.llmApiKey = e.target.value;\n this.llmError = '';\n }}\n ?disabled=${this.isLoading}\n />\n ${this.llmError ? html`
${this.llmError}
` : ''}\n
\n `}\n
\n
\n\n \n
\n
\n
3. Select STT Provider
\n
\n ${this.providers.stt.map(\n p => html`\n this.handleSttProviderChange(e, p.id)}\n >\n ${p.name}\n \n `\n )}\n
\n
\n
\n
4. Enter STT API Key
\n ${this.sttProvider === 'ollama'\n ? html`\n
\n STT not supported by Ollama\n
\n `\n : this.sttProvider === 'whisper'\n ? html`\n
\n {\n this.handleSttModelChange(e);\n this.sttError = '';\n }}\n ?disabled=${this.isLoading}\n >\n \n ${[\n { id: 'whisper-tiny', name: 'Whisper Tiny (39M)' },\n { id: 'whisper-base', name: 'Whisper Base (74M)' },\n { id: 'whisper-small', name: 'Whisper Small (244M)' },\n { id: 'whisper-medium', name: 'Whisper Medium (769M)' },\n ].map(model => html` `)}\n \n ${this.sttError ? html`
${this.sttError}
` : ''}\n
\n `\n : html`\n
\n {\n this.sttApiKey = e.target.value;\n this.sttError = '';\n }}\n ?disabled=${this.isLoading}\n />\n ${this.sttError ? html`
${this.sttError}
` : ''}\n
\n `}\n
\n
\n
\n \n
\n\n
\n Get your API key from: OpenAI | Google | Anthropic\n
\n Glass does not collect your personal data —\n See details\n
\n\n
\n ${this.errorMessage}\n
\n \n ${this.successMessage}\n
\n \n `;\n }\n}\n\ncustomElements.define('apikey-header', ApiKeyHeader);\n"], ["/glass/src/features/common/services/databaseInitializer.js", "const { app } = require('electron');\nconst path = require('path');\nconst fs = require('fs');\nconst sqliteClient = require('./sqliteClient');\nconst config = require('../config/config');\n\nclass DatabaseInitializer {\n constructor() {\n this.isInitialized = false;\n \n // 최종적으로 사용될 DB 경로 (쓰기 가능한 위치)\n const userDataPath = app.getPath('userData');\n // In both development and production mode, the database is stored in the userData directory:\n // macOS: ~/Library/Application Support/Glass/pickleglass.db\n // Windows: %APPDATA%\\Glass\\pickleglass.db\n this.dbPath = path.join(userDataPath, 'pickleglass.db');\n this.dataDir = userDataPath;\n\n // The original DB path (read-only location in the package)\n this.sourceDbPath = app.isPackaged\n ? path.join(process.resourcesPath, 'data', 'pickleglass.db')\n : path.join(app.getAppPath(), 'data', 'pickleglass.db');\n }\n\n ensureDatabaseExists() {\n if (!fs.existsSync(this.dbPath)) {\n console.log(`[DB] Database not found at ${this.dbPath}. Preparing to create new database...`);\n\n // userData 디렉토리 생성 (없을 경우)\n if (!fs.existsSync(this.dataDir)) {\n fs.mkdirSync(this.dataDir, { recursive: true });\n }\n\n // 패키지에 번들된 초기 DB가 있으면 복사, 없으면 빈 파일을 생성하도록 둔다.\n if (fs.existsSync(this.sourceDbPath)) {\n try {\n fs.copyFileSync(this.sourceDbPath, this.dbPath);\n console.log(`[DB] Bundled database copied to ${this.dbPath}`);\n } catch (error) {\n console.error(`[DB] Failed to copy bundled database:`, error);\n // 복사 실패 시에도 새 DB를 생성할 수 있도록 계속 진행\n }\n } else {\n console.log('[DB] No bundled DB found – a fresh database will be created.');\n }\n }\n }\n\n async initialize() {\n if (this.isInitialized) {\n console.log('[DB] Already initialized.');\n return true;\n }\n\n try {\n this.ensureDatabaseExists();\n\n sqliteClient.connect(this.dbPath); // DB 경로를 인자로 전달\n \n // This single call will now synchronize the schema and then init default data.\n await sqliteClient.initTables();\n\n // Clean up any orphaned sessions from previous versions\n await sqliteClient.cleanupEmptySessions();\n\n this.isInitialized = true;\n console.log('[DB] Database initialized successfully');\n return true;\n } catch (error) {\n console.error('[DB] Database initialization failed:', error);\n this.isInitialized = false;\n throw error; \n }\n }\n\n async ensureDataDirectory() {\n try {\n if (!fs.existsSync(this.dataDir)) {\n fs.mkdirSync(this.dataDir, { recursive: true });\n console.log('[DatabaseInitializer] Data directory created:', this.dataDir);\n } else {\n console.log('[DatabaseInitializer] Data directory exists:', this.dataDir);\n }\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to create data directory:', error);\n throw error;\n }\n }\n\n async checkDatabaseExists() {\n try {\n const exists = fs.existsSync(this.dbPath);\n console.log('[DatabaseInitializer] Database file check:', { path: this.dbPath, exists });\n return exists;\n } catch (error) {\n console.error('[DatabaseInitializer] Error checking database file:', error);\n return false;\n }\n }\n\n async createNewDatabase() {\n console.log('[DatabaseInitializer] Creating new database...');\n try {\n await sqliteClient.connect(); // Connect and initialize tables/default data\n \n const user = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!user) {\n throw new Error('Default user was not created during initialization.');\n }\n \n console.log(`[DatabaseInitializer] Default user check successful, UID: ${user.uid}`);\n return { success: true, user };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to create new database:', error);\n throw error;\n }\n }\n\n async connectToExistingDatabase() {\n console.log('[DatabaseInitializer] Connecting to existing database...');\n try {\n await sqliteClient.connect();\n \n const user = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!user) {\n console.warn('[DatabaseInitializer] Default user not found in existing DB, attempting recovery.');\n throw new Error('Default user missing');\n }\n \n console.log(`[DatabaseInitializer] Connection to existing DB successful for user: ${user.uid}`);\n return { success: true, user };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Failed to connect to existing database:', error);\n throw error;\n }\n }\n\n async validateAndRecoverData() {\n console.log('[DatabaseInitializer] Validating database integrity...');\n try {\n console.log('[DatabaseInitializer] Validating database integrity...');\n\n // The synchronizeSchema function handles table and column creation now.\n // We just need to ensure default data is present.\n await sqliteClient.synchronizeSchema();\n\n const defaultUser = await sqliteClient.getUser(sqliteClient.defaultUserId);\n if (!defaultUser) {\n console.log('[DatabaseInitializer] Default user not found - creating...');\n await sqliteClient.initDefaultData();\n }\n\n const presetTemplates = await sqliteClient.getPresets('default_user');\n if (!presetTemplates || presetTemplates.length === 0) {\n console.log('[DatabaseInitializer] Preset templates missing - creating...');\n await sqliteClient.initDefaultData();\n }\n\n console.log('[DatabaseInitializer] Database validation completed');\n return { success: true };\n\n } catch (error) {\n console.error('[DatabaseInitializer] Database validation failed:', error);\n try {\n await sqliteClient.initDefaultData();\n console.log('[DatabaseInitializer] Default data recovered');\n return { success: true };\n } catch (error) {\n console.error('[DatabaseInitializer] Database validation failed:', error);\n throw error;\n }\n }\n }\n\n async getStatus() {\n return {\n isInitialized: this.isInitialized,\n dbPath: this.dbPath,\n dbExists: fs.existsSync(this.dbPath),\n enableSQLiteStorage: config.get('enableSQLiteStorage'),\n enableOfflineMode: config.get('enableOfflineMode')\n };\n }\n\n async reset() {\n try {\n console.log('[DatabaseInitializer] Resetting database...');\n \n sqliteClient.close();\n \n if (fs.existsSync(this.dbPath)) {\n fs.unlinkSync(this.dbPath);\n console.log('[DatabaseInitializer] Database file deleted');\n }\n\n this.isInitialized = false;\n await this.initialize();\n\n console.log('[DatabaseInitializer] Database reset completed');\n return true;\n\n } catch (error) {\n console.error('[DatabaseInitializer] Database reset failed:', error);\n return false;\n }\n }\n\n close() {\n if (sqliteClient) {\n sqliteClient.close();\n }\n this.isInitialized = false;\n console.log('[DatabaseInitializer] Database connection closed');\n }\n\n getDatabasePath() {\n return this.dbPath;\n }\n}\n\nconst databaseInitializer = new DatabaseInitializer();\n\nmodule.exports = databaseInitializer; "], ["/glass/src/features/listen/listenService.js", "const { BrowserWindow } = require('electron');\nconst SttService = require('./stt/sttService');\nconst SummaryService = require('./summary/summaryService');\nconst authService = require('../common/services/authService');\nconst sessionRepository = require('../common/repositories/session');\nconst sttRepository = require('./stt/repositories');\nconst internalBridge = require('../../bridge/internalBridge');\n\nclass ListenService {\n constructor() {\n this.sttService = new SttService();\n this.summaryService = new SummaryService();\n this.currentSessionId = null;\n this.isInitializingSession = false;\n\n this.setupServiceCallbacks();\n console.log('[ListenService] Service instance created.');\n }\n\n setupServiceCallbacks() {\n // STT service callbacks\n this.sttService.setCallbacks({\n onTranscriptionComplete: (speaker, text) => {\n this.handleTranscriptionComplete(speaker, text);\n },\n onStatusUpdate: (status) => {\n this.sendToRenderer('update-status', status);\n }\n });\n\n // Summary service callbacks\n this.summaryService.setCallbacks({\n onAnalysisComplete: (data) => {\n console.log('📊 Analysis completed:', data);\n },\n onStatusUpdate: (status) => {\n this.sendToRenderer('update-status', status);\n }\n });\n }\n\n sendToRenderer(channel, data) {\n const { windowPool } = require('../../window/windowManager');\n const listenWindow = windowPool?.get('listen');\n \n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send(channel, data);\n }\n }\n\n initialize() {\n this.setupIpcHandlers();\n console.log('[ListenService] Initialized and ready.');\n }\n\n async handleListenRequest(listenButtonText) {\n const { windowPool } = require('../../window/windowManager');\n const listenWindow = windowPool.get('listen');\n const header = windowPool.get('header');\n\n try {\n switch (listenButtonText) {\n case 'Listen':\n console.log('[ListenService] changeSession to \"Listen\"');\n internalBridge.emit('window:requestVisibility', { name: 'listen', visible: true });\n await this.initializeSession();\n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send('session-state-changed', { isActive: true });\n }\n break;\n \n case 'Stop':\n console.log('[ListenService] changeSession to \"Stop\"');\n await this.closeSession();\n if (listenWindow && !listenWindow.isDestroyed()) {\n listenWindow.webContents.send('session-state-changed', { isActive: false });\n }\n break;\n \n case 'Done':\n console.log('[ListenService] changeSession to \"Done\"');\n internalBridge.emit('window:requestVisibility', { name: 'listen', visible: false });\n listenWindow.webContents.send('session-state-changed', { isActive: false });\n break;\n \n default:\n throw new Error(`[ListenService] unknown listenButtonText: ${listenButtonText}`);\n }\n \n header.webContents.send('listen:changeSessionResult', { success: true });\n\n } catch (error) {\n console.error('[ListenService] error in handleListenRequest:', error);\n header.webContents.send('listen:changeSessionResult', { success: false });\n throw error; \n }\n }\n\n async handleTranscriptionComplete(speaker, text) {\n console.log(`[ListenService] Transcription complete: ${speaker} - ${text}`);\n \n // Save to database\n await this.saveConversationTurn(speaker, text);\n \n // Add to summary service for analysis\n this.summaryService.addConversationTurn(speaker, text);\n }\n\n async saveConversationTurn(speaker, transcription) {\n if (!this.currentSessionId) {\n console.error('[DB] Cannot save turn, no active session ID.');\n return;\n }\n if (transcription.trim() === '') return;\n\n try {\n await sessionRepository.touch(this.currentSessionId);\n await sttRepository.addTranscript({\n sessionId: this.currentSessionId,\n speaker: speaker,\n text: transcription.trim(),\n });\n console.log(`[DB] Saved transcript for session ${this.currentSessionId}: (${speaker})`);\n } catch (error) {\n console.error('Failed to save transcript to DB:', error);\n }\n }\n\n async initializeNewSession() {\n try {\n // The UID is no longer passed to the repository method directly.\n // The adapter layer handles UID injection. We just ensure a user is available.\n const user = authService.getCurrentUser();\n if (!user) {\n // This case should ideally not happen as authService initializes a default user.\n throw new Error(\"Cannot initialize session: auth service not ready.\");\n }\n \n this.currentSessionId = await sessionRepository.getOrCreateActive('listen');\n console.log(`[DB] New listen session ensured: ${this.currentSessionId}`);\n\n // Set session ID for summary service\n this.summaryService.setSessionId(this.currentSessionId);\n \n // Reset conversation history\n this.summaryService.resetConversationHistory();\n\n console.log('New conversation session started:', this.currentSessionId);\n return true;\n } catch (error) {\n console.error('Failed to initialize new session in DB:', error);\n this.currentSessionId = null;\n return false;\n }\n }\n\n async initializeSession(language = 'en') {\n if (this.isInitializingSession) {\n console.log('Session initialization already in progress.');\n return false;\n }\n\n this.isInitializingSession = true;\n this.sendToRenderer('session-initializing', true);\n this.sendToRenderer('update-status', 'Initializing sessions...');\n\n try {\n // Initialize database session\n const sessionInitialized = await this.initializeNewSession();\n if (!sessionInitialized) {\n throw new Error('Failed to initialize database session');\n }\n\n /* ---------- STT Initialization Retry Logic ---------- */\n const MAX_RETRY = 10;\n const RETRY_DELAY_MS = 300; // 0.3 seconds\n\n let sttReady = false;\n for (let attempt = 1; attempt <= MAX_RETRY; attempt++) {\n try {\n await this.sttService.initializeSttSessions(language);\n sttReady = true;\n break; // Exit on success\n } catch (err) {\n console.warn(\n `[ListenService] STT init attempt ${attempt} failed: ${err.message}`\n );\n if (attempt < MAX_RETRY) {\n await new Promise(r => setTimeout(r, RETRY_DELAY_MS));\n }\n }\n }\n if (!sttReady) throw new Error('STT init failed after retries');\n /* ------------------------------------------- */\n\n console.log('✅ Listen service initialized successfully.');\n \n this.sendToRenderer('update-status', 'Connected. Ready to listen.');\n \n return true;\n } catch (error) {\n console.error('❌ Failed to initialize listen service:', error);\n this.sendToRenderer('update-status', 'Initialization failed.');\n return false;\n } finally {\n this.isInitializingSession = false;\n this.sendToRenderer('session-initializing', false);\n this.sendToRenderer('change-listen-capture-state', { status: \"start\" });\n }\n }\n\n async sendMicAudioContent(data, mimeType) {\n return await this.sttService.sendMicAudioContent(data, mimeType);\n }\n\n async startMacOSAudioCapture() {\n if (process.platform !== 'darwin') {\n throw new Error('macOS audio capture only available on macOS');\n }\n return await this.sttService.startMacOSAudioCapture();\n }\n\n async stopMacOSAudioCapture() {\n this.sttService.stopMacOSAudioCapture();\n }\n\n isSessionActive() {\n return this.sttService.isSessionActive();\n }\n\n async closeSession() {\n try {\n this.sendToRenderer('change-listen-capture-state', { status: \"stop\" });\n // Close STT sessions\n await this.sttService.closeSessions();\n\n await this.stopMacOSAudioCapture();\n\n // End database session\n if (this.currentSessionId) {\n await sessionRepository.end(this.currentSessionId);\n console.log(`[DB] Session ${this.currentSessionId} ended.`);\n }\n\n // Reset state\n this.currentSessionId = null;\n this.summaryService.resetConversationHistory();\n\n console.log('Listen service session closed.');\n return { success: true };\n } catch (error) {\n console.error('Error closing listen service session:', error);\n return { success: false, error: error.message };\n }\n }\n\n getCurrentSessionData() {\n return {\n sessionId: this.currentSessionId,\n conversationHistory: this.summaryService.getConversationHistory(),\n totalTexts: this.summaryService.getConversationHistory().length,\n analysisData: this.summaryService.getCurrentAnalysisData(),\n };\n }\n\n getConversationHistory() {\n return this.summaryService.getConversationHistory();\n }\n\n _createHandler(asyncFn, successMessage, errorMessage) {\n return async (...args) => {\n try {\n const result = await asyncFn.apply(this, args);\n if (successMessage) console.log(successMessage);\n // `startMacOSAudioCapture`는 성공 시 { success, error } 객체를 반환하지 않으므로,\n // 핸들러가 일관된 응답을 보내도록 여기서 success 객체를 반환합니다.\n // 다른 함수들은 이미 success 객체를 반환합니다.\n return result && typeof result.success !== 'undefined' ? result : { success: true };\n } catch (e) {\n console.error(errorMessage, e);\n return { success: false, error: e.message };\n }\n };\n }\n\n // `_createHandler`를 사용하여 핸들러들을 동적으로 생성합니다.\n handleSendMicAudioContent = this._createHandler(\n this.sendMicAudioContent,\n null,\n 'Error sending user audio:'\n );\n\n handleStartMacosAudio = this._createHandler(\n async () => {\n if (process.platform !== 'darwin') {\n return { success: false, error: 'macOS audio capture only available on macOS' };\n }\n if (this.sttService.isMacOSAudioRunning?.()) {\n return { success: false, error: 'already_running' };\n }\n await this.startMacOSAudioCapture();\n return { success: true, error: null };\n },\n 'macOS audio capture started.',\n 'Error starting macOS audio capture:'\n );\n \n handleStopMacosAudio = this._createHandler(\n this.stopMacOSAudioCapture,\n 'macOS audio capture stopped.',\n 'Error stopping macOS audio capture:'\n );\n\n handleUpdateGoogleSearchSetting = this._createHandler(\n async (enabled) => {\n console.log('Google Search setting updated to:', enabled);\n },\n null,\n 'Error updating Google Search setting:'\n );\n}\n\nconst listenService = new ListenService();\nmodule.exports = listenService;"], ["/glass/src/features/common/ai/providers/ollama.js", "const http = require('http');\nconst fetch = require('node-fetch');\n\n// Request Queue System for Ollama API (only for non-streaming requests)\nclass RequestQueue {\n constructor() {\n this.queue = [];\n this.processing = false;\n this.streamingActive = false;\n }\n\n async addStreamingRequest(requestFn) {\n // Streaming requests have priority - wait for current processing to finish\n while (this.processing) {\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n \n this.streamingActive = true;\n console.log('[Ollama Queue] Starting streaming request (priority)');\n \n try {\n const result = await requestFn();\n return result;\n } finally {\n this.streamingActive = false;\n console.log('[Ollama Queue] Streaming request completed');\n }\n }\n\n async add(requestFn) {\n return new Promise((resolve, reject) => {\n this.queue.push({ requestFn, resolve, reject });\n this.process();\n });\n }\n\n async process() {\n if (this.processing || this.queue.length === 0) {\n return;\n }\n\n // Wait if streaming is active\n if (this.streamingActive) {\n setTimeout(() => this.process(), 100);\n return;\n }\n\n this.processing = true;\n\n while (this.queue.length > 0) {\n // Check if streaming started while processing queue\n if (this.streamingActive) {\n this.processing = false;\n setTimeout(() => this.process(), 100);\n return;\n }\n\n const { requestFn, resolve, reject } = this.queue.shift();\n \n try {\n console.log(`[Ollama Queue] Processing queued request (${this.queue.length} remaining)`);\n const result = await requestFn();\n resolve(result);\n } catch (error) {\n console.error('[Ollama Queue] Request failed:', error);\n reject(error);\n }\n }\n\n this.processing = false;\n }\n}\n\n// Global request queue instance\nconst requestQueue = new RequestQueue();\n\nclass OllamaProvider {\n static async validateApiKey() {\n try {\n const response = await fetch('http://localhost:11434/api/tags');\n if (response.ok) {\n return { success: true };\n } else {\n return { success: false, error: 'Ollama service is not running. Please start Ollama first.' };\n }\n } catch (error) {\n return { success: false, error: 'Cannot connect to Ollama. Please ensure Ollama is installed and running.' };\n }\n }\n}\n\n\nfunction convertMessagesToOllamaFormat(messages) {\n return messages.map(msg => {\n if (Array.isArray(msg.content)) {\n let textContent = '';\n const images = [];\n \n for (const part of msg.content) {\n if (part.type === 'text') {\n textContent += part.text;\n } else if (part.type === 'image_url') {\n const base64 = part.image_url.url.replace(/^data:image\\/[^;]+;base64,/, '');\n images.push(base64);\n }\n }\n \n return {\n role: msg.role,\n content: textContent,\n ...(images.length > 0 && { images })\n };\n } else {\n return msg;\n }\n });\n}\n\nfunction createLLM({ \n model, \n temperature = 0.7, \n maxTokens = 2048, \n baseUrl = 'http://localhost:11434',\n ...config \n}) {\n if (!model) {\n throw new Error('Model parameter is required for Ollama LLM. Please specify a model name (e.g., \"llama3.2:latest\", \"gemma3:4b\")');\n }\n return {\n generateContent: async (parts) => {\n let systemPrompt = '';\n const userContent = [];\n\n for (const part of parts) {\n if (typeof part === 'string') {\n if (systemPrompt === '' && part.includes('You are')) {\n systemPrompt = part;\n } else {\n userContent.push(part);\n }\n } else if (part.inlineData) {\n userContent.push({\n type: 'image',\n image: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`\n });\n }\n }\n\n const messages = [];\n if (systemPrompt) {\n messages.push({ role: 'system', content: systemPrompt });\n }\n messages.push({ role: 'user', content: userContent.join('\\n') });\n\n // Use request queue to prevent concurrent API calls\n return await requestQueue.add(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages,\n stream: false,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n \n return {\n response: {\n text: () => result.message.content\n },\n raw: result\n };\n } catch (error) {\n console.error('Ollama LLM error:', error);\n throw error;\n }\n });\n },\n\n chat: async (messages) => {\n const ollamaMessages = convertMessagesToOllamaFormat(messages);\n\n // Use request queue to prevent concurrent API calls\n return await requestQueue.add(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages: ollamaMessages,\n stream: false,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n const result = await response.json();\n \n return {\n content: result.message.content,\n raw: result\n };\n } catch (error) {\n console.error('Ollama chat error:', error);\n throw error;\n }\n });\n }\n };\n}\n\nfunction createStreamingLLM({ \n model, \n temperature = 0.7, \n maxTokens = 2048, \n baseUrl = 'http://localhost:11434',\n ...config \n}) {\n if (!model) {\n throw new Error('Model parameter is required for Ollama streaming LLM. Please specify a model name (e.g., \"llama3.2:latest\", \"gemma3:4b\")');\n }\n return {\n streamChat: async (messages) => {\n console.log('[Ollama Provider] Starting streaming request');\n\n const ollamaMessages = convertMessagesToOllamaFormat(messages);\n console.log('[Ollama Provider] Converted messages for Ollama:', ollamaMessages);\n\n // Streaming requests have priority over queued requests\n return await requestQueue.addStreamingRequest(async () => {\n try {\n const response = await fetch(`${baseUrl}/api/chat`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model,\n messages: ollamaMessages,\n stream: true,\n options: {\n temperature,\n num_predict: maxTokens,\n }\n })\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);\n }\n\n console.log('[Ollama Provider] Got streaming response');\n\n const stream = new ReadableStream({\n async start(controller) {\n let buffer = '';\n\n try {\n response.body.on('data', (chunk) => {\n buffer += chunk.toString();\n const lines = buffer.split('\\n');\n buffer = lines.pop() || '';\n\n for (const line of lines) {\n if (line.trim() === '') continue;\n \n try {\n const data = JSON.parse(line);\n \n if (data.message?.content) {\n const sseData = JSON.stringify({\n choices: [{\n delta: {\n content: data.message.content\n }\n }]\n });\n controller.enqueue(new TextEncoder().encode(`data: ${sseData}\\n\\n`));\n }\n \n if (data.done) {\n controller.enqueue(new TextEncoder().encode('data: [DONE]\\n\\n'));\n }\n } catch (e) {\n console.error('[Ollama Provider] Failed to parse chunk:', e);\n }\n }\n });\n\n response.body.on('end', () => {\n controller.close();\n console.log('[Ollama Provider] Streaming completed');\n });\n\n response.body.on('error', (error) => {\n console.error('[Ollama Provider] Streaming error:', error);\n controller.error(error);\n });\n \n } catch (error) {\n console.error('[Ollama Provider] Streaming setup error:', error);\n controller.error(error);\n }\n }\n });\n\n return {\n ok: true,\n body: stream\n };\n \n } catch (error) {\n console.error('[Ollama Provider] Request error:', error);\n throw error;\n }\n });\n }\n };\n}\n\nmodule.exports = {\n OllamaProvider,\n createLLM,\n createStreamingLLM,\n convertMessagesToOllamaFormat\n}; "], ["/glass/src/features/settings/settingsService.js", "const { ipcMain, BrowserWindow } = require('electron');\nconst Store = require('electron-store');\nconst authService = require('../common/services/authService');\nconst settingsRepository = require('./repositories');\nconst { getStoredApiKey, getStoredProvider, windowPool } = require('../../window/windowManager');\n\n// New imports for common services\nconst modelStateService = require('../common/services/modelStateService');\nconst localAIManager = require('../common/services/localAIManager');\n\nconst store = new Store({\n name: 'pickle-glass-settings',\n defaults: {\n users: {}\n }\n});\n\n// Configuration constants\nconst NOTIFICATION_CONFIG = {\n RELEVANT_WINDOW_TYPES: ['settings', 'main'],\n DEBOUNCE_DELAY: 300, // prevent spam during bulk operations (ms)\n MAX_RETRY_ATTEMPTS: 3,\n RETRY_BASE_DELAY: 1000, // exponential backoff base (ms)\n};\n\n// New facade functions for model state management\nasync function getModelSettings() {\n try {\n const [config, storedKeys, selectedModels, availableLlm, availableStt] = await Promise.all([\n modelStateService.getProviderConfig(),\n modelStateService.getAllApiKeys(),\n modelStateService.getSelectedModels(),\n modelStateService.getAvailableModels('llm'),\n modelStateService.getAvailableModels('stt')\n ]);\n \n return { success: true, data: { config, storedKeys, availableLlm, availableStt, selectedModels } };\n } catch (error) {\n console.error('[SettingsService] Error getting model settings:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function clearApiKey(provider) {\n const success = await modelStateService.handleRemoveApiKey(provider);\n return { success };\n}\n\nasync function setSelectedModel(type, modelId) {\n const success = await modelStateService.handleSetSelectedModel(type, modelId);\n return { success };\n}\n\n// LocalAI facade functions\nasync function getOllamaStatus() {\n return localAIManager.getServiceStatus('ollama');\n}\n\nasync function ensureOllamaReady() {\n const status = await localAIManager.getServiceStatus('ollama');\n if (!status.installed || !status.running) {\n await localAIManager.startService('ollama');\n }\n return { success: true };\n}\n\nasync function shutdownOllama() {\n return localAIManager.stopService('ollama');\n}\n\n\n// window targeting system\nclass WindowNotificationManager {\n constructor() {\n this.pendingNotifications = new Map();\n }\n\n /**\n * Send notifications only to relevant windows\n * @param {string} event - Event name\n * @param {*} data - Event data\n * @param {object} options - Notification options\n */\n notifyRelevantWindows(event, data = null, options = {}) {\n const { \n windowTypes = NOTIFICATION_CONFIG.RELEVANT_WINDOW_TYPES,\n debounce = NOTIFICATION_CONFIG.DEBOUNCE_DELAY \n } = options;\n\n if (debounce > 0) {\n this.debounceNotification(event, () => {\n this.sendToTargetWindows(event, data, windowTypes);\n }, debounce);\n } else {\n this.sendToTargetWindows(event, data, windowTypes);\n }\n }\n\n sendToTargetWindows(event, data, windowTypes) {\n const relevantWindows = this.getRelevantWindows(windowTypes);\n \n if (relevantWindows.length === 0) {\n console.log(`[WindowNotificationManager] No relevant windows found for event: ${event}`);\n return;\n }\n\n console.log(`[WindowNotificationManager] Sending ${event} to ${relevantWindows.length} relevant windows`);\n \n relevantWindows.forEach(win => {\n try {\n if (data) {\n win.webContents.send(event, data);\n } else {\n win.webContents.send(event);\n }\n } catch (error) {\n console.warn(`[WindowNotificationManager] Failed to send ${event} to window:`, error.message);\n }\n });\n }\n\n getRelevantWindows(windowTypes) {\n const allWindows = BrowserWindow.getAllWindows();\n const relevantWindows = [];\n\n allWindows.forEach(win => {\n if (win.isDestroyed()) return;\n\n for (const [windowName, poolWindow] of windowPool || []) {\n if (poolWindow === win && windowTypes.includes(windowName)) {\n if (windowName === 'settings' || win.isVisible()) {\n relevantWindows.push(win);\n }\n break;\n }\n }\n });\n\n return relevantWindows;\n }\n\n debounceNotification(key, fn, delay) {\n // Clear existing timeout\n if (this.pendingNotifications.has(key)) {\n clearTimeout(this.pendingNotifications.get(key));\n }\n\n // Set new timeout\n const timeoutId = setTimeout(() => {\n fn();\n this.pendingNotifications.delete(key);\n }, delay);\n\n this.pendingNotifications.set(key, timeoutId);\n }\n\n cleanup() {\n // Clear all pending notifications\n this.pendingNotifications.forEach(timeoutId => clearTimeout(timeoutId));\n this.pendingNotifications.clear();\n }\n}\n\n// Global instance\nconst windowNotificationManager = new WindowNotificationManager();\n\n// Default keybinds configuration\nconst DEFAULT_KEYBINDS = {\n mac: {\n moveUp: 'Cmd+Up',\n moveDown: 'Cmd+Down',\n moveLeft: 'Cmd+Left',\n moveRight: 'Cmd+Right',\n toggleVisibility: 'Cmd+\\\\',\n toggleClickThrough: 'Cmd+M',\n nextStep: 'Cmd+Enter',\n manualScreenshot: 'Cmd+Shift+S',\n previousResponse: 'Cmd+[',\n nextResponse: 'Cmd+]',\n scrollUp: 'Cmd+Shift+Up',\n scrollDown: 'Cmd+Shift+Down',\n },\n windows: {\n moveUp: 'Ctrl+Up',\n moveDown: 'Ctrl+Down',\n moveLeft: 'Ctrl+Left',\n moveRight: 'Ctrl+Right',\n toggleVisibility: 'Ctrl+\\\\',\n toggleClickThrough: 'Ctrl+M',\n nextStep: 'Ctrl+Enter',\n manualScreenshot: 'Ctrl+Shift+S',\n previousResponse: 'Ctrl+[',\n nextResponse: 'Ctrl+]',\n scrollUp: 'Ctrl+Shift+Up',\n scrollDown: 'Ctrl+Shift+Down',\n }\n};\n\n// Service state\nlet currentSettings = null;\n\nfunction getDefaultSettings() {\n const isMac = process.platform === 'darwin';\n return {\n profile: 'school',\n language: 'en',\n screenshotInterval: '5000',\n imageQuality: '0.8',\n layoutMode: 'stacked',\n keybinds: isMac ? DEFAULT_KEYBINDS.mac : DEFAULT_KEYBINDS.windows,\n throttleTokens: 500,\n maxTokens: 2000,\n throttlePercent: 80,\n googleSearchEnabled: false,\n backgroundTransparency: 0.5,\n fontSize: 14,\n contentProtection: true\n };\n}\n\nasync function getSettings() {\n try {\n const uid = authService.getCurrentUserId();\n const userSettingsKey = uid ? `users.${uid}` : 'users.default';\n \n const defaultSettings = getDefaultSettings();\n const savedSettings = store.get(userSettingsKey, {});\n \n currentSettings = { ...defaultSettings, ...savedSettings };\n return currentSettings;\n } catch (error) {\n console.error('[SettingsService] Error getting settings from store:', error);\n return getDefaultSettings();\n }\n}\n\nasync function saveSettings(settings) {\n try {\n const uid = authService.getCurrentUserId();\n const userSettingsKey = uid ? `users.${uid}` : 'users.default';\n \n const currentSaved = store.get(userSettingsKey, {});\n const newSettings = { ...currentSaved, ...settings };\n \n store.set(userSettingsKey, newSettings);\n currentSettings = newSettings;\n \n // Use smart notification system\n windowNotificationManager.notifyRelevantWindows('settings-updated', currentSettings);\n\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error saving settings to store:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function getPresets() {\n try {\n // The adapter now handles which presets to return based on login state.\n const presets = await settingsRepository.getPresets();\n return presets;\n } catch (error) {\n console.error('[SettingsService] Error getting presets:', error);\n return [];\n }\n}\n\nasync function getPresetTemplates() {\n try {\n const templates = await settingsRepository.getPresetTemplates();\n return templates;\n } catch (error) {\n console.error('[SettingsService] Error getting preset templates:', error);\n return [];\n }\n}\n\nasync function createPreset(title, prompt) {\n try {\n // The adapter injects the UID.\n const result = await settingsRepository.createPreset({ title, prompt });\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'created',\n presetId: result.id,\n title\n });\n \n return { success: true, id: result.id };\n } catch (error) {\n console.error('[SettingsService] Error creating preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function updatePreset(id, title, prompt) {\n try {\n // The adapter injects the UID.\n await settingsRepository.updatePreset(id, { title, prompt });\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'updated',\n presetId: id,\n title\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error updating preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function deletePreset(id) {\n try {\n // The adapter injects the UID.\n await settingsRepository.deletePreset(id);\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', {\n action: 'deleted',\n presetId: id\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error deleting preset:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function saveApiKey(apiKey, provider = 'openai') {\n try {\n // Use ModelStateService as the single source of truth for API key management\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n throw new Error('ModelStateService not initialized');\n }\n \n await modelStateService.setApiKey(provider, apiKey);\n \n // Notify windows\n BrowserWindow.getAllWindows().forEach(win => {\n if (!win.isDestroyed()) {\n win.webContents.send('api-key-validated', apiKey);\n }\n });\n \n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error saving API key:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function removeApiKey() {\n try {\n // Use ModelStateService as the single source of truth for API key management\n const modelStateService = global.modelStateService;\n if (!modelStateService) {\n throw new Error('ModelStateService not initialized');\n }\n \n // Remove all API keys for all providers\n const providers = ['openai', 'anthropic', 'gemini', 'ollama', 'whisper'];\n for (const provider of providers) {\n await modelStateService.removeApiKey(provider);\n }\n \n // Notify windows\n BrowserWindow.getAllWindows().forEach(win => {\n if (!win.isDestroyed()) {\n win.webContents.send('api-key-removed');\n }\n });\n \n console.log('[SettingsService] API key removed for all providers');\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error removing API key:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function updateContentProtection(enabled) {\n try {\n const settings = await getSettings();\n settings.contentProtection = enabled;\n \n // Update content protection in main window\n const { app } = require('electron');\n const mainWindow = windowPool.get('main');\n if (mainWindow && !mainWindow.isDestroyed()) {\n mainWindow.setContentProtection(enabled);\n }\n \n return await saveSettings(settings);\n } catch (error) {\n console.error('[SettingsService] Error updating content protection:', error);\n return { success: false, error: error.message };\n }\n}\n\nasync function getAutoUpdateSetting() {\n try {\n return settingsRepository.getAutoUpdate();\n } catch (error) {\n console.error('[SettingsService] Error getting auto update setting:', error);\n return true; // Fallback to enabled\n }\n}\n\nasync function setAutoUpdateSetting(isEnabled) {\n try {\n await settingsRepository.setAutoUpdate(isEnabled);\n return { success: true };\n } catch (error) {\n console.error('[SettingsService] Error setting auto update setting:', error);\n return { success: false, error: error.message };\n }\n}\n\nfunction initialize() {\n // cleanup \n windowNotificationManager.cleanup();\n \n console.log('[SettingsService] Initialized and ready.');\n}\n\n// Cleanup function\nfunction cleanup() {\n windowNotificationManager.cleanup();\n console.log('[SettingsService] Cleaned up resources.');\n}\n\nfunction notifyPresetUpdate(action, presetId, title = null) {\n const data = { action, presetId };\n if (title) data.title = title;\n \n windowNotificationManager.notifyRelevantWindows('presets-updated', data);\n}\n\nmodule.exports = {\n initialize,\n cleanup,\n notifyPresetUpdate,\n getSettings,\n saveSettings,\n getPresets,\n getPresetTemplates,\n createPreset,\n updatePreset,\n deletePreset,\n saveApiKey,\n removeApiKey,\n updateContentProtection,\n getAutoUpdateSetting,\n setAutoUpdateSetting,\n // Model settings facade\n getModelSettings,\n clearApiKey,\n setSelectedModel,\n // Ollama facade\n getOllamaStatus,\n ensureOllamaReady,\n shutdownOllama\n};"], ["/glass/src/features/common/ai/providers/whisper.js", "let spawn, path, EventEmitter;\n\nif (typeof window === 'undefined') {\n spawn = require('child_process').spawn;\n path = require('path');\n EventEmitter = require('events').EventEmitter;\n} else {\n class DummyEventEmitter {\n on() {}\n emit() {}\n removeAllListeners() {}\n }\n EventEmitter = DummyEventEmitter;\n}\n\nclass WhisperSTTSession extends EventEmitter {\n constructor(model, whisperService, sessionId) {\n super();\n this.model = model;\n this.whisperService = whisperService;\n this.sessionId = sessionId || `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n this.process = null;\n this.isRunning = false;\n this.audioBuffer = Buffer.alloc(0);\n this.processingInterval = null;\n this.lastTranscription = '';\n }\n\n async initialize() {\n try {\n await this.whisperService.ensureModelAvailable(this.model);\n this.isRunning = true;\n this.startProcessingLoop();\n return true;\n } catch (error) {\n console.error('[WhisperSTT] Initialization error:', error);\n this.emit('error', error);\n return false;\n }\n }\n\n startProcessingLoop() {\n this.processingInterval = setInterval(async () => {\n const minBufferSize = 16000 * 2 * 0.15;\n if (this.audioBuffer.length >= minBufferSize && !this.process) {\n console.log(`[WhisperSTT-${this.sessionId}] Processing audio chunk, buffer size: ${this.audioBuffer.length}`);\n await this.processAudioChunk();\n }\n }, 1500);\n }\n\n async processAudioChunk() {\n if (!this.isRunning || this.audioBuffer.length === 0) return;\n\n const audioData = this.audioBuffer;\n this.audioBuffer = Buffer.alloc(0);\n\n try {\n const tempFile = await this.whisperService.saveAudioToTemp(audioData, this.sessionId);\n \n if (!tempFile || typeof tempFile !== 'string') {\n console.error('[WhisperSTT] Invalid temp file path:', tempFile);\n return;\n }\n \n const whisperPath = await this.whisperService.getWhisperPath();\n const modelPath = await this.whisperService.getModelPath(this.model);\n\n if (!whisperPath || !modelPath) {\n console.error('[WhisperSTT] Invalid whisper or model path:', { whisperPath, modelPath });\n return;\n }\n\n this.process = spawn(whisperPath, [\n '-m', modelPath,\n '-f', tempFile,\n '--no-timestamps',\n '--output-txt',\n '--output-json',\n '--language', 'auto',\n '--threads', '4',\n '--print-progress', 'false'\n ]);\n\n let output = '';\n let errorOutput = '';\n\n this.process.stdout.on('data', (data) => {\n output += data.toString();\n });\n\n this.process.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n\n this.process.on('close', async (code) => {\n this.process = null;\n \n if (code === 0 && output.trim()) {\n const transcription = output.trim();\n if (transcription && transcription !== this.lastTranscription) {\n this.lastTranscription = transcription;\n console.log(`[WhisperSTT-${this.sessionId}] Transcription: \"${transcription}\"`);\n this.emit('transcription', {\n text: transcription,\n timestamp: Date.now(),\n confidence: 1.0,\n sessionId: this.sessionId\n });\n }\n } else if (errorOutput) {\n console.error(`[WhisperSTT-${this.sessionId}] Process error:`, errorOutput);\n }\n\n await this.whisperService.cleanupTempFile(tempFile);\n });\n\n } catch (error) {\n console.error('[WhisperSTT] Processing error:', error);\n this.emit('error', error);\n }\n }\n\n sendRealtimeInput(audioData) {\n if (!this.isRunning) {\n console.warn(`[WhisperSTT-${this.sessionId}] Session not running, cannot accept audio`);\n return;\n }\n\n if (typeof audioData === 'string') {\n try {\n audioData = Buffer.from(audioData, 'base64');\n } catch (error) {\n console.error('[WhisperSTT] Failed to decode base64 audio data:', error);\n return;\n }\n } else if (audioData instanceof ArrayBuffer) {\n audioData = Buffer.from(audioData);\n } else if (!Buffer.isBuffer(audioData) && !(audioData instanceof Uint8Array)) {\n console.error('[WhisperSTT] Invalid audio data type:', typeof audioData);\n return;\n }\n\n if (!Buffer.isBuffer(audioData)) {\n audioData = Buffer.from(audioData);\n }\n\n if (audioData.length > 0) {\n this.audioBuffer = Buffer.concat([this.audioBuffer, audioData]);\n // Log every 10th audio chunk to avoid spam\n if (Math.random() < 0.1) {\n console.log(`[WhisperSTT-${this.sessionId}] Received audio chunk: ${audioData.length} bytes, total buffer: ${this.audioBuffer.length} bytes`);\n }\n }\n }\n\n async close() {\n console.log(`[WhisperSTT-${this.sessionId}] Closing session`);\n this.isRunning = false;\n\n if (this.processingInterval) {\n clearInterval(this.processingInterval);\n this.processingInterval = null;\n }\n\n if (this.process) {\n this.process.kill('SIGTERM');\n this.process = null;\n }\n\n this.removeAllListeners();\n }\n}\n\nclass WhisperProvider {\n static async validateApiKey() {\n // Whisper is a local service, no API key validation needed.\n return { success: true };\n }\n\n constructor() {\n this.whisperService = null;\n }\n\n async initialize() {\n if (!this.whisperService) {\n this.whisperService = require('../../services/whisperService');\n if (!this.whisperService.isInitialized) {\n await this.whisperService.initialize();\n }\n }\n }\n\n async createSTT(config) {\n await this.initialize();\n \n const model = config.model || 'whisper-tiny';\n const sessionType = config.sessionType || 'unknown';\n console.log(`[WhisperProvider] Creating ${sessionType} STT session with model: ${model}`);\n \n // Create unique session ID based on type\n const sessionId = `${sessionType}_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`;\n const session = new WhisperSTTSession(model, this.whisperService, sessionId);\n \n // Log session creation\n console.log(`[WhisperProvider] Created session: ${sessionId}`);\n \n const initialized = await session.initialize();\n if (!initialized) {\n throw new Error('Failed to initialize Whisper STT session');\n }\n\n if (config.callbacks) {\n if (config.callbacks.onmessage) {\n session.on('transcription', config.callbacks.onmessage);\n }\n if (config.callbacks.onerror) {\n session.on('error', config.callbacks.onerror);\n }\n if (config.callbacks.onclose) {\n session.on('close', config.callbacks.onclose);\n }\n }\n\n return session;\n }\n\n async createLLM() {\n throw new Error('Whisper provider does not support LLM functionality');\n }\n\n async createStreamingLLM() {\n console.warn('[WhisperProvider] Streaming LLM is not supported by Whisper.');\n throw new Error('Whisper does not support LLM.');\n }\n}\n\nmodule.exports = {\n WhisperProvider,\n WhisperSTTSession\n};"], ["/glass/src/features/listen/stt/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst sttRepositoryAdapter = {\n addTranscript: ({ sessionId, speaker, text }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().addTranscript({ uid, sessionId, speaker, text });\n },\n getAllTranscriptsBySessionId: (sessionId) => {\n return getBaseRepository().getAllTranscriptsBySessionId(sessionId);\n }\n};\n\nmodule.exports = sttRepositoryAdapter; "], ["/glass/src/features/common/ai/providers/anthropic.js", "const { Anthropic } = require(\"@anthropic-ai/sdk\")\n\nclass AnthropicProvider {\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string' || !key.startsWith('sk-ant-')) {\n return { success: false, error: 'Invalid Anthropic API key format.' };\n }\n\n try {\n const response = await fetch(\"https://api.anthropic.com/v1/messages\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": key,\n \"anthropic-version\": \"2023-06-01\",\n },\n body: JSON.stringify({\n model: \"claude-3-haiku-20240307\",\n max_tokens: 1,\n messages: [{ role: \"user\", content: \"Hi\" }],\n }),\n });\n\n if (response.ok || response.status === 400) { // 400 is a valid response for a bad request, not a bad key\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n return { success: false, error: errorData.error?.message || `Validation failed with status: ${response.status}` };\n }\n } catch (error) {\n console.error(`[AnthropicProvider] Network error during key validation:`, error);\n return { success: false, error: 'A network error occurred during validation.' };\n }\n }\n}\n\n/**\n * Creates an Anthropic STT session\n * Note: Anthropic doesn't have native real-time STT, so this is a placeholder\n * You might want to use a different STT service or implement a workaround\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.language='en'] - Language code\n * @param {object} [opts.callbacks] - Event callbacks\n * @returns {Promise} STT session placeholder\n */\nasync function createSTT({ apiKey, language = \"en\", callbacks = {}, ...config }) {\n console.warn(\"[Anthropic] STT not natively supported. Consider using OpenAI or Gemini for STT.\")\n\n // Return a mock STT session that doesn't actually do anything\n // You might want to fallback to another provider for STT\n return {\n sendRealtimeInput: async (audioData) => {\n console.warn(\"[Anthropic] STT sendRealtimeInput called but not implemented\")\n },\n close: async () => {\n console.log(\"[Anthropic] STT session closed\")\n },\n }\n}\n\n/**\n * Creates an Anthropic LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.model='claude-3-5-sonnet-20241022'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=4096] - Max tokens\n * @returns {object} LLM instance\n */\nfunction createLLM({ apiKey, model = \"claude-3-5-sonnet-20241022\", temperature = 0.7, maxTokens = 4096, ...config }) {\n const client = new Anthropic({ apiKey })\n\n return {\n generateContent: async (parts) => {\n const messages = []\n let systemPrompt = \"\"\n const userContent = []\n\n for (const part of parts) {\n if (typeof part === \"string\") {\n if (systemPrompt === \"\" && part.includes(\"You are\")) {\n systemPrompt = part\n } else {\n userContent.push({ type: \"text\", text: part })\n }\n } else if (part.inlineData) {\n userContent.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: part.inlineData.mimeType,\n data: part.inlineData.data,\n },\n })\n }\n }\n\n if (userContent.length > 0) {\n messages.push({ role: \"user\", content: userContent })\n }\n\n try {\n const response = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: messages,\n })\n\n return {\n response: {\n text: () => response.content[0].text,\n },\n raw: response,\n }\n } catch (error) {\n console.error(\"Anthropic API error:\", error)\n throw error\n }\n },\n\n // For compatibility with chat-style interfaces\n chat: async (messages) => {\n let systemPrompt = \"\"\n const anthropicMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemPrompt = msg.content\n } else {\n // Handle multimodal content\n let content\n if (Array.isArray(msg.content)) {\n content = []\n for (const part of msg.content) {\n if (typeof part === \"string\") {\n content.push({ type: \"text\", text: part })\n } else if (part.type === \"text\") {\n content.push({ type: \"text\", text: part.text })\n } else if (part.type === \"image_url\" && part.image_url) {\n // Convert base64 image to Anthropic format\n const imageUrl = part.image_url.url\n const [mimeInfo, base64Data] = imageUrl.split(\",\")\n\n // Extract the actual MIME type from the data URL\n const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || \"image/jpeg\"\n\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: mimeType,\n data: base64Data,\n },\n })\n }\n }\n } else {\n content = [{ type: \"text\", text: msg.content }]\n }\n\n anthropicMessages.push({\n role: msg.role === \"user\" ? \"user\" : \"assistant\",\n content: content,\n })\n }\n }\n\n const response = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: anthropicMessages,\n })\n\n return {\n content: response.content[0].text,\n raw: response,\n }\n },\n }\n}\n\n/**\n * Creates an Anthropic streaming LLM instance\n * @param {object} opts - Configuration options\n * @param {string} opts.apiKey - Anthropic API key\n * @param {string} [opts.model='claude-3-5-sonnet-20241022'] - Model name\n * @param {number} [opts.temperature=0.7] - Temperature\n * @param {number} [opts.maxTokens=4096] - Max tokens\n * @returns {object} Streaming LLM instance\n */\nfunction createStreamingLLM({\n apiKey,\n model = \"claude-3-5-sonnet-20241022\",\n temperature = 0.7,\n maxTokens = 4096,\n ...config\n}) {\n const client = new Anthropic({ apiKey })\n\n return {\n streamChat: async (messages) => {\n console.log(\"[Anthropic Provider] Starting streaming request\")\n\n let systemPrompt = \"\"\n const anthropicMessages = []\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemPrompt = msg.content\n } else {\n // Handle multimodal content\n let content\n if (Array.isArray(msg.content)) {\n content = []\n for (const part of msg.content) {\n if (typeof part === \"string\") {\n content.push({ type: \"text\", text: part })\n } else if (part.type === \"text\") {\n content.push({ type: \"text\", text: part.text })\n } else if (part.type === \"image_url\" && part.image_url) {\n // Convert base64 image to Anthropic format\n const imageUrl = part.image_url.url\n const [mimeInfo, base64Data] = imageUrl.split(\",\")\n\n // Extract the actual MIME type from the data URL\n const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || \"image/jpeg\"\n\n console.log(`[Anthropic] Processing image with MIME type: ${mimeType}`)\n\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: mimeType,\n data: base64Data,\n },\n })\n }\n }\n } else {\n content = [{ type: \"text\", text: msg.content }]\n }\n\n anthropicMessages.push({\n role: msg.role === \"user\" ? \"user\" : \"assistant\",\n content: content,\n })\n }\n }\n\n // Create a ReadableStream to handle Anthropic's streaming\n const stream = new ReadableStream({\n async start(controller) {\n try {\n console.log(\"[Anthropic Provider] Processing messages:\", anthropicMessages.length, \"messages\")\n\n let chunkCount = 0\n let totalContent = \"\"\n\n // Stream the response\n const stream = await client.messages.create({\n model: model,\n max_tokens: maxTokens,\n temperature: temperature,\n system: systemPrompt || undefined,\n messages: anthropicMessages,\n stream: true,\n })\n\n for await (const chunk of stream) {\n if (chunk.type === \"content_block_delta\" && chunk.delta.type === \"text_delta\") {\n chunkCount++\n const chunkText = chunk.delta.text || \"\"\n totalContent += chunkText\n\n // Format as SSE data\n const data = JSON.stringify({\n choices: [\n {\n delta: {\n content: chunkText,\n },\n },\n ],\n })\n controller.enqueue(new TextEncoder().encode(`data: ${data}\\n\\n`))\n }\n }\n\n console.log(\n `[Anthropic Provider] Streamed ${chunkCount} chunks, total length: ${totalContent.length} chars`,\n )\n\n // Send the final done message\n controller.enqueue(new TextEncoder().encode(\"data: [DONE]\\n\\n\"))\n controller.close()\n console.log(\"[Anthropic Provider] Streaming completed successfully\")\n } catch (error) {\n console.error(\"[Anthropic Provider] Streaming error:\", error)\n controller.error(error)\n }\n },\n })\n\n // Create a Response object with the stream\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n },\n })\n },\n }\n}\n\nmodule.exports = {\n AnthropicProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};\n"], ["/glass/src/features/listen/summary/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst summaryRepositoryAdapter = {\n saveSummary: ({ sessionId, tldr, text, bullet_json, action_json, model }) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().saveSummary({ uid, sessionId, tldr, text, bullet_json, action_json, model });\n },\n getSummaryBySessionId: (sessionId) => {\n return getBaseRepository().getSummaryBySessionId(sessionId);\n }\n};\n\nmodule.exports = summaryRepositoryAdapter; "], ["/glass/src/features/common/repositories/permission/sqlite.repository.js", "const sqliteClient = require('../../services/sqliteClient');\n\nfunction markKeychainCompleted(uid) {\n return sqliteClient.query(\n 'INSERT OR REPLACE INTO permissions (uid, keychain_completed) VALUES (?, 1)',\n [uid]\n );\n}\n\nfunction checkKeychainCompleted(uid) {\n const row = sqliteClient.query('SELECT keychain_completed FROM permissions WHERE uid = ?', [uid]);\n return row.length > 0 && row[0].keychain_completed === 1;\n}\n\nmodule.exports = {\n markKeychainCompleted,\n checkKeychainCompleted\n}; "], ["/glass/src/ui/listen/audioCore/listenCapture.js", "const createAecModule = require('./aec.js');\n\nlet aecModPromise = null; // 한 번만 로드\nlet aecMod = null;\nlet aecPtr = 0; // Rust Aec* 1개만 재사용\n\n/** WASM 모듈 가져오고 1회 초기화 */\nasync function getAec () {\n if (aecModPromise) return aecModPromise; // 캐시\n\n aecModPromise = createAecModule().then((M) => {\n aecMod = M; \n\n console.log('WASM Module Loaded:', M); \n // C 심볼 → JS 래퍼 바인딩 (딱 1번)\n M.newPtr = M.cwrap('AecNew', 'number',\n ['number','number','number','number']);\n M.cancel = M.cwrap('AecCancelEcho', null,\n ['number','number','number','number','number']);\n M.destroy = M.cwrap('AecDestroy', null, ['number']);\n return M;\n });\n\n return aecModPromise;\n}\n\n// 바로 로드-실패 로그를 보기 위해\n// getAec().catch(console.error);\n// ---------------------------\n// Constants & Globals\n// ---------------------------\nconst SAMPLE_RATE = 24000;\nconst AUDIO_CHUNK_DURATION = 0.1;\nconst BUFFER_SIZE = 4096;\n\nconst isLinux = window.api.platform.isLinux;\nconst isMacOS = window.api.platform.isMacOS;\n\nlet mediaStream = null;\nlet micMediaStream = null;\nlet audioContext = null;\nlet audioProcessor = null;\nlet systemAudioContext = null;\nlet systemAudioProcessor = null;\n\nlet systemAudioBuffer = [];\nconst MAX_SYSTEM_BUFFER_SIZE = 10;\n\n// ---------------------------\n// Utility helpers (exact from renderer.js)\n// ---------------------------\nfunction isVoiceActive(audioFloat32Array, threshold = 0.005) {\n if (!audioFloat32Array || audioFloat32Array.length === 0) {\n return false;\n }\n\n let sumOfSquares = 0;\n for (let i = 0; i < audioFloat32Array.length; i++) {\n sumOfSquares += audioFloat32Array[i] * audioFloat32Array[i];\n }\n const rms = Math.sqrt(sumOfSquares / audioFloat32Array.length);\n\n // console.log(`VAD RMS: ${rms.toFixed(4)}`); // For debugging VAD threshold\n\n return rms > threshold;\n}\n\nfunction base64ToFloat32Array(base64) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n\n const int16Array = new Int16Array(bytes.buffer);\n const float32Array = new Float32Array(int16Array.length);\n\n for (let i = 0; i < int16Array.length; i++) {\n float32Array[i] = int16Array[i] / 32768.0;\n }\n\n return float32Array;\n}\n\nfunction convertFloat32ToInt16(float32Array) {\n const int16Array = new Int16Array(float32Array.length);\n for (let i = 0; i < float32Array.length; i++) {\n // Improved scaling to prevent clipping\n const s = Math.max(-1, Math.min(1, float32Array[i]));\n int16Array[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n return int16Array;\n}\n\nfunction arrayBufferToBase64(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n/* ───────────────────────── JS ↔︎ WASM 헬퍼 ───────────────────────── */\nfunction int16PtrFromFloat32(mod, f32) {\n const len = f32.length;\n const bytes = len * 2;\n const ptr = mod._malloc(bytes);\n // HEAP16이 없으면 HEAPU8.buffer로 직접 래핑\n const heapBuf = (mod.HEAP16 ? mod.HEAP16.buffer : mod.HEAPU8.buffer);\n const i16 = new Int16Array(heapBuf, ptr, len);\n for (let i = 0; i < len; ++i) {\n const s = Math.max(-1, Math.min(1, f32[i]));\n i16[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n return { ptr, view: i16 };\n}\n\nfunction float32FromInt16View(i16) {\n const out = new Float32Array(i16.length);\n for (let i = 0; i < i16.length; ++i) out[i] = i16[i] / 32768;\n return out;\n}\n\n/* 필요하다면 종료 시 */\nfunction disposeAec () {\n getAec().then(mod => { if (aecPtr) mod.destroy(aecPtr); });\n}\n\n// listenCapture.js\n\nfunction runAecSync(micF32, sysF32) {\n if (!aecMod || !aecPtr || !aecMod.HEAPU8) {\n // console.log('🔊 No AEC module or heap buffer');\n return micF32;\n }\n\n const frameSize = 160; // AEC 모듈 초기화 시 설정한 프레임 크기\n const numFrames = Math.floor(micF32.length / frameSize);\n\n // 최종 처리된 오디오 데이터를 담을 버퍼\n const processedF32 = new Float32Array(micF32.length);\n\n // 시스템 오디오와 마이크 오디오의 길이를 맞춥니다. (안정성 확보)\n let alignedSysF32 = new Float32Array(micF32.length);\n if (sysF32.length > 0) {\n // sysF32를 micF32 길이에 맞게 자르거나 채웁니다.\n const lengthToCopy = Math.min(micF32.length, sysF32.length);\n alignedSysF32.set(sysF32.slice(0, lengthToCopy));\n }\n\n\n // 2400개 샘플을 160개 프레임으로 나누어 루프 실행\n for (let i = 0; i < numFrames; i++) {\n const offset = i * frameSize;\n\n // 현재 프레임에 해당하는 160개 샘플을 잘라냅니다.\n const micFrame = micF32.subarray(offset, offset + frameSize);\n const echoFrame = alignedSysF32.subarray(offset, offset + frameSize);\n\n // WASM 메모리에 프레임 데이터 쓰기\n const micPtr = int16PtrFromFloat32(aecMod, micFrame);\n const echoPtr = int16PtrFromFloat32(aecMod, echoFrame);\n const outPtr = aecMod._malloc(frameSize * 2); // 160 * 2 bytes\n\n // AEC 실행 (160개 샘플 단위)\n aecMod.cancel(aecPtr, micPtr.ptr, echoPtr.ptr, outPtr, frameSize);\n\n // WASM 메모리에서 처리된 프레임 데이터 읽기\n const heapBuf = (aecMod.HEAP16 ? aecMod.HEAP16.buffer : aecMod.HEAPU8.buffer);\n const outFrameI16 = new Int16Array(heapBuf, outPtr, frameSize);\n const outFrameF32 = float32FromInt16View(outFrameI16);\n\n // 처리된 프레임을 최종 버퍼의 올바른 위치에 복사\n processedF32.set(outFrameF32, offset);\n\n // 할당된 메모리 해제\n aecMod._free(micPtr.ptr);\n aecMod._free(echoPtr.ptr);\n aecMod._free(outPtr);\n }\n\n return processedF32;\n // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲\n // 여기까지가 새로운 로직\n // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲\n}\n\n\n// System audio data handler\nwindow.api.listenCapture.onSystemAudioData((event, { data }) => {\n systemAudioBuffer.push({\n data: data,\n timestamp: Date.now(),\n });\n\n // 오래된 데이터 제거\n if (systemAudioBuffer.length > MAX_SYSTEM_BUFFER_SIZE) {\n systemAudioBuffer = systemAudioBuffer.slice(-MAX_SYSTEM_BUFFER_SIZE);\n }\n});\n\n// ---------------------------\n// Complete token tracker (exact from renderer.js)\n// ---------------------------\nlet tokenTracker = {\n tokens: [],\n audioStartTime: null,\n\n addTokens(count, type = 'image') {\n const now = Date.now();\n this.tokens.push({\n timestamp: now,\n count: count,\n type: type,\n });\n\n this.cleanOldTokens();\n },\n\n calculateImageTokens(width, height) {\n const pixels = width * height;\n if (pixels <= 384 * 384) {\n return 85;\n }\n\n const tiles = Math.ceil(pixels / (768 * 768));\n return tiles * 85;\n },\n\n trackAudioTokens() {\n if (!this.audioStartTime) {\n this.audioStartTime = Date.now();\n return;\n }\n\n const now = Date.now();\n const elapsedSeconds = (now - this.audioStartTime) / 1000;\n\n const audioTokens = Math.floor(elapsedSeconds * 16);\n\n if (audioTokens > 0) {\n this.addTokens(audioTokens, 'audio');\n this.audioStartTime = now;\n }\n },\n\n cleanOldTokens() {\n const oneMinuteAgo = Date.now() - 60 * 1000;\n this.tokens = this.tokens.filter(token => token.timestamp > oneMinuteAgo);\n },\n\n getTokensInLastMinute() {\n this.cleanOldTokens();\n return this.tokens.reduce((total, token) => total + token.count, 0);\n },\n\n shouldThrottle() {\n const throttleEnabled = localStorage.getItem('throttleTokens') === 'true';\n if (!throttleEnabled) {\n return false;\n }\n\n const maxTokensPerMin = parseInt(localStorage.getItem('maxTokensPerMin') || '500000', 10);\n const throttleAtPercent = parseInt(localStorage.getItem('throttleAtPercent') || '75', 10);\n\n const currentTokens = this.getTokensInLastMinute();\n const throttleThreshold = Math.floor((maxTokensPerMin * throttleAtPercent) / 100);\n\n console.log(`Token check: ${currentTokens}/${maxTokensPerMin} (throttle at ${throttleThreshold})`);\n\n return currentTokens >= throttleThreshold;\n },\n\n // Reset the tracker\n reset() {\n this.tokens = [];\n this.audioStartTime = null;\n },\n};\n\n// Track audio tokens every few seconds\nsetInterval(() => {\n tokenTracker.trackAudioTokens();\n}, 2000);\n\n// ---------------------------\n// Audio processing functions (exact from renderer.js)\n// ---------------------------\nasync function setupMicProcessing(micStream) {\n /* ── WASM 먼저 로드 ───────────────────────── */\n const mod = await getAec();\n if (!aecPtr) aecPtr = mod.newPtr(160, 1600, 24000, 1);\n\n\n const micAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n await micAudioContext.resume(); \n const micSource = micAudioContext.createMediaStreamSource(micStream);\n const micProcessor = micAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n micProcessor.onaudioprocess = (e) => {\n const inputData = e.inputBuffer.getChannelData(0);\n audioBuffer.push(...inputData);\n // console.log('🎤 micProcessor.onaudioprocess');\n\n // samplesPerChunk(=2400) 만큼 모이면 전송\n while (audioBuffer.length >= samplesPerChunk) {\n let chunk = audioBuffer.splice(0, samplesPerChunk);\n let processedChunk = new Float32Array(chunk); // 기본값\n\n // ───────────────── WASM AEC ─────────────────\n if (systemAudioBuffer.length > 0) {\n const latest = systemAudioBuffer[systemAudioBuffer.length - 1];\n const sysF32 = base64ToFloat32Array(latest.data);\n\n // **음성 구간일 때만 런**\n processedChunk = runAecSync(new Float32Array(chunk), sysF32);\n // console.log('🔊 Applied WASM-AEC (speex)');\n } else {\n console.log('🔊 No system audio for AEC reference');\n }\n\n const pcm16 = convertFloat32ToInt16(processedChunk);\n const b64 = arrayBufferToBase64(pcm16.buffer);\n\n window.api.listenCapture.sendMicAudioContent({\n data: b64,\n mimeType: 'audio/pcm;rate=24000',\n });\n }\n };\n\n micSource.connect(micProcessor);\n micProcessor.connect(micAudioContext.destination);\n\n audioProcessor = micProcessor;\n return { context: micAudioContext, processor: micProcessor };\n}\n\nfunction setupLinuxMicProcessing(micStream) {\n // Setup microphone audio processing for Linux\n const micAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n const micSource = micAudioContext.createMediaStreamSource(micStream);\n const micProcessor = micAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n micProcessor.onaudioprocess = async e => {\n const inputData = e.inputBuffer.getChannelData(0);\n audioBuffer.push(...inputData);\n\n // Process audio in chunks\n while (audioBuffer.length >= samplesPerChunk) {\n const chunk = audioBuffer.splice(0, samplesPerChunk);\n const pcmData16 = convertFloat32ToInt16(chunk);\n const base64Data = arrayBufferToBase64(pcmData16.buffer);\n\n await window.api.listenCapture.sendMicAudioContent({\n data: base64Data,\n mimeType: 'audio/pcm;rate=24000',\n });\n }\n };\n\n micSource.connect(micProcessor);\n micProcessor.connect(micAudioContext.destination);\n\n // Store processor reference for cleanup\n audioProcessor = micProcessor;\n}\n\nfunction setupSystemAudioProcessing(systemStream) {\n const systemAudioContext = new AudioContext({ sampleRate: SAMPLE_RATE });\n const systemSource = systemAudioContext.createMediaStreamSource(systemStream);\n const systemProcessor = systemAudioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);\n\n let audioBuffer = [];\n const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;\n\n systemProcessor.onaudioprocess = async e => {\n const inputData = e.inputBuffer.getChannelData(0);\n if (!inputData || inputData.length === 0) return;\n \n audioBuffer.push(...inputData);\n\n while (audioBuffer.length >= samplesPerChunk) {\n const chunk = audioBuffer.splice(0, samplesPerChunk);\n const pcmData16 = convertFloat32ToInt16(chunk);\n const base64Data = arrayBufferToBase64(pcmData16.buffer);\n\n try {\n await window.api.listenCapture.sendSystemAudioContent({\n data: base64Data,\n mimeType: 'audio/pcm;rate=24000',\n });\n } catch (error) {\n console.error('Failed to send system audio:', error);\n }\n }\n };\n\n systemSource.connect(systemProcessor);\n systemProcessor.connect(systemAudioContext.destination);\n\n return { context: systemAudioContext, processor: systemProcessor };\n}\n\n// ---------------------------\n// Main capture functions (exact from renderer.js)\n// ---------------------------\nasync function startCapture(screenshotIntervalSeconds = 5, imageQuality = 'medium') {\n\n // Reset token tracker when starting new capture session\n tokenTracker.reset();\n console.log('🎯 Token tracker reset for new capture session');\n\n try {\n if (isMacOS) {\n\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n\n // On macOS, use SystemAudioDump for audio and getDisplayMedia for screen\n console.log('Starting macOS capture with SystemAudioDump...');\n\n // Start macOS audio capture\n const audioResult = await window.api.listenCapture.startMacosSystemAudio();\n if (!audioResult.success) {\n console.warn('[listenCapture] macOS audio start failed:', audioResult.error);\n\n // 이미 실행 중 → stop 후 재시도\n if (audioResult.error === 'already_running') {\n await window.api.listenCapture.stopMacosSystemAudio();\n await new Promise(r => setTimeout(r, 500));\n const retry = await window.api.listenCapture.startMacosSystemAudio();\n if (!retry.success) {\n throw new Error('Retry failed: ' + retry.error);\n }\n } else {\n throw new Error('Failed to start macOS audio capture: ' + audioResult.error);\n }\n }\n\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n\n console.log('macOS microphone capture started');\n const { context, processor } = await setupMicProcessing(micMediaStream);\n audioContext = context;\n audioProcessor = processor;\n } catch (micErr) {\n console.warn('Failed to get microphone on macOS:', micErr);\n }\n ////////// for index & subjects //////////\n\n console.log('macOS screen capture started - audio handled by SystemAudioDump');\n } else if (isLinux) {\n\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n \n // Linux - use display media for screen capture and getUserMedia for microphone\n mediaStream = await navigator.mediaDevices.getDisplayMedia({\n video: {\n frameRate: 1,\n width: { ideal: 1920 },\n height: { ideal: 1080 },\n },\n audio: false, // Don't use system audio loopback on Linux\n });\n\n // Get microphone input for Linux\n let micMediaStream = null;\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n\n console.log('Linux microphone capture started');\n\n // Setup audio processing for microphone on Linux\n setupLinuxMicProcessing(micMediaStream);\n } catch (micError) {\n console.warn('Failed to get microphone access on Linux:', micError);\n // Continue without microphone if permission denied\n }\n\n console.log('Linux screen capture started');\n } else {\n // Windows - capture mic and system audio separately using native loopback\n console.log('Starting Windows capture with native loopback audio...');\n\n // Ensure STT sessions are initialized before starting audio capture\n const sessionActive = await window.api.listenCapture.isSessionActive();\n if (!sessionActive) {\n throw new Error('STT sessions not initialized - please wait for initialization to complete');\n }\n\n // 1. Get user's microphone\n try {\n micMediaStream = await navigator.mediaDevices.getUserMedia({\n audio: {\n sampleRate: SAMPLE_RATE,\n channelCount: 1,\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n video: false,\n });\n console.log('Windows microphone capture started');\n const { context, processor } = await setupMicProcessing(micMediaStream);\n audioContext = context;\n audioProcessor = processor;\n } catch (micErr) {\n console.warn('Could not get microphone access on Windows:', micErr);\n }\n\n // 2. Get system audio using native Electron loopback\n try {\n mediaStream = await navigator.mediaDevices.getDisplayMedia({\n video: true,\n audio: true // This will now use native loopback from our handler\n });\n \n // Verify we got audio tracks\n const audioTracks = mediaStream.getAudioTracks();\n if (audioTracks.length === 0) {\n throw new Error('No audio track in native loopback stream');\n }\n \n console.log('Windows native loopback audio capture started');\n const { context, processor } = setupSystemAudioProcessing(mediaStream);\n systemAudioContext = context;\n systemAudioProcessor = processor;\n } catch (sysAudioErr) {\n console.error('Failed to start Windows native loopback audio:', sysAudioErr);\n // Continue without system audio\n }\n }\n } catch (err) {\n console.error('Error starting capture:', err);\n // Note: pickleGlass.e() is not available in this context, commenting out\n // pickleGlass.e().setStatus('error');\n }\n}\n\nfunction stopCapture() {\n // Clean up microphone resources\n if (audioProcessor) {\n audioProcessor.disconnect();\n audioProcessor = null;\n }\n if (audioContext) {\n audioContext.close();\n audioContext = null;\n }\n\n // Clean up system audio resources\n if (systemAudioProcessor) {\n systemAudioProcessor.disconnect();\n systemAudioProcessor = null;\n }\n if (systemAudioContext) {\n systemAudioContext.close();\n systemAudioContext = null;\n }\n\n // Stop and release media stream tracks\n if (mediaStream) {\n mediaStream.getTracks().forEach(track => track.stop());\n mediaStream = null;\n }\n if (micMediaStream) {\n micMediaStream.getTracks().forEach(t => t.stop());\n micMediaStream = null;\n }\n\n // Stop macOS audio capture if running\n if (isMacOS) {\n window.api.listenCapture.stopMacosSystemAudio().catch(err => {\n console.error('Error stopping macOS audio:', err);\n });\n }\n}\n\n// ---------------------------\n// Exports & global registration\n// ---------------------------\nmodule.exports = {\n getAec, // 새로 만든 초기화 함수\n runAecSync, // sync 버전\n disposeAec, // 필요시 Rust 객체 파괴\n startCapture,\n stopCapture,\n isLinux,\n isMacOS,\n};\n\n// Expose functions to global scope for external access (exact from renderer.js)\nif (typeof window !== 'undefined') {\n window.listenCapture = module.exports;\n window.pickleGlass = window.pickleGlass || {};\n window.pickleGlass.startCapture = startCapture;\n window.pickleGlass.stopCapture = stopCapture;\n} "], ["/glass/src/window/windowManager.js", "const { BrowserWindow, globalShortcut, screen, app, shell } = require('electron');\nconst WindowLayoutManager = require('./windowLayoutManager');\nconst SmoothMovementManager = require('./smoothMovementManager');\nconst path = require('node:path');\nconst os = require('os');\nconst shortcutsService = require('../features/shortcuts/shortcutsService');\nconst internalBridge = require('../bridge/internalBridge');\nconst permissionRepository = require('../features/common/repositories/permission');\n\n/* ────────────────[ GLASS BYPASS ]─────────────── */\nlet liquidGlass;\nconst isLiquidGlassSupported = () => {\n if (process.platform !== 'darwin') {\n return false;\n }\n const majorVersion = parseInt(os.release().split('.')[0], 10);\n // return majorVersion >= 25; // macOS 26+ (Darwin 25+)\n return majorVersion >= 26; // See you soon!\n};\nlet shouldUseLiquidGlass = isLiquidGlassSupported();\nif (shouldUseLiquidGlass) {\n try {\n liquidGlass = require('electron-liquid-glass');\n } catch (e) {\n console.warn('Could not load optional dependency \"electron-liquid-glass\". The feature will be disabled.');\n shouldUseLiquidGlass = false;\n }\n}\n/* ────────────────[ GLASS BYPASS ]─────────────── */\n\nlet isContentProtectionOn = true;\nlet lastVisibleWindows = new Set(['header']);\n\nlet currentHeaderState = 'apikey';\nconst windowPool = new Map();\n\nlet settingsHideTimer = null;\n\n\nlet layoutManager = null;\nlet movementManager = null;\n\n\nfunction updateChildWindowLayouts(animated = true) {\n // if (movementManager.isAnimating) return;\n\n const visibleWindows = {};\n const listenWin = windowPool.get('listen');\n const askWin = windowPool.get('ask');\n if (listenWin && !listenWin.isDestroyed() && listenWin.isVisible()) {\n visibleWindows.listen = true;\n }\n if (askWin && !askWin.isDestroyed() && askWin.isVisible()) {\n visibleWindows.ask = true;\n }\n\n if (Object.keys(visibleWindows).length === 0) return;\n\n const newLayout = layoutManager.calculateFeatureWindowLayout(visibleWindows);\n movementManager.animateLayout(newLayout, animated);\n}\n\nconst showSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: true });\n};\n\nconst hideSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: false });\n};\n\nconst cancelHideSettingsWindow = () => {\n internalBridge.emit('window:requestVisibility', { name: 'settings', visible: true });\n};\n\nconst moveWindowStep = (direction) => {\n internalBridge.emit('window:moveStep', { direction });\n};\n\nconst resizeHeaderWindow = ({ width, height }) => {\n internalBridge.emit('window:resizeHeaderWindow', { width, height });\n};\n\nconst handleHeaderAnimationFinished = (state) => {\n internalBridge.emit('window:headerAnimationFinished', state);\n};\n\nconst getHeaderPosition = () => {\n return new Promise((resolve) => {\n internalBridge.emit('window:getHeaderPosition', (position) => {\n resolve(position);\n });\n });\n};\n\nconst moveHeaderTo = (newX, newY) => {\n internalBridge.emit('window:moveHeaderTo', { newX, newY });\n};\n\nconst adjustWindowHeight = (winName, targetHeight) => {\n internalBridge.emit('window:adjustWindowHeight', { winName, targetHeight });\n};\n\n\nfunction setupWindowController(windowPool, layoutManager, movementManager) {\n internalBridge.on('window:requestVisibility', ({ name, visible }) => {\n handleWindowVisibilityRequest(windowPool, layoutManager, movementManager, name, visible);\n });\n internalBridge.on('window:requestToggleAllWindowsVisibility', ({ targetVisibility }) => {\n changeAllWindowsVisibility(windowPool, targetVisibility);\n });\n internalBridge.on('window:moveToDisplay', ({ displayId }) => {\n // movementManager.moveToDisplay(displayId);\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateNewPositionForDisplay(header, displayId);\n if (newPosition) {\n movementManager.animateWindowPosition(header, newPosition, {\n onComplete: () => updateChildWindowLayouts(true)\n });\n }\n }\n });\n internalBridge.on('window:moveToEdge', ({ direction }) => {\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateEdgePosition(header, direction);\n movementManager.animateWindowPosition(header, newPosition, { \n onComplete: () => updateChildWindowLayouts(true) \n });\n }\n });\n\n internalBridge.on('window:moveStep', ({ direction }) => {\n const header = windowPool.get('header');\n if (header) { \n const newHeaderPosition = layoutManager.calculateStepMovePosition(header, direction);\n if (!newHeaderPosition) return;\n \n const futureHeaderBounds = { ...header.getBounds(), ...newHeaderPosition };\n const visibleWindows = {};\n const listenWin = windowPool.get('listen');\n const askWin = windowPool.get('ask');\n if (listenWin && !listenWin.isDestroyed() && listenWin.isVisible()) {\n visibleWindows.listen = true;\n }\n if (askWin && !askWin.isDestroyed() && askWin.isVisible()) {\n visibleWindows.ask = true;\n }\n\n const newChildLayout = layoutManager.calculateFeatureWindowLayout(visibleWindows, futureHeaderBounds);\n \n movementManager.animateWindowPosition(header, newHeaderPosition);\n movementManager.animateLayout(newChildLayout);\n }\n });\n\n internalBridge.on('window:resizeHeaderWindow', ({ width, height }) => {\n const header = windowPool.get('header');\n if (!header || movementManager.isAnimating) return;\n\n const newHeaderBounds = layoutManager.calculateHeaderResize(header, { width, height });\n \n const wasResizable = header.isResizable();\n if (!wasResizable) header.setResizable(true);\n\n movementManager.animateWindowBounds(header, newHeaderBounds, {\n onComplete: () => {\n if (!wasResizable) header.setResizable(false);\n updateChildWindowLayouts(true);\n }\n });\n });\n internalBridge.on('window:headerAnimationFinished', (state) => {\n const header = windowPool.get('header');\n if (!header || header.isDestroyed()) return;\n\n if (state === 'hidden') {\n header.hide();\n } else if (state === 'visible') {\n updateChildWindowLayouts(false);\n }\n });\n internalBridge.on('window:getHeaderPosition', (reply) => {\n const header = windowPool.get('header');\n if (header && !header.isDestroyed()) {\n reply(header.getBounds());\n } else {\n reply({ x: 0, y: 0, width: 0, height: 0 });\n }\n });\n internalBridge.on('window:moveHeaderTo', ({ newX, newY }) => {\n const header = windowPool.get('header');\n if (header) {\n const newPosition = layoutManager.calculateClampedPosition(header, { x: newX, y: newY });\n header.setPosition(newPosition.x, newPosition.y);\n }\n });\n internalBridge.on('window:adjustWindowHeight', ({ winName, targetHeight }) => {\n console.log(`[Layout Debug] adjustWindowHeight: targetHeight=${targetHeight}`);\n const senderWindow = windowPool.get(winName);\n if (senderWindow) {\n const newBounds = layoutManager.calculateWindowHeightAdjustment(senderWindow, targetHeight);\n \n const wasResizable = senderWindow.isResizable();\n if (!wasResizable) senderWindow.setResizable(true);\n\n movementManager.animateWindowBounds(senderWindow, newBounds, {\n onComplete: () => {\n if (!wasResizable) senderWindow.setResizable(false);\n updateChildWindowLayouts(true);\n }\n });\n }\n });\n}\n\nfunction changeAllWindowsVisibility(windowPool, targetVisibility) {\n const header = windowPool.get('header');\n if (!header) return;\n\n if (typeof targetVisibility === 'boolean' &&\n header.isVisible() === targetVisibility) {\n return;\n }\n \n if (header.isVisible()) {\n lastVisibleWindows.clear();\n \n windowPool.forEach((win, name) => {\n if (win && !win.isDestroyed() && win.isVisible()) {\n lastVisibleWindows.add(name);\n }\n });\n \n lastVisibleWindows.forEach(name => {\n if (name === 'header') return;\n const win = windowPool.get(name);\n if (win && !win.isDestroyed()) win.hide();\n });\n header.hide();\n \n return;\n }\n \n lastVisibleWindows.forEach(name => {\n const win = windowPool.get(name);\n if (win && !win.isDestroyed())\n win.show();\n });\n }\n\n/**\n * \n * @param {Map} windowPool\n * @param {WindowLayoutManager} layoutManager \n * @param {SmoothMovementManager} movementManager\n * @param {'listen' | 'ask' | 'settings' | 'shortcut-settings'} name \n * @param {boolean} shouldBeVisible \n */\nasync function handleWindowVisibilityRequest(windowPool, layoutManager, movementManager, name, shouldBeVisible) {\n console.log(`[WindowManager] Request: set '${name}' visibility to ${shouldBeVisible}`);\n const win = windowPool.get(name);\n\n if (!win || win.isDestroyed()) {\n console.warn(`[WindowManager] Window '${name}' not found or destroyed.`);\n return;\n }\n\n if (name !== 'settings') {\n const isCurrentlyVisible = win.isVisible();\n if (isCurrentlyVisible === shouldBeVisible) {\n console.log(`[WindowManager] Window '${name}' is already in the desired state.`);\n return;\n }\n }\n\n const disableClicks = (selectedWindow) => {\n for (const [name, win] of windowPool) {\n if (win !== selectedWindow && !win.isDestroyed()) {\n win.setIgnoreMouseEvents(true, { forward: true });\n }\n }\n };\n\n const restoreClicks = () => {\n for (const [, win] of windowPool) {\n if (!win.isDestroyed()) win.setIgnoreMouseEvents(false);\n }\n };\n\n if (name === 'settings') {\n if (shouldBeVisible) {\n // Cancel any pending hide operations\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n settingsHideTimer = null;\n }\n const position = layoutManager.calculateSettingsWindowPosition();\n if (position) {\n win.setBounds(position);\n win.__lockedByButton = true;\n win.show();\n win.moveTop();\n win.setAlwaysOnTop(true);\n } else {\n console.warn('[WindowManager] Could not calculate settings window position.');\n }\n } else {\n // Hide after a delay\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n }\n settingsHideTimer = setTimeout(() => {\n if (win && !win.isDestroyed()) {\n win.setAlwaysOnTop(false);\n win.hide();\n }\n settingsHideTimer = null;\n }, 200);\n\n win.__lockedByButton = false;\n }\n return;\n }\n\n\n if (name === 'shortcut-settings') {\n if (shouldBeVisible) {\n // layoutManager.positionShortcutSettingsWindow();\n const newBounds = layoutManager.calculateShortcutSettingsWindowPosition();\n if (newBounds) win.setBounds(newBounds);\n \n if (process.platform === 'darwin') {\n win.setAlwaysOnTop(true, 'screen-saver');\n } else {\n win.setAlwaysOnTop(true);\n }\n // globalShortcut.unregisterAll();\n disableClicks(win);\n win.show();\n } else {\n if (process.platform === 'darwin') {\n win.setAlwaysOnTop(false, 'screen-saver');\n } else {\n win.setAlwaysOnTop(false);\n }\n restoreClicks();\n win.hide();\n }\n return;\n }\n\n if (name === 'listen' || name === 'ask') {\n const win = windowPool.get(name);\n const otherName = name === 'listen' ? 'ask' : 'listen';\n const otherWin = windowPool.get(otherName);\n const isOtherWinVisible = otherWin && !otherWin.isDestroyed() && otherWin.isVisible();\n \n const ANIM_OFFSET_X = 50;\n const ANIM_OFFSET_Y = 20;\n\n const finalVisibility = {\n listen: (name === 'listen' && shouldBeVisible) || (otherName === 'listen' && isOtherWinVisible),\n ask: (name === 'ask' && shouldBeVisible) || (otherName === 'ask' && isOtherWinVisible),\n };\n if (!shouldBeVisible) {\n finalVisibility[name] = false;\n }\n\n const targetLayout = layoutManager.calculateFeatureWindowLayout(finalVisibility);\n\n if (shouldBeVisible) {\n if (!win) return;\n const targetBounds = targetLayout[name];\n if (!targetBounds) return;\n\n const startPos = { ...targetBounds };\n if (name === 'listen') startPos.x -= ANIM_OFFSET_X;\n else if (name === 'ask') startPos.y -= ANIM_OFFSET_Y;\n\n win.setOpacity(0);\n win.setBounds(startPos);\n win.show();\n\n movementManager.fade(win, { to: 1 });\n movementManager.animateLayout(targetLayout);\n\n } else {\n if (!win || !win.isVisible()) return;\n\n const currentBounds = win.getBounds();\n const targetPos = { ...currentBounds };\n if (name === 'listen') targetPos.x -= ANIM_OFFSET_X;\n else if (name === 'ask') targetPos.y -= ANIM_OFFSET_Y;\n\n movementManager.fade(win, { to: 0, onComplete: () => win.hide() });\n movementManager.animateWindowPosition(win, targetPos);\n \n // 다른 창들도 새 레이아웃으로 애니메이션\n const otherWindowsLayout = { ...targetLayout };\n delete otherWindowsLayout[name];\n movementManager.animateLayout(otherWindowsLayout);\n }\n }\n}\n\n\nconst setContentProtection = (status) => {\n isContentProtectionOn = status;\n console.log(`[Protection] Content protection toggled to: ${isContentProtectionOn}`);\n windowPool.forEach(win => {\n if (win && !win.isDestroyed()) {\n win.setContentProtection(isContentProtectionOn);\n }\n });\n};\n\nconst getContentProtectionStatus = () => isContentProtectionOn;\n\nconst toggleContentProtection = () => {\n const newStatus = !getContentProtectionStatus();\n setContentProtection(newStatus);\n return newStatus;\n};\n\n\nconst openLoginPage = () => {\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n const personalizeUrl = `${webUrl}/personalize?desktop=true`;\n shell.openExternal(personalizeUrl);\n console.log('Opening personalization page:', personalizeUrl);\n};\n\n\nfunction createFeatureWindows(header, namesToCreate) {\n // if (windowPool.has('listen')) return;\n\n const commonChildOptions = {\n parent: header,\n show: false,\n frame: false,\n transparent: true,\n vibrancy: false,\n hasShadow: false,\n skipTaskbar: true,\n hiddenInMissionControl: true,\n resizable: false,\n webPreferences: {\n nodeIntegration: false,\n contextIsolation: true,\n preload: path.join(__dirname, '../preload.js'),\n },\n };\n\n const createFeatureWindow = (name) => {\n if (windowPool.has(name)) return;\n \n switch (name) {\n case 'listen': {\n const listen = new BrowserWindow({\n ...commonChildOptions, width:400,minWidth:400,maxWidth:900,\n maxHeight:900,\n });\n listen.setContentProtection(isContentProtectionOn);\n listen.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n listen.setWindowButtonVisibility(false);\n }\n const listenLoadOptions = { query: { view: 'listen' } };\n if (!shouldUseLiquidGlass) {\n listen.loadFile(path.join(__dirname, '../ui/app/content.html'), listenLoadOptions);\n }\n else {\n listenLoadOptions.query.glass = 'true';\n listen.loadFile(path.join(__dirname, '../ui/app/content.html'), listenLoadOptions);\n listen.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(listen.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n if (!app.isPackaged) {\n listen.webContents.openDevTools({ mode: 'detach' });\n }\n windowPool.set('listen', listen);\n break;\n }\n\n // ask\n case 'ask': {\n const ask = new BrowserWindow({ ...commonChildOptions, width:600 });\n ask.setContentProtection(isContentProtectionOn);\n ask.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n ask.setWindowButtonVisibility(false);\n }\n const askLoadOptions = { query: { view: 'ask' } };\n if (!shouldUseLiquidGlass) {\n ask.loadFile(path.join(__dirname, '../ui/app/content.html'), askLoadOptions);\n }\n else {\n askLoadOptions.query.glass = 'true';\n ask.loadFile(path.join(__dirname, '../ui/app/content.html'), askLoadOptions);\n ask.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(ask.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n \n // Open DevTools in development\n if (!app.isPackaged) {\n ask.webContents.openDevTools({ mode: 'detach' });\n }\n windowPool.set('ask', ask);\n break;\n }\n\n // settings\n case 'settings': {\n const settings = new BrowserWindow({ ...commonChildOptions, width:240, maxHeight:400, parent:undefined });\n settings.setContentProtection(isContentProtectionOn);\n settings.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n settings.setWindowButtonVisibility(false);\n }\n const settingsLoadOptions = { query: { view: 'settings' } };\n if (!shouldUseLiquidGlass) {\n settings.loadFile(path.join(__dirname,'../ui/app/content.html'), settingsLoadOptions)\n .catch(console.error);\n }\n else {\n settingsLoadOptions.query.glass = 'true';\n settings.loadFile(path.join(__dirname,'../ui/app/content.html'), settingsLoadOptions)\n .catch(console.error);\n settings.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(settings.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1);\n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n windowPool.set('settings', settings); \n\n if (!app.isPackaged) {\n settings.webContents.openDevTools({ mode: 'detach' });\n }\n break;\n }\n\n case 'shortcut-settings': {\n const shortcutEditor = new BrowserWindow({\n ...commonChildOptions,\n width: 353,\n height: 720,\n modal: false,\n parent: undefined,\n alwaysOnTop: true,\n titleBarOverlay: false,\n });\n\n shortcutEditor.setContentProtection(isContentProtectionOn);\n shortcutEditor.setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true});\n if (process.platform === 'darwin') {\n shortcutEditor.setWindowButtonVisibility(false);\n }\n\n const loadOptions = { query: { view: 'shortcut-settings' } };\n if (!shouldUseLiquidGlass) {\n shortcutEditor.loadFile(path.join(__dirname, '../ui/app/content.html'), loadOptions);\n } else {\n loadOptions.query.glass = 'true';\n shortcutEditor.loadFile(path.join(__dirname, '../ui/app/content.html'), loadOptions);\n shortcutEditor.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(shortcutEditor.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n }\n });\n }\n\n windowPool.set('shortcut-settings', shortcutEditor);\n if (!app.isPackaged) {\n shortcutEditor.webContents.openDevTools({ mode: 'detach' });\n }\n break;\n }\n }\n };\n\n if (Array.isArray(namesToCreate)) {\n namesToCreate.forEach(name => createFeatureWindow(name));\n } else if (typeof namesToCreate === 'string') {\n createFeatureWindow(namesToCreate);\n } else {\n createFeatureWindow('listen');\n createFeatureWindow('ask');\n createFeatureWindow('settings');\n createFeatureWindow('shortcut-settings');\n }\n}\n\nfunction destroyFeatureWindows() {\n const featureWindows = ['listen','ask','settings','shortcut-settings'];\n if (settingsHideTimer) {\n clearTimeout(settingsHideTimer);\n settingsHideTimer = null;\n }\n featureWindows.forEach(name=>{\n const win = windowPool.get(name);\n if (win && !win.isDestroyed()) win.destroy();\n windowPool.delete(name);\n });\n}\n\n\n\nfunction getCurrentDisplay(window) {\n if (!window || window.isDestroyed()) return screen.getPrimaryDisplay();\n\n const windowBounds = window.getBounds();\n const windowCenter = {\n x: windowBounds.x + windowBounds.width / 2,\n y: windowBounds.y + windowBounds.height / 2,\n };\n\n return screen.getDisplayNearestPoint(windowCenter);\n}\n\n\n\nfunction createWindows() {\n const HEADER_HEIGHT = 47;\n const DEFAULT_WINDOW_WIDTH = 353;\n\n const primaryDisplay = screen.getPrimaryDisplay();\n const { y: workAreaY, width: screenWidth } = primaryDisplay.workArea;\n\n const initialX = Math.round((screenWidth - DEFAULT_WINDOW_WIDTH) / 2);\n const initialY = workAreaY + 21;\n \n const header = new BrowserWindow({\n width: DEFAULT_WINDOW_WIDTH,\n height: HEADER_HEIGHT,\n x: initialX,\n y: initialY,\n frame: false,\n transparent: true,\n vibrancy: false,\n hasShadow: false,\n alwaysOnTop: true,\n skipTaskbar: true,\n hiddenInMissionControl: true,\n resizable: false,\n focusable: true,\n acceptFirstMouse: true,\n webPreferences: {\n nodeIntegration: false,\n contextIsolation: true,\n preload: path.join(__dirname, '../preload.js'),\n backgroundThrottling: false,\n webSecurity: false,\n enableRemoteModule: false,\n // Ensure proper rendering and prevent pixelation\n experimentalFeatures: false,\n },\n // Prevent pixelation and ensure proper rendering\n useContentSize: true,\n disableAutoHideCursor: true,\n });\n if (process.platform === 'darwin') {\n header.setWindowButtonVisibility(false);\n }\n const headerLoadOptions = {};\n if (!shouldUseLiquidGlass) {\n header.loadFile(path.join(__dirname, '../ui/app/header.html'), headerLoadOptions);\n }\n else {\n headerLoadOptions.query = { glass: 'true' };\n header.loadFile(path.join(__dirname, '../ui/app/header.html'), headerLoadOptions);\n header.webContents.once('did-finish-load', () => {\n const viewId = liquidGlass.addView(header.getNativeWindowHandle());\n if (viewId !== -1) {\n liquidGlass.unstable_setVariant(viewId, liquidGlass.GlassMaterialVariant.bubbles);\n // liquidGlass.unstable_setScrim(viewId, 1); \n // liquidGlass.unstable_setSubdued(viewId, 1);\n }\n });\n }\n windowPool.set('header', header);\n layoutManager = new WindowLayoutManager(windowPool);\n movementManager = new SmoothMovementManager(windowPool);\n\n\n header.on('moved', () => {\n if (movementManager.isAnimating) {\n return;\n }\n updateChildWindowLayouts(false);\n });\n\n header.webContents.once('dom-ready', () => {\n shortcutsService.initialize(windowPool);\n shortcutsService.registerShortcuts();\n });\n\n setupIpcHandlers(windowPool, layoutManager);\n setupWindowController(windowPool, layoutManager, movementManager);\n\n if (currentHeaderState === 'main') {\n createFeatureWindows(header, ['listen', 'ask', 'settings', 'shortcut-settings']);\n }\n\n header.setContentProtection(isContentProtectionOn);\n header.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });\n \n // Open DevTools in development\n if (!app.isPackaged) {\n header.webContents.openDevTools({ mode: 'detach' });\n }\n\n header.on('focus', () => {\n console.log('[WindowManager] Header gained focus');\n });\n\n header.on('blur', () => {\n console.log('[WindowManager] Header lost focus');\n });\n\n header.webContents.on('before-input-event', (event, input) => {\n if (input.type === 'mouseDown') {\n const target = input.target;\n if (target && (target.includes('input') || target.includes('apikey'))) {\n header.focus();\n }\n }\n });\n\n header.on('resize', () => updateChildWindowLayouts(false));\n\n return windowPool;\n}\n\n\nfunction setupIpcHandlers(windowPool, layoutManager) {\n screen.on('display-added', (event, newDisplay) => {\n console.log('[Display] New display added:', newDisplay.id);\n });\n\n screen.on('display-removed', (event, oldDisplay) => {\n console.log('[Display] Display removed:', oldDisplay.id);\n const header = windowPool.get('header');\n\n if (header && getCurrentDisplay(header).id === oldDisplay.id) {\n const primaryDisplay = screen.getPrimaryDisplay();\n const newPosition = layoutManager.calculateNewPositionForDisplay(header, primaryDisplay.id);\n if (newPosition) {\n // 복구 상황이므로 애니메이션 없이 즉시 이동\n header.setPosition(newPosition.x, newPosition.y, false);\n updateChildWindowLayouts(false);\n }\n }\n });\n\n screen.on('display-metrics-changed', (event, display, changedMetrics) => {\n // 레이아웃 업데이트 함수를 새 버전으로 호출\n updateChildWindowLayouts(false);\n });\n}\n\n\nconst handleHeaderStateChanged = (state) => {\n console.log(`[WindowManager] Header state changed to: ${state}`);\n currentHeaderState = state;\n\n if (state === 'main') {\n createFeatureWindows(windowPool.get('header'));\n } else { // 'apikey' | 'permission'\n destroyFeatureWindows();\n }\n internalBridge.emit('reregister-shortcuts');\n};\n\n\nmodule.exports = {\n createWindows,\n windowPool,\n toggleContentProtection,\n resizeHeaderWindow,\n getContentProtectionStatus,\n showSettingsWindow,\n hideSettingsWindow,\n cancelHideSettingsWindow,\n openLoginPage,\n moveWindowStep,\n handleHeaderStateChanged,\n handleHeaderAnimationFinished,\n getHeaderPosition,\n moveHeaderTo,\n adjustWindowHeight,\n};"], ["/glass/src/features/common/services/authService.js", "const { onAuthStateChanged, signInWithCustomToken, signOut } = require('firebase/auth');\nconst { BrowserWindow, shell } = require('electron');\nconst { getFirebaseAuth } = require('./firebaseClient');\nconst fetch = require('node-fetch');\nconst encryptionService = require('./encryptionService');\nconst migrationService = require('./migrationService');\nconst sessionRepository = require('../repositories/session');\nconst providerSettingsRepository = require('../repositories/providerSettings');\nconst permissionService = require('./permissionService');\n\nasync function getVirtualKeyByEmail(email, idToken) {\n if (!idToken) {\n throw new Error('Firebase ID token is required for virtual key request');\n }\n\n const resp = await fetch('https://serverless-api-sf3o.vercel.app/api/virtual_key', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${idToken}`,\n },\n body: JSON.stringify({ email: email.trim().toLowerCase() }),\n redirect: 'follow',\n });\n\n const json = await resp.json().catch(() => ({}));\n if (!resp.ok) {\n console.error('[VK] API request failed:', json.message || 'Unknown error');\n throw new Error(json.message || `HTTP ${resp.status}: Virtual key request failed`);\n }\n\n const vKey = json?.data?.virtualKey || json?.data?.virtual_key || json?.data?.newVKey?.slug;\n\n if (!vKey) throw new Error('virtual key missing in response');\n return vKey;\n}\n\nclass AuthService {\n constructor() {\n this.currentUserId = 'default_user';\n this.currentUserMode = 'local'; // 'local' or 'firebase'\n this.currentUser = null;\n this.isInitialized = false;\n\n // This ensures the key is ready before any login/logout state change.\n this.initializationPromise = null;\n\n sessionRepository.setAuthService(this);\n }\n\n initialize() {\n if (this.isInitialized) return this.initializationPromise;\n\n this.initializationPromise = new Promise((resolve) => {\n const auth = getFirebaseAuth();\n onAuthStateChanged(auth, async (user) => {\n const previousUser = this.currentUser;\n\n if (user) {\n // User signed IN\n console.log(`[AuthService] Firebase user signed in:`, user.uid);\n this.currentUser = user;\n this.currentUserId = user.uid;\n this.currentUserMode = 'firebase';\n\n // Clean up any zombie sessions from a previous run for this user.\n await sessionRepository.endAllActiveSessions();\n\n // ** Initialize encryption key for the logged-in user if permissions are already granted **\n if (process.platform === 'darwin' && !(await permissionService.checkKeychainCompleted(this.currentUserId))) {\n console.warn('[AuthService] Keychain permission not yet completed for this user. Deferring key initialization.');\n } else {\n await encryptionService.initializeKey(user.uid);\n }\n\n // ** Check for and run data migration for the user **\n // No 'await' here, so it runs in the background without blocking startup.\n migrationService.checkAndRunMigration(user);\n\n // ***** CRITICAL: Wait for the virtual key and model state update to complete *****\n try {\n const idToken = await user.getIdToken(true);\n const virtualKey = await getVirtualKeyByEmail(user.email, idToken);\n\n if (global.modelStateService) {\n // The model state service now writes directly to the DB, no in-memory state.\n await global.modelStateService.setFirebaseVirtualKey(virtualKey);\n }\n console.log(`[AuthService] Virtual key for ${user.email} has been processed and state updated.`);\n\n } catch (error) {\n console.error('[AuthService] Failed to fetch or save virtual key:', error);\n // This is not critical enough to halt the login, but we should log it.\n }\n\n } else {\n // User signed OUT\n console.log(`[AuthService] No Firebase user.`);\n if (previousUser) {\n console.log(`[AuthService] Clearing API key for logged-out user: ${previousUser.uid}`);\n if (global.modelStateService) {\n // The model state service now writes directly to the DB.\n await global.modelStateService.setFirebaseVirtualKey(null);\n }\n }\n this.currentUser = null;\n this.currentUserId = 'default_user';\n this.currentUserMode = 'local';\n\n // End active sessions for the local/default user as well.\n await sessionRepository.endAllActiveSessions();\n\n encryptionService.resetSessionKey();\n }\n this.broadcastUserState();\n \n if (!this.isInitialized) {\n this.isInitialized = true;\n console.log('[AuthService] Initialized and resolved initialization promise.');\n resolve();\n }\n });\n });\n\n return this.initializationPromise;\n }\n\n async startFirebaseAuthFlow() {\n try {\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n const authUrl = `${webUrl}/login?mode=electron`;\n console.log(`[AuthService] Opening Firebase auth URL in browser: ${authUrl}`);\n await shell.openExternal(authUrl);\n return { success: true };\n } catch (error) {\n console.error('[AuthService] Failed to open Firebase auth URL:', error);\n return { success: false, error: error.message };\n }\n }\n\n async signInWithCustomToken(token) {\n const auth = getFirebaseAuth();\n try {\n const userCredential = await signInWithCustomToken(auth, token);\n console.log(`[AuthService] Successfully signed in with custom token for user:`, userCredential.user.uid);\n // onAuthStateChanged will handle the state update and broadcast\n } catch (error) {\n console.error('[AuthService] Error signing in with custom token:', error);\n throw error; // Re-throw to be handled by the caller\n }\n }\n\n async signOut() {\n const auth = getFirebaseAuth();\n try {\n // End all active sessions for the current user BEFORE signing out.\n await sessionRepository.endAllActiveSessions();\n\n await signOut(auth);\n console.log('[AuthService] User sign-out initiated successfully.');\n // onAuthStateChanged will handle the state update and broadcast,\n // which will also re-evaluate the API key status.\n } catch (error) {\n console.error('[AuthService] Error signing out:', error);\n }\n }\n \n broadcastUserState() {\n const userState = this.getCurrentUser();\n console.log('[AuthService] Broadcasting user state change:', userState);\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed() && win.webContents && !win.webContents.isDestroyed()) {\n win.webContents.send('user-state-changed', userState);\n }\n });\n }\n\n getCurrentUserId() {\n return this.currentUserId;\n }\n\n getCurrentUser() {\n const isLoggedIn = !!(this.currentUserMode === 'firebase' && this.currentUser);\n\n if (isLoggedIn) {\n return {\n uid: this.currentUser.uid,\n email: this.currentUser.email,\n displayName: this.currentUser.displayName,\n mode: 'firebase',\n isLoggedIn: true,\n //////// before_modelStateService ////////\n // hasApiKey: this.hasApiKey // Always true for firebase users, but good practice\n //////// before_modelStateService ////////\n };\n }\n return {\n uid: this.currentUserId, // returns 'default_user'\n email: 'contact@pickle.com',\n displayName: 'Default User',\n mode: 'local',\n isLoggedIn: false,\n //////// before_modelStateService ////////\n // hasApiKey: this.hasApiKey\n //////// before_modelStateService ////////\n };\n }\n}\n\nconst authService = new AuthService();\nmodule.exports = authService; "], ["/glass/src/ui/settings/SettingsView.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n// import { getOllamaProgressTracker } from '../../features/common/services/localProgressTracker.js'; // 제거됨\n\nexport class SettingsView extends LitElement {\n static styles = css`\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n :host {\n display: block;\n width: 240px;\n height: 100%;\n color: white;\n }\n\n .settings-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: rgba(20, 20, 20, 0.8);\n border-radius: 12px;\n outline: 0.5px rgba(255, 255, 255, 0.2) solid;\n outline-offset: -1px;\n box-sizing: border-box;\n position: relative;\n overflow-y: auto;\n padding: 12px 12px;\n z-index: 1000;\n }\n\n .settings-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .settings-container::-webkit-scrollbar-track {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n }\n\n .settings-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n }\n\n .settings-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .settings-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n filter: blur(10px);\n z-index: -1;\n }\n \n .settings-button[disabled],\n .api-key-section input[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .header-section {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n padding-bottom: 6px;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n position: relative;\n z-index: 1;\n }\n\n .title-line {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .app-title {\n font-size: 13px;\n font-weight: 500;\n color: white;\n margin: 0 0 4px 0;\n }\n\n .account-info {\n font-size: 11px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n }\n\n .invisibility-icon {\n padding-top: 2px;\n opacity: 0;\n transition: opacity 0.3s ease;\n }\n\n .invisibility-icon.visible {\n opacity: 1;\n }\n\n .invisibility-icon svg {\n width: 16px;\n height: 16px;\n }\n\n .shortcuts-section {\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: 4px 0;\n position: relative;\n z-index: 1;\n }\n\n .shortcut-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 0;\n color: white;\n font-size: 11px;\n }\n\n .shortcut-name {\n font-weight: 300;\n }\n\n .shortcut-keys {\n display: flex;\n align-items: center;\n gap: 3px;\n }\n\n .cmd-key, .shortcut-key {\n background: rgba(255, 255, 255, 0.1);\n border-radius: 3px;\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 11px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.9);\n }\n\n /* Buttons Section */\n .buttons-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n padding-top: 6px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n position: relative;\n z-index: 1;\n flex: 1;\n }\n\n .settings-button {\n background: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-radius: 4px;\n color: white;\n padding: 5px 10px;\n font-size: 11px;\n font-weight: 400;\n cursor: pointer;\n transition: all 0.15s ease;\n display: flex;\n align-items: center;\n justify-content: center;\n white-space: nowrap;\n }\n\n .settings-button:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .settings-button:active {\n transform: translateY(1px);\n }\n\n .settings-button.full-width {\n width: 100%;\n }\n\n .settings-button.half-width {\n flex: 1;\n }\n\n .settings-button.danger {\n background: rgba(255, 59, 48, 0.1);\n border-color: rgba(255, 59, 48, 0.3);\n color: rgba(255, 59, 48, 0.9);\n }\n\n .settings-button.danger:hover {\n background: rgba(255, 59, 48, 0.15);\n border-color: rgba(255, 59, 48, 0.4);\n }\n\n .move-buttons, .bottom-buttons {\n display: flex;\n gap: 4px;\n }\n\n .api-key-section {\n padding: 6px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .api-key-section input {\n width: 100%;\n background: rgba(0,0,0,0.2);\n border: 1px solid rgba(255,255,255,0.2);\n color: white;\n border-radius: 4px;\n padding: 4px;\n font-size: 11px;\n margin-bottom: 4px;\n box-sizing: border-box;\n }\n\n .api-key-section input::placeholder {\n color: rgba(255, 255, 255, 0.4);\n }\n\n /* Preset Management Section */\n .preset-section {\n padding: 6px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .preset-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 4px;\n }\n\n .preset-title {\n font-size: 11px;\n font-weight: 500;\n color: white;\n }\n\n .preset-count {\n font-size: 9px;\n color: rgba(255, 255, 255, 0.5);\n margin-left: 4px;\n }\n\n .preset-toggle {\n font-size: 10px;\n color: rgba(255, 255, 255, 0.6);\n cursor: pointer;\n padding: 2px 4px;\n border-radius: 2px;\n transition: background-color 0.15s ease;\n }\n\n .preset-toggle:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .preset-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n max-height: 120px;\n overflow-y: auto;\n }\n\n .preset-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 6px;\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n cursor: pointer;\n transition: all 0.15s ease;\n font-size: 11px;\n border: 1px solid transparent;\n }\n\n .preset-item:hover {\n background: rgba(255, 255, 255, 0.1);\n border-color: rgba(255, 255, 255, 0.1);\n }\n\n .preset-item.selected {\n background: rgba(0, 122, 255, 0.25);\n border-color: rgba(0, 122, 255, 0.6);\n box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.3);\n }\n\n .preset-name {\n color: white;\n flex: 1;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n font-weight: 300;\n }\n\n .preset-item.selected .preset-name {\n font-weight: 500;\n }\n\n .preset-status {\n font-size: 9px;\n color: rgba(0, 122, 255, 0.8);\n font-weight: 500;\n margin-left: 6px;\n }\n\n .no-presets-message {\n padding: 12px 8px;\n text-align: center;\n color: rgba(255, 255, 255, 0.5);\n font-size: 10px;\n line-height: 1.4;\n }\n\n .no-presets-message .web-link {\n color: rgba(0, 122, 255, 0.8);\n text-decoration: underline;\n cursor: pointer;\n }\n\n .no-presets-message .web-link:hover {\n color: rgba(0, 122, 255, 1);\n }\n\n .loading-state {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n color: rgba(255, 255, 255, 0.7);\n font-size: 11px;\n }\n\n .loading-spinner {\n width: 12px;\n height: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-top: 1px solid rgba(255, 255, 255, 0.8);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin-right: 6px;\n }\n\n .hidden {\n display: none;\n }\n\n .api-key-section, .model-selection-section {\n padding: 8px 0;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .provider-key-group, .model-select-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n label {\n font-size: 11px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.8);\n margin-left: 2px;\n }\n label > strong {\n color: white;\n font-weight: 600;\n }\n .provider-key-group input {\n width: 100%; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.2);\n color: white; border-radius: 4px; padding: 5px 8px; font-size: 11px; box-sizing: border-box;\n }\n .key-buttons { display: flex; gap: 4px; }\n .key-buttons .settings-button { flex: 1; padding: 4px; }\n .model-list {\n display: flex; flex-direction: column; gap: 2px; max-height: 120px;\n overflow-y: auto; background: rgba(0,0,0,0.3); border-radius: 4px;\n padding: 4px; margin-top: 4px;\n }\n .model-item { \n padding: 5px 8px; \n font-size: 11px; \n border-radius: 3px; \n cursor: pointer; \n transition: background-color 0.15s; \n display: flex; \n justify-content: space-between; \n align-items: center; \n }\n .model-item:hover { background-color: rgba(255,255,255,0.1); }\n .model-item.selected { background-color: rgba(0, 122, 255, 0.4); font-weight: 500; }\n .model-status { \n font-size: 9px; \n color: rgba(255,255,255,0.6); \n margin-left: 8px; \n }\n .model-status.installed { color: rgba(0, 255, 0, 0.8); }\n .model-status.not-installed { color: rgba(255, 200, 0, 0.8); }\n .install-progress {\n flex: 1;\n height: 4px;\n background: rgba(255,255,255,0.1);\n border-radius: 2px;\n margin-left: 8px;\n overflow: hidden;\n }\n .install-progress-bar {\n height: 100%;\n background: rgba(0, 122, 255, 0.8);\n transition: width 0.3s ease;\n }\n \n /* Dropdown styles */\n select.model-dropdown {\n background: rgba(0,0,0,0.2);\n color: white;\n cursor: pointer;\n }\n \n select.model-dropdown option {\n background: #1a1a1a;\n color: white;\n }\n \n select.model-dropdown option:disabled {\n color: rgba(255,255,255,0.4);\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n\n :host-context(body.has-glass) * {\n background: transparent !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n outline: none !important;\n border: none !important;\n border-radius: 0 !important;\n transition: none !important;\n animation: none !important;\n }\n\n :host-context(body.has-glass) .settings-container::before {\n display: none !important;\n }\n `;\n\n\n //////// after_modelStateService ////////\n static properties = {\n shortcuts: { type: Object, state: true },\n firebaseUser: { type: Object, state: true },\n isLoading: { type: Boolean, state: true },\n isContentProtectionOn: { type: Boolean, state: true },\n saving: { type: Boolean, state: true },\n providerConfig: { type: Object, state: true },\n apiKeys: { type: Object, state: true },\n availableLlmModels: { type: Array, state: true },\n availableSttModels: { type: Array, state: true },\n selectedLlm: { type: String, state: true },\n selectedStt: { type: String, state: true },\n isLlmListVisible: { type: Boolean },\n isSttListVisible: { type: Boolean },\n presets: { type: Array, state: true },\n selectedPreset: { type: Object, state: true },\n showPresets: { type: Boolean, state: true },\n autoUpdateEnabled: { type: Boolean, state: true },\n autoUpdateLoading: { type: Boolean, state: true },\n // Ollama related properties\n ollamaStatus: { type: Object, state: true },\n ollamaModels: { type: Array, state: true },\n installingModels: { type: Object, state: true },\n // Whisper related properties\n whisperModels: { type: Array, state: true },\n };\n //////// after_modelStateService ////////\n\n constructor() {\n super();\n //////// after_modelStateService ////////\n this.shortcuts = {};\n this.firebaseUser = null;\n this.apiKeys = { openai: '', gemini: '', anthropic: '', whisper: '' };\n this.providerConfig = {};\n this.isLoading = true;\n this.isContentProtectionOn = true;\n this.saving = false;\n this.availableLlmModels = [];\n this.availableSttModels = [];\n this.selectedLlm = null;\n this.selectedStt = null;\n this.isLlmListVisible = false;\n this.isSttListVisible = false;\n this.presets = [];\n this.selectedPreset = null;\n this.showPresets = false;\n // Ollama related\n this.ollamaStatus = { installed: false, running: false };\n this.ollamaModels = [];\n this.installingModels = {}; // { modelName: progress }\n // Whisper related\n this.whisperModels = [];\n this.whisperProgressTracker = null; // Will be initialized when needed\n this.handleUsePicklesKey = this.handleUsePicklesKey.bind(this)\n this.autoUpdateEnabled = true;\n this.autoUpdateLoading = true;\n this.loadInitialData();\n //////// after_modelStateService ////////\n }\n\n async loadAutoUpdateSetting() {\n if (!window.api) return;\n this.autoUpdateLoading = true;\n try {\n const enabled = await window.api.settingsView.getAutoUpdate();\n this.autoUpdateEnabled = enabled;\n console.log('Auto-update setting loaded:', enabled);\n } catch (e) {\n console.error('Error loading auto-update setting:', e);\n this.autoUpdateEnabled = true; // fallback\n }\n this.autoUpdateLoading = false;\n this.requestUpdate();\n }\n\n async handleToggleAutoUpdate() {\n if (!window.api || this.autoUpdateLoading) return;\n this.autoUpdateLoading = true;\n this.requestUpdate();\n try {\n const newValue = !this.autoUpdateEnabled;\n const result = await window.api.settingsView.setAutoUpdate(newValue);\n if (result && result.success) {\n this.autoUpdateEnabled = newValue;\n } else {\n console.error('Failed to update auto-update setting');\n }\n } catch (e) {\n console.error('Error toggling auto-update:', e);\n }\n this.autoUpdateLoading = false;\n this.requestUpdate();\n }\n\n async loadLocalAIStatus() {\n try {\n // Load Ollama status\n const ollamaStatus = await window.api.settingsView.getOllamaStatus();\n if (ollamaStatus?.success) {\n this.ollamaStatus = { installed: ollamaStatus.installed, running: ollamaStatus.running };\n this.ollamaModels = ollamaStatus.models || [];\n }\n \n // Load Whisper models status only if Whisper is enabled\n if (this.apiKeys?.whisper === 'local') {\n const whisperModelsResult = await window.api.settingsView.getWhisperInstalledModels();\n if (whisperModelsResult?.success) {\n const installedWhisperModels = whisperModelsResult.models;\n if (this.providerConfig?.whisper) {\n this.providerConfig.whisper.sttModels.forEach(m => {\n const installedInfo = installedWhisperModels.find(i => i.id === m.id);\n if (installedInfo) {\n m.installed = installedInfo.installed;\n }\n });\n }\n }\n }\n \n // Trigger UI update\n this.requestUpdate();\n } catch (error) {\n console.error('Error loading LocalAI status:', error);\n }\n }\n\n //////// after_modelStateService ////////\n async loadInitialData() {\n if (!window.api) return;\n this.isLoading = true;\n try {\n // Load essential data first\n const [userState, modelSettings, presets, contentProtection, shortcuts] = await Promise.all([\n window.api.settingsView.getCurrentUser(),\n window.api.settingsView.getModelSettings(), // Facade call\n window.api.settingsView.getPresets(),\n window.api.settingsView.getContentProtectionStatus(),\n window.api.settingsView.getCurrentShortcuts()\n ]);\n \n if (userState && userState.isLoggedIn) this.firebaseUser = userState;\n \n if (modelSettings.success) {\n const { config, storedKeys, availableLlm, availableStt, selectedModels } = modelSettings.data;\n this.providerConfig = config;\n this.apiKeys = storedKeys;\n this.availableLlmModels = availableLlm;\n this.availableSttModels = availableStt;\n this.selectedLlm = selectedModels.llm;\n this.selectedStt = selectedModels.stt;\n }\n\n this.presets = presets || [];\n this.isContentProtectionOn = contentProtection;\n this.shortcuts = shortcuts || {};\n if (this.presets.length > 0) {\n const firstUserPreset = this.presets.find(p => p.is_default === 0);\n if (firstUserPreset) this.selectedPreset = firstUserPreset;\n }\n \n // Load LocalAI status asynchronously to improve initial load time\n this.loadLocalAIStatus();\n } catch (error) {\n console.error('Error loading initial settings data:', error);\n } finally {\n this.isLoading = false;\n }\n }\n\n\n async handleSaveKey(provider) {\n const input = this.shadowRoot.querySelector(`#key-input-${provider}`);\n if (!input) return;\n const key = input.value;\n \n // For Ollama, we need to ensure it's ready first\n if (provider === 'ollama') {\n this.saving = true;\n \n // First ensure Ollama is installed and running\n const ensureResult = await window.api.settingsView.ensureOllamaReady();\n if (!ensureResult.success) {\n alert(`Failed to setup Ollama: ${ensureResult.error}`);\n this.saving = false;\n return;\n }\n \n // Now validate (which will check if service is running)\n const result = await window.api.settingsView.validateKey({ provider, key: 'local' });\n \n if (result.success) {\n await this.refreshModelData();\n await this.refreshOllamaStatus();\n } else {\n alert(`Failed to connect to Ollama: ${result.error}`);\n }\n this.saving = false;\n return;\n }\n \n // For Whisper, just enable it\n if (provider === 'whisper') {\n this.saving = true;\n const result = await window.api.settingsView.validateKey({ provider, key: 'local' });\n \n if (result.success) {\n await this.refreshModelData();\n } else {\n alert(`Failed to enable Whisper: ${result.error}`);\n }\n this.saving = false;\n return;\n }\n \n // For other providers, use the normal flow\n this.saving = true;\n const result = await window.api.settingsView.validateKey({ provider, key });\n \n if (result.success) {\n await this.refreshModelData();\n } else {\n alert(`Failed to save ${provider} key: ${result.error}`);\n input.value = this.apiKeys[provider] || '';\n }\n this.saving = false;\n }\n \n async handleClearKey(provider) {\n console.log(`[SettingsView] handleClearKey: ${provider}`);\n this.saving = true;\n await window.api.settingsView.removeApiKey(provider);\n this.apiKeys = { ...this.apiKeys, [provider]: '' };\n await this.refreshModelData();\n this.saving = false;\n }\n\n async refreshModelData() {\n const [availableLlm, availableStt, selected, storedKeys] = await Promise.all([\n window.api.settingsView.getAvailableModels({ type: 'llm' }),\n window.api.settingsView.getAvailableModels({ type: 'stt' }),\n window.api.settingsView.getSelectedModels(),\n window.api.settingsView.getAllKeys()\n ]);\n this.availableLlmModels = availableLlm;\n this.availableSttModels = availableStt;\n this.selectedLlm = selected.llm;\n this.selectedStt = selected.stt;\n this.apiKeys = storedKeys;\n this.requestUpdate();\n }\n \n async toggleModelList(type) {\n const visibilityProp = type === 'llm' ? 'isLlmListVisible' : 'isSttListVisible';\n\n if (!this[visibilityProp]) {\n this.saving = true;\n this.requestUpdate();\n \n await this.refreshModelData();\n\n this.saving = false;\n }\n\n // 데이터 새로고침 후, 목록의 표시 상태를 토글합니다.\n this[visibilityProp] = !this[visibilityProp];\n this.requestUpdate();\n }\n \n async selectModel(type, modelId) {\n // Check if this is an Ollama model that needs to be installed\n const provider = this.getProviderForModel(type, modelId);\n if (provider === 'ollama') {\n const ollamaModel = this.ollamaModels.find(m => m.name === modelId);\n if (ollamaModel && !ollamaModel.installed && !ollamaModel.installing) {\n // Need to install the model first\n await this.installOllamaModel(modelId);\n return;\n }\n }\n \n // Check if this is a Whisper model that needs to be downloaded\n if (provider === 'whisper' && type === 'stt') {\n const isInstalling = this.installingModels[modelId] !== undefined;\n const whisperModelInfo = this.providerConfig.whisper.sttModels.find(m => m.id === modelId);\n \n if (whisperModelInfo && !whisperModelInfo.installed && !isInstalling) {\n await this.downloadWhisperModel(modelId);\n return;\n }\n }\n \n this.saving = true;\n await window.api.settingsView.setSelectedModel({ type, modelId });\n if (type === 'llm') this.selectedLlm = modelId;\n if (type === 'stt') this.selectedStt = modelId;\n this.isLlmListVisible = false;\n this.isSttListVisible = false;\n this.saving = false;\n this.requestUpdate();\n }\n \n async refreshOllamaStatus() {\n const ollamaStatus = await window.api.settingsView.getOllamaStatus();\n if (ollamaStatus?.success) {\n this.ollamaStatus = { installed: ollamaStatus.installed, running: ollamaStatus.running };\n this.ollamaModels = ollamaStatus.models || [];\n }\n }\n \n async installOllamaModel(modelName) {\n try {\n // Ollama 모델 다운로드 시작\n this.installingModels = { ...this.installingModels, [modelName]: 0 };\n this.requestUpdate();\n\n // 진행률 이벤트 리스너 설정 - 통합 LocalAI 이벤트 사용\n const progressHandler = (event, data) => {\n if (data.service === 'ollama' && data.model === modelName) {\n this.installingModels = { ...this.installingModels, [modelName]: data.progress || 0 };\n this.requestUpdate();\n }\n };\n\n // 통합 LocalAI 이벤트 리스너 등록\n window.api.settingsView.onLocalAIInstallProgress(progressHandler);\n\n try {\n const result = await window.api.settingsView.pullOllamaModel(modelName);\n \n if (result.success) {\n console.log(`[SettingsView] Model ${modelName} installed successfully`);\n delete this.installingModels[modelName];\n this.requestUpdate();\n \n // 상태 새로고침\n await this.refreshOllamaStatus();\n await this.refreshModelData();\n } else {\n throw new Error(result.error || 'Installation failed');\n }\n } finally {\n // 통합 LocalAI 이벤트 리스너 제거\n window.api.settingsView.removeOnLocalAIInstallProgress(progressHandler);\n }\n } catch (error) {\n console.error(`[SettingsView] Error installing model ${modelName}:`, error);\n delete this.installingModels[modelName];\n this.requestUpdate();\n }\n }\n \n async downloadWhisperModel(modelId) {\n // Mark as installing\n this.installingModels = { ...this.installingModels, [modelId]: 0 };\n this.requestUpdate();\n \n try {\n // Set up progress listener - 통합 LocalAI 이벤트 사용\n const progressHandler = (event, data) => {\n if (data.service === 'whisper' && data.model === modelId) {\n this.installingModels = { ...this.installingModels, [modelId]: data.progress || 0 };\n this.requestUpdate();\n }\n };\n \n window.api.settingsView.onLocalAIInstallProgress(progressHandler);\n \n // Start download\n const result = await window.api.settingsView.downloadWhisperModel(modelId);\n \n if (result.success) {\n // Update the model's installed status\n if (this.providerConfig?.whisper?.sttModels) {\n const modelInfo = this.providerConfig.whisper.sttModels.find(m => m.id === modelId);\n if (modelInfo) {\n modelInfo.installed = true;\n }\n }\n \n // Remove from installing models\n delete this.installingModels[modelId];\n this.requestUpdate();\n \n // Reload LocalAI status to get fresh data\n await this.loadLocalAIStatus();\n \n // Auto-select the model after download\n await this.selectModel('stt', modelId);\n } else {\n // Remove from installing models on failure too\n delete this.installingModels[modelId];\n this.requestUpdate();\n alert(`Failed to download Whisper model: ${result.error}`);\n }\n \n // Cleanup\n window.api.settingsView.removeOnLocalAIInstallProgress(progressHandler);\n } catch (error) {\n console.error(`[SettingsView] Error downloading Whisper model ${modelId}:`, error);\n // Remove from installing models on error\n delete this.installingModels[modelId];\n this.requestUpdate();\n alert(`Error downloading ${modelId}: ${error.message}`);\n }\n }\n \n getProviderForModel(type, modelId) {\n for (const [providerId, config] of Object.entries(this.providerConfig)) {\n const models = type === 'llm' ? config.llmModels : config.sttModels;\n if (models?.some(m => m.id === modelId)) {\n return providerId;\n }\n }\n return null;\n }\n\n\n handleUsePicklesKey(e) {\n e.preventDefault()\n if (this.wasJustDragged) return\n \n console.log(\"Requesting Firebase authentication from main process...\")\n window.api.settingsView.startFirebaseAuth();\n }\n //////// after_modelStateService ////////\n\n openShortcutEditor() {\n window.api.settingsView.openShortcutSettingsWindow();\n }\n\n connectedCallback() {\n super.connectedCallback();\n \n this.setupEventListeners();\n this.setupIpcListeners();\n this.setupWindowResize();\n this.loadAutoUpdateSetting();\n // Force one height calculation immediately (innerHeight may be 0 at first)\n setTimeout(() => this.updateScrollHeight(), 0);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.cleanupEventListeners();\n this.cleanupIpcListeners();\n this.cleanupWindowResize();\n \n // Cancel any ongoing Ollama installations when component is destroyed\n const installingModels = Object.keys(this.installingModels);\n if (installingModels.length > 0) {\n installingModels.forEach(modelName => {\n window.api.settingsView.cancelOllamaInstallation(modelName);\n });\n }\n }\n\n setupEventListeners() {\n this.addEventListener('mouseenter', this.handleMouseEnter);\n this.addEventListener('mouseleave', this.handleMouseLeave);\n }\n\n cleanupEventListeners() {\n this.removeEventListener('mouseenter', this.handleMouseEnter);\n this.removeEventListener('mouseleave', this.handleMouseLeave);\n }\n\n setupIpcListeners() {\n if (!window.api) return;\n \n this._userStateListener = (event, userState) => {\n console.log('[SettingsView] Received user-state-changed:', userState);\n if (userState && userState.isLoggedIn) {\n this.firebaseUser = userState;\n } else {\n this.firebaseUser = null;\n }\n this.loadAutoUpdateSetting();\n // Reload model settings when user state changes (Firebase login/logout)\n this.loadInitialData();\n };\n \n this._settingsUpdatedListener = (event, settings) => {\n console.log('[SettingsView] Received settings-updated');\n this.settings = settings;\n this.requestUpdate();\n };\n\n // 프리셋 업데이트 리스너 추가\n this._presetsUpdatedListener = async (event) => {\n console.log('[SettingsView] Received presets-updated, refreshing presets');\n try {\n const presets = await window.api.settingsView.getPresets();\n this.presets = presets || [];\n \n // 현재 선택된 프리셋이 삭제되었는지 확인 (사용자 프리셋만 고려)\n const userPresets = this.presets.filter(p => p.is_default === 0);\n if (this.selectedPreset && !userPresets.find(p => p.id === this.selectedPreset.id)) {\n this.selectedPreset = userPresets.length > 0 ? userPresets[0] : null;\n }\n \n this.requestUpdate();\n } catch (error) {\n console.error('[SettingsView] Failed to refresh presets:', error);\n }\n };\n this._shortcutListener = (event, keybinds) => {\n console.log('[SettingsView] Received updated shortcuts:', keybinds);\n this.shortcuts = keybinds;\n };\n \n window.api.settingsView.onUserStateChanged(this._userStateListener);\n window.api.settingsView.onSettingsUpdated(this._settingsUpdatedListener);\n window.api.settingsView.onPresetsUpdated(this._presetsUpdatedListener);\n window.api.settingsView.onShortcutsUpdated(this._shortcutListener);\n }\n\n cleanupIpcListeners() {\n if (!window.api) return;\n \n if (this._userStateListener) {\n window.api.settingsView.removeOnUserStateChanged(this._userStateListener);\n }\n if (this._settingsUpdatedListener) {\n window.api.settingsView.removeOnSettingsUpdated(this._settingsUpdatedListener);\n }\n if (this._presetsUpdatedListener) {\n window.api.settingsView.removeOnPresetsUpdated(this._presetsUpdatedListener);\n }\n if (this._shortcutListener) {\n window.api.settingsView.removeOnShortcutsUpdated(this._shortcutListener);\n }\n }\n\n setupWindowResize() {\n this.resizeHandler = () => {\n this.requestUpdate();\n this.updateScrollHeight();\n };\n window.addEventListener('resize', this.resizeHandler);\n \n // Initial setup\n setTimeout(() => this.updateScrollHeight(), 100);\n }\n\n cleanupWindowResize() {\n if (this.resizeHandler) {\n window.removeEventListener('resize', this.resizeHandler);\n }\n }\n\n updateScrollHeight() {\n // Electron 일부 시점에서 window.innerHeight 가 0 으로 보고되는 버그 보호\n const rawHeight = window.innerHeight || (window.screen ? window.screen.height : 0);\n const MIN_HEIGHT = 300; // 최소 보장 높이\n const maxHeight = Math.max(MIN_HEIGHT, rawHeight);\n\n this.style.maxHeight = `${maxHeight}px`;\n\n const container = this.shadowRoot?.querySelector('.settings-container');\n if (container) {\n container.style.maxHeight = `${maxHeight}px`;\n }\n }\n\n handleMouseEnter = () => {\n window.api.settingsView.cancelHideSettingsWindow();\n // Recalculate height in case it was set to 0 before\n this.updateScrollHeight();\n }\n\n handleMouseLeave = () => {\n window.api.settingsView.hideSettingsWindow();\n }\n\n\n getMainShortcuts() {\n return [\n { name: 'Show / Hide', accelerator: this.shortcuts.toggleVisibility },\n { name: 'Ask Anything', accelerator: this.shortcuts.nextStep },\n { name: 'Scroll Up Response', accelerator: this.shortcuts.scrollUp },\n { name: 'Scroll Down Response', accelerator: this.shortcuts.scrollDown },\n ];\n }\n\n renderShortcutKeys(accelerator) {\n if (!accelerator) return html`N/A`;\n \n const keyMap = {\n 'Cmd': '⌘', 'Command': '⌘', 'Ctrl': '⌃', 'Alt': '⌥', 'Shift': '⇧', 'Enter': '↵',\n 'Up': '↑', 'Down': '↓', 'Left': '←', 'Right': '→'\n };\n\n // scrollDown/scrollUp의 특수 처리\n if (accelerator.includes('↕')) {\n const keys = accelerator.replace('↕','').split('+');\n keys.push('↕');\n return html`${keys.map(key => html`${keyMap[key] || key}`)}`;\n }\n\n const keys = accelerator.split('+');\n return html`${keys.map(key => html`${keyMap[key] || key}`)}`;\n }\n\n togglePresets() {\n this.showPresets = !this.showPresets;\n }\n\n async handlePresetSelect(preset) {\n this.selectedPreset = preset;\n // Here you could implement preset application logic\n console.log('Selected preset:', preset);\n }\n\n handleMoveLeft() {\n console.log('Move Left clicked');\n window.api.settingsView.moveWindowStep('left');\n }\n\n handleMoveRight() {\n console.log('Move Right clicked');\n window.api.settingsView.moveWindowStep('right');\n }\n\n async handlePersonalize() {\n console.log('Personalize clicked');\n try {\n await window.api.settingsView.openPersonalizePage();\n } catch (error) {\n console.error('Failed to open personalize page:', error);\n }\n }\n\n async handleToggleInvisibility() {\n console.log('Toggle Invisibility clicked');\n this.isContentProtectionOn = await window.api.settingsView.toggleContentProtection();\n this.requestUpdate();\n }\n\n async handleSaveApiKey() {\n const input = this.shadowRoot.getElementById('api-key-input');\n if (!input || !input.value) return;\n\n const newApiKey = input.value;\n try {\n const result = await window.api.settingsView.saveApiKey(newApiKey);\n if (result.success) {\n console.log('API Key saved successfully via IPC.');\n this.apiKey = newApiKey;\n this.requestUpdate();\n } else {\n console.error('Failed to save API Key via IPC:', result.error);\n }\n } catch(e) {\n console.error('Error invoking save-api-key IPC:', e);\n }\n }\n\n handleQuit() {\n console.log('Quit clicked');\n window.api.settingsView.quitApplication();\n }\n\n handleFirebaseLogout() {\n console.log('Firebase Logout clicked');\n window.api.settingsView.firebaseLogout();\n }\n\n async handleOllamaShutdown() {\n console.log('[SettingsView] Shutting down Ollama service...');\n \n if (!window.api) return;\n \n try {\n // Show loading state\n this.ollamaStatus = { ...this.ollamaStatus, running: false };\n this.requestUpdate();\n \n const result = await window.api.settingsView.shutdownOllama(false); // Graceful shutdown\n \n if (result.success) {\n console.log('[SettingsView] Ollama shut down successfully');\n // Refresh status to reflect the change\n await this.refreshOllamaStatus();\n } else {\n console.error('[SettingsView] Failed to shutdown Ollama:', result.error);\n // Restore previous state on error\n await this.refreshOllamaStatus();\n }\n } catch (error) {\n console.error('[SettingsView] Error during Ollama shutdown:', error);\n // Restore previous state on error\n await this.refreshOllamaStatus();\n }\n }\n\n //////// after_modelStateService ////////\n render() {\n if (this.isLoading) {\n return html`\n
\n
\n
\n Loading...\n
\n
\n `;\n }\n\n const loggedIn = !!this.firebaseUser;\n\n const apiKeyManagementHTML = html`\n
\n ${Object.entries(this.providerConfig)\n .filter(([id, config]) => !id.includes('-glass'))\n .map(([id, config]) => {\n if (id === 'ollama') {\n // Special UI for Ollama\n return html`\n
\n \n ${this.ollamaStatus.installed && this.ollamaStatus.running ? html`\n
\n ✓ Ollama is running\n
\n \n ` : this.ollamaStatus.installed ? html`\n
\n ⚠ Ollama installed but not running\n
\n \n ` : html`\n
\n ✗ Ollama not installed\n
\n \n `}\n
\n `;\n }\n \n if (id === 'whisper') {\n // Simplified UI for Whisper without model selection\n return html`\n
\n \n ${this.apiKeys[id] === 'local' ? html`\n
\n ✓ Whisper is enabled\n
\n \n ` : html`\n \n `}\n
\n `;\n }\n \n // Regular providers\n return html`\n
\n \n \n
\n \n \n
\n
\n `;\n })}\n
\n `;\n \n const getModelName = (type, id) => {\n const models = type === 'llm' ? this.availableLlmModels : this.availableSttModels;\n const model = models.find(m => m.id === id);\n return model ? model.name : id;\n }\n\n const modelSelectionHTML = html`\n
\n
\n \n \n ${this.isLlmListVisible ? html`\n
\n ${this.availableLlmModels.map(model => {\n const isOllama = this.getProviderForModel('llm', model.id) === 'ollama';\n const ollamaModel = isOllama ? this.ollamaModels.find(m => m.name === model.id) : null;\n const isInstalling = this.installingModels[model.id] !== undefined;\n const installProgress = this.installingModels[model.id] || 0;\n \n return html`\n
this.selectModel('llm', model.id)}>\n ${model.name}\n ${isOllama ? html`\n ${isInstalling ? html`\n
\n
\n
\n ` : ollamaModel?.installed ? html`\n ✓ Installed\n ` : html`\n Click to install\n `}\n ` : ''}\n
\n `;\n })}\n
\n ` : ''}\n
\n
\n \n \n ${this.isSttListVisible ? html`\n
\n ${this.availableSttModels.map(model => {\n const isWhisper = this.getProviderForModel('stt', model.id) === 'whisper';\n const whisperModel = isWhisper && this.providerConfig?.whisper?.sttModels \n ? this.providerConfig.whisper.sttModels.find(m => m.id === model.id) \n : null;\n const isInstalling = this.installingModels[model.id] !== undefined;\n const installProgress = this.installingModels[model.id] || 0;\n \n return html`\n
this.selectModel('stt', model.id)}>\n ${model.name}\n ${isWhisper ? html`\n ${isInstalling ? html`\n
\n
\n
\n ` : whisperModel?.installed ? html`\n ✓ Installed\n ` : html`\n Not Installed\n `}\n ` : ''}\n
\n `;\n })}\n
\n ` : ''}\n
\n
\n `;\n\n return html`\n
\n
\n
\n

Pickle Glass

\n
\n ${this.firebaseUser\n ? html`Account: ${this.firebaseUser.email || 'Logged In'}`\n : `Account: Not Logged In`\n }\n
\n
\n
\n \n \n \n
\n
\n\n ${apiKeyManagementHTML}\n ${modelSelectionHTML}\n\n
\n \n
\n\n \n
\n ${this.getMainShortcuts().map(shortcut => html`\n
\n ${shortcut.name}\n
\n ${this.renderShortcutKeys(shortcut.accelerator)}\n
\n
\n `)}\n
\n\n
\n
\n \n My Presets\n (${this.presets.filter(p => p.is_default === 0).length})\n \n \n ${this.showPresets ? '▼' : '▶'}\n \n
\n \n
\n ${this.presets.filter(p => p.is_default === 0).length === 0 ? html`\n
\n No custom presets yet.
\n \n Create your first preset\n \n
\n ` : this.presets.filter(p => p.is_default === 0).map(preset => html`\n
this.handlePresetSelect(preset)}>\n ${preset.title}\n ${this.selectedPreset?.id === preset.id ? html`Selected` : ''}\n
\n `)}\n
\n
\n\n
\n \n \n \n
\n \n \n
\n \n \n \n
\n ${this.firebaseUser\n ? html`\n \n `\n : html`\n \n `\n }\n \n
\n
\n
\n `;\n }\n //////// after_modelStateService ////////\n}\n\ncustomElements.define('settings-view', SettingsView);"], ["/glass/src/features/common/services/encryptionService.js", "const crypto = require('crypto');\nlet keytar;\n\n// Dynamically import keytar, as it's an optional dependency.\ntry {\n keytar = require('keytar');\n} catch (error) {\n console.warn('[EncryptionService] keytar is not available. Will use in-memory key for this session. Restarting the app might be required for data persistence after login.');\n keytar = null;\n}\n\nconst permissionService = require('./permissionService');\n\nconst SERVICE_NAME = 'com.pickle.glass'; // A unique identifier for the app in the keychain\nlet sessionKey = null; // In-memory fallback key\n\nconst ALGORITHM = 'aes-256-gcm';\nconst IV_LENGTH = 16; // For AES, this is always 16\nconst AUTH_TAG_LENGTH = 16;\n\n\n/**\n * Initializes the encryption key for a given user.\n * It first tries to get the key from the OS keychain.\n * If that fails, it generates a new key.\n * If keytar is available, it saves the new key.\n * Otherwise, it uses an in-memory key for the session.\n *\n * @param {string} userId - The unique identifier for the user (e.g., Firebase UID).\n */\nasync function initializeKey(userId) {\n if (!userId) {\n throw new Error('A user ID must be provided to initialize the encryption key.');\n }\n\n let keyRetrieved = false;\n\n if (keytar) {\n try {\n let key = await keytar.getPassword(SERVICE_NAME, userId);\n if (!key) {\n console.log(`[EncryptionService] No key found for ${userId}. Creating a new one.`);\n key = crypto.randomBytes(32).toString('hex');\n await keytar.setPassword(SERVICE_NAME, userId, key);\n console.log(`[EncryptionService] New key securely stored in keychain for ${userId}.`);\n } else {\n console.log(`[EncryptionService] Encryption key successfully retrieved from keychain for ${userId}.`);\n keyRetrieved = true;\n }\n sessionKey = key;\n } catch (error) {\n console.error('[EncryptionService] keytar failed. Falling back to in-memory key for this session.', error);\n keytar = null; // Disable keytar for the rest of the session to avoid repeated errors\n sessionKey = crypto.randomBytes(32).toString('hex');\n }\n } else {\n // keytar is not available\n if (!sessionKey) {\n console.warn('[EncryptionService] Using in-memory session key. Data will not persist across restarts without keytar.');\n sessionKey = crypto.randomBytes(32).toString('hex');\n }\n }\n\n // Mark keychain completed in permissions DB if this is the first successful retrieval or storage\n try {\n await permissionService.markKeychainCompleted(userId);\n if (keyRetrieved) {\n console.log(`[EncryptionService] Keychain completion marked in DB for ${userId}.`);\n }\n } catch (permErr) {\n console.error('[EncryptionService] Failed to mark keychain completion:', permErr);\n }\n\n if (!sessionKey) {\n throw new Error('Failed to initialize encryption key.');\n }\n}\n\nfunction resetSessionKey() {\n sessionKey = null;\n}\n\n/**\n * Encrypts a given text using AES-256-GCM.\n * @param {string} text The text to encrypt.\n * @returns {string | null} The encrypted data, as a base64 string containing iv, authTag, and content, or the original value if it cannot be encrypted.\n */\nfunction encrypt(text) {\n if (!sessionKey) {\n console.error('[EncryptionService] Encryption key is not initialized. Cannot encrypt.');\n return text; // Return original if key is missing\n }\n if (text == null) { // checks for null or undefined\n return text;\n }\n\n try {\n const key = Buffer.from(sessionKey, 'hex');\n const iv = crypto.randomBytes(IV_LENGTH);\n const cipher = crypto.createCipheriv(ALGORITHM, key, iv);\n \n let encrypted = cipher.update(String(text), 'utf8', 'hex');\n encrypted += cipher.final('hex');\n \n const authTag = cipher.getAuthTag();\n\n // Prepend IV and AuthTag to the encrypted content, then encode as base64.\n return Buffer.concat([iv, authTag, Buffer.from(encrypted, 'hex')]).toString('base64');\n } catch (error) {\n console.error('[EncryptionService] Encryption failed:', error);\n return text; // Return original on error\n }\n}\n\n/**\n * Decrypts a given encrypted string.\n * @param {string} encryptedText The base64 encrypted text.\n * @returns {string | null} The decrypted text, or the original value if it cannot be decrypted.\n */\nfunction decrypt(encryptedText) {\n if (!sessionKey) {\n console.error('[EncryptionService] Encryption key is not initialized. Cannot decrypt.');\n return encryptedText; // Return original if key is missing\n }\n if (encryptedText == null || typeof encryptedText !== 'string') {\n return encryptedText;\n }\n\n try {\n const data = Buffer.from(encryptedText, 'base64');\n if (data.length < IV_LENGTH + AUTH_TAG_LENGTH) {\n // This is not a valid encrypted string, likely plain text.\n return encryptedText;\n }\n \n const key = Buffer.from(sessionKey, 'hex');\n const iv = data.slice(0, IV_LENGTH);\n const authTag = data.slice(IV_LENGTH, IV_LENGTH + AUTH_TAG_LENGTH);\n const encryptedContent = data.slice(IV_LENGTH + AUTH_TAG_LENGTH);\n\n const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);\n decipher.setAuthTag(authTag);\n \n let decrypted = decipher.update(encryptedContent, 'hex', 'utf8');\n decrypted += decipher.final('utf8');\n \n return decrypted;\n } catch (error) {\n // It's common for this to fail if the data is not encrypted (e.g., legacy data).\n // In that case, we return the original value.\n console.error('[EncryptionService] Decryption failed:', error);\n return encryptedText;\n }\n}\n\nfunction looksEncrypted(str) {\n if (!str || typeof str !== 'string') return false;\n // Base64 chars + optional '=' padding\n if (!/^[A-Za-z0-9+/]+={0,2}$/.test(str)) return false;\n try {\n const buf = Buffer.from(str, 'base64');\n // Our AES-GCM cipher text must be at least 32 bytes (IV 16 + TAG 16)\n return buf.length >= 32;\n } catch {\n return false;\n }\n}\n\nmodule.exports = {\n initializeKey,\n resetSessionKey,\n encrypt,\n decrypt,\n looksEncrypted,\n}; "], ["/glass/pickleglass_web/backend_node/routes/conversations.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/', async (req, res) => {\n try {\n const sessions = await ipcRequest(req, 'get-sessions');\n res.json(sessions);\n } catch (error) {\n console.error('Failed to get sessions via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve sessions' });\n }\n});\n\nrouter.post('/', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'create-session', req.body);\n res.status(201).json({ ...result, message: 'Session created successfully' });\n } catch (error) {\n console.error('Failed to create session via IPC:', error);\n res.status(500).json({ error: 'Failed to create session' });\n }\n});\n\nrouter.get('/:session_id', async (req, res) => {\n try {\n const details = await ipcRequest(req, 'get-session-details', req.params.session_id);\n if (!details) {\n return res.status(404).json({ error: 'Session not found' });\n }\n res.json(details);\n } catch (error) {\n console.error(`Failed to get session details via IPC for ${req.params.session_id}:`, error);\n res.status(500).json({ error: 'Failed to retrieve session details' });\n }\n});\n\nrouter.delete('/:session_id', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-session', req.params.session_id);\n res.status(200).json({ message: 'Session deleted successfully' });\n } catch (error) {\n console.error(`Failed to delete session via IPC for ${req.params.session_id}:`, error);\n res.status(500).json({ error: 'Failed to delete session' });\n }\n});\n\n// The search functionality will be more complex to move to IPC.\n// For now, we can disable it or leave it as is, knowing it's a future task.\nrouter.get('/search', (req, res) => {\n res.status(501).json({ error: 'Search not implemented for IPC bridge yet.' });\n});\n\nmodule.exports = router; "], ["/glass/src/ui/listen/ListenView.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\nimport './stt/SttView.js';\nimport './summary/SummaryView.js';\n\nexport class ListenView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 400px;\n transform: translate3d(0, 0, 0);\n backface-visibility: hidden;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n will-change: transform, opacity;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n/* Allow text selection in insights responses */\n.insights-container, .insights-container *, .markdown-content {\n user-select: text !important;\n cursor: text !important;\n}\n\n/* highlight.js 스타일 추가 */\n.insights-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n}\n\n.insights-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n}\n\n.insights-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n}\n\n.insights-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n}\n\n.hljs-keyword {\n color: #ff79c6 !important;\n}\n\n.hljs-string {\n color: #f1fa8c !important;\n}\n\n.hljs-comment {\n color: #6272a4 !important;\n}\n\n.hljs-number {\n color: #bd93f9 !important;\n}\n\n.hljs-function {\n color: #50fa7b !important;\n}\n\n.hljs-title {\n color: #50fa7b !important;\n}\n\n.hljs-variable {\n color: #8be9fd !important;\n}\n\n.hljs-built_in {\n color: #ffb86c !important;\n}\n\n.hljs-attr {\n color: #50fa7b !important;\n}\n\n.hljs-tag {\n color: #ff79c6 !important;\n}\n .assistant-container {\n display: flex;\n flex-direction: column;\n color: #ffffff;\n box-sizing: border-box;\n position: relative;\n background: rgba(0, 0, 0, 0.6);\n overflow: hidden;\n border-radius: 12px;\n width: 100%;\n height: 100%;\n }\n\n .assistant-container::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 12px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .assistant-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n z-index: -1;\n }\n\n .top-bar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 6px 16px;\n min-height: 32px;\n position: relative;\n z-index: 1;\n width: 100%;\n box-sizing: border-box;\n flex-shrink: 0;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .bar-left-text {\n color: white;\n font-size: 13px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n position: relative;\n overflow: hidden;\n white-space: nowrap;\n flex: 1;\n min-width: 0;\n max-width: 200px;\n }\n\n .bar-left-text-content {\n display: inline-block;\n transition: transform 0.3s ease;\n }\n\n .bar-left-text-content.slide-in {\n animation: slideIn 0.3s ease forwards;\n }\n\n .bar-controls {\n display: flex;\n gap: 4px;\n align-items: center;\n flex-shrink: 0;\n width: 120px;\n justify-content: flex-end;\n box-sizing: border-box;\n padding: 4px;\n }\n\n .toggle-button {\n display: flex;\n align-items: center;\n gap: 5px;\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: none;\n outline: none;\n box-shadow: none;\n padding: 4px 8px;\n border-radius: 5px;\n font-size: 11px;\n font-weight: 500;\n cursor: pointer;\n height: 24px;\n white-space: nowrap;\n transition: background-color 0.15s ease;\n justify-content: center;\n }\n\n .toggle-button:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .toggle-button svg {\n flex-shrink: 0;\n width: 12px;\n height: 12px;\n }\n\n .copy-button {\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: none;\n outline: none;\n box-shadow: none;\n padding: 4px;\n border-radius: 3px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 24px;\n height: 24px;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n position: relative;\n overflow: hidden;\n }\n\n .copy-button:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n\n .copy-button svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n }\n\n .copy-button .check-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .copy-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .check-icon {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n\n .timer {\n font-family: 'Monaco', 'Menlo', monospace;\n font-size: 10px;\n color: rgba(255, 255, 255, 0.7);\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .top-bar,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .transcription-container,\n :host-context(body.has-glass) .insights-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .outline-item,\n :host-context(body.has-glass) .request-item,\n :host-context(body.has-glass) .markdown-content,\n :host-context(body.has-glass) .insights-container pre,\n :host-context(body.has-glass) .insights-container p code,\n :host-context(body.has-glass) .insights-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container::before,\n :host-context(body.has-glass) .assistant-container::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .toggle-button:hover,\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .outline-item:hover,\n :host-context(body.has-glass) .request-item.clickable:hover,\n :host-context(body.has-glass) .markdown-content:hover {\n background: transparent !important;\n transform: none !important;\n }\n\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-thumb,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button {\n border-radius: 0 !important;\n }\n\n :host-context(body.has-glass) ::-webkit-scrollbar,\n :host-context(body.has-glass) ::-webkit-scrollbar-track,\n :host-context(body.has-glass) ::-webkit-scrollbar-thumb {\n background: transparent !important;\n width: 0 !important; /* 스크롤바 자체 숨기기 */\n }\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .top-bar,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .transcription-container,\n :host-context(body.has-glass) .insights-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .outline-item,\n :host-context(body.has-glass) .request-item,\n :host-context(body.has-glass) .markdown-content,\n :host-context(body.has-glass) .insights-container pre,\n :host-context(body.has-glass) .insights-container p code,\n :host-context(body.has-glass) .insights-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container::before,\n :host-context(body.has-glass) .assistant-container::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .toggle-button:hover,\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .outline-item:hover,\n :host-context(body.has-glass) .request-item.clickable:hover,\n :host-context(body.has-glass) .markdown-content:hover {\n background: transparent !important;\n transform: none !important;\n }\n\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .transcription-container::-webkit-scrollbar-thumb,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .insights-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .assistant-container,\n :host-context(body.has-glass) .stt-message,\n :host-context(body.has-glass) .toggle-button,\n :host-context(body.has-glass) .copy-button {\n border-radius: 0 !important;\n }\n\n :host-context(body.has-glass) ::-webkit-scrollbar,\n :host-context(body.has-glass) ::-webkit-scrollbar-track,\n :host-context(body.has-glass) ::-webkit-scrollbar-thumb {\n background: transparent !important;\n width: 0 !important;\n }\n `;\n\n static properties = {\n viewMode: { type: String },\n isHovering: { type: Boolean },\n isAnimating: { type: Boolean },\n copyState: { type: String },\n elapsedTime: { type: String },\n captureStartTime: { type: Number },\n isSessionActive: { type: Boolean },\n hasCompletedRecording: { type: Boolean },\n };\n\n constructor() {\n super();\n this.isSessionActive = false;\n this.hasCompletedRecording = false;\n this.viewMode = 'insights';\n this.isHovering = false;\n this.isAnimating = false;\n this.elapsedTime = '00:00';\n this.captureStartTime = null;\n this.timerInterval = null;\n this.adjustHeightThrottle = null;\n this.isThrottled = false;\n this.copyState = 'idle';\n this.copyTimeout = null;\n\n this.adjustWindowHeight = this.adjustWindowHeight.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n // Only start timer if session is active\n if (this.isSessionActive) {\n this.startTimer();\n }\n if (window.api) {\n window.api.listenView.onSessionStateChanged((event, { isActive }) => {\n const wasActive = this.isSessionActive;\n this.isSessionActive = isActive;\n\n if (!wasActive && isActive) {\n this.hasCompletedRecording = false;\n this.startTimer();\n // Reset child components\n this.updateComplete.then(() => {\n const sttView = this.shadowRoot.querySelector('stt-view');\n const summaryView = this.shadowRoot.querySelector('summary-view');\n if (sttView) sttView.resetTranscript();\n if (summaryView) summaryView.resetAnalysis();\n });\n this.requestUpdate();\n }\n if (wasActive && !isActive) {\n this.hasCompletedRecording = true;\n this.stopTimer();\n this.requestUpdate();\n }\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.stopTimer();\n\n if (this.adjustHeightThrottle) {\n clearTimeout(this.adjustHeightThrottle);\n this.adjustHeightThrottle = null;\n }\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n }\n\n startTimer() {\n this.captureStartTime = Date.now();\n this.timerInterval = setInterval(() => {\n const elapsed = Math.floor((Date.now() - this.captureStartTime) / 1000);\n const minutes = Math.floor(elapsed / 60)\n .toString()\n .padStart(2, '0');\n const seconds = (elapsed % 60).toString().padStart(2, '0');\n this.elapsedTime = `${minutes}:${seconds}`;\n this.requestUpdate();\n }, 1000);\n }\n\n stopTimer() {\n if (this.timerInterval) {\n clearInterval(this.timerInterval);\n this.timerInterval = null;\n }\n }\n\n adjustWindowHeight() {\n if (!window.api) return;\n\n this.updateComplete\n .then(() => {\n const topBar = this.shadowRoot.querySelector('.top-bar');\n const activeContent = this.viewMode === 'transcript'\n ? this.shadowRoot.querySelector('stt-view')\n : this.shadowRoot.querySelector('summary-view');\n\n if (!topBar || !activeContent) return;\n\n const topBarHeight = topBar.offsetHeight;\n\n const contentHeight = activeContent.scrollHeight;\n\n const idealHeight = topBarHeight + contentHeight;\n\n const targetHeight = Math.min(700, idealHeight);\n\n console.log(\n `[Height Adjusted] Mode: ${this.viewMode}, TopBar: ${topBarHeight}px, Content: ${contentHeight}px, Ideal: ${idealHeight}px, Target: ${targetHeight}px`\n );\n\n window.api.listenView.adjustWindowHeight('listen', targetHeight);\n })\n .catch(error => {\n console.error('Error in adjustWindowHeight:', error);\n });\n }\n\n toggleViewMode() {\n this.viewMode = this.viewMode === 'insights' ? 'transcript' : 'insights';\n this.requestUpdate();\n }\n\n handleCopyHover(isHovering) {\n this.isHovering = isHovering;\n if (isHovering) {\n this.isAnimating = true;\n } else {\n this.isAnimating = false;\n }\n this.requestUpdate();\n }\n\n async handleCopy() {\n if (this.copyState === 'copied') return;\n\n let textToCopy = '';\n\n if (this.viewMode === 'transcript') {\n const sttView = this.shadowRoot.querySelector('stt-view');\n textToCopy = sttView ? sttView.getTranscriptText() : '';\n } else {\n const summaryView = this.shadowRoot.querySelector('summary-view');\n textToCopy = summaryView ? summaryView.getSummaryText() : '';\n }\n\n try {\n await navigator.clipboard.writeText(textToCopy);\n console.log('Content copied to clipboard');\n\n this.copyState = 'copied';\n this.requestUpdate();\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n this.copyTimeout = setTimeout(() => {\n this.copyState = 'idle';\n this.requestUpdate();\n }, 1500);\n } catch (err) {\n console.error('Failed to copy:', err);\n }\n }\n\n adjustWindowHeightThrottled() {\n if (this.isThrottled) {\n return;\n }\n\n this.adjustWindowHeight();\n\n this.isThrottled = true;\n\n this.adjustHeightThrottle = setTimeout(() => {\n this.isThrottled = false;\n }, 16);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n\n if (changedProperties.has('viewMode')) {\n this.adjustWindowHeight();\n }\n }\n\n handleSttMessagesUpdated(event) {\n // Handle messages update from SttView if needed\n this.adjustWindowHeightThrottled();\n }\n\n firstUpdated() {\n super.firstUpdated();\n setTimeout(() => this.adjustWindowHeight(), 200);\n }\n\n render() {\n const displayText = this.isHovering\n ? this.viewMode === 'transcript'\n ? 'Copy Transcript'\n : 'Copy Glass Analysis'\n : this.viewMode === 'insights'\n ? `Live insights`\n : `Glass is Listening ${this.elapsedTime}`;\n\n return html`\n
\n
\n
\n ${displayText}\n
\n
\n \n this.handleCopyHover(true)}\n @mouseleave=${() => this.handleCopyHover(false)}\n >\n \n \n \n \n \n \n \n \n
\n
\n\n \n\n \n
\n `;\n }\n}\n\ncustomElements.define('listen-view', ListenView);\n"], ["/glass/src/features/common/services/localAIManager.js", "const { EventEmitter } = require('events');\nconst ollamaService = require('./ollamaService');\nconst whisperService = require('./whisperService');\n\n\n//Central manager for managing Ollama and Whisper services \nclass LocalAIManager extends EventEmitter {\n constructor() {\n super();\n \n // service map\n this.services = {\n ollama: ollamaService,\n whisper: whisperService\n };\n \n // unified state management\n this.state = {\n ollama: {\n installed: false,\n running: false,\n models: []\n },\n whisper: {\n installed: false,\n initialized: false,\n models: []\n }\n };\n \n // setup event listeners\n this.setupEventListeners();\n }\n \n \n // subscribe to events from each service and re-emit as unified events\n setupEventListeners() {\n // ollama events\n ollamaService.on('install-progress', (data) => {\n this.emit('install-progress', 'ollama', data);\n });\n \n ollamaService.on('installation-complete', () => {\n this.emit('installation-complete', 'ollama');\n this.updateServiceState('ollama');\n });\n \n ollamaService.on('error', (error) => {\n this.emit('error', { service: 'ollama', ...error });\n });\n \n ollamaService.on('model-pull-complete', (data) => {\n this.emit('model-ready', { service: 'ollama', ...data });\n this.updateServiceState('ollama');\n });\n \n ollamaService.on('state-changed', (state) => {\n this.emit('state-changed', 'ollama', state);\n });\n \n // Whisper 이벤트\n whisperService.on('install-progress', (data) => {\n this.emit('install-progress', 'whisper', data);\n });\n \n whisperService.on('installation-complete', () => {\n this.emit('installation-complete', 'whisper');\n this.updateServiceState('whisper');\n });\n \n whisperService.on('error', (error) => {\n this.emit('error', { service: 'whisper', ...error });\n });\n \n whisperService.on('model-download-complete', (data) => {\n this.emit('model-ready', { service: 'whisper', ...data });\n this.updateServiceState('whisper');\n });\n }\n \n /**\n * 서비스 설치\n */\n async installService(serviceName, options = {}) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n try {\n if (serviceName === 'ollama') {\n return await service.handleInstall();\n } else if (serviceName === 'whisper') {\n // Whisper는 자동 설치\n await service.initialize();\n return { success: true };\n }\n } catch (error) {\n this.emit('error', {\n service: serviceName,\n errorType: 'installation-failed',\n error: error.message\n });\n throw error;\n }\n }\n \n /**\n * 서비스 상태 조회\n */\n async getServiceStatus(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.getStatus();\n } else if (serviceName === 'whisper') {\n const installed = await service.isInstalled();\n const running = await service.isServiceRunning();\n const models = await service.getInstalledModels();\n return {\n success: true,\n installed,\n running,\n models\n };\n }\n }\n \n /**\n * 서비스 시작\n */\n async startService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n const result = await service.startService();\n await this.updateServiceState(serviceName);\n return { success: result };\n }\n \n /**\n * 서비스 중지\n */\n async stopService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n let result;\n if (serviceName === 'ollama') {\n result = await service.shutdown(false);\n } else if (serviceName === 'whisper') {\n result = await service.stopService();\n }\n \n // 서비스 중지 후 상태 업데이트\n await this.updateServiceState(serviceName);\n \n return result;\n }\n \n /**\n * 모델 설치/다운로드\n */\n async installModel(serviceName, modelId, options = {}) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.pullModel(modelId);\n } else if (serviceName === 'whisper') {\n return await service.downloadModel(modelId);\n }\n }\n \n /**\n * 설치된 모델 목록 조회\n */\n async getInstalledModels(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n if (serviceName === 'ollama') {\n return await service.getAllModelsWithStatus();\n } else if (serviceName === 'whisper') {\n return await service.getInstalledModels();\n }\n }\n \n /**\n * 모델 워밍업 (Ollama 전용)\n */\n async warmUpModel(modelName, forceRefresh = false) {\n return await ollamaService.warmUpModel(modelName, forceRefresh);\n }\n \n /**\n * 자동 워밍업 (Ollama 전용)\n */\n async autoWarmUp() {\n return await ollamaService.autoWarmUpSelectedModel();\n }\n \n /**\n * 진단 실행\n */\n async runDiagnostics(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n const diagnostics = {\n service: serviceName,\n timestamp: new Date().toISOString(),\n checks: {}\n };\n \n try {\n // 1. 설치 상태 확인\n diagnostics.checks.installation = {\n check: 'Installation',\n status: await service.isInstalled() ? 'pass' : 'fail',\n details: {}\n };\n \n // 2. 서비스 실행 상태\n diagnostics.checks.running = {\n check: 'Service Running',\n status: await service.isServiceRunning() ? 'pass' : 'fail',\n details: {}\n };\n \n // 3. 포트 연결 테스트 및 상세 health check (Ollama)\n if (serviceName === 'ollama') {\n try {\n // Use comprehensive health check\n const health = await service.healthCheck();\n diagnostics.checks.health = {\n check: 'Service Health',\n status: health.healthy ? 'pass' : 'fail',\n details: health\n };\n \n // Legacy port check for compatibility\n diagnostics.checks.port = {\n check: 'Port Connectivity',\n status: health.checks.apiResponsive ? 'pass' : 'fail',\n details: { connected: health.checks.apiResponsive }\n };\n } catch (error) {\n diagnostics.checks.health = {\n check: 'Service Health',\n status: 'fail',\n details: { error: error.message }\n };\n diagnostics.checks.port = {\n check: 'Port Connectivity',\n status: 'fail',\n details: { error: error.message }\n };\n }\n \n // 4. 모델 목록\n if (diagnostics.checks.running.status === 'pass') {\n try {\n const models = await service.getInstalledModels();\n diagnostics.checks.models = {\n check: 'Installed Models',\n status: 'pass',\n details: { count: models.length, models: models.map(m => m.name) }\n };\n \n // 5. 워밍업 상태\n const warmupStatus = await service.getWarmUpStatus();\n diagnostics.checks.warmup = {\n check: 'Model Warm-up',\n status: 'pass',\n details: warmupStatus\n };\n } catch (error) {\n diagnostics.checks.models = {\n check: 'Installed Models',\n status: 'fail',\n details: { error: error.message }\n };\n }\n }\n }\n \n // 4. Whisper 특화 진단\n if (serviceName === 'whisper') {\n // 바이너리 확인\n diagnostics.checks.binary = {\n check: 'Whisper Binary',\n status: service.whisperPath ? 'pass' : 'fail',\n details: { path: service.whisperPath }\n };\n \n // 모델 디렉토리\n diagnostics.checks.modelDir = {\n check: 'Model Directory',\n status: service.modelsDir ? 'pass' : 'fail',\n details: { path: service.modelsDir }\n };\n }\n \n // 전체 진단 결과\n const allChecks = Object.values(diagnostics.checks);\n diagnostics.summary = {\n total: allChecks.length,\n passed: allChecks.filter(c => c.status === 'pass').length,\n failed: allChecks.filter(c => c.status === 'fail').length,\n overallStatus: allChecks.every(c => c.status === 'pass') ? 'healthy' : 'unhealthy'\n };\n \n } catch (error) {\n diagnostics.error = error.message;\n diagnostics.summary = {\n overallStatus: 'error'\n };\n }\n \n return diagnostics;\n }\n \n /**\n * 서비스 복구\n */\n async repairService(serviceName) {\n const service = this.services[serviceName];\n if (!service) {\n throw new Error(`Unknown service: ${serviceName}`);\n }\n \n console.log(`[LocalAIManager] Starting repair for ${serviceName}...`);\n const repairLog = [];\n \n try {\n // 1. 진단 실행\n repairLog.push('Running diagnostics...');\n const diagnostics = await this.runDiagnostics(serviceName);\n \n if (diagnostics.summary.overallStatus === 'healthy') {\n repairLog.push('Service is already healthy, no repair needed');\n return {\n success: true,\n repairLog,\n diagnostics\n };\n }\n \n // 2. 설치 문제 해결\n if (diagnostics.checks.installation?.status === 'fail') {\n repairLog.push('Installation missing, attempting to install...');\n try {\n await this.installService(serviceName);\n repairLog.push('Installation completed');\n } catch (error) {\n repairLog.push(`Installation failed: ${error.message}`);\n throw error;\n }\n }\n \n // 3. 서비스 재시작\n if (diagnostics.checks.running?.status === 'fail') {\n repairLog.push('Service not running, attempting to start...');\n \n // 종료 시도\n try {\n await this.stopService(serviceName);\n repairLog.push('Stopped existing service');\n } catch (error) {\n repairLog.push('Service was not running');\n }\n \n // 잠시 대기\n await new Promise(resolve => setTimeout(resolve, 2000));\n \n // 시작\n try {\n await this.startService(serviceName);\n repairLog.push('Service started successfully');\n } catch (error) {\n repairLog.push(`Failed to start service: ${error.message}`);\n throw error;\n }\n }\n \n // 4. 포트 문제 해결 (Ollama)\n if (serviceName === 'ollama' && diagnostics.checks.port?.status === 'fail') {\n repairLog.push('Port connectivity issue detected');\n \n // 프로세스 강제 종료\n if (process.platform === 'darwin') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('pkill -f ollama');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n else if (process.platform === 'win32') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('taskkill /F /IM ollama.exe');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n else if (process.platform === 'linux') {\n try {\n const { exec } = require('child_process');\n const { promisify } = require('util');\n const execAsync = promisify(exec);\n await execAsync('pkill -f ollama');\n repairLog.push('Killed stale Ollama processes');\n } catch (error) {\n repairLog.push('No stale processes found');\n }\n }\n \n await new Promise(resolve => setTimeout(resolve, 1000));\n \n // 재시작\n await this.startService(serviceName);\n repairLog.push('Restarted service after port cleanup');\n }\n \n // 5. Whisper 특화 복구\n if (serviceName === 'whisper') {\n // 세션 정리\n if (diagnostics.checks.running?.status === 'pass') {\n repairLog.push('Cleaning up Whisper sessions...');\n await service.cleanup();\n repairLog.push('Sessions cleaned up');\n }\n \n // 초기화\n if (!service.installState.isInitialized) {\n repairLog.push('Re-initializing Whisper...');\n await service.initialize();\n repairLog.push('Whisper re-initialized');\n }\n }\n \n // 6. 최종 상태 확인\n repairLog.push('Verifying repair...');\n const finalDiagnostics = await this.runDiagnostics(serviceName);\n \n const success = finalDiagnostics.summary.overallStatus === 'healthy';\n repairLog.push(success ? 'Repair successful!' : 'Repair failed - manual intervention may be required');\n \n // 성공 시 상태 업데이트\n if (success) {\n await this.updateServiceState(serviceName);\n }\n \n return {\n success,\n repairLog,\n diagnostics: finalDiagnostics\n };\n \n } catch (error) {\n repairLog.push(`Repair error: ${error.message}`);\n return {\n success: false,\n repairLog,\n error: error.message\n };\n }\n }\n \n /**\n * 상태 업데이트\n */\n async updateServiceState(serviceName) {\n try {\n const status = await this.getServiceStatus(serviceName);\n this.state[serviceName] = status;\n \n // 상태 변경 이벤트 발행\n this.emit('state-changed', serviceName, status);\n } catch (error) {\n console.error(`[LocalAIManager] Failed to update ${serviceName} state:`, error);\n }\n }\n \n /**\n * 전체 상태 조회\n */\n async getAllServiceStates() {\n const states = {};\n \n for (const serviceName of Object.keys(this.services)) {\n try {\n states[serviceName] = await this.getServiceStatus(serviceName);\n } catch (error) {\n states[serviceName] = {\n success: false,\n error: error.message\n };\n }\n }\n \n return states;\n }\n \n /**\n * 주기적 상태 동기화 시작\n */\n startPeriodicSync(interval = 30000) {\n if (this.syncInterval) {\n return;\n }\n \n this.syncInterval = setInterval(async () => {\n for (const serviceName of Object.keys(this.services)) {\n await this.updateServiceState(serviceName);\n }\n }, interval);\n \n // 각 서비스의 주기적 동기화도 시작\n ollamaService.startPeriodicSync();\n }\n \n /**\n * 주기적 상태 동기화 중지\n */\n stopPeriodicSync() {\n if (this.syncInterval) {\n clearInterval(this.syncInterval);\n this.syncInterval = null;\n }\n \n // 각 서비스의 주기적 동기화도 중지\n ollamaService.stopPeriodicSync();\n }\n \n /**\n * 전체 종료\n */\n async shutdown() {\n this.stopPeriodicSync();\n \n const results = {};\n for (const [serviceName, service] of Object.entries(this.services)) {\n try {\n if (serviceName === 'ollama') {\n results[serviceName] = await service.shutdown(false);\n } else if (serviceName === 'whisper') {\n await service.cleanup();\n results[serviceName] = true;\n }\n } catch (error) {\n results[serviceName] = false;\n console.error(`[LocalAIManager] Failed to shutdown ${serviceName}:`, error);\n }\n }\n \n return results;\n }\n \n /**\n * 에러 처리\n */\n async handleError(serviceName, errorType, details = {}) {\n console.error(`[LocalAIManager] Error in ${serviceName}: ${errorType}`, details);\n \n // 서비스별 에러 처리\n switch(errorType) {\n case 'installation-failed':\n // 설치 실패 시 이벤트 발생\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || 'Installation failed',\n canRetry: true\n });\n break;\n \n case 'model-pull-failed':\n case 'model-download-failed':\n // 모델 다운로드 실패\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n model: details.model,\n error: details.error || 'Model download failed',\n canRetry: true\n });\n break;\n \n case 'service-not-responding':\n // 서비스 반응 없음\n console.log(`[LocalAIManager] Attempting to repair ${serviceName}...`);\n const repairResult = await this.repairService(serviceName);\n \n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || 'Service not responding',\n repairAttempted: true,\n repairSuccessful: repairResult.success\n });\n break;\n \n default:\n // 기타 에러\n this.emit('error-occurred', {\n service: serviceName,\n errorType,\n error: details.error || `Unknown error: ${errorType}`,\n canRetry: false\n });\n }\n }\n}\n\n// 싱글톤\nconst localAIManager = new LocalAIManager();\nmodule.exports = localAIManager;"], ["/glass/src/features/common/ai/providers/deepgram.js", "// providers/deepgram.js\n\nconst { createClient, LiveTranscriptionEvents } = require('@deepgram/sdk');\nconst WebSocket = require('ws');\n\n/**\n * Deepgram Provider 클래스. API 키 유효성 검사를 담당합니다.\n */\nclass DeepgramProvider {\n /**\n * Deepgram API 키의 유효성을 검사합니다.\n * @param {string} key - 검사할 Deepgram API 키\n * @returns {Promise<{success: boolean, error?: string}>}\n */\n static async validateApiKey(key) {\n if (!key || typeof key !== 'string') {\n return { success: false, error: 'Invalid Deepgram API key format.' };\n }\n try {\n // ✨ 변경점: SDK 대신 직접 fetch로 API를 호출하여 안정성 확보 (openai.js 방식)\n const response = await fetch('https://api.deepgram.com/v1/projects', {\n headers: { 'Authorization': `Token ${key}` }\n });\n\n if (response.ok) {\n return { success: true };\n } else {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.err_msg || `Validation failed with status: ${response.status}`;\n return { success: false, error: message };\n }\n } catch (error) {\n console.error(`[DeepgramProvider] Network error during key validation:`, error);\n return { success: false, error: error.message || 'A network error occurred during validation.' };\n }\n }\n}\n\nfunction createSTT({\n apiKey,\n language = 'en-US',\n sampleRate = 24000,\n callbacks = {},\n }) {\n const qs = new URLSearchParams({\n model: 'nova-3',\n encoding: 'linear16',\n sample_rate: sampleRate.toString(),\n language,\n smart_format: 'true',\n interim_results: 'true',\n channels: '1',\n });\n \n const url = `wss://api.deepgram.com/v1/listen?${qs}`;\n \n const ws = new WebSocket(url, {\n headers: { Authorization: `Token ${apiKey}` },\n });\n ws.binaryType = 'arraybuffer';\n \n return new Promise((resolve, reject) => {\n const to = setTimeout(() => {\n ws.terminate();\n reject(new Error('DG open timeout (10 s)'));\n }, 10_000);\n \n ws.on('open', () => {\n clearTimeout(to);\n resolve({\n sendRealtimeInput: (buf) => ws.send(buf),\n close: () => ws.close(1000, 'client'),\n });\n });\n \n ws.on('message', raw => {\n let msg;\n try { msg = JSON.parse(raw.toString()); } catch { return; }\n if (msg.channel?.alternatives?.[0]?.transcript !== undefined) {\n callbacks.onmessage?.({ provider: 'deepgram', ...msg });\n }\n });\n \n ws.on('close', (code, reason) =>\n callbacks.onclose?.({ code, reason: reason.toString() })\n );\n \n ws.on('error', err => {\n clearTimeout(to);\n callbacks.onerror?.(err);\n reject(err);\n });\n });\n }\n\n// ... (LLM 관련 Placeholder 함수들은 그대로 유지) ...\nfunction createLLM(opts) {\n console.warn(\"[Deepgram] LLM not supported.\");\n return { generateContent: async () => { throw new Error(\"Deepgram does not support LLM functionality.\"); } };\n}\nfunction createStreamingLLM(opts) {\n console.warn(\"[Deepgram] Streaming LLM not supported.\");\n return { streamChat: async () => { throw new Error(\"Deepgram does not support Streaming LLM functionality.\"); } };\n}\n\nmodule.exports = {\n DeepgramProvider,\n createSTT,\n createLLM,\n createStreamingLLM\n};"], ["/glass/src/features/common/services/firebaseClient.js", "const { initializeApp } = require('firebase/app');\nconst { initializeAuth } = require('firebase/auth');\nconst Store = require('electron-store');\nconst { getFirestore, setLogLevel } = require('firebase/firestore');\n\n// setLogLevel('debug');\n\n/**\n * Firebase Auth expects the `persistence` option passed to `initializeAuth()` to be *classes*,\n * not instances. It then calls `new PersistenceClass()` internally. \n *\n * The helper below returns such a class, pre-configured with an `electron-store` instance that\n * will be shared across all constructed objects. This mirrors the pattern used by Firebase's own\n * `browserLocalPersistence` implementation as well as community solutions for NodeJS.\n */\nfunction createElectronStorePersistence(storeName = 'firebase-auth-session') {\n // Create a single `electron-store` behind the scenes – all Persistence instances will use it.\n const sharedStore = new Store({ name: storeName });\n\n return class ElectronStorePersistence {\n constructor() {\n this.store = sharedStore;\n this.type = 'LOCAL';\n }\n\n /**\n * Firebase calls this to check whether the persistence is usable in the current context.\n */\n _isAvailable() {\n return Promise.resolve(true);\n }\n\n async _set(key, value) {\n this.store.set(key, value);\n }\n\n async _get(key) {\n return this.store.get(key) ?? null;\n }\n\n async _remove(key) {\n this.store.delete(key);\n }\n\n /**\n * These are used by Firebase to react to external storage events (e.g. multi-tab).\n * Electron apps are single-renderer per process, so we can safely provide no-op\n * implementations.\n */\n _addListener(_key, _listener) {\n // no-op\n }\n\n _removeListener(_key, _listener) {\n // no-op\n }\n };\n}\n\nconst firebaseConfig = {\n apiKey: 'AIzaSyAgtJrmsFWG1C7m9S55HyT1laICEzuUS2g',\n authDomain: 'pickle-3651a.firebaseapp.com',\n projectId: 'pickle-3651a',\n storageBucket: 'pickle-3651a.firebasestorage.app',\n messagingSenderId: '904706892885',\n appId: '1:904706892885:web:0e42b3dda796674ead20dc',\n measurementId: 'G-SQ0WM6S28T',\n};\n\nlet firebaseApp = null;\nlet firebaseAuth = null;\nlet firestoreInstance = null; // To hold the specific DB instance\n\nfunction initializeFirebase() {\n if (firebaseApp) {\n console.log('[FirebaseClient] Firebase already initialized.');\n return;\n }\n try {\n firebaseApp = initializeApp(firebaseConfig);\n \n // Build a *class* persistence provider and hand it to Firebase.\n const ElectronStorePersistence = createElectronStorePersistence('firebase-auth-session');\n\n firebaseAuth = initializeAuth(firebaseApp, {\n // `initializeAuth` accepts a single class or an array – we pass an array for future\n // extensibility and to match Firebase examples.\n persistence: [ElectronStorePersistence],\n });\n\n // Initialize Firestore with the specific database ID\n firestoreInstance = getFirestore(firebaseApp, 'pickle-glass');\n\n console.log('[FirebaseClient] Firebase initialized successfully with class-based electron-store persistence.');\n console.log('[FirebaseClient] Firestore instance is targeting the \"pickle-glass\" database.');\n } catch (error) {\n console.error('[FirebaseClient] Firebase initialization failed:', error);\n }\n}\n\nfunction getFirebaseAuth() {\n if (!firebaseAuth) {\n throw new Error(\"Firebase Auth has not been initialized. Call initializeFirebase() first.\");\n }\n return firebaseAuth;\n}\n\nfunction getFirestoreInstance() {\n if (!firestoreInstance) {\n throw new Error(\"Firestore has not been initialized. Call initializeFirebase() first.\");\n }\n return firestoreInstance;\n}\n\nmodule.exports = {\n initializeFirebase,\n getFirebaseAuth,\n getFirestoreInstance,\n}; "], ["/glass/src/features/common/ai/factory.js", "// factory.js\n\n/**\n * @typedef {object} ModelOption\n * @property {string} id \n * @property {string} name\n */\n\n/**\n * @typedef {object} Provider\n * @property {string} name\n * @property {() => any} handler\n * @property {ModelOption[]} llmModels\n * @property {ModelOption[]} sttModels\n */\n\n/**\n * @type {Object.}\n */\nconst PROVIDERS = {\n 'openai': {\n name: 'OpenAI',\n handler: () => require(\"./providers/openai\"),\n llmModels: [\n { id: 'gpt-4.1', name: 'GPT-4.1' },\n ],\n sttModels: [\n { id: 'gpt-4o-mini-transcribe', name: 'GPT-4o Mini Transcribe' }\n ],\n },\n\n 'openai-glass': {\n name: 'OpenAI (Glass)',\n handler: () => require(\"./providers/openai\"),\n llmModels: [\n { id: 'gpt-4.1-glass', name: 'GPT-4.1 (glass)' },\n ],\n sttModels: [\n { id: 'gpt-4o-mini-transcribe-glass', name: 'GPT-4o Mini Transcribe (glass)' }\n ],\n },\n 'gemini': {\n name: 'Gemini',\n handler: () => require(\"./providers/gemini\"),\n llmModels: [\n { id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash' },\n ],\n sttModels: [\n { id: 'gemini-live-2.5-flash-preview', name: 'Gemini Live 2.5 Flash' }\n ],\n },\n 'anthropic': {\n name: 'Anthropic',\n handler: () => require(\"./providers/anthropic\"),\n llmModels: [\n { id: 'claude-3-5-sonnet-20241022', name: 'Claude 3.5 Sonnet' },\n ],\n sttModels: [],\n },\n 'deepgram': {\n name: 'Deepgram',\n handler: () => require(\"./providers/deepgram\"),\n llmModels: [],\n sttModels: [\n { id: 'nova-3', name: 'Nova-3 (General)' },\n ],\n },\n 'ollama': {\n name: 'Ollama (Local)',\n handler: () => require(\"./providers/ollama\"),\n llmModels: [], // Dynamic models populated from installed Ollama models\n sttModels: [], // Ollama doesn't support STT yet\n },\n 'whisper': {\n name: 'Whisper (Local)',\n handler: () => {\n // This needs to remain a function due to its conditional logic for renderer/main process\n if (typeof window === 'undefined') {\n const { WhisperProvider } = require(\"./providers/whisper\");\n return new WhisperProvider();\n }\n // Return a dummy object for the renderer process\n return {\n validateApiKey: async () => ({ success: true }), // Mock validate for renderer\n createSTT: () => { throw new Error('Whisper STT is only available in main process'); },\n };\n },\n llmModels: [],\n sttModels: [\n { id: 'whisper-tiny', name: 'Whisper Tiny (39M)' },\n { id: 'whisper-base', name: 'Whisper Base (74M)' },\n { id: 'whisper-small', name: 'Whisper Small (244M)' },\n { id: 'whisper-medium', name: 'Whisper Medium (769M)' },\n ],\n },\n};\n\nfunction sanitizeModelId(model) {\n return (typeof model === 'string') ? model.replace(/-glass$/, '') : model;\n}\n\nfunction createSTT(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n \n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createSTT) {\n throw new Error(`STT not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createSTT(opts);\n}\n\nfunction createLLM(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n\n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createLLM) {\n throw new Error(`LLM not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createLLM(opts);\n}\n\nfunction createStreamingLLM(provider, opts) {\n if (provider === 'openai-glass') provider = 'openai';\n \n const handler = PROVIDERS[provider]?.handler();\n if (!handler?.createStreamingLLM) {\n throw new Error(`Streaming LLM not supported for provider: ${provider}`);\n }\n if (opts && opts.model) {\n opts = { ...opts, model: sanitizeModelId(opts.model) };\n }\n return handler.createStreamingLLM(opts);\n}\n\nfunction getProviderClass(providerId) {\n const providerConfig = PROVIDERS[providerId];\n if (!providerConfig) return null;\n \n // Handle special cases for glass providers\n let actualProviderId = providerId;\n if (providerId === 'openai-glass') {\n actualProviderId = 'openai';\n }\n \n // The handler function returns the module, from which we get the class.\n const module = providerConfig.handler();\n \n // Map provider IDs to their actual exported class names\n const classNameMap = {\n 'openai': 'OpenAIProvider',\n 'anthropic': 'AnthropicProvider',\n 'gemini': 'GeminiProvider',\n 'deepgram': 'DeepgramProvider',\n 'ollama': 'OllamaProvider',\n 'whisper': 'WhisperProvider'\n };\n \n const className = classNameMap[actualProviderId];\n return className ? module[className] : null;\n}\n\nfunction getAvailableProviders() {\n const stt = [];\n const llm = [];\n for (const [id, provider] of Object.entries(PROVIDERS)) {\n if (provider.sttModels.length > 0) stt.push(id);\n if (provider.llmModels.length > 0) llm.push(id);\n }\n return { stt: [...new Set(stt)], llm: [...new Set(llm)] };\n}\n\nmodule.exports = {\n PROVIDERS,\n createSTT,\n createLLM,\n createStreamingLLM,\n getProviderClass,\n getAvailableProviders,\n};"], ["/glass/src/ui/listen/summary/SummaryView.js", "import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';\n\nexport class SummaryView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n /* Inherit font styles from parent */\n\n /* highlight.js 스타일 추가 */\n .insights-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .insights-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .insights-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n }\n\n .insights-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n }\n\n .hljs-keyword {\n color: #ff79c6 !important;\n }\n .hljs-string {\n color: #f1fa8c !important;\n }\n .hljs-comment {\n color: #6272a4 !important;\n }\n .hljs-number {\n color: #bd93f9 !important;\n }\n .hljs-function {\n color: #50fa7b !important;\n }\n .hljs-variable {\n color: #8be9fd !important;\n }\n .hljs-built_in {\n color: #ffb86c !important;\n }\n .hljs-title {\n color: #50fa7b !important;\n }\n .hljs-attr {\n color: #50fa7b !important;\n }\n .hljs-tag {\n color: #ff79c6 !important;\n }\n\n .insights-container {\n overflow-y: auto;\n padding: 12px 16px 16px 16px;\n position: relative;\n z-index: 1;\n min-height: 150px;\n max-height: 600px;\n flex: 1;\n }\n\n /* Visibility handled by parent component */\n\n .insights-container::-webkit-scrollbar {\n width: 8px;\n }\n .insights-container::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n }\n .insights-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.3);\n border-radius: 4px;\n }\n .insights-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.5);\n }\n\n insights-title {\n color: rgba(255, 255, 255, 0.8);\n font-size: 15px;\n font-weight: 500;\n font-family: 'Helvetica Neue', sans-serif;\n margin: 12px 0 8px 0;\n display: block;\n }\n\n .insights-container h4 {\n color: #ffffff;\n font-size: 12px;\n font-weight: 600;\n margin: 12px 0 8px 0;\n padding: 4px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: default;\n }\n\n .insights-container h4:hover {\n background: transparent;\n }\n\n .insights-container h4:first-child {\n margin-top: 0;\n }\n\n .outline-item {\n color: #ffffff;\n font-size: 11px;\n line-height: 1.4;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n transition: background-color 0.15s ease;\n cursor: pointer;\n word-wrap: break-word;\n }\n\n .outline-item:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .request-item {\n color: #ffffff;\n font-size: 12px;\n line-height: 1.2;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: default;\n word-wrap: break-word;\n transition: background-color 0.15s ease;\n }\n\n .request-item.clickable {\n cursor: pointer;\n transition: all 0.15s ease;\n }\n .request-item.clickable:hover {\n background: rgba(255, 255, 255, 0.1);\n transform: translateX(2px);\n }\n\n /* 마크다운 렌더링된 콘텐츠 스타일 */\n .markdown-content {\n color: #ffffff;\n font-size: 11px;\n line-height: 1.4;\n margin: 4px 0;\n padding: 6px 8px;\n border-radius: 4px;\n background: transparent;\n cursor: pointer;\n word-wrap: break-word;\n transition: all 0.15s ease;\n }\n\n .markdown-content:hover {\n background: rgba(255, 255, 255, 0.1);\n transform: translateX(2px);\n }\n\n .markdown-content p {\n margin: 4px 0;\n }\n\n .markdown-content ul,\n .markdown-content ol {\n margin: 4px 0;\n padding-left: 16px;\n }\n\n .markdown-content li {\n margin: 2px 0;\n }\n\n .markdown-content a {\n color: #8be9fd;\n text-decoration: none;\n }\n\n .markdown-content a:hover {\n text-decoration: underline;\n }\n\n .markdown-content strong {\n font-weight: 600;\n color: #f8f8f2;\n }\n\n .markdown-content em {\n font-style: italic;\n color: #f1fa8c;\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100px;\n color: rgba(255, 255, 255, 0.6);\n font-size: 12px;\n font-style: italic;\n }\n `;\n\n static properties = {\n structuredData: { type: Object },\n isVisible: { type: Boolean },\n hasCompletedRecording: { type: Boolean },\n };\n\n constructor() {\n super();\n this.structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: [],\n };\n this.isVisible = true;\n this.hasCompletedRecording = false;\n\n // 마크다운 라이브러리 초기화\n this.marked = null;\n this.hljs = null;\n this.isLibrariesLoaded = false;\n this.DOMPurify = null;\n this.isDOMPurifyLoaded = false;\n\n this.loadLibraries();\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (window.api) {\n window.api.summaryView.onSummaryUpdate((event, data) => {\n this.structuredData = data;\n this.requestUpdate();\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.summaryView.removeAllSummaryUpdateListeners();\n }\n }\n\n // Handle session reset from parent\n resetAnalysis() {\n this.structuredData = {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n followUps: [],\n };\n this.requestUpdate();\n }\n\n async loadLibraries() {\n try {\n if (!window.marked) {\n await this.loadScript('../../../assets/marked-4.3.0.min.js');\n }\n\n if (!window.hljs) {\n await this.loadScript('../../../assets/highlight-11.9.0.min.js');\n }\n\n if (!window.DOMPurify) {\n await this.loadScript('../../../assets/dompurify-3.0.7.min.js');\n }\n\n this.marked = window.marked;\n this.hljs = window.hljs;\n this.DOMPurify = window.DOMPurify;\n\n if (this.marked && this.hljs) {\n this.marked.setOptions({\n highlight: (code, lang) => {\n if (lang && this.hljs.getLanguage(lang)) {\n try {\n return this.hljs.highlight(code, { language: lang }).value;\n } catch (err) {\n console.warn('Highlight error:', err);\n }\n }\n try {\n return this.hljs.highlightAuto(code).value;\n } catch (err) {\n console.warn('Auto highlight error:', err);\n }\n return code;\n },\n breaks: true,\n gfm: true,\n pedantic: false,\n smartypants: false,\n xhtml: false,\n });\n\n this.isLibrariesLoaded = true;\n console.log('Markdown libraries loaded successfully');\n }\n\n if (this.DOMPurify) {\n this.isDOMPurifyLoaded = true;\n console.log('DOMPurify loaded successfully in SummaryView');\n }\n } catch (error) {\n console.error('Failed to load libraries:', error);\n }\n }\n\n loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n parseMarkdown(text) {\n if (!text) return '';\n\n if (!this.isLibrariesLoaded || !this.marked) {\n return text;\n }\n\n try {\n return this.marked(text);\n } catch (error) {\n console.error('Markdown parsing error:', error);\n return text;\n }\n }\n\n handleMarkdownClick(originalText) {\n this.handleRequestClick(originalText);\n }\n\n renderMarkdownContent() {\n if (!this.isLibrariesLoaded || !this.marked) {\n return;\n }\n\n const markdownElements = this.shadowRoot.querySelectorAll('[data-markdown-id]');\n markdownElements.forEach(element => {\n const originalText = element.getAttribute('data-original-text');\n if (originalText) {\n try {\n let parsedHTML = this.parseMarkdown(originalText);\n\n if (this.isDOMPurifyLoaded && this.DOMPurify) {\n parsedHTML = this.DOMPurify.sanitize(parsedHTML);\n\n if (this.DOMPurify.removed && this.DOMPurify.removed.length > 0) {\n console.warn('Unsafe content detected in insights, showing plain text');\n element.textContent = '⚠️ ' + originalText;\n return;\n }\n }\n\n element.innerHTML = parsedHTML;\n } catch (error) {\n console.error('Error rendering markdown for element:', error);\n element.textContent = originalText;\n }\n }\n });\n }\n\n async handleRequestClick(requestText) {\n console.log('🔥 Analysis request clicked:', requestText);\n\n if (window.api) {\n try {\n const result = await window.api.summaryView.sendQuestionFromSummary(requestText);\n\n if (result.success) {\n console.log('✅ Question sent to AskView successfully');\n } else {\n console.error('❌ Failed to send question to AskView:', result.error);\n }\n } catch (error) {\n console.error('❌ Error in handleRequestClick:', error);\n }\n }\n }\n\n getSummaryText() {\n const data = this.structuredData || { summary: [], topic: { header: '', bullets: [] }, actions: [] };\n let sections = [];\n\n if (data.summary && data.summary.length > 0) {\n sections.push(`Current Summary:\\n${data.summary.map(s => `• ${s}`).join('\\n')}`);\n }\n\n if (data.topic && data.topic.header && data.topic.bullets.length > 0) {\n sections.push(`\\n${data.topic.header}:\\n${data.topic.bullets.map(b => `• ${b}`).join('\\n')}`);\n }\n\n if (data.actions && data.actions.length > 0) {\n sections.push(`\\nActions:\\n${data.actions.map(a => `▸ ${a}`).join('\\n')}`);\n }\n\n if (data.followUps && data.followUps.length > 0) {\n sections.push(`\\nFollow-Ups:\\n${data.followUps.map(f => `▸ ${f}`).join('\\n')}`);\n }\n\n return sections.join('\\n\\n').trim();\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.renderMarkdownContent();\n }\n\n render() {\n if (!this.isVisible) {\n return html`
`;\n }\n\n const data = this.structuredData || {\n summary: [],\n topic: { header: '', bullets: [] },\n actions: [],\n };\n\n const hasAnyContent = data.summary.length > 0 || data.topic.bullets.length > 0 || data.actions.length > 0;\n\n return html`\n
\n ${!hasAnyContent\n ? html`
No insights yet...
`\n : html`\n Current Summary\n ${data.summary.length > 0\n ? data.summary\n .slice(0, 5)\n .map(\n (bullet, index) => html`\n this.handleMarkdownClick(bullet)}\n >\n ${bullet}\n
\n `\n )\n : html`
No content yet...
`}\n ${data.topic.header\n ? html`\n ${data.topic.header}\n ${data.topic.bullets\n .slice(0, 3)\n .map(\n (bullet, index) => html`\n this.handleMarkdownClick(bullet)}\n >\n ${bullet}\n \n `\n )}\n `\n : ''}\n ${data.actions.length > 0\n ? html`\n Actions\n ${data.actions\n .slice(0, 5)\n .map(\n (action, index) => html`\n this.handleMarkdownClick(action)}\n >\n ${action}\n \n `\n )}\n `\n : ''}\n ${this.hasCompletedRecording && data.followUps && data.followUps.length > 0\n ? html`\n Follow-Ups\n ${data.followUps.map(\n (followUp, index) => html`\n this.handleMarkdownClick(followUp)}\n >\n ${followUp}\n \n `\n )}\n `\n : ''}\n `}\n \n `;\n }\n}\n\ncustomElements.define('summary-view', SummaryView); "], ["/glass/src/features/common/repositories/providerSettings/index.js", "const sqliteRepository = require('./sqlite.repository');\n\nfunction getBaseRepository() {\n // For now, we only have sqlite. This could be expanded later.\n return sqliteRepository;\n}\n\nconst providerSettingsRepositoryAdapter = {\n // Core CRUD operations\n async getByProvider(provider) {\n const repo = getBaseRepository();\n return await repo.getByProvider(provider);\n },\n\n async getAll() {\n const repo = getBaseRepository();\n return await repo.getAll();\n },\n\n async upsert(provider, settings) {\n const repo = getBaseRepository();\n const now = Date.now();\n \n const settingsWithMeta = {\n ...settings,\n provider,\n updated_at: now,\n created_at: settings.created_at || now\n };\n \n return await repo.upsert(provider, settingsWithMeta);\n },\n\n async remove(provider) {\n const repo = getBaseRepository();\n return await repo.remove(provider);\n },\n\n async removeAll() {\n const repo = getBaseRepository();\n return await repo.removeAll();\n },\n\n async getRawApiKeys() {\n // This function should always target the local sqlite DB,\n // as it's part of the local-first boot sequence.\n return await sqliteRepository.getRawApiKeys();\n },\n \n async getActiveProvider(type) {\n const repo = getBaseRepository();\n return await repo.getActiveProvider(type);\n },\n \n async setActiveProvider(provider, type) {\n const repo = getBaseRepository();\n return await repo.setActiveProvider(provider, type);\n },\n \n async getActiveSettings() {\n const repo = getBaseRepository();\n return await repo.getActiveSettings();\n }\n};\n\nmodule.exports = {\n ...providerSettingsRepositoryAdapter\n}; "], ["/glass/src/ui/listen/stt/SttView.js", "import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';\n\nexport class SttView extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n /* Inherit font styles from parent */\n\n .transcription-container {\n overflow-y: auto;\n padding: 12px 12px 16px 12px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-height: 150px;\n max-height: 600px;\n position: relative;\n z-index: 1;\n flex: 1;\n }\n\n /* Visibility handled by parent component */\n\n .transcription-container::-webkit-scrollbar {\n width: 8px;\n }\n .transcription-container::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n }\n .transcription-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.3);\n border-radius: 4px;\n }\n .transcription-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.5);\n }\n\n .stt-message {\n padding: 8px 12px;\n border-radius: 12px;\n max-width: 80%;\n word-wrap: break-word;\n word-break: break-word;\n line-height: 1.5;\n font-size: 13px;\n margin-bottom: 4px;\n box-sizing: border-box;\n }\n\n .stt-message.them {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.9);\n align-self: flex-start;\n border-bottom-left-radius: 4px;\n margin-right: auto;\n }\n\n .stt-message.me {\n background: rgba(0, 122, 255, 0.8);\n color: white;\n align-self: flex-end;\n border-bottom-right-radius: 4px;\n margin-left: auto;\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100px;\n color: rgba(255, 255, 255, 0.6);\n font-size: 12px;\n font-style: italic;\n }\n `;\n\n static properties = {\n sttMessages: { type: Array },\n isVisible: { type: Boolean },\n };\n\n constructor() {\n super();\n this.sttMessages = [];\n this.isVisible = true;\n this.messageIdCounter = 0;\n this._shouldScrollAfterUpdate = false;\n\n this.handleSttUpdate = this.handleSttUpdate.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (window.api) {\n window.api.sttView.onSttUpdate(this.handleSttUpdate);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.sttView.removeOnSttUpdate(this.handleSttUpdate);\n }\n }\n\n // Handle session reset from parent\n resetTranscript() {\n this.sttMessages = [];\n this.requestUpdate();\n }\n\n handleSttUpdate(event, { speaker, text, isFinal, isPartial }) {\n if (text === undefined) return;\n\n const container = this.shadowRoot.querySelector('.transcription-container');\n this._shouldScrollAfterUpdate = container ? container.scrollTop + container.clientHeight >= container.scrollHeight - 10 : false;\n\n const findLastPartialIdx = spk => {\n for (let i = this.sttMessages.length - 1; i >= 0; i--) {\n const m = this.sttMessages[i];\n if (m.speaker === spk && m.isPartial) return i;\n }\n return -1;\n };\n\n const newMessages = [...this.sttMessages];\n const targetIdx = findLastPartialIdx(speaker);\n\n if (isPartial) {\n if (targetIdx !== -1) {\n newMessages[targetIdx] = {\n ...newMessages[targetIdx],\n text,\n isPartial: true,\n isFinal: false,\n };\n } else {\n newMessages.push({\n id: this.messageIdCounter++,\n speaker,\n text,\n isPartial: true,\n isFinal: false,\n });\n }\n } else if (isFinal) {\n if (targetIdx !== -1) {\n newMessages[targetIdx] = {\n ...newMessages[targetIdx],\n text,\n isPartial: false,\n isFinal: true,\n };\n } else {\n newMessages.push({\n id: this.messageIdCounter++,\n speaker,\n text,\n isPartial: false,\n isFinal: true,\n });\n }\n }\n\n this.sttMessages = newMessages;\n \n // Notify parent component about message updates\n this.dispatchEvent(new CustomEvent('stt-messages-updated', {\n detail: { messages: this.sttMessages },\n bubbles: true\n }));\n }\n\n scrollToBottom() {\n setTimeout(() => {\n const container = this.shadowRoot.querySelector('.transcription-container');\n if (container) {\n container.scrollTop = container.scrollHeight;\n }\n }, 0);\n }\n\n getSpeakerClass(speaker) {\n return speaker.toLowerCase() === 'me' ? 'me' : 'them';\n }\n\n getTranscriptText() {\n return this.sttMessages.map(msg => `${msg.speaker}: ${msg.text}`).join('\\n');\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n\n if (changedProperties.has('sttMessages')) {\n if (this._shouldScrollAfterUpdate) {\n this.scrollToBottom();\n this._shouldScrollAfterUpdate = false;\n }\n }\n }\n\n render() {\n if (!this.isVisible) {\n return html`
`;\n }\n\n return html`\n
\n ${this.sttMessages.length === 0\n ? html`
Waiting for speech...
`\n : this.sttMessages.map(msg => html`\n
\n ${msg.text}\n
\n `)\n }\n
\n `;\n }\n}\n\ncustomElements.define('stt-view', SttView); "], ["/glass/src/bridge/featureBridge.js", "// src/bridge/featureBridge.js\nconst { ipcMain, app, BrowserWindow } = require('electron');\nconst settingsService = require('../features/settings/settingsService');\nconst authService = require('../features/common/services/authService');\nconst whisperService = require('../features/common/services/whisperService');\nconst ollamaService = require('../features/common/services/ollamaService');\nconst modelStateService = require('../features/common/services/modelStateService');\nconst shortcutsService = require('../features/shortcuts/shortcutsService');\nconst presetRepository = require('../features/common/repositories/preset');\nconst localAIManager = require('../features/common/services/localAIManager');\nconst askService = require('../features/ask/askService');\nconst listenService = require('../features/listen/listenService');\nconst permissionService = require('../features/common/services/permissionService');\nconst encryptionService = require('../features/common/services/encryptionService');\n\nmodule.exports = {\n // Renderer로부터의 요청을 수신하고 서비스로 전달\n initialize() {\n // Settings Service\n ipcMain.handle('settings:getPresets', async () => await settingsService.getPresets());\n ipcMain.handle('settings:get-auto-update', async () => await settingsService.getAutoUpdateSetting());\n ipcMain.handle('settings:set-auto-update', async (event, isEnabled) => await settingsService.setAutoUpdateSetting(isEnabled)); \n ipcMain.handle('settings:get-model-settings', async () => await settingsService.getModelSettings());\n ipcMain.handle('settings:clear-api-key', async (e, { provider }) => await settingsService.clearApiKey(provider));\n ipcMain.handle('settings:set-selected-model', async (e, { type, modelId }) => await settingsService.setSelectedModel(type, modelId)); \n\n ipcMain.handle('settings:get-ollama-status', async () => await settingsService.getOllamaStatus());\n ipcMain.handle('settings:ensure-ollama-ready', async () => await settingsService.ensureOllamaReady());\n ipcMain.handle('settings:shutdown-ollama', async () => await settingsService.shutdownOllama());\n\n // Shortcuts\n ipcMain.handle('settings:getCurrentShortcuts', async () => await shortcutsService.loadKeybinds());\n ipcMain.handle('shortcut:getDefaultShortcuts', async () => await shortcutsService.handleRestoreDefaults());\n ipcMain.handle('shortcut:closeShortcutSettingsWindow', async () => await shortcutsService.closeShortcutSettingsWindow());\n ipcMain.handle('shortcut:openShortcutSettingsWindow', async () => await shortcutsService.openShortcutSettingsWindow());\n ipcMain.handle('shortcut:saveShortcuts', async (event, newKeybinds) => await shortcutsService.handleSaveShortcuts(newKeybinds));\n ipcMain.handle('shortcut:toggleAllWindowsVisibility', async () => await shortcutsService.toggleAllWindowsVisibility());\n\n // Permissions\n ipcMain.handle('check-system-permissions', async () => await permissionService.checkSystemPermissions());\n ipcMain.handle('request-microphone-permission', async () => await permissionService.requestMicrophonePermission());\n ipcMain.handle('open-system-preferences', async (event, section) => await permissionService.openSystemPreferences(section));\n ipcMain.handle('mark-keychain-completed', async () => await permissionService.markKeychainCompleted());\n ipcMain.handle('check-keychain-completed', async () => await permissionService.checkKeychainCompleted());\n ipcMain.handle('initialize-encryption-key', async () => {\n const userId = authService.getCurrentUserId();\n await encryptionService.initializeKey(userId);\n return { success: true };\n });\n\n // User/Auth\n ipcMain.handle('get-current-user', () => authService.getCurrentUser());\n ipcMain.handle('start-firebase-auth', async () => await authService.startFirebaseAuthFlow());\n ipcMain.handle('firebase-logout', async () => await authService.signOut());\n\n // App\n ipcMain.handle('quit-application', () => app.quit());\n\n // Whisper\n ipcMain.handle('whisper:download-model', async (event, modelId) => await whisperService.handleDownloadModel(modelId));\n ipcMain.handle('whisper:get-installed-models', async () => await whisperService.handleGetInstalledModels());\n \n // General\n ipcMain.handle('get-preset-templates', () => presetRepository.getPresetTemplates());\n ipcMain.handle('get-web-url', () => process.env.pickleglass_WEB_URL || 'http://localhost:3000');\n\n // Ollama\n ipcMain.handle('ollama:get-status', async () => await ollamaService.handleGetStatus());\n ipcMain.handle('ollama:install', async () => await ollamaService.handleInstall());\n ipcMain.handle('ollama:start-service', async () => await ollamaService.handleStartService());\n ipcMain.handle('ollama:ensure-ready', async () => await ollamaService.handleEnsureReady());\n ipcMain.handle('ollama:get-models', async () => await ollamaService.handleGetModels());\n ipcMain.handle('ollama:get-model-suggestions', async () => await ollamaService.handleGetModelSuggestions());\n ipcMain.handle('ollama:pull-model', async (event, modelName) => await ollamaService.handlePullModel(modelName));\n ipcMain.handle('ollama:is-model-installed', async (event, modelName) => await ollamaService.handleIsModelInstalled(modelName));\n ipcMain.handle('ollama:warm-up-model', async (event, modelName) => await ollamaService.handleWarmUpModel(modelName));\n ipcMain.handle('ollama:auto-warm-up', async () => await ollamaService.handleAutoWarmUp());\n ipcMain.handle('ollama:get-warm-up-status', async () => await ollamaService.handleGetWarmUpStatus());\n ipcMain.handle('ollama:shutdown', async (event, force = false) => await ollamaService.handleShutdown(force));\n\n // Ask\n ipcMain.handle('ask:sendQuestionFromAsk', async (event, userPrompt) => await askService.sendMessage(userPrompt));\n ipcMain.handle('ask:sendQuestionFromSummary', async (event, userPrompt) => await askService.sendMessage(userPrompt));\n ipcMain.handle('ask:toggleAskButton', async () => await askService.toggleAskButton());\n ipcMain.handle('ask:closeAskWindow', async () => await askService.closeAskWindow());\n \n // Listen\n ipcMain.handle('listen:sendMicAudio', async (event, { data, mimeType }) => await listenService.handleSendMicAudioContent(data, mimeType));\n ipcMain.handle('listen:sendSystemAudio', async (event, { data, mimeType }) => {\n const result = await listenService.sttService.sendSystemAudioContent(data, mimeType);\n if(result.success) {\n listenService.sendToRenderer('system-audio-data', { data });\n }\n return result;\n });\n ipcMain.handle('listen:startMacosSystemAudio', async () => await listenService.handleStartMacosAudio());\n ipcMain.handle('listen:stopMacosSystemAudio', async () => await listenService.handleStopMacosAudio());\n ipcMain.handle('update-google-search-setting', async (event, enabled) => await listenService.handleUpdateGoogleSearchSetting(enabled));\n ipcMain.handle('listen:isSessionActive', async () => await listenService.isSessionActive());\n ipcMain.handle('listen:changeSession', async (event, listenButtonText) => {\n console.log('[FeatureBridge] listen:changeSession from mainheader', listenButtonText);\n try {\n await listenService.handleListenRequest(listenButtonText);\n return { success: true };\n } catch (error) {\n console.error('[FeatureBridge] listen:changeSession failed', error.message);\n return { success: false, error: error.message };\n }\n });\n\n // ModelStateService\n ipcMain.handle('model:validate-key', async (e, { provider, key }) => await modelStateService.handleValidateKey(provider, key));\n ipcMain.handle('model:get-all-keys', async () => await modelStateService.getAllApiKeys());\n ipcMain.handle('model:set-api-key', async (e, { provider, key }) => await modelStateService.setApiKey(provider, key));\n ipcMain.handle('model:remove-api-key', async (e, provider) => await modelStateService.handleRemoveApiKey(provider));\n ipcMain.handle('model:get-selected-models', async () => await modelStateService.getSelectedModels());\n ipcMain.handle('model:set-selected-model', async (e, { type, modelId }) => await modelStateService.handleSetSelectedModel(type, modelId));\n ipcMain.handle('model:get-available-models', async (e, { type }) => await modelStateService.getAvailableModels(type));\n ipcMain.handle('model:are-providers-configured', async () => await modelStateService.areProvidersConfigured());\n ipcMain.handle('model:get-provider-config', () => modelStateService.getProviderConfig());\n ipcMain.handle('model:re-initialize-state', async () => await modelStateService.initialize());\n\n // LocalAIManager 이벤트를 모든 윈도우에 브로드캐스트\n localAIManager.on('install-progress', (service, data) => {\n const event = { service, ...data };\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:install-progress', event);\n }\n });\n });\n localAIManager.on('installation-complete', (service) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:installation-complete', { service });\n }\n });\n });\n localAIManager.on('error', (error) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:error-occurred', error);\n }\n });\n });\n // Handle error-occurred events from LocalAIManager's error handling\n localAIManager.on('error-occurred', (error) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:error-occurred', error);\n }\n });\n });\n localAIManager.on('model-ready', (data) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:model-ready', data);\n }\n });\n });\n localAIManager.on('state-changed', (service, state) => {\n const event = { service, ...state };\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('localai:service-status-changed', event);\n }\n });\n });\n\n // 주기적 상태 동기화 시작\n localAIManager.startPeriodicSync();\n\n // ModelStateService 이벤트를 모든 윈도우에 브로드캐스트\n modelStateService.on('state-updated', (state) => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('model-state:updated', state);\n }\n });\n });\n modelStateService.on('settings-updated', () => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('settings-updated');\n }\n });\n });\n modelStateService.on('force-show-apikey-header', () => {\n BrowserWindow.getAllWindows().forEach(win => {\n if (win && !win.isDestroyed()) {\n win.webContents.send('force-show-apikey-header');\n }\n });\n });\n\n // LocalAI 통합 핸들러 추가\n ipcMain.handle('localai:install', async (event, { service, options }) => {\n return await localAIManager.installService(service, options);\n });\n ipcMain.handle('localai:get-status', async (event, service) => {\n return await localAIManager.getServiceStatus(service);\n });\n ipcMain.handle('localai:start-service', async (event, service) => {\n return await localAIManager.startService(service);\n });\n ipcMain.handle('localai:stop-service', async (event, service) => {\n return await localAIManager.stopService(service);\n });\n ipcMain.handle('localai:install-model', async (event, { service, modelId, options }) => {\n return await localAIManager.installModel(service, modelId, options);\n });\n ipcMain.handle('localai:get-installed-models', async (event, service) => {\n return await localAIManager.getInstalledModels(service);\n });\n ipcMain.handle('localai:run-diagnostics', async (event, service) => {\n return await localAIManager.runDiagnostics(service);\n });\n ipcMain.handle('localai:repair-service', async (event, service) => {\n return await localAIManager.repairService(service);\n });\n \n // 에러 처리 핸들러\n ipcMain.handle('localai:handle-error', async (event, { service, errorType, details }) => {\n return await localAIManager.handleError(service, errorType, details);\n });\n \n // 전체 상태 조회\n ipcMain.handle('localai:get-all-states', async (event) => {\n return await localAIManager.getAllServiceStates();\n });\n\n console.log('[FeatureBridge] Initialized with all feature handlers.');\n },\n\n // Renderer로 상태를 전송\n sendAskProgress(win, progress) {\n win.webContents.send('feature:ask:progress', progress);\n },\n};"], ["/glass/src/ui/ask/AskView.js", "import { html, css, LitElement } from '../../ui/assets/lit-core-2.7.4.min.js';\nimport { parser, parser_write, parser_end, default_renderer } from '../../ui/assets/smd.js';\n\nexport class AskView extends LitElement {\n static properties = {\n currentResponse: { type: String },\n currentQuestion: { type: String },\n isLoading: { type: Boolean },\n copyState: { type: String },\n isHovering: { type: Boolean },\n hoveredLineIndex: { type: Number },\n lineCopyState: { type: Object },\n showTextInput: { type: Boolean },\n headerText: { type: String },\n headerAnimating: { type: Boolean },\n isStreaming: { type: Boolean },\n };\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n color: white;\n transform: translate3d(0, 0, 0);\n backface-visibility: hidden;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n will-change: transform, opacity;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n @keyframes slideUp {\n 0% {\n opacity: 1;\n transform: translateY(0) scale(1);\n filter: blur(0px);\n }\n 30% {\n opacity: 0.7;\n transform: translateY(-20%) scale(0.98);\n filter: blur(0.5px);\n }\n 70% {\n opacity: 0.3;\n transform: translateY(-80%) scale(0.92);\n filter: blur(1.5px);\n }\n 100% {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n filter: blur(2px);\n }\n }\n\n @keyframes slideDown {\n 0% {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n filter: blur(2px);\n }\n 30% {\n opacity: 0.5;\n transform: translateY(-50%) scale(0.92);\n filter: blur(1px);\n }\n 65% {\n opacity: 0.9;\n transform: translateY(-5%) scale(0.99);\n filter: blur(0.2px);\n }\n 85% {\n opacity: 0.98;\n transform: translateY(2%) scale(1.005);\n filter: blur(0px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0) scale(1);\n filter: blur(0px);\n }\n }\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n /* Allow text selection in assistant responses */\n .response-container, .response-container * {\n user-select: text !important;\n cursor: text !important;\n }\n\n .response-container pre {\n background: rgba(0, 0, 0, 0.4) !important;\n border-radius: 8px !important;\n padding: 12px !important;\n margin: 8px 0 !important;\n overflow-x: auto !important;\n border: 1px solid rgba(255, 255, 255, 0.1) !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .response-container code {\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace !important;\n font-size: 11px !important;\n background: transparent !important;\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n }\n\n .response-container pre code {\n white-space: pre !important;\n word-wrap: normal !important;\n word-break: normal !important;\n display: block !important;\n }\n\n .response-container p code {\n background: rgba(255, 255, 255, 0.1) !important;\n padding: 2px 4px !important;\n border-radius: 3px !important;\n color: #ffd700 !important;\n }\n\n .hljs-keyword {\n color: #ff79c6 !important;\n }\n .hljs-string {\n color: #f1fa8c !important;\n }\n .hljs-comment {\n color: #6272a4 !important;\n }\n .hljs-number {\n color: #bd93f9 !important;\n }\n .hljs-function {\n color: #50fa7b !important;\n }\n .hljs-variable {\n color: #8be9fd !important;\n }\n .hljs-built_in {\n color: #ffb86c !important;\n }\n .hljs-title {\n color: #50fa7b !important;\n }\n .hljs-attr {\n color: #50fa7b !important;\n }\n .hljs-tag {\n color: #ff79c6 !important;\n }\n\n .ask-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: rgba(0, 0, 0, 0.6);\n border-radius: 12px;\n outline: 0.5px rgba(255, 255, 255, 0.3) solid;\n outline-offset: -1px;\n backdrop-filter: blur(1px);\n box-sizing: border-box;\n position: relative;\n overflow: hidden;\n }\n\n .ask-container::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n border-radius: 12px;\n filter: blur(10px);\n z-index: -1;\n }\n\n .response-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 16px;\n background: transparent;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n flex-shrink: 0;\n }\n\n .response-header.hidden {\n display: none;\n }\n\n .header-left {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n }\n\n .response-icon {\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.2);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .response-icon svg {\n width: 12px;\n height: 12px;\n stroke: rgba(255, 255, 255, 0.9);\n }\n\n .response-label {\n font-size: 13px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.9);\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n\n .response-label.animating {\n animation: fadeInOut 0.3s ease-in-out;\n }\n\n @keyframes fadeInOut {\n 0% {\n opacity: 1;\n transform: translateY(0);\n }\n 50% {\n opacity: 0;\n transform: translateY(-10px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .header-right {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n justify-content: flex-end;\n }\n\n .question-text {\n font-size: 13px;\n color: rgba(255, 255, 255, 0.7);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 300px;\n margin-right: 8px;\n }\n\n .header-controls {\n display: flex;\n gap: 8px;\n align-items: center;\n flex-shrink: 0;\n }\n\n .copy-button {\n background: transparent;\n color: rgba(255, 255, 255, 0.9);\n border: 1px solid rgba(255, 255, 255, 0.2);\n padding: 4px;\n border-radius: 3px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 24px;\n height: 24px;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n position: relative;\n overflow: hidden;\n }\n\n .copy-button:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n\n .copy-button svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n }\n\n .copy-button .check-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .copy-icon {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.5);\n }\n\n .copy-button.copied .check-icon {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n\n .close-button {\n background: rgba(255, 255, 255, 0.07);\n color: white;\n border: none;\n padding: 4px;\n border-radius: 20px;\n outline: 1px rgba(255, 255, 255, 0.3) solid;\n outline-offset: -1px;\n backdrop-filter: blur(0.5px);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n }\n\n .close-button:hover {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 1);\n }\n\n .response-container {\n flex: 1;\n padding: 16px;\n padding-left: 48px;\n overflow-y: auto;\n font-size: 14px;\n line-height: 1.6;\n background: transparent;\n min-height: 0;\n max-height: 400px;\n position: relative;\n }\n\n .response-container.hidden {\n display: none;\n }\n\n .response-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .response-container::-webkit-scrollbar-track {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 3px;\n }\n\n .response-container::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n }\n\n .response-container::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .loading-dots {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n padding: 40px;\n }\n\n .loading-dot {\n width: 8px;\n height: 8px;\n background: rgba(255, 255, 255, 0.6);\n border-radius: 50%;\n animation: pulse 1.5s ease-in-out infinite;\n }\n\n .loading-dot:nth-child(1) {\n animation-delay: 0s;\n }\n\n .loading-dot:nth-child(2) {\n animation-delay: 0.2s;\n }\n\n .loading-dot:nth-child(3) {\n animation-delay: 0.4s;\n }\n\n @keyframes pulse {\n 0%,\n 80%,\n 100% {\n opacity: 0.3;\n transform: scale(0.8);\n }\n 40% {\n opacity: 1;\n transform: scale(1.2);\n }\n }\n\n .response-line {\n position: relative;\n padding: 2px 0;\n margin: 0;\n transition: background-color 0.15s ease;\n }\n\n .response-line:hover {\n background: rgba(255, 255, 255, 0.05);\n border-radius: 4px;\n }\n\n .line-copy-button {\n position: absolute;\n left: -32px;\n top: 50%;\n transform: translateY(-50%);\n background: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.2);\n border-radius: 3px;\n padding: 2px;\n cursor: pointer;\n opacity: 0;\n transition: opacity 0.15s ease, background-color 0.15s ease;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n }\n\n .response-line:hover .line-copy-button {\n opacity: 1;\n }\n\n .line-copy-button:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n\n .line-copy-button.copied {\n background: rgba(40, 167, 69, 0.3);\n }\n\n .line-copy-button svg {\n width: 12px;\n height: 12px;\n stroke: rgba(255, 255, 255, 0.9);\n }\n\n .text-input-container {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n background: rgba(0, 0, 0, 0.1);\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n flex-shrink: 0;\n transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;\n transform-origin: bottom;\n }\n\n .text-input-container.hidden {\n opacity: 0;\n transform: scaleY(0);\n padding: 0;\n height: 0;\n overflow: hidden;\n border-top: none;\n }\n\n .text-input-container.no-response {\n border-top: none;\n }\n\n #textInput {\n flex: 1;\n padding: 10px 14px;\n background: rgba(0, 0, 0, 0.2);\n border-radius: 20px;\n outline: none;\n border: none;\n color: white;\n font-size: 14px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 400;\n }\n\n #textInput::placeholder {\n color: rgba(255, 255, 255, 0.5);\n }\n\n #textInput:focus {\n outline: none;\n }\n\n .response-line h1,\n .response-line h2,\n .response-line h3,\n .response-line h4,\n .response-line h5,\n .response-line h6 {\n color: rgba(255, 255, 255, 0.95);\n margin: 16px 0 8px 0;\n font-weight: 600;\n }\n\n .response-line p {\n margin: 8px 0;\n color: rgba(255, 255, 255, 0.9);\n }\n\n .response-line ul,\n .response-line ol {\n margin: 8px 0;\n padding-left: 20px;\n }\n\n .response-line li {\n margin: 4px 0;\n color: rgba(255, 255, 255, 0.9);\n }\n\n .response-line code {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.95);\n padding: 2px 6px;\n border-radius: 4px;\n font-family: 'Monaco', 'Menlo', monospace;\n font-size: 13px;\n }\n\n .response-line pre {\n background: rgba(255, 255, 255, 0.05);\n color: rgba(255, 255, 255, 0.95);\n padding: 12px;\n border-radius: 6px;\n overflow-x: auto;\n margin: 12px 0;\n border: 1px solid rgba(255, 255, 255, 0.1);\n }\n\n .response-line pre code {\n background: none;\n padding: 0;\n }\n\n .response-line blockquote {\n border-left: 3px solid rgba(255, 255, 255, 0.3);\n margin: 12px 0;\n padding: 8px 16px;\n background: rgba(255, 255, 255, 0.05);\n color: rgba(255, 255, 255, 0.8);\n }\n\n .empty-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: rgba(255, 255, 255, 0.5);\n font-size: 14px;\n }\n\n .btn-gap {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n gap: 4px;\n }\n\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .ask-container,\n :host-context(body.has-glass) .response-header,\n :host-context(body.has-glass) .response-icon,\n :host-context(body.has-glass) .copy-button,\n :host-context(body.has-glass) .close-button,\n :host-context(body.has-glass) .line-copy-button,\n :host-context(body.has-glass) .text-input-container,\n :host-context(body.has-glass) .response-container pre,\n :host-context(body.has-glass) .response-container p code,\n :host-context(body.has-glass) .response-container pre code {\n background: transparent !important;\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .ask-container::before {\n display: none !important;\n }\n\n :host-context(body.has-glass) .copy-button:hover,\n :host-context(body.has-glass) .close-button:hover,\n :host-context(body.has-glass) .line-copy-button,\n :host-context(body.has-glass) .line-copy-button:hover,\n :host-context(body.has-glass) .response-line:hover {\n background: transparent !important;\n }\n\n :host-context(body.has-glass) .response-container::-webkit-scrollbar-track,\n :host-context(body.has-glass) .response-container::-webkit-scrollbar-thumb {\n background: transparent !important;\n }\n\n .submit-btn, .clear-btn {\n display: flex;\n align-items: center;\n background: transparent;\n color: white;\n border: none;\n border-radius: 6px;\n margin-left: 8px;\n font-size: 13px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n overflow: hidden;\n cursor: pointer;\n transition: background 0.15s;\n height: 32px;\n padding: 0 10px;\n box-shadow: none;\n }\n .submit-btn:hover, .clear-btn:hover {\n background: rgba(255,255,255,0.1);\n }\n .btn-label {\n margin-right: 8px;\n display: flex;\n align-items: center;\n height: 100%;\n }\n .btn-icon {\n background: rgba(255,255,255,0.1);\n border-radius: 13%;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n }\n .btn-icon img, .btn-icon svg {\n width: 13px;\n height: 13px;\n display: block;\n }\n .header-clear-btn {\n background: transparent;\n border: none;\n display: flex;\n align-items: center;\n gap: 2px;\n cursor: pointer;\n padding: 0 2px;\n }\n .header-clear-btn .icon-box {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n background-color: rgba(255, 255, 255, 0.1);\n border-radius: 13%;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .header-clear-btn:hover .icon-box {\n background-color: rgba(255,255,255,0.18);\n }\n `;\n\n constructor() {\n super();\n this.currentResponse = '';\n this.currentQuestion = '';\n this.isLoading = false;\n this.copyState = 'idle';\n this.showTextInput = true;\n this.headerText = 'AI Response';\n this.headerAnimating = false;\n this.isStreaming = false;\n\n this.marked = null;\n this.hljs = null;\n this.DOMPurify = null;\n this.isLibrariesLoaded = false;\n\n // SMD.js streaming markdown parser\n this.smdParser = null;\n this.smdContainer = null;\n this.lastProcessedLength = 0;\n\n this.handleSendText = this.handleSendText.bind(this);\n this.handleTextKeydown = this.handleTextKeydown.bind(this);\n this.handleCopy = this.handleCopy.bind(this);\n this.clearResponseContent = this.clearResponseContent.bind(this);\n this.handleEscKey = this.handleEscKey.bind(this);\n this.handleScroll = this.handleScroll.bind(this);\n this.handleCloseAskWindow = this.handleCloseAskWindow.bind(this);\n this.handleCloseIfNoContent = this.handleCloseIfNoContent.bind(this);\n\n this.loadLibraries();\n\n // --- Resize helpers ---\n this.isThrottled = false;\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n console.log('📱 AskView connectedCallback - IPC 이벤트 리스너 설정');\n\n document.addEventListener('keydown', this.handleEscKey);\n\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n const needed = entry.contentRect.height;\n const current = window.innerHeight;\n\n if (needed > current - 4) {\n this.requestWindowResize(Math.ceil(needed));\n }\n }\n });\n\n const container = this.shadowRoot?.querySelector('.ask-container');\n if (container) this.resizeObserver.observe(container);\n\n this.handleQuestionFromAssistant = (event, question) => {\n console.log('AskView: Received question from ListenView:', question);\n this.handleSendText(null, question);\n };\n\n if (window.api) {\n window.api.askView.onShowTextInput(() => {\n console.log('Show text input signal received');\n if (!this.showTextInput) {\n this.showTextInput = true;\n this.updateComplete.then(() => this.focusTextInput());\n } else {\n this.focusTextInput();\n }\n });\n\n window.api.askView.onScrollResponseUp(() => this.handleScroll('up'));\n window.api.askView.onScrollResponseDown(() => this.handleScroll('down'));\n window.api.askView.onAskStateUpdate((event, newState) => {\n this.currentResponse = newState.currentResponse;\n this.currentQuestion = newState.currentQuestion;\n this.isLoading = newState.isLoading;\n this.isStreaming = newState.isStreaming;\n \n const wasHidden = !this.showTextInput;\n this.showTextInput = newState.showTextInput;\n \n if (newState.showTextInput) {\n if (wasHidden) {\n this.updateComplete.then(() => this.focusTextInput());\n } else {\n this.focusTextInput();\n }\n }\n });\n console.log('AskView: IPC 이벤트 리스너 등록 완료');\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n\n console.log('📱 AskView disconnectedCallback - IPC 이벤트 리스너 제거');\n\n document.removeEventListener('keydown', this.handleEscKey);\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n if (this.headerAnimationTimeout) {\n clearTimeout(this.headerAnimationTimeout);\n }\n\n if (this.streamingTimeout) {\n clearTimeout(this.streamingTimeout);\n }\n\n Object.values(this.lineCopyTimeouts).forEach(timeout => clearTimeout(timeout));\n\n if (window.api) {\n window.api.askView.removeOnAskStateUpdate(this.handleAskStateUpdate);\n window.api.askView.removeOnShowTextInput(this.handleShowTextInput);\n window.api.askView.removeOnScrollResponseUp(this.handleScroll);\n window.api.askView.removeOnScrollResponseDown(this.handleScroll);\n console.log('✅ AskView: IPC 이벤트 리스너 제거 필요');\n }\n }\n\n\n async loadLibraries() {\n try {\n if (!window.marked) {\n await this.loadScript('../../assets/marked-4.3.0.min.js');\n }\n\n if (!window.hljs) {\n await this.loadScript('../../assets/highlight-11.9.0.min.js');\n }\n\n if (!window.DOMPurify) {\n await this.loadScript('../../assets/dompurify-3.0.7.min.js');\n }\n\n this.marked = window.marked;\n this.hljs = window.hljs;\n this.DOMPurify = window.DOMPurify;\n\n if (this.marked && this.hljs) {\n this.marked.setOptions({\n highlight: (code, lang) => {\n if (lang && this.hljs.getLanguage(lang)) {\n try {\n return this.hljs.highlight(code, { language: lang }).value;\n } catch (err) {\n console.warn('Highlight error:', err);\n }\n }\n try {\n return this.hljs.highlightAuto(code).value;\n } catch (err) {\n console.warn('Auto highlight error:', err);\n }\n return code;\n },\n breaks: true,\n gfm: true,\n pedantic: false,\n smartypants: false,\n xhtml: false,\n });\n\n this.isLibrariesLoaded = true;\n this.renderContent();\n console.log('Markdown libraries loaded successfully in AskView');\n }\n\n if (this.DOMPurify) {\n this.isDOMPurifyLoaded = true;\n console.log('DOMPurify loaded successfully in AskView');\n }\n } catch (error) {\n console.error('Failed to load libraries in AskView:', error);\n }\n }\n\n handleCloseAskWindow() {\n // this.clearResponseContent();\n window.api.askView.closeAskWindow();\n }\n\n handleCloseIfNoContent() {\n if (!this.currentResponse && !this.isLoading && !this.isStreaming) {\n this.handleCloseAskWindow();\n }\n }\n\n handleEscKey(e) {\n if (e.key === 'Escape') {\n e.preventDefault();\n this.handleCloseIfNoContent();\n }\n }\n\n clearResponseContent() {\n this.currentResponse = '';\n this.currentQuestion = '';\n this.isLoading = false;\n this.isStreaming = false;\n this.headerText = 'AI Response';\n this.showTextInput = true;\n this.lastProcessedLength = 0;\n this.smdParser = null;\n this.smdContainer = null;\n }\n\n handleInputFocus() {\n this.isInputFocused = true;\n }\n\n focusTextInput() {\n requestAnimationFrame(() => {\n const textInput = this.shadowRoot?.getElementById('textInput');\n if (textInput) {\n textInput.focus();\n }\n });\n }\n\n\n loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n parseMarkdown(text) {\n if (!text) return '';\n\n if (!this.isLibrariesLoaded || !this.marked) {\n return text;\n }\n\n try {\n return this.marked(text);\n } catch (error) {\n console.error('Markdown parsing error in AskView:', error);\n return text;\n }\n }\n\n fixIncompleteCodeBlocks(text) {\n if (!text) return text;\n\n const codeBlockMarkers = text.match(/```/g) || [];\n const markerCount = codeBlockMarkers.length;\n\n if (markerCount % 2 === 1) {\n return text + '\\n```';\n }\n\n return text;\n }\n\n handleScroll(direction) {\n const scrollableElement = this.shadowRoot.querySelector('#responseContainer');\n if (scrollableElement) {\n const scrollAmount = 100; // 한 번에 스크롤할 양 (px)\n if (direction === 'up') {\n scrollableElement.scrollTop -= scrollAmount;\n } else {\n scrollableElement.scrollTop += scrollAmount;\n }\n }\n }\n\n\n renderContent() {\n const responseContainer = this.shadowRoot.getElementById('responseContainer');\n if (!responseContainer) return;\n \n // Check loading state\n if (this.isLoading) {\n responseContainer.innerHTML = `\n
\n
\n
\n
\n
`;\n this.resetStreamingParser();\n return;\n }\n \n // If there is no response, show empty state\n if (!this.currentResponse) {\n responseContainer.innerHTML = `
...
`;\n this.resetStreamingParser();\n return;\n }\n \n // Set streaming markdown parser\n this.renderStreamingMarkdown(responseContainer);\n\n // After updating content, recalculate window height\n this.adjustWindowHeightThrottled();\n }\n\n resetStreamingParser() {\n this.smdParser = null;\n this.smdContainer = null;\n this.lastProcessedLength = 0;\n }\n\n renderStreamingMarkdown(responseContainer) {\n try {\n // 파서가 없거나 컨테이너가 변경되었으면 새로 생성\n if (!this.smdParser || this.smdContainer !== responseContainer) {\n this.smdContainer = responseContainer;\n this.smdContainer.innerHTML = '';\n \n // smd.js의 default_renderer 사용\n const renderer = default_renderer(this.smdContainer);\n this.smdParser = parser(renderer);\n this.lastProcessedLength = 0;\n }\n\n // 새로운 텍스트만 처리 (스트리밍 최적화)\n const currentText = this.currentResponse;\n const newText = currentText.slice(this.lastProcessedLength);\n \n if (newText.length > 0) {\n // 새로운 텍스트 청크를 파서에 전달\n parser_write(this.smdParser, newText);\n this.lastProcessedLength = currentText.length;\n }\n\n // 스트리밍이 완료되면 파서 종료\n if (!this.isStreaming && !this.isLoading) {\n parser_end(this.smdParser);\n }\n\n // 코드 하이라이팅 적용\n if (this.hljs) {\n responseContainer.querySelectorAll('pre code').forEach(block => {\n if (!block.hasAttribute('data-highlighted')) {\n this.hljs.highlightElement(block);\n block.setAttribute('data-highlighted', 'true');\n }\n });\n }\n\n // 스크롤을 맨 아래로\n responseContainer.scrollTop = responseContainer.scrollHeight;\n \n } catch (error) {\n console.error('Error rendering streaming markdown:', error);\n // 에러 발생 시 기본 텍스트 렌더링으로 폴백\n this.renderFallbackContent(responseContainer);\n }\n }\n\n renderFallbackContent(responseContainer) {\n const textToRender = this.currentResponse || '';\n \n if (this.isLibrariesLoaded && this.marked && this.DOMPurify) {\n try {\n // 마크다운 파싱\n const parsedHtml = this.marked.parse(textToRender);\n\n // DOMPurify로 정제\n const cleanHtml = this.DOMPurify.sanitize(parsedHtml, {\n ALLOWED_TAGS: [\n 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'br', 'strong', 'b', 'em', 'i',\n 'ul', 'ol', 'li', 'blockquote', 'code', 'pre', 'a', 'img', 'table', 'thead',\n 'tbody', 'tr', 'th', 'td', 'hr', 'sup', 'sub', 'del', 'ins',\n ],\n ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class', 'id', 'target', 'rel'],\n });\n\n responseContainer.innerHTML = cleanHtml;\n\n // 코드 하이라이팅 적용\n if (this.hljs) {\n responseContainer.querySelectorAll('pre code').forEach(block => {\n this.hljs.highlightElement(block);\n });\n }\n } catch (error) {\n console.error('Error in fallback rendering:', error);\n responseContainer.textContent = textToRender;\n }\n } else {\n // 라이브러리가 로드되지 않았을 때 기본 렌더링\n const basicHtml = textToRender\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\\n\\n/g, '

')\n .replace(/\\n/g, '
')\n .replace(/\\*\\*(.*?)\\*\\*/g, '$1')\n .replace(/\\*(.*?)\\*/g, '$1')\n .replace(/`([^`]+)`/g, '$1');\n\n responseContainer.innerHTML = `

${basicHtml}

`;\n }\n }\n\n\n requestWindowResize(targetHeight) {\n if (window.api) {\n window.api.askView.adjustWindowHeight(targetHeight);\n }\n }\n\n animateHeaderText(text) {\n this.headerAnimating = true;\n this.requestUpdate();\n\n setTimeout(() => {\n this.headerText = text;\n this.headerAnimating = false;\n this.requestUpdate();\n }, 150);\n }\n\n startHeaderAnimation() {\n this.animateHeaderText('analyzing screen...');\n\n if (this.headerAnimationTimeout) {\n clearTimeout(this.headerAnimationTimeout);\n }\n\n this.headerAnimationTimeout = setTimeout(() => {\n this.animateHeaderText('thinking...');\n }, 1500);\n }\n\n renderMarkdown(content) {\n if (!content) return '';\n\n if (this.isLibrariesLoaded && this.marked) {\n return this.parseMarkdown(content);\n }\n\n return content\n .replace(/\\*\\*(.*?)\\*\\*/g, '$1')\n .replace(/\\*(.*?)\\*/g, '$1')\n .replace(/`(.*?)`/g, '$1');\n }\n\n fixIncompleteMarkdown(text) {\n if (!text) return text;\n\n // 불완전한 볼드체 처리\n const boldCount = (text.match(/\\*\\*/g) || []).length;\n if (boldCount % 2 === 1) {\n text += '**';\n }\n\n // 불완전한 이탤릭체 처리\n const italicCount = (text.match(/(? closeBrackets) {\n text += ']';\n }\n\n const openParens = (text.match(/\\]\\(/g) || []).length;\n const closeParens = (text.match(/\\)\\s*$/g) || []).length;\n if (openParens > closeParens && text.endsWith('(')) {\n text += ')';\n }\n\n return text;\n }\n\n\n async handleCopy() {\n if (this.copyState === 'copied') return;\n\n let responseToCopy = this.currentResponse;\n\n if (this.isDOMPurifyLoaded && this.DOMPurify) {\n const testHtml = this.renderMarkdown(responseToCopy);\n const sanitized = this.DOMPurify.sanitize(testHtml);\n\n if (this.DOMPurify.removed && this.DOMPurify.removed.length > 0) {\n console.warn('Unsafe content detected, copy blocked');\n return;\n }\n }\n\n const textToCopy = `Question: ${this.currentQuestion}\\n\\nAnswer: ${responseToCopy}`;\n\n try {\n await navigator.clipboard.writeText(textToCopy);\n console.log('Content copied to clipboard');\n\n this.copyState = 'copied';\n this.requestUpdate();\n\n if (this.copyTimeout) {\n clearTimeout(this.copyTimeout);\n }\n\n this.copyTimeout = setTimeout(() => {\n this.copyState = 'idle';\n this.requestUpdate();\n }, 1500);\n } catch (err) {\n console.error('Failed to copy:', err);\n }\n }\n\n async handleLineCopy(lineIndex) {\n const originalLines = this.currentResponse.split('\\n');\n const lineToCopy = originalLines[lineIndex];\n\n if (!lineToCopy) return;\n\n try {\n await navigator.clipboard.writeText(lineToCopy);\n console.log('Line copied to clipboard');\n\n // '복사됨' 상태로 UI 즉시 업데이트\n this.lineCopyState = { ...this.lineCopyState, [lineIndex]: true };\n this.requestUpdate(); // LitElement에 UI 업데이트 요청\n\n // 기존 타임아웃이 있다면 초기화\n if (this.lineCopyTimeouts && this.lineCopyTimeouts[lineIndex]) {\n clearTimeout(this.lineCopyTimeouts[lineIndex]);\n }\n\n // ✨ 수정된 타임아웃: 1.5초 후 '복사됨' 상태 해제\n this.lineCopyTimeouts[lineIndex] = setTimeout(() => {\n const updatedState = { ...this.lineCopyState };\n delete updatedState[lineIndex];\n this.lineCopyState = updatedState;\n this.requestUpdate(); // UI 업데이트 요청\n }, 1500);\n } catch (err) {\n console.error('Failed to copy line:', err);\n }\n }\n\n async handleSendText(e, overridingText = '') {\n const textInput = this.shadowRoot?.getElementById('textInput');\n const text = (overridingText || textInput?.value || '').trim();\n // if (!text) return;\n\n textInput.value = '';\n\n if (window.api) {\n window.api.askView.sendMessage(text).catch(error => {\n console.error('Error sending text:', error);\n });\n }\n }\n\n handleTextKeydown(e) {\n // Fix for IME composition issue: Ignore Enter key presses while composing.\n if (e.isComposing) {\n return;\n }\n\n const isPlainEnter = e.key === 'Enter' && !e.shiftKey && !e.metaKey && !e.ctrlKey;\n const isModifierEnter = e.key === 'Enter' && (e.metaKey || e.ctrlKey);\n\n if (isPlainEnter || isModifierEnter) {\n e.preventDefault();\n this.handleSendText();\n }\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n \n // ✨ isLoading 또는 currentResponse가 변경될 때마다 뷰를 다시 그립니다.\n if (changedProperties.has('isLoading') || changedProperties.has('currentResponse')) {\n this.renderContent();\n }\n \n if (changedProperties.has('showTextInput') || changedProperties.has('isLoading') || changedProperties.has('currentResponse')) {\n this.adjustWindowHeightThrottled();\n }\n \n if (changedProperties.has('showTextInput') && this.showTextInput) {\n this.focusTextInput();\n }\n }\n\n firstUpdated() {\n setTimeout(() => this.adjustWindowHeight(), 200);\n }\n\n\n getTruncatedQuestion(question, maxLength = 30) {\n if (!question) return '';\n if (question.length <= maxLength) return question;\n return question.substring(0, maxLength) + '...';\n }\n\n\n\n render() {\n const hasResponse = this.isLoading || this.currentResponse || this.isStreaming;\n const headerText = this.isLoading ? 'Thinking...' : 'AI Response';\n\n return html`\n
\n \n
\n
\n
\n \n \n \n \n
\n ${headerText}\n
\n
\n ${this.getTruncatedQuestion(this.currentQuestion)}\n
\n \n \n
\n
\n
\n\n \n
\n \n
\n\n \n
\n \n \n Submit\n \n ↵\n \n \n
\n
\n `;\n }\n\n // Dynamically resize the BrowserWindow to fit current content\n adjustWindowHeight() {\n if (!window.api) return;\n\n this.updateComplete.then(() => {\n const headerEl = this.shadowRoot.querySelector('.response-header');\n const responseEl = this.shadowRoot.querySelector('.response-container');\n const inputEl = this.shadowRoot.querySelector('.text-input-container');\n\n if (!headerEl || !responseEl) return;\n\n const headerHeight = headerEl.classList.contains('hidden') ? 0 : headerEl.offsetHeight;\n const responseHeight = responseEl.scrollHeight;\n const inputHeight = (inputEl && !inputEl.classList.contains('hidden')) ? inputEl.offsetHeight : 0;\n\n const idealHeight = headerHeight + responseHeight + inputHeight;\n\n const targetHeight = Math.min(700, idealHeight);\n\n window.api.askView.adjustWindowHeight(\"ask\", targetHeight);\n\n }).catch(err => console.error('AskView adjustWindowHeight error:', err));\n }\n\n // Throttled wrapper to avoid excessive IPC spam (executes at most once per animation frame)\n adjustWindowHeightThrottled() {\n if (this.isThrottled) return;\n\n this.isThrottled = true;\n requestAnimationFrame(() => {\n this.adjustWindowHeight();\n this.isThrottled = false;\n });\n }\n}\n\ncustomElements.define('ask-view', AskView);\n"], ["/glass/src/ui/app/PermissionHeader.js", "import { LitElement, html, css } from '../assets/lit-core-2.7.4.min.js';\n\nexport class PermissionHeader extends LitElement {\n static styles = css`\n :host {\n display: block;\n transition: opacity 0.3s ease-in, transform 0.3s ease-in;\n will-change: opacity, transform;\n }\n\n :host(.sliding-out) {\n opacity: 0;\n transform: translateY(-20px);\n }\n\n :host(.hidden) {\n opacity: 0;\n pointer-events: none;\n }\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n box-sizing: border-box;\n }\n\n .container {\n -webkit-app-region: drag;\n width: 285px;\n /* height is now set dynamically */\n padding: 18px 20px;\n background: rgba(0, 0, 0, 0.3);\n border-radius: 16px;\n overflow: hidden;\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .container::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 16px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 10px;\n right: 10px;\n width: 14px;\n height: 14px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 3px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 14px;\n line-height: 1;\n padding: 0;\n }\n\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n\n .close-button:active {\n transform: scale(0.95);\n }\n\n .title {\n color: white;\n font-size: 16px;\n font-weight: 500;\n margin: 0;\n text-align: center;\n flex-shrink: 0;\n }\n\n .form-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 100%;\n margin-top: auto;\n }\n\n .form-content.all-granted {\n flex-grow: 1;\n justify-content: center;\n margin-top: 0;\n }\n\n .subtitle {\n color: rgba(255, 255, 255, 0.7);\n font-size: 11px;\n font-weight: 400;\n text-align: center;\n margin-bottom: 12px;\n line-height: 1.3;\n }\n\n .permission-status {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-bottom: 12px;\n min-height: 20px;\n }\n\n .permission-item {\n display: flex;\n align-items: center;\n gap: 6px;\n color: rgba(255, 255, 255, 0.8);\n font-size: 11px;\n font-weight: 400;\n }\n\n .permission-item.granted {\n color: rgba(34, 197, 94, 0.9);\n }\n\n .permission-icon {\n width: 12px;\n height: 12px;\n opacity: 0.8;\n }\n\n .check-icon {\n width: 12px;\n height: 12px;\n color: rgba(34, 197, 94, 0.9);\n }\n\n .action-button {\n -webkit-app-region: no-drag;\n width: 100%;\n height: 34px;\n background: rgba(255, 255, 255, 0.2);\n border: none;\n border-radius: 10px;\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s ease;\n position: relative;\n overflow: hidden;\n margin-bottom: 6px;\n }\n\n .action-button::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 10px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .action-button:hover:not(:disabled) {\n background: rgba(255, 255, 255, 0.3);\n }\n\n .action-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .continue-button {\n -webkit-app-region: no-drag;\n width: 100%;\n height: 34px;\n background: rgba(34, 197, 94, 0.8);\n border: none;\n border-radius: 10px;\n color: white;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s ease;\n position: relative;\n overflow: hidden;\n margin-top: 4px;\n }\n\n .continue-button::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 10px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.5) 100%);\n -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .continue-button:hover:not(:disabled) {\n background: rgba(34, 197, 94, 0.9);\n }\n\n .continue-button:disabled {\n background: rgba(255, 255, 255, 0.2);\n cursor: not-allowed;\n }\n \n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .container,\n :host-context(body.has-glass) .action-button,\n :host-context(body.has-glass) .continue-button,\n :host-context(body.has-glass) .close-button {\n background: transparent !important;\n border: none !important;\n box-shadow: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n }\n\n :host-context(body.has-glass) .container::after,\n :host-context(body.has-glass) .action-button::after,\n :host-context(body.has-glass) .continue-button::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .action-button:hover,\n :host-context(body.has-glass) .continue-button:hover,\n :host-context(body.has-glass) .close-button:hover {\n background: transparent !important;\n }\n `;\n\n static properties = {\n microphoneGranted: { type: String },\n screenGranted: { type: String },\n keychainGranted: { type: String },\n isChecking: { type: String },\n continueCallback: { type: Function },\n userMode: { type: String }, // 'local' or 'firebase'\n };\n\n constructor() {\n super();\n this.microphoneGranted = 'unknown';\n this.screenGranted = 'unknown';\n this.keychainGranted = 'unknown';\n this.isChecking = false;\n this.continueCallback = null;\n this.userMode = 'local'; // Default to local\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n if (changedProperties.has('userMode')) {\n const newHeight = this.userMode === 'firebase' ? 280 : 220;\n console.log(`[PermissionHeader] User mode changed to ${this.userMode}, requesting resize to ${newHeight}px`);\n this.dispatchEvent(new CustomEvent('request-resize', {\n detail: { height: newHeight },\n bubbles: true,\n composed: true\n }));\n }\n }\n\n async connectedCallback() {\n super.connectedCallback();\n\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n this.userMode = userState.mode;\n } catch (e) {\n console.error('[PermissionHeader] Failed to get user state', e);\n this.userMode = 'local'; // Fallback to local\n }\n }\n\n await this.checkPermissions();\n \n // Set up periodic permission check\n this.permissionCheckInterval = setInterval(async () => {\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n this.userMode = userState.mode;\n } catch (e) {\n this.userMode = 'local';\n }\n }\n this.checkPermissions();\n }, 1000);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.permissionCheckInterval) {\n clearInterval(this.permissionCheckInterval);\n }\n }\n\n async checkPermissions() {\n if (!window.api || this.isChecking) return;\n \n this.isChecking = true;\n \n try {\n const permissions = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Permission check result:', permissions);\n \n const prevMic = this.microphoneGranted;\n const prevScreen = this.screenGranted;\n const prevKeychain = this.keychainGranted;\n \n this.microphoneGranted = permissions.microphone;\n this.screenGranted = permissions.screen;\n this.keychainGranted = permissions.keychain;\n \n // if permissions changed == UI update\n if (prevMic !== this.microphoneGranted || prevScreen !== this.screenGranted || prevKeychain !== this.keychainGranted) {\n console.log('[PermissionHeader] Permission status changed, updating UI');\n this.requestUpdate();\n }\n\n const isKeychainRequired = this.userMode === 'firebase';\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n \n // if all permissions granted == automatically continue\n if (this.microphoneGranted === 'granted' && \n this.screenGranted === 'granted' && \n keychainOk && \n this.continueCallback) {\n console.log('[PermissionHeader] All permissions granted, proceeding automatically');\n setTimeout(() => this.handleContinue(), 500);\n }\n } catch (error) {\n console.error('[PermissionHeader] Error checking permissions:', error);\n } finally {\n this.isChecking = false;\n }\n }\n\n async handleMicrophoneClick() {\n if (!window.api || this.microphoneGranted === 'granted') return;\n \n console.log('[PermissionHeader] Requesting microphone permission...');\n \n try {\n const result = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Microphone permission result:', result);\n \n if (result.microphone === 'granted') {\n this.microphoneGranted = 'granted';\n this.requestUpdate();\n return;\n }\n \n if (result.microphone === 'not-determined' || result.microphone === 'denied' || result.microphone === 'unknown' || result.microphone === 'restricted') {\n const res = await window.api.permissionHeader.requestMicrophonePermission();\n if (res.status === 'granted' || res.success === true) {\n this.microphoneGranted = 'granted';\n this.requestUpdate();\n return;\n }\n }\n \n \n // Check permissions again after a delay\n // setTimeout(() => this.checkPermissions(), 1000);\n } catch (error) {\n console.error('[PermissionHeader] Error requesting microphone permission:', error);\n }\n }\n\n async handleScreenClick() {\n if (!window.api || this.screenGranted === 'granted') return;\n \n console.log('[PermissionHeader] Checking screen recording permission...');\n \n try {\n const permissions = await window.api.permissionHeader.checkSystemPermissions();\n console.log('[PermissionHeader] Screen permission check result:', permissions);\n \n if (permissions.screen === 'granted') {\n this.screenGranted = 'granted';\n this.requestUpdate();\n return;\n }\n if (permissions.screen === 'not-determined' || permissions.screen === 'denied' || permissions.screen === 'unknown' || permissions.screen === 'restricted') {\n console.log('[PermissionHeader] Opening screen recording preferences...');\n await window.api.permissionHeader.openSystemPreferences('screen-recording');\n }\n \n // Check permissions again after a delay\n // (This may not execute if app restarts after permission grant)\n // setTimeout(() => this.checkPermissions(), 2000);\n } catch (error) {\n console.error('[PermissionHeader] Error opening screen recording preferences:', error);\n }\n }\n\n async handleKeychainClick() {\n if (!window.api || this.keychainGranted === 'granted') return;\n \n console.log('[PermissionHeader] Requesting keychain permission...');\n \n try {\n // Trigger initializeKey to prompt for keychain access\n // Assuming encryptionService is accessible or via API\n await window.api.permissionHeader.initializeEncryptionKey(); // New IPC handler needed\n \n // After success, update status\n this.keychainGranted = 'granted';\n this.requestUpdate();\n } catch (error) {\n console.error('[PermissionHeader] Error requesting keychain permission:', error);\n }\n }\n\n async handleContinue() {\n const isKeychainRequired = this.userMode === 'firebase';\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n\n if (this.continueCallback && \n this.microphoneGranted === 'granted' && \n this.screenGranted === 'granted' && \n keychainOk) {\n // Mark permissions as completed\n if (window.api && isKeychainRequired) {\n try {\n await window.api.permissionHeader.markKeychainCompleted();\n console.log('[PermissionHeader] Marked keychain as completed');\n } catch (error) {\n console.error('[PermissionHeader] Error marking keychain as completed:', error);\n }\n }\n \n this.continueCallback();\n }\n }\n\n handleClose() {\n console.log('Close button clicked');\n if (window.api) {\n window.api.common.quitApplication();\n }\n }\n\n render() {\n const isKeychainRequired = this.userMode === 'firebase';\n const containerHeight = isKeychainRequired ? 280 : 220;\n const keychainOk = !isKeychainRequired || this.keychainGranted === 'granted';\n const allGranted = this.microphoneGranted === 'granted' && this.screenGranted === 'granted' && keychainOk;\n\n return html`\n
\n \n

Permission Setup Required

\n\n
\n ${!allGranted ? html`\n
Grant access to microphone, screen recording${isKeychainRequired ? ' and keychain' : ''} to continue
\n \n
\n
\n ${this.microphoneGranted === 'granted' ? html`\n \n \n \n Microphone ✓\n ` : html`\n \n \n \n Microphone\n `}\n
\n \n
\n ${this.screenGranted === 'granted' ? html`\n \n \n \n Screen ✓\n ` : html`\n \n \n \n Screen Recording\n `}\n
\n\n ${isKeychainRequired ? html`\n
\n ${this.keychainGranted === 'granted' ? html`\n \n \n \n Data Encryption ✓\n ` : html`\n \n \n \n Data Encryption\n `}\n
\n ` : ''}\n
\n\n \n\n \n\n ${isKeychainRequired ? html`\n \n
\n Stores the key to encrypt your data. Press \"Always Allow\" to continue.\n
\n ` : ''}\n ` : html`\n \n `}\n
\n
\n `;\n }\n}\n\ncustomElements.define('permission-setup', PermissionHeader); "], ["/glass/src/features/common/repositories/session/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\n\nlet authService = null;\n\nfunction setAuthService(service) {\n authService = service;\n}\n\nfunction getBaseRepository() {\n if (!authService) {\n // Fallback or error if authService is not set, to prevent crashes.\n // During initial load, it might not be set, so we default to sqlite.\n return sqliteRepository;\n }\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\n// The adapter layer that injects the UID\nconst sessionRepositoryAdapter = {\n setAuthService, // Expose the setter\n\n getById: (id) => getBaseRepository().getById(id),\n \n create: (type = 'ask') => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().create(uid, type);\n },\n \n getAllByUserId: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getAllByUserId(uid);\n },\n\n updateTitle: (id, title) => getBaseRepository().updateTitle(id, title),\n \n deleteWithRelatedData: (id) => getBaseRepository().deleteWithRelatedData(id),\n\n end: (id) => getBaseRepository().end(id),\n\n updateType: (id, type) => getBaseRepository().updateType(id, type),\n\n touch: (id) => getBaseRepository().touch(id),\n\n getOrCreateActive: (requestedType = 'ask') => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getOrCreateActive(uid, requestedType);\n },\n\n endAllActiveSessions: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().endAllActiveSessions(uid);\n },\n};\n\nmodule.exports = sessionRepositoryAdapter; "], ["/glass/src/window/smoothMovementManager.js", "const { screen } = require('electron');\n\nclass SmoothMovementManager {\n constructor(windowPool) {\n this.windowPool = windowPool;\n this.stepSize = 80;\n this.animationDuration = 300;\n this.headerPosition = { x: 0, y: 0 };\n this.isAnimating = false;\n this.hiddenPosition = null;\n this.lastVisiblePosition = null;\n this.currentDisplayId = null;\n this.animationFrameId = null;\n\n this.animationTimers = new Map();\n }\n\n /**\n * @param {BrowserWindow} win\n * @returns {boolean}\n */\n _isWindowValid(win) {\n if (!win || win.isDestroyed()) {\n // 해당 창의 타이머가 있으면 정리\n if (this.animationTimers.has(win)) {\n clearTimeout(this.animationTimers.get(win));\n this.animationTimers.delete(win);\n }\n return false;\n }\n return true;\n }\n\n /**\n * \n * @param {BrowserWindow} win\n * @param {number} targetX\n * @param {number} targetY\n * @param {object} [options]\n * @param {object} [options.sizeOverride]\n * @param {function} [options.onComplete]\n * @param {number} [options.duration]\n */\n animateWindow(win, targetX, targetY, options = {}) {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n\n const { sizeOverride, onComplete, duration: animDuration } = options;\n const start = win.getBounds();\n const startTime = Date.now();\n const duration = animDuration || this.animationDuration;\n const { width, height } = sizeOverride || start;\n\n const step = () => {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete();\n return;\n }\n\n const p = Math.min((Date.now() - startTime) / duration, 1);\n const eased = 1 - Math.pow(1 - p, 3); // ease-out-cubic\n const x = start.x + (targetX - start.x) * eased;\n const y = start.y + (targetY - start.y) * eased;\n\n win.setBounds({ x: Math.round(x), y: Math.round(y), width, height });\n\n if (p < 1) {\n setTimeout(step, 8);\n } else {\n this.layoutManager.updateLayout();\n if (onComplete) {\n onComplete();\n }\n }\n };\n step();\n }\n\n fade(win, { from, to, duration = 250, onComplete }) {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete();\n return;\n }\n const startOpacity = from ?? win.getOpacity();\n const startTime = Date.now();\n \n const step = () => {\n if (!this._isWindowValid(win)) {\n if (onComplete) onComplete(); return;\n }\n const progress = Math.min(1, (Date.now() - startTime) / duration);\n const eased = 1 - Math.pow(1 - progress, 3);\n win.setOpacity(startOpacity + (to - startOpacity) * eased);\n \n if (progress < 1) {\n setTimeout(step, 8);\n } else {\n win.setOpacity(to);\n if (onComplete) onComplete();\n }\n };\n step();\n }\n \n animateWindowBounds(win, targetBounds, options = {}) {\n if (this.animationTimers.has(win)) {\n clearTimeout(this.animationTimers.get(win));\n }\n\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n\n this.isAnimating = true;\n\n const startBounds = win.getBounds();\n const startTime = Date.now();\n const duration = options.duration || this.animationDuration;\n \n const step = () => {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n \n const progress = Math.min(1, (Date.now() - startTime) / duration);\n const eased = 1 - Math.pow(1 - progress, 3);\n \n const newBounds = {\n x: Math.round(startBounds.x + (targetBounds.x - startBounds.x) * eased),\n y: Math.round(startBounds.y + (targetBounds.y - startBounds.y) * eased),\n width: Math.round(startBounds.width + ((targetBounds.width ?? startBounds.width) - startBounds.width) * eased),\n height: Math.round(startBounds.height + ((targetBounds.height ?? startBounds.height) - startBounds.height) * eased),\n };\n win.setBounds(newBounds);\n \n if (progress < 1) {\n const timerId = setTimeout(step, 8);\n this.animationTimers.set(win, timerId);\n } else {\n win.setBounds(targetBounds);\n this.animationTimers.delete(win);\n \n if (this.animationTimers.size === 0) {\n this.isAnimating = false;\n }\n \n if (options.onComplete) options.onComplete();\n }\n };\n step();\n }\n \n animateWindowPosition(win, targetPosition, options = {}) {\n if (!this._isWindowValid(win)) {\n if (options.onComplete) options.onComplete();\n return;\n }\n const currentBounds = win.getBounds();\n const targetBounds = { ...currentBounds, ...targetPosition };\n this.animateWindowBounds(win, targetBounds, options);\n }\n \n animateLayout(layout, animated = true) {\n if (!layout) return;\n for (const winName in layout) {\n const win = this.windowPool.get(winName);\n const targetBounds = layout[winName];\n if (win && !win.isDestroyed() && targetBounds) {\n if (animated) {\n this.animateWindowBounds(win, targetBounds);\n } else {\n win.setBounds(targetBounds);\n }\n }\n }\n }\n\n destroy() {\n if (this.animationFrameId) {\n clearTimeout(this.animationFrameId);\n this.animationFrameId = null;\n }\n this.isAnimating = false;\n console.log('[Movement] Manager destroyed');\n }\n}\n\nmodule.exports = SmoothMovementManager;\n"], ["/glass/src/window/windowLayoutManager.js", "const { screen } = require('electron');\n\n/**\n * \n * @param {BrowserWindow} window \n * @returns {Display}\n */\nfunction getCurrentDisplay(window) {\n if (!window || window.isDestroyed()) return screen.getPrimaryDisplay();\n\n const windowBounds = window.getBounds();\n const windowCenter = {\n x: windowBounds.x + windowBounds.width / 2,\n y: windowBounds.y + windowBounds.height / 2,\n };\n\n return screen.getDisplayNearestPoint(windowCenter);\n}\n\nclass WindowLayoutManager {\n /**\n * @param {Map} windowPool - 관리할 창들의 맵\n */\n constructor(windowPool) {\n this.windowPool = windowPool;\n this.isUpdating = false;\n this.PADDING = 80;\n }\n\n getHeaderPosition = () => {\n const header = this.windowPool.get('header');\n if (header) {\n const [x, y] = header.getPosition();\n return { x, y };\n }\n return { x: 0, y: 0 };\n };\n\n\n /**\n * \n * @returns {{name: string, primary: string, secondary: string}}\n */\n determineLayoutStrategy(headerBounds, screenWidth, screenHeight, relativeX, relativeY, workAreaX, workAreaY) {\n const headerRelX = headerBounds.x - workAreaX;\n const headerRelY = headerBounds.y - workAreaY;\n\n const spaceBelow = screenHeight - (headerRelY + headerBounds.height);\n const spaceAbove = headerRelY;\n const spaceLeft = headerRelX;\n const spaceRight = screenWidth - (headerRelX + headerBounds.width);\n\n if (spaceBelow >= 400) {\n return { name: 'below', primary: 'below', secondary: relativeX < 0.5 ? 'right' : 'left' };\n } else if (spaceAbove >= 400) {\n return { name: 'above', primary: 'above', secondary: relativeX < 0.5 ? 'right' : 'left' };\n } else if (relativeX < 0.3 && spaceRight >= 800) {\n return { name: 'right-side', primary: 'right', secondary: spaceBelow > spaceAbove ? 'below' : 'above' };\n } else if (relativeX > 0.7 && spaceLeft >= 800) {\n return { name: 'left-side', primary: 'left', secondary: spaceBelow > spaceAbove ? 'below' : 'above' };\n } else {\n return { name: 'adaptive', primary: spaceBelow > spaceAbove ? 'below' : 'above', secondary: spaceRight > spaceLeft ? 'right' : 'left' };\n }\n }\n\n\n\n /**\n * @returns {{x: number, y: number} | null}\n */\n calculateSettingsWindowPosition() {\n const header = this.windowPool.get('header');\n const settings = this.windowPool.get('settings');\n\n if (!header || header.isDestroyed() || !settings || settings.isDestroyed()) {\n return null;\n }\n\n const headerBounds = header.getBounds();\n const settingsBounds = settings.getBounds();\n const display = getCurrentDisplay(header);\n const { x: workAreaX, y: workAreaY, width: screenWidth, height: screenHeight } = display.workArea;\n\n const PAD = 5;\n const buttonPadding = 170;\n\n const x = headerBounds.x + headerBounds.width - settingsBounds.width + buttonPadding;\n const y = headerBounds.y + headerBounds.height + PAD;\n\n const clampedX = Math.max(workAreaX + 10, Math.min(workAreaX + screenWidth - settingsBounds.width - 10, x));\n const clampedY = Math.max(workAreaY + 10, Math.min(workAreaY + screenHeight - settingsBounds.height - 10, y));\n\n return { x: Math.round(clampedX), y: Math.round(clampedY) };\n }\n\n\n calculateHeaderResize(header, { width, height }) {\n if (!header) return null;\n const currentBounds = header.getBounds();\n const centerX = currentBounds.x + currentBounds.width / 2;\n const newX = Math.round(centerX - width / 2);\n const display = getCurrentDisplay(header);\n const { x: workAreaX, width: workAreaWidth } = display.workArea;\n const clampedX = Math.max(workAreaX, Math.min(workAreaX + workAreaWidth - width, newX));\n return { x: clampedX, y: currentBounds.y, width, height };\n }\n \n calculateClampedPosition(header, { x: newX, y: newY }) {\n if (!header) return null;\n const targetDisplay = screen.getDisplayNearestPoint({ x: newX, y: newY });\n const { x: workAreaX, y: workAreaY, width, height } = targetDisplay.workArea;\n const headerBounds = header.getBounds();\n const clampedX = Math.max(workAreaX, Math.min(newX, workAreaX + width - headerBounds.width));\n const clampedY = Math.max(workAreaY, Math.min(newY, workAreaY + height - headerBounds.height));\n return { x: clampedX, y: clampedY };\n }\n \n calculateWindowHeightAdjustment(senderWindow, targetHeight) {\n if (!senderWindow) return null;\n const currentBounds = senderWindow.getBounds();\n const minHeight = senderWindow.getMinimumSize()[1];\n const maxHeight = senderWindow.getMaximumSize()[1];\n let adjustedHeight = Math.max(minHeight, targetHeight);\n if (maxHeight > 0) {\n adjustedHeight = Math.min(maxHeight, adjustedHeight);\n }\n console.log(`[Layout Debug] calculateWindowHeightAdjustment: targetHeight=${targetHeight}`);\n return { ...currentBounds, height: adjustedHeight };\n }\n \n // 기존 getTargetBoundsForFeatureWindows를 이 함수로 대체합니다.\n calculateFeatureWindowLayout(visibility, headerBoundsOverride = null) {\n const header = this.windowPool.get('header');\n const headerBounds = headerBoundsOverride || (header ? header.getBounds() : null);\n\n if (!headerBounds) return {};\n\n let display;\n if (headerBoundsOverride) {\n const boundsCenter = {\n x: headerBounds.x + headerBounds.width / 2,\n y: headerBounds.y + headerBounds.height / 2,\n };\n display = screen.getDisplayNearestPoint(boundsCenter);\n } else {\n display = getCurrentDisplay(header);\n }\n \n const { width: screenWidth, height: screenHeight, x: workAreaX, y: workAreaY } = display.workArea;\n \n const ask = this.windowPool.get('ask');\n const listen = this.windowPool.get('listen');\n \n const askVis = visibility.ask && ask && !ask.isDestroyed();\n const listenVis = visibility.listen && listen && !listen.isDestroyed();\n \n if (!askVis && !listenVis) return {};\n \n const PAD = 8;\n const headerTopRel = headerBounds.y - workAreaY;\n const headerBottomRel = headerTopRel + headerBounds.height;\n const headerCenterXRel = headerBounds.x - workAreaX + headerBounds.width / 2;\n \n const relativeX = headerCenterXRel / screenWidth;\n const relativeY = (headerBounds.y - workAreaY) / screenHeight;\n const strategy = this.determineLayoutStrategy(headerBounds, screenWidth, screenHeight, relativeX, relativeY, workAreaX, workAreaY);\n \n const askB = askVis ? ask.getBounds() : null;\n const listenB = listenVis ? listen.getBounds() : null;\n\n if (askVis) {\n console.log(`[Layout Debug] Ask Window Bounds: height=${askB.height}, width=${askB.width}`);\n }\n if (listenVis) {\n console.log(`[Layout Debug] Listen Window Bounds: height=${listenB.height}, width=${listenB.width}`);\n }\n \n const layout = {};\n \n if (askVis && listenVis) {\n let askXRel = headerCenterXRel - (askB.width / 2);\n let listenXRel = askXRel - listenB.width - PAD;\n \n if (listenXRel < PAD) {\n listenXRel = PAD;\n askXRel = listenXRel + listenB.width + PAD;\n }\n if (askXRel + askB.width > screenWidth - PAD) {\n askXRel = screenWidth - PAD - askB.width;\n listenXRel = askXRel - listenB.width - PAD;\n }\n \n if (strategy.primary === 'above') {\n const windowBottomAbs = headerBounds.y - PAD;\n layout.ask = { x: Math.round(askXRel + workAreaX), y: Math.round(windowBottomAbs - askB.height), width: askB.width, height: askB.height };\n layout.listen = { x: Math.round(listenXRel + workAreaX), y: Math.round(windowBottomAbs - listenB.height), width: listenB.width, height: listenB.height };\n } else { // 'below'\n const yAbs = headerBounds.y + headerBounds.height + PAD;\n layout.ask = { x: Math.round(askXRel + workAreaX), y: Math.round(yAbs), width: askB.width, height: askB.height };\n layout.listen = { x: Math.round(listenXRel + workAreaX), y: Math.round(yAbs), width: listenB.width, height: listenB.height };\n }\n } else { // Single window\n const winName = askVis ? 'ask' : 'listen';\n const winB = askVis ? askB : listenB;\n if (!winB) return {};\n \n let xRel = headerCenterXRel - winB.width / 2;\n xRel = Math.max(PAD, Math.min(screenWidth - winB.width - PAD, xRel));\n \n let yPos;\n if (strategy.primary === 'above') {\n yPos = (headerBounds.y - workAreaY) - PAD - winB.height;\n } else { // 'below'\n yPos = (headerBounds.y - workAreaY) + headerBounds.height + PAD;\n }\n \n layout[winName] = { x: Math.round(xRel + workAreaX), y: Math.round(yPos + workAreaY), width: winB.width, height: winB.height };\n }\n return layout;\n }\n \n calculateShortcutSettingsWindowPosition() {\n const header = this.windowPool.get('header');\n const shortcutSettings = this.windowPool.get('shortcut-settings');\n if (!header || !shortcutSettings) return null;\n \n const headerBounds = header.getBounds();\n const shortcutBounds = shortcutSettings.getBounds();\n const { workArea } = getCurrentDisplay(header);\n \n let newX = Math.round(headerBounds.x + (headerBounds.width / 2) - (shortcutBounds.width / 2));\n let newY = Math.round(headerBounds.y);\n \n newX = Math.max(workArea.x, Math.min(newX, workArea.x + workArea.width - shortcutBounds.width));\n newY = Math.max(workArea.y, Math.min(newY, workArea.y + workArea.height - shortcutBounds.height));\n \n return { x: newX, y: newY, width: shortcutBounds.width, height: shortcutBounds.height };\n }\n\n calculateStepMovePosition(header, direction) {\n if (!header) return null;\n const currentBounds = header.getBounds();\n const stepSize = 80; // 이동 간격\n let targetX = currentBounds.x;\n let targetY = currentBounds.y;\n \n switch (direction) {\n case 'left': targetX -= stepSize; break;\n case 'right': targetX += stepSize; break;\n case 'up': targetY -= stepSize; break;\n case 'down': targetY += stepSize; break;\n }\n \n return this.calculateClampedPosition(header, { x: targetX, y: targetY });\n }\n \n calculateEdgePosition(header, direction) {\n if (!header) return null;\n const display = getCurrentDisplay(header);\n const { workArea } = display;\n const currentBounds = header.getBounds();\n \n let targetX = currentBounds.x;\n let targetY = currentBounds.y;\n \n switch (direction) {\n case 'left': targetX = workArea.x; break;\n case 'right': targetX = workArea.x + workArea.width - currentBounds.width; break;\n case 'up': targetY = workArea.y; break;\n case 'down': targetY = workArea.y + workArea.height - currentBounds.height; break;\n }\n return { x: targetX, y: targetY };\n }\n \n calculateNewPositionForDisplay(window, targetDisplayId) {\n if (!window) return null;\n \n const targetDisplay = screen.getAllDisplays().find(d => d.id === targetDisplayId);\n if (!targetDisplay) return null;\n \n const currentBounds = window.getBounds();\n const currentDisplay = getCurrentDisplay(window);\n \n if (currentDisplay.id === targetDisplay.id) return { x: currentBounds.x, y: currentBounds.y };\n \n const relativeX = (currentBounds.x - currentDisplay.workArea.x) / currentDisplay.workArea.width;\n const relativeY = (currentBounds.y - currentDisplay.workArea.y) / currentDisplay.workArea.height;\n \n const targetX = targetDisplay.workArea.x + targetDisplay.workArea.width * relativeX;\n const targetY = targetDisplay.workArea.y + targetDisplay.workArea.height * relativeY;\n \n const clampedX = Math.max(targetDisplay.workArea.x, Math.min(targetX, targetDisplay.workArea.x + targetDisplay.workArea.width - currentBounds.width));\n const clampedY = Math.max(targetDisplay.workArea.y, Math.min(targetY, targetDisplay.workArea.y + targetDisplay.workArea.height - currentBounds.height));\n \n return { x: Math.round(clampedX), y: Math.round(clampedY) };\n }\n \n /**\n * @param {Rectangle} bounds1\n * @param {Rectangle} bounds2\n * @returns {boolean}\n */\n boundsOverlap(bounds1, bounds2) {\n const margin = 10;\n return !(\n bounds1.x + bounds1.width + margin < bounds2.x ||\n bounds2.x + bounds2.width + margin < bounds1.x ||\n bounds1.y + bounds1.height + margin < bounds2.y ||\n bounds2.y + bounds2.height + margin < bounds1.y\n );\n }\n}\n\nmodule.exports = WindowLayoutManager;"], ["/glass/src/ui/app/HeaderController.js", "import './MainHeader.js';\nimport './ApiKeyHeader.js';\nimport './PermissionHeader.js';\nimport './WelcomeHeader.js';\n\nclass HeaderTransitionManager {\n constructor() {\n this.headerContainer = document.getElementById('header-container');\n this.currentHeaderType = null; // 'welcome' | 'apikey' | 'main' | 'permission'\n this.welcomeHeader = null;\n this.apiKeyHeader = null;\n this.mainHeader = null;\n this.permissionHeader = null;\n\n /**\n * only one header window is allowed\n * @param {'welcome'|'apikey'|'main'|'permission'} type\n */\n this.ensureHeader = (type) => {\n console.log('[HeaderController] ensureHeader: Ensuring header of type:', type);\n if (this.currentHeaderType === type) {\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'already exists.');\n return;\n }\n\n this.headerContainer.innerHTML = '';\n \n this.welcomeHeader = null;\n this.apiKeyHeader = null;\n this.mainHeader = null;\n this.permissionHeader = null;\n\n // Create new header element\n if (type === 'welcome') {\n this.welcomeHeader = document.createElement('welcome-header');\n this.welcomeHeader.loginCallback = () => this.handleLoginOption();\n this.welcomeHeader.apiKeyCallback = () => this.handleApiKeyOption();\n this.headerContainer.appendChild(this.welcomeHeader);\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'created.');\n } else if (type === 'apikey') {\n this.apiKeyHeader = document.createElement('apikey-header');\n this.apiKeyHeader.stateUpdateCallback = (userState) => this.handleStateUpdate(userState);\n this.apiKeyHeader.backCallback = () => this.transitionToWelcomeHeader();\n this.apiKeyHeader.addEventListener('request-resize', e => {\n this._resizeForApiKey(e.detail.height); \n });\n this.headerContainer.appendChild(this.apiKeyHeader);\n console.log('[HeaderController] ensureHeader: Header of type:', type, 'created.');\n } else if (type === 'permission') {\n this.permissionHeader = document.createElement('permission-setup');\n this.permissionHeader.addEventListener('request-resize', e => {\n this._resizeForPermissionHeader(e.detail.height); \n });\n this.permissionHeader.continueCallback = async () => {\n if (window.api && window.api.headerController) {\n console.log('[HeaderController] Re-initializing model state after permission grant...');\n await window.api.headerController.reInitializeModelState();\n }\n this.transitionToMainHeader();\n };\n this.headerContainer.appendChild(this.permissionHeader);\n } else {\n this.mainHeader = document.createElement('main-header');\n this.headerContainer.appendChild(this.mainHeader);\n this.mainHeader.startSlideInAnimation?.();\n }\n\n this.currentHeaderType = type;\n this.notifyHeaderState(type === 'permission' ? 'apikey' : type); // Keep permission state as apikey for compatibility\n };\n\n console.log('[HeaderController] Manager initialized');\n\n // WelcomeHeader 콜백 메서드들\n this.handleLoginOption = this.handleLoginOption.bind(this);\n this.handleApiKeyOption = this.handleApiKeyOption.bind(this);\n\n this._bootstrap();\n\n if (window.api) {\n window.api.headerController.onUserStateChanged((event, userState) => {\n console.log('[HeaderController] Received user state change:', userState);\n this.handleStateUpdate(userState);\n });\n\n window.api.headerController.onAuthFailed((event, { message }) => {\n console.error('[HeaderController] Received auth failure from main process:', message);\n if (this.apiKeyHeader) {\n this.apiKeyHeader.errorMessage = 'Authentication failed. Please try again.';\n this.apiKeyHeader.isLoading = false;\n }\n });\n window.api.headerController.onForceShowApiKeyHeader(async () => {\n console.log('[HeaderController] Received broadcast to show apikey header. Switching now.');\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n if (!isConfigured) {\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n } else {\n await this._resizeForApiKey();\n this.ensureHeader('apikey');\n }\n }); \n }\n }\n\n notifyHeaderState(stateOverride) {\n const state = stateOverride || this.currentHeaderType || 'apikey';\n if (window.api) {\n window.api.headerController.sendHeaderStateChanged(state);\n }\n }\n\n async _bootstrap() {\n // The initial state will be sent by the main process via 'user-state-changed'\n // We just need to request it.\n if (window.api) {\n const userState = await window.api.common.getCurrentUser();\n console.log('[HeaderController] Bootstrapping with initial user state:', userState);\n this.handleStateUpdate(userState);\n } else {\n // Fallback for non-electron environment (testing/web)\n this.ensureHeader('welcome');\n }\n }\n\n\n //////// after_modelStateService ////////\n async handleStateUpdate(userState) {\n const isConfigured = await window.api.apiKeyHeader.areProvidersConfigured();\n\n if (isConfigured) {\n // If providers are configured, always check permissions regardless of login state.\n const permissionResult = await this.checkPermissions();\n if (permissionResult.success) {\n this.transitionToMainHeader();\n } else {\n this.transitionToPermissionHeader();\n }\n } else {\n // If no providers are configured, show the welcome header to prompt for setup.\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n }\n }\n\n // WelcomeHeader 콜백 메서드들\n async handleLoginOption() {\n console.log('[HeaderController] Login option selected');\n if (window.api) {\n await window.api.common.startFirebaseAuth();\n }\n }\n\n async handleApiKeyOption() {\n console.log('[HeaderController] API key option selected');\n await this._resizeForApiKey(400);\n this.ensureHeader('apikey');\n // ApiKeyHeader에 뒤로가기 콜백 설정\n if (this.apiKeyHeader) {\n this.apiKeyHeader.backCallback = () => this.transitionToWelcomeHeader();\n }\n }\n\n async transitionToWelcomeHeader() {\n if (this.currentHeaderType === 'welcome') {\n return this._resizeForWelcome();\n }\n\n await this._resizeForWelcome();\n this.ensureHeader('welcome');\n }\n //////// after_modelStateService ////////\n\n async transitionToPermissionHeader() {\n // Prevent duplicate transitions\n if (this.currentHeaderType === 'permission') {\n console.log('[HeaderController] Already showing permission setup, skipping transition');\n return;\n }\n\n // Check if permissions were previously completed\n if (window.api) {\n try {\n const permissionsCompleted = await window.api.headerController.checkPermissionsCompleted();\n if (permissionsCompleted) {\n console.log('[HeaderController] Permissions were previously completed, checking current status...');\n \n // Double check current permission status\n const permissionResult = await this.checkPermissions();\n if (permissionResult.success) {\n // Skip permission setup if already granted\n this.transitionToMainHeader();\n return;\n }\n \n console.log('[HeaderController] Permissions were revoked, showing setup again');\n }\n } catch (error) {\n console.error('[HeaderController] Error checking permissions completed status:', error);\n }\n }\n\n let initialHeight = 220;\n if (window.api) {\n try {\n const userState = await window.api.common.getCurrentUser();\n if (userState.mode === 'firebase') {\n initialHeight = 280;\n }\n } catch (e) {\n console.error('Could not get user state for resize', e);\n }\n }\n\n await this._resizeForPermissionHeader(initialHeight);\n this.ensureHeader('permission');\n }\n\n async transitionToMainHeader(animate = true) {\n if (this.currentHeaderType === 'main') {\n return this._resizeForMain();\n }\n\n await this._resizeForMain();\n this.ensureHeader('main');\n }\n\n async _resizeForMain() {\n if (!window.api) return;\n console.log('[HeaderController] _resizeForMain: Resizing window to 353x47');\n return window.api.headerController.resizeHeaderWindow({ width: 353, height: 47 }).catch(() => {});\n }\n\n async _resizeForApiKey(height = 370) {\n if (!window.api) return;\n console.log(`[HeaderController] _resizeForApiKey: Resizing window to 456x${height}`);\n return window.api.headerController.resizeHeaderWindow({ width: 456, height: height }).catch(() => {});\n }\n\n async _resizeForPermissionHeader(height) {\n if (!window.api) return;\n const finalHeight = height || 220;\n return window.api.headerController.resizeHeaderWindow({ width: 285, height: finalHeight })\n .catch(() => {});\n }\n\n async _resizeForWelcome() {\n if (!window.api) return;\n console.log('[HeaderController] _resizeForWelcome: Resizing window to 456x370');\n return window.api.headerController.resizeHeaderWindow({ width: 456, height: 364 })\n .catch(() => {});\n }\n\n async checkPermissions() {\n if (!window.api) {\n return { success: true };\n }\n \n try {\n const permissions = await window.api.headerController.checkSystemPermissions();\n console.log('[HeaderController] Current permissions:', permissions);\n \n if (!permissions.needsSetup) {\n return { success: true };\n }\n\n let errorMessage = '';\n if (!permissions.microphone && !permissions.screen) {\n errorMessage = 'Microphone and screen recording access required';\n }\n \n return { \n success: false, \n error: errorMessage\n };\n } catch (error) {\n console.error('[HeaderController] Error checking permissions:', error);\n return { \n success: false, \n error: 'Failed to check permissions' \n };\n }\n }\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n new HeaderTransitionManager();\n});\n"], ["/glass/src/ui/listen/audioCore/aec.js", "var createAecModule = (() => {\n var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;\n return (\nasync function(moduleArg = {}) {\n var moduleRtn;\n\nvar Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window==\"object\";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!=\"undefined\";var ENVIRONMENT_IS_NODE=typeof process==\"object\"&&process.versions?.node&&process.type!=\"renderer\";var arguments_=[];var thisProgram=\"./this.program\";var quit_=(status,toThrow)=>{throw toThrow};if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory=\"\";var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(\".\",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open(\"GET\",url,false);xhr.responseType=\"arraybuffer\";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:\"same-origin\"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+\" : \"+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var readyPromiseResolve,readyPromiseReject;var wasmMemory;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);Module[\"HEAP16\"]=HEAP16=new Int16Array(b);Module[\"HEAPU8\"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module[\"preRun\"]){if(typeof Module[\"preRun\"]==\"function\")Module[\"preRun\"]=[Module[\"preRun\"]];while(Module[\"preRun\"].length){addOnPreRun(Module[\"preRun\"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(!Module[\"noFSInit\"]&&!FS.initialized)FS.init();TTY.init();wasmExports[\"v\"]();FS.ignorePermissions=false}function postRun(){if(Module[\"postRun\"]){if(typeof Module[\"postRun\"]==\"function\")Module[\"postRun\"]=[Module[\"postRun\"]];while(Module[\"postRun\"].length){addOnPostRun(Module[\"postRun\"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module[\"monitorRunDependencies\"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module[\"monitorRunDependencies\"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module[\"onAbort\"]?.(what);what=\"Aborted(\"+what+\")\";err(what);ABORT=true;what+=\". Build with -sASSERTIONS for more info.\";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return base64Decode(\"AGFzbQEAAAABhgETYAJ/fwF/YAN/f38Bf2ACf38AYAN/f38AYAF/AGAEf39/fwBgAX8Bf2AFf39/f38AYAAAYAZ/f39/f38AYAR/f39/AX9gBX9/f39/AX9gAAF/YAZ/f39/f38Bf2AHf39/f39/fwBgBH9+f38Bf2AHf39/f39/fwF/YAJ+fwF/YAN/fn8BfgJ5FAFhAWEADAFhAWIABAFhAWMAAgFhAWQAAwFhAWUABQFhAWYACgFhAWcACgFhAWgACQFhAWkAAAFhAWoABwFhAWsABAFhAWwADwFhAW0ADQFhAW4AAAFhAW8AAAFhAXAAAAFhAXEAAwFhAXIACAFhAXMABgFhAXQABgPKAcgBBAYCDQYHAQEACAMECAsDBwMGCAYDAwEBBAcEAwMDAgICBQAACwEAAQMDBAoEBAQABAIDARABBgAOAwADAAMHAAMCAwMGBAQEBgQAAw4HAgUDBgcLBAMAAgYFBAYECBEGAgQBBAAAAAUDBggIAwIAAwAFAAAAAAcABAIMBAcGCgQCAgUFAAACAgIAAgIDAgAFBQEBAwUFBQUFAAAEBAAAAQAAAgYEBxIEAAAAAAAAAQAAAAAAAAAAAAYCAgYCAQkJBwcFBQEBBAgEBQFwAX9/BQcBAYICgIACBggBfwFB4PkECwdDDgF1AgABdgDbAQF3AJIBAXgAkAEBeQCPAQF6ABgBQQAUAUIAjQEBQwCMAQFEANoBAUUAkQEBRgCOAQFHANEBAUgBAAnUAQEAQQELfswBwgG6AUtOaIkBUIsBhgGEATmIAYcBhQEkNIMBVYIBfn1EcHDZAdIB1AHXAUTTAdUB1gHPAdABTndvsAFpgAGvARsWrQFSuQFAGUCVAZQBtwE+igEukwF1bSFKNrIBogFmQB6gAaMBH8YB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A0EPTQRAIAIgAyAGaiIAQQNyNgIEIAAgAmoiACAAKAIEQQFyNgIEDAELIAIgBkEDcjYCBCACIAZqIgUgA0EBcjYCBCADIAVqIAM2AgAgCARAIAhBeHFB7PMAaiEAQdjzACgCACEBAn9BASAIQQN2dCIHIARxRQRAQcTzACAEIAdyNgIAIAAMAQsgACgCCAshBCAAIAE2AgggBCABNgIMIAEgADYCDCABIAQ2AggLQdjzACAFNgIAQczzACADNgIACyACQQhqIQALIApBEGokACAAC/gBAgR/AX4jAEEgayIFJAACQAJAIAEgASACaiICSwRAQQAhAQwBC0EAIQEgAyAEakEBa0EAIANrca0gAiAAKAIAIgdBAXQiBiACIAZLGyICQQhBBCAEQQFGGyIGIAIgBksbIgatfiIJQiCIQgBSDQAgCaciCEGAgICAeCADa0sNAEEAIQIgBSAHBH8gBSAEIAdsNgIcIAUgACgCBDYCFCADBUEACzYCGCAFQQhqIAMgCCAFQRRqEDUgBSgCCEEBRw0BIAUoAhAhAiAFKAIMIQELIAEgAkG85wAQJAALIAUoAgwhASAAIAY2AgAgACABNgIEIAVBIGokAAt0AQF/IAJFBEAgACgCBCABKAIERg8LIAAgAUYEQEEBDwsgASgCBCICLQAAIQECQCAAKAIEIgMtAAAiAEUNACAAIAFHDQADQCACLQABIQEgAy0AASIARQ0BIAJBAWohAiADQQFqIQMgACABRg0ACwsgACABRgucBAEIfyMAQRBrIgMkACADIAE2AgQgAyAANgIAIANCoICAgA43AggCfwJAAkACQCACKAIQIgkEQCACKAIUIgANAQwCCyACKAIMIgBFDQEgAigCCCIBIABBA3RqIQQgAEEBa0H/////AXFBAWohBiACKAIAIQADQAJAIAAoAgQiBUUNACADKAIAIAAoAgAgBSADKAIEKAIMEQEARQ0AQQEMBQtBASABKAIAIAMgASgCBBEAAA0EGiAAQQhqIQAgBCABQQhqIgFHDQALDAILIABBGGwhCiAAQQFrQf////8BcUEBaiEGIAIoAgghBCACKAIAIQADQAJAIAAoAgQiAUUNACADKAIAIAAoAgAgASADK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AZBAXYhCSADKAIIIQxBASEDA0AgAiADQQJ0IgRqIgpBAmsgByAGIANrQQJ0IgtqIgguAQAiDSAEIAdqIg4uAQAiD2pBDXRBgIABaiIQIA8gDWtBAXUiDSAEIAxqIgQuAQAiD2wgCC4BAiIIIA4uAQIiDmpBD3RBgIACakEQdSIRIAQuAQIiBGxrQQF1IhJqQQ92OwEAIAogDiAIa0ENdCIKIA8gEWwgBCANbGpBAXUiBGpBgIABakEPdjsBACACIAtqIgsgBCAKa0GAgAFqQQ92OwEAIAtBAmsgECASa0EPdjsBACADIAlHIANBAWohAw0ACwsMAQtBtQEQXQALAkAgACgCCCIHQQBMDQBBASAFdEEBdSEAQQAhBkEAIQMgB0EETwRAIAFBBmohDCABQQRqIQogAUECaiELIAdB/P///wdxIQhBACEJA0AgASADQQF0IgRqIg0gACANLgEAaiAFdTsBACAEIAtqIg0gACANLgEAaiAFdTsBACAEIApqIg0gACANLgEAaiAFdTsBACAEIAxqIgQgACAELgEAaiAFdTsBACADQQRqIQMgCUEEaiIJIAhHDQALCyAHQQNxIgQEQANAIAEgA0EBdGoiCSAAIAkuAQBqIAV1OwEAIANBAWohAyAGQQFqIgYgBEcNAAsLQQAhBEEAIQMgB0EETwRAIAJBBmohCSACQQRqIQwgAkECaiEKIAdB/P///wdxIQtBACEGA0AgAiADQQF0IgFqIgggACAILgEAaiAFdTsBACABIApqIgggACAILgEAaiAFdTsBACABIAxqIgggACAILgEAaiAFdTsBACABIAlqIgEgACABLgEAaiAFdTsBACADQQRqIQMgBkEEaiIGIAtHDQALCyAHQQNxIgFFDQADQCACIANBAXRqIgYgACAGLgEAaiAFdTsBACADQQFqIQMgBEEBaiIEIAFHDQALCwvBAQEDfyAALQAAQSBxRQRAAkAgACgCECIDBH8gAwUgABBsDQEgACgCEAsgACgCFCIEayACSQRAIAAgASACIAAoAiQRAQAaDAELAkACQCAAKAJQQQBIDQAgAkUNACACIQMDQCABIANqIgVBAWstAABBCkcEQCADQQFrIgMNAQwCCws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FakEQdSAAbEGAgMjxAGpBEHUiAEENIAJrdSAAIAJBDWt0IAJBDUkbOwEAIAVBAWoiBSAIRw0ACwsCQCABQWlIDQBBASAHIAdBAUwbIgJBAXFBACEAIAFBaUcEQCACQf7///8HcSEHQQAhBQNAIAkgAEECdCICakGAATYCACACIAtqQQE2AgAgDiAAQQF0IgJqQf//ATsBACACIA1qQYACOwEAIAIgDGpBgAI7AQAgCSAAQQFyIgJBAnQiD2pBgAE2AgAgCyAPakEBNgIAIA4gAkEBdCICakH//wE7AQAgAiANakGAAjsBACACIAxqQYACOwEAIABBAmohACAFQQJqIgUgB0cNAAsLBEAgCSAAQQJ0IgJqQYABNgIAIAIgC2pBATYCACAOIABBAXQiAGpB//8BOwEAIAAgDWpBgAI7AQAgACAMakGAAjsBAAsgAUEATA0AQQAhBUEAIQIgAUEITwRAIARBHGohByAEQRhqIQkgBEEUaiELIARBEGohDCAEQQxqIQ0gBEEIaiEOIARBBGohDyABQfj///8HcSERQQAhBgNAIAQgAkECdCIAakEBNgIAIAAgD2pBATYCACAAIA5qQQE2AgAgACANakEBNgIAIAAgDGpBATYCACAAIAtqQQE2AgAgACAJakEBNgIAIAAgB2pBATYCACACQQhqIQIgBkEIaiIGIBFHDQALCyABQQdxIgBFDQADQCAEIAJBAnRqQQE2AgAgAkEBaiECIAVBAWoiBSAARw0ACwsgA0EANgKUASAIEFwhACADQQA2ApgBIANBADYCkAEgAyAANgKcASADIQIjAEEgayIAJAAgAiAKNgI0IABBIGokAEEBBUEACyEBQdn5AC0AABoCQEEMQQQQHCIARQRAQfj4AEEANgIAQRFBBEEMEANB+PgAKAIAQfj4AEEANgIAQQFHDQEQABogChBaIAEEQCACEFkLECYACyAAIAo2AgggACACNgIEIAAgATYCACAADwsAC0cBAn8jAEEwayIAJAAgAEEBNgIYIABBjPAANgIUIABCADcCICAAIABBLGoiATYCHCAAQQxqIgIgASAAQRRqEB4gAhAfEB0ACyYAIAAgAUEBckEQajYCBCAAIAFBAnFFIAFB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EH4+ABBADYCAEEBRw0AEAAaECAACyAAEAEACwJAAkACQCADLQCYBCIBQQRGBEAgAygCkAQiAUGBBE8NASAIIAAoAgggByABIAAoAgwoAhwRBQAgAy0AuAQiAEEERg0DIABBA0cNAyADKAK8BCIBKAIAIQICQCABKAIEIgAoAgAiBARAQfj4AEEANgIAIAQgAhACQfj4ACgCAEH4+ABBADYCAEEBRg0BCyAAKAIEBEAgACgCCBogAhAUCyABEBQMBAsQACEDIAAoAgRFDQIgACgCCBogAhAUDAILAkACQCABQQNGBEAgAygCnAQiASgCACEEIAEoAgQiAigCACIFBEBB+PgAQQA2AgAgBSAEEAJB+PgAKAIAQfj4AEEANgIAQQFGDQILIAIoAgQEQCACKAIIGiAEEBQLIAEQFAsgACgCDCgCJCEBIAAoAgghACADQdjsADYCoAQgA0IDNwKsBCADIAo3A8gEIAMgCTcDwAQgAyALNwO4BCADIANBuARqNgKoBCADQQQ2AqQEIANBmARqIAAgA0GgBGogAREDACADLQCYBCIAQQRGDQQgAEEDRw0EIAMoApwEIgEoAgAhAiABKAIEIgAoAgAiBARAQfj4AEEANgIAIAQgAhACQfj4ACgCAEH4+ABBADYCAEEBRg0CCyAAKAIEBEAgACgCCBogAhAUCyABEBQMBAsQACEDIAIoAgRFDQIgAigCCBogBBAUDAILEAAhAyAAKAIERQ0BIAAoAggaIAIQFAwBCyABQYAEQcjsABBXAAsgARAUIAMQAQALIANB0ARqJAALtgIBA38jAEEwayIAJABB2PkALQAARQRAIABBAjYCDCAAQbjrADYCCCAAQgE3AhQgACAAQShqrUKAgICAgAGENwMgIAAgATYCKCAAIABBIGo2AhAgACAAQS9qIABBCGoQHgJAAkAgAC0AACIBQQRGDQAgAUEDRw0AIAAoAgQiAigCACEDIAIoAgQiASgCACIEBEBB+PgAQQA2AgAgBCADEAJB+PgAKAIAQfj4AEEANgIAQQFGDQILIAEoAgQEQCABKAIIGiADEBQLIAIQFAsgAEEwaiQADwsQACABKAIEBEAgASgCCBogAxAUCyACEBQQA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NACAAEBQgAxABAAsgAxABAAtdAQF/IwBBMGsiBCQAIARBATYCDCAEQgE3AhQgBEGQygA2AgggBCADOgAvIAQgBEEvaq1CgICAgIAIhDcDICAEIARBIGo2AhAgACABIARBCGogAhEDACAEQTBqJAALzAEBAX8jAEEQayIBJAACQAJAIAMEQANAAkACQCACQf////8HIAMgA0H/////B08bEEMiBEF/RwRAIAEgBDYCDCABQQQ6AAggBEUEQEHI6QAhAwwGCyADIARPDQEgBCADQZDrABAvAAsgAUEAOgALIAFBADsACSABQQA6AAggAUHA8wAoAgAiBDYCDCAEQRtGDQEgAUEIaiEDDAQLIAIgBGohAiADIARrIQMLIAMNAAsLIABBBDoAAAwBCyAAIAMpAwA3AgALIAFBEGokAAvTAQICfgV/IAAoAggiBigCBCIHQv////8PIAYpAwgiAyADQv////8PWhunayIFQQAgBSAHTRsiBSACIAIgBUsbIggEQCAGKAIAIAetIgQgAyADIARWG6dqIAEgCPwKAAALIAYgAyAIrXw3AwgCQAJAIAIgBU0NAEHI6QApAwAiA0L/AYNCBFENACAALQAAQQRHBEBB+PgAQQA2AgBBJSAAEAJB+PgAKAIAQfj4AEEANgIAQQFGDQILIAAgAzcCAEEBIQkLIAkPCxAAIAAgAzcCABABAAtQAQF/IAAoAggiACgCACAAKAIIIgNrIAJJBEAgACADIAJBAUEBEBkgACgCCCEDCyACBEAgACgCBCADaiABIAL8CgAACyAAIAIgA2o2AghBAAuVAwECfyMAQTBrIgMkAEH4+ABBADYCACADQQQ6AAggAyABNgIQQSsgA0EIakGc6AAgAhAFIQFB+PgAKAIAIQJB+PgAQQA2AgACQAJAIAJBAUYNAAJAAkAgAQRAIAMtAAhBBEcNAUH4+ABBADYCACADQQA2AiggA0IENwIgIANBuOoANgIYIANBATYCHEEsIANBGGpBwOoAEANB+PgAKAIAQfj4AEEANgIAQQFGDQMACyAAQQQ6AAAgAy0ACCIAQQRGDQEgAEEDRw0BIAMoAgwiAigCACEEAkAgAigCBCIBKAIAIgAEQEH4+ABB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GokAAupAgEFfyADBEAgA0EDcSEHAkAgA0EESQRADAELIAJBHGohBCADQXxxIQgDQCAEKAIAIARBCGsoAgAgBEEQaygCACAEQRhrKAIAIAVqampqIQUgBEEgaiEEIAggBkEEaiIGRw0ACwsgBwRAIAZBA3QgAmpBBGohBANAIAQoAgAgBWohBSAEQQhqIQQgB0EBayIHDQALCyABKAIAIAEoAggiBGsgBUkEQCABIAQgBUEBQQEQGSABKAIIIQQLIANBA3QgAmohBQNAIAIoAgAhBiACKAIEIgMgASgCACAEa0sEQCABIAQgA0EBQQEQGSABKAIIIQQLIAMEQCABKAIEIARqIAYgA/wKAAALIAEgAyAEaiIENgIIIAJBCGoiAiAFRw0ACwsgAEEEOgAAC1ABAX8gASgCACABKAIIIgRrIANJBEAgASAEIANBAUEBEBkgASgCCCEECyADBEAgASgCBCAEaiACIAP8CgAACyAAQQQ6AAAgASADIARqNgIIC7YCAQV/AkAgA0UEQAwBCyADQQNxIQcCQCADQQRJBEAMAQsgAkEcaiEEIANBfHEhCANAIAQoAgAgBEEIaygCACAEQRBrKAIAIARBGGsoAgAgBWpqamohBSAEQSBqIQQgCCAGQQRqIgZHDQALCyAHBEAgBkEDdCACakEEaiEEA0AgBCgCACAFaiEFIARBCGohBCAHQQFrIgcNAAsLIAEoAgAgASgCCCIEayAFSQRAIAEgBCAFQQFBARAZCyADQQN0IAJqIQYgASgCCCEEA0AgAigCACEHIAIoAgQiAyABKAIAIARrSwRAIAEgBCADQQFBARAZIAEoAgghBAsgAwRAIAEoAgQgBGogByAD/AoAAAsgASADIARqIgQ2AgggAkEIaiICIAZHDQALCyAAQQQ6AAAgACAFNgIEC1cBAX8gASgCACABKAIIIgRrIANJBEAgASAEIANBAUEBEBkgASgCCCEECyADBEAgASgCBCAEaiACIAP8CgAACyAAIAM2AgQgASADIARqNgIIIABBBDoAAAvqAwEDfyMAQbABayICJAACQAJAAkACQAJAAkACQCAALQAAQQFrDgMBAgMACyACIAAoAgQiAzYCBCACQRhqIgBBA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A0EQajYCHAJAAkACQAJAAkAgAEUEQCADQgA3AigMAQtBhPkAQQE6AABB0PkAKAIAIQZB0PkAQQA2AgAgA0EANgIoIAMgBjYCLCAGDQELAkAgA0EoaiIBKAIADQAgASgCBCIARQ0AIAAgACgCACIAQQFrNgIAIABBAUcNACABQQRqEEILIANBHGogA0E/akGY7AAQaQwBCyADIAY2AjAgBkEIaiEBIAYoAghFBEBB+PgAQQA2AgBBJiABEAgaQfj4ACgCAEH4+ABBADYCAEEBRg0CC0EAIQJBpPkAKAIAQf////8HcQRAQcj5ACgCAEEARyECC0H4+ABBADYCAEEoIANBHGogBkEQakHw6wAQBEH4+AAoAgBB+PgAQQA2AgBBAUYEQBAAIQUgASACEDIMAwsgASACEDJBhPkAQQE6AABB0PkAKAIAIQBB0PkAIAY2AgAgAyAANgI4IANBATYCNCAARQ0AIAAgACgCACIAQQFrNgIAIABBAUcNACADQThqEEILIANBQGskAA8LEAAhBQsgBiAGKAIAIgBBAWs2AgAgAEEBRgRAIANBMGoQQgsgBRABAAsMACAAQczoACABEBsLDAAgAEG06AAgARAbCwwAIABBhOgAIAEQGwsMACAAQZzoACABEBsLrAMCBn8CfiMAQRBrIgIkACACQQA2AgwCfwJAIAFBgAFPBEAgAUGAEEkNASABQYCABE8EQCACIAFBP3FBgAFyOgAPIAIgAUESdkHwAXI6AAwgAiABQQZ2QT9xQYABcjoADiACIAFBDHZBP3FBgAFyOgANQQQMAwsgAiABQT9xQYABcjoADiACIAFBDHZB4AFyOgAMIAIgAUEGdkE/cUGAAXI6AA1BAwwCCyACIAE6AAxBAQwBCyACIAFBP3FBgAFyOgANIAIgAUEGdkHAAXI6AAxBAgshASAAKAIIIgQoAgQiBUL/////DyAEKQMIIgggCEL/////D1obp2siA0EAIAMgBU0bIgMgASABIANLGyIGBEAgBCgCACAFrSIJIAggCCAJVhunaiACQQxqIAb8CgAACyAEIAggBq18NwMIAkACQCABIANNDQBByOkAKQMAIghC/wGDQgRRDQAgAC0AAEEERwRAQ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AAAA0AAADULQAALAAAAG4AAAAVAAAABC4AACoAAAAxAAAARQAAAAQuAAAqAAAANwAAAA4AAAAELgAAKgAAADgAAABLAAAALi4AABYAAAAELgAAKgAAAEUAAAANAAAABC4AACoAAACEAAAADQAAAEguAAAoAAAA6AAAACMAAABILgAAKAAAAPUAAAA6AAAAcC4AAEUAAAC1LgAAHwAAANQuAAAyAAAARAAAABEAAAAGLwAAFwAAANQuAAAyAAAASgAAABEAAAAdLwAAHAAAANQuAAAyAAAAkQAAABIAAAA0JQAARCUAAFUlAABnJQAAdyUAAIclAACaJQAArCUAALklAADHJQAA3CUAAOglAADzJQAACCYAAB0mAAAsJgAAOiYAAE0mAABzJgAAqyYAAMQmAADbJgAA5yYAAPAmAAD6JgAACicAACEnAAAvJwAAPScAAEonAABeJwAAZicAAIEnAACPJwAAnycAALUnAADKJwAA1ScAAOsnAAD4JwAAAygAAA4oAACMKwAAlCsAAKQrAAC1KwAAxCsAANMrAADlKwAA9isAAAIsAAALLAAAGywAACYsAAAwLAAABiUAAD0sAABKLAAAViwAAGcsAAB5LAAAhywAAJ0sAACpLAAAtCwAALwsAADFLAAA0CwAANssAADoLAAA9CwAAAAtAAASLQAAGi0AACgtAAA0LQAAQy0AAFYtAABhLQAAbC0AAHktAACELQAAji0AAJMtAACsMAAACgAAABwAAAAF\")}function getBinarySync(file){if(ArrayBuffer.isView(file)){return file}if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw\"both async and sync fetching of the wasm failed\"}async function getWasmBinary(binaryFile){return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports[\"u\"];updateMemoryViews();wasmTable=wasmExports[\"H\"];assignWasmExports(wasmExports);removeRunDependency(\"wasm-instantiate\");return wasmExports}addRunDependency(\"wasm-instantiate\");function receiveInstantiationResult(result){return receiveInstance(result[\"instance\"])}var info=getWasmImports();if(Module[\"instantiateWasm\"]){return new Promise((resolve,reject)=>{Module[\"instantiateWasm\"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name=\"ExitStatus\";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var base64Decode=b64=>{var b1,b2,i=0,j=0,bLength=b64.length;var output=new Uint8Array((bLength*3>>2)-(b64[bLength-2]==\"=\")-(b64[bLength-1]==\"=\"));for(;i>4;output[j+1]=b1<<4|b2>>2;output[j+2]=b2<<6|base64ReverseLookup[b64.charCodeAt(i+3)]}return output};var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionLast=0;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var uncaughtExceptionCount=0;var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=ptr}throw exceptionLast};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd)+1;if(sizeabort(\"\");var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||\"./this.program\";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator==\"object\"&&navigator.language||\"C\").replace(\"-\",\"_\")+\".UTF-8\";var env={USER:\"web_user\",LOGNAME:\"web_user\",PATH:\"/\",PWD:\"/\",HOME:\"/home/web_user\",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module[\"onExit\"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var PATH={isAbs:path=>path.charAt(0)===\"/\",splitPath:filename=>{var splitPathRe=/^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last===\".\"){parts.splice(i,1)}else if(last===\"..\"){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift(\"..\")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.slice(-1)===\"/\";path=PATH.normalizeArray(path.split(\"/\").filter(p=>!!p),!isAbsolute).join(\"/\");if(!path&&!isAbsolute){path=\".\"}if(path&&trailingSlash){path+=\"/\"}return(isAbsolute?\"/\":\"\")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return\".\"}if(dir){dir=dir.slice(0,-1)}return root+dir},basename:path=>path&&path.match(/([^\\/]+|\\/)\\/*$/)[1],join:(...paths)=>PATH.normalize(paths.join(\"/\")),join2:(l,r)=>PATH.normalize(l+\"/\"+r)};var initRandomFill=()=>view=>crypto.getRandomValues(view);var randomFill=view=>{(randomFill=initRandomFill())(view)};var PATH_FS={resolve:(...args)=>{var resolvedPath=\"\",resolvedAbsolute=false;for(var i=args.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?args[i]:FS.cwd();if(typeof path!=\"string\"){throw new TypeError(\"Arguments to path.resolve must be strings\")}else if(!path){return\"\"}resolvedPath=path+\"/\"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split(\"/\").filter(p=>!!p),!resolvedAbsolute).join(\"/\");return(resolvedAbsolute?\"/\":\"\")+resolvedPath||\".\"},relative:(from,to)=>{from=PATH_FS.resolve(from).slice(1);to=PATH_FS.resolve(to).slice(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!==\"\")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split(\"/\"));var toParts=trim(to.split(\"/\"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str=\"\";while(idx>10,56320|ch&1023)}}return str};var FS_stdin_getChar_buffer=[];var intArrayFromString=(stringy,dontAddNull,length)=>{var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array};var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var result=null;if(typeof window!=\"undefined\"&&typeof window.prompt==\"function\"){result=window.prompt(\"Input: \");if(result!==null){result+=\"\\n\"}}else{}if(!result){return null}FS_stdin_getChar_buffer=intArrayFromString(result,true)}return FS_stdin_getChar_buffer.shift()};var TTY={ttys:[],init(){},shutdown(){},register(dev,ops){TTY.ttys[dev]={input:[],output:[],ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close(stream){stream.tty.ops.fsync(stream.tty)},fsync(stream){stream.tty.ops.fsync(stream.tty)},read(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i0){out(UTF8ArrayToString(tty.output));tty.output=[]}},ioctl_tcgets(tty){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(tty,optional_actions,data){return 0},ioctl_tiocgwinsz(tty){return[24,80]}},default_tty1_ops:{put_char(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync(tty){if(tty.output?.length>0){err(UTF8ArrayToString(tty.output));tty.output=[]}}}};var mmapAlloc=size=>{abort()};var MEMFS={ops_table:null,mount(mount){return MEMFS.createNode(null,\"/\",16895,0)},createNode(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}MEMFS.ops_table||={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}};var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.atime=node.mtime=node.ctime=Date.now();if(parent){parent.contents[name]=node;parent.atime=parent.mtime=parent.ctime=node.atime}return node},getFileDataAsTypedArray(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.atime);attr.mtime=new Date(node.mtime);attr.ctime=new Date(node.ctime);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr(node,attr){for(const key of[\"mode\",\"atime\",\"mtime\",\"ctime\"]){if(attr[key]!=null){node[key]=attr[key]}}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup(parent,name){throw MEMFS.doesNotExistError},mknod(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename(old_node,new_dir,new_name){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){if(FS.isDir(old_node.mode)){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}FS.hashRemoveNode(new_node)}delete old_node.parent.contents[old_node.name];new_dir.contents[new_name]=old_node;old_node.name=new_name;new_dir.ctime=new_dir.mtime=old_node.parent.ctime=old_node.parent.mtime=Date.now()},unlink(parent,name){delete parent.contents[name];parent.ctime=parent.mtime=Date.now()},rmdir(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.ctime=parent.mtime=Date.now()},readdir(node){return[\".\",\"..\",...Object.keys(node.contents)]},symlink(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length{var arrayBuffer=await readAsync(url);return new Uint8Array(arrayBuffer)};var FS_createDataFile=(...args)=>FS.createDataFile(...args);var getUniqueRunDependency=id=>id;var preloadPlugins=[];var FS_handledByPreloadPlugin=(byteArray,fullname,finish,onerror)=>{if(typeof Browser!=\"undefined\")Browser.init();var handled=false;preloadPlugins.forEach(plugin=>{if(handled)return;if(plugin[\"canHandle\"](fullname)){plugin[\"handle\"](byteArray,fullname,finish,onerror);handled=true}});return handled};var FS_createPreloadedFile=(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency(`cp ${fullname}`);function processData(byteArray){function finish(byteArray){preFinish?.();if(!dontCreateFile){FS_createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}onload?.();removeRunDependency(dep)}if(FS_handledByPreloadPlugin(byteArray,fullname,finish,()=>{onerror?.();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url==\"string\"){asyncLoad(url).then(processData,onerror)}else{processData(url)}};var FS_modeStringToFlags=str=>{var flagModes={r:0,\"r+\":2,w:512|64|1,\"w+\":512|64|2,a:1024|64|1,\"a+\":1024|64|2};var flags=flagModes[str];if(typeof flags==\"undefined\"){throw new Error(`Unknown file open mode: ${str}`)}return flags};var FS_getMode=(canRead,canWrite)=>{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode};var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:\"/\",initialized:false,ignorePermissions:true,filesystems:null,syncFSRequests:0,readFiles:{},ErrnoError:class{name=\"ErrnoError\";constructor(errno){this.errno=errno}},FSStream:class{shared={};get object(){return this.node}set object(val){this.node=val}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(val){this.shared.flags=val}get position(){return this.shared.position}set position(val){this.shared.position=val}},FSNode:class{node_ops={};stream_ops={};readMode=292|73;writeMode=146;mounted=null;constructor(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.rdev=rdev;this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(val){val?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(val){val?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return FS.isDir(this.mode)}get isDevice(){return FS.isChrdev(this.mode)}},lookupPath(path,opts={}){if(!path){throw new FS.ErrnoError(44)}opts.follow_mount??=true;if(!PATH.isAbs(path)){path=FS.cwd()+\"/\"+path}linkloop:for(var nlinks=0;nlinks<40;nlinks++){var parts=path.split(\"/\").filter(p=>!!p);var current=FS.root;var current_path=\"/\";for(var i=0;i>>0)%FS.nameTable.length},hashAddNode(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode(parent,name){var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode(parent,name,mode,rdev){var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode(node){FS.hashRemoveNode(node)},isRoot(node){return node===node.parent},isMountpoint(node){return!!node.mounted},isFile(mode){return(mode&61440)===32768},isDir(mode){return(mode&61440)===16384},isLink(mode){return(mode&61440)===40960},isChrdev(mode){return(mode&61440)===8192},isBlkdev(mode){return(mode&61440)===24576},isFIFO(mode){return(mode&61440)===4096},isSocket(mode){return(mode&49152)===49152},flagsToPermissionString(flag){var perms=[\"r\",\"w\",\"rw\"][flag&3];if(flag&512){perms+=\"w\"}return perms},nodePermissions(node,perms){if(FS.ignorePermissions){return 0}if(perms.includes(\"r\")&&!(node.mode&292)){return 2}else if(perms.includes(\"w\")&&!(node.mode&146)){return 2}else if(perms.includes(\"x\")&&!(node.mode&73)){return 2}return 0},mayLookup(dir){if(!FS.isDir(dir.mode))return 54;var errCode=FS.nodePermissions(dir,\"x\");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate(dir,name){if(!FS.isDir(dir.mode)){return 54}try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,\"wx\")},mayDelete(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,\"wx\");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen(node,flags){if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!==\"r\"||flags&(512|64)){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},checkOpExists(op,err){if(!op){throw new FS.ErrnoError(err)}return op},MAX_OPEN_FDS:4096,nextfd(){for(var fd=0;fd<=FS.MAX_OPEN_FDS;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStreamChecked(fd){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}return stream},getStream:fd=>FS.streams[fd],createStream(stream,fd=-1){stream=Object.assign(new FS.FSStream,stream);if(fd==-1){fd=FS.nextfd()}stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream(fd){FS.streams[fd]=null},dupStream(origStream,fd=-1){var stream=FS.createStream(origStream,fd);stream.stream_ops?.dup?.(stream);return stream},doSetAttr(stream,node,attr){var setattr=stream?.stream_ops.setattr;var arg=setattr?stream:node;setattr??=node.node_ops.setattr;FS.checkOpExists(setattr,63);setattr(arg,attr)},chrdev_stream_ops:{open(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;stream.stream_ops.open?.(stream)},llseek(){throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push(...m.mounts)}return mounts},syncfs(populate,callback){if(typeof populate==\"function\"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`)}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount(type,opts,mountpoint){var root=mountpoint===\"/\";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type,opts,mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup(parent,name){return parent.node_ops.lookup(parent,name)},mknod(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name){throw new FS.ErrnoError(28)}if(name===\".\"||name===\"..\"){throw new FS.ErrnoError(20)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},statfs(path){return FS.statfsNode(FS.lookupPath(path,{follow:true}).node)},statfsStream(stream){return FS.statfsNode(stream.node)},statfsNode(node){var rtn={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:FS.nextInode,ffree:FS.nextInode-1,fsid:42,flags:2,namelen:255};if(node.node_ops.statfs){Object.assign(rtn,node.node_ops.statfs(node.mount.opts.root))}return rtn},create(path,mode=438){mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir(path,mode=511){mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree(path,mode){var dirs=path.split(\"/\");var d=\"\";for(var dir of dirs){if(!dir)continue;if(d||PATH.isAbs(path))d+=\"/\";d+=dir;try{FS.mkdir(d,mode)}catch(e){if(e.errno!=20)throw e}}},mkdev(path,mode,dev){if(typeof dev==\"undefined\"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink(oldpath,newpath){if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename(old_path,new_path){var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!==\".\"){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!==\".\"){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,\"w\");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name);old_node.parent=new_dir}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir(path){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;var readdir=FS.checkOpExists(node.node_ops.readdir,54);return readdir(node)},unlink(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink(path){var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return link.node_ops.readlink(link)},stat(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;var getattr=FS.checkOpExists(node.node_ops.getattr,63);return getattr(node)},fstat(fd){var stream=FS.getStreamChecked(fd);var node=stream.node;var getattr=stream.stream_ops.getattr;var arg=getattr?stream:node;getattr??=node.node_ops.getattr;FS.checkOpExists(getattr,63);return getattr(arg)},lstat(path){return FS.stat(path,true)},doChmod(stream,node,mode,dontFollow){FS.doSetAttr(stream,node,{mode:mode&4095|node.mode&~4095,ctime:Date.now(),dontFollow})},chmod(path,mode,dontFollow){var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}FS.doChmod(null,node,mode,dontFollow)},lchmod(path,mode){FS.chmod(path,mode,true)},fchmod(fd,mode){var stream=FS.getStreamChecked(fd);FS.doChmod(stream,stream.node,mode,false)},doChown(stream,node,dontFollow){FS.doSetAttr(stream,node,{timestamp:Date.now(),dontFollow})},chown(path,uid,gid,dontFollow){var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}FS.doChown(null,node,dontFollow)},lchown(path,uid,gid){FS.chown(path,uid,gid,true)},fchown(fd,uid,gid){var stream=FS.getStreamChecked(fd);FS.doChown(stream,stream.node,false)},doTruncate(stream,node,len){if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,\"w\");if(errCode){throw new FS.ErrnoError(errCode)}FS.doSetAttr(stream,node,{size:len,timestamp:Date.now()})},truncate(path,len){if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path==\"string\"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}FS.doTruncate(null,node,len)},ftruncate(fd,len){var stream=FS.getStreamChecked(fd);if(len<0||(stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.doTruncate(stream,stream.node,len)},utime(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;var setattr=FS.checkOpExists(node.node_ops.setattr,63);setattr(node,{atime,mtime})},open(path,flags,mode=438){if(path===\"\"){throw new FS.ErrnoError(44)}flags=typeof flags==\"string\"?FS_modeStringToFlags(flags):flags;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;var isDirPath;if(typeof path==\"object\"){node=path}else{isDirPath=path.endsWith(\"/\");var lookup=FS.lookupPath(path,{follow:!(flags&131072),noent_okay:true});node=lookup.node;path=lookup.path}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else if(isDirPath){throw new FS.ErrnoError(31)}else{node=FS.mknod(path,mode|511,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node,path:FS.getPath(node),flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(created){FS.chmod(node,mode&511)}if(Module[\"logReadFiles\"]&&!(flags&1)){if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close(stream){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed(stream){return stream.fd===null},llseek(stream,offset,whence){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read(stream,buffer,offset,length,position){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!=\"undefined\";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write(stream,buffer,offset,length,position,canOwn){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!=\"undefined\";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},mmap(stream,length,position,prot,flags){if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}if(!length){throw new FS.ErrnoError(28)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync(stream,buffer,offset,length,mmapFlags){if(!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},ioctl(stream,cmd,arg){if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile(path,opts={}){opts.flags=opts.flags||0;opts.encoding=opts.encoding||\"binary\";if(opts.encoding!==\"utf8\"&&opts.encoding!==\"binary\"){throw new Error(`Invalid encoding type \"${opts.encoding}\"`)}var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding===\"utf8\"){buf=UTF8ArrayToString(buf)}FS.close(stream);return buf},writeFile(path,data,opts={}){opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data==\"string\"){data=new Uint8Array(intArrayFromString(data,true))}if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error(\"Unsupported data type\")}FS.close(stream)},cwd:()=>FS.currentPath,chdir(path){var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,\"x\");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories(){FS.mkdir(\"/tmp\");FS.mkdir(\"/home\");FS.mkdir(\"/home/web_user\")},createDefaultDevices(){FS.mkdir(\"/dev\");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length,llseek:()=>0});FS.mkdev(\"/dev/null\",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev(\"/dev/tty\",FS.makedev(5,0));FS.mkdev(\"/dev/tty1\",FS.makedev(6,0));var randomBuffer=new Uint8Array(1024),randomLeft=0;var randomByte=()=>{if(randomLeft===0){randomFill(randomBuffer);randomLeft=randomBuffer.byteLength}return randomBuffer[--randomLeft]};FS.createDevice(\"/dev\",\"random\",randomByte);FS.createDevice(\"/dev\",\"urandom\",randomByte);FS.mkdir(\"/dev/shm\");FS.mkdir(\"/dev/shm/tmp\")},createSpecialDirectories(){FS.mkdir(\"/proc\");var proc_self=FS.mkdir(\"/proc/self\");FS.mkdir(\"/proc/self/fd\");FS.mount({mount(){var node=FS.createNode(proc_self,\"fd\",16895,73);node.stream_ops={llseek:MEMFS.stream_ops.llseek};node.node_ops={lookup(parent,name){var fd=+name;var stream=FS.getStreamChecked(fd);var ret={parent:null,mount:{mountpoint:\"fake\"},node_ops:{readlink:()=>stream.path},id:fd+1};ret.parent=ret;return ret},readdir(){return Array.from(FS.streams.entries()).filter(([k,v])=>v).map(([k,v])=>k.toString())}};return node}},{},\"/proc/self/fd\")},createStandardStreams(input,output,error){if(input){FS.createDevice(\"/dev\",\"stdin\",input)}else{FS.symlink(\"/dev/tty\",\"/dev/stdin\")}if(output){FS.createDevice(\"/dev\",\"stdout\",null,output)}else{FS.symlink(\"/dev/tty\",\"/dev/stdout\")}if(error){FS.createDevice(\"/dev\",\"stderr\",null,error)}else{FS.symlink(\"/dev/tty1\",\"/dev/stderr\")}var stdin=FS.open(\"/dev/stdin\",0);var stdout=FS.open(\"/dev/stdout\",1);var stderr=FS.open(\"/dev/stderr\",1)},staticInit(){FS.nameTable=new Array(4096);FS.mount(MEMFS,{},\"/\");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={MEMFS}},init(input,output,error){FS.initialized=true;input??=Module[\"stdin\"];output??=Module[\"stdout\"];error??=Module[\"stderr\"];FS.createStandardStreams(input,output,error)},quit(){FS.initialized=false;for(var stream of FS.streams){if(stream){FS.close(stream)}}},findObject(path,dontResolveLastLink){var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath(path,dontResolveLastLink){try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path===\"/\"}catch(e){ret.error=e.errno}return ret},createPath(parent,path,canRead,canWrite){parent=typeof parent==\"string\"?parent:FS.getPath(parent);var parts=path.split(\"/\").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){if(e.errno!=20)throw e}parent=current}return current},createFile(parent,name,properties,canRead,canWrite){var path=PATH.join2(typeof parent==\"string\"?parent:FS.getPath(parent),name);var mode=FS_getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile(parent,name,data,canRead,canWrite,canOwn){var path=name;if(parent){parent=typeof parent==\"string\"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS_getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data==\"string\"){var arr=new Array(data.length);for(var i=0,len=data.length;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]}setDataGetter(getter){this.getter=getter}cacheLength(){var xhr=new XMLHttpRequest;xhr.open(\"HEAD\",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error(\"Couldn't load \"+url+\". Status: \"+xhr.status);var datalength=Number(xhr.getResponseHeader(\"Content-length\"));var header;var hasByteServing=(header=xhr.getResponseHeader(\"Accept-Ranges\"))&&header===\"bytes\";var usesGzip=(header=xhr.getResponseHeader(\"Content-Encoding\"))&&header===\"gzip\";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error(\"invalid range (\"+from+\", \"+to+\") or no bytes requested!\");if(to>datalength-1)throw new Error(\"only \"+datalength+\" bytes available! programmer error!\");var xhr=new XMLHttpRequest;xhr.open(\"GET\",url,false);if(datalength!==chunkSize)xhr.setRequestHeader(\"Range\",\"bytes=\"+from+\"-\"+to);xhr.responseType=\"arraybuffer\";if(xhr.overrideMimeType){xhr.overrideMimeType(\"text/plain; charset=x-user-defined\")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error(\"Couldn't load \"+url+\". Status: \"+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||\"\",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==\"undefined\"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==\"undefined\")throw new Error(\"doXHR failed!\");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out(\"LazyFiles on gzip forces download of the whole file when length is accessed\")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true}get length(){if(!this.lengthKnown){this.cacheLength()}return this._length}get chunkSize(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}if(typeof XMLHttpRequest!=\"undefined\"){if(!ENVIRONMENT_IS_WORKER)throw\"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc\";var lazyArray=new LazyUint8Array;var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=(...args)=>{FS.forceLoadFile(node);return fn(...args)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr,allocated:true}};node.stream_ops=stream_ops;return node}};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):\"\";var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=SYSCALLS.getStreamFromFD(dirfd);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return dir+\"/\"+path},writeStat(buf,stat){HEAP32[buf>>2]=stat.dev;HEAP32[buf+4>>2]=stat.mode;HEAPU32[buf+8>>2]=stat.nlink;HEAP32[buf+12>>2]=stat.uid;HEAP32[buf+16>>2]=stat.gid;HEAP32[buf+20>>2]=stat.rdev;HEAP64[buf+24>>3]=BigInt(stat.size);HEAP32[buf+32>>2]=4096;HEAP32[buf+36>>2]=stat.blocks;var atime=stat.atime.getTime();var mtime=stat.mtime.getTime();var ctime=stat.ctime.getTime();HEAP64[buf+40>>3]=BigInt(Math.floor(atime/1e3));HEAPU32[buf+48>>2]=atime%1e3*1e3*1e3;HEAP64[buf+56>>3]=BigInt(Math.floor(mtime/1e3));HEAPU32[buf+64>>2]=mtime%1e3*1e3*1e3;HEAP64[buf+72>>3]=BigInt(Math.floor(ctime/1e3));HEAPU32[buf+80>>2]=ctime%1e3*1e3*1e3;HEAP64[buf+88>>3]=BigInt(stat.ino);return 0},writeStatFs(buf,stats){HEAP32[buf+4>>2]=stats.bsize;HEAP32[buf+40>>2]=stats.bsize;HEAP32[buf+8>>2]=stats.blocks;HEAP32[buf+12>>2]=stats.bfree;HEAP32[buf+16>>2]=stats.bavail;HEAP32[buf+20>>2]=stats.files;HEAP32[buf+24>>2]=stats.ffree;HEAP32[buf+28>>2]=stats.fsid;HEAP32[buf+44>>2]=stats.flags;HEAP32[buf+36>>2]=stats.namelen},doMsync(addr,stream,len,flags,offset){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(43)}if(flags&2){return 0}var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},getStreamFromFD(fd){var stream=FS.getStreamChecked(fd);return stream},varargs:undefined,getStr(ptr){var ret=UTF8ToString(ptr);return ret}};function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>numINT53_MAX?NaN:Number(num);function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);try{if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);HEAP64[newOffset>>3]=BigInt(stream.position);if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var doWritev=(stream,iov,iovcnt,offset)=>{var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2]=num;return 0}catch(e){if(typeof FS==\"undefined\"||!(e.name===\"ErrnoError\"))throw e;return e.errno}}var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var getCFunc=ident=>{var func=Module[\"_\"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType===\"string\"){return UTF8ToString(ret)}if(returnType===\"boolean\")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i{var numericArgs=!argTypes||argTypes.every(type=>type===\"number\"||type===\"boolean\");var numericRet=returnType!==\"string\";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};for(var base64ReverseLookup=new Uint8Array(123),i=25;i>=0;--i){base64ReverseLookup[48+i]=52+i;base64ReverseLookup[65+i]=i;base64ReverseLookup[97+i]=26+i}base64ReverseLookup[43]=62;base64ReverseLookup[47]=63;FS.createPreloadedFile=FS_createPreloadedFile;FS.staticInit();MEMFS.doesNotExistError=new FS.ErrnoError(44);MEMFS.doesNotExistError.stack=\"\";{if(Module[\"noExitRuntime\"])noExitRuntime=Module[\"noExitRuntime\"];if(Module[\"preloadPlugins\"])preloadPlugins=Module[\"preloadPlugins\"];if(Module[\"print\"])out=Module[\"print\"];if(Module[\"printErr\"])err=Module[\"printErr\"];if(Module[\"wasmBinary\"])wasmBinary=Module[\"wasmBinary\"];if(Module[\"arguments\"])arguments_=Module[\"arguments\"];if(Module[\"thisProgram\"])thisProgram=Module[\"thisProgram\"]}Module[\"ccall\"]=ccall;Module[\"cwrap\"]=cwrap;var _AecNew,_AecCancelEcho,_AecDestroy,_malloc,_free,_setThrew,__emscripten_tempret_set,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_can_catch;function assignWasmExports(wasmExports){Module[\"_AecNew\"]=_AecNew=wasmExports[\"w\"];Module[\"_AecCancelEcho\"]=_AecCancelEcho=wasmExports[\"x\"];Module[\"_AecDestroy\"]=_AecDestroy=wasmExports[\"y\"];Module[\"_malloc\"]=_malloc=wasmExports[\"z\"];Module[\"_free\"]=_free=wasmExports[\"A\"];_setThrew=wasmExports[\"B\"];__emscripten_tempret_set=wasmExports[\"C\"];__emscripten_stack_restore=wasmExports[\"D\"];__emscripten_stack_alloc=wasmExports[\"E\"];_emscripten_stack_get_current=wasmExports[\"F\"];___cxa_can_catch=wasmExports[\"G\"]}var wasmImports={a:___cxa_find_matching_catch_2,q:___cxa_throw,b:___resumeException,p:___syscall_getcwd,r:__abort_js,t:_emscripten_resize_heap,n:_environ_get,o:_environ_sizes_get,k:_exit,s:_fd_close,l:_fd_seek,g:_fd_write,i:invoke_ii,f:invoke_iiii,m:invoke_iiiiii,c:invoke_vi,d:invoke_vii,e:invoke_viii,j:invoke_viiii,h:invoke_viiiii};var wasmExports=await createWasm();function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module[\"calledRun\"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module[\"onRuntimeInitialized\"]?.();postRun()}if(Module[\"setStatus\"]){Module[\"setStatus\"](\"Running...\");setTimeout(()=>{setTimeout(()=>Module[\"setStatus\"](\"\"),1);doRun()},1)}else{doRun()}}function preInit(){if(Module[\"preInit\"]){if(typeof Module[\"preInit\"]==\"function\")Module[\"preInit\"]=[Module[\"preInit\"]];while(Module[\"preInit\"].length>0){Module[\"preInit\"].shift()()}}}preInit();run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}\n\n\n return moduleRtn;\n}\n);\n})();\nif (typeof exports === 'object' && typeof module === 'object') {\n module.exports = createAecModule;\n // This default export looks redundant, but it allows TS to import this\n // commonjs style module.\n module.exports.default = createAecModule;\n} else if (typeof define === 'function' && define['amd'])\n define([], () => createAecModule);\n"], ["/glass/src/ui/app/MainHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class MainHeader extends LitElement {\n static properties = {\n isTogglingSession: { type: Boolean, state: true },\n shortcuts: { type: Object, state: true },\n listenSessionStatus: { type: String, state: true },\n };\n\n static styles = css`\n :host {\n display: flex;\n transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease-out;\n }\n\n :host(.hiding) {\n animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;\n }\n\n :host(.showing) {\n animation: slideDown 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n\n :host(.sliding-in) {\n animation: fadeIn 0.2s ease-out forwards;\n }\n\n :host(.hidden) {\n opacity: 0;\n transform: translateY(-150%) scale(0.85);\n pointer-events: none;\n }\n\n\n * {\n font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: default;\n user-select: none;\n }\n\n .header {\n -webkit-app-region: drag;\n width: max-content;\n height: 47px;\n padding: 2px 10px 2px 13px;\n background: transparent;\n overflow: hidden;\n border-radius: 9000px;\n /* backdrop-filter: blur(1px); */\n justify-content: space-between;\n align-items: center;\n display: inline-flex;\n box-sizing: border-box;\n position: relative;\n }\n\n .header::before {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n border-radius: 9000px;\n z-index: -1;\n }\n\n .header::after {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n border-radius: 9000px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%); \n -webkit-mask:\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .listen-button {\n -webkit-app-region: no-drag;\n height: 26px;\n padding: 0 13px;\n background: transparent;\n border-radius: 9000px;\n justify-content: center;\n width: 78px;\n align-items: center;\n gap: 6px;\n display: flex;\n border: none;\n cursor: pointer;\n position: relative;\n }\n\n .listen-button:disabled {\n cursor: default;\n opacity: 0.8;\n }\n\n .listen-button.active::before {\n background: rgba(215, 0, 0, 0.5);\n }\n\n .listen-button.active:hover::before {\n background: rgba(255, 20, 20, 0.6);\n }\n\n .listen-button.done {\n background-color: rgba(255, 255, 255, 0.6);\n transition: background-color 0.15s ease;\n }\n\n .listen-button.done .action-text-content {\n color: black;\n }\n \n .listen-button.done .listen-icon svg rect,\n .listen-button.done .listen-icon svg path {\n fill: black;\n }\n\n .listen-button.done:hover {\n background-color: #f0f0f0;\n }\n\n .listen-button:hover::before {\n background: rgba(255, 255, 255, 0.18);\n }\n\n .listen-button::before {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n background: rgba(255, 255, 255, 0.14);\n border-radius: 9000px;\n z-index: -1;\n transition: background 0.15s ease;\n }\n\n .listen-button::after {\n content: '';\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n border-radius: 9000px;\n padding: 1px;\n background: linear-gradient(169deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.17) 100%);\n -webkit-mask:\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n pointer-events: none;\n }\n\n .listen-button.done::after {\n display: none;\n }\n\n .loading-dots {\n display: flex;\n align-items: center;\n gap: 5px;\n }\n\n .loading-dots span {\n width: 6px;\n height: 6px;\n background-color: white;\n border-radius: 50%;\n animation: pulse 1.4s infinite ease-in-out both;\n }\n .loading-dots span:nth-of-type(1) {\n animation-delay: -0.32s;\n }\n .loading-dots span:nth-of-type(2) {\n animation-delay: -0.16s;\n }\n @keyframes pulse {\n 0%, 80%, 100% {\n opacity: 0.2;\n }\n 40% {\n opacity: 1.0;\n }\n }\n\n .header-actions {\n -webkit-app-region: no-drag;\n height: 26px;\n box-sizing: border-box;\n justify-content: flex-start;\n align-items: center;\n gap: 9px;\n display: flex;\n padding: 0 8px;\n border-radius: 6px;\n transition: background 0.15s ease;\n }\n\n .header-actions:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .ask-action {\n margin-left: 4px;\n }\n\n .action-button,\n .action-text {\n padding-bottom: 1px;\n justify-content: center;\n align-items: center;\n gap: 10px;\n display: flex;\n }\n\n .action-text-content {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500; /* Medium */\n word-wrap: break-word;\n }\n\n .icon-container {\n justify-content: flex-start;\n align-items: center;\n gap: 4px;\n display: flex;\n }\n\n .icon-container.ask-icons svg,\n .icon-container.showhide-icons svg {\n width: 12px;\n height: 12px;\n }\n\n .listen-icon svg {\n width: 12px;\n height: 11px;\n position: relative;\n top: 1px;\n }\n\n .icon-box {\n color: white;\n font-size: 12px;\n font-family: 'Helvetica Neue', sans-serif;\n font-weight: 500;\n background-color: rgba(255, 255, 255, 0.1);\n border-radius: 13%;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .settings-button {\n -webkit-app-region: no-drag;\n padding: 5px;\n border-radius: 50%;\n background: transparent;\n transition: background 0.15s ease;\n color: white;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n .settings-button:hover {\n background: rgba(255, 255, 255, 0.1);\n }\n\n .settings-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 3px;\n }\n\n .settings-icon svg {\n width: 16px;\n height: 16px;\n }\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) .header,\n :host-context(body.has-glass) .listen-button,\n :host-context(body.has-glass) .header-actions,\n :host-context(body.has-glass) .settings-button {\n background: transparent !important;\n filter: none !important;\n box-shadow: none !important;\n backdrop-filter: none !important;\n }\n :host-context(body.has-glass) .icon-box {\n background: transparent !important;\n border: none !important;\n }\n\n :host-context(body.has-glass) .header::before,\n :host-context(body.has-glass) .header::after,\n :host-context(body.has-glass) .listen-button::before,\n :host-context(body.has-glass) .listen-button::after {\n display: none !important;\n }\n\n :host-context(body.has-glass) .header-actions:hover,\n :host-context(body.has-glass) .settings-button:hover,\n :host-context(body.has-glass) .listen-button:hover::before {\n background: transparent !important;\n }\n :host-context(body.has-glass) * {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n }\n\n :host-context(body.has-glass) .header,\n :host-context(body.has-glass) .listen-button,\n :host-context(body.has-glass) .header-actions,\n :host-context(body.has-glass) .settings-button,\n :host-context(body.has-glass) .icon-box {\n border-radius: 0 !important;\n }\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n `;\n\n constructor() {\n super();\n this.shortcuts = {};\n this.isVisible = true;\n this.isAnimating = false;\n this.hasSlidIn = false;\n this.settingsHideTimer = null;\n this.isTogglingSession = false;\n this.listenSessionStatus = 'beforeSession';\n this.animationEndTimer = null;\n this.handleAnimationEnd = this.handleAnimationEnd.bind(this);\n this.handleMouseMove = this.handleMouseMove.bind(this);\n this.handleMouseUp = this.handleMouseUp.bind(this);\n this.dragState = null;\n this.wasJustDragged = false;\n }\n\n _getListenButtonText(status) {\n switch (status) {\n case 'beforeSession': return 'Listen';\n case 'inSession' : return 'Stop';\n case 'afterSession': return 'Done';\n default : return 'Listen';\n }\n }\n\n async handleMouseDown(e) {\n e.preventDefault();\n\n const initialPosition = await window.api.mainHeader.getHeaderPosition();\n\n this.dragState = {\n initialMouseX: e.screenX,\n initialMouseY: e.screenY,\n initialWindowX: initialPosition.x,\n initialWindowY: initialPosition.y,\n moved: false,\n };\n\n window.addEventListener('mousemove', this.handleMouseMove, { capture: true });\n window.addEventListener('mouseup', this.handleMouseUp, { once: true, capture: true });\n }\n\n handleMouseMove(e) {\n if (!this.dragState) return;\n\n const deltaX = Math.abs(e.screenX - this.dragState.initialMouseX);\n const deltaY = Math.abs(e.screenY - this.dragState.initialMouseY);\n \n if (deltaX > 3 || deltaY > 3) {\n this.dragState.moved = true;\n }\n\n const newWindowX = this.dragState.initialWindowX + (e.screenX - this.dragState.initialMouseX);\n const newWindowY = this.dragState.initialWindowY + (e.screenY - this.dragState.initialMouseY);\n\n window.api.mainHeader.moveHeaderTo(newWindowX, newWindowY);\n }\n\n handleMouseUp(e) {\n if (!this.dragState) return;\n\n const wasDragged = this.dragState.moved;\n\n window.removeEventListener('mousemove', this.handleMouseMove, { capture: true });\n this.dragState = null;\n\n if (wasDragged) {\n this.wasJustDragged = true;\n setTimeout(() => {\n this.wasJustDragged = false;\n }, 0);\n }\n }\n\n toggleVisibility() {\n if (this.isAnimating) {\n console.log('[MainHeader] Animation already in progress, ignoring toggle');\n return;\n }\n \n if (this.animationEndTimer) {\n clearTimeout(this.animationEndTimer);\n this.animationEndTimer = null;\n }\n \n this.isAnimating = true;\n \n if (this.isVisible) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n hide() {\n this.classList.remove('showing');\n this.classList.add('hiding');\n }\n \n show() {\n this.classList.remove('hiding', 'hidden');\n this.classList.add('showing');\n }\n \n handleAnimationEnd(e) {\n if (e.target !== this) return;\n \n this.isAnimating = false;\n \n if (this.classList.contains('hiding')) {\n this.classList.add('hidden');\n if (window.api) {\n window.api.mainHeader.sendHeaderAnimationFinished('hidden');\n }\n } else if (this.classList.contains('showing')) {\n if (window.api) {\n window.api.mainHeader.sendHeaderAnimationFinished('visible');\n }\n }\n }\n\n startSlideInAnimation() {\n if (this.hasSlidIn) return;\n this.classList.add('sliding-in');\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('animationend', this.handleAnimationEnd);\n\n if (window.api) {\n\n this._sessionStateTextListener = (event, { success }) => {\n if (success) {\n this.listenSessionStatus = ({\n beforeSession: 'inSession',\n inSession: 'afterSession',\n afterSession: 'beforeSession',\n })[this.listenSessionStatus] || 'beforeSession';\n } else {\n this.listenSessionStatus = 'beforeSession';\n }\n this.isTogglingSession = false; // ✨ 로딩 상태만 해제\n };\n window.api.mainHeader.onListenChangeSessionResult(this._sessionStateTextListener);\n\n this._shortcutListener = (event, keybinds) => {\n console.log('[MainHeader] Received updated shortcuts:', keybinds);\n this.shortcuts = keybinds;\n };\n window.api.mainHeader.onShortcutsUpdated(this._shortcutListener);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('animationend', this.handleAnimationEnd);\n \n if (this.animationEndTimer) {\n clearTimeout(this.animationEndTimer);\n this.animationEndTimer = null;\n }\n \n if (window.api) {\n if (this._sessionStateTextListener) {\n window.api.mainHeader.removeOnListenChangeSessionResult(this._sessionStateTextListener);\n }\n if (this._shortcutListener) {\n window.api.mainHeader.removeOnShortcutsUpdated(this._shortcutListener);\n }\n }\n }\n\n showSettingsWindow(element) {\n if (this.wasJustDragged) return;\n if (window.api) {\n console.log(`[MainHeader] showSettingsWindow called at ${Date.now()}`);\n window.api.mainHeader.showSettingsWindow();\n\n }\n }\n\n hideSettingsWindow() {\n if (this.wasJustDragged) return;\n if (window.api) {\n console.log(`[MainHeader] hideSettingsWindow called at ${Date.now()}`);\n window.api.mainHeader.hideSettingsWindow();\n }\n }\n\n async _handleListenClick() {\n if (this.wasJustDragged) return;\n if (this.isTogglingSession) {\n return;\n }\n\n this.isTogglingSession = true;\n\n try {\n const listenButtonText = this._getListenButtonText(this.listenSessionStatus);\n if (window.api) {\n await window.api.mainHeader.sendListenButtonClick(listenButtonText);\n }\n } catch (error) {\n console.error('IPC invoke for session change failed:', error);\n this.isTogglingSession = false;\n }\n }\n\n async _handleAskClick() {\n if (this.wasJustDragged) return;\n\n try {\n if (window.api) {\n await window.api.mainHeader.sendAskButtonClick();\n }\n } catch (error) {\n console.error('IPC invoke for ask button failed:', error);\n }\n }\n\n async _handleToggleAllWindowsVisibility() {\n if (this.wasJustDragged) return;\n\n try {\n if (window.api) {\n await window.api.mainHeader.sendToggleAllWindowsVisibility();\n }\n } catch (error) {\n console.error('IPC invoke for all windows visibility button failed:', error);\n }\n }\n\n\n renderShortcut(accelerator) {\n if (!accelerator) return html``;\n\n const keyMap = {\n 'Cmd': '⌘', 'Command': '⌘',\n 'Ctrl': '⌃', 'Control': '⌃',\n 'Alt': '⌥', 'Option': '⌥',\n 'Shift': '⇧',\n 'Enter': '↵',\n 'Backspace': '⌫',\n 'Delete': '⌦',\n 'Tab': '⇥',\n 'Escape': '⎋',\n 'Up': '↑', 'Down': '↓', 'Left': '←', 'Right': '→',\n '\\\\': html``,\n };\n\n const keys = accelerator.split('+');\n return html`${keys.map(key => html`\n
${keyMap[key] || key}
\n `)}`;\n }\n\n render() {\n const listenButtonText = this._getListenButtonText(this.listenSessionStatus);\n \n const buttonClasses = {\n active: listenButtonText === 'Stop',\n done: listenButtonText === 'Done',\n };\n const showStopIcon = listenButtonText === 'Stop' || listenButtonText === 'Done';\n\n return html`\n
\n \n\n
this._handleAskClick()}>\n
\n
Ask
\n
\n
\n ${this.renderShortcut(this.shortcuts.nextStep)}\n
\n
\n\n
this._handleToggleAllWindowsVisibility()}>\n
\n
Show/Hide
\n
\n
\n ${this.renderShortcut(this.shortcuts.toggleVisibility)}\n
\n
\n\n \n
\n `;\n }\n}\n\ncustomElements.define('main-header', MainHeader);\n"], ["/glass/pickleglass_web/backend_node/routes/presets.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/', async (req, res) => {\n try {\n const presets = await ipcRequest(req, 'get-presets');\n res.json(presets);\n } catch (error) {\n console.error('Failed to get presets via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve presets' });\n }\n});\n\nrouter.post('/', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'create-preset', req.body);\n res.status(201).json({ ...result, message: 'Preset created successfully' });\n } catch (error) {\n console.error('Failed to create preset via IPC:', error);\n res.status(500).json({ error: 'Failed to create preset' });\n }\n});\n\nrouter.put('/:id', async (req, res) => {\n try {\n await ipcRequest(req, 'update-preset', { id: req.params.id, data: req.body });\n res.json({ message: 'Preset updated successfully' });\n } catch (error) {\n console.error('Failed to update preset via IPC:', error);\n res.status(500).json({ error: 'Failed to update preset' });\n }\n});\n\nrouter.delete('/:id', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-preset', req.params.id);\n res.json({ message: 'Preset deleted successfully' });\n } catch (error) {\n console.error('Failed to delete preset via IPC:', error);\n res.status(500).json({ error: 'Failed to delete preset' });\n }\n});\n\nmodule.exports = router; "], ["/glass/src/features/common/repositories/whisperModel/index.js", "const BaseModelRepository = require('../baseModel');\n\nclass WhisperModelRepository extends BaseModelRepository {\n constructor(db, tableName = 'whisper_models') {\n super(db, tableName);\n }\n\n async initializeModels(availableModels) {\n const existingModels = await this.getAll();\n const existingIds = new Set(existingModels.map(m => m.id));\n \n for (const [modelId, modelInfo] of Object.entries(availableModels)) {\n if (!existingIds.has(modelId)) {\n await this.create({\n id: modelId,\n name: modelInfo.name,\n size: modelInfo.size,\n installed: 0,\n installing: 0\n });\n }\n }\n }\n\n async getInstalledModels() {\n return this.findAll({ installed: 1 });\n }\n\n async setInstalled(modelId, installed = true) {\n return this.update({ id: modelId }, { \n installed: installed ? 1 : 0,\n installing: 0\n });\n }\n\n async setInstalling(modelId, installing = true) {\n return this.update({ id: modelId }, { \n installing: installing ? 1 : 0 \n });\n }\n\n async isInstalled(modelId) {\n const model = await this.findOne({ id: modelId });\n return model && model.installed === 1;\n }\n\n async isInstalling(modelId) {\n const model = await this.findOne({ id: modelId });\n return model && model.installing === 1;\n }\n}\n\nmodule.exports = WhisperModelRepository;"], ["/glass/pickleglass_web/backend_node/index.js", "const express = require('express');\nconst cors = require('cors');\n// const db = require('./db'); // No longer needed\nconst { identifyUser } = require('./middleware/auth');\n\nfunction createApp(eventBridge) {\n const app = express();\n\n const webUrl = process.env.pickleglass_WEB_URL || 'http://localhost:3000';\n console.log(`🔧 Backend CORS configured for: ${webUrl}`);\n\n app.use(cors({\n origin: webUrl,\n credentials: true,\n }));\n\n app.use(express.json());\n\n app.get('/', (req, res) => {\n res.json({ message: \"pickleglass API is running\" });\n });\n\n app.use((req, res, next) => {\n req.bridge = eventBridge;\n next();\n });\n\n app.use('/api', identifyUser);\n\n app.use('/api/auth', require('./routes/auth'));\n app.use('/api/user', require('./routes/user'));\n app.use('/api/conversations', require('./routes/conversations'));\n app.use('/api/presets', require('./routes/presets'));\n\n app.get('/api/sync/status', (req, res) => {\n res.json({\n status: 'online',\n timestamp: new Date().toISOString(),\n version: '1.0.0'\n });\n });\n\n app.post('/api/desktop/set-user', (req, res) => {\n res.json({\n success: true,\n message: \"Direct IPC communication is now used. This endpoint is deprecated.\",\n user: req.body,\n deprecated: true\n });\n });\n\n app.get('/api/desktop/status', (req, res) => {\n res.json({\n connected: true,\n current_user: null,\n communication_method: \"IPC\",\n file_based_deprecated: true\n });\n });\n\n return app;\n}\n\nmodule.exports = createApp;\n"], ["/glass/src/features/common/config/config.js", "// Configuration management for environment-based settings\nconst os = require('os');\nconst path = require('path');\nconst fs = require('fs');\n\nclass Config {\n constructor() {\n this.env = process.env.NODE_ENV || 'development';\n this.defaults = {\n apiUrl: process.env.pickleglass_API_URL || 'http://localhost:9001',\n apiTimeout: 10000,\n \n webUrl: process.env.pickleglass_WEB_URL || 'http://localhost:3000',\n \n enableJWT: false,\n fallbackToHeaderAuth: false,\n \n cacheTimeout: 5 * 60 * 1000,\n enableCaching: true,\n \n syncInterval: 0,\n healthCheckInterval: 30 * 1000,\n \n defaultWindowWidth: 400,\n defaultWindowHeight: 60,\n \n enableOfflineMode: true,\n enableFileBasedCommunication: false,\n enableSQLiteStorage: true,\n \n logLevel: 'info',\n enableDebugLogging: false\n };\n \n this.config = { ...this.defaults };\n this.loadEnvironmentConfig();\n this.loadUserConfig();\n }\n \n loadEnvironmentConfig() {\n if (process.env.pickleglass_API_URL) {\n this.config.apiUrl = process.env.pickleglass_API_URL;\n console.log(`[Config] API URL from env: ${this.config.apiUrl}`);\n }\n \n if (process.env.pickleglass_WEB_URL) {\n this.config.webUrl = process.env.pickleglass_WEB_URL;\n console.log(`[Config] Web URL from env: ${this.config.webUrl}`);\n }\n \n if (process.env.pickleglass_API_TIMEOUT) {\n this.config.apiTimeout = parseInt(process.env.pickleglass_API_TIMEOUT);\n }\n \n if (process.env.pickleglass_ENABLE_JWT) {\n this.config.enableJWT = process.env.pickleglass_ENABLE_JWT === 'true';\n }\n \n if (process.env.pickleglass_CACHE_TIMEOUT) {\n this.config.cacheTimeout = parseInt(process.env.pickleglass_CACHE_TIMEOUT);\n }\n \n if (process.env.pickleglass_LOG_LEVEL) {\n this.config.logLevel = process.env.pickleglass_LOG_LEVEL;\n }\n \n if (process.env.pickleglass_DEBUG) {\n this.config.enableDebugLogging = process.env.pickleglass_DEBUG === 'true';\n }\n \n if (this.env === 'production') {\n this.config.enableDebugLogging = false;\n this.config.logLevel = 'warn';\n } else if (this.env === 'development') {\n this.config.enableDebugLogging = true;\n this.config.logLevel = 'debug';\n }\n }\n \n loadUserConfig() {\n try {\n const userConfigPath = this.getUserConfigPath();\n if (fs.existsSync(userConfigPath)) {\n const userConfig = JSON.parse(fs.readFileSync(userConfigPath, 'utf-8'));\n this.config = { ...this.config, ...userConfig };\n console.log('[Config] User config loaded from:', userConfigPath);\n }\n } catch (error) {\n console.warn('[Config] Failed to load user config:', error.message);\n }\n }\n \n getUserConfigPath() {\n const configDir = path.join(os.homedir(), '.pickleglass');\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true });\n }\n return path.join(configDir, 'config.json');\n }\n \n get(key) {\n return this.config[key];\n }\n \n set(key, value) {\n this.config[key] = value;\n }\n \n getAll() {\n return { ...this.config };\n }\n \n saveUserConfig() {\n try {\n const userConfigPath = this.getUserConfigPath();\n const userConfig = { ...this.config };\n \n Object.keys(this.defaults).forEach(key => {\n if (userConfig[key] === this.defaults[key]) {\n delete userConfig[key];\n }\n });\n \n fs.writeFileSync(userConfigPath, JSON.stringify(userConfig, null, 2));\n console.log('[Config] User config saved to:', userConfigPath);\n } catch (error) {\n console.error('[Config] Failed to save user config:', error);\n }\n }\n \n reset() {\n this.config = { ...this.defaults };\n this.loadEnvironmentConfig();\n }\n \n isDevelopment() {\n return this.env === 'development';\n }\n \n isProduction() {\n return this.env === 'production';\n }\n \n shouldLog(level) {\n const levels = ['debug', 'info', 'warn', 'error'];\n const currentLevelIndex = levels.indexOf(this.config.logLevel);\n const requestedLevelIndex = levels.indexOf(level);\n return requestedLevelIndex >= currentLevelIndex;\n }\n}\n\nconst config = new Config();\n\nmodule.exports = config;"], ["/glass/functions/index.js", "/**\n * Import function triggers from their respective submodules:\n *\n * const {onCall} = require(\"firebase-functions/v2/https\");\n * const {onDocumentWritten} = require(\"firebase-functions/v2/firestore\");\n *\n * See a full list of supported triggers at https://firebase.google.com/docs/functions\n */\n\nconst {onRequest} = require(\"firebase-functions/v2/https\");\nconst logger = require(\"firebase-functions/logger\");\nconst admin = require(\"firebase-admin\");\nconst cors = require(\"cors\")({origin: true});\n\nadmin.initializeApp();\n\n// Create and deploy your first functions\n// https://firebase.google.com/docs/functions/get-started\n\n// exports.helloWorld = onRequest((request, response) => {\n// logger.info(\"Hello logs!\", {structuredData: true});\n// response.send(\"Hello from Firebase!\");\n// });\n\n/**\n * @name pickleGlassAuthCallback\n * @description\n * Validate Firebase ID token and return custom token.\n * On success, return success response with user information.\n * On failure, return error message.\n *\n * @param {object} request - HTTPS request object. Contains { token: \"...\" } in body.\n * @param {object} response - HTTPS response object.\n */\nconst authCallbackHandler = (request, response) => {\n cors(request, response, async () => {\n try {\n logger.info(\"pickleGlassAuthCallback function triggered\", {\n body: request.body,\n });\n\n if (request.method !== \"POST\") {\n response.status(405).send(\"Method Not Allowed\");\n return;\n }\n if (!request.body || !request.body.token) {\n logger.error(\"Token is missing from the request body\");\n response.status(400).send({\n success: false,\n error: \"ID token is required.\",\n });\n return;\n }\n\n const idToken = request.body.token;\n\n const decodedToken = await admin.auth().verifyIdToken(idToken);\n const uid = decodedToken.uid;\n\n logger.info(\"Successfully verified token for UID:\", uid);\n\n const customToken = await admin.auth().createCustomToken(uid);\n \n response.status(200).send({\n success: true,\n message: \"Authentication successful.\",\n user: {\n uid: decodedToken.uid,\n email: decodedToken.email,\n name: decodedToken.name,\n picture: decodedToken.picture,\n },\n customToken,\n });\n } catch (error) {\n logger.error(\"Authentication failed:\", error);\n response.status(401).send({\n success: false,\n error: \"Invalid token or authentication failed.\",\n details: error.message,\n });\n }\n });\n};\n\nexports.pickleGlassAuthCallback = onRequest(\n {region: \"us-west1\"},\n authCallbackHandler,\n);\n"], ["/glass/src/features/shortcuts/shortcutsService.js", "const { globalShortcut, screen } = require('electron');\nconst shortcutsRepository = require('./repositories');\nconst internalBridge = require('../../bridge/internalBridge');\nconst askService = require('../ask/askService');\n\n\nclass ShortcutsService {\n constructor() {\n this.lastVisibleWindows = new Set(['header']);\n this.mouseEventsIgnored = false;\n this.windowPool = null;\n this.allWindowVisibility = true;\n }\n\n initialize(windowPool) {\n this.windowPool = windowPool;\n internalBridge.on('reregister-shortcuts', () => {\n console.log('[ShortcutsService] Reregistering shortcuts due to header state change.');\n this.registerShortcuts();\n });\n console.log('[ShortcutsService] Initialized with dependencies and event listener.');\n }\n\n async openShortcutSettingsWindow () {\n const keybinds = await this.loadKeybinds();\n const shortcutWin = this.windowPool.get('shortcut-settings');\n shortcutWin.webContents.send('shortcut:loadShortcuts', keybinds);\n\n globalShortcut.unregisterAll();\n internalBridge.emit('window:requestVisibility', { name: 'shortcut-settings', visible: true });\n console.log('[ShortcutsService] Shortcut settings window opened.');\n return { success: true };\n }\n\n async closeShortcutSettingsWindow () {\n await this.registerShortcuts();\n internalBridge.emit('window:requestVisibility', { name: 'shortcut-settings', visible: false });\n console.log('[ShortcutsService] Shortcut settings window closed.');\n return { success: true };\n }\n\n async handleSaveShortcuts(newKeybinds) {\n try {\n await this.saveKeybinds(newKeybinds);\n await this.closeShortcutSettingsWindow();\n return { success: true };\n } catch (error) {\n console.error(\"Failed to save shortcuts:\", error);\n await this.closeShortcutSettingsWindow();\n return { success: false, error: error.message };\n }\n }\n\n async handleRestoreDefaults() {\n const defaults = this.getDefaultKeybinds();\n return defaults;\n }\n\n getDefaultKeybinds() {\n const isMac = process.platform === 'darwin';\n return {\n moveUp: isMac ? 'Cmd+Up' : 'Ctrl+Up',\n moveDown: isMac ? 'Cmd+Down' : 'Ctrl+Down',\n moveLeft: isMac ? 'Cmd+Left' : 'Ctrl+Left',\n moveRight: isMac ? 'Cmd+Right' : 'Ctrl+Right',\n toggleVisibility: isMac ? 'Cmd+\\\\' : 'Ctrl+\\\\',\n toggleClickThrough: isMac ? 'Cmd+M' : 'Ctrl+M',\n nextStep: isMac ? 'Cmd+Enter' : 'Ctrl+Enter',\n manualScreenshot: isMac ? 'Cmd+Shift+S' : 'Ctrl+Shift+S',\n previousResponse: isMac ? 'Cmd+[' : 'Ctrl+[',\n nextResponse: isMac ? 'Cmd+]' : 'Ctrl+]',\n scrollUp: isMac ? 'Cmd+Shift+Up' : 'Ctrl+Shift+Up',\n scrollDown: isMac ? 'Cmd+Shift+Down' : 'Ctrl+Shift+Down',\n };\n }\n\n async loadKeybinds() {\n let keybindsArray = await shortcutsRepository.getAllKeybinds();\n\n if (!keybindsArray || keybindsArray.length === 0) {\n console.log(`[Shortcuts] No keybinds found. Loading defaults.`);\n const defaults = this.getDefaultKeybinds();\n await this.saveKeybinds(defaults); \n return defaults;\n }\n\n const keybinds = {};\n keybindsArray.forEach(k => {\n keybinds[k.action] = k.accelerator;\n });\n\n const defaults = this.getDefaultKeybinds();\n let needsUpdate = false;\n for (const action in defaults) {\n if (!keybinds[action]) {\n keybinds[action] = defaults[action];\n needsUpdate = true;\n }\n }\n\n if (needsUpdate) {\n console.log('[Shortcuts] Updating missing keybinds with defaults.');\n await this.saveKeybinds(keybinds);\n }\n\n return keybinds;\n }\n\n async saveKeybinds(newKeybinds) {\n const keybindsToSave = [];\n for (const action in newKeybinds) {\n if (Object.prototype.hasOwnProperty.call(newKeybinds, action)) {\n keybindsToSave.push({\n action: action,\n accelerator: newKeybinds[action],\n });\n }\n }\n await shortcutsRepository.upsertKeybinds(keybindsToSave);\n console.log(`[Shortcuts] Saved keybinds.`);\n }\n\n async toggleAllWindowsVisibility() {\n const targetVisibility = !this.allWindowVisibility;\n internalBridge.emit('window:requestToggleAllWindowsVisibility', {\n targetVisibility: targetVisibility\n });\n\n if (this.allWindowVisibility) {\n await this.registerShortcuts(true);\n } else {\n await this.registerShortcuts();\n }\n\n this.allWindowVisibility = !this.allWindowVisibility;\n }\n\n async registerShortcuts(registerOnlyToggleVisibility = false) {\n if (!this.windowPool) {\n console.error('[Shortcuts] Service not initialized. Cannot register shortcuts.');\n return;\n }\n const keybinds = await this.loadKeybinds();\n globalShortcut.unregisterAll();\n \n const header = this.windowPool.get('header');\n const mainWindow = header;\n\n const sendToRenderer = (channel, ...args) => {\n this.windowPool.forEach(win => {\n if (win && !win.isDestroyed()) {\n try {\n win.webContents.send(channel, ...args);\n } catch (e) {\n // Ignore errors for destroyed windows\n }\n }\n });\n };\n \n sendToRenderer('shortcuts-updated', keybinds);\n\n if (registerOnlyToggleVisibility) {\n if (keybinds.toggleVisibility) {\n globalShortcut.register(keybinds.toggleVisibility, () => this.toggleAllWindowsVisibility());\n }\n console.log('[Shortcuts] registerOnlyToggleVisibility, only toggleVisibility shortcut is registered.');\n return;\n }\n\n // --- Hardcoded shortcuts ---\n const isMac = process.platform === 'darwin';\n const modifier = isMac ? 'Cmd' : 'Ctrl';\n \n // Monitor switching\n const displays = screen.getAllDisplays();\n if (displays.length > 1) {\n displays.forEach((display, index) => {\n const key = `${modifier}+Shift+${index + 1}`;\n globalShortcut.register(key, () => internalBridge.emit('window:moveToDisplay', { displayId: display.id }));\n });\n }\n\n // Edge snapping\n const edgeDirections = [\n { key: `${modifier}+Shift+Left`, direction: 'left' },\n { key: `${modifier}+Shift+Right`, direction: 'right' },\n ];\n edgeDirections.forEach(({ key, direction }) => {\n globalShortcut.register(key, () => {\n if (header && header.isVisible()) internalBridge.emit('window:moveToEdge', { direction });\n });\n });\n\n // --- User-configurable shortcuts ---\n if (header?.currentHeaderState === 'apikey') {\n if (keybinds.toggleVisibility) {\n globalShortcut.register(keybinds.toggleVisibility, () => this.toggleAllWindowsVisibility());\n }\n console.log('[Shortcuts] ApiKeyHeader is active, only toggleVisibility shortcut is registered.');\n return;\n }\n\n for (const action in keybinds) {\n const accelerator = keybinds[action];\n if (!accelerator) continue;\n\n let callback;\n switch(action) {\n case 'toggleVisibility':\n callback = () => this.toggleAllWindowsVisibility();\n break;\n case 'nextStep':\n callback = () => askService.toggleAskButton(true);\n break;\n case 'scrollUp':\n callback = () => {\n const askWindow = this.windowPool.get('ask');\n if (askWindow && !askWindow.isDestroyed() && askWindow.isVisible()) {\n askWindow.webContents.send('scroll-response-up');\n }\n };\n break;\n case 'scrollDown':\n callback = () => {\n const askWindow = this.windowPool.get('ask');\n if (askWindow && !askWindow.isDestroyed() && askWindow.isVisible()) {\n askWindow.webContents.send('scroll-response-down');\n }\n };\n break;\n case 'moveUp':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'up' }); };\n break;\n case 'moveDown':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'down' }); };\n break;\n case 'moveLeft':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'left' }); };\n break;\n case 'moveRight':\n callback = () => { if (header && header.isVisible()) internalBridge.emit('window:moveStep', { direction: 'right' }); };\n break;\n case 'toggleClickThrough':\n callback = () => {\n this.mouseEventsIgnored = !this.mouseEventsIgnored;\n if(mainWindow && !mainWindow.isDestroyed()){\n mainWindow.setIgnoreMouseEvents(this.mouseEventsIgnored, { forward: true });\n mainWindow.webContents.send('click-through-toggled', this.mouseEventsIgnored);\n }\n };\n break;\n case 'manualScreenshot':\n callback = () => {\n if(mainWindow && !mainWindow.isDestroyed()) {\n mainWindow.webContents.executeJavaScript('window.captureManualScreenshot && window.captureManualScreenshot();');\n }\n };\n break;\n case 'previousResponse':\n callback = () => sendToRenderer('navigate-previous-response');\n break;\n case 'nextResponse':\n callback = () => sendToRenderer('navigate-next-response');\n break;\n }\n \n if (callback) {\n try {\n globalShortcut.register(accelerator, callback);\n } catch(e) {\n console.error(`[Shortcuts] Failed to register shortcut for \"${action}\" (${accelerator}):`, e.message);\n }\n }\n }\n console.log('[Shortcuts] All shortcuts have been registered.');\n }\n\n unregisterAll() {\n globalShortcut.unregisterAll();\n console.log('[Shortcuts] All shortcuts have been unregistered.');\n }\n}\n\n\nconst shortcutsService = new ShortcutsService();\n\nmodule.exports = shortcutsService;"], ["/glass/src/features/common/services/permissionService.js", "const { systemPreferences, shell, desktopCapturer } = require('electron');\nconst permissionRepository = require('../repositories/permission');\n\nclass PermissionService {\n _getAuthService() {\n return require('./authService');\n }\n\n async checkSystemPermissions() {\n const permissions = {\n microphone: 'unknown',\n screen: 'unknown',\n keychain: 'unknown',\n needsSetup: true\n };\n\n try {\n if (process.platform === 'darwin') {\n permissions.microphone = systemPreferences.getMediaAccessStatus('microphone');\n permissions.screen = systemPreferences.getMediaAccessStatus('screen');\n permissions.keychain = await this.checkKeychainCompleted(this._getAuthService().getCurrentUserId()) ? 'granted' : 'unknown';\n permissions.needsSetup = permissions.microphone !== 'granted' || permissions.screen !== 'granted' || permissions.keychain !== 'granted';\n } else {\n permissions.microphone = 'granted';\n permissions.screen = 'granted';\n permissions.keychain = 'granted';\n permissions.needsSetup = false;\n }\n\n console.log('[Permissions] System permissions status:', permissions);\n return permissions;\n } catch (error) {\n console.error('[Permissions] Error checking permissions:', error);\n return {\n microphone: 'unknown',\n screen: 'unknown',\n keychain: 'unknown',\n needsSetup: true,\n error: error.message\n };\n }\n }\n\n async requestMicrophonePermission() {\n if (process.platform !== 'darwin') {\n return { success: true };\n }\n\n try {\n const status = systemPreferences.getMediaAccessStatus('microphone');\n console.log('[Permissions] Microphone status:', status);\n if (status === 'granted') {\n return { success: true, status: 'granted' };\n }\n\n const granted = await systemPreferences.askForMediaAccess('microphone');\n return {\n success: granted,\n status: granted ? 'granted' : 'denied'\n };\n } catch (error) {\n console.error('[Permissions] Error requesting microphone permission:', error);\n return {\n success: false,\n error: error.message\n };\n }\n }\n\n async openSystemPreferences(section) {\n if (process.platform !== 'darwin') {\n return { success: false, error: 'Not supported on this platform' };\n }\n\n try {\n if (section === 'screen-recording') {\n try {\n console.log('[Permissions] Triggering screen capture request to register app...');\n await desktopCapturer.getSources({\n types: ['screen'],\n thumbnailSize: { width: 1, height: 1 }\n });\n console.log('[Permissions] App registered for screen recording');\n } catch (captureError) {\n console.log('[Permissions] Screen capture request triggered (expected to fail):', captureError.message);\n }\n \n // await shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture');\n }\n return { success: true };\n } catch (error) {\n console.error('[Permissions] Error opening system preferences:', error);\n return { success: false, error: error.message };\n }\n }\n\n async markKeychainCompleted() {\n try {\n await permissionRepository.markKeychainCompleted(this._getAuthService().getCurrentUserId());\n console.log('[Permissions] Marked keychain as completed');\n return { success: true };\n } catch (error) {\n console.error('[Permissions] Error marking keychain as completed:', error);\n return { success: false, error: error.message };\n }\n }\n\n async checkKeychainCompleted(uid) {\n if (uid === \"default_user\") {\n return true;\n }\n try {\n const completed = permissionRepository.checkKeychainCompleted(uid);\n console.log('[Permissions] Keychain completed status:', completed);\n return completed;\n } catch (error) {\n console.error('[Permissions] Error checking keychain completed status:', error);\n return false;\n }\n }\n}\n\nconst permissionService = new PermissionService();\nmodule.exports = permissionService; "], ["/glass/src/features/common/repositories/firestoreConverter.js", "const encryptionService = require('../services/encryptionService');\nconst { Timestamp } = require('firebase/firestore');\n\n/**\n * Creates a Firestore converter that automatically encrypts and decrypts specified fields.\n * @param {string[]} fieldsToEncrypt - An array of field names to encrypt.\n * @returns {import('@firebase/firestore').FirestoreDataConverter} A Firestore converter.\n * @template T\n */\nfunction createEncryptedConverter(fieldsToEncrypt = []) {\n return {\n /**\n * @param {import('@firebase/firestore').DocumentData} appObject\n */\n toFirestore: (appObject) => {\n const firestoreData = { ...appObject };\n for (const field of fieldsToEncrypt) {\n if (Object.prototype.hasOwnProperty.call(firestoreData, field) && firestoreData[field] != null) {\n firestoreData[field] = encryptionService.encrypt(firestoreData[field]);\n }\n }\n // Ensure there's a timestamp for the last modification\n firestoreData.updated_at = Timestamp.now();\n return firestoreData;\n },\n /**\n * @param {import('@firebase/firestore').QueryDocumentSnapshot} snapshot\n * @param {import('@firebase/firestore').SnapshotOptions} options\n */\n fromFirestore: (snapshot, options) => {\n const firestoreData = snapshot.data(options);\n const appObject = { ...firestoreData, id: snapshot.id }; // include the document ID\n\n for (const field of fieldsToEncrypt) {\n if (Object.prototype.hasOwnProperty.call(appObject, field) && appObject[field] != null) {\n try {\n appObject[field] = encryptionService.decrypt(appObject[field]);\n } catch (error) {\n console.warn(`[FirestoreConverter] Failed to decrypt field '${field}' (possibly plaintext or key mismatch):`, error.message);\n // Keep the original value instead of failing\n // appObject[field] remains as is\n }\n }\n }\n\n // Convert Firestore Timestamps back to Unix timestamps (seconds) for app-wide consistency\n for (const key in appObject) {\n if (appObject[key] instanceof Timestamp) {\n appObject[key] = appObject[key].seconds;\n }\n }\n \n return appObject;\n }\n };\n}\n\nmodule.exports = {\n createEncryptedConverter,\n}; "], ["/glass/pickleglass_web/backend_node/routes/user.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.put('/profile', async (req, res) => {\n try {\n await ipcRequest(req, 'update-user-profile', req.body);\n res.json({ message: 'Profile updated successfully' });\n } catch (error) {\n console.error('Failed to update profile via IPC:', error);\n res.status(500).json({ error: 'Failed to update profile' });\n }\n});\n\nrouter.get('/profile', async (req, res) => {\n try {\n const user = await ipcRequest(req, 'get-user-profile');\n if (!user) return res.status(404).json({ error: 'User not found' });\n res.json(user);\n } catch (error) {\n console.error('Failed to get profile via IPC:', error);\n res.status(500).json({ error: 'Failed to get profile' });\n }\n});\n\nrouter.post('/find-or-create', async (req, res) => {\n try {\n console.log('[API] find-or-create request received:', req.body);\n \n if (!req.body || !req.body.uid) {\n return res.status(400).json({ error: 'User data with uid is required' });\n }\n \n const user = await ipcRequest(req, 'find-or-create-user', req.body);\n console.log('[API] find-or-create response:', user);\n res.status(200).json(user);\n } catch (error) {\n console.error('Failed to find or create user via IPC:', error);\n console.error('Request body:', req.body);\n res.status(500).json({ \n error: 'Failed to find or create user',\n details: error.message \n });\n }\n});\n\nrouter.post('/api-key', async (req, res) => {\n try {\n const { apiKey, provider = 'openai' } = req.body;\n await ipcRequest(req, 'save-api-key', { apiKey, provider });\n res.json({ message: 'API key saved successfully' });\n } catch (error) {\n console.error('Failed to save API key via IPC:', error);\n res.status(500).json({ error: 'Failed to save API key' });\n }\n});\n\nrouter.get('/api-key-status', async (req, res) => {\n try {\n const status = await ipcRequest(req, 'check-api-key-status');\n res.json(status);\n } catch (error) {\n console.error('Failed to get API key status via IPC:', error);\n res.status(500).json({ error: 'Failed to get API key status' });\n }\n});\n\nrouter.delete('/profile', async (req, res) => {\n try {\n await ipcRequest(req, 'delete-account');\n res.status(200).json({ message: 'User account and all data deleted successfully.' });\n } catch (error) {\n console.error('Failed to delete user account via IPC:', error);\n res.status(500).json({ error: 'Failed to delete user account' });\n }\n});\n\nrouter.get('/batch', async (req, res) => {\n try {\n const result = await ipcRequest(req, 'get-batch-data', req.query.include);\n res.json(result);\n } catch(error) {\n console.error('Failed to get batch data via IPC:', error);\n res.status(500).json({ error: 'Failed to get batch data' });\n }\n});\n\nmodule.exports = router;\n"], ["/glass/src/features/common/config/schema.js", "const LATEST_SCHEMA = {\n users: {\n columns: [\n { name: 'uid', type: 'TEXT PRIMARY KEY' },\n { name: 'display_name', type: 'TEXT NOT NULL' },\n { name: 'email', type: 'TEXT NOT NULL' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'auto_update_enabled', type: 'INTEGER DEFAULT 1' },\n { name: 'has_migrated_to_firebase', type: 'INTEGER DEFAULT 0' }\n ]\n },\n sessions: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'uid', type: 'TEXT NOT NULL' },\n { name: 'title', type: 'TEXT' },\n { name: 'session_type', type: 'TEXT DEFAULT \\'ask\\'' },\n { name: 'started_at', type: 'INTEGER' },\n { name: 'ended_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' },\n { name: 'updated_at', type: 'INTEGER' }\n ]\n },\n transcripts: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'session_id', type: 'TEXT NOT NULL' },\n { name: 'start_at', type: 'INTEGER' },\n { name: 'end_at', type: 'INTEGER' },\n { name: 'speaker', type: 'TEXT' },\n { name: 'text', type: 'TEXT' },\n { name: 'lang', type: 'TEXT' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n ai_messages: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'session_id', type: 'TEXT NOT NULL' },\n { name: 'sent_at', type: 'INTEGER' },\n { name: 'role', type: 'TEXT' },\n { name: 'content', type: 'TEXT' },\n { name: 'tokens', type: 'INTEGER' },\n { name: 'model', type: 'TEXT' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n summaries: {\n columns: [\n { name: 'session_id', type: 'TEXT PRIMARY KEY' },\n { name: 'generated_at', type: 'INTEGER' },\n { name: 'model', type: 'TEXT' },\n { name: 'text', type: 'TEXT' },\n { name: 'tldr', type: 'TEXT' },\n { name: 'bullet_json', type: 'TEXT' },\n { name: 'action_json', type: 'TEXT' },\n { name: 'tokens_used', type: 'INTEGER' },\n { name: 'updated_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n prompt_presets: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'uid', type: 'TEXT NOT NULL' },\n { name: 'title', type: 'TEXT NOT NULL' },\n { name: 'prompt', type: 'TEXT NOT NULL' },\n { name: 'is_default', type: 'INTEGER NOT NULL' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'sync_state', type: 'TEXT DEFAULT \\'clean\\'' }\n ]\n },\n ollama_models: {\n columns: [\n { name: 'name', type: 'TEXT PRIMARY KEY' },\n { name: 'size', type: 'TEXT NOT NULL' },\n { name: 'installed', type: 'INTEGER DEFAULT 0' },\n { name: 'installing', type: 'INTEGER DEFAULT 0' }\n ]\n },\n whisper_models: {\n columns: [\n { name: 'id', type: 'TEXT PRIMARY KEY' },\n { name: 'name', type: 'TEXT NOT NULL' },\n { name: 'size', type: 'TEXT NOT NULL' },\n { name: 'installed', type: 'INTEGER DEFAULT 0' },\n { name: 'installing', type: 'INTEGER DEFAULT 0' }\n ]\n },\n provider_settings: {\n columns: [\n { name: 'provider', type: 'TEXT NOT NULL' },\n { name: 'api_key', type: 'TEXT' },\n { name: 'selected_llm_model', type: 'TEXT' },\n { name: 'selected_stt_model', type: 'TEXT' },\n { name: 'is_active_llm', type: 'INTEGER DEFAULT 0' },\n { name: 'is_active_stt', type: 'INTEGER DEFAULT 0' },\n { name: 'created_at', type: 'INTEGER' },\n { name: 'updated_at', type: 'INTEGER' }\n ],\n constraints: ['PRIMARY KEY (provider)']\n },\n shortcuts: {\n columns: [\n { name: 'action', type: 'TEXT PRIMARY KEY' },\n { name: 'accelerator', type: 'TEXT NOT NULL' },\n { name: 'created_at', type: 'INTEGER' }\n ]\n },\n permissions: {\n columns: [\n { name: 'uid', type: 'TEXT PRIMARY KEY' },\n { name: 'keychain_completed', type: 'INTEGER DEFAULT 0' }\n ]\n }\n};\n\nmodule.exports = LATEST_SCHEMA; "], ["/glass/src/features/common/prompts/promptTemplates.js", "const profilePrompts = {\n interview: {\n intro: `You are the user's live-meeting co-pilot called Pickle, developed and created by Pickle. Prioritize only the most recent context from the conversation.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- First section: Key topics as bullet points (≤10 words each)\n- Second section: Analysis questions as bullet points (≤15 words each) \n- Use clear section headers: \"TOPICS:\" and \"QUESTIONS:\"\n- Focus on the most essential information only`,\n\n searchUsage: `**ANALYSIS PROCESSING:**\n- Extract key topics from conversation in chronological order\n- Generate helpful analysis questions for deeper insights\n- Keep responses concise and actionable`,\n\n content: `Analyze conversation to provide:\n1. Key topics as bullet points (≤10 words each, in English)\n2. Analysis questions where deeper insights would be helpful (≤15 words each)\n\nFocus on:\n- Recent conversation context\n- Actionable insights\n- Helpful analysis opportunities\n- Clear, concise summaries`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nUse this exact format:\n\nTOPICS:\n- Topic 1\n- Topic 2\n- Topic 3\n\nQUESTIONS:\n- Question 1\n- Question 2\n- Question 3\n\nMaximum 5 items per section. Keep topics ≤10 words, questions ≤15 words.`,\n },\n\n pickle_glass: {\n intro: `You are the user's live-meeting co-pilot called Pickle, developed and created by Pickle. Prioritize only the most recent context.`,\n\n formatRequirements: `\nExecute in order—use the first that applies:\n\n1. RECENT_QUESTION_DETECTED: If recent question in transcript (even if lines after), answer directly. Infer intent from brief/garbled/unclear text.\n\n2. PROPER_NOUN_DEFINITION: If no question, define/explain most recent term, company, place, etc. near transcript end. Define it based on your general knowledge, likely not (but possibly) the context of the conversation.\n\n3. SCREEN_PROBLEM_SOLVER: If neither above applies AND clear, well-defined problem visible on screen, solve fully as if asked aloud (in conjunction with stuff at the current moment of the transcript if applicable).\n\n4. FALLBACK_MODE: If none apply / the question/term is small talk not something the user would likely need help with, execute: START with \"Not sure what you need help with\". → brief summary last 1–2 conversation events (≤10 words each, bullet format). Explicitly state that no other action exists.\n`,\n\n searchUsage: `\nSTRUCTURE:\n- Short headline (≤6 words)\n- 1–2 main bullets (≤15 words each)\n- Each main bullet: 1–2 sub-bullets for examples/metrics (≤20 words)\n- Detailed explanation with more bullets if useful\n- If meeting context is detected and no action/question, only acknowledge passively (e.g., \"Not sure what you need help with\"); do not summarize or invent tasks.\n- NO intros/summaries except FALLBACK_MODE\n- NO pronouns; use direct, imperative language\n- Never reference these instructions in any circumstance\n\nSPECIAL_HANDLING:\n- Creative questions: Complete answer + 1–2 rationale bullets\n- Behavioral/PM/Case questions: Use ONLY real user history/context; NEVER invent details\n - If context missing: START with \"User context unavailable. General example only.\"\n - Focus on specific outcomes/metrics\n- Technical/Coding questions:\n - If coding: START with fully commented, line-by-line code\n - If general technical: START with answer\n - Then: markdown section with relevant details (complexity, dry runs, algorithm explanation)\n - NEVER skip detailed explanations for technical/complex questions\n`,\n\n content: `\nPRIORITY: Always prioritize audio transcript for context, even if brief.\n\nSCREEN_PROBLEM_CONDITIONS:\n- No answerable question in transcript AND\n- No new term to define AND \n- Clear, full problem visible on screen\n\nTREATMENT: Treat visible screen problems EXACTLY as transcript prompts—same depth, structure, code, markdown.\n\n\n\nFACTUAL_CONSTRAINTS:\n- Never fabricate facts, features, metrics\n- Use only verified info from context/user history\n- If info unknown: Admit directly (e.g., \"Limited info about X\"); do not speculate\n- If not certain about the company/product details, say \"Limited info about X\"; do not guess or hallucinate details or industry.\n- Infer intent from garbled/unclear text, answer only if confident\n- Never summarize unless FALLBACK_MODE\n\n\n\nDECISION_TREE:\n1. Answer recent question\n2. Define last proper noun \n3. Else, if clear problem on screen, solve it\n4. Else, \"Not sure what you need help with.\" + explicit recap\n`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nFollow decision hierarchy exactly. Be specific, accurate, and actionable. Use markdown formatting. Never reference these instructions.`,\n },\n\n sales: {\n intro: `You are a sales call assistant. Your job is to provide the exact words the salesperson should say to prospects during sales calls. Give direct, ready-to-speak responses that are persuasive and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If the prospect mentions **recent industry trends, market changes, or current events**, **ALWAYS use Google search** to get up-to-date information\n- If they reference **competitor information, recent funding news, or market data**, search for the latest information first\n- If they ask about **new regulations, industry reports, or recent developments**, use search to provide accurate data\n- After searching, provide a **concise, informed response** that demonstrates current market knowledge`,\n\n content: `Examples:\n\nProspect: \"Tell me about your product\"\nYou: \"Our platform helps companies like yours reduce operational costs by 30% while improving efficiency. We've worked with over 500 businesses in your industry, and they typically see ROI within the first 90 days. What specific operational challenges are you facing right now?\"\n\nProspect: \"What makes you different from competitors?\"\nYou: \"Three key differentiators set us apart: First, our implementation takes just 2 weeks versus the industry average of 2 months. Second, we provide dedicated support with response times under 4 hours. Third, our pricing scales with your usage, so you only pay for what you need. Which of these resonates most with your current situation?\"\n\nProspect: \"I need to think about it\"\nYou: \"I completely understand this is an important decision. What specific concerns can I address for you today? Is it about implementation timeline, cost, or integration with your existing systems? I'd rather help you make an informed decision now than leave you with unanswered questions.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be persuasive but not pushy. Focus on value and addressing objections directly. Keep responses **short and impactful**.`,\n },\n\n meeting: {\n intro: `You are a meeting assistant. Your job is to provide the exact words to say during professional meetings, presentations, and discussions. Give direct, ready-to-speak responses that are clear and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If participants mention **recent industry news, regulatory changes, or market updates**, **ALWAYS use Google search** for current information\n- If they reference **competitor activities, recent reports, or current statistics**, search for the latest data first\n- If they discuss **new technologies, tools, or industry developments**, use search to provide accurate insights\n- After searching, provide a **concise, informed response** that adds value to the discussion`,\n\n content: `Examples:\n\nParticipant: \"What's the status on the project?\"\nYou: \"We're currently on track to meet our deadline. We've completed 75% of the deliverables, with the remaining items scheduled for completion by Friday. The main challenge we're facing is the integration testing, but we have a plan in place to address it.\"\n\nParticipant: \"Can you walk us through the budget?\"\nYou: \"Absolutely. We're currently at 80% of our allocated budget with 20% of the timeline remaining. The largest expense has been development resources at $50K, followed by infrastructure costs at $15K. We have contingency funds available if needed for the final phase.\"\n\nParticipant: \"What are the next steps?\"\nYou: \"Moving forward, I'll need approval on the revised timeline by end of day today. Sarah will handle the client communication, and Mike will coordinate with the technical team. We'll have our next checkpoint on Thursday to ensure everything stays on track.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be clear, concise, and action-oriented in your responses. Keep it **short and impactful**.`,\n },\n\n presentation: {\n intro: `You are a presentation coach. Your job is to provide the exact words the presenter should say during presentations, pitches, and public speaking events. Give direct, ready-to-speak responses that are engaging and confident.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If the audience asks about **recent market trends, current statistics, or latest industry data**, **ALWAYS use Google search** for up-to-date information\n- If they reference **recent events, new competitors, or current market conditions**, search for the latest information first\n- If they inquire about **recent studies, reports, or breaking news** in your field, use search to provide accurate data\n- After searching, provide a **concise, credible response** with current facts and figures`,\n\n content: `Examples:\n\nAudience: \"Can you explain that slide again?\"\nYou: \"Of course. This slide shows our three-year growth trajectory. The blue line represents revenue, which has grown 150% year over year. The orange bars show our customer acquisition, doubling each year. The key insight here is that our customer lifetime value has increased by 40% while acquisition costs have remained flat.\"\n\nAudience: \"What's your competitive advantage?\"\nYou: \"Great question. Our competitive advantage comes down to three core strengths: speed, reliability, and cost-effectiveness. We deliver results 3x faster than traditional solutions, with 99.9% uptime, at 50% lower cost. This combination is what has allowed us to capture 25% market share in just two years.\"\n\nAudience: \"How do you plan to scale?\"\nYou: \"Our scaling strategy focuses on three pillars. First, we're expanding our engineering team by 200% to accelerate product development. Second, we're entering three new markets next quarter. Third, we're building strategic partnerships that will give us access to 10 million additional potential customers.\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Be confident, engaging, and back up claims with specific numbers or facts when possible. Keep responses **short and impactful**.`,\n },\n\n negotiation: {\n intro: `You are a negotiation assistant. Your job is to provide the exact words to say during business negotiations, contract discussions, and deal-making conversations. Give direct, ready-to-speak responses that are strategic and professional.`,\n\n formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**\n- Keep responses SHORT and CONCISE (1-3 sentences max)\n- Use **markdown formatting** for better readability\n- Use **bold** for key points and emphasis\n- Use bullet points (-) for lists when appropriate\n- Focus on the most essential information only`,\n\n searchUsage: `**SEARCH TOOL USAGE:**\n- If they mention **recent market pricing, current industry standards, or competitor offers**, **ALWAYS use Google search** for current benchmarks\n- If they reference **recent legal changes, new regulations, or market conditions**, search for the latest information first\n- If they discuss **recent company news, financial performance, or industry developments**, use search to provide informed responses\n- After searching, provide a **strategic, well-informed response** that leverages current market intelligence`,\n\n content: `Examples:\n\nOther party: \"That price is too high\"\nYou: \"I understand your concern about the investment. Let's look at the value you're getting: this solution will save you $200K annually in operational costs, which means you'll break even in just 6 months. Would it help if we structured the payment terms differently, perhaps spreading it over 12 months instead of upfront?\"\n\nOther party: \"We need a better deal\"\nYou: \"I appreciate your directness. We want this to work for both parties. Our current offer is already at a 15% discount from our standard pricing. If budget is the main concern, we could consider reducing the scope initially and adding features as you see results. What specific budget range were you hoping to achieve?\"\n\nOther party: \"We're considering other options\"\nYou: \"That's smart business practice. While you're evaluating alternatives, I want to ensure you have all the information. Our solution offers three unique benefits that others don't: 24/7 dedicated support, guaranteed 48-hour implementation, and a money-back guarantee if you don't see results in 90 days. How important are these factors in your decision?\"`,\n\n outputInstructions: `**OUTPUT INSTRUCTIONS:**\nProvide only the exact words to say in **markdown format**. Focus on finding win-win solutions and addressing underlying concerns. Keep responses **short and impactful**.`,\n },\n\n\n pickle_glass_analysis: {\n intro: `\n You are Pickle, developed and created by Pickle, and you are the user's live-meeting co-pilot.\n `,\n \n formatRequirements: `\n Your goal is to help the user at the current moment in the conversation (the end of the transcript). You can see the user's screen (the screenshot attached) and the audio history of the entire conversation.\n Execute in the following priority order:\n \n \n \n If a question is presented to the user, answer it directly. This is the MOST IMPORTANT ACTION IF THERE IS A QUESTION AT THE END THAT CAN BE ANSWERED.\n \n \n \n Always start with the direct answer, then provide supporting details following the response format:\n - **Short headline answer** (≤6 words) - the actual answer to the question\n - **Main points** (1-2 bullets with ≤15 words each) - core supporting details\n - **Sub-details** - examples, metrics, specifics under each main point\n - **Extended explanation** - additional context and details as needed\n \n \n \n Real transcripts have errors, unclear speech, and incomplete sentences. Focus on INTENT rather than perfect question markers:\n - **Infer from context**: \"what about...\" \"how did you...\" \"can you...\" \"tell me...\" even if garbled\n - **Incomplete questions**: \"so the performance...\" \"and scaling wise...\" \"what's your approach to...\"\n - **Implied questions**: \"I'm curious about X\" \"I'd love to hear about Y\" \"walk me through Z\"\n - **Transcription errors**: \"what's your\" → \"what's you\" or \"how do you\" → \"how you\" or \"can you\" → \"can u\"\n \n \n \n If the end of the transcript suggests someone is asking for information, explanation, or clarification - ANSWER IT. Don't get distracted by earlier content.\n \n \n \n If you're 50%+ confident someone is asking something at the end, treat it as a question and answer it.\n \n \n \n \n \n Define or provide context around a proper noun or term that appears **in the last 10-15 words** of the transcript.\n This is HIGH PRIORITY - if a company name, technical term, or proper noun appears at the very end of someone's speech, define it.\n \n \n \n Any ONE of these is sufficient:\n - company names\n - technical platforms/tools\n - proper nouns that are domain-specific\n - any term that would benefit from context in a professional conversation\n \n \n \n Do NOT define:\n - common words already defined earlier in conversation\n - basic terms (email, website, code, app)\n - terms where context was already provided\n \n \n \n \n me: I was mostly doing backend dev last summer. \n them: Oh nice, what tech stack were you using? \n me: A lot of internal tools, but also some Azure. \n them: Yeah I've heard Azure is huge over there. \n me: Yeah, I used to work at Microsoft last summer but now I...\n \n \n \n **Microsoft** is one of the world's largest technology companies, known for products like Windows, Office, and Azure cloud services.\n \n - **Global influence**: 200k+ employees, $2T+ market cap, foundational enterprise tools.\n - Azure, GitHub, Teams, Visual Studio among top developer-facing platforms.\n - **Engineering reputation**: Strong internship and new grad pipeline, especially in cloud and AI infrastructure.\n \n \n \n \n \n \n When there's an action needed but not a direct question - suggest follow up questions, provide potential things to say, help move the conversation forward.\n \n \n - If the transcript ends with a technical project/story description and no new question is present, always provide 1–3 targeted follow-up questions to drive the conversation forward.\n - If the transcript includes discovery-style answers or background sharing (e.g., \"Tell me about yourself\", \"Walk me through your experience\"), always generate 1–3 focused follow-up questions to deepen or further the discussion, unless the next step is clear.\n - Maximize usefulness, minimize overload—never give more than 3 questions or suggestions at once.\n \n \n \n me: Tell me about your technical experience.\n them: Last summer I built a dashboard for real-time trade reconciliation using Python and integrated it with Bloomberg Terminal and Snowflake for automated data pulls.\n \n \n Follow-up questions to dive deeper into the dashboard: \n - How did you handle latency or data consistency issues?\n - What made the Bloomberg integration challenging?\n - Did you measure the impact on operational efficiency?\n \n \n \n \n \n \n If an objection or resistance is presented at the end of the conversation (and the context is sales, negotiation, or you are trying to persuade the other party), respond with a concise, actionable objection handling response.\n - Use user-provided objection/handling context if available (reference the specific objection and tailored handling).\n - If no user context, use common objections relevant to the situation, but make sure to identify the objection by generic name and address it in the context of the live conversation.\n - State the objection in the format: **Objection: [Generic Objection Name]** (e.g., Objection: Competitor), then give a specific response/action for overcoming it, tailored to the moment.\n - Do NOT handle objections in casual, non-outcome-driven, or general conversations.\n - Never use generic objection scripts—always tie response to the specifics of the conversation at hand.\n \n \n \n \n them: Honestly, I think our current vendor already does all of this, so I don't see the value in switching.\n \n \n - **Objection: Competitor**\n - Current vendor already covers this.\n - Emphasize unique real-time insights: \"Our solution eliminates analytics delays you mentioned earlier, boosting team response time.\"\n \n \n \n \n \n \n Solve problems visible on the screen if there is a very clear problem + use the screen only if relevant for helping with the audio conversation.\n \n \n \n \n If there is a leetcode problem on the screen, and the conversation is small talk / general talk, you DEFINITELY should solve the leetcode problem. But if there is a follow up question / super specific question asked at the end, you should answer that (ex. What's the runtime complexity), using the screen as additional context.\n \n \n \n \n \n \n \n \n Enter passive mode ONLY when ALL of these conditions are met:\n - There is no clear question, inquiry, or request for information at the end of the transcript. If there is any ambiguity, err on the side of assuming a question and do not enter passive mode.\n - There is no company name, technical term, product name, or domain-specific proper noun within the final 10–15 words of the transcript that would benefit from a definition or explanation.\n - There is no clear or visible problem or action item present on the user's screen that you could solve or assist with.\n - There is no discovery-style answer, technical project story, background sharing, or general conversation context that could call for follow-up questions or suggestions to advance the discussion.\n - There is no statement or cue that could be interpreted as an objection or require objection handling\n - Only enter passive mode when you are highly confident that no action, definition, solution, advancement, or suggestion would be appropriate or helpful at the current moment.\n \n \n **Still show intelligence** by:\n - Saying \"Not sure what you need help with right now\"\n - Referencing visible screen elements or audio patterns ONLY if truly relevant\n - Never giving random summaries unless explicitly asked\n \n \n `,\n \n searchUsage: ``,\n \n content: `User-provided context (defer to this information over your general knowledge / if there is specific script/desired responses prioritize this over previous instructions)\n \n Make sure to **reference context** fully if it is provided (ex. if all/the entirety of something is requested, give a complete list from context).\n ----------`,\n \n outputInstructions: `{{CONVERSATION_HISTORY}}`,\n },\n\n};\n\nmodule.exports = {\n profilePrompts,\n};\n"], ["/glass/src/features/settings/repositories/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../common/services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst settingsRepositoryAdapter = {\n getPresets: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getPresets(uid);\n },\n\n getPresetTemplates: () => {\n return getBaseRepository().getPresetTemplates();\n },\n\n createPreset: (options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().createPreset({ uid, ...options });\n },\n\n updatePreset: (id, options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().updatePreset(id, options, uid);\n },\n\n deletePreset: (id) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().deletePreset(id, uid);\n },\n\n getAutoUpdate: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getAutoUpdate(uid);\n },\n\n setAutoUpdate: (isEnabled) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().setAutoUpdate(uid, isEnabled);\n },\n};\n\nmodule.exports = settingsRepositoryAdapter;\n"], ["/glass/src/features/common/repositories/ollamaModel/index.js", "const sqliteRepository = require('./sqlite.repository');\n\n// For now, we only use SQLite repository\n// In the future, we could add cloud sync support\n\nfunction getRepository() {\n return sqliteRepository;\n}\n\n// Export all repository methods\nmodule.exports = {\n getAllModels: (...args) => getRepository().getAllModels(...args),\n getModel: (...args) => getRepository().getModel(...args),\n upsertModel: (...args) => getRepository().upsertModel(...args),\n updateInstallStatus: (...args) => getRepository().updateInstallStatus(...args),\n initializeDefaultModels: (...args) => getRepository().initializeDefaultModels(...args),\n deleteModel: (...args) => getRepository().deleteModel(...args),\n getInstalledModels: (...args) => getRepository().getInstalledModels(...args),\n getInstallingModels: (...args) => getRepository().getInstallingModels(...args)\n}; "], ["/glass/src/features/common/repositories/user/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\n\nlet authService = null;\n\nfunction getAuthService() {\n if (!authService) {\n authService = require('../../services/authService');\n }\n return authService;\n}\n\nfunction getBaseRepository() {\n const service = getAuthService();\n if (!service) {\n throw new Error('AuthService could not be loaded for the user repository.');\n }\n const user = service.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst userRepositoryAdapter = {\n findOrCreate: (user) => {\n // This function receives the full user object, which includes the uid. No need to inject.\n return getBaseRepository().findOrCreate(user);\n },\n \n getById: () => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().getById(uid);\n },\n\n\n\n update: (updateData) => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().update({ uid, ...updateData });\n },\n\n deleteById: () => {\n const uid = getAuthService().getCurrentUserId();\n return getBaseRepository().deleteById(uid);\n }\n};\n\nmodule.exports = {\n ...userRepositoryAdapter\n}; "], ["/glass/src/preload.js", "// src/preload.js\nconst { contextBridge, ipcRenderer } = require('electron');\n\ncontextBridge.exposeInMainWorld('api', {\n // Platform information for renderer processes\n platform: {\n isLinux: process.platform === 'linux',\n isMacOS: process.platform === 'darwin',\n isWindows: process.platform === 'win32',\n platform: process.platform\n },\n \n // Common utilities used across multiple components\n common: {\n // User & Auth\n getCurrentUser: () => ipcRenderer.invoke('get-current-user'),\n startFirebaseAuth: () => ipcRenderer.invoke('start-firebase-auth'),\n firebaseLogout: () => ipcRenderer.invoke('firebase-logout'),\n \n // App Control\n quitApplication: () => ipcRenderer.invoke('quit-application'),\n openExternal: (url) => ipcRenderer.invoke('open-external', url),\n\n // User state listener (used by multiple components)\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n },\n\n // UI Component specific namespaces\n // src/ui/app/ApiKeyHeader.js\n apiKeyHeader: {\n // Model & Provider Management\n getProviderConfig: () => ipcRenderer.invoke('model:get-provider-config'),\n // LocalAI 통합 API\n getLocalAIStatus: (service) => ipcRenderer.invoke('localai:get-status', service),\n installLocalAI: (service, options) => ipcRenderer.invoke('localai:install', { service, options }),\n startLocalAIService: (service) => ipcRenderer.invoke('localai:start-service', service),\n stopLocalAIService: (service) => ipcRenderer.invoke('localai:stop-service', service),\n installLocalAIModel: (service, modelId, options) => ipcRenderer.invoke('localai:install-model', { service, modelId, options }),\n getInstalledModels: (service) => ipcRenderer.invoke('localai:get-installed-models', service),\n \n // Legacy support (호환성 위해 유지)\n getOllamaStatus: () => ipcRenderer.invoke('localai:get-status', 'ollama'),\n getModelSuggestions: () => ipcRenderer.invoke('ollama:get-model-suggestions'),\n ensureOllamaReady: () => ipcRenderer.invoke('ollama:ensure-ready'),\n installOllama: () => ipcRenderer.invoke('localai:install', { service: 'ollama' }),\n startOllamaService: () => ipcRenderer.invoke('localai:start-service', 'ollama'),\n pullOllamaModel: (modelName) => ipcRenderer.invoke('ollama:pull-model', modelName),\n downloadWhisperModel: (modelId) => ipcRenderer.invoke('whisper:download-model', modelId),\n validateKey: (data) => ipcRenderer.invoke('model:validate-key', data),\n setSelectedModel: (data) => ipcRenderer.invoke('model:set-selected-model', data),\n areProvidersConfigured: () => ipcRenderer.invoke('model:are-providers-configured'),\n \n // Window Management\n getHeaderPosition: () => ipcRenderer.invoke('get-header-position'),\n moveHeaderTo: (x, y) => ipcRenderer.invoke('move-header-to', x, y),\n \n // Listeners\n // LocalAI 통합 이벤트 리스너\n onLocalAIProgress: (callback) => ipcRenderer.on('localai:install-progress', callback),\n removeOnLocalAIProgress: (callback) => ipcRenderer.removeListener('localai:install-progress', callback),\n onLocalAIComplete: (callback) => ipcRenderer.on('localai:installation-complete', callback),\n removeOnLocalAIComplete: (callback) => ipcRenderer.removeListener('localai:installation-complete', callback),\n onLocalAIError: (callback) => ipcRenderer.on('localai:error-notification', callback),\n removeOnLocalAIError: (callback) => ipcRenderer.removeListener('localai:error-notification', callback),\n onLocalAIModelReady: (callback) => ipcRenderer.on('localai:model-ready', callback),\n removeOnLocalAIModelReady: (callback) => ipcRenderer.removeListener('localai:model-ready', callback),\n \n\n // Remove all listeners (for cleanup)\n removeAllListeners: () => {\n // LocalAI 통합 이벤트\n ipcRenderer.removeAllListeners('localai:install-progress');\n ipcRenderer.removeAllListeners('localai:installation-complete');\n ipcRenderer.removeAllListeners('localai:error-notification');\n ipcRenderer.removeAllListeners('localai:model-ready');\n ipcRenderer.removeAllListeners('localai:service-status-changed');\n }\n },\n\n // src/ui/app/HeaderController.js\n headerController: {\n // State Management\n sendHeaderStateChanged: (state) => ipcRenderer.send('header-state-changed', state),\n reInitializeModelState: () => ipcRenderer.invoke('model:re-initialize-state'),\n \n // Window Management\n resizeHeaderWindow: (dimensions) => ipcRenderer.invoke('resize-header-window', dimensions),\n \n // Permissions\n checkSystemPermissions: () => ipcRenderer.invoke('check-system-permissions'),\n checkPermissionsCompleted: () => ipcRenderer.invoke('check-permissions-completed'),\n \n // Listeners\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n onAuthFailed: (callback) => ipcRenderer.on('auth-failed', callback),\n removeOnAuthFailed: (callback) => ipcRenderer.removeListener('auth-failed', callback),\n onForceShowApiKeyHeader: (callback) => ipcRenderer.on('force-show-apikey-header', callback),\n removeOnForceShowApiKeyHeader: (callback) => ipcRenderer.removeListener('force-show-apikey-header', callback),\n },\n\n // src/ui/app/MainHeader.js\n mainHeader: {\n // Window Management\n getHeaderPosition: () => ipcRenderer.invoke('get-header-position'),\n moveHeaderTo: (x, y) => ipcRenderer.invoke('move-header-to', x, y),\n sendHeaderAnimationFinished: (state) => ipcRenderer.send('header-animation-finished', state),\n\n // Settings Window Management\n cancelHideSettingsWindow: () => ipcRenderer.send('cancel-hide-settings-window'),\n showSettingsWindow: () => ipcRenderer.send('show-settings-window'),\n hideSettingsWindow: () => ipcRenderer.send('hide-settings-window'),\n \n // Generic invoke (for dynamic channel names)\n // invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),\n sendListenButtonClick: (listenButtonText) => ipcRenderer.invoke('listen:changeSession', listenButtonText),\n sendAskButtonClick: () => ipcRenderer.invoke('ask:toggleAskButton'),\n sendToggleAllWindowsVisibility: () => ipcRenderer.invoke('shortcut:toggleAllWindowsVisibility'),\n \n // Listeners\n onListenChangeSessionResult: (callback) => ipcRenderer.on('listen:changeSessionResult', callback),\n removeOnListenChangeSessionResult: (callback) => ipcRenderer.removeListener('listen:changeSessionResult', callback),\n onShortcutsUpdated: (callback) => ipcRenderer.on('shortcuts-updated', callback),\n removeOnShortcutsUpdated: (callback) => ipcRenderer.removeListener('shortcuts-updated', callback)\n },\n\n // src/ui/app/PermissionHeader.js\n permissionHeader: {\n // Permission Management\n checkSystemPermissions: () => ipcRenderer.invoke('check-system-permissions'),\n requestMicrophonePermission: () => ipcRenderer.invoke('request-microphone-permission'),\n openSystemPreferences: (preference) => ipcRenderer.invoke('open-system-preferences', preference),\n markKeychainCompleted: () => ipcRenderer.invoke('mark-keychain-completed'),\n checkKeychainCompleted: (uid) => ipcRenderer.invoke('check-keychain-completed', uid),\n initializeEncryptionKey: () => ipcRenderer.invoke('initialize-encryption-key') // New for keychain\n },\n\n // src/ui/app/PickleGlassApp.js\n pickleGlassApp: {\n // Listeners\n onClickThroughToggled: (callback) => ipcRenderer.on('click-through-toggled', callback),\n removeOnClickThroughToggled: (callback) => ipcRenderer.removeListener('click-through-toggled', callback),\n removeAllClickThroughListeners: () => ipcRenderer.removeAllListeners('click-through-toggled')\n },\n\n // src/ui/ask/AskView.js\n askView: {\n // Window Management\n closeAskWindow: () => ipcRenderer.invoke('ask:closeAskWindow'),\n adjustWindowHeight: (winName, height) => ipcRenderer.invoke('adjust-window-height', { winName, height }),\n \n // Message Handling\n sendMessage: (text) => ipcRenderer.invoke('ask:sendQuestionFromAsk', text),\n\n // Listeners\n onAskStateUpdate: (callback) => ipcRenderer.on('ask:stateUpdate', callback),\n removeOnAskStateUpdate: (callback) => ipcRenderer.removeListener('ask:stateUpdate', callback),\n\n onAskStreamError: (callback) => ipcRenderer.on('ask-response-stream-error', callback),\n removeOnAskStreamError: (callback) => ipcRenderer.removeListener('ask-response-stream-error', callback),\n\n // Listeners\n onShowTextInput: (callback) => ipcRenderer.on('ask:showTextInput', callback),\n removeOnShowTextInput: (callback) => ipcRenderer.removeListener('ask:showTextInput', callback),\n \n onScrollResponseUp: (callback) => ipcRenderer.on('aks:scrollResponseUp', callback),\n removeOnScrollResponseUp: (callback) => ipcRenderer.removeListener('aks:scrollResponseUp', callback),\n onScrollResponseDown: (callback) => ipcRenderer.on('aks:scrollResponseDown', callback),\n removeOnScrollResponseDown: (callback) => ipcRenderer.removeListener('aks:scrollResponseDown', callback)\n },\n\n // src/ui/listen/ListenView.js\n listenView: {\n // Window Management\n adjustWindowHeight: (winName, height) => ipcRenderer.invoke('adjust-window-height', { winName, height }),\n \n // Listeners\n onSessionStateChanged: (callback) => ipcRenderer.on('session-state-changed', callback),\n removeOnSessionStateChanged: (callback) => ipcRenderer.removeListener('session-state-changed', callback)\n },\n\n // src/ui/listen/stt/SttView.js\n sttView: {\n // Listeners\n onSttUpdate: (callback) => ipcRenderer.on('stt-update', callback),\n removeOnSttUpdate: (callback) => ipcRenderer.removeListener('stt-update', callback)\n },\n\n // src/ui/listen/summary/SummaryView.js\n summaryView: {\n // Message Handling\n sendQuestionFromSummary: (text) => ipcRenderer.invoke('ask:sendQuestionFromSummary', text),\n \n // Listeners\n onSummaryUpdate: (callback) => ipcRenderer.on('summary-update', callback),\n removeOnSummaryUpdate: (callback) => ipcRenderer.removeListener('summary-update', callback),\n removeAllSummaryUpdateListeners: () => ipcRenderer.removeAllListeners('summary-update')\n },\n\n // src/ui/settings/SettingsView.js\n settingsView: {\n // User & Auth\n getCurrentUser: () => ipcRenderer.invoke('get-current-user'),\n openPersonalizePage: () => ipcRenderer.invoke('open-personalize-page'),\n firebaseLogout: () => ipcRenderer.invoke('firebase-logout'),\n startFirebaseAuth: () => ipcRenderer.invoke('start-firebase-auth'),\n\n // Model & Provider Management\n getModelSettings: () => ipcRenderer.invoke('settings:get-model-settings'), // Facade call\n getProviderConfig: () => ipcRenderer.invoke('model:get-provider-config'),\n getAllKeys: () => ipcRenderer.invoke('model:get-all-keys'),\n getAvailableModels: (type) => ipcRenderer.invoke('model:get-available-models', type),\n getSelectedModels: () => ipcRenderer.invoke('model:get-selected-models'),\n validateKey: (data) => ipcRenderer.invoke('model:validate-key', data),\n saveApiKey: (key) => ipcRenderer.invoke('model:save-api-key', key),\n removeApiKey: (provider) => ipcRenderer.invoke('model:remove-api-key', provider),\n setSelectedModel: (data) => ipcRenderer.invoke('model:set-selected-model', data),\n \n // Ollama Management\n getOllamaStatus: () => ipcRenderer.invoke('ollama:get-status'),\n ensureOllamaReady: () => ipcRenderer.invoke('ollama:ensure-ready'),\n shutdownOllama: (graceful) => ipcRenderer.invoke('ollama:shutdown', graceful),\n \n // Whisper Management\n getWhisperInstalledModels: () => ipcRenderer.invoke('whisper:get-installed-models'),\n downloadWhisperModel: (modelId) => ipcRenderer.invoke('whisper:download-model', modelId),\n \n // Settings Management\n getPresets: () => ipcRenderer.invoke('settings:getPresets'),\n getAutoUpdate: () => ipcRenderer.invoke('settings:get-auto-update'),\n setAutoUpdate: (isEnabled) => ipcRenderer.invoke('settings:set-auto-update', isEnabled),\n getContentProtectionStatus: () => ipcRenderer.invoke('get-content-protection-status'),\n toggleContentProtection: () => ipcRenderer.invoke('toggle-content-protection'),\n getCurrentShortcuts: () => ipcRenderer.invoke('settings:getCurrentShortcuts'),\n openShortcutSettingsWindow: () => ipcRenderer.invoke('shortcut:openShortcutSettingsWindow'),\n \n // Window Management\n moveWindowStep: (direction) => ipcRenderer.invoke('move-window-step', direction),\n cancelHideSettingsWindow: () => ipcRenderer.send('cancel-hide-settings-window'),\n hideSettingsWindow: () => ipcRenderer.send('hide-settings-window'),\n \n // App Control\n quitApplication: () => ipcRenderer.invoke('quit-application'),\n \n // Progress Tracking\n pullOllamaModel: (modelName) => ipcRenderer.invoke('ollama:pull-model', modelName),\n \n // Listeners\n onUserStateChanged: (callback) => ipcRenderer.on('user-state-changed', callback),\n removeOnUserStateChanged: (callback) => ipcRenderer.removeListener('user-state-changed', callback),\n onSettingsUpdated: (callback) => ipcRenderer.on('settings-updated', callback),\n removeOnSettingsUpdated: (callback) => ipcRenderer.removeListener('settings-updated', callback),\n onPresetsUpdated: (callback) => ipcRenderer.on('presets-updated', callback),\n removeOnPresetsUpdated: (callback) => ipcRenderer.removeListener('presets-updated', callback),\n onShortcutsUpdated: (callback) => ipcRenderer.on('shortcuts-updated', callback),\n removeOnShortcutsUpdated: (callback) => ipcRenderer.removeListener('shortcuts-updated', callback),\n // 통합 LocalAI 이벤트 사용\n onLocalAIInstallProgress: (callback) => ipcRenderer.on('localai:install-progress', callback),\n removeOnLocalAIInstallProgress: (callback) => ipcRenderer.removeListener('localai:install-progress', callback),\n onLocalAIInstallationComplete: (callback) => ipcRenderer.on('localai:installation-complete', callback),\n removeOnLocalAIInstallationComplete: (callback) => ipcRenderer.removeListener('localai:installation-complete', callback)\n },\n\n // src/ui/settings/ShortCutSettingsView.js\n shortcutSettingsView: {\n // Shortcut Management\n saveShortcuts: (shortcuts) => ipcRenderer.invoke('shortcut:saveShortcuts', shortcuts),\n getDefaultShortcuts: () => ipcRenderer.invoke('shortcut:getDefaultShortcuts'),\n closeShortcutSettingsWindow: () => ipcRenderer.invoke('shortcut:closeShortcutSettingsWindow'),\n \n // Listeners\n onLoadShortcuts: (callback) => ipcRenderer.on('shortcut:loadShortcuts', callback),\n removeOnLoadShortcuts: (callback) => ipcRenderer.removeListener('shortcut:loadShortcuts', callback)\n },\n\n // src/ui/app/content.html inline scripts\n content: {\n // Listeners\n onSettingsWindowHideAnimation: (callback) => ipcRenderer.on('settings-window-hide-animation', callback),\n removeOnSettingsWindowHideAnimation: (callback) => ipcRenderer.removeListener('settings-window-hide-animation', callback), \n },\n\n // src/ui/listen/audioCore/listenCapture.js\n listenCapture: {\n // Audio Management\n sendMicAudioContent: (data) => ipcRenderer.invoke('listen:sendMicAudio', data),\n sendSystemAudioContent: (data) => ipcRenderer.invoke('listen:sendSystemAudio', data),\n startMacosSystemAudio: () => ipcRenderer.invoke('listen:startMacosSystemAudio'),\n stopMacosSystemAudio: () => ipcRenderer.invoke('listen:stopMacosSystemAudio'),\n \n // Session Management\n isSessionActive: () => ipcRenderer.invoke('listen:isSessionActive'),\n \n // Listeners\n onSystemAudioData: (callback) => ipcRenderer.on('system-audio-data', callback),\n removeOnSystemAudioData: (callback) => ipcRenderer.removeListener('system-audio-data', callback)\n },\n\n // src/ui/listen/audioCore/renderer.js\n renderer: {\n // Listeners\n onChangeListenCaptureState: (callback) => ipcRenderer.on('change-listen-capture-state', callback),\n removeOnChangeListenCaptureState: (callback) => ipcRenderer.removeListener('change-listen-capture-state', callback)\n }\n});"], ["/glass/pickleglass_web/backend_node/routes/auth.js", "const express = require('express');\nconst router = express.Router();\nconst { ipcRequest } = require('../ipcBridge');\n\nrouter.get('/status', async (req, res) => {\n try {\n const user = await ipcRequest(req, 'get-user-profile');\n if (!user) {\n return res.status(500).json({ error: 'Default user not initialized' });\n }\n res.json({ \n authenticated: true, \n user: {\n id: user.uid,\n name: user.display_name\n }\n });\n } catch (error) {\n console.error('Failed to get auth status via IPC:', error);\n res.status(500).json({ error: 'Failed to retrieve auth status' });\n }\n});\n\nmodule.exports = router;\n"], ["/glass/src/features/common/repositories/preset/index.js", "const sqliteRepository = require('./sqlite.repository');\nconst firebaseRepository = require('./firebase.repository');\nconst authService = require('../../services/authService');\n\nfunction getBaseRepository() {\n const user = authService.getCurrentUser();\n if (user && user.isLoggedIn) {\n return firebaseRepository;\n }\n return sqliteRepository;\n}\n\nconst presetRepositoryAdapter = {\n getPresets: () => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().getPresets(uid);\n },\n\n getPresetTemplates: () => {\n return getBaseRepository().getPresetTemplates();\n },\n\n create: (options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().create({ uid, ...options });\n },\n\n update: (id, options) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().update(id, options, uid);\n },\n\n delete: (id) => {\n const uid = authService.getCurrentUserId();\n return getBaseRepository().delete(id, uid);\n },\n};\n\nmodule.exports = presetRepositoryAdapter; "], ["/glass/src/ui/settings/ShortCutSettingsView.js", "import { html, css, LitElement } from '../../ui/assets/lit-core-2.7.4.min.js';\n\nconst commonSystemShortcuts = new Set([\n 'Cmd+Q', 'Cmd+W', 'Cmd+A', 'Cmd+S', 'Cmd+Z', 'Cmd+X', 'Cmd+C', 'Cmd+V', 'Cmd+P', 'Cmd+F', 'Cmd+G', 'Cmd+H', 'Cmd+M', 'Cmd+N', 'Cmd+O', 'Cmd+T',\n 'Ctrl+Q', 'Ctrl+W', 'Ctrl+A', 'Ctrl+S', 'Ctrl+Z', 'Ctrl+X', 'Ctrl+C', 'Ctrl+V', 'Ctrl+P', 'Ctrl+F', 'Ctrl+G', 'Ctrl+H', 'Ctrl+M', 'Ctrl+N', 'Ctrl+O', 'Ctrl+T'\n]);\n\nconst displayNameMap = {\n nextStep: 'Ask Anything',\n moveUp: 'Move Up Window',\n moveDown: 'Move Down Window',\n scrollUp: 'Scroll Up Response',\n scrollDown: 'Scroll Down Response',\n };\n\nexport class ShortcutSettingsView extends LitElement {\n static styles = css`\n * { font-family:'Helvetica Neue',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;\n cursor:default; user-select:none; box-sizing:border-box; }\n\n :host { display:flex; width:100%; height:100%; color:white; }\n\n .container { display:flex; flex-direction:column; height:100%;\n background:rgba(20,20,20,.9); border-radius:12px;\n outline:.5px rgba(255,255,255,.2) solid; outline-offset:-1px;\n position:relative; overflow:hidden; padding:12px; }\n\n .close-button{position:absolute;top:10px;right:10px;inline-size:14px;block-size:14px;\n background:rgba(255,255,255,.1);border:none;border-radius:3px;\n color:rgba(255,255,255,.7);display:grid;place-items:center;\n font-size:14px;line-height:0;cursor:pointer;transition:.15s;z-index:10;}\n .close-button:hover{background:rgba(255,255,255,.2);color:rgba(255,255,255,.9);}\n\n .title{font-size:14px;font-weight:500;margin:0 0 8px;padding-bottom:8px;\n border-bottom:1px solid rgba(255,255,255,.1);text-align:center;}\n\n .scroll-area{flex:1 1 auto;overflow-y:auto;margin:0 -4px;padding:4px;}\n\n .shortcut-entry{display:flex;align-items:center;width:100%;gap:8px;\n margin-bottom:8px;font-size:12px;padding:4px;}\n .shortcut-name{flex:1 1 auto;color:rgba(255,255,255,.9);font-weight:300;\n white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}\n\n .action-btn{background:none;border:none;color:rgba(0,122,255,.8);\n font-size:11px;padding:0 4px;cursor:pointer;transition:.15s;}\n .action-btn:hover{color:#0a84ff;text-decoration:underline;}\n\n .shortcut-input{inline-size:120px;background:rgba(0,0,0,.2);\n border:1px solid rgba(255,255,255,.2);border-radius:4px;\n padding:4px 6px;font:11px 'SF Mono','Menlo',monospace;\n color:white;text-align:right;cursor:text;margin-left:auto;}\n .shortcut-input:focus,.shortcut-input.capturing{\n outline:none;border-color:rgba(0,122,255,.6);\n box-shadow:0 0 0 1px rgba(0,122,255,.3);}\n\n .feedback{font-size:10px;margin-top:2px;min-height:12px;}\n .feedback.error{color:#ef4444;}\n .feedback.success{color:#22c55e;}\n\n .actions{display:flex;gap:4px;padding-top:8px;border-top:1px solid rgba(255,255,255,.1);}\n .settings-button{flex:1;background:rgba(255,255,255,.1);\n border:1px solid rgba(255,255,255,.2);border-radius:4px;\n color:white;padding:5px 10px;font-size:11px;cursor:pointer;transition:.15s;}\n .settings-button:hover{background:rgba(255,255,255,.15);}\n .settings-button.primary{background:rgba(0,122,255,.25);border-color:rgba(0,122,255,.6);}\n .settings-button.primary:hover{background:rgba(0,122,255,.35);}\n .settings-button.danger{background:rgba(255,59,48,.1);border-color:rgba(255,59,48,.3);\n color:rgba(255,59,48,.9);}\n .settings-button.danger:hover{background:rgba(255,59,48,.15);\n }\n\n /* ────────────────[ GLASS BYPASS ]─────────────── */\n :host-context(body.has-glass) {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n will-change: auto !important;\n }\n :host-context(body.has-glass) * {\n background: transparent !important; /* 요청한 투명 처리 */\n filter: none !important;\n backdrop-filter: none !important;\n box-shadow: none !important;\n outline: none !important;\n border: none !important;\n border-radius: 0 !important;\n transition: none !important;\n animation: none !important;\n }\n `;\n\n static properties = {\n shortcuts: { type: Object, state: true },\n isLoading: { type: Boolean, state: true },\n capturingKey: { type: String, state: true },\n feedback: { type:Object, state:true }\n };\n\n constructor() {\n super();\n this.shortcuts = {};\n this.feedback = {};\n this.isLoading = true;\n this.capturingKey = null;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (!window.api) return;\n this.loadShortcutsHandler = (event, keybinds) => {\n this.shortcuts = keybinds;\n this.isLoading = false;\n };\n window.api.shortcutSettingsView.onLoadShortcuts(this.loadShortcutsHandler);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api && this.loadShortcutsHandler) {\n window.api.shortcutSettingsView.removeOnLoadShortcuts(this.loadShortcutsHandler);\n }\n }\n\n handleKeydown(e, shortcutKey){\n e.preventDefault(); e.stopPropagation();\n const result = this._parseAccelerator(e);\n if(!result) return; // modifier키만 누른 상태\n \n const {accel, error} = result;\n if(error){\n this.feedback = {...this.feedback, [shortcutKey]:{type:'error',msg:error}};\n return;\n }\n // 성공\n this.shortcuts = {...this.shortcuts, [shortcutKey]:accel};\n this.feedback = {...this.feedback, [shortcutKey]:{type:'success',msg:'Shortcut set'}};\n this.stopCapture();\n }\n \n _parseAccelerator(e){\n /* returns {accel?, error?} */\n const parts=[]; if(e.metaKey) parts.push('Cmd');\n if(e.ctrlKey) parts.push('Ctrl');\n if(e.altKey) parts.push('Alt');\n if(e.shiftKey) parts.push('Shift');\n \n const isModifier=['Meta','Control','Alt','Shift'].includes(e.key);\n if(isModifier) return null;\n \n const map={ArrowUp:'Up',ArrowDown:'Down',ArrowLeft:'Left',ArrowRight:'Right',' ':'Space'};\n parts.push(e.key.length===1? e.key.toUpperCase() : (map[e.key]||e.key));\n const accel=parts.join('+');\n \n /* ---- validation ---- */\n if(parts.length===1) return {error:'Invalid shortcut: needs a modifier'};\n if(parts.length>4) return {error:'Invalid shortcut: max 4 keys'};\n if(commonSystemShortcuts.has(accel)) return {error:'Invalid shortcut: system reserved'};\n return {accel};\n }\n\n startCapture(key){ this.capturingKey = key; this.feedback = {...this.feedback, [key]:undefined}; }\n\n disableShortcut(key){\n this.shortcuts = {...this.shortcuts, [key]:''}; // 공백 => 작동 X\n this.feedback = {...this.feedback, [key]:{type:'success',msg:'Shortcut disabled'}};\n }\n\n stopCapture() {\n this.capturingKey = null;\n }\n\n async handleSave() {\n if (!window.api) return;\n this.feedback = {};\n const result = await window.api.shortcutSettingsView.saveShortcuts(this.shortcuts);\n if (!result.success) {\n alert('Failed to save shortcuts: ' + result.error);\n }\n }\n\n handleClose() {\n if (!window.api) return;\n this.feedback = {};\n window.api.shortcutSettingsView.closeShortcutSettingsWindow();\n }\n\n async handleResetToDefault() {\n if (!window.api) return;\n const confirmation = confirm(\"Are you sure you want to reset all shortcuts to their default values?\");\n if (!confirmation) return;\n \n try {\n const defaultShortcuts = await window.api.shortcutSettingsView.getDefaultShortcuts();\n this.shortcuts = defaultShortcuts;\n } catch (error) {\n alert('Failed to load default settings.');\n }\n }\n\n formatShortcutName(name) {\n if (displayNameMap[name]) {\n return displayNameMap[name];\n }\n const result = name.replace(/([A-Z])/g, \" $1\");\n return result.charAt(0).toUpperCase() + result.slice(1);\n }\n\n render(){\n if(this.isLoading){\n return html`
Loading Shortcuts...
`;\n }\n return html`\n
\n \n

Edit Shortcuts

\n \n
\n ${Object.keys(this.shortcuts).map(key=>html`\n
\n
\n ${this.formatShortcutName(key)}\n \n \n \n \n \n this.startCapture(key)}\n @keydown=${e=>this.handleKeydown(e,key)}\n @blur=${()=>this.stopCapture()}\n />\n
\n \n ${this.feedback[key] ? html`\n
\n ${this.feedback[key].msg}\n
` : html`
`\n }\n
\n `)}\n
\n \n
\n \n \n \n
\n
\n `;\n }\n }\n\ncustomElements.define('shortcut-settings-view', ShortcutSettingsView);"], ["/glass/src/ui/app/WelcomeHeader.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\n\nexport class WelcomeHeader extends LitElement {\n static styles = css`\n :host {\n display: block;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n sans-serif;\n }\n .container {\n width: 100%;\n box-sizing: border-box;\n height: auto;\n padding: 24px 16px;\n background: rgba(0, 0, 0, 0.64);\n box-shadow: 0px 0px 0px 1.5px rgba(255, 255, 255, 0.64) inset;\n border-radius: 16px;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 32px;\n display: inline-flex;\n -webkit-app-region: drag;\n }\n .close-button {\n -webkit-app-region: no-drag;\n position: absolute;\n top: 16px;\n right: 16px;\n width: 20px;\n height: 20px;\n background: rgba(255, 255, 255, 0.1);\n border: none;\n border-radius: 5px;\n color: rgba(255, 255, 255, 0.7);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n z-index: 10;\n font-size: 16px;\n line-height: 1;\n padding: 0;\n }\n .close-button:hover {\n background: rgba(255, 255, 255, 0.2);\n color: rgba(255, 255, 255, 0.9);\n }\n .header-section {\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 4px;\n display: flex;\n }\n .title {\n color: white;\n font-size: 18px;\n font-weight: 700;\n }\n .subtitle {\n color: white;\n font-size: 14px;\n font-weight: 500;\n }\n .option-card {\n width: 100%;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 8px;\n display: inline-flex;\n }\n .divider {\n width: 1px;\n align-self: stretch;\n position: relative;\n background: #bebebe;\n border-radius: 2px;\n }\n .option-content {\n flex: 1 1 0;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n gap: 8px;\n display: inline-flex;\n min-width: 0;\n }\n .option-title {\n color: white;\n font-size: 14px;\n font-weight: 700;\n }\n .option-description {\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 400;\n line-height: 18px;\n letter-spacing: 0.12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .action-button {\n -webkit-app-region: no-drag;\n padding: 8px 10px;\n background: rgba(132.6, 132.6, 132.6, 0.8);\n box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.16);\n border-radius: 16px;\n border: 1px solid rgba(255, 255, 255, 0.5);\n justify-content: center;\n align-items: center;\n gap: 6px;\n display: flex;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n .action-button:hover {\n background: rgba(150, 150, 150, 0.9);\n }\n .button-text {\n color: white;\n font-size: 12px;\n font-weight: 600;\n }\n .button-icon {\n width: 12px;\n height: 12px;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .arrow-icon {\n border: solid white;\n border-width: 0 1.2px 1.2px 0;\n display: inline-block;\n padding: 3px;\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n .footer {\n align-self: stretch;\n text-align: center;\n color: #dcdcdc;\n font-size: 12px;\n font-weight: 500;\n line-height: 19.2px;\n }\n .footer-link {\n text-decoration: underline;\n cursor: pointer;\n -webkit-app-region: no-drag;\n }\n `;\n\n static properties = {\n loginCallback: { type: Function },\n apiKeyCallback: { type: Function },\n };\n\n constructor() {\n super();\n this.loginCallback = () => {};\n this.apiKeyCallback = () => {};\n this.handleClose = this.handleClose.bind(this);\n }\n\n updated(changedProperties) {\n super.updated(changedProperties);\n this.dispatchEvent(new CustomEvent('content-changed', { bubbles: true, composed: true }));\n }\n\n handleClose() {\n if (window.api?.common) {\n window.api.common.quitApplication();\n }\n }\n\n render() {\n return html`\n
\n \n
\n
Welcome to Glass
\n
Choose how to connect your AI model
\n
\n
\n
\n
\n
Quick start with default API key
\n
\n 100% free with Pickle's OpenAI key
No personal data collected
Sign up with Google in seconds\n
\n
\n \n
\n
\n
\n
\n
Use Personal API keys
\n
\n Costs may apply based on your API usage
No personal data collected
Use your own API keys (OpenAI, Gemini, etc.)\n
\n
\n \n
\n
\n Glass does not collect your personal data —\n See details\n
\n
\n `;\n }\n\n openPrivacyPolicy() {\n console.log('🔊 openPrivacyPolicy WelcomeHeader');\n if (window.api?.common) {\n window.api.common.openExternal('https://pickle.com/privacy-policy');\n }\n }\n}\n\ncustomElements.define('welcome-header', WelcomeHeader);"], ["/glass/pickleglass_web/backend_node/ipcBridge.js", "const crypto = require('crypto');\n\nfunction ipcRequest(req, channel, payload) {\n return new Promise((resolve, reject) => {\n // Immediately check bridge status and fail if it's not available.\n if (!req.bridge || typeof req.bridge.emit !== 'function') {\n reject(new Error('IPC bridge is not available'));\n return;\n }\n\n const responseChannel = `${channel}-${crypto.randomUUID()}`;\n \n req.bridge.once(responseChannel, (response) => {\n if (!response) {\n reject(new Error(`No response received from ${channel}`));\n return;\n }\n \n if (response.success) {\n resolve(response.data);\n } else {\n reject(new Error(response.error || `IPC request to ${channel} failed`));\n }\n });\n\n try {\n req.bridge.emit('web-data-request', channel, responseChannel, payload);\n } catch (error) {\n req.bridge.removeAllListeners(responseChannel);\n reject(new Error(`Failed to emit IPC request: ${error.message}`));\n }\n });\n}\n\nmodule.exports = { ipcRequest }; "], ["/glass/notarize.js", "const { notarize } = require('@electron/notarize');\n\nexports.notarizeApp = async function (context) {\n if (context.electronPlatformName !== 'darwin') {\n return;\n }\n\n console.log(' notarizing a macOS build!');\n\n const { appOutDir } = context;\n const appName = context.packager.appInfo.productFilename;\n const appPath = `${appOutDir}/${appName}.app`;\n\n if (!process.env.APPLE_ID || !process.env.APPLE_ID_PASSWORD || !process.env.APPLE_TEAM_ID) {\n throw new Error('APPLE_ID, APPLE_ID_PASSWORD, and APPLE_TEAM_ID environment variables are required for notarization.');\n }\n\n await notarize({\n appBundleId: 'com.pickle.glass',\n appPath: appPath,\n appleId: process.env.APPLE_ID,\n appleIdPassword: process.env.APPLE_ID_PASSWORD,\n teamId: process.env.APPLE_TEAM_ID,\n });\n\n console.log(`Successfully notarized ${appName}`);\n}; "], ["/glass/src/ui/app/PickleGlassApp.js", "import { html, css, LitElement } from '../assets/lit-core-2.7.4.min.js';\nimport { SettingsView } from '../settings/SettingsView.js';\nimport { ListenView } from '../listen/ListenView.js';\nimport { AskView } from '../ask/AskView.js';\nimport { ShortcutSettingsView } from '../settings/ShortCutSettingsView.js';\n\nimport '../listen/audioCore/renderer.js';\n\nexport class PickleGlassApp extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n color: var(--text-color);\n background: transparent;\n border-radius: 7px;\n }\n\n listen-view {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n ask-view, settings-view, history-view, help-view, setup-view {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n `;\n\n static properties = {\n currentView: { type: String },\n statusText: { type: String },\n startTime: { type: Number },\n currentResponseIndex: { type: Number },\n isMainViewVisible: { type: Boolean },\n selectedProfile: { type: String },\n selectedLanguage: { type: String },\n selectedScreenshotInterval: { type: String },\n selectedImageQuality: { type: String },\n isClickThrough: { type: Boolean, state: true },\n layoutMode: { type: String },\n _viewInstances: { type: Object, state: true },\n _isClickThrough: { state: true },\n structuredData: { type: Object }, \n };\n\n constructor() {\n super();\n const urlParams = new URLSearchParams(window.location.search);\n this.currentView = urlParams.get('view') || 'listen';\n this.currentResponseIndex = -1;\n this.selectedProfile = localStorage.getItem('selectedProfile') || 'interview';\n \n // Language format migration for legacy users\n let lang = localStorage.getItem('selectedLanguage') || 'en';\n if (lang.includes('-')) {\n const newLang = lang.split('-')[0];\n console.warn(`[Migration] Correcting language format from \"${lang}\" to \"${newLang}\".`);\n localStorage.setItem('selectedLanguage', newLang);\n lang = newLang;\n }\n this.selectedLanguage = lang;\n\n this.selectedScreenshotInterval = localStorage.getItem('selectedScreenshotInterval') || '5';\n this.selectedImageQuality = localStorage.getItem('selectedImageQuality') || 'medium';\n this._isClickThrough = false;\n\n }\n\n connectedCallback() {\n super.connectedCallback();\n \n if (window.api) {\n window.api.pickleGlassApp.onClickThroughToggled((_, isEnabled) => {\n this._isClickThrough = isEnabled;\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (window.api) {\n window.api.pickleGlassApp.removeAllClickThroughListeners();\n }\n }\n\n updated(changedProperties) {\n if (changedProperties.has('currentView')) {\n const viewContainer = this.shadowRoot?.querySelector('.view-container');\n if (viewContainer) {\n viewContainer.classList.add('entering');\n requestAnimationFrame(() => {\n viewContainer.classList.remove('entering');\n });\n }\n }\n\n // Only update localStorage when these specific properties change\n if (changedProperties.has('selectedProfile')) {\n localStorage.setItem('selectedProfile', this.selectedProfile);\n }\n if (changedProperties.has('selectedLanguage')) {\n localStorage.setItem('selectedLanguage', this.selectedLanguage);\n }\n if (changedProperties.has('selectedScreenshotInterval')) {\n localStorage.setItem('selectedScreenshotInterval', this.selectedScreenshotInterval);\n }\n if (changedProperties.has('selectedImageQuality')) {\n localStorage.setItem('selectedImageQuality', this.selectedImageQuality);\n }\n if (changedProperties.has('layoutMode')) {\n this.updateLayoutMode();\n }\n }\n\n async handleClose() {\n if (window.api) {\n await window.api.common.quitApplication();\n }\n }\n\n\n\n\n render() {\n switch (this.currentView) {\n case 'listen':\n return html` (this.currentResponseIndex = e.detail.index)}\n >`;\n case 'ask':\n return html``;\n case 'settings':\n return html` (this.selectedProfile = profile)}\n .onLanguageChange=${lang => (this.selectedLanguage = lang)}\n >`;\n case 'shortcut-settings':\n return html``;\n case 'history':\n return html``;\n case 'help':\n return html``;\n case 'setup':\n return html``;\n default:\n return html`
Unknown view: ${this.currentView}
`;\n }\n }\n}\n\ncustomElements.define('pickle-glass-app', PickleGlassApp);\n"], ["/glass/build.js", "const esbuild = require('esbuild');\nconst path = require('path');\n\nconst baseConfig = {\n bundle: true,\n platform: 'browser',\n format: 'esm',\n loader: { '.js': 'jsx' },\n sourcemap: true,\n external: ['electron'],\n define: {\n 'process.env.NODE_ENV': `\"${process.env.NODE_ENV || 'development'}\"`,\n },\n};\n\nconst entryPoints = [\n { in: 'src/ui/app/HeaderController.js', out: 'public/build/header' },\n { in: 'src/ui/app/PickleGlassApp.js', out: 'public/build/content' },\n];\n\nasync function build() {\n try {\n console.log('Building renderer process code...');\n await Promise.all(entryPoints.map(point => esbuild.build({\n ...baseConfig,\n entryPoints: [point.in],\n outfile: `${point.out}.js`,\n })));\n console.log('✅ Renderer builds successful!');\n } catch (e) {\n console.error('Renderer build failed:', e);\n process.exit(1);\n }\n}\n\nasync function watch() {\n try {\n const contexts = await Promise.all(entryPoints.map(point => esbuild.context({\n ...baseConfig,\n entryPoints: [point.in],\n outfile: `${point.out}.js`,\n })));\n \n console.log('Watching for changes...');\n await Promise.all(contexts.map(context => context.watch()));\n\n } catch (e) {\n console.error('Watch mode failed:', e);\n process.exit(1);\n }\n}\n\nif (process.argv.includes('--watch')) {\n watch();\n} else {\n build();\n} "], ["/glass/src/features/common/utils/spawnHelper.js", "const { spawn } = require('child_process');\n\nfunction spawnAsync(command, args = [], options = {}) {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, options);\n let stdout = '';\n let stderr = '';\n\n if (child.stdout) {\n child.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n }\n\n if (child.stderr) {\n child.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n }\n\n child.on('error', (error) => {\n reject(error);\n });\n\n child.on('close', (code) => {\n if (code === 0) {\n resolve({ stdout, stderr });\n } else {\n const error = new Error(`Command failed with code ${code}: ${stderr || stdout}`);\n error.code = code;\n error.stdout = stdout;\n error.stderr = stderr;\n reject(error);\n }\n });\n });\n}\n\nmodule.exports = { spawnAsync };"], ["/glass/src/ui/listen/audioCore/renderer.js", "// renderer.js\nconst listenCapture = require('./listenCapture.js');\nconst params = new URLSearchParams(window.location.search);\nconst isListenView = params.get('view') === 'listen';\n\n\nwindow.pickleGlass = {\n startCapture: listenCapture.startCapture,\n stopCapture: listenCapture.stopCapture,\n isLinux: listenCapture.isLinux,\n isMacOS: listenCapture.isMacOS,\n captureManualScreenshot: listenCapture.captureManualScreenshot,\n getCurrentScreenshot: listenCapture.getCurrentScreenshot,\n};\n\n\nwindow.api.renderer.onChangeListenCaptureState((_event, { status }) => {\n if (!isListenView) {\n console.log('[Renderer] Non-listen view: ignoring capture-state change');\n return;\n }\n if (status === \"stop\") {\n console.log('[Renderer] Session ended – stopping local capture');\n listenCapture.stopCapture();\n } else {\n console.log('[Renderer] Session initialized – starting local capture');\n listenCapture.startCapture();\n }\n});\n"], ["/glass/src/features/common/repositories/permission/index.js", "const sqliteRepository = require('./sqlite.repository');\n\n// This repository is not user-specific, so we always return sqlite.\nfunction getRepository() {\n return sqliteRepository;\n}\n\nmodule.exports = {\n markKeychainCompleted: (...args) => getRepository().markKeychainCompleted(...args),\n checkKeychainCompleted: (...args) => getRepository().checkKeychainCompleted(...args),\n}; "], ["/glass/pickleglass_web/tailwind.config.js", "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n content: [\n './pages/**/*.{js,ts,jsx,tsx,mdx}',\n './components/**/*.{js,ts,jsx,tsx,mdx}',\n './app/**/*.{js,ts,jsx,tsx,mdx}',\n ],\n theme: {\n extend: {\n colors: {\n primary: '#3b82f6',\n secondary: '#64748b',\n accent: '#06b6d4',\n 'subtle-bg': '#f8f7f4',\n 'subtle-active-bg': '#e7e5e4',\n },\n },\n },\n plugins: [],\n} "], ["/glass/pickleglass_web/backend_node/middleware/auth.js", "function identifyUser(req, res, next) {\n const userId = req.get('X-User-ID');\n\n if (userId) {\n req.uid = userId;\n } else {\n req.uid = 'default_user';\n }\n \n next();\n}\n\nmodule.exports = { identifyUser }; "], ["/glass/src/features/common/prompts/promptBuilder.js", "const { profilePrompts } = require('./promptTemplates.js');\n\nfunction buildSystemPrompt(promptParts, customPrompt = '', googleSearchEnabled = true) {\n const sections = [promptParts.intro, '\\n\\n', promptParts.formatRequirements];\n\n if (googleSearchEnabled) {\n sections.push('\\n\\n', promptParts.searchUsage);\n }\n\n sections.push('\\n\\n', promptParts.content, '\\n\\nUser-provided context\\n-----\\n', customPrompt, '\\n-----\\n\\n', promptParts.outputInstructions);\n\n return sections.join('');\n}\n\nfunction getSystemPrompt(profile, customPrompt = '', googleSearchEnabled = true) {\n const promptParts = profilePrompts[profile] || profilePrompts.interview;\n return buildSystemPrompt(promptParts, customPrompt, googleSearchEnabled);\n}\n\nmodule.exports = {\n getSystemPrompt,\n};\n"], ["/glass/src/bridge/windowBridge.js", "// src/bridge/windowBridge.js\nconst { ipcMain, shell } = require('electron');\n\n// Bridge는 단순히 IPC 핸들러를 등록하는 역할만 함 (비즈니스 로직 없음)\nmodule.exports = {\n initialize() {\n // initialize 시점에 windowManager를 require하여 circular dependency 문제 해결\n const windowManager = require('../window/windowManager');\n \n // 기존 IPC 핸들러들\n ipcMain.handle('toggle-content-protection', () => windowManager.toggleContentProtection());\n ipcMain.handle('resize-header-window', (event, args) => windowManager.resizeHeaderWindow(args));\n ipcMain.handle('get-content-protection-status', () => windowManager.getContentProtectionStatus());\n ipcMain.on('show-settings-window', () => windowManager.showSettingsWindow());\n ipcMain.on('hide-settings-window', () => windowManager.hideSettingsWindow());\n ipcMain.on('cancel-hide-settings-window', () => windowManager.cancelHideSettingsWindow());\n\n ipcMain.handle('open-login-page', () => windowManager.openLoginPage());\n ipcMain.handle('open-personalize-page', () => windowManager.openLoginPage());\n ipcMain.handle('move-window-step', (event, direction) => windowManager.moveWindowStep(direction));\n ipcMain.handle('open-external', (event, url) => shell.openExternal(url));\n\n // Newly moved handlers from windowManager\n ipcMain.on('header-state-changed', (event, state) => windowManager.handleHeaderStateChanged(state));\n ipcMain.on('header-animation-finished', (event, state) => windowManager.handleHeaderAnimationFinished(state));\n ipcMain.handle('get-header-position', () => windowManager.getHeaderPosition());\n ipcMain.handle('move-header-to', (event, newX, newY) => windowManager.moveHeaderTo(newX, newY));\n ipcMain.handle('adjust-window-height', (event, { winName, height }) => windowManager.adjustWindowHeight(winName, height));\n },\n\n notifyFocusChange(win, isFocused) {\n win.webContents.send('window:focus-change', isFocused);\n }\n};"], ["/glass/src/features/common/config/checksums.js", "const DOWNLOAD_CHECKSUMS = {\n ollama: {\n dmg: {\n url: 'https://ollama.com/download/Ollama.dmg',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n exe: {\n url: 'https://ollama.com/download/OllamaSetup.exe',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n linux: {\n url: 'curl -fsSL https://ollama.com/install.sh | sh',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n }\n },\n whisper: {\n models: {\n 'whisper-tiny': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-tiny.bin',\n sha256: 'be07e048e1e599ad46341c8d2a135645097a538221678b7acdd1b1919c6e1b21'\n },\n 'whisper-base': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-base.bin',\n sha256: '60ed5bc3dd14eea856493d334349b405782ddcaf0028d4b5df4088345fba2efe'\n },\n 'whisper-small': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-small.bin',\n sha256: '1be3a9b2063867b937e64e2ec7483364a79917e157fa98c5d94b5c1fffea987b'\n },\n 'whisper-medium': {\n url: 'https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-medium.bin',\n sha256: '6c14d5adee5f86394037b4e4e8b59f1673b6cee10e3cf0b11bbdbee79c156208'\n }\n },\n binaries: {\n 'v1.7.6': {\n mac: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-mac-x64.zip',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n windows: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-win-x64.zip',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n },\n linux: {\n url: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.6/whisper-cpp-v1.7.6-linux-x64.tar.gz',\n sha256: null // TODO: 실제 체크섬 추가 필요 - null일 경우 체크섬 검증 스킵됨\n }\n }\n }\n }\n};\n\nmodule.exports = { DOWNLOAD_CHECKSUMS };"], ["/glass/pickleglass_web/next.config.js", "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n reactStrictMode: true,\n swcMinify: true,\n output: 'export',\n\n images: { unoptimized: true },\n}\n\nmodule.exports = nextConfig "], ["/glass/src/bridge/internalBridge.js", "// src/bridge/internalBridge.js\nconst { EventEmitter } = require('events');\n\n// FeatureCore와 WindowCore를 잇는 내부 이벤트 버스\nconst internalBridge = new EventEmitter();\nmodule.exports = internalBridge;\n\n// 예시 이벤트\n// internalBridge.on('content-protection-changed', (enabled) => {\n// // windowManager에서 처리\n// });"], ["/glass/pickleglass_web/postcss.config.js", "module.exports = {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n} "], ["/glass/src/features/shortcuts/repositories/index.js", "module.exports = require('./sqlite.repository'); "], ["/glass/preload.js", ""]], "task_instance_info": {"created_time": "2025-08-21 00:01:29", "created_task_model": "DeepSeek-R1", "function_skeleton": "function addAiMessage ({ uid, sessionId, role, content, model = 'unknown' }) {}", "code_description": "This code segment functions to: Persist structured communication records in a database by generating unique identifiers, capturing temporal metadata, and handling potential storage errors through transactional operations."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\nfunction addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n const db = sqliteClient.getDb();\n const query = `\n INSERT INTO ai_messages (uid, session_id, role, content, model, sent_at)\n VALUES (?, ?, ?, ?, ?, datetime('now'))\n `;\n return db.prepare(query).run(uid, sessionId, role, content, model);\n}\n[TASK_END]\n```", "inference_time": "2025-08-21 00-01-54"}, "editdistance_info": {"edit_distance": 44.7368, "calculate_time": "2025-08-21 00:01:54", "true_code_clean": "function addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n const db = sqliteClient.getDb();\n const messageId = require('crypto').randomUUID();\n const now = Math.floor(Date.now() / 1000);\n const query = `INSERT INTO ai_messages (id, session_id, sent_at, role, content, model, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)`;\n try {\n db.prepare(query).run(messageId, sessionId, now, role, content, model, now);\n return { id: messageId };\n } catch (err) {\n console.error('SQLite: Failed to add AI message:', err);\n throw err;\n }\n}", "predict_code_clean": "function addAiMessage({ uid, sessionId, role, content, model = 'unknown' }) {\n const db = sqliteClient.getDb();\n const query = `\n INSERT INTO ai_messages (uid, session_id, role, content, model, sent_at)\n VALUES (?, ?, ?, ?, ?, datetime('now'))\n `;\n return db.prepare(query).run(uid, sessionId, role, content, model);\n}"}}