/* AI 设计师 Agent 聊天窗(首页)——参考 opencode Session/Tool 架构的后端驱动 */ (function () { if (!window.PL || !PL.api) return; const SID_KEY = 'pouchlab.agent.sid'; const HANDOFF_KEY = 'pouchlab.agent.handoff'; const st = { open: false, busy: false, sid: null, left: null, messages: [], state: null }; function ensure() { if (document.getElementById('plAgentFab')) return; const fab = document.createElement('button'); fab.id = 'plAgentFab'; fab.type = 'button'; fab.innerHTML = 'AI 设计师'; document.body.appendChild(fab); fab.addEventListener('click', toggle); const panel = document.createElement('div'); panel.id = 'plAgentPanel'; panel.className = 'pl-agent-panel'; panel.hidden = true; panel.innerHTML = '