cueframe 0.3.2 → 0.4.3

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.
package/README.md CHANGED
@@ -2,26 +2,44 @@
2
2
 
3
3
  Agent-native CLI for **CueFrame** — turn media into rendered video from the
4
4
  terminal. Every command speaks `--json` (an NDJSON event stream) and the binary
5
- self-describes via `cueframe describe --json`, so agents can drive it without
5
+ self-describes via `npx -y cueframe describe --json`, so agents can drive it without
6
6
  guesswork.
7
7
 
8
- > **Preview release.** Early-access build for invited testers, connected to the
9
- > hosted CueFrame service.
8
+ > Connects to the hosted CueFrame service — create an API key at
9
+ > [app.cueframe.ai](https://app.cueframe.ai), or use `npx -y cueframe login`.
10
10
 
11
- ## Install
11
+ ## Run it
12
+
13
+ There is nothing to install. Every command in this README runs as
14
+ `npx -y cueframe …` and is executable verbatim:
12
15
 
13
16
  ```bash
14
- npx cueframe@latest --help # zero-install
15
- # or
16
- npm i -g cueframe # global `cueframe`
17
+ npx -y cueframe --help
18
+ ```
19
+
20
+ `npx -y cueframe install` wires the CueFrame MCP server into every agent on your
21
+ machine — but note it installs **no binary**: npx unpacks to an ephemeral cache and
22
+ leaves nothing on your `PATH`. That is deliberate. `npx` re-resolves the current
23
+ version on every call (~0.5s warm), so these commands can never go stale the way a
24
+ pinned global install does.
25
+
26
+ Running many commands in a row and want to skip that overhead? Install it once and
27
+ drop the `npx -y ` prefix:
28
+
29
+ ```bash
30
+ npm i -g cueframe # optional — needs a user-writable npm prefix
17
31
  ```
18
32
 
33
+ This is an optimization, not the supported path. On a default Linux install it fails
34
+ with `EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cueframe'` unless
35
+ you have configured an npm prefix in your home directory.
36
+
19
37
  ## Authenticate
20
38
 
21
39
  ```bash
22
- cueframe auth <cf_live_… key> # static API key (CI / headless)
40
+ npx -y cueframe auth <cf_live_… key> # static API key (CI / headless)
23
41
  # or
24
- cueframe login # OAuth device flow (browser)
42
+ npx -y cueframe login # OAuth device flow (browser)
25
43
  ```
26
44
 
27
45
  The key can also be supplied via the `CUEFRAME_API_KEY` environment variable.
@@ -30,60 +48,68 @@ The key can also be supplied via the `CUEFRAME_API_KEY` environment variable.
30
48
 
31
49
  ```bash
32
50
  # 1. Register media (video / image / audio)
33
- cueframe upload ./source.mp4 --json # → mediaItemId
51
+ npx -y cueframe upload ./source.mp4 --json # → mediaItemId
34
52
 
35
53
  # 2. Create a project (sets aspect / format)
36
- cueframe project create -n promo -a 9:16 --json # → projectId
54
+ npx -y cueframe project create -n promo -a 9:16 --json # → projectId
37
55
 
38
56
  # 3. Author the composition — tracks of clips, per-clip reframe/trim,
39
57
  # optional captions. The composition is the source of truth.
40
- cueframe composition put <projectId> -b @composition.json
58
+ npx -y cueframe composition put <projectId> -b @composition.json
41
59
 
42
60
  # 4. Render the saved composition to MP4 (queues, SSE-watches, downloads)
43
- cueframe render <projectId> -o out.mp4 --json
61
+ npx -y cueframe render <projectId> -o out.mp4 --json
44
62
  ```
45
63
 
46
64
  `render` takes only a project id and renders whatever composition is saved on
47
- it — no clip suggestion required. Run `cueframe describe --json` for the full
65
+ it — no clip suggestion required. Run `npx -y cueframe describe --json` for the full
48
66
  composition schema and every command + flag.
49
67
 
50
68
  ## Let CueFrame pick the clip (podcast → short)
51
69
 
52
70
  ```bash
53
- cueframe upload ./long.mp4 --analyze --json # media + AI clip suggestions
54
- cueframe clips <mediaItemId> --json # list suggestions (sug_…)
55
- cueframe project create -n short -a 9:16 --from-suggestion <sug_…> --json
56
- cueframe render <projectId> -o short.mp4 --json
71
+ npx -y cueframe upload ./long.mp4 --analyze --json # media + AI clip suggestions
72
+ npx -y cueframe clips <mediaItemId> --json # list suggestions (sug_…)
73
+ npx -y cueframe project create -n short -a 9:16 --from-suggestion <sug_…> --json
74
+ npx -y cueframe render <projectId> -o short.mp4 --json
57
75
  ```
58
76
 
59
77
  Both paths converge on `render`; the suggestion on-ramp just authors the
60
78
  composition for you instead of you hand-writing it.
61
79
 
62
- ## Install the agent skill
63
-
64
- Drop the usage skill into your agent so Claude Code / Cursor / Codex know how to
65
- drive the CLI:
80
+ ## Wire it into your agents
66
81
 
67
82
  ```bash
68
- cueframe install # → ~/.claude/skills/cueframe-cli
83
+ npx -y cueframe install
69
84
  ```
70
85
 
86
+ Detects every agent on the machine — Claude Code, Cursor, Codex, VS Code, Windsurf,
87
+ Zed, Gemini CLI, Copilot CLI and more — and wires the CueFrame MCP server into each
88
+ one's config. Auth happens on the agent's first call via a browser "Allow"; no API key.
89
+
90
+ It also copies the usage skills to `~/.claude/skills/`. **Only Claude Code reads that
91
+ directory** — every other agent gets the same verb surface as MCP tools from the server,
92
+ so there is nothing further to install for them.
93
+
94
+ Claude Desktop and ChatGPT can't be wired from the command line (neither reads a local
95
+ MCP config) — add `https://api.cueframe.ai/v1/mcp` as a custom connector instead.
96
+
71
97
  ## For agents
