Commit graph

409 commits

Author SHA1 Message Date
juancarlos.cavero
925583efdd feat(mcp): stdio transport for hosts that only launch a subprocess
Some MCP hosts never speak HTTP to a server: they run it as a command and
talk over stdin/stdout. Glama's Dockerfile deployments wrap exactly that
(and a local self-host user can now skip the web server entirely), so the
directory could not introspect our tools at all — mcp.openshorts.app 401s
without a key, by design.

mcp_stdio.py is transport only: mcp_server keeps the protocol, and tool
calls go through the same call_tool -> ASGITransport path, so stdio and
HTTP cannot answer differently. Two things it has to get right, both
covered by the test: stdout is swapped for stderr before app is imported,
because the pipeline prints everywhere and one stray line corrupts the
JSON-RPC stream; and the app's lifespan is entered explicitly, which
ASGITransport does not do on its own.

glama.json declares the maintainer, one of the listing gaps the directory
reports.

Claude-Session: https://claude.ai/code/session_01PkWCDoMsdmSxGXXh4jqF1m
2026-09-07 11:50:39 +02:00
victormanuel.caverogracia
59ec005d3a fix(build): remove untracked openConsentManager references from Landing.jsx 2026-09-07 11:45:43 +02:00
victormanuel.caverogracia
2d36b03370 fix(build): remove untracked consent and CookieBanner imports from main.jsx 2026-09-07 11:41:25 +02:00
victormanuel.caverogracia
ca9ecd6e67 perf: optimize pagespeed - lazy load app, fix video CLS and compress logo 2026-09-07 11:30:33 +02:00
juancarlos.cavero
a602a2aa96 fix(videos): restore a project from R2 before answering 404 under /videos
Reopening a project whose working files were gone (redeploy, hourly sweep)
fired the transcript requests, which pull the job back from R2 (~25 s for
2 GB), and the <video> loads at the same instant; /videos was a plain
StaticFiles mount, so every player got a 404 until the user reloaded
(job cff3ad6c, 6-sep-2026 00:37 UTC, 15 x 404).

- restoring_static.py: StaticFiles subclass that, on a miss, hands the job
  id to a restorer and looks once more. Range/ETag/HEAD behaviour untouched.
- app.py: restore_project's core is now _restore_job_files (no auth, the
  caller decides); the /videos restorer looks the Project up by job id and
  restores for its owner. The files are public by job id already, so this
  grants nothing new. A player arriving mid-restore waits on the per-job
  lock instead of failing. The "Auto-restored" line is printed once, when
  files were actually pulled, instead of once per waiting request.

Claude-Session: https://claude.ai/code/session_013ubPhpBw8kAUcLXCCfH4C5
2026-09-06 12:28:38 +02:00
juancarlos.cavero
959407c30e fix(download): explicit default,mweb clients so account cookies stop yielding "Video unavailable"
With account cookies yt-dlp's authed defaults are tv_downgraded + web, and on
a share of videos both come back UNPLAYABLE / SABR-only, reported as "Video
unavailable" with no formats. That happened on every static IP too, so it was
mistaken for an IP ban and fed ~26 downloads a week to the per-GB proxy,
which then fetched 360p through the same dead client list. Measured in the
prod container on 6-sep-2026, same static proxy, same video: cookies +
defaults -> unavailable; cookies + default,mweb (+ PO token) -> 1080p; no
cookies -> 1080p.

- yt_clients.py: one client list (default,mweb + bgutil provider) shared by
  the download and the duration probe. Never player_skip=webpage: it drops
  the Data Sync ID and mweb loses its PO token (360p only).
- main.py: the fallback list (tv_embed, android) is gone from yt-dlp; the
  fallback now runs anonymously when the cookie attempt already failed on
  that route, and every attempt asks for the 1080p spec (the fallback's
  best[ext=mp4] was itself the 360p progressive file).
- metering: an uploader's country block is a content error; the residential
  pool failed identically in 5 of 6 paid probes (3-5 sep). The probe alert
  now says when the paid proxy failed too.

