conformtools 0.6.28 → 0.6.30

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 (59) hide show
  1. package/dist/{account-RSL4PTDB.js → account-B7ZF6OQM.js} +1 -1
  2. package/dist/{agent-hook-setup-IACTYSVL.js → agent-hook-setup-KBCGZNEE.js} +1 -1
  3. package/dist/{analysis-engine-BBOSGAB2.js → analysis-engine-LGB4OXG7.js} +1 -1
  4. package/dist/{bridge-I6VDW7YC.js → bridge-4ZKCOIOA.js} +1 -1
  5. package/dist/browser/timeline_core_bg.wasm +0 -0
  6. package/dist/{chunk-X76IIWBH.js → chunk-2XB3P2Q5.js} +1 -1
  7. package/dist/{chunk-CSH2RRI6.js → chunk-3QYAWIID.js} +1 -1
  8. package/dist/{chunk-7CASAJU4.js → chunk-463MBAHG.js} +1 -1
  9. package/dist/{chunk-QY4QDBIN.js → chunk-4QGSPWXM.js} +91 -91
  10. package/dist/{chunk-TGLH2JDW.js → chunk-FHCRWOI7.js} +1 -1
  11. package/dist/{chunk-NRURUPLU.js → chunk-GDPYFRSV.js} +1 -1
  12. package/dist/chunk-H3FD5KA2.js +7 -0
  13. package/dist/{chunk-BIX5ETBY.js → chunk-HHOFGYZ7.js} +1 -1
  14. package/dist/{chunk-CV7OBWOX.js → chunk-KMDKF7EJ.js} +1 -1
  15. package/dist/chunk-KWJVI7VL.js +545 -0
  16. package/dist/chunk-QQBDHVUU.js +3 -0
  17. package/dist/chunk-RKJML7MH.js +10 -0
  18. package/dist/{chunk-3KS3547B.js → chunk-SSFG7FNI.js} +1 -1
  19. package/dist/{chunk-WG75XXKG.js → chunk-TBODUVBP.js} +2 -2
  20. package/dist/{chunk-UXEL636C.js → chunk-UXVABU6B.js} +1 -1
  21. package/dist/{chunk-HNEKQMQG.js → chunk-YJREJ2MH.js} +1 -1
  22. package/dist/{chunk-UE76WJ3Y.js → chunk-ZL562JIE.js} +1 -1
  23. package/dist/chunk-ZNBXAGOK.js +7 -0
  24. package/dist/{chunk-RL5XRG6O.js → chunk-ZTXOFGJY.js} +1 -1
  25. package/dist/{claude-setup-6RMV3QZM.js → claude-setup-FYWGYBTH.js} +1 -1
  26. package/dist/cli.js +2 -2
  27. package/dist/demo-engine-I35YCWFG.js +3 -0
  28. package/dist/{engine-I2NXY2OK.js → engine-WJLTTZSK.js} +2 -2
  29. package/dist/framing-AYR35WRJ.js +3 -0
  30. package/dist/gfx-worker.js +1 -1
  31. package/dist/h264-QGSP23K2.js +3 -0
  32. package/dist/{h264-mxf-PKSTGNGH.js → h264-mxf-I4YANT5F.js} +1 -1
  33. package/dist/{host-relink-B3M3B3VF.js → host-relink-ACZC6TG2.js} +1 -1
  34. package/dist/{hosted-26GUD7IU.js → hosted-SPL5V4NR.js} +1 -1
  35. package/dist/hosts-RSOGNUPK.js +3 -0
  36. package/dist/http.js +2 -2
  37. package/dist/{inspect-RT36GEVU.js → inspect-B6KD6ZTA.js} +2 -2
  38. package/dist/{isobmff-65LRNCQH.js → isobmff-LAXAYC7P.js} +1 -1
  39. package/dist/{mc-video-2PCAX65A.js → mc-video-KQ7TP4DG.js} +1 -1
  40. package/dist/mcp.js +7 -7
  41. package/dist/{media-NCUTSVJ4.js → media-SUPBJX64.js} +1 -1
  42. package/dist/{mxf-WFJNAX7D.js → mxf-2TQO552L.js} +1 -1
  43. package/dist/{ops-SH3IUU2Z.js → ops-CVKPID5Z.js} +1 -1
  44. package/dist/{probe-VB6JH6ZJ.js → probe-HUPB4H4G.js} +1 -1
  45. package/dist/{r3d-X2O5LUAB.js → r3d-EPSGIBPT.js} +1 -1
  46. package/dist/resolve-bridge.py +9 -3
  47. package/dist/{sequence-patch-OHYBBKKZ.js → sequence-patch-GXM3QSJC.js} +1 -1
  48. package/dist/{store-F2CTSR6E.js → store-INNJPUPR.js} +1 -1
  49. package/dist/{timeline-33MJ3HOK.js → timeline-EXRRCS47.js} +1 -1
  50. package/package.json +5 -5
  51. package/dist/chunk-7GEOQ4N6.js +0 -537
  52. package/dist/chunk-AR5BTVBM.js +0 -7
  53. package/dist/chunk-IDADYIY6.js +0 -7
  54. package/dist/chunk-TIZC6IEH.js +0 -10
  55. package/dist/chunk-ZPIY5DOU.js +0 -3
  56. package/dist/demo-engine-ITZ7VG6Q.js +0 -3
  57. package/dist/framing-QC7Z2GRK.js +0 -3
  58. package/dist/h264-TVMYQ7EB.js +0 -3
  59. package/dist/hosts-LVKUUVG7.js +0 -3
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{c as le,d as ue,g as pe,h as fe,i as de}from"./chunk-VZ3XYHK4.js";import{a as me}from"./chunk-HNEKQMQG.js";import{a as s}from"./chunk-E75BCWXY.js";import{B as T,C as R,D as re,E as O,F as oe,O as ie,R as ae,V as se,W as ce,b as c,da as l,h as y,i as te,o as h,p as b,v as ne,z as _}from"./chunk-ZPIY5DOU.js";var Be=["pro","studio","enterprise"],gt=e=>Be.includes((e??"").toLowerCase()),ge=["align","reconform","conform-reference"],he=["autobalance"],Fe={transferGB:2e3},g={payg:{id:"payg",name:"Pay As You Go",includes:{web:!0,mcp:!1,app:!1,studio_tools:!1}},web:{id:"web",name:"Indie",unlisted:!0,includes:{web:!0,mcp:!1,app:!1,studio_tools:!1},allowance:{transferGB:50}},indie:{id:"indie",name:"Pro",popular:!0,includes:{web:!0,mcp:!0,app:!0,studio_tools:!1},allowance:{transferGB:250}},pro:{id:"pro",name:"Studio",includes:{web:!0,mcp:!0,app:!0,studio_tools:!0},allowance:{transferGB:1e3}},studio:{id:"studio",name:"Enterprise",includes:{web:!0,mcp:!0,app:!0,studio_tools:!0},allowance:Fe}},_e={web:!0,mcp:!0,app:!0,studio_tools:!0};import{AsyncLocalStorage as xe}from"node:async_hooks";var M=()=>{throw new Error("this build has no local engine \u2014 timelines are read and written on conform.tools")};function we(e,t){return M()}function ye(e,t){return M()}function be(e){return M()}var Ge=new xe;function B(e){let t=Ge.getStore();if(!t||t.declared.includes(e))return;let n=`verb '${t.verb}' reached the protected stage '${e}' without declaring it in protectedStages (core/verbs.ts)`;if(c("CONFORM_STRICT_STAGES")==="1")throw new s("internal",n);console.error(`[conform] warning: ${n}`)}var F=!1,ze=new xe;function J(){let e=ze.getStore();if(e==="hosted")return"hosted";if(e==="local"){if(!!1)throw new s("unsupported","offline conversion needs the app's own engine (this build converts on conform.tools)");return"local"}return c("CONFORM_ENGINE")==="hosted"||!!1?"hosted":"local"}async function vt(e){return B("canonicalize"),J()==="local"?await we(e.fmt,e.data):await ve(e.fmt,e.file)}async function St(e,t){return B("write"),J()==="local"?await ye(e,t):await Se(e,t)}async function xt(e){if(J()!=="local")return null;B("canonicalize");let t=JSON.parse(await be(JSON.stringify(e)));return{session:t.session,issues:t.issues??[]}}import{createPrivateKey as Et,createPublicKey as Ke,sign as At,verify as We}from"node:crypto";import{Buffer as v}from"node:buffer";var He="CONFORMTOOLS_LICENSE_V1",ke=/^[0-9A-F]{8}(-[0-9A-F]{8}){3}$/,Oe=e=>JSON.stringify({dev_mode:e.dev_mode??!1,email:e.email,expires_at:e.expires_at,features:e.features,issued_at:e.issued_at,machine_fingerprint:e.machine_fingerprint,tier:e.tier});function Ee(e){let t=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!r.startsWith("#")&&!r.startsWith("-----")).join(""),n=JSON.parse(v.from(t,"base64").toString("utf8"));if(n?.magic!==He||!n.payload?.data)throw new Error("not a conform.tools licence");return n.payload}function Ae(e,t){let n=v.from(e.signature,"base64"),r=v.from(Oe(e.data));return n.length!==64?!1:t.some(o=>We(null,r,Ke({key:v.concat([v.from("302a300506032b6570032100","hex"),v.from(o)]),format:"der",type:"spki"}),n))}var Ye=["cMwVBrEYKMzlG6pC7FF2lNKIoEqGz2xB5yph6clNnTg=","qnheqkkDU09l1oI6h2CFh4uQ97bY/hkTA5niGKH0+X8="],qe=Ye.map(e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)));function N(){let e=c("CONFORM_RECORDS_DIR");if(e)return e;let t=b(),n=y()==="darwin"?l(t,"Library/Application Support"):y()==="win32"?c("LOCALAPPDATA")??l(t,"AppData/Local"):c("XDG_DATA_HOME")??l(t,".local/share");return l(n,"conform.tools")}var Ve=()=>c("CONFORM_LICENSE_PATH")??l(N(),"license.lic"),$=()=>l(N(),"grant.lic"),Xe=null;function I(){return Xe??=(async()=>{let e=await me();if(!e)return[];let t=await ae(e,["machine"],{timeoutMs:15e3}).catch(()=>null);try{return JSON.parse(t?.stdout??"").machines.filter(n=>ke.test(n))}catch{return[]}})()}function Ze(e,t,n=Date.now()){if(!Ae(e,qe))return{ok:!1,reason:"invalid licence signature"};let r=Date.parse(e.data.expires_at);return!Number.isFinite(r)||r<n?{ok:!1,reason:`licence expired ${e.data.expires_at}`}:[t??[]].flat().includes(e.data.machine_fingerprint)?{ok:!0,data:e.data}:{ok:!1,reason:"licence is for another machine"}}async function Pe(){let e;try{e=await _(Ve())}catch{return null}try{return Ze(Ee(e),await I())}catch(t){return{ok:!1,reason:t.message}}}var Qe={production:{supabaseUrl:"https://sttpwvjbpsetzbhrkohl.supabase.co",anonKey:"sb_publishable_cyuIPsrQa5Ye7lqFxjnknQ_ozDuwwzp",appBase:"https://conform.tools"},staging:{supabaseUrl:"https://slxggvbvgzkiwojcgykx.supabase.co",anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNseGdndmJ2Z3praXdvamNneWt4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEyODUzMTksImV4cCI6MjA4Njg2MTMxOX0.b18iDsWftny0k9VmOCcbN6kLlyZsZ7GULn_jRH9CE9I",appBase:"https://beta.conform.tools"}};function a(){let e=c("CONFORM_ENV")==="staging"?"staging":"production",t=Qe[e];return{env:e,supabaseUrl:c("CONFORM_SUPABASE_URL")??t.supabaseUrl,anonKey:c("CONFORM_SUPABASE_ANON_KEY")??t.anonKey,appBase:c("CONFORM_APP_BASE")??t.appBase}}var et=600*1e3,Te=72*3600*1e3,tt=300*1e3,S=()=>l(h(),a().env==="production"?"auth.json":`auth-${a().env}.json`);async function x(){for(let e of new Set([S(),l(h(),"auth.json")]))try{let t=JSON.parse(await _(e));if(t.env===a().env&&t.access_token)return t}catch{}return await rt()}var nt=()=>{let e=y()==="win32"?c("APPDATA")??l(b(),"AppData","Roaming"):y()==="darwin"?l(b(),"Library","Application Support"):c("XDG_CONFIG_HOME")??l(b(),".config");return l(e,"conform-tools","kv-store.json")};async function rt(){let e=nt();try{let t=JSON.parse(await _(e)),n=JSON.parse(t["ct-supabase-auth"]??"null");if(!n?.access_token||!n.refresh_token)return null;let r=n.access_token.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");if(JSON.parse(atob(r+"=".repeat(-r.length&3))).iss!==`${a().supabaseUrl}/auth/v1`)return null;let i={env:a().env,access_token:n.access_token,refresh_token:n.refresh_token,expires_at:n.expires_at??0};return await L(i),delete t["ct-supabase-auth"],await T(e,JSON.stringify(t)),i}catch{return null}}async function ot(){try{for await(let e of ie(h())){if(!/^auth(?:-(\w+))?\.json$/.exec(e.name))continue;let n=JSON.parse(await _(l(h(),e.name)));if(n.access_token&&n.env&&n.env!==a().env)return{other_env:n.env}}}catch{}return{}}async function L(e){await R(h()),await T(S(),JSON.stringify(e)),await oe(S(),384)}var z=6e3,P=0,K=()=>Date.now()<P,$e=()=>{P=Date.now()+6e4};function Bt(){P=0}var Ie=e=>e.expires_at-60>Date.now()/1e3;async function G(e){let t=await x();return t&&t.refresh_token!==e.refresh_token&&Object.assign(e,t),Ie(e)}async function W(e){if(Ie(e))return e.access_token;if(K())return null;if(await G(e))return e.access_token;let t=await re(`${S()}.lock`);try{if(await G(e))return e.access_token;let n=a(),r=await fetch(`${n.supabaseUrl}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{apikey:n.anonKey,"content-type":"application/json"},body:JSON.stringify({refresh_token:e.refresh_token}),signal:AbortSignal.timeout(z)}).catch(i=>{throw $e(),i});if(!r.ok)return r.status!==400&&r.status!==401?null:await G(e)?e.access_token:"";let o=await r.json();return e.access_token=o.access_token,o.refresh_token&&(e.refresh_token=o.refresh_token),e.expires_at=o.expires_at??Math.floor(Date.now()/1e3)+(o.expires_in??3600),await L(e),e.access_token}catch{return null}finally{await t()}}async function Ft(){return(await x().catch(()=>null))?.last_entitlement?.model_key??null}async function Jt(){return(await H()).token}async function H(e="conform.tools"){let t=await x();if(!t)return m=null,{token:null,error:new s("not_signed_in",`${e}: not signed in to conform.tools \u2014 run account_login`)};let n=await W(t);return n?{token:n,error:null}:n===""?(m=null,{token:null,error:new s("not_signed_in",`${e}: the sign-in expired or was revoked \u2014 sign in again (account_login)`)}):{token:null,error:new s("offline",`${e}: couldn't reach conform.tools to renew the sign-in (no answer, or the server was busy). You are still signed in; it retries by itself \u2014 check the network if it keeps happening.`)}}var m=null;function Ne(e,t){return{signed_in:!0,entitled:e.entitled,env:a().env,email:e.email,access:e.access,tier:e.tier,trial_days_remaining:e.trial_days_remaining,source:t,...e.entitled?{}:{reason:"not_entitled"},...e.invite_only?{invite_only:!0}:{},...e.dev?{dev:!0}:{}}}async function Y(e={}){let t=await Pe();if(t?.ok)return{signed_in:!!await x().catch(()=>null),entitled:!0,env:a().env,email:t.data.email,access:"licence",tier:t.data.tier,source:"licence"};let n=await it(e);return t&&!n.entitled?{...n,licence_error:t.reason}:n}async function it(e){if(!e.force&&m&&Date.now()-m.at<et)return{...m.status,source:"cache"};let t=a(),n=await x();if(!n)return{signed_in:!1,entitled:!1,env:t.env,reason:"not_signed_in",...await ot()};let r=await W(n);if(r==="")return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(r&&!K())try{let o=(await I())[0],i=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/entitlement${o?`?machine=${o}`:""}`,{headers:{authorization:`Bearer ${r}`,apikey:t.anonKey},signal:AbortSignal.timeout(z)}).catch(u=>{throw $e(),u});if(i.status===401||i.status===403)return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(i.ok){let{grant:u,...p}=(await i.json()).data;o&&await at(u),n.last_entitlement=p,n.last_entitlement_at=Date.now(),await L(n);let f=Ne(p,"live");return m={at:Date.now(),status:f},f}}catch{}if(n.last_entitlement&&n.last_entitlement_at&&Date.now()-n.last_entitlement_at<Te){let o=Te-(Date.now()-n.last_entitlement_at);return{...Ne(n.last_entitlement,"grace"),grace_remaining_h:Math.round(o/36e4)/10}}return{signed_in:!0,entitled:!1,env:t.env,reason:"offline_grace_expired"}}async function at(e){try{if(!e)return await O($());await R(N()),await T($(),e)}catch{}}function st(e){return e.source==="licence"?`${e.email} \xB7 machine licence (${e.tier}) \u2014 runs offline, no account check`:ct(e)+(e.licence_error?`
4
- (the machine licence was not used: ${e.licence_error})`:"")}function ct(e){let t=a();if(!e.signed_in)return`not signed in (${t.env})${e.other_env?`; you are signed in to ${e.other_env} only (each server keeps its own sign-in)`:""}. Run the account_login tool, or \`npx -y conformtools@latest login\` in a terminal.`;if(e.reason==="auth_rejected")return"signed-in session was rejected (expired or revoked) \u2014 sign in again with account_login.";if(e.reason==="offline_grace_expired")return"offline for more than 72 h since the last account check \u2014 reconnect and run account_status.";let n=`${e.email??"(unknown email)"} \xB7 ${t.env}`;if(!e.entitled&&e.invite_only)return`${n}
5
- the conform.tools engine (the MCP and the app) is invite-only for now, and ${e.email??"this account"} is not on the list. If that is the wrong Google account, run account_logout, then account_login with the invited one.`;if(!e.entitled)return`${n}
6
- no active plan on ${e.email??"this account"}: the MCP is in the ${g.indie.name} plan and up. If that is the wrong Google account, run account_logout, then account_login and pick the account with the plan; otherwise choose a plan at ${t.appBase}/pricing, then run account_status.`;let r=e.access==="trial"?`trial, ${e.trial_days_remaining??"?"} day(s) left`:e.access==="allowlist"?"invited (early access)":`subscribed${e.tier?` (${q(e.tier)})`:""}`,o=D(e),i=o?` \xB7 includes ${[o.web&&"the web tools",o.mcp&&"the MCP",o.app&&"the app"].filter(Boolean).join(", ")||"the web tools"}`:"";return`${n}
7
- ${r}${i}${e.source==="grace"?` \u2014 offline, using the last check (${e.grace_remaining_h} h of grace left)`:""}`}function q(e){return g[e.toLowerCase()]?.name??e}function D(e){if(e.access==="trial")return _e;let t=(e.tier??"").toLowerCase();return(t==="enterprise"?g.studio:g[t])?.includes??null}var Le=()=>Y();function Gt(e){Le=e}async function De(){let e=await Le();if(e.entitled)return e;let t=e.signed_in&&e.reason==="not_entitled"?"not_entitled":"not_signed_in";throw new s(t,st(e),{account:e})}async function zt(){let e=await De();if(e.source==="licence"||D(e)?.mcp!==!1)return e;throw new s("not_entitled",`The conform.tools MCP is in the ${g.indie.name} plan and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${q(e.tier)})`:""}`} includes Timeline Exchange on ${a().appBase}, but not the engine on this machine. Upgrade at ${a().appBase}/pricing, then run account_status.`,{account:e,needs:"mcp"})}async function lt(){let e=await De();if(e.source==="licence")return e;if(!D(e)?.app)throw new s("not_entitled",`The conform.tools app is in the ${g.indie.name} plan and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${q(e.tier)})`:""}`} does not include the app. Upgrade at ${a().appBase}/pricing, then reopen the app.`,{account:e,needs:"app"});let t=await ft();if(t)throw new s("seat_in_use",`This seat is in use on ${t}. Each seat runs the app on one computer at a time: quit the app there (or sign out), or wait 15 minutes after it last ran, then reopen it here.`,{account:e,needs:"seat",in_use_by:t});return e}var Ce=()=>c("CONFORM_DEV")==="0",Kt=()=>!Ce()&&(F||m?.status.dev===!0);async function ut(){return!Ce()&&(F||(await Y().catch(()=>null))?.dev===!0)}async function Wt(e){if(!(!he.includes(e)||await ut()))throw new s("not_found",`no tool "${e}"`)}async function Ht(e){if(!ge.includes(e))return;let t=await lt();if(!(t.source==="licence"||D(t)?.studio_tools!==!1))throw new s("not_entitled",`This tool is in the ${g.pro.name} plan. Upgrade at ${a().appBase}/pricing.`,{account:t,needs:"studio_tools"})}var pt=240*1e3,A=null;async function ft(){if(A&&Date.now()-A.at<pt)return A.busy;let e=await Ue("POST").catch(()=>null);return A={at:Date.now(),busy:e},e}async function Ue(e){let t=a(),n=await x(),r=(await I())[0],o=n&&await W(n);if(!o||!r||K())return null;let i=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/seat`,{method:e,headers:{authorization:`Bearer ${o}`,apikey:t.anonKey,"content-type":"application/json"},body:JSON.stringify({machine:r,name:te()}),signal:AbortSignal.timeout(z)});return i.status===409?(await i.json()).in_use_by??"another computer":null}var E=null;function Yt(e={}){if(E)return E;let t=a(),n=crypto.randomUUID().replaceAll("-","");return E=new Promise((r,o)=>{let i=!1,u=d=>{i||(i=!0,clearTimeout(f),setTimeout(()=>p.close(),250),E=null,d())},p=ce({hostname:"127.0.0.1",port:0,onListen:async d=>{let k=`${t.appBase}/plugin-auth?client=engine&port=${d}&state=${n}`,w=await se(k);e.onUrl?.(k,w)}},async d=>{let k=new URL(d.url);if(k.pathname!=="/callback")return new Response("not found",{status:404});let w=k.searchParams,Z=w.get("access_token")??"",Q=w.get("refresh_token")??"",C=!!Z&&!!Q&&w.get("state")===n;if(C){let ee=Number(w.get("expires_at"));await L({env:t.env,access_token:Z,refresh_token:Q,expires_at:ee>0?ee:Math.floor(Date.now()/1e3)+3600}),m=null,P=0,Y({force:!0}).then(U=>u(()=>r(U)),U=>u(()=>o(U)))}return new Response(dt(C),{status:C?200:400,headers:{"content-type":"text/html; charset=utf-8"}})}),f=setTimeout(()=>u(()=>o(new s("not_signed_in","sign-in was not completed within 5 minutes"))),e.timeoutMs??tt)}),E}async function qt(){await Ue("DELETE").catch(()=>{}),A=null,m=null,P=0,await ne(S())&&await O(S()),await O($()).catch(()=>{});let e=l(h(),"auth.json");try{JSON.parse(await _(e)).env===a().env&&await O(e)}catch{}}function dt(e){let[t,n]=e?["Connected","You're signed in \u2014 you can close this tab."]:["Sign-in failed","Please try again."];return`<!doctype html><meta charset=utf-8><title>conform.tools</title><body style='font:16px -apple-system,Helvetica,Arial,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7;color:#1d1d1f'><div style='text-align:center'><div style='font-size:22px;font-weight:700'>conform<span style='color:#ff3c00'>.tools</span></div><div style='margin-top:14px;font-size:20px;font-weight:600'>${t}</div><div style='margin-top:6px;color:#6e6e73'>${n}</div></div></body>`}le(!0);var Re={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",capcut:"capcut",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml",blscene:"baselight-blscene"},rn=Object.keys(Re),mt=new Set([502,503,504,529,546]),V=(e,t)=>`${a().supabaseUrl}/functions/v1/${e}${t}`;async function X(){let{token:e,error:t}=await H("reading and writing timelines runs on conform.tools");if(!e&&c("CONFORM_ANONYMOUS_READ")==="1")return a().anonKey;if(!e)throw t;return e}async function Me(e,t){let n;for(let r=0;r<3;r++){try{let o=await fetch(e,t);if(!mt.has(o.status)||r===2)return o;n=new Error(`status ${o.status}`)}catch(o){if(n=o,r===2)break}await new Promise(o=>setTimeout(o,1500*(r+1)))}throw new s("offline",`conform.tools is unreachable (${n instanceof Error?n.message:String(n)}) \u2014 reading and writing timelines need the network`)}async function je(e,t){let r=(await e.json().catch(()=>({})))?.error?.message??`${t} failed (${e.status})`;throw e.status===401?new s("not_signed_in",`${r} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new s("not_entitled",r):new s(e.status>=500?"engine":"refused",r)}async function ve(e,t){let n=Re[e];if(!n)throw new s("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:r,extract:o}=await ue(t,n),i=JSON.stringify({format:r,source_filename:t.name,persist:!1}),{contentType:u,body:p}=await pe(i,typeof o=="string"?o:JSON.stringify(o)),f=await Me(V("v1-timeline-canonicalize","/v1/timeline-canonicalize"),{method:"POST",headers:{"content-type":u,authorization:`Bearer ${await X()}`,apikey:a().anonKey},body:p});f.ok||await je(f,"read");let d=await f.json();return JSON.stringify(d.session)}async function Se(e,t){let n=await Me(V("v1-write","/v1/write"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${await X()}`,apikey:a().anonKey,"x-engine-accept-delivery":"cdn"},body:JSON.stringify({target_format:e,session:t})});n.ok||await je(n,"write");let r=de(n.headers.get(fe))??[];if(n.headers.get("x-engine-delivery")==="cdn"){let i=await n.json(),u=await fetch(i.download_url);if(!u.ok)throw new s("engine",`download failed (${u.status})`);let p=new Uint8Array(await u.arrayBuffer());if(p.byteLength!==i.size)throw new s("engine",`download incomplete: ${p.byteLength} of ${i.size} bytes`);return{body:p,contentType:i.content_type,filenameSuggestion:i.filename,issues:r,serverSession:i.session_id??void 0}}let o=n.headers.get("content-disposition")?.match(/filename="([^"]+)"/)?.[1];return{body:new Uint8Array(await n.arrayBuffer()),contentType:n.headers.get("content-type")??"application/octet-stream",filenameSuggestion:o??`timeline.${e}`,issues:r,serverSession:n.headers.get("x-session-id")??void 0}}async function on(e,t,n){try{let r={"content-type":"application/json",authorization:`Bearer ${await X()}`,apikey:a().anonKey},o=d=>V("v1-sessions",`/v1/sessions/${encodeURIComponent(e)}/original${d}`),i=await fetch(o(""),{method:"POST",headers:r,body:JSON.stringify({filename:t,content_type:"application/octet-stream"})});if(!i.ok)return!1;let{key:u,upload:p}=await i.json();return(await fetch(p.url,{method:p.method??"PUT",headers:p.headers??{"content-type":"application/octet-stream"},body:n})).ok?(await fetch(o("/complete"),{method:"POST",headers:r,body:JSON.stringify({key:u})})).ok:!1}catch{return!1}}export{gt as a,he as b,g as c,rn as d,ve as e,Se as f,on as g,Ge as h,F as i,ze as j,J as k,vt as l,St as m,xt as n,I as o,a as p,nt as q,z as r,Bt as s,Ft as t,Jt as u,H as v,Y as w,st as x,D as y,Gt as z,De as A,zt as B,lt as C,Kt as D,ut as E,Wt as F,Ht as G,Yt as H,qt as I};
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{B as C,C as x,G as y,a as h,da as c,o as w,p as g,v as u,z as S}from"./chunk-ZPIY5DOU.js";var I=new Set(["ffmpeg","ffprobe","ffplay","sox","soxi","mediainfo","exiftool","mkvmerge","mkvextract","mp4box","bmxtranswrap","raw2rgb","redline","art-cmd","oiiotool","iconvert","idiff","asdcp-wrap","asdcp-unwrap","asdcp-info","opendcp","dcp_inspect","handbrakecli","gst-launch-1.0","mencoder","mplayer","sips","afconvert","avconvert","qtfaststart","mediaconch","bwfmetaedit","x264","x265","aomenc","svtav1encapp","otiotool","otioconvert","otioview","cineform","ale2csv"]),N=["mov","mp4","m4v","mxf","mkv","avi","webm","mts","m2ts","mpg","mpeg","r3d","braw","ari","arx","crm","dng","dpx","exr","wav","aif","aiff","bwf","flac","mp3","aac","m4a","caf"],J=["aaf","avb","edl","drt","otio","fcpxml","fcpxmld","prproj","ptx","ale","xml","csv"],L=new Set(["xml","csv","png","jpg","jpeg","tif","tiff"]),M=new Set([...N,...J,...L]);var m="conformtools-hook",d=o=>o&&typeof o=="object"&&!Array.isArray(o)?o:{},k=o=>!!o&&typeof o=="object"&&typeof o.command=="string"&&o.command.includes(m),A=[["PostToolUse","Bash"],["UserPromptSubmit",null],["Stop",null]];function U(o,e,t,n){let r=Array.isArray(o[e])?[...o[e]]:[],s=(i,a)=>({...i,...t?{matcher:t}:{},hooks:a});for(let i=0;i<r.length;i++){let a=d(r[i]),l=Array.isArray(a.hooks)?a.hooks:[],f=l.findIndex(k);if(f<0)continue;if(JSON.stringify(l[f])===JSON.stringify(n)&&(!t||a.matcher===t))return"kept";let H=[...l];return H[f]=n,r[i]=s(a,H),o[e]=r,"updated"}return o[e]=[...r,s({},[n])],"installed"}function $(o,e,t={}){let n={...d(o.hooks)},r=A.map(([s,i])=>U(n,s,i,{type:"command",command:e,timeout:10,...t.async&&i?{async:!0}:{}}));return r.every(s=>s==="kept")?{settings:o,result:"kept"}:{settings:{...o,hooks:n},result:r.every(s=>s==="installed")?"installed":"updated"}}function _(o){let e={...d(o.hooks)},t=!1;for(let[r]of A){if(!Array.isArray(e[r]))continue;let s=e[r].map(i=>{let a=d(i);if(!Array.isArray(a.hooks))return i;let l=a.hooks.filter(f=>!k(f));return l.length!==a.hooks.length&&(t=!0),l.length?{...a,hooks:l}:null}).filter(i=>i!==null);s.length?e[r]=s:delete e[r]}if(!t)return{settings:o,removed:!1};let n={...o};return Object.keys(e).length?n.hooks=e:delete n.hooks,{settings:n,removed:!0}}var X=30*6e4;function E(o,e,t){let n=d(o.hooks),r=Array.isArray(n.afterShellExecution)?[...n.afterShellExecution]:[],s={command:e,timeout:10,matcher:t},i=r.findIndex(k);return i>=0&&JSON.stringify(r[i])===JSON.stringify(s)?{settings:o,result:"kept"}:(i>=0?r[i]=s:r.push(s),{settings:{version:1,...o,hooks:{...n,afterShellExecution:r}},result:i>=0?"updated":"installed"})}function O(o){let e=d(o.hooks);if(!Array.isArray(e.afterShellExecution))return{settings:o,removed:!1};let t=e.afterShellExecution.filter(s=>!k(s));if(t.length===e.afterShellExecution.length)return{settings:o,removed:!1};let n={...e};t.length?n.afterShellExecution=t:delete n.afterShellExecution;let r={...o};return Object.keys(n).length?r.hooks=n:delete r.hooks,{settings:r,removed:!0}}function j(){return`\\b(${[...I].map(e=>e.replace(/[.+-]/g,"\\$&")).join("|")})\\b|\\.(${[...M].join("|")})\\b`}function q(o){let e=(o??"").toLowerCase();return e?e.includes("claude-code")||e.includes("claude code")?"claude":e.includes("codex")?"codex":e.includes("cursor")?"cursor":null:null}var D=["claude","codex","cursor"],p=()=>({claude:c(g(),".claude","settings.json"),codex:c(g(),".codex","hooks.json"),cursor:c(g(),".cursor","hooks.json")});async function F(){let o=new URL(import.meta.url),e=h(new URL("./hook.js",o));if(await u(e)){await x(w());let n=c(w(),`${m}.js`);return await y(e,n),`node "${n}"`}let t=h(new URL("../adapters/hook.ts",o));return await u(t)?`deno run --allow-read --allow-write --allow-env --no-check --unstable-sloppy-imports "${t}" ${m}`:null}async function v(o){if(!await u(o))return{};let e=await S(o);try{return e.trim()?JSON.parse(e):{}}catch{return"invalid"}}async function P(o,e){let t;return await u(o)?(t=`${o}.conformtools-backup`,await y(o,t)):await x(c(o,"..")),await C(o,JSON.stringify(e,null,2)+`
4
- `),t}async function z(o,e={}){let t=e.file??p()[o];try{let n=e.command??await F();if(!n)return{client:o,file:t,result:"skipped",detail:"no hook script beside this build"};let r=await v(t);if(r==="invalid")return{client:o,file:t,result:"failed",detail:`${t} is not valid JSON; nothing was changed`};let s=o==="cursor"?E(r,n,j()):$(r,n,{async:o==="codex"});if(s.result==="kept")return{client:o,file:t,result:"kept"};let i=await P(t,s.settings);return{client:o,file:t,result:s.result,backup:i}}catch(n){return{client:o,file:t,result:"failed",detail:n instanceof Error?n.message:String(n)}}}async function B(o,e={}){let t=e.file??p()[o],n=await v(t);if(n==="invalid")return{client:o,file:t,removed:!1};let r=o==="cursor"?O(n):_(n);if(!r.removed)return{client:o,file:t,removed:!1};let s=await P(t,r.settings);return{client:o,file:t,removed:!0,backup:s}}async function R(){let o=p(),e=[];for(let t of D)await u(c(o[t],".."))&&e.push(t);return e}var V=async()=>Promise.all((await R()).map(o=>z(o))),Q=async()=>Promise.all((await R()).map(o=>B(o)));async function K(o,e=p()[o]){let t=await v(e);return t!=="invalid"&&JSON.stringify(t).includes(m)}var b={claude:"Claude Code",codex:"Codex",cursor:"Cursor"},T="which other programs the agent ran on media or timeline files (program names and file extensions only; never a command, a path, a name, a prompt or an output), and on each message you send it reminds the agent to log your request with every name and path taken out (the hook itself sends nothing of the message)";function Y(o){return o.length?o.map(e=>{let t=b[e.client],n={installed:`${t}: agent hook installed in ${e.file}${e.backup?` (backup: ${e.backup})`:""}`,updated:`${t}: agent hook refreshed in ${e.file}`,kept:`${t}: agent hook already in ${e.file}`,skipped:`${t}: agent hook not installed (${e.detail})`,failed:`${t}: agent hook not installed: ${e.detail}`}[e.result];return e.client==="codex"&&(e.result==="installed"||e.result==="updated")?`${n}; Codex asks you to trust it once (/hooks)`:n}).concat(`It records ${T}. conformtools hooks off removes it; conformtools telemetry off removes it with the rest.`).join(`
5
- `):"Agent hook: no Claude Code, Codex or Cursor folder on this machine; nothing to install."}function oo(o){let e=o.filter(t=>t.removed);return e.length?e.map(t=>`${b[t.client]}: agent hook removed from ${t.file}`).join(`
6
- `):"Agent hook: not installed anywhere on this machine."}async function eo(){let o=await R();return o.length?[...await Promise.all(o.map(async t=>`${b[t]}: agent hook ${await K(t)?"on":"off"} (${p()[t]})`)),`It records ${T}. conformtools hooks on|off.`].join(`
7
- `):"Agent hook: no Claude Code, Codex or Cursor folder on this machine."}export{q as a,D as b,p as c,F as d,z as e,B as f,R as g,V as h,Q as i,K as j,T as k,Y as l,oo as m,eo as n};
@@ -1,10 +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 F}from"./chunk-3PVQ5QP4.js";import{b as ge,c as we,f as _e}from"./chunk-VFXMP7IF.js";import{f as X,h as he}from"./chunk-ASFUV3PB.js";import{a as be}from"./chunk-NRURUPLU.js";import{i as N}from"./chunk-TGLH2JDW.js";import{b as P,d as T,f as E}from"./chunk-NU3X7P4N.js";import{Ja as pe,ea as ce,fa as le,ka as ue,pa as me,ya as de,za as fe}from"./chunk-7Z65WW4I.js";import{a as ae}from"./chunk-E75BCWXY.js";import{A as J,C as K,H as V,O as v,P as z,Q as se,T as ie,aa as b,b as D,ba as x,ca as k,d as ee,da as y,e as re,h as te,l as ne,m as B,t as W,u as L,w as oe,x as R}from"./chunk-ZPIY5DOU.js";var G=!1,O=8,De=0,ze=3,U=2;async function ke(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),n=i=>String.fromCharCode(t[i],t[i+1],t[i+2],t[i+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(n(4)==="RED1"||n(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],s=n(4);return/^[A-Za-z0-9 ]{4}$/.test(s)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ne(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Te(e){return async(t,n)=>new Uint8Array(await e.slice(t,Math.min(t+n,e.size)).arrayBuffer())}function ye(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function ir(e){return await pe(),xe?xe.clip(e,G?"rec709":"",()=>$e(e)):$e(e)}var xe=null;async function $e(e){let t=await ke(e),n=[];if(t==="r3d"){let r=e,s=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],o=r.bases??[0],i=async(u,f,m)=>{let p=o[u]+f;return new Uint8Array(await e.slice(p,Math.min(p+m,o[u]+s[u].size)).arrayBuffer())},a=JSON.stringify(s.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await fe(i,a)),l=JSON.parse(await ue(i,a));return s.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&n.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:o[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:ye(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:De},geometrySpec:{codec:"r3d",subbands:ze},index:null,warnings:n}}if(t==="mxf"){let r=Te(e),s=JSON.parse(await de(r,e.size));if(!s)throw new Error(`${e.name}: MXF index unreadable`);let o=JSON.parse(await me(r,e.size)),i=[];for(let p=0;p<o.frame_count;p++)i.push({offset:o.frames[p*2],size:o.frames[p*2+1]});let a=i.filter(p=>p.size===0).length;a&&n.push(`${a} frame(s) had no locatable picture KLV`);let c=s.width??0,l=s.height??0,u=(s.inner_codec??"").toLowerCase(),f=null,m="MXF";return u==="arriraw"?(f={codec:"arriraw",w:c,h:l,scale:O},m="ARRIRAW"):u==="xocn"?(f={codec:"xocn",scale:O,...G?{display:"rec709"}:{}},m="X-OCN"):await le(r,e.size)?(f={codec:"vc3",scale:O},m="DNxHR"):await ce(r,e.size)?(f={codec:"prores"},m="ProRes"):n.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:f?i:[],w:c,h:l,fps:ye(s),startFrame:s.timecode?.start_frame??0,dropFrame:s.timecode?.drop_frame??!1,label:m,spec:f,geometrySpec:f&&f.codec==="arriraw"?{...f,scale:U}:f&&f.codec==="xocn"?{codec:"xocn",scale:U,...G?{display:"rec709"}:{}}:f&&f.codec==="vc3"?{codec:"vc3",scale:U}:null,index:null,warnings:n}}if(t==="isobmff"){let r=await he(e),s=Ne(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:X(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:n};if(r.kind==="h264"||r.kind==="hevc")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:X(r.kind),spec:null,geometrySpec:null,index:r,warnings:n};let o=s==="braw"?{codec:"braw",scale:O}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:O}:null;return o||n.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:o?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:o?s==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:o,geometrySpec:o?{...o,scale:U}:null,index:r,warnings:n}}throw new Error(`${e.name}: unrecognised container`)}var Y=null;var Ue=Number(D("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(re()/2),Math.floor(ee()/2**31))),Z=0,ve=[],Me=async(...e)=>{Z>=Ue?await new Promise(t=>ve.push(t)):Z++;try{return await ie(...e)}finally{let t=ve.shift();t?t():Z--}};async function Re(){let e=te()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[D("CONFORM_NATIVE_DECODE"),ne(e),W(new URL(`./${e}`,import.meta.url)),W(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await oe(n))return n;return null}var S=class extends Error{constructor(n,r){super(r);this.why=n}};function Pr(e){let t=null;try{t=JSON.parse(e.trim().split(`
4
- `).pop())}catch{}if(t?.why==="not_entitled")throw new ae("not_entitled",t.detail??"this machine is not licensed");return t?.detail??e.trim()}function Fe(e,t){try{let n=JSON.parse(e.trim().split(`
5
- `).pop()??"");return new S(n.why,n.detail)}catch{return new S("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Er(e){return Y?.owns(e)?Y.meta(`probe|${e}`,()=>Se(e)):Se(e)}async function Se(e){let t=await Re();if(!t)throw new S("missing",B("the native decoder (conformtools-decode)"));let n=[],r=await Me(t,["probe",e],s=>n.push(s));if(r.code!==0)throw Fe(r.stderr,r.code);return JSON.parse(new TextDecoder().decode(Pe(n)))}function Pe(e){let t=e.reduce((s,o)=>s+o.length,0),n=new Uint8Array(t),r=0;for(let s of e)n.set(s,r),r+=s.length;return n}async function Ie(e,t,n,r,s){let o=await Re();if(!o)throw new S("missing",B("the native decoder (conformtools-decode)"));let i=null,a=[],c=0,l=m=>{let p=new Uint8Array(m),d=0;for(;d<m;){let h=a[0],g=Math.min(h.length,m-d);p.set(h.subarray(0,g),d),d+=g,g===h.length?a.shift():a[0]=h.subarray(g)}return c-=m,p},u=[e,t,"--width",String(s.width??32768)];s.from!=null&&u.push("--from",String(s.from)),s.count!=null&&u.push("--count",String(s.count)),s.range&&u.push("--range",s.range);let f=await Me(o,u,m=>{if(a.push(m),c+=m.length,!i){let d=Pe(a.splice(0));a.push(d);let h=d.indexOf(10);if(h<0)return;i=JSON.parse(new TextDecoder().decode(d.subarray(0,h))),l(h+1),n(i)}let p=4+i.w*i.h*(i.bpp??(e==="rgb16"?6:4));for(;c>=p;){let d=l(p);r(new DataView(d.buffer).getUint32(0,!0),d.subarray(4))}},{signal:s.signal});if(f.code!==0||!i)throw Fe(f.stderr,f.code)}function Ee(e,t,n,r={}){return Ie("bgra",e,t,n,r)}var He=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],I=e=>(e>>4)*10+(e&15);function je(e){let t=I(e&63),n=I(e>>>8&127),r=I(e>>>16&127),s=I(e>>>24&63),o=i=>String(i).padStart(2,"0");return`${o(s)}:${o(r)}:${o(n)}${e&64?";":":"}${o(t)}`}function Be(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let n={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,s=()=>{let i=r;for(;r<e.length&&e[r]!==0;)r++;let a=new TextDecoder().decode(e.subarray(i,r));return r++,a},o=i=>({width:t.getInt32(i+8,!0)-t.getInt32(i,!0)+1,height:t.getInt32(i+12,!0)-t.getInt32(i+4,!0)+1});for(;r<e.length;){let i=s();if(!i)break;let a=s();if(r+4>e.length)return null;let c=t.getInt32(r,!0);if(r+=4,c<0||r+c>e.length)return null;if(n.attributes.push(`${i}:${a}`),i==="framesPerSecond"&&a==="rational"&&c>=8){let l=t.getInt32(r,!0),u=t.getUint32(r+4,!0);n.fps=u?l/u:null}else i==="timeCode"&&a==="timecode"&&c>=8?n.timecode=je(t.getUint32(r,!0)):i==="dataWindow"&&a==="box2i"&&c>=16?{width:n.width,height:n.height}=o(r):i==="displayWindow"&&a==="box2i"&&c>=16?n.display=o(r):i==="compression"&&c>=1&&(n.compression=He[e[r]]??`type ${e[r]}`);r+=c}return n}async function We(e){let t=e,n=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await R(e))n=/^(.*?)(\d+)(\.exr)$/i;else{t=x(e);let o=r?[null,r[1],r[2],r[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(b(e));if(!o)return{frames:[e],numbers:[]};let i=a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`^${i(o[1])}(\\d{${o[2].length}})${i(o[3])}$`,"i")}let s=[];for await(let o of v(t)){let i=o.isFile?n.exec(o.name):null;i&&s.push({n:Number(i[i.length===4?2:1]),f:y(t,o.name)})}return s.sort((o,i)=>o.n-i.n),{frames:s.map(o=>o.f),numbers:s.map(o=>o.n)}}async function Q(e){let t=await We(e),n=t.frames[0];if(!n)throw new Error(`no .exr frames for '${b(e)}'`);let r=await z(n),s;try{s=Be(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!s)throw new Error(`'${b(n)}' is not an OpenEXR file`);let o=Math.max(1,t.frames.length),i=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,a=s.fps??0;return{id:b(n),kind:"external",target_url:n,local_path:n,content_kind:o>1?"video":"still",source_fps:s.fps??void 0,source_timecode:s.timecode??void 0,source_resolution_w:s.width,source_resolution_h:s.height,available_range:{start:{value:0,rate:a},duration:{value:o,rate:a}},streams:[{kind:"video",codec:"exr",width:s.width,height:s.height,rate:s.fps??void 0,codec_specific:{compression:s.compression}}],vendor_metadata:{exr:{frames:o,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:i,display_window:s.display,attributes:s.attributes,fps_source:s.fps!=null?"header framesPerSecond":"not in the header",timecode_source:s.timecode?"header timeCode (first frame)":"not in the header"}}}}var C=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function Le(e){let t=await z(e);return{path:e,file:t,size:t.size}}function Je(e){return(t,n)=>e.file.readAt(t,n)}async function Ke(e){let t=F(b(e));if(!t)return[e];let n=x(e),r=[];for await(let s of v(n)){if(!s.isFile)continue;let o=F(s.name);o&&o.clipBase===t.clipBase&&r.push({n:o.partNumber,p:y(n,s.name)})}return r.sort((s,o)=>s.n-o.n).map(s=>s.p)}async function Ve(e){let t=[],n=[];for await(let r of v(e))!r.isFile||r.name.startsWith(".")||(F(r.name)?t.push(r.name):C.has(k(r.name).toLowerCase())&&n.push(r.name));if(t.length)return y(e,t.sort()[0]);if(n.length===1)return y(e,n[0]);throw n.length?(n.sort(),new Error(`'${b(e)}' is a folder of ${n.length} clips (${n.slice(0,3).join(", ")}${n.length>3?", \u2026":""}): probe one of them, or media_find to list them all`)):new Error(`'${b(e)}' is a folder with no media file in it (looked for ${[...C].join(" ")}, and RED parts)`)}async function q(e){await R(e)&&(e=await Ve(e));let t=we(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...C].join(" ")})`);let n=await Ke(e),r=await Promise.all(n.map(Le));return{source:_e(t,r.map(o=>ge(b(o.path),{fileSize:o.size,read:Je(o)}))),parts:r,format:t,anchor:n[0],close:()=>r.forEach(o=>o.file.close())}}async function jr(e,t,n,r){if(!/h264|avc|hevc|h265/.test(n)){let s=null,o=await q(e);try{return await N(o.source,{verb:"decode",index:t,intent:"park"})}catch(i){s=i}finally{o.close()}try{return await Oe(e,t,r)}catch(i){throw/no decoder/.test(String(s))?i:s instanceof Error?s:new Error(String(s))}}return Oe(e,t,r)}async function Oe(e,t,n){t=Math.round(t);let r=0,s=0,o=null;if(await Ee(e,a=>{r=a.w,s=a.h},(a,c)=>{a===t&&(o=c)},{from:t,count:1,width:n}),!o)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let i=o;for(let a=0;a<i.length;a+=4){let c=i[a];i[a]=i[a+2],i[a+2]=c}return{rgba:i,width:r,height:s}}async function A(e){if(await R(e)){let n=[];for await(let r of v(e))r.isFile&&/\.exr$/i.test(r.name)&&!r.name.startsWith(".")&&n.push(r.name);if(n.length)return Q(y(e,n.sort()[0]))}if(/\.exr$/i.test(e))return Q(e);let t=await q(e);try{let n=await N(t.source,{verb:"inspect"});if(!n)throw new Error(`could not read '${b(e)}' as ${t.format}`);return n.target_url=t.anchor,n.local_path=t.anchor,n.id=n.id||b(t.anchor),t.parts.length>1&&((n.vendor_metadata??={}).spanned_parts=t.parts.map(r=>b(r.path))),n.size_bytes=t.parts.reduce((r,s)=>r+s.size,0),n}finally{t.close()}}function Ae(e,t,n,r){let s=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,o=Math.floor(e*s/t+1e-6);return{tc:P(o,r),frames:Math.round(n*s/t)}}var Xe=e=>String(Math.round(e*1e3)/1e3);function Br(e,t){let n=e.streams?.find(d=>d.kind==="video"),r=e.streams?.filter(d=>d.kind==="audio")??[],s=e.vendor_metadata?.bext;if(!n&&e.available_range&&r[0]?.rate){let d=r[0].rate,h=e.available_range.duration.value,w=(t?[t]:[24e3/1001,24]).map(_=>{let $=Ae(s?.time_reference??0,s?.sample_rate||d,h,_);return`${s?`start TC ${$.tc}, `:""}${$.frames} frames @ ${Xe(_)} fps`});return[e.target_url??"",`audio only; ${h} samples (${(h/d).toFixed(3)} s)${s?`; BWF time_reference ${s.time_reference}`:"; no BWF timecode"}`,...w,...t?[]:["(pass fps for the project's rate)"],...r.map((_,$)=>`audio ${r.length>1?`${$+1}: `:""}${_.codec??"pcm"} ${_.channels??"?"}ch ${_.rate} Hz ${_.bit_depth??"?"}-bit`)].join(`
6
- `)}let o=e.available_range?.duration?.value??e.declared_duration?.value??null,i=e.source_fps??n?.rate??null,a=e.size_bytes,c=e.vendor_metadata?.spanned_parts,l=n?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,n?.bit_depth?`${n.bit_depth}-bit`:null,l.colr?`color ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", "),f=e.source_pixel_aspect&&Math.abs(e.source_pixel_aspect-1)>.001?e.source_pixel_aspect:null,m=f&&n?.width&&n?.height?`pixel aspect ${Math.round(f*1e3)/1e3}: stored ${n.width}x${n.height}, shown ${(n.width*f/n.height).toFixed(2)}:1 (squeezed; a trim keeps it, a square-pixel copy is a new render)`:null,p=e.raw_extraction?.mov_probe?.every_sample_is_keyframe===!1&&n?"long-GOP (not every frame is a keyframe): media_trim starts on the keyframe at or before the frame asked for":null;return[e.target_url??"",n?`${n.codec??"?"} ${n.width??"?"}x${n.height??"?"}${i?` @ ${Math.round(i*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",...[m,p].filter(d=>!!d),`start TC ${e.source_timecode??"none"}; ${o!=null?`${o} frames`:"length unknown"}${o!=null&&i?` (${(o/i).toFixed(2)} s)`:""}`,r.length?r.map((d,h)=>{let g=d.codec_specific?.channel_layout;return`audio ${r.length>1?`${h+1}: `:""}${d.codec??"pcm"} ${d.channels??"?"}ch${g?` (${g})`:""} ${d.rate??"?"} Hz ${d.bit_depth??"?"}-bit`}).join(`
7
- `):"no audio",`${e.reel_name?`reel ${e.reel_name}; `:""}${a!=null?`${(a/1e6).toFixed(1)} MB`:""}${c?`; spanned ${c.length} parts`:""}`].join(`
8
- `)}var Ge=8*1024*1024,H=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0));async function Ye(e,t,n){if(e.executable_locally===!1)throw new Error("this trim plan is server-side only");let r=new Map(t.parts.map(o=>[b(o.path),o]));await K(x(n));let s=await se(n);try{await s.truncate(e.total_size),await s.writeAt(0,H(e.dest_header_bytes_base64));for(let o of e.src_byte_ranges){let i=o.src_file_name?r.get(b(o.src_file_name)):t.parts[0];if(!i)throw new Error(`plan references unknown source part '${o.src_file_name}'`);let a=0;for(;a<o.length;){let c=Math.min(Ge,o.length-a),l=await i.file.readAt(o.offset+a,c);if(l.length<c)throw new Error(`short read in ${b(i.path)} at ${o.offset+a}`);await s.writeAt(o.write_to_dest_offset+a,l),a+=c}}e.dest_footer_bytes_base64&&e.dest_footer_offset!=null&&await s.writeAt(e.dest_footer_offset,H(e.dest_footer_bytes_base64));for(let o of e.dest_patches??[])await s.writeAt(o.offset,H(o.bytes_base64))}finally{await s.close()}for(let o of e.dest_sidecar_writes??[])await J(y(x(n),o.name),H(o.bytes_base64))}function Ze(e,t){let n=[];for(let r of e){if(r.kind!=="clip"||!r.source_range)continue;let s=r.source_range.start.value,o=r.source_range.duration.value,i=Math.max(0,Math.floor(s)-t),a=Math.floor(s+o-1)+t;a>=i&&n.push({first_frame:i,last_frame:a})}return be(n)}async function Qe(e,t,n,r,s){let o=await q(e);try{let i=Ze(t,n);if(!i.length)throw new Error("no usable frame ranges (items need kind=clip with source_range)");let a=await N(o.source,{verb:"trim",selection:{items:t,handles:n}}),c=k(o.anchor),l=o.format==="r3d",u=l?F(b(o.anchor))?.clipBase??b(o.anchor,c):b(o.anchor,c),f=[];for(let[m,p]of a.entries()){let d=p.output_clip_number??(i.length>1?m+1:void 0),h=i[(d??1)-1]??i[0],g=d&&(p.output_clip_count??i.length)>1?`_S${String(d).padStart(3,"0")}`:"",w;if(l){let _=p.output_part_number??m+1;w=y(r,`${u}${g}.RDC`,`${u}_${String(_).padStart(3,"0")}.R3D`),f.push({path:w,bytes:p.total_size,island:h,part:_,clip:d})}else{let _=s&&a.length===1?s:`${u}${g||`_trim_${h.first_frame}-${h.last_frame}`}${c}`;w=y(r,_),f.push({path:w,bytes:p.total_size,island:h,clip:d})}await Ye(p,o,w)}return l||await qe(e,f,!!s&&a.length===1),{outputs:f,islands:i,format:o.format}}finally{o.close()}}async function qe(e,t,n){let r=await A(e).catch(()=>null),s=r?.source_fps??r?.streams?.find(o=>o.kind==="video")?.rate??null;if(!(!r?.source_timecode||!s))for(let o of t){if(!o.island)continue;let i=await A(o.path).catch(()=>null),a=i?.available_range?.duration?.value??i?.declared_duration?.value;if(!i?.source_timecode||!a)continue;let c=E(i.source_timecode,s,r.source_timecode);if(c===o.island.first_frame&&c+a-1===o.island.last_frame||(o.island={first_frame:c,last_frame:c+a-1},n))continue;let l=o.path.replace(/_trim_\d+-\d+(\.[^./\\]+)$/,`_trim_${c}-${c+a-1}$1`);l!==o.path&&(await V(o.path,l),o.path=l)}}async function Wr(e){let t=await A(e.path),n=t.source_fps??t.streams?.find(w=>w.kind==="video")?.rate??null,r=t.available_range?.duration?.value??t.declared_duration?.value??null,s=t.streams?.find(w=>w.kind==="audio")?.rate;if(!n&&e.fps&&s&&r!=null){let w=t.vendor_metadata?.bext,_=Ae(w?.time_reference??0,w?.sample_rate||s,r,e.fps);n=Math.abs(e.fps*1001-Math.round(e.fps*1001/1e3)*1e3)<1?Math.round(e.fps)*1e3/1001:e.fps,r=_.frames,t.source_timecode=_.tc}if(!n)throw new Error(s?"cannot trim: audio-only file: pass fps (the project's video rate) to count in/out in frames":"cannot trim: no frame rate / timecode track on this file");let o=E(e.in,n,t.source_timecode??null),i=E(e.out,n,t.source_timecode??null);e.out_exclusive&&(i-=1);let a=t.source_timecode??"00:00:00:00",c=r!=null?P((T(a,n)??0)+r-1,n,!!t.vendor_metadata?.drop_frame):null;if(i<o)throw new Error(`out ${e.out} is before in ${e.in}`);if(o<0)throw new Error(`in ${e.in} is before the file starts (${a}, frame 0)`);if(r!=null&&i>r-1)throw new Error(`out ${e.out} is past the end of the file (last frame ${c}, frame ${r-1})`);let l={id:"trim",kind:"clip",source_range:{start:{value:o,rate:n},duration:{value:i-o+1,rate:n}}},u=x(e.path),f;if(e.out_path)try{(await L(e.out_path)).isDirectory?u=e.out_path:(u=x(e.out_path),f=b(e.out_path))}catch{u=x(e.out_path),f=b(e.out_path)}let m=await Qe(e.path,[l],Math.max(0,Math.floor(e.handles??0)),u,f),p=m.islands[0],d=m.outputs.length===1&&m.outputs[0].island?m.outputs[0].island:p,h=d.first_frame,g=d.last_frame;return{outputs:m.outputs,first_frame:h,last_frame:g,frames:g-h+1,fps:n,facts:t,...h!==p.first_frame||g!==p.last_frame?{asked:{first_frame:p.first_frame,last_frame:p.last_frame}}:{}}}function Ce(e){let t=[...C].map(n=>n.slice(1)).join("|");return e.toLowerCase().replace(new RegExp(`\\.(${t})(?=[._\\s-]|$)`,"g"),"").replace(/[^a-z0-9]/g,"")}function er(e,t){let n=Ce(e),r=Ce(t);if(r&&n.includes(r))return"name";let s=t.toLowerCase().split(/[^a-z0-9]+/).filter(o=>/\d/.test(o)&&o.length>=3);return s.length&&s.every(o=>n.includes(o))?"id":null}async function Lr(e,t,n){let r=[],s=0,o=null,i=Date.now()+n.time_limit_s*1e3,a=async(c,l)=>{try{for await(let u of v(c)){if(o&&!o.startsWith("folders"))return;if(++s>n.max_entries){o=`stopped after ${n.max_entries} entries (max_entries)`;return}if(Date.now()>i){o=`stopped after ${n.time_limit_s} s (time_limit_s)`;return}if(u.name.startsWith("."))continue;let f=y(c,u.name);if(u.isDirectory)l<n.max_depth?await a(f,l+1):o??=`folders deeper than max_depth=${n.max_depth} not searched (e.g. ${f})`;else if(u.isFile&&C.has(k(u.name).toLowerCase())){let m=er(u.name,t);m&&r.push({path:f,match:m,size:(await L(f).catch(()=>({size:0}))).size})}}}catch{}};if(await a(e,0),n.probe)for(let c=0;c<r.length;c+=8)await Promise.all(r.slice(c,c+8).map(async l=>{try{l.facts=await A(l.path)}catch(u){l.error=u.message}}));return r.sort((c,l)=>c.path.localeCompare(l.path)),{hits:r,scanned:s,truncated:o}}function rr(e){let t=e.streams?.find(a=>a.kind==="video"),n=e.source_fps??t?.rate??null,r=e.available_range?.duration?.value??e.declared_duration?.value??null,s=t?.codec_specific??{},o=e.source_timecode&&n?T(e.source_timecode,n):null,i=o!=null&&r!=null&&n?P((o+r)%(Math.round(n)*86400),n,e.source_timecode.includes(";")):null;return`${t?`${t.codec??"?"}${s.profile?` ${s.profile}`:""} ${t.width??"?"}x${t.height??"?"}`:"no video"}${n?` @ ${Math.round(n*1e3)/1e3} fps`:""}; TC ${e.source_timecode??"none"}${i?`\u2013${i}`:""}; ${r??"?"} fr${r!=null&&n?` (${(r/n).toFixed(2)} s)`:""}`}function Jr(e,t,n,r){let s=e.hits.slice(0,r),o=[];e.truncated&&o.push(`TRUNCATED: ${e.truncated} \u2014 the search did NOT cover all of ${t}; the matches below may be incomplete.`),e.hits.length>s.length&&o.push(`TRUNCATED: showing ${s.length} of ${e.hits.length} matches. Pass limit=${e.hits.length} or narrow the query.`),o.push(`${e.hits.length} file${e.hits.length===1?"":"s"} match "${n}" under ${t} (${e.scanned} entries scanned)`);let i=new Map;for(let c of e.hits)i.set(b(c.path).toLowerCase(),(i.get(b(c.path).toLowerCase())??0)+1);let a=[...i].filter(([,c])=>c>1);a.length&&o.push(`same name in several folders: ${a.map(([c,l])=>`${c} \xD7${l}`).join(", ")} \u2014 they can be DIFFERENT clips; match by TC + duration, never by name alone`);for(let c of s)o.push(`- ${c.path}${c.match==="id"?" (id match)":""}
9
- ${c.facts?rr(c.facts):c.error?`probe failed: ${c.error}`:`${(c.size/1e6).toFixed(1)} MB`}`);return o.join(`
10
- `)}async function Kr(e,t,n=0){let r=await A(e),s=r.source_fps??r.streams?.find(m=>m.kind==="video")?.rate??null,o=r.available_range?.duration?.value??r.declared_duration?.value??null;if(!s||o==null)throw new Error(`cannot check coverage: ${b(e)} has no frame rate or length`);let i=Math.round(s)*86400,a=r.source_timecode?T(r.source_timecode,s)??0:0,c=!!r.source_timecode?.includes(";"),l=m=>{let p=E(m,s,r.source_timecode??null);return typeof m=="number"||/^\d+$/.test(m.trim())?p:p<-i/2?p+i:p>i/2?p-i:p},u=m=>P(((a+m)%i+i)%i,s,c),f=t.map((m,p)=>{let d=l(m.in),h=l(m.out),g=d,w=o-h,_=g>=0&&w>=0&&h>d,$=Math.max(0,-g),j=Math.max(0,-w),M=[];return h<=d?M.push("out is not after in"):_?M.push(`covered; handles head ${g} / tail ${w} fr`):M.push(`NOT covered: short ${[$?`${$} fr at head`:"",j?`${j} fr at tail`:""].filter(Boolean).join(", ")}`),_&&n&&(g<n||w<n)&&M.push(`handles short of ${n}: ${[g<n?`head by ${n-g}`:"",w<n?`tail by ${n-w}`:""].filter(Boolean).join(", ")}`),{label:m.label??`range ${p+1}`,in_tc:u(d),out_tc:u(h),frames:h-d,covered:_,head:g,tail:w,short_head:$,short_tail:j,note:M.join("; ")}});return{facts:r,rows:f}}export{ir as a,Re as b,Pr as c,Er as d,Ee as e,We as f,C as g,Ke as h,Ve as i,q as j,jr as k,A as l,Ae as m,Br as n,Ze as o,Qe as p,Wr as q,Ce as r,er as s,Lr as t,rr as u,Jr as v,Kr as w};
@@ -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 U,writeFile as _,appendFile as V,stat as B,readdir as X,mkdir as j,open as T,copyFile as Z,mkdtemp as Q,rm as P,chmod as ee,rename as z,cp as te,statfs as re,realpath as ne}from"node:fs/promises";import{execFile as oe,spawn as L}from"node:child_process";import{createHash as se}from"node:crypto";import{createReadStream as ie,chmodSync as S,cpSync as ae,existsSync as A,mkdirSync as C,readdirSync as ce,statSync as N}from"node:fs";import{homedir as le,hostname as ue,tmpdir as de,platform as me,release as fe,arch as pe,totalmem as ge,availableParallelism as ye}from"node:os";import{fileURLToPath as D}from"node:url";import we from"node:http";import be from"node:http2";import f from"node:process";import{setTimeout as he}from"node:timers";import{Buffer as $}from"node:buffer";import{basename as xe,dirname as J,join as w,resolve as I,sep as v}from"node:path";import{createRequire as ve}from"node:module";import{basename as Mt,dirname as Ct,extname as Nt,join as It,relative as Ht,resolve as Wt}from"node:path";{let e=globalThis.fetch,t=typeof globalThis.Deno<"u";e&&!t&&(globalThis.fetch=(async(r,o)=>{let n=typeof r=="string"?r:r instanceof URL?r.href:r.url;if(n.startsWith("file:")){let s=await U(D(n)),i=n.endsWith(".wasm")?"application/wasm":"application/octet-stream";return new Response(s,{status:200,headers:{"content-type":i}})}return e(r,o)}))}var b=e=>f.env[e];function _e(e,t){he(e,t).unref()}var Be=()=>Number(b("CONFORM_MEMORY_GB")??0)*2**30||ge(),je=()=>ye(),ze=()=>f.argv.slice(2),Le=e=>f.exit(e),Pe=()=>f.platform,Je=()=>ue(),qe=()=>b("CONFORM_PYTHON")??(Pe()==="win32"?"python":"python3"),Ge=()=>f.arch,q=()=>`${f.platform}-${f.arch}`;function Ye(e){try{return w(J(ve(import.meta.url).resolve(`${$e(q())}/package.json`)),e)}catch{return null}}var $e=e=>`conformtools-${e==="win32-x64"?"windows-x64":e}`,Ke=e=>`${e} is not in this package for ${q()} (conform.tools builds it for darwin-arm64, darwin-x64, linux-x64 and win32-x64)`;function Ve(){let e=f.versions.deno,t=b("CONFORM_APP_VERSION"),r=e?`deno ${e}`:`node ${f.version}`;return{platform:`${me()} ${fe()} ${pe()}`,runtime:t&&/^[0-9A-Za-z.-]{1,32}$/.test(t)?`${r} app ${t}`:r}}var Re=()=>b("CONFORM_MCP_HOME")??w(O(),".conform-mcp"),O=()=>b("HOME")??le();function Xe(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=D(t)}catch{}return t==="~"?t=O():(t.startsWith("~/")||t.startsWith("~\\"))&&(t=w(O(),t.slice(2))),t&&I(t)+(/[\\/]$/.test(t)&&!/[\\/]$/.test(I(t))?v:"")}async function Ze(e,t){let r=await import("node:sqlite").catch(()=>null);if(r?.DatabaseSync){let n=new r.DatabaseSync(e,{readOnly:!0});try{let s=n.prepare(t);return s.setReadBigInts(!0),s.all().map(i=>Object.fromEntries(Object.entries(i).map(([c,l])=>[c,typeof l=="bigint"?Number(l):l])))}finally{n.close()}}let o=await F("sqlite3",["-readonly","-json",e,t]);if(!o.success)throw new Error(`sqlite3 ${xe(e)}: ${o.stderr.trim()||o.stdout.trim()}`);return o.stdout.trim()?JSON.parse(o.stdout):[]}var Qe=(e,t)=>e?`${e.replace(/[\\/]+$/,"")}${e.includes("\\")&&!e.includes("/")?"\\":"/"}${t}`:t;function et(e){let t=D(e),r=t.indexOf(`${v}deno-compile-`);if(r<0||!A(t))return t;let o=t.slice(r+1).split(v).slice(1).join(v),n=w(Re(),"bin",o);try{return G(t,n,!0),n}catch{return t}}function G(e,t,r=!1){let o=N(e);if(o.isDirectory()){A(t)||C(t,{recursive:!0}),S(t,493);for(let s of ce(e))G(w(e,s),w(t,s));return}let n=A(t)?N(t):null;(!n||n.size!==o.size||n.mtimeMs<o.mtimeMs)&&(n?S(t,420):C(J(t),{recursive:!0}),ae(e,t,{force:!0,preserveTimestamps:!0})),S(t,r||o.mode&73?493:420)}var H=null;var x=e=>H?.owns(e)?H:null;async function W(e){let t=await B(e);return{isFile:t.isFile(),isDirectory:t.isDirectory(),size:t.size,mtimeMs:t.mtimeMs}}function R(e){return x(e)?.stat(e,()=>W(e))??W(e)}async function tt(e){try{return await R(e),!0}catch{return!1}}async function rt(e){try{return(await R(e)).isFile}catch{return!1}}async function nt(e){try{return(await R(e)).isDirectory}catch{return!1}}async function ot(e){x(e)?.guard(e,"read whole file");let t=await U(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}var st=e=>U(e,"utf8"),it=(e,t)=>_(e,t),at=(e,t,r)=>r?.append?V(e,t):_(e,t);async function ct(e){await j(e,{recursive:!0})}async function lt(e,t={}){let r=Date.now()+(t.timeoutMs??5e3),o=t.staleMs??15e3;for(;;)try{await j(e);break}catch(n){if(n.code!=="EEXIST")throw n;try{if(Date.now()-(await R(e)).mtimeMs>o){await P(e,{recursive:!0,force:!0});continue}}catch{}if(Date.now()>r)break;await new Promise(s=>setTimeout(s,25))}return()=>P(e,{recursive:!0,force:!0}).catch(()=>{})}var ut=e=>P(e,{force:!0}),dt=(e,t)=>ee(e,t).catch(()=>{}),mt=(e,t)=>Z(e,t),ft=(e,t)=>z(e,t),pt=e=>P(e,{recursive:!0,force:!0}),gt=(e,t)=>te(e,t,{recursive:!0,verbatimSymlinks:!0});async function yt(e){try{let t=await re(e);return Number(t.bavail)*Number(t.bsize)}catch{return null}}async function wt(e){try{return await ne(e)}catch{return null}}var bt=()=>f.ppid,ht=(e="conform-")=>Q(w(de(),e));async function*xt(e){let t=async()=>(await X(e,{withFileTypes:!0})).map(r=>({name:r.name,isFile:r.isFile(),isDirectory:r.isDirectory()}));yield*await(x(e)?.readDir(e,t)??t())}async function vt(e){x(e)?.guard(e,"read bytes");let t=await T(e,"r"),r=(await t.stat()).size;return{path:e,size:r,async readAt(o,n){let s=new Uint8Array(n),i=0;for(;i<n;){let{bytesRead:c}=await t.read(s,i,n-i,o+i);if(!c)break;i+=c}return i===n?s:s.subarray(0,i)},close:()=>t.close()}}async function Pt(e){let t=await T(e,"w");return{async writeAt(r,o){let n=0;for(;n<o.length;){let{bytesWritten:s}=await t.write(o,n,o.length-n,r+n);n+=s}},truncate:r=>t.truncate(r),close:()=>t.close()}}var Y=(e,t)=>{for(let r of t)x(r)?.guard(r,`${e.split(/[\\/]/).pop()} ${t[0]}`)};function F(e,t,r={}){return Y(e,t),new Promise(o=>{oe(e,t,{maxBuffer:1<<30,env:r.env?{...f.env,...r.env}:void 0,timeout:r.timeoutMs},(n,s,i)=>{let c=n?.code??0;o({success:!n,code:c,stdout:String(s),stderr:String(i)})})})}var ke="[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 $t(){let e=await F("powershell.exe",["-NoProfile","-NonInteractive","-Command",ke],{timeoutMs:3e4});return Se(e.stdout)}function Se(e){let t;try{t=JSON.parse(e.replace(/^/,"").trim()||"[]")}catch{return[]}return(Array.isArray(t)?t:[t]).flatMap(r=>{let o=r??{},n=Number(o.pid);return!Number.isInteger(n)||n<=0?[]:[{pid:n,args:String(o.cmd||o.exe||""),title:typeof o.title=="string"?o.title:""}]})}function Rt(e,t,r,o={}){return Y(e,t),new Promise((n,s)=>{let i=L(e,t,{env:o.env?{...f.env,...o.env}:void 0,stdio:["ignore","pipe","pipe"]}),c="";i.stdout.on("data",l=>r(l)),i.stderr.on("data",l=>{c+=new TextDecoder().decode(l)}),i.on("error",s),i.on("close",l=>n({code:l,stderr:c})),o.signal?.addEventListener("abort",()=>i.kill(),{once:!0})})}function kt(e,t,r,o,n={}){let s=L(e,t,{stdio:["pipe","pipe","pipe"],env:n.env?{...f.env,...n.env}:void 0});s.stdin.on("error",()=>{}),s.stdout.on("data",a=>r(a)),s.stderr.on("data",a=>o?.(new TextDecoder().decode(a)));let i=new Promise(a=>{s.on("close",u=>a(u)),s.on("error",()=>a(null))}),c=[s,s.stdout,s.stderr,s.stdin],l=a=>{for(let u of c)(a?u.ref:u.unref)?.call(u)};return l(!1),{write:a=>new Promise((u,p)=>{s.stdin.write(a,m=>m?p(m):u())}),hold:l,close:()=>{try{s.stdin.end(),s.kill()}catch{}},exited:i}}async function St(e){if(b("CONFORM_NO_BROWSER"))return!1;let[t,r]=f.platform==="darwin"?["open",[e]]:f.platform==="win32"?["cmd",["/c","start","",e.replace(/&/g,"^&")]]:["xdg-open",[e]];return(await F(t,r)).success}function At(e,t){let r=we.createServer(async(o,n)=>{try{let s=[];if(o.method!=="GET"&&o.method!=="HEAD")for await(let p of o)s.push(p);let i=s.length>0,c=new Headers;for(let[p,m]of Object.entries(o.headers))m!=null&&c.set(p,Array.isArray(m)?m.join(", "):m);let l=`http://${o.headers.host??`${e.hostname}:${e.port}`}${o.url??"/"}`,a=new AbortController;n.on("close",()=>{n.writableEnded||a.abort()});let u=await t(new Request(l,{method:o.method,headers:c,body:i?$.concat(s):void 0,signal:a.signal}));if(n.statusCode=u.status,u.headers.forEach((p,m)=>n.setHeader(m,p)),u.body&&u.headers.get("content-type")?.startsWith("text/event-stream")){n.flushHeaders();let p=u.body.getReader();for(a.signal.addEventListener("abort",()=>void p.cancel(),{once:!0});;){let{value:m,done:g}=await p.read();if(g)break;n.write(m)}n.end();return}n.end($.from(await u.arrayBuffer()))}catch(s){n.statusCode=500,n.end(JSON.stringify({ok:!1,code:"internal",message:s instanceof Error?s.message:String(s)}))}});return r.listen(e.port,e.hostname,()=>{let o=r.address();e.onListen?.(typeof o=="object"&&o?o.port:e.port)}),{close:()=>r.close()}}var y=class extends Error{constructor(r,o,n){super(o);this.code=r;this.grpcStatus=n}};function Ot(e,t,r,o,n){return new Promise((s,i)=>{let c=be.connect(`http://${e}:${t}`),l=!1,a=(d,K)=>{l||(l=!0,clearTimeout(p),c.destroy(),d?i(d):s(K))},u=!1;c.on("connect",()=>{u=!0});let p=setTimeout(()=>a(u?new y("deadline",`no answer from ${e}:${t} in ${n} ms`):new y("unavailable",`${e}:${t}: no connection in ${n} ms`)),n);c.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`)));let m=$.alloc(5+o.length);m.writeUInt32BE(o.length,1),m.set(o,5);let g=c.request({":method":"POST",":path":r,"content-type":"application/grpc",te:"trailers"}),E=[],h,k="",M=d=>{d["grpc-status"]!=null&&(h=String(d["grpc-status"]),k=decodeURIComponent(String(d["grpc-message"]??"")))};g.on("response",M),g.on("trailers",M),g.on("data",d=>E.push(d)),g.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`))),g.on("end",()=>{if(h!=="0")return a(new y("grpc",`grpc-status ${h??"missing"}${k?`: ${k}`:""}`,h==null?void 0:Number(h)));let d=$.concat(E);if(d.length<5||d[0]!==0)return a(new y("grpc","reply is not one uncompressed gRPC message"));a(null,new Uint8Array(d.subarray(5,5+d.readUInt32BE(1))))}),g.end(m)})}async function Ut(e){let t=se("sha256");for await(let r of ie(e))t.update(r);return t.digest("hex")}async function Tt(e,t,r){let o=`${t}.part`;for(let n=0;;n++){let s=0;try{s=(await B(o)).size}catch{}try{let i=await fetch(e,{headers:s?{Range:`bytes=${s}-`}:{}});if(i.status===416)break;if(!i.ok||!i.body)throw new Error(`${e} answered ${i.status}`);s&&i.status!==206&&(s=0);let c=s+Number(i.headers.get("content-length")??0),l=await T(o,s?"a":"w");try{let a=s;for await(let u of i.body)await l.write(u),a+=u.length,r?.(a,c)}finally{await l.close()}break}catch(i){if(n>=4)throw i;await new Promise(c=>setTimeout(c,2e3*(n+1)))}}await z(o,t)}function Dt(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}export{D as a,b,_e as c,Be as d,je as e,ze as f,Le as g,Pe as h,Je as i,qe as j,Ge as k,Ye as l,Ke as m,Ve as n,Re as o,O as p,Xe as q,Ze as r,Qe as s,et as t,R as u,tt as v,rt as w,nt as x,ot as y,st as z,it as A,at as B,ct as C,lt as D,ut as E,dt as F,mt as G,ft as H,pt as I,gt as J,yt as K,wt as L,bt as M,ht as N,xt as O,vt as P,Pt as Q,F as R,$t as S,Rt as T,kt as U,St as V,At as W,y as X,Ot as Y,Ut as Z,Tt as _,Dt as $,Mt as aa,Ct as ba,Nt as ca,It as da,Ht as ea,Wt as fa};