@popmelt.com/core 0.37.0 → 0.38.0
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 +30 -2
- package/THIRD_PARTY_NOTICES.md +236 -0
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/skills/popmelt-core/SKILL.md +5 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/codex-plugin/skills/popmelt-core/SKILL.md +5 -1
- package/dist/ExploreAttachment-IIEORQP3.mjs +1 -0
- package/dist/{PagePreviewLayer-KQ2FLIGX.mjs → PagePreviewLayer-AFSRCBAX.mjs} +1 -1
- package/dist/ParticipantRuntime-CGJH7YZL.mjs +1 -0
- package/dist/PhoneHostGate-OCIMKPLM.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-N2A5XPRO.mjs +1 -0
- package/dist/PreviewRuntime-3ANAJNFO.mjs +1 -0
- package/dist/QueuedReplies-5YG2DN3W.mjs +1 -0
- package/dist/SamplePlacementOverlay-EOJW6XGE.mjs +1 -0
- package/dist/ShareProjectPane-VYWTF3FW.mjs +1 -0
- package/dist/SuppliedContext-3S4HT6U6.mjs +1 -0
- package/dist/ThreadErrorCard-CTMVMETS.mjs +1 -0
- package/dist/ThreadPanel-G7OKSWD4.mjs +1 -0
- package/dist/adapter-react-three-fiber.d.mts +16 -3
- package/dist/adapter-react-three-fiber.mjs +1 -1
- package/dist/adapter-three.d.mts +22 -3
- package/dist/adapter-three.mjs +4 -4
- package/dist/bridge-entry.mjs +1 -1
- package/dist/bridge-recovery-NUYIGCFV.mjs +1 -0
- package/dist/bridgeSSEStream-HUFNXYPG.mjs +1 -0
- package/dist/bridgeWebSocketStream-AS22Y2FP.mjs +1 -0
- package/dist/browser-runtime-WXDKC4TL.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/canvas-chat-note-OLVVP55Y.mjs +1 -0
- package/dist/checkFixture-UNTXJKRN.mjs +1 -0
- package/dist/{chunk-I6FJ533W.mjs → chunk-25EXQOPI.mjs} +1 -1
- package/dist/{chunk-L6S66APQ.mjs → chunk-2F2BVGFH.mjs} +1 -1
- package/dist/chunk-2GICKLUW.mjs +1 -0
- package/dist/chunk-3DUTQ6GY.mjs +1 -0
- package/dist/{chunk-76WRZ2NH.mjs → chunk-3LZQLRZ2.mjs} +1 -1
- package/dist/{chunk-IAXSC2ZN.mjs → chunk-43BZCDGL.mjs} +1 -1
- package/dist/{chunk-WC4ZNVFM.mjs → chunk-5F34UIKL.mjs} +1 -1
- package/dist/{chunk-ECMLCGAM.mjs → chunk-6RMM7JB6.mjs} +1 -1
- package/dist/{chunk-DO46YJCX.mjs → chunk-6V4Q2JFN.mjs} +1 -1
- package/dist/{chunk-MHWIFSXJ.mjs → chunk-7MYZEG74.mjs} +1 -1
- package/dist/{chunk-6O5QLRSA.mjs → chunk-ACBGA4NT.mjs} +1 -1
- package/dist/{chunk-B22WBEQC.mjs → chunk-B3RA4XAR.mjs} +1 -1
- package/dist/{chunk-FON4QY7P.mjs → chunk-BEGAJYOY.mjs} +1 -1
- package/dist/{chunk-YVT3J6JB.mjs → chunk-BJUSVIDN.mjs} +1 -1
- package/dist/chunk-BOZVNUHJ.mjs +1 -0
- package/dist/chunk-BRAEIDNX.mjs +30 -0
- package/dist/chunk-CRZEJJI6.mjs +1 -0
- package/dist/{chunk-CIA6WVXQ.mjs → chunk-DBCBG5J6.mjs} +1 -1
- package/dist/{chunk-RUJC32MA.mjs → chunk-EFWBHWHP.mjs} +1 -1
- package/dist/{chunk-WDSFOF2E.mjs → chunk-F3VZQGPM.mjs} +1 -1
- package/dist/{chunk-EZVFCJEG.mjs → chunk-FYURSPM3.mjs} +1 -1
- package/dist/{chunk-DRPRASD6.mjs → chunk-G6BN5TAZ.mjs} +1 -1
- package/dist/chunk-GTVTUWGH.mjs +1 -0
- package/dist/{chunk-I7AI52RX.mjs → chunk-JAMYVQFC.mjs} +1 -1
- package/dist/chunk-JJK4LAN6.mjs +1 -0
- package/dist/{chunk-SOT33EQ4.mjs → chunk-JJRKR4X3.mjs} +1 -1
- package/dist/{chunk-XY7YW7SH.mjs → chunk-KHDXOXYF.mjs} +1 -1
- package/dist/chunk-KL5ODVJA.mjs +1 -0
- package/dist/{chunk-MDPZUECK.mjs → chunk-L356S4EY.mjs} +1 -1
- package/dist/{chunk-IGKU4YIV.mjs → chunk-O2OYVEL7.mjs} +1 -1
- package/dist/{chunk-YYFF2X3L.mjs → chunk-P2WAXWAZ.mjs} +1 -1
- package/dist/{chunk-EUFR7R5Q.mjs → chunk-QXFBFKN6.mjs} +1 -1
- package/dist/chunk-RJWFSAKE.mjs +1 -0
- package/dist/{chunk-FJWWBKCQ.mjs → chunk-RWZ7SVMO.mjs} +1 -1
- package/dist/{chunk-JLK3VRBT.mjs → chunk-SKM4ZXV5.mjs} +1 -1
- package/dist/{chunk-EBJ23A7F.mjs → chunk-TEXVTTWA.mjs} +1 -1
- package/dist/{chunk-QXVMGZFP.mjs → chunk-TSQEBZYO.mjs} +1 -1
- package/dist/{chunk-JEGBAHYK.mjs → chunk-TVIKC33M.mjs} +1 -1
- package/dist/{chunk-JCW2WY7X.mjs → chunk-TXL2CR66.mjs} +1 -1
- package/dist/{chunk-B2ISA6V6.mjs → chunk-W62YY5IT.mjs} +1 -1
- package/dist/{chunk-BYASSHKJ.mjs → chunk-WIJSWSNF.mjs} +1 -1
- package/dist/{chunk-NI77Y3WC.mjs → chunk-WJVRGXOS.mjs} +1 -1
- package/dist/{chunk-PILMDBAX.mjs → chunk-WNOLXY3Y.mjs} +1 -1
- package/dist/{chunk-BVGHHT3Y.mjs → chunk-X56HNVHF.mjs} +1 -1
- package/dist/chunk-Y3WTPLDG.mjs +1 -0
- package/dist/chunk-YGP6PPOZ.mjs +1 -0
- package/dist/{chunk-LOUWY55X.mjs → chunk-ZHXTB5IN.mjs} +1 -1
- package/dist/chunk-ZSTKAPV5.mjs +24 -0
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-WYH7D6SS.mjs +1 -0
- package/dist/{codex-project-LIU27RXA.mjs → codex-project-Q4CKTDOH.mjs} +1 -1
- package/dist/{codex-store-mount-EPETPOBA.mjs → codex-store-mount-RSRKEV2B.mjs} +1 -1
- package/dist/dev-server-SDS67665.mjs +1 -0
- package/dist/focus-inspection-LGIRFL2T.mjs +1 -0
- package/dist/guest-admission.mjs +1 -1
- package/dist/guest-live-canvas.mjs +1 -1
- package/dist/index.d.mts +27 -6
- package/dist/index.mjs +1 -1
- package/dist/inviteQr-YK3JAR6U.mjs +1 -0
- package/dist/media.d.mts +3 -3
- package/dist/media.mjs +1 -1
- package/dist/memory-legacy.mjs +1 -1
- package/dist/memory-store.mjs +1 -1
- package/dist/{participantBootstrap-DuosDN9G.d.mts → participantBootstrap-BTcD7XgB.d.mts} +2 -2
- package/dist/{peer-client-RSC6EGAF.mjs → peer-client-HYSUL7UZ.mjs} +1 -1
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.d.mts +3 -1
- package/dist/server.mjs +1 -1
- package/dist/{subjects-BhO1x5tz.d.mts → subjects-D_yanOQ2.d.mts} +6 -0
- package/dist/taste-proposal-session-AAXK4CFL.mjs +1 -0
- package/dist/toolbarFonts-JAGSN3DN.mjs +1 -0
- package/dist/{video-adapter-B8J5awc_.d.mts → video-adapter-CWpR4NSt.d.mts} +1 -1
- package/dist/webpEncoder-MTPCVDOG.mjs +1 -0
- package/dist/workspace-snapshot-RUGPDEYJ.mjs +1 -0
- package/package.json +26 -35
- package/dist/ExploreAttachment-IO3CNUWH.mjs +0 -1
- package/dist/ParticipantRuntime-Y2BQVJSL.mjs +0 -1
- package/dist/PhoneHostGate-2G4BA5FP.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-H5QWBFD7.mjs +0 -1
- package/dist/PreviewRuntime-V2PZF462.mjs +0 -1
- package/dist/QueuedReplies-4APDDNQX.mjs +0 -1
- package/dist/SamplePlacementOverlay-ELSP5AHM.mjs +0 -1
- package/dist/ShareProjectPane-OR2LS2A3.mjs +0 -1
- package/dist/SuppliedContext-SAQKEDWW.mjs +0 -1
- package/dist/ThreadErrorCard-OSHIWSHR.mjs +0 -1
- package/dist/ThreadPanel-YPL2HDUC.mjs +0 -1
- package/dist/bridge-recovery-3IQN3U6D.mjs +0 -1
- package/dist/bridgeSSEStream-6OMAFDFW.mjs +0 -1
- package/dist/bridgeWebSocketStream-WIOGOPJW.mjs +0 -1
- package/dist/browser-runtime-O3EKN3FI.mjs +0 -1
- package/dist/canvas-chat-note-O3USBECW.mjs +0 -1
- package/dist/checkFixture-SOSI7AT4.mjs +0 -1
- package/dist/chunk-4OEHQ6M7.mjs +0 -24
- package/dist/chunk-4YQWU5YB.mjs +0 -1
- package/dist/chunk-AGYBVMHX.mjs +0 -1
- package/dist/chunk-LXFKOYLK.mjs +0 -1
- package/dist/chunk-NXTWB3A7.mjs +0 -1
- package/dist/chunk-OFJUTWJU.mjs +0 -1
- package/dist/chunk-PLE6FFKY.mjs +0 -1
- package/dist/chunk-ROKRMYFR.mjs +0 -1
- package/dist/chunk-SNAJBV7T.mjs +0 -30
- package/dist/chunk-TQ3SP5TE.mjs +0 -1
- package/dist/chunk-YU3ZY76H.mjs +0 -1
- package/dist/codex-note-context-UI55CWRI.mjs +0 -1
- package/dist/dev-server-WYB2CRC5.mjs +0 -1
- package/dist/focus-inspection-42IEM45O.mjs +0 -1
- package/dist/inviteQr-U77MLSEQ.mjs +0 -1
- package/dist/taste-proposal-session-DBOUA54V.mjs +0 -1
- package/dist/toolbarFonts-GVPRHJGB.mjs +0 -1
- package/dist/workspace-snapshot-6LN7U2NJ.mjs +0 -1
- /package/dist/{chunk-PWQB3FIW.mjs → chunk-AWWUJO3N.mjs} +0 -0
- /package/dist/{chunk-SQA27YGA.mjs → chunk-FIOGWEZA.mjs} +0 -0
- /package/dist/{chunk-W2QQVB2H.mjs → chunk-VXRRHXUP.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as t,f as e}from"./chunk-
|
|
1
|
+
import{d as t,f as e}from"./chunk-O2OYVEL7.mjs";import{C as a,h as r,q as i}from"./chunk-BRAEIDNX.mjs";import{readFile as o,realpath as n,mkdir as s,writeFile as c}from"fs/promises";import{createHash as p}from"crypto";import{join as d,resolve as l}from"path";function u(t,e){let a=p("sha256").update(e).digest("hex");return d(t,".popmelt","participant-agents",a+".json")}async function f(t,a){if(a.storeId!==t.storeId)return{ok:!1,body:{status:"writable_store_required"}};if("string"!=typeof a.threadId||!a.threadId||"string"!=typeof a.text||!a.text.trim()||a.text.length>8e3)return{ok:!1,body:{status:"invalid_note"}};let r;try{r=await h(t,t.sessionId,!0)}catch(t){if("ENOENT"!==t.code)throw t;return{ok:!1,body:{status:"participant_invitation_required"}}}if(!r)return{ok:!1,body:{status:"enrolled_bridge_required"}};let i=await e(r.endpoint,"/participants/thread-note",{...r.request,method:"POST",signal:AbortSignal.timeout(3e4),body:JSON.stringify({storeId:t.storeId,threadId:a.threadId,reply:a.text,sessionId:t.sessionId,requestId:a.requestId})});return{ok:i.response.ok,body:i.body}}async function h(t,a,s=!1){let c=await o(d(t.projectRoot,".popmelt","participant-bridge.json"),"utf8").then(JSON.parse).catch(e=>{if("ENOENT"!==e.code||!t.bridgePort)throw e;return{projectId:t.projectId,port:t.bridgePort}});if(c.projectId!==t.projectId||!Number.isInteger(c.port)||c.port<1||c.port>65535)return null;let p={redirect:"error",signal:AbortSignal.timeout(3e3)},l=await e(c,"/status",p);if(!l.response.ok||l.body?.projectId!==t.projectId)return null;let f,h=u(t.projectRoot,a);try{f=JSON.parse(await o(h,"utf8"))}catch(l){if("ENOENT"!==l.code||!s)throw l;let u=await n(t.projectRoot),m=i(a);if(r(u)!==t.projectId||!m)return null;let g=JSON.parse(await o(d(u,".popmelt","participant-host.json"),"utf8"));if(!(await e(c,"/participants/agent-join",{...p,method:"POST",headers:{"X-Popmelt-Participant-Id":g.participantId,"X-Popmelt-Participant-Token":g.token},body:JSON.stringify({sessionId:a,name:m,headless:!0})})).response.ok)return null;f=JSON.parse(await o(h,"utf8"))}return{endpoint:c,request:{...p,headers:{"X-Popmelt-Participant-Id":f.participantId,"X-Popmelt-Participant-Token":f.token}}}}async function m(t,a,r){let i=[t,...t.mountedStores].find(t=>t.storeId===a.storeId);if(!i||r&&i!==t)return{ok:!1,body:{status:"store_unavailable"}};if(r&&("string"!=typeof a.threadId||!a.threadId))return{ok:!1,body:{status:"thread_required"}};let o=await h(i,t.sessionId,r).catch(t=>{if("ENOENT"===t.code)return null;throw t});if(!o)return{ok:!1,body:{status:"enrolled_bridge_required",message:"Join this project as a Popmelt peer and check that its bridge is running."}};let{endpoint:n,request:s}=o,c=await e(n,r?t.sessionId.startsWith("claude:")?"/participants/link-claude-chat":"/participants/link-codex-chat":"/participants/check-claude-notes",{...s,method:"POST",body:JSON.stringify({sessionId:t.sessionId,...r?{threadId:a.threadId}:{}})});return{ok:c.response.ok,body:c.body}}async function g(i,l,f={}){if(t())return{status:"already_managed_by_bridge"};if((await e(i,"/status",{redirect:"error",signal:AbortSignal.timeout(3e3)})).body?.participantSessions)return async function(t,i,l){if(!l.projectRoot)throw new Error("Participant connections require the active project root");let f=await n(l.projectRoot);if(r(f)!==t.projectId)throw new Error("Participant project does not match");let h,m,g=d(f,".popmelt"),w=p("sha256").update(i).digest("hex"),I=async(a,r,i)=>{let o=await e(t,"/participants/"+a,{method:"POST",redirect:"error",headers:{"X-Popmelt-Participant-Id":r.participantId,"X-Popmelt-Participant-Token":r.token},body:JSON.stringify(i),signal:AbortSignal.timeout(9e4)}),n=o.body;if(!o.response.ok||n.error)throw new Error(n.error??"Participant connection unavailable");return n};try{h=JSON.parse(await o(u(f,i),"utf8"))}catch(t){if("ENOENT"!==t.code)throw t;if(!l.name)return{status:"participant_invitation_required"};let e=JSON.parse(await o(d(g,"participant-host.json"),"utf8")),a=await I("agent-join",e,{sessionId:i,name:l.name});h=a.credential,m=a.participant}if(!l.action){let t=await I("agent-connect",h,{});return{status:"participant_connected",participantId:h.participantId,participant:t.participant??m}}let y=await I("agent-act",h,{action:a(l.action)}),b=y.evidence;if(b?.frame?.image){let t=b.frame.image;if(!/^data:image\/jpeg;base64,[A-Za-z0-9+/=]+$/.test(t)||t.length>7e5)throw new Error("Invalid participant preview");let e=d(g,"artifacts","participant-previews");await s(e,{recursive:!0,mode:448});let a=d(e,w+".jpg");return await c(a,Buffer.from(t.slice(t.indexOf(",")+1),"base64"),{mode:384}),{status:"participant_connected",participant:y.participant,evidence:{...b,frame:{imagePath:a,targets:b.frame.targets}}}}return{status:"participant_connected",participant:y.participant,evidence:y.evidence}}(i,l,f);let h=async(t,a)=>{let r=await e(i,`/peers/${t}`,{method:"POST",body:JSON.stringify(a),signal:AbortSignal.timeout(5e4)}),o=r.body;if(!r.response.ok||o?.error)throw new Error(o?.error??"Peer connection unavailable");return o},m=await h("join",{sessionId:l,name:f.name}),g=f.action?await h("act",{token:m.token,clientId:f.clientId,action:a(f.action)}):m,w=g.peer;return{...g.status?{status:g.status}:{},...w?{peer:{...w,state:w.state?{annotations:w.state.annotations,styleModifications:w.state.styleModifications,textModifications:w.state.textModifications,undoDepth:w.state.undoStack.length,redoDepth:w.state.redoStack.length}:null}}:{},...g.evidence?{evidence:g.evidence}:{},clients:m.clients}}async function w(t){let a=e=>{let a=t.indexOf(e);return a>=0?t[a+1]:void 0},i=a("--session");if(!i)throw new Error("Usage: popmelt peer --session <stable-agent-session> [--project-root <active-project>] [--name <your-name>] [--client <canvas-id>] [--action <JSON>]");let s=await n(l(a("--project-root")??process.cwd())),c=JSON.parse(await o(d(s,".popmelt","bridge.lock"),"utf8")),p=r(s),u=await e({port:c.port,projectId:p},"/status",{signal:AbortSignal.timeout(3e3)});if(!u.response.ok||u.body.projectRoot!==s&&(!u.body.participantSessions||u.body.projectId!==p))throw new Error("No matching running project bridge");let f=a("--action");console.log(JSON.stringify(await g({port:c.port,projectId:p},i,{name:a("--name"),projectRoot:s,clientId:a("--client"),action:f?JSON.parse(f):void 0}),null,2))}export{u as a,f as b,h as c,m as d,g as e,w as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{f as e}from"./chunk-
|
|
1
|
+
"use client";import{f as e}from"./chunk-VXRRHXUP.mjs";import{e as t,f as n}from"./chunk-AAMUU2QA.mjs";import{u as a,d as i}from"./chunk-LH7HKUCK.mjs";import{createContext as r}from"react";function o(e,t){let n=a(e.filter(e=>!e.includes("data-pm=")),t);return"matched"===n.status?n.element:null}function l(e){if(!e||!/^\/(?!\/)/.test(e)||/[\\?#\s]/.test(e))return;let t=n(e);return t.startsWith("//")||t.startsWith("/__popmelt/")?void 0:new URL(t,"https://local.invalid").pathname===t?t:void 0}function s(e){let t,n=e.messages?.find(e=>"human"===e.role),a=n?.annotationSnapshot;try{if(a?.url){let e=new URL(a.url);/^https?:$/.test(e.protocol)&&(t=e)}}catch{}let i=a?.annotations?.[0],r=n?.requestItems?.find(e=>"changes"===e.kind),o=(e.targetBindings??[]).map(e=>e.anchor),s=o.find(e=>"dom"===e.type),m=[...e.elementIdentifiers??[],...r?[r.elementKey]:[]],c=l(t?.pathname),p=l(s?.pathname)??l(i?.pathname)??l(r?.pathname)??l(m.find(e=>e.startsWith("/")&&e.includes(":"))?.split(":")[0])??c,u=o.filter(e=>"opaque"===e.type||l(e.pathname)===p),f=!i||i.pathname&&l(i.pathname)!==p?void 0:i;f?.target&&u.push({type:"opaque",...f.target});let h=f?.elements?.[0];!f?.region&&(f?.linkedSelector||h)&&u.push({type:"dom",pathname:p??"/",structuralSelector:h?.selector,runtimeSelector:f?.linkedSelector,targetFingerprint:h?.targetFingerprint});for(let e of m){let t=e.indexOf(":"),n=e.startsWith("/")?t>0&&l(e.slice(0,t))===p?e.slice(t+1):"":c&&c===p?e:"";n&&u.push({type:"dom",pathname:p??"/",structuralSelector:n})}let d=f?.region;if(!(u.length||d?.points.length||f||r))return null;let g=c===p&&t?t.search+t.hash:"";return{pathname:p,href:p&&p+g,targets:u,region:d,element:h}}function m(e){return n(location.pathname)+location.search+location.hash===e}function c(e){try{let t=sessionStorage.getItem(e);if(!t)return;sessionStorage.removeItem(e);let n=JSON.parse(t);if(n.expires>Date.now()&&"string"==typeof n.id&&m(n.href))return n.id}catch{}}function p(n,a,r){let l,s=!1,p=new AbortController,u=()=>{s=!0,clearTimeout(l),p.abort()};for(let e of["wheel","pointerdown","touchstart","keydown"])window.addEventListener(e,u,{capture:!0,passive:!0,signal:p.signal});let{href:f}=a;return async function(){if(f&&!m(f)){try{sessionStorage.setItem(r.storageKey,JSON.stringify({id:n,href:f,expires:Date.now()+3e4}))}catch{}if(r.navigate)await r.navigate(f);else{let e=new URL(t(location.pathname).slice(0,-1)+f,location.origin),n=e.pathname!==location.pathname||e.search!==location.search;if(location.assign(e.href),n)return}}let p=performance.now()+4e3,h=!1,d=null,g=0,x=!1,y=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",w=async()=>{if(!s){if(!f||m(f)){!x&&f&&c(r.storageKey),x=!0;let t=d?.isConnected?d:function(e,t){for(let n of e)if("opaque"===n.type){let e=t.resolve(n);if(e)return e.subject.sourceElement??e.element}else{let e=o([n.structuralSelector,n.runtimeSelector,...n.legacySelectors??[]].filter(e=>!!e),n.targetFingerprint);if(e)return e}return null}(a.targets,r.registry);if(t){for(let e=t.parentElement;e;e=e.parentElement)e instanceof HTMLDetailsElement&&!e.open&&(e.open=!0);let e=i(t),n=e.bottom<=0||e.top>=innerHeight||e.right<=0||e.left>=innerWidth;e.height&&e.width&&(d!==t||n&&performance.now()-g>750)&&(t.scrollIntoView({behavior:d?"instant":y,block:"center",inline:"nearest"}),d=t,g=performance.now())}if(!d&&!h&&a.element?.revealRecipe&&(h=!0,await e(void 0,[a.element]),s))return;if(!t&&a.region?.points.length){let e=a.region.points.map(e=>e.x),t=a.region.points.map(e=>e.y);return window.scrollTo({left:(Math.min(...e)+Math.max(...e)-innerWidth)/2,top:(Math.min(...t)+Math.max(...t)-innerHeight)/2,behavior:y}),u()}if(!a.targets.length)return u()}else if(x)return u();performance.now()<p?l=setTimeout(()=>{w().catch(u)},d?250:160):u()}};await w()}().catch(u),u}function u(e,t){return"string"==typeof t.canvasLabel?t.canvasLabel:[e,t.modified].filter(Boolean).join(" ")}function f(e){return S(e,512)||"Empty text"}function h(e){if("changes"!==e.kind)return;if("string"==typeof e.replacementText)return e.replacementText;let t=[];for(let n of e.changes){if(!n.startsWith("Text: "))return;let e=n.slice(6).split(" → ");if(2!==e.length)return;t.push("empty"===e[1]?"":e[1])}return t.length?t.join(" "):void 0}function d(e){if(!e?.length)return;let t=[];for(let n of e){let e=h(n);if(void 0===e)return;t.push(e.replace(/\s+/g," ").trim()||"Empty text")}return t.join("; ")}function g(e=[]){let t={};if(e.some(e=>"annotation"===e.kind))return t;for(let n of e){if("changes"!==n.kind)continue;let e=h(n);void 0!==e&&(t[n.elementKey]=f(e))}return t}function x(e){let t=e?.requestItems?.flatMap(e=>"annotation"===e.kind&&e.text.trim()?[e.text.trim()]:[]);if(t?.length)return t.join("; ");let n=e?.requestItems?.flatMap(e=>"changes"===e.kind?[`${e.elementLabel} [${e.changes.join(", ")}]`]:[]);return n?.length?n.join("; "):e?.requestText?.trim()||void 0}function y(e,t){if(!e?.frames?.length)return[];let n=new Map;for(let t of e.steps){let e=t.visuals?.afterFrameId;e&&!n.has(e)&&n.set(e,t.action?.label?`After ${t.action.label}`:"Resulting state")}return e.frames.flatMap((e,a)=>{let i=t[e.imageIndex];return i?[{id:e.id,imageIndex:e.imageIndex,label:0===a?"Initial state":n.get(e.id)??"State",url:i}]:[]})}function w(e){let t=e.instruction?.trim();return t?e.attachments?.some(e=>e.name?.trim()===t)?null:t:null}function v(e,t){let n=e?.tagName?.toLowerCase(),a=e?.id?`#${e.id}`:"",i=e?.className?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",r=n?`${n}${a}${i}`:t;return e?.reactComponent?`<${e.reactComponent}> ${r}`:r}function $(e){let t=e.elements?.[0]?.reactComponent||e.elements?.[0]?.tagName||e.linkedSelector,n=e.type&&"annotation"!==e.type?`${e.type} annotation`:"Annotation";return t?`${n} on ${t}`:n}function b(e){let t=e.annotations.map(e=>{let t=e.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:e.id,pathname:e.pathname,text:w(e)??$(e),...t>0?{interactionEpisodeStepCount:t}:{}}}),n=new Map,a=e=>{let a=`${e.pathname??""}:${e.durableSelector??e.selector}`,i=n.get(a);if(i)return i.changes.push(e.text),void 0!==i.replacementText&&e.textEdit?i.replacementText=u(i.replacementText,e.textEdit):delete i.replacementText,void(void 0!==e.annotationNumber&&(void 0===i.annotationNumber||e.annotationNumber<i.annotationNumber)&&(i.annotationNumber=e.annotationNumber));let r={kind:"changes",elementKey:a,elementLabel:v(e.element,e.selector),...void 0!==e.annotationNumber?{annotationNumber:e.annotationNumber}:{},pathname:e.pathname,changes:[e.text],...e.textEdit?{replacementText:u(void 0,e.textEdit)}:{}};n.set(a,r),t.push(r)};for(let t of e.styleModifications??[])for(let e of t.changes)a({...t,text:`${e.property}: ${e.original||"unset"} → ${e.modified||"unset"}${e.token?` (${e.token})`:""}`});for(let t of e.textModifications??[])a({...t,textEdit:t,text:`Text: ${t.original||"empty"} → ${t.modified||"empty"}`});for(let t of e.domModifications??[])a({...t,text:"copy"===t.operation?"Copied element":"Moved element"});return e.spacingTokenChanges?.length&&t.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:e.spacingTokenChanges.map(e=>`${e.tokenName}: ${e.originalPx}px → ${e.newPx}px`)}),t}function k(e){let t=e.annotations.flatMap(e=>{let t=w(e);return t?[{instruction:t,pathname:e.pathname}]:[]});if(0===t.length)return;if(new Set(t.map(e=>e.pathname).filter(Boolean)).size<=1)return t.map(e=>e.instruction).join("\n\n");let n=new Map;for(let e of t){let t=e.pathname||"(unknown)",a=n.get(t)??[];a.push(e.instruction),n.set(t,a)}return[...n.entries()].map(([e,t])=>`\`${e}\`\n${t.map(e=>`- ${e}`).join("\n")}`).join("\n")}function S(e,t=96){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(0,t-3))}...`:n}var M=r(null),N=r(void 0);export{o as a,s as b,c,p as d,u as e,f,d as g,g as h,x as i,y as j,b as k,k as l,S as m,M as n,N as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{i as e,g as t,a as r}from"./chunk-AGCS65LT.mjs";import{b as n}from"./chunk-SUAHDXJZ.mjs";var a=new Set;function o(e,t){let n=new URL(e).origin;"websocket"===t&&new URL(e).pathname!==r?a.add(n):a.delete(n)}function i(t){return a.has(new URL(t).origin)?new s(t,!0):e(t)?new s(t):new EventSource(t)}var s=class{constructor(e,t=!1){this.readyState=0,this.onerror=null,this.controller=new AbortController,this.listeners=new Map,this.fail=()=>{this.controller.signal.aborted||(this.readyState=2,this.controller.abort(),this.emit("error",""),this.onerror?.call(this,new Event("error")))},typeof document<"u"&&document.addEventListener("resume",this.fail,{signal:this.controller.signal}),this.read(e,t)}addEventListener(e,t){let r=this.listeners.get(e)??new Set;r.add(t),this.listeners.set(e,r)}close(){this.readyState=2,this.controller.abort(),this.listeners.clear()}emit(e,t){let r=new MessageEvent(e,{data:t});for(let t of this.listeners.get(e)??[])t(r)}async read(e,t){try{if(t){let{readBridgeWebSocket:t}=await(import("./bridgeWebSocketStream-WIOGOPJW.mjs"));return void await t(e,this.controller.signal,(e,t)=>{"connected"===e&&(this.readyState=1),this.emit(e,t)})}let{readBridgeSSE:r}=await(import("./bridgeSSEStream-6OMAFDFW.mjs"));await r(e,this.controller.signal,()=>{this.readyState=1},(e,t)=>this.emit(e,t))}catch{this.fail()}}},l="http://localhost:1111",c=new Map;function d(){return typeof window<"u"?window.__POPMELT_PROJECT_ID__??null:null}function u(e,r={}){return t(e,function(e={}){let t=d();if(!t)return e;let r=new Headers(e.headers);return r.set("X-Popmelt-Project-Id",t),{...e,headers:r}}(r))}async function p(e,t,r){let n=new URLSearchParams({annotationId:t,kind:r.kind,name:r.name}),a=await g(`${e}/draft-attachments?${n}`,{method:"POST",headers:{"Content-Type":r.blob.type},body:r.blob},15e3);if(!a.ok)throw new Error((await a.json().catch(()=>null))?.error||`Bridge returned ${a.status}`);return(await a.json()).attachment}async function h(e,t){0!==t.length&&await g(`${e}/draft-attachments/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:t})},5e3)}async function f(e,t){await g(`${e}/draft-attachments/${encodeURIComponent(t)}`,{method:"DELETE"},5e3)}async function w(e,t){if((c.get(e)??0)>Date.now())return null;try{let r=await g(`${e}/capture/native`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageUrl:t.url,clip:t.clip,scale:t.scale})},2500);if(!r.ok)return c.set(e,Date.now()+(404===r.status||501===r.status?6e4:1e4)),null;let n=await r.blob();return n.size>0?n:null}catch{return c.set(e,Date.now()+1e4),null}}function g(e,t={},r=15e3){let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let a=setTimeout(()=>n.abort(),r);return u(e,{...t,signal:n.signal}).finally(()=>clearTimeout(a))}async function m(e=l){try{let t=await g(`${e}/ui-preferences`,{},5e3);return t.ok?await t.json():null}catch{return null}}async function y(e,t){try{let r=await g(`${e}/ui-preferences`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:t})},5e3);return r.ok?await r.json():null}catch{return null}}async function $(e=l,t){try{let r=t?`?refresh=${encodeURIComponent(t)}`:"",n=await g(`${e}/capabilities${r}`,{},t?35e3:5e3);return n.ok?await n.json():null}catch{return null}}async function b(e,t,r="/status"){let n=new AbortController,a=setTimeout(()=>n.abort(),t);try{let t=await u(`${e}${r}`,{signal:n.signal});if(!t.ok)return null;let a=await t.json();return o(e,a.eventTransport),a}catch{return null}finally{n.abort(),clearTimeout(a)}}async function I(e=l){return b(e,2e3)}async function j(e){return b(`http://localhost:${e}`,500,"/status?discovery=1")}async function S(e){return I(e)}async function k(e,t){if(typeof location<"u"&&e&&(e===location.origin+r||n(e??""))){let r=await S(e);return t&&r?.projectId===t?{url:e,port:Number(location.port)||443,projectId:t}:null}if(e&&e!==l)try{let r=new URL(e),n=await S(e);if(!n&&!t)return null;if((n||!t)&&(!n||!t||n.projectId===t)){if(n?.projectId&&!t)return null;if(n)return{url:e,port:parseInt(r.port,10)||1111,projectId:n.projectId}}}catch{if(!t)return null}let a=typeof window<"u"?window.location.origin:null,o=await j(1111);if(o){if(t&&o.projectId===t)return{url:"http://localhost:1111",port:1111,projectId:o.projectId};if(o.devOrigin&&a&&o.devOrigin===a&&!t&&!o.projectId)return{url:"http://localhost:1111",port:1111,projectId:o.projectId}}let i=function(e=1111){return Array.from({length:Math.min(32,65536-e)},(t,r)=>e+r)}().slice(1).map(e=>j(e).then(t=>t?{status:t,port:e}:null)),s=(await Promise.all(i)).filter(e=>null!==e),c=[];o&&c.push({port:1111,devOrigin:o.devOrigin,projectId:o.projectId});for(let e of s)c.push({port:e.port,devOrigin:e.status.devOrigin,projectId:e.status.projectId});if(t){let e=c.find(e=>e.projectId===t);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}if(a){let e=c.find(e=>e.devOrigin===a&&!e.projectId);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}return 1!==c.length||c[0].projectId?null:{url:`http://localhost:${c[0].port}`,port:c[0].port,projectId:c[0].projectId}}async function v(e=l,t,r=-1,n={}){try{let a=await g(`${e}/jobs/${t}/events?afterSeq=${r}`,{},5e3);if(404===a.status||410===a.status)return null;if(!a.ok){if(n.retryUnavailable&&(429===a.status||a.status>=500))throw new Error("Bridge history is temporarily unavailable");return null}return await a.json()}catch(e){if(n.retryUnavailable)throw e;return null}}async function T(e,t,r=l,n,a,o,i,s,c,d,u,p,h){let f=O({screenshots:e,feedbackJson:t,color:n,provider:a,model:o,pastedImages:i,sourceId:s,agentSettings:c,continuationThreadId:d,continuationSelectorAliases:u,continuationTargetBindingId:p}),w=await g(`${r}/send`,{method:"POST",body:f,...h?{headers:{"X-Popmelt-Peer-Grant":h}}:{}},3e4);if(!w.ok){let e=await w.text();throw new Error(`Bridge returned ${w.status}: ${e}`)}return w.json()}function O({screenshots:e,feedbackJson:t,color:r,provider:n,model:a,pastedImages:o,sourceId:i,agentSettings:s,continuationThreadId:l,continuationSelectorAliases:c,continuationTargetBindingId:d}){let u=new FormData;if(e instanceof Map){let t=!0;for(let[r,n]of e){let e=encodeURIComponent(r);u.append(`screenshot-${e}`,n,`screenshot-${e}.webp`),t&&(u.append("screenshot",n,"screenshot.webp"),t=!1)}t&&u.append("screenshot",new Blob([],{type:"image/webp"}),"screenshot.webp")}else u.append("screenshot",e,"screenshot.webp");if(u.append("feedback",t),r&&u.append("color",r),n&&u.append("provider",n),a&&u.append("model",a),function(e,t){t?.reasoningEffort&&e.append("reasoningEffort",t.reasoningEffort),t?.serviceTier&&e.append("serviceTier",t.serviceTier)}(u,s),i&&u.append("sourceId",i),l&&u.append("continuationThreadId",l),d&&u.append("continuationTargetBindingId",d),c?.length&&u.append("continuationSelectorAliases",JSON.stringify(c)),o)for(let[e,t]of o)for(let r=0;r<t.length;r++)u.append(`image-${e}-${r}`,t[r],`image-${e}-${r}.webp`);return u}async function E(e=l){let t=()=>({head:{sequence:0,updatedAt:new Date(0).toISOString()},counts:{total:0,emerging:0,testing:0,grounded:0,challenged:0,retired:0,needsGrounding:0},explanations:[]});try{let r=await g(`${e}/memory/imprint-view`,{},5e3);return r.ok?r.json():t()}catch{return t()}}function P(e){return new Promise(t=>setTimeout(t,e))}async function B(e=l,t,r=15e3){let n=Date.now();try{let t=await g(`${e}/restart`,{method:"POST"},5e3);if(!t.ok){let e=await t.text().catch(()=>"");return{ok:!1,error:e?`Bridge restart returned ${t.status}: ${e}`:`Bridge restart returned ${t.status}`,elapsedMs:Date.now()-n}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"Bridge restart request failed",elapsedMs:Date.now()-n}}let a=null,o=e,i=d();for(;Date.now()-n<r;){if(await P(350),a=await I(o),!a?.ok&&i){let t=await k(e,i);t?.url&&(o=t.url,a=await I(o))}if(a?.ok&&(!i||a.projectId===i)&&(!t||a.version===t))return{ok:!0,status:a,elapsedMs:Date.now()-n,bridgeUrl:o}}let s=t?` with version ${t}`:"";return a?.ok&&t&&a.version!==t?{ok:!1,error:`Bridge is running version ${a.version??"unknown"}, but this page expects ${t}. Refresh the page to load the current package. If the mismatch remains, rebuild or update the package used by the bridge, then restart it.`,status:a,elapsedMs:Date.now()-n}:{ok:!1,error:`Bridge did not come back${s} within ${Math.round(r/1e3)}s`,status:a,elapsedMs:Date.now()-n}}async function D(e=l){return(await B(e)).ok}async function C(e,t,r=l,n,a,o,i,s,c,d){let u,p=`${r}/reply`;if(i&&i.length>0){let r=new FormData,l=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});r.append("screenshot",l,"screenshot.png"),r.append("feedback",JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:o,sourceId:s,...c,...d}));for(let e=0;e<i.length;e++)r.append(`image-reply-${e}`,i[e],`reply-image-${e}.webp`);u={method:"POST",body:r}}else u={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:o,sourceId:s,...c,...d})};let h=await g(p,u,3e4);if(!h.ok){let e=await h.text();throw new Error(`Bridge returned ${h.status}: ${e}`)}return h.json()}async function U(e,t=l,r=!1){let n=await g(`${t}/thread/${encodeURIComponent(e)}/archive${r?"?cancelQueued=true":""}`,{method:"POST"},15e3);if(!n.ok&&404!==n.status){let e=await n.text();throw new Error(`Bridge returned ${n.status}: ${e}`)}return n.json()}async function A(e,t=l){let r=await g(`${t}/thread/${encodeURIComponent(e)}/restore`,{method:"POST"},15e3);if(!r.ok)throw new Error(`Thread restore failed: ${r.status}`)}async function M(e=l){let t=await g(`${e}/workspace/clear`,{method:"POST"},5e3);if(!t.ok){let e=await t.text();throw new Error(`Bridge returned ${t.status}: ${e}`)}return t.json()}export{i as a,u as b,p as c,h as d,f as e,w as f,m as g,y as h,$ as i,I as j,k,v as l,T as m,O as n,E as o,B as p,D as q,C as r,U as s,A as t,M as u};
|
|
1
|
+
"use client";import{i as e,g as t,a as r}from"./chunk-AGCS65LT.mjs";import{b as n}from"./chunk-SUAHDXJZ.mjs";var a=new Set;function o(e,t){let n=new URL(e).origin;"websocket"===t&&new URL(e).pathname!==r?a.add(n):a.delete(n)}function i(t){return a.has(new URL(t).origin)?new s(t,!0):e(t)?new s(t):new EventSource(t)}var s=class{constructor(e,t=!1){this.readyState=0,this.onerror=null,this.controller=new AbortController,this.listeners=new Map,this.fail=()=>{this.controller.signal.aborted||(this.readyState=2,this.controller.abort(),this.emit("error",""),this.onerror?.call(this,new Event("error")))},typeof document<"u"&&document.addEventListener("resume",this.fail,{signal:this.controller.signal}),this.read(e,t)}addEventListener(e,t){let r=this.listeners.get(e)??new Set;r.add(t),this.listeners.set(e,r)}close(){this.readyState=2,this.controller.abort(),this.listeners.clear()}emit(e,t){let r=new MessageEvent(e,{data:t});for(let t of this.listeners.get(e)??[])t(r)}async read(e,t){try{if(t){let{readBridgeWebSocket:t}=await(import("./bridgeWebSocketStream-AS22Y2FP.mjs"));return void await t(e,this.controller.signal,(e,t)=>{"connected"===e&&(this.readyState=1),this.emit(e,t)})}let{readBridgeSSE:r}=await(import("./bridgeSSEStream-HUFNXYPG.mjs"));await r(e,this.controller.signal,()=>{this.readyState=1},(e,t)=>this.emit(e,t))}catch{this.fail()}}},l="http://localhost:1111",c=new Map;function d(){return typeof window<"u"?window.__POPMELT_PROJECT_ID__??null:null}function u(e,r={}){return t(e,function(e={}){let t=d();if(!t)return e;let r=new Headers(e.headers);return r.set("X-Popmelt-Project-Id",t),{...e,headers:r}}(r))}async function p(e,t,r){let n=new URLSearchParams({annotationId:t,kind:r.kind,name:r.name}),a=await g(`${e}/draft-attachments?${n}`,{method:"POST",headers:{"Content-Type":r.blob.type},body:r.blob},15e3);if(!a.ok)throw new Error((await a.json().catch(()=>null))?.error||`Bridge returned ${a.status}`);return(await a.json()).attachment}async function h(e,t){0!==t.length&&await g(`${e}/draft-attachments/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:t})},5e3)}async function f(e,t){await g(`${e}/draft-attachments/${encodeURIComponent(t)}`,{method:"DELETE"},5e3)}async function w(e,t){if((c.get(e)??0)>Date.now())return null;try{let r=await g(`${e}/capture/native`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageUrl:t.url,clip:t.clip,scale:t.scale})},2500);if(!r.ok)return c.set(e,Date.now()+(404===r.status||501===r.status?6e4:1e4)),null;let n=await r.blob();return n.size>0?n:null}catch{return c.set(e,Date.now()+1e4),null}}function g(e,t={},r=15e3){let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let a=setTimeout(()=>n.abort(),r);return u(e,{...t,signal:n.signal}).finally(()=>clearTimeout(a))}async function m(e=l){try{let t=await g(`${e}/ui-preferences`,{},5e3);return t.ok?await t.json():null}catch{return null}}async function y(e,t){try{let r=await g(`${e}/ui-preferences`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:t})},5e3);return r.ok?await r.json():null}catch{return null}}async function $(e=l,t){try{let r=t?`?refresh=${encodeURIComponent(t)}`:"",n=await g(`${e}/capabilities${r}`,{},t?35e3:5e3);return n.ok?await n.json():null}catch{return null}}async function b(e,t,r="/status"){let n=new AbortController,a=setTimeout(()=>n.abort(),t);try{let t=await u(`${e}${r}`,{signal:n.signal});if(!t.ok)return null;let a=await t.json();return o(e,a.eventTransport),a}catch{return null}finally{n.abort(),clearTimeout(a)}}async function I(e=l){return b(e,2e3)}async function j(e){return b(`http://localhost:${e}`,500,"/status?discovery=1")}async function S(e){return I(e)}async function k(e,t){if(typeof location<"u"&&e&&(e===location.origin+r||n(e??""))){let r=await S(e);return t&&r?.projectId===t?{url:e,port:Number(location.port)||443,projectId:t}:null}if(e&&e!==l)try{let r=new URL(e),n=await S(e);if(!n&&!t)return null;if((n||!t)&&(!n||!t||n.projectId===t)){if(n?.projectId&&!t)return null;if(n)return{url:e,port:parseInt(r.port,10)||1111,projectId:n.projectId}}}catch{if(!t)return null}let a=typeof window<"u"?window.location.origin:null,o=await j(1111);if(o){if(t&&o.projectId===t)return{url:"http://localhost:1111",port:1111,projectId:o.projectId};if(o.devOrigin&&a&&o.devOrigin===a&&!t&&!o.projectId)return{url:"http://localhost:1111",port:1111,projectId:o.projectId}}let i=function(e=1111){return Array.from({length:Math.min(32,65536-e)},(t,r)=>e+r)}().slice(1).map(e=>j(e).then(t=>t?{status:t,port:e}:null)),s=(await Promise.all(i)).filter(e=>null!==e),c=[];o&&c.push({port:1111,devOrigin:o.devOrigin,projectId:o.projectId});for(let e of s)c.push({port:e.port,devOrigin:e.status.devOrigin,projectId:e.status.projectId});if(t){let e=c.find(e=>e.projectId===t);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}if(a){let e=c.find(e=>e.devOrigin===a&&!e.projectId);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}return 1!==c.length||c[0].projectId?null:{url:`http://localhost:${c[0].port}`,port:c[0].port,projectId:c[0].projectId}}async function v(e=l,t,r=-1,n={}){try{let a=await g(`${e}/jobs/${t}/events?afterSeq=${r}`,{},5e3);if(404===a.status||410===a.status)return null;if(!a.ok){if(n.retryUnavailable&&(429===a.status||a.status>=500))throw new Error("Bridge history is temporarily unavailable");return null}return await a.json()}catch(e){if(n.retryUnavailable)throw e;return null}}async function T(e,t,r=l,n,a,o,i,s,c,d,u,p,h){let f=O({screenshots:e,feedbackJson:t,color:n,provider:a,model:o,pastedImages:i,sourceId:s,agentSettings:c,continuationThreadId:d,continuationSelectorAliases:u,continuationTargetBindingId:p}),w=await g(`${r}/send`,{method:"POST",body:f,...h?{headers:{"X-Popmelt-Peer-Grant":h}}:{}},3e4);if(!w.ok){let e=await w.text();throw new Error(`Bridge returned ${w.status}: ${e}`)}return w.json()}function O({screenshots:e,feedbackJson:t,color:r,provider:n,model:a,pastedImages:o,sourceId:i,agentSettings:s,continuationThreadId:l,continuationSelectorAliases:c,continuationTargetBindingId:d}){let u=new FormData;if(e instanceof Map){let t=!0;for(let[r,n]of e){let e=encodeURIComponent(r);u.append(`screenshot-${e}`,n,`screenshot-${e}.webp`),t&&(u.append("screenshot",n,"screenshot.webp"),t=!1)}t&&u.append("screenshot",new Blob([],{type:"image/webp"}),"screenshot.webp")}else u.append("screenshot",e,"screenshot.webp");if(u.append("feedback",t),r&&u.append("color",r),n&&u.append("provider",n),a&&u.append("model",a),function(e,t){t?.reasoningEffort&&e.append("reasoningEffort",t.reasoningEffort),t?.serviceTier&&e.append("serviceTier",t.serviceTier)}(u,s),i&&u.append("sourceId",i),l&&u.append("continuationThreadId",l),d&&u.append("continuationTargetBindingId",d),c?.length&&u.append("continuationSelectorAliases",JSON.stringify(c)),o)for(let[e,t]of o)for(let r=0;r<t.length;r++)u.append(`image-${e}-${r}`,t[r],`image-${e}-${r}.webp`);return u}async function E(e=l){let t=()=>({head:{sequence:0,updatedAt:new Date(0).toISOString()},counts:{total:0,emerging:0,testing:0,grounded:0,challenged:0,retired:0,needsGrounding:0},explanations:[]});try{let r=await g(`${e}/memory/imprint-view`,{},5e3);return r.ok?r.json():t()}catch{return t()}}function P(e){return new Promise(t=>setTimeout(t,e))}async function B(e=l,t,r=15e3){let n=Date.now();try{let t=await g(`${e}/restart`,{method:"POST"},5e3);if(!t.ok){let e=await t.text().catch(()=>"");return{ok:!1,error:e?`Bridge restart returned ${t.status}: ${e}`:`Bridge restart returned ${t.status}`,elapsedMs:Date.now()-n}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"Bridge restart request failed",elapsedMs:Date.now()-n}}let a=null,o=e,i=d();for(;Date.now()-n<r;){if(await P(350),a=await I(o),!a?.ok&&i){let t=await k(e,i);t?.url&&(o=t.url,a=await I(o))}if(a?.ok&&(!i||a.projectId===i)&&(!t||a.version===t))return{ok:!0,status:a,elapsedMs:Date.now()-n,bridgeUrl:o}}let s=t?` with version ${t}`:"";return a?.ok&&t&&a.version!==t?{ok:!1,error:`Bridge is running version ${a.version??"unknown"}, but this page expects ${t}. Refresh the page to load the current package. If the mismatch remains, rebuild or update the package used by the bridge, then restart it.`,status:a,elapsedMs:Date.now()-n}:{ok:!1,error:`Bridge did not come back${s} within ${Math.round(r/1e3)}s`,status:a,elapsedMs:Date.now()-n}}async function U(e=l){return(await B(e)).ok}async function C(e,t,r=l,n,a,o,i,s,c,d){let u,p=`${r}/reply`;if(i&&i.length>0){let r=new FormData,l=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});r.append("screenshot",l,"screenshot.png"),r.append("feedback",JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:o,sourceId:s,...c,...d}));for(let e=0;e<i.length;e++)r.append(`image-reply-${e}`,i[e],`reply-image-${e}.webp`);u={method:"POST",body:r}}else u={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:o,sourceId:s,...c,...d})};let h=await g(p,u,3e4);if(!h.ok){let e=await h.text();throw new Error(`Bridge returned ${h.status}: ${e}`)}return h.json()}async function D(e,t=l,r=!1){let n=await g(`${t}/thread/${encodeURIComponent(e)}/archive${r?"?cancelQueued=true":""}`,{method:"POST"},15e3);if(!n.ok&&404!==n.status){let e=await n.text();throw new Error(`Bridge returned ${n.status}: ${e}`)}return n.json()}async function A(e,t=l){let r=await g(`${t}/thread/${encodeURIComponent(e)}/restore`,{method:"POST"},15e3);if(!r.ok)throw new Error(`Thread restore failed: ${r.status}`)}async function M(e=l){let t=await g(`${e}/workspace/clear`,{method:"POST"},5e3);if(!t.ok){let e=await t.text();throw new Error(`Bridge returned ${t.status}: ${e}`)}return t.json()}export{i as a,u as b,p as c,h as d,f as e,w as f,m as g,y as h,$ as i,I as j,k,v as l,T as m,O as n,E as o,B as p,U as q,C as r,D as s,A as t,M as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{x as t}from"./chunk-
|
|
1
|
+
"use client";import{x as t}from"./chunk-DBCBG5J6.mjs";import{w as e}from"./chunk-P2WAXWAZ.mjs";import{b as o}from"./chunk-HAZXZ5TU.mjs";import{c as n,a as i}from"./chunk-WJVRGXOS.mjs";import{N as a}from"./chunk-OA63PYHZ.mjs";import{b as r}from"./chunk-6RMM7JB6.mjs";import{useRef as l,useMemo as p,useState as m,useCallback as s,useEffect as f}from"react";import{jsx as c,Fragment as d,jsxs as u}from"react/jsx-runtime";function g({element:t,elements:e,registry:o,label:n="Looking",engaged:i=!0,outlineColor:a,inverse:r=!1}){let u=l(0),g=p(()=>e??(t?[t]:[]),[e,t]),[h,k]=m(()=>g.map(t=>({target:t,id:++u.current,animateEntrance:!0,exiting:!1}))),x=s(t=>{k(e=>e.filter(e=>e.id!==t))},[]);return f(()=>{g.length&&k(t=>{let e=t.some(({target:t})=>t.isConnected),o=g.map(o=>t.find(t=>t.target===o&&!t.exiting)??{target:o,id:++u.current,animateEntrance:!e,exiting:!1});return[...t.filter(t=>!t.exiting&&!g.includes(t.target)).map(t=>({...t,exiting:!0})),...o]})},[g]),c(d,{children:h.map(({target:t,id:e,animateEntrance:l,exiting:p})=>c(y,{id:e,element:i&&g.includes(t)?t:null,target:t,animateEntrance:l,exiting:p,registry:o,label:n,outlineColor:a,inverse:r,onDone:x},e))})}function y({id:p,element:s,target:g,animateEntrance:y,exiting:h,registry:k,label:x,outlineColor:b,inverse:R,onDone:v}){let[T]=n(),w=i[T],j=g,[Y,C]=m(!1),A=l(Date.now()),[B,D]=m(null);return f(()=>{if(!j)return;let t,e=()=>{let n=o(j);D(t=>n?t?.left===n.left&&t.top===n.top?t:{left:n.left,top:n.top}:null),t=requestAnimationFrame(e)};return e(),()=>cancelAnimationFrame(t)},[j]),f(()=>{let t,e;return h?e=setTimeout(()=>v(p),200):s?(A.current=Date.now(),C(!1)):t=setTimeout(()=>{C(!0),e=setTimeout(()=>v(p),300)},Math.max(0,A.current+1700-Date.now())),()=>{clearTimeout(t),clearTimeout(e)}},[s,h,p,v]),j?.isConnected?u(d,{children:[c("style",{children:'\n @keyframes popmelt-looking-in-left { from { opacity: 0; transform: translateX(26px); clip-path: inset(0 100% 0 0); } to { opacity: 1; transform: translateX(0); clip-path: inset(0); } }\n @keyframes popmelt-looking-out-left { from { opacity: 1; } to { opacity: 0; } }\n @keyframes popmelt-looking-in-up { from { opacity: 0; transform: translateY(26px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: translateY(0); clip-path: inset(0); } }\n @keyframes popmelt-looking-in-alone-up-left { from { opacity: 0; transform: translate(8px, 8px); } to { opacity: 1; transform: translate(0, 0); } }\n @keyframes popmelt-looking-in-alone-down-left { from { opacity: 0; transform: translate(8px, -8px); } to { opacity: 1; transform: translate(0, 0); } }\n @keyframes popmelt-looking-in-alone-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes popmelt-looking-in-alone-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes popmelt-looking-out-up { from { opacity: 1; } to { opacity: 0; } }\n @keyframes popmelt-looking-fade-in { from { opacity: 0; } to { opacity: 1; } }\n @keyframes popmelt-looking-fade-out { from { opacity: 1; } to { opacity: 0; } }\n @keyframes popmelt-looking-blink { 0%, 40%, 72.5%, 100% { transform: scaleY(1); } 50%, 62.5% { transform: scaleY(0.1); } }\n .popmelt-looking-eye { animation: popmelt-looking-blink 1000ms 200ms both; transform-origin: center; }\n @media (prefers-reduced-motion: reduce) {\n [data-devtools="focus-inspection"], .popmelt-looking-eye { animation: none !important; }\n [data-popmelt-looking-exiting] { opacity: 0 !important; }\n }\n '}),c(e,{element:j,subjectRegistry:k,hideOutline:!b||Y||h,color:b,outlineZIndex:b?10002:void 0,hideFill:!0,hideTooltip:!0,railHeight:22,renderRail:(e,o)=>{let n=B??e,i=n.left>=28,l=!B&&e.anchor.startsWith("bottom-"),p=B?i?"left":"up":`${l?"down":"up"}${i?"-left":""}`,m=B&&!i?Math.max(4,n.top-22-2):n.top,s=i?n.left-22-2:n.left,f=o.left+o.width/2>=s+11,d=o.top+o.height/2>=m+11?f?"borderBottomRightRadius":"borderBottomLeftRadius":f?"borderTopRightRadius":"borderTopLeftRadius";return c("div",{"data-devtools":"focus-inspection","data-popmelt-looking-exiting":h?"true":void 0,"data-popmelt-canvas-block":!0,role:"status","aria-live":h?"off":"polite","aria-hidden":h||void 0,"aria-label":x,title:x,style:{position:"fixed",animation:h?"popmelt-looking-fade-out 200ms ease both":Y||y?`popmelt-looking-${Y?"out":B?"in":"in-alone"}-${Y?i?"left":"up":p} ${Y?300:200}ms ease both`:"popmelt-looking-fade-in 200ms ease both",left:s,top:m,height:22,width:22,boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:R?w.actionSurface:w.surface,color:R?w.actionForeground:w.primary,border:`1px solid ${R?w.actionHover:w.border}`,borderTopLeftRadius:t,borderTopRightRadius:t,borderBottomLeftRadius:t,borderBottomRightRadius:t,...B?{}:{[d]:2},fontFamily:r,fontSize:12,letterSpacing:"0.24px",whiteSpace:"nowrap",pointerEvents:h?"none":"auto",zIndex:j.hasAttribute("data-popmelt-thread-header")?10006:10002},children:c(a,{className:y&&!h?"popmelt-looking-eye":void 0,size:12,"aria-hidden":!0})})}})]}):null}export{g as a};
|