Claude-Session: https://claude.ai/code/session_013ubPhpBw8kAUcLXCCfH4C5
2026-09-06 03:43:46 +02:00
juancarlos.cavero
3c9cc989f2 fix(metering): the duration probe carries the download's cookies
Ten probes in one hour on 4-sep paid the per-GB proxy 1.8 MB each because
all three static IPs answered 'Sign in to confirm you are not a bot' to the
ANONYMOUS probe, while the same IPs served the cookie-authenticated
download of those very videos without a complaint: a datacenter IP's
anonymous rate limit is low and we make ~400 YouTube hits a day from three
of them. The probe now writes YOUTUBE_COOKIES to a temp file and passes it
as cookiefile, exactly as download_youtube_video does, and removes it in a
finally (the chain walk moved into _probe_with_proxies so that file has one
obvious lifetime).

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-04 16:03:16 +02:00
juancarlos.cavero
a85a41bb6a fix(download): free fallback-static attempt before any per-GB proxy
Since the static IPs moved to three countries, every remaining paid rescue
had the same shape: all three statics answer 'Video unavailable' and the
paid fallback then downloads the video fine. Tested on the morning's case
(2eCIMQMy0AQ): the video is fine from a residential IP, the HD/web client
gets the fake unavailable on all three statics, and the conservative
clients (tv_embed/android) pass on those very same IPs. So it is the
client, not the IP, and the fix is free: try the fallback strategy through
a static before spending a per-GB byte. No quality trade: the paid path
was capped at 720p anyway.

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-04 16:03:16 +02:00
victormanuel.caverogracia
3e6d5c3bee feat(billing): mirror paid invoices, top-ups and refunds into OpenPanel as revenue
The browser's `Subscribed` event is an intent signal: it misses renewals,
is eaten by ad-blockers and never sees a refund. The Stripe webhook is the
only place money is known for certain, so every invoice.paid (new /
renewal / upgrade), one-off top-up and charge.refunded (negative) is now
mirrored as OpenPanel's native `revenue` event, keyed by the user uuid the
browser and the job events already use.

Each event carries the acquisition channel read back from
signup_attribution (utm_source > referrer host > direct) plus plan,
interval, billing_reason and the Stripe id — so revenue is sliceable by
where the buyer came from. Fire-and-forget: never touches the webhook path.

The dashboard now `identify`s the signed-in user on every boot (OpenPanel
keeps the profile in memory only) and clears it on sign-out, so pageviews
and the server-side events share one profile.

Also fixes GET /api/billing/invoices, which called the non-existent
`database.SessionLocal` and 500'd for every user with a Stripe customer.

Claude-Session: https://claude.ai/code/session_01GPZmS33ubmHxHEc84X7sQy
2026-09-03 14:16:19 +02:00
juancarlos.cavero
780306540f test(proxy): import yt_dlp lazily so the minimal CI env collects the module
Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-02 13:27:22 +02:00
juancarlos.cavero
5459f69ec6 feat(proxy): daily budget cap for the paid proxy, and probe the statics against YouTube
PAID_PROXY_DAILY_MB (default 500): past it, the per-GB proxy is dropped
from the duration probe and from every new job's env until UTC midnight,
with one Telegram note per day. A repeat of 28-aug (statics refused by
YouTube for hours) now costs $0.50 at worst instead of $14.

The watcher probed the statics against google.com/generate_204, which kept
answering 204 that whole day while YouTube served the static IPs fake
'Video unavailable'. A static now has to return a real watch page with a
playable player response; the paid probe keeps the cheap plain-HTTP 204
(HTTPS through DataImpulse breaks in httpx even when healthy).

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-02 13:25:06 +02:00
juancarlos.cavero
0ed40c3a8f fix(proxy): treat 'Video unavailable' on a static route as IP-suspect
Five videos 'unavailable' on all three static IPs on 1-sep downloaded fine
through the residential proxy (proxy_usage rows 19:33-07:07): YouTube
serves a fake unavailable to IPs it dislikes, the 19-aug symptom. Blocking
the paid retry on that text would 400 real videos; a truly dead link now
costs ~3 MB to re-check instead.

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-02 12:37:10 +02:00
juancarlos.cavero
c20ecc69c5 fix(proxy): read the job's source URL after the script name, not python's -u flag
Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-01 18:18:47 +02:00
juancarlos.cavero
4748e1bfa6 fix(proxy): keep the per-GB proxy at zero and leave a durable trail when it is used
DataImpulse showed ~0.2 $/day with the static pool healthy, and $14 on
28-aug that nothing on the server could explain: the monthly counter is
in-memory and the container log rotates within the hour. The panel's
per-host rows for 31-aug/1-sep pointed at two leaks.

The duration probe (cloud/metering.probe_url_minutes) walked every URL that
failed on the statics through the paid proxy with both extractors, ~1.7 MB
a time: private, removed and members-only videos, live streams with no
duration, and every non-YouTube URL (Twitch, Kick, Rumble, product pages,
drive links) that the download plan itself never sends there. It now
reaches the paid proxy only for a failure another IP can fix (bot-check,
403/429, proxy or network errors) and never for a non-YouTube URL.