72
98
 
73
99
  - **`--json` everywhere** — NDJSON lifecycle: `<verb>_prepare → <verb>_progress* → <verb>_complete | error`, plus a non-zero exit on failure.
74
- - **`cueframe describe --json`** — the full command tree as structured JSON.
75
- - **`cueframe api <METHOD> <path>`** — raw escape hatch over the v1 API.
100
+ - **`npx -y cueframe describe --json`** — the full command tree as structured JSON.
101
+ - **`npx -y cueframe api <METHOD> <path>`** — raw escape hatch over the v1 API.
76
102
 
77
103
  ## Common commands
78
104
 
79
105
  | Need to… | Command |
80
106
  |---|---|
81
- | List projects | `cueframe list` |
82
- | Read a composition + ETag | `cueframe composition get <projectId> --json` |
83
- | Write a composition | `cueframe composition put <projectId> -b @comp.json` |
84
- | Export to Final Cut / Premiere | `cueframe export fcpxml \| premiere <projectId> -s <sug_…> --wait -o cut.zip` |
107
+ | List projects | `npx -y cueframe list` |
108
+ | Read a composition + ETag | `npx -y cueframe composition get <projectId> --json` |
109
+ | Write a composition | `npx -y cueframe composition put <projectId> -b @comp.json` |
110
+ | Export to Final Cut / Premiere | `npx -y cueframe export fcpxml \| premiere <projectId> -s <sug_…> --wait -o cut.zip` |
85
111
  | Validate without mutating | append `--dry-run` |
86
112
 
87
113
  ---
88
114
 
