conformtools 0.6.6 → 0.6.7

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 (72) hide show
  1. package/README.md +15 -10
  2. package/dist/{account-HDXVTS5T.js → account-DJTD3KYK.js} +1 -1
  3. package/dist/{bridge-D5KPIUSY.js → bridge-JQF4V3V2.js} +1 -1
  4. package/dist/browser/timeline_core_bg.wasm +0 -0
  5. package/dist/chunk-2BPR6LK6.js +3 -0
  6. package/dist/{chunk-VS3MKKJ5.js → chunk-3D3Z4TBR.js} +1 -1
  7. package/dist/{chunk-OJWIBQK4.js → chunk-55BKURYP.js} +167 -165
  8. package/dist/chunk-5WEZRGXG.js +39 -0
  9. package/dist/{chunk-P7OVDUA5.js → chunk-6V4OEOOX.js} +1 -1
  10. package/dist/{chunk-6ML26TIK.js → chunk-A7FNR3T5.js} +1 -1
  11. package/dist/chunk-AMRJXYL4.js +3 -0
  12. package/dist/{chunk-5SUGU2YR.js → chunk-D4WPRRBT.js} +1 -1
  13. package/dist/{chunk-UKKRZ574.js → chunk-EUBXH67N.js} +2 -2
  14. package/dist/{chunk-AS7IXHYM.js → chunk-GK4YYKJ6.js} +1 -1
  15. package/dist/{chunk-LFJLRLEP.js → chunk-GM6QKY7W.js} +1 -1
  16. package/dist/{chunk-HGDO3OED.js → chunk-J2JXLEAI.js} +1 -1
  17. package/dist/{chunk-5RSNFPED.js → chunk-NAFLOZER.js} +6 -5
  18. package/dist/{chunk-5JBUCVRI.js → chunk-P2LL3JMC.js} +1 -1
  19. package/dist/{chunk-3OCQA33E.js → chunk-PHAMF4JF.js} +2 -1
  20. package/dist/chunk-RGMTLNMF.js +3 -0
  21. package/dist/chunk-RJ6JA2LZ.js +3 -0
  22. package/dist/{chunk-RFIPLBQ4.js → chunk-S5JDS5PQ.js} +1 -1
  23. package/dist/{chunk-X53BNWNV.js → chunk-SGLQY53R.js} +1 -1
  24. package/dist/{chunk-EJGVNQ3E.js → chunk-SKFMOLUO.js} +1 -1
  25. package/dist/{chunk-SZD4C5MB.js → chunk-SNTAZJ5A.js} +1 -1
  26. package/dist/{chunk-3XD6NC4G.js → chunk-VIBEEWPC.js} +1 -1
  27. package/dist/{chunk-NQHQKEP5.js → chunk-WN53ARHJ.js} +1 -1
  28. package/dist/{chunk-OVUCL3YY.js → chunk-XLEINKFL.js} +1 -1
  29. package/dist/cli.js +3 -3
  30. package/dist/conformtools-analyze +0 -0
  31. package/dist/conformtools-decode +0 -0
  32. package/dist/{cr3-wasm-L2LFY3LM.js → cr3-wasm-HLJWEV2S.js} +1 -1
  33. package/dist/{dng-wasm-U6NC3MDK.js → dng-wasm-CQDLPM5V.js} +1 -1
  34. package/dist/{dpx-wasm-RMKEUKED.js → dpx-wasm-TLGMM7BO.js} +1 -1
  35. package/dist/{exr-wasm-LBAOMOZD.js → exr-wasm-2NPKPTVB.js} +1 -1
  36. package/dist/framing-SWOD4CWB.js +3 -0
  37. package/dist/gfx-worker.js +1 -1
  38. package/dist/{h264-3ESGVT6G.js → h264-JJMZSUWW.js} +1 -1
  39. package/dist/{h264-mxf-NPFS7NGH.js → h264-mxf-DCUOGLDU.js} +1 -1
  40. package/dist/{host-relink-D6CB2VOQ.js → host-relink-TWAF6WIG.js} +1 -1
  41. package/dist/hosts-Z666EF7V.js +3 -0
  42. package/dist/http.js +2 -2
  43. package/dist/{inspect-7ASUPU73.js → inspect-FJKYPEXL.js} +15 -15
  44. package/dist/{isobmff-SIOE67WL.js → isobmff-VJOWP4MH.js} +1 -1
  45. package/dist/mc-video-5MGGOQN4.js +3 -0
  46. package/dist/mcp.js +1 -1
  47. package/dist/{media-7AUNRKHF.js → media-NZYVREUF.js} +1 -1
  48. package/dist/media_core-YZ3PABEG.js +9 -0
  49. package/dist/{mxf-74TTDICM.js → mxf-FJSRFLJC.js} +1 -1
  50. package/dist/{ops-FSOOBXMV.js → ops-X7NAREC4.js} +1 -1
  51. package/dist/premiere-uxp/lib/probe.js +212 -1
  52. package/dist/{r3d-ZDJ3WURS.js → r3d-CXUNG6VS.js} +1 -1
  53. package/dist/{r3d-YTLOMC7C.js → r3d-T5O6IIZZ.js} +1 -1
  54. package/dist/{source-BDJAUQVR.js → source-QGWWLMME.js} +1 -1
  55. package/dist/still-P4JJNTEO.js +3 -0
  56. package/dist/still-wasm-DN5LPASS.js +3 -0
  57. package/dist/{store-ZHXLQCGN.js → store-7IOEBOZY.js} +1 -1
  58. package/dist/{tiff-wasm-D2FJ3L56.js → tiff-wasm-BPRDR6EB.js} +1 -1
  59. package/dist/{timeline-6DYFDVEH.js → timeline-DQG6TVPF.js} +1 -1
  60. package/dist/wasm/media_core_bg.wasm +0 -0
  61. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  62. package/dist/{wav-OWMUGQMM.js → wav-64SC6P7U.js} +1 -1
  63. package/package.json +1 -1
  64. package/dist/chunk-7MC7M2Y5.js +0 -3
  65. package/dist/chunk-BL6L5ZBP.js +0 -39
  66. package/dist/chunk-C5IX63YF.js +0 -3
  67. package/dist/chunk-UCMNH6Q6.js +0 -3
  68. package/dist/chunk-XNR7M4VX.js +0 -3
  69. package/dist/framing-SRCJKAYO.js +0 -3
  70. package/dist/hosts-W4AD2MYH.js +0 -3
  71. package/dist/media_core-Q2PIEV7D.js +0 -9
  72. package/dist/still-ZG2RUQAL.js +0 -3
