agentcue 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +15 -6
  2. package/dist/client.js +12 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -58,6 +58,14 @@ Then attach the overlay in the browser using any output printed in your terminal
58
58
  - **Bookmarklet**: run the zero-config Bookmarklet URL on any local page
59
59
  - **Built-in playground**: open `http://localhost:4318/demo` to test live edits immediately
60
60
 
61
+ ### Browser Extension (Chrome / Edge / Arc / Brave)
62
+
63
+ Use the Manifest V3 browser extension (`packages/extension`) to activate **Pick Mode** on any tab with a single toolbar click or `Cmd/Ctrl + Shift + F`, while automatically mounting the collapsed `✦` launcher on `localhost` / `127.0.0.1` dev servers:
64
+
65
+ 1. Download [`agentcue-extension.zip`](https://agentcue.yuler.dev/agentcue-extension.zip) (or build locally with `mise run extension:build` to produce `packages/extension/dist`).
66
+ 2. Open `chrome://extensions`, enable **Developer mode**, and click **Load unpacked** pointing to the unzipped folder (or `packages/extension/dist`).
67
+ 3. Start `npx agentcue` in your project workspace (or use `C` / **Copy Markdown** standalone on any webpage without a local bridge). Right-click the extension icon to configure a custom Bridge URL or toggle `localhost` auto-mount.
68
+
61
69
  ## Browser Shortcuts
62
70
 
63
71
  | Shortcut | Action |
@@ -107,12 +115,13 @@ mise run check
107
115
 
108
116
  ### Workspace Targets
109
117
 
110
- | Workspace | Description | Dev / Start Command | Port |
111
- | --------------------- | ---------------------------------------------------- | --------------------------------- | ------- |
112
- | `packages/agentcue` | CLI, local HTTP/SSE bridge, Vite plugin, and overlay | `mise run agentcue:start` | `:4318` |
113
- | `apps/web` | Official showcase and interactive documentation | `mise run web:dev` | `:4319` |
114
- | `examples/html` | Plain HTML playground with live reload | `mise run example:html:dev` | `:4320` |
115
- | `examples/vite-react` | Vite + React + TypeScript HMR playground | `mise run example:vite-react:dev` | `:5173` |
118
+ | Workspace | Description | Dev / Start Command | Port |
119
+ | --------------------- | ---------------------------------------------------------- | --------------------------------- | ------- |
120
+ | `packages/agentcue` | CLI, local HTTP/SSE bridge, Vite plugin, and overlay | `mise run agentcue:start` | `:4318` |
121
+ | `packages/extension` | Manifest V3 browser extension (unpacked + `.zip` bundle) | `mise run extension:dev` | — |
122
+ | `apps/web` | Official showcase and interactive documentation | `mise run web:dev` | `:4319` |
123
+ | `examples/html` | Plain HTML playground with live reload | `mise run example:html:dev` | `:4320` |
124
+ | `examples/vite-react` | Vite + React + TypeScript HMR playground | `mise run example:vite-react:dev` | `:5173` |
116
125
 
117
126
  Other workspace tasks: `mise run build`, `mise run test`, and `mise run clean`.
118
127
 
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- (()=>{var _e=`
1
+ (()=>{var He=`
2
2
  :host {
3
3
  all: initial;
4
4
  position: fixed;
@@ -410,9 +410,9 @@
410
410
  transition: opacity 120ms ease 80ms, transform 120ms ease 80ms, visibility 0s linear 80ms;
411
411
  }
412
412
  .sep { width: 1px; height: 16px; background: rgba(255, 255, 255, 0.12); margin: 0 3px; flex-shrink: 0; }
413
- `;var rt=["display","fontSize","fontWeight","color","backgroundColor","padding","margin","borderRadius","gap"];function pe(n){if(typeof CSS<"u"&&typeof CSS.escape==="function")return CSS.escape(n);return n.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function ue(n){if(!n)return!1;if(n.includes(":")||/^radix-|^headlessui-|^\d+$/.test(n))return!1;return n.length<=48}function He(n,i=2){return Array.from(n.classList).filter((s)=>s.length>1&&s.length<=36&&!/^css-[a-z0-9]+$|^sc-[a-zA-Z0-9]+$|^svelte-[a-z0-9]+$/.test(s)).slice(0,i)}function at(n,i=!1){let o=n.tagName.toLowerCase();if(n.id&&ue(n.id))return`#${pe(n.id)}`;let s=n.getAttribute("data-testid")||n.getAttribute("data-test-id");if(s){let l=n.hasAttribute("data-testid")?"data-testid":"data-test-id";return`${o}[${l}="${s.replace(/"/g,"\\\"")}"]`}let t=He(n,2),c=t.length>0?`${o}.${t.map((l)=>pe(l)).join(".")}`:o;if(i&&n.parentElement){let l=Array.from(n.parentElement.children).filter((p)=>p.tagName===n.tagName);if(l.length>1){let p=l.indexOf(n)+1;c+=`:nth-of-type(${p})`}}return c}function lt(n){let i=n.ownerDocument;if(n.id&&ue(n.id))return`#${pe(n.id)}`;let o=[],s=n,t=0;while(s&&s.tagName.toLowerCase()!=="html"&&t<6){if(s.tagName.toLowerCase()==="body"){o.unshift("body");break}let l=at(s,!0);o.unshift(l);let p=o.join(" > ");try{if(i.querySelectorAll(p).length===1)return p}catch{}if(l.startsWith("#"))break;s=s.parentElement,t++}return o.join(" > ")||n.tagName.toLowerCase()}function ct(n){let i=[],o=n,s=0;while(o&&s<5){let t=o.tagName.toLowerCase();if(t==="html")break;if(t==="body"){i.unshift("body");break}let c=He(o,1),l=o.id&&ue(o.id)?`${t}#${o.id}`:c.length>0?`${t}.${c[0]}`:t;i.unshift(l),o=o.parentElement,s++}return i.join(" > ")}function dt(n,i=500){let o=n.cloneNode(!0),s=o.tagName.toLowerCase()==="svg"?[o]:Array.from(o.querySelectorAll("svg"));for(let c of s)if(c.innerHTML.length>80)c.innerHTML="<!-- svg -->";let t=o.outerHTML.replace(/\s+/g," ").trim();if(t.length<=i)return t;return`${t.slice(0,i-15)}...<!--truncated-->`}function pt(n){let i=n.split(`
414
- `);for(let o of i){if(o.includes("react-stack-top-frame")||o.includes("node_modules")||o.includes("react_jsx")||o.includes("react-dom")||o.includes("/@vite/")||o.includes("__agentcue"))continue;let s=o.match(/https?:\/\/[^/]+\/([^\s:)]+):(\d+)(?::\d+)?/);if(s){let t=s[1].split("?")[0];if(t.startsWith("@fs/"))t=`/${t.slice(4)}`;return`${t}:${s[2]}`}}return}function ut(n){let i,o=[],s=n;for(let d=0;d<12&&s&&!i;d++){let u=s.getAttribute("data-source");if(u){i=u;break}let v=s.getAttribute("data-astro-source-file");if(v){let L=s.getAttribute("data-astro-source-loc");i=L?`${v}:${L}`:v;break}let g=s.getAttribute("data-inspector-relative-path")||s.getAttribute("data-v-inspector-file");if(g){let L=s.getAttribute("data-inspector-line")||s.getAttribute("data-v-inspector-line");i=L?`${g}:${L}`:g;break}s=s.parentElement}let t=n,c=t.__svelte_meta;if(!i&&c?.loc?.file){let{file:d,line:u}=c.loc;i=u!=null?`${d}:${u}`:d}let l=t.__vueParentComponent,p=0;while(l&&p<6){let d=l.type?.__name||l.type?.name;if(d&&!o.includes(`<${d}>`))o.unshift(`<${d}>`);if(!i&&l.type?.__file)i=l.type.__file;l=l.parent,p++}let m=Object.keys(n).find((d)=>d.startsWith("__reactFiber$")||d.startsWith("__reactInternalInstance$"));if(m){let d=t[m],u=0;while(d&&u<12){if(!i&&d._debugSource?.fileName){let{fileName:v,lineNumber:g}=d._debugSource;i=g!=null?`${v}:${g}`:v}if(!i&&d._debugStack?.stack)i=pt(d._debugStack.stack);if(d.type&&typeof d.type==="function"){let v=d.type,g=v.displayName||v.name;if(g&&/^[A-Z]/.test(g)&&o.length<4&&o[0]!==`<${g}>`)o.unshift(`<${g}>`)}d=d.return,u++}}return{sourceHint:i,componentStack:o.length>0?o.join(" > "):void 0}}function J(n){let i=n.ownerDocument.defaultView,o=i?i.getComputedStyle(n):null,s={};if(o)for(let d of rt){let u=d.replace(/[A-Z]/g,(g)=>`-${g.toLowerCase()}`),v=o.getPropertyValue(u);if(v)s[u]=v}let t=n.getBoundingClientRect(),c=(n.textContent||"").replace(/\s+/g," ").trim(),l=c.length>140?`${c.slice(0,140)}…`:c,{sourceHint:p,componentStack:m}=ut(n);return{tagName:n.tagName.toLowerCase(),selector:lt(n),breadcrumb:ct(n),outerHTML:dt(n),textExcerpt:l,computedStyles:s,boundingBox:{x:t.left,y:t.top,width:t.width,height:t.height},sourceHint:p,componentStack:m}}function Ne(n,i,o){let s="status-dot",t=`Agent: ${o} · A`,c="";if(!n)s="status-dot offline",t=`Offline (Copy only) · ${o} (A)`;else if(i?.activeCue){s="status-dot running";let l=i.queuedCount>0?` (+${i.queuedCount})`:"";c=`${i.activeCue.agent} editing…${l}`,t=`${c} · A`}else if(i?.status==="error"&&i.lastResult)s="status-dot error",t=`Error ✗ · ${o} (A)`;else if(i?.status==="done"&&i.lastResult)t=`Done ✓ (${(i.lastResult.durationMs/1000).toFixed(1)}s) · ${o} (A)`;return{dotClass:s,statusTip:t,compactRunning:c}}function ge(n,i,o){return{agent:n,continueSession:i,pageUrl:window.location.href,pageTitle:document.title,pins:o.map((s,t)=>({index:t+1,note:s.note.trim(),context:s.context}))}}var Be="agentcue:active-sessions";function De(){try{let n=sessionStorage.getItem(Be);return n?new Set(JSON.parse(n)):new Set}catch{return new Set}}function Q(n){try{sessionStorage.setItem(Be,JSON.stringify([...n]))}catch{}}function ze(n,i,o,s,t){let c=new Set(o.map((l)=>l.id));for(let[l,p]of i)if(!c.has(l))i.delete(l),p.classList.add("removing"),setTimeout(()=>p.remove(),170);o.forEach((l,p)=>{let{x:m,y:d}=Ye(l),u=i.get(l.id);if(!u)u=document.createElement("div"),u.className="pin-badge",u.addEventListener("click",(v)=>{v.stopPropagation(),t(l.id)}),i.set(l.id,u),n.appendChild(u);u.classList.toggle("active",l.id===s),u.textContent=String(p+1),u.style.left=`${Math.round(m)}px`,u.style.top=`${Math.round(d)}px`,u.title=l.note||l.context.selector})}function Oe(n,i,o,s,t){n.textContent=s,i.innerHTML="",o.forEach((c,l)=>{let p=document.createElement("button");p.className=c===s?"agent-opt selected":"agent-opt",p.innerHTML=`<span class="agent-opt-left"><span class="agent-opt-dot"></span><span>${c}</span></span><span class="agent-opt-kbd">${l+1}</span>`,p.addEventListener("click",(m)=>{m.stopPropagation(),t(c)}),i.appendChild(p)})}function P(n,i,o){return Math.max(i,Math.min(o,n))}function Re(){return typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)}function je(n){for(let i of n.composedPath())if(i instanceof HTMLElement){let o=i.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT"||i.isContentEditable)return!0}return!1}function Ye(n){let i=n.el.getBoundingClientRect();if(i.width===0&&i.height===0)return{x:P(n.context.boundingBox.x+16,16,window.innerWidth-16),y:P(n.context.boundingBox.y+16,16,window.innerHeight-16)};return{x:P(i.left+i.width*n.relX,14,window.innerWidth-14),y:P(i.top+i.height*n.relY,14,window.innerHeight-14)}}function fe(n,i,o=!1){let{x:s,y:t}=Ye(i),c=310,l=165,p=s+18,m="0px";if(p+310>window.innerWidth-12)p=Math.max(12,s-310-18),m="100%";let d=t-16,u="20px";if(d+165>window.innerHeight-64)d=Math.max(12,window.innerHeight-165-64),u=`${P(Math.round(t-d),16,149)}px`;n.classList.toggle("no-glide",!o),n.style.transformOrigin=`${m} ${u}`,n.style.left=`${Math.round(p)}px`,n.style.top=`${Math.round(d)}px`}function Ke(n,i,o,s){if(!s||!o){n.classList.remove("visible"),i.classList.remove("visible");return}let t=o.getBoundingClientRect();if(t.width<=0||t.height<=0){n.classList.remove("visible"),i.classList.remove("visible");return}let c=o===document.body||o===document.documentElement,l=c?Math.max(4,Math.round(t.left)):Math.round(t.left),p=c?Math.max(4,Math.round(t.top)):Math.round(t.top),m=c?Math.min(window.innerWidth-4,Math.round(t.right)):Math.round(t.right),d=c?Math.min(window.innerHeight-4,Math.round(t.bottom)):Math.round(t.bottom);n.style.left=`${l}px`,n.style.top=`${p}px`,n.style.width=`${Math.max(0,m-l)}px`,n.style.height=`${Math.max(0,d-p)}px`,n.classList.add("visible");let u=J(o),v=`${u.tagName}${o.id?`#${o.id}`:o.classList[0]?`.${o.classList[0]}`:""} · ${Math.round(t.width)}×${Math.round(t.height)}`,g=u.sourceHint||u.componentStack||"";if(i.innerHTML="",i.appendChild(document.createTextNode(v)),g){let O=document.createElement("span");O.className="hint-source",O.textContent=g,i.appendChild(O)}let L=p>=28?p-24:d<=window.innerHeight-32?d+6:p+8;i.style.left=`${P(c?l+8:l,8,window.innerWidth-240)}px`,i.style.top=`${Math.round(L)}px`,i.classList.add("visible")}var gt='<svg class="launcher-logo" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M19 9.5V7a3 3 0 0 0-3-3H7a3 3 0 0 0-3 3v9a3 3 0 0 0 3 3h2.5" stroke="#60a5fa" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/><circle cx="9.5" cy="9.5" r="1.75" fill="#60a5fa"/><path d="M15.5 10C16.15 14.05 16.95 14.85 21 15.5C16.95 16.15 16.15 16.95 15.5 21C14.85 16.95 14.05 16.15 10 15.5C14.05 14.85 14.85 14.05 15.5 10Z" fill="currentColor"/></svg>',me='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="9" y1="6" x2="9" y2="18"/><line x1="15" y1="6" x2="15" y2="18"/></svg>',Fe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="3"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',be='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>',Ue='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M10.7 5.1A11 11 0 0 1 12 5c6.4 0 10 7 10 7a13.2 13.2 0 0 1-1.7 2.7"/><path d="M6.6 6.6C4 8.4 2 12 2 12s3.6 7 10 7a9.8 9.8 0 0 0 5.4-1.6"/><line x1="2" y1="2" x2="22" y2="22"/></svg>';function Ge(n,i){let o=document.createElement("agentcue-root"),s=o.attachShadow({mode:"open"});s.innerHTML=`
415
- <style>${_e}</style>
413
+ `;var gt=["display","fontSize","fontWeight","color","backgroundColor","padding","margin","borderRadius","gap"];function de(t){if(typeof CSS<"u"&&typeof CSS.escape==="function")return CSS.escape(t);return t.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function pe(t){if(!t)return!1;if(t.includes(":")||/^radix-|^headlessui-|^\d+$/.test(t))return!1;return t.length<=48}function Ie(t,n=2){return Array.from(t.classList).filter((s)=>s.length>1&&s.length<=36&&!/^css-[a-z0-9]+$|^sc-[a-zA-Z0-9]+$|^svelte-[a-z0-9]+$/.test(s)).slice(0,n)}function ft(t,n=!1){let o=t.tagName.toLowerCase();if(t.id&&pe(t.id))return`#${de(t.id)}`;let s=t.getAttribute("data-testid")||t.getAttribute("data-test-id");if(s){let a=t.hasAttribute("data-testid")?"data-testid":"data-test-id";return`${o}[${a}="${s.replace(/"/g,"\\\"")}"]`}let r=Ie(t,2),i=r.length>0?`${o}.${r.map((a)=>de(a)).join(".")}`:o;if(n&&t.parentElement){let a=Array.from(t.parentElement.children).filter((d)=>d.tagName===t.tagName);if(a.length>1){let d=a.indexOf(t)+1;i+=`:nth-of-type(${d})`}}return i}function mt(t){let n=t.ownerDocument;if(t.id&&pe(t.id))return`#${de(t.id)}`;let o=[],s=t,r=0;while(s&&s.tagName.toLowerCase()!=="html"&&r<6){if(s.tagName.toLowerCase()==="body"){o.unshift("body");break}let a=ft(s,!0);o.unshift(a);let d=o.join(" > ");try{if(n.querySelectorAll(d).length===1)return d}catch{}if(a.startsWith("#"))break;s=s.parentElement,r++}return o.join(" > ")||t.tagName.toLowerCase()}function bt(t){let n=[],o=t,s=0;while(o&&s<5){let r=o.tagName.toLowerCase();if(r==="html")break;if(r==="body"){n.unshift("body");break}let i=Ie(o,1),a=o.id&&pe(o.id)?`${r}#${o.id}`:i.length>0?`${r}.${i[0]}`:r;n.unshift(a),o=o.parentElement,s++}return n.join(" > ")}function ht(t,n=500){let o=t.cloneNode(!0),s=o.tagName.toLowerCase()==="svg"?[o]:Array.from(o.querySelectorAll("svg"));for(let i of s)if(i.innerHTML.length>80)i.innerHTML="<!-- svg -->";let r=o.outerHTML.replace(/\s+/g," ").trim();if(r.length<=n)return r;return`${r.slice(0,n-15)}...<!--truncated-->`}function xt(t){let n=t.split(`
414
+ `);for(let o of n){if(o.includes("react-stack-top-frame")||o.includes("node_modules")||o.includes("react_jsx")||o.includes("react-dom")||o.includes("/@vite/")||o.includes("__agentcue"))continue;let s=o.match(/https?:\/\/[^/]+\/([^\s:)]+):(\d+)(?::\d+)?/);if(s){let r=s[1].split("?")[0];if(r.startsWith("@fs/"))r=`/${r.slice(4)}`;return`${r}:${s[2]}`}}return}function vt(t){let n,o=[],s=t,r=s.__svelte_meta;if(!n&&r?.loc?.file){let{file:c,line:g}=r.loc;n=g!=null?`${c}:${g}`:c}let i=s.__vueParentComponent,a=0;while(i&&a<6){let c=i.type?.__name||i.type?.name;if(c&&!o.includes(`<${c}>`))o.unshift(`<${c}>`);if(!n&&i.type?.__file)n=i.type.__file;i=i.parent,a++}let d=Object.keys(t).find((c)=>c.startsWith("__reactFiber$")||c.startsWith("__reactInternalInstance$"));if(d){let c=s[d],g=0;while(c&&g<12){if(!n&&c._debugSource?.fileName){let{fileName:u,lineNumber:h}=c._debugSource;n=h!=null?`${u}:${h}`:u}if(!n&&c._debugStack?.stack)n=xt(c._debugStack.stack);if(c.type&&typeof c.type==="function"){let u=c.type,h=u.displayName||u.name;if(h&&/^[A-Z]/.test(h)&&o.length<4&&o[0]!==`<${h}>`)o.unshift(`<${h}>`)}c=c.return,g++}}return{sourceHint:n,componentStack:o.length>0?o.join(" > "):void 0}}function yt(t){let n,o=t;for(let r=0;r<12&&o&&!n;r++){let i=o.getAttribute("data-source");if(i){n=i;break}let a=o.getAttribute("data-astro-source-file");if(a){let c=o.getAttribute("data-astro-source-loc");n=c?`${a}:${c}`:a;break}let d=o.getAttribute("data-inspector-relative-path")||o.getAttribute("data-v-inspector-file");if(d){let c=o.getAttribute("data-inspector-line")||o.getAttribute("data-v-inspector-line");n=c?`${d}:${c}`:d;break}o=o.parentElement}let s=vt(t);return{sourceHint:n??s.sourceHint,componentStack:s.componentStack}}function ue(t,n){let o=t.ownerDocument.defaultView,s=o?o.getComputedStyle(t):null,r={};if(s)for(let u of gt){let h=u.replace(/[A-Z]/g,(_)=>`-${_.toLowerCase()}`),O=s.getPropertyValue(h);if(O)r[h]=O}let i=t.getBoundingClientRect(),a=(t.textContent||"").replace(/\s+/g," ").trim(),d=a.length>140?`${a.slice(0,140)}…`:a,{sourceHint:c,componentStack:g}=yt(t);if((!c||!g)&&n){let u=n(t);if(u)c=c??u.sourceHint,g=g??u.componentStack}return{tagName:t.tagName.toLowerCase(),selector:mt(t),breadcrumb:bt(t),outerHTML:ht(t),textExcerpt:d,computedStyles:r,boundingBox:{x:i.left,y:i.top,width:i.width,height:i.height},sourceHint:c,componentStack:g}}function _e(t,n,o){let s="status-dot",r=`Agent: ${o} · A`,i="";if(!t)s="status-dot offline",r=`Offline (Copy only) · ${o} (A)`;else if(n?.activeCue){s="status-dot running";let a=n.queuedCount>0?` (+${n.queuedCount})`:"";i=`${n.activeCue.agent} editing…${a}`,r=`${i} · A`}else if(n?.status==="error"&&n.lastResult)s="status-dot error",r=`Error ✗ · ${o} (A)`;else if(n?.status==="done"&&n.lastResult)r=`Done ✓ (${(n.lastResult.durationMs/1000).toFixed(1)}s) · ${o} (A)`;return{dotClass:s,statusTip:r,compactRunning:i}}function Ne(t,n,o,s){let r=document.elementFromPoint(t,n),i=r===document.documentElement?document.body||r:r;if(!i||i===o)return null;let a=i.getBoundingClientRect();return{id:`${Date.now()}-${Math.random().toString(36).slice(2,7)}`,el:i,relX:a.width>0?B((t-a.left)/a.width,0.1,0.9):0.5,relY:a.height>0?B((n-a.top)/a.height,0.1,0.9):0.5,note:"",context:ue(i,s)}}function ge(t,n,o){return{agent:t,continueSession:n,pageUrl:window.location.href,pageTitle:document.title,pins:o.map((s,r)=>({index:r+1,note:s.note.trim(),context:s.context}))}}var Be="agentcue:selected-agent",De="agentcue:active-sessions";function wt(){try{let t=sessionStorage.getItem(De);return t?new Set(JSON.parse(t)):new Set}catch{return new Set}}function kt(t){try{sessionStorage.setItem(De,JSON.stringify([...t]))}catch{}}function Oe(){return{getSelectedAgent:()=>{try{return localStorage.getItem(Be)}catch{return null}},setSelectedAgent:(t)=>{try{localStorage.setItem(Be,t)}catch{}},loadActiveSessions:wt,saveActiveSessions:kt}}function ze(t,n,o,s,r){let i=new Set(o.map((a)=>a.id));for(let[a,d]of n)if(!i.has(a))n.delete(a),d.classList.add("removing"),setTimeout(()=>d.remove(),170);o.forEach((a,d)=>{let{x:c,y:g}=Ye(a),u=n.get(a.id);if(!u)u=document.createElement("div"),u.className="pin-badge",u.addEventListener("click",(h)=>{h.stopPropagation(),r(a.id)}),n.set(a.id,u),t.appendChild(u);u.classList.toggle("active",a.id===s),u.textContent=String(d+1),u.style.left=`${Math.round(c)}px`,u.style.top=`${Math.round(g)}px`,u.title=a.note||a.context.selector})}function Re(t,n,o,s,r){t.textContent=s,n.innerHTML="",o.forEach((i,a)=>{let d=document.createElement("button");d.className=i===s?"agent-opt selected":"agent-opt",d.innerHTML=`<span class="agent-opt-left"><span class="agent-opt-dot"></span><span>${i}</span></span><span class="agent-opt-kbd">${a+1}</span>`,d.addEventListener("click",(c)=>{c.stopPropagation(),r(i)}),n.appendChild(d)})}function B(t,n,o){return Math.max(n,Math.min(o,t))}function Fe(){return typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)}function je(t){for(let n of t.composedPath())if(n instanceof HTMLElement){let o=n.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT"||n.isContentEditable)return!0}return!1}function Ye(t){let n=t.el.getBoundingClientRect();if(n.width===0&&n.height===0)return{x:B(t.context.boundingBox.x+16,16,window.innerWidth-16),y:B(t.context.boundingBox.y+16,16,window.innerHeight-16)};return{x:B(n.left+n.width*t.relX,14,window.innerWidth-14),y:B(n.top+n.height*t.relY,14,window.innerHeight-14)}}function fe(t,n,o=!1){let{x:s,y:r}=Ye(n),i=310,a=165,d=s+18,c="0px";if(d+310>window.innerWidth-12)d=Math.max(12,s-310-18),c="100%";let g=r-16,u="20px";if(g+165>window.innerHeight-64)g=Math.max(12,window.innerHeight-165-64),u=`${B(Math.round(r-g),16,149)}px`;t.classList.toggle("no-glide",!o),t.style.transformOrigin=`${c} ${u}`,t.style.left=`${Math.round(d)}px`,t.style.top=`${Math.round(g)}px`}function Ke(t,n,o,s,r){if(!s||!o){t.classList.remove("visible"),n.classList.remove("visible");return}let i=o.getBoundingClientRect();if(i.width<=0||i.height<=0){t.classList.remove("visible"),n.classList.remove("visible");return}let a=o===document.body||o===document.documentElement,d=a?Math.max(4,Math.round(i.left)):Math.round(i.left),c=a?Math.max(4,Math.round(i.top)):Math.round(i.top),g=a?Math.min(window.innerWidth-4,Math.round(i.right)):Math.round(i.right),u=a?Math.min(window.innerHeight-4,Math.round(i.bottom)):Math.round(i.bottom);t.style.left=`${d}px`,t.style.top=`${c}px`,t.style.width=`${Math.max(0,g-d)}px`,t.style.height=`${Math.max(0,u-c)}px`,t.classList.add("visible");let h=ue(o,r),O=`${h.tagName}${o.id?`#${o.id}`:o.classList[0]?`.${o.classList[0]}`:""} · ${Math.round(i.width)}×${Math.round(i.height)}`,_=h.sourceHint||h.componentStack||"";if(n.innerHTML="",n.appendChild(document.createTextNode(O)),_){let F=document.createElement("span");F.className="hint-source",F.textContent=_,n.appendChild(F)}let E=c>=28?c-24:u<=window.innerHeight-32?u+6:c+8;n.style.left=`${B(a?d+8:d,8,window.innerWidth-240)}px`,n.style.top=`${Math.round(E)}px`,n.classList.add("visible")}var Et='<svg class="launcher-logo" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M19 9.5V7a3 3 0 0 0-3-3H7a3 3 0 0 0-3 3v9a3 3 0 0 0 3 3h2.5" stroke="#60a5fa" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/><circle cx="9.5" cy="9.5" r="1.75" fill="#60a5fa"/><path d="M15.5 10C16.15 14.05 16.95 14.85 21 15.5C16.95 16.15 16.15 16.95 15.5 21C14.85 16.95 14.05 16.15 10 15.5C14.05 14.85 14.85 14.05 15.5 10Z" fill="currentColor"/></svg>',me='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="9" y1="6" x2="9" y2="18"/><line x1="15" y1="6" x2="15" y2="18"/></svg>',Ue='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="3"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',be='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>',qe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M10.7 5.1A11 11 0 0 1 12 5c6.4 0 10 7 10 7a13.2 13.2 0 0 1-1.7 2.7"/><path d="M6.6 6.6C4 8.4 2 12 2 12s3.6 7 10 7a9.8 9.8 0 0 0 5.4-1.6"/><line x1="2" y1="2" x2="22" y2="22"/></svg>';function Ge(t,n,o="open"){let s=document.createElement("agentcue-root"),r=s.attachShadow({mode:o});r.innerHTML=`
415
+ <style>${He}</style>
416
416
  <div class="hover-box" id="hoverBox"></div>
417
417
  <div class="hover-tag" id="hoverTag"></div>
418
418
  <div class="pins-layer" id="pinsLayer"></div>
@@ -429,7 +429,7 @@
429
429
  <span class="popover-hints">↵ Save & next · ⇧↵ Newline</span>
430
430
  <div class="popover-actions">
431
431
  <button class="btn-sm" id="popSave">Save</button>
432
- <button class="btn-sm primary" id="popSend">Send ${n}</button>
432
+ <button class="btn-sm primary" id="popSend">Send ${t}</button>
433
433
  </div>
434
434
  </div>
435
435
  </div>
@@ -443,9 +443,9 @@
443
443
  <div id="agentMenuList"></div>
444
444
  </div>
445
445
  <div class="toolbar-stage">
446
- <button class="launcher" id="launcherBtn" title="Activate agentcue (${i})">
446
+ <button class="launcher" id="launcherBtn" title="Activate agentcue (${n})">
447
447
  <span class="status-dot offline" id="launcherDot"></span>
448
- ${gt}
448
+ ${Et}
449
449
  <span class="launcher-text" id="launcherText"></span>
450
450
  <span class="launcher-count" id="launcherCount">0</span>
451
451
  </button>
@@ -460,7 +460,7 @@
460
460
  <button class="tool-btn" id="clearBtn" data-tip="Clear Pins · X" disabled>
461
461
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
462
462
  </button>
463
- <button class="tool-btn send-btn" id="sendBtn" data-tip="Send Cue · S / ${n}" disabled>
463
+ <button class="tool-btn send-btn" id="sendBtn" data-tip="Send Cue · S / ${t}" disabled>
464
464
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
465
465
  <span class="send-count" id="sendCount"></span>
466
466
  </button>
@@ -481,9 +481,9 @@
481
481
  </div>
482
482
  </div>
483
483
  </div>
484
- `,document.documentElement.appendChild(o);let t=(c)=>s.getElementById(c);return{host:o,hoverBox:t("hoverBox"),hoverTag:t("hoverTag"),pinsLayer:t("pinsLayer"),popover:t("popover"),popNum:t("popNum"),popSel:t("popSel"),popDelete:t("popDelete"),popInput:t("popInput"),popSave:t("popSave"),popSend:t("popSend"),toastEl:t("toast"),agentMenu:t("agentMenu"),agentMenuList:t("agentMenuList"),launcherBtn:t("launcherBtn"),launcherDot:t("launcherDot"),launcherText:t("launcherText"),launcherCount:t("launcherCount"),capsule:t("capsule"),statusDot:t("statusDot"),pickBtn:t("pickBtn"),agentBtn:t("agentBtn"),agentLabel:t("agentLabel"),contBtn:t("contBtn"),hideBtn:t("hideBtn"),copyBtn:t("copyBtn"),clearBtn:t("clearBtn"),sendBtn:t("sendBtn"),sendCount:t("sendCount"),collapseBtn:t("collapseBtn")}}function ft(n){let i=Object.entries(n).filter(([,o])=>o&&o!=="none"&&o!=="normal"&&o!=="0px");if(i.length===0)return"";return i.map(([o,s])=>`${o}: ${s}`).join("; ")}function mt(n){let{context:i,note:o,index:s}=n,t=[];if(t.push(`### Pin #${s}: ${o.trim()}`),i.sourceHint)t.push(`- **Source hint**: \`${i.sourceHint}\``);if(i.componentStack)t.push(`- **Component tree**: \`${i.componentStack}\``);t.push(`- **Selector**: \`${i.selector}\``),t.push(`- **DOM path**: \`${i.breadcrumb}\``);let{width:c,height:l,x:p,y:m}=i.boundingBox;if(t.push(`- **Box**: ${Math.round(c)}×${Math.round(l)}px at (${Math.round(p)}, ${Math.round(m)})`),i.textExcerpt)t.push(`- **Visible text**: ${JSON.stringify(i.textExcerpt)}`);let d=ft(i.computedStyles);if(d)t.push(`- **Computed styles**: \`${d}\``);return t.push("- **DOM snippet**:"),t.push("```html"),t.push(i.outerHTML),t.push("```"),t.join(`
485
- `)}function Xe(n){let o=["Apply the following visual UI changes directly to the source files in this workspace.","Locate the exact source files using the selectors, visible text, DOM structure, and source hints below, then make minimal, clean edits.","",`- **Page**: \`${(()=>{try{let t=new URL(n.pageUrl);return`${t.pathname}${t.search}${t.hash}`||"/"}catch{return n.pageUrl||"/"}})()}\`${n.pageTitle?` (${n.pageTitle})`:""}`,`- **Total Pins**: ${n.pins.length}`].join(`
486
- `),s=n.pins.map((t,c)=>mt({...t,index:c+1}));return[o,...s].join(`
484
+ `,document.documentElement.appendChild(s);let i=(a)=>r.getElementById(a);return{host:s,shadow:r,hoverBox:i("hoverBox"),hoverTag:i("hoverTag"),pinsLayer:i("pinsLayer"),popover:i("popover"),popNum:i("popNum"),popSel:i("popSel"),popDelete:i("popDelete"),popInput:i("popInput"),popSave:i("popSave"),popSend:i("popSend"),toastEl:i("toast"),agentMenu:i("agentMenu"),agentMenuList:i("agentMenuList"),launcherBtn:i("launcherBtn"),launcherDot:i("launcherDot"),launcherText:i("launcherText"),launcherCount:i("launcherCount"),capsule:i("capsule"),statusDot:i("statusDot"),pickBtn:i("pickBtn"),agentBtn:i("agentBtn"),agentLabel:i("agentLabel"),contBtn:i("contBtn"),hideBtn:i("hideBtn"),copyBtn:i("copyBtn"),clearBtn:i("clearBtn"),sendBtn:i("sendBtn"),sendCount:i("sendCount"),collapseBtn:i("collapseBtn")}}function We(t){let n=()=>(typeof t==="function"?t():t).replace(/\/+$/,"");return{async sendCue(o){let s=await fetch(`${n()}/api/cue`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),r=await s.json().catch(()=>({}));return{ok:s.ok&&Boolean(r.cueId),status:s.status,cueId:r.cueId,error:r.error,queuePosition:r.queuePosition}},subscribeEvents(o){let s=new EventSource(`${n()}/api/events`);return s.onopen=()=>o.onOpen(),s.onmessage=(r)=>{try{let i=JSON.parse(r.data);o.onEvent(i)}catch{}},s.onerror=()=>o.onError(),()=>s.close()}}}function St(t){let n=Object.entries(t).filter(([,o])=>o&&o!=="none"&&o!=="normal"&&o!=="0px");if(n.length===0)return"";return n.map(([o,s])=>`${o}: ${s}`).join("; ")}function Ct(t){let{context:n,note:o,index:s}=t,r=[];if(r.push(`### Pin #${s}: ${o.trim()}`),n.sourceHint)r.push(`- **Source hint**: \`${n.sourceHint}\``);if(n.componentStack)r.push(`- **Component tree**: \`${n.componentStack}\``);r.push(`- **Selector**: \`${n.selector}\``),r.push(`- **DOM path**: \`${n.breadcrumb}\``);let{width:i,height:a,x:d,y:c}=n.boundingBox;if(r.push(`- **Box**: ${Math.round(i)}×${Math.round(a)}px at (${Math.round(d)}, ${Math.round(c)})`),n.textExcerpt)r.push(`- **Visible text**: ${JSON.stringify(n.textExcerpt)}`);let g=St(n.computedStyles);if(g)r.push(`- **Computed styles**: \`${g}\``);return r.push("- **DOM snippet**:"),r.push("```html"),r.push(n.outerHTML),r.push("```"),r.join(`
485
+ `)}function Xe(t){let o=["Apply the following visual UI changes directly to the source files in this workspace.","Locate the exact source files using the selectors, visible text, DOM structure, and source hints below, then make minimal, clean edits.","",`- **Page**: \`${(()=>{try{let r=new URL(t.pageUrl);return`${r.pathname}${r.search}${r.hash}`||"/"}catch{return t.pageUrl||"/"}})()}\`${t.pageTitle?` (${t.pageTitle})`:""}`,`- **Total Pins**: ${t.pins.length}`].join(`
486
+ `),s=t.pins.map((r,i)=>Ct({...r,index:i+1}));return[o,...s].join(`
487
487
 
488
488
  `)+`
489
- `}var ee=["agy","claude","cursor-agent","codex","pi"];var he="agentcue:selected-agent";function We(n){let i=Re(),o=i?"⌘↵":"Ctrl+↵",s=i?"⌘⇧F":"Ctrl+Shift+F",{host:t,hoverBox:c,hoverTag:l,pinsLayer:p,popover:m,popNum:d,popSel:u,popDelete:v,popInput:g,popSave:L,popSend:O,toastEl:te,agentMenu:xe,agentMenuList:qe,launcherBtn:ve,launcherDot:Ve,launcherText:Ze,launcherCount:ye,capsule:Je,statusDot:Qe,pickBtn:F,agentBtn:U,agentLabel:et,contBtn:ne,hideBtn:R,copyBtn:D,clearBtn:we,sendBtn:ke,sendCount:tt,collapseBtn:nt}=Ge(o,s),k=!1,S=!1,C=!1,G=!1,H=!1,ie=[...ee],x=localStorage.getItem(he)||"agy";if(!ee.includes(x))x="agy";let M=De(),Ee=null,f=[],it=new Map,b=null,X=null,W=new Map,q=new Map,Se=new Set,oe=null,se=null;function re(){return ie.length>0?ie:[...ee]}function z(e,r=!1,a=3200){if(oe)clearTimeout(oe);te.textContent=e,te.className=r?"toast visible error":"toast visible",oe=setTimeout(()=>{te.className="toast"},a)}function I(e){H=e,xe.classList.toggle("visible",e),U.classList.toggle("menu-open",e)}function ae(e,r=!0){if(x=e,localStorage.setItem(he,x),le(),T(),j(),r)I(!1)}function Ce(){if(!M.has(x)){z(`Next Cue for ${x} will already start a new session`);return}M.delete(x),Q(M),T(),z(`Session reset · Next Cue starts a new ${x} session`)}function ot(e=1){let r=re(),a=r.indexOf(x),w=r[(a+e+r.length)%r.length];ae(w,!1)}function le(){let e=re();if(!e.includes(x))x=e[0];Oe(et,qe,e,x,(r)=>ae(r,!0))}function j(){let{dotClass:e,statusTip:r,compactRunning:a}=Ne(G,Ee,x);Qe.className=e,Ve.className=e,U.setAttribute("data-tip",r),Ze.textContent=a}function T(){ve.classList.toggle("hidden",k),Je.classList.toggle("expanded",k),p.classList.toggle("hidden",C);let e=k&&S;F.classList.toggle("pick-active",e),F.innerHTML=e?me:Fe,F.setAttribute("data-tip",e?"Pause Pick · P":"Resume Pick · P");let r=M.has(x);ne.classList.toggle("cont-active",r),ne.setAttribute("data-tip",r?"Reset Session (in session) · R":"New Session (1st Cue)"),document.documentElement.style.cursor=e?"crosshair":"";let a=f.filter((y)=>y.note.trim().length>0).length,h=b!==null&&g.value.trim().length>0?f.filter((y)=>y.id!==b&&y.note.trim().length>0).length+1:a;ye.textContent=String(a),ye.classList.toggle("visible",!k&&a>0),R.innerHTML=C?Ue:be,R.classList.toggle("hide-active",C),R.setAttribute("data-tip",C?"Show Pins · H":"Hide Pins · H"),R.disabled=f.length===0,tt.textContent=h>0?String(h):"",ke.disabled=h===0,D.disabled=h===0,we.disabled=f.length===0}function N(e=!1){if(ze(p,it,f,b,(r)=>{if(!k)_(!0);Me(r)}),b){let r=f.find((a)=>a.id===b);if(r)fe(m,r,e)}T()}function B(e){X=e,Ke(c,l,e,k&&S&&b===null)}function Me(e){let r=f.findIndex((h)=>h.id===e);if(r===-1)return;let a=f[r],w=m.classList.contains("visible");if(C=!1,I(!1),b=e,d.textContent=`#${r+1}`,u.textContent=a.context.sourceHint||a.context.selector,g.value=a.note,fe(m,a,w),!w)m.offsetWidth;m.classList.add("visible"),B(null),N(w),g.focus(),g.selectionStart=g.value.length}function A(e){if(!b)return;let r=f.find((a)=>a.id===b);if(r){if(e)r.note=g.value.trim();if(!r.note.trim())f=f.filter((a)=>a.id!==r.id)}b=null,m.classList.remove("visible"),g.blur(),N()}function Le(e){if(!e&&b)A(!0);if(S=e,!S)B(null);T()}function _(e){if(e)k=!0,C=!1,S=!0,T();else{if(b)A(!0);I(!1),S=!1,k=!1,B(null),T()}}function Te(){b=null,m.classList.remove("visible"),f=[],C=!1,N()}function Ae(){if(f.length===0)return;if(!C&&b)A(!0);C=!C,T()}function Pe(){if(b)A(!0);return f.filter((e)=>e.note.trim().length>0)}async function $e(){let e=Pe();if(e.length===0)return;let r=Xe(ge(x,M.has(x),e));if(await navigator.clipboard.writeText(r),se)clearTimeout(se);D.classList.add("copied"),D.setAttribute("data-tip","Copied ✓"),se=setTimeout(()=>{D.classList.remove("copied"),D.setAttribute("data-tip","Copy Markdown · C")},1600)}function V(e,r,a=!1){if(a)M.delete(x),Q(M);let w=new Set(f.map((h)=>h.id));for(let h of e)if(!w.has(h.id))f.push(h);_(!0),N(),z(`Cue failed — Pins restored: ${r}`,!0,6500)}async function Y(){let e=Pe();if(e.length===0)return;if(!G){z("Local agentcue daemon is offline. Use Copy or start `npx agentcue`.",!0,5000);return}let r=M.has(x),a=!r;M.add(x),Q(M);let w=ge(x,r,e),h=[...e];f=[],_(!1),N();try{let y=await fetch(`${n}/api/cue`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)}),E=await y.json();if(!y.ok||!E.cueId){V(h,E.error||`HTTP ${y.status}`,a);return}if(q.has(E.cueId)){let K=q.get(E.cueId);q.delete(E.cueId),V(h,K,a);return}if(!Se.delete(E.cueId)){W.set(E.cueId,h);let K=E.queuePosition&&E.queuePosition>1?` (queued #${E.queuePosition})`:"",Z=r?" (continue)":" (new session)";z(`Sent ${h.length} Pin(s) → ${x}${Z}${K}`)}}catch(y){V(h,y instanceof Error?y.message:"Network error",a)}}ve.addEventListener("click",()=>_(!0)),nt.addEventListener("click",()=>_(!1)),F.addEventListener("click",()=>Le(!S)),U.addEventListener("click",(e)=>{e.stopPropagation(),I(!H)}),ne.addEventListener("click",()=>Ce()),R.addEventListener("click",()=>Ae()),D.addEventListener("click",()=>void $e()),we.addEventListener("click",()=>Te()),ke.addEventListener("click",()=>void Y()),g.addEventListener("input",()=>T()),g.addEventListener("keydown",(e)=>{if(e.key==="Enter"&&(e.metaKey||e.ctrlKey)){e.preventDefault(),e.stopPropagation(),Y();return}if(e.key==="Enter"&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),A(!0);return}if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),A(!1)}),L.addEventListener("click",()=>A(!0)),O.addEventListener("click",()=>void Y()),v.addEventListener("click",()=>{if(!b)return;f=f.filter((e)=>e.id!==b),b=null,m.classList.remove("visible"),g.blur(),N()});function ce(e){return e.composedPath().includes(t)}window.addEventListener("mousemove",(e)=>{if(!k||!S||b!==null||ce(e)){if(ce(e))B(null);return}let r=document.elementFromPoint(e.clientX,e.clientY),a=r===document.documentElement?document.body||r:r;if(a&&a!==t){if(a!==X)B(a)}else B(null)},{passive:!0});for(let e of["pointerdown","mousedown","mouseup","click"])window.addEventListener(e,(r)=>{if(H&&e==="pointerdown"&&!r.composedPath().includes(xe)&&!r.composedPath().includes(U))I(!1);if(!k||!S||ce(r))return;if(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),e!=="click")return;if(b!==null)A(!0);let a=r,w=document.elementFromPoint(a.clientX,a.clientY),h=w===document.documentElement?document.body||w:w;if(!h||h===t)return;let y=h.getBoundingClientRect(),E=y.width>0?P((a.clientX-y.left)/y.width,0.1,0.9):0.5,K=y.height>0?P((a.clientY-y.top)/y.height,0.1,0.9):0.5,Z={id:`${Date.now()}-${Math.random().toString(36).slice(2,7)}`,el:h,relX:E,relY:K,note:"",context:J(h)};f.push(Z),Me(Z.id)},{capture:!0});window.addEventListener("keydown",(e)=>{if((e.metaKey||e.ctrlKey)&&e.shiftKey&&e.code==="KeyF"){e.preventDefault(),e.stopPropagation(),_(!k);return}if(!k)return;if((e.metaKey||e.ctrlKey)&&e.key==="Enter"){if(b!==null||f.some((r)=>r.note.trim().length>0))e.preventDefault(),e.stopPropagation(),Y();return}if(e.key==="Escape"){if(e.preventDefault(),e.stopPropagation(),b!==null)A(!1);else if(H)I(!1);else _(!1);return}if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&b===null&&!je(e)){if(e.code==="KeyA")e.preventDefault(),I(!H);else if(H&&(e.key==="ArrowDown"||e.key==="ArrowUp"))e.preventDefault(),ot(e.key==="ArrowDown"?1:-1);else if(H&&e.key==="Enter")e.preventDefault(),I(!1);else if(/^Digit[1-9]$/.test(e.code)){let r=Number(e.code.slice(5))-1,a=re();if(r<a.length)e.preventDefault(),ae(a[r],!0)}else if(e.code==="KeyP")e.preventDefault(),Le(!S);else if(e.code==="KeyR")e.preventDefault(),Ce();else if(e.code==="KeyS"&&f.some((r)=>r.note.trim().length>0))e.preventDefault(),Y();else if(e.code==="KeyC"&&f.some((r)=>r.note.trim().length>0))e.preventDefault(),$e();else if(e.code==="KeyX"&&f.length>0)e.preventDefault(),Te();else if(e.code==="KeyH"&&f.length>0)e.preventDefault(),Ae()}},{capture:!0});let de=!1,Ie=()=>{if(de)return;de=!0,requestAnimationFrame(()=>{if(de=!1,f.length>0)N(!1);if(k&&S&&X)B(X)})};window.addEventListener("scroll",Ie,{capture:!0,passive:!0}),window.addEventListener("resize",Ie,{passive:!0});function st(){let e=new EventSource(`${n}/api/events`);e.onopen=()=>{G=!0,j()},e.onmessage=(r)=>{try{let a=JSON.parse(r.data);if(a.type==="state"){if(Ee=a.state,a.state.agents.length>0){if(ie=a.state.agents,!localStorage.getItem(he)&&a.state.defaultAgent)x=a.state.defaultAgent;le()}j()}else if(a.type==="cue:done"){if(!W.delete(a.cueId))Se.add(a.cueId);z(`${a.agent} finished in ${(a.durationMs/1000).toFixed(1)}s ✓`)}else if(a.type==="cue:error"){let w=W.get(a.cueId);if(W.delete(a.cueId),w)V(w,a.error);else q.set(a.cueId,a.error)}}catch{}},e.onerror=()=>{G=!1,j()}}return le(),T(),j(),st(),{togglePickMode:()=>_(!k)}}function bt(){if(typeof window<"u"&&window.__AGENTCUE_ORIGIN__)return window.__AGENTCUE_ORIGIN__.replace(/\/+$/,"");let n=document.currentScript;if(n?.src)try{let i=new URL(n.src,typeof window<"u"?window.location.href:"http://localhost:4318"),o=i.pathname.replace(/\/client\.js$/,"").replace(/\/+$/,"");return`${i.origin}${o}`}catch{}return"http://localhost:4318"}function ht(){if(typeof window>"u"||typeof document>"u")return;if(window.__AGENTCUE_INSTANCE__){window.__AGENTCUE_INSTANCE__.togglePickMode();return}let n=bt(),i=()=>{if(!window.__AGENTCUE_INSTANCE__)window.__AGENTCUE_INSTANCE__=We(n)};if(document.documentElement)i();else window.addEventListener("DOMContentLoaded",i,{once:!0})}ht();})();
489
+ `}var Q=["agy","claude","cursor-agent","codex","pi"];function Ve(t,n){let o=n?.transport??We(t),s=n?.stateStore??Oe(),r=n?.requireTrustedSend??!1,i=n?.resolveFrameworkHints,a=Fe(),d=a?"⌘↵":"Ctrl+↵",c=a?"⌘⇧F":"Ctrl+Shift+F",{host:g,shadow:u,hoverBox:h,hoverTag:O,pinsLayer:_,popover:E,popNum:F,popSel:Ze,popDelete:Je,popInput:S,popSave:Qe,popSend:et,toastEl:ee,agentMenu:he,agentMenuList:tt,launcherBtn:xe,launcherDot:nt,launcherText:ot,launcherCount:ve,capsule:it,statusDot:rt,pickBtn:U,agentBtn:q,agentLabel:st,contBtn:te,hideBtn:j,copyBtn:z,clearBtn:ye,sendBtn:we,sendCount:at,collapseBtn:lt}=Ge(d,c,n?.shadowMode??"open"),v=!1,k=!1,C=!1,G=!1,I=!1,ne=[...Q],b=s.getSelectedAgent()||"agy";if(!Q.includes(b))b="agy";let M=s.loadActiveSessions(),ke=null,f=[],ct=new Map,m=null,W=null,X=new Map,V=new Map,Ee=new Set,oe=null,ie=null;function re(){return ne.length>0?ne:[...Q]}function R(e,l=!1,p=3200){if(oe)clearTimeout(oe);ee.textContent=e,ee.className=l?"toast visible error":"toast visible",oe=setTimeout(()=>{ee.className="toast"},p)}function T(e){I=e,he.classList.toggle("visible",e),q.classList.toggle("menu-open",e)}function se(e,l=!0){if(b=e,s.setSelectedAgent(b),ae(),P(),Y(),l)T(!1)}function Se(){if(!M.has(b)){R(`Next Cue for ${b} will already start a new session`);return}M.delete(b),s.saveActiveSessions(M),P(),R(`Session reset · Next Cue starts a new ${b} session`)}function dt(e=1){let l=re(),p=l.indexOf(b),x=l[(p+e+l.length)%l.length];se(x,!1)}function ae(){let e=re();if(!e.includes(b))b=e[0];Re(st,tt,e,b,(l)=>se(l,!0))}function Y(){let{dotClass:e,statusTip:l,compactRunning:p}=_e(G,ke,b);rt.className=e,nt.className=e,q.setAttribute("data-tip",l),ot.textContent=p}function P(){xe.classList.toggle("hidden",v),it.classList.toggle("expanded",v),_.classList.toggle("hidden",C);let e=v&&k;U.classList.toggle("pick-active",e),U.innerHTML=e?me:Ue,U.setAttribute("data-tip",e?"Pause Pick · P":"Resume Pick · P");let l=M.has(b);te.classList.toggle("cont-active",l),te.setAttribute("data-tip",l?"Reset Session (in session) · R":"New Session (1st Cue)"),document.documentElement.style.cursor=e?"crosshair":"";let p=f.filter((L)=>L.note.trim().length>0).length,w=m!==null&&S.value.trim().length>0?f.filter((L)=>L.id!==m&&L.note.trim().length>0).length+1:p;ve.textContent=String(p),ve.classList.toggle("visible",!v&&p>0),j.innerHTML=C?qe:be,j.classList.toggle("hide-active",C),j.setAttribute("data-tip",C?"Show Pins · H":"Hide Pins · H"),j.disabled=f.length===0,at.textContent=w>0?String(w):"",we.disabled=w===0,z.disabled=w===0,ye.disabled=f.length===0}function N(e=!1){if(ze(_,ct,f,m,(l)=>{if(!v)A(!0);Ce(l)}),m){let l=f.find((p)=>p.id===m);if(l)fe(E,l,e)}P()}function D(e){W=e,Ke(h,O,e,v&&k&&m===null,i)}function Ce(e){let l=f.findIndex((w)=>w.id===e);if(l===-1)return;let p=f[l],x=E.classList.contains("visible");if(C=!1,T(!1),m=e,F.textContent=`#${l+1}`,Ze.textContent=p.context.sourceHint||p.context.selector,S.value=p.note,fe(E,p,x),!x)E.offsetWidth;E.classList.add("visible"),D(null),N(x),S.focus(),S.selectionStart=S.value.length}function H(e){if(!m)return;let l=f.find((p)=>p.id===m);if(l){if(e)l.note=S.value.trim();if(!l.note.trim())f=f.filter((p)=>p.id!==l.id)}m=null,E.classList.remove("visible"),S.blur(),N()}function Me(e){if(!e&&m)H(!0);if(k=e,!k)D(null);P()}function A(e){if(e)v=!0,C=!1,k=!0,P();else{if(m)H(!0);T(!1),k=!1,v=!1,D(null),P()}}function Ae(){m=null,E.classList.remove("visible"),f=[],C=!1,N()}function Le(){if(f.length===0)return;if(!C&&m)H(!0);C=!C,P()}function Te(){if(m)H(!0);return f.filter((e)=>e.note.trim().length>0)}async function Pe(){let e=Te();if(e.length===0)return;let l=Xe(ge(b,M.has(b),e));if(await navigator.clipboard.writeText(l),ie)clearTimeout(ie);z.classList.add("copied"),z.setAttribute("data-tip","Copied ✓"),ie=setTimeout(()=>{z.classList.remove("copied"),z.setAttribute("data-tip","Copy Markdown · C")},1600)}function Z(e,l,p=!1){if(p)M.delete(b),s.saveActiveSessions(M);let x=new Set(f.map((w)=>w.id));for(let w of e)if(!x.has(w.id))f.push(w);A(!0),N(),R(`Cue failed — Pins restored: ${l}`,!0,6500)}async function K(e){if(r&&!e?.isTrusted)return;let l=Te();if(l.length===0)return;if(!G){R("Local agentcue daemon is offline. Use Copy or start `npx agentcue`.",!0,5000);return}let p=M.has(b),x=!p;M.add(b),s.saveActiveSessions(M);let w=ge(b,p,l),L=[...l];f=[],A(!1),N();try{let y=await o.sendCue(w);if(!y.ok||!y.cueId){Z(L,y.error||`HTTP ${y.status}`,x);return}if(V.has(y.cueId)){let ce=V.get(y.cueId);V.delete(y.cueId),Z(L,ce,x);return}if(!Ee.delete(y.cueId)){X.set(y.cueId,L);let ce=y.queuePosition&&y.queuePosition>1?` (queued #${y.queuePosition})`:"",ut=p?" (continue)":" (new session)";R(`Sent ${L.length} Pin(s) → ${b}${ut}${ce}`)}}catch(y){Z(L,y instanceof Error?y.message:"Network error",x)}}xe.addEventListener("click",()=>A(!0)),lt.addEventListener("click",()=>A(!1)),U.addEventListener("click",()=>Me(!k)),q.addEventListener("click",(e)=>{e.stopPropagation(),T(!I)}),te.addEventListener("click",()=>Se()),j.addEventListener("click",()=>Le()),z.addEventListener("click",()=>void Pe()),ye.addEventListener("click",()=>Ae()),we.addEventListener("click",(e)=>void K(e)),S.addEventListener("input",()=>P()),S.addEventListener("keydown",(e)=>{if(e.key==="Enter"&&(e.metaKey||e.ctrlKey)){e.preventDefault(),e.stopPropagation(),K(e);return}if(e.key==="Enter"&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),H(!0);return}if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),H(!1)}),Qe.addEventListener("click",()=>H(!0)),et.addEventListener("click",(e)=>void K(e)),Je.addEventListener("click",()=>{if(!m)return;f=f.filter((e)=>e.id!==m),m=null,E.classList.remove("visible"),S.blur(),N()});function J(e){return e.composedPath().includes(g)}window.addEventListener("mousemove",(e)=>{if(!v||!k||m!==null||J(e)){if(J(e))D(null);return}let l=document.elementFromPoint(e.clientX,e.clientY),p=l===document.documentElement?document.body||l:l;if(p&&p!==g){if(p!==W)D(p)}else D(null)},{passive:!0}),u.addEventListener("pointerdown",(e)=>{if(I&&!e.composedPath().includes(he)&&!e.composedPath().includes(q))T(!1)});for(let e of["pointerdown","mousedown","mouseup","click"])window.addEventListener(e,(l)=>{if(r&&!l.isTrusted)return;if(I&&e==="pointerdown"&&!J(l))T(!1);if(!v||!k||J(l))return;if(l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),e!=="click")return;if(m!==null)H(!0);let p=l,x=Ne(p.clientX,p.clientY,g,i);if(!x)return;f.push(x),Ce(x.id)},{capture:!0});window.addEventListener("keydown",(e)=>{if(r&&!e.isTrusted)return;if((e.metaKey||e.ctrlKey)&&e.shiftKey&&e.code==="KeyF"){e.preventDefault(),e.stopPropagation(),A(!v);return}if(!v)return;if((e.metaKey||e.ctrlKey)&&e.key==="Enter"){if(m!==null||f.some((l)=>l.note.trim().length>0))e.preventDefault(),e.stopPropagation(),K(e);return}if(e.key==="Escape"){if(e.preventDefault(),e.stopPropagation(),m!==null)H(!1);else if(I)T(!1);else A(!1);return}if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&m===null&&!je(e)){if(e.code==="KeyA")e.preventDefault(),T(!I);else if(I&&(e.key==="ArrowDown"||e.key==="ArrowUp"))e.preventDefault(),dt(e.key==="ArrowDown"?1:-1);else if(I&&e.key==="Enter")e.preventDefault(),T(!1);else if(/^Digit[1-9]$/.test(e.code)){let l=Number(e.code.slice(5))-1,p=re();if(l<p.length)e.preventDefault(),se(p[l],!0)}else if(e.code==="KeyP")e.preventDefault(),Me(!k);else if(e.code==="KeyR")e.preventDefault(),Se();else if(e.code==="KeyS"&&f.some((l)=>l.note.trim().length>0))e.preventDefault(),K(e);else if(e.code==="KeyC"&&f.some((l)=>l.note.trim().length>0))e.preventDefault(),Pe();else if(e.code==="KeyX"&&f.length>0)e.preventDefault(),Ae();else if(e.code==="KeyH"&&f.length>0)e.preventDefault(),Le()}},{capture:!0});let le=!1,$e=()=>{if(le)return;le=!0,requestAnimationFrame(()=>{if(le=!1,f.length>0)N(!1);if(v&&k&&W)D(W)})};window.addEventListener("scroll",$e,{capture:!0,passive:!0}),window.addEventListener("resize",$e,{passive:!0});function pt(){o.subscribeEvents({onOpen:()=>{G=!0,Y()},onEvent:(e)=>{if(e.type==="state"){if(ke=e.state,e.state.agents.length>0){if(ne=e.state.agents,!s.getSelectedAgent()&&e.state.defaultAgent)b=e.state.defaultAgent;ae()}Y()}else if(e.type==="cue:done"){if(!X.delete(e.cueId))Ee.add(e.cueId);R(`${e.agent} finished in ${(e.durationMs/1000).toFixed(1)}s ✓`)}else if(e.type==="cue:error"){let l=X.get(e.cueId);if(X.delete(e.cueId),l)Z(l,e.error);else V.set(e.cueId,e.error)}},onError:()=>{G=!1,Y()}})}if(ae(),P(),Y(),pt(),n?.startActive)A(!0);return{togglePickMode:()=>A(!v),setActive:A,isActive:()=>v}}function Mt(){if(typeof window<"u"&&window.__AGENTCUE_ORIGIN__)return window.__AGENTCUE_ORIGIN__.replace(/\/+$/,"");let t=document.currentScript;if(t?.src)try{let n=new URL(t.src,typeof window<"u"?window.location.href:"http://localhost:4318"),o=n.pathname.replace(/\/client\.js$/,"").replace(/\/+$/,"");return`${n.origin}${o}`}catch{}return"http://localhost:4318"}function At(){if(typeof window>"u"||typeof document>"u")return;if(window.__AGENTCUE_INSTANCE__){window.__AGENTCUE_INSTANCE__.togglePickMode();return}let t=Mt(),n=()=>{if(!window.__AGENTCUE_INSTANCE__)window.__AGENTCUE_INSTANCE__=Ve(t)};if(document.documentElement)n();else window.addEventListener("DOMContentLoaded",n,{once:!0})}At();})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentcue",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Pick DOM nodes in the browser and push structured UI edit Cues straight to your local Agent CLI (agy, claude, cursor-agent, codex, pi).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://agentcue.yuler.dev",