89
- © CueFrame — preview release.
115
+ © CueFrame — AGPL-3.0-only. Commercial licences available.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{C as a}from"./chunk-QKQNZIRI.js";import"./chunk-3QSA3EBY.js";export{a as analyzeCommand};
File without changes
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{a as y}from"./chunk-3QSA3EBY.js";var u=class extends Error{status;code;details;requestId;constructor(o,t,n){super(t.message),this.name="ApiError",this.status=o,this.code=t.code,this.details=t.details,this.requestId=n}},P=class extends Error{url;timeoutMs;constructor(o,t){super(`Request timed out after ${t}ms: ${o}`),this.name="TimeoutError",this.url=o,this.timeoutMs=t}},k=class extends Error{url;constructor(o,t){super(`Request failed before a response: ${o}`,{cause:t}),this.name="NetworkError",this.url=o}},l={baseUrl:""};function T(e){return l={timeoutMs:3e4,...e},l}function b(){return l}function Ve(e,o){return/^https?:\/\//.test(o)?o:e.replace(/\/$/,"")+(o.startsWith("/")?o:`/${o}`)}async function j(e,o={}){if(!l.baseUrl)throw new Error("@cueframe/sdk: createClient({baseUrl}) must be called before issuing requests.");let t=l.fetch??fetch,n=Ve(l.baseUrl,e),s=new Headers({accept:"application/json"});for(let[a,f]of Object.entries(l.headers??{}))s.set(a,f);o.headers&&new Headers(o.headers).forEach((a,f)=>s.set(f,a)),l.apiKey&&!s.has("authorization")&&s.set("authorization",`Bearer ${l.apiKey}`);let i=l.timeoutMs??3e4,p=new AbortController,c=setTimeout(()=>p.abort(),i),d=o.signal?AbortSignal.any([o.signal,p.signal]):p.signal;try{let a=await t(n,{...o,headers:s,signal:d}),f={};a.headers.forEach((g,R)=>{f[R.toLowerCase()]=g});let x=null;if(a.status!==204)if((a.headers.get("content-type")??"").includes("application/json"))try{x=await a.json()}catch{x=null}else x=await a.text();return{status:a.status,statusText:a.statusText,headers:f,body:x,requestId:f["x-request-id"]}}catch(a){throw o.signal?.aborted?a:p.signal.aborted?new P(n,i):new k(n,a)}finally{clearTimeout(c)}}async function r(e,o={}){let t=await j(e,o);if(t.status>=400){let n;throw t.body&&typeof t.body=="object"&&"error"in t.body?n=t.body.error??{code:"unknown",message:t.statusText}:n={code:"unknown",message:t.statusText},new u(t.status,n,t.requestId)}if(t.status!==204)return t.body}var He={unauthorized:"The API key is invalid or expired for this target. Run `cueframe login` (or `cueframe auth <api-key>`), and check the key matches the target environment.",forbidden:"The key's scopes don't allow this operation. Create a key with the needed preset (`cueframe keys create --preset ...`) or use a key with wider scopes.",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 E(e){return e instanceof u?He[e.code]??null:null}async function*Ye(e,o,t){let n=b();if(!n?.baseUrl)throw new Error(`@cueframe/sdk: createClient({baseUrl}) must be called before ${o}.`);let s=n.baseUrl.replace(/\/$/,"")+e,i=new Headers({accept:"text/event-stream",...n.headers??{}});n.apiKey&&!i.has("authorization")&&i.set("authorization",`Bearer ${n.apiKey}`);let c=await(n.fetch??fetch)(s,{method:"GET",headers:i,signal:t.signal});if(!c.ok){let x;try{x=(await c.json()).error??{code:"unknown",message:c.statusText}}catch{x={code:"unknown",message:c.statusText}}throw new u(c.status,x,c.headers.get("x-request-id")??void 0)}if(!c.body)throw new Error("SSE response has no body");let d=c.body.getReader(),a=new TextDecoder("utf-8"),f="";try{for(;;){let{value:x,done:g}=await d.read();if(g)break;f+=a.decode(x,{stream:!0});let R=f.indexOf(`
3
+
4
+ `);for(;R!==-1;){let Ze=f.slice(0,R);f=f.slice(R+2);let M=Qe(Ze);M&&(yield M),R=f.indexOf(`
5
+
6
+ `)}}}finally{try{d.releaseLock()}catch{}}}function Qe(e){if(!e.trim())return null;let o=null,t=[];for(let n of e.split(`
7
+ `)){if(!n||n.startsWith(":"))continue;let s=n.indexOf(":");if(s===-1)continue;let i=n.slice(0,s),p=n.slice(s+1).replace(/^ /,"");i==="event"?o=p:i==="data"&&t.push(p)}return!o||t.length===0?null:{event:o,data:t.join(`
8
+ `)}}async function*Xe(e,o,t={}){let n=`/v1/projects/${encodeURIComponent(e)}/renders/${encodeURIComponent(o)}/stream`;for await(let s of Ye(n,"iterRenderEvents",t)){let i=eo(s);i&&(yield i)}}function eo(e){let{event:o,data:t}=e;if(t===null||o!=="progress"&&o!=="complete"&&o!=="error")return null;let n;try{n=JSON.parse(t)}catch{return null}return{event:o,data:n}}var h={};y(h,{composeFromSuggestion:()=>io,getComposeFromSuggestionUrl:()=>G,getListMediaSuggestionsUrl:()=>U,getResetMediaSuggestionsUrl:()=>$,getSuggestBriefsUrl:()=>L,listMediaSuggestions:()=>ao,resetMediaSuggestions:()=>mo,suggestBriefs:()=>fo});var G=e=>`/v1/projects/${e}/composition/from-suggestion`,io=async(e,o,t)=>r(G(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),U=e=>`/v1/media/${e}/suggestions`,ao=async(e,o)=>r(U(e),{...o,method:"GET"}),L=e=>`/v1/media/${e}/suggestions`,fo=async(e,o)=>r(L(e),{...o,method:"POST"}),$=e=>`/v1/media/${e}/suggestions`,mo=async(e,o)=>r($(e),{...o,method:"DELETE"});var D={};y(D,{createComponent:()=>uo,getComponent:()=>lo,getComponentSource:()=>yo,getCreateComponentUrl:()=>J,getGetComponentSourceUrl:()=>z,getGetComponentUrl:()=>W,getListCatalogUrl:()=>_,getUpdateComponentUrl:()=>N,listCatalog:()=>co,updateComponent:()=>xo});var _=e=>{let o=new URLSearchParams;Object.entries(e||{}).forEach(([n,s])=>{s!==void 0&&o.append(n,s===null?"null":s.toString())});let t=o.toString();return t.length>0?`/v1/components?${t}`:"/v1/components"},co=async(e,o)=>r(_(e),{...o,method:"GET"}),J=()=>"/v1/components",uo=async(e,o)=>r(J(),{...o,method:"POST",headers:{"Content-Type":"application/json",...o?.headers},body:JSON.stringify(e)}),N=e=>`/v1/components/${e}`,xo=async(e,o,t)=>r(N(e),{...t,method:"PUT",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),W=e=>`/v1/components/${e}`,lo=async(e,o)=>r(W(e),{...o,method:"GET"}),z=e=>`/v1/components/${e}/source`,yo=async(e,o)=>r(z(e),{...o,method:"GET"});var Q={};y(Q,{cancelExport:()=>Io,createFcpxmlExport:()=>Po,createPremiereExport:()=>ko,getCancelExportUrl:()=>Y,getCreateFcpxmlExportUrl:()=>Z,getCreatePremiereExportUrl:()=>V,getExport:()=>vo,getGetExportUrl:()=>H});var Z=e=>`/v1/projects/${e}/exports/fcpxml`,Po=async(e,o,t)=>r(Z(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),V=e=>`/v1/projects/${e}/exports/premiere`,ko=async(e,o,t)=>r(V(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),H=(e,o)=>`/v1/projects/${e}/exports/${o}`,vo=async(e,o,t)=>r(H(e,o),{...t,method:"GET"}),Y=(e,o)=>`/v1/projects/${e}/exports/${o}/cancel`,Io=async(e,o,t)=>r(Y(e,o),{...t,method:"POST"});var ye={};y(ye,{analyzeTranscript:()=>zo,createMediaUpload:()=>Bo,createUploadToken:()=>wo,deleteMedia:()=>jo,finalizeMedia:()=>Fo,generateMedia:()=>Ao,getAnalyzeTranscriptUrl:()=>le,getCreateMediaUploadUrl:()=>oe,getCreateUploadTokenUrl:()=>ee,getDeleteMediaUrl:()=>pe,getFinalizeMediaUrl:()=>re,getGenerateMediaUrl:()=>ne,getGetMediaContextUrl:()=>fe,getGetMediaPerformanceUrl:()=>xe,getGetMediaTranscriptUrl:()=>ae,getGetMediaUrl:()=>ie,getImportMediaUrl:()=>se,getListMediaFactsUrl:()=>de,getListMediaUrl:()=>te,getMedia:()=>Go,getMediaContext:()=>Lo,getMediaPerformance:()=>Wo,getMediaTranscript:()=>Uo,getPurchaseMediaFactUrl:()=>ue,getSearchLibraryUrl:()=>X,getTriggerMatteBakeUrl:()=>ce,getTriggerSubjectDetectionUrl:()=>me,importMedia:()=>Mo,listMedia:()=>Ko,listMediaFacts:()=>Jo,purchaseMediaFact:()=>No,searchLibrary:()=>Eo,triggerMatteBake:()=>_o,triggerSubjectDetection:()=>$o});var X=e=>{let o=new URLSearchParams;Object.entries(e||{}).forEach(([n,s])=>{s!==void 0&&o.append(n,s===null?"null":s.toString())});let t=o.toString();return t.length>0?`/v1/media/search?${t}`:"/v1/media/search"},Eo=async(e,o)=>r(X(e),{...o,method:"GET"}),ee=()=>"/v1/uploads/token",wo=async(e,o)=>r(ee(),{...o,method:"POST",headers:{"Content-Type":"application/json",...o?.headers},body:JSON.stringify(e)}),oe=()=>"/v1/media",Bo=async(e,o)=>r(oe(),{...o,method:"POST",headers:{"Content-Type":"application/json",...o?.headers},body:JSON.stringify(e)}),te=()=>"/v1/media",Ko=async e=>r(te(),{...e,method:"GET"}),re=e=>`/v1/media/${e}/finalize`,Fo=async(e,o,t)=>r(re(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),ne=()=>"/v1/media/generate",Ao=async(e,o)=>r(ne(),{...o,method:"POST",headers:{"Content-Type":"application/json",...o?.headers},body:JSON.stringify(e)}),se=()=>"/v1/media/import",Mo=async(e,o)=>r(se(),{...o,method:"POST",headers:{"Content-Type":"application/json",...o?.headers},body:JSON.stringify(e)}),pe=e=>`/v1/media/${e}`,jo=async(e,o)=>r(pe(e),{...o,method:"DELETE"}),ie=e=>`/v1/media/${e}`,Go=async(e,o)=>r(ie(e),{...o,method:"GET"}),ae=e=>`/v1/media/${e}/transcript`,Uo=async(e,o)=>r(ae(e),{...o,method:"GET"}),fe=e=>`/v1/media/${e}/context`,Lo=async(e,o)=>r(fe(e),{...o,method:"GET"}),me=e=>`/v1/media/${e}/detect-subjects`,$o=async(e,o)=>r(me(e),{...o,method:"POST"}),ce=e=>`/v1/media/${e}/matte`,_o=async(e,o,t)=>r(ce(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),de=(e,o)=>{let t=new URLSearchParams;Object.entries(o||{}).forEach(([s,i])=>{i!==void 0&&t.append(s,i===null?"null":i.toString())});let n=t.toString();return n.length>0?`/v1/media/${e}/facts?${n}`:`/v1/media/${e}/facts`},Jo=async(e,o,t)=>r(de(e,o),{...t,method:"GET"}),ue=e=>`/v1/media/${e}/facts`,No=async(e,o,t)=>r(ue(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),xe=e=>`/v1/media/${e}/performance`,Wo=async(e,o)=>r(xe(e),{...o,method:"GET"}),le=e=>`/v1/media/${e}/transcript/analyze`,zo=async(e,o,t)=>r(le(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)});var Pe={};y(Pe,{createProject:()=>Zo,deleteProject:()=>Yo,getCreateProjectUrl:()=>Oe,getDeleteProjectUrl:()=>he,getGetProjectContextUrl:()=>Se,getGetProjectUrl:()=>Ce,getListProjectsUrl:()=>Re,getPatchProjectUrl:()=>ge,getProject:()=>Vo,getProjectContext:()=>Qo,listProjects:()=>Do,patchProject:()=>Ho});var Re=()=>"/v1/projects",Do=async e=>r(Re(),{...e,method:"GET"}),Oe=()=>"/v1/projects",Zo=async(e,o)=>r(Oe(),{...o,method:"POST",headers:{"Content-Type":"application/json",...o?.headers},body:JSON.stringify(e)}),Ce=e=>`/v1/projects/${e}`,Vo=async(e,o)=>r(Ce(e),{...o,method:"GET"}),ge=e=>`/v1/projects/${e}`,Ho=async(e,o,t)=>r(ge(e),{...t,method:"PATCH",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),he=e=>`/v1/projects/${e}`,Yo=async(e,o)=>r(he(e),{...o,method:"DELETE"}),Se=e=>`/v1/projects/${e}/context`,Qo=async(e,o)=>r(Se(e),{...o,method:"GET"});var Be={};y(Be,{cancelRender:()=>nt,createRender:()=>et,getCancelRenderUrl:()=>Te,getCreateRenderUrl:()=>ke,getGetRenderUrl:()=>qe,getListProjectRendersUrl:()=>ve,getPreviewClipUrl:()=>Ie,getRefreshRenderUrlUrl:()=>Ee,getRender:()=>rt,getRetryRenderUrl:()=>be,getStreamRenderUrl:()=>we,listProjectRenders:()=>ot,previewClip:()=>tt,refreshRenderUrl:()=>pt,retryRender:()=>st,streamRender:()=>it});var ke=e=>`/v1/projects/${e}/renders`,et=async(e,o,t)=>r(ke(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),ve=e=>`/v1/projects/${e}/renders`,ot=async(e,o)=>r(ve(e),{...o,method:"GET"}),Ie=e=>`/v1/projects/${e}/preview-clip`,tt=async(e,o,t)=>r(Ie(e),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:JSON.stringify(o)}),qe=(e,o)=>`/v1/projects/${e}/renders/${o}`,rt=async(e,o,t)=>r(qe(e,o),{...t,method:"GET"}),Te=(e,o)=>`/v1/projects/${e}/renders/${o}/cancel`,nt=async(e,o,t)=>r(Te(e,o),{...t,method:"POST"}),be=(e,o)=>`/v1/projects/${e}/renders/${o}/retry`,st=async(e,o,t)=>r(be(e,o),{...t,method:"POST"}),Ee=(e,o)=>`/v1/projects/${e}/renders/${o}/refresh-url`,pt=async(e,o,t)=>r(Ee(e,o),{...t,method:"POST"}),we=(e,o)=>`/v1/projects/${e}/renders/${o}/stream`,it=async(e,o,t)=>r(we(e,o),{...t,method:"GET"});var Ue={};y(Ue,{createSession:()=>ct,deleteSession:()=>ut,getCreateSessionUrl:()=>Fe,getDeleteSessionUrl:()=>Me,getGetMuxJobUrl:()=>Ge,getGetSessionUrl:()=>Ae,getListSessionsUrl:()=>Ke,getMuxJob:()=>lt,getSession:()=>dt,getTriggerMuxJobUrl:()=>je,listSessions:()=>mt,triggerMuxJob:()=>xt});var Ke=()=>"/v1/sessions",mt=async e=>r(Ke(),{...e,method:"GET"}),Fe=()=>"/v1/sessions",ct=async(e,o)=>r(Fe(),{...o,method:"POST",headers:{"Content-Type":"application/json",...o?.headers},body:JSON.stringify(e)}),Ae=e=>`/v1/sessions/${e}`,dt=async(e,o)=>r(Ae(e),{...o,method:"GET"}),Me=e=>`/v1/sessions/${e}`,ut=async(e,o)=>r(Me(e),{...o,method:"DELETE"}),je=e=>`/v1/sessions/${e}/mux-job`,xt=async(e,o)=>r(je(e),{...o,method:"POST"}),Ge=e=>`/v1/sessions/${e}/mux-job`,lt=async(e,o)=>r(Ge(e),{...o,method:"GET"});import{readFileSync as gt,writeFileSync as ht,mkdirSync as St,existsSync as Pt}from"fs";import{join as Le}from"path";import{homedir as kt}from"os";var m={Success:0,UserError:2,ApiClientError:3,ApiServerError:4,NetworkError:5,PaymentRequired:6};function w(e){if(e instanceof u){if(e.status===402)return m.PaymentRequired;if(e.status>=500)return m.ApiServerError;if(e.status>=400)return m.ApiClientError}let o=e?.exitCode;return typeof o=="number"?o:m.NetworkError}function tb(e){return e===402?m.PaymentRequired:e>=500?m.ApiServerError:e>=400?m.ApiClientError:m.Success}function S(e){process.exit(e)}var $e=Le(kt(),".cueframe"),v=Le($e,"auth.json"),O={local:"http://127.0.0.1:3211",dev:"https://api-dev.cueframe.ai",prod:"https://api.cueframe.ai"},vt="prod";function ab(e=vt){return process.env.CUEFRAME_API_URL??O[e]??O.prod}var I=class extends Error{constructor(t,n){super(n);this.code=t;this.name="AuthStoreError"}code;exitCode=m.UserError};function _e(){if(!Pt(v))return{targets:{}};let e=gt(v,"utf-8");try{return JSON.parse(e)}catch{throw new I("auth_config_corrupt",`${v} is corrupt and cannot be parsed. Delete it and re-run \`cueframe login\`.`)}}function It(e){St($e,{recursive:!0,mode:448}),ht(v,JSON.stringify(e,null,2),{mode:384})}function fb(e,o="prod",t){let n=_e(),s=O[o]??O.prod;n.targets[o]={apiKey:e,apiUrl:t??s},It(n)}function Je(e="prod"){let o=process.env.CUEFRAME_API_KEY,t=process.env.CUEFRAME_API_URL;if(o)return{apiKey:o,apiUrl:t??O[e]??O.prod};let s=_e().targets[e];if(!s)throw new I("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 s}function Ne(e){let{apiKey:o,apiUrl:t}=Je(e);T({baseUrl:t,apiKey:o})}function q(e){let o=e instanceof u?`${e.message} (${e.code}${e.status?`, ${e.status}`:""})`:e instanceof Error?e.message:String(e),t=E(e);return t?`${o}
9
+ \u2192 ${t}`:o}import qt from"ora";import Tt from"pino";var bt="v1",We=Tt({level:"trace",base:{schemaVersion:bt},messageKey:"event",timestamp:()=>`,"ts":${Date.now()}`,formatters:{level:()=>({_:0})}});function B(e,o){return qt({text:e,isSilent:!!o}).start()}function C(e,o,t={}){e.json&&We.info(t,o)}function Rb(e,o,t){if(e.json){console.log(JSON.stringify(o,null,2));return}t()}function K(e,o,t,n){let s=t instanceof Error?t.message:String(t),i=typeof t?.code=="string"?t.code:void 0,p=t?.status;e.json?We.info({phase:o,message:s,...i?{code:i}:{},...typeof p=="number"?{status:p}:{},exitCode:n},"error"):process.stderr.write(`\u2716 ${o}: ${q(t)}
10
+ `)}function F(e,o,t,n){e.json&&K(e,o,t,n)}function Ob(e,o){o.json||console.log(e)}function Et(e){for(let o=0;o<e.length;o++){let t=e.charCodeAt(o);if(t<=31||t===127)return!0}return!1}function De(e,o,t){e.length===0&&ze(`${o} is empty.`,t),Et(e)&&ze(`${o} contains a control character (newline, tab, or null byte). Identifiers must be plain text \u2014 check for a stray copy-paste artifact.`,t)}function ze(e,o){K(o,"preflight",new Error(e),m.UserError),S(m.UserError)}var wt=5e3,A=300*1e3;async function Tb(e,o){if(De(e,"mediaItemId",o),o.dryRun){C(o,"analyze_dry_run",{mediaItemId:e,target:o.target,wait:!!o.wait,wouldCall:"POST /v1/media/:id/suggestions"}),o.json||console.log(`[dry-run] Would trigger clip analysis for ${e} on ${o.target}.`);return}Ne(o.target),C(o,"analyze_prepare",{mediaItemId:e,target:o.target,wait:!!o.wait});let t=B("Triggering clip analysis\u2026",o.json),n;try{n=await h.suggestBriefs(e),t.succeed(n.workflowId?`Analysis started (workflow: ${n.workflowId})`:`Analysis ${n.alreadyRunning?"already running":"started"}`)}catch(p){t.fail(`Failed to start analysis: ${q(p)}`),F(o,"analyze_prepare",p,w(p)),S(w(p))}if(C(o,"analyze_ready",{mediaItemId:e,workflowId:n.workflowId,alreadyRunning:!!n.alreadyRunning}),!o.wait){o.json||console.log(`
11
+ Run \`cueframe clips ${e}\` to check results.`);return}let s=B("Waiting for analysis to complete\u2026",o.json),i=Date.now();for(;;){await new Promise(p=>setTimeout(p,wt)),Date.now()-i>A&&(s.fail(`Timed out after ${Math.round(A/1e3)}s. Run \`cueframe clips ${e}\` to check later.`),F(o,"analyze_progress",new Error(`Analysis did not complete within ${Math.round(A/1e3)}s`),m.UserError),S(m.UserError));try{let p=await h.listMediaSuggestions(e);if(p.suggestions.length>0){s.succeed(`Analysis complete \u2014 ${p.suggestions.length} clips found`),C(o,"analyze_complete",{mediaItemId:e,durationMs:Date.now()-i,suggestionCount:p.suggestions.length,suggestions:p.suggestions}),o.json||p.suggestions.forEach((d,a)=>{let f=(d.trim.end-d.trim.start).toFixed(1);console.log(`
12
+ ${a+1}. ${d.title} (${d.id})`),console.log(` ${d.trim.start.toFixed(1)}s \u2013 ${d.trim.end.toFixed(1)}s (${f}s) score: ${d.score}`),console.log(` ${d.reason}`)});return}let c=Math.round((Date.now()-i)/1e3);s.text=`Waiting for analysis\u2026 (${c}s)`,C(o,"analyze_progress",{mediaItemId:e,elapsedSec:c})}catch{}}}export{u as a,T as b,j as c,r as d,E as e,Xe as f,h as g,D as h,Q as i,ye as j,Pe as k,Be as l,Ue as m,m as n,w as o,tb as p,S as q,ab as r,fb as s,Ne as t,q as u,B as v,C as w,Rb as x,K as y,F as z,Ob as A,De as B,Tb as C};