package/dist/http.js CHANGED
@@ -1,5 +1,5 @@
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 xt}from"./chunk-NFJHWZJX.js";import{$ as yt,G as nt,H as ot,I as dt,J as pt,K as gt,R as ht,S as wt,T as _t,X as b,Y as kt,_ as U}from"./chunk-OJWIBQK4.js";import"./chunk-OVUCL3YY.js";import"./chunk-UKKRZ574.js";import"./chunk-LFJLRLEP.js";import"./chunk-RFIPLBQ4.js";import"./chunk-SZD4C5MB.js";import{J as I,t as mt,u as ft}from"./chunk-BL6L5ZBP.js";import{a as et}from"./chunk-5JBUCVRI.js";import"./chunk-PFISREY4.js";import"./chunk-TXQR2HI2.js";import"./chunk-JV7TZDKJ.js";import"./chunk-3XD6NC4G.js";import"./chunk-PFZVET7S.js";import"./chunk-P7OVDUA5.js";import"./chunk-UCMNH6Q6.js";import"./chunk-5SUGU2YR.js";import"./chunk-NQHQKEP5.js";import"./chunk-6ML26TIK.js";import"./chunk-HGDO3OED.js";import"./chunk-X53BNWNV.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-7MC7M2Y5.js";import"./chunk-VS3MKKJ5.js";import"./chunk-XNR7M4VX.js";import"./chunk-AS7IXHYM.js";import"./chunk-NU3X7P4N.js";import"./chunk-C5IX63YF.js";import{B as v,D as lt,t as rt,u as st,v as it,x as at,y as ct,z as ut}from"./chunk-EJGVNQ3E.js";import{n as H}from"./chunk-5RSNFPED.js";import{a as B}from"./chunk-3OCQA33E.js";import{D as L,H as D,I as Z,J as q,Q as tt,V as M,W as J,Y as x,b as E,k as P,q as V,r as W,u as K,v as X,w as A,x as Y,y as $,z as Q}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";import C from"node:process";var bt=new Map;function St(t,s,o,T){let i=`${t}:${o}:${T}`,a=bt.get(i);return a||(a=(async()=>{let n=x(P(),"cache","grade-luts",t);await $(n);let l=x(n,`V${o}_${T}.cube`);if(!await W(l)){let{adapter:_}=await import("./hosts-W4AD2MYH.js");if((await _("resolve").clipLut({timeline:s,track:o,start:T,out_path:l})).ok===!1)return null}return l})().catch(()=>null),bt.set(i,a)),a}var Ct=new Set(["/app/convert","/app/canonicalize"]);function Ot(t,s){let o=(s??"").split(";")[0].trim().toLowerCase();return o==="application/json"||o==="application/octet-stream"&&Ct.has(t)}function Nt(t){let s=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(s)?`_${s}`:s}var F={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Rt(){try{return JSON.parse(await X(x(P(),"projects","projects.json")))}catch{return[]}}async function Tt(){let t=await b("project",{action:"list"});if(!t.isError){let s=t.structuredContent?.projects??[];return await $(x(P(),"projects")),await Y(x(P(),"projects","projects.json"),JSON.stringify(s)),{projects:[F,...s],offline:!1}}return{projects:[F,...await Rt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function $t(t){return t==="local"?F:(await Rt()).find(s=>s.id===t)??{id:t,name:t}}async function Pt(t,s,o,T,i=(a,n)=>new Response(a,{headers:{"content-type":n}})){if(s[0]!=="app")return null;let[,a,n,l]=s,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(a==="policy"&&t.method==="GET"){let{config:e}=await import("./account-HDXVTS5T.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return o(r?.ok?await r.json():{offline:!0})}if(a==="account"&&t.method==="GET"){let e=await b("account_status",{}),r=await H().then(()=>({app:!0}),u=>({app:!1,app_reason:u.message,code:u.code}));return o({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await H().then(()=>null,r=>r);if(e)return o({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(a==="events"&&t.method==="GET")return T(gt());if(a==="front"&&t.method==="POST"){let e=await t.json();return pt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),o({ok:!0})}if(a==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=M(e.get("name")||"timeline"),u=e.get("out")||"",g=JSON.parse(e.get("targets")||"[]"),c=JSON.parse(e.get("sequences")||"[]");if(!u||!g.length)return o({ok:!1,error:"a folder and at least one format are needed"},400);let m=await D("conform-te-"),k=x(m,r);await A(k,new Uint8Array(await t.arrayBuffer()));let h=await b("timeline_read",{path:k}),S=h.structuredContent?.session_id??h.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(h.isError||!S)return o({ok:!1,error:h.content[0]?.text??"could not read the timeline"});let p=(await v(S)).session.timelines.filter(y=>y.kind!=="compound"),w=c.length?p.filter(y=>c.includes(y.name??"")):p,d=[],O=0;for(let y of w)for(let R of g){let N=x(u,`${Nt(y.name??"timeline")}.${R.ext}`),z=await b("timeline_write",{session_id:S,target:R.target,out_path:N,...w.length>1||p.length>1?{timeline_id:y.id}:{}});z.isError?d.push(`${y.name} \u2192 ${R.target}: ${z.content[0]?.text}`):O++}return await L(m).catch(()=>{}),o({ok:O>0,savedCount:O,...d.length?{error:d.join(`
3
+ import{a as xt}from"./chunk-NFJHWZJX.js";import{$ as yt,G as nt,H as ot,I as dt,J as pt,K as gt,R as ht,S as wt,T as _t,X as b,Y as kt,_ as U}from"./chunk-55BKURYP.js";import"./chunk-S5JDS5PQ.js";import"./chunk-XLEINKFL.js";import"./chunk-EUBXH67N.js";import"./chunk-SNTAZJ5A.js";import"./chunk-TXQR2HI2.js";import{J as I,t as mt,u as ft}from"./chunk-5WEZRGXG.js";import{a as et}from"./chunk-P2LL3JMC.js";import"./chunk-GM6QKY7W.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-GK4YYKJ6.js";import"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import{B as v,D as lt,t as rt,u as st,v as it,x as at,y as ct,z as ut}from"./chunk-SKFMOLUO.js";import{n as H}from"./chunk-NAFLOZER.js";import{a as B}from"./chunk-PHAMF4JF.js";import{D as L,H as D,I as Z,J as q,Q as tt,V as M,W as J,Y as x,b as E,k as P,q as V,r as W,u as K,v as X,w as A,x as Y,y as $,z as Q}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";import C from"node:process";var bt=new Map;function St(t,s,o,T){let i=`${t}:${o}:${T}`,a=bt.get(i);return a||(a=(async()=>{let n=x(P(),"cache","grade-luts",t);await $(n);let l=x(n,`V${o}_${T}.cube`);if(!await W(l)){let{adapter:_}=await import("./hosts-Z666EF7V.js");if((await _("resolve").clipLut({timeline:s,track:o,start:T,out_path:l})).ok===!1)return null}return l})().catch(()=>null),bt.set(i,a)),a}var Ct=new Set(["/app/convert","/app/canonicalize"]);function Ot(t,s){let o=(s??"").split(";")[0].trim().toLowerCase();return o==="application/json"||o==="application/octet-stream"&&Ct.has(t)}function Nt(t){let s=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(s)?`_${s}`:s}var F={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Rt(){try{return JSON.parse(await X(x(P(),"projects","projects.json")))}catch{return[]}}async function Tt(){let t=await b("project",{action:"list"});if(!t.isError){let s=t.structuredContent?.projects??[];return await $(x(P(),"projects")),await Y(x(P(),"projects","projects.json"),JSON.stringify(s)),{projects:[F,...s],offline:!1}}return{projects:[F,...await Rt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function $t(t){return t==="local"?F:(await Rt()).find(s=>s.id===t)??{id:t,name:t}}async function Pt(t,s,o,T,i=(a,n)=>new Response(a,{headers:{"content-type":n}})){if(s[0]!=="app")return null;let[,a,n,l]=s,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(a==="policy"&&t.method==="GET"){let{config:e}=await import("./account-DJTD3KYK.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return o(r?.ok?await r.json():{offline:!0})}if(a==="account"&&t.method==="GET"){let e=await b("account_status",{}),r=await H().then(()=>({app:!0}),u=>({app:!1,app_reason:u.message,code:u.code}));return o({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await H().then(()=>null,r=>r);if(e)return o({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(a==="events"&&t.method==="GET")return T(gt());if(a==="front"&&t.method==="POST"){let e=await t.json();return pt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),o({ok:!0})}if(a==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=M(e.get("name")||"timeline"),u=e.get("out")||"",g=JSON.parse(e.get("targets")||"[]"),c=JSON.parse(e.get("sequences")||"[]");if(!u||!g.length)return o({ok:!1,error:"a folder and at least one format are needed"},400);let m=await D("conform-te-"),k=x(m,r);await A(k,new Uint8Array(await t.arrayBuffer()));let h=await b("timeline_read",{path:k}),S=h.structuredContent?.session_id??h.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(h.isError||!S)return o({ok:!1,error:h.content[0]?.text??"could not read the timeline"});let p=(await v(S)).session.timelines.filter(y=>y.kind!=="compound"),w=c.length?p.filter(y=>c.includes(y.name??"")):p,d=[],O=0;for(let y of w)for(let R of g){let N=x(u,`${Nt(y.name??"timeline")}.${R.ext}`),z=await b("timeline_write",{session_id:S,target:R.target,out_path:N,...w.length>1||p.length>1?{timeline_id:y.id}:{}});z.isError?d.push(`${y.name} \u2192 ${R.target}: ${z.content[0]?.text}`):O++}return await L(m).catch(()=>{}),o({ok:O>0,savedCount:O,...d.length?{error:d.join(`
4
4
  `)}:{}})}if(a==="fs"&&t.method==="POST"){let{op:e,path:r,offset:u=0,length:g=0}=await _();if(e==="statPath"){let c=await V(r).catch(()=>null);return o({ok:!0,result:c?{kind:c.isDirectory?"directory":"file",size:c.size,lastModified:Math.round(c.mtimeMs)}:null})}if(e==="readDir"){let c=[];for await(let m of Z(r))(m.isFile||m.isDirectory)&&c.push({name:m.name,kind:m.isDirectory?"directory":"file"});return o({ok:!0,result:c})}if(e==="readFile"){let c=await q(r);try{return i(await c.readAt(Math.max(0,u),Math.min(Math.max(0,g),16<<20)),"application/octet-stream")}finally{await c.close()}}return o({ok:!1,code:"bad_request",message:`no fs op ${e}`},400)}if(a==="canonicalize"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=JSON.parse(e.get("sequences")||"[]"),u=JSON.parse(e.get("previous")||"[]"),g=await D("conform-te-");try{let c=x(g,M(e.get("name")||"timeline"));await A(c,new Uint8Array(await t.arrayBuffer()));let m=await b("timeline_read",{path:c}),k=m.structuredContent?.session_id??m.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(m.isError||!k)return o({ok:!1,error:m.content[0]?.text??"could not read the timeline"},422);let h=(await v(k)).session,S=h.timelines;if(r.length){let p=new Map;for(let d of u)p.set(d,(p.get(d)??0)+1);let w=new Set;for(let d of r){let O=h.timelines.filter(N=>N.kind!=="compound"&&(N.name??"")===d),y=p.get(d)??0;p.set(d,y+1);let R=O[Math.min(y,O.length-1)];R&&w.add(R)}S=h.timelines.filter(d=>d.kind==="compound"||w.has(d))}return o({ok:!0,session_id:k,session:{...h,timelines:S}})}finally{await L(g).catch(()=>{})}}if(a==="sessions"&&n&&l==="frame"){let e=new URL(t.url).searchParams,r=Math.max(0,Math.round(Number(e.get("f")??0))),u=Math.min(3840,Math.max(64,Number(e.get("w")??1280)|0));try{let k=(await v(n)).session,h=e.get("track")==="offline"?"offline":Number(e.get("track"))||void 0,S;if(e.get("grade")==="resolve"&&h!=="offline"){let w=(()=>{try{return mt(k,{record:r,timeline:e.get("timeline")??void 0,track:h})}catch{return null}})();w&&(S=await St(n,e.get("host_timeline")??void 0,w.video_track,w.record_start)??void 0)}let p=await ft(k,r,u,e.get("timeline")??void 0,h,S);if(p){let w=new Uint8Array(12+p.px.length),d=new DataView(w.buffer);return d.setUint32(0,p.w,!0),d.setUint32(4,p.h,!0),d.setUint32(8,p.order==="bgra"?1:0,!0),w.set(p.px,12),i(w,"application/x-conform-pixels")}}catch(k){return o({ok:!1,code:"no_frame",message:k.message},404)}let g=await b("timeline_frame",{session_id:n,record:r,width:u,...e.get("timeline")?{timeline:e.get("timeline")}:{}}),c=g.structuredContent?.out_path;if(g.isError||!c)return o({ok:!1,code:String(g.structuredContent?.code??"no_frame"),message:g.content[0]?.text??"no picture here"},404);let m=await K(c);return await(M(J(c)).startsWith("conform-frame-")?L(J(c)):Q(c)).catch(()=>{}),i(m,"image/png")}if(a==="sessions"&&n&&t.method==="GET"){let e=await v(n).catch(()=>null);return e?o(e):o({ok:!1,code:"not_found"},404)}if(a==="sessions"&&!n)return o(await lt());if(a!=="projects")return o({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await _(),r=await b("project",{action:"create",name:e.name,client_name:e.client_name,handles:e.handles});return r.isError?o({...r.structuredContent,text:r.content[0]?.text},422):(await Tt(),o(r.structuredContent))}return o(await Tt())}if(!l){let[e,r,u,g]=await Promise.all([$t(n),st(n).catch(()=>null),ut(n),dt(n)]);await at(n===rt?null:{id:n,name:e.name??n});let{text:c="",...m}=r??{};return o({project:e,context:c,context_meta:m,sessions:u,activity:g.slice(-100).reverse()})}if(l==="sessions"&&t.method==="PUT")return await ct(n,String((await _()).session_id??"")),o({ok:!0});if(l==="context"&&t.method==="PUT"){let e=await _();try{let{text:r,...u}=await it(n,String(e.text??""),e.base===void 0?void 0:e.base);return o({ok:!0,context:r,context_meta:u})}catch(r){if(r instanceof B&&r.code==="context_conflict"){let u=r.data?.current;return o({ok:!1,code:r.code,message:r.message,context:u.context,context_meta:{updated_at:u.context_updated_at,updated_by:u.context_updated_by_name??null}},409)}throw r}}return o({ok:!1,code:"not_found"},404)}catch(e){let r=e instanceof B?e:null;return o({ok:!1,code:r?.code??"internal",message:e.message},r?.code==="not_found"?404:r?.code==="invalid_args"?400:500)}}var Lt=Number(E("CONFORM_HTTP_PORT")??7791);E("CONFORM_EXIT_WITH_PARENT")==="1"&&(C.stdin.on("end",()=>C.exit(0)),C.stdin.on("close",()=>C.exit(0)),C.stdin.resume());var G=E("CONFORM_HTTP_TOKEN")??"",vt=(E("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),j=(t,s=new Headers)=>{let o=t.headers.get("origin")??"";return vt.includes(o)&&s.set("access-control-allow-origin",o),s.set("access-control-allow-headers","authorization, content-type"),s.set("access-control-allow-methods","GET, POST, PUT, DELETE, OPTIONS"),s.set("access-control-allow-private-network","true"),s.set("vary","origin"),s},Et=new Set,f=(t,s,o=200)=>new Response(JSON.stringify(s),{status:o,headers:j(t,new Headers({"content-type":"application/json"}))});tt({hostname:"127.0.0.1",port:Lt,onListen:t=>{Et=new Set([`127.0.0.1:${t}`,`localhost:${t}`,`[::1]:${t}`]),console.error(`conformtools HTTP API on http://127.0.0.1:${t} (${U.length} verbs)`),xt(t,G)}},async t=>{let s=new URL(t.url),o=(t.headers.get("host")??"").toLowerCase();if(!Et.has(o))return new Response("forbidden host",{status:403});let T=t.headers.get("origin");if(T&&!vt.includes(T))return new Response("forbidden origin",{status:403});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:j(t)});if((t.method==="POST"||t.method==="PUT")&&t.headers.get("content-length")!=="0"&&!Ot(s.pathname,t.headers.get("content-type")))return f(t,{ok:!1,code:"unsupported_media_type",message:"send the body as application/json"},415);if(G&&t.headers.get("authorization")!==`Bearer ${G}`&&s.pathname!=="/health")return f(t,{ok:!1,code:"unauthorized"},401);let i=s.pathname.split("/").filter(Boolean);try{if(s.pathname==="/health")return f(t,{ok:!0,verbs:U.length,version:et,engine:I()});if(i[0]==="verbs"&&i.length===1&&t.method==="GET")return f(t,U.map(n=>({name:n.name,title:n.title,description:n.description,long:!!n.long,input_schema:ot(nt.object(n.inputSchema)),protected_stages:n.protectedStages??[],engine:I()})));if(i[0]==="verbs"&&i.length===2&&t.method==="POST"){let n=yt(i[1]);if(!n)return f(t,{ok:!1,code:"not_found",message:`unknown verb ${i[1]}`},404);let l=t.headers.get("content-type")?.includes("json")?await t.json():{},_=kt(n.name,l);if(!_.ok)return f(t,{..._.result.structuredContent,text:_.result.content[0].text},400);let e=await b(n.name,_.data);return f(t,{...e.structuredContent??{ok:!e.isError},text:e.content.map(r=>r.text).join(`
5
- `)},e.isError?422:200)}if(i[0]==="debug"&&i.length===3&&t.method==="POST"&&Deno.env.get("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-D5KPIUSY.js"),l=await n();return await l.waitFor(i[1],5e3)?f(t,{ok:!0,result:await l.request(i[1],i[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):f(t,{ok:!1,code:"not_connected"},409)}let a=await Pt(t,i,(n,l)=>f(t,n,l),n=>new Response(n,{headers:j(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,l)=>new Response(n,{headers:j(t,new Headers({"content-type":l,"cache-control":"no-store"}))}));if(a)return a;if(i[0]==="jobs"&&i.length===1)return f(t,await _t());if(i[0]==="jobs"&&i.length===2){if(t.method==="DELETE")return f(t,{ok:wt(i[1])});let n=await ht(i[1]);return n?f(t,n):f(t,{ok:!1,code:"not_found"},404)}return f(t,{ok:!1,code:"not_found"},404)}catch(a){return f(t,{ok:!1,code:"internal",message:a instanceof Error?a.message:String(a)},500)}});
5
+ `)},e.isError?422:200)}if(i[0]==="debug"&&i.length===3&&t.method==="POST"&&Deno.env.get("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-JQF4V3V2.js"),l=await n();return await l.waitFor(i[1],5e3)?f(t,{ok:!0,result:await l.request(i[1],i[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):f(t,{ok:!1,code:"not_connected"},409)}let a=await Pt(t,i,(n,l)=>f(t,n,l),n=>new Response(n,{headers:j(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,l)=>new Response(n,{headers:j(t,new Headers({"content-type":l,"cache-control":"no-store"}))}));if(a)return a;if(i[0]==="jobs"&&i.length===1)return f(t,await _t());if(i[0]==="jobs"&&i.length===2){if(t.method==="DELETE")return f(t,{ok:wt(i[1])});let n=await ht(i[1]);return n?f(t,n):f(t,{ok:!1,code:"not_found"},404)}return f(t,{ok:!1,code:"not_found"},404)}catch(a){return f(t,{ok:!1,code:"internal",message:a instanceof Error?a.message:String(a)},500)}});