@cliptude/cli 0.1.32 → 0.1.33

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.
@@ -1219,12 +1219,16 @@ class CliptudeClient:
1219
1219
  *,
1220
1220
  image_path: str | Path | None = None,
1221
1221
  image_url: str | None = None,
1222
+ image_file: tuple[str, bytes, str] | None = None,
1222
1223
  name: str = "",
1223
1224
  _retried: bool = False,
1224
1225
  ) -> Any:
1225
- """Add a Vector Explainer character from a local image or a public image URL; returns its id."""
1226
- if bool(image_path) == bool((image_url or "").strip()):
1227
- raise CliptudeApiError("Give image_path or image_url (one of them).")
1226
+ """Add a Vector Explainer character from a local image, a public image URL, or (file name, bytes, mime)
1227
+ sent by a widget; returns its id."""
1228
+ if sum(bool(x) for x in (image_path, (image_url or "").strip(), image_file)) != 1:
1229
+ raise CliptudeApiError("Give image_path, image_url or the image itself (one of them).")
1230
+ if image_file:
1231
+ return self._post_vector_character_file(image_file, name, _retried)
1228
1232
  if image_url:
1229
1233
  return self.request(
1230
1234
  "POST", "/api/v1/vector-characters", json_body={"image_url": image_url.strip(), "name": name}
@@ -1254,6 +1258,28 @@ class CliptudeClient:
1254
1258
  self._raise_http(resp, payload=payload)
1255
1259
  return payload
1256
1260
 
1261
+ def _post_vector_character_file(self, image_file: tuple[str, bytes, str], name: str, _retried: bool) -> Any:
1262
+ file_name, raw, mime = image_file
1263
+ try:
1264
+ resp = httpx.post(
1265
+ f"{self.base_url}/api/v1/vector-characters",
1266
+ headers=self._headers(json_content=False),
1267
+ data={"name": name},
1268
+ files={"image": (file_name, raw, mime)},
1269
+ timeout=max(self.timeout, 120.0),
1270
+ )
1271
+ except httpx.HTTPError as exc:
1272
+ raise CliptudeApiError(str(exc)) from exc
1273
+ if resp.status_code == 401 and not _retried and self._maybe_refresh():
1274
+ return self._post_vector_character_file(image_file, name, True)
1275
+ try:
1276
+ payload = resp.json()
1277
+ except ValueError:
1278
+ payload = {"error": resp.text}
1279
+ if resp.status_code >= 400:
1280
+ self._raise_http(resp, payload=payload)
1281
+ return payload
1282
+
1257
1283
  def delete_vector_character(self, character_id: str) -> Any:
1258
1284
  """Delete one of your uploaded characters (refused while a template uses it)."""
1259
1285
  return self.request("DELETE", f"/api/v1/vector-characters/{_uuid_seg(character_id, 'character_id')}")
@@ -340,9 +340,11 @@ def build_server(*, with_http_auth: bool = False):
340
340
  "with its picker, one at a time, and wait for each pick before the next, in this order as the format uses it "
341
341
  "(live formats only: faceless_documentary, faceless_top_10, avatar_video, talking_head, vector_explainer): "
342
342
  "voice (list_voices); the presenter (list_avatars, Avatar Video) or character (list_vector_characters, "
343
- "Vector Explainer); background music (show_choices field background_music_library_file); background picture "
343
+ "Vector Explainer; the user can upload their own there); background music (show_choices field background_music_library_file); background picture "
344
344
  "(show_choices background_image); style pack, visual theme and captions (show_choices "
345
- "faceless_documentary_style, visual_theme, caption_style); then create_template. Never list options as text "
345
+ "faceless_documentary_style, visual_theme, caption_style; Vector Explainer: vector_illustration_style and "
346
+ "vector_reveal_mode instead of the style pack, where Video animation costs more than the default stills); "
347
+ "then create_template. Never list options as text "
346
348
  "when a picker exists. create_template and get_template show the template as a card (voice, presenter, "
347
349
  "music, background, style, switches) with \"Make a video with this template\" and \"Change something\"; "
348
350
  "list_templates shows a gallery with \"Use this template\". "
@@ -584,6 +586,8 @@ def build_server(*, with_http_auth: bool = False):
584
586
  name: Annotated[str, Field(min_length=1, max_length=120, description="A short name for the character, e.g. 'Dr. Maya'")],
585
587
  image_path: Annotated[str | None, Field(description="Local PNG, JPG or WEBP file. Stdio / local MCP only: a remote server refuses it; use image_url there.")] = None,
586
588
  image_url: Annotated[str | None, Field(description="Public https link to the image (use on remote hosts).")] = None,
589
+ image_base64: Annotated[str | None, Field(description="The image itself, base64 (PNG, JPG or WEBP, max 10 MB). The character picker sends this when the user uploads their own.")] = None,
590
+ image_file_name: Annotated[str | None, Field(description="File name of image_base64, e.g. maya.png")] = None,
587
591
  ) -> dict[str, Any]:
