conformtools 0.6.10 → 0.6.11

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 (69) hide show
  1. package/README.md +53 -22
  2. package/dist/{account-GFIQC77T.js → account-IUWNSDG5.js} +1 -1
  3. package/dist/{analysis-engine-4K5K6L53.js → analysis-engine-M7W32RRC.js} +1 -1
  4. package/dist/bridge-SV7PCLQY.js +3 -0
  5. package/dist/browser/timeline_core_bg.wasm +0 -0
  6. package/dist/{chunk-56EEBHP2.js → chunk-2CY2OOOJ.js} +1 -1
  7. package/dist/chunk-2QT5MMBP.js +499 -0
  8. package/dist/chunk-2WBGXD27.js +8 -0
  9. package/dist/chunk-5YULBQJX.js +3 -0
  10. package/dist/chunk-5YWO2LBG.js +3 -0
  11. package/dist/chunk-64X5DLH5.js +6 -0
  12. package/dist/{chunk-XJNWAQON.js → chunk-6NLB5TZ2.js} +1 -1
  13. package/dist/chunk-6VP6G7CY.js +10 -0
  14. package/dist/chunk-G3SZDPDS.js +3 -0
  15. package/dist/chunk-IK6RKNS5.js +3 -0
  16. package/dist/chunk-IN6XVTUS.js +3 -0
  17. package/dist/{chunk-NQNS4Y2B.js → chunk-LVGGCRDW.js} +1 -1
  18. package/dist/chunk-N34DQ6MH.js +14 -0
  19. package/dist/chunk-NSQP6CTA.js +20 -0
  20. package/dist/chunk-QTFFVLVJ.js +8 -0
  21. package/dist/chunk-RKIRHMON.js +5 -0
  22. package/dist/chunk-ROPKSAFP.js +6 -0
  23. package/dist/{chunk-GM262EDM.js → chunk-S6KP52OG.js} +1 -1
  24. package/dist/chunk-THVX57I3.js +4 -0
  25. package/dist/chunk-VE423Z2L.js +132 -0
  26. package/dist/chunk-XF3YMBI7.js +3 -0
  27. package/dist/{chunk-E5ENIKNR.js → chunk-XIAG7ACN.js} +2 -2
  28. package/dist/chunk-YU3SUSK3.js +3 -0
  29. package/dist/claude-setup-REU4AOKX.js +13 -0
  30. package/dist/cli.js +8 -8
  31. package/dist/emscripten-module-Q67P5WYC-HW3D2R5O.js +2161 -0
  32. package/dist/ffi-7KTOX2T4.js +3 -0
  33. package/dist/framing-ZTMYZR2S.js +3 -0
  34. package/dist/gfx-worker.js +1 -1
  35. package/dist/host-relink-FHNXXMHW.js +10 -0
  36. package/dist/hosted-BWAYLJXR.js +3 -0
  37. package/dist/hosts-Y6HGDRLM.js +3 -0
  38. package/dist/http.js +3 -3
  39. package/dist/{inspect-D3WEYL2W.js → inspect-RJFJQSHZ.js} +1 -1
  40. package/dist/mcp.js +7 -7
  41. package/dist/{media-3YMIZSSF.js → media-22VAJIVT.js} +1 -1
  42. package/dist/module-ES6BEMUI-L6VQ7K3J.js +3 -0
  43. package/dist/module-asyncify-2EFITU5U-Z4EEM6X7.js +3 -0
  44. package/dist/{probe-COWUTQGN.js → probe-72QZKMCC.js} +1 -1
  45. package/dist/{sequence-patch-JVEZW24V.js → sequence-patch-CN4VC5W3.js} +1 -1
  46. package/dist/{store-SZKXADGI.js → store-H676BOKI.js} +1 -1
  47. package/dist/timeline-5TGA5HBY.js +3 -0
  48. package/package.json +10 -1
  49. package/dist/bridge-73XMEZLH.js +0 -3
  50. package/dist/chunk-2MJAQROY.js +0 -5
  51. package/dist/chunk-7QUSVHO2.js +0 -10
  52. package/dist/chunk-CJYLQ3UM.js +0 -5
  53. package/dist/chunk-DFDXSIMI.js +0 -39
  54. package/dist/chunk-DNS4ZYIO.js +0 -3
  55. package/dist/chunk-JHTMYXJM.js +0 -20
  56. package/dist/chunk-QHXX5GDD.js +0 -440
  57. package/dist/chunk-TDIY4NRQ.js +0 -3
  58. package/dist/chunk-UGVGRL5M.js +0 -3
  59. package/dist/chunk-Y2QHZUGL.js +0 -5
  60. package/dist/chunk-YC7QDS5U.js +0 -19
  61. package/dist/chunk-ZVUKOFUX.js +0 -6
  62. package/dist/claude-setup-OKOPPDMB.js +0 -5
  63. package/dist/conformtools-analyze +0 -0
  64. package/dist/conformtools-decode +0 -0
  65. package/dist/framing-BKTUEUZO.js +0 -3
  66. package/dist/host-relink-PTV44KXF.js +0 -10
  67. package/dist/hosts-D3TR2QEV.js +0 -3
  68. package/dist/i2o-transfer +0 -0
  69. package/dist/timeline-PEUC3G7K.js +0 -3
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{readFile as A,writeFile as W,appendFile as L,stat as H,readdir as J,mkdir as G,open as S,copyFile as q,mkdtemp as Y,rm as M,chmod as K,rename as _,cp as Q,statfs as V,realpath as X}from"node:fs/promises";import{execFile as Z,spawn as B}from"node:child_process";import{createHash as ee}from"node:crypto";import{createReadStream as te,chmodSync as re,cpSync as ne,existsSync as D,statSync as E}from"node:fs";import{homedir as se,tmpdir as oe,platform as ie,release as ae,arch as ce,totalmem as le,availableParallelism as ue}from"node:os";import{fileURLToPath as k}from"node:url";import de from"node:http";import me from"node:http2";import p from"node:process";import{Buffer as v}from"node:buffer";import{basename as fe,join as P,resolve as C,sep as x}from"node:path";import{basename as bt,dirname as wt,extname as ht,join as xt,relative as vt,resolve as Pt}from"node:path";{let e=globalThis.fetch,t=typeof globalThis.Deno<"u";e&&!t&&(globalThis.fetch=(async(n,s)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url;if(r.startsWith("file:")){let o=await A(k(r)),i=r.endsWith(".wasm")?"application/wasm":"application/octet-stream";return new Response(o,{status:200,headers:{"content-type":i}})}return e(n,s)}))}var w=e=>p.env[e],Fe=()=>Number(w("CONFORM_MEMORY_GB")??0)*2**30||le(),Oe=()=>ue(),Te=()=>p.argv.slice(2),De=e=>p.exit(e),pe=()=>p.platform,Ee=()=>w("CONFORM_PYTHON")??(pe()==="win32"?"python":"python3"),Ce=()=>p.arch;function Ie(){let e=p.versions.deno;return{platform:`${ie()} ${ae()} ${ce()}`,runtime:e?`deno ${e}`:`node ${p.version}`}}var ge=()=>w("CONFORM_MCP_HOME")??P(R(),".conform-mcp"),R=()=>w("HOME")??se();function Ne(e){let t=e.trim();if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),/^file:\/\//i.test(t))try{t=k(t)}catch{}return t==="~"?t=R():(t.startsWith("~/")||t.startsWith("~\\"))&&(t=P(R(),t.slice(2))),t&&C(t)+(/[\\/]$/.test(t)&&!/[\\/]$/.test(C(t))?x:"")}async function We(e,t){let n=await import("node:sqlite").catch(()=>null);if(n?.DatabaseSync){let r=new n.DatabaseSync(e,{readOnly:!0});try{let o=r.prepare(t);return o.setReadBigInts(!0),o.all().map(i=>Object.fromEntries(Object.entries(i).map(([c,a])=>[c,typeof a=="bigint"?Number(a):a])))}finally{r.close()}}let s=await F("sqlite3",["-readonly","-json",e,t]);if(!s.success)throw new Error(`sqlite3 ${fe(e)}: ${s.stderr.trim()||s.stdout.trim()}`);return s.stdout.trim()?JSON.parse(s.stdout):[]}var He=(e,t)=>e?`${e.replace(/[\\/]+$/,"")}${e.includes("\\")&&!e.includes("/")?"\\":"/"}${t}`:t;function Me(e){let t=k(e),n=t.indexOf(`${x}deno-compile-`);if(n<0||!D(t))return t;let s=t.slice(n+1).split(x).slice(1).join(x),r=P(ge(),"bin",s);try{let o=E(t),i=D(r)?E(r):null;return(!i||o.isFile()&&(i.size!==o.size||i.mtimeMs<o.mtimeMs))&&(ne(t,r,{recursive:!0,force:!0}),o.isFile()&&re(r,493)),r}catch{return t}}var I=null;var h=e=>I?.owns(e)?I:null;async function N(e){let t=await H(e);return{isFile:t.isFile(),isDirectory:t.isDirectory(),size:t.size,mtimeMs:t.mtimeMs}}function U(e){return h(e)?.stat(e,()=>N(e))??N(e)}async function _e(e){try{return await U(e),!0}catch{return!1}}async function Be(e){try{return(await U(e)).isFile}catch{return!1}}async function je(e){try{return(await U(e)).isDirectory}catch{return!1}}async function ze(e){h(e)?.guard(e,"read whole file");let t=await A(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}var Le=e=>A(e,"utf8"),Je=(e,t)=>W(e,t),Ge=(e,t,n)=>n?.append?L(e,t):W(e,t);async function qe(e){await G(e,{recursive:!0})}var Ye=e=>M(e,{force:!0}),Ke=(e,t)=>K(e,t).catch(()=>{}),Qe=(e,t)=>q(e,t),Ve=(e,t)=>_(e,t),Xe=e=>M(e,{recursive:!0,force:!0}),Ze=(e,t)=>Q(e,t,{recursive:!0,verbatimSymlinks:!0});async function et(e){try{let t=await V(e);return Number(t.bavail)*Number(t.bsize)}catch{return null}}async function tt(e){try{return await X(e)}catch{return null}}var rt=(e="conform-")=>Y(P(oe(),e));async function*nt(e){let t=async()=>(await J(e,{withFileTypes:!0})).map(n=>({name:n.name,isFile:n.isFile(),isDirectory:n.isDirectory()}));yield*await(h(e)?.readDir(e,t)??t())}async function st(e){h(e)?.guard(e,"read bytes");let t=await S(e,"r"),n=(await t.stat()).size;return{path:e,size:n,async readAt(s,r){let o=new Uint8Array(r),i=0;for(;i<r;){let{bytesRead:c}=await t.read(o,i,r-i,s+i);if(!c)break;i+=c}return i===r?o:o.subarray(0,i)},close:()=>t.close()}}async function ot(e){let t=await S(e,"w");return{async writeAt(n,s){let r=0;for(;r<s.length;){let{bytesWritten:o}=await t.write(s,r,s.length-r,n+r);r+=o}},truncate:n=>t.truncate(n),close:()=>t.close()}}var j=(e,t)=>{for(let n of t)h(n)?.guard(n,`${e.split(/[\\/]/).pop()} ${t[0]}`)};function F(e,t,n={}){return j(e,t),new Promise(s=>{Z(e,t,{maxBuffer:1<<30,env:n.env?{...p.env,...n.env}:void 0,timeout:n.timeoutMs},(r,o,i)=>{let c=r?.code??0;s({success:!r,code:c,stdout:String(o),stderr:String(i)})})})}var ye="[Console]::OutputEncoding=[Text.Encoding]::UTF8;$t=@{};Get-Process|?{$_.MainWindowTitle}|%{$t[$_.Id]=$_.MainWindowTitle};ConvertTo-Json -Compress -InputObject @(Get-CimInstance Win32_Process|%{[pscustomobject]@{pid=[int]$_.ProcessId;exe=$_.ExecutablePath;cmd=$_.CommandLine;title=$t[[int]$_.ProcessId]}})";async function it(){let e=await F("powershell.exe",["-NoProfile","-NonInteractive","-Command",ye],{timeoutMs:3e4});return be(e.stdout)}function be(e){let t;try{t=JSON.parse(e.replace(/^/,"").trim()||"[]")}catch{return[]}return(Array.isArray(t)?t:[t]).flatMap(n=>{let s=n??{},r=Number(s.pid);return!Number.isInteger(r)||r<=0?[]:[{pid:r,args:String(s.cmd||s.exe||""),title:typeof s.title=="string"?s.title:""}]})}function at(e,t,n,s={}){return j(e,t),new Promise((r,o)=>{let i=B(e,t,{env:s.env?{...p.env,...s.env}:void 0,stdio:["ignore","pipe","pipe"]}),c="";i.stdout.on("data",a=>n(a)),i.stderr.on("data",a=>{c+=new TextDecoder().decode(a)}),i.on("error",o),i.on("close",a=>r({code:a,stderr:c})),s.signal?.addEventListener("abort",()=>i.kill(),{once:!0})})}function ct(e,t,n,s){let r=B(e,t,{stdio:["pipe","pipe","pipe"]});r.stdout.on("data",a=>n(a)),r.stderr.on("data",a=>s?.(new TextDecoder().decode(a)));let o=new Promise(a=>{r.on("close",l=>a(l)),r.on("error",()=>a(null))}),i=[r,r.stdout,r.stderr,r.stdin],c=a=>{for(let l of i)(a?l.ref:l.unref)?.call(l)};return c(!1),{write:a=>new Promise((l,d)=>{r.stdin.write(a,m=>m?d(m):l())}),hold:c,close:()=>{try{r.stdin.end(),r.kill()}catch{}},exited:o}}async function lt(e){if(w("CONFORM_NO_BROWSER"))return!1;let[t,n]=p.platform==="darwin"?["open",[e]]:p.platform==="win32"?["cmd",["/c","start","",e.replace(/&/g,"^&")]]:["xdg-open",[e]];return(await F(t,n)).success}function ut(e,t){let n=de.createServer(async(s,r)=>{try{let o=[];if(s.method!=="GET"&&s.method!=="HEAD")for await(let m of s)o.push(m);let i=o.length>0,c=new Headers;for(let[m,f]of Object.entries(s.headers))f!=null&&c.set(m,Array.isArray(f)?f.join(", "):f);let a=`http://${s.headers.host??`${e.hostname}:${e.port}`}${s.url??"/"}`,l=new AbortController;r.on("close",()=>{r.writableEnded||l.abort()});let d=await t(new Request(a,{method:s.method,headers:c,body:i?v.concat(o):void 0,signal:l.signal}));if(r.statusCode=d.status,d.headers.forEach((m,f)=>r.setHeader(f,m)),d.body&&d.headers.get("content-type")?.startsWith("text/event-stream")){r.flushHeaders();let m=d.body.getReader();for(l.signal.addEventListener("abort",()=>void m.cancel(),{once:!0});;){let{value:f,done:g}=await m.read();if(g)break;r.write(f)}r.end();return}r.end(v.from(await d.arrayBuffer()))}catch(o){r.statusCode=500,r.end(JSON.stringify({ok:!1,code:"internal",message:o instanceof Error?o.message:String(o)}))}});return n.listen(e.port,e.hostname,()=>{let s=n.address();e.onListen?.(typeof s=="object"&&s?s.port:e.port)}),{close:()=>n.close()}}var y=class extends Error{constructor(n,s,r){super(s);this.code=n;this.grpcStatus=r}};function dt(e,t,n,s,r){return new Promise((o,i)=>{let c=me.connect(`http://${e}:${t}`),a=!1,l=(u,z)=>{a||(a=!0,clearTimeout(m),c.destroy(),u?i(u):o(z))},d=!1;c.on("connect",()=>{d=!0});let m=setTimeout(()=>l(d?new y("deadline",`no answer from ${e}:${t} in ${r} ms`):new y("unavailable",`${e}:${t}: no connection in ${r} ms`)),r);c.on("error",u=>l(new y("unavailable",`${e}:${t}: ${u.message}`)));let f=v.alloc(5+s.length);f.writeUInt32BE(s.length,1),f.set(s,5);let g=c.request({":method":"POST",":path":n,"content-type":"application/grpc",te:"trailers"}),O=[],b,$="",T=u=>{u["grpc-status"]!=null&&(b=String(u["grpc-status"]),$=decodeURIComponent(String(u["grpc-message"]??"")))};g.on("response",T),g.on("trailers",T),g.on("data",u=>O.push(u)),g.on("error",u=>l(new y("unavailable",`${e}:${t}: ${u.message}`))),g.on("end",()=>{if(b!=="0")return l(new y("grpc",`grpc-status ${b??"missing"}${$?`: ${$}`:""}`,b==null?void 0:Number(b)));let u=v.concat(O);if(u.length<5||u[0]!==0)return l(new y("grpc","reply is not one uncompressed gRPC message"));l(null,new Uint8Array(u.subarray(5,5+u.readUInt32BE(1))))}),g.end(f)})}async function mt(e){let t=ee("sha256");for await(let n of te(e))t.update(n);return t.digest("hex")}async function ft(e,t,n){let s=`${t}.part`;for(let r=0;;r++){let o=0;try{o=(await H(s)).size}catch{}try{let i=await fetch(e,{headers:o?{Range:`bytes=${o}-`}:{}});if(i.status===416)break;if(!i.ok||!i.body)throw new Error(`${e} answered ${i.status}`);o&&i.status!==206&&(o=0);let c=o+Number(i.headers.get("content-length")??0),a=await S(s,o?"a":"w");try{let l=o;for await(let d of i.body)await a.write(d),l+=d.length,n?.(l,c)}finally{await a.close()}break}catch(i){if(r>=4)throw i;await new Promise(c=>setTimeout(c,2e3*(r+1)))}}await _(s,t)}function pt(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}export{k as a,w as b,Fe as c,Oe as d,Te as e,De as f,pe as g,Ee as h,Ce as i,Ie as j,ge as k,R as l,Ne as m,We as n,He as o,Me as p,U as q,_e as r,Be as s,je as t,ze as u,Le as v,Je as w,Ge as x,qe as y,Ye as z,Ke as A,Qe as B,Ve as C,Xe as D,Ze as E,et as F,tt as G,rt as H,nt as I,st as J,ot as K,F as L,it as M,at as N,ct as O,lt as P,ut as Q,y as R,dt as S,mt as T,ft as U,pt as V,bt as W,wt as X,ht as Y,xt as Z,vt as _,Pt as $};
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{A as L,Z as P,b as N,k as A,p as O,v as R,x as M,y as W,z as I}from"./chunk-DNS4ZYIO.js";import K from"node:http";import{connect as Y}from"node:net";import{createHash as U,randomBytes as j}from"node:crypto";import{Buffer as m}from"node:buffer";var D="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";function C(o,e,a=!1){let n=e.length,t=a?128:0,s=n<126?m.from([128|o,t|n]):n<65536?m.from([128|o,t|126,n>>8,n&255]):(()=>{let i=m.alloc(10);return i[0]=128|o,i[1]=t|127,i.writeBigUInt64BE(BigInt(n),2),i})();if(!a)return m.concat([s,m.from(e)]);let r=j(4),c=m.from(e);for(let i=0;i<c.length;i++)c[i]^=r[i&3];return m.concat([s,r,c])}function J(o,e,a,n=!1){let t=m.alloc(0),s=[],r=0,c=!1,i=[],p=[],u=()=>{c||(c=!0,p.forEach(l=>l()))},f=(l=1e3,d="")=>{if(c)return;let h=m.from(d),g=m.alloc(2+h.length);g.writeUInt16BE(l,0),h.copy(g,2);try{o.write(C(8,g,n))}catch{}o.end(),u()};return o.on("data",l=>{for(t=m.concat([t,l]);t.length>=2;){let d=(t[0]&128)!==0,h=t[0]&15,g=(t[1]&128)!==0,v=t[1]&127,y=2;if(v===126){if(t.length<4)return;v=t.readUInt16BE(2),y=4}else if(v===127){if(t.length<10)return;let w=t.readBigUInt64BE(2);if(w>BigInt(a))return f(1009,"too big");v=Number(w),y=10}if(g===n)return f(1002,n?"server frames must not be masked":"client frames must be masked");if(v>a||r+v>a)return f(1009,"message too big");let T=g?4:0;if(t.length<y+T+v)return;let S=m.from(t.subarray(y+T,y+T+v));if(g){let w=t.subarray(y,y+4);for(let x=0;x<S.length;x++)S[x]^=w[x&3]}if(t=t.subarray(y+T+v),h===8)return f(1e3);if(h===9){o.write(C(10,S,n));continue}if(h!==10){if(h===1||h===0){if(s.push(S),r+=S.length,d){let w=m.concat(s).toString("utf8");s=[],r=0,i.forEach(x=>x(w))}continue}return f(1003,"text frames only")}}}),o.on("close",u),o.on("error",u),{origin:e,send:l=>{c||o.write(C(1,m.from(l,"utf8"),n))},close:f,onMessage:l=>{i.push(l)},onClose:l=>{p.push(l)}}}function F(o,e){let a=new Set,n=K.createServer((t,s)=>{let r=n.address();o.onHttp?.(t,s,typeof r=="object"&&r?r.port:o.port)||(s.writeHead(426,{"content-type":"text/plain"}),s.end("websocket only"))});return n.on("upgrade",(t,s)=>{let r=t.headers["sec-websocket-key"];if(t.url?.split("?")[0]!==o.path||typeof r!="string"||String(t.headers.upgrade).toLowerCase()!=="websocket"){s.end(`HTTP/1.1 400 Bad Request\r
4
- \r
5
- `);return}let c=U("sha1").update(r+D).digest("base64");s.write(`HTTP/1.1 101 Switching Protocols\r
6
- Upgrade: websocket\r
7
- Connection: Upgrade\r
8
- Sec-WebSocket-Accept: ${c}\r
9
- \r
10
- `),a.add(s),s.on("close",()=>a.delete(s));let i=typeof t.headers.origin=="string"?t.headers.origin:null;e(J(s,i,o.maxBytes))}),new Promise((t,s)=>{n.once("error",s),n.listen(o.port,o.hostname,()=>{let r=n.address();t({port:typeof r=="object"&&r?r.port:o.port,close:()=>new Promise(c=>{for(let i of a)i.destroy();n.close(()=>c())})})})})}function de(o,e){let a=new URL(o);if(a.protocol!=="ws:")return Promise.reject(new Error(`only ws:// URLs: ${o}`));let n=j(16).toString("base64"),t=U("sha1").update(n+D).digest("base64");return new Promise((s,r)=>{let c=Y({host:a.hostname,port:Number(a.port||80)}),i=f=>{c.destroy(),r(f)};c.setTimeout(e.timeoutMs,()=>i(new Error(`no answer from ${a.host} within ${e.timeoutMs} ms`))),c.once("error",i),c.once("connect",()=>c.write(`GET ${a.pathname}${a.search} HTTP/1.1\r
11
- Host: ${a.host}\r
12
- Upgrade: websocket\r
13
- Connection: Upgrade\r
14
- Sec-WebSocket-Key: ${n}\r
15
- Sec-WebSocket-Version: 13\r
16
- \r
17
- `));let p=m.alloc(0),u=f=>{p=m.concat([p,f]);let l=p.indexOf(`\r
18
- \r
19
- `);if(l<0)return;c.off("data",u);let d=p.subarray(0,l).toString("latin1").split(`\r
20
- `),h=d.find(y=>/^sec-websocket-accept:/i.test(y))?.split(":")[1]?.trim();if(!/^HTTP\/1\.1 101/.test(d[0])||h!==t)return i(new Error(`${a.host} refused the WebSocket upgrade: ${d[0]}`));c.setTimeout(0),c.off("error",i);let g=p.subarray(l+4),v=J(c,null,e.maxBytes,!0);g.length&&c.emit("data",g),s(v)};c.on("data",u)})}import{existsSync as te,readFileSync as ne}from"node:fs";var $="0.6.10";function Q(o,e){let a=o.split("-")[0].split(".").map(Number),n=e.split("-")[0].split(".").map(Number);for(let t=0;t<Math.max(a.length,n.length);t++){let s=(a[t]||0)-(n[t]||0);if(s)return s>0}return!1}var Z=null;function q(){return N("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):Z??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(o=>o.ok?o.json():null).then(o=>typeof o?.version=="string"?o.version:null).catch(()=>null)}var ee="run npx -y --prefer-online conformtools@latest mcp (in the MCP client config too; --prefer-online makes npx re-check npm instead of reusing its cached copy), then restart the MCP client; if an old global install is shadowing it: npm rm -g conformtools";async function ve(){let o=await q();return`conformtools ${$}`+(o&&Q(o,$)?` \u2014 update available: ${o} \u2192 ${ee}`:"")}var k=1,re=[48127,48128,48129,48130,48131,48132,48133,48134],oe=5e3,V=4,se=8*1024*1024,b=class extends Error{constructor(a,n){super(n);this.code=a}},_=()=>P(A(),"host-bridge","pairing.json"),B="/avid-panel/",ie="/avid-panel/pairing",G="avid",z={"index.html":"text/html; charset=utf-8","panel.js":"text/javascript; charset=utf-8","panel.css":"text/css; charset=utf-8","icon.svg":"image/svg+xml"},ae="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self' ws://localhost:{port} ws://127.0.0.1:{port} http://localhost:* http://127.0.0.1:* https://localhost:* https://127.0.0.1:*; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",X=o=>[`http://localhost:${o}`,`http://127.0.0.1:${o}`];function ce(){for(let o of["./avid/panel/web-dist/","./avid-panel/"]){let e=O(new URL(o,import.meta.url));if(te(P(e,"index.html")))return e}return null}function le(){let o=new Uint8Array(32);return crypto.getRandomValues(o),Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}var H=class{constructor(){this.token=le();this.port=0;this.live=new Map;this.waiters=[];this.seq=0;this.events=[]}async start(e=re){let a;for(let n of e)try{this.server=await F({hostname:"127.0.0.1",port:n,path:"/host-bridge",maxBytes:se,onHttp:(t,s,r)=>this.servePanel(t,s,r)},t=>this.accept(t)),this.port=this.server.port;break}catch(t){a=t}if(!this.server)throw new b("no_port",`every host-bridge port (${e.join(", ")}) is taken: ${a}`);await W(P(A(),"host-bridge")),await M(_(),JSON.stringify({protocol:k,url:`ws://127.0.0.1:${this.port}/host-bridge`,port:this.port,token:this.token})),await L(_(),384)}async stop(){for(let e of this.live.values())e.conn.close(1001,"engine stopping");this.live.clear(),await this.server?.close();try{JSON.parse(await R(_())).token===this.token&&await I(_())}catch{}}peers(){return[...this.live.values()].map(e=>e.peer)}peer(e){return this.live.get(e)?.peer}async waitFor(e,a){return this.live.has(e)?this.peer(e):(await Promise.race([new Promise(n=>this.waiters.push({host:e,resolve:n})),new Promise(n=>setTimeout(n,a))]),this.peer(e))}request(e,a,n={},t=3e4){let s=this.live.get(e);if(!s)return Promise.reject(new b("not_connected",`${e}: its panel is not connected`));let r=`r${++this.seq}`;return new Promise((c,i)=>{let p=setTimeout(()=>{s.pending.delete(r),i(new b("timeout",`${e}: no answer to ${a} within ${Math.round(t/1e3)} s`))},t);s.pending.set(r,{resolve:c,reject:i,timer:p}),s.conn.send(JSON.stringify({type:"request",id:r,method:a,params:n}))})}servePanel(e,a,n){let t=(e.url??"").split("?")[0];if(!t.startsWith(B)&&t!==B.slice(0,-1))return!1;let s=(f,l,d,h=!1)=>{let g=typeof d=="string"?new TextEncoder().encode(d):d;return a.writeHead(f,{"content-type":l,"content-length":String(g.length),"cache-control":"no-store","x-content-type-options":"nosniff","referrer-policy":"no-referrer","cross-origin-resource-policy":"same-origin","x-frame-options":"DENY","content-security-policy":ae.replaceAll("{port}",String(n))}),a.end(h?void 0:g),!0},r=(f,l)=>s(f,"text/plain; charset=utf-8",l),c=f=>{let l=e.headers[f];return typeof l=="string"?l:void 0},i=(c("host")??"").toLowerCase();if(i!==`localhost:${n}`&&i!==`127.0.0.1:${n}`)return r(421,"misdirected request");if(t===ie)return e.method==="POST"&&X(n).includes(c("origin")??"")&&(c("sec-fetch-site")??"same-origin")==="same-origin"&&c("x-ct-panel")==="1"&&(c("content-length")??"0").trim()==="0"?s(200,"application/json",JSON.stringify({protocol:k,url:`ws://localhost:${n}/host-bridge`,port:n,token:this.token})):r(403,"forbidden");if(e.method!=="GET"&&e.method!=="HEAD")return r(405,"method not allowed");let p=t.slice(B.length)||"index.html",u=ce();return!z[p]||!u?r(404,"not found"):s(200,z[p],ne(P(u,p)),e.method==="HEAD")}accept(e){let a=!!e.origin&&X(this.port).includes(e.origin);if(e.origin&&/^https?:/i.test(e.origin)&&!a){e.send(JSON.stringify({type:"error",code:"origin_refused",message:"web pages may not use the host bridge"})),e.close(1008,"origin");return}let n=null,t=setTimeout(()=>{n||(e.send(JSON.stringify({type:"error",code:"hello_timeout",message:"no hello"})),e.close(1008,"hello"))},oe);e.onMessage(s=>{let r;try{r=JSON.parse(s)}catch{return}if(!n){let i=(l,d)=>{clearTimeout(t),e.send(JSON.stringify({type:"error",code:l,message:d})),e.close(1008,l)};if(r.type!=="hello")return i("hello_expected","the first frame must be hello");if(r.protocol!==k)return i("protocol_mismatch",`this engine speaks protocol ${k}`);if(r.token!==this.token)return i("bad_token","the pairing token does not match: re-read the pairing file");let p=r.host??{},u=String(p.id??"");if(!/^[a-z][a-z0-9_-]{1,31}$/.test(u))return i("bad_host","host.id is missing or malformed");if(a&&u!==G)return i("origin_mismatch",`a connection from the panel page may only be host ${G}`);if(!this.live.has(u)&&this.live.size>=V)return i("too_many_peers",`at most ${V} panels`);clearTimeout(t),this.live.get(u)?.conn.close(1e3,"replaced by a newer connection"),n=u;let f={id:u,name:String(p.name??u),version:String(p.version??""),platform:String(p.platform??""),capabilities:Array.isArray(r.capabilities)?r.capabilities.map(String):[],optional_verbs:Array.isArray(r.optional_verbs)?r.optional_verbs.map(String):[]};this.live.set(u,{peer:f,conn:e,pending:new Map}),e.send(JSON.stringify({type:"welcome",protocol:k,app:{name:"conformtools",version:$}})),this.waiters=this.waiters.filter(l=>l.host===u?(l.resolve(),!1):!0);return}let c=this.live.get(n);if(!(!c||c.conn!==e))if(r.type==="response"){let i=c.pending.get(String(r.id));if(!i)return;if(c.pending.delete(String(r.id)),clearTimeout(i.timer),r.ok)i.resolve(r.result??null);else{let p=r.error??{};i.reject(new b(p.code??"peer_error",`${n}: ${p.message??p.code??"error"}`))}}else r.type==="event"&&(this.events.push({host:n,name:String(r.name),data:r.data}),this.events.length>200&&this.events.shift())}),e.onClose(()=>{if(clearTimeout(t),!n)return;let s=this.live.get(n);if(s?.conn===e){for(let r of s.pending.values())clearTimeout(r.timer),r.reject(new b("disconnected",`${n}: the panel disconnected`));this.live.delete(n)}})}},E=null;function Pe(){return E??=(async()=>{let o=new H;return await o.start(),o})(),E.catch(()=>{E=null}),E}function ke(){E=null}export{$ as a,Q as b,q as c,ee as d,ve as e,de as f,k as g,re as h,b as i,_ as j,B as k,X as l,H as m,Pe as n,ke as o};