cueframe 0.4.4 → 0.4.6

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{E as a}from"./chunk-LFRF3TXV.js";import"./chunk-MCQRX24V.js";export{a as analyzeCommand};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{b as y}from"./chunk-MCQRX24V.js";var u=class extends Error{status;code;details;requestId;constructor(t,r,s){super(r.message),this.name="ApiError",this.status=t,this.code=r.code,this.details=r.details,this.requestId=s}},v=class extends Error{url;timeoutMs;constructor(t,r){super(`Request timed out after ${r}ms: ${t}`),this.name="TimeoutError",this.url=t,this.timeoutMs=r}},k=class extends Error{url;constructor(t,r){super(`Request failed before a response: ${t}`,{cause:r}),this.name="NetworkError",this.url=t}},g={baseUrl:""};function j(e){return g={timeoutMs:3e4,...e},g}function T(){return g}function ot(e,t){return/^https?:\/\//.test(t)?t:e.replace(/\/$/,"")+(t.startsWith("/")?t:`/${t}`)}async function U(e,t={}){if(!g.baseUrl)throw new Error("@cueframe/sdk: createClient({baseUrl}) must be called before issuing requests.");let r=g.fetch??fetch,s=ot(g.baseUrl,e),o=new Headers({accept:"application/json"});for(let[c,f]of Object.entries(g.headers??{}))o.set(c,f);t.headers&&new Headers(t.headers).forEach((c,f)=>o.set(f,c)),g.apiKey&&!o.has("authorization")&&o.set("authorization",`Bearer ${g.apiKey}`);let n=g.timeoutMs??3e4,i=new AbortController,p=setTimeout(()=>i.abort(),n),m=t.signal?AbortSignal.any([t.signal,i.signal]):i.signal;try{let c=await r(s,{...t,headers:o,signal:m}),f={};c.headers.forEach((b,x)=>{f[x.toLowerCase()]=b});let l=null;if(c.status!==204)if((c.headers.get("content-type")??"").includes("application/json"))try{l=await c.json()}catch{l=null}else l=await c.text();return{status:c.status,statusText:c.statusText,headers:f,body:l,requestId:f["x-request-id"]}}catch(c){throw t.signal?.aborted?c:i.signal.aborted?new v(s,n):new k(s,c)}finally{clearTimeout(p)}}async function a(e,t={}){let r=await U(e,t);if(r.status>=400){let s;throw r.body&&typeof r.body=="object"&&"error"in r.body?s=r.body.error??{code:"unknown",message:r.statusText}:s={code:"unknown",message:r.statusText},new u(r.status,s,r.requestId)}if(r.status!==204)return r.body}var st={unauthorized:"The credential is invalid or expired for this target, or it belongs to a different environment. Re-authenticate the way you connected: reconnect the MCP server, run `cueframe login` in a terminal, or supply a current API key.",forbidden:"The credential's permissions don't cover this operation. The server message above names the exact missing ones and the `permissions` body that grants them; a key's permissions are fixed at creation, so this needs a NEW key, not a change to this one.",not_found:"No such resource in this org (cross-org access also reads as 404). Check the id, or enumerate with the matching list command/tool.",media_not_ready:"Media is still processing. Wait for the `media.transcribed` webhook or retry after ~30s.",suggestions_already_complete:"Suggestions already exist for this media item. To re-run, call DELETE /v1/media/:id/suggestions first to reset state.",precondition_required:"Fetch the resource with GET first to obtain its ETag, then resend the write with `If-Match: <etag>`. `cueframe composition get` returns one for you.",stale_etag:"Resource was modified since your last GET \u2014 `details.currentEtag` is the value to thread next. Re-GET (or run `cueframe composition get`) and rebase your edits before retrying.",conflict:"ETag mismatch \u2014 the resource was modified since your last GET. Re-fetch and merge before retrying.",media_in_use:"Media is referenced by other resources. See `details.projectIds` and `details.sessionIds` \u2014 remove those references before deleting.",session_in_use:"Session is referenced by a composition. See `details.projectIds` \u2014 remove those references before deleting.",render_not_cancellable:"Render is already in a terminal state (complete / error / cancelled) and cannot be cancelled.",rate_limited:"Rate limit exceeded. Back off using the `retry-after` response header.",invalid_composition:"Composition violates an invariant (see `details`). Common ones: clip_source_track_kind_mismatch, track_clips_overlap, transition_no_predecessor.",clip_not_found:"The clip suggestion publicId doesn't exist in this org. Run `cueframe clips <mediaItemId>` to enumerate valid sug_* ids.",service_unavailable:"The processing pipeline is temporarily unavailable. Retry shortly; if it persists, contact support@cueframe.ai with the requestId.",payment_required:"The request exceeds a billing limit. For generation, the estimated cost is over the per-call ceiling (see `details.estimateUsd` / `details.ceilingUsd`) \u2014 lower the requested duration or raise the ceiling."};function I(e){return e instanceof u?st[e.code]??null:null}async function*nt(e,t,r){let s=T();if(!s?.baseUrl)throw new Error(`@cueframe/sdk: createClient({baseUrl}) must be called before ${t}.`);let o=s.baseUrl.replace(/\/$/,"")+e,n=new Headers({accept:"text/event-stream",...s.headers??{}});s.apiKey&&!n.has("authorization")&&n.set("authorization",`Bearer ${s.apiKey}`);let p=await(s.fetch??fetch)(o,{method:"GET",headers:n,signal:r.signal});if(!p.ok){let l;try{l=(await p.json()).error??{code:"unknown",message:p.statusText}}catch{l={code:"unknown",message:p.statusText}}throw new u(p.status,l,p.headers.get("x-request-id")??void 0)}if(!p.body)throw new Error("SSE response has no body");let m=p.body.getReader(),c=new TextDecoder("utf-8"),f="";try{for(;;){let{value:l,done:b}=await m.read();if(b)break;f+=c.decode(l,{stream:!0});let x=f.indexOf(`
3
+
4
+ `);for(;x!==-1;){let rt=f.slice(0,x);f=f.slice(x+2);let K=it(rt);K&&(yield K),x=f.indexOf(`
5
+
6
+ `)}}}finally{try{m.releaseLock()}catch{}}}function it(e){if(!e.trim())return null;let t=null,r=[];for(let s of e.split(`
7
+ `)){if(!s||s.startsWith(":"))continue;let o=s.indexOf(":");if(o===-1)continue;let n=s.slice(0,o),i=s.slice(o+1).replace(/^ /,"");n==="event"?t=i:n==="data"&&r.push(i)}return!t||r.length===0?null:{event:t,data:r.join(`
8
+ `)}}async function*at(e,t,r={}){let s=`/v1/projects/${encodeURIComponent(e)}/renders/${encodeURIComponent(t)}/stream`;for await(let o of nt(s,"iterRenderEvents",r)){let n=pt(o);n&&(yield n)}}function pt(e){let{event:t,data:r}=e;if(r===null||t!=="progress"&&t!=="complete"&&t!=="error")return null;let s;try{s=JSON.parse(r)}catch{return null}return{event:t,data:s}}var _={};y(_,{createBrandKit:()=>ut,createExemplarUploads:()=>xt,extractBrandKit:()=>lt,getBrandKit:()=>gt,getBrandKitExemplars:()=>yt,getCreateBrandKitUrl:()=>L,getCreateExemplarUploadsUrl:()=>J,getExtractBrandKitUrl:()=>G,getGetBrandKitExemplarsUrl:()=>$,getGetBrandKitUrl:()=>N,getListBrandKitsUrl:()=>F,listBrandKits:()=>mt});var F=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([s,o])=>{o!==void 0&&t.append(s,o===null?"null":String(o))});let r=t.toString();return r.length>0?`/v1/brand-kits?${r}`:"/v1/brand-kits"},mt=async(e,t)=>a(F(e),{...t,method:"GET"}),L=()=>"/v1/brand-kits",ut=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(L(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},G=()=>"/v1/brand-kits/extract",lt=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(G(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},N=e=>`/v1/brand-kits/${e}`,gt=async(e,t)=>a(N(e),{...t,method:"GET"}),$=e=>`/v1/brand-kits/${e}/exemplars`,yt=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a($(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},J=()=>"/v1/brand-kits/exemplar-uploads",xt=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(J(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})};var P={};y(P,{composeFromSuggestion:()=>bt,getComposeFromSuggestionUrl:()=>H,getListMediaSuggestionsUrl:()=>D,getResetMediaSuggestionsUrl:()=>z,getSuggestBriefsUrl:()=>W,listMediaSuggestions:()=>Pt,resetMediaSuggestions:()=>St,suggestBriefs:()=>ht});var H=e=>`/v1/projects/${e}/composition/from-suggestion`,bt=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(H(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},D=(e,t)=>{let r=new URLSearchParams;Object.entries(t||{}).forEach(([o,n])=>{n!==void 0&&r.append(o,n===null?"null":String(n))});let s=r.toString();return s.length>0?`/v1/media/${e}/suggestions?${s}`:`/v1/media/${e}/suggestions`},Pt=async(e,t,r)=>a(D(e,t),{...r,method:"GET"}),W=e=>`/v1/media/${e}/suggestions`,ht=async(e,t)=>a(W(e),{...t,method:"POST"}),z=e=>`/v1/media/${e}/suggestions`,St=async(e,t)=>a(z(e),{...t,method:"DELETE"});var te={};y(te,{createComponent:()=>kt,getComponent:()=>jt,getComponentSource:()=>Tt,getCreateComponentUrl:()=>Y,getGetComponentSourceUrl:()=>ee,getGetComponentUrl:()=>Q,getListCatalogUrl:()=>V,getPatchComponentUrl:()=>X,getUpdateComponentUrl:()=>Z,listCatalog:()=>vt,patchComponent:()=>Et,updateComponent:()=>qt});var V=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([s,o])=>{o!==void 0&&t.append(s,o===null?"null":String(o))});let r=t.toString();return r.length>0?`/v1/components?${r}`:"/v1/components"},vt=async(e,t)=>a(V(e),{...t,method:"GET"}),Y=()=>"/v1/components",kt=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(Y(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},Z=e=>`/v1/components/${e}`,qt=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(Z(e),{...r,method:"PUT",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},X=e=>`/v1/components/${e}`,Et=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(X(e),{...r,method:"PATCH",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},Q=e=>`/v1/components/${e}`,jt=async(e,t)=>a(Q(e),{...t,method:"GET"}),ee=e=>`/v1/components/${e}/source`,Tt=async(e,t)=>a(ee(e),{...t,method:"GET"});var ie={};y(ie,{cancelExport:()=>Lt,createFcpxmlExport:()=>Kt,createPremiereExport:()=>Ut,getCancelExportUrl:()=>ne,getCreateFcpxmlExportUrl:()=>re,getCreatePremiereExportUrl:()=>oe,getExport:()=>Ft,getGetExportUrl:()=>se});var re=e=>`/v1/projects/${e}/exports/fcpxml`,Kt=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(re(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},oe=e=>`/v1/projects/${e}/exports/premiere`,Ut=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(oe(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},se=(e,t)=>`/v1/projects/${e}/exports/${t}`,Ft=async(e,t,r)=>a(se(e,t),{...r,method:"GET"}),ne=(e,t)=>`/v1/projects/${e}/exports/${t}/cancel`,Lt=async(e,t,r)=>a(ne(e,t),{...r,method:"POST"});var ve={};y(ve,{analyzeTimeline:()=>nr,analyzeTranscript:()=>sr,createMediaUpload:()=>Ht,createUploadToken:()=>_t,deleteMedia:()=>Yt,finalizeMedia:()=>Wt,generateMedia:()=>zt,getAnalyzeTimelineUrl:()=>Se,getAnalyzeTranscriptUrl:()=>he,getCreateMediaUploadUrl:()=>ce,getCreateUploadTokenUrl:()=>pe,getDeleteMediaUrl:()=>le,getFinalizeMediaUrl:()=>de,getGenerateMediaUrl:()=>me,getGetMediaContextUrl:()=>xe,getGetMediaTranscriptUrl:()=>ye,getGetMediaUrl:()=>ge,getImportMediaUrl:()=>ue,getListMediaFactsUrl:()=>be,getListMediaUrl:()=>fe,getMedia:()=>Zt,getMediaContext:()=>Qt,getMediaTranscript:()=>Xt,getPurchaseMediaFactUrl:()=>Pe,getSearchLibraryUrl:()=>ae,getTriggerMatteBakeUrl:()=>Ce,getTriggerSubjectDetectionUrl:()=>Re,importMedia:()=>Vt,listMedia:()=>Dt,listMediaFacts:()=>rr,purchaseMediaFact:()=>or,searchLibrary:()=>Jt,triggerMatteBake:()=>tr,triggerSubjectDetection:()=>er});var ae=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([s,o])=>{o!==void 0&&t.append(s,o===null?"null":String(o))});let r=t.toString();return r.length>0?`/v1/media/search?${r}`:"/v1/media/search"},Jt=async(e,t)=>a(ae(e),{...t,method:"GET"}),pe=()=>"/v1/uploads/token",_t=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(pe(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},ce=()=>"/v1/media",Ht=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(ce(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},fe=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([s,o])=>{o!==void 0&&t.append(s,o===null?"null":String(o))});let r=t.toString();return r.length>0?`/v1/media?${r}`:"/v1/media"},Dt=async(e,t)=>a(fe(e),{...t,method:"GET"}),de=e=>`/v1/media/${e}/finalize`,Wt=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(de(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},me=()=>"/v1/media/generate",zt=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(me(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},ue=()=>"/v1/media/import",Vt=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(ue(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},le=e=>`/v1/media/${e}`,Yt=async(e,t)=>a(le(e),{...t,method:"DELETE"}),ge=e=>`/v1/media/${e}`,Zt=async(e,t)=>a(ge(e),{...t,method:"GET"}),ye=(e,t)=>{let r=new URLSearchParams;Object.entries(t||{}).forEach(([o,n])=>{n!==void 0&&r.append(o,n===null?"null":String(n))});let s=r.toString();return s.length>0?`/v1/media/${e}/transcript?${s}`:`/v1/media/${e}/transcript`},Xt=async(e,t,r)=>a(ye(e,t),{...r,method:"GET"}),xe=e=>`/v1/media/${e}/context`,Qt=async(e,t)=>a(xe(e),{...t,method:"GET"}),Re=(e,t)=>{let r=new URLSearchParams;Object.entries(t||{}).forEach(([o,n])=>{n!==void 0&&r.append(o,n===null?"null":String(n))});let s=r.toString();return s.length>0?`/v1/media/${e}/detect-subjects?${s}`:`/v1/media/${e}/detect-subjects`},er=async(e,t,r)=>a(Re(e,t),{...r,method:"POST"}),Ce=e=>`/v1/media/${e}/matte`,tr=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(Ce(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},be=(e,t)=>{let r=new URLSearchParams;Object.entries(t||{}).forEach(([o,n])=>{n!==void 0&&r.append(o,n===null?"null":String(n))});let s=r.toString();return s.length>0?`/v1/media/${e}/facts?${s}`:`/v1/media/${e}/facts`},rr=async(e,t,r)=>a(be(e,t),{...r,method:"GET"}),Pe=e=>`/v1/media/${e}/facts`,or=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(Pe(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},he=e=>`/v1/media/${e}/transcript/analyze`,sr=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(he(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},Se=()=>"/v1/timeline-analysis",nr=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(Se(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})};var Oe={};y(Oe,{createProject:()=>ar,deleteProject:()=>fr,getCreateProjectUrl:()=>qe,getDeleteProjectUrl:()=>Te,getGetProjectContextUrl:()=>Ie,getGetProjectUrl:()=>Ee,getListProjectsUrl:()=>ke,getPatchProjectUrl:()=>je,getProject:()=>pr,getProjectContext:()=>dr,listProjects:()=>ir,patchProject:()=>cr});var ke=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([s,o])=>{o!==void 0&&t.append(s,o===null?"null":String(o))});let r=t.toString();return r.length>0?`/v1/projects?${r}`:"/v1/projects"},ir=async(e,t)=>a(ke(e),{...t,method:"GET"}),qe=()=>"/v1/projects",ar=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a(qe(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},Ee=e=>`/v1/projects/${e}`,pr=async(e,t)=>a(Ee(e),{...t,method:"GET"}),je=e=>`/v1/projects/${e}`,cr=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(je(e),{...r,method:"PATCH",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},Te=e=>`/v1/projects/${e}`,fr=async(e,t)=>a(Te(e),{...t,method:"DELETE"}),Ie=e=>`/v1/projects/${e}/context`,dr=async(e,t)=>a(Ie(e),{...t,method:"GET"});var Ge={};y(Ge,{cancelRender:()=>yr,createRender:()=>mr,getCancelRenderUrl:()=>Ke,getCreateRenderUrl:()=>Ae,getGetRenderUrl:()=>Be,getListProjectRendersUrl:()=>we,getPreviewClipUrl:()=>Me,getRefreshRenderUrlUrl:()=>Fe,getRender:()=>gr,getRetryRenderUrl:()=>Ue,getStreamRenderUrl:()=>Le,listProjectRenders:()=>ur,previewClip:()=>lr,refreshRenderUrl:()=>Rr,retryRender:()=>xr,streamRender:()=>Cr});var Ae=e=>`/v1/projects/${e}/renders`,mr=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(Ae(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},we=(e,t)=>{let r=new URLSearchParams;Object.entries(t||{}).forEach(([o,n])=>{n!==void 0&&r.append(o,n===null?"null":String(n))});let s=r.toString();return s.length>0?`/v1/projects/${e}/renders?${s}`:`/v1/projects/${e}/renders`},ur=async(e,t,r)=>a(we(e,t),{...r,method:"GET"}),Me=e=>`/v1/projects/${e}/preview-clip`,lr=async(e,t,r)=>{let s=o=>{if(!o)return{};if(o instanceof Headers)return Object.fromEntries(o.entries());if(Symbol.iterator in o)return Object.fromEntries(Array.from(o,i=>Array.from(i)));let n={};for(let[i,p]of Object.entries(o))p!==void 0&&(n[i]=p);return n};return a(Me(e),{...r,method:"POST",headers:{"Content-Type":"application/json",...s(r?.headers)},body:JSON.stringify(t)})},Be=(e,t)=>`/v1/projects/${e}/renders/${t}`,gr=async(e,t,r)=>a(Be(e,t),{...r,method:"GET"}),Ke=(e,t)=>`/v1/projects/${e}/renders/${t}/cancel`,yr=async(e,t,r)=>a(Ke(e,t),{...r,method:"POST"}),Ue=(e,t)=>`/v1/projects/${e}/renders/${t}/retry`,xr=async(e,t,r)=>a(Ue(e,t),{...r,method:"POST"}),Fe=(e,t)=>`/v1/projects/${e}/renders/${t}/refresh-url`,Rr=async(e,t,r)=>a(Fe(e,t),{...r,method:"POST"}),Le=(e,t)=>`/v1/projects/${e}/renders/${t}/stream`,Cr=async(e,t,r)=>a(Le(e,t),{...r,method:"GET"});var We={};y(We,{createSession:()=>Sr,deleteSession:()=>kr,getCreateSessionUrl:()=>$e,getDeleteSessionUrl:()=>_e,getGetMuxJobUrl:()=>De,getGetSessionUrl:()=>Je,getListSessionsUrl:()=>Ne,getMuxJob:()=>Er,getSession:()=>vr,getTriggerMuxJobUrl:()=>He,listSessions:()=>hr,triggerMuxJob:()=>qr});var Ne=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([s,o])=>{o!==void 0&&t.append(s,o===null?"null":String(o))});let r=t.toString();return r.length>0?`/v1/sessions?${r}`:"/v1/sessions"},hr=async(e,t)=>a(Ne(e),{...t,method:"GET"}),$e=()=>"/v1/sessions",Sr=async(e,t)=>{let r=s=>{if(!s)return{};if(s instanceof Headers)return Object.fromEntries(s.entries());if(Symbol.iterator in s)return Object.fromEntries(Array.from(s,n=>Array.from(n)));let o={};for(let[n,i]of Object.entries(s))i!==void 0&&(o[n]=i);return o};return a($e(),{...t,method:"POST",headers:{"Content-Type":"application/json",...r(t?.headers)},body:JSON.stringify(e)})},Je=e=>`/v1/sessions/${e}`,vr=async(e,t)=>a(Je(e),{...t,method:"GET"}),_e=e=>`/v1/sessions/${e}`,kr=async(e,t)=>a(_e(e),{...t,method:"DELETE"}),He=e=>`/v1/sessions/${e}/mux-job`,qr=async(e,t)=>a(He(e),{...t,method:"POST"}),De=e=>`/v1/sessions/${e}/mux-job`,Er=async(e,t)=>a(De(e),{...t,method:"GET"});import{readFileSync as Ar,writeFileSync as wr,mkdirSync as Mr,existsSync as Br}from"fs";import{join as ze}from"path";import{homedir as Kr}from"os";var d={Success:0,UserError:2,ApiClientError:3,ApiServerError:4,NetworkError:5,PaymentRequired:6};function O(e){if(e instanceof u){if(e.status===402)return d.PaymentRequired;if(e.status>=500)return d.ApiServerError;if(e.status>=400)return d.ApiClientError}let t=e?.exitCode;return typeof t=="number"?t:d.NetworkError}function JR(e){return e===402?d.PaymentRequired:e>=500?d.ApiServerError:e>=400?d.ApiClientError:d.Success}function h(e){process.exit(e)}var Ve=ze(Kr(),".cueframe"),q=ze(Ve,"auth.json"),R={local:"http://127.0.0.1:3211",dev:"https://api-dev.cueframe.ai",prod:"https://api.cueframe.ai"},Ur="prod";function VR(e=Ur){return process.env.CUEFRAME_API_URL??R[e]??R.prod}var S=class extends Error{constructor(r,s){super(s);this.code=r;this.name="AuthStoreError"}code;exitCode=d.UserError};function YR(e){if(!/^cf_(?:live|test)_[A-Za-z0-9_-]{8,}$/.test(e))throw new S("auth_invalid","Invalid API key. Expected a key beginning with cf_live_ or cf_test_.")}function Ye(){if(!Br(q))return{targets:{}};let e=Ar(q,"utf-8");try{return JSON.parse(e)}catch{throw new S("auth_config_corrupt",`${q} is corrupt and cannot be parsed. Delete it and re-run \`cueframe login\`.`)}}function Fr(e){Mr(Ve,{recursive:!0,mode:448}),wr(q,JSON.stringify(e,null,2),{mode:384})}function ZR(e,t="prod",r){let s=Ye(),o=R[t]??R.prod;s.targets[t]={apiKey:e,apiUrl:r??o},Fr(s)}function Ze(e="prod"){let t=process.env.CUEFRAME_API_KEY,r=process.env.CUEFRAME_API_URL;if(t)return{apiKey:t,apiUrl:r??R[e]??R.prod};let o=Ye().targets[e];if(!o)throw new S("auth_missing",`No auth configured for target "${e}". Run \`cueframe login --target ${e}\` (browser sign-in) or \`cueframe auth <api-key> --target ${e}\` (CI / headless).`);return o}function Xe(e){let{apiKey:t,apiUrl:r}=Ze(e);j({baseUrl:r,apiKey:t})}function E(e){let t=e instanceof u?`${e.message} (${e.code}${e.status?`, ${e.status}`:""})`:e instanceof Error?e.message:String(e),r=I(e);return r?`${t}
9
+ \u2192 ${r}`:t}import Lr from"ora";import Gr from"pino";var Nr="v1",Qe=Gr({level:"trace",base:{schemaVersion:Nr},messageKey:"event",timestamp:()=>`,"ts":${Date.now()}`,formatters:{level:()=>({_:0})}});function A(e,t){return Lr({text:e,isSilent:!!t}).start()}function C(e,t,r={}){e.json&&Qe.info(r,t)}function nC(e,t,r){if(e.json){console.log(JSON.stringify(t,null,2));return}r()}function w(e,t,r,s){let o=r instanceof Error?r.message:String(r),n=typeof r?.code=="string"?r.code:void 0,i=r?.status;e.json?Qe.info({phase:t,message:o,...n?{code:n}:{},...typeof i=="number"?{status:i}:{},exitCode:s},"error"):process.stderr.write(`\u2716 ${t}: ${E(r)}
10
+ `)}function M(e,t,r,s){e.json&&w(e,t,r,s)}function iC(e,t){t.json||console.log(e)}function $r(e){for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<=31||r===127)return!0}return!1}function tt(e,t,r){e.length===0&&et(`${t} is empty.`,r),$r(e)&&et(`${t} contains a control character (newline, tab, or null byte). Identifiers must be plain text \u2014 check for a stray copy-paste artifact.`,r)}function et(e,t){w(t,"preflight",new Error(e),d.UserError),h(d.UserError)}var Jr=5e3,B=300*1e3;async function yC(e,t){if(tt(e,"mediaItemId",t),t.dryRun){C(t,"analyze_dry_run",{mediaItemId:e,target:t.target,wait:!!t.wait,wouldCall:"POST /v1/media/:id/suggestions"}),t.json||console.log(`[dry-run] Would trigger clip analysis for ${e} on ${t.target}.`);return}Xe(t.target),C(t,"analyze_prepare",{mediaItemId:e,target:t.target,wait:!!t.wait});let r=A("Triggering clip analysis\u2026",t.json),s;try{s=await P.suggestBriefs(e),r.succeed(`Analysis ${s.alreadyRunning?"already running":"started"}`)}catch(i){r.fail(`Failed to start analysis: ${E(i)}`),M(t,"analyze_prepare",i,O(i)),h(O(i))}if(C(t,"analyze_ready",{mediaItemId:e,status:s.status,alreadyRunning:!!s.alreadyRunning}),!t.wait){t.json||console.log(`
11
+ Run \`cueframe clips ${e}\` to check results.`);return}let o=A("Waiting for analysis to complete\u2026",t.json),n=Date.now();for(;;){await new Promise(i=>setTimeout(i,Jr)),Date.now()-n>B&&(o.fail(`Timed out after ${Math.round(B/1e3)}s. Run \`cueframe clips ${e}\` to check later.`),M(t,"analyze_progress",new Error(`Analysis did not complete within ${Math.round(B/1e3)}s`),d.UserError),h(d.UserError));try{let i=await P.listMediaSuggestions(e);if(i.suggestions.length>0){o.succeed(`Analysis complete \u2014 ${i.suggestions.length} clips found`),C(t,"analyze_complete",{mediaItemId:e,durationMs:Date.now()-n,suggestionCount:i.suggestions.length,suggestions:i.suggestions}),t.json||i.suggestions.forEach((m,c)=>{let f=(m.trim.end-m.trim.start).toFixed(1);console.log(`
12
+ ${c+1}. ${m.title} (${m.id})`),console.log(` ${m.trim.start.toFixed(1)}s \u2013 ${m.trim.end.toFixed(1)}s (${f}s) score: ${m.score}`),console.log(` ${m.reason}`)});return}let p=Math.round((Date.now()-n)/1e3);o.text=`Waiting for analysis\u2026 (${p}s)`,C(t,"analyze_progress",{mediaItemId:e,elapsedSec:p})}catch{}}}export{u as a,j as b,U as c,a as d,I as e,at as f,_ as g,P as h,te as i,ie as j,ve as k,Oe as l,Ge as m,We as n,d as o,O as p,JR as q,h as r,VR as s,YR as t,ZR as u,Xe as v,E as w,A as x,C as y,nC as z,w as A,M as B,iC as C,tt as D,yC as E};
File without changes