588
592
  """Add the user's own Vector Explainer character and return its id (use it as vector_character_id). Use a picture the user supplied, or one you made for them: in that case show it to the user and upload only after they approve it. Best results: one full-body, front-facing character in flat vector style on a plain or transparent background, at least 1024 px, no text. It appears in the Cliptude wizard too."""
589
593
  refused = _local_path_refused(remote, ("image_path", image_path))
@@ -592,8 +596,17 @@ def build_server(*, with_http_auth: bool = False):
592
596
  try:
593
597
  path = (image_path or "").strip() or None
594
598
  url = (image_url or "").strip() or None
595
- if bool(path) == bool(url):
596
- return {"error": "Give image_path or image_url (one of them)."}
599
+ data = (image_base64 or "").strip() or None
600
+ if sum(bool(x) for x in (path, url, data)) != 1:
601
+ return {"error": "Give image_path, image_url or image_base64 (one of them)."}
602
+ if data:
603
+ from .creation import _file_arg
604
+
605
+ image = _file_arg(data_base64=data, file_name=image_file_name or "character.png", path=None,
606
+ local=not remote, what="character image")
607
+ if not image[2].startswith("image/"):
608
+ return {"error": "The character must be a PNG, JPG or WEBP image."}
609
+ return _client().upload_vector_character(image_file=image, name=name)
597
610
  return _client().upload_vector_character(image_path=path, image_url=url, name=name)
598
611
  except Exception as exc:
599
612
  return _err(exc)
@@ -153,6 +153,12 @@ label.row.ack.missing { border-color: light-dark(#f59e0b, #b45309); }
153
153
  .script p { margin: 0; line-height: 1.55; }
154
154
  .script .sentence { display: flex; gap: 10px; }
155
155
  .script .num { flex: none; min-width: 26px; text-align: right; color: var(--color-text-tertiary); font-variant-numeric: tabular-nums; font-size: var(--font-text-xs-size); padding-top: 2px; }
156
+ .tabset { display: flex; flex-direction: column; gap: 10px; }
157
+ .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border-secondary); }
158
+ .tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 6px 10px; margin-bottom: -1px;
159
+ color: var(--color-text-secondary); font-weight: 600; }
160
+ .tab[aria-selected="true"] { color: var(--color-text-primary); border-bottom-color: var(--accent); }
161
+ .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
156
162
  .changes { display: flex; flex-direction: column; gap: 8px; }
157
163
  textarea { font: inherit; font-size: var(--font-text-sm-size); color: var(--color-text-primary); background: var(--color-background-secondary);
158
164
  border: 1px solid var(--color-border-primary); border-radius: var(--border-radius-sm); padding: 8px 10px; resize: vertical; }
@@ -7,6 +7,10 @@
7
7
  <style>
8
8
  /*@BASE_CSS@*/
