Commit graph

10 commits

Author SHA1 Message Date
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
05ef151bb1 fix(mcp): tell clients to hand the video URL straight to process_video
Connected from claude.ai, Claude tried to open the YouTube URL itself and
then web-searched it before ever calling process_video. The server
instructions and the tool/parameter descriptions now say the URL is passed
through as written and that OpenShorts does the downloading; fetching or
inspecting it first is neither possible nor needed.
2026-08-27 01:37:43 +02:00
juancarlos.cavero
83ad817a31 feat(mcp): OAuth 2.1 for claude.ai/ChatGPT, and a "connect an agent" panel
claude.ai and ChatGPT connect to a remote MCP server by URL and expect the
server to run the login: RFC 9728/8414 discovery under /.well-known/,
dynamic client registration (public clients, PKCE S256 mandatory), an
authorization endpoint and a token endpoint. The consent screen is the
dashboard (#/oauth/authorize) because the session JWT lives in localStorage
on the frontend host; the API bounces there and mints the code on a
session-authenticated POST. Redeeming the code mints an ordinary osk_ API
key named after the client and returns it as the access token, so every
existing auth, quota and ownership rule applies unchanged and the user
disconnects an app by revoking that key. The /mcp 401 now carries
WWW-Authenticate: Bearer resource_metadata=... so clients find the flow.

Dashboard: a "Connect an agent" card (Account in cloud, Settings when
self-hosted) with copy-ready setup for claude.ai, ChatGPT, Claude Code,
Claude Desktop, Cursor, n8n and curl; the clip generator links to it. The
/mcp page, README and CLAUDE.md describe the URL-only connection.
2026-08-27 01:17:49 +02:00
juancarlos.cavero
9c220efddb feat(editor): manual framing override (auto / full frame / track subject)
The scene classifier only counts faces, so a screencast-style video with a
presenter in frame gets TRACK and the crop eats the slide (the SCREENCAST/
WIDE detectors sit behind the opt-in layouts=auto flag). The clip editor now
has a framing selector that pins every scene's layout: 'full' renders the
whole source frame (WIDE: no side-crop, blurred bands), 'track' forces the
subject-tracking crop, 'auto' returns to the classifier.

Plumbed as force_strategy through reframe_v2.render -> render_clip ->
perform_recut -> /api/clip/rerender (and the recut_clip MCP tool). A
non-auto choice always re-reframes from the retained source (409 without
it) and persists in the clip's recipe, so later plain trims inherit the
look instead of silently reverting; an explicit 'auto' resets it.

Verified live: framing=full on a TRACK-cropped clip re-rendered with the
full frame visible edge to edge (125s source path), and the editor reopens
with the persisted choice preselected.
2026-08-19 01:06:48 +02:00
juancarlos.cavero
100fa583a1 Merge feat/clip-editor: per-clip EDL editor + manual generation controls (PR #62, discussion #65) 2026-08-18 19:27:49 +02:00
juancarlos.cavero
b81125c572 feat(generate): manual clip count and duration controls (discussion #65)
/api/process (and the process_video MCP tool) now accept optional
target_clips (1-15) and clip_min_seconds / clip_max_seconds (5-180),
surfaced in the dashboard as a collapsed 'advanced options' section.
Blank means the AI decides, keeping the default request byte-identical.

Plumbed through the same env overrides the A/B harness already reads:
CLIP_TARGET_MIN/MAX (existing) and a new clip_duration_bounds() in
clip_selection.py backing CLIP_MIN_SECONDS/MAX_SECONDS. The detail and
visual prompts take the band as template placeholders instead of the
hardcoded 15-60, and word-snapping enforces the same bounds. All three
knobs are honest targets, not guarantees: the model still returns fewer
clips when the material doesn't hold them, and the UI copy says so.

Verified live: target_clips=2 + band 8-15s on the demo video returned
exactly 2 clips of 13.3s and 13.7s (the uncontrolled run gave one 41.7s
clip); out-of-range values 400 with a named reason.
2026-08-18 19:21:42 +02:00
juancarlos.cavero
46c61e407b feat(mcp): list_clips renders as an MCP App clip picker in UI-capable clients
New mcp_ui module holds the template: preview each 9:16 clip inline,
select the keepers and publish them via publish_clip from inside the
conversation. One template, three data paths, because the ecosystem has
not converged: baked-in JSON on the per-call embedded resource, the
ChatGPT Apps window.openai bridge, and the MCP Apps ready/render-data
postMessage handshake. Titles are JSON-escaped so a clip name cannot
break out of the script tag, and the template is fully inline because
host CSPs block external fetches.

The server grows resources/list, resources/read and the resources
capability; list_clips declares the template under both _meta.ui
.resourceUri and openai/outputTemplate. Non-UI clients see the same
text and structured content as before; the extra content entry is
spec-tolerated. The unknown-method protocol test moves off
resources/list, which is now a real method.
2026-08-05 23:59:02 +02:00
victorcavero14
d9b15b4328 feat(editor): per-clip EDL backend — recut engine, /edl + /rerender endpoints, MCP tool
Every clip now exposes its recipe (which source segments it was cut from)
via GET /api/clip/{job}/{i}/edl, and POST /api/clip/rerender re-renders it
from an edited segment list: fast path recuts from the already-reframed
canonical file, source path re-reframes from the retained source
(--keep-original now passed for URL jobs). Captions/subtitles/transcript
remap piecewise through recut.virtual_transcript for multi-segment clips.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-05 11:03:15 +02:00
juancarlos.cavero
f10655fd1c feat(agents): the pipeline as a platform — API keys, MCP server, webhooks
Agents don't forget to come back; humans do. Make the whole pipeline
drivable without the dashboard:

- API keys (osk_...): sha256-stored tokens minted from the account page.
  get_current_user_optional resolves them like a session, so metering,
  entitlement, priority and job ownership apply to agents with zero
  endpoint changes. Key management refuses API-key auth (a leaked key
  cannot mint replacements).
- MCP server at /mcp: stateless Streamable-HTTP JSON-RPC, no SDK
  dependency. Six tools (process_video, get_job_status, list_clips,
  get_quota, add_subtitles, publish_clip) that call back into this same
  app in-process via ASGITransport with the caller's auth headers, so
  MCP can never drift from REST behavior. Cloud requires a key;
  self-host stays BYOK-open.
- Completion webhooks: webhook_url (+ optional HMAC webhook_secret) on
  /api/process, SSRF-checked at submit AND delivery, fired once after
  the R2 archive so payloads carry durable links, survives redeploys
  via the resume manifest.
- Dashboard: API keys card in the account page (create once-shown key,
  list, revoke).
- Tests pin BILLING_ENABLED=0 in conftest so the suite no longer
  depends on the developer's personal .env.
2026-08-03 22:33:16 +02:00