main.py prints PROXY_ROUTE=<json> after every download: the winning
attempt, paid bytes summed over every attempt that used the per-GB proxy
(failed ones included; a paid attempt that died after three fragments was
billed for them), and each free attempt's error text. app.py persists it as
a proxy_usage row at job end and pages Telegram whenever the paid proxy
carried bytes, folding a burst into one message per 5 min; a probe that
reached the paid proxy is recorded the same way.

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-01 17:56:48 +02:00
victormanuel.caverogracia
2876878237 fix(dashboard): refresh the header minute meter after usage
Minutes are reserved when a job starts, not when it finishes. Re-fetch
/api/me on start, complete, fail, quota, bulk subtitles and clip re-render
so the pill in the header moves without a reload.
2026-09-01 14:26:45 +02:00
victormanuel.caverogracia
8a22fa7b9e fix(dashboard): replace cramped tutorial card with a Next tour
The coach chip stacked three step labels on top of each other. Walk Clip
Generator control by control instead, and park the tooltip inside the
viewport on small screens.
2026-09-01 14:11:44 +02:00
victormanuel.caverogracia
016267f204 feat(dashboard): first-login Clip Generator tutorial
New accounts land on Clip Generator with other tools locked. A modal
walks paste → generate → clips and celebrates the first successful job.
2026-09-01 13:55:37 +02:00
victormanuel.caverogracia
b4000ac9bc feat(billing): legal invoices from AgentLedger on the account page
GET /api/billing/invoices lists the AgentLedger-issued Spanish invoices for
the signed-in user's Stripe customer (public View/PDF links), backfilling the
customer's history on demand when AgentLedger has nothing yet. New env:
AGENTLEDGER_API_KEY (+ optional AGENTLEDGER_API_URL / AGENTLEDGER_TREASURY_ID).
InvoicesCard renders under the plan card for accounts with a billing relationship.

