@popmelt.com/core 0.28.4 → 0.30.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.
Files changed (56) hide show
  1. package/README.md +20 -2
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  3. package/claude-plugin/skills/popmelt-core/SKILL.md +6 -0
  4. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  5. package/codex-plugin/skills/popmelt-core/SKILL.md +6 -0
  6. package/dist/{ParticipantRuntime-U4YOVIGA.mjs → ParticipantRuntime-AKVKVNO2.mjs} +14 -14
  7. package/dist/{PopmeltTasteConnectedPane-ODOMXUNO.mjs → PopmeltTasteConnectedPane-L5ULGACH.mjs} +12 -12
  8. package/dist/QueuedReplies-ZYUDSTS2.mjs +46 -0
  9. package/dist/ThreadErrorCard-Q5GQ4EIF.mjs +2 -0
  10. package/dist/bridge-entry.mjs +1 -1
  11. package/dist/bridge-recovery-3IQN3U6D.mjs +2 -0
  12. package/dist/bridgeSSEStream-NEYI73TC.mjs +4 -0
  13. package/dist/bridgeWebSocketStream-H3DCP4T3.mjs +2 -0
  14. package/dist/browser-runtime-PPQ2GUER.mjs +2 -0
  15. package/dist/browser.mjs +1 -1
  16. package/dist/canvas-chat-note-7HSL7MH6.mjs +2 -0
  17. package/dist/chunk-2BVRVVHJ.mjs +347 -0
  18. package/dist/chunk-2P2NUZW7.mjs +2 -0
  19. package/dist/chunk-2RRYBN2J.mjs +17 -0
  20. package/dist/chunk-4BEN6VQ7.mjs +2 -0
  21. package/dist/chunk-4V7SK3M6.mjs +3 -0
  22. package/dist/chunk-6VXFTT5U.mjs +2 -0
  23. package/dist/chunk-AR4MHLWP.mjs +342 -0
  24. package/dist/chunk-CPOYMGYY.mjs +2 -0
  25. package/dist/chunk-ENGMQINZ.mjs +62 -0
  26. package/dist/{chunk-3DUSECUJ.mjs → chunk-HTHUSDZT.mjs} +1 -1
  27. package/dist/chunk-MZNY6VXR.mjs +2 -0
  28. package/dist/{chunk-CKD6RNCO.mjs → chunk-N4F7DGFN.mjs} +1 -1
  29. package/dist/chunk-O6HC437G.mjs +307 -0
  30. package/dist/chunk-OFHBVUTT.mjs +315 -0
  31. package/dist/chunk-YYWUENSJ.mjs +2 -0
  32. package/dist/chunk-ZQTLCQPC.mjs +1 -0
  33. package/dist/cli.mjs +34 -328
  34. package/dist/codex-note-context-ZLQU57WU.mjs +2 -0
  35. package/dist/codex-project-P3J62GZR.mjs +2 -0
  36. package/dist/codex-session-registry-25DAA2KO.mjs +2 -0
  37. package/dist/{dev-server-rQIWJcSX.d.mts → dev-server-DtX2_HCa.d.mts} +2 -0
  38. package/dist/index.mjs +1 -1
  39. package/dist/memory-store.d.mts +1 -1
  40. package/dist/peer-client-DGX6OHMK.mjs +2 -0
  41. package/dist/plugin-astro.d.mts +1 -1
  42. package/dist/plugin-astro.mjs +1 -1
  43. package/dist/plugin-nuxt.d.mts +1 -1
  44. package/dist/plugin-nuxt.mjs +1 -1
  45. package/dist/plugin-vite.d.mts +1 -1
  46. package/dist/plugin-vite.mjs +1 -1
  47. package/dist/server.d.mts +2 -2
  48. package/dist/server.mjs +5 -5
  49. package/dist/{types-Bur49CLH.d.mts → types-C8tjyhiF.d.mts} +21 -0
  50. package/package.json +22 -32
  51. package/dist/browser-runtime-2L55FIH3.mjs +0 -2
  52. package/dist/chunk-5NOCGSQL.mjs +0 -291
  53. package/dist/chunk-ERUGF5VG.mjs +0 -347
  54. package/dist/chunk-L4G2KO2P.mjs +0 -1
  55. package/dist/chunk-OYJINEC5.mjs +0 -77
  56. package/dist/chunk-YYK7MXEK.mjs +0 -369
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import{useState as p}from"react";import{Check as q,X as x,PenLine as C,Trash2 as k}from"lucide-react";import{jsxs as r,jsx as e,Fragment as v}from"react/jsx-runtime";function w({messages:a,renderMessage:c,onChange:n}){return a.length?r("section",{"aria-label":"Queued messages",style:{display:"flex",flexDirection:"column",gap:6,flexShrink:0,borderTop:"1px solid var(--popmelt-thread-hairline)",paddingTop:8},children:[e("style",{children:`
3
+ [data-queued-reply-actions] {
4
+ width: 0;
5
+ margin-left: 0;
6
+ opacity: 0;
7
+ overflow: hidden;
8
+ pointer-events: none;
9
+ transition: width 100ms ease-out, margin-left 100ms ease-out, opacity 100ms ease-out;
10
+ }
11
+ [data-queued-reply]:hover [data-queued-reply-actions],
12
+ [data-queued-reply]:focus-within [data-queued-reply-actions],
13
+ [data-queued-reply][data-editing="true"] [data-queued-reply-actions] {
14
+ width: 52px;
15
+ margin-left: 5px;
16
+ opacity: 1;
17
+ pointer-events: auto;
18
+ }
19
+ [data-queued-reply-actions] button {
20
+ color: var(--popmelt-thread-muted);
21
+ transition: color 50ms ease-out;
22
+ }
23
+ [data-queued-reply-actions] button:not(:disabled):hover,
24
+ [data-queued-reply-actions] button:not(:disabled):focus-visible {
25
+ color: var(--popmelt-thread-action);
26
+ }
27
+ [data-queued-reply-actions] button:not(:disabled):active {
28
+ color: var(--popmelt-thread-action-hover);
29
+ }
30
+ [data-queued-reply-actions] button:disabled {
31
+ opacity: 0.4;
32
+ cursor: default;
33
+ }
34
+ @media (hover: none), (pointer: coarse) {
35
+ [data-queued-reply-actions] {
36
+ width: 52px;
37
+ margin-left: 5px;
38
+ opacity: 1;
39
+ pointer-events: auto;
40
+ }
41
+ }
42
+ @media (prefers-reduced-motion: reduce) {
43
+ [data-queued-reply-actions],
44
+ [data-queued-reply-actions] button { transition: none; }
45
+ }
46
+ `}),r("div",{style:{fontSize:12,fontWeight:600,marginBottom:4,color:"var(--popmelt-thread-muted)"},children:[a.length," queued"]}),a.map(i=>e(S,{message:i,renderMessage:c,onChange:n},i.lifecycle?.submissionIds[0]??`${i.jobId}-${i.timestamp}`))]}):null}function S({message:a,renderMessage:c,onChange:n}){let[i,l]=p(!1),[d,y]=p(a.replyToQuestion??""),[o,g]=p(!1),[b,m]=p(""),s=!!(n&&a.lifecycle?.submissionIds[0])&&!o,h=async t=>{if(!(!s||!n||t==="")){g(!0),m("");try{await n(a,t),l(!1)}catch(f){m(f instanceof Error?f.message:"Could not update queued message.")}finally{g(!1)}}},u={display:"inline-flex",alignItems:"center",justifyContent:"center",background:"none",border:0,cursor:"pointer",padding:5,width:26,height:28,flexShrink:0};return r("div",{"data-queued-reply":!0,"data-editing":i,style:{display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0,flexShrink:0},children:[r("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:[e("div",{"data-queued-reply-preview":!0,style:{flex:1,minWidth:0},children:i&&n?e("textarea",{autoFocus:!0,"aria-label":"Edit queued message",value:d,disabled:o,onChange:t=>y(t.target.value),onKeyDown:t=>{t.key==="Escape"&&(t.stopPropagation(),o||l(!1)),t.key==="Enter"&&(t.metaKey||t.ctrlKey)&&!t.nativeEvent.isComposing&&(t.preventDefault(),t.stopPropagation(),h(d.trim()))},style:{width:"100%",boxSizing:"border-box",minHeight:90,resize:"vertical",font:"inherit",lineHeight:1.5,color:"inherit",background:"var(--popmelt-thread-raised)",border:"1px solid var(--popmelt-thread-hairline)",borderRadius:12,padding:12}}):c(a)}),n&&e("div",{"data-queued-reply-actions":!0,style:{display:"flex",flexShrink:0},children:i?r(v,{children:[e("button",{type:"button",title:"Save queued message","aria-label":"Save queued message",disabled:!s||!d.trim(),style:u,onClick:()=>{h(d.trim())},children:e(q,{size:14})}),e("button",{type:"button",title:"Cancel editing","aria-label":"Cancel editing",disabled:o,style:u,onClick:()=>l(!1),children:e(x,{size:14})})]}):r(v,{children:[e("button",{type:"button",title:"Edit queued message","aria-label":"Edit queued message",disabled:!s,style:u,onClick:()=>{y(a.replyToQuestion??""),m(""),l(!0)},children:e(C,{size:14})}),e("button",{type:"button",title:"Delete queued message","aria-label":"Delete queued message",disabled:!s,style:u,onClick:()=>{h(null)},children:e(k,{size:14})})]})})]}),b&&e("div",{role:"alert",style:{fontSize:12,color:"#dc2626"},children:b})]})}export{w as QueuedReplies};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{a as k}from"./chunk-2P2NUZW7.mjs";import{i as $}from"./chunk-MZNY6VXR.mjs";import"./chunk-2RRYBN2J.mjs";import{b as j}from"./chunk-CPOYMGYY.mjs";import"./chunk-6VXFTT5U.mjs";import{useState as S,useRef as w,useEffect as x,useCallback as z}from"react";import{ArrowUpRight as O,Copy as U}from"lucide-react";import{jsx as o,jsxs as l,Fragment as C}from"react/jsx-runtime";function E({provider:r,bridgeUrl:c}){let[e,i]=S("idle"),[s,t]=S(!1),d=w(!0),g=w(!1),u=r==="codex"?"Codex":"Claude",h=r==="codex"?"codex login":"claude auth login",y=`${c}/provider-login/${r}`;x(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=z(async n=>{let a=await j(y,{method:n,cache:"no-store",signal:AbortSignal.timeout(1e4),...n==="POST"?{headers:{"Content-Type":"application/json"},body:"{}"}:{}});if(!a.ok)throw new Error("Sign-in unavailable");let p=await a.json();return["pending","complete","failed","manual"].includes(p.state)?p.state:"failed"},[y]);x(()=>{if(e!=="pending")return;let n=!1,a,p=Date.now()+10*6e4;async function v(){try{let f=await m("GET");if(n)return;f!=="pending"||Date.now()>=p?i(f==="pending"?"failed":f):a=setTimeout(()=>{v()},1500)}catch{n||i("failed")}}return a=setTimeout(()=>{v()},1500),()=>{n=!0,clearTimeout(a)}},[e,m]);async function T(){if(!g.current){g.current=!0,i("opening");try{let n=await m("POST");d.current&&i(n)}catch{d.current&&i("failed")}finally{g.current=!1}}}let b={...$("dark"),display:"inline-flex",alignItems:"center",gap:8,font:"inherit",fontWeight:400,color:"var(--popmelt-thread-primary)",background:"var(--popmelt-thread-control)",cursor:"pointer"};return o("span",{"data-provider-sign-in":r,children:e==="complete"?l("span",{role:"status",children:["Signed in to ",u,". Send your reply to continue."]}):l(C,{children:[l("button",{type:"button",style:b,disabled:e==="opening"||e==="pending",onClick:()=>{T()},children:[e==="opening"?"Opening\u2026":e==="pending"?`Signing in to ${u}\u2026`:`Sign in to ${u}`,o(O,{size:14,"aria-hidden":"true"})]}),o("span",{role:"status",children:e==="pending"?" Complete sign-in in the terminal window, then return here.":e==="manual"?" Open your terminal and paste the login command.":e==="failed"?" Sign-in did not finish. Try again, or use your terminal.":" to continue."}),(e==="manual"||e==="failed")&&l("button",{type:"button",style:{...b,marginLeft:6},onClick:()=>{navigator.clipboard.writeText(h).then(()=>t(!0)).catch(()=>t(!1))},"aria-label":`Copy ${u} login command`,children:[s?"Copied":h,o(U,{size:14,"aria-hidden":"true"})]})]})})}function P({message:{error:r,errorKind:c,provider:e},bridgeUrl:i,canSignIn:s}){let t=r?k(r,c):null;return o("div",{style:{backgroundColor:"var(--popmelt-thread-soft)",border:"1px solid var(--popmelt-thread-border)",borderRadius:24,color:"var(--popmelt-thread-muted-strong)",fontSize:14,letterSpacing:"0.14px",lineHeight:1.35,padding:16},children:s&&t?.kind==="authentication"&&(e==="codex"||e==="claude")?o(E,{provider:e,bridgeUrl:i}):l(C,{children:[o("span",{style:{color:t?"#f59e0b":"var(--popmelt-thread-muted-strong)"},children:t?.label??"Cancelled"}),t?` \u2014 ${t.message}`:""]})})}export{P as default};
@@ -1,2 +1,2 @@
1
- import{j as n}from"./chunk-5NOCGSQL.mjs";import"./chunk-GL4I4MI6.mjs";import"./chunk-QXVMGZFP.mjs";import{mkdir as d,unlink as l,writeFile as P}from"fs/promises";import{join as r}from"path";var u=parseInt(process.env.POPMELT_PORT||"1111",10),s=process.env.POPMELT_PROJECT_ROOT||process.cwd(),w=process.env.POPMELT_DEV_ORIGIN||void 0,m=process.env.POPMELT_COPILOT_PATH||void 0,O=process.env.POPMELT_CDP_URL||void 0,c=r(s,".popmelt"),i=r(c,"bridge.lock");async function f(e){await d(c,{recursive:!0}),await P(i,JSON.stringify({pid:process.pid,port:e,startedAt:Date.now()})+`
1
+ import{k as n}from"./chunk-O6HC437G.mjs";import"./chunk-GL4I4MI6.mjs";import"./chunk-QXVMGZFP.mjs";import{mkdir as d,unlink as l,writeFile as P}from"fs/promises";import{join as r}from"path";var u=parseInt(process.env.POPMELT_PORT||"1111",10),s=process.env.POPMELT_PROJECT_ROOT||process.cwd(),w=process.env.POPMELT_DEV_ORIGIN||void 0,m=process.env.POPMELT_COPILOT_PATH||void 0,O=process.env.POPMELT_CDP_URL||void 0,c=r(s,".popmelt"),i=r(c,"bridge.lock");async function f(e){await d(c,{recursive:!0}),await P(i,JSON.stringify({pid:process.pid,port:e,startedAt:Date.now()})+`
2
2
  `)}async function a(){try{await l(i)}catch{}}async function T(){let e=await n({port:u,projectRoot:s,devOrigin:w,copilotPath:m,nativeCaptureUrl:O,restartMode:"detached"});await f(e.port),await new Promise(p=>{let t=!1,o=async()=>{t||(t=!0,await e.close(),await a(),p(),process.exit(0))};process.on("SIGTERM",o),process.on("SIGINT",o)})}T().catch(e=>{console.error("[popmelt bridge-entry] Fatal:",e),a().finally(()=>process.exit(1))});
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ function f(r,i,o){let n=new Set(r.filter(e=>e.data.jobId===i).map(e=>e.data.seq).filter(e=>typeof e=="number")),a=[];for(let e of o)if(!(e.type==="done"||e.type==="error")){if(typeof e.seq=="number"){if(n.has(e.seq))continue;n.add(e.seq)}a.push({type:e.type,data:e,timestamp:Date.now()})}return a.length?[...r,...a]:r}function p(r,i,o){return[...r].reverse().find(a=>a.type==="done"||a.type==="error")||(i?void 0:o)}function c(r,i,o){let n=new Set(i.map(t=>t.id)),a=new Map(o.map(t=>[t.id,t])),e=r.flatMap(t=>{let l=a.get(t);return l?.status==="done"||l?.status==="error"?[l]:[]}),d=new Set(e.map(t=>t.id)),s=r.filter(t=>!d.has(t));for(let t of n)s.includes(t)||s.push(t);return{serverActiveIds:n,terminalJobs:e,reconciledActiveIds:s}}export{f as mergeBackfillHistory,c as planBridgeReconnectRecovery,p as selectBackfillTerminalEvent};
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ import{c as w}from"./chunk-6VXFTT5U.mjs";async function m(s,r,f,h){if(r.aborted)return;let a=await fetch(s,w(s,{signal:r}));if(!a.ok||!a.body||!a.headers.get("content-type")?.includes("text/event-stream"))throw new Error("Event stream unavailable");if(r.aborted)return;f();let c=a.body.getReader(),g=new TextDecoder,e="",o="message",n=[],i=0;try{for(;!r.aborted;){let d=await c.read();if(d.done)throw new Error("Event stream ended");if(e+=g.decode(d.value,{stream:!0}),e.length>2*1024*1024)throw new Error("Event frame too large");let l;for(;(l=e.indexOf(`
3
+ `))!==-1;){let t=e.slice(0,l).replace(/\r$/,"");if(e=e.slice(l+1),!t)n.length&&h(o,n.join(`
4
+ `)),o="message",n=[],i=0;else if(t.startsWith("event:"))o=t.slice(6).trimStart();else if(t.startsWith("data:")&&(n.push(t.slice(5).replace(/^ /,"")),i+=t.length,i>2*1024*1024))throw new Error("Event frame too large")}}}finally{await c.cancel().catch(()=>{})}}export{m as readBridgeSSE};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{c as m}from"./chunk-6VXFTT5U.mjs";async function g(v,i,w){if(i.aborted)return;let e=new URL(v);if(e.protocol!=="http:"||!["localhost","127.0.0.1","[::1]"].includes(e.hostname))throw new Error("WebSocket experiment requires a local bridge");let p=new URL(e);p.pathname="/events/ticket";let t=new AbortController,c=()=>t.abort();i.addEventListener("abort",c,{once:!0});let b=setTimeout(c,1e4);try{let f=await fetch(p,m(v,{method:"POST",signal:t.signal,redirect:"error",credentials:"omit"}));if(!f.ok)throw new Error("Event subscription unavailable");let a=await f.json();if(a.version!==1||typeof a.ticket!="string"||a.ticket.length>128)throw new Error("Invalid event subscription");if(t.signal.aborted){if(i.aborted)return;throw new Error("Event subscription timed out")}e.protocol="ws:",e.pathname="/events/socket",e.search="",e.hash="",await new Promise((u,E)=>{let r=new WebSocket(e),l=!1,d=!1,s=n=>{d||(d=!0,t.signal.removeEventListener("abort",h),r.close(),n&&!i.aborted?E(n):u())},h=()=>s(new Error("Event subscription ended"));t.signal.addEventListener("abort",h,{once:!0}),r.onopen=()=>r.send(JSON.stringify({version:1,type:"subscribe",ticket:a.ticket})),r.onerror=()=>s(new Error("Event socket unavailable")),r.onclose=()=>s(new Error("Event socket ended")),r.onmessage=({data:n})=>{if(!d)try{if(typeof n!="string"||n.length>2*1024*1024)throw new Error("Invalid event frame");let o=JSON.parse(n);if(o.version!==1)throw new Error("Unsupported event protocol");if(!l&&o.type==="connected")l=!0,clearTimeout(b),w("connected",JSON.stringify({status:"connected"}));else if(l&&o.type==="event"&&typeof o.event?.type=="string")w(o.event.type,JSON.stringify(o.event));else throw new Error("Unexpected event frame")}catch{s(new Error("Invalid event frame"))}}})}finally{t.abort(),clearTimeout(b),i.removeEventListener("abort",c)}}export{g as readBridgeWebSocket};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{b as m,a as i}from"./chunk-AR4MHLWP.mjs";import"./chunk-3LBOX7HQ.mjs";import"./chunk-HTHUSDZT.mjs";import"./chunk-2BVRVVHJ.mjs";import"./chunk-ENGMQINZ.mjs";import"./chunk-JQHZFDY5.mjs";import"./chunk-MP7S5ALD.mjs";import"./chunk-XOGBFVWI.mjs";import"./chunk-2P2NUZW7.mjs";import"./chunk-MZNY6VXR.mjs";import"./chunk-2RRYBN2J.mjs";import"./chunk-CPOYMGYY.mjs";import"./chunk-EX63NVDN.mjs";import"./chunk-N2ZEZCHO.mjs";import"./chunk-J3UIBBU2.mjs";import"./chunk-6VXFTT5U.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-LVEMYZOA.mjs";import"./chunk-HGW2U6PD.mjs";import{createElement as p}from"react";import{createRoot as e}from"react-dom/client";function n(o,t){let r=e(o);return r.render(p(m,t)),()=>{r.unmount(),i()}}export{n as mountBrowserRuntime};
package/dist/browser.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{a as isPopmeltPreview}from"./chunk-EX63NVDN.mjs";var m={unmount(){}},u="[data-popmelt-browser-host]";async function p(o={}){if(!o.enabled||typeof document>"u")return m;if(document.querySelector(`${u}, [data-popmelt-top-layer-host]`))throw new Error("Popmelt is already mounted. Unmount it before mounting again.");let e=document.createElement("div");e.setAttribute("data-popmelt-browser-host",""),e.setAttribute("data-devtools",""),document.documentElement.appendChild(e);let d=[["__POPMELT_PROJECT_ID__",o.projectId],["__POPMELT_BRIDGE_URL__",o.bridgeUrl]].flatMap(([t,r])=>{if(r===void 0)return[];let n=Object.prototype.hasOwnProperty.call(window,t),l=window[t],i=r??void 0;return window[t]=i,[()=>{window[t]===i&&(n?window[t]=l:delete window[t])}]}),a=()=>{e.remove();for(let t of d)t()};try{let{mountBrowserRuntime:t}=await import("./browser-runtime-2L55FIH3.mjs");if(!e.isConnected)throw new Error("Popmelt mount was removed before startup.");let r=t(e,o),n=!0;return{unmount(){if(n){n=!1;try{r()}finally{a()}}}}}catch(t){throw a(),t}}export{p as mountPopmelt};
2
+ export{a as isPopmeltPreview}from"./chunk-EX63NVDN.mjs";var m={unmount(){}},u="[data-popmelt-browser-host]";async function p(o={}){if(!o.enabled||typeof document>"u")return m;if(document.querySelector(`${u}, [data-popmelt-top-layer-host]`))throw new Error("Popmelt is already mounted. Unmount it before mounting again.");let e=document.createElement("div");e.setAttribute("data-popmelt-browser-host",""),e.setAttribute("data-devtools",""),document.documentElement.appendChild(e);let d=[["__POPMELT_PROJECT_ID__",o.projectId],["__POPMELT_BRIDGE_URL__",o.bridgeUrl]].flatMap(([t,r])=>{if(r===void 0)return[];let n=Object.prototype.hasOwnProperty.call(window,t),l=window[t],i=r??void 0;return window[t]=i,[()=>{window[t]===i&&(n?window[t]=l:delete window[t])}]}),a=()=>{e.remove();for(let t of d)t()};try{let{mountBrowserRuntime:t}=await import("./browser-runtime-PPQ2GUER.mjs");if(!e.isConnected)throw new Error("Popmelt mount was removed before startup.");let r=t(e,o),n=!0;return{unmount(){if(n){n=!1;try{r()}finally{a()}}}}}catch(t){throw a(),t}}export{p as mountPopmelt};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{b as y}from"./chunk-CPOYMGYY.mjs";import"./chunk-6VXFTT5U.mjs";async function f(s,d,l,r,c,m){let n=r[1].toLowerCase()==="claude"?"Claude":"Codex";if(!c)throw new Error("Only the host can send a chat note.");if(m)throw new Error("Send a text-only note.");let a=l.find(o=>o.provider===n&&o.linked);if(!a)throw new Error("Send a note to this thread from "+n+" first so your reply reaches the right chat.");let p=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(r[2])),w=Array.from(new Uint8Array(p),o=>o.toString(16).padStart(2,"0")).join(""),e=JSON.stringify(["popmelt-note",s,d,a.id,w]),i=sessionStorage.getItem(e)??crypto.randomUUID();sessionStorage.setItem(e,i);let h=await y(`${s}/participants/send-to-${n.toLowerCase()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:d,text:r[2],requestId:i,linkId:a.id})}),t=await h.json();if(!h.ok||!(t.queuedInChat||t.availableInChat))throw new Error(t.error??"The bridge did not confirm delivery.");return sessionStorage.getItem(e)===i&&sessionStorage.removeItem(e),{jobId:t.jobId}}export{f as sendCanvasChatNote};