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.
- package/README.md +15 -6
- package/dist/client.js +12 -12
- 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
|
|
111
|
-
| --------------------- |
|
|
112
|
-
| `packages/agentcue` | CLI, local HTTP/SSE bridge, Vite plugin, and overlay
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `examples/
|
|
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
|
|
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
|
|
414
|
-
`);for(let o of
|
|
415
|
-
<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 ${
|
|
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 (${
|
|
446
|
+
<button class="launcher" id="launcherBtn" title="Activate agentcue (${n})">
|
|
447
447
|
<span class="status-dot offline" id="launcherDot"></span>
|
|
448
|
-
${
|
|
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 / ${
|
|
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(
|
|
485
|
-
`)}function Xe(
|
|
486
|
-
`),s=
|
|
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
|
|
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.
|
|
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",
|