conformtools 0.6.24 → 0.6.26

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
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-NHWWMLZW.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?`
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
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
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
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 and Conform Connect 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};
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,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{Qc as d}from"./chunk-PXW7CKCO.js";import{B as l,C as p,F as m,da as f,o as c,z as u}from"./chunk-ZPIY5DOU.js";import o from"node:process";import{readFileSync as g,rmSync as h}from"node:fs";import{createConnection as w}from"node:net";var x=new Set(["tool_run","app","tool"]),s=()=>f(c(),"engine.json");async function I(e,r){await p(c()),await l(s(),JSON.stringify({port:e,token:r||void 0,pid:o.pid})),await m(s(),384);for(let t of["SIGINT","SIGTERM"])o.on(t,()=>o.exit(0));o.on("exit",()=>{try{JSON.parse(g(s(),"utf8")).pid===o.pid&&h(s())}catch{}})}function S(e,r=1500){return new Promise(t=>{let n=w({host:"127.0.0.1",port:e}),i=y=>{clearTimeout(a),n.destroy(),t(y)},a=setTimeout(()=>i(!1),r);n.once("connect",()=>i(!0)).once("error",()=>i(!1))})}async function O(e,r){if(!x.has(e))return null;let t;try{t=JSON.parse(await u(s()))}catch{return null}if(t.pid===o.pid||!await S(t.port))return null;let n;try{n=await fetch(`http://127.0.0.1:${t.port}/verbs/${e}`,{method:"POST",body:JSON.stringify(r),headers:{"content-type":"application/json","x-conform-client":d()??"mcp",...t.token?{authorization:`Bearer ${t.token}`}:{}}})}catch{return null}if(n.status===401||n.status===404)return null;let{text:i,...a}=await n.json();return{content:[{type:"text",text:i??""}],structuredContent:a,isError:!n.ok}}export{I as a,O as b};
3
+ import{Rc as d}from"./chunk-FDUFUJXI.js";import{B as l,C as p,F as m,da as f,o as c,z as u}from"./chunk-ZPIY5DOU.js";import o from"node:process";import{readFileSync as g,rmSync as h}from"node:fs";import{createConnection as w}from"node:net";var x=new Set(["tool_run","app","tool"]),s=()=>f(c(),"engine.json");async function I(e,r){await p(c()),await l(s(),JSON.stringify({port:e,token:r||void 0,pid:o.pid})),await m(s(),384);for(let t of["SIGINT","SIGTERM"])o.on(t,()=>o.exit(0));o.on("exit",()=>{try{JSON.parse(g(s(),"utf8")).pid===o.pid&&h(s())}catch{}})}function S(e,r=1500){return new Promise(t=>{let n=w({host:"127.0.0.1",port:e}),i=y=>{clearTimeout(a),n.destroy(),t(y)},a=setTimeout(()=>i(!1),r);n.once("connect",()=>i(!0)).once("error",()=>i(!1))})}async function O(e,r){if(!x.has(e))return null;let t;try{t=JSON.parse(await u(s()))}catch{return null}if(t.pid===o.pid||!await S(t.port))return null;let n;try{n=await fetch(`http://127.0.0.1:${t.port}/verbs/${e}`,{method:"POST",body:JSON.stringify(r),headers:{"content-type":"application/json","x-conform-client":d()??"mcp",...t.token?{authorization:`Bearer ${t.token}`}:{}}})}catch{return null}if(n.status===401||n.status===404)return null;let{text:i,...a}=await n.json();return{content:[{type:"text",text:i??""}],structuredContent:a,isError:!n.ok}}export{I as a,O as b};