Claude-Session: https://claude.ai/code/session_01Chec1RKALL2v8V4GsDfPCW
2026-09-01 12:36:59 +02:00
victormanuel.caverogracia
2b2a58202e fix(dashboard): drop the public gallery link from UGC gallery
The in-app grid already is the gallery; the extra tab to /gallery was redundant.
2026-09-01 10:35:19 +02:00
victormanuel.caverogracia
9d69bea940 fix(dashboard): play UGC gallery clips in a modal
Cards were mounting every mp4 with preload=metadata, so the grid stalled,
and click did nothing except a hidden View link that opened another tab.
Posters only until click; playback stays on the same screen.
2026-09-01 10:27:34 +02:00
juancarlos.cavero
5fe2251a4d fix(hooks): grounded hook keeps the clip's strongest figure
The rewrite named the on-screen thing but traded the number for it ("7x
faster" became "using NVIDIA"). The prompt now requires both.

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-01 02:19:00 +02:00
juancarlos.cavero
41952d6208 fix(hooks): ground GENERAL stretches too when the video is a screencast
First prod run of hook grounding on a product-update video: the layout
picker said screencast (0.95) but the render emitted only track/general
ranges, because the width gate did not upgrade the stats cards, so the
grounding never fired and every clip kept its topic-summary hook. A
GENERAL scene on a screencast video is a face-less full-screen slide or
dialog, not a group shot (checked frame by frame), so it now counts as
screen when screencast_layout is enabled for the job.

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-01 02:18:21 +02:00
juancarlos.cavero
58056996f4 feat(hooks): ground hook and title on the screen for screencast clips
The hook and title come from the detail pass, which only reads the
transcript, so a clip whose meaning is on the screen shipped with a topic
summary ("I automated my clips with AI") while the viewer watched an MCP
connector being configured.

Two halves. The detail prompt now carries the rule that hook and title name
the concrete thing happening inside the clip, never the video's topic. And
after the render, when the layout sidecar says at least 25% of a clip is
screencast / wide / inset, hook_grounding sends three frames from those
stretches at 1024px plus the clip's own words to Gemini and rewrites hook
and title in place before auto_hook_clip burns them; the originals stay
under hook_grounding.before. Gemini-only (frames): a local-LLM install logs
one line and keeps the transcript hook. HOOK_GROUNDING=0 disables it.

Verified live on the reported frame: on_screen "Configuración del conector
del servidor MCP de OpenShorts", hook "Configura el servidor MCP de
OpenShorts paso a paso", stable across three runs.

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-01 02:02:22 +02:00
juancarlos.cavero
c0da654733 feat(llm): run the moment picker on any OpenAI-compatible server (Ollama, vLLM, LM Studio)
Self-hosters asked for a pipeline that never calls Google. LLM_BASE_URL (+
LLM_MODEL, LLM_API_KEY) routes the transcript scoring and detail passes of
get_viral_clips to a /chat/completions endpoint; the answer is validated with
the same pydantic schemas Gemini enforces server-side, so main.py sees one
shape. json_schema is requested first and the request falls back to
json_object and then to free text when a server rejects the field.

Scoring batches drop from 8 to 3 windows on the local path: Ollama's default
4k context truncates silently and a truncated prompt scores garbage.
Self-host /api/process now accepts a request without X-Gemini-Key when the
backend is configured, /api/config exposes localLlm and the dashboard stops
demanding the key. Frame-based stages (layout picker, on-screen content,
silent videos) stay on Gemini and degrade as before without a key; the
silent-video path says so instead of failing generically.

Verified end to end with Ollama 0.13.5 + qwen2.5:7b on an M1 Pro: a 15-min
talk, 14 windows, 6 clips with usable hooks and titles, six local calls and
zero requests to Google.

Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
2026-09-01 01:34:48 +02:00
victormanuel.caverogracia
0c65520e2f fix(dashboard): bind Icon in pricing and legal maps
The hosted-vs-self table on #/pricing and the legal docs list rendered
<Icon> without destructuring icon from the row, which crashed the page.
2026-08-31 18:08:08 +02:00
juancarlos.cavero
56697568f9 fix(source): refuse to mint a signed url for a job we cannot identify
/api/source-url skipped the ownership check when the job record did not
resolve, and then signed anyway. That made it the one door in the design that
hands out a working capability without asking who is asking, which is precisely
what locking down /api/source was for.

Narrow in practice: a real job resolves, from its metadata or from the manifest
that names its owner while it runs, so the uncovered case is a directory in a
half-written state. It also still takes guessing a UUID, so this was never
worse than the behaviour it replaced. It is fixed because "a hole with a rare
precondition" is still a hole.

Off billing it keeps answering, since there is no owner to check and the
self-host preview would otherwise break for nothing.

The test stubs the minter so that reopening the hole fails on the status
assertion rather than on _cloud_config being None off billing: a test that
passes only because the code under it happens to crash stops guarding the day
it stops crashing. Verified by reopening the hole and reading the failure.

Claude-Session: https://claude.ai/code/session_01WyFE2wXi8quZR6nLRRLDgE
2026-08-31 00:14:18 +02:00
juancarlos.cavero
57e32b9052 fix(legal): narrow the refund promise and say who owes the visible ai disclosure
Two corrections to texts published this morning, both of them cases where what
we wrote was wider than what we meant.

Refunds. The policy now covers the most recent charge only, and only when the
service went unused since it was taken: this is the renewal nobody noticed, not
a free trial with the receipts kept. "Used" is defined as minutes spent, since
that is the thing the system can actually check, and signing in to look around
is called out as not using it.

That change has a consequence section 12 had to follow. The first version said
the commercial policy was more generous than the statutory withdrawal right and
was the one that applied. With a no-usage condition attached that stopped being
true, and a clause claiming to supersede a consumer right while being worse than
it is void and reads badly. Section 12 now says the two do different jobs, and
that the statutory right is the one that helps when minutes were spent, because
it refunds pro rata without requiring the service be untouched. The refund pages
point at it rather than letting anyone lose it.

AI labelling. Section 7 said we "label and mark" dubbed clips, which promised a
visible label we do not burn and do not intend to. Art. 50(2) puts the
machine-readable marking on the provider, which we now do; art. 50(4) puts the
visible disclosure on the deployer, which is the person publishing, and each
platform's AI-content label is the normal way for them to discharge it. The text
now says exactly that, and covers AI-actor videos too, which are marked as well.

Claude-Session: https://claude.ai/code/session_01WyFE2wXi8quZR6nLRRLDgE
2026-08-29 20:58:45 +02:00
juancarlos.cavero
87adf88daa fix(source): stop serving the untouched original without a credential
GET /api/source streams the file we downloaded, not a derived clip, and it was
open on the reasoning that the UUID job id is the capability. That makes the
product a public YouTube downloader wearing a UUID, which is the characterisation
worth avoiding, and one leaked id in a log or a referer opens someone else's
video.

A <video src> cannot carry an Authorization header, which is why it was open in
the first place, so the owner mints a short-lived signed URL from
/api/source-url and hands the player that. The endpoint takes the signature or
falls back to the owner check. Self-host and ownerless BYOK jobs are untouched:
no owner to check, no secret to sign with. The owner lookup is gated on
BILLING_ENABLED because it falls through to a full rescan of the output
directory, which off billing would run on every preview and buy nothing.

Both minters go through _signed_source_url. The EDL feeds ClipEditor's source
monitor the same way and was built as a bare path, which works in self-host and
in every test and 404s in cloud. The regression test asserts the endpoint calls
the minter rather than comparing strings: off billing the helper returns that
same bare path, so a string comparison passes just as happily with the bug in.
Verified by putting the bug back and watching it fail.

The frontend mints at render, not when the session is persisted, or localStorage
would hold a token that expired overnight.

SOURCE_RETENTION_SECONDS can age the retained download out ahead of the clips it
produced, and defaults to the job clock, so nothing changes until someone sets
it. Lowering it is not free: the EDL, rerender, scenes and reframe endpoints all
read that file and answer 409 once it is gone.

Claude-Session: https://claude.ai/code/session_01WyFE2wXi8quZR6nLRRLDgE
2026-08-29 17:19:39 +02:00
juancarlos.cavero
8c91403f22 feat(ai-act): mark dubbed and ai-actor output as machine-readable ai content
Art. 50(2) asks a provider whose system generates synthetic audio or video to
mark the output in a machine-readable way, and the terms already promised we
"label and mark" dubbed clips while nothing did either.

mark_ai_generated stamps the disclosure by stream copy, so it is a remux and
never a re-encode. The tag is `comment` because mp4 keeps only the standard
tags and ffmpeg drops a custom key without warning, which a test pins. It is
best effort by design: a missing tag must not lose someone the video they just
paid minutes for.

Deliberately narrow, on dubbing and AI actors, not on an ordinary clip whose
pixels and audio are the user's own footage. Marking everything would make the
tag mean nothing. TranslateModal says the file is tagged and that the person
publishing it owes their audience the disclosure, which is the art. 50(4) duty
and falls on them, not on us.

Still missing, and a product decision rather than an oversight: the visible
burned-in label.

Claude-Session: https://claude.ai/code/session_01WyFE2wXi8quZR6nLRRLDgE
2026-08-29 17:19:24 +02:00
juancarlos.cavero
72780441d8 feat(billing): collect terms acceptance and immediate-performance consent at checkout
The session was created without consent_collection, so nothing recorded that
the buyer accepted the terms, and nothing captured the express request for
immediate performance that lets us charge for the minutes already consumed when
someone withdraws inside the 14 days. The terms described that mechanism; the
checkout did not implement it.

Falls back to a checkout without the box if Stripe rejects it, and matches on
the message rather than the exception class: the box needs a terms of service
URL set in the dashboard, and which subclass Stripe raises for that is not
worth betting the pay button on. It switches itself on once the URL is there.

Claude-Session: https://claude.ai/code/session_01WyFE2wXi8quZR6nLRRLDgE
2026-08-29 17:19:11 +02:00
juancarlos.cavero
e21cab22fb feat(legal): dmca agent, california rights, refunds and a notice-and-action page
Five gaps in the published package, all of them things the texts either
promised or needed:

- DMCA. Section 9 implemented the DSA notice-and-action mechanism, which does
  not grant the US safe harbor. Adds the designated agent under 512(c)(2), what
  a notification must contain, the counter-notification of 512(g) and the
  misrepresentation liability of 512(f). Publishing this is only half of it:
  the designation still has to be filed at dmca.copyright.gov.
- California. The privacy policy had no CCPA/CPRA section at all. Says plainly
  that we do not sell or share, and that the reframing detects faces to know
  where to crop but never to identify anyone, which is the question a CPRA
  reader asks next.
- Refunds. New /refunds and /reembolsos: 14 days from any charge, refunded in
  full, no usage deducted. Section 12 now says the commercial policy is more
  generous than the statutory withdrawal right and is the one that applies,
  because two clauses answering differently about the same 14 days is what a
  dispute is made of.
- Notice and action. The art. 16 mechanism lived inside a terms clause, which
  reads poorly against "easy to access". Now its own page in both languages,
  linked from the footer, the hub and section 9.
- Signup. LoginModal created the account without linking the terms or the
  privacy policy: a magic-link signup never passes the footer.

docs/dsa-notice-and-action.md is the half nobody outside sees: acknowledge the
same working day, decide in 72 hours, the art. 17 statement of reasons, and a
written three-strike rule, since "reasonably implemented" is the test and an
unwritten policy fails it. It also records why arts. 15 and 20-28 do not apply
to us (hosting service, micro enterprise), so nobody builds them by mistake.

Claude-Session: https://claude.ai/code/session_01WyFE2wXi8quZR6nLRRLDgE
2026-08-29 17:19:11 +02:00
juancarlos.cavero
ad8ab59086 fix(dashboard): the score badge has to say what it is
It shipped as a bare coloured number next to "Clip 4", which on a video
thumbnail reads as a duration, a rank, a position — anything. The user's
reaction to the deployed version was "sale el número pero no se entiende qué
es", which is the whole feature failing to land.

Now it names itself and carries its scale: a trend icon, the word "viral", the
number, "/100". Only the number takes the traffic-light colour, so the label
stays quiet and the value is what the eye lands on.

Claude-Session: https://claude.ai/code/session_01KeQYCfUX2E9Q2fDgZMKEaJ
2026-08-29 03:00:13 +02:00
juancarlos.cavero
6f9c01e2c6 feat(dashboard): show each clip's score and lead with the best one
The detail pass has always returned a predicted_score per clip and the
dashboard threw it away, rendering the clips in transcript order. That buries
the strongest clip wherever it happens to fall in the video, and the first card
is the one people actually watch, publish and judge the product by.

The cards are now ordered by score, and each one carries its number. The
ORIGINAL array position is what still travels down as `index`: it is the clip's
identity in clip_index on /api/subtitle, /api/edit and publishing, in the
clip-N.mp4 download name and in the saved per-clip project state. Sorting the
array itself would have repointed all of that at the wrong clip, silently.

So the badge keeps saying "Clip 4" at the top of the list rather than "Clip 1" —
the number identifies the file you download, the position tells you what to post
first. Ties and clips with no score keep transcript order.

Claude-Session: https://claude.ai/code/session_01KeQYCfUX2E9Q2fDgZMKEaJ
2026-08-29 02:53:32 +02:00
juancarlos.cavero
2a84049c4a test(alerts): bring the proxy watcher tests onto the two-strike rule
5807217 made a route miss two probes before paging and re-worded the
alerts by impact, but only added tests for the new behaviour — the older
file still asserted the old contract and CI has been red since.

A single tick no longer opens an incident, so the specs now tick
`_PROXY_STRIKES` times; the statics-down alert says "down" rather than
"DOWN" because with the paid proxy still answering it is a cost warning,
not an outage; and the nag repeats the headline with the elapsed hours
instead of "STILL down".

The fixture also cleared every piece of watcher state except the strike
counter that commit introduced, which leaked between tests.

Claude-Session: https://claude.ai/code/session_01AzDnEa5EREFyibXEwsRCW9
2026-08-29 01:51:32 +02:00
juancarlos.cavero
9c7cae2173 fix(social): say that a tiktok draft carries no caption, and say it when scheduling a week
ResultCard warned that tiktok arrives as a draft; ScheduleWeekModal, which
queues a whole week at once and has tiktok on by default, said nothing. That
is the worse of the two: a silent drawer of drafts and a profile that stays
empty for seven days reads as a broken integration.

Both notices were also missing the actionable half. TikTok's upload-to-inbox
endpoint takes only source_info — there is no post_info anywhere in the
request — so the title and description we send are dropped for a video draft,
whether the user typed them in ResultCard or the AI wrote them for the weekly
queue. The user has to write them in the app, and neither screen said so.

Extracted to one component so the two copies cannot drift.

Claude-Session: https://claude.ai/code/session_01KeQYCfUX2E9Q2fDgZMKEaJ
2026-08-29 01:42:45 +02:00
juancarlos.cavero
4a137005ca fix(selection): trim the detail pass by score, not by position
The detail pass returns its clips in transcript order, batch after batch, and
the overflow was cut with shorts[:max_clips] — which keeps the EARLIEST clips
and drops the tail. On a 9m19s walkthrough, three runs of the same source put
every surviving clip inside the first 2m40s, 4m39s and 8m55s respectively; the
demo, the MCP walkthrough and the close were simply the part of the list that
fell off the end. The failure scales the wrong way, too: the more clips the
model proposes, the more of the video disappears (output tokens 2067 -> 8m55s
of coverage, 3407 -> 2m40s).

It also undoes the windowing. get_viral_clips builds scoring windows precisely
because "a single call over the whole transcript clusters picks near the
start", and a positional slice puts that clustering straight back. Pass 1
already sorts by score before its own cut; pass 2 just never did.

trim_to_best ranks by predicted_score, which the detail prompt has always
asked for and nothing here was reading, and returns the survivors in
transcript order so clip numbering still runs front to back.

Claude-Session: https://claude.ai/code/session_01KeQYCfUX2E9Q2fDgZMKEaJ
2026-08-29 01:42:45 +02:00
juancarlos.cavero
b4be92cb63 fix(reframe): a source already shot vertical is passed through untouched
The scene classifier sends every face-less shot to GENERAL, and GENERAL scales
the content to 42% of the frame height. That ratio buys presence on a LANDSCAPE
source by overflowing the sides; on a 1080x1920 upload the same number is a
shrink, leaving a 453px sliver floating over a blurred copy of itself. A user's
already-vertical video came back with its screen-recording scenes rendered that
way while its talking-head scenes (TRACK, whose crop is the whole frame) looked
right, so a single clip alternated between correct and ruined.

source_already_fits() gates the whole thing: a source at or past the target
aspect has no width to buy back, so the classifier, the SPLIT detection and the
screencast/inset upgrades are all skipped and every scene renders TRACK. The
layout picker is skipped too, saving a Gemini call per upload that the render
would have ignored anyway.

general_filtergraph() additionally floors the foreground at the height where the
source fills the output width, so the editor's explicit GENERAL override on a
portrait clip cannot reproduce the shrink. A 16:9 source keeps the 0.42 ratio
untouched.

Two siblings of the same bug, both only reachable on a source TALLER than the
target: the TRACK crop pinned y=0 and threw away the bottom of the frame instead
of trimming both ends, and v1's create_general_frame indexed the output with a
negative offset, which raises rather than renders.

Claude-Session: https://claude.ai/code/session_01KeQYCfUX2E9Q2fDgZMKEaJ
2026-08-29 00:06:15 +02:00
juancarlos.cavero
5807217f00 fix(alerts): proxy watcher says what is affected, and needs two misses
'paid proxy DOWN: YouTube-URL jobs will keep failing' fired on a single
ReadTimeout while the three static proxies were fine, and read as an
outage. Severity now follows the actual impact: fallback down with the
statics up is informational (no impact), statics down is a cost warning
(jobs run on the per-GB proxy), both down is the red one. A route has to
miss two probes 30 min apart before anyone is paged.
2026-08-28 01:21:06 +02:00
juancarlos.cavero
3e74fe47f7 feat(mcp): burn the hook line by default, auto_hook=false opts out
Matches the dashboard: an agent user expects the same clips they get in
the app. The REST endpoint keeps absent=off for older integrations.
2026-08-27 20:26:57 +02:00
juancarlos.cavero
8251f4f02a feat(mcp): auto_hook and hook_style on process_video
The dashboard burns the AI hook line by default; API/MCP callers never
could because the field is off when absent. Exposed as an explicit opt-in
so existing integrations keep their output byte-for-byte.
2026-08-27 19:37:23 +02:00
juancarlos.cavero
3d637f51ce test(selection): fix the expected bisect trace 2026-08-27 19:15:36 +02:00
juancarlos.cavero
443c7980a5 fix(selection): bisect a Gemini policy block instead of failing the job
PROHIBITED_CONTENT fired on the scoring batch of a plain software
walkthrough: windows 5+6 together blocked 3/3 on lite, 3.7-flash and
2.5-flash, each alone passed, and a neutral prompt over the same text
passed. The filter reacts to combinations, so it cannot be predicted or
sanitized. Both selection passes now run through _run_stage_split: on a
block the batch is halved until the combination is isolated, and only a
window that blocks on its own is dropped. The affected job now yields 2
clips instead of dying.
2026-08-27 19:14:44 +02:00
juancarlos.cavero
22c991d22b fix(download): direct file URLs bypass the proxy chain
The ISP/paid proxies exist to dodge YouTube's ban on the server IP. A
direct mp4 (catbox, tmpfiles, a CDN, an R2 link) has nothing to dodge and
crawled at ~9 KB/s through the static proxy (6 MB in 11 min on 27-aug)
while the server's own IP pulls 17 MB/s. Non-YouTube hosts now download
direct, with one static proxy as the only fallback and never the per-GB
one.
2026-08-27 18:57:37 +02:00
juancarlos.cavero
15195f591a fix(metering): size direct video URLs with ffprobe when yt-dlp reports no duration
Cloud metering probed the source with yt-dlp only; its generic extractor
never returns a duration for a plain mp4 URL, so every direct-file job
(agent uploads on tmpfiles/uguu, a CDN link) died at submit with 'Could
not determine the video duration'. On a generic hit the probe now stops
walking proxies and reads the container header over HTTP with ffprobe
(range requests, browser UA, 30 s timeout); tmpfiles links are refreshed
first. Reported by a user driving the MCP from claude.ai.
2026-08-27 17:10:13 +02:00
juancarlos.cavero
f4c227e624 feat(mcp): tmpfiles.org fallback for agent uploads, 6 h slot expiry, DELETE /api/uploads
claude.ai's sandbox can upload to tmpfiles.org but their /dl/ links are
signed with a short-lived stamp and 302 to an HTML page once stale, which
yt-dlp cannot use. file_hosts.resolve() reads the page and takes the
fresh /dl/ link before download. create_upload now tells the agent to try
our upload_url first and fall back to tmpfiles.org. Unused slots expire
after 6 h (was 24) via _sweep_pending_uploads, and DELETE drops one early.
2026-08-27 16:36:46 +02:00
juancarlos.cavero
0a21de29a2 feat(mcp): create_upload for local files, captions switch per job
process_video now takes captions:false for sources that already carry
burned-in subtitles (maps to AUTO_CAPTIONS=0 for that job only) and
accepts upload_id as an alternative to source_url. create_upload reserves
a slot (POST /api/uploads) and returns a PUT URL the agent streams the raw
bytes to (curl -T works from any runtime); the owner recorded at reserve
time is checked at process time, files sit in UPLOAD_DIR under the usual
sweep, slots expire after 24 h. Tool count is 8 everywhere it is quoted.
2026-08-27 16:32:05 +02:00
juancarlos.cavero
ecf9b0bfec feat(thumbnail): topic-first concepts, likeness-preserving references, refine follows the requested language
Feedback from a real run: thumbnails were 'face + two words' and the
person did not look like the presenter. The concept planner now has to
show the subject (product, number, result) with props and depth, and may
use the plain face only once. Frames are kept at native resolution so the
face crop sent as reference is ~800px instead of ~500px, and the image
prompt demands the exact same real person (no idealizing, no caricature).
Refining titles in another language now updates the session language and
returns paired thumbnail texts, so the thumbnail follows the title.
2026-08-27 15:52:34 +02:00
juancarlos.cavero
fe4e256cc4 fix(thumbnail): byte-part references, public-figure fallback, frames effect race
Browser run on a real video surfaced three defects:
- references were one PIL Image shared by the worker threads; the SDK's
  encoder raced and every generation died. Now each reference is an
  immutable JPEG byte part.
- Gemini's image model refuses recognisable public figures, by reference
  photo and by name alike (IMAGE_OTHER). The concept planner no longer
  writes real names or brands into scene prompts, and a blocked render is
  retried once without the person; the card says so.
- the frames effect listed its own state as a dependency, so setting it
  re-ran the effect and the cleanup discarded the response in flight.
2026-08-27 12:21:01 +02:00
juancarlos.cavero
8c477e090d config(thumbnail): default the title model to gemini-3.7-flash
Same transcript, three models: 3.5-flash 34 s, 3.7-flash 14 s, 3.1-pro 105 s.
3.7 gave the most specific thumbnail hooks (the ones that quote a figure from
the video rather than a stock phrase) at the lowest latency.
2026-08-27 11:03:23 +02:00
juancarlos.cavero
eb6ef13bba feat(thumbnail): concept-driven thumbnails, crisp burned text, face frames from the video, scored titles
Titles: transcript + 10 frames instead of uploading the whole video (an hour
was ~1M tokens), a brainstorm across fixed styles then a critic that scores,
dedupes by angle and pairs each title with a 1-4 word thumbnail hook. Mobile
rules: payoff inside 50 chars, keyword first. Text model moves to
GEMINI_MODEL_THUMBNAIL (default gemini-3.5-flash); flash-lite is the weakest
tier and this is the one creative step.

Thumbnails: a text call designs N different concepts, one image call each in
parallel. Default burns the hook text with PIL (Anton, black stroke) over
negative space the image model is told to leave, so accents are never wrong;
'AI painted' toggle keeps the old behaviour. Outputs cover-cropped to
1280x720 under YouTube's 2 MB. GET /api/thumbnail/frames/{session} picks
frames with a large, sharp face spread across the runtime and the dashboard
offers them as the person reference. Phone-size preview row in the UI.
JSON parsing now uses raw_decode: flash appended a stray ]} once.
2026-08-27 10:57:34 +02:00