9
9
  .thumb img { object-fit: contain; background: #fff; }
10
+ .upload { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--color-border-secondary);
11
+ border-radius: var(--border-radius-md); background: var(--color-background-secondary); }
12
+ .upload label { display: flex; flex-direction: column; gap: 4px; font-size: var(--font-text-sm-size); color: var(--color-text-secondary); }
13
+ .upload .photo-preview { max-width: 160px; max-height: 200px; object-fit: contain; background: #fff; border-radius: var(--border-radius-sm); }
10
14
  .card .desc { color: var(--color-text-secondary); font-size: var(--font-text-xs-size); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
11
15
  </style>
12
16
  </head>
@@ -19,7 +23,9 @@
19
23
  <div class="toolbar">
20
24
  <label class="sr-only" for="filter">Filter characters</label>
21
25
  <input type="search" id="filter" placeholder="Filter characters" autocomplete="off">
26
+ <button type="button" id="upload-open">Upload your own</button>
22
27
  </div>
28
+ <div id="upload-panel" class="upload" hidden></div>
23
29
  <div id="content"><div class="status" role="status">Loading characters…</div></div>
24
30
  <div class="selection" id="selection">
25
31
  <span class="what" id="selected-text">Pick a character, or go without one.</span>
@@ -82,6 +88,71 @@
82
88
  document.getElementById("selected-text").textContent = "“" + c.name + "” · " + c.id;
83
89
  }
84
90
 
91
+ /* ---- Upload the user's own character (free; private to their account) ---- */
92
+ var UPLOAD_PAGE = "https://cliptude.com/create/?format=vector_explainer";
93
+ function openUpload() {
94
+ if (!Cliptude.canCallTools()) {
95
+ Cliptude.openLink(UPLOAD_PAGE).then(function () { UI.toast("Opened Cliptude: upload the character in the Vector Explainer step."); })
96
+ .catch(function () { UI.toast("Upload it at " + UPLOAD_PAGE + "."); });
97
+ return;
98
+ }
99
+ var panel = document.getElementById("upload-panel");
100
+ panel.hidden = false;
101
+ var name = h("input", { type: "text", id: "ch-name", maxlength: "120", placeholder: "e.g. Dr. Maya" });
102
+ var file = h("input", { type: "file", id: "ch-image", accept: "image/png,image/jpeg,image/webp" });
103
+ var preview = h("span", {});
104
+ var go = h("button", { type: "button", class: "primary" }, ["Upload"]);
105
+ var cancel = h("button", { type: "button", onclick: function () { panel.hidden = true; Cliptude.reportSize(); } }, ["Cancel"]);
106
+ var out = h("div", {});
107
+ var image = null;
108
+ file.addEventListener("change", function () {
109
+ image = null; UI.clear(preview);
110
+ var f = file.files[0];
111
+ if (!f) return;
112
+ if (f.size > 10 * 1024 * 1024) { UI.toast("The image is over 10 MB."); file.value = ""; return; }
113
+ var reader = new FileReader();
114
+ reader.onload = function () {
115
+ var url = String(reader.result);
116
+ var img = h("img", { class: "photo-preview", src: url, alt: "Selected character" });
117
+ img.onload = function () { Cliptude.reportSize(); };
118
+ preview.appendChild(img);
119
+ image = { name: f.name, base64: url.split(",")[1] };
120
+ if (!name.value.trim()) name.value = f.name.replace(/\.[^.]+$/, "").replace(/[-_]+/g, " ");
121
+ };
122
+ reader.readAsDataURL(f);
123
+ });
124
+ UI.clear(panel).appendChild(h("h2", { class: "section-title" }, ["Upload your own character"]));
125
+ panel.appendChild(h("span", { class: "sub" }, ["Private to your account, and free. Best: one full-body, front-facing character in flat vector style on a plain or transparent background, 1024 px or more, no text."]));
126
+ panel.appendChild(h("label", { for: "ch-name" }, ["Name", name]));
127
+ panel.appendChild(h("label", { for: "ch-image" }, ["Image (PNG, JPG or WEBP, up to 10 MB)", file]));
128
+ panel.appendChild(preview);
129
+ panel.appendChild(h("div", { class: "toolbar" }, [go, cancel]));
130
+ panel.appendChild(out);
131
+ go.addEventListener("click", function () {
132
+ if (!image) { UI.toast("Choose an image."); return; }
133
+ if (!name.value.trim()) { UI.toast("Give the character a name."); return; }
134
+ go.disabled = true;
135
+ UI.status(out, "Uploading…");
136
+ Cliptude.callTool("upload_vector_character", { name: name.value.trim(), image_base64: image.base64, image_file_name: image.name })
137
+ .then(function (res) {
138
+ go.disabled = false;
139
+ var err = UI.errorText(res);
140
+ if (err) { UI.status(out, err, "error"); return; }
141
+ var c = (res && (res.character || res)) || {};
142
+ var added = { id: String(c.id || ""), name: c.name || name.value.trim(), preview_url: c.preview_url || c.image_url || c.url || "",
143
+ descriptor: "Yours", description: c.description || "" };
144
+ if (!added.id) { UI.status(out, "Cliptude did not return the new character's id.", "error"); return; }
145
+ data.uploads = [added].concat(data.uploads || []);
146
+ panel.hidden = true;
147
+ select(added);
148
+ UI.toast("Uploaded. It is selected: press Use this character.");
149
+ })
150
+ .catch(function () { go.disabled = false; UI.status(out, "Could not reach Cliptude.", "error"); });
151
+ });
152
+ Cliptude.reportSize();
153
+ }
154
+ document.getElementById("upload-open").addEventListener("click", openUpload);
155
+
85
156
  document.getElementById("filter").addEventListener("input", render);
86
157
  document.getElementById("use").addEventListener("click", function () {
87
158
  if (!selected) return;
@@ -292,6 +292,51 @@ var Views = (function () {
292
292
  ]));
293
293
  }
294
294
 
295
+ /** The words the reviewed call will voice or brief: the agent's script, or the brief Cliptude writes from. */
296
+ function reviewScriptPanel(input, rev) {
297
+ input = input || {};
298
+ var text = String(input.script || rev.script || "").trim();
299
+ var label = "Script";
300
+ if (!text && input.prompt) { text = String(input.prompt).trim(); label = "Brief"; }
301
+ if (!text) return null;
302
+ var count = words(text);
303
+ var body = h("div", { class: "script", tabindex: "0" });
304
+ text.split(/\n\s*\n/).map(function (p) { return p.trim(); }).filter(Boolean).forEach(function (p) {
305
+ body.appendChild(h("p", {}, [p]));
306
+ });
307
+ return { label: label + " (" + num(count) + " words)", body: body };
308
+ }
309
+
310
+ /** Accessible tabs: [{label, panel}]; the first is shown. Arrow keys move between tabs. */
311
+ function tabs(items) {
312
+ var uid = "t" + Math.random().toString(36).slice(2, 8);
313
+ var list = h("div", { class: "tabs", role: "tablist" });
314
+ var wrap = h("div", { class: "tabset" }, [list]);
315
+ var buttons = items.map(function (item, i) {
316
+ var panel = h("div", { role: "tabpanel", id: uid + "-p" + i, "aria-labelledby": uid + "-t" + i, hidden: i !== 0 }, [item.panel]);
317
+ var btn = h("button", { type: "button", role: "tab", id: uid + "-t" + i, "aria-controls": uid + "-p" + i,
318
+ "aria-selected": i === 0 ? "true" : "false", tabindex: i === 0 ? "0" : "-1", class: "tab" }, [item.label]);
319
+ btn.addEventListener("click", function () { select(i); });
320
+ btn.addEventListener("keydown", function (e) {
321
+ if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
322
+ var next = (i + (e.key === "ArrowRight" ? 1 : items.length - 1)) % items.length;
323
+ select(next); buttons[next].focus(); e.preventDefault();
324
+ }
325
+ });
326
+ list.appendChild(btn);
327
+ wrap.appendChild(panel);
328
+ return btn;
329
+ });
330
+ function select(n) {
331
+ buttons.forEach(function (b, i) {
332
+ b.setAttribute("aria-selected", i === n ? "true" : "false");
333
+ b.tabIndex = i === n ? 0 : -1;
334
+ document.getElementById(uid + "-p" + i).hidden = i !== n;
335
+ });
336
+ }
337
+ return wrap;
338
+ }
339
+
295
340
  function review(container, data, ctx) {
296
341
  var detail = data.detail;
297
342
  var rev = detail.review || {};
@@ -340,7 +385,15 @@ var Views = (function () {
340
385
  var value = str(s.value);
341
386
  table.appendChild(h("dd", { class: s.on === false || value === "Off" ? "off" : "" }, [value]));
342
387
  });
343
- container.appendChild(section("Every setting", [table]));
388
+ var scriptPanel = reviewScriptPanel(ctx.input(), rev);
389
+ if (scriptPanel) {
390
+ container.appendChild(tabs([
391
+ { label: "Every setting", panel: table },
392
+ { label: scriptPanel.label, panel: scriptPanel.body }
393
+ ]));
394
+ } else {
395
+ container.appendChild(section("Every setting", [table]));
396
+ }
344
397
 
345
398
  var confirm = h("button", { type: "button", class: "primary", id: "confirm" }, ["Confirm"]);
346
399
  var change = h("button", { type: "button", onclick: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cliptude/cli",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "Cliptude CLI — generate videos from saved templates.",
5
5
  "homepage": "https://github.com/cliptude/cliptude#readme",
6
6
  "bin": {
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "cliptude-mcp"
7
- version = "0.1.32"
7
+ version = "0.1.33"
8
8
  description = "Cliptude jobs CLI and MCP server (thin client of /api/v1)."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"