conformtools 0.6.20 → 0.6.22

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 (83) hide show
  1. package/dist/account-ZGDVLMZA.js +3 -0
  2. package/dist/{agent-hook-setup-D2QNHA3V.js → agent-hook-setup-ZY4UBZIG.js} +1 -1
  3. package/dist/{analysis-engine-VNGF3DE4.js → analysis-engine-BBOSGAB2.js} +1 -1
  4. package/dist/{bridge-MLBUD6XW.js → bridge-56MINHUF.js} +1 -1
  5. package/dist/browser/timeline_core_bg.wasm +0 -0
  6. package/dist/{chunk-2WNNDPVR.js → chunk-3KS3547B.js} +1 -1
  7. package/dist/{chunk-L2RTMZCN.js → chunk-4I4MV3DE.js} +1 -1
  8. package/dist/{chunk-OSPDH2RK.js → chunk-64AMZWOI.js} +1 -1
  9. package/dist/{chunk-6IL7M3VP.js → chunk-65SLDY2M.js} +72 -72
  10. package/dist/{chunk-3WJSWOCS.js → chunk-67VLJJ75.js} +2 -2
  11. package/dist/{chunk-EWW5KWAO.js → chunk-6C3EEZH3.js} +1 -1
  12. package/dist/{chunk-4UT55WZA.js → chunk-BFN565RJ.js} +1 -1
  13. package/dist/{chunk-WYI4LL4P.js → chunk-CHEQJC4U.js} +190 -190
  14. package/dist/{chunk-A7AYMSY7.js → chunk-DHDSDH6R.js} +2 -2
  15. package/dist/chunk-E75BCWXY.js +4 -0
  16. package/dist/{chunk-V2FVIZT7.js → chunk-FSXF4K3J.js} +1 -1
  17. package/dist/{chunk-M545OKDZ.js → chunk-HNEKQMQG.js} +1 -1
  18. package/dist/chunk-IW5M45CL.js +3 -0
  19. package/dist/{chunk-2GRXBIJB.js → chunk-JGI5YEGH.js} +1 -1
  20. package/dist/chunk-JUJESM4P.js +3 -0
  21. package/dist/{chunk-567IWIX6.js → chunk-M3DXHHD7.js} +1 -1
  22. package/dist/chunk-NHWWMLZW.js +5 -0
  23. package/dist/{chunk-HROU7LLU.js → chunk-O5HYVCFL.js} +1 -1
  24. package/dist/chunk-OCNKVM26.js +7 -0
  25. package/dist/{chunk-HCT34NDA.js → chunk-OVBFJOO2.js} +1 -1
  26. package/dist/{chunk-ATEWMIY5.js → chunk-PKKUIGZ5.js} +1 -1
  27. package/dist/{chunk-GBNPOZ32.js → chunk-QNVFSA7C.js} +1 -1
  28. package/dist/{chunk-ZAL7Y5VZ.js → chunk-QPSQQEO6.js} +1 -1
  29. package/dist/{chunk-2DEUYEQD.js → chunk-REBF4U5B.js} +1 -1
  30. package/dist/{chunk-2S2ZPQQD.js → chunk-REGL3GQB.js} +1 -1
  31. package/dist/{chunk-4V3KLFCJ.js → chunk-TFKKODSA.js} +1 -1
  32. package/dist/{chunk-JVJUJKUP.js → chunk-Z3LQ56WS.js} +1 -1
  33. package/dist/{chunk-LUKA7UUJ.js → chunk-ZCQTIYXB.js} +1 -1
  34. package/dist/chunk-ZPIY5DOU.js +3 -0
  35. package/dist/{claude-setup-AI4WXN2V.js → claude-setup-6RMV3QZM.js} +1 -1
  36. package/dist/cli.js +2 -2
  37. package/dist/{cr3-wasm-DIWL7CPH.js → cr3-wasm-HWPQ3QAN.js} +1 -1
  38. package/dist/{dng-wasm-PE463PG2.js → dng-wasm-D7HO2OUE.js} +1 -1
  39. package/dist/{dpx-wasm-DKE3LJ6Z.js → dpx-wasm-ASRFRLRT.js} +1 -1
  40. package/dist/{exr-wasm-HAFH3YA5.js → exr-wasm-Y53DGEKJ.js} +1 -1
  41. package/dist/flame/hook/conformtools_flame/verbs.py +21 -4
  42. package/dist/framing-JYGNU6TH.js +3 -0
  43. package/dist/gfx-worker.js +1 -1
  44. package/dist/{h264-4ETGWMKR.js → h264-ZJCLCYYY.js} +1 -1
  45. package/dist/{h264-mxf-EFHHQL7X.js → h264-mxf-BI4ACQUH.js} +1 -1
  46. package/dist/{host-relink-MVHI3YQI.js → host-relink-XMVOQYKN.js} +1 -1
  47. package/dist/hosted-7KVSASRJ.js +3 -0
  48. package/dist/hosts-ZPBLYFYP.js +3 -0
  49. package/dist/http.js +4 -4
  50. package/dist/{inspect-5TMUYGAL.js → inspect-4RF2SDJR.js} +16 -17
  51. package/dist/{isobmff-55TPOVCK.js → isobmff-FZBZCEYH.js} +1 -1
  52. package/dist/{mc-video-GKWEWCEQ.js → mc-video-IUPFHPIS.js} +1 -1
  53. package/dist/mcp.js +1 -1
  54. package/dist/{media-HCKSVARE.js → media-R677IADY.js} +1 -1
  55. package/dist/{media_core-XOKN7UUF.js → media_core-KHSB6EFN.js} +2 -2
  56. package/dist/mxf-IUCZVILV.js +3 -0
  57. package/dist/{ops-UGZODMYE.js → ops-L5X3Q6SQ.js} +1 -1
  58. package/dist/{probe-YOYK7HR5.js → probe-VB6JH6ZJ.js} +1 -1
  59. package/dist/{r3d-EKISZSKU.js → r3d-EIQEVYGC.js} +1 -1
  60. package/dist/{r3d-XHSJUARW.js → r3d-VBXKIIRY.js} +1 -1
  61. package/dist/resolve-bridge.py +208 -13
  62. package/dist/{sequence-patch-5MFTY52Q.js → sequence-patch-OHYBBKKZ.js} +1 -1
  63. package/dist/{still-IDLCMQRD.js → still-XAFHXXC3.js} +1 -1
  64. package/dist/{still-wasm-54HEDTRX.js → still-wasm-ZG6PA67L.js} +1 -1
  65. package/dist/{store-6XN5Q6UG.js → store-ZXNF2RXS.js} +1 -1
  66. package/dist/{tiff-wasm-O7XUGXIO.js → tiff-wasm-AHQJJAK2.js} +1 -1
  67. package/dist/timeline-LJYGRP3R.js +3 -0
  68. package/dist/wasm/media_core_bg.wasm +0 -0
  69. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  70. package/dist/{wav-OLA3QYFJ.js → wav-4COVRAK3.js} +1 -1
  71. package/package.json +5 -5
  72. package/dist/account-VD3EE5UT.js +0 -3
  73. package/dist/chunk-2XQ42O7E.js +0 -7
  74. package/dist/chunk-COALWMI7.js +0 -4
  75. package/dist/chunk-GHP6HDLM.js +0 -3
  76. package/dist/chunk-IPQLKAF2.js +0 -4
  77. package/dist/chunk-MU5AGXSH.js +0 -3
  78. package/dist/chunk-Y7PFSVRX.js +0 -3
  79. package/dist/framing-U46POZQG.js +0 -3
  80. package/dist/hosted-6BLHLZXM.js +0 -3
  81. package/dist/hosts-7UO4QETB.js +0 -3
  82. package/dist/mxf-AJTCMKTX.js +0 -3
  83. package/dist/timeline-TFF3L7JP.js +0 -3
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{Ha as v,na as g,pa as b}from"./chunk-L2RTMZCN.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-AJTCMKTX.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
3
+ import{Ha as v,na as g,pa as b}from"./chunk-4I4MV3DE.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-IUCZVILV.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as T}from"./chunk-JVJUJKUP.js";import{c as D}from"./chunk-OSPDH2RK.js";import{$b as N,S as M,Vb as P,dc as q}from"./chunk-6IL7M3VP.js";import"./chunk-IN6XVTUS.js";import{l as A}from"./chunk-GBNPOZ32.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-V2FVIZT7.js";import"./chunk-GHP6HDLM.js";import"./chunk-LUKA7UUJ.js";import"./chunk-ATEWMIY5.js";import"./chunk-2GRXBIJB.js";import"./chunk-EWW5KWAO.js";import"./chunk-567IWIX6.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-2DEUYEQD.js";import"./chunk-4V3KLFCJ.js";import"./chunk-2S2ZPQQD.js";import"./chunk-ZAL7Y5VZ.js";import"./chunk-IPQLKAF2.js";import"./chunk-Y7PFSVRX.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-L2RTMZCN.js";import"./chunk-3WJSWOCS.js";import"./chunk-2XQ42O7E.js";import"./chunk-M545OKDZ.js";import"./chunk-COALWMI7.js";import{N as x,O as E,aa as U,ba as R,da as k,q as O,u as S}from"./chunk-MU5AGXSH.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let o=await V(s,i);return await I(s,o.session,i),o}async function I(s,i,o){let r=await s.liveMarkers(o).catch(()=>null);if(!r)return;let l=i.timelines,e=l.find(m=>m.kind!=="compound")??l[0];if(!e)return;let t=(m,f,a,p)=>({id:`live-${p??"tl"}-${m}`,time:{value:m},duration:{value:Math.max(1,f)},color:a.color,name:a.name,note:a.note,...p?{item_id:p}:{}}),n=r.timeline.map(m=>t(m.frame,m.duration,m)),c=e.tracks.filter(m=>m.kind==="Video");for(let m of r.clips){let f=c[m.track-1]?.items.find(a=>a.timeline_range?.start?.value===m.start);if(f)for(let a of m.markers)n.push(t(a.frame,a.duration,a,f.id))}e.markers=n}async function V(s,i){let o=await s.items({timeline:i,kind:"video"}),r=o.items.map(f=>`${f.kind}:${f.track}:${f.start}:${f.end-f.start}`),l=async f=>{let a=await D(f,o.timeline).catch(()=>null);if(!a||!r.every(d=>a.has(d)))return null;let{session:p}=await P(f,"prproj"),u=p.timelines.find(d=>d.name===o.timeline);return u?z(p,u):null};if(o.project_path){let f=await l(o.project_path);if(f)return await C(f),{session:f,from:"the saved project (matches the live sequence)",path:o.project_path};let a=k(R(o.project_path),"Adobe Premiere Pro Auto-Save"),p=U(o.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let d of E(a))d.isFile&&d.name.startsWith(`${p}--`)&&d.name.endsWith(".prproj")&&u.push({path:k(a,d.name),mtime:(await S(k(a,d.name))).mtime?.getTime()??0})}catch{}for(let d of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await l(d.path);if(g&&await C(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(d.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:d.path}}}let e=k(await x("conform-ppro-"),"live.otio"),t=await s.export({timeline:i,out_path:e}),{session:n}=await P(t.path,t.format);if(await W(s,n),await Z(n),typeof o.drop_frame=="boolean")for(let f of n.timelines)f.is_drop_frame=o.drop_frame;await C(n);for(let f of n.timelines)for(let a of f.tracks)for(let p of a.items){let u=p;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let c=await s.model(i).then(f=>f.items.filter(a=>Object.keys(a.sizing??{}).length).map(a=>`${a.name??a.file_path.split("/").pop()} (V${a.track} @${a.start-f.start_frame})`)).catch(()=>[]),m=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${c.length?` \u2014 ${c.length} clip(s) here have Motion that will not carry: ${c.slice(0,6).join(", ")}${c.length>6?"\u2026":""}`:""}; save the project (or wait for its auto-save) and run it again for every one of them`;return{session:n,from:"Premiere's OTIO export of the live sequence (no saved or auto-saved copy matches it yet)",path:t.path,lossy:m}}async function C(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let l=y(r);l&&await S(l).then(e=>e.isFile,()=>!1)&&i.add(R(l))}let o=s;for(let r of i){let l=await T(o,{media_root:r,gather:"path",criteria:{file_name:!0,file_name_mode:"tight"},lane:"both",reset:!1,dry_run:!1,compare:!1,cap:2e3,remember:!1}).catch(()=>null);l?.changed&&(o=l.session)}return o!==s&&Object.assign(s,o),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function Z(s){let i=0;for(let o of s.media_references??[]){if(o.source_resolution_w)continue;let r=y(o),l=r?await A(r).catch(()=>null):null;if(!l)continue;let e=l;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&o[t]==null&&(o[t]=e[t]);o.source_fps??=e.source_fps??null,o.source_timecode??=e.source_timecode??null,!o.available_range&&e.available_range&&(o.available_range=e.available_range),i++}return i}async function re(s,i){let o=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!o.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],l=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of o){let n=l.get(t.offline_reference.clip_id);if(n?.file){let c=i.media_references.find(m=>y(m)===n.file);c||(c={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(c)),t.offline_reference.media_reference_id=c.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:c}=await import("./store-6XN5Q6UG.js"),m=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),f=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:m}:{clip_id:n.id,out_path:m}),{session:a}=await P(f.path,"drt");a=(await M(a))?.session??a,t.offline_reference.session_id=(await c(a,f.path,"drt")).id,e++}else t.offline_reference=null}return e}async function W(s,i){let o=(await s.projectClips()).clips,r=new Map(o.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),l=0;for(let e of i.media_references??[]){if(e.source_timecode)continue;let t=r.get(y(e));if(t){e.source_timecode=F(t.start_frame,t.fps),e.source_fps??=t.fps,l++;continue}let n=y(e),c=n?await A(n).catch(()=>null):null;c?.source_timecode&&(e.source_timecode=c.source_timecode,e.source_fps??=c.source_fps??null,l++)}return l}function z(s,i){let o=new Map(s.timelines.map(l=>[l.id,l])),r=[i];for(let l=0;l<r.length;l++)for(let e of r[l].tracks)for(let t of e.items){let n=t.nested_timeline_id,c=n?o.get(n):void 0;c&&!r.includes(c)&&r.push(c)}return{...s,timelines:r}}function X(s,i){let o=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let c=o.get(n.id),m=y(n);c!==void 0&&m&&m!==c&&r.push({ref_id:n.id,old:c,new:m})}let l=new Map(r.map(n=>[n.ref_id,n])),e=[],t=i.timelines.find(n=>n.kind==="primary")??i.timelines[0];for(let n of t?.tracks??[])if(n.kind==="Video")for(let c of n.items){let m=c.media_reference_id?l.get(c.media_reference_id):void 0;!m||c.kind!=="clip"||!c.source_range||e.push({track:n.track_index,start:c.timeline_range.start.value,duration:c.timeline_range.duration.value,src_in:c.source_range.start.value,path:m.new,name:c.name??""})}return{media:r,cuts:e}}async function oe(s,i){let{session:o,from:r,lossy:l}=await H(s,i.timeline),e=await T(structuredClone(o),{media_root:i.media_root,gather:"walk",reset:!0,lane:"video",dry_run:!1,cap:2e3,criteria:i.criteria??(i.mode==="cut_in"?{file_name:!1,reel_name:!0}:{file_name:!0,file_name_mode:"loose"}),tolerances:i.tolerances}),{media:t,cuts:n}=X(o,e.session),c=[`read from ${r}`,...l&&i.mode==="new_version"?[`\u26A0 ${l}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],m=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...c,...m,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
3
+ import{a as T}from"./chunk-Z3LQ56WS.js";import{c as D}from"./chunk-64AMZWOI.js";import{$b as N,S as M,Vb as P,dc as q}from"./chunk-65SLDY2M.js";import"./chunk-IN6XVTUS.js";import{l as A}from"./chunk-QNVFSA7C.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-FSXF4K3J.js";import"./chunk-JUJESM4P.js";import"./chunk-ZCQTIYXB.js";import"./chunk-PKKUIGZ5.js";import"./chunk-JGI5YEGH.js";import"./chunk-6C3EEZH3.js";import"./chunk-M3DXHHD7.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-REBF4U5B.js";import"./chunk-TFKKODSA.js";import"./chunk-REGL3GQB.js";import"./chunk-QPSQQEO6.js";import"./chunk-IW5M45CL.js";import"./chunk-NHWWMLZW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-4I4MV3DE.js";import"./chunk-67VLJJ75.js";import"./chunk-OCNKVM26.js";import"./chunk-HNEKQMQG.js";import"./chunk-E75BCWXY.js";import{N as x,O as E,aa as U,ba as R,da as k,q as O,u as S}from"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let o=await V(s,i);return await I(s,o.session,i),o}async function I(s,i,o){let r=await s.liveMarkers(o).catch(()=>null);if(!r)return;let l=i.timelines,e=l.find(m=>m.kind!=="compound")??l[0];if(!e)return;let t=(m,f,a,p)=>({id:`live-${p??"tl"}-${m}`,time:{value:m},duration:{value:Math.max(1,f)},color:a.color,name:a.name,note:a.note,...p?{item_id:p}:{}}),n=r.timeline.map(m=>t(m.frame,m.duration,m)),c=e.tracks.filter(m=>m.kind==="Video");for(let m of r.clips){let f=c[m.track-1]?.items.find(a=>a.timeline_range?.start?.value===m.start);if(f)for(let a of m.markers)n.push(t(a.frame,a.duration,a,f.id))}e.markers=n}async function V(s,i){let o=await s.items({timeline:i,kind:"video"}),r=o.items.map(f=>`${f.kind}:${f.track}:${f.start}:${f.end-f.start}`),l=async f=>{let a=await D(f,o.timeline).catch(()=>null);if(!a||!r.every(d=>a.has(d)))return null;let{session:p}=await P(f,"prproj"),u=p.timelines.find(d=>d.name===o.timeline);return u?z(p,u):null};if(o.project_path){let f=await l(o.project_path);if(f)return await C(f),{session:f,from:"the saved project (matches the live sequence)",path:o.project_path};let a=k(R(o.project_path),"Adobe Premiere Pro Auto-Save"),p=U(o.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let d of E(a))d.isFile&&d.name.startsWith(`${p}--`)&&d.name.endsWith(".prproj")&&u.push({path:k(a,d.name),mtime:(await S(k(a,d.name))).mtime?.getTime()??0})}catch{}for(let d of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await l(d.path);if(g&&await C(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(d.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:d.path}}}let e=k(await x("conform-ppro-"),"live.otio"),t=await s.export({timeline:i,out_path:e}),{session:n}=await P(t.path,t.format);if(await W(s,n),await Z(n),typeof o.drop_frame=="boolean")for(let f of n.timelines)f.is_drop_frame=o.drop_frame;await C(n);for(let f of n.timelines)for(let a of f.tracks)for(let p of a.items){let u=p;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let c=await s.model(i).then(f=>f.items.filter(a=>Object.keys(a.sizing??{}).length).map(a=>`${a.name??a.file_path.split("/").pop()} (V${a.track} @${a.start-f.start_frame})`)).catch(()=>[]),m=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${c.length?` \u2014 ${c.length} clip(s) here have Motion that will not carry: ${c.slice(0,6).join(", ")}${c.length>6?"\u2026":""}`:""}; save the project (or wait for its auto-save) and run it again for every one of them`;return{session:n,from:"Premiere's OTIO export of the live sequence (no saved or auto-saved copy matches it yet)",path:t.path,lossy:m}}async function C(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let l=y(r);l&&await S(l).then(e=>e.isFile,()=>!1)&&i.add(R(l))}let o=s;for(let r of i){let l=await T(o,{media_root:r,gather:"path",criteria:{file_name:!0,file_name_mode:"tight"},lane:"both",reset:!1,dry_run:!1,compare:!1,cap:2e3,remember:!1}).catch(()=>null);l?.changed&&(o=l.session)}return o!==s&&Object.assign(s,o),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function Z(s){let i=0;for(let o of s.media_references??[]){if(o.source_resolution_w)continue;let r=y(o),l=r?await A(r).catch(()=>null):null;if(!l)continue;let e=l;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&o[t]==null&&(o[t]=e[t]);o.source_fps??=e.source_fps??null,o.source_timecode??=e.source_timecode??null,!o.available_range&&e.available_range&&(o.available_range=e.available_range),i++}return i}async function re(s,i){let o=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!o.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],l=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of o){let n=l.get(t.offline_reference.clip_id);if(n?.file){let c=i.media_references.find(m=>y(m)===n.file);c||(c={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(c)),t.offline_reference.media_reference_id=c.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:c}=await import("./store-ZXNF2RXS.js"),m=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),f=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:m}:{clip_id:n.id,out_path:m}),{session:a}=await P(f.path,"drt");a=(await M(a))?.session??a,t.offline_reference.session_id=(await c(a,f.path,"drt")).id,e++}else t.offline_reference=null}return e}async function W(s,i){let o=(await s.projectClips()).clips,r=new Map(o.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),l=0;for(let e of i.media_references??[]){if(e.source_timecode)continue;let t=r.get(y(e));if(t){e.source_timecode=F(t.start_frame,t.fps),e.source_fps??=t.fps,l++;continue}let n=y(e),c=n?await A(n).catch(()=>null):null;c?.source_timecode&&(e.source_timecode=c.source_timecode,e.source_fps??=c.source_fps??null,l++)}return l}function z(s,i){let o=new Map(s.timelines.map(l=>[l.id,l])),r=[i];for(let l=0;l<r.length;l++)for(let e of r[l].tracks)for(let t of e.items){let n=t.nested_timeline_id,c=n?o.get(n):void 0;c&&!r.includes(c)&&r.push(c)}return{...s,timelines:r}}function X(s,i){let o=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let c=o.get(n.id),m=y(n);c!==void 0&&m&&m!==c&&r.push({ref_id:n.id,old:c,new:m})}let l=new Map(r.map(n=>[n.ref_id,n])),e=[],t=i.timelines.find(n=>n.kind==="primary")??i.timelines[0];for(let n of t?.tracks??[])if(n.kind==="Video")for(let c of n.items){let m=c.media_reference_id?l.get(c.media_reference_id):void 0;!m||c.kind!=="clip"||!c.source_range||e.push({track:n.track_index,start:c.timeline_range.start.value,duration:c.timeline_range.duration.value,src_in:c.source_range.start.value,path:m.new,name:c.name??""})}return{media:r,cuts:e}}async function oe(s,i){let{session:o,from:r,lossy:l}=await H(s,i.timeline),e=await T(structuredClone(o),{media_root:i.media_root,gather:"walk",reset:!0,lane:"video",dry_run:!1,cap:2e3,criteria:i.criteria??(i.mode==="cut_in"?{file_name:!1,reel_name:!0}:{file_name:!0,file_name_mode:"loose"}),tolerances:i.tolerances}),{media:t,cuts:n}=X(o,e.session),c=[`read from ${r}`,...l&&i.mode==="new_version"?[`\u26A0 ${l}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],m=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...c,...m,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
4
4
  `).slice(-6).join(`
5
5
  `)].filter(Boolean).join(`
6
6
  `),data:{media:t,cuts:n,from:r}};if(i.mode==="replace"||i.mode==="hires"||i.mode==="proxy"){let d=(await s.projectClips()).clips.flatMap(w=>t.filter(j=>j.old===w.file).map(j=>({clip:w.id,path:j.new,mode:i.mode}))),g=i.mode==="replace"?L(o,e.session,t):new Map,_=g.size?await Y(s,new Set(g.keys())):[],b=await s.relinkClips(d),h=b.results.filter(w=>w.ok).length,$=[...c,`${i.mode==="hires"?"attached full-res behind":i.mode==="proxy"?"attached as proxies to":"repointed"} ${h}/${d.length} project clip(s)${i.mode==="proxy"?" (Toggle Proxies in Premiere switches)":""}`,...m,...b.results.filter(w=>!w.ok).map(w=>` refused: ${w.detail??"Premiere refused"}`)],v=_.length?await B(s,_,g):null;return v&&$.push(...v.lines),{text:$.join(`
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a,b,c,d}from"./chunk-IW5M45CL.js";import"./chunk-NHWWMLZW.js";import"./chunk-C2ESM27Z.js";import"./chunk-OCNKVM26.js";import"./chunk-HNEKQMQG.js";import"./chunk-E75BCWXY.js";import"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";export{a as HOSTED_READ_KEYS,b as readHosted,d as shareOriginal,c as writeHosted};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{g as a,h as b,i as c,j as d}from"./chunk-DHDSDH6R.js";import"./chunk-64AMZWOI.js";import"./chunk-65SLDY2M.js";import"./chunk-IN6XVTUS.js";import"./chunk-QNVFSA7C.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-FSXF4K3J.js";import"./chunk-JUJESM4P.js";import"./chunk-ZCQTIYXB.js";import"./chunk-PKKUIGZ5.js";import"./chunk-JGI5YEGH.js";import"./chunk-6C3EEZH3.js";import"./chunk-M3DXHHD7.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-REBF4U5B.js";import"./chunk-TFKKODSA.js";import"./chunk-REGL3GQB.js";import"./chunk-QPSQQEO6.js";import"./chunk-IW5M45CL.js";import"./chunk-NHWWMLZW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-4I4MV3DE.js";import"./chunk-67VLJJ75.js";import"./chunk-OCNKVM26.js";import"./chunk-HNEKQMQG.js";import"./chunk-E75BCWXY.js";import"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";export{a as AVID_SETUP,b as FLAME_SETUP,d as adapter,c as setAdapter};
package/dist/http.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as jt}from"./chunk-4UT55WZA.js";import{a as Tt,b as vt,c as Rt,d as Et,e as Pt,f as Ct,g as $t,h as At,k as O,l as Nt,o as $,p as Mt}from"./chunk-WYI4LL4P.js";import"./chunk-HCT34NDA.js";import"./chunk-JVJUJKUP.js";import"./chunk-A7AYMSY7.js";import"./chunk-OSPDH2RK.js";import"./chunk-2WNNDPVR.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import{Eb as wt,Fb as _t,G as it,H as ct,J as ht,Q as W,Uc as yt,Yc as bt,Zc as D,_c as T,fd as xt,hd as St,jd as Ot,yc as kt}from"./chunk-6IL7M3VP.js";import"./chunk-IN6XVTUS.js";import"./chunk-GBNPOZ32.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-V2FVIZT7.js";import{a as at}from"./chunk-GHP6HDLM.js";import"./chunk-LUKA7UUJ.js";import"./chunk-ATEWMIY5.js";import"./chunk-2GRXBIJB.js";import"./chunk-EWW5KWAO.js";import"./chunk-567IWIX6.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-2DEUYEQD.js";import"./chunk-4V3KLFCJ.js";import"./chunk-2S2ZPQQD.js";import"./chunk-ZAL7Y5VZ.js";import"./chunk-IPQLKAF2.js";import"./chunk-Y7PFSVRX.js";import"./chunk-C2ESM27Z.js";import"./chunk-LMRPCWHV.js";import"./chunk-HROU7LLU.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-L2RTMZCN.js";import{C,E as gt,t as V,u as ut,v as dt,x as pt,y as mt,z as ft}from"./chunk-3WJSWOCS.js";import{l as lt,p as G}from"./chunk-2XQ42O7E.js";import"./chunk-M545OKDZ.js";import{a as H}from"./chunk-COALWMI7.js";import{A as F,B as et,C as j,E as nt,I as L,N as J,O as ot,P as st,W as rt,aa as U,b as v,ba as I,da as S,o as P,u as B,v as Q,y as q,z as tt}from"./chunk-MU5AGXSH.js";import"./chunk-PSANHDZM.js";import N from"node:process";var Lt=new Map;function Ut(t,i,s,b){let a=`${t}:${s}:${b}`,o=Lt.get(a);return o||(o=(async()=>{let n=S(P(),"cache","grade-luts",t);await j(n);let d=S(n,`V${s}_${b}.cube`);if(!await Q(d)){let{adapter:_}=await import("./hosts-7UO4QETB.js");if((await _("resolve").clipLut({timeline:i,track:s,start:b,out_path:d})).ok===!1)return null}return d})().catch(()=>null),Lt.set(a,o)),o}var Vt=new Set(["/app/convert","/app/canonicalize"]);function zt(t,i){let s=(i??"").split(";")[0].trim().toLowerCase();return s==="application/json"||s==="application/octet-stream"&&Vt.has(t)}function Wt(t){let i=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(i)?`_${i}`:i}var K={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Bt(){try{return JSON.parse(await tt(S(P(),"projects","projects.json")))}catch{return[]}}async function Dt(){let t=await O("project",{action:"list"});if(!t.isError){let i=t.structuredContent?.projects??[];return await j(S(P(),"projects")),await et(S(P(),"projects","projects.json"),JSON.stringify(i)),{projects:[K,...i],offline:!1}}return{projects:[K,...await Bt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function Kt(t){return t==="local"?K:(await Bt()).find(i=>i.id===t)??{id:t,name:t}}async function Ft(t,i,s,b,a=(o,n)=>new Response(o,{headers:{"content-type":n}})){if(i[0]!=="app")return null;let[,o,n,d]=i,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(o==="policy"&&t.method==="GET"){let{config:e}=await import("./account-VD3EE5UT.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return s(r?.ok?await r.json():{offline:!0})}if(o==="account"&&t.method==="GET"){let e=await O("account_status",{}),r=await G().then(c=>({app:!0,studio_tools:c.source==="licence"||lt(c)?.studio_tools!==!1}),c=>({app:!1,app_reason:c.message,code:c.code,...c.data?.in_use_by?{in_use_by:c.data.in_use_by}:{}}));return s({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await G().then(()=>null,r=>r);if(e)return s({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(o==="events"&&t.method==="GET")return b(Et());if(o==="front"&&t.method==="POST"){let e=await t.json();return vt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),s({ok:!0})}if(o==="problem"&&t.method==="POST"){let e=await t.json().catch(()=>({}));return await D("app_window",{isError:!0,content:[],structuredContent:{code:"window_error",message:`${String(e.what??"").slice(0,200)}${e.detail?`
4
- ${String(e.detail).slice(0,100)}`:""}`}},0),s({ok:!0})}if(o==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=U(e.get("name")||"timeline"),c=e.get("out")||"",p=JSON.parse(e.get("targets")||"[]"),l=JSON.parse(e.get("sequences")||"[]");if(!c||!p.length)return s({ok:!1,error:"a folder and at least one format are needed"},400);let u=await J("conform-te-"),f=S(u,r);await F(f,new Uint8Array(await t.arrayBuffer()));let h=await O("timeline_read",{path:f}),y=h.structuredContent?.session_id??h.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(h.isError||!y)return s({ok:!1,error:h.content[0]?.text??"could not read the timeline"});let w=(await C(y)).session.timelines.filter(x=>x.kind!=="compound"),k=l.length?w.filter(x=>l.includes(x.name??"")):w,m=[],R=0;for(let x of k)for(let E of p){let M=S(c,`${Wt(x.name??"timeline")}.${E.ext}`),Z=await O("timeline_write",{session_id:y,target:E.target,out_path:M,...k.length>1||w.length>1?{timeline_id:x.id}:{}});Z.isError?m.push(`${x.name} \u2192 ${E.target}: ${Z.content[0]?.text}`):R++}return await L(u).catch(()=>{}),s({ok:R>0,savedCount:R,...m.length?{error:m.join(`
5
- `)}:{}})}if(o==="fs"&&t.method==="POST"){let{op:e,path:r,offset:c=0,length:p=0}=await _();if(e==="statPath"){let l=await B(r).catch(()=>null);return s({ok:!0,result:l?{kind:l.isDirectory?"directory":"file",size:l.size,lastModified:Math.round(l.mtimeMs)}:null})}if(e==="readDir"){let l=[];for await(let u of ot(r))(u.isFile||u.isDirectory)&&l.push({name:u.name,kind:u.isDirectory?"directory":"file"});return s({ok:!0,result:l})}if(e==="readFile"){let l=p>0?p:Math.max(0,(await B(r)).size-Math.max(0,c)),u=512<<20;if(l>u)return s({ok:!1,code:"too_large",message:`${r} is ${Math.round(l/(1<<20))} MB: read it in parts (offset, length \u2264 ${u>>20} MB)`},413);let f=await st(r);try{return a(await f.readAt(Math.max(0,c),l),"application/octet-stream")}finally{await f.close()}}return s({ok:!1,code:"bad_request",message:`no fs op ${e}`},400)}if(o==="canonicalize"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=JSON.parse(e.get("sequences")||"[]"),c=JSON.parse(e.get("previous")||"[]"),p=await J("conform-te-");try{let l=S(p,U(e.get("name")||"timeline"));await F(l,new Uint8Array(await t.arrayBuffer()));let u=await O("timeline_read",{path:l}),f=u.structuredContent?.session_id??u.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(u.isError||!f)return s({ok:!1,error:u.content[0]?.text??"could not read the timeline"},422);let h=(await C(f)).session,y=h.timelines;if(r.length){let w=new Map;for(let m of c)w.set(m,(w.get(m)??0)+1);let k=new Set;for(let m of r){let R=h.timelines.filter(M=>M.kind!=="compound"&&(M.name??"")===m),x=w.get(m)??0;w.set(m,x+1);let E=R[Math.min(x,R.length-1)];E&&k.add(E)}y=h.timelines.filter(m=>m.kind==="compound"||k.has(m))}return s({ok:!0,session_id:f,session:{...h,timelines:y}})}finally{await L(p).catch(()=>{})}}if(o==="sessions"&&n&&d==="frame"){let e=new URL(t.url).searchParams,r=Math.max(0,Math.round(Number(e.get("f")??0))),c=Math.min(3840,Math.max(64,Number(e.get("w")??1280)|0));try{let f=(await C(n)).session,h=e.get("track")==="offline"?"offline":Number(e.get("track"))||void 0,y;if(e.get("grade")==="resolve"&&h!=="offline"){let k=(()=>{try{return wt(f,{record:r,timeline:e.get("timeline")??void 0,track:h})}catch{return null}})();k&&(y=await Ut(n,e.get("host_timeline")??void 0,k.video_track,k.record_start)??void 0)}let w=await _t(f,r,c,e.get("timeline")??void 0,h,y);if(w){let k=new Uint8Array(12+w.px.length),m=new DataView(k.buffer);return m.setUint32(0,w.w,!0),m.setUint32(4,w.h,!0),m.setUint32(8,w.order==="bgra"?1:0,!0),k.set(w.px,12),a(k,"application/x-conform-pixels")}}catch(f){return s({ok:!1,code:"no_frame",message:f.message},404)}let p=await O("timeline_frame",{session_id:n,record:r,width:c,...e.get("timeline")?{timeline:e.get("timeline")}:{}},{poll:!0}),l=p.structuredContent?.out_path;if(p.isError||!l)return s({ok:!1,code:String(p.structuredContent?.code??"no_frame"),message:p.content[0]?.text??"no picture here"},404);let u=await q(l);return await(U(I(l)).startsWith("conform-frame-")?L(I(l)):nt(l)).catch(()=>{}),a(u,"image/png")}if(o==="sessions"&&n&&t.method==="GET"){let e=await C(n).catch(()=>null);return e?s(e):s({ok:!1,code:"not_found"},404)}if(o==="sessions"&&!n)return s(await gt());if(o!=="projects")return s({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await _(),r=await O("project",{action:"create",name:e.name,client_name:e.client_name,handles:e.handles});return r.isError?s({...r.structuredContent,text:r.content[0]?.text},422):(await Dt(),s(r.structuredContent))}return s(await Dt())}if(!d){let[e,r,c,p,l,u]=await Promise.all([Kt(n),ut(n).catch(()=>null),ft(n),ht(n),xt(n).then(y=>y.facts).catch(()=>[]),n===V?null:St().catch(()=>null)]);await pt(n===V?null:{id:n,name:e.name??n});let{text:f="",...h}=r??{};return s({project:e,context:f,context_meta:h,sessions:c,activity:p.slice(-100).reverse(),known:Ot(l),facility:u?.text??""})}if(d==="sessions"&&t.method==="PUT")return await mt(n,String((await _()).session_id??"")),s({ok:!0});if(d==="context"&&t.method==="PUT"){let e=await _();try{let{text:r,...c}=await dt(n,String(e.text??""),e.base===void 0?void 0:e.base);return s({ok:!0,context:r,context_meta:c})}catch(r){if(r instanceof H&&r.code==="context_conflict"){let c=r.data?.current;return s({ok:!1,code:r.code,message:r.message,context:c.context,context_meta:{updated_at:c.context_updated_at,updated_by:c.context_updated_by_name??null}},409)}throw r}}return s({ok:!1,code:"not_found"},404)}catch(e){let r=e instanceof H?e:null;return s({ok:!1,code:r?.code??"internal",message:e.message},r?.code==="not_found"?404:r?.code==="invalid_args"?400:500)}}var Jt=t=>t==="1"?"app":"http",X=(t,i)=>t&&i.has(t)?t:"custom",A=new Map,Xt=500;function It(t){let i=null,s=Tt(a=>{switch(a.type){case"open":T(`app:open:${X(a.tool,t)}`);break;case"home":T("app:home");break;case"workspace":{let o=a.workspace;T("app:workspace",{counts:{open:Array.isArray(o?.open)?o.open.length:0}});break}case"settings":{let o=a.settings&&typeof a.settings=="object"?Object.keys(a.settings).filter(n=>/^[A-Za-z0-9_.]{1,64}$/.test(n)).slice(0,16):[];T("app:settings",{fields:o});break}case"run":{let o=a.run;if(!o?.id||!o.status||!/^[a-z]+$/.test(o.status)||A.get(o.id)===o.status)break;A.size>=Xt&&A.delete(A.keys().next().value),A.set(o.id,o.status),T(`app:run_${o.status}:${X(o.tool,t)}`,{fields:[o.by==="app"?"app":"assistant"],ok:o.status!=="failed"});break}}}),b=Rt(a=>{let o=/^[a-z]+$/.test(a.view)?a.view:"other",n=`${a.project}|${o}|${a.tool??""}`;n!==i&&(i=n,T(o==="tool"?`app:view:tool:${X(a.tool,t)}`:`app:view:${o}`))});return()=>{s(),b()}}bt();var Yt=Number(v("CONFORM_HTTP_PORT")??7791);v("CONFORM_EXIT_WITH_PARENT")==="1"&&(N.stdin.on("end",()=>N.exit(0)),N.stdin.on("close",()=>N.exit(0)),N.stdin.resume());yt(Jt(v("CONFORM_EXIT_WITH_PARENT")));It(new Set([...kt.map(t=>t.id),...$.map(t=>t.name),"context","source"]));var Y=v("CONFORM_HTTP_TOKEN")??"",Gt=(v("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),z=(t,i=new Headers)=>{let s=t.headers.get("origin")??"";return Gt.includes(s)&&i.set("access-control-allow-origin",s),i.set("access-control-allow-headers","authorization, content-type, x-conform-client, x-conform-poll"),i.set("access-control-allow-methods","GET, POST, PUT, DELETE, OPTIONS"),i.set("access-control-allow-private-network","true"),i.set("vary","origin"),i},Ht=new Set,g=(t,i,s=200)=>new Response(JSON.stringify(i),{status:s,headers:z(t,new Headers({"content-type":"application/json"}))});rt({hostname:"127.0.0.1",port:Yt,onListen:t=>{Ht=new Set([`127.0.0.1:${t}`,`localhost:${t}`,`[::1]:${t}`]),console.error(`conformtools HTTP API on http://127.0.0.1:${t} (${$.length} verbs)`),jt(t,Y)}},async t=>{let i=new URL(t.url),s=(t.headers.get("host")??"").toLowerCase();if(!Ht.has(s))return new Response("forbidden host",{status:403});let b=t.headers.get("origin");if(b&&!Gt.includes(b))return new Response("forbidden origin",{status:403});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:z(t)});if((t.method==="POST"||t.method==="PUT")&&t.headers.get("content-length")!=="0"&&!zt(i.pathname,t.headers.get("content-type")))return g(t,{ok:!1,code:"unsupported_media_type",message:"send the body as application/json"},415);if(Y&&t.headers.get("authorization")!==`Bearer ${Y}`&&i.pathname!=="/health")return g(t,{ok:!1,code:"unauthorized"},401);let a=i.pathname.split("/").filter(Boolean);try{if(i.pathname==="/health")return g(t,{ok:!0,verbs:$.length,version:at,engine:W()});if(a[0]==="verbs"&&a.length===1&&t.method==="GET")return g(t,$.map(n=>({name:n.name,title:n.title,description:n.description,long:!!n.long,input_schema:ct(it.object(n.inputSchema)),protected_stages:n.protectedStages??[],engine:W()})));if(a[0]==="verbs"&&a.length===2&&t.method==="POST"){let n=Mt(a[1]);if(!n)return g(t,{ok:!1,code:"not_found",message:`unknown verb ${a[1]}`},404);let d=t.headers.get("content-type")?.includes("json")?await t.json():{},_=Nt(n.name,d);if(!_.ok)return g(t,{..._.result.structuredContent,text:_.result.content[0].text},400);let e=t.headers.get("x-conform-client"),r=e?null:Pt(n.name,_.data,()=>void T("finish_missing"));r&&D(n.name,r,0,Object.keys(_.data));let c=r??await O(n.name,_.data,{client:e??"http",poll:t.headers.get("x-conform-poll")==="1"});return g(t,{...c.structuredContent??{ok:!c.isError},text:c.content.map(p=>p.text).join(`
6
- `)},c.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&v("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-MLBUD6XW.js"),d=await n();return await d.waitFor(a[1],5e3)?g(t,{ok:!0,result:await d.request(a[1],a[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):g(t,{ok:!1,code:"not_connected"},409)}let o=await Ft(t,a,(n,d)=>g(t,n,d),n=>new Response(n,{headers:z(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,d)=>new Response(n,{headers:z(t,new Headers({"content-type":d,"cache-control":"no-store"}))}));if(o)return o;if(a[0]==="jobs"&&a.length===1)return g(t,await At());if(a[0]==="jobs"&&a.length===2){if(t.method==="DELETE")return g(t,{ok:$t(a[1])});let n=await Ct(a[1]);return n?g(t,n):g(t,{ok:!1,code:"not_found"},404)}return g(t,{ok:!1,code:"not_found"},404)}catch(o){return g(t,{ok:!1,code:"internal",message:o instanceof Error?o.message:String(o)},500)}});
3
+ import{a as jt}from"./chunk-BFN565RJ.js";import{a as Tt,b as vt,c as Rt,d as Et,e as Pt,f as Ct,g as $t,h as At,k as O,l as Nt,o as $,p as Mt}from"./chunk-CHEQJC4U.js";import"./chunk-OVBFJOO2.js";import"./chunk-Z3LQ56WS.js";import"./chunk-DHDSDH6R.js";import"./chunk-64AMZWOI.js";import"./chunk-3KS3547B.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import{Eb as wt,Fb as _t,G as it,H as ct,J as ht,Q as W,Uc as yt,Yc as bt,Zc as D,_c as T,fd as xt,hd as St,jd as Ot,yc as kt}from"./chunk-65SLDY2M.js";import"./chunk-IN6XVTUS.js";import"./chunk-QNVFSA7C.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-FSXF4K3J.js";import{a as at}from"./chunk-JUJESM4P.js";import"./chunk-ZCQTIYXB.js";import"./chunk-PKKUIGZ5.js";import"./chunk-JGI5YEGH.js";import"./chunk-6C3EEZH3.js";import"./chunk-M3DXHHD7.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-REBF4U5B.js";import"./chunk-TFKKODSA.js";import"./chunk-REGL3GQB.js";import"./chunk-QPSQQEO6.js";import"./chunk-IW5M45CL.js";import"./chunk-NHWWMLZW.js";import"./chunk-C2ESM27Z.js";import"./chunk-LMRPCWHV.js";import"./chunk-O5HYVCFL.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-4I4MV3DE.js";import{C,E as gt,t as V,u as ut,v as dt,x as pt,y as mt,z as ft}from"./chunk-67VLJJ75.js";import{m as lt,q as G}from"./chunk-OCNKVM26.js";import"./chunk-HNEKQMQG.js";import{a as H}from"./chunk-E75BCWXY.js";import{A as F,B as et,C as j,E as nt,I as L,N as J,O as ot,P as st,W as rt,aa as U,b as v,ba as I,da as S,o as P,u as B,v as Q,y as q,z as tt}from"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";import N from"node:process";var Lt=new Map;function Ut(t,i,r,b){let a=`${t}:${r}:${b}`,o=Lt.get(a);return o||(o=(async()=>{let n=S(P(),"cache","grade-luts",t);await j(n);let d=S(n,`V${r}_${b}.cube`);if(!await Q(d)){let{adapter:_}=await import("./hosts-ZPBLYFYP.js");if((await _("resolve").clipLut({timeline:i,track:r,start:b,out_path:d})).ok===!1)return null}return d})().catch(()=>null),Lt.set(a,o)),o}var Vt=new Set(["/app/convert","/app/canonicalize"]);function zt(t,i){let r=(i??"").split(";")[0].trim().toLowerCase();return r==="application/json"||r==="application/octet-stream"&&Vt.has(t)}function Wt(t){let i=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(i)?`_${i}`:i}var K={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Bt(){try{return JSON.parse(await tt(S(P(),"projects","projects.json")))}catch{return[]}}async function Dt(){let t=await O("project",{action:"list"});if(!t.isError){let i=t.structuredContent?.projects??[];return await j(S(P(),"projects")),await et(S(P(),"projects","projects.json"),JSON.stringify(i)),{projects:[K,...i],offline:!1}}return{projects:[K,...await Bt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function Kt(t){return t==="local"?K:(await Bt()).find(i=>i.id===t)??{id:t,name:t}}async function Ft(t,i,r,b,a=(o,n)=>new Response(o,{headers:{"content-type":n}})){if(i[0]!=="app")return null;let[,o,n,d]=i,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(o==="policy"&&t.method==="GET"){let{config:e}=await import("./account-ZGDVLMZA.js"),s=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return r(s?.ok?await s.json():{offline:!0})}if(o==="account"&&t.method==="GET"){let e=await O("account_status",{}),s=await G().then(c=>({app:!0,studio_tools:c.source==="licence"||lt(c)?.studio_tools!==!1}),c=>({app:!1,app_reason:c.message,code:c.code,...c.data?.in_use_by?{in_use_by:c.data.in_use_by}:{}}));return r({...e.structuredContent,...e.structuredContent?.account??{},...s,text:e.content[0]?.text})}{let e=await G().then(()=>null,s=>s);if(e)return r({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(o==="events"&&t.method==="GET")return b(Et());if(o==="front"&&t.method==="POST"){let e=await t.json();return vt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),r({ok:!0})}if(o==="problem"&&t.method==="POST"){let e=await t.json().catch(()=>({})),s=/\bnot signed in\b/i.test(String(e.what??""))?"not_signed_in":"window_error";return await D("app_window",{isError:!0,content:[],structuredContent:{code:s,message:`${String(e.what??"").slice(0,200)}${e.detail?`
4
+ ${String(e.detail).slice(0,100)}`:""}`}},0),r({ok:!0})}if(o==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,s=U(e.get("name")||"timeline"),c=e.get("out")||"",p=JSON.parse(e.get("targets")||"[]"),l=JSON.parse(e.get("sequences")||"[]");if(!c||!p.length)return r({ok:!1,error:"a folder and at least one format are needed"},400);let u=await J("conform-te-"),f=S(u,s);await F(f,new Uint8Array(await t.arrayBuffer()));let h=await O("timeline_read",{path:f}),y=h.structuredContent?.session_id??h.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(h.isError||!y)return r({ok:!1,error:h.content[0]?.text??"could not read the timeline"});let w=(await C(y)).session.timelines.filter(x=>x.kind!=="compound"),k=l.length?w.filter(x=>l.includes(x.name??"")):w,m=[],R=0;for(let x of k)for(let E of p){let M=S(c,`${Wt(x.name??"timeline")}.${E.ext}`),Z=await O("timeline_write",{session_id:y,target:E.target,out_path:M,...k.length>1||w.length>1?{timeline_id:x.id}:{}});Z.isError?m.push(`${x.name} \u2192 ${E.target}: ${Z.content[0]?.text}`):R++}return await L(u).catch(()=>{}),r({ok:R>0,savedCount:R,...m.length?{error:m.join(`
5
+ `)}:{}})}if(o==="fs"&&t.method==="POST"){let{op:e,path:s,offset:c=0,length:p=0}=await _();if(e==="statPath"){let l=await B(s).catch(()=>null);return r({ok:!0,result:l?{kind:l.isDirectory?"directory":"file",size:l.size,lastModified:Math.round(l.mtimeMs)}:null})}if(e==="readDir"){let l=[];for await(let u of ot(s))(u.isFile||u.isDirectory)&&l.push({name:u.name,kind:u.isDirectory?"directory":"file"});return r({ok:!0,result:l})}if(e==="readFile"){let l=p>0?p:Math.max(0,(await B(s)).size-Math.max(0,c)),u=512<<20;if(l>u)return r({ok:!1,code:"too_large",message:`${s} is ${Math.round(l/(1<<20))} MB: read it in parts (offset, length \u2264 ${u>>20} MB)`},413);let f=await st(s);try{return a(await f.readAt(Math.max(0,c),l),"application/octet-stream")}finally{await f.close()}}return r({ok:!1,code:"bad_request",message:`no fs op ${e}`},400)}if(o==="canonicalize"&&t.method==="POST"){let e=new URL(t.url).searchParams,s=JSON.parse(e.get("sequences")||"[]"),c=JSON.parse(e.get("previous")||"[]"),p=await J("conform-te-");try{let l=S(p,U(e.get("name")||"timeline"));await F(l,new Uint8Array(await t.arrayBuffer()));let u=await O("timeline_read",{path:l}),f=u.structuredContent?.session_id??u.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(u.isError||!f)return r({ok:!1,error:u.content[0]?.text??"could not read the timeline"},422);let h=(await C(f)).session,y=h.timelines;if(s.length){let w=new Map;for(let m of c)w.set(m,(w.get(m)??0)+1);let k=new Set;for(let m of s){let R=h.timelines.filter(M=>M.kind!=="compound"&&(M.name??"")===m),x=w.get(m)??0;w.set(m,x+1);let E=R[Math.min(x,R.length-1)];E&&k.add(E)}y=h.timelines.filter(m=>m.kind==="compound"||k.has(m))}return r({ok:!0,session_id:f,session:{...h,timelines:y}})}finally{await L(p).catch(()=>{})}}if(o==="sessions"&&n&&d==="frame"){let e=new URL(t.url).searchParams,s=Math.max(0,Math.round(Number(e.get("f")??0))),c=Math.min(3840,Math.max(64,Number(e.get("w")??1280)|0));try{let f=(await C(n)).session,h=e.get("track")==="offline"?"offline":Number(e.get("track"))||void 0,y;if(e.get("grade")==="resolve"&&h!=="offline"){let k=(()=>{try{return wt(f,{record:s,timeline:e.get("timeline")??void 0,track:h})}catch{return null}})();k&&(y=await Ut(n,e.get("host_timeline")??void 0,k.video_track,k.record_start)??void 0)}let w=await _t(f,s,c,e.get("timeline")??void 0,h,y);if(w){let k=new Uint8Array(12+w.px.length),m=new DataView(k.buffer);return m.setUint32(0,w.w,!0),m.setUint32(4,w.h,!0),m.setUint32(8,w.order==="bgra"?1:0,!0),k.set(w.px,12),a(k,"application/x-conform-pixels")}}catch(f){return r({ok:!1,code:"no_frame",message:f.message},404)}let p=await O("timeline_frame",{session_id:n,record:s,width:c,...e.get("timeline")?{timeline:e.get("timeline")}:{}},{poll:!0}),l=p.structuredContent?.out_path;if(p.isError||!l)return r({ok:!1,code:String(p.structuredContent?.code??"no_frame"),message:p.content[0]?.text??"no picture here"},404);let u=await q(l);return await(U(I(l)).startsWith("conform-frame-")?L(I(l)):nt(l)).catch(()=>{}),a(u,"image/png")}if(o==="sessions"&&n&&t.method==="GET"){let e=await C(n).catch(()=>null);return e?r(e):r({ok:!1,code:"not_found"},404)}if(o==="sessions"&&!n)return r(await gt());if(o!=="projects")return r({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await _(),s=await O("project",{action:"create",name:e.name,client_name:e.client_name,handles:e.handles});return s.isError?r({...s.structuredContent,text:s.content[0]?.text},422):(await Dt(),r(s.structuredContent))}return r(await Dt())}if(!d){let[e,s,c,p,l,u]=await Promise.all([Kt(n),ut(n).catch(()=>null),ft(n),ht(n),xt(n).then(y=>y.facts).catch(()=>[]),n===V?null:St().catch(()=>null)]);await pt(n===V?null:{id:n,name:e.name??n});let{text:f="",...h}=s??{};return r({project:e,context:f,context_meta:h,sessions:c,activity:p.slice(-100).reverse(),known:Ot(l),facility:u?.text??""})}if(d==="sessions"&&t.method==="PUT")return await mt(n,String((await _()).session_id??"")),r({ok:!0});if(d==="context"&&t.method==="PUT"){let e=await _();try{let{text:s,...c}=await dt(n,String(e.text??""),e.base===void 0?void 0:e.base);return r({ok:!0,context:s,context_meta:c})}catch(s){if(s instanceof H&&s.code==="context_conflict"){let c=s.data?.current;return r({ok:!1,code:s.code,message:s.message,context:c.context,context_meta:{updated_at:c.context_updated_at,updated_by:c.context_updated_by_name??null}},409)}throw s}}return r({ok:!1,code:"not_found"},404)}catch(e){let s=e instanceof H?e:null;return r({ok:!1,code:s?.code??"internal",message:e.message},s?.code==="not_found"?404:s?.code==="invalid_args"?400:500)}}var Jt=t=>t==="1"?"app":"http",X=(t,i)=>t&&i.has(t)?t:"custom",A=new Map,Xt=500;function It(t){let i=null,r=Tt(a=>{switch(a.type){case"open":T(`app:open:${X(a.tool,t)}`);break;case"home":T("app:home");break;case"workspace":{let o=a.workspace;T("app:workspace",{counts:{open:Array.isArray(o?.open)?o.open.length:0}});break}case"settings":{let o=a.settings&&typeof a.settings=="object"?Object.keys(a.settings).filter(n=>/^[A-Za-z0-9_.]{1,64}$/.test(n)).slice(0,16):[];T("app:settings",{fields:o});break}case"run":{let o=a.run;if(!o?.id||!o.status||!/^[a-z]+$/.test(o.status)||A.get(o.id)===o.status)break;A.size>=Xt&&A.delete(A.keys().next().value),A.set(o.id,o.status),T(`app:run_${o.status}:${X(o.tool,t)}`,{fields:[o.by==="app"?"app":"assistant"],ok:o.status!=="failed"});break}}}),b=Rt(a=>{let o=/^[a-z]+$/.test(a.view)?a.view:"other",n=`${a.project}|${o}|${a.tool??""}`;n!==i&&(i=n,T(o==="tool"?`app:view:tool:${X(a.tool,t)}`:`app:view:${o}`))});return()=>{r(),b()}}bt();var Yt=Number(v("CONFORM_HTTP_PORT")??7791);v("CONFORM_EXIT_WITH_PARENT")==="1"&&(N.stdin.on("end",()=>N.exit(0)),N.stdin.on("close",()=>N.exit(0)),N.stdin.resume());yt(Jt(v("CONFORM_EXIT_WITH_PARENT")));It(new Set([...kt.map(t=>t.id),...$.map(t=>t.name),"context","source"]));var Y=v("CONFORM_HTTP_TOKEN")??"",Gt=(v("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),z=(t,i=new Headers)=>{let r=t.headers.get("origin")??"";return Gt.includes(r)&&i.set("access-control-allow-origin",r),i.set("access-control-allow-headers","authorization, content-type, x-conform-client, x-conform-poll"),i.set("access-control-allow-methods","GET, POST, PUT, DELETE, OPTIONS"),i.set("access-control-allow-private-network","true"),i.set("vary","origin"),i},Ht=new Set,g=(t,i,r=200)=>new Response(JSON.stringify(i),{status:r,headers:z(t,new Headers({"content-type":"application/json"}))});rt({hostname:"127.0.0.1",port:Yt,onListen:t=>{Ht=new Set([`127.0.0.1:${t}`,`localhost:${t}`,`[::1]:${t}`]),console.error(`conformtools HTTP API on http://127.0.0.1:${t} (${$.length} verbs)`),jt(t,Y)}},async t=>{let i=new URL(t.url),r=(t.headers.get("host")??"").toLowerCase();if(!Ht.has(r))return new Response("forbidden host",{status:403});let b=t.headers.get("origin");if(b&&!Gt.includes(b))return new Response("forbidden origin",{status:403});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:z(t)});if((t.method==="POST"||t.method==="PUT")&&t.headers.get("content-length")!=="0"&&!zt(i.pathname,t.headers.get("content-type")))return g(t,{ok:!1,code:"unsupported_media_type",message:"send the body as application/json"},415);if(Y&&t.headers.get("authorization")!==`Bearer ${Y}`&&i.pathname!=="/health")return g(t,{ok:!1,code:"unauthorized"},401);let a=i.pathname.split("/").filter(Boolean);try{if(i.pathname==="/health")return g(t,{ok:!0,verbs:$.length,version:at,engine:W()});if(a[0]==="verbs"&&a.length===1&&t.method==="GET")return g(t,$.map(n=>({name:n.name,title:n.title,description:n.description,long:!!n.long,input_schema:ct(it.object(n.inputSchema)),protected_stages:n.protectedStages??[],engine:W()})));if(a[0]==="verbs"&&a.length===2&&t.method==="POST"){let n=Mt(a[1]);if(!n)return g(t,{ok:!1,code:"not_found",message:`unknown verb ${a[1]}`},404);let d=t.headers.get("content-type")?.includes("json")?await t.json():{},_=Nt(n.name,d);if(!_.ok)return g(t,{..._.result.structuredContent,text:_.result.content[0].text},400);let e=t.headers.get("x-conform-client"),s=e?null:Pt(n.name,_.data,()=>void T("finish_missing"));s&&D(n.name,s,0,Object.keys(_.data));let c=s??await O(n.name,_.data,{client:e??"http",poll:t.headers.get("x-conform-poll")==="1"});return g(t,{...c.structuredContent??{ok:!c.isError},text:c.content.map(p=>p.text).join(`
6
+ `)},c.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&v("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-56MINHUF.js"),d=await n();return await d.waitFor(a[1],5e3)?g(t,{ok:!0,result:await d.request(a[1],a[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):g(t,{ok:!1,code:"not_connected"},409)}let o=await Ft(t,a,(n,d)=>g(t,n,d),n=>new Response(n,{headers:z(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,d)=>new Response(n,{headers:z(t,new Headers({"content-type":d,"cache-control":"no-store"}))}));if(o)return o;if(a[0]==="jobs"&&a.length===1)return g(t,await At());if(a[0]==="jobs"&&a.length===2){if(t.method==="DELETE")return g(t,{ok:$t(a[1])});let n=await Ct(a[1]);return n?g(t,n):g(t,{ok:!1,code:"not_found"},404)}return g(t,{ok:!1,code:"not_found"},404)}catch(o){return g(t,{ok:!1,code:"internal",message:o instanceof Error?o.message:String(